@webstudio-is/react-sdk 0.59.0 → 0.61.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 (163) hide show
  1. package/lib/app/custom-components/shared/remix-link.js +2 -2
  2. package/lib/app/index.js +0 -1
  3. package/lib/cjs/app/custom-components/shared/remix-link.js +2 -2
  4. package/lib/cjs/app/index.js +0 -1
  5. package/lib/cjs/components/__generated__/blockquote.props.js +5 -0
  6. package/lib/cjs/components/__generated__/body.props.js +5 -0
  7. package/lib/cjs/components/__generated__/bold.props.js +5 -0
  8. package/lib/cjs/components/__generated__/box.props.js +5 -0
  9. package/lib/cjs/components/__generated__/button.props.js +5 -1
  10. package/lib/cjs/components/__generated__/code.props.js +5 -0
  11. package/lib/cjs/components/__generated__/form.props.js +5 -0
  12. package/lib/cjs/components/__generated__/heading.props.js +5 -0
  13. package/lib/cjs/components/__generated__/image.props.js +5 -0
  14. package/lib/cjs/components/__generated__/input.props.js +11 -2
  15. package/lib/cjs/components/__generated__/italic.props.js +5 -0
  16. package/lib/cjs/components/__generated__/link-block.props.js +5 -1
  17. package/lib/cjs/components/__generated__/link.props.js +5 -1
  18. package/lib/cjs/components/__generated__/list-item.props.js +5 -0
  19. package/lib/cjs/components/__generated__/list.props.js +5 -0
  20. package/lib/cjs/components/__generated__/paragraph.props.js +5 -0
  21. package/lib/cjs/components/__generated__/rich-text-link.props.js +5 -1
  22. package/lib/cjs/components/__generated__/separator.props.js +5 -0
  23. package/lib/cjs/components/__generated__/span.props.js +5 -0
  24. package/lib/cjs/components/__generated__/subscript.props.js +5 -0
  25. package/lib/cjs/components/__generated__/superscript.props.js +5 -0
  26. package/lib/cjs/components/__generated__/text-block.props.js +5 -0
  27. package/lib/cjs/components/blockquote.ws.js +36 -48
  28. package/lib/cjs/components/body.ws.js +19 -24
  29. package/lib/cjs/components/button.ws.js +1 -1
  30. package/lib/cjs/components/code.ws.js +20 -28
  31. package/lib/cjs/components/component-meta.js +2 -1
  32. package/lib/cjs/components/form.ws.js +14 -7
  33. package/lib/cjs/components/heading.ws.js +1 -1
  34. package/lib/cjs/components/image.ws.js +8 -9
  35. package/lib/cjs/components/italic.ws.js +5 -5
  36. package/lib/cjs/components/link-block.ws.js +5 -5
  37. package/lib/cjs/components/link.js +1 -1
  38. package/lib/cjs/components/link.ws.js +9 -10
  39. package/lib/cjs/components/list-item.ws.js +1 -1
  40. package/lib/cjs/components/list.ws.js +22 -22
  41. package/lib/cjs/components/paragraph.ws.js +1 -1
  42. package/lib/cjs/components/separator.ws.js +20 -20
  43. package/lib/cjs/components/text-block.ws.js +6 -7
  44. package/lib/cjs/css/css.js +6 -9
  45. package/lib/cjs/css/normalize.js +166 -185
  46. package/lib/cjs/css/presets.js +14 -34
  47. package/lib/cjs/css/style-rules.js +17 -0
  48. package/lib/cjs/embed-template.js +160 -0
  49. package/lib/cjs/index.js +1 -0
  50. package/lib/components/__generated__/blockquote.props.js +5 -0
  51. package/lib/components/__generated__/body.props.js +5 -0
  52. package/lib/components/__generated__/bold.props.js +5 -0
  53. package/lib/components/__generated__/box.props.js +5 -0
  54. package/lib/components/__generated__/button.props.js +5 -1
  55. package/lib/components/__generated__/code.props.js +5 -0
  56. package/lib/components/__generated__/form.props.js +5 -0
  57. package/lib/components/__generated__/heading.props.js +5 -0
  58. package/lib/components/__generated__/image.props.js +5 -0
  59. package/lib/components/__generated__/input.props.js +11 -2
  60. package/lib/components/__generated__/italic.props.js +5 -0
  61. package/lib/components/__generated__/link-block.props.js +5 -1
  62. package/lib/components/__generated__/link.props.js +5 -1
  63. package/lib/components/__generated__/list-item.props.js +5 -0
  64. package/lib/components/__generated__/list.props.js +5 -0
  65. package/lib/components/__generated__/paragraph.props.js +5 -0
  66. package/lib/components/__generated__/rich-text-link.props.js +5 -1
  67. package/lib/components/__generated__/separator.props.js +5 -0
  68. package/lib/components/__generated__/span.props.js +5 -0
  69. package/lib/components/__generated__/subscript.props.js +5 -0
  70. package/lib/components/__generated__/superscript.props.js +5 -0
  71. package/lib/components/__generated__/text-block.props.js +5 -0
  72. package/lib/components/blockquote.ws.js +36 -48
  73. package/lib/components/body.ws.js +19 -24
  74. package/lib/components/button.ws.js +1 -1
  75. package/lib/components/code.ws.js +20 -28
  76. package/lib/components/component-meta.js +2 -1
  77. package/lib/components/form.ws.js +14 -7
  78. package/lib/components/heading.ws.js +1 -1
  79. package/lib/components/image.ws.js +8 -9
  80. package/lib/components/italic.ws.js +5 -5
  81. package/lib/components/link-block.ws.js +5 -5
  82. package/lib/components/link.js +1 -1
  83. package/lib/components/link.ws.js +9 -10
  84. package/lib/components/list-item.ws.js +1 -1
  85. package/lib/components/list.ws.js +22 -22
  86. package/lib/components/paragraph.ws.js +1 -1
  87. package/lib/components/separator.ws.js +20 -20
  88. package/lib/components/text-block.ws.js +6 -7
  89. package/lib/css/css.js +8 -11
  90. package/lib/css/normalize.js +166 -185
  91. package/lib/css/presets.js +14 -34
  92. package/lib/css/style-rules.js +17 -0
  93. package/lib/embed-template.js +140 -0
  94. package/lib/index.js +1 -0
  95. package/lib/types/app/index.d.ts +0 -1
  96. package/lib/types/components/box.stories.d.ts +2 -2
  97. package/lib/types/components/component-meta.d.ts +20 -5
  98. package/lib/types/components/components-utils.d.ts +1 -1
  99. package/lib/types/css/normalize.d.ts +8786 -2286
  100. package/lib/types/css/presets.d.ts +2 -38
  101. package/lib/types/css/style-rules.d.ts +11 -9
  102. package/lib/types/embed-template.d.ts +1725 -0
  103. package/lib/types/embed-template.test.d.ts +1 -0
  104. package/lib/types/index.d.ts +1 -0
  105. package/package.json +16 -19
  106. package/src/app/custom-components/shared/remix-link.tsx +2 -2
  107. package/src/app/index.ts +0 -1
  108. package/src/components/__generated__/blockquote.props.ts +5 -0
  109. package/src/components/__generated__/body.props.ts +5 -0
  110. package/src/components/__generated__/bold.props.ts +5 -0
  111. package/src/components/__generated__/box.props.ts +5 -0
  112. package/src/components/__generated__/button.props.ts +5 -1
  113. package/src/components/__generated__/code.props.ts +5 -0
  114. package/src/components/__generated__/form.props.ts +5 -0
  115. package/src/components/__generated__/heading.props.ts +5 -0
  116. package/src/components/__generated__/image.props.ts +5 -0
  117. package/src/components/__generated__/input.props.ts +11 -2
  118. package/src/components/__generated__/italic.props.ts +5 -0
  119. package/src/components/__generated__/link-block.props.ts +5 -1
  120. package/src/components/__generated__/link.props.ts +5 -1
  121. package/src/components/__generated__/list-item.props.ts +5 -0
  122. package/src/components/__generated__/list.props.ts +5 -0
  123. package/src/components/__generated__/paragraph.props.ts +5 -0
  124. package/src/components/__generated__/rich-text-link.props.ts +5 -1
  125. package/src/components/__generated__/separator.props.ts +5 -0
  126. package/src/components/__generated__/span.props.ts +5 -0
  127. package/src/components/__generated__/subscript.props.ts +5 -0
  128. package/src/components/__generated__/superscript.props.ts +5 -0
  129. package/src/components/__generated__/text-block.props.ts +5 -0
  130. package/src/components/blockquote.ws.tsx +42 -52
  131. package/src/components/body.ws.tsx +25 -32
  132. package/src/components/bold.ws.tsx +6 -3
  133. package/src/components/box.ws.ts +6 -3
  134. package/src/components/button.ws.tsx +7 -4
  135. package/src/components/code.ws.tsx +26 -32
  136. package/src/components/component-meta.ts +5 -3
  137. package/src/components/form.ws.tsx +19 -9
  138. package/src/components/heading.ws.tsx +7 -4
  139. package/src/components/image.ws.tsx +14 -12
  140. package/src/components/input.ws.tsx +6 -3
  141. package/src/components/italic.ws.tsx +11 -8
  142. package/src/components/link-block.ws.tsx +11 -8
  143. package/src/components/link.tsx +1 -1
  144. package/src/components/link.ws.tsx +15 -13
  145. package/src/components/list-item.ws.tsx +7 -4
  146. package/src/components/list.ws.tsx +28 -25
  147. package/src/components/paragraph.ws.tsx +7 -4
  148. package/src/components/separator.ws.tsx +26 -25
  149. package/src/components/span.ws.tsx +6 -3
  150. package/src/components/subscript.ws.tsx +6 -3
  151. package/src/components/superscript.ws.tsx +6 -3
  152. package/src/components/text-block.ws.tsx +12 -11
  153. package/src/css/css.ts +8 -11
  154. package/src/css/normalize.ts +165 -188
  155. package/src/css/presets.ts +15 -37
  156. package/src/css/style-rules.ts +24 -0
  157. package/src/embed-template.test.ts +210 -0
  158. package/src/embed-template.ts +187 -0
  159. package/src/index.ts +1 -0
  160. package/lib/app/handle-request.server.js +0 -16
  161. package/lib/cjs/app/handle-request.server.js +0 -36
  162. package/lib/types/app/handle-request.server.d.ts +0 -2
  163. package/src/app/handle-request.server.tsx +0 -21
