@builder.io/sdk-solid 0.5.8 → 0.6.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 (162) hide show
  1. package/README.md +0 -4
  2. package/dist/index.d.ts +51 -0
  3. package/lib/browser/dev.js +4790 -0
  4. package/lib/browser/dev.jsx +4392 -0
  5. package/lib/browser/index.js +4767 -0
  6. package/lib/browser/index.jsx +4374 -0
  7. package/lib/edge/dev.js +7921 -0
  8. package/lib/edge/dev.jsx +7525 -0
  9. package/lib/edge/index.js +7898 -0
  10. package/lib/edge/index.jsx +7507 -0
  11. package/lib/node/dev.js +4790 -0
  12. package/lib/node/dev.jsx +4392 -0
  13. package/lib/node/index.js +4767 -0
  14. package/lib/node/index.jsx +4374 -0
  15. package/package.json +86 -14
  16. package/CHANGELOG.md +0 -98
  17. package/solid-index.jsx +0 -5
  18. package/src/blocks/BaseText.jsx +0 -11
  19. package/src/blocks/button/button.jsx +0 -41
  20. package/src/blocks/button/component-info.js +0 -34
  21. package/src/blocks/columns/columns.jsx +0 -174
  22. package/src/blocks/columns/component-info.js +0 -218
  23. package/src/blocks/custom-code/component-info.js +0 -24
  24. package/src/blocks/custom-code/custom-code.jsx +0 -62
  25. package/src/blocks/embed/component-info.js +0 -37
  26. package/src/blocks/embed/embed.jsx +0 -50
  27. package/src/blocks/embed/helpers.js +0 -3
  28. package/src/blocks/form/component-info.js +0 -223
  29. package/src/blocks/form/form.jsx +0 -5
  30. package/src/blocks/fragment/component-info.js +0 -8
  31. package/src/blocks/fragment/fragment.jsx +0 -5
  32. package/src/blocks/helpers.js +0 -27
  33. package/src/blocks/image/component-info.js +0 -122
  34. package/src/blocks/image/image.helpers.js +0 -46
  35. package/src/blocks/image/image.jsx +0 -122
  36. package/src/blocks/img/component-info.js +0 -15
  37. package/src/blocks/img/img.jsx +0 -20
  38. package/src/blocks/input/component-info.js +0 -45
  39. package/src/blocks/input/input.jsx +0 -22
  40. package/src/blocks/raw-text/component-info.js +0 -11
  41. package/src/blocks/raw-text/raw-text.jsx +0 -10
  42. package/src/blocks/section/component-info.js +0 -41
  43. package/src/blocks/section/section.jsx +0 -26
  44. package/src/blocks/select/component-info.js +0 -44
  45. package/src/blocks/select/select.jsx +0 -30
  46. package/src/blocks/submit-button/component-info.js +0 -23
  47. package/src/blocks/submit-button/submit-button.jsx +0 -11
  48. package/src/blocks/symbol/component-info.js +0 -35
  49. package/src/blocks/symbol/symbol.helpers.js +0 -60
  50. package/src/blocks/symbol/symbol.jsx +0 -64
  51. package/src/blocks/text/component-info.js +0 -20
  52. package/src/blocks/text/text.jsx +0 -14
  53. package/src/blocks/textarea/component-info.js +0 -38
  54. package/src/blocks/textarea/textarea.jsx +0 -16
  55. package/src/blocks/video/component-info.js +0 -83
  56. package/src/blocks/video/video.jsx +0 -61
  57. package/src/components/block/block.helpers.js +0 -99
  58. package/src/components/block/block.jsx +0 -167
  59. package/src/components/block/components/block-styles.jsx +0 -85
  60. package/src/components/block/components/block-wrapper.jsx +0 -50
  61. package/src/components/block/components/component-ref/component-ref.helpers.js +0 -41
  62. package/src/components/block/components/component-ref/component-ref.jsx +0 -58
  63. package/src/components/block/components/interactive-element.jsx +0 -30
  64. package/src/components/block/components/repeated-block.jsx +0 -20
  65. package/src/components/block/types.js +0 -0
  66. package/src/components/blocks/blocks-wrapper.jsx +0 -66
  67. package/src/components/blocks/blocks.jsx +0 -57
  68. package/src/components/content/components/enable-editor.jsx +0 -347
  69. package/src/components/content/components/styles.helpers.js +0 -56
  70. package/src/components/content/components/styles.jsx +0 -36
  71. package/src/components/content/content.helpers.js +0 -48
  72. package/src/components/content/content.jsx +0 -136
  73. package/src/components/content/content.types.js +0 -0
  74. package/src/components/content/index.js +0 -2
  75. package/src/components/content/wrap-component-ref.js +0 -2
  76. package/src/components/content-variants/content-variants.jsx +0 -115
  77. package/src/components/content-variants/content-variants.types.js +0 -0
  78. package/src/components/content-variants/helpers.js +0 -158
  79. package/src/components/inlined-script.jsx +0 -5
  80. package/src/components/inlined-styles.jsx +0 -5
  81. package/src/constants/builder-registered-components.js +0 -63
  82. package/src/constants/device-sizes.js +0 -48
  83. package/src/constants/sdk-version.js +0 -1
  84. package/src/constants/target.js +0 -4
  85. package/src/context/builder.context.js +0 -16
  86. package/src/context/components.context.js +0 -5
  87. package/src/context/types.js +0 -0
  88. package/src/functions/apply-patch-with-mutation.js +0 -66
  89. package/src/functions/camel-to-kebab-case.js +0 -2
  90. package/src/functions/evaluate/acorn-interpreter.js +0 -2876
  91. package/src/functions/evaluate/evaluate.js +0 -79
  92. package/src/functions/evaluate/index.js +0 -2
  93. package/src/functions/evaluate/non-node-runtime/index.js +0 -18
  94. package/src/functions/evaluate/non-node-runtime/non-node-runtime.js +0 -92
  95. package/src/functions/evaluate/types.js +0 -0
  96. package/src/functions/event-handler-name.js +0 -5
  97. package/src/functions/extract-text-styles.js +0 -14
  98. package/src/functions/fast-clone.js +0 -2
  99. package/src/functions/fetch-builder-props.js +0 -60
  100. package/src/functions/get-block-actions-handler.js +0 -11
  101. package/src/functions/get-block-actions.js +0 -29
  102. package/src/functions/get-block-component-options.js +0 -27
  103. package/src/functions/get-block-properties.js +0 -63
  104. package/src/functions/get-builder-search-params/index.js +0 -33
  105. package/src/functions/get-content/generate-content-url.js +0 -59
  106. package/src/functions/get-content/index.js +0 -116
  107. package/src/functions/get-content/types.js +0 -0
  108. package/src/functions/get-fetch.js +0 -12
  109. package/src/functions/get-global-this.js +0 -16
  110. package/src/functions/get-processed-block.js +0 -74
  111. package/src/functions/get-react-native-block-styles.js +0 -32
  112. package/src/functions/is-browser.js +0 -4
  113. package/src/functions/is-editing.js +0 -6
  114. package/src/functions/is-iframe.js +0 -5
  115. package/src/functions/is-non-node-server.js +0 -9
  116. package/src/functions/is-previewing.js +0 -12
  117. package/src/functions/on-change.js +0 -24
  118. package/src/functions/register-component.js +0 -60
  119. package/src/functions/register.js +0 -27
  120. package/src/functions/sanitize-react-native-block-styles.js +0 -71
  121. package/src/functions/set-editor-settings.js +0 -13
  122. package/src/functions/set.js +0 -9
  123. package/src/functions/track/helpers.js +0 -48
  124. package/src/functions/track/index.js +0 -131
  125. package/src/functions/track/interaction.js +0 -57
  126. package/src/functions/transform-block-properties.js +0 -4
  127. package/src/functions/transform-block.js +0 -4
  128. package/src/helpers/ab-tests.js +0 -158
  129. package/src/helpers/canTrack.js +0 -3
  130. package/src/helpers/cookie.js +0 -77
  131. package/src/helpers/css.js +0 -30
  132. package/src/helpers/flatten.js +0 -31
  133. package/src/helpers/localStorage.js +0 -32
  134. package/src/helpers/logger.js +0 -8
  135. package/src/helpers/nullable.js +0 -2
  136. package/src/helpers/preview-lru-cache/get.js +0 -4
  137. package/src/helpers/preview-lru-cache/helpers.js +0 -0
  138. package/src/helpers/preview-lru-cache/init.js +0 -2
  139. package/src/helpers/preview-lru-cache/set.js +0 -31
  140. package/src/helpers/preview-lru-cache/types.js +0 -0
  141. package/src/helpers/sessionId.js +0 -55
  142. package/src/helpers/time.js +0 -3
  143. package/src/helpers/url.js +0 -11
  144. package/src/helpers/uuid.js +0 -11
  145. package/src/helpers/visitorId.js +0 -35
  146. package/src/index-helpers/blocks-exports.js +0 -13
  147. package/src/index-helpers/top-of-file.js +0 -2
  148. package/src/index.js +0 -12
  149. package/src/scripts/init-editing.js +0 -109
  150. package/src/types/api-version.js +0 -2
  151. package/src/types/builder-block.js +0 -0
  152. package/src/types/builder-content.js +0 -0
  153. package/src/types/builder-props.js +0 -0
  154. package/src/types/can-track.js +0 -0
  155. package/src/types/components.js +0 -0
  156. package/src/types/deep-partial.js +0 -0
  157. package/src/types/element.js +0 -0
  158. package/src/types/enforced-partials.js +0 -0
  159. package/src/types/input.js +0 -0
  160. package/src/types/targets.js +0 -0
  161. package/src/types/typescript.js +0 -0
  162. package/vite.config.ts +0 -18
