@builder.io/sdk-solid 0.0.8-6 → 0.0.8-9

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@builder.io/sdk-solid",
3
- "version": "0.0.8-6",
3
+ "version": "0.0.8-9",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "./src/solid-index.jsx",
@@ -16,11 +16,11 @@
16
16
  "solid-styled-components": "^0.27.6"
17
17
  },
18
18
  "peerDependencies": {
19
- "solid-js": "^1.3.15"
19
+ "solid-js": "^1.4.3"
20
20
  },
21
21
  "devDependencies": {
22
22
  "babel-preset-solid": "^1.3.17",
23
- "solid-js": "^1.3.15",
23
+ "solid-js": "^1.4.3",
24
24
  "vite": "^2.9.8",
25
25
  "vite-plugin-solid": "^2.2.6"
26
26
  }
@@ -51,7 +51,7 @@ function Columns(props) {
51
51
  }
52
52
 
53
53
  });
54
- return <div class={css({
54
+ return <div class={"builder-columns " + css({
55
55
  display: "flex",
56
56
  alignItems: "stretch",
57
57
  lineHeight: "normal",
@@ -66,7 +66,7 @@ function Columns(props) {
66
66
  {(column, _index) => {
67
67
  const index = _index();
68
68
 
69
- return <div class={css({
69
+ return <div class={"builder-column " + css({
70
70
  flexGrow: "1",
71
71
  "@media (max-width: 999px)": {
72
72
  width: "var(--column-width-tablet) !important",
@@ -80,7 +80,7 @@ function Columns(props) {
80
80
  width: state.getColumnCssWidth(index),
81
81
  "margin-left": `${index === 0 ? 0 : state.getGutterSize()}px`,
82
82
  ...state.columnCssVars
83
- }}>
83
+ }} key={index}>
84
84
  <RenderBlocks blocks={column.blocks}></RenderBlocks>
85
85
  </div>;
86
86
  }}
@@ -55,17 +55,20 @@ function Columns(props) {
55
55
 
56
56
  return (
57
57
  <div
58
- class={css({
59
- display: "flex",
60
- alignItems: "stretch",
61
- lineHeight: "normal",
62
- "@media (max-width: 999px)": {
63
- flexDirection: "var(--flex-dir-tablet)",
64
- },
65
- "@media (max-width: 639px)": {
66
- flexDirection: "var(--flex-dir)",
67
- },
68
- })}
58
+ class={
59
+ "builder-columns " +
60
+ css({
61
+ display: "flex",
62
+ alignItems: "stretch",
63
+ lineHeight: "normal",
64
+ "@media (max-width: 999px)": {
65
+ flexDirection: "var(--flex-dir-tablet)",
66
+ },
67
+ "@media (max-width: 639px)": {
68
+ flexDirection: "var(--flex-dir)",
69
+ },
70
+ })
71
+ }
69
72
  style={state.columnsCssVars}
70
73
  >
71
74
  <For each={props.columns}>
@@ -73,22 +76,26 @@ function Columns(props) {
73
76
  const index = _index();
74
77
  return (
75
78
  <div
76
- class={css({
77
- flexGrow: "1",
78
- "@media (max-width: 999px)": {
79
- width: "var(--column-width-tablet) !important",
80
- marginLeft: "var(--column-margin-left-tablet) !important",
81
- },
82
- "@media (max-width: 639px)": {
83
- width: "var(--column-width) !important",
84
- marginLeft: "var(--column-margin-left) !important",
85
- },
86
- })}
79
+ class={
80
+ "builder-column " +
81
+ css({
82
+ flexGrow: "1",
83
+ "@media (max-width: 999px)": {
84
+ width: "var(--column-width-tablet) !important",
85
+ marginLeft: "var(--column-margin-left-tablet) !important",
86
+ },
87
+ "@media (max-width: 639px)": {
88
+ width: "var(--column-width) !important",
89
+ marginLeft: "var(--column-margin-left) !important",
90
+ },
91
+ })
92
+ }
87
93
  style={{
88
94
  width: state.getColumnCssWidth(index),
89
95
  "margin-left": `${index === 0 ? 0 : state.getGutterSize()}px`,
90
96
  ...state.columnCssVars,
91
97
  }}
98
+ key={index}
92
99
  >
93
100
  <RenderBlocks blocks={column.blocks}></RenderBlocks>
94
101
  </div>
@@ -46,7 +46,7 @@ function Embed(props) {
46
46
  onMount(() => {
47
47
  state.findAndRunScripts();
48
48
  });
49
- return <div ref={elem} innerHTML={props.content}></div>;
49
+ return <div class="builder-embed" ref={elem} innerHTML={props.content}></div>;
50
50
  }
51
51
 
52
52
  export default Embed;
@@ -55,7 +55,7 @@ function Embed(props) {
55
55
  state.findAndRunScripts();
56
56
  });
57
57
 
58
- return <div ref={elem} innerHTML={props.content}></div>;
58
+ return <div class="builder-embed" ref={elem} innerHTML={props.content}></div>;
59
59
  }
60
60
 
61
61
  export default Embed;
@@ -236,7 +236,7 @@ function FormComponent(props) {
236
236
  <BuilderBlocks dataPath="sendingMessage" blocks={props.sendingMessage}></BuilderBlocks>
237
237
  </Show>
238
238
  <Show when={state.submissionState === "error" && state.responseData}>
239
- <pre class={css({
239
+ <pre class={"builder-form-error-text " + css({
240
240
  padding: "10px",
241
241
  color: "red",
242
242
  textAlign: "center"
@@ -271,11 +271,14 @@ function FormComponent(props) {
271
271
  </Show>
272
272
  <Show when={state.submissionState === "error" && state.responseData}>
273
273
  <pre
274
- class={css({
275
- padding: "10px",
276
- color: "red",
277
- textAlign: "center",
278
- })}
274
+ class={
275
+ "builder-form-error-text " +
276
+ css({
277
+ padding: "10px",
278
+ color: "red",
279
+ textAlign: "center",
280
+ })
281
+ }
279
282
  >
280
283
  {JSON.stringify(state.responseData, null, 2)}
281
284
  </pre>
@@ -14,14 +14,14 @@ function Image(props) {
14
14
  width: "100%",
15
15
  top: "0px",
16
16
  left: "0px"
17
- })} loading="lazy" alt={props.altText} aria-role={props.altText ? "presentation" : undefined} style={{
17
+ })} loading="lazy" alt={props.altText} role={props.altText ? "presentation" : undefined} style={{
18
18
  "object-position": props.backgroundSize || "center",
19
19
  "object-fit": props.backgroundSize || "cover"
20
20
  }} src={props.image} srcset={props.srcset} sizes={props.sizes} />
21
21
  <source srcSet={props.srcset} />
22
22
  </picture>
23
23
  <Show when={props.aspectRatio && !(props.fitContent && props.builderBlock?.children?.length)}>
24
- <div class={css({
24
+ <div class={"builder-image-sizer " + css({
25
25
  width: "100%",
26
26
  pointerEvents: "none",
27
27
  fontSize: "0"
@@ -27,7 +27,7 @@ function Image(props) {
27
27
  }
28
28
  loading="lazy"
29
29
  alt={props.altText}
30
- aria-role={props.altText ? "presentation" : undefined}
30
+ role={props.altText ? "presentation" : undefined}
31
31
  style={{
32
32
  "object-position": props.backgroundSize || "center",
33
33
  "object-fit": props.backgroundSize || "cover",
@@ -45,11 +45,14 @@ function Image(props) {
45
45
  }
46
46
  >
47
47
  <div
48
- class={css({
49
- width: "100%",
50
- pointerEvents: "none",
51
- fontSize: "0",
52
- })}
48
+ class={
49
+ "builder-image-sizer " +
50
+ css({
51
+ width: "100%",
52
+ pointerEvents: "none",
53
+ fontSize: "0",
54
+ })
55
+ }
53
56
  style={{
54
57
  "padding-top": props.aspectRatio * 100 + "%",
55
58
  }}
@@ -1,5 +1,5 @@
1
1
  function Text(props) {
2
- return <div innerHTML={props.text}></div>;
2
+ return <div class="builder-text" innerHTML={props.text}></div>;
3
3
  }
4
4
 
5
5
  export default Text;
@@ -1,5 +1,5 @@
1
1
  function Text(props) {
2
- return <div innerHTML={props.text}></div>;
2
+ return <div class="builder-text" innerHTML={props.text}></div>;
3
3
  }
4
4
 
5
5
  export default Text;
@@ -0,0 +1,23 @@
1
+ const EMPTY_HTML_ELEMENTS = [
2
+ "area",
3
+ "base",
4
+ "br",
5
+ "col",
6
+ "embed",
7
+ "hr",
8
+ "img",
9
+ "input",
10
+ "keygen",
11
+ "link",
12
+ "meta",
13
+ "param",
14
+ "source",
15
+ "track",
16
+ "wbr"
17
+ ];
18
+ const isEmptyHtmlElement = (tagName) => {
19
+ return typeof tagName === "string" && EMPTY_HTML_ELEMENTS.includes(tagName.toLowerCase());
20
+ };
21
+ export {
22
+ isEmptyHtmlElement
23
+ };
@@ -10,6 +10,7 @@ import { getBlockStyles } from "../../functions/get-block-styles.js";
10
10
  import { getBlockTag } from "../../functions/get-block-tag.js";
11
11
  import { getProcessedBlock } from "../../functions/get-processed-block.js";
12
12
  import BlockStyles from "./block-styles";
13
+ import { isEmptyHtmlElement } from "./render-block.helpers.js";
13
14
 
14
15
  function RenderBlock(props) {
15
16
  const state = createMutable({
@@ -85,16 +86,16 @@ function RenderBlock(props) {
85
86
 
86
87
  });
87
88
  const builderContext = useContext(BuilderContext);
88
- return <>
89
- <Show fallback={<Dynamic {...state.componentOptions} attributes={state.propertiesAndActions} builderBlock={state.useBlock} style={state.css} component={state.componentRef}>
90
- <For each={state.children}>
91
- {(child, _index) => {
92
- const index = _index();
93
-
94
- return <RenderBlock block={child}></RenderBlock>;
95
- }}
96
- </For>
97
- </Dynamic>} when={!state.componentInfo?.noWrap}>
89
+ return <Show fallback={<Dynamic {...state.componentOptions} attributes={state.propertiesAndActions} builderBlock={state.useBlock} style={state.css} component={state.componentRef}>
90
+ <For each={state.children}>
91
+ {(child, _index) => {
92
+ const index = _index();
93
+
94
+ return <RenderBlock key={child.id} block={child}></RenderBlock>;
95
+ }}
96
+ </For>
97
+ </Dynamic>} when={!state.componentInfo?.noWrap}>
98
+ <Show fallback={<Dynamic {...state.propertiesAndActions} style={state.css} component={state.tagName}></Dynamic>} when={!isEmptyHtmlElement(state.tagName)}>
98
99
  <Dynamic {...state.propertiesAndActions} style={state.css} component={state.tagName}>
99
100
  <Show when={TARGET === "vue" || TARGET === "svelte"}>
100
101
  <BlockStyles block={state.useBlock}></BlockStyles>
@@ -105,7 +106,7 @@ function RenderBlock(props) {
105
106
  {(child, _index) => {
106
107
  const index = _index();
107
108
 
108
- return <RenderBlock block={child}></RenderBlock>;
109
+ return <RenderBlock key={child.id} block={child}></RenderBlock>;
109
110
  }}
110
111
  </For>
111
112
  </Dynamic>
@@ -114,12 +115,12 @@ function RenderBlock(props) {
114
115
  {(child, _index) => {
115
116
  const index = _index();
116
117
 
117
- return <RenderBlock block={child}></RenderBlock>;
118
+ return <RenderBlock key={child.id} block={child}></RenderBlock>;
118
119
  }}
119
120
  </For>
120
121
  </Dynamic>
121
122
  </Show>
122
- </>;
123
+ </Show>;
123
124
  }
124
125
 
125
126
  export default RenderBlock;
@@ -11,6 +11,7 @@ import { getBlockStyles } from "../../functions/get-block-styles.js";
11
11
  import { getBlockTag } from "../../functions/get-block-tag.js";
12
12
  import { getProcessedBlock } from "../../functions/get-processed-block.js";
13
13
  import BlockStyles from "./block-styles.lite";
14
+ import { isEmptyHtmlElement } from "./render-block.helpers.js";
14
15
 
15
16
  function RenderBlock(props) {
16
17
  const state = createMutable({
@@ -80,25 +81,34 @@ function RenderBlock(props) {
80
81
  const builderContext = useContext(BuilderContext);
81
82
 
82
83
  return (
83
- <>
84
+ <Show
85
+ fallback={
86
+ <Dynamic
87
+ {...state.componentOptions}
88
+ attributes={state.propertiesAndActions}
89
+ builderBlock={state.useBlock}
90
+ style={state.css}
91
+ component={state.componentRef}
92
+ >
93
+ <For each={state.children}>
94
+ {(child, _index) => {
95
+ const index = _index();
96
+ return <RenderBlock key={child.id} block={child}></RenderBlock>;
97
+ }}
98
+ </For>
99
+ </Dynamic>
100
+ }
101
+ when={!state.componentInfo?.noWrap}
102
+ >
84
103
  <Show
85
104
  fallback={
86
105
  <Dynamic
87
- {...state.componentOptions}
88
- attributes={state.propertiesAndActions}
89
- builderBlock={state.useBlock}
106
+ {...state.propertiesAndActions}
90
107
  style={state.css}
91
- component={state.componentRef}
92
- >
93
- <For each={state.children}>
94
- {(child, _index) => {
95
- const index = _index();
96
- return <RenderBlock block={child}></RenderBlock>;
97
- }}
98
- </For>
99
- </Dynamic>
108
+ component={state.tagName}
109
+ ></Dynamic>
100
110
  }
101
- when={!state.componentInfo?.noWrap}
111
+ when={!isEmptyHtmlElement(state.tagName)}
102
112
  >
103
113
  <Dynamic
104
114
  {...state.propertiesAndActions}
@@ -117,7 +127,9 @@ function RenderBlock(props) {
117
127
  <For each={state.children}>
118
128
  {(child, _index) => {
119
129
  const index = _index();
120
- return <RenderBlock block={child}></RenderBlock>;
130
+ return (
131
+ <RenderBlock key={child.id} block={child}></RenderBlock>
132
+ );
121
133
  }}
122
134
  </For>
123
135
  </Dynamic>
@@ -125,12 +137,12 @@ function RenderBlock(props) {
125
137
  <For each={state.noCompRefChildren}>
126
138
  {(child, _index) => {
127
139
  const index = _index();
128
- return <RenderBlock block={child}></RenderBlock>;
140
+ return <RenderBlock key={child.id} block={child}></RenderBlock>;
129
141
  }}
130
142
  </For>
131
143
  </Dynamic>
132
144
  </Show>
133
- </>
145
+ </Show>
134
146
  );
135
147
  }
136
148
 
@@ -53,7 +53,7 @@ function RenderContent(props) {
53
53
  // which is the new standard way of providing custom components, and must therefore take precedence.
54
54
  ...components, ...(props.customComponents || [])];
55
55
  const allComponents = allComponentsArray.reduce((acc, curr) => ({ ...acc,
56
- [curr.info.name]: curr
56
+ [curr.name]: curr
57
57
  }), {});
58
58
  return allComponents;
59
59
  },
@@ -143,14 +143,16 @@ function RenderContent(props) {
143
143
  },
144
144
 
145
145
  emitStateUpdate() {
146
- window.dispatchEvent(new CustomEvent("builder:component:stateChange", {
147
- detail: {
148
- state: state.contentState,
149
- ref: {
150
- name: props.model
146
+ if (isEditing()) {
147
+ window.dispatchEvent(new CustomEvent("builder:component:stateChange", {
148
+ detail: {
149
+ state: state.contentState,
150
+ ref: {
151
+ name: props.model
152
+ }
151
153
  }
152
- }
153
- }));
154
+ }));
155
+ }
154
156
  }
155
157
 
156
158
  });
@@ -62,7 +62,7 @@ function RenderContent(props) {
62
62
  ...(props.customComponents || []),
63
63
  ];
64
64
  const allComponents = allComponentsArray.reduce(
65
- (acc, curr) => ({ ...acc, [curr.info.name]: curr }),
65
+ (acc, curr) => ({ ...acc, [curr.name]: curr }),
66
66
  {} as RegisteredComponents
67
67
  );
68
68
  return allComponents;
@@ -143,19 +143,21 @@ function RenderContent(props) {
143
143
  });
144
144
  },
145
145
  emitStateUpdate() {
146
- window.dispatchEvent(
147
- new CustomEvent<BuilderComponentStateChange>(
148
- "builder:component:stateChange",
149
- {
150
- detail: {
151
- state: state.contentState,
152
- ref: {
153
- name: props.model,
146
+ if (isEditing()) {
147
+ window.dispatchEvent(
148
+ new CustomEvent<BuilderComponentStateChange>(
149
+ "builder:component:stateChange",
150
+ {
151
+ detail: {
152
+ state: state.contentState,
153
+ ref: {
154
+ name: props.model,
155
+ },
154
156
  },
155
- },
156
- }
157
- )
158
- );
157
+ }
158
+ )
159
+ );
160
+ }
159
161
  },
160
162
  });
161
163
 
@@ -1,3 +1,19 @@
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, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
+ var __spreadValues = (a, b) => {
7
+ for (var prop in b || (b = {}))
8
+ if (__hasOwnProp.call(b, prop))
9
+ __defNormalProp(a, prop, b[prop]);
10
+ if (__getOwnPropSymbols)
11
+ for (var prop of __getOwnPropSymbols(b)) {
12
+ if (__propIsEnum.call(b, prop))
13
+ __defNormalProp(a, prop, b[prop]);
14
+ }
15
+ return a;
16
+ };
1
17
  import { default as Button } from "../blocks/button/button.jsx";
2
18
  import { componentInfo as buttonComponentInfo } from "../blocks/button/component-info";
3
19
  import { default as Columns } from "../blocks/columns/columns.jsx";
@@ -15,14 +31,14 @@ import { default as Text } from "../blocks/text/text.jsx";
15
31
  import { componentInfo as videoComponentInfo } from "../blocks/video/component-info";
16
32
  import { default as Video } from "../blocks/video/video.jsx";
17
33
  const getDefaultRegisteredComponents = () => [
18
- { component: Columns, info: columnsComponentInfo },
19
- { component: Image, info: imageComponentInfo },
20
- { component: Text, info: textComponentInfo },
21
- { component: Video, info: videoComponentInfo },
22
- { component: Symbol, info: symbolComponentInfo },
23
- { component: Button, info: buttonComponentInfo },
24
- { component: Section, info: sectionComponentInfo },
25
- { component: Fragment, info: fragmentComponentInfo }
34
+ __spreadValues({ component: Columns }, columnsComponentInfo),
35
+ __spreadValues({ component: Image }, imageComponentInfo),
36
+ __spreadValues({ component: Text }, textComponentInfo),
37
+ __spreadValues({ component: Video }, videoComponentInfo),
38
+ __spreadValues({ component: Symbol }, symbolComponentInfo),
39
+ __spreadValues({ component: Button }, buttonComponentInfo),
40
+ __spreadValues({ component: Section }, sectionComponentInfo),
41
+ __spreadValues({ component: Fragment }, fragmentComponentInfo)
26
42
  ];
27
43
  export {
28
44
  getDefaultRegisteredComponents
@@ -30,10 +30,10 @@ function getBlockStyles(block) {
30
30
  var _a, _b, _c, _d, _e;
31
31
  const styles = __spreadValues({}, convertStyleObject((_a = block.responsiveStyles) == null ? void 0 : _a.large));
32
32
  if ((_b = block.responsiveStyles) == null ? void 0 : _b.medium) {
33
- styles[`@media (max-width: ${sizes.medium})`] = convertStyleObject((_c = block.responsiveStyles) == null ? void 0 : _c.medium);
33
+ styles[`@media (max-width: ${sizes.medium.max})`] = convertStyleObject((_c = block.responsiveStyles) == null ? void 0 : _c.medium);
34
34
  }
35
35
  if ((_d = block.responsiveStyles) == null ? void 0 : _d.small) {
36
- styles[`@media (max-width: ${sizes.small})`] = convertStyleObject((_e = block.responsiveStyles) == null ? void 0 : _e.small);
36
+ styles[`@media (max-width: ${sizes.small.max})`] = convertStyleObject((_e = block.responsiveStyles) == null ? void 0 : _e.small);
37
37
  }
38
38
  return styles;
39
39
  }
@@ -17,19 +17,36 @@ var __spreadValues = (a, b) => {
17
17
  return a;
18
18
  };
19
19
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ var __objRest = (source, exclude) => {
21
+ var target = {};
22
+ for (var prop in source)
23
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
24
+ target[prop] = source[prop];
25
+ if (source != null && __getOwnPropSymbols)
26
+ for (var prop of __getOwnPropSymbols(source)) {
27
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
28
+ target[prop] = source[prop];
29
+ }
30
+ return target;
31
+ };
20
32
  import { fastClone } from "./fast-clone.js";
21
33
  const components = [];
22
34
  function registerComponent(component, info) {
23
- components.push({ component, info });
35
+ components.push(__spreadValues({ component }, info));
24
36
  console.warn("registerComponent is deprecated. Use the `customComponents` prop in RenderContent instead to provide your custom components to the builder SDK.");
25
37
  return component;
26
38
  }
27
- const createRegisterComponentMessage = ({
28
- info
29
- }) => ({
30
- type: "builder.registerComponent",
31
- data: prepareComponentInfoToSend(fastClone(info))
32
- });
39
+ const createRegisterComponentMessage = (_a) => {
40
+ var _b = _a, {
41
+ component
42
+ } = _b, info = __objRest(_b, [
43
+ "component"
44
+ ]);
45
+ return {
46
+ type: "builder.registerComponent",
47
+ data: prepareComponentInfoToSend(fastClone(info))
48
+ };
49
+ };
33
50
  function prepareComponentInfoToSend(info) {
34
51
  return __spreadValues(__spreadValues({}, info), info.inputs && {
35
52
  inputs: info.inputs.map((input) => {