@webstudio-is/react-sdk 0.60.0 → 0.62.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 (233) hide show
  1. package/lib/app/custom-components/__generated__/form.props.js +412 -0
  2. package/lib/app/custom-components/__generated__/image.props.js +442 -0
  3. package/lib/app/custom-components/__generated__/link-block.props.js +432 -0
  4. package/lib/app/custom-components/__generated__/link.props.js +432 -0
  5. package/lib/app/custom-components/__generated__/rich-text-link.props.js +432 -0
  6. package/lib/app/custom-components/form.js +54 -0
  7. package/lib/app/custom-components/form.ws.js +81 -0
  8. package/lib/app/custom-components/index.js +10 -4
  9. package/lib/cjs/app/custom-components/__generated__/form.props.js +432 -0
  10. package/lib/cjs/app/custom-components/__generated__/image.props.js +462 -0
  11. package/lib/cjs/app/custom-components/__generated__/link-block.props.js +452 -0
  12. package/lib/cjs/app/custom-components/__generated__/link.props.js +452 -0
  13. package/lib/cjs/app/custom-components/__generated__/rich-text-link.props.js +452 -0
  14. package/lib/cjs/app/custom-components/form.js +70 -0
  15. package/lib/cjs/app/custom-components/form.ws.js +101 -0
  16. package/lib/cjs/app/custom-components/index.js +12 -6
  17. package/lib/cjs/components/__generated__/checkbox-field.props.js +419 -0
  18. package/lib/cjs/components/__generated__/checkbox.props.js +459 -0
  19. package/lib/cjs/components/__generated__/error-message.props.js +418 -0
  20. package/lib/cjs/components/__generated__/input.props.js +8 -3
  21. package/lib/cjs/components/__generated__/label.props.js +420 -0
  22. package/lib/cjs/components/__generated__/radio-button-field.props.js +419 -0
  23. package/lib/cjs/components/__generated__/radio-button.props.js +459 -0
  24. package/lib/cjs/components/__generated__/success-message.props.js +418 -0
  25. package/lib/cjs/components/__generated__/textarea.props.js +432 -0
  26. package/lib/cjs/components/blockquote.ws.js +36 -48
  27. package/lib/cjs/components/body.ws.js +20 -17
  28. package/lib/cjs/components/button.ws.js +8 -3
  29. package/lib/cjs/components/checkbox-field.js +29 -0
  30. package/lib/cjs/components/checkbox-field.ws.js +53 -0
  31. package/lib/cjs/components/checkbox.js +29 -0
  32. package/lib/cjs/components/checkbox.ws.js +55 -0
  33. package/lib/cjs/components/code.ws.js +20 -28
  34. package/lib/cjs/components/component-meta.js +3 -1
  35. package/lib/cjs/components/components-utils.js +9 -1
  36. package/lib/cjs/components/components.js +17 -1
  37. package/lib/cjs/components/error-message.js +29 -0
  38. package/lib/cjs/components/error-message.ws.js +40 -0
  39. package/lib/cjs/components/form.js +1 -1
  40. package/lib/cjs/components/form.ws.js +35 -9
  41. package/lib/cjs/components/heading.ws.js +1 -1
  42. package/lib/cjs/components/image.ws.js +8 -9
  43. package/lib/cjs/components/index.js +43 -2
  44. package/lib/cjs/components/input.ws.js +15 -3
  45. package/lib/cjs/components/italic.ws.js +5 -5
  46. package/lib/cjs/components/label.js +29 -0
  47. package/lib/cjs/components/label.ws.js +54 -0
  48. package/lib/cjs/components/link-block.ws.js +6 -6
  49. package/lib/cjs/components/link.ws.js +9 -10
  50. package/lib/cjs/components/list-item.ws.js +2 -1
  51. package/lib/cjs/components/list.ws.js +22 -22
  52. package/lib/cjs/components/paragraph.ws.js +1 -1
  53. package/lib/cjs/components/radio-button-field.js +29 -0
  54. package/lib/cjs/components/radio-button-field.ws.js +53 -0
  55. package/lib/cjs/components/radio-button.js +29 -0
  56. package/lib/cjs/components/radio-button.ws.js +55 -0
  57. package/lib/cjs/components/separator.ws.js +20 -20
  58. package/lib/cjs/components/success-message.js +29 -0
  59. package/lib/cjs/components/success-message.ws.js +40 -0
  60. package/lib/cjs/components/text-block.ws.js +6 -7
  61. package/lib/cjs/components/textarea.js +29 -0
  62. package/lib/cjs/components/textarea.ws.js +56 -0
  63. package/lib/cjs/css/css.js +6 -9
  64. package/lib/cjs/css/normalize.js +168 -185
  65. package/lib/cjs/css/presets.js +14 -34
  66. package/lib/cjs/css/style-rules.js +17 -0
  67. package/lib/cjs/embed-template.js +160 -0
  68. package/lib/cjs/index.js +1 -0
  69. package/lib/components/__generated__/checkbox-field.props.js +399 -0
  70. package/lib/components/__generated__/checkbox.props.js +439 -0
  71. package/lib/components/__generated__/error-message.props.js +398 -0
  72. package/lib/components/__generated__/input.props.js +8 -3
  73. package/lib/components/__generated__/label.props.js +400 -0
  74. package/lib/components/__generated__/radio-button-field.props.js +399 -0
  75. package/lib/components/__generated__/radio-button.props.js +439 -0
  76. package/lib/components/__generated__/success-message.props.js +398 -0
  77. package/lib/components/__generated__/textarea.props.js +412 -0
  78. package/lib/components/blockquote.ws.js +36 -48
  79. package/lib/components/body.ws.js +20 -17
  80. package/lib/components/button.ws.js +8 -3
  81. package/lib/components/checkbox-field.js +9 -0
  82. package/lib/components/checkbox-field.ws.js +33 -0
  83. package/lib/components/checkbox.js +9 -0
  84. package/lib/components/checkbox.ws.js +35 -0
  85. package/lib/components/code.ws.js +20 -28
  86. package/lib/components/component-meta.js +3 -1
  87. package/lib/components/components-utils.js +9 -1
  88. package/lib/components/components.js +17 -1
  89. package/lib/components/error-message.js +9 -0
  90. package/lib/components/error-message.ws.js +20 -0
  91. package/lib/components/form.js +1 -1
  92. package/lib/components/form.ws.js +35 -9
  93. package/lib/components/heading.ws.js +1 -1
  94. package/lib/components/image.ws.js +8 -9
  95. package/lib/components/index.js +43 -2
  96. package/lib/components/input.ws.js +15 -3
  97. package/lib/components/italic.ws.js +5 -5
  98. package/lib/components/label.js +9 -0
  99. package/lib/components/label.ws.js +34 -0
  100. package/lib/components/link-block.ws.js +7 -7
  101. package/lib/components/link.ws.js +9 -10
  102. package/lib/components/list-item.ws.js +2 -1
  103. package/lib/components/list.ws.js +22 -22
  104. package/lib/components/paragraph.ws.js +1 -1
  105. package/lib/components/radio-button-field.js +9 -0
  106. package/lib/components/radio-button-field.ws.js +33 -0
  107. package/lib/components/radio-button.js +9 -0
  108. package/lib/components/radio-button.ws.js +35 -0
  109. package/lib/components/separator.ws.js +20 -20
  110. package/lib/components/success-message.js +9 -0
  111. package/lib/components/success-message.ws.js +20 -0
  112. package/lib/components/text-block.ws.js +6 -7
  113. package/lib/components/textarea.js +9 -0
  114. package/lib/components/textarea.ws.js +36 -0
  115. package/lib/css/css.js +8 -11
  116. package/lib/css/normalize.js +168 -185
  117. package/lib/css/presets.js +14 -34
  118. package/lib/css/style-rules.js +17 -0
  119. package/lib/embed-template.js +140 -0
  120. package/lib/index.js +1 -0
  121. package/lib/types/app/custom-components/__generated__/form.props.d.ts +2 -0
  122. package/lib/types/app/custom-components/__generated__/image.props.d.ts +2 -0
  123. package/lib/types/app/custom-components/__generated__/link-block.props.d.ts +2 -0
  124. package/lib/types/app/custom-components/__generated__/link.props.d.ts +2 -0
  125. package/lib/types/app/custom-components/__generated__/rich-text-link.props.d.ts +2 -0
  126. package/lib/types/app/custom-components/form.d.ts +5 -0
  127. package/lib/types/app/custom-components/form.ws.d.ts +3 -0
  128. package/lib/types/app/custom-components/index.d.ts +6 -1
  129. package/lib/types/components/__generated__/checkbox-field.props.d.ts +2 -0
  130. package/lib/types/components/__generated__/checkbox.props.d.ts +2 -0
  131. package/lib/types/components/__generated__/error-message.props.d.ts +2 -0
  132. package/lib/types/components/__generated__/label.props.d.ts +2 -0
  133. package/lib/types/components/__generated__/radio-button-field.props.d.ts +2 -0
  134. package/lib/types/components/__generated__/radio-button.props.d.ts +2 -0
  135. package/lib/types/components/__generated__/success-message.props.d.ts +2 -0
  136. package/lib/types/components/__generated__/textarea.props.d.ts +2 -0
  137. package/lib/types/components/box.stories.d.ts +2 -2
  138. package/lib/types/components/checkbox-field.d.ts +3 -0
  139. package/lib/types/components/checkbox-field.ws.d.ts +3 -0
  140. package/lib/types/components/checkbox.d.ts +3 -0
  141. package/lib/types/components/checkbox.ws.d.ts +3 -0
  142. package/lib/types/components/component-meta.d.ts +23 -5
  143. package/lib/types/components/components-utils.d.ts +5 -20
  144. package/lib/types/components/components.d.ts +8 -0
  145. package/lib/types/components/error-message.d.ts +3 -0
  146. package/lib/types/components/error-message.ws.d.ts +3 -0
  147. package/lib/types/components/index.d.ts +1 -0
  148. package/lib/types/components/input.d.ts +3 -1
  149. package/lib/types/components/input.stories.d.ts +6 -2
  150. package/lib/types/components/label.d.ts +3 -0
  151. package/lib/types/components/label.ws.d.ts +3 -0
  152. package/lib/types/components/radio-button-field.d.ts +3 -0
  153. package/lib/types/components/radio-button-field.ws.d.ts +3 -0
  154. package/lib/types/components/radio-button.d.ts +3 -0
  155. package/lib/types/components/radio-button.ws.d.ts +3 -0
  156. package/lib/types/components/success-message.d.ts +3 -0
  157. package/lib/types/components/success-message.ws.d.ts +3 -0
  158. package/lib/types/components/textarea.d.ts +3 -0
  159. package/lib/types/components/textarea.ws.d.ts +3 -0
  160. package/lib/types/css/normalize.d.ts +8977 -2286
  161. package/lib/types/css/presets.d.ts +2 -38
  162. package/lib/types/css/style-rules.d.ts +11 -9
  163. package/lib/types/embed-template.d.ts +1725 -0
  164. package/lib/types/embed-template.test.d.ts +1 -0
  165. package/lib/types/index.d.ts +1 -0
  166. package/package.json +15 -14
  167. package/src/app/custom-components/__generated__/form.props.ts +457 -0
  168. package/src/app/custom-components/__generated__/image.props.ts +487 -0
  169. package/src/app/custom-components/__generated__/link-block.props.ts +477 -0
  170. package/src/app/custom-components/__generated__/link.props.ts +477 -0
  171. package/src/app/custom-components/__generated__/rich-text-link.props.ts +477 -0
  172. package/src/app/custom-components/form.tsx +94 -0
  173. package/src/app/custom-components/form.ws.tsx +86 -0
  174. package/src/app/custom-components/index.ts +9 -4
  175. package/src/components/__generated__/checkbox-field.props.ts +444 -0
  176. package/src/components/__generated__/checkbox.props.ts +484 -0
  177. package/src/components/__generated__/error-message.props.ts +443 -0
  178. package/src/components/__generated__/input.props.ts +8 -3
  179. package/src/components/__generated__/label.props.ts +445 -0
  180. package/src/components/__generated__/radio-button-field.props.ts +444 -0
  181. package/src/components/__generated__/radio-button.props.ts +484 -0
  182. package/src/components/__generated__/success-message.props.ts +443 -0
  183. package/src/components/__generated__/textarea.props.ts +457 -0
  184. package/src/components/blockquote.ws.tsx +42 -52
  185. package/src/components/body.ws.tsx +26 -23
  186. package/src/components/bold.ws.tsx +6 -3
  187. package/src/components/box.ws.ts +6 -3
  188. package/src/components/button.ws.tsx +13 -5
  189. package/src/components/checkbox-field.tsx +10 -0
  190. package/src/components/checkbox-field.ws.tsx +38 -0
  191. package/src/components/checkbox.tsx +13 -0
  192. package/src/components/checkbox.ws.tsx +40 -0
  193. package/src/components/code.ws.tsx +26 -32
  194. package/src/components/component-meta.ts +6 -3
  195. package/src/components/components-utils.ts +16 -10
  196. package/src/components/components.ts +8 -0
  197. package/src/components/error-message.tsx +10 -0
  198. package/src/components/error-message.ws.tsx +24 -0
  199. package/src/components/form.tsx +5 -1
  200. package/src/components/form.ws.tsx +39 -10
  201. package/src/components/heading.ws.tsx +7 -4
  202. package/src/components/image.ws.tsx +14 -12
  203. package/src/components/index.ts +47 -0
  204. package/src/components/input.tsx +3 -1
  205. package/src/components/input.ws.tsx +19 -4
  206. package/src/components/italic.ws.tsx +11 -8
  207. package/src/components/label.tsx +10 -0
  208. package/src/components/label.ws.tsx +39 -0
  209. package/src/components/link-block.ws.tsx +13 -10
  210. package/src/components/link.ws.tsx +15 -13
  211. package/src/components/list-item.ws.tsx +8 -4
  212. package/src/components/list.ws.tsx +28 -25
  213. package/src/components/paragraph.ws.tsx +7 -4
  214. package/src/components/radio-button-field.tsx +10 -0
  215. package/src/components/radio-button-field.ws.tsx +38 -0
  216. package/src/components/radio-button.tsx +13 -0
  217. package/src/components/radio-button.ws.tsx +40 -0
  218. package/src/components/separator.ws.tsx +26 -25
  219. package/src/components/span.ws.tsx +6 -3
  220. package/src/components/subscript.ws.tsx +6 -3
  221. package/src/components/success-message.tsx +10 -0
  222. package/src/components/success-message.ws.tsx +24 -0
  223. package/src/components/superscript.ws.tsx +6 -3
  224. package/src/components/text-block.ws.tsx +12 -11
  225. package/src/components/textarea.tsx +13 -0
  226. package/src/components/textarea.ws.tsx +41 -0
  227. package/src/css/css.ts +8 -11
  228. package/src/css/normalize.ts +166 -188
  229. package/src/css/presets.ts +15 -37
  230. package/src/css/style-rules.ts +24 -0
  231. package/src/embed-template.test.ts +210 -0
  232. package/src/embed-template.ts +187 -0
  233. package/src/index.ts +1 -0
