@webstudio-is/react-sdk 0.60.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 (83) hide show
  1. package/lib/cjs/components/blockquote.ws.js +36 -48
  2. package/lib/cjs/components/body.ws.js +20 -17
  3. package/lib/cjs/components/button.ws.js +1 -1
  4. package/lib/cjs/components/code.ws.js +20 -28
  5. package/lib/cjs/components/component-meta.js +2 -1
  6. package/lib/cjs/components/form.ws.js +14 -7
  7. package/lib/cjs/components/heading.ws.js +1 -1
  8. package/lib/cjs/components/image.ws.js +8 -9
  9. package/lib/cjs/components/italic.ws.js +5 -5
  10. package/lib/cjs/components/link-block.ws.js +5 -5
  11. package/lib/cjs/components/link.ws.js +9 -10
  12. package/lib/cjs/components/list-item.ws.js +1 -1
  13. package/lib/cjs/components/list.ws.js +22 -22
  14. package/lib/cjs/components/paragraph.ws.js +1 -1
  15. package/lib/cjs/components/separator.ws.js +20 -20
  16. package/lib/cjs/components/text-block.ws.js +6 -7
  17. package/lib/cjs/css/css.js +6 -9
  18. package/lib/cjs/css/normalize.js +166 -185
  19. package/lib/cjs/css/presets.js +14 -34
  20. package/lib/cjs/css/style-rules.js +17 -0
  21. package/lib/cjs/embed-template.js +160 -0
  22. package/lib/cjs/index.js +1 -0
  23. package/lib/components/blockquote.ws.js +36 -48
  24. package/lib/components/body.ws.js +20 -17
  25. package/lib/components/button.ws.js +1 -1
  26. package/lib/components/code.ws.js +20 -28
  27. package/lib/components/component-meta.js +2 -1
  28. package/lib/components/form.ws.js +14 -7
  29. package/lib/components/heading.ws.js +1 -1
  30. package/lib/components/image.ws.js +8 -9
  31. package/lib/components/italic.ws.js +5 -5
  32. package/lib/components/link-block.ws.js +5 -5
  33. package/lib/components/link.ws.js +9 -10
  34. package/lib/components/list-item.ws.js +1 -1
  35. package/lib/components/list.ws.js +22 -22
  36. package/lib/components/paragraph.ws.js +1 -1
  37. package/lib/components/separator.ws.js +20 -20
  38. package/lib/components/text-block.ws.js +6 -7
  39. package/lib/css/css.js +8 -11
  40. package/lib/css/normalize.js +166 -185
  41. package/lib/css/presets.js +14 -34
  42. package/lib/css/style-rules.js +17 -0
  43. package/lib/embed-template.js +140 -0
  44. package/lib/index.js +1 -0
  45. package/lib/types/components/box.stories.d.ts +2 -2
  46. package/lib/types/components/component-meta.d.ts +20 -5
  47. package/lib/types/components/components-utils.d.ts +1 -1
  48. package/lib/types/css/normalize.d.ts +8786 -2286
  49. package/lib/types/css/presets.d.ts +2 -38
  50. package/lib/types/css/style-rules.d.ts +11 -9
  51. package/lib/types/embed-template.d.ts +1725 -0
  52. package/lib/types/embed-template.test.d.ts +1 -0
  53. package/lib/types/index.d.ts +1 -0
  54. package/package.json +14 -13
  55. package/src/components/blockquote.ws.tsx +42 -52
  56. package/src/components/body.ws.tsx +26 -23
  57. package/src/components/bold.ws.tsx +6 -3
  58. package/src/components/box.ws.ts +6 -3
  59. package/src/components/button.ws.tsx +7 -4
  60. package/src/components/code.ws.tsx +26 -32
  61. package/src/components/component-meta.ts +5 -3
  62. package/src/components/form.ws.tsx +19 -9
  63. package/src/components/heading.ws.tsx +7 -4
  64. package/src/components/image.ws.tsx +14 -12
  65. package/src/components/input.ws.tsx +6 -3
  66. package/src/components/italic.ws.tsx +11 -8
  67. package/src/components/link-block.ws.tsx +11 -8
  68. package/src/components/link.ws.tsx +15 -13
  69. package/src/components/list-item.ws.tsx +7 -4
  70. package/src/components/list.ws.tsx +28 -25
  71. package/src/components/paragraph.ws.tsx +7 -4
  72. package/src/components/separator.ws.tsx +26 -25
  73. package/src/components/span.ws.tsx +6 -3
  74. package/src/components/subscript.ws.tsx +6 -3
  75. package/src/components/superscript.ws.tsx +6 -3
  76. package/src/components/text-block.ws.tsx +12 -11
  77. package/src/css/css.ts +8 -11
  78. package/src/css/normalize.ts +165 -188
  79. package/src/css/presets.ts +15 -37
  80. package/src/css/style-rules.ts +24 -0
  81. package/src/embed-template.test.ts +210 -0
  82. package/src/embed-template.ts +187 -0
  83. package/src/index.ts +1 -0
