@builder.io/sdk-solid 0.0.8-1 → 0.0.8-12

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 (63) hide show
  1. package/README.md +5 -1
  2. package/package.json +11 -7
  3. package/src/blocks/button/button.jsx +1 -1
  4. package/src/blocks/button/button.lite.tsx +4 -1
  5. package/src/blocks/columns/columns.jsx +4 -4
  6. package/src/blocks/columns/columns.lite.tsx +31 -24
  7. package/src/blocks/custom-code/custom-code.jsx +1 -1
  8. package/src/blocks/custom-code/custom-code.lite.tsx +2 -1
  9. package/src/blocks/embed/embed.jsx +2 -2
  10. package/src/blocks/embed/embed.lite.tsx +3 -2
  11. package/src/blocks/form/form.jsx +3 -3
  12. package/src/blocks/form/form.lite.tsx +10 -7
  13. package/src/blocks/image/image.jsx +3 -3
  14. package/src/blocks/image/image.lite.tsx +10 -7
  15. package/src/blocks/symbol/component-info.js +1 -0
  16. package/src/blocks/symbol/symbol.jsx +3 -2
  17. package/src/blocks/symbol/symbol.lite.tsx +4 -2
  18. package/src/blocks/text/text.jsx +1 -1
  19. package/src/blocks/text/text.lite.tsx +1 -1
  20. package/src/components/render-block/block-styles.jsx +19 -4
  21. package/src/components/render-block/block-styles.lite.tsx +22 -4
  22. package/src/components/render-block/render-block.helpers.js +23 -0
  23. package/src/components/render-block/render-block.jsx +49 -32
  24. package/src/components/render-block/render-block.lite.tsx +75 -38
  25. package/src/components/render-block/render-component.jsx +27 -0
  26. package/src/components/render-block/render-component.lite.tsx +38 -0
  27. package/src/components/render-blocks.jsx +12 -2
  28. package/src/components/render-blocks.lite.tsx +21 -2
  29. package/src/components/render-content/components/render-styles.jsx +1 -1
  30. package/src/components/render-content/components/render-styles.lite.tsx +1 -1
  31. package/src/components/render-content/index.js +4 -0
  32. package/src/components/render-content/render-content.jsx +34 -9
  33. package/src/components/render-content/render-content.lite.tsx +47 -17
  34. package/src/components/render-inlined-styles.jsx +2 -1
  35. package/src/components/render-inlined-styles.lite.tsx +4 -1
  36. package/src/constants/builder-registered-components.js +45 -0
  37. package/src/context/builder.context.js +2 -1
  38. package/src/functions/fast-clone.js +4 -0
  39. package/src/functions/get-block-component-options.js +6 -1
  40. package/src/functions/get-block-styles.js +2 -2
  41. package/src/functions/register-component.js +30 -13
  42. package/src/index-helpers/blocks-exports.js +11 -9
  43. package/src/solid-index.jsx +5 -0
  44. package/src/types/components.js +0 -0
  45. package/src/types/element.js +0 -0
  46. package/src/blocks/button/index.js +0 -7
  47. package/src/blocks/columns/index.js +0 -7
  48. package/src/blocks/custom-code/index.js +0 -7
  49. package/src/blocks/embed/index.js +0 -7
  50. package/src/blocks/form/index.js +0 -7
  51. package/src/blocks/fragment/index.js +0 -7
  52. package/src/blocks/image/index.js +0 -7
  53. package/src/blocks/img/index.js +0 -7
  54. package/src/blocks/input/index.js +0 -7
  55. package/src/blocks/raw-text/index.js +0 -7
  56. package/src/blocks/section/index.js +0 -7
  57. package/src/blocks/select/index.js +0 -7
  58. package/src/blocks/submit-button/index.js +0 -7
  59. package/src/blocks/symbol/index.js +0 -7
  60. package/src/blocks/text/index.js +0 -7
  61. package/src/blocks/textarea/index.js +0 -7
  62. package/src/blocks/video/index.js +0 -7
  63. package/src/functions/macro-eval.js +0 -5
@@ -1,4 +1,5 @@
1
1
  import { Show } from "solid-js";
2
+ import { Dynamic } from "solid-js/web";
2
3
  import { createMutable } from "solid-js/store";
3
4
  import { TARGET } from "../constants/target.js";