@@ -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",
@@ -0,0 +1,10 @@
1
+ import { forwardRef, type ElementRef, type ComponentProps } from "react";
2
+
3
+ export const defaultTag = "label";
4
+
5
+ export const Label = forwardRef<
6
+ ElementRef<typeof defaultTag>,
7
+ ComponentProps<typeof defaultTag>
8
+ >((props, ref) => <label {...props} ref={ref} />);
9
+
10
+ Label.displayName = "Label";
@@ -0,0 +1,39 @@
1
+ import { TextBlockIcon } from "@webstudio-is/icons";
2
+ import type {
3
+ WsComponentMeta,
4
+ WsComponentPropsMeta,
5
+ PresetStyle,
6
+ } from "./component-meta";
7
+ import { props } from "./__generated__/label.props";
8
+ import type { defaultTag } from "./label";
9
+ import { label } from "../css/normalize";
10
+
11
+ const presetStyle = {
12
+ label: [
13
+ ...label,
14
+ { property: "display", value: { type: "keyword", value: "block" } },
15
+ ],
16
+ } satisfies PresetStyle<typeof defaultTag>;
17
+
18
+ export const meta: WsComponentMeta = {
19
+ category: "forms",
20
+ type: "rich-text",
21
+ label: "Input Label",
22
+ Icon: TextBlockIcon,
23
+ presetStyle,
24
+ children: [{ type: "text", value: "Form Label" }],
25
+ };
26
+
27
+ export const propsMeta: WsComponentPropsMeta = {
28
+ props: {
29
+ ...props,
30
+ htmlFor: {
31
+ required: false,
32
+ control: "text",
33
+ type: "string",
34
+ rows: 0,
35
+ label: "For",
36
+ },
37
+ },
38
+ initialProps: ["htmlFor"],
39
+ };
@@ -1,26 +1,29 @@
1
- import { BoxLinkIcon } from "@webstudio-is/icons";
2
- import type { WsComponentMeta, WsComponentPropsMeta } from "./component-meta";
1
+ import { LinkBlockIcon } from "@webstudio-is/icons";
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",
21
24
  type: "container",
