foldkit-mixins 0.14.0 → 0.16.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 (48) hide show
  1. package/README.md +95 -27
  2. package/dist/app.d.mts +30 -14
  3. package/dist/app.d.mts.map +1 -1
  4. package/dist/app.mjs +12 -18
  5. package/dist/app.mjs.map +1 -1
  6. package/dist/{core-By7s5txd.mjs → core-BrR6UPbk.mjs} +6 -2
  7. package/dist/core-BrR6UPbk.mjs.map +1 -0
  8. package/dist/index.d.mts +2 -2
  9. package/dist/index.mjs +2 -2
  10. package/dist/pipe-DrDyEhoj.d.mts +11 -0
  11. package/dist/pipe-DrDyEhoj.d.mts.map +1 -0
  12. package/dist/root-D_gJPXBw.mjs +345 -0
  13. package/dist/root-D_gJPXBw.mjs.map +1 -0
  14. package/dist/{slotView-8_CHU9i7.d.mts → slotView-BfOwXpGw.d.mts} +2 -10
  15. package/dist/slotView-BfOwXpGw.d.mts.map +1 -0
  16. package/dist/{style-BhOFChc5.mjs → style-COMT0F2e.mjs} +2 -5
  17. package/dist/style-COMT0F2e.mjs.map +1 -0
  18. package/dist/{style-moq41T8O.d.mts → style-Cs-aMa_a.d.mts} +2 -2
  19. package/dist/{style-moq41T8O.d.mts.map → style-Cs-aMa_a.d.mts.map} +1 -1
  20. package/dist/testing.d.mts +1 -1
  21. package/dist/theme.d.mts +250 -41
  22. package/dist/theme.d.mts.map +1 -1
  23. package/dist/theme.mjs +43 -209
  24. package/dist/theme.mjs.map +1 -1
  25. package/dist/themes-DKzh-mwX.d.mts +434 -0
  26. package/dist/themes-DKzh-mwX.d.mts.map +1 -0
  27. package/dist/tokens-BpnLFiKE.mjs +1040 -0
  28. package/dist/tokens-BpnLFiKE.mjs.map +1 -0
  29. package/dist/tokens-P-zBWN9o.d.mts +582 -0
  30. package/dist/tokens-P-zBWN9o.d.mts.map +1 -0
  31. package/dist/utilities.d.mts +3 -4
  32. package/dist/utilities.d.mts.map +1 -1
  33. package/dist/utilities.mjs +3 -3
  34. package/dist/utilities.mjs.map +1 -1
  35. package/package.json +1 -1
  36. package/dist/core-By7s5txd.mjs.map +0 -1
  37. package/dist/oklch-BCbqJ1aM.d.mts +0 -238
  38. package/dist/oklch-BCbqJ1aM.d.mts.map +0 -1
  39. package/dist/root-DCb6aqif.d.mts +0 -25
  40. package/dist/root-DCb6aqif.d.mts.map +0 -1
  41. package/dist/root-cMUipDvi.mjs +0 -37
  42. package/dist/root-cMUipDvi.mjs.map +0 -1
  43. package/dist/slotView-8_CHU9i7.d.mts.map +0 -1
  44. package/dist/style-BhOFChc5.mjs.map +0 -1
  45. package/dist/tokens-BOFcnIJM.mjs +0 -310
  46. package/dist/tokens-BOFcnIJM.mjs.map +0 -1
  47. package/dist/tokens-DOTnlgyA.d.mts +0 -265
  48. package/dist/tokens-DOTnlgyA.d.mts.map +0 -1