4
5
 
@@ -15,7 +16,7 @@ function RenderInlinedStyles(props) {
15
16
  }
16
17
 
17
18
  });
18
- return <Show when={TARGET === "svelte"}>
19
+ return <Show fallback={<Dynamic component={state.tagName}>{props.styles}</Dynamic>} when={TARGET === "svelte"}>
19
20
  <div innerHTML={state.injectedStyleScript}></div>
20
21
  </Show>;
21
22
  }
@@ -17,7 +17,10 @@ function RenderInlinedStyles(props) {
17
17
  });
18
18
 
19
19
  return (
20
- <Show when={TARGET === "svelte"}>
20
+ <Show
21
+ fallback={<Dynamic component={state.tagName}>{props.styles}</Dynamic>}
22
+ when={TARGET === "svelte"}
23
+ >
21
24
  <div innerHTML={state.injectedStyleScript}></div>
22
25
  </Show>
23
26
  );
@@ -0,0 +1,45 @@
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
+ };
17
+ import { default as Button } from "../blocks/button/button.jsx";
18
+ import { componentInfo as buttonComponentInfo } from "../blocks/button/component-info";
19
+ import { default as Columns } from "../blocks/columns/columns.jsx";
20
+ import { componentInfo as columnsComponentInfo } from "../blocks/columns/component-info";
21
+ import { componentInfo as fragmentComponentInfo } from "../blocks/fragment/component-info";
22
+ import { default as Fragment } from "../blocks/fragment/fragment.jsx";
23
+ import { componentInfo as imageComponentInfo } from "../blocks/image/component-info";
24
+ import { default as Image } from "../blocks/image/image.jsx";
25
+ import { componentInfo as sectionComponentInfo } from "../blocks/section/component-info";
26
+ import { default as Section } from "../blocks/section/section.jsx";
27
+ import { componentInfo as symbolComponentInfo } from "../blocks/symbol/component-info";
28
+ import { default as Symbol } from "../blocks/symbol/symbol.jsx";
29
+ import { componentInfo as textComponentInfo } from "../blocks/text/component-info";
30
+ import { default as Text } from "../blocks/text/text.jsx";
31
+ import { componentInfo as videoComponentInfo } from "../blocks/video/component-info";
32
+ import { default as Video } from "../blocks/video/video.jsx";
33
+ const getDefaultRegisteredComponents = () => [
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)
42
+ ];
43
+ export {
44
+ getDefaultRegisteredComponents
45
+ };
@@ -3,7 +3,8 @@ var stdin_default = createContext({
3
3
  content: null,
4
4
  context: {},
5
5
  state: {},
6
- apiKey: null
6
+ apiKey: null,
7
+ registeredComponents: {}
7
8
  });
8
9
  export {
9
10
  stdin_default as default
@@ -0,0 +1,4 @@
1
+ const fastClone = (obj) => JSON.parse(JSON.stringify(obj));
2
+ export {
3
+ fastClone
4
+ };
@@ -1,4 +1,6 @@
1
1
  var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
2
4
  var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
4
6
  var __propIsEnum = Object.prototype.propertyIsEnumerable;
@@ -14,9 +16,12 @@ var __spreadValues = (a, b) => {
14
16
  }
15
17
  return a;
16
18
  };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
17
20
  function getBlockComponentOptions(block) {
18
21
  var _a;
19
- return __spreadValues(__spreadValues({}, (_a = block.component) == null ? void 0 : _a.options), block.options);
22
+ return __spreadProps(__spreadValues(__spreadValues({}, (_a = block.component) == null ? void 0 : _a.options), block.options), {
23
+ builderBlock: block
24
+ });
20
25
  }
