@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,72 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import {
|
|
3
|
+
getMaxWidthQueryForSize,
|
|
4
|
+
getSizesForBreakpoints,
|
|
5
|
+
} from "../../constants/device-sizes.js";
|
|
6
|
+
import { TARGET } from "../../constants/target.js";
|
|
7
|
+
import { getProcessedBlock } from "../../functions/get-processed-block.js";
|
|
8
|
+
import { createCssClass } from "../../helpers/css.js";
|
|
9
|
+
import RenderInlinedStyles from "../render-inlined-styles.js";
|
|
10
|
+
|
|
11
|
+
export default function BlockStyles(props) {
|
|
12
|
+
const _context = { ...props["_context"] };
|
|
13
|
+
|
|
14
|
+
const state = {
|
|
15
|
+
get useBlock() {
|
|
16
|
+
return getProcessedBlock({
|
|
17
|
+
block: props.block,
|
|
18
|
+
state: props.context.state,
|
|
19
|
+
context: props.context.context,
|
|
20
|
+
shouldEvaluateBindings: true,
|
|
21
|
+
});
|
|
22
|
+
},
|
|
23
|
+
get css() {
|
|
24
|
+
const styles = state.useBlock.responsiveStyles;
|
|
25
|
+
const content = props.context.content;
|
|
26
|
+
const sizesWithUpdatedBreakpoints = getSizesForBreakpoints(
|
|
27
|
+
content?.meta?.breakpoints || {}
|
|
28
|
+
);
|
|
29
|
+
const largeStyles = styles?.large;
|
|
30
|
+
const mediumStyles = styles?.medium;
|
|
31
|
+
const smallStyles = styles?.small;
|
|
32
|
+
const className = state.useBlock.id;
|
|
33
|
+
const largeStylesClass = largeStyles
|
|
34
|
+
? createCssClass({
|
|
35
|
+
className,
|
|
36
|
+
styles: largeStyles,
|
|
37
|
+
})
|
|
38
|
+
: "";
|
|
39
|
+
const mediumStylesClass = mediumStyles
|
|
40
|
+
? createCssClass({
|
|
41
|
+
className,
|
|
42
|
+
styles: mediumStyles,
|
|
43
|
+
mediaQuery: getMaxWidthQueryForSize(
|
|
44
|
+
"medium",
|
|
45
|
+
sizesWithUpdatedBreakpoints
|
|
46
|
+
),
|
|
47
|
+
})
|
|
48
|
+
: "";
|
|
49
|
+
const smallStylesClass = smallStyles
|
|
50
|
+
? createCssClass({
|
|
51
|
+
className,
|
|
52
|
+
styles: smallStyles,
|
|
53
|
+
mediaQuery: getMaxWidthQueryForSize(
|
|
54
|
+
"small",
|
|
55
|
+
sizesWithUpdatedBreakpoints
|
|
56
|
+
),
|
|
57
|
+
})
|
|
58
|
+
: "";
|
|
59
|
+
return [largeStylesClass, mediumStylesClass, smallStylesClass].join(" ");
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
return (
|
|
64
|
+
<>
|
|
65
|
+
{TARGET !== "reactNative" && state.css ? (
|
|
66
|
+
<>
|
|
67
|
+
<RenderInlinedStyles styles={state.css} _context={_context} />
|
|
68
|
+
</>
|
|
69
|
+
) : null}
|
|
70
|
+
</>
|
|
71
|
+
);
|
|
72
|
+
}
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { getBlockActions } from "../../functions/get-block-actions.js";
|
|
3
|
+
import { getBlockComponentOptions } from "../../functions/get-block-component-options.js";
|
|
4
|
+
import { getBlockProperties } from "../../functions/get-block-properties.js";
|
|
5
|
+
import { getBlockTag } from "../../functions/get-block-tag.js";
|
|
6
|
+
import { getProcessedBlock } from "../../functions/get-processed-block.js";
|
|
7
|
+
import { evaluate } from "../../functions/evaluate.js";
|
|
8
|
+
import BlockStyles from "./block-styles.js";
|
|
9
|
+
import { isEmptyHtmlElement } from "./render-block.helpers.js";
|
|
10
|
+
import RenderRepeatedBlock from "./render-repeated-block.js";
|
|
11
|
+
import { TARGET } from "../../constants/target.js";
|
|
12
|
+
import { extractTextStyles } from "../../functions/extract-text-styles.js";
|
|
13
|
+
import RenderComponentWithContext from "./render-component-with-context.js";
|
|
14
|
+
import RenderComponent from "./render-component.js";
|
|
15
|
+
import { getReactNativeBlockStyles } from "../../functions/get-react-native-block-styles.js";
|
|
16
|
+
|
|
17
|
+
export default function RenderBlock(props) {
|
|
18
|
+
const _context = { ...props["_context"] };
|
|
19
|
+
|
|
20
|
+
const state = {
|
|
21
|
+
get component() {
|
|
22
|
+
const componentName = getProcessedBlock({
|
|
23
|
+
block: props.block,
|
|
24
|
+
state: props.context.state,
|
|
25
|
+
context: props.context.context,
|
|
26
|
+
shouldEvaluateBindings: false,
|
|
27
|
+
}).component?.name;
|
|
28
|
+
if (!componentName) {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
const ref = props.context.registeredComponents[componentName];
|
|
32
|
+
if (!ref) {
|
|
33
|
+
// TODO: Public doc page with more info about this message
|
|
34
|
+
console.warn(`
|
|
35
|
+
Could not find a registered component named "${componentName}".
|
|
36
|
+
If you registered it, is the file that registered it imported by the file that needs to render it?`);
|
|
37
|
+
return undefined;
|
|
38
|
+
} else {
|
|
39
|
+
return ref;
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
get tag() {
|
|
43
|
+
return getBlockTag(state.useBlock);
|
|
44
|
+
},
|
|
45
|
+
get useBlock() {
|
|
46
|
+
return state.repeatItemData
|
|
47
|
+
? props.block
|
|
48
|
+
: getProcessedBlock({
|
|
49
|
+
block: props.block,
|
|
50
|
+
state: props.context.state,
|
|
51
|
+
context: props.context.context,
|
|
52
|
+
shouldEvaluateBindings: true,
|
|
53
|
+
});
|
|
54
|
+
},
|
|
55
|
+
get actions() {
|
|
56
|
+
return getBlockActions({
|
|
57
|
+
block: state.useBlock,
|
|
58
|
+
state: props.context.state,
|
|
59
|
+
context: props.context.context,
|
|
60
|
+
});
|
|
61
|
+
},
|
|
62
|
+
get attributes() {
|
|
63
|
+
const blockProperties = getBlockProperties(state.useBlock);
|
|
64
|
+
return {
|
|
65
|
+
...blockProperties,
|
|
66
|
+
...(TARGET === "reactNative"
|
|
67
|
+
? {
|
|
68
|
+
style: getReactNativeBlockStyles({
|
|
69
|
+
block: state.useBlock,
|
|
70
|
+
context: props.context,
|
|
71
|
+
blockStyles: blockProperties.style,
|
|
72
|
+
}),
|
|
73
|
+
}
|
|
74
|
+
: {}),
|
|
75
|
+
};
|
|
76
|
+
},
|
|
77
|
+
get shouldWrap() {
|
|
78
|
+
return !state.component?.noWrap;
|
|
79
|
+
},
|
|
80
|
+
get renderComponentProps() {
|
|
81
|
+
return {
|
|
82
|
+
blockChildren: state.useChildren,
|
|
83
|
+
componentRef: state.component?.component,
|
|
84
|
+
componentOptions: {
|
|
85
|
+
...getBlockComponentOptions(state.useBlock),
|
|
86
|
+
/**
|
|
87
|
+
* These attributes are passed to the wrapper element when there is one. If `noWrap` is set to true, then
|
|
88
|
+
* they are provided to the component itself directly.
|
|
89
|
+
*/
|
|
90
|
+
...(state.shouldWrap
|
|
91
|
+
? {}
|
|
92
|
+
: {
|
|
93
|
+
attributes: {
|
|
94
|
+
...state.attributes,
|
|
95
|
+
...state.actions,
|
|
96
|
+
},
|
|
97
|
+
}),
|
|
98
|
+
customBreakpoints: state.childrenContext?.content?.meta?.breakpoints,
|
|
99
|
+
},
|
|
100
|
+
context: state.childrenContext,
|
|
101
|
+
};
|
|
102
|
+
},
|
|
103
|
+
get useChildren() {
|
|
104
|
+
// TO-DO: When should `canHaveChildren` dictate rendering?
|
|
105
|
+
// This is currently commented out because some Builder components (e.g. Box) do not have `canHaveChildren: true`,
|
|
106
|
+
// but still receive and need to render children.
|
|
107
|
+
// return state.componentInfo?.canHaveChildren ? state.useBlock.children : [];
|
|
108
|
+
return state.useBlock.children ?? [];
|
|
109
|
+
},
|
|
110
|
+
get childrenWithoutParentComponent() {
|
|
111
|
+
/**
|
|
112
|
+
* When there is no `componentRef`, there might still be children that need to be rendered. In this case,
|
|
113
|
+
* we render them outside of `componentRef`.
|
|
114
|
+
* NOTE: We make sure not to render this if `repeatItemData` is non-null, because that means we are rendering an array of
|
|
115
|
+
* blocks, and the children will be repeated within those blocks.
|
|
116
|
+
*/
|
|
117
|
+
const shouldRenderChildrenOutsideRef =
|
|
118
|
+
!state.component?.component && !state.repeatItemData;
|
|
119
|
+
return shouldRenderChildrenOutsideRef ? state.useChildren : [];
|
|
120
|
+
},
|
|
121
|
+
get repeatItemData() {
|
|
122
|
+
/**
|
|
123
|
+
* we don't use `state.useBlock` here because the processing done within its logic includes evaluating the block's bindings,
|
|
124
|
+
* which will not work if there is a repeat.
|
|
125
|
+
*/
|
|
126
|
+
const { repeat, ...blockWithoutRepeat } = props.block;
|
|
127
|
+
if (!repeat?.collection) {
|
|
128
|
+
return undefined;
|
|
129
|
+
}
|
|
130
|
+
const itemsArray = evaluate({
|
|
131
|
+
code: repeat.collection,
|
|
132
|
+
state: props.context.state,
|
|
133
|
+
context: props.context.context,
|
|
134
|
+
});
|
|
135
|
+
if (!Array.isArray(itemsArray)) {
|
|
136
|
+
return undefined;
|
|
137
|
+
}
|
|
138
|
+
const collectionName = repeat.collection.split(".").pop();
|
|
139
|
+
const itemNameToUse =
|
|
140
|
+
repeat.itemName || (collectionName ? collectionName + "Item" : "item");
|
|
141
|
+
const repeatArray = itemsArray.map((item, index) => ({
|
|
142
|
+
context: {
|
|
143
|
+
...props.context,
|
|
144
|
+
state: {
|
|
145
|
+
...props.context.state,
|
|
146
|
+
$index: index,
|
|
147
|
+
$item: item,
|
|
148
|
+
[itemNameToUse]: item,
|
|
149
|
+
[`$${itemNameToUse}Index`]: index,
|
|
150
|
+
},
|
|
151
|
+
},
|
|
152
|
+
block: blockWithoutRepeat,
|
|
153
|
+
}));
|
|
154
|
+
return repeatArray;
|
|
155
|
+
},
|
|
156
|
+
get inheritedTextStyles() {
|
|
157
|
+
if (TARGET !== "reactNative") {
|
|
158
|
+
return {};
|
|
159
|
+
}
|
|
160
|
+
const styles = getReactNativeBlockStyles({
|
|
161
|
+
block: state.useBlock,
|
|
162
|
+
context: props.context,
|
|
163
|
+
blockStyles: state.attributes.style,
|
|
164
|
+
});
|
|
165
|
+
return extractTextStyles(styles);
|
|
166
|
+
},
|
|
167
|
+
get childrenContext() {
|
|
168
|
+
return {
|
|
169
|
+
apiKey: props.context.apiKey,
|
|
170
|
+
state: props.context.state,
|
|
171
|
+
content: props.context.content,
|
|
172
|
+
context: props.context.context,
|
|
173
|
+
registeredComponents: props.context.registeredComponents,
|
|
174
|
+
inheritedStyles: state.inheritedTextStyles,
|
|
175
|
+
};
|
|
176
|
+
},
|
|
177
|
+
get renderComponentTag() {
|
|
178
|
+
if (TARGET === "reactNative") {
|
|
179
|
+
return RenderComponentWithContext;
|
|
180
|
+
} else if (TARGET === "vue3") {
|
|
181
|
+
// vue3 expects a string for the component tag
|
|
182
|
+
return "RenderComponent";
|
|
183
|
+
} else {
|
|
184
|
+
return RenderComponent;
|
|
185
|
+
}
|
|
186
|
+
},
|
|
187
|
+
componentInfo: null,
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
const RenderComponentTagRef = state.renderComponentTag;
|
|
191
|
+
const TagRef = state.tag;
|
|
192
|
+
|
|
193
|
+
return (
|
|
194
|
+
<>
|
|
195
|
+
{state.shouldWrap ? (
|
|
196
|
+
<>
|
|
197
|
+
{isEmptyHtmlElement(state.tag) ? (
|
|
198
|
+
<>
|
|
199
|
+
<TagRef {...state.attributes} {...state.actions} />
|
|
200
|
+
</>
|
|
201
|
+
) : null}
|
|
202
|
+
{!isEmptyHtmlElement(state.tag) && state.repeatItemData ? (
|
|
203
|
+
<>
|
|
204
|
+
{state.repeatItemData?.map((data, index) => (
|
|
205
|
+
<RenderRepeatedBlock
|
|
206
|
+
key={index}
|
|
207
|
+
repeatContext={data.context}
|
|
208
|
+
block={data.block}
|
|
209
|
+
_context={_context}
|
|
210
|
+
/>
|
|
211
|
+
))}
|
|
212
|
+
</>
|
|
213
|
+
) : null}
|
|
214
|
+
{!isEmptyHtmlElement(state.tag) && !state.repeatItemData ? (
|
|
215
|
+
<>
|
|
216
|
+
<TagRef {...state.attributes} {...state.actions}>
|
|
217
|
+
<RenderComponentTagRef
|
|
218
|
+
{...state.renderComponentProps}
|
|
219
|
+
_context={_context}
|
|
220
|
+
/>
|
|
221
|
+
|
|
222
|
+
{state.childrenWithoutParentComponent?.map((child) => (
|
|
223
|
+
<RenderBlock
|
|
224
|
+
key={"render-block-" + child.id}
|
|
225
|
+
block={child}
|
|
226
|
+
context={state.childrenContext}
|
|
227
|
+
_context={_context}
|
|
228
|
+
/>
|
|
229
|
+
))}
|
|
230
|
+
|
|
231
|
+
{state.childrenWithoutParentComponent?.map((child) => (
|
|
232
|
+
<BlockStyles
|
|
233
|
+
key={"block-style-" + child.id}
|
|
234
|
+
block={child}
|
|
235
|
+
context={state.childrenContext}
|
|
236
|
+
_context={_context}
|
|
237
|
+
/>
|
|
238
|
+
))}
|
|
239
|
+
</TagRef>
|
|
240
|
+
</>
|
|
241
|
+
) : null}
|
|
242
|
+
</>
|
|
243
|
+
) : (
|
|
244
|
+
<RenderComponentTagRef
|
|
245
|
+
{...state.renderComponentProps}
|
|
246
|
+
_context={_context}
|
|
247
|
+
/>
|
|
248
|
+
)}
|
|
249
|
+
</>
|
|
250
|
+
);
|
|
251
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import BuilderContext from "../../context/builder.context.js";
|
|
3
|
+
import RenderComponent from "./render-component.js";
|
|
4
|
+
|
|
5
|
+
export default function RenderComponentWithContext(props) {
|
|
6
|
+
const _context = { ...props["_context"] };
|
|
7
|
+
|
|
8
|
+
_context.BuilderContext = {
|
|
9
|
+
get content() {
|
|
10
|
+
return props.context.content;
|
|
11
|
+
},
|
|
12
|
+
get state() {
|
|
13
|
+
return props.context.state;
|
|
14
|
+
},
|
|
15
|
+
get context() {
|
|
16
|
+
return props.context.context;
|
|
17
|
+
},
|
|
18
|
+
get apiKey() {
|
|
19
|
+
return props.context.apiKey;
|
|
20
|
+
},
|
|
21
|
+
get registeredComponents() {
|
|
22
|
+
return props.context.registeredComponents;
|
|
23
|
+
},
|
|
24
|
+
get inheritedStyles() {
|
|
25
|
+
return props.context.inheritedStyles;
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<RenderComponent
|
|
31
|
+
componentRef={props.componentRef}
|
|
32
|
+
componentOptions={props.componentOptions}
|
|
33
|
+
blockChildren={props.blockChildren}
|
|
34
|
+
context={props.context}
|
|
35
|
+
_context={_context}
|
|
36
|
+
/>
|
|
37
|
+
);
|
|
38
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import BlockStyles from "./block-styles.js";
|
|
3
|
+
import RenderBlock from "./render-block.js";
|
|
4
|
+
|
|
5
|
+
export default function RenderComponent(props) {
|
|
6
|
+
const _context = { ...props["_context"] };
|
|
7
|
+
|
|
8
|
+
const ComponentRefRef = props.componentRef;
|
|
9
|
+
|
|
10
|
+
return (
|
|
11
|
+
<>
|
|
12
|
+
{props.componentRef ? (
|
|
13
|
+
<>
|
|
14
|
+
<ComponentRefRef {...props.componentOptions} _context={_context}>
|
|
15
|
+
{props.blockChildren?.map((child) => (
|
|
16
|
+
<RenderBlock
|
|
17
|
+
key={"render-block-" + child.id}
|
|
18
|
+
block={child}
|
|
19
|
+
context={props.context}
|
|
20
|
+
_context={_context}
|
|
21
|
+
/>
|
|
22
|
+
))}
|
|
23
|
+
|
|
24
|
+
{props.blockChildren?.map((child) => (
|
|
25
|
+
<BlockStyles
|
|
26
|
+
key={"block-style-" + child.id}
|
|
27
|
+
block={child}
|
|
28
|
+
context={props.context}
|
|
29
|
+
_context={_context}
|
|
30
|
+
/>
|
|
31
|
+
))}
|
|
32
|
+
</ComponentRefRef>
|
|
33
|
+
</>
|
|
34
|
+
) : null}
|
|
35
|
+
</>
|
|
36
|
+
);
|
|
37
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import BuilderContext from "../../context/builder.context.js";
|
|
3
|
+
import RenderBlock from "./render-block.js";
|
|
4
|
+
|
|
5
|
+
export default function RenderRepeatedBlock(props) {
|
|
6
|
+
const _context = { ...props["_context"] };
|
|
7
|
+
|
|
8
|
+
_context.BuilderContext = {
|
|
9
|
+
get content() {
|
|
10
|
+
return props.repeatContext.content;
|
|
11
|
+
},
|
|
12
|
+
get state() {
|
|
13
|
+
return props.repeatContext.state;
|
|
14
|
+
},
|
|
15
|
+
get context() {
|
|
16
|
+
return props.repeatContext.context;
|
|
17
|
+
},
|
|
18
|
+
get apiKey() {
|
|
19
|
+
return props.repeatContext.apiKey;
|
|
20
|
+
},
|
|
21
|
+
get registeredComponents() {
|
|
22
|
+
return props.repeatContext.registeredComponents;
|
|
23
|
+
},
|
|
24
|
+
get inheritedStyles() {
|
|
25
|
+
return props.repeatContext.inheritedStyles;
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<RenderBlock
|
|
31
|
+
block={props.block}
|
|
32
|
+
context={props.repeatContext}
|
|
33
|
+
_context={_context}
|
|
34
|
+
/>
|
|
35
|
+
);
|
|
36
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import BuilderContext from "../context/builder.context.js";
|
|
3
|
+
import { isEditing } from "../functions/is-editing.js";
|
|
4
|
+
import BlockStyles from "./render-block/block-styles.js";
|
|
5
|
+
import RenderBlock from "./render-block/render-block.js";
|
|
6
|
+
|
|
7
|
+
export default function RenderBlocks(props) {
|
|
8
|
+
const _context = { ...props["_context"] };
|
|
9
|
+
|
|
10
|
+
const state = {
|
|
11
|
+
get className() {
|
|
12
|
+
return "builder-blocks" + (!props.blocks?.length ? " no-blocks" : "");
|
|
13
|
+
},
|
|
14
|
+
onClick() {
|
|
15
|
+
if (isEditing() && !props.blocks?.length) {
|
|
16
|
+
window.parent?.postMessage(
|
|
17
|
+
{
|
|
18
|
+
type: "builder.clickEmptyBlocks",
|
|
19
|
+
data: {
|
|
20
|
+
parentElementId: props.parent,
|
|
21
|
+
dataPath: props.path,
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
"*"
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
onMouseEnter() {
|
|
29
|
+
if (isEditing() && !props.blocks?.length) {
|
|
30
|
+
window.parent?.postMessage(
|
|
31
|
+
{
|
|
32
|
+
type: "builder.hoverEmptyBlocks",
|
|
33
|
+
data: {
|
|
34
|
+
parentElementId: props.parent,
|
|
35
|
+
dataPath: props.path,
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
"*"
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const builderContext = _context["BuilderContext"];
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<>
|
|
48
|
+
<div
|
|
49
|
+
className={state.className + " div-4f307ff9"}
|
|
50
|
+
builder-path={props.path}
|
|
51
|
+
builder-parent-id={props.parent}
|
|
52
|
+
dataSet={{
|
|
53
|
+
class: state.className,
|
|
54
|
+
}}
|
|
55
|
+
style={props.styleProp}
|
|
56
|
+
>
|
|
57
|
+
{props.blocks ? (
|
|
58
|
+
<>
|
|
59
|
+
{props.blocks?.map((block) => (
|
|
60
|
+
<RenderBlock
|
|
61
|
+
key={"render-block-" + block.id}
|
|
62
|
+
block={block}
|
|
63
|
+
context={builderContext}
|
|
64
|
+
_context={_context}
|
|
65
|
+
/>
|
|
66
|
+
))}
|
|
67
|
+
</>
|
|
68
|
+
) : null}
|
|
69
|
+
|
|
70
|
+
{props.blocks ? (
|
|
71
|
+
<>
|
|
72
|
+
{props.blocks?.map((block) => (
|
|
73
|
+
<BlockStyles
|
|
74
|
+
key={"block-style-" + block.id}
|
|
75
|
+
block={block}
|
|
76
|
+
context={builderContext}
|
|
77
|
+
_context={_context}
|
|
78
|
+
/>
|
|
79
|
+
))}
|
|
80
|
+
</>
|
|
81
|
+
) : null}
|
|
82
|
+
</div>
|
|
83
|
+
<style>{`.div-4f307ff9 {
|
|
84
|
+
display: flex;
|
|
85
|
+
flex-direction: column;
|
|
86
|
+
align-items: stretch;
|
|
87
|
+
}`}</style>
|
|
88
|
+
</>
|
|
89
|
+
);
|
|
90
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import RenderInlinedStyles from "../../render-inlined-styles.js";
|
|
3
|
+
|
|
4
|
+
export default function RenderContentStyles(props) {
|
|
5
|
+
const _context = { ...props["_context"] };
|
|
6
|
+
|
|
7
|
+
const state = {
|
|
8
|
+
getCssFromFont(font) {
|
|
9
|
+
// TODO: compute what font sizes are used and only load those.......
|
|
10
|
+
const family =
|
|
11
|
+
font.family +
|
|
12
|
+
(font.kind && !font.kind.includes("#") ? ", " + font.kind : "");
|
|
13
|
+
const name = family.split(",")[0];
|
|
14
|
+
const url = font.fileUrl ?? font?.files?.regular;
|
|
15
|
+
let str = "";
|
|
16
|
+
if (url && family && name) {
|
|
17
|
+
str += `
|
|
18
|
+
@font-face {
|
|
19
|
+
font-family: "${family}";
|
|
20
|
+
src: local("${name}"), url('${url}') format('woff2');
|
|
21
|
+
font-display: fallback;
|
|
22
|
+
font-weight: 400;
|
|
23
|
+
}
|
|
24
|
+
`.trim();
|
|
25
|
+
}
|
|
26
|
+
if (font.files) {
|
|
27
|
+
for (const weight in font.files) {
|
|
28
|
+
const isNumber = String(Number(weight)) === weight;
|
|
29
|
+
if (!isNumber) {
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
// TODO: maybe limit number loaded
|
|
33
|
+
const weightUrl = font.files[weight];
|
|
34
|
+
if (weightUrl && weightUrl !== url) {
|
|
35
|
+
str += `
|
|
36
|
+
@font-face {
|
|
37
|
+
font-family: "${family}";
|
|
38
|
+
src: url('${weightUrl}') format('woff2');
|
|
39
|
+
font-display: fallback;
|
|
40
|
+
font-weight: ${weight};
|
|
41
|
+
}
|
|
42
|
+
`.trim();
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return str;
|
|
47
|
+
},
|
|
48
|
+
getFontCss({ customFonts }) {
|
|
49
|
+
// TODO: flag for this
|
|
50
|
+
// if (!this.builder.allowCustomFonts) {
|
|
51
|
+
// return '';
|
|
52
|
+
// }
|
|
53
|
+
// TODO: separate internal data from external
|
|
54
|
+
return (
|
|
55
|
+
customFonts?.map((font) => this.getCssFromFont(font))?.join(" ") || ""
|
|
56
|
+
);
|
|
57
|
+
},
|
|
58
|
+
get injectedStyles() {
|
|
59
|
+
return `
|
|
60
|
+
${props.cssCode || ""}
|
|
61
|
+
${state.getFontCss({
|
|
62
|
+
customFonts: props.customFonts,
|
|
63
|
+
})}`;
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
return (
|
|
68
|
+
<RenderInlinedStyles styles={state.injectedStyles} _context={_context} />
|
|
69
|
+
);
|
|
70
|
+
}
|