@fluixi-css/core 1.0.0-next.1 → 1.0.0-next.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 (53) hide show
  1. package/dist/package.json +1 -1
  2. package/dist/reset.css +174 -152
  3. package/dist/src/css-parser.cjs +6 -1
  4. package/dist/src/css-parser.cjs.map +1 -1
  5. package/dist/src/css-parser.js +6 -2
  6. package/dist/src/css-parser.js.map +1 -1
  7. package/dist/src/css-parser.mjs +6 -1
  8. package/dist/src/css-parser.mjs.map +1 -1
  9. package/dist/src/engine/apply.d.ts +2 -0
  10. package/dist/src/engine/apply.js +75 -0
  11. package/dist/src/engine/apply.js.map +1 -0
  12. package/dist/src/engine/ast.js +25 -2
  13. package/dist/src/engine/ast.js.map +1 -1
  14. package/dist/src/engine/atom.js +8 -1
  15. package/dist/src/engine/atom.js.map +1 -1
  16. package/dist/src/engine/compile.js +48 -10
  17. package/dist/src/engine/compile.js.map +1 -1
  18. package/dist/src/engine/directives.js +45 -19
  19. package/dist/src/engine/directives.js.map +1 -1
  20. package/dist/src/engine/index.d.ts +4 -0
  21. package/dist/src/engine/index.js +11 -5
  22. package/dist/src/engine/index.js.map +1 -1
  23. package/dist/src/engine/log.d.ts +6 -0
  24. package/dist/src/engine/log.js +42 -0
  25. package/dist/src/engine/log.js.map +1 -0
  26. package/dist/src/engine/registry.d.ts +5 -4
  27. package/dist/src/engine/registry.js +2 -2
  28. package/dist/src/engine/registry.js.map +1 -1
  29. package/dist/src/engine/transform.d.ts +22 -0
  30. package/dist/src/engine/transform.js +60 -30
  31. package/dist/src/engine/transform.js.map +1 -1
  32. package/dist/src/engine/ui-preset.d.ts +20 -1
  33. package/dist/src/engine/ui-preset.js +87 -9
  34. package/dist/src/engine/ui-preset.js.map +1 -1
  35. package/dist/src/engine/utilities/backgrounds.js +11 -0
  36. package/dist/src/engine/utilities/backgrounds.js.map +1 -1
  37. package/dist/src/engine/utilities/borders.js +60 -1
  38. package/dist/src/engine/utilities/borders.js.map +1 -1
  39. package/dist/src/engine/utilities/layout.js +25 -0
  40. package/dist/src/engine/utilities/layout.js.map +1 -1
  41. package/dist/src/engine/utilities/spacing.js +25 -1
  42. package/dist/src/engine/utilities/spacing.js.map +1 -1
  43. package/dist/src/engine/utilities/typography.js +7 -0
  44. package/dist/src/engine/utilities/typography.js.map +1 -1
  45. package/dist/src/engine/variants.js +25 -6
  46. package/dist/src/engine/variants.js.map +1 -1
  47. package/dist/src/index.cjs +748 -209
  48. package/dist/src/index.cjs.map +1 -1
  49. package/dist/src/index.mjs +746 -210
  50. package/dist/src/index.mjs.map +1 -1
  51. package/dist/tsconfig.tsbuildinfo +1 -1
  52. package/package.json +1 -1
  53. package/reset.css +174 -152
@@ -2,8 +2,18 @@ import { decl, rule } from './ast';
2
2
  // Bridges a fluixi-css theme to the `--flx-ui-*` custom properties the Fluixi UI
3
3
  // components read (`@fluixi-ui/tokens`). Each bridge emits `--flx-ui-x: var(--src)`
4
4
  // so a fluixi-css theme *drives* the UI — change the theme, the components follow —
5
- // without copying any values across. A bridge is emitted only when its source
6
- // token exists, so the UI's own defaults stand in for anything the theme omits.
5
+ // without copying any values across. A primitive bridge is emitted only when its
6
+ // source token exists, so the UI's own defaults stand in for anything the theme omits.
7
+ //
8
+ // Colour is the driven half: when the theme supplies the functional scales
9
+ // (`--color-accent-1..12` / `--color-gray-1..12`), this also emits the UI's whole
10
+ // *semantic* layer (`--flx-ui-color-primary`, …). That layer is purely structural —
11
+ // every var references a scale/alias var, never a concrete colour — so it carries no
12
+ // palette data across the package boundary; `@fluixi-ui/tokens` still owns the
13
+ // default values. The semantic layer is re-emitted in a dark scope because
14
+ // custom-property substitution freezes at the declaring element: a `:root`-only
15
+ // `--flx-ui-color-primary: var(--flx-ui-accent-9)` would inherit light's *resolved*
16
+ // colour into a dark subtree instead of re-resolving against the dark scale.
7
17
  // UI space scale ↔ the `--spacing` base (space-4 = 1rem = 0.25rem × 4).
8
18
  const SPACE_STEPS = [0, 1, 2, 3, 4, 5, 6, 8, 10, 12, 16, 20, 24];
9
19
  // UI font-size keys ↔ fluixi `--text-*` keys (the UI's `md` is fluixi's `base`).
