@weasel-js/theme 1.13.0 → 1.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/dist/{chunk-AAQSJSVD.js → chunk-F5ODXRE3.js} +9 -4
- package/dist/chunk-F5ODXRE3.js.map +1 -0
- package/dist/{chunk-R2SSGWGZ.js → chunk-NCAQ54LO.js} +46 -16
- package/dist/chunk-NCAQ54LO.js.map +1 -0
- package/dist/{chunk-R7OXPHZJ.js → chunk-PYRAKINY.js} +3 -3
- package/dist/{chunk-R7OXPHZJ.js.map → chunk-PYRAKINY.js.map} +1 -1
- package/dist/{definition-wsEi-XBr.d.ts → definition-nZbgRG7A.d.ts} +13 -7
- package/dist/engine.d.ts +2 -2
- package/dist/engine.js +102 -65
- package/dist/engine.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +5 -5
- package/dist/prefs.d.ts +17 -3
- package/dist/prefs.js +24 -4
- package/dist/prefs.js.map +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/react.js +3 -3
- package/dist/themes/platinum.d.ts +1 -1
- package/dist/themes/platinum.js +1 -1
- package/dist/themes/win9x.d.ts +1 -1
- package/dist/themes/win9x.js +1 -1
- package/dist/tokens.css +9 -5
- package/package.json +4 -4
- package/dist/chunk-AAQSJSVD.js.map +0 -1
- package/dist/chunk-R2SSGWGZ.js.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { generate, DEFAULT_CONSTRAINTS } from './chunk-S7MJPFDP.js';
|
|
2
2
|
import { readCssNumber } from './chunk-M3R5MV7Q.js';
|
|
3
3
|
import { themeAxes, resolveTheme, atAlpha, withAlpha, themeChain } from './chunk-32JKTYS2.js';
|
|
4
|
-
import { weaselTheme } from './chunk-
|
|
4
|
+
import { weaselTheme } from './chunk-NCAQ54LO.js';
|
|
5
5
|
import { fullSelection } from './chunk-P5F3GZV6.js';
|
|
6
6
|
import { resolvePaletteColor, colorLiteralToCss, parseColor, interpolateSrgb, rgbaToHex, cssColorLiteral } from '@weasel-js/paint';
|
|
7
7
|
|
|
@@ -335,5 +335,5 @@ function colorCssAt(list, i, ctx = defaultContext()) {
|
|
|
335
335
|
}
|
|
336
336
|
|
|
337
337
|
export { TINT_REF, applyTheme, blendTheme, colorAt, colorCount, colorCssAt, colorSourceCss, colorSourceLiteral, isColorModePreference, rampSteps, resolveCurrentColor, themeTints };
|
|
338
|
-
//# sourceMappingURL=chunk-
|
|
339
|
-
//# sourceMappingURL=chunk-
|
|
338
|
+
//# sourceMappingURL=chunk-PYRAKINY.js.map
|
|
339
|
+
//# sourceMappingURL=chunk-PYRAKINY.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/blendTheme.ts","../src/themeSheet.ts","../src/applyTheme.ts","../src/currentColor.ts","../src/colorMode.ts","../src/colorListItems.ts","../src/colorSource.ts","../src/colorList.ts"],"names":["colorLiteralToCss"],"mappings":";;;;;;;AAcA,IAAM,QAAA,GAAW,CAAC,OAAA,KAAyC,OAAA,CAAQ,OAAO,CAAC,IAAA,EAAM,CAAA,KAAO,CAAA,CAAE,MAAA,GAAS,IAAA,CAAK,MAAA,GAAS,CAAA,GAAI,IAAK,CAAA,CAAE,GAAA;AAE5H,SAAS,aAAa,OAAA,EAAkD;AACtE,EAAA,IAAI,GAAA,GAAM,CAAA;AACV,EAAA,IAAI,KAAA,GAAQ,CAAA;AACZ,EAAA,IAAI,IAAA;AACJ,EAAA,KAAA,MAAW,EAAE,GAAA,EAAK,MAAA,EAAO,IAAK,OAAA,EAAS;AACrC,IAAA,MAAM,IAAA,GAAO,cAAc,GAAG,CAAA;AAC9B,IAAA,IAAI,CAAC,IAAA,IAAS,IAAA,KAAS,UAAa,IAAA,CAAK,IAAA,KAAS,MAAO,OAAO,MAAA;AAChE,IAAA,IAAA,GAAO,IAAA,CAAK,IAAA;AACZ,IAAA,GAAA,IAAO,KAAK,KAAA,GAAQ,MAAA;AACpB,IAAA,KAAA,I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,OAAA,GAAU,kBAAA,CAAmB,IAAA,EAAM,GAAG,CAAA;AAC5C,EAAA,OAAO,QAAA,CAAS,OAAA,IAAWA,iBAAAA,CAAkB,OAAO,GAAG,CAAC,CAAA;AAC1D;AAOO,SAAS,UAAA,CAAW,IAAA,EAAiB,CAAA,EAAW,GAAA,GAA0B,gBAAe,EAAW;AACzG,EAAA,IAAI,MAAA,CAAO,IAAI,CAAA,EAAG,OAAO,CAAA,IAAA,EAAO,aAAa,IAAA,EAAM,CAAA,EAAG,GAAA,CAAI,KAAK,CAAC,CAAA,CAAA,CAAA;AAChE,EAAA,MAAM,IAAA,GAAO,WAAA,CAAY,IAAA,EAAM,CAAC,CAAA;AAChC,EAAA,OAAO,OAAO,SAAS,QAAA,GAAW,IAAA,GAAO,SAAS,cAAA,CAAe,IAAA,EAAM,GAAG,CAAA,EAAG,CAAC,CAAA;AAChF","file":"chunk-R7OXPHZJ.js","sourcesContent":["import { interpolateSrgb, parseColor, rgbaToHex } from '@weasel-js/paint';\nimport { fullSelection, type Selection } from './axes.ts';\nimport { readCssNumber } from './cssNumber.ts';\nimport { resolveTheme, themeAxes, type ResolvedTheme } from './resolveTheme.ts';\nimport type { Theme } from './theme.ts';\n\n/** A weight for each value of each axis a blend is made along. A value left out weighs nothing. */\nexport type AxisWeights = Readonly<Record<string, Readonly<Record<string, number>>>>;\n\ninterface Weighted {\n readonly css: string;\n readonly weight: number;\n}\n\nconst heaviest = (members: readonly Weighted[]): string => members.reduce((most, m) => (m.weight > most.weight ? m : most)).css;\n\nfunction blendNumbers(members: readonly Weighted[]): string | undefined {\n let sum = 0;\n let total = 0;\n let unit: string | undefined;\n for (const { css, weight } of members) {\n const read = readCssNumber(css);\n if (!read || (unit !== undefined && read.unit !== unit)) return undefined;\n unit = read.unit;\n sum += read.value * weight;\n total += weight;\n }\n return `${Number((sum / total).toFixed(4))}${unit}`;\n}\n\nfunction blendColors(members: readonly Weighted[]): string | undefined {\n let mixed: [number, number, number, number] | undefined;\n let total = 0;\n for (const { css, weight } of members) {\n let next: readonly [number, number, number, number];\n try {\n next = parseColor(css);\n } catch {\n return undefined;\n }\n total += weight;\n if (!mixed) {\n mixed = [...next];\n continue;\n }\n const t = weight / total;\n const [r, g, b] = interpolateSrgb([mixed[0], mixed[1], mixed[2]], [next[0], next[1], next[2]], t, 'oklch');\n mixed = [r, g, b, mixed[3] + (next[3] - mixed[3]) * t];\n }\n return rgbaToHex(mixed!);\n}\n\nfunction blend(members: readonly Weighted[]): string {\n if (members.every((m) => m.css === members[0]!.css)) return members[0]!.css;\n return blendNumbers(members) ?? blendColors(members) ?? heaviest(members);\n}\n\n/**\n * `theme` partway between values of its axes: resolved at every selection\n * `weights` gives a share to, and each token folded from what it resolved to\n * there. A color mixes in OKLCH and a number with one unit throughout mixes\n * linearly; any other value is the heaviest selection's, the first on a tie.\n * It is the resolved values that mix, never the rules behind them, so a token\n * that is an alias in one mode and a literal in the other blends like any\n * other. An axis `weights` leaves out stays at `selection`.\n */\nexport function blendTheme(theme: Theme, weights: AxisWeights, selection: Selection = {}): ResolvedTheme {\n const axes = themeAxes(theme);\n let at: { selection: Selection; weight: number }[] = [{ selection: fullSelection(axes, selection), weight: 1 }];\n for (const [axis, shares] of Object.entries(weights)) {\n if (!Object.hasOwn(axes, axis)) continue;\n const given = Object.entries(shares).filter(([value, share]) => share > 0 && Object.hasOwn(axes[axis]!.values, value));\n if (given.length === 0) continue;\n at = at.flatMap((one) => given.map(([value, share]) => ({ selection: { ...one.selection, [axis]: value }, weight: one.weight * share })));\n }\n const resolved = at.map((one) => ({ tokens: resolveTheme(theme, one.selection) as Record<string, string>, weight: one.weight }));\n if (resolved.length === 1) return resolved[0]!.tokens as ResolvedTheme;\n\n const out: Record<string, string> = {};\n const names = new Set(resolved.flatMap((one) => Object.keys(one.tokens)));\n for (const name of names) {\n out[name] = blend(resolved.filter((one) => one.tokens[name] !== undefined).map((one) => ({ css: one.tokens[name]!, weight: one.weight })));\n }\n return out as ResolvedTheme;\n}\n","/**\n * The stylesheet a document or a shadow root holds its themes' rules in, and\n * the count of what still uses each one.\n *\n * A rule lives where its elements do: a popout window's document and a shadow\n * root each get a sheet of their own, since a rule in the opener's document\n * styles nothing in either. A rule nobody holds any more leaves its sheet, so\n * a page that mints a theme per instance holds only the live ones.\n */\n\n/** Where an element's styles come from. */\nexport type StyleRoot = Document | ShadowRoot;\n\nconst STYLE_ID = 'wzl-themes';\n\ninterface Variant {\n /** 0 is the definition that has the bare selector; a second, different\n * definition held at once under the same name and selection gets its own. */\n id: number;\n body: string;\n holds: number;\n}\n\ninterface RootSheet {\n /** `selector` → the definitions held under it. */\n rules: Map<string, Variant[]>;\n sheet: CSSStyleSheet | null;\n styleEl: HTMLStyleElement | null;\n}\n\nlet sheets = new WeakMap<StyleRoot, RootSheet>();\n\n/** Test seam: forgets every sheet, so each case starts clean. */\nexport function __resetThemeSheet(): void {\n sheets = new WeakMap();\n}\n\n/** The root `el`'s styles come from: its shadow root, else its document. */\nexport function styleRootOf(el: Element): StyleRoot {\n const root = el.getRootNode();\n return root instanceof (el.ownerDocument.defaultView?.ShadowRoot ?? ShadowRoot) ? (root as ShadowRoot) : el.ownerDocument;\n}\n\nconst documentOf = (root: StyleRoot): Document => ('host' in root ? root.ownerDocument : root);\n\n/** The selector suffix that keeps a variant's rule off the other definitions' elements, at no cost in specificity. */\nconst only = (id: number): string => (id === 0 ? '' : `:where([data-wzl-variant='${id}'])`);\n\nfunction write(root: StyleRoot, held: RootSheet): void {\n const css = [...held.rules]\n .flatMap(([selector, variants]) =>\n // The bare rule first: it matches a variant's elements too, and the variant's has to win the tie.\n [...variants].sort((a, b) => a.id - b.id).map((v) => `${selector}${only(v.id)} { ${v.body} }`))\n .join('\\n');\n // Not `@weasel-js/react`'s `adoptCss`: this entry loads without React.\n const win = documentOf(root).defaultView;\n const Sheet = win?.CSSStyleSheet;\n if (Sheet && 'replaceSync' in Sheet.prototype && Array.isArray(root.adoptedStyleSheets)) {\n if (!held.sheet) {\n // From the root's own window: a constructed sheet cannot be adopted across documents.\n held.sheet = new Sheet();\n root.adoptedStyleSheets = [...root.adoptedStyleSheets, held.sheet];\n }\n held.sheet.replaceSync(css);\n return;\n }\n if (!held.styleEl) {\n held.styleEl = documentOf(root).createElement('style');\n held.styleEl.id = STYLE_ID;\n ('host' in root ? root : root.head).appendChild(held.styleEl);\n }\n held.styleEl.textContent = css;\n}\n\n/**\n * Hold the rule `selector { body }` in `root`'s sheet. Returns the variant id\n * the holder's element is to carry (0 for none) and the release, which takes\n * the rule out of the sheet once nothing else holds it.\n */\nexport function holdRule(root: StyleRoot, selector: string, body: string): { variant: number; release: () => void } {\n let held = sheets.get(root);\n if (!held) sheets.set(root, (held = { rules: new Map(), sheet: null, styleEl: null }));\n const variants = held.rules.get(selector) ?? [];\n let variant = variants.find((v) => v.body === body);\n if (variant) {\n variant.holds++;\n } else {\n let id = 0;\n while (variants.some((v) => v.id === id)) id++;\n variant = { id, body, holds: 1 };\n held.rules.set(selector, [...variants, variant]);\n write(root, held);\n }\n const mine = variant;\n const sheet = held;\n let released = false;\n return {\n variant: mine.id,\n release: () => {\n if (released) return;\n released = true;\n if (--mine.holds > 0) return;\n const left = (sheet.rules.get(selector) ?? []).filter((v) => v !== mine);\n if (left.length > 0) sheet.rules.set(selector, left);\n else sheet.rules.delete(selector);\n write(root, sheet);\n },\n };\n}\n","import { fullSelection, type Selection } from './axes';\nimport { blendTheme, type AxisWeights } from './blendTheme';\nimport { resolveTheme, themeAxes } from './resolveTheme';\nimport type { Theme } from './theme';\nimport { holdRule, styleRootOf } from './themeSheet';\n\nexport { __resetThemeSheet } from './themeSheet';\n\n/** What an element holds from its last `applyTheme`, so the next one, or its release, can let go of it. */\nconst holds = new WeakMap<HTMLElement, () => void>();\n\n/**\n * Apply `theme` at `selection` to `el`'s subtree, and return the release.\n *\n * Stamps `data-wzl-theme` and one `data-wzl-<axis>` per axis, and holds a\n * matching rule block in the stylesheet of the document or shadow root `el`\n * lives in. Deliberately not inline properties: the cascade then does the\n * work, per-subtree overrides are just a different theme name, and no\n * `!important` is ever needed. No-op outside a DOM.\n *\n * An element holds one application: applying again replaces what it held, so\n * a caller restyling one root never has to release. The release is for a\n * subtree that goes away. It takes the attributes back off and lets go of the\n * rule, which leaves the sheet once no element holds it; a release whose\n * element has since been given something else does nothing.\n *\n * With `weights`, the rule holds the theme blended along the axes they name\n * (see `blendTheme`), under the same attributes: applying again with the next\n * weights is one step of a transition between two selections.\n *\n * Two different themes may share a name. The second held at once has its rule\n * kept to its own elements by a `data-wzl-variant` attribute, matched inside\n * `:where()` so the rule's specificity is the first's.\n */\nexport function applyTheme(el: HTMLElement, theme: Theme, selection: Selection = {}, options: { weights?: AxisWeights } = {}): () => void {\n if (typeof document === 'undefined') return () => {};\n\n const axes = themeAxes(theme);\n const sel = fullSelection(axes, selection);\n const body = Object.entries(options.weights ? blendTheme(theme, options.weights, sel) : resolveTheme(theme, sel))\n .map(([name, value]) => `${name}: ${value};`)\n .join(' ');\n const names = Object.keys(axes);\n const selector = `[data-wzl-theme='${theme.name}']${names.map((a) => `[data-wzl-${a}='${sel[a]}']`).join('')}`;\n // Held before the last one is let go, so re-applying the same rule rewrites nothing.\n const { variant, release: releaseRule } = holdRule(styleRootOf(el), selector, body);\n holds.get(el)?.();\n\n el.setAttribute('data-wzl-theme', theme.name);\n for (const a of names) el.setAttribute(`data-wzl-${a}`, sel[a]);\n if (variant === 0) el.removeAttribute('data-wzl-variant');\n else el.setAttribute('data-wzl-variant', String(variant));\n\n // The attributes go only through `release`: a hold replaced by the next application leaves them to it.\n const letGo = (): void => {\n holds.delete(el);\n releaseRule();\n };\n holds.set(el, letGo);\n return () => {\n if (holds.get(el) !== letGo) return;\n letGo();\n for (const a of ['theme', 'variant', ...names]) el.removeAttribute(`data-wzl-${a}`);\n };\n}\n","import { atAlpha, withAlpha } from './dtcg/color.ts';\n\nconst NUMBER = String.raw`(\\d*\\.?\\d+)(%?)`;\nconst RELATIVE = new RegExp(String.raw`^rgb\\(\\s*from\\s+currentcolor\\s+r\\s+g\\s+b\\s*/\\s*${NUMBER}\\s*\\)$`, 'i');\nconst MIX = new RegExp(String.raw`^color-mix\\(\\s*in\\s+[\\w-]+\\s*,\\s*currentcolor\\s+${NUMBER}\\s*,\\s*transparent\\s*\\)$`, 'i');\n\nconst fraction = (n: string, pct: string) => Number(n) / (pct ? 100 : 1);\n\n/**\n * A resolved token value with `currentColor` taken to be `current`, for a surface drawn without the\n * cascade — a canvas reading a resolved theme — where `currentColor` has nothing to resolve against.\n * Pass the color of the text the value is drawn beside, usually `--wzl-fg`. A value that never\n * mentions `currentColor` comes back unchanged.\n *\n * Flattens the forms the kit's themes write: bare `currentColor`, `rgb(from currentColor r g b / a)`\n * and `color-mix(in <space>, currentColor p%, transparent)`. Throws on any other use of it.\n */\nexport function resolveCurrentColor(value: string, current: string): string {\n const v = value.trim();\n if (!/currentcolor/i.test(v)) return value;\n if (/^currentcolor$/i.test(v)) return current;\n const rel = RELATIVE.exec(v);\n if (rel) return atAlpha(current, fraction(rel[1], rel[2]));\n const mix = MIX.exec(v);\n if (mix && mix[2] === '%') return withAlpha(current, fraction(mix[1], mix[2]));\n throw new Error(`resolveCurrentColor: cannot flatten \"${value}\"`);\n}\n","/** A color mode the theme's `mode` axis resolves. */\nexport type ColorMode = 'light' | 'dark';\n\n/**\n * What a user chose: a mode, or `'auto'` — follow the OS, live. `'auto'` is\n * not a mode; resolve it with `useResolvedColorMode` before handing it to a\n * `ThemeProvider` selection.\n */\nexport type ColorModePreference = 'auto' | ColorMode;\n\n/** Whether a value — say, one read back from storage — is a preference. */\nexport function isColorModePreference(v: unknown): v is ColorModePreference {\n return v === 'auto' || v === 'light' || v === 'dark';\n}\n","import type { ColorLiteral, ColorRef, ColorSource, Palette } from '@weasel-js/paint';\nimport type { CategoricalRampDef } from './definition.ts';\nimport { DEFAULT_CONSTRAINTS, generate, type Constraints } from './engine/color/generate.ts';\nimport { resolveTheme, themeChain, type ResolvedTheme } from './resolveTheme.ts';\nimport { weaselTheme, type Theme } from './theme.ts';\n\n/** The categorical generator the swatch ramp uses, asked for `count` colors. */\nexport interface GeneratedColors {\n readonly generate: { readonly count: number; readonly gates?: CategoricalRampDef['gates'] };\n}\n\n/** A ramp of the active theme, by name — `{ ramp: 'swatch' }` walks its steps in order. */\nexport interface RampColors {\n readonly ramp: string;\n}\n\n/** One color of a list: a CSS color string, or a `ColorSource` resolved when it is read. */\nexport type ColorListItem = string | ColorSource;\n\n/** The forms a theme definition can hold: everything but a function. */\nexport type SerializableColorList = readonly (string | ColorLiteral | ColorRef)[] | GeneratedColors | RampColors;\n\n/**\n * Several colors, read by index with `colorAt`, wrapping. Items, each a CSS\n * string or a `ColorSource`; the swatch ramp's generator; a ramp of the active\n * theme, which follows the mode; or a function of the index.\n */\nexport type ColorList = readonly ColorListItem[] | GeneratedColors | RampColors | ((i: number) => ColorListItem);\n\n/** What a `ColorList` resolves against. `useTheme()`'s value is one. */\nexport interface ColorContext {\n readonly theme: Theme;\n readonly resolved: ResolvedTheme;\n}\n\n/** What a `ColorSource` resolves against under a theme. `useTints()`'s value is one. */\nexport interface ColorSourceContext extends ColorContext {\n /** The list `{ ref: 'tint' }` indexes. Absent: the theme's own. */\n readonly tints?: ColorList;\n /** Names answered before the theme's. */\n readonly palette?: Palette;\n}\n\nconst wrap = (i: number, n: number) => ((Math.trunc(i) % n) + n) % n;\n\nconst generated = new Map<string, readonly string[]>();\n\nfunction generatedColors({ generate: g }: GeneratedColors): readonly string[] {\n const key = JSON.stringify([g.count, g.gates ?? {}]);\n let colors = generated.get(key);\n if (!colors) {\n const palette = generate({ ...DEFAULT_CONSTRAINTS, ...(g.gates as Partial<Constraints>), count: g.count, anchors: [] });\n colors = palette.swatches.map((s) => s.hex.toLowerCase());\n generated.set(key, colors);\n }\n return colors;\n}\n\n/** `rampSteps`, answering `undefined` for a ramp the chain lacks. */\nexport function findRampSteps(theme: Theme, ramp: string): readonly string[] | undefined {\n for (const t of themeChain(theme).reverse()) {\n const steps = t.ramps?.[ramp];\n if (steps) return steps;\n }\n return undefined;\n}\n\n/** A ramp's step names, from the nearest theme in the chain that declares it. */\nexport function rampSteps(theme: Theme, ramp: string): readonly string[] {\n const steps = findRampSteps(theme, ramp);\n if (!steps) throw new Error(`Theme \"${theme.name}\" has no ramp \"${ramp}\"`);\n return steps;\n}\n\n/** The tint list a theme declares, from the nearest theme in its chain that has one. */\nexport function themeTints(theme: Theme): ColorList {\n for (const t of themeChain(theme).reverse()) if (t.tints) return t.tints;\n return { ramp: 'swatch' };\n}\n\nlet fallback: ColorContext | undefined;\nexport const defaultContext = () => (fallback ??= { theme: weaselTheme, resolved: resolveTheme(weaselTheme) });\n\nconst pickStep = (list: RampColors, i: number, theme: Theme): string => {\n const steps = rampSteps(theme, list.ramp);\n return steps[wrap(i, steps.length)];\n};\n\n/** The custom property behind the `i`th step of a ramp list, wrapping. */\nexport const rampProperty = (list: RampColors, i: number, theme: Theme): string =>\n `--wzl-${list.ramp}-${pickStep(list, i, theme)}`;\n\nexport const isRamp = (list: ColorList): list is RampColors => typeof list !== 'function' && 'ramp' in list;\n\n/** The `i`th item of a list that is not a ramp, wrapping, as it was written. */\nexport function colorItemAt(list: Exclude<ColorList, RampColors>, i: number): ColorListItem {\n if (typeof list === 'function') return list(i);\n const colors = 'generate' in list ? generatedColors(list) : list;\n if (colors.length === 0) throw new Error('colorAt: empty color list');\n return colors[wrap(i, colors.length)];\n}\n\n/** How many distinct colors `list` holds before it wraps; `undefined` for a function, which never does. */\nexport function colorCount(list: ColorList, ctx: ColorContext = defaultContext()): number | undefined {\n if (typeof list === 'function') return undefined;\n if ('ramp' in list) return rampSteps(ctx.theme, list.ramp).length;\n return 'generate' in list ? list.generate.count : list.length;\n}\n","import {\n colorLiteralToCss,\n cssColorLiteral,\n resolvePaletteColor,\n type ColorFnContext,\n type ColorLiteral,\n type ColorRef,\n type ColorSource,\n type Palette,\n} from '@weasel-js/paint';\nimport {\n colorItemAt,\n defaultContext,\n findRampSteps,\n isRamp,\n rampProperty,\n themeTints,\n type ColorList,\n type ColorSourceContext,\n} from './colorListItems.ts';\nimport { resolveCurrentColor } from './currentColor.ts';\n\n/** The name the tint list answers to: `{ ref: 'tint', index: 2 }` is the third tint, wrapping. */\nexport const TINT_REF = 'tint';\n\nexport type { ColorSourceContext };\n\nconst NO_PALETTE: Palette = { entries: [] };\n\nconst tintsOf = (ctx: ColorSourceContext): ColorList => ctx.tints ?? themeTints(ctx.theme);\n\nfunction parsed(css: string): ColorLiteral | null {\n try {\n return cssColorLiteral(css);\n } catch {\n return null;\n }\n}\n\n/** The custom property a theme ref names: itself when spelled as one, a token by name, or a ramp step by index. */\nfunction propertyOf(ref: ColorRef, ctx: ColorSourceContext): string | null {\n if (ref.ref.startsWith('--')) return ref.index === undefined ? ref.ref : null;\n if (ref.index === undefined) return `--wzl-${ref.ref}`;\n const step = findRampSteps(ctx.theme, ref.ref)?.[ref.index];\n return step === undefined ? null : `--wzl-${ref.ref}-${step}`;\n}\n\nfunction tokenLiteral(property: string, ctx: ColorSourceContext): ColorLiteral | null {\n const value = (ctx.resolved as Readonly<Record<string, string>>)[property];\n if (value === undefined) return null;\n try {\n return parsed(resolveCurrentColor(value, ctx.resolved['--wzl-fg']));\n } catch {\n return null;\n }\n}\n\nconst isRef = (source: ColorSource): source is ColorRef => typeof source !== 'function' && 'ref' in source;\n\nfunction tintSource(index: number, ctx: ColorSourceContext): ColorSource | null {\n const tints = tintsOf(ctx);\n if (isRamp(tints)) return tokenLiteral(rampProperty(tints, index, ctx.theme), ctx);\n const item = colorItemAt(tints, index);\n return typeof item === 'string' ? parsed(item) : item;\n}\n\nfunction themeSource(ref: ColorRef, ctx: ColorSourceContext): ColorSource | null {\n if (ref.ref === TINT_REF) return tintSource(ref.index ?? 0, ctx);\n const property = propertyOf(ref, ctx);\n return property === null ? null : tokenLiteral(property, ctx);\n}\n\n/**\n * Resolve `source` to a literal, for a surface drawn without the cascade. A ref\n * names an entry of the context's palette first, then the theme: `tint` with an\n * index into the tint list, a token by its name without the `--wzl-` prefix, a\n * ramp by its name with the index of a step, or a custom property spelled out.\n * `null` for a name nothing answers, a token that is not a color, and a custom\n * property the theme does not define.\n */\nexport function colorSourceLiteral(source: ColorSource, ctx: ColorSourceContext = defaultContext()): ColorLiteral | null {\n return resolvePaletteColor(ctx.palette ?? NO_PALETTE, source, (ref) => themeSource(ref, ctx));\n}\n\nfunction literalCss(source: ColorSource, ctx: ColorSourceContext): string | null {\n const literal = colorSourceLiteral(source, ctx);\n return literal && colorLiteralToCss(literal);\n}\n\nfunction tintCss(source: ColorRef, ctx: ColorSourceContext): string | null {\n const tints = tintsOf(ctx);\n const index = source.index ?? 0;\n if (isRamp(tints)) return `var(${rampProperty(tints, index, ctx.theme)})`;\n const item = colorItemAt(tints, index);\n if (typeof item === 'string') return item;\n return isRef(item) && item.ref !== TINT_REF ? colorSourceCss(item, ctx) : literalCss(source, ctx);\n}\n\nfunction themeRefCss(ref: ColorRef, ctx: ColorSourceContext): string | null {\n if (ref.ref === TINT_REF) return tintCss(ref, ctx);\n const property = propertyOf(ref, ctx);\n if (property === null) return null;\n return ref.ref.startsWith('--') || tokenLiteral(property, ctx) ? `var(${property})` : null;\n}\n\nfunction nth<T>(items: Iterable<T>, n: number): T | undefined {\n let i = 0;\n for (const item of items) if (i++ === n) return item;\n return undefined;\n}\n\n/**\n * The theme ref `source` comes down to when followed by name alone, through\n * palette entries and functions that only name another color. `null` when it\n * ends anywhere else, or when a function read a color to compute its own.\n */\nfunction namedThemeRef(source: ColorSource, ctx: ColorSourceContext): ColorRef | null {\n const entries = ctx.palette?.entries ?? [];\n const seen = new Set<string>();\n let read = false;\n const fnCtx: ColorFnContext = {\n resolve: (s) => {\n read = true;\n return colorSourceLiteral(s, ctx);\n },\n };\n let at: ColorSource | null | undefined = source;\n while (at != null && !read) {\n if (typeof at === 'function') {\n at = at(fnCtx);\n continue;\n }\n if (!isRef(at)) return null;\n const { ref, index = 0 } = at;\n const entry = entries.find((e) => e.name === ref);\n if (!entry) return at;\n const key = `${index}:${ref}`;\n if (seen.has(key)) return null;\n seen.add(key);\n if ('color' in entry) at = index === 0 ? entry.color : null;\n else at = nth(entry.colors(fnCtx), index);\n }\n return null;\n}\n\n/**\n * `source` as a CSS color, naming what `colorSourceLiteral` resolves. A source\n * that comes down to a ref the theme answers, directly or through palette\n * entries and functions that only name another color, is written as that\n * ref's custom property: it follows the cascade with no re-render, and a\n * property spelled out need not be the theme's. Everything else is written as\n * the literal it resolves to in `ctx`, which includes a function that reads a\n * color through `resolve` to compute its own.\n */\nexport function colorSourceCss(source: ColorSource, ctx: ColorSourceContext = defaultContext()): string | null {\n const named = namedThemeRef(source, ctx);\n return named ? themeRefCss(named, ctx) : literalCss(source, ctx);\n}\n","import { colorLiteralToCss } from '@weasel-js/paint';\nimport { colorItemAt, defaultContext, isRamp, rampProperty, type ColorList, type ColorSourceContext } from './colorListItems.ts';\nimport { colorSourceCss, colorSourceLiteral } from './colorSource.ts';\nimport type { ResolvedTheme } from './resolveTheme.ts';\n\nexport {\n colorCount,\n findRampSteps,\n rampSteps,\n themeTints,\n type ColorContext,\n type ColorList,\n type ColorListItem,\n type GeneratedColors,\n type RampColors,\n type SerializableColorList,\n} from './colorListItems.ts';\n\nfunction answered(css: string | null, i: number): string {\n if (css === null) throw new Error(`colorAt: nothing answers item ${i} of the color list`);\n return css;\n}\n\n/**\n * The `i`th color of `list`, wrapping. A ramp list reads the resolved theme, so\n * the answer follows its mode; a `ColorSource` item resolves against the\n * context's palette, then its theme. Throws on an item nothing answers.\n */\nexport function colorAt(list: ColorList, i: number, ctx: ColorSourceContext = defaultContext()): string {\n if (isRamp(list)) return ctx.resolved[rampProperty(list, i, ctx.theme) as keyof ResolvedTheme];\n const item = colorItemAt(list, i);\n if (typeof item === 'string') return item;\n const literal = colorSourceLiteral(item, ctx);\n return answered(literal && colorLiteralToCss(literal), i);\n}\n\n/**\n * As `colorAt`, but a ramp list, and an item that names the theme, answers\n * with its custom property (`var(--wzl-swatch-sky)`), so a color written into\n * CSS follows a mode change without re-rendering, provider or not.\n */\nexport function colorCssAt(list: ColorList, i: number, ctx: ColorSourceContext = defaultContext()): string {\n if (isRamp(list)) return `var(${rampProperty(list, i, ctx.theme)})`;\n const item = colorItemAt(list, i);\n return typeof item === 'string' ? item : answered(colorSourceCss(item, ctx), i);\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/blendTheme.ts","../src/themeSheet.ts","../src/applyTheme.ts","../src/currentColor.ts","../src/colorMode.ts","../src/colorListItems.ts","../src/colorSource.ts","../src/colorList.ts"],"names":["colorLiteralToCss"],"mappings":";;;;;;;AAcA,IAAM,QAAA,GAAW,CAAC,OAAA,KAAyC,OAAA,CAAQ,OAAO,CAAC,IAAA,EAAM,CAAA,KAAO,CAAA,CAAE,MAAA,GAAS,IAAA,CAAK,MAAA,GAAS,CAAA,GAAI,IAAK,CAAA,CAAE,GAAA;AAE5H,SAAS,aAAa,OAAA,EAAkD;AACtE,EAAA,IAAI,GAAA,GAAM,CAAA;AACV,EAAA,IAAI,KAAA,GAAQ,CAAA;AACZ,EAAA,IAAI,IAAA;AACJ,EAAA,KAAA,MAAW,EAAE,GAAA,EAAK,MAAA,EAAO,IAAK,OAAA,EAAS;AACrC,IAAA,MAAM,IAAA,GAAO,cAAc,GAAG,CAAA;AAC9B,IAAA,IAAI,CAAC,IAAA,IAAS,IAAA,KAAS,UAAa,IAAA,CAAK,IAAA,KAAS,MAAO,OAAO,MAAA;AAChE,IAAA,IAAA,GAAO,IAAA,CAAK,IAAA;AACZ,IAAA,GAAA,IAAO,KAAK,KAAA,GAAQ,MAAA;AACpB,IAAA,KAAA,IAAS,MAAA;AAAA,EACX;AACA,EAAA,OAAO,CAAA,EAAG,QAAQ,GAAA,GAAM,KAAA,EAAO,QAAQ,CAAC,CAAC,CAAC,CAAA,EAAG,IAAI,CAAA,CAAA;AACnD;AAEA,SAAS,YAAY,OAAA,EAAkD;AACrE,EAAA,IAAI,KA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AA,GAA0B,gBAAe,EAAW;AACzG,EAAA,IAAI,MAAA,CAAO,IAAI,CAAA,EAAG,OAAO,CAAA,IAAA,EAAO,aAAa,IAAA,EAAM,CAAA,EAAG,GAAA,CAAI,KAAK,CAAC,CAAA,CAAA,CAAA;AAChE,EAAA,MAAM,IAAA,GAAO,WAAA,CAAY,IAAA,EAAM,CAAC,CAAA;AAChC,EAAA,OAAO,OAAO,SAAS,QAAA,GAAW,IAAA,GAAO,SAAS,cAAA,CAAe,IAAA,EAAM,GAAG,CAAA,EAAG,CAAC,CAAA;AAChF","file":"chunk-PYRAKINY.js","sourcesContent":["import { interpolateSrgb, parseColor, rgbaToHex } from '@weasel-js/paint';\nimport { fullSelection, type Selection } from './axes.ts';\nimport { readCssNumber } from './cssNumber.ts';\nimport { resolveTheme, themeAxes, type ResolvedTheme } from './resolveTheme.ts';\nimport type { Theme } from './theme.ts';\n\n/** A weight for each value of each axis a blend is made along. A value left out weighs nothing. */\nexport type AxisWeights = Readonly<Record<string, Readonly<Record<string, number>>>>;\n\ninterface Weighted {\n readonly css: string;\n readonly weight: number;\n}\n\nconst heaviest = (members: readonly Weighted[]): string => members.reduce((most, m) => (m.weight > most.weight ? m : most)).css;\n\nfunction blendNumbers(members: readonly Weighted[]): string | undefined {\n let sum = 0;\n let total = 0;\n let unit: string | undefined;\n for (const { css, weight } of members) {\n const read = readCssNumber(css);\n if (!read || (unit !== undefined && read.unit !== unit)) return undefined;\n unit = read.unit;\n sum += read.value * weight;\n total += weight;\n }\n return `${Number((sum / total).toFixed(4))}${unit}`;\n}\n\nfunction blendColors(members: readonly Weighted[]): string | undefined {\n let mixed: [number, number, number, number] | undefined;\n let total = 0;\n for (const { css, weight } of members) {\n let next: readonly [number, number, number, number];\n try {\n next = parseColor(css);\n } catch {\n return undefined;\n }\n total += weight;\n if (!mixed) {\n mixed = [...next];\n continue;\n }\n const t = weight / total;\n const [r, g, b] = interpolateSrgb([mixed[0], mixed[1], mixed[2]], [next[0], next[1], next[2]], t, 'oklch');\n mixed = [r, g, b, mixed[3] + (next[3] - mixed[3]) * t];\n }\n return rgbaToHex(mixed!);\n}\n\nfunction blend(members: readonly Weighted[]): string {\n if (members.every((m) => m.css === members[0]!.css)) return members[0]!.css;\n return blendNumbers(members) ?? blendColors(members) ?? heaviest(members);\n}\n\n/**\n * `theme` partway between values of its axes: resolved at every selection\n * `weights` gives a share to, and each token folded from what it resolved to\n * there. A color mixes in OKLCH and a number with one unit throughout mixes\n * linearly; any other value is the heaviest selection's, the first on a tie.\n * It is the resolved values that mix, never the rules behind them, so a token\n * that is an alias in one mode and a literal in the other blends like any\n * other. An axis `weights` leaves out stays at `selection`.\n */\nexport function blendTheme(theme: Theme, weights: AxisWeights, selection: Selection = {}): ResolvedTheme {\n const axes = themeAxes(theme);\n let at: { selection: Selection; weight: number }[] = [{ selection: fullSelection(axes, selection), weight: 1 }];\n for (const [axis, shares] of Object.entries(weights)) {\n if (!Object.hasOwn(axes, axis)) continue;\n const given = Object.entries(shares).filter(([value, share]) => share > 0 && Object.hasOwn(axes[axis]!.values, value));\n if (given.length === 0) continue;\n at = at.flatMap((one) => given.map(([value, share]) => ({ selection: { ...one.selection, [axis]: value }, weight: one.weight * share })));\n }\n const resolved = at.map((one) => ({ tokens: resolveTheme(theme, one.selection) as Record<string, string>, weight: one.weight }));\n if (resolved.length === 1) return resolved[0]!.tokens as ResolvedTheme;\n\n const out: Record<string, string> = {};\n const names = new Set(resolved.flatMap((one) => Object.keys(one.tokens)));\n for (const name of names) {\n out[name] = blend(resolved.filter((one) => one.tokens[name] !== undefined).map((one) => ({ css: one.tokens[name]!, weight: one.weight })));\n }\n return out as ResolvedTheme;\n}\n","/**\n * The stylesheet a document or a shadow root holds its themes' rules in, and\n * the count of what still uses each one.\n *\n * A rule lives where its elements do: a popout window's document and a shadow\n * root each get a sheet of their own, since a rule in the opener's document\n * styles nothing in either. A rule nobody holds any more leaves its sheet, so\n * a page that mints a theme per instance holds only the live ones.\n */\n\n/** Where an element's styles come from. */\nexport type StyleRoot = Document | ShadowRoot;\n\nconst STYLE_ID = 'wzl-themes';\n\ninterface Variant {\n /** 0 is the definition that has the bare selector; a second, different\n * definition held at once under the same name and selection gets its own. */\n id: number;\n body: string;\n holds: number;\n}\n\ninterface RootSheet {\n /** `selector` → the definitions held under it. */\n rules: Map<string, Variant[]>;\n sheet: CSSStyleSheet | null;\n styleEl: HTMLStyleElement | null;\n}\n\nlet sheets = new WeakMap<StyleRoot, RootSheet>();\n\n/** Test seam: forgets every sheet, so each case starts clean. */\nexport function __resetThemeSheet(): void {\n sheets = new WeakMap();\n}\n\n/** The root `el`'s styles come from: its shadow root, else its document. */\nexport function styleRootOf(el: Element): StyleRoot {\n const root = el.getRootNode();\n return root instanceof (el.ownerDocument.defaultView?.ShadowRoot ?? ShadowRoot) ? (root as ShadowRoot) : el.ownerDocument;\n}\n\nconst documentOf = (root: StyleRoot): Document => ('host' in root ? root.ownerDocument : root);\n\n/** The selector suffix that keeps a variant's rule off the other definitions' elements, at no cost in specificity. */\nconst only = (id: number): string => (id === 0 ? '' : `:where([data-wzl-variant='${id}'])`);\n\nfunction write(root: StyleRoot, held: RootSheet): void {\n const css = [...held.rules]\n .flatMap(([selector, variants]) =>\n // The bare rule first: it matches a variant's elements too, and the variant's has to win the tie.\n [...variants].sort((a, b) => a.id - b.id).map((v) => `${selector}${only(v.id)} { ${v.body} }`))\n .join('\\n');\n // Not `@weasel-js/react`'s `adoptCss`: this entry loads without React.\n const win = documentOf(root).defaultView;\n const Sheet = win?.CSSStyleSheet;\n if (Sheet && 'replaceSync' in Sheet.prototype && Array.isArray(root.adoptedStyleSheets)) {\n if (!held.sheet) {\n // From the root's own window: a constructed sheet cannot be adopted across documents.\n held.sheet = new Sheet();\n root.adoptedStyleSheets = [...root.adoptedStyleSheets, held.sheet];\n }\n held.sheet.replaceSync(css);\n return;\n }\n if (!held.styleEl) {\n held.styleEl = documentOf(root).createElement('style');\n held.styleEl.id = STYLE_ID;\n ('host' in root ? root : root.head).appendChild(held.styleEl);\n }\n held.styleEl.textContent = css;\n}\n\n/**\n * Hold the rule `selector { body }` in `root`'s sheet. Returns the variant id\n * the holder's element is to carry (0 for none) and the release, which takes\n * the rule out of the sheet once nothing else holds it.\n */\nexport function holdRule(root: StyleRoot, selector: string, body: string): { variant: number; release: () => void } {\n let held = sheets.get(root);\n if (!held) sheets.set(root, (held = { rules: new Map(), sheet: null, styleEl: null }));\n const variants = held.rules.get(selector) ?? [];\n let variant = variants.find((v) => v.body === body);\n if (variant) {\n variant.holds++;\n } else {\n let id = 0;\n while (variants.some((v) => v.id === id)) id++;\n variant = { id, body, holds: 1 };\n held.rules.set(selector, [...variants, variant]);\n write(root, held);\n }\n const mine = variant;\n const sheet = held;\n let released = false;\n return {\n variant: mine.id,\n release: () => {\n if (released) return;\n released = true;\n if (--mine.holds > 0) return;\n const left = (sheet.rules.get(selector) ?? []).filter((v) => v !== mine);\n if (left.length > 0) sheet.rules.set(selector, left);\n else sheet.rules.delete(selector);\n write(root, sheet);\n },\n };\n}\n","import { fullSelection, type Selection } from './axes';\nimport { blendTheme, type AxisWeights } from './blendTheme';\nimport { resolveTheme, themeAxes } from './resolveTheme';\nimport type { Theme } from './theme';\nimport { holdRule, styleRootOf } from './themeSheet';\n\nexport { __resetThemeSheet } from './themeSheet';\n\n/** What an element holds from its last `applyTheme`, so the next one, or its release, can let go of it. */\nconst holds = new WeakMap<HTMLElement, () => void>();\n\n/**\n * Apply `theme` at `selection` to `el`'s subtree, and return the release.\n *\n * Stamps `data-wzl-theme` and one `data-wzl-<axis>` per axis, and holds a\n * matching rule block in the stylesheet of the document or shadow root `el`\n * lives in. Deliberately not inline properties: the cascade then does the\n * work, per-subtree overrides are just a different theme name, and no\n * `!important` is ever needed. No-op outside a DOM.\n *\n * An element holds one application: applying again replaces what it held, so\n * a caller restyling one root never has to release. The release is for a\n * subtree that goes away. It takes the attributes back off and lets go of the\n * rule, which leaves the sheet once no element holds it; a release whose\n * element has since been given something else does nothing.\n *\n * With `weights`, the rule holds the theme blended along the axes they name\n * (see `blendTheme`), under the same attributes: applying again with the next\n * weights is one step of a transition between two selections.\n *\n * Two different themes may share a name. The second held at once has its rule\n * kept to its own elements by a `data-wzl-variant` attribute, matched inside\n * `:where()` so the rule's specificity is the first's.\n */\nexport function applyTheme(el: HTMLElement, theme: Theme, selection: Selection = {}, options: { weights?: AxisWeights } = {}): () => void {\n if (typeof document === 'undefined') return () => {};\n\n const axes = themeAxes(theme);\n const sel = fullSelection(axes, selection);\n const body = Object.entries(options.weights ? blendTheme(theme, options.weights, sel) : resolveTheme(theme, sel))\n .map(([name, value]) => `${name}: ${value};`)\n .join(' ');\n const names = Object.keys(axes);\n const selector = `[data-wzl-theme='${theme.name}']${names.map((a) => `[data-wzl-${a}='${sel[a]}']`).join('')}`;\n // Held before the last one is let go, so re-applying the same rule rewrites nothing.\n const { variant, release: releaseRule } = holdRule(styleRootOf(el), selector, body);\n holds.get(el)?.();\n\n el.setAttribute('data-wzl-theme', theme.name);\n for (const a of names) el.setAttribute(`data-wzl-${a}`, sel[a]);\n if (variant === 0) el.removeAttribute('data-wzl-variant');\n else el.setAttribute('data-wzl-variant', String(variant));\n\n // The attributes go only through `release`: a hold replaced by the next application leaves them to it.\n const letGo = (): void => {\n holds.delete(el);\n releaseRule();\n };\n holds.set(el, letGo);\n return () => {\n if (holds.get(el) !== letGo) return;\n letGo();\n for (const a of ['theme', 'variant', ...names]) el.removeAttribute(`data-wzl-${a}`);\n };\n}\n","import { atAlpha, withAlpha } from './dtcg/color.ts';\n\nconst NUMBER = String.raw`(\\d*\\.?\\d+)(%?)`;\nconst RELATIVE = new RegExp(String.raw`^rgb\\(\\s*from\\s+currentcolor\\s+r\\s+g\\s+b\\s*/\\s*${NUMBER}\\s*\\)$`, 'i');\nconst MIX = new RegExp(String.raw`^color-mix\\(\\s*in\\s+[\\w-]+\\s*,\\s*currentcolor\\s+${NUMBER}\\s*,\\s*transparent\\s*\\)$`, 'i');\n\nconst fraction = (n: string, pct: string) => Number(n) / (pct ? 100 : 1);\n\n/**\n * A resolved token value with `currentColor` taken to be `current`, for a surface drawn without the\n * cascade — a canvas reading a resolved theme — where `currentColor` has nothing to resolve against.\n * Pass the color of the text the value is drawn beside, usually `--wzl-fg`. A value that never\n * mentions `currentColor` comes back unchanged.\n *\n * Flattens the forms the kit's themes write: bare `currentColor`, `rgb(from currentColor r g b / a)`\n * and `color-mix(in <space>, currentColor p%, transparent)`. Throws on any other use of it.\n */\nexport function resolveCurrentColor(value: string, current: string): string {\n const v = value.trim();\n if (!/currentcolor/i.test(v)) return value;\n if (/^currentcolor$/i.test(v)) return current;\n const rel = RELATIVE.exec(v);\n if (rel) return atAlpha(current, fraction(rel[1], rel[2]));\n const mix = MIX.exec(v);\n if (mix && mix[2] === '%') return withAlpha(current, fraction(mix[1], mix[2]));\n throw new Error(`resolveCurrentColor: cannot flatten \"${value}\"`);\n}\n","/** A color mode the theme's `mode` axis resolves. */\nexport type ColorMode = 'light' | 'dark';\n\n/**\n * What a user chose: a mode, or `'auto'` — follow the OS, live. `'auto'` is\n * not a mode; resolve it with `useResolvedColorMode` before handing it to a\n * `ThemeProvider` selection.\n */\nexport type ColorModePreference = 'auto' | ColorMode;\n\n/** Whether a value — say, one read back from storage — is a preference. */\nexport function isColorModePreference(v: unknown): v is ColorModePreference {\n return v === 'auto' || v === 'light' || v === 'dark';\n}\n","import type { ColorLiteral, ColorRef, ColorSource, Palette } from '@weasel-js/paint';\nimport type { CategoricalRampDef } from './definition.ts';\nimport { DEFAULT_CONSTRAINTS, generate, type Constraints } from './engine/color/generate.ts';\nimport { resolveTheme, themeChain, type ResolvedTheme } from './resolveTheme.ts';\nimport { weaselTheme, type Theme } from './theme.ts';\n\n/** The categorical generator the swatch ramp uses, asked for `count` colors. */\nexport interface GeneratedColors {\n readonly generate: { readonly count: number; readonly gates?: CategoricalRampDef['gates'] };\n}\n\n/** A ramp of the active theme, by name — `{ ramp: 'swatch' }` walks its steps in order. */\nexport interface RampColors {\n readonly ramp: string;\n}\n\n/** One color of a list: a CSS color string, or a `ColorSource` resolved when it is read. */\nexport type ColorListItem = string | ColorSource;\n\n/** The forms a theme definition can hold: everything but a function. */\nexport type SerializableColorList = readonly (string | ColorLiteral | ColorRef)[] | GeneratedColors | RampColors;\n\n/**\n * Several colors, read by index with `colorAt`, wrapping. Items, each a CSS\n * string or a `ColorSource`; the swatch ramp's generator; a ramp of the active\n * theme, which follows the mode; or a function of the index.\n */\nexport type ColorList = readonly ColorListItem[] | GeneratedColors | RampColors | ((i: number) => ColorListItem);\n\n/** What a `ColorList` resolves against. `useTheme()`'s value is one. */\nexport interface ColorContext {\n readonly theme: Theme;\n readonly resolved: ResolvedTheme;\n}\n\n/** What a `ColorSource` resolves against under a theme. `useTints()`'s value is one. */\nexport interface ColorSourceContext extends ColorContext {\n /** The list `{ ref: 'tint' }` indexes. Absent: the theme's own. */\n readonly tints?: ColorList;\n /** Names answered before the theme's. */\n readonly palette?: Palette;\n}\n\nconst wrap = (i: number, n: number) => ((Math.trunc(i) % n) + n) % n;\n\nconst generated = new Map<string, readonly string[]>();\n\nfunction generatedColors({ generate: g }: GeneratedColors): readonly string[] {\n const key = JSON.stringify([g.count, g.gates ?? {}]);\n let colors = generated.get(key);\n if (!colors) {\n const palette = generate({ ...DEFAULT_CONSTRAINTS, ...(g.gates as Partial<Constraints>), count: g.count, anchors: [] });\n colors = palette.swatches.map((s) => s.hex.toLowerCase());\n generated.set(key, colors);\n }\n return colors;\n}\n\n/** `rampSteps`, answering `undefined` for a ramp the chain lacks. */\nexport function findRampSteps(theme: Theme, ramp: string): readonly string[] | undefined {\n for (const t of themeChain(theme).reverse()) {\n const steps = t.ramps?.[ramp];\n if (steps) return steps;\n }\n return undefined;\n}\n\n/** A ramp's step names, from the nearest theme in the chain that declares it. */\nexport function rampSteps(theme: Theme, ramp: string): readonly string[] {\n const steps = findRampSteps(theme, ramp);\n if (!steps) throw new Error(`Theme \"${theme.name}\" has no ramp \"${ramp}\"`);\n return steps;\n}\n\n/** The tint list a theme declares, from the nearest theme in its chain that has one. */\nexport function themeTints(theme: Theme): ColorList {\n for (const t of themeChain(theme).reverse()) if (t.tints) return t.tints;\n return { ramp: 'swatch' };\n}\n\nlet fallback: ColorContext | undefined;\nexport const defaultContext = () => (fallback ??= { theme: weaselTheme, resolved: resolveTheme(weaselTheme) });\n\nconst pickStep = (list: RampColors, i: number, theme: Theme): string => {\n const steps = rampSteps(theme, list.ramp);\n return steps[wrap(i, steps.length)];\n};\n\n/** The custom property behind the `i`th step of a ramp list, wrapping. */\nexport const rampProperty = (list: RampColors, i: number, theme: Theme): string =>\n `--wzl-${list.ramp}-${pickStep(list, i, theme)}`;\n\nexport const isRamp = (list: ColorList): list is RampColors => typeof list !== 'function' && 'ramp' in list;\n\n/** The `i`th item of a list that is not a ramp, wrapping, as it was written. */\nexport function colorItemAt(list: Exclude<ColorList, RampColors>, i: number): ColorListItem {\n if (typeof list === 'function') return list(i);\n const colors = 'generate' in list ? generatedColors(list) : list;\n if (colors.length === 0) throw new Error('colorAt: empty color list');\n return colors[wrap(i, colors.length)];\n}\n\n/** How many distinct colors `list` holds before it wraps; `undefined` for a function, which never does. */\nexport function colorCount(list: ColorList, ctx: ColorContext = defaultContext()): number | undefined {\n if (typeof list === 'function') return undefined;\n if ('ramp' in list) return rampSteps(ctx.theme, list.ramp).length;\n return 'generate' in list ? list.generate.count : list.length;\n}\n","import {\n colorLiteralToCss,\n cssColorLiteral,\n resolvePaletteColor,\n type ColorFnContext,\n type ColorLiteral,\n type ColorRef,\n type ColorSource,\n type Palette,\n} from '@weasel-js/paint';\nimport {\n colorItemAt,\n defaultContext,\n findRampSteps,\n isRamp,\n rampProperty,\n themeTints,\n type ColorList,\n type ColorSourceContext,\n} from './colorListItems.ts';\nimport { resolveCurrentColor } from './currentColor.ts';\n\n/** The name the tint list answers to: `{ ref: 'tint', index: 2 }` is the third tint, wrapping. */\nexport const TINT_REF = 'tint';\n\nexport type { ColorSourceContext };\n\nconst NO_PALETTE: Palette = { entries: [] };\n\nconst tintsOf = (ctx: ColorSourceContext): ColorList => ctx.tints ?? themeTints(ctx.theme);\n\nfunction parsed(css: string): ColorLiteral | null {\n try {\n return cssColorLiteral(css);\n } catch {\n return null;\n }\n}\n\n/** The custom property a theme ref names: itself when spelled as one, a token by name, or a ramp step by index. */\nfunction propertyOf(ref: ColorRef, ctx: ColorSourceContext): string | null {\n if (ref.ref.startsWith('--')) return ref.index === undefined ? ref.ref : null;\n if (ref.index === undefined) return `--wzl-${ref.ref}`;\n const step = findRampSteps(ctx.theme, ref.ref)?.[ref.index];\n return step === undefined ? null : `--wzl-${ref.ref}-${step}`;\n}\n\nfunction tokenLiteral(property: string, ctx: ColorSourceContext): ColorLiteral | null {\n const value = (ctx.resolved as Readonly<Record<string, string>>)[property];\n if (value === undefined) return null;\n try {\n return parsed(resolveCurrentColor(value, ctx.resolved['--wzl-fg']));\n } catch {\n return null;\n }\n}\n\nconst isRef = (source: ColorSource): source is ColorRef => typeof source !== 'function' && 'ref' in source;\n\nfunction tintSource(index: number, ctx: ColorSourceContext): ColorSource | null {\n const tints = tintsOf(ctx);\n if (isRamp(tints)) return tokenLiteral(rampProperty(tints, index, ctx.theme), ctx);\n const item = colorItemAt(tints, index);\n return typeof item === 'string' ? parsed(item) : item;\n}\n\nfunction themeSource(ref: ColorRef, ctx: ColorSourceContext): ColorSource | null {\n if (ref.ref === TINT_REF) return tintSource(ref.index ?? 0, ctx);\n const property = propertyOf(ref, ctx);\n return property === null ? null : tokenLiteral(property, ctx);\n}\n\n/**\n * Resolve `source` to a literal, for a surface drawn without the cascade. A ref\n * names an entry of the context's palette first, then the theme: `tint` with an\n * index into the tint list, a token by its name without the `--wzl-` prefix, a\n * ramp by its name with the index of a step, or a custom property spelled out.\n * `null` for a name nothing answers, a token that is not a color, and a custom\n * property the theme does not define.\n */\nexport function colorSourceLiteral(source: ColorSource, ctx: ColorSourceContext = defaultContext()): ColorLiteral | null {\n return resolvePaletteColor(ctx.palette ?? NO_PALETTE, source, (ref) => themeSource(ref, ctx));\n}\n\nfunction literalCss(source: ColorSource, ctx: ColorSourceContext): string | null {\n const literal = colorSourceLiteral(source, ctx);\n return literal && colorLiteralToCss(literal);\n}\n\nfunction tintCss(source: ColorRef, ctx: ColorSourceContext): string | null {\n const tints = tintsOf(ctx);\n const index = source.index ?? 0;\n if (isRamp(tints)) return `var(${rampProperty(tints, index, ctx.theme)})`;\n const item = colorItemAt(tints, index);\n if (typeof item === 'string') return item;\n return isRef(item) && item.ref !== TINT_REF ? colorSourceCss(item, ctx) : literalCss(source, ctx);\n}\n\nfunction themeRefCss(ref: ColorRef, ctx: ColorSourceContext): string | null {\n if (ref.ref === TINT_REF) return tintCss(ref, ctx);\n const property = propertyOf(ref, ctx);\n if (property === null) return null;\n return ref.ref.startsWith('--') || tokenLiteral(property, ctx) ? `var(${property})` : null;\n}\n\nfunction nth<T>(items: Iterable<T>, n: number): T | undefined {\n let i = 0;\n for (const item of items) if (i++ === n) return item;\n return undefined;\n}\n\n/**\n * The theme ref `source` comes down to when followed by name alone, through\n * palette entries and functions that only name another color. `null` when it\n * ends anywhere else, or when a function read a color to compute its own.\n */\nfunction namedThemeRef(source: ColorSource, ctx: ColorSourceContext): ColorRef | null {\n const entries = ctx.palette?.entries ?? [];\n const seen = new Set<string>();\n let read = false;\n const fnCtx: ColorFnContext = {\n resolve: (s) => {\n read = true;\n return colorSourceLiteral(s, ctx);\n },\n };\n let at: ColorSource | null | undefined = source;\n while (at != null && !read) {\n if (typeof at === 'function') {\n at = at(fnCtx);\n continue;\n }\n if (!isRef(at)) return null;\n const { ref, index = 0 } = at;\n const entry = entries.find((e) => e.name === ref);\n if (!entry) return at;\n const key = `${index}:${ref}`;\n if (seen.has(key)) return null;\n seen.add(key);\n if ('color' in entry) at = index === 0 ? entry.color : null;\n else at = nth(entry.colors(fnCtx), index);\n }\n return null;\n}\n\n/**\n * `source` as a CSS color, naming what `colorSourceLiteral` resolves. A source\n * that comes down to a ref the theme answers, directly or through palette\n * entries and functions that only name another color, is written as that\n * ref's custom property: it follows the cascade with no re-render, and a\n * property spelled out need not be the theme's. Everything else is written as\n * the literal it resolves to in `ctx`, which includes a function that reads a\n * color through `resolve` to compute its own.\n */\nexport function colorSourceCss(source: ColorSource, ctx: ColorSourceContext = defaultContext()): string | null {\n const named = namedThemeRef(source, ctx);\n return named ? themeRefCss(named, ctx) : literalCss(source, ctx);\n}\n","import { colorLiteralToCss } from '@weasel-js/paint';\nimport { colorItemAt, defaultContext, isRamp, rampProperty, type ColorList, type ColorSourceContext } from './colorListItems.ts';\nimport { colorSourceCss, colorSourceLiteral } from './colorSource.ts';\nimport type { ResolvedTheme } from './resolveTheme.ts';\n\nexport {\n colorCount,\n findRampSteps,\n rampSteps,\n themeTints,\n type ColorContext,\n type ColorList,\n type ColorListItem,\n type GeneratedColors,\n type RampColors,\n type SerializableColorList,\n} from './colorListItems.ts';\n\nfunction answered(css: string | null, i: number): string {\n if (css === null) throw new Error(`colorAt: nothing answers item ${i} of the color list`);\n return css;\n}\n\n/**\n * The `i`th color of `list`, wrapping. A ramp list reads the resolved theme, so\n * the answer follows its mode; a `ColorSource` item resolves against the\n * context's palette, then its theme. Throws on an item nothing answers.\n */\nexport function colorAt(list: ColorList, i: number, ctx: ColorSourceContext = defaultContext()): string {\n if (isRamp(list)) return ctx.resolved[rampProperty(list, i, ctx.theme) as keyof ResolvedTheme];\n const item = colorItemAt(list, i);\n if (typeof item === 'string') return item;\n const literal = colorSourceLiteral(item, ctx);\n return answered(literal && colorLiteralToCss(literal), i);\n}\n\n/**\n * As `colorAt`, but a ramp list, and an item that names the theme, answers\n * with its custom property (`var(--wzl-swatch-sky)`), so a color written into\n * CSS follows a mode change without re-rendering, provider or not.\n */\nexport function colorCssAt(list: ColorList, i: number, ctx: ColorSourceContext = defaultContext()): string {\n if (isRamp(list)) return `var(${rampProperty(list, i, ctx.theme)})`;\n const item = colorItemAt(list, i);\n return typeof item === 'string' ? item : answered(colorSourceCss(item, ctx), i);\n}\n"]}
|
|
@@ -74,7 +74,7 @@ declare function bakeChain(definition: ThemeDefinition, lookup?: Lookup): BakedT
|
|
|
74
74
|
|
|
75
75
|
/** Every design token the built-in themes declare, spelled as the CSS
|
|
76
76
|
* custom property it becomes. */
|
|
77
|
-
type TokenName = '--wzl-accent' | '--wzl-accent-base' | '--wzl-accent-fg' | '--wzl-accent-hover' | '--wzl-accent-soft' | '--wzl-accent-strong' | '--wzl-backdrop' | '--wzl-border' | '--wzl-border-on-sunken' | '--wzl-border-strong' | '--wzl-border-w' | '--wzl-checker-a' | '--wzl-checker-b' | '--wzl-checker-size' | '--wzl-code-constant' | '--wzl-code-keyword' | '--wzl-code-name' | '--wzl-code-number' | '--wzl-code-property' | '--wzl-code-string' | '--wzl-control-h' | '--wzl-control-h-sm' | '--wzl-control-h-xs' | '--wzl-curve-color' | '--wzl-curve-width' | '--wzl-danger' | '--wzl-danger-base' | '--wzl-ease-in-cubic' | '--wzl-ease-in-out-cubic' | '--wzl-ease-out-back' | '--wzl-ease-out-cubic' | '--wzl-fg' | '--wzl-fg-inverse' | '--wzl-fg-muted' | '--wzl-fg-muted-on-accent' | '--wzl-fg-on-accent' | '--wzl-fg-subtle' | '--wzl-fg-subtle-on-accent' | '--wzl-field-pad-x' | '--wzl-focus-ring' | '--wzl-font-body' | '--wzl-font-display' | '--wzl-font-mono' | '--wzl-font-numeric' | '--wzl-font-size' | '--wzl-font-size-2xs' | '--wzl-font-size-lg' | '--wzl-font-size-md' | '--wzl-font-size-sm' | '--wzl-font-size-xl' | '--wzl-font-size-xs' | '--wzl-font-ui' | '--wzl-font-weight-bold' | '--wzl-font-weight-light' | '--wzl-font-weight-medium' | '--wzl-font-weight-normal' | '--wzl-glass-blur' | '--wzl-glass-tint' | '--wzl-gloss' | '--wzl-gray-100' | '--wzl-gray-200' | '--wzl-gray-300' | '--wzl-gray-400' | '--wzl-gray-50' | '--wzl-gray-500' | '--wzl-gray-600' | '--wzl-gray-700' | '--wzl-gray-800' | '--wzl-gray-900' | '--wzl-handle-dot-size' | '--wzl-handle-dot-size-sm' | '--wzl-handle-size' | '--wzl-handle-size-lg' | '--wzl-handle-size-sm' | '--wzl-icon-button-size' | '--wzl-info' | '--wzl-info-base' | '--wzl-leading' | '--wzl-leading-snug' | '--wzl-leading-tight' | '--wzl-line' | '--wzl-line-strong' | '--wzl-line-subtle' | '--wzl-line-width' | '--wzl-motion-fast' | '--wzl-motion-medium' | '--wzl-panel-blur' | '--wzl-panel-border-color' | '--wzl-panel-border-style' | '--wzl-panel-border-width' | '--wzl-panel-pad' | '--wzl-panel-radius' | '--wzl-panel-surface' | '--wzl-panel-tint-mix' | '--wzl-panel-title-case' | '--wzl-panel-title-color' | '--wzl-panel-title-font' | '--wzl-panel-title-inset' | '--wzl-panel-title-size' | '--wzl-panel-title-tracking' | '--wzl-panel-title-weight' | '--wzl-radius-lg' | '--wzl-radius-md' | '--wzl-radius-pill' | '--wzl-radius-sm' | '--wzl-scrim' | '--wzl-secondary' | '--wzl-secondary-base' | '--wzl-secondary-fg' | '--wzl-secondary-soft' | '--wzl-secondary-strong' | '--wzl-shadow' | '--wzl-slider-thumb-mix' | '--wzl-slider-thumb-size' | '--wzl-slider-thumb-slop' | '--wzl-slider-track-h' | '--wzl-slider-track-mix' | '--wzl-slider-track-slop' | '--wzl-space-1' | '--wzl-space-2' | '--wzl-space-3' | '--wzl-space-4' | '--wzl-space-5' | '--wzl-space-6' | '--wzl-space-7' | '--wzl-space-8' | '--wzl-space-lg' | '--wzl-space-md' | '--wzl-space-sm' | '--wzl-space-xs' | '--wzl-stance-advanced-title-color' | '--wzl-stance-aside-blur' | '--wzl-stance-aside-border-color' | '--wzl-stance-aside-surface' | '--wzl-stance-aside-title-color' | '--wzl-stance-clarify-border-width' | '--wzl-stance-clarify-nested-radius' | '--wzl-stance-clarify-nested-surface' | '--wzl-stance-clarify-radius' | '--wzl-stance-clarify-tint-mix' | '--wzl-stance-debug-border-style' | '--wzl-stance-debug-title-case' | '--wzl-stance-debug-title-font' | '--wzl-stance-preview-pad' | '--wzl-stance-preview-title-case' | '--wzl-stance-preview-title-inset' | '--wzl-stance-preview-title-size' | '--wzl-success' | '--wzl-success-base' | '--wzl-surface' | '--wzl-surface-hover' | '--wzl-surface-popover' | '--wzl-surface-pressed' | '--wzl-surface-raised' | '--wzl-surface-sunken' | '--wzl-swatch-amber' | '--wzl-swatch-blue' | '--wzl-swatch-citron' | '--wzl-swatch-fuchsia' | '--wzl-swatch-green' | '--wzl-swatch-red' | '--wzl-swatch-rose' | '--wzl-swatch-sky' | '--wzl-swatch-teal' | '--wzl-swatch-violet' | '--wzl-tb-height' | '--wzl-tracking-none' | '--wzl-tracking-wide' | '--wzl-tracking-wider' | '--wzl-warning' | '--wzl-warning-base' | '--wzl-workspace-line' | '--wzl-workspace-surface' | '--wzl-z-drag' | '--wzl-z-hud' | '--wzl-z-modal' | '--wzl-z-overlay' | '--wzl-z-popover' | '--wzl-z-toast' | '--wzl-z-toolbar';
|
|
77
|
+
type TokenName = '--wzl-accent' | '--wzl-accent-base' | '--wzl-accent-fg' | '--wzl-accent-hover' | '--wzl-accent-soft' | '--wzl-accent-strong' | '--wzl-backdrop' | '--wzl-border' | '--wzl-border-on-sunken' | '--wzl-border-strong' | '--wzl-border-w' | '--wzl-checker-a' | '--wzl-checker-b' | '--wzl-checker-size' | '--wzl-code-constant' | '--wzl-code-keyword' | '--wzl-code-name' | '--wzl-code-number' | '--wzl-code-property' | '--wzl-code-string' | '--wzl-control-h' | '--wzl-control-h-sm' | '--wzl-control-h-xs' | '--wzl-curve-color' | '--wzl-curve-width' | '--wzl-danger' | '--wzl-danger-base' | '--wzl-ease-in-cubic' | '--wzl-ease-in-out-cubic' | '--wzl-ease-out-back' | '--wzl-ease-out-cubic' | '--wzl-fg' | '--wzl-fg-inverse' | '--wzl-fg-muted' | '--wzl-fg-muted-on-accent' | '--wzl-fg-on-accent' | '--wzl-fg-subtle' | '--wzl-fg-subtle-on-accent' | '--wzl-field-pad-x' | '--wzl-focus-ring' | '--wzl-font-body' | '--wzl-font-display' | '--wzl-font-mono' | '--wzl-font-numeric' | '--wzl-font-size' | '--wzl-font-size-2xs' | '--wzl-font-size-lg' | '--wzl-font-size-md' | '--wzl-font-size-sm' | '--wzl-font-size-xl' | '--wzl-font-size-xs' | '--wzl-font-ui' | '--wzl-font-weight-bold' | '--wzl-font-weight-light' | '--wzl-font-weight-medium' | '--wzl-font-weight-normal' | '--wzl-glass-blur' | '--wzl-glass-tint' | '--wzl-gloss' | '--wzl-gray-100' | '--wzl-gray-200' | '--wzl-gray-300' | '--wzl-gray-400' | '--wzl-gray-50' | '--wzl-gray-500' | '--wzl-gray-600' | '--wzl-gray-700' | '--wzl-gray-800' | '--wzl-gray-900' | '--wzl-handle-dot-size' | '--wzl-handle-dot-size-sm' | '--wzl-handle-size' | '--wzl-handle-size-lg' | '--wzl-handle-size-sm' | '--wzl-icon-button-size' | '--wzl-info' | '--wzl-info-base' | '--wzl-leading' | '--wzl-leading-snug' | '--wzl-leading-tight' | '--wzl-line' | '--wzl-line-strong' | '--wzl-line-subtle' | '--wzl-line-width' | '--wzl-motion-fast' | '--wzl-motion-medium' | '--wzl-panel-blur' | '--wzl-panel-border-color' | '--wzl-panel-border-style' | '--wzl-panel-border-width' | '--wzl-panel-pad' | '--wzl-panel-radius' | '--wzl-panel-surface' | '--wzl-panel-tint-mix' | '--wzl-panel-title-case' | '--wzl-panel-title-color' | '--wzl-panel-title-font' | '--wzl-panel-title-inset' | '--wzl-panel-title-size' | '--wzl-panel-title-tracking' | '--wzl-panel-title-weight' | '--wzl-radius-lg' | '--wzl-radius-md' | '--wzl-radius-pill' | '--wzl-radius-sm' | '--wzl-scrim' | '--wzl-secondary' | '--wzl-secondary-base' | '--wzl-secondary-fg' | '--wzl-secondary-soft' | '--wzl-secondary-strong' | '--wzl-shadow' | '--wzl-slider-thumb-mix' | '--wzl-slider-thumb-size' | '--wzl-slider-thumb-slop' | '--wzl-slider-track-h' | '--wzl-slider-track-mix' | '--wzl-slider-track-slop' | '--wzl-space-1' | '--wzl-space-2' | '--wzl-space-3' | '--wzl-space-4' | '--wzl-space-5' | '--wzl-space-6' | '--wzl-space-7' | '--wzl-space-8' | '--wzl-space-lg' | '--wzl-space-md' | '--wzl-space-sm' | '--wzl-space-xs' | '--wzl-stance-advanced-title-color' | '--wzl-stance-aside-blur' | '--wzl-stance-aside-border-color' | '--wzl-stance-aside-surface' | '--wzl-stance-aside-title-color' | '--wzl-stance-clarify-border-width' | '--wzl-stance-clarify-nested-radius' | '--wzl-stance-clarify-nested-surface' | '--wzl-stance-clarify-radius' | '--wzl-stance-clarify-tint-mix' | '--wzl-stance-debug-border-style' | '--wzl-stance-debug-title-case' | '--wzl-stance-debug-title-font' | '--wzl-stance-preview-pad' | '--wzl-stance-preview-title-case' | '--wzl-stance-preview-title-inset' | '--wzl-stance-preview-title-size' | '--wzl-success' | '--wzl-success-base' | '--wzl-surface' | '--wzl-surface-hover' | '--wzl-surface-popover' | '--wzl-surface-pressed' | '--wzl-surface-raised' | '--wzl-surface-sunken' | '--wzl-swatch-amber' | '--wzl-swatch-blue' | '--wzl-swatch-citron' | '--wzl-swatch-fuchsia' | '--wzl-swatch-green' | '--wzl-swatch-red' | '--wzl-swatch-rose' | '--wzl-swatch-sky' | '--wzl-swatch-teal' | '--wzl-swatch-violet' | '--wzl-tb-height' | '--wzl-tracking-none' | '--wzl-tracking-wide' | '--wzl-tracking-wider' | '--wzl-warning' | '--wzl-warning-base' | '--wzl-workspace' | '--wzl-workspace-line' | '--wzl-workspace-surface' | '--wzl-z-drag' | '--wzl-z-hud' | '--wzl-z-modal' | '--wzl-z-overlay' | '--wzl-z-popover' | '--wzl-z-toast' | '--wzl-z-toolbar';
|
|
78
78
|
/** A built-in theme with its aliases already collapsed: every selection
|
|
79
79
|
* (keyed `mode=dark`, axes in declaration order) maps every token name to
|
|
80
80
|
* a final CSS value. */
|
|
@@ -256,8 +256,9 @@ declare const THEMES: {
|
|
|
256
256
|
readonly '--wzl-checker-a': "#25272c";
|
|
257
257
|
readonly '--wzl-checker-b': "#181a1e";
|
|
258
258
|
readonly '--wzl-checker-size': "8px";
|
|
259
|
-
readonly '--wzl-workspace-surface': "#
|
|
259
|
+
readonly '--wzl-workspace-surface': "#272727";
|
|
260
260
|
readonly '--wzl-workspace-line': "rgba(230, 231, 233, 0.1)";
|
|
261
|
+
readonly '--wzl-workspace': "repeating-linear-gradient(45deg, transparent 0 8px, var(--wzl-workspace-line) 8px 16px) var(--wzl-workspace-surface)";
|
|
261
262
|
readonly '--wzl-field-pad-x': "8px";
|
|
262
263
|
readonly '--wzl-gloss': "0";
|
|
263
264
|
readonly '--wzl-font-size': "13px";
|
|
@@ -438,8 +439,9 @@ declare const THEMES: {
|
|
|
438
439
|
readonly '--wzl-checker-a': "#25272c";
|
|
439
440
|
readonly '--wzl-checker-b': "#181a1e";
|
|
440
441
|
readonly '--wzl-checker-size': "8px";
|
|
441
|
-
readonly '--wzl-workspace-surface': "#
|
|
442
|
+
readonly '--wzl-workspace-surface': "#272727";
|
|
442
443
|
readonly '--wzl-workspace-line': "rgba(230, 231, 233, 0.1)";
|
|
444
|
+
readonly '--wzl-workspace': "repeating-linear-gradient(45deg, transparent 0 8px, var(--wzl-workspace-line) 8px 16px) var(--wzl-workspace-surface)";
|
|
443
445
|
readonly '--wzl-field-pad-x': "8px";
|
|
444
446
|
readonly '--wzl-gloss': "0";
|
|
445
447
|
readonly '--wzl-font-size': "15px";
|
|
@@ -620,8 +622,9 @@ declare const THEMES: {
|
|
|
620
622
|
readonly '--wzl-checker-a': "#25272c";
|
|
621
623
|
readonly '--wzl-checker-b': "#181a1e";
|
|
622
624
|
readonly '--wzl-checker-size': "8px";
|
|
623
|
-
readonly '--wzl-workspace-surface': "#
|
|
625
|
+
readonly '--wzl-workspace-surface': "#272727";
|
|
624
626
|
readonly '--wzl-workspace-line': "rgba(230, 231, 233, 0.1)";
|
|
627
|
+
readonly '--wzl-workspace': "repeating-linear-gradient(45deg, transparent 0 8px, var(--wzl-workspace-line) 8px 16px) var(--wzl-workspace-surface)";
|
|
625
628
|
readonly '--wzl-field-pad-x': "8px";
|
|
626
629
|
readonly '--wzl-gloss': "0";
|
|
627
630
|
readonly '--wzl-font-size': "18px";
|
|
@@ -802,8 +805,9 @@ declare const THEMES: {
|
|
|
802
805
|
readonly '--wzl-checker-a': "#c9cbcf";
|
|
803
806
|
readonly '--wzl-checker-b': "#f5f5f6";
|
|
804
807
|
readonly '--wzl-checker-size': "8px";
|
|
805
|
-
readonly '--wzl-workspace-surface': "#
|
|
808
|
+
readonly '--wzl-workspace-surface': "#e7e7e7";
|
|
806
809
|
readonly '--wzl-workspace-line': "rgba(14, 15, 18, 0.1)";
|
|
810
|
+
readonly '--wzl-workspace': "repeating-linear-gradient(45deg, transparent 0 8px, var(--wzl-workspace-line) 8px 16px) var(--wzl-workspace-surface)";
|
|
807
811
|
readonly '--wzl-field-pad-x': "8px";
|
|
808
812
|
readonly '--wzl-gloss': "0";
|
|
809
813
|
readonly '--wzl-font-size': "13px";
|
|
@@ -984,8 +988,9 @@ declare const THEMES: {
|
|
|
984
988
|
readonly '--wzl-checker-a': "#c9cbcf";
|
|
985
989
|
readonly '--wzl-checker-b': "#f5f5f6";
|
|
986
990
|
readonly '--wzl-checker-size': "8px";
|
|
987
|
-
readonly '--wzl-workspace-surface': "#
|
|
991
|
+
readonly '--wzl-workspace-surface': "#e7e7e7";
|
|
988
992
|
readonly '--wzl-workspace-line': "rgba(14, 15, 18, 0.1)";
|
|
993
|
+
readonly '--wzl-workspace': "repeating-linear-gradient(45deg, transparent 0 8px, var(--wzl-workspace-line) 8px 16px) var(--wzl-workspace-surface)";
|
|
989
994
|
readonly '--wzl-field-pad-x': "8px";
|
|
990
995
|
readonly '--wzl-gloss': "0";
|
|
991
996
|
readonly '--wzl-font-size': "15px";
|
|
@@ -1166,8 +1171,9 @@ declare const THEMES: {
|
|
|
1166
1171
|
readonly '--wzl-checker-a': "#c9cbcf";
|
|
1167
1172
|
readonly '--wzl-checker-b': "#f5f5f6";
|
|
1168
1173
|
readonly '--wzl-checker-size': "8px";
|
|
1169
|
-
readonly '--wzl-workspace-surface': "#
|
|
1174
|
+
readonly '--wzl-workspace-surface': "#e7e7e7";
|
|
1170
1175
|
readonly '--wzl-workspace-line': "rgba(14, 15, 18, 0.1)";
|
|
1176
|
+
readonly '--wzl-workspace': "repeating-linear-gradient(45deg, transparent 0 8px, var(--wzl-workspace-line) 8px 16px) var(--wzl-workspace-surface)";
|
|
1171
1177
|
readonly '--wzl-field-pad-x': "8px";
|
|
1172
1178
|
readonly '--wzl-gloss': "0";
|
|
1173
1179
|
readonly '--wzl-font-size': "18px";
|
package/dist/engine.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { OklchDeg, oklchDegToHex } from '@weasel-js/paint';
|
|
2
|
-
import { T as ThemeDefinition, L as Lookup, F as FlatTokens, R as RawToken, S as Selection, B as BakedTheme, A as AxisDefs, a as Theme } from './definition-
|
|
3
|
-
export { C as CategoricalRampDef, b as ContrastRule, c as LightnessRampDef, d as LiteralRule, N as NumberParam, O as OffsetRule, P as PinObject, e as PinValue, f as RampDef, g as RefRule, h as ScaleDef, i as SemanticCommon, j as SemanticRule, k as StepRule, l as bake, m as bakeChain, n as mergeChain } from './definition-
|
|
2
|
+
import { T as ThemeDefinition, L as Lookup, F as FlatTokens, R as RawToken, S as Selection, B as BakedTheme, A as AxisDefs, a as Theme } from './definition-nZbgRG7A.js';
|
|
3
|
+
export { C as CategoricalRampDef, b as ContrastRule, c as LightnessRampDef, d as LiteralRule, N as NumberParam, O as OffsetRule, P as PinObject, e as PinValue, f as RampDef, g as RefRule, h as ScaleDef, i as SemanticCommon, j as SemanticRule, k as StepRule, l as bake, m as bakeChain, n as mergeChain } from './definition-nZbgRG7A.js';
|
|
4
4
|
|
|
5
5
|
/** A color in OKLCH: lightness 0–1, chroma, hue in degrees. paint's own type,
|
|
6
6
|
* under the name this engine has always called it. */
|
package/dist/engine.js
CHANGED
|
@@ -78,6 +78,7 @@ function mergeChain(def, lookup, seen = /* @__PURE__ */ new Set()) {
|
|
|
78
78
|
// src/engine/deps.ts
|
|
79
79
|
var SEED_REF = /^\{seeds\.([\w-]+)\}$/;
|
|
80
80
|
var TOKEN_REF = /^\{([^}.]+)\}$/;
|
|
81
|
+
var VAR_REF = /var\(\s*--wzl-([\w-]+)/g;
|
|
81
82
|
var node = () => ({ axes: /* @__PURE__ */ new Set(), seeds: /* @__PURE__ */ new Set(), edges: /* @__PURE__ */ new Set() });
|
|
82
83
|
function scan(v, into) {
|
|
83
84
|
if (typeof v === "string") {
|
|
@@ -87,6 +88,7 @@ function scan(v, into) {
|
|
|
87
88
|
else {
|
|
88
89
|
const ref = TOKEN_REF.exec(s);
|
|
89
90
|
if (ref) into.edges.add(ref[1]);
|
|
91
|
+
for (const m of s.matchAll(VAR_REF)) into.edges.add(m[1]);
|
|
90
92
|
}
|
|
91
93
|
return;
|
|
92
94
|
}
|
|
@@ -1249,8 +1251,8 @@ function toDTCG(theme) {
|
|
|
1249
1251
|
};
|
|
1250
1252
|
}
|
|
1251
1253
|
|
|
1252
|
-
// src/hooks.ts
|
|
1253
|
-
var
|
|
1254
|
+
// src/hooks/frame.ts
|
|
1255
|
+
var FRAME_HOOKS = [
|
|
1254
1256
|
{
|
|
1255
1257
|
name: "titlebar-surface",
|
|
1256
1258
|
type: "color",
|
|
@@ -1317,6 +1319,16 @@ var TOKEN_HOOKS = [
|
|
|
1317
1319
|
value: "none",
|
|
1318
1320
|
description: "Box shadow of a well: the frame a field draws its value in, a checkbox, a radio, the track of a switch, a slider, or a segmented control, and a cell of a flat one."
|
|
1319
1321
|
},
|
|
1322
|
+
{
|
|
1323
|
+
name: "entered-group",
|
|
1324
|
+
type: "color",
|
|
1325
|
+
value: "#a48bd4",
|
|
1326
|
+
description: "Color of the dashed frame a canvas draws around the group it is working inside. Read off the canvas element, so it can be set on it or anything above it."
|
|
1327
|
+
}
|
|
1328
|
+
];
|
|
1329
|
+
|
|
1330
|
+
// src/hooks/controls.ts
|
|
1331
|
+
var CONTROL_HOOKS = [
|
|
1320
1332
|
{
|
|
1321
1333
|
name: "field-border",
|
|
1322
1334
|
type: "border",
|
|
@@ -1389,12 +1401,6 @@ var TOKEN_HOOKS = [
|
|
|
1389
1401
|
value: "var(--btn-engraving)",
|
|
1390
1402
|
description: "Text shadow of a Button\u2019s label. Unset, an engraving stamp under the glyphs in dark mode."
|
|
1391
1403
|
},
|
|
1392
|
-
{
|
|
1393
|
-
name: "detail-figure-min-width",
|
|
1394
|
-
type: "dimension",
|
|
1395
|
-
value: "8ch",
|
|
1396
|
-
description: 'Least width of a value cell in a `values="figures"` DetailList.'
|
|
1397
|
-
},
|
|
1398
1404
|
{
|
|
1399
1405
|
name: "disclosure-gap",
|
|
1400
1406
|
type: "dimension",
|
|
@@ -1431,6 +1437,82 @@ var TOKEN_HOOKS = [
|
|
|
1431
1437
|
value: "var(--wzl-font-size)",
|
|
1432
1438
|
description: "Font size of the text in a field, a select, a radio, a segmented bar or a button. Unset, each takes its own size; a params row sets it to --wzl-params-text-size."
|
|
1433
1439
|
},
|
|
1440
|
+
{
|
|
1441
|
+
name: "select-border",
|
|
1442
|
+
type: "border",
|
|
1443
|
+
value: "1px solid var(--wzl-border)",
|
|
1444
|
+
description: "Border of a Select\u2019s trigger. Unset, a boxed trigger draws --wzl-border and a bare one a transparent border of the same width."
|
|
1445
|
+
},
|
|
1446
|
+
{
|
|
1447
|
+
name: "select-fg",
|
|
1448
|
+
type: "color",
|
|
1449
|
+
value: "var(--wzl-fg)",
|
|
1450
|
+
description: "Text color of a Select\u2019s trigger."
|
|
1451
|
+
},
|
|
1452
|
+
{
|
|
1453
|
+
name: "swatch-size",
|
|
1454
|
+
type: "dimension",
|
|
1455
|
+
value: "28px",
|
|
1456
|
+
description: "Minimum cell of a swatch grid \u2014 PatternPicker, and any panel laying swatches out the same way."
|
|
1457
|
+
},
|
|
1458
|
+
{
|
|
1459
|
+
name: "tree-indent",
|
|
1460
|
+
type: "dimension",
|
|
1461
|
+
value: "calc(var(--wzl-control-h-xs) + var(--wzl-space-2))",
|
|
1462
|
+
description: "Indent of each Tree level. Unset, it is one twisty and one gap, so a child\u2019s twisty sits under its parent\u2019s label."
|
|
1463
|
+
},
|
|
1464
|
+
{
|
|
1465
|
+
name: "tree-font-size",
|
|
1466
|
+
type: "dimension",
|
|
1467
|
+
value: "var(--wzl-font-size-sm)",
|
|
1468
|
+
description: "Size of a Tree row\u2019s text."
|
|
1469
|
+
},
|
|
1470
|
+
{
|
|
1471
|
+
name: "tree-fold-size",
|
|
1472
|
+
type: "dimension",
|
|
1473
|
+
value: "16px",
|
|
1474
|
+
description: "Size of the leading glyph a Tree folds a branch by, where its branches fold by their glyphs."
|
|
1475
|
+
},
|
|
1476
|
+
{
|
|
1477
|
+
name: "tree-guide",
|
|
1478
|
+
type: "color",
|
|
1479
|
+
value: "var(--wzl-fg-subtle)",
|
|
1480
|
+
description: "Color of the bracket a Tree draws down a branch."
|
|
1481
|
+
},
|
|
1482
|
+
{
|
|
1483
|
+
name: "tree-selected",
|
|
1484
|
+
type: "color",
|
|
1485
|
+
value: "var(--wzl-border)",
|
|
1486
|
+
description: "Background of a selected Tree row."
|
|
1487
|
+
},
|
|
1488
|
+
{
|
|
1489
|
+
name: "tree-leaf-indent",
|
|
1490
|
+
type: "dimension",
|
|
1491
|
+
value: "0",
|
|
1492
|
+
description: "How far in from its branches' glyphs a Tree with guides sets a row that folds nothing."
|
|
1493
|
+
},
|
|
1494
|
+
{
|
|
1495
|
+
name: "button-pad-x",
|
|
1496
|
+
type: "dimension",
|
|
1497
|
+
value: "var(--wzl-space-6)",
|
|
1498
|
+
description: "Inline padding of a text Button below the container that sets it, at every size. Unset, `--wzl-space-4` at sm and `--wzl-space-6` at md. Icon-only buttons stay square."
|
|
1499
|
+
},
|
|
1500
|
+
{
|
|
1501
|
+
name: "button-font-weight",
|
|
1502
|
+
type: "fontWeight",
|
|
1503
|
+
value: "var(--wzl-font-weight-medium)",
|
|
1504
|
+
description: "Font weight of a Button\u2019s label below the container that sets it."
|
|
1505
|
+
}
|
|
1506
|
+
];
|
|
1507
|
+
|
|
1508
|
+
// src/hooks/panels.ts
|
|
1509
|
+
var PANEL_HOOKS = [
|
|
1510
|
+
{
|
|
1511
|
+
name: "detail-figure-min-width",
|
|
1512
|
+
type: "dimension",
|
|
1513
|
+
value: "8ch",
|
|
1514
|
+
description: 'Least width of a value cell in a `values="figures"` DetailList.'
|
|
1515
|
+
},
|
|
1434
1516
|
{
|
|
1435
1517
|
name: "params-label-align",
|
|
1436
1518
|
type: "string",
|
|
@@ -1503,24 +1585,6 @@ var TOKEN_HOOKS = [
|
|
|
1503
1585
|
value: "calc(4.5ch + 2px)",
|
|
1504
1586
|
description: "Width of a Properties row\u2019s value readout \u2014 four digits, so the controls beside a column of readouts end on one line. A range whose widest value needs more widens its own readout."
|
|
1505
1587
|
},
|
|
1506
|
-
{
|
|
1507
|
-
name: "select-border",
|
|
1508
|
-
type: "border",
|
|
1509
|
-
value: "1px solid var(--wzl-border)",
|
|
1510
|
-
description: "Border of a Select\u2019s trigger. Unset, a boxed trigger draws --wzl-border and a bare one a transparent border of the same width."
|
|
1511
|
-
},
|
|
1512
|
-
{
|
|
1513
|
-
name: "select-fg",
|
|
1514
|
-
type: "color",
|
|
1515
|
-
value: "var(--wzl-fg)",
|
|
1516
|
-
description: "Text color of a Select\u2019s trigger."
|
|
1517
|
-
},
|
|
1518
|
-
{
|
|
1519
|
-
name: "swatch-size",
|
|
1520
|
-
type: "dimension",
|
|
1521
|
-
value: "28px",
|
|
1522
|
-
description: "Minimum cell of a swatch grid \u2014 PatternPicker, and any panel laying swatches out the same way."
|
|
1523
|
-
},
|
|
1524
1588
|
{
|
|
1525
1589
|
name: "timeline-label-w",
|
|
1526
1590
|
type: "dimension",
|
|
@@ -1533,42 +1597,6 @@ var TOKEN_HOOKS = [
|
|
|
1533
1597
|
value: "32px",
|
|
1534
1598
|
description: "Width reserved for the Timeline\u2019s value axis."
|
|
1535
1599
|
},
|
|
1536
|
-
{
|
|
1537
|
-
name: "tree-indent",
|
|
1538
|
-
type: "dimension",
|
|
1539
|
-
value: "calc(var(--wzl-control-h-xs) + var(--wzl-space-2))",
|
|
1540
|
-
description: "Indent of each Tree level. Unset, it is one twisty and one gap, so a child\u2019s twisty sits under its parent\u2019s label."
|
|
1541
|
-
},
|
|
1542
|
-
{
|
|
1543
|
-
name: "tree-font-size",
|
|
1544
|
-
type: "dimension",
|
|
1545
|
-
value: "var(--wzl-font-size-sm)",
|
|
1546
|
-
description: "Size of a Tree row\u2019s text."
|
|
1547
|
-
},
|
|
1548
|
-
{
|
|
1549
|
-
name: "tree-fold-size",
|
|
1550
|
-
type: "dimension",
|
|
1551
|
-
value: "16px",
|
|
1552
|
-
description: "Size of the leading glyph a Tree folds a branch by, where its branches fold by their glyphs."
|
|
1553
|
-
},
|
|
1554
|
-
{
|
|
1555
|
-
name: "tree-guide",
|
|
1556
|
-
type: "color",
|
|
1557
|
-
value: "var(--wzl-fg-subtle)",
|
|
1558
|
-
description: "Color of the bracket a Tree draws down a branch."
|
|
1559
|
-
},
|
|
1560
|
-
{
|
|
1561
|
-
name: "tree-selected",
|
|
1562
|
-
type: "color",
|
|
1563
|
-
value: "var(--wzl-border)",
|
|
1564
|
-
description: "Background of a selected Tree row."
|
|
1565
|
-
},
|
|
1566
|
-
{
|
|
1567
|
-
name: "tree-leaf-indent",
|
|
1568
|
-
type: "dimension",
|
|
1569
|
-
value: "0",
|
|
1570
|
-
description: "How far in from its branches' glyphs a Tree with guides sets a row that folds nothing."
|
|
1571
|
-
},
|
|
1572
1600
|
{
|
|
1573
1601
|
name: "dialog-max-width",
|
|
1574
1602
|
type: "dimension",
|
|
@@ -1600,13 +1628,22 @@ var TOKEN_HOOKS = [
|
|
|
1600
1628
|
description: "How a PropertyPanel\u2019s title row lines its actions up with the title: center, or baseline for actions that are text."
|
|
1601
1629
|
},
|
|
1602
1630
|
{
|
|
1603
|
-
name: "
|
|
1631
|
+
name: "tree-row-h",
|
|
1632
|
+
type: "dimension",
|
|
1633
|
+
value: "var(--wzl-control-h)",
|
|
1634
|
+
description: "Height of every row in a Tree below the container that sets it, and of its drag ghost. Unset, the control height."
|
|
1635
|
+
},
|
|
1636
|
+
{
|
|
1637
|
+
name: "tree-current",
|
|
1604
1638
|
type: "color",
|
|
1605
|
-
value: "
|
|
1606
|
-
description: "
|
|
1639
|
+
value: "var(--wzl-accent-fg)",
|
|
1640
|
+
description: "Text color of the Tree row marked `current`, the page or item being shown."
|
|
1607
1641
|
}
|
|
1608
1642
|
];
|
|
1609
1643
|
|
|
1644
|
+
// src/hooks.ts
|
|
1645
|
+
var TOKEN_HOOKS = [...FRAME_HOOKS, ...CONTROL_HOOKS, ...PANEL_HOOKS];
|
|
1646
|
+
|
|
1610
1647
|
// src/engine/emit/manifest.ts
|
|
1611
1648
|
var MERGED_GROUPS = { danger: "status", warning: "status", success: "status" };
|
|
1612
1649
|
var groupOf = (name) => {
|