@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
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import * as React from "react";
|
|
3
|
-
import { useState } from "react";
|
|
4
|
-
import { getBlockActions } from "../../functions/get-block-actions.js";
|
|
5
|
-
import { getBlockComponentOptions } from "../../functions/get-block-component-options.js";
|
|
6
|
-
import { getBlockProperties } from "../../functions/get-block-properties.js";
|
|
7
|
-
import { getProcessedBlock } from "../../functions/get-processed-block.js";
|
|
8
|
-
import BlockStyles from "./components/block-styles";
|
|
9
|
-
import { getComponent, getRepeatItemData, isEmptyHtmlElement, } from "./block.helpers.js";
|
|
10
|
-
import RepeatedBlock from "./components/repeated-block";
|
|
11
|
-
import { TARGET } from "../../constants/target.js";
|
|
12
|
-
import Component from "./components/component";
|
|
13
|
-
import { getReactNativeBlockStyles } from "../../functions/get-react-native-block-styles.js";
|
|
14
|
-
function Block(props) {
|
|
15
|
-
const [component, setComponent] = useState(() => getComponent({
|
|
16
|
-
block: props.block,
|
|
17
|
-
context: props.context,
|
|
18
|
-
}));
|
|
19
|
-
function repeatItem() {
|
|
20
|
-
return getRepeatItemData({
|
|
21
|
-
block: props.block,
|
|
22
|
-
context: props.context,
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
function processedBlock() {
|
|
26
|
-
return repeatItem()
|
|
27
|
-
? props.block
|
|
28
|
-
: getProcessedBlock({
|
|
29
|
-
block: props.block,
|
|
30
|
-
localState: props.context.localState,
|
|
31
|
-
rootState: props.context.rootState,
|
|
32
|
-
rootSetState: props.context.rootSetState,
|
|
33
|
-
context: props.context.context,
|
|
34
|
-
shouldEvaluateBindings: true,
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
const [Tag, setTag] = useState(() => props.block.tagName || "div");
|
|
38
|
-
function canShowBlock() {
|
|
39
|
-
if ("hide" in processedBlock()) {
|
|
40
|
-
return !processedBlock().hide;
|
|
41
|
-
}
|
|
42
|
-
if ("show" in processedBlock()) {
|
|
43
|
-
return processedBlock().show;
|
|
44
|
-
}
|
|
45
|
-
return true;
|
|
46
|
-
}
|
|
47
|
-
function actions() {
|
|
48
|
-
return getBlockActions({
|
|
49
|
-
block: processedBlock(),
|
|
50
|
-
rootState: props.context.rootState,
|
|
51
|
-
rootSetState: props.context.rootSetState,
|
|
52
|
-
localState: props.context.localState,
|
|
53
|
-
context: props.context.context,
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
function attributes() {
|
|
57
|
-
const blockProperties = getBlockProperties(processedBlock());
|
|
58
|
-
return {
|
|
59
|
-
...blockProperties,
|
|
60
|
-
...(TARGET === "reactNative"
|
|
61
|
-
? {
|
|
62
|
-
style: getReactNativeBlockStyles({
|
|
63
|
-
block: processedBlock(),
|
|
64
|
-
context: props.context,
|
|
65
|
-
blockStyles: blockProperties.style,
|
|
66
|
-
}),
|
|
67
|
-
}
|
|
68
|
-
: {}),
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
function childrenWithoutParentComponent() {
|
|
72
|
-
/**
|
|
73
|
-
* When there is no `componentRef`, there might still be children that need to be rendered. In this case,
|
|
74
|
-
* we render them outside of `componentRef`.
|
|
75
|
-
* NOTE: We make sure not to render this if `repeatItemData` is non-null, because that means we are rendering an array of
|
|
76
|
-
* blocks, and the children will be repeated within those blocks.
|
|
77
|
-
*/
|
|
78
|
-
const shouldRenderChildrenOutsideRef = !component?.component && !repeatItem();
|
|
79
|
-
return shouldRenderChildrenOutsideRef
|
|
80
|
-
? processedBlock().children ?? []
|
|
81
|
-
: [];
|
|
82
|
-
}
|
|
83
|
-
function renderComponentProps() {
|
|
84
|
-
return {
|
|
85
|
-
blockChildren: processedBlock().children ?? [],
|
|
86
|
-
componentRef: component?.component,
|
|
87
|
-
componentOptions: {
|
|
88
|
-
...getBlockComponentOptions(processedBlock()),
|
|
89
|
-
/**
|
|
90
|
-
* These attributes are passed to the wrapper element when there is one. If `noWrap` is set to true, then
|
|
91
|
-
* they are provided to the component itself directly.
|
|
92
|
-
*/
|
|
93
|
-
...(!component?.noWrap
|
|
94
|
-
? {}
|
|
95
|
-
: {
|
|
96
|
-
attributes: {
|
|
97
|
-
...attributes(),
|
|
98
|
-
...actions(),
|
|
99
|
-
},
|
|
100
|
-
}),
|
|
101
|
-
builderContext: props.context,
|
|
102
|
-
...(component?.name === "Symbol" || component?.name === "Columns"
|
|
103
|
-
? {
|
|
104
|
-
builderComponents: props.components,
|
|
105
|
-
}
|
|
106
|
-
: {}),
|
|
107
|
-
},
|
|
108
|
-
context: childrenContext,
|
|
109
|
-
components: props.components,
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
const [childrenContext, setChildrenContext] = useState(() => props.context);
|
|
113
|
-
return (React.createElement(React.Fragment, null, canShowBlock() ? (React.createElement(React.Fragment, null, !component?.noWrap ? (React.createElement(React.Fragment, null,
|
|
114
|
-
isEmptyHtmlElement(Tag) ? (React.createElement(React.Fragment, null,
|
|
115
|
-
React.createElement(Tag, { ...attributes(), ...actions() }))) : null,
|
|
116
|
-
!isEmptyHtmlElement(Tag) && repeatItem() ? (React.createElement(React.Fragment, null, repeatItem()?.map((data, index) => (React.createElement(RepeatedBlock, { key: index, repeatContext: data.context, block: data.block, components: props.components }))))) : null,
|
|
117
|
-
!isEmptyHtmlElement(Tag) && !repeatItem() ? (React.createElement(React.Fragment, null,
|
|
118
|
-
React.createElement(Tag, { ...attributes(), ...actions() },
|
|
119
|
-
React.createElement(Component, { ...renderComponentProps() }),
|
|
120
|
-
childrenWithoutParentComponent()?.map((child) => (React.createElement(Block, { key: "render-block-" + child.id, block: child, context: childrenContext, components: props.components }))),
|
|
121
|
-
childrenWithoutParentComponent()?.map((child) => (React.createElement(BlockStyles, { key: "block-style-" + child.id, block: child, context: childrenContext })))))) : null)) : (React.createElement(React.Fragment, null,
|
|
122
|
-
React.createElement(Component, { ...renderComponentProps() }))))) : null));
|
|
123
|
-
}
|
|
124
|
-
export default Block;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
type ComponentOptions = PropsWithBuilderData<{
|
|
3
|
-
[index: string]: any;
|
|
4
|
-
attributes?: {
|
|
5
|
-
[index: string]: any;
|
|
6
|
-
};
|
|
7
|
-
}>;
|
|
8
|
-
export interface ComponentProps {
|
|
9
|
-
componentRef: any;
|
|
10
|
-
componentOptions: ComponentOptions;
|
|
11
|
-
blockChildren: BuilderBlock[];
|
|
12
|
-
context: BuilderContextInterface;
|
|
13
|
-
components: Dictionary<RegisteredComponent>;
|
|
14
|
-
}
|
|
15
|
-
import type { BuilderBlock } from "../../../types/builder-block.js";
|
|
16
|
-
import type { BuilderContextInterface, RegisteredComponent } from "../../../context/types.js";
|
|
17
|
-
import type { PropsWithBuilderData } from "../../../types/builder-props.js";
|
|
18
|
-
import type { Dictionary } from "../../../types/typescript.js";
|
|
19
|
-
declare function Component(props: ComponentProps): JSX.Element;
|
|
20
|
-
export default Component;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import * as React from "react";
|
|
3
|
-
import BlockStyles from "./block-styles";
|
|
4
|
-
import Block from "../block";
|
|
5
|
-
function Component(props) {
|
|
6
|
-
return (React.createElement(React.Fragment, null, props.componentRef ? (React.createElement(React.Fragment, null,
|
|
7
|
-
React.createElement(props.componentRef, { ...props.componentOptions },
|
|
8
|
-
props.blockChildren?.map((child) => (React.createElement(Block, { key: "render-block-" + child.id, block: child, context: props.context, components: props.components }))),
|
|
9
|
-
props.blockChildren?.map((child) => (React.createElement(BlockStyles, { key: "block-style-" + child.id, block: child, context: props.context })))))) : null));
|
|
10
|
-
}
|
|
11
|
-
export default Component;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
type Props = {
|
|
3
|
-
block: BuilderBlock;
|
|
4
|
-
repeatContext: BuilderContextInterface;
|
|
5
|
-
components: Dictionary<RegisteredComponent>;
|
|
6
|
-
};
|
|
7
|
-
import type { BuilderContextInterface, RegisteredComponent } from "../../../context/types.js";
|
|
8
|
-
import type { BuilderBlock } from "../../../types/builder-block";
|
|
9
|
-
import type { Dictionary } from "../../../types/typescript";
|
|
10
|
-
declare function RepeatedBlock(props: Props): JSX.Element;
|
|
11
|
-
export default RepeatedBlock;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
export type BlocksProps = Partial<BlocksWrapperProps> & {
|
|
3
|
-
context: BuilderContextInterface;
|
|
4
|
-
components: Dictionary<RegisteredComponent>;
|
|
5
|
-
};
|
|
6
|
-
import type { BlocksWrapperProps } from "./blocks-wrapper";
|
|
7
|
-
import type { BuilderContextInterface, RegisteredComponent } from "../../context/types.js";
|
|
8
|
-
import type { Dictionary } from "../../types/typescript";
|
|
9
|
-
declare function Blocks(props: BlocksProps): JSX.Element;
|
|
10
|
-
export default Blocks;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
type BuilderEditorProps = Omit<ContentProps, "customComponents"> & {
|
|
3
|
-
customComponents: Dictionary<ComponentInfo>;
|
|
4
|
-
builderContextSignal: BuilderContextInterface;
|
|
5
|
-
setBuilderContextSignal: any;
|
|
6
|
-
children?: any;
|
|
7
|
-
};
|
|
8
|
-
import type { BuilderContextInterface } from "../../../context/types.js";
|
|
9
|
-
import type { ContentProps } from "../content.types.js";
|
|
10
|
-
import type { Dictionary } from "../../../types/typescript.js";
|
|
11
|
-
import type { ComponentInfo } from "../../../types/components.js";
|
|
12
|
-
declare function EnableEditor(props: BuilderEditorProps): JSX.Element;
|
|
13
|
-
export default EnableEditor;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { BuilderContent } from '../../types/builder-content';
|
|
2
|
-
import type { Nullable } from '../../types/typescript';
|
|
3
|
-
import type { ContentProps } from './content.types';
|
|
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>;
|
|
@@ -1,30 +0,0 @@
|
|
|
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 &&
|
|
6
|
-
input.defaultValue !== undefined &&
|
|
7
|
-
content?.data?.state &&
|
|
8
|
-
content.data.state[input.name] === undefined) {
|
|
9
|
-
defaultValues[input.name] = input.defaultValue;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
const stateToUse = {
|
|
13
|
-
...content?.data?.state,
|
|
14
|
-
...data,
|
|
15
|
-
...(locale ? { locale } : {}),
|
|
16
|
-
};
|
|
17
|
-
return { ...defaultValues, ...stateToUse };
|
|
18
|
-
};
|
|
19
|
-
export const getContentInitialValue = ({ content, data, }) => {
|
|
20
|
-
return !content
|
|
21
|
-
? undefined
|
|
22
|
-
: {
|
|
23
|
-
...content,
|
|
24
|
-
data: {
|
|
25
|
-
...content?.data,
|
|
26
|
-
...data,
|
|
27
|
-
},
|
|
28
|
-
meta: content?.meta,
|
|
29
|
-
};
|
|
30
|
-
};
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import type { BuilderRenderContext, RegisteredComponent, BuilderRenderState } from '../../context/types';
|
|
2
|
-
import type { BuilderContent } from '../../types/builder-content';
|
|
3
|
-
import type { Nullable } from '../../types/typescript';
|
|
4
|
-
import type { ApiVersion } from '../../types/api-version';
|
|
5
|
-
export interface ContentProps {
|
|
6
|
-
content?: Nullable<BuilderContent>;
|
|
7
|
-
model?: string;
|
|
8
|
-
data?: {
|
|
9
|
-
[key: string]: any;
|
|
10
|
-
};
|
|
11
|
-
context?: BuilderRenderContext;
|
|
12
|
-
apiKey: string;
|
|
13
|
-
apiVersion?: ApiVersion;
|
|
14
|
-
customComponents?: RegisteredComponent[];
|
|
15
|
-
canTrack?: boolean;
|
|
16
|
-
locale?: string;
|
|
17
|
-
/** @deprecated use `enrich` instead **/
|
|
18
|
-
includeRefs?: boolean;
|
|
19
|
-
enrich?: boolean;
|
|
20
|
-
/**
|
|
21
|
-
* TO-DO: improve qwik generator to not remap this name for non-HTML tags, then name it `className`
|
|
22
|
-
*/
|
|
23
|
-
classNameProp?: string;
|
|
24
|
-
hideContent?: boolean;
|
|
25
|
-
parentContentId?: string;
|
|
26
|
-
isSsrAbTest?: boolean;
|
|
27
|
-
}
|
|
28
|
-
export interface BuilderComponentStateChange {
|
|
29
|
-
state: BuilderRenderState;
|
|
30
|
-
ref: {
|
|
31
|
-
name?: string;
|
|
32
|
-
props?: {
|
|
33
|
-
builderBlock?: {
|
|
34
|
-
id?: string;
|
|
35
|
-
};
|
|
36
|
-
};
|
|
37
|
-
};
|
|
38
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import * as React from "react";
|
|
3
|
-
import { useState } from "react";
|
|
4
|
-
import { checkShouldRunVariants, getVariants, getVariantsScriptString, } from "./helpers";
|
|
5
|
-
import Content from "../content/content";
|
|
6
|
-
import { getDefaultCanTrack } from "../../helpers/canTrack";
|
|
7
|
-
import InlinedStyles from "../inlined-styles";
|
|
8
|
-
import { handleABTestingSync } from "../../helpers/ab-tests";
|
|
9
|
-
function RenderContentVariants(props) {
|
|
10
|
-
const [variantScriptStr, setVariantScriptStr] = useState(() => getVariantsScriptString(getVariants(props.content).map((value) => ({
|
|
11
|
-
id: value.id,
|
|
12
|
-
testRatio: value.testRatio,
|
|
13
|
-
})), props.content?.id || ""));
|
|
14
|
-
const [shouldRenderVariants, setShouldRenderVariants] = useState(() => checkShouldRunVariants({
|
|
15
|
-
canTrack: getDefaultCanTrack(props.canTrack),
|
|
16
|
-
content: props.content,
|
|
17
|
-
}));
|
|
18
|
-
const [hideVariantsStyleString, setHideVariantsStyleString] = useState(() => getVariants(props.content)
|
|
19
|
-
.map((value) => `.variant-${value.id} { display: none; } `)
|
|
20
|
-
.join(""));
|
|
21
|
-
const [contentToRender, setContentToRender] = useState(() => checkShouldRunVariants({
|
|
22
|
-
canTrack: getDefaultCanTrack(props.canTrack),
|
|
23
|
-
content: props.content,
|
|
24
|
-
})
|
|
25
|
-
? props.content
|
|
26
|
-
: handleABTestingSync({
|
|
27
|
-
item: props.content,
|
|
28
|
-
canTrack: getDefaultCanTrack(props.canTrack),
|
|
29
|
-
}));
|
|
30
|
-
return (React.createElement(React.Fragment, null,
|
|
31
|
-
shouldRenderVariants ? (React.createElement(React.Fragment, null,
|
|
32
|
-
React.createElement(InlinedStyles, { id: `variants-styles-${props.content?.id}`, styles: hideVariantsStyleString }),
|
|
33
|
-
React.createElement("script", { id: `variants-script-${props.content?.id}`, dangerouslySetInnerHTML: { __html: variantScriptStr } }),
|
|
34
|
-
getVariants(props.content)?.map((variant) => (React.createElement(Content, { key: variant.id, content: variant, apiKey: props.apiKey, apiVersion: props.apiVersion, canTrack: props.canTrack, customComponents: props.customComponents, hideContent: true, parentContentId: props.content?.id, isSsrAbTest: shouldRenderVariants }))))) : null,
|
|
35
|
-
React.createElement(Content, { model: props.model, content: contentToRender, apiKey: props.apiKey, apiVersion: props.apiVersion, canTrack: props.canTrack, customComponents: props.customComponents, classNameProp: `variant-${props.content?.id}`, parentContentId: props.content?.id, isSsrAbTest: shouldRenderVariants })));
|
|
36
|
-
}
|
|
37
|
-
export default RenderContentVariants;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { Nullable } from '../../helpers/nullable';
|
|
2
|
-
import type { BuilderContent } from '../../types/builder-content';
|
|
3
|
-
export declare const getVariants: (content: Nullable<BuilderContent>) => import("../../types/builder-content").BuilderContentVariation[];
|
|
4
|
-
export declare const checkShouldRunVariants: ({ canTrack, content, }: {
|
|
5
|
-
canTrack: Nullable<boolean>;
|
|
6
|
-
content: Nullable<BuilderContent>;
|
|
7
|
-
}) => boolean;
|
|
8
|
-
type VariantData = {
|
|
9
|
-
id: string;
|
|
10
|
-
testRatio?: number;
|
|
11
|
-
};
|
|
12
|
-
export declare const getVariantsScriptString: (variants: VariantData[], contentId: string) => string;
|
|
13
|
-
export declare const getRenderContentScriptString: ({ parentContentId, contentId, }: {
|
|
14
|
-
contentId: string;
|
|
15
|
-
parentContentId: string;
|
|
16
|
-
}) => string;
|
|
17
|
-
export {};
|
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
import { TARGET } from '../../constants/target';
|
|
2
|
-
import { isBrowser } from '../../functions/is-browser';
|
|
3
|
-
export const getVariants = (content) => Object.values(content?.variations || {});
|
|
4
|
-
export const checkShouldRunVariants = ({ canTrack, content, }) => {
|
|
5
|
-
const hasVariants = getVariants(content).length > 0;
|
|
6
|
-
if (!hasVariants) {
|
|
7
|
-
return false;
|
|
8
|
-
}
|
|
9
|
-
if (!canTrack) {
|
|
10
|
-
return false;
|
|
11
|
-
}
|
|
12
|
-
if (isBrowser()) {
|
|
13
|
-
return false;
|
|
14
|
-
}
|
|
15
|
-
return true;
|
|
16
|
-
};
|
|
17
|
-
/**
|
|
18
|
-
* NOTE: when this function is stringified, single-line comments can cause weird issues when compiled by Sveltekit.
|
|
19
|
-
* Make sure to write multi-line comments only.
|
|
20
|
-
*/
|
|
21
|
-
function bldrAbTest(contentId, variants, isHydrationTarget) {
|
|
22
|
-
function getAndSetVariantId() {
|
|
23
|
-
function setCookie(name, value, days) {
|
|
24
|
-
let expires = '';
|
|
25
|
-
if (days) {
|
|
26
|
-
const date = new Date();
|
|
27
|
-
date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);
|
|
28
|
-
expires = '; expires=' + date.toUTCString();
|
|
29
|
-
}
|
|
30
|
-
document.cookie =
|
|
31
|
-
name +
|
|
32
|
-
'=' +
|
|
33
|
-
(value || '') +
|
|
34
|
-
expires +
|
|
35
|
-
'; path=/' +
|
|
36
|
-
'; Secure; SameSite=None';
|
|
37
|
-
}
|
|
38
|
-
function getCookie(name) {
|
|
39
|
-
const nameEQ = name + '=';
|
|
40
|
-
const ca = document.cookie.split(';');
|
|
41
|
-
for (let i = 0; i < ca.length; i++) {
|
|
42
|
-
let c = ca[i];
|
|
43
|
-
while (c.charAt(0) === ' ')
|
|
44
|
-
c = c.substring(1, c.length);
|
|
45
|
-
if (c.indexOf(nameEQ) === 0)
|
|
46
|
-
return c.substring(nameEQ.length, c.length);
|
|
47
|
-
}
|
|
48
|
-
return null;
|
|
49
|
-
}
|
|
50
|
-
const cookieName = `builder.tests.${contentId}`;
|
|
51
|
-
const variantInCookie = getCookie(cookieName);
|
|
52
|
-
const availableIDs = variants.map((vr) => vr.id).concat(contentId);
|
|
53
|
-
/**
|
|
54
|
-
* cookie already exists
|
|
55
|
-
*/
|
|
56
|
-
if (variantInCookie && availableIDs.includes(variantInCookie)) {
|
|
57
|
-
return variantInCookie;
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* no cookie exists, find variant
|
|
61
|
-
*/
|
|
62
|
-
let n = 0;
|
|
63
|
-
const random = Math.random();
|
|
64
|
-
for (let i = 0; i < variants.length; i++) {
|
|
65
|
-
const variant = variants[i];
|
|
66
|
-
const testRatio = variant.testRatio;
|
|
67
|
-
n += testRatio;
|
|
68
|
-
if (random < n) {
|
|
69
|
-
setCookie(cookieName, variant.id);
|
|
70
|
-
return variant.id;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* no variant found, assign default content
|
|
75
|
-
*/
|
|
76
|
-
setCookie(cookieName, contentId);
|
|
77
|
-
return contentId;
|
|
78
|
-
}
|
|
79
|
-
const winningVariantId = getAndSetVariantId();
|
|
80
|
-
const styleEl = document.getElementById(`variants-styles-${contentId}`);
|
|
81
|
-
/**
|
|
82
|
-
* For React to work, we need hydration to match SSR, so we completely remove this node and the styles tag.
|
|
83
|
-
*/
|
|
84
|
-
if (isHydrationTarget) {
|
|
85
|
-
styleEl.remove();
|
|
86
|
-
const thisScriptEl = document.getElementById(`variants-script-${contentId}`);
|
|
87
|
-
thisScriptEl?.remove();
|
|
88
|
-
}
|
|
89
|
-
else {
|
|
90
|
-
/* update styles to hide all variants except the winning variant */
|
|
91
|
-
const newStyleStr = variants
|
|
92
|
-
.concat({ id: contentId })
|
|
93
|
-
.filter((variant) => variant.id !== winningVariantId)
|
|
94
|
-
.map((value) => {
|
|
95
|
-
return `.variant-${value.id} { display: none; }
|
|
96
|
-
`;
|
|
97
|
-
})
|
|
98
|
-
.join('');
|
|
99
|
-
/* TO-DO: check if this actually updates the style */
|
|
100
|
-
styleEl.innerHTML = newStyleStr;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* NOTE: when this function is stringified, single-line comments can cause weird issues when compiled by Sveltekit.
|
|
105
|
-
* Make sure to write multi-line comments only.
|
|
106
|
-
*/
|
|
107
|
-
function bldrCntntScrpt(variantContentId, defaultContentId, isHydrationTarget) {
|
|
108
|
-
if (!navigator.cookieEnabled) {
|
|
109
|
-
return;
|
|
110
|
-
}
|
|
111
|
-
function getCookie(name) {
|
|
112
|
-
const nameEQ = name + '=';
|
|
113
|
-
const ca = document.cookie.split(';');
|
|
114
|
-
for (let i = 0; i < ca.length; i++) {
|
|
115
|
-
let c = ca[i];
|
|
116
|
-
while (c.charAt(0) === ' ')
|
|
117
|
-
c = c.substring(1, c.length);
|
|
118
|
-
if (c.indexOf(nameEQ) === 0)
|
|
119
|
-
return c.substring(nameEQ.length, c.length);
|
|
120
|
-
}
|
|
121
|
-
return null;
|
|
122
|
-
}
|
|
123
|
-
const cookieName = `builder.tests.${defaultContentId}`;
|
|
124
|
-
const variantId = getCookie(cookieName);
|
|
125
|
-
/** get parent div by searching on `builder-content-id` attr */
|
|
126
|
-
const parentDiv = document.querySelector(`[builder-content-id="${variantContentId}"]`);
|
|
127
|
-
const variantIsDefaultContent = variantContentId === defaultContentId;
|
|
128
|
-
if (variantId === variantContentId) {
|
|
129
|
-
if (variantIsDefaultContent) {
|
|
130
|
-
/** the default content is already visible, no need to do anything */
|
|
131
|
-
return;
|
|
132
|
-
}
|
|
133
|
-
/** this is the winning variant and not already visible: remove `hidden` and `aria-hidden` attr */
|
|
134
|
-
parentDiv?.removeAttribute('hidden');
|
|
135
|
-
parentDiv?.removeAttribute('aria-hidden');
|
|
136
|
-
}
|
|
137
|
-
else {
|
|
138
|
-
if (variantIsDefaultContent) {
|
|
139
|
-
if (isHydrationTarget) {
|
|
140
|
-
/**
|
|
141
|
-
* For React to work, we need to support hydration, in which case the first CSR will have none of the hidden variants.
|
|
142
|
-
* So we completely remove that node.
|
|
143
|
-
*/
|
|
144
|
-
parentDiv?.remove();
|
|
145
|
-
}
|
|
146
|
-
else {
|
|
147
|
-
/** this is not the winning variant, add `hidden` attr */
|
|
148
|
-
parentDiv?.setAttribute('hidden', 'true');
|
|
149
|
-
parentDiv?.setAttribute('aria-hidden', 'true');
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
/** This is not the winning variant, and it's not the default content.
|
|
153
|
-
* There's no need to hide it, because it's already hidden.
|
|
154
|
-
*/
|
|
155
|
-
return;
|
|
156
|
-
}
|
|
157
|
-
return;
|
|
158
|
-
}
|
|
159
|
-
const getIsHydrationTarget = (target) => target === 'react' ||
|
|
160
|
-
target === 'reactNative' ||
|
|
161
|
-
target === 'vue3' ||
|
|
162
|
-
target === 'vue2';
|
|
163
|
-
const isHydrationTarget = getIsHydrationTarget(TARGET);
|
|
164
|
-
/**
|
|
165
|
-
* We hardcode explicit function names here, because the `.toString()` of a function can change depending on the bundler.
|
|
166
|
-
* Some bundlers will minify the fn name, etc.
|
|
167
|
-
*
|
|
168
|
-
* So we hardcode the function names here, and then use those names in the script string to make sure the function names are consistent.
|
|
169
|
-
*/
|
|
170
|
-
const AB_TEST_FN_NAME = 'bldrAbTest';
|
|
171
|
-
const CONTENT_FN_NAME = 'bldrCntntScrpt';
|
|
172
|
-
export const getVariantsScriptString = (variants, contentId) => {
|
|
173
|
-
const fnStr = bldrAbTest.toString().replace(/\s+/g, ' ');
|
|
174
|
-
const fnStr2 = bldrCntntScrpt.toString().replace(/\s+/g, ' ');
|
|
175
|
-
return `
|
|
176
|
-
const ${AB_TEST_FN_NAME} = ${fnStr}
|
|
177
|
-
const ${CONTENT_FN_NAME} = ${fnStr2}
|
|
178
|
-
${AB_TEST_FN_NAME}("${contentId}", ${JSON.stringify(variants)}, ${isHydrationTarget})
|
|
179
|
-
`;
|
|
180
|
-
};
|
|
181
|
-
export const getRenderContentScriptString = ({ parentContentId, contentId, }) => {
|
|
182
|
-
return `
|
|
183
|
-
${CONTENT_FN_NAME}("${contentId}", "${parentContentId}", ${isHydrationTarget})`;
|
|
184
|
-
};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
export type BlockStylesProps = {
|
|
3
|
-
block: BuilderBlock;
|
|
4
|
-
context: BuilderContextInterface;
|
|
5
|
-
};
|
|
6
|
-
import type { BuilderContextInterface } from "../../context/types.js";
|
|
7
|
-
import type { BuilderBlock } from "../../types/builder-block.js";
|
|
8
|
-
declare function BlockStyles(props: BlockStylesProps): JSX.Element;
|
|
9
|
-
export default BlockStyles;
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import * as React from "react";
|
|
3
|
-
import { getMaxWidthQueryForSize, getSizesForBreakpoints, } from "../../constants/device-sizes.js";
|
|
4
|
-
import { TARGET } from "../../constants/target.js";
|
|
5
|
-
import { getProcessedBlock } from "../../functions/get-processed-block.js";
|
|
6
|
-
import { createCssClass } from "../../helpers/css.js";
|
|
7
|
-
import { checkIsDefined } from "../../helpers/nullable.js";
|
|
8
|
-
import InlinedStyles from "../inlined-styles";
|
|
9
|
-
function BlockStyles(props) {
|
|
10
|
-
function useBlock() {
|
|
11
|
-
return getProcessedBlock({
|
|
12
|
-
block: props.block,
|
|
13
|
-
localState: props.context.localState,
|
|
14
|
-
rootState: props.context.rootState,
|
|
15
|
-
rootSetState: props.context.rootSetState,
|
|
16
|
-
context: props.context.context,
|
|
17
|
-
shouldEvaluateBindings: true,
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
function canShowBlock() {
|
|
21
|
-
// only render styles for blocks that are visible
|
|
22
|
-
if (checkIsDefined(useBlock().hide)) {
|
|
23
|
-
return !useBlock().hide;
|
|
24
|
-
}
|
|
25
|
-
if (checkIsDefined(useBlock().show)) {
|
|
26
|
-
return useBlock().show;
|
|
27
|
-
}
|
|
28
|
-
return true;
|
|
29
|
-
}
|
|
30
|
-
function css() {
|
|
31
|
-
const styles = useBlock().responsiveStyles;
|
|
32
|
-
const content = props.context.content;
|
|
33
|
-
const sizesWithUpdatedBreakpoints = getSizesForBreakpoints(content?.meta?.breakpoints || {});
|
|
34
|
-
const largeStyles = styles?.large;
|
|
35
|
-
const mediumStyles = styles?.medium;
|
|
36
|
-
const smallStyles = styles?.small;
|
|
37
|
-
const className = useBlock().id;
|
|
38
|
-
if (!className) {
|
|
39
|
-
return "";
|
|
40
|
-
}
|
|
41
|
-
const largeStylesClass = largeStyles
|
|
42
|
-
? createCssClass({
|
|
43
|
-
className,
|
|
44
|
-
styles: largeStyles,
|
|
45
|
-
})
|
|
46
|
-
: "";
|
|
47
|
-
const mediumStylesClass = mediumStyles
|
|
48
|
-
? createCssClass({
|
|
49
|
-
className,
|
|
50
|
-
styles: mediumStyles,
|
|
51
|
-
mediaQuery: getMaxWidthQueryForSize("medium", sizesWithUpdatedBreakpoints),
|
|
52
|
-
})
|
|
53
|
-
: "";
|
|
54
|
-
const smallStylesClass = smallStyles
|
|
55
|
-
? createCssClass({
|
|
56
|
-
className,
|
|
57
|
-
styles: smallStyles,
|
|
58
|
-
mediaQuery: getMaxWidthQueryForSize("small", sizesWithUpdatedBreakpoints),
|
|
59
|
-
})
|
|
60
|
-
: "";
|
|
61
|
-
return [largeStylesClass, mediumStylesClass, smallStylesClass].join(" ");
|
|
62
|
-
}
|
|
63
|
-
return (React.createElement(React.Fragment, null, TARGET !== "reactNative" && css() && canShowBlock() ? (React.createElement(React.Fragment, null,
|
|
64
|
-
React.createElement(InlinedStyles, { styles: css() }))) : null));
|
|
65
|
-
}
|
|
66
|
-
export default BlockStyles;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
export type RenderBlockProps = {
|
|
3
|
-
block: BuilderBlock;
|
|
4
|
-
context: BuilderContextInterface;
|
|
5
|
-
};
|
|
6
|
-
import type { BuilderContextInterface } from "../../context/types.js";
|
|
7
|
-
import type { BuilderBlock } from "../../types/builder-block.js";
|
|
8
|
-
declare function RenderBlock(props: RenderBlockProps): JSX.Element;
|
|
9
|
-
export default RenderBlock;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { BuilderContextInterface } from '../../context/types';
|
|
2
|
-
import type { BuilderBlock } from '../../types/builder-block';
|
|
3
|
-
import type { RepeatData } from './types';
|
|
4
|
-
export declare const isEmptyHtmlElement: (tagName: unknown) => boolean;
|
|
5
|
-
export declare const getComponent: ({ block, context, }: {
|
|
6
|
-
block: BuilderBlock;
|
|
7
|
-
context: BuilderContextInterface;
|
|
8
|
-
}) => import("../../context/types").RegisteredComponent;
|
|
9
|
-
export declare const getRepeatItemData: ({ block, context, }: {
|
|
10
|
-
block: BuilderBlock;
|
|
11
|
-
context: BuilderContextInterface;
|
|
12
|
-
}) => RepeatData[] | undefined;
|