@webstudio-is/react-sdk 0.65.0 → 0.66.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 (155) hide show
  1. package/lib/app/custom-components/form.ws.js +2 -2
  2. package/lib/app/custom-components/image.js +7 -13
  3. package/lib/app/params.js +1 -0
  4. package/lib/cjs/app/custom-components/form.ws.js +2 -2
  5. package/lib/cjs/app/custom-components/image.js +3 -12
  6. package/lib/cjs/app/params.js +1 -0
  7. package/lib/cjs/components/__generated__/html.props.js +31 -0
  8. package/lib/cjs/components/blockquote.ws.js +2 -2
  9. package/lib/cjs/components/body.ws.js +2 -2
  10. package/lib/cjs/components/bold.ws.js +2 -2
  11. package/lib/cjs/components/box.ws.js +2 -2
  12. package/lib/cjs/components/button.ws.js +2 -2
  13. package/lib/cjs/components/checkbox-field.ws.js +2 -2
  14. package/lib/cjs/components/checkbox.ws.js +2 -2
  15. package/lib/cjs/components/code.ws.js +2 -2
  16. package/lib/cjs/components/component-meta.js +2 -2
  17. package/lib/cjs/components/components-utils.js +1 -43
  18. package/lib/cjs/components/components.js +2 -0
  19. package/lib/cjs/components/error-message.ws.js +2 -2
  20. package/lib/cjs/components/form.ws.js +2 -2
  21. package/lib/cjs/components/fragment.ws.js +1 -1
  22. package/lib/cjs/components/heading.ws.js +2 -2
  23. package/lib/cjs/components/html.js +80 -0
  24. package/lib/cjs/components/html.ws.js +43 -0
  25. package/lib/cjs/components/image.ws.js +2 -2
  26. package/lib/cjs/components/index.js +7 -53
  27. package/lib/cjs/components/input.ws.js +2 -2
  28. package/lib/cjs/components/italic.ws.js +2 -2
  29. package/lib/cjs/components/label.ws.js +2 -2
  30. package/lib/cjs/components/link-block.ws.js +2 -2
  31. package/lib/cjs/components/link.ws.js +2 -2
  32. package/lib/cjs/components/list-item.ws.js +2 -2
  33. package/lib/cjs/components/list.ws.js +2 -2
  34. package/lib/cjs/components/paragraph.ws.js +2 -2
  35. package/lib/cjs/components/radio-button-field.ws.js +2 -2
  36. package/lib/cjs/components/radio-button.ws.js +2 -2
  37. package/lib/cjs/components/separator.ws.js +2 -2
  38. package/lib/cjs/components/slot.ws.js +2 -2
  39. package/lib/cjs/components/span.ws.js +2 -2
  40. package/lib/cjs/components/subscript.ws.js +2 -2
  41. package/lib/cjs/components/success-message.ws.js +2 -2
  42. package/lib/cjs/components/superscript.ws.js +2 -2
  43. package/lib/cjs/components/text-block.ws.js +2 -2
  44. package/lib/cjs/components/textarea.ws.js +2 -2
  45. package/lib/cjs/css/css.js +2 -5
  46. package/lib/cjs/css/normalize.js +1 -1
  47. package/lib/cjs/css/presets.js +8 -1
  48. package/lib/cjs/tree/create-elements-tree.js +2 -4
  49. package/lib/components/__generated__/html.props.js +11 -0
  50. package/lib/components/blockquote.ws.js +2 -2
  51. package/lib/components/body.ws.js +2 -2
  52. package/lib/components/bold.ws.js +2 -2
  53. package/lib/components/box.ws.js +2 -2
  54. package/lib/components/button.ws.js +2 -2
  55. package/lib/components/checkbox-field.ws.js +2 -2
  56. package/lib/components/checkbox.ws.js +2 -2
  57. package/lib/components/code.ws.js +2 -2
  58. package/lib/components/component-meta.js +3 -3
  59. package/lib/components/components-utils.js +1 -43
  60. package/lib/components/components.js +2 -0
  61. package/lib/components/error-message.ws.js +2 -2
  62. package/lib/components/form.ws.js +2 -2
  63. package/lib/components/fragment.ws.js +1 -1
  64. package/lib/components/heading.ws.js +2 -2
  65. package/lib/components/html.js +65 -0
  66. package/lib/components/html.ws.js +23 -0
  67. package/lib/components/image.ws.js +2 -2
  68. package/lib/components/index.js +7 -53
  69. package/lib/components/input.ws.js +2 -2
  70. package/lib/components/italic.ws.js +2 -2
  71. package/lib/components/label.ws.js +2 -2
  72. package/lib/components/link-block.ws.js +2 -2
  73. package/lib/components/link.ws.js +2 -2
  74. package/lib/components/list-item.ws.js +2 -2
  75. package/lib/components/list.ws.js +2 -2
  76. package/lib/components/paragraph.ws.js +2 -2
  77. package/lib/components/radio-button-field.ws.js +2 -2
  78. package/lib/components/radio-button.ws.js +2 -2
  79. package/lib/components/separator.ws.js +2 -2
  80. package/lib/components/slot.ws.js +2 -2
  81. package/lib/components/span.ws.js +2 -2
  82. package/lib/components/subscript.ws.js +2 -2
  83. package/lib/components/success-message.ws.js +2 -2
  84. package/lib/components/superscript.ws.js +2 -2
  85. package/lib/components/text-block.ws.js +2 -2
  86. package/lib/components/textarea.ws.js +2 -2
  87. package/lib/css/css.js +2 -5
  88. package/lib/css/normalize.js +2 -2
  89. package/lib/css/presets.js +8 -1
  90. package/lib/tree/create-elements-tree.js +2 -4
  91. package/lib/types/app/params.d.ts +22 -1
  92. package/lib/types/components/__generated__/html.props.d.ts +2 -0
  93. package/lib/types/components/component-meta.d.ts +1785 -10
  94. package/lib/types/components/components-utils.d.ts +6 -3
  95. package/lib/types/components/components.d.ts +1 -0
  96. package/lib/types/components/html.d.ts +7 -0
  97. package/lib/types/components/html.stories.d.ts +11 -0
  98. package/lib/types/components/html.ws.d.ts +3 -0
  99. package/lib/types/components/index.d.ts +2 -2
  100. package/lib/types/context.d.ts +1 -0
  101. package/lib/types/css/css.d.ts +2 -0
  102. package/lib/types/css/presets.d.ts +1 -0
  103. package/lib/types/tree/create-elements-tree.d.ts +2 -2
  104. package/package.json +13 -12
  105. package/src/app/custom-components/form.ws.tsx +2 -2
  106. package/src/app/custom-components/image.tsx +7 -13
  107. package/src/app/params.ts +23 -1
  108. package/src/components/__generated__/html.props.ts +10 -0
  109. package/src/components/blockquote.ws.tsx +2 -2
  110. package/src/components/body.ws.tsx +2 -2
  111. package/src/components/bold.ws.tsx +2 -2
  112. package/src/components/box.ws.ts +2 -2
  113. package/src/components/button.ws.tsx +2 -2
  114. package/src/components/checkbox-field.ws.tsx +2 -2
  115. package/src/components/checkbox.ws.tsx +2 -2
  116. package/src/components/code.ws.tsx +2 -2
  117. package/src/components/component-meta.ts +3 -6
  118. package/src/components/components-utils.ts +14 -58
  119. package/src/components/components.ts +1 -0
  120. package/src/components/error-message.ws.tsx +2 -2
  121. package/src/components/form.ws.tsx +2 -2
  122. package/src/components/fragment.ws.ts +1 -1
  123. package/src/components/heading.ws.tsx +2 -2
  124. package/src/components/html.stories.tsx +16 -0
  125. package/src/components/html.tsx +96 -0
  126. package/src/components/html.ws.ts +22 -0
  127. package/src/components/image.ws.tsx +2 -2
  128. package/src/components/index.ts +6 -83
  129. package/src/components/input.ws.tsx +2 -2
  130. package/src/components/italic.ws.tsx +2 -2
  131. package/src/components/label.ws.tsx +2 -2
  132. package/src/components/link-block.ws.tsx +2 -2
  133. package/src/components/link.ws.tsx +2 -2
  134. package/src/components/list-item.ws.tsx +2 -2
  135. package/src/components/list.ws.tsx +2 -2
  136. package/src/components/paragraph.ws.tsx +2 -2
  137. package/src/components/radio-button-field.ws.tsx +2 -2
  138. package/src/components/radio-button.ws.tsx +2 -2
  139. package/src/components/separator.ws.tsx +2 -2
  140. package/src/components/slot.ws.ts +2 -2
  141. package/src/components/span.ws.tsx +2 -2
  142. package/src/components/subscript.ws.tsx +2 -2
  143. package/src/components/success-message.ws.tsx +2 -2
  144. package/src/components/superscript.ws.tsx +2 -2
  145. package/src/components/text-block.ws.tsx +2 -2
  146. package/src/components/textarea.ws.tsx +2 -2
  147. package/src/context.tsx +1 -0
  148. package/src/css/css.ts +4 -5
  149. package/src/css/normalize.ts +2 -2
  150. package/src/css/presets.ts +7 -0
  151. package/src/tree/create-elements-tree.tsx +3 -5
  152. package/lib/cjs/tree/session-storage-polyfill.js +0 -65
  153. package/lib/tree/session-storage-polyfill.js +0 -45
  154. package/lib/types/tree/session-storage-polyfill.d.ts +0 -2
  155. package/src/tree/session-storage-polyfill.tsx +0 -50
