@webstudio-is/react-sdk 0.49.0 → 0.51.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 (165) hide show
  1. package/lib/app/custom-components/image.js +11 -13
  2. package/lib/app/custom-components/shared/remix-link.js +7 -24
  3. package/lib/app/handle-request.server.js +1 -4
  4. package/lib/app/root.js +11 -29
  5. package/lib/cjs/app/custom-components/image.cjs +10 -12
  6. package/lib/cjs/app/custom-components/shared/remix-link.cjs +6 -23
  7. package/lib/cjs/app/handle-request.server.cjs +1 -4
  8. package/lib/cjs/app/root.cjs +11 -29
  9. package/lib/cjs/components/__generated__/fragment.props.cjs +24 -0
  10. package/lib/cjs/components/__generated__/link-block.props.cjs +5 -5
  11. package/lib/cjs/components/__generated__/link.props.cjs +6 -6
  12. package/lib/cjs/components/__generated__/rich-text-link.props.cjs +5 -5
  13. package/lib/cjs/components/__generated__/slot.props.cjs +24 -0
  14. package/lib/cjs/components/blockquote.ws.cjs +1 -0
  15. package/lib/cjs/components/body.cjs +1 -4
  16. package/lib/cjs/components/body.ws.cjs +1 -1
  17. package/lib/cjs/components/bold.cjs +1 -4
  18. package/lib/cjs/components/box.ws.cjs +1 -0
  19. package/lib/cjs/components/button.cjs +1 -6
  20. package/lib/cjs/components/button.ws.cjs +1 -0
  21. package/lib/cjs/components/code.ws.cjs +1 -0
  22. package/lib/cjs/components/{component-type.cjs → component-meta.cjs} +22 -4
  23. package/lib/cjs/components/components-utils.cjs +6 -0
  24. package/lib/cjs/components/components.cjs +4 -0
  25. package/lib/cjs/components/form.cjs +1 -4
  26. package/lib/cjs/components/form.ws.cjs +1 -0
  27. package/lib/cjs/components/fragment.cjs +29 -0
  28. package/lib/cjs/components/fragment.ws.cjs +32 -0
  29. package/lib/cjs/components/heading.ws.cjs +1 -0
  30. package/lib/cjs/components/image.cjs +8 -5
  31. package/lib/cjs/components/image.ws.cjs +4 -0
  32. package/lib/cjs/components/index.cjs +8 -0
  33. package/lib/cjs/components/input.cjs +1 -4
  34. package/lib/cjs/components/input.ws.cjs +1 -0
  35. package/lib/cjs/components/italic.cjs +1 -4
  36. package/lib/cjs/components/link-block.cjs +1 -4
  37. package/lib/cjs/components/link-block.ws.cjs +7 -2
  38. package/lib/cjs/components/link.cjs +10 -7
  39. package/lib/cjs/components/link.ws.cjs +9 -1
  40. package/lib/cjs/components/list-item.ws.cjs +1 -0
  41. package/lib/cjs/components/list.ws.cjs +1 -0
  42. package/lib/cjs/components/paragraph.cjs +1 -4
  43. package/lib/cjs/components/paragraph.ws.cjs +1 -0
  44. package/lib/cjs/components/rich-text-link.cjs +1 -4
  45. package/lib/cjs/components/rich-text-link.ws.cjs +7 -3
  46. package/lib/cjs/components/separator.ws.cjs +1 -0
  47. package/lib/cjs/components/slot.cjs +36 -0
  48. package/lib/cjs/components/slot.ws.cjs +34 -0
  49. package/lib/cjs/components/span.cjs +1 -4
  50. package/lib/cjs/components/subscript.cjs +1 -4
  51. package/lib/cjs/components/superscript.cjs +1 -4
  52. package/lib/cjs/components/text-block.cjs +1 -4
  53. package/lib/cjs/components/text-block.ws.cjs +1 -0
  54. package/lib/cjs/context.cjs +2 -1
  55. package/lib/cjs/css/categories.cjs +6 -0
  56. package/lib/cjs/index.cjs +2 -0
  57. package/lib/cjs/props.cjs +43 -2
  58. package/lib/cjs/pubsub/create.cjs +13 -0
  59. package/lib/cjs/tree/create-elements-tree.cjs +33 -22
  60. package/lib/cjs/tree/root.cjs +1 -0
  61. package/lib/cjs/tree/session-storage-polyfill.cjs +7 -4
  62. package/lib/cjs/tree/webstudio-component.cjs +5 -10
  63. package/lib/components/__generated__/fragment.props.js +4 -0
  64. package/lib/components/__generated__/link-block.props.js +5 -5
  65. package/lib/components/__generated__/link.props.js +6 -6
  66. package/lib/components/__generated__/rich-text-link.props.js +5 -5
  67. package/lib/components/__generated__/slot.props.js +4 -0
  68. package/lib/components/blockquote.ws.js +1 -0
  69. package/lib/components/body.js +1 -4
  70. package/lib/components/body.ws.js +1 -1
  71. package/lib/components/bold.js +1 -4
  72. package/lib/components/box.ws.js +1 -0
  73. package/lib/components/button.js +1 -6
  74. package/lib/components/button.ws.js +1 -0
  75. package/lib/components/code.ws.js +1 -0
  76. package/lib/components/component-meta.js +34 -0
  77. package/lib/components/components-utils.js +2 -0
  78. package/lib/components/components.js +4 -0
  79. package/lib/components/form.js +1 -4
  80. package/lib/components/form.ws.js +1 -0
  81. package/lib/components/fragment.js +9 -0
  82. package/lib/components/fragment.ws.js +12 -0
  83. package/lib/components/heading.ws.js +1 -0
  84. package/lib/components/image.js +8 -5
  85. package/lib/components/image.ws.js +4 -0
  86. package/lib/components/index.js +8 -0
  87. package/lib/components/input.js +1 -4
  88. package/lib/components/input.ws.js +1 -0
  89. package/lib/components/italic.js +1 -4
  90. package/lib/components/link-block.js +1 -4
  91. package/lib/components/link-block.ws.js +7 -2
  92. package/lib/components/link.js +10 -7
  93. package/lib/components/link.ws.js +9 -1
  94. package/lib/components/list-item.ws.js +1 -0
  95. package/lib/components/list.ws.js +1 -0
  96. package/lib/components/paragraph.js +1 -4
  97. package/lib/components/paragraph.ws.js +1 -0
  98. package/lib/components/rich-text-link.js +1 -4
  99. package/lib/components/rich-text-link.ws.js +8 -4
  100. package/lib/components/separator.ws.js +1 -0
  101. package/lib/components/slot.js +16 -0
  102. package/lib/components/slot.ws.js +14 -0
  103. package/lib/components/span.js +1 -4
  104. package/lib/components/subscript.js +1 -4
  105. package/lib/components/superscript.js +1 -4
  106. package/lib/components/text-block.js +1 -4
  107. package/lib/components/text-block.ws.js +1 -0
  108. package/lib/context.js +2 -1
  109. package/lib/css/categories.js +6 -0
  110. package/lib/index.js +4 -0
  111. package/lib/props.js +43 -2
  112. package/lib/pubsub/create.js +9 -0
  113. package/lib/tree/create-elements-tree.js +33 -22
  114. package/lib/tree/root.js +1 -0
  115. package/lib/tree/session-storage-polyfill.js +7 -4
  116. package/lib/tree/webstudio-component.js +5 -10
  117. package/package.json +12 -16
  118. package/src/app/custom-components/image.tsx +4 -7
  119. package/src/app/custom-components/index.ts +1 -1
  120. package/src/app/custom-components/shared/remix-link.tsx +12 -48
  121. package/src/components/__generated__/fragment.props.ts +3 -0
  122. package/src/components/__generated__/link-block.props.ts +5 -5
  123. package/src/components/__generated__/link.props.ts +6 -6
  124. package/src/components/__generated__/rich-text-link.props.ts +5 -5
  125. package/src/components/__generated__/slot.props.ts +3 -0
  126. package/src/components/blockquote.ws.tsx +2 -1
  127. package/src/components/body.ws.tsx +2 -2
  128. package/src/components/bold.ws.tsx +1 -1
  129. package/src/components/box.ws.ts +2 -1
  130. package/src/components/button.ws.tsx +2 -1
  131. package/src/components/code.ws.tsx +2 -1
  132. package/src/components/{component-type.ts → component-meta.ts} +21 -23
  133. package/src/components/components-utils.ts +4 -0
  134. package/src/components/components.ts +2 -0
  135. package/src/components/form.ws.tsx +2 -1
  136. package/src/components/fragment.tsx +11 -0
  137. package/src/components/fragment.ws.ts +11 -0
  138. package/src/components/heading.ws.tsx +2 -1
  139. package/src/components/image.ws.tsx +2 -1
  140. package/src/components/index.ts +11 -1
  141. package/src/components/input.ws.tsx +2 -1
  142. package/src/components/italic.ws.tsx +1 -1
  143. package/src/components/link-block.ws.tsx +8 -3
  144. package/src/components/link.tsx +12 -6
  145. package/src/components/link.ws.tsx +10 -2
  146. package/src/components/list-item.ws.tsx +2 -1
  147. package/src/components/list.ws.tsx +2 -1
  148. package/src/components/paragraph.ws.tsx +2 -1
  149. package/src/components/rich-text-link.ws.tsx +10 -5
  150. package/src/components/separator.ws.tsx +2 -1
  151. package/src/components/slot.stories.tsx +16 -0
  152. package/src/components/slot.tsx +17 -0
  153. package/src/components/slot.ws.ts +13 -0
  154. package/src/components/span.ws.tsx +1 -1
  155. package/src/components/subscript.ws.tsx +1 -1
  156. package/src/components/superscript.ws.tsx +1 -1
  157. package/src/components/text-block.ws.tsx +2 -1
  158. package/src/context.tsx +3 -1
  159. package/src/index.ts +5 -4
  160. package/src/props.test.ts +95 -0
  161. package/src/props.ts +59 -3
  162. package/src/tree/create-elements-tree.tsx +30 -12
  163. package/src/tree/root.ts +2 -0
  164. package/src/tree/webstudio-component.tsx +1 -0
  165. package/lib/components/component-type.js +0 -20