21
26
  export {
22
27
  getBlockComponentOptions
@@ -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,27 +17,43 @@ var __spreadValues = (a, b) => {
17
17
  return a;
18
18
  };
19
19
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
- import { isBrowser } from "./is-browser.js";
21
- const components = {};
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
+ };
32
+ import { fastClone } from "./fast-clone.js";
33
+ const components = [];
22
34
  function registerComponent(component, info) {
23
- var _a;
24
- components[info.name] = { component, info };
25
- if (isBrowser()) {
26
- const sendInfo = prepareComponentInfoToSend(info);
27
- (_a = window.parent) == null ? void 0 : _a.postMessage({
28
- type: "builder.registerComponent",
29
- data: sendInfo
30
- }, "*");
31
- }
35
+ components.push(__spreadValues({ component }, info));
36
+ console.warn("registerComponent is deprecated. Use the `customComponents` prop in RenderContent instead to provide your custom components to the builder SDK.");
32
37
  return component;
33
38
  }
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
+ };
34
50
  function prepareComponentInfoToSend(info) {
35
51
  return __spreadValues(__spreadValues({}, info), info.inputs && {
36
52
  inputs: info.inputs.map((input) => {
37
53
  const keysToConvertFnToString = ["onChange", "showIf"];
38
54
  for (const key of keysToConvertFnToString) {
39
- if (input[key] && typeof input[key] === "function") {
40
- const fn = input[key];
55
+ const fn = input[key];
56
+ if (fn && typeof fn === "function") {
41
57
  input = __spreadProps(__spreadValues({}, input), {
42
58
  [key]: `return (${fn.toString()}).apply(this, arguments)`
43
59
  });
@@ -49,5 +65,6 @@ function prepareComponentInfoToSend(info) {
49
65
  }
50
66
  export {
51
67
  components,
68
+ createRegisterComponentMessage,
52
69
  registerComponent
53
70
  };
@@ -1,17 +1,19 @@
1
- import { default as default2 } from "../blocks/columns/index.js";
2
- import { default as default3 } from "../blocks/image/index.js";
3
- import { default as default4 } from "../blocks/text/index.js";
4
- import { default as default5 } from "../blocks/video/index.js";
5
- import { default as default6 } from "../blocks/symbol/index.js";
6
- import { default as default7 } from "../blocks/button/index.js";
7
- import { default as default8 } from "../blocks/section/index.js";
8
- import { default as default9 } from "../blocks/fragment/index.js";
9
- import { default as default10 } from "../components/render-content/render-content";
1
+ import { default as default2 } from "../blocks/columns/columns.jsx";
2
+ import { default as default3 } from "../blocks/image/image.jsx";
3
+ import { default as default4 } from "../blocks/text/text.jsx";
4
+ import { default as default5 } from "../blocks/video/video.jsx";
5
+ import { default as default6 } from "../blocks/symbol/symbol.jsx";
6
+ import { default as default7 } from "../blocks/button/button.jsx";
7
+ import { default as default8 } from "../blocks/section/section.jsx";
8
+ import { default as default9 } from "../blocks/fragment/fragment.jsx";
9
+ import { default as default10 } from "../components/render-content/render-content.jsx";
10
+ import { default as default11 } from "../components/render-blocks.jsx";
10
11
  export {
11
12
  default7 as Button,
12
13
  default2 as Columns,
13
14
  default9 as Fragment,
14
15
  default3 as Image,
16
+ default11 as RenderBlocks,
15
17
  default10 as RenderContent,
16
18
  default8 as Section,
17
19
  default6 as Symbol,
@@ -0,0 +1,5 @@
1
+ /**
2
+ * We need to have a `.jsx` entry point for our SolidJS SDK. To avoid enforcing this to all other frameworks,
3
+ * we add this file and use it to re-export the index.js file from the Mitosis-generated code.
4
+ */
5
+ export * from '../src/index.js';
File without changes
File without changes
@@ -1,7 +0,0 @@
1
- import { registerComponent } from "../../functions/register-component.js";
2
- import component from "./button";
3
- import { componentInfo } from "./component-info.js";
4
- var stdin_default = registerComponent(component, componentInfo);
5
- export {
6
- stdin_default as default
7
- };
@@ -1,7 +0,0 @@
1
- import { registerComponent } from "../../functions/register-component.js";
2
- import component from "./columns";
3
- import { componentInfo } from "./component-info.js";
4
- var stdin_default = registerComponent(component, componentInfo);
5
- export {
6
- stdin_default as default
7
- };
@@ -1,7 +0,0 @@
1
- import { registerComponent } from "../../functions/register-component.js";
2
- import { componentInfo } from "./component-info.js";
3
- import component from "./custom-code";
4
- var stdin_default = registerComponent(component, componentInfo);
5
- export {
6
- stdin_default as default
7
- };
@@ -1,7 +0,0 @@
1
- import { registerComponent } from "../../functions/register-component.js";
2
- import { componentInfo } from "./component-info.js";
3
- import component from "./embed";
4
- var stdin_default = registerComponent(component, componentInfo);
5
- export {
6
- stdin_default as default
7
- };
@@ -1,7 +0,0 @@
1
- import { registerComponent } from "../../functions/register-component.js";
2
- import { componentInfo } from "./component-info.js";
3
- import component from "./form";
4
- var stdin_default = registerComponent(component, componentInfo);
5
- export {
6
- stdin_default as default
7
- };
@@ -1,7 +0,0 @@
1
- import { registerComponent } from "../../functions/register-component.js";
2
- import { componentInfo } from "./component-info.js";
3
- import component from "./fragment";
4
- var stdin_default = registerComponent(component, componentInfo);
5
- export {
6
- stdin_default as default
7
- };
@@ -1,7 +0,0 @@
1
- import { registerComponent } from "../../functions/register-component.js";
2
- import { componentInfo } from "./component-info.js";
3
- import component from "./image";
4
- var stdin_default = registerComponent(component, componentInfo);
5
- export {
6
- stdin_default as default
7
- };
@@ -1,7 +0,0 @@
1
- import { registerComponent } from "../../functions/register-component.js";
2
- import { componentInfo } from "./component-info.js";
3
- import component from "./img";
4
- var stdin_default = registerComponent(component, componentInfo);
5
- export {
6
- stdin_default as default
7
- };
@@ -1,7 +0,0 @@
1
- import { registerComponent } from "../../functions/register-component.js";
2
- import { componentInfo } from "./component-info.js";
3
- import component from "./input";
4
- var stdin_default = registerComponent(component, componentInfo);
5
- export {
6
- stdin_default as default
7
- };
@@ -1,7 +0,0 @@
1
- import { registerComponent } from "../../functions/register-component.js";
2
- import { componentInfo } from "./component-info.js";
3
- import component from "./raw-text";
4
- var stdin_default = registerComponent(component, componentInfo);
5
- export {
6
- stdin_default as default
7
- };
@@ -1,7 +0,0 @@
1
- import { registerComponent } from "../../functions/register-component.js";
2
- import { componentInfo } from "./component-info.js";
3
- import component from "./section";
4
- var stdin_default = registerComponent(component, componentInfo);
5
- export {
6
- stdin_default as default
7
- };
@@ -1,7 +0,0 @@
1
- import { registerComponent } from "../../functions/register-component.js";
2
- import { componentInfo } from "./component-info.js";
3
- import component from "./select";
4
- var stdin_default = registerComponent(component, componentInfo);
5
- export {
6
- stdin_default as default
7
- };
@@ -1,7 +0,0 @@
1
- import { registerComponent } from "../../functions/register-component.js";
2
- import { componentInfo } from "./component-info.js";
3
- import component from "./submit-button";
4
- var stdin_default = registerComponent(component, componentInfo);
5
- export {
6
- stdin_default as default
7
- };
@@ -1,7 +0,0 @@
1
- import { registerComponent } from "../../functions/register-component.js";
2
- import { componentInfo } from "./component-info.js";
3
- import component from "./symbol";
4
- var stdin_default = registerComponent(component, componentInfo);
5
- export {
6
- stdin_default as default
7
- };
@@ -1,7 +0,0 @@
1
- import { registerComponent } from "../../functions/register-component.js";
2
- import { componentInfo } from "./component-info.js";
3
- import component from "./text";
4
- var stdin_default = registerComponent(component, componentInfo);
5
- export {
6
- stdin_default as default
7
- };
@@ -1,7 +0,0 @@
1
- import { registerComponent } from "../../functions/register-component.js";
2
- import { componentInfo } from "./component-info.js";
3
- import component from "./textarea";
4
- var stdin_default = registerComponent(component, componentInfo);
5
- export {
6
- stdin_default as default
7
- };
@@ -1,7 +0,0 @@
1
- import { registerComponent } from "../../functions/register-component.js";
2
- import { componentInfo } from "./component-info.js";
3
- import component from "./video";
4
- var stdin_default = registerComponent(component, componentInfo);
5
- export {
6
- stdin_default as default
7
- };
@@ -1,5 +0,0 @@
1
- function macroEval(items, string) {
2
- }
3
- export {
4
- macroEval
5
- };