@zazz-ui/core 0.4.1 → 0.5.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/AUTHORING.md +158 -0
- package/CHANGELOG.md +331 -0
- package/README.md +55 -23
- package/dist/scroll-state-C8mA5gq6.js +1 -0
- package/dist/sri.json +124 -72
- package/dist/zazz.css +1 -1
- package/dist/zazz.js +1 -1
- package/editor/zazz.css-data.json +116794 -0
- package/editor/zazz.html-data.json +1683 -0
- package/editor/zazz.language-data.json +5001 -0
- package/editor/zazz.lint-data.json +152 -0
- package/package.json +12 -5
- package/src/base/_breakpoints.css +12 -0
- package/src/base/_layers.css +8 -9
- package/src/base/_properties-2xl.css +171 -0
- package/src/base/_properties-active.css +107 -0
- package/src/base/_properties-checked.css +107 -0
- package/src/base/_properties-current.css +107 -0
- package/src/base/_properties-disabled.css +107 -0
- package/src/base/_properties-focus-visible.css +107 -0
- package/src/base/_properties-focus-within.css +107 -0
- package/src/base/_properties-hover.css +107 -0
- package/src/base/_properties-lg.css +171 -0
- package/src/base/_properties-md.css +171 -0
- package/src/base/_properties-open.css +107 -0
- package/src/base/_properties-sm.css +171 -0
- package/src/base/_properties-starting.css +55 -0
- package/src/base/_properties-stuck.css +55 -0
- package/src/base/_properties-xl.css +171 -0
- package/src/base/_properties.css +555 -0
- package/src/base/_reset.css +67 -75
- package/src/base/_switches.css +145 -0
- package/src/base/_typography.css +437 -370
- package/src/base/_utilities-box.css +142 -0
- package/src/base/_utilities-color.css +290 -0
- package/src/base/_utilities-effects.css +235 -0
- package/src/base/_utilities-flow.css +312 -0
- package/src/base/_utilities-grid.css +143 -0
- package/src/base/_utilities-margin.css +376 -0
- package/src/base/_utilities-pseudo.css +426 -0
- package/src/base/_utilities-sizing.css +259 -0
- package/src/base/_utilities-spacing.css +190 -0
- package/src/base/_utilities-tier-2xl.css +93 -0
- package/src/base/_utilities-tier-active.css +61 -0
- package/src/base/_utilities-tier-checked.css +61 -0
- package/src/base/_utilities-tier-current.css +61 -0
- package/src/base/_utilities-tier-disabled.css +61 -0
- package/src/base/_utilities-tier-focus-visible.css +61 -0
- package/src/base/_utilities-tier-focus-within.css +61 -0
- package/src/base/_utilities-tier-hover.css +63 -0
- package/src/base/_utilities-tier-lg.css +93 -0
- package/src/base/_utilities-tier-md.css +93 -0
- package/src/base/_utilities-tier-open.css +61 -0
- package/src/base/_utilities-tier-sm.css +93 -0
- package/src/base/_utilities-tier-starting.css +35 -0
- package/src/base/_utilities-tier-stuck.css +114 -0
- package/src/base/_utilities-tier-xl.css +93 -0
- package/src/base/_utilities-typography.css +141 -0
- package/src/base/_variables.css +323 -372
- package/src/base/_view-transitions.css +10 -12
- package/src/base/command-score.d.ts.map +1 -1
- package/src/base/command-score.js +1 -2
- package/src/base/command-score.ts +1 -2
- package/src/base/dialog-lifecycle.js +1 -1
- package/src/base/dialog-lifecycle.ts +1 -1
- package/src/base/embla.d.ts +6 -7
- package/src/base/embla.d.ts.map +1 -1
- package/src/base/embla.js +89 -55
- package/src/base/embla.ts +89 -55
- package/src/base/hotkeys.d.ts +0 -5
- package/src/base/hotkeys.d.ts.map +1 -1
- package/src/base/hotkeys.ts +0 -5
- package/src/base/navigation.d.ts +12 -1
- package/src/base/navigation.d.ts.map +1 -1
- package/src/base/navigation.js +229 -86
- package/src/base/navigation.ts +224 -92
- package/src/base/reveal.js +14 -14
- package/src/base/reveal.ts +14 -14
- package/src/base/scroll-state.d.ts +21 -0
- package/src/base/scroll-state.d.ts.map +1 -0
- package/src/base/scroll-state.js +177 -0
- package/src/base/scroll-state.ts +188 -0
- package/src/base/signals.d.ts +1 -2
- package/src/base/signals.d.ts.map +1 -1
- package/src/base/signals.js +4 -6
- package/src/base/signals.ts +4 -6
- package/src/base/style-format.d.ts +33 -0
- package/src/base/style-format.d.ts.map +1 -0
- package/src/base/style-format.js +160 -0
- package/src/base/style-format.ts +180 -0
- package/src/base/typeahead.d.ts +19 -4
- package/src/base/typeahead.d.ts.map +1 -1
- package/src/base/typeahead.js +68 -21
- package/src/base/typeahead.ts +73 -23
- package/src/base/utilities.d.ts +188 -0
- package/src/base/utilities.d.ts.map +1 -0
- package/src/base/utilities.js +750 -0
- package/src/base/utilities.ts +865 -0
- package/src/base/utils.d.ts +3 -7
- package/src/base/utils.d.ts.map +1 -1
- package/src/base/utils.js +4 -8
- package/src/base/utils.ts +4 -8
- package/src/base/zazz-element.d.ts +14 -8
- package/src/base/zazz-element.d.ts.map +1 -1
- package/src/base/zazz-element.js +14 -8
- package/src/base/zazz-element.ts +15 -8
- package/src/globals.d.ts +1 -1
- package/src/head.d.ts +50 -4
- package/src/head.d.ts.map +1 -1
- package/src/head.js +119 -38
- package/src/head.ts +172 -41
- package/src/index.css +57 -14
- package/src/index.js +5 -0
- package/src/index.ts +6 -0
- package/src/manifest.d.ts +36 -5
- package/src/manifest.d.ts.map +1 -1
- package/src/manifest.js +150 -6
- package/src/manifest.ts +167 -9
- package/src/primitives/accordion/accordion.css +18 -17
- package/src/primitives/accordion/accordion.html +42 -9
- package/src/primitives/alert-dialog/alert-dialog.css +13 -13
- package/src/primitives/alert-dialog/alert-dialog.html +26 -12
- package/src/primitives/autocomplete/autocomplete-groups.html +64 -33
- package/src/primitives/autocomplete/autocomplete.css +43 -39
- package/src/primitives/autocomplete/autocomplete.d.ts +6 -5
- package/src/primitives/autocomplete/autocomplete.d.ts.map +1 -1
- package/src/primitives/autocomplete/autocomplete.html +38 -26
- package/src/primitives/autocomplete/autocomplete.js +6 -5
- package/src/primitives/autocomplete/autocomplete.ts +6 -5
- package/src/primitives/avatar/avatar.html +110 -15
- package/src/primitives/badge/badge-icon.html +22 -8
- package/src/primitives/badge/badge.css +401 -128
- package/src/primitives/badge/badge.html +12 -6
- package/src/primitives/breadcrumbs/breadcrumbs.html +25 -5
- package/src/primitives/button/button-icon-only.html +17 -11
- package/src/primitives/button/button-icon.html +9 -3
- package/src/primitives/button/button.css +408 -164
- package/src/primitives/button/button.html +14 -7
- package/src/primitives/button-group/button-group-vertical.html +5 -5
- package/src/primitives/button-group/button-group.css +53 -25
- package/src/primitives/button-group/button-group.html +18 -12
- package/src/primitives/callout/callout.css +114 -0
- package/src/primitives/callout/callout.html +188 -0
- package/src/primitives/card/card-subgrid.html +249 -34
- package/src/primitives/card/card.css +125 -0
- package/src/primitives/card/card.html +141 -20
- package/src/primitives/carousel/carousel.css +30 -20
- package/src/primitives/carousel/carousel.d.ts +7 -10
- package/src/primitives/carousel/carousel.d.ts.map +1 -1
- package/src/primitives/carousel/carousel.html +420 -84
- package/src/primitives/carousel/carousel.js +1 -1
- package/src/primitives/carousel/carousel.ts +8 -11
- package/src/primitives/checkbox/checkbox-tasklist.html +6 -6
- package/src/primitives/checkbox/checkbox.css +98 -40
- package/src/primitives/checkbox/checkbox.d.ts.map +1 -1
- package/src/primitives/checkbox/checkbox.html +13 -8
- package/src/primitives/checkbox/checkbox.js +7 -9
- package/src/primitives/checkbox/checkbox.ts +7 -15
- package/src/primitives/combobox/combobox-multiselect.html +53 -33
- package/src/primitives/combobox/combobox.css +145 -122
- package/src/primitives/combobox/combobox.d.ts +12 -11
- package/src/primitives/combobox/combobox.d.ts.map +1 -1
- package/src/primitives/combobox/combobox.html +48 -28
- package/src/primitives/combobox/combobox.js +46 -51
- package/src/primitives/combobox/combobox.ts +48 -55
- package/src/primitives/command/command-actions.d.ts +2 -3
- package/src/primitives/command/command-actions.d.ts.map +1 -1
- package/src/primitives/command/command-actions.html +48 -33
- package/src/primitives/command/command-actions.js +12 -10
- package/src/primitives/command/command-actions.ts +12 -13
- package/src/primitives/command/command-dialog.html +49 -25
- package/src/primitives/command/command.css +52 -42
- package/src/primitives/command/command.d.ts +10 -7
- package/src/primitives/command/command.d.ts.map +1 -1
- package/src/primitives/command/command.html +95 -46
- package/src/primitives/command/command.js +30 -13
- package/src/primitives/command/command.ts +30 -12
- package/src/primitives/debug/audit-core.d.ts +64 -0
- package/src/primitives/debug/audit-core.d.ts.map +1 -0
- package/src/primitives/debug/audit-core.js +356 -0
- package/src/primitives/debug/audit-core.ts +535 -0
- package/src/primitives/debug/debug.d.ts +50 -0
- package/src/primitives/debug/debug.d.ts.map +1 -0
- package/src/primitives/debug/debug.js +168 -0
- package/src/primitives/debug/debug.ts +211 -0
- package/src/primitives/dialog/dialog-with-form.html +67 -45
- package/src/primitives/dialog/dialog.css +87 -61
- package/src/primitives/dialog/dialog.html +25 -17
- package/src/primitives/fields/fields.css +108 -134
- package/src/primitives/fields/fields.html +39 -0
- package/src/primitives/input/input-icon-leading.html +3 -3
- package/src/primitives/input/input-icon-trailing.html +3 -3
- package/src/primitives/input/input.css +87 -49
- package/src/primitives/input/input.html +15 -15
- package/src/primitives/input-group/input-group-password-group.html +15 -15
- package/src/primitives/input-group/input-group.css +118 -75
- package/src/primitives/input-group/input-group.html +42 -30
- package/src/primitives/kbd/kbd-group.html +15 -2
- package/src/primitives/kbd/kbd.css +44 -31
- package/src/primitives/kbd/kbd.html +7 -1
- package/src/primitives/layout/layout.css +159 -0
- package/src/primitives/layout/layout.html +35 -0
- package/src/primitives/lightbox/lightbox.css +178 -105
- package/src/primitives/lightbox/lightbox.d.ts.map +1 -1
- package/src/primitives/lightbox/lightbox.html +138 -166
- package/src/primitives/lightbox/lightbox.js +10 -13
- package/src/primitives/lightbox/lightbox.ts +12 -13
- package/src/primitives/menu/menu-interest.html +60 -18
- package/src/primitives/menu/menu.css +22 -17
- package/src/primitives/menu/menu.d.ts +5 -5
- package/src/primitives/menu/menu.html +195 -40
- package/src/primitives/menu/menu.js +8 -8
- package/src/primitives/menu/menu.ts +8 -8
- package/src/primitives/menubar/menubar-help-search.html +78 -32
- package/src/primitives/menubar/menubar.html +166 -38
- package/src/primitives/meter/meter.css +41 -38
- package/src/primitives/meter/meter.html +44 -9
- package/src/primitives/mobile-menu/mobile-menu.css +47 -40
- package/src/primitives/mobile-menu/mobile-menu.html +1460 -179
- package/src/primitives/navigation-menu/navigation-menu-featured.html +155 -33
- package/src/primitives/navigation-menu/navigation-menu-icon-grid.html +222 -47
- package/src/primitives/navigation-menu/navigation-menu-interest.html +130 -38
- package/src/primitives/navigation-menu/navigation-menu-megamenu.html +402 -72
- package/src/primitives/navigation-menu/navigation-menu-simple.html +90 -40
- package/src/primitives/navigation-menu/navigation-menu.css +104 -106
- package/src/primitives/navigation-menu/navigation-menu.html +554 -158
- package/src/primitives/otp/otp.css +43 -44
- package/src/primitives/otp/otp.d.ts +4 -5
- package/src/primitives/otp/otp.d.ts.map +1 -1
- package/src/primitives/otp/otp.html +7 -6
- package/src/primitives/otp/otp.js +13 -18
- package/src/primitives/otp/otp.ts +12 -19
- package/src/primitives/password-group/password-group.css +132 -107
- package/src/primitives/password-group/password-group.d.ts.map +1 -1
- package/src/primitives/password-group/password-group.html +23 -16
- package/src/primitives/password-group/password-group.js +11 -12
- package/src/primitives/password-group/password-group.ts +11 -12
- package/src/primitives/popover/popover.css +88 -95
- package/src/primitives/popover/popover.html +18 -0
- package/src/primitives/progress/progress-indeterminate.html +1 -1
- package/src/primitives/progress/progress.css +34 -35
- package/src/primitives/progress/progress.html +18 -4
- package/src/primitives/prose/prose.html +19 -12
- package/src/primitives/radio/radio.css +83 -46
- package/src/primitives/radio/radio.html +16 -11
- package/src/primitives/reveal/reveal.css +37 -46
- package/src/primitives/reveal/reveal.html +15 -0
- package/src/primitives/scroll-fade/scroll-fade.css +115 -0
- package/src/primitives/scroll-fade/scroll-fade.html +69 -0
- package/src/primitives/select/multiselect.d.ts +8 -10
- package/src/primitives/select/multiselect.d.ts.map +1 -1
- package/src/primitives/select/multiselect.js +23 -27
- package/src/primitives/select/multiselect.ts +23 -29
- package/src/primitives/select/select-align.html +79 -16
- package/src/primitives/select/select-multiple.html +8 -4
- package/src/primitives/select/select-sides.html +104 -21
- package/src/primitives/select/select.css +297 -186
- package/src/primitives/select/select.html +24 -5
- package/src/primitives/separator/separator.css +15 -18
- package/src/primitives/separator/separator.html +37 -10
- package/src/primitives/slider/slider.css +48 -38
- package/src/primitives/slider/slider.html +9 -1
- package/src/primitives/style-guard/style-guard.d.ts +19 -0
- package/src/primitives/style-guard/style-guard.d.ts.map +1 -0
- package/src/primitives/style-guard/style-guard.js +125 -0
- package/src/primitives/style-guard/style-guard.ts +153 -0
- package/src/primitives/switch/switch.css +42 -33
- package/src/primitives/switch/switch.html +11 -6
- package/src/primitives/table/table-alternating.html +1 -1
- package/src/primitives/table/table-grid.html +5 -5
- package/src/primitives/table/table-size-sm.html +1 -1
- package/src/primitives/table/table.css +64 -61
- package/src/primitives/table/table.html +7 -7
- package/src/primitives/tabs/tabs.css +167 -166
- package/src/primitives/tabs/tabs.d.ts +10 -11
- package/src/primitives/tabs/tabs.d.ts.map +1 -1
- package/src/primitives/tabs/tabs.html +192 -36
- package/src/primitives/tabs/tabs.js +14 -15
- package/src/primitives/tabs/tabs.ts +14 -15
- package/src/primitives/textarea/textarea.css +69 -44
- package/src/primitives/textarea/textarea.html +3 -3
- package/src/primitives/toaster/toaster.css +90 -92
- package/src/primitives/toaster/toaster.d.ts +0 -6
- package/src/primitives/toaster/toaster.d.ts.map +1 -1
- package/src/primitives/toaster/toaster.html +22 -18
- package/src/primitives/toaster/toaster.js +64 -72
- package/src/primitives/toaster/toaster.ts +71 -87
- package/src/primitives/toggle/toggle.css +368 -153
- package/src/primitives/toggle/toggle.html +27 -9
- package/src/primitives/toggle-group/toggle-group-multiple.html +3 -3
- package/src/primitives/toggle-group/toggle-group-vertical.html +4 -4
- package/src/primitives/toggle-group/toggle-group.css +71 -23
- package/src/primitives/toggle-group/toggle-group.html +3 -3
- package/src/primitives/toolbar/toolbar.html +35 -13
- package/src/primitives/tooltip/tooltip-disabled.html +3 -3
- package/src/primitives/tooltip/tooltip-sides.html +36 -14
- package/src/primitives/tooltip/tooltip-with-kbd.html +5 -5
- package/src/primitives/tooltip/tooltip.css +111 -80
- package/src/primitives/tooltip/tooltip.html +3 -3
- package/src/primitives/utilities/aspect-ratio.html +51 -7
- package/src/primitives/utilities/basis.html +64 -11
- package/src/primitives/utilities/col-span.html +65 -9
- package/src/primitives/utilities/compose.html +48 -10
- package/src/primitives/utilities/flex-align.html +89 -19
- package/src/primitives/utilities/flex-direction.html +111 -13
- package/src/primitives/utilities/flex-grow.html +41 -7
- package/src/primitives/utilities/gap.html +158 -19
- package/src/primitives/utilities/grid-cols.html +75 -7
- package/src/primitives/utilities/grid-responsive.html +111 -12
- package/src/primitives/utilities/margin-auto.html +38 -7
- package/src/primitives/utilities/object-fit.html +75 -13
- package/src/primitives/utilities/order.html +40 -4
- package/src/primitives/utilities/overflow.html +74 -20
- package/src/primitives/utilities/padding-compose.html +67 -10
- package/src/primitives/utilities/padding.html +84 -13
- package/src/primitives/utilities/pile.html +29 -0
- package/src/primitives/utilities/position.html +65 -8
- package/src/primitives/utilities/responsive-flex.html +54 -7
- package/src/primitives/utilities/responsive-grid.html +115 -12
- package/src/primitives/utilities/size.html +120 -16
- package/src/primitives/utilities/width.html +123 -16
- package/examples/about.html +0 -583
- package/examples/components.html +0 -1028
- package/examples/forms.html +0 -504
- package/examples/index.html +0 -261
- package/examples/layout.html +0 -313
- package/examples/products.html +0 -839
- package/examples/responsive.html +0 -332
- package/src/base/_layout.css +0 -571
- package/src/base/_utilities.css +0 -6758
- package/src/primitives/utilities/grid-pile.html +0 -5
|
@@ -0,0 +1,865 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @fileoverview The utility table: the single source the utilities generator,
|
|
5
|
+
* the editor custom data, and `<ui-debug>` read. Data only — no imports, no
|
|
6
|
+
* CSS text.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/** Breakpoints, ascending: Tailwind's five names. */
|
|
10
|
+
export const BREAKPOINTS = ["sm", "md", "lg", "xl", "2xl"] as const;
|
|
11
|
+
export type Breakpoint = (typeof BREAKPOINTS)[number];
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Breakpoint thresholds, in `ch` of the nearest inline-size container's font,
|
|
15
|
+
* chosen for legibility: each answers "what text layout fits here?". sm: the
|
|
16
|
+
* narrowest comfortable line; md: one full reading measure (`--article-md`);
|
|
17
|
+
* lg: two 45ch columns; xl: three 40ch columns; 2xl: two full 75ch measures.
|
|
18
|
+
* ≈ 404 / 656 / 909 / 1210 / 1515px with the system font at 16px.
|
|
19
|
+
*/
|
|
20
|
+
export const BREAKPOINT_CH: Record<Breakpoint, number> = {
|
|
21
|
+
sm: 40,
|
|
22
|
+
md: 65,
|
|
23
|
+
lg: 90,
|
|
24
|
+
xl: 120,
|
|
25
|
+
"2xl": 150,
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Layout band and component widths (`--layout-*`), in rem for predictable
|
|
30
|
+
* geometry: Tailwind's scale. Decoupled from the query thresholds above.
|
|
31
|
+
*/
|
|
32
|
+
export const LAYOUT_REM: Record<Breakpoint, number> = {
|
|
33
|
+
sm: 40,
|
|
34
|
+
md: 48,
|
|
35
|
+
lg: 64,
|
|
36
|
+
xl: 80,
|
|
37
|
+
"2xl": 96,
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/** Interaction states, highest precedence first. */
|
|
41
|
+
export const STATES = [
|
|
42
|
+
"starting",
|
|
43
|
+
"disabled",
|
|
44
|
+
"active",
|
|
45
|
+
"focus-visible",
|
|
46
|
+
"focus-within",
|
|
47
|
+
"hover",
|
|
48
|
+
"checked",
|
|
49
|
+
"current",
|
|
50
|
+
"open",
|
|
51
|
+
"stuck",
|
|
52
|
+
] as const;
|
|
53
|
+
export type State = (typeof STATES)[number];
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* How each state is selected: a pseudo-class (or `:is()` list) on the element,
|
|
57
|
+
* with an optional media guard; for `stuck`, the nearest sticky scroll-state
|
|
58
|
+
* container (see `STUCK_STATE`); for `starting`, the element's
|
|
59
|
+
* `@starting-style` (the style it transitions from when it first renders or
|
|
60
|
+
* leaves `display: none`). Pseudo states have a `--group-*` form; the stuck
|
|
61
|
+
* and starting states do not (the trigger is the container, or the element's
|
|
62
|
+
* own first style).
|
|
63
|
+
*/
|
|
64
|
+
export const STATE_SELECTORS: Record<
|
|
65
|
+
State,
|
|
66
|
+
{ pseudo: string; media?: string; stuck?: true; starting?: true }
|
|
67
|
+
> = {
|
|
68
|
+
starting: { pseudo: "", starting: true },
|
|
69
|
+
disabled: { pseudo: ':is(:disabled, [aria-disabled="true"])' },
|
|
70
|
+
active: { pseudo: ":active" },
|
|
71
|
+
"focus-visible": { pseudo: ":focus-visible" },
|
|
72
|
+
"focus-within": { pseudo: ":focus-within" },
|
|
73
|
+
hover: { pseudo: ":hover", media: "(hover: hover)" },
|
|
74
|
+
checked: { pseudo: ':is(:checked, [aria-checked="true"])' },
|
|
75
|
+
current: { pseudo: ':is([aria-current]:not([aria-current="false"]))' },
|
|
76
|
+
open: { pseudo: ':is([open], :popover-open, [aria-expanded="true"])' },
|
|
77
|
+
stuck: { pseudo: "", stuck: true },
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* The experimental `stuck` state: `scroll-state(stuck: <side>)` where container
|
|
82
|
+
* scroll-state queries are supported, `base/scroll-state.ts` elsewhere. Any
|
|
83
|
+
* sticky element (a `style` holding `: sticky`, so `--position: sticky`, its
|
|
84
|
+
* tiers, or raw `position: sticky`) or one that sets `--stuck-state` becomes
|
|
85
|
+
* the container; a container query never matches the container itself, so
|
|
86
|
+
* `--<utility>--stuck` applies to its *descendants* while it is stuck to the
|
|
87
|
+
* side its `--stuck-state` names (`fallback` when unset). `--stuck-state` has
|
|
88
|
+
* no emission or tiers of its own: switch `--position` off at a breakpoint to
|
|
89
|
+
* drop the state there.
|
|
90
|
+
*/
|
|
91
|
+
export const STUCK_STATE = {
|
|
92
|
+
modifier: "stuck-state",
|
|
93
|
+
supports: "(container-type: scroll-state)",
|
|
94
|
+
/** Where unsupported, `base/scroll-state.ts` writes the stuck sides here, on the container. */
|
|
95
|
+
polyfill: "data-ui-stuck",
|
|
96
|
+
fallback: "top",
|
|
97
|
+
/** Sticky elements: `--position: sticky`, its tiers, or raw `position: sticky`. */
|
|
98
|
+
sticky: '[style*=": sticky"]',
|
|
99
|
+
sides: [
|
|
100
|
+
"top",
|
|
101
|
+
"right",
|
|
102
|
+
"bottom",
|
|
103
|
+
"left",
|
|
104
|
+
"block-start",
|
|
105
|
+
"block-end",
|
|
106
|
+
"inline-start",
|
|
107
|
+
"inline-end",
|
|
108
|
+
],
|
|
109
|
+
} as const;
|
|
110
|
+
|
|
111
|
+
/** True when `--group-<utility>--<state>` exists for the state. */
|
|
112
|
+
export function hasGroup(state: State): boolean {
|
|
113
|
+
return !STATE_SELECTORS[state].stuck && !STATE_SELECTORS[state].starting;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export function isState(tier: string): tier is State {
|
|
117
|
+
return (STATES as readonly string[]).includes(tier);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/** How a utility's value is read. */
|
|
121
|
+
export type Mode = "dual" | "raw" | "keyword" | "integer";
|
|
122
|
+
|
|
123
|
+
/** Utility families; each family has one tier kind. */
|
|
124
|
+
export type Family =
|
|
125
|
+
| "flow"
|
|
126
|
+
| "grid"
|
|
127
|
+
| "spacing"
|
|
128
|
+
| "margin"
|
|
129
|
+
| "sizing"
|
|
130
|
+
| "typography"
|
|
131
|
+
| "color"
|
|
132
|
+
| "effects"
|
|
133
|
+
| "box";
|
|
134
|
+
|
|
135
|
+
/** A family's tiers: breakpoints, states, both (paint that also changes per breakpoint), or none. */
|
|
136
|
+
export type Tiers = "breakpoints" | "states" | "both" | "none";
|
|
137
|
+
|
|
138
|
+
export const FAMILY_TIERS: Record<Family, Tiers> = {
|
|
139
|
+
flow: "breakpoints",
|
|
140
|
+
grid: "breakpoints",
|
|
141
|
+
spacing: "breakpoints",
|
|
142
|
+
margin: "breakpoints",
|
|
143
|
+
sizing: "breakpoints",
|
|
144
|
+
typography: "breakpoints",
|
|
145
|
+
color: "both",
|
|
146
|
+
effects: "states",
|
|
147
|
+
box: "none",
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
export interface Utility {
|
|
151
|
+
/** The name after `--` (`w`, `grid-cols`). */
|
|
152
|
+
name: string;
|
|
153
|
+
/** CSS properties the utility emits (several for `--size`). */
|
|
154
|
+
properties: readonly string[];
|
|
155
|
+
mode: Mode;
|
|
156
|
+
family: Family;
|
|
157
|
+
/**
|
|
158
|
+
* Special emission shapes: `repeat` wraps an integer in
|
|
159
|
+
* `repeat(n, minmax(0, 1fr))`; `span` writes `span n / span n`; `grid-fit` packs auto-fit columns;
|
|
160
|
+
* `line-clamp` adds the -webkit-box companions; `bg` is a relative oklch
|
|
161
|
+
* with `--bg-alpha`; `none` feeds a composite (`box-shadow`) and emits nothing itself;
|
|
162
|
+
* `border` is a border shorthand: it sorts a color, number, or length into
|
|
163
|
+
* width and color channels, and the side rules emit them.
|
|
164
|
+
*/
|
|
165
|
+
emit?: "plain" | "repeat" | "span" | "grid-fit" | "line-clamp" | "bg" | "none" | "border";
|
|
166
|
+
/** Overrides the family's tier kind (`none` for a utility that is base-only). */
|
|
167
|
+
tiers?: Tiers;
|
|
168
|
+
/**
|
|
169
|
+
* The `border` emission's width and color channels (`--_<name>-w`, `--_<name>-c`)
|
|
170
|
+
* inherit, for a switch that draws them on the element's children (`--divide`).
|
|
171
|
+
*/
|
|
172
|
+
inherits?: true;
|
|
173
|
+
/**
|
|
174
|
+
* No-base allowlist: the CSS initial value as a literal. A utility with
|
|
175
|
+
* `noBase` applies a tier on a plain element without a base value.
|
|
176
|
+
*/
|
|
177
|
+
noBase?: string;
|
|
178
|
+
/**
|
|
179
|
+
* Extra selectors excluded from the no-base rule: elements whose
|
|
180
|
+
* placement chain a primitive owns, e.g. a layout's children for `--band`.
|
|
181
|
+
*/
|
|
182
|
+
noBaseExclude?: readonly string[];
|
|
183
|
+
/**
|
|
184
|
+
* Keywords the typed emission (the dual pair, or an integer's `repeat()`)
|
|
185
|
+
* cannot carry. A utility written with one of its keywords, at the base or
|
|
186
|
+
* any tier, switches to its raw emission at every tier; its other values on
|
|
187
|
+
* that element must then be valid as written (a length, not a scale number).
|
|
188
|
+
* Other utilities on the element are unaffected.
|
|
189
|
+
*/
|
|
190
|
+
keywords?: readonly string[];
|
|
191
|
+
/**
|
|
192
|
+
* The utility also exists as `--before-<name>` / `--after-<name>`,
|
|
193
|
+
* read on the pseudo-element with an exact gate. Pseudo utilities are never
|
|
194
|
+
* registered, because `::before` must inherit them from its host.
|
|
195
|
+
*/
|
|
196
|
+
pseudo?: true;
|
|
197
|
+
/**
|
|
198
|
+
* Keyword shorthands: `--shadow: md` reads as `--shadow: var(--shadow-md)`.
|
|
199
|
+
* Each is an exact-value rule at the base and at every tier of the family, so
|
|
200
|
+
* it works in `--shadow--hover: lg` too; any other value passes through as
|
|
201
|
+
* usual. A keyword that is a prefix of another must come first.
|
|
202
|
+
*/
|
|
203
|
+
aliases?: Readonly<Record<string, string>>;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/** Gradient types: `--bg-<type>` emits `<type>-gradient(<prelude>, <--bg-stops>)`. */
|
|
207
|
+
export const GRADIENT_TYPES = ["linear", "radial", "conic"] as const;
|
|
208
|
+
|
|
209
|
+
/** The size scale shared by the token keywords (`--shadow: md`). */
|
|
210
|
+
export const SIZE_KEYWORDS = ["2xs", "xs", "sm", "md", "lg", "xl", "2xl"] as const;
|
|
211
|
+
|
|
212
|
+
/** `--shadow: md` → `var(--shadow-md)`. */
|
|
213
|
+
const SHADOWS = Object.fromEntries(SIZE_KEYWORDS.map((size) => [size, `var(--shadow-${size})`]));
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* `--font-weight: strong` → `var(--font-weight-strong)`: the role weights, so a
|
|
217
|
+
* theme's weights reach utilities. Standard names (`medium`) are not keywords:
|
|
218
|
+
* write the number (`500`); `<ui-debug>` says so.
|
|
219
|
+
*/
|
|
220
|
+
const FONT_WEIGHTS = {
|
|
221
|
+
heading: "var(--font-weight-heading)",
|
|
222
|
+
body: "var(--font-weight-body)",
|
|
223
|
+
strong: "var(--font-weight-strong)",
|
|
224
|
+
} as const;
|
|
225
|
+
|
|
226
|
+
/** Standard weight names and the number to write instead (`normal` and `bold` are CSS). */
|
|
227
|
+
export const FONT_WEIGHT_NAMES: Readonly<Record<string, number>> = {
|
|
228
|
+
thin: 100,
|
|
229
|
+
hairline: 100,
|
|
230
|
+
extralight: 200,
|
|
231
|
+
"extra-light": 200,
|
|
232
|
+
ultralight: 200,
|
|
233
|
+
light: 300,
|
|
234
|
+
regular: 400,
|
|
235
|
+
medium: 500,
|
|
236
|
+
semibold: 600,
|
|
237
|
+
"semi-bold": 600,
|
|
238
|
+
demibold: 600,
|
|
239
|
+
extrabold: 800,
|
|
240
|
+
"extra-bold": 800,
|
|
241
|
+
ultrabold: 800,
|
|
242
|
+
black: 900,
|
|
243
|
+
heavy: 900,
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* `--display` shorthands that set the flex direction with the display (there
|
|
248
|
+
* is no `--flex-direction` utility): `[display, flex-direction]`. Plain `flex`
|
|
249
|
+
* or `inline-flex` at a tier resets the direction to row. A keyword that is a
|
|
250
|
+
* prefix of another comes first.
|
|
251
|
+
*/
|
|
252
|
+
export const DISPLAY_SHORTHANDS: Readonly<Record<string, readonly [string, string]>> = {
|
|
253
|
+
"flex-row": ["flex", "row"],
|
|
254
|
+
"flex-row-reverse": ["flex", "row-reverse"],
|
|
255
|
+
"flex-col": ["flex", "column"],
|
|
256
|
+
"flex-col-reverse": ["flex", "column-reverse"],
|
|
257
|
+
"inline-flex-row": ["inline-flex", "row"],
|
|
258
|
+
"inline-flex-row-reverse": ["inline-flex", "row-reverse"],
|
|
259
|
+
"inline-flex-col": ["inline-flex", "column"],
|
|
260
|
+
"inline-flex-col-reverse": ["inline-flex", "column-reverse"],
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
/** The border shorthands, all sides first. */
|
|
264
|
+
export const BORDER_SHORTHANDS = [
|
|
265
|
+
"border",
|
|
266
|
+
"border-x",
|
|
267
|
+
"border-y",
|
|
268
|
+
"border-l",
|
|
269
|
+
"border-t",
|
|
270
|
+
"border-r",
|
|
271
|
+
"border-b",
|
|
272
|
+
] as const;
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* Each physical side of the border shorthand, the logical property prefix it
|
|
276
|
+
* sets, and the shorthands that cover it, most specific first.
|
|
277
|
+
*/
|
|
278
|
+
export const BORDER_SIDES = [
|
|
279
|
+
{ side: "l", property: "border-inline-start", shorthands: ["border-l", "border-x", "border"] },
|
|
280
|
+
{ side: "t", property: "border-block-start", shorthands: ["border-t", "border-y", "border"] },
|
|
281
|
+
{ side: "r", property: "border-inline-end", shorthands: ["border-r", "border-x", "border"] },
|
|
282
|
+
{ side: "b", property: "border-block-end", shorthands: ["border-b", "border-y", "border"] },
|
|
283
|
+
] as const;
|
|
284
|
+
|
|
285
|
+
/** The four sizing keywords. Margin takes only `auto`. */
|
|
286
|
+
export const SIZING_KEYWORDS = ["auto", "fit-content", "min-content", "max-content"] as const;
|
|
287
|
+
export const MARGIN_KEYWORDS = ["auto"] as const;
|
|
288
|
+
/** A layout places its children; a tier-only column utility there keeps the band below the tier. */
|
|
289
|
+
const LAYOUT_CHILDREN = ["ui-layout > *", '[data-ui~="layout"] > *'] as const;
|
|
290
|
+
|
|
291
|
+
/**
|
|
292
|
+
* Track-list keywords `--grid-cols` / `--grid-rows` take besides a count. `none`
|
|
293
|
+
* is not one: `--template-cols: none` says the same, and every keyword
|
|
294
|
+
* costs a rule per breakpoint (SPEC claim 16).
|
|
295
|
+
*/
|
|
296
|
+
export const GRID_TEMPLATE_KEYWORDS = ["subgrid"] as const;
|
|
297
|
+
|
|
298
|
+
/** The utility table. Order within a family is emission order (shorthands first). */
|
|
299
|
+
export const UTILITIES: readonly Utility[] = [
|
|
300
|
+
// flow: keywords and raw values; most are on the no-base allowlist
|
|
301
|
+
{ name: "display", pseudo: true, properties: ["display"], mode: "keyword", family: "flow" },
|
|
302
|
+
// breakpoint tiers so sticky (and the stuck state) can switch off per breakpoint
|
|
303
|
+
{
|
|
304
|
+
name: "position",
|
|
305
|
+
pseudo: true,
|
|
306
|
+
properties: ["position"],
|
|
307
|
+
mode: "keyword",
|
|
308
|
+
family: "flow",
|
|
309
|
+
noBase: "static",
|
|
310
|
+
},
|
|
311
|
+
{
|
|
312
|
+
name: "flex-wrap",
|
|
313
|
+
properties: ["flex-wrap"],
|
|
314
|
+
mode: "keyword",
|
|
315
|
+
family: "flow",
|
|
316
|
+
noBase: "nowrap",
|
|
317
|
+
},
|
|
318
|
+
{ name: "shrink", properties: ["flex-shrink"], mode: "raw", family: "flow", noBase: "1" },
|
|
319
|
+
{
|
|
320
|
+
name: "grid-flow",
|
|
321
|
+
properties: ["grid-auto-flow"],
|
|
322
|
+
mode: "keyword",
|
|
323
|
+
family: "flow",
|
|
324
|
+
noBase: "row",
|
|
325
|
+
},
|
|
326
|
+
{
|
|
327
|
+
name: "auto-cols",
|
|
328
|
+
properties: ["grid-auto-columns"],
|
|
329
|
+
mode: "raw",
|
|
330
|
+
family: "flow",
|
|
331
|
+
noBase: "auto",
|
|
332
|
+
},
|
|
333
|
+
{
|
|
334
|
+
name: "auto-rows",
|
|
335
|
+
properties: ["grid-auto-rows"],
|
|
336
|
+
mode: "raw",
|
|
337
|
+
family: "flow",
|
|
338
|
+
noBase: "auto",
|
|
339
|
+
},
|
|
340
|
+
{ name: "items", properties: ["align-items"], mode: "keyword", family: "flow", noBase: "normal" },
|
|
341
|
+
{
|
|
342
|
+
name: "justify",
|
|
343
|
+
properties: ["justify-content"],
|
|
344
|
+
mode: "keyword",
|
|
345
|
+
family: "flow",
|
|
346
|
+
noBase: "normal",
|
|
347
|
+
},
|
|
348
|
+
// Grid alignment shorthands: the CSS alignment keywords only (`center`, `safe end`, `space-between`).
|
|
349
|
+
{
|
|
350
|
+
name: "place-items",
|
|
351
|
+
properties: ["place-items"],
|
|
352
|
+
mode: "keyword",
|
|
353
|
+
family: "flow",
|
|
354
|
+
noBase: "normal",
|
|
355
|
+
},
|
|
356
|
+
{
|
|
357
|
+
name: "place-content",
|
|
358
|
+
properties: ["place-content"],
|
|
359
|
+
mode: "keyword",
|
|
360
|
+
family: "flow",
|
|
361
|
+
noBase: "normal",
|
|
362
|
+
},
|
|
363
|
+
{ name: "self", properties: ["align-self"], mode: "keyword", family: "flow", noBase: "auto" },
|
|
364
|
+
{ name: "flex", properties: ["flex"], mode: "raw", family: "flow", noBase: "0 1 auto" },
|
|
365
|
+
{ name: "basis", properties: ["flex-basis"], mode: "raw", family: "flow", noBase: "auto" },
|
|
366
|
+
{ name: "order", properties: ["order"], mode: "raw", family: "flow", noBase: "0" },
|
|
367
|
+
// a layout child's band (`layout-md`); any grid-column value works
|
|
368
|
+
{
|
|
369
|
+
name: "band",
|
|
370
|
+
properties: ["grid-column"],
|
|
371
|
+
mode: "raw",
|
|
372
|
+
family: "flow",
|
|
373
|
+
noBase: "auto",
|
|
374
|
+
noBaseExclude: LAYOUT_CHILDREN,
|
|
375
|
+
},
|
|
376
|
+
// Tailwind's col-span / col-start / col-end (and row-*): span is a count,
|
|
377
|
+
// start and end are line numbers; start and end follow span so they combine
|
|
378
|
+
{
|
|
379
|
+
name: "col-span",
|
|
380
|
+
properties: ["grid-column"],
|
|
381
|
+
mode: "integer",
|
|
382
|
+
family: "flow",
|
|
383
|
+
emit: "span",
|
|
384
|
+
noBase: "1",
|
|
385
|
+
noBaseExclude: LAYOUT_CHILDREN,
|
|
386
|
+
},
|
|
387
|
+
{
|
|
388
|
+
name: "col-start",
|
|
389
|
+
properties: ["grid-column-start"],
|
|
390
|
+
mode: "raw",
|
|
391
|
+
family: "flow",
|
|
392
|
+
noBase: "auto",
|
|
393
|
+
noBaseExclude: LAYOUT_CHILDREN,
|
|
394
|
+
},
|
|
395
|
+
{
|
|
396
|
+
name: "col-end",
|
|
397
|
+
properties: ["grid-column-end"],
|
|
398
|
+
mode: "raw",
|
|
399
|
+
family: "flow",
|
|
400
|
+
noBase: "auto",
|
|
401
|
+
noBaseExclude: LAYOUT_CHILDREN,
|
|
402
|
+
},
|
|
403
|
+
{
|
|
404
|
+
name: "row-span",
|
|
405
|
+
properties: ["grid-row"],
|
|
406
|
+
mode: "integer",
|
|
407
|
+
family: "flow",
|
|
408
|
+
emit: "span",
|
|
409
|
+
noBase: "1",
|
|
410
|
+
},
|
|
411
|
+
{
|
|
412
|
+
name: "row-start",
|
|
413
|
+
properties: ["grid-row-start"],
|
|
414
|
+
mode: "raw",
|
|
415
|
+
family: "flow",
|
|
416
|
+
noBase: "auto",
|
|
417
|
+
},
|
|
418
|
+
{ name: "row-end", properties: ["grid-row-end"], mode: "raw", family: "flow", noBase: "auto" },
|
|
419
|
+
// grid: integers become repeat() (plus subgrid); templates are raw;
|
|
420
|
+
// grid-fit packs auto-fit columns
|
|
421
|
+
{
|
|
422
|
+
name: "grid-cols",
|
|
423
|
+
properties: ["grid-template-columns"],
|
|
424
|
+
mode: "integer",
|
|
425
|
+
family: "grid",
|
|
426
|
+
emit: "repeat",
|
|
427
|
+
noBase: "1",
|
|
428
|
+
keywords: GRID_TEMPLATE_KEYWORDS,
|
|
429
|
+
},
|
|
430
|
+
{
|
|
431
|
+
name: "grid-rows",
|
|
432
|
+
properties: ["grid-template-rows"],
|
|
433
|
+
mode: "integer",
|
|
434
|
+
family: "grid",
|
|
435
|
+
emit: "repeat",
|
|
436
|
+
noBase: "1",
|
|
437
|
+
keywords: GRID_TEMPLATE_KEYWORDS,
|
|
438
|
+
},
|
|
439
|
+
// raw track lists take states too, for the 0fr → 1fr expand (`--template-rows--open: 1fr`)
|
|
440
|
+
{
|
|
441
|
+
name: "template-cols",
|
|
442
|
+
properties: ["grid-template-columns"],
|
|
443
|
+
mode: "raw",
|
|
444
|
+
family: "grid",
|
|
445
|
+
tiers: "both",
|
|
446
|
+
noBase: "none",
|
|
447
|
+
},
|
|
448
|
+
{
|
|
449
|
+
name: "template-rows",
|
|
450
|
+
properties: ["grid-template-rows"],
|
|
451
|
+
mode: "raw",
|
|
452
|
+
family: "grid",
|
|
453
|
+
tiers: "both",
|
|
454
|
+
noBase: "none",
|
|
455
|
+
},
|
|
456
|
+
{
|
|
457
|
+
name: "grid-fit",
|
|
458
|
+
properties: ["grid-template-columns"],
|
|
459
|
+
mode: "raw",
|
|
460
|
+
family: "grid",
|
|
461
|
+
emit: "grid-fit",
|
|
462
|
+
},
|
|
463
|
+
// spacing: dual mode; gap is on the no-base allowlist
|
|
464
|
+
{ name: "p", pseudo: true, properties: ["padding"], mode: "dual", family: "spacing" },
|
|
465
|
+
{ name: "px", pseudo: true, properties: ["padding-inline"], mode: "dual", family: "spacing" },
|
|
466
|
+
{ name: "py", pseudo: true, properties: ["padding-block"], mode: "dual", family: "spacing" },
|
|
467
|
+
{
|
|
468
|
+
name: "pt",
|
|
469
|
+
pseudo: true,
|
|
470
|
+
properties: ["padding-block-start"],
|
|
471
|
+
mode: "dual",
|
|
472
|
+
family: "spacing",
|
|
473
|
+
},
|
|
474
|
+
{ name: "pb", pseudo: true, properties: ["padding-block-end"], mode: "dual", family: "spacing" },
|
|
475
|
+
{
|
|
476
|
+
name: "pl",
|
|
477
|
+
pseudo: true,
|
|
478
|
+
properties: ["padding-inline-start"],
|
|
479
|
+
mode: "dual",
|
|
480
|
+
family: "spacing",
|
|
481
|
+
},
|
|
482
|
+
{ name: "pr", pseudo: true, properties: ["padding-inline-end"], mode: "dual", family: "spacing" },
|
|
483
|
+
{ name: "gap", properties: ["gap"], mode: "dual", family: "spacing", noBase: "0" },
|
|
484
|
+
{ name: "gap-x", properties: ["column-gap"], mode: "dual", family: "spacing", noBase: "0" },
|
|
485
|
+
{ name: "gap-y", properties: ["row-gap"], mode: "dual", family: "spacing", noBase: "0" },
|
|
486
|
+
{ name: "inset", pseudo: true, properties: ["inset"], mode: "dual", family: "spacing" },
|
|
487
|
+
// axis insets: left + right and top + bottom (logical, like the sides)
|
|
488
|
+
{ name: "inset-x", pseudo: true, properties: ["inset-inline"], mode: "dual", family: "spacing" },
|
|
489
|
+
{ name: "inset-y", pseudo: true, properties: ["inset-block"], mode: "dual", family: "spacing" },
|
|
490
|
+
{ name: "top", pseudo: true, properties: ["inset-block-start"], mode: "dual", family: "spacing" },
|
|
491
|
+
{
|
|
492
|
+
name: "bottom",
|
|
493
|
+
pseudo: true,
|
|
494
|
+
properties: ["inset-block-end"],
|
|
495
|
+
mode: "dual",
|
|
496
|
+
family: "spacing",
|
|
497
|
+
},
|
|
498
|
+
{
|
|
499
|
+
name: "left",
|
|
500
|
+
pseudo: true,
|
|
501
|
+
properties: ["inset-inline-start"],
|
|
502
|
+
mode: "dual",
|
|
503
|
+
family: "spacing",
|
|
504
|
+
},
|
|
505
|
+
{
|
|
506
|
+
name: "right",
|
|
507
|
+
pseudo: true,
|
|
508
|
+
properties: ["inset-inline-end"],
|
|
509
|
+
mode: "dual",
|
|
510
|
+
family: "spacing",
|
|
511
|
+
},
|
|
512
|
+
// margin: dual mode plus `auto`
|
|
513
|
+
{ name: "m", properties: ["margin"], mode: "dual", family: "margin", keywords: MARGIN_KEYWORDS },
|
|
514
|
+
{
|
|
515
|
+
name: "mx",
|
|
516
|
+
properties: ["margin-inline"],
|
|
517
|
+
mode: "dual",
|
|
518
|
+
family: "margin",
|
|
519
|
+
keywords: MARGIN_KEYWORDS,
|
|
520
|
+
},
|
|
521
|
+
{
|
|
522
|
+
name: "my",
|
|
523
|
+
properties: ["margin-block"],
|
|
524
|
+
mode: "dual",
|
|
525
|
+
family: "margin",
|
|
526
|
+
keywords: MARGIN_KEYWORDS,
|
|
527
|
+
},
|
|
528
|
+
{
|
|
529
|
+
name: "mt",
|
|
530
|
+
properties: ["margin-block-start"],
|
|
531
|
+
mode: "dual",
|
|
532
|
+
family: "margin",
|
|
533
|
+
keywords: MARGIN_KEYWORDS,
|
|
534
|
+
},
|
|
535
|
+
{
|
|
536
|
+
name: "mb",
|
|
537
|
+
properties: ["margin-block-end"],
|
|
538
|
+
mode: "dual",
|
|
539
|
+
family: "margin",
|
|
540
|
+
keywords: MARGIN_KEYWORDS,
|
|
541
|
+
},
|
|
542
|
+
{
|
|
543
|
+
name: "ml",
|
|
544
|
+
properties: ["margin-inline-start"],
|
|
545
|
+
mode: "dual",
|
|
546
|
+
family: "margin",
|
|
547
|
+
keywords: MARGIN_KEYWORDS,
|
|
548
|
+
},
|
|
549
|
+
{
|
|
550
|
+
name: "mr",
|
|
551
|
+
properties: ["margin-inline-end"],
|
|
552
|
+
mode: "dual",
|
|
553
|
+
family: "margin",
|
|
554
|
+
keywords: MARGIN_KEYWORDS,
|
|
555
|
+
},
|
|
556
|
+
// sizing: dual mode; the four keywords only where they are used (`--w`, `--h`,
|
|
557
|
+
// `--min-w`, `--max-w`): each keyword-bearing utility costs a base rule and two
|
|
558
|
+
// rules per breakpoint (SPEC claim 16). `--size: fit-content` is `--w` + `--h`;
|
|
559
|
+
// a hero that must not squish is `--min-h: 100svh`, not `--h: 100svh; --min-h: fit-content`
|
|
560
|
+
{
|
|
561
|
+
name: "w",
|
|
562
|
+
properties: ["inline-size"],
|
|
563
|
+
mode: "dual",
|
|
564
|
+
family: "sizing",
|
|
565
|
+
keywords: SIZING_KEYWORDS,
|
|
566
|
+
pseudo: true,
|
|
567
|
+
},
|
|
568
|
+
{
|
|
569
|
+
name: "h",
|
|
570
|
+
properties: ["block-size"],
|
|
571
|
+
mode: "dual",
|
|
572
|
+
family: "sizing",
|
|
573
|
+
keywords: SIZING_KEYWORDS,
|
|
574
|
+
pseudo: true,
|
|
575
|
+
},
|
|
576
|
+
{
|
|
577
|
+
name: "size",
|
|
578
|
+
properties: ["inline-size", "block-size"],
|
|
579
|
+
mode: "dual",
|
|
580
|
+
family: "sizing",
|
|
581
|
+
pseudo: true,
|
|
582
|
+
},
|
|
583
|
+
{
|
|
584
|
+
name: "min-w",
|
|
585
|
+
properties: ["min-inline-size"],
|
|
586
|
+
mode: "dual",
|
|
587
|
+
family: "sizing",
|
|
588
|
+
keywords: SIZING_KEYWORDS,
|
|
589
|
+
pseudo: true,
|
|
590
|
+
},
|
|
591
|
+
{
|
|
592
|
+
name: "max-w",
|
|
593
|
+
properties: ["max-inline-size"],
|
|
594
|
+
mode: "dual",
|
|
595
|
+
family: "sizing",
|
|
596
|
+
keywords: SIZING_KEYWORDS,
|
|
597
|
+
pseudo: true,
|
|
598
|
+
},
|
|
599
|
+
{
|
|
600
|
+
name: "min-h",
|
|
601
|
+
properties: ["min-block-size"],
|
|
602
|
+
mode: "dual",
|
|
603
|
+
family: "sizing",
|
|
604
|
+
pseudo: true,
|
|
605
|
+
},
|
|
606
|
+
{
|
|
607
|
+
name: "max-h",
|
|
608
|
+
properties: ["max-block-size"],
|
|
609
|
+
mode: "dual",
|
|
610
|
+
family: "sizing",
|
|
611
|
+
pseudo: true,
|
|
612
|
+
},
|
|
613
|
+
{
|
|
614
|
+
name: "aspect",
|
|
615
|
+
pseudo: true,
|
|
616
|
+
properties: ["aspect-ratio"],
|
|
617
|
+
mode: "raw",
|
|
618
|
+
family: "sizing",
|
|
619
|
+
noBase: "auto",
|
|
620
|
+
},
|
|
621
|
+
// typography: one utility per property; roles live in _typography.css
|
|
622
|
+
{ name: "font-size", pseudo: true, properties: ["font-size"], mode: "raw", family: "typography" },
|
|
623
|
+
{
|
|
624
|
+
name: "font-weight",
|
|
625
|
+
pseudo: true,
|
|
626
|
+
properties: ["font-weight"],
|
|
627
|
+
mode: "raw",
|
|
628
|
+
family: "typography",
|
|
629
|
+
aliases: FONT_WEIGHTS,
|
|
630
|
+
},
|
|
631
|
+
{ name: "font-family", properties: ["font-family"], mode: "raw", family: "typography" },
|
|
632
|
+
{ name: "font-style", properties: ["font-style"], mode: "keyword", family: "typography" },
|
|
633
|
+
{ name: "leading", properties: ["line-height"], mode: "raw", family: "typography" },
|
|
634
|
+
{ name: "tracking", properties: ["letter-spacing"], mode: "raw", family: "typography" },
|
|
635
|
+
{
|
|
636
|
+
name: "text-align",
|
|
637
|
+
properties: ["text-align"],
|
|
638
|
+
mode: "keyword",
|
|
639
|
+
family: "typography",
|
|
640
|
+
noBase: "start",
|
|
641
|
+
},
|
|
642
|
+
{ name: "text-transform", properties: ["text-transform"], mode: "keyword", family: "typography" },
|
|
643
|
+
{
|
|
644
|
+
name: "text-wrap",
|
|
645
|
+
properties: ["text-wrap"],
|
|
646
|
+
mode: "keyword",
|
|
647
|
+
family: "typography",
|
|
648
|
+
noBase: "wrap",
|
|
649
|
+
},
|
|
650
|
+
{
|
|
651
|
+
name: "line-clamp",
|
|
652
|
+
properties: ["-webkit-line-clamp"],
|
|
653
|
+
mode: "integer",
|
|
654
|
+
family: "typography",
|
|
655
|
+
emit: "line-clamp",
|
|
656
|
+
},
|
|
657
|
+
// states too, for the link pattern `--text-decoration--hover: underline`
|
|
658
|
+
{
|
|
659
|
+
name: "text-decoration",
|
|
660
|
+
properties: ["text-decoration-line"],
|
|
661
|
+
mode: "raw",
|
|
662
|
+
family: "typography",
|
|
663
|
+
tiers: "both",
|
|
664
|
+
noBase: "none",
|
|
665
|
+
},
|
|
666
|
+
{ name: "whitespace", properties: ["white-space"], mode: "keyword", family: "typography" },
|
|
667
|
+
// color: states; bg-alpha feeds the bg emission
|
|
668
|
+
{ name: "text", properties: ["color"], mode: "raw", family: "color", pseudo: true },
|
|
669
|
+
{
|
|
670
|
+
name: "bg",
|
|
671
|
+
properties: ["background-color"],
|
|
672
|
+
mode: "raw",
|
|
673
|
+
family: "color",
|
|
674
|
+
emit: "bg",
|
|
675
|
+
pseudo: true,
|
|
676
|
+
},
|
|
677
|
+
{ name: "bg-alpha", properties: [], mode: "raw", family: "color", emit: "none" },
|
|
678
|
+
// gradients: the type utility carries the prelude (direction, shape, position,
|
|
679
|
+
// `in <color-space> [<hue> hue]`), --bg-stops the color stops; they compose
|
|
680
|
+
// into background-image. `--bg: none` also clears background-image.
|
|
681
|
+
// No tiers: a gradient rarely changes per state or breakpoint, and every tier
|
|
682
|
+
// of four utilities cost 1 KB; `--bg--<tier>: none` still clears one.
|
|
683
|
+
...GRADIENT_TYPES.map(
|
|
684
|
+
(type): Utility => ({
|
|
685
|
+
name: `bg-${type}`,
|
|
686
|
+
properties: [],
|
|
687
|
+
mode: "raw",
|
|
688
|
+
family: "color",
|
|
689
|
+
emit: "none",
|
|
690
|
+
tiers: "none",
|
|
691
|
+
}),
|
|
692
|
+
),
|
|
693
|
+
{ name: "bg-stops", properties: [], mode: "raw", family: "color", emit: "none", tiers: "none" },
|
|
694
|
+
{
|
|
695
|
+
name: "border-color",
|
|
696
|
+
properties: ["border-color"],
|
|
697
|
+
mode: "raw",
|
|
698
|
+
family: "color",
|
|
699
|
+
pseudo: true,
|
|
700
|
+
},
|
|
701
|
+
{
|
|
702
|
+
name: "border-width",
|
|
703
|
+
properties: ["border-width"],
|
|
704
|
+
mode: "raw",
|
|
705
|
+
family: "color",
|
|
706
|
+
pseudo: true,
|
|
707
|
+
},
|
|
708
|
+
{
|
|
709
|
+
name: "border-style",
|
|
710
|
+
properties: ["border-style"],
|
|
711
|
+
mode: "raw",
|
|
712
|
+
family: "color",
|
|
713
|
+
pseudo: true,
|
|
714
|
+
},
|
|
715
|
+
// border shorthands: a color, a number (px), or a length; the side rules
|
|
716
|
+
// read them after the all-sides longhands, so --border-color beats --border.
|
|
717
|
+
// A side takes only the shorthand (`--border-b: 1`, `--border-t: red`):
|
|
718
|
+
// per-side width and color longhands were dropped as too rare for their cost
|
|
719
|
+
...BORDER_SHORTHANDS.map(
|
|
720
|
+
(name): Utility => ({ name, properties: [], mode: "raw", family: "color", emit: "border" }),
|
|
721
|
+
),
|
|
722
|
+
// effects: states; ring* and shadow compose into one box-shadow
|
|
723
|
+
{
|
|
724
|
+
name: "opacity",
|
|
725
|
+
pseudo: true,
|
|
726
|
+
properties: ["opacity"],
|
|
727
|
+
mode: "raw",
|
|
728
|
+
family: "effects",
|
|
729
|
+
noBase: "1",
|
|
730
|
+
},
|
|
731
|
+
{
|
|
732
|
+
name: "shadow",
|
|
733
|
+
properties: [],
|
|
734
|
+
mode: "raw",
|
|
735
|
+
family: "effects",
|
|
736
|
+
emit: "none",
|
|
737
|
+
aliases: SHADOWS,
|
|
738
|
+
},
|
|
739
|
+
// the shadow color for an element and its subtree: _variables.css re-declares the
|
|
740
|
+
// --shadow-* tokens wherever this is set, so keyword, var(), and primitive shadows follow
|
|
741
|
+
{ name: "shadow-hue", properties: [], mode: "raw", family: "box", emit: "none" },
|
|
742
|
+
{ name: "ring", properties: [], mode: "raw", family: "effects", emit: "none" },
|
|
743
|
+
{ name: "ring-color", properties: [], mode: "raw", family: "effects", emit: "none" },
|
|
744
|
+
{ name: "ring-offset", properties: [], mode: "raw", family: "effects", emit: "none" },
|
|
745
|
+
{ name: "ring-offset-color", properties: [], mode: "raw", family: "effects", emit: "none" },
|
|
746
|
+
{
|
|
747
|
+
name: "scale",
|
|
748
|
+
pseudo: true,
|
|
749
|
+
properties: ["scale"],
|
|
750
|
+
mode: "raw",
|
|
751
|
+
family: "effects",
|
|
752
|
+
noBase: "none",
|
|
753
|
+
},
|
|
754
|
+
{
|
|
755
|
+
name: "translate",
|
|
756
|
+
pseudo: true,
|
|
757
|
+
properties: ["translate"],
|
|
758
|
+
mode: "raw",
|
|
759
|
+
family: "effects",
|
|
760
|
+
noBase: "none",
|
|
761
|
+
},
|
|
762
|
+
{
|
|
763
|
+
name: "rotate",
|
|
764
|
+
pseudo: true,
|
|
765
|
+
properties: ["rotate"],
|
|
766
|
+
mode: "raw",
|
|
767
|
+
family: "effects",
|
|
768
|
+
noBase: "none",
|
|
769
|
+
},
|
|
770
|
+
{ name: "transition", pseudo: true, properties: ["transition"], mode: "raw", family: "effects" },
|
|
771
|
+
// box: no tiers
|
|
772
|
+
{
|
|
773
|
+
name: "rounded",
|
|
774
|
+
properties: ["border-radius"],
|
|
775
|
+
mode: "raw",
|
|
776
|
+
family: "box",
|
|
777
|
+
pseudo: true,
|
|
778
|
+
noBase: "0",
|
|
779
|
+
},
|
|
780
|
+
{ name: "overflow", properties: ["overflow"], mode: "keyword", family: "box", noBase: "visible" },
|
|
781
|
+
{
|
|
782
|
+
name: "overflow-x",
|
|
783
|
+
properties: ["overflow-x"],
|
|
784
|
+
mode: "keyword",
|
|
785
|
+
family: "box",
|
|
786
|
+
noBase: "visible",
|
|
787
|
+
},
|
|
788
|
+
{
|
|
789
|
+
name: "overflow-y",
|
|
790
|
+
properties: ["overflow-y"],
|
|
791
|
+
mode: "keyword",
|
|
792
|
+
family: "box",
|
|
793
|
+
noBase: "visible",
|
|
794
|
+
},
|
|
795
|
+
{ name: "outline", pseudo: true, properties: ["outline"], mode: "raw", family: "box" },
|
|
796
|
+
{ name: "cursor", properties: ["cursor"], mode: "keyword", family: "box" },
|
|
797
|
+
{
|
|
798
|
+
name: "pointer-events",
|
|
799
|
+
pseudo: true,
|
|
800
|
+
properties: ["pointer-events"],
|
|
801
|
+
mode: "keyword",
|
|
802
|
+
family: "box",
|
|
803
|
+
},
|
|
804
|
+
{ name: "visibility", pseudo: true, properties: ["visibility"], mode: "keyword", family: "box" },
|
|
805
|
+
{ name: "z", pseudo: true, properties: ["z-index"], mode: "raw", family: "box", noBase: "auto" },
|
|
806
|
+
{ name: "object-fit", properties: ["object-fit"], mode: "keyword", family: "box" },
|
|
807
|
+
// the divider between children for the divide-x / divide-y switches: the
|
|
808
|
+
// border shorthand's grammar, emitting only its (inherited) width and color channels
|
|
809
|
+
{ name: "divide", properties: [], mode: "raw", family: "box", emit: "border", inherits: true },
|
|
810
|
+
];
|
|
811
|
+
|
|
812
|
+
/** Utilities that exist only on pseudo-elements. */
|
|
813
|
+
export const PSEUDO_ONLY: readonly Utility[] = [
|
|
814
|
+
{ name: "content", properties: ["content"], mode: "raw", family: "box", pseudo: true },
|
|
815
|
+
];
|
|
816
|
+
|
|
817
|
+
export const PSEUDO_SIDES = ["before", "after"] as const;
|
|
818
|
+
export type PseudoSide = (typeof PSEUDO_SIDES)[number];
|
|
819
|
+
|
|
820
|
+
/** Tier names a utility's family allows, in setter order. */
|
|
821
|
+
export function tiersOf(utility: Utility): readonly string[] {
|
|
822
|
+
const kind = utility.tiers ?? FAMILY_TIERS[utility.family];
|
|
823
|
+
if (kind === "breakpoints") return BREAKPOINTS;
|
|
824
|
+
if (kind === "states") return STATES;
|
|
825
|
+
if (kind === "both") return [...STATES, ...BREAKPOINTS];
|
|
826
|
+
return [];
|
|
827
|
+
}
|
|
828
|
+
|
|
829
|
+
/** A utility property name, split into its parts. */
|
|
830
|
+
export interface UtilityName {
|
|
831
|
+
name: string;
|
|
832
|
+
tier?: string;
|
|
833
|
+
side?: string;
|
|
834
|
+
group?: true;
|
|
835
|
+
}
|
|
836
|
+
|
|
837
|
+
const TIER_NAMES = new Set<string>([...BREAKPOINTS, ...STATES]);
|
|
838
|
+
|
|
839
|
+
/** `--before-w--md` → { side: "before", name: "w", tier: "md" }; `--group-bg--hover` sets `group`. */
|
|
840
|
+
export function parseUtilityName(raw: string): UtilityName {
|
|
841
|
+
let body = raw.slice(2);
|
|
842
|
+
let group: true | undefined;
|
|
843
|
+
if (body.startsWith("group-")) {
|
|
844
|
+
group = true;
|
|
845
|
+
body = body.slice("group-".length);
|
|
846
|
+
}
|
|
847
|
+
let side: string | undefined;
|
|
848
|
+
for (const candidate of PSEUDO_SIDES) {
|
|
849
|
+
if (body.startsWith(`${candidate}-`)) {
|
|
850
|
+
side = candidate;
|
|
851
|
+
body = body.slice(candidate.length + 1);
|
|
852
|
+
break;
|
|
853
|
+
}
|
|
854
|
+
}
|
|
855
|
+
const split = body.lastIndexOf("--");
|
|
856
|
+
if (split > 0 && TIER_NAMES.has(body.slice(split + 2))) {
|
|
857
|
+
return {
|
|
858
|
+
name: body.slice(0, split),
|
|
859
|
+
tier: body.slice(split + 2),
|
|
860
|
+
side,
|
|
861
|
+
...(group ? { group } : {}),
|
|
862
|
+
};
|
|
863
|
+
}
|
|
864
|
+
return { name: body, side, ...(group ? { group } : {}) };
|
|
865
|
+
}
|