package/README.md CHANGED
@@ -276,10 +276,8 @@ one.
276
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 |
277
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` |
278
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 |
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` |
280
- | `Theme.hardShadows` | from `foldkit-mixins/theme`: the shadow scale as solid offset copies with no blur, for a retro or brutalist look; compose it over `Theme.tokens`, and `shadow-strength` still fades it |
281
- | Type and shape knobs | `Theme.tokens`' `knob` group also holds `text-scale` (every type size), `heading-scale` (how far headings stand above the body), `leading` (line heights) and `control-round` (1 rounds buttons and segmented trays to a pill through `radius-control`); `weight-heading` and `tracking-heading` set the headings' weight and letter spacing |
282
- | `Theme.relief.soft` / `.hard` / `.bevel` | from `foldkit-mixins/theme`: how controls stand off the page, as the `shadow-raised` (a faced button), `shadow-pressed` (held or on) and `shadow-field` (a field's well) tokens, which `Theme.tokens` ships flat; compose one over `Theme.tokens` and every `foldkit-mixins-ui` button and field follows |
279
+ | `Theme.make(values)` / `Theme.standard(theme?)` | from `foldkit-mixins/theme`: a theme, the typed knob values it changes (`Knobs.standard`); every shipped token with a theme's knobs, for `Theme.root` |
280
+ | `Theme.tokens` / `Theme.breakpointWidths(theme)` | from `foldkit-mixins/theme`: the shipped spacing, type, radius, motion, width, 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`); the breakpoints as pixel widths for `foldkit-primitives/media` |
283
281
  | `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` |
284
282
  | `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 |
285
283
 
@@ -334,12 +332,73 @@ Beyond `self`, `pseudo`, `media`, `supports`, `container` and `nest`, the rule p
334
332
  scoped to the class (`:is(a, b)` is not split), and a selector that writes `&` places the class
335
333
  itself (`nest('[data-open] &')`).
336
334
 
337
- ### Theme from a few knobs
335
+ ### Themes as typed knobs
338
336
 
339
- `foldkit-mixins/theme` extends the root `Theme` with the pieces a page ships. `Theme.oklch` takes
340
- an accent color and a few knobs (hue shifts, a neutral hue, surface saturation and contrast, a
341
- contrast factor, feedback hues) and returns typed tokens for surfaces, text, outlines, and the accent, secondary,
342
- tertiary and feedback families. Only the `knob` group holds literals; every other value is a CSS
337
+ `foldkit-mixins/theme` extends the root `Theme` with the pieces a page ships. A theme is a typed
338
+ set of knob values: only what it changes, every other knob at its default.
339
+ `Theme.make` checks each value against its knob (`Knobs.standard`, grouped by concern: `accent`,
340
+ `surface`, `shape`, `type`, `motion`, `shadow`, `menu`, `feedback`, `code`, `chart`, `scales`),
341
+ so a misspelt knob or a choice outside its options is a type error and a number out of its range
342
+ throws where the theme is made. A theme is `pipe`able: `Theme.set` changes some knobs, and
343
+ `Theme.describe` gives it a title and a description for a list of themes.
344
+
345
+ ```ts
346
+ const cobalt = Theme.make({
347
+ accent: { hue: 235, chroma: 0.225, lightness: 55 },
348
+ surface: { saturation: 0, contrast: 24 },
349
+ shape: { radius: 1.8, density: 1.1, controls: 'pill' },
350
+ menu: { panel: 'inverted' },
351
+ }).pipe(Theme.describe({ title: 'Cobalt' }))
352
+
353
+ const cobaltDense = cobalt.pipe(Theme.set({ shape: { density: 0.9 } }))
354
+
355
+ const sheet = Style.stylesheet(
356
+ Layers.standard.declare,
357
+ Layers.standard.in('theme', Theme.root(Theme.standard(cobaltDense))),
358
+ )
359
+ ```
360
+
361
+ `Theme.make` writes nothing itself: `Theme.variables(theme)` is the knob variables it declares
362
+ (the values it sets, and each unset knob's default or the expression it follows, such as the
363
+ neutrals following the accent's hue), and `Theme.standard(theme)` is every shipped token with
364
+ them, which `Theme.root` declares: the derivations are the same CSS for every theme, so a theme is
365
+ only its knobs. A knob of an
366
+ application's own is a `Knob` kind (`Knob.number`, `percent`, `length`, `angle`, `choice`,
367
+ `font`, `schemed`), and `Theme.make(knobs, values)` takes a set of them. Every knob is a variable, choices
368
+ too: an option is the CSS its variables hold, so `shadow.relief: 'bevel'` writes the bevelled
369
+ shadow lists and `motion.easing: 'spring'` writes the spring curve, and each switches at runtime
370
+ as a number does.
371
+ Each knob carries a `title`, a `description` and its `default`, so a control can be drawn from
372
+ it; `Knobs.schema(Knobs.standard)` is the Schema of a theme's values (a Model field, a decoded
373
+ URL), `Theme.print(theme)` writes a theme's `Theme.make({ … })` source, only the knobs that differ
374
+ from their defaults, and `Theme.fonts` names the font stacks a `type.body` knob may take. An editor
375
+ reaches a knob by its path, typed by it: `Knobs.paths(knobs)` lists them, `Knobs.at(knobs,
376
+ 'shape.radius')` is the knob, and `Knobs.valueAt` and `Knobs.withValue` read and set one value of a
377
+ theme, checked by its knob; a schemed knob's `light` and `dark` are knobs of their own, each with its
378
+ range. `/create` is drawn this way.
379
+
380
+ Themes are installed by name, the names being a record's keys:
381
+
382
+ ```ts
383
+ const themes = Themes.make({ cobalt, cobaltDense }, { initial: 'cobalt' })
384
+ const { t, stylesheet } = AppStyle.make({ themes })
385
+ const Model = Schema.Struct({ theme: themes.Name })
386
+ ```
387
+
388
+ The root declares the palette's derivations with the initial theme's knobs, and each other theme
389
+ writes only its knobs under `:root[data-theme="name"]`, the same element, where every token
390
+ re-derives from them. Which theme shows is the Model's fact (`themes.Name` decodes the field),
391
+ and `Themes.apply(themes, name)` is the Command's effect that shows it. A token resolves where it
392
+ is declared, so knobs set below the root change nothing derived from them there:
393
+ `Theme.scope(theme, '.marketing')` declares the derivations again under the selector, which
394
+ `Theme.scoped`'s token overrides do not. `AppStyle.make({ theme })` takes one theme, and its
395
+ `tokens` an application's own groups beside the shipped ones. The design is in
396
+ `docs/theme-knobs.md`.
397
+
398
+ ### What the palette derives
399
+
400
+ `Theme.standard(theme)` holds typed tokens for surfaces, text, outlines, and the accent, secondary,
401
+ tertiary and feedback families, derived from the theme's knobs. Only the `knob` group holds literals; every other value is a CSS
343
402
  expression over other tokens (`oklch(from …)`, `color-mix()`, `light-dark()`), so the browser does
344
403
  the derivation and one knob override recolors everything below it. Each family (`accent`,
345
404
  `secondary`, `tertiary`, `success`, `warning`, `error`, `info`) is one shape: a fill, `default`,
@@ -348,19 +407,27 @@ line in it that stands off the base; and two text colors named for where they go
348
407
  text on that fill (near white on a mid accent), and `ink` is text in the family's color on the
349
408
  base surface, dark enough to read in a light scheme and light enough in a dark one. Colored text
350
409
  is `ink`, never `default`. The surfaces are the base at a few lightnesses with its chroma, so a
351
- panel and a sidebar read as the page's own color, in the accent's hue unless `neutral: { h }` gives
410
+ panel and a sidebar read as the page's own color, in the accent's hue unless `surface.hue` gives
352
411
  them one of their own (a base color: a warm stone under a blue accent); `bedrock` is the deepest of them in both
353
412
  schemes, and the focus ring, `outline.focus`, is the accent. The `syntax` group colors code by
354
413
  the kinds a tokenizer names (`syntax-keyword` is `--fk-syntax-keyword`, as
355
414
  `foldkit-richtext-code` and its Shiki adapter name them): `keyword`, `function` and `type` in
356
415
  the accent, secondary and tertiary hues, `string`, `number` and `property` in the success,
357
- warning and info hues, all at one lightness per scheme and the `syntaxChroma` knob's chroma, and
416
+ warning and info hues, all at one lightness per scheme and the `code.chroma` knob's chroma, and
358
417
  `operator`, `punctuation` and `comment` in the text's own grey. The `chart` group is a chart's
359
418
  series colors, `chart-1` to `chart-5` as shadcn names them: the dataviz reference palette's first
360
419
  five slots in its order, so neighbors stay apart under protan and deutan vision, each a fixed turn