@@ -1,8 +1,11 @@
1
- import type { Style } from "@webstudio-is/css-data";
2
1
  import { HeadingIcon } from "@webstudio-is/icons";
3
2
  import type { ComponentProps } from "react";
4
3
  import { h1, h2, h3, h4, h5, h6 } from "../css/normalize";
5
- import type { WsComponentMeta, WsComponentPropsMeta } from "./component-meta";
4
+ import type {
5
+ PresetStyle,
6
+ WsComponentMeta,
7
+ WsComponentPropsMeta,
8
+ } from "./component-meta";
6
9
  import type { Heading } from "./heading";
7
10
  import { props } from "./__generated__/heading.props";
8
11
 
@@ -15,14 +18,14 @@ const presetStyle = {
15
18
  h4,
16
19
  h5,
17
20
  h6,
18
- } as const satisfies Record<HeadingTags, Style>;
21
+ } satisfies PresetStyle<HeadingTags>;
19
22
 
20
23
  export const meta: WsComponentMeta = {
21
24
  category: "typography",
22
25
  type: "rich-text",
23
26
  label: "Heading",
24
27
  Icon: HeadingIcon,
25
- children: ["Heading you can edit"],
28
+ children: [{ type: "text", value: "Heading you can edit" }],
26
29
  presetStyle,
27
30
  };
