@builder.io/sdk-react 0.4.4 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{sdk/blocks → blocks}/BaseText.d.ts +0 -1
- package/dist/{sdk/blocks → blocks}/BaseText.js +2 -2
- package/dist/{sdk/blocks → blocks}/button/button.d.ts +3 -2
- package/dist/{sdk/blocks → blocks}/button/button.js +3 -5
- package/dist/blocks/button/component-info.d.ts +2 -0
- package/dist/{sdk/blocks → blocks}/button/component-info.js +9 -13
- package/dist/blocks/columns/columns.d.ts +16 -0
- package/dist/{sdk/blocks → blocks}/columns/columns.js +15 -21
- package/dist/blocks/columns/component-info.d.ts +2 -0
- package/dist/{sdk/blocks → blocks}/columns/component-info.js +62 -83
- package/dist/blocks/custom-code/component-info.d.ts +2 -0
- package/dist/{sdk/blocks → blocks}/custom-code/component-info.js +7 -11
- package/dist/{sdk/blocks → blocks}/custom-code/custom-code.d.ts +0 -1
- package/dist/{sdk/blocks → blocks}/custom-code/custom-code.js +1 -1
- package/dist/blocks/embed/component-info.d.ts +2 -0
- package/dist/{sdk/blocks → blocks}/embed/component-info.js +8 -15
- package/dist/{sdk/blocks → blocks}/embed/embed.d.ts +0 -1
- package/dist/{sdk/blocks → blocks}/embed/embed.js +1 -1
- package/dist/blocks/embed/helpers.js +2 -0
- package/dist/blocks/form/component-info.d.ts +2 -0
- package/dist/{sdk/blocks → blocks}/form/component-info.js +94 -129
- package/dist/blocks/form/form.d.ts +2 -0
- package/dist/blocks/form/form.js +6 -0
- package/dist/blocks/fragment/component-info.d.ts +2 -0
- package/dist/{sdk/blocks → blocks}/fragment/component-info.js +1 -1
- package/dist/{sdk/blocks → blocks}/fragment/fragment.d.ts +0 -1
- package/dist/{sdk/blocks → blocks}/fragment/fragment.js +1 -1
- package/dist/blocks/helpers.d.ts +13 -0
- package/dist/blocks/helpers.js +40 -0
- package/dist/blocks/image/component-info.d.ts +2 -0
- package/dist/{sdk/blocks → blocks}/image/component-info.js +33 -63
- package/dist/{sdk/blocks → blocks}/image/image.d.ts +0 -1
- package/dist/{sdk/blocks → blocks}/image/image.helpers.js +2 -11
- package/dist/{sdk/blocks → blocks}/image/image.js +7 -7
- package/dist/blocks/img/component-info.d.ts +2 -0
- package/dist/{sdk/blocks → blocks}/img/component-info.js +4 -6
- package/dist/{sdk/blocks → blocks}/img/img.d.ts +3 -2
- package/dist/{sdk/blocks → blocks}/img/img.js +1 -1
- package/dist/blocks/input/component-info.d.ts +2 -0
- package/dist/{sdk/blocks → blocks}/input/component-info.js +15 -40
- package/dist/{sdk/blocks → blocks}/input/input.d.ts +3 -2
- package/dist/{sdk/blocks → blocks}/input/input.js +1 -1
- package/dist/blocks/raw-text/component-info.d.ts +2 -0
- package/dist/{sdk/blocks → blocks}/raw-text/component-info.js +3 -5
- package/dist/{sdk/blocks → blocks}/raw-text/raw-text.d.ts +0 -1
- package/dist/blocks/raw-text/raw-text.js +6 -0
- package/dist/blocks/section/component-info.d.ts +2 -0
- package/dist/{sdk/blocks → blocks}/section/component-info.js +13 -18
- package/dist/{sdk/blocks → blocks}/section/section.d.ts +3 -2
- package/dist/{sdk/blocks → blocks}/section/section.js +1 -1
- package/dist/blocks/select/component-info.d.ts +2 -0
- package/dist/{sdk/blocks → blocks}/select/component-info.js +22 -34
- package/dist/{sdk/blocks → blocks}/select/select.d.ts +3 -2
- package/dist/{sdk/blocks → blocks}/select/select.js +1 -1
- package/dist/blocks/submit-button/component-info.d.ts +2 -0
- package/dist/{sdk/blocks → blocks}/submit-button/component-info.js +5 -7
- package/dist/{sdk/blocks → blocks}/submit-button/submit-button.d.ts +3 -2
- package/dist/{sdk/blocks → blocks}/submit-button/submit-button.js +1 -1
- package/dist/blocks/symbol/component-info.d.ts +2 -0
- package/dist/{sdk/blocks → blocks}/symbol/component-info.js +12 -17
- package/dist/blocks/symbol/symbol.d.ts +23 -0
- package/dist/blocks/symbol/symbol.helpers.d.ts +14 -0
- package/dist/blocks/symbol/symbol.helpers.js +31 -0
- package/dist/blocks/symbol/symbol.js +45 -0
- package/dist/blocks/text/component-info.d.ts +2 -0
- package/dist/{sdk/blocks → blocks}/text/component-info.js +6 -7
- package/dist/{sdk/blocks → blocks}/text/text.d.ts +1 -2
- package/dist/{sdk/blocks → blocks}/text/text.js +2 -2
- package/dist/blocks/textarea/component-info.d.ts +2 -0
- package/dist/{sdk/blocks → blocks}/textarea/component-info.js +13 -19
- package/dist/{sdk/blocks → blocks}/textarea/textarea.d.ts +3 -2
- package/dist/{sdk/blocks → blocks}/textarea/textarea.js +1 -1
- package/dist/blocks/video/component-info.d.ts +2 -0
- package/dist/{sdk/blocks → blocks}/video/component-info.js +35 -55
- package/dist/{sdk/blocks → blocks}/video/video.d.ts +1 -1
- package/dist/{sdk/blocks → blocks}/video/video.js +2 -2
- package/dist/components/block/block.d.ts +9 -0
- package/dist/components/block/block.helpers.d.ts +13 -0
- package/dist/{sdk/components/render-block/render-block.helpers.js → components/block/block.helpers.js} +12 -29
- package/dist/components/block/block.js +94 -0
- package/dist/{sdk/components/render-block → components/block/components}/block-styles.d.ts +2 -3
- package/dist/{sdk/components/render-block → components/block/components}/block-styles.js +23 -24
- package/dist/components/block/components/block-wrapper.d.ts +16 -0
- package/dist/components/block/components/block-wrapper.js +36 -0
- package/dist/components/block/components/component-ref/component-ref.d.ts +3 -0
- package/dist/components/block/components/component-ref/component-ref.helpers.d.ts +28 -0
- package/dist/components/block/components/component-ref/component-ref.helpers.js +22 -0
- package/dist/components/block/components/component-ref/component-ref.js +23 -0
- package/dist/components/block/components/interactive-element.d.ts +11 -0
- package/dist/components/block/components/interactive-element.js +20 -0
- package/dist/components/block/components/repeated-block.d.ts +9 -0
- package/dist/components/block/components/repeated-block.js +11 -0
- package/dist/components/blocks/blocks-wrapper.d.ts +10 -0
- package/dist/{sdk/components/render-blocks.js → components/blocks/blocks-wrapper.js} +6 -13
- package/dist/components/blocks/blocks.d.ts +8 -0
- package/dist/components/blocks/blocks.js +11 -0
- package/dist/components/content/components/enable-editor.d.ts +9 -0
- package/dist/{sdk/components/render-content/render-content.js → components/content/components/enable-editor.js} +69 -140
- package/dist/components/content/components/styles.d.ts +8 -0
- package/dist/{sdk/components/render-content/components/render-styles.helpers.d.ts → components/content/components/styles.helpers.d.ts} +1 -1
- package/dist/{sdk/components/render-content/components/render-styles.helpers.js → components/content/components/styles.helpers.js} +3 -4
- package/dist/{sdk/components/render-content/components/render-styles.js → components/content/components/styles.js} +7 -7
- package/dist/components/content/content.d.ts +3 -0
- package/dist/components/content/content.helpers.d.ts +7 -0
- package/dist/components/content/content.helpers.js +30 -0
- package/dist/components/content/content.js +79 -0
- package/dist/components/content/content.types.d.ts +24 -0
- package/dist/components/content/index.d.ts +1 -0
- package/dist/components/content/index.js +1 -0
- package/dist/components/content-variants/content-variants.d.ts +9 -0
- package/dist/components/content-variants/content-variants.js +46 -0
- package/dist/components/content-variants/content-variants.types.d.ts +20 -0
- package/dist/components/content-variants/helpers.d.ts +41 -0
- package/dist/{sdk/components/render-content-variants → components/content-variants}/helpers.js +46 -41
- package/dist/components/inlined-script.d.ts +6 -0
- package/dist/components/inlined-script.js +6 -0
- package/dist/components/inlined-styles.d.ts +6 -0
- package/dist/{sdk/components/render-inlined-styles.js → components/inlined-styles.js} +3 -3
- package/dist/{sdk/constants → constants}/builder-registered-components.js +34 -13
- package/dist/{sdk/constants → constants}/device-sizes.js +9 -8
- package/dist/constants/sdk-version.d.ts +1 -0
- package/dist/constants/sdk-version.js +1 -0
- package/dist/{sdk/context → context}/builder.context.js +1 -1
- package/dist/{sdk/context → context}/types.d.ts +1 -1
- package/dist/functions/acorn_interpreter.d.ts +1 -0
- package/dist/functions/acorn_interpreter.js +3027 -0
- package/dist/functions/apply-patch-with-mutation.d.ts +10 -0
- package/dist/functions/apply-patch-with-mutation.js +54 -0
- package/dist/functions/apply-patch-with-mutation.test.js +53 -0
- package/dist/functions/evaluate/acorn.d.ts +0 -0
- package/dist/functions/evaluate/acorn.js +2432 -0
- package/dist/{sdk/functions → functions/evaluate}/evaluate.d.ts +5 -2
- package/dist/functions/evaluate/evaluate.js +70 -0
- package/dist/functions/evaluate/evaluate.test.js +23 -0
- package/dist/functions/evaluate/index.d.ts +1 -0
- package/dist/functions/evaluate/index.js +1 -0
- package/dist/functions/evaluate/interpreter.d.ts +2 -0
- package/dist/functions/evaluate/interpreter.js +3853 -0
- package/dist/functions/evaluate/non-node-runtime.d.ts +2 -0
- package/dist/functions/evaluate/non-node-runtime.js +84 -0
- package/dist/functions/evaluate/types.d.ts +10 -0
- package/dist/functions/evaluate.d.ts +23 -0
- package/dist/{sdk/functions → functions}/evaluate.js +28 -9
- package/dist/{sdk/functions → functions}/evaluate.test.js +11 -5
- package/dist/{sdk/functions → functions}/extract-text-styles.js +2 -14
- package/dist/{sdk/functions → functions}/get-block-actions-handler.js +3 -3
- package/dist/{sdk/functions → functions}/get-block-actions.d.ts +1 -0
- package/dist/functions/get-block-actions.js +28 -0
- package/dist/{sdk/functions → functions}/get-block-component-options.js +1 -1
- package/dist/functions/get-block-properties.d.ts +6 -0
- package/dist/{sdk/functions → functions}/get-block-properties.js +15 -9
- package/dist/{sdk/functions → functions}/get-builder-search-params/fn.test.js +1 -1
- package/dist/{sdk/functions → functions}/get-builder-search-params/index.js +3 -7
- package/dist/{sdk/functions → functions}/get-content/generate-content-url.js +7 -5
- package/dist/{sdk/functions → functions}/get-content/generate-content-url.test.js +31 -17
- package/dist/{sdk/functions → functions}/get-content/index.d.ts +2 -6
- package/dist/{sdk/functions → functions}/get-content/index.js +26 -6
- package/dist/functions/get-content/processCookies.d.ts +2 -0
- package/dist/functions/get-content/processCookies.js +3 -0
- package/dist/{sdk/functions → functions}/get-processed-block.d.ts +1 -1
- package/dist/{sdk/functions → functions}/get-processed-block.js +11 -7
- package/dist/{sdk/functions → functions}/get-processed-block.test.js +8 -6
- package/dist/{sdk/functions → functions}/get-react-native-block-styles.d.ts +1 -1
- package/dist/{sdk/functions → functions}/get-react-native-block-styles.js +2 -2
- package/dist/{sdk/functions → functions}/if-target.d.ts +1 -1
- package/dist/{sdk/functions → functions}/if-target.js +1 -1
- package/dist/functions/is-editing.js +5 -0
- package/dist/functions/is-non-node-server.d.ts +4 -0
- package/dist/functions/is-non-node-server.js +8 -0
- package/dist/{sdk/functions → functions}/on-change.js +1 -1
- package/dist/{sdk/functions → functions}/on-change.test.js +13 -3
- package/dist/{sdk/functions → functions}/register-component.d.ts +2 -1
- package/dist/functions/register-component.js +38 -0
- package/dist/{sdk/functions → functions}/register.js +2 -2
- package/dist/{sdk/functions → functions}/sanitize-react-native-block-styles.js +13 -5
- package/dist/{sdk/functions → functions}/set-editor-settings.js +1 -1
- package/dist/functions/set.js +14 -0
- package/dist/{sdk/functions → functions}/set.test.js +9 -3
- package/dist/{sdk/functions → functions}/track/helpers.js +6 -11
- package/dist/{sdk/functions → functions}/track/index.js +26 -14
- package/dist/{sdk/functions → functions}/track/interaction.js +15 -16
- package/dist/functions/transform-block-properties.d.ts +1 -0
- package/dist/{sdk/functions → functions}/transform-block-properties.js +2 -0
- package/dist/{sdk/helpers → helpers}/ab-tests.d.ts +2 -2
- package/dist/{sdk/helpers → helpers}/ab-tests.js +48 -30
- package/dist/{sdk/helpers → helpers}/canTrack.js +1 -1
- package/dist/{sdk/helpers → helpers}/cookie.d.ts +2 -2
- package/dist/{sdk/helpers → helpers}/cookie.js +13 -26
- package/dist/{sdk/helpers → helpers}/css.d.ts +1 -1
- package/dist/{sdk/helpers → helpers}/css.js +1 -1
- package/dist/{sdk/helpers → helpers}/flatten.js +8 -8
- package/dist/{sdk/helpers → helpers}/localStorage.d.ts +2 -2
- package/dist/{sdk/helpers → helpers}/localStorage.js +2 -2
- package/dist/{sdk/helpers → helpers}/logger.js +1 -1
- package/dist/helpers/preview-lru-cache/get.d.ts +1 -0
- package/dist/helpers/preview-lru-cache/get.js +7 -0
- package/dist/helpers/preview-lru-cache/helpers.d.ts +1 -0
- package/dist/helpers/preview-lru-cache/helpers.js +9 -0
- package/dist/helpers/preview-lru-cache/init.d.ts +6 -0
- package/dist/helpers/preview-lru-cache/init.js +15 -0
- package/dist/helpers/preview-lru-cache/set.d.ts +7 -0
- package/dist/helpers/preview-lru-cache/set.js +9 -0
- package/dist/helpers/preview-lru-cache/types.d.ts +12 -0
- package/dist/helpers/preview-lru-cache/types.js +6 -0
- package/dist/{sdk/helpers → helpers}/sessionId.d.ts +2 -2
- package/dist/{sdk/helpers → helpers}/sessionId.js +11 -4
- package/dist/{sdk/helpers → helpers}/uuid.js +1 -1
- package/dist/{sdk/helpers → helpers}/visitorId.d.ts +1 -1
- package/dist/{sdk/helpers → helpers}/visitorId.js +7 -4
- package/dist/{sdk/index-helpers → index-helpers}/blocks-exports.d.ts +2 -2
- package/dist/{sdk/index-helpers → index-helpers}/blocks-exports.js +2 -2
- package/dist/{sdk/index.d.ts → index.d.ts} +2 -2
- package/dist/{sdk/index.js → index.js} +1 -1
- package/dist/scripts/init-editing.js +110 -0
- package/dist/types/builder-props.d.ts +9 -0
- package/dist/{sdk/types → types}/components.d.ts +8 -2
- package/dist/types/enforced-partials.d.ts +21 -0
- package/dist/types/targets.d.ts +1 -0
- package/dist/{server/types → types}/typescript.d.ts +6 -0
- package/package.json +6 -13
- package/dist/sdk/blocks/button/component-info.d.ts +0 -2
- package/dist/sdk/blocks/columns/columns.d.ts +0 -16
- package/dist/sdk/blocks/columns/component-info.d.ts +0 -2
- package/dist/sdk/blocks/custom-code/component-info.d.ts +0 -2
- package/dist/sdk/blocks/embed/component-info.d.ts +0 -2
- package/dist/sdk/blocks/embed/helpers.js +0 -6
- package/dist/sdk/blocks/form/component-info.d.ts +0 -2
- package/dist/sdk/blocks/form/form.d.ts +0 -40
- package/dist/sdk/blocks/form/form.js +0 -203
- package/dist/sdk/blocks/fragment/component-info.d.ts +0 -2
- package/dist/sdk/blocks/image/component-info.d.ts +0 -2
- package/dist/sdk/blocks/img/component-info.d.ts +0 -2
- package/dist/sdk/blocks/input/component-info.d.ts +0 -2
- package/dist/sdk/blocks/raw-text/component-info.d.ts +0 -2
- package/dist/sdk/blocks/raw-text/raw-text.js +0 -6
- package/dist/sdk/blocks/section/component-info.d.ts +0 -2
- package/dist/sdk/blocks/select/component-info.d.ts +0 -2
- package/dist/sdk/blocks/submit-button/component-info.d.ts +0 -2
- package/dist/sdk/blocks/symbol/component-info.d.ts +0 -2
- package/dist/sdk/blocks/symbol/symbol.d.ts +0 -21
- package/dist/sdk/blocks/symbol/symbol.js +0 -69
- package/dist/sdk/blocks/text/component-info.d.ts +0 -2
- package/dist/sdk/blocks/textarea/component-info.d.ts +0 -2
- package/dist/sdk/blocks/util.d.ts +0 -4
- package/dist/sdk/blocks/util.js +0 -13
- package/dist/sdk/blocks/video/component-info.d.ts +0 -2
- package/dist/sdk/components/render-block/render-block.d.ts +0 -9
- package/dist/sdk/components/render-block/render-block.helpers.d.ts +0 -12
- package/dist/sdk/components/render-block/render-block.js +0 -115
- package/dist/sdk/components/render-block/render-component.d.ts +0 -17
- package/dist/sdk/components/render-block/render-component.js +0 -11
- package/dist/sdk/components/render-block/render-repeated-block.d.ts +0 -9
- package/dist/sdk/components/render-block/render-repeated-block.js +0 -11
- package/dist/sdk/components/render-blocks.d.ts +0 -10
- package/dist/sdk/components/render-content/builder-editing.d.ts +0 -3
- package/dist/sdk/components/render-content/builder-editing.js +0 -6
- package/dist/sdk/components/render-content/components/render-styles.d.ts +0 -9
- package/dist/sdk/components/render-content/index.d.ts +0 -1
- package/dist/sdk/components/render-content/index.js +0 -1
- package/dist/sdk/components/render-content/render-content.d.ts +0 -4
- package/dist/sdk/components/render-content/render-content.helpers.d.ts +0 -7
- package/dist/sdk/components/render-content/render-content.helpers.js +0 -30
- package/dist/sdk/components/render-content/render-content.types.d.ts +0 -38
- package/dist/sdk/components/render-content-variants/helpers.d.ts +0 -17
- package/dist/sdk/components/render-content-variants/render-content-variants.d.ts +0 -5
- package/dist/sdk/components/render-content-variants/render-content-variants.js +0 -37
- package/dist/sdk/components/render-inlined-styles.d.ts +0 -7
- package/dist/sdk/constants/sdk-version.d.ts +0 -1
- package/dist/sdk/constants/sdk-version.js +0 -1
- package/dist/sdk/functions/get-block-actions.js +0 -15
- package/dist/sdk/functions/get-block-properties.d.ts +0 -7
- package/dist/sdk/functions/get-content/ab-testing.d.ts +0 -5
- package/dist/sdk/functions/get-content/ab-testing.js +0 -78
- package/dist/sdk/functions/is-editing.js +0 -7
- package/dist/sdk/functions/register-component.js +0 -26
- package/dist/sdk/functions/set.js +0 -21
- package/dist/sdk/functions/transform-block-properties.d.ts +0 -1
- package/dist/sdk/scripts/init-editing.js +0 -102
- package/dist/sdk/types/targets.d.ts +0 -3
- package/dist/sdk/types/typescript.d.ts +0 -5
- package/dist/server/functions/get-builder-search-params/index.d.ts +0 -6
- package/dist/server/functions/get-builder-search-params/index.js +0 -36
- package/dist/server/functions/get-content/ab-testing.d.ts +0 -5
- package/dist/server/functions/get-content/ab-testing.js +0 -78
- package/dist/server/functions/get-content/generate-content-url.d.ts +0 -2
- package/dist/server/functions/get-content/generate-content-url.js +0 -31
- package/dist/server/functions/get-content/generate-content-url.test.js +0 -82
- package/dist/server/functions/get-content/index.d.ts +0 -11
- package/dist/server/functions/get-content/index.js +0 -40
- package/dist/server/functions/get-content/types.d.ts +0 -45
- package/dist/server/functions/get-fetch.d.ts +0 -1
- package/dist/server/functions/get-fetch.js +0 -11
- package/dist/server/functions/get-global-this.d.ts +0 -4
- package/dist/server/functions/get-global-this.js +0 -15
- package/dist/server/functions/is-browser.d.ts +0 -1
- package/dist/server/functions/is-browser.js +0 -3
- package/dist/server/helpers/ab-tests.d.ts +0 -8
- package/dist/server/helpers/ab-tests.js +0 -5
- package/dist/server/helpers/cookie.d.ts +0 -15
- package/dist/server/helpers/cookie.js +0 -65
- package/dist/server/helpers/flatten.d.ts +0 -6
- package/dist/server/helpers/flatten.js +0 -19
- package/dist/server/helpers/logger.d.ts +0 -5
- package/dist/server/helpers/logger.js +0 -6
- package/dist/server/helpers/nullable.d.ts +0 -2
- package/dist/server/helpers/nullable.js +0 -1
- package/dist/server/helpers/url.d.ts +0 -6
- package/dist/server/helpers/url.js +0 -15
- package/dist/server/types/api-version.d.ts +0 -2
- package/dist/server/types/api-version.js +0 -1
- package/dist/server/types/builder-block.d.ts +0 -66
- package/dist/server/types/builder-content.d.ts +0 -46
- package/dist/server/types/can-track.d.ts +0 -3
- package/dist/server/types/input.d.ts +0 -121
- package/dist/server/types/typescript.js +0 -1
- /package/dist/{sdk/blocks → blocks}/embed/helpers.d.ts +0 -0
- /package/dist/{sdk/blocks → blocks}/image/image.helpers.d.ts +0 -0
- /package/dist/{sdk/components/render-block → components/block}/types.d.ts +0 -0
- /package/dist/{sdk/components/render-block → components/block}/types.js +0 -0
- /package/dist/{sdk/context/types.js → components/content/content.types.js} +0 -0
- /package/dist/{sdk/components/render-content → components/content}/wrap-component-ref.d.ts +0 -0
- /package/dist/{sdk/components/render-content → components/content}/wrap-component-ref.js +0 -0
- /package/dist/{sdk/components/render-content/render-content.types.js → components/content-variants/content-variants.types.js} +0 -0
- /package/dist/{sdk/constants → constants}/builder-registered-components.d.ts +0 -0
- /package/dist/{sdk/constants → constants}/device-sizes.d.ts +0 -0
- /package/dist/{sdk/constants → constants}/target.d.ts +0 -0
- /package/dist/{sdk/constants → constants}/target.js +0 -0
- /package/dist/{sdk/context → context}/builder.context.d.ts +0 -0
- /package/dist/{sdk/functions/get-content → context}/types.js +0 -0
- /package/dist/{sdk/functions/evaluate.test.d.ts → functions/apply-patch-with-mutation.test.d.ts} +0 -0
- /package/dist/{sdk/functions → functions}/camel-to-kebab-case.d.ts +0 -0
- /package/dist/{sdk/functions → functions}/camel-to-kebab-case.js +0 -0
- /package/dist/{sdk/functions/get-content/generate-content-url.test.d.ts → functions/evaluate/evaluate.test.d.ts} +0 -0
- /package/dist/{server/functions/get-content → functions/evaluate}/types.js +0 -0
- /package/dist/{sdk/functions/get-builder-search-params/fn.test.d.ts → functions/evaluate.test.d.ts} +0 -0
- /package/dist/{sdk/functions → functions}/event-handler-name.d.ts +0 -0
- /package/dist/{sdk/functions → functions}/event-handler-name.js +0 -0
- /package/dist/{sdk/functions → functions}/extract-text-styles.d.ts +0 -0
- /package/dist/{sdk/functions → functions}/fast-clone.d.ts +0 -0
- /package/dist/{sdk/functions → functions}/fast-clone.js +0 -0
- /package/dist/{sdk/functions → functions}/get-block-actions-handler.d.ts +0 -0
- /package/dist/{sdk/functions → functions}/get-block-component-options.d.ts +0 -0
- /package/dist/{sdk/functions/get-processed-block.test.d.ts → functions/get-builder-search-params/fn.test.d.ts} +0 -0
- /package/dist/{sdk/functions → functions}/get-builder-search-params/index.d.ts +0 -0
- /package/dist/{sdk/functions → functions}/get-content/generate-content-url.d.ts +0 -0
- /package/dist/{server/functions → functions}/get-content/generate-content-url.test.d.ts +0 -0
- /package/dist/{sdk/functions → functions}/get-content/types.d.ts +0 -0
- /package/dist/{sdk/functions/on-change.test.d.ts → functions/get-content/types.js} +0 -0
- /package/dist/{sdk/functions → functions}/get-fetch.d.ts +0 -0
- /package/dist/{sdk/functions → functions}/get-fetch.js +0 -0
- /package/dist/{sdk/functions → functions}/get-global-this.d.ts +0 -0
- /package/dist/{sdk/functions → functions}/get-global-this.js +0 -0
- /package/dist/{sdk/functions/set.test.d.ts → functions/get-processed-block.test.d.ts} +0 -0
- /package/dist/{sdk/functions → functions}/is-browser.d.ts +0 -0
- /package/dist/{sdk/functions → functions}/is-browser.js +0 -0
- /package/dist/{sdk/functions → functions}/is-editing.d.ts +0 -0
- /package/dist/{sdk/functions → functions}/is-iframe.d.ts +0 -0
- /package/dist/{sdk/functions → functions}/is-iframe.js +0 -0
- /package/dist/{sdk/functions → functions}/is-previewing.d.ts +0 -0
- /package/dist/{sdk/functions → functions}/is-previewing.js +0 -0
- /package/dist/{sdk/functions → functions}/on-change.d.ts +0 -0
- /package/dist/{sdk/helpers/url.test.d.ts → functions/on-change.test.d.ts} +0 -0
- /package/dist/{sdk/functions → functions}/register.d.ts +0 -0
- /package/dist/{sdk/functions → functions}/sanitize-react-native-block-styles.d.ts +0 -0
- /package/dist/{sdk/functions → functions}/set-editor-settings.d.ts +0 -0
- /package/dist/{sdk/functions → functions}/set.d.ts +0 -0
- /package/dist/{sdk/types/builder-block.js → functions/set.test.d.ts} +0 -0
- /package/dist/{sdk/functions → functions}/track/helpers.d.ts +0 -0
- /package/dist/{sdk/functions → functions}/track/index.d.ts +0 -0
- /package/dist/{sdk/functions → functions}/track/interaction.d.ts +0 -0
- /package/dist/{sdk/functions → functions}/transform-block.d.ts +0 -0
- /package/dist/{sdk/functions → functions}/transform-block.js +0 -0
- /package/dist/{sdk/helpers → helpers}/canTrack.d.ts +0 -0
- /package/dist/{sdk/helpers → helpers}/flatten.d.ts +0 -0
- /package/dist/{sdk/helpers → helpers}/logger.d.ts +0 -0
- /package/dist/{sdk/helpers → helpers}/nullable.d.ts +0 -0
- /package/dist/{sdk/helpers → helpers}/nullable.js +0 -0
- /package/dist/{sdk/helpers → helpers}/time.d.ts +0 -0
- /package/dist/{sdk/helpers → helpers}/time.js +0 -0
- /package/dist/{sdk/helpers → helpers}/url.d.ts +0 -0
- /package/dist/{sdk/helpers → helpers}/url.js +0 -0
- /package/dist/{sdk/types/builder-content.js → helpers/url.test.d.ts} +0 -0
- /package/dist/{sdk/helpers → helpers}/url.test.js +0 -0
- /package/dist/{sdk/helpers → helpers}/uuid.d.ts +0 -0
- /package/dist/{sdk/index-helpers → index-helpers}/top-of-file.d.ts +0 -0
- /package/dist/{sdk/index-helpers → index-helpers}/top-of-file.js +0 -0
- /package/dist/{sdk/scripts → scripts}/init-editing.d.ts +0 -0
- /package/dist/{sdk/types → types}/api-version.d.ts +0 -0
- /package/dist/{sdk/types → types}/api-version.js +0 -0
- /package/dist/{sdk/types → types}/builder-block.d.ts +0 -0
- /package/dist/{server/types → types}/builder-block.js +0 -0
- /package/dist/{sdk/types → types}/builder-content.d.ts +0 -0
- /package/dist/{server/types → types}/builder-content.js +0 -0
- /package/dist/{sdk/types/can-track.js → types/builder-props.js} +0 -0
- /package/dist/{sdk/types → types}/can-track.d.ts +0 -0
- /package/dist/{server/types → types}/can-track.js +0 -0
- /package/dist/{sdk/types → types}/components.js +0 -0
- /package/dist/{sdk/types → types}/deep-partial.d.ts +0 -0
- /package/dist/{sdk/types → types}/deep-partial.js +0 -0
- /package/dist/{sdk/types → types}/element.d.ts +0 -0
- /package/dist/{sdk/types → types}/element.js +0 -0
- /package/dist/{sdk/types/input.js → types/enforced-partials.js} +0 -0
- /package/dist/{sdk/types → types}/input.d.ts +0 -0
- /package/dist/{server/types → types}/input.js +0 -0
- /package/dist/{sdk/types → types}/targets.js +0 -0
- /package/dist/{sdk/types → types}/typescript.js +0 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { getBlockProperties } from '../../../../functions/get-block-properties.js';
|
|
2
|
+
export const getWrapperProps = ({ componentOptions, builderBlock, context, componentRef, includeBlockProps, isInteractive, contextValue }) => {
|
|
3
|
+
const interactiveElementProps = {
|
|
4
|
+
Wrapper: componentRef,
|
|
5
|
+
block: builderBlock,
|
|
6
|
+
context,
|
|
7
|
+
wrapperProps: componentOptions
|
|
8
|
+
};
|
|
9
|
+
return isInteractive ? interactiveElementProps : {
|
|
10
|
+
...componentOptions,
|
|
11
|
+
/**
|
|
12
|
+
* If `noWrap` is set to `true`, then the block's props/attributes are provided to the
|
|
13
|
+
* component itself directly. Otherwise, they are provided to the wrapper element.
|
|
14
|
+
*/
|
|
15
|
+
...(includeBlockProps ? {
|
|
16
|
+
attributes: getBlockProperties({
|
|
17
|
+
block: builderBlock,
|
|
18
|
+
context: contextValue
|
|
19
|
+
})
|
|
20
|
+
} : {})
|
|
21
|
+
};
|
|
22
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
import BlockStyles from "../block-styles";
|
|
5
|
+
import Block from "../../block";
|
|
6
|
+
import InteractiveElement from "../interactive-element";
|
|
7
|
+
import { getWrapperProps } from "./component-ref.helpers.js";
|
|
8
|
+
function ComponentRef(props) {
|
|
9
|
+
const [Wrapper, setWrapper] = useState(() => props.isInteractive ? InteractiveElement : props.componentRef);
|
|
10
|
+
return (React.createElement(React.Fragment, null, props.componentRef ? (React.createElement(React.Fragment, null,
|
|
11
|
+
React.createElement(Wrapper, { ...getWrapperProps({
|
|
12
|
+
componentOptions: props.componentOptions,
|
|
13
|
+
builderBlock: props.builderBlock,
|
|
14
|
+
context: props.context,
|
|
15
|
+
componentRef: props.componentRef,
|
|
16
|
+
includeBlockProps: props.includeBlockProps,
|
|
17
|
+
isInteractive: props.isInteractive,
|
|
18
|
+
contextValue: props.context,
|
|
19
|
+
}) },
|
|
20
|
+
props.blockChildren?.map((child) => (React.createElement(Block, { key: "block-" + child.id, block: child, context: props.context, registeredComponents: props.registeredComponents }))),
|
|
21
|
+
props.blockChildren?.map((child) => (React.createElement(BlockStyles, { key: "block-style-" + child.id, block: child, context: props.context })))))) : null));
|
|
22
|
+
}
|
|
23
|
+
export default ComponentRef;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type InteractiveElementProps = {
|
|
2
|
+
Wrapper: any;
|
|
3
|
+
block: BuilderBlock;
|
|
4
|
+
context: BuilderContextInterface;
|
|
5
|
+
wrapperProps: object;
|
|
6
|
+
};
|
|
7
|
+
import type { BuilderContextInterface } from "../../../context/types.js";
|
|
8
|
+
import type { BuilderBlock } from "../../../types/builder-block.js";
|
|
9
|
+
import type { PropsWithChildren } from "../../../types/typescript.js";
|
|
10
|
+
declare function InteractiveElement(props: PropsWithChildren<InteractiveElementProps>): JSX.Element;
|
|
11
|
+
export default InteractiveElement;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { getBlockActions } from "../../../functions/get-block-actions.js";
|
|
4
|
+
import { getBlockProperties } from "../../../functions/get-block-properties.js";
|
|
5
|
+
function InteractiveElement(props) {
|
|
6
|
+
return (React.createElement(props.Wrapper, { ...props.wrapperProps, attributes: {
|
|
7
|
+
...getBlockProperties({
|
|
8
|
+
block: props.block,
|
|
9
|
+
context: props.context,
|
|
10
|
+
}),
|
|
11
|
+
...getBlockActions({
|
|
12
|
+
block: props.block,
|
|
13
|
+
rootState: props.context.rootState,
|
|
14
|
+
rootSetState: props.context.rootSetState,
|
|
15
|
+
localState: props.context.localState,
|
|
16
|
+
context: props.context.context,
|
|
17
|
+
}),
|
|
18
|
+
} }, props.children));
|
|
19
|
+
}
|
|
20
|
+
export default InteractiveElement;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
type Props = {
|
|
2
|
+
block: BuilderBlock;
|
|
3
|
+
repeatContext: BuilderContextInterface;
|
|
4
|
+
registeredComponents: RegisteredComponents;
|
|
5
|
+
};
|
|
6
|
+
import type { BuilderContextInterface, RegisteredComponents } from "../../../context/types.js";
|
|
7
|
+
import type { BuilderBlock } from "../../../types/builder-block.js";
|
|
8
|
+
declare function RepeatedBlock(props: Props): JSX.Element;
|
|
9
|
+
export default RepeatedBlock;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
import BuilderContext from "../../../context/builder.context";
|
|
5
|
+
import Block from "../block";
|
|
6
|
+
function RepeatedBlock(props) {
|
|
7
|
+
const [store, setStore] = useState(() => props.repeatContext);
|
|
8
|
+
return (React.createElement(BuilderContext.Provider, { value: store },
|
|
9
|
+
React.createElement(Block, { block: props.block, context: store, registeredComponents: props.registeredComponents })));
|
|
10
|
+
}
|
|
11
|
+
export default RepeatedBlock;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type BlocksWrapperProps = {
|
|
2
|
+
blocks: BuilderBlock[] | undefined;
|
|
3
|
+
parent: string | undefined;
|
|
4
|
+
path: string | undefined;
|
|
5
|
+
styleProp: Record<string, any> | undefined;
|
|
6
|
+
};
|
|
7
|
+
import type { BuilderBlock } from "../../types/builder-block.js";
|
|
8
|
+
import type { PropsWithChildren } from "../../types/typescript.js";
|
|
9
|
+
declare function BlocksWrapper(props: PropsWithChildren<BlocksWrapperProps>): JSX.Element;
|
|
10
|
+
export default BlocksWrapper;
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
"use client";
|
|
2
2
|
import * as React from "react";
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
import { isEditing } from "../functions/is-editing.js";
|
|
6
|
-
import BlockStyles from "./render-block/block-styles";
|
|
7
|
-
import RenderBlock from "./render-block/render-block";
|
|
8
|
-
function RenderBlocks(props) {
|
|
3
|
+
import { isEditing } from "../../functions/is-editing.js";
|
|
4
|
+
function BlocksWrapper(props) {
|
|
9
5
|
function className() {
|
|
10
6
|
return "builder-blocks" + (!props.blocks?.length ? " no-blocks" : "");
|
|
11
7
|
}
|
|
@@ -31,15 +27,12 @@ function RenderBlocks(props) {
|
|
|
31
27
|
}, "*");
|
|
32
28
|
}
|
|
33
29
|
}
|
|
34
|
-
const builderContext = useContext(BuilderContext);
|
|
35
30
|
return (React.createElement(React.Fragment, null,
|
|
36
|
-
React.createElement("div", { className: className() + " div-
|
|
37
|
-
|
|
38
|
-
props.blocks ? (React.createElement(React.Fragment, null, props.blocks?.map((block) => (React.createElement(BlockStyles, { key: "block-style-" + block.id, block: block, context: builderContext }))))) : null),
|
|
39
|
-
React.createElement("style", null, `.div-6dd9939e {
|
|
31
|
+
React.createElement("div", { className: className() + " div-b2473120", "builder-path": props.path, "builder-parent-id": props.parent, style: props.styleProp, onClick: (event) => onClick(), onMouseEnter: (event) => onMouseEnter(), onKeyPress: (event) => onClick() }, props.children),
|
|
32
|
+
React.createElement("style", null, `.div-b2473120 {
|
|
40
33
|
display: flex;
|
|
41
34
|
flex-direction: column;
|
|
42
35
|
align-items: stretch;
|
|
43
36
|
}`)));
|
|
44
37
|
}
|
|
45
|
-
export default
|
|
38
|
+
export default BlocksWrapper;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type BlocksProps = Partial<BlocksWrapperProps> & {
|
|
2
|
+
context: BuilderContextInterface;
|
|
3
|
+
registeredComponents: RegisteredComponents;
|
|
4
|
+
};
|
|
5
|
+
import type { BlocksWrapperProps } from "./blocks-wrapper";
|
|
6
|
+
import type { BuilderContextInterface, RegisteredComponents } from "../../context/types.js";
|
|
7
|
+
declare function Blocks(props: BlocksProps): JSX.Element;
|
|
8
|
+
export default Blocks;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import BlockStyles from "../block/components/block-styles";
|
|
4
|
+
import Block from "../block/block";
|
|
5
|
+
import BlocksWrapper from "./blocks-wrapper";
|
|
6
|
+
function Blocks(props) {
|
|
7
|
+
return (React.createElement(BlocksWrapper, { blocks: props.blocks, parent: props.parent, path: props.path, styleProp: props.styleProp },
|
|
8
|
+
props.blocks ? (React.createElement(React.Fragment, null, props.blocks?.map((block) => (React.createElement(Block, { key: "render-block-" + block.id, block: block, context: props.context, registeredComponents: props.registeredComponents }))))) : null,
|
|
9
|
+
props.blocks ? (React.createElement(React.Fragment, null, props.blocks?.map((block) => (React.createElement(BlockStyles, { key: "block-style-" + block.id, block: block, context: props.context }))))) : null));
|
|
10
|
+
}
|
|
11
|
+
export default Blocks;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
type BuilderEditorProps = Omit<ContentProps, "customComponents" | "data" | "apiVersion" | "isSsrAbTest"> & {
|
|
2
|
+
builderContextSignal: BuilderContextInterface;
|
|
3
|
+
setBuilderContextSignal?: (signal: any) => any;
|
|
4
|
+
children?: any;
|
|
5
|
+
};
|
|
6
|
+
import type { BuilderContextInterface } from "../../../context/types.js";
|
|
7
|
+
import type { ContentProps } from "../content.types.js";
|
|
8
|
+
declare function EnableEditor(props: BuilderEditorProps): JSX.Element;
|
|
9
|
+
export default EnableEditor;
|
|
@@ -1,69 +1,45 @@
|
|
|
1
|
-
|
|
1
|
+
"use client";
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import { useState, useRef, useEffect } from "react";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import {
|
|
17
|
-
|
|
18
|
-
import { getInteractionPropertiesForEvent } from "../../functions/track/interaction.js";
|
|
19
|
-
import { getContentInitialValue, getContextStateInitialValue, } from "./render-content.helpers.js";
|
|
20
|
-
import { TARGET } from "../../constants/target.js";
|
|
21
|
-
import { logger } from "../../helpers/logger.js";
|
|
22
|
-
import { getRenderContentScriptString } from "../render-content-variants/helpers.js";
|
|
23
|
-
import { wrapComponentRef } from "./wrap-component-ref.js";
|
|
24
|
-
function RenderContent(props) {
|
|
4
|
+
import { evaluate } from "../../../functions/evaluate";
|
|
5
|
+
import { fetch } from "../../../functions/get-fetch.js";
|
|
6
|
+
import { isBrowser } from "../../../functions/is-browser.js";
|
|
7
|
+
import { isEditing } from "../../../functions/is-editing.js";
|
|
8
|
+
import { createRegisterComponentMessage } from "../../../functions/register-component.js";
|
|
9
|
+
import { _track } from "../../../functions/track/index.js";
|
|
10
|
+
import builderContext from "../../../context/builder.context";
|
|
11
|
+
import { registerInsertMenu, setupBrowserForEditing, } from "../../../scripts/init-editing.js";
|
|
12
|
+
import { checkIsDefined } from "../../../helpers/nullable.js";
|
|
13
|
+
import { getInteractionPropertiesForEvent } from "../../../functions/track/interaction.js";
|
|
14
|
+
import { logger } from "../../../helpers/logger.js";
|
|
15
|
+
import { getContent } from "../../../functions/get-content/index.js";
|
|
16
|
+
import { isPreviewing } from "../../../functions/is-previewing.js";
|
|
17
|
+
function EnableEditor(props) {
|
|
25
18
|
const elementRef = useRef(null);
|
|
19
|
+
const [canTrackToUse, setCanTrackToUse] = useState(() => checkIsDefined(props.canTrack) ? props.canTrack : true);
|
|
26
20
|
const [forceReRenderCount, setForceReRenderCount] = useState(() => 0);
|
|
27
|
-
const [overrideContent, setOverrideContent] = useState(() => null);
|
|
28
21
|
function mergeNewContent(newContent) {
|
|
29
|
-
|
|
30
|
-
...
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
...
|
|
34
|
-
data
|
|
35
|
-
...builderContextSignal.content?.data,
|
|
36
|
-
...newContent?.data,
|
|
37
|
-
},
|
|
38
|
-
meta: {
|
|
39
|
-
...builderContextSignal.content?.meta,
|
|
40
|
-
...newContent?.meta,
|
|
41
|
-
breakpoints: newContent?.meta?.breakpoints ||
|
|
42
|
-
builderContextSignal.content?.meta?.breakpoints,
|
|
43
|
-
},
|
|
22
|
+
const newContentValue = {
|
|
23
|
+
...props.builderContextSignal.content,
|
|
24
|
+
...newContent,
|
|
25
|
+
data: {
|
|
26
|
+
...props.builderContextSignal.content?.data,
|
|
27
|
+
...newContent?.data,
|
|
44
28
|
},
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
content: {
|
|
51
|
-
...builderContextSignal.content,
|
|
52
|
-
meta: {
|
|
53
|
-
...builderContextSignal.content?.meta,
|
|
54
|
-
breakpoints,
|
|
55
|
-
},
|
|
29
|
+
meta: {
|
|
30
|
+
...props.builderContextSignal.content?.meta,
|
|
31
|
+
...newContent?.meta,
|
|
32
|
+
breakpoints: newContent?.meta?.breakpoints ||
|
|
33
|
+
props.builderContextSignal.content?.meta?.breakpoints,
|
|
56
34
|
},
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
const [update, setUpdate] = useState(() => 0);
|
|
60
|
-
const [canTrackToUse, setCanTrackToUse] = useState(() => checkIsDefined(props.canTrack) ? props.canTrack : true);
|
|
61
|
-
function contentSetState(newRootState) {
|
|
62
|
-
setBuilderContextSignal((PREVIOUS_VALUE) => ({
|
|
35
|
+
};
|
|
36
|
+
props.setBuilderContextSignal((PREVIOUS_VALUE) => ({
|
|
63
37
|
...PREVIOUS_VALUE,
|
|
64
|
-
|
|
38
|
+
content: newContentValue,
|
|
65
39
|
}));
|
|
66
40
|
}
|
|
41
|
+
const [lastUpdated, setLastUpdated] = useState(() => 0);
|
|
42
|
+
const [shouldSendResetCookie, setShouldSendResetCookie] = useState(() => false);
|
|
67
43
|
function processMessage(event) {
|
|
68
44
|
const { data } = event;
|
|
69
45
|
if (data) {
|
|
@@ -71,11 +47,16 @@ function RenderContent(props) {
|
|
|
71
47
|
case "builder.configureSdk": {
|
|
72
48
|
const messageContent = data.data;
|
|
73
49
|
const { breakpoints, contentId } = messageContent;
|
|
74
|
-
if (!contentId ||
|
|
50
|
+
if (!contentId ||
|
|
51
|
+
contentId !== props.builderContextSignal.content?.id) {
|
|
75
52
|
return;
|
|
76
53
|
}
|
|
77
54
|
if (breakpoints) {
|
|
78
|
-
|
|
55
|
+
mergeNewContent({
|
|
56
|
+
meta: {
|
|
57
|
+
breakpoints,
|
|
58
|
+
},
|
|
59
|
+
});
|
|
79
60
|
}
|
|
80
61
|
setForceReRenderCount(forceReRenderCount + 1); // This is a hack to force Qwik to re-render.
|
|
81
62
|
break;
|
|
@@ -93,32 +74,28 @@ function RenderContent(props) {
|
|
|
93
74
|
}
|
|
94
75
|
break;
|
|
95
76
|
}
|
|
96
|
-
case "builder.patchUpdates": {
|
|
97
|
-
// TODO
|
|
98
|
-
break;
|
|
99
|
-
}
|
|
100
77
|
}
|
|
101
78
|
}
|
|
102
79
|
}
|
|
103
80
|
function evaluateJsCode() {
|
|
104
81
|
// run any dynamic JS code attached to content
|
|
105
|
-
const jsCode = builderContextSignal.content?.data?.jsCode;
|
|
82
|
+
const jsCode = props.builderContextSignal.content?.data?.jsCode;
|
|
106
83
|
if (jsCode) {
|
|
107
84
|
evaluate({
|
|
108
85
|
code: jsCode,
|
|
109
86
|
context: props.context || {},
|
|
110
87
|
localState: undefined,
|
|
111
|
-
rootState: builderContextSignal.rootState,
|
|
112
|
-
rootSetState:
|
|
88
|
+
rootState: props.builderContextSignal.rootState,
|
|
89
|
+
rootSetState: props.builderContextSignal.rootSetState,
|
|
113
90
|
});
|
|
114
91
|
}
|
|
115
92
|
}
|
|
116
93
|
const [httpReqsData, setHttpReqsData] = useState(() => ({}));
|
|
117
94
|
const [clicked, setClicked] = useState(() => false);
|
|
118
95
|
function onClick(event) {
|
|
119
|
-
if (builderContextSignal.content) {
|
|
120
|
-
const variationId = builderContextSignal.content?.testVariationId;
|
|
121
|
-
const contentId = builderContextSignal.content?.id;
|
|
96
|
+
if (props.builderContextSignal.content) {
|
|
97
|
+
const variationId = props.builderContextSignal.content?.testVariationId;
|
|
98
|
+
const contentId = props.builderContextSignal.content?.id;
|
|
122
99
|
_track({
|
|
123
100
|
type: "click",
|
|
124
101
|
canTrack: canTrackToUse,
|
|
@@ -138,8 +115,8 @@ function RenderContent(props) {
|
|
|
138
115
|
code: group,
|
|
139
116
|
context: props.context || {},
|
|
140
117
|
localState: undefined,
|
|
141
|
-
rootState: builderContextSignal.rootState,
|
|
142
|
-
rootSetState:
|
|
118
|
+
rootState: props.builderContextSignal.rootState,
|
|
119
|
+
rootSetState: props.builderContextSignal.rootSetState,
|
|
143
120
|
}));
|
|
144
121
|
}
|
|
145
122
|
function handleRequest({ url, key }) {
|
|
@@ -147,17 +124,18 @@ function RenderContent(props) {
|
|
|
147
124
|
.then((response) => response.json())
|
|
148
125
|
.then((json) => {
|
|
149
126
|
const newState = {
|
|
150
|
-
...builderContextSignal.rootState,
|
|
127
|
+
...props.builderContextSignal.rootState,
|
|
151
128
|
[key]: json,
|
|
152
129
|
};
|
|
153
|
-
|
|
130
|
+
props.builderContextSignal.rootSetState?.(newState);
|
|
131
|
+
httpReqsData[key] = true;
|
|
154
132
|
})
|
|
155
133
|
.catch((err) => {
|
|
156
134
|
console.error("error fetching dynamic data", url, err);
|
|
157
135
|
});
|
|
158
136
|
}
|
|
159
137
|
function runHttpRequests() {
|
|
160
|
-
const requests = builderContextSignal.content?.data?.httpRequests ?? {};
|
|
138
|
+
const requests = props.builderContextSignal.content?.data?.httpRequests ?? {};
|
|
161
139
|
Object.entries(requests).forEach(([key, url]) => {
|
|
162
140
|
if (url && (!httpReqsData[key] || isEditing())) {
|
|
163
141
|
const evaluatedUrl = evalExpression(url);
|
|
@@ -172,7 +150,7 @@ function RenderContent(props) {
|
|
|
172
150
|
if (isEditing()) {
|
|
173
151
|
window.dispatchEvent(new CustomEvent("builder:component:stateChange", {
|
|
174
152
|
detail: {
|
|
175
|
-
state: builderContextSignal.rootState,
|
|
153
|
+
state: props.builderContextSignal.rootState,
|
|
176
154
|
ref: {
|
|
177
155
|
name: props.model,
|
|
178
156
|
},
|
|
@@ -180,44 +158,6 @@ function RenderContent(props) {
|
|
|
180
158
|
}));
|
|
181
159
|
}
|
|
182
160
|
}
|
|
183
|
-
const [scriptStr, setScriptStr] = useState(() => getRenderContentScriptString({
|
|
184
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-non-null-asserted-optional-chain
|
|
185
|
-
contentId: props.content?.id,
|
|
186
|
-
parentContentId: props.parentContentId,
|
|
187
|
-
}));
|
|
188
|
-
const [builderContextSignal, setBuilderContextSignal] = useState(() => ({
|
|
189
|
-
content: getContentInitialValue({
|
|
190
|
-
content: props.content,
|
|
191
|
-
data: props.data,
|
|
192
|
-
}),
|
|
193
|
-
localState: undefined,
|
|
194
|
-
rootState: getContextStateInitialValue({
|
|
195
|
-
content: props.content,
|
|
196
|
-
data: props.data,
|
|
197
|
-
locale: props.locale,
|
|
198
|
-
}),
|
|
199
|
-
rootSetState: contentSetState,
|
|
200
|
-
context: props.context || {},
|
|
201
|
-
apiKey: props.apiKey,
|
|
202
|
-
apiVersion: props.apiVersion,
|
|
203
|
-
registeredComponents: [
|
|
204
|
-
...getDefaultRegisteredComponents(),
|
|
205
|
-
// While this `components` object is deprecated, we must maintain support for it.
|
|
206
|
-
// Since users are able to override our default components, we need to make sure that we do not break such
|
|
207
|
-
// existing usage.
|
|
208
|
-
// This is why we spread `components` after the default Builder.io components, but before the `props.customComponents`,
|
|
209
|
-
// which is the new standard way of providing custom components, and must therefore take precedence.
|
|
210
|
-
...components,
|
|
211
|
-
...(props.customComponents || []),
|
|
212
|
-
].reduce((acc, { component, ...curr }) => ({
|
|
213
|
-
...acc,
|
|
214
|
-
[curr.name]: {
|
|
215
|
-
component: TARGET === "vue3" ? wrapComponentRef(component) : component,
|
|
216
|
-
...curr,
|
|
217
|
-
},
|
|
218
|
-
}), {}),
|
|
219
|
-
inheritedStyles: {},
|
|
220
|
-
}));
|
|
221
161
|
useEffect(() => {
|
|
222
162
|
if (!props.apiKey) {
|
|
223
163
|
logger.error("No API key provided to `RenderContent` component. This can cause issues. Please provide an API key using the `apiKey` prop.");
|
|
@@ -225,6 +165,7 @@ function RenderContent(props) {
|
|
|
225
165
|
if (isBrowser()) {
|
|
226
166
|
if (isEditing()) {
|
|
227
167
|
setForceReRenderCount(forceReRenderCount + 1);
|
|
168
|
+
window.addEventListener("message", processMessage);
|
|
228
169
|
registerInsertMenu();
|
|
229
170
|
setupBrowserForEditing({
|
|
230
171
|
...(props.locale
|
|
@@ -243,16 +184,15 @@ function RenderContent(props) {
|
|
|
243
184
|
}
|
|
244
185
|
: {}),
|
|
245
186
|
});
|
|
246
|
-
Object.values(builderContextSignal.
|
|
187
|
+
Object.values(props.builderContextSignal.componentInfos).forEach((registeredComponent) => {
|
|
247
188
|
const message = createRegisterComponentMessage(registeredComponent);
|
|
248
189
|
window.parent?.postMessage(message, "*");
|
|
249
190
|
});
|
|
250
|
-
window.addEventListener("message", processMessage);
|
|
251
191
|
window.addEventListener("builder:component:stateChangeListenerActivated", emitStateUpdate);
|
|
252
192
|
}
|
|
253
|
-
if (builderContextSignal.content) {
|
|
254
|
-
const variationId = builderContextSignal.content?.testVariationId;
|
|
255
|
-
const contentId = builderContextSignal.content?.id;
|
|
193
|
+
if (props.builderContextSignal.content) {
|
|
194
|
+
const variationId = props.builderContextSignal.content?.testVariationId;
|
|
195
|
+
const contentId = props.builderContextSignal.content?.id;
|
|
256
196
|
_track({
|
|
257
197
|
type: "impression",
|
|
258
198
|
canTrack: canTrackToUse,
|
|
@@ -280,7 +220,7 @@ function RenderContent(props) {
|
|
|
280
220
|
getContent({
|
|
281
221
|
model: props.model,
|
|
282
222
|
apiKey: props.apiKey,
|
|
283
|
-
apiVersion: props.apiVersion,
|
|
223
|
+
apiVersion: props.builderContextSignal.apiVersion,
|
|
284
224
|
}).then((content) => {
|
|
285
225
|
if (content) {
|
|
286
226
|
mergeNewContent(content);
|
|
@@ -298,18 +238,19 @@ function RenderContent(props) {
|
|
|
298
238
|
mergeNewContent(props.content);
|
|
299
239
|
}
|
|
300
240
|
}, [props.content]);
|
|
241
|
+
useEffect(() => { }, [shouldSendResetCookie]);
|
|
301
242
|
useEffect(() => {
|
|
302
243
|
evaluateJsCode();
|
|
303
244
|
}, [
|
|
304
|
-
builderContextSignal.content?.data?.jsCode,
|
|
305
|
-
builderContextSignal.rootState,
|
|
245
|
+
props.builderContextSignal.content?.data?.jsCode,
|
|
246
|
+
props.builderContextSignal.rootState,
|
|
306
247
|
]);
|
|
307
248
|
useEffect(() => {
|
|
308
249
|
runHttpRequests();
|
|
309
|
-
}, [builderContextSignal.content?.data?.httpRequests]);
|
|
250
|
+
}, [props.builderContextSignal.content?.data?.httpRequests]);
|
|
310
251
|
useEffect(() => {
|
|
311
252
|
emitStateUpdate();
|
|
312
|
-
}, [builderContextSignal.rootState]);
|
|
253
|
+
}, [props.builderContextSignal.rootState]);
|
|
313
254
|
useEffect(() => {
|
|
314
255
|
return () => {
|
|
315
256
|
if (isBrowser()) {
|
|
@@ -318,24 +259,12 @@ function RenderContent(props) {
|
|
|
318
259
|
}
|
|
319
260
|
};
|
|
320
261
|
}, []);
|
|
321
|
-
return (React.createElement(builderContext.Provider, { value: builderContextSignal }, builderContextSignal.content ? (React.createElement(React.Fragment, null,
|
|
322
|
-
React.createElement("div", { ref: elementRef, onClick: (event) => onClick(event), "builder-content-id": builderContextSignal.content?.id, "builder-model": props.model, ...(
|
|
323
|
-
? {
|
|
324
|
-
|
|
325
|
-
// currently, we can't set the actual ID here. // we don't need it right now, we just need to identify content divs for testing.
|
|
326
|
-
"builder-content-id": "",
|
|
327
|
-
},
|
|
328
|
-
}
|
|
329
|
-
: {}), ...(props.hideContent
|
|
330
|
-
? {
|
|
262
|
+
return (React.createElement(builderContext.Provider, { value: props.builderContextSignal }, props.builderContextSignal.content ? (React.createElement(React.Fragment, null,
|
|
263
|
+
React.createElement("div", { key: forceReRenderCount, ref: elementRef, onClick: (event) => onClick(event), "builder-content-id": props.builderContextSignal.content?.id, "builder-model": props.model, ...(props.showContent
|
|
264
|
+
? {}
|
|
265
|
+
: {
|
|
331
266
|
hidden: true,
|
|
332
267
|
"aria-hidden": true,
|
|
333
|
-
}
|
|
334
|
-
: {}), className: props.classNameProp },
|
|
335
|
-
props.isSsrAbTest ? (React.createElement(React.Fragment, null,
|
|
336
|
-
React.createElement("script", { dangerouslySetInnerHTML: { __html: scriptStr } }))) : null,
|
|
337
|
-
TARGET !== "reactNative" ? (React.createElement(React.Fragment, null,
|
|
338
|
-
React.createElement(RenderContentStyles, { contentId: builderContextSignal.content?.id, cssCode: builderContextSignal.content?.data?.cssCode, customFonts: builderContextSignal.content?.data?.customFonts }))) : null,
|
|
339
|
-
React.createElement(RenderBlocks, { blocks: builderContextSignal.content?.data?.blocks, key: forceReRenderCount })))) : null));
|
|
268
|
+
}), className: props.classNameProp }, props.children))) : null));
|
|
340
269
|
}
|
|
341
|
-
export default
|
|
270
|
+
export default EnableEditor;
|
|
@@ -9,7 +9,7 @@ export interface CustomFont {
|
|
|
9
9
|
export declare const getFontCss: ({ customFonts }: {
|
|
10
10
|
customFonts?: CustomFont[];
|
|
11
11
|
}) => string;
|
|
12
|
-
export declare const getCss: ({ cssCode, contentId
|
|
12
|
+
export declare const getCss: ({ cssCode, contentId }: {
|
|
13
13
|
cssCode?: string;
|
|
14
14
|
contentId?: string;
|
|
15
15
|
}) => string;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
const getCssFromFont = (font) => {
|
|
2
2
|
// TODO: compute what font sizes are used and only load those.......
|
|
3
|
-
const family = font.family +
|
|
4
|
-
(font.kind && !font.kind.includes('#') ? ', ' + font.kind : '');
|
|
3
|
+
const family = font.family + (font.kind && !font.kind.includes('#') ? ', ' + font.kind : '');
|
|
5
4
|
const name = family.split(',')[0];
|
|
6
5
|
const url = font.fileUrl ?? font?.files?.regular;
|
|
7
6
|
let str = '';
|
|
@@ -43,9 +42,9 @@ export const getFontCss = ({ customFonts }) => {
|
|
|
43
42
|
// return '';
|
|
44
43
|
// }
|
|
45
44
|
// TODO: separate internal data from external
|
|
46
|
-
return customFonts?.map(
|
|
45
|
+
return customFonts?.map(font => getCssFromFont(font))?.join(' ') || '';
|
|
47
46
|
};
|
|
48
|
-
export const getCss = ({ cssCode, contentId
|
|
47
|
+
export const getCss = ({ cssCode, contentId }) => {
|
|
49
48
|
if (!cssCode) {
|
|
50
49
|
return '';
|
|
51
50
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
"use client";
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import { useState } from "react";
|
|
4
|
-
import
|
|
5
|
-
import { getCss } from "./
|
|
6
|
-
import { getFontCss } from "./
|
|
7
|
-
function
|
|
4
|
+
import InlinedStyles from "../../inlined-styles";
|
|
5
|
+
import { getCss } from "./styles.helpers.js";
|
|
6
|
+
import { getFontCss } from "./styles.helpers.js";
|
|
7
|
+
function ContentStyles(props) {
|
|
8
8
|
const [injectedStyles, setInjectedStyles] = useState(() => `
|
|
9
9
|
${getCss({
|
|
10
10
|
cssCode: props.cssCode,
|
|
@@ -27,6 +27,6 @@ ${getFontCss({
|
|
|
27
27
|
font-family: inherit;
|
|
28
28
|
}
|
|
29
29
|
`.trim());
|
|
30
|
-
return React.createElement(
|
|
30
|
+
return React.createElement(InlinedStyles, { styles: injectedStyles });
|
|
31
31
|
}
|
|
32
|
-
export default
|
|
32
|
+
export default ContentStyles;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { BuilderContent } from '../../types/builder-content.js';
|
|
2
|
+
import type { Nullable } from '../../types/typescript.js';
|
|
3
|
+
import type { ContentProps } from './content.types.js';
|
|
4
|
+
export declare const getContextStateInitialValue: ({ content, data, locale }: Pick<ContentProps, 'content' | 'data' | 'locale'>) => {
|
|
5
|
+
[x: string]: unknown;
|
|
6
|
+
};
|
|
7
|
+
export declare const getContentInitialValue: ({ content, data }: Pick<ContentProps, 'content' | 'data'>) => Nullable<BuilderContent>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export const getContextStateInitialValue = ({ content, data, locale }) => {
|
|
2
|
+
const defaultValues = {};
|
|
3
|
+
// set default values for content state inputs
|
|
4
|
+
content?.data?.inputs?.forEach(input => {
|
|
5
|
+
if (input.name && input.defaultValue !== undefined && content?.data?.state && content.data.state[input.name] === undefined) {
|
|
6
|
+
defaultValues[input.name] = input.defaultValue;
|
|
7
|
+
}
|
|
8
|
+
});
|
|
9
|
+
const stateToUse = {
|
|
10
|
+
...content?.data?.state,
|
|
11
|
+
...data,
|
|
12
|
+
...(locale ? {
|
|
13
|
+
locale
|
|
14
|
+
} : {})
|
|
15
|
+
};
|
|
16
|
+
return {
|
|
17
|
+
...defaultValues,
|
|
18
|
+
...stateToUse
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
export const getContentInitialValue = ({ content, data }) => {
|
|
22
|
+
return !content ? undefined : {
|
|
23
|
+
...content,
|
|
24
|
+
data: {
|
|
25
|
+
...content?.data,
|
|
26
|
+
...data
|
|
27
|
+
},
|
|
28
|
+
meta: content?.meta
|
|
29
|
+
};
|
|
30
|
+
};
|