@webstudio-is/react-sdk 0.61.0 → 0.63.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 (251) 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 +2 -0
  27. package/lib/cjs/components/body.ws.js +2 -0
  28. package/lib/cjs/components/bold.ws.js +2 -0
  29. package/lib/cjs/components/box.ws.js +2 -0
  30. package/lib/cjs/components/button.ws.js +8 -2
  31. package/lib/cjs/components/checkbox-field.js +29 -0
  32. package/lib/cjs/components/checkbox-field.ws.js +55 -0
  33. package/lib/cjs/components/checkbox.js +29 -0
  34. package/lib/cjs/components/checkbox.ws.js +57 -0
  35. package/lib/cjs/components/code.ws.js +2 -0
  36. package/lib/cjs/components/component-meta.js +13 -1
  37. package/lib/cjs/components/components-utils.js +9 -1
  38. package/lib/cjs/components/components.js +17 -1
  39. package/lib/cjs/components/error-message.js +29 -0
  40. package/lib/cjs/components/error-message.ws.js +40 -0
  41. package/lib/cjs/components/form.js +1 -1
  42. package/lib/cjs/components/form.ws.js +27 -6
  43. package/lib/cjs/components/heading.ws.js +2 -0
  44. package/lib/cjs/components/image.ws.js +2 -0
  45. package/lib/cjs/components/index.js +43 -2
  46. package/lib/cjs/components/input.ws.js +17 -3
  47. package/lib/cjs/components/italic.ws.js +2 -0
  48. package/lib/cjs/components/label.js +29 -0
  49. package/lib/cjs/components/label.ws.js +56 -0
  50. package/lib/cjs/components/link-block.ws.js +1 -1
  51. package/lib/cjs/components/link.ws.js +13 -1
  52. package/lib/cjs/components/list-item.ws.js +3 -0
  53. package/lib/cjs/components/list.ws.js +2 -0
  54. package/lib/cjs/components/paragraph.ws.js +2 -0
  55. package/lib/cjs/components/radio-button-field.js +29 -0
  56. package/lib/cjs/components/radio-button-field.ws.js +55 -0
  57. package/lib/cjs/components/radio-button.js +29 -0
  58. package/lib/cjs/components/radio-button.ws.js +57 -0
  59. package/lib/cjs/components/separator.ws.js +2 -0
  60. package/lib/cjs/components/span.ws.js +2 -0
  61. package/lib/cjs/components/subscript.ws.js +2 -0
  62. package/lib/cjs/components/success-message.js +29 -0
  63. package/lib/cjs/components/success-message.ws.js +40 -0
  64. package/lib/cjs/components/superscript.ws.js +2 -0
  65. package/lib/cjs/components/text-block.ws.js +2 -0
  66. package/lib/cjs/components/textarea.js +29 -0
  67. package/lib/cjs/components/textarea.ws.js +58 -0
  68. package/lib/cjs/css/normalize.js +3 -1
  69. package/lib/cjs/css/presets.js +19 -1
  70. package/lib/cjs/index.js +2 -1
  71. package/lib/components/__generated__/checkbox-field.props.js +399 -0
  72. package/lib/components/__generated__/checkbox.props.js +439 -0
  73. package/lib/components/__generated__/error-message.props.js +398 -0
  74. package/lib/components/__generated__/input.props.js +8 -3
  75. package/lib/components/__generated__/label.props.js +400 -0
  76. package/lib/components/__generated__/radio-button-field.props.js +399 -0
  77. package/lib/components/__generated__/radio-button.props.js +439 -0
  78. package/lib/components/__generated__/success-message.props.js +398 -0
  79. package/lib/components/__generated__/textarea.props.js +412 -0
  80. package/lib/components/blockquote.ws.js +4 -0
  81. package/lib/components/body.ws.js +4 -0
  82. package/lib/components/bold.ws.js +4 -0
  83. package/lib/components/box.ws.js +4 -0
  84. package/lib/components/button.ws.js +10 -2
  85. package/lib/components/checkbox-field.js +9 -0
  86. package/lib/components/checkbox-field.ws.js +37 -0
  87. package/lib/components/checkbox.js +9 -0
  88. package/lib/components/checkbox.ws.js +39 -0
  89. package/lib/components/code.ws.js +4 -0
  90. package/lib/components/component-meta.js +13 -1
  91. package/lib/components/components-utils.js +9 -1
  92. package/lib/components/components.js +17 -1
  93. package/lib/components/error-message.js +9 -0
  94. package/lib/components/error-message.ws.js +20 -0
  95. package/lib/components/form.js +1 -1
  96. package/lib/components/form.ws.js +29 -6
  97. package/lib/components/heading.ws.js +4 -0
  98. package/lib/components/image.ws.js +4 -0
  99. package/lib/components/index.js +43 -2
  100. package/lib/components/input.ws.js +19 -3
  101. package/lib/components/italic.ws.js +4 -0
  102. package/lib/components/label.js +9 -0
  103. package/lib/components/label.ws.js +38 -0
  104. package/lib/components/link-block.ws.js +2 -2
  105. package/lib/components/link.ws.js +15 -1
  106. package/lib/components/list-item.ws.js +5 -0
  107. package/lib/components/list.ws.js +4 -0
  108. package/lib/components/paragraph.ws.js +4 -0
  109. package/lib/components/radio-button-field.js +9 -0
  110. package/lib/components/radio-button-field.ws.js +37 -0
  111. package/lib/components/radio-button.js +9 -0
  112. package/lib/components/radio-button.ws.js +39 -0
  113. package/lib/components/separator.ws.js +4 -0
  114. package/lib/components/span.ws.js +4 -0
  115. package/lib/components/subscript.ws.js +4 -0
  116. package/lib/components/success-message.js +9 -0
  117. package/lib/components/success-message.ws.js +20 -0
  118. package/lib/components/superscript.ws.js +4 -0
  119. package/lib/components/text-block.ws.js +4 -0
  120. package/lib/components/textarea.js +9 -0
  121. package/lib/components/textarea.ws.js +40 -0
  122. package/lib/css/normalize.js +4 -2
  123. package/lib/css/presets.js +19 -1
  124. package/lib/index.js +4 -2
  125. package/lib/types/app/custom-components/__generated__/form.props.d.ts +2 -0
  126. package/lib/types/app/custom-components/__generated__/image.props.d.ts +2 -0
  127. package/lib/types/app/custom-components/__generated__/link-block.props.d.ts +2 -0
  128. package/lib/types/app/custom-components/__generated__/link.props.d.ts +2 -0
  129. package/lib/types/app/custom-components/__generated__/rich-text-link.props.d.ts +2 -0
  130. package/lib/types/app/custom-components/form.d.ts +5 -0
  131. package/lib/types/app/custom-components/form.ws.d.ts +3 -0
  132. package/lib/types/app/custom-components/index.d.ts +6 -1
  133. package/lib/types/components/__generated__/checkbox-field.props.d.ts +2 -0
  134. package/lib/types/components/__generated__/checkbox.props.d.ts +2 -0
  135. package/lib/types/components/__generated__/error-message.props.d.ts +2 -0
  136. package/lib/types/components/__generated__/label.props.d.ts +2 -0
  137. package/lib/types/components/__generated__/radio-button-field.props.d.ts +2 -0
  138. package/lib/types/components/__generated__/radio-button.props.d.ts +2 -0
  139. package/lib/types/components/__generated__/success-message.props.d.ts +2 -0
  140. package/lib/types/components/__generated__/textarea.props.d.ts +2 -0
  141. package/lib/types/components/blockquote.ws.d.ts +1 -1
  142. package/lib/types/components/body.ws.d.ts +1 -1
  143. package/lib/types/components/bold.ws.d.ts +1 -1
  144. package/lib/types/components/box.ws.d.ts +1 -1
  145. package/lib/types/components/button.ws.d.ts +1 -1
  146. package/lib/types/components/checkbox-field.d.ts +3 -0
  147. package/lib/types/components/checkbox-field.ws.d.ts +3 -0
  148. package/lib/types/components/checkbox.d.ts +3 -0
  149. package/lib/types/components/checkbox.ws.d.ts +3 -0
  150. package/lib/types/components/code.ws.d.ts +1 -1
  151. package/lib/types/components/component-meta.d.ts +17 -4
  152. package/lib/types/components/components-utils.d.ts +5 -20
  153. package/lib/types/components/components.d.ts +8 -0
  154. package/lib/types/components/error-message.d.ts +3 -0
  155. package/lib/types/components/error-message.ws.d.ts +3 -0
  156. package/lib/types/components/form.ws.d.ts +1 -1
  157. package/lib/types/components/heading.ws.d.ts +1 -1
  158. package/lib/types/components/image.ws.d.ts +1 -1
  159. package/lib/types/components/index.d.ts +1 -0
  160. package/lib/types/components/input.d.ts +3 -1
  161. package/lib/types/components/input.stories.d.ts +6 -2
  162. package/lib/types/components/input.ws.d.ts +1 -1
  163. package/lib/types/components/italic.ws.d.ts +1 -1
  164. package/lib/types/components/label.d.ts +3 -0
  165. package/lib/types/components/label.ws.d.ts +3 -0
  166. package/lib/types/components/link.ws.d.ts +1 -1
  167. package/lib/types/components/list-item.ws.d.ts +1 -1
  168. package/lib/types/components/list.ws.d.ts +1 -1
  169. package/lib/types/components/paragraph.ws.d.ts +1 -1
  170. package/lib/types/components/radio-button-field.d.ts +3 -0
  171. package/lib/types/components/radio-button-field.ws.d.ts +3 -0
  172. package/lib/types/components/radio-button.d.ts +3 -0
  173. package/lib/types/components/radio-button.ws.d.ts +3 -0
  174. package/lib/types/components/separator.ws.d.ts +1 -1
  175. package/lib/types/components/span.ws.d.ts +1 -1
  176. package/lib/types/components/subscript.ws.d.ts +1 -1
  177. package/lib/types/components/success-message.d.ts +3 -0
  178. package/lib/types/components/success-message.ws.d.ts +3 -0
  179. package/lib/types/components/superscript.ws.d.ts +1 -1
  180. package/lib/types/components/text-block.ws.d.ts +1 -1
  181. package/lib/types/components/textarea.d.ts +3 -0
  182. package/lib/types/components/textarea.ws.d.ts +3 -0
  183. package/lib/types/css/normalize.d.ts +239 -46
  184. package/lib/types/css/presets.d.ts +3 -2
  185. package/lib/types/css/style-rules.d.ts +1 -1
  186. package/lib/types/embed-template.d.ts +4 -4
  187. package/lib/types/index.d.ts +1 -1
  188. package/package.json +12 -12
  189. package/src/app/custom-components/__generated__/form.props.ts +457 -0
  190. package/src/app/custom-components/__generated__/image.props.ts +487 -0
  191. package/src/app/custom-components/__generated__/link-block.props.ts +477 -0
  192. package/src/app/custom-components/__generated__/link.props.ts +477 -0
  193. package/src/app/custom-components/__generated__/rich-text-link.props.ts +477 -0
  194. package/src/app/custom-components/form.tsx +94 -0
  195. package/src/app/custom-components/form.ws.tsx +86 -0
  196. package/src/app/custom-components/index.ts +9 -4
  197. package/src/components/__generated__/checkbox-field.props.ts +444 -0
  198. package/src/components/__generated__/checkbox.props.ts +484 -0
  199. package/src/components/__generated__/error-message.props.ts +443 -0
  200. package/src/components/__generated__/input.props.ts +8 -3
  201. package/src/components/__generated__/label.props.ts +445 -0
  202. package/src/components/__generated__/radio-button-field.props.ts +444 -0
  203. package/src/components/__generated__/radio-button.props.ts +484 -0
  204. package/src/components/__generated__/success-message.props.ts +443 -0
  205. package/src/components/__generated__/textarea.props.ts +457 -0
  206. package/src/components/blockquote.ws.tsx +6 -4
  207. package/src/components/body.ws.tsx +6 -4
  208. package/src/components/bold.ws.tsx +6 -4
  209. package/src/components/box.ws.ts +6 -4
  210. package/src/components/button.ws.tsx +11 -5
  211. package/src/components/checkbox-field.tsx +10 -0
  212. package/src/components/checkbox-field.ws.tsx +40 -0
  213. package/src/components/checkbox.tsx +13 -0
  214. package/src/components/checkbox.ws.tsx +42 -0
  215. package/src/components/code.ws.tsx +6 -4
  216. package/src/components/component-meta.ts +12 -0
  217. package/src/components/components-utils.ts +16 -10
  218. package/src/components/components.ts +8 -0
  219. package/src/components/error-message.tsx +10 -0
  220. package/src/components/error-message.ws.tsx +24 -0
  221. package/src/components/form.tsx +5 -1
  222. package/src/components/form.ws.tsx +30 -9
  223. package/src/components/heading.ws.tsx +6 -4
  224. package/src/components/image.ws.tsx +6 -4
  225. package/src/components/index.ts +47 -0
  226. package/src/components/input.tsx +3 -1
  227. package/src/components/input.ws.tsx +19 -5
  228. package/src/components/italic.ws.tsx +6 -4
  229. package/src/components/label.tsx +10 -0
  230. package/src/components/label.ws.tsx +41 -0
  231. package/src/components/link-block.ws.tsx +2 -2
  232. package/src/components/link.ws.tsx +17 -5
  233. package/src/components/list-item.ws.tsx +7 -4
  234. package/src/components/list.ws.tsx +6 -4
  235. package/src/components/paragraph.ws.tsx +6 -4
  236. package/src/components/radio-button-field.tsx +10 -0
  237. package/src/components/radio-button-field.ws.tsx +40 -0
  238. package/src/components/radio-button.tsx +13 -0
  239. package/src/components/radio-button.ws.tsx +42 -0
  240. package/src/components/separator.ws.tsx +6 -4
  241. package/src/components/span.ws.tsx +6 -4
  242. package/src/components/subscript.ws.tsx +6 -4
  243. package/src/components/success-message.tsx +10 -0
  244. package/src/components/success-message.ws.tsx +24 -0
  245. package/src/components/superscript.ws.tsx +6 -4
  246. package/src/components/text-block.ws.tsx +6 -4
  247. package/src/components/textarea.tsx +13 -0
  248. package/src/components/textarea.ws.tsx +43 -0
  249. package/src/css/normalize.ts +21 -18
  250. package/src/css/presets.ts +20 -2
  251. package/src/index.ts +1 -0
