@zazz-ui/core 0.6.1 → 0.6.3

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 (55) hide show
  1. package/AUTHORING.md +5 -3
  2. package/CHANGELOG.md +46 -0
  3. package/README.md +5 -5
  4. package/dist/csp-D72qtdXZ.js +1 -0
  5. package/dist/sri.json +18 -15
  6. package/dist/zazz.css +1 -1
  7. package/dist/zazz.js +1 -1
  8. package/editor/zazz.css-data.json +2028 -0
  9. package/editor/zazz.language-data.json +15 -3
  10. package/package.json +1 -1
  11. package/src/base/_reset.css +9 -17
  12. package/src/base/_utilities-color.css +3 -0
  13. package/src/base/_utilities-spacing.css +35 -0
  14. package/src/base/_variables.css +4 -0
  15. package/src/base/csp.d.ts +19 -0
  16. package/src/base/csp.d.ts.map +1 -0
  17. package/src/base/csp.js +131 -0
  18. package/src/base/csp.ts +137 -0
  19. package/src/base/declarations.d.ts +36 -0
  20. package/src/base/declarations.d.ts.map +1 -0
  21. package/src/base/declarations.js +70 -0
  22. package/src/base/declarations.ts +97 -0
  23. package/src/base/style-format.d.ts +3 -22
  24. package/src/base/style-format.d.ts.map +1 -1
  25. package/src/base/style-format.js +4 -62
  26. package/src/base/style-format.ts +4 -71
  27. package/src/base/utilities.d.ts.map +1 -1
  28. package/src/base/utilities.js +35 -17
  29. package/src/base/utilities.ts +42 -20
  30. package/src/head.d.ts +6 -0
  31. package/src/head.d.ts.map +1 -1
  32. package/src/head.js +21 -14
  33. package/src/head.ts +38 -11
  34. package/src/index.js +22 -0
  35. package/src/index.ts +19 -0
  36. package/src/manifest.d.ts +21 -1
  37. package/src/manifest.d.ts.map +1 -1
  38. package/src/manifest.js +10 -1
  39. package/src/manifest.ts +25 -1
  40. package/src/primitives/badge/badge.css +61 -111
  41. package/src/primitives/badge/badge.html +5 -0
  42. package/src/primitives/button/button.css +55 -53
  43. package/src/primitives/button/button.html +4 -0
  44. package/src/primitives/callout/callout.css +35 -10
  45. package/src/primitives/debug/audit-core.d.ts +1 -1
  46. package/src/primitives/debug/audit-core.d.ts.map +1 -1
  47. package/src/primitives/debug/audit-core.js +35 -5
  48. package/src/primitives/debug/audit-core.ts +42 -4
  49. package/src/primitives/prose/prose.html +3 -3
  50. package/src/primitives/table/table-size-sm.html +12 -12
  51. package/src/primitives/utilities/aspect-ratio.html +1 -0
  52. package/src/primitives/utilities/margin-auto.html +1 -1
  53. package/src/primitives/utilities/overflow.html +5 -6
  54. package/src/primitives/utilities/position.html +1 -1
  55. package/src/primitives/utilities/width.html +2 -1
@@ -1241,7 +1241,7 @@
1241
1241
  "file": "primitives/badge/badge.css"
1242
1242
  },
1243
1243
  "--ui-badge-h": {
1244
- "value": "calc(var(--spacing) * 5.5)",
1244
+ "value": "calc(var(--spacing) * 5)",
1245
1245
  "file": "primitives/badge/badge.css"
1246
1246
  },
1247
1247
  "--ui-badge-icon-size": {
@@ -1253,7 +1253,7 @@
1253
1253
  "file": "primitives/badge/badge.css"
1254
1254
  },
1255
1255
  "--ui-badge-px": {
1256
- "value": "calc(var(--spacing) * 1.5)",
1256
+ "value": "calc(var(--spacing) * 1.25)",
1257
1257
  "file": "primitives/badge/badge.css"
1258
1258
  },
1259
1259
  "--ui-badge-ring-color": {
@@ -1341,7 +1341,7 @@
1341
1341
  "file": "primitives/button/button.css"
1342
1342
  },
1343
1343
  "--ui-button-leading": {
1344
- "value": "var(--leading-sm)",
1344
+ "value": "1",
1345
1345
  "file": "primitives/button/button.css"
1346
1346
  },
1347
1347
  "--ui-button-min-h": {
@@ -3884,6 +3884,18 @@
3884
3884
  "light": "oklch(1 0 0)",
3885
3885
  "dark": "oklch(13% 0.028 261.692)"
3886
3886
  },
3887
+ "--color-selection": {
3888
+ "value": "var(--color-primary)",
3889
+ "file": "base/_variables.css",
3890
+ "light": "oklch(0.145 0 0)",
3891
+ "dark": "oklch(0.985 0 0)"
3892
+ },
3893
+ "--color-selection-foreground": {
3894
+ "value": "var(--color-primary-foreground)",
3895
+ "file": "base/_variables.css",
3896
+ "light": "oklch(1 0 0)",
3897
+ "dark": "oklch(0.145 0 0)"
3898
+ },
3887
3899
  "--color-shade-100": {
3888
3900
  "value": "oklch(from var(--color-neutral-950) l c h / 0.1)",
3889
3901
  "file": "base/_variables.css",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zazz-ui/core",
3
- "version": "0.6.1",
3
+ "version": "0.6.3",
4
4
  "description": "Zazz Design Framework — a zero-build, semantic-token CSS + vanilla JS UI kit built on modern web standards.",
5
5
  "keywords": [
6
6
  "cascade-layers",
@@ -10,11 +10,11 @@
10
10
  * @uses view-transition-name via the <main> tag - main-content and [data-transition-layer] —
11
11
  * global (animated in _view-transitions.css)
12
12
  * @uses text-box — vertical trim on headings
13
- * @uses color-mix(), oklch(from …), contrast-color() — mark/highlight tints
14
13
  * @tokens Native-element hooks declared in each element's rule (override them
15
14
  * on the element): --code-* (incl. --code-font-family), --search-cancel-*,
16
15
  * --placeholder-color, --strong-font-weight, --hr-bg,
17
- * --optgroup-font-weight, --optgroup-option-pl; --selection-bg on html
16
+ * --optgroup-font-weight, --optgroup-option-pl. Text selection reads
17
+ * --color-selection / --color-selection-foreground (_variables.css)
18
18
  *
19
19
  * Checkbox, range, switch, select picker, popover and dialog internals live in
20
20
  * their primitive stylesheets.
@@ -43,8 +43,6 @@
43
43
  -webkit-text-size-adjust: 100%;
44
44
  background-color: var(--color-background);
45
45
  -webkit-tap-highlight-color: transparent;
46
- /* text selection tint (::selection reads it from the selected element) */
47
- --selection-bg: oklch(from var(--color-primary) calc(l + 0.1) c h / 0.3);
48
46
 
49
47
  /* html (the viewport) is the page's scrolling element, as browsers expect */
50
48
  scroll-behavior: smooth;
@@ -256,12 +254,12 @@
256
254
  }