@@ -31,35 +31,41 @@ const createElementsTree = ({
31
31
  instance,
32
32
  propsByInstanceIdStore,
33
33
  assetsStore,
34
+ pagesStore,
34
35
  Component,
35
36
  getComponent
36
37
  }) => {
38
+ const rootInstanceSelector = [instance.id];
37
39
  const children = createInstanceChildrenElements({
40
+ instanceSelector: rootInstanceSelector,
38
41
  Component,
39
42
  children: instance.children,
40
43
  getComponent
41
44
  });
42
- const body = createInstanceElement({
45
+ const root = createInstanceElement({
43
46
  Component,
44
47
  instance,
48
+ instanceSelector: rootInstanceSelector,
45
49
  children: [
46
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react.Fragment, {
47
- children: [
48
- children,
49
- sandbox && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_session_storage_polyfill.SessionStoragePolyfill, {}),
50
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react2.ScrollRestoration, {}),
51
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react2.Scripts, {})
52
- ]
53
- }, "children")
50
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react.Fragment, { children: [
51
+ children,
52
+ sandbox && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_session_storage_polyfill.SessionStoragePolyfill, {}),
53
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react2.ScrollRestoration, {}),
54
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react2.Scripts, {})
55
+ ] }, "children")
54
56
  ],
