@builder.io/sdk-svelte 0.4.5 → 0.5.1
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/package/--package.json +41 -29
- package/package/CHANGELOG.md +8 -0
- package/package/blocks/BaseText.svelte +1 -1
- package/package/blocks/button/button.svelte +18 -33
- package/package/blocks/button/button.svelte.d.ts +3 -1
- package/package/blocks/button/component-info.d.ts +1 -1
- package/package/blocks/button/component-info.js +9 -13
- package/package/blocks/columns/columns.svelte +12 -18
- package/package/blocks/columns/columns.svelte.d.ts +11 -7
- package/package/blocks/columns/component-info.d.ts +1 -1
- package/package/blocks/columns/component-info.js +62 -83
- package/package/blocks/custom-code/component-info.d.ts +1 -1
- package/package/blocks/custom-code/component-info.js +7 -11
- package/package/blocks/embed/component-info.d.ts +1 -1
- package/package/blocks/embed/component-info.js +8 -15
- package/package/blocks/embed/helpers.js +1 -5
- package/package/blocks/form/component-info.d.ts +1 -1
- package/package/blocks/form/component-info.js +94 -129
- package/package/blocks/form/form.svelte +2 -289
- package/package/blocks/form/form.svelte.d.ts +1 -57
- package/package/blocks/fragment/component-info.d.ts +1 -1
- package/package/blocks/fragment/component-info.js +1 -1
- package/package/blocks/helpers.d.ts +13 -0
- package/package/blocks/helpers.js +40 -0
- package/package/blocks/image/component-info.d.ts +1 -1
- package/package/blocks/image/component-info.js +33 -63
- package/package/blocks/image/image.helpers.js +2 -11
- package/package/blocks/image/image.svelte.d.ts +0 -1
- package/package/blocks/img/component-info.d.ts +1 -1
- package/package/blocks/img/component-info.js +4 -6
- package/package/blocks/img/img.svelte +4 -29
- package/package/blocks/img/img.svelte.d.ts +3 -1
- package/package/blocks/input/component-info.d.ts +1 -1
- package/package/blocks/input/component-info.js +15 -40
- package/package/blocks/input/input.svelte +4 -29
- package/package/blocks/input/input.svelte.d.ts +3 -1
- package/package/blocks/raw-text/component-info.d.ts +1 -1
- package/package/blocks/raw-text/component-info.js +3 -5
- package/package/blocks/raw-text/raw-text.svelte +3 -5
- package/package/blocks/raw-text/raw-text.svelte.d.ts +1 -1
- package/package/blocks/section/component-info.d.ts +1 -1
- package/package/blocks/section/component-info.js +13 -18
- package/package/blocks/section/section.svelte +4 -29
- package/package/blocks/section/section.svelte.d.ts +3 -1
- package/package/blocks/select/component-info.d.ts +1 -1
- package/package/blocks/select/component-info.js +22 -34
- package/package/blocks/select/select.svelte +4 -29
- package/package/blocks/select/select.svelte.d.ts +3 -1
- package/package/blocks/submit-button/component-info.d.ts +1 -1
- package/package/blocks/submit-button/component-info.js +5 -7
- package/package/blocks/submit-button/submit-button.svelte +4 -29
- package/package/blocks/submit-button/submit-button.svelte.d.ts +3 -1
- package/package/blocks/symbol/component-info.d.ts +1 -1
- package/package/blocks/symbol/component-info.js +12 -17
- package/package/blocks/symbol/symbol.helpers.d.ts +14 -0
- package/package/blocks/symbol/symbol.helpers.js +31 -0
- package/package/blocks/symbol/symbol.svelte +37 -87
- package/package/blocks/symbol/symbol.svelte.d.ts +13 -7
- package/package/blocks/text/component-info.d.ts +1 -1
- package/package/blocks/text/component-info.js +6 -7
- package/package/blocks/text/text.svelte +1 -1
- package/package/blocks/textarea/component-info.d.ts +1 -1
- package/package/blocks/textarea/component-info.js +13 -19
- package/package/blocks/textarea/textarea.svelte +4 -29
- package/package/blocks/textarea/textarea.svelte.d.ts +3 -1
- package/package/blocks/video/component-info.d.ts +1 -1
- package/package/blocks/video/component-info.js +35 -55
- package/package/blocks/video/video.svelte +4 -30
- package/package/blocks/video/video.svelte.d.ts +2 -0
- package/package/components/block/block.helpers.d.ts +13 -0
- package/package/components/{render-block/render-block.helpers.js → block/block.helpers.js} +12 -29
- package/package/components/block/block.svelte +135 -0
- package/package/components/block/block.svelte.d.ts +26 -0
- package/package/components/{render-block → block/components}/block-styles.svelte +20 -22
- package/package/components/{render-block → block/components}/block-styles.svelte.d.ts +2 -2
- package/package/components/block/components/block-wrapper.svelte +53 -0
- package/package/components/block/components/block-wrapper.svelte.d.ts +33 -0
- package/package/components/block/components/component-ref/component-ref.helpers.d.ts +36 -0
- package/package/components/block/components/component-ref/component-ref.helpers.js +22 -0
- package/package/components/block/components/component-ref/component-ref.svelte +37 -0
- package/package/components/block/components/component-ref/component-ref.svelte.d.ts +24 -0
- package/package/components/block/components/interactive-element.svelte +29 -0
- package/package/components/block/components/interactive-element.svelte.d.ts +31 -0
- package/package/components/{render-block/render-repeated-block.svelte → block/components/repeated-block.svelte} +4 -3
- package/package/components/block/components/repeated-block.svelte.d.ts +25 -0
- package/package/components/{render-blocks.svelte → blocks/blocks-wrapper.svelte} +3 -20
- package/package/components/blocks/blocks-wrapper.svelte.d.ts +29 -0
- package/package/components/blocks/blocks.svelte +36 -0
- package/package/components/blocks/blocks.svelte.d.ts +28 -0
- package/package/components/{render-content/render-content.svelte → content/components/enable-editor.svelte} +47 -166
- package/package/components/content/components/enable-editor.svelte.d.ts +36 -0
- package/package/components/{render-content/components/render-styles.helpers.d.ts → content/components/styles.helpers.d.ts} +1 -1
- package/package/components/{render-content/components/render-styles.helpers.js → content/components/styles.helpers.js} +3 -4
- package/package/components/{render-content/components/render-styles.svelte → content/components/styles.svelte} +2 -2
- package/package/components/{render-content/components/render-styles.svelte.d.ts → content/components/styles.svelte.d.ts} +5 -5
- package/package/components/content/content.helpers.d.ts +7 -0
- package/package/components/content/content.helpers.js +30 -0
- package/package/components/content/content.svelte +118 -0
- package/package/components/content/content.svelte.d.ts +30 -0
- package/package/components/{render-content/render-content.types.d.ts → content/content.types.d.ts} +4 -4
- package/package/components/content/index.d.ts +1 -0
- package/package/components/content/index.js +1 -0
- package/package/components/{render-content-variants/render-content-variants.svelte → content-variants/content-variants.svelte} +20 -19
- package/package/components/{render-content-variants/render-content-variants.svelte.d.ts → content-variants/content-variants.svelte.d.ts} +6 -6
- package/package/components/{render-content-variants/render-content-variants.types.d.ts → content-variants/content-variants.types.d.ts} +5 -5
- package/package/components/{render-content-variants → content-variants}/helpers.d.ts +7 -7
- package/package/components/{render-content-variants → content-variants}/helpers.js +13 -22
- package/package/constants/builder-registered-components.js +34 -13
- package/package/constants/device-sizes.js +9 -8
- package/package/constants/sdk-version.d.ts +1 -1
- package/package/constants/sdk-version.js +1 -1
- package/package/constants/target.d.ts +1 -1
- package/package/context/builder.context.d.ts +1 -1
- package/package/context/builder.context.js +1 -1
- package/package/context/components.context.d.ts +7 -0
- package/package/context/components.context.js +5 -0
- package/package/context/types.d.ts +1 -1
- package/package/functions/apply-patch-with-mutation.d.ts +10 -0
- package/package/functions/apply-patch-with-mutation.js +54 -0
- package/package/functions/evaluate/acorn.d.ts +0 -0
- package/package/functions/evaluate/acorn.js +2433 -0
- package/package/functions/{evaluate.d.ts → evaluate/evaluate.d.ts} +5 -2
- package/package/functions/{evaluate.js → evaluate/evaluate.js} +34 -13
- package/package/functions/evaluate/index.d.ts +1 -0
- package/package/functions/evaluate/index.js +1 -0
- package/package/functions/evaluate/interpreter.d.ts +2 -0
- package/package/functions/evaluate/interpreter.js +3853 -0
- package/package/functions/evaluate/non-node-runtime.d.ts +2 -0
- package/package/functions/evaluate/non-node-runtime.js +84 -0
- package/package/functions/evaluate/types.d.ts +10 -0
- package/package/functions/extract-text-styles.js +2 -14
- package/package/functions/get-block-actions-handler.js +3 -3
- package/package/functions/get-block-actions.d.ts +1 -0
- package/package/functions/get-block-actions.js +14 -1
- package/package/functions/get-block-component-options.js +1 -1
- package/package/functions/get-block-properties.d.ts +5 -1
- package/package/functions/get-block-properties.js +15 -9
- package/package/functions/get-builder-search-params/index.js +3 -7
- package/package/functions/get-content/generate-content-url.js +7 -5
- package/package/functions/get-content/index.d.ts +2 -6
- package/package/functions/get-content/index.js +26 -6
- package/package/functions/get-processed-block.d.ts +1 -1
- package/package/functions/get-processed-block.js +11 -7
- package/package/functions/get-react-native-block-styles.d.ts +1 -1
- package/package/functions/get-react-native-block-styles.js +2 -2
- package/package/functions/if-target.d.ts +1 -1
- package/package/functions/if-target.js +1 -1
- package/package/functions/is-editing.js +1 -3
- package/package/functions/is-non-node-server.d.ts +4 -0
- package/package/functions/is-non-node-server.js +8 -0
- package/package/functions/on-change.js +1 -1
- package/package/functions/register-component.d.ts +2 -1
- package/package/functions/register-component.js +20 -8
- package/package/functions/register.js +2 -2
- package/package/functions/sanitize-react-native-block-styles.js +13 -5
- package/package/functions/set-editor-settings.js +1 -1
- package/package/functions/set.js +2 -9
- package/package/functions/track/helpers.js +6 -11
- package/package/functions/track/index.js +26 -14
- package/package/functions/track/interaction.js +15 -16
- package/package/helpers/ab-tests.d.ts +2 -2
- package/package/helpers/ab-tests.js +42 -30
- package/package/helpers/canTrack.js +1 -1
- package/package/helpers/cookie.d.ts +2 -2
- package/package/helpers/cookie.js +13 -26
- package/package/helpers/css.d.ts +1 -1
- package/package/helpers/css.js +1 -1
- package/package/helpers/flatten.js +8 -8
- package/package/helpers/localStorage.d.ts +2 -2
- package/package/helpers/localStorage.js +2 -2
- package/package/helpers/logger.js +1 -1
- package/package/helpers/preview-lru-cache/get.d.ts +1 -0
- package/package/helpers/preview-lru-cache/get.js +7 -0
- package/package/helpers/preview-lru-cache/helpers.d.ts +1 -0
- package/package/helpers/preview-lru-cache/helpers.js +9 -0
- package/package/helpers/preview-lru-cache/init.d.ts +6 -0
- package/package/helpers/preview-lru-cache/init.js +15 -0
- package/package/helpers/preview-lru-cache/set.d.ts +7 -0
- package/package/helpers/preview-lru-cache/set.js +9 -0
- package/package/helpers/preview-lru-cache/types.d.ts +12 -0
- package/package/helpers/preview-lru-cache/types.js +6 -0
- package/package/helpers/sessionId.d.ts +2 -2
- package/package/helpers/sessionId.js +11 -4
- package/package/helpers/uuid.js +1 -1
- package/package/helpers/visitorId.d.ts +1 -1
- package/package/helpers/visitorId.js +7 -4
- package/package/index-helpers/blocks-exports.d.ts +2 -2
- package/package/index-helpers/blocks-exports.js +2 -2
- package/package/index.d.ts +2 -2
- package/package/index.js +1 -1
- package/package/scripts/init-editing.js +65 -57
- package/package/types/builder-props.d.ts +10 -0
- package/package/types/components.d.ts +8 -2
- package/package/types/enforced-partials.d.ts +1 -1
- package/package/types/targets.d.ts +1 -3
- package/package/types/typescript.d.ts +3 -0
- package/package.json +2 -2
- package/src/blocks/BaseText.svelte +1 -1
- package/src/blocks/button/button.svelte +21 -34
- package/src/blocks/button/component-info.ts +20 -27
- package/src/blocks/columns/columns.svelte +26 -30
- package/src/blocks/columns/component-info.ts +205 -240
- package/src/blocks/custom-code/component-info.ts +20 -27
- package/src/blocks/embed/component-info.ts +34 -51
- package/src/blocks/embed/helpers.ts +2 -8
- package/src/blocks/form/component-info.ts +204 -253
- package/src/blocks/form/form.svelte +1 -368
- package/src/blocks/fragment/component-info.ts +3 -5
- package/src/blocks/helpers.ts +43 -0
- package/src/blocks/image/component-info.ts +113 -161
- package/src/blocks/image/image.helpers.ts +5 -33
- package/src/blocks/img/component-info.ts +11 -16
- package/src/blocks/img/img.svelte +7 -31
- package/src/blocks/input/component-info.ts +35 -66
- package/src/blocks/input/input.svelte +7 -31
- package/src/blocks/raw-text/component-info.ts +8 -12
- package/src/blocks/raw-text/raw-text.svelte +2 -5
- package/src/blocks/section/component-info.ts +28 -37
- package/src/blocks/section/section.svelte +7 -30
- package/src/blocks/select/component-info.ts +38 -55
- package/src/blocks/select/select.svelte +7 -31
- package/src/blocks/submit-button/component-info.ts +10 -15
- package/src/blocks/submit-button/submit-button.svelte +7 -30
- package/src/blocks/symbol/component-info.ts +31 -39
- package/src/blocks/symbol/symbol.helpers.ts +47 -0
- package/src/blocks/symbol/symbol.svelte +50 -97
- package/src/blocks/text/component-info.ts +14 -18
- package/src/blocks/text/text.svelte +1 -1
- package/src/blocks/textarea/component-info.ts +26 -36
- package/src/blocks/textarea/textarea.svelte +7 -30
- package/src/blocks/video/component-info.ts +77 -103
- package/src/blocks/video/video.svelte +4 -31
- package/src/components/{render-block/render-block.helpers.ts → block/block.helpers.ts} +22 -49
- package/src/components/block/block.svelte +158 -0
- package/src/components/{render-block → block/components}/block-styles.svelte +23 -24
- package/src/components/block/components/block-wrapper.svelte +70 -0
- package/src/components/block/components/component-ref/component-ref.helpers.ts +53 -0
- package/src/components/block/components/component-ref/component-ref.svelte +41 -0
- package/src/components/block/components/interactive-element.svelte +42 -0
- package/src/components/block/components/repeated-block.svelte +30 -0
- package/src/components/{render-block → block}/types.ts +1 -2
- package/src/components/{render-blocks.svelte → blocks/blocks-wrapper.svelte} +14 -32
- package/src/components/blocks/blocks.svelte +51 -0
- package/src/components/{render-content/render-content.svelte → content/components/enable-editor.svelte} +71 -199
- package/src/components/{render-content/components/render-styles.helpers.ts → content/components/styles.helpers.ts} +9 -11
- package/src/components/{render-content/components/render-styles.svelte → content/components/styles.svelte} +3 -3
- package/src/components/content/content.helpers.ts +42 -0
- package/src/components/content/content.svelte +144 -0
- package/src/components/{render-content/render-content.types.ts → content/content.types.ts} +5 -9
- package/src/components/content/index.ts +1 -0
- package/src/components/{render-content → content}/wrap-component-ref.ts +1 -1
- package/src/components/{render-content-variants/render-content-variants.svelte → content-variants/content-variants.svelte} +26 -24
- package/src/components/{render-content-variants/render-content-variants.types.ts → content-variants/content-variants.types.ts} +9 -11
- package/src/components/{render-content-variants → content-variants}/helpers.ts +27 -73
- package/src/constants/builder-registered-components.ts +34 -14
- package/src/constants/device-sizes.ts +16 -22
- package/src/constants/sdk-version.ts +1 -1
- package/src/constants/target.ts +3 -1
- package/src/context/builder.context.ts +1 -1
- package/src/context/components.context.ts +6 -0
- package/src/context/types.ts +2 -7
- package/src/functions/apply-patch-with-mutation.ts +61 -0
- package/src/functions/camel-to-kebab-case.ts +1 -2
- package/src/functions/evaluate/acorn.ts +2501 -0
- package/src/functions/evaluate/evaluate.ts +90 -0
- package/src/functions/evaluate/index.ts +1 -0
- package/src/functions/evaluate/interpreter.ts +3887 -0
- package/src/functions/evaluate/non-node-runtime.ts +94 -0
- package/src/functions/evaluate/types.ts +10 -0
- package/src/functions/extract-text-styles.ts +3 -18
- package/src/functions/fast-clone.ts +1 -2
- package/src/functions/get-block-actions-handler.ts +11 -20
- package/src/functions/get-block-actions.ts +22 -14
- package/src/functions/get-block-component-options.ts +2 -3
- package/src/functions/get-block-properties.ts +24 -17
- package/src/functions/get-builder-search-params/index.ts +5 -21
- package/src/functions/get-content/generate-content-url.ts +10 -25
- package/src/functions/get-content/index.ts +34 -37
- package/src/functions/get-content/types.ts +4 -2
- package/src/functions/get-fetch.ts +3 -10
- package/src/functions/get-global-this.ts +1 -2
- package/src/functions/get-processed-block.ts +14 -21
- package/src/functions/get-react-native-block-styles.ts +6 -12
- package/src/functions/if-target.ts +2 -3
- package/src/functions/is-browser.ts +1 -1
- package/src/functions/is-editing.ts +2 -7
- package/src/functions/is-iframe.ts +1 -2
- package/src/functions/is-non-node-server.ts +9 -0
- package/src/functions/is-previewing.ts +1 -4
- package/src/functions/on-change.ts +2 -2
- package/src/functions/register-component.ts +24 -26
- package/src/functions/register.ts +6 -8
- package/src/functions/sanitize-react-native-block-styles.ts +17 -24
- package/src/functions/set-editor-settings.ts +5 -6
- package/src/functions/set.ts +3 -15
- package/src/functions/track/helpers.ts +8 -24
- package/src/functions/track/index.ts +37 -42
- package/src/functions/track/interaction.ts +21 -38
- package/src/functions/transform-block-properties.ts +1 -1
- package/src/functions/transform-block.ts +1 -1
- package/src/helpers/ab-tests.ts +64 -79
- package/src/helpers/canTrack.ts +2 -4
- package/src/helpers/cookie.ts +15 -46
- package/src/helpers/css.ts +4 -13
- package/src/helpers/flatten.ts +11 -16
- package/src/helpers/localStorage.ts +4 -8
- package/src/helpers/logger.ts +2 -2
- package/src/helpers/nullable.ts +1 -3
- package/src/helpers/preview-lru-cache/get.ts +8 -0
- package/src/helpers/preview-lru-cache/helpers.ts +9 -0
- package/src/helpers/preview-lru-cache/init.ts +17 -0
- package/src/helpers/preview-lru-cache/set.ts +18 -0
- package/src/helpers/preview-lru-cache/types.ts +12 -0
- package/src/helpers/sessionId.ts +12 -13
- package/src/helpers/time.ts +1 -3
- package/src/helpers/url.ts +1 -2
- package/src/helpers/uuid.ts +3 -3
- package/src/helpers/visitorId.ts +14 -17
- package/src/index-helpers/blocks-exports.ts +2 -2
- package/src/index-helpers/top-of-file.ts +1 -1
- package/src/index.ts +2 -13
- package/src/scripts/init-editing.ts +85 -98
- package/src/types/api-version.ts +1 -1
- package/src/types/builder-block.ts +1 -3
- package/src/types/builder-content.ts +7 -4
- package/src/types/builder-props.ts +10 -0
- package/src/types/can-track.ts +1 -1
- package/src/types/components.ts +17 -13
- package/src/types/deep-partial.ts +1 -7
- package/src/types/element.ts +1 -3
- package/src/types/enforced-partials.ts +6 -20
- package/src/types/input.ts +6 -9
- package/src/types/targets.ts +1 -6
- package/src/types/typescript.ts +9 -9
- package/package/blocks/util.d.ts +0 -4
- package/package/blocks/util.js +0 -13
- package/package/components/render-block/render-block.helpers.d.ts +0 -12
- package/package/components/render-block/render-block.svelte +0 -152
- package/package/components/render-block/render-block.svelte.d.ts +0 -24
- package/package/components/render-block/render-component.svelte +0 -21
- package/package/components/render-block/render-component.svelte.d.ts +0 -34
- package/package/components/render-block/render-repeated-block.svelte.d.ts +0 -23
- package/package/components/render-blocks.svelte.d.ts +0 -26
- package/package/components/render-content/builder-editing.svelte +0 -4
- package/package/components/render-content/builder-editing.svelte.d.ts +0 -14
- package/package/components/render-content/index.d.ts +0 -1
- package/package/components/render-content/index.js +0 -1
- package/package/components/render-content/render-content.helpers.d.ts +0 -7
- package/package/components/render-content/render-content.helpers.js +0 -30
- package/package/components/render-content/render-content.svelte.d.ts +0 -30
- package/package/functions/evaluate.test.js +0 -17
- package/package/functions/get-builder-search-params/fn.test.js +0 -13
- package/package/functions/get-content/generate-content-url.test.d.ts +0 -1
- package/package/functions/get-content/generate-content-url.test.js +0 -97
- package/package/functions/get-processed-block.test.d.ts +0 -1
- package/package/functions/get-processed-block.test.js +0 -33
- package/package/functions/on-change.test.d.ts +0 -1
- package/package/functions/on-change.test.js +0 -20
- package/package/functions/set.test.d.ts +0 -1
- package/package/functions/set.test.js +0 -16
- package/package/helpers/url.test.d.ts +0 -1
- package/package/helpers/url.test.js +0 -21
- package/src/blocks/util.ts +0 -18
- package/src/components/render-block/render-block.svelte +0 -173
- package/src/components/render-block/render-component.svelte +0 -40
- package/src/components/render-block/render-repeated-block.svelte +0 -25
- package/src/components/render-content/builder-editing.svelte +0 -4
- package/src/components/render-content/index.ts +0 -1
- package/src/components/render-content/render-content.helpers.ts +0 -48
- package/src/functions/evaluate.test.ts +0 -21
- package/src/functions/evaluate.ts +0 -99
- package/src/functions/get-builder-search-params/fn.test.ts +0 -19
- package/src/functions/get-content/generate-content-url.test.ts +0 -112
- package/src/functions/get-processed-block.test.ts +0 -35
- package/src/functions/on-change.test.ts +0 -23
- package/src/functions/set.test.ts +0 -19
- package/src/helpers/url.test.ts +0 -23
- /package/package/components/{render-block → block}/types.d.ts +0 -0
- /package/package/components/{render-block → block}/types.js +0 -0
- /package/package/components/{render-content/render-content.types.js → content/content.types.js} +0 -0
- /package/package/components/{render-content → content}/wrap-component-ref.d.ts +0 -0
- /package/package/components/{render-content → content}/wrap-component-ref.js +0 -0
- /package/package/components/{render-content-variants/render-content-variants.types.js → content-variants/content-variants.types.js} +0 -0
- /package/package/functions/{evaluate.test.d.ts → evaluate/types.js} +0 -0
- /package/package/{functions/get-builder-search-params/fn.test.d.ts → types/builder-props.js} +0 -0
|
@@ -1,43 +1,24 @@
|
|
|
1
|
-
import type { BuilderContextInterface } from '../../context/types';
|
|
1
|
+
import type { BuilderContextInterface, RegisteredComponents } from '../../context/types.js';
|
|
2
2
|
import { evaluate } from '../../functions/evaluate';
|
|
3
|
-
import { getProcessedBlock } from '../../functions/get-processed-block';
|
|
4
|
-
import type { BuilderBlock } from '../../types/builder-block';
|
|
5
|
-
import type { RepeatData } from './types';
|
|
3
|
+
import { getProcessedBlock } from '../../functions/get-processed-block.js';
|
|
4
|
+
import type { BuilderBlock } from '../../types/builder-block.js';
|
|
5
|
+
import type { RepeatData } from './types.js';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* https://developer.mozilla.org/en-US/docs/Glossary/Empty_element
|
|
9
9
|
*/
|
|
10
|
-
const EMPTY_HTML_ELEMENTS = [
|
|
11
|
-
'area',
|
|
12
|
-
'base',
|
|
13
|
-
'br',
|
|
14
|
-
'col',
|
|
15
|
-
'embed',
|
|
16
|
-
'hr',
|
|
17
|
-
'img',
|
|
18
|
-
'input',
|
|
19
|
-
'keygen',
|
|
20
|
-
'link',
|
|
21
|
-
'meta',
|
|
22
|
-
'param',
|
|
23
|
-
'source',
|
|
24
|
-
'track',
|
|
25
|
-
'wbr',
|
|
26
|
-
];
|
|
27
|
-
|
|
10
|
+
const EMPTY_HTML_ELEMENTS = ['area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'keygen', 'link', 'meta', 'param', 'source', 'track', 'wbr'];
|
|
28
11
|
export const isEmptyHtmlElement = (tagName: unknown) => {
|
|
29
|
-
return (
|
|
30
|
-
typeof tagName === 'string' &&
|
|
31
|
-
EMPTY_HTML_ELEMENTS.includes(tagName.toLowerCase())
|
|
32
|
-
);
|
|
12
|
+
return typeof tagName === 'string' && EMPTY_HTML_ELEMENTS.includes(tagName.toLowerCase());
|
|
33
13
|
};
|
|
34
|
-
|
|
35
14
|
export const getComponent = ({
|
|
36
15
|
block,
|
|
37
16
|
context,
|
|
17
|
+
registeredComponents
|
|
38
18
|
}: {
|
|
39
19
|
block: BuilderBlock;
|
|
40
20
|
context: BuilderContextInterface;
|
|
21
|
+
registeredComponents: RegisteredComponents;
|
|
41
22
|
}) => {
|
|
42
23
|
const componentName = getProcessedBlock({
|
|
43
24
|
block,
|
|
@@ -45,15 +26,12 @@ export const getComponent = ({
|
|
|
45
26
|
rootState: context.rootState,
|
|
46
27
|
rootSetState: context.rootSetState,
|
|
47
28
|
context: context.context,
|
|
48
|
-
shouldEvaluateBindings: false
|
|
29
|
+
shouldEvaluateBindings: false
|
|
49
30
|
}).component?.name;
|
|
50
|
-
|
|
51
31
|
if (!componentName) {
|
|
52
32
|
return null;
|
|
53
33
|
}
|
|
54
|
-
|
|
55
|
-
const ref = context.registeredComponents[componentName];
|
|
56
|
-
|
|
34
|
+
const ref = registeredComponents[componentName];
|
|
57
35
|
if (!ref) {
|
|
58
36
|
// TODO: Public doc page with more info about this message
|
|
59
37
|
console.warn(`
|
|
@@ -64,40 +42,36 @@ export const getComponent = ({
|
|
|
64
42
|
return ref;
|
|
65
43
|
}
|
|
66
44
|
};
|
|
67
|
-
|
|
68
45
|
export const getRepeatItemData = ({
|
|
69
46
|
block,
|
|
70
|
-
context
|
|
47
|
+
context
|
|
71
48
|
}: {
|
|
72
49
|
block: BuilderBlock;
|
|
73
50
|
context: BuilderContextInterface;
|
|
74
51
|
}): RepeatData[] | undefined => {
|
|
75
52
|
/**
|
|
76
|
-
* we don't use `state.
|
|
53
|
+
* we don't use `state.processedBlock` here because the processing done within its logic includes evaluating the block's bindings,
|
|
77
54
|
* which will not work if there is a repeat.
|
|
78
55
|
*/
|
|
79
|
-
const {
|
|
80
|
-
|
|
56
|
+
const {
|
|
57
|
+
repeat,
|
|
58
|
+
...blockWithoutRepeat
|
|
59
|
+
} = block;
|
|
81
60
|
if (!repeat?.collection) {
|
|
82
61
|
return undefined;
|
|
83
62
|
}
|
|
84
|
-
|
|
85
63
|
const itemsArray = evaluate({
|
|
86
64
|
code: repeat.collection,
|
|
87
65
|
localState: context.localState,
|
|
88
66
|
rootState: context.rootState,
|
|
89
67
|
rootSetState: context.rootSetState,
|
|
90
|
-
context: context.context
|
|
68
|
+
context: context.context
|
|
91
69
|
});
|
|
92
|
-
|
|
93
70
|
if (!Array.isArray(itemsArray)) {
|
|
94
71
|
return undefined;
|
|
95
72
|
}
|
|
96
|
-
|
|
97
73
|
const collectionName = repeat.collection.split('.').pop();
|
|
98
|
-
const itemNameToUse =
|
|
99
|
-
repeat.itemName || (collectionName ? collectionName + 'Item' : 'item');
|
|
100
|
-
|
|
74
|
+
const itemNameToUse = repeat.itemName || (collectionName ? collectionName + 'Item' : 'item');
|
|
101
75
|
const repeatArray = itemsArray.map<RepeatData>((item, index) => ({
|
|
102
76
|
context: {
|
|
103
77
|
...context,
|
|
@@ -106,11 +80,10 @@ export const getRepeatItemData = ({
|
|
|
106
80
|
$index: index,
|
|
107
81
|
$item: item,
|
|
108
82
|
[itemNameToUse]: item,
|
|
109
|
-
[`$${itemNameToUse}Index`]: index
|
|
110
|
-
}
|
|
83
|
+
[`$${itemNameToUse}Index`]: index
|
|
84
|
+
}
|
|
111
85
|
},
|
|
112
|
-
block: blockWithoutRepeat
|
|
86
|
+
block: blockWithoutRepeat
|
|
113
87
|
}));
|
|
114
|
-
|
|
115
88
|
return repeatArray;
|
|
116
|
-
}
|
|
89
|
+
}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
<script context="module" lang="ts">
|
|
2
|
+
export type BlockProps = {
|
|
3
|
+
block: BuilderBlock;
|
|
4
|
+
context: Writable<BuilderContextInterface>;
|
|
5
|
+
registeredComponents: RegisteredComponents;
|
|
6
|
+
};
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
<script lang="ts">
|
|
10
|
+
import { writable } from "svelte/store";
|
|
11
|
+
|
|
12
|
+
import type {
|
|
13
|
+
BuilderContextInterface,
|
|
14
|
+
RegisteredComponents,
|
|
15
|
+
} from "../../context/types.js";
|
|
16
|
+
import { getBlockComponentOptions } from "../../functions/get-block-component-options.js";
|
|
17
|
+
import { getBlockProperties } from "../../functions/get-block-properties.js";
|
|
18
|
+
import { getProcessedBlock } from "../../functions/get-processed-block.js";
|
|
19
|
+
import type { BuilderBlock } from "../../types/builder-block.js";
|
|
20
|
+
import BlockStyles from "./components/block-styles.svelte";
|
|
21
|
+
import {
|
|
22
|
+
getComponent,
|
|
23
|
+
getRepeatItemData,
|
|
24
|
+
isEmptyHtmlElement,
|
|
25
|
+
} from "./block.helpers.js";
|
|
26
|
+
import RepeatedBlock from "./components/repeated-block.svelte";
|
|
27
|
+
import { extractTextStyles } from "../../functions/extract-text-styles.js";
|
|
28
|
+
import ComponentRef from "./components/component-ref/component-ref.svelte";
|
|
29
|
+
import type { ComponentProps } from "./components/component-ref/component-ref.helpers.js";
|
|
30
|
+
import BlockWrapper from "./components/block-wrapper.svelte";
|
|
31
|
+
import type { Writable } from "svelte/store";
|
|
32
|
+
|
|
33
|
+
export let block: BlockProps["block"];
|
|
34
|
+
export let context: BlockProps["context"];
|
|
35
|
+
export let registeredComponents: BlockProps["registeredComponents"];
|
|
36
|
+
|
|
37
|
+
$: blockComponent = () => {
|
|
38
|
+
return getComponent({
|
|
39
|
+
block: block,
|
|
40
|
+
context: $context,
|
|
41
|
+
registeredComponents: registeredComponents,
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
$: repeatItem = () => {
|
|
45
|
+
return getRepeatItemData({
|
|
46
|
+
block: block,
|
|
47
|
+
context: $context,
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
$: processedBlock = () => {
|
|
51
|
+
return repeatItem()
|
|
52
|
+
? block
|
|
53
|
+
: getProcessedBlock({
|
|
54
|
+
block: block,
|
|
55
|
+
localState: $context.localState,
|
|
56
|
+
rootState: $context.rootState,
|
|
57
|
+
rootSetState: $context.rootSetState,
|
|
58
|
+
context: $context.context,
|
|
59
|
+
shouldEvaluateBindings: true,
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
$: Tag = () => {
|
|
63
|
+
return block.tagName || "div";
|
|
64
|
+
};
|
|
65
|
+
$: canShowBlock = () => {
|
|
66
|
+
if ("hide" in processedBlock()) {
|
|
67
|
+
return !processedBlock().hide;
|
|
68
|
+
}
|
|
69
|
+
if ("show" in processedBlock()) {
|
|
70
|
+
return processedBlock().show;
|
|
71
|
+
}
|
|
72
|
+
return true;
|
|
73
|
+
};
|
|
74
|
+
$: childrenWithoutParentComponent = () => {
|
|
75
|
+
/**
|
|
76
|
+
* When there is no `componentRef`, there might still be children that need to be rendered. In this case,
|
|
77
|
+
* we render them outside of `componentRef`.
|
|
78
|
+
* NOTE: We make sure not to render this if `repeatItemData` is non-null, because that means we are rendering an array of
|
|
79
|
+
* blocks, and the children will be repeated within those blocks.
|
|
80
|
+
*/
|
|
81
|
+
const shouldRenderChildrenOutsideRef =
|
|
82
|
+
!blockComponent?.()?.component && !repeatItem();
|
|
83
|
+
return shouldRenderChildrenOutsideRef
|
|
84
|
+
? processedBlock().children ?? []
|
|
85
|
+
: [];
|
|
86
|
+
};
|
|
87
|
+
$: componentRefProps = () => {
|
|
88
|
+
return {
|
|
89
|
+
blockChildren: processedBlock().children ?? [],
|
|
90
|
+
componentRef: blockComponent?.()?.component,
|
|
91
|
+
componentOptions: {
|
|
92
|
+
...getBlockComponentOptions(processedBlock()),
|
|
93
|
+
builderContext: context,
|
|
94
|
+
...(blockComponent?.()?.name === "Symbol" ||
|
|
95
|
+
blockComponent?.()?.name === "Columns"
|
|
96
|
+
? {
|
|
97
|
+
builderComponents: registeredComponents,
|
|
98
|
+
}
|
|
99
|
+
: {}),
|
|
100
|
+
},
|
|
101
|
+
context: childrenContext,
|
|
102
|
+
registeredComponents: registeredComponents,
|
|
103
|
+
builderBlock: processedBlock(),
|
|
104
|
+
includeBlockProps: blockComponent?.()?.noWrap === true,
|
|
105
|
+
isInteractive: !blockComponent?.()?.isRSC,
|
|
106
|
+
};
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
let childrenContext = writable($context);
|
|
110
|
+
</script>
|
|
111
|
+
|
|
112
|
+
{#if canShowBlock()}
|
|
113
|
+
{#if !blockComponent?.()?.noWrap}
|
|
114
|
+
{#if isEmptyHtmlElement(Tag())}
|
|
115
|
+
<BlockWrapper
|
|
116
|
+
Wrapper={Tag()}
|
|
117
|
+
block={processedBlock()}
|
|
118
|
+
{context}
|
|
119
|
+
hasChildren={false}
|
|
120
|
+
/>
|
|
121
|
+
{/if}
|
|
122
|
+
|
|
123
|
+
{#if !isEmptyHtmlElement(Tag()) && repeatItem()}
|
|
124
|
+
{#each repeatItem() as data, index (index)}
|
|
125
|
+
<RepeatedBlock
|
|
126
|
+
repeatContext={data.context}
|
|
127
|
+
block={data.block}
|
|
128
|
+
{registeredComponents}
|
|
129
|
+
/>
|
|
130
|
+
{/each}
|
|
131
|
+
{/if}
|
|
132
|
+
|
|
133
|
+
{#if !isEmptyHtmlElement(Tag()) && !repeatItem()}
|
|
134
|
+
<BlockWrapper
|
|
135
|
+
Wrapper={Tag()}
|
|
136
|
+
block={processedBlock()}
|
|
137
|
+
{context}
|
|
138
|
+
hasChildren={true}
|
|
139
|
+
>
|
|
140
|
+
<ComponentRef {...componentRefProps()} />
|
|
141
|
+
|
|
142
|
+
{#each childrenWithoutParentComponent() as child ("block-" + child.id)}
|
|
143
|
+
<svelte:self
|
|
144
|
+
block={child}
|
|
145
|
+
context={childrenContext}
|
|
146
|
+
{registeredComponents}
|
|
147
|
+
/>
|
|
148
|
+
{/each}
|
|
149
|
+
|
|
150
|
+
{#each childrenWithoutParentComponent() as child ("block-style-" + child.id)}
|
|
151
|
+
<BlockStyles block={child} context={$childrenContext} />
|
|
152
|
+
{/each}
|
|
153
|
+
</BlockWrapper>
|
|
154
|
+
{/if}
|
|
155
|
+
{:else}
|
|
156
|
+
<ComponentRef {...componentRefProps()} />
|
|
157
|
+
{/if}
|
|
158
|
+
{/if}
|
|
@@ -9,40 +9,30 @@
|
|
|
9
9
|
import {
|
|
10
10
|
getMaxWidthQueryForSize,
|
|
11
11
|
getSizesForBreakpoints,
|
|
12
|
-
} from "
|
|
13
|
-
import { TARGET } from "
|
|
14
|
-
import type { BuilderContextInterface } from "
|
|
15
|
-
import { getProcessedBlock } from "
|
|
16
|
-
import { createCssClass } from "
|
|
17
|
-
import { checkIsDefined } from "
|
|
18
|
-
import type { BuilderBlock } from "
|
|
19
|
-
import InlinedStyles from "
|
|
12
|
+
} from "../../../constants/device-sizes.js";
|
|
13
|
+
import { TARGET } from "../../../constants/target.js";
|
|
14
|
+
import type { BuilderContextInterface } from "../../../context/types.js";
|
|
15
|
+
import { getProcessedBlock } from "../../../functions/get-processed-block.js";
|
|
16
|
+
import { createCssClass } from "../../../helpers/css.js";
|
|
17
|
+
import { checkIsDefined } from "../../../helpers/nullable.js";
|
|
18
|
+
import type { BuilderBlock } from "../../../types/builder-block.js";
|
|
19
|
+
import InlinedStyles from "../../inlined-styles.svelte";
|
|
20
20
|
|
|
21
21
|
export let block: BlockStylesProps["block"];
|
|
22
22
|
export let context: BlockStylesProps["context"];
|
|
23
23
|
|
|
24
|
-
$: useBlock = () => {
|
|
25
|
-
return getProcessedBlock({
|
|
26
|
-
block: block,
|
|
27
|
-
localState: context.localState,
|
|
28
|
-
rootState: context.rootState,
|
|
29
|
-
rootSetState: context.rootSetState,
|
|
30
|
-
context: context.context,
|
|
31
|
-
shouldEvaluateBindings: true,
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
24
|
$: canShowBlock = () => {
|
|
35
25
|
// only render styles for blocks that are visible
|
|
36
|
-
if (checkIsDefined(
|
|
37
|
-
return !
|
|
26
|
+
if (checkIsDefined(processedBlock.hide)) {
|
|
27
|
+
return !processedBlock.hide;
|
|
38
28
|
}
|
|
39
|
-
if (checkIsDefined(
|
|
40
|
-
return
|
|
29
|
+
if (checkIsDefined(processedBlock.show)) {
|
|
30
|
+
return processedBlock.show;
|
|
41
31
|
}
|
|
42
32
|
return true;
|
|
43
33
|
};
|
|
44
34
|
$: css = () => {
|
|
45
|
-
const styles =
|
|
35
|
+
const styles = processedBlock.responsiveStyles;
|
|
46
36
|
const content = context.content;
|
|
47
37
|
const sizesWithUpdatedBreakpoints = getSizesForBreakpoints(
|
|
48
38
|
content?.meta?.breakpoints || {}
|
|
@@ -50,7 +40,7 @@
|
|
|
50
40
|
const largeStyles = styles?.large;
|
|
51
41
|
const mediumStyles = styles?.medium;
|
|
52
42
|
const smallStyles = styles?.small;
|
|
53
|
-
const className =
|
|
43
|
+
const className = processedBlock.id;
|
|
54
44
|
if (!className) {
|
|
55
45
|
return "";
|
|
56
46
|
}
|
|
@@ -82,6 +72,15 @@
|
|
|
82
72
|
: "";
|
|
83
73
|
return [largeStylesClass, mediumStylesClass, smallStylesClass].join(" ");
|
|
84
74
|
};
|
|
75
|
+
|
|
76
|
+
let processedBlock = getProcessedBlock({
|
|
77
|
+
block: block,
|
|
78
|
+
localState: context.localState,
|
|
79
|
+
rootState: context.rootState,
|
|
80
|
+
rootSetState: context.rootSetState,
|
|
81
|
+
context: context.context,
|
|
82
|
+
shouldEvaluateBindings: true,
|
|
83
|
+
});
|
|
85
84
|
</script>
|
|
86
85
|
|
|
87
86
|
{#if TARGET !== "reactNative" && css() && canShowBlock()}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
<script context="module" lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* This import is used by the Svelte SDK. Do not remove.
|
|
4
|
+
*/ // eslint-disable-next-line unused-imports/no-unused-imports, @typescript-eslint/no-unused-vars
|
|
5
|
+
type BlockWrapperProps = {
|
|
6
|
+
Wrapper: string;
|
|
7
|
+
block: BuilderBlock;
|
|
8
|
+
context: Writable<BuilderContextInterface>;
|
|
9
|
+
hasChildren: boolean;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* This component renders a block's wrapper HTML element (from the block's `tagName` property).
|
|
14
|
+
* It reuses the exact same logic as the `InteractiveElement` component, but we need to have 2 separate components for
|
|
15
|
+
* Svelte's sake, as it needs to know at compile-time whether to use:
|
|
16
|
+
* - `<svelte:element>` (for HTML element) or
|
|
17
|
+
* - `<svelte:component>` (for custom components)
|
|
18
|
+
*/
|
|
19
|
+
</script>
|
|
20
|
+
|
|
21
|
+
<script lang="ts">
|
|
22
|
+
import type { PropsWithChildren } from "../../../types/typescript.js";
|
|
23
|
+
import type { BuilderBlock } from "../../../types/builder-block.js";
|
|
24
|
+
import type { BuilderContextInterface } from "../../../context/types.js";
|
|
25
|
+
import { getBlockActions } from "../../../functions/get-block-actions.js";
|
|
26
|
+
import { getBlockProperties } from "../../../functions/get-block-properties.js";
|
|
27
|
+
import { setAttrs } from "../../../blocks/helpers.js";
|
|
28
|
+
import type { Writable } from "svelte/store";
|
|
29
|
+
|
|
30
|
+
export let Wrapper: PropsWithChildren<BlockWrapperProps>["Wrapper"];
|
|
31
|
+
export let block: PropsWithChildren<BlockWrapperProps>["block"];
|
|
32
|
+
export let context: PropsWithChildren<BlockWrapperProps>["context"];
|
|
33
|
+
export let hasChildren: PropsWithChildren<BlockWrapperProps>["hasChildren"];
|
|
34
|
+
</script>
|
|
35
|
+
|
|
36
|
+
{#if hasChildren}
|
|
37
|
+
<svelte:element
|
|
38
|
+
this={Wrapper}
|
|
39
|
+
{...getBlockProperties({
|
|
40
|
+
block: block,
|
|
41
|
+
context: $context,
|
|
42
|
+
})}
|
|
43
|
+
use:setAttrs={getBlockActions({
|
|
44
|
+
block: block,
|
|
45
|
+
rootState: $context.rootState,
|
|
46
|
+
rootSetState: $context.rootSetState,
|
|
47
|
+
localState: $context.localState,
|
|
48
|
+
context: $context.context,
|
|
49
|
+
stripPrefix: true,
|
|
50
|
+
})}
|
|
51
|
+
>
|
|
52
|
+
<slot />
|
|
53
|
+
</svelte:element>
|
|
54
|
+
{:else}
|
|
55
|
+
<svelte:element
|
|
56
|
+
this={Wrapper}
|
|
57
|
+
{...getBlockProperties({
|
|
58
|
+
block: block,
|
|
59
|
+
context: $context,
|
|
60
|
+
})}
|
|
61
|
+
use:setAttrs={getBlockActions({
|
|
62
|
+
block: block,
|
|
63
|
+
rootState: $context.rootState,
|
|
64
|
+
rootSetState: $context.rootSetState,
|
|
65
|
+
localState: $context.localState,
|
|
66
|
+
context: $context.context,
|
|
67
|
+
stripPrefix: true,
|
|
68
|
+
})}
|
|
69
|
+
/>
|
|
70
|
+
{/if}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { Writable } from "svelte/store";
|
|
2
|
+
import type { BuilderContextInterface, RegisteredComponents } from '../../../../context/types.js';
|
|
3
|
+
import { getBlockProperties } from '../../../../functions/get-block-properties.js';
|
|
4
|
+
import type { BuilderBlock } from '../../../../types/builder-block.js';
|
|
5
|
+
import type { PropsWithBuilderData } from '../../../../types/builder-props.js';
|
|
6
|
+
import type { InteractiveElementProps } from '../interactive-element.svelte';
|
|
7
|
+
type ComponentOptions = PropsWithBuilderData<{
|
|
8
|
+
[index: string]: any;
|
|
9
|
+
attributes?: {
|
|
10
|
+
[index: string]: any;
|
|
11
|
+
};
|
|
12
|
+
}>;
|
|
13
|
+
export interface ComponentProps {
|
|
14
|
+
componentRef: any;
|
|
15
|
+
componentOptions: ComponentOptions;
|
|
16
|
+
blockChildren: BuilderBlock[];
|
|
17
|
+
context: Writable<BuilderContextInterface>;
|
|
18
|
+
registeredComponents: RegisteredComponents;
|
|
19
|
+
builderBlock: BuilderBlock;
|
|
20
|
+
includeBlockProps: boolean;
|
|
21
|
+
isInteractive: boolean | undefined;
|
|
22
|
+
}
|
|
23
|
+
export const getWrapperProps = ({
|
|
24
|
+
componentOptions,
|
|
25
|
+
builderBlock,
|
|
26
|
+
context,
|
|
27
|
+
componentRef,
|
|
28
|
+
includeBlockProps,
|
|
29
|
+
isInteractive,
|
|
30
|
+
contextValue
|
|
31
|
+
}: Omit<ComponentProps, 'blockChildren' | 'registeredComponents'> & {
|
|
32
|
+
contextValue: BuilderContextInterface;
|
|
33
|
+
}) => {
|
|
34
|
+
const interactiveElementProps: InteractiveElementProps = {
|
|
35
|
+
Wrapper: componentRef,
|
|
36
|
+
block: builderBlock,
|
|
37
|
+
context,
|
|
38
|
+
wrapperProps: componentOptions
|
|
39
|
+
};
|
|
40
|
+
return isInteractive ? interactiveElementProps : {
|
|
41
|
+
...componentOptions,
|
|
42
|
+
/**
|
|
43
|
+
* If `noWrap` is set to `true`, then the block's props/attributes are provided to the
|
|
44
|
+
* component itself directly. Otherwise, they are provided to the wrapper element.
|
|
45
|
+
*/
|
|
46
|
+
...(includeBlockProps ? {
|
|
47
|
+
attributes: getBlockProperties({
|
|
48
|
+
block: builderBlock,
|
|
49
|
+
context: contextValue
|
|
50
|
+
})
|
|
51
|
+
} : {})
|
|
52
|
+
};
|
|
53
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import BlockStyles from "../block-styles.svelte";
|
|
3
|
+
import Block from "../../block.svelte";
|
|
4
|
+
import InteractiveElement from "../interactive-element.svelte";
|
|
5
|
+
import type { ComponentProps } from "./component-ref.helpers.js";
|
|
6
|
+
import { getWrapperProps } from "./component-ref.helpers.js";
|
|
7
|
+
|
|
8
|
+
export let isInteractive: ComponentProps["isInteractive"];
|
|
9
|
+
export let componentRef: ComponentProps["componentRef"];
|
|
10
|
+
export let componentOptions: ComponentProps["componentOptions"];
|
|
11
|
+
export let builderBlock: ComponentProps["builderBlock"];
|
|
12
|
+
export let context: ComponentProps["context"];
|
|
13
|
+
export let includeBlockProps: ComponentProps["includeBlockProps"];
|
|
14
|
+
export let blockChildren: ComponentProps["blockChildren"];
|
|
15
|
+
export let registeredComponents: ComponentProps["registeredComponents"];
|
|
16
|
+
|
|
17
|
+
let Wrapper = isInteractive ? InteractiveElement : componentRef;
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
{#if componentRef}
|
|
21
|
+
<svelte:component
|
|
22
|
+
this={Wrapper}
|
|
23
|
+
{...getWrapperProps({
|
|
24
|
+
componentOptions: componentOptions,
|
|
25
|
+
builderBlock: builderBlock,
|
|
26
|
+
context: context,
|
|
27
|
+
componentRef: componentRef,
|
|
28
|
+
includeBlockProps: includeBlockProps,
|
|
29
|
+
isInteractive: isInteractive,
|
|
30
|
+
contextValue: $context,
|
|
31
|
+
})}
|
|
32
|
+
>
|
|
33
|
+
{#each blockChildren as child ("block-" + child.id)}
|
|
34
|
+
<Block block={child} {context} {registeredComponents} />
|
|
35
|
+
{/each}
|
|
36
|
+
|
|
37
|
+
{#each blockChildren as child ("block-style-" + child.id)}
|
|
38
|
+
<BlockStyles block={child} context={$context} />
|
|
39
|
+
{/each}
|
|
40
|
+
</svelte:component>
|
|
41
|
+
{/if}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
<script context="module" lang="ts">
|
|
2
|
+
export type InteractiveElementProps = {
|
|
3
|
+
Wrapper: any;
|
|
4
|
+
block: BuilderBlock;
|
|
5
|
+
context: Writable<BuilderContextInterface>;
|
|
6
|
+
wrapperProps: object;
|
|
7
|
+
};
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<script lang="ts">
|
|
11
|
+
import type { BuilderContextInterface } from "../../../context/types.js";
|
|
12
|
+
import { getBlockActions } from "../../../functions/get-block-actions.js";
|
|
13
|
+
import { getBlockProperties } from "../../../functions/get-block-properties.js";
|
|
14
|
+
import type { BuilderBlock } from "../../../types/builder-block.js";
|
|
15
|
+
import type { PropsWithChildren } from "../../../types/typescript.js";
|
|
16
|
+
import type { Writable } from "svelte/store";
|
|
17
|
+
|
|
18
|
+
export let Wrapper: PropsWithChildren<InteractiveElementProps>["Wrapper"];
|
|
19
|
+
export let wrapperProps: PropsWithChildren<InteractiveElementProps>["wrapperProps"];
|
|
20
|
+
export let block: PropsWithChildren<InteractiveElementProps>["block"];
|
|
21
|
+
export let context: PropsWithChildren<InteractiveElementProps>["context"];
|
|
22
|
+
</script>
|
|
23
|
+
|
|
24
|
+
<svelte:component
|
|
25
|
+
this={Wrapper}
|
|
26
|
+
{...wrapperProps}
|
|
27
|
+
attributes={{
|
|
28
|
+
...getBlockProperties({
|
|
29
|
+
block: block,
|
|
30
|
+
context: $context,
|
|
31
|
+
}),
|
|
32
|
+
...getBlockActions({
|
|
33
|
+
block: block,
|
|
34
|
+
rootState: $context.rootState,
|
|
35
|
+
rootSetState: $context.rootSetState,
|
|
36
|
+
localState: $context.localState,
|
|
37
|
+
context: $context.context,
|
|
38
|
+
}),
|
|
39
|
+
}}
|
|
40
|
+
>
|
|
41
|
+
<slot />
|
|
42
|
+
</svelte:component>
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
<script context="module" lang="ts">
|
|
2
|
+
type Props = {
|
|
3
|
+
block: BuilderBlock;
|
|
4
|
+
repeatContext: BuilderContextInterface;
|
|
5
|
+
registeredComponents: RegisteredComponents;
|
|
6
|
+
};
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
<script lang="ts">
|
|
10
|
+
import { setContext } from "svelte";
|
|
11
|
+
import { writable } from "svelte/store";
|
|
12
|
+
|
|
13
|
+
import BuilderContext from "../../../context/builder.context";
|
|
14
|
+
import type {
|
|
15
|
+
BuilderContextInterface,
|
|
16
|
+
RegisteredComponents,
|
|
17
|
+
} from "../../../context/types.js";
|
|
18
|
+
import type { BuilderBlock } from "../../../types/builder-block.js";
|
|
19
|
+
import Block from "../block.svelte";
|
|
20
|
+
|
|
21
|
+
export let repeatContext: Props["repeatContext"];
|
|
22
|
+
export let block: Props["block"];
|
|
23
|
+
export let registeredComponents: Props["registeredComponents"];
|
|
24
|
+
|
|
25
|
+
let store = writable(repeatContext);
|
|
26
|
+
|
|
27
|
+
setContext(BuilderContext.key, store);
|
|
28
|
+
</script>
|
|
29
|
+
|
|
30
|
+
<Block {block} context={store} {registeredComponents} />
|