@builder.io/sdk-react-native 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/blocks/button/button.js +6 -2
- package/dist/blocks/button/component-info.js +4 -8
- package/dist/blocks/columns/columns.js +19 -23
- package/dist/blocks/columns/component-info.js +27 -48
- package/dist/blocks/custom-code/component-info.js +4 -8
- package/dist/blocks/custom-code/custom-code.js +1 -1
- package/dist/blocks/embed/component-info.js +7 -11
- package/dist/blocks/embed/embed.js +1 -1
- package/dist/blocks/embed/helpers.js +2 -6
- package/dist/blocks/form/component-info.js +33 -69
- package/dist/blocks/form/form.js +2 -203
- package/dist/blocks/fragment/fragment.js +1 -1
- package/dist/blocks/helpers.js +33 -0
- package/dist/blocks/image/component-info.js +21 -47
- package/dist/blocks/image/image.helpers.js +2 -2
- package/dist/blocks/img/component-info.js +2 -4
- package/dist/blocks/img/img.js +2 -1
- package/dist/blocks/input/component-info.js +8 -34
- package/dist/blocks/input/input.js +2 -1
- package/dist/blocks/raw-text/component-info.js +2 -4
- package/dist/blocks/raw-text/raw-text.js +3 -2
- package/dist/blocks/section/component-info.js +5 -10
- package/dist/blocks/section/section.js +2 -1
- package/dist/blocks/select/component-info.js +12 -24
- package/dist/blocks/select/select.js +2 -1
- package/dist/blocks/submit-button/component-info.js +2 -4
- package/dist/blocks/submit-button/submit-button.js +2 -1
- package/dist/blocks/symbol/component-info.js +7 -12
- package/dist/blocks/symbol/symbol.helpers.js +66 -0
- package/dist/blocks/symbol/symbol.js +23 -50
- package/dist/blocks/text/component-info.js +3 -4
- package/dist/blocks/textarea/component-info.js +6 -12
- package/dist/blocks/textarea/textarea.js +2 -1
- package/dist/blocks/video/component-info.js +21 -41
- package/dist/components/block/block.helpers.js +102 -0
- package/dist/components/block/block.js +141 -0
- package/dist/components/block/components/block-styles.js +95 -0
- package/dist/components/block/components/block-wrapper/block-wrapper.js +41 -0
- package/dist/components/block/components/block-wrapper.js +56 -0
- package/dist/components/block/components/component-ref/component-ref.helpers.js +40 -0
- package/dist/components/block/components/component-ref/component-ref.js +63 -0
- package/dist/components/block/components/component-ref.js +81 -0
- package/dist/components/block/components/component.js +41 -0
- package/dist/components/block/components/interactive-element/interactive-element.helpers.js +35 -0
- package/dist/components/block/components/interactive-element/interactive-element.js +36 -0
- package/dist/components/block/components/interactive-element.js +46 -0
- package/dist/components/block/components/repeated-block.js +40 -0
- package/dist/components/block/types.js +1 -0
- package/dist/components/blocks/blocks-wrapper.js +69 -0
- package/dist/components/blocks/blocks.js +41 -0
- package/dist/components/content/builder-editing.js +32 -0
- package/dist/components/content/components/content-styles.helpers.js +55 -0
- package/dist/components/content/components/content-styles.js +61 -0
- package/dist/components/content/components/enable-editor.js +310 -0
- package/dist/components/content/components/styles.helpers.js +55 -0
- package/dist/components/content/components/styles.js +61 -0
- package/dist/components/content/content.helpers.js +49 -0
- package/dist/components/content/content.js +110 -0
- package/dist/components/content/content.types.js +1 -0
- package/dist/components/content/index.js +8 -0
- package/dist/components/content/wrap-component-ref.js +5 -0
- package/dist/components/content-variants/content-variants.js +77 -0
- package/dist/components/content-variants/content-variants.types.js +1 -0
- package/dist/components/content-variants/helpers.js +175 -0
- package/dist/components/inlined-script.js +32 -0
- package/dist/components/{render-inlined-styles.js → inlined-styles.js} +3 -3
- package/dist/components/render-block/block-styles.js +2 -2
- package/dist/components/render-content/components/render-styles.js +2 -2
- package/dist/components/render-content/render-content.js +10 -8
- package/dist/components/render-content-variants/helpers.js +49 -20
- package/dist/components/render-content-variants/render-content-variants.js +29 -24
- package/dist/components/render-content-variants/render-content-variants.types.js +1 -0
- package/dist/constants/device-sizes.js +2 -2
- package/dist/constants/sdk-version.js +1 -1
- package/dist/context/builder.context.js +1 -1
- package/dist/functions/apply-patch-with-mutation.js +75 -0
- package/dist/functions/apply-patch-with-mutation.test.js +55 -0
- package/dist/functions/camel-to-kebab-case.js +1 -1
- package/dist/functions/evaluate/acorn.js +1691 -0
- package/dist/functions/evaluate/evaluate.js +72 -0
- package/dist/functions/evaluate/index.js +5 -0
- package/dist/functions/evaluate/interpreter.js +2903 -0
- package/dist/functions/evaluate/non-node-runtime.js +97 -0
- package/dist/functions/evaluate/types.js +1 -0
- package/dist/functions/evaluate.test.js +12 -6
- package/dist/functions/event-handler-name.js +1 -1
- package/dist/functions/extract-text-styles.js +3 -9
- package/dist/functions/fast-clone.js +1 -1
- package/dist/functions/get-block-actions-handler.js +2 -2
- package/dist/functions/get-block-actions.js +14 -1
- package/dist/functions/get-block-component-options.js +6 -1
- package/dist/functions/get-block-properties.js +21 -8
- package/dist/functions/get-builder-search-params/fn.test.js +3 -3
- package/dist/functions/get-builder-search-params/index.js +4 -4
- package/dist/functions/get-content/generate-content-url.js +12 -5
- package/dist/functions/get-content/generate-content-url.test.js +31 -17
- package/dist/functions/get-content/index.js +36 -12
- package/dist/functions/get-content/processCookies.js +7 -0
- package/dist/functions/get-processed-block.js +8 -3
- package/dist/functions/get-processed-block.test.js +3 -1
- package/dist/functions/get-react-native-block-styles.js +6 -1
- package/dist/functions/is-non-node-server.js +12 -0
- package/dist/functions/on-change.test.js +13 -3
- package/dist/functions/register-component.js +24 -19
- package/dist/functions/sanitize-react-native-block-styles.js +17 -6
- package/dist/functions/set.test.js +9 -3
- package/dist/functions/track/helpers.js +5 -5
- package/dist/functions/track/index.js +29 -18
- package/dist/functions/track/interaction.js +10 -4
- package/dist/functions/transform-block-properties.js +2 -0
- package/dist/helpers/ab-tests.js +38 -14
- package/dist/helpers/canTrack.js +2 -2
- package/dist/helpers/css.js +2 -2
- package/dist/helpers/flatten.js +10 -7
- package/dist/helpers/nullable.js +1 -1
- package/dist/helpers/preview-lru-cache/get.js +11 -0
- package/dist/helpers/preview-lru-cache/helpers.js +13 -0
- package/dist/helpers/preview-lru-cache/init.js +13 -0
- package/dist/helpers/preview-lru-cache/set.js +37 -0
- package/dist/helpers/preview-lru-cache/types.js +1 -0
- package/dist/helpers/sessionId.js +13 -6
- package/dist/helpers/url.js +1 -1
- package/dist/helpers/visitorId.js +4 -1
- package/dist/index-helpers/blocks-exports.js +2 -2
- package/dist/scripts/init-editing.js +61 -46
- package/dist/types/builder-props.js +1 -0
- package/dist/types/enforced-partials.js +1 -0
- package/package.json +2 -2
- package/src/blocks/button/button.jsx +11 -2
- package/src/blocks/button/component-info.js +16 -22
- package/src/blocks/columns/columns.jsx +29 -28
- package/src/blocks/columns/component-info.js +203 -226
- package/src/blocks/custom-code/component-info.js +19 -25
- package/src/blocks/custom-code/custom-code.jsx +1 -1
- package/src/blocks/embed/component-info.js +31 -37
- package/src/blocks/embed/embed.jsx +1 -1
- package/src/blocks/embed/helpers.js +3 -9
- package/src/blocks/form/component-info.js +174 -212
- package/src/blocks/form/form.jsx +3 -247
- package/src/blocks/fragment/component-info.js +1 -3
- package/src/blocks/fragment/fragment.jsx +1 -1
- package/src/blocks/helpers.js +27 -0
- package/src/blocks/image/component-info.js +105 -133
- package/src/blocks/image/image.helpers.js +3 -5
- package/src/blocks/img/component-info.js +8 -12
- package/src/blocks/img/img.jsx +3 -1
- package/src/blocks/input/component-info.js +29 -57
- package/src/blocks/input/input.jsx +3 -1
- package/src/blocks/raw-text/component-info.js +7 -11
- package/src/blocks/raw-text/raw-text.jsx +4 -2
- package/src/blocks/section/component-info.js +24 -31
- package/src/blocks/section/section.jsx +3 -1
- package/src/blocks/select/component-info.js +34 -48
- package/src/blocks/select/select.jsx +3 -1
- package/src/blocks/submit-button/component-info.js +6 -10
- package/src/blocks/submit-button/submit-button.jsx +3 -2
- package/src/blocks/symbol/component-info.js +30 -37
- package/src/blocks/symbol/symbol.helpers.js +60 -0
- package/src/blocks/symbol/symbol.jsx +34 -59
- package/src/blocks/text/component-info.js +10 -13
- package/src/blocks/textarea/component-info.js +22 -30
- package/src/blocks/textarea/textarea.jsx +3 -1
- package/src/blocks/video/component-info.js +74 -96
- package/src/components/{render-block/render-block.helpers.js → block/block.helpers.js} +26 -44
- package/src/components/{render-block/render-block.jsx → block/block.jsx} +68 -81
- package/src/components/{render-block → block/components}/block-styles.jsx +19 -18
- package/src/components/block/components/block-wrapper.jsx +58 -0
- package/src/components/block/components/component-ref/component-ref.helpers.js +41 -0
- package/src/components/block/components/component-ref/component-ref.jsx +72 -0
- package/src/components/block/components/interactive-element.jsx +37 -0
- package/src/components/{render-block/render-repeated-block.jsx → block/components/repeated-block.jsx} +10 -6
- package/src/components/blocks/blocks-wrapper.jsx +74 -0
- package/src/components/blocks/blocks.jsx +51 -0
- package/src/components/{render-content/render-content.jsx → content/components/enable-editor.jsx} +81 -165
- package/src/components/{render-content/components/render-styles.helpers.js → content/components/styles.helpers.js} +6 -7
- package/src/components/{render-content/components/render-styles.jsx → content/components/styles.jsx} +7 -7
- package/src/components/{render-content/render-content.helpers.js → content/content.helpers.js} +15 -15
- package/src/components/content/content.jsx +141 -0
- package/src/components/content/content.types.js +0 -0
- package/src/components/content/index.js +2 -0
- package/src/components/content/wrap-component-ref.js +2 -0
- package/src/components/content-variants/content-variants.jsx +120 -0
- package/src/components/{render-content-variants → content-variants}/helpers.js +58 -41
- package/src/components/inlined-script.jsx +18 -0
- package/src/components/{render-inlined-styles.jsx → inlined-styles.jsx} +3 -3
- package/src/constants/device-sizes.js +6 -6
- package/src/constants/sdk-version.js +1 -1
- package/src/context/builder.context.js +1 -1
- package/src/functions/apply-patch-with-mutation.js +66 -0
- package/src/functions/camel-to-kebab-case.js +2 -4
- package/src/functions/evaluate/acorn.js +1595 -0
- package/src/functions/{evaluate.js → evaluate/evaluate.js} +36 -10
- package/src/functions/evaluate/index.js +2 -0
- package/src/functions/evaluate/interpreter.js +2801 -0
- package/src/functions/evaluate/non-node-runtime.js +92 -0
- package/src/functions/evaluate/types.js +0 -0
- package/src/functions/event-handler-name.js +2 -4
- package/src/functions/extract-text-styles.js +4 -12
- package/src/functions/fast-clone.js +2 -4
- package/src/functions/get-block-actions-handler.js +3 -5
- package/src/functions/get-block-actions.js +15 -4
- package/src/functions/get-block-component-options.js +11 -12
- package/src/functions/get-block-properties.js +29 -19
- package/src/functions/get-builder-search-params/index.js +5 -10
- package/src/functions/get-content/generate-content-url.js +17 -19
- package/src/functions/get-content/index.js +43 -29
- package/src/functions/get-fetch.js +1 -3
- package/src/functions/get-global-this.js +1 -3
- package/src/functions/get-processed-block.js +12 -13
- package/src/functions/get-react-native-block-styles.js +11 -12
- package/src/functions/if-target.js +1 -3
- package/src/functions/is-browser.js +1 -3
- package/src/functions/is-editing.js +1 -3
- package/src/functions/is-iframe.js +1 -3
- package/src/functions/is-non-node-server.js +9 -0
- package/src/functions/is-previewing.js +1 -3
- package/src/functions/on-change.js +1 -4
- package/src/functions/register-component.js +34 -42
- package/src/functions/register.js +1 -3
- package/src/functions/sanitize-react-native-block-styles.js +22 -17
- package/src/functions/set-editor-settings.js +1 -3
- package/src/functions/set.js +1 -3
- package/src/functions/track/helpers.js +3 -5
- package/src/functions/track/index.js +45 -43
- package/src/functions/track/interaction.js +11 -7
- package/src/functions/transform-block-properties.js +2 -0
- package/src/helpers/ab-tests.js +46 -26
- package/src/helpers/canTrack.js +3 -5
- package/src/helpers/css.js +3 -7
- package/src/helpers/flatten.js +15 -18
- package/src/helpers/localStorage.js +1 -4
- package/src/helpers/logger.js +1 -3
- package/src/helpers/nullable.js +2 -4
- package/src/helpers/preview-lru-cache/get.js +8 -0
- package/src/helpers/preview-lru-cache/helpers.js +10 -0
- package/src/helpers/preview-lru-cache/init.js +10 -0
- package/src/helpers/preview-lru-cache/set.js +35 -0
- package/src/helpers/preview-lru-cache/types.js +0 -0
- package/src/helpers/sessionId.js +14 -11
- package/src/helpers/time.js +1 -3
- package/src/helpers/url.js +2 -4
- package/src/helpers/uuid.js +4 -6
- package/src/helpers/visitorId.js +8 -7
- package/src/index-helpers/blocks-exports.js +1 -1
- package/src/index.js +2 -17
- package/src/scripts/init-editing.js +62 -48
- package/src/types/api-version.js +1 -3
- package/src/types/builder-props.js +0 -0
- package/src/types/enforced-partials.js +0 -0
- package/dist/blocks/BaseText.d.ts +0 -6
- package/dist/blocks/button/button.d.ts +0 -9
- package/dist/blocks/button/component-info.d.ts +0 -2
- package/dist/blocks/columns/columns.d.ts +0 -16
- package/dist/blocks/columns/component-info.d.ts +0 -2
- package/dist/blocks/custom-code/component-info.d.ts +0 -2
- package/dist/blocks/custom-code/custom-code.d.ts +0 -5
- package/dist/blocks/embed/component-info.d.ts +0 -2
- package/dist/blocks/embed/embed.d.ts +0 -5
- package/dist/blocks/embed/helpers.d.ts +0 -1
- package/dist/blocks/form/component-info.d.ts +0 -2
- package/dist/blocks/form/form.d.ts +0 -28
- package/dist/blocks/fragment/component-info.d.ts +0 -2
- package/dist/blocks/fragment/fragment.d.ts +0 -8
- package/dist/blocks/image/component-info.d.ts +0 -2
- package/dist/blocks/image/image.d.ts +0 -17
- package/dist/blocks/image/image.helpers.d.ts +0 -1
- package/dist/blocks/img/component-info.d.ts +0 -2
- package/dist/blocks/img/img.d.ts +0 -11
- package/dist/blocks/input/component-info.d.ts +0 -2
- package/dist/blocks/input/input.d.ts +0 -12
- package/dist/blocks/raw-text/component-info.d.ts +0 -2
- package/dist/blocks/raw-text/raw-text.d.ts +0 -5
- package/dist/blocks/section/component-info.d.ts +0 -2
- package/dist/blocks/section/section.d.ts +0 -9
- package/dist/blocks/select/component-info.d.ts +0 -2
- package/dist/blocks/select/select.d.ts +0 -13
- package/dist/blocks/submit-button/component-info.d.ts +0 -2
- package/dist/blocks/submit-button/submit-button.d.ts +0 -7
- package/dist/blocks/symbol/component-info.d.ts +0 -2
- package/dist/blocks/symbol/symbol.d.ts +0 -21
- package/dist/blocks/text/component-info.d.ts +0 -2
- package/dist/blocks/text/text.d.ts +0 -7
- package/dist/blocks/textarea/component-info.d.ts +0 -2
- package/dist/blocks/textarea/textarea.d.ts +0 -10
- package/dist/blocks/util.d.ts +0 -4
- package/dist/blocks/video/component-info.d.ts +0 -2
- package/dist/blocks/video/video.d.ts +0 -31
- package/dist/components/render-block/block-styles.d.ts +0 -9
- package/dist/components/render-block/render-block.d.ts +0 -9
- package/dist/components/render-block/render-block.helpers.d.ts +0 -12
- package/dist/components/render-block/render-component.d.ts +0 -17
- package/dist/components/render-block/render-repeated-block.d.ts +0 -9
- package/dist/components/render-block/types.d.ts +0 -6
- package/dist/components/render-blocks.d.ts +0 -10
- package/dist/components/render-content/builder-editing.d.ts +0 -3
- package/dist/components/render-content/components/render-styles.d.ts +0 -9
- package/dist/components/render-content/components/render-styles.helpers.d.ts +0 -15
- package/dist/components/render-content/index.d.ts +0 -1
- package/dist/components/render-content/render-content.d.ts +0 -4
- package/dist/components/render-content/render-content.helpers.d.ts +0 -7
- package/dist/components/render-content/render-content.types.d.ts +0 -38
- package/dist/components/render-content/wrap-component-ref.d.ts +0 -6
- package/dist/components/render-content-variants/helpers.d.ts +0 -17
- package/dist/components/render-content-variants/render-content-variants.d.ts +0 -5
- package/dist/components/render-inlined-styles.d.ts +0 -7
- package/dist/constants/builder-registered-components.d.ts +0 -6
- package/dist/constants/device-sizes.d.ts +0 -13
- package/dist/constants/sdk-version.d.ts +0 -1
- package/dist/constants/target.d.ts +0 -3
- package/dist/context/builder.context.d.ts +0 -3
- package/dist/context/types.d.ts +0 -35
- package/dist/functions/camel-to-kebab-case.d.ts +0 -1
- package/dist/functions/evaluate.d.ts +0 -7
- package/dist/functions/evaluate.test.d.ts +0 -1
- package/dist/functions/event-handler-name.d.ts +0 -1
- package/dist/functions/extract-text-styles.d.ts +0 -4
- package/dist/functions/fast-clone.d.ts +0 -4
- package/dist/functions/get-block-actions-handler.d.ts +0 -8
- package/dist/functions/get-block-actions.d.ts +0 -9
- package/dist/functions/get-block-component-options.d.ts +0 -2
- package/dist/functions/get-block-properties.d.ts +0 -2
- package/dist/functions/get-builder-search-params/fn.test.d.ts +0 -1
- package/dist/functions/get-builder-search-params/index.d.ts +0 -12
- package/dist/functions/get-content/generate-content-url.d.ts +0 -2
- package/dist/functions/get-content/generate-content-url.test.d.ts +0 -1
- package/dist/functions/get-content/index.d.ts +0 -16
- package/dist/functions/get-content/types.d.ts +0 -51
- package/dist/functions/get-fetch.d.ts +0 -1
- package/dist/functions/get-processed-block.d.ts +0 -10
- package/dist/functions/get-processed-block.test.d.ts +0 -1
- package/dist/functions/get-react-native-block-styles.d.ts +0 -7
- package/dist/functions/if-target.d.ts +0 -7
- package/dist/functions/is-browser.d.ts +0 -1
- package/dist/functions/is-editing.d.ts +0 -1
- package/dist/functions/is-iframe.d.ts +0 -1
- package/dist/functions/is-previewing.d.ts +0 -1
- package/dist/functions/on-change.d.ts +0 -7
- package/dist/functions/on-change.test.d.ts +0 -1
- package/dist/functions/register-component.d.ts +0 -14
- package/dist/functions/register.d.ts +0 -16
- package/dist/functions/sanitize-react-native-block-styles.d.ts +0 -3
- package/dist/functions/set-editor-settings.d.ts +0 -4
- package/dist/functions/set.d.ts +0 -7
- package/dist/functions/set.test.d.ts +0 -1
- package/dist/functions/track/helpers.d.ts +0 -5
- package/dist/functions/track/index.d.ts +0 -51
- package/dist/functions/track/interaction.d.ts +0 -13
- package/dist/functions/transform-block-properties.d.ts +0 -3
- package/dist/functions/transform-block.d.ts +0 -2
- package/dist/helpers/ab-tests.d.ts +0 -9
- package/dist/helpers/canTrack.d.ts +0 -1
- package/dist/helpers/cookie.d.ts +0 -9
- package/dist/helpers/css.d.ts +0 -7
- package/dist/helpers/flatten.d.ts +0 -6
- package/dist/helpers/localStorage.d.ts +0 -9
- package/dist/helpers/logger.d.ts +0 -6
- package/dist/helpers/nullable.d.ts +0 -2
- package/dist/helpers/sessionId.d.ts +0 -6
- package/dist/helpers/time.d.ts +0 -1
- package/dist/helpers/url.d.ts +0 -6
- package/dist/helpers/url.test.d.ts +0 -1
- package/dist/helpers/uuid.d.ts +0 -8
- package/dist/helpers/visitorId.d.ts +0 -6
- package/dist/index-helpers/blocks-exports.d.ts +0 -8
- package/dist/index-helpers/top-of-file.d.ts +0 -1
- package/dist/index.d.ts +0 -15
- package/dist/scripts/init-editing.d.ts +0 -6
- package/dist/types/api-version.d.ts +0 -2
- package/dist/types/builder-block.d.ts +0 -66
- package/dist/types/builder-content.d.ts +0 -44
- package/dist/types/can-track.d.ts +0 -3
- package/dist/types/components.d.ts +0 -105
- package/dist/types/deep-partial.d.ts +0 -3
- package/dist/types/element.d.ts +0 -59
- package/dist/types/input.d.ts +0 -121
- package/dist/types/targets.d.ts +0 -3
- package/dist/types/typescript.d.ts +0 -5
- package/src/blocks/util.js +0 -8
- package/src/components/render-block/render-component.jsx +0 -55
- package/src/components/render-blocks.jsx +0 -101
- package/src/components/render-content/builder-editing.jsx +0 -16
- package/src/components/render-content/index.js +0 -4
- package/src/components/render-content/wrap-component-ref.js +0 -4
- package/src/components/render-content-variants/render-content-variants.jsx +0 -101
- package/src/functions/evaluate.test.js +0 -17
- package/src/functions/get-builder-search-params/fn.test.js +0 -13
- package/src/functions/get-content/generate-content-url.test.js +0 -97
- package/src/functions/get-processed-block.test.js +0 -34
- package/src/functions/on-change.test.js +0 -19
- package/src/functions/set.test.js +0 -16
- package/src/helpers/url.test.js +0 -21
- /package/src/components/{render-block → block}/types.js +0 -0
- /package/src/components/{render-content/render-content.types.js → content-variants/content-variants.types.js} +0 -0
package/src/components/{render-content/render-content.jsx → content/components/enable-editor.jsx}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
"use client";
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import {
|
|
4
4
|
FlatList,
|
|
@@ -9,80 +9,57 @@ import {
|
|
|
9
9
|
Text,
|
|
10
10
|
} from "react-native";
|
|
11
11
|
import { useState, useContext, useRef, useEffect } from "react";
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import
|
|
19
|
-
import {
|
|
20
|
-
components,
|
|
21
|
-
createRegisterComponentMessage,
|
|
22
|
-
} from "../../functions/register-component.js";
|
|
23
|
-
import { _track } from "../../functions/track/index.js";
|
|
24
|
-
import RenderBlocks from "../render-blocks";
|
|
25
|
-
import RenderContentStyles from "./components/render-styles";
|
|
26
|
-
import builderContext from "../../context/builder.context.js";
|
|
12
|
+
import { evaluate } from "../../../functions/evaluate";
|
|
13
|
+
import { fetch } from "../../../functions/get-fetch.js";
|
|
14
|
+
import { isBrowser } from "../../../functions/is-browser.js";
|
|
15
|
+
import { isEditing } from "../../../functions/is-editing.js";
|
|
16
|
+
import { createRegisterComponentMessage } from "../../../functions/register-component.js";
|
|
17
|
+
import { _track } from "../../../functions/track/index.js";
|
|
18
|
+
import builderContext from "../../../context/builder.context";
|
|
27
19
|
import {
|
|
28
20
|
registerInsertMenu,
|
|
29
21
|
setupBrowserForEditing,
|
|
30
|
-
} from "
|
|
31
|
-
import { checkIsDefined } from "
|
|
32
|
-
import { getInteractionPropertiesForEvent } from "
|
|
33
|
-
import {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
} from "
|
|
37
|
-
import { TARGET } from "../../constants/target.js";
|
|
38
|
-
import { logger } from "../../helpers/logger.js";
|
|
39
|
-
import { getRenderContentScriptString } from "../render-content-variants/helpers.js";
|
|
40
|
-
import { wrapComponentRef } from "./wrap-component-ref.js";
|
|
22
|
+
} from "../../../scripts/init-editing.js";
|
|
23
|
+
import { checkIsDefined } from "../../../helpers/nullable.js";
|
|
24
|
+
import { getInteractionPropertiesForEvent } from "../../../functions/track/interaction.js";
|
|
25
|
+
import { logger } from "../../../helpers/logger.js";
|
|
26
|
+
import { getContent } from "../../../functions/get-content/index.js";
|
|
27
|
+
import { isPreviewing } from "../../../functions/is-previewing.js";
|
|
28
|
+
import { postPreviewContent } from "../../../helpers/preview-lru-cache/set.js";
|
|
41
29
|
|
|
42
|
-
function
|
|
30
|
+
function EnableEditor(props) {
|
|
43
31
|
const elementRef = useRef(null);
|
|
44
|
-
const [
|
|
32
|
+
const [canTrackToUse, setCanTrackToUse] = useState(() =>
|
|
33
|
+
checkIsDefined(props.canTrack) ? props.canTrack : true
|
|
34
|
+
);
|
|
45
35
|
|
|
46
|
-
const [
|
|
36
|
+
const [forceReRenderCount, setForceReRenderCount] = useState(() => 0);
|
|
47
37
|
|
|
48
38
|
function mergeNewContent(newContent) {
|
|
49
|
-
|
|
50
|
-
...builderContextSignal.content,
|
|
39
|
+
const newContentValue = {
|
|
40
|
+
...props.builderContextSignal.content,
|
|
51
41
|
...newContent,
|
|
52
42
|
data: {
|
|
53
|
-
...builderContextSignal.content?.data,
|
|
43
|
+
...props.builderContextSignal.content?.data,
|
|
54
44
|
...newContent?.data,
|
|
55
45
|
},
|
|
56
46
|
meta: {
|
|
57
|
-
...builderContextSignal.content?.meta,
|
|
47
|
+
...props.builderContextSignal.content?.meta,
|
|
58
48
|
...newContent?.meta,
|
|
59
49
|
breakpoints:
|
|
60
50
|
newContent?.meta?.breakpoints ||
|
|
61
|
-
builderContextSignal.content?.meta?.breakpoints,
|
|
51
|
+
props.builderContextSignal.content?.meta?.breakpoints,
|
|
62
52
|
},
|
|
63
53
|
};
|
|
54
|
+
props.builderContextSignal.content = newContentValue;
|
|
64
55
|
}
|
|
65
56
|
|
|
66
|
-
|
|
67
|
-
builderContextSignal.content = {
|
|
68
|
-
...builderContextSignal.content,
|
|
69
|
-
meta: {
|
|
70
|
-
...builderContextSignal.content?.meta,
|
|
71
|
-
breakpoints,
|
|
72
|
-
},
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
const [update, setUpdate] = useState(() => 0);
|
|
57
|
+
const [lastUpdated, setLastUpdated] = useState(() => 0);
|
|
77
58
|
|
|
78
|
-
const [
|
|
79
|
-
|
|
59
|
+
const [shouldSendResetCookie, setShouldSendResetCookie] = useState(
|
|
60
|
+
() => false
|
|
80
61
|
);
|
|
81
62
|
|
|
82
|
-
function contentSetState(newRootState) {
|
|
83
|
-
builderContextSignal.rootState = newRootState;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
63
|
function processMessage(event) {
|
|
87
64
|
const { data } = event;
|
|
88
65
|
if (data) {
|
|
@@ -90,11 +67,18 @@ function RenderContent(props) {
|
|
|
90
67
|
case "builder.configureSdk": {
|
|
91
68
|
const messageContent = data.data;
|
|
92
69
|
const { breakpoints, contentId } = messageContent;
|
|
93
|
-
if (
|
|
70
|
+
if (
|
|
71
|
+
!contentId ||
|
|
72
|
+
contentId !== props.builderContextSignal.content?.id
|
|
73
|
+
) {
|
|
94
74
|
return;
|
|
95
75
|
}
|
|
96
76
|
if (breakpoints) {
|
|
97
|
-
|
|
77
|
+
mergeNewContent({
|
|
78
|
+
meta: {
|
|
79
|
+
breakpoints,
|
|
80
|
+
},
|
|
81
|
+
});
|
|
98
82
|
}
|
|
99
83
|
setForceReRenderCount(forceReRenderCount + 1); // This is a hack to force Qwik to re-render.
|
|
100
84
|
break;
|
|
@@ -114,24 +98,20 @@ function RenderContent(props) {
|
|
|
114
98
|
|
|
115
99
|
break;
|
|
116
100
|
}
|
|
117
|
-
case "builder.patchUpdates": {
|
|
118
|
-
// TODO
|
|
119
|
-
break;
|
|
120
|
-
}
|
|
121
101
|
}
|
|
122
102
|
}
|
|
123
103
|
}
|
|
124
104
|
|
|
125
105
|
function evaluateJsCode() {
|
|
126
106
|
// run any dynamic JS code attached to content
|
|
127
|
-
const jsCode = builderContextSignal.content?.data?.jsCode;
|
|
107
|
+
const jsCode = props.builderContextSignal.content?.data?.jsCode;
|
|
128
108
|
if (jsCode) {
|
|
129
109
|
evaluate({
|
|
130
110
|
code: jsCode,
|
|
131
111
|
context: props.context || {},
|
|
132
112
|
localState: undefined,
|
|
133
|
-
rootState: builderContextSignal.rootState,
|
|
134
|
-
rootSetState:
|
|
113
|
+
rootState: props.builderContextSignal.rootState,
|
|
114
|
+
rootSetState: props.builderContextSignal.rootSetState,
|
|
135
115
|
});
|
|
136
116
|
}
|
|
137
117
|
}
|
|
@@ -141,9 +121,9 @@ function RenderContent(props) {
|
|
|
141
121
|
const [clicked, setClicked] = useState(() => false);
|
|
142
122
|
|
|
143
123
|
function onClick(event) {
|
|
144
|
-
if (builderContextSignal.content) {
|
|
145
|
-
const variationId = builderContextSignal.content?.testVariationId;
|
|
146
|
-
const contentId = builderContextSignal.content?.id;
|
|
124
|
+
if (props.builderContextSignal.content) {
|
|
125
|
+
const variationId = props.builderContextSignal.content?.testVariationId;
|
|
126
|
+
const contentId = props.builderContextSignal.content?.id;
|
|
147
127
|
_track({
|
|
148
128
|
type: "click",
|
|
149
129
|
canTrack: canTrackToUse,
|
|
@@ -165,8 +145,8 @@ function RenderContent(props) {
|
|
|
165
145
|
code: group,
|
|
166
146
|
context: props.context || {},
|
|
167
147
|
localState: undefined,
|
|
168
|
-
rootState: builderContextSignal.rootState,
|
|
169
|
-
rootSetState:
|
|
148
|
+
rootState: props.builderContextSignal.rootState,
|
|
149
|
+
rootSetState: props.builderContextSignal.rootSetState,
|
|
170
150
|
})
|
|
171
151
|
);
|
|
172
152
|
}
|
|
@@ -176,10 +156,11 @@ function RenderContent(props) {
|
|
|
176
156
|
.then((response) => response.json())
|
|
177
157
|
.then((json) => {
|
|
178
158
|
const newState = {
|
|
179
|
-
...builderContextSignal.rootState,
|
|
159
|
+
...props.builderContextSignal.rootState,
|
|
180
160
|
[key]: json,
|
|
181
161
|
};
|
|
182
|
-
|
|
162
|
+
props.builderContextSignal.rootSetState?.(newState);
|
|
163
|
+
httpReqsData[key] = true;
|
|
183
164
|
})
|
|
184
165
|
.catch((err) => {
|
|
185
166
|
console.error("error fetching dynamic data", url, err);
|
|
@@ -187,7 +168,8 @@ function RenderContent(props) {
|
|
|
187
168
|
}
|
|
188
169
|
|
|
189
170
|
function runHttpRequests() {
|
|
190
|
-
const requests =
|
|
171
|
+
const requests =
|
|
172
|
+
props.builderContextSignal.content?.data?.httpRequests ?? {};
|
|
191
173
|
Object.entries(requests).forEach(([key, url]) => {
|
|
192
174
|
if (url && (!httpReqsData[key] || isEditing())) {
|
|
193
175
|
const evaluatedUrl = evalExpression(url);
|
|
@@ -204,7 +186,7 @@ function RenderContent(props) {
|
|
|
204
186
|
window.dispatchEvent(
|
|
205
187
|
new CustomEvent("builder:component:stateChange", {
|
|
206
188
|
detail: {
|
|
207
|
-
state: builderContextSignal.rootState,
|
|
189
|
+
state: props.builderContextSignal.rootState,
|
|
208
190
|
ref: {
|
|
209
191
|
name: props.model,
|
|
210
192
|
},
|
|
@@ -214,52 +196,6 @@ function RenderContent(props) {
|
|
|
214
196
|
}
|
|
215
197
|
}
|
|
216
198
|
|
|
217
|
-
const [scriptStr, setScriptStr] = useState(() =>
|
|
218
|
-
getRenderContentScriptString({
|
|
219
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-non-null-asserted-optional-chain
|
|
220
|
-
contentId: props.content?.id,
|
|
221
|
-
parentContentId: props.parentContentId,
|
|
222
|
-
})
|
|
223
|
-
);
|
|
224
|
-
|
|
225
|
-
const [builderContextSignal, setBuilderContextSignal] = useState(() => ({
|
|
226
|
-
content: getContentInitialValue({
|
|
227
|
-
content: props.content,
|
|
228
|
-
data: props.data,
|
|
229
|
-
}),
|
|
230
|
-
localState: undefined,
|
|
231
|
-
rootState: getContextStateInitialValue({
|
|
232
|
-
content: props.content,
|
|
233
|
-
data: props.data,
|
|
234
|
-
locale: props.locale,
|
|
235
|
-
}),
|
|
236
|
-
rootSetState: contentSetState,
|
|
237
|
-
context: props.context || {},
|
|
238
|
-
apiKey: props.apiKey,
|
|
239
|
-
apiVersion: props.apiVersion,
|
|
240
|
-
registeredComponents: [
|
|
241
|
-
...getDefaultRegisteredComponents(),
|
|
242
|
-
// While this `components` object is deprecated, we must maintain support for it.
|
|
243
|
-
// Since users are able to override our default components, we need to make sure that we do not break such
|
|
244
|
-
// existing usage.
|
|
245
|
-
// This is why we spread `components` after the default Builder.io components, but before the `props.customComponents`,
|
|
246
|
-
// which is the new standard way of providing custom components, and must therefore take precedence.
|
|
247
|
-
...components,
|
|
248
|
-
...(props.customComponents || []),
|
|
249
|
-
].reduce(
|
|
250
|
-
(acc, { component, ...curr }) => ({
|
|
251
|
-
...acc,
|
|
252
|
-
[curr.name]: {
|
|
253
|
-
component:
|
|
254
|
-
TARGET === "vue3" ? wrapComponentRef(component) : component,
|
|
255
|
-
...curr,
|
|
256
|
-
},
|
|
257
|
-
}),
|
|
258
|
-
{}
|
|
259
|
-
),
|
|
260
|
-
inheritedStyles: {},
|
|
261
|
-
}));
|
|
262
|
-
|
|
263
199
|
useEffect(() => {
|
|
264
200
|
if (!props.apiKey) {
|
|
265
201
|
logger.error(
|
|
@@ -269,6 +205,7 @@ function RenderContent(props) {
|
|
|
269
205
|
if (isBrowser()) {
|
|
270
206
|
if (isEditing()) {
|
|
271
207
|
setForceReRenderCount(forceReRenderCount + 1);
|
|
208
|
+
window.addEventListener("message", processMessage);
|
|
272
209
|
registerInsertMenu();
|
|
273
210
|
setupBrowserForEditing({
|
|
274
211
|
...(props.locale
|
|
@@ -287,21 +224,20 @@ function RenderContent(props) {
|
|
|
287
224
|
}
|
|
288
225
|
: {}),
|
|
289
226
|
});
|
|
290
|
-
Object.values(builderContextSignal.
|
|
227
|
+
Object.values(props.builderContextSignal.componentInfos).forEach(
|
|
291
228
|
(registeredComponent) => {
|
|
292
229
|
const message = createRegisterComponentMessage(registeredComponent);
|
|
293
230
|
window.parent?.postMessage(message, "*");
|
|
294
231
|
}
|
|
295
232
|
);
|
|
296
|
-
window.addEventListener("message", processMessage);
|
|
297
233
|
window.addEventListener(
|
|
298
234
|
"builder:component:stateChangeListenerActivated",
|
|
299
235
|
emitStateUpdate
|
|
300
236
|
);
|
|
301
237
|
}
|
|
302
|
-
if (builderContextSignal.content) {
|
|
303
|
-
const variationId = builderContextSignal.content?.testVariationId;
|
|
304
|
-
const contentId = builderContextSignal.content?.id;
|
|
238
|
+
if (props.builderContextSignal.content) {
|
|
239
|
+
const variationId = props.builderContextSignal.content?.testVariationId;
|
|
240
|
+
const contentId = props.builderContextSignal.content?.id;
|
|
305
241
|
_track({
|
|
306
242
|
type: "impression",
|
|
307
243
|
canTrack: canTrackToUse,
|
|
@@ -310,7 +246,6 @@ function RenderContent(props) {
|
|
|
310
246
|
variationId: variationId !== contentId ? variationId : undefined,
|
|
311
247
|
});
|
|
312
248
|
}
|
|
313
|
-
|
|
314
249
|
// override normal content in preview mode
|
|
315
250
|
if (isPreviewing()) {
|
|
316
251
|
const searchParams = new URL(location.href).searchParams;
|
|
@@ -336,7 +271,7 @@ function RenderContent(props) {
|
|
|
336
271
|
getContent({
|
|
337
272
|
model: props.model,
|
|
338
273
|
apiKey: props.apiKey,
|
|
339
|
-
apiVersion: props.apiVersion,
|
|
274
|
+
apiVersion: props.builderContextSignal.apiVersion,
|
|
340
275
|
}).then((content) => {
|
|
341
276
|
if (content) {
|
|
342
277
|
mergeNewContent(content);
|
|
@@ -355,18 +290,19 @@ function RenderContent(props) {
|
|
|
355
290
|
mergeNewContent(props.content);
|
|
356
291
|
}
|
|
357
292
|
}, [props.content]);
|
|
293
|
+
useEffect(() => {}, [shouldSendResetCookie]);
|
|
358
294
|
useEffect(() => {
|
|
359
295
|
evaluateJsCode();
|
|
360
296
|
}, [
|
|
361
|
-
builderContextSignal.content?.data?.jsCode,
|
|
362
|
-
builderContextSignal.rootState,
|
|
297
|
+
props.builderContextSignal.content?.data?.jsCode,
|
|
298
|
+
props.builderContextSignal.rootState,
|
|
363
299
|
]);
|
|
364
300
|
useEffect(() => {
|
|
365
301
|
runHttpRequests();
|
|
366
|
-
}, [builderContextSignal.content?.data?.httpRequests]);
|
|
302
|
+
}, [props.builderContextSignal.content?.data?.httpRequests]);
|
|
367
303
|
useEffect(() => {
|
|
368
304
|
emitStateUpdate();
|
|
369
|
-
}, [builderContextSignal.rootState]);
|
|
305
|
+
}, [props.builderContextSignal.rootState]);
|
|
370
306
|
|
|
371
307
|
useEffect(() => {
|
|
372
308
|
return () => {
|
|
@@ -381,54 +317,34 @@ function RenderContent(props) {
|
|
|
381
317
|
}, []);
|
|
382
318
|
|
|
383
319
|
return (
|
|
384
|
-
<builderContext.Provider value={builderContextSignal}>
|
|
385
|
-
{builderContextSignal.content ? (
|
|
320
|
+
<builderContext.Provider value={props.builderContextSignal}>
|
|
321
|
+
{props.builderContextSignal.content ? (
|
|
386
322
|
<>
|
|
387
|
-
<
|
|
323
|
+
<View
|
|
324
|
+
key={forceReRenderCount}
|
|
388
325
|
ref={elementRef}
|
|
389
326
|
onClick={(event) => onClick(event)}
|
|
390
|
-
builder-content-id={builderContextSignal.content?.id}
|
|
327
|
+
builder-content-id={props.builderContextSignal.content?.id}
|
|
391
328
|
builder-model={props.model}
|
|
392
|
-
{...
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
? {
|
|
329
|
+
{...{
|
|
330
|
+
// 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.
|
|
331
|
+
dataSet: {
|
|
332
|
+
"builder-content-id": "",
|
|
333
|
+
},
|
|
334
|
+
}}
|
|
335
|
+
{...(props.showContent
|
|
336
|
+
? {}
|
|
337
|
+
: {
|
|
402
338
|
hidden: true,
|
|
403
339
|
"aria-hidden": true,
|
|
404
|
-
}
|
|
405
|
-
: {})}
|
|
340
|
+
})}
|
|
406
341
|
>
|
|
407
|
-
{props.
|
|
408
|
-
|
|
409
|
-
<ScrollView dangerouslySetInnerHTML={{ __html: scriptStr }} />
|
|
410
|
-
</>
|
|
411
|
-
) : null}
|
|
412
|
-
|
|
413
|
-
{TARGET !== "reactNative" ? (
|
|
414
|
-
<>
|
|
415
|
-
<RenderContentStyles
|
|
416
|
-
contentId={builderContextSignal.content?.id}
|
|
417
|
-
cssCode={builderContextSignal.content?.data?.cssCode}
|
|
418
|
-
customFonts={builderContextSignal.content?.data?.customFonts}
|
|
419
|
-
/>
|
|
420
|
-
</>
|
|
421
|
-
) : null}
|
|
422
|
-
|
|
423
|
-
<RenderBlocks
|
|
424
|
-
blocks={builderContextSignal.content?.data?.blocks}
|
|
425
|
-
key={forceReRenderCount}
|
|
426
|
-
/>
|
|
427
|
-
</ScrollView>
|
|
342
|
+
{props.children}
|
|
343
|
+
</View>
|
|
428
344
|
</>
|
|
429
345
|
) : null}
|
|
430
346
|
</builderContext.Provider>
|
|
431
347
|
);
|
|
432
348
|
}
|
|
433
349
|
|
|
434
|
-
export default
|
|
350
|
+
export default EnableEditor;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const getCssFromFont =
|
|
1
|
+
const getCssFromFont = font => {
|
|
2
2
|
var _a, _b;
|
|
3
3
|
const family = font.family + (font.kind && !font.kind.includes("#") ? ", " + font.kind : "");
|
|
4
4
|
const name = family.split(",")[0];
|
|
@@ -35,9 +35,11 @@ font-weight: ${weight};
|
|
|
35
35
|
}
|
|
36
36
|
return str;
|
|
37
37
|
};
|
|
38
|
-
const getFontCss = ({
|
|
38
|
+
const getFontCss = ({
|
|
39
|
+
customFonts
|
|
40
|
+
}) => {
|
|
39
41
|
var _a;
|
|
40
|
-
return ((_a = customFonts == null ? void 0 : customFonts.map(
|
|
42
|
+
return ((_a = customFonts == null ? void 0 : customFonts.map(font => getCssFromFont(font))) == null ? void 0 : _a.join(" ")) || "";
|
|
41
43
|
};
|
|
42
44
|
const getCss = ({
|
|
43
45
|
cssCode,
|
|
@@ -51,7 +53,4 @@ const getCss = ({
|
|
|
51
53
|
}
|
|
52
54
|
return (cssCode == null ? void 0 : cssCode.replace(/&/g, `div[builder-content-id="${contentId}"]`)) || "";
|
|
53
55
|
};
|
|
54
|
-
export {
|
|
55
|
-
getCss,
|
|
56
|
-
getFontCss
|
|
57
|
-
};
|
|
56
|
+
export { getCss, getFontCss }
|
package/src/components/{render-content/components/render-styles.jsx → content/components/styles.jsx}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
"use client";
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import {
|
|
4
4
|
FlatList,
|
|
@@ -9,11 +9,11 @@ import {
|
|
|
9
9
|
Text,
|
|
10
10
|
} from "react-native";
|
|
11
11
|
import { useState } from "react";
|
|
12
|
-
import
|
|
13
|
-
import { getCss } from "./
|
|
14
|
-
import { getFontCss } from "./
|
|
12
|
+
import InlinedStyles from "../../inlined-styles";
|
|
13
|
+
import { getCss } from "./styles.helpers.js";
|
|
14
|
+
import { getFontCss } from "./styles.helpers.js";
|
|
15
15
|
|
|
16
|
-
function
|
|
16
|
+
function ContentStyles(props) {
|
|
17
17
|
const [injectedStyles, setInjectedStyles] = useState(() =>
|
|
18
18
|
`
|
|
19
19
|
${getCss({
|
|
@@ -39,7 +39,7 @@ ${getFontCss({
|
|
|
39
39
|
`.trim()
|
|
40
40
|
);
|
|
41
41
|
|
|
42
|
-
return <
|
|
42
|
+
return <InlinedStyles styles={injectedStyles} />;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
export default
|
|
45
|
+
export default ContentStyles;
|
package/src/components/{render-content/render-content.helpers.js → content/content.helpers.js}
RENAMED
|
@@ -4,16 +4,17 @@ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
|
4
4
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
6
|
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
configurable: true,
|
|
10
|
+
writable: true,
|
|
11
|
+
value
|
|
12
|
+
}) : obj[key] = value;
|
|
8
13
|
var __spreadValues = (a, b) => {
|
|
9
|
-
for (var prop in b || (b = {}))
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
-
if (__propIsEnum.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
}
|
|
14
|
+
for (var prop in b || (b = {})) if (__hasOwnProp.call(b, prop)) __defNormalProp(a, prop, b[prop]);
|
|
15
|
+
if (__getOwnPropSymbols) for (var prop of __getOwnPropSymbols(b)) {
|
|
16
|
+
if (__propIsEnum.call(b, prop)) __defNormalProp(a, prop, b[prop]);
|
|
17
|
+
}
|
|
17
18
|
return a;
|
|
18
19
|
};
|
|
19
20
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
@@ -24,13 +25,15 @@ const getContextStateInitialValue = ({
|
|
|
24
25
|
}) => {
|
|
25
26
|
var _a, _b, _c;
|
|
26
27
|
const defaultValues = {};
|
|
27
|
-
(_b = (_a = content == null ? void 0 : content.data) == null ? void 0 : _a.inputs) == null ? void 0 : _b.forEach(
|
|
28
|
+
(_b = (_a = content == null ? void 0 : content.data) == null ? void 0 : _a.inputs) == null ? void 0 : _b.forEach(input => {
|
|
28
29
|
var _a2;
|
|
29
30
|
if (input.name && input.defaultValue !== void 0 && ((_a2 = content == null ? void 0 : content.data) == null ? void 0 : _a2.state) && content.data.state[input.name] === void 0) {
|
|
30
31
|
defaultValues[input.name] = input.defaultValue;
|
|
31
32
|
}
|
|
32
33
|
});
|
|
33
|
-
const stateToUse = __spreadValues(__spreadValues(__spreadValues({}, (_c = content == null ? void 0 : content.data) == null ? void 0 : _c.state), data), locale ? {
|
|
34
|
+
const stateToUse = __spreadValues(__spreadValues(__spreadValues({}, (_c = content == null ? void 0 : content.data) == null ? void 0 : _c.state), data), locale ? {
|
|
35
|
+
locale
|
|
36
|
+
} : {});
|
|
34
37
|
return __spreadValues(__spreadValues({}, defaultValues), stateToUse);
|
|
35
38
|
};
|
|
36
39
|
const getContentInitialValue = ({
|
|
@@ -42,7 +45,4 @@ const getContentInitialValue = ({
|
|
|
42
45
|
meta: content == null ? void 0 : content.meta
|
|
43
46
|
});
|
|
44
47
|
};
|
|
45
|
-
export {
|
|
46
|
-
getContentInitialValue,
|
|
47
|
-
getContextStateInitialValue
|
|
48
|
-
};
|
|
48
|
+
export { getContentInitialValue, getContextStateInitialValue }
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import {
|
|
4
|
+
FlatList,
|
|
5
|
+
ScrollView,
|
|
6
|
+
View,
|
|
7
|
+
StyleSheet,
|
|
8
|
+
Image,
|
|
9
|
+
Text,
|
|
10
|
+
} from "react-native";
|
|
11
|
+
import { useState } from "react";
|
|
12
|
+
import { getDefaultRegisteredComponents } from "../../constants/builder-registered-components.js";
|
|
13
|
+
import {
|
|
14
|
+
components,
|
|
15
|
+
serializeComponentInfo,
|
|
16
|
+
} from "../../functions/register-component.js";
|
|
17
|
+
import Blocks from "../blocks/blocks";
|
|
18
|
+
import ContentStyles from "./components/styles";
|
|
19
|
+
import {
|
|
20
|
+
getContentInitialValue,
|
|
21
|
+
getContextStateInitialValue,
|
|
22
|
+
} from "./content.helpers.js";
|
|
23
|
+
import { TARGET } from "../../constants/target.js";
|
|
24
|
+
import { getRenderContentScriptString } from "../content-variants/helpers.js";
|
|
25
|
+
import EnableEditor from "./components/enable-editor";
|
|
26
|
+
import InlinedScript from "../inlined-script";
|
|
27
|
+
import { wrapComponentRef } from "./wrap-component-ref.js";
|
|
28
|
+
|
|
29
|
+
function ContentComponent(props) {
|
|
30
|
+
const [scriptStr, setScriptStr] = useState(() =>
|
|
31
|
+
getRenderContentScriptString({
|
|
32
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-non-null-asserted-optional-chain
|
|
33
|
+
variationId: props.content?.testVariationId,
|
|
34
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-non-null-asserted-optional-chain
|
|
35
|
+
contentId: props.content?.id,
|
|
36
|
+
})
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
function contentSetState(newRootState) {
|
|
40
|
+
builderContextSignal.rootState = newRootState;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const [registeredComponents, setRegisteredComponents] = useState(() =>
|
|
44
|
+
[
|
|
45
|
+
...getDefaultRegisteredComponents(),
|
|
46
|
+
// While this `components` object is deprecated, we must maintain support for it.
|
|
47
|
+
// Since users are able to override our default components, we need to make sure that we do not break such
|
|
48
|
+
// existing usage.
|
|
49
|
+
// This is why we spread `components` after the default Builder.io components, but before the `props.customComponents`,
|
|
50
|
+
// which is the new standard way of providing custom components, and must therefore take precedence.
|
|
51
|
+
...components,
|
|
52
|
+
...(props.customComponents || []),
|
|
53
|
+
].reduce(
|
|
54
|
+
(acc, { component, ...info }) => ({
|
|
55
|
+
...acc,
|
|
56
|
+
[info.name]: {
|
|
57
|
+
component: component,
|
|
58
|
+
...serializeComponentInfo(info),
|
|
59
|
+
},
|
|
60
|
+
}),
|
|
61
|
+
{}
|
|
62
|
+
)
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
const [builderContextSignal, setBuilderContextSignal] = useState(() => ({
|
|
66
|
+
content: getContentInitialValue({
|
|
67
|
+
content: props.content,
|
|
68
|
+
data: props.data,
|
|
69
|
+
}),
|
|
70
|
+
localState: undefined,
|
|
71
|
+
rootState: getContextStateInitialValue({
|
|
72
|
+
content: props.content,
|
|
73
|
+
data: props.data,
|
|
74
|
+
locale: props.locale,
|
|
75
|
+
}),
|
|
76
|
+
rootSetState: contentSetState,
|
|
77
|
+
context: props.context || {},
|
|
78
|
+
apiKey: props.apiKey,
|
|
79
|
+
apiVersion: props.apiVersion,
|
|
80
|
+
componentInfos: [
|
|
81
|
+
...getDefaultRegisteredComponents(),
|
|
82
|
+
// While this `components` object is deprecated, we must maintain support for it.
|
|
83
|
+
// Since users are able to override our default components, we need to make sure that we do not break such
|
|
84
|
+
// existing usage.
|
|
85
|
+
// This is why we spread `components` after the default Builder.io components, but before the `props.customComponents`,
|
|
86
|
+
// which is the new standard way of providing custom components, and must therefore take precedence.
|
|
87
|
+
...components,
|
|
88
|
+
...(props.customComponents || []),
|
|
89
|
+
].reduce(
|
|
90
|
+
(acc, { component: _, ...info }) => ({
|
|
91
|
+
...acc,
|
|
92
|
+
[info.name]: serializeComponentInfo(info),
|
|
93
|
+
}),
|
|
94
|
+
{}
|
|
95
|
+
),
|
|
96
|
+
inheritedStyles: {},
|
|
97
|
+
}));
|
|
98
|
+
|
|
99
|
+
return (
|
|
100
|
+
<EnableEditor
|
|
101
|
+
content={props.content}
|
|
102
|
+
model={props.model}
|
|
103
|
+
context={props.context}
|
|
104
|
+
apiKey={props.apiKey}
|
|
105
|
+
canTrack={props.canTrack}
|
|
106
|
+
locale={props.locale}
|
|
107
|
+
includeRefs={props.includeRefs}
|
|
108
|
+
enrich={props.enrich}
|
|
109
|
+
classNameProp={props.classNameProp}
|
|
110
|
+
showContent={props.showContent}
|
|
111
|
+
builderContextSignal={builderContextSignal}
|
|
112
|
+
{...{
|
|
113
|
+
setBuilderContextSignal: setBuilderContextSignal,
|
|
114
|
+
}}
|
|
115
|
+
>
|
|
116
|
+
{props.isSsrAbTest ? (
|
|
117
|
+
<>
|
|
118
|
+
<InlinedScript scriptStr={scriptStr} />
|
|
119
|
+
</>
|
|
120
|
+
) : null}
|
|
121
|
+
|
|
122
|
+
{TARGET !== "reactNative" ? (
|
|
123
|
+
<>
|
|
124
|
+
<ContentStyles
|
|
125
|
+
contentId={builderContextSignal.content?.id}
|
|
126
|
+
cssCode={builderContextSignal.content?.data?.cssCode}
|
|
127
|
+
customFonts={builderContextSignal.content?.data?.customFonts}
|
|
128
|
+
/>
|
|
129
|
+
</>
|
|
130
|
+
) : null}
|
|
131
|
+
|
|
132
|
+
<Blocks
|
|
133
|
+
blocks={builderContextSignal.content?.data?.blocks}
|
|
134
|
+
context={builderContextSignal}
|
|
135
|
+
registeredComponents={registeredComponents}
|
|
136
|
+
/>
|
|
137
|
+
</EnableEditor>
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export default ContentComponent;
|
|
File without changes
|