55
57
  getComponent
56
58
  });
57
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_context.ReactSdkContext.Provider, {
58
- value: { propsByInstanceIdStore, assetsStore },
59
- children: body
60
- });
59
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
60
+ import_context.ReactSdkContext.Provider,
61
+ {
62
+ value: { propsByInstanceIdStore, assetsStore, pagesStore },
63
+ children: root
64
+ }
65
+ );
61
66
  };
62
67
  const createInstanceChildrenElements = ({
68
+ instanceSelector,
63
69
  children,
64
70
  Component,
65
71
  getComponent
@@ -70,13 +76,16 @@ const createInstanceChildrenElements = ({
70
76
  elements.push(child.value);
71
77
  continue;
72
78
  }
79
+ const childInstanceSelector = [child.id, ...instanceSelector];
73
80
  const children2 = createInstanceChildrenElements({
81
+ instanceSelector: childInstanceSelector,
74
82
  children: child.children,
75
83
  Component,
76
84
  getComponent
77
85
  });
78
86
  const element = createInstanceElement({
79
87
  instance: child,
88
+ instanceSelector: childInstanceSelector,
80
89
  Component,
81
90
  children: children2,
82
91
  getComponent
@@ -88,16 +97,18 @@ const createInstanceChildrenElements = ({
88
97
  const createInstanceElement = ({
89
98
  Component,
90
99
  instance,
100
+ instanceSelector,
91
101
  children = [],
92
102
  getComponent
93
103
  }) => {
94
- const props = {
95
- instance,
96
- children,
97
- key: instance.id,
98
- getComponent
99
- };
100
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, {
101
- ...props
102
- });
104
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
105
+ Component,
106
+ {
107
+ instance,
108
+ instanceSelector,
109
+ getComponent,
110
+ children
111
+ },
112
+ instance.id
113
+ );
103
114
  };
@@ -75,6 +75,7 @@ const InstanceRoot = ({
75
75
  (0, import_props.getPropsByInstanceId)(new Map(data.build.props))
76
76
  ),
77
77
  assetsStore: (0, import_nanostores.atom)(new Map(data.assets.map((asset) => [asset.id, asset]))),
78
+ pagesStore: (0, import_nanostores.atom)(new Map(data.pages.map((page) => [page.id, page]))),
78
79
  Component: Component ?? import_webstudio_component.WebstudioComponent,
79
80
  getComponent
80
81
  });
@@ -56,7 +56,10 @@ const polyfill = function() {
56
56
  });
57
57
  }
58
58
  }.toString();
59
- const SessionStoragePolyfill = () => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("script", {
60
- dangerouslySetInnerHTML: { __html: `(${polyfill})()` },
61
- suppressHydrationWarning: true
62
- });
59
+ const SessionStoragePolyfill = () => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
60
+ "script",
61
+ {
62
+ dangerouslySetInnerHTML: { __html: `(${polyfill})()` },
63
+ suppressHydrationWarning: true
64
+ }
65
+ );
@@ -30,12 +30,10 @@ var import_react = require("react");
30
30
  var import_props = require("../props");
