@builder.io/sdk-react 0.2.3-4 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +72 -3
- package/dist/sdk/blocks/columns/columns.js +5 -5
- package/dist/sdk/blocks/image/image.js +8 -7
- package/dist/sdk/blocks/symbol/symbol.js +3 -2
- package/dist/sdk/blocks/video/video.js +4 -1
- package/dist/sdk/components/render-block/block-styles.js +3 -1
- package/dist/sdk/components/render-block/render-block.helpers.d.ts +0 -1
- package/dist/sdk/components/render-block/render-block.helpers.js +8 -20
- package/dist/sdk/components/render-block/render-block.js +24 -15
- package/dist/sdk/components/render-block/render-repeated-block.js +3 -2
- package/dist/sdk/components/render-content/render-content.js +31 -12
- package/dist/sdk/components/render-content-variants/helpers.d.ts +12 -0
- package/dist/sdk/components/render-content-variants/helpers.js +154 -0
- package/dist/sdk/components/render-content-variants/render-content-variants.d.ts +5 -0
- package/dist/sdk/components/render-content-variants/render-content-variants.js +29 -0
- package/dist/sdk/components/render-inlined-styles.js +2 -2
- package/dist/sdk/constants/sdk-version.d.ts +1 -0
- package/dist/sdk/constants/sdk-version.js +1 -0
- package/dist/sdk/context/builder.context.js +3 -2
- package/dist/sdk/context/types.d.ts +17 -2
- package/dist/sdk/functions/evaluate.d.ts +4 -3
- package/dist/sdk/functions/evaluate.js +23 -2
- package/dist/sdk/functions/evaluate.test.d.ts +1 -0
- package/dist/sdk/functions/evaluate.test.js +17 -0
- package/dist/sdk/functions/get-block-actions-handler.d.ts +1 -1
- package/dist/sdk/functions/get-block-actions-handler.js +3 -1
- package/dist/sdk/functions/get-block-actions.d.ts +1 -1
- package/dist/sdk/functions/get-processed-block.d.ts +2 -2
- package/dist/sdk/functions/get-processed-block.js +16 -4
- package/dist/sdk/functions/get-processed-block.test.js +3 -1
- package/dist/sdk/helpers/canTrack.d.ts +1 -0
- package/dist/sdk/helpers/canTrack.js +2 -0
- package/dist/sdk/index.d.ts +1 -0
- package/dist/sdk/scripts/init-editing.js +2 -0
- package/package.json +5 -5
- package/CHANGELOG.md +0 -25
- package/packages/react/src/blocks/BaseText.tsx +0 -19
- package/packages/react/src/blocks/button/button.tsx +0 -45
- package/packages/react/src/blocks/button/component-info.ts +0 -42
- package/packages/react/src/blocks/columns/columns.tsx +0 -211
- package/packages/react/src/blocks/columns/component-info.ts +0 -254
- package/packages/react/src/blocks/custom-code/component-info.ts +0 -31
- package/packages/react/src/blocks/custom-code/custom-code.tsx +0 -76
- package/packages/react/src/blocks/embed/component-info.ts +0 -55
- package/packages/react/src/blocks/embed/embed.tsx +0 -59
- package/packages/react/src/blocks/embed/helpers.ts +0 -8
- package/packages/react/src/blocks/form/component-info.ts +0 -282
- package/packages/react/src/blocks/form/form.tsx +0 -320
- package/packages/react/src/blocks/fragment/component-info.ts +0 -10
- package/packages/react/src/blocks/fragment/fragment.tsx +0 -14
- package/packages/react/src/blocks/image/component-info.ts +0 -172
- package/packages/react/src/blocks/image/image.helpers.ts +0 -75
- package/packages/react/src/blocks/image/image.tsx +0 -144
- package/packages/react/src/blocks/img/component-info.ts +0 -21
- package/packages/react/src/blocks/img/img.tsx +0 -40
- package/packages/react/src/blocks/input/component-info.ts +0 -78
- package/packages/react/src/blocks/input/input.tsx +0 -33
- package/packages/react/src/blocks/raw-text/component-info.ts +0 -15
- package/packages/react/src/blocks/raw-text/raw-text.tsx +0 -18
- package/packages/react/src/blocks/section/component-info.ts +0 -50
- package/packages/react/src/blocks/section/section.tsx +0 -33
- package/packages/react/src/blocks/select/component-info.ts +0 -61
- package/packages/react/src/blocks/select/select.tsx +0 -35
- package/packages/react/src/blocks/submit-button/component-info.ts +0 -32
- package/packages/react/src/blocks/submit-button/submit-button.tsx +0 -17
- package/packages/react/src/blocks/symbol/component-info.ts +0 -43
- package/packages/react/src/blocks/symbol/symbol.tsx +0 -111
- package/packages/react/src/blocks/text/component-info.ts +0 -24
- package/packages/react/src/blocks/text/text.tsx +0 -20
- package/packages/react/src/blocks/textarea/component-info.ts +0 -48
- package/packages/react/src/blocks/textarea/textarea.tsx +0 -24
- package/packages/react/src/blocks/util.ts +0 -18
- package/packages/react/src/blocks/video/component-info.ts +0 -109
- package/packages/react/src/blocks/video/video.tsx +0 -84
- package/packages/react/src/components/render-block/block-styles.tsx +0 -98
- package/packages/react/src/components/render-block/render-block.helpers.ts +0 -138
- package/packages/react/src/components/render-block/render-block.tsx +0 -216
- package/packages/react/src/components/render-block/render-component.tsx +0 -52
- package/packages/react/src/components/render-block/render-repeated-block.tsx +0 -43
- package/packages/react/src/components/render-block/types.ts +0 -7
- package/packages/react/src/components/render-blocks.tsx +0 -97
- package/packages/react/src/components/render-content/builder-editing.tsx +0 -8
- package/packages/react/src/components/render-content/components/render-styles.helpers.ts +0 -79
- package/packages/react/src/components/render-content/components/render-styles.tsx +0 -45
- package/packages/react/src/components/render-content/index.ts +0 -1
- package/packages/react/src/components/render-content/render-content.helpers.ts +0 -48
- package/packages/react/src/components/render-content/render-content.tsx +0 -410
- package/packages/react/src/components/render-content/render-content.types.ts +0 -33
- package/packages/react/src/components/render-inlined-styles.tsx +0 -36
- package/packages/react/src/constants/builder-registered-components.ts +0 -42
- package/packages/react/src/constants/device-sizes.ts +0 -65
- package/packages/react/src/constants/target.ts +0 -2
- package/packages/react/src/context/builder.context.ts +0 -12
- package/packages/react/src/context/types.ts +0 -26
- package/packages/react/src/functions/camel-to-kebab-case.ts +0 -2
- package/packages/react/src/functions/evaluate.ts +0 -57
- package/packages/react/src/functions/event-handler-name.ts +0 -6
- package/packages/react/src/functions/extract-text-styles.ts +0 -39
- package/packages/react/src/functions/fast-clone.ts +0 -5
- package/packages/react/src/functions/get-block-actions-handler.ts +0 -20
- package/packages/react/src/functions/get-block-actions.ts +0 -25
- package/packages/react/src/functions/get-block-component-options.ts +0 -12
- package/packages/react/src/functions/get-block-properties.ts +0 -75
- package/packages/react/src/functions/get-builder-search-params/fn.test.ts +0 -19
- package/packages/react/src/functions/get-builder-search-params/index.ts +0 -50
- package/packages/react/src/functions/get-content/ab-testing.ts +0 -132
- package/packages/react/src/functions/get-content/generate-content-url.test.ts +0 -95
- package/packages/react/src/functions/get-content/generate-content-url.ts +0 -59
- package/packages/react/src/functions/get-content/index.ts +0 -62
- package/packages/react/src/functions/get-content/types.ts +0 -53
- package/packages/react/src/functions/get-fetch.ts +0 -18
- package/packages/react/src/functions/get-global-this.ts +0 -17
- package/packages/react/src/functions/get-processed-block.test.ts +0 -33
- package/packages/react/src/functions/get-processed-block.ts +0 -54
- package/packages/react/src/functions/get-react-native-block-styles.ts +0 -33
- package/packages/react/src/functions/if-target.ts +0 -20
- package/packages/react/src/functions/is-browser.ts +0 -3
- package/packages/react/src/functions/is-editing.ts +0 -10
- package/packages/react/src/functions/is-iframe.ts +0 -5
- package/packages/react/src/functions/is-previewing.ts +0 -14
- package/packages/react/src/functions/on-change.test.ts +0 -23
- package/packages/react/src/functions/on-change.ts +0 -29
- package/packages/react/src/functions/register-component.ts +0 -50
- package/packages/react/src/functions/register.ts +0 -46
- package/packages/react/src/functions/sanitize-react-native-block-styles.ts +0 -65
- package/packages/react/src/functions/set-editor-settings.ts +0 -16
- package/packages/react/src/functions/set.test.ts +0 -19
- package/packages/react/src/functions/set.ts +0 -26
- package/packages/react/src/functions/track/helpers.ts +0 -67
- package/packages/react/src/functions/track/index.ts +0 -136
- package/packages/react/src/functions/track/interaction.ts +0 -80
- package/packages/react/src/functions/transform-block-properties.ts +0 -3
- package/packages/react/src/functions/transform-block.ts +0 -6
- package/packages/react/src/helpers/ab-tests.ts +0 -22
- package/packages/react/src/helpers/cookie.ts +0 -107
- package/packages/react/src/helpers/css.ts +0 -42
- package/packages/react/src/helpers/flatten.ts +0 -24
- package/packages/react/src/helpers/localStorage.ts +0 -40
- package/packages/react/src/helpers/logger.ts +0 -6
- package/packages/react/src/helpers/nullable.ts +0 -4
- package/packages/react/src/helpers/sessionId.ts +0 -38
- package/packages/react/src/helpers/time.ts +0 -4
- package/packages/react/src/helpers/url.test.ts +0 -23
- package/packages/react/src/helpers/url.ts +0 -16
- package/packages/react/src/helpers/uuid.ts +0 -17
- package/packages/react/src/helpers/visitorId.ts +0 -40
- package/packages/react/src/index-helpers/blocks-exports.ts +0 -10
- package/packages/react/src/index-helpers/top-of-file.ts +0 -4
- package/packages/react/src/index.ts +0 -14
- package/packages/react/src/scripts/init-editing.ts +0 -123
- package/packages/react/src/types/api-version.ts +0 -2
- package/packages/react/src/types/builder-block.ts +0 -69
- package/packages/react/src/types/builder-content.ts +0 -46
- package/packages/react/src/types/can-track.ts +0 -3
- package/packages/react/src/types/components.ts +0 -117
- package/packages/react/src/types/deep-partial.ts +0 -7
- package/packages/react/src/types/element.ts +0 -60
- package/packages/react/src/types/input.ts +0 -125
- package/packages/react/src/types/targets.ts +0 -6
- package/packages/react/src/types/typescript.ts +0 -7
- package/packages/rsc/src/blocks/BaseText.jsx +0 -12
- package/packages/rsc/src/blocks/button/button.jsx +0 -37
- package/packages/rsc/src/blocks/button/component-info.js +0 -40
- package/packages/rsc/src/blocks/columns/columns.jsx +0 -172
- package/packages/rsc/src/blocks/columns/component-info.js +0 -241
- package/packages/rsc/src/blocks/custom-code/component-info.js +0 -30
- package/packages/rsc/src/blocks/custom-code/custom-code.jsx +0 -57
- package/packages/rsc/src/blocks/embed/component-info.js +0 -43
- package/packages/rsc/src/blocks/embed/embed.jsx +0 -45
- package/packages/rsc/src/blocks/embed/helpers.js +0 -9
- package/packages/rsc/src/blocks/form/component-info.js +0 -261
- package/packages/rsc/src/blocks/form/form.jsx +0 -260
- package/packages/rsc/src/blocks/fragment/component-info.js +0 -10
- package/packages/rsc/src/blocks/fragment/fragment.jsx +0 -9
- package/packages/rsc/src/blocks/image/component-info.js +0 -150
- package/packages/rsc/src/blocks/image/image.helpers.js +0 -48
- package/packages/rsc/src/blocks/image/image.jsx +0 -122
- package/packages/rsc/src/blocks/img/component-info.js +0 -19
- package/packages/rsc/src/blocks/img/img.jsx +0 -21
- package/packages/rsc/src/blocks/input/component-info.js +0 -73
- package/packages/rsc/src/blocks/input/input.jsx +0 -23
- package/packages/rsc/src/blocks/raw-text/component-info.js +0 -15
- package/packages/rsc/src/blocks/raw-text/raw-text.jsx +0 -14
- package/packages/rsc/src/blocks/section/component-info.js +0 -48
- package/packages/rsc/src/blocks/section/section.jsx +0 -27
- package/packages/rsc/src/blocks/select/component-info.js +0 -58
- package/packages/rsc/src/blocks/select/select.jsx +0 -24
- package/packages/rsc/src/blocks/submit-button/component-info.js +0 -27
- package/packages/rsc/src/blocks/submit-button/submit-button.jsx +0 -13
- package/packages/rsc/src/blocks/symbol/component-info.js +0 -42
- package/packages/rsc/src/blocks/symbol/symbol.jsx +0 -89
- package/packages/rsc/src/blocks/text/component-info.js +0 -23
- package/packages/rsc/src/blocks/text/text.jsx +0 -17
- package/packages/rsc/src/blocks/textarea/component-info.js +0 -46
- package/packages/rsc/src/blocks/textarea/textarea.jsx +0 -17
- package/packages/rsc/src/blocks/util.js +0 -8
- package/packages/rsc/src/blocks/video/component-info.js +0 -105
- package/packages/rsc/src/blocks/video/video.jsx +0 -63
- package/packages/rsc/src/components/render-block/block-styles.jsx +0 -88
- package/packages/rsc/src/components/render-block/render-block.helpers.js +0 -129
- package/packages/rsc/src/components/render-block/render-block.jsx +0 -201
- package/packages/rsc/src/components/render-block/render-component.jsx +0 -39
- package/packages/rsc/src/components/render-block/render-repeated-block.jsx +0 -27
- package/packages/rsc/src/components/render-block/types.js +0 -0
- package/packages/rsc/src/components/render-blocks.jsx +0 -92
- package/packages/rsc/src/components/render-content/builder-editing.jsx +0 -64
- package/packages/rsc/src/components/render-content/components/render-styles.helpers.js +0 -57
- package/packages/rsc/src/components/render-content/components/render-styles.jsx +0 -39
- package/packages/rsc/src/components/render-content/index.js +0 -4
- package/packages/rsc/src/components/render-content/render-content.helpers.js +0 -48
- package/packages/rsc/src/components/render-content/render-content.jsx +0 -253
- package/packages/rsc/src/components/render-content/render-content.types.js +0 -0
- package/packages/rsc/src/components/render-inlined-styles.jsx +0 -33
- package/packages/rsc/src/constants/builder-registered-components.js +0 -54
- package/packages/rsc/src/constants/device-sizes.js +0 -48
- package/packages/rsc/src/constants/target.js +0 -4
- package/packages/rsc/src/context/builder.context.js +0 -14
- package/packages/rsc/src/context/types.js +0 -0
- package/packages/rsc/src/functions/camel-to-kebab-case.js +0 -4
- package/packages/rsc/src/functions/evaluate.js +0 -6
- package/packages/rsc/src/functions/event-handler-name.js +0 -7
- package/packages/rsc/src/functions/extract-text-styles.js +0 -22
- package/packages/rsc/src/functions/fast-clone.js +0 -4
- package/packages/rsc/src/functions/get-block-actions-handler.js +0 -11
- package/packages/rsc/src/functions/get-block-actions.js +0 -18
- package/packages/rsc/src/functions/get-block-component-options.js +0 -28
- package/packages/rsc/src/functions/get-block-properties.js +0 -53
- package/packages/rsc/src/functions/get-builder-search-params/fn.test.js +0 -13
- package/packages/rsc/src/functions/get-builder-search-params/index.js +0 -38
- package/packages/rsc/src/functions/get-content/ab-testing.js +0 -99
- package/packages/rsc/src/functions/get-content/generate-content-url.js +0 -60
- package/packages/rsc/src/functions/get-content/generate-content-url.test.js +0 -82
- package/packages/rsc/src/functions/get-content/index.js +0 -83
- package/packages/rsc/src/functions/get-content/types.js +0 -0
- package/packages/rsc/src/functions/get-fetch.js +0 -14
- package/packages/rsc/src/functions/get-global-this.js +0 -18
- package/packages/rsc/src/functions/get-processed-block.js +0 -59
- package/packages/rsc/src/functions/get-processed-block.test.js +0 -32
- package/packages/rsc/src/functions/get-react-native-block-styles.js +0 -33
- package/packages/rsc/src/functions/if-target.js +0 -15
- package/packages/rsc/src/functions/is-browser.js +0 -6
- package/packages/rsc/src/functions/is-editing.js +0 -8
- package/packages/rsc/src/functions/is-iframe.js +0 -7
- package/packages/rsc/src/functions/is-previewing.js +0 -14
- package/packages/rsc/src/functions/on-change.js +0 -27
- package/packages/rsc/src/functions/on-change.test.js +0 -19
- package/packages/rsc/src/functions/register-component.js +0 -68
- package/packages/rsc/src/functions/register.js +0 -29
- package/packages/rsc/src/functions/sanitize-react-native-block-styles.js +0 -66
- package/packages/rsc/src/functions/set-editor-settings.js +0 -15
- package/packages/rsc/src/functions/set.js +0 -11
- package/packages/rsc/src/functions/set.test.js +0 -16
- package/packages/rsc/src/functions/track/helpers.js +0 -50
- package/packages/rsc/src/functions/track/index.js +0 -129
- package/packages/rsc/src/functions/track/interaction.js +0 -53
- package/packages/rsc/src/functions/transform-block-properties.js +0 -6
- package/packages/rsc/src/functions/transform-block.js +0 -6
- package/packages/rsc/src/helpers/ab-tests.js +0 -16
- package/packages/rsc/src/helpers/cookie.js +0 -81
- package/packages/rsc/src/helpers/css.js +0 -34
- package/packages/rsc/src/helpers/flatten.js +0 -34
- package/packages/rsc/src/helpers/localStorage.js +0 -35
- package/packages/rsc/src/helpers/logger.js +0 -9
- package/packages/rsc/src/helpers/nullable.js +0 -4
- package/packages/rsc/src/helpers/sessionId.js +0 -52
- package/packages/rsc/src/helpers/time.js +0 -5
- package/packages/rsc/src/helpers/url.js +0 -13
- package/packages/rsc/src/helpers/url.test.js +0 -21
- package/packages/rsc/src/helpers/uuid.js +0 -13
- package/packages/rsc/src/helpers/visitorId.js +0 -34
- package/packages/rsc/src/index-helpers/blocks-exports.js +0 -22
- package/packages/rsc/src/index-helpers/top-of-file.js +0 -2
- package/packages/rsc/src/index.js +0 -13
- package/packages/rsc/src/scripts/init-editing.js +0 -93
- package/packages/rsc/src/types/api-version.js +0 -4
- package/packages/rsc/src/types/builder-block.js +0 -0
- package/packages/rsc/src/types/builder-content.js +0 -0
- package/packages/rsc/src/types/can-track.js +0 -0
- package/packages/rsc/src/types/components.js +0 -0
- package/packages/rsc/src/types/deep-partial.js +0 -0
- package/packages/rsc/src/types/element.js +0 -0
- package/packages/rsc/src/types/input.js +0 -0
- package/packages/rsc/src/types/targets.js +0 -0
- package/packages/rsc/src/types/typescript.js +0 -0
- package/tsconfig.json +0 -28
- package/tsconfig.sdk.json +0 -10
- package/tsconfig.server.json +0 -10
- package/vite.config.ts +0 -91
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export { default as Button } from '../blocks/button/button';
|
|
2
|
-
export { default as Columns } from '../blocks/columns/columns';
|
|
3
|
-
export { default as Fragment } from '../blocks/fragment/fragment';
|
|
4
|
-
export { default as Image } from '../blocks/image/image';
|
|
5
|
-
export { default as RenderBlocks } from '../components/render-blocks';
|
|
6
|
-
export { default as RenderContent } from '../components/render-content/render-content';
|
|
7
|
-
export { default as Section } from '../blocks/section/section';
|
|
8
|
-
export { default as Symbol } from '../blocks/symbol/symbol';
|
|
9
|
-
export { default as Text } from '../blocks/text/text';
|
|
10
|
-
export { default as Video } from '../blocks/video/video';
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export * from './index-helpers/top-of-file.js';
|
|
2
|
-
|
|
3
|
-
export * from './index-helpers/blocks-exports.js';
|
|
4
|
-
|
|
5
|
-
export * from './functions/is-editing.js';
|
|
6
|
-
export * from './functions/is-previewing.js';
|
|
7
|
-
export * from './functions/register-component.js';
|
|
8
|
-
export * from './functions/register.js';
|
|
9
|
-
export * from './functions/set-editor-settings.js';
|
|
10
|
-
export * from './functions/get-content/index.js';
|
|
11
|
-
export * from './functions/get-builder-search-params/index.js';
|
|
12
|
-
export { track } from './functions/track/index.js';
|
|
13
|
-
export type { RegisteredComponent } from './context/types';
|
|
14
|
-
export type { ComponentInfo } from './types/components';
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import { TARGET } from '../constants/target.js';
|
|
2
|
-
import { isBrowser } from '../functions/is-browser.js';
|
|
3
|
-
import { register } from '../functions/register.js';
|
|
4
|
-
|
|
5
|
-
export const registerInsertMenu = () => {
|
|
6
|
-
register('insertMenu', {
|
|
7
|
-
name: '_default',
|
|
8
|
-
default: true,
|
|
9
|
-
items: [
|
|
10
|
-
{ name: 'Box' },
|
|
11
|
-
{ name: 'Text' },
|
|
12
|
-
{ name: 'Image' },
|
|
13
|
-
{ name: 'Columns' },
|
|
14
|
-
...(TARGET === 'reactNative'
|
|
15
|
-
? []
|
|
16
|
-
: [
|
|
17
|
-
{ name: 'Core:Section' },
|
|
18
|
-
{ name: 'Core:Button' },
|
|
19
|
-
{ name: 'Embed' },
|
|
20
|
-
{ name: 'Custom Code' },
|
|
21
|
-
]),
|
|
22
|
-
],
|
|
23
|
-
});
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
let isSetupForEditing = false;
|
|
27
|
-
export const setupBrowserForEditing = (
|
|
28
|
-
options: {
|
|
29
|
-
includeRefs?: boolean;
|
|
30
|
-
locale?: string;
|
|
31
|
-
} = {}
|
|
32
|
-
) => {
|
|
33
|
-
if (isSetupForEditing) {
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
isSetupForEditing = true;
|
|
37
|
-
if (isBrowser()) {
|
|
38
|
-
window.parent?.postMessage(
|
|
39
|
-
{
|
|
40
|
-
type: 'builder.sdkInfo',
|
|
41
|
-
data: {
|
|
42
|
-
target: TARGET,
|
|
43
|
-
// TODO: compile these in
|
|
44
|
-
// type: process.env.SDK_TYPE,
|
|
45
|
-
// version: process.env.SDK_VERSION,
|
|
46
|
-
supportsPatchUpdates: false,
|
|
47
|
-
// Supports builder-model="..." attribute which is needed to
|
|
48
|
-
// scope our '+ add block' button styling
|
|
49
|
-
supportsAddBlockScoping: true,
|
|
50
|
-
supportsCustomBreakpoints: true,
|
|
51
|
-
},
|
|
52
|
-
},
|
|
53
|
-
'*'
|
|
54
|
-
);
|
|
55
|
-
|
|
56
|
-
window.parent?.postMessage(
|
|
57
|
-
{
|
|
58
|
-
type: 'builder.updateContent',
|
|
59
|
-
data: {
|
|
60
|
-
options,
|
|
61
|
-
},
|
|
62
|
-
},
|
|
63
|
-
'*'
|
|
64
|
-
);
|
|
65
|
-
|
|
66
|
-
window.addEventListener('message', ({ data }) => {
|
|
67
|
-
if (!data?.type) {
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
switch (data.type) {
|
|
72
|
-
case 'builder.evaluate': {
|
|
73
|
-
const text = data.data.text;
|
|
74
|
-
const args = data.data.arguments || [];
|
|
75
|
-
const id = data.data.id;
|
|
76
|
-
// tslint:disable-next-line:no-function-constructor-with-string-args
|
|
77
|
-
const fn = new Function(text);
|
|
78
|
-
let result: any;
|
|
79
|
-
let error: Error | null = null;
|
|
80
|
-
try {
|
|
81
|
-
// eslint-disable-next-line prefer-spread
|
|
82
|
-
result = fn.apply(null, args);
|
|
83
|
-
} catch (err) {
|
|
84
|
-
error = err as Error;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
if (error) {
|
|
88
|
-
window.parent?.postMessage(
|
|
89
|
-
{
|
|
90
|
-
type: 'builder.evaluateError',
|
|
91
|
-
data: { id, error: error.message },
|
|
92
|
-
},
|
|
93
|
-
'*'
|
|
94
|
-
);
|
|
95
|
-
} else {
|
|
96
|
-
if (result && typeof result.then === 'function') {
|
|
97
|
-
(result as Promise<any>)
|
|
98
|
-
.then((finalResult) => {
|
|
99
|
-
window.parent?.postMessage(
|
|
100
|
-
{
|
|
101
|
-
type: 'builder.evaluateResult',
|
|
102
|
-
data: { id, result: finalResult },
|
|
103
|
-
},
|
|
104
|
-
'*'
|
|
105
|
-
);
|
|
106
|
-
})
|
|
107
|
-
.catch(console.error);
|
|
108
|
-
} else {
|
|
109
|
-
window.parent?.postMessage(
|
|
110
|
-
{
|
|
111
|
-
type: 'builder.evaluateResult',
|
|
112
|
-
data: { result, id },
|
|
113
|
-
},
|
|
114
|
-
'*'
|
|
115
|
-
);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
break;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
};
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
type JSONValue = string | number | boolean | JSONObject | JSONArray;
|
|
2
|
-
|
|
3
|
-
interface JSONObject {
|
|
4
|
-
[x: string]: JSONValue;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
interface JSONArray extends Array<JSONValue> {}
|
|
8
|
-
|
|
9
|
-
/** @todo typedoc this */
|
|
10
|
-
export interface BuilderBlock {
|
|
11
|
-
'@type': '@builder.io/sdk:Element';
|
|
12
|
-
'@version'?: number;
|
|
13
|
-
id?: string;
|
|
14
|
-
tagName?: string;
|
|
15
|
-
layerName?: string;
|
|
16
|
-
groupLocked?: boolean;
|
|
17
|
-
layerLocked?: boolean;
|
|
18
|
-
/** @todo make alias for properties.class */
|
|
19
|
-
class?: string;
|
|
20
|
-
children?: BuilderBlock[];
|
|
21
|
-
responsiveStyles?: {
|
|
22
|
-
large?: Partial<CSSStyleDeclaration>;
|
|
23
|
-
medium?: Partial<CSSStyleDeclaration>;
|
|
24
|
-
small?: Partial<CSSStyleDeclaration>;
|
|
25
|
-
/** @deprecated */
|
|
26
|
-
xsmall?: Partial<CSSStyleDeclaration>;
|
|
27
|
-
};
|
|
28
|
-
component?: {
|
|
29
|
-
name: string;
|
|
30
|
-
options?: any;
|
|
31
|
-
tag?: string;
|
|
32
|
-
};
|
|
33
|
-
bindings?: {
|
|
34
|
-
[key: string]: string;
|
|
35
|
-
};
|
|
36
|
-
meta?: {
|
|
37
|
-
[key: string]: JSONValue;
|
|
38
|
-
};
|
|
39
|
-
actions?: {
|
|
40
|
-
[key: string]: string;
|
|
41
|
-
};
|
|
42
|
-
properties?: {
|
|
43
|
-
[key: string]: string;
|
|
44
|
-
};
|
|
45
|
-
code?: {
|
|
46
|
-
bindings?: {
|
|
47
|
-
[key: string]: string;
|
|
48
|
-
};
|
|
49
|
-
actions?: {
|
|
50
|
-
[key: string]: string;
|
|
51
|
-
};
|
|
52
|
-
};
|
|
53
|
-
repeat?: {
|
|
54
|
-
collection: string;
|
|
55
|
-
itemName?: string;
|
|
56
|
-
} | null;
|
|
57
|
-
animations?: any[]; // TODO: type the animation spec
|
|
58
|
-
style?: Partial<CSSStyleDeclaration>;
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* generated by the "Hide If" binding
|
|
62
|
-
*/
|
|
63
|
-
hide?: boolean;
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* generated by the "Show If" binding
|
|
67
|
-
*/
|
|
68
|
-
show?: boolean;
|
|
69
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import type { BuilderBlock } from './builder-block.js';
|
|
2
|
-
import type { Input } from './input.js';
|
|
3
|
-
import type { Nullable } from './typescript.js';
|
|
4
|
-
|
|
5
|
-
export interface Breakpoints {
|
|
6
|
-
small: number;
|
|
7
|
-
medium: number;
|
|
8
|
-
}
|
|
9
|
-
export interface BuilderContentVariation {
|
|
10
|
-
data?: {
|
|
11
|
-
title?: string;
|
|
12
|
-
blocks?: BuilderBlock[];
|
|
13
|
-
inputs?: Input[];
|
|
14
|
-
state?: { [key: string]: any };
|
|
15
|
-
jsCode?: string;
|
|
16
|
-
tsCode?: string;
|
|
17
|
-
httpRequests?: { [key: string]: string };
|
|
18
|
-
[key: string]: any;
|
|
19
|
-
};
|
|
20
|
-
name?: string;
|
|
21
|
-
testRatio?: number;
|
|
22
|
-
id?: string;
|
|
23
|
-
meta?: {
|
|
24
|
-
breakpoints?: Nullable<Breakpoints>;
|
|
25
|
-
[key: string]: any;
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// TODO: separate full and partial versions
|
|
30
|
-
export interface BuilderContent extends BuilderContentVariation {
|
|
31
|
-
// TODO: query
|
|
32
|
-
'@version'?: number;
|
|
33
|
-
id?: string;
|
|
34
|
-
name?: string;
|
|
35
|
-
published?: 'published' | 'draft' | 'archived';
|
|
36
|
-
modelId?: string;
|
|
37
|
-
priority?: number;
|
|
38
|
-
lastUpdated?: number;
|
|
39
|
-
startDate?: number;
|
|
40
|
-
endDate?: number;
|
|
41
|
-
variations?: {
|
|
42
|
-
[id: string]: BuilderContentVariation | undefined;
|
|
43
|
-
};
|
|
44
|
-
testVariationId?: string;
|
|
45
|
-
testVariationName?: string;
|
|
46
|
-
}
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import type { BuilderElement } from './element';
|
|
2
|
-
import type { Input } from './input';
|
|
3
|
-
|
|
4
|
-
export interface ComponentInfo {
|
|
5
|
-
/**
|
|
6
|
-
* Name your component something unique, e.g. 'MyButton'. You can override built-in components
|
|
7
|
-
* by registering a component with the same name, e.g. 'Text', to replace the built-in text component
|
|
8
|
-
*/
|
|
9
|
-
name: string;
|
|
10
|
-
description?: string;
|
|
11
|
-
/**
|
|
12
|
-
* Link to a documentation page for this component
|
|
13
|
-
*/
|
|
14
|
-
docsLink?: string;
|
|
15
|
-
image?: string;
|
|
16
|
-
/**
|
|
17
|
-
* Input schema for your component for users to fill in the options
|
|
18
|
-
*/
|
|
19
|
-
inputs?: Input[];
|
|
20
|
-
class?: any;
|
|
21
|
-
type?: 'angular' | 'webcomponent' | 'react' | 'vue';
|
|
22
|
-
defaultStyles?: { [key: string]: string };
|
|
23
|
-
/**
|
|
24
|
-
* Turn on if your component can accept children. Be sure to use in combination with
|
|
25
|
-
* withChildren(YourComponent) like here
|
|
26
|
-
* github.com/BuilderIO/builder/blob/master/examples/react-design-system/src/components/HeroWithChildren/HeroWithChildren.builder.js#L5
|
|
27
|
-
*/
|
|
28
|
-
canHaveChildren?: boolean;
|
|
29
|
-
fragment?: boolean;
|
|
30
|
-
/**
|
|
31
|
-
* Do not wrap a component in a dom element. Be sure to use {...props.attributes} with this option
|
|
32
|
-
* like here github.com/BuilderIO/builder/blob/master/packages/react/src/blocks/forms/Input.tsx#L34
|
|
33
|
-
*/
|
|
34
|
-
noWrap?: boolean;
|
|
35
|
-
/**
|
|
36
|
-
* Default children
|
|
37
|
-
*/
|
|
38
|
-
defaultChildren?: BuilderElement[];
|
|
39
|
-
defaults?: Partial<BuilderElement>;
|
|
40
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
41
|
-
hooks?: { [key: string]: string | Function };
|
|
42
|
-
/**
|
|
43
|
-
* Hide your component in editor, useful for gradually deprecating components
|
|
44
|
-
*/
|
|
45
|
-
hideFromInsertMenu?: boolean;
|
|
46
|
-
// For webcomponents
|
|
47
|
-
tag?: string;
|
|
48
|
-
static?: boolean;
|
|
49
|
-
/**
|
|
50
|
-
* Passing a list of model names will restrict using the component to only the models listed here, otherwise it'll be available for all models
|
|
51
|
-
*/
|
|
52
|
-
models?: string[];
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Specify restrictions direct children must match
|
|
56
|
-
*/
|
|
57
|
-
childRequirements?: {
|
|
58
|
-
/** Message to show when this doesn't match, e.g. "Children of 'Columns' must be a 'Column'" */
|
|
59
|
-
message: string;
|
|
60
|
-
/** Simple way to say children must be a specific component name */
|
|
61
|
-
component?: string;
|
|
62
|
-
/**
|
|
63
|
-
* More advanced - specify a MongoDB-style query (using sift.js github.com/crcn/sift.js)
|
|
64
|
-
* of what the children objects should match, e.g.
|
|
65
|
-
*
|
|
66
|
-
* @example
|
|
67
|
-
* query: {
|
|
68
|
-
* // Child of this element must be a 'Button' or 'Text' component
|
|
69
|
-
* 'component.name': { $in: ['Button', 'Text'] }
|
|
70
|
-
* }
|
|
71
|
-
*/
|
|
72
|
-
query?: any;
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Specify restrictions any parent must match
|
|
77
|
-
*/
|
|
78
|
-
requiresParent?: {
|
|
79
|
-
/** Message to show when this doesn't match, e.g. "'Add to cart' buttons must be within a 'Product box'" */
|
|
80
|
-
message: string;
|
|
81
|
-
/** Simple way to say a parent must be a specific component name, e.g. 'Product box' */
|
|
82
|
-
component?: string;
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* More advanced - specify a MongoDB-style query (using sift.js github.com/crcn/sift.js)
|
|
86
|
-
* of what at least one parent in the parents hierarchy should match, e.g.
|
|
87
|
-
*
|
|
88
|
-
* @example
|
|
89
|
-
* query: {
|
|
90
|
-
* // Thils element must be somewhere inside either a 'Product box' or 'Collection' component
|
|
91
|
-
* 'component.name': { $in: ['Product Box', 'Collection'] }
|
|
92
|
-
* }
|
|
93
|
-
*/
|
|
94
|
-
query?: any;
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
/** not yet implemented */
|
|
98
|
-
friendlyName?: string;
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* Use to restrict access to your component based on a the current user permissions
|
|
102
|
-
* By default components will show to all users
|
|
103
|
-
* for more information on permissions in builder check https://www.builder.io/c/docs/guides/roles-and-permissions
|
|
104
|
-
*/
|
|
105
|
-
requiredPermissions?: Array<Permission>;
|
|
106
|
-
|
|
107
|
-
// TO-DO: is this used?
|
|
108
|
-
hidden?: boolean;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
type Permission =
|
|
112
|
-
| 'read'
|
|
113
|
-
| 'publish'
|
|
114
|
-
| 'editCode'
|
|
115
|
-
| 'editDesigns'
|
|
116
|
-
| 'admin'
|
|
117
|
-
| 'create';
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
type JSONValue = string | number | boolean | JSONObject | JSONArray;
|
|
2
|
-
|
|
3
|
-
interface JSONObject {
|
|
4
|
-
[x: string]: JSONValue;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
interface JSONArray extends Array<JSONValue> {}
|
|
8
|
-
|
|
9
|
-
/** @todo typedoc this */
|
|
10
|
-
export interface BuilderElement {
|
|
11
|
-
'@type': '@builder.io/sdk:Element';
|
|
12
|
-
'@version'?: number;
|
|
13
|
-
id?: string;
|
|
14
|
-
tagName?: string;
|
|
15
|
-
layerName?: string;
|
|
16
|
-
groupLocked?: boolean;
|
|
17
|
-
layerLocked?: boolean;
|
|
18
|
-
/** @todo make alias for properties.class */
|
|
19
|
-
class?: string;
|
|
20
|
-
children?: BuilderElement[];
|
|
21
|
-
responsiveStyles?: {
|
|
22
|
-
large?: Partial<CSSStyleDeclaration>;
|
|
23
|
-
medium?: Partial<CSSStyleDeclaration>;
|
|
24
|
-
small?: Partial<CSSStyleDeclaration>;
|
|
25
|
-
/** @deprecated */
|
|
26
|
-
xsmall?: Partial<CSSStyleDeclaration>;
|
|
27
|
-
};
|
|
28
|
-
component?: {
|
|
29
|
-
name: string;
|
|
30
|
-
options?: any;
|
|
31
|
-
tag?: string;
|
|
32
|
-
};
|
|
33
|
-
bindings?: {
|
|
34
|
-
[key: string]: string;
|
|
35
|
-
};
|
|
36
|
-
meta?: {
|
|
37
|
-
[key: string]: JSONValue;
|
|
38
|
-
};
|
|
39
|
-
actions?: {
|
|
40
|
-
[key: string]: string;
|
|
41
|
-
};
|
|
42
|
-
properties?: {
|
|
43
|
-
[key: string]: string;
|
|
44
|
-
};
|
|
45
|
-
code?: {
|
|
46
|
-
bindings?: {
|
|
47
|
-
[key: string]: string;
|
|
48
|
-
};
|
|
49
|
-
actions?: {
|
|
50
|
-
[key: string]: string;
|
|
51
|
-
};
|
|
52
|
-
};
|
|
53
|
-
repeat?: {
|
|
54
|
-
collection: string;
|
|
55
|
-
itemName?: string;
|
|
56
|
-
} | null;
|
|
57
|
-
animations?: Animation[]; // TODO: type the animation spec
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
interface Animation {}
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
export interface Input {
|
|
2
|
-
/** This is the name of the component prop this input represents */
|
|
3
|
-
name: string;
|
|
4
|
-
/** A friendlier name to show in the UI if the component prop name is not ideal for end users */
|
|
5
|
-
friendlyName?: string;
|
|
6
|
-
/** @hidden @deprecated */
|
|
7
|
-
description?: string;
|
|
8
|
-
/** A default value to use */
|
|
9
|
-
defaultValue?: any;
|
|
10
|
-
/**
|
|
11
|
-
* The type of input to use, such as 'text'
|
|
12
|
-
*
|
|
13
|
-
* See all available inputs [here](https://www.builder.io/c/docs/custom-react-components#input-types)
|
|
14
|
-
* and you can create your own custom input types and associated editor UIs with [plugins](https://www.builder.io/c/docs/extending/plugins)
|
|
15
|
-
*/
|
|
16
|
-
type: string;
|
|
17
|
-
/** Is this input mandatory or not */
|
|
18
|
-
required?: boolean;
|
|
19
|
-
/** @hidden */
|
|
20
|
-
autoFocus?: boolean;
|
|
21
|
-
subFields?: Input[];
|
|
22
|
-
/**
|
|
23
|
-
* Additional text to render in the UI to give guidance on how to use this
|
|
24
|
-
*
|
|
25
|
-
* @example
|
|
26
|
-
* ```js
|
|
27
|
-
* helperText: 'Be sure to use a proper URL, starting with "https://"'
|
|
28
|
-
* 111
|
|
29
|
-
*/
|
|
30
|
-
helperText?: string;
|
|
31
|
-
/** @hidden */
|
|
32
|
-
allowedFileTypes?: string[];
|
|
33
|
-
/** @hidden */
|
|
34
|
-
imageHeight?: number;
|
|
35
|
-
/** @hidden */
|
|
36
|
-
imageWidth?: number;
|
|
37
|
-
/** @hidden */
|
|
38
|
-
mediaHeight?: number;
|
|
39
|
-
/** @hidden */
|
|
40
|
-
mediaWidth?: number;
|
|
41
|
-
/** @hidden */
|
|
42
|
-
hideFromUI?: boolean;
|
|
43
|
-
/** @hidden */
|
|
44
|
-
modelId?: string;
|
|
45
|
-
/**
|
|
46
|
-
* Number field type validation maximum accepted input
|
|
47
|
-
*/
|
|
48
|
-
max?: number;
|
|
49
|
-
/**
|
|
50
|
-
* Number field type validation minimum accepted input
|
|
51
|
-
*/
|
|
52
|
-
min?: number;
|
|
53
|
-
/**
|
|
54
|
-
* Number field type step size when using arrows
|
|
55
|
-
*/
|
|
56
|
-
step?: number;
|
|
57
|
-
/**
|
|
58
|
-
* Set this to `true` to show the editor for this input when
|
|
59
|
-
* children of this component are selected. This is useful for things
|
|
60
|
-
* like Tabs, such that users may not always select the Tabs component
|
|
61
|
-
* directly but will still be looking for how to add additional tabs
|
|
62
|
-
*/
|
|
63
|
-
broadcast?: boolean;
|
|
64
|
-
/**
|
|
65
|
-
* Set this to `true` to show the editor for this input when
|
|
66
|
-
* group locked parents of this component are selected. This is useful
|
|
67
|
-
* to bubble up important inputs for locked groups, like text and images
|
|
68
|
-
*/
|
|
69
|
-
bubble?: boolean;
|
|
70
|
-
/**
|
|
71
|
-
* Set this to `true` if you want this component to be translatable
|
|
72
|
-
*/
|
|
73
|
-
localized?: boolean;
|
|
74
|
-
/** @hidden */
|
|
75
|
-
options?: {
|
|
76
|
-
[key: string]: any;
|
|
77
|
-
};
|
|
78
|
-
/**
|
|
79
|
-
* For "text" input type, specifying an enum will show a dropdown of options instead
|
|
80
|
-
*/
|
|
81
|
-
enum?:
|
|
82
|
-
| string[]
|
|
83
|
-
| {
|
|
84
|
-
label: string;
|
|
85
|
-
value: any;
|
|
86
|
-
helperText?: string;
|
|
87
|
-
}[];
|
|
88
|
-
/** Regex field validation for all string types (text, longText, html, url, etc) */
|
|
89
|
-
regex?: {
|
|
90
|
-
/** pattern to test, like "^\/[a-z]$" */
|
|
91
|
-
pattern: string;
|
|
92
|
-
/** flags for the RegExp constructor, e.g. "gi" */
|
|
93
|
-
options?: string;
|
|
94
|
-
/**
|
|
95
|
-
* Friendly message to display to end-users if the regex fails, e.g.
|
|
96
|
-
* "You must use a relative url starting with '/...' "
|
|
97
|
-
*/
|
|
98
|
-
message: string;
|
|
99
|
-
};
|
|
100
|
-
/**
|
|
101
|
-
* Set this to `true` to put this under the "show more" section of
|
|
102
|
-
* the options editor. Useful for things that are more advanced
|
|
103
|
-
* or more rarely used and don't need to be too prominent
|
|
104
|
-
*/
|
|
105
|
-
advanced?: boolean;
|
|
106
|
-
/** @hidden */
|
|
107
|
-
// onChange?: Function | string;
|
|
108
|
-
/** @hidden */
|
|
109
|
-
code?: boolean;
|
|
110
|
-
/** @hidden */
|
|
111
|
-
richText?: boolean;
|
|
112
|
-
/** @hidden */
|
|
113
|
-
showIf?: ((options: Map<string, any>) => boolean) | string;
|
|
114
|
-
/** @hidden */
|
|
115
|
-
copyOnAdd?: boolean;
|
|
116
|
-
/**
|
|
117
|
-
* Use optionally with inputs of type `reference`. Restricts the content entry picker to a specific model by name.
|
|
118
|
-
*/
|
|
119
|
-
model?: string;
|
|
120
|
-
|
|
121
|
-
valueType?: {
|
|
122
|
-
type?: string;
|
|
123
|
-
};
|
|
124
|
-
onChange?: ((options: Map<string, any>) => void | Promise<void>) | string;
|
|
125
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import BuilderContext from "../context/builder.context.js";
|
|
3
|
-
|
|
4
|
-
function BaseText(props) {
|
|
5
|
-
const _context = { ...props["_context"] };
|
|
6
|
-
|
|
7
|
-
const builderContext = _context["BuilderContext"];
|
|
8
|
-
|
|
9
|
-
return <span style={builderContext.inheritedStyles}>{props.text}</span>;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export default BaseText;
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
|
|
3
|
-
function Button(props) {
|
|
4
|
-
const _context = { ...props["_context"] };
|
|
5
|
-
|
|
6
|
-
return (
|
|
7
|
-
<>
|
|
8
|
-
{props.link ? (
|
|
9
|
-
<>
|
|
10
|
-
<a
|
|
11
|
-
role="button"
|
|
12
|
-
{...props.attributes}
|
|
13
|
-
href={props.link}
|
|
14
|
-
target={props.openLinkInNewTab ? "_blank" : undefined}
|
|
15
|
-
>
|
|
16
|
-
{props.text}
|
|
17
|
-
</a>
|
|
18
|
-
</>
|
|
19
|
-
) : (
|
|
20
|
-
<button
|
|
21
|
-
className={
|
|
22
|
-
/** * We have to explicitly provide `class` so that Mitosis knows to merge it with `css`. */
|
|
23
|
-
props.attributes.class + " button-3083674c"
|
|
24
|
-
}
|
|
25
|
-
{...props.attributes}
|
|
26
|
-
>
|
|
27
|
-
{props.text}
|
|
28
|
-
</button>
|
|
29
|
-
)}
|
|
30
|
-
<style>{`.button-3083674c {
|
|
31
|
-
all: unset;
|
|
32
|
-
}`}</style>
|
|
33
|
-
</>
|
|
34
|
-
);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export default Button;
|