foldkit-mixins 0.15.0 → 0.17.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 +110 -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-BsyR6nwj.mjs +373 -0
  13. package/dist/root-BsyR6nwj.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 +320 -41
  22. package/dist/theme.d.mts.map +1 -1
  23. package/dist/theme.mjs +115 -212
  24. package/dist/theme.mjs.map +1 -1
  25. package/dist/themes-B9jxH5tK.d.mts +453 -0
  26. package/dist/themes-B9jxH5tK.d.mts.map +1 -0
  27. package/dist/tokens-D6z26O2A.d.mts +600 -0
  28. package/dist/tokens-D6z26O2A.d.mts.map +1 -0
  29. package/dist/tokens-DIIMgir1.mjs +1079 -0
  30. package/dist/tokens-DIIMgir1.mjs.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-BIjkKhiC.d.mts +0 -283
  46. package/dist/tokens-BIjkKhiC.d.mts.map +0 -1
  47. package/dist/tokens-ByWGqQV3.mjs +0 -325
  48. package/dist/tokens-ByWGqQV3.mjs.map +0 -1
package/README.md CHANGED
@@ -276,10 +276,9 @@ 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.knobScript({ key?, selector? })` / `Theme.chooseKnobs(theme, { base, key?, selector? })` | from `foldkit-mixins/theme`: a head script applying kept knob variables before the first paint; a Command's Effect that applies `theme`'s knobs that differ from `base` and keeps them |
280
+ | `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` |
281
+ | `Theme.tokens` / `Theme.breakpointWidths(theme)` | from `foldkit-mixins/theme`: the shipped spacing, type, radius, motion, width, border, shadow and breakpoint scales, `icon` (the masks the components draw their own icons with, Lucide's by default; an application's pack is `foldkit-mixins-ui`'s `Icons.tokens(pack)`, passed as its own tokens), 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
282
  | `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
