@ui0/theme 0.1.4 → 0.1.5
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/components/index.js +53 -44
- package/dist/components/style.css +1 -2
- package/dist/display.scss +0 -3
- package/dist/{generate-Dey8zJEZ.mjs → generate-DjBK9MD8.mjs} +4 -5
- package/dist/generate-DjBK9MD8.mjs.map +1 -0
- package/dist/generator/cli.mjs +1 -1
- package/dist/generator/vite.d.mts.map +1 -1
- package/dist/generator/vite.mjs +13 -3
- package/dist/generator/vite.mjs.map +1 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +17 -24
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -7
- package/src/contracts/backdrop/backdrop.generator.ts +0 -2
- package/src/contracts/color/color.generator.ts +7 -0
- package/src/contracts/contract.ts +5 -1
- package/src/contracts/display/display.contract.ts +12 -11
- package/src/contracts/display/display.scss +0 -3
- package/src/contracts/typography/typography.generator.spec.ts +7 -5
- package/src/contracts/typography/typography.module.css +1 -1
- package/src/generator/theme.default.css +2 -48
- package/dist/generate-Dey8zJEZ.mjs.map +0 -1
package/dist/components/index.js
CHANGED
|
@@ -1,44 +1,53 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { provideHost as
|
|
3
|
-
import { Slot as
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
1
|
+
import { defineComponent as i, useAttrs as m, useCssModule as d, reactive as u, computed as h, openBlock as f, createBlock as _, unref as n, normalizeClass as v, withCtx as y, renderSlot as g, normalizeProps as P, guardReactiveProps as k } from "vue";
|
|
2
|
+
import { provideHost as x } from "@ui0/composable";
|
|
3
|
+
import { Slot as C } from "@ui0/core";
|
|
4
|
+
const M = Symbol("ThemeProviderKey"), S = /* @__PURE__ */ i({
|
|
5
|
+
inheritAttrs: !1,
|
|
6
|
+
__name: "theme-provider",
|
|
7
|
+
props: {
|
|
8
|
+
appearance: {},
|
|
9
|
+
preset: {}
|
|
10
|
+
},
|
|
11
|
+
setup(s, { expose: a }) {
|
|
12
|
+
const t = s, o = m(), p = d(), e = u({
|
|
13
|
+
provided: !0,
|
|
14
|
+
appearance: "light",
|
|
15
|
+
preset: "default"
|
|
16
|
+
});
|
|
17
|
+
t.preset && (e.preset = t.preset), t.appearance && (e.appearance = t.appearance);
|
|
18
|
+
const l = h(
|
|
19
|
+
() => e.provided ? [p.theme, "theme-" + e.preset, "theme_" + e.appearance] : []
|
|
20
|
+
), c = {
|
|
21
|
+
appearance(r) {
|
|
22
|
+
e.appearance = r;
|
|
23
|
+
},
|
|
24
|
+
preset(r) {
|
|
25
|
+
e.preset = r;
|
|
26
|
+
},
|
|
27
|
+
toggle() {
|
|
28
|
+
e.appearance = e.appearance === "dark" ? "light" : "dark";
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
return x(M, c), a(c), (r, A) => (f(), _(n(C), {
|
|
32
|
+
class: v([...l.value, n(o).class])
|
|
33
|
+
}, {
|
|
34
|
+
default: y(() => [
|
|
35
|
+
g(r.$slots, "default", P(k(c)))
|
|
36
|
+
]),
|
|
37
|
+
_: 3
|
|
38
|
+
}, 8, ["class"]));
|
|
39
|
+
}
|
|
40
|
+
}), T = "th_3cb8", $ = {
|
|
41
|
+
theme: T
|
|
42
|
+
}, b = (s, a) => {
|
|
43
|
+
const t = s.__vccOpts || s;
|
|
44
|
+
for (const [o, p] of a)
|
|
45
|
+
t[o] = p;
|
|
46
|
+
return t;
|
|
47
|
+
}, z = {
|
|
48
|
+
$style: $
|
|
49
|
+
}, H = /* @__PURE__ */ b(S, [["__cssModules", z]]);
|
|
50
|
+
export {
|
|
51
|
+
H as ThemeProvider,
|
|
52
|
+
M as ThemeProviderKey
|
|
53
|
+
};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
@layer theme,ui0;@layer ui0.theme-provider{.th_3cb8{--0-c-src:initial;--0-c-src-l:initial;--0-c-src-d:initial;--0-c-src-hover:initial;--0-c-src-active:initial;--0-c-src-focus:initial;--0-c-src-l-hover:initial;--0-c-src-l-active:initial;--0-c-src-l-focus:initial;--0-c-src-d-hover:initial;--0-c-src-d-active:initial;--0-c-src-d-focus:initial;--0-c-o:var(--0-c-src,var(--0-c-src-l,1));--0-c-cur:rgb(var(--0-c-cur-v) / var(--0-c-o))}.theme_dark .th_3cb8{--0-c-o:var(--0-c-src-d,var(--0-c-src,1))}.th_3cb8:hover{--0-c-o:var(--0-c-src-hover,var(--0-c-src,var(--0-c-src-l,1)))}.th_3cb8:active{--0-c-o:var(--0-c-src-active,var(--0-c-src,var(--0-c-src-l,1)))}.th_3cb8:focus{--0-c-o:var(--0-c-src-focus,var(--0-c-src,var(--0-c-src-l,1)))}.theme_dark .th_3cb8:hover{--0-c-o:var(--0-c-src-d-hover,var(--0-c-src-hover,var(--0-c-src-d,var(--0-c-src,1))))}.theme_dark .th_3cb8:active{--0-c-o:var(--0-c-src-d-active,var(--0-c-src-active,var(--0-c-src-d,var(--0-c-src,1))))}.theme_dark .th_3cb8:focus{--0-c-o:var(--0-c-src-d-focus,var(--0-c-src-focus,var(--0-c-src-d,var(--0-c-src,1))))}.th_3cb8{--0-f-src:initial;--0-f-src-l:initial;--0-f-src-d:initial;--0-f-src-hover:initial;--0-f-src-active:initial;--0-f-src-focus:initial;--0-f-src-l-hover:initial;--0-f-src-l-active:initial;--0-f-src-l-focus:initial;--0-f-src-d-hover:initial;--0-f-src-d-active:initial;--0-f-src-d-focus:initial;--0-f-o:var(--0-f-src,var(--0-f-src-l,1));--0-f-cur:rgb(var(--0-f-cur-v) / var(--0-f-o))}.theme_dark .th_3cb8{--0-f-o:var(--0-f-src-d,var(--0-f-src,1))}.th_3cb8:hover{--0-f-o:var(--0-f-src-hover,var(--0-f-src,var(--0-f-src-l,1)))}.th_3cb8:active{--0-f-o:var(--0-f-src-active,var(--0-f-src,var(--0-f-src-l,1)))}.th_3cb8:focus{--0-f-o:var(--0-f-src-focus,var(--0-f-src,var(--0-f-src-l,1)))}.theme_dark .th_3cb8:hover{--0-f-o:var(--0-f-src-d-hover,var(--0-f-src-hover,var(--0-f-src-d,var(--0-f-src,1))))}.theme_dark .th_3cb8:active{--0-f-o:var(--0-f-src-d-active,var(--0-f-src-active,var(--0-f-src-d,var(--0-f-src,1))))}.theme_dark .th_3cb8:focus{--0-f-o:var(--0-f-src-d-focus,var(--0-f-src-focus,var(--0-f-src-d,var(--0-f-src,1))))}.th_3cb8{--0-g-cur:initial;color:var(--0-c-cur);background-color:var(--0-f-cur);background-image:var(--0-g-cur);--0-s:calc(var(--0-s,var(--0-s-m)) * var(--0-s-density,1));--0-sc:calc(var(--0-sc,var(--0-sc-m)) * var(--0-s-density,1));font-size:var(--0-fs-m)}}
|
|
2
|
-
/*$vite$:1*/
|
|
1
|
+
@layer theme,ui0,ui0.theme-provider;@layer ui0.theme-provider{.th_3cb8{--0-c-src: initial;--0-c-src-l: initial;--0-c-src-d: initial;--0-c-src-hover: initial;--0-c-src-active: initial;--0-c-src-focus: initial;--0-c-src-l-hover: initial;--0-c-src-l-active: initial;--0-c-src-l-focus: initial;--0-c-src-d-hover: initial;--0-c-src-d-active: initial;--0-c-src-d-focus: initial;--0-c-o: var(--0-c-src, var(--0-c-src-l, 1));--0-c-cur: rgb(var(--0-c-cur-v) / var(--0-c-o))}.theme_dark .th_3cb8{--0-c-o: var(--0-c-src-d, var(--0-c-src, 1))}.th_3cb8:hover{--0-c-o: var(--0-c-src-hover, var(--0-c-src, var(--0-c-src-l, 1)))}.th_3cb8:active{--0-c-o: var(--0-c-src-active, var(--0-c-src, var(--0-c-src-l, 1)))}.th_3cb8:focus{--0-c-o: var(--0-c-src-focus, var(--0-c-src, var(--0-c-src-l, 1)))}.theme_dark .th_3cb8:hover{--0-c-o: var(--0-c-src-d-hover, var(--0-c-src-hover, var(--0-c-src-d, var(--0-c-src, 1))))}.theme_dark .th_3cb8:active{--0-c-o: var(--0-c-src-d-active, var(--0-c-src-active, var(--0-c-src-d, var(--0-c-src, 1))))}.theme_dark .th_3cb8:focus{--0-c-o: var(--0-c-src-d-focus, var(--0-c-src-focus, var(--0-c-src-d, var(--0-c-src, 1))))}.th_3cb8{--0-f-src: initial;--0-f-src-l: initial;--0-f-src-d: initial;--0-f-src-hover: initial;--0-f-src-active: initial;--0-f-src-focus: initial;--0-f-src-l-hover: initial;--0-f-src-l-active: initial;--0-f-src-l-focus: initial;--0-f-src-d-hover: initial;--0-f-src-d-active: initial;--0-f-src-d-focus: initial;--0-f-o: var(--0-f-src, var(--0-f-src-l, 1));--0-f-cur: rgb(var(--0-f-cur-v) / var(--0-f-o))}.theme_dark .th_3cb8{--0-f-o: var(--0-f-src-d, var(--0-f-src, 1))}.th_3cb8:hover{--0-f-o: var(--0-f-src-hover, var(--0-f-src, var(--0-f-src-l, 1)))}.th_3cb8:active{--0-f-o: var(--0-f-src-active, var(--0-f-src, var(--0-f-src-l, 1)))}.th_3cb8:focus{--0-f-o: var(--0-f-src-focus, var(--0-f-src, var(--0-f-src-l, 1)))}.theme_dark .th_3cb8:hover{--0-f-o: var(--0-f-src-d-hover, var(--0-f-src-hover, var(--0-f-src-d, var(--0-f-src, 1))))}.theme_dark .th_3cb8:active{--0-f-o: var(--0-f-src-d-active, var(--0-f-src-active, var(--0-f-src-d, var(--0-f-src, 1))))}.theme_dark .th_3cb8:focus{--0-f-o: var(--0-f-src-d-focus, var(--0-f-src-focus, var(--0-f-src-d, var(--0-f-src, 1))))}.th_3cb8{--0-g-cur: initial;color:var(--0-c-cur);background-color:var(--0-f-cur);background-image:var(--0-g-cur);--0-s: calc(var(--0-s, var(--0-s-m)) * var(--0-s-density, 1));--0-sc: calc(var(--0-sc, var(--0-sc-m)) * var(--0-s-density, 1));font-size:var(--0-fs-m)}}
|
package/dist/display.scss
CHANGED
|
@@ -2,9 +2,6 @@
|
|
|
2
2
|
// Component-namespace wiring for the display contract: the generator emits
|
|
3
3
|
// `--0-display-base` on the theme blocks; this mixin mirrors it into the
|
|
4
4
|
// component namespace so a component can consume (and locally override) it.
|
|
5
|
-
@mixin use() {
|
|
6
|
-
--0c-display: var(--0-display-base, initial);
|
|
7
|
-
}
|
|
8
5
|
|
|
9
6
|
@mixin wh($width, $height) {
|
|
10
7
|
$max-w: ' and (max-width: #{$width})';
|
|
@@ -53,7 +53,6 @@ const DEFAULTS = {
|
|
|
53
53
|
sepia: "1"
|
|
54
54
|
};
|
|
55
55
|
const backdropGenerator = (ctx) => {
|
|
56
|
-
const { hash } = ctx;
|
|
57
56
|
const config = ctx.config.backdrop;
|
|
58
57
|
const backdropSettings = ctx.settings.backdrop;
|
|
59
58
|
const fnSettings = backdropSettings === false ? {} : backdropSettings ?? {};
|
|
@@ -64,7 +63,6 @@ const backdropGenerator = (ctx) => {
|
|
|
64
63
|
for (const fn of enabled) backdrop[fn] = `${config?.[fn] ?? DEFAULTS[fn]}`;
|
|
65
64
|
return { backdrop };
|
|
66
65
|
}
|
|
67
|
-
console.log("hash", backdrop_module_css_default.backdrop);
|
|
68
66
|
return {
|
|
69
67
|
namespace: "bd",
|
|
70
68
|
vars: (scheme) => scheme ? {} : vars(),
|
|
@@ -307,6 +305,7 @@ const colorGenerator = (ctx) => {
|
|
|
307
305
|
const f = {};
|
|
308
306
|
if ("background" in base) f["cur-v"] = "var(--0-c-background-v)";
|
|
309
307
|
f.cur = "rgb(var(--0-f-cur-v, var(--0-c-background-v)) / var(--0-f-o, 1))";
|
|
308
|
+
if ("background" in base) c["theme-contrast-v"] = SPACES.hsl.lightnessOf(base.background) < 50 ? "255 255 255" : "0 0 0";
|
|
310
309
|
return {
|
|
311
310
|
c,
|
|
312
311
|
f
|
|
@@ -925,7 +924,7 @@ function generateThemeArtifacts(config, emitPresets) {
|
|
|
925
924
|
styles: diffList(baseBlock?.styles ?? {}, block.styles)
|
|
926
925
|
}]);
|
|
927
926
|
}
|
|
928
|
-
const additions = [...declLines(run.schemeVars[scheme]), ...declLines(run.schemeStyles[scheme])];
|
|
927
|
+
const additions = [...declLines(diffList(base.schemeVars[scheme], run.schemeVars[scheme])), ...declLines(diffList(base.schemeStyles[scheme], run.schemeStyles[scheme]))];
|
|
929
928
|
if (additions.length) css += `${selector} {\n /* ${scheme} additions */\n${additions.join("\n")}\n}\n`;
|
|
930
929
|
}
|
|
931
930
|
}
|
|
@@ -1035,6 +1034,6 @@ ${registry("Ui0ThemeColorNames", colors)}
|
|
|
1035
1034
|
export {}
|
|
1036
1035
|
`;
|
|
1037
1036
|
}
|
|
1038
|
-
export {
|
|
1037
|
+
export { buildPool as _, deepMerge as a, ensureThemeBaseStyle as b, contractGenerators as c, round_module_css_default as d, elevation_module_css_default as f, parseRef as g, parseColorProp as h, withDefaults as i, typography_module_css_default as l, color_module_css_default as m, generateThemeCss as n, resolvePreset as o, disabled_module_css_default as p, generateThemeTypes as r, hashClassName as s, generateThemeArtifacts as t, size_module_css_default as u, resolvePool as v, schemesOf as x, backdrop_module_css_default as y };
|
|
1039
1038
|
|
|
1040
|
-
//# sourceMappingURL=generate-
|
|
1039
|
+
//# sourceMappingURL=generate-DjBK9MD8.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-DjBK9MD8.mjs","names":["$backdrop","colorCss","$color","disabledCss","$disabled","$display","$elevation","roundCss","$round","sizeCss","$size","typographyCss","$typography","builtinDefaults","config"],"sources":["../src/types.ts","../src/generator/base.ts","../src/contracts/backdrop/backdrop.module.css.ui0-map","../src/contracts/backdrop/backdrop.generator.ts","../src/generator/pool.ts","../src/contracts/color/color.token.ts","../src/contracts/color/color.inject.module.css.ui0-inject","../src/contracts/color/color.module.css.ui0-map","../src/contracts/color/color.generator.ts","../src/contracts/disabled/disabled.inject.module.css.ui0-inject","../src/contracts/disabled/disabled.module.css.ui0-map","../src/contracts/disabled/disabled.generator.ts","../src/contracts/display/display.module.css.ui0-map","../src/contracts/display/display.generator.ts","../src/contracts/elevation/elevation.module.css.ui0-map","../src/contracts/elevation/elevation.generator.ts","../src/contracts/round/round.inject.module.scss.ui0-inject","../src/contracts/round/round.module.css.ui0-map","../src/contracts/round/round.generator.ts","../src/generator/scales.ts","../src/contracts/size/size.inject.module.scss.ui0-inject","../src/contracts/size/size.module.css.ui0-map","../src/contracts/size/size.generator.ts","../src/contracts/style/style.generator.ts","../src/contracts/typography/typography.inject.module.css.ui0-inject","../src/contracts/typography/typography.module.css.ui0-map","../src/contracts/typography/typography.generator.ts","../src/generator.ts","../src/generator/hash.ts","../src/generator/contracts.ts","../src/generator/theme-def.ts","../src/generator/generate.ts"],"sourcesContent":["// Local helpers around the theme types (which live in @ui0/types/theme -\n// import them from there directly; there is deliberately no re-export barrel\n// here). The registries (Ui0ThemePresetAppearanceConfig, Ui0ThemeContracts,\n// Ui0ThemeContractSettings) stay intentionally EMPTY there: each contract\n// fills them via interface merging in its own <name>.types.ts registration\n// file (`declare module '@ui0/types/theme'`).\nimport type { ThemePreset, ThemePresetSchemes } from '@ui0/types'\n\nexport function schemesOf(preset: ThemePreset): ThemePresetSchemes {\n return preset as ThemePresetSchemes\n}\n","// The theme's element reset. Two delivery paths share the one rule:\n// - the generator embeds it at the top of the generated theme css\n// (generateBaseCss, consumed via generate.ts);\n// - the core plugin injects it into the document at install time\n// (ensureThemeBaseStyle) - so a host gets the body reset the moment\n// ui0.use(createUi0Theme(config)) runs, without importing the css.\n\n/**\n * The base `body` reset every theme ships: margin 0 and the base font size.\n * Themed colors stay on the themed subtrees - the body itself stays neutral.\n *\n * @returns the `body {...}` rule\n */\nexport function generateBaseCss(): string {\n return `body {\\n` + ` margin: 0;\\n` + ` font-size: 1rem;\\n` + `}`\n}\n\n/** marker attribute of the injected base-reset <style> element */\nexport const BASE_STYLE_ATTR = 'data-ui0-theme-base'\n\n/**\n * Inject the base body reset into a document, idempotently - a second call\n * finds the previously created `<style>` and returns it untouched. SSR-safe:\n * a no-op wherever there is no DOM (direct server calls, nuxt module setup).\n *\n * @param doc - the document to inject into (defaults to the global one)\n * @returns the style element carrying the reset, or null without a DOM\n */\nexport function ensureThemeBaseStyle(doc?: Document): HTMLStyleElement | null {\n if (typeof document === 'undefined') return null\n const target = doc ?? document\n const selector = `style[${BASE_STYLE_ATTR}]`\n const existing = target.head.querySelector<HTMLStyleElement>(selector)\n if (existing) return existing\n\n const el = target.createElement('style')\n el.setAttribute(BASE_STYLE_ATTR, '')\n el.textContent = generateBaseCss()\n target.head.appendChild(el)\n return el\n}\n","export default { \"backdrop\": \"ba_d486\" }","// The backdrop contract's generator endpoint: one setter class per\n// backdrop-filter function the config enables. The backdrop prop selects\n// which function a component gets; the configured default lands on the theme\n// block as `--0-backdrop-*` and doubles as the setter's var fallback.\nimport type { CSSModuleClassList, VarList } from '@ui0/types'\nimport type { ThemeContractGenerator } from '@ui0/types'\n\nimport type { ContractFactory } from '../generator'\nimport type { BackdropFunction } from './backdrop.types'\n\nimport $backdrop from './backdrop.module.css'\n\n/** every backdrop-filter function the prop can select */\nexport const BACKDROP_FUNCTIONS: ReadonlyArray<BackdropFunction> = [\n 'blur',\n 'brightness',\n 'contrast',\n 'drop-shadow',\n 'grayscale',\n 'hue-rotate',\n 'invert',\n 'opacity',\n 'saturate',\n 'sepia'\n]\n\n/** fallback value per function when the config omits the value */\nconst DEFAULTS: Record<BackdropFunction, string> = {\n blur: '4px',\n brightness: '0.5',\n contrast: '0.5',\n 'drop-shadow': '0 4px 8px rgba(0, 0, 0, 0.5)',\n grayscale: '1',\n 'hue-rotate': '90deg',\n invert: '1',\n opacity: '0.5',\n saturate: '0.5',\n sepia: '1'\n}\n\nconst backdropGenerator: ContractFactory = (ctx): ThemeContractGenerator => {\n const config = ctx.config.backdrop\n // which functions ship: the appearance config's keys by default, plus any\n // function the settings turn on; a `false` in the settings always wins.\n // (a whole-contract `false` never reaches here - the orchestrator skips\n // disabled contracts; narrowed defensively anyway)\n const backdropSettings = ctx.settings.backdrop\n const fnSettings: Partial<Record<BackdropFunction, boolean>> =\n backdropSettings === false ? {} : (backdropSettings ?? {})\n const fromConfig: BackdropFunction[] = config ? (Object.keys(config) as BackdropFunction[]) : ['blur']\n const enabled = [\n ...new Set([...fromConfig, ...(Object.keys(fnSettings) as BackdropFunction[]).filter((fn) => fnSettings[fn])])\n ].filter((fn) => fnSettings[fn] !== false)\n\n function vars(): Record<string, VarList> {\n const backdrop: VarList = {}\n for (const fn of enabled) {\n backdrop[fn] = `${config?.[fn] ?? DEFAULTS[fn]}`\n }\n return { backdrop }\n }\n\n return {\n namespace: 'bd',\n vars: (scheme) => (scheme ? {} : vars()),\n css: () => {\n return (\n `.${$backdrop.backdrop} {\\n` +\n ` backdrop-filter: var(--0-backdrop);\\n` +\n ` -webkit-backdrop-filter: var(--0-backdrop);\\n` +\n ` will-change: backdrop-filter;\\n` +\n `}`\n )\n },\n class: (): CSSModuleClassList => ({ ...$backdrop }),\n styles: () => ({})\n }\n}\n\nexport default backdropGenerator\n","// Color pool resolution: config entries -> base RGB values + l/d/c/s ramps\n// (lazy, with literal/alias/ramp-step/blend references and cycle protection).\n// The pool shape is the color contract's config slice (Ui0ThemeConfig.color.pool).\nimport type { RgbTuple } from '@ui0/types'\nimport { blend, darken, isLiteralColor, lighten, SPACES, toRgb } from '@ui0/util'\n\nimport type {\n ColorOptions,\n ThemeColorEntry,\n ThemeColorPool,\n ThemeColorRampType,\n ThemeColorSpace\n} from '../contracts/color'\n\n// all 4 types are always resolvable on demand (getRampArray is lazy - a \"-c3\"\n// reference still works even for a color that doesn't eagerly generate c/s),\n// but only DEFAULT_RAMP_TYPES are generated+emitted for every color. c/s cost\n// a background-lightness lookup and double the declarations per color, so\n// they're opt-in per color via a 3rd tuple element:\n// name: [color, steps, ['c','s']] - extra ramps, hsl space (default)\n// name: [color, steps, { ramps: ['c','s'], space: 'oklch' }] - + perceptual space\nconst DEFAULT_RAMP_TYPES: ThemeColorRampType[] = ['l', 'd']\n\n/** Read the per-color options out of a pool entry's 3rd tuple element. */\nfunction colorOptions(raw: ThemeColorEntry): {\n ramps: ThemeColorRampType[]\n space: ThemeColorSpace\n} {\n const opt = Array.isArray(raw) ? raw[2] : undefined\n if (Array.isArray(opt)) return { ramps: opt, space: 'hsl' }\n if (opt && typeof opt === 'object')\n return {\n ramps: (opt as ColorOptions).ramps || [],\n space: (opt as ColorOptions).space || 'hsl'\n }\n return { ramps: [], space: 'hsl' }\n}\n\n/**\n * The ramp types a pool entry wants generated: the defaults (l/d) plus any\n * extras (c/s) from its options, deduped, order-stable.\n *\n * @param raw - the pool entry to read options from\n * @returns the ramp types to emit for this entry\n */\nexport function requestedRampTypes(raw: ThemeColorEntry): ThemeColorRampType[] {\n return [...new Set([...DEFAULT_RAMP_TYPES, ...colorOptions(raw).ramps])]\n}\n\n/** merge a scheme's pool over the base pool (scheme wins per entry) */\nexport function buildPool(base: ThemeColorPool | undefined, scheme: ThemeColorPool | undefined): ThemeColorPool {\n return { ...base, ...scheme }\n}\n\nexport interface ResolvedPool {\n base: Record<string, RgbTuple>\n ramps: Record<string, Partial<Record<ThemeColorRampType, RgbTuple[]>>>\n}\n\n/**\n * Resolve a whole color pool into base RGB triples plus per-color ramps.\n *\n * Entries may be literals (`'#fff'`, `'rgb(...)'`, named), aliases (`'brand'`),\n * ramp-step references (`'brand-l2'`) or blend expressions\n * (`[['#0d654e', '#000', 50], 3]`); cycles (background referencing a ramp\n * that needs background's lightness) are broken by resolving only what each\n * step needs - ramp arrays are built lazily and cached per (color, type).\n *\n * @param pool - the pool slice of an appearance config\n * @returns resolved base colors and the generated ramps\n * @throws on circular references and unknown color names\n */\nexport function resolvePool(pool: ThemeColorPool): ResolvedPool {\n const resolvedBase: Record<string, RgbTuple> = {}\n const resolvedRampArrays: Record<string, Partial<Record<ThemeColorRampType, RgbTuple[]>>> = {}\n const resolvingBase = new Set<string>()\n\n /** Resolve any reference form to an RGB triple (literal / ramp step / alias). */\n function resolveRef(ref: string): RgbTuple {\n if (isLiteralColor(ref)) return toRgb(ref)\n // \"{name}-{type}{step}\" ramp reference - pulls in only that ONE ramp type,\n // not the sibling ramps (l/d never need bg; only c/s do - computing all 4\n // eagerly here would force a bg lookup even when only l/d was asked for,\n // which is exactly what causes the background-references-a-ramp cycle).\n const m = ref.match(/^(.+)-([ldcs])(\\d+)$/)\n if (m) {\n const [, refName, type, stepStr] = m\n return getRampArray(refName, type as ThemeColorRampType)[Number(stepStr) - 1]\n }\n // ...else a bare \"{name}\" reference (needs only that entry's base)\n resolveBase(ref)\n return resolvedBase[ref]\n }\n\n /** Resolve a non-string entry: a [color, steps] tuple or a blend expression. */\n function resolveExpr(expr: Exclude<ThemeColorEntry, string>): {\n base: RgbTuple\n steps: number\n } {\n if (Array.isArray(expr[0])) {\n const [c1, c2, depth] = expr[0]\n const base = blend(\n typeof c1 === 'string' ? resolveRef(c1) : c1,\n typeof c2 === 'string' ? resolveRef(c2) : c2,\n depth\n )\n return { base, steps: expr[1] }\n }\n return { base: resolveRef(expr[0]), steps: expr[1] }\n }\n\n /**\n * Resolve ONLY the base value - never needs the scheme's background lightness,\n * so it can be called while resolving background itself without a cycle.\n */\n function resolveBase(name: string): void {\n if (name in resolvedBase) return\n if (resolvingBase.has(name)) throw new Error(`circular color reference: ${name}`)\n resolvingBase.add(name)\n\n const raw = pool[name]\n if (raw === undefined) throw new Error(`unknown color reference: ${name}`)\n resolvedBase[name] = typeof raw === 'string' ? resolveRef(raw) : resolveExpr(raw).base\n\n resolvingBase.delete(name)\n }\n\n /**\n * The background's lightness, read in the SAME space as the color being\n * ramped, so the \"which side of 50\" comparison stays apples-to-apples.\n */\n function baseLightness(space: ThemeColorSpace): number {\n resolveBase('background')\n return SPACES[space].lightnessOf(resolvedBase.background)\n }\n\n /** Build (and cache) one color's ramp of one type, lazily. */\n function getRampArray(name: string, type: ThemeColorRampType): RgbTuple[] {\n resolvedRampArrays[name] = resolvedRampArrays[name] || {}\n const cached = resolvedRampArrays[name][type]\n if (cached) return cached\n\n resolveBase(name)\n const raw = pool[name] as Exclude<ThemeColorEntry, string>\n const steps = raw[1] // string (bare alias) entries never reach here - no ramp of their own\n const base = resolvedBase[name]\n const { space } = colorOptions(raw)\n\n let arr: RgbTuple[]\n if (type === 'l') {\n arr = Array.from({ length: steps }, (_, i) => lighten(base, i + 1, steps, space))\n } else if (type === 'd') {\n arr = Array.from({ length: steps }, (_, i) => darken(base, i + 1, steps, space))\n } else {\n const bg = name === 'background' ? SPACES[space].lightnessOf(base) : baseLightness(space)\n arr =\n type === 'c'\n ? Array.from({ length: steps }, (_, i) =>\n bg < 50 ? lighten(base, i + 1, steps, space) : darken(base, i + 1, steps, space)\n )\n : Array.from({ length: steps }, (_, i) =>\n bg < 50 ? darken(base, i + 1, steps, space) : lighten(base, i + 1, steps, space)\n )\n }\n resolvedRampArrays[name][type] = arr\n return arr\n }\n\n for (const name of Object.keys(pool)) {\n resolveBase(name)\n if (typeof pool[name] !== 'string') {\n for (const type of requestedRampTypes(pool[name])) getRampArray(name, type)\n }\n }\n return { base: resolvedBase, ramps: resolvedRampArrays }\n}\n","// The color/fill prop-dsl parser (v2 grammar):\n//\n// prop := token (' ' token)* tokens = layers: base + overrides\n// token := ref -> both schemes, no pseudo\n// | ref '/' ref -> positional pair: light / dark\n// | [scheme ':'][pseudo ':'] ref\n// ref := name ['-' ramp] ['@' pct]\n//\n// examples:\n// success both schemes\n// success@80/warning@100 light success@80, dark warning@100\n// dark:warning dark only (light falls back to the inherited/current)\n// success hover:success@90 base + full pseudo override (no opacity sugar)\n//\n// scheme is EITHER a positional pair OR named prefixes, never both; a\n// trailing/leading slash pair member must be a full ref (dark-only is\n// spelled `dark:...`).\nimport { isArray, isNumberish, isString } from '@ui0/util'\n\nimport type { ColorPseudo, ColorScheme, ColorToken } from './color.types'\n\nexport const ColorSchemeValues: ReadonlyArray<ColorScheme> = ['light', 'dark']\nexport const ColorPseudoValues: ReadonlyArray<ColorPseudo> = ['hover', 'active', 'focus']\n\nconst SPACE = /\\s+/\n\n/** parse a `<ref>[@pct]` tail into ref + opacity (0..1) */\nexport function parseRef(raw: string): { ref: string; opacity?: number } {\n const at = raw.lastIndexOf('@')\n if (at === -1) return { ref: raw }\n const ref = raw.slice(0, at)\n const pct = raw.slice(at + 1)\n if (!ref || !isNumberish(pct)) throw new Error(`ui0 color: invalid ref \"${raw}\" (expected name[@pct])`)\n const n = Number(pct)\n if (n < 0 || n > 100) throw new Error(`ui0 color: opacity ${pct} out of 0..100 in \"${raw}\"`)\n return { ref, opacity: n / 100 }\n}\n\nfunction parseToken(raw: string): ColorToken {\n const segments = raw.split(':')\n const out: ColorToken = { ref: '' }\n while (segments.length > 1) {\n const head = segments[0]\n if ((ColorSchemeValues as ReadonlyArray<string>).includes(head)) {\n out.scheme = head as ColorScheme\n } else if ((ColorPseudoValues as ReadonlyArray<string>).includes(head)) {\n out.pseudo = head as ColorPseudo\n } else {\n throw new Error(`ui0 color: unknown prefix \"${head}\" in \"${raw}\" (expected light|dark|hover|active|focus)`)\n }\n segments.shift()\n }\n Object.assign(out, parseRef(segments[0]))\n if (!out.ref) throw new Error(`ui0 color: missing color ref in \"${raw}\"`)\n return out\n}\n\n/** parse a color/fill prop value into tokens (one per layer) */\nexport function parseColorProp(value: string | string[] | undefined | null): ColorToken[] {\n const raws = (isString(value) ? value.split(SPACE) : isArray(value) ? value : [])\n .map((x) => String(x).trim())\n .filter(Boolean)\n\n const tokens: ColorToken[] = []\n let sawPair = false\n let sawNamedScheme = false\n for (const raw of raws) {\n if (raw.includes('/')) {\n const pair = raw.split('/')\n if (pair.length !== 2 || !pair[0] || !pair[1])\n throw new Error(`ui0 color: \"${raw}\" is not a light/dark pair (spell single-scheme as dark:ref)`)\n if (pair[0].includes(':') || pair[1].includes(':'))\n throw new Error(\n `ui0 color: \"${raw}\" - pair segments must be plain refs (name[-ramp][@pct]); ` +\n 'prefixed parts need the named form: light:<ref> [pseudo:]<ref>'\n )\n tokens.push({ scheme: 'light', ...parseRef(pair[0]) })\n tokens.push({ scheme: 'dark', ...parseRef(pair[1]) })\n sawPair = true\n } else {\n const token = parseToken(raw)\n if (token.scheme) sawNamedScheme = true\n tokens.push(token)\n }\n }\n if (sawPair && sawNamedScheme)\n throw new Error('ui0 color: a positional `a/b` pair cannot mix with light:/dark: prefixes in one prop')\n return tokens\n}\n","export default \".co_ca8c { /* slot marker */ }\\n.fi_8a2f { /* slot marker */ }\\n.gr_9658 { /* slot marker */ }\"","export default { \"colored\": \"co_ca8c\", \"filled\": \"fi_8a2f\", \"gradiented\": \"gr_9658\" }","// The color contract's generator endpoint (v2): turns the preset's color\n// pool into the --0-c-* swatch vars + ramps and the swatch setter classes the\n// runtime resolves against. Setter family:\n// [scheme-][pseudo-]{c|f}-<name> re-points the current slot\n// gating: ungated (both schemes / no pseudo), .theme_light, .theme_dark for\n// schemes; :hover/:active/:focus pseudo-classes for pseudos. The full grid\n// ships per pool name (the used-tokens resolver is planned to prune it).\n// Opacity VALUES never appear here - they ride element inline styles and the\n// color.use() scss bridges pick the active context (see color.scss). The\n// slot marker classes are static - they ship in color.inject.module.css;\n// class() re-exports the registry map plus the config-generated grid.\nimport type { CSSModuleClassList, RgbTuple, VarList } from '@ui0/types'\nimport type { ThemeContractGenerator } from '@ui0/types'\nimport { SPACES } from '@ui0/util'\n\nimport { buildPool, resolvePool } from '../../generator/pool'\nimport type { ContractFactory } from '../generator'\nimport { ColorPseudoValues, ColorSchemeValues } from './color.token'\nimport type { ColorThemeAppearanceConfig, ThemeColorPool } from './color.types'\n\nimport colorCss from './color.inject.module.css'\nimport $color from './color.module.css'\n\n// the ramp math (hsl/oklch) yields fractional channels - the css space-\n// separated syntax wants integers (also what hexToRgb/named colors produce)\nfunction channels(rgb: RgbTuple): string {\n return rgb.map((v) => Math.round(v)).join(' ')\n}\n\nconst PSEUDOS: ReadonlyArray<string | undefined> = [undefined, ...ColorPseudoValues]\nconst GATINGS: ReadonlyArray<{ prefix: string; selector: string }> = [\n { prefix: '', selector: '' },\n ...ColorSchemeValues.map((s) => ({\n prefix: `${s}-`,\n selector: `.theme_${s} `\n }))\n]\nconst SLOTS = ['c', 'f'] as const\n\nconst colorGenerator: ContractFactory = (ctx): ThemeContractGenerator => {\n const { config, hash } = ctx\n\n function vars(): Record<string, VarList> {\n const pool = (config as { color?: ColorThemeAppearanceConfig }).color\n const merged: ThemeColorPool = buildPool(pool, undefined)\n if (!Object.keys(merged).length) return {}\n\n const { base, ramps } = resolvePool(merged)\n const c: VarList = {}\n // every pool entry, foreground/background like any other - full word\n for (const [name, rgb] of Object.entries(base)) {\n c[`${name}-v`] = channels(rgb)\n const ramp = ramps[name]\n if (!ramp) continue\n for (const [type, steps] of Object.entries(ramp)) {\n steps?.forEach((rgbStep, i) => {\n c[`${name}-${type}${i + 1}-v`] = channels(rgbStep)\n })\n }\n }\n // the composed current slots a component consumes (color.scss mixins).\n // The base theme block assigns the current channel slots from the\n // foreground/background values; a .c-*/.f-* setter re-declares the -v slot\n // on its element to override\n if ('foreground' in base) c['cur-v'] = 'var(--0-c-foreground-v)'\n c.cur = 'rgb(var(--0-c-cur-v, var(--0-c-foreground-v)) / var(--0-c-o, 1))'\n const f: VarList = {}\n if ('background' in base) f['cur-v'] = 'var(--0-c-background-v)'\n f.cur = 'rgb(var(--0-f-cur-v, var(--0-c-background-v)) / var(--0-f-o, 1))'\n // the background-relative contrast flip: same hsl lightness comparison\n // the c/s ramps use - dark backgrounds read against white, light ones\n // against black; nothing is emitted without a background to flip\n if ('background' in base) {\n c['theme-contrast-v'] = SPACES.hsl.lightnessOf(base.background) < 50 ? '255 255 255' : '0 0 0'\n }\n return { c, f }\n }\n\n function css(): string {\n const pool = (config as { color?: ColorThemeAppearanceConfig }).color\n const names = Object.keys(buildPool(pool, undefined))\n if (!names.length) return colorCss\n\n const lines: string[] = []\n for (const { prefix, selector } of GATINGS) {\n for (const pseudo of PSEUDOS) {\n const pseudoPrefix = pseudo ? `${pseudo}-` : ''\n const pseudoSuffix = pseudo ? `:${pseudo}` : ''\n for (const name of names) {\n for (const slot of SLOTS) {\n const cls = `${prefix}${pseudoPrefix}${slot}-${name}`\n const ns = slot === 'c' ? '--0-c' : '--0-f'\n lines.push(`${selector}.${hash(cls)}${pseudoSuffix} { ${ns}-cur-v: var(--0-c-${name}-v); }`)\n }\n }\n }\n }\n return `${colorCss}\\n${lines.join('\\n')}`\n }\n\n function classes(): CSSModuleClassList {\n // the slot markers come from the registry map; the swatch grid is\n // config-generated and rides the same name-only hasher\n const out: CSSModuleClassList = { ...$color }\n const pool = (config as { color?: ColorThemeAppearanceConfig }).color\n const names = Object.keys(buildPool(pool, undefined))\n for (const { prefix } of GATINGS) {\n for (const pseudo of PSEUDOS) {\n const pseudoPrefix = pseudo ? `${pseudo}-` : ''\n for (const name of names) {\n for (const slot of SLOTS) {\n out[`${prefix}${pseudoPrefix}${slot}-${name}`] = hash(`${prefix}${pseudoPrefix}${slot}-${name}`)\n }\n }\n }\n }\n return out\n }\n\n return {\n namespace: 'c',\n vars: (scheme) => (scheme ? {} : vars()),\n css,\n class: classes,\n styles: () => ({})\n }\n}\n\nexport default colorGenerator\n","export default \".di_17eb {\\n opacity: var(--0-dis-o, 0.5);\\n}\"","export default { \"disabled\": \"di_17eb\" }","// The disabled contract's generator endpoint: the .disabled setter applies\n// the disabled-state look (shipped as static css in disabled.inject.module.css,\n// selectors hashed at build); the opacity value is theme-authored\n// (Ui0ThemePresetAppearanceConfig.disabled.opacity) and lands on the theme block.\nimport type { CSSModuleClassList, VarList } from '@ui0/types'\nimport type { ThemeContractGenerator } from '@ui0/types'\n\nimport type { ContractFactory } from '../generator'\nimport type { DisabledThemeAppearanceConfig } from './disabled.types'\n\nimport disabledCss from './disabled.inject.module.css'\nimport $disabled from './disabled.module.css'\n\nconst disabledGenerator: ContractFactory = (ctx): ThemeContractGenerator => {\n const { config } = ctx\n\n function vars(): Record<string, VarList> {\n const disabled = (config as { disabled?: DisabledThemeAppearanceConfig }).disabled\n if (disabled?.opacity === undefined) return {}\n return { dis: { o: disabled.opacity } }\n }\n\n return {\n namespace: 'dis',\n vars: (scheme) => (scheme ? {} : vars()),\n css: () => disabledCss,\n class: (): CSSModuleClassList => ({ ...$disabled }),\n styles: () => ({})\n }\n}\n\nexport default disabledGenerator\n","export default { \"displayed\": \"di_e228\", \"displayNormal\": \"di_bf77\" }","// The display contract's generator endpoint: turns the contract's slice of\n// the appearance config (DisplayThemeAppearanceConfig) into css vars and\n// setter classes. Values are authored in the theme config; this generator\n// only knows the wiring.\nimport type { CSSModuleClassList, StyleList, VarList } from '@ui0/types'\nimport type { ThemeContractGenerator } from '@ui0/types'\nimport { toUnits } from '@ui0/util'\n\nimport type { ContractContext, ContractFactory } from '../generator'\nimport type { DisplayThemeAppearanceConfig } from './display.types'\n\n// the logical class names shipped in display.module.css - class() re-exports\n// the registry map, so the logical names resolve to the distiller hashes.\nimport $display from './display.module.css'\n\nconst displayGenerator: ContractFactory = (ctx: ContractContext): ThemeContractGenerator => {\n const { config } = ctx\n\n function vars(): Record<string, VarList> {\n // after registration (see display.types.ts) this reads\n // `config.display`; typed loosely until the contract is named.\n const display = (config as { display?: DisplayThemeAppearanceConfig }).display\n if (display?.base === undefined) return {}\n return { display: { base: display.base } }\n }\n\n return {\n namespace: 'd',\n vars: (scheme) => (scheme ? {} : vars()),\n css: () => `.${$display.displayed} { /* point the component slot at the theme var */ }`,\n localScss: () => {\n const brp = ctx.settings.display?.breakpoints\n const out: StyleList = {}\n\n if (brp) {\n Object.keys(brp).forEach((k) => {\n out[`$${k}`] = toUnits(brp[k])\n })\n }\n return out\n },\n class: (): CSSModuleClassList => ({ ...$display }),\n styles: () => {\n const brp = ctx.settings.display?.breakpoints\n const out: StyleList = {}\n\n if (brp) {\n Object.keys(brp).forEach((k) => {\n out[`--0-display-${k}`] = toUnits(brp[k])\n })\n }\n return out\n }\n }\n}\n\nexport default displayGenerator\n","export default { \"elv\": \"el_b4e0\", \"elv1\": \"el_5e0f\", \"elv1n\": \"el_5995\", \"elv2\": \"el_fb8f\", \"elv2n\": \"el_af23\", \"elv3\": \"el_8867\", \"elv3n\": \"el_6c3d\", \"elv4\": \"el_4d5e\", \"elv4n\": \"el_a211\", \"elv5\": \"el_1ab1\", \"elv5n\": \"el_2df9\", \"elv6\": \"el_56bd\", \"elv6n\": \"el_b036\", \"elv7\": \"el_61ea\", \"elv7n\": \"el_8003\", \"elv8\": \"el_8924\", \"elv8n\": \"el_7bc0\", \"elv9\": \"el_1bb1\", \"elv9n\": \"el_734f\", \"elv10\": \"el_40d4\", \"elv10n\": \"el_ef94\", \"elv11\": \"el_a016\", \"elv11n\": \"el_fcd8\", \"elv12\": \"el_1c39\", \"elv12n\": \"el_ba0c\", \"elv13\": \"el_5602\", \"elv13n\": \"el_d306\", \"elv14\": \"el_3f15\", \"elv14n\": \"el_ece8\", \"elv15\": \"el_3130\", \"elv15n\": \"el_5599\", \"elv16\": \"el_c651\", \"elv16n\": \"el_f2d2\" }","// The elevation contract's generator endpoint: ONE .elv base class carries the\n// box-shadow (built from css vars), the per-step classes (.elv1..steps /\n// .elv1n..stepsn for inset) only fill in the var values for their step - no\n// shadow math is repeated per class. Shadow tuning (color, steps) lands in\n// the config with the elevation appearance settings.\nimport type { CSSModuleClassList } from '@ui0/types'\nimport type { ThemeContractGenerator } from '@ui0/types'\n\nimport type { ContractFactory } from '../generator'\nimport type { ElevationThemeAppearanceConfig } from './elevation.types'\n\nimport $elevation from './elevation.module.css'\n\n// the shared shadow: a fixed highlight ring + three layers assembled from the\n// --0-elv-* vars (the step classes fill those in; the base class shadows with\n// zero/fallback values until one is applied)\nconst BASE_CLASS_BODY = ` box-shadow:\n 0 0 0 1px rgba(255 255 255 / .1),\n var(--0-elv-i, ) 0px 1px 1px rgba(var(--0-elv-c, 0 0 0) / 0.1),\n var(--0-elv-i, ) var(--0-elv-x1, 0px) var(--0-elv-y1, 0px) rgba(var(--0-elv-c, 0 0 0) / 0.095),\n var(--0-elv-i, ) var(--0-elv-x2, 0px) var(--0-elv-y2, 0px) rgba(var(--0-elv-c, 0 0 0) / 0.13);`\n\nconst elevationGenerator: ContractFactory = (ctx): ThemeContractGenerator => {\n const { config, hash } = ctx\n const steps = (config as { elevation?: ElevationThemeAppearanceConfig }).elevation?.steps ?? 16\n function vars() {\n return {\n elv: {\n x1: '1px',\n y1: 'calc(var(--0-elv-x1) * 3)',\n x2: 'calc(var(--0-elv-x1) * 1.5)',\n y2: 'calc(var(--0-elv-x1) * 1.5)'\n }\n }\n }\n function stepVars(i: number, inset: boolean): string {\n const lines = [` --0-elv-x1: ${i}px;`]\n if (inset) lines.push(' --0-elv-i: inset;')\n return lines.join('\\n')\n }\n\n function css(): string {\n const lines: string[] = [`.${$elevation.elv} {\\n${BASE_CLASS_BODY}\\n}`]\n for (let i = 1; i <= steps; i++) {\n lines.push(`.${hash(`elv${i}`)} {\\n${stepVars(i, false)}\\n}`)\n lines.push(`.${hash(`elv${i}n`)} {\\n${stepVars(i, true)}\\n}`)\n }\n return lines.join('\\n')\n }\n\n function classes(): CSSModuleClassList {\n // the base class + the default 16 steps come from the registry map; a\n // config that extends the step count generates the extras dynamically\n const out: CSSModuleClassList = { ...$elevation }\n for (let i = 1; i <= steps; i++) {\n out[`elv${i}`] = hash(`elv${i}`)\n out[`elv${i}n`] = hash(`elv${i}n`)\n }\n return out\n }\n\n return {\n namespace: 'e',\n vars,\n css,\n class: classes,\n styles: () => ({})\n }\n}\n\nexport default elevationGenerator\n","export default \".rF_7ee9 {\\n --0-r-tl: var(--0c-r-full, var(--0-r-full));\\n --0-r-tr: var(--0c-r-full, var(--0-r-full));\\n --0-r-bl: var(--0c-r-full, var(--0-r-full));\\n --0-r-br: var(--0c-r-full, var(--0-r-full));\\n}\\n\\n.rS_e0da {\\n --0-r-tl: var(--0c-r-smooth, var(--0-r-smooth));\\n --0-r-tr: var(--0c-r-smooth, var(--0-r-smooth));\\n --0-r-bl: var(--0c-r-smooth, var(--0-r-smooth));\\n --0-r-br: var(--0c-r-smooth, var(--0-r-smooth));\\n}\\n\\n.rB_2f08 {\\n --0-r-tl: var(--0c-r-basic, var(--0-r-basic));\\n --0-r-tr: var(--0c-r-basic, var(--0-r-basic));\\n --0-r-bl: var(--0c-r-basic, var(--0-r-basic));\\n --0-r-br: var(--0c-r-basic, var(--0-r-basic));\\n}\\n\\n.rH_7415 {\\n --0-r-tl: var(--0c-r-hard, var(--0-r-hard));\\n --0-r-tr: var(--0c-r-hard, var(--0-r-hard));\\n --0-r-bl: var(--0c-r-hard, var(--0-r-hard));\\n --0-r-br: var(--0c-r-hard, var(--0-r-hard));\\n}\\n\\n.rN_2296 {\\n --0-r-tl: var(--0c-r-none, var(--0-r-none));\\n --0-r-tr: var(--0c-r-none, var(--0-r-none));\\n --0-r-bl: var(--0c-r-none, var(--0-r-none));\\n --0-r-br: var(--0c-r-none, var(--0-r-none));\\n}\\n\\n.ro_0102 {\\n --0-r-tl: var(--0c-r-basic, var(--0-r-basic));\\n --0-r-tr: var(--0c-r-basic, var(--0-r-basic));\\n --0-r-bl: var(--0c-r-basic, var(--0-r-basic));\\n --0-r-br: var(--0c-r-basic, var(--0-r-basic));\\n}\\n\\n.rl_52df {\\n --0-r-tl: var(--0c-r-basic, var(--0-r-basic));\\n --0-r-bl: var(--0c-r-basic, var(--0-r-basic));\\n}\\n\\n.rr_597c {\\n --0-r-tr: var(--0c-r-basic, var(--0-r-basic));\\n --0-r-br: var(--0c-r-basic, var(--0-r-basic));\\n}\\n\\n.rt_cdff {\\n --0-r-tl: var(--0c-r-basic, var(--0-r-basic));\\n --0-r-tr: var(--0c-r-basic, var(--0-r-basic));\\n}\\n\\n.rb_64f2 {\\n --0-r-bl: var(--0c-r-basic, var(--0-r-basic));\\n --0-r-br: var(--0c-r-basic, var(--0-r-basic));\\n}\\n\\n.tl_e660 {\\n --0-r-tl: var(--0c-r-basic, var(--0-r-basic));\\n}\\n\\n.tr_7817 {\\n --0-r-tr: var(--0c-r-basic, var(--0-r-basic));\\n}\\n\\n.bl_29d9 {\\n --0-r-bl: var(--0c-r-basic, var(--0-r-basic));\\n}\\n\\n.br_8850 {\\n --0-r-br: var(--0c-r-basic, var(--0-r-basic));\\n}\"","export default { \"rounded\": \"ro_0102\", \"rBasic\": \"rB_2f08\", \"rSmooth\": \"rS_e0da\", \"rHard\": \"rH_7415\", \"rNone\": \"rN_2296\", \"rFull\": \"rF_7ee9\", \"rl\": \"rl_52df\", \"rr\": \"rr_597c\", \"rt\": \"rt_cdff\", \"rb\": \"rb_64f2\", \"br\": \"br_8850\", \"bl\": \"bl_29d9\", \"tl\": \"tl_e660\", \"tr\": \"tr_7817\" }","// The round contract's generator endpoint: corner-radius setter classes.\n// The resolved rounding values live in the component namespace (--0c-r-*, see\n// round.scss); a setter class points the per-corner slots at one of\n// them, falling back to the theme-level --0-r-* when the component never ran\n// apply() (its own computed default wins where it did). The setter css is\n// static - it ships in round.inject.module.scss (compiled + hashed at build);\n// class() re-exports the registry map from round.module.css.\nimport type { CSSModuleClassList, StyleList } from '@ui0/types'\nimport type { ThemeContractGenerator } from '@ui0/types'\n\nimport type { ContractFactory } from '../generator'\n\nimport roundCss from './round.inject.module.scss'\nimport $round from './round.module.css'\n\nconst roundGenerator: ContractFactory = (): ThemeContractGenerator => {\n return {\n namespace: 'r',\n vars: () => ({}),\n css: () => roundCss,\n class: (): CSSModuleClassList => ({ ...$round }),\n styles: (): StyleList => ({\n '--0-r-base': '4px',\n '--0-r-tl': '0px',\n '--0-r-tr': '0px',\n '--0-r-bl': '0px',\n '--0-r-basic': 'calc(var(--0-s-m, 42px) * var(--0-s-density, 1))',\n '--0-r-br': '0px'\n })\n }\n}\n\nexport default roundGenerator\n","// Token expansion: a single base value -> the xxxs..xxxl geometric scale,\n// roundings derived from the control height, the heading scale and the global\n// unit scales (spacing / control / control-child). Every helper returns a\n// VarList (var name -> value) that the orchestrator merges into the theme\n// block and serializes.\n\nimport type { VarList } from '@ui0/types'\n\n// a single base value becomes the \"m\" step of a 9-step scale (xxxs..xxxl) -\n// geometric progression, ratio 1.2 (\"minor third\", the type-scale.com default),\n// rounded to the unit's natural precision so it works for any base the theme\n// sets, not just one hand-picked value.\nexport const SCALE_RATIO = 1.2\nconst SCALE_STEPS = ['xxxs', 'xxs', 'xs', 's', 'm', 'l', 'xl', 'xxl', 'xxxl']\n\n/** The step -> value map of one geometric scale. */\nfunction scaleValues(base: number, ratio: number): Record<string, number> {\n const out: Record<string, number> = {}\n for (const step of SCALE_STEPS) {\n const power = SCALE_STEPS.indexOf(step) - SCALE_STEPS.indexOf('m')\n out[step] = base * ratio ** power\n }\n return out\n}\n\n/**\n * Expand a single base value into the xxxs..xxxl scale with PURE step names\n * (no `--0-` prefix - the caller assigns the namespace).\n *\n * Three scales use this: `fs` (text font-size), `s` (control heights - a\n * component's `size` prop picks a step) and `sc` (a control's child heights).\n * An unparseable value (e.g. 'inherit') emits only the `m` step verbatim.\n *\n * @param value - the base value (the \"m\" step)\n * @param ratio - the geometric ratio between steps\n * @returns the pure step -> value map\n */\nexport function renderScale(value: string | number, ratio: number = SCALE_RATIO): VarList {\n const m = String(value).match(/^([\\d.]+)([a-z%]*)$/i)\n if (!m) return { m: value }\n const base = parseFloat(m[1])\n const unit = m[2] || 'px' // a bare number means px\n const round = (n: number) => (unit === 'px' ? Math.round(n) : Math.round(n * 1000) / 1000)\n const values = scaleValues(base, ratio)\n return Object.fromEntries(SCALE_STEPS.map((step) => [step, `${round(values[step])}${unit}`]))\n}\n\n// when a theme declares no `roundings`, the rounding names are derived from the\n// control height: full is half the control (a pill), the rest are evenly\n// shorter proportions. Mirrors the round.scss mixin's computed defaults, so a\n// theme that sets only controlSize still gets a coherent --0-r-* set.\nconst ROUND_DIVISORS: Record<string, number> = {\n hard: 14,\n basic: 8,\n smooth: 4,\n full: 2\n}\n\n/**\n * Derive the rounding values from the control height: `full` is half the\n * control (a pill), the rest are evenly shorter proportions. Mirrors the\n * round.scss mixin's computed defaults, so a theme that sets only the control\n * size still gets a coherent `--0-r-*` set. PURE names (`none`, `hard`, ...) -\n * the caller assigns the namespace.\n *\n * @param controlSize - the control height the proportions divide\n * @returns the pure rounding name -> value map\n */\nexport function renderDerivedRoundings(controlSize: string | number): VarList {\n const out: VarList = { none: '0px' }\n const m = String(controlSize).match(/^([\\d.]+)([a-z%]*)$/i)\n if (m) {\n const base = parseFloat(m[1])\n const unit = m[2] || 'px'\n const round = (n: number) => (unit === 'px' ? Math.round(n) : Math.round(n * 1000) / 1000)\n for (const [k, d] of Object.entries(ROUND_DIVISORS)) out[k] = `${round(base / d)}${unit}`\n } else {\n // non-numeric (e.g. a var()/clamp()) - keep it live as a calc()\n for (const [k, d] of Object.entries(ROUND_DIVISORS)) out[k] = `calc(${controlSize} / ${d})`\n }\n return out\n}\n\nconst HEADING_LEVELS = 6\n\n/**\n * The heading scale - h1..h6 derived from the SAME base as the font-size\n * scale (typography.fontSize), stepped by `ratio`. h6 is anchored to the\n * base font size, each level up is one ratio larger (h1 is the largest).\n * PURE names (`h1`..`h6`) - the caller assigns the namespace.\n *\n * @param fontSize - the base font size\n * @param ratio - the per-level growth ratio\n * @returns the pure heading level -> value map\n */\nexport function renderHeadingScale(fontSize: string | number, ratio: number): VarList {\n const m = String(fontSize).match(/^([\\d.]+)([a-z%]*)$/i)\n if (!m) return {}\n const base = parseFloat(m[1])\n const unit = m[2] || 'px'\n const round = (n: number) => (unit === 'px' ? Math.round(n) : Math.round(n * 1000) / 1000)\n const out: VarList = {}\n for (let lvl = 1; lvl <= HEADING_LEVELS; lvl++) {\n out[`h${lvl}`] = `${round(base * ratio ** (HEADING_LEVELS - lvl))}${unit}`\n }\n return out\n}\n\n/**\n * The global unit scales, emitted on the theme so they ALWAYS exist - a\n * component that doesn't opt into the `sizeable()` mixin simply inherits\n * them. Each is a calc() off the theme's own base vars (same formula the\n * SCSS `sizeable()` mixin uses locally, so a component can re-derive the\n * control units under its own `size`):\n *\n * `--0-u{1..8}` <- `--0-u-base` (spacing / typography)\n * `--0-uc{1..8}` <- `--0-s-m` x density / 14 (control units)\n * `--0-ucc{1..4}` <- `--0-sc-m` x density / 10 (control-child units)\n *\n * @param ns - the namespace step 1 lands in (only used for the calc refs to\n * `--0-<ns>-1`)\n * @param first - the value of the `1` step (usually a calc off the base)\n * @param count - how many steps to emit\n * @returns the pure step -> value map\n */\nexport function renderUnits(ns: string, first: string, count: number): VarList {\n const out: VarList = { 1: first }\n for (let i = 2; i <= count; i++) out[i] = `calc(var(--0-${ns}1) * ${i})`\n return out\n}\n\n/**\n * Numbers get a unit suffix (px for lengths, ms for durations); strings pass\n * through verbatim so an author can write '.3em', '1s', 'clamp(...)', etc.\n *\n * @param v - the authored value\n * @param unit - the unit for numbers, defaults to `'px'`\n * @returns the css-ready value\n */\nexport function cssLen(v: unknown, unit = 'px'): string {\n return typeof v === 'number' ? `${v}${unit}` : String(v)\n}\n","export default \".si_bce5 {\\n --0-s: var(--0-s-xxxs);\\n}\\n\\n.si_87d4 {\\n --0-s: var(--0-s-xxs);\\n}\\n\\n.si_0820 {\\n --0-s: var(--0-s-xs);\\n}\\n\\n.si_9329 {\\n --0-s: var(--0-s-s);\\n}\\n\\n.si_96e7 {\\n --0-s: var(--0-s-m);\\n}\\n\\n.si_05f9 {\\n --0-s: var(--0-s-l);\\n}\\n\\n.si_81de {\\n --0-s: var(--0-s-xl);\\n}\\n\\n.si_d16b {\\n --0-s: var(--0-s-xxl);\\n}\\n\\n.si_5136 {\\n --0-s: var(--0-s-xxxl);\\n}\\n\\n.si_e681 {\\n --0-s: var(--0-s-custom);\\n}\"","export default { \"sizeXl\": \"si_81de\", \"sizeM\": \"si_96e7\", \"sizeXs\": \"si_0820\", \"sizeS\": \"si_9329\", \"sizeL\": \"si_05f9\", \"sizeXxs\": \"si_87d4\", \"sizeXxxs\": \"si_bce5\", \"sizeXxxl\": \"si_5136\", \"sizeXxl\": \"si_d16b\", \"sizeCustom\": \"si_e681\", \"sized\": \"si_3f5b\", \"child\": \"ch_ddc9\", \"fontSizing\": \"fo_5e6f\" }","// The size contract's generator endpoint: turns the preset's size settings\n// (Ui0ThemeConfig.size: control/child base heights) into the contract's css\n// vars - the --0-s-*/--0-sc-* height scales and the derived --0-uc*/--0-ucc*\n// unit scales. The `size` prop setters are static - they ship in\n// size.inject.module.scss (compiled + hashed at build); class() re-exports\n// the registry map from size.module.css, so prop values resolve to the same\n// hashed names the distiller publishes.\nimport type { CSSModuleClassList, VarList } from '@ui0/types'\nimport type { ThemeContractGenerator } from '@ui0/types'\n\nimport { renderScale, renderUnits, SCALE_RATIO } from '../../generator/scales'\nimport type { ContractContext, ContractFactory } from '../generator'\n\nimport sizeCss from './size.inject.module.scss'\nimport $size from './size.module.css'\n\nconst CONTROL_UNIT_DIVIDER = 14\nconst CONTROL_CHILD_UNIT_DIVIDER = 10\n\nconst sizeGenerator: ContractFactory = (ctx: ContractContext): ThemeContractGenerator => {\n const { config } = ctx\n\n function vars(): Record<string, VarList> {\n const out: Record<string, VarList> = {}\n const size = config.size\n if (size?.control !== undefined) {\n out.s = renderScale(size.control, SCALE_RATIO)\n out.uc = renderUnits('uc', `calc(var(--0-s-m) * var(--0-s-density, 1) / ${CONTROL_UNIT_DIVIDER})`, 8)\n }\n if (size?.child !== undefined) {\n out.sc = renderScale(size.child)\n out.ucc = renderUnits('ucc', `calc(var(--0-sc-m) * var(--0-s-density, 1) / ${CONTROL_CHILD_UNIT_DIVIDER})`, 4)\n }\n // base density multiplier; the global .density-* classes flip it at\n // runtime. (a per-theme density setting returns with the density contract)\n if (size?.control !== undefined || size?.child !== undefined) {\n out.s = { ...out.s, density: 1 }\n }\n return out\n }\n\n return {\n namespace: 's',\n vars: (scheme) => (scheme ? {} : vars()),\n css: () => sizeCss,\n class: (): CSSModuleClassList => ({ ...$size }),\n styles: () => ({})\n }\n}\n\nexport default sizeGenerator\n","// The style contract's generator endpoint: passes arbitrary css through from\n// the preset config - `style.vars` become `--0-style-*` custom properties on\n// the theme block, `style.raw` lands as plain declarations. No classes of its\n// own.\nimport type { CSSModuleClassList, StyleList, VarList } from '@ui0/types'\nimport type { ThemeContractGenerator } from '@ui0/types'\n\nimport type { ContractFactory } from '../generator'\n\nconst styleGenerator: ContractFactory = (ctx): ThemeContractGenerator => {\n const { config } = ctx\n\n function vars(): Record<string, VarList> {\n const style = config.style\n if (!style?.vars) return {}\n return {\n style: Object.fromEntries(Object.entries(style.vars))\n }\n }\n\n function styles(): StyleList {\n const style = config.style\n if (!style?.raw) return {}\n return { ...style.raw }\n }\n\n return {\n namespace: 'style',\n vars: (scheme) => (scheme ? {} : vars()),\n css: () => '',\n class: (): CSSModuleClassList => ({}),\n styles: (scheme) => (scheme ? {} : styles())\n }\n}\n\nexport default styleGenerator\n","export default \".fw_f5d2 { font-weight: 100 }\\n.fw_25c0 { font-weight: 200 }\\n.fw_de2b { font-weight: 300 }\\n.fw_a02f { font-weight: 400 }\\n.fw_c057 { font-weight: 500 }\\n.fw_aee5 { font-weight: 600 }\\n.fw_3207 { font-weight: 700 }\\n.fw_d808 { font-weight: 800 }\\n.fw_bb66 { font-weight: 900 }\\n\\n.tt_c60d { text-transform: uppercase }\\n.tt_56d5 { text-transform: lowercase }\\n.tt_ce2a { text-transform: capitalize }\\n.tt_1ff4 { text-transform: none }\\n.tt_59a5 { text-transform: full-width }\\n.tt_50f0 { text-transform: full-size-kana }\\n\\n.ta_c49e { text-align: start }\\n.ta_e1d2 { text-align: end }\\n.ta_d725 { text-align: center }\\n.ta_3342 { text-align: left }\\n.ta_e5b8 { text-align: right }\\n.ta_010c { text-align: justify }\\n.ta_0241 { text-align: match-parent }\\n\\n.to_a88e { text-orientation: mixed }\\n.to_4919 { text-orientation: sideways }\\n.to_2640 { text-orientation: sideways-right }\\n.to_de51 { text-orientation: use-glyph-orientation }\\n.to_35e5 { text-orientation: upright }\\n\\n.tw_83bf { text-wrap: nowrap }\\n.tw_d03a { text-wrap: wrap }\\n.tw_4fdb { text-wrap: balance }\\n.tw_f5a3 { text-wrap: pretty }\\n.tw_698e { text-wrap: stable }\\nh1, h2, h3, h4, h5, h6 {\\n --0-typo-step: 0.25rem; /* шаг (длина) */\\n font-size: calc(var(--0-typo-h-fs, var(--0-typo-fs, 1rem)) + var(--0-typo-step) * var(--0-typo-x));\\n line-height: calc(1 + 1 / var(--0-typo-x));\\n\\n}\\nh1 { --0-typo-x: 6; }\\nh2 { --0-typo-x: 5; }\\nh3 { --0-typo-x: 4; }\\nh4 { --0-typo-x: 3; }\\nh5 { --0-typo-x: 2; }\\nh6 { --0-typo-x: 1; }\"","export default { \"fw100\": \"fw_f5d2\", \"fw200\": \"fw_25c0\", \"fw300\": \"fw_de2b\", \"fw400\": \"fw_a02f\", \"fw500\": \"fw_c057\", \"fw600\": \"fw_aee5\", \"fw700\": \"fw_3207\", \"fw800\": \"fw_d808\", \"fw900\": \"fw_bb66\", \"tt-uppercase\": \"tt_c60d\", \"tt-lowercase\": \"tt_56d5\", \"tt-capitalize\": \"tt_ce2a\", \"tt-none\": \"tt_1ff4\", \"tt-full\": \"tt_59a5\", \"tt-full-size-kana\": \"tt_50f0\", \"ta-center\": \"ta_d725\", \"ta-end\": \"ta_e1d2\", \"ta-justify\": \"ta_010c\", \"ta-left\": \"ta_3342\", \"ta-match-parent\": \"ta_0241\", \"ta-right\": \"ta_e5b8\", \"ta-start\": \"ta_c49e\", \"to-mixed\": \"to_a88e\", \"to-sideways\": \"to_4919\", \"to-sideways-right\": \"to_2640\", \"to-use-glyph-orientation\": \"to_de51\", \"to-upright\": \"to_35e5\", \"tw-nowrap\": \"tw_83bf\", \"tw-wrap\": \"tw_d03a\", \"tw-balance\": \"tw_4fdb\", \"tw-pretty\": \"tw_f5a3\", \"tw-stable\": \"tw_698e\" }","// The typography contract's generator endpoint: turns the contract's slice of\n// the appearance config (TypographyThemeAppearanceConfig) into css vars and\n// ships the contract's own static css (the font-weight / text-transform /\n// text-align / text-orientation / text-wrap utility setters). The setter css\n// lives in typography.inject.module.css - the ui0 css-modules pipeline\n// compiles it and hashes the selectors at build; class() re-exports the\n// registry map from typography.module.css, so logical names resolve to the\n// same hashes everywhere.\nimport type { CSSModuleClassList, ThemeContractGenerator, VarList } from '@ui0/types'\nimport { toUnits, tryToUnits } from '@ui0/util'\n\nimport type { ContractContext, ContractFactory } from '../generator'\n\nimport typographyCss from './typography.inject.module.css'\nimport $typography from './typography.module.css'\n\nconst typographyGenerator: ContractFactory = (ctx: ContractContext): ThemeContractGenerator => {\n function vars(): Record<string, VarList> {\n // after registration (see typography.types.ts) this reads\n // `config.typography`; typed loosely until the contract is named.\n\n if (ctx.settings.typography) {\n const { headingRatio, fontSizeHeading, fontSize } = ctx.settings.typography\n return {\n typo: {\n fs: tryToUnits(fontSize),\n 'h-ratio': headingRatio,\n 'h-fs': toUnits(fontSizeHeading) || tryToUnits(fontSize)\n }\n }\n }\n return {}\n }\n\n return {\n namespace: 't',\n vars: (scheme) => (scheme ? {} : vars()),\n css: () => typographyCss,\n class: (): CSSModuleClassList => ({ ...$typography }),\n styles: () => ({})\n }\n}\n\nexport default typographyGenerator\n","import backdropGenerator from './contracts/backdrop/backdrop.generator'\nimport colorGenerator from './contracts/color/color.generator'\nimport disabledGenerator from './contracts/disabled/disabled.generator'\nimport displayGenerator from './contracts/display/display.generator'\nimport elevationGenerator from './contracts/elevation/elevation.generator'\n// The generator registry: every contract's factory, assembled from\n// contracts/*/<name>.generator.ts in emission order (vars join in this\n// order). Each contract module default-exports its ContractFactory - no\n// named create<Name>Generator exports to keep in sync here.\n//\n// External contracts (a contract shipped as its own package, future work)\n// will default-export the same ContractFactory shape; a consumer merges them\n// into this map - or passes its own registry to runContractGenerators'\n// `factories` param - instead of this package growing import couplings.\nimport type { ContractFactory } from './contracts/generator'\nimport roundGenerator from './contracts/round/round.generator'\nimport sizeGenerator from './contracts/size/size.generator'\nimport styleGenerator from './contracts/style/style.generator'\nimport typographyGenerator from './contracts/typography/typography.generator'\n\nexport const contractGenerators: Record<string, ContractFactory> = {\n size: sizeGenerator,\n color: colorGenerator,\n round: roundGenerator,\n backdrop: backdropGenerator,\n elevation: elevationGenerator,\n disabled: disabledGenerator,\n display: displayGenerator,\n typography: typographyGenerator,\n style: styleGenerator\n}\n","// The class-name hasher for generated contract CSS. Must produce exactly the\n// same names as the @ui0/vite distiller (which hashes src/contracts/**/*.module.css)\n// - src/generator/hash.spec.ts (in size.generator.spec.ts) asserts the lockstep,\n// so class() maps and .module.css @value exports always agree with the classes\n// emitted into the generated theme CSS.\n//\n// sha256hex is pure JS (packages/util) - no node:crypto, so the theme's\n// runtime API (class() maps) works in the browser too.\nimport { sha256hex } from '@ui0/util'\n\n/** deterministic scoped name for a class-registry entry: xx_<sha256(name):4> */\nexport function hashClassName(name: string): string {\n const hash = sha256hex(name).slice(0, 4)\n return `${name.slice(0, 2)}_${hash}`\n}\n","import type { StyleList, VarList } from '@ui0/types'\n// Contract orchestration: runs the contract factories per preset/appearance\n// and collects what each wants emitted: theme-block vars/styles, per-scheme\n// additions, the contract's own css (setter classes) and its local scss.\n// Each factory gets a ContractContext (resolved appearance config + the class\n// hasher) and returns the generator whose vars() feed the theme blocks and\n// whose css()/class()/styles()/localScss() face the runtime consumer.\nimport type {\n ThemeAppearance,\n ThemeContractGenerator,\n ThemePresetName,\n Ui0ThemePresetAppearanceConfig,\n Ui0ThemeContractSettings\n} from '@ui0/types'\n\nimport type { ContractContext, ContractFactory } from '../contracts/generator'\n// the built-in contract factories, assembled in src/generator.ts (each\n// contract default-exports its factory); external contract packages will\n// pass their own merged registry through the `factories` param instead\nimport { contractGenerators } from '../generator'\nimport { hashClassName } from './hash'\n\n/**\n * One contract's slice of a theme block: the vars and plain declarations the\n * contract emitted for the appearance config the run was created with.\n */\nexport interface ContractThemeBlock {\n /** the contract's name (a key of the factories registry) */\n contract: string\n vars: VarList\n styles: StyleList\n}\n\n/**\n * Run every registered contract against one resolved appearance config and\n * collect what each wants emitted: theme-block vars/styles (per contract and\n * merged), per-scheme additions, and the contract's own css (setter classes -\n * config-independent, deduped by the caller across presets).\n *\n * A contract whose entry in `settings` is exactly `false` is disabled: its\n * factory never runs, so it contributes no blocks, no vars and no css.\n *\n * `themeVars`/`themeStyles` merge every contract's base-appearance output;\n * `schemeVars`/`schemeStyles` hold per-scheme additions only (contracts emit\n * nothing there unless they have scheme-specific values - the orchestrator\n * re-runs them against the scheme-merged config for full scheme blocks).\n */\nexport interface ContractGeneratorResult {\n generators: Record<string, ThemeContractGenerator>\n themeStyles: StyleList\n themeVars: VarList\n /** the per-contract split of themeVars/themeStyles, in factory emission order */\n themeBlocks: ContractThemeBlock[]\n schemeVars: Record<ThemeAppearance, VarList>\n schemeStyles: Record<ThemeAppearance, StyleList>\n contractCss: Record<string, string>\n /** per-contract consumer scss (the localScss exit point), keyed by contract */\n contractLocalScss: Record<string, string>\n}\n/**\n * Run every registered contract factory against one resolved appearance\n * config. See {@link ContractGeneratorResult} for the collected shape.\n *\n * @param presetName - the preset being generated (goes into the context)\n * @param config - the resolved appearance config (extends flattened, base\n * merged under the scheme)\n * @param hash - class-name hasher; defaults to the distiller-lockstep hasher\n * @param settings - the consumer's contract settings (ThemePluginConfig.contracts)\n * @param factories - the registry to run; defaults to the built-in\n * {@link contractGenerators} - external contract packages merge their own\n * default-exported factories in and pass the merged map\n */\nexport function runContractGenerators(\n presetName: ThemePresetName,\n config: Ui0ThemePresetAppearanceConfig,\n hash: (name: string) => string = hashClassName,\n settings: Ui0ThemeContractSettings = {},\n factories: Record<string, ContractFactory> = contractGenerators\n): ContractGeneratorResult {\n const ctx: ContractContext = { presetName, config, settings, hash }\n const generators: Record<string, ThemeContractGenerator> = {}\n const themeVars: VarList = {}\n const themeStyles: StyleList = {}\n const themeBlocks: ContractThemeBlock[] = []\n const schemeVars: Record<ThemeAppearance, VarList> = {\n default: {},\n dark: {},\n light: {}\n }\n const schemeStyles: Record<ThemeAppearance, StyleList> = {\n default: {},\n dark: {},\n light: {}\n }\n const contractCss: Record<string, string> = {}\n const contractLocalScss: Record<string, string> = {}\n\n for (const [name, factory] of Object.entries(factories)) {\n // settings.<name> === false disables the contract entirely\n if ((settings as Record<string, unknown>)[name] === false) continue\n\n const generator = factory(ctx)\n generators[name] = generator\n\n // generators speak pure (namespace -> varName -> value); the orchestrator\n // owns the global prefix, expanding to `--0-<namespace>-<varName>`\n const vars = flattenVars(generator.vars())\n const styles = generator.styles()\n Object.assign(themeVars, vars)\n Object.assign(themeStyles, styles)\n themeBlocks.push({ contract: name, vars, styles })\n\n for (const scheme of ['default', 'dark', 'light'] as const) {\n Object.assign(schemeVars[scheme], flattenVars(generator.vars(scheme)))\n Object.assign(schemeStyles[scheme], generator.styles(scheme))\n }\n\n const css = generator.css()\n if (css) contractCss[name] = css\n const localScss = generator.localScss?.()\n if (localScss && Object.keys(localScss).length) contractLocalScss[name] = localScss\n }\n\n return {\n generators,\n themeStyles,\n themeVars,\n themeBlocks,\n schemeVars,\n schemeStyles,\n contractCss,\n contractLocalScss\n }\n}\n\n/**\n * Expand a generator's namespaced pure vars into the flat global form:\n * `{ s: { m: '32px' } }` -> `{ '--0-s-m': '32px' }`. Numeric keys join the\n * namespace directly (`{ uc: { 1: x } }` -> `--0-uc1`) - the unit-scale\n * convention; every other key takes a dash (`--0-<ns>-<name>`).\n */\nfunction flattenVars(namespaced: Record<string, VarList>): VarList {\n const out: VarList = {}\n for (const [ns, list] of Object.entries(namespaced)) {\n for (const [k, v] of Object.entries(list)) {\n out[/^\\d/.test(k) ? `--0-${ns}${k}` : `--0-${ns}-${k}`] = v\n }\n }\n return out\n}\n","// Preset resolution: deep-flattening `extends` chains into self-complete\n// presets - each appearance config is merged independently (weakest ->\n// strongest: the extended preset <- this preset's own appearance config).\nimport type { ThemePreset, ThemePresetName, ThemePresets } from '@ui0/types'\n\n/** Type guard: a plain record (not an array, not null) - deepMerge recurses\n * into these and overwrites anything else. */\nfunction isPlainObject(v: unknown): v is Record<string, unknown> {\n return typeof v === 'object' && v !== null && !Array.isArray(v)\n}\n\n/**\n * Deep-merge `from` over `to` and return a new object.\n *\n * Nested plain objects merge key by key; anything else (scalars, arrays,\n * class instances, mismatched types) is replaced wholesale - `from` wins.\n * Neither input is mutated.\n *\n * @param to - the base object (weakest)\n * @param from - the object merged on top (strongest)\n * @returns the merged object\n */\nexport function deepMerge<T extends Record<string, unknown>>(to: T, from: T): T {\n const result = { ...to }\n for (const key in from) {\n if (key in to && isPlainObject(to[key]) && isPlainObject(from[key])) {\n result[key] = deepMerge(to[key] as Record<string, unknown>, from[key] as Record<string, unknown>) as T[Extract<\n keyof T,\n string\n >]\n } else {\n result[key] = from[key]\n }\n }\n return result\n}\n\n/**\n * Resolve one preset into a self-complete preset, flattening its `extends`\n * chain: the extended preset is merged UNDER this preset's own appearance\n * configs. Results are memoized in `cache` - pass the same cache across a\n * whole generation run so shared ancestors resolve once.\n *\n * @param presets - the preset map to resolve against\n * @param name - the preset to resolve\n * @param cache - per-run memo of already-resolved presets\n * @returns the flattened preset\n * @throws when `name` (or a preset in its `extends` chain) is undeclared\n */\nexport function resolvePreset(\n presets: ThemePresets,\n name: ThemePresetName,\n cache: Record<ThemePresetName, ThemePreset>\n): ThemePreset {\n if (cache[name]) return cache[name]\n const raw = presets[name]\n if (!raw) throw new Error(`unknown theme preset: ${name}`)\n const resolved = raw.extends\n ? (deepMerge(\n resolvePreset(presets, raw.extends, cache) as unknown as Record<string, unknown>,\n raw as unknown as Record<string, unknown>\n ) as unknown as ThemePreset)\n : raw\n cache[name] = resolved\n return resolved\n}\n","// Orchestrator: resolve presets (extends flattened) -> run the contract\n// generators per appearance -> emit the theme CSS. Each contract owns its\n// own vars/classes; this file only assembles the blocks:\n//\n// .theme-{preset} <- one block per contract (themeBlocks),\n// commented /* <contract> */\n// .theme-{preset}.theme_dark <- color-scheme + one block per contract\n// carrying ONLY the declarations that\n// differ from the base (everything else\n// inherits the base block)\n// .theme-{preset}.theme_light <- same for light\n// <contract setter classes> <- css(), deduped, inside `@layer theme`\nimport type { StyleList, VarList } from '@ui0/types'\nimport type {\n ThemePluginConfig,\n ThemePreset,\n ThemePresetName,\n Ui0ThemePresetAppearanceConfig,\n Ui0ThemeContractSettings\n} from '@ui0/types'\n\nimport builtinDefaults from '../config.default'\nimport { schemesOf } from '../types'\nimport { generateBaseCss } from './base'\nimport { runContractGenerators } from './contracts'\nimport type { ContractThemeBlock } from './contracts'\nimport { buildPool, resolvePool } from './pool'\nimport { deepMerge, resolvePreset } from './theme-def'\n\n/**\n * Merge the built-in default preset UNDER every preset of the consumer's\n * config (weakest -> strongest: built-in default <- the preset itself), so\n * any setting a preset omits falls back to the default. The default preset\n * itself is always present; an empty consumer config gets exactly the\n * built-in default. Contract settings follow the same rule - the built-in\n * `contracts` map sits under the consumer's one (deep-merged per contract).\n */\nexport function withDefaults(\n config: ThemePluginConfig = {\n default: builtinDefaults.default,\n contracts: {},\n presets: {}\n }\n): ThemePluginConfig {\n const base = builtinDefaults.presets[builtinDefaults.default]\n if (!base) return config\n const presets = config.presets ?? {}\n\n const keys = new Set([...Object.keys(builtinDefaults.presets), ...Object.keys(presets)])\n const out: ThemePluginConfig = {\n default: keys.has(config.default) ? config.default : builtinDefaults.default,\n // contract settings follow the presets' rule: the built-in baseline\n // sits UNDER the consumer's own (per contract, deep-merged)\n contracts: deepMerge(\n (builtinDefaults.contracts ?? {}) as Record<string, unknown>,\n (config.contracts ?? {}) as Record<string, unknown>\n ) as Ui0ThemeContractSettings,\n presets: {}\n }\n for (const key of keys) {\n const preset = presets[key] ?? builtinDefaults.presets[key]\n out.presets[key] = preset\n ? (deepMerge(\n base as unknown as Record<string, unknown>,\n preset as unknown as Record<string, unknown>\n ) as unknown as ThemePreset)\n : structuredClone(base)\n }\n return out\n}\n\n/**\n * The structural result of a generation run: the theme css (preset blocks +\n * contract setter classes inside `@layer theme`) plus each contract's css\n * keyed by name - a consumer that wants to split outputs takes the pieces\n * apart instead of the single {@link generateThemeCss} string.\n */\nexport interface ThemeArtifacts {\n themeCss: string\n contractCss: Record<string, string>\n /** per-contract consumer scss (localScss), first preset wins - config-independent */\n localScss: Record<string, string>\n}\n\n/**\n * Generate the theme for a resolved config: one base block per preset\n * (`.theme-{preset}`) plus a scheme block per declared appearance\n * (`.theme_{scheme}`, re-declaring the full merged config), and every\n * contract's setter classes, deduped across presets, inside `@layer theme`.\n *\n * @param config - a config already passed through {@link withDefaults}\n * @param emitPresets - which presets get a css block. Defaults to every\n * preset of `config`; pass the consumer's own preset names to keep the\n * built-in default out of the emitted css while it still back-fills the\n * consumer's presets with fallback values\n * @returns the assembled theme css and the per-contract css/scss pieces\n */\nexport function generateThemeArtifacts(\n config: ThemePluginConfig,\n emitPresets?: ThemePresetName[]\n): ThemeArtifacts {\n const cache: Record<ThemePresetName, ThemePreset> = {}\n // contract css/scss is config-independent for static setters (same body for\n // every preset) - first preset wins per contract name.\n const contractCss = new Map<string, string>()\n const localScss = new Map<string, string>()\n let css = ''\n\n for (const presetName of emitPresets ?? Object.keys(config.presets)) {\n const preset = resolvePreset(config.presets, presetName, cache)\n\n const base = runContractGenerators(presetName, schemesOf(preset).default, undefined, config.contracts)\n collectContractPieces(contractCss, base.contractCss)\n collectContractPieces(localScss, base.contractLocalScss)\n css += emitThemeBlocks(`.theme-${presetName}`, base.themeBlocks)\n const baseBlocks = new Map(base.themeBlocks.map((b) => [b.contract, b]))\n\n for (const scheme of ['dark', 'light'] as const) {\n const schemeConf = schemesOf(preset)[scheme]\n if (!schemeConf) continue\n // the scheme inherits everything the base declares; a scheme block\n // re-declares ONLY the declarations whose value actually differs\n // (the run sees the scheme-merged config, diffed against the base run)\n const merged = deepMerge(\n schemesOf(preset).default as Record<string, unknown>,\n schemeConf as Record<string, unknown>\n ) as Ui0ThemePresetAppearanceConfig\n const run = runContractGenerators(presetName, merged, undefined, config.contracts)\n collectContractPieces(contractCss, run.contractCss)\n collectContractPieces(localScss, run.contractLocalScss)\n\n const selector = `.theme-${presetName}.theme_${scheme}`\n css += `${selector} {\\n color-scheme: ${scheme};\\n}\\n`\n for (const block of run.themeBlocks) {\n const baseBlock = baseBlocks.get(block.contract)\n css += emitThemeBlocks(selector, [\n {\n contract: block.contract,\n vars: diffList(baseBlock?.vars ?? {}, block.vars),\n styles: diffList(baseBlock?.styles ?? {}, block.styles)\n }\n ])\n }\n\n // per-scheme additions on top of the base declaration (contracts rarely\n // emit these - a non-empty map means the contract computes scheme-\n // specific values it did not put into the base block; diff against the\n // base run so unchanged schemes re-declare nothing)\n const additions = [\n ...declLines(diffList(base.schemeVars[scheme], run.schemeVars[scheme])),\n ...declLines(diffList(base.schemeStyles[scheme], run.schemeStyles[scheme]))\n ]\n if (additions.length) css += `${selector} {\\n /* ${scheme} additions */\\n${additions.join('\\n')}\\n}\\n`\n }\n }\n\n // contract setter classes live in the same low-priority `theme` layer (a\n // component's own ui0.<comp> layer still wins over them). The base body\n // reset comes first - everything else in the layer overrides it.\n const contractBody = [...contractCss.values()].join('\\n')\n const layerBody = `${generateBaseCss()}\\n${css}${contractBody ? contractBody + '\\n' : ''}`\n return {\n themeCss: `@layer theme, ui0;\\n@layer theme {\\n${layerBody}}\\n`,\n contractCss: Object.fromEntries(contractCss),\n localScss: Object.fromEntries(localScss)\n }\n}\n\n/**\n * Generate the complete theme CSS for a resolved config - the single-string\n * form of {@link generateThemeArtifacts}. Pass the result through\n * `withDefaults` first unless the config is already self-complete.\n *\n * @param config - a config already passed through {@link withDefaults}\n * @param emitPresets - which presets get a css block (see\n * {@link generateThemeArtifacts})\n * @returns the theme css (preset + scheme blocks + setter classes)\n */\nexport function generateThemeCss(\n config: ThemePluginConfig,\n emitPresets?: ThemePresetName[]\n): string {\n return generateThemeArtifacts(config, emitPresets).themeCss\n}\n\n/**\n * Merge a run's per-contract pieces into the cross-preset dedupe map - the\n * first preset to emit a contract's setters/scss wins (they are\n * config-independent).\n */\nfunction collectContractPieces(map: Map<string, string>, pieces: Record<string, string>) {\n for (const [name, body] of Object.entries(pieces)) {\n if (!map.has(name)) map.set(name, body)\n }\n}\n\n/**\n * VarList/StyleList -> theme-block declaration lines. Keys pass through\n * verbatim (css custom properties keep their exact spelling); values are\n * interpolated as authored - numbers print bare (`--0-dis-o: 1;`).\n */\nfunction declLines(list: VarList | StyleList): string[] {\n return Object.entries(list).map(([k, v]) => ` ${k}: ${v};`)\n}\n\n/**\n * Emit one theme block per contract that produced declarations: the same\n * selector repeated, each block carrying a `/* <contract> *\\/` comment, so\n * the generated css reads per-contract and a disabled (or silent) contract\n * simply has no block. Contracts with nothing to declare are skipped.\n */\nfunction emitThemeBlocks(selector: string, blocks: ContractThemeBlock[]): string {\n let out = ''\n for (const block of blocks) {\n const decls = [...declLines(block.vars), ...declLines(block.styles)]\n if (!decls.length) continue\n out += `${selector} {\\n /* ${block.contract} */\\n${decls.join('\\n')}\\n}\\n`\n }\n return out\n}\n\n/**\n * The entries of `next` whose value differs from `prev`. Scheme blocks only\n * re-declare what actually changes against the base block - everything else\n * inherits, so an unchanged scheme adds no declarations at all.\n */\nfunction diffList<T extends VarList | StyleList>(prev: T, next: T): T {\n const out: Record<string, unknown> = {}\n for (const [k, v] of Object.entries(next)) {\n if (prev[k] !== v) out[k] = v\n }\n return out as T\n}\n\n/**\n * Generate a .d.ts that augments the global Ui0Theme* registries so the\n * editor can suggest what exists: Ui0ThemeNames (presets for ThemeProvider),\n * Ui0ThemeSchemeNames (appearances), Ui0ThemeColorNames (pool refs incl.\n * ramp steps, unioned across every emitted preset and scheme). Pass\n * withDefaults(config).\n *\n * @param config - a config already passed through {@link withDefaults}\n * @param emitPresets - which presets contribute names (see\n * {@link generateThemeArtifacts}); defaults to every preset of `config`\n */\nexport function generateThemeTypes(\n config: ThemePluginConfig,\n emitPresets?: ThemePresetName[]\n): string {\n const names = emitPresets ?? Object.keys(config.presets)\n const schemes = new Set<string>()\n const colors = new Set<string>()\n const cache: Record<ThemePresetName, ThemePreset> = {}\n\n for (const presetName of names) {\n const preset = resolvePreset(config.presets, presetName, cache)\n const appearances = schemesOf(preset)\n // scheme pools reference base aliases (brand-l3 etc.) - merge each\n // appearance over the base before resolving, like the orchestrator\n const base = appearances.default as Record<string, unknown>\n for (const [scheme, appearance] of Object.entries(appearances)) {\n if (scheme !== 'default') schemes.add(scheme)\n const merged = deepMerge(base, appearance as Record<string, unknown>) as Ui0ThemePresetAppearanceConfig\n const pool = merged.color\n if (!pool) continue\n const { base: poolBase, ramps } = resolvePool(buildPool(pool, undefined))\n for (const name of Object.keys(poolBase)) {\n colors.add(name)\n const ramp = ramps[name]\n if (!ramp) continue\n for (const [type, steps] of Object.entries(ramp)) {\n steps?.forEach((_, i) => colors.add(`${name}-${type}${i + 1}`))\n }\n }\n }\n }\n\n const registry = (name: string, keys: Iterable<string>) =>\n ` interface ${name} {\\n${[...keys]\n .sort()\n .map((k) => ` '${k}': true`)\n .join('\\n')}\\n }`\n\n return `// GENERATED by @ui0/theme — do not edit\ndeclare global {\n interface Ui0ThemeNames {\n${names.map((k) => ` '${k}': true`).join('\\n')}\n }\n${registry('Ui0ThemeSchemeNames', schemes)}\n${registry('Ui0ThemeColorNames', colors)}\n}\n\nexport {}\n`\n}\n"],"mappings":";;;AAQA,SAAgB,UAAU,QAAyC;CACjE,OAAO;AACT;;;;;;;;ACGA,SAAgB,kBAA0B;CACxC,OAAO;AACT;;AAGA,MAAa,kBAAkB;;;;;;;;;AAU/B,SAAgB,qBAAqB,KAAyC;CAC5E,IAAI,OAAO,aAAa,aAAa,OAAO;CAC5C,MAAM,SAAS,OAAO;CACtB,MAAM,WAAW,SAAS,gBAAgB;CAC1C,MAAM,WAAW,OAAO,KAAK,cAAgC,QAA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C,CAAC;GACpB,IAAI,CAAC,MAAM;GACX,MAAM,EAAE,MAAM,UAAU,UAAU,YAAY,UAAU,MAAM,KAAA,CAAS,CAAC;GACxE,KAAK,MAAM,QAAQ,OAAO,KAAK,QAAQ,GAAG;IACxC,OAAO,IAAI,IAAI;IACf,MAAM,OAAO,MAAM;IACnB,IAAI,CAAC,MAAM;IACX,KAAK,MAAM,CAAC,MAAM,UAAU,OAAO,QAAQ,IAAI,GAC7C,OAAO,SAAS,GAAG,MAAM,OAAO,IAAI,GAAG,KAAK,GAAG,OAAO,IAAI,GAAG,CAAC;GAElE;EACF;CACF;CAEA,MAAM,YAAY,MAAc,SAC9B,eAAe,KAAK,MAAM,CAAC,GAAG,IAAI,CAAC,CAChC,KAAK,CAAC,CACN,KAAK,MAAM,QAAQ,EAAE,QAAQ,CAAC,CAC9B,KAAK,IAAI,EAAE;CAEhB,OAAO;;;EAGP,MAAM,KAAK,MAAM,QAAQ,EAAE,QAAQ,CAAC,CAAC,KAAK,IAAI,EAAE;;EAEhD,SAAS,uBAAuB,OAAO,EAAE;EACzC,SAAS,sBAAsB,MAAM,EAAE;;;;;AAKzC"}
|
package/dist/generator/cli.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { i as withDefaults, n as generateThemeCss } from "../generate-
|
|
2
|
+
import { i as withDefaults, n as generateThemeCss } from "../generate-DjBK9MD8.mjs";
|
|
3
3
|
import { t as loadThemeConfig } from "../load-config-64q6nzFy.mjs";
|
|
4
4
|
import { existsSync, mkdirSync, watch, writeFileSync } from "node:fs";
|
|
5
5
|
import path from "node:path";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite.d.mts","names":[],"sources":["../../src/generator/vite.ts"],"mappings":";
|
|
1
|
+
{"version":3,"file":"vite.d.mts","names":[],"sources":["../../src/generator/vite.ts"],"mappings":";iBA6CiB;EAOf;EAOA;;;;;;;;;;;;;wBAcsB,SAAS,UAAS,kBAAuB"}
|
package/dist/generator/vite.mjs
CHANGED
|
@@ -1,9 +1,19 @@
|
|
|
1
|
-
import { i as withDefaults, r as generateThemeTypes, t as generateThemeArtifacts } from "../generate-
|
|
1
|
+
import { i as withDefaults, r as generateThemeTypes, t as generateThemeArtifacts } from "../generate-DjBK9MD8.mjs";
|
|
2
2
|
import { t as loadThemeConfig } from "../load-config-64q6nzFy.mjs";
|
|
3
3
|
import { existsSync, mkdirSync, writeFileSync } from "node:fs";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
// src/generator/vite.ts
|
|
6
6
|
const CONFIG_NAMES = ["ui0.config.ts", "ui0.theme.ts"];
|
|
7
|
+
function findConfigUp(start) {
|
|
8
|
+
let dir = start;
|
|
9
|
+
for (let i = 0; i < 4; i++) {
|
|
10
|
+
const hit = CONFIG_NAMES.map((n) => path.join(dir, n)).find((p) => existsSync(p));
|
|
11
|
+
if (hit) return hit;
|
|
12
|
+
const parent = path.dirname(dir);
|
|
13
|
+
if (parent === dir) break;
|
|
14
|
+
dir = parent;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
7
17
|
const CSS_MODULE_ID = "virtual:ui0-theme.css";
|
|
8
18
|
const JS_MODULE_ID = "virtual:ui0-theme";
|
|
9
19
|
const RESOLVED_CSS_MODULE_ID = "\0" + CSS_MODULE_ID;
|
|
@@ -64,8 +74,8 @@ function ui0Theme(options = {}) {
|
|
|
64
74
|
name: "ui0:theme",
|
|
65
75
|
configResolved(resolvedConfig) {
|
|
66
76
|
if (options.config) configPath = path.resolve(resolvedConfig.root, options.config);
|
|
67
|
-
else configPath =
|
|
68
|
-
outPath = options.out ? path.resolve(resolvedConfig.root, options.out) : "";
|
|
77
|
+
else configPath = findConfigUp(resolvedConfig.root) ?? "";
|
|
78
|
+
outPath = options.out ? path.resolve(configPath ? path.dirname(configPath) : resolvedConfig.root, options.out) : "";
|
|
69
79
|
},
|
|
70
80
|
async buildStart() {
|
|
71
81
|
await writeOut();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite.mjs","names":[],"sources":["../../src/generator/vite.ts"],"sourcesContent":["import { existsSync, mkdirSync, writeFileSync } from 'node:fs'\nimport path from 'node:path'\n\nimport type { StyleList, ThemePresetName } from '@ui0/types'\nimport type { Plugin, ResolvedConfig } from 'vite'\n\nimport { generateThemeArtifacts, generateThemeTypes, withDefaults } from './generate'\nimport { loadThemeConfig } from './load-config'\n\n// The Vite plugin - imported as the package's `/vite` entry:\n// import ui0Theme from 'ui0-theme/vite'\n\n// convention over configuration: the theme config lives at the project root\n// under one of these names (same as the CLI), default-exporting a ThemeConfig.\nconst CONFIG_NAMES = ['ui0.config.ts', 'ui0.theme.ts']\n\n// two consumption modes:\n// - `virtual:ui0-theme.css` -> plain CSS text. Vite's own CSS pipeline picks\n// this up (extracted to a real .css asset on build, injected + HMR'd as a\n// <style> tag in dev) exactly like any other .css import.\n// - `virtual:ui0-theme` -> a JS module that ships the CSS as a string\n// and injects it into <head> itself when the consumer calls it - useful\n// when the app needs to control WHEN the theme applies (e.g. after\n// reading a stored preference, before first paint) instead of letting\n// Vite's CSS asset pipeline decide.\nconst CSS_MODULE_ID = 'virtual:ui0-theme.css'\nconst JS_MODULE_ID = 'virtual:ui0-theme'\nconst RESOLVED_CSS_MODULE_ID = '\\0' + CSS_MODULE_ID\nconst RESOLVED_JS_MODULE_ID = '\\0' + JS_MODULE_ID\n\nexport interface Ui0ThemeOptions {\n // explicit path to the theme config (default-exporting a ThemeConfig).\n // Relative paths resolve against the Vite root. When omitted, the plugin\n // looks for ui0.config.ts / ui0-theme.config.ts in the root; when none is\n // found it emits just the built-in defaults.\n config?: string\n\n // output mode. Omitted (default): serve the CSS as the virtual module\n // `virtual:ui0-theme.css`. When set to a path (relative to the Vite root,\n // e.g. 'src/assets/theme.css'): write the generated CSS to that file instead\n // and keep it in sync on config changes - import it like any normal .css.\n out?: string\n}\n\n/**\n * The ui0 theme Vite plugin. Serves the generated theme CSS either as the\n * virtual module `virtual:ui0-theme.css` (through Vite's own CSS pipeline)\n * or as a plain-JS virtual module that injects the CSS on demand; with\n * `out` set, writes the CSS (+ a sibling .d.ts typing the theme names) to a\n * real file instead. The consumer's config is merged over the built-in\n * defaults; config edits invalidate the cache and reload.\n *\n * @param options - `config` (explicit config path) and/or `out` (file mode)\n * @returns the Vite plugin\n */\nexport default function ui0Theme(options: Ui0ThemeOptions = {}): Plugin {\n // '' means \"no consumer config\" -> emit the built-in defaults alone\n let configPath = ''\n let outPath = ''\n let cachedArtifacts: {\n css: string\n types: string\n localScss: Record<string, StyleList>\n } | null = null\n\n /** Generate (once, then cache) the theme css + the theme-names .d.ts. */\n async function generate(): Promise<{\n css: string\n types: string\n localScss: Record<string, StyleList>\n }> {\n if (cachedArtifacts !== null) return cachedArtifacts\n // the built-in defaults are always the baseline; a consumer config (if any)\n // is merged on top. No config at all -> the defaults theme by itself.\n const consumerConfig = configPath ? await loadThemeConfig(configPath) : undefined\n const themeConfig = withDefaults(consumerConfig)\n // a consumer with own presets gets exactly their blocks - the built-in\n // default stays in the config as the fallback layer but is not emitted\n const emitPresets = consumerConfig?.presets\n ? (Object.keys(consumerConfig.presets) as ThemePresetName[])\n : undefined\n const artifacts = generateThemeArtifacts(themeConfig, emitPresets)\n cachedArtifacts = {\n css: artifacts.themeCss,\n types: generateThemeTypes(themeConfig, emitPresets),\n localScss: artifacts.localScss\n }\n return cachedArtifacts\n }\n\n /** The generated theme css (cached). */\n async function getCss(): Promise<string> {\n return (await generate()).css\n }\n\n /**\n * File mode: write the generated CSS to `out` (+ a sibling .d.ts that types\n * the theme names for ThemeProvider), creating parent dirs. Contracts that\n * expose the optional localScss exit point (config-generated scss data like\n * the display breakpoints) get a `<contractname>.scss` next to it - the\n * scss counterpart of theme.css, one file per contract; contracts without\n * localScss generate no file.\n */\n async function writeOut(): Promise<void> {\n if (!outPath) return\n const { css, types, localScss } = await generate()\n mkdirSync(path.dirname(outPath), { recursive: true })\n writeFileSync(outPath, '/* generated by ui0-theme - do not edit by hand */\\n' + css)\n writeFileSync(outPath.replace(/\\.css$/, '') + '.d.ts', types)\n\n for (const [name, scssVars] of Object.entries(localScss)) {\n const body = Object.entries(scssVars)\n .map(([k, v]) => `${k}: ${v};`)\n .join('\\n')\n writeFileSync(\n path.join(path.dirname(outPath), `${name}.scss`),\n `/* generated by ui0-theme from the theme config - do not edit by hand */\\n${body}\\n`\n )\n }\n }\n\n return {\n name: 'ui0:theme',\n\n configResolved(resolvedConfig: ResolvedConfig) {\n if (options.config) {\n configPath = path.resolve(resolvedConfig.root, options.config)\n } else {\n configPath = CONFIG_NAMES.map((n) => path.join(resolvedConfig.root, n)).find((p) => existsSync(p)) ?? ''\n }\n outPath = options.out ? path.resolve(resolvedConfig.root, options.out) : ''\n },\n\n // in file mode, write the CSS before the build/dev server reads it\n async buildStart() {\n await writeOut()\n },\n\n resolveId(id) {\n if (id === CSS_MODULE_ID) return RESOLVED_CSS_MODULE_ID\n if (id === JS_MODULE_ID) return RESOLVED_JS_MODULE_ID\n return undefined\n },\n\n async load(id) {\n if (id === RESOLVED_CSS_MODULE_ID) {\n return getCss()\n }\n if (id === RESOLVED_JS_MODULE_ID) {\n const css = await getCss()\n return [\n `const css = ${JSON.stringify(css)}`,\n 'let styleEl',\n 'export function applyUi0Theme() {',\n ' if (styleEl) return styleEl',\n ' styleEl = document.createElement(\"style\")',\n ' styleEl.setAttribute(\"data-ui0-theme\", \"\")',\n ' styleEl.textContent = css',\n ' document.head.appendChild(styleEl)',\n ' return styleEl',\n '}',\n 'export default css'\n ].join('\\n')\n }\n return undefined\n },\n\n configureServer(server) {\n if (!configPath) return\n server.watcher.add(configPath)\n server.watcher.on('change', async (file) => {\n if (path.resolve(file) !== path.resolve(configPath)) return\n cachedArtifacts = null\n if (outPath) {\n // file mode: rewrite the .css; Vite's own watcher HMRs the file\n await writeOut()\n return\n }\n for (const id of [RESOLVED_CSS_MODULE_ID, RESOLVED_JS_MODULE_ID]) {\n const mod = server.moduleGraph.get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"version":3,"file":"vite.mjs","names":[],"sources":["../../src/generator/vite.ts"],"sourcesContent":["import { existsSync, mkdirSync, writeFileSync } from 'node:fs'\nimport path from 'node:path'\n\nimport type { StyleList, ThemePresetName } from '@ui0/types'\nimport type { Plugin, ResolvedConfig } from 'vite'\n\nimport { generateThemeArtifacts, generateThemeTypes, withDefaults } from './generate'\nimport { loadThemeConfig } from './load-config'\n\n// The Vite plugin - imported as the package's `/vite` entry:\n// import ui0Theme from 'ui0-theme/vite'\n\n// convention over configuration: the theme config lives at the project root\n// under one of these names (same as the CLI), default-exporting a ThemeConfig.\nconst CONFIG_NAMES = ['ui0.config.ts', 'ui0.theme.ts']\n\n// hosts like nuxt set the vite root to a subdir of the project (nuxt: <root>/app)\n// - the config convention is the PROJECT root, so walk up a few levels looking\n// for it; nearest hit wins\nfunction findConfigUp(start: string): string | undefined {\n let dir = start\n for (let i = 0; i < 4; i++) {\n const hit = CONFIG_NAMES.map((n) => path.join(dir, n)).find((p) => existsSync(p))\n if (hit) return hit\n const parent = path.dirname(dir)\n if (parent === dir) break\n dir = parent\n }\n return undefined\n}\n\n// two consumption modes:\n// - `virtual:ui0-theme.css` -> plain CSS text. Vite's own CSS pipeline picks\n// this up (extracted to a real .css asset on build, injected + HMR'd as a\n// <style> tag in dev) exactly like any other .css import.\n// - `virtual:ui0-theme` -> a JS module that ships the CSS as a string\n// and injects it into <head> itself when the consumer calls it - useful\n// when the app needs to control WHEN the theme applies (e.g. after\n// reading a stored preference, before first paint) instead of letting\n// Vite's CSS asset pipeline decide.\nconst CSS_MODULE_ID = 'virtual:ui0-theme.css'\nconst JS_MODULE_ID = 'virtual:ui0-theme'\nconst RESOLVED_CSS_MODULE_ID = '\\0' + CSS_MODULE_ID\nconst RESOLVED_JS_MODULE_ID = '\\0' + JS_MODULE_ID\n\nexport interface Ui0ThemeOptions {\n // explicit path to the theme config (default-exporting a ThemeConfig).\n // Relative paths resolve against the Vite root. When omitted, the plugin\n // looks for ui0.config.ts / ui0-theme.config.ts walking UP from the Vite\n // root (a few levels - hosts like nuxt root the vite config at <project>/app\n // while the config convention is the project root); when none is found it\n // emits just the built-in defaults.\n config?: string\n\n // output mode. Omitted (default): serve the CSS as the virtual module\n // `virtual:ui0-theme.css`. When set to a path (e.g. 'src/assets/theme.css'):\n // write the generated CSS to that file instead and keep it in sync on config\n // changes - import it like any normal .css. Relative paths resolve against\n // the theme config's directory (or the Vite root when no config is found).\n out?: string\n}\n\n/**\n * The ui0 theme Vite plugin. Serves the generated theme CSS either as the\n * virtual module `virtual:ui0-theme.css` (through Vite's own CSS pipeline)\n * or as a plain-JS virtual module that injects the CSS on demand; with\n * `out` set, writes the CSS (+ a sibling .d.ts typing the theme names) to a\n * real file instead. The consumer's config is merged over the built-in\n * defaults; config edits invalidate the cache and reload.\n *\n * @param options - `config` (explicit config path) and/or `out` (file mode)\n * @returns the Vite plugin\n */\nexport default function ui0Theme(options: Ui0ThemeOptions = {}): Plugin {\n // '' means \"no consumer config\" -> emit the built-in defaults alone\n let configPath = ''\n let outPath = ''\n let cachedArtifacts: {\n css: string\n types: string\n localScss: Record<string, StyleList>\n } | null = null\n\n /** Generate (once, then cache) the theme css + the theme-names .d.ts. */\n async function generate(): Promise<{\n css: string\n types: string\n localScss: Record<string, StyleList>\n }> {\n if (cachedArtifacts !== null) return cachedArtifacts\n // the built-in defaults are always the baseline; a consumer config (if any)\n // is merged on top. No config at all -> the defaults theme by itself.\n const consumerConfig = configPath ? await loadThemeConfig(configPath) : undefined\n\n const themeConfig = withDefaults(consumerConfig)\n // a consumer with own presets gets exactly their blocks - the built-in\n // default stays in the config as the fallback layer but is not emitted\n const emitPresets = consumerConfig?.presets\n ? (Object.keys(consumerConfig.presets) as ThemePresetName[])\n : undefined\n const artifacts = generateThemeArtifacts(themeConfig, emitPresets)\n cachedArtifacts = {\n css: artifacts.themeCss,\n types: generateThemeTypes(themeConfig, emitPresets),\n localScss: artifacts.localScss\n }\n return cachedArtifacts\n }\n\n /** The generated theme css (cached). */\n async function getCss(): Promise<string> {\n return (await generate()).css\n }\n\n /**\n * File mode: write the generated CSS to `out` (+ a sibling .d.ts that types\n * the theme names for ThemeProvider), creating parent dirs. Contracts that\n * expose the optional localScss exit point (config-generated scss data like\n * the display breakpoints) get a `<contractname>.scss` next to it - the\n * scss counterpart of theme.css, one file per contract; contracts without\n * localScss generate no file.\n */\n async function writeOut(): Promise<void> {\n if (!outPath) return\n const { css, types, localScss } = await generate()\n mkdirSync(path.dirname(outPath), { recursive: true })\n writeFileSync(outPath, '/* generated by ui0-theme - do not edit by hand */\\n' + css)\n writeFileSync(outPath.replace(/\\.css$/, '') + '.d.ts', types)\n\n for (const [name, scssVars] of Object.entries(localScss)) {\n const body = Object.entries(scssVars)\n .map(([k, v]) => `${k}: ${v};`)\n .join('\\n')\n writeFileSync(\n path.join(path.dirname(outPath), `${name}.scss`),\n `/* generated by ui0-theme from the theme config - do not edit by hand */\\n${body}\\n`\n )\n }\n }\n\n return {\n name: 'ui0:theme',\n\n configResolved(resolvedConfig: ResolvedConfig) {\n if (options.config) {\n configPath = path.resolve(resolvedConfig.root, options.config)\n } else {\n configPath = findConfigUp(resolvedConfig.root) ?? ''\n }\n // out paths name project-level artifacts - anchor them at the config's\n // directory (the project root by convention), not at the vite root,\n // which hosts like nuxt point at a subdir (app/)\n outPath = options.out ? path.resolve(configPath ? path.dirname(configPath) : resolvedConfig.root, options.out) : ''\n },\n\n // in file mode, write the CSS before the build/dev server reads it\n async buildStart() {\n await writeOut()\n },\n\n resolveId(id) {\n if (id === CSS_MODULE_ID) return RESOLVED_CSS_MODULE_ID\n if (id === JS_MODULE_ID) return RESOLVED_JS_MODULE_ID\n return undefined\n },\n\n async load(id) {\n if (id === RESOLVED_CSS_MODULE_ID) {\n return getCss()\n }\n if (id === RESOLVED_JS_MODULE_ID) {\n const css = await getCss()\n return [\n `const css = ${JSON.stringify(css)}`,\n 'let styleEl',\n 'export function applyUi0Theme() {',\n ' if (styleEl) return styleEl',\n ' styleEl = document.createElement(\"style\")',\n ' styleEl.setAttribute(\"data-ui0-theme\", \"\")',\n ' styleEl.textContent = css',\n ' document.head.appendChild(styleEl)',\n ' return styleEl',\n '}',\n 'export default css'\n ].join('\\n')\n }\n return undefined\n },\n\n configureServer(server) {\n if (!configPath) return\n server.watcher.add(configPath)\n server.watcher.on('change', async (file) => {\n if (path.resolve(file) !== path.resolve(configPath)) return\n cachedArtifacts = null\n if (outPath) {\n // file mode: rewrite the .css; Vite's own watcher HMRs the file\n await writeOut()\n return\n }\n for (const id of [RESOLVED_CSS_MODULE_ID, RESOLVED_JS_MODULE_ID]) {\n const mod = server.moduleGraph.getModuleById(id)\n if (mod) server.moduleGraph.invalidateModule(mod)\n }\n server.ws.send({ type: 'full-reload' })\n })\n }\n }\n}\n"],"mappings":";;;;;AAcA,MAAM,eAAe,CAAC,iBAAiB,cAAc;AAKrD,SAAS,aAAa,OAAmC;CACvD,IAAI,MAAM;CACV,KAAK,IAAI,IAAI,GAAG,IAAI,GAAG,KAAK;EAC1B,MAAM,MAAM,aAAa,KAAK,MAAM,KAAK,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,MAAM,WAAW,CAAC,CAAC;EAChF,IAAI,KAAK,OAAO;EAChB,MAAM,SAAS,KAAK,QAAQ,GAAG;EAC/B,IAAI,WAAW,KAAK;EACpB,MAAM;CACR;AAEF;AAWA,MAAM,gBAAgB;AACtB,MAAM,eAAe;AACrB,MAAM,yBAAyB,OAAO;AACtC,MAAM,wBAAwB,OAAO;;;;;;;;;;;;AA8BrC,SAAwB,SAAS,UAA2B,CAAC,GAAW;CAEtE,IAAI,aAAa;CACjB,IAAI,UAAU;CACd,IAAI,kBAIO;;CAGX,eAAe,WAIZ;EACD,IAAI,oBAAoB,MAAM,OAAO;EAGrC,MAAM,iBAAiB,aAAa,MAAM,gBAAgB,UAAU,IAAI,KAAA;EAExE,MAAM,cAAc,aAAa,cAAc;EAG/C,MAAM,cAAc,gBAAgB,UAC/B,OAAO,KAA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AAI,OAAO,uBAAuB;IAChC,MAAM,MAAM,MAAM,OAAO;IACzB,OAAO;KACL,eAAe,KAAK,UAAU,GAAG;KACjC;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACA;IACF,CAAC,CAAC,KAAK,IAAI;GACb;EAEF;EAEA,gBAAgB,QAAQ;GACtB,IAAI,CAAC,YAAY;GACjB,OAAO,QAAQ,IAAI,UAAU;GAC7B,OAAO,QAAQ,GAAG,UAAU,OAAO,SAAS;IAC1C,IAAI,KAAK,QAAQ,IAAI,MAAM,KAAK,QAAQ,UAAU,GAAG;IACrD,kBAAkB;IAClB,IAAI,SAAS;KAEX,MAAM,SAAS;KACf;IACF;IACA,KAAK,MAAM,MAAM,CAAC,wBAAwB,qBAAqB,GAAG;KAChE,MAAM,MAAM,OAAO,YAAY,cAAc,EAAE;KAC/C,IAAI,KAAK,OAAO,YAAY,iBAAiB,GAAG;IAClD;IACA,OAAO,GAAG,KAAK,EAAE,MAAM,cAAc,CAAC;GACxC,CAAC;EACH;CACF;AACF"}
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":["_0","_0","_0","_0","_0","_0","ThemePluginConfig","ThemePresetName","ThemePluginConfig","ThemePluginConfig","ThemeInstanceOptions","ThemeInstance","ThemeInstance","ThemeContractName","Ui0ThemeContracts","Ui0ThemeContracts","ThemeInstance","ThemePresetName","Ui0ThemePresetAppearanceConfig","ThemeContractGenerator","ThemeContractName","_$__round0.RoundProps"],"sources":["../src/contracts/backdrop/backdrop.types.ts","../src/contracts/color/color.types.ts","../src/contracts/disabled/disabled.types.ts","../src/contracts/elevation/elevation.types.ts","../src/contracts/round/round.types.ts","../src/contracts/size/size.types.ts","../src/generator/generate.ts","../src/plugin.ts","../src/instance.ts","../src/useTheme.ts","../src/contracts/display/display.types.ts","../src/useDisplay.ts","../src/contracts/contract.ts","../src/useThemeContext.ts","../src/contracts/generator.ts","../src/generator.ts","../src/contracts/round/round.keys.ts","../src/contracts/round/index.ts","../src/contracts/backdrop/backdrop.keys.ts","../src/contracts/backdrop/index.ts","../src/contracts/color/color.keys.ts","../src/contracts/color/index.ts","../src/contracts/disabled/disabled.keys.ts","../src/contracts/disabled/index.ts","../src/contracts/elevation/elevation.keys.ts","../src/contracts/elevation/index.ts","../src/contracts/size/size.keys.ts","../src/contracts/size/size.generator.ts","../src/contracts/size/index.ts","../src/contracts/index.ts"],"mappings":";;;;KAGY;UAYK;EACf,WAAW,sBAAsB,oBAAoB;;;UAItC;EACf,OAAO;EACP,aAAa;EACb,WAAW;EACX;EACA,YAAY;EACZ,eAAe;EACf,SAAS;EACT,UAAU;EACV,WAAW;EACX,QAAQ;;;YAME;IACR,WAAW;;YAEH,0BAA0B;YAC1B;;IAER,mBAAmB,QAAQ,OAAO;;;;UCvCrB;EACf,QAAQ;;;UAIO;EACf,OAAO;;;;;UAMQ;EACf,WAAW;;;UAII;EACf,QAAQ;;KAGE;KACA,iBAAiB,OAAO,gBAAgB;;;KAIxC,6BAA6B;;KAG7B;;KAEA;UAEK;EACf,QAAQ;EACR,QAAQ;;KAKE,gCAAgC,mBAAmB;KAGnD;KAEA,kBACR,iBAGC,gBAAgB,8BAA8B,uBAAuB;;KAK9D;KACA;UAEK;EACf,SAAS;EACT,SAAS;;EAET;;EAEA;;;YAMU;IACR,QAAQ;;YAEA;;;IAGR,kBAAkB;;YAEV,0BAA0B,YAAY,WAAW;;UChF5C;EACf;;UAGe;EACf;;;YAMU;IACR,WAAW;;YAEH;IACR;;YAEQ,0BAA0B;;UCfrB;EACf,YAAY;;UAGG;EACf;;;YAMU;IACR,YAAY;;YAEJ;IACR;;YAEQ,0BAA0B;;UCjBrB;EACf,QAAQ;EACR,cAAc;;UAGC;EACf;;;YAMU;IACR,QAAQ;;YAEA;IACR;MACE;;;YAGM,0BAA0B;;KAE1B,cACR;KAkBQ,QAAQ,aAAa;KCrCrB;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KACA;KAEA,OACR,WACA,UACA,SACA,QACA,QACA,QACA,SACA,UACA,6CAIA;KAEQ,cAAc;UAET;EACf,OAAO;;UAGQ;EACf,UAAU;;;UAIK;;EAEf,UAAU;;EAEV,QAAQ;;;cAIG,oBAAoB;;YAKrB;IACR,OAAO;;YAEC;IACR;;YAEQ,0BAA0B,WAAW;;;;;;;;;;wBCxBjC,aACd,SAAQM,sBAKPA;;;;;;;UAkCc;EACf;EACA,aAAa;;EAEb,WAAW;;;;;;;;;;;;;;;wBAgBG,uBACd,QAAQA,qBACR,cAAcC,sBACb;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":["_0","_0","_0","_0","_0","_0","ThemePluginConfig","ThemePresetName","ThemePluginConfig","ThemePluginConfig","ThemeInstanceOptions","ThemeInstance","ThemeInstance","ThemeContractName","Ui0ThemeContracts","Ui0ThemeContracts","ThemeInstance","ThemePresetName","Ui0ThemePresetAppearanceConfig","ThemeContractGenerator","ThemeContractName","_$__round0.RoundProps"],"sources":["../src/contracts/backdrop/backdrop.types.ts","../src/contracts/color/color.types.ts","../src/contracts/disabled/disabled.types.ts","../src/contracts/elevation/elevation.types.ts","../src/contracts/round/round.types.ts","../src/contracts/size/size.types.ts","../src/generator/generate.ts","../src/plugin.ts","../src/instance.ts","../src/useTheme.ts","../src/contracts/display/display.types.ts","../src/useDisplay.ts","../src/contracts/contract.ts","../src/useThemeContext.ts","../src/contracts/generator.ts","../src/generator.ts","../src/contracts/round/round.keys.ts","../src/contracts/round/index.ts","../src/contracts/backdrop/backdrop.keys.ts","../src/contracts/backdrop/index.ts","../src/contracts/color/color.keys.ts","../src/contracts/color/index.ts","../src/contracts/disabled/disabled.keys.ts","../src/contracts/disabled/index.ts","../src/contracts/elevation/elevation.keys.ts","../src/contracts/elevation/index.ts","../src/contracts/size/size.keys.ts","../src/contracts/size/size.generator.ts","../src/contracts/size/index.ts","../src/contracts/index.ts"],"mappings":";;;;KAGY;UAYK;EACf,WAAW,sBAAsB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a;cCKpE,mBAAmB,oBAAoB;cAEvC,UAAU;cCTV,kBAAiD,aAAa;cAC9D,aAAuC,aAAa,IAAI;cACxD,YAAqC,aAAa,IAAI;cCKtD,gBAAgB,qBAAqB,gBAAgB,aAAa;cAMlE,OAAO;cCdP,gBAA6C,aAAa;cAE1D,qBAAuD,aAAa;cCMpE,mBAAmB,oBAAoB;cAEvC,UAAU;cCTV,iBAA+C,aAAa,IAAI;cAChE,sBAAyD,aAAa;cCKtE,oBAAoB,oBAAoB;cAExC,WAAW;cCPX,YAAqC,aAAa,IAAI;cACtD,mBAA+C,aAAa,IAAI;cAChE,iBAA+C,aAAa;cCYnE,eAAe;cCPR,eAAe,qBAAqB,YAAY;cAEhD,MAAM;cCIN,WAAW,OAAOC,qBAAmB;cAWrC,+FAAAC"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { _ as buildPool, a as deepMerge, b as ensureThemeBaseStyle, c as contractGenerators, d as round_module_css_default, f as elevation_module_css_default, g as parseRef, h as parseColorProp, i as withDefaults, l as typography_module_css_default, m as color_module_css_default, n as generateThemeCss, o as resolvePreset, p as disabled_module_css_default, r as generateThemeTypes, s as hashClassName, t as generateThemeArtifacts, u as size_module_css_default, v as resolvePool, x as schemesOf, y as backdrop_module_css_default } from "./generate-DjBK9MD8.mjs";
|
|
2
2
|
import config from "./config.default.mjs";
|
|
3
3
|
import { RecordContainer, arrayPickNext, arrayPickPrev, getClientHeight, getClientWidth, isArray, isBrowser, isString, mergeCssModulesStyles, newFrameworkError, objectMerge, parseUnits, propsToCssModuleClassNext, toCamelCase } from "@ui0/util";
|
|
4
4
|
import { AT_SIGN } from "@ui0/shared";
|
|
@@ -216,22 +216,11 @@ const disabled = {
|
|
|
216
216
|
props: DisabledPropsKeys
|
|
217
217
|
};
|
|
218
218
|
// src/contracts/display/display.contract.ts
|
|
219
|
-
function displayClasses(props, styles) {
|
|
220
|
-
const $ = mergeCssModulesStyles(display_module_css_default, styles);
|
|
221
|
-
const out = [];
|
|
222
|
-
if (props.display && $.displayed) out.push($.displayed);
|
|
223
|
-
return out;
|
|
224
|
-
}
|
|
225
219
|
function displayDeal(instance) {
|
|
226
|
-
|
|
220
|
+
instance.props;
|
|
227
221
|
return {
|
|
228
222
|
classes: () => {
|
|
229
|
-
|
|
230
|
-
if (props.display === "inherit") {
|
|
231
|
-
const ctx = instance.context;
|
|
232
|
-
if (ctx?.display) return instance.inject(displayClasses({ display: ctx.display.value }, instance.$styles));
|
|
233
|
-
}
|
|
234
|
-
return instance.inject(displayClasses(props, instance.$styles));
|
|
223
|
+
return [];
|
|
235
224
|
},
|
|
236
225
|
styles: () => instance.inject(EMPTY_OBJ)
|
|
237
226
|
};
|
|
@@ -709,14 +698,17 @@ const Ui0ThemeKey = Symbol("ui0-theme");
|
|
|
709
698
|
function createUi0Theme(config) {
|
|
710
699
|
return { install(instance) {
|
|
711
700
|
const theme = createThemeInstance(config);
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
instance.vue
|
|
719
|
-
|
|
701
|
+
if (theme) {
|
|
702
|
+
Object.keys(contracts).forEach((c) => {
|
|
703
|
+
theme.addContract(contracts[c]);
|
|
704
|
+
});
|
|
705
|
+
const display = new Display(config.contracts.display);
|
|
706
|
+
if (typeof document !== "undefined") ensureThemeBaseStyle(document);
|
|
707
|
+
if (instance.vue) {
|
|
708
|
+
instance.vue.provide(Ui0ThemeKey, theme);
|
|
709
|
+
if (display) instance.vue.provide(DisplayKey, display);
|
|
710
|
+
}
|
|
711
|
+
instance.theme = theme;
|
|
720
712
|
}
|
|
721
713
|
return theme;
|
|
722
714
|
} };
|
|
@@ -736,7 +728,6 @@ function useDisplay(onUpdate) {
|
|
|
736
728
|
if (hasInjectionContext()) {
|
|
737
729
|
const display = inject(DisplayKey);
|
|
738
730
|
if (display) {
|
|
739
|
-
console.log("if display", display);
|
|
740
731
|
if (onUpdate) onMounted(() => {
|
|
741
732
|
const id = display.addUpdateListener(onUpdate);
|
|
742
733
|
onUnmounted(() => {
|
|
@@ -775,7 +766,9 @@ var ThemeContractInstance = class {
|
|
|
775
766
|
const instance = this;
|
|
776
767
|
for (const contract of Object.values(this.contracts)) {
|
|
777
768
|
if (isArray(name)) name.forEach((n) => {
|
|
778
|
-
if (contract.props?.includes(n))
|
|
769
|
+
if (contract.props?.includes(n)) {
|
|
770
|
+
if (contract.flag & 2) jobs[contract.name] = contract.deal;
|
|
771
|
+
}
|
|
779
772
|
});
|
|
780
773
|
else if (isString(name)) {
|
|
781
774
|
if (contract.props?.includes(name)) jobs[contract.name] = contract;
|