257
255
  }
258
256
 
259
- /* Custom text selection styling — the tinted background is safe everywhere
260
- (relative oklch is Baseline). contrast-color() is Chromium-only, so it is
261
- gated: without it the selection keeps its inherited text color, which stays
262
- legible against a 30%-opacity tint in both light and dark modes.
257
+ /* Text selection: an opaque --color-selection fill with its own
258
+ --color-selection-foreground text, a role pair like primary, so contrast
259
+ comes from the pair rather than a tint over unknown content.
263
260
 
264
- On :root only, on purpose: highlight pseudo-elements inherit from the
261
+ On :root only, on purpose (so the tokens only take effect on :root; set on
262
+ a subtree they change nothing): highlight pseudo-elements inherit from the
265
263
  parent's highlight pseudo-element (css-pseudo-4 highlight inheritance:
266
264
  Chrome 134+, Firefox, WebKit), so one rule reaches every selection. A
267
265
  universal `::selection` rule that reads a var() makes Chromium recalculate
@@ -270,14 +268,8 @@
270
268
  children, 194 ms per frame; 0.4 ms with this form). Engines without
271
269
  highlight inheritance fall back to the UA selection color. */
272
270
  :root::selection {
273
- background-color: var(--selection-bg);
274
- }
275
-
276
- @supports (color: contrast-color(white)) {
277
- :root::selection {
278
- /* legible on the 30% primary tint over the background */
279
- color: contrast-color(color-mix(in oklch, var(--color-background) 50%, var(--selection-bg)));
280
- }
271
+ background-color: var(--color-selection);
272
+ color: var(--color-selection-foreground);
281
273
  }
282
274
 