283
  | `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
284
 
@@ -334,12 +333,79 @@ Beyond `self`, `pseudo`, `media`, `supports`, `container` and `nest`, the rule p
334
333
  scoped to the class (`:is(a, b)` is not split), and a selector that writes `&` places the class
335
334
  itself (`nest('[data-open] &')`).
336
335
 
337
- ### Theme from a few knobs
336
+ ### Themes as typed knobs
338
337
 
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
338
+ `foldkit-mixins/theme` extends the root `Theme` with the pieces a page ships. A theme is a typed
339
+ set of knob values: only what it changes, every other knob at its default.
340
+ `Theme.make` checks each value against its knob (`Knobs.standard`, grouped by concern: `accent`,
341
+ `surface`, `shape`, `type`, `icon`, `motion`, `shadow`, `menu`, `feedback`, `code`, `chart`, `scales`),
342
+ so a misspelt knob or a choice outside its options is a type error and a number out of its range
343
+ throws where the theme is made. A theme is `pipe`able: `Theme.set` changes some knobs, and
344
+ `Theme.describe` gives it a title and a description for a list of themes.
345
+
346
+ ```ts
347
+ const cobalt = Theme.make({
348
+ accent: { hue: 235, chroma: 0.225, lightness: 55 },
349
+ surface: { saturation: 0, contrast: 24 },
350
+ shape: { radius: 1.8, density: 1.1, controls: 'pill' },
351
+ menu: { panel: 'inverted' },
352
+ }).pipe(Theme.describe({ title: 'Cobalt' }))
353
+
354
+ const cobaltDense = cobalt.pipe(Theme.set({ shape: { density: 0.9 } }))
355
+
356
+ const sheet = Style.stylesheet(
357
+ Layers.standard.declare,
358
+ Layers.standard.in('theme', Theme.root(Theme.standard(cobaltDense))),
359
+ )
360
+ ```
361
+
362
+ `Theme.make` writes nothing itself: `Theme.variables(theme)` is the knob variables it declares
363
+ (the values it sets, and each unset knob's default or the expression it follows, such as the
364
+ neutrals following the accent's hue), and `Theme.standard(theme)` is every shipped token with
365
+ them, which `Theme.root` declares: the derivations are the same CSS for every theme, so a theme is
366
+ only its knobs. A knob of an
367
+ application's own is a `Knob` kind (`Knob.number`, `percent`, `length`, `angle`, `choice`,
368
+ `font`, `schemed`), and `Theme.make(knobs, values)` takes a set of them. Every knob is a variable, choices
369
+ too: an option is the CSS its variables hold, so `shadow.relief: 'bevel'` writes the bevelled
370
+ shadow lists and `motion.easing: 'spring'` writes the spring curve, and each switches at runtime
371
+ as a number does.
372
+ Each knob carries a `title`, a `description` and its `default`, so a control can be drawn from
373
+ it; `Knobs.schema(Knobs.standard)` is the Schema of a theme's values (a Model field, a decoded
374
+ URL), `Theme.print(theme)` writes a theme's `Theme.make({ … })` source, only the knobs that differ
375
+ from their defaults, and `Theme.fonts` names the font stacks a `type.body` knob may take. An editor
376
+ reaches a knob by its path, typed by it: `Knobs.paths(knobs)` lists them, `Knobs.at(knobs,
377
+ 'shape.radius')` is the knob, and `Knobs.valueAt` and `Knobs.withValue` read and set one value of a
378
+ theme, checked by its knob; a schemed knob's `light` and `dark` are knobs of their own, each with its
379
+ range. `/create` is drawn this way.
380
+
381
+ Themes are installed by name, the names being a record's keys:
382
+
383
+ ```ts
384
+ const themes = Themes.make({ cobalt, cobaltDense }, { initial: 'cobalt' })
385
+ const { t, stylesheet } = AppStyle.make({ themes })
386
+ const Model = Schema.Struct({ theme: themes.Name })
387
+ ```
388
+
389
+ The root declares the palette's derivations with the initial theme's knobs, and each other theme
390
+ writes only its knobs under `:root[data-theme="name"]`, the same element, where every token
391
+ re-derives from them. Which theme shows is the Model's fact (`themes.Name` decodes the field),
392
+ and `Themes.apply(themes, name)` is the Command's effect that shows it. To keep a reader's choice,
393
+ `Themes.choose(themes, name, key?)` shows it and keeps the name in `localStorage` (the initial
394
+ theme keeps nothing), and `Themes.script(themes, key?)` is the text of a head `<script>` that shows
395
+ the kept one before the first paint, on the attribute `apply` writes: a name no theme has, and
396
+ storage that throws, leave the initial theme. The Model's field still starts at the initial theme
397
+ on a static page, so restore it from the same key (`Mirror.kv`); on a page rendered per request,
398
+ read it from a cookie into the Model instead (see `foldkit-ssr`). A token resolves where it
399
+ is declared, so knobs set below the root change nothing derived from them there:
400
+ `Theme.scope(theme, '.marketing')` declares the derivations again under the selector, which
401
+ `Theme.scoped`'s token overrides do not. `AppStyle.make({ theme })` takes one theme, and its
402
+ `tokens` an application's own groups beside the shipped ones. The design is in
403
+ `docs/theme-knobs.md`.
404
+
405
+ ### What the palette derives
406
+
407
+ `Theme.standard(theme)` holds typed tokens for surfaces, text, outlines, and the accent, secondary,
408
+ tertiary and feedback families, derived from the theme's knobs. Only the `knob` group holds literals; every other value is a CSS
343
409
  expression over other tokens (`oklch(from …)`, `color-mix()`, `light-dark()`), so the browser does
344
410
  the derivation and one knob override recolors everything below it. Each family (`accent`,
345
411
  `secondary`, `tertiary`, `success`, `warning`, `error`, `info`) is one shape: a fill, `default`,
@@ -348,19 +414,27 @@ line in it that stands off the base; and two text colors named for where they go
348
414
  text on that fill (near white on a mid accent), and `ink` is text in the family's color on the
349
415
  base surface, dark enough to read in a light scheme and light enough in a dark one. Colored text
350
416
  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
417
+ panel and a sidebar read as the page's own color, in the accent's hue unless `surface.hue` gives
352
418
  them one of their own (a base color: a warm stone under a blue accent); `bedrock` is the deepest of them in both
353
419
  schemes, and the focus ring, `outline.focus`, is the accent. The `syntax` group colors code by
354
420
  the kinds a tokenizer names (`syntax-keyword` is `--fk-syntax-keyword`, as
355
421
  `foldkit-richtext-code` and its Shiki adapter name them): `keyword`, `function` and `type` in
356
422
  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
423
+ warning and info hues, all at one lightness per scheme and the `code.chroma` knob's chroma, and
358
424
  `operator`, `punctuation` and `comment` in the text's own grey. The `chart` group is a chart's
359
425
  series colors, `chart-1` to `chart-5` as shadcn names them: the dataviz reference palette's first
360
426
  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`