@@ -20,6 +30,46 @@ const FONT_SIZE = [
20
30
  const RADIUS = ['sm', 'md', 'lg', 'xl'];
21
31
  const SHADOW = ['sm', 'md', 'lg', 'xl'];
22
32
  const BREAKPOINT = ['sm', 'md', 'lg', 'xl', '2xl'];
33
+ // The UI's semantic layer, mirrored from `@fluixi-ui/tokens` (`semanticColors`).
34
+ // Structural only — refs into the scales/aliases the bridge (or the UI's own
35
+ // defaults) provide. `color-primary-fg` and `color-overlay` are intentionally
36
+ // omitted: they're concrete kit defaults, not scale-derived, so the UI package
37
+ // keeps ownership of them.
38
+ const SEMANTIC = [
39
+ ['color-bg', 'gray-1'],
40
+ ['color-bg-subtle', 'gray-2'],
41
+ ['color-bg-muted', 'gray-3'],
42
+ ['color-fg', 'gray-12'],
43
+ ['color-fg-muted', 'gray-11'],
44
+ ['color-border', 'gray-6'],
45
+ ['color-border-strong', 'gray-7'],
46
+ ['color-focus-ring', 'accent-8'],
47
+ ['color-primary', 'accent-9'],
48
+ ['color-primary-hover', 'accent-10'],
49
+ ['color-primary-active', 'accent-11'],
50
+ ['color-primary-subtle', 'accent-3'],
51
+ ['color-danger', 'danger-solid'],
52
+ ['color-danger-fg', 'danger-fg'],
53
+ ['color-danger-subtle', 'danger-subtle'],
54
+ ['color-success', 'success-solid'],
55
+ ['color-success-fg', 'success-fg'],
56
+ ['color-success-subtle', 'success-subtle'],
57
+ ['color-warning', 'warning-solid'],
58
+ ['color-warning-fg', 'warning-fg'],
59
+ ['color-warning-subtle', 'warning-subtle'],
60
+ ];
61
+ // Optional status-colour bridges: a theme may drive the UI's danger/success/
62
+ // warning solids by supplying `--color-danger` / `--color-success` / `--color-warning`.
63
+ const STATUS = [
64
+ ['danger-solid', '--color-danger'],
65
+ ['success-solid', '--color-success'],
66
+ ['warning-solid', '--color-warning'],
67
+ ];
68
+ /** True once the theme supplies enough of the functional scales to drive colour. */
69
+ function hasColorScales(theme) {
70
+ return theme.has('--color-accent-9') || theme.has('--color-gray-1');
71
+ }
72
+ /** The primitive + scale bridges (non-colour and the raw scale refs). */
23
73
  export function uiTokenBridges(theme) {
24
74
  const out = [];
25
75
  const bridge = (flx, source) => {
@@ -39,18 +89,46 @@ export function uiTokenBridges(theme) {
39
89
  bridge(`shadow-${k}`, `--shadow-${k}`);
40
90
  for (const k of BREAKPOINT)
41
91
  bridge(`breakpoint-${k}`, `--breakpoint-${k}`);
42
- // The functional colour scales are opt-in: a project supplies a Radix-style
43
- // `--color-accent-1..12` / `--color-gray-1..12` in its theme and the UI's
44
- // semantic colours (`--flx-ui-color-primary`, …) follow. Absent them, the UI's
45
- // built-in scales stand.
92
+ // Functional colour scales are opt-in: supply a Radix-style 1..12 ramp and the
93
+ // UI's semantic colours follow. Absent them, the UI's built-in scales stand.
46
94
  for (let i = 1; i <= 12; i++) {
47
95
  bridge(`accent-${i}`, `--color-accent-${i}`);
48
96
  bridge(`gray-${i}`, `--color-gray-${i}`);
49
97
  }
98
+ for (const [flx, source] of STATUS)
99
+ bridge(flx, source);
50
100
  return out;
51
101
  }
52
- // The bridges as a `:root { … }` rule, ready to prepend to the compiled sheet.
53
- export function emitUiTheme(theme, selector = ':root') {
54
- return rule(selector, uiTokenBridges(theme));
102
+ /** The structural semantic layer — emitted only when the theme drives colour. */
103
+ export function uiSemanticLayer(theme) {
104
+ if (!hasColorScales(theme))
105
+ return [];
106
+ return SEMANTIC.map(([name, ref]) => decl(`--flx-ui-${name}`, `var(--flx-ui-${ref})`));
107
+ }
108
+ /**
109
+ * The bridges as sibling top-level rules, ready to prepend to the compiled sheet:
110
+ * `:root` (primitives + scales + semantic layer) and, when the theme drives
111
+ * colour, a dark-scope re-emit of the colour half so its `var()` refs re-resolve
112
+ * against the theme's dark-scoped `--color-*` values.
113
+ */
114
+ export function emitUiTheme(theme, options = {}) {
115
+ const { selector = ':root', darkSelector = "[data-theme='dark']" } = options;
116
+ const out = [rule(selector, [...uiTokenBridges(theme), ...uiSemanticLayer(theme)])];
117
+ if (darkSelector && hasColorScales(theme)) {
118
+ // Re-emit only the colour half in the dark scope (primitives don't flip).
119
+ const darkColor = [];
120
+ for (let i = 1; i <= 12; i++) {
121
+ if (theme.has(`--color-accent-${i}`))
122
+ darkColor.push(decl(`--flx-ui-accent-${i}`, `var(--color-accent-${i})`));
123
+ if (theme.has(`--color-gray-${i}`))
124
+ darkColor.push(decl(`--flx-ui-gray-${i}`, `var(--color-gray-${i})`));
125
+ }
126
+ for (const [flx, source] of STATUS)
127
+ if (theme.has(source))
128
+ darkColor.push(decl(`--flx-ui-${flx}`, `var(${source})`));
129
+ darkColor.push(...uiSemanticLayer(theme));
130
+ out.push(rule(darkSelector, darkColor));
131
+ }
132
+ return out;
55
133
  }
56
134
  //# sourceMappingURL=ui-preset.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ui-preset.js","sourceRoot":"","sources":["../../../src/engine/ui-preset.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoC,IAAI,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAGrE,iFAAiF;AACjF,oFAAoF;AACpF,oFAAoF;AACpF,8EAA8E;AAC9E,gFAAgF;AAEhF,wEAAwE;AACxE,MAAM,WAAW,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;AAEjE,iFAAiF;AACjF,MAAM,SAAS,GAAuB;IACpC,CAAC,IAAI,EAAE,IAAI,CAAC;IACZ,CAAC,IAAI,EAAE,IAAI,CAAC;IACZ,CAAC,IAAI,EAAE,MAAM,CAAC;IACd,CAAC,IAAI,EAAE,IAAI,CAAC;IACZ,CAAC,IAAI,EAAE,IAAI,CAAC;IACZ,CA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,MAAM,CAAC,IAAI,MAAM;QAAE,MAAM,CAAC,UAAU,CAAC,EAAE,EAAE,YAAY,CAAC,EAAE,CAAC,CAAC;IAC/D,KAAK,MAAM,CAAC,IAAI,UAAU;QAAE,MAAM,CAAC,cAAc,CAAC,EAAE,EAAE,gBAAgB,CAAC,EAAE,CAAC,CAAC;IAE3E,4EAA4E;IAC5E,0EAA0E;IAC1E,+EAA+E;IAC/E,yBAAyB;IACzB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC;QAC7B,MAAM,CAAC,UAAU,CAAC,EAAE,EAAE,kBAAkB,CAAC,EAAE,CAAC,CAAC;QAC7C,MAAM,CAAC,QAAQ,CAAC,EAAE,EAAE,gBAAgB,CAAC,EAAE,CAAC,CAAC;IAC3C,CAAC;IAED,OAAO,GAAG,CAAC;AACb,CAAC;AAED,+EAA+E;AAC/E,MAAM,UAAU,WAAW,CAAC,KAAY,EAAE,QAAQ,GAAG,OAAO;IAC1D,OAAO,IAAI,CAAC,QAAQ,EAAE,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC;AAC/C,CAAC","sourcesContent":["import { type Declaration, type StyleRule, decl, rule } from './ast';\nimport { Theme } from './theme';\n\n// Bridges a fluixi-css theme to the `--flx-ui-*` custom properties the Fluixi UI\n// components read (`@fluixi-ui/tokens`). Each bridge emits `--flx-ui-x: var(--src)`\n// so a fluixi-css theme *drives* the UI — change the theme, the components follow —\n// without copying any values across. A bridge is emitted only when its source\n// token exists, so the UI's own defaults stand in for anything the theme omits.\n\n// UI space scale ↔ the `--spacing` base (space-4 = 1rem = 0.25rem × 4).\nconst SPACE_STEPS = [0, 1, 2, 3, 4, 5, 6, 8, 10, 12, 16, 20, 24];\n\n// UI font-size keys ↔ fluixi `--text-*` keys (the UI's `md` is fluixi's `base`).\nconst FONT_SIZE: [string, string][] = [\n ['xs', 'xs'],\n ['sm', 'sm'],\n ['md', 'base'],\n ['lg', 'lg'],\n ['xl', 'xl'],\n ['2xl', '2xl'],\n ['3xl', '3xl'],\n ['4xl', '4xl'],\n];\n\nconst RADIUS = ['sm', 'md', 'lg', 'xl'];\nconst SHADOW = ['sm', 'md', 'lg', 'xl'];\nconst BREAKPOINT = ['sm', 'md', 'lg', 'xl', '2xl'];\n\nexport function uiTokenBridges(theme: Theme): Declaration[] {\n const out: Declaration[] = [];\n const bridge = (flx: string, source: string) => {\n if (theme.has(source)) out.push(decl(`--flx-ui-${flx}`, `var(${source})`));\n };\n\n if (theme.has('--spacing')) {\n for (const n of SPACE_STEPS) {\n out.push(decl(`--flx-ui-space-${n}`, n === 0 ? '0px' : `calc(var(--spacing) * ${n})`));\n }\n }\n\n for (const k of RADIUS) bridge(`radius-${k}`, `--radius-${k}`);\n for (const [flx, key] of FONT_SIZE) bridge(`font-size-${flx}`, `--text-${key}`);\n for (const k of SHADOW) bridge(`shadow-${k}`, `--shadow-${k}`);\n for (const k of BREAKPOINT) bridge(`breakpoint-${k}`, `--breakpoint-${k}`);\n\n // The functional colour scales are opt-in: a project supplies a Radix-style\n // `--color-accent-1..12` / `--color-gray-1..12` in its theme and the UI's\n // semantic colours (`--flx-ui-color-primary`, …) follow. Absent them, the UI's\n // built-in scales stand.\n for (let i = 1; i <= 12; i++) {\n bridge(`accent-${i}`, `--color-accent-${i}`);\n bridge(`gray-${i}`, `--color-gray-${i}`);\n }\n\n return out;\n}\n\n// The bridges as a `:root { … }` rule, ready to prepend to the compiled sheet.\nexport function emitUiTheme(theme: Theme, selector = ':root'): StyleRule {\n return rule(selector, uiTokenBridges(theme));\n}\n"]}
1
+ {"version":3,"file":"ui-preset.js","sourceRoot":"","sources":["../../../src/engine/ui-preset.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkD,IAAI,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAGnF,iFAAiF;AACjF,oFAAoF;AACpF,oFAAoF;AACpF,iFAAiF;AACjF,uFAAuF;AACvF,EAAE;AACF,2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AC,IAAI,MAAM;YAAE,IAAI,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC;gBAAE,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,GAAG,EAAE,EAAE,OAAO,MAAM,GAAG,CAAC,CAAC,CAAC;QACrH,SAAS,CAAC,IAAI,CAAC,GAAG,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC;QAC1C,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC,CAAC;IAC1C,CAAC;IAED,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["import { type AstNode, type Declaration, type StyleRule, decl, rule } from './ast';\nimport { Theme } from './theme';\n\n// Bridges a fluixi-css theme to the `--flx-ui-*` custom properties the Fluixi UI\n// components read (`@fluixi-ui/tokens`). Each bridge emits `--flx-ui-x: var(--src)`\n// so a fluixi-css theme *drives* the UI — change the theme, the components follow —\n// without copying any values across. A primitive bridge is emitted only when its\n// source token exists, so the UI's own defaults stand in for anything the theme omits.\n//\n// Colour is the driven half: when the theme supplies the functional scales\n// (`--color-accent-1..12` / `--color-gray-1..12`), this also emits the UI's whole\n// *semantic* layer (`--flx-ui-color-primary`, …). That layer is purely structural —\n// every var references a scale/alias var, never a concrete colour — so it carries no\n// palette data across the package boundary; `@fluixi-ui/tokens` still owns the\n// default values. The semantic layer is re-emitted in a dark scope because\n// custom-property substitution freezes at the declaring element: a `:root`-only\n// `--flx-ui-color-primary: var(--flx-ui-accent-9)` would inherit light's *resolved*\n// colour into a dark subtree instead of re-resolving against the dark scale.\n\n// UI space scale ↔ the `--spacing` base (space-4 = 1rem = 0.25rem × 4).\nconst SPACE_STEPS = [0, 1, 2, 3, 4, 5, 6, 8, 10, 12, 16, 20, 24];\n\n// UI font-size keys ↔ fluixi `--text-*` keys (the UI's `md` is fluixi's `base`).\nconst FONT_SIZE: [string, string][] = [\n ['xs', 'xs'],\n ['sm', 'sm'],\n ['md', 'base'],\n ['lg', 'lg'],\n ['xl', 'xl'],\n ['2xl', '2xl'],\n ['3xl', '3xl'],\n ['4xl', '4xl'],\n];\n\nconst RADIUS = ['sm', 'md', 'lg', 'xl'];\nconst SHADOW = ['sm', 'md', 'lg', 'xl'];\nconst BREAKPOINT = ['sm', 'md', 'lg', 'xl', '2xl'];\n\n// The UI's semantic layer, mirrored from `@fluixi-ui/tokens` (`semanticColors`).\n// Structural only — refs into the scales/aliases the bridge (or the UI's own\n// defaults) provide. `color-primary-fg` and `color-overlay` are intentionally\n// omitted: they're concrete kit defaults, not scale-derived, so the UI package\n// keeps ownership of them.\nconst SEMANTIC: [string, string][] = [\n ['color-bg', 'gray-1'],\n ['color-bg-subtle', 'gray-2'],\n ['color-bg-muted', 'gray-3'],\n ['color-fg', 'gray-12'],\n ['color-fg-muted', 'gray-11'],\n ['color-border', 'gray-6'],\n ['color-border-strong', 'gray-7'],\n ['color-focus-ring', 'accent-8'],\n ['color-primary', 'accent-9'],\n ['color-primary-hover', 'accent-10'],\n ['color-primary-active', 'accent-11'],\n ['color-primary-subtle', 'accent-3'],\n ['color-danger', 'danger-solid'],\n ['color-danger-fg', 'danger-fg'],\n ['color-danger-subtle', 'danger-subtle'],\n ['color-success', 'success-solid'],\n ['color-success-fg', 'success-fg'],\n ['color-success-subtle', 'success-subtle'],\n ['color-warning', 'warning-solid'],\n ['color-warning-fg', 'warning-fg'],\n ['color-warning-subtle', 'warning-subtle'],\n];\n\n// Optional status-colour bridges: a theme may drive the UI's danger/success/\n// warning solids by supplying `--color-danger` / `--color-success` / `--color-warning`.\nconst STATUS: [string, string][] = [\n ['danger-solid', '--color-danger'],\n ['success-solid', '--color-success'],\n ['warning-solid', '--color-warning'],\n];\n\n/** True once the theme supplies enough of the functional scales to drive colour. */\nfunction hasColorScales(theme: Theme): boolean {\n return theme.has('--color-accent-9') || theme.has('--color-gray-1');\n}\n\n/** The primitive + scale bridges (non-colour and the raw scale refs). */\nexport function uiTokenBridges(theme: Theme): Declaration[] {\n const out: Declaration[] = [];\n const bridge = (flx: string, source: string) => {\n if (theme.has(source)) out.push(decl(`--flx-ui-${flx}`, `var(${source})`));\n };\n\n if (theme.has('--spacing')) {\n for (const n of SPACE_STEPS) {\n out.push(decl(`--flx-ui-space-${n}`, n === 0 ? '0px' : `calc(var(--spacing) * ${n})`));\n }\n }\n\n for (const k of RADIUS) bridge(`radius-${k}`, `--radius-${k}`);\n for (const [flx, key] of FONT_SIZE) bridge(`font-size-${flx}`, `--text-${key}`);\n for (const k of SHADOW) bridge(`shadow-${k}`, `--shadow-${k}`);\n for (const k of BREAKPOINT) bridge(`breakpoint-${k}`, `--breakpoint-${k}`);\n\n // Functional colour scales are opt-in: supply a Radix-style 1..12 ramp and the\n // UI's semantic colours follow. Absent them, the UI's built-in scales stand.\n for (let i = 1; i <= 12; i++) {\n bridge(`accent-${i}`, `--color-accent-${i}`);\n bridge(`gray-${i}`, `--color-gray-${i}`);\n }\n for (const [flx, source] of STATUS) bridge(flx, source);\n\n return out;\n}\n\n/** The structural semantic layer — emitted only when the theme drives colour. */\nexport function uiSemanticLayer(theme: Theme): Declaration[] {\n if (!hasColorScales(theme)) return [];\n return SEMANTIC.map(([name, ref]) => decl(`--flx-ui-${name}`, `var(--flx-ui-${ref})`));\n}\n\nexport interface EmitUiOptions {\n /** Root scope for the bridges + semantic layer. */\n selector?: string;\n /**\n * Dark scope. The scale bridges + semantic layer are re-emitted here so the\n * `var()` refs re-resolve against the theme's dark-scoped `--color-*` values.\n * Emitted only when the theme drives colour. Pass `null` to skip.\n */\n darkSelector?: string | null;\n}\n\n/**\n * The bridges as sibling top-level rules, ready to prepend to the compiled sheet:\n * `:root` (primitives + scales + semantic layer) and, when the theme drives\n * colour, a dark-scope re-emit of the colour half so its `var()` refs re-resolve\n * against the theme's dark-scoped `--color-*` values.\n */\nexport function emitUiTheme(theme: Theme, options: EmitUiOptions = {}): StyleRule[] {\n const { selector = ':root', darkSelector = \"[data-theme='dark']\" } = options;\n\n const out: StyleRule[] = [rule(selector, [...uiTokenBridges(theme), ...uiSemanticLayer(theme)])];\n\n if (darkSelector && hasColorScales(theme)) {\n // Re-emit only the colour half in the dark scope (primitives don't flip).\n const darkColor: AstNode[] = [];\n for (let i = 1; i <= 12; i++) {\n if (theme.has(`--color-accent-${i}`)) darkColor.push(decl(`--flx-ui-accent-${i}`, `var(--color-accent-${i})`));\n if (theme.has(`--color-gray-${i}`)) darkColor.push(decl(`--flx-ui-gray-${i}`, `var(--color-gray-${i})`));\n }\n for (const [flx, source] of STATUS) if (theme.has(source)) darkColor.push(decl(`--flx-ui-${flx}`, `var(${source})`));\n darkColor.push(...uiSemanticLayer(theme));\n out.push(rule(darkSelector, darkColor));\n }\n\n return out;\n}\n"]}
@@ -28,5 +28,16 @@ export function registerBackgrounds(reg) {
28
28
  'right-bottom': 'right bottom',
29
29
  });
30
30
  props(reg, 'background-image', { 'bg-none': 'none' });
31
+ // Form-control colours.
32
+ reg.dynamicRule('accent', ({ value, modifier, theme }) => {
33
+ if ((value === null || value === void 0 ? void 0 : value.kind) === 'named' && value.value === 'auto')
34
+ return [decl('accent-color', 'auto')];
35
+ const c = colorValue(value, modifier, theme);
36
+ return c ? [decl('accent-color', c)] : null;
37
+ });
38
+ reg.dynamicRule('caret', ({ value, modifier, theme }) => {
39
+ const c = colorValue(value, modifier, theme);
40
+ return c ? [decl('caret-color', c)] : null;
41
+ });
31
42
  }
32
43
  //# sourceMappingURL=backgrounds.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"backgrounds.js","sourceRoot":"","sources":["../../../../src/engine/utilities/backgrounds.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAEvD,MAAM,UAAU,mBAAmB,CAAC,GAAa;IAC/C,GAAG,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE,EAAE;QACnD,MAAM,CAAC,GAAG,UAAU,CAAC,KAAK,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;QAC7C,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,kBAAkB,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAClD,CAAC,CAAC,CAAC;IAEH,kEAAkE;IAClE,QAAQ,CAAC,GAAG,EAAE,IAAI,EAAE,mBAAmB,EAAE;QACvC,MAAM,EAAE,QAAQ;QAChB,WAAW,EAAE,WAAW;QACxB,UAAU,EAAE,UAAU;QACtB,UAAU,EAAE,UAAU;QACtB,cAAc,EAAE,OAAO;QACvB,cAAc,EAAE,OAAO;KACxB,CAAC,CAAC;IACH,QAAQ,CAAC,GAAG,EAAE,IAAI,EAAE,iBAAiB,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC,CAAC;IAC7F,QAAQ,CAAC,GAAG,EAAE,IAAI,EAAE,uBAAuB,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC;IACnG,QAAQ,CAAC,GAAG,EAAE,IAAI,EAAE,qBAAqB,EAAE;QACzC,MAAM,EAAE,QAAQ;QAChB,GAAG,EAAE,KAAK;QACV,MAAM,EAAE,QAAQ;QAChB,IAAI,EAAE,MAAM;QACZ,KAAK,EAAE,OAAO;QACd,UAAU,EAAE,UAAU;QACtB,WAAW,EAAE,WAAW;QACxB,aAAa,EAAE,aAAa;QAC5B,cAAc,EAAE,cAAc;KAC/B,CAAC,CAAC;IACH,KAAK,CAAC,GAAG,EAAE,kBAAkB,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC,CAAC;AACxD,CAAC","sourcesContent":["import { decl } from '../ast';\nimport type { Registry } from '../registry';\nimport { colorValue, keywords, props } from './values';\n\nexport function registerBackgrounds(reg: Registry): void {\n reg.dynamicRule('bg', ({ value, modifier, theme }) => {\n const c = colorValue(value, modifier, theme);\n return c ? [decl('background-color', c)] : null;\n });\n\n // Keyword forms of `bg-*` — these win over the colour root above.\n keywords(reg, 'bg', 'background-repeat', {\n repeat: 'repeat',\n 'no-repeat': 'no-repeat',\n 'repeat-x': 'repeat-x',\n 'repeat-y': 'repeat-y',\n 'repeat-round': 'round',\n 'repeat-space': 'space',\n });\n keywords(reg, 'bg', 'background-size', { auto: 'auto', cover: 'cover', contain: 'contain' });\n keywords(reg, 'bg', 'background-attachment', { fixed: 'fixed', local: 'local', scroll: 'scroll' });\n keywords(reg, 'bg', 'background-position', {\n center: 'center',\n top: 'top',\n bottom: 'bottom',\n left: 'left',\n right: 'right',\n 'left-top': 'left top',\n 'right-top': 'right top',\n 'left-bottom': 'left bottom',\n 'right-bottom': 'right bottom',\n });\n props(reg, 'background-image', { 'bg-none': 'none' });\n}\n"]}
1
+ {"version":3,"file":"backgrounds.js","sourceRoot":"","sources":["../../../../src/engine/utilities/backgrounds.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAEvD,MAAM,UAAU,mBAAmB,CAAC,GAAa;IAC/C,GAAG,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE,EAAE;QACnD,MAAM,CAAC,GAAG,UAAU,CAAC,KAAK,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;QAC7C,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,kBAAkB,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAClD,CAAC,CAAC,CAAC;IAEH,kEAAkE;IAClE,QAAQ,CAAC,GAAG,EAAE,IAAI,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CAAC;QAC7C,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAC9C,CAAC,CAAC,CAAC;IACH,GAAG,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE,EAAE;QACtD,MAAM,CAAC,GAAG,UAAU,CAAC,KAAK,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;QAC7C,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAC7C,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { decl } from '../ast';\nimport type { Registry } from '../registry';\nimport { colorValue, keywords, props } from './values';\n\nexport function registerBackgrounds(reg: Registry): void {\n reg.dynamicRule('bg', ({ value, modifier, theme }) => {\n const c = colorValue(value, modifier, theme);\n return c ? [decl('background-color', c)] : null;\n });\n\n // Keyword forms of `bg-*` — these win over the colour root above.\n keywords(reg, 'bg', 'background-repeat', {\n repeat: 'repeat',\n 'no-repeat': 'no-repeat',\n 'repeat-x': 'repeat-x',\n 'repeat-y': 'repeat-y',\n 'repeat-round': 'round',\n 'repeat-space': 'space',\n });\n keywords(reg, 'bg', 'background-size', { auto: 'auto', cover: 'cover', contain: 'contain' });\n keywords(reg, 'bg', 'background-attachment', { fixed: 'fixed', local: 'local', scroll: 'scroll' });\n keywords(reg, 'bg', 'background-position', {\n center: 'center',\n top: 'top',\n bottom: 'bottom',\n left: 'left',\n right: 'right',\n 'left-top': 'left top',\n 'right-top': 'right top',\n 'left-bottom': 'left bottom',\n 'right-bottom': 'right bottom',\n });\n props(reg, 'background-image', { 'bg-none': 'none' });\n\n // Form-control colours.\n reg.dynamicRule('accent', ({ value, modifier, theme }) => {\n if (value?.kind === 'named' && value.value === 'auto') return [decl('accent-color', 'auto')];\n const c = colorValue(value, modifier, theme);\n return c ? [decl('accent-color', c)] : null;\n });\n reg.dynamicRule('caret', ({ value, modifier, theme }) => {\n const c = colorValue(value, modifier, theme);\n return c ? [decl('caret-color', c)] : null;\n });\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { decl } from '../ast';
1
+ import { decl, rule } from '../ast';
2
2
  import { colorValue, keywords } from './values';
3
3
  export function registerBorders(reg) {
4
4
  border(reg, 'border', 'border', ['-top', '-right', '-bottom', '-left']);
@@ -18,6 +18,8 @@ export function registerBorders(reg) {
18
18
  hidden: 'hidden',
19
19
  none: 'none',
20
20
  });
21
+ divide(reg);
22
+ ring(reg);
21
23
  rounded(reg, 'rounded', ['']);
22
24
  rounded(reg, 'rounded-t', ['-top-left', '-top-right']);
23
25
  rounded(reg, 'rounded-r', ['-top-right', '-bottom-right']);
@@ -92,4 +94,61 @@ function outline(reg) {
92
94
  return color ? [decl('outline-color', color)] : null;
93
95
  });
94
96
  }
97
+ // Borders *between* children (adjacent-sibling combinator). `divide-x`/`divide-y`
98
+ // set the width, `divide-{color}`/`divide-{style}` the rest; `-reverse` flips the
99
+ // edge via a `--flx-divide-*-reverse` toggle.
100
+ const BETWEEN = '& > :not([hidden]) ~ :not([hidden])';
101
+ function divide(reg) {
102
+ divideWidth(reg, 'x', 'border-right-width', 'border-left-width');
103
+ divideWidth(reg, 'y', 'border-top-width', 'border-bottom-width');
104
+ reg.dynamicRule('divide', ({ value, modifier, theme }) => {
105
+ if (value === null)
106
+ return null;
107
+ const style = value.kind === 'named' ? DIVIDE_STYLES[value.value] : undefined;
108
+ if (style)
109
+ return [rule(BETWEEN, [decl('border-style', style)])];
110
+ const color = colorFor(value, modifier, theme);
111
+ return color ? [rule(BETWEEN, [decl('border-color', color)])] : null;
112
+ });
113
+ }
114
+ const DIVIDE_STYLES = {
115
+ solid: 'solid',
116
+ dashed: 'dashed',
117
+ dotted: 'dotted',
118
+ double: 'double',
119
+ none: 'none',
120
+ };
121
+ function divideWidth(reg, axis, reverseProp, mainProp) {
122
+ const flag = `--flx-divide-${axis}-reverse`;
123
+ reg.dynamicRule(`divide-${axis}`, ({ value }) => {
124
+ if ((value === null || value === void 0 ? void 0 : value.kind) === 'named' && value.value === 'reverse')
125
+ return [rule(BETWEEN, [decl(flag, '1')])];
126
+ const w = widthValue(value, '1px');
127
+ if (w === null)
128
+ return null;
129
+ return [
130
+ rule(BETWEEN, [
131
+ decl(flag, '0'),
132
+ decl(reverseProp, `calc(${w} * var(${flag}))`),
133
+ decl(mainProp, `calc(${w} * calc(1 - var(${flag})))`),
134
+ ]),
135
+ ];
136
+ });
137
+ }
138
+ // A focus/selection ring drawn as a box-shadow, composed through `--flx-ring-*`
139
+ // (declared in reset.css) so `ring`, `ring-{color}` and `ring-inset` stack.
140
+ function ring(reg) {
141
+ reg.rule('ring-inset', [decl('--flx-ring-inset', 'inset')]);
142
+ reg.dynamicRule('ring', ({ value, modifier, theme }) => {
143
+ const w = value === null ? '3px' : widthValue(value, null);
144
+ if (w !== null) {
145
+ return [
146
+ decl('--flx-ring-shadow', `var(--flx-ring-inset) 0 0 0 calc(${w} + var(--flx-ring-offset-width)) var(--flx-ring-color)`),
147
+ decl('box-shadow', 'var(--flx-ring-offset-shadow), var(--flx-ring-shadow), var(--flx-shadow, 0 0 #0000)'),
148
+ ];
149
+ }
150
+ const color = colorFor(value, modifier, theme);
151
+ return color ? [decl('--flx-ring-color', color)] : null;
152
+ });
153
+ }
95
154
  //# sourceMappingURL=borders.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"borders.js","sourceRoot":"","sources":["../../../../src/engine/utilities/borders.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,IAAI,EAAE,MAAM,QAAQ,CAAC;AAIhD,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEhD,MAAM,UAAU,eAAe,CAAC,GAAa;IAC3C,MAAM,CAAC,GAAG,EAAE,QAAQ,EAAE,QAAQ,EAAE,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AC;QAC/C,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,eAAe,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACvD,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { type Declaration, decl } from '../ast';\nimport type { AtomModifier, AtomValue } from '../atom';\nimport type { Registry } from '../registry';\nimport { Theme } from '../theme';\nimport { colorValue, keywords } from './values';\n\nexport function registerBorders(reg: Registry): void {\n border(reg, 'border', 'border', ['-top', '-right', '-bottom', '-left']);\n border(reg, 'border-x', 'border', ['-left', '-right']);\n border(reg, 'border-y', 'border', ['-top', '-bottom']);\n border(reg, 'border-t', 'border', ['-top']);\n border(reg, 'border-r', 'border', ['-right']);\n border(reg, 'border-b', 'border', ['-bottom']);\n border(reg, 'border-l', 'border', ['-left']);\n border(reg, 'border-s', 'border', ['-inline-start']);\n border(reg, 'border-e', 'border', ['-inline-end']);\n\n keywords(reg, 'border', 'border-style', {\n solid: 'solid',\n dashed: 'dashed',\n dotted: 'dotted',\n double: 'double',\n hidden: 'hidden',\n none: 'none',\n });\n\n rounded(reg, 'rounded', ['']);\n rounded(reg, 'rounded-t', ['-top-left', '-top-right']);\n rounded(reg, 'rounded-r', ['-top-right', '-bottom-right']);\n rounded(reg, 'rounded-b', ['-bottom-right', '-bottom-left']);\n rounded(reg, 'rounded-l', ['-top-left', '-bottom-left']);\n rounded(reg, 'rounded-tl', ['-top-left']);\n rounded(reg, 'rounded-tr', ['-top-right']);\n rounded(reg, 'rounded-br', ['-bottom-right']);\n rounded(reg, 'rounded-bl', ['-bottom-left']);\n\n outline(reg);\n}\n\n// `border`, `border-2`, `border-red-500`, `border-[#fff]`, `border-[2px]` all share\n// one root: a bare value or number is a width, a colour token/arbitrary is a colour.\nfunction border(reg: Registry, root: string, base: string, sides: string[]): void {\n reg.dynamicRule(root, ({ value, modifier, theme }) => {\n const width = widthValue(value, base === 'border' ? '1px' : null);\n if (width !== null) return sides.map((s) => decl(`${base}${s}-width`, width));\n const color = colorFor(value, modifier, theme);\n return color ? sides.map((s) => decl(`${base}${s}-color`, color)) : null;\n });\n}\n\nfunction widthValue(value: AtomValue | null, bare: string | null): string | null {\n if (value === null) return bare;\n if (value.kind === 'arbitrary') {\n if (value.dataType === 'length') return value.value;\n if (value.dataType === null && /^[\\d.]+(px|rem|em|%)$/.test(value.value)) return value.value;\n return null;\n }\n return /^\\d+$/.test(value.value) ? `${value.value}px` : null;\n}\n\nfunction colorFor(value: AtomValue | null, modifier: AtomModifier | null, theme: Theme): string | null {\n if (value?.kind === 'arbitrary' && value.dataType === 'length') return null;\n return colorValue(value, modifier, theme);\n}\n\nfunction rounded(reg: Registry, root: string, corners: string[]): void {\n reg.dynamicRule(root, ({ value, theme }) => {\n const r = radiusValue(value, theme);\n return r ? corners.map((c) => decl(`border${c}-radius`, r)) : null;\n });\n}\n\nfunction radiusValue(value: AtomValue | null, theme: Theme): string | null {\n if (value === null) return theme.resolve('radius', 'DEFAULT');\n if (value.kind === 'arbitrary') return value.value;\n if (value.value === 'none') return '0';\n if (value.value === 'full') return 'calc(infinity * 1px)';\n return theme.resolve('radius', value.value);\n}\n\nfunction outline(reg: Registry): void {\n keywords(reg, 'outline', 'outline-style', {\n none: 'none',\n solid: 'solid',\n dashed: 'dashed',\n dotted: 'dotted',\n double: 'double',\n });\n reg.dynamicRule('outline', ({ value, modifier, theme }): Declaration[] | null => {\n if (value === null) return [decl('outline-style', 'solid')];\n const width = widthValue(value, null);\n if (width !== null) return [decl('outline-width', width)];\n const color = colorFor(value, modifier, theme);\n return color ? [decl('outline-color', color)] : null;\n });\n}\n"]}
1
+ {"version":3,"file":"borders.js","sourceRoot":"","sources":["../../../../src/engine/utilities/borders.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,IAAI,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAItD,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEhD,MAAM,U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AM,EAAE,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE,EAAE;QACrD,MAAM,CAAC,GAAG,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QAC3D,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC;YACf,OAAO;gBACL,IAAI,CACF,mBAAmB,EACnB,oCAAoC,CAAC,wDAAwD,CAC9F;gBACD,IAAI,CACF,YAAY,EACZ,qFAAqF,CACtF;aACF,CAAC;QACJ,CAAC;QACD,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;QAC/C,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,kBAAkB,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAC1D,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { type Declaration, decl, rule } from '../ast';\nimport type { AtomModifier, AtomValue } from '../atom';\nimport type { Registry } from '../registry';\nimport { Theme } from '../theme';\nimport { colorValue, keywords } from './values';\n\nexport function registerBorders(reg: Registry): void {\n border(reg, 'border', 'border', ['-top', '-right', '-bottom', '-left']);\n border(reg, 'border-x', 'border', ['-left', '-right']);\n border(reg, 'border-y', 'border', ['-top', '-bottom']);\n border(reg, 'border-t', 'border', ['-top']);\n border(reg, 'border-r', 'border', ['-right']);\n border(reg, 'border-b', 'border', ['-bottom']);\n border(reg, 'border-l', 'border', ['-left']);\n border(reg, 'border-s', 'border', ['-inline-start']);\n border(reg, 'border-e', 'border', ['-inline-end']);\n\n keywords(reg, 'border', 'border-style', {\n solid: 'solid',\n dashed: 'dashed',\n dotted: 'dotted',\n double: 'double',\n hidden: 'hidden',\n none: 'none',\n });\n\n divide(reg);\n ring(reg);\n\n rounded(reg, 'rounded', ['']);\n rounded(reg, 'rounded-t', ['-top-left', '-top-right']);\n rounded(reg, 'rounded-r', ['-top-right', '-bottom-right']);\n rounded(reg, 'rounded-b', ['-bottom-right', '-bottom-left']);\n rounded(reg, 'rounded-l', ['-top-left', '-bottom-left']);\n rounded(reg, 'rounded-tl', ['-top-left']);\n rounded(reg, 'rounded-tr', ['-top-right']);\n rounded(reg, 'rounded-br', ['-bottom-right']);\n rounded(reg, 'rounded-bl', ['-bottom-left']);\n\n outline(reg);\n}\n\n// `border`, `border-2`, `border-red-500`, `border-[#fff]`, `border-[2px]` all share\n// one root: a bare value or number is a width, a colour token/arbitrary is a colour.\nfunction border(reg: Registry, root: string, base: string, sides: string[]): void {\n reg.dynamicRule(root, ({ value, modifier, theme }) => {\n const width = widthValue(value, base === 'border' ? '1px' : null);\n if (width !== null) return sides.map((s) => decl(`${base}${s}-width`, width));\n const color = colorFor(value, modifier, theme);\n return color ? sides.map((s) => decl(`${base}${s}-color`, color)) : null;\n });\n}\n\nfunction widthValue(value: AtomValue | null, bare: string | null): string | null {\n if (value === null) return bare;\n if (value.kind === 'arbitrary') {\n if (value.dataType === 'length') return value.value;\n if (value.dataType === null && /^[\\d.]+(px|rem|em|%)$/.test(value.value)) return value.value;\n return null;\n }\n return /^\\d+$/.test(value.value) ? `${value.value}px` : null;\n}\n\nfunction colorFor(value: AtomValue | null, modifier: AtomModifier | null, theme: Theme): string | null {\n if (value?.kind === 'arbitrary' && value.dataType === 'length') return null;\n return colorValue(value, modifier, theme);\n}\n\nfunction rounded(reg: Registry, root: string, corners: string[]): void {\n reg.dynamicRule(root, ({ value, theme }) => {\n const r = radiusValue(value, theme);\n return r ? corners.map((c) => decl(`border${c}-radius`, r)) : null;\n });\n}\n\nfunction radiusValue(value: AtomValue | null, theme: Theme): string | null {\n if (value === null) return theme.resolve('radius', 'DEFAULT');\n if (value.kind === 'arbitrary') return value.value;\n if (value.value === 'none') return '0';\n if (value.value === 'full') return 'calc(infinity * 1px)';\n return theme.resolve('radius', value.value);\n}\n\nfunction outline(reg: Registry): void {\n keywords(reg, 'outline', 'outline-style', {\n none: 'none',\n solid: 'solid',\n dashed: 'dashed',\n dotted: 'dotted',\n double: 'double',\n });\n reg.dynamicRule('outline', ({ value, modifier, theme }): Declaration[] | null => {\n if (value === null) return [decl('outline-style', 'solid')];\n const width = widthValue(value, null);\n if (width !== null) return [decl('outline-width', width)];\n const color = colorFor(value, modifier, theme);\n return color ? [decl('outline-color', color)] : null;\n });\n}\n\n// Borders *between* children (adjacent-sibling combinator). `divide-x`/`divide-y`\n// set the width, `divide-{color}`/`divide-{style}` the rest; `-reverse` flips the\n// edge via a `--flx-divide-*-reverse` toggle.\nconst BETWEEN = '& > :not([hidden]) ~ :not([hidden])';\n\nfunction divide(reg: Registry): void {\n divideWidth(reg, 'x', 'border-right-width', 'border-left-width');\n divideWidth(reg, 'y', 'border-top-width', 'border-bottom-width');\n\n reg.dynamicRule('divide', ({ value, modifier, theme }) => {\n if (value === null) return null;\n const style = value.kind === 'named' ? DIVIDE_STYLES[value.value] : undefined;\n if (style) return [rule(BETWEEN, [decl('border-style', style)])];\n const color = colorFor(value, modifier, theme);\n return color ? [rule(BETWEEN, [decl('border-color', color)])] : null;\n });\n}\n\nconst DIVIDE_STYLES: Record<string, string> = {\n solid: 'solid',\n dashed: 'dashed',\n dotted: 'dotted',\n double: 'double',\n none: 'none',\n};\n\nfunction divideWidth(reg: Registry, axis: 'x' | 'y', reverseProp: string, mainProp: string): void {\n const flag = `--flx-divide-${axis}-reverse`;\n reg.dynamicRule(`divide-${axis}`, ({ value }) => {\n if (value?.kind === 'named' && value.value === 'reverse') return [rule(BETWEEN, [decl(flag, '1')])];\n const w = widthValue(value, '1px');\n if (w === null) return null;\n return [\n rule(BETWEEN, [\n decl(flag, '0'),\n decl(reverseProp, `calc(${w} * var(${flag}))`),\n decl(mainProp, `calc(${w} * calc(1 - var(${flag})))`),\n ]),\n ];\n });\n}\n\n// A focus/selection ring drawn as a box-shadow, composed through `--flx-ring-*`\n// (declared in reset.css) so `ring`, `ring-{color}` and `ring-inset` stack.\nfunction ring(reg: Registry): void {\n reg.rule('ring-inset', [decl('--flx-ring-inset', 'inset')]);\n reg.dynamicRule('ring', ({ value, modifier, theme }) => {\n const w = value === null ? '3px' : widthValue(value, null);\n if (w !== null) {\n return [\n decl(\n '--flx-ring-shadow',\n `var(--flx-ring-inset) 0 0 0 calc(${w} + var(--flx-ring-offset-width)) var(--flx-ring-color)`,\n ),\n decl(\n 'box-shadow',\n 'var(--flx-ring-offset-shadow), var(--flx-ring-shadow), var(--flx-shadow, 0 0 #0000)',\n ),\n ];\n }\n const color = colorFor(value, modifier, theme);\n return color ? [decl('--flx-ring-color', color)] : null;\n });\n}\n"]}
@@ -65,6 +65,31 @@ export function registerLayout(reg) {
65
65
  return [decl('z-index', 'auto')];
66
66
  return /^\d+$/.test(value.value) ? [decl('z-index', value.value)] : null;
67
67
  });
68
+ reg.dynamicRule('columns', ({ value }) => {
69
+ if (!value)
70
+ return null;
71
+ if (value.kind === 'arbitrary')
72
+ return [decl('columns', value.value)];
73
+ if (value.value === 'auto' || /^\d+$/.test(value.value))
74
+ return [decl('columns', value.value)];
75
+ return null;
76
+ });
77
+ // Scroll snapping. The axis utilities read `--flx-scroll-snap-strictness`
78
+ // (reset.css defaults it to `proximity`), so `snap-x snap-mandatory` composes.
79
+ props(reg, 'scroll-snap-type', {
80
+ 'snap-none': 'none',
81
+ 'snap-x': 'x var(--flx-scroll-snap-strictness)',
82
+ 'snap-y': 'y var(--flx-scroll-snap-strictness)',
83
+ 'snap-both': 'both var(--flx-scroll-snap-strictness)',
84
+ });
85
+ props(reg, '--flx-scroll-snap-strictness', { 'snap-mandatory': 'mandatory', 'snap-proximity': 'proximity' });
86
+ props(reg, 'scroll-snap-align', {
87
+ 'snap-start': 'start',
88
+ 'snap-end': 'end',
89
+ 'snap-center': 'center',
90
+ 'snap-align-none': 'none',
91
+ });
92
+ props(reg, 'scroll-snap-stop', { 'snap-normal': 'normal', 'snap-always': 'always' });
68
93
  }
69
94
  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;IAClB,MAAM,EAAE,QAAQ;CACjB,CAAC;AAEF,SAAS,KAAK,CAAC,GAAa,EAAE,IAAY,EAAE,KAAe;IACzD,GAAG,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE,EAAE;QAC7D,IAAI,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,IAAI,MAAK,OAAO,IAAI,KAAK,CAAC,KAAK,KAAK,MAAM;YAAE,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;QAChG,MAAM,CAAC,GAAG,SAAS,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAC;QAC1D,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACjD,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { decl } from '../ast';\nimport type { Registry } from '../registry';\nimport { keywords, props, sizeValue } from './values';\n\nexport function registerLayout(reg: Registry): void {\n props(reg, 'display', {\n block: 'block',\n inline: 'inline',\n 'inline-block': 'inline-block',\n flex: 'flex',\n 'inline-flex': 'inline-flex',\n grid: 'grid',\n 'inline-grid': 'inline-grid',\n table: 'table',\n 'flow-root': 'flow-root',\n contents: 'contents',\n hidden: 'none',\n });\n\n props(reg, 'position', {\n static: 'static',\n fixed: 'fixed',\n absolute: 'absolute',\n relative: 'relative',\n sticky: 'sticky',\n });\n\n keywords(reg, 'overflow', 'overflow', OVERFLOW);\n keywords(reg, 'overflow-x', 'overflow-x', OVERFLOW);\n keywords(reg, 'overflow-y', 'overflow-y', OVERFLOW);\n\n props(reg, 'visibility', { visible: 'visible', invisible: 'hidden', collapse: 'collapse' });\n keywords(reg, 'box', 'box-sizing', { border: 'border-box', content: 'content-box' });\n props(reg, 'isolation', { isolate: 'isolate', 'isolation-auto': 'auto' });\n\n keywords(reg, 'object', 'object-fit', {\n contain: 'contain',\n cover: 'cover',\n fill: 'fill',\n none: 'none',\n 'scale-down': 'scale-down',\n });\n keywords(reg, 'object', 'object-position', {\n top: 'top',\n bottom: 'bottom',\n center: 'center',\n left: 'left',\n right: 'right',\n 'left-top': 'left top',\n 'right-top': 'right top',\n 'left-bottom': 'left bottom',\n 'right-bottom': 'right bottom',\n });\n\n keywords(reg, 'float', 'float', { start: 'inline-start', end: 'inline-end', left: 'left', right: 'right', none: 'none' });\n keywords(reg, 'clear', 'clear', { start: 'inline-start', end: 'inline-end', left: 'left', right: 'right', both: 'both', none: 'none' });\n\n inset(reg, 'inset', ['top', 'right', 'bottom', 'left']);\n inset(reg, 'inset-x', ['left', 'right']);\n inset(reg, 'inset-y', ['top', 'bottom']);\n inset(reg, 'top', ['top']);\n inset(reg, 'right', ['right']);\n inset(reg, 'bottom', ['bottom']);\n inset(reg, 'left', ['left']);\n inset(reg, 'start', ['inset-inline-start']);\n inset(reg, 'end', ['inset-inline-end']);\n\n reg.dynamicRule('z', ({ value }) => {\n if (!value) return null;\n if (value.kind === 'arbitrary') return [decl('z-index', value.value)];\n if (value.value === 'auto') return [decl('z-index', 'auto')];\n return /^\\d+$/.test(value.value) ? [decl('z-index', value.value)] : null;\n });\n}\n\nconst OVERFLOW: Record<string, string> = {\n auto: 'auto',\n hidden: 'hidden',\n clip: 'clip',\n visible: 'visible',\n scroll: 'scroll',\n};\n\nfunction inset(reg: Registry, root: string, props: string[]): void {\n reg.dynamicRule(root, ({ value, negative, modifier, theme }) => {\n if (value?.kind === 'named' && value.value === 'auto') return props.map((p) => decl(p, 'auto'));\n const v = sizeValue(value, theme, { negative, modifier });\n return v ? props.map((p) => decl(p, v)) : null;\n });\n}\n"]}
1
+ {"version":3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I,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,IAAI,MAAK,OAAO,IAAI,KAAK,CAAC,KAAK,KAAK,MAAM;YAAE,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;QAChG,MAAM,CAAC,GAAG,SAAS,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAC;QAC1D,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACjD,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { decl } from '../ast';\nimport type { Registry } from '../registry';\nimport { keywords, props, sizeValue } from './values';\n\nexport function registerLayout(reg: Registry): void {\n props(reg, 'display', {\n block: 'block',\n inline: 'inline',\n 'inline-block': 'inline-block',\n flex: 'flex',\n 'inline-flex': 'inline-flex',\n grid: 'grid',\n 'inline-grid': 'inline-grid',\n table: 'table',\n 'flow-root': 'flow-root',\n contents: 'contents',\n hidden: 'none',\n });\n\n props(reg, 'position', {\n static: 'static',\n fixed: 'fixed',\n absolute: 'absolute',\n relative: 'relative',\n sticky: 'sticky',\n });\n\n keywords(reg, 'overflow', 'overflow', OVERFLOW);\n keywords(reg, 'overflow-x', 'overflow-x', OVERFLOW);\n keywords(reg, 'overflow-y', 'overflow-y', OVERFLOW);\n\n props(reg, 'visibility', { visible: 'visible', invisible: 'hidden', collapse: 'collapse' });\n keywords(reg, 'box', 'box-sizing', { border: 'border-box', content: 'content-box' });\n props(reg, 'isolation', { isolate: 'isolate', 'isolation-auto': 'auto' });\n\n keywords(reg, 'object', 'object-fit', {\n contain: 'contain',\n cover: 'cover',\n fill: 'fill',\n none: 'none',\n 'scale-down': 'scale-down',\n });\n keywords(reg, 'object', 'object-position', {\n top: 'top',\n bottom: 'bottom',\n center: 'center',\n left: 'left',\n right: 'right',\n 'left-top': 'left top',\n 'right-top': 'right top',\n 'left-bottom': 'left bottom',\n 'right-bottom': 'right bottom',\n });\n\n keywords(reg, 'float', 'float', { start: 'inline-start', end: 'inline-end', left: 'left', right: 'right', none: 'none' });\n keywords(reg, 'clear', 'clear', { start: 'inline-start', end: 'inline-end', left: 'left', right: 'right', both: 'both', none: 'none' });\n\n inset(reg, 'inset', ['top', 'right', 'bottom', 'left']);\n inset(reg, 'inset-x', ['left', 'right']);\n inset(reg, 'inset-y', ['top', 'bottom']);\n inset(reg, 'top', ['top']);\n inset(reg, 'right', ['right']);\n inset(reg, 'bottom', ['bottom']);\n inset(reg, 'left', ['left']);\n inset(reg, 'start', ['inset-inline-start']);\n inset(reg, 'end', ['inset-inline-end']);\n\n reg.dynamicRule('z', ({ value }) => {\n if (!value) return null;\n if (value.kind === 'arbitrary') return [decl('z-index', value.value)];\n if (value.value === 'auto') return [decl('z-index', 'auto')];\n return /^\\d+$/.test(value.value) ? [decl('z-index', value.value)] : null;\n });\n\n reg.dynamicRule('columns', ({ value }) => {\n if (!value) return null;\n if (value.kind === 'arbitrary') return [decl('columns', value.value)];\n if (value.value === 'auto' || /^\\d+$/.test(value.value)) return [decl('columns', value.value)];\n return null;\n });\n\n // Scroll snapping. The axis utilities read `--flx-scroll-snap-strictness`\n // (reset.css defaults it to `proximity`), so `snap-x snap-mandatory` composes.\n props(reg, 'scroll-snap-type', {\n 'snap-none': 'none',\n 'snap-x': 'x var(--flx-scroll-snap-strictness)',\n 'snap-y': 'y var(--flx-scroll-snap-strictness)',\n 'snap-both': 'both var(--flx-scroll-snap-strictness)',\n });\n props(reg, '--flx-scroll-snap-strictness', { 'snap-mandatory': 'mandatory', 'snap-proximity': 'proximity' });\n props(reg, 'scroll-snap-align', {\n 'snap-start': 'start',\n 'snap-end': 'end',\n 'snap-center': 'center',\n 'snap-align-none': 'none',\n });\n props(reg, 'scroll-snap-stop', { 'snap-normal': 'normal', 'snap-always': 'always' });\n}\n\nconst OVERFLOW: Record<string, string> = {\n auto: 'auto',\n hidden: 'hidden',\n clip: 'clip',\n visible: 'visible',\n scroll: 'scroll',\n};\n\nfunction inset(reg: Registry, root: string, props: string[]): void {\n reg.dynamicRule(root, ({ value, negative, modifier, theme }) => {\n if (value?.kind === 'named' && value.value === 'auto') return props.map((p) => decl(p, 'auto'));\n const v = sizeValue(value, theme, { negative, modifier });\n return v ? props.map((p) => decl(p, v)) : null;\n });\n}\n"]}
@@ -1,8 +1,32 @@
1
- import { decl } from '../ast';
1
+ import { decl, rule } from '../ast';
2
2
  import { sizeValue } from './values';
3
3
  export function registerSpacing(reg) {
4
4
  for (const [root, props] of Object.entries(SPACING))
5
5
  spacing(reg, root, props, root[0] === 'm');
6
+ spaceBetween(reg, 'x', 'margin-inline-start', 'margin-inline-end');
7
+ spaceBetween(reg, 'y', 'margin-top', 'margin-bottom');
8
+ }
9
+ // Only the space *between* siblings, applied to every child after the first via
10
+ // the adjacent-sibling combinator. `space-x-reverse` flips which edge carries the
11
+ // margin (a `--flx-space-*-reverse` toggle, so it composes with the value util).
12
+ const BETWEEN = '& > :not([hidden]) ~ :not([hidden])';
13
+ function spaceBetween(reg, axis, startProp, endProp) {
14
+ const flag = `--flx-space-${axis}-reverse`;
15
+ reg.dynamicRule(`space-${axis}`, ({ value, negative, theme }) => {
16
+ if ((value === null || value === void 0 ? void 0 : value.kind) === 'named' && value.value === 'reverse') {
17
+ return [rule(BETWEEN, [decl(flag, '1')])];
18
+ }
19
+ const v = sizeValue(value, theme, { negative });
20
+ if (!v)
21
+ return null;
22
+ return [
23
+ rule(BETWEEN, [
24
+ decl(flag, '0'),
25
+ decl(startProp, `calc(${v} * calc(1 - var(${flag})))`),
26
+ decl(endProp, `calc(${v} * var(${flag}))`),
27
+ ]),
28
+ ];
29
+ });
6
30
  }
7
31
  // `px`/`py` expand to the physical left/right, top/bottom pair (not the logical
8
32
  // `padding-inline`) to match established output; `ps`/`pe` use the logical edges.
@@ -1 +1 @@
1
- {"version":3,"file":"spacing.js","sourceRoot":"","sources":["../../../../src/engine/utilities/spacing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAErC,MAAM,UAAU,eAAe,CAAC,GAAa;IAC3C,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC;QAAE,OAAO,CAAC,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC;AAClG,CAAC;AAED,gFAAgF;AAChF,kFAAkF;AAClF,MAAM,OAAO,GAA6B;IACxC,CAAC,EAAE,CAAC,SAAS,CAAC;IACd,EAAE,EAAE,CAAC,cAAc,EAAE,eAAe,CAAC;IACrC,EAAE,EAAE,CAAC,aAAa,EAAE,gBAAgB,CAAC;IACrC,EAAE,EAAE,CAAC,sBAAsB,CAAC;IAC5B,EAAE,EAAE,CAAC,oBAAoB,CAAC;IAC1B,EAAE,EAAE,CAAC,aAAa,CAAC;IACnB,EAAE,EAAE,CAAC,eAAe,CAAC;IACrB,EAAE,EAAE,CAAC,gBAAgB,CAAC;IACtB,EAAE,EAAE,CAAC,cAAc,CAAC;IACpB,CAAC,EAAE,CAAC,QAAQ,CAAC;IACb,EAAE,EAAE,CAAC,aAAa,EAAE,cAAc,CAAC;IACnC,EAAE,EAAE,CAAC,YAAY,EAAE,eAAe,CAAC;IACnC,EAAE,EAAE,CAAC,qBAAqB,CAAC;IAC3B,EAAE,EAAE,CAAC,mBAAmB,CAAC;IACzB,EAAE,EAAE,CAAC,YAAY,CAAC;IAClB,EAAE,EAAE,CAAC,cAAc,CAAC;IACpB,EAAE,EAAE,CAAC,eAAe,CAAC;IACrB,EAAE,EAAE,CAAC,aAAa,CAAC;IACnB,UAAU,EAAE,CAAC,eAAe,CAAC;IAC7B,UAAU,EAAE,CAAC,gBAAgB,CAAC;CAC/B,CAAC;AAEF,SAAS,OAAO,CAAC,GAAa,EAAE,IAAY,EAAE,KAAe,EAAE,SAAkB;IAC/E,GAAG,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE,EAAE;QACnD,IAAI,SAAS,IAAI,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,IAAI,MAAK,OAAO,IAAI,KAAK,CAAC,KAAK,KAAK,MAAM;YAAE,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;QAC7G,MAAM,CAAC,GAAG,SAAS,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC;QAChD,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACjD,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { decl } from '../ast';\nimport type { Registry } from '../registry';\nimport { sizeValue } from './values';\n\nexport function registerSpacing(reg: Registry): void {\n for (const [root, props] of Object.entries(SPACING)) spacing(reg, root, props, root[0] === 'm');\n}\n\n// `px`/`py` expand to the physical left/right, top/bottom pair (not the logical\n// `padding-inline`) to match established output; `ps`/`pe` use the logical edges.\nconst SPACING: Record<string, string[]> = {\n p: ['padding'],\n px: ['padding-left', 'padding-right'],\n py: ['padding-top', 'padding-bottom'],\n ps: ['padding-inline-start'],\n pe: ['padding-inline-end'],\n pt: ['padding-top'],\n pr: ['padding-right'],\n pb: ['padding-bottom'],\n pl: ['padding-left'],\n m: ['margin'],\n mx: ['margin-left', 'margin-right'],\n my: ['margin-top', 'margin-bottom'],\n ms: ['margin-inline-start'],\n me: ['margin-inline-end'],\n mt: ['margin-top'],\n mr: ['margin-right'],\n mb: ['margin-bottom'],\n ml: ['margin-left'],\n 'scroll-m': ['scroll-margin'],\n 'scroll-p': ['scroll-padding'],\n};\n\nfunction spacing(reg: Registry, root: string, props: string[], allowAuto: boolean): void {\n reg.dynamicRule(root, ({ value, negative, theme }) => {\n if (allowAuto && value?.kind === 'named' && value.value === 'auto') return props.map((p) => decl(p, 'auto'));\n const v = sizeValue(value, theme, { negative });\n return v ? props.map((p) => decl(p, v)) : null;\n });\n}\n"]}
1
+ {"version":3,"file":"spacing.js","sourceRoot":"","sources":["../../../../src/engine/utilities/spacing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAEpC,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAErC,MAAM,UAAU,eAAe,CAAC,GAAa;IAC3C,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC;QAAE,OAAO,CAAC,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC;IAChG,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,qBAAqB,EAAE,mBAAmB,CAAC,CAAC;IACnE,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,YAAY,EAAE,eAAe,CAAC,CAAC;AACxD,CAAC;AAED,gFAAgF;AAChF,kFAAkF;AAClF,iFAAiF;AACjF,MAAM,OAAO,GAAG,qCAAqC,CAAC;AAEtD,SAAS,YAAY,CAAC,GAAa,EAAE,IAAe,EAAE,SAAiB,EAAE,OAAe;IACtF,MAAM,IAAI,GAAG,eAAe,IAAI,UAAU,CAAC;IAC3C,GAAG,CAAC,WAAW,CAAC,SAAS,IAAI,EAA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ACnC,EAAE,EAAE,CAAC,YAAY,EAAE,eAAe,CAAC;IACnC,EAAE,EAAE,CAAC,qBAAqB,CAAC;IAC3B,EAAE,EAAE,CAAC,mBAAmB,CAAC;IACzB,EAAE,EAAE,CAAC,YAAY,CAAC;IAClB,EAAE,EAAE,CAAC,cAAc,CAAC;IACpB,EAAE,EAAE,CAAC,eAAe,CAAC;IACrB,EAAE,EAAE,CAAC,aAAa,CAAC;IACnB,UAAU,EAAE,CAAC,eAAe,CAAC;IAC7B,UAAU,EAAE,CAAC,gBAAgB,CAAC;CAC/B,CAAC;AAEF,SAAS,OAAO,CAAC,GAAa,EAAE,IAAY,EAAE,KAAe,EAAE,SAAkB;IAC/E,GAAG,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE,EAAE;QACnD,IAAI,SAAS,IAAI,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,IAAI,MAAK,OAAO,IAAI,KAAK,CAAC,KAAK,KAAK,MAAM;YAAE,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;QAC7G,MAAM,CAAC,GAAG,SAAS,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC;QAChD,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACjD,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { decl, rule } from '../ast';\nimport type { Registry } from '../registry';\nimport { sizeValue } from './values';\n\nexport function registerSpacing(reg: Registry): void {\n for (const [root, props] of Object.entries(SPACING)) spacing(reg, root, props, root[0] === 'm');\n spaceBetween(reg, 'x', 'margin-inline-start', 'margin-inline-end');\n spaceBetween(reg, 'y', 'margin-top', 'margin-bottom');\n}\n\n// Only the space *between* siblings, applied to every child after the first via\n// the adjacent-sibling combinator. `space-x-reverse` flips which edge carries the\n// margin (a `--flx-space-*-reverse` toggle, so it composes with the value util).\nconst BETWEEN = '& > :not([hidden]) ~ :not([hidden])';\n\nfunction spaceBetween(reg: Registry, axis: 'x' | 'y', startProp: string, endProp: string): void {\n const flag = `--flx-space-${axis}-reverse`;\n reg.dynamicRule(`space-${axis}`, ({ value, negative, theme }) => {\n if (value?.kind === 'named' && value.value === 'reverse') {\n return [rule(BETWEEN, [decl(flag, '1')])];\n }\n const v = sizeValue(value, theme, { negative });\n if (!v) return null;\n return [\n rule(BETWEEN, [\n decl(flag, '0'),\n decl(startProp, `calc(${v} * calc(1 - var(${flag})))`),\n decl(endProp, `calc(${v} * var(${flag}))`),\n ]),\n ];\n });\n}\n\n// `px`/`py` expand to the physical left/right, top/bottom pair (not the logical\n// `padding-inline`) to match established output; `ps`/`pe` use the logical edges.\nconst SPACING: Record<string, string[]> = {\n p: ['padding'],\n px: ['padding-left', 'padding-right'],\n py: ['padding-top', 'padding-bottom'],\n ps: ['padding-inline-start'],\n pe: ['padding-inline-end'],\n pt: ['padding-top'],\n pr: ['padding-right'],\n pb: ['padding-bottom'],\n pl: ['padding-left'],\n m: ['margin'],\n mx: ['margin-left', 'margin-right'],\n my: ['margin-top', 'margin-bottom'],\n ms: ['margin-inline-start'],\n me: ['margin-inline-end'],\n mt: ['margin-top'],\n mr: ['margin-right'],\n mb: ['margin-bottom'],\n ml: ['margin-left'],\n 'scroll-m': ['scroll-margin'],\n 'scroll-p': ['scroll-padding'],\n};\n\nfunction spacing(reg: Registry, root: string, props: string[], allowAuto: boolean): void {\n reg.dynamicRule(root, ({ value, negative, theme }) => {\n if (allowAuto && value?.kind === 'named' && value.value === 'auto') return props.map((p) => decl(p, 'auto'));\n const v = sizeValue(value, theme, { negative });\n return v ? props.map((p) => decl(p, v)) : null;\n });\n}\n"]}
@@ -77,6 +77,13 @@ export function registerTypography(reg) {
77
77
  const t = (value === null || value === void 0 ? void 0 : value.kind) === 'named' ? TRACKING[value.value] : null;
78
78
  return t ? [decl('letter-spacing', t)] : null;
79
79
  });
80
+ reg.dynamicRule('content', ({ value }) => {
81
+ if (!value)
82
+ return null;
83
+ if (value.kind === 'arbitrary')
84
+ return [decl('content', value.value)];
85
+ return value.value === 'none' ? [decl('content', 'none')] : null;
86
+ });
80
87
  }
81
88
  const WEIGHTS = {
82
89
  thin: '100',
@@ -1 +1 @@
1
- {"version":3,"file":"typography.js","sourceRoot":"","sources":["../../../../src/engine/utilities/typography.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAI9B,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAEhF,MAAM,UAAU,kBAAkB,CAAC,GAAa;IAC9C,+EAA+E;IAC/E,gFAAgF;IAChF,oEAAoE;IACpE,GAAG,CAAC,WAAW,CAAC,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE,EAAE;QACrD,IAAI,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,IAAI,MAAK,OAAO,EAAE,CAAC;YAC5B,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,KAAK,CAAC,KAAK,CAAC,IAAI,cAAc,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC;gBACvE,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,UAAU,CAAC,KAAK,EAAE,QAAQ,EAAE,KAAK,CAAE,CAAC,CAAC,CAAC;YAC9D,CAAC;YACD,MAAM,EAAE,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;YAC9C,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,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;CACX,CAAC;AAEF,MAAM,QAAQ,GAA2B;IACvC,OAAO,EAAE,SAAS;IAClB,KAAK,EAAE,UAAU;IACjB,MAAM,EAAE,KAAK;IACb,IAAI,EAAE,SAAS;IACf,KAAK,EAAE,QAAQ;IACf,MAAM,EAAE,OAAO;CAChB,CAAC;AAEF,SAAS,cAAc,CAAC,KAAuB,EAAE,KAAY;IAC3D,IAAI,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,IAAI,MAAK,WAAW;QAAE,OAAO,CAAC,IAAI,CAAC,aAAa,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;IAC3E,IAAI,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,IAAI,MAAK,OAAO,EAAE,CAAC;QAC5B,IAAI,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC;YAAE,OAAO,CAAC,IAAI,CAAC,aAAa,EAAE,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAC7E,IAAI,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC;YACxD,OAAO,CAAC,IAAI,CAAC,aAAa,EAAE,yBAAyB,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;QACxE,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import { decl } from '../ast';\nimport type { AtomValue } from '../atom';\nimport type { Registry } from '../registry';\nimport { Theme } from '../theme';\nimport { colorValue, keywords, props, SPECIAL_COLORS, statics } from './values';\n\nexport function registerTypography(reg: Registry): void {\n // `text-` is overloaded: a colour token, a font-size token, or an arbitrary of\n // either kind. Alignment/overflow keywords (`text-center`, `text-ellipsis`) are\n // registered as statics below, which win over this functional root.\n reg.dynamicRule('text', ({ value, modifier, theme }) => {\n if (value?.kind === 'named') {\n if (theme.resolve('color', value.value) || SPECIAL_COLORS[value.value]) {\n return [decl('color', colorValue(value, modifier, theme)!)];\n }\n const fs = theme.resolve('text', value.value);\n return fs ? [decl('font-size', fs)] : null;\n }\n if (value?.kind === 'arbitrary') {\n if (value.dataType === 'length') return [decl('font-size', value.value)];\n const c = colorValue(value, modifier, theme);\n return c ? [decl('color', c)] : null;\n }\n return null;\n });\n\n props(reg, 'text-align', {\n 'text-left': 'left',\n 'text-center': 'center',\n 'text-right': 'right',\n 'text-justify': 'justify',\n 'text-start': 'start',\n 'text-end': 'end',\n });\n props(reg, 'text-overflow', { truncate: 'ellipsis', 'text-ellipsis': 'ellipsis', 'text-clip': 'clip' });\n // `truncate` is the one that also clips and stops wrapping.\n reg.rule('truncate', [\n decl('overflow', 'hidden'),\n decl('text-overflow', 'ellipsis'),\n decl('white-space', 'nowrap'),\n ]);\n\n keywords(reg, 'font', 'font-weight', WEIGHTS);\n props(reg, 'font-family', {\n 'font-sans': 'ui-sans-serif, system-ui, sans-serif',\n 'font-serif': 'ui-serif, Georgia, serif',\n 'font-mono': 'ui-monospace, SFMono-Regular, Menlo, monospace',\n });\n\n props(reg, 'font-style', { italic: 'italic', 'not-italic': 'normal' });\n props(reg, 'text-decoration-line', {\n underline: 'underline',\n overline: 'overline',\n 'line-through': 'line-through',\n 'no-underline': 'none',\n });\n props(reg, 'text-transform', {\n uppercase: 'uppercase',\n lowercase: 'lowercase',\n capitalize: 'capitalize',\n 'normal-case': 'none',\n });\n keywords(reg, 'whitespace', 'white-space', {\n normal: 'normal',\n nowrap: 'nowrap',\n pre: 'pre',\n 'pre-line': 'pre-line',\n 'pre-wrap': 'pre-wrap',\n 'break-spaces': 'break-spaces',\n });\n statics(reg, {\n 'break-normal': [decl('overflow-wrap', 'normal'), decl('word-break', 'normal')],\n 'break-words': [decl('overflow-wrap', 'break-word')],\n 'break-all': [decl('word-break', 'break-all')],\n 'break-keep': [decl('word-break', 'keep-all')],\n });\n\n keywords(reg, 'list', 'list-style-type', { none: 'none', disc: 'disc', decimal: 'decimal' });\n keywords(reg, 'list', 'list-style-position', { inside: 'inside', outside: 'outside' });\n\n reg.dynamicRule('leading', ({ value, theme }) => resolveLeading(value, theme));\n reg.dynamicRule('tracking', ({ value }) => {\n if (value?.kind === 'arbitrary') return [decl('letter-spacing', value.value)];\n const t = value?.kind === 'named' ? TRACKING[value.value] : null;\n return t ? [decl('letter-spacing', t)] : null;\n });\n}\n\nconst WEIGHTS: Record<string, string> = {\n thin: '100',\n extralight: '200',\n light: '300',\n normal: '400',\n medium: '500',\n semibold: '600',\n bold: '700',\n extrabold: '800',\n black: '900',\n};\n\nconst LEADING: Record<string, string> = {\n none: '1',\n tight: '1.25',\n snug: '1.375',\n normal: '1.5',\n relaxed: '1.625',\n loose: '2',\n};\n\nconst TRACKING: Record<string, string> = {\n tighter: '-0.05em',\n tight: '-0.025em',\n normal: '0em',\n wide: '0.025em',\n wider: '0.05em',\n widest: '0.1em',\n};\n\nfunction resolveLeading(value: AtomValue | null, theme: Theme) {\n if (value?.kind === 'arbitrary') return [decl('line-height', value.value)];\n if (value?.kind === 'named') {\n if (LEADING[value.value]) return [decl('line-height', LEADING[value.value])];\n if (/^\\d+$/.test(value.value) && theme.has('--spacing')) {\n return [decl('line-height', `calc(var(--spacing) * ${value.value})`)];\n }\n }\n return null;\n}\n"]}
1
+ {"version":3,"file":"typography.js","sourceRoot":"","sources":["../../../../src/engine/utilities/typography.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAI9B,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAEhF,MAAM,UAAU,kBAAkB,CAAC,GAAa;IAC9C,+EAA+E;IAC/E,gFAAgF;IAChF,oEAAoE;IACpE,GAAG,CAAC,WAAW,CAAC,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE,EAAE;QACrD,IAAI,CAAA,KAA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,CAAC,CAAC,CAAC;IAC3E,IAAI,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,IAAI,MAAK,OAAO,EAAE,CAAC;QAC5B,IAAI,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC;YAAE,OAAO,CAAC,IAAI,CAAC,aAAa,EAAE,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAC7E,IAAI,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC;YACxD,OAAO,CAAC,IAAI,CAAC,aAAa,EAAE,yBAAyB,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;QACxE,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import { decl } from '../ast';\nimport type { AtomValue } from '../atom';\nimport type { Registry } from '../registry';\nimport { Theme } from '../theme';\nimport { colorValue, keywords, props, SPECIAL_COLORS, statics } from './values';\n\nexport function registerTypography(reg: Registry): void {\n // `text-` is overloaded: a colour token, a font-size token, or an arbitrary of\n // either kind. Alignment/overflow keywords (`text-center`, `text-ellipsis`) are\n // registered as statics below, which win over this functional root.\n reg.dynamicRule('text', ({ value, modifier, theme }) => {\n if (value?.kind === 'named') {\n if (theme.resolve('color', value.value) || SPECIAL_COLORS[value.value]) {\n return [decl('color', colorValue(value, modifier, theme)!)];\n }\n const fs = theme.resolve('text', value.value);\n return fs ? [decl('font-size', fs)] : null;\n }\n if (value?.kind === 'arbitrary') {\n if (value.dataType === 'length') return [decl('font-size', value.value)];\n const c = colorValue(value, modifier, theme);\n return c ? [decl('color', c)] : null;\n }\n return null;\n });\n\n props(reg, 'text-align', {\n 'text-left': 'left',\n 'text-center': 'center',\n 'text-right': 'right',\n 'text-justify': 'justify',\n 'text-start': 'start',\n 'text-end': 'end',\n });\n props(reg, 'text-overflow', { truncate: 'ellipsis', 'text-ellipsis': 'ellipsis', 'text-clip': 'clip' });\n // `truncate` is the one that also clips and stops wrapping.\n reg.rule('truncate', [\n decl('overflow', 'hidden'),\n decl('text-overflow', 'ellipsis'),\n decl('white-space', 'nowrap'),\n ]);\n\n keywords(reg, 'font', 'font-weight', WEIGHTS);\n props(reg, 'font-family', {\n 'font-sans': 'ui-sans-serif, system-ui, sans-serif',\n 'font-serif': 'ui-serif, Georgia, serif',\n 'font-mono': 'ui-monospace, SFMono-Regular, Menlo, monospace',\n });\n\n props(reg, 'font-style', { italic: 'italic', 'not-italic': 'normal' });\n props(reg, 'text-decoration-line', {\n underline: 'underline',\n overline: 'overline',\n 'line-through': 'line-through',\n 'no-underline': 'none',\n });\n props(reg, 'text-transform', {\n uppercase: 'uppercase',\n lowercase: 'lowercase',\n capitalize: 'capitalize',\n 'normal-case': 'none',\n });\n keywords(reg, 'whitespace', 'white-space', {\n normal: 'normal',\n nowrap: 'nowrap',\n pre: 'pre',\n 'pre-line': 'pre-line',\n 'pre-wrap': 'pre-wrap',\n 'break-spaces': 'break-spaces',\n });\n statics(reg, {\n 'break-normal': [decl('overflow-wrap', 'normal'), decl('word-break', 'normal')],\n 'break-words': [decl('overflow-wrap', 'break-word')],\n 'break-all': [decl('word-break', 'break-all')],\n 'break-keep': [decl('word-break', 'keep-all')],\n });\n\n keywords(reg, 'list', 'list-style-type', { none: 'none', disc: 'disc', decimal: 'decimal' });\n keywords(reg, 'list', 'list-style-position', { inside: 'inside', outside: 'outside' });\n\n reg.dynamicRule('leading', ({ value, theme }) => resolveLeading(value, theme));\n reg.dynamicRule('tracking', ({ value }) => {\n if (value?.kind === 'arbitrary') return [decl('letter-spacing', value.value)];\n const t = value?.kind === 'named' ? TRACKING[value.value] : null;\n return t ? [decl('letter-spacing', t)] : null;\n });\n\n reg.dynamicRule('content', ({ value }) => {\n if (!value) return null;\n if (value.kind === 'arbitrary') return [decl('content', value.value)];\n return value.value === 'none' ? [decl('content', 'none')] : null;\n });\n}\n\nconst WEIGHTS: Record<string, string> = {\n thin: '100',\n extralight: '200',\n light: '300',\n normal: '400',\n medium: '500',\n semibold: '600',\n bold: '700',\n extrabold: '800',\n black: '900',\n};\n\nconst LEADING: Record<string, string> = {\n none: '1',\n tight: '1.25',\n snug: '1.375',\n normal: '1.5',\n relaxed: '1.625',\n loose: '2',\n};\n\nconst TRACKING: Record<string, string> = {\n tighter: '-0.05em',\n tight: '-0.025em',\n normal: '0em',\n wide: '0.025em',\n wider: '0.05em',\n widest: '0.1em',\n};\n\nfunction resolveLeading(value: AtomValue | null, theme: Theme) {\n if (value?.kind === 'arbitrary') return [decl('line-height', value.value)];\n if (value?.kind === 'named') {\n if (LEADING[value.value]) return [decl('line-height', LEADING[value.value])];\n if (/^\\d+$/.test(value.value) && theme.has('--spacing')) {\n return [decl('line-height', `calc(var(--spacing) * ${value.value})`)];\n }\n }\n return null;\n}\n"]}
@@ -7,6 +7,10 @@ export function registerVariants(reg) {
7
7
  reg.variant(name, { atRule: { name: 'media', params } });
8
8
  reg.variant('rtl', { selector: '&:where([dir="rtl"], [dir="rtl"] *)' });
9
9
  reg.variant('ltr', { selector: '&:where([dir="ltr"], [dir="ltr"] *)' });
10
+ reg.variant('*', { selector: '& > *' }); // direct children
11
+ reg.variant('**', { selector: '& *' }); // all descendants
12
+ reg.variant('open', { selector: '&:is([open], :open)' });
13
+ reg.variant('inert', { selector: '&:is([inert], [inert] *)' });
10
14
  registerBreakpointVariants(reg);
11
15
  // `max-md`, `min-lg` resolve the named breakpoint from the theme; `max-[600px]`
12
16
  // takes the width verbatim. `max-*` overrides the `max-w`/`max-h` utilities here
@@ -20,12 +24,12 @@ export function registerVariants(reg) {
20
24
  };
21
25
  reg.dynamicVariant('min', (v) => mediaWidth('min-width', width(v)));
22
26
  reg.dynamicVariant('max', (v) => mediaWidth('max-width', width(v)));
23
- reg.dynamicVariant('group', (v) => relational(v, '.group', ' &'));
24
- reg.dynamicVariant('peer', (v) => relational(v, '.peer', ' ~ &'));
27
+ reg.dynamicVariant('group', (v, m) => relational(v, m, '.group', ' &'));
28
+ reg.dynamicVariant('peer', (v, m) => relational(v, m, '.peer', ' ~ &'));
25
29
  reg.dynamicVariant('data', (v) => (named(v) ? { selector: `&[data-${named(v)}]` } : null));
26
30
  reg.dynamicVariant('aria', (v) => (named(v) ? { selector: `&[aria-${named(v)}]` } : null));
27
31
  reg.dynamicVariant('has', (v) => (named(v) ? { selector: `&:has(${named(v)})` } : null));
28
- reg.dynamicVariant('not', (v) => (named(v) ? { selector: `&:not(${named(v)})` } : null));
32
+ reg.dynamicVariant('not', (v) => notVariant(reg, v));
29
33
  reg.dynamicVariant('supports', (v) => (named(v) ? { atRule: { name: 'supports', params: `(${named(v)})` } } : null));
30
34
  }
31
35
  // The named breakpoints (`sm:`/`md:`/…) are static variants, so their media params
@@ -95,12 +99,27 @@ function named(v) {
95
99
  return v ? v.value : null;
96
100
  }
97
101
  // `group-hover` → `.group:hover &`; `group-[.foo]` → `.group.foo &`. A named value
98
- // is a pseudo-class, an arbitrary one is a raw selector fragment.
99
- function relational(v, base, tail) {
102
+ // is a pseudo-class, an arbitrary one is a raw selector fragment. A `/name`
103
+ // modifier scopes to a named group/peer (`group-hover/item` → `.group\/item:hover`).
104
+ function relational(v, m, base, tail) {
100
105
  const value = named(v);
101
106
  if (!value)
102
107
  return null;
103
108
  const cond = v.kind === 'arbitrary' ? value : `:${value}`;
104
- return { selector: `${base}${cond}${tail}` };
109
+ const scope = m ? `${base}\\/${m.value}` : base;
110
+ return { selector: `${scope}${cond}${tail}` };
111
+ }
112
+ // `not-hover` → `&:not(:hover)`, `not-first` → `&:not(:first-child)`: resolve the
113
+ // inner variant's pseudo, so the selector is valid (not the literal name). Only
114
+ // simple pseudo variants compose; `not-[…]` takes an arbitrary selector.
115
+ function notVariant(reg, v) {
116
+ var _a, _b;
117
+ const value = named(v);
118
+ if (!value)
119
+ return null;
120
+ if (v.kind === 'arbitrary')
121
+ return { selector: `&:not(${value})` };
122
+ const frag = (_b = (_a = reg.getVariant(value)) === null || _a === void 0 ? void 0 : _a.selector) === null || _b === void 0 ? void 0 : _b.replace(/^&/, '').trim();
123
+ return frag && frag.startsWith(':') ? { selector: `&:not(${frag})` } : null;
105
124
  }
106
125
  //# sourceMappingURL=variants.js.map