@builder.io/sdk-solid 0.0.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.
Files changed (89) hide show
  1. package/README.md +3 -0
  2. package/package.json +9 -0
  3. package/src/blocks/button.js +41 -0
  4. package/src/blocks/button.lite.tsx +18 -0
  5. package/src/blocks/columns.js +133 -0
  6. package/src/blocks/columns.lite.tsx +96 -0
  7. package/src/blocks/custom-code.js +72 -0
  8. package/src/blocks/custom-code.lite.tsx +65 -0
  9. package/src/blocks/embed.js +62 -0
  10. package/src/blocks/embed.lite.tsx +57 -0
  11. package/src/blocks/form.js +355 -0
  12. package/src/blocks/form.lite.tsx +291 -0
  13. package/src/blocks/fragment.js +15 -0
  14. package/src/blocks/fragment.lite.tsx +3 -0
  15. package/src/blocks/image.js +136 -0
  16. package/src/blocks/image.lite.tsx +81 -0
  17. package/src/blocks/img.js +39 -0
  18. package/src/blocks/img.lite.tsx +16 -0
  19. package/src/blocks/input.js +45 -0
  20. package/src/blocks/input.lite.tsx +18 -0
  21. package/src/blocks/raw-text.js +25 -0
  22. package/src/blocks/raw-text.lite.tsx +8 -0
  23. package/src/blocks/section.js +24 -0
  24. package/src/blocks/section.lite.tsx +16 -0
  25. package/src/blocks/select.js +57 -0
  26. package/src/blocks/select.lite.tsx +23 -0
  27. package/src/blocks/submit-button.js +18 -0
  28. package/src/blocks/submit-button.lite.tsx +7 -0
  29. package/src/blocks/symbol.js +69 -0
  30. package/src/blocks/symbol.lite.tsx +37 -0
  31. package/src/blocks/text.js +15 -0
  32. package/src/blocks/text.lite.tsx +3 -0
  33. package/src/blocks/textarea.js +34 -0
  34. package/src/blocks/textarea.lite.tsx +11 -0
  35. package/src/blocks/video.js +54 -0
  36. package/src/blocks/video.lite.tsx +24 -0
  37. package/src/components/block-styles.js +3 -0
  38. package/src/components/block-styles.lite.tsx +3 -0
  39. package/src/components/error-boundary.js +3 -0
  40. package/src/components/error-boundary.lite.tsx +3 -0
  41. package/src/components/render-block.js +154 -0
  42. package/src/components/render-block.lite.tsx +108 -0
  43. package/src/components/render-blocks.js +104 -0
  44. package/src/components/render-blocks.lite.tsx +72 -0
  45. package/src/components/render-content.js +314 -0
  46. package/src/components/render-content.lite.tsx +289 -0
  47. package/src/constants/device-sizes.js +39 -0
  48. package/src/context/builder.context.js +10 -0
  49. package/src/functions/evaluate.js +28 -0
  50. package/src/functions/event-handler-name.js +7 -0
  51. package/src/functions/get-block-actions.js +23 -0
  52. package/src/functions/get-block-component-options.js +23 -0
  53. package/src/functions/get-block-properties.js +29 -0
  54. package/src/functions/get-block-styles.js +42 -0
  55. package/src/functions/get-block-tag.js +6 -0
  56. package/src/functions/get-builder-search-params/fn.test.js +13 -0
  57. package/src/functions/get-builder-search-params/index.js +22 -0
  58. package/src/functions/get-content/fn.test.js +31 -0
  59. package/src/functions/get-content/index.js +137 -0
  60. package/src/functions/get-fetch.js +12 -0
  61. package/src/functions/get-global-this.js +18 -0
  62. package/src/functions/get-processed-block.js +46 -0
  63. package/src/functions/get-processed-block.test.js +31 -0
  64. package/src/functions/get-target.js +6 -0
  65. package/src/functions/if-target.js +6 -0
  66. package/src/functions/is-browser.js +6 -0
  67. package/src/functions/is-editing.js +7 -0
  68. package/src/functions/is-iframe.js +7 -0
  69. package/src/functions/is-previewing.js +14 -0
  70. package/src/functions/is-react-native.js +6 -0
  71. package/src/functions/macro-eval.js +5 -0
  72. package/src/functions/on-change.js +27 -0
  73. package/src/functions/on-change.test.js +19 -0
  74. package/src/functions/previewing-model-name.js +11 -0
  75. package/src/functions/register-component.js +53 -0
  76. package/src/functions/register.js +29 -0
  77. package/src/functions/set-editor-settings.js +15 -0
  78. package/src/functions/set.js +11 -0
  79. package/src/functions/set.test.js +16 -0
  80. package/src/functions/track.js +22 -0
  81. package/src/functions/transform-block.js +6 -0
  82. package/src/index-helpers/blocks-exports.js +20 -0
  83. package/src/index-helpers/top-of-file.js +4 -0
  84. package/src/index.js +13 -0
  85. package/src/scripts/init-editing.js +70 -0
  86. package/src/types/builder-block.js +0 -0
  87. package/src/types/builder-content.js +0 -0
  88. package/src/types/deep-partial.js +0 -0
  89. package/src/types/typescript.js +0 -0