@@ -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,42 @@
1
+ import { RadioCheckedIcon } from "@webstudio-is/icons";
2
+ import {
3
+ type WsComponentMeta,
4
+ type WsComponentPropsMeta,
5
+ type PresetStyle,
6
+ defaultStates,
7
+ } from "./component-meta";
8
+ import type { defaultTag } from "./radio-button";
9
+ import { input } from "../css/normalize";
10
+ import { props } from "./__generated__/radio-button.props";
11
+
12
+ const presetStyle = {
13
+ input: [
14
+ ...input,
15
+ {
16
+ property: "marginRight",
17
+ value: { type: "unit", unit: "em", value: 0.5 },
18
+ },
19
+ ],
20
+ } satisfies PresetStyle<typeof defaultTag>;
21
+
22
+ export const meta: WsComponentMeta = {
23
+ type: "control",
24
+ label: "Radio Button",
25
+ Icon: RadioCheckedIcon,
26
+ presetStyle,
27
+ states: [
28
+ ...defaultStates,
29
+ { selector: ":checked", label: "Checked" },
30
+ { selector: ":required", label: "Required" },
31
+ { selector: ":optional", label: "Optional" },
32
+ { selector: ":disabled", label: "Disabled" },
33
+ { selector: ":enabled", label: "Enabled" },
34
+ { selector: ":read-only", label: "Read Only" },
35
+ { selector: ":read-write", label: "Read Write" },
36
+ ],
37
+ };
38
+
39
+ export const propsMeta: WsComponentPropsMeta = {
40
+ props,
41
+ initialProps: ["name"],
42
+ };
@@ -1,8 +1,9 @@
1
1
  import { DashIcon } from "@webstudio-is/icons";