31
31
  const renderText = (text) => {
32
32
  const lines = text.split("\n");
33
- return lines.map((line, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react.Fragment, {
34
- children: [
35
- line,
36
- index < lines.length - 1 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("br", {}) : null
37
- ]
38
- }, index));
33
+ return lines.map((line, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react.Fragment, { children: [
34
+ line,
35
+ index < lines.length - 1 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("br", {}) : null
36
+ ] }, index));
39
37
  };
40
38
  const renderWebstudioComponentChildren = (children) => {
41
39
  if (children === void 0 || children.length === 0) {
@@ -62,10 +60,7 @@ const WebstudioComponent = ({
62
60
  if (Component === void 0) {
63
61
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {});
64
62
  }
65
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, {
66
- ...props,
67
- children: renderWebstudioComponentChildren(children)
68
- });
63
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, { ...props, children: renderWebstudioComponentChildren(children) });
69
64
  };
70
65
  const idAttribute = "data-ws-id";
71
66
  const componentAttribute = "data-ws-component";
@@ -0,0 +1,4 @@
1
+ const props = {};
2
+ export {
3
+ props
4
+ };
@@ -2,18 +2,18 @@ const props = {
2
2
  slot: { required: false, control: "text", type: "string" },
3
3
  style: { required: false, control: "text", type: "string" },
4
4
  title: { required: false, control: "text", type: "string" },
5
- download: { required: false, control: "text", type: "string" },
6
5
  href: { required: false, control: "text", type: "string" },
7
- hrefLang: { required: false, control: "text", type: "string" },
8
- media: { required: false, control: "text", type: "string" },
9
- ping: { required: false, control: "text", type: "string" },
10
- rel: { required: false, control: "text", type: "string" },
11
6
  target: {
12
7
  required: false,
13
8
  control: "select",
14
9
  type: "string",
15
10
  options: ["_self", "_blank", "_parent", "_top"]
16
11
  },
12
+ download: { required: false, control: "text", type: "string" },
13
+ hrefLang: { required: false, control: "text", type: "string" },
14
+ media: { required: false, control: "text", type: "string" },
15
+ ping: { required: false, control: "text", type: "string" },
16
+ rel: { required: false, control: "text", type: "string" },
17
17
  type: { required: false, control: "text", type: "string" },
18
18
  referrerPolicy: {
19
19
  required: false,
@@ -2,18 +2,18 @@ const props = {
2
2
  slot: { required: false, control: "text", type: "string" },
3
3
  style: { required: false, control: "text", type: "string" },
4
4
  title: { required: false, control: "text", type: "string" },
5
- download: { required: false, control: "text", type: "string" },
6
- href: { required: false, control: "text", type: "string", defaultValue: "" },
7
- hrefLang: { required: false, control: "text", type: "string" },
8
- media: { required: false, control: "text", type: "string" },
9
- ping: { required: false, control: "text", type: "string" },
10
- rel: { required: false, control: "text", type: "string" },
5
+ href: { required: false, control: "text", type: "string" },
11
6
  target: {
12
7
  required: false,
13
8
  control: "select",
14
9
  type: "string",
15
10
  options: ["_self", "_blank", "_parent", "_top"]
16
11
  },
12
+ download: { required: false, control: "text", type: "string" },
13
+ hrefLang: { required: false, control: "text", type: "string" },
14
+ media: { required: false, control: "text", type: "string" },
15
+ ping: { required: false, control: "text", type: "string" },
16
+ rel: { required: false, control: "text", type: "string" },
17
17
  type: { required: false, control: "text", type: "string" },
18
18
  referrerPolicy: {
19
19
  required: false,
@@ -2,18 +2,18 @@ const props = {
2
2
  slot: { required: false, control: "text", type: "string" },
3
3
  style: { required: false, control: "text", type: "string" },
4
4
  title: { required: false, control: "text", type: "string" },
5
- download: { required: false, control: "text", type: "string" },
6
5
  href: { required: false, control: "text", type: "string" },
7
- hrefLang: { required: false, control: "text", type: "string" },
8
- media: { required: false, control: "text", type: "string" },
9
- ping: { required: false, control: "text", type: "string" },
10
- rel: { required: false, control: "text", type: "string" },
11
6
  target: {
12
7
  required: false,
13
8
  control: "select",
14
9
  type: "string",
15
10
  options: ["_self", "_blank", "_parent", "_top"]
16
11
  },
12
+ download: { required: false, control: "text", type: "string" },
13
+ hrefLang: { required: false, control: "text", type: "string" },
14
+ media: { required: false, control: "text", type: "string" },
15
+ ping: { required: false, control: "text", type: "string" },
16
+ rel: { required: false, control: "text", type: "string" },
17
17
  type: { required: false, control: "text", type: "string" },
18
18
  referrerPolicy: {
19
19
  required: false,
@@ -0,0 +1,4 @@
1
+ const props = {};
2
+ export {
3
+ props
4
+ };
@@ -39,6 +39,7 @@ const presetStyle = {
39
39
  }
40
40
  };
41
41
  const meta = {
42
+ category: "typography",
42
43
  type: "rich-text",
43
44
  label: "Blockquote",
44
45
  Icon: BlockquoteIcon,
@@ -1,10 +1,7 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { forwardRef } from "react";
3
3
  const defaultTag = "body";
4
- const Body = forwardRef((props, ref) => /* @__PURE__ */ jsx("body", {
5
- ...props,
6
- ref
7
- }));
4
+ const Body = forwardRef((props, ref) => /* @__PURE__ */ jsx("body", { ...props, ref }));
8
5
  Body.displayName = "Body";
9
6
  export {
10
7
  Body
@@ -50,7 +50,7 @@ const presetStyle = {
50
50
  }
51
51
  };
52
52
  const meta = {
53
- type: "body",
53
+ type: "container",
54
54
  label: "Body",
55
55
  Icon: BodyIcon,
56
56
  presetStyle
@@ -1,10 +1,7 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { forwardRef } from "react";
3
3
  const defaultTag = "b";
4
- const Bold = forwardRef((props, ref) => /* @__PURE__ */ jsx("b", {
5
- ...props,
6
- ref
7
- }));
4
+ const Bold = forwardRef((props, ref) => /* @__PURE__ */ jsx("b", { ...props, ref }));
8
5
  Bold.displayName = "Bold";
9
6
  export {
10
7
  Bold
@@ -7,6 +7,7 @@ const presetStyle = {
7
7
  }
8
8
  };
9
9
  const meta = {
10
+ category: "general",
10
11
  type: "container",
11
12
  label: "Box",
12
13
  Icon: BoxIcon,
@@ -7,12 +7,7 @@ const Button = forwardRef(
7
7
  innerText = "Edit Inner Text in Properties",
8
8
  children,
9
9
  ...props
10
- }, ref) => /* @__PURE__ */ jsx("button", {
11
- type,
12
- ...props,
13
- ref,
14
- children: children ? children : innerText
15
- })
10
+ }, ref) => /* @__PURE__ */ jsx("button", { type, ...props, ref, children: children ? children : innerText })
16
11
  );
17
12
  Button.displayName = "Button";
18
13
  export {
@@ -1,6 +1,7 @@
1
1
  import { ButtonIcon } from "@webstudio-is/icons";
2
2
  import { props } from "./__generated__/button.props";
3
3
  const meta = {
4
+ category: "forms",
4
5
  type: "container",
5
6
  label: "Button",
6
7
  Icon: ButtonIcon
@@ -30,6 +30,7 @@ const presetStyle = {
30
30
  }
31
31
  };
32
32
  const meta = {
33
+ category: "general",
33
34
  type: "rich-text",
34
35
  label: "Code",
35
36
  Icon: CodeIcon,
@@ -0,0 +1,34 @@
1
+ import { z } from "zod";
2
+ import { PropMeta } from "@webstudio-is/generate-arg-types";
3
+ const WsComponentPropsMeta = z.object({
4
+ props: z.record(PropMeta),
5
+ initialProps: z.array(z.string()).optional()
6
+ });
7
+ const componentCategories = [
8
+ "general",
9
+ "typography",
10
+ "media",
11
+ "forms"
12
+ ];
13
+ const WsComponentMeta = z.object({
14
+ category: z.enum(componentCategories).optional(),
15
+ // container - can accept other components with dnd
16
+ // control - usually form controls like inputs, without children
17
+ // embed - images, videos or other embeddable components, without children
18
+ // rich-text - editable text component
19
+ // rich-text-child - formatted text fragment, not listed in components list
20
+ type: z.enum([
21
+ "container",
22
+ "control",
23
+ "embed",
24
+ "rich-text",
25
+ "rich-text-child"
26
+ ]),
27
+ label: z.string(),
28
+ Icon: z.function(),
29
+ presetStyle: z.optional(z.any()),
30
+ children: z.optional(z.array(z.string()))
31
+ });
32
+ export {
33
+ componentCategories
34
+ };
@@ -1,6 +1,8 @@
1
1
  import * as components from "./components";
2
2
  import { registeredComponents } from "./index";
3
3
  const componentNames = Object.keys({
4
+ Slot: 1,
5
+ Fragment: 1,
4
6
  Box: 1,
5
7
  Body: 1,
6
8
  TextBlock: 1,
@@ -1,3 +1,5 @@
1
+ import { Slot } from "./slot";
2
+ import { Fragment } from "./fragment";
1
3
  import { Body } from "./body";
2
4
  import { Box } from "./box";
3
5
  import { TextBlock } from "./text-block";
@@ -28,6 +30,7 @@ export {
28
30
  Button,
29
31
  Code,
30
32
  Form,
33
+ Fragment,
31
34
  Heading,
32
35
  Image,
33
36
  Input,
@@ -39,6 +42,7 @@ export {
39
42
  Paragraph,
40
43
  RichTextLink,
41
44
  Separator,
45
+ Slot,
42
46
  Span,
43
47
  Subscript,
44
48
  Superscript,
@@ -1,10 +1,7 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { forwardRef } from "react";
3
3
  const defaultTag = "form";
4
- const Form = forwardRef((props, ref) => /* @__PURE__ */ jsx("form", {
5
- ...props,
6
- ref
7
- }));
4
+ const Form = forwardRef((props, ref) => /* @__PURE__ */ jsx("form", { ...props, ref }));
8
5
  Form.displayName = "Form";
9
6
  export {
10
7
  Form
@@ -12,6 +12,7 @@ const presetStyle = {
12
12
  }
13
13
  };
14
14
  const meta = {
15
+ category: "forms",
15
16
  type: "container",
16
17
  label: "Form",
17
18
  Icon: FormIcon,
@@ -0,0 +1,9 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { forwardRef } from "react";
3
+ const Fragment = forwardRef((props, ref) => {
4
+ return /* @__PURE__ */ jsx("div", { ...props, ref, style: { display: "contents" } });
5
+ });
6
+ Fragment.displayName = "Fragment";
7
+ export {
8
+ Fragment
9
+ };
@@ -0,0 +1,12 @@
1
+ const meta = {
2
+ type: "container",
3
+ label: "Fragment",
4
+ Icon: () => null
5
+ };
6
+ const propsMeta = {
7
+ props: {}
8
+ };
9
+ export {
10
+ meta,
11
+ propsMeta
12
+ };
@@ -1,6 +1,7 @@
1
1
  import { HeadingIcon } from "@webstudio-is/icons";
2
2
  import { props } from "./__generated__/heading.props";
3
3
  const meta = {
4
+ category: "typography",
4
5
  type: "rich-text",
5
6
  label: "Heading",
6
7
  Icon: HeadingIcon,
@@ -3,11 +3,14 @@ import { forwardRef } from "react";
3
3
  const defaultTag = "img";
4
4
  const Image = forwardRef(
5
5
  (imageProps, ref) => {
6
- return /* @__PURE__ */ jsx("img", {
7
- ...imageProps,
8
- src: imageProps.src || imagePlaceholderSvg,
9
- ref
10
- });
6
+ return /* @__PURE__ */ jsx(
7
+ "img",
8
+ {
9
+ ...imageProps,
10
+ src: imageProps.src || imagePlaceholderSvg,
11
+ ref
12
+ }
13
+ );
11
14
  }
12
15
  );
13
16
  Image.defaultProps = {
@@ -1,17 +1,21 @@
1
1
  import { ImageIcon } from "@webstudio-is/icons";
2
2
  import { props } from "./__generated__/image.props";
3
3
  const presetStyle = {
4
+ // Otherwise on new image insert onto canvas it can overfit screen size multiple times
4
5
  maxWidth: {
5
6
  type: "unit",
6
7
  unit: "%",
7
8
  value: 100
8
9
  },
10
+ // inline | inline-block is not suitable because without line-height: 0 on the parent you get unsuitable spaces/margins
11
+ // see https://stackoverflow.com/questions/24771194/is-the-margin-of-inline-block-4px-is-static-for-all-browsers
9
12
  display: {
10
13
  type: "keyword",
11
14
  value: "block"
12
15
  }
13
16
  };
14
17
  const meta = {
18
+ category: "media",
15
19
  type: "embed",
16
20
  label: "Image",
17
21
  Icon: ImageIcon,
@@ -1,4 +1,6 @@
1
1
  import { PropMeta } from "@webstudio-is/generate-arg-types";
2
+ import { meta as SlotMeta } from "./slot.ws";
3
+ import { meta as FragmentMeta } from "./fragment.ws";
2
4
  import { meta as BodyMeta } from "./body.ws";
3
5
  import { meta as BoxMeta } from "./box.ws";
4
6
  import { meta as TextBlockMeta } from "./text-block.ws";
@@ -21,6 +23,8 @@ import { meta as ListMeta } from "./list.ws";
21
23
  import { meta as ListItemMeta } from "./list-item.ws";
22
24
  import { meta as SeparatorMeta } from "./separator.ws";
23
25
  import { meta as CodeMeta } from "./code.ws";
26
+ import { propsMeta as SlotMetaPropsMeta } from "./slot.ws";
27
+ import { propsMeta as FragmentMetaPropsMeta } from "./fragment.ws";
24
28
  import { propsMeta as BodyMetaPropsMeta } from "./body.ws";
25
29
  import { propsMeta as BoxMetaPropsMeta } from "./box.ws";
26
30
  import { propsMeta as TextBlockMetaPropsMeta } from "./text-block.ws";
@@ -44,6 +48,8 @@ import { propsMeta as ListItemPropsMeta } from "./list-item.ws";
44
48
  import { propsMeta as SeparatorPropsMeta } from "./separator.ws";
45
49
  import { propsMeta as CodePropsMeta } from "./code.ws";
46
50
  const defaultMetas = {
51
+ Slot: SlotMeta,
52
+ Fragment: FragmentMeta,
47
53
  Box: BoxMeta,
48
54
  Body: BodyMeta,
49
55
  TextBlock: TextBlockMeta,
@@ -79,6 +85,8 @@ const registerComponentMetas = (overrides) => {
79
85
  currentMetas = result;
80
86
  };
81
87
  const defaultPropsMetasRaw = {
88
+ Slot: SlotMetaPropsMeta,
89
+ Fragment: FragmentMetaPropsMeta,
82
90
  Box: BoxMetaPropsMeta,
83
91
  Body: BodyMetaPropsMeta,
84
92
  TextBlock: TextBlockMetaPropsMeta,
@@ -1,10 +1,7 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { forwardRef } from "react";
3
3
  const defaultTag = "input";
4
- const Input = forwardRef(({ children: _children, ...props }, ref) => /* @__PURE__ */ jsx("input", {
5
- ...props,
6
- ref
7
- }));
4
+ const Input = forwardRef(({ children: _children, ...props }, ref) => /* @__PURE__ */ jsx("input", { ...props, ref }));
8
5
  Input.displayName = "Input";
9
6
  export {
10
7
  Input
@@ -1,6 +1,7 @@
1
1
  import { InputIcon } from "@webstudio-is/icons";
2
2
  import { props } from "./__generated__/input.props";
3
3
  const meta = {
4
+ category: "forms",
4
5
  type: "control",
5
6
  label: "Input",
6
7
  Icon: InputIcon
@@ -1,10 +1,7 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { forwardRef } from "react";
3
3
  const defaultTag = "i";
4
- const Italic = forwardRef((props, ref) => /* @__PURE__ */ jsx("i", {
5
- ...props,
6
- ref
7
- }));
4
+ const Italic = forwardRef((props, ref) => /* @__PURE__ */ jsx("i", { ...props, ref }));
8
5
  Italic.displayName = "Italic";
9
6
  export {
10
7
  Italic
@@ -1,10 +1,7 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { forwardRef } from "react";
3
3
  import { Link } from "./link";
4
- const LinkBlock = forwardRef((props, ref) => /* @__PURE__ */ jsx(Link, {
5
- ...props,
6
- ref
7
- }));
4
+ const LinkBlock = forwardRef((props, ref) => /* @__PURE__ */ jsx(Link, { ...props, ref }));
8
5
  LinkBlock.displayName = "LinkBlock";
9
6
  export {
10
7
  LinkBlock
@@ -1,5 +1,6 @@
1
1
  import { BoxLinkIcon } from "@webstudio-is/icons";
2
2
  import { props } from "./__generated__/link-block.props";
3
+ import { propsMeta as linkPropsMeta } from "./link.ws";
3
4
  const presetStyle = {
4
5
  boxSizing: {
5
6
  type: "keyword",
@@ -11,14 +12,18 @@ const presetStyle = {
11
12
  }
12
13
  };
13
14
  const meta = {
15
+ category: "general",
14
16
  type: "container",
15
17
  label: "Link Block",
16
18
  Icon: BoxLinkIcon,
17
19
  presetStyle
18
20
  };
19
21
  const propsMeta = {
20
- props,
21
- initialProps: ["href", "target", "prefetch"]
22
+ props: {
23
+ ...props,
24
+ href: linkPropsMeta.props.href
25
+ },
26
+ initialProps: linkPropsMeta.initialProps
22
27
  };
23
28
  export {
24
29
  meta,
@@ -1,14 +1,17 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { forwardRef } from "react";
3
- const Link = forwardRef(
4
- ({ href = "", ...props }, ref) => {
5
- return /* @__PURE__ */ jsx("a", {
3
+ import { usePropUrl, getInstanceIdFromComponentProps } from "../props";
4
+ const Link = forwardRef((props, ref) => {
5
+ const href = usePropUrl(getInstanceIdFromComponentProps(props), "href");
6
+ return /* @__PURE__ */ jsx(
7
+ "a",
8
+ {
6
9
  ...props,
7
- href,
10
+ href: typeof href === "string" ? href : href?.path,
8
11
  ref
9
- });
10
- }
11
- );
12
+ }
13
+ );
14
+ });
12
15
  Link.displayName = "Link";
13
16
  export {
14
17
  Link
@@ -12,6 +12,7 @@ const presetStyle = {
12
12
  }
13
13
  };
14
14
  const meta = {
15
+ category: "general",
15
16
  type: "rich-text",
16
17
  label: "Link Text",
17
18
  Icon: Link2Icon,
@@ -19,7 +20,14 @@ const meta = {
19
20
  children: ["Link text you can edit"]
20
21
  };
21
22
  const propsMeta = {
22
- props,
23
+ props: {
24
+ ...props,
25
+ href: {
26
+ type: "string",
27
+ control: "url",
28
+ required: false
29
+ }
30
+ },
23
31
  initialProps: ["href", "target", "prefetch"]
24
32
  };
25
33
  export {