283
275
  /* ===========================================================================
@@ -17,6 +17,9 @@
17
17
  --_bg: var(--bg);
18
18
  background-color: oklch(from var(--_bg-resolved) l c h / calc(alpha * var(--_bg-alpha-resolved, 1)));
19
19
  }
20
+ :where(:is([style*="--bg:"], [style*="--bg--"], [style*="--group-bg--"]):not(ui-accordion, ui-autocomplete, ui-button-group, ui-carousel, ui-combobox, ui-command, ui-kbd-group, ui-layout, ui-lightbox, ui-menu, ui-multiselect, ui-otp, ui-password, ui-tabs, ui-toaster, ui-toggle-group, ui-tooltip, [data-ui~="accordion"], [data-ui~="alert-dialog"], [data-ui~="autocomplete"], [data-ui~="badge"], [data-ui~="button"], [data-ui~="button-group"], [data-ui~="callout"], [data-ui~="card"], [data-ui~="carousel"], [data-ui~="combobox"], [data-ui~="command"], [data-ui~="dialog"], [data-ui~="field"], [data-ui~="field-group"], [data-ui~="input"], [data-ui~="input-group"], [data-ui~="kbd-group"], [data-ui~="layout"], [data-ui~="lightbox"], [data-ui~="menu"], [data-ui~="meter"], [data-ui~="mobile-menu"], [data-ui~="multiselect"], [data-ui~="navigation-menu"], [data-ui~="otp"], [data-ui~="password-group"], [data-ui~="progress"], [data-ui~="radio"], [data-ui~="radio-group"], [data-ui~="scroll-fade"], [data-ui~="select"], [data-ui~="separator"], [data-ui~="table"], [data-ui~="tabs"], [data-ui~="textarea"], [data-ui~="toaster"], [data-ui~="toggle"], [data-ui~="toggle-group"], [data-ui~="tooltip"], code, hr)) {
21
+ background-color: oklch(from var(--_bg-resolved, transparent) l c h / calc(alpha * var(--_bg-alpha-resolved, 1)));
22
+ }
20
23
 
21
24
  :where([style*="--bg-alpha:"], [style*="--bg-alpha--"], [style*="--group-bg-alpha--"]) {
22
25
  --_bg-alpha-resolved: var(--_bg-alpha-starting, var(--_bg-alpha-disabled, var(--_bg-alpha-active, var(--_bg-alpha-focus-visible, var(--_bg-alpha-focus-within, var(--_bg-alpha-hover, var(--_bg-alpha-checked, var(--_bg-alpha-current, var(--_bg-alpha-open, var(--_bg-alpha-g-disabled, var(--_bg-alpha-g-active, var(--_bg-alpha-g-focus-visible, var(--_bg-alpha-g-focus-within, var(--_bg-alpha-g-hover, var(--_bg-alpha-g-checked, var(--_bg-alpha-g-current, var(--_bg-alpha-g-open, var(--_bg-alpha-stuck, var(--_bg-alpha-2xl, var(--_bg-alpha-xl, var(--_bg-alpha-lg, var(--_bg-alpha-md, var(--_bg-alpha-sm, var(--_bg-alpha))))))))))))))))))))))));
@@ -11,6 +11,11 @@
11
11
  --_p-num: var(--_p-resolved);
12
12
  padding: calc(var(--_p-len) + var(--_p-num) * var(--spacing));
13
13
  }
14
+ :where(:is([style*="--p:"], [style*="--p--"], [style*="--group-p--"]):not(ui-accordion, ui-autocomplete, ui-button-group, ui-carousel, ui-combobox, ui-command, ui-kbd-group, ui-layout, ui-lightbox, ui-menu, ui-multiselect, ui-otp, ui-password, ui-tabs, ui-toaster, ui-toggle-group, ui-tooltip, [data-ui~="accordion"], [data-ui~="alert-dialog"], [data-ui~="autocomplete"], [data-ui~="badge"], [data-ui~="button"], [data-ui~="button-group"], [data-ui~="callout"], [data-ui~="card"], [data-ui~="carousel"], [data-ui~="combobox"], [data-ui~="command"], [data-ui~="dialog"], [data-ui~="field"], [data-ui~="field-group"], [data-ui~="input"], [data-ui~="input-group"], [data-ui~="kbd-group"], [data-ui~="layout"], [data-ui~="lightbox"], [data-ui~="menu"], [data-ui~="meter"], [data-ui~="mobile-menu"], [data-ui~="multiselect"], [data-ui~="navigation-menu"], [data-ui~="otp"], [data-ui~="password-group"], [data-ui~="progress"], [data-ui~="radio"], [data-ui~="radio-group"], [data-ui~="scroll-fade"], [data-ui~="select"], [data-ui~="separator"], [data-ui~="table"], [data-ui~="tabs"], [data-ui~="textarea"], [data-ui~="toaster"], [data-ui~="toggle"], [data-ui~="toggle-group"], [data-ui~="tooltip"], [data-ui~="prose"] :is(ul, ol, dd, blockquote, cite), code, button, input, select, textarea, optgroup)) {
15
+ --_p-len: var(--_p-resolved, 0);
16
+ --_p-num: var(--_p-resolved, 0);
17
+ padding: calc(var(--_p-len) + var(--_p-num) * var(--spacing));
18
+ }
14
19
 
15
20
  :where([style*="--px:"], [style*="--px--"]) {
16
21
  --_px-resolved: var(--_px-2xl, var(--_px-xl, var(--_px-lg, var(--_px-md, var(--_px-sm, var(--_px))))));
@@ -21,6 +26,11 @@
21
26
  --_px-num: var(--_px-resolved);
22
27
  padding-inline: calc(var(--_px-len) + var(--_px-num) * var(--spacing));
23
28
  }
29
+ :where(:is([style*="--px:"], [style*="--px--"], [style*="--group-px--"]):not(ui-accordion, ui-autocomplete, ui-button-group, ui-carousel, ui-combobox, ui-command, ui-kbd-group, ui-layout, ui-lightbox, ui-menu, ui-multiselect, ui-otp, ui-password, ui-tabs, ui-toaster, ui-toggle-group, ui-tooltip, [data-ui~="accordion"], [data-ui~="alert-dialog"], [data-ui~="autocomplete"], [data-ui~="badge"], [data-ui~="button"], [data-ui~="button-group"], [data-ui~="callout"], [data-ui~="card"], [data-ui~="carousel"], [data-ui~="combobox"], [data-ui~="command"], [data-ui~="dialog"], [data-ui~="field"], [data-ui~="field-group"], [data-ui~="input"], [data-ui~="input-group"], [data-ui~="kbd-group"], [data-ui~="layout"], [data-ui~="lightbox"], [data-ui~="menu"], [data-ui~="meter"], [data-ui~="mobile-menu"], [data-ui~="multiselect"], [data-ui~="navigation-menu"], [data-ui~="otp"], [data-ui~="password-group"], [data-ui~="progress"], [data-ui~="radio"], [data-ui~="radio-group"], [data-ui~="scroll-fade"], [data-ui~="select"], [data-ui~="separator"], [data-ui~="table"], [data-ui~="tabs"], [data-ui~="textarea"], [data-ui~="toaster"], [data-ui~="toggle"], [data-ui~="toggle-group"], [data-ui~="tooltip"], [data-ui~="prose"] :is(ul, ol, dd, blockquote, cite), code, button, input, select, textarea, optgroup)) {
30
+ --_px-len: var(--_px-resolved, 0);
31
+ --_px-num: var(--_px-resolved, 0);
32
+ padding-inline: calc(var(--_px-len) + var(--_px-num) * var(--spacing));
33
+ }
24
34
 
25
35
  :where([style*="--py:"], [style*="--py--"]) {
26
36
  --_py-resolved: var(--_py-2xl, var(--_py-xl, var(--_py-lg, var(--_py-md, var(--_py-sm, var(--_py))))));
@@ -31,6 +41,11 @@
31
41
  --_py-num: var(--_py-resolved);
32
42
  padding-block: calc(var(--_py-len) + var(--_py-num) * var(--spacing));
33
43
  }
44
+ :where(:is([style*="--py:"], [style*="--py--"], [style*="--group-py--"]):not(ui-accordion, ui-autocomplete, ui-button-group, ui-carousel, ui-combobox, ui-command, ui-kbd-group, ui-layout, ui-lightbox, ui-menu, ui-multiselect, ui-otp, ui-password, ui-tabs, ui-toaster, ui-toggle-group, ui-tooltip, [data-ui~="accordion"], [data-ui~="alert-dialog"], [data-ui~="autocomplete"], [data-ui~="badge"], [data-ui~="button"], [data-ui~="button-group"], [data-ui~="callout"], [data-ui~="card"], [data-ui~="carousel"], [data-ui~="combobox"], [data-ui~="command"], [data-ui~="dialog"], [data-ui~="field"], [data-ui~="field-group"], [data-ui~="input"], [data-ui~="input-group"], [data-ui~="kbd-group"], [data-ui~="layout"], [data-ui~="lightbox"], [data-ui~="menu"], [data-ui~="meter"], [data-ui~="mobile-menu"], [data-ui~="multiselect"], [data-ui~="navigation-menu"], [data-ui~="otp"], [data-ui~="password-group"], [data-ui~="progress"], [data-ui~="radio"], [data-ui~="radio-group"], [data-ui~="scroll-fade"], [data-ui~="select"], [data-ui~="separator"], [data-ui~="table"], [data-ui~="tabs"], [data-ui~="textarea"], [data-ui~="toaster"], [data-ui~="toggle"], [data-ui~="toggle-group"], [data-ui~="tooltip"], [data-ui~="prose"] :is(ul, ol, dd, blockquote, cite), code, button, input, select, textarea, optgroup)) {
45
+ --_py-len: var(--_py-resolved, 0);
46
+ --_py-num: var(--_py-resolved, 0);
47
+ padding-block: calc(var(--_py-len) + var(--_py-num) * var(--spacing));
48
+ }
34
49
 
35
50
  :where([style*="--pt:"], [style*="--pt--"]) {
36
51
  --_pt-resolved: var(--_pt-2xl, var(--_pt-xl, var(--_pt-lg, var(--_pt-md, var(--_pt-sm, var(--_pt))))));
@@ -41,6 +56,11 @@
41
56
  --_pt-num: var(--_pt-resolved);
42
57
  padding-block-start: calc(var(--_pt-len) + var(--_pt-num) * var(--spacing));
43
58
  }
59
+ :where(:is([style*="--pt:"], [style*="--pt--"], [style*="--group-pt--"]):not(ui-accordion, ui-autocomplete, ui-button-group, ui-carousel, ui-combobox, ui-command, ui-kbd-group, ui-layout, ui-lightbox, ui-menu, ui-multiselect, ui-otp, ui-password, ui-tabs, ui-toaster, ui-toggle-group, ui-tooltip, [data-ui~="accordion"], [data-ui~="alert-dialog"], [data-ui~="autocomplete"], [data-ui~="badge"], [data-ui~="button"], [data-ui~="button-group"], [data-ui~="callout"], [data-ui~="card"], [data-ui~="carousel"], [data-ui~="combobox"], [data-ui~="command"], [data-ui~="dialog"], [data-ui~="field"], [data-ui~="field-group"], [data-ui~="input"], [data-ui~="input-group"], [data-ui~="kbd-group"], [data-ui~="layout"], [data-ui~="lightbox"], [data-ui~="menu"], [data-ui~="meter"], [data-ui~="mobile-menu"], [data-ui~="multiselect"], [data-ui~="navigation-menu"], [data-ui~="otp"], [data-ui~="password-group"], [data-ui~="progress"], [data-ui~="radio"], [data-ui~="radio-group"], [data-ui~="scroll-fade"], [data-ui~="select"], [data-ui~="separator"], [data-ui~="table"], [data-ui~="tabs"], [data-ui~="textarea"], [data-ui~="toaster"], [data-ui~="toggle"], [data-ui~="toggle-group"], [data-ui~="tooltip"], [data-ui~="prose"] :is(ul, ol, dd, blockquote, cite), code, button, input, select, textarea, optgroup)) {
60
+ --_pt-len: var(--_pt-resolved, 0);
61
+ --_pt-num: var(--_pt-resolved, 0);
62
+ padding-block-start: calc(var(--_pt-len) + var(--_pt-num) * var(--spacing));
63
+ }
44
64
 
45
65
  :where([style*="--pb:"], [style*="--pb--"]) {
46
66
  --_pb-resolved: var(--_pb-2xl, var(--_pb-xl, var(--_pb-lg, var(--_pb-md, var(--_pb-sm, var(--_pb))))));
@@ -51,6 +71,11 @@
51
71
  --_pb-num: var(--_pb-resolved);
52
72
  padding-block-end: calc(var(--_pb-len) + var(--_pb-num) * var(--spacing));
53
73
  }
74
+ :where(:is([style*="--pb:"], [style*="--pb--"], [style*="--group-pb--"]):not(ui-accordion, ui-autocomplete, ui-button-group, ui-carousel, ui-combobox, ui-command, ui-kbd-group, ui-layout, ui-lightbox, ui-menu, ui-multiselect, ui-otp, ui-password, ui-tabs, ui-toaster, ui-toggle-group, ui-tooltip, [data-ui~="accordion"], [data-ui~="alert-dialog"], [data-ui~="autocomplete"], [data-ui~="badge"], [data-ui~="button"], [data-ui~="button-group"], [data-ui~="callout"], [data-ui~="card"], [data-ui~="carousel"], [data-ui~="combobox"], [data-ui~="command"], [data-ui~="dialog"], [data-ui~="field"], [data-ui~="field-group"], [data-ui~="input"], [data-ui~="input-group"], [data-ui~="kbd-group"], [data-ui~="layout"], [data-ui~="lightbox"], [data-ui~="menu"], [data-ui~="meter"], [data-ui~="mobile-menu"], [data-ui~="multiselect"], [data-ui~="navigation-menu"], [data-ui~="otp"], [data-ui~="password-group"], [data-ui~="progress"], [data-ui~="radio"], [data-ui~="radio-group"], [data-ui~="scroll-fade"], [data-ui~="select"], [data-ui~="separator"], [data-ui~="table"], [data-ui~="tabs"], [data-ui~="textarea"], [data-ui~="toaster"], [data-ui~="toggle"], [data-ui~="toggle-group"], [data-ui~="tooltip"], [data-ui~="prose"] :is(ul, ol, dd, blockquote, cite), code, button, input, select, textarea, optgroup)) {
75
+ --_pb-len: var(--_pb-resolved, 0);
76
+ --_pb-num: var(--_pb-resolved, 0);
77
+ padding-block-end: calc(var(--_pb-len) + var(--_pb-num) * var(--spacing));
78
+ }
54
79
 
55
80
  :where([style*="--pl:"], [style*="--pl--"]) {
56
81
  --_pl-resolved: var(--_pl-2xl, var(--_pl-xl, var(--_pl-lg, var(--_pl-md, var(--_pl-sm, var(--_pl))))));
@@ -61,6 +86,11 @@
61
86
  --_pl-num: var(--_pl-resolved);
62
87
  padding-inline-start: calc(var(--_pl-len) + var(--_pl-num) * var(--spacing));
63
88
  }
89
+ :where(:is([style*="--pl:"], [style*="--pl--"], [style*="--group-pl--"]):not(ui-accordion, ui-autocomplete, ui-button-group, ui-carousel, ui-combobox, ui-command, ui-kbd-group, ui-layout, ui-lightbox, ui-menu, ui-multiselect, ui-otp, ui-password, ui-tabs, ui-toaster, ui-toggle-group, ui-tooltip, [data-ui~="accordion"], [data-ui~="alert-dialog"], [data-ui~="autocomplete"], [data-ui~="badge"], [data-ui~="button"], [data-ui~="button-group"], [data-ui~="callout"], [data-ui~="card"], [data-ui~="carousel"], [data-ui~="combobox"], [data-ui~="command"], [data-ui~="dialog"], [data-ui~="field"], [data-ui~="field-group"], [data-ui~="input"], [data-ui~="input-group"], [data-ui~="kbd-group"], [data-ui~="layout"], [data-ui~="lightbox"], [data-ui~="menu"], [data-ui~="meter"], [data-ui~="mobile-menu"], [data-ui~="multiselect"], [data-ui~="navigation-menu"], [data-ui~="otp"], [data-ui~="password-group"], [data-ui~="progress"], [data-ui~="radio"], [data-ui~="radio-group"], [data-ui~="scroll-fade"], [data-ui~="select"], [data-ui~="separator"], [data-ui~="table"], [data-ui~="tabs"], [data-ui~="textarea"], [data-ui~="toaster"], [data-ui~="toggle"], [data-ui~="toggle-group"], [data-ui~="tooltip"], [data-ui~="prose"] :is(ul, ol, dd, blockquote, cite), code, button, input, select, textarea, optgroup)) {
90
+ --_pl-len: var(--_pl-resolved, 0);
91
+ --_pl-num: var(--_pl-resolved, 0);
92
+ padding-inline-start: calc(var(--_pl-len) + var(--_pl-num) * var(--spacing));
93
+ }
64
94
 
65
95
  :where([style*="--pr:"], [style*="--pr--"]) {
66
96
  --_pr-resolved: var(--_pr-2xl, var(--_pr-xl, var(--_pr-lg, var(--_pr-md, var(--_pr-sm, var(--_pr))))));
@@ -71,6 +101,11 @@
71
101
  --_pr-num: var(--_pr-resolved);
72
102
  padding-inline-end: calc(var(--_pr-len) + var(--_pr-num) * var(--spacing));
73
103
  }
104
+ :where(:is([style*="--pr:"], [style*="--pr--"], [style*="--group-pr--"]):not(ui-accordion, ui-autocomplete, ui-button-group, ui-carousel, ui-combobox, ui-command, ui-kbd-group, ui-layout, ui-lightbox, ui-menu, ui-multiselect, ui-otp, ui-password, ui-tabs, ui-toaster, ui-toggle-group, ui-tooltip, [data-ui~="accordion"], [data-ui~="alert-dialog"], [data-ui~="autocomplete"], [data-ui~="badge"], [data-ui~="button"], [data-ui~="button-group"], [data-ui~="callout"], [data-ui~="card"], [data-ui~="carousel"], [data-ui~="combobox"], [data-ui~="command"], [data-ui~="dialog"], [data-ui~="field"], [data-ui~="field-group"], [data-ui~="input"], [data-ui~="input-group"], [data-ui~="kbd-group"], [data-ui~="layout"], [data-ui~="lightbox"], [data-ui~="menu"], [data-ui~="meter"], [data-ui~="mobile-menu"], [data-ui~="multiselect"], [data-ui~="navigation-menu"], [data-ui~="otp"], [data-ui~="password-group"], [data-ui~="progress"], [data-ui~="radio"], [data-ui~="radio-group"], [data-ui~="scroll-fade"], [data-ui~="select"], [data-ui~="separator"], [data-ui~="table"], [data-ui~="tabs"], [data-ui~="textarea"], [data-ui~="toaster"], [data-ui~="toggle"], [data-ui~="toggle-group"], [data-ui~="tooltip"], [data-ui~="prose"] :is(ul, ol, dd, blockquote, cite), code, button, input, select, textarea, optgroup)) {
105
+ --_pr-len: var(--_pr-resolved, 0);
106
+ --_pr-num: var(--_pr-resolved, 0);
107
+ padding-inline-end: calc(var(--_pr-len) + var(--_pr-num) * var(--spacing));
108
+ }
74
109
 
75
110
  :where([style*="--gap:"], [style*="--gap--"]) {
76
111
  --_gap-resolved: var(--_gap-2xl, var(--_gap-xl, var(--_gap-lg, var(--_gap-md, var(--_gap-sm, var(--_gap))))));
@@ -64,6 +64,10 @@
64
64
  --color-input: light-dark(var(--color-neutral-50), var(--color-tint-100));
65
65
  --color-input-foreground: light-dark(var(--color-neutral-900), var(--color-white));
66
66
 
67
+ /* selection */
68
+ --color-selection: var(--color-primary);
69
+ --color-selection-foreground: var(--color-primary-foreground);
70
+
67
71
  /* overlay */