2
- import type {
3
- PresetStyle,
4
- WsComponentMeta,
5
- WsComponentPropsMeta,
2
+ import {
3
+ defaultStates,
4
+ type PresetStyle,
5
+ type WsComponentMeta,
6
+ type WsComponentPropsMeta,
6
7
  } from "./component-meta";
7
8
  import { props } from "./__generated__/separator.props";
8
9
  import type { defaultTag } from "./separator";
@@ -44,6 +45,7 @@ export const meta: WsComponentMeta = {
44
45
  type: "embed",
45
46
  label: "Separator",
46
47
  Icon: DashIcon,
48
+ states: defaultStates,
47
49
  presetStyle,
48
50
  children: [],
49
51
  };
@@ -1,9 +1,10 @@
1
1
  import { PaintBrushIcon } from "@webstudio-is/icons";
2
2
  import { span } from "../css/normalize";
3
- import type {
4
- PresetStyle,
5
- WsComponentMeta,
6
- WsComponentPropsMeta,
3
+ import {
4
+ defaultStates,
5
+ type PresetStyle,
6
+ type WsComponentMeta,
7
+ type WsComponentPropsMeta,
7
8
  } from "./component-meta";
8
9
  import type { defaultTag } from "./span";
9
10
  import { props } from "./__generated__/span.props";
@@ -16,6 +17,7 @@ export const meta: WsComponentMeta = {
16
17
  type: "rich-text-child",
17
18
  label: "Styled Text",
18
19
  Icon: PaintBrushIcon,
20
+ states: defaultStates,
19
21
  presetStyle,
20
22
  };
21
23
 
@@ -1,9 +1,10 @@
1
1
  import { SubscriptIcon } from "@webstudio-is/icons";
2
2
  import { sub } from "../css/normalize";
3
- import type {
4
- PresetStyle,
5
- WsComponentMeta,
6
- WsComponentPropsMeta,
3
+ import {
4
+ defaultStates,
5
+ type PresetStyle,
6
+ type WsComponentMeta,
7
+ type WsComponentPropsMeta,
7
8
  } from "./component-meta";
8
9
  import type { defaultTag } from "./subscript";
9
10
  import { props } from "./__generated__/subscript.props";
@@ -16,6 +17,7 @@ export const meta: WsComponentMeta = {
16
17
  type: "rich-text-child",
17
18
  label: "Subscript Text",
18
19
  Icon: SubscriptIcon,
20
+ states: defaultStates,
19
21
  presetStyle,
20
22
  };
21
23
 
@@ -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,9 +1,10 @@
1
1
  import { SuperscriptIcon } from "@webstudio-is/icons";
2
2
  import { sup } from "../css/normalize";
3
- import type {
4
- PresetStyle,
5
- WsComponentMeta,
6
- WsComponentPropsMeta,
3
+ import {
4
+ defaultStates,
5
+ type PresetStyle,
6
+ type WsComponentMeta,
7
+ type WsComponentPropsMeta,
7
8
  } from "./component-meta";
8
9
  import type { defaultTag } from "./superscript";
9
10
  import { props } from "./__generated__/superscript.props";
@@ -16,6 +17,7 @@ export const meta: WsComponentMeta = {
16
17
  type: "rich-text-child",
17
18
  label: "Superscript Text",
18
19
  Icon: SuperscriptIcon,
20
+ states: defaultStates,
19
21
  presetStyle,
20
22
  };
21
23
 
@@ -1,8 +1,9 @@
1
1
  import { TextBlockIcon } from "@webstudio-is/icons";
2
- import type {
3
- PresetStyle,
4
- WsComponentMeta,
5
- WsComponentPropsMeta,
2
+ import {
3
+ defaultStates,
4
+ type PresetStyle,
5
+ type WsComponentMeta,
6
+ type WsComponentPropsMeta,
6
7
  } from "./component-meta";
7
8
  import { props } from "./__generated__/text-block.props";
8
9
  import type { defaultTag } from "./text-block";
@@ -23,6 +24,7 @@ export const meta: WsComponentMeta = {
23
24
  type: "rich-text",
24
25
  label: "Text Block",
25
26
  Icon: TextBlockIcon,
27
+ states: defaultStates,
26
28
  presetStyle,
27
29
  children: [{ type: "text", value: "Block of text you can edit" }],
28
30
  };
@@ -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";
@@ -0,0 +1,43 @@
1
+ import { FormTextAreaIcon } from "@webstudio-is/icons";
2
+ import { textarea } from "../css/normalize";
3
+ import {
4
+ type WsComponentMeta,
5
+ type WsComponentPropsMeta,
6
+ type PresetStyle,
7
+ defaultStates,
8
+ } from "./component-meta";
9
+ import type { defaultTag } from "./textarea";
10
+ import { props } from "./__generated__/textarea.props";
11
+
12
+ const presetStyle = {
13
+ textarea: [
14
+ ...textarea,
15
+ // resize doesn't work well while on canvas
16
+ { property: "resize", value: { type: "keyword", value: "none" } },
17
+ ],
18
+ } satisfies PresetStyle<typeof defaultTag>;
19
+
20
+ export const meta: WsComponentMeta = {
21
+ category: "forms",
22
+ type: "control",
23
+ label: "Text Area",
24
+ Icon: FormTextAreaIcon,
25
+ presetStyle,
26
+ states: [
27
+ ...defaultStates,
28
+ { selector: "::placeholder", label: "Placeholder" },
29
+ { selector: ":valid", label: "Valid" },
30
+ { selector: ":invalid", label: "Invalid" },
31
+ { selector: ":required", label: "Required" },
32
+ { selector: ":optional", label: "Optional" },
33
+ { selector: ":disabled", label: "Disabled" },
34
+ { selector: ":enabled", label: "Enabled" },
35
+ { selector: ":read-only", label: "Read Only" },
36
+ { selector: ":read-write", label: "Read Write" },
37
+ ],
38
+ };
39
+
40
+ export const propsMeta: WsComponentPropsMeta = {
41
+ props,
42
+ initialProps: ["name", "placeholder", "required", "autoFocus"],
43
+ };
@@ -16,9 +16,11 @@
16
16
  */
17
17
 
18
18
  // webstudio custom opinionated presets
19
- import { borders } from "./presets";
19
+ import { borders, linkColors } from "./presets";
20
20
  import type { EmbedTemplateStyleDecl } from "../embed-template";
21
21
 
22
+ export type Styles = EmbedTemplateStyleDecl[];
23
+
22
24
  /**
23
25
  Use a better box model (opinionated).
24
26
  */
@@ -35,7 +37,7 @@ const boxSizing = {
35
37
  * box-sizing: border-box;
36
38
  }
37
39
  */
38
- const baseStyle = [boxSizing, ...borders] satisfies EmbedTemplateStyleDecl[];
40
+ const baseStyle = [boxSizing, ...borders] satisfies Styles;
39
41
 
40
42
  export const div = baseStyle;
41
43
  export const address = baseStyle;
@@ -48,6 +50,7 @@ export const main = baseStyle;
48
50
  export const nav = baseStyle;
49
51
  export const section = baseStyle;
50
52
  export const form = baseStyle;
53
+ export const label = baseStyle;
51
54
 
52
55
  export const h1 = baseStyle;
53
56
  export const h2 = baseStyle;
@@ -60,7 +63,7 @@ export const i = baseStyle;
60
63
 
61
64
  export const img = baseStyle;
62
65
 
63
- export const a = baseStyle;
66
+ export const a = [boxSizing, ...borders, ...linkColors];
64
67
  export const li = baseStyle;
65
68
  export const ul = baseStyle;
66
69
  export const ol = baseStyle;
@@ -92,7 +95,7 @@ export const html = [
92
95
  },
93
96
  boxSizing,
94
97
  ...borders,
95
- ] satisfies EmbedTemplateStyleDecl[];
98
+ ] satisfies Styles;
96
99
 
97
100
  /**
98
101
  1. Remove the margin in all browsers.
@@ -126,7 +129,7 @@ export const body = [
126
129
  },
127
130
  boxSizing,
128
131
  ...borders,
129
- ] satisfies EmbedTemplateStyleDecl[];
132
+ ] satisfies Styles;
130
133
 
131
134
  /**
132
135
  1. Add the correct height in Firefox.
@@ -145,7 +148,7 @@ export const hr = [
145
148
  },
146
149
  boxSizing,
147
150
  ...borders,
148
- ] satisfies EmbedTemplateStyleDecl[];
151
+ ] satisfies Styles;
149
152
 
150
153
  /**
151
154
  Add the correct text decoration in Chrome, Edge, and Safari.
@@ -167,7 +170,7 @@ export const b = [
167
170
  },
168
171
  boxSizing,
169
172
  ...borders,
170
- ] satisfies EmbedTemplateStyleDecl[];
173
+ ] satisfies Styles;
171
174
  export const strong = b;
172
175
 
173
176
  /**
@@ -190,7 +193,7 @@ export const code = [
190
193
  },
191
194
  boxSizing,
192
195
  ...borders,
193
- ] satisfies EmbedTemplateStyleDecl[];
196
+ ] satisfies Styles;
194
197
 
195
198
  export const kbd = code;
196
199
  export const samp = code;
@@ -207,7 +210,7 @@ export const small = [
207
210
  },
208
211
  boxSizing,
209
212
  ...borders,
210
- ] satisfies EmbedTemplateStyleDecl[];
213
+ ] satisfies Styles;
211
214
 
212
215
  /**
213
216
  Prevent 'sub' and 'sup' elements from affecting the line height in all browsers.
@@ -232,7 +235,7 @@ const subSupBase = [
232
235
  },
233
236
  boxSizing,
234
237
  ...borders,
235
- ] satisfies EmbedTemplateStyleDecl[];
238
+ ] satisfies Styles;
236
239
 
237
240
  export const sub = [
238
241
  ...subSupBase,
@@ -240,7 +243,7 @@ export const sub = [
240
243
  property: "bottom",
241
244
  value: { type: "unit", value: -0.25, unit: "em" },
242
245
  },
243
- ] satisfies EmbedTemplateStyleDecl[];
246
+ ] satisfies Styles;
244
247
 
245
248
  export const sup = [
246
249
  ...subSupBase,
@@ -248,7 +251,7 @@ export const sup = [
248
251
  property: "top",
249
252
  value: { type: "unit", value: -0.5, unit: "em" },
250
253
  },
251
- ] satisfies EmbedTemplateStyleDecl[];
254
+ ] satisfies Styles;
252
255
 
253
256
  /*
254
257
  Tabular data
@@ -285,7 +288,7 @@ export const table = [
285
288
  value: { type: "keyword", value: "inherit" },
286
289
  },
287
290
  boxSizing,
288
- ] satisfies EmbedTemplateStyleDecl[];
291
+ ] satisfies Styles;
289
292
 
290
293
  /*
291
294
  Forms
@@ -330,7 +333,7 @@ const buttonBase = [
330
333
  },
331
334
  boxSizing,
332
335
  ...borders,
333
- ] satisfies EmbedTemplateStyleDecl[];
336
+ ] satisfies Styles;
334
337
 
335
338
  export const input = buttonBase;
336
339
  export const optgroup = buttonBase;
@@ -345,7 +348,7 @@ export const button = [
345
348
  property: "textTransform",
346
349
  value: { type: "keyword", value: "none" },
347
350
  },
348
- ] satisfies EmbedTemplateStyleDecl[];
351
+ ] satisfies Styles;
349
352
 
350
353
  export const select = button;
351
354
 
@@ -417,7 +420,7 @@ export const legend = [
417
420
  },
418
421
  boxSizing,
419
422
  ...borders,
420
- ] satisfies EmbedTemplateStyleDecl[];
423
+ ] satisfies Styles;
421
424
 
422
425
  /**
423
426
  Add the correct vertical alignment in Chrome and Firefox.
@@ -430,7 +433,7 @@ export const progress = [
430
433
  },
431
434
  boxSizing,
432
435
  ...borders,
433
- ] satisfies EmbedTemplateStyleDecl[];
436
+ ] satisfies Styles;
434
437
 
435
438
  /**
436
439
  Correct the cursor style of increment and decrement buttons in Safari.
@@ -493,4 +496,4 @@ export const summary = [
493
496
  },
494
497
  boxSizing,
495
498
  ...borders,
496
- ] satisfies EmbedTemplateStyleDecl[];
499
+ ] satisfies Styles;
@@ -1,6 +1,6 @@
1
- import type { EmbedTemplateStyleDecl } from "../embed-template";
1
+ import type { Styles } from "./normalize";
2
2
 
3
- export const borders: EmbedTemplateStyleDecl[] = [
3
+ export const borders: Styles = [
4
4
  {
5
5
  property: "borderTopWidth",
6
6
  value: { type: "unit", value: 1, unit: "px" },
@@ -18,3 +18,21 @@ export const borders: EmbedTemplateStyleDecl[] = [
18
18
  value: { type: "unit", value: 1, unit: "px" },
19
19
  },
20
20
  ];
21
+
22
+ export const linkColors: Styles = [
23
+ {
24
+ property: "color",
25
+ value: { type: "rgb", r: 0, g: 0, b: 238, alpha: 1 },
26
+ },
27
+ {
28
+ state: ":active",
29
+ property: "color",
30
+ // chrome and safari use rgb(255, 0, 0)
31
+ value: { type: "rgb", r: 238, g: 0, b: 0, alpha: 1 },
32
+ },
33
+ {
34
+ state: ":visited",
35
+ property: "color",
36
+ value: { type: "rgb", r: 85, g: 26, b: 139, alpha: 1 },
37
+ },
38
+ ];
package/src/index.ts CHANGED
@@ -15,5 +15,6 @@ export {
15
15
  type WsComponentMeta,
16
16
  type ComponentState,
17
17
  componentCategories,
18
+ stateCategories,
18
19
  } from "./components/component-meta";
19
20
  export * from "./embed-template";