@@ -15,18 +15,17 @@
15
15
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
16
16
  */
17
17
 
18
- import type { Style } from "@webstudio-is/css-data";
19
-
20
18
  // webstudio custom opinionated presets
21
19
  import { borders } from "./presets";
20
+ import type { EmbedTemplateStyleDecl } from "../embed-template";
22
21
 
23
22
  /**
24
23
  Use a better box model (opinionated).
25
24
  */
26
25
  const boxSizing = {
27
- type: "keyword",
28
- value: "border-box",
29
- } as const;
26
+ property: "boxSizing",
27
+ value: { type: "keyword", value: "border-box" },
28
+ } satisfies EmbedTemplateStyleDecl;
30
29
 
31
30
  /**
32
31
  * We dont support rules like this now, implement boxSizing for each used element
@@ -36,10 +35,7 @@ const boxSizing = {
36
35
  * box-sizing: border-box;
37
36
  }
38
37
  */
39
- const baseStyle = {
40
- boxSizing,
41
- ...borders,
42
- } as const satisfies Style;
38
+ const baseStyle = [boxSizing, ...borders] satisfies EmbedTemplateStyleDecl[];
43
39
 
44
40
  export const div = baseStyle;
45
41
  export const address = baseStyle;
@@ -78,83 +74,78 @@ export const span = baseStyle;
78
74
  2. Prevent adjustments of font size after orientation changes in iOS.
79
75
  3. Use a more readable tab size (opinionated).
80
76
  */