22
25
  label: "Link Block",
23
- Icon: BoxLinkIcon,
26
+ Icon: LinkBlockIcon,
24
27
  states: linkMeta.states,
25
28
  presetStyle,
26
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,24 @@
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",
18
+ acceptedParents: ["List"],
15
19
  label: "List Item",
16
20
  Icon: ListItemIcon,
17
- children: ["List Item you can edit"],
21
+ children: [{ type: "text", value: "List Item you can edit" }],
18
22
  presetStyle,
19
23
  };
20
24
 
@@ -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
 
@@ -0,0 +1,10 @@
1
+ import { forwardRef, type ElementRef, type ComponentProps } from "react";
2
+
3
+ export const defaultTag = "label";
4
+
5
+ export const RadioButtonField = forwardRef<
6
+ ElementRef<typeof defaultTag>,
7
+ Omit<ComponentProps<typeof defaultTag>, "htmlFor">
8
+ >((props, ref) => <label {...props} ref={ref} />);
9
+
10
+ RadioButtonField.displayName = "RadioButtonField";
@@ -0,0 +1,38 @@
1
+ import { RadioCheckedIcon } from "@webstudio-is/icons";
2
+ import type {
3
+ WsComponentMeta,
4
+ WsComponentPropsMeta,
5
+ PresetStyle,
6
+ } from "./component-meta";
7
+ import { props } from "./__generated__/radio-button-field.props";
8
+ import type { defaultTag } from "./radio-button-field";
9
+ import { label } from "../css/normalize";
10
+
11
+ const presetStyle = {
12
+ label: [
13
+ ...label,
14
+ { property: "display", value: { type: "keyword", value: "flex" } },
15
+ ],
16
+ } satisfies PresetStyle<typeof defaultTag>;
17
+
18
+ export const meta: WsComponentMeta = {
19
+ category: "forms",
20
+ type: "container",
21
+ label: "Radio Button Field",
22
+ Icon: RadioCheckedIcon,
23
+ presetStyle,
24
+ children: [
25
+ { type: "instance", component: "RadioButton", props: [], children: [] },
26
+ {
27
+ type: "instance",
28
+ component: "TextBlock",
29
+ props: [],
30
+ children: [{ type: "text", value: "Radio" }],
31
+ },
32
+ ],
33
+ };
34
+
35
+ export const propsMeta: WsComponentPropsMeta = {
36
+ props,
37
+ initialProps: [],
38
+ };
@@ -0,0 +1,13 @@
1
+ import { forwardRef, type ElementRef, type ComponentProps } from "react";
2
+
3
+ export const defaultTag = "input";
4
+
5
+ export const RadioButton = forwardRef<
6
+ ElementRef<typeof defaultTag>,
7
+ Omit<ComponentProps<typeof defaultTag>, "type">
8
+ // Make sure children are not passed down to an input, because this will result in error.
9
+ >(({ children: _children, ...props }, ref) => (
10
+ <input {...props} type="radio" ref={ref} />
11
+ ));
12
+
13
+ RadioButton.displayName = "RadioButton";
@@ -0,0 +1,40 @@
1
+ import { RadioCheckedIcon } from "@webstudio-is/icons";
2
+ import type {
3
+ WsComponentMeta,
4
+ WsComponentPropsMeta,
5
+ PresetStyle,
6
+ } from "./component-meta";
7
+ import type { defaultTag } from "./radio-button";
8
+ import { input } from "../css/normalize";
9
+ import { props } from "./__generated__/radio-button.props";
10
+
11
+ const presetStyle = {
12
+ input: [
13
+ ...input,
14
+ {
15
+ property: "marginRight",
16
+ value: { type: "unit", unit: "em", value: 0.5 },
17
+ },
18
+ ],
19
+ } satisfies PresetStyle<typeof defaultTag>;
20
+
21
+ export const meta: WsComponentMeta = {
22
+ type: "control",
23
+ label: "Radio Button",
24
+ Icon: RadioCheckedIcon,
25
+ presetStyle,
26
+ states: [
27
+ { selector: ":checked", label: "Checked" },
28
+ { selector: ":required", label: "Required" },
29
+ { selector: ":optional", label: "Optional" },
30
+ { selector: ":disabled", label: "Disabled" },
31
+ { selector: ":enabled", label: "Enabled" },
32
+ { selector: ":read-only", label: "Read Only" },
33
+ { selector: ":read-write", label: "Read Write" },
34
+ ],
35
+ };
36
+
37
+ export const propsMeta: WsComponentPropsMeta = {
38
+ props,
39
+ initialProps: ["name"],
40
+ };
@@ -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",
@@ -0,0 +1,10 @@
1
+ import { forwardRef, type ElementRef, type ComponentProps } from "react";
2
+
3
+ export const defaultTag = "div";
4
+
5
+ export const SuccessMessage = forwardRef<
6
+ ElementRef<typeof defaultTag>,
7
+ ComponentProps<typeof defaultTag>
8
+ >((props, ref) => <div {...props} ref={ref} />);
9
+
10
+ SuccessMessage.displayName = "SuccessMessage";
@@ -0,0 +1,24 @@
1
+ import { BoxIcon } from "@webstudio-is/icons";
2
+ import type {
3
+ WsComponentMeta,
4
+ WsComponentPropsMeta,
5
+ PresetStyle,
6
+ } from "./component-meta";
7
+ import { props } from "./__generated__/success-message.props";
8
+ import { div } from "../css/normalize";
9
+
10
+ const presetStyle = {
11
+ div,
12
+ } satisfies PresetStyle<"div">;
13
+
14
+ export const meta: WsComponentMeta = {
15
+ type: "container",
16
+ label: "Success Message",
17
+ Icon: BoxIcon,
18
+ presetStyle,
19
+ };
20
+
21
+ export const propsMeta: WsComponentPropsMeta = {
22
+ props,
23
+ initialProps: [],
24
+ };
@@ -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 = {
@@ -0,0 +1,13 @@
1
+ import { forwardRef, type ElementRef, type ComponentProps } from "react";
2
+
3
+ export const defaultTag = "textarea";
4
+
5
+ export const Textarea = forwardRef<
6
+ ElementRef<typeof defaultTag>,
7
+ ComponentProps<typeof defaultTag>
8
+ // Make sure children are not passed down to an textarea, because this will result in error.
9
+ >(({ children: _children, ...props }, ref) => (
10
+ <textarea {...props} ref={ref} />
11
+ ));
12
+
13
+ Textarea.displayName = "Textarea";