foldkit-mixins 0.12.0 → 0.14.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 +4 -1
- package/dist/app.d.mts +1 -1
- package/dist/app.mjs +6 -6
- package/dist/{core-IMVYU8JN.mjs → core-By7s5txd.mjs} +2 -2
- package/dist/{core-IMVYU8JN.mjs.map → core-By7s5txd.mjs.map} +1 -1
- package/dist/defaults.d.mts.map +1 -1
- package/dist/defaults.mjs +10 -4
- package/dist/defaults.mjs.map +1 -1
- package/dist/index.mjs +4 -4
- package/dist/{layers-keV38soP.mjs → layers-DxWvuCJL.mjs} +2 -2
- package/dist/{layers-keV38soP.mjs.map → layers-DxWvuCJL.mjs.map} +1 -1
- package/dist/layers.mjs +1 -1
- package/dist/layout.mjs +1 -1
- package/dist/prose.mjs +1 -1
- package/dist/{root-BBi88KYx.mjs → root-cMUipDvi.mjs} +3 -3
- package/dist/{root-BBi88KYx.mjs.map → root-cMUipDvi.mjs.map} +1 -1
- package/dist/{slotMark-D5MmzQQI.mjs → slotMark-y-RLAuTU.mjs} +2 -2
- package/dist/{slotMark-D5MmzQQI.mjs.map → slotMark-y-RLAuTU.mjs.map} +1 -1
- package/dist/{style-vLRL50Ar.mjs → style-BhOFChc5.mjs} +6 -6
- package/dist/style-BhOFChc5.mjs.map +1 -0
- package/dist/{styleValue-Cj4YjgVB.mjs → styleValue-6hpAYYfg.mjs} +63 -4
- package/dist/styleValue-6hpAYYfg.mjs.map +1 -0
- package/dist/testing.mjs +1 -1
- package/dist/theme.d.mts +54 -2
- package/dist/theme.d.mts.map +1 -1
- package/dist/theme.mjs +7 -5
- package/dist/theme.mjs.map +1 -1
- package/dist/{tokens-CHPdmeHV.mjs → tokens-BOFcnIJM.mjs} +99 -20
- package/dist/tokens-BOFcnIJM.mjs.map +1 -0
- package/dist/{tokens-vUZrqdqI.d.mts → tokens-DOTnlgyA.d.mts} +67 -2
- package/dist/tokens-DOTnlgyA.d.mts.map +1 -0
- package/dist/utilities.d.mts +1 -1
- package/dist/utilities.mjs +3 -3
- package/package.json +1 -1
- package/dist/style-vLRL50Ar.mjs.map +0 -1
- package/dist/styleValue-Cj4YjgVB.mjs.map +0 -1
- package/dist/tokens-CHPdmeHV.mjs.map +0 -1
- package/dist/tokens-vUZrqdqI.d.mts.map +0 -1
package/README.md
CHANGED
|
@@ -276,7 +276,10 @@ one.
|
|
|
276
276
|
| `Theme.lightDark(light, dark)` / `Theme.compose(base, over)` | a token that follows the color scheme with CSS `light-dark()`; themes merged at definition time |
|
|
277
277
|
| `Theme.root(theme, { omit?, colorScheme? })` / `Theme.scoped(theme, selector, overrides)` | from `foldkit-mixins/theme`: tokens as `:root` custom properties, or as overrides under a selector; unlayered global pieces for `Style.stylesheet` |
|
|
278
278
|
| `Theme.schemeScript(key?)` / `Theme.chooseScheme(scheme, key?)` / `Theme.currentScheme()` | from `foldkit-mixins/theme`: a head script applying a kept `light` or `dark` before the first paint; a Command's Effect that applies and keeps a choice; the scheme applied now |
|
|
279
|
-
| `Theme.tokens` / `Theme.oklch(knobs)` / `Theme.breakpointWidths(theme)` | from `foldkit-mixins/theme`: the shipped spacing, type, radius, motion, border, shadow and breakpoint scales; a whole palette derived from an accent and a few knobs (including the shadow color, denser in a dark scheme); the breakpoints as pixel widths for `foldkit-primitives/media` |
|
|
279
|
+
| `Theme.tokens` / `Theme.oklch(knobs)` / `Theme.breakpointWidths(theme)` | from `foldkit-mixins/theme`: the shipped spacing, type, radius, motion, border, shadow and breakpoint scales, and `safe` (what a notch or the home indicator takes from each screen edge, `env(safe-area-inset-*)`, 0 unless the viewport meta says `viewport-fit=cover`); a whole palette derived from an accent and a few knobs (including the shadow color, denser in a dark scheme); the breakpoints as pixel widths for `foldkit-primitives/media` |
|
|
280
|
+
| `Theme.hardShadows` | from `foldkit-mixins/theme`: the shadow scale as solid offset copies with no blur, for a retro or brutalist look; compose it over `Theme.tokens`, and `shadow-strength` still fades it |
|
|
281
|
+
| Type and shape knobs | `Theme.tokens`' `knob` group also holds `text-scale` (every type size), `heading-scale` (how far headings stand above the body), `leading` (line heights) and `control-round` (1 rounds buttons and segmented trays to a pill through `radius-control`); `weight-heading` and `tracking-heading` set the headings' weight and letter spacing |
|
|
282
|
+
| `Theme.relief.soft` / `.hard` / `.bevel` | from `foldkit-mixins/theme`: how controls stand off the page, as the `shadow-raised` (a faced button), `shadow-pressed` (held or on) and `shadow-field` (a field's well) tokens, which `Theme.tokens` ships flat; compose one over `Theme.tokens` and every `foldkit-mixins-ui` button and field follows |
|
|
280
283
|
| `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
284
|
| `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
285
|
|
package/dist/app.d.mts
CHANGED
|
@@ -3,7 +3,7 @@ import { standard } from "./layers.mjs";
|
|
|
3
3
|
import { a as NamedStyle, l as StyleOptions, n as Declared, r as DeclaredPieces, u as StylePieces } from "./style-moq41T8O.mjs";
|
|
4
4
|
import { a as compose, r as ThemeTokens, t as Refs } from "./core-Cq9PThXv.mjs";
|
|
5
5
|
import { n as RootOptions } from "./root-DCb6aqif.mjs";
|
|
6
|
-
import { r as Tokens } from "./tokens-
|
|
6
|
+
import { r as Tokens } from "./tokens-DOTnlgyA.mjs";
|
|
7
7
|
//#region src/app.d.ts
|
|
8
8
|
export interface AppStyleOptions<Palette extends ThemeTokens> {
|
|
9
9
|
/** The application's own tokens, usually `Theme.oklch(…)`, laid over `Theme.tokens`. */
|
package/dist/app.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { i as stylesheet, n as forSlots, r as slots } from "./style-
|
|
2
|
-
import { i as compose } from "./styleValue-
|
|
3
|
-
import { r as standard } from "./layers-
|
|
4
|
-
import { o as ref, r as compose$1 } from "./core-
|
|
5
|
-
import { t as root } from "./root-
|
|
6
|
-
import {
|
|
1
|
+
import { i as stylesheet, n as forSlots, r as slots } from "./style-BhOFChc5.mjs";
|
|
2
|
+
import { i as compose } from "./styleValue-6hpAYYfg.mjs";
|
|
3
|
+
import { r as standard } from "./layers-DxWvuCJL.mjs";
|
|
4
|
+
import { o as ref, r as compose$1 } from "./core-By7s5txd.mjs";
|
|
5
|
+
import { t as root } from "./root-cMUipDvi.mjs";
|
|
6
|
+
import { l as tokens } from "./tokens-BOFcnIJM.mjs";
|
|
7
7
|
import { body, reset } from "./defaults.mjs";
|
|
8
8
|
//#region src/app.ts
|
|
9
9
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { u as inline } from "./styleValue-
|
|
1
|
+
import { u as inline } from "./styleValue-6hpAYYfg.mjs";
|
|
2
2
|
//#region src/theme/core.ts
|
|
3
3
|
/**
|
|
4
4
|
* `Theme` is typed token data, not a service. Dynamic theme state (light/dark)
|
|
@@ -50,4 +50,4 @@ const Theme = {
|
|
|
50
50
|
//#endregion
|
|
51
51
|
export { lightDark as a, define as i, VAR_PREFIX as n, ref as o, compose as r, variables as s, Theme as t };
|
|
52
52
|
|
|
53
|
-
//# sourceMappingURL=core-
|
|
53
|
+
//# sourceMappingURL=core-By7s5txd.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core-
|
|
1
|
+
{"version":3,"file":"core-By7s5txd.mjs","names":[],"sources":["../src/theme/core.ts"],"sourcesContent":["/**\n * `Theme` is typed token data, not a service. Dynamic theme state (light/dark)\n * belongs in the Foldkit Model; `variables` compiles the tokens to CSS custom\n * properties so switching a class or a root style is cheap and SSR-safe.\n */\nimport { inline, type StyleValue } from '../styleValue.js'\n\nexport type ThemeTokens = {\n readonly [group: string]: { readonly [name: string]: string }\n}\n\nexport type Theme<T extends ThemeTokens = ThemeTokens> = T\n\nexport const VAR_PREFIX = '--fk'\n\nexport const define = <T extends ThemeTokens>(tokens: T): Readonly<T> =>\n Object.freeze(\n Object.fromEntries(\n Object.entries(tokens).map(([group, names]) => [group, Object.freeze({ ...names })]),\n ),\n ) as Readonly<T>\n\n/** `var(--fk-group-name)` for every token, by the theme's own group and token names. */\nexport type Refs<T extends ThemeTokens> = {\n readonly [G in keyof T & string]: { readonly [N in keyof T[G] & string]: string }\n}\n\nconst refsByTheme = new WeakMap<ThemeTokens, Refs<ThemeTokens>>()\n\n/**\n * The theme's tokens as references: `Theme.ref(theme).surface.overt` is\n * `var(--fk-surface-overt)`, and a group or name the theme lacks is a type\n * error. Only the names are read, never the values. Built once per theme.\n */\nexport const ref = <T extends ThemeTokens>(theme: T): Refs<T> => {\n const cached = refsByTheme.get(theme)\n if (cached !== undefined) return cached as Refs<T>\n const built = Object.freeze(\n Object.fromEntries(\n Object.entries(theme).map(([group, names]) => [\n group,\n Object.freeze(\n Object.fromEntries(\n Object.keys(names).map(name => [name, `var(${VAR_PREFIX}-${group}-${name})`]),\n ),\n ),\n ]),\n ),\n )\n refsByTheme.set(theme, built)\n return built as Refs<T>\n}\n\nexport const variables = <T extends ThemeTokens>(theme: T): StyleValue => {\n const style: Record<`--${string}`, string> = {}\n for (const [group, names] of Object.entries(theme)) {\n for (const [name, value] of Object.entries(names as Record<string, string>)) {\n style[`${VAR_PREFIX}-${group}-${name}`] = value\n }\n }\n return inline(style)\n}\n\n/**\n * A token that follows the user's color scheme with CSS `light-dark()`: no\n * JavaScript and no Model field. A theme the user chooses is the other case,\n * and belongs in the Model as a class on the root; `variables` compiles both.\n */\nexport const lightDark = (light: string, dark: string): string => `light-dark(${light}, ${dark})`\n\ntype Merge<A, B> = {\n readonly [G in keyof A | keyof B]: G extends keyof B\n ? G extends keyof A\n ? A[G] & B[G]\n : B[G]\n : G extends keyof A\n ? A[G]\n : never\n}\n\n/** Themes merged at definition time, later tokens winning within a group. */\nexport const compose = <A extends ThemeTokens, B extends ThemeTokens>(\n base: A,\n over: B,\n): Readonly<Merge<A, B>> => {\n const merged: Record<string, Record<string, string>> = {}\n for (const source of [base, over]) {\n for (const [group, names] of Object.entries(source)) {\n merged[group] = { ...merged[group], ...(names as Record<string, string>) }\n }\n }\n return define(merged) as unknown as Readonly<Merge<A, B>>\n}\n\nexport const Theme = { define, ref, variables, lightDark, compose } as const\n"],"mappings":";;;;;;;AAaA,MAAa,aAAa;AAE1B,MAAa,UAAiC,WAC5C,OAAO,OACL,OAAO,YACL,OAAO,QAAQ,MAAM,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,OAAO,OAAO,OAAO,EAAE,GAAG,MAAM,CAAC,CAAC,CAAC,CACrF,CACF;AAOF,MAAM,8BAAc,IAAI,QAAwC;;;;;;AAOhE,MAAa,OAA8B,UAAsB;CAC/D,MAAM,SAAS,YAAY,IAAI,KAAK;CACpC,IAAI,WAAW,KAAA,GAAW,OAAO;CACjC,MAAM,QAAQ,OAAO,OACnB,OAAO,YACL,OAAO,QAAQ,KAAK,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAC5C,OACA,OAAO,OACL,OAAO,YACL,OAAO,KAAK,KAAK,CAAC,CAAC,KAAI,SAAQ,CAAC,MAAM,OAAO,WAAW,GAAG,MAAM,GAAG,KAAK,EAAE,CAAC,CAC9E,CACF,CACF,CAAC,CACH,CACF;CACA,YAAY,IAAI,OAAO,KAAK;CAC5B,OAAO;AACT;AAEA,MAAa,aAAoC,UAAyB;CACxE,MAAM,QAAuC,CAAC;CAC9C,KAAK,MAAM,CAAC,OAAO,UAAU,OAAO,QAAQ,KAAK,GAC/C,KAAK,MAAM,CAAC,MAAM,UAAU,OAAO,QAAQ,KAA+B,GACxE,MAAM,GAAG,WAAW,GAAG,MAAM,GAAG,UAAU;CAG9C,OAAO,OAAO,KAAK;AACrB;;;;;;AAOA,MAAa,aAAa,OAAe,SAAyB,cAAc,MAAM,IAAI,KAAK;;AAa/F,MAAa,WACX,MACA,SAC0B;CAC1B,MAAM,SAAiD,CAAC;CACxD,KAAK,MAAM,UAAU,CAAC,MAAM,IAAI,GAC9B,KAAK,MAAM,CAAC,OAAO,UAAU,OAAO,QAAQ,MAAM,GAChD,OAAO,SAAS;EAAE,GAAG,OAAO;EAAQ,GAAI;CAAiC;CAG7E,OAAO,OAAO,MAAM;AACtB;AAEA,MAAa,QAAQ;CAAE;CAAQ;CAAK;CAAW;CAAW;AAAQ"}
|
package/dist/defaults.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaults.d.mts","names":[],"sources":["../src/defaults.ts"],"mappings":";;;qBAca,OAAO;;
|
|
1
|
+
{"version":3,"file":"defaults.d.mts","names":[],"sources":["../src/defaults.ts"],"mappings":";;;qBAca,OAAO;;qBAkCP,MAAM;;;;;;qBAcN,UAAU;;qBAaV,OAAO;;qBAWP,MAAM;;qBAWN,UAAU;;qBAcV,KAAK;qBAEL"}
|
package/dist/defaults.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as global, i as compose } from "./styleValue-
|
|
1
|
+
import { c as global, i as compose } from "./styleValue-6hpAYYfg.mjs";
|
|
2
2
|
//#region src/defaults.ts
|
|
3
3
|
/**
|
|
4
4
|
* `foldkit-mixins/defaults`: the baseline plain HTML gets before any slot is
|
|
@@ -12,7 +12,11 @@ const v = (name, fallback) => `var(--fk-${name}, ${fallback})`;
|
|
|
12
12
|
/** Box model, margins, media, form-control fonts: what every page assumes. */
|
|
13
13
|
const reset = global([
|
|
14
14
|
"*,*::before,*::after{box-sizing:border-box;margin:0;min-width:0}",
|
|
15
|
-
":where(html){text-size-adjust:
|
|
15
|
+
":where(html){text-size-adjust:100%;-webkit-text-size-adjust:100%;tab-size:4;font-synthesis:none;text-rendering:optimizeLegibility}",
|
|
16
|
+
":where(:root){-webkit-tap-highlight-color:transparent}",
|
|
17
|
+
":where(:is(a,button,input,select,textarea,summary,label,[role=button],[role=tab],[role=option],[role=menuitem])){touch-action:manipulation}",
|
|
18
|
+
"@media (pointer:coarse){:where(:root){--fk-touch-floor:2.75rem}}",
|
|
19
|
+
":where(:is(button,summary,[role=button],[role=tab],[role=option],[role=menuitem],[role=menuitemcheckbox],[role=menuitemradio],[role=switch],[role=checkbox],[role=radio])){-webkit-user-select:none;user-select:none}",
|
|
16
20
|
":where(:is(img,picture,video,canvas,svg)){display:block;max-inline-size:100%;block-size:auto}",
|
|
17
21
|
":where(:is(input,button,textarea,select)){font:inherit;color:inherit}",
|
|
18
22
|
":where(textarea){field-sizing:content;min-block-size:2lh}",
|
|
@@ -39,7 +43,8 @@ const headings = global([
|
|
|
39
43
|
/** Link color, hover, and a visible focus ring. */
|
|
40
44
|
const links = global([
|
|
41
45
|
`:where(a){color:${v("text-link", "LinkText")};text-decoration-thickness:from-font;text-underline-offset:0.15em}`,
|
|
42
|
-
|
|
46
|
+
`@media (hover:hover){:where(a:hover){color:${v("text-link-hover", "LinkText")}}}`,
|
|
47
|
+
`:where(a:active){color:${v("text-link-hover", "LinkText")}}`,
|
|
43
48
|
`:where(:is(a,button,input,select,textarea,summary,[tabindex]):focus-visible){outline:${v("border-thick", "2px")} solid ${v("outline-focus", "Highlight")};outline-offset:2px}`
|
|
44
49
|
].join(""));
|
|
45
50
|
/** Inline code and code blocks on the subtle surface. */
|
|
@@ -56,7 +61,8 @@ const controls = global([
|
|
|
56
61
|
`:where(:is(input,select,textarea):focus-visible){border-color:${v("accent-default", "Highlight")}}`,
|
|
57
62
|
`:where(:is(input,select,textarea)[aria-invalid=true]){border-color:${v("error-default", "red")}}`,
|
|
58
63
|
`:where(button,[type=button],[type=submit],[type=reset]){padding:${v("space-xs", "0.5rem")} ${v("space-md", "1rem")};border:${v("border-thin", "1px")} solid ${v("outline-default", "ButtonBorder")};border-radius:${v("radius-md", "6px")};background:${v("surface-subtle", "ButtonFace")};color:${v("text-default", "ButtonText")};cursor:pointer;transition:background ${v("motion-fast", "150ms")} ${v("motion-ease", "ease-out")}}`,
|
|
59
|
-
|
|
64
|
+
`@media (hover:hover){:where(button,[type=button],[type=submit],[type=reset]):hover{background:${v("surface-muted", "ButtonFace")}}}`,
|
|
65
|
+
`:where(button,[type=button],[type=submit],[type=reset]):active{background:${v("surface-muted", "ButtonFace")}}`,
|
|
60
66
|
`:where(:is(button,input,select,textarea):disabled){opacity:0.5;cursor:not-allowed}`,
|
|
61
67
|
`:where(:is(input,select,textarea,button)::placeholder){color:${v("text-muted", "GrayText")}}`
|
|
62
68
|
].join(""));
|
package/dist/defaults.mjs.map
CHANGED
|
@@ -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 // Reduced motion is fewer and gentler, not none: what moves snaps (the\n // `travel` knob on every element, important so one that sets the knob\n // itself, a scoped theme's or an inline one, cannot restore it), while a\n // fade keeps its duration. Keyframes are a recipe's own and still stop.\n `@media (prefers-reduced-motion:reduce){*,*::before,*::after{--fk-knob-travel:0!important;animation-duration:0.01ms!important;scroll-behavior:auto!important}}`,\n ].join(''),\n)\n\n/** The page's font, color, background, and color scheme. */\nexport const body: StyleValue = global(\n // Scrollbars in the theme's line color, which keeps the page's hue, not the\n // browser's grey; inherited, so one rule reaches every scrolling panel.\n `:where(:root){scrollbar-color:${v('outline-overt', 'auto')} transparent;accent-color:${v('accent-default', 'auto')}}` +\n // Selected text in the accent's tint rather than the browser's own blue.\n `:where(::selection){background:color-mix(in oklab, ${v('accent-default', 'Highlight')} 28%, transparent)}` +\n `:where(body){font-family:${v('font-body', 'system-ui, sans-serif')};font-size:${v('size-md', '1rem')};line-height:${v('leading-normal', '1.5')};font-weight:${v('weight-normal', '400')};color:${v('text-default', 'CanvasText')};background:${v('surface-base', 'Canvas')};-webkit-font-smoothing:antialiased}`,\n)\n\n/**\n * A type hierarchy for h1 to h6 from the size scale, in `text-overt`. A\n * container drawn in a color of its own, such as a band on the accent, sets\n * `--fk-heading: currentColor` (`Style.vars`) and its headings take its color.\n */\nexport const headings: StyleValue = global(\n [\n `:where(:is(h1,h2,h3,h4,h5,h6)){font-family:${v('font-heading', 'inherit')};font-weight:${v('weight-bold', '700')};line-height:${v('leading-tight', '1.2')};color:${v('heading', v('text-overt', 'inherit'))};letter-spacing:-0.01em}`,\n `:where(h1){font-size:${v('size-4xl', '2.25rem')}}`,\n `:where(h2){font-size:${v('size-3xl', '1.875rem')}}`,\n `:where(h3){font-size:${v('size-2xl', '1.5rem')}}`,\n `:where(h4){font-size:${v('size-xl', '1.25rem')}}`,\n `:where(h5){font-size:${v('size-lg', '1.125rem')}}`,\n `:where(h6){font-size:${v('size-md', '1rem')}}`,\n ].join(''),\n)\n\n/** Link color, hover, and a visible focus ring. */\nexport const links: StyleValue = global(\n [\n `:where(a){color:${v('text-link', 'LinkText')};text-decoration-thickness:from-font;text-underline-offset:0.15em}`,\n `:where(a:hover){color:${v('text-link-hover', 'LinkText')}}`,\n `:where(:is(a,button,input,select,textarea,summary,[tabindex]):focus-visible){outline:${v('border-thick', '2px')} solid ${v('outline-focus', 'Highlight')};outline-offset:2px}`,\n ].join(''),\n)\n\n/** Inline code and code blocks on the subtle surface. */\nexport const code: StyleValue = global(\n [\n `:where(:is(code,kbd,samp,pre)){font-family:${v('font-mono', 'ui-monospace, monospace')};font-size:${v('size-sm', '0.875rem')}}`,\n `:where(:not(pre)>code){padding:0.1em 0.35em;border-radius:${v('radius-sm', '3px')};background:${v('surface-muted', 'transparent')};overflow-wrap:anywhere}`,\n `:where(kbd){padding:0.1em 0.4em;border:${v('border-thin', '1px')} solid ${v('outline-default', 'currentColor')};border-block-end-width:2px;border-radius:${v('radius-sm', '3px')};font-size:0.85em}`,\n `:where(hr){border:0;border-block-start:${v('border-thin', '1px')} solid ${v('outline-subtle', 'currentColor')}}`,\n `:where(pre){padding:${v('space-md', '1rem')};border:${v('border-thin', '1px')} solid ${v('outline-subtle', 'transparent')};border-radius:${v('radius-md', '6px')};background:${v('surface-subtle', 'transparent')};overflow-x:auto;line-height:${v('leading-snug', '1.375')}}`,\n ].join(''),\n)\n\n/** Text inputs, selects, textareas, and buttons: one radius, one border, one focus. */\nexport const controls: StyleValue = global(\n [\n `:where(:is(input:not([type=checkbox],[type=radio],[type=range],[type=color],[type=file]),select,textarea)){padding:${v('space-xs', '0.5rem')} ${v('space-sm', '0.75rem')};border:${v('border-thin', '1px')} solid ${v('outline-default', 'ButtonBorder')};border-radius:${v('radius-md', '6px')};background:${v('surface-base', 'Field')};color:${v('text-default', 'FieldText')};transition:border-color ${v('motion-fast', '150ms')} ${v('motion-ease', 'ease-out')}}`,\n `:where(:is(input,select,textarea):focus-visible){border-color:${v('accent-default', 'Highlight')}}`,\n `:where(:is(input,select,textarea)[aria-invalid=true]){border-color:${v('error-default', 'red')}}`,\n `:where(button,[type=button],[type=submit],[type=reset]){padding:${v('space-xs', '0.5rem')} ${v('space-md', '1rem')};border:${v('border-thin', '1px')} solid ${v('outline-default', 'ButtonBorder')};border-radius:${v('radius-md', '6px')};background:${v('surface-subtle', 'ButtonFace')};color:${v('text-default', 'ButtonText')};cursor:pointer;transition:background ${v('motion-fast', '150ms')} ${v('motion-ease', 'ease-out')}}`,\n `:where(button,[type=button],[type=submit],[type=reset]):hover{background:${v('surface-muted', 'ButtonFace')}}`,\n `:where(:is(button,input,select,textarea):disabled){opacity:0.5;cursor:not-allowed}`,\n `:where(:is(input,select,textarea,button)::placeholder){color:${v('text-muted', 'GrayText')}}`,\n ].join(''),\n)\n\n/** Every default except `reset`, which belongs in its own layer. */\nexport const all: StyleValue = compose(body, headings, links, code, controls)\n\nexport const Defaults = { reset, body, headings, links, code, controls, all } as const\n"],"mappings":";;;;;;;;;;AAWA,MAAM,KAAK,MAAc,aAA6B,YAAY,KAAK,IAAI,SAAS;;AAGpF,MAAa,QAAoB,OAC/B;CACE;CACA;CACA;CACA;CACA;CACA;CACA;CAKA;AACF,CAAC,CAAC,KAAK,EAAE,CACX;;AAGA,MAAa,OAAmB,OAG9B,iCAAiC,EAAE,iBAAiB,MAAM,EAAE,4BAA4B,EAAE,kBAAkB,MAAM,EAAE,sDAE5D,EAAE,kBAAkB,WAAW,EAAE,8CAC3D,EAAE,aAAa,uBAAuB,EAAE,aAAa,EAAE,WAAW,MAAM,EAAE,eAAe,EAAE,kBAAkB,KAAK,EAAE,eAAe,EAAE,iBAAiB,KAAK,EAAE,SAAS,EAAE,gBAAgB,YAAY,EAAE,cAAc,EAAE,gBAAgB,QAAQ,EAAE,qCAChR;;;;;;AAOA,MAAa,WAAuB,OAClC;CACE,8C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B,OAClC;CACE,sHAAsH,EAAE,YAAY,QAAQ,EAAE,GAAG,EAAE,YAAY,SAAS,EAAE,UAAU,EAAE,eAAe,KAAK,EAAE,SAAS,EAAE,mBAAmB,cAAc,EAAE,iBAAiB,EAAE,aAAa,KAAK,EAAE,cAAc,EAAE,gBAAgB,OAAO,EAAE,SAAS,EAAE,gBAAgB,WAAW,EAAE,2BAA2B,EAAE,eAAe,OAAO,EAAE,GAAG,EAAE,eAAe,UAAU,EAAE;CACvc,iEAAiE,EAAE,kBAAkB,WAAW,EAAE;CAClG,sEAAsE,EAAE,iBAAiB,KAAK,EAAE;CAChG,mEAAmE,EAAE,YAAY,QAAQ,EAAE,GAAG,EAAE,YAAY,MAAM,EAAE,UAAU,EAAE,eAAe,KAAK,EAAE,SAAS,EAAE,mBAAmB,cAAc,EAAE,iBAAiB,EAAE,aAAa,KAAK,EAAE,cAAc,EAAE,kBAAkB,YAAY,EAAE,SAAS,EAAE,gBAAgB,YAAY,EAAE,wCAAwC,EAAE,eAAe,OAAO,EAAE,GAAG,EAAE,eAAe,UAAU,EAAE;CACta,4EAA4E,EAAE,iBAAiB,YAAY,EAAE;CAC7G;CACA,gEAAgE,EAAE,cAAc,UAAU,EAAE;AAC9F,CAAC,CAAC,KAAK,EAAE,CACX;;AAGA,MAAa,MAAkB,QAAQ,MAAM,UAAU,OAAO,MAAM,QAAQ;AAE5E,MAAa,WAAW;CAAE;CAAO;CAAM;CAAU;CAAO;CAAM;CAAU;AAAI"}
|
|
1
|
+
{"version":3,"file":"defaults.mjs","names":[],"sources":["../src/defaults.ts"],"sourcesContent":["/**\n * `foldkit-mixins/defaults`: the baseline plain HTML gets before any slot is\n * styled. Every member is element-selector CSS over `--fk-*` tokens with a\n * fallback, so it re-themes with the tokens and still reads without them.\n * The pieces are unlayered; a page puts `reset` in `reset` and the rest in\n * `defaults` with `Layers.standard.in`. Selectors use `:where()` so any\n * class rule beats them.\n */\nimport { compose, global } from './styleValue.js'\nimport type { StyleValue } from './styleValue.js'\n\nconst v = (name: string, fallback: string): string => `var(--fk-${name}, ${fallback})`\n\n/** Box model, margins, media, form-control fonts: what every page assumes. */\nexport const reset: StyleValue = global(\n [\n '*,*::before,*::after{box-sizing:border-box;margin:0;min-width:0}',\n // 100%, not none: none stops a phone enlarging text in landscape, and also the\n // reader's own text size, where a browser applies it through this property.\n ':where(html){text-size-adjust:100%;-webkit-text-size-adjust:100%;tab-size:4;font-synthesis:none;text-rendering:optimizeLegibility}',\n // A tap draws no grey square of the browser's own: what was pressed shows its own\n // `:active` state (Defaults.controls, the recipes). And a second tap is a tap, not a\n // zoom, so a quick press on a stepper or a pager does not wait for one.\n ':where(:root){-webkit-tap-highlight-color:transparent}',\n ':where(:is(a,button,input,select,textarea,summary,label,[role=button],[role=tab],[role=option],[role=menuitem])){touch-action:manipulation}',\n // What a finger needs, 44px, as the platforms advise: the recipes' controls are at least\n // this tall where the pointer is coarse, and keep their density elsewhere. A region that\n // must stay dense sets it to 0.\n '@media (pointer:coarse){:where(:root){--fk-touch-floor:2.75rem}}',\n // A control's words are its name, not text to select: a long press on a button, a tab or\n // a menu row selected them on a phone and offered to copy, and a double tap selected a\n // word. Prefixed by hand, as iOS Safari reads only the prefixed one. Not a tree's rows or\n // a grid's cells, whose text may be edited or copied.\n ':where(:is(button,summary,[role=button],[role=tab],[role=option],[role=menuitem],[role=menuitemcheckbox],[role=menuitemradio],[role=switch],[role=checkbox],[role=radio])){-webkit-user-select:none;user-select:none}',\n ':where(:is(img,picture,video,canvas,svg)){display:block;max-inline-size:100%;block-size:auto}',\n ':where(:is(input,button,textarea,select)){font:inherit;color:inherit}',\n ':where(textarea){field-sizing:content;min-block-size:2lh}',\n ':where(:is(h1,h2,h3,h4,h5,h6)){text-wrap:balance}',\n ':where(p){text-wrap:pretty;overflow-wrap:break-word}',\n // Reduced motion is fewer and gentler, not none: what moves snaps (the\n // `travel` knob on every element, important so one that sets the knob\n // itself, a scoped theme's or an inline one, cannot restore it), while a\n // fade keeps its duration. Keyframes are a recipe's own and still stop.\n `@media (prefers-reduced-motion:reduce){*,*::before,*::after{--fk-knob-travel:0!important;animation-duration:0.01ms!important;scroll-behavior:auto!important}}`,\n ].join(''),\n)\n\n/** The page's font, color, background, and color scheme. */\nexport const body: StyleValue = global(\n // Scrollbars in the theme's line color, which keeps the page's hue, not the\n // browser's grey; inherited, so one rule reaches every scrolling panel.\n `:where(:root){scrollbar-color:${v('outline-overt', 'auto')} transparent;accent-color:${v('accent-default', 'auto')}}` +\n // Selected text in the accent's tint rather than the browser's own blue.\n `:where(::selection){background:color-mix(in oklab, ${v('accent-default', 'Highlight')} 28%, transparent)}` +\n `:where(body){font-family:${v('font-body', 'system-ui, sans-serif')};font-size:${v('size-md', '1rem')};line-height:${v('leading-normal', '1.5')};font-weight:${v('weight-normal', '400')};color:${v('text-default', 'CanvasText')};background:${v('surface-base', 'Canvas')};-webkit-font-smoothing:antialiased}`,\n)\n\n/**\n * A type hierarchy for h1 to h6 from the size scale, in `text-overt`. A\n * container drawn in a color of its own, such as a band on the accent, sets\n * `--fk-heading: currentColor` (`Style.vars`) and its headings take its color.\n */\nexport const headings: StyleValue = global(\n [\n `:where(:is(h1,h2,h3,h4,h5,h6)){font-family:${v('font-heading', 'inherit')};font-weight:${v('weight-bold', '700')};line-height:${v('leading-tight', '1.2')};color:${v('heading', v('text-overt', 'inherit'))};letter-spacing:-0.01em}`,\n `:where(h1){font-size:${v('size-4xl', '2.25rem')}}`,\n `:where(h2){font-size:${v('size-3xl', '1.875rem')}}`,\n `:where(h3){font-size:${v('size-2xl', '1.5rem')}}`,\n `:where(h4){font-size:${v('size-xl', '1.25rem')}}`,\n `:where(h5){font-size:${v('size-lg', '1.125rem')}}`,\n `:where(h6){font-size:${v('size-md', '1rem')}}`,\n ].join(''),\n)\n\n/** Link color, hover, and a visible focus ring. */\nexport const links: StyleValue = global(\n [\n `:where(a){color:${v('text-link', 'LinkText')};text-decoration-thickness:from-font;text-underline-offset:0.15em}`,\n // Only where something hovers: a touch screen keeps `:hover` on the link tapped last.\n `@media (hover:hover){:where(a:hover){color:${v('text-link-hover', 'LinkText')}}}`,\n `:where(a:active){color:${v('text-link-hover', 'LinkText')}}`,\n `:where(:is(a,button,input,select,textarea,summary,[tabindex]):focus-visible){outline:${v('border-thick', '2px')} solid ${v('outline-focus', 'Highlight')};outline-offset:2px}`,\n ].join(''),\n)\n\n/** Inline code and code blocks on the subtle surface. */\nexport const code: StyleValue = global(\n [\n `:where(:is(code,kbd,samp,pre)){font-family:${v('font-mono', 'ui-monospace, monospace')};font-size:${v('size-sm', '0.875rem')}}`,\n `:where(:not(pre)>code){padding:0.1em 0.35em;border-radius:${v('radius-sm', '3px')};background:${v('surface-muted', 'transparent')};overflow-wrap:anywhere}`,\n `:where(kbd){padding:0.1em 0.4em;border:${v('border-thin', '1px')} solid ${v('outline-default', 'currentColor')};border-block-end-width:2px;border-radius:${v('radius-sm', '3px')};font-size:0.85em}`,\n `:where(hr){border:0;border-block-start:${v('border-thin', '1px')} solid ${v('outline-subtle', 'currentColor')}}`,\n `:where(pre){padding:${v('space-md', '1rem')};border:${v('border-thin', '1px')} solid ${v('outline-subtle', 'transparent')};border-radius:${v('radius-md', '6px')};background:${v('surface-subtle', 'transparent')};overflow-x:auto;line-height:${v('leading-snug', '1.375')}}`,\n ].join(''),\n)\n\n/** Text inputs, selects, textareas, and buttons: one radius, one border, one focus. */\nexport const controls: StyleValue = global(\n [\n `:where(:is(input:not([type=checkbox],[type=radio],[type=range],[type=color],[type=file]),select,textarea)){padding:${v('space-xs', '0.5rem')} ${v('space-sm', '0.75rem')};border:${v('border-thin', '1px')} solid ${v('outline-default', 'ButtonBorder')};border-radius:${v('radius-md', '6px')};background:${v('surface-base', 'Field')};color:${v('text-default', 'FieldText')};transition:border-color ${v('motion-fast', '150ms')} ${v('motion-ease', 'ease-out')}}`,\n `:where(:is(input,select,textarea):focus-visible){border-color:${v('accent-default', 'Highlight')}}`,\n `:where(:is(input,select,textarea)[aria-invalid=true]){border-color:${v('error-default', 'red')}}`,\n `:where(button,[type=button],[type=submit],[type=reset]){padding:${v('space-xs', '0.5rem')} ${v('space-md', '1rem')};border:${v('border-thin', '1px')} solid ${v('outline-default', 'ButtonBorder')};border-radius:${v('radius-md', '6px')};background:${v('surface-subtle', 'ButtonFace')};color:${v('text-default', 'ButtonText')};cursor:pointer;transition:background ${v('motion-fast', '150ms')} ${v('motion-ease', 'ease-out')}}`,\n `@media (hover:hover){:where(button,[type=button],[type=submit],[type=reset]):hover{background:${v('surface-muted', 'ButtonFace')}}}`,\n `:where(button,[type=button],[type=submit],[type=reset]):active{background:${v('surface-muted', 'ButtonFace')}}`,\n `:where(:is(button,input,select,textarea):disabled){opacity:0.5;cursor:not-allowed}`,\n `:where(:is(input,select,textarea,button)::placeholder){color:${v('text-muted', 'GrayText')}}`,\n ].join(''),\n)\n\n/** Every default except `reset`, which belongs in its own layer. */\nexport const all: StyleValue = compose(body, headings, links, code, controls)\n\nexport const Defaults = { reset, body, headings, links, code, controls, all } as const\n"],"mappings":";;;;;;;;;;AAWA,MAAM,KAAK,MAAc,aAA6B,YAAY,KAAK,IAAI,SAAS;;AAGpF,MAAa,QAAoB,OAC/B;CACE;CAGA;CAIA;CACA;CAIA;CAKA;CACA;CACA;CACA;CACA;CACA;CAKA;AACF,CAAC,CAAC,KAAK,EAAE,CACX;;AAGA,MAAa,OAAmB,OAG9B,iCAAiC,EAAE,iBAAiB,MAAM,EAAE,4BAA4B,EAAE,kBAAkB,MAAM,EAAE,sDAE5D,EAAE,kBAAkB,WAAW,EAAE,8CAC3D,EAAE,aAAa,uBAAuB,EAAE,aAAa,EAAE,WAAW,MAAM,EAAE,eAAe,EAAE,kBAAkB,KAAK,EAAE,eAAe,EAAE,iBAAiB,KAAK,EAAE,SAAS,EAAE,gBAAgB,YAAY,EAAE,cAAc,EAAE,gBAAgB,QAAQ,EAAE,qCAChR;;;;;;AAOA,MAAa,WAAuB,OAClC;CACE,8CAA8C,EAAE,gBAAgB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CACX;;AAGA,MAAa,WAAuB,OAClC;CACE,sHAAsH,EAAE,YAAY,QAAQ,EAAE,GAAG,EAAE,YAAY,SAAS,EAAE,UAAU,EAAE,eAAe,KAAK,EAAE,SAAS,EAAE,mBAAmB,cAAc,EAAE,iBAAiB,EAAE,aAAa,KAAK,EAAE,cAAc,EAAE,gBAAgB,OAAO,EAAE,SAAS,EAAE,gBAAgB,WAAW,EAAE,2BAA2B,EAAE,eAAe,OAAO,EAAE,GAAG,EAAE,eAAe,UAAU,EAAE;CACvc,iEAAiE,EAAE,kBAAkB,WAAW,EAAE;CAClG,sEAAsE,EAAE,iBAAiB,KAAK,EAAE;CAChG,mEAAmE,EAAE,YAAY,QAAQ,EAAE,GAAG,EAAE,YAAY,MAAM,EAAE,UAAU,EAAE,eAAe,KAAK,EAAE,SAAS,EAAE,mBAAmB,cAAc,EAAE,iBAAiB,EAAE,aAAa,KAAK,EAAE,cAAc,EAAE,kBAAkB,YAAY,EAAE,SAAS,EAAE,gBAAgB,YAAY,EAAE,wCAAwC,EAAE,eAAe,OAAO,EAAE,GAAG,EAAE,eAAe,UAAU,EAAE;CACta,iGAAiG,EAAE,iBAAiB,YAAY,EAAE;CAClI,6EAA6E,EAAE,iBAAiB,YAAY,EAAE;CAC9G;CACA,gEAAgE,EAAE,cAAc,UAAU,EAAE;AAC9F,CAAC,CAAC,KAAK,EAAE,CACX;;AAGA,MAAa,MAAkB,QAAQ,MAAM,UAAU,OAAO,MAAM,QAAQ;AAE5E,MAAa,WAAW;CAAE;CAAO;CAAM;CAAU;CAAO;CAAM;CAAU;AAAI"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
|
|
2
|
-
import { _ as extendsCapability, a as slots_exports, b as metadataToken_exports, c as slotView_exports, d as mixin_exports, f as isTagged, g as capability_exports, h as Interactive, l as resolver_exports, m as Focusable, o as slot_exports, p as Container, s as attach$1, t as Style, u as dynamic, v as is$4, x as nameOf, y as make$3 } from "./style-
|
|
3
|
-
import { E as diagnostics_exports, T as DiagnosticError } from "./styleValue-
|
|
4
|
-
import { t as Layers } from "./layers-
|
|
5
|
-
import { t as Theme } from "./core-
|
|
2
|
+
import { _ as extendsCapability, a as slots_exports, b as metadataToken_exports, c as slotView_exports, d as mixin_exports, f as isTagged, g as capability_exports, h as Interactive, l as resolver_exports, m as Focusable, o as slot_exports, p as Container, s as attach$1, t as Style, u as dynamic, v as is$4, x as nameOf, y as make$3 } from "./style-BhOFChc5.mjs";
|
|
3
|
+
import { E as diagnostics_exports, T as DiagnosticError } from "./styleValue-6hpAYYfg.mjs";
|
|
4
|
+
import { t as Layers } from "./layers-DxWvuCJL.mjs";
|
|
5
|
+
import { t as Theme } from "./core-By7s5txd.mjs";
|
|
6
6
|
import { Option } from "effect";
|
|
7
7
|
//#region src/a11y.ts
|
|
8
8
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { T as DiagnosticError, f as make } from "./styleValue-
|
|
1
|
+
import { T as DiagnosticError, f as make } from "./styleValue-6hpAYYfg.mjs";
|
|
2
2
|
//#region src/cssBlocks.ts
|
|
3
3
|
const withoutComments = (text) => text.replace(/\/\*[\s\S]*?\*\//g, "").trim();
|
|
4
4
|
/** Index just past the string starting at `start`, which holds its quote. */
|
|
@@ -190,4 +190,4 @@ const Layers = {
|
|
|
190
190
|
//#endregion
|
|
191
191
|
export { isUnordered as a, declaredNames as i, define as n, layerOf as o, standard as r, topLevelBlocks as s, Layers as t };
|
|
192
192
|
|
|
193
|
-
//# sourceMappingURL=layers-
|
|
193
|
+
//# sourceMappingURL=layers-DxWvuCJL.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layers-keV38soP.mjs","names":[],"sources":["../src/cssBlocks.ts","../src/layers.ts"],"sourcesContent":["/**\n * The top-level blocks of compiled CSS text, and which cascade layer each is\n * in. `Layers.in` reads them to leave an already-layered block where it is,\n * and `Style.stylesheet` to refuse a rule outside the declared order. The\n * text is the compiler's own output or a `Style.global` chunk, so a scanner\n * that respects strings, comments, and brace depth is enough; it is not a\n * CSS parser.\n */\nexport interface Block {\n /** What precedes the body, comments removed: `@layer app`, `.x:hover`, or a whole `@layer a, b;`. */\n readonly prelude: string\n /** The block's full text, as it appeared. */\n readonly text: string\n}\n\nconst withoutComments = (text: string): string => text.replace(/\\/\\*[\\s\\S]*?\\*\\//g, '').trim()\n\n/** Index just past the string starting at `start`, which holds its quote. */\nconst endOfString = (css: string, start: number): number => {\n const quote = css[start]\n let index = start + 1\n while (index < css.length && css[index] !== quote) index += css[index] === '\\\\' ? 2 : 1\n return index + 1\n}\n\nexport const topLevelBlocks = (css: string): ReadonlyArray<Block> => {\n const blocks: Array<Block> = []\n let start = 0\n let depth = 0\n let bodyAt = -1\n let index = 0\n while (index < css.length) {\n const char = css[index]\n if (char === '\"' || char === \"'\") {\n index = endOfString(css, index)\n continue\n }\n if (char === '/' && css[index + 1] === '*') {\n const end = css.indexOf('*/', index + 2)\n index = end === -1 ? css.length : end + 2\n continue\n }\n if (char === '{') {\n if (depth === 0) bodyAt = index\n depth++\n } else if (char === '}') {\n depth--\n if (depth === 0) {\n blocks.push({\n prelude: withoutComments(css.slice(start, bodyAt)),\n text: css.slice(start, index + 1),\n })\n start = index + 1\n }\n } else if (char === ';' && depth === 0) {\n const text = css.slice(start, index + 1)\n blocks.push({ prelude: withoutComments(text), text })\n start = index + 1\n }\n index++\n }\n const rest = css.slice(start)\n if (withoutComments(rest) !== '') blocks.push({ prelude: withoutComments(rest), text: rest })\n return blocks\n}\n\n/** `@layer a, b, c;`: an order statement, not a layered rule. */\nexport const isLayerStatement = (block: Block): boolean => /^@layer\\s[^{}]*;$/.test(block.prelude)\n\n/** The layer a `@layer name{…}` block is in; undefined for any other block. */\nexport const layerOf = (block: Block): string | undefined =>\n /^@layer\\s+([^\\s{},;]+)$/.exec(block.prelude)?.[1]\n\n/** Blocks the cascade does not order: the layer statement, keyframes, font faces, registered properties. */\nexport const isUnordered = (block: Block): boolean =>\n isLayerStatement(block) ||\n /^@(?:-webkit-)?keyframes\\s|^@font-face\\b|^@property\\s/.test(block.prelude)\n\n/** The names a `@layer a, b, c;` statement declares. */\nexport const declaredNames = (statement: string): ReadonlyArray<string> =>\n statement\n .replace(/^@layer\\s+/, '')\n .replace(/;$/, '')\n .split(',')\n .map(name => name.trim())\n","/**\n * Cascade layers as a value. `define` names an order; the result declares\n * it (`declare`) and places a piece in one of its layers (`in`), typed to\n * those names so a misspelled layer is a type error. `standard` is the\n * order a design system built on the `/theme`, `/layout`, `/defaults`, and\n * `/prose` subpaths expects; the pieces those ship are unlayered until a\n * page wraps them, so a different order needs no different generators.\n */\nimport { isLayerStatement, layerOf, topLevelBlocks } from './cssBlocks.js'\nimport { DiagnosticError } from './diagnostics.js'\nimport type { SlotItem } from './slotItem.js'\nimport type { StyleRule } from './styleRules.js'\nimport { make, type StyleValue } from './styleValue.js'\n\n/**\n * One layer of one order, for `Style.forSlots(S)(pieces, { layer })`: every\n * piece is placed before it is compiled, so the style a view attaches and the\n * style a sheet ships are the same value with the same classes. A piece\n * already in another layer keeps it and is not refused, because a slot piece\n * that is only a layered layout or recipe is ordinary.\n */\nexport interface Placement<Name extends string = string> {\n readonly layer: Name\n readonly place: (piece: StyleValue) => StyleValue\n}\n\nexport interface Layers<Name extends string> {\n readonly names: ReadonlyArray<Name>\n /** The `@layer a, b, c;` statement as a global piece; `Style.stylesheet` hoists it first. */\n readonly declare: StyleValue\n /**\n * The piece's unlayered rules and global CSS emitted inside `@layer name`,\n * including rules under `whenInput` and per-item pieces. A rule or block\n * already in a layer keeps it, so a design system's layered layout composed\n * into an application style stays in `layouts`. A piece with nothing\n * unlayered but something in another layer is refused with\n * `style:relayered`, since the call would move nothing. A slot style is\n * layered where it is defined, with `layer`, not here: placing a finished\n * style would copy it under new classes that no view attaches.\n */\n readonly in: (name: Name, piece: StyleValue) => StyleValue\n /** The placement `Style.forSlots` takes as its `layer` option. */\n readonly layer: (name: Name) => Placement<Name>\n}\n\n/** What one `in` call placed, and which other layers it left in place. */\ninterface Tally {\n placed: number\n readonly kept: Set<string>\n}\n\nconst tally = (): Tally => ({ placed: 0, kept: new Set() })\n\nconst placeRule = (name: string, rule: StyleRule, count: Tally): StyleRule => {\n if (rule.layer !== undefined && rule.layer !== name) {\n count.kept.add(rule.layer)\n return rule\n }\n count.placed++\n return rule.layer === name ? rule : { ...rule, layer: name }\n}\n\n/** Runs of unlayered blocks go into one `@layer name{…}`; layered blocks and statements stay. */\nconst placeGlobal = (name: string, css: string, count: Tally): string => {\n const out: Array<string> = []\n let pending = ''\n const flush = (): void => {\n if (pending !== '') out.push(`@layer ${name}{${pending}}`)\n pending = ''\n }\n for (const block of topLevelBlocks(css)) {\n const layer = layerOf(block)\n if (isLayerStatement(block)) {\n flush()\n out.push(block.text)\n } else if (layer === undefined) {\n pending += block.text\n count.placed++\n } else {\n flush()\n out.push(block.text)\n if (layer === name) count.placed++\n else count.kept.add(layer)\n }\n }\n flush()\n return out.join('')\n}\n\nconst place = (name: string, piece: StyleValue, count: Tally): StyleValue =>\n Object.freeze({\n ...piece,\n ...(piece.rules === undefined\n ? {}\n : { rules: Object.freeze(piece.rules.map(rule => placeRule(name, rule, count))) }),\n ...(piece.globalCss === undefined\n ? {}\n : { globalCss: Object.freeze(piece.globalCss.map(css => placeGlobal(name, css, count))) }),\n ...(piece.conditions === undefined\n ? {}\n : {\n conditions: Object.freeze(\n piece.conditions.map(condition => ({\n predicate: condition.predicate,\n piece: place(name, condition.piece, count),\n })),\n ),\n }),\n ...(piece.items === undefined\n ? {}\n : {\n // Rendered per item, after `in` returned: nothing to refuse by then.\n items: Object.freeze(\n piece.items.map(\n render => (item: SlotItem | undefined) => place(name, render(item), tally()),\n ),\n ),\n }),\n })\n\nconst refuseRelayer = (name: string, count: Tally): void => {\n if (count.placed > 0 || count.kept.size === 0) return\n const layers = [...count.kept]\n throw new DiagnosticError({\n source: 'style',\n code: 'style:relayered',\n severity: 'error',\n message: `Layers.in(\"${name}\", …) was given a piece already in layer ${layers.map(layer => `\"${layer}\"`).join(', ')}; a layered rule keeps its layer, so nothing would move. Place the unlayered piece instead.`,\n details: { layer: name, kept: layers },\n })\n}\n\nconst placeIn = (name: string, piece: StyleValue): StyleValue => {\n const count = tally()\n const placed = place(name, piece, count)\n refuseRelayer(name, count)\n return placed\n}\n\nexport const define = <const Name extends string>(names: ReadonlyArray<Name>): Layers<Name> => {\n const seen = new Set<string>()\n for (const name of names) {\n if (seen.has(name)) {\n throw new DiagnosticError({\n source: 'style',\n code: 'style:duplicate-layer',\n severity: 'error',\n message: `Layers.define names \"${name}\" twice`,\n })\n }\n seen.add(name)\n }\n return Object.freeze({\n names: Object.freeze([...names]),\n declare: make({ globalCss: Object.freeze([`@layer ${names.join(', ')};`]) }),\n in: placeIn,\n layer: (name: Name): Placement<Name> =>\n Object.freeze({ layer: name, place: (piece: StyleValue) => place(name, piece, tally()) }),\n })\n}\n\n/**\n * The shipped order. `reset` normalizes; `tokens` holds the scales that do\n * not change per theme; `theme` the knobs and what derives from them, plus\n * scoped overrides; `defaults` element defaults; then a design system's\n * `components`, `layouts` (after components, so a wrapper never beats a\n * component's inner rule), a recipe's `variants`, `utilities`, and the\n * application's `app`, always last.\n */\nexport const standard = define([\n 'reset',\n 'tokens',\n 'theme',\n 'defaults',\n 'components',\n 'layouts',\n 'variants',\n 'utilities',\n 'app',\n])\n\nexport const Layers = { define, standard } as const\n"],"mappings":";;AAeA,MAAM,mBAAmB,SAAyB,KAAK,QAAQ,qBAAqB,EAAE,CAAC,CAAC,KAAK;;AAG7F,MAAM,eAAe,KAAa,UAA0B;CAC1D,MAAM,QAAQ,IAAI;CAClB,IAAI,QAAQ,QAAQ;CACpB,OAAO,QAAQ,IAAI,UAAU,IAAI,WAAW,OAAO,SAAS,IAAI,WAAW,OAAO,IAAI;CACtF,OAAO,QAAQ;AACjB;AAEA,MAAa,kBAAkB,Q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OAAO,OAAO,CAAC,GAAG,KAAK,CAAC;EAC/B,SAAS,KAAK,EAAE,WAAW,OAAO,OAAO,CAAC,UAAU,MAAM,KAAK,IAAI,EAAE,EAAE,CAAC,EAAE,CAAC;EAC3E,IAAI;EACJ,QAAQ,SACN,OAAO,OAAO;GAAE,OAAO;GAAM,QAAQ,UAAsB,MAAM,MAAM,OAAO,MAAM,CAAC;EAAE,CAAC;CAC5F,CAAC;AACH;;;;;;;;;AAUA,MAAa,WAAW,OAAO;CAC7B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,MAAa,SAAS;CAAE;CAAQ;AAAS"}
|
|
1
|
+
{"version":3,"file":"layers-DxWvuCJL.mjs","names":[],"sources":["../src/cssBlocks.ts","../src/layers.ts"],"sourcesContent":["/**\n * The top-level blocks of compiled CSS text, and which cascade layer each is\n * in. `Layers.in` reads them to leave an already-layered block where it is,\n * and `Style.stylesheet` to refuse a rule outside the declared order. The\n * text is the compiler's own output or a `Style.global` chunk, so a scanner\n * that respects strings, comments, and brace depth is enough; it is not a\n * CSS parser.\n */\nexport interface Block {\n /** What precedes the body, comments removed: `@layer app`, `.x:hover`, or a whole `@layer a, b;`. */\n readonly prelude: string\n /** The block's full text, as it appeared. */\n readonly text: string\n}\n\nconst withoutComments = (text: string): string => text.replace(/\\/\\*[\\s\\S]*?\\*\\//g, '').trim()\n\n/** Index just past the string starting at `start`, which holds its quote. */\nconst endOfString = (css: string, start: number): number => {\n const quote = css[start]\n let index = start + 1\n while (index < css.length && css[index] !== quote) index += css[index] === '\\\\' ? 2 : 1\n return index + 1\n}\n\nexport const topLevelBlocks = (css: string): ReadonlyArray<Block> => {\n const blocks: Array<Block> = []\n let start = 0\n let depth = 0\n let bodyAt = -1\n let index = 0\n while (index < css.length) {\n const char = css[index]\n if (char === '\"' || char === \"'\") {\n index = endOfString(css, index)\n continue\n }\n if (char === '/' && css[index + 1] === '*') {\n const end = css.indexOf('*/', index + 2)\n index = end === -1 ? css.length : end + 2\n continue\n }\n if (char === '{') {\n if (depth === 0) bodyAt = index\n depth++\n } else if (char === '}') {\n depth--\n if (depth === 0) {\n blocks.push({\n prelude: withoutComments(css.slice(start, bodyAt)),\n text: css.slice(start, index + 1),\n })\n start = index + 1\n }\n } else if (char === ';' && depth === 0) {\n const text = css.slice(start, index + 1)\n blocks.push({ prelude: withoutComments(text), text })\n start = index + 1\n }\n index++\n }\n const rest = css.slice(start)\n if (withoutComments(rest) !== '') blocks.push({ prelude: withoutComments(rest), text: rest })\n return blocks\n}\n\n/** `@layer a, b, c;`: an order statement, not a layered rule. */\nexport const isLayerStatement = (block: Block): boolean => /^@layer\\s[^{}]*;$/.test(block.prelude)\n\n/** The layer a `@layer name{…}` block is in; undefined for any other block. */\nexport const layerOf = (block: Block): string | undefined =>\n /^@layer\\s+([^\\s{},;]+)$/.exec(block.prelude)?.[1]\n\n/** Blocks the cascade does not order: the layer statement, keyframes, font faces, registered properties. */\nexport const isUnordered = (block: Block): boolean =>\n isLayerStatement(block) ||\n /^@(?:-webkit-)?keyframes\\s|^@font-face\\b|^@property\\s/.test(block.prelude)\n\n/** The names a `@layer a, b, c;` statement declares. */\nexport const declaredNames = (statement: string): ReadonlyArray<string> =>\n statement\n .replace(/^@layer\\s+/, '')\n .replace(/;$/, '')\n .split(',')\n .map(name => name.trim())\n","/**\n * Cascade layers as a value. `define` names an order; the result declares\n * it (`declare`) and places a piece in one of its layers (`in`), typed to\n * those names so a misspelled layer is a type error. `standard` is the\n * order a design system built on the `/theme`, `/layout`, `/defaults`, and\n * `/prose` subpaths expects; the pieces those ship are unlayered until a\n * page wraps them, so a different order needs no different generators.\n */\nimport { isLayerStatement, layerOf, topLevelBlocks } from './cssBlocks.js'\nimport { DiagnosticError } from './diagnostics.js'\nimport type { SlotItem } from './slotItem.js'\nimport type { StyleRule } from './styleRules.js'\nimport { make, type StyleValue } from './styleValue.js'\n\n/**\n * One layer of one order, for `Style.forSlots(S)(pieces, { layer })`: every\n * piece is placed before it is compiled, so the style a view attaches and the\n * style a sheet ships are the same value with the same classes. A piece\n * already in another layer keeps it and is not refused, because a slot piece\n * that is only a layered layout or recipe is ordinary.\n */\nexport interface Placement<Name extends string = string> {\n readonly layer: Name\n readonly place: (piece: StyleValue) => StyleValue\n}\n\nexport interface Layers<Name extends string> {\n readonly names: ReadonlyArray<Name>\n /** The `@layer a, b, c;` statement as a global piece; `Style.stylesheet` hoists it first. */\n readonly declare: StyleValue\n /**\n * The piece's unlayered rules and global CSS emitted inside `@layer name`,\n * including rules under `whenInput` and per-item pieces. A rule or block\n * already in a layer keeps it, so a design system's layered layout composed\n * into an application style stays in `layouts`. A piece with nothing\n * unlayered but something in another layer is refused with\n * `style:relayered`, since the call would move nothing. A slot style is\n * layered where it is defined, with `layer`, not here: placing a finished\n * style would copy it under new classes that no view attaches.\n */\n readonly in: (name: Name, piece: StyleValue) => StyleValue\n /** The placement `Style.forSlots` takes as its `layer` option. */\n readonly layer: (name: Name) => Placement<Name>\n}\n\n/** What one `in` call placed, and which other layers it left in place. */\ninterface Tally {\n placed: number\n readonly kept: Set<string>\n}\n\nconst tally = (): Tally => ({ placed: 0, kept: new Set() })\n\nconst placeRule = (name: string, rule: StyleRule, count: Tally): StyleRule => {\n if (rule.layer !== undefined && rule.layer !== name) {\n count.kept.add(rule.layer)\n return rule\n }\n count.placed++\n return rule.layer === name ? rule : { ...rule, layer: name }\n}\n\n/** Runs of unlayered blocks go into one `@layer name{…}`; layered blocks and statements stay. */\nconst placeGlobal = (name: string, css: string, count: Tally): string => {\n const out: Array<string> = []\n let pending = ''\n const flush = (): void => {\n if (pending !== '') out.push(`@layer ${name}{${pending}}`)\n pending = ''\n }\n for (const block of topLevelBlocks(css)) {\n const layer = layerOf(block)\n if (isLayerStatement(block)) {\n flush()\n out.push(block.text)\n } else if (layer === undefined) {\n pending += block.text\n count.placed++\n } else {\n flush()\n out.push(block.text)\n if (layer === name) count.placed++\n else count.kept.add(layer)\n }\n }\n flush()\n return out.join('')\n}\n\nconst place = (name: string, piece: StyleValue, count: Tally): StyleValue =>\n Object.freeze({\n ...piece,\n ...(piece.rules === undefined\n ? {}\n : { rules: Object.freeze(piece.rules.map(rule => placeRule(name, rule, count))) }),\n ...(piece.globalCss === undefined\n ? {}\n : { globalCss: Object.freeze(piece.globalCss.map(css => placeGlobal(name, css, count))) }),\n ...(piece.conditions === undefined\n ? {}\n : {\n conditions: Object.freeze(\n piece.conditions.map(condition => ({\n predicate: condition.predicate,\n piece: place(name, condition.piece, count),\n })),\n ),\n }),\n ...(piece.items === undefined\n ? {}\n : {\n // Rendered per item, after `in` returned: nothing to refuse by then.\n items: Object.freeze(\n piece.items.map(\n render => (item: SlotItem | undefined) => place(name, render(item), tally()),\n ),\n ),\n }),\n })\n\nconst refuseRelayer = (name: string, count: Tally): void => {\n if (count.placed > 0 || count.kept.size === 0) return\n const layers = [...count.kept]\n throw new DiagnosticError({\n source: 'style',\n code: 'style:relayered',\n severity: 'error',\n message: `Layers.in(\"${name}\", …) was given a piece already in layer ${layers.map(layer => `\"${layer}\"`).join(', ')}; a layered rule keeps its layer, so nothing would move. Place the unlayered piece instead.`,\n details: { layer: name, kept: layers },\n })\n}\n\nconst placeIn = (name: string, piece: StyleValue): StyleValue => {\n const count = tally()\n const placed = place(name, piece, count)\n refuseRelayer(name, count)\n return placed\n}\n\nexport const define = <const Name extends string>(names: ReadonlyArray<Name>): Layers<Name> => {\n const seen = new Set<string>()\n for (const name of names) {\n if (seen.has(name)) {\n throw new DiagnosticError({\n source: 'style',\n code: 'style:duplicate-layer',\n severity: 'error',\n message: `Layers.define names \"${name}\" twice`,\n })\n }\n seen.add(name)\n }\n return Object.freeze({\n names: Object.freeze([...names]),\n declare: make({ globalCss: Object.freeze([`@layer ${names.join(', ')};`]) }),\n in: placeIn,\n layer: (name: Name): Placement<Name> =>\n Object.freeze({ layer: name, place: (piece: StyleValue) => place(name, piece, tally()) }),\n })\n}\n\n/**\n * The shipped order. `reset` normalizes; `tokens` holds the scales that do\n * not change per theme; `theme` the knobs and what derives from them, plus\n * scoped overrides; `defaults` element defaults; then a design system's\n * `components`, `layouts` (after components, so a wrapper never beats a\n * component's inner rule), a recipe's `variants`, `utilities`, and the\n * application's `app`, always last.\n */\nexport const standard = define([\n 'reset',\n 'tokens',\n 'theme',\n 'defaults',\n 'components',\n 'layouts',\n 'variants',\n 'utilities',\n 'app',\n])\n\nexport const Layers = { define, standard } as const\n"],"mappings":";;AAeA,MAAM,mBAAmB,SAAyB,KAAK,QAAQ,qBAAqB,EAAE,CAAC,CAAC,KAAK;;AAG7F,MAAM,eAAe,KAAa,UAA0B;CAC1D,MAAM,QAAQ,IAAI;CAClB,IAAI,QAAQ,QAAQ;CACpB,OAAO,QAAQ,IAAI,UAAU,IAAI,WAAW,OAAO,SAAS,IAAI,WAAW,OAAO,IAAI;CACtF,OAAO,QAAQ;AACjB;AAEA,MAAa,kBAAkB,QAAsC;CACnE,MAAM,SAAuB,CAAC;CAC9B,IAAI,QAAQ;CACZ,IAAI,QAAQ;CACZ,IAAI,SAAS;CACb,IAAI,QAAQ;CACZ,OAAO,QAAQ,IAAI,QAAQ;EACzB,MAAM,OAAO,IAAI;EACjB,IAAI,SAAS,QAAO,SAAS,KAAK;GAChC,QAAQ,YAAY,KAAK,KAAK;GAC9B;EACF;EACA,IAAI,SAAS,OAAO,IAAI,QAAQ,OAAO,KAAK;GAC1C,MAAM,MAAM,IAAI,QAAQ,MAAM,QAAQ,CAAC;GACvC,QAAQ,QAAQ,KAAK,IAAI,SAAS,MAAM;GACxC;EACF;EACA,IAAI,SAAS,KAAK;GAChB,IAAI,UAAU,GAAG,SAAS;GAC1B;EACF,OAAO,IAAI,SAAS,KAAK;GACvB;GACA,IAAI,UAAU,GAAG;IACf,OAAO,KAAK;KACV,SAAS,gBAAgB,IAAI,MAAM,OAAO,MAAM,CAAC;KACjD,MAAM,IAAI,MAAM,OAAO,QAAQ,CAAC;IAClC,CAAC;IACD,QAAQ,QAAQ;GAClB;EAC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Ac,KAAK,2CAA2C,OAAO,KAAI,UAAS,IAAI,MAAM,EAAE,CAAC,CAAC,KAAK,IAAI,EAAE;EACpH,SAAS;GAAE,OAAO;GAAM,MAAM;EAAO;CACvC,CAAC;AACH;AAEA,MAAM,WAAW,MAAc,UAAkC;CAC/D,MAAM,QAAQ,MAAM;CACpB,MAAM,SAAS,MAAM,MAAM,OAAO,KAAK;CACvC,cAAc,MAAM,KAAK;CACzB,OAAO;AACT;AAEA,MAAa,UAAqC,UAA6C;CAC7F,MAAM,uBAAO,IAAI,IAAY;CAC7B,KAAK,MAAM,QAAQ,OAAO;EACxB,IAAI,KAAK,IAAI,IAAI,GACf,MAAM,IAAI,gBAAgB;GACxB,QAAQ;GACR,MAAM;GACN,UAAU;GACV,SAAS,wBAAwB,KAAK;EACxC,CAAC;EAEH,KAAK,IAAI,IAAI;CACf;CACA,OAAO,OAAO,OAAO;EACnB,OAAO,OAAO,OAAO,CAAC,GAAG,KAAK,CAAC;EAC/B,SAAS,KAAK,EAAE,WAAW,OAAO,OAAO,CAAC,UAAU,MAAM,KAAK,IAAI,EAAE,EAAE,CAAC,EAAE,CAAC;EAC3E,IAAI;EACJ,QAAQ,SACN,OAAO,OAAO;GAAE,OAAO;GAAM,QAAQ,UAAsB,MAAM,MAAM,OAAO,MAAM,CAAC;EAAE,CAAC;CAC5F,CAAC;AACH;;;;;;;;;AAUA,MAAa,WAAW,OAAO;CAC7B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,MAAa,SAAS;CAAE;CAAQ;AAAS"}
|
package/dist/layers.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as Layers, n as define, r as standard } from "./layers-
|
|
1
|
+
export { t as Layers, n as define, r as standard } from "./layers-DxWvuCJL.mjs";
|
package/dist/layout.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as className, _ as self, a as container, h as pseudo, i as compose, m as nest, o as empty, p as media, x as vars } from "./styleValue-
|
|
1
|
+
import { C as className, _ as self, a as container, h as pseudo, i as compose, m as nest, o as empty, p as media, x as vars } from "./styleValue-6hpAYYfg.mjs";
|
|
2
2
|
//#region src/layout.ts
|
|
3
3
|
/**
|
|
4
4
|
* `foldkit-mixins/layout`: layout pieces (stack, cluster, sidebar, …) as
|
package/dist/prose.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as self, i as compose, m as nest, u as inline } from "./styleValue-
|
|
1
|
+
import { _ as self, i as compose, m as nest, u as inline } from "./styleValue-6hpAYYfg.mjs";
|
|
2
2
|
//#region src/prose.ts
|
|
3
3
|
/**
|
|
4
4
|
* `foldkit-mixins/prose`: the longform-content contract. One class carries
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { c as global } from "./styleValue-
|
|
2
|
-
import { n as VAR_PREFIX } from "./core-
|
|
1
|
+
import { c as global } from "./styleValue-6hpAYYfg.mjs";
|
|
2
|
+
import { n as VAR_PREFIX } from "./core-By7s5txd.mjs";
|
|
3
3
|
//#region src/theme/root.ts
|
|
4
4
|
/**
|
|
5
5
|
* A theme's tokens as `:root` custom properties, for the page stylesheet.
|
|
@@ -34,4 +34,4 @@ const scoped = (_theme, selector, overrides) => {
|
|
|
34
34
|
//#endregion
|
|
35
35
|
export { scoped as n, root as t };
|
|
36
36
|
|
|
37
|
-
//# sourceMappingURL=root-
|
|
37
|
+
//# sourceMappingURL=root-cMUipDvi.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"root-
|
|
1
|
+
{"version":3,"file":"root-cMUipDvi.mjs","names":[],"sources":["../src/theme/root.ts"],"sourcesContent":["/**\n * A theme's tokens as `:root` custom properties, for the page stylesheet.\n * Unlayered: the page decides which layer with `Layers.in`.\n */\nimport { global, type StyleValue } from '../styleValue.js'\nimport { VAR_PREFIX, type ThemeTokens } from './core.js'\n\nexport interface RootOptions {\n /** Tokens present in this theme are left out, so a scale shipped in another layer goes out once. */\n readonly omit?: ThemeTokens\n /** Default `'light dark'`, so `lightDark` tokens resolve. */\n readonly colorScheme?: 'light dark' | 'light' | 'dark'\n}\n\n/**\n * Every token as `--fk-group-name:value`, in authored order. `omit` is\n * matched token by token, not group by group: two themes can both carry a\n * `knob` group (the scales' density beside a palette's hues) and only the\n * names `omit` has are skipped.\n */\nconst declarations = (theme: ThemeTokens, omit?: ThemeTokens): ReadonlyArray<string> =>\n Object.entries(theme).flatMap(([group, names]) =>\n Object.entries(names).flatMap(([name, value]) =>\n omit !== undefined && Object.hasOwn(omit[group] ?? {}, name)\n ? []\n : [`${VAR_PREFIX}-${group}-${name}:${value}`],\n ),\n )\n\nexport const root = (theme: ThemeTokens, options?: RootOptions): StyleValue =>\n global(\n `:root{${[...declarations(theme, options?.omit), `color-scheme:${options?.colorScheme ?? 'light dark'}`].join(';')}}`,\n )\n\n/** Some of a theme's tokens, by the theme's own group and token names. */\nexport type Overrides<T extends ThemeTokens> = {\n readonly [G in keyof T]?: { readonly [N in keyof T[G]]?: string }\n}\n\n/**\n * Token overrides under `selector`: a named theme the Model selects with a\n * root attribute (`:root[data-theme=\"ocean\"]`), a scheme the user chose\n * (`:root[data-color-scheme=\"dark\"]`), or a subtree (`.marketing`). Which\n * one is active is the Model's fact; this only says what it means.\n *\n * `theme` is the theme being overridden and is read only for its type, so a\n * group or token it lacks is a type error rather than a variable nothing reads.\n */\nexport const scoped = <T extends ThemeTokens>(\n _theme: T,\n selector: string,\n overrides: Overrides<T>,\n): StyleValue => {\n const tokens: Record<string, Record<string, string>> = {}\n for (const [group, names] of Object.entries(overrides)) {\n const defined: Record<string, string> = {}\n for (const [name, value] of Object.entries(names ?? {})) {\n if (typeof value === 'string') defined[name] = value\n }\n tokens[group] = defined\n }\n return global(`${selector}{${declarations(tokens).join(';')}}`)\n}\n"],"mappings":";;;;;;;;;;;;;AAoBA,MAAM,gBAAgB,OAAoB,SACxC,OAAO,QAAQ,KAAK,CAAC,CAAC,SAAS,CAAC,OAAO,WACrC,OAAO,QAAQ,KAAK,CAAC,CAAC,SAAS,CAAC,MAAM,WACpC,SAAS,KAAA,KAAa,OAAO,OAAO,KAAK,UAAU,CAAC,GAAG,IAAI,IACvD,CAAC,IACD,CAAC,GAAG,WAAW,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,CAChD,CACF;AAEF,MAAa,QAAQ,OAAoB,YACvC,OACE,SAAS,CAAC,GAAG,aAAa,OAAO,SAAS,IAAI,GAAG,gBAAgB,SAAS,eAAe,cAAc,CAAC,CAAC,KAAK,GAAG,EAAE,EACrH;;;;;;;;;;AAgBF,MAAa,UACX,QACA,UACA,cACe;CACf,MAAM,SAAiD,CAAC;CACxD,KAAK,MAAM,CAAC,OAAO,UAAU,OAAO,QAAQ,SAAS,GAAG;EACtD,MAAM,UAAkC,CAAC;EACzC,KAAK,MAAM,CAAC,MAAM,UAAU,OAAO,QAAQ,SAAS,CAAC,CAAC,GACpD,IAAI,OAAO,UAAU,UAAU,QAAQ,QAAQ;EAEjD,OAAO,SAAS;CAClB;CACA,OAAO,OAAO,GAAG,SAAS,GAAG,aAAa,MAAM,CAAC,CAAC,KAAK,GAAG,EAAE,EAAE;AAChE"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as standard } from "./layers-
|
|
1
|
+
import { r as standard } from "./layers-DxWvuCJL.mjs";
|
|
2
2
|
//#region src/inject.ts
|
|
3
3
|
/**
|
|
4
4
|
* Styles that arrive with what uses them. Compiling a Style registers each
|
|
@@ -132,4 +132,4 @@ const drawMarked = (draw) => {
|
|
|
132
132
|
//#endregion
|
|
133
133
|
export { register as a, ensure as i, drawMarked as n, usedIn as o, isMarking as r, SLOT_MARK as t };
|
|
134
134
|
|
|
135
|
-
//# sourceMappingURL=slotMark-
|
|
135
|
+
//# sourceMappingURL=slotMark-y-RLAuTU.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slotMark-
|
|
1
|
+
{"version":3,"file":"slotMark-y-RLAuTU.mjs","names":[],"sources":["../src/inject.ts","../src/slotMark.ts"],"sourcesContent":["/**\n * Styles that arrive with what uses them. Compiling a Style registers each\n * class it produces with that class's CSS; the name is a hash of the CSS, so\n * the registry is the same on the server and in the browser, and holds no DOM.\n *\n * When a Slot draws a class in a browser, the CSS is queued, and one microtask\n * later (after the patch, before the browser paints) appended to a single\n * `<style data-foldkit-styles>` element, unless a stylesheet on the page\n * already carries the class: a static sheet and injection never repeat each\n * other.\n *\n * The registry holds every class compiled in the process and never lets one\n * go, which is bounded by the code when Styles are defined once, as they are\n * meant to be. A Style compiled during a render from data (a width from the\n * Model) would register a class per value; such a value belongs in an inline\n * custom property read by a rule instead.\n */\nimport { standard } from './layers.js'\n\nconst registry = new Map<string, string>()\n\n/** Records the CSS a compiled class stands for. Called by the compiler. */\nexport const register = (className: string, css: string): void => {\n if (!registry.has(className)) registry.set(className, css)\n}\n\n/** A compiled class in CSS text: `.style-` and its hash. */\nconst COMPILED_CLASS = /\\.(style-[0-9a-z]+)/g\n\n/** An `@layer` order statement, as opposed to a layer block. */\nconst LAYER_STATEMENT = /@layer [^{};]+;/g\n\n/** The standard layer order, as one `@layer` statement. */\nconst layerOrder = (): string => standard.declare.globalCss?.join('') ?? ''\n\n/**\n * The CSS for every compiled class that `html` carries, after the standard\n * layer order: what a server puts in a page's head, so it is styled before\n * any script runs. The browser's injection then finds these classes present\n * and adds nothing twice.\n */\nexport const usedIn = (html: string): string => {\n const found = new Set<string>()\n for (const [className] of html.matchAll(/style-[0-9a-z]+/g)) {\n if (registry.has(className)) found.add(className)\n }\n return [layerOrder(), ...[...found].map(className => registry.get(className) ?? '')].join('')\n}\n\n/** What the page carries: counted from its sheets once, then kept as CSS is queued. */\ninterface Page {\n readonly present: Set<string>\n readonly globals: Set<string>\n /** Contributions already handled whole: a Style's are the same object every render. */\n readonly handled: WeakSet<object>\n /** The layer order a sheet on the page declares, which the injected sheet repeats. */\n readonly order: string | undefined\n /** The sheets counted, so a removed one means counting again. */\n readonly counted: ReadonlyArray<HTMLStyleElement>\n element: HTMLStyleElement | undefined\n}\n\nlet page: Page | undefined\nlet pending: Array<string> = []\nlet scheduled = false\n\n/**\n * The page as injection knows it, counted afresh when a sheet it counted or its\n * own element has been removed (by a test's cleanup, or an application\n * replacing the head).\n */\nconst current = (): Page => {\n if (\n page !== undefined &&\n (page.element === undefined || page.element.isConnected) &&\n page.counted.every(sheet => sheet.isConnected)\n )\n return page\n const present = new Set<string>()\n let order: string | undefined\n const counted = Array.from(document.querySelectorAll('style'))\n for (const sheet of counted) {\n const text = sheet.textContent ?? ''\n for (const [, className] of text.matchAll(COMPILED_CLASS))\n if (className !== undefined) present.add(className)\n order ??= text.match(LAYER_STATEMENT)?.[0]\n }\n page = {\n present,\n globals: new Set(),\n handled: new WeakSet(),\n order,\n counted,\n element: undefined,\n }\n return page\n}\n\nconst flush = (): void => {\n scheduled = false\n if (pending.length === 0) return\n const into = current()\n if (into.element === undefined) {\n const element = document.createElement('style')\n element.setAttribute('data-foldkit-styles', '')\n // A layer order first: the page's own, or the standard one where it has\n // none. Layers are ordered by where they are first named, so an injected\n // `@layer components { … }` that came to stand ahead of the page's order\n // (a test's sheet, or an application's, put in after it) would otherwise\n // make `components` the first layer, under the reset.\n element.textContent = into.order ?? layerOrder()\n document.head.appendChild(element)\n into.element = element\n }\n into.element.appendChild(document.createTextNode(pending.join('')))\n pending = []\n}\n\n/**\n * Queues the CSS of each registered class a contribution draws that the page\n * does not carry yet, and its global CSS (keyframes, a theme root) once.\n * Outside a browser it does nothing: a server extracts what it rendered instead.\n */\nexport const ensure = (contribution: {\n readonly classes?: ReadonlyArray<string>\n readonly globalCss?: string\n}): void => {\n if (typeof document === 'undefined') return\n const into = current()\n if (into.handled.has(contribution)) return\n for (const className of contribution.classes ?? []) {\n if (into.present.has(className)) continue\n const css = registry.get(className)\n if (css === undefined) continue\n into.present.add(className)\n pending.push(css)\n }\n const globalCss = contribution.globalCss\n // A layer order is the page's to declare, so a Style's own is not repeated.\n if (globalCss !== undefined && globalCss !== '' && !into.globals.has(globalCss)) {\n into.globals.add(globalCss)\n pending.push(globalCss.replace(LAYER_STATEMENT, ''))\n }\n // Frozen, a contribution cannot draw other classes next time it is drawn.\n if (Object.isFrozen(contribution)) into.handled.add(contribution)\n if (pending.length > 0 && !scheduled) {\n scheduled = true\n queueMicrotask(flush)\n }\n}\n","/**\n * Marking the elements Slots draw with the Slot's name, for\n * `foldkit-mixins/testing`'s `Inert.draw`. Internal: the package index does not\n * export it, and a view drawn for real is never marked.\n */\n\n/** The data attribute a marked element carries: `data-fk-slot=\"row\"`. */\nexport const SLOT_MARK = 'fk-slot'\n\nlet marking = false\n\n/** Whether Slots mark what they draw: only while `drawMarked` runs. */\nexport const isMarking = (): boolean => marking\n\n/** Draws with every Slot, however deeply nested its view, marking its element. */\nexport const drawMarked = <A>(draw: () => A): A => {\n marking = true\n try {\n return draw()\n } finally {\n marking = false\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAmBA,MAAM,2BAAW,IAAI,IAAoB;;AAGzC,MAAa,YAAY,WAAmB,QAAsB;CAChE,IAAI,CAAC,SAAS,IAAI,SAAS,GAAG,SAAS,IAAI,WAAW,GAAG;AAC3D;;AAGA,MAAM,iBAAiB;;AAGvB,MAAM,kBAAkB;;AAGxB,MAAM,mBAA2B,SAAS,QAAQ,WAAW,KAAK,EAAE,KAAK;;;;;;;AAQzE,MAAa,UAAU,SAAyB;CAC9C,MAAM,wBAAQ,IAAI,IAAY;CAC9B,KAAK,MAAM,CAAC,cAAc,KAAK,SAAS,kBAAkB,GACxD,IAAI,SAAS,IAAI,SAAS,GAAG,MAAM,IAAI,SAAS;CAElD,OAAO,CAAC,WAAW,GAAG,GAAG,CAAC,GAAG,KAAK,CAAC,CAAC,KAAI,cAAa,SAAS,IAAI,SAAS,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,EAAE;AAC9F;AAeA,IAAI;AACJ,IAAI,UAAyB,CAAC;AAC9B,IAAI,YAAY;;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AAA,GAAW;EACvB,KAAK,QAAQ,IAAI,SAAS;EAC1B,QAAQ,KAAK,GAAG;CAClB;CACA,MAAM,YAAY,aAAa;CAE/B,IAAI,cAAc,KAAA,KAAa,cAAc,MAAM,CAAC,KAAK,QAAQ,IAAI,SAAS,GAAG;EAC/E,KAAK,QAAQ,IAAI,SAAS;EAC1B,QAAQ,KAAK,UAAU,QAAQ,iBAAiB,EAAE,CAAC;CACrD;CAEA,IAAI,OAAO,SAAS,YAAY,GAAG,KAAK,QAAQ,IAAI,YAAY;CAChE,IAAI,QAAQ,SAAS,KAAK,CAAC,WAAW;EACpC,YAAY;EACZ,eAAe,KAAK;CACtB;AACF;;;;;;;;;AC9IA,MAAa,YAAY;AAEzB,IAAI,UAAU;;AAGd,MAAa,kBAA2B;;AAGxC,MAAa,cAAiB,SAAqB;CACjD,UAAU;CACV,IAAI;EACF,OAAO,KAAK;CACd,UAAU;EACR,UAAU;CACZ;AACF"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
|
|
2
|
-
import { C as className, S as viewTransitionName, T as DiagnosticError, _ as self, a as container, b as toStyleValue, c as global, d as keyframes, f as make$4, g as responsive, h as pseudo, i as compose$1, l as grid, m as nest, n as at, o as empty$1, p as media, r as classPiece, s as enter, t as allowDiscrete, u as inline, v as states, w as css, x as vars, y as supports } from "./styleValue-
|
|
3
|
-
import { a as isUnordered, i as declaredNames, o as layerOf, s as topLevelBlocks } from "./layers-
|
|
4
|
-
import { a as register, i as ensure, o as usedIn, r as isMarking, t as SLOT_MARK } from "./slotMark-
|
|
2
|
+
import { C as className, S as viewTransitionName, T as DiagnosticError, _ as self, a as container, b as toStyleValue, c as global, d as keyframes, f as make$4, g as responsive, h as pseudo, i as compose$1, l as grid, m as nest, n as at, o as empty$1, p as media, r as classPiece, s as enter, t as allowDiscrete, u as inline, v as states, w as css, x as vars, y as supports } from "./styleValue-6hpAYYfg.mjs";
|
|
3
|
+
import { a as isUnordered, i as declaredNames, o as layerOf, s as topLevelBlocks } from "./layers-DxWvuCJL.mjs";
|
|
4
|
+
import { a as register, i as ensure, o as usedIn, r as isMarking, t as SLOT_MARK } from "./slotMark-y-RLAuTU.mjs";
|
|
5
5
|
import { createKeyedLazy, createLazy, inertHtml } from "foldkit/html";
|
|
6
|
-
import { Stream } from "effect";
|
|
6
|
+
import { Cause, Stream } from "effect";
|
|
7
7
|
//#region src/metadataToken.ts
|
|
8
8
|
var metadataToken_exports = /* @__PURE__ */ __exportAll({
|
|
9
9
|
MetadataTokenTypeId: () => MetadataTokenTypeId,
|
|
@@ -371,7 +371,7 @@ const composeMounts = (mounts, slot) => {
|
|
|
371
371
|
}))
|
|
372
372
|
},
|
|
373
373
|
f: (element, viewStateChanges) => Stream.mergeAll(mounts.map((mount) => mount.f(element, viewStateChanges).pipe(Stream.catchCause((cause) => {
|
|
374
|
-
console.error(`[OnMount ${mount.name}] unhandled failure`, cause);
|
|
374
|
+
if (!Cause.hasInterruptsOnly(cause)) console.error(`[OnMount ${mount.name}] unhandled failure`, cause);
|
|
375
375
|
return Stream.empty;
|
|
376
376
|
}))), { concurrency: "unbounded" })
|
|
377
377
|
});
|
|
@@ -1266,4 +1266,4 @@ const Style = {
|
|
|
1266
1266
|
//#endregion
|
|
1267
1267
|
export { extendsCapability as _, slots_exports as a, metadataToken_exports as b, slotView_exports as c, mixin_exports as d, isTagged as f, capability_exports as g, Interactive as h, stylesheet as i, resolver_exports as l, Focusable as m, forSlots as n, slot_exports as o, Container as p, slots as r, attach$1 as s, Style as t, dynamic as u, is$2 as v, nameOf as x, make$3 as y };
|
|
1268
1268
|
|
|
1269
|
-
//# sourceMappingURL=style-
|
|
1269
|
+
//# sourceMappingURL=style-BhOFChc5.mjs.map
|