81
- export const html = {
77
+ export const html = [
82
78
  /* 1 */
83
- lineHeight: {
84
- type: "unit",
85
- value: 1.15,
86
- unit: "number",
79
+ {
80
+ property: "lineHeight",
81
+ value: { type: "unit", value: 1.15, unit: "number" },
87
82
  },
88
-
89
83
  /* 2 */
90
- textSizeAdjust: {
91
- type: "unit",
92
- value: 100,
93
- unit: "%",
84
+ {
85
+ property: "textSizeAdjust",
86
+ value: { type: "unit", value: 100, unit: "%" },
94
87
  },
95
-
96
88
  /* 3 */
97
- tabSize: {
98
- type: "unit",
99
- value: 4,
100
- unit: "number",
89
+ {
90
+ property: "tabSize",
91
+ value: { type: "unit", value: 4, unit: "number" },
101
92
  },
102
-
103
93
  boxSizing,
104
94
  ...borders,
105
- } as const satisfies Style;
95
+ ] satisfies EmbedTemplateStyleDecl[];
106
96
 
107
97
  /**
108
98
  1. Remove the margin in all browsers.
109
99
  2. Improve consistency of default fonts in all browsers. (https://github.com/sindresorhus/modern-normalize/issues/3)
110
100
  */
111
- export const body = {
101
+ export const body = [
112
102
  /* 1 */
113
- marginTop: {
114
- type: "unit",
115
- value: 0,
116
- unit: "number",
117
- },
118
- marginRight: {
119
- type: "unit",
120
- value: 0,
121
- unit: "number",
122
- },
123
- marginBottom: {
124
- type: "unit",
125
- value: 0,
126
- unit: "number",
127
- },
128
- marginLeft: {
129
- type: "unit",
130
- value: 0,
131
- unit: "number",
103
+ {
104
+ property: "marginTop",
105
+ value: { type: "unit", value: 0, unit: "number" },
106
+ },
107
+ {
108
+ property: "marginRight",
109
+ value: { type: "unit", value: 0, unit: "number" },
110
+ },
111
+ {
112
+ property: "marginBottom",
113
+ value: { type: "unit", value: 0, unit: "number" },
114
+ },
115
+ {
116
+ property: "marginLeft",
117
+ value: { type: "unit", value: 0, unit: "number" },
132
118
  },
133
119
  /* 2 */
134
- fontFamily: {
135
- type: "keyword",
136
- value: `system-ui, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji'`,
120
+ {
121
+ property: "fontFamily",
122
+ value: {
123
+ type: "keyword",
124
+ value: `system-ui, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji'`,
125
+ },
137
126
  },
138
127
  boxSizing,
139
128
  ...borders,
140
- } as const satisfies Style;
129
+ ] satisfies EmbedTemplateStyleDecl[];
141
130
 
142
131
  /**
143
132
  1. Add the correct height in Firefox.
144
133
  2. Correct the inheritance of border color in Firefox. (https://bugzilla.mozilla.org/show_bug.cgi?id=190655)
145
134
  */
146
- export const hr = {
135
+ export const hr = [
147
136
  /* 1 */
148
- height: {
149
- type: "unit",
150
- value: 0,
151
- unit: "number",
137
+ {
138
+ property: "height",
139
+ value: { type: "unit", value: 0, unit: "number" },
152
140
  },
153
141
  /* 2 */
154
- color: { type: "keyword", value: "inherit" },
142
+ {
143
+ property: "color",
144
+ value: { type: "keyword", value: "inherit" },
145
+ },
155
146
  boxSizing,
156
147
  ...borders,
157
- } as const satisfies Style;
148
+ ] satisfies EmbedTemplateStyleDecl[];
158
149
 
159
150
  /**
160
151
  Add the correct text decoration in Chrome, Edge, and Safari.
@@ -169,35 +160,37 @@ abbr[title] {
169
160
  /**
170
161
  Add the correct font weight in Edge and Safari.
171
162
  */
172
- export const b = {
173
- fontWeight: {
174
- type: "keyword",
175
- value: "bolder",
163
+ export const b = [
164
+ {
165
+ property: "fontWeight",
166
+ value: { type: "keyword", value: "700" },
176
167
  },
177
168
  boxSizing,
178
169
  ...borders,
179
- } as const satisfies Style;
170
+ ] satisfies EmbedTemplateStyleDecl[];
180
171
  export const strong = b;
181
172
 
182
173
  /**
183
174
  1. Improve consistency of default fonts in all browsers. (https://github.com/sindresorhus/modern-normalize/issues/3)
184
175
  2. Correct the odd 'em' font sizing in all browsers.
185
176
  */
186
- export const code = {
177
+ export const code = [
187
178
  /* 1 */
188
- fontFamily: {
189
- type: "keyword",
190
- value: `ui-monospace, SFMono-Regular, Consolas, 'Liberation Mono', Menlo, monospace`,
179
+ {
180
+ property: "fontFamily",
181
+ value: {
182
+ type: "keyword",
183
+ value: `ui-monospace, SFMono-Regular, Consolas, 'Liberation Mono', Menlo, monospace`,
184
+ },
191
185
  },
192
186
  /* 2 */
193
- fontSize: {
194
- type: "unit",
195
- value: 1,
196
- unit: "em",
187
+ {
188
+ property: "fontSize",
189
+ value: { type: "unit", value: 1, unit: "em" },
197
190
  },
198
191
  boxSizing,
199
192
  ...borders,
200
- } as const satisfies Style;
193
+ ] satisfies EmbedTemplateStyleDecl[];
201
194
 
202
195
  export const kbd = code;
203
196
  export const samp = code;
@@ -207,60 +200,55 @@ export const pre = code;
207
200
  Add the correct font size in all browsers.
208
201
  */
209
202
 
210
- export const small = {
211
- fontSize: {
212
- type: "unit",
213
- value: 80,
214
- unit: "%",
203
+ export const small = [
204
+ {
205
+ property: "fontSize",
206
+ value: { type: "unit", value: 80, unit: "%" },
215
207
  },
216
208
  boxSizing,
217
209
  ...borders,
218
- } as const satisfies Style;
210
+ ] satisfies EmbedTemplateStyleDecl[];
219
211
 
220
212
  /**
221
213
  Prevent 'sub' and 'sup' elements from affecting the line height in all browsers.
222
214
  */
223
215
 
224
- const subSupBase = {
225
- fontSize: {
226
- type: "unit",
227
- value: 75,
228
- unit: "%",
216
+ const subSupBase = [
217
+ {
218
+ property: "fontSize",
219
+ value: { type: "unit", value: 75, unit: "%" },
229
220
  },
230
- lineHeight: {
231
- type: "unit",
232
- value: 0,
233
- unit: "number",
221
+ {
222
+ property: "lineHeight",
223
+ value: { type: "unit", value: 0, unit: "number" },
234
224
  },
235
- position: {
236
- type: "keyword",
237
- value: "relative",
225
+ {
226
+ property: "position",
227
+ value: { type: "keyword", value: "relative" },
238
228
  },
239
- verticalAlign: {
240
- type: "keyword",
241
- value: "baseline",
229
+ {
230
+ property: "verticalAlign",
231
+ value: { type: "keyword", value: "baseline" },
242
232
  },
243
233
  boxSizing,
244
234
  ...borders,
245
- } as const satisfies Style;
235
+ ] satisfies EmbedTemplateStyleDecl[];
246
236
 
247
- export const sub = {
237
+ export const sub = [
248
238
  ...subSupBase,
249
- bottom: {
250
- type: "unit",
251
- value: -0.25,
252
- unit: "em",
239
+ {
240
+ property: "bottom",
241
+ value: { type: "unit", value: -0.25, unit: "em" },
253
242
  },
254
- } as const satisfies Style;
243
+ ] satisfies EmbedTemplateStyleDecl[];
255
244
 
256
- export const sup = {
245
+ export const sup = [
257
246
  ...subSupBase,
258
- top: {
259
- type: "unit",
260
- value: -0.5,
261
- unit: "em",
247
+ {
248
+ property: "top",
249
+ value: { type: "unit", value: -0.5, unit: "em" },
262
250
  },
263
- } as const satisfies Style;
251
+ ] satisfies EmbedTemplateStyleDecl[];
264
252
 
265
253
  /*
266
254
  Tabular data
@@ -272,33 +260,32 @@ Tabular data
272
260
  2. Correct table border color inheritance in Chrome and Safari. (https://bugs.chromium.org/p/chromium/issues/detail?id=935729, https://bugs.webkit.org/show_bug.cgi?id=195016)
273
261
  */
274
262
 
275
- export const table = {
263
+ export const table = [
276
264
  /* 1 */
277
- textIndent: {
278
- type: "unit",
279
- value: 0,
280
- unit: "number",
265
+ {
266
+ property: "textIndent",
267
+ value: { type: "unit", value: 0, unit: "number" },
281
268
  },
282
269
  ...borders,
283
270
  /* 2 */
284
- borderTopColor: {
285
- type: "keyword",
286
- value: "inherit",
271
+ {
272
+ property: "borderTopColor",
273
+ value: { type: "keyword", value: "inherit" },
287
274
  },
288
- borderRightColor: {
289
- type: "keyword",
290
- value: "inherit",
275
+ {
276
+ property: "borderRightColor",
277
+ value: { type: "keyword", value: "inherit" },
291
278
  },
292
- borderBottomColor: {
293
- type: "keyword",
294
- value: "inherit",
279
+ {
280
+ property: "borderBottomColor",
281
+ value: { type: "keyword", value: "inherit" },
295
282
  },
296
- borderLeftColor: {
297
- type: "keyword",
298
- value: "inherit",
283
+ {
284
+ property: "borderLeftColor",
285
+ value: { type: "keyword", value: "inherit" },
299
286
  },
300
287
  boxSizing,
301
- } as const satisfies Style;
288
+ ] satisfies EmbedTemplateStyleDecl[];
302
289
 
303
290
  /*
304
291
  Forms
@@ -310,46 +297,40 @@ Forms
310
297
  2. Remove the margin in Firefox and Safari.
311
298
  */
312
299
 
313
- const buttonBase = {
300
+ const buttonBase = [
314
301
  /* 1 */
315
- fontFamily: {
316
- type: "keyword",
317
- value: "inherit",
302
+ {
303
+ property: "fontFamily",
304
+ value: { type: "keyword", value: "inherit" },
318
305
  },
319
- fontSize: {
320
- type: "unit",
321
- value: 100,
322
- unit: "%",
306
+ {
307
+ property: "fontSize",
308
+ value: { type: "unit", value: 100, unit: "%" },
323
309
  },
324
- lineHeight: {
325
- type: "unit",
326
- value: 1.15,
327
- unit: "number",
310
+ {
311
+ property: "lineHeight",
312
+ value: { type: "unit", value: 1.15, unit: "number" },
328
313
  },
329
314
  /* 2 */
330
- marginTop: {
331
- type: "unit",
332
- value: 0,
333
- unit: "number",
334
- },
335
- marginRight: {
336
- type: "unit",
337
- value: 0,
338
- unit: "number",
339
- },
340
- marginBottom: {
341
- type: "unit",
342
- value: 0,
343
- unit: "number",
344
- },
345
- marginLeft: {
346
- type: "unit",
347
- value: 0,
348
- unit: "number",
315
+ {
316
+ property: "marginTop",
317
+ value: { type: "unit", value: 0, unit: "number" },
318
+ },
319
+ {
320
+ property: "marginRight",
321
+ value: { type: "unit", value: 0, unit: "number" },
322
+ },
323
+ {
324
+ property: "marginBottom",
325
+ value: { type: "unit", value: 0, unit: "number" },
326
+ },
327
+ {
328
+ property: "marginLeft",
329
+ value: { type: "unit", value: 0, unit: "number" },
349
330
  },
350
331
  boxSizing,
351
332
  ...borders,
352
- } as const satisfies Style;
333
+ ] satisfies EmbedTemplateStyleDecl[];
353
334
 
354
335
  export const input = buttonBase;
355
336
  export const optgroup = buttonBase;
@@ -358,13 +339,13 @@ export const textarea = buttonBase;
358
339
  /**
359
340
  Remove the inheritance of text transform in Edge and Firefox.
360
341
  */
361
- export const button = {
342
+ export const button = [
362
343
  ...buttonBase,
363
- textTransform: {
364
- type: "keyword",
365
- value: "none",
344
+ {
345
+ property: "textTransform",
346
+ value: { type: "keyword", value: "none" },
366
347
  },
367
- } as const satisfies Style;
348
+ ] satisfies EmbedTemplateStyleDecl[];
368
349
 
369
350
  export const select = button;
370
351
 
@@ -417,43 +398,39 @@ See: https://github.com/mozilla/gecko-dev/blob/2f9eacd9d3d995c937b4251a5557d95d4
417
398
  Remove the padding so developers are not caught out when they zero out 'fieldset' elements in all browsers.
418
399
  */
419
400
 
420
- export const legend = {
421
- paddingTop: {
422
- type: "unit",
423
- value: 0,
424
- unit: "number",
401
+ export const legend = [
402
+ {
403
+ property: "paddingTop",
404
+ value: { type: "unit", value: 0, unit: "number" },
425
405
  },
426
- paddingRight: {
427
- type: "unit",
428
- value: 0,
429
- unit: "number",
406
+ {
407
+ property: "paddingRight",
408
+ value: { type: "unit", value: 0, unit: "number" },
430
409
  },
431
- paddingBottom: {
432
- type: "unit",
433
- value: 0,
434
- unit: "number",
410
+ {
411
+ property: "paddingBottom",
412
+ value: { type: "unit", value: 0, unit: "number" },
435
413
  },
436
- paddingLeft: {
437
- type: "unit",
438
- value: 0,
439
- unit: "number",
414
+ {
415
+ property: "paddingLeft",
416
+ value: { type: "unit", value: 0, unit: "number" },
440
417
  },
441
418
  boxSizing,
442
419
  ...borders,
443
- } as const satisfies Style;
420
+ ] satisfies EmbedTemplateStyleDecl[];
444
421
 
445
422
  /**
446
423
  Add the correct vertical alignment in Chrome and Firefox.
447
424
  */
448
425
 
449
- export const progress = {
450
- verticalAlign: {
451
- type: "keyword",
452
- value: "baseline",
426
+ export const progress = [
427
+ {
428
+ property: "verticalAlign",
429
+ value: { type: "keyword", value: "baseline" },
453
430
  },
454
431
  boxSizing,
455
432
  ...borders,
456
- } as const satisfies Style;
433
+ ] satisfies EmbedTemplateStyleDecl[];
457
434
 
458
435
  /**
459
436
  Correct the cursor style of increment and decrement buttons in Safari.
@@ -509,11 +486,11 @@ Interactive
509
486
  Add the correct display in Chrome and Safari.
510
487
  */
511
488
 
512
- export const summary = {
513
- display: {
514
- type: "keyword",
515
- value: "list-item",
489
+ export const summary = [
490
+ {
491
+ property: "display",
492
+ value: { type: "keyword", value: "list-item" },
516
493
  },
517
494
  boxSizing,
518
495
  ...borders,
519
- } as const satisfies Style;
496
+ ] satisfies EmbedTemplateStyleDecl[];
@@ -1,42 +1,20 @@
1
- import type { Style } from "@webstudio-is/css-data";
1
+ import type { EmbedTemplateStyleDecl } from "../embed-template";
2
2
 
3
- export const borders = {
4
- borderTopColor: {
5
- type: "keyword",
6
- value: "currentColor",
3
+ export const borders: EmbedTemplateStyleDecl[] = [
4
+ {
5
+ property: "borderTopWidth",
6
+ value: { type: "unit", value: 1, unit: "px" },
7
7
  },
8
- borderRightColor: {
9
- type: "keyword",
10
- value: "currentColor",
8
+ {
9
+ property: "borderRightWidth",
10
+ value: { type: "unit", value: 1, unit: "px" },
11
11
  },
12
- borderBottomColor: {
13
- type: "keyword",
14
- value: "currentColor",
12
+ {
13
+ property: "borderBottomWidth",
14
+ value: { type: "unit", value: 1, unit: "px" },
15
15
  },
16
- borderLeftColor: {
17
- type: "keyword",
18
- value: "currentColor",
16
+ {
17
+ property: "borderLeftWidth",
18
+ value: { type: "unit", value: 1, unit: "px" },
19
19
  },
20
-
21
- borderTopWidth: {
22
- type: "unit",
23
- value: 1,
24
- unit: "px",
25
- },
26
-
27
- borderRightWidth: {
28
- type: "unit",
29
- value: 1,
30
- unit: "px",
31
- },
32
- borderBottomWidth: {
33
- type: "unit",
34
- value: 1,
35
- unit: "px",
36
- },
37
- borderLeftWidth: {
38
- type: "unit",
39
- value: 1,
40
- unit: "px",
41
- },
42
- } as const satisfies Style;
20
+ ];
@@ -6,6 +6,8 @@ import type {
6
6
  StyleSource,
7
7
  StyleSourceSelections,
8
8
  } from "@webstudio-is/project-build";
9
+ import type { PresetStyle } from "../components/component-meta";
10
+ import { componentAttribute } from "../tree";
9
11
 
10
12
  type StyleRule = {
11
13
  instanceId: string;
@@ -75,3 +77,25 @@ export const getStyleRules = (
75
77
 
76
78
  return styleRules;
77
79
  };
80
+
81
+ export const getPresetStyleRules = (
82
+ component: string,
83
+ presetStyle: PresetStyle
84
+ ) => {
85
+ // group style declarations by selector to render as separate rules
86
+ const presetStyleRules = new Map<string, Style>();
87
+ for (const [tag, styles] of Object.entries(presetStyle)) {
88
+ for (const styleDecl of styles) {
89
+ const selector = `${tag}:where([${componentAttribute}=${component}])${
90
+ styleDecl.state ?? ""
91
+ }`;
92
+ let rule = presetStyleRules.get(selector);
93
+ if (rule === undefined) {
94
+ rule = {};
95
+ presetStyleRules.set(selector, rule);
96
+ }
97
+ rule[styleDecl.property] = styleDecl.value;
98
+ }
99
+ }
100
+ return presetStyleRules;
101
+ };