361
- 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
362
- panel (`surface`, `ink`, `blur`) and its lit row (`highlight`, `highlight-ink`): `menu: { accent:
363
- 'bold' }` lights the row in the accent's fill, and `menu: { color }` draws the panel `inverted`
420
+ of hue from the `chart-h` knob at a lightness and chroma set for that hue in each scheme. Seven
421
+ color scales, `red`, `orange`, `yellow`, `green`, `teal`, `blue` and `purple`, are for what no
422
+ role names (a tag's color, an illustration, a status of the application's own): steps `1` (near
423
+ white) to `10` (near black) share one lightness ladder, so `red-6` is as light as `blue-6` and a
424
+ step means the same contrast in every hue, with chroma swelling toward the middle and thinning
425
+ at both ends, where a vivid near-white or near-black falls out of gamut; `wash-1` to `wash-4`
426
+ mix step 6 into `surface.base` at 8, 16, 28 and 44%, so a tinted ground follows the scheme and
427
+ the surface knobs. Each hue is a knob (`red-h`), and `scale-c` scales every step's chroma
428
+ (`--fk-blue-wash-2`, `ref.blue['6']`). The `popup` group is a menu's
429
+ panel (`surface`, `ink`, `blur`) and its lit row (`highlight`, `highlight-ink`): `menu.highlight:
430
+ 'bold'` lights the row in the accent's fill, and `menu.panel` draws the panel `inverted`
364
431
  (the other scheme's surface and text) or `translucent` over a blur, as shadcn's menu options do.
365
432
  Each is a 0-or-1 knob (`popup-bold`, `popup-invert`) blended by `color-mix`, so an override
366
433
  switches it live. The `state` group is what a state lays over the surface under it, a mix of the
@@ -371,7 +438,11 @@ border?)` is the radius of a surface inset in another, so their corners are conc
371
438
  container that pads its children can publish that instead: spread `Theme.nests(radius, inset,
372
439
  border?)` beside its own radius and padding, and `Theme.nested()` with no arguments on any
373
440
  descendant (a row, a pill, a highlight, a focus ring) reads it. Outside such a container it is
374
- square.
441
+ square. `Theme.concentric({ min, max })` is a control's corner read the same way, the container's
442
+ corner less its inset kept between `min` and `max`, and `max` outside any: `foldkit-mixins-ui`'s
443
+ buttons and fields take `concentric({ min: sm, max: md })`, and its Card, Dialog, Toast and Alert
444
+ `nests`, so a button in a card rounds with the card. A control that `nests` its own parts sets
445
+ `'--fk-control-corner': 'inherit'` after `nests`, or it reads the corner it publishes.
375
446
  `Theme.raise(offset)` lifts an element `offset` levels above the raised element holding it (or the
376
447
  page, level 1), capped at 8, and `Theme.raisedSurface()` is its background at that level: a popover
377
448
  opened in a dialog lands above the dialog with nothing passed. In a light scheme the first two
@@ -392,7 +463,7 @@ import { Layers, Slot, Slots, Capability, Style } from 'foldkit-mixins'
392
463
  import { Theme } from 'foldkit-mixins/theme'
393
464
 
394
465
  const L = Layers.standard
395
- const theme = Theme.compose(Theme.tokens, Theme.oklch({ accent: { h: 280, c: 0.15, l: '60%' } }))
466
+ const theme = Theme.standard(Theme.make({ accent: { hue: 280, chroma: 0.15, lightness: 60 } }))
396
467
  const t = Theme.ref(theme) // t.surface.base is 'var(--fk-surface-base)'; a missing name is a type error
397
468
 
398
469
  const PageSlots = Slots.define({ root: Slot.make({ capability: Capability.Container }) })
@@ -404,9 +475,7 @@ const PageStyle = Style.forSlots(PageSlots)(
404
475
 
405
476
  export const sheet = Style.stylesheet(
406
477
  L.declare,
407
- L.in('tokens', Theme.root(Theme.tokens)),
408
- L.in('theme', Theme.root(theme, { omit: Theme.tokens })),
409
- L.in('theme', Theme.scoped(theme, ':root[data-theme="ocean"]', { knob: { 'accent-h': '215' } })),
478
+ L.in('theme', Theme.root(theme)),
410
479
  PageStyle,
411
480
  )
412
481
  ```
