@builder.io/sdk-react 0.4.5 → 0.5.1-0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{sdk/blocks → blocks}/BaseText.d.ts +0 -1
- package/dist/{sdk/blocks → blocks}/BaseText.js +2 -2
- package/dist/{sdk/blocks → blocks}/button/button.d.ts +3 -2
- package/dist/{sdk/blocks → blocks}/button/button.js +3 -5
- package/dist/blocks/button/component-info.d.ts +2 -0
- package/dist/{sdk/blocks → blocks}/button/component-info.js +9 -13
- package/dist/blocks/columns/columns.d.ts +16 -0
- package/dist/{sdk/blocks → blocks}/columns/columns.js +13 -19
- package/dist/blocks/columns/component-info.d.ts +2 -0
- package/dist/{sdk/blocks → blocks}/columns/component-info.js +62 -83
- package/dist/blocks/custom-code/component-info.d.ts +2 -0
- package/dist/{sdk/blocks → blocks}/custom-code/component-info.js +7 -11
- package/dist/{sdk/blocks → blocks}/custom-code/custom-code.d.ts +0 -1
- package/dist/{sdk/blocks → blocks}/custom-code/custom-code.js +1 -1
- package/dist/blocks/embed/component-info.d.ts +2 -0
- package/dist/{sdk/blocks → blocks}/embed/component-info.js +8 -15
- package/dist/{sdk/blocks → blocks}/embed/embed.d.ts +0 -1
- package/dist/{sdk/blocks → blocks}/embed/embed.js +1 -1
- package/dist/blocks/embed/helpers.js +2 -0
- package/dist/blocks/form/component-info.d.ts +2 -0
- package/dist/{sdk/blocks → blocks}/form/component-info.js +94 -129
- package/dist/blocks/form/form.d.ts +2 -0
- package/dist/blocks/form/form.js +6 -0
- package/dist/blocks/fragment/component-info.d.ts +2 -0
- package/dist/{sdk/blocks → blocks}/fragment/component-info.js +1 -1
- package/dist/{sdk/blocks → blocks}/fragment/fragment.d.ts +0 -1
- package/dist/{sdk/blocks → blocks}/fragment/fragment.js +1 -1
- package/dist/blocks/helpers.d.ts +13 -0
- package/dist/blocks/helpers.js +40 -0
- package/dist/blocks/image/component-info.d.ts +2 -0
- package/dist/{sdk/blocks → blocks}/image/component-info.js +33 -63
- package/dist/{sdk/blocks → blocks}/image/image.d.ts +0 -1
- package/dist/{sdk/blocks → blocks}/image/image.helpers.js +2 -11
- package/dist/{sdk/blocks → blocks}/image/image.js +7 -7
- package/dist/blocks/img/component-info.d.ts +2 -0
- package/dist/{sdk/blocks → blocks}/img/component-info.js +4 -6
- package/dist/{sdk/blocks → blocks}/img/img.d.ts +3 -2
- package/dist/{sdk/blocks → blocks}/img/img.js +1 -1
- package/dist/blocks/input/component-info.d.ts +2 -0
- package/dist/{sdk/blocks → blocks}/input/component-info.js +15 -40
- package/dist/{sdk/blocks → blocks}/input/input.d.ts +3 -2
- package/dist/{sdk/blocks → blocks}/input/input.js +1 -1
- package/dist/blocks/raw-text/component-info.d.ts +2 -0
- package/dist/{sdk/blocks → blocks}/raw-text/component-info.js +3 -5
- package/dist/{sdk/blocks → blocks}/raw-text/raw-text.d.ts +0 -1
- package/dist/blocks/raw-text/raw-text.js +6 -0
- package/dist/blocks/section/component-info.d.ts +2 -0
- package/dist/{sdk/blocks → blocks}/section/component-info.js +13 -18
- package/dist/{sdk/blocks → blocks}/section/section.d.ts +3 -2
- package/dist/{sdk/blocks → blocks}/section/section.js +1 -1
- package/dist/blocks/select/component-info.d.ts +2 -0
- package/dist/{sdk/blocks → blocks}/select/component-info.js +22 -34
- package/dist/{sdk/blocks → blocks}/select/select.d.ts +3 -2
- package/dist/{sdk/blocks → blocks}/select/select.js +1 -1
- package/dist/blocks/submit-button/component-info.d.ts +2 -0
- package/dist/{sdk/blocks → blocks}/submit-button/component-info.js +5 -7
- package/dist/{sdk/blocks → blocks}/submit-button/submit-button.d.ts +3 -2
- package/dist/{sdk/blocks → blocks}/submit-button/submit-button.js +1 -1
- package/dist/blocks/symbol/component-info.d.ts +2 -0
- package/dist/{sdk/blocks → blocks}/symbol/component-info.js +12 -17
- package/dist/blocks/symbol/symbol.d.ts +23 -0
- package/dist/blocks/symbol/symbol.helpers.d.ts +14 -0
- package/dist/blocks/symbol/symbol.helpers.js +31 -0
- package/dist/blocks/symbol/symbol.js +45 -0
- package/dist/blocks/text/component-info.d.ts +2 -0
- package/dist/{sdk/blocks → blocks}/text/component-info.js +6 -7
- package/dist/{sdk/blocks → blocks}/text/text.d.ts +0 -1
- package/dist/{sdk/blocks → blocks}/text/text.js +2 -2
- package/dist/blocks/textarea/component-info.d.ts +2 -0
- package/dist/{sdk/blocks → blocks}/textarea/component-info.js +13 -19
- package/dist/{sdk/blocks → blocks}/textarea/textarea.d.ts +3 -2
- package/dist/{sdk/blocks → blocks}/textarea/textarea.js +1 -1
- package/dist/blocks/video/component-info.d.ts +2 -0
- package/dist/{sdk/blocks → blocks}/video/component-info.js +35 -55
- package/dist/{sdk/blocks → blocks}/video/video.d.ts +1 -1
- package/dist/{sdk/blocks → blocks}/video/video.js +2 -2
- package/dist/{sdk/components → components}/block/block.d.ts +2 -4
- package/dist/components/block/block.helpers.d.ts +13 -0
- package/dist/{sdk/components → components}/block/block.helpers.js +12 -29
- package/dist/components/block/block.js +94 -0
- package/dist/{sdk/components → components}/block/components/block-styles.d.ts +0 -1
- package/dist/{sdk/components → components}/block/components/block-styles.js +1 -1
- package/dist/components/block/components/block-wrapper.d.ts +16 -0
- package/dist/components/block/components/block-wrapper.js +36 -0
- package/dist/components/block/components/component-ref/component-ref.d.ts +3 -0
- package/dist/components/block/components/component-ref/component-ref.helpers.d.ts +28 -0
- package/dist/components/block/components/component-ref/component-ref.helpers.js +22 -0
- package/dist/components/block/components/component-ref/component-ref.js +23 -0
- package/dist/components/block/components/interactive-element.d.ts +11 -0
- package/dist/components/block/components/interactive-element.js +20 -0
- package/dist/components/block/components/repeated-block.d.ts +9 -0
- package/dist/{sdk/components → components}/block/components/repeated-block.js +3 -3
- package/dist/{sdk/components → components}/blocks/blocks-wrapper.d.ts +2 -5
- package/dist/{sdk/components → components}/blocks/blocks-wrapper.js +3 -3
- package/dist/components/blocks/blocks.d.ts +8 -0
- package/dist/{sdk/components → components}/blocks/blocks.js +9 -3
- package/dist/components/content/components/enable-editor.d.ts +9 -0
- package/dist/{sdk/components → components}/content/components/enable-editor.js +31 -39
- package/dist/{sdk/components/content/components/content-styles.d.ts → components/content/components/styles.d.ts} +1 -2
- package/dist/{sdk/components/content/components/content-styles.helpers.d.ts → components/content/components/styles.helpers.d.ts} +1 -1
- package/dist/{sdk/components/content/components/content-styles.helpers.js → components/content/components/styles.helpers.js} +3 -4
- package/dist/{sdk/components/content/components/content-styles.js → components/content/components/styles.js} +3 -3
- package/dist/components/content/content.d.ts +3 -0
- package/dist/components/content/content.helpers.d.ts +7 -0
- package/dist/components/content/content.helpers.js +30 -0
- package/dist/{sdk/components → components}/content/content.js +26 -40
- package/dist/{sdk/components/render-content/render-content.types.d.ts → components/content/content.types.d.ts} +4 -4
- package/dist/components/content-variants/content-variants.d.ts +9 -0
- package/dist/{sdk/components/render-content-variants/render-content-variants.js → components/content-variants/content-variants.js} +23 -22
- package/dist/{sdk/components/render-content-variants/render-content-variants.types.d.ts → components/content-variants/content-variants.types.d.ts} +5 -5
- package/dist/{sdk/components/render-content-variants → components/content-variants}/helpers.d.ts +7 -7
- package/dist/{sdk/components/render-content-variants → components/content-variants}/helpers.js +13 -22
- package/dist/{sdk/components → components}/inlined-script.d.ts +0 -1
- package/dist/{sdk/components → components}/inlined-script.js +1 -1
- package/dist/{sdk/components → components}/inlined-styles.d.ts +0 -1
- package/dist/{sdk/components → components}/inlined-styles.js +1 -1
- package/dist/{sdk/constants → constants}/builder-registered-components.js +34 -13
- package/dist/{sdk/constants → constants}/device-sizes.js +9 -8
- package/dist/constants/sdk-version.d.ts +1 -0
- package/dist/constants/sdk-version.js +1 -0
- package/dist/{sdk/context → context}/builder.context.js +1 -1
- package/dist/context/components.context.d.ts +3 -0
- package/dist/context/components.context.js +2 -0
- package/dist/{sdk/context → context}/types.d.ts +1 -1
- package/dist/functions/acorn_interpreter.d.ts +1 -0
- package/dist/functions/acorn_interpreter.js +3027 -0
- package/dist/functions/apply-patch-with-mutation.d.ts +10 -0
- package/dist/functions/apply-patch-with-mutation.js +54 -0
- package/dist/functions/apply-patch-with-mutation.test.js +53 -0
- package/dist/functions/evaluate/acorn.d.ts +0 -0
- package/dist/functions/evaluate/acorn.js +2432 -0
- package/dist/{sdk/functions → functions/evaluate}/evaluate.d.ts +5 -2
- package/dist/functions/evaluate/evaluate.js +70 -0
- package/dist/functions/evaluate/evaluate.test.js +23 -0
- package/dist/functions/evaluate/index.d.ts +1 -0
- package/dist/functions/evaluate/index.js +1 -0
- package/dist/functions/evaluate/interpreter.d.ts +2 -0
- package/dist/functions/evaluate/interpreter.js +3853 -0
- package/dist/functions/evaluate/non-node-runtime.d.ts +2 -0
- package/dist/functions/evaluate/non-node-runtime.js +84 -0
- package/dist/functions/evaluate/types.d.ts +10 -0
- package/dist/functions/evaluate.d.ts +23 -0
- package/dist/{sdk/functions → functions}/evaluate.js +28 -9
- package/dist/{sdk/functions → functions}/evaluate.test.js +11 -5
- package/dist/{sdk/functions → functions}/extract-text-styles.js +2 -14
- package/dist/{sdk/functions → functions}/get-block-actions-handler.js +3 -3
- package/dist/{sdk/functions → functions}/get-block-actions.d.ts +1 -0
- package/dist/functions/get-block-actions.js +28 -0
- package/dist/{sdk/functions → functions}/get-block-component-options.js +1 -1
- package/dist/functions/get-block-properties.d.ts +6 -0
- package/dist/{sdk/functions → functions}/get-block-properties.js +15 -9
- package/dist/{sdk/functions → functions}/get-builder-search-params/fn.test.js +1 -1
- package/dist/{sdk/functions → functions}/get-builder-search-params/index.js +3 -7
- package/dist/{sdk/functions → functions}/get-content/generate-content-url.js +7 -5
- package/dist/{sdk/functions → functions}/get-content/generate-content-url.test.js +31 -17
- package/dist/{sdk/functions → functions}/get-content/index.d.ts +2 -6
- package/dist/{sdk/functions → functions}/get-content/index.js +26 -6
- package/dist/functions/get-content/processCookies.d.ts +2 -0
- package/dist/functions/get-content/processCookies.js +3 -0
- package/dist/{sdk/functions → functions}/get-processed-block.d.ts +1 -1
- package/dist/{sdk/functions → functions}/get-processed-block.js +11 -7
- package/dist/{sdk/functions → functions}/get-processed-block.test.js +8 -6
- package/dist/{sdk/functions → functions}/get-react-native-block-styles.d.ts +1 -1
- package/dist/{sdk/functions → functions}/get-react-native-block-styles.js +2 -2
- package/dist/{sdk/functions → functions}/if-target.d.ts +1 -1
- package/dist/{sdk/functions → functions}/if-target.js +1 -1
- package/dist/functions/is-editing.js +5 -0
- package/dist/functions/is-non-node-server.d.ts +4 -0
- package/dist/functions/is-non-node-server.js +8 -0
- package/dist/{sdk/functions → functions}/on-change.js +1 -1
- package/dist/{sdk/functions → functions}/on-change.test.js +13 -3
- package/dist/{sdk/functions → functions}/register-component.d.ts +2 -1
- package/dist/functions/register-component.js +38 -0
- package/dist/{sdk/functions → functions}/register.js +2 -2
- package/dist/{sdk/functions → functions}/sanitize-react-native-block-styles.js +13 -5
- package/dist/{sdk/functions → functions}/set-editor-settings.js +1 -1
- package/dist/functions/set.js +14 -0
- package/dist/{sdk/functions → functions}/set.test.js +9 -3
- package/dist/{sdk/functions → functions}/track/helpers.js +6 -11
- package/dist/{sdk/functions → functions}/track/index.js +26 -14
- package/dist/{sdk/functions → functions}/track/interaction.js +15 -16
- package/dist/functions/transform-block-properties.d.ts +1 -0
- package/dist/{sdk/functions → functions}/transform-block-properties.js +2 -0
- package/dist/{sdk/helpers → helpers}/ab-tests.d.ts +2 -2
- package/dist/{sdk/helpers → helpers}/ab-tests.js +42 -30
- package/dist/{sdk/helpers → helpers}/canTrack.js +1 -1
- package/dist/{sdk/helpers → helpers}/cookie.d.ts +2 -2
- package/dist/{sdk/helpers → helpers}/cookie.js +13 -26
- package/dist/{sdk/helpers → helpers}/css.d.ts +1 -1
- package/dist/{sdk/helpers → helpers}/css.js +1 -1
- package/dist/{sdk/helpers → helpers}/flatten.js +8 -8
- package/dist/{sdk/helpers → helpers}/localStorage.d.ts +2 -2
- package/dist/{sdk/helpers → helpers}/localStorage.js +2 -2
- package/dist/{sdk/helpers → helpers}/logger.js +1 -1
- package/dist/helpers/preview-lru-cache/get.d.ts +1 -0
- package/dist/helpers/preview-lru-cache/get.js +7 -0
- package/dist/helpers/preview-lru-cache/helpers.d.ts +1 -0
- package/dist/helpers/preview-lru-cache/helpers.js +9 -0
- package/dist/helpers/preview-lru-cache/init.d.ts +6 -0
- package/dist/helpers/preview-lru-cache/init.js +15 -0
- package/dist/helpers/preview-lru-cache/set.d.ts +7 -0
- package/dist/helpers/preview-lru-cache/set.js +9 -0
- package/dist/helpers/preview-lru-cache/types.d.ts +12 -0
- package/dist/helpers/preview-lru-cache/types.js +6 -0
- package/dist/{sdk/helpers → helpers}/sessionId.d.ts +2 -2
- package/dist/{sdk/helpers → helpers}/sessionId.js +11 -4
- package/dist/{sdk/helpers → helpers}/uuid.js +1 -1
- package/dist/{sdk/helpers → helpers}/visitorId.d.ts +1 -1
- package/dist/{sdk/helpers → helpers}/visitorId.js +7 -4
- package/dist/{sdk/index-helpers → index-helpers}/blocks-exports.d.ts +2 -2
- package/dist/{sdk/index-helpers → index-helpers}/blocks-exports.js +2 -2
- package/dist/{sdk/index.d.ts → index.d.ts} +2 -2
- package/dist/{sdk/index.js → index.js} +1 -1
- package/dist/scripts/init-editing.js +110 -0
- package/dist/types/builder-props.d.ts +9 -0
- package/dist/{sdk/types → types}/components.d.ts +8 -2
- package/dist/{sdk/types → types}/enforced-partials.d.ts +1 -1
- package/dist/types/targets.d.ts +1 -0
- package/dist/{sdk/types → types}/typescript.d.ts +3 -0
- package/package.json +8 -16
- package/server/package.json +5 -0
- package/dist/sdk/blocks/button/component-info.d.ts +0 -2
- package/dist/sdk/blocks/columns/columns.d.ts +0 -16
- package/dist/sdk/blocks/columns/component-info.d.ts +0 -2
- package/dist/sdk/blocks/custom-code/component-info.d.ts +0 -2
- package/dist/sdk/blocks/embed/component-info.d.ts +0 -2
- package/dist/sdk/blocks/embed/helpers.js +0 -6
- package/dist/sdk/blocks/form/component-info.d.ts +0 -2
- package/dist/sdk/blocks/form/form.d.ts +0 -40
- package/dist/sdk/blocks/form/form.js +0 -203
- package/dist/sdk/blocks/fragment/component-info.d.ts +0 -2
- package/dist/sdk/blocks/image/component-info.d.ts +0 -2
- package/dist/sdk/blocks/img/component-info.d.ts +0 -2
- package/dist/sdk/blocks/input/component-info.d.ts +0 -2
- package/dist/sdk/blocks/raw-text/component-info.d.ts +0 -2
- package/dist/sdk/blocks/raw-text/raw-text.js +0 -6
- package/dist/sdk/blocks/section/component-info.d.ts +0 -2
- package/dist/sdk/blocks/select/component-info.d.ts +0 -2
- package/dist/sdk/blocks/submit-button/component-info.d.ts +0 -2
- package/dist/sdk/blocks/symbol/component-info.d.ts +0 -2
- package/dist/sdk/blocks/symbol/symbol.d.ts +0 -21
- package/dist/sdk/blocks/symbol/symbol.js +0 -71
- package/dist/sdk/blocks/text/component-info.d.ts +0 -2
- package/dist/sdk/blocks/textarea/component-info.d.ts +0 -2
- package/dist/sdk/blocks/util.d.ts +0 -4
- package/dist/sdk/blocks/util.js +0 -13
- package/dist/sdk/blocks/video/component-info.d.ts +0 -2
- package/dist/sdk/components/block/block.helpers.d.ts +0 -12
- package/dist/sdk/components/block/block.js +0 -124
- package/dist/sdk/components/block/components/component.d.ts +0 -20
- package/dist/sdk/components/block/components/component.js +0 -11
- package/dist/sdk/components/block/components/repeated-block.d.ts +0 -11
- package/dist/sdk/components/blocks/blocks.d.ts +0 -10
- package/dist/sdk/components/content/components/enable-editor.d.ts +0 -13
- package/dist/sdk/components/content/content.d.ts +0 -4
- package/dist/sdk/components/content/content.helpers.d.ts +0 -7
- package/dist/sdk/components/content/content.helpers.js +0 -30
- package/dist/sdk/components/content/content.types.d.ts +0 -38
- package/dist/sdk/components/content-variants/content-variants.d.ts +0 -5
- package/dist/sdk/components/content-variants/content-variants.js +0 -37
- package/dist/sdk/components/content-variants/helpers.d.ts +0 -17
- package/dist/sdk/components/content-variants/helpers.js +0 -184
- package/dist/sdk/components/render-block/block-styles.d.ts +0 -9
- package/dist/sdk/components/render-block/block-styles.js +0 -66
- package/dist/sdk/components/render-block/render-block.d.ts +0 -9
- package/dist/sdk/components/render-block/render-block.helpers.d.ts +0 -12
- package/dist/sdk/components/render-block/render-block.helpers.js +0 -86
- package/dist/sdk/components/render-block/render-block.js +0 -115
- package/dist/sdk/components/render-block/render-component.d.ts +0 -17
- package/dist/sdk/components/render-block/render-component.js +0 -11
- package/dist/sdk/components/render-block/render-repeated-block.d.ts +0 -9
- package/dist/sdk/components/render-block/render-repeated-block.js +0 -11
- package/dist/sdk/components/render-block/types.d.ts +0 -6
- package/dist/sdk/components/render-blocks.d.ts +0 -10
- package/dist/sdk/components/render-blocks.js +0 -45
- package/dist/sdk/components/render-content/builder-editing.d.ts +0 -3
- package/dist/sdk/components/render-content/builder-editing.js +0 -6
- package/dist/sdk/components/render-content/components/render-styles.d.ts +0 -9
- package/dist/sdk/components/render-content/components/render-styles.helpers.d.ts +0 -15
- package/dist/sdk/components/render-content/components/render-styles.helpers.js +0 -59
- package/dist/sdk/components/render-content/components/render-styles.js +0 -32
- package/dist/sdk/components/render-content/index.d.ts +0 -1
- package/dist/sdk/components/render-content/index.js +0 -1
- package/dist/sdk/components/render-content/render-content.d.ts +0 -4
- package/dist/sdk/components/render-content/render-content.helpers.d.ts +0 -7
- package/dist/sdk/components/render-content/render-content.helpers.js +0 -30
- package/dist/sdk/components/render-content/render-content.js +0 -343
- package/dist/sdk/components/render-content/wrap-component-ref.d.ts +0 -6
- package/dist/sdk/components/render-content/wrap-component-ref.js +0 -6
- package/dist/sdk/components/render-content-variants/render-content-variants.d.ts +0 -10
- package/dist/sdk/components/render-inlined-styles.d.ts +0 -7
- package/dist/sdk/components/render-inlined-styles.js +0 -6
- package/dist/sdk/constants/sdk-version.d.ts +0 -1
- package/dist/sdk/constants/sdk-version.js +0 -1
- package/dist/sdk/functions/get-block-actions.js +0 -15
- package/dist/sdk/functions/get-block-properties.d.ts +0 -7
- package/dist/sdk/functions/get-content/ab-testing.d.ts +0 -5
- package/dist/sdk/functions/get-content/ab-testing.js +0 -78
- package/dist/sdk/functions/is-editing.js +0 -7
- package/dist/sdk/functions/register-component.js +0 -26
- package/dist/sdk/functions/set.js +0 -21
- package/dist/sdk/functions/transform-block-properties.d.ts +0 -1
- package/dist/sdk/scripts/init-editing.js +0 -102
- package/dist/sdk/types/builder-props.d.ts +0 -10
- package/dist/sdk/types/targets.d.ts +0 -3
- package/dist/server/functions/get-builder-search-params/index.d.ts +0 -6
- package/dist/server/functions/get-builder-search-params/index.js +0 -36
- package/dist/server/functions/get-content/ab-testing.d.ts +0 -5
- package/dist/server/functions/get-content/ab-testing.js +0 -78
- package/dist/server/functions/get-content/generate-content-url.d.ts +0 -2
- package/dist/server/functions/get-content/generate-content-url.js +0 -31
- package/dist/server/functions/get-content/generate-content-url.test.d.ts +0 -1
- package/dist/server/functions/get-content/generate-content-url.test.js +0 -82
- package/dist/server/functions/get-content/index.d.ts +0 -11
- package/dist/server/functions/get-content/index.js +0 -40
- package/dist/server/functions/get-content/types.d.ts +0 -45
- package/dist/server/functions/get-fetch.d.ts +0 -1
- package/dist/server/functions/get-fetch.js +0 -11
- package/dist/server/functions/get-global-this.d.ts +0 -4
- package/dist/server/functions/get-global-this.js +0 -15
- package/dist/server/functions/is-browser.d.ts +0 -1
- package/dist/server/functions/is-browser.js +0 -3
- package/dist/server/helpers/ab-tests.d.ts +0 -8
- package/dist/server/helpers/ab-tests.js +0 -5
- package/dist/server/helpers/cookie.d.ts +0 -15
- package/dist/server/helpers/cookie.js +0 -65
- package/dist/server/helpers/flatten.d.ts +0 -6
- package/dist/server/helpers/flatten.js +0 -19
- package/dist/server/helpers/logger.d.ts +0 -5
- package/dist/server/helpers/logger.js +0 -6
- package/dist/server/helpers/nullable.d.ts +0 -2
- package/dist/server/helpers/nullable.js +0 -1
- package/dist/server/helpers/url.d.ts +0 -6
- package/dist/server/helpers/url.js +0 -15
- package/dist/server/types/api-version.d.ts +0 -2
- package/dist/server/types/api-version.js +0 -1
- package/dist/server/types/builder-block.d.ts +0 -66
- package/dist/server/types/builder-block.js +0 -1
- package/dist/server/types/builder-content.d.ts +0 -46
- package/dist/server/types/builder-content.js +0 -1
- package/dist/server/types/can-track.d.ts +0 -3
- package/dist/server/types/can-track.js +0 -1
- package/dist/server/types/input.d.ts +0 -121
- package/dist/server/types/input.js +0 -1
- package/dist/server/types/typescript.d.ts +0 -5
- package/dist/server/types/typescript.js +0 -1
- /package/dist/{sdk/blocks → blocks}/embed/helpers.d.ts +0 -0
- /package/dist/{sdk/blocks → blocks}/image/image.helpers.d.ts +0 -0
- /package/dist/{sdk/components → components}/block/types.d.ts +0 -0
- /package/dist/{sdk/components → components}/block/types.js +0 -0
- /package/dist/{sdk/components/render-block/types.js → components/content/content.types.js} +0 -0
- /package/dist/{sdk/components → components}/content/index.d.ts +0 -0
- /package/dist/{sdk/components → components}/content/index.js +0 -0
- /package/dist/{sdk/components → components}/content/wrap-component-ref.d.ts +0 -0
- /package/dist/{sdk/components → components}/content/wrap-component-ref.js +0 -0
- /package/dist/{sdk/components/content/content.types.js → components/content-variants/content-variants.types.js} +0 -0
- /package/dist/{sdk/constants → constants}/builder-registered-components.d.ts +0 -0
- /package/dist/{sdk/constants → constants}/device-sizes.d.ts +0 -0
- /package/dist/{sdk/constants → constants}/target.d.ts +0 -0
- /package/dist/{sdk/constants → constants}/target.js +0 -0
- /package/dist/{sdk/context → context}/builder.context.d.ts +0 -0
- /package/dist/{sdk/context → context}/types.js +0 -0
- /package/dist/{sdk/components/render-content-variants/render-content-variants.types.js → functions/apply-patch-with-mutation.test.d.ts} +0 -0
- /package/dist/{sdk/functions → functions}/camel-to-kebab-case.d.ts +0 -0
- /package/dist/{sdk/functions → functions}/camel-to-kebab-case.js +0 -0
- /package/dist/{sdk/components/render-content/render-content.types.js → functions/evaluate/evaluate.test.d.ts} +0 -0
- /package/dist/{sdk/functions/get-content → functions/evaluate}/types.js +0 -0
- /package/dist/{sdk/functions → functions}/evaluate.test.d.ts +0 -0
- /package/dist/{sdk/functions → functions}/event-handler-name.d.ts +0 -0
- /package/dist/{sdk/functions → functions}/event-handler-name.js +0 -0
- /package/dist/{sdk/functions → functions}/extract-text-styles.d.ts +0 -0
- /package/dist/{sdk/functions → functions}/fast-clone.d.ts +0 -0
- /package/dist/{sdk/functions → functions}/fast-clone.js +0 -0
- /package/dist/{sdk/functions → functions}/get-block-actions-handler.d.ts +0 -0
- /package/dist/{sdk/functions → functions}/get-block-component-options.d.ts +0 -0
- /package/dist/{sdk/functions → functions}/get-builder-search-params/fn.test.d.ts +0 -0
- /package/dist/{sdk/functions → functions}/get-builder-search-params/index.d.ts +0 -0
- /package/dist/{sdk/functions → functions}/get-content/generate-content-url.d.ts +0 -0
- /package/dist/{sdk/functions → functions}/get-content/generate-content-url.test.d.ts +0 -0
- /package/dist/{sdk/functions → functions}/get-content/types.d.ts +0 -0
- /package/dist/{server/functions → functions}/get-content/types.js +0 -0
- /package/dist/{sdk/functions → functions}/get-fetch.d.ts +0 -0
- /package/dist/{sdk/functions → functions}/get-fetch.js +0 -0
- /package/dist/{sdk/functions → functions}/get-global-this.d.ts +0 -0
- /package/dist/{sdk/functions → functions}/get-global-this.js +0 -0
- /package/dist/{sdk/functions → functions}/get-processed-block.test.d.ts +0 -0
- /package/dist/{sdk/functions → functions}/is-browser.d.ts +0 -0
- /package/dist/{sdk/functions → functions}/is-browser.js +0 -0
- /package/dist/{sdk/functions → functions}/is-editing.d.ts +0 -0
- /package/dist/{sdk/functions → functions}/is-iframe.d.ts +0 -0
- /package/dist/{sdk/functions → functions}/is-iframe.js +0 -0
- /package/dist/{sdk/functions → functions}/is-previewing.d.ts +0 -0
- /package/dist/{sdk/functions → functions}/is-previewing.js +0 -0
- /package/dist/{sdk/functions → functions}/on-change.d.ts +0 -0
- /package/dist/{sdk/functions → functions}/on-change.test.d.ts +0 -0
- /package/dist/{sdk/functions → functions}/register.d.ts +0 -0
- /package/dist/{sdk/functions → functions}/sanitize-react-native-block-styles.d.ts +0 -0
- /package/dist/{sdk/functions → functions}/set-editor-settings.d.ts +0 -0
- /package/dist/{sdk/functions → functions}/set.d.ts +0 -0
- /package/dist/{sdk/functions → functions}/set.test.d.ts +0 -0
- /package/dist/{sdk/functions → functions}/track/helpers.d.ts +0 -0
- /package/dist/{sdk/functions → functions}/track/index.d.ts +0 -0
- /package/dist/{sdk/functions → functions}/track/interaction.d.ts +0 -0
- /package/dist/{sdk/functions → functions}/transform-block.d.ts +0 -0
- /package/dist/{sdk/functions → functions}/transform-block.js +0 -0
- /package/dist/{sdk/helpers → helpers}/canTrack.d.ts +0 -0
- /package/dist/{sdk/helpers → helpers}/flatten.d.ts +0 -0
- /package/dist/{sdk/helpers → helpers}/logger.d.ts +0 -0
- /package/dist/{sdk/helpers → helpers}/nullable.d.ts +0 -0
- /package/dist/{sdk/helpers → helpers}/nullable.js +0 -0
- /package/dist/{sdk/helpers → helpers}/time.d.ts +0 -0
- /package/dist/{sdk/helpers → helpers}/time.js +0 -0
- /package/dist/{sdk/helpers → helpers}/url.d.ts +0 -0
- /package/dist/{sdk/helpers → helpers}/url.js +0 -0
- /package/dist/{sdk/helpers → helpers}/url.test.d.ts +0 -0
- /package/dist/{sdk/helpers → helpers}/url.test.js +0 -0
- /package/dist/{sdk/helpers → helpers}/uuid.d.ts +0 -0
- /package/dist/{sdk/index-helpers → index-helpers}/top-of-file.d.ts +0 -0
- /package/dist/{sdk/index-helpers → index-helpers}/top-of-file.js +0 -0
- /package/dist/{sdk/scripts → scripts}/init-editing.d.ts +0 -0
- /package/dist/{sdk/types → types}/api-version.d.ts +0 -0
- /package/dist/{sdk/types → types}/api-version.js +0 -0
- /package/dist/{sdk/types → types}/builder-block.d.ts +0 -0
- /package/dist/{sdk/types → types}/builder-block.js +0 -0
- /package/dist/{sdk/types → types}/builder-content.d.ts +0 -0
- /package/dist/{sdk/types → types}/builder-content.js +0 -0
- /package/dist/{sdk/types → types}/builder-props.js +0 -0
- /package/dist/{sdk/types → types}/can-track.d.ts +0 -0
- /package/dist/{sdk/types → types}/can-track.js +0 -0
- /package/dist/{sdk/types → types}/components.js +0 -0
- /package/dist/{sdk/types → types}/deep-partial.d.ts +0 -0
- /package/dist/{sdk/types → types}/deep-partial.js +0 -0
- /package/dist/{sdk/types → types}/element.d.ts +0 -0
- /package/dist/{sdk/types → types}/element.js +0 -0
- /package/dist/{sdk/types → types}/enforced-partials.js +0 -0
- /package/dist/{sdk/types → types}/input.d.ts +0 -0
- /package/dist/{sdk/types → types}/input.js +0 -0
- /package/dist/{sdk/types → types}/targets.js +0 -0
- /package/dist/{sdk/types → types}/typescript.js +0 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
type Props = {
|
|
2
|
+
block: BuilderBlock;
|
|
3
|
+
repeatContext: BuilderContextInterface;
|
|
4
|
+
registeredComponents: RegisteredComponents;
|
|
5
|
+
};
|
|
6
|
+
import type { BuilderContextInterface, RegisteredComponents } from "../../../context/types.js";
|
|
7
|
+
import type { BuilderBlock } from "../../../types/builder-block.js";
|
|
8
|
+
declare function RepeatedBlock(props: Props): JSX.Element;
|
|
9
|
+
export default RepeatedBlock;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
"use client";
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import { useState } from "react";
|
|
4
|
-
import BuilderContext from "../../../context/builder.context
|
|
4
|
+
import BuilderContext from "../../../context/builder.context";
|
|
5
5
|
import Block from "../block";
|
|
6
6
|
function RepeatedBlock(props) {
|
|
7
7
|
const [store, setStore] = useState(() => props.repeatContext);
|
|
8
8
|
return (React.createElement(BuilderContext.Provider, { value: store },
|
|
9
|
-
React.createElement(Block, { block: props.block, context: store,
|
|
9
|
+
React.createElement(Block, { block: props.block, context: store, registeredComponents: props.registeredComponents })));
|
|
10
10
|
}
|
|
11
11
|
export default RepeatedBlock;
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
export type BlocksWrapperProps = {
|
|
3
2
|
blocks: BuilderBlock[] | undefined;
|
|
4
3
|
parent: string | undefined;
|
|
5
4
|
path: string | undefined;
|
|
6
5
|
styleProp: Record<string, any> | undefined;
|
|
7
6
|
};
|
|
8
|
-
type PropsWithChildren = BlocksWrapperProps & {
|
|
9
|
-
children?: any;
|
|
10
|
-
};
|
|
11
7
|
import type { BuilderBlock } from "../../types/builder-block.js";
|
|
12
|
-
|
|
8
|
+
import type { PropsWithChildren } from "../../types/typescript.js";
|
|
9
|
+
declare function BlocksWrapper(props: PropsWithChildren<BlocksWrapperProps>): JSX.Element;
|
|
13
10
|
export default BlocksWrapper;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
"use client";
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import { isEditing } from "../../functions/is-editing.js";
|
|
4
4
|
function BlocksWrapper(props) {
|
|
@@ -28,8 +28,8 @@ function BlocksWrapper(props) {
|
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
return (React.createElement(React.Fragment, null,
|
|
31
|
-
React.createElement("div", { className: className() + " div-
|
|
32
|
-
React.createElement("style", null, `.div-
|
|
31
|
+
React.createElement("div", { className: className() + " div-b2473120", "builder-path": props.path, "builder-parent-id": props.parent, style: props.styleProp, onClick: (event) => onClick(), onMouseEnter: (event) => onMouseEnter(), onKeyPress: (event) => onClick() }, props.children),
|
|
32
|
+
React.createElement("style", null, `.div-b2473120 {
|
|
33
33
|
display: flex;
|
|
34
34
|
flex-direction: column;
|
|
35
35
|
align-items: stretch;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type BlocksProps = Partial<BlocksWrapperProps> & {
|
|
2
|
+
context?: BuilderContextInterface;
|
|
3
|
+
registeredComponents?: RegisteredComponents;
|
|
4
|
+
};
|
|
5
|
+
import type { BlocksWrapperProps } from "./blocks-wrapper";
|
|
6
|
+
import type { BuilderContextInterface, RegisteredComponents } from "../../context/types.js";
|
|
7
|
+
declare function Blocks(props: BlocksProps): JSX.Element;
|
|
8
|
+
export default Blocks;
|
|
@@ -1,11 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
"use client";
|
|
2
2
|
import * as React from "react";
|
|
3
|
+
import { useContext } from "react";
|
|
3
4
|
import BlockStyles from "../block/components/block-styles";
|
|
4
5
|
import Block from "../block/block";
|
|
5
6
|
import BlocksWrapper from "./blocks-wrapper";
|
|
7
|
+
import BuilderContext from "../../context/builder.context";
|
|
8
|
+
import ComponentsContext from "../../context/components.context";
|
|
6
9
|
function Blocks(props) {
|
|
10
|
+
const builderContext = useContext(BuilderContext);
|
|
11
|
+
const componentsContext = useContext(ComponentsContext);
|
|
7
12
|
return (React.createElement(BlocksWrapper, { blocks: props.blocks, parent: props.parent, path: props.path, styleProp: props.styleProp },
|
|
8
|
-
props.blocks ? (React.createElement(React.Fragment, null, props.blocks?.map((block) => (React.createElement(Block, { key: "render-block-" + block.id, block: block, context: props.context,
|
|
9
|
-
|
|
13
|
+
props.blocks ? (React.createElement(React.Fragment, null, props.blocks?.map((block) => (React.createElement(Block, { key: "render-block-" + block.id, block: block, context: props.context || builderContext, registeredComponents: props.registeredComponents ||
|
|
14
|
+
componentsContext.registeredComponents }))))) : null,
|
|
15
|
+
props.blocks ? (React.createElement(React.Fragment, null, props.blocks?.map((block) => (React.createElement(BlockStyles, { key: "block-style-" + block.id, block: block, context: props.context || builderContext }))))) : null));
|
|
10
16
|
}
|
|
11
17
|
export default Blocks;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
type BuilderEditorProps = Omit<ContentProps, "customComponents" | "data" | "apiVersion" | "isSsrAbTest"> & {
|
|
2
|
+
builderContextSignal: BuilderContextInterface;
|
|
3
|
+
setBuilderContextSignal?: (signal: any) => any;
|
|
4
|
+
children?: any;
|
|
5
|
+
};
|
|
6
|
+
import type { BuilderContextInterface } from "../../../context/types.js";
|
|
7
|
+
import type { ContentProps } from "../content.types.js";
|
|
8
|
+
declare function EnableEditor(props: BuilderEditorProps): JSX.Element;
|
|
9
|
+
export default EnableEditor;
|
|
@@ -1,43 +1,45 @@
|
|
|
1
|
-
|
|
1
|
+
"use client";
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import { useState, useRef, useEffect } from "react";
|
|
4
|
-
import { evaluate } from "../../../functions/evaluate
|
|
5
|
-
import { getContent } from "../../../functions/get-content/index.js";
|
|
4
|
+
import { evaluate } from "../../../functions/evaluate";
|
|
6
5
|
import { fetch } from "../../../functions/get-fetch.js";
|
|
7
6
|
import { isBrowser } from "../../../functions/is-browser.js";
|
|
8
7
|
import { isEditing } from "../../../functions/is-editing.js";
|
|
9
|
-
import { isPreviewing } from "../../../functions/is-previewing.js";
|
|
10
8
|
import { createRegisterComponentMessage } from "../../../functions/register-component.js";
|
|
11
9
|
import { _track } from "../../../functions/track/index.js";
|
|
12
|
-
import builderContext from "../../../context/builder.context
|
|
10
|
+
import builderContext from "../../../context/builder.context";
|
|
13
11
|
import { registerInsertMenu, setupBrowserForEditing, } from "../../../scripts/init-editing.js";
|
|
14
12
|
import { checkIsDefined } from "../../../helpers/nullable.js";
|
|
15
13
|
import { getInteractionPropertiesForEvent } from "../../../functions/track/interaction.js";
|
|
16
|
-
import { TARGET } from "../../../constants/target.js";
|
|
17
14
|
import { logger } from "../../../helpers/logger.js";
|
|
15
|
+
import { getContent } from "../../../functions/get-content/index.js";
|
|
16
|
+
import { isPreviewing } from "../../../functions/is-previewing.js";
|
|
18
17
|
function EnableEditor(props) {
|
|
19
18
|
const elementRef = useRef(null);
|
|
19
|
+
const [canTrackToUse, setCanTrackToUse] = useState(() => checkIsDefined(props.canTrack) ? props.canTrack : true);
|
|
20
20
|
const [forceReRenderCount, setForceReRenderCount] = useState(() => 0);
|
|
21
21
|
function mergeNewContent(newContent) {
|
|
22
|
+
const newContentValue = {
|
|
23
|
+
...props.builderContextSignal.content,
|
|
24
|
+
...newContent,
|
|
25
|
+
data: {
|
|
26
|
+
...props.builderContextSignal.content?.data,
|
|
27
|
+
...newContent?.data,
|
|
28
|
+
},
|
|
29
|
+
meta: {
|
|
30
|
+
...props.builderContextSignal.content?.meta,
|
|
31
|
+
...newContent?.meta,
|
|
32
|
+
breakpoints: newContent?.meta?.breakpoints ||
|
|
33
|
+
props.builderContextSignal.content?.meta?.breakpoints,
|
|
34
|
+
},
|
|
35
|
+
};
|
|
22
36
|
props.setBuilderContextSignal((PREVIOUS_VALUE) => ({
|
|
23
37
|
...PREVIOUS_VALUE,
|
|
24
|
-
content:
|
|
25
|
-
...props.builderContextSignal.content,
|
|
26
|
-
...newContent,
|
|
27
|
-
data: {
|
|
28
|
-
...props.builderContextSignal.content?.data,
|
|
29
|
-
...newContent?.data,
|
|
30
|
-
},
|
|
31
|
-
meta: {
|
|
32
|
-
...props.builderContextSignal.content?.meta,
|
|
33
|
-
...newContent?.meta,
|
|
34
|
-
breakpoints: newContent?.meta?.breakpoints ||
|
|
35
|
-
props.builderContextSignal.content?.meta?.breakpoints,
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
+
content: newContentValue,
|
|
38
39
|
}));
|
|
39
40
|
}
|
|
40
|
-
const [
|
|
41
|
+
const [lastUpdated, setLastUpdated] = useState(() => 0);
|
|
42
|
+
const [shouldSendResetCookie, setShouldSendResetCookie] = useState(() => false);
|
|
41
43
|
function processMessage(event) {
|
|
42
44
|
const { data } = event;
|
|
43
45
|
if (data) {
|
|
@@ -72,10 +74,6 @@ function EnableEditor(props) {
|
|
|
72
74
|
}
|
|
73
75
|
break;
|
|
74
76
|
}
|
|
75
|
-
case "builder.patchUpdates": {
|
|
76
|
-
// TODO
|
|
77
|
-
break;
|
|
78
|
-
}
|
|
79
77
|
}
|
|
80
78
|
}
|
|
81
79
|
}
|
|
@@ -167,6 +165,7 @@ function EnableEditor(props) {
|
|
|
167
165
|
if (isBrowser()) {
|
|
168
166
|
if (isEditing()) {
|
|
169
167
|
setForceReRenderCount(forceReRenderCount + 1);
|
|
168
|
+
window.addEventListener("message", processMessage);
|
|
170
169
|
registerInsertMenu();
|
|
171
170
|
setupBrowserForEditing({
|
|
172
171
|
...(props.locale
|
|
@@ -185,11 +184,10 @@ function EnableEditor(props) {
|
|
|
185
184
|
}
|
|
186
185
|
: {}),
|
|
187
186
|
});
|
|
188
|
-
Object.values(props.builderContextSignal.
|
|
187
|
+
Object.values(props.builderContextSignal.componentInfos).forEach((registeredComponent) => {
|
|
189
188
|
const message = createRegisterComponentMessage(registeredComponent);
|
|
190
189
|
window.parent?.postMessage(message, "*");
|
|
191
190
|
});
|
|
192
|
-
window.addEventListener("message", processMessage);
|
|
193
191
|
window.addEventListener("builder:component:stateChangeListenerActivated", emitStateUpdate);
|
|
194
192
|
}
|
|
195
193
|
if (props.builderContextSignal.content) {
|
|
@@ -222,7 +220,7 @@ function EnableEditor(props) {
|
|
|
222
220
|
getContent({
|
|
223
221
|
model: props.model,
|
|
224
222
|
apiKey: props.apiKey,
|
|
225
|
-
apiVersion: props.apiVersion,
|
|
223
|
+
apiVersion: props.builderContextSignal.apiVersion,
|
|
226
224
|
}).then((content) => {
|
|
227
225
|
if (content) {
|
|
228
226
|
mergeNewContent(content);
|
|
@@ -240,6 +238,7 @@ function EnableEditor(props) {
|
|
|
240
238
|
mergeNewContent(props.content);
|
|
241
239
|
}
|
|
242
240
|
}, [props.content]);
|
|
241
|
+
useEffect(() => { }, [shouldSendResetCookie]);
|
|
243
242
|
useEffect(() => {
|
|
244
243
|
evaluateJsCode();
|
|
245
244
|
}, [
|
|
@@ -261,18 +260,11 @@ function EnableEditor(props) {
|
|
|
261
260
|
};
|
|
262
261
|
}, []);
|
|
263
262
|
return (React.createElement(builderContext.Provider, { value: props.builderContextSignal }, props.builderContextSignal.content ? (React.createElement(React.Fragment, null,
|
|
264
|
-
React.createElement("div", { ref: elementRef, onClick: (event) => onClick(event), "builder-content-id": props.builderContextSignal.content?.id, "builder-model": props.model,
|
|
265
|
-
? {
|
|
266
|
-
|
|
267
|
-
// currently, we can't set the actual ID here. // we don't need it right now, we just need to identify content divs for testing.
|
|
268
|
-
"builder-content-id": "",
|
|
269
|
-
},
|
|
270
|
-
}
|
|
271
|
-
: {}), ...(props.hideContent
|
|
272
|
-
? {
|
|
263
|
+
React.createElement("div", { key: forceReRenderCount, ref: elementRef, onClick: (event) => onClick(event), "builder-content-id": props.builderContextSignal.content?.id, "builder-model": props.model, ...(props.showContent
|
|
264
|
+
? {}
|
|
265
|
+
: {
|
|
273
266
|
hidden: true,
|
|
274
267
|
"aria-hidden": true,
|
|
275
|
-
}
|
|
276
|
-
: {}), className: props.classNameProp }, props.children))) : null));
|
|
268
|
+
}), className: props.classNameProp }, props.children))) : null));
|
|
277
269
|
}
|
|
278
270
|
export default EnableEditor;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
interface Props {
|
|
3
2
|
cssCode?: string;
|
|
4
3
|
customFonts?: CustomFont[];
|
|
5
4
|
contentId?: string;
|
|
6
5
|
}
|
|
7
|
-
import type { CustomFont } from "./
|
|
6
|
+
import type { CustomFont } from "./styles.helpers.js";
|
|
8
7
|
declare function ContentStyles(props: Props): JSX.Element;
|
|
9
8
|
export default ContentStyles;
|
|
@@ -9,7 +9,7 @@ export interface CustomFont {
|
|
|
9
9
|
export declare const getFontCss: ({ customFonts }: {
|
|
10
10
|
customFonts?: CustomFont[];
|
|
11
11
|
}) => string;
|
|
12
|
-
export declare const getCss: ({ cssCode, contentId
|
|
12
|
+
export declare const getCss: ({ cssCode, contentId }: {
|
|
13
13
|
cssCode?: string;
|
|
14
14
|
contentId?: string;
|
|
15
15
|
}) => string;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
const getCssFromFont = (font) => {
|
|
2
2
|
// TODO: compute what font sizes are used and only load those.......
|
|
3
|
-
const family = font.family +
|
|
4
|
-
(font.kind && !font.kind.includes('#') ? ', ' + font.kind : '');
|
|
3
|
+
const family = font.family + (font.kind && !font.kind.includes('#') ? ', ' + font.kind : '');
|
|
5
4
|
const name = family.split(',')[0];
|
|
6
5
|
const url = font.fileUrl ?? font?.files?.regular;
|
|
7
6
|
let str = '';
|
|
@@ -43,9 +42,9 @@ export const getFontCss = ({ customFonts }) => {
|
|
|
43
42
|
// return '';
|
|
44
43
|
// }
|
|
45
44
|
// TODO: separate internal data from external
|
|
46
|
-
return customFonts?.map(
|
|
45
|
+
return customFonts?.map(font => getCssFromFont(font))?.join(' ') || '';
|
|
47
46
|
};
|
|
48
|
-
export const getCss = ({ cssCode, contentId
|
|
47
|
+
export const getCss = ({ cssCode, contentId }) => {
|
|
49
48
|
if (!cssCode) {
|
|
50
49
|
return '';
|
|
51
50
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
"use client";
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import { useState } from "react";
|
|
4
4
|
import InlinedStyles from "../../inlined-styles";
|
|
5
|
-
import { getCss } from "./
|
|
6
|
-
import { getFontCss } from "./
|
|
5
|
+
import { getCss } from "./styles.helpers.js";
|
|
6
|
+
import { getFontCss } from "./styles.helpers.js";
|
|
7
7
|
function ContentStyles(props) {
|
|
8
8
|
const [injectedStyles, setInjectedStyles] = useState(() => `
|
|
9
9
|
${getCss({
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { BuilderContent } from '../../types/builder-content.js';
|
|
2
|
+
import type { Nullable } from '../../types/typescript.js';
|
|
3
|
+
import type { ContentProps } from './content.types.js';
|
|
4
|
+
export declare const getContextStateInitialValue: ({ content, data, locale }: Pick<ContentProps, 'content' | 'data' | 'locale'>) => {
|
|
5
|
+
[x: string]: unknown;
|
|
6
|
+
};
|
|
7
|
+
export declare const getContentInitialValue: ({ content, data }: Pick<ContentProps, 'content' | 'data'>) => Nullable<BuilderContent>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export const getContextStateInitialValue = ({ content, data, locale }) => {
|
|
2
|
+
const defaultValues = {};
|
|
3
|
+
// set default values for content state inputs
|
|
4
|
+
content?.data?.inputs?.forEach(input => {
|
|
5
|
+
if (input.name && input.defaultValue !== undefined && content?.data?.state && content.data.state[input.name] === undefined) {
|
|
6
|
+
defaultValues[input.name] = input.defaultValue;
|
|
7
|
+
}
|
|
8
|
+
});
|
|
9
|
+
const stateToUse = {
|
|
10
|
+
...content?.data?.state,
|
|
11
|
+
...data,
|
|
12
|
+
...(locale ? {
|
|
13
|
+
locale
|
|
14
|
+
} : {})
|
|
15
|
+
};
|
|
16
|
+
return {
|
|
17
|
+
...defaultValues,
|
|
18
|
+
...stateToUse
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
export const getContentInitialValue = ({ content, data }) => {
|
|
22
|
+
return !content ? undefined : {
|
|
23
|
+
...content,
|
|
24
|
+
data: {
|
|
25
|
+
...content?.data,
|
|
26
|
+
...data
|
|
27
|
+
},
|
|
28
|
+
meta: content?.meta
|
|
29
|
+
};
|
|
30
|
+
};
|
|
@@ -1,20 +1,22 @@
|
|
|
1
|
-
|
|
1
|
+
"use client";
|
|
2
2
|
import * as React from "react";
|
|
3
|
-
import { useState
|
|
3
|
+
import { useState } from "react";
|
|
4
4
|
import { getDefaultRegisteredComponents } from "../../constants/builder-registered-components.js";
|
|
5
|
-
import { components } from "../../functions/register-component.js";
|
|
5
|
+
import { components, serializeComponentInfo, } from "../../functions/register-component.js";
|
|
6
6
|
import Blocks from "../blocks/blocks";
|
|
7
|
-
import ContentStyles from "./components/
|
|
7
|
+
import ContentStyles from "./components/styles";
|
|
8
8
|
import { getContentInitialValue, getContextStateInitialValue, } from "./content.helpers.js";
|
|
9
9
|
import { TARGET } from "../../constants/target.js";
|
|
10
10
|
import { getRenderContentScriptString } from "../content-variants/helpers.js";
|
|
11
|
-
import { wrapComponentRef } from "./wrap-component-ref.js";
|
|
12
11
|
import EnableEditor from "./components/enable-editor";
|
|
13
|
-
|
|
12
|
+
import InlinedScript from "../inlined-script";
|
|
13
|
+
import ComponentsContext from "../../context/components.context";
|
|
14
|
+
function ContentComponent(props) {
|
|
14
15
|
const [scriptStr, setScriptStr] = useState(() => getRenderContentScriptString({
|
|
16
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-non-null-asserted-optional-chain
|
|
17
|
+
variationId: props.content?.testVariationId,
|
|
15
18
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-non-null-asserted-optional-chain
|
|
16
19
|
contentId: props.content?.id,
|
|
17
|
-
parentContentId: props.parentContentId,
|
|
18
20
|
}));
|
|
19
21
|
function contentSetState(newRootState) {
|
|
20
22
|
setBuilderContextSignal((PREVIOUS_VALUE) => ({
|
|
@@ -22,7 +24,7 @@ function Content(props) {
|
|
|
22
24
|
rootState: newRootState,
|
|
23
25
|
}));
|
|
24
26
|
}
|
|
25
|
-
const [
|
|
27
|
+
const [registeredComponents, setRegisteredComponents] = useState(() => [
|
|
26
28
|
...getDefaultRegisteredComponents(),
|
|
27
29
|
// While this `components` object is deprecated, we must maintain support for it.
|
|
28
30
|
// Since users are able to override our default components, we need to make sure that we do not break such
|
|
@@ -31,20 +33,13 @@ function Content(props) {
|
|
|
31
33
|
// which is the new standard way of providing custom components, and must therefore take precedence.
|
|
32
34
|
...components,
|
|
33
35
|
...(props.customComponents || []),
|
|
34
|
-
].reduce((acc, info) => ({
|
|
36
|
+
].reduce((acc, { component, ...info }) => ({
|
|
35
37
|
...acc,
|
|
36
|
-
[info.name]:
|
|
38
|
+
[info.name]: {
|
|
39
|
+
component: component,
|
|
40
|
+
...serializeComponentInfo(info),
|
|
41
|
+
},
|
|
37
42
|
}), {}));
|
|
38
|
-
function customComponentsInfo() {
|
|
39
|
-
// TO-DO: fix once we remove `useStore<any>` hack in Qwik generator.
|
|
40
|
-
return Object.values(customComps).reduce((acc, { component: _, ...info }) => ({
|
|
41
|
-
...acc,
|
|
42
|
-
[info.name]: info,
|
|
43
|
-
}), {});
|
|
44
|
-
}
|
|
45
|
-
function tempContextSignalSetter() {
|
|
46
|
-
return setBuilderContextSignal;
|
|
47
|
-
}
|
|
48
43
|
const [builderContextSignal, setBuilderContextSignal] = useState(() => ({
|
|
49
44
|
content: getContentInitialValue({
|
|
50
45
|
content: props.content,
|
|
@@ -56,11 +51,11 @@ function Content(props) {
|
|
|
56
51
|
data: props.data,
|
|
57
52
|
locale: props.locale,
|
|
58
53
|
}),
|
|
59
|
-
rootSetState:
|
|
54
|
+
rootSetState: contentSetState,
|
|
60
55
|
context: props.context || {},
|
|
61
56
|
apiKey: props.apiKey,
|
|
62
57
|
apiVersion: props.apiVersion,
|
|
63
|
-
|
|
58
|
+
componentInfos: [
|
|
64
59
|
...getDefaultRegisteredComponents(),
|
|
65
60
|
// While this `components` object is deprecated, we must maintain support for it.
|
|
66
61
|
// Since users are able to override our default components, we need to make sure that we do not break such
|
|
@@ -69,29 +64,20 @@ function Content(props) {
|
|
|
69
64
|
// which is the new standard way of providing custom components, and must therefore take precedence.
|
|
70
65
|
...components,
|
|
71
66
|
...(props.customComponents || []),
|
|
72
|
-
].reduce((acc, { component, ...
|
|
67
|
+
].reduce((acc, { component: _, ...info }) => ({
|
|
73
68
|
...acc,
|
|
74
|
-
[
|
|
75
|
-
component: TARGET === "vue3" ? wrapComponentRef(component) : component,
|
|
76
|
-
...curr,
|
|
77
|
-
},
|
|
69
|
+
[info.name]: serializeComponentInfo(info),
|
|
78
70
|
}), {}),
|
|
79
71
|
inheritedStyles: {},
|
|
80
72
|
}));
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
data: props.data,
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
}, [props.content, props.data, props.locale]);
|
|
89
|
-
return (React.createElement(React.Fragment, null, builderContextSignal.content ? (React.createElement(React.Fragment, null,
|
|
90
|
-
React.createElement(EnableEditor, { content: props.content, model: props.model, data: props.data, context: props.context, apiKey: props.apiKey, apiVersion: props.apiVersion, customComponents: customComponentsInfo(), canTrack: props.canTrack, locale: props.locale, includeRefs: props.includeRefs, enrich: props.enrich, classNameProp: props.classNameProp, hideContent: props.hideContent, parentContentId: props.parentContentId, isSsrAbTest: props.isSsrAbTest, builderContextSignal: builderContextSignal, setBuilderContextSignal: tempContextSignalSetter() },
|
|
73
|
+
return (React.createElement(ComponentsContext.Provider, { value: {
|
|
74
|
+
registeredComponents: registeredComponents,
|
|
75
|
+
} },
|
|
76
|
+
React.createElement(EnableEditor, { content: props.content, model: props.model, context: props.context, apiKey: props.apiKey, canTrack: props.canTrack, locale: props.locale, includeRefs: props.includeRefs, enrich: props.enrich, classNameProp: props.classNameProp, showContent: props.showContent, builderContextSignal: builderContextSignal, setBuilderContextSignal: setBuilderContextSignal },
|
|
91
77
|
props.isSsrAbTest ? (React.createElement(React.Fragment, null,
|
|
92
|
-
React.createElement(
|
|
78
|
+
React.createElement(InlinedScript, { scriptStr: scriptStr }))) : null,
|
|
93
79
|
TARGET !== "reactNative" ? (React.createElement(React.Fragment, null,
|
|
94
80
|
React.createElement(ContentStyles, { contentId: builderContextSignal.content?.id, cssCode: builderContextSignal.content?.data?.cssCode, customFonts: builderContextSignal.content?.data?.customFonts }))) : null,
|
|
95
|
-
React.createElement(Blocks, { blocks: builderContextSignal.content?.data?.blocks, context: builderContextSignal,
|
|
81
|
+
React.createElement(Blocks, { blocks: builderContextSignal.content?.data?.blocks, context: builderContextSignal, registeredComponents: registeredComponents }))));
|
|
96
82
|
}
|
|
97
|
-
export default
|
|
83
|
+
export default ContentComponent;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { BuilderRenderState } from '../../context/types';
|
|
2
|
-
import type { EnforcePartials } from '../../types/enforced-partials';
|
|
3
|
-
import type {
|
|
1
|
+
import type { BuilderRenderState } from '../../context/types.js';
|
|
2
|
+
import type { EnforcePartials } from '../../types/enforced-partials.js';
|
|
3
|
+
import type { ContentVariantsProps } from '../content-variants/content-variants.types.js';
|
|
4
4
|
interface InternalRenderProps {
|
|
5
5
|
/**
|
|
6
6
|
* TO-DO: improve qwik generator to not remap this name for non-HTML tags, then name it `className`
|
|
@@ -9,7 +9,7 @@ interface InternalRenderProps {
|
|
|
9
9
|
showContent: boolean;
|
|
10
10
|
isSsrAbTest: boolean;
|
|
11
11
|
}
|
|
12
|
-
export type
|
|
12
|
+
export type ContentProps = InternalRenderProps & EnforcePartials<ContentVariantsProps>;
|
|
13
13
|
export interface BuilderComponentStateChange {
|
|
14
14
|
state: BuilderRenderState;
|
|
15
15
|
ref: {
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
type VariantsProviderProps = ContentVariantsProps & {
|
|
2
|
+
/**
|
|
3
|
+
* For internal use only. Do not provide this prop.
|
|
4
|
+
*/
|
|
5
|
+
__isNestedRender?: boolean;
|
|
6
|
+
};
|
|
7
|
+
import type { ContentVariantsProps } from "./content-variants.types.js";
|
|
8
|
+
declare function ContentVariants(props: VariantsProviderProps): JSX.Element;
|
|
9
|
+
export default ContentVariants;
|
|
@@ -1,45 +1,46 @@
|
|
|
1
|
-
|
|
1
|
+
"use client";
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import { useState, useEffect } from "react";
|
|
4
|
-
import { checkShouldRunVariants, getScriptString, getVariants, getVariantsScriptString, } from "./helpers";
|
|
5
|
-
import
|
|
6
|
-
import { getDefaultCanTrack } from "../../helpers/canTrack";
|
|
4
|
+
import { checkShouldRunVariants, getScriptString, getVariants, getVariantsScriptString, } from "./helpers.js";
|
|
5
|
+
import ContentComponent from "../content/content";
|
|
6
|
+
import { getDefaultCanTrack } from "../../helpers/canTrack.js";
|
|
7
7
|
import InlinedStyles from "../inlined-styles";
|
|
8
|
-
import { handleABTestingSync } from "../../helpers/ab-tests";
|
|
8
|
+
import { handleABTestingSync } from "../../helpers/ab-tests.js";
|
|
9
9
|
import InlinedScript from "../inlined-script";
|
|
10
|
-
import { TARGET } from "../../constants/target";
|
|
11
|
-
function
|
|
10
|
+
import { TARGET } from "../../constants/target.js";
|
|
11
|
+
function ContentVariants(props) {
|
|
12
12
|
const [shouldRenderVariants, setShouldRenderVariants] = useState(() => checkShouldRunVariants({
|
|
13
13
|
canTrack: getDefaultCanTrack(props.canTrack),
|
|
14
14
|
content: props.content,
|
|
15
15
|
}));
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
16
|
+
function variantScriptStr() {
|
|
17
|
+
return getVariantsScriptString(getVariants(props.content).map((value) => ({
|
|
18
|
+
id: value.testVariationId,
|
|
19
|
+
testRatio: value.testRatio,
|
|
20
|
+
})), props.content?.id || "");
|
|
21
|
+
}
|
|
22
|
+
function hideVariantsStyleString() {
|
|
23
|
+
return getVariants(props.content)
|
|
24
|
+
.map((value) => `.variant-${value.testVariationId} { display: none; } `)
|
|
25
|
+
.join("");
|
|
26
|
+
}
|
|
23
27
|
useEffect(() => {
|
|
24
28
|
/**
|
|
25
29
|
* We unmount the non-winning variants post-hydration in Vue.
|
|
26
30
|
*/
|
|
27
|
-
if (TARGET === "vue2" || TARGET === "vue3") {
|
|
28
|
-
setShouldRenderVariants(false);
|
|
29
|
-
}
|
|
30
31
|
}, []);
|
|
31
32
|
return (React.createElement(React.Fragment, null,
|
|
32
33
|
!props.__isNestedRender && TARGET !== "reactNative" ? (React.createElement(React.Fragment, null,
|
|
33
34
|
React.createElement(InlinedScript, { scriptStr: getScriptString() }))) : null,
|
|
34
35
|
shouldRenderVariants ? (React.createElement(React.Fragment, null,
|
|
35
|
-
React.createElement(InlinedStyles, { id: `variants-styles-${props.content?.id}`, styles: hideVariantsStyleString }),
|
|
36
|
-
React.createElement(InlinedScript, { scriptStr: variantScriptStr }),
|
|
37
|
-
getVariants(props.content)?.map((variant) => (React.createElement(
|
|
38
|
-
React.createElement(
|
|
36
|
+
React.createElement(InlinedStyles, { id: `variants-styles-${props.content?.id}`, styles: hideVariantsStyleString() }),
|
|
37
|
+
React.createElement(InlinedScript, { scriptStr: variantScriptStr() }),
|
|
38
|
+
getVariants(props.content)?.map((variant) => (React.createElement(ContentComponent, { key: variant.testVariationId, content: variant, showContent: false, classNameProp: undefined, model: props.model, data: props.data, context: props.context, apiKey: props.apiKey, apiVersion: props.apiVersion, customComponents: props.customComponents, canTrack: props.canTrack, locale: props.locale, includeRefs: props.includeRefs, enrich: props.enrich, isSsrAbTest: shouldRenderVariants }))))) : null,
|
|
39
|
+
React.createElement(ContentComponent, { content: shouldRenderVariants
|
|
39
40
|
? props.content
|
|
40
41
|
: handleABTestingSync({
|
|
41
42
|
item: props.content,
|
|
42
43
|
canTrack: getDefaultCanTrack(props.canTrack),
|
|
43
44
|
}), classNameProp: `variant-${props.content?.id}`, showContent: true, model: props.model, data: props.data, context: props.context, apiKey: props.apiKey, apiVersion: props.apiVersion, customComponents: props.customComponents, canTrack: props.canTrack, locale: props.locale, includeRefs: props.includeRefs, enrich: props.enrich, isSsrAbTest: shouldRenderVariants })));
|
|
44
45
|
}
|
|
45
|
-
export default
|
|
46
|
+
export default ContentVariants;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { BuilderRenderContext, RegisteredComponent } from '../../context/types';
|
|
2
|
-
import type { ApiVersion } from '../../types/api-version';
|
|
3
|
-
import type { BuilderContent } from '../../types/builder-content';
|
|
4
|
-
import type { Nullable } from '../../types/typescript';
|
|
5
|
-
export interface
|
|
1
|
+
import type { BuilderRenderContext, RegisteredComponent } from '../../context/types.js';
|
|
2
|
+
import type { ApiVersion } from '../../types/api-version.js';
|
|
3
|
+
import type { BuilderContent } from '../../types/builder-content.js';
|
|
4
|
+
import type { Nullable } from '../../types/typescript.js';
|
|
5
|
+
export interface ContentVariantsProps {
|
|
6
6
|
content?: Nullable<BuilderContent>;
|
|
7
7
|
model?: string;
|
|
8
8
|
data?: {
|
package/dist/{sdk/components/render-content-variants → components/content-variants}/helpers.d.ts
RENAMED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import type { Nullable } from '../../helpers/nullable';
|
|
2
|
-
import type { BuilderContent } from '../../types/builder-content';
|
|
1
|
+
import type { Nullable } from '../../helpers/nullable.js';
|
|
2
|
+
import type { BuilderContent } from '../../types/builder-content.js';
|
|
3
3
|
export declare const getVariants: (content: Nullable<BuilderContent>) => {
|
|
4
4
|
testVariationId: string;
|
|
5
5
|
id: string;
|
|
6
6
|
data?: {
|
|
7
7
|
[key: string]: any;
|
|
8
8
|
title?: string;
|
|
9
|
-
blocks?: import("../../types/builder-block").BuilderBlock[];
|
|
10
|
-
inputs?: import("../../types/input").Input[];
|
|
9
|
+
blocks?: import("../../types/builder-block.js").BuilderBlock[];
|
|
10
|
+
inputs?: import("../../types/input.js").Input[];
|
|
11
11
|
state?: {
|
|
12
12
|
[key: string]: any;
|
|
13
13
|
};
|
|
@@ -21,10 +21,10 @@ export declare const getVariants: (content: Nullable<BuilderContent>) => {
|
|
|
21
21
|
testRatio?: number;
|
|
22
22
|
meta?: {
|
|
23
23
|
[key: string]: any;
|
|
24
|
-
breakpoints?: import("../../types/builder-content").Breakpoints;
|
|
24
|
+
breakpoints?: import("../../types/builder-content.js").Breakpoints;
|
|
25
25
|
};
|
|
26
26
|
}[];
|
|
27
|
-
export declare const checkShouldRunVariants: ({ canTrack, content
|
|
27
|
+
export declare const checkShouldRunVariants: ({ canTrack, content }: {
|
|
28
28
|
canTrack: Nullable<boolean>;
|
|
29
29
|
content: Nullable<BuilderContent>;
|
|
30
30
|
}) => boolean;
|
|
@@ -34,7 +34,7 @@ type VariantData = {
|
|
|
34
34
|
};
|
|
35
35
|
export declare const getScriptString: () => string;
|
|
36
36
|
export declare const getVariantsScriptString: (variants: VariantData[], contentId: string) => string;
|
|
37
|
-
export declare const getRenderContentScriptString: ({ contentId, variationId
|
|
37
|
+
export declare const getRenderContentScriptString: ({ contentId, variationId }: {
|
|
38
38
|
variationId: string;
|
|
39
39
|
contentId: string;
|
|
40
40
|
}) => string;
|