427
+ of hue from the `chart-h` knob at a lightness and chroma set for that hue in each scheme. Seven
428
+ color scales, `red`, `orange`, `yellow`, `green`, `teal`, `blue` and `purple`, are for what no
429
+ role names (a tag's color, an illustration, a status of the application's own): steps `1` (near
430
+ white) to `10` (near black) share one lightness ladder, so `red-6` is as light as `blue-6` and a
431
+ step means the same contrast in every hue, with chroma swelling toward the middle and thinning
432
+ at both ends, where a vivid near-white or near-black falls out of gamut; `wash-1` to `wash-4`
433
+ mix step 6 into `surface.base` at 8, 16, 28 and 44%, so a tinted ground follows the scheme and
434
+ the surface knobs. Each hue is a knob (`red-h`), and `scale-c` scales every step's chroma
435
+ (`--fk-blue-wash-2`, `ref.blue['6']`). The `popup` group is a menu's
436
+ panel (`surface`, `ink`, `blur`) and its lit row (`highlight`, `highlight-ink`): `menu.highlight:
437
+ 'bold'` lights the row in the accent's fill, and `menu.panel` draws the panel `inverted`
364
438
  (the other scheme's surface and text) or `translucent` over a blur, as shadcn's menu options do.
365
439
  Each is a 0-or-1 knob (`popup-bold`, `popup-invert`) blended by `color-mix`, so an override
366
440
  switches it live. The `state` group is what a state lays over the surface under it, a mix of the
@@ -396,7 +470,7 @@ import { Layers, Slot, Slots, Capability, Style } from 'foldkit-mixins'
396
470
  import { Theme } from 'foldkit-mixins/theme'
397
471
 
398
472
  const L = Layers.standard
399
- const theme = Theme.compose(Theme.tokens, Theme.oklch({ accent: { h: 280, c: 0.15, l: '60%' } }))
473
+ const theme = Theme.standard(Theme.make({ accent: { hue: 280, chroma: 0.15, lightness: 60 } }))
400
474
  const t = Theme.ref(theme) // t.surface.base is 'var(--fk-surface-base)'; a missing name is a type error
401
475
 
402
476
  const PageSlots = Slots.define({ root: Slot.make({ capability: Capability.Container }) })
@@ -408,9 +482,7 @@ const PageStyle = Style.forSlots(PageSlots)(
408
482
 
409
483
  export const sheet = Style.stylesheet(
410
484
  L.declare,
411
- L.in('tokens', Theme.root(Theme.tokens)),
412
- L.in('theme', Theme.root(theme, { omit: Theme.tokens })),
413
- L.in('theme', Theme.scoped(theme, ':root[data-theme="ocean"]', { knob: { 'accent-h': '215' } })),
485
+ L.in('theme', Theme.root(theme)),
414
486
  PageStyle,
415
487
  )
416
488
  ```
@@ -422,16 +494,27 @@ option; a layout or recipe it composes keeps the layer it was already given. `L.
422
494
  bare pieces: a layer is part of a rule's identity, so layering a finished style would copy it
423
495
  under new class names that no view attaches.
424
496
 
425
- `omit` leaves out the tokens another theme already declared, so the scales go out once in
426
- `tokens` and the palette once in `theme`. Which theme is active is a Model fact: the view writes
427
- `data-theme` on the root, and `Theme.scoped` only says what the value means. A scheme the browser
428
- picks needs nothing, because the `light-dark()` values follow it. A scheme the user picks is a
497
+ `Theme.root` declares every token once, at `:root`; its `omit` leaves out tokens a rule of
498
+ another layer already declared. Which theme is active is a Model fact: `Themes.make` below names
499
+ them. A scheme the browser picks needs nothing, because the `light-dark()` values follow it. A scheme the user picks is a
429
500
  `color-scheme` override on the root, which must be in place before the first paint or a reader
430
501
  who chose dark sees one light frame: `Theme.schemeScript(key?)` is the text of a head `<script>`
431
502
  that applies the one kept in `localStorage`, `Theme.chooseScheme(scheme, key?)` (`'light'`,
432
503
  `'dark'` or `'system'`) is a Command's Effect that applies and keeps a choice, and
433
504
  `Theme.currentScheme()` reads back what is applied, for the Model once the browser takes the page
434
- over (the docs site does it in its SSR plan's `boot`). The palette
505
+ over (the docs site does it in its SSR plan's `boot`).
506
+
507
+ Knob values a reader set, as on a theme-making page, need the same: `Theme.knobScript({ key?,
508
+ selector? })` is the text of a head `<script>` that applies the knob variables kept in
509
+ `localStorage` to `selector` (`:root` by default), and `Theme.chooseKnobs(theme, { base, key?,
510
+ selector? })` is a Command's Effect that applies `theme`'s and keeps them. Both write one
511
+ unlayered rule in one `<style>` element, so it beats the layered theme, an inline style still
512
+ beats it, and the Command replaces what the script wrote rather than handing over from it. What is
513
+ kept is the variables that differ from `base`, with `KNOBS_FORMAT`: an entry of another format, a
514
+ property that is not a knob, and storage that throws are ignored, and the base theme keeps
515
+ nothing. A token derives where it is declared, so a selector other than `:root` must declare the
516
+ tokens too (`Theme.scope`). On a page rendered per request, put the theme in the Model from a
517
+ cookie instead (see `foldkit-ssr`). The palette
435
518
  needs relative color syntax and `light-dark()` (Chrome 123, Firefox 128, Safari 17.5).
436
519
 
437
520
  `Style.responsive(Theme.tokens.breakpoint, { md: { … } })` and
@@ -522,9 +605,9 @@ import { AppStyle } from 'foldkit-mixins/app'
522
605
  import { Theme } from 'foldkit-mixins/theme'
523
606
  import { Utilities as U } from 'foldkit-mixins/utilities'
524
607
 
525
- // The theme over Theme.tokens, its references, the app layer and the page sheet.
608
+ // The theme's tokens, their references, the app layer and the page sheet.
526
609
  const { t, slots, forSlots, stylesheet } = AppStyle.make({
527
- palette: Theme.oklch({ accent: { h: 260, c: 0.21, l: '62%' } }),
610
+ theme: Theme.make({ accent: { hue: 260, chroma: 0.21, lightness: 62 } }),
528
611
  colorScheme: 'light',
529
612
  })
530
613
 
@@ -568,7 +651,7 @@ What each call does, and does not do:
568
651
  `Utilities` are one-idea pieces whose steps are the shipped scales' token names, so an invalid
569
652
  step is a type error and the value still follows the `density` knob and theme overrides:
570
653
  `p`, `px`, `py`, `m`, `mx`, `my`, `gap` (a `space` step or `'0'`; margins also `'auto'`), `text`
571
- (`size`), `font` (`weight`), `leading`, `rounded` (`radius`), `color` and `bg` (a `Theme.oklch`
654
+ (`size`), `font` (`weight`), `leading`, `rounded` (`radius`), `color` and `bg` (a palette
572
655
  color as `'group.name'`), `items` and `justify` (`'between'` is `space-between`), and the
573
656
  constants `flex`, `column`, `grid`, `block`, `hidden`, `wFull`, `textCenter`, `uppercase`,
574
657
  `truncate`, `pointer` and `selectNone`, and `scrollFade(axis)`, a scroller's content dissolving
@@ -581,7 +664,7 @@ label at a heavier weight, read from the element's `data-label`, so turning bold
581
664
  beside it. Each is a `Style.self` rule, unlayered, so it takes the
582
665
  layer of the style it is composed into, and a plain declaration after it wins per property. A
583
666
  value off the scale is a plain declaration (`{ fontSize: '3.75rem' }`); a color outside
584
- `Theme.oklch`'s groups is read through `t`.
667
+ the palette's groups is read through `t`.
585
668
 
586
669
  ## Behavior: reusable element-level interaction
587
670
 
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-BIjkKhiC.mjs";
5
+ import { d as RootOptions, g as KnobTheme, r as Themes, t as StandardTokens, v as Standard } from "./themes-B9jxH5tK.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 { u as tokens } from "./tokens-ByWGqQV3.mjs";
4
+ import { o as ref, r as compose$1 } from "./core-BrR6UPbk.mjs";
5
+ import { l as standardOf, t as root } from "./root-BsyR6nwj.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"}