foldkit-mixins 0.5.0 → 0.7.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.
package/README.md CHANGED
@@ -276,7 +276,7 @@ one.
276
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 |
277
277
  | `Theme.lightDark(light, dark)` / `Theme.compose(base, over)` | a token that follows the color scheme with CSS `light-dark()`; themes merged at definition time |
278
278
  | `Theme.root(theme, { omit?, colorScheme? })` / `Theme.scoped(theme, selector, overrides)` | from `foldkit-mixins/theme`: tokens as `:root` custom properties, or as overrides under a selector; unlayered global pieces for `Style.stylesheet` |
279
- | `Theme.tokens` / `Theme.oklch(knobs)` / `Theme.breakpointWidths(theme)` | from `foldkit-mixins/theme`: the shipped spacing, type, radius, motion, border and breakpoint scales; a whole palette derived from an accent and a few knobs; the breakpoints as pixel widths for `foldkit-primitives/media` |
279
+ | `Theme.tokens` / `Theme.oklch(knobs)` / `Theme.breakpointWidths(theme)` | from `foldkit-mixins/theme`: the shipped spacing, type, radius, motion, border, shadow and breakpoint scales; 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
280
  | `Layers.define(names)` / `Layers.standard` | cascade layers as a value: `names`, `declare` (the `@layer …;` statement as a global piece), `in(name, piece)` (a piece's unlayered rules and global CSS inside that layer; what is already layered keeps its layer; a piece wholly in another layer is `style:relayered`) and `layer(name)` (the placement `Style.forSlots(S)(pieces, { layer })` takes, so a slot style is compiled in that layer). A name outside the order is a type error. `standard` is `reset, tokens, theme, defaults, components, layouts, variants, utilities, app`; also under `foldkit-mixins/layers` |
281
281
  | `Style.stylesheet(...)` | one `<style>` block from `NamedStyle`s and bare `StyleValue`s: the layer order hoisted first (two different orders is `style:conflicting-layer-order`), then global chunks, then scoped classes, deduplicated. Once an order is declared, a rule outside it is `style:unlayered-rule`, since it would beat every layer; keyframes, font faces and `@property` pass |
282
282
 
@@ -782,6 +782,17 @@ Slot's name, however deeply its views nest; a view drawn for real is never marke
782
782
  under a Foldkit Scene's render frame, so a view that embeds a Submodel with `h.submodel`
783
783
  (every `@foldkit/ui` component page) draws whole, `childAttributes` included; nothing is
784
784
  dispatched, and no Command or Mount it declares runs or is checked. On that tree,
785
+ On the real runtime, `Frames.track()` from `foldkit-mixins/testing` tracks the
786
+ page's animation frames (create it after any stub of `requestAnimationFrame`,
787
+ and `dispose()` it after). `await frames.settle()` resolves once every frame
788
+ asked for has run and none followed, so a test reads the page drawn instead of
789
+ sleeping and hoping; pass `Sync.mount`'s handle (`frames.settle(mounted)`) to
790
+ wait for its replica first. `settle` does not wait for I/O a Command started:
791
+ wait for that result (`vi.waitFor`), then settle. `hold()` keeps every frame
792
+ back until `release()`, so events meet the view as last drawn, as input
793
+ faster than a frame does; see
794
+ [Messages carry intent](../../docs/state-model.md#messages-carry-intent-not-results-worked-out-from-the-last-frame).
795
+
785
796
  `Inert.bySlot(root, 'input')` finds a Slot's elements, `Inert.unslotted(root, { inside })` lists
786
797
  every element no Slot drew (skipping what a Slot named in `inside` holds, such as a canvas drawing
787
798
  the application's page), and `Inert.fixedInline(root, { inside })` every inline declaration that
@@ -802,6 +813,30 @@ expect(Inert.missingTokens(tree, stylesheet)).toEqual([])
802
813
  A tree whose Styles read no token passes the second vacuously; assert that
803
814
  `Inert.css(Inert.all(tree))` contains `var(--fk-` where that would be a mistake.
804
815
 
816
+ ## Foundations in the first paint
817
+
818
+ A view's Styles arrive as it draws, so a page that has not run its script yet is
819
+ unstyled. `foldkit-mixins/foundations` writes the one stylesheet that belongs to
820
+ no view — the reset, the palette, the type — into the document's head, in
821
+ development through the running server and in a build through one of its own. It
822
+ compiles a module the application owns, through a server, as the page would
823
+ compile it, so the build's foundations are the application's rather than a copy.
824
+
825
+ ```ts
826
+ // vite.config.ts
827
+ import { foundations } from 'foldkit-mixins/foundations'
828
+
829
+ export default defineConfig({
830
+ plugins: [foundations({ module: '/src/styles/sheet.ts' })],
831
+ })
832
+ ```
833
+
834
+ The module must be pure (it builds a string) and export the stylesheet text;
835
+ `export` names that export (default `stylesheet`), and `root` what `vite build`
836
+ runs from. `loadFoundations(options)` is the same compile without the plugin,
837
+ returning the text for a caller that writes it itself. The subpath is node-only:
838
+ a page that imports it fails fast naming `vite`.
839
+
805
840
  ## `@foldkit/ui`
806
841
 
807
842
  `foldkit-mixins-ui` adapts `@foldkit/ui` components that expose attribute bundles or a consumer
package/dist/app.d.mts CHANGED
@@ -3,7 +3,7 @@ import { standard } from "./layers.mjs";
3
3
  import { a as NamedStyle, c as StyleOptions, l as StylePieces, n as Declared, r as DeclaredPieces } from "./style-CtCqaL0l.mjs";
4
4
  import { a as compose, r as ThemeTokens, t as Refs } from "./core-CUw_n1Nd.mjs";
5
5
  import { n as RootOptions } from "./root-xyWS6geK.mjs";
6
- import { t as Tokens } from "./tokens-BR_qxDR7.mjs";
6
+ import { t as Tokens } from "./tokens-XZSP0AvO.mjs";
7
7
  //#region src/app.d.ts
8
8
  export interface AppStyleOptions<Palette extends ThemeTokens> {
9
9
  /** The application's own tokens, usually `Theme.oklch(…)`, laid over `Theme.tokens`. */
package/dist/app.mjs CHANGED
@@ -3,7 +3,7 @@ import { i as compose } from "./styleValue-_G9jwb17.mjs";
3
3
  import { r as standard } from "./layers-B31M0tDi.mjs";
4
4
  import { o as ref, r as compose$1 } from "./core-Bxj0UQDF.mjs";
5
5
  import { t as root } from "./root-C1u12YMD.mjs";
6
- import { r as tokens } from "./tokens-DteBJVN-.mjs";
6
+ import { r as tokens } from "./tokens-O8S8QH_R.mjs";
7
7
  import { body, reset } from "./defaults.mjs";
8
8
  //#region src/app.ts
9
9
  /**
@@ -100,6 +100,9 @@ declare const oklch: (knobs: OklchKnobs) => Readonly<{
100
100
  'on-fill': string;
101
101
  ink: string;
102
102
  };
103
+ shadow: {
104
+ color: string;
105
+ };
103
106
  success: {
104
107
  default: string;
105
108
  subtle: string;
@@ -132,4 +135,4 @@ declare const oklch: (knobs: OklchKnobs) => Readonly<{
132
135
  type OklchTheme = ReturnType<typeof oklch>;
133
136
  //#endregion
134
137
  export { OklchTheme as n, oklch as r, OklchKnobs as t };
135
- //# sourceMappingURL=oklch-BxvCD0oi.d.mts.map
138
+ //# sourceMappingURL=oklch-FOemcYSv.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"oklch-BxvCD0oi.d.mts","names":[],"sources":["../src/theme/oklch.ts"],"mappings":";UAUiB;;WAEN;aACE;aACA;aACA;;aAEA;eAAkB;eAAqB;;;;WAGzC;WACA;;WAEA;;WAEA;;WAEA;;WAEA;aACE;aACA;aACA;aACA;;;cA2EA,QAAS,OAAO,eAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA2E3B,aAAa,kBAAkB"}
1
+ {"version":3,"file":"oklch-FOemcYSv.d.mts","names":[],"sources":["../src/theme/oklch.ts"],"mappings":";UAUiB;;WAEN;aACE;aACA;aACA;;aAEA;eAAkB;eAAqB;;;;WAGzC;WACA;;WAEA;;WAEA;;WAEA;;WAEA;aACE;aACA;aACA;aACA;;;cA2EA,QAAS,OAAO,eAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAmF3B,aAAa,kBAAkB"}
@@ -26,5 +26,40 @@ export declare const Inert: {
26
26
  readonly byLabel: (root: Html | undefined, label: string) => ReadonlyArray<Node>;
27
27
  readonly pressed: (node: Html | undefined) => Option.Option<boolean>;
28
28
  };
29
+ /** Something with work of its own to finish before a page is settled, such as `Sync.mount`'s handle. */
30
+ export interface Settles {
31
+ readonly settled: () => Promise<void>;
32
+ }
33
+ /** The page's animation frames, tracked: held, released, and waited for. */
34
+ export interface TrackedFrames {
35
+ /** Holds every frame asked for from now until `release`: nothing is drawn meanwhile. */
36
+ readonly hold: () => void;
37
+ /** Runs the held frames, and lets those after run as they are asked for. */
38
+ readonly release: () => void;
39
+ /**
40
+ * Resolves once nothing is left to draw: every frame asked for has run, and
41
+ * a turn of the event loop after the last asked for no other. Each of
42
+ * `barriers` settles first, and the two are waited for again until both
43
+ * are quiet in one round, since a frame can lead to a dispatch and a
44
+ * dispatch to a frame. Rejects while frames are held, and after 50 rounds
45
+ * of frames that keep coming. It knows only frames asked for: a runtime
46
+ * still starting has asked for none, so wait for its first drawing, and
47
+ * for I/O a Command started, before settling what follows.
48
+ */
49
+ readonly settle: (...barriers: ReadonlyArray<Settles>) => Promise<void>;
50
+ /** Puts back the frame functions it replaced. */
51
+ readonly dispose: () => void;
52
+ }
53
+ /**
54
+ * The page's animation frames, tracked from the moment `track` is called.
55
+ * Foldkit draws on `requestAnimationFrame`, so `settle` waits for what a
56
+ * transition asked to draw, instead of a sleep that guesses how long that
57
+ * takes, and `hold` keeps every frame back so events meet the view as it
58
+ * was last drawn, as keys and clicks faster than a frame do. Call it after
59
+ * any stub of `requestAnimationFrame`, since it wraps whichever is installed.
60
+ */
61
+ export declare const Frames: {
62
+ readonly track: () => TrackedFrames;
63
+ };
29
64
  //#endregion
30
65
  //# sourceMappingURL=testing.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"testing.d.mts","names":[],"sources":["../src/testing.ts"],"mappings":";;;;;YAeY,OAAO,QAAQ;qBAgOd;WAjIC,OAAA,OAAO,OAAO,SAAO,MAC3B,SAAkB,OAAO,OAAO,UAAQ,OACvC,UACN;WA+FiB,MAAA,OAAA,cAAc;WAWL,gBAAA,MAAA,MAAI,uBAAuB;WA5ElC,SAAA,MAAA,kBAAgB,iBAAiB,cAAc;WAqC7D,YAAA,MAAA,kBAAgB;aACF,SAAS;QAC5B;WAcK,cAAA,MAAA,kBAAgB;aACF,S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ldkit/scene";
7
7
  * (`SlotView.inertBuilder()`), for tests that check what a view draws without
8
8
  * a DOM. They read an element as the browser would: an attribute or a
9
9
  * property, whichever the builder wrote, so a test need not know that `title`
10
- * and `value` are properties while `aria-label` is an attribute.
10
+ * and `value` are properties while `aria-label` is an attribute. `Frames.hold`
11
+ * is for tests on the real runtime: input faster than a frame.
11
12
  */
12
13
  /** Every node under `root`, itself first, depth first. */
13
14
  const all = (root) => root === null || root === void 0 ? [] : [root, ...(root.children ?? []).flatMap((child) => typeof child === "string" ? [] : all(child))];
@@ -161,7 +162,85 @@ const Inert = {
161
162
  byLabel,
162
163
  pressed
163
164
  };
165
+ const rounds = 50;
166
+ const turn = () => new Promise((resolve) => setTimeout(resolve, 0));
167
+ const track = () => {
168
+ const request = globalThis.requestAnimationFrame;
169
+ const cancel = globalThis.cancelAnimationFrame;
170
+ const waiting = /* @__PURE__ */ new Map();
171
+ const held = [];
172
+ let holding = false;
173
+ let next = 0;
174
+ let ran = [];
175
+ const ranOne = () => {
176
+ for (const resolve of ran.splice(0)) resolve();
177
+ };
178
+ const schedule = (id, callback) => waiting.set(id, request((time) => {
179
+ waiting.delete(id);
180
+ try {
181
+ callback(time);
182
+ } finally {
183
+ ranOne();
184
+ }
185
+ }));
186
+ globalThis.requestAnimationFrame = (callback) => {
187
+ const id = ++next;
188
+ if (holding) {
189
+ waiting.set(id, -1);
190
+ held.push({
191
+ id,
192
+ callback
193
+ });
194
+ } else schedule(id, callback);
195
+ return id;
196
+ };
197
+ globalThis.cancelAnimationFrame = (id) => {
198
+ const underlying = waiting.get(id);
199
+ waiting.delete(id);
200
+ const index = held.findIndex((frame) => frame.id === id);
201
+ if (index !== -1) held.splice(index, 1);
202
+ if (underlying !== void 0 && underlying !== -1) cancel(underlying);
203
+ };
204
+ const aFrame = () => new Promise((resolve) => ran.push(resolve));
205
+ return {
206
+ hold: () => {
207
+ holding = true;
208
+ },
209
+ release: () => {
210
+ holding = false;
211
+ for (const { id, callback } of held.splice(0)) schedule(id, callback);
212
+ },
213
+ settle: async (...barriers) => {
214
+ for (let round = 0; round < rounds; round++) {
215
+ if (holding) throw new Error("Frames.settle: frames are held; release them first.");
216
+ for (const barrier of barriers) await barrier.settled();
217
+ if (waiting.size > 0) {
218
+ await aFrame();
219
+ continue;
220
+ }
221
+ await turn();
222
+ if (waiting.size === 0) return;
223
+ }
224
+ const hidden = typeof document !== "undefined" && document.visibilityState === "hidden" ? " The document is hidden, and a hidden page runs no frames." : "";
225
+ throw new Error(`Frames.settle: still drawing after ${rounds} rounds (a Mount or an animation keeps asking for frames).${hidden}`);
226
+ },
227
+ dispose: () => {
228
+ globalThis.requestAnimationFrame = request;
229
+ globalThis.cancelAnimationFrame = cancel;
230
+ ranOne();
231
+ }
232
+ };
233
+ };
234
+ /**
235
+ * The page's animation frames, tracked from the moment `track` is called.
236
+ * Foldkit draws on `requestAnimationFrame`, so `settle` waits for what a
237
+ * transition asked to draw, instead of a sleep that guesses how long that
238
+ * takes, and `hold` keeps every frame back so events meet the view as it
239
+ * was last drawn, as keys and clicks faster than a frame do. Call it after
240
+ * any stub of `requestAnimationFrame`, since it wraps whichever is installed.
241
+ */
242
+ const Frames = { track };
164
243
  //#endregion
165
- export { Inert };
244
+ export { Frames, Inert };
166
245
 
167
246
  //# sourceMappingURL=testing.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"testing.mjs","names":[],"sources":["../src/testing.ts"],"sourcesContent":["/**\n * `foldkit-mixins/testing`: queries over a view drawn with the inert builder\n * (`SlotView.inertBuilder()`), for tests that check what a view draws without\n * a DOM. They read an element as the browser would: an attribute or a\n * property, whichever the builder wrote, so a test need not know that `title`\n * and `value` are properties while `aria-label` is an attribute.\n */\nimport { Option } from 'effect'\nimport type { Html, HtmlBuilder } from 'foldkit/html'\nimport { given, scene, tap } from 'foldkit/scene'\nimport { usedIn } from './inject.js'\nimport { SLOT_MARK, drawMarked } from './slotMark.js'\nimport type * as SlotView from './slotView.js'\n\n/** An element or text node of an inert tree. */\nexport type Node = Exclude<Html, null>\n\n/** Every node under `root`, itself first, depth first. */\nconst all = (root: Html | undefined): ReadonlyArray<Node> =>\n root === null || root === undefined\n ? []\n : [\n root,\n ...(root.children ?? []).flatMap(child => (typeof child === 'string' ? [] : all(child))),\n ]\n\n/** A node's children that are nodes, not plain strings. */\nconst children = (node: Html | undefined): ReadonlyArray<Node> =>\n (node?.children ?? []).filter((child): child is Node => typeof child !== 'string')\n\n/** Every element under `root` with this tag. */\nconst byTag = (root: Html | undefined, tag: string): ReadonlyArray<Node> =>\n all(root).filter(node => node.sel === tag)\n\n/** The text under a node, joined. */\nconst text = (node: Html | undefined): string =>\n all(node)\n .map(each => each.text ?? '')\n .join('')\n\n/** Attributes whose property has another name. */\nconst propertyNames: Readonly<Record<string, string>> = { for: 'htmlFor', class: 'className' }\n\n/** An attribute or a property, whichever the builder wrote; the attribute first. */\nconst value = (node: Html | undefined, key: string): unknown =>\n node?.data?.attrs?.[key] ??\n node?.data?.props?.[key] ??\n node?.data?.props?.[propertyNames[key] ?? key]\n\n/** The classes on a node, in the order the builder wrote them. */\nconst classes = (node: Html | undefined): ReadonlyArray<string> =>\n Object.entries(node?.data?.class ?? {})\n .filter(([, on]) => on === true)\n .map(([name]) => name)\n\n/** The inline style on a node, empty when it has none. */\nconst style = (node: Html | undefined): Readonly<Record<string, string>> => node?.data?.style ?? {}\n\n/** Every element under `root` with this role. */\nconst byRole = (root: Html | undefined, role: string): ReadonlyArray<Node> =>\n all(root).filter(node => value(node, 'role') === role)\n\n/**\n * Every element under `root` named `label`: by its `aria-label`, by the text of\n * a `<label for>` pointing at its id, or by its own text. By text, only the\n * innermost element counts, not every ancestor whose text is the same.\n */\nconst byLabel = (root: Html | undefined, label: string): ReadonlyArray<Node> => {\n const nodes = all(root).filter(node => node.sel !== undefined)\n const labelled = new Set(\n nodes\n .filter(node => node.sel === 'label' && text(node) === label)\n .map(node => value(node, 'for')),\n )\n const byText = new Set(\n nodes.filter(\n node =>\n value(node, 'aria-label') === undefined && node.sel !== 'label' && text(node) === label,\n ),\n )\n const innermost = new Set(\n [...byText].filter(node => !all(node).some(inner => inner !== node && byText.has(inner))),\n )\n return nodes.filter(\n node =>\n value(node, 'aria-label') === label ||\n (value(node, 'id') !== undefined && labelled.has(value(node, 'id'))) ||\n innermost.has(node),\n )\n}\n\n/** Whether a toggle button is pressed; none when it is not a toggle. */\nconst pressed = (node: Html | undefined): Option.Option<boolean> =>\n Option.map(\n Option.fromUndefinedOr(value(node, 'aria-pressed')),\n state => state === 'true' || state === true,\n )\n\n/** Ends the Scene `draw` borrows once the view has drawn, before its end-of-test checks. */\nconst DRAWN = Symbol('drawn')\n\n/**\n * A SlotView drawn inert, each element a Slot draws marked with the Slot's\n * name, however deeply nested its view, for `bySlot` and `unslotted`. Only\n * here: a view drawn for real carries no mark.\n *\n * It draws under a Foldkit Scene's render frame, which `h.submodel` and a\n * Submodel's `childAttributes` need; nothing is dispatched, and no Command or\n * Mount the drawing declares is run or checked.\n */\nconst draw = <Slots, Input, Message>(\n view: SlotView.SlotView<Slots, Input, Message>,\n input: Input,\n): Html => {\n let drawn: Html = null\n const drawInto = (model: Input, h: HtmlBuilder<Message>): Html => {\n drawn = view(model, h)\n // Scene refuses a view that draws nothing; what it draws is not the result.\n return h.div([], [])\n }\n try {\n drawMarked(() =>\n scene(\n { update: (model: Input) => ({ model }), view: drawInto },\n given(input),\n tap(() => {\n throw DRAWN\n }),\n ),\n )\n } catch (error) {\n if (error !== DRAWN) throw error\n }\n return drawn\n}\n\n/** The Slot a node was drawn by, in a tree from `draw`; none for one no Slot drew. */\nconst slotOf = (node: Html | undefined): Option.Option<string> => {\n const name = value(node, `data-${SLOT_MARK}`)\n return typeof name === 'string' ? Option.some(name) : Option.none()\n}\n\n/** Every element a Slot drew, in a tree from `draw`. */\nconst bySlot = (root: Html | undefined, slot: string): ReadonlyArray<Node> =>\n all(root).filter(node => Option.contains(slotOf(node), slot))\n\n/** Where each element sits: its tags from the root, `main > nav > a`. */\nconst pathsOf = (root: Html | undefined): ReadonlyMap<Node, string> => {\n const paths = new Map<Node, string>()\n const walk = (node: Html | undefined, above: string): void => {\n if (node === null || node === undefined || node.sel === undefined) return\n const here = above === '' ? node.sel : `${above} > ${node.sel}`\n paths.set(node, here)\n for (const child of children(node)) walk(child, here)\n }\n walk(root, '')\n return paths\n}\n\n/** The elements of the package's own markup: every element, except inside a Slot named in `inside`. */\nconst own = (root: Html | undefined, inside: ReadonlyArray<string>): ReadonlyArray<Node> => {\n const skipped = new Set(inside)\n const found: Array<Node> = []\n const walk = (node: Html | undefined): void => {\n if (node === null || node === undefined || node.sel === undefined) return\n found.push(node)\n if (Option.exists(slotOf(node), name => skipped.has(name))) return\n for (const child of children(node)) walk(child)\n }\n walk(root)\n return found\n}\n\n/**\n * Every element in a tree from `draw` that no Slot drew, by its path: markup a\n * stylist could reach only through a selector into the package. What a Slot\n * named in `inside` holds is not the package's, such as a canvas drawing the\n * application's own page, and is skipped.\n */\nconst unslotted = (\n root: Html | undefined,\n options: { readonly inside?: ReadonlyArray<string> } = {},\n): ReadonlyArray<string> => {\n const paths = pathsOf(root)\n return own(root, options.inside ?? [])\n .filter(node => Option.isNone(slotOf(node)))\n .map(node => paths.get(node) ?? node.sel ?? '')\n}\n\n/**\n * Every inline declaration that is not a custom property, by its element's\n * path, skipping what a Slot named in `inside` holds: a fixed value inline\n * outranks every rule, so a later layer could not override it. A value known\n * only per element belongs in a custom property that a rule reads.\n */\nconst fixedInline = (\n root: Html | undefined,\n options: { readonly inside?: ReadonlyArray<string> } = {},\n): ReadonlyArray<string> => {\n const paths = pathsOf(root)\n return own(root, options.inside ?? []).flatMap(node =>\n Object.keys(style(node))\n .filter(property => !property.startsWith('--'))\n .map(property => `${paths.get(node) ?? node.sel ?? ''}: ${property}`),\n )\n}\n\n/** The compiled CSS behind the classes on `nodes`, after the standard layer order. */\nconst css = (nodes: ReadonlyArray<Html>): string => usedIn(nodes.flatMap(classes).join(' '))\n\nconst TOKEN_READ = /var\\((--fk-[\\w-]+)\\)/g\n\n/**\n * The `--fk-*` tokens the tree's Styles read with no fallback and that\n * nothing defines, in first-read order: not `stylesheet`, not a drawn rule,\n * not an inline style. Such a read makes its declaration invalid, so a test\n * asserts `toEqual([])`. A tree whose Styles read no token passes too; check\n * `css` for `var(--fk-` when that would be a mistake.\n */\nconst missingTokens = (root: Html, stylesheet: string): ReadonlyArray<string> => {\n const nodes = all(root)\n const drawn = css(nodes)\n const inline = nodes.flatMap(node => Object.entries(style(node)))\n const read = new Set([\n ...Array.from(drawn.matchAll(TOKEN_READ), ([, name]) => name ?? ''),\n ...inline.flatMap(([, value]) =>\n Array.from(value.matchAll(TOKEN_READ), ([, name]) => name ?? ''),\n ),\n ])\n const defined = new Set(inline.map(([property]) => property))\n return [...read].filter(\n name =>\n name !== '' &&\n !stylesheet.includes(`${name}:`) &&\n !drawn.includes(`${name}:`) &&\n !defined.has(name),\n )\n}\n\nexport const Inert = {\n draw,\n css,\n missingTokens,\n bySlot,\n unslotted,\n fixedInline,\n all,\n children,\n byTag,\n text,\n value,\n classes,\n style,\n byRole,\n byLabel,\n pressed,\n} as const\n"],"mappings":";;;;;;;;;;;;AAkBA,MAAM,OAAO,SACX,SAAS,QAAQ,SAAS,KAAA,IACtB,CAAC,IACD,CACE,MACA,IAAI,KAAK,YAAY,CAAC,EAAA,CAAG,SAAQ,UAAU,OAAO,UAAU,WAAW,CAAC,IAAI,IAAI,KAAK,CAAE,CACzF;;AAGN,MAAM,YAAY,UACf,MAAM,YAAY,CAAC,EAAA,CAAG,QAAQ,UAAyB,OAAO,UAAU,QAAQ;;AAGnF,MAAM,SAAS,MAAwB,QACrC,IAAI,IAAI,CAAC,CAAC,QAAO,SAAQ,KAAK,QAAQ,GAAG;;AAG3C,MAAM,QAAQ,SACZ,IAAI,IAAI,CAAC,CACN,KAAI,SAAQ,KAAK,QAAQ,EAAE,CAAC,CAC5B,KAAK,EAAE;;AAGZ,MAAM,gBAAkD;CAAE,KAAK;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,EAAE,GAClE,GAAG,OAAO,SAAS,GAAG,WACpB,MAAM,KAAK,MAAM,SAAS,UAAU,IAAI,GAAG,UAAU,QAAQ,EAAE,CACjE,CACF,CAAC;CACD,MAAM,UAAU,IAAI,IAAI,OAAO,KAAK,CAAC,cAAc,QAAQ,CAAC;CAC5D,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC,QACf,SACE,SAAS,MACT,CAAC,WAAW,SAAS,GAAG,KAAK,EAAE,KAC/B,CAAC,MAAM,SAAS,GAAG,KAAK,EAAE,KAC1B,CAAC,QAAQ,IAAI,IAAI,CACrB;AACF;AAEA,MAAa,QAAQ;CACnB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF"}
1
+ {"version":3,"file":"testing.mjs","names":[],"sources":["../src/testing.ts"],"sourcesContent":["/**\n * `foldkit-mixins/testing`: queries over a view drawn with the inert builder\n * (`SlotView.inertBuilder()`), for tests that check what a view draws without\n * a DOM. They read an element as the browser would: an attribute or a\n * property, whichever the builder wrote, so a test need not know that `title`\n * and `value` are properties while `aria-label` is an attribute. `Frames.hold`\n * is for tests on the real runtime: input faster than a frame.\n */\nimport { Option } from 'effect'\nimport type { Html, HtmlBuilder } from 'foldkit/html'\nimport { given, scene, tap } from 'foldkit/scene'\nimport { usedIn } from './inject.js'\nimport { SLOT_MARK, drawMarked } from './slotMark.js'\nimport type * as SlotView from './slotView.js'\n\n/** An element or text node of an inert tree. */\nexport type Node = Exclude<Html, null>\n\n/** Every node under `root`, itself first, depth first. */\nconst all = (root: Html | undefined): ReadonlyArray<Node> =>\n root === null || root === undefined\n ? []\n : [\n root,\n ...(root.children ?? []).flatMap(child => (typeof child === 'string' ? [] : all(child))),\n ]\n\n/** A node's children that are nodes, not plain strings. */\nconst children = (node: Html | undefined): ReadonlyArray<Node> =>\n (node?.children ?? []).filter((child): child is Node => typeof child !== 'string')\n\n/** Every element under `root` with this tag. */\nconst byTag = (root: Html | undefined, tag: string): ReadonlyArray<Node> =>\n all(root).filter(node => node.sel === tag)\n\n/** The text under a node, joined. */\nconst text = (node: Html | undefined): string =>\n all(node)\n .map(each => each.text ?? '')\n .join('')\n\n/** Attributes whose property has another name. */\nconst propertyNames: Readonly<Record<string, string>> = { for: 'htmlFor', class: 'className' }\n\n/** An attribute or a property, whichever the builder wrote; the attribute first. */\nconst value = (node: Html | undefined, key: string): unknown =>\n node?.data?.attrs?.[key] ??\n node?.data?.props?.[key] ??\n node?.data?.props?.[propertyNames[key] ?? key]\n\n/** The classes on a node, in the order the builder wrote them. */\nconst classes = (node: Html | undefined): ReadonlyArray<string> =>\n Object.entries(node?.data?.class ?? {})\n .filter(([, on]) => on === true)\n .map(([name]) => name)\n\n/** The inline style on a node, empty when it has none. */\nconst style = (node: Html | undefined): Readonly<Record<string, string>> => node?.data?.style ?? {}\n\n/** Every element under `root` with this role. */\nconst byRole = (root: Html | undefined, role: string): ReadonlyArray<Node> =>\n all(root).filter(node => value(node, 'role') === role)\n\n/**\n * Every element under `root` named `label`: by its `aria-label`, by the text of\n * a `<label for>` pointing at its id, or by its own text. By text, only the\n * innermost element counts, not every ancestor whose text is the same.\n */\nconst byLabel = (root: Html | undefined, label: string): ReadonlyArray<Node> => {\n const nodes = all(root).filter(node => node.sel !== undefined)\n const labelled = new Set(\n nodes\n .filter(node => node.sel === 'label' && text(node) === label)\n .map(node => value(node, 'for')),\n )\n const byText = new Set(\n nodes.filter(\n node =>\n value(node, 'aria-label') === undefined && node.sel !== 'label' && text(node) === label,\n ),\n )\n const innermost = new Set(\n [...byText].filter(node => !all(node).some(inner => inner !== node && byText.has(inner))),\n )\n return nodes.filter(\n node =>\n value(node, 'aria-label') === label ||\n (value(node, 'id') !== undefined && labelled.has(value(node, 'id'))) ||\n innermost.has(node),\n )\n}\n\n/** Whether a toggle button is pressed; none when it is not a toggle. */\nconst pressed = (node: Html | undefined): Option.Option<boolean> =>\n Option.map(\n Option.fromUndefinedOr(value(node, 'aria-pressed')),\n state => state === 'true' || state === true,\n )\n\n/** Ends the Scene `draw` borrows once the view has drawn, before its end-of-test checks. */\nconst DRAWN = Symbol('drawn')\n\n/**\n * A SlotView drawn inert, each element a Slot draws marked with the Slot's\n * name, however deeply nested its view, for `bySlot` and `unslotted`. Only\n * here: a view drawn for real carries no mark.\n *\n * It draws under a Foldkit Scene's render frame, which `h.submodel` and a\n * Submodel's `childAttributes` need; nothing is dispatched, and no Command or\n * Mount the drawing declares is run or checked.\n */\nconst draw = <Slots, Input, Message>(\n view: SlotView.SlotView<Slots, Input, Message>,\n input: Input,\n): Html => {\n let drawn: Html = null\n const drawInto = (model: Input, h: HtmlBuilder<Message>): Html => {\n drawn = view(model, h)\n // Scene refuses a view that draws nothing; what it draws is not the result.\n return h.div([], [])\n }\n try {\n drawMarked(() =>\n scene(\n { update: (model: Input) => ({ model }), view: drawInto },\n given(input),\n tap(() => {\n throw DRAWN\n }),\n ),\n )\n } catch (error) {\n if (error !== DRAWN) throw error\n }\n return drawn\n}\n\n/** The Slot a node was drawn by, in a tree from `draw`; none for one no Slot drew. */\nconst slotOf = (node: Html | undefined): Option.Option<string> => {\n const name = value(node, `data-${SLOT_MARK}`)\n return typeof name === 'string' ? Option.some(name) : Option.none()\n}\n\n/** Every element a Slot drew, in a tree from `draw`. */\nconst bySlot = (root: Html | undefined, slot: string): ReadonlyArray<Node> =>\n all(root).filter(node => Option.contains(slotOf(node), slot))\n\n/** Where each element sits: its tags from the root, `main > nav > a`. */\nconst pathsOf = (root: Html | undefined): ReadonlyMap<Node, string> => {\n const paths = new Map<Node, string>()\n const walk = (node: Html | undefined, above: string): void => {\n if (node === null || node === undefined || node.sel === undefined) return\n const here = above === '' ? node.sel : `${above} > ${node.sel}`\n paths.set(node, here)\n for (const child of children(node)) walk(child, here)\n }\n walk(root, '')\n return paths\n}\n\n/** The elements of the package's own markup: every element, except inside a Slot named in `inside`. */\nconst own = (root: Html | undefined, inside: ReadonlyArray<string>): ReadonlyArray<Node> => {\n const skipped = new Set(inside)\n const found: Array<Node> = []\n const walk = (node: Html | undefined): void => {\n if (node === null || node === undefined || node.sel === undefined) return\n found.push(node)\n if (Option.exists(slotOf(node), name => skipped.has(name))) return\n for (const child of children(node)) walk(child)\n }\n walk(root)\n return found\n}\n\n/**\n * Every element in a tree from `draw` that no Slot drew, by its path: markup a\n * stylist could reach only through a selector into the package. What a Slot\n * named in `inside` holds is not the package's, such as a canvas drawing the\n * application's own page, and is skipped.\n */\nconst unslotted = (\n root: Html | undefined,\n options: { readonly inside?: ReadonlyArray<string> } = {},\n): ReadonlyArray<string> => {\n const paths = pathsOf(root)\n return own(root, options.inside ?? [])\n .filter(node => Option.isNone(slotOf(node)))\n .map(node => paths.get(node) ?? node.sel ?? '')\n}\n\n/**\n * Every inline declaration that is not a custom property, by its element's\n * path, skipping what a Slot named in `inside` holds: a fixed value inline\n * outranks every rule, so a later layer could not override it. A value known\n * only per element belongs in a custom property that a rule reads.\n */\nconst fixedInline = (\n root: Html | undefined,\n options: { readonly inside?: ReadonlyArray<string> } = {},\n): ReadonlyArray<string> => {\n const paths = pathsOf(root)\n return own(root, options.inside ?? []).flatMap(node =>\n Object.keys(style(node))\n .filter(property => !property.startsWith('--'))\n .map(property => `${paths.get(node) ?? node.sel ?? ''}: ${property}`),\n )\n}\n\n/** The compiled CSS behind the classes on `nodes`, after the standard layer order. */\nconst css = (nodes: ReadonlyArray<Html>): string => usedIn(nodes.flatMap(classes).join(' '))\n\nconst TOKEN_READ = /var\\((--fk-[\\w-]+)\\)/g\n\n/**\n * The `--fk-*` tokens the tree's Styles read with no fallback and that\n * nothing defines, in first-read order: not `stylesheet`, not a drawn rule,\n * not an inline style. Such a read makes its declaration invalid, so a test\n * asserts `toEqual([])`. A tree whose Styles read no token passes too; check\n * `css` for `var(--fk-` when that would be a mistake.\n */\nconst missingTokens = (root: Html, stylesheet: string): ReadonlyArray<string> => {\n const nodes = all(root)\n const drawn = css(nodes)\n const inline = nodes.flatMap(node => Object.entries(style(node)))\n const read = new Set([\n ...Array.from(drawn.matchAll(TOKEN_READ), ([, name]) => name ?? ''),\n ...inline.flatMap(([, value]) =>\n Array.from(value.matchAll(TOKEN_READ), ([, name]) => name ?? ''),\n ),\n ])\n const defined = new Set(inline.map(([property]) => property))\n return [...read].filter(\n name =>\n name !== '' &&\n !stylesheet.includes(`${name}:`) &&\n !drawn.includes(`${name}:`) &&\n !defined.has(name),\n )\n}\n\nexport const Inert = {\n draw,\n css,\n missingTokens,\n bySlot,\n unslotted,\n fixedInline,\n all,\n children,\n byTag,\n text,\n value,\n classes,\n style,\n byRole,\n byLabel,\n pressed,\n} as const\n\n/** Something with work of its own to finish before a page is settled, such as `Sync.mount`'s handle. */\nexport interface Settles {\n readonly settled: () => Promise<void>\n}\n\n/** The page's animation frames, tracked: held, released, and waited for. */\nexport interface TrackedFrames {\n /** Holds every frame asked for from now until `release`: nothing is drawn meanwhile. */\n readonly hold: () => void\n /** Runs the held frames, and lets those after run as they are asked for. */\n readonly release: () => void\n /**\n * Resolves once nothing is left to draw: every frame asked for has run, and\n * a turn of the event loop after the last asked for no other. Each of\n * `barriers` settles first, and the two are waited for again until both\n * are quiet in one round, since a frame can lead to a dispatch and a\n * dispatch to a frame. Rejects while frames are held, and after 50 rounds\n * of frames that keep coming. It knows only frames asked for: a runtime\n * still starting has asked for none, so wait for its first drawing, and\n * for I/O a Command started, before settling what follows.\n */\n readonly settle: (...barriers: ReadonlyArray<Settles>) => Promise<void>\n /** Puts back the frame functions it replaced. */\n readonly dispose: () => void\n}\n\nconst rounds = 50\nconst turn = () => new Promise<void>(resolve => setTimeout(resolve, 0))\n\nconst track = (): TrackedFrames => {\n const request = globalThis.requestAnimationFrame\n const cancel = globalThis.cancelAnimationFrame\n // Frames asked for and not yet run, by the id this hands out.\n const waiting = new Map<number, number>()\n const held: Array<{ readonly id: number; readonly callback: FrameRequestCallback }> = []\n let holding = false\n let next = 0\n let ran: Array<() => void> = []\n const ranOne = () => {\n for (const resolve of ran.splice(0)) resolve()\n }\n const schedule = (id: number, callback: FrameRequestCallback) =>\n waiting.set(\n id,\n request(time => {\n waiting.delete(id)\n try {\n callback(time)\n } finally {\n ranOne()\n }\n }),\n )\n globalThis.requestAnimationFrame = callback => {\n const id = ++next\n if (holding) {\n waiting.set(id, -1)\n held.push({ id, callback })\n } else schedule(id, callback)\n return id\n }\n globalThis.cancelAnimationFrame = id => {\n const underlying = waiting.get(id)\n waiting.delete(id)\n const index = held.findIndex(frame => frame.id === id)\n if (index !== -1) held.splice(index, 1)\n if (underlying !== undefined && underlying !== -1) cancel(underlying)\n }\n const aFrame = () => new Promise<void>(resolve => ran.push(resolve))\n return {\n hold: () => {\n holding = true\n },\n release: () => {\n holding = false\n for (const { id, callback } of held.splice(0)) schedule(id, callback)\n },\n settle: async (...barriers) => {\n for (let round = 0; round < rounds; round++) {\n if (holding) {\n throw new Error('Frames.settle: frames are held; release them first.')\n }\n for (const barrier of barriers) await barrier.settled()\n if (waiting.size > 0) {\n await aFrame()\n continue\n }\n // A turn after the last frame: Foldkit may finish a transition on a\n // task of its own and ask for another.\n await turn()\n if (waiting.size === 0) return\n }\n const hidden =\n typeof document !== 'undefined' && document.visibilityState === 'hidden'\n ? ' The document is hidden, and a hidden page runs no frames.'\n : ''\n throw new Error(\n `Frames.settle: still drawing after ${rounds} rounds (a Mount or an animation keeps asking for frames).${hidden}`,\n )\n },\n dispose: () => {\n globalThis.requestAnimationFrame = request\n globalThis.cancelAnimationFrame = cancel\n ranOne()\n },\n }\n}\n\n/**\n * The page's animation frames, tracked from the moment `track` is called.\n * Foldkit draws on `requestAnimationFrame`, so `settle` waits for what a\n * transition asked to draw, instead of a sleep that guesses how long that\n * takes, and `hold` keeps every frame back so events meet the view as it\n * was last drawn, as keys and clicks faster than a frame do. Call it after\n * any stub of `requestAnimationFrame`, since it wraps whichever is installed.\n */\nexport const Frames = { track } as const\n"],"mappings":";;;;;;;;;;;;;AAmBA,MAAM,OAAO,SACX,SAAS,QAAQ,SAAS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CAAsC,OAAO,4DAA4D,QAC3G;EACF;EACA,eAAe;GACb,WAAW,wBAAwB;GACnC,WAAW,uBAAuB;GAClC,OAAO;EACT;CACF;AACF;;;;;;;;;AAUA,MAAa,SAAS,EAAE,MAAM"}
package/dist/theme.d.mts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { o as StyleValue } from "./styleValue-BavTe9MZ.mjs";
2
2
  import { a as compose, c as lightDark, i as VAR_PREFIX, l as ref, n as Theme$1, o as core_d_exports, r as ThemeTokens, s as define, t as Refs, u as variables } from "./core-CUw_n1Nd.mjs";
3
3
  import { i as scoped, n as RootOptions, r as root, t as Overrides } from "./root-xyWS6geK.mjs";
4
- import { i as tokens, n as breakpointWidths, r as inContainer, t as Tokens } from "./tokens-BR_qxDR7.mjs";
5
- import { n as OklchTheme, r as oklch, t as OklchKnobs } from "./oklch-BxvCD0oi.mjs";
4
+ import { i as tokens, n as breakpointWidths, r as inContainer, t as Tokens } from "./tokens-XZSP0AvO.mjs";
5
+ import { n as OklchTheme, r as oklch, t as OklchKnobs } from "./oklch-FOemcYSv.mjs";
6
6
  //#region src/theme.d.ts
7
7
  export declare const Theme: {
8
8
  readonly root: (theme: ThemeTokens, options?: RootOptions) => StyleValue;
@@ -68,6 +68,14 @@ export declare const Theme: {
68
68
  thick: string;
69
69
  heavy: string;
70
70
  };
71
+ shadow: {
72
+ xs: string;
73
+ sm: string;
74
+ md: string;
75
+ lg: string;
76
+ xl: string;
77
+ inset: string;
78
+ };
71
79
  breakpoint: {
72
80
  sm: string;
73
81
  md: string;
@@ -153,6 +161,9 @@ export declare const Theme: {
153
161
  'on-fill': string;
154
162
  ink: string;
155
163
  };
164
+ shadow: {
165
+ color: string;
166
+ };
156
167
  success: {
157
168
  default: string;
158
169
  subtle: string;
@@ -1 +1 @@
1
- {"version":3,"file":"theme.d.mts","names":[],"sources":["../src/theme.ts"],"mappings":";;;;;;qBAoBa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;WASyoE,cAAA,oBAAA,SAAA,yBAAA,cAAA,aAAA,4BAAS,WAAA;0BAAA"}
1
+ {"version":3,"file":"theme.d.mts","names":[],"sources":["../src/theme.ts"],"mappings":";;;;;;qBAoBa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;WAS42F,cAAA,oBAAA,SAAA,yBAAA,cAAA,aAAA,4BAAS,WAAA;0BAAA"}
package/dist/theme.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { a as lightDark, i as define, n as VAR_PREFIX, o as ref, r as compose, s as variables, t as Theme$1 } from "./core-Bxj0UQDF.mjs";
2
2
  import { n as scoped, t as root } from "./root-C1u12YMD.mjs";
3
- import { n as inContainer, r as tokens, t as breakpointWidths } from "./tokens-DteBJVN-.mjs";
3
+ import { n as inContainer, r as tokens, t as breakpointWidths } from "./tokens-O8S8QH_R.mjs";
4
4
  //#region src/theme/oklch.ts
5
5
  /**
6
6
  * A whole palette from a few knobs, as css-tags derives it: every value
@@ -117,6 +117,7 @@ const oklch = (knobs) => {
117
117
  accent: family("accent", ld(`oklch(${v("knob", "accent-l")} ${v("knob", "accent-c")} ${v("hue", "accent")})`, `oklch(${v("knob", "accent-l-dark")} ${v("knob", "accent-c-dark")} ${v("hue", "accent")})`)),
118
118
  secondary: family("secondary", rehue(accent, v("hue", "secondary"))),
119
119
  tertiary: family("tertiary", rehue(accent, v("hue", "tertiary"))),
120
+ shadow: { color: ld(`oklch(25% calc(${surfaceC} * 2) ${neutral} / 0.14)`, `oklch(5% calc(${surfaceCDark} * 2) ${neutral} / 0.6)`) },
120
121
  success: feedback("success", 55, .15),
121
122
  warning: feedback("warning", 70, .15),
122
123
  error: feedback("error", 60, .2),
@@ -1 +1 @@
1
- {"version":3,"file":"theme.mjs","names":["Core.Theme"],"sources":["../src/theme/oklch.ts","../src/theme.ts"],"sourcesContent":["/**\n * A whole palette from a few knobs, as css-tags derives it: every value\n * except the knobs is a CSS expression over other tokens, so overriding a\n * knob anywhere (a scoped theme, a subtree, an inline style) re-derives the\n * rest in the browser. Where light and dark schemes need different numbers\n * the value is a `light-dark()` pair, so one theme serves both and a user's\n * choice is a `color-scheme` override.\n */\nimport { define } from './core.js'\n\nexport interface OklchKnobs {\n /** The brand color: hue in degrees, chroma 0–0.4, lightness as a percentage. */\n readonly accent: {\n readonly h: number\n readonly c: number\n readonly l: string\n /** Lighter and stronger on dark surfaces; defaults `70%` and `c + 0.03`. */\n readonly dark?: { readonly l?: string; readonly c?: number }\n }\n /** Degrees added to the accent hue for the secondary and tertiary families. */\n readonly secondaryHueShift?: number\n readonly tertiaryHueShift?: number\n /** Chroma of neutral surfaces; 0 is gray. */\n readonly surfaceSaturation?: number\n /** How far apart the surface steps are, 0–100%. */\n readonly surfaceContrast?: string\n /** Multiplies text chroma. */\n readonly contrastFactor?: number\n /** Hues of the feedback families. */\n readonly feedback?: {\n readonly success?: number\n readonly warning?: number\n readonly error?: number\n readonly info?: number\n }\n}\n\nconst v = (group: string, name: string) => `var(--fk-${group}-${name})`\n/** A computed knob without float noise: `0.02`, not `0.019999999999999997`. */\nconst num = (value: number) => String(Number(value.toFixed(4)))\nconst ld = (light: string, dark: string) => `light-dark(${light}, ${dark})`\nconst offset = (amount: number) => `${amount < 0 ? '-' : '+'} ${Math.abs(amount)}`\n/** `oklch(from <color> …)` with the hue kept. */\nconst from = (color: string, l: string, c: string) => `oklch(from ${color} ${l} ${c} h)`\nconst shift = (color: string, dl: number, dc: number) =>\n from(color, `calc(l ${offset(dl)})`, `calc(c ${offset(dc)})`)\nconst scale = (color: string, dl: number, cx: number) =>\n from(color, `calc(l ${offset(dl)})`, `calc(c * ${cx})`)\n/** The same lightness and chroma as `color` on another hue. */\nconst rehue = (color: string, hue: string) => `oklch(from ${color} l c ${hue})`\n/** Near-black or near-white text over `color`. */\nconst contrast = (color: string) =>\n `oklch(from ${color} clamp(0.1, (0.65 / l - 1) * 999, 0.98) min(c, 0.08) h)`\n/** `color` as text on the base surface: dark in a light scheme, light in a dark one. */\nconst ink = (color: string) => ld(from(color, '0.5', 'c'), from(color, '0.8', 'c'))\n/** `color` tinted onto the base surface, the same in both schemes. */\nconst tint = (color: string, percent: number) =>\n `color-mix(in oklch, ${v('surface', 'base')} ${percent}%, ${color})`\n\n/** The default text color at `percent` over the base surface. */\nconst line = (percent: number) =>\n `color-mix(in oklch, ${v('text', 'default')} ${percent}%, ${v('surface', 'base')})`\n\nconst neutral = v('hue', 'neutral')\nconst base = v('surface', 'base')\nconst surfaceC = v('knob', 'surface-c')\nconst surfaceCDark = v('knob', 'surface-c-dark')\nconst contrastFactor = v('knob', 'contrast-factor')\n\ntype Step = readonly [lightness: number, chroma: number]\n\n/** A surface step: the base mixed toward a target by `surface-contrast`. */\nconst surfaceStep = (light: Step, dark: Step) => {\n const amount = v('knob', 'surface-contrast')\n const target = ld(scale(base, light[0], light[1]), scale(base, dark[0], dark[1]))\n return `color-mix(in oklch, ${base} calc(100% - ${amount}), ${target} ${amount})`\n}\n\n/** A text color: fixed lightness, chroma scaled by surface saturation and the contrast factor. */\nconst text = (light: Step, dark: Step) =>\n ld(\n `oklch(${light[0]}% calc(${surfaceC} * ${light[1]} * ${contrastFactor}) ${neutral})`,\n `oklch(${dark[0]}% calc(${surfaceCDark} * ${dark[1]} * ${contrastFactor}) ${neutral})`,\n )\n\nconst family = (name: string, defaultValue: string) => {\n const color = v(name, 'default')\n return {\n default: defaultValue,\n hover: shift(color, -0.06, 0),\n active: shift(color, -0.1, 0.05),\n subtle: tint(color, 85),\n 'on-fill': contrast(color),\n ink: ink(color),\n }\n}\n\nconst feedback = (name: string, l: number, c: number) => {\n const color = v(name, 'default')\n return {\n default: `oklch(${l}% ${c} ${v('knob', `${name}-h`)})`,\n subtle: tint(color, 85),\n 'on-fill': contrast(color),\n ink: ink(color),\n outline: shift(color, -0.05, 0),\n }\n}\n\nexport const oklch = (knobs: OklchKnobs) => {\n const accent = v('accent', 'default')\n const surfaceSaturation = knobs.surfaceSaturation ?? 0.015\n return define({\n knob: {\n 'accent-h': String(knobs.accent.h),\n 'accent-c': String(knobs.accent.c),\n 'accent-l': knobs.accent.l,\n 'accent-c-dark': num(knobs.accent.dark?.c ?? Math.min(0.4, knobs.accent.c + 0.03)),\n 'accent-l-dark': knobs.accent.dark?.l ?? '70%',\n 'secondary-shift': String(knobs.secondaryHueShift ?? 60),\n 'tertiary-shift': String(knobs.tertiaryHueShift ?? -90),\n 'surface-c': String(surfaceSaturation),\n 'surface-c-dark': num(surfaceSaturation * (4 / 3)),\n 'surface-contrast': knobs.surfaceContrast ?? '65%',\n 'contrast-factor': String(knobs.contrastFactor ?? 1),\n 'base-l': '97.5%',\n 'base-l-dark': '22%',\n 'success-h': String(knobs.feedback?.success ?? 145),\n 'warning-h': String(knobs.feedback?.warning ?? 75),\n 'error-h': String(knobs.feedback?.error ?? 25),\n 'info-h': String(knobs.feedback?.info ?? 245),\n },\n hue: {\n accent: v('knob', 'accent-h'),\n secondary: `calc(${v('knob', 'accent-h')} + ${v('knob', 'secondary-shift')})`,\n tertiary: `calc(${v('knob', 'accent-h')} + ${v('knob', 'tertiary-shift')})`,\n neutral: v('hue', 'accent'),\n },\n surface: {\n base: ld(\n `oklch(${v('knob', 'base-l')} calc(${surfaceC} * 0.9) ${neutral})`,\n `oklch(${v('knob', 'base-l-dark')} calc(${surfaceCDark} * 0.9) ${neutral})`,\n ),\n muted: surfaceStep([-0.04, 0.8], [-0.03, 0.5]),\n subtle: surfaceStep([-0.025, 1.05], [-0.015, 0.7]),\n default: surfaceStep([-0.055, 1.2], [0.045, 1]),\n overt: surfaceStep([-0.31, 2.25], [0.125, 1.2]),\n bedrock: ld(\n `oklch(8% calc(${surfaceC} * 1.2) ${neutral})`,\n `oklch(98% calc(${surfaceCDark} * 0.7) ${neutral})`,\n ),\n },\n text: {\n default: text([20, 2], [88, 0.8]),\n muted: text([45, 1.5], [65, 1.2]),\n subtle: text([35, 1.8], [75, 1]),\n overt: text([10, 2.2], [95, 0.6]),\n link: shift(accent, 0.1, 0.05),\n 'link-hover': shift(v('text', 'link'), -0.1, 0),\n },\n // Text mixed into the base: darker than the surface in a light scheme,\n // lighter in a dark one, so a line separates in both from one expression.\n outline: {\n subtle: line(10),\n default: line(18),\n overt: line(35),\n focus: shift(accent, -0.1, 0.1),\n },\n accent: family(\n 'accent',\n ld(\n `oklch(${v('knob', 'accent-l')} ${v('knob', 'accent-c')} ${v('hue', 'accent')})`,\n `oklch(${v('knob', 'accent-l-dark')} ${v('knob', 'accent-c-dark')} ${v('hue', 'accent')})`,\n ),\n ),\n secondary: family('secondary', rehue(accent, v('hue', 'secondary'))),\n tertiary: family('tertiary', rehue(accent, v('hue', 'tertiary'))),\n success: feedback('success', 55, 0.15),\n warning: feedback('warning', 70, 0.15),\n error: feedback('error', 60, 0.2),\n info: feedback('info', 65, 0.15),\n })\n}\n\nexport type OklchTheme = ReturnType<typeof oklch>\n","/**\n * `foldkit-mixins/theme`: the root export's `Theme` plus the page-level\n * pieces. `root` and `scoped` turn tokens into unlayered `:root` and\n * selector rules for `Style.stylesheet`; `tokens` is the shipped set of\n * non-color scales; `oklch` derives a whole palette from a few knobs.\n */\nimport * as Core from './theme/core.js'\nimport { oklch } from './theme/oklch.js'\nimport { root, scoped } from './theme/root.js'\nimport { breakpointWidths, inContainer, tokens } from './theme/tokens.js'\n\nexport { compose, define, lightDark, ref, variables, VAR_PREFIX } from './theme/core.js'\nexport type { Refs, Theme as ThemeValue, ThemeTokens } from './theme/core.js'\nexport { root, scoped } from './theme/root.js'\nexport type { Overrides, RootOptions } from './theme/root.js'\nexport { breakpointWidths, inContainer, tokens } from './theme/tokens.js'\nexport type { Tokens } from './theme/tokens.js'\nexport { oklch } from './theme/oklch.js'\nexport type { OklchKnobs, OklchTheme } from './theme/oklch.js'\n\nexport const Theme = {\n ...Core.Theme,\n root,\n scoped,\n tokens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AAQ,EACnD;EACF;EACA,MAAM;GACJ,SAAS,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAG,CAAC;GAChC,OAAO,KAAK,CAAC,IAAI,GAAG,GAAG,CAAC,IAAI,GAAG,CAAC;GAChC,QAAQ,KAAK,CAAC,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC,CAAC;GAC/B,OAAO,KAAK,CAAC,IAAI,GAAG,GAAG,CAAC,IAAI,EAAG,CAAC;GAChC,MAAM,MAAM,QAAQ,IAAK,GAAI;GAC7B,cAAc,MAAM,EAAE,QAAQ,MAAM,GAAG,KAAM,CAAC;EAChD;EAGA,SAAS;GACP,QAAQ,KAAK,EAAE;GACf,SAAS,KAAK,EAAE;GAChB,OAAO,KAAK,EAAE;GACd,OAAO,MAAM,QAAQ,KAAM,EAAG;EAChC;EACA,QAAQ,OACN,UACA,GACE,SAAS,EAAE,QAAQ,UAAU,EAAE,GAAG,EAAE,QAAQ,UAAU,EAAE,GAAG,EAAE,OAAO,QAAQ,EAAE,IAC9E,SAAS,EAAE,QAAQ,eAAe,EAAE,GAAG,EAAE,QAAQ,eAAe,EAAE,GAAG,EAAE,OAAO,QAAQ,EAAE,EAC1F,CACF;EACA,WAAW,OAAO,aAAa,MAAM,QAAQ,EAAE,OAAO,WAAW,CAAC,CAAC;EACnE,UAAU,OAAO,YAAY,MAAM,QAAQ,EAAE,OAAO,UAAU,CAAC,CAAC;EAChE,SAAS,SAAS,WAAW,IAAI,GAAI;EACrC,SAAS,SAAS,WAAW,IAAI,GAAI;EACrC,OAAO,SAAS,SAAS,IAAI,EAAG;EAChC,MAAM,SAAS,QAAQ,IAAI,GAAI;CACjC,CAAC;AACH;;;;;;;;;ACjKA,MAAa,QAAQ;CACnB,GAAGA;CACH;CACA;CACA;CACA;CACA;CACA;AACF"}
1
+ {"version":3,"file":"theme.mjs","names":["Core.Theme"],"sources":["../src/theme/oklch.ts","../src/theme.ts"],"sourcesContent":["/**\n * A whole palette from a few knobs, as css-tags derives it: every value\n * except the knobs is a CSS expression over other tokens, so overriding a\n * knob anywhere (a scoped theme, a subtree, an inline style) re-derives the\n * rest in the browser. Where light and dark schemes need different numbers\n * the value is a `light-dark()` pair, so one theme serves both and a user's\n * choice is a `color-scheme` override.\n */\nimport { define } from './core.js'\n\nexport interface OklchKnobs {\n /** The brand color: hue in degrees, chroma 0–0.4, lightness as a percentage. */\n readonly accent: {\n readonly h: number\n readonly c: number\n readonly l: string\n /** Lighter and stronger on dark surfaces; defaults `70%` and `c + 0.03`. */\n readonly dark?: { readonly l?: string; readonly c?: number }\n }\n /** Degrees added to the accent hue for the secondary and tertiary families. */\n readonly secondaryHueShift?: number\n readonly tertiaryHueShift?: number\n /** Chroma of neutral surfaces; 0 is gray. */\n readonly surfaceSaturation?: number\n /** How far apart the surface steps are, 0–100%. */\n readonly surfaceContrast?: string\n /** Multiplies text chroma. */\n readonly contrastFactor?: number\n /** Hues of the feedback families. */\n readonly feedback?: {\n readonly success?: number\n readonly warning?: number\n readonly error?: number\n readonly info?: number\n }\n}\n\nconst v = (group: string, name: string) => `var(--fk-${group}-${name})`\n/** A computed knob without float noise: `0.02`, not `0.019999999999999997`. */\nconst num = (value: number) => String(Number(value.toFixed(4)))\nconst ld = (light: string, dark: string) => `light-dark(${light}, ${dark})`\nconst offset = (amount: number) => `${amount < 0 ? '-' : '+'} ${Math.abs(amount)}`\n/** `oklch(from <color> …)` with the hue kept. */\nconst from = (color: string, l: string, c: string) => `oklch(from ${color} ${l} ${c} h)`\nconst shift = (color: string, dl: number, dc: number) =>\n from(color, `calc(l ${offset(dl)})`, `calc(c ${offset(dc)})`)\nconst scale = (color: string, dl: number, cx: number) =>\n from(color, `calc(l ${offset(dl)})`, `calc(c * ${cx})`)\n/** The same lightness and chroma as `color` on another hue. */\nconst rehue = (color: string, hue: string) => `oklch(from ${color} l c ${hue})`\n/** Near-black or near-white text over `color`. */\nconst contrast = (color: string) =>\n `oklch(from ${color} clamp(0.1, (0.65 / l - 1) * 999, 0.98) min(c, 0.08) h)`\n/** `color` as text on the base surface: dark in a light scheme, light in a dark one. */\nconst ink = (color: string) => ld(from(color, '0.5', 'c'), from(color, '0.8', 'c'))\n/** `color` tinted onto the base surface, the same in both schemes. */\nconst tint = (color: string, percent: number) =>\n `color-mix(in oklch, ${v('surface', 'base')} ${percent}%, ${color})`\n\n/** The default text color at `percent` over the base surface. */\nconst line = (percent: number) =>\n `color-mix(in oklch, ${v('text', 'default')} ${percent}%, ${v('surface', 'base')})`\n\nconst neutral = v('hue', 'neutral')\nconst base = v('surface', 'base')\nconst surfaceC = v('knob', 'surface-c')\nconst surfaceCDark = v('knob', 'surface-c-dark')\nconst contrastFactor = v('knob', 'contrast-factor')\n\ntype Step = readonly [lightness: number, chroma: number]\n\n/** A surface step: the base mixed toward a target by `surface-contrast`. */\nconst surfaceStep = (light: Step, dark: Step) => {\n const amount = v('knob', 'surface-contrast')\n const target = ld(scale(base, light[0], light[1]), scale(base, dark[0], dark[1]))\n return `color-mix(in oklch, ${base} calc(100% - ${amount}), ${target} ${amount})`\n}\n\n/** A text color: fixed lightness, chroma scaled by surface saturation and the contrast factor. */\nconst text = (light: Step, dark: Step) =>\n ld(\n `oklch(${light[0]}% calc(${surfaceC} * ${light[1]} * ${contrastFactor}) ${neutral})`,\n `oklch(${dark[0]}% calc(${surfaceCDark} * ${dark[1]} * ${contrastFactor}) ${neutral})`,\n )\n\nconst family = (name: string, defaultValue: string) => {\n const color = v(name, 'default')\n return {\n default: defaultValue,\n hover: shift(color, -0.06, 0),\n active: shift(color, -0.1, 0.05),\n subtle: tint(color, 85),\n 'on-fill': contrast(color),\n ink: ink(color),\n }\n}\n\nconst feedback = (name: string, l: number, c: number) => {\n const color = v(name, 'default')\n return {\n default: `oklch(${l}% ${c} ${v('knob', `${name}-h`)})`,\n subtle: tint(color, 85),\n 'on-fill': contrast(color),\n ink: ink(color),\n outline: shift(color, -0.05, 0),\n }\n}\n\nexport const oklch = (knobs: OklchKnobs) => {\n const accent = v('accent', 'default')\n const surfaceSaturation = knobs.surfaceSaturation ?? 0.015\n return define({\n knob: {\n 'accent-h': String(knobs.accent.h),\n 'accent-c': String(knobs.accent.c),\n 'accent-l': knobs.accent.l,\n 'accent-c-dark': num(knobs.accent.dark?.c ?? Math.min(0.4, knobs.accent.c + 0.03)),\n 'accent-l-dark': knobs.accent.dark?.l ?? '70%',\n 'secondary-shift': String(knobs.secondaryHueShift ?? 60),\n 'tertiary-shift': String(knobs.tertiaryHueShift ?? -90),\n 'surface-c': String(surfaceSaturation),\n 'surface-c-dark': num(surfaceSaturation * (4 / 3)),\n 'surface-contrast': knobs.surfaceContrast ?? '65%',\n 'contrast-factor': String(knobs.contrastFactor ?? 1),\n 'base-l': '97.5%',\n 'base-l-dark': '22%',\n 'success-h': String(knobs.feedback?.success ?? 145),\n 'warning-h': String(knobs.feedback?.warning ?? 75),\n 'error-h': String(knobs.feedback?.error ?? 25),\n 'info-h': String(knobs.feedback?.info ?? 245),\n },\n hue: {\n accent: v('knob', 'accent-h'),\n secondary: `calc(${v('knob', 'accent-h')} + ${v('knob', 'secondary-shift')})`,\n tertiary: `calc(${v('knob', 'accent-h')} + ${v('knob', 'tertiary-shift')})`,\n neutral: v('hue', 'accent'),\n },\n surface: {\n base: ld(\n `oklch(${v('knob', 'base-l')} calc(${surfaceC} * 0.9) ${neutral})`,\n `oklch(${v('knob', 'base-l-dark')} calc(${surfaceCDark} * 0.9) ${neutral})`,\n ),\n muted: surfaceStep([-0.04, 0.8], [-0.03, 0.5]),\n subtle: surfaceStep([-0.025, 1.05], [-0.015, 0.7]),\n default: surfaceStep([-0.055, 1.2], [0.045, 1]),\n overt: surfaceStep([-0.31, 2.25], [0.125, 1.2]),\n bedrock: ld(\n `oklch(8% calc(${surfaceC} * 1.2) ${neutral})`,\n `oklch(98% calc(${surfaceCDark} * 0.7) ${neutral})`,\n ),\n },\n text: {\n default: text([20, 2], [88, 0.8]),\n muted: text([45, 1.5], [65, 1.2]),\n subtle: text([35, 1.8], [75, 1]),\n overt: text([10, 2.2], [95, 0.6]),\n link: shift(accent, 0.1, 0.05),\n 'link-hover': shift(v('text', 'link'), -0.1, 0),\n },\n // Text mixed into the base: darker than the surface in a light scheme,\n // lighter in a dark one, so a line separates in both from one expression.\n outline: {\n subtle: line(10),\n default: line(18),\n overt: line(35),\n focus: shift(accent, -0.1, 0.1),\n },\n accent: family(\n 'accent',\n ld(\n `oklch(${v('knob', 'accent-l')} ${v('knob', 'accent-c')} ${v('hue', 'accent')})`,\n `oklch(${v('knob', 'accent-l-dark')} ${v('knob', 'accent-c-dark')} ${v('hue', 'accent')})`,\n ),\n ),\n secondary: family('secondary', rehue(accent, v('hue', 'secondary'))),\n tertiary: family('tertiary', rehue(accent, v('hue', 'tertiary'))),\n // A near-black of the neutral hue: faint on a light surface, and denser\n // on a dark one, where a light shadow would read as a glow.\n shadow: {\n color: ld(\n `oklch(25% calc(${surfaceC} * 2) ${neutral} / 0.14)`,\n `oklch(5% calc(${surfaceCDark} * 2) ${neutral} / 0.6)`,\n ),\n },\n success: feedback('success', 55, 0.15),\n warning: feedback('warning', 70, 0.15),\n error: feedback('error', 60, 0.2),\n info: feedback('info', 65, 0.15),\n })\n}\n\nexport type OklchTheme = ReturnType<typeof oklch>\n","/**\n * `foldkit-mixins/theme`: the root export's `Theme` plus the page-level\n * pieces. `root` and `scoped` turn tokens into unlayered `:root` and\n * selector rules for `Style.stylesheet`; `tokens` is the shipped set of\n * non-color scales; `oklch` derives a whole palette from a few knobs.\n */\nimport * as Core from './theme/core.js'\nimport { oklch } from './theme/oklch.js'\nimport { root, scoped } from './theme/root.js'\nimport { breakpointWidths, inContainer, tokens } from './theme/tokens.js'\n\nexport { compose, define, lightDark, ref, variables, VAR_PREFIX } from './theme/core.js'\nexport type { Refs, Theme as ThemeValue, ThemeTokens } from './theme/core.js'\nexport { root, scoped } from './theme/root.js'\nexport type { Overrides, RootOptions } from './theme/root.js'\nexport { breakpointWidths, inContainer, tokens } from './theme/tokens.js'\nexport type { Tokens } from './theme/tokens.js'\nexport { oklch } from './theme/oklch.js'\nexport type { OklchKnobs, OklchTheme } from './theme/oklch.js'\n\nexport const Theme = {\n ...Core.Theme,\n root,\n scoped,\n tokens,\n breakpointWidths,\n inContainer,\n oklch,\n} as const\n"],"mappings":";;;;;;;;;;;;AAqCA,MAAM,KAAK,OAAe,SAAiB,YAAY,MAAM,GAAG,KAAK;;AAErE,MAAM,OAAO,UAAkB,OAAO,OAAO,MAAM,QAAQ,CAAC,CAAC,CAAC;AAC9D,MAAM,MAAM,OAAe,SAAiB,cAAc,MAAM,IAAI,KAAK;AACzE,MAAM,UAAU,WAAmB,GAAG,SAAS,IAAI,MAAM,IAAI,GAAG,KAAK,IAAI,MAAM;;AAE/E,MAAM,QAAQ,OAAe,GAAW,MAAc,cAAc,MAAM,GAAG,EAAE,GAAG,EAAE;AACpF,MAAM,SAAS,OAAe,IAAY,OACxC,KAAK,OAAO,UAAU,OAAO,EAAE,EAAE,IAAI,UAAU,OAAO,EAAE,EAAE,EAAE;AAC9D,MAAM,SAAS,OAAe,IAAY,OACxC,KAAK,OAAO,UAAU,OAAO,EAAE,EAAE,IAAI,YAAY,GAAG,EAAE;;AAExD,MAAM,SAAS,OAAe,QAAgB,cAAc,MAAM,OAAO,IAAI;;AAE7E,MAAM,YAAY,UAChB,cAAc,MAAM;;AAEtB,MAAM,OAAO,UAAkB,GAAG,KAAK,OAAO,OAAO,GAAG,GAAG,KAAK,OAAO,OAAO,GAAG,CAAC;;AAElF,MAAM,QAAQ,OAAe,YAC3B,uBAAuB,EAAE,WAAW,MAAM,EAAE,GAAG,QAAQ,KAAK,MAAM;;AAGpE,MAAM,QAAQ,YACZ,uBAAuB,EAAE,QAAQ,SAAS,EAAE,GAAG,QAAQ,KAAK,EAAE,WAAW,MAAM,EAAE;AAEnF,MAAM,UAAU,EAAE,OAAO,SAAS;AAClC,MAAM,OAAO,EAAE,WAAW,MAAM;AAChC,MAAM,WAAW,EAAE,QAAQ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I,EAAG;EAChC,MAAM,SAAS,QAAQ,IAAI,GAAI;CACjC,CAAC;AACH;;;;;;;;;ACzKA,MAAa,QAAQ;CACnB,GAAGA;CACH;CACA;CACA;CACA;CACA;CACA;AACF"}
@@ -4,12 +4,16 @@ import { i as define } from "./core-Bxj0UQDF.mjs";
4
4
  /**
5
5
  * The non-color scales a design system shares across themes. Space and
6
6
  * radius multiply by the `density` and `radius-factor` knobs, so a compact
7
- * or a rounder theme is one override. `breakpoint` is the record
7
+ * or a rounder theme is one override. `shadow` is drawn in `shadow.color`,
8
+ * which a palette sets (`Theme.oklch` does, stronger in a dark scheme, where
9
+ * a shadow mixed from the text would glow); alone it falls back to black. `breakpoint` is the record
8
10
  * `Style.responsive` takes; `breakpointWidths` gives the same names as pixel
9
11
  * thresholds for `foldkit-primitives/media` Breakpoints.
10
12
  */
11
13
  const space = (rem) => `calc(${rem}rem * var(--fk-knob-density))`;
12
14
  const radius = (px) => `calc(${px}px * var(--fk-knob-radius-factor))`;
15
+ const shade = "var(--fk-shadow-color, oklch(0% 0 0 / 0.12))";
16
+ const shadow = (...layers) => layers.map((layer) => `${layer} ${shade}`).join(", ");
13
17
  const tokens = define({
14
18
  knob: {
15
19
  density: "1",
@@ -71,6 +75,14 @@ const tokens = define({
71
75
  thick: "2px",
72
76
  heavy: "3px"
73
77
  },
78
+ shadow: {
79
+ xs: shadow("0 1px 2px 0"),
80
+ sm: shadow("0 1px 3px 0", "0 1px 2px -1px"),
81
+ md: shadow("0 4px 6px -1px", "0 2px 4px -2px"),
82
+ lg: shadow("0 10px 15px -3px", "0 4px 6px -4px"),
83
+ xl: shadow("0 20px 25px -5px", "0 8px 10px -6px"),
84
+ inset: shadow("inset 0 2px 4px 0")
85
+ },
74
86
  breakpoint: {
75
87
  sm: "(min-width: 40rem)",
76
88
  md: "(min-width: 48rem)",
@@ -114,4 +126,4 @@ const inContainer = (name, breakpoints) => Object.freeze(Object.fromEntries(Obje
114
126
  //#endregion
115
127
  export { inContainer as n, tokens as r, breakpointWidths as t };
116
128
 
117
- //# sourceMappingURL=tokens-DteBJVN-.mjs.map
129
+ //# sourceMappingURL=tokens-O8S8QH_R.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tokens-O8S8QH_R.mjs","names":[],"sources":["../src/theme/tokens.ts"],"sourcesContent":["/**\n * The non-color scales a design system shares across themes. Space and\n * radius multiply by the `density` and `radius-factor` knobs, so a compact\n * or a rounder theme is one override. `shadow` is drawn in `shadow.color`,\n * which a palette sets (`Theme.oklch` does, stronger in a dark scheme, where\n * a shadow mixed from the text would glow); alone it falls back to black. `breakpoint` is the record\n * `Style.responsive` takes; `breakpointWidths` gives the same names as pixel\n * thresholds for `foldkit-primitives/media` Breakpoints.\n */\nimport { DiagnosticError } from '../diagnostics.js'\nimport { define } from './core.js'\n\nconst space = (rem: number) => `calc(${rem}rem * var(--fk-knob-density))`\nconst radius = (px: number) => `calc(${px}px * var(--fk-knob-radius-factor))`\nconst shade = 'var(--fk-shadow-color, oklch(0% 0 0 / 0.12))'\nconst shadow = (...layers: ReadonlyArray<string>) =>\n layers.map(layer => `${layer} ${shade}`).join(', ')\n\nexport const tokens = define({\n knob: { density: '1', 'radius-factor': '1' },\n space: {\n '3xs': space(0.125),\n '2xs': space(0.25),\n xs: space(0.5),\n sm: space(0.75),\n md: space(1),\n lg: space(1.5),\n xl: space(2),\n '2xl': space(3),\n '3xl': space(4),\n },\n radius: {\n xs: radius(2),\n sm: radius(3),\n md: radius(6),\n lg: radius(8),\n xl: radius(12),\n full: '9999px',\n },\n font: { body: 'system-ui, sans-serif', heading: 'inherit', mono: 'ui-monospace, monospace' },\n size: {\n xs: '0.75rem',\n sm: '0.875rem',\n md: '1rem',\n lg: '1.125rem',\n xl: '1.25rem',\n '2xl': '1.5rem',\n '3xl': '1.875rem',\n '4xl': '2.25rem',\n },\n leading: { tight: '1.2', snug: '1.375', normal: '1.5', relaxed: '1.6' },\n weight: { normal: '400', medium: '500', semibold: '600', bold: '700' },\n motion: { fast: '150ms', normal: '250ms', ease: 'ease-out' },\n border: { thin: '1px', thick: '2px', heavy: '3px' },\n // Raised a little to a lot: a pressed control, a lifted cell, a menu, a dialog.\n shadow: {\n xs: shadow('0 1px 2px 0'),\n sm: shadow('0 1px 3px 0', '0 1px 2px -1px'),\n md: shadow('0 4px 6px -1px', '0 2px 4px -2px'),\n lg: shadow('0 10px 15px -3px', '0 4px 6px -4px'),\n xl: shadow('0 20px 25px -5px', '0 8px 10px -6px'),\n inset: shadow('inset 0 2px 4px 0'),\n },\n breakpoint: {\n sm: '(min-width: 40rem)',\n md: '(min-width: 48rem)',\n lg: '(min-width: 64rem)',\n xl: '(min-width: 80rem)',\n },\n})\n\nexport type Tokens = typeof tokens\n\n// A plain `min-width`, of the window or of a named container.\nconst MIN_WIDTH = /^(?:@container\\s+[\\w-]+\\s+)?\\(min-width:\\s*(\\d+(?:\\.\\d+)?)(rem|px)\\)$/\n\n/**\n * Each breakpoint query's `min-width` in pixels (rem at 16), so CSS and the\n * Model agree on what `md` means. A query that is not a plain `min-width`\n * is refused: it has no single threshold. A container's is its container's.\n */\nexport const breakpointWidths = (theme: {\n readonly breakpoint: { readonly [name: string]: string }\n}): Readonly<Record<string, number>> => {\n const widths: Record<string, number> = {}\n for (const [name, query] of Object.entries(theme.breakpoint)) {\n const match = MIN_WIDTH.exec(query)\n if (match === null) {\n throw new DiagnosticError({\n source: 'theme',\n code: 'theme:unparseable-breakpoint',\n severity: 'error',\n message: `Breakpoint \"${name}\" is \"${query}\", not a \"(min-width: <rem|px>)\" query`,\n details: { name, query },\n })\n }\n const amount = Number(match[1])\n widths[name] = match[2] === 'rem' ? amount * 16 : amount\n }\n return Object.freeze(widths)\n}\n\n/**\n * The same breakpoints measured on a named container rather than the window:\n * `Theme.inContainer('page', Theme.tokens.breakpoint)` gives `md` as\n * `'@container page (min-width: 48rem)'`, for `Style.responsive` and a\n * responsive look. An element must be that container (`container: page /\n * inline-size`) for them to match.\n */\nexport const inContainer = <Breakpoints extends Readonly<Record<string, string>>>(\n name: string,\n breakpoints: Breakpoints,\n): { readonly [K in keyof Breakpoints]: string } =>\n Object.freeze(\n Object.fromEntries(\n Object.entries(breakpoints).map(([at, query]) => [at, `@container ${name} ${query}`]),\n ),\n ) as { readonly [K in keyof Breakpoints]: string }\n"],"mappings":";;;;;;;;;;;;AAYA,MAAM,SAAS,QAAgB,QAAQ,IAAI;AAC3C,MAAM,UAAU,OAAe,QAAQ,GAAG;AAC1C,MAAM,QAAQ;AACd,MAAM,UAAU,GAAG,WACjB,OAAO,KAAI,UAAS,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC,KAAK,IAAI;AAEpD,MAAa,SAAS,OAAO;CAC3B,MAAM;EAAE,SAAS;EAAK,iBAAiB;CAAI;CAC3C,OAAO;EACL,OAAO,MAAM,IAAK;EAClB,OAAO,MAAM,GAAI;EACjB,IAAI,MAAM,EAAG;EACb,IAAI,MAAM,GAAI;EACd,IAAI,MAAM,CAAC;EACX,IAAI,MAAM,GAAG;EACb,IAAI,MAAM,CAAC;EACX,OAAO,MAAM,CAAC;EACd,OAAO,MAAM,CAAC;CAChB;CACA,QAAQ;EACN,IAAI,OAAO,CAAC;EACZ,IAAI,OAAO,CAAC;EACZ,IAAI,OAAO,CAAC;EACZ,IAAI,OAAO,CAAC;EACZ,IAAI,OAAO,EAAE;EACb,MAAM;CACR;CACA,MAAM;EAAE,MAAM;EAAyB,SAAS;EAAW,MAAM;CAA0B;CAC3F,MAAM;EACJ,IAAI;EACJ,IAAI;EACJ,IAAI;EACJ,IAAI;EACJ,IAAI;EACJ,OAAO;EACP,OAAO;EACP,OAAO;CACT;CACA,SAAS;EAAE,OAAO;EAAO,MAAM;EAAS,QAAQ;EAAO,SAAS;CAAM;CACtE,QAAQ;EAAE,QAAQ;EAAO,QAAQ;EAAO,UAAU;EAAO,MAAM;CAAM;CACrE,QAAQ;EAAE,MAAM;EAAS,QAAQ;EAAS,MAAM;CAAW;CAC3D,QAAQ;EAAE,MAAM;EAAO,OAAO;EAAO,OAAO;CAAM;CAElD,QAAQ;EACN,IAAI,OAAO,aAAa;EACxB,IAAI,OAAO,eAAe,gBAAgB;EAC1C,IAAI,OAAO,kBAAkB,gBAAgB;EAC7C,IAAI,OAAO,oBAAoB,gBAAgB;EAC/C,IAAI,OAAO,oBAAoB,iBAAiB;EAChD,OAAO,OAAO,mBAAmB;CACnC;CACA,YAAY;EACV,IAAI;EACJ,IAAI;EACJ,IAAI;EACJ,IAAI;CACN;AACF,CAAC;AAKD,MAAM,YAAY;;;;;;AAOlB,MAAa,oBAAoB,UAEO;CACtC,MAAM,SAAiC,CAAC;CACxC,KAAK,MAAM,CAAC,MAAM,UAAU,OAAO,QAAQ,MAAM,UAAU,GAAG;EAC5D,MAAM,QAAQ,UAAU,KAAK,KAAK;EAClC,IAAI,UAAU,MACZ,MAAM,IAAI,gBAAgB;GACxB,QAAQ;GACR,MAAM;GACN,UAAU;GACV,SAAS,eAAe,KAAK,QAAQ,MAAM;GAC3C,SAAS;IAAE;IAAM;GAAM;EACzB,CAAC;EAEH,MAAM,SAAS,OAAO,MAAM,EAAE;EAC9B,OAAO,QAAQ,MAAM,OAAO,QAAQ,SAAS,KAAK;CACpD;CACA,OAAO,OAAO,OAAO,MAAM;AAC7B;;;;;;;;AASA,MAAa,eACX,MACA,gBAEA,OAAO,OACL,OAAO,YACL,OAAO,QAAQ,WAAW,CAAC,CAAC,KAAK,CAAC,IAAI,WAAW,CAAC,IAAI,cAAc,KAAK,GAAG,OAAO,CAAC,CACtF,CACF"}
@@ -60,6 +60,14 @@ declare const tokens: Readonly<{
60
60
  thick: string;
61
61
  heavy: string;
62
62
  };
63
+ shadow: {
64
+ xs: string;
65
+ sm: string;
66
+ md: string;
67
+ lg: string;
68
+ xl: string;
69
+ inset: string;
70
+ };
63
71
  breakpoint: {
64
72
  sm: string;
65
73
  md: string;
@@ -88,4 +96,4 @@ declare const breakpointWidths: (theme: {
88
96
  declare const inContainer: <Breakpoints extends Readonly<Record<string, string>>>(name: string, breakpoints: Breakpoints) => { readonly [K in keyof Breakpoints]: string; };
89
97
  //#endregion
90
98
  export { tokens as i, breakpointWidths as n, inContainer as r, Tokens as t };
91
- //# sourceMappingURL=tokens-BR_qxDR7.d.mts.map
99
+ //# sourceMappingURL=tokens-XZSP0AvO.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tokens-XZSP0AvO.d.mts","names":[],"sources":["../src/theme/tokens.ts"],"mappings":";cAkBa,QAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAqDP,gBAAgB;;;;;;cAUf,mBAAoB;WACtB;cAAwB;;MAC/B,SAAS;;;;;;;;cA0BA,cAAe,oBAAoB,SAAS,yBACvD,cACA,aAAa,4BACA,WAAW"}
@@ -1,6 +1,6 @@
1
1
  import { o as StyleValue } from "./styleValue-BavTe9MZ.mjs";
2
- import { t as Tokens } from "./tokens-BR_qxDR7.mjs";
3
- import { n as OklchTheme } from "./oklch-BxvCD0oi.mjs";
2
+ import { t as Tokens } from "./tokens-XZSP0AvO.mjs";
3
+ import { n as OklchTheme } from "./oklch-FOemcYSv.mjs";
4
4
  //#region src/utilities.d.ts
5
5
  /** A space step, or none. */
6
6
  export type Space = (keyof Tokens['space'] & string) | '0';
@@ -1,6 +1,6 @@
1
1
  import { _ as self } from "./styleValue-_G9jwb17.mjs";
2
2
  import { n as VAR_PREFIX, o as ref } from "./core-Bxj0UQDF.mjs";
3
- import { r as tokens } from "./tokens-DteBJVN-.mjs";
3
+ import { r as tokens } from "./tokens-O8S8QH_R.mjs";
4
4
  //#region src/utilities.ts
5
5
  /**
6
6
  * `foldkit-mixins/utilities`: one-idea pieces over the shipped scales, so
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "foldkit-mixins",
3
- "version": "0.5.0",
3
+ "version": "0.7.0",
4
4
  "description": "Typed slot contracts and inside-out Style/Behavior attachments for Foldkit.",
5
5
  "keywords": [
6
6
  "foldkit",
@@ -85,13 +85,13 @@
85
85
  "LICENSE"
86
86
  ],
87
87
  "peerDependencies": {
88
- "effect": ">=4.0.0-rc.116 <4.0.0-rc.118",
89
- "foldkit": "^0.163.0"
88
+ "effect": "^4.0.0",
89
+ "foldkit": "^0.165.0"
90
90
  },
91
91
  "devDependencies": {
92
- "@effect/platform-browser": "4.0.0-rc.116",
93
- "effect": "4.0.0-rc.116",
94
- "foldkit": "0.163.0",
92
+ "@effect/platform-browser": "4.0.0",
93
+ "effect": "4.0.0",
94
+ "foldkit": "0.165.0",
95
95
  "tsdown": "^0.23.0",
96
96
  "typescript": "5.9.3",
97
97
  "vite": "5.4.21"
@@ -1 +0,0 @@
1
- {"version":3,"file":"tokens-BR_qxDR7.d.mts","names":[],"sources":["../src/theme/tokens.ts"],"mappings":";cAaa,QAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA4CP,gBAAgB;;;;;;cAUf,mBAAoB;WACtB;cAAwB;;MAC/B,SAAS;;;;;;;;cA0BA,cAAe,oBAAoB,SAAS,yBACvD,cACA,aAAa,4BACA,WAAW"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"tokens-DteBJVN-.mjs","names":[],"sources":["../src/theme/tokens.ts"],"sourcesContent":["/**\n * The non-color scales a design system shares across themes. Space and\n * radius multiply by the `density` and `radius-factor` knobs, so a compact\n * or a rounder theme is one override. `breakpoint` is the record\n * `Style.responsive` takes; `breakpointWidths` gives the same names as pixel\n * thresholds for `foldkit-primitives/media` Breakpoints.\n */\nimport { DiagnosticError } from '../diagnostics.js'\nimport { define } from './core.js'\n\nconst space = (rem: number) => `calc(${rem}rem * var(--fk-knob-density))`\nconst radius = (px: number) => `calc(${px}px * var(--fk-knob-radius-factor))`\n\nexport const tokens = define({\n knob: { density: '1', 'radius-factor': '1' },\n space: {\n '3xs': space(0.125),\n '2xs': space(0.25),\n xs: space(0.5),\n sm: space(0.75),\n md: space(1),\n lg: space(1.5),\n xl: space(2),\n '2xl': space(3),\n '3xl': space(4),\n },\n radius: {\n xs: radius(2),\n sm: radius(3),\n md: radius(6),\n lg: radius(8),\n xl: radius(12),\n full: '9999px',\n },\n font: { body: 'system-ui, sans-serif', heading: 'inherit', mono: 'ui-monospace, monospace' },\n size: {\n xs: '0.75rem',\n sm: '0.875rem',\n md: '1rem',\n lg: '1.125rem',\n xl: '1.25rem',\n '2xl': '1.5rem',\n '3xl': '1.875rem',\n '4xl': '2.25rem',\n },\n leading: { tight: '1.2', snug: '1.375', normal: '1.5', relaxed: '1.6' },\n weight: { normal: '400', medium: '500', semibold: '600', bold: '700' },\n motion: { fast: '150ms', normal: '250ms', ease: 'ease-out' },\n border: { thin: '1px', thick: '2px', heavy: '3px' },\n breakpoint: {\n sm: '(min-width: 40rem)',\n md: '(min-width: 48rem)',\n lg: '(min-width: 64rem)',\n xl: '(min-width: 80rem)',\n },\n})\n\nexport type Tokens = typeof tokens\n\n// A plain `min-width`, of the window or of a named container.\nconst MIN_WIDTH = /^(?:@container\\s+[\\w-]+\\s+)?\\(min-width:\\s*(\\d+(?:\\.\\d+)?)(rem|px)\\)$/\n\n/**\n * Each breakpoint query's `min-width` in pixels (rem at 16), so CSS and the\n * Model agree on what `md` means. A query that is not a plain `min-width`\n * is refused: it has no single threshold. A container's is its container's.\n */\nexport const breakpointWidths = (theme: {\n readonly breakpoint: { readonly [name: string]: string }\n}): Readonly<Record<string, number>> => {\n const widths: Record<string, number> = {}\n for (const [name, query] of Object.entries(theme.breakpoint)) {\n const match = MIN_WIDTH.exec(query)\n if (match === null) {\n throw new DiagnosticError({\n source: 'theme',\n code: 'theme:unparseable-breakpoint',\n severity: 'error',\n message: `Breakpoint \"${name}\" is \"${query}\", not a \"(min-width: <rem|px>)\" query`,\n details: { name, query },\n })\n }\n const amount = Number(match[1])\n widths[name] = match[2] === 'rem' ? amount * 16 : amount\n }\n return Object.freeze(widths)\n}\n\n/**\n * The same breakpoints measured on a named container rather than the window:\n * `Theme.inContainer('page', Theme.tokens.breakpoint)` gives `md` as\n * `'@container page (min-width: 48rem)'`, for `Style.responsive` and a\n * responsive look. An element must be that container (`container: page /\n * inline-size`) for them to match.\n */\nexport const inContainer = <Breakpoints extends Readonly<Record<string, string>>>(\n name: string,\n breakpoints: Breakpoints,\n): { readonly [K in keyof Breakpoints]: string } =>\n Object.freeze(\n Object.fromEntries(\n Object.entries(breakpoints).map(([at, query]) => [at, `@container ${name} ${query}`]),\n ),\n ) as { readonly [K in keyof Breakpoints]: string }\n"],"mappings":";;;;;;;;;;AAUA,MAAM,SAAS,QAAgB,QAAQ,IAAI;AAC3C,MAAM,UAAU,OAAe,QAAQ,GAAG;AAE1C,MAAa,SAAS,OAAO;CAC3B,MAAM;EAAE,SAAS;EAAK,iBAAiB;CAAI;CAC3C,OAAO;EACL,OAAO,MAAM,IAAK;EAClB,OAAO,MAAM,GAAI;EACjB,IAAI,MAAM,EAAG;EACb,IAAI,MAAM,GAAI;EACd,IAAI,MAAM,CAAC;EACX,IAAI,MAAM,GAAG;EACb,IAAI,MAAM,CAAC;EACX,OAAO,MAAM,CAAC;EACd,OAAO,MAAM,CAAC;CAChB;CACA,QAAQ;EACN,IAAI,OAAO,CAAC;EACZ,IAAI,OAAO,CAAC;EACZ,IAAI,OAAO,CAAC;EACZ,IAAI,OAAO,CAAC;EACZ,IAAI,OAAO,EAAE;EACb,MAAM;CACR;CACA,MAAM;EAAE,MAAM;EAAyB,SAAS;EAAW,MAAM;CAA0B;CAC3F,MAAM;EACJ,IAAI;EACJ,IAAI;EACJ,IAAI;EACJ,IAAI;EACJ,IAAI;EACJ,OAAO;EACP,OAAO;EACP,OAAO;CACT;CACA,SAAS;EAAE,OAAO;EAAO,MAAM;EAAS,QAAQ;EAAO,SAAS;CAAM;CACtE,QAAQ;EAAE,QAAQ;EAAO,QAAQ;EAAO,UAAU;EAAO,MAAM;CAAM;CACrE,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