@@ -1,60 +0,0 @@
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
- var __async = (__this, __arguments, generator) => {
19
- return new Promise((resolve, reject) => {
20
- var fulfilled = value => {
21
- try {
22
- step(generator.next(value));
23
- } catch (e) {
24
- reject(e);
25
- }
26
- };
27
- var rejected = value => {
28
- try {
29
- step(generator.throw(value));
30
- } catch (e) {
31
- reject(e);
32
- }
33
- };
34
- var step = x => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
35
- step((generator = generator.apply(__this, __arguments)).next());
36
- });
37
- };
38
- import { logger } from "../../helpers/logger.js";
39
- import { fetchOneEntry } from "../../index.js";
40
- const fetchSymbolContent = _0 => __async(void 0, [_0], function* ({
41
- builderContextValue,
42
- symbol
43
- }) {
44
- if ((symbol == null ? void 0 : symbol.model) && (builderContextValue == null ? void 0 : builderContextValue.apiKey)) {
45
- return fetchOneEntry(__spreadValues({
46
- model: symbol.model,
47
- apiKey: builderContextValue.apiKey,
48
- apiVersion: builderContextValue.apiVersion
49
- }, (symbol == null ? void 0 : symbol.entry) && {
50
- query: {
51
- id: symbol.entry
52
- }
53
- })).catch(err => {
54
- logger.error("Could not fetch symbol content: ", err);
55
- return void 0;
56
- });
57
- }
58
- return void 0;
59
- });
60
- export { fetchSymbolContent }
@@ -1,64 +0,0 @@
1
- import { onMount, on, createEffect, createSignal } from "solid-js";
2
-
3
- import ContentVariants from "../../components/content-variants/content-variants";
4
- import { filterAttrs } from "../helpers.js";
5
- import { fetchSymbolContent } from "./symbol.helpers.js";
6
-
7
- function Symbol(props) {
8
- const [contentToUse, setContentToUse] = createSignal(props.symbol?.content);
9
-
10
- function className() {
11
- return [
12
- ...[props.attributes.class],
13
- "builder-symbol",
14
- props.symbol?.inline ? "builder-inline-symbol" : undefined,
15
- props.symbol?.dynamic || props.dynamic
16
- ? "builder-dynamic-symbol"
17
- : undefined,
18
- ]
19
- .filter(Boolean)
20
- .join(" ");
21
- }
22
-
23
- function setContent() {
24
- if (contentToUse()) return;
25
- fetchSymbolContent({
26
- symbol: props.symbol,
27
- builderContextValue: props.builderContext,
28
- }).then((newContent) => {
29
- if (newContent) {
30
- setContentToUse(newContent);
31
- }
32
- });
33
- }
34
-
35
- onMount(() => {
36
- setContent();
37
- });
38
-
39
- function onUpdateFn_0() {
40
- setContent();
41
- }
42
- createEffect(on(() => [props.symbol], onUpdateFn_0));
43
-
44
- return (
45
- <div class={className()} {...{}} {...props.attributes} {...{}}>
46
- <ContentVariants
47
- __isNestedRender={true}
48
- apiVersion={props.builderContext.apiVersion}
49
- apiKey={props.builderContext.apiKey}
50
- context={props.builderContext.context}
51
- customComponents={Object.values(props.builderComponents)}
52
- data={{
53
- ...props.symbol?.data,
54
- ...props.builderContext.localState,
55
- ...contentToUse()?.data?.state,
56
- }}
57
- model={props.symbol?.model}
58
- content={contentToUse()}
59
- ></ContentVariants>
60
- </div>
61
- );
62
- }
63
-
64
- export default Symbol;
@@ -1,20 +0,0 @@
1
- const componentInfo = {
2
- name: "Text",
3
- static: true,
4
- isRSC: true,
5
- image: "https://firebasestorage.googleapis.com/v0/b/builder-3b0a2.appspot.com/o/images%2Fbaseline-text_fields-24px%20(1).svg?alt=media&token=12177b73-0ee3-42ca-98c6-0dd003de1929",
6
- inputs: [{
7
- name: "text",
8
- type: "html",
9
- required: true,
10
- autoFocus: true,
11
- bubble: true,
12
- defaultValue: "Enter some text..."
13
- }],
14
- defaultStyles: {
15
- lineHeight: "normal",
16
- height: "auto",
17
- textAlign: "center"
18
- }
19
- };
20
- export { componentInfo }
@@ -1,14 +0,0 @@
1
- function Text(props) {
2
- return (
3
- <span
4
- class="builder-text"
5
- innerHTML={props.text?.toString() || ""}
6
- style={{
7
- outline: "none",
8
- }}
9
- {...{}}
10
- ></span>
11
- );
12
- }
13
-
14
- export default Text;
@@ -1,38 +0,0 @@
1
- const componentInfo = {
2
- name: "Form:TextArea",
3
- image: "https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2Ff74a2f3de58c4c3e939204e5b6b8f6c3",
4
- inputs: [{
5
- advanced: true,
6
- name: "value",
7
- type: "string"
8
- }, {
9
- name: "name",
10
- type: "string",
11
- required: true,
12
- helperText: 'Every input in a form needs a unique name describing what it gets, e.g. "email"'
13
- }, {
14
- name: "defaultValue",
15
- type: "string"
16
- }, {
17
- name: "placeholder",
18
- type: "string",
19
- defaultValue: "Hello there"
20
- }, {
21
- name: "required",
22
- type: "boolean",
23
- defaultValue: false
24
- }],
25
- defaultStyles: {
26
- paddingTop: "10px",
27
- paddingBottom: "10px",
28
- paddingLeft: "10px",
29
- paddingRight: "10px",
30
- borderRadius: "3px",
31
- borderWidth: "1px",
32
- borderStyle: "solid",
33
- borderColor: "#ccc"
34
- },
35
- static: true,
36
- noWrap: true
37
- };
38
- export { componentInfo }
@@ -1,16 +0,0 @@
1
- import { filterAttrs } from "../helpers.js";
2
-
3
- function Textarea(props) {
4
- return (
5
- <textarea
6
- {...{}}
7
- {...props.attributes}
8
- placeholder={props.placeholder}
9
- name={props.name}
10
- value={props.value}
11
- defaultValue={props.defaultValue}
12
- ></textarea>
13
- );
14
- }
15
-
16
- export default Textarea;
@@ -1,83 +0,0 @@
1
- const componentInfo = {
2
- name: "Video",
3
- canHaveChildren: true,
4
- defaultStyles: {
5
- minHeight: "20px",
6
- minWidth: "20px"
7
- },
8
- image: "https://firebasestorage.googleapis.com/v0/b/builder-3b0a2.appspot.com/o/images%2Fbaseline-videocam-24px%20(1).svg?alt=media&token=49a84e4a-b20e-4977-a650-047f986874bb",
9
- inputs: [{
10
- name: "video",
11
- type: "file",
12
- allowedFileTypes: ["mp4"],
13
- bubble: true,
14
- defaultValue: "https://firebasestorage.googleapis.com/v0/b/builder-3b0a2.appspot.com/o/assets%2FKQlEmWDxA0coC3PK6UvkrjwkIGI2%2F28cb070609f546cdbe5efa20e931aa4b?alt=media&token=912e9551-7a7c-4dfb-86b6-3da1537d1a7f",
15
- required: true
16
- }, {
17
- name: "posterImage",
18
- type: "file",
19
- allowedFileTypes: ["jpeg", "png"],
20
- helperText: "Image to show before the video plays"
21
- }, {
22
- name: "autoPlay",
23
- type: "boolean",
24
- defaultValue: true
25
- }, {
26
- name: "controls",
27
- type: "boolean",
28
- defaultValue: false
29
- }, {
30
- name: "muted",
31
- type: "boolean",
32
- defaultValue: true
33
- }, {
34
- name: "loop",
35
- type: "boolean",
36
- defaultValue: true
37
- }, {
38
- name: "playsInline",
39
- type: "boolean",
40
- defaultValue: true
41
- }, {
42
- name: "fit",
43
- type: "text",
44
- defaultValue: "cover",
45
- enum: ["contain", "cover", "fill", "auto"]
46
- }, {
47
- name: "preload",
48
- type: "text",
49
- defaultValue: "metadata",
50
- enum: ["auto", "metadata", "none"]
51
- }, {
52
- name: "fitContent",
53
- type: "boolean",
54
- helperText: "When child blocks are provided, fit to them instead of using the aspect ratio",
55
- defaultValue: true,
56
- advanced: true
57
- }, {
58
- name: "position",
59
- type: "text",
60
- defaultValue: "center",
61
- enum: ["center", "top", "left", "right", "bottom", "top left", "top right", "bottom left", "bottom right"]
62
- }, {
63
- name: "height",
64
- type: "number",
65
- advanced: true
66
- }, {
67
- name: "width",
68
- type: "number",
69
- advanced: true
70
- }, {
71
- name: "aspectRatio",
72
- type: "number",
73
- advanced: true,
74
- defaultValue: 0.7004048582995948
75
- }, {
76
- name: "lazyLoad",
77
- type: "boolean",
78
- helperText: 'Load this video "lazily" - as in only when a user scrolls near the video. Recommended for optmized performance and bandwidth consumption',
79
- defaultValue: true,
80
- advanced: true
81
- }]
82
- };
83
- export { componentInfo }
@@ -1,61 +0,0 @@
1
- import { createSignal } from "solid-js";
2
-
3
- function Video(props) {
4
- function videoProps() {
5
- return {
6
- ...(props.autoPlay === true
7
- ? {
8
- autoPlay: true,
9
- }
10
- : {}),
11
- ...(props.muted === true
12
- ? {
13
- muted: true,
14
- }
15
- : {}),
16
- ...(props.controls === true
17
- ? {
18
- controls: true,
19
- }
20
- : {}),
21
- ...(props.loop === true
22
- ? {
23
- loop: true,
24
- }
25
- : {}),
26
- ...(props.playsInline === true
27
- ? {
28
- playsInline: true,
29
- }
30
- : {}),
31
- };
32
- }
33
-
34
- function spreadProps() {
35
- return {
36
- ...props.attributes,
37
- ...videoProps(),
38
- };
39
- }
40
-
41
- return (
42
- <video
43
- {...spreadProps()}
44
- preload={props.preload || "metadata"}
45
- style={{
46
- width: "100%",
47
- height: "100%",
48
- ...props.attributes?.style,
49
- "object-fit": props.fit,
50
- "object-position": props.position,
51
- // Hack to get object fit to work as expected and
52
- // not have the video overflow
53
- "border-radius": 1,
54
- }}
55
- src={props.video || "no-src"}
56
- poster={props.posterImage}
57
- ></video>
58
- );
59
- }
60
-
61
- export default Video;
@@ -1,99 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __defProps = Object.defineProperties;
3
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {
8
- enumerable: true,
9
- configurable: true,
10
- writable: true,
11
- value
12
- }) : obj[key] = value;
13
- var __spreadValues = (a, b) => {
14
- for (var prop in b || (b = {})) if (__hasOwnProp.call(b, prop)) __defNormalProp(a, prop, b[prop]);
15
- if (__getOwnPropSymbols) for (var prop of __getOwnPropSymbols(b)) {
16
- if (__propIsEnum.call(b, prop)) __defNormalProp(a, prop, b[prop]);
17
- }
18
- return a;
19
- };
20
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
21
- var __objRest = (source, exclude) => {
22
- var target = {};
23
- for (var prop in source) if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0) target[prop] = source[prop];
24
- if (source != null && __getOwnPropSymbols) for (var prop of __getOwnPropSymbols(source)) {
25
- if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop)) target[prop] = source[prop];
26
- }
27
- return target;
28
- };
29
- import { evaluate } from "../../functions/evaluate/index.js";
30
- import { getProcessedBlock } from "../../functions/get-processed-block.js";
31
- const EMPTY_HTML_ELEMENTS = ["area", "base", "br", "col", "embed", "hr", "img", "input", "keygen", "link", "meta", "param", "source", "track", "wbr"];
32
- const isEmptyHtmlElement = tagName => {
33
- return typeof tagName === "string" && EMPTY_HTML_ELEMENTS.includes(tagName.toLowerCase());
34
- };
35
- const getComponent = ({
36
- block,
37
- context,
38
- registeredComponents
39
- }) => {
40
- var _a;
41
- const componentName = (_a = getProcessedBlock({
42
- block,
43
- localState: context.localState,
44
- rootState: context.rootState,
45
- rootSetState: context.rootSetState,
46
- context: context.context,
47
- shouldEvaluateBindings: false
48
- }).component) == null ? void 0 : _a.name;
49
- if (!componentName) {
50
- return null;
51
- }
52
- const ref = registeredComponents[componentName];
53
- if (!ref) {
54
- console.warn(`
55
- Could not find a registered component named "${componentName}".
56
- If you registered it, is the file that registered it imported by the file that needs to render it?`);
57
- return void 0;
58
- } else {
59
- return ref;
60
- }
61
- };
62
- const getRepeatItemData = ({
63
- block,
64
- context
65
- }) => {
66
- const _a = block,
67
- {
68
- repeat
69
- } = _a,
70
- blockWithoutRepeat = __objRest(_a, ["repeat"]);
71
- if (!(repeat == null ? void 0 : repeat.collection)) {
72
- return void 0;
73
- }
74
- const itemsArray = evaluate({
75
- code: repeat.collection,
76
- localState: context.localState,
77
- rootState: context.rootState,
78
- rootSetState: context.rootSetState,
79
- context: context.context
80
- });
81
- if (!Array.isArray(itemsArray)) {
82
- return void 0;
83
- }
84
- const collectionName = repeat.collection.split(".").pop();
85
- const itemNameToUse = repeat.itemName || (collectionName ? collectionName + "Item" : "item");
86
- const repeatArray = itemsArray.map((item, index) => ({
87
- context: __spreadProps(__spreadValues({}, context), {
88
- localState: __spreadProps(__spreadValues({}, context.localState), {
89
- $index: index,
90
- $item: item,
91
- [itemNameToUse]: item,
92
- [`$${itemNameToUse}Index`]: index
93
- })
94
- }),
95
- block: blockWithoutRepeat
96
- }));
97
- return repeatArray;
98
- };
99
- export { getComponent, getRepeatItemData, isEmptyHtmlElement }
@@ -1,167 +0,0 @@
1
- import { Show, For, createSignal } from "solid-js";
2
-
3
- import { getBlockComponentOptions } from "../../functions/get-block-component-options.js";
4
- import { getBlockProperties } from "../../functions/get-block-properties.js";
5
- import { getProcessedBlock } from "../../functions/get-processed-block.js";
6
- import BlockStyles from "./components/block-styles";
7
- import {
8
- getComponent,
9
- getRepeatItemData,
10
- isEmptyHtmlElement,
11
- } from "./block.helpers.js";
12
- import RepeatedBlock from "./components/repeated-block";
13
- import { extractTextStyles } from "../../functions/extract-text-styles.js";
14
- import ComponentRef from "./components/component-ref/component-ref";
15
- import BlockWrapper from "./components/block-wrapper";
16
-
17
- function Block(props) {
18
- const [childrenContext, setChildrenContext] = createSignal(props.context);
19
-
20
- function blockComponent() {
21
- return getComponent({
22
- block: props.block,
23
- context: props.context,
24
- registeredComponents: props.registeredComponents,
25
- });
26
- }
27
-
28
- function repeatItem() {
29
- return getRepeatItemData({
30
- block: props.block,
31
- context: props.context,
32
- });
33
- }
34
-
35
- function processedBlock() {
36
- return repeatItem()
37
- ? props.block
38
- : getProcessedBlock({
39
- block: props.block,
40
- localState: props.context.localState,
41
- rootState: props.context.rootState,
42
- rootSetState: props.context.rootSetState,
43
- context: props.context.context,
44
- shouldEvaluateBindings: true,
45
- });
46
- }
47
-
48
- function Tag() {
49
- return props.block.tagName || "div";
50
- }
51
-
52
- function canShowBlock() {
53
- if ("hide" in processedBlock()) {
54
- return !processedBlock().hide;
55
- }
56
- if ("show" in processedBlock()) {
57
- return processedBlock().show;
58
- }
59
- return true;
60
- }
61
-
62
- function childrenWithoutParentComponent() {
63
- /**
64
- * When there is no `componentRef`, there might still be children that need to be rendered. In this case,
65
- * we render them outside of `componentRef`.
66
- * NOTE: We make sure not to render this if `repeatItemData` is non-null, because that means we are rendering an array of
67
- * blocks, and the children will be repeated within those blocks.
68
- */
69
- const shouldRenderChildrenOutsideRef =
70
- !blockComponent()?.component && !repeatItem();
71
- return shouldRenderChildrenOutsideRef
72
- ? processedBlock().children ?? []
73
- : [];
74
- }
75
-
76
- function componentRefProps() {
77
- return {
78
- blockChildren: processedBlock().children ?? [],
79
- componentRef: blockComponent()?.component,
80
- componentOptions: {
81
- ...getBlockComponentOptions(processedBlock()),
82
- builderContext: props.context,
83
- ...(blockComponent()?.name === "Symbol" ||
84
- blockComponent()?.name === "Columns"
85
- ? {
86
- builderComponents: props.registeredComponents,
87
- }
88
- : {}),
89
- },
90
- context: childrenContext(),
91
- registeredComponents: props.registeredComponents,
92
- builderBlock: processedBlock(),
93
- includeBlockProps: blockComponent()?.noWrap === true,
94
- isInteractive: !blockComponent()?.isRSC,
95
- };
96
- }
97
-
98
- return (
99
- <Show when={canShowBlock()}>
100
- <Show
101
- fallback={<ComponentRef {...componentRefProps()}></ComponentRef>}
102
- when={!blockComponent()?.noWrap}
103
- >
104
- <Show when={isEmptyHtmlElement(Tag())}>
105
- <BlockWrapper
106
- Wrapper={Tag()}
107
- block={processedBlock()}
108
- context={props.context}
109
- hasChildren={false}
110
- ></BlockWrapper>
111
- </Show>
112
- <Show when={!isEmptyHtmlElement(Tag()) && repeatItem()}>
113
- <For each={repeatItem()}>
114
- {(data, _index) => {
115
- const index = _index();
116
- return (
117
- <RepeatedBlock
118
- key={index}
119
- repeatContext={data.context}
120
- block={data.block}
121
- registeredComponents={props.registeredComponents}
122
- ></RepeatedBlock>
123
- );
124
- }}
125
- </For>
126
- </Show>
127
- <Show when={!isEmptyHtmlElement(Tag()) && !repeatItem()}>
128
- <BlockWrapper
129
- Wrapper={Tag()}
130
- block={processedBlock()}
131
- context={props.context}
132
- hasChildren={true}
133
- >
134
- <ComponentRef {...componentRefProps()}></ComponentRef>
135
- <For each={childrenWithoutParentComponent()}>
136
- {(child, _index) => {
137
- const index = _index();
138
- return (
139
- <Block
140
- key={"block-" + child.id}
141
- block={child}
142
- context={childrenContext()}
143
- registeredComponents={props.registeredComponents}
144
- ></Block>
145
- );
146
- }}
147
- </For>
148
- <For each={childrenWithoutParentComponent()}>
149
- {(child, _index) => {
150
- const index = _index();
151
- return (
152
- <BlockStyles
153
- key={"block-style-" + child.id}
154
- block={child}
155
- context={childrenContext()}
156
- ></BlockStyles>
157
- );
158
- }}
159
- </For>
160
- </BlockWrapper>
161
- </Show>
162
- </Show>
163
- </Show>
164
- );
165
- }
166
-
167
- export default Block;