foldkit-mixins 0.11.0 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/README.md +45 -13
  2. package/dist/app.d.mts +1 -1
  3. package/dist/app.mjs +6 -6
  4. package/dist/{core-IMVYU8JN.mjs → core-By7s5txd.mjs} +2 -2
  5. package/dist/{core-IMVYU8JN.mjs.map → core-By7s5txd.mjs.map} +1 -1
  6. package/dist/defaults.d.mts.map +1 -1
  7. package/dist/defaults.mjs +11 -5
  8. package/dist/defaults.mjs.map +1 -1
  9. package/dist/index.mjs +4 -4
  10. package/dist/{layers-keV38soP.mjs → layers-DxWvuCJL.mjs} +2 -2
  11. package/dist/{layers-keV38soP.mjs.map → layers-DxWvuCJL.mjs.map} +1 -1
  12. package/dist/layers.mjs +1 -1
  13. package/dist/layout.mjs +1 -1
  14. package/dist/{oklch-CDSDQNWl.d.mts → oklch-BCbqJ1aM.d.mts} +76 -1
  15. package/dist/oklch-BCbqJ1aM.d.mts.map +1 -0
  16. package/dist/prose.mjs +1 -1
  17. package/dist/{root-BBi88KYx.mjs → root-cMUipDvi.mjs} +3 -3
  18. package/dist/{root-BBi88KYx.mjs.map → root-cMUipDvi.mjs.map} +1 -1
  19. package/dist/{slotMark-DK75y0GJ.mjs → slotMark-y-RLAuTU.mjs} +6 -6
  20. package/dist/slotMark-y-RLAuTU.mjs.map +1 -0
  21. package/dist/slotView-8_CHU9i7.d.mts.map +1 -1
  22. package/dist/{style-BAYqZ3kF.mjs → style-BYPLd2Zo.mjs} +4 -4
  23. package/dist/style-BYPLd2Zo.mjs.map +1 -0
  24. package/dist/{styleValue-Cj4YjgVB.mjs → styleValue-6hpAYYfg.mjs} +63 -4
  25. package/dist/styleValue-6hpAYYfg.mjs.map +1 -0
  26. package/dist/testing.d.mts.map +1 -1
  27. package/dist/testing.mjs +11 -3
  28. package/dist/testing.mjs.map +1 -1
  29. package/dist/theme.d.mts +82 -4
  30. package/dist/theme.d.mts.map +1 -1
  31. package/dist/theme.mjs +122 -9
  32. package/dist/theme.mjs.map +1 -1
  33. package/dist/tokens-B40SXDyL.mjs +237 -0
  34. package/dist/tokens-B40SXDyL.mjs.map +1 -0
  35. package/dist/tokens-ryMUpT48.d.mts +206 -0
  36. package/dist/tokens-ryMUpT48.d.mts.map +1 -0
  37. package/dist/utilities.d.mts +36 -2
  38. package/dist/utilities.d.mts.map +1 -1
  39. package/dist/utilities.mjs +141 -5
  40. package/dist/utilities.mjs.map +1 -1
  41. package/package.json +1 -1
  42. package/dist/oklch-CDSDQNWl.d.mts.map +0 -1
  43. package/dist/slotMark-DK75y0GJ.mjs.map +0 -1
  44. package/dist/style-BAYqZ3kF.mjs.map +0 -1
  45. package/dist/styleValue-Cj4YjgVB.mjs.map +0 -1
  46. package/dist/tokens-B3i8bXZp.mjs +0 -139
  47. package/dist/tokens-B3i8bXZp.mjs.map +0 -1
  48. package/dist/tokens-BaLmrfbp.d.mts +0 -102
  49. package/dist/tokens-BaLmrfbp.d.mts.map +0 -1
package/README.md CHANGED
@@ -104,8 +104,7 @@ projection, and `foldkit-mixins-ui` adapts `@foldkit/ui` components.
104
104
 
105
105
  The design-system pieces are subpaths, so an application that only attaches classes pays for
106
106
  none of them: `foldkit-mixins/layers`, `/theme`, `/layout`, `/defaults`, `/prose`, `/utilities`
107
- and `/app` (see
108
- [styleImprovements-DESIGN.md](../../docs/design/styleImprovements-DESIGN.md)).
107
+ and `/app`.
109
108
 
110
109
  ## Quick start
111
110
 
@@ -277,7 +276,7 @@ one.
277
276
  | `Theme.lightDark(light, dark)` / `Theme.compose(base, over)` | a token that follows the color scheme with CSS `light-dark()`; themes merged at definition time |
278
277
  | `Theme.root(theme, { omit?, colorScheme? })` / `Theme.scoped(theme, selector, overrides)` | from `foldkit-mixins/theme`: tokens as `:root` custom properties, or as overrides under a selector; unlayered global pieces for `Style.stylesheet` |
279
278
  | `Theme.schemeScript(key?)` / `Theme.chooseScheme(scheme, key?)` / `Theme.currentScheme()` | from `foldkit-mixins/theme`: a head script applying a kept `light` or `dark` before the first paint; a Command's Effect that applies and keeps a choice; the scheme applied now |
