foldkit-mixins 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/README.md +228 -13
  2. package/dist/app.d.mts +46 -0
  3. package/dist/app.d.mts.map +1 -0
  4. package/dist/app.mjs +45 -0
  5. package/dist/app.mjs.map +1 -0
  6. package/dist/{core-izIY2GSX.mjs → core-Bxj0UQDF.mjs} +2 -2
  7. package/dist/{core-izIY2GSX.mjs.map → core-Bxj0UQDF.mjs.map} +1 -1
  8. package/dist/{core-B86QnDhB.d.mts → core-CUw_n1Nd.d.mts} +2 -2
  9. package/dist/{core-B86QnDhB.d.mts.map → core-CUw_n1Nd.d.mts.map} +1 -1
  10. package/dist/defaults.d.mts +6 -2
  11. package/dist/defaults.d.mts.map +1 -1
  12. package/dist/defaults.mjs +7 -3
  13. package/dist/defaults.mjs.map +1 -1
  14. package/dist/foundations.d.mts +30 -0
  15. package/dist/foundations.d.mts.map +1 -0
  16. package/dist/foundations.mjs +71 -0
  17. package/dist/foundations.mjs.map +1 -0
  18. package/dist/index.d.mts +11 -566
  19. package/dist/index.d.mts.map +1 -1
  20. package/dist/index.mjs +63 -1076
  21. package/dist/index.mjs.map +1 -1
  22. package/dist/{layers-CJS5d1i7.mjs → layers-B31M0tDi.mjs} +3 -7
  23. package/dist/layers-B31M0tDi.mjs.map +1 -0
  24. package/dist/layers.d.mts +1 -1
  25. package/dist/layers.d.mts.map +1 -1
  26. package/dist/layers.mjs +1 -1
  27. package/dist/layout.d.mts +1 -1
  28. package/dist/layout.mjs +1 -1
  29. package/dist/oklch-BxvCD0oi.d.mts +135 -0
  30. package/dist/oklch-BxvCD0oi.d.mts.map +1 -0
  31. package/dist/prose.d.mts +8 -2
  32. package/dist/prose.d.mts.map +1 -1
  33. package/dist/prose.mjs +11 -7
  34. package/dist/prose.mjs.map +1 -1
  35. package/dist/root-C1u12YMD.mjs +37 -0
  36. package/dist/root-C1u12YMD.mjs.map +1 -0
  37. package/dist/root-xyWS6geK.d.mts +25 -0
  38. package/dist/root-xyWS6geK.d.mts.map +1 -0
  39. package/dist/slotItem-D6_m6IqP.d.mts +18 -0
  40. package/dist/slotItem-D6_m6IqP.d.mts.map +1 -0
  41. package/dist/slotMark-Rdsjb7XI.mjs +135 -0
  42. package/dist/slotMark-Rdsjb7XI.mjs.map +1 -0
  43. package/dist/slotView-BtIF2pHo.d.mts +476 -0
  44. package/dist/slotView-BtIF2pHo.d.mts.map +1 -0
  45. package/dist/style-CKjLee4e.mjs +1266 -0
  46. package/dist/style-CKjLee4e.mjs.map +1 -0
  47. package/dist/style-CtCqaL0l.d.mts +182 -0
  48. package/dist/style-CtCqaL0l.d.mts.map +1 -0
  49. package/dist/{styleValue-C9vAKt7A.d.mts → styleValue-BavTe9MZ.d.mts} +13 -18
  50. package/dist/styleValue-BavTe9MZ.d.mts.map +1 -0
  51. package/dist/{styleValue--iQMTcPn.mjs → styleValue-_G9jwb17.mjs} +84 -78
  52. package/dist/styleValue-_G9jwb17.mjs.map +1 -0
  53. package/dist/testing.d.mts +30 -0
  54. package/dist/testing.d.mts.map +1 -0
  55. package/dist/testing.mjs +167 -0
  56. package/dist/testing.mjs.map +1 -0
  57. package/dist/theme.d.mts +21 -240
  58. package/dist/theme.d.mts.map +1 -1
  59. package/dist/theme.mjs +11 -143
  60. package/dist/theme.mjs.map +1 -1
  61. package/dist/tokens-BR_qxDR7.d.mts +91 -0
  62. package/dist/tokens-BR_qxDR7.d.mts.map +1 -0
  63. package/dist/tokens-DteBJVN-.mjs +117 -0
  64. package/dist/tokens-DteBJVN-.mjs.map +1 -0
  65. package/dist/utilities.d.mts +73 -0
  66. package/dist/utilities.d.mts.map +1 -0
  67. package/dist/utilities.mjs +90 -0
  68. package/dist/utilities.mjs.map +1 -0
  69. package/package.json +30 -3
  70. package/dist/diagnostics-YJ7991-A.mjs +0 -15
  71. package/dist/diagnostics-YJ7991-A.mjs.map +0 -1
  72. package/dist/layers-CJS5d1i7.mjs.map +0 -1
  73. package/dist/styleValue--iQMTcPn.mjs.map +0 -1
  74. package/dist/styleValue-C9vAKt7A.d.mts.map +0 -1
package/README.md CHANGED
@@ -103,7 +103,8 @@ pnpm add foldkit-mixins
103
103
  projection, and `foldkit-mixins-ui` adapts `@foldkit/ui` components.
104
104
 
105
105
  The design-system pieces are subpaths, so an application that only attaches classes pays for
106
- none of them: `foldkit-mixins/layers`, `/theme`, `/layout`, `/defaults`, and `/prose` (see
106
+ none of them: `foldkit-mixins/layers`, `/theme`, `/layout`, `/defaults`, `/prose`, `/utilities`
107
+ and `/app` (see
107
108
  [styleImprovements-DESIGN.md](../../docs/design/styleImprovements-DESIGN.md)).
108
109
 
109
110
  ## Quick start
@@ -178,9 +179,17 @@ the base view. Adding another `OnInput` attachment is a conflict, not a way to
178
179
  chain a second application update. Compose the action in the existing Message
179
180
  handler instead.
180
181
 
181
- For `Style.pseudo`, `Style.media`, or other compiled rules, also install the
182
- text returned by `Style.stylesheet(style)` in the page. Calling a SlotView
183
- returns HTML; it does not inject a stylesheet for you.
182
+ A Style's compiled rules (`Style.pseudo`, `Style.media`, a layer) arrive with
183
+ the Slot that draws them. In a browser, the first time a Slot draws a class,
184
+ its CSS is appended to one `<style data-foldkit-styles>` element, in the
185
+ microtask after the draw and before the browser paints. The element is made
186
+ only when there is something to add, and declares the standard layer order
187
+ first unless a sheet on the page already declares one, which it leaves alone.
188
+ Classes a stylesheet already on the page carries are left out, so
189
+ installing `Style.stylesheet(...)` yourself (for the first paint, or on the
190
+ server) never duplicates them. Outside a browser nothing is injected: a server
191
+ puts `Style.usedIn(html)`, the CSS of every compiled class the page's markup
192
+ uses, in the page's head (with `foldkit-ssr`, through its `head` option).
184
193
 
185
194
  ## What the resolver guarantees
186
195
 
@@ -240,6 +249,15 @@ string. A misspelled or kebab-case property in an object literal is a type
240
249
  error; the compiler writes the kebab-case name. Values are not checked, so
241
250
  `var(...)` and `light-dark(...)` pass through.
242
251
 
252
+ Wherever a slot's piece is taken (`forSlots`, `slots`, `forCapability`, a
253
+ `recipeFor` definition) and in `compose`, `when`, `whenInput` and `perItem`, a
254
+ piece may also be written short: a declarations object means
255
+ `Style.self(declarations)`, a list means `Style.compose(...list)`, and `{}` is
256
+ `Style.empty`. So `[Style.class('card'), { padding: '1rem' }]` is
257
+ `Style.compose(Style.class('card'), Style.self({ padding: '1rem' }))`. A
258
+ `StyleValue` carries a brand, so a declarations object is never mistaken for
259
+ one.
260
+
243
261
  | Primitive | Meaning |
244
262
  | --- | --- |
245
263
  | `Style.class(...)` | class tokens |
@@ -247,10 +265,12 @@ error; the compiler writes the kebab-case name. Values are not checked, so
247
265
  | `Style.compose(...)` | concatenate classes; later declarations win per property |
248
266
  | `Style.when(condition, piece)` | a boolean known at authoring time |
249
267
  | `Style.whenInput(predicate, piece)` | a condition read from the view input at render time |
