@webstudio-is/react-sdk 0.62.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 (121) hide show
  1. package/lib/cjs/components/blockquote.ws.js +2 -0
  2. package/lib/cjs/components/body.ws.js +2 -0
  3. package/lib/cjs/components/bold.ws.js +2 -0
  4. package/lib/cjs/components/box.ws.js +2 -0
  5. package/lib/cjs/components/button.ws.js +2 -1
  6. package/lib/cjs/components/checkbox-field.ws.js +2 -0
  7. package/lib/cjs/components/checkbox.ws.js +2 -0
  8. package/lib/cjs/components/code.ws.js +2 -0
  9. package/lib/cjs/components/component-meta.js +12 -1
  10. package/lib/cjs/components/form.ws.js +2 -0
  11. package/lib/cjs/components/heading.ws.js +2 -0
  12. package/lib/cjs/components/image.ws.js +2 -0
  13. package/lib/cjs/components/input.ws.js +2 -0
  14. package/lib/cjs/components/italic.ws.js +2 -0
  15. package/lib/cjs/components/label.ws.js +2 -0
  16. package/lib/cjs/components/link.ws.js +13 -1
  17. package/lib/cjs/components/list-item.ws.js +2 -0
  18. package/lib/cjs/components/list.ws.js +2 -0
  19. package/lib/cjs/components/paragraph.ws.js +2 -0
  20. package/lib/cjs/components/radio-button-field.ws.js +2 -0
  21. package/lib/cjs/components/radio-button.ws.js +2 -0
  22. package/lib/cjs/components/separator.ws.js +2 -0
  23. package/lib/cjs/components/span.ws.js +2 -0
  24. package/lib/cjs/components/subscript.ws.js +2 -0
  25. package/lib/cjs/components/superscript.ws.js +2 -0
  26. package/lib/cjs/components/text-block.ws.js +2 -0
  27. package/lib/cjs/components/textarea.ws.js +2 -0
  28. package/lib/cjs/css/normalize.js +1 -1
  29. package/lib/cjs/css/presets.js +19 -1
  30. package/lib/cjs/index.js +2 -1
  31. package/lib/components/blockquote.ws.js +4 -0
  32. package/lib/components/body.ws.js +4 -0
  33. package/lib/components/bold.ws.js +4 -0
  34. package/lib/components/box.ws.js +4 -0
  35. package/lib/components/button.ws.js +4 -1
  36. package/lib/components/checkbox-field.ws.js +4 -0
  37. package/lib/components/checkbox.ws.js +4 -0
  38. package/lib/components/code.ws.js +4 -0
  39. package/lib/components/component-meta.js +12 -1
  40. package/lib/components/form.ws.js +4 -0
  41. package/lib/components/heading.ws.js +4 -0
  42. package/lib/components/image.ws.js +4 -0
  43. package/lib/components/input.ws.js +4 -0
  44. package/lib/components/italic.ws.js +4 -0
  45. package/lib/components/label.ws.js +4 -0
  46. package/lib/components/link.ws.js +15 -1
  47. package/lib/components/list-item.ws.js +4 -0
  48. package/lib/components/list.ws.js +4 -0
  49. package/lib/components/paragraph.ws.js +4 -0
  50. package/lib/components/radio-button-field.ws.js +4 -0
  51. package/lib/components/radio-button.ws.js +4 -0
  52. package/lib/components/separator.ws.js +4 -0
  53. package/lib/components/span.ws.js +4 -0
  54. package/lib/components/subscript.ws.js +4 -0
  55. package/lib/components/superscript.ws.js +4 -0
  56. package/lib/components/text-block.ws.js +4 -0
  57. package/lib/components/textarea.ws.js +4 -0
  58. package/lib/css/normalize.js +2 -2
  59. package/lib/css/presets.js +19 -1
  60. package/lib/index.js +4 -2
  61. package/lib/types/components/blockquote.ws.d.ts +1 -1
  62. package/lib/types/components/body.ws.d.ts +1 -1
  63. package/lib/types/components/bold.ws.d.ts +1 -1
  64. package/lib/types/components/box.ws.d.ts +1 -1
  65. package/lib/types/components/button.ws.d.ts +1 -1
  66. package/lib/types/components/checkbox-field.ws.d.ts +1 -1
  67. package/lib/types/components/checkbox.ws.d.ts +1 -1
  68. package/lib/types/components/code.ws.d.ts +1 -1
  69. package/lib/types/components/component-meta.d.ts +16 -6
  70. package/lib/types/components/form.ws.d.ts +1 -1
  71. package/lib/types/components/heading.ws.d.ts +1 -1
  72. package/lib/types/components/image.ws.d.ts +1 -1
  73. package/lib/types/components/input.ws.d.ts +1 -1
  74. package/lib/types/components/italic.ws.d.ts +1 -1
  75. package/lib/types/components/label.ws.d.ts +1 -1
  76. package/lib/types/components/link.ws.d.ts +1 -1
  77. package/lib/types/components/list-item.ws.d.ts +1 -1
  78. package/lib/types/components/list.ws.d.ts +1 -1
  79. package/lib/types/components/paragraph.ws.d.ts +1 -1
  80. package/lib/types/components/radio-button-field.ws.d.ts +1 -1
  81. package/lib/types/components/radio-button.ws.d.ts +1 -1
  82. package/lib/types/components/separator.ws.d.ts +1 -1
  83. package/lib/types/components/span.ws.d.ts +1 -1
  84. package/lib/types/components/subscript.ws.d.ts +1 -1
  85. package/lib/types/components/superscript.ws.d.ts +1 -1
  86. package/lib/types/components/text-block.ws.d.ts +1 -1
  87. package/lib/types/components/textarea.ws.d.ts +1 -1
  88. package/lib/types/css/normalize.d.ts +2 -0
  89. package/lib/types/css/presets.d.ts +3 -2
  90. package/lib/types/index.d.ts +1 -1
  91. package/package.json +11 -11
  92. package/src/components/blockquote.ws.tsx +6 -4
  93. package/src/components/body.ws.tsx +6 -4
  94. package/src/components/bold.ws.tsx +6 -4
  95. package/src/components/box.ws.ts +6 -4
  96. package/src/components/button.ws.tsx +6 -5
  97. package/src/components/checkbox-field.ws.tsx +6 -4
  98. package/src/components/checkbox.ws.tsx +6 -4
  99. package/src/components/code.ws.tsx +6 -4
  100. package/src/components/component-meta.ts +11 -0
  101. package/src/components/form.ws.tsx +6 -4
  102. package/src/components/heading.ws.tsx +6 -4
  103. package/src/components/image.ws.tsx +6 -4
  104. package/src/components/input.ws.tsx +6 -4
  105. package/src/components/italic.ws.tsx +6 -4
  106. package/src/components/label.ws.tsx +6 -4
  107. package/src/components/link.ws.tsx +17 -5
  108. package/src/components/list-item.ws.tsx +6 -4
  109. package/src/components/list.ws.tsx +6 -4
  110. package/src/components/paragraph.ws.tsx +6 -4
  111. package/src/components/radio-button-field.ws.tsx +6 -4
  112. package/src/components/radio-button.ws.tsx +6 -4
  113. package/src/components/separator.ws.tsx +6 -4
  114. package/src/components/span.ws.tsx +6 -4
  115. package/src/components/subscript.ws.tsx +6 -4
  116. package/src/components/superscript.ws.tsx +6 -4
  117. package/src/components/text-block.ws.tsx +6 -4
  118. package/src/components/textarea.ws.tsx +6 -4
  119. package/src/css/normalize.ts +20 -18
  120. package/src/css/presets.ts +20 -2
  121. package/src/index.ts +1 -0