280
- | `Theme.tokens` / `Theme.oklch(knobs)` / `Theme.breakpointWidths(theme)` | from `foldkit-mixins/theme`: the shipped spacing, type, radius, motion, border, shadow and breakpoint scales; a whole palette derived from an accent and a few knobs (including the shadow color, denser in a dark scheme); the breakpoints as pixel widths for `foldkit-primitives/media` |
279
+ | `Theme.tokens` / `Theme.oklch(knobs)` / `Theme.breakpointWidths(theme)` | from `foldkit-mixins/theme`: the shipped spacing, type, radius, motion, border, shadow and breakpoint scales, and `safe` (what a notch or the home indicator takes from each screen edge, `env(safe-area-inset-*)`, 0 unless the viewport meta says `viewport-fit=cover`); a whole palette derived from an accent and a few knobs (including the shadow color, denser in a dark scheme); the breakpoints as pixel widths for `foldkit-primitives/media` |
281
280
  | `Layers.define(names)` / `Layers.standard` | cascade layers as a value: `names`, `declare` (the `@layer …;` statement as a global piece), `in(name, piece)` (a piece's unlayered rules and global CSS inside that layer; what is already layered keeps its layer; a piece wholly in another layer is `style:relayered`) and `layer(name)` (the placement `Style.forSlots(S)(pieces, { layer })` takes, so a slot style is compiled in that layer). A name outside the order is a type error. `standard` is `reset, tokens, theme, defaults, components, layouts, variants, utilities, app`; also under `foldkit-mixins/layers` |
282
281
  | `Style.stylesheet(...)` | one `<style>` block from `NamedStyle`s and bare `StyleValue`s: the layer order hoisted first (two different orders is `style:conflicting-layer-order`), then global chunks, then scoped classes, deduplicated. Once an order is declared, a rule outside it is `style:unlayered-rule`, since it would beat every layer; keyframes, font faces and `@property` pass |
283
282
 
@@ -335,8 +334,8 @@ Beyond `self`, `pseudo`, `media`, `supports`, `container` and `nest`, the rule p
335
334
  ### Theme from a few knobs
336
335
 
337
336
  `foldkit-mixins/theme` extends the root `Theme` with the pieces a page ships. `Theme.oklch` takes
338
- an accent color and a few knobs (hue shifts, surface saturation and contrast, a contrast factor,
339
- feedback hues) and returns typed tokens for surfaces, text, outlines, and the accent, secondary,
337
+ an accent color and a few knobs (hue shifts, a neutral hue, surface saturation and contrast, a
338
+ contrast factor, feedback hues) and returns typed tokens for surfaces, text, outlines, and the accent, secondary,
340
339
  tertiary and feedback families. Only the `knob` group holds literals; every other value is a CSS
341
340
  expression over other tokens (`oklch(from …)`, `color-mix()`, `light-dark()`), so the browser does
342
341
  the derivation and one knob override recolors everything below it. Each family (`accent`,
@@ -346,14 +345,42 @@ line in it that stands off the base; and two text colors named for where they go
346
345
  text on that fill (near white on a mid accent), and `ink` is text in the family's color on the
347
346
  base surface, dark enough to read in a light scheme and light enough in a dark one. Colored text
348
347
  is `ink`, never `default`. The surfaces are the base at a few lightnesses with its chroma, so a
349
- panel and a sidebar read as the page's own color; `bedrock` is the deepest of them in both
348
+ panel and a sidebar read as the page's own color, in the accent's hue unless `neutral: { h }` gives
349
+ them one of their own (a base color: a warm stone under a blue accent); `bedrock` is the deepest of them in both
350
350
  schemes, and the focus ring, `outline.focus`, is the accent. The `syntax` group colors code by
351
351
  the kinds a tokenizer names (`syntax-keyword` is `--fk-syntax-keyword`, as
352
352
  `foldkit-richtext-code` and its Shiki adapter name them): `keyword`, `function` and `type` in
353
353
  the accent, secondary and tertiary hues, `string`, `number` and `property` in the success,
354
354
  warning and info hues, all at one lightness per scheme and the `syntaxChroma` knob's chroma, and
355
- `operator`, `punctuation` and `comment` in the text's own grey. `Theme.tokens` is the
355
+ `operator`, `punctuation` and `comment` in the text's own grey. The `chart` group is a chart's
356
+ series colors, `chart-1` to `chart-5` as shadcn names them: the dataviz reference palette's first
357
+ five slots in its order, so neighbors stay apart under protan and deutan vision, each a fixed turn
358
+ of hue from the `chart-h` knob at a lightness and chroma set for that hue in each scheme. The `popup` group is a menu's
359
+ panel (`surface`, `ink`, `blur`) and its lit row (`highlight`, `highlight-ink`): `menu: { accent:
360
+ 'bold' }` lights the row in the accent's fill, and `menu: { color }` draws the panel `inverted`
361
+ (the other scheme's surface and text) or `translucent` over a blur, as shadcn's menu options do.
362
+ Each is a 0-or-1 knob (`popup-bold`, `popup-invert`) blended by `color-mix`, so an override
363
+ switches it live. The `state` group is what a state lays over the surface under it, a mix of the
364
+ element's own text color (`hover`; `tint` and `tint-hover`, a see-through fill; `edge`, a hairline
365
+ inside an image), so it reads at any elevation and on any band; its amounts are knobs
366
+ (`state-hover`, `state-tint`, `state-tint-dark`, `image-edge`). `Theme.nested(outer, inset,
367
+ border?)` is the radius of a surface inset in another, so their corners are concentric. A
368
+ container that pads its children can publish that instead: spread `Theme.nests(radius, inset,
369
+ border?)` beside its own radius and padding, and `Theme.nested()` with no arguments on any
370
+ descendant (a row, a pill, a highlight, a focus ring) reads it. Outside such a container it is
371
+ square.
372
+ `Theme.raise(offset)` lifts an element `offset` levels above the raised element holding it (or the
373
+ page, level 1), capped at 8, and `Theme.raisedSurface()` is its background at that level: a popover
374
+ opened in a dialog lands above the dialog with nothing passed. In a light scheme the first two
375
+ levels step toward white and the rest stay there, so shadow carries elevation; in a dark scheme
376
+ each level is an even step lighter.
377
+ `Theme.tokens` is the
356
378
  non-color scales, with `space` and `radius` multiplied by the `density` and `radius-factor` knobs.
379
+ Its `motion` group is three tiers, `fast`, `moderate` and `slow` (80, 160 and 240ms, for hover and
380
+ fades, popups and tabs, dialogs), each with a quicker `-exit` for dismissals, all multiplied by the
381
+ `motion` knob. A duration of something that moves or resizes also multiplies by `knob.travel`,
382
+ which `Defaults.reset` sets to 0 under `prefers-reduced-motion`: the thing stops travelling, and its
383
+ fade still plays.
357
384
 
358
385
  A theme reaches the page as pieces, and the page chooses the layers:
359
386
 
@@ -537,7 +564,14 @@ step is a type error and the value still follows the `density` knob and theme ov
537
564
  (`size`), `font` (`weight`), `leading`, `rounded` (`radius`), `color` and `bg` (a `Theme.oklch`
538
565
  color as `'group.name'`), `items` and `justify` (`'between'` is `space-between`), and the
539
566
  constants `flex`, `column`, `grid`, `block`, `hidden`, `wFull`, `textCenter`, `uppercase`,
540
- `truncate`, `pointer` and `selectNone`. Each is a `Style.self` rule, unlayered, so it takes the
567
+ `truncate`, `pointer` and `selectNone`, and `scrollFade(axis)`, a scroller's content dissolving
568
+ toward an edge with more to scroll (a scroll-driven mask: the true ends stay crisp until something
569
+ is past them, and a browser without scroll timelines gets no fade), `scrollDivider(axis)` with
570
+ `scrollTimeline(axis)`, a hairline at each edge with more past it, drawn on a positioned parent's
571
+ `::before` and `::after` (the fade's mask would erase a line inside the scroller) from the timeline
572
+ the scroller names, where the browser has `timeline-scope`, and `steady(weight)`, room for a
573
+ label at a heavier weight, read from the element's `data-label`, so turning bold moves nothing
574
+ beside it. Each is a `Style.self` rule, unlayered, so it takes the
541
575
  layer of the style it is composed into, and a plain declaration after it wins per property. A
542
576
  value off the scale is a plain declaration (`{ fontSize: '3.75rem' }`); a color outside
543
577
  `Theme.oklch`'s groups is read through `t`.
@@ -864,8 +898,9 @@ a page that imports it fails fast naming `vite`.
864
898
  ## `@foldkit/ui`
865
899
 
866
900
  `foldkit-mixins-ui` adapts `@foldkit/ui` components that expose attribute bundles or a consumer
867
- render seam. Button, Input, Checkbox, Disclosure, Dialog, Popover, Tooltip, Slider, Tabs,
868
- RadioGroup, Calendar and others are covered.
901
+ render seam. Button, Input, Checkbox, Disclosure, Dialog, Popover, Tooltip, Tabs, RadioGroup,
902
+ Calendar and others are covered. The Slider is drawn by `foldkit-mixins-ui` itself, for one number
903
+ or a range, rather than adapted.
869
904
 
870
905
  Some components build their entire element tree internally and expose no attachment seam; those
871
906
  cannot be adapted without changing the component API. Others simply do not have an adapter yet.
@@ -878,9 +913,6 @@ The API is still settling (`0.2.x`). This package replaces none of Foldkit's sta
878
913
  machinery — Commands, Subscriptions, Mounts, ManagedResources, Models or Submodels. Its job is
879
914
  narrower: make view customization explicit, typed and composable.
880
915
 
881
- The [design note](https://github.com/doeixd/foldkit-plus/blob/main/docs/design/mixins-DESIGN.md)
882
- records the substrate probes and implementation decisions.
883
-
884
916
  ## See also
885
917
 
886
918
  - [Inside-out view composition](https://github.com/doeixd/foldkit-plus/blob/main/docs/mixins.md) — the mental model and when to use it.
package/dist/app.d.mts CHANGED
@@ -3,7 +3,7 @@ import { standard } from "./layers.mjs";
3
3
  import { a as NamedStyle, l as StyleOptions, n as Declared, r as DeclaredPieces, u as StylePieces } from "./style-moq41T8O.mjs";
4
4
  import { a as compose, r as ThemeTokens, t as Refs } from "./core-Cq9PThXv.mjs";
5
5
  import { n as RootOptions } from "./root-DCb6aqif.mjs";
6
- import { t as Tokens } from "./tokens-BaLmrfbp.mjs";
6
+ import { r as Tokens } from "./tokens-ryMUpT48.mjs";
7
7
  //#region src/app.d.ts
8
8
  export interface AppStyleOptions<Palette extends ThemeTokens> {
9
9
  /** The application's own tokens, usually `Theme.oklch(…)`, laid over `Theme.tokens`. */
package/dist/app.mjs CHANGED
@@ -1,9 +1,9 @@
1
- import { i as stylesheet, n as forSlots, r as slots } from "./style-BAYqZ3kF.mjs";
2
- import { i as compose } from "./styleValue-Cj4YjgVB.mjs";
3
- import { r as standard } from "./layers-keV38soP.mjs";
4
- import { o as ref, r as compose$1 } from "./core-IMVYU8JN.mjs";
5
- import { t as root } from "./root-BBi88KYx.mjs";
6
- import { r as tokens } from "./tokens-B3i8bXZp.mjs";
1
+ import { i as stylesheet, n as forSlots, r as slots } from "./style-BYPLd2Zo.mjs";
2
+ import { i as compose } from "./styleValue-6hpAYYfg.mjs";
3
+ import { r as standard } from "./layers-DxWvuCJL.mjs";
4
+ import { o as ref, r as compose$1 } from "./core-By7s5txd.mjs";
5
+ import { t as root } from "./root-cMUipDvi.mjs";
6
+ import { s as tokens } from "./tokens-B40SXDyL.mjs";
7
7
  import { body, reset } from "./defaults.mjs";
8
8
  //#region src/app.ts
9
9
  /**
@@ -1,4 +1,4 @@
1
- import { u as inline } from "./styleValue-Cj4YjgVB.mjs";
1
+ import { u as inline } from "./styleValue-6hpAYYfg.mjs";
2
2
  //#region src/theme/core.ts
3
3
  /**
4
4
  * `Theme` is typed token data, not a service. Dynamic theme state (light/dark)
@@ -50,4 +50,4 @@ const Theme = {
50
50
  //#endregion
51
51
  export { lightDark as a, define as i, VAR_PREFIX as n, ref as o, compose as r, variables as s, Theme as t };
52
52
 
53
- //# sourceMappingURL=core-IMVYU8JN.mjs.map
53
+ //# sourceMappingURL=core-By7s5txd.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"core-IMVYU8JN.mjs","names":[],"sources":["../src/theme/core.ts"],"sourcesContent":["/**\n * `Theme` is typed token data, not a service. Dynamic theme state (light/dark)\n * belongs in the Foldkit Model; `variables` compiles the tokens to CSS custom\n * properties so switching a class or a root style is cheap and SSR-safe.\n */\nimport { inline, type StyleValue } from '../styleValue.js'\n\nexport type ThemeTokens = {\n readonly [group: string]: { readonly [name: string]: string }\n}\n\nexport type Theme<T extends ThemeTokens = ThemeTokens> = T\n\nexport const VAR_PREFIX = '--fk'\n\nexport const define = <T extends ThemeTokens>(tokens: T): Readonly<T> =>\n Object.freeze(\n Object.fromEntries(\n Object.entries(tokens).map(([group, names]) => [group, Object.freeze({ ...names })]),\n ),\n ) as Readonly<T>\n\n/** `var(--fk-group-name)` for every token, by the theme's own group and token names. */\nexport type Refs<T extends ThemeTokens> = {\n readonly [G in keyof T & string]: { readonly [N in keyof T[G] & string]: string }\n}\n\nconst refsByTheme = new WeakMap<ThemeTokens, Refs<ThemeTokens>>()\n\n/**\n * The theme's tokens as references: `Theme.ref(theme).surface.overt` is\n * `var(--fk-surface-overt)`, and a group or name the theme lacks is a type\n * error. Only the names are read, never the values. Built once per theme.\n */\nexport const ref = <T extends ThemeTokens>(theme: T): Refs<T> => {\n const cached = refsByTheme.get(theme)\n if (cached !== undefined) return cached as Refs<T>\n const built = Object.freeze(\n Object.fromEntries(\n Object.entries(theme).map(([group, names]) => [\n group,\n Object.freeze(\n Object.fromEntries(\n Object.keys(names).map(name => [name, `var(${VAR_PREFIX}-${group}-${name})`]),\n ),\n ),\n ]),\n ),\n )\n refsByTheme.set(theme, built)\n return built as Refs<T>\n}\n\nexport const variables = <T extends ThemeTokens>(theme: T): StyleValue => {\n const style: Record<`--${string}`, string> = {}\n for (const [group, names] of Object.entries(theme)) {\n for (const [name, value] of Object.entries(names as Record<string, string>)) {\n style[`${VAR_PREFIX}-${group}-${name}`] = value\n }\n }\n return inline(style)\n}\n\n/**\n * A token that follows the user's color scheme with CSS `light-dark()`: no\n * JavaScript and no Model field. A theme the user chooses is the other case,\n * and belongs in the Model as a class on the root; `variables` compiles both.\n */\nexport const lightDark = (light: string, dark: string): string => `light-dark(${light}, ${dark})`\n\ntype Merge<A, B> = {\n readonly [G in keyof A | keyof B]: G extends keyof B\n ? G extends keyof A\n ? A[G] & B[G]\n : B[G]\n : G extends keyof A\n ? A[G]\n : never\n}\n\n/** Themes merged at definition time, later tokens winning within a group. */\nexport const compose = <A extends ThemeTokens, B extends ThemeTokens>(\n base: A,\n over: B,\n): Readonly<Merge<A, B>> => {\n const merged: Record<string, Record<string, string>> = {}\n for (const source of [base, over]) {\n for (const [group, names] of Object.entries(source)) {\n merged[group] = { ...merged[group], ...(names as Record<string, string>) }\n }\n }\n return define(merged) as unknown as Readonly<Merge<A, B>>\n}\n\nexport const Theme = { define, ref, variables, lightDark, compose } as const\n"],"mappings":";;;;;;;AAaA,MAAa,aAAa;AAE1B,MAAa,UAAiC,WAC5C,OAAO,OACL,OAAO,YACL,OAAO,QAAQ,MAAM,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,OAAO,OAAO,OAAO,EAAE,GAAG,MAAM,CAAC,CAAC,CAAC,CACrF,CACF;AAOF,MAAM,8BAAc,IAAI,QAAwC;;;;;;AAOhE,MAAa,OAA8B,UAAsB;CAC/D,MAAM,SAAS,YAAY,IAAI,KAAK;CACpC,IAAI,WAAW,KAAA,GAAW,OAAO;CACjC,MAAM,QAAQ,OAAO,OACnB,OAAO,YACL,OAAO,QAAQ,KAAK,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAC5C,OACA,OAAO,OACL,OAAO,YACL,OAAO,KAAK,KAAK,CAAC,CAAC,KAAI,SAAQ,CAAC,MAAM,OAAO,WAAW,GAAG,MAAM,GAAG,KAAK,EAAE,CAAC,CAC9E,CACF,CACF,CAAC,CACH,CACF;CACA,YAAY,IAAI,OAAO,KAAK;CAC5B,OAAO;AACT;AAEA,MAAa,aAAoC,UAAyB;CACxE,MAAM,QAAuC,CAAC;CAC9C,KAAK,MAAM,CAAC,OAAO,UAAU,OAAO,QAAQ,KAAK,GAC/C,KAAK,MAAM,CAAC,MAAM,UAAU,OAAO,QAAQ,KAA+B,GACxE,MAAM,GAAG,WAAW,GAAG,MAAM,GAAG,UAAU;CAG9C,OAAO,OAAO,KAAK;AACrB;;;;;;AAOA,MAAa,aAAa,OAAe,SAAyB,cAAc,MAAM,IAAI,KAAK;;AAa/F,MAAa,WACX,MACA,SAC0B;CAC1B,MAAM,SAAiD,CAAC;CACxD,KAAK,MAAM,UAAU,CAAC,MAAM,IAAI,GAC9B,KAAK,MAAM,CAAC,OAAO,UAAU,OAAO,QAAQ,MAAM,GAChD,OAAO,SAAS;EAAE,GAAG,OAAO;EAAQ,GAAI;CAAiC;CAG7E,OAAO,OAAO,MAAM;AACtB;AAEA,MAAa,QAAQ;CAAE;CAAQ;CAAK;CAAW;CAAW;AAAQ"}
1
+ {"version":3,"file":"core-By7s5txd.mjs","names":[],"sources":["../src/theme/core.ts"],"sourcesContent":["/**\n * `Theme` is typed token data, not a service. Dynamic theme state (light/dark)\n * belongs in the Foldkit Model; `variables` compiles the tokens to CSS custom\n * properties so switching a class or a root style is cheap and SSR-safe.\n */\nimport { inline, type StyleValue } from '../styleValue.js'\n\nexport type ThemeTokens = {\n readonly [group: string]: { readonly [name: string]: string }\n}\n\nexport type Theme<T extends ThemeTokens = ThemeTokens> = T\n\nexport const VAR_PREFIX = '--fk'\n\nexport const define = <T extends ThemeTokens>(tokens: T): Readonly<T> =>\n Object.freeze(\n Object.fromEntries(\n Object.entries(tokens).map(([group, names]) => [group, Object.freeze({ ...names })]),\n ),\n ) as Readonly<T>\n\n/** `var(--fk-group-name)` for every token, by the theme's own group and token names. */\nexport type Refs<T extends ThemeTokens> = {\n readonly [G in keyof T & string]: { readonly [N in keyof T[G] & string]: string }\n}\n\nconst refsByTheme = new WeakMap<ThemeTokens, Refs<ThemeTokens>>()\n\n/**\n * The theme's tokens as references: `Theme.ref(theme).surface.overt` is\n * `var(--fk-surface-overt)`, and a group or name the theme lacks is a type\n * error. Only the names are read, never the values. Built once per theme.\n */\nexport const ref = <T extends ThemeTokens>(theme: T): Refs<T> => {\n const cached = refsByTheme.get(theme)\n if (cached !== undefined) return cached as Refs<T>\n const built = Object.freeze(\n Object.fromEntries(\n Object.entries(theme).map(([group, names]) => [\n group,\n Object.freeze(\n Object.fromEntries(\n Object.keys(names).map(name => [name, `var(${VAR_PREFIX}-${group}-${name})`]),\n ),\n ),\n ]),\n ),\n )\n refsByTheme.set(theme, built)\n return built as Refs<T>\n}\n\nexport const variables = <T extends ThemeTokens>(theme: T): StyleValue => {\n const style: Record<`--${string}`, string> = {}\n for (const [group, names] of Object.entries(theme)) {\n for (const [name, value] of Object.entries(names as Record<string, string>)) {\n style[`${VAR_PREFIX}-${group}-${name}`] = value\n }\n }\n return inline(style)\n}\n\n/**\n * A token that follows the user's color scheme with CSS `light-dark()`: no\n * JavaScript and no Model field. A theme the user chooses is the other case,\n * and belongs in the Model as a class on the root; `variables` compiles both.\n */\nexport const lightDark = (light: string, dark: string): string => `light-dark(${light}, ${dark})`\n\ntype Merge<A, B> = {\n readonly [G in keyof A | keyof B]: G extends keyof B\n ? G extends keyof A\n ? A[G] & B[G]\n : B[G]\n : G extends keyof A\n ? A[G]\n : never\n}\n\n/** Themes merged at definition time, later tokens winning within a group. */\nexport const compose = <A extends ThemeTokens, B extends ThemeTokens>(\n base: A,\n over: B,\n): Readonly<Merge<A, B>> => {\n const merged: Record<string, Record<string, string>> = {}\n for (const source of [base, over]) {\n for (const [group, names] of Object.entries(source)) {\n merged[group] = { ...merged[group], ...(names as Record<string, string>) }\n }\n }\n return define(merged) as unknown as Readonly<Merge<A, B>>\n}\n\nexport const Theme = { define, ref, variables, lightDark, compose } as const\n"],"mappings":";;;;;;;AAaA,MAAa,aAAa;AAE1B,MAAa,UAAiC,WAC5C,OAAO,OACL,OAAO,YACL,OAAO,QAAQ,MAAM,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,OAAO,OAAO,OAAO,EAAE,GAAG,MAAM,CAAC,CAAC,CAAC,CACrF,CACF;AAOF,MAAM,8BAAc,IAAI,QAAwC;;;;;;AAOhE,MAAa,OAA8B,UAAsB;CAC/D,MAAM,SAAS,YAAY,IAAI,KAAK;CACpC,IAAI,WAAW,KAAA,GAAW,OAAO;CACjC,MAAM,QAAQ,OAAO,OACnB,OAAO,YACL,OAAO,QAAQ,KAAK,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAC5C,OACA,OAAO,OACL,OAAO,YACL,OAAO,KAAK,KAAK,CAAC,CAAC,KAAI,SAAQ,CAAC,MAAM,OAAO,WAAW,GAAG,MAAM,GAAG,KAAK,EAAE,CAAC,CAC9E,CACF,CACF,CAAC,CACH,CACF;CACA,YAAY,IAAI,OAAO,KAAK;CAC5B,OAAO;AACT;AAEA,MAAa,aAAoC,UAAyB;CACxE,MAAM,QAAuC,CAAC;CAC9C,KAAK,MAAM,CAAC,OAAO,UAAU,OAAO,QAAQ,KAAK,GAC/C,KAAK,MAAM,CAAC,MAAM,UAAU,OAAO,QAAQ,KAA+B,GACxE,MAAM,GAAG,WAAW,GAAG,MAAM,GAAG,UAAU;CAG9C,OAAO,OAAO,KAAK;AACrB;;;;;;AAOA,MAAa,aAAa,OAAe,SAAyB,cAAc,MAAM,IAAI,KAAK;;AAa/F,MAAa,WACX,MACA,SAC0B;CAC1B,MAAM,SAAiD,CAAC;CACxD,KAAK,MAAM,UAAU,CAAC,MAAM,IAAI,GAC9B,KAAK,MAAM,CAAC,OAAO,UAAU,OAAO,QAAQ,MAAM,GAChD,OAAO,SAAS;EAAE,GAAG,OAAO;EAAQ,GAAI;CAAiC;CAG7E,OAAO,OAAO,MAAM;AACtB;AAEA,MAAa,QAAQ;CAAE;CAAQ;CAAK;CAAW;CAAW;AAAQ"}
@@ -1 +1 @@
1
- {"version":3,"file":"defaults.d.mts","names":[],"sources":["../src/defaults.ts"],"mappings":";;;qBAca,OAAO;;qBAcP,MAAM;;;;;;qBAcN,UAAU;;qBAaV,OAAO;;qBASP,MAAM;;qBAWN,UAAU;;qBAaV,KAAK;qBAEL"}
1
+ {"version":3,"file":"defaults.d.mts","names":[],"sources":["../src/defaults.ts"],"mappings":";;;qBAca,OAAO;;qBAkCP,MAAM;;;;;;qBAcN,UAAU;;qBAaV,OAAO;;qBAWP,MAAM;;qBAWN,UAAU;;qBAcV,KAAK;qBAEL"}
package/dist/defaults.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { c as global, i as compose } from "./styleValue-Cj4YjgVB.mjs";
1
+ import { c as global, i as compose } from "./styleValue-6hpAYYfg.mjs";
2
2
  //#region src/defaults.ts
3
3
  /**
4
4
  * `foldkit-mixins/defaults`: the baseline plain HTML gets before any slot is
@@ -12,13 +12,17 @@ const v = (name, fallback) => `var(--fk-${name}, ${fallback})`;
12
12
  /** Box model, margins, media, form-control fonts: what every page assumes. */
13
13
  const reset = global([
14
14
  "*,*::before,*::after{box-sizing:border-box;margin:0;min-width:0}",
15
- ":where(html){text-size-adjust:none;-webkit-text-size-adjust:none;tab-size:4;font-synthesis:none;text-rendering:optimizeLegibility}",
15
+ ":where(html){text-size-adjust:100%;-webkit-text-size-adjust:100%;tab-size:4;font-synthesis:none;text-rendering:optimizeLegibility}",
16
+ ":where(:root){-webkit-tap-highlight-color:transparent}",
17
+ ":where(:is(a,button,input,select,textarea,summary,label,[role=button],[role=tab],[role=option],[role=menuitem])){touch-action:manipulation}",
18
+ "@media (pointer:coarse){:where(:root){--fk-touch-floor:2.75rem}}",
19
+ ":where(:is(button,summary,[role=button],[role=tab],[role=option],[role=menuitem],[role=menuitemcheckbox],[role=menuitemradio],[role=switch],[role=checkbox],[role=radio])){-webkit-user-select:none;user-select:none}",
16
20
  ":where(:is(img,picture,video,canvas,svg)){display:block;max-inline-size:100%;block-size:auto}",
17
21
  ":where(:is(input,button,textarea,select)){font:inherit;color:inherit}",
18
22
  ":where(textarea){field-sizing:content;min-block-size:2lh}",
19
23
  ":where(:is(h1,h2,h3,h4,h5,h6)){text-wrap:balance}",
20
24
  ":where(p){text-wrap:pretty;overflow-wrap:break-word}",
21
- `@media (prefers-reduced-motion:reduce){*,*::before,*::after{animation-duration:0.01ms!important;transition-duration:0.01ms!important;scroll-behavior:auto!important}}`
25
+ `@media (prefers-reduced-motion:reduce){*,*::before,*::after{--fk-knob-travel:0!important;animation-duration:0.01ms!important;scroll-behavior:auto!important}}`
22
26
  ].join(""));
23
27
  /** The page's font, color, background, and color scheme. */
24
28
  const body = global(`:where(:root){scrollbar-color:${v("outline-overt", "auto")} transparent;accent-color:${v("accent-default", "auto")}}:where(::selection){background:color-mix(in oklab, ${v("accent-default", "Highlight")} 28%, transparent)}:where(body){font-family:${v("font-body", "system-ui, sans-serif")};font-size:${v("size-md", "1rem")};line-height:${v("leading-normal", "1.5")};font-weight:${v("weight-normal", "400")};color:${v("text-default", "CanvasText")};background:${v("surface-base", "Canvas")};-webkit-font-smoothing:antialiased}`);
@@ -39,7 +43,8 @@ const headings = global([
39
43
  /** Link color, hover, and a visible focus ring. */
40
44
  const links = global([
41
45
  `:where(a){color:${v("text-link", "LinkText")};text-decoration-thickness:from-font;text-underline-offset:0.15em}`,
42
- `:where(a:hover){color:${v("text-link-hover", "LinkText")}}`,
46
+ `@media (hover:hover){:where(a:hover){color:${v("text-link-hover", "LinkText")}}}`,
47
+ `:where(a:active){color:${v("text-link-hover", "LinkText")}}`,
43
48
  `:where(:is(a,button,input,select,textarea,summary,[tabindex]):focus-visible){outline:${v("border-thick", "2px")} solid ${v("outline-focus", "Highlight")};outline-offset:2px}`
44
49
  ].join(""));
45
50
  /** Inline code and code blocks on the subtle surface. */
@@ -56,7 +61,8 @@ const controls = global([
56
61
  `:where(:is(input,select,textarea):focus-visible){border-color:${v("accent-default", "Highlight")}}`,
57
62
  `:where(:is(input,select,textarea)[aria-invalid=true]){border-color:${v("error-default", "red")}}`,
58
63
  `:where(button,[type=button],[type=submit],[type=reset]){padding:${v("space-xs", "0.5rem")} ${v("space-md", "1rem")};border:${v("border-thin", "1px")} solid ${v("outline-default", "ButtonBorder")};border-radius:${v("radius-md", "6px")};background:${v("surface-subtle", "ButtonFace")};color:${v("text-default", "ButtonText")};cursor:pointer;transition:background ${v("motion-fast", "150ms")} ${v("motion-ease", "ease-out")}}`,
59
- `:where(button,[type=button],[type=submit],[type=reset]):hover{background:${v("surface-muted", "ButtonFace")}}`,
64
+ `@media (hover:hover){:where(button,[type=button],[type=submit],[type=reset]):hover{background:${v("surface-muted", "ButtonFace")}}}`,
65
+ `:where(button,[type=button],[type=submit],[type=reset]):active{background:${v("surface-muted", "ButtonFace")}}`,
60
66
  `:where(:is(button,input,select,textarea):disabled){opacity:0.5;cursor:not-allowed}`,
61
67
  `:where(:is(input,select,textarea,button)::placeholder){color:${v("text-muted", "GrayText")}}`
62
68
  ].join(""));
@@ -1 +1 @@
1
- {"version":3,"file":"defaults.mjs","names":[],"sources":["../src/defaults.ts"],"sourcesContent":["/**\n * `foldkit-mixins/defaults`: the baseline plain HTML gets before any slot is\n * styled. Every member is element-selector CSS over `--fk-*` tokens with a\n * fallback, so it re-themes with the tokens and still reads without them.\n * The pieces are unlayered; a page puts `reset` in `reset` and the rest in\n * `defaults` with `Layers.standard.in`. Selectors use `:where()` so any\n * class rule beats them.\n */\nimport { compose, global } from './styleValue.js'\nimport type { StyleValue } from './styleValue.js'\n\nconst v = (name: string, fallback: string): string => `var(--fk-${name}, ${fallback})`\n\n/** Box model, margins, media, form-control fonts: what every page assumes. */\nexport const reset: StyleValue = global(\n [\n '*,*::before,*::after{box-sizing:border-box;margin:0;min-width:0}',\n ':where(html){text-size-adjust:none;-webkit-text-size-adjust:none;tab-size:4;font-synthesis:none;text-rendering:optimizeLegibility}',\n ':where(:is(img,picture,video,canvas,svg)){display:block;max-inline-size:100%;block-size:auto}',\n ':where(:is(input,button,textarea,select)){font:inherit;color:inherit}',\n ':where(textarea){field-sizing:content;min-block-size:2lh}',\n ':where(:is(h1,h2,h3,h4,h5,h6)){text-wrap:balance}',\n ':where(p){text-wrap:pretty;overflow-wrap:break-word}',\n `@media (prefers-reduced-motion:reduce){*,*::before,*::after{animation-duration:0.01ms!important;transition-duration:0.01ms!important;scroll-behavior:auto!important}}`,\n ].join(''),\n)\n\n/** The page's font, color, background, and color scheme. */\nexport const body: StyleValue = global(\n // Scrollbars in the theme's line color, which keeps the page's hue, not the\n // browser's grey; inherited, so one rule reaches every scrolling panel.\n `:where(:root){scrollbar-color:${v('outline-overt', 'auto')} transparent;accent-color:${v('accent-default', 'auto')}}` +\n // Selected text in the accent's tint rather than the browser's own blue.\n `:where(::selection){background:color-mix(in oklab, ${v('accent-default', 'Highlight')} 28%, transparent)}` +\n `:where(body){font-family:${v('font-body', 'system-ui, sans-serif')};font-size:${v('size-md', '1rem')};line-height:${v('leading-normal', '1.5')};font-weight:${v('weight-normal', '400')};color:${v('text-default', 'CanvasText')};background:${v('surface-base', 'Canvas')};-webkit-font-smoothing:antialiased}`,\n)\n\n/**\n * A type hierarchy for h1 to h6 from the size scale, in `text-overt`. A\n * container drawn in a color of its own, such as a band on the accent, sets\n * `--fk-heading: currentColor` (`Style.vars`) and its headings take its color.\n */\nexport const headings: StyleValue = global(\n [\n `:where(:is(h1,h2,h3,h4,h5,h6)){font-family:${v('font-heading', 'inherit')};font-weight:${v('weight-bold', '700')};line-height:${v('leading-tight', '1.2')};color:${v('heading', v('text-overt', 'inherit'))};letter-spacing:-0.01em}`,\n `:where(h1){font-size:${v('size-4xl', '2.25rem')}}`,\n `:where(h2){font-size:${v('size-3xl', '1.875rem')}}`,\n `:where(h3){font-size:${v('size-2xl', '1.5rem')}}`,\n `:where(h4){font-size:${v('size-xl', '1.25rem')}}`,\n `:where(h5){font-size:${v('size-lg', '1.125rem')}}`,\n `:where(h6){font-size:${v('size-md', '1rem')}}`,\n ].join(''),\n)\n\n/** Link color, hover, and a visible focus ring. */\nexport const links: StyleValue = global(\n [\n `:where(a){color:${v('text-link', 'LinkText')};text-decoration-thickness:from-font;text-underline-offset:0.15em}`,\n `:where(a:hover){color:${v('text-link-hover', 'LinkText')}}`,\n `:where(:is(a,button,input,select,textarea,summary,[tabindex]):focus-visible){outline:${v('border-thick', '2px')} solid ${v('outline-focus', 'Highlight')};outline-offset:2px}`,\n ].join(''),\n)\n\n/** Inline code and code blocks on the subtle surface. */\nexport const code: StyleValue = global(\n [\n `:where(:is(code,kbd,samp,pre)){font-family:${v('font-mono', 'ui-monospace, monospace')};font-size:${v('size-sm', '0.875rem')}}`,\n `:where(:not(pre)>code){padding:0.1em 0.35em;border-radius:${v('radius-sm', '3px')};background:${v('surface-muted', 'transparent')};overflow-wrap:anywhere}`,\n `:where(kbd){padding:0.1em 0.4em;border:${v('border-thin', '1px')} solid ${v('outline-default', 'currentColor')};border-block-end-width:2px;border-radius:${v('radius-sm', '3px')};font-size:0.85em}`,\n `:where(hr){border:0;border-block-start:${v('border-thin', '1px')} solid ${v('outline-subtle', 'currentColor')}}`,\n `:where(pre){padding:${v('space-md', '1rem')};border:${v('border-thin', '1px')} solid ${v('outline-subtle', 'transparent')};border-radius:${v('radius-md', '6px')};background:${v('surface-subtle', 'transparent')};overflow-x:auto;line-height:${v('leading-snug', '1.375')}}`,\n ].join(''),\n)\n\n/** Text inputs, selects, textareas, and buttons: one radius, one border, one focus. */\nexport const controls: StyleValue = global(\n [\n `:where(:is(input:not([type=checkbox],[type=radio],[type=range],[type=color],[type=file]),select,textarea)){padding:${v('space-xs', '0.5rem')} ${v('space-sm', '0.75rem')};border:${v('border-thin', '1px')} solid ${v('outline-default', 'ButtonBorder')};border-radius:${v('radius-md', '6px')};background:${v('surface-base', 'Field')};color:${v('text-default', 'FieldText')};transition:border-color ${v('motion-fast', '150ms')} ${v('motion-ease', 'ease-out')}}`,\n `:where(:is(input,select,textarea):focus-visible){border-color:${v('accent-default', 'Highlight')}}`,\n `:where(:is(input,select,textarea)[aria-invalid=true]){border-color:${v('error-default', 'red')}}`,\n `:where(button,[type=button],[type=submit],[type=reset]){padding:${v('space-xs', '0.5rem')} ${v('space-md', '1rem')};border:${v('border-thin', '1px')} solid ${v('outline-default', 'ButtonBorder')};border-radius:${v('radius-md', '6px')};background:${v('surface-subtle', 'ButtonFace')};color:${v('text-default', 'ButtonText')};cursor:pointer;transition:background ${v('motion-fast', '150ms')} ${v('motion-ease', 'ease-out')}}`,\n `:where(button,[type=button],[type=submit],[type=reset]):hover{background:${v('surface-muted', 'ButtonFace')}}`,\n `:where(:is(button,input,select,textarea):disabled){opacity:0.5;cursor:not-allowed}`,\n `:where(:is(input,select,textarea,button)::placeholder){color:${v('text-muted', 'GrayText')}}`,\n ].join(''),\n)\n\n/** Every default except `reset`, which belongs in its own layer. */\nexport const all: StyleValue = compose(body, headings, links, code, controls)\n\nexport const Defaults = { reset, body, headings, links, code, controls, all } as const\n"],"mappings":";;;;;;;;;;AAWA,MAAM,KAAK,MAAc,aAA6B,YAAY,KAAK,IAAI,SAAS;;AAGpF,MAAa,QAAoB,OAC/B;CACE;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC,CAAC,KAAK,EAAE,CACX;;AAGA,MAAa,OAAmB,OAG9B,iCAAiC,EAAE,iBAAiB,MAAM,EAAE,4BAA4B,EAAE,kBAAkB,MAAM,EAAE,sDAE5D,EAAE,kBAAkB,WAAW,EAAE,8CAC3D,EAAE,aAAa,uBAAuB,EAAE,aAAa,EAAE,WAAW,MAAM,EAAE,eAAe,EAAE,kBAAkB,KAAK,EAAE,eAAe,EAAE,iBAAiB,KAAK,EAAE,SAAS,EAAE,gBAAgB,YAAY,EAAE,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AE,gBAAgB,OAAO,EAAE;AAC/Q,CAAC,CAAC,KAAK,EAAE,CACX;;AAGA,MAAa,WAAuB,OAClC;CACE,sHAAsH,EAAE,YAAY,QAAQ,EAAE,GAAG,EAAE,YAAY,SAAS,EAAE,UAAU,EAAE,eAAe,KAAK,EAAE,SAAS,EAAE,mBAAmB,cAAc,EAAE,iBAAiB,EAAE,aAAa,KAAK,EAAE,cAAc,EAAE,gBAAgB,OAAO,EAAE,SAAS,EAAE,gBAAgB,WAAW,EAAE,2BAA2B,EAAE,eAAe,OAAO,EAAE,GAAG,EAAE,eAAe,UAAU,EAAE;CACvc,iEAAiE,EAAE,kBAAkB,WAAW,EAAE;CAClG,sEAAsE,EAAE,iBAAiB,KAAK,EAAE;CAChG,mEAAmE,EAAE,YAAY,QAAQ,EAAE,GAAG,EAAE,YAAY,MAAM,EAAE,UAAU,EAAE,eAAe,KAAK,EAAE,SAAS,EAAE,mBAAmB,cAAc,EAAE,iBAAiB,EAAE,aAAa,KAAK,EAAE,cAAc,EAAE,kBAAkB,YAAY,EAAE,SAAS,EAAE,gBAAgB,YAAY,EAAE,wCAAwC,EAAE,eAAe,OAAO,EAAE,GAAG,EAAE,eAAe,UAAU,EAAE;CACta,4EAA4E,EAAE,iBAAiB,YAAY,EAAE;CAC7G;CACA,gEAAgE,EAAE,cAAc,UAAU,EAAE;AAC9F,CAAC,CAAC,KAAK,EAAE,CACX;;AAGA,MAAa,MAAkB,QAAQ,MAAM,UAAU,OAAO,MAAM,QAAQ;AAE5E,MAAa,WAAW;CAAE;CAAO;CAAM;CAAU;CAAO;CAAM;CAAU;AAAI"}
1
+ {"version":3,"file":"defaults.mjs","names":[],"sources":["../src/defaults.ts"],"sourcesContent":["/**\n * `foldkit-mixins/defaults`: the baseline plain HTML gets before any slot is\n * styled. Every member is element-selector CSS over `--fk-*` tokens with a\n * fallback, so it re-themes with the tokens and still reads without them.\n * The pieces are unlayered; a page puts `reset` in `reset` and the rest in\n * `defaults` with `Layers.standard.in`. Selectors use `:where()` so any\n * class rule beats them.\n */\nimport { compose, global } from './styleValue.js'\nimport type { StyleValue } from './styleValue.js'\n\nconst v = (name: string, fallback: string): string => `var(--fk-${name}, ${fallback})`\n\n/** Box model, margins, media, form-control fonts: what every page assumes. */\nexport const reset: StyleValue = global(\n [\n '*,*::before,*::after{box-sizing:border-box;margin:0;min-width:0}',\n // 100%, not none: none stops a phone enlarging text in landscape, and also the\n // reader's own text size, where a browser applies it through this property.\n ':where(html){text-size-adjust:100%;-webkit-text-size-adjust:100%;tab-size:4;font-synthesis:none;text-rendering:optimizeLegibility}',\n // A tap draws no grey square of the browser's own: what was pressed shows its own\n // `:active` state (Defaults.controls, the recipes). And a second tap is a tap, not a\n // zoom, so a quick press on a stepper or a pager does not wait for one.\n ':where(:root){-webkit-tap-highlight-color:transparent}',\n ':where(:is(a,button,input,select,textarea,summary,label,[role=button],[role=tab],[role=option],[role=menuitem])){touch-action:manipulation}',\n // What a finger needs, 44px, as the platforms advise: the recipes' controls are at least\n // this tall where the pointer is coarse, and keep their density elsewhere. A region that\n // must stay dense sets it to 0.\n '@media (pointer:coarse){:where(:root){--fk-touch-floor:2.75rem}}',\n // A control's words are its name, not text to select: a long press on a button, a tab or\n // a menu row selected them on a phone and offered to copy, and a double tap selected a\n // word. Prefixed by hand, as iOS Safari reads only the prefixed one. Not a tree's rows or\n // a grid's cells, whose text may be edited or copied.\n ':where(:is(button,summary,[role=button],[role=tab],[role=option],[role=menuitem],[role=menuitemcheckbox],[role=menuitemradio],[role=switch],[role=checkbox],[role=radio])){-webkit-user-select:none;user-select:none}',\n ':where(:is(img,picture,video,canvas,svg)){display:block;max-inline-size:100%;block-size:auto}',\n ':where(:is(input,button,textarea,select)){font:inherit;color:inherit}',\n ':where(textarea){field-sizing:content;min-block-size:2lh}',\n ':where(:is(h1,h2,h3,h4,h5,h6)){text-wrap:balance}',\n ':where(p){text-wrap:pretty;overflow-wrap:break-word}',\n // Reduced motion is fewer and gentler, not none: what moves snaps (the\n // `travel` knob on every element, important so one that sets the knob\n // itself, a scoped theme's or an inline one, cannot restore it), while a\n // fade keeps its duration. Keyframes are a recipe's own and still stop.\n `@media (prefers-reduced-motion:reduce){*,*::before,*::after{--fk-knob-travel:0!important;animation-duration:0.01ms!important;scroll-behavior:auto!important}}`,\n ].join(''),\n)\n\n/** The page's font, color, background, and color scheme. */\nexport const body: StyleValue = global(\n // Scrollbars in the theme's line color, which keeps the page's hue, not the\n // browser's grey; inherited, so one rule reaches every scrolling panel.\n `:where(:root){scrollbar-color:${v('outline-overt', 'auto')} transparent;accent-color:${v('accent-default', 'auto')}}` +\n // Selected text in the accent's tint rather than the browser's own blue.\n `:where(::selection){background:color-mix(in oklab, ${v('accent-default', 'Highlight')} 28%, transparent)}` +\n `:where(body){font-family:${v('font-body', 'system-ui, sans-serif')};font-size:${v('size-md', '1rem')};line-height:${v('leading-normal', '1.5')};font-weight:${v('weight-normal', '400')};color:${v('text-default', 'CanvasText')};background:${v('surface-base', 'Canvas')};-webkit-font-smoothing:antialiased}`,\n)\n\n/**\n * A type hierarchy for h1 to h6 from the size scale, in `text-overt`. A\n * container drawn in a color of its own, such as a band on the accent, sets\n * `--fk-heading: currentColor` (`Style.vars`) and its headings take its color.\n */\nexport const headings: StyleValue = global(\n [\n `:where(:is(h1,h2,h3,h4,h5,h6)){font-family:${v('font-heading', 'inherit')};font-weight:${v('weight-bold', '700')};line-height:${v('leading-tight', '1.2')};color:${v('heading', v('text-overt', 'inherit'))};letter-spacing:-0.01em}`,\n `:where(h1){font-size:${v('size-4xl', '2.25rem')}}`,\n `:where(h2){font-size:${v('size-3xl', '1.875rem')}}`,\n `:where(h3){font-size:${v('size-2xl', '1.5rem')}}`,\n `:where(h4){font-size:${v('size-xl', '1.25rem')}}`,\n `:where(h5){font-size:${v('size-lg', '1.125rem')}}`,\n `:where(h6){font-size:${v('size-md', '1rem')}}`,\n ].join(''),\n)\n\n/** Link color, hover, and a visible focus ring. */\nexport const links: StyleValue = global(\n [\n `:where(a){color:${v('text-link', 'LinkText')};text-decoration-thickness:from-font;text-underline-offset:0.15em}`,\n // Only where something hovers: a touch screen keeps `:hover` on the link tapped last.\n `@media (hover:hover){:where(a:hover){color:${v('text-link-hover', 'LinkText')}}}`,\n `:where(a:active){color:${v('text-link-hover', 'LinkText')}}`,\n `:where(:is(a,button,input,select,textarea,summary,[tabindex]):focus-visible){outline:${v('border-thick', '2px')} solid ${v('outline-focus', 'Highlight')};outline-offset:2px}`,\n ].join(''),\n)\n\n/** Inline code and code blocks on the subtle surface. */\nexport const code: StyleValue = global(\n [\n `:where(:is(code,kbd,samp,pre)){font-family:${v('font-mono', 'ui-monospace, monospace')};font-size:${v('size-sm', '0.875rem')}}`,\n `:where(:not(pre)>code){padding:0.1em 0.35em;border-radius:${v('radius-sm', '3px')};background:${v('surface-muted', 'transparent')};overflow-wrap:anywhere}`,\n `:where(kbd){padding:0.1em 0.4em;border:${v('border-thin', '1px')} solid ${v('outline-default', 'currentColor')};border-block-end-width:2px;border-radius:${v('radius-sm', '3px')};font-size:0.85em}`,\n `:where(hr){border:0;border-block-start:${v('border-thin', '1px')} solid ${v('outline-subtle', 'currentColor')}}`,\n `:where(pre){padding:${v('space-md', '1rem')};border:${v('border-thin', '1px')} solid ${v('outline-subtle', 'transparent')};border-radius:${v('radius-md', '6px')};background:${v('surface-subtle', 'transparent')};overflow-x:auto;line-height:${v('leading-snug', '1.375')}}`,\n ].join(''),\n)\n\n/** Text inputs, selects, textareas, and buttons: one radius, one border, one focus. */\nexport const controls: StyleValue = global(\n [\n `:where(:is(input:not([type=checkbox],[type=radio],[type=range],[type=color],[type=file]),select,textarea)){padding:${v('space-xs', '0.5rem')} ${v('space-sm', '0.75rem')};border:${v('border-thin', '1px')} solid ${v('outline-default', 'ButtonBorder')};border-radius:${v('radius-md', '6px')};background:${v('surface-base', 'Field')};color:${v('text-default', 'FieldText')};transition:border-color ${v('motion-fast', '150ms')} ${v('motion-ease', 'ease-out')}}`,\n `:where(:is(input,select,textarea):focus-visible){border-color:${v('accent-default', 'Highlight')}}`,\n `:where(:is(input,select,textarea)[aria-invalid=true]){border-color:${v('error-default', 'red')}}`,\n `:where(button,[type=button],[type=submit],[type=reset]){padding:${v('space-xs', '0.5rem')} ${v('space-md', '1rem')};border:${v('border-thin', '1px')} solid ${v('outline-default', 'ButtonBorder')};border-radius:${v('radius-md', '6px')};background:${v('surface-subtle', 'ButtonFace')};color:${v('text-default', 'ButtonText')};cursor:pointer;transition:background ${v('motion-fast', '150ms')} ${v('motion-ease', 'ease-out')}}`,\n `@media (hover:hover){:where(button,[type=button],[type=submit],[type=reset]):hover{background:${v('surface-muted', 'ButtonFace')}}}`,\n `:where(button,[type=button],[type=submit],[type=reset]):active{background:${v('surface-muted', 'ButtonFace')}}`,\n `:where(:is(button,input,select,textarea):disabled){opacity:0.5;cursor:not-allowed}`,\n `:where(:is(input,select,textarea,button)::placeholder){color:${v('text-muted', 'GrayText')}}`,\n ].join(''),\n)\n\n/** Every default except `reset`, which belongs in its own layer. */\nexport const all: StyleValue = compose(body, headings, links, code, controls)\n\nexport const Defaults = { reset, body, headings, links, code, controls, all } as const\n"],"mappings":";;;;;;;;;;AAWA,MAAM,KAAK,MAAc,aAA6B,YAAY,KAAK,IAAI,SAAS;;AAGpF,MAAa,QAAoB,OAC/B;CACE;CAGA;CAIA;CACA;CAIA;CAKA;CACA;CACA;CACA;CACA;CACA;CAKA;AACF,CAAC,CAAC,KAAK,EAAE,CACX;;AAGA,MAAa,OAAmB,OAG9B,iCAAiC,EAAE,iBAAiB,MAAM,EAAE,4BAA4B,EAAE,kBAAkB,MAAM,EAAE,sDAE5D,EAAE,kBAAkB,WAAW,EAAE,8CAC3D,EAAE,aAAa,uBAAuB,EAAE,aAAa,EAAE,WAAW,MAAM,EAAE,eAAe,EAAE,kBAAkB,KAAK,EAAE,eAAe,EAAE,iBAAiB,KAAK,EAAE,SAAS,EAAE,gBAAgB,YAAY,EAAE,cAAc,EAAE,gBAAgB,QAAQ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AAE,+BAA+B,EAAE,gBAAgB,OAAO,EAAE;AAC/Q,CAAC,CAAC,KAAK,EAAE,CACX;;AAGA,MAAa,WAAuB,OAClC;CACE,sHAAsH,EAAE,YAAY,QAAQ,EAAE,GAAG,EAAE,YAAY,SAAS,EAAE,UAAU,EAAE,eAAe,KAAK,EAAE,SAAS,EAAE,mBAAmB,cAAc,EAAE,iBAAiB,EAAE,aAAa,KAAK,EAAE,cAAc,EAAE,gBAAgB,OAAO,EAAE,SAAS,EAAE,gBAAgB,WAAW,EAAE,2BAA2B,EAAE,eAAe,OAAO,EAAE,GAAG,EAAE,eAAe,UAAU,EAAE;CACvc,iEAAiE,EAAE,kBAAkB,WAAW,EAAE;CAClG,sEAAsE,EAAE,iBAAiB,KAAK,EAAE;CAChG,mEAAmE,EAAE,YAAY,QAAQ,EAAE,GAAG,EAAE,YAAY,MAAM,EAAE,UAAU,EAAE,eAAe,KAAK,EAAE,SAAS,EAAE,mBAAmB,cAAc,EAAE,iBAAiB,EAAE,aAAa,KAAK,EAAE,cAAc,EAAE,kBAAkB,YAAY,EAAE,SAAS,EAAE,gBAAgB,YAAY,EAAE,wCAAwC,EAAE,eAAe,OAAO,EAAE,GAAG,EAAE,eAAe,UAAU,EAAE;CACta,iGAAiG,EAAE,iBAAiB,YAAY,EAAE;CAClI,6EAA6E,EAAE,iBAAiB,YAAY,EAAE;CAC9G;CACA,gEAAgE,EAAE,cAAc,UAAU,EAAE;AAC9F,CAAC,CAAC,KAAK,EAAE,CACX;;AAGA,MAAa,MAAkB,QAAQ,MAAM,UAAU,OAAO,MAAM,QAAQ;AAE5E,MAAa,WAAW;CAAE;CAAO;CAAM;CAAU;CAAO;CAAM;CAAU;AAAI"}
package/dist/index.mjs CHANGED
@@ -1,8 +1,8 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
2
- import { _ as extendsCapability, a as slots_exports, b as metadataToken_exports, c as slotView_exports, d as mixin_exports, f as isTagged, g as capability_exports, h as Interactive, l as resolver_exports, m as Focusable, o as slot_exports, p as Container, s as attach$1, t as Style, u as dynamic, v as is$4, x as nameOf, y as make$3 } from "./style-BAYqZ3kF.mjs";
3
- import { E as diagnostics_exports, T as DiagnosticError } from "./styleValue-Cj4YjgVB.mjs";
4
- import { t as Layers } from "./layers-keV38soP.mjs";
5
- import { t as Theme } from "./core-IMVYU8JN.mjs";
2
+ import { _ as extendsCapability, a as slots_exports, b as metadataToken_exports, c as slotView_exports, d as mixin_exports, f as isTagged, g as capability_exports, h as Interactive, l as resolver_exports, m as Focusable, o as slot_exports, p as Container, s as attach$1, t as Style, u as dynamic, v as is$4, x as nameOf, y as make$3 } from "./style-BYPLd2Zo.mjs";
3
+ import { E as diagnostics_exports, T as DiagnosticError } from "./styleValue-6hpAYYfg.mjs";
4
+ import { t as Layers } from "./layers-DxWvuCJL.mjs";
5
+ import { t as Theme } from "./core-By7s5txd.mjs";
6
6
  import { Option } from "effect";
7
7
  //#region src/a11y.ts
8
8
  /**
@@ -1,4 +1,4 @@
1
- import { T as DiagnosticError, f as make } from "./styleValue-Cj4YjgVB.mjs";
1
+ import { T as DiagnosticError, f as make } from "./styleValue-6hpAYYfg.mjs";
2
2
  //#region src/cssBlocks.ts
3
3
  const withoutComments = (text) => text.replace(/\/\*[\s\S]*?\*\//g, "").trim();
4
4
  /** Index just past the string starting at `start`, which holds its quote. */
@@ -190,4 +190,4 @@ const Layers = {
190
190
  //#endregion
191
191
  export { isUnordered as a, declaredNames as i, define as n, layerOf as o, standard as r, topLevelBlocks as s, Layers as t };
192
192
 
193
- //# sourceMappingURL=layers-keV38soP.mjs.map
193
+ //# sourceMappingURL=layers-DxWvuCJL.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"layers-keV38soP.mjs","names":[],"sources":["../src/cssBlocks.ts","../src/layers.ts"],"sourcesContent":["/**\n * The top-level blocks of compiled CSS text, and which cascade layer each is\n * in. `Layers.in` reads them to leave an already-layered block where it is,\n * and `Style.stylesheet` to refuse a rule outside the declared order. The\n * text is the compiler's own output or a `Style.global` chunk, so a scanner\n * that respects strings, comments, and brace depth is enough; it is not a\n * CSS parser.\n */\nexport interface Block {\n /** What precedes the body, comments removed: `@layer app`, `.x:hover`, or a whole `@layer a, b;`. */\n readonly prelude: string\n /** The block's full text, as it appeared. */\n readonly text: string\n}\n\nconst withoutComments = (text: string): string => text.replace(/\\/\\*[\\s\\S]*?\\*\\//g, '').trim()\n\n/** Index just past the string starting at `start`, which holds its quote. */\nconst endOfString = (css: string, start: number): number => {\n const quote = css[start]\n let index = start + 1\n while (index < css.length && css[index] !== quote) index += css[index] === '\\\\' ? 2 : 1\n return index + 1\n}\n\nexport const topLevelBlocks = (css: string): ReadonlyArray<Block> => {\n const blocks: Array<Block> = []\n let start = 0\n let depth = 0\n let bodyAt = -1\n let index = 0\n while (index < css.length) {\n const char = css[index]\n if (char === '\"' || char === \"'\") {\n index = endOfString(css, index)\n continue\n }\n if (char === '/' && css[index + 1] === '*') {\n const end = css.indexOf('*/', index + 2)\n index = end === -1 ? css.length : end + 2\n continue\n }\n if (char === '{') {\n if (depth === 0) bodyAt = index\n depth++\n } else if (char === '}') {\n depth--\n if (depth === 0) {\n blocks.push({\n prelude: withoutComments(css.slice(start, bodyAt)),\n text: css.slice(start, index + 1),\n })\n start = index + 1\n }\n } else if (char === ';' && depth === 0) {\n const text = css.slice(start, index + 1)\n blocks.push({ prelude: withoutComments(text), text })\n start = index + 1\n }\n index++\n }\n const rest = css.slice(start)\n if (withoutComments(rest) !== '') blocks.push({ prelude: withoutComments(rest), text: rest })\n return blocks\n}\n\n/** `@layer a, b, c;`: an order statement, not a layered rule. */\nexport const isLayerStatement = (block: Block): boolean => /^@layer\\s[^{}]*;$/.test(block.prelude)\n\n/** The layer a `@layer name{…}` block is in; undefined for any other block. */\nexport const layerOf = (block: Block): string | undefined =>\n /^@layer\\s+([^\\s{},;]+)$/.exec(block.prelude)?.[1]\n\n/** Blocks the cascade does not order: the layer statement, keyframes, font faces, registered properties. */\nexport const isUnordered = (block: Block): boolean =>\n isLayerStatement(block) ||\n /^@(?:-webkit-)?keyframes\\s|^@font-face\\b|^@property\\s/.test(block.prelude)\n\n/** The names a `@layer a, b, c;` statement declares. */\nexport const declaredNames = (statement: string): ReadonlyArray<string> =>\n statement\n .replace(/^@layer\\s+/, '')\n .replace(/;$/, '')\n .split(',')\n .map(name => name.trim())\n","/**\n * Cascade layers as a value. `define` names an order; the result declares\n * it (`declare`) and places a piece in one of its layers (`in`), typed to\n * those names so a misspelled layer is a type error. `standard` is the\n * order a design system built on the `/theme`, `/layout`, `/defaults`, and\n * `/prose` subpaths expects; the pieces those ship are unlayered until a\n * page wraps them, so a different order needs no different generators.\n */\nimport { isLayerStatement, layerOf, topLevelBlocks } from './cssBlocks.js'\nimport { DiagnosticError } from './diagnostics.js'\nimport type { SlotItem } from './slotItem.js'\nimport type { StyleRule } from './styleRules.js'\nimport { make, type StyleValue } from './styleValue.js'\n\n/**\n * One layer of one order, for `Style.forSlots(S)(pieces, { layer })`: every\n * piece is placed before it is compiled, so the style a view attaches and the\n * style a sheet ships are the same value with the same classes. A piece\n * already in another layer keeps it and is not refused, because a slot piece\n * that is only a layered layout or recipe is ordinary.\n */\nexport interface Placement<Name extends string = string> {\n readonly layer: Name\n readonly place: (piece: StyleValue) => StyleValue\n}\n\nexport interface Layers<Name extends string> {\n readonly names: ReadonlyArray<Name>\n /** The `@layer a, b, c;` statement as a global piece; `Style.stylesheet` hoists it first. */\n readonly declare: StyleValue\n /**\n * The piece's unlayered rules and global CSS emitted inside `@layer name`,\n * including rules under `whenInput` and per-item pieces. A rule or block\n * already in a layer keeps it, so a design system's layered layout composed\n * into an application style stays in `layouts`. A piece with nothing\n * unlayered but something in another layer is refused with\n * `style:relayered`, since the call would move nothing. A slot style is\n * layered where it is defined, with `layer`, not here: placing a finished\n * style would copy it under new classes that no view attaches.\n */\n readonly in: (name: Name, piece: StyleValue) => StyleValue\n /** The placement `Style.forSlots` takes as its `layer` option. */\n readonly layer: (name: Name) => Placement<Name>\n}\n\n/** What one `in` call placed, and which other layers it left in place. */\ninterface Tally {\n placed: number\n readonly kept: Set<string>\n}\n\nconst tally = (): Tally => ({ placed: 0, kept: new Set() })\n\nconst placeRule = (name: string, rule: StyleRule, count: Tally): StyleRule => {\n if (rule.layer !== undefined && rule.layer !== name) {\n count.kept.add(rule.layer)\n return rule\n }\n count.placed++\n return rule.layer === name ? rule : { ...rule, layer: name }\n}\n\n/** Runs of unlayered blocks go into one `@layer name{…}`; layered blocks and statements stay. */\nconst placeGlobal = (name: string, css: string, count: Tally): string => {\n const out: Array<string> = []\n let pending = ''\n const flush = (): void => {\n if (pending !== '') out.push(`@layer ${name}{${pending}}`)\n pending = ''\n }\n for (const block of topLevelBlocks(css)) {\n const layer = layerOf(block)\n if (isLayerStatement(block)) {\n flush()\n out.push(block.text)\n } else if (layer === undefined) {\n pending += block.text\n count.placed++\n } else {\n flush()\n out.push(block.text)\n if (layer === name) count.placed++\n else count.kept.add(layer)\n }\n }\n flush()\n return out.join('')\n}\n\nconst place = (name: string, piece: StyleValue, count: Tally): StyleValue =>\n Object.freeze({\n ...piece,\n ...(piece.rules === undefined\n ? {}\n : { rules: Object.freeze(piece.rules.map(rule => placeRule(name, rule, count))) }),\n ...(piece.globalCss === undefined\n ? {}\n : { globalCss: Object.freeze(piece.globalCss.map(css => placeGlobal(name, css, count))) }),\n ...(piece.conditions === undefined\n ? {}\n : {\n conditions: Object.freeze(\n piece.conditions.map(condition => ({\n predicate: condition.predicate,\n piece: place(name, condition.piece, count),\n })),\n ),\n }),\n ...(piece.items === undefined\n ? {}\n : {\n // Rendered per item, after `in` returned: nothing to refuse by then.\n items: Object.freeze(\n piece.items.map(\n render => (item: SlotItem | undefined) => place(name, render(item), tally()),\n ),\n ),\n }),\n })\n\nconst refuseRelayer = (name: string, count: Tally): void => {\n if (count.placed > 0 || count.kept.size === 0) return\n const layers = [...count.kept]\n throw new DiagnosticError({\n source: 'style',\n code: 'style:relayered',\n severity: 'error',\n message: `Layers.in(\"${name}\", …) was given a piece already in layer ${layers.map(layer => `\"${layer}\"`).join(', ')}; a layered rule keeps its layer, so nothing would move. Place the unlayered piece instead.`,\n details: { layer: name, kept: layers },\n })\n}\n\nconst placeIn = (name: string, piece: StyleValue): StyleValue => {\n const count = tally()\n const placed = place(name, piece, count)\n refuseRelayer(name, count)\n return placed\n}\n\nexport const define = <const Name extends string>(names: ReadonlyArray<Name>): Layers<Name> => {\n const seen = new Set<string>()\n for (const name of names) {\n if (seen.has(name)) {\n throw new DiagnosticError({\n source: 'style',\n code: 'style:duplicate-layer',\n severity: 'error',\n message: `Layers.define names \"${name}\" twice`,\n })\n }\n seen.add(name)\n }\n return Object.freeze({\n names: Object.freeze([...names]),\n declare: make({ globalCss: Object.freeze([`@layer ${names.join(', ')};`]) }),\n in: placeIn,\n layer: (name: Name): Placement<Name> =>\n Object.freeze({ layer: name, place: (piece: StyleValue) => place(name, piece, tally()) }),\n })\n}\n\n/**\n * The shipped order. `reset` normalizes; `tokens` holds the scales that do\n * not change per theme; `theme` the knobs and what derives from them, plus\n * scoped overrides; `defaults` element defaults; then a design system's\n * `components`, `layouts` (after components, so a wrapper never beats a\n * component's inner rule), a recipe's `variants`, `utilities`, and the\n * application's `app`, always last.\n */\nexport const standard = define([\n 'reset',\n 'tokens',\n 'theme',\n 'defaults',\n 'components',\n 'layouts',\n 'variants',\n 'utilities',\n 'app',\n])\n\nexport const Layers = { define, standard } as const\n"],"mappings":";;AAeA,MAAM,mBAAmB,SAAyB,KAAK,QAAQ,qBAAqB,EAAE,CAAC,CAAC,KAAK;;AAG7F,MAAM,eAAe,KAAa,UAA0B;CAC1D,MAAM,QAAQ,IAAI;CAClB,IAAI,QAAQ,QAAQ;CACpB,OAAO,QAAQ,IAAI,UAAU,IAAI,WAAW,OAAO,SAAS,IAAI,WAAW,OAAO,IAAI;CACtF,OAAO,QAAQ;AACjB;AAEA,MAAa,kBAAkB,QAAsC;CACnE,MAAM,SAAuB,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AAK,CAAC;EAC/B,SAAS,KAAK,EAAE,WAAW,OAAO,OAAO,CAAC,UAAU,MAAM,KAAK,IAAI,EAAE,EAAE,CAAC,EAAE,CAAC;EAC3E,IAAI;EACJ,QAAQ,SACN,OAAO,OAAO;GAAE,OAAO;GAAM,QAAQ,UAAsB,MAAM,MAAM,OAAO,MAAM,CAAC;EAAE,CAAC;CAC5F,CAAC;AACH;;;;;;;;;AAUA,MAAa,WAAW,OAAO;CAC7B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,MAAa,SAAS;CAAE;CAAQ;AAAS"}
1
+ {"version":3,"file":"layers-DxWvuCJL.mjs","names":[],"sources":["../src/cssBlocks.ts","../src/layers.ts"],"sourcesContent":["/**\n * The top-level blocks of compiled CSS text, and which cascade layer each is\n * in. `Layers.in` reads them to leave an already-layered block where it is,\n * and `Style.stylesheet` to refuse a rule outside the declared order. The\n * text is the compiler's own output or a `Style.global` chunk, so a scanner\n * that respects strings, comments, and brace depth is enough; it is not a\n * CSS parser.\n */\nexport interface Block {\n /** What precedes the body, comments removed: `@layer app`, `.x:hover`, or a whole `@layer a, b;`. */\n readonly prelude: string\n /** The block's full text, as it appeared. */\n readonly text: string\n}\n\nconst withoutComments = (text: string): string => text.replace(/\\/\\*[\\s\\S]*?\\*\\//g, '').trim()\n\n/** Index just past the string starting at `start`, which holds its quote. */\nconst endOfString = (css: string, start: number): number => {\n const quote = css[start]\n let index = start + 1\n while (index < css.length && css[index] !== quote) index += css[index] === '\\\\' ? 2 : 1\n return index + 1\n}\n\nexport const topLevelBlocks = (css: string): ReadonlyArray<Block> => {\n const blocks: Array<Block> = []\n let start = 0\n let depth = 0\n let bodyAt = -1\n let index = 0\n while (index < css.length) {\n const char = css[index]\n if (char === '\"' || char === \"'\") {\n index = endOfString(css, index)\n continue\n }\n if (char === '/' && css[index + 1] === '*') {\n const end = css.indexOf('*/', index + 2)\n index = end === -1 ? css.length : end + 2\n continue\n }\n if (char === '{') {\n if (depth === 0) bodyAt = index\n depth++\n } else if (char === '}') {\n depth--\n if (depth === 0) {\n blocks.push({\n prelude: withoutComments(css.slice(start, bodyAt)),\n text: css.slice(start, index + 1),\n })\n start = index + 1\n }\n } else if (char === ';' && depth === 0) {\n const text = css.slice(start, index + 1)\n blocks.push({ prelude: withoutComments(text), text })\n start = index + 1\n }\n index++\n }\n const rest = css.slice(start)\n if (withoutComments(rest) !== '') blocks.push({ prelude: withoutComments(rest), text: rest })\n return blocks\n}\n\n/** `@layer a, b, c;`: an order statement, not a layered rule. */\nexport const isLayerStatement = (block: Block): boolean => /^@layer\\s[^{}]*;$/.test(block.prelude)\n\n/** The layer a `@layer name{…}` block is in; undefined for any other block. */\nexport const layerOf = (block: Block): string | undefined =>\n /^@layer\\s+([^\\s{},;]+)$/.exec(block.prelude)?.[1]\n\n/** Blocks the cascade does not order: the layer statement, keyframes, font faces, registered properties. */\nexport const isUnordered = (block: Block): boolean =>\n isLayerStatement(block) ||\n /^@(?:-webkit-)?keyframes\\s|^@font-face\\b|^@property\\s/.test(block.prelude)\n\n/** The names a `@layer a, b, c;` statement declares. */\nexport const declaredNames = (statement: string): ReadonlyArray<string> =>\n statement\n .replace(/^@layer\\s+/, '')\n .replace(/;$/, '')\n .split(',')\n .map(name => name.trim())\n","/**\n * Cascade layers as a value. `define` names an order; the result declares\n * it (`declare`) and places a piece in one of its layers (`in`), typed to\n * those names so a misspelled layer is a type error. `standard` is the\n * order a design system built on the `/theme`, `/layout`, `/defaults`, and\n * `/prose` subpaths expects; the pieces those ship are unlayered until a\n * page wraps them, so a different order needs no different generators.\n */\nimport { isLayerStatement, layerOf, topLevelBlocks } from './cssBlocks.js'\nimport { DiagnosticError } from './diagnostics.js'\nimport type { SlotItem } from './slotItem.js'\nimport type { StyleRule } from './styleRules.js'\nimport { make, type StyleValue } from './styleValue.js'\n\n/**\n * One layer of one order, for `Style.forSlots(S)(pieces, { layer })`: every\n * piece is placed before it is compiled, so the style a view attaches and the\n * style a sheet ships are the same value with the same classes. A piece\n * already in another layer keeps it and is not refused, because a slot piece\n * that is only a layered layout or recipe is ordinary.\n */\nexport interface Placement<Name extends string = string> {\n readonly layer: Name\n readonly place: (piece: StyleValue) => StyleValue\n}\n\nexport interface Layers<Name extends string> {\n readonly names: ReadonlyArray<Name>\n /** The `@layer a, b, c;` statement as a global piece; `Style.stylesheet` hoists it first. */\n readonly declare: StyleValue\n /**\n * The piece's unlayered rules and global CSS emitted inside `@layer name`,\n * including rules under `whenInput` and per-item pieces. A rule or block\n * already in a layer keeps it, so a design system's layered layout composed\n * into an application style stays in `layouts`. A piece with nothing\n * unlayered but something in another layer is refused with\n * `style:relayered`, since the call would move nothing. A slot style is\n * layered where it is defined, with `layer`, not here: placing a finished\n * style would copy it under new classes that no view attaches.\n */\n readonly in: (name: Name, piece: StyleValue) => StyleValue\n /** The placement `Style.forSlots` takes as its `layer` option. */\n readonly layer: (name: Name) => Placement<Name>\n}\n\n/** What one `in` call placed, and which other layers it left in place. */\ninterface Tally {\n placed: number\n readonly kept: Set<string>\n}\n\nconst tally = (): Tally => ({ placed: 0, kept: new Set() })\n\nconst placeRule = (name: string, rule: StyleRule, count: Tally): StyleRule => {\n if (rule.layer !== undefined && rule.layer !== name) {\n count.kept.add(rule.layer)\n return rule\n }\n count.placed++\n return rule.layer === name ? rule : { ...rule, layer: name }\n}\n\n/** Runs of unlayered blocks go into one `@layer name{…}`; layered blocks and statements stay. */\nconst placeGlobal = (name: string, css: string, count: Tally): string => {\n const out: Array<string> = []\n let pending = ''\n const flush = (): void => {\n if (pending !== '') out.push(`@layer ${name}{${pending}}`)\n pending = ''\n }\n for (const block of topLevelBlocks(css)) {\n const layer = layerOf(block)\n if (isLayerStatement(block)) {\n flush()\n out.push(block.text)\n } else if (layer === undefined) {\n pending += block.text\n count.placed++\n } else {\n flush()\n out.push(block.text)\n if (layer === name) count.placed++\n else count.kept.add(layer)\n }\n }\n flush()\n return out.join('')\n}\n\nconst place = (name: string, piece: StyleValue, count: Tally): StyleValue =>\n Object.freeze({\n ...piece,\n ...(piece.rules === undefined\n ? {}\n : { rules: Object.freeze(piece.rules.map(rule => placeRule(name, rule, count))) }),\n ...(piece.globalCss === undefined\n ? {}\n : { globalCss: Object.freeze(piece.globalCss.map(css => placeGlobal(name, css, count))) }),\n ...(piece.conditions === undefined\n ? {}\n : {\n conditions: Object.freeze(\n piece.conditions.map(condition => ({\n predicate: condition.predicate,\n piece: place(name, condition.piece, count),\n })),\n ),\n }),\n ...(piece.items === undefined\n ? {}\n : {\n // Rendered per item, after `in` returned: nothing to refuse by then.\n items: Object.freeze(\n piece.items.map(\n render => (item: SlotItem | undefined) => place(name, render(item), tally()),\n ),\n ),\n }),\n })\n\nconst refuseRelayer = (name: string, count: Tally): void => {\n if (count.placed > 0 || count.kept.size === 0) return\n const layers = [...count.kept]\n throw new DiagnosticError({\n source: 'style',\n code: 'style:relayered',\n severity: 'error',\n message: `Layers.in(\"${name}\", …) was given a piece already in layer ${layers.map(layer => `\"${layer}\"`).join(', ')}; a layered rule keeps its layer, so nothing would move. Place the unlayered piece instead.`,\n details: { layer: name, kept: layers },\n })\n}\n\nconst placeIn = (name: string, piece: StyleValue): StyleValue => {\n const count = tally()\n const placed = place(name, piece, count)\n refuseRelayer(name, count)\n return placed\n}\n\nexport const define = <const Name extends string>(names: ReadonlyArray<Name>): Layers<Name> => {\n const seen = new Set<string>()\n for (const name of names) {\n if (seen.has(name)) {\n throw new DiagnosticError({\n source: 'style',\n code: 'style:duplicate-layer',\n severity: 'error',\n message: `Layers.define names \"${name}\" twice`,\n })\n }\n seen.add(name)\n }\n return Object.freeze({\n names: Object.freeze([...names]),\n declare: make({ globalCss: Object.freeze([`@layer ${names.join(', ')};`]) }),\n in: placeIn,\n layer: (name: Name): Placement<Name> =>\n Object.freeze({ layer: name, place: (piece: StyleValue) => place(name, piece, tally()) }),\n })\n}\n\n/**\n * The shipped order. `reset` normalizes; `tokens` holds the scales that do\n * not change per theme; `theme` the knobs and what derives from them, plus\n * scoped overrides; `defaults` element defaults; then a design system's\n * `components`, `layouts` (after components, so a wrapper never beats a\n * component's inner rule), a recipe's `variants`, `utilities`, and the\n * application's `app`, always last.\n */\nexport const standard = define([\n 'reset',\n 'tokens',\n 'theme',\n 'defaults',\n 'components',\n 'layouts',\n 'variants',\n 'utilities',\n 'app',\n])\n\nexport const Layers = { define, standard } as const\n"],"mappings":";;AAeA,MAAM,mBAAmB,SAAyB,KAAK,QAAQ,qBAAqB,EAAE,CAAC,CAAC,KAAK;;AAG7F,MAAM,eAAe,KAAa,UAA0B;CAC1D,MAAM,QAAQ,IAAI;CAClB,IAAI,QAAQ,QAAQ;CACpB,OAAO,QAAQ,IAAI,UAAU,IAAI,WAAW,OAAO,SAAS,IAAI,WAAW,OAAO,IAAI;CACtF,OAAO,QAAQ;AACjB;AAEA,MAAa,kBAAkB,QAAsC;CACnE,MAAM,SAAuB,CAAC;CAC9B,IAAI,QAAQ;CACZ,IAAI,QAAQ;CACZ,IAAI,SAAS;CACb,IAAI,QAAQ;CACZ,OAAO,QAAQ,IAAI,QAAQ;EACzB,MAAM,OAAO,IAAI;EACjB,IAAI,SAAS,QAAO,SAAS,KAAK;GAChC,QAAQ,YAAY,KAAK,KAAK;GAC9B;EACF;EACA,IAAI,SAAS,OAAO,IAAI,QAAQ,OAAO,KAAK;GAC1C,MAAM,MAAM,IAAI,QAAQ,MAAM,QAAQ,CAAC;GACvC,QAAQ,QAAQ,KAAK,IAAI,SAAS,MAAM;GACxC;EACF;EACA,IAAI,SAAS,KAAK;GAChB,IAAI,UAAU,GAAG,SAAS;GAC1B;EACF,OAAO,IAAI,SAAS,KAAK;GACvB;GACA,IAAI,UAAU,GAAG;IACf,OAAO,KAAK;KACV,SAAS,gBAAgB,IAAI,MAAM,OAAO,MAAM,CAAC;KACjD,MAAM,IAAI,MAAM,OAAO,QAAQ,CAAC;IAClC,CAAC;IACD,QAAQ,QAAQ;GAClB;EACF,OAAO,IAAI,SAAS,OAAO,UAAU,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AS,IAAI,MAAM,EAAE,CAAC,CAAC,KAAK,IAAI,EAAE;EACpH,SAAS;GAAE,OAAO;GAAM,MAAM;EAAO;CACvC,CAAC;AACH;AAEA,MAAM,WAAW,MAAc,UAAkC;CAC/D,MAAM,QAAQ,MAAM;CACpB,MAAM,SAAS,MAAM,MAAM,OAAO,KAAK;CACvC,cAAc,MAAM,KAAK;CACzB,OAAO;AACT;AAEA,MAAa,UAAqC,UAA6C;CAC7F,MAAM,uBAAO,IAAI,IAAY;CAC7B,KAAK,MAAM,QAAQ,OAAO;EACxB,IAAI,KAAK,IAAI,IAAI,GACf,MAAM,IAAI,gBAAgB;GACxB,QAAQ;GACR,MAAM;GACN,UAAU;GACV,SAAS,wBAAwB,KAAK;EACxC,CAAC;EAEH,KAAK,IAAI,IAAI;CACf;CACA,OAAO,OAAO,OAAO;EACnB,OAAO,OAAO,OAAO,CAAC,GAAG,KAAK,CAAC;EAC/B,SAAS,KAAK,EAAE,WAAW,OAAO,OAAO,CAAC,UAAU,MAAM,KAAK,IAAI,EAAE,EAAE,CAAC,EAAE,CAAC;EAC3E,IAAI;EACJ,QAAQ,SACN,OAAO,OAAO;GAAE,OAAO;GAAM,QAAQ,UAAsB,MAAM,MAAM,OAAO,MAAM,CAAC;EAAE,CAAC;CAC5F,CAAC;AACH;;;;;;;;;AAUA,MAAa,WAAW,OAAO;CAC7B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,MAAa,SAAS;CAAE;CAAQ;AAAS"}
package/dist/layers.mjs CHANGED
@@ -1 +1 @@
1
- export { t as Layers, n as define, r as standard } from "./layers-keV38soP.mjs";
1
+ export { t as Layers, n as define, r as standard } from "./layers-DxWvuCJL.mjs";
package/dist/layout.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { C as className, _ as self, a as container, h as pseudo, i as compose, m as nest, o as empty, p as media, x as vars } from "./styleValue-Cj4YjgVB.mjs";
1
+ import { C as className, _ as self, a as container, h as pseudo, i as compose, m as nest, o as empty, p as media, x as vars } from "./styleValue-6hpAYYfg.mjs";
2
2
  //#region src/layout.ts
3
3
  /**
4
4
  * `foldkit-mixins/layout`: layout pieces (stack, cluster, sidebar, …) as
@@ -14,6 +14,24 @@ interface OklchKnobs {
14
14
  /** Degrees added to the accent hue for the secondary and tertiary families. */
15
15
  readonly secondaryHueShift?: number;
16
16
  readonly tertiaryHueShift?: number;
17
+ /**
18
+ * The hue of the neutrals (surfaces, text, outlines, the shadow), apart
19
+ * from the accent's, as a base color is: a warm stone under a blue accent.
20
+ * Without it the neutrals take the accent's hue, and follow it when the
21
+ * `accent-h` knob moves.
22
+ */
23
+ readonly neutral?: {
24
+ readonly h: number;
25
+ };
26
+ /**
27
+ * The tint of every shadow: its hue (the neutrals' unless given) and chroma
28
+ * (twice the surfaces' unless given), so a warm theme's cards cast a warm
29
+ * shadow. `shadow-strength` still scales how much of it shows.
30
+ */
31
+ readonly shadow?: {
32
+ readonly h?: number;
33
+ readonly c?: number;
34
+ };
17
35
  /** Chroma of neutral surfaces; 0 is gray. */
18
36
  readonly surfaceSaturation?: number;
19
37
  /** How far apart the surface steps are, 0–100%. */
@@ -22,6 +40,17 @@ interface OklchKnobs {
22
40
  readonly contrastFactor?: number;
23
41
  /** Chroma of the code colors (`syntax-*`), 0–0.4; default `0.14`. */
24
42
  readonly syntaxChroma?: number;
43
+ /**
44
+ * How menus, listboxes and comboboxes draw their panels, as shadcn's menu
45
+ * options: the row the keys or pointer are on in a tint of the text
46
+ * (`subtle`, the default) or the accent's fill (`bold`); the panel in the
47
+ * page's surface (`default`), the opposite scheme's (`inverted`), or either
48
+ * see-through over a blur (`translucent`, `inverted-translucent`).
49
+ */
50
+ readonly menu?: {
51
+ readonly accent?: 'subtle' | 'bold';
52
+ readonly color?: 'default' | 'inverted' | 'translucent' | 'inverted-translucent';
53
+ };
25
54
  /** Hues of the feedback families. */
26
55
  readonly feedback?: {
27
56
  readonly success?: number;
@@ -29,6 +58,15 @@ interface OklchKnobs {
29
58
  readonly error?: number;
30
59
  readonly info?: number;
31
60
  };
61
+ /**
62
+ * What a hover is made of: `neutral` mixes the element's own text, as
63
+ * before; `surface` (the default) mixes a painted surface's own paint where
64
+ * one names it (an alert band, a tone's fill), the text elsewhere; `accent`
65
+ * leans every hover on the accent at low chroma, as Fluid's. One override
66
+ * changes every component. Painted surfaces read the derived `surface-ink`
67
+ * knob below (0 in `neutral`), so the choice also switches at runtime.
68
+ */
69
+ readonly stateHue?: 'neutral' | 'surface' | 'accent';
32
70
  }
33
71
  declare const oklch: (knobs: OklchKnobs) => Readonly<{
34
72
  knob: {
@@ -37,6 +75,7 @@ declare const oklch: (knobs: OklchKnobs) => Readonly<{
37
75
  'accent-l': string;
38
76
  'accent-c-dark': string;
39
77
  'accent-l-dark': string;
78
+ 'neutral-h': string;
40
79
  'secondary-shift': string;
41
80
  'tertiary-shift': string;
42
81
  'surface-c': string;
@@ -50,6 +89,19 @@ declare const oklch: (knobs: OklchKnobs) => Readonly<{
50
89
  'error-h': string;
51
90
  'info-h': string;
52
91
  'syntax-c': string;
92
+ 'chart-h': string;
93
+ 'popup-bold': string;
94
+ 'popup-invert': string;
95
+ 'popup-alpha': string;
96
+ 'popup-blur': string;
97
+ 'state-hover': string;
98
+ 'state-tint': string;
99
+ 'state-tint-dark': string;
100
+ 'surface-ink': string;
101
+ 'image-edge': string;
102
+ 'shadow-h': string;
103
+ 'shadow-c': string;
104
+ 'raise-dark': string;
53
105
  };
54
106
  hue: {
55
107
  accent: string;
@@ -59,6 +111,7 @@ declare const oklch: (knobs: OklchKnobs) => Readonly<{
59
111
  };
60
112
  surface: {
61
113
  base: string;
114
+ field: string;
62
115
  muted: string;
63
116
  subtle: string;
64
117
  default: string;
@@ -109,6 +162,21 @@ declare const oklch: (knobs: OklchKnobs) => Readonly<{
109
162
  shadow: {
110
163
  color: string;
111
164
  };
165
+ state: {
166
+ hover: string;
167
+ tint: string;
168
+ 'tint-hover': string;
169
+ edge: string;
170
+ ink: string;
171
+ };
172
+ popup: {
173
+ surface: string;
174
+ inverted: string;
175
+ ink: string;
176
+ highlight: string;
177
+ 'highlight-ink': string;
178
+ blur: string;
179
+ };
112
180
  success: {
113
181
  default: string;
114
182
  hover: string;
@@ -145,6 +213,13 @@ declare const oklch: (knobs: OklchKnobs) => Readonly<{
145
213
  'on-fill': string;
146
214
  ink: string;
147
215
  };
216
+ chart: {
217
+ '1': string;
218
+ '2': string;
219
+ '3': string;
220
+ '4': string;
221
+ '5': string;
222
+ };
148
223
  syntax: {
149
224
  keyword: string;
150
225
  function: string;
@@ -160,4 +235,4 @@ declare const oklch: (knobs: OklchKnobs) => Readonly<{
160
235
  type OklchTheme = ReturnType<typeof oklch>;
161
236
  //#endregion
162
237
  export { OklchTheme as n, oklch as r, OklchKnobs as t };
163
- //# sourceMappingURL=oklch-CDSDQNWl.d.mts.map
238
+ //# sourceMappingURL=oklch-BCbqJ1aM.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oklch-BCbqJ1aM.d.mts","names":[],"sources":["../src/theme/oklch.ts"],"mappings":";UAYiB;;WAEN;aACE;aACA;aACA;;aAEA;eAAkB;eAAqB;;;;WAGzC;WACA;;;;;;;WAOA;aAAqB;;;;;;;WAMrB;aAAoB;aAAqB;;;WAEzC;;WAEA;;WAEA;;WAEA;;;;;;;;WAQA;aACE;aACA;;;WAGF;aACE;aACA;aACA;aACA;;;;;;;;;;WAUF;;cAoHE,QAAK,OAAW,eAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA+CjC;IACA;IACA;IACA;;;IAGA;IAOA;IAIA;IACA;IACA;IACA;IAGA;;;IAMA;IACA;IACA;IACA;IACA;IACA;;;IAOA;IACA;IACA;IAGA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAcA;;;IAoBA;IACA;IAIA;IAIA;IACA;;;IAIA;IASA;IAKA;IACA;IAKA;IACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAUA;IACA;IACA;IACA;IACA;;;IAMA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;;;KAKM,aAAa,kBAAkB"}
package/dist/prose.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { _ as self, i as compose, m as nest, u as inline } from "./styleValue-Cj4YjgVB.mjs";
1
+ import { _ as self, i as compose, m as nest, u as inline } from "./styleValue-6hpAYYfg.mjs";
2
2
  //#region src/prose.ts
3
3
  /**
4
4
  * `foldkit-mixins/prose`: the longform-content contract. One class carries
@@ -1,5 +1,5 @@
1
- import { c as global } from "./styleValue-Cj4YjgVB.mjs";
2
- import { n as VAR_PREFIX } from "./core-IMVYU8JN.mjs";
1
+ import { c as global } from "./styleValue-6hpAYYfg.mjs";
2
+ import { n as VAR_PREFIX } from "./core-By7s5txd.mjs";
3
3
  //#region src/theme/root.ts
4
4
  /**
5
5
  * A theme's tokens as `:root` custom properties, for the page stylesheet.
@@ -34,4 +34,4 @@ const scoped = (_theme, selector, overrides) => {
34
34
  //#endregion
35
35
  export { scoped as n, root as t };
36
36
 
37
- //# sourceMappingURL=root-BBi88KYx.mjs.map
37
+ //# sourceMappingURL=root-cMUipDvi.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"root-BBi88KYx.mjs","names":[],"sources":["../src/theme/root.ts"],"sourcesContent":["/**\n * A theme's tokens as `:root` custom properties, for the page stylesheet.\n * Unlayered: the page decides which layer with `Layers.in`.\n */\nimport { global, type StyleValue } from '../styleValue.js'\nimport { VAR_PREFIX, type ThemeTokens } from './core.js'\n\nexport interface RootOptions {\n /** Tokens present in this theme are left out, so a scale shipped in another layer goes out once. */\n readonly omit?: ThemeTokens\n /** Default `'light dark'`, so `lightDark` tokens resolve. */\n readonly colorScheme?: 'light dark' | 'light' | 'dark'\n}\n\n/**\n * Every token as `--fk-group-name:value`, in authored order. `omit` is\n * matched token by token, not group by group: two themes can both carry a\n * `knob` group (the scales' density beside a palette's hues) and only the\n * names `omit` has are skipped.\n */\nconst declarations = (theme: ThemeTokens, omit?: ThemeTokens): ReadonlyArray<string> =>\n Object.entries(theme).flatMap(([group, names]) =>\n Object.entries(names).flatMap(([name, value]) =>\n omit !== undefined && Object.hasOwn(omit[group] ?? {}, name)\n ? []\n : [`${VAR_PREFIX}-${group}-${name}:${value}`],\n ),\n )\n\nexport const root = (theme: ThemeTokens, options?: RootOptions): StyleValue =>\n global(\n `:root{${[...declarations(theme, options?.omit), `color-scheme:${options?.colorScheme ?? 'light dark'}`].join(';')}}`,\n )\n\n/** Some of a theme's tokens, by the theme's own group and token names. */\nexport type Overrides<T extends ThemeTokens> = {\n readonly [G in keyof T]?: { readonly [N in keyof T[G]]?: string }\n}\n\n/**\n * Token overrides under `selector`: a named theme the Model selects with a\n * root attribute (`:root[data-theme=\"ocean\"]`), a scheme the user chose\n * (`:root[data-color-scheme=\"dark\"]`), or a subtree (`.marketing`). Which\n * one is active is the Model's fact; this only says what it means.\n *\n * `theme` is the theme being overridden and is read only for its type, so a\n * group or token it lacks is a type error rather than a variable nothing reads.\n */\nexport const scoped = <T extends ThemeTokens>(\n _theme: T,\n selector: string,\n overrides: Overrides<T>,\n): StyleValue => {\n const tokens: Record<string, Record<string, string>> = {}\n for (const [group, names] of Object.entries(overrides)) {\n const defined: Record<string, string> = {}\n for (const [name, value] of Object.entries(names ?? {})) {\n if (typeof value === 'string') defined[name] = value\n }\n tokens[group] = defined\n }\n return global(`${selector}{${declarations(tokens).join(';')}}`)\n}\n"],"mappings":";;;;;;;;;;;;;AAoBA,MAAM,gBAAgB,OAAoB,SACxC,OAAO,QAAQ,KAAK,CAAC,CAAC,SAAS,CAAC,OAAO,WACrC,OAAO,QAAQ,KAAK,CAAC,CAAC,SAAS,CAAC,MAAM,WACpC,SAAS,KAAA,KAAa,OAAO,OAAO,KAAK,UAAU,CAAC,GAAG,IAAI,IACvD,CAAC,IACD,CAAC,GAAG,WAAW,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,CAChD,CACF;AAEF,MAAa,QAAQ,OAAoB,YACvC,OACE,SAAS,CAAC,GAAG,aAAa,OAAO,SAAS,IAAI,GAAG,gBAAgB,SAAS,eAAe,cAAc,CAAC,CAAC,KAAK,GAAG,EAAE,EACrH;;;;;;;;;;AAgBF,MAAa,UACX,QACA,UACA,cACe;CACf,MAAM,SAAiD,CAAC;CACxD,KAAK,MAAM,CAAC,OAAO,UAAU,OAAO,QAAQ,SAAS,GAAG;EACtD,MAAM,UAAkC,CAAC;EACzC,KAAK,MAAM,CAAC,MAAM,UAAU,OAAO,QAAQ,SAAS,CAAC,CAAC,GACpD,IAAI,OAAO,UAAU,UAAU,QAAQ,QAAQ;EAEjD,OAAO,SAAS;CAClB;CACA,OAAO,OAAO,GAAG,SAAS,GAAG,aAAa,MAAM,CAAC,CAAC,KAAK,GAAG,EAAE,EAAE;AAChE"}
1
+ {"version":3,"file":"root-cMUipDvi.mjs","names":[],"sources":["../src/theme/root.ts"],"sourcesContent":["/**\n * A theme's tokens as `:root` custom properties, for the page stylesheet.\n * Unlayered: the page decides which layer with `Layers.in`.\n */\nimport { global, type StyleValue } from '../styleValue.js'\nimport { VAR_PREFIX, type ThemeTokens } from './core.js'\n\nexport interface RootOptions {\n /** Tokens present in this theme are left out, so a scale shipped in another layer goes out once. */\n readonly omit?: ThemeTokens\n /** Default `'light dark'`, so `lightDark` tokens resolve. */\n readonly colorScheme?: 'light dark' | 'light' | 'dark'\n}\n\n/**\n * Every token as `--fk-group-name:value`, in authored order. `omit` is\n * matched token by token, not group by group: two themes can both carry a\n * `knob` group (the scales' density beside a palette's hues) and only the\n * names `omit` has are skipped.\n */\nconst declarations = (theme: ThemeTokens, omit?: ThemeTokens): ReadonlyArray<string> =>\n Object.entries(theme).flatMap(([group, names]) =>\n Object.entries(names).flatMap(([name, value]) =>\n omit !== undefined && Object.hasOwn(omit[group] ?? {}, name)\n ? []\n : [`${VAR_PREFIX}-${group}-${name}:${value}`],\n ),\n )\n\nexport const root = (theme: ThemeTokens, options?: RootOptions): StyleValue =>\n global(\n `:root{${[...declarations(theme, options?.omit), `color-scheme:${options?.colorScheme ?? 'light dark'}`].join(';')}}`,\n )\n\n/** Some of a theme's tokens, by the theme's own group and token names. */\nexport type Overrides<T extends ThemeTokens> = {\n readonly [G in keyof T]?: { readonly [N in keyof T[G]]?: string }\n}\n\n/**\n * Token overrides under `selector`: a named theme the Model selects with a\n * root attribute (`:root[data-theme=\"ocean\"]`), a scheme the user chose\n * (`:root[data-color-scheme=\"dark\"]`), or a subtree (`.marketing`). Which\n * one is active is the Model's fact; this only says what it means.\n *\n * `theme` is the theme being overridden and is read only for its type, so a\n * group or token it lacks is a type error rather than a variable nothing reads.\n */\nexport const scoped = <T extends ThemeTokens>(\n _theme: T,\n selector: string,\n overrides: Overrides<T>,\n): StyleValue => {\n const tokens: Record<string, Record<string, string>> = {}\n for (const [group, names] of Object.entries(overrides)) {\n const defined: Record<string, string> = {}\n for (const [name, value] of Object.entries(names ?? {})) {\n if (typeof value === 'string') defined[name] = value\n }\n tokens[group] = defined\n }\n return global(`${selector}{${declarations(tokens).join(';')}}`)\n}\n"],"mappings":";;;;;;;;;;;;;AAoBA,MAAM,gBAAgB,OAAoB,SACxC,OAAO,QAAQ,KAAK,CAAC,CAAC,SAAS,CAAC,OAAO,WACrC,OAAO,QAAQ,KAAK,CAAC,CAAC,SAAS,CAAC,MAAM,WACpC,SAAS,KAAA,KAAa,OAAO,OAAO,KAAK,UAAU,CAAC,GAAG,IAAI,IACvD,CAAC,IACD,CAAC,GAAG,WAAW,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,CAChD,CACF;AAEF,MAAa,QAAQ,OAAoB,YACvC,OACE,SAAS,CAAC,GAAG,aAAa,OAAO,SAAS,IAAI,GAAG,gBAAgB,SAAS,eAAe,cAAc,CAAC,CAAC,KAAK,GAAG,EAAE,EACrH;;;;;;;;;;AAgBF,MAAa,UACX,QACA,UACA,cACe;CACf,MAAM,SAAiD,CAAC;CACxD,KAAK,MAAM,CAAC,OAAO,UAAU,OAAO,QAAQ,SAAS,GAAG;EACtD,MAAM,UAAkC,CAAC;EACzC,KAAK,MAAM,CAAC,MAAM,UAAU,OAAO,QAAQ,SAAS,CAAC,CAAC,GACpD,IAAI,OAAO,UAAU,UAAU,QAAQ,QAAQ;EAEjD,OAAO,SAAS;CAClB;CACA,OAAO,OAAO,GAAG,SAAS,GAAG,aAAa,MAAM,CAAC,CAAC,KAAK,GAAG,EAAE,EAAE;AAChE"}