@builder.io/sdk-solid 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.
Files changed (140) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/package.json +1 -1
  3. package/src/blocks/BaseText.jsx +1 -1
  4. package/src/blocks/button/button.jsx +5 -3
  5. package/src/blocks/button/component-info.js +16 -22
  6. package/src/blocks/columns/columns.jsx +12 -21
  7. package/src/blocks/columns/component-info.js +203 -226
  8. package/src/blocks/custom-code/component-info.js +19 -25
  9. package/src/blocks/embed/component-info.js +31 -37
  10. package/src/blocks/embed/helpers.js +3 -9
  11. package/src/blocks/form/component-info.js +174 -212
  12. package/src/blocks/form/form.jsx +1 -268
  13. package/src/blocks/fragment/component-info.js +1 -3
  14. package/src/blocks/helpers.js +27 -0
  15. package/src/blocks/image/component-info.js +105 -133
  16. package/src/blocks/image/image.helpers.js +3 -5
  17. package/src/blocks/img/component-info.js +8 -12
  18. package/src/blocks/img/img.jsx +2 -0
  19. package/src/blocks/input/component-info.js +29 -57
  20. package/src/blocks/input/input.jsx +2 -0
  21. package/src/blocks/raw-text/component-info.js +7 -11
  22. package/src/blocks/raw-text/raw-text.jsx +2 -2
  23. package/src/blocks/section/component-info.js +24 -31
  24. package/src/blocks/section/section.jsx +3 -0
  25. package/src/blocks/select/component-info.js +34 -48
  26. package/src/blocks/select/select.jsx +2 -0
  27. package/src/blocks/submit-button/component-info.js +6 -10
  28. package/src/blocks/submit-button/submit-button.jsx +3 -1
  29. package/src/blocks/symbol/component-info.js +30 -37
  30. package/src/blocks/symbol/symbol.helpers.js +60 -0
  31. package/src/blocks/symbol/symbol.jsx +31 -68
  32. package/src/blocks/text/component-info.js +10 -13
  33. package/src/blocks/text/text.jsx +1 -1
  34. package/src/blocks/textarea/component-info.js +22 -30
  35. package/src/blocks/textarea/textarea.jsx +3 -0
  36. package/src/blocks/video/component-info.js +74 -96
  37. package/src/blocks/video/video.jsx +1 -0
  38. package/src/components/{render-block/render-block.helpers.js → block/block.helpers.js} +26 -44
  39. package/src/components/{render-block/render-block.jsx → block/block.jsx} +65 -80
  40. package/src/components/{render-block → block/components}/block-styles.jsx +16 -16
  41. package/src/components/block/components/block-wrapper.jsx +50 -0
  42. package/src/components/block/components/component-ref/component-ref.helpers.js +41 -0
  43. package/src/components/block/components/component-ref/component-ref.jsx +58 -0
  44. package/src/components/block/components/interactive-element.jsx +30 -0
  45. package/src/components/block/components/repeated-block.jsx +20 -0
  46. package/src/components/blocks/blocks-wrapper.jsx +66 -0
  47. package/src/components/blocks/blocks.jsx +48 -0
  48. package/src/components/{render-content/render-content.jsx → content/components/enable-editor.jsx} +86 -175
  49. package/src/components/{render-content/components/render-styles.helpers.js → content/components/styles.helpers.js} +6 -7
  50. package/src/components/{render-content/components/render-styles.jsx → content/components/styles.jsx} +4 -4
  51. package/src/components/{render-content/render-content.helpers.js → content/content.helpers.js} +15 -15
  52. package/src/components/content/content.jsx +129 -0
  53. package/src/components/content/index.js +2 -0
  54. package/src/components/content/wrap-component-ref.js +2 -0
  55. package/src/components/{render-content-variants/render-content-variants.jsx → content-variants/content-variants.jsx} +19 -22
  56. package/src/components/{render-content-variants → content-variants}/helpers.js +28 -40
  57. package/src/constants/builder-registered-components.js +34 -25
  58. package/src/constants/device-sizes.js +6 -6
  59. package/src/constants/sdk-version.js +1 -1
  60. package/src/context/builder.context.js +1 -1
  61. package/src/functions/apply-patch-with-mutation.js +66 -0
  62. package/src/functions/camel-to-kebab-case.js +2 -4
  63. package/src/functions/evaluate/acorn.js +1595 -0
  64. package/src/functions/{evaluate.js → evaluate/evaluate.js} +36 -10
  65. package/src/functions/evaluate/index.js +2 -0
  66. package/src/functions/evaluate/interpreter.js +2801 -0
  67. package/src/functions/evaluate/non-node-runtime.js +92 -0
  68. package/src/functions/evaluate/types.js +0 -0
  69. package/src/functions/event-handler-name.js +2 -4
  70. package/src/functions/extract-text-styles.js +4 -12
  71. package/src/functions/fast-clone.js +2 -4
  72. package/src/functions/get-block-actions-handler.js +3 -5
  73. package/src/functions/get-block-actions.js +15 -4
  74. package/src/functions/get-block-component-options.js +11 -12
  75. package/src/functions/get-block-properties.js +29 -19
  76. package/src/functions/get-builder-search-params/index.js +5 -10
  77. package/src/functions/get-content/generate-content-url.js +17 -19
  78. package/src/functions/get-content/index.js +43 -29
  79. package/src/functions/get-fetch.js +1 -3
  80. package/src/functions/get-global-this.js +1 -3
  81. package/src/functions/get-processed-block.js +12 -13
  82. package/src/functions/get-react-native-block-styles.js +11 -12
  83. package/src/functions/if-target.js +1 -3
  84. package/src/functions/is-browser.js +1 -3
  85. package/src/functions/is-editing.js +1 -3
  86. package/src/functions/is-iframe.js +1 -3
  87. package/src/functions/is-non-node-server.js +9 -0
  88. package/src/functions/is-previewing.js +1 -3
  89. package/src/functions/on-change.js +1 -4
  90. package/src/functions/register-component.js +34 -42
  91. package/src/functions/register.js +1 -3
  92. package/src/functions/sanitize-react-native-block-styles.js +22 -17
  93. package/src/functions/set-editor-settings.js +1 -3
  94. package/src/functions/set.js +1 -3
  95. package/src/functions/track/helpers.js +3 -5
  96. package/src/functions/track/index.js +45 -43
  97. package/src/functions/track/interaction.js +11 -7
  98. package/src/functions/transform-block-properties.js +1 -3
  99. package/src/functions/transform-block.js +1 -3
  100. package/src/helpers/ab-tests.js +45 -28
  101. package/src/helpers/canTrack.js +3 -5
  102. package/src/helpers/cookie.js +15 -24
  103. package/src/helpers/css.js +3 -7
  104. package/src/helpers/flatten.js +15 -18
  105. package/src/helpers/localStorage.js +1 -4
  106. package/src/helpers/logger.js +1 -3
  107. package/src/helpers/nullable.js +2 -4
  108. package/src/helpers/preview-lru-cache/get.js +8 -0
  109. package/src/helpers/preview-lru-cache/helpers.js +10 -0
  110. package/src/helpers/preview-lru-cache/init.js +10 -0
  111. package/src/helpers/preview-lru-cache/set.js +35 -0
  112. package/src/helpers/preview-lru-cache/types.js +0 -0
  113. package/src/helpers/sessionId.js +14 -11
  114. package/src/helpers/time.js +1 -3
  115. package/src/helpers/url.js +2 -4
  116. package/src/helpers/uuid.js +4 -6
  117. package/src/helpers/visitorId.js +8 -7
  118. package/src/index-helpers/blocks-exports.js +3 -14
  119. package/src/index-helpers/top-of-file.js +1 -3
  120. package/src/index.js +2 -17
  121. package/src/scripts/init-editing.js +62 -48
  122. package/src/types/api-version.js +1 -3
  123. package/src/types/builder-props.js +0 -0
  124. package/src/blocks/util.js +0 -8
  125. package/src/components/render-block/render-component.jsx +0 -40
  126. package/src/components/render-block/render-repeated-block.jsx +0 -16
  127. package/src/components/render-blocks.jsx +0 -100
  128. package/src/components/render-content/builder-editing.jsx +0 -5
  129. package/src/components/render-content/index.js +0 -4
  130. package/src/components/render-content/wrap-component-ref.js +0 -4
  131. package/src/functions/evaluate.test.js +0 -17
  132. package/src/functions/get-builder-search-params/fn.test.js +0 -13
  133. package/src/functions/get-content/generate-content-url.test.js +0 -97
  134. package/src/functions/get-processed-block.test.js +0 -34
  135. package/src/functions/on-change.test.js +0 -19
  136. package/src/functions/set.test.js +0 -16
  137. package/src/helpers/url.test.js +0 -21
  138. /package/src/components/{render-block → block}/types.js +0 -0
  139. /package/src/components/{render-content/render-content.types.js → content/content.types.js} +0 -0
  140. /package/src/components/{render-content-variants/render-content-variants.types.js → content-variants/content-variants.types.js} +0 -0