68
72
  --color-muted: light-dark(var(--color-shade-50), var(--color-tint-100));
69
73
  --color-muted-foreground: light-dark(var(--color-shade-600), var(--color-tint-600));
@@ -0,0 +1,19 @@
1
+ /** True when the document's policy blocks inline style attributes (some styled element has an empty declaration block). */
2
+ declare function blockedInlineStyles(root?: ParentNode): boolean;
3
+ /** Writes `el`'s `style` attribute into its declaration block through the CSSOM. No-op when the block already matches. */
4
+ declare function applyInlineStyles(el: Element): void;
5
+ /**
6
+ * @namespace Csp
7
+ * @property {Function} blockedInlineStyles - True when the policy blocks inline style attributes.
8
+ * @property {Function} applyInlineStyles - Applies one element's blocked attribute through the CSSOM.
9
+ * @property {Function} start - Applies every blocked attribute under `root` (default `document.body`) and watches for new ones.
10
+ * @property {Function} stop - Stops watching.
11
+ */
12
+ declare const Csp: {
13
+ blockedInlineStyles: typeof blockedInlineStyles;
14
+ applyInlineStyles: typeof applyInlineStyles;
15
+ start(root?: Element): void;
16
+ stop(): void;
17
+ };
18
+ export { Csp };
19
+ //# sourceMappingURL=csp.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"csp.d.ts","sourceRoot":"","sources":["csp.ts"],"names":[],"mappings":"AAsCA,2HAA2H;AAC3H,iBAAS,mBAAmB,CAAC,IAAI,GAAE,UAAqB,GAAG,OAAO,CAGjE;AA8BD,0HAA0H;AAC1H,iBAAS,iBAAiB,CAAC,EAAE,EAAE,OAAO,GAAG,IAAI,CAQ5C;AAkBD;;;;;;GAMG;AACH,QAAA,MAAM,GAAG;;;iBAGK,OAAO,GAAmB,IAAI;YAWlC,IAAI;CAIb,CAAC;AAYF,OAAO,EAAE,GAAG,EAAE,CAAC"}
@@ -0,0 +1,131 @@
1
+ "use strict";
2
+ /**
3
+ * @fileoverview CSP fallback: applies `style` attributes a Content Security Policy blocked.
4
+ * @description Loaded by `index.ts` only when the page's policy blocks inline
5
+ * style attributes (`style-src-attr` without `'unsafe-inline'`, or a
6
+ * `style-src` without it): the attribute text is still in the DOM, so the
7
+ * kit's `[style*="--p:"]` gates still match, but none of its values apply.
8
+ * CSP does not govern the CSSOM, so this module reads each attribute and
9
+ * writes its declarations with `style.setProperty`, one by one (never
10
+ * `cssText` or `setAttribute`, which the policy blocks), then watches for
11
+ * attributes written later. Utilities then need JavaScript and apply after the
12
+ * module runs; a policy that allows attributes (`style-src-attr
13
+ * 'unsafe-inline'`) needs none of this. `data-ui-guard="off"` opts an element
14
+ * out, as it does for the style guard.
15
+ *
16
+ * Detection never writes a probe: it looks for an element whose attribute
17
+ * holds a declaration while its declaration block is empty, which is what a
18
+ * blocked attribute looks like on load, so the kit never raises a violation
19
+ * report of its own. A blocked write to an element that already has a block
20
+ * (an app's `setAttribute("style", …)` after the fallback ran) leaves the old
21
+ * block in place, so each apply compares the attribute's declarations with
22
+ * the block and rewrites the block only when they differ.
23
+ */
24
+ import { plainValue, scanDeclarations } from "./declarations.js";
25
+ // --- Detection ---
26
+ /** True when `el` carries a `style` attribute with a declaration that the policy did not apply. */
27
+ function blocked(el) {
28
+ if (!("style" in el))
29
+ return false;
30
+ const text = el.getAttribute("style");
31
+ return !!text && text.includes(":") && el.style.length === 0;
32
+ }
33
+ /** True when the document's policy blocks inline style attributes (some styled element has an empty declaration block). */
34
+ function blockedInlineStyles(root = document) {
35
+ for (const el of root.querySelectorAll("[style]"))
36
+ if (blocked(el))
37
+ return true;
38
+ return false;
39
+ }
40
+ // --- Apply ---
41
+ /** name → [value, priority] of the attribute's declarations, as `setProperty` takes them. */
42
+ function declared(text) {
43
+ const out = new Map();
44
+ for (const declaration of scanDeclarations(text)) {
45
+ if (declaration.colon !== -1) {
46
+ out.set(declaration.name, [plainValue(declaration), declaration.priority]);
47
+ }
48
+ }
49
+ return out;
50
+ }
51
+ /** True when the declaration block already holds exactly the attribute's declarations. */
52
+ function inSync(el, wanted) {
53
+ const { style } = el;
54
+ if (style.length !== wanted.size)
55
+ return false;
56
+ for (const [name, [value, priority]] of wanted) {
57
+ if (style.getPropertyValue(name).trim() !== value.trim() ||
58
+ style.getPropertyPriority(name) !== priority) {
59
+ return false;
60
+ }
61
+ }
62
+ return true;
63
+ }
64
+ /** Writes `el`'s `style` attribute into its declaration block through the CSSOM. No-op when the block already matches. */
65
+ function applyInlineStyles(el) {
66
+ if (!("style" in el) || el.getAttribute("data-ui-guard") === "off")
67
+ return;
68
+ const styled = el;
69
+ const wanted = declared(el.getAttribute("style") ?? "");
70
+ if (inSync(styled, wanted))
71
+ return;
72
+ // a blocked write leaves the previous block behind; the attribute is the truth
73
+ for (const name of [...styled.style].reverse())
74
+ styled.style.removeProperty(name);
75
+ for (const [name, [value, priority]] of wanted)
76
+ styled.style.setProperty(name, value, priority);
77
+ }
78
+ function applyAll(root) {
79
+ if (root instanceof Element)
80
+ applyInlineStyles(root);
81
+ for (const el of root.querySelectorAll("[style]"))
82
+ applyInlineStyles(el);
83
+ }
84
+ // --- Observe ---
85
+ let observer = null;
86
+ function onMutations(mutations) {
87
+ for (const mutation of mutations) {
88
+ if (mutation.type === "attributes")
89
+ applyInlineStyles(mutation.target);
90
+ for (const node of mutation.addedNodes)
91
+ if (node instanceof Element)
92
+ applyAll(node);
93
+ }
94
+ }
95
+ /**
96
+ * @namespace Csp
97
+ * @property {Function} blockedInlineStyles - True when the policy blocks inline style attributes.
98
+ * @property {Function} applyInlineStyles - Applies one element's blocked attribute through the CSSOM.
99
+ * @property {Function} start - Applies every blocked attribute under `root` (default `document.body`) and watches for new ones.
100
+ * @property {Function} stop - Stops watching.
101
+ */
102
+ const Csp = {
103
+ blockedInlineStyles,
104
+ applyInlineStyles,
105
+ start(root = document.body) {
106
+ Csp.stop();
107
+ applyAll(root);
108
+ observer = new MutationObserver(onMutations);
109
+ observer.observe(root, {
110
+ attributes: true,
111
+ attributeFilter: ["style"],
112
+ childList: true,
113
+ subtree: true,
114
+ });
115
+ },
116
+ stop() {
117
+ observer?.disconnect();
118
+ observer = null;
119
+ },
120
+ };
121
+ // Auto-initialize in the browser once the DOM is ready (index.ts imports this
122
+ // module only when it has already seen a blocked attribute)
123
+ if (typeof window !== "undefined" && typeof document !== "undefined") {
124
+ if (document.readyState === "loading") {
125
+ document.addEventListener("DOMContentLoaded", () => Csp.start());
126
+ }
127
+ else {
128
+ Csp.start();
129
+ }
130
+ }
131
+ export { Csp };
@@ -0,0 +1,137 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * @fileoverview CSP fallback: applies `style` attributes a Content Security Policy blocked.
5
+ * @description Loaded by `index.ts` only when the page's policy blocks inline
6
+ * style attributes (`style-src-attr` without `'unsafe-inline'`, or a
7
+ * `style-src` without it): the attribute text is still in the DOM, so the
8
+ * kit's `[style*="--p:"]` gates still match, but none of its values apply.
9
+ * CSP does not govern the CSSOM, so this module reads each attribute and
10
+ * writes its declarations with `style.setProperty`, one by one (never
11
+ * `cssText` or `setAttribute`, which the policy blocks), then watches for
12
+ * attributes written later. Utilities then need JavaScript and apply after the
13
+ * module runs; a policy that allows attributes (`style-src-attr
14
+ * 'unsafe-inline'`) needs none of this. `data-ui-guard="off"` opts an element
15
+ * out, as it does for the style guard.
16
+ *
17
+ * Detection never writes a probe: it looks for an element whose attribute
18
+ * holds a declaration while its declaration block is empty, which is what a
19
+ * blocked attribute looks like on load, so the kit never raises a violation
20
+ * report of its own. A blocked write to an element that already has a block
21
+ * (an app's `setAttribute("style", …)` after the fallback ran) leaves the old
22
+ * block in place, so each apply compares the attribute's declarations with
23
+ * the block and rewrites the block only when they differ.
24
+ */
25
+
26
+ import { plainValue, scanDeclarations } from "./declarations.ts";
27
+
28
+ type Styled = Element & ElementCSSInlineStyle;
29
+
30
+ // --- Detection ---
31
+
32
+ /** True when `el` carries a `style` attribute with a declaration that the policy did not apply. */
33
+ function blocked(el: Element): el is Styled {
34
+ if (!("style" in el)) return false;
35
+ const text = el.getAttribute("style");
36
+ return !!text && text.includes(":") && (el as Styled).style.length === 0;
37
+ }
38
+
39
+ /** True when the document's policy blocks inline style attributes (some styled element has an empty declaration block). */
40
+ function blockedInlineStyles(root: ParentNode = document): boolean {
41
+ for (const el of root.querySelectorAll("[style]")) if (blocked(el)) return true;
42
+ return false;
43
+ }
44
+
45
+ // --- Apply ---
46
+
47
+ /** name → [value, priority] of the attribute's declarations, as `setProperty` takes them. */
48
+ function declared(text: string): Map<string, [string, string]> {
49
+ const out = new Map<string, [string, string]>();
50
+ for (const declaration of scanDeclarations(text)) {
51
+ if (declaration.colon !== -1) {
52
+ out.set(declaration.name, [plainValue(declaration), declaration.priority]);
53
+ }
54
+ }
55
+ return out;
56
+ }
57
+
58
+ /** True when the declaration block already holds exactly the attribute's declarations. */
59
+ function inSync(el: Styled, wanted: Map<string, [string, string]>): boolean {
60
+ const { style } = el;
61
+ if (style.length !== wanted.size) return false;
62
+ for (const [name, [value, priority]] of wanted) {
63
+ if (
64
+ style.getPropertyValue(name).trim() !== value.trim() ||
65
+ style.getPropertyPriority(name) !== priority
66
+ ) {
67
+ return false;
68
+ }
69
+ }
70
+ return true;
71
+ }
72
+
73
+ /** Writes `el`'s `style` attribute into its declaration block through the CSSOM. No-op when the block already matches. */
74
+ function applyInlineStyles(el: Element): void {
75
+ if (!("style" in el) || el.getAttribute("data-ui-guard") === "off") return;
76
+ const styled = el as Styled;
77
+ const wanted = declared(el.getAttribute("style") ?? "");
78
+ if (inSync(styled, wanted)) return;
79
+ // a blocked write leaves the previous block behind; the attribute is the truth
80
+ for (const name of [...styled.style].reverse()) styled.style.removeProperty(name);
81
+ for (const [name, [value, priority]] of wanted) styled.style.setProperty(name, value, priority);
82
+ }
83
+
84
+ function applyAll(root: ParentNode): void {
85
+ if (root instanceof Element) applyInlineStyles(root);
86
+ for (const el of root.querySelectorAll("[style]")) applyInlineStyles(el);
87
+ }
88
+
89
+ // --- Observe ---
90
+
91
+ let observer: MutationObserver | null = null;
92
+
93
+ function onMutations(mutations: MutationRecord[]): void {
94
+ for (const mutation of mutations) {
95
+ if (mutation.type === "attributes") applyInlineStyles(mutation.target as Element);
96
+ for (const node of mutation.addedNodes) if (node instanceof Element) applyAll(node);
97
+ }
98
+ }
99
+
100
+ /**
101
+ * @namespace Csp
102
+ * @property {Function} blockedInlineStyles - True when the policy blocks inline style attributes.
103
+ * @property {Function} applyInlineStyles - Applies one element's blocked attribute through the CSSOM.
104
+ * @property {Function} start - Applies every blocked attribute under `root` (default `document.body`) and watches for new ones.
105
+ * @property {Function} stop - Stops watching.
106
+ */
107
+ const Csp = {
108
+ blockedInlineStyles,
109
+ applyInlineStyles,
110
+ start(root: Element = document.body): void {
111
+ Csp.stop();
112
+ applyAll(root);
113
+ observer = new MutationObserver(onMutations);
114
+ observer.observe(root, {
115
+ attributes: true,
116
+ attributeFilter: ["style"],
117
+ childList: true,
118
+ subtree: true,
119
+ });
120
+ },
121
+ stop(): void {
122
+ observer?.disconnect();
123
+ observer = null;
124
+ },
125
+ };
126
+
127
+ // Auto-initialize in the browser once the DOM is ready (index.ts imports this
128
+ // module only when it has already seen a blocked attribute)
129
+ if (typeof window !== "undefined" && typeof document !== "undefined") {
130
+ if (document.readyState === "loading") {
131
+ document.addEventListener("DOMContentLoaded", () => Csp.start());
132
+ } else {
133
+ Csp.start();
134
+ }
135
+ }
136
+
137
+ export { Csp };
@@ -0,0 +1,36 @@
1
+ /**
2
+ * @fileoverview Splits a `style` attribute value into declarations.
3
+ * @description One parser for every reader of the attribute text: the
4
+ * formatter (`style-format.ts`), the language server, and the CSP fallback
5
+ * (`csp.ts`). Splits on top-level `;` only, so a `;` inside `url("…")`,
6
+ * `var(--x, …)`, or a quoted string stays in its value. No imports, so a
7
+ * runtime module can use it without pulling in the utility tables.
8
+ */
9
+ /** `[start, end)` offsets into a style value. */
10
+ export type Range = [number, number];
11
+ /** One declaration of a style value, with its parts' offsets (all trimmed). */
12
+ export interface ScannedDeclaration {
13
+ /** The whole declaration. */
14
+ span: Range;
15
+ /** The name; a declaration still being typed (`--p`) is all name. */
16
+ name: string;
17
+ nameSpan: Range;
18
+ /** Offset of the colon, or -1 when there is none yet. */
19
+ colon: number;
20
+ /** The value as written, `!important` included. */
21
+ value: string;
22
+ /** Empty (`[colon + 1, colon + 1]`) when nothing follows the colon. */
23
+ valueSpan: Range;
24
+ /** `"important"` when the value ends in `!important`, else `""` (what `setProperty` takes). */
25
+ priority: "" | "important";
26
+ }
27
+ /**
28
+ * Scans a style value into declarations, splitting on top-level `;` (not inside
29
+ * parentheses or quotes). Empty segments are skipped.
30
+ */
31
+ export declare function scanDeclarations(value: string): ScannedDeclaration[];
32
+ /** Splits a style value on top-level `;`, ignoring ones inside parentheses or quotes. */
33
+ export declare function splitDeclarations(value: string): string[];
34
+ /** A declaration's value without its `!important`, for `setProperty(name, value, priority)`. */
35
+ export declare function plainValue({ value }: ScannedDeclaration): string;
36
+ //# sourceMappingURL=declarations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"declarations.d.ts","sourceRoot":"","sources":["declarations.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AAIH,iDAAiD;AACjD,MAAM,MAAM,KAAK,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAErC,+EAA+E;AAC/E,MAAM,WAAW,kBAAkB;IACjC,6BAA6B;IAC7B,IAAI,EAAE,KAAK,CAAC;IACZ,qEAAqE;IACrE,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,KAAK,CAAC;IAChB,yDAAyD;IACzD,KAAK,EAAE,MAAM,CAAC;IACd,mDAAmD;IACnD,KAAK,EAAE,MAAM,CAAC;IACd,uEAAuE;IACvE,SAAS,EAAE,KAAK,CAAC;IACjB,+FAA+F;IAC/F,QAAQ,EAAE,EAAE,GAAG,WAAW,CAAC;CAC5B;AAWD;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,kBAAkB,EAAE,CAwCpE;AAED,yFAAyF;AACzF,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAEzD;AAED,gGAAgG;AAChG,wBAAgB,UAAU,CAAC,EAAE,KAAK,EAAE,EAAE,kBAAkB,GAAG,MAAM,CAEhE"}
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ /** Trims `[start, end)` of `text` to its non-whitespace extent. */
3
+ function trimRange(text, start, end) {
4
+ while (start < end && /\s/.test(text[start]))
5
+ start++;
6
+ while (end > start && /\s/.test(text[end - 1]))
7
+ end--;
8
+ return [start, end];
9
+ }
10
+ const IMPORTANT = /!\s*important$/i;
11
+ /**
12
+ * Scans a style value into declarations, splitting on top-level `;` (not inside
13
+ * parentheses or quotes). Empty segments are skipped.
14
+ */
15
+ export function scanDeclarations(value) {
16
+ const found = [];
17
+ const push = (from, to) => {
18
+ const span = trimRange(value, from, to);
19
+ if (span[0] === span[1])
20
+ return;
21
+ const colon = value.indexOf(":", span[0]);
22
+ const hasColon = colon !== -1 && colon < span[1];
23
+ const nameSpan = hasColon ? trimRange(value, span[0], colon) : span;
24
+ const valueSpan = hasColon
25
+ ? trimRange(value, colon + 1, span[1])
26
+ : [span[1], span[1]];
27
+ const text = value.slice(...valueSpan);
28
+ found.push({
29
+ span,
30
+ name: value.slice(...nameSpan),
31
+ nameSpan,
32
+ colon: hasColon ? colon : -1,
33
+ value: text,
34
+ valueSpan,
35
+ priority: IMPORTANT.test(text) ? "important" : "",
36
+ });
37
+ };
38
+ let depth = 0;
39
+ let quote = null;
40
+ let start = 0;
41
+ for (let i = 0; i < value.length; i++) {
42
+ const ch = value[i];
43
+ if (quote) {
44
+ if (ch === "\\")
45
+ i++;
46
+ else if (ch === quote)
47
+ quote = null;
48
+ }
49
+ else if (ch === '"' || ch === "'")
50
+ quote = ch;
51
+ else if (ch === "(")
52
+ depth++;
53
+ else if (ch === ")")
54
+ depth = Math.max(0, depth - 1);
55
+ else if (ch === ";" && depth === 0) {
56
+ push(start, i);
57
+ start = i + 1;
58
+ }
59
+ }
60
+ push(start, value.length);
61
+ return found;
62
+ }
63
+ /** Splits a style value on top-level `;`, ignoring ones inside parentheses or quotes. */
64
+ export function splitDeclarations(value) {
65
+ return scanDeclarations(value).map(({ span }) => value.slice(...span));
66
+ }
67
+ /** A declaration's value without its `!important`, for `setProperty(name, value, priority)`. */
68
+ export function plainValue({ value }) {
69
+ return value.replace(IMPORTANT, "").trimEnd();
70
+ }