@@ -1,4 +1,4 @@
1
- import { CodeIcon } from "@webstudio-is/icons";
1
+ import { CodeIcon } from "@webstudio-is/icons/svg";
2
2
  import {
3
3
  defaultStates
4
4
  } from "./component-meta";
@@ -34,7 +34,7 @@ const meta = {
34
34
  category: "general",
35
35
  type: "rich-text",
36
36
  label: "Code",
37
- Icon: CodeIcon,
37
+ icon: CodeIcon,
38
38
  states: defaultStates,
39
39
  presetStyle,
40
40
  children: [{ type: "text", value: "Code you can edit" }]
@@ -1,6 +1,6 @@
1
1
  import { z } from "zod";
2
2
  import { PropMeta } from "@webstudio-is/generate-arg-types";
3
- import { WsEmbedTemplate } from "../embed-template";
3
+ import { EmbedTemplateStyleDecl, WsEmbedTemplate } from "../embed-template";
4
4
  const WsComponentPropsMeta = z.object({
5
5
  props: z.record(PropMeta),
6
6
  initialProps: z.array(z.string()).optional()
@@ -40,8 +40,8 @@ const WsComponentMeta = z.object({
40
40
  ]),
41
41
  acceptedParents: z.optional(z.array(z.string())),
42
42
  label: z.string(),
43
- Icon: z.function(),
44
- presetStyle: z.optional(z.any()),
43
+ icon: z.string(),
44
+ presetStyle: z.optional(z.record(z.string(), EmbedTemplateStyleDecl)),
45
45
  states: z.optional(z.array(ComponentState)),
46
46
  children: z.optional(WsEmbedTemplate)
47
47
  });
@@ -1,46 +1,5 @@
1
1
  import * as components from "./components";
2
2
  import { registeredComponents } from "./index";
3
- const componentNames = Object.keys({
4
- Slot: 1,
5
- Fragment: 1,
6
- Box: 1,
7
- Body: 1,
8
- TextBlock: 1,
9
- Heading: 1,
10
- Paragraph: 1,
11
- Link: 1,
12
- LinkBlock: 1,
13
- RichTextLink: 1,
14
- Span: 1,
15
- Bold: 1,
16
- Italic: 1,
17
- Superscript: 1,
18
- Subscript: 1,
19
- Button: 1,
20
- Input: 1,
21
- Form: 1,
22
- Image: 1,
23
- Blockquote: 1,
24
- List: 1,
25
- ListItem: 1,
26
- Separator: 1,
27
- Code: 1,
28
- Label: 1,
29
- SuccessMessage: 1,
30
- ErrorMessage: 1,
31
- Textarea: 1,
32
- RadioButtonField: 1,
33
- RadioButton: 1,
34
- CheckboxField: 1,
35
- Checkbox: 1
36
- });
37
- const getComponentNames = () => {
38
- const uniqueNames = /* @__PURE__ */ new Set([
39
- ...componentNames,
40
- ...Object.keys(registeredComponents || {})
41
- ]);
42
- return Array.from(uniqueNames);
43
- };
44
3
  const getComponent = (name) => {
45
4
  return registeredComponents != null && name in registeredComponents ? registeredComponents[name] : components[name];
46
5
  };
@@ -51,6 +10,5 @@ const createGetComponent = (comps) => {
51
10
  };
52
11
  export {
53
12
  createGetComponent,
54
- getComponent,
55
- getComponentNames
13
+ getComponent
56
14
  };
@@ -1,5 +1,6 @@
1
1
  import { Slot } from "./slot";
2
2
  import { Fragment } from "./fragment";
3
+ import { Html } from "./html";
3
4
  import { Body } from "./body";
4
5
  import { Box } from "./box";
5
6
  import { TextBlock } from "./text-block";
@@ -43,6 +44,7 @@ export {
43
44
  Form,
44
45
  Fragment,
45
46
  Heading,
47
+ Html,
46
48
  Image,
47
49
  Input,
48
50
  Italic,
@@ -1,4 +1,4 @@
1
- import { BoxIcon } from "@webstudio-is/icons";
1
+ import { BoxIcon } from "@webstudio-is/icons/svg";
2
2
  import { props } from "./__generated__/error-message.props";
3
3
  import { div } from "../css/normalize";
4
4
  const presetStyle = {
@@ -7,7 +7,7 @@ const presetStyle = {
7
7
  const meta = {
8
8
  type: "container",
9
9
  label: "Error Message",
10
- Icon: BoxIcon,
10
+ icon: BoxIcon,
11
11
  presetStyle
12
12
  };
13
13
  const propsMeta = {
@@ -1,4 +1,4 @@
1
- import { FormIcon } from "@webstudio-is/icons";
1
+ import { FormIcon } from "@webstudio-is/icons/svg";
2
2
  import { form } from "../css/normalize";
3
3
  import {
4
4
  defaultStates
@@ -14,7 +14,7 @@ const meta = {
14
14
  category: "forms",
15
15
  type: "container",
16
16
  label: "Form",
17
- Icon: FormIcon,
17
+ icon: FormIcon,
18
18
  states: defaultStates,
19
19
  presetStyle,
20
20
  children: [
@@ -1,7 +1,7 @@
1
1
  const meta = {
2
2
  type: "container",
3
3
  label: "Fragment",
4
- Icon: () => null
4
+ icon: ""
5
5
  };
6
6
  const propsMeta = {
7
7
  props: {}
@@ -1,4 +1,4 @@
1
- import { HeadingIcon } from "@webstudio-is/icons";
1
+ import { HeadingIcon } from "@webstudio-is/icons/svg";
2
2
  import { h1, h2, h3, h4, h5, h6 } from "../css/normalize";
3
3
  import {
4
4
  defaultStates
@@ -16,7 +16,7 @@ const meta = {
16
16
  category: "typography",
17
17
  type: "rich-text",
18
18
  label: "Heading",
19
- Icon: HeadingIcon,
19
+ icon: HeadingIcon,
20
20
  children: [{ type: "text", value: "Heading you can edit" }],
21
21
  states: defaultStates,
22
22
  presetStyle
@@ -0,0 +1,65 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import {
3
+ forwardRef,
4
+ useContext,
5
+ useEffect,
6
+ useRef
7
+ } from "react";
8
+ import { mergeRefs } from "@react-aria/utils";
9
+ import { ReactSdkContext } from "../context";
10
+ const ExecutableHtml = (props) => {
11
+ const { code, innerRef, ...rest } = props;
12
+ const containerRef = useRef(null);
13
+ useEffect(() => {
14
+ const container = containerRef.current;
15
+ if (container === null || code === void 0) {
16
+ return;
17
+ }
18
+ const range = document.createRange();
19
+ range.setStart(container, 0);
20
+ const fragment = range.createContextualFragment(code);
21
+ while (container.firstChild) {
22
+ container.removeChild(container.firstChild);
23
+ }
24
+ container.append(fragment);
25
+ }, [code]);
26
+ return /* @__PURE__ */ jsx(
27
+ "div",
28
+ {
29
+ ...rest,
30
+ ref: mergeRefs(innerRef, containerRef),
31
+ style: { display: "contents" }
32
+ }
33
+ );
34
+ };
35
+ const InnerHtml = (props) => {
36
+ const { code, innerRef, ...rest } = props;
37
+ return /* @__PURE__ */ jsx(
38
+ "div",
39
+ {
40
+ ...rest,
41
+ ref: innerRef,
42
+ style: { display: "contents" },
43
+ dangerouslySetInnerHTML: { __html: props.code ?? "" }
44
+ }
45
+ );
46
+ };
47
+ const Placeholder = (props) => {
48
+ const { code, innerRef, ...rest } = props;
49
+ return /* @__PURE__ */ jsx("div", { ref: innerRef, ...rest, style: { padding: "20px" }, children: 'Paste html into "Code" prop' });
50
+ };
51
+ const Html = forwardRef((props, ref) => {
52
+ const { renderer } = useContext(ReactSdkContext);
53
+ const { code, executeScriptInCanvas, ...rest } = props;
54
+ if (code === void 0 || code.trim().length === 0) {
55
+ return /* @__PURE__ */ jsx(Placeholder, { innerRef: ref, ...rest });
56
+ }
57
+ if (renderer === "canvas" && executeScriptInCanvas === true) {
58
+ return /* @__PURE__ */ jsx(ExecutableHtml, { innerRef: ref, code, ...rest });
59
+ }
60
+ return /* @__PURE__ */ jsx(InnerHtml, { innerRef: ref, code, ...rest });
61
+ });
62
+ Html.displayName = "Html";
63
+ export {
64
+ Html
65
+ };
@@ -0,0 +1,23 @@
1
+ import { CodeIcon } from "@webstudio-is/icons/svg";
2
+ import { props } from "./__generated__/html.props";
3
+ const meta = {
4
+ category: "general",
5
+ type: "embed",
6
+ label: "Html",
7
+ icon: CodeIcon
8
+ };
9
+ const propsMeta = {
10
+ props: {
11
+ ...props,
12
+ code: {
13
+ required: true,
14
+ control: "code",
15
+ type: "string",
16
+ rows: 10
17
+ }
18
+ }
19
+ };
20
+ export {
21
+ meta,
22
+ propsMeta
23
+ };
@@ -1,4 +1,4 @@
1
- import { ImageIcon } from "@webstudio-is/icons";
1
+ import { ImageIcon } from "@webstudio-is/icons/svg";
2
2
  import { img } from "../css/normalize";
3
3
  import {
4
4
  defaultStates
@@ -24,7 +24,7 @@ const meta = {
24
24
  category: "media",
25
25
  type: "embed",
26
26
  label: "Image",
27
- Icon: ImageIcon,
27
+ icon: ImageIcon,
28
28
  states: defaultStates,
29
29
  presetStyle
30
30
  };
@@ -1,6 +1,6 @@
1
- import { PropMeta } from "@webstudio-is/generate-arg-types";
2
1
  import { meta as SlotMeta } from "./slot.ws";
3
2
  import { meta as FragmentMeta } from "./fragment.ws";
3
+ import { meta as HtmlMeta } from "./html.ws";
4
4
  import { meta as BodyMeta } from "./body.ws";
5
5
  import { meta as BoxMeta } from "./box.ws";
6
6
  import { meta as TextBlockMeta } from "./text-block.ws";
@@ -33,6 +33,7 @@ import { meta as CheckboxFieldMeta } from "./checkbox-field.ws";
33
33
  import { meta as CheckboxMeta } from "./checkbox.ws";
34
34
  import { propsMeta as SlotMetaPropsMeta } from "./slot.ws";
35
35
  import { propsMeta as FragmentMetaPropsMeta } from "./fragment.ws";
36
+ import { propsMeta as HtmlMetaPropsMeta } from "./html.ws";
36
37
  import { propsMeta as BodyMetaPropsMeta } from "./body.ws";
37
38
  import { propsMeta as BoxMetaPropsMeta } from "./box.ws";
38
39
  import { propsMeta as TextBlockMetaPropsMeta } from "./text-block.ws";
@@ -66,6 +67,7 @@ import { propsMeta as CheckboxPropsMeta } from "./checkbox.ws";
66
67
  const defaultMetas = {
67
68
  Slot: SlotMeta,
68
69
  Fragment: FragmentMeta,
70
+ Html: HtmlMeta,
69
71
  Box: BoxMeta,
70
72
  Body: BodyMeta,
71
73
  TextBlock: TextBlockMeta,
@@ -108,9 +110,10 @@ const registerComponentMetas = (overrides) => {
108
110
  }
109
111
  currentMetas = result;
110
112
  };
111
- const defaultPropsMetasRaw = {
113
+ const defaultPropsMetas = {
112
114
  Slot: SlotMetaPropsMeta,
113
115
  Fragment: FragmentMetaPropsMeta,
116
+ Html: HtmlMetaPropsMeta,
114
117
  Box: BoxMetaPropsMeta,
115
118
  Body: BodyMetaPropsMeta,
116
119
  TextBlock: TextBlockMetaPropsMeta,
@@ -142,59 +145,10 @@ const defaultPropsMetasRaw = {
142
145
  CheckboxField: CheckboxFieldPropsMeta,
143
146
  Checkbox: CheckboxPropsMeta
144
147
  };
145
- const defaultPropsMetas = defaultPropsMetasRaw;
146
- let registeredPropsMetas = {};
147
- let currentPropsMetas = void 0;
148
- const getComponentPropsMeta = (name) => {
149
- if (currentPropsMetas === void 0) {
150
- currentPropsMetas = {};
151
- for (const name2 of Object.keys(defaultPropsMetas)) {
152
- const props = computeProps(
153
- defaultPropsMetas[name2],
154
- registeredPropsMetas[name2] ?? {}
155
- );
156
- const initialProps = computeInitialProps(
157
- props,
158
- defaultPropsMetas[name2],
159
- registeredPropsMetas[name2] ?? {}
160
- );
161
- currentPropsMetas[name2] = { props, initialProps };
162
- }
163
- }
164
- return currentPropsMetas[name];
165
- };
166
- const registerComponentPropsMetas = (metas) => {
167
- registeredPropsMetas = metas;
168
- currentPropsMetas = void 0;
169
- };
170
148
  let registeredComponents;
171
149
  const registerComponents = (components) => {
172
150
  registeredComponents = components;
173
151
  };
174
- const computeProps = (defaults, overrides) => {
175
- if (overrides) {
176
- const allNames = (/* @__PURE__ */ new Set([
177
- ...Object.keys(defaults.props ?? {}),
178
- ...Object.keys(overrides?.props ?? {})
179
- ])).values();
180
- const result = {};
181
- for (const name of allNames) {
182
- result[name] = PropMeta.parse({
183
- ...defaults.props[name],
184
- ...overrides?.props?.[name]
185
- });
186
- }
187
- return result;
188
- }
189
- return defaults.props;
190
- };
191
- const computeInitialProps = (props, defaults, overrides) => {
192
- const initialProps = overrides?.initialProps ?? defaults?.initialProps ?? [];
193
- const requiredProps = props ? Object.entries(props).filter(
194
- ([name, value]) => value?.required && initialProps.includes(name) === false
195
- ).map(([name]) => name) : [];
196
- return [...initialProps, ...requiredProps];
197
- };
198
152
  const canAcceptComponent = (parentComponent, childComponent) => {
199
153
  const parentMeta = getComponentMeta(parentComponent);
200
154
  const childMeta = getComponentMeta(childComponent);
@@ -205,10 +159,10 @@ const canAcceptComponent = (parentComponent, childComponent) => {
205
159
  };
206
160
  export {
207
161
  canAcceptComponent,
162
+ defaultMetas,
163
+ defaultPropsMetas,
208
164
  getComponentMeta,
209
- getComponentPropsMeta,
210
165
  registerComponentMetas,
211
- registerComponentPropsMetas,
212
166
  registerComponents,
213
167
  registeredComponents
214
168
  };
@@ -1,4 +1,4 @@
1
- import { FormTextFieldIcon } from "@webstudio-is/icons";
1
+ import { FormTextFieldIcon } from "@webstudio-is/icons/svg";
2
2
  import { input } from "../css/normalize";
3
3
  import {
4
4
  defaultStates
@@ -11,7 +11,7 @@ const meta = {
11
11
  category: "forms",
12
12
  type: "control",
13
13
  label: "Text Input",
14
- Icon: FormTextFieldIcon,
14
+ icon: FormTextFieldIcon,
15
15
  presetStyle,
16
16
  states: [
17
17
  ...defaultStates,
@@ -1,4 +1,4 @@
1
- import { TextItalicIcon } from "@webstudio-is/icons";
1
+ import { TextItalicIcon } from "@webstudio-is/icons/svg";
2
2
  import {
3
3
  defaultStates
4
4
  } from "./component-meta";
@@ -16,7 +16,7 @@ const presetStyle = {
16
16
  const meta = {
17
17
  type: "rich-text-child",
18
18
  label: "Italic Text",
19
- Icon: TextItalicIcon,
19
+ icon: TextItalicIcon,
20
20
  states: defaultStates,
21
21
  presetStyle
22
22
  };
@@ -1,4 +1,4 @@
1
- import { TextBlockIcon } from "@webstudio-is/icons";
1
+ import { TextBlockIcon } from "@webstudio-is/icons/svg";
2
2
  import {
3
3
  defaultStates
4
4
  } from "./component-meta";
@@ -14,7 +14,7 @@ const meta = {
14
14
  category: "forms",
15
15
  type: "rich-text",
16
16
  label: "Input Label",
17
- Icon: TextBlockIcon,
17
+ icon: TextBlockIcon,
18
18
  states: defaultStates,
19
19
  presetStyle,
20
20
  children: [{ type: "text", value: "Form Label" }]
@@ -1,4 +1,4 @@
1
- import { LinkBlockIcon } from "@webstudio-is/icons";
1
+ import { LinkBlockIcon } from "@webstudio-is/icons/svg";
2
2
  import { props } from "./__generated__/link-block.props";
3
3
  import { meta as linkMeta, propsMeta as linkPropsMeta } from "./link.ws";
4
4
  import { a } from "../css/normalize";
@@ -15,7 +15,7 @@ const meta = {
15
15
  category: "general",
16
16
  type: "container",
17
17
  label: "Link Block",
18
- Icon: LinkBlockIcon,
18
+ icon: LinkBlockIcon,
19
19
  states: linkMeta.states,
20
20
  presetStyle
21
21
  };
@@ -1,4 +1,4 @@
1
- import { LinkIcon } from "@webstudio-is/icons";
1
+ import { LinkIcon } from "@webstudio-is/icons/svg";
2
2
  import { a } from "../css/normalize";
3
3
  import {
4
4
  defaultStates
@@ -21,7 +21,7 @@ const meta = {
21
21
  category: "general",
22
22
  type: "rich-text",
23
23
  label: "Link Text",
24
- Icon: LinkIcon,
24
+ icon: LinkIcon,
25
25
  presetStyle,
26
26
  states: [
27
27
  ...defaultStates,
@@ -1,4 +1,4 @@
1
- import { ListItemIcon } from "@webstudio-is/icons";
1
+ import { ListItemIcon } from "@webstudio-is/icons/svg";
2
2
  import { li } from "../css/normalize";
3
3
  import {
4
4
  defaultStates
@@ -12,7 +12,7 @@ const meta = {
12
12
  type: "rich-text",
13
13
  acceptedParents: ["List"],
14
14
  label: "List Item",
15
- Icon: ListItemIcon,
15
+ icon: ListItemIcon,
16
16
  children: [{ type: "text", value: "List Item you can edit" }],
17
17
  states: defaultStates,
18
18
  presetStyle
@@ -1,4 +1,4 @@
1
- import { ListIcon } from "@webstudio-is/icons";
1
+ import { ListIcon } from "@webstudio-is/icons/svg";
2
2
  import {
3
3
  defaultStates
4
4
  } from "./component-meta";
@@ -40,7 +40,7 @@ const meta = {
40
40
  category: "typography",
41
41
  type: "container",
42
42
  label: "List",
43
- Icon: ListIcon,
43
+ icon: ListIcon,
44
44
  states: defaultStates,
45
45
  presetStyle,
46
46
  children: []
@@ -1,4 +1,4 @@
1
- import { TextAlignLeftIcon } from "@webstudio-is/icons";
1
+ import { TextAlignLeftIcon } from "@webstudio-is/icons/svg";
2
2
  import { p } from "../css/normalize";
3
3
  import {
4
4
  defaultStates
@@ -11,7 +11,7 @@ const meta = {
11
11
  category: "typography",
12
12
  type: "rich-text",
13
13
  label: "Paragraph",
14
- Icon: TextAlignLeftIcon,
14
+ icon: TextAlignLeftIcon,
15
15
  children: [{ type: "text", value: "Pragraph you can edit" }],
16
16
  states: defaultStates,
17
17
  presetStyle
@@ -1,4 +1,4 @@
1
- import { RadioCheckedIcon } from "@webstudio-is/icons";
1
+ import { RadioCheckedIcon } from "@webstudio-is/icons/svg";
2
2
  import {
3
3
  defaultStates
4
4
  } from "./component-meta";
@@ -14,7 +14,7 @@ const meta = {
14
14
  category: "forms",
15
15
  type: "container",
16
16
  label: "Radio",
17
- Icon: RadioCheckedIcon,
17
+ icon: RadioCheckedIcon,
18
18
  states: defaultStates,
19
19
  presetStyle,
20
20
  children: [
@@ -1,4 +1,4 @@
1
- import { RadioCheckedIcon } from "@webstudio-is/icons";
1
+ import { RadioCheckedIcon } from "@webstudio-is/icons/svg";
2
2
  import {
3
3
  defaultStates
4
4
  } from "./component-meta";
@@ -16,7 +16,7 @@ const presetStyle = {
16
16
  const meta = {
17
17
  type: "control",
18
18
  label: "Radio Input",
19
- Icon: RadioCheckedIcon,
19
+ icon: RadioCheckedIcon,
20
20
  presetStyle,
21
21
  states: [
22
22
  ...defaultStates,
@@ -1,4 +1,4 @@
1
- import { DashIcon } from "@webstudio-is/icons";
1
+ import { DashIcon } from "@webstudio-is/icons/svg";
2
2
  import {
3
3
  defaultStates
4
4
  } from "./component-meta";
@@ -37,7 +37,7 @@ const meta = {
37
37
  category: "general",
38
38
  type: "embed",
39
39
  label: "Separator",
40
- Icon: DashIcon,
40
+ icon: DashIcon,
41
41
  states: defaultStates,
42
42
  presetStyle,
43
43
  children: []
@@ -1,9 +1,9 @@
1
- import { SlotComponentIcon } from "@webstudio-is/icons";
1
+ import { SlotComponentIcon } from "@webstudio-is/icons/svg";
2
2
  const meta = {
3
3
  category: "general",
4
4
  type: "container",
5
5
  label: "Slot",
6
- Icon: SlotComponentIcon
6
+ icon: SlotComponentIcon
7
7
  };
8
8
  const propsMeta = {
9
9
  props: {}
@@ -1,4 +1,4 @@
1
- import { PaintBrushIcon } from "@webstudio-is/icons";
1
+ import { PaintBrushIcon } from "@webstudio-is/icons/svg";
2
2
  import { span } from "../css/normalize";
3
3
  import {
4
4
  defaultStates
@@ -10,7 +10,7 @@ const presetStyle = {
10
10
  const meta = {
11
11
  type: "rich-text-child",
12
12
  label: "Styled Text",
13
- Icon: PaintBrushIcon,
13
+ icon: PaintBrushIcon,
14
14
  states: defaultStates,
15
15
  presetStyle
16
16
  };
@@ -1,4 +1,4 @@
1
- import { SubscriptIcon } from "@webstudio-is/icons";
1
+ import { SubscriptIcon } from "@webstudio-is/icons/svg";
2
2
  import { sub } from "../css/normalize";
3
3
  import {
4
4
  defaultStates
@@ -10,7 +10,7 @@ const presetStyle = {
10
10
  const meta = {
11
11
  type: "rich-text-child",
12
12
  label: "Subscript Text",
13
- Icon: SubscriptIcon,
13
+ icon: SubscriptIcon,
14
14
  states: defaultStates,
15
15
  presetStyle
16
16
  };
@@ -1,4 +1,4 @@
1
- import { BoxIcon } from "@webstudio-is/icons";
1
+ import { BoxIcon } from "@webstudio-is/icons/svg";
2
2
  import { props } from "./__generated__/success-message.props";
3
3
  import { div } from "../css/normalize";
4
4
  const presetStyle = {
@@ -7,7 +7,7 @@ const presetStyle = {
7
7
  const meta = {
8
8
  type: "container",
9
9
  label: "Success Message",
10
- Icon: BoxIcon,
10
+ icon: BoxIcon,
11
11
  presetStyle
12
12
  };
13
13
  const propsMeta = {
@@ -1,4 +1,4 @@
1
- import { SuperscriptIcon } from "@webstudio-is/icons";
1
+ import { SuperscriptIcon } from "@webstudio-is/icons/svg";
2
2
  import { sup } from "../css/normalize";
3
3
  import {
4
4
  defaultStates
@@ -10,7 +10,7 @@ const presetStyle = {
10
10
  const meta = {
11
11
  type: "rich-text-child",
12
12
  label: "Superscript Text",
13
- Icon: SuperscriptIcon,
13
+ icon: SuperscriptIcon,
14
14
  states: defaultStates,
15
15
  presetStyle
16
16
  };
@@ -1,4 +1,4 @@
1
- import { TextBlockIcon } from "@webstudio-is/icons";
1
+ import { TextBlockIcon } from "@webstudio-is/icons/svg";
2
2
  import {
3
3
  defaultStates
4
4
  } from "./component-meta";
@@ -17,7 +17,7 @@ const meta = {
17
17
  category: "typography",
18
18
  type: "rich-text",
19
19
  label: "Text Block",
20
- Icon: TextBlockIcon,
20
+ icon: TextBlockIcon,
21
21
  states: defaultStates,
22
22
  presetStyle,
23
23
  children: [{ type: "text", value: "Block of text you can edit" }]
@@ -1,4 +1,4 @@
1
- import { FormTextAreaIcon } from "@webstudio-is/icons";
1
+ import { FormTextAreaIcon } from "@webstudio-is/icons/svg";
2
2
  import { textarea } from "../css/normalize";
3
3
  import {
4
4
  defaultStates
@@ -15,7 +15,7 @@ const meta = {
15
15
  category: "forms",
16
16
  type: "control",
17
17
  label: "Text Area",
18
- Icon: FormTextAreaIcon,
18
+ icon: FormTextAreaIcon,
19
19
  presetStyle,
20
20
  states: [
21
21
  ...defaultStates,
package/lib/css/css.js CHANGED
@@ -1,6 +1,4 @@
1
1
  import { createCssEngine } from "@webstudio-is/css-engine";
2
- import { getComponentNames } from "../components/components-utils";
3
- import { getComponentMeta } from "../components";
4
2
  import { idAttribute } from "../tree";
5
3
  import { addGlobalRules } from "./global-rules";
6
4
  import { getPresetStyleRules, getStyleRules } from "./style-rules";
@@ -37,9 +35,8 @@ const generateCssText = (data, options) => {
37
35
  for (const breakpoint of breakpoints.values()) {
38
36
  engine.addMediaRule(breakpoint.id, breakpoint);
39
37
  }
40
- for (const component of getComponentNames()) {
41
- const meta = getComponentMeta(component);
42
- const presetStyle = meta?.presetStyle;
38
+ for (const [component, meta] of data.componentMetas) {
39
+ const presetStyle = meta.presetStyle;
43
40
  if (presetStyle === void 0) {
44
41
  continue;
45
42
  }