@builder.io/sdk-react 0.4.5 → 0.5.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/{sdk/components → components}/blocks/blocks.d.ts +2 -4
- package/dist/{sdk/components → components}/blocks/blocks.js +2 -2
- 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/components/content/content.js +79 -0
- 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/{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 +6 -13
- 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/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.js +0 -97
- 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
|
+
import type { BuilderContextInterface, RegisteredComponents } from '../context/types.js';
|
|
2
|
+
import type { BuilderBlock } from './builder-block.js';
|
|
3
|
+
export type PropsWithBuilderData<T> = T & {
|
|
4
|
+
builderBlock: BuilderBlock;
|
|
5
|
+
builderContext: BuilderContextInterface;
|
|
6
|
+
};
|
|
7
|
+
export type BuilderComponentsProp = {
|
|
8
|
+
builderComponents: RegisteredComponents;
|
|
9
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { BuilderElement } from './element';
|
|
2
|
-
import type { Input } from './input';
|
|
1
|
+
import type { BuilderElement } from './element.js';
|
|
2
|
+
import type { Input } from './input.js';
|
|
3
3
|
export interface ComponentInfo {
|
|
4
4
|
/**
|
|
5
5
|
* Name your component something unique, e.g. 'MyButton'. You can override built-in components
|
|
@@ -33,6 +33,12 @@ export interface ComponentInfo {
|
|
|
33
33
|
* like here github.com/BuilderIO/builder/blob/master/packages/react/src/blocks/forms/Input.tsx#L34
|
|
34
34
|
*/
|
|
35
35
|
noWrap?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* TO-DO: make this optional only for RSC SDK.
|
|
38
|
+
*
|
|
39
|
+
* Set this to `true` if your component is a React Server Component (RSC).
|
|
40
|
+
*/
|
|
41
|
+
isRSC?: boolean;
|
|
36
42
|
/**
|
|
37
43
|
* Default children
|
|
38
44
|
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type Target = 'vue3' | 'vue2' | 'reactNative' | 'svelte' | 'qwik' | 'react' | 'solid' | 'rsc';
|
package/package.json
CHANGED
|
@@ -1,30 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@builder.io/sdk-react",
|
|
3
3
|
"description": "Builder.io SDK for React",
|
|
4
|
-
"version": "0.
|
|
5
|
-
"type": "module",
|
|
4
|
+
"version": "0.5.0",
|
|
6
5
|
"files": [
|
|
7
6
|
"dist"
|
|
8
7
|
],
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
9
|
"exports": {
|
|
10
|
-
".": "./dist/
|
|
11
|
-
"./server": "./dist/
|
|
10
|
+
".": "./dist/index.js",
|
|
11
|
+
"./server": "./dist/functions/get-content/index.js"
|
|
12
12
|
},
|
|
13
13
|
"scripts": {
|
|
14
|
-
"build
|
|
15
|
-
"build:types:sdk": "tsc -p ./tsconfig.sdk.json",
|
|
16
|
-
"build:types": "yarn build:types:sdk",
|
|
17
|
-
"build": "yarn build:types"
|
|
14
|
+
"build": "tsc"
|
|
18
15
|
},
|
|
19
16
|
"peerDependencies": {
|
|
20
17
|
"react": "^18.2.0"
|
|
21
18
|
},
|
|
22
19
|
"devDependencies": {
|
|
23
|
-
"@vitejs/plugin-react": "^4.0.0",
|
|
24
20
|
"react": "^18.2.0",
|
|
25
|
-
"
|
|
26
|
-
"typescript": "^4.9.4",
|
|
27
|
-
"vite": "^4.3.3",
|
|
28
|
-
"vite-plugin-dts": "^2.3.0"
|
|
21
|
+
"typescript": "^5.1.6"
|
|
29
22
|
}
|
|
30
23
|
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
type Column = {
|
|
3
|
-
blocks: BuilderBlock[];
|
|
4
|
-
width?: number;
|
|
5
|
-
};
|
|
6
|
-
type StackColumnsAt = "tablet" | "mobile" | "never";
|
|
7
|
-
export interface ColumnProps {
|
|
8
|
-
columns?: Column[];
|
|
9
|
-
builderBlock: BuilderBlock;
|
|
10
|
-
space?: number;
|
|
11
|
-
stackColumnsAt?: StackColumnsAt;
|
|
12
|
-
reverseColumnsWhenStacked?: boolean;
|
|
13
|
-
}
|
|
14
|
-
import type { BuilderBlock } from "../../types/builder-block";
|
|
15
|
-
declare function Columns(props: ColumnProps): JSX.Element;
|
|
16
|
-
export default Columns;
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
/**
|
|
3
|
-
* This component was copied over from the old SDKs and has a lot of code pointing to invalid functions/env vars. It needs
|
|
4
|
-
* to be cleaned up before the component can actually be usable.
|
|
5
|
-
*/
|
|
6
|
-
interface BuilderElement {
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* This component was copied over from the old SDKs and has a lot of code pointing to invalid functions/env vars. It needs
|
|
10
|
-
* to be cleaned up before the component can actually be usable.
|
|
11
|
-
*/
|
|
12
|
-
export interface FormProps {
|
|
13
|
-
attributes?: any;
|
|
14
|
-
name?: string;
|
|
15
|
-
action?: string;
|
|
16
|
-
validate?: boolean;
|
|
17
|
-
method?: string;
|
|
18
|
-
builderBlock?: BuilderElement;
|
|
19
|
-
sendSubmissionsTo?: string;
|
|
20
|
-
sendSubmissionsToEmail?: string;
|
|
21
|
-
sendWithJs?: boolean;
|
|
22
|
-
contentType?: string;
|
|
23
|
-
customHeaders?: {
|
|
24
|
-
[key: string]: string;
|
|
25
|
-
};
|
|
26
|
-
successUrl?: string;
|
|
27
|
-
previewState?: FormState;
|
|
28
|
-
successMessage?: BuilderElement[];
|
|
29
|
-
errorMessage?: BuilderElement[];
|
|
30
|
-
sendingMessage?: BuilderElement[];
|
|
31
|
-
resetFormOnSubmit?: boolean;
|
|
32
|
-
errorMessagePath?: string;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* This component was copied over from the old SDKs and has a lot of code pointing to invalid functions/env vars. It needs
|
|
36
|
-
* to be cleaned up before the component can actually be usable.
|
|
37
|
-
*/
|
|
38
|
-
export type FormState = "unsubmitted" | "sending" | "success" | "error";
|
|
39
|
-
declare function FormComponent(props: FormProps): JSX.Element;
|
|
40
|
-
export default FormComponent;
|
|
@@ -1,203 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import * as React from "react";
|
|
3
|
-
import { useState, useContext, useRef } from "react";
|
|
4
|
-
import RenderBlock from "../../components/render-block/render-block";
|
|
5
|
-
import BuilderBlocks from "../../components/render-blocks";
|
|
6
|
-
import { isEditing } from "../../functions/is-editing.js";
|
|
7
|
-
function FormComponent(props) {
|
|
8
|
-
const formRef = useRef(null);
|
|
9
|
-
const [formState, setFormState] = useState(() => "unsubmitted");
|
|
10
|
-
const [responseData, setResponseData] = useState(() => null);
|
|
11
|
-
const [formErrorMessage, setFormErrorMessage] = useState(() => "");
|
|
12
|
-
function submissionState() {
|
|
13
|
-
return (isEditing() && props.previewState) || formState;
|
|
14
|
-
}
|
|
15
|
-
function onSubmit(event) {
|
|
16
|
-
const sendWithJs = props.sendWithJs || props.sendSubmissionsTo === "email";
|
|
17
|
-
if (props.sendSubmissionsTo === "zapier") {
|
|
18
|
-
event.preventDefault();
|
|
19
|
-
}
|
|
20
|
-
else if (sendWithJs) {
|
|
21
|
-
if (!(props.action || props.sendSubmissionsTo === "email")) {
|
|
22
|
-
event.preventDefault();
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
event.preventDefault();
|
|
26
|
-
const el = event.currentTarget;
|
|
27
|
-
const headers = props.customHeaders || {};
|
|
28
|
-
let body;
|
|
29
|
-
const formData = new FormData(el);
|
|
30
|
-
// TODO: maybe support null
|
|
31
|
-
const formPairs = Array.from(event.currentTarget.querySelectorAll("input,select,textarea"))
|
|
32
|
-
.filter((el) => !!el.name)
|
|
33
|
-
.map((el) => {
|
|
34
|
-
let value;
|
|
35
|
-
const key = el.name;
|
|
36
|
-
if (el instanceof HTMLInputElement) {
|
|
37
|
-
if (el.type === "radio") {
|
|
38
|
-
if (el.checked) {
|
|
39
|
-
value = el.name;
|
|
40
|
-
return {
|
|
41
|
-
key,
|
|
42
|
-
value,
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
else if (el.type === "checkbox") {
|
|
47
|
-
value = el.checked;
|
|
48
|
-
}
|
|
49
|
-
else if (el.type === "number" || el.type === "range") {
|
|
50
|
-
const num = el.valueAsNumber;
|
|
51
|
-
if (!isNaN(num)) {
|
|
52
|
-
value = num;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
else if (el.type === "file") {
|
|
56
|
-
// TODO: one vs multiple files
|
|
57
|
-
value = el.files;
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
value = el.value;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
value = el.value;
|
|
65
|
-
}
|
|
66
|
-
return {
|
|
67
|
-
key,
|
|
68
|
-
value,
|
|
69
|
-
};
|
|
70
|
-
});
|
|
71
|
-
let contentType = props.contentType;
|
|
72
|
-
if (props.sendSubmissionsTo === "email") {
|
|
73
|
-
contentType = "multipart/form-data";
|
|
74
|
-
}
|
|
75
|
-
Array.from(formPairs).forEach(({ value }) => {
|
|
76
|
-
if (value instanceof File ||
|
|
77
|
-
(Array.isArray(value) && value[0] instanceof File) ||
|
|
78
|
-
value instanceof FileList) {
|
|
79
|
-
contentType = "multipart/form-data";
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
// TODO: send as urlEncoded or multipart by default
|
|
83
|
-
// because of ease of use and reliability in browser API
|
|
84
|
-
// for encoding the form?
|
|
85
|
-
if (contentType !== "application/json") {
|
|
86
|
-
body = formData;
|
|
87
|
-
}
|
|
88
|
-
else {
|
|
89
|
-
// Json
|
|
90
|
-
const json = {};
|
|
91
|
-
Array.from(formPairs).forEach(({ value, key }) => {
|
|
92
|
-
set(json, key, value);
|
|
93
|
-
});
|
|
94
|
-
body = JSON.stringify(json);
|
|
95
|
-
}
|
|
96
|
-
if (contentType && contentType !== "multipart/form-data") {
|
|
97
|
-
if (
|
|
98
|
-
/* Zapier doesn't allow content-type header to be sent from browsers */ !(sendWithJs && props.action?.includes("zapier.com"))) {
|
|
99
|
-
headers["content-type"] = contentType;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
const presubmitEvent = new CustomEvent("presubmit", { detail: { body } });
|
|
103
|
-
if (formRef.current) {
|
|
104
|
-
formRef.current.dispatchEvent(presubmitEvent);
|
|
105
|
-
if (presubmitEvent.defaultPrevented) {
|
|
106
|
-
return;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
setFormState("sending");
|
|
110
|
-
const formUrl = `${builder.env === "dev" ? "http://localhost:5000" : "https://builder.io"}/api/v1/form-submit?apiKey=${builder.apiKey}&to=${btoa(props.sendSubmissionsToEmail || "")}&name=${encodeURIComponent(props.name || "")}`;
|
|
111
|
-
fetch(props.sendSubmissionsTo === "email"
|
|
112
|
-
? formUrl
|
|
113
|
-
: props.action /* TODO: throw error if no action URL */, { body, headers, method: props.method || "post" }).then(async (res) => {
|
|
114
|
-
let body;
|
|
115
|
-
const contentType = res.headers.get("content-type");
|
|
116
|
-
if (contentType && contentType.indexOf("application/json") !== -1) {
|
|
117
|
-
body = await res.json();
|
|
118
|
-
}
|
|
119
|
-
else {
|
|
120
|
-
body = await res.text();
|
|
121
|
-
}
|
|
122
|
-
if (!res.ok && props.errorMessagePath) {
|
|
123
|
-
/* TODO: allow supplying an error formatter function */ let message = get(body, props.errorMessagePath);
|
|
124
|
-
if (message) {
|
|
125
|
-
if (typeof message !== "string") {
|
|
126
|
-
/* TODO: ideally convert json to yaml so it woul dbe like error: - email has been taken */ message =
|
|
127
|
-
JSON.stringify(message);
|
|
128
|
-
}
|
|
129
|
-
setFormErrorMessage(message);
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
setResponseData(body);
|
|
133
|
-
setFormState(res.ok ? "success" : "error");
|
|
134
|
-
if (res.ok) {
|
|
135
|
-
const submitSuccessEvent = new CustomEvent("submit:success", {
|
|
136
|
-
detail: { res, body },
|
|
137
|
-
});
|
|
138
|
-
if (formRef.current) {
|
|
139
|
-
formRef.current.dispatchEvent(submitSuccessEvent);
|
|
140
|
-
if (submitSuccessEvent.defaultPrevented) {
|
|
141
|
-
return;
|
|
142
|
-
}
|
|
143
|
-
/* TODO: option to turn this on/off? */ if (props.resetFormOnSubmit !== false) {
|
|
144
|
-
formRef.current.reset();
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
/* TODO: client side route event first that can be preventDefaulted */ if (props.successUrl) {
|
|
148
|
-
if (formRef.current) {
|
|
149
|
-
const event = new CustomEvent("route", {
|
|
150
|
-
detail: { url: props.successUrl },
|
|
151
|
-
});
|
|
152
|
-
formRef.current.dispatchEvent(event);
|
|
153
|
-
if (!event.defaultPrevented) {
|
|
154
|
-
location.href = props.successUrl;
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
else {
|
|
158
|
-
location.href = props.successUrl;
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
}, (err) => {
|
|
163
|
-
const submitErrorEvent = new CustomEvent("submit:error", {
|
|
164
|
-
detail: { error: err },
|
|
165
|
-
});
|
|
166
|
-
if (formRef.current) {
|
|
167
|
-
formRef.current.dispatchEvent(submitErrorEvent);
|
|
168
|
-
if (submitErrorEvent.defaultPrevented) {
|
|
169
|
-
return;
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
setResponseData(err);
|
|
173
|
-
setFormState("error");
|
|
174
|
-
});
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
const builderContext = useContext(BuilderContext);
|
|
178
|
-
return (React.createElement(React.Fragment, null,
|
|
179
|
-
" ",
|
|
180
|
-
React.createElement("form", { validate: props.validate, ref: formRef, action: !props.sendWithJs && props.action, method: props.method, name: props.name, onSubmit: (event) => onSubmit(event), ...props.attributes },
|
|
181
|
-
" ",
|
|
182
|
-
props.builderBlock && props.builderBlock.children ? (React.createElement(React.Fragment, null, props.builderBlock?.children?.map((block) => (React.createElement(RenderBlock, { block: block, context: builderContext }))))) : null,
|
|
183
|
-
" ",
|
|
184
|
-
submissionState() === "error" ? (React.createElement(React.Fragment, null,
|
|
185
|
-
React.createElement(BuilderBlocks, { dataPath: "errorMessage", blocks: props.errorMessage }))) : null,
|
|
186
|
-
" ",
|
|
187
|
-
submissionState() === "sending" ? (React.createElement(React.Fragment, null,
|
|
188
|
-
React.createElement(BuilderBlocks, { dataPath: "sendingMessage", blocks: props.sendingMessage }))) : null,
|
|
189
|
-
" ",
|
|
190
|
-
submissionState() === "error" && responseData ? (React.createElement(React.Fragment, null,
|
|
191
|
-
React.createElement("pre", { className: "builder-form-error-text pre-0217077c" },
|
|
192
|
-
" ",
|
|
193
|
-
JSON.stringify(responseData, null, 2),
|
|
194
|
-
" "))) : null,
|
|
195
|
-
" ",
|
|
196
|
-
submissionState() === "success" ? (React.createElement(React.Fragment, null,
|
|
197
|
-
React.createElement(BuilderBlocks, { dataPath: "successMessage", blocks: props.successMessage }))) : null,
|
|
198
|
-
" "),
|
|
199
|
-
" ",
|
|
200
|
-
React.createElement("style", null, `.pre-0217077c { padding: 10px; color: red; text-align: center; }`),
|
|
201
|
-
" "));
|
|
202
|
-
}
|
|
203
|
-
export default FormComponent;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import * as React from "react";
|
|
3
|
-
function RawText(props) {
|
|
4
|
-
return (React.createElement("span", { className: props.attributes?.class || props.attributes?.className, dangerouslySetInnerHTML: { __html: props.text || "" } }));
|
|
5
|
-
}
|
|
6
|
-
export default RawText;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
export interface SymbolInfo {
|
|
3
|
-
model?: string;
|
|
4
|
-
entry?: string;
|
|
5
|
-
data?: any;
|
|
6
|
-
content?: BuilderContent;
|
|
7
|
-
inline?: boolean;
|
|
8
|
-
dynamic?: boolean;
|
|
9
|
-
}
|
|
10
|
-
export interface SymbolProps {
|
|
11
|
-
symbol?: SymbolInfo;
|
|
12
|
-
dataOnly?: boolean;
|
|
13
|
-
dynamic?: boolean;
|
|
14
|
-
builderBlock?: BuilderBlock;
|
|
15
|
-
attributes?: any;
|
|
16
|
-
inheritState?: boolean;
|
|
17
|
-
}
|
|
18
|
-
import type { BuilderContent } from "../../types/builder-content.js";
|
|
19
|
-
import type { BuilderBlock } from "../../types/builder-block.js";
|
|
20
|
-
declare function Symbol(props: SymbolProps): JSX.Element;
|
|
21
|
-
export default Symbol;
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import * as React from "react";
|
|
3
|
-
import { useState, useContext, useEffect } from "react";
|
|
4
|
-
import RenderContentVariants from "../../components/render-content-variants/render-content-variants";
|
|
5
|
-
import BuilderContext from "../../context/builder.context.js";
|
|
6
|
-
import { getContent } from "../../functions/get-content/index.js";
|
|
7
|
-
import { TARGET } from "../../constants/target";
|
|
8
|
-
import { logger } from "../../helpers/logger";
|
|
9
|
-
function Symbol(props) {
|
|
10
|
-
const [className, setClassName] = useState(() => [
|
|
11
|
-
...(TARGET === "vue2" || TARGET === "vue3"
|
|
12
|
-
? Object.keys(props.attributes.class)
|
|
13
|
-
: [props.attributes.class]),
|
|
14
|
-
"builder-symbol",
|
|
15
|
-
props.symbol?.inline ? "builder-inline-symbol" : undefined,
|
|
16
|
-
props.symbol?.dynamic || props.dynamic
|
|
17
|
-
? "builder-dynamic-symbol"
|
|
18
|
-
: undefined,
|
|
19
|
-
]
|
|
20
|
-
.filter(Boolean)
|
|
21
|
-
.join(" "));
|
|
22
|
-
const [contentToUse, setContentToUse] = useState(() => props.symbol?.content);
|
|
23
|
-
function fetchContent() {
|
|
24
|
-
/**
|
|
25
|
-
* If:
|
|
26
|
-
* - we have a symbol prop
|
|
27
|
-
* - yet it does not have any content
|
|
28
|
-
* - and we have not already stored content from before
|
|
29
|
-
* - and it has a model name
|
|
30
|
-
*
|
|
31
|
-
* then we want to re-fetch the symbol content.
|
|
32
|
-
*/
|
|
33
|
-
if (!contentToUse &&
|
|
34
|
-
props.symbol?.model &&
|
|
35
|
-
// This is a hack, we should not need to check for this, but it is needed for Svelte.
|
|
36
|
-
builderContext?.apiKey) {
|
|
37
|
-
getContent({
|
|
38
|
-
model: props.symbol.model,
|
|
39
|
-
apiKey: builderContext.apiKey,
|
|
40
|
-
apiVersion: builderContext.apiVersion,
|
|
41
|
-
...(props.symbol?.entry && {
|
|
42
|
-
query: {
|
|
43
|
-
id: props.symbol.entry,
|
|
44
|
-
},
|
|
45
|
-
}),
|
|
46
|
-
})
|
|
47
|
-
.then((response) => {
|
|
48
|
-
if (response) {
|
|
49
|
-
setContentToUse(response);
|
|
50
|
-
}
|
|
51
|
-
})
|
|
52
|
-
.catch((err) => {
|
|
53
|
-
logger.error("Could not fetch symbol content: ", err);
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
const builderContext = useContext(BuilderContext);
|
|
58
|
-
useEffect(() => {
|
|
59
|
-
fetchContent();
|
|
60
|
-
}, []);
|
|
61
|
-
useEffect(() => {
|
|
62
|
-
fetchContent();
|
|
63
|
-
}, [props.symbol]);
|
|
64
|
-
return (React.createElement("div", { ...props.attributes, className: className },
|
|
65
|
-
React.createElement(RenderContentVariants, { __isNestedRender: true, apiVersion: builderContext.apiVersion, apiKey: builderContext.apiKey, context: builderContext.context, customComponents: Object.values(builderContext.registeredComponents), data: {
|
|
66
|
-
...props.symbol?.data,
|
|
67
|
-
...builderContext.localState,
|
|
68
|
-
...contentToUse?.data?.state,
|
|
69
|
-
}, model: props.symbol?.model, content: contentToUse })));
|
|
70
|
-
}
|
|
71
|
-
export default Symbol;
|
package/dist/sdk/blocks/util.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Input attributes that are functions must be converted to strings before being serialized to JSON.
|
|
3
|
-
*/
|
|
4
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
5
|
-
export const serializeFn = (fnValue) => {
|
|
6
|
-
const fnStr = fnValue.toString().trim();
|
|
7
|
-
// we need to account for a few different fn syntaxes:
|
|
8
|
-
// 1. `function name(args) => {code}`
|
|
9
|
-
// 2. `name(args) => {code}`
|
|
10
|
-
// 3. `(args) => {}`
|
|
11
|
-
const appendFunction = !fnStr.startsWith('function') && !fnStr.startsWith('(');
|
|
12
|
-
return `return (${appendFunction ? 'function ' : ''}${fnStr}).apply(this, arguments)`;
|
|
13
|
-
};
|
|
@@ -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;
|