@@ -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
  };
@@ -1,9 +1,10 @@
1
1
  import { FormTextAreaIcon } from "@webstudio-is/icons";
2
2
  import { textarea } from "../css/normalize";
3
- import type {
4
- WsComponentMeta,
5
- WsComponentPropsMeta,
6
- PresetStyle,
3
+ import {
4
+ type WsComponentMeta,
5
+ type WsComponentPropsMeta,
6
+ type PresetStyle,
7
+ defaultStates,
7
8
  } from "./component-meta";
8
9
  import type { defaultTag } from "./textarea";
9
10
  import { props } from "./__generated__/textarea.props";
@@ -23,6 +24,7 @@ export const meta: WsComponentMeta = {
23
24
  Icon: FormTextAreaIcon,
24
25
  presetStyle,
25
26
  states: [
27
+ ...defaultStates,
26
28
  { selector: "::placeholder", label: "Placeholder" },
27
29
  { selector: ":valid", label: "Valid" },
28
30
  { selector: ":invalid", label: "Invalid" },
@@ -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;
@@ -61,7 +63,7 @@ export const i = baseStyle;
61
63
 
62
64
  export const img = baseStyle;
63
65
 
64
- export const a = baseStyle;
66
+ export const a = [boxSizing, ...borders, ...linkColors];
65
67
  export const li = baseStyle;
66
68
  export const ul = baseStyle;
67
69
  export const ol = baseStyle;
@@ -93,7 +95,7 @@ export const html = [
93
95
  },
94
96
  boxSizing,
95
97
  ...borders,
96
- ] satisfies EmbedTemplateStyleDecl[];
98
+ ] satisfies Styles;
97
99
 
98
100
  /**
99
101
  1. Remove the margin in all browsers.
@@ -127,7 +129,7 @@ export const body = [
127
129
  },
128
130
  boxSizing,
129
131
  ...borders,
130
- ] satisfies EmbedTemplateStyleDecl[];
132
+ ] satisfies Styles;
131
133
 
132
134
  /**
133
135
  1. Add the correct height in Firefox.
@@ -146,7 +148,7 @@ export const hr = [
146
148
  },
147
149
  boxSizing,
148
150
  ...borders,
149
- ] satisfies EmbedTemplateStyleDecl[];
151
+ ] satisfies Styles;
150
152
 
151
153
  /**
152
154
  Add the correct text decoration in Chrome, Edge, and Safari.
@@ -168,7 +170,7 @@ export const b = [
168
170
  },
169
171
  boxSizing,
170
172
  ...borders,
171
- ] satisfies EmbedTemplateStyleDecl[];
173
+ ] satisfies Styles;
172
174
  export const strong = b;
173
175
 
174
176
  /**
@@ -191,7 +193,7 @@ export const code = [
191
193
  },
192
194
  boxSizing,
193
195
  ...borders,
194
- ] satisfies EmbedTemplateStyleDecl[];
196
+ ] satisfies Styles;
195
197
 
196
198
  export const kbd = code;
197
199
  export const samp = code;
@@ -208,7 +210,7 @@ export const small = [
208
210
  },
209
211
  boxSizing,
210
212
  ...borders,
211
- ] satisfies EmbedTemplateStyleDecl[];
213
+ ] satisfies Styles;
212
214
 
213
215
  /**
214
216
  Prevent 'sub' and 'sup' elements from affecting the line height in all browsers.
@@ -233,7 +235,7 @@ const subSupBase = [
233
235
  },
234
236
  boxSizing,
235
237
  ...borders,
236
- ] satisfies EmbedTemplateStyleDecl[];
238
+ ] satisfies Styles;
237
239
 
238
240
  export const sub = [
239
241
  ...subSupBase,
@@ -241,7 +243,7 @@ export const sub = [
241
243
  property: "bottom",
242
244
  value: { type: "unit", value: -0.25, unit: "em" },
243
245
  },
244
- ] satisfies EmbedTemplateStyleDecl[];
246
+ ] satisfies Styles;
245
247
 
246
248
  export const sup = [
247
249
  ...subSupBase,
@@ -249,7 +251,7 @@ export const sup = [
249
251
  property: "top",
250
252
  value: { type: "unit", value: -0.5, unit: "em" },
251
253
  },
252
- ] satisfies EmbedTemplateStyleDecl[];
254
+ ] satisfies Styles;
253
255
 
254
256
  /*
255
257
  Tabular data
@@ -286,7 +288,7 @@ export const table = [
286
288
  value: { type: "keyword", value: "inherit" },
287
289
  },
288
290
  boxSizing,
289
- ] satisfies EmbedTemplateStyleDecl[];
291
+ ] satisfies Styles;
290
292
 
291
293
  /*
292
294
  Forms
@@ -331,7 +333,7 @@ const buttonBase = [
331
333
  },
332
334
  boxSizing,
333
335
  ...borders,
334
- ] satisfies EmbedTemplateStyleDecl[];
336
+ ] satisfies Styles;
335
337
 
336
338
  export const input = buttonBase;
337
339
  export const optgroup = buttonBase;
@@ -346,7 +348,7 @@ export const button = [
346
348
  property: "textTransform",
347
349
  value: { type: "keyword", value: "none" },
348
350
  },
349
- ] satisfies EmbedTemplateStyleDecl[];
351
+ ] satisfies Styles;
350
352
 
351
353
  export const select = button;
352
354
 
@@ -418,7 +420,7 @@ export const legend = [
418
420
  },
419
421
  boxSizing,
420
422
  ...borders,
421
- ] satisfies EmbedTemplateStyleDecl[];
423
+ ] satisfies Styles;
422
424
 
423
425
  /**
424
426
  Add the correct vertical alignment in Chrome and Firefox.
@@ -431,7 +433,7 @@ export const progress = [
431
433
  },
432
434
  boxSizing,
433
435
  ...borders,
434
- ] satisfies EmbedTemplateStyleDecl[];
436
+ ] satisfies Styles;
435
437
 
436
438
  /**
437
439
  Correct the cursor style of increment and decrement buttons in Safari.
@@ -494,4 +496,4 @@ export const summary = [
494
496
  },
495
497
  boxSizing,
496
498
  ...borders,
497
- ] 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";