@@ -0,0 +1,50 @@
1
+ import { Show } from "solid-js";
2
+ import { Dynamic } from "solid-js/web";
3
+
4
+ import { getBlockActions } from "../../../functions/get-block-actions.js";
5
+ import { getBlockProperties } from "../../../functions/get-block-properties.js";
6
+
7
+ function BlockWrapper(props) {
8
+ return (
9
+ <Show
10
+ fallback={
11
+ <Dynamic
12
+ {...getBlockProperties({
13
+ block: props.block,
14
+ context: props.context,
15
+ })}
16
+ {...getBlockActions({
17
+ block: props.block,
18
+ rootState: props.context.rootState,
19
+ rootSetState: props.context.rootSetState,
20
+ localState: props.context.localState,
21
+ context: props.context.context,
22
+ stripPrefix: true,
23
+ })}
24
+ component={props.Wrapper}
25
+ ></Dynamic>
26
+ }
27
+ when={props.hasChildren}
28
+ >
29
+ <Dynamic
30
+ {...getBlockProperties({
31
+ block: props.block,
32
+ context: props.context,
33
+ })}
34
+ {...getBlockActions({
35
+ block: props.block,
36
+ rootState: props.context.rootState,
37
+ rootSetState: props.context.rootSetState,
38
+ localState: props.context.localState,
39
+ context: props.context.context,
40
+ stripPrefix: true,
41
+ })}
42
+ component={props.Wrapper}
43
+ >
44
+ {props.children}
45
+ </Dynamic>
46
+ </Show>
47
+ );
48
+ }
49
+
50
+ export default BlockWrapper;
@@ -0,0 +1,41 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
4
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
5
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {
6
+ enumerable: true,
7
+ configurable: true,
8
+ writable: true,
9
+ value
10
+ }) : obj[key] = value;
11
+ var __spreadValues = (a, b) => {
12
+ for (var prop in b || (b = {})) if (__hasOwnProp.call(b, prop)) __defNormalProp(a, prop, b[prop]);
13
+ if (__getOwnPropSymbols) for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop)) __defNormalProp(a, prop, b[prop]);
15
+ }
16
+ return a;
17
+ };
18
+ import { getBlockProperties } from "../../../../functions/get-block-properties.js";
19
+ const getWrapperProps = ({
20
+ componentOptions,
21
+ builderBlock,
22
+ context,
23
+ componentRef,
24
+ includeBlockProps,
25
+ isInteractive,
26
+ contextValue
27
+ }) => {
28
+ const interactiveElementProps = {
29
+ Wrapper: componentRef,
30
+ block: builderBlock,
31
+ context,
32
+ wrapperProps: componentOptions
33
+ };
34
+ return isInteractive ? interactiveElementProps : __spreadValues(__spreadValues({}, componentOptions), includeBlockProps ? {
35
+ attributes: getBlockProperties({
36
+ block: builderBlock,
37
+ context: contextValue
38
+ })
39
+ } : {});
40
+ };
41
+ export { getWrapperProps }
@@ -0,0 +1,58 @@
1
+ import { Show, For, createSignal } from "solid-js";
2
+ import { Dynamic } from "solid-js/web";
3
+
4
+ import BlockStyles from "../block-styles.jsx";
5
+ import Block from "../../block.jsx";
6
+ import InteractiveElement from "../interactive-element.jsx";
7
+ import { getWrapperProps } from "./component-ref.helpers.js";
8
+
9
+ function ComponentRef(props) {
10
+ const [Wrapper, setWrapper] = createSignal(
11
+ props.isInteractive ? InteractiveElement : props.componentRef
12
+ );
13
+
14
+ return (
15
+ <Show when={props.componentRef}>
16
+ <Dynamic
17
+ {...getWrapperProps({
18
+ componentOptions: props.componentOptions,
19
+ builderBlock: props.builderBlock,
20
+ context: props.context,
21
+ componentRef: props.componentRef,
22
+ includeBlockProps: props.includeBlockProps,
23
+ isInteractive: props.isInteractive,
24
+ contextValue: props.context,
25
+ })}
26
+ component={Wrapper()}
27
+ >
28
+ <For each={props.blockChildren}>
29
+ {(child, _index) => {
30
+ const index = _index();
31
+ return (
32
+ <Block
33
+ key={"block-" + child.id}
34
+ block={child}
35
+ context={props.context}
36
+ registeredComponents={props.registeredComponents}
37
+ ></Block>
38
+ );
39
+ }}
40
+ </For>
41
+ <For each={props.blockChildren}>
42
+ {(child, _index) => {
43
+ const index = _index();
44
+ return (
45
+ <BlockStyles
46
+ key={"block-style-" + child.id}
47
+ block={child}
48
+ context={props.context}
49
+ ></BlockStyles>
50
+ );
51
+ }}
52
+ </For>
53
+ </Dynamic>
54
+ </Show>
55
+ );
56
+ }
57
+
58
+ export default ComponentRef;
@@ -0,0 +1,30 @@
1
+ import { Dynamic } from "solid-js/web";
2
+
3
+ import { getBlockActions } from "../../../functions/get-block-actions.js";
4
+ import { getBlockProperties } from "../../../functions/get-block-properties.js";
5
+
6
+ function InteractiveElement(props) {
7
+ return (
8
+ <Dynamic
9
+ {...props.wrapperProps}
10
+ attributes={{
11
+ ...getBlockProperties({
12
+ block: props.block,
13
+ context: props.context,
14
+ }),
15
+ ...getBlockActions({
16
+ block: props.block,
17
+ rootState: props.context.rootState,
18
+ rootSetState: props.context.rootSetState,
19
+ localState: props.context.localState,
20
+ context: props.context.context,
21
+ }),
22
+ }}
23
+ component={props.Wrapper}
24
+ >
25
+ {props.children}
26
+ </Dynamic>
27
+ );
28
+ }
29
+
30
+ export default InteractiveElement;
@@ -0,0 +1,20 @@
1
+ import { createSignal } from "solid-js";
2
+
3
+ import BuilderContext from "../../../context/builder.context";
4
+ import Block from "../block.jsx";
5
+
6
+ function RepeatedBlock(props) {
7
+ const [store, setStore] = createSignal(props.repeatContext);
8
+
9
+ return (
10
+ <BuilderContext.Provider value={store()}>
11
+ <Block
12
+ block={props.block}
13
+ context={store()}
14
+ registeredComponents={props.registeredComponents}
15
+ ></Block>
16
+ </BuilderContext.Provider>
17
+ );
18
+ }
19
+
20
+ export default RepeatedBlock;
@@ -0,0 +1,66 @@
1
+ import { createSignal } from "solid-js";
2
+
3
+ import { css } from "solid-styled-components";
4
+
5
+ import { isEditing } from "../../functions/is-editing.js";
6
+
7
+ function BlocksWrapper(props) {
8
+ function className() {
9
+ return "builder-blocks" + (!props.blocks?.length ? " no-blocks" : "");
10
+ }
11
+
12
+ function onClick() {
13
+ if (isEditing() && !props.blocks?.length) {
14
+ window.parent?.postMessage(
15
+ {
16
+ type: "builder.clickEmptyBlocks",
17
+ data: {
18
+ parentElementId: props.parent,
19
+ dataPath: props.path,
20
+ },
21
+ },
22
+ "*"
23
+ );
24
+ }
25
+ }
26
+
27
+ function onMouseEnter() {
28
+ if (isEditing() && !props.blocks?.length) {
29
+ window.parent?.postMessage(
30
+ {
31
+ type: "builder.hoverEmptyBlocks",
32
+ data: {
33
+ parentElementId: props.parent,
34
+ dataPath: props.path,
35
+ },
36
+ },
37
+ "*"
38
+ );
39
+ }
40
+ }
41
+
42
+ return (
43
+ <div
44
+ class={
45
+ className() +
46
+ " " +
47
+ css({
48
+ display: "flex",
49
+ flexDirection: "column",
50
+ alignItems: "stretch",
51
+ })
52
+ }
53
+ builder-path={props.path}
54
+ builder-parent-id={props.parent}
55
+ {...{}}
56
+ style={props.styleProp}
57
+ onClick={(event) => onClick()}
58
+ onMouseEnter={(event) => onMouseEnter()}
59
+ onKeyPress={(event) => onClick()}
60
+ >
61
+ {props.children}
62
+ </div>
63
+ );
64
+ }
65
+
66
+ export default BlocksWrapper;
@@ -0,0 +1,48 @@
1
+ import { Show, For } from "solid-js";
2
+
3
+ import BlockStyles from "../block/components/block-styles.jsx";
4
+ import Block from "../block/block.jsx";
5
+ import BlocksWrapper from "./blocks-wrapper.jsx";
6
+
7
+ function Blocks(props) {
8
+ return (
9
+ <BlocksWrapper
10
+ blocks={props.blocks}
11
+ parent={props.parent}
12
+ path={props.path}
13
+ styleProp={props.styleProp}
14
+ >
15
+ <Show when={props.blocks}>
16
+ <For each={props.blocks}>
17
+ {(block, _index) => {
18
+ const index = _index();
19
+ return (
20
+ <Block
21
+ key={"render-block-" + block.id}
22
+ block={block}
23
+ context={props.context}
24
+ registeredComponents={props.registeredComponents}
25
+ ></Block>
26
+ );
27
+ }}
28
+ </For>
29
+ </Show>
30
+ <Show when={props.blocks}>
31
+ <For each={props.blocks}>
32
+ {(block, _index) => {
33
+ const index = _index();
34
+ return (
35
+ <BlockStyles
36
+ key={"block-style-" + block.id}
37
+ block={block}
38
+ context={props.context}
39
+ ></BlockStyles>
40
+ );
41
+ }}
42
+ </For>
43
+ </Show>
44
+ </BlocksWrapper>
45
+ );
46
+ }
47
+
48
+ export default Blocks;