@@ -0,0 +1,34 @@
1
+ import { template as _$template } from "solid-js/web";
2
+ import { setAttribute as _$setAttribute } from "solid-js/web";
3
+ import { effect as _$effect } from "solid-js/web";
4
+ import { spread as _$spread } from "solid-js/web";
5
+
6
+ const _tmpl$ = /*#__PURE__*/_$template(`<textarea></textarea>`, 2);
7
+
8
+ export default function Textarea(props) {
9
+ return (() => {
10
+ const _el$ = _tmpl$.cloneNode(true);
11
+
12
+ _$spread(_el$, () => props.attributes, false, false);
13
+
14
+ _$effect(_p$ => {
15
+ const _v$ = props.placeholder,
16
+ _v$2 = props.name,
17
+ _v$3 = props.value,
18
+ _v$4 = props.defaultValue;
19
+ _v$ !== _p$._v$ && _$setAttribute(_el$, "placeholder", _p$._v$ = _v$);
20
+ _v$2 !== _p$._v$2 && _$setAttribute(_el$, "name", _p$._v$2 = _v$2);
21
+ _v$3 !== _p$._v$3 && (_el$.value = _p$._v$3 = _v$3);
22
+ _v$4 !== _p$._v$4 && _$setAttribute(_el$, "defaultvalue", _p$._v$4 = _v$4);
23
+ return _p$;
24
+ }, {
25
+ _v$: undefined,
26
+ _v$2: undefined,
27
+ _v$3: undefined,
28
+ _v$4: undefined
29
+ });
30
+
31
+ return _el$;
32
+ })();
33
+ }import { registerComponent } from '../functions/register-component';
34
+ registerComponent(Textarea, {name:'Form:TextArea',builtIn:true,image:'https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2Ff74a2f3de58c4c3e939204e5b6b8f6c3',inputs:[{advanced:true,name:'value',type:'string'},{name:'name',type:'string',required:true,helperText:'Every input in a form needs a unique name describing what it gets, e.g. "email"'},{name:'defaultValue',type:'string'},{name:'placeholder',type:'string',defaultValue:'Hello there'},{name:'required',type:'boolean',defaultValue:false}],defaultStyles:{paddingTop:'10px',paddingBottom:'10px',paddingLeft:'10px',paddingRight:'10px',borderRadius:'3px',borderWidth:'1px',borderStyle:'solid',borderColor:'#ccc'},static:true,noWrap:true});
@@ -0,0 +1,11 @@
1
+ export default function Textarea(props) {
2
+ return (
3
+ <textarea
4
+ {...props.attributes}
5
+ placeholder={props.placeholder}
6
+ name={props.name}
7
+ value={props.value}
8
+ defaultValue={props.defaultValue}
9
+ ></textarea>
10
+ );
11
+ }
@@ -0,0 +1,54 @@
1
+ import { template as _$template } from "solid-js/web";
2
+ import { setAttribute as _$setAttribute } from "solid-js/web";
3
+ import { style as _$style } from "solid-js/web";
4
+ import { effect as _$effect } from "solid-js/web";
5
+ import { spread as _$spread } from "solid-js/web";
6
+
7
+ const _tmpl$ = /*#__PURE__*/_$template(`<video preload="none"></video>`, 2);
8
+
9
+ export default function Video(props) {
10
+ return (() => {
11
+ const _el$ = _tmpl$.cloneNode(true);
12
+
13
+ _$spread(_el$, () => props.attributes, false, false);
14
+
15
+ _$effect(_p$ => {
16
+ const _v$ = {
17
+ width: "100%",
18
+ height: "100%",
19
+ ...props.attributes?.style,
20
+ objectFit: props.fit,
21
+ objectPosition: props.position,
22
+ // Hack to get object fit to work as expected and
23
+ // not have the video overflow
24
+ borderRadius: 1
25
+ },
26
+ _v$2 = props.video || "no-src",
27
+ _v$3 = props.posterImage,
28
+ _v$4 = props.autoPlay,
29
+ _v$5 = props.muted,
30
+ _v$6 = props.controls,
31
+ _v$7 = props.loop;
32
+
33
+ _p$._v$ = _$style(_el$, _v$, _p$._v$);
34
+ _v$2 !== _p$._v$2 && _$setAttribute(_el$, "key", _p$._v$2 = _v$2);
35
+ _v$3 !== _p$._v$3 && _$setAttribute(_el$, "poster", _p$._v$3 = _v$3);
36
+ _v$4 !== _p$._v$4 && _$setAttribute(_el$, "autoplay", _p$._v$4 = _v$4);
37
+ _v$5 !== _p$._v$5 && (_el$.muted = _p$._v$5 = _v$5);
38
+ _v$6 !== _p$._v$6 && (_el$.controls = _p$._v$6 = _v$6);
39
+ _v$7 !== _p$._v$7 && (_el$.loop = _p$._v$7 = _v$7);
40
+ return _p$;
41
+ }, {
42
+ _v$: undefined,
43
+ _v$2: undefined,
44
+ _v$3: undefined,
45
+ _v$4: undefined,
46
+ _v$5: undefined,
47
+ _v$6: undefined,
48
+ _v$7: undefined
49
+ });
50
+
51
+ return _el$;
52
+ })();
53
+ }import { registerComponent } from '../functions/register-component';
54
+ registerComponent(Video, {name:'Video',canHaveChildren:true,builtIn:true,defaultStyles:{minHeight:'20px',minWidth:'20px'},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',inputs:[{name:'video',type:'file',allowedFileTypes:['mp4'],bubble:true,defaultValue:'https://firebasestorage.googleapis.com/v0/b/builder-3b0a2.appspot.com/o/assets%2FKQlEmWDxA0coC3PK6UvkrjwkIGI2%2F28cb070609f546cdbe5efa20e931aa4b?alt=media&token=912e9551-7a7c-4dfb-86b6-3da1537d1a7f',required:true},{name:'posterImage',type:'file',allowedFileTypes:['jpeg','png'],helperText:'Image to show before the video plays'},{name:'autoPlay',type:'boolean',defaultValue:true},{name:'controls',type:'boolean',defaultValue:false},{name:'muted',type:'boolean',defaultValue:true},{name:'loop',type:'boolean',defaultValue:true},{name:'playsInline',type:'boolean',defaultValue:true},{name:'fit',type:'text',defaultValue:'cover',enum:['contain','cover','fill','auto']},{name:'fitContent',type:'boolean',helperText:'When child blocks are provided, fit to them instead of using the aspect ratio',defaultValue:true,advanced:true},{name:'position',type:'text',defaultValue:'center',enum:['center','top','left','right','bottom','top left','top right','bottom left','bottom right']},{name:'height',type:'number',advanced:true},{name:'width',type:'number',advanced:true},{name:'aspectRatio',type:'number',advanced:true,defaultValue:0.7004048582995948},{name:'lazyLoad',type:'boolean',helperText:'Load this video "lazily" - as in only when a user scrolls near the video. Recommended for optmized performance and bandwidth consumption',defaultValue:true,advanced:true}]});
@@ -0,0 +1,24 @@
1
+ export default function Video(props) {
2
+ return (
3
+ <video
4
+ {...props.attributes}
5
+ preload="none"
6
+ style={{
7
+ width: "100%",
8
+ height: "100%",
9
+ ...props.attributes?.style,
10
+ objectFit: props.fit,
11
+ objectPosition: props.position,
12
+ // Hack to get object fit to work as expected and
13
+ // not have the video overflow
14
+ borderRadius: 1,
15
+ }}
16
+ key={props.video || "no-src"}
17
+ poster={props.posterImage}
18
+ autoPlay={props.autoPlay}
19
+ muted={props.muted}
20
+ controls={props.controls}
21
+ loop={props.loop}
22
+ ></video>
23
+ );
24
+ }
@@ -0,0 +1,3 @@
1
+ export default function BlockStyles(props) {
2
+ return [];
3
+ }
@@ -0,0 +1,3 @@
1
+ export default function BlockStyles(props) {
2
+ return <></>;
3
+ }
@@ -0,0 +1,3 @@
1
+ export default function ErrorBoundary(props) {
2
+ return [];
3
+ }
@@ -0,0 +1,3 @@
1
+ export default function ErrorBoundary(props) {
2
+ return <></>;
3
+ }
@@ -0,0 +1,154 @@
1
+ import { mergeProps as _$mergeProps } from "solid-js/web";
2
+ import { createComponent as _$createComponent } from "solid-js/web";
3
+ import { Show, For } from "solid-js";
4
+ import { Dynamic } from "solid-js/web";
5
+ import { createMutable } from "solid-js/store";
6
+ import { getBlockComponentOptions } from "../functions/get-block-component-options";
7
+ import { getBlockProperties } from "../functions/get-block-properties";
8
+ import { getBlockStyles } from "../functions/get-block-styles";
9
+ import { getBlockTag } from "../functions/get-block-tag";
10
+ import { components } from "../functions/register-component";
11
+ import BuilderContext from "../context/builder.context";
12
+ import { getBlockActions } from "../functions/get-block-actions";
13
+ import { getProcessedBlock } from "../functions/get-processed-block";
14
+ import BlockStyles from "./block-styles";
15
+ export default function RenderBlock(props) {
16
+ const state = createMutable({
17
+ get component() {
18
+ const componentName = state.useBlock.component?.name;
19
+
20
+ if (!componentName) {
21
+ return null;
22
+ }
23
+
24
+ const ref = components[state.useBlock.component?.name];
25
+
26
+ if (componentName && !ref) {
27
+ // TODO: Public doc page with more info about this message
28
+ console.warn(`
29
+ Could not find a registered component named "${componentName}".
30
+ If you registered it, is the file that registered it imported by the file that needs to render it?`);
31
+ }
32
+
33
+ return ref;
34
+ },
35
+
36
+ get componentInfo() {
37
+ return state.component?.info;
38
+ },
39
+
40
+ get componentRef() {
41
+ return state.component?.component;
42
+ },
43
+
44
+ get tagName() {
45
+ return getBlockTag(state.useBlock);
46
+ },
47
+
48
+ get useBlock() {
49
+ return getProcessedBlock({
50
+ block: props.block,
51
+ state: builderContext.state,
52
+ context: builderContext.context
53
+ });
54
+ },
55
+
56
+ get propertiesAndActions() {
57
+ return { ...getBlockProperties(state.useBlock),
58
+ ...getBlockActions({
59
+ block: state.useBlock,
60
+ state: builderContext.state,
61
+ context: builderContext.context
62
+ })
63
+ };
64
+ },
65
+
66
+ get css() {
67
+ return getBlockStyles(state.useBlock);
68
+ },
69
+
70
+ get componentOptions() {
71
+ return getBlockComponentOptions(state.useBlock);
72
+ },
73
+
74
+ get children() {
75
+ // TO-DO: When should `canHaveChildren` dictate rendering?
76
+ // This is currently commented out because some Builder components (e.g. Box) do not have `canHaveChildren: true`,
77
+ // but still receive and need to render children.
78
+ // return state.componentInfo?.canHaveChildren ? state.useBlock.children : [];
79
+ return state.useBlock.children ?? [];
80
+ },
81
+
82
+ get noCompRefChildren() {
83
+ return state.componentRef ? [] : state.children;
84
+ }
85
+
86
+ });
87
+ const builderContext = useContext(BuilderContext);
88
+ return _$createComponent(Show, {
89
+ get when() {
90
+ return !state.componentInfo?.noWrap;
91
+ },
92
+
93
+ get children() {
94
+ return _$createComponent(Dynamic, _$mergeProps(() => state.propertiesAndActions, {
95
+ get style() {
96
+ return state.css;
97
+ },
98
+
99
+ get component() {
100
+ return state.tagName;
101
+ },
102
+
103
+ get children() {
104
+ return [_$createComponent(BlockStyles, {
105
+ get block() {
106
+ return state.useBlock;
107
+ }
108
+
109
+ }), _$createComponent(Show, {
110
+ get when() {
111
+ return state.componentRef;
112
+ },
113
+
114
+ get children() {
115
+ return _$createComponent(Dynamic, _$mergeProps(() => state.componentOptions, {
116
+ get builderBlock() {
117
+ return state.useBlock;
118
+ },
119
+
120
+ get component() {
121
+ return state.componentRef;
122
+ },
123
+
124
+ get children() {
125
+ return _$createComponent(For, {
126
+ get each() {
127
+ return state.children;
128
+ },
129
+
130
+ children: (child, index) => _$createComponent(RenderBlock, {
131
+ block: child
132
+ })
133
+ });
134
+ }
135
+
136
+ }));
137
+ }
138
+
139
+ }), _$createComponent(For, {
140
+ get each() {
141
+ return state.noCompRefChildren;
142
+ },
143
+
144
+ children: (child, index) => _$createComponent(RenderBlock, {
145
+ block: child
146
+ })
147
+ })];
148
+ }
149
+
150
+ }));
151
+ }
152
+
153
+ });
154
+ }
@@ -0,0 +1,108 @@
1
+ import { Show, For } from "solid-js";
2
+ import { Dynamic } from "solid-js/web";
3
+ import { createMutable } from "solid-js/store";
4
+
5
+ import { getBlockComponentOptions } from "../functions/get-block-component-options";
6
+ import { getBlockProperties } from "../functions/get-block-properties";
7
+ import { getBlockStyles } from "../functions/get-block-styles";
8
+ import { getBlockTag } from "../functions/get-block-tag";
9
+ import { components } from "../functions/register-component";
10
+ import BuilderContext from "../context/builder.context.lite";
11
+ import { getBlockActions } from "../functions/get-block-actions";
12
+ import { getProcessedBlock } from "../functions/get-processed-block";
13
+ import BlockStyles from "./block-styles.lite";
14
+
15
+ export default function RenderBlock(props) {
16
+ const state = createMutable({
17
+ get component() {
18
+ const componentName = state.useBlock.component?.name;
19
+
20
+ if (!componentName) {
21
+ return null;
22
+ }
23
+
24
+ const ref = components[state.useBlock.component?.name!];
25
+
26
+ if (componentName && !ref) {
27
+ // TODO: Public doc page with more info about this message
28
+ console.warn(`
29
+ Could not find a registered component named "${componentName}".
30
+ If you registered it, is the file that registered it imported by the file that needs to render it?`);
31
+ }
32
+
33
+ return ref;
34
+ },
35
+ get componentInfo() {
36
+ return state.component?.info;
37
+ },
38
+ get componentRef() {
39
+ return state.component?.component;
40
+ },
41
+ get tagName() {
42
+ return getBlockTag(state.useBlock);
43
+ },
44
+ get useBlock() {
45
+ return getProcessedBlock({
46
+ block: props.block,
47
+ state: builderContext.state,
48
+ context: builderContext.context,
49
+ });
50
+ },
51
+ get propertiesAndActions() {
52
+ return {
53
+ ...getBlockProperties(state.useBlock),
54
+ ...getBlockActions({
55
+ block: state.useBlock,
56
+ state: builderContext.state,
57
+ context: builderContext.context,
58
+ }),
59
+ };
60
+ },
61
+ get css() {
62
+ return getBlockStyles(state.useBlock);
63
+ },
64
+ get componentOptions() {
65
+ return getBlockComponentOptions(state.useBlock);
66
+ },
67
+ get children() {
68
+ // TO-DO: When should `canHaveChildren` dictate rendering?
69
+ // This is currently commented out because some Builder components (e.g. Box) do not have `canHaveChildren: true`,
70
+ // but still receive and need to render children.
71
+ // return state.componentInfo?.canHaveChildren ? state.useBlock.children : [];
72
+ return state.useBlock.children ?? [];
73
+ },
74
+ get noCompRefChildren() {
75
+ return state.componentRef ? [] : state.children;
76
+ },
77
+ });
78
+
79
+ const builderContext = useContext(BuilderContext);
80
+
81
+ return (
82
+ <>
83
+ <Show when={!state.componentInfo?.noWrap}>
84
+ <Dynamic
85
+ {...state.propertiesAndActions}
86
+ style={state.css}
87
+ component={state.tagName}
88
+ >
89
+ <BlockStyles block={state.useBlock}></BlockStyles>
90
+ <Show when={state.componentRef}>
91
+ <Dynamic
92
+ {...state.componentOptions}
93
+ builderBlock={state.useBlock}
94
+ component={state.componentRef}
95
+ >
96
+ <For each={state.children}>
97
+ {(child, index) => <RenderBlock block={child}></RenderBlock>}
98
+ </For>
99
+ </Dynamic>
100
+ </Show>
101
+ <For each={state.noCompRefChildren}>
102
+ {(child, index) => <RenderBlock block={child}></RenderBlock>}
103
+ </For>
104
+ </Dynamic>
105
+ </Show>
106
+ </>
107
+ );
108
+ }
@@ -0,0 +1,104 @@
1
+ import { template as _$template } from "solid-js/web";
2
+ import { delegateEvents as _$delegateEvents } from "solid-js/web";
3
+ import { setAttribute as _$setAttribute } from "solid-js/web";
4
+ import { effect as _$effect } from "solid-js/web";
5
+ import { insert as _$insert } from "solid-js/web";
6
+ import { createComponent as _$createComponent } from "solid-js/web";
7
+
8
+ const _tmpl$ = /*#__PURE__*/_$template(`<div></div>`, 2);
9
+
10
+ import { Show, For } from "solid-js";
11
+ import { createMutable } from "solid-js/store";
12
+ import { css } from "solid-styled-components";
13
+ import { isEditing } from "../functions/is-editing";
14
+ import RenderBlock from "./render-block";
15
+ export default function RenderBlocks(props) {
16
+ const state = createMutable({
17
+ get className() {
18
+ return "builder-blocks" + (!props.blocks?.length ? " no-blocks" : "");
19
+ },
20
+
21
+ onClick() {
22
+ if (isEditing() && !props.blocks?.length) {
23
+ window.parent?.postMessage({
24
+ type: "builder.clickEmptyBlocks",
25
+ data: {
26
+ parentElementId: props.parent,
27
+ dataPath: props.path
28
+ }
29
+ }, "*");
30
+ }
31
+ },
32
+
33
+ onMouseEnter() {
34
+ if (isEditing() && !props.blocks?.length) {
35
+ window.parent?.postMessage({
36
+ type: "builder.hoverEmptyBlocks",
37
+ data: {
38
+ parentElementId: props.parent,
39
+ dataPath: props.path
40
+ }
41
+ }, "*");
42
+ }
43
+ }
44
+
45
+ });
46
+ return (() => {
47
+ const _el$ = _tmpl$.cloneNode(true);
48
+
49
+ _el$.addEventListener("mouseenter", event => state.onMouseEnter());
50
+
51
+ _el$.$$click = event => state.onClick();
52
+
53
+ _$insert(_el$, _$createComponent(Show, {
54
+ get when() {
55
+ return props.blocks;
56
+ },
57
+
58
+ get children() {
59
+ return _$createComponent(For, {
60
+ get each() {
61
+ return props.blocks;
62
+ },
63
+
64
+ children: (block, index) => _$createComponent(RenderBlock, {
65
+ get key() {
66
+ return block.id;
67
+ },
68
+
69
+ block: block
70
+ })
71
+ });
72
+ }
73
+
74
+ }));
75
+
76
+ _$effect(_p$ => {
77
+ const _v$ = state.className + " " + css({
78
+ display: "flex",
79
+ flexDirection: "column",
80
+ alignItems: "stretch"
81
+ }),
82
+ _v$2 = props.path,
83
+ _v$3 = props.parent,
84
+ _v$4 = {
85
+ class: state.className
86
+ };
87
+
88
+ _v$ !== _p$._v$ && (_el$.className = _p$._v$ = _v$);
89
+ _v$2 !== _p$._v$2 && _$setAttribute(_el$, "builder-path", _p$._v$2 = _v$2);
90
+ _v$3 !== _p$._v$3 && _$setAttribute(_el$, "builder-parent-id", _p$._v$3 = _v$3);
91
+ _v$4 !== _p$._v$4 && _$setAttribute(_el$, "dataset", _p$._v$4 = _v$4);
92
+ return _p$;
93
+ }, {
94
+ _v$: undefined,
95
+ _v$2: undefined,
96
+ _v$3: undefined,
97
+ _v$4: undefined
98
+ });
99
+
100
+ return _el$;
101
+ })();
102
+ }
103
+
104
+ _$delegateEvents(["click"]);
@@ -0,0 +1,72 @@
1
+ import { Show, For } from "solid-js";
2
+
3
+ import { createMutable } from "solid-js/store";
4
+ import { css } from "solid-styled-components";
5
+
6
+ import { isEditing } from "../functions/is-editing";
7
+ import RenderBlock from "./render-block.lite";
8
+
9
+ export default function RenderBlocks(props) {
10
+ const state = createMutable({
11
+ get className() {
12
+ return "builder-blocks" + (!props.blocks?.length ? " no-blocks" : "");
13
+ },
14
+ onClick() {
15
+ if (isEditing() && !props.blocks?.length) {
16
+ window.parent?.postMessage(
17
+ {
18
+ type: "builder.clickEmptyBlocks",
19
+ data: {
20
+ parentElementId: props.parent,
21
+ dataPath: props.path,
22
+ },
23
+ },
24
+ "*"
25
+ );
26
+ }
27
+ },
28
+ onMouseEnter() {
29
+ if (isEditing() && !props.blocks?.length) {
30
+ window.parent?.postMessage(
31
+ {
32
+ type: "builder.hoverEmptyBlocks",
33
+ data: {
34
+ parentElementId: props.parent,
35
+ dataPath: props.path,
36
+ },
37
+ },
38
+ "*"
39
+ );
40
+ }
41
+ },
42
+ });
43
+
44
+ return (
45
+ <div
46
+ class={
47
+ state.className +
48
+ " " +
49
+ css({
50
+ display: "flex",
51
+ flexDirection: "column",
52
+ alignItems: "stretch",
53
+ })
54
+ }
55
+ builder-path={props.path}
56
+ builder-parent-id={props.parent}
57
+ dataSet={{
58
+ class: state.className,
59
+ }}
60
+ onClick={(event) => state.onClick()}
61
+ onMouseEnter={(event) => state.onMouseEnter()}
62
+ >
63
+ <Show when={props.blocks}>
64
+ <For each={props.blocks}>
65
+ {(block, index) => (
66
+ <RenderBlock key={block.id} block={block}></RenderBlock>
67
+ )}
68
+ </For>
69
+ </Show>
70
+ </div>
71
+ );
72
+ }