@builder.io/sdk-react 0.1.1 → 0.1.3
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/react/blocks/BaseText.js +7 -0
- package/dist/react/blocks/button/button.js +9 -0
- package/dist/react/blocks/button/component-info.js +39 -0
- package/dist/react/blocks/columns/columns.js +131 -0
- package/dist/react/blocks/columns/component-info.js +241 -0
- package/dist/react/blocks/custom-code/component-info.js +29 -0
- package/dist/react/blocks/custom-code/custom-code.js +49 -0
- package/dist/react/blocks/embed/component-info.js +44 -0
- package/dist/react/blocks/embed/embed.js +40 -0
- package/dist/react/blocks/embed/helpers.js +7 -0
- package/dist/react/blocks/form/component-info.js +260 -0
- package/dist/react/blocks/form/form.js +201 -0
- package/dist/react/blocks/fragment/component-info.js +9 -0
- package/dist/react/blocks/fragment/fragment.js +4 -0
- package/dist/react/blocks/image/component-info.js +149 -0
- package/dist/react/blocks/image/image.helpers.js +46 -0
- package/dist/react/blocks/image/image.js +82 -0
- package/dist/react/blocks/img/component-info.js +18 -0
- package/dist/react/blocks/img/img.js +8 -0
- package/dist/react/blocks/input/component-info.js +72 -0
- package/dist/react/blocks/input/input.js +5 -0
- package/dist/react/blocks/raw-text/component-info.js +14 -0
- package/dist/react/blocks/raw-text/raw-text.js +4 -0
- package/dist/react/blocks/section/component-info.js +47 -0
- package/dist/react/blocks/section/section.js +17 -0
- package/dist/react/blocks/select/component-info.js +57 -0
- package/dist/react/blocks/select/select.js +5 -0
- package/dist/react/blocks/submit-button/component-info.js +26 -0
- package/dist/react/blocks/submit-button/submit-button.js +4 -0
- package/dist/react/blocks/symbol/component-info.js +41 -0
- package/dist/react/blocks/symbol/symbol.js +63 -0
- package/dist/react/blocks/text/component-info.js +22 -0
- package/dist/react/blocks/text/text.js +4 -0
- package/dist/react/blocks/textarea/component-info.js +45 -0
- package/dist/react/blocks/textarea/textarea.js +4 -0
- package/dist/react/blocks/util.js +6 -0
- package/dist/react/blocks/video/component-info.js +104 -0
- package/dist/react/blocks/video/video.js +48 -0
- package/dist/react/components/render-block/block-styles.js +48 -0
- package/dist/react/components/render-block/render-block.helpers.js +104 -0
- package/dist/react/components/render-block/render-block.js +122 -0
- package/dist/react/components/render-block/render-component-with-context.js +27 -0
- package/dist/react/components/render-block/render-component.js +10 -0
- package/dist/react/components/render-block/render-repeated-block.js +15 -0
- package/dist/react/components/render-block/types.js +1 -0
- package/dist/react/components/render-blocks.js +45 -0
- package/dist/react/components/render-content/builder-editing.js +4 -0
- package/dist/react/components/render-content/components/render-styles.js +59 -0
- package/dist/react/components/render-content/index.js +2 -0
- package/dist/react/components/render-content/render-content.js +285 -0
- package/dist/react/components/render-inlined-styles.js +15 -0
- package/dist/react/constants/builder-registered-components.js +52 -0
- package/dist/react/constants/device-sizes.js +45 -0
- package/dist/react/constants/target.js +2 -0
- package/dist/react/context/builder.context.js +10 -0
- package/dist/react/context/types.js +1 -0
- package/dist/react/functions/camel-to-kebab-case.js +2 -0
- package/dist/react/functions/evaluate.js +22 -0
- package/dist/react/functions/event-handler-name.js +5 -0
- package/dist/react/functions/extract-text-styles.js +20 -0
- package/dist/react/functions/fast-clone.js +2 -0
- package/dist/react/functions/get-block-actions-handler.js +9 -0
- package/dist/react/functions/get-block-actions.js +16 -0
- package/dist/react/functions/get-block-component-options.js +26 -0
- package/dist/react/functions/get-block-properties.js +48 -0
- package/dist/react/functions/get-block-tag.js +4 -0
- package/dist/react/functions/get-builder-search-params/fn.test.js +13 -0
- package/dist/react/functions/get-builder-search-params/index.js +33 -0
- package/dist/react/functions/get-content/ab-testing.js +86 -0
- package/dist/react/functions/get-content/generate-content-url.js +41 -0
- package/dist/react/functions/get-content/generate-content-url.test.js +31 -0
- package/dist/react/functions/get-content/index.js +64 -0
- package/dist/react/functions/get-content/types.js +1 -0
- package/dist/react/functions/get-fetch.js +12 -0
- package/dist/react/functions/get-global-this.js +16 -0
- package/dist/react/functions/get-processed-block.js +49 -0
- package/dist/react/functions/get-processed-block.test.js +32 -0
- package/dist/react/functions/get-react-native-block-styles.js +27 -0
- package/dist/react/functions/if-target.js +10 -0
- package/dist/react/functions/is-browser.js +4 -0
- package/dist/react/functions/is-editing.js +5 -0
- package/dist/react/functions/is-iframe.js +5 -0
- package/dist/react/functions/is-previewing.js +12 -0
- package/dist/react/functions/on-change.js +24 -0
- package/dist/react/functions/on-change.test.js +19 -0
- package/dist/react/functions/register-component.js +60 -0
- package/dist/react/functions/register.js +28 -0
- package/dist/react/functions/sanitize-react-native-block-styles.js +68 -0
- package/dist/react/functions/set-editor-settings.js +13 -0
- package/dist/react/functions/set.js +9 -0
- package/dist/react/functions/set.test.js +16 -0
- package/dist/react/functions/track/helpers.js +50 -0
- package/dist/react/functions/track/index.js +120 -0
- package/dist/react/functions/track/interaction.js +48 -0
- package/dist/react/functions/track.js +116 -0
- package/dist/react/functions/transform-block-properties.js +4 -0
- package/dist/react/functions/transform-block.js +4 -0
- package/dist/react/helpers/ab-tests.js +6 -0
- package/dist/react/helpers/cookie.js +70 -0
- package/dist/react/helpers/css.js +28 -0
- package/dist/react/helpers/flatten.js +32 -0
- package/dist/react/helpers/localStorage.js +27 -0
- package/dist/react/helpers/nullable.js +2 -0
- package/dist/react/helpers/sessionId.js +46 -0
- package/dist/react/helpers/time.js +3 -0
- package/dist/react/helpers/url.js +11 -0
- package/dist/react/helpers/url.test.js +21 -0
- package/dist/react/helpers/uuid.js +10 -0
- package/dist/react/helpers/visitorId.js +28 -0
- package/dist/react/index-helpers/blocks-exports.js +11 -0
- package/dist/react/index-helpers/top-of-file.js +2 -0
- package/dist/react/index.js +12 -0
- package/dist/react/scripts/init-editing.js +93 -0
- package/dist/react/types/builder-block.js +1 -0
- package/dist/react/types/builder-content.js +1 -0
- package/dist/react/types/can-track.js +1 -0
- package/dist/react/types/components.js +1 -0
- package/dist/react/types/deep-partial.js +1 -0
- package/dist/react/types/element.js +1 -0
- package/dist/react/types/targets.js +1 -0
- package/dist/react/types/typescript.js +1 -0
- package/dist/rsc/blocks/BaseText.js +7 -0
- package/dist/rsc/blocks/button/button.js +10 -0
- package/dist/rsc/blocks/button/component-info.js +39 -0
- package/dist/rsc/blocks/columns/columns.js +136 -0
- package/dist/rsc/blocks/columns/component-info.js +241 -0
- package/dist/rsc/blocks/custom-code/component-info.js +29 -0
- package/dist/rsc/blocks/custom-code/custom-code.js +45 -0
- package/dist/rsc/blocks/embed/component-info.js +44 -0
- package/dist/rsc/blocks/embed/embed.js +36 -0
- package/dist/rsc/blocks/embed/helpers.js +7 -0
- package/dist/rsc/blocks/form/component-info.js +260 -0
- package/dist/rsc/blocks/form/form.js +204 -0
- package/dist/rsc/blocks/fragment/component-info.js +9 -0
- package/dist/rsc/blocks/fragment/fragment.js +5 -0
- package/dist/rsc/blocks/image/component-info.js +149 -0
- package/dist/rsc/blocks/image/image.helpers.js +46 -0
- package/dist/rsc/blocks/image/image.js +85 -0
- package/dist/rsc/blocks/img/component-info.js +18 -0
- package/dist/rsc/blocks/img/img.js +9 -0
- package/dist/rsc/blocks/input/component-info.js +72 -0
- package/dist/rsc/blocks/input/input.js +6 -0
- package/dist/rsc/blocks/raw-text/component-info.js +14 -0
- package/dist/rsc/blocks/raw-text/raw-text.js +5 -0
- package/dist/rsc/blocks/section/component-info.js +47 -0
- package/dist/rsc/blocks/section/section.js +18 -0
- package/dist/rsc/blocks/select/component-info.js +57 -0
- package/dist/rsc/blocks/select/select.js +6 -0
- package/dist/rsc/blocks/submit-button/component-info.js +26 -0
- package/dist/rsc/blocks/submit-button/submit-button.js +5 -0
- package/dist/rsc/blocks/symbol/component-info.js +41 -0
- package/dist/rsc/blocks/symbol/symbol.js +37 -0
- package/dist/rsc/blocks/text/component-info.js +22 -0
- package/dist/rsc/blocks/text/text.js +5 -0
- package/dist/rsc/blocks/textarea/component-info.js +45 -0
- package/dist/rsc/blocks/textarea/textarea.js +5 -0
- package/dist/rsc/blocks/util.js +6 -0
- package/dist/rsc/blocks/video/component-info.js +104 -0
- package/dist/rsc/blocks/video/video.js +51 -0
- package/dist/rsc/components/render-block/block-styles.js +51 -0
- package/dist/rsc/components/render-block/render-block.helpers.js +104 -0
- package/dist/rsc/components/render-block/render-block.js +126 -0
- package/dist/rsc/components/render-block/render-component-with-context.js +27 -0
- package/dist/rsc/components/render-block/render-component.js +11 -0
- package/dist/rsc/components/render-block/render-repeated-block.js +15 -0
- package/dist/rsc/components/render-block/types.js +1 -0
- package/dist/rsc/components/render-blocks.js +47 -0
- package/dist/rsc/components/render-content/builder-editing.js +5 -0
- package/dist/rsc/components/render-content/components/render-styles.js +62 -0
- package/dist/rsc/components/render-content/index.js +2 -0
- package/dist/rsc/components/render-content/render-content.js +201 -0
- package/dist/rsc/components/render-inlined-styles.js +18 -0
- package/dist/rsc/constants/builder-registered-components.js +52 -0
- package/dist/rsc/constants/device-sizes.js +45 -0
- package/dist/rsc/constants/target.js +2 -0
- package/dist/rsc/context/builder.context.js +9 -0
- package/dist/rsc/context/types.js +1 -0
- package/dist/rsc/functions/camel-to-kebab-case.js +2 -0
- package/dist/rsc/functions/evaluate.js +4 -0
- package/dist/rsc/functions/event-handler-name.js +5 -0
- package/dist/rsc/functions/extract-text-styles.js +20 -0
- package/dist/rsc/functions/fast-clone.js +2 -0
- package/dist/rsc/functions/get-block-actions-handler.js +9 -0
- package/dist/rsc/functions/get-block-actions.js +16 -0
- package/dist/rsc/functions/get-block-component-options.js +26 -0
- package/dist/rsc/functions/get-block-properties.js +48 -0
- package/dist/rsc/functions/get-block-tag.js +4 -0
- package/dist/rsc/functions/get-builder-search-params/fn.test.js +13 -0
- package/dist/rsc/functions/get-builder-search-params/index.js +33 -0
- package/dist/rsc/functions/get-content/ab-testing.js +86 -0
- package/dist/rsc/functions/get-content/generate-content-url.js +41 -0
- package/dist/rsc/functions/get-content/generate-content-url.test.js +31 -0
- package/dist/rsc/functions/get-content/index.js +64 -0
- package/dist/rsc/functions/get-content/types.js +1 -0
- package/dist/rsc/functions/get-fetch.js +12 -0
- package/dist/rsc/functions/get-global-this.js +16 -0
- package/dist/rsc/functions/get-processed-block.js +49 -0
- package/dist/rsc/functions/get-processed-block.test.js +32 -0
- package/dist/rsc/functions/get-react-native-block-styles.js +27 -0
- package/dist/rsc/functions/if-target.js +10 -0
- package/dist/rsc/functions/is-browser.js +4 -0
- package/dist/rsc/functions/is-editing.js +5 -0
- package/dist/rsc/functions/is-iframe.js +5 -0
- package/dist/rsc/functions/is-previewing.js +12 -0
- package/dist/rsc/functions/on-change.js +24 -0
- package/dist/rsc/functions/on-change.test.js +19 -0
- package/dist/rsc/functions/register-component.js +60 -0
- package/dist/rsc/functions/register.js +28 -0
- package/dist/rsc/functions/sanitize-react-native-block-styles.js +68 -0
- package/dist/rsc/functions/set-editor-settings.js +13 -0
- package/dist/rsc/functions/set.js +9 -0
- package/dist/rsc/functions/set.test.js +16 -0
- package/dist/rsc/functions/track/helpers.js +50 -0
- package/dist/rsc/functions/track/index.js +120 -0
- package/dist/rsc/functions/track/interaction.js +48 -0
- package/dist/rsc/functions/track.js +116 -0
- package/dist/rsc/functions/transform-block-properties.js +4 -0
- package/dist/rsc/functions/transform-block.js +4 -0
- package/dist/rsc/helpers/ab-tests.js +6 -0
- package/dist/rsc/helpers/cookie.js +70 -0
- package/dist/rsc/helpers/css.js +28 -0
- package/dist/rsc/helpers/flatten.js +32 -0
- package/dist/rsc/helpers/localStorage.js +27 -0
- package/dist/rsc/helpers/nullable.js +2 -0
- package/dist/rsc/helpers/sessionId.js +46 -0
- package/dist/rsc/helpers/time.js +3 -0
- package/dist/rsc/helpers/url.js +11 -0
- package/dist/rsc/helpers/url.test.js +21 -0
- package/dist/rsc/helpers/uuid.js +10 -0
- package/dist/rsc/helpers/visitorId.js +28 -0
- package/dist/rsc/index-helpers/blocks-exports.js +11 -0
- package/dist/rsc/index-helpers/top-of-file.js +2 -0
- package/dist/rsc/index.js +12 -0
- package/dist/rsc/scripts/init-editing.js +93 -0
- package/dist/rsc/types/builder-block.js +1 -0
- package/dist/rsc/types/builder-content.js +1 -0
- package/dist/rsc/types/can-track.js +1 -0
- package/dist/rsc/types/components.js +1 -0
- package/dist/rsc/types/deep-partial.js +1 -0
- package/dist/rsc/types/element.js +1 -0
- package/dist/rsc/types/targets.js +1 -0
- package/dist/rsc/types/typescript.js +1 -0
- package/package.json +11 -6
- package/packages/_rsc/src/blocks/BaseText.jsx +10 -0
- package/packages/_rsc/src/blocks/button/button.jsx +29 -0
- package/packages/_rsc/src/blocks/columns/{columns.js → columns.jsx} +80 -61
- package/packages/_rsc/src/blocks/custom-code/custom-code.jsx +55 -0
- package/packages/_rsc/src/blocks/embed/embed.jsx +43 -0
- package/packages/_rsc/src/blocks/form/form.jsx +259 -0
- package/packages/_rsc/src/blocks/fragment/fragment.jsx +7 -0
- package/packages/_rsc/src/blocks/image/image.jsx +124 -0
- package/packages/_rsc/src/blocks/img/img.jsx +19 -0
- package/packages/_rsc/src/blocks/input/input.jsx +21 -0
- package/packages/_rsc/src/blocks/raw-text/raw-text.jsx +12 -0
- package/packages/_rsc/src/blocks/section/section.jsx +29 -0
- package/packages/_rsc/src/blocks/select/select.jsx +22 -0
- package/packages/_rsc/src/blocks/submit-button/submit-button.jsx +11 -0
- package/packages/_rsc/src/blocks/symbol/symbol.jsx +56 -0
- package/packages/_rsc/src/blocks/text/text.jsx +12 -0
- package/packages/_rsc/src/blocks/textarea/textarea.jsx +15 -0
- package/packages/_rsc/src/blocks/video/video.jsx +61 -0
- package/packages/_rsc/src/components/render-block/block-styles.jsx +72 -0
- package/packages/_rsc/src/components/render-block/render-block.jsx +251 -0
- package/packages/_rsc/src/components/render-block/render-component-with-context.jsx +38 -0
- package/packages/_rsc/src/components/render-block/render-component.jsx +37 -0
- package/packages/_rsc/src/components/render-block/render-repeated-block.jsx +36 -0
- package/packages/_rsc/src/components/render-blocks.jsx +90 -0
- package/packages/_rsc/src/components/render-content/builder-editing.jsx +7 -0
- package/packages/_rsc/src/components/render-content/components/render-styles.jsx +70 -0
- package/packages/_rsc/src/components/render-content/render-content.jsx +259 -0
- package/packages/_rsc/src/components/render-inlined-styles.jsx +33 -0
- package/packages/_rsc/src/helpers/cookie.js +4 -2
- package/packages/_rsc/src/helpers/localStorage.js +1 -0
- package/packages/_rsc/src/helpers/sessionId.js +4 -1
- package/packages/_rsc/src/helpers/url.js +3 -0
- package/packages/_rsc/src/helpers/url.test.js +6 -0
- package/packages/_rsc/src/helpers/visitorId.js +1 -0
- package/packages/react/src/blocks/BaseText.jsx +9 -0
- package/packages/react/src/blocks/button/button.jsx +27 -0
- package/packages/react/src/blocks/button/component-info.js +41 -0
- package/packages/react/src/blocks/columns/columns.jsx +172 -0
- package/packages/react/src/blocks/columns/component-info.js +242 -0
- package/packages/react/src/blocks/custom-code/component-info.js +31 -0
- package/packages/react/src/blocks/custom-code/custom-code.jsx +64 -0
- package/packages/react/src/blocks/embed/component-info.js +44 -0
- package/packages/react/src/blocks/embed/embed.jsx +49 -0
- package/packages/react/src/blocks/embed/helpers.js +9 -0
- package/packages/react/src/blocks/form/component-info.js +262 -0
- package/packages/react/src/blocks/form/form.jsx +253 -0
- package/packages/react/src/blocks/fragment/component-info.js +11 -0
- package/packages/react/src/blocks/fragment/fragment.jsx +5 -0
- package/packages/react/src/blocks/image/component-info.js +151 -0
- package/packages/react/src/blocks/image/image.helpers.js +48 -0
- package/packages/react/src/blocks/image/image.jsx +120 -0
- package/packages/react/src/blocks/img/component-info.js +20 -0
- package/packages/react/src/blocks/img/img.jsx +17 -0
- package/packages/react/src/blocks/input/component-info.js +74 -0
- package/packages/react/src/blocks/input/input.jsx +19 -0
- package/packages/react/src/blocks/raw-text/component-info.js +16 -0
- package/packages/react/src/blocks/raw-text/raw-text.jsx +10 -0
- package/packages/react/src/blocks/section/component-info.js +49 -0
- package/packages/react/src/blocks/section/section.jsx +27 -0
- package/packages/react/src/blocks/select/component-info.js +59 -0
- package/packages/react/src/blocks/select/select.jsx +20 -0
- package/packages/react/src/blocks/submit-button/component-info.js +28 -0
- package/packages/react/src/blocks/submit-button/submit-button.jsx +9 -0
- package/packages/react/src/blocks/symbol/component-info.js +43 -0
- package/packages/react/src/blocks/symbol/symbol.jsx +86 -0
- package/packages/react/src/blocks/text/component-info.js +24 -0
- package/packages/react/src/blocks/text/text.jsx +10 -0
- package/packages/react/src/blocks/textarea/component-info.js +47 -0
- package/packages/react/src/blocks/textarea/textarea.jsx +13 -0
- package/packages/react/src/blocks/util.js +8 -0
- package/packages/react/src/blocks/video/component-info.js +106 -0
- package/packages/react/src/blocks/video/video.jsx +58 -0
- package/packages/react/src/components/render-block/block-styles.jsx +69 -0
- package/packages/react/src/components/render-block/render-block.helpers.js +113 -0
- package/packages/react/src/components/render-block/render-block.jsx +184 -0
- package/packages/react/src/components/render-block/render-component.jsx +33 -0
- package/packages/react/src/components/render-block/render-repeated-block.jsx +21 -0
- package/packages/react/src/components/render-block/types.js +0 -0
- package/packages/react/src/components/render-blocks.jsx +89 -0
- package/packages/react/src/components/render-content/builder-editing.jsx +5 -0
- package/packages/react/src/components/render-content/components/render-styles.jsx +64 -0
- package/packages/react/src/components/render-content/index.js +4 -0
- package/packages/react/src/components/render-content/render-content.jsx +372 -0
- package/packages/react/src/components/render-inlined-styles.jsx +28 -0
- package/packages/react/src/constants/builder-registered-components.js +54 -0
- package/packages/react/src/constants/device-sizes.js +48 -0
- package/packages/react/src/constants/target.js +4 -0
- package/packages/react/src/context/builder.context.js +12 -0
- package/packages/react/src/context/types.js +0 -0
- package/packages/react/src/functions/camel-to-kebab-case.js +4 -0
- package/packages/react/src/functions/evaluate.js +29 -0
- package/packages/react/src/functions/event-handler-name.js +7 -0
- package/packages/react/src/functions/extract-text-styles.js +22 -0
- package/packages/react/src/functions/fast-clone.js +4 -0
- package/packages/react/src/functions/get-block-actions-handler.js +11 -0
- package/packages/react/src/functions/get-block-actions.js +18 -0
- package/packages/{_rsc/src/blocks/textarea/textarea.js → react/src/functions/get-block-component-options.js} +6 -10
- package/packages/react/src/functions/get-block-properties.js +50 -0
- package/packages/react/src/functions/get-block-tag.js +6 -0
- package/packages/react/src/functions/get-builder-search-params/fn.test.js +13 -0
- package/packages/react/src/functions/get-builder-search-params/index.js +38 -0
- package/packages/react/src/functions/get-content/ab-testing.js +99 -0
- package/packages/react/src/functions/get-content/generate-content-url.js +55 -0
- package/packages/react/src/functions/get-content/generate-content-url.test.js +31 -0
- package/packages/react/src/functions/get-content/index.js +65 -0
- package/packages/react/src/functions/get-content/types.js +0 -0
- package/packages/react/src/functions/get-fetch.js +14 -0
- package/packages/react/src/functions/get-global-this.js +18 -0
- package/packages/react/src/functions/get-processed-block.js +59 -0
- package/packages/react/src/functions/get-processed-block.test.js +32 -0
- package/packages/{_rsc/src/blocks/BaseText.js → react/src/functions/get-react-native-block-styles.js} +14 -8
- package/packages/react/src/functions/if-target.js +15 -0
- package/packages/react/src/functions/is-browser.js +6 -0
- package/packages/react/src/functions/is-editing.js +7 -0
- package/packages/react/src/functions/is-iframe.js +7 -0
- package/packages/react/src/functions/is-previewing.js +14 -0
- package/packages/react/src/functions/on-change.js +27 -0
- package/packages/react/src/functions/on-change.test.js +19 -0
- package/packages/react/src/functions/register-component.js +68 -0
- package/packages/react/src/functions/register.js +29 -0
- package/packages/react/src/functions/sanitize-react-native-block-styles.js +66 -0
- package/packages/react/src/functions/set-editor-settings.js +15 -0
- package/packages/react/src/functions/set.js +11 -0
- package/packages/react/src/functions/set.test.js +16 -0
- package/packages/react/src/functions/track/helpers.js +50 -0
- package/packages/react/src/functions/track/index.js +128 -0
- package/packages/react/src/functions/track/interaction.js +53 -0
- package/packages/react/src/functions/transform-block-properties.js +6 -0
- package/packages/react/src/functions/transform-block.js +6 -0
- package/packages/react/src/helpers/ab-tests.js +16 -0
- package/packages/react/src/helpers/cookie.js +81 -0
- package/packages/react/src/helpers/css.js +34 -0
- package/packages/{_rsc/src/blocks/input/input.js → react/src/helpers/flatten.js} +12 -14
- package/packages/react/src/helpers/localStorage.js +35 -0
- package/packages/react/src/helpers/nullable.js +4 -0
- package/packages/react/src/helpers/sessionId.js +52 -0
- package/packages/react/src/helpers/time.js +5 -0
- package/packages/react/src/helpers/url.js +13 -0
- package/packages/react/src/helpers/url.test.js +21 -0
- package/packages/react/src/helpers/uuid.js +13 -0
- package/packages/react/src/helpers/visitorId.js +34 -0
- package/packages/react/src/index-helpers/blocks-exports.js +22 -0
- package/packages/react/src/index-helpers/top-of-file.js +4 -0
- package/packages/react/src/index.js +14 -0
- package/packages/react/src/scripts/init-editing.js +93 -0
- package/packages/react/src/types/builder-block.js +0 -0
- package/packages/react/src/types/builder-content.js +0 -0
- package/packages/react/src/types/can-track.js +0 -0
- package/packages/react/src/types/components.js +0 -0
- package/packages/react/src/types/deep-partial.js +0 -0
- package/packages/react/src/types/element.js +0 -0
- package/packages/react/src/types/targets.js +0 -0
- package/packages/react/src/types/typescript.js +0 -0
- package/packages/rsc/src/blocks/BaseText.jsx +10 -0
- package/packages/rsc/src/blocks/button/button.jsx +29 -0
- package/packages/rsc/src/blocks/button/component-info.js +41 -0
- package/packages/rsc/src/blocks/columns/columns.jsx +172 -0
- package/packages/rsc/src/blocks/columns/component-info.js +242 -0
- package/packages/rsc/src/blocks/custom-code/component-info.js +31 -0
- package/packages/rsc/src/blocks/custom-code/custom-code.jsx +55 -0
- package/packages/rsc/src/blocks/embed/component-info.js +44 -0
- package/packages/rsc/src/blocks/embed/embed.jsx +43 -0
- package/packages/rsc/src/blocks/embed/helpers.js +9 -0
- package/packages/rsc/src/blocks/form/component-info.js +262 -0
- package/packages/rsc/src/blocks/form/form.jsx +259 -0
- package/packages/rsc/src/blocks/fragment/component-info.js +11 -0
- package/packages/rsc/src/blocks/fragment/fragment.jsx +7 -0
- package/packages/rsc/src/blocks/image/component-info.js +151 -0
- package/packages/rsc/src/blocks/image/image.helpers.js +48 -0
- package/packages/rsc/src/blocks/image/image.jsx +122 -0
- package/packages/rsc/src/blocks/img/component-info.js +20 -0
- package/packages/rsc/src/blocks/img/img.jsx +19 -0
- package/packages/rsc/src/blocks/input/component-info.js +74 -0
- package/packages/rsc/src/blocks/input/input.jsx +21 -0
- package/packages/rsc/src/blocks/raw-text/component-info.js +16 -0
- package/packages/rsc/src/blocks/raw-text/raw-text.jsx +12 -0
- package/packages/rsc/src/blocks/section/component-info.js +49 -0
- package/packages/rsc/src/blocks/section/section.jsx +29 -0
- package/packages/rsc/src/blocks/select/component-info.js +59 -0
- package/packages/rsc/src/blocks/select/select.jsx +22 -0
- package/packages/rsc/src/blocks/submit-button/component-info.js +28 -0
- package/packages/rsc/src/blocks/submit-button/submit-button.jsx +11 -0
- package/packages/rsc/src/blocks/symbol/component-info.js +43 -0
- package/packages/rsc/src/blocks/symbol/symbol.jsx +56 -0
- package/packages/rsc/src/blocks/text/component-info.js +24 -0
- package/packages/rsc/src/blocks/text/text.jsx +12 -0
- package/packages/rsc/src/blocks/textarea/component-info.js +47 -0
- package/packages/rsc/src/blocks/textarea/textarea.jsx +15 -0
- package/packages/rsc/src/blocks/util.js +8 -0
- package/packages/rsc/src/blocks/video/component-info.js +106 -0
- package/packages/rsc/src/blocks/video/video.jsx +61 -0
- package/packages/rsc/src/components/render-block/block-styles.jsx +72 -0
- package/packages/rsc/src/components/render-block/render-block.helpers.js +113 -0
- package/packages/rsc/src/components/render-block/render-block.jsx +183 -0
- package/packages/rsc/src/components/render-block/render-component.jsx +37 -0
- package/packages/rsc/src/components/render-block/render-repeated-block.jsx +24 -0
- package/packages/rsc/src/components/render-block/types.js +0 -0
- package/packages/rsc/src/components/render-blocks.jsx +90 -0
- package/packages/rsc/src/components/render-content/builder-editing.jsx +7 -0
- package/packages/rsc/src/components/render-content/components/render-styles.jsx +70 -0
- package/packages/rsc/src/components/render-content/index.js +4 -0
- package/packages/rsc/src/components/render-content/render-content.jsx +245 -0
- package/packages/rsc/src/components/render-inlined-styles.jsx +33 -0
- package/packages/rsc/src/constants/builder-registered-components.js +54 -0
- package/packages/rsc/src/constants/device-sizes.js +48 -0
- package/packages/rsc/src/constants/target.js +4 -0
- package/packages/rsc/src/context/builder.context.js +11 -0
- package/packages/rsc/src/context/types.js +0 -0
- package/packages/rsc/src/functions/camel-to-kebab-case.js +4 -0
- package/packages/rsc/src/functions/evaluate.js +6 -0
- package/packages/rsc/src/functions/event-handler-name.js +7 -0
- package/packages/rsc/src/functions/extract-text-styles.js +22 -0
- package/packages/rsc/src/functions/fast-clone.js +4 -0
- package/packages/rsc/src/functions/get-block-actions-handler.js +11 -0
- package/packages/rsc/src/functions/get-block-actions.js +18 -0
- package/packages/{_rsc/src/blocks/text/text.js → rsc/src/functions/get-block-component-options.js} +8 -7
- package/packages/rsc/src/functions/get-block-properties.js +50 -0
- package/packages/rsc/src/functions/get-block-tag.js +6 -0
- package/packages/rsc/src/functions/get-builder-search-params/fn.test.js +13 -0
- package/packages/rsc/src/functions/get-builder-search-params/index.js +38 -0
- package/packages/rsc/src/functions/get-content/ab-testing.js +99 -0
- package/packages/rsc/src/functions/get-content/generate-content-url.js +55 -0
- package/packages/rsc/src/functions/get-content/generate-content-url.test.js +31 -0
- package/packages/rsc/src/functions/get-content/index.js +65 -0
- package/packages/rsc/src/functions/get-content/types.js +0 -0
- package/packages/rsc/src/functions/get-fetch.js +14 -0
- package/packages/rsc/src/functions/get-global-this.js +18 -0
- package/packages/rsc/src/functions/get-processed-block.js +59 -0
- package/packages/rsc/src/functions/get-processed-block.test.js +32 -0
- package/packages/{_rsc/src/blocks/raw-text/raw-text.js → rsc/src/functions/get-react-native-block-styles.js} +14 -9
- package/packages/rsc/src/functions/if-target.js +15 -0
- package/packages/rsc/src/functions/is-browser.js +6 -0
- package/packages/rsc/src/functions/is-editing.js +7 -0
- package/packages/rsc/src/functions/is-iframe.js +7 -0
- package/packages/rsc/src/functions/is-previewing.js +14 -0
- package/packages/rsc/src/functions/on-change.js +27 -0
- package/packages/rsc/src/functions/on-change.test.js +19 -0
- package/packages/rsc/src/functions/register-component.js +68 -0
- package/packages/rsc/src/functions/register.js +29 -0
- package/packages/rsc/src/functions/sanitize-react-native-block-styles.js +66 -0
- package/packages/rsc/src/functions/set-editor-settings.js +15 -0
- package/packages/rsc/src/functions/set.js +11 -0
- package/packages/rsc/src/functions/set.test.js +16 -0
- package/packages/rsc/src/functions/track/helpers.js +50 -0
- package/packages/rsc/src/functions/track/index.js +128 -0
- package/packages/rsc/src/functions/track/interaction.js +53 -0
- package/packages/rsc/src/functions/transform-block-properties.js +6 -0
- package/packages/rsc/src/functions/transform-block.js +6 -0
- package/packages/rsc/src/helpers/ab-tests.js +16 -0
- package/packages/rsc/src/helpers/cookie.js +81 -0
- package/packages/rsc/src/helpers/css.js +34 -0
- package/packages/{_rsc/src/blocks/section/section.js → rsc/src/helpers/flatten.js} +12 -18
- package/packages/rsc/src/helpers/localStorage.js +35 -0
- package/packages/rsc/src/helpers/nullable.js +4 -0
- package/packages/rsc/src/helpers/sessionId.js +52 -0
- package/packages/rsc/src/helpers/time.js +5 -0
- package/packages/rsc/src/helpers/url.js +13 -0
- package/packages/rsc/src/helpers/url.test.js +21 -0
- package/packages/rsc/src/helpers/uuid.js +13 -0
- package/packages/rsc/src/helpers/visitorId.js +34 -0
- package/packages/rsc/src/index-helpers/blocks-exports.js +22 -0
- package/packages/rsc/src/index-helpers/top-of-file.js +2 -0
- package/packages/rsc/src/index.js +14 -0
- package/packages/rsc/src/scripts/init-editing.js +93 -0
- package/packages/rsc/src/types/builder-block.js +0 -0
- package/packages/rsc/src/types/builder-content.js +0 -0
- package/packages/rsc/src/types/can-track.js +0 -0
- package/packages/rsc/src/types/components.js +0 -0
- package/packages/rsc/src/types/deep-partial.js +0 -0
- package/packages/rsc/src/types/element.js +0 -0
- package/packages/rsc/src/types/targets.js +0 -0
- package/packages/rsc/src/types/typescript.js +0 -0
- package/src/blocks/BaseText.jsx +4 -7
- package/src/blocks/button/button.jsx +25 -32
- package/src/blocks/columns/columns.jsx +83 -59
- package/src/blocks/custom-code/custom-code.jsx +29 -15
- package/src/blocks/embed/embed.jsx +15 -11
- package/src/blocks/form/form.jsx +184 -148
- package/src/blocks/fragment/fragment.jsx +3 -5
- package/src/blocks/image/image.jsx +80 -56
- package/src/blocks/img/img.jsx +14 -29
- package/src/blocks/input/input.jsx +16 -32
- package/src/blocks/raw-text/raw-text.jsx +8 -9
- package/src/blocks/section/section.jsx +25 -37
- package/src/blocks/select/select.jsx +17 -32
- package/src/blocks/submit-button/submit-button.jsx +7 -23
- package/src/blocks/symbol/symbol.jsx +59 -48
- package/src/blocks/text/text.jsx +8 -8
- package/src/blocks/textarea/textarea.jsx +11 -29
- package/src/blocks/video/video.jsx +52 -48
- package/src/components/render-block/block-styles.jsx +48 -29
- package/src/components/render-block/render-block.jsx +150 -100
- package/src/components/render-block/render-component-with-context.jsx +35 -32
- package/src/components/render-block/render-component.jsx +30 -32
- package/src/components/render-block/render-repeated-block.jsx +30 -30
- package/src/components/render-blocks.jsx +73 -47
- package/src/components/render-content/builder-editing.jsx +3 -5
- package/src/components/render-content/components/render-styles.jsx +21 -15
- package/src/components/render-content/index.js +1 -1
- package/src/components/render-content/render-content.jsx +209 -134
- package/src/components/render-inlined-styles.jsx +19 -8
- package/src/constants/builder-registered-components.js +11 -11
- package/src/helpers/cookie.js +4 -2
- package/src/helpers/localStorage.js +1 -0
- package/src/helpers/sessionId.js +4 -1
- package/src/helpers/url.js +3 -0
- package/src/helpers/url.test.js +6 -0
- package/src/helpers/visitorId.js +1 -0
- package/src/index-helpers/blocks-exports.js +10 -10
- package/tsconfig.base.json +18 -0
- package/tsconfig.react.json +7 -0
- package/tsconfig.rsc.json +7 -0
- package/packages/_rsc/src/blocks/button/button.js +0 -35
- package/packages/_rsc/src/blocks/custom-code/custom-code.js +0 -63
- package/packages/_rsc/src/blocks/embed/embed.js +0 -55
- package/packages/_rsc/src/blocks/form/form.js +0 -222
- package/packages/_rsc/src/blocks/fragment/fragment.js +0 -24
- package/packages/_rsc/src/blocks/image/image.js +0 -101
- package/packages/_rsc/src/blocks/img/img.js +0 -33
- package/packages/_rsc/src/blocks/select/select.js +0 -36
- package/packages/_rsc/src/blocks/submit-button/submit-button.js +0 -26
- package/packages/_rsc/src/blocks/symbol/symbol.js +0 -60
- package/packages/_rsc/src/blocks/video/video.js +0 -57
- package/packages/_rsc/src/components/render-block/block-styles.js +0 -70
- package/packages/_rsc/src/components/render-block/render-block.js +0 -211
- package/packages/_rsc/src/components/render-block/render-component-with-context.js +0 -51
- package/packages/_rsc/src/components/render-block/render-component.js +0 -43
- package/packages/_rsc/src/components/render-block/render-repeated-block.js +0 -49
- package/packages/_rsc/src/components/render-blocks.js +0 -80
- package/packages/_rsc/src/components/render-content/builder-editing.js +0 -35
- package/packages/_rsc/src/components/render-content/components/render-styles.js +0 -78
- package/packages/_rsc/src/components/render-content/render-content.js +0 -215
- package/packages/_rsc/src/components/render-inlined-styles.js +0 -36
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { useState, useContext, useRef, useEffect } from "react";
|
|
3
|
+
import { getDefaultRegisteredComponents } from "../../constants/builder-registered-components.js";
|
|
4
|
+
import { TARGET } from "../../constants/target.js";
|
|
5
|
+
import { evaluate } from "../../functions/evaluate.js";
|
|
6
|
+
import { getContent } from "../../functions/get-content/index.js";
|
|
7
|
+
import { fetch } from "../../functions/get-fetch.js";
|
|
8
|
+
import { isBrowser } from "../../functions/is-browser.js";
|
|
9
|
+
import { isEditing } from "../../functions/is-editing.js";
|
|
10
|
+
import { isPreviewing } from "../../functions/is-previewing.js";
|
|
11
|
+
import { components, createRegisterComponentMessage, } from "../../functions/register-component.js";
|
|
12
|
+
import { _track } from "../../functions/track/index.js";
|
|
13
|
+
import RenderBlocks from "../render-blocks.js";
|
|
14
|
+
import RenderContentStyles from "./components/render-styles.js";
|
|
15
|
+
import builderContext from "../../context/builder.context.js";
|
|
16
|
+
import { registerInsertMenu, setupBrowserForEditing, } from "../../scripts/init-editing.js";
|
|
17
|
+
import { checkIsDefined } from "../../helpers/nullable.js";
|
|
18
|
+
import { getInteractionPropertiesForEvent } from "../../functions/track/interaction.js";
|
|
19
|
+
export default function RenderContent(props) {
|
|
20
|
+
const elementRef = useRef(null);
|
|
21
|
+
const [forceReRenderCount, setForceReRenderCount] = useState(() => 0);
|
|
22
|
+
const [overrideContent, setOverrideContent] = useState(() => null);
|
|
23
|
+
function useContent() {
|
|
24
|
+
if (!props.content && !overrideContent) {
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
...props.content,
|
|
29
|
+
...overrideContent,
|
|
30
|
+
data: {
|
|
31
|
+
...props.content?.data,
|
|
32
|
+
...props.data,
|
|
33
|
+
...overrideContent?.data,
|
|
34
|
+
},
|
|
35
|
+
meta: {
|
|
36
|
+
...props.content?.meta,
|
|
37
|
+
...overrideContent?.meta,
|
|
38
|
+
breakpoints: useBreakpoints ||
|
|
39
|
+
overrideContent?.meta?.breakpoints ||
|
|
40
|
+
props.content?.meta?.breakpoints,
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
const [update, setUpdate] = useState(() => 0);
|
|
45
|
+
const [useBreakpoints, setUseBreakpoints] = useState(() => null);
|
|
46
|
+
const [canTrackToUse, setCanTrackToUse] = useState(() => checkIsDefined(props.canTrack) ? props.canTrack : true);
|
|
47
|
+
const [overrideState, setOverrideState] = useState(() => ({}));
|
|
48
|
+
function contentState() {
|
|
49
|
+
return {
|
|
50
|
+
...props.content?.data?.state,
|
|
51
|
+
...props.data,
|
|
52
|
+
...(props.locale
|
|
53
|
+
? {
|
|
54
|
+
locale: props.locale,
|
|
55
|
+
}
|
|
56
|
+
: {}),
|
|
57
|
+
...overrideState,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
const [contextContext, setContextContext] = useState(() => props.context || {});
|
|
61
|
+
const [allRegisteredComponents, setAllRegisteredComponents] = useState(() => [
|
|
62
|
+
...getDefaultRegisteredComponents(),
|
|
63
|
+
// While this `components` object is deprecated, we must maintain support for it.
|
|
64
|
+
// Since users are able to override our default components, we need to make sure that we do not break such
|
|
65
|
+
// existing usage.
|
|
66
|
+
// This is why we spread `components` after the default Builder.io components, but before the `props.customComponents`,
|
|
67
|
+
// which is the new standard way of providing custom components, and must therefore take precedence.
|
|
68
|
+
...components,
|
|
69
|
+
...(props.customComponents || []),
|
|
70
|
+
].reduce((acc, curr) => ({
|
|
71
|
+
...acc,
|
|
72
|
+
[curr.name]: curr,
|
|
73
|
+
}), {}));
|
|
74
|
+
function processMessage(event) {
|
|
75
|
+
const { data } = event;
|
|
76
|
+
if (data) {
|
|
77
|
+
switch (data.type) {
|
|
78
|
+
case "builder.configureSdk": {
|
|
79
|
+
const messageContent = data.data;
|
|
80
|
+
const { breakpoints, contentId } = messageContent;
|
|
81
|
+
if (!contentId || contentId !== useContent?.()?.id) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
setUseBreakpoints(breakpoints);
|
|
85
|
+
setForceReRenderCount(forceReRenderCount + 1); // This is a hack to force Qwik to re-render.
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
88
|
+
case "builder.contentUpdate": {
|
|
89
|
+
const messageContent = data.data;
|
|
90
|
+
const key = messageContent.key ||
|
|
91
|
+
messageContent.alias ||
|
|
92
|
+
messageContent.entry ||
|
|
93
|
+
messageContent.modelName;
|
|
94
|
+
const contentData = messageContent.data;
|
|
95
|
+
if (key === props.model) {
|
|
96
|
+
setOverrideContent(contentData);
|
|
97
|
+
setForceReRenderCount(forceReRenderCount + 1); // This is a hack to force Qwik to re-render.
|
|
98
|
+
}
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
case "builder.patchUpdates": {
|
|
102
|
+
// TODO
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
function evaluateJsCode() {
|
|
109
|
+
// run any dynamic JS code attached to content
|
|
110
|
+
const jsCode = useContent?.()?.data?.jsCode;
|
|
111
|
+
if (jsCode) {
|
|
112
|
+
evaluate({
|
|
113
|
+
code: jsCode,
|
|
114
|
+
context: contextContext,
|
|
115
|
+
state: contentState(),
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
const [httpReqsData, setHttpReqsData] = useState(() => ({}));
|
|
120
|
+
const [clicked, setClicked] = useState(() => false);
|
|
121
|
+
function onClick(event) {
|
|
122
|
+
if (useContent()) {
|
|
123
|
+
const variationId = useContent?.()?.testVariationId;
|
|
124
|
+
const contentId = useContent?.()?.id;
|
|
125
|
+
_track({
|
|
126
|
+
type: "click",
|
|
127
|
+
canTrack: canTrackToUse,
|
|
128
|
+
contentId,
|
|
129
|
+
apiKey: props.apiKey,
|
|
130
|
+
variationId: variationId !== contentId ? variationId : undefined,
|
|
131
|
+
...getInteractionPropertiesForEvent(event),
|
|
132
|
+
unique: !clicked,
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
if (!clicked) {
|
|
136
|
+
setClicked(true);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
function evalExpression(expression) {
|
|
140
|
+
return expression.replace(/{{([^}]+)}}/g, (_match, group) => evaluate({
|
|
141
|
+
code: group,
|
|
142
|
+
context: contextContext,
|
|
143
|
+
state: contentState(),
|
|
144
|
+
}));
|
|
145
|
+
}
|
|
146
|
+
function handleRequest({ url, key }) {
|
|
147
|
+
fetch(url)
|
|
148
|
+
.then((response) => response.json())
|
|
149
|
+
.then((json) => {
|
|
150
|
+
const newOverrideState = {
|
|
151
|
+
...overrideState,
|
|
152
|
+
[key]: json,
|
|
153
|
+
};
|
|
154
|
+
setOverrideState(newOverrideState);
|
|
155
|
+
})
|
|
156
|
+
.catch((err) => {
|
|
157
|
+
console.log("error fetching dynamic data", url, err);
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
function runHttpRequests() {
|
|
161
|
+
const requests = useContent?.()?.data?.httpRequests ?? {};
|
|
162
|
+
Object.entries(requests).forEach(([key, url]) => {
|
|
163
|
+
if (url && (!httpReqsData[key] || isEditing())) {
|
|
164
|
+
const evaluatedUrl = evalExpression(url);
|
|
165
|
+
handleRequest({
|
|
166
|
+
url: evaluatedUrl,
|
|
167
|
+
key,
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
function emitStateUpdate() {
|
|
173
|
+
if (isEditing()) {
|
|
174
|
+
window.dispatchEvent(new CustomEvent("builder:component:stateChange", {
|
|
175
|
+
detail: {
|
|
176
|
+
state: contentState(),
|
|
177
|
+
ref: {
|
|
178
|
+
name: props.model,
|
|
179
|
+
},
|
|
180
|
+
},
|
|
181
|
+
}));
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
function shouldRenderContentStyles() {
|
|
185
|
+
return Boolean((useContent?.()?.data?.cssCode ||
|
|
186
|
+
useContent?.()?.data?.customFonts?.length) &&
|
|
187
|
+
TARGET !== "reactNative");
|
|
188
|
+
}
|
|
189
|
+
useEffect(() => {
|
|
190
|
+
if (!props.apiKey) {
|
|
191
|
+
console.error("[Builder.io]: No API key provided to `RenderContent` component. This can cause issues. Please provide an API key using the `apiKey` prop.");
|
|
192
|
+
}
|
|
193
|
+
if (isBrowser()) {
|
|
194
|
+
if (isEditing()) {
|
|
195
|
+
setForceReRenderCount(forceReRenderCount + 1);
|
|
196
|
+
registerInsertMenu();
|
|
197
|
+
setupBrowserForEditing({
|
|
198
|
+
...(props.locale
|
|
199
|
+
? {
|
|
200
|
+
locale: props.locale,
|
|
201
|
+
}
|
|
202
|
+
: {}),
|
|
203
|
+
...(props.includeRefs
|
|
204
|
+
? {
|
|
205
|
+
includeRefs: props.includeRefs,
|
|
206
|
+
}
|
|
207
|
+
: {}),
|
|
208
|
+
});
|
|
209
|
+
Object.values(allRegisteredComponents).forEach((registeredComponent) => {
|
|
210
|
+
const message = createRegisterComponentMessage(registeredComponent);
|
|
211
|
+
window.parent?.postMessage(message, "*");
|
|
212
|
+
});
|
|
213
|
+
window.addEventListener("message", processMessage);
|
|
214
|
+
window.addEventListener("builder:component:stateChangeListenerActivated", emitStateUpdate);
|
|
215
|
+
}
|
|
216
|
+
if (useContent()) {
|
|
217
|
+
const variationId = useContent?.()?.testVariationId;
|
|
218
|
+
const contentId = useContent?.()?.id;
|
|
219
|
+
_track({
|
|
220
|
+
type: "impression",
|
|
221
|
+
canTrack: canTrackToUse,
|
|
222
|
+
contentId,
|
|
223
|
+
apiKey: props.apiKey,
|
|
224
|
+
variationId: variationId !== contentId ? variationId : undefined,
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
// override normal content in preview mode
|
|
228
|
+
if (isPreviewing()) {
|
|
229
|
+
const searchParams = new URL(location.href).searchParams;
|
|
230
|
+
const searchParamPreview = searchParams.get("builder.preview");
|
|
231
|
+
const previewApiKey = searchParams.get("apiKey") || searchParams.get("builder.space");
|
|
232
|
+
/**
|
|
233
|
+
* Make sure that:
|
|
234
|
+
* - the preview model name is the same as the one we're rendering, since there can be multiple models rendered * at the same time, e.g. header/page/footer. * - the API key is the same, since we don't want to preview content from other organizations.
|
|
235
|
+
*
|
|
236
|
+
* TO-DO: should we check that the preview item ID is the same as the initial one being rendered? Or would
|
|
237
|
+
* this break scenarios where the item is not published yet?
|
|
238
|
+
*
|
|
239
|
+
* TO-DO: should we only update the state when there is a change?
|
|
240
|
+
**/
|
|
241
|
+
if (searchParamPreview === props.model &&
|
|
242
|
+
previewApiKey === props.apiKey) {
|
|
243
|
+
getContent({
|
|
244
|
+
model: props.model,
|
|
245
|
+
apiKey: props.apiKey,
|
|
246
|
+
}).then((content) => {
|
|
247
|
+
if (content) {
|
|
248
|
+
setOverrideContent(content);
|
|
249
|
+
}
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
evaluateJsCode();
|
|
254
|
+
runHttpRequests();
|
|
255
|
+
emitStateUpdate();
|
|
256
|
+
}
|
|
257
|
+
}, []);
|
|
258
|
+
useEffect(() => {
|
|
259
|
+
evaluateJsCode();
|
|
260
|
+
}, [useContent?.()?.data?.jsCode, contentState()]);
|
|
261
|
+
useEffect(() => {
|
|
262
|
+
runHttpRequests();
|
|
263
|
+
}, [useContent?.()?.data?.httpRequests]);
|
|
264
|
+
useEffect(() => {
|
|
265
|
+
emitStateUpdate();
|
|
266
|
+
}, [contentState()]);
|
|
267
|
+
useEffect(() => {
|
|
268
|
+
return () => {
|
|
269
|
+
if (isBrowser()) {
|
|
270
|
+
window.removeEventListener("message", processMessage);
|
|
271
|
+
window.removeEventListener("builder:component:stateChangeListenerActivated", emitStateUpdate);
|
|
272
|
+
}
|
|
273
|
+
};
|
|
274
|
+
}, []);
|
|
275
|
+
return (React.createElement(builderContext.Provider, { value: {
|
|
276
|
+
content: useContent(),
|
|
277
|
+
state: contentState(),
|
|
278
|
+
context: contextContext,
|
|
279
|
+
apiKey: props.apiKey,
|
|
280
|
+
registeredComponents: allRegisteredComponents,
|
|
281
|
+
} }, useContent() ? (React.createElement(React.Fragment, null,
|
|
282
|
+
React.createElement("div", { ref: elementRef, onClick: (event) => onClick(event), "builder-content-id": useContent?.()?.id, "builder-model": props.model },
|
|
283
|
+
shouldRenderContentStyles() ? (React.createElement(RenderContentStyles, { cssCode: useContent?.()?.data?.cssCode, customFonts: useContent?.()?.data?.customFonts })) : null,
|
|
284
|
+
React.createElement(RenderBlocks, { blocks: useContent?.()?.data?.blocks, key: forceReRenderCount })))) : null));
|
|
285
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { TARGET } from "../constants/target.js";
|
|
3
|
+
export default function RenderInlinedStyles(props) {
|
|
4
|
+
function injectedStyleScript() {
|
|
5
|
+
return `<${tag()}>${props.styles}</${tag()}>`;
|
|
6
|
+
}
|
|
7
|
+
function tag() {
|
|
8
|
+
// NOTE: we have to obfusctate the name of the tag due to a limitation in the svelte-preprocessor plugin.
|
|
9
|
+
// https://github.com/sveltejs/vite-plugin-svelte/issues/315#issuecomment-1109000027
|
|
10
|
+
return "sty" + "le";
|
|
11
|
+
}
|
|
12
|
+
const TagRef = tag();
|
|
13
|
+
return (React.createElement(React.Fragment, null, TARGET === "svelte" ? (React.createElement(React.Fragment, null,
|
|
14
|
+
React.createElement("div", { dangerouslySetInnerHTML: { __html: injectedStyleScript() } }))) : (React.createElement(TagRef, null, props.styles))));
|
|
15
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
+
var __spreadValues = (a, b) => {
|
|
7
|
+
for (var prop in b || (b = {}))
|
|
8
|
+
if (__hasOwnProp.call(b, prop))
|
|
9
|
+
__defNormalProp(a, prop, b[prop]);
|
|
10
|
+
if (__getOwnPropSymbols)
|
|
11
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
12
|
+
if (__propIsEnum.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
}
|
|
15
|
+
return a;
|
|
16
|
+
};
|
|
17
|
+
import { default as Button } from "../blocks/button/button.js";
|
|
18
|
+
import { componentInfo as buttonComponentInfo } from "../blocks/button/component-info.js";
|
|
19
|
+
import { default as Columns } from "../blocks/columns/columns.js";
|
|
20
|
+
import { componentInfo as columnsComponentInfo } from "../blocks/columns/component-info.js";
|
|
21
|
+
import { componentInfo as fragmentComponentInfo } from "../blocks/fragment/component-info.js";
|
|
22
|
+
import { default as Fragment } from "../blocks/fragment/fragment.js";
|
|
23
|
+
import { componentInfo as imageComponentInfo } from "../blocks/image/component-info.js";
|
|
24
|
+
import { default as Image } from "../blocks/image/image.js";
|
|
25
|
+
import { componentInfo as sectionComponentInfo } from "../blocks/section/component-info.js";
|
|
26
|
+
import { default as Section } from "../blocks/section/section.js";
|
|
27
|
+
import { componentInfo as symbolComponentInfo } from "../blocks/symbol/component-info.js";
|
|
28
|
+
import { default as Symbol } from "../blocks/symbol/symbol.js";
|
|
29
|
+
import { componentInfo as textComponentInfo } from "../blocks/text/component-info.js";
|
|
30
|
+
import { default as Text } from "../blocks/text/text.js";
|
|
31
|
+
import { componentInfo as videoComponentInfo } from "../blocks/video/component-info.js";
|
|
32
|
+
import { default as Video } from "../blocks/video/video.js";
|
|
33
|
+
import { componentInfo as embedComponentInfo } from "../blocks/embed/component-info.js";
|
|
34
|
+
import { default as embed } from "../blocks/embed/embed.js";
|
|
35
|
+
import { default as Img } from "../blocks/img/img.js";
|
|
36
|
+
import { componentInfo as imgComponentInfo } from "../blocks/img/component-info.js";
|
|
37
|
+
import { default as customCode } from "../blocks/custom-code/custom-code.js";
|
|
38
|
+
import { componentInfo as customCodeInfo } from "../blocks/custom-code/component-info.js";
|
|
39
|
+
const getDefaultRegisteredComponents = () => [
|
|
40
|
+
__spreadValues({ component: Columns }, columnsComponentInfo),
|
|
41
|
+
__spreadValues({ component: Image }, imageComponentInfo),
|
|
42
|
+
__spreadValues({ component: Img }, imgComponentInfo),
|
|
43
|
+
__spreadValues({ component: Text }, textComponentInfo),
|
|
44
|
+
__spreadValues({ component: Video }, videoComponentInfo),
|
|
45
|
+
__spreadValues({ component: Symbol }, symbolComponentInfo),
|
|
46
|
+
__spreadValues({ component: Button }, buttonComponentInfo),
|
|
47
|
+
__spreadValues({ component: Section }, sectionComponentInfo),
|
|
48
|
+
__spreadValues({ component: Fragment }, fragmentComponentInfo),
|
|
49
|
+
__spreadValues({ component: embed }, embedComponentInfo),
|
|
50
|
+
__spreadValues({ component: customCode }, customCodeInfo)
|
|
51
|
+
];
|
|
52
|
+
export { getDefaultRegisteredComponents };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { fastClone } from "../functions/fast-clone";
|
|
2
|
+
const SIZES = {
|
|
3
|
+
small: {
|
|
4
|
+
min: 320,
|
|
5
|
+
default: 321,
|
|
6
|
+
max: 640
|
|
7
|
+
},
|
|
8
|
+
medium: {
|
|
9
|
+
min: 641,
|
|
10
|
+
default: 642,
|
|
11
|
+
max: 991
|
|
12
|
+
},
|
|
13
|
+
large: {
|
|
14
|
+
min: 990,
|
|
15
|
+
default: 991,
|
|
16
|
+
max: 1200
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
const getMaxWidthQueryForSize = (size, sizeValues = SIZES) => `@media (max-width: ${sizeValues[size].max}px)`;
|
|
20
|
+
const getSizesForBreakpoints = ({ small, medium }) => {
|
|
21
|
+
const newSizes = fastClone(SIZES);
|
|
22
|
+
if (!small || !medium) {
|
|
23
|
+
return newSizes;
|
|
24
|
+
}
|
|
25
|
+
const smallMin = Math.floor(small / 2);
|
|
26
|
+
newSizes.small = {
|
|
27
|
+
max: small,
|
|
28
|
+
min: smallMin,
|
|
29
|
+
default: smallMin + 1
|
|
30
|
+
};
|
|
31
|
+
const mediumMin = newSizes.small.max + 1;
|
|
32
|
+
newSizes.medium = {
|
|
33
|
+
max: medium,
|
|
34
|
+
min: mediumMin,
|
|
35
|
+
default: mediumMin + 1
|
|
36
|
+
};
|
|
37
|
+
const largeMin = newSizes.medium.max + 1;
|
|
38
|
+
newSizes.large = {
|
|
39
|
+
max: 2e3,
|
|
40
|
+
min: largeMin,
|
|
41
|
+
default: largeMin + 1
|
|
42
|
+
};
|
|
43
|
+
return newSizes;
|
|
44
|
+
};
|
|
45
|
+
export { getMaxWidthQueryForSize, getSizesForBreakpoints };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { isBrowser } from "./is-browser.js";
|
|
2
|
+
import { isEditing } from "./is-editing.js";
|
|
3
|
+
function evaluate({ code, context, state, event, isExpression = true }) {
|
|
4
|
+
if (code === "") {
|
|
5
|
+
console.warn("Skipping evaluation of empty code block.");
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
|
+
const builder = {
|
|
9
|
+
isEditing: isEditing(),
|
|
10
|
+
isBrowser: isBrowser(),
|
|
11
|
+
isServer: !isBrowser()
|
|
12
|
+
};
|
|
13
|
+
const useReturn = isExpression && !(code.includes(";") || code.includes(" return ") || code.trim().startsWith("return "));
|
|
14
|
+
const useCode = useReturn ? `return (${code});` : code;
|
|
15
|
+
try {
|
|
16
|
+
return new Function("builder", "Builder", "state", "context", "event", useCode)(builder, builder, state, context, event);
|
|
17
|
+
}
|
|
18
|
+
catch (e) {
|
|
19
|
+
console.warn("Builder custom code error: \n While Evaluating: \n ", useCode, "\n", e);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
export { evaluate };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const TEXT_STYLE_KEYS = [
|
|
2
|
+
"color",
|
|
3
|
+
"whiteSpace",
|
|
4
|
+
"direction",
|
|
5
|
+
"hyphens",
|
|
6
|
+
"overflowWrap"
|
|
7
|
+
];
|
|
8
|
+
const isTextStyle = (key) => {
|
|
9
|
+
return TEXT_STYLE_KEYS.includes(key) || key.startsWith("font") || key.startsWith("text") || key.startsWith("letter") || key.startsWith("line") || key.startsWith("word") || key.startsWith("writing");
|
|
10
|
+
};
|
|
11
|
+
const extractTextStyles = (styles) => {
|
|
12
|
+
const textStyles = {};
|
|
13
|
+
Object.entries(styles).forEach(([key, value]) => {
|
|
14
|
+
if (isTextStyle(key)) {
|
|
15
|
+
textStyles[key] = value;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
return textStyles;
|
|
19
|
+
};
|
|
20
|
+
export { extractTextStyles };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { getEventHandlerName } from "./event-handler-name.js";
|
|
2
|
+
import { createEventHandler } from "./get-block-actions-handler.js";
|
|
3
|
+
function getBlockActions(options) {
|
|
4
|
+
var _a;
|
|
5
|
+
const obj = {};
|
|
6
|
+
const optionActions = (_a = options.block.actions) != null ? _a : {};
|
|
7
|
+
for (const key in optionActions) {
|
|
8
|
+
if (!optionActions.hasOwnProperty(key)) {
|
|
9
|
+
continue;
|
|
10
|
+
}
|
|
11
|
+
const value = optionActions[key];
|
|
12
|
+
obj[getEventHandlerName(key)] = createEventHandler(value, options);
|
|
13
|
+
}
|
|
14
|
+
return obj;
|
|
15
|
+
}
|
|
16
|
+
export { getBlockActions };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
function getBlockComponentOptions(block) {
|
|
21
|
+
var _a;
|
|
22
|
+
return __spreadProps(__spreadValues(__spreadValues({}, (_a = block.component) == null ? void 0 : _a.options), block.options), {
|
|
23
|
+
builderBlock: block
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
export { getBlockComponentOptions };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
import { TARGET } from "../constants/target.js";
|
|
21
|
+
import { convertStyleMapToCSSArray } from "../helpers/css.js";
|
|
22
|
+
import { transformBlockProperties } from "./transform-block-properties.js";
|
|
23
|
+
function getBlockProperties(block) {
|
|
24
|
+
var _a;
|
|
25
|
+
const properties = __spreadProps(__spreadValues({}, block.properties), {
|
|
26
|
+
"builder-id": block.id,
|
|
27
|
+
style: getStyleAttribute(block.style),
|
|
28
|
+
class: [block.id, "builder-block", block.class, (_a = block.properties) == null ? void 0 : _a.class].filter(Boolean).join(" ")
|
|
29
|
+
});
|
|
30
|
+
return transformBlockProperties(properties);
|
|
31
|
+
}
|
|
32
|
+
function getStyleAttribute(style) {
|
|
33
|
+
if (!style) {
|
|
34
|
+
return void 0;
|
|
35
|
+
}
|
|
36
|
+
switch (TARGET) {
|
|
37
|
+
case "svelte":
|
|
38
|
+
case "vue2":
|
|
39
|
+
case "vue3":
|
|
40
|
+
case "solid":
|
|
41
|
+
return convertStyleMapToCSSArray(style).join(" ");
|
|
42
|
+
case "qwik":
|
|
43
|
+
case "reactNative":
|
|
44
|
+
case "react":
|
|
45
|
+
return style;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
export { getBlockProperties };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { convertSearchParamsToQueryObject, getBuilderSearchParams } from ".";
|
|
2
|
+
const querystring = "someotherValue=jklsjfdal&abc=klfdjklgfds&builder.cachebust=true&builder.preview=page&builder.noCache=true&__builder_editing__=true&builder.overrides.page=037948e52eaf4743afed464f02c70da4&builder.overrides.037948e52eaf4743afed464f02c70da4=037948e52eaf4743afed464f02c70da4&builder.overrides.page%3A%2F=037948e52eaf4743afed464f02c70da4&preview_theme_id=128854393017";
|
|
3
|
+
const url = new URL(`localhost:3000/about-us?${querystring}`);
|
|
4
|
+
describe("Get Builder SearchParams", () => {
|
|
5
|
+
test("correctly converts URLSearchParams to object", () => {
|
|
6
|
+
const output = convertSearchParamsToQueryObject(url.searchParams);
|
|
7
|
+
expect(output).toMatchSnapshot();
|
|
8
|
+
});
|
|
9
|
+
test("correctly extracts all builder params from a query object", () => {
|
|
10
|
+
const output = getBuilderSearchParams(convertSearchParamsToQueryObject(url.searchParams));
|
|
11
|
+
expect(output).toMatchSnapshot();
|
|
12
|
+
});
|
|
13
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { isBrowser } from "../is-browser.js";
|
|
2
|
+
const BUILDER_SEARCHPARAMS_PREFIX = "builder.";
|
|
3
|
+
const BUILDER_OPTIONS_PREFIX = "options.";
|
|
4
|
+
const convertSearchParamsToQueryObject = (searchParams) => {
|
|
5
|
+
const options = {};
|
|
6
|
+
searchParams.forEach((value, key) => {
|
|
7
|
+
options[key] = value;
|
|
8
|
+
});
|
|
9
|
+
return options;
|
|
10
|
+
};
|
|
11
|
+
const getBuilderSearchParams = (_options) => {
|
|
12
|
+
if (!_options) {
|
|
13
|
+
return {};
|
|
14
|
+
}
|
|
15
|
+
const options = normalizeSearchParams(_options);
|
|
16
|
+
const newOptions = {};
|
|
17
|
+
Object.keys(options).forEach((key) => {
|
|
18
|
+
if (key.startsWith(BUILDER_SEARCHPARAMS_PREFIX)) {
|
|
19
|
+
const trimmedKey = key.replace(BUILDER_SEARCHPARAMS_PREFIX, "").replace(BUILDER_OPTIONS_PREFIX, "");
|
|
20
|
+
newOptions[trimmedKey] = options[key];
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
return newOptions;
|
|
24
|
+
};
|
|
25
|
+
const getBuilderSearchParamsFromWindow = () => {
|
|
26
|
+
if (!isBrowser()) {
|
|
27
|
+
return {};
|
|
28
|
+
}
|
|
29
|
+
const searchParams = new URLSearchParams(window.location.search);
|
|
30
|
+
return getBuilderSearchParams(searchParams);
|
|
31
|
+
};
|
|
32
|
+
const normalizeSearchParams = (searchParams) => searchParams instanceof URLSearchParams ? convertSearchParamsToQueryObject(searchParams) : searchParams;
|
|
33
|
+
export { convertSearchParamsToQueryObject, getBuilderSearchParams, getBuilderSearchParamsFromWindow, normalizeSearchParams };
|