28
31
 
@@ -1,28 +1,30 @@
1
- import type { Style } from "@webstudio-is/css-data";
2
1
  import { ImageIcon } from "@webstudio-is/icons";
3
2
  import { img } from "../css/normalize";
4
- import type { WsComponentMeta, WsComponentPropsMeta } from "./component-meta";
3
+ import type {
4
+ PresetStyle,
5
+ WsComponentMeta,
6
+ WsComponentPropsMeta,
7
+ } from "./component-meta";
5
8
  import type { defaultTag } from "./image";
6
9
  import { props } from "./__generated__/image.props";
7
10
 
8
11
  const presetStyle = {
9
- img: {
12
+ img: [
10
13
  ...img,
11
14
 
12
15
  // Otherwise on new image insert onto canvas it can overfit screen size multiple times
13
- maxWidth: {
14
- type: "unit",
15
- unit: "%",
16
- value: 100,
16
+ {
17
+ property: "maxWidth",
18
+ value: { type: "unit", unit: "%", value: 100 },
17
19
  },
18
20
  // inline | inline-block is not suitable because without line-height: 0 on the parent you get unsuitable spaces/margins
19
21
  // see https://stackoverflow.com/questions/24771194/is-the-margin-of-inline-block-4px-is-static-for-all-browsers
20
- display: {
21
- type: "keyword",
22
- value: "block",
22
+ {
23
+ property: "display",
24
+ value: { type: "keyword", value: "block" },
23
25
  },
24
- },
25
- } as const satisfies Record<typeof defaultTag, Style>;
26
+ ],
27
+ } satisfies PresetStyle<typeof defaultTag>;
26
28
 
27
29
  export const meta: WsComponentMeta = {
28
30
  category: "media",
@@ -1,13 +1,16 @@
1
- import type { Style } from "@webstudio-is/css-data";
2
1
  import { FormTextFieldIcon } from "@webstudio-is/icons";
3
2
  import { input } from "../css/normalize";
4
- import type { WsComponentMeta, WsComponentPropsMeta } from "./component-meta";
3
+ import type {
4
+ PresetStyle,
5
+ WsComponentMeta,
6
+ WsComponentPropsMeta,
7
+ } from "./component-meta";
5
8
  import type { defaultTag } from "./input";
6
9
  import { props } from "./__generated__/input.props";
7
10
 
8
11
  const presetStyle = {
9
12
  input,
10
- } as const satisfies Record<typeof defaultTag, Style>;
13
+ } satisfies PresetStyle<typeof defaultTag>;
11
14
 
12
15
  export const meta: WsComponentMeta = {
13
16
  category: "forms",
@@ -1,19 +1,22 @@
1
- import type { Style } from "@webstudio-is/css-data";
2
1
  import { TextItalicIcon } from "@webstudio-is/icons";
3
2
  import type { defaultTag } from "./italic";
4
- import type { WsComponentMeta, WsComponentPropsMeta } from "./component-meta";
3
+ import type {
4
+ PresetStyle,
5
+ WsComponentMeta,
6
+ WsComponentPropsMeta,
7
+ } from "./component-meta";
5
8
  import { props } from "./__generated__/italic.props";
6
9
  import { i } from "../css/normalize";
7
10
 
8
11
  const presetStyle = {
9
- i: {
12
+ i: [
10
13
  ...i,
11
- fontStyle: {
12
- type: "keyword",
13
- value: "italic",
14
+ {
15
+ property: "fontStyle",
16
+ value: { type: "keyword", value: "italic" },
14
17
  },
15
- },
16
- } as const satisfies Record<typeof defaultTag, Style>;
18
+ ],
19
+ } satisfies PresetStyle<typeof defaultTag>;
17
20
 
18
21
  export const meta: WsComponentMeta = {
19
22
  type: "rich-text-child",
@@ -1,20 +1,23 @@
1
1
  import { BoxLinkIcon } from "@webstudio-is/icons";
2
- import type { WsComponentMeta, WsComponentPropsMeta } from "./component-meta";
2
+ import type {
3
+ PresetStyle,
4
+ WsComponentMeta,
5
+ WsComponentPropsMeta,
6
+ } from "./component-meta";
3
7
  import { props } from "./__generated__/link-block.props";
4
8
  import { meta as linkMeta, propsMeta as linkPropsMeta } from "./link.ws";
5
9
  import type { defaultTag } from "./link-block";
6
- import type { Style } from "@webstudio-is/css-data";
7
10
  import { a } from "../css/normalize";
8
11
 
9
12
  const presetStyle = {
10
- a: {
13
+ a: [
11
14
  ...a,
12
- display: {
13
- type: "keyword",
14
- value: "inline-block",
15
+ {
16
+ property: "display",
17
+ value: { type: "keyword", value: "inline-block" },
15
18
  },
16
- },
17
- } as const satisfies Record<typeof defaultTag, Style>;
19
+ ],
20
+ } satisfies PresetStyle<typeof defaultTag>;
18
21
 
19
22
  export const meta: WsComponentMeta = {
20
23
  category: "general",
@@ -23,7 +23,7 @@ export const Link = forwardRef<HTMLAnchorElement, Props>((props, ref) => {
23
23
 
24
24
  switch (href?.type) {
25
25
  case "page":
26
- url = href.page.path;
26
+ url = href.page.path === "" ? "/" : href.page.path;
27
27
  if (href.hash !== undefined) {
28
28
  url += `#${href.hash}`;
29
29
  }
@@ -1,24 +1,26 @@
1
- import type { Style } from "@webstudio-is/css-data";
2
1
  import { LinkIcon } from "@webstudio-is/icons";
3
2
  import { a } from "../css/normalize";
4
- import type { WsComponentMeta, WsComponentPropsMeta } from "./component-meta";
3
+ import type {
4
+ PresetStyle,
5
+ WsComponentMeta,
6
+ WsComponentPropsMeta,
7
+ } from "./component-meta";
5
8
  import type { defaultTag } from "./link";
6
9
  import { props } from "./__generated__/link.props";
7
10
 
8
11
  const presetStyle = {
9
- a: {
12
+ a: [
10
13
  ...a,
11
- minHeight: {
12
- type: "unit",
13
- unit: "em",
14
- value: 1,
14
+ {
15
+ property: "minHeight",
16
+ value: { type: "unit", unit: "em", value: 1 },
15
17
  },
16
- display: {
17
- type: "keyword",
18
- value: "inline-block",
18
+ {
19
+ property: "display",
20
+ value: { type: "keyword", value: "inline-block" },
19
21
  },
20
- },
21
- } as const satisfies Record<typeof defaultTag, Style>;
22
+ ],
23
+ } satisfies PresetStyle<typeof defaultTag>;
22
24
 
23
25
  export const meta: WsComponentMeta = {
24
26
  category: "general",
@@ -27,7 +29,7 @@ export const meta: WsComponentMeta = {
27
29
  Icon: LinkIcon,
28
30
  presetStyle,
29
31
  states: [{ selector: "[aria-current=page]", label: "Current page" }],
30
- children: ["Link text you can edit"],
32
+ children: [{ type: "text", value: "Link text you can edit" }],
31
33
  };
32
34
 
33
35
  export const propsMeta: WsComponentPropsMeta = {
@@ -1,20 +1,23 @@
1
- import type { Style } from "@webstudio-is/css-data";
2
1
  import { ListItemIcon } from "@webstudio-is/icons";
3
2
  import { li } from "../css/normalize";
4
- import type { WsComponentMeta, WsComponentPropsMeta } from "./component-meta";
3
+ import type {
4
+ PresetStyle,
5
+ WsComponentMeta,
6
+ WsComponentPropsMeta,
7
+ } from "./component-meta";
5
8
  import type { defaultTag } from "./list-item";
6
9
  import { props } from "./__generated__/list-item.props";
7
10
 
8
11
  const presetStyle = {
9
12
  li,
10
- } as const satisfies Record<typeof defaultTag, Style>;
13
+ } satisfies PresetStyle<typeof defaultTag>;
11
14
 
12
15
  export const meta: WsComponentMeta = {
13
16
  category: "typography",
14
17
  type: "rich-text",
15
18
  label: "List Item",
16
19
  Icon: ListItemIcon,
17
- children: ["List Item you can edit"],
20
+ children: [{ type: "text", value: "List Item you can edit" }],
18
21
  presetStyle,
19
22
  };
20
23
 
@@ -1,42 +1,45 @@
1
1
  import { ListIcon } from "@webstudio-is/icons";
2
- import type { WsComponentMeta, WsComponentPropsMeta } from "./component-meta";
2
+ import type {
3
+ PresetStyle,
4
+ WsComponentMeta,
5
+ WsComponentPropsMeta,
6
+ } from "./component-meta";
3
7
  import { props } from "./__generated__/list.props";
4
8
  import type { ListTag } from "./list";
5
- import type { Style } from "@webstudio-is/css-data";
6
9
  import { ol, ul } from "../css/normalize";
7
10
 
8
11
  const presetStyle = {
9
- ol: {
12
+ ol: [
10
13
  ...ol,
11
- marginTop: {
12
- type: "keyword",
13
- value: "0",
14
+ {
15
+ property: "marginTop",
16
+ value: { type: "keyword", value: "0" },
14
17
  },
15
- marginBottom: {
16
- type: "keyword",
17
- value: "10px",
18
+ {
19
+ property: "marginBottom",
20
+ value: { type: "keyword", value: "10px" },
18
21
  },
19
- paddingLeft: {
20
- type: "keyword",
21
- value: "40px",
22
+ {
23
+ property: "paddingLeft",
24
+ value: { type: "keyword", value: "40px" },
22
25
  },
23
- },
24
- ul: {
26
+ ],
27
+ ul: [
25
28
  ...ul,
26
- marginTop: {
27
- type: "keyword",
28
- value: "0",
29
+ {
30
+ property: "marginTop",
31
+ value: { type: "keyword", value: "0" },
29
32
  },
30
- marginBottom: {
31
- type: "keyword",
32
- value: "10px",
33
+ {
34
+ property: "marginBottom",
35
+ value: { type: "keyword", value: "10px" },
33
36
  },
34
- paddingLeft: {
35
- type: "keyword",
36
- value: "40px",
37
+ {
38
+ property: "paddingLeft",
39
+ value: { type: "keyword", value: "40px" },
37
40
  },
38
- },
39
- } as const satisfies Record<ListTag, Style>;
41
+ ],
42
+ } satisfies PresetStyle<ListTag>;
40
43
 
41
44
  export const meta: WsComponentMeta = {
42
45
  category: "typography",
@@ -1,20 +1,23 @@
1
- import type { Style } from "@webstudio-is/css-data";
2
1
  import { TextAlignLeftIcon } from "@webstudio-is/icons";
3
2
  import { p } from "../css/normalize";
4
- import type { WsComponentMeta, WsComponentPropsMeta } from "./component-meta";
3
+ import type {
4
+ PresetStyle,
5
+ WsComponentMeta,
6
+ WsComponentPropsMeta,
7
+ } from "./component-meta";
5
8
  import type { defaultTag } from "./paragraph";
6
9
  import { props } from "./__generated__/paragraph.props";
7
10
 
8
11
  const presetStyle = {
9
12
  p,
10
- } as const satisfies Record<typeof defaultTag, Style>;
13
+ } satisfies PresetStyle<typeof defaultTag>;
11
14
 
12
15
  export const meta: WsComponentMeta = {
13
16
  category: "typography",
14
17
  type: "rich-text",
15
18
  label: "Paragraph",
16
19
  Icon: TextAlignLeftIcon,
17
- children: ["Pragraph you can edit"],
20
+ children: [{ type: "text", value: "Pragraph you can edit" }],
18
21
  presetStyle,
19
22
  };
20
23
 
@@ -1,42 +1,43 @@
1
1
  import { DashIcon } from "@webstudio-is/icons";
2
- import type { WsComponentMeta, WsComponentPropsMeta } from "./component-meta";
2
+ import type {
3
+ PresetStyle,
4
+ WsComponentMeta,
5
+ WsComponentPropsMeta,
6
+ } from "./component-meta";
3
7
  import { props } from "./__generated__/separator.props";
4
8
  import type { defaultTag } from "./separator";
5
- import type { Style } from "@webstudio-is/css-data";
6
9
  import { hr } from "../css/normalize";
7
10
 
8
11
  const presetStyle = {
9
- hr: {
12
+ hr: [
10
13
  ...hr,
11
14
 
12
- height: {
13
- type: "keyword",
14
- value: "1px",
15
+ {
16
+ property: "height",
17
+ value: { type: "keyword", value: "1px" },
15
18
  },
16
-
17
- backgroundColor: {
18
- type: "keyword",
19
- value: "gray",
19
+ {
20
+ property: "backgroundColor",
21
+ value: { type: "keyword", value: "gray" },
20
22
  },
21
-
22
- borderTopStyle: {
23
- type: "keyword",
24
- value: "none",
23
+ {
24
+ property: "borderTopStyle",
25
+ value: { type: "keyword", value: "none" },
25
26
  },
26
- borderRightStyle: {
27
- type: "keyword",
28
- value: "none",
27
+ {
28
+ property: "borderRightStyle",
29
+ value: { type: "keyword", value: "none" },
29
30
  },
30
- borderLeftStyle: {
31
- type: "keyword",
32
- value: "none",
31
+ {
32
+ property: "borderLeftStyle",
33
+ value: { type: "keyword", value: "none" },
33
34
  },
34
- borderBottomStyle: {
35
- type: "keyword",
36
- value: "none",
35
+ {
36
+ property: "borderBottomStyle",
37
+ value: { type: "keyword", value: "none" },
37
38
  },
38
- },
39
- } as const satisfies Record<typeof defaultTag, Style>;
39
+ ],
40
+ } satisfies PresetStyle<typeof defaultTag>;
40
41
 
41
42
  export const meta: WsComponentMeta = {
42
43
  category: "general",
@@ -1,13 +1,16 @@
1
- import type { Style } from "@webstudio-is/css-data";
2
1
  import { PaintBrushIcon } from "@webstudio-is/icons";
3
2
  import { span } from "../css/normalize";
4
- import type { WsComponentMeta, WsComponentPropsMeta } from "./component-meta";
3
+ import type {
4
+ PresetStyle,
5
+ WsComponentMeta,
6
+ WsComponentPropsMeta,
7
+ } from "./component-meta";
5
8
  import type { defaultTag } from "./span";
6
9
  import { props } from "./__generated__/span.props";
7
10
 
8
11
  const presetStyle = {
9
12
  span,
10
- } as const satisfies Record<typeof defaultTag, Style>;
13
+ } satisfies PresetStyle<typeof defaultTag>;
11
14
 
12
15
  export const meta: WsComponentMeta = {
13
16
  type: "rich-text-child",
@@ -1,13 +1,16 @@
1
- import type { Style } from "@webstudio-is/css-data";
2
1
  import { SubscriptIcon } from "@webstudio-is/icons";
3
2
  import { sub } from "../css/normalize";
4
- import type { WsComponentMeta, WsComponentPropsMeta } from "./component-meta";
3
+ import type {
4
+ PresetStyle,
5
+ WsComponentMeta,
6
+ WsComponentPropsMeta,
7
+ } from "./component-meta";
5
8
  import type { defaultTag } from "./subscript";
6
9
  import { props } from "./__generated__/subscript.props";
7
10
 
8
11
  const presetStyle = {
9
12
  sub,
10
- } as const satisfies Record<typeof defaultTag, Style>;
13
+ } satisfies PresetStyle<typeof defaultTag>;
11
14
 
12
15
  export const meta: WsComponentMeta = {
13
16
  type: "rich-text-child",
@@ -1,13 +1,16 @@
1
- import type { Style } from "@webstudio-is/css-data";
2
1
  import { SuperscriptIcon } from "@webstudio-is/icons";
3
2
  import { sup } from "../css/normalize";
4
- import type { WsComponentMeta, WsComponentPropsMeta } from "./component-meta";
3
+ import type {
4
+ PresetStyle,
5
+ WsComponentMeta,
6
+ WsComponentPropsMeta,
7
+ } from "./component-meta";
5
8
  import type { defaultTag } from "./superscript";
6
9
  import { props } from "./__generated__/superscript.props";
7
10
 
8
11
  const presetStyle = {
9
12
  sup,
10
- } as const satisfies Record<typeof defaultTag, Style>;
13
+ } satisfies PresetStyle<typeof defaultTag>;
11
14
 
12
15
  export const meta: WsComponentMeta = {
13
16
  type: "rich-text-child",
@@ -1,21 +1,22 @@
1
1
  import { TextBlockIcon } from "@webstudio-is/icons";
2
- import type { WsComponentMeta, WsComponentPropsMeta } from "./component-meta";
2
+ import type {
3
+ PresetStyle,
4
+ WsComponentMeta,
5
+ WsComponentPropsMeta,
6
+ } from "./component-meta";
3
7
  import { props } from "./__generated__/text-block.props";
4
8
  import type { defaultTag } from "./text-block";
5
- import type { Style } from "@webstudio-is/css-data";
6
9
  import { div } from "../css/normalize";
7
10
 
8
11
  const presetStyle = {
9
- div: {
12
+ div: [
10
13
  ...div,
11
-
12
- minHeight: {
13
- type: "unit",
14
- unit: "em",
15
- value: 1,
14
+ {
15
+ property: "minHeight",
16
+ value: { type: "unit", unit: "em", value: 1 },
16
17
  },
17
- },
18
- } as const satisfies Record<typeof defaultTag, Style>;
18
+ ],
19
+ } satisfies PresetStyle<typeof defaultTag>;
19
20
 
20
21
  export const meta: WsComponentMeta = {
21
22
  category: "typography",
@@ -23,7 +24,7 @@ export const meta: WsComponentMeta = {
23
24
  label: "Text Block",
24
25
  Icon: TextBlockIcon,
25
26
  presetStyle,
26
- children: ["Block of text you can edit"],
27
+ children: [{ type: "text", value: "Block of text you can edit" }],
27
28
  };
28
29
 
29
30
  export const propsMeta: WsComponentPropsMeta = {
package/src/css/css.ts CHANGED
@@ -3,9 +3,9 @@ import type { Asset, Assets } from "@webstudio-is/asset-uploader";
3
3
  import type { Build } from "@webstudio-is/project-build";
4
4
  import { getComponentNames } from "../components/components-utils";
5
5
  import { getComponentMeta } from "../components";
6
- import { componentAttribute, idAttribute } from "../tree";
6
+ import { idAttribute } from "../tree";
7
7
  import { addGlobalRules } from "./global-rules";
8
- import { getStyleRules } from "./style-rules";
8
+ import { getPresetStyleRules, getStyleRules } from "./style-rules";
9
9
 
10
10
  type Data = {
11
11
  assets: Asset[];
@@ -64,15 +64,12 @@ export const generateCssText = (data: Data, options: CssOptions) => {
64
64
  for (const component of getComponentNames()) {
65
65
  const meta = getComponentMeta(component);
66
66
  const presetStyle = meta?.presetStyle;
67
- if (presetStyle !== undefined) {
68
- for (const [tag, style] of Object.entries(presetStyle)) {
69
- engine.addStyleRule(
70
- `${tag}:where([${componentAttribute}=${component}])`,
71
- {
72
- style,
73
- }
74
- );
75
- }
67
+ if (presetStyle === undefined) {
68
+ continue;
69
+ }
70
+ const rules = getPresetStyleRules(component, presetStyle);
71
+ for (const [selector, style] of rules) {
72
+ engine.addStyleRule(selector, { style });
76
73
  }
77
74
  }
78
75