@@ -418,10 +487,9 @@ option; a layout or recipe it composes keeps the layer it was already given. `L.
418
487
  bare pieces: a layer is part of a rule's identity, so layering a finished style would copy it
419
488
  under new class names that no view attaches.
420
489
 
421
- `omit` leaves out the tokens another theme already declared, so the scales go out once in
422
- `tokens` and the palette once in `theme`. Which theme is active is a Model fact: the view writes
423
- `data-theme` on the root, and `Theme.scoped` only says what the value means. A scheme the browser
424
- picks needs nothing, because the `light-dark()` values follow it. A scheme the user picks is a
490
+ `Theme.root` declares every token once, at `:root`; its `omit` leaves out tokens a rule of
491
+ another layer already declared. Which theme is active is a Model fact: `Themes.make` below names
492
+ them. A scheme the browser picks needs nothing, because the `light-dark()` values follow it. A scheme the user picks is a
425
493
  `color-scheme` override on the root, which must be in place before the first paint or a reader
426
494
  who chose dark sees one light frame: `Theme.schemeScript(key?)` is the text of a head `<script>`
427
495
  that applies the one kept in `localStorage`, `Theme.chooseScheme(scheme, key?)` (`'light'`,
@@ -518,9 +586,9 @@ import { AppStyle } from 'foldkit-mixins/app'
518
586
  import { Theme } from 'foldkit-mixins/theme'
519
587
  import { Utilities as U } from 'foldkit-mixins/utilities'
520
588
 
521
- // The theme over Theme.tokens, its references, the app layer and the page sheet.
589
+ // The theme's tokens, their references, the app layer and the page sheet.
522
590
  const { t, slots, forSlots, stylesheet } = AppStyle.make({
523
- palette: Theme.oklch({ accent: { h: 260, c: 0.21, l: '62%' } }),
591
+ theme: Theme.make({ accent: { hue: 260, chroma: 0.21, lightness: 62 } }),
524
592
  colorScheme: 'light',
525
593
  })
526
594
 
@@ -564,7 +632,7 @@ What each call does, and does not do:
564
632
  `Utilities` are one-idea pieces whose steps are the shipped scales' token names, so an invalid
565
633
  step is a type error and the value still follows the `density` knob and theme overrides:
566
634
  `p`, `px`, `py`, `m`, `mx`, `my`, `gap` (a `space` step or `'0'`; margins also `'auto'`), `text`
567
- (`size`), `font` (`weight`), `leading`, `rounded` (`radius`), `color` and `bg` (a `Theme.oklch`
635
+ (`size`), `font` (`weight`), `leading`, `rounded` (`radius`), `color` and `bg` (a palette
568
636
  color as `'group.name'`), `items` and `justify` (`'between'` is `space-between`), and the
569
637
  constants `flex`, `column`, `grid`, `block`, `hidden`, `wFull`, `textCenter`, `uppercase`,
570
638
  `truncate`, `pointer` and `selectNone`, and `scrollFade(axis)`, a scroller's content dissolving
@@ -577,7 +645,7 @@ label at a heavier weight, read from the element's `data-label`, so turning bold
577
645
  beside it. Each is a `Style.self` rule, unlayered, so it takes the
578
646
  layer of the style it is composed into, and a plain declaration after it wins per property. A
579
647
  value off the scale is a plain declaration (`{ fontSize: '3.75rem' }`); a color outside
580
- `Theme.oklch`'s groups is read through `t`.
648
+ the palette's groups is read through `t`.
581
649
 
582
650
  ## Behavior: reusable element-level interaction
583
651
 
package/dist/app.d.mts CHANGED
@@ -1,13 +1,15 @@
1
1
  import { i as StyleValue } from "./styleValue-DEsUAC4v.mjs";
2
2
  import { standard } from "./layers.mjs";
3
- import { a as NamedStyle, l as StyleOptions, n as Declared, r as DeclaredPieces, u as StylePieces } from "./style-moq41T8O.mjs";
3
+ import { a as NamedStyle, l as StyleOptions, n as Declared, r as DeclaredPieces, u as StylePieces } from "./style-Cs-aMa_a.mjs";
4
4
  import { a as compose, r as ThemeTokens, t as Refs } from "./core-Cq9PThXv.mjs";
5
- import { n as RootOptions } from "./root-DCb6aqif.mjs";
6
- import { r as Tokens } from "./tokens-DOTnlgyA.mjs";
5
+ import { c as RootOptions, h as Standard, n as Themes, p as KnobTheme, t as StandardTokens } from "./themes-DKzh-mwX.mjs";
7
6
  //#region src/app.d.ts
8
- export interface AppStyleOptions<Palette extends ThemeTokens> {
9
- /** The application's own tokens, usually `Theme.oklch(…)`, laid over `Theme.tokens`. */
10
- readonly palette: Palette;
7
+ interface Common<Own extends ThemeTokens> {
8
+ /**
9
+ * Tokens of the application's own, laid over the shipped ones:
10
+ * `Theme.define({ game: { … } })`, read through `t` beside them.
11
+ */
12
+ readonly tokens?: Own;
11
13
  /** The page's `color-scheme`; `'light'` keeps a light page light in a dark browser. Default `'light dark'`. */
12
14
  readonly colorScheme?: NonNullable<RootOptions['colorScheme']>;
13
15
  /**
@@ -16,31 +18,45 @@ export interface AppStyleOptions<Palette extends ThemeTokens> {
16
18
  */
17
19
  readonly global?: ReadonlyArray<StyleValue>;
18
20
  }
21
+ export interface AppStyleOptions<Own extends ThemeTokens> extends Common<Own> {
22
+ /** The application's one theme: `Theme.make({ … })`. */
23
+ readonly theme: KnobTheme<Standard>;
24
+ }
25
+ /**
26
+ * The options with a set of named themes in place of one: the root declares
27
+ * the initial theme, and each other is drawn where the Model names it
28
+ * (`Themes.apply`).
29
+ */
30
+ export interface AppStyleThemesOptions<Name extends string, Own extends ThemeTokens> extends Common<Own> {
31
+ readonly themes: Themes<Name>;
32
+ }
19
33
  /** A style's options with its layer fixed to the application's. */
20
34
  export type AppStyleOptionsFor = Omit<StyleOptions, 'layer'>;
21
- export interface AppStyle<Palette extends ThemeTokens> {
22
- /** `Theme.tokens` with the palette over it. */
23
- readonly theme: ReturnType<typeof compose<Tokens, Palette>>;
35
+ export interface AppStyle<Own extends ThemeTokens> {
36
+ /** Every shipped token with the theme's knobs, and the application's own over them. */
37
+ readonly theme: ReturnType<typeof compose<StandardTokens, Own>>;
24
38
  /** Every token of `theme` as a typed `var(--fk-…)` reference. */
25
- readonly t: Refs<ReturnType<typeof compose<Tokens, Palette>>>;
39
+ readonly t: Refs<ReturnType<typeof compose<StandardTokens, Own>>>;
26
40
  /** The layer order the stylesheet declares, for placing a layout or recipe (`L.in('layouts', …)`). */
27
41
  readonly L: typeof standard;
28
42
  /** `Style.slots` in the `app` layer: the application's own Slots, declared by their style. */
29
43
  readonly slots: <S>(pieces: DeclaredPieces<S>, options?: AppStyleOptionsFor) => Declared<S>;
30
44
  /** `Style.forSlots` in the `app` layer: a published contract (`ButtonSlots`) styled for this application. */
31
45
  readonly forSlots: <Slots>(contract: Slots) => (pieces: StylePieces<Slots>, options?: AppStyleOptionsFor) => NamedStyle<Slots>;
32
- /** The page sheet: the layer order, reset, tokens, palette, `Defaults.body` and `global`. */
46
+ /** The page sheet: the layer order, reset, tokens, `Defaults.body` and `global`. */
33
47
  readonly stylesheet: string;
34
48
  }
35
49
  /**
36
- * The application's theme, layer and page stylesheet:
37
- * `const { t, slots, stylesheet } = AppStyle.make({ palette: Theme.oklch({ … }) })`.
50
+ * The application's tokens, layer and page stylesheet:
51
+ * `const { t, slots, stylesheet } = AppStyle.make({ theme: Theme.make({ … }) })`.
38
52
  * Slot styles are no longer in the stylesheet: a Slot injects its classes' CSS
39
53
  * when it first draws them.
40
54
  */
41
- export declare const make: <Palette extends ThemeTokens>(options: AppStyleOptions<Palette>) => AppStyle<Palette>;
55
+ export declare function make<Name extends string, Own extends ThemeTokens = Record<never, never>>(options: AppStyleThemesOptions<Name, Own>): AppStyle<Own>;
56
+ export declare function make<Own extends ThemeTokens = Record<never, never>>(options: AppStyleOptions<Own>): AppStyle<Own>;
42
57
  export declare const AppStyle: {
43
58
  readonly make: typeof make;
44
59
  };
45
60
  //#endregion
61
+ export {};
46
62
  //# sourceMappingURL=app.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"app.d.mts","names":["composeThemes"],"sources":["../src/app.ts"],"mappings":";;;;;;;iBAwBiB,gBAAgB,gBAAgB;;WAEtC,SAAS;;WAET,cAAc,YAAY;;;;;WAK1B,SAAS,cAAc;;;YAItB,qBAAqB,KAAK;iBAErB,SAAS,gBAAgB;;WAE/B,OAAO,kBAAkBA,QAAc,QAAQ;;WAE/C,GAAG,KAAK,kBAAkBA,QAAc,QAAQ;;WAEhD,UAAU;;WAEV,QAAQ,GAAG,QAAQ,eAAe,IAAI,UAAU,uBAAuB,SAAS;;WAEhF,WAAW,OAClB,UAAU,WACN,QAAQ,YAAY,QAAQ,UAAU,uBAAuB,WAAW;;WAErE;;;;;;;;qBAWE,OAAQ,gBAAgB,aAAW,SACrC,gBAAgB,aACxB,SAAS;qBAuBC;wBAAA"}
1
+ {"version":3,"file":"app.d.mts","names":["composeThemes"],"sources":["../src/app.ts"],"mappings":";;;;;;UAyBU,OAAO,YAAY;;;;;WAKlB,SAAS;;WAET,cAAc,YAAY;;;;;WAK1B,SAAS,cAAc;;iBAGjB,gBAAgB,YAAY,qBAAqB,OAAO;;WAE9D,OAAO,UAAU;;;;;;;iBAQX,sBACf,qBACA,YAAY,qBACJ,OAAO;WACN,QAAQ,OAAO;;;YAId,qBAAqB,KAAK;iBAErB,SAAS,YAAY;;WAE3B,OAAO,kBAAkBA,QAAc,gBAAgB;;WAEvD,GAAG,KAAK,kBAAkBA,QAAc,gBAAgB;;WAExD,UAAU;;WAEV,QAAQ,GAAG,QAAQ,eAAe,IAAI,UAAU,uBAAuB,SAAS;;WAEhF,WAAW,OAClB,UAAU,WACN,QAAQ,YAAY,QAAQ,UAAU,uBAAuB,WAAW;;WAErE;;;;;;;;wBAWK,KAAK,qBAAqB,YAAY,cAAc,sBAClE,SAAS,sBAAsB,MAAM,OACpC,SAAS;wBACI,KAAK,YAAY,cAAc,sBAC7C,SAAS,gBAAgB,OACxB,SAAS;qBA2BC;wBAAA"}
package/dist/app.mjs CHANGED
@@ -1,27 +1,21 @@
1
- import { i as stylesheet, n as forSlots, r as slots } from "./style-BhOFChc5.mjs";
1
+ import { i as stylesheet, n as forSlots, r as slots } from "./style-COMT0F2e.mjs";
2
2
  import { i as compose } from "./styleValue-6hpAYYfg.mjs";
3
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 { l as tokens } from "./tokens-BOFcnIJM.mjs";
4
+ import { o as ref, r as compose$1 } from "./core-BrR6UPbk.mjs";
5
+ import { o as standardOf, t as root } from "./root-D_gJPXBw.mjs";
7
6
  import { body, reset } from "./defaults.mjs";
8
7
  //#region src/app.ts
9
8
  /**
10
9
  * `foldkit-mixins/app`: an application's style setup, fixed once. Every
11
- * application on the standard layers writes the same preamble: a theme over
12
- * `Theme.tokens`, its references, the `app` layer passed to each style, and a
13
- * page stylesheet of the layer order, the reset, the tokens, the palette and
14
- * the body defaults. `AppStyle.make` is that preamble as a value.
10
+ * application on the standard layers writes the same preamble: its theme's
11
+ * tokens, their references, the `app` layer passed to each style, and a page
12
+ * stylesheet of the layer order, the reset, the tokens and the body defaults.
13
+ * `AppStyle.make` is that preamble as a value.
15
14
  */
16
15
  const app = standard.layer("app");
17
- /**
18
- * The application's theme, layer and page stylesheet:
19
- * `const { t, slots, stylesheet } = AppStyle.make({ palette: Theme.oklch({ … }) })`.
20
- * Slot styles are no longer in the stylesheet: a Slot injects its classes' CSS
21
- * when it first draws them.
22
- */
23
- const make = (options) => {
24
- const theme = compose$1(tokens, options.palette);
16
+ function make(options) {
17
+ const shipped = "themes" in options ? options.themes.root : standardOf(options.theme);
18
+ const theme = compose$1(shipped, options.tokens ?? {});
25
19
  const scheme = options.colorScheme === void 0 ? {} : { colorScheme: options.colorScheme };
26
20
  return Object.freeze({
27
21
  theme,
@@ -35,9 +29,9 @@ const make = (options) => {
35
29
  ...styleOptions,
36
30
  layer: app
37
31
  }),
38
- stylesheet: stylesheet(standard.declare, standard.in("reset", reset), standard.in("tokens", root(tokens, scheme)), standard.in("theme", root(options.palette, scheme)), standard.in("defaults", compose(body, ...options.global ?? [])))
32
+ stylesheet: stylesheet(standard.declare, standard.in("reset", reset), standard.in("theme", root(theme, scheme)), ..."themes" in options ? [standard.in("theme", options.themes.scoped)] : [], standard.in("defaults", compose(body, ...options.global ?? [])))
39
33
  });
40
- };
34
+ }
41
35
  const AppStyle = { make };
42
36
  //#endregion
43
37
  export { AppStyle, make };
package/dist/app.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"app.mjs","names":["composeThemes"],"sources":["../src/app.ts"],"sourcesContent":["/**\n * `foldkit-mixins/app`: an application's style setup, fixed once. Every\n * application on the standard layers writes the same preamble: a theme over\n * `Theme.tokens`, its references, the `app` layer passed to each style, and a\n * page stylesheet of the layer order, the reset, the tokens, the palette and\n * the body defaults. `AppStyle.make` is that preamble as a value.\n */\nimport { body, reset } from './defaults.js'\nimport { standard } from './layers.js'\nimport {\n forSlots,\n slots,\n stylesheet,\n type Declared,\n type DeclaredPieces,\n type NamedStyle,\n type StyleOptions,\n type StylePieces,\n} from './style.js'\nimport { compose, type StyleValue } from './styleValue.js'\nimport { compose as composeThemes, ref, type Refs, type ThemeTokens } from './theme/core.js'\nimport { root, type RootOptions } from './theme/root.js'\nimport { tokens, type Tokens } from './theme/tokens.js'\n\nexport interface AppStyleOptions<Palette extends ThemeTokens> {\n /** The application's own tokens, usually `Theme.oklch(…)`, laid over `Theme.tokens`. */\n readonly palette: Palette\n /** The page's `color-scheme`; `'light'` keeps a light page light in a dark browser. Default `'light dark'`. */\n readonly colorScheme?: NonNullable<RootOptions['colorScheme']>\n /**\n * More page-wide pieces after `Defaults.body`, such as `Defaults.headings`,\n * keyframes or a font face, placed in the `defaults` layer.\n */\n readonly global?: ReadonlyArray<StyleValue>\n}\n\n/** A style's options with its layer fixed to the application's. */\nexport type AppStyleOptionsFor = Omit<StyleOptions, 'layer'>\n\nexport interface AppStyle<Palette extends ThemeTokens> {\n /** `Theme.tokens` with the palette over it. */\n readonly theme: ReturnType<typeof composeThemes<Tokens, Palette>>\n /** Every token of `theme` as a typed `var(--fk-…)` reference. */\n readonly t: Refs<ReturnType<typeof composeThemes<Tokens, Palette>>>\n /** The layer order the stylesheet declares, for placing a layout or recipe (`L.in('layouts', …)`). */\n readonly L: typeof standard\n /** `Style.slots` in the `app` layer: the application's own Slots, declared by their style. */\n readonly slots: <S>(pieces: DeclaredPieces<S>, options?: AppStyleOptionsFor) => Declared<S>\n /** `Style.forSlots` in the `app` layer: a published contract (`ButtonSlots`) styled for this application. */\n readonly forSlots: <Slots>(\n contract: Slots,\n ) => (pieces: StylePieces<Slots>, options?: AppStyleOptionsFor) => NamedStyle<Slots>\n /** The page sheet: the layer order, reset, tokens, palette, `Defaults.body` and `global`. */\n readonly stylesheet: string\n}\n\nconst app = standard.layer('app')\n\n/**\n * The application's theme, layer and page stylesheet:\n * `const { t, slots, stylesheet } = AppStyle.make({ palette: Theme.oklch({ … }) })`.\n * Slot styles are no longer in the stylesheet: a Slot injects its classes' CSS\n * when it first draws them.\n */\nexport const make = <Palette extends ThemeTokens>(\n options: AppStyleOptions<Palette>,\n): AppStyle<Palette> => {\n const theme = composeThemes(tokens, options.palette)\n const scheme = options.colorScheme === undefined ? {} : { colorScheme: options.colorScheme }\n return Object.freeze({\n theme,\n t: ref(theme),\n L: standard,\n slots: <S>(pieces: DeclaredPieces<S>, styleOptions?: AppStyleOptionsFor) =>\n slots(pieces, { ...styleOptions, layer: app }),\n forSlots:\n <Slots>(contract: Slots) =>\n (pieces: StylePieces<Slots>, styleOptions?: AppStyleOptionsFor) =>\n forSlots(contract)(pieces, { ...styleOptions, layer: app }),\n stylesheet: stylesheet(\n standard.declare,\n standard.in('reset', reset),\n standard.in('tokens', root(tokens, scheme)),\n standard.in('theme', root(options.palette, scheme)),\n standard.in('defaults', compose(body, ...(options.global ?? []))),\n ),\n })\n}\n\nexport const AppStyle = { make } as const\n"],"mappings":";;;;;;;;;;;;;;;AAwDA,MAAM,MAAM,SAAS,MAAM,KAAK;;;;;;;AAQhC,MAAa,QACX,YACsB;CACtB,MAAM,QAAQA,UAAc,QAAQ,QAAQ,OAAO;CACnD,MAAM,SAAS,QAAQ,gBAAgB,KAAA,IAAY,CAAC,IAAI,EAAE,aAAa,QAAQ,YAAY;CAC3F,OAAO,OAAO,OAAO;EACnB;EACA,GAAG,IAAI,KAAK;EACZ,GAAG;EACH,QAAW,QAA2B,iBACpC,MAAM,QAAQ;GAAE,GAAG;GAAc,OAAO;EAAI,CAAC;EAC/C,WACU,cACP,QAA4B,iBAC3B,SAAS,QAAQ,CAAC,CAAC,QAAQ;GAAE,GAAG;GAAc,OAAO;EAAI,CAAC;EAC9D,YAAY,WACV,SAAS,SACT,SAAS,GAAG,SAAS,KAAK,GAC1B,SAAS,GAAG,UAAU,KAAK,QAAQ,MAAM,CAAC,GAC1C,SAAS,GAAG,SAAS,KAAK,QAAQ,SAAS,MAAM,CAAC,GAClD,SAAS,GAAG,YAAY,QAAQ,MAAM,GAAI,QAAQ,UAAU,CAAC,CAAE,CAAC,CAClE;CACF,CAAC;AACH;AAEA,MAAa,WAAW,EAAE,KAAK"}
1
+ {"version":3,"file":"app.mjs","names":["composeThemes"],"sources":["../src/app.ts"],"sourcesContent":["/**\n * `foldkit-mixins/app`: an application's style setup, fixed once. Every\n * application on the standard layers writes the same preamble: its theme's\n * tokens, their references, the `app` layer passed to each style, and a page\n * stylesheet of the layer order, the reset, the tokens and the body defaults.\n * `AppStyle.make` is that preamble as a value.\n */\nimport { body, reset } from './defaults.js'\nimport { standard } from './layers.js'\nimport {\n forSlots,\n slots,\n stylesheet,\n type Declared,\n type DeclaredPieces,\n type NamedStyle,\n type StyleOptions,\n type StylePieces,\n} from './style.js'\nimport { compose, type StyleValue } from './styleValue.js'\nimport { compose as composeThemes, ref, type Refs, type ThemeTokens } from './theme/core.js'\nimport type { KnobTheme, Standard } from './theme/knobs.js'\nimport { root, type RootOptions } from './theme/root.js'\nimport { standardOf, type StandardTokens, type Themes } from './theme/themes.js'\n\ninterface Common<Own extends ThemeTokens> {\n /**\n * Tokens of the application's own, laid over the shipped ones:\n * `Theme.define({ game: { … } })`, read through `t` beside them.\n */\n readonly tokens?: Own\n /** The page's `color-scheme`; `'light'` keeps a light page light in a dark browser. Default `'light dark'`. */\n readonly colorScheme?: NonNullable<RootOptions['colorScheme']>\n /**\n * More page-wide pieces after `Defaults.body`, such as `Defaults.headings`,\n * keyframes or a font face, placed in the `defaults` layer.\n */\n readonly global?: ReadonlyArray<StyleValue>\n}\n\nexport interface AppStyleOptions<Own extends ThemeTokens> extends Common<Own> {\n /** The application's one theme: `Theme.make({ … })`. */\n readonly theme: KnobTheme<Standard>\n}\n\n/**\n * The options with a set of named themes in place of one: the root declares\n * the initial theme, and each other is drawn where the Model names it\n * (`Themes.apply`).\n */\nexport interface AppStyleThemesOptions<\n Name extends string,\n Own extends ThemeTokens,\n> extends Common<Own> {\n readonly themes: Themes<Name>\n}\n\n/** A style's options with its layer fixed to the application's. */\nexport type AppStyleOptionsFor = Omit<StyleOptions, 'layer'>\n\nexport interface AppStyle<Own extends ThemeTokens> {\n /** Every shipped token with the theme's knobs, and the application's own over them. */\n readonly theme: ReturnType<typeof composeThemes<StandardTokens, Own>>\n /** Every token of `theme` as a typed `var(--fk-…)` reference. */\n readonly t: Refs<ReturnType<typeof composeThemes<StandardTokens, Own>>>\n /** The layer order the stylesheet declares, for placing a layout or recipe (`L.in('layouts', …)`). */\n readonly L: typeof standard\n /** `Style.slots` in the `app` layer: the application's own Slots, declared by their style. */\n readonly slots: <S>(pieces: DeclaredPieces<S>, options?: AppStyleOptionsFor) => Declared<S>\n /** `Style.forSlots` in the `app` layer: a published contract (`ButtonSlots`) styled for this application. */\n readonly forSlots: <Slots>(\n contract: Slots,\n ) => (pieces: StylePieces<Slots>, options?: AppStyleOptionsFor) => NamedStyle<Slots>\n /** The page sheet: the layer order, reset, tokens, `Defaults.body` and `global`. */\n readonly stylesheet: string\n}\n\nconst app = standard.layer('app')\n\n/**\n * The application's tokens, layer and page stylesheet:\n * `const { t, slots, stylesheet } = AppStyle.make({ theme: Theme.make({ … }) })`.\n * Slot styles are no longer in the stylesheet: a Slot injects its classes' CSS\n * when it first draws them.\n */\nexport function make<Name extends string, Own extends ThemeTokens = Record<never, never>>(\n options: AppStyleThemesOptions<Name, Own>,\n): AppStyle<Own>\nexport function make<Own extends ThemeTokens = Record<never, never>>(\n options: AppStyleOptions<Own>,\n): AppStyle<Own>\nexport function make(\n options: AppStyleOptions<ThemeTokens> | AppStyleThemesOptions<string, ThemeTokens>,\n): AppStyle<ThemeTokens> {\n const shipped = 'themes' in options ? options.themes.root : standardOf(options.theme)\n const theme = composeThemes(shipped, options.tokens ?? {})\n const scheme = options.colorScheme === undefined ? {} : { colorScheme: options.colorScheme }\n return Object.freeze({\n theme,\n t: ref(theme),\n L: standard,\n slots: <S>(pieces: DeclaredPieces<S>, styleOptions?: AppStyleOptionsFor) =>\n slots(pieces, { ...styleOptions, layer: app }),\n forSlots:\n <Slots>(contract: Slots) =>\n (pieces: StylePieces<Slots>, styleOptions?: AppStyleOptionsFor) =>\n forSlots(contract)(pieces, { ...styleOptions, layer: app }),\n stylesheet: stylesheet(\n standard.declare,\n standard.in('reset', reset),\n standard.in('theme', root(theme, scheme)),\n ...('themes' in options ? [standard.in('theme', options.themes.scoped)] : []),\n standard.in('defaults', compose(body, ...(options.global ?? []))),\n ),\n })\n}\n\nexport const AppStyle = { make } as const\n"],"mappings":";;;;;;;;;;;;;;AA6EA,MAAM,MAAM,SAAS,MAAM,KAAK;AAchC,SAAgB,KACd,SACuB;CACvB,MAAM,UAAU,YAAY,UAAU,QAAQ,OAAO,OAAO,WAAW,QAAQ,KAAK;CACpF,MAAM,QAAQA,UAAc,SAAS,QAAQ,UAAU,CAAC,CAAC;CACzD,MAAM,SAAS,QAAQ,gBAAgB,KAAA,IAAY,CAAC,IAAI,EAAE,aAAa,QAAQ,YAAY;CAC3F,OAAO,OAAO,OAAO;EACnB;EACA,GAAG,IAAI,KAAK;EACZ,GAAG;EACH,QAAW,QAA2B,iBACpC,MAAM,QAAQ;GAAE,GAAG;GAAc,OAAO;EAAI,CAAC;EAC/C,WACU,cACP,QAA4B,iBAC3B,SAAS,QAAQ,CAAC,CAAC,QAAQ;GAAE,GAAG;GAAc,OAAO;EAAI,CAAC;EAC9D,YAAY,WACV,SAAS,SACT,SAAS,GAAG,SAAS,KAAK,GAC1B,SAAS,GAAG,SAAS,KAAK,OAAO,MAAM,CAAC,GACxC,GAAI,YAAY,UAAU,CAAC,SAAS,GAAG,SAAS,QAAQ,OAAO,MAAM,CAAC,IAAI,CAAC,GAC3E,SAAS,GAAG,YAAY,QAAQ,MAAM,GAAI,QAAQ,UAAU,CAAC,CAAE,CAAC,CAClE;CACF,CAAC;AACH;AAEA,MAAa,WAAW,EAAE,KAAK"}
@@ -1,4 +1,8 @@
1
1
  import { u as inline } from "./styleValue-6hpAYYfg.mjs";
2
+ //#region src/pipe.ts
3
+ /** Ported from `effect-atom-jsx/src/View.ts` `pipeSelf`. */
4
+ const pipeSelf = (self, fns) => fns.reduce((acc, fn) => fn(acc), self);
5
+ //#endregion
2
6
  //#region src/theme/core.ts
3
7
  /**
4
8
  * `Theme` is typed token data, not a service. Dynamic theme state (light/dark)
@@ -48,6 +52,6 @@ const Theme = {
48
52
  compose
49
53
  };
50
54
  //#endregion
51
- export { lightDark as a, define as i, VAR_PREFIX as n, ref as o, compose as r, variables as s, Theme as t };
55
+ export { lightDark as a, pipeSelf as c, define as i, VAR_PREFIX as n, ref as o, compose as r, variables as s, Theme as t };
52
56
 
53
- //# sourceMappingURL=core-By7s5txd.mjs.map
57
+ //# sourceMappingURL=core-BrR6UPbk.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core-BrR6UPbk.mjs","names":[],"sources":["../src/pipe.ts","../src/theme/core.ts"],"sourcesContent":["/** Ported from `effect-atom-jsx/src/View.ts` `pipeSelf`. */\nexport const pipeSelf = (self: unknown, fns: ReadonlyArray<(value: any) => any>): unknown =>\n fns.reduce((acc, fn) => fn(acc), self)\n\nexport type Pipeable<Self> = {\n pipe(): Self\n pipe(...fns: ReadonlyArray<(self: Self) => Self>): Self\n pipe<A>(ab: (self: Self) => A): A\n pipe<A, B>(ab: (self: Self) => A, bc: (a: A) => B): B\n pipe<A, B, C>(ab: (self: Self) => A, bc: (a: A) => B, cd: (b: B) => C): C\n}\n","/**\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":";;;AACA,MAAa,YAAY,MAAe,QACtC,IAAI,QAAQ,KAAK,OAAO,GAAG,GAAG,GAAG,IAAI;;;;;;;;ACWvC,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"}
package/dist/index.d.mts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { t as SlotItem } from "./slotItem-D6_m6IqP.mjs";
2
2
  import { C as StyleRule, i as StyleValue, n as Piece, r as StyleCondition, t as Declarations } from "./styleValue-DEsUAC4v.mjs";
3
3
  import { Layers, Placement } from "./layers.mjs";
4
- import { $ as metadataToken_d_exports, A as requirement_d_exports, B as Contribution, C as RequirementName, D as UnnamedSlot, E as SlotProtection, F as AnyMixin, G as StaticContribution, H as DynamicContribution, I as Mixin, J as Capability, K as StaticContributionMap, L as MixinFor, M as event_d_exports, N as AttrToken, O as slot_d_exports, P as attr_d_exports, Q as capability_d_exports, R as StaticMixin, T as SlotCapability, U as InputContribution, V as ContributionContext, W as SlotContribution, Z as Satisfies, _ as Any$1, a as SlotViewRender, b as EventName, c as slotView_d_exports, d as resolver_d_exports, f as BehaviorSlotOptions, g as behavior_d_exports, h as SlotRequirements, i as SlotView, j as EventToken, k as RequirementToken, l as ResolveOptions, m as NamedBehavior, n as SlotBuilder, o as SlotViewTransform, p as BehaviorSpec, q as Any, r as SlotBuilders, s as SlotViewTransformFor, t as MessageSlotView, u as SlotAttributes, x as HiddenOf, y as AttributeName, z as mixin_d_exports } from "./slotView-8_CHU9i7.mjs";
5
- import { a as NamedStyle, c as Style, d as StyleValues, f as StylesheetSource, i as DeclaredSlots, l as StyleOptions, m as slots_d_exports, n as Declared, o as SlotPiece, p as Contract, r as DeclaredPieces, s as SlotRecipe, t as ContainerSlot, u as StylePieces } from "./style-moq41T8O.mjs";
4
+ import { $ as metadataToken_d_exports, A as requirement_d_exports, B as Contribution, C as RequirementName, D as UnnamedSlot, E as SlotProtection, F as AnyMixin, G as StaticContribution, H as DynamicContribution, I as Mixin, J as Capability, K as StaticContributionMap, L as MixinFor, M as event_d_exports, N as AttrToken, O as slot_d_exports, P as attr_d_exports, Q as capability_d_exports, R as StaticMixin, T as SlotCapability, U as InputContribution, V as ContributionContext, W as SlotContribution, Z as Satisfies, _ as Any$1, a as SlotViewRender, b as EventName, c as slotView_d_exports, d as resolver_d_exports, f as BehaviorSlotOptions, g as behavior_d_exports, h as SlotRequirements, i as SlotView, j as EventToken, k as RequirementToken, l as ResolveOptions, m as NamedBehavior, n as SlotBuilder, o as SlotViewTransform, p as BehaviorSpec, q as Any, r as SlotBuilders, s as SlotViewTransformFor, t as MessageSlotView, u as SlotAttributes, x as HiddenOf, y as AttributeName, z as mixin_d_exports } from "./slotView-BfOwXpGw.mjs";
5
+ import { a as NamedStyle, c as Style, d as StyleValues, f as StylesheetSource, i as DeclaredSlots, l as StyleOptions, m as slots_d_exports, n as Declared, o as SlotPiece, p as Contract, r as DeclaredPieces, s as SlotRecipe, t as ContainerSlot, u as StylePieces } from "./style-Cs-aMa_a.mjs";
6
6
  import { n as Theme, r as ThemeTokens, t as Refs } from "./core-Cq9PThXv.mjs";
7
7
  import { Attribute, KeyboardModifiers } from "foldkit/html";
8
8
  declare namespace diagnostics_d_exports {
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-BhOFChc5.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-COMT0F2e.mjs";
3
3
  import { E as diagnostics_exports, T as DiagnosticError } from "./styleValue-6hpAYYfg.mjs";
4
4
  import { t as Layers } from "./layers-DxWvuCJL.mjs";
5
- import { t as Theme } from "./core-By7s5txd.mjs";
5
+ import { t as Theme } from "./core-BrR6UPbk.mjs";
6
6
  import { Option } from "effect";
7
7
  //#region src/a11y.ts
8
8
  /**
@@ -0,0 +1,11 @@
1
+ //#region src/pipe.d.ts
2
+ type Pipeable<Self> = {
3
+ pipe(): Self;
4
+ pipe(...fns: ReadonlyArray<(self: Self) => Self>): Self;
5
+ pipe<A>(ab: (self: Self) => A): A;
6
+ pipe<A, B>(ab: (self: Self) => A, bc: (a: A) => B): B;
7
+ pipe<A, B, C>(ab: (self: Self) => A, bc: (a: A) => B, cd: (b: B) => C): C;
8
+ };
9
+ //#endregion
10
+ export { Pipeable as t };
11
+ //# sourceMappingURL=pipe-DrDyEhoj.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pipe-DrDyEhoj.d.mts","names":[],"sources":["../src/pipe.ts"],"mappings":";KAIY,SAAS;EACnB,QAAQ;EACR,QAAQ,KAAK,eAAe,MAAM,SAAS,QAAQ;EACnD,KAAK,GAAG,KAAK,MAAM,SAAS,IAAI;EAChC,KAAK,GAAG,GAAG,KAAK,MAAM,SAAS,GAAG,KAAK,GAAG,MAAM,IAAI;EACpD,KAAK,GAAG,GAAG,GAAG,KAAK,MAAM,SAAS,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,MAAM,IAAI"}