250
- | `Style.recipe({ base, variants, defaults, compound })` | one slot: returns `selection => StyleValue` |
268
+ | `Style.recipe({ base, variants, defaults, compound })` | one slot: returns `selection => StyleValue`; every field is optional, so a recipe may be only its base |
251
269
  | `Style.recipeFor(Slots)({ base, variants, defaults, compound })` | every slot: returns `selection => StylePieces`; `null` unsets a defaulted axis; `.extend(patch)` merges per slot and refuses a slot the contract lacks |
252
- | `Style.perItem(item => piece)` / `Style.stagger({ stepMs })` | a piece from the item the slot is rendered for (`attrs(base, item)`); stagger writes `--fk-index` and a `calc` delay |
270
+ | `Style.perItem(item => piece)` / `Style.stagger({ stepMs })` | a piece from the item the slot is rendered for (`attrs(base, item)`); stagger writes `--fk-index` inline and the `calc` delay as a rule |
253
271
  | `Style.forCapability(Slots)(capability, piece)` | one piece for every public slot whose capability satisfies it |
272
+ | `Style.slots(pieces, options?)` / `Style.slot(slotOptions, piece)` | an application's own Slots declared by their style: `{ slots, style }` (see [An application's own look](#an-applications-own-look)) |
273
+ | `Style.install(css)` | in a browser, one `<style>` in the head holding `css`, unless one already holds exactly that text; returns the element |
254
274
  | `Style.self` / `pseudo` / `media` / `supports` / `container` / `nest` | rule-based appearance; `self` is a rule on the element's own class (`&{…}`), for declarations a layer must hold |
255
275
  | `Style.keyframes` / `global` | class-independent CSS |
256
276
  | `Theme.define` / `Theme.ref(theme)` / `variables` | typed tokens; every token as a typed `var(--fk-group-name)` reference (`Theme.ref(theme).surface.base`), built once per theme; the tokens as inline custom properties |
@@ -279,21 +299,26 @@ Style.stylesheet(FieldStyle, CardStyle)
279
299
  Equal rules share a class, so server and client derive the same class and CSS. A rule piece
280
300
  inside `Style.whenInput` compiles to its class like any other; the class is static and only its
281
301
  presence follows the input, and its CSS is in `Style.stylesheet` whether or not the condition
282
- ever holds.
302
+ ever holds. Drawn, it is injected like any other class.
283
303
 
284
304
  Beyond `self`, `pseudo`, `media`, `supports`, `container` and `nest`, the rule pieces are:
285
305
 
286
306
  - `Style.states({ open: { opacity: '1' } })` compiles to `&[data-state="open"]`, for Behaviors that
287
307
  write `data-state`; `whenInput` when the view knows, `states` when the DOM does;
288
308
  - `Style.responsive(breakpoints, { md: { display: 'flex' } })`, named breakpoints from the record
289
- you pass, so a misspelled one is a type error;
309
+ you pass, so a misspelled one is a type error; a breakpoint is a media query or a whole at-rule,
310
+ such as `'@container page (min-width: 48rem)'`;
311
+ - `Style.at('@container builder (max-width: 40rem)', Style.pseudo('[data-open="false"]', { … }))`
312
+ puts a piece's rules inside an at-rule, where no one constructor does; a class, a piece chosen
313
+ when drawn, global CSS or a rule already inside an at-rule throws there;
290
314
  - `Style.enter({ opacity: '0' })`, a `@starting-style` rule the element animates from, with
291
315
  `Style.allowDiscrete` when `display` takes part;
292
316
  - `Style.vars({ '--gap': '1rem' })` and `Style.viewTransitionName('hero')`, declarations;
293
317
  - `Style.grid({ areas: [['header', 'header'], ['nav', 'main']], columns, rows, gap })`, a grid
294
318
  template with typed areas: `.style` for the container and `.area('main')` for a child, where
295
319
  a name the template lacks is a type error and a ragged template raises
296
- `mixins:ragged-grid-areas`;
320
+ `mixins:ragged-grid-areas`. Both are rules, not inline declarations, so a later layer can
321
+ override the template;
297
322
  - `Selector.attr`, `not`, `is`, `child`, `descendant`, `sibling`, `siblings` build the selector
298
323
  strings `pseudo` and `nest` take. Each takes a selector list: every top-level selector is
299
324
  scoped to the class (`:is(a, b)` is not split), and a selector that writes `&` places the class
@@ -306,7 +331,11 @@ an accent color and a few knobs (hue shifts, surface saturation and contrast, a
306
331
  feedback hues) and returns typed tokens for surfaces, text, outlines, and the accent, secondary,
307
332
  tertiary and feedback families. Only the `knob` group holds literals; every other value is a CSS
308
333
  expression over other tokens (`oklch(from …)`, `color-mix()`, `light-dark()`), so the browser does
309
- the derivation and one knob override recolors everything below it. `Theme.tokens` is the
334
+ the derivation and one knob override recolors everything below it. Each family (`accent`,
335
+ `secondary`, `tertiary`, `success`, `warning`, `error`, `info`) has a fill, `default`, and two
336
+ text colors named for where they go: `on-fill` is text on that fill (near white on a mid accent),
337
+ and `ink` is text in the family's color on the base surface, dark enough to read in a light scheme
338
+ and light enough in a dark one. Colored text is `ink`, never `default`. `Theme.tokens` is the
310
339
  non-color scales, with `space` and `radius` multiplied by the `density` and `radius-factor` knobs.
311
340
 
312
341
  A theme reaches the page as pieces, and the page chooses the layers:
@@ -352,6 +381,10 @@ needs relative color syntax and `light-dark()` (Chrome 123, Firefox 128, Safari
352
381
  `Style.responsive(Theme.tokens.breakpoint, { md: { … } })` and
353
382
  `Theme.breakpointWidths(Theme.tokens)` (for the `Breakpoints` bundle) name the same breakpoints;
354
383
  a query that is not a plain `min-width` raises `theme:unparseable-breakpoint`.
384
+ `Theme.inContainer('page', Theme.tokens.breakpoint)` is the same breakpoints measured on the
385
+ container named `page` rather than the window: an editor's preview frame, narrow in a wide
386
+ window, then draws a look as a narrow screen would. An element must be that container
387
+ (`containerType: 'inline-size', containerName: 'page'`).
355
388
 
356
389
  ### Layout
357
390
 
@@ -386,10 +419,14 @@ distinct value is its own class. `sidebar` and `switcher` are flex math and need
386
419
  (box model, media, form-control fonts, reduced motion) and `body`, `headings`, `links`, `code`,
387
420
  `controls`, composed as `Defaults.all` (everything except `reset`). Each is element-selector CSS
388
421
  under `:where()` over `--fk-*` tokens with a fallback, so a class rule always beats it and it reads
389
- with or without a theme. `foldkit-mixins/prose` is the longform contract: `Prose.style({ measure?,
390
- rhythm? })` is one class for every caller (the rhythm between unlike elements: heading to
422
+ with or without a theme. Headings are `text-overt` unless a container sets `--fk-heading`: a band
423
+ drawn in its own color writes `Style.vars({ '--fk-heading': 'currentColor' })` and the headings
424
+ inside take its color, with no rule on the heading. `foldkit-mixins-ui`'s unfilled buttons read
425
+ `--fk-ink` the same way. `foldkit-mixins/prose` is the longform contract: `Prose.style({ measure?,
426
+ leading?, rhythm? })` is one class for every caller (the rhythm between unlike elements: heading to
391
427
  paragraph, list to paragraph, around figures) whose options are `--fk-prose-*` variables on the
392
- element. Both are unlayered; the page places them:
428
+ element. Its measure and line height are a rule reading those variables, so a later layer can
429
+ override them. Both are unlayered; the page places them:
393
430
 
394
431
  ```ts
395
432
  import { Layers, Style } from 'foldkit-mixins'
@@ -407,6 +444,80 @@ export const sheet = Style.stylesheet(
407
444
  )
408
445
  ```
409
446
 
447
+ ### An application's own look
448
+
449
+ Everything above serves two kinds of author. A component or design system **publishes** a
450
+ contract (`ButtonSlots`) that others style with `Style.forSlots`. An application mostly styles
451
+ **its own** markup: Slots nobody else attaches to, one theme, one layer, one page sheet. For
452
+ that case the contract, the style and the setup can each be written once:
453
+
454
+ | You are... | Use |
455
+ | --- | --- |
456
+ | styling a contract someone published | `Style.forSlots(ButtonSlots)(pieces, options)` |
457
+ | declaring your own Slots and their look | `Style.slots(pieces, options)` |
458
+ | fixing theme, `app` layer and page sheet for one application | `AppStyle.make` from `foldkit-mixins/app` |
459
+ | writing a token-backed declaration in a word | `Utilities` from `foldkit-mixins/utilities` |
460
+
461
+ ```ts
462
+ import { Event, Style, SlotView } from 'foldkit-mixins'
463
+ import { AppStyle } from 'foldkit-mixins/app'
464
+ import { Theme } from 'foldkit-mixins/theme'
465
+ import { Utilities as U } from 'foldkit-mixins/utilities'
466
+
467
+ // The theme over Theme.tokens, its references, the app layer and the page sheet.
468
+ const { t, slots, forSlots, stylesheet } = AppStyle.make({
469
+ palette: Theme.oklch({ accent: { h: 260, c: 0.21, l: '62%' } }),
470
+ colorScheme: 'light',
471
+ })
472
+
473
+ // Each key is a Container slot with that piece; Style.slot gives a slot options.
474
+ export const Page = slots({
475
+ root: [U.p('lg'), U.bg('surface.base')],
476
+ count: [U.textCenter, U.font('bold'), { fontSize: '3.75rem', color: t.text.default }],
477
+ form: Style.slot({ events: [Event.Submit] }, [U.flex, U.gap('sm')]),
478
+ })
479
+
480
+ export const Counter = SlotView.forMessages<never>()
481
+ .define(Page.slots, (count: number, slots, h) =>
482
+ h.main(slots.root.attrs(), [h.p(slots.count.attrs(), [String(count)])]),
483
+ )
484
+ .pipe(Style.attach(Page.style))
485
+
486
+ // In the browser entry, before the application runs:
487
+ Style.install(stylesheet)
488
+ ```
489
+
490
+ A published contract takes the same layer through the kit's `forSlots`, as
491
+ `forSlots(ButtonSlots)(Recipes.Button())` with `foldkit-mixins-ui`.
492
+
493
+ What each call does, and does not do:
494
+
495
+ - `AppStyle.make` computes, once: `theme` is `Theme.compose(Theme.tokens, palette)`, `t` is
496
+ `Theme.ref(theme)`, `L` is `Layers.standard`, and `stylesheet` is the text of the layer order,
497
+ `Defaults.reset`, the tokens, the palette and `Defaults.body` (plus any `global` pieces, in the
498
+ `defaults` layer). It installs nothing and owns no state; a scheme or theme the user picks is
499
+ still a Model fact (see [Theme from a few knobs](#theme-from-a-few-knobs)).
500
+ - `slots(pieces)` is `Style.slots(pieces, { layer: L.layer('app') })`, and `forSlots` is
501
+ `Style.forSlots` with the same layer: the options take a `name`, never a layer. Both
502
+ compile once, where they are defined.
503
+ - `Style.slots` returns `{ slots, style }`: `slots` is the contract (`Slots.define` of a
504
+ `Container` per key, or the `Style.slot` options, which default to `Container` too and are
505
+ never `hidden`), and `style` the `NamedStyle` a view attaches. A slot with no look takes `{}`.
506
+ The view still decides the markup; the contract only names what it may draw.
507
+ - `Style.install(stylesheet)` is the one call that touches the DOM. The sheet holds no slot
508
+ class: a Slot's CSS is injected when it first draws.
509
+
510
+ `Utilities` are one-idea pieces whose steps are the shipped scales' token names, so an invalid
511
+ step is a type error and the value still follows the `density` knob and theme overrides:
512
+ `p`, `px`, `py`, `m`, `mx`, `my`, `gap` (a `space` step or `'0'`; margins also `'auto'`), `text`
513
+ (`size`), `font` (`weight`), `leading`, `rounded` (`radius`), `color` and `bg` (a `Theme.oklch`
514
+ color as `'group.name'`), `items` and `justify` (`'between'` is `space-between`), and the
515
+ constants `flex`, `column`, `grid`, `block`, `hidden`, `wFull`, `textCenter`, `uppercase`,
516
+ `truncate`, `pointer` and `selectNone`. Each is a `Style.self` rule, unlayered, so it takes the
517
+ layer of the style it is composed into, and a plain declaration after it wins per property. A
518
+ value off the scale is a plain declaration (`{ fontSize: '3.75rem' }`); a color outside
519
+ `Theme.oklch`'s groups is read through `t`.
520
+
410
521
  ## Behavior: reusable element-level interaction
411
522
 
412
523
  A Behavior is a reusable bundle of element-level interaction that does **not** own application
@@ -513,6 +624,72 @@ For per-item groups such as tabs, options or calendar cells, use
513
624
  `SlotView.buildersFor(slots, mixins, { input, h })` and map the items yourself. One contribution
514
625
  then applies to every item while each item's base attributes retain their own event ownership.
515
626
 
627
+ ### Parts: redraw only what changed
628
+
629
+ A SlotView runs whole on every change to its input. A larger view can be cut
630
+ into parts, each declaring the input keys it reads and given only those. A part
631
+ runs again only when one of those values changed by identity; otherwise
632
+ Foldkit reuses its last drawing without diffing it.
633
+
634
+ ```ts
635
+ type Input = { readonly title: string; readonly count: number }
636
+ const Parts = SlotView.parts(PanelSlots)<Input, Message>()
637
+
638
+ const Title = Parts.part('Title', { reads: ['title'] }, (input, slots, h) =>
639
+ h.h2(slots.title.attrs(), [input.title]),
640
+ )
641
+ const Count = Parts.part('Count', { reads: ['count'] }, (input, slots, h) =>
642
+ h.p(slots.count.attrs(), [String(input.count)]),
643
+ )
644
+ const Panel = Parts.assemble((input, slots, h, draw) =>
645
+ h.section(slots.root.attrs(), [draw(Title), draw(Count)]),
646
+ )
647
+ ```
648
+
649
+ `input.count` inside `Title` does not compile, so a part cannot read a value it
650
+ is not redrawn for. `Panel` is an ordinary SlotView: Styles and Behaviors attach
651
+ to it and reach every part's Slots.
652
+
653
+ - **A part's own Behaviors** go in its `behaviors` option, declared over the
654
+ part's selection (`Pick<Input, 'count'>`), and are resolved against it.
655
+ - **A Mixin attached to the whole view that reads the input** (a Behavior's
656
+ `attributes`, `Style.whenInput`) is resolved against the whole input, so the
657
+ parts it reaches are drawn again on every change: correct, not cached. Static
658
+ Styles cost nothing.
659
+ - **Memoizing needs a running application.** Drawn inert (a test, a server's
660
+ first pass), every part is drawn afresh.
661
+
662
+ A Slot drawn once per item can memoize each item, in a part or any SlotView:
663
+
664
+ ```ts
665
+ const drawRow = (
666
+ slots: SlotView.SlotBuilders<typeof ListSlots, Message>,
667
+ h: HtmlBuilder<Message>,
668
+ { index, text }: { readonly index: number; readonly text: string },
669
+ ) => h.li(slots.row.attrs([h.Key(text)], { index, id: text }), [text])
670
+
671
+ const Rows = ListParts.part('Rows', { reads: ['rows'] }, (input, slots, h) =>
672
+ h.ul(
673
+ slots.root.attrs(),
674
+ input.rows.map((text, index) => slots.row.lazy({ index, id: text }, drawRow, { index, text })),
675
+ ),
676
+ )
677
+ ```
678
+
679
+ An item is drawn again only when one of its arguments changed by identity, or
680
+ when a Mixin gave the Slots it used something different for it (a static Style
681
+ by identity, so two views apart only by a Style draw their rows apart). A Behavior
682
+ that works out a roving tab stop from the whole list redraws the row the stop
683
+ left and the row it reached, and no other. `drawRow` reads only its arguments,
684
+ so define it once, not per render. A Mixin that gives an item a handler made per
685
+ render, and an item drawing that holds another, are drawn every time: correct,
686
+ not cached.
687
+ Items are remembered by key for the life of the page, as Foldkit's keyed memo
688
+ is, so key by something bounded (a node id), not by something that keeps
689
+ changing (a search's results). The memo is one per drawing function: two views
690
+ drawing the same key with one `drawRow` share it, and each misses whenever
691
+ what it gives the row differs from the other's. Drawn inert, nothing is kept.
692
+
516
693
  ## With `foldkit-surface`
517
694
 
518
695
  Mixins do not require Surface, but the two fit naturally: Surface says **what a feature may
@@ -587,6 +764,44 @@ Attributes.find(input, 'Class')?.value // 'field-input'
587
764
  Attributes.find(input, 'AriaInvalid')?.value // true
588
765
  ```
589
766
 
767
+ What a whole view draws is read with `Inert` from `foldkit-mixins/testing`: `Inert.all`,
768
+ `children`, `byTag`, `byRole`, `byLabel` (by `aria-label`, a `<label for>`, or the innermost
769
+ element with that text), `text`, `value` (an attribute or a property, whichever the builder
770
+ wrote, so `title` and `value` need no special case), `classes`, `style` and `pressed` (an
771
+ `Option`, none for a button that is not a toggle).
772
+
773
+ ```ts
774
+ import { Inert } from 'foldkit-mixins/testing'
775
+
776
+ const root = Probe({ value: 'Ada', invalid: false }, SlotView.inertBuilder<Message>())
777
+ Inert.value(Inert.byTag(root, 'input')[0], 'value') // 'Ada'
778
+ ```
779
+
780
+ `Inert.draw(view, input)` draws a SlotView with every element a Slot draws marked with the
781
+ Slot's name, however deeply its views nest; a view drawn for real is never marked. It draws
782
+ under a Foldkit Scene's render frame, so a view that embeds a Submodel with `h.submodel`
783
+ (every `@foldkit/ui` component page) draws whole, `childAttributes` included; nothing is
784
+ dispatched, and no Command or Mount it declares runs or is checked. On that tree,
785
+ `Inert.bySlot(root, 'input')` finds a Slot's elements, `Inert.unslotted(root, { inside })` lists
786
+ every element no Slot drew (skipping what a Slot named in `inside` holds, such as a canvas drawing
787
+ the application's page), and `Inert.fixedInline(root, { inside })` every inline declaration that
788
+ is not a custom property. A package view's test expects both lists to be empty.
789
+
790
+ `Inert.css(nodes)` is the compiled CSS behind the nodes' classes, and
791
+ `Inert.missingTokens(root, stylesheet)` lists the `--fk-*` tokens the drawn Styles read with no
792
+ fallback that nothing defines (not the sheet, not a drawn rule, not an inline style), each of
793
+ which makes its declaration invalid in a browser. The two checks every application view test
794
+ repeats are then:
795
+
796
+ ```ts
797
+ const tree = Inert.draw(Counter, 0)
798
+ expect(Inert.unslotted(tree)).toEqual([])
799
+ expect(Inert.missingTokens(tree, stylesheet)).toEqual([])
800
+ ```
801
+
802
+ A tree whose Styles read no token passes the second vacuously; assert that
803
+ `Inert.css(Inert.all(tree))` contains `var(--fk-` where that would be a mistake.
804
+
590
805
  ## `@foldkit/ui`
591
806
 
592
807
  `foldkit-mixins-ui` adapts `@foldkit/ui` components that expose attribute bundles or a consumer
package/dist/app.d.mts ADDED
@@ -0,0 +1,46 @@
1
+ import { o as StyleValue } from "./styleValue-BavTe9MZ.mjs";
2
+ import { standard } from "./layers.mjs";
3
+ import { a as NamedStyle, c as StyleOptions, l as StylePieces, n as Declared, r as DeclaredPieces } from "./style-CtCqaL0l.mjs";
4
+ import { a as compose, r as ThemeTokens, t as Refs } from "./core-CUw_n1Nd.mjs";
5
+ import { n as RootOptions } from "./root-xyWS6geK.mjs";
6
+ import { t as Tokens } from "./tokens-BR_qxDR7.mjs";
7
+ //#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;
11
+ /** The page's `color-scheme`; `'light'` keeps a light page light in a dark browser. Default `'light dark'`. */
12
+ readonly colorScheme?: NonNullable<RootOptions['colorScheme']>;
13
+ /**
14
+ * More page-wide pieces after `Defaults.body`, such as `Defaults.headings`,
15
+ * keyframes or a font face, placed in the `defaults` layer.
16
+ */
17
+ readonly global?: ReadonlyArray<StyleValue>;
18
+ }
19
+ /** A style's options with its layer fixed to the application's. */
20
+ 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>>;
24
+ /** Every token of `theme` as a typed `var(--fk-…)` reference. */
25
+ readonly t: Refs<ReturnType<typeof compose<Tokens, Palette>>>;
26
+ /** The layer order the stylesheet declares, for placing a layout or recipe (`L.in('layouts', …)`). */
27
+ readonly L: typeof standard;
28
+ /** `Style.slots` in the `app` layer: the application's own Slots, declared by their style. */
29
+ readonly slots: <S>(pieces: DeclaredPieces<S>, options?: AppStyleOptionsFor) => Declared<S>;
30
+ /** `Style.forSlots` in the `app` layer: a published contract (`ButtonSlots`) styled for this application. */
31
+ 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`. */
33
+ readonly stylesheet: string;
34
+ }
35
+ /**
36
+ * The application's theme, layer and page stylesheet:
37
+ * `const { t, slots, stylesheet } = AppStyle.make({ palette: Theme.oklch({ … }) })`.
38
+ * Slot styles are no longer in the stylesheet: a Slot injects its classes' CSS
39
+ * when it first draws them.
40
+ */
41
+ export declare const make: <Palette extends ThemeTokens>(options: AppStyleOptions<Palette>) => AppStyle<Palette>;
42
+ export declare const AppStyle: {
43
+ readonly make: <Palette extends ThemeTokens>(options: AppStyleOptions<Palette>) => AppStyle<Palette>;
44
+ };
45
+ //#endregion
46
+ //# sourceMappingURL=app.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app.d.mts","names":[],"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,kBAAkB,QAAc,QAAQ;;WAE/C,GAAG,KAAK,kBAAkB,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,aACnC,SAAS,gBAAgB,aACxB,SAAS;qBAuBC;WAzBQ,OAAA,gBAAgB,aAAW,SACrC,gBAAgB,aACxB,SAAS"}
package/dist/app.mjs ADDED
@@ -0,0 +1,45 @@
1
+ import { i as stylesheet, n as forSlots, r as slots } from "./style-CKjLee4e.mjs";
2
+ import { i as compose } from "./styleValue-_G9jwb17.mjs";
3
+ import { r as standard } from "./layers-B31M0tDi.mjs";
4
+ import { o as ref, r as compose$1 } from "./core-Bxj0UQDF.mjs";
5
+ import { t as root } from "./root-C1u12YMD.mjs";
6
+ import { r as tokens } from "./tokens-DteBJVN-.mjs";
7
+ import { body, reset } from "./defaults.mjs";
8
+ //#region src/app.ts
9
+ /**
10
+ * `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.
15
+ */
16
+ 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);
25
+ const scheme = options.colorScheme === void 0 ? {} : { colorScheme: options.colorScheme };
26
+ return Object.freeze({
27
+ theme,
28
+ t: ref(theme),
29
+ L: standard,
30
+ slots: (pieces, styleOptions) => slots(pieces, {
31
+ ...styleOptions,
32
+ layer: app
33
+ }),
34
+ forSlots: (contract) => (pieces, styleOptions) => forSlots(contract)(pieces, {
35
+ ...styleOptions,
36
+ layer: app
37
+ }),
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 ?? [])))
39
+ });
40
+ };
41
+ const AppStyle = { make };
42
+ //#endregion
43
+ export { AppStyle, make };
44
+
45
+ //# sourceMappingURL=app.mjs.map
@@ -0,0 +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,4 +1,4 @@
1
- import { l as inline } from "./styleValue--iQMTcPn.mjs";
1
+ import { u as inline } from "./styleValue-_G9jwb17.mjs";
2
2
  //#region src/theme/core.ts
3
3
  /**
4
4
  * `Theme` is typed token data, not a service. Dynamic theme state (light/dark)
@@ -50,4 +50,4 @@ const Theme = {
50
50
  //#endregion
51
51
  export { lightDark as a, define as i, VAR_PREFIX as n, ref as o, compose as r, variables as s, Theme as t };
52
52
 
53
- //# sourceMappingURL=core-izIY2GSX.mjs.map
53
+ //# sourceMappingURL=core-Bxj0UQDF.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"core-izIY2GSX.mjs","names":[],"sources":["../src/theme/core.ts"],"sourcesContent":["/**\n * `Theme` is typed token data, not a service. Dynamic theme state (light/dark)\n * belongs in the Foldkit Model; `variables` compiles the tokens to CSS custom\n * properties so switching a class or a root style is cheap and SSR-safe.\n */\nimport { inline, type StyleValue } from '../styleValue.js'\n\nexport type ThemeTokens = {\n readonly [group: string]: { readonly [name: string]: string }\n}\n\nexport type Theme<T extends ThemeTokens = ThemeTokens> = T\n\nexport const VAR_PREFIX = '--fk'\n\nexport const define = <T extends ThemeTokens>(tokens: T): Readonly<T> =>\n Object.freeze(\n Object.fromEntries(\n Object.entries(tokens).map(([group, names]) => [group, Object.freeze({ ...names })]),\n ),\n ) as Readonly<T>\n\n/** `var(--fk-group-name)` for every token, by the theme's own group and token names. */\nexport type Refs<T extends ThemeTokens> = {\n readonly [G in keyof T & string]: { readonly [N in keyof T[G] & string]: string }\n}\n\nconst refsByTheme = new WeakMap<ThemeTokens, Refs<ThemeTokens>>()\n\n/**\n * The theme's tokens as references: `Theme.ref(theme).surface.overt` is\n * `var(--fk-surface-overt)`, and a group or name the theme lacks is a type\n * error. Only the names are read, never the values. Built once per theme.\n */\nexport const ref = <T extends ThemeTokens>(theme: T): Refs<T> => {\n const cached = refsByTheme.get(theme)\n if (cached !== undefined) return cached as Refs<T>\n const built = Object.freeze(\n Object.fromEntries(\n Object.entries(theme).map(([group, names]) => [\n group,\n Object.freeze(\n Object.fromEntries(\n Object.keys(names).map(name => [name, `var(${VAR_PREFIX}-${group}-${name})`]),\n ),\n ),\n ]),\n ),\n )\n refsByTheme.set(theme, built)\n return built as Refs<T>\n}\n\nexport const variables = <T extends ThemeTokens>(theme: T): StyleValue => {\n const style: Record<`--${string}`, string> = {}\n for (const [group, names] of Object.entries(theme)) {\n for (const [name, value] of Object.entries(names as Record<string, string>)) {\n style[`${VAR_PREFIX}-${group}-${name}`] = value\n }\n }\n return inline(style)\n}\n\n/**\n * A token that follows the user's color scheme with CSS `light-dark()`: no\n * JavaScript and no Model field. A theme the user chooses is the other case,\n * and belongs in the Model as a class on the root; `variables` compiles both.\n */\nexport const lightDark = (light: string, dark: string): string => `light-dark(${light}, ${dark})`\n\ntype Merge<A, B> = {\n readonly [G in keyof A | keyof B]: G extends keyof B\n ? G extends keyof A\n ? A[G] & B[G]\n : B[G]\n : G extends keyof A\n ? A[G]\n : never\n}\n\n/** Themes merged at definition time, later tokens winning within a group. */\nexport const compose = <A extends ThemeTokens, B extends ThemeTokens>(\n base: A,\n over: B,\n): Readonly<Merge<A, B>> => {\n const merged: Record<string, Record<string, string>> = {}\n for (const source of [base, over]) {\n for (const [group, names] of Object.entries(source)) {\n merged[group] = { ...merged[group], ...(names as Record<string, string>) }\n }\n }\n return define(merged) as unknown as Readonly<Merge<A, B>>\n}\n\nexport const Theme = { define, ref, variables, lightDark, compose } as const\n"],"mappings":";;;;;;;AAaA,MAAa,aAAa;AAE1B,MAAa,UAAiC,WAC5C,OAAO,OACL,OAAO,YACL,OAAO,QAAQ,MAAM,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,OAAO,OAAO,OAAO,EAAE,GAAG,MAAM,CAAC,CAAC,CAAC,CACrF,CACF;AAOF,MAAM,8BAAc,IAAI,QAAwC;;;;;;AAOhE,MAAa,OAA8B,UAAsB;CAC/D,MAAM,SAAS,YAAY,IAAI,KAAK;CACpC,IAAI,WAAW,KAAA,GAAW,OAAO;CACjC,MAAM,QAAQ,OAAO,OACnB,OAAO,YACL,OAAO,QAAQ,KAAK,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAC5C,OACA,OAAO,OACL,OAAO,YACL,OAAO,KAAK,KAAK,CAAC,CAAC,KAAI,SAAQ,CAAC,MAAM,OAAO,WAAW,GAAG,MAAM,GAAG,KAAK,EAAE,CAAC,CAC9E,CACF,CACF,CAAC,CACH,CACF;CACA,YAAY,IAAI,OAAO,KAAK;CAC5B,OAAO;AACT;AAEA,MAAa,aAAoC,UAAyB;CACxE,MAAM,QAAuC,CAAC;CAC9C,KAAK,MAAM,CAAC,OAAO,UAAU,OAAO,QAAQ,KAAK,GAC/C,KAAK,MAAM,CAAC,MAAM,UAAU,OAAO,QAAQ,KAA+B,GACxE,MAAM,GAAG,WAAW,GAAG,MAAM,GAAG,UAAU;CAG9C,OAAO,OAAO,KAAK;AACrB;;;;;;AAOA,MAAa,aAAa,OAAe,SAAyB,cAAc,MAAM,IAAI,KAAK;;AAa/F,MAAa,WACX,MACA,SAC0B;CAC1B,MAAM,SAAiD,CAAC;CACxD,KAAK,MAAM,UAAU,CAAC,MAAM,IAAI,GAC9B,KAAK,MAAM,CAAC,OAAO,UAAU,OAAO,QAAQ,MAAM,GAChD,OAAO,SAAS;EAAE,GAAG,OAAO;EAAQ,GAAI;CAAiC;CAG7E,OAAO,OAAO,MAAM;AACtB;AAEA,MAAa,QAAQ;CAAE;CAAQ;CAAK;CAAW;CAAW;AAAQ"}
1
+ {"version":3,"file":"core-Bxj0UQDF.mjs","names":[],"sources":["../src/theme/core.ts"],"sourcesContent":["/**\n * `Theme` is typed token data, not a service. Dynamic theme state (light/dark)\n * belongs in the Foldkit Model; `variables` compiles the tokens to CSS custom\n * properties so switching a class or a root style is cheap and SSR-safe.\n */\nimport { inline, type StyleValue } from '../styleValue.js'\n\nexport type ThemeTokens = {\n readonly [group: string]: { readonly [name: string]: string }\n}\n\nexport type Theme<T extends ThemeTokens = ThemeTokens> = T\n\nexport const VAR_PREFIX = '--fk'\n\nexport const define = <T extends ThemeTokens>(tokens: T): Readonly<T> =>\n Object.freeze(\n Object.fromEntries(\n Object.entries(tokens).map(([group, names]) => [group, Object.freeze({ ...names })]),\n ),\n ) as Readonly<T>\n\n/** `var(--fk-group-name)` for every token, by the theme's own group and token names. */\nexport type Refs<T extends ThemeTokens> = {\n readonly [G in keyof T & string]: { readonly [N in keyof T[G] & string]: string }\n}\n\nconst refsByTheme = new WeakMap<ThemeTokens, Refs<ThemeTokens>>()\n\n/**\n * The theme's tokens as references: `Theme.ref(theme).surface.overt` is\n * `var(--fk-surface-overt)`, and a group or name the theme lacks is a type\n * error. Only the names are read, never the values. Built once per theme.\n */\nexport const ref = <T extends ThemeTokens>(theme: T): Refs<T> => {\n const cached = refsByTheme.get(theme)\n if (cached !== undefined) return cached as Refs<T>\n const built = Object.freeze(\n Object.fromEntries(\n Object.entries(theme).map(([group, names]) => [\n group,\n Object.freeze(\n Object.fromEntries(\n Object.keys(names).map(name => [name, `var(${VAR_PREFIX}-${group}-${name})`]),\n ),\n ),\n ]),\n ),\n )\n refsByTheme.set(theme, built)\n return built as Refs<T>\n}\n\nexport const variables = <T extends ThemeTokens>(theme: T): StyleValue => {\n const style: Record<`--${string}`, string> = {}\n for (const [group, names] of Object.entries(theme)) {\n for (const [name, value] of Object.entries(names as Record<string, string>)) {\n style[`${VAR_PREFIX}-${group}-${name}`] = value\n }\n }\n return inline(style)\n}\n\n/**\n * A token that follows the user's color scheme with CSS `light-dark()`: no\n * JavaScript and no Model field. A theme the user chooses is the other case,\n * and belongs in the Model as a class on the root; `variables` compiles both.\n */\nexport const lightDark = (light: string, dark: string): string => `light-dark(${light}, ${dark})`\n\ntype Merge<A, B> = {\n readonly [G in keyof A | keyof B]: G extends keyof B\n ? G extends keyof A\n ? A[G] & B[G]\n : B[G]\n : G extends keyof A\n ? A[G]\n : never\n}\n\n/** Themes merged at definition time, later tokens winning within a group. */\nexport const compose = <A extends ThemeTokens, B extends ThemeTokens>(\n base: A,\n over: B,\n): Readonly<Merge<A, B>> => {\n const merged: Record<string, Record<string, string>> = {}\n for (const source of [base, over]) {\n for (const [group, names] of Object.entries(source)) {\n merged[group] = { ...merged[group], ...(names as Record<string, string>) }\n }\n }\n return define(merged) as unknown as Readonly<Merge<A, B>>\n}\n\nexport const Theme = { define, ref, variables, lightDark, compose } as const\n"],"mappings":";;;;;;;AAaA,MAAa,aAAa;AAE1B,MAAa,UAAiC,WAC5C,OAAO,OACL,OAAO,YACL,OAAO,QAAQ,MAAM,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,OAAO,OAAO,OAAO,EAAE,GAAG,MAAM,CAAC,CAAC,CAAC,CACrF,CACF;AAOF,MAAM,8BAAc,IAAI,QAAwC;;;;;;AAOhE,MAAa,OAA8B,UAAsB;CAC/D,MAAM,SAAS,YAAY,IAAI,KAAK;CACpC,IAAI,WAAW,KAAA,GAAW,OAAO;CACjC,MAAM,QAAQ,OAAO,OACnB,OAAO,YACL,OAAO,QAAQ,KAAK,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAC5C,OACA,OAAO,OACL,OAAO,YACL,OAAO,KAAK,KAAK,CAAC,CAAC,KAAI,SAAQ,CAAC,MAAM,OAAO,WAAW,GAAG,MAAM,GAAG,KAAK,EAAE,CAAC,CAC9E,CACF,CACF,CAAC,CACH,CACF;CACA,YAAY,IAAI,OAAO,KAAK;CAC5B,OAAO;AACT;AAEA,MAAa,aAAoC,UAAyB;CACxE,MAAM,QAAuC,CAAC;CAC9C,KAAK,MAAM,CAAC,OAAO,UAAU,OAAO,QAAQ,KAAK,GAC/C,KAAK,MAAM,CAAC,MAAM,UAAU,OAAO,QAAQ,KAA+B,GACxE,MAAM,GAAG,WAAW,GAAG,MAAM,GAAG,UAAU;CAG9C,OAAO,OAAO,KAAK;AACrB;;;;;;AAOA,MAAa,aAAa,OAAe,SAAyB,cAAc,MAAM,IAAI,KAAK;;AAa/F,MAAa,WACX,MACA,SAC0B;CAC1B,MAAM,SAAiD,CAAC;CACxD,KAAK,MAAM,UAAU,CAAC,MAAM,IAAI,GAC9B,KAAK,MAAM,CAAC,OAAO,UAAU,OAAO,QAAQ,MAAM,GAChD,OAAO,SAAS;EAAE,GAAG,OAAO;EAAQ,GAAI;CAAiC;CAG7E,OAAO,OAAO,MAAM;AACtB;AAEA,MAAa,QAAQ;CAAE;CAAQ;CAAK;CAAW;CAAW;AAAQ"}
@@ -1,4 +1,4 @@
1
- import { a as StyleValue } from "./styleValue-C9vAKt7A.mjs";
1
+ import { o as StyleValue } from "./styleValue-BavTe9MZ.mjs";
2
2
  declare namespace core_d_exports {
3
3
  export { Refs, Theme, ThemeTokens, VAR_PREFIX, compose, define, lightDark, ref, variables };
4
4
  }
@@ -37,4 +37,4 @@ declare const Theme: {
37
37
  };
38
38
  //#endregion
39
39
  export { compose as a, lightDark as c, VAR_PREFIX as i, ref as l, Theme as n, core_d_exports as o, ThemeTokens as r, define as s, Refs as t, variables as u };
40
- //# sourceMappingURL=core-B86QnDhB.d.mts.map
40
+ //# sourceMappingURL=core-CUw_n1Nd.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"core-B86QnDhB.d.mts","names":[],"sources":["../src/theme/core.ts"],"mappings":";;;;KAOY;YACA;cAA4B;;;KAG5B,MAAM,UAAU,cAAc,eAAe;cAE5C;cAEA,SAAU,UAAU,aAAa,QAAQ,MAAI,SAAS;;KAQvD,KAAK,UAAU,2BACf,WAAW,yBAAyB,WAAW,EAAE;;;;;;cAUhD,MAAO,UAAU,aAAa,OAAO,MAAI,KAAK;cAmB9C,YAAa,UAAU,aAAa,OAAO,MAAI;;;;;;cAe/C,YAAa,eAAe;KAEpC,MAAM,GAAG,iBACF,WAAW,UAAU,IAAI,gBAAgB,IAC/C,gBAAgB,IACd,EAAE,KAAK,EAAE,KACT,EAAE,KACJ,gBAAgB,IACd,EAAE;;cAKG,UAAW,UAAU,aAAa,UAAU,aACvD,MAAM,GACN,MAAM,MACL,SAAS,MAAM,GAAG;cAUR;WA/EU,SAAA,UAAU,aAAW,QAAU,MAAI,SAAS;WAmB/C,MAAA,UAAU,aAAW,OAAS,MAAI,KAAK;WAmBjC,YAAA,UAAU,aAAW,OAAS,MAAI;WAe3B,YAAA,eAAM;WAaf,UAAA,UAAU,aAAa,UAAU,aAAW,MAC5D,GAAC,MACD,MACL,SAAS,MAAM,GAAG"}
1
+ {"version":3,"file":"core-CUw_n1Nd.d.mts","names":[],"sources":["../src/theme/core.ts"],"mappings":";;;;KAOY;YACA;cAA4B;;;KAG5B,MAAM,UAAU,cAAc,eAAe;cAE5C;cAEA,SAAU,UAAU,aAAa,QAAQ,MAAI,SAAS;;KAQvD,KAAK,UAAU,2BACf,WAAW,yBAAyB,WAAW,EAAE;;;;;;cAUhD,MAAO,UAAU,aAAa,OAAO,MAAI,KAAK;cAmB9C,YAAa,UAAU,aAAa,OAAO,MAAI;;;;;;cAe/C,YAAa,eAAe;KAEpC,MAAM,GAAG,iBACF,WAAW,UAAU,IAAI,gBAAgB,IAC/C,gBAAgB,IACd,EAAE,KAAK,EAAE,KACT,EAAE,KACJ,gBAAgB,IACd,EAAE;;cAKG,UAAW,UAAU,aAAa,UAAU,aACvD,MAAM,GACN,MAAM,MACL,SAAS,MAAM,GAAG;cAUR;WA/EU,SAAA,UAAU,aAAW,QAAU,MAAI,SAAS;WAmB/C,MAAA,UAAU,aAAW,OAAS,MAAI,KAAK;WAmBjC,YAAA,UAAU,aAAW,OAAS,MAAI;WAe3B,YAAA,eAAM;WAaf,UAAA,UAAU,aAAa,UAAU,aAAW,MAC5D,GAAC,MACD,MACL,SAAS,MAAM,GAAG"}
@@ -1,10 +1,14 @@
1
- import { a as StyleValue } from "./styleValue-C9vAKt7A.mjs";
1
+ import { o as StyleValue } from "./styleValue-BavTe9MZ.mjs";
2
2
  //#region src/defaults.d.ts
3
3
  /** Box model, margins, media, form-control fonts: what every page assumes. */
4
4
  export declare const reset: StyleValue;
5
5
  /** The page's font, color, background, and color scheme. */
6
6
  export declare const body: StyleValue;
7
- /** A type hierarchy for h1 to h6 from the size scale. */
7
+ /**
8
+ * A type hierarchy for h1 to h6 from the size scale, in `text-overt`. A
9
+ * container drawn in a color of its own, such as a band on the accent, sets
10
+ * `--fk-heading: currentColor` (`Style.vars`) and its headings take its color.
11
+ */
8
12
  export declare const headings: StyleValue;
9
13
  /** Link color, hover, and a visible focus ring. */
10
14
  export declare const links: StyleValue;
@@ -1 +1 @@
1
- {"version":3,"file":"defaults.d.mts","names":[],"sources":["../src/defaults.ts"],"mappings":";;;qBAca,OAAO;;qBAcP,MAAM;;qBAKN,UAAU;;qBAaV,OAAO;;qBASP,MAAM;;qBASN,UAAU;;qBAaV,KAAK;qBAEL"}
1
+ {"version":3,"file":"defaults.d.mts","names":[],"sources":["../src/defaults.ts"],"mappings":";;;qBAca,OAAO;;qBAcP,MAAM;;;;;;qBASN,UAAU;;qBAaV,OAAO;;qBASP,MAAM;;qBASN,UAAU;;qBAaV,KAAK;qBAEL"}
package/dist/defaults.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { r as compose, s as global } from "./styleValue--iQMTcPn.mjs";
1
+ import { c as global, i as compose } from "./styleValue-_G9jwb17.mjs";
2
2
  //#region src/defaults.ts
3
3
  /**
4
4
  * `foldkit-mixins/defaults`: the baseline plain HTML gets before any slot is
@@ -22,9 +22,13 @@ const reset = global([
22
22
  ].join(""));
23
23
  /** The page's font, color, background, and color scheme. */
24
24
  const body = global(`:where(body){font-family:${v("font-body", "system-ui, sans-serif")};font-size:${v("size-md", "1rem")};line-height:${v("leading-normal", "1.5")};font-weight:${v("weight-normal", "400")};color:${v("text-default", "CanvasText")};background:${v("surface-base", "Canvas")};-webkit-font-smoothing:antialiased}`);
25
- /** A type hierarchy for h1 to h6 from the size scale. */
25
+ /**
26
+ * A type hierarchy for h1 to h6 from the size scale, in `text-overt`. A
27
+ * container drawn in a color of its own, such as a band on the accent, sets
28
+ * `--fk-heading: currentColor` (`Style.vars`) and its headings take its color.
29
+ */
26
30
  const headings = global([
27
- `:where(:is(h1,h2,h3,h4,h5,h6)){font-family:${v("font-heading", "inherit")};font-weight:${v("weight-bold", "700")};line-height:${v("leading-tight", "1.2")};color:${v("text-overt", "inherit")};letter-spacing:-0.01em}`,
31
+ `:where(:is(h1,h2,h3,h4,h5,h6)){font-family:${v("font-heading", "inherit")};font-weight:${v("weight-bold", "700")};line-height:${v("leading-tight", "1.2")};color:${v("heading", v("text-overt", "inherit"))};letter-spacing:-0.01em}`,
28
32
  `:where(h1){font-size:${v("size-4xl", "2.25rem")}}`,
29
33
  `:where(h2){font-size:${v("size-3xl", "1.875rem")}}`,
30
34
  `:where(h3){font-size:${v("size-2xl", "1.5rem")}}`,
@@ -1 +1 @@
1
- {"version":3,"file":"defaults.mjs","names":[],"sources":["../src/defaults.ts"],"sourcesContent":["/**\n * `foldkit-mixins/defaults`: the baseline plain HTML gets before any slot is\n * styled. Every member is element-selector CSS over `--fk-*` tokens with a\n * fallback, so it re-themes with the tokens and still reads without them.\n * The pieces are unlayered; a page puts `reset` in `reset` and the rest in\n * `defaults` with `Layers.standard.in`. Selectors use `:where()` so any\n * class rule beats them.\n */\nimport { compose, global } from './styleValue.js'\nimport type { StyleValue } from './styleValue.js'\n\nconst v = (name: string, fallback: string): string => `var(--fk-${name}, ${fallback})`\n\n/** Box model, margins, media, form-control fonts: what every page assumes. */\nexport const reset: StyleValue = global(\n [\n '*,*::before,*::after{box-sizing:border-box;margin:0;min-width:0}',\n ':where(html){text-size-adjust:none;-webkit-text-size-adjust:none;tab-size:4;font-synthesis:none;text-rendering:optimizeLegibility}',\n ':where(:is(img,picture,video,canvas,svg)){display:block;max-inline-size:100%;block-size:auto}',\n ':where(:is(input,button,textarea,select)){font:inherit;color:inherit}',\n ':where(textarea){field-sizing:content;min-block-size:2lh}',\n ':where(:is(h1,h2,h3,h4,h5,h6)){text-wrap:balance}',\n ':where(p){text-wrap:pretty;overflow-wrap:break-word}',\n `@media (prefers-reduced-motion:reduce){*,*::before,*::after{animation-duration:0.01ms!important;transition-duration:0.01ms!important;scroll-behavior:auto!important}}`,\n ].join(''),\n)\n\n/** The page's font, color, background, and color scheme. */\nexport const body: StyleValue = global(\n `:where(body){font-family:${v('font-body', 'system-ui, sans-serif')};font-size:${v('size-md', '1rem')};line-height:${v('leading-normal', '1.5')};font-weight:${v('weight-normal', '400')};color:${v('text-default', 'CanvasText')};background:${v('surface-base', 'Canvas')};-webkit-font-smoothing:antialiased}`,\n)\n\n/** A type hierarchy for h1 to h6 from the size scale. */\nexport const headings: StyleValue = global(\n [\n `:where(:is(h1,h2,h3,h4,h5,h6)){font-family:${v('font-heading', 'inherit')};font-weight:${v('weight-bold', '700')};line-height:${v('leading-tight', '1.2')};color:${v('text-overt', 'inherit')};letter-spacing:-0.01em}`,\n `:where(h1){font-size:${v('size-4xl', '2.25rem')}}`,\n `:where(h2){font-size:${v('size-3xl', '1.875rem')}}`,\n `:where(h3){font-size:${v('size-2xl', '1.5rem')}}`,\n `:where(h4){font-size:${v('size-xl', '1.25rem')}}`,\n `:where(h5){font-size:${v('size-lg', '1.125rem')}}`,\n `:where(h6){font-size:${v('size-md', '1rem')}}`,\n ].join(''),\n)\n\n/** Link color, hover, and a visible focus ring. */\nexport const links: StyleValue = global(\n [\n `:where(a){color:${v('text-link', 'LinkText')};text-decoration-thickness:from-font;text-underline-offset:0.15em}`,\n `:where(a:hover){color:${v('text-link-hover', 'LinkText')}}`,\n `:where(:is(a,button,input,select,textarea,summary,[tabindex]):focus-visible){outline:${v('border-thick', '2px')} solid ${v('outline-focus', 'Highlight')};outline-offset:2px}`,\n ].join(''),\n)\n\n/** Inline code and code blocks on the subtle surface. */\nexport const code: StyleValue = global(\n [\n `:where(:is(code,kbd,samp,pre)){font-family:${v('font-mono', 'ui-monospace, monospace')};font-size:${v('size-sm', '0.875rem')}}`,\n `:where(:not(pre)>code){padding:0.1em 0.35em;border-radius:${v('radius-sm', '3px')};background:${v('surface-subtle', 'transparent')};overflow-wrap:anywhere}`,\n `:where(pre){padding:${v('space-md', '1rem')};border:${v('border-thin', '1px')} solid ${v('outline-subtle', 'transparent')};border-radius:${v('radius-md', '6px')};background:${v('surface-subtle', 'transparent')};overflow-x:auto;line-height:${v('leading-snug', '1.375')}}`,\n ].join(''),\n)\n\n/** Text inputs, selects, textareas, and buttons: one radius, one border, one focus. */\nexport const controls: StyleValue = global(\n [\n `:where(:is(input:not([type=checkbox],[type=radio],[type=range],[type=color],[type=file]),select,textarea)){padding:${v('space-xs', '0.5rem')} ${v('space-sm', '0.75rem')};border:${v('border-thin', '1px')} solid ${v('outline-default', 'ButtonBorder')};border-radius:${v('radius-md', '6px')};background:${v('surface-base', 'Field')};color:${v('text-default', 'FieldText')};transition:border-color ${v('motion-fast', '150ms')} ${v('motion-ease', 'ease-out')}}`,\n `:where(:is(input,select,textarea):focus-visible){border-color:${v('accent-default', 'Highlight')}}`,\n `:where(:is(input,select,textarea)[aria-invalid=true]){border-color:${v('error-default', 'red')}}`,\n `:where(button,[type=button],[type=submit],[type=reset]){padding:${v('space-xs', '0.5rem')} ${v('space-md', '1rem')};border:${v('border-thin', '1px')} solid ${v('outline-default', 'ButtonBorder')};border-radius:${v('radius-md', '6px')};background:${v('surface-subtle', 'ButtonFace')};color:${v('text-default', 'ButtonText')};cursor:pointer;transition:background ${v('motion-fast', '150ms')} ${v('motion-ease', 'ease-out')}}`,\n `:where(button,[type=button],[type=submit],[type=reset]):hover{background:${v('surface-muted', 'ButtonFace')}}`,\n `:where(:is(button,input,select,textarea):disabled){opacity:0.5;cursor:not-allowed}`,\n `:where(:is(input,select,textarea,button)::placeholder){color:${v('text-muted', 'GrayText')}}`,\n ].join(''),\n)\n\n/** Every default except `reset`, which belongs in its own layer. */\nexport const all: StyleValue = compose(body, headings, links, code, controls)\n\nexport const Defaults = { reset, body, headings, links, code, controls, all } as const\n"],"mappings":"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"}
1
+ {"version":3,"file":"defaults.mjs","names":[],"sources":["../src/defaults.ts"],"sourcesContent":["/**\n * `foldkit-mixins/defaults`: the baseline plain HTML gets before any slot is\n * styled. Every member is element-selector CSS over `--fk-*` tokens with a\n * fallback, so it re-themes with the tokens and still reads without them.\n * The pieces are unlayered; a page puts `reset` in `reset` and the rest in\n * `defaults` with `Layers.standard.in`. Selectors use `:where()` so any\n * class rule beats them.\n */\nimport { compose, global } from './styleValue.js'\nimport type { StyleValue } from './styleValue.js'\n\nconst v = (name: string, fallback: string): string => `var(--fk-${name}, ${fallback})`\n\n/** Box model, margins, media, form-control fonts: what every page assumes. */\nexport const reset: StyleValue = global(\n [\n '*,*::before,*::after{box-sizing:border-box;margin:0;min-width:0}',\n ':where(html){text-size-adjust:none;-webkit-text-size-adjust:none;tab-size:4;font-synthesis:none;text-rendering:optimizeLegibility}',\n ':where(:is(img,picture,video,canvas,svg)){display:block;max-inline-size:100%;block-size:auto}',\n ':where(:is(input,button,textarea,select)){font:inherit;color:inherit}',\n ':where(textarea){field-sizing:content;min-block-size:2lh}',\n ':where(:is(h1,h2,h3,h4,h5,h6)){text-wrap:balance}',\n ':where(p){text-wrap:pretty;overflow-wrap:break-word}',\n `@media (prefers-reduced-motion:reduce){*,*::before,*::after{animation-duration:0.01ms!important;transition-duration:0.01ms!important;scroll-behavior:auto!important}}`,\n ].join(''),\n)\n\n/** The page's font, color, background, and color scheme. */\nexport const body: StyleValue = global(\n `:where(body){font-family:${v('font-body', 'system-ui, sans-serif')};font-size:${v('size-md', '1rem')};line-height:${v('leading-normal', '1.5')};font-weight:${v('weight-normal', '400')};color:${v('text-default', 'CanvasText')};background:${v('surface-base', 'Canvas')};-webkit-font-smoothing:antialiased}`,\n)\n\n/**\n * A type hierarchy for h1 to h6 from the size scale, in `text-overt`. A\n * container drawn in a color of its own, such as a band on the accent, sets\n * `--fk-heading: currentColor` (`Style.vars`) and its headings take its color.\n */\nexport const headings: StyleValue = global(\n [\n `:where(:is(h1,h2,h3,h4,h5,h6)){font-family:${v('font-heading', 'inherit')};font-weight:${v('weight-bold', '700')};line-height:${v('leading-tight', '1.2')};color:${v('heading', v('text-overt', 'inherit'))};letter-spacing:-0.01em}`,\n `:where(h1){font-size:${v('size-4xl', '2.25rem')}}`,\n `:where(h2){font-size:${v('size-3xl', '1.875rem')}}`,\n `:where(h3){font-size:${v('size-2xl', '1.5rem')}}`,\n `:where(h4){font-size:${v('size-xl', '1.25rem')}}`,\n `:where(h5){font-size:${v('size-lg', '1.125rem')}}`,\n `:where(h6){font-size:${v('size-md', '1rem')}}`,\n ].join(''),\n)\n\n/** Link color, hover, and a visible focus ring. */\nexport const links: StyleValue = global(\n [\n `:where(a){color:${v('text-link', 'LinkText')};text-decoration-thickness:from-font;text-underline-offset:0.15em}`,\n `:where(a:hover){color:${v('text-link-hover', 'LinkText')}}`,\n `:where(:is(a,button,input,select,textarea,summary,[tabindex]):focus-visible){outline:${v('border-thick', '2px')} solid ${v('outline-focus', 'Highlight')};outline-offset:2px}`,\n ].join(''),\n)\n\n/** Inline code and code blocks on the subtle surface. */\nexport const code: StyleValue = global(\n [\n `:where(:is(code,kbd,samp,pre)){font-family:${v('font-mono', 'ui-monospace, monospace')};font-size:${v('size-sm', '0.875rem')}}`,\n `:where(:not(pre)>code){padding:0.1em 0.35em;border-radius:${v('radius-sm', '3px')};background:${v('surface-subtle', 'transparent')};overflow-wrap:anywhere}`,\n `:where(pre){padding:${v('space-md', '1rem')};border:${v('border-thin', '1px')} solid ${v('outline-subtle', 'transparent')};border-radius:${v('radius-md', '6px')};background:${v('surface-subtle', 'transparent')};overflow-x:auto;line-height:${v('leading-snug', '1.375')}}`,\n ].join(''),\n)\n\n/** Text inputs, selects, textareas, and buttons: one radius, one border, one focus. */\nexport const controls: StyleValue = global(\n [\n `:where(:is(input:not([type=checkbox],[type=radio],[type=range],[type=color],[type=file]),select,textarea)){padding:${v('space-xs', '0.5rem')} ${v('space-sm', '0.75rem')};border:${v('border-thin', '1px')} solid ${v('outline-default', 'ButtonBorder')};border-radius:${v('radius-md', '6px')};background:${v('surface-base', 'Field')};color:${v('text-default', 'FieldText')};transition:border-color ${v('motion-fast', '150ms')} ${v('motion-ease', 'ease-out')}}`,\n `:where(:is(input,select,textarea):focus-visible){border-color:${v('accent-default', 'Highlight')}}`,\n `:where(:is(input,select,textarea)[aria-invalid=true]){border-color:${v('error-default', 'red')}}`,\n `:where(button,[type=button],[type=submit],[type=reset]){padding:${v('space-xs', '0.5rem')} ${v('space-md', '1rem')};border:${v('border-thin', '1px')} solid ${v('outline-default', 'ButtonBorder')};border-radius:${v('radius-md', '6px')};background:${v('surface-subtle', 'ButtonFace')};color:${v('text-default', 'ButtonText')};cursor:pointer;transition:background ${v('motion-fast', '150ms')} ${v('motion-ease', 'ease-out')}}`,\n `:where(button,[type=button],[type=submit],[type=reset]):hover{background:${v('surface-muted', 'ButtonFace')}}`,\n `:where(:is(button,input,select,textarea):disabled){opacity:0.5;cursor:not-allowed}`,\n `:where(:is(input,select,textarea,button)::placeholder){color:${v('text-muted', 'GrayText')}}`,\n ].join(''),\n)\n\n/** Every default except `reset`, which belongs in its own layer. */\nexport const all: StyleValue = compose(body, headings, links, code, controls)\n\nexport const Defaults = { reset, body, headings, links, code, controls, all } as const\n"],"mappings":"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"}
@@ -0,0 +1,30 @@
1
+ import { Plugin } from "vite";
2
+ //#region src/foundations.d.ts
3
+ /**
4
+ * Compiles the stylesheet a module exports: what the page's first paint is
5
+ * styled with before any script runs. The module is evaluated, so it must be
6
+ * pure (building a string, like the CMS example's sheet).
7
+ */
8
+ export declare const loadFoundations: (options: {
9
+ /** The stylesheet module, root-relative (`/src/styles/sheet.ts`). */
10
+ readonly module: string;
11
+ /** The export holding the stylesheet text. Default `stylesheet`. */
12
+ readonly export?: string | undefined;
13
+ /** What `vite build` runs from. Default the current directory. */
14
+ readonly root?: string | undefined;
15
+ }) => Promise<string>;
16
+ /**
17
+ * Writes the foundations into the page's head: in development through the
18
+ * running server, in a build through one of its own. Without it, each move
19
+ * between pages paints unstyled until the script runs.
20
+ */
21
+ export declare const foundations: (options: {
22
+ /** The stylesheet module, root-relative (`/src/styles/sheet.ts`). */
23
+ readonly module: string;
24
+ /** The export holding the stylesheet text. Default `stylesheet`. */
25
+ readonly export?: string | undefined;
26
+ /** What `vite build` runs from. Default the current directory. */
27
+ readonly root?: string | undefined;
28
+ }) => Plugin;
29
+ //#endregion
30
+ //# sourceMappingURL=foundations.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"foundations.d.mts","names":[],"sources":["../src/foundations.ts"],"mappings":";;;;;;;qBA4Ca,kBAAyB;;WAE3B;;WAEA;;WAEA;MACP;;;;;;qBA4BS,cAAe;;WAEjB;;WAEA;;WAEA;MACP"}