@webstudio-is/css-data 0.59.0 → 0.61.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webstudio-is/css-data",
3
- "version": "0.59.0",
3
+ "version": "0.61.0",
4
4
  "description": "CSS Data",
5
5
  "author": "Webstudio <github@webstudio.is>",
6
6
  "homepage": "https://webstudio.is",
@@ -9,12 +9,13 @@
9
9
  "@types/css-tree": "^2.0.0",
10
10
  "camelcase": "^6.3.0",
11
11
  "css-tree": "^2.3.1",
12
+ "html-tags": "^3.2.0",
12
13
  "mdn-data": "2.0.30",
13
14
  "tsx": "^3.12.6",
14
15
  "typescript": "5.0.3",
15
16
  "zod": "^3.19.1",
16
17
  "@webstudio-is/scripts": "^0.0.0",
17
- "@webstudio-is/tsconfig": "^1.0.5"
18
+ "@webstudio-is/tsconfig": "^1.0.6"
18
19
  },
19
20
  "peerDependencies": {
20
21
  "zod": "^3.19.1"
@@ -3836,8 +3836,8 @@ export const keywordValues = {
3836
3836
  "unset",
3837
3837
  ],
3838
3838
  fontWeight: [
3839
- "normal",
3840
- "bold",
3839
+ "400",
3840
+ "700",
3841
3841
  "bolder",
3842
3842
  "lighter",
3843
3843
  "initial",
@@ -330,7 +330,7 @@ export const properties = {
330
330
  inherited: false,
331
331
  initial: {
332
332
  type: "keyword",
333
- value: "currentcolor",
333
+ value: "currentColor",
334
334
  },
335
335
  popularity: 0.00012849,
336
336
  appliesTo: "allElements",
@@ -360,7 +360,7 @@ export const properties = {
360
360
  inherited: false,
361
361
  initial: {
362
362
  type: "keyword",
363
- value: "currentcolor",
363
+ value: "currentColor",
364
364
  },
365
365
  popularity: 0.00172099,
366
366
  appliesTo: "allElements",
@@ -390,7 +390,7 @@ export const properties = {
390
390
  inherited: false,
391
391
  initial: {
392
392
  type: "keyword",
393
- value: "currentcolor",
393
+ value: "currentColor",
394
394
  },
395
395
  popularity: 0.00170188,
396
396
  appliesTo: "allElements",
@@ -420,7 +420,7 @@ export const properties = {
420
420
  inherited: false,
421
421
  initial: {
422
422
  type: "keyword",
423
- value: "currentcolor",
423
+ value: "currentColor",
424
424
  },
425
425
  popularity: 0.42283564,
426
426
  appliesTo: "allElements",
@@ -557,7 +557,7 @@ export const properties = {
557
557
  inherited: false,
558
558
  initial: {
559
559
  type: "keyword",
560
- value: "currentcolor",
560
+ value: "currentColor",
561
561
  },
562
562
  popularity: 0.00007844,
563
563
  appliesTo: "allElements",
@@ -587,7 +587,7 @@ export const properties = {
587
587
  inherited: false,
588
588
  initial: {
589
589
  type: "keyword",
590
- value: "currentcolor",
590
+ value: "currentColor",
591
591
  },
592
592
  popularity: 0.00196849,
593
593
  appliesTo: "allElements",
@@ -617,7 +617,7 @@ export const properties = {
617
617
  inherited: false,
618
618
  initial: {
619
619
  type: "keyword",
620
- value: "currentcolor",
620
+ value: "currentColor",
621
621
  },
622
622
  popularity: 0.00196928,
623
623
  appliesTo: "allElements",
@@ -647,7 +647,7 @@ export const properties = {
647
647
  inherited: false,
648
648
  initial: {
649
649
  type: "keyword",
650
- value: "currentcolor",
650
+ value: "currentColor",
651
651
  },
652
652
  popularity: 0.30754028,
653
653
  appliesTo: "allElements",
@@ -677,7 +677,7 @@ export const properties = {
677
677
  inherited: false,
678
678
  initial: {
679
679
  type: "keyword",
680
- value: "currentcolor",
680
+ value: "currentColor",
681
681
  },
682
682
  popularity: 0.29336595,
683
683
  appliesTo: "allElements",
@@ -740,7 +740,7 @@ export const properties = {
740
740
  inherited: false,
741
741
  initial: {
742
742
  type: "keyword",
743
- value: "currentcolor",
743
+ value: "currentColor",
744
744
  },
745
745
  popularity: 0.43342948,
746
746
  appliesTo: "allElements",
@@ -983,7 +983,7 @@ export const properties = {
983
983
  inherited: false,
984
984
  initial: {
985
985
  type: "keyword",
986
- value: "currentcolor",
986
+ value: "currentColor",
987
987
  },
988
988
  popularity: 0.01356616,
989
989
  appliesTo: "multicolElements",
@@ -1425,7 +1425,7 @@ export const properties = {
1425
1425
  inherited: true,
1426
1426
  initial: {
1427
1427
  type: "keyword",
1428
- value: "normal",
1428
+ value: "400",
1429
1429
  },
1430
1430
  popularity: 0.88598106,
1431
1431
  appliesTo: "allElements",
@@ -3106,7 +3106,7 @@ export const properties = {
3106
3106
  inherited: false,
3107
3107
  initial: {
3108
3108
  type: "keyword",
3109
- value: "currentcolor",
3109
+ value: "currentColor",
3110
3110
  },
3111
3111
  popularity: 0.05079903,
3112
3112
  appliesTo: "allElements",
@@ -3166,7 +3166,7 @@ export const properties = {
3166
3166
  inherited: false,
3167
3167
  initial: {
3168
3168
  type: "keyword",
3169
- value: "currentcolor",
3169
+ value: "currentColor",
3170
3170
  },
3171
3171
  popularity: 0,
3172
3172
  appliesTo: "allElements",
@@ -0,0 +1,8 @@
1
+ import * as html from "./html";
2
+ import type { htmlTags as HtmlTags } from "html-tags";
3
+
4
+ type ExportedTags = keyof typeof html;
5
+
6
+ declare let exportedTags: ExportedTags;
7
+
8
+ exportedTags satisfies HtmlTags;
package/src/html.ts ADDED
@@ -0,0 +1,545 @@
1
+ // all styles are taken from following source
2
+ // https://searchfox.org/mozilla-central/source/layout/style/res/html.css
3
+ // https://chromium.googlesource.com/chromium/blink/+/master/Source/core/css/html.css
4
+ // https://trac.webkit.org/browser/trunk/Source/WebCore/css/html.css
5
+
6
+ import type { htmlTags as HtmlTags } from "html-tags";
7
+ import type { StyleProperty, StyleValue } from "./schema";
8
+
9
+ type StyleDecl = {
10
+ property: StyleProperty;
11
+ value: StyleValue;
12
+ };
13
+ type Styles = StyleDecl[];
14
+
15
+ export type Html = {
16
+ [tag in HtmlTags]?: Styles;
17
+ };
18
+
19
+ const displayBlock: Styles[number] = {
20
+ property: "display",
21
+ value: { type: "keyword", value: "block" },
22
+ };
23
+
24
+ const mt1em: Styles[number] = {
25
+ property: "marginTop",
26
+ value: { type: "unit", value: 1, unit: "em" },
27
+ };
28
+
29
+ const mb1em: Styles[number] = {
30
+ property: "marginBottom",
31
+ value: { type: "unit", value: 1, unit: "em" },
32
+ };
33
+
34
+ const ml40px: Styles[number] = {
35
+ property: "marginLeft",
36
+ value: { type: "unit", value: 40, unit: "px" },
37
+ };
38
+
39
+ const mr40px: Styles[number] = {
40
+ property: "marginRight",
41
+ value: { type: "unit", value: 40, unit: "px" },
42
+ };
43
+
44
+ const pl40px: Styles[number] = {
45
+ property: "paddingLeft",
46
+ value: { type: "unit", value: 40, unit: "px" },
47
+ };
48
+
49
+ const fontWeightBold: Styles[number] = {
50
+ property: "fontWeight",
51
+ // in browsers defined as bold
52
+ // though builder accepts only numeric values
53
+ value: { type: "keyword", value: "700" },
54
+ };
55
+
56
+ const fontStyleItalic: Styles[number] = {
57
+ property: "fontStyle",
58
+ value: { type: "keyword", value: "italic" },
59
+ };
60
+
61
+ const pt1px: Styles[number] = {
62
+ property: "paddingTop",
63
+ value: { type: "unit", value: 1, unit: "px" },
64
+ };
65
+
66
+ const pr1px: Styles[number] = {
67
+ property: "paddingRight",
68
+ value: { type: "unit", value: 1, unit: "px" },
69
+ };
70
+
71
+ const pb1px: Styles[number] = {
72
+ property: "paddingBottom",
73
+ value: { type: "unit", value: 1, unit: "px" },
74
+ };
75
+
76
+ const pl1px: Styles[number] = {
77
+ property: "paddingLeft",
78
+ value: { type: "unit", value: 1, unit: "px" },
79
+ };
80
+
81
+ /* blocks */
82
+
83
+ export const article: Styles = [displayBlock];
84
+ export {
85
+ article as aside,
86
+ article as details,
87
+ article as div,
88
+ article as dt,
89
+ article as figcaption,
90
+ article as footer,
91
+ article as form,
92
+ article as header,
93
+ article as hgroup,
94
+ article as html,
95
+ article as main,
96
+ article as nav,
97
+ article as section,
98
+ article as summary,
99
+ };
100
+
101
+ export const body: Styles = [
102
+ displayBlock,
103
+ {
104
+ property: "marginTop",
105
+ value: { type: "unit", value: 8, unit: "px" },
106
+ },
107
+ {
108
+ property: "marginRight",
109
+ value: { type: "unit", value: 8, unit: "px" },
110
+ },
111
+ {
112
+ property: "marginBottom",
113
+ value: { type: "unit", value: 8, unit: "px" },
114
+ },
115
+ {
116
+ property: "marginLeft",
117
+ value: { type: "unit", value: 8, unit: "px" },
118
+ },
119
+ ];
120
+
121
+ export const p: Styles = [displayBlock, mt1em, mb1em];
122
+ export { p as dl };
123
+
124
+ export const dd: Styles = [displayBlock, ml40px];
125
+
126
+ export const blockquote: Styles = [displayBlock, mt1em, mb1em, ml40px, mr40px];
127
+ export { blockquote as figure };
128
+
129
+ export const address: Styles = [displayBlock, fontStyleItalic];
130
+
131
+ // h1 font-size, margin-top and margin-bottom depend on outer tags
132
+ // so better define statically in preset styles
133
+ export const h1: Styles = [
134
+ displayBlock,
135
+ fontWeightBold,
136
+ {
137
+ property: "fontSize",
138
+ value: { type: "unit", value: 2, unit: "em" },
139
+ },
140
+ {
141
+ property: "marginTop",
142
+ value: { type: "unit", value: 0.67, unit: "em" },
143
+ },
144
+ {
145
+ property: "marginBottom",
146
+ value: { type: "unit", value: 0.67, unit: "em" },
147
+ },
148
+ ];
149
+
150
+ export const h2: Styles = [
151
+ displayBlock,
152
+ fontWeightBold,
153
+ {
154
+ property: "fontSize",
155
+ value: { type: "unit", value: 1.5, unit: "em" },
156
+ },
157
+ {
158
+ property: "marginTop",
159
+ value: { type: "unit", value: 0.83, unit: "em" },
160
+ },
161
+ {
162
+ property: "marginBottom",
163
+ value: { type: "unit", value: 0.83, unit: "em" },
164
+ },
165
+ ];
166
+
167
+ export const h3: Styles = [
168
+ displayBlock,
169
+ fontWeightBold,
170
+ {
171
+ property: "fontSize",
172
+ value: { type: "unit", value: 1.17, unit: "em" },
173
+ },
174
+ {
175
+ property: "marginTop",
176
+ value: { type: "unit", value: 1, unit: "em" },
177
+ },
178
+ {
179
+ property: "marginBottom",
180
+ value: { type: "unit", value: 1, unit: "em" },
181
+ },
182
+ ];
183
+
184
+ export const h4: Styles = [
185
+ displayBlock,
186
+ fontWeightBold,
187
+ {
188
+ property: "marginTop",
189
+ value: { type: "unit", value: 1.33, unit: "em" },
190
+ },
191
+ {
192
+ property: "marginBottom",
193
+ value: { type: "unit", value: 1.33, unit: "em" },
194
+ },
195
+ ];
196
+
197
+ export const h5: Styles = [
198
+ displayBlock,
199
+ fontWeightBold,
200
+ {
201
+ property: "fontSize",
202
+ value: { type: "unit", value: 0.83, unit: "em" },
203
+ },
204
+ {
205
+ property: "marginTop",
206
+ value: { type: "unit", value: 1.67, unit: "em" },
207
+ },
208
+ {
209
+ property: "marginBottom",
210
+ value: { type: "unit", value: 1.67, unit: "em" },
211
+ },
212
+ ];
213
+
214
+ export const h6: Styles = [
215
+ displayBlock,
216
+ fontWeightBold,
217
+ {
218
+ property: "fontSize",
219
+ value: { type: "unit", value: 0.67, unit: "em" },
220
+ },
221
+ {
222
+ property: "marginTop",
223
+ value: { type: "unit", value: 2.33, unit: "em" },
224
+ },
225
+ {
226
+ property: "marginBottom",
227
+ value: { type: "unit", value: 2.33, unit: "em" },
228
+ },
229
+ ];
230
+
231
+ export const pre: Styles = [
232
+ displayBlock,
233
+ {
234
+ property: "whiteSpace",
235
+ value: { type: "keyword", value: "pre" },
236
+ },
237
+ mt1em,
238
+ mb1em,
239
+ ];
240
+
241
+ /* tables */
242
+
243
+ export const table: Styles = [
244
+ {
245
+ property: "display",
246
+ value: { type: "keyword", value: "table" },
247
+ },
248
+ {
249
+ property: "borderSpacing",
250
+ value: { type: "unit", value: 2, unit: "px" },
251
+ },
252
+ {
253
+ property: "borderCollapse",
254
+ value: { type: "keyword", value: "separate" },
255
+ },
256
+ {
257
+ property: "boxSizing",
258
+ value: { type: "keyword", value: "border-box" },
259
+ },
260
+ {
261
+ property: "borderSpacing",
262
+ value: { type: "unit", value: 0, unit: "number" },
263
+ },
264
+ ];
265
+
266
+ export const caption: Styles = [
267
+ {
268
+ property: "display",
269
+ value: { type: "keyword", value: "table" },
270
+ },
271
+ {
272
+ property: "textAlign",
273
+ value: { type: "keyword", value: "center" },
274
+ },
275
+ ];
276
+
277
+ export const tr: Styles = [
278
+ {
279
+ property: "display",
280
+ value: { type: "keyword", value: "table-row" },
281
+ },
282
+ {
283
+ property: "verticalAlign",
284
+ value: { type: "keyword", value: "inherit" },
285
+ },
286
+ ];
287
+
288
+ export const col: Styles = [
289
+ {
290
+ property: "display",
291
+ value: { type: "keyword", value: "table-column" },
292
+ },
293
+ ];
294
+
295
+ export const colgroup: Styles = [
296
+ {
297
+ property: "display",
298
+ value: { type: "keyword", value: "table-column-group" },
299
+ },
300
+ ];
301
+
302
+ export const tbody: Styles = [
303
+ {
304
+ property: "display",
305
+ value: { type: "keyword", value: "table-row-group" },
306
+ },
307
+ {
308
+ property: "verticalAlign",
309
+ value: { type: "keyword", value: "middle" },
310
+ },
311
+ ];
312
+
313
+ export const thead: Styles = [
314
+ {
315
+ property: "display",
316
+ value: { type: "keyword", value: "table-header-group" },
317
+ },
318
+ {
319
+ property: "verticalAlign",
320
+ value: { type: "keyword", value: "middle" },
321
+ },
322
+ ];
323
+
324
+ export const tfoot: Styles = [
325
+ {
326
+ property: "display",
327
+ value: { type: "keyword", value: "table-footer-group" },
328
+ },
329
+ {
330
+ property: "verticalAlign",
331
+ value: { type: "keyword", value: "middle" },
332
+ },
333
+ ];
334
+
335
+ export const td: Styles = [
336
+ {
337
+ property: "display",
338
+ value: { type: "keyword", value: "table-cell" },
339
+ },
340
+ {
341
+ property: "verticalAlign",
342
+ value: { type: "keyword", value: "inherit" },
343
+ },
344
+ {
345
+ property: "textAlign",
346
+ value: { type: "keyword", value: "unset" },
347
+ },
348
+ pt1px,
349
+ pr1px,
350
+ pb1px,
351
+ pl1px,
352
+ ];
353
+
354
+ export const th: Styles = [
355
+ {
356
+ property: "display",
357
+ value: { type: "keyword", value: "table-cell" },
358
+ },
359
+ {
360
+ property: "verticalAlign",
361
+ value: { type: "keyword", value: "inherit" },
362
+ },
363
+ fontWeightBold,
364
+ pt1px,
365
+ pr1px,
366
+ pb1px,
367
+ pl1px,
368
+ ];
369
+
370
+ /* inlines */
371
+
372
+ export const b: Styles = [
373
+ // in firefox defined as bolder
374
+ fontWeightBold,
375
+ ];
376
+ export { b as strong };
377
+
378
+ export const i: Styles = [fontStyleItalic];
379
+ export { i as cite, i as em, i as var, i as dfn };
380
+
381
+ export const code: Styles = [
382
+ {
383
+ property: "fontFamily",
384
+ // in firefox defined as -moz-fixed
385
+ value: { type: "fontFamily", value: ["monospace"] },
386
+ },
387
+ ];
388
+ export { code as kbd, code as samp };
389
+
390
+ export const mark: Styles = [
391
+ {
392
+ property: "backgroundColor",
393
+ // in firefox defined as Mark
394
+ value: { type: "keyword", value: "yellow" },
395
+ },
396
+ {
397
+ property: "color",
398
+ // in firefox defined as MarkText
399
+ value: { type: "keyword", value: "black" },
400
+ },
401
+ ];
402
+
403
+ export const u: Styles = [
404
+ {
405
+ property: "textDecorationStyle",
406
+ value: { type: "keyword", value: "underline" },
407
+ },
408
+ ];
409
+ export { u as ins };
410
+
411
+ export const s: Styles = [
412
+ {
413
+ property: "textDecorationStyle",
414
+ value: { type: "keyword", value: "line-through" },
415
+ },
416
+ ];
417
+ export { s as del };
418
+
419
+ export const sub: Styles = [
420
+ {
421
+ property: "verticalAlign",
422
+ value: { type: "keyword", value: "sub" },
423
+ },
424
+ {
425
+ property: "fontSize",
426
+ value: { type: "keyword", value: "smaller" },
427
+ },
428
+ ];
429
+
430
+ export const sup: Styles = [
431
+ {
432
+ property: "verticalAlign",
433
+ value: { type: "keyword", value: "super" },
434
+ },
435
+ {
436
+ property: "fontSize",
437
+ value: { type: "keyword", value: "smaller" },
438
+ },
439
+ ];
440
+
441
+ /* lists */
442
+
443
+ // nested lists have no top/bottom margins
444
+ // so better redefine statically in preset
445
+ export const ul: Styles = [
446
+ displayBlock,
447
+ {
448
+ property: "listStyleType",
449
+ value: { type: "keyword", value: "disc" },
450
+ },
451
+ mt1em,
452
+ mb1em,
453
+ pl40px,
454
+ ];
455
+
456
+ export const ol: Styles = [
457
+ displayBlock,
458
+ {
459
+ property: "listStyleType",
460
+ value: { type: "keyword", value: "decimal" },
461
+ },
462
+ mt1em,
463
+ mb1em,
464
+ pl40px,
465
+ ];
466
+
467
+ export const li: Styles = [
468
+ {
469
+ property: "display",
470
+ value: { type: "keyword", value: "list-item" },
471
+ },
472
+ {
473
+ property: "textAlign",
474
+ value: { type: "keyword", value: "match-parent" },
475
+ },
476
+ ];
477
+
478
+ /* leafs */
479
+
480
+ export const hr: Styles = [
481
+ {
482
+ property: "color",
483
+ value: { type: "keyword", value: "gray" },
484
+ },
485
+
486
+ {
487
+ property: "borderTopWidth",
488
+ value: { type: "unit", value: 1, unit: "px" },
489
+ },
490
+ {
491
+ property: "borderRightWidth",
492
+ value: { type: "unit", value: 1, unit: "px" },
493
+ },
494
+ {
495
+ property: "borderBottomWidth",
496
+ value: { type: "unit", value: 1, unit: "px" },
497
+ },
498
+ {
499
+ property: "borderLeftWidth",
500
+ value: { type: "unit", value: 1, unit: "px" },
501
+ },
502
+
503
+ {
504
+ property: "borderTopStyle",
505
+ value: { type: "keyword", value: "inset" },
506
+ },
507
+ {
508
+ property: "borderRightStyle",
509
+ value: { type: "keyword", value: "inset" },
510
+ },
511
+ {
512
+ property: "borderBottomStyle",
513
+ value: { type: "keyword", value: "inset" },
514
+ },
515
+ {
516
+ property: "borderLeftStyle",
517
+ value: { type: "keyword", value: "inset" },
518
+ },
519
+
520
+ {
521
+ property: "marginTop",
522
+ value: { type: "unit", value: 0.5, unit: "em" },
523
+ },
524
+ {
525
+ property: "marginBottom",
526
+ value: { type: "unit", value: 0.5, unit: "em" },
527
+ },
528
+ {
529
+ property: "marginLeft",
530
+ value: { type: "keyword", value: "auto" },
531
+ },
532
+ {
533
+ property: "marginRight",
534
+ value: { type: "keyword", value: "auto" },
535
+ },
536
+
537
+ // firefox only
538
+ {
539
+ property: "overflow",
540
+ value: { type: "keyword", value: "hidden" },
541
+ },
542
+
543
+ /* This is not really per spec but all browsers define it */
544
+ displayBlock,
545
+ ];
package/src/index.ts CHANGED
@@ -1,3 +1,7 @@
1
+ import type { Html } from "./html";
2
+ import * as exportedHtml from "./html";
3
+ export const html: Html = exportedHtml;
4
+
1
5
  export * from "./__generated__/keyword-values";
2
6
  export * from "./__generated__/properties";
3
7
  export * from "./__generated__/units";