@varo-ui/theme 1.1.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../src/theme.ts","../src/provider.ts"],"sourcesContent":["import type {\n ComponentTokens,\n SemanticTokens,\n ThemeDefinition,\n ThemeOverrides,\n ThemePalette,\n ThemeSeed\n} from './types'\n\nexport function createPalette(seed: ThemeSeed): ThemePalette {\n return {\n primary: {\n '50': '#eff6ff',\n '500': seed.primary,\n '600': seed.primary\n },\n neutral: {\n '0': '#ffffff',\n '50': '#f8fafc',\n '200': '#e2e8f0',\n '500': '#64748b',\n '900': '#0f172a',\n '1000': seed.neutral\n },\n success: {\n '500': seed.success\n },\n warning: {\n '500': seed.warning\n },\n error: {\n '500': seed.error\n }\n }\n}\n\nexport function createSemanticTokens(palette: ThemePalette): SemanticTokens {\n return {\n textBase: palette.neutral['1000'],\n textMuted: palette.neutral['500'],\n surfaceBase: palette.neutral['0'],\n surfaceElevated: palette.neutral['50'],\n borderBase: palette.neutral['200'],\n borderStrong: palette.neutral['900'],\n primaryBase: palette.primary['500'],\n primaryHover: palette.primary['600'],\n dangerBase: palette.error['500']\n }\n}\n\nexport function createComponentTokens(semantic: SemanticTokens): ComponentTokens {\n return {\n button: {\n borderRadius: '12px',\n heightSm: '32px',\n heightMd: '40px',\n heightLg: '48px'\n },\n dialog: {\n borderRadius: '16px',\n overlayColor: semantic.borderStrong\n },\n input: {\n borderRadius: '12px',\n heightSm: '32px',\n heightMd: '40px',\n heightLg: '48px'\n }\n }\n}\n\nexport function createTheme(seed: ThemeSeed): ThemeDefinition {\n const palette = createPalette(seed)\n const semantic = createSemanticTokens(palette)\n const components = createComponentTokens(semantic)\n\n return {\n seed,\n palette,\n semantic,\n components\n }\n}\n\nexport function mergeThemeOverrides(theme: ThemeDefinition, overrides: ThemeOverrides = {}): ThemeDefinition {\n return {\n ...theme,\n semantic: {\n ...theme.semantic,\n ...overrides.semantic\n },\n components: {\n button: {\n ...theme.components.button,\n ...overrides.components?.button\n },\n dialog: {\n ...theme.components.dialog,\n ...overrides.components?.dialog\n },\n input: {\n ...theme.components.input,\n ...overrides.components?.input\n }\n }\n }\n}\n","import type { App, InjectionKey, Plugin } from 'vue'\nimport type { ThemeDefinition } from './types'\nimport type { ThemeConfig } from './types-runtime'\nimport { computed, inject, provide } from 'vue'\nimport { createTheme } from './theme'\n\nconst ThemeKey: InjectionKey<ThemeConfig> = Symbol('varo-theme')\n\nexport function provideVaroTheme(config: ThemeConfig) {\n provide(ThemeKey, config)\n}\n\nexport function useVaroTheme() {\n const config = inject(ThemeKey, undefined)\n\n if (!config) {\n return computed<ThemeDefinition>(() =>\n createTheme({\n primary: '#2563eb',\n success: '#16a34a',\n warning: '#d97706',\n error: '#dc2626',\n neutral: '#0f172a',\n }),\n )\n }\n\n return computed(() => config.theme)\n}\n\nexport const VaroConfigProvider = {\n install(app: App, config?: ThemeConfig) {\n if (!config) { throw new Error('VaroConfigProvider requires a theme configuration.') }\n app.provide(ThemeKey, config)\n },\n} satisfies Plugin\n"],"mappings":";;AASA,SAAgB,cAAc,MAA+B;CAC3D,OAAO;EACL,SAAS;GACP,MAAM;GACN,OAAO,KAAK;GACZ,OAAO,KAAK;EACd;EACA,SAAS;GACP,KAAK;GACL,MAAM;GACN,OAAO;GACP,OAAO;GACP,OAAO;GACP,QAAQ,KAAK;EACf;EACA,SAAS,EACP,OAAO,KAAK,QACd;EACA,SAAS,EACP,OAAO,KAAK,QACd;EACA,OAAO,EACL,OAAO,KAAK,MACd;CACF;AACF;AAEA,SAAgB,qBAAqB,SAAuC;CAC1E,OAAO;EACL,UAAU,QAAQ,QAAQ;EAC1B,WAAW,QAAQ,QAAQ;EAC3B,aAAa,QAAQ,QAAQ;EAC7B,iBAAiB,QAAQ,QAAQ;EACjC,YAAY,QAAQ,QAAQ;EAC5B,cAAc,QAAQ,QAAQ;EAC9B,aAA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AAM;AAC9B,EACF"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../src/provider.ts"],"sourcesContent":["import type {\n App,\n ComputedRef,\n InjectionKey,\n Plugin,\n PropType,\n} from 'vue'\nimport type { ThemeCssVariables } from './css'\nimport type { ThemeDefinition, ThemeOverrides } from './types'\nimport type { ThemeConfig } from './types-runtime'\nimport { computed, defineComponent, h, inject, provide, toValue, watchEffect } from 'vue'\nimport { createThemeCssVariables } from './css'\nimport { createTheme, mergeThemeOverrides } from './theme'\n\nconst ThemeKey: InjectionKey<ComputedRef<ThemeDefinition>> = Symbol('varo-theme')\nconst fallbackTheme = createTheme({\n primary: '#07c160',\n success: '#13b248',\n warning: '#fa9200',\n error: '#eb3437',\n neutral: '#303133',\n info: '#73767a',\n})\n\ninterface InlineStyleSnapshot {\n priority: string\n value: string\n}\n\ninterface ThemeLayer {\n owner: symbol\n variables: ThemeCssVariables\n}\n\ninterface ThemeTargetState {\n base: Map<string, InlineStyleSnapshot>\n layers: ThemeLayer[]\n}\n\nconst targetStates = new WeakMap<HTMLElement, ThemeTargetState>()\n\nfunction resolveTheme(config: ThemeConfig): ThemeDefinition {\n return mergeThemeOverrides(toValue(config.theme), toValue(config.overrides) ?? {})\n}\n\nfunction applyTargetState(target: HTMLElement, state: ThemeTargetState): void {\n const activeLayer = state.layers[state.layers.length - 1]\n const activeVariables = activeLayer?.variables as unknown as Record<string, string> | undefined\n for (const [name, snapshot] of state.base) {\n const value = activeVariables?.[name]\n if (value !== undefined) {\n target.style.setProperty(name, value)\n }\n else if (snapshot.value) {\n target.style.setProperty(name, snapshot.value, snapshot.priority)\n }\n else {\n target.style.removeProperty(name)\n }\n }\n}\n\nfunction bindThemeVariables(\n target: HTMLElement,\n theme: ComputedRef<ThemeDefinition>,\n): () => void {\n let state = targetStates.get(target)\n if (!state) {\n state = { base: new Map(), layers: [] }\n targetStates.set(target, state)\n }\n\n const owner = Symbol('varo-theme-owner')\n const layer: ThemeLayer = {\n owner,\n variables: createThemeCssVariables(theme.value),\n }\n state.layers.push(layer)\n\n const stop = watchEffect(() => {\n const variables = createThemeCssVariables(theme.value)\n for (const name of Object.keys(variables)) {\n if (!state!.base.has(name)) {\n state!.base.set(name, {\n priority: target.style.getPropertyPriority(name),\n value: target.style.getPropertyValue(name),\n })\n }\n }\n layer.variables = variables\n if (state!.layers[state!.layers.length - 1]?.owner === owner) {\n applyTargetState(target, state!)\n }\n })\n\n return () => {\n stop()\n const index = state!.layers.findIndex(candidate => candidate.owner === owner)\n if (index < 0) {\n return\n }\n const wasActive = index === state!.layers.length - 1\n state!.layers.splice(index, 1)\n if (wasActive) {\n applyTargetState(target, state!)\n }\n if (state!.layers.length === 0) {\n targetStates.delete(target)\n }\n }\n}\n\nexport function provideVaroTheme(config: ThemeConfig): void {\n provide(ThemeKey, computed(() => resolveTheme(config)))\n}\n\nexport function useVaroTheme(): ComputedRef<ThemeDefinition> {\n return inject(ThemeKey, computed(() => fallbackTheme))\n}\n\nexport const VaroThemeProvider = defineComponent({\n name: 'VaroThemeProvider',\n inheritAttrs: false,\n props: {\n theme: {\n type: Object as PropType<ThemeDefinition>,\n required: true,\n },\n overrides: {\n type: Object as PropType<ThemeOverrides>,\n default: undefined,\n },\n },\n setup(props, { attrs, slots }) {\n const theme = computed(() =>\n mergeThemeOverrides(props.theme, props.overrides ?? {}),\n )\n const styles = computed(() => createThemeCssVariables(theme.value))\n provide(ThemeKey, theme)\n\n return () =>\n h(\n 'div',\n {\n ...attrs,\n style: [styles.value, attrs.style],\n },\n slots.default?.(),\n )\n },\n})\n\nexport const VaroConfigProvider = {\n install(app: App, config?: ThemeConfig) {\n if (!config) {\n throw new Error('VaroConfigProvider requires a theme configuration.')\n }\n\n const theme = computed(() => resolveTheme(config))\n app.provide(ThemeKey, theme)\n if (typeof document === 'undefined') {\n return\n }\n\n const release = bindThemeVariables(config.target ?? document.documentElement, theme)\n app.onUnmount(release)\n },\n} satisfies Plugin\n"],"mappings":";;;AAcA,MAAM,WAAuD,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AAU,SAAS,iBAAiB,KAAK;CACnF,IAAI,UAAU,OAAO;AACvB,EACF"}
@@ -0,0 +1,11 @@
1
+ import { c as ThemeDefinition, d as ThemeSeed, l as ThemeOverrides, o as ComponentTokens, s as SemanticTokens, u as ThemePalette } from "./css-D2jQSprg.mjs";
2
+
3
+ //#region src/theme.d.ts
4
+ declare function createPalette(seed: ThemeSeed): ThemePalette;
5
+ declare function createSemanticTokens(palette: ThemePalette): SemanticTokens;
6
+ declare function createComponentTokens(semantic: SemanticTokens): ComponentTokens;
7
+ declare function createTheme(seed: ThemeSeed): ThemeDefinition;
8
+ declare function mergeThemeOverrides(theme: ThemeDefinition, overrides?: ThemeOverrides): ThemeDefinition;
9
+ //#endregion
10
+ export { mergeThemeOverrides as a, createTheme as i, createPalette as n, createSemanticTokens as r, createComponentTokens as t };
11
+ //# sourceMappingURL=theme-B7G19AEI.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"theme-B7G19AEI.d.mts","names":[],"sources":["../src/theme.ts"],"mappings":";;;iBA6EgB,aAAA,CAAc,IAAA,EAAM,SAAA,GAAY,YAAY;AAAA,iBAkF5C,oBAAA,CAAqB,OAAA,EAAS,YAAA,GAAe,cAAc;AAAA,iBAwC3D,qBAAA,CAAsB,QAAA,EAAU,cAAA,GAAiB,eAAe;AAAA,iBAqBhE,WAAA,CAAY,IAAA,EAAM,SAAA,GAAY,eAAe;AAAA,iBAa7C,mBAAA,CAAoB,KAAA,EAAO,eAAA,EAAiB,SAAA,GAAW,cAAA,GAAsB,eAAA"}
@@ -0,0 +1,371 @@
1
+ //#region src/css.ts
2
+ function colorWithAlpha(color, alpha) {
3
+ const value = color.slice(1);
4
+ const normalized = value.length === 3 ? value.split("").map((part) => `${part}${part}`).join("") : value;
5
+ if (!color.startsWith("#") || !/^[\da-f]{6}$/i.test(normalized)) return color;
6
+ return `rgb(${Number.parseInt(normalized.slice(0, 2), 16)} ${Number.parseInt(normalized.slice(2, 4), 16)} ${Number.parseInt(normalized.slice(4, 6), 16)} / ${alpha}%)`;
7
+ }
8
+ function semanticTextColor(base, text) {
9
+ if (!/^#[\da-f]{6}$/i.test(base) || !/^#[\da-f]{6}$/i.test(text)) return text;
10
+ return `#${[
11
+ 1,
12
+ 3,
13
+ 5
14
+ ].map((offset) => {
15
+ const baseChannel = Number.parseInt(base.slice(offset, offset + 2), 16);
16
+ const textChannel = Number.parseInt(text.slice(offset, offset + 2), 16);
17
+ return Math.round((baseChannel + textChannel) / 2).toString(16).padStart(2, "0");
18
+ }).join("")}`;
19
+ }
20
+ function relativeLuminance(color) {
21
+ const value = color.slice(1);
22
+ const normalized = value.length === 3 ? value.split("").map((part) => `${part}${part}`).join("") : value;
23
+ if (!color.startsWith("#") || !/^[\da-f]{6}$/i.test(normalized)) return;
24
+ const channelLuminance = (offset) => {
25
+ const channel = Number.parseInt(normalized.slice(offset, offset + 2), 16) / 255;
26
+ return channel <= .04045 ? channel / 12.92 : ((channel + .055) / 1.055) ** 2.4;
27
+ };
28
+ return channelLuminance(0) * .2126 + channelLuminance(2) * .7152 + channelLuminance(4) * .0722;
29
+ }
30
+ function contrastSafeForeground(background) {
31
+ const backgroundLuminance = relativeLuminance(background);
32
+ if (backgroundLuminance == null) throw new Error(`Contrast-safe foreground requires a hex color (#RGB or #RRGGBB): ${background}`);
33
+ return (backgroundLuminance + .05) / .05 >= 1.05 / (backgroundLuminance + .05) ? "#000000" : "#ffffff";
34
+ }
35
+ function createThemeCssVariables(theme, overrides = {}) {
36
+ return {
37
+ "--varo-ui-white": theme.palette.neutral.white,
38
+ "--varo-ui-black": theme.palette.neutral.black,
39
+ "--varo-ui-bg": theme.semantic.surfaceElevated,
40
+ "--varo-ui-surface": theme.semantic.surfaceBase,
41
+ "--varo-ui-surface-muted": theme.semantic.fillLight,
42
+ "--varo-ui-surface-overlay": theme.semantic.surfaceOverlay,
43
+ "--varo-ui-text": theme.semantic.textBase,
44
+ "--varo-ui-text-regular": theme.semantic.textRegular,
45
+ "--varo-ui-text-muted": theme.semantic.textMuted,
46
+ "--varo-ui-text-placeholder": theme.semantic.textPlaceholder,
47
+ "--varo-ui-text-disabled": theme.semantic.textDisabled,
48
+ "--varo-ui-border": theme.semantic.borderBase,
49
+ "--varo-ui-border-strong": theme.semantic.borderStrong,
50
+ "--varo-ui-border-dark": theme.palette.neutral["border-dark"],
51
+ "--varo-ui-border-light": theme.semantic.borderLight,
52
+ "--varo-ui-border-lighter": theme.semantic.borderLighter,
53
+ "--varo-ui-border-extra-light": theme.palette.neutral["border-extra-light"],
54
+ "--varo-ui-fill": theme.semantic.fillBase,
55
+ "--varo-ui-fill-darker": theme.palette.neutral["fill-darker"],
56
+ "--varo-ui-fill-dark": theme.palette.neutral["fill-dark"],
57
+ "--varo-ui-fill-light": theme.semantic.fillLight,
58
+ "--varo-ui-fill-lighter": theme.semantic.fillLighter,
59
+ "--varo-ui-fill-extra-light": theme.palette.neutral["fill-extra-light"],
60
+ "--varo-ui-primary": theme.semantic.primaryBase,
61
+ "--varo-ui-primary-dark": theme.semantic.primaryDark,
62
+ "--varo-ui-primary-hover": theme.semantic.primaryHover,
63
+ "--varo-ui-primary-soft": theme.semantic.primarySoft,
64
+ "--varo-ui-primary-foreground": contrastSafeForeground(theme.semantic.primaryBase),
65
+ "--varo-ui-primary-hover-foreground": contrastSafeForeground(theme.semantic.primaryHover),
66
+ "--varo-ui-primary-text": semanticTextColor(theme.semantic.primaryBase, theme.semantic.textBase),
67
+ "--varo-ui-success": theme.semantic.successBase,
68
+ "--varo-ui-success-dark": theme.semantic.successDark,
69
+ "--varo-ui-success-hover": theme.semantic.successHover,
70
+ "--varo-ui-success-soft": theme.semantic.successSoft,
71
+ "--varo-ui-success-foreground": contrastSafeForeground(theme.semantic.successBase),
72
+ "--varo-ui-success-hover-foreground": contrastSafeForeground(theme.semantic.successHover),
73
+ "--varo-ui-success-text": semanticTextColor(theme.semantic.successBase, theme.semantic.textBase),
74
+ "--varo-ui-warning": theme.semantic.warningBase,
75
+ "--varo-ui-warning-dark": theme.semantic.warningDark,
76
+ "--varo-ui-warning-hover": theme.semantic.warningHover,
77
+ "--varo-ui-warning-soft": theme.semantic.warningSoft,
78
+ "--varo-ui-warning-foreground": contrastSafeForeground(theme.semantic.warningBase),
79
+ "--varo-ui-warning-hover-foreground": contrastSafeForeground(theme.semantic.warningHover),
80
+ "--varo-ui-warning-text": semanticTextColor(theme.semantic.warningBase, theme.semantic.textBase),
81
+ "--varo-ui-danger": theme.semantic.dangerBase,
82
+ "--varo-ui-danger-dark": theme.semantic.dangerDark,
83
+ "--varo-ui-danger-hover": theme.semantic.dangerHover,
84
+ "--varo-ui-danger-soft": theme.semantic.dangerSoft,
85
+ "--varo-ui-danger-foreground": contrastSafeForeground(theme.semantic.dangerBase),
86
+ "--varo-ui-danger-hover-foreground": contrastSafeForeground(theme.semantic.dangerHover),
87
+ "--varo-ui-danger-text": semanticTextColor(theme.semantic.dangerBase, theme.semantic.textBase),
88
+ "--varo-ui-info": theme.semantic.infoBase,
89
+ "--varo-ui-info-dark": theme.semantic.infoDark,
90
+ "--varo-ui-info-hover": theme.semantic.infoHover,
91
+ "--varo-ui-info-soft": theme.semantic.infoSoft,
92
+ "--varo-ui-info-foreground": contrastSafeForeground(theme.semantic.infoBase),
93
+ "--varo-ui-info-hover-foreground": contrastSafeForeground(theme.semantic.infoHover),
94
+ "--varo-ui-info-text": semanticTextColor(theme.semantic.infoBase, theme.semantic.textBase),
95
+ "--varo-ui-button-radius": theme.components.button.borderRadius,
96
+ "--varo-ui-button-height-sm": theme.components.button.heightSm,
97
+ "--varo-ui-button-height-md": theme.components.button.heightMd,
98
+ "--varo-ui-button-height-lg": theme.components.button.heightLg,
99
+ "--varo-ui-input-radius": theme.components.input.borderRadius,
100
+ "--varo-ui-input-height-sm": theme.components.input.heightSm,
101
+ "--varo-ui-input-height-md": theme.components.input.heightMd,
102
+ "--varo-ui-input-height-lg": theme.components.input.heightLg,
103
+ "--varo-ui-radius": "var(--varo-ui-button-radius)",
104
+ "--varo-ui-radius-sm": "var(--varo-ui-input-radius)",
105
+ "--varo-ui-shadow-sm": theme.seed.mode === "dark" ? "0 1px 2px rgb(0 0 0 / 46%)" : "0 1px 2px rgb(48 49 51 / 6%)",
106
+ "--varo-ui-shadow-md": theme.seed.mode === "dark" ? "0 12px 32px 4px rgb(0 0 0 / 36%), 0 8px 20px rgb(0 0 0 / 72%)" : "0 12px 32px 4px rgb(0 0 0 / 4%), 0 8px 20px rgb(0 0 0 / 8%)",
107
+ "--varo-ui-ring": colorWithAlpha(theme.semantic.primaryBase, 16),
108
+ "--varo-ui-focus": contrastSafeForeground(theme.semantic.surfaceBase),
109
+ ...overrides
110
+ };
111
+ }
112
+ function renderThemeCssVariables(selector, variables) {
113
+ const normalizedSelector = selector.trim();
114
+ if (!normalizedSelector || /[{}]/.test(normalizedSelector)) throw new Error(`Invalid theme CSS selector: ${selector}`);
115
+ return `${normalizedSelector} {\n${Object.entries(variables).map(([name, value]) => {
116
+ if (/[;{}\r\n]/.test(value)) throw new Error(`Invalid theme CSS variable value for ${name}`);
117
+ return ` ${name}: ${value};`;
118
+ }).join("\n")}\n}`;
119
+ }
120
+ //#endregion
121
+ //#region src/theme.ts
122
+ const REFERENCE_SCALES = {
123
+ "#07c160": {
124
+ dark: "#06ad56",
125
+ light: "#38cd80",
126
+ soft: "#e6f9ef"
127
+ },
128
+ "#007dff": {
129
+ dark: "#006ad9",
130
+ light: "#3397ff",
131
+ soft: "#e5f2ff"
132
+ },
133
+ "#13b248": {
134
+ dark: "#10973d",
135
+ light: "#42c16d",
136
+ soft: "#e7f7ec"
137
+ },
138
+ "#fa9200": {
139
+ dark: "#d57c00",
140
+ light: "#fba833",
141
+ soft: "#fef4e5"
142
+ },
143
+ "#eb3437": {
144
+ dark: "#c82c2f",
145
+ light: "#ef5d5f",
146
+ soft: "#fdeaeb"
147
+ },
148
+ "#73767a": {
149
+ dark: "#5c5e62",
150
+ light: "#8f9195",
151
+ soft: "#f1f1f2"
152
+ }
153
+ };
154
+ const DARK_SOFT_COLORS = {
155
+ "#07c160": "#122c1f",
156
+ "#007dff": "#112335",
157
+ "#13b248": "#142a1b",
158
+ "#fa9200": "#342611",
159
+ "#eb3437": "#321819",
160
+ "#73767a": "#212222"
161
+ };
162
+ function mixHex(base, target, targetWeight) {
163
+ const normalizedBase = base.toLowerCase();
164
+ if (!/^#[\da-f]{6}$/.test(normalizedBase) || !/^#[\da-f]{6}$/.test(target)) return base;
165
+ return `#${[
166
+ 1,
167
+ 3,
168
+ 5
169
+ ].map((offset) => {
170
+ const baseChannel = Number.parseInt(normalizedBase.slice(offset, offset + 2), 16);
171
+ const targetChannel = Number.parseInt(target.slice(offset, offset + 2), 16);
172
+ return Math.round(baseChannel * (1 - targetWeight) + targetChannel * targetWeight).toString(16).padStart(2, "0");
173
+ }).join("")}`;
174
+ }
175
+ function createColorScale(base, mode) {
176
+ const normalized = base.toLowerCase();
177
+ const reference = REFERENCE_SCALES[normalized];
178
+ const lightScale = reference ? {
179
+ base,
180
+ ...reference
181
+ } : {
182
+ base,
183
+ dark: mixHex(base, "#000000", .15),
184
+ light: mixHex(base, "#ffffff", .2),
185
+ soft: mixHex(base, "#ffffff", .9)
186
+ };
187
+ const scale = mode === "dark" ? {
188
+ ...lightScale,
189
+ soft: DARK_SOFT_COLORS[normalized] ?? mixHex(base, "#141414", .86)
190
+ } : lightScale;
191
+ return {
192
+ ...scale,
193
+ 50: scale.soft,
194
+ 500: scale.base,
195
+ 600: scale.dark
196
+ };
197
+ }
198
+ function createPalette(seed) {
199
+ const mode = seed.mode ?? "light";
200
+ const neutral = mode === "dark" ? {
201
+ "0": "#141414",
202
+ "50": "#1d1d1d",
203
+ "100": "#262727",
204
+ "200": "#4c4d4f",
205
+ "300": "#636466",
206
+ "400": "#8d9095",
207
+ "500": "#a3a6ad",
208
+ "600": "#cfd3dc",
209
+ "900": "#e5eaf3",
210
+ "1000": "#e5eaf3",
211
+ "white": "#ffffff",
212
+ "black": "#000000",
213
+ "text-primary": "#e5eaf3",
214
+ "text-regular": "#cfd3dc",
215
+ "text-secondary": "#a3a6ad",
216
+ "text-placeholder": "#8d9095",
217
+ "text-disabled": "#6c6e72",
218
+ "border-darker": "#636466",
219
+ "border-dark": "#58585a",
220
+ "border-base": "#4c4d4f",
221
+ "border-light": "#414243",
222
+ "border-lighter": "#363637",
223
+ "border-extra-light": "#2a2b2c",
224
+ "fill-darker": "#424243",
225
+ "fill-dark": "#39393a",
226
+ "fill-base": "#303030",
227
+ "fill-light": "#262727",
228
+ "fill-lighter": "#1d1d1d",
229
+ "fill-extra-light": "#191919",
230
+ "bg-page": "#0a0a0a",
231
+ "bg-base": "#141414",
232
+ "bg-overlay": "#1d1e1f"
233
+ } : {
234
+ "0": "#ffffff",
235
+ "50": "#fafafa",
236
+ "100": "#f5f7fa",
237
+ "200": "#dcdfe6",
238
+ "300": "#cdd0d6",
239
+ "400": "#a8abb2",
240
+ "500": "#909399",
241
+ "600": "#606266",
242
+ "900": seed.neutral,
243
+ "1000": seed.neutral,
244
+ "white": "#ffffff",
245
+ "black": "#000000",
246
+ "text-primary": seed.neutral,
247
+ "text-regular": "#606266",
248
+ "text-secondary": "#909399",
249
+ "text-placeholder": "#a8abb2",
250
+ "text-disabled": "#c0c4cc",
251
+ "border-darker": "#cdd0d6",
252
+ "border-dark": "#d4d7de",
253
+ "border-base": "#dcdfe6",
254
+ "border-light": "#e4e7ed",
255
+ "border-lighter": "#ebeef5",
256
+ "border-extra-light": "#f2f6fc",
257
+ "fill-darker": "#e6e8eb",
258
+ "fill-dark": "#ebedf0",
259
+ "fill-base": "#f0f2f5",
260
+ "fill-light": "#f5f7fa",
261
+ "fill-lighter": "#fafafa",
262
+ "fill-extra-light": "#fafcff",
263
+ "bg-page": "#f2f3f5",
264
+ "bg-base": "#ffffff",
265
+ "bg-overlay": "#ffffff"
266
+ };
267
+ return {
268
+ primary: createColorScale(seed.primary, mode),
269
+ success: createColorScale(seed.success, mode),
270
+ warning: createColorScale(seed.warning, mode),
271
+ error: createColorScale(seed.error, mode),
272
+ info: createColorScale(seed.info ?? "#73767a", mode),
273
+ neutral
274
+ };
275
+ }
276
+ function createSemanticTokens(palette) {
277
+ return {
278
+ textBase: palette.neutral["text-primary"],
279
+ textRegular: palette.neutral["text-regular"],
280
+ textMuted: palette.neutral["text-secondary"],
281
+ textPlaceholder: palette.neutral["text-placeholder"],
282
+ textDisabled: palette.neutral["text-disabled"],
283
+ surfaceBase: palette.neutral["bg-base"],
284
+ surfaceElevated: palette.neutral["bg-page"],
285
+ surfaceOverlay: palette.neutral["bg-overlay"],
286
+ fillBase: palette.neutral["fill-base"],
287
+ fillLight: palette.neutral["fill-light"],
288
+ fillLighter: palette.neutral["fill-lighter"],
289
+ borderBase: palette.neutral["border-base"],
290
+ borderStrong: palette.neutral["border-darker"],
291
+ borderLight: palette.neutral["border-light"],
292
+ borderLighter: palette.neutral["border-lighter"],
293
+ primaryBase: palette.primary.base,
294
+ primaryDark: palette.primary.dark,
295
+ primaryHover: palette.primary.light,
296
+ primarySoft: palette.primary.soft,
297
+ successBase: palette.success.base,
298
+ successDark: palette.success.dark,
299
+ successHover: palette.success.light,
300
+ successSoft: palette.success.soft,
301
+ warningBase: palette.warning.base,
302
+ warningDark: palette.warning.dark,
303
+ warningHover: palette.warning.light,
304
+ warningSoft: palette.warning.soft,
305
+ dangerBase: palette.error.base,
306
+ dangerDark: palette.error.dark,
307
+ dangerHover: palette.error.light,
308
+ dangerSoft: palette.error.soft,
309
+ infoBase: palette.info.base,
310
+ infoDark: palette.info.dark,
311
+ infoHover: palette.info.light,
312
+ infoSoft: palette.info.soft
313
+ };
314
+ }
315
+ function createComponentTokens(semantic) {
316
+ return {
317
+ button: {
318
+ borderRadius: "12px",
319
+ heightSm: "36px",
320
+ heightMd: "44px",
321
+ heightLg: "48px"
322
+ },
323
+ dialog: {
324
+ borderRadius: "16px",
325
+ overlayColor: semantic.borderStrong
326
+ },
327
+ input: {
328
+ borderRadius: "12px",
329
+ heightSm: "36px",
330
+ heightMd: "44px",
331
+ heightLg: "48px"
332
+ }
333
+ };
334
+ }
335
+ function createTheme(seed) {
336
+ const palette = createPalette(seed);
337
+ const semantic = createSemanticTokens(palette);
338
+ return {
339
+ seed,
340
+ palette,
341
+ semantic,
342
+ components: createComponentTokens(semantic)
343
+ };
344
+ }
345
+ function mergeThemeOverrides(theme, overrides = {}) {
346
+ return {
347
+ ...theme,
348
+ semantic: {
349
+ ...theme.semantic,
350
+ ...overrides.semantic
351
+ },
352
+ components: {
353
+ button: {
354
+ ...theme.components.button,
355
+ ...overrides.components?.button
356
+ },
357
+ dialog: {
358
+ ...theme.components.dialog,
359
+ ...overrides.components?.dialog
360
+ },
361
+ input: {
362
+ ...theme.components.input,
363
+ ...overrides.components?.input
364
+ }
365
+ }
366
+ };
367
+ }
368
+ //#endregion
369
+ export { mergeThemeOverrides as a, renderThemeCssVariables as c, createTheme as i, createPalette as n, contrastSafeForeground as o, createSemanticTokens as r, createThemeCssVariables as s, createComponentTokens as t };
370
+
371
+ //# sourceMappingURL=theme-Bg24AjHw.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"theme-Bg24AjHw.mjs","names":[],"sources":["../src/css.ts","../src/theme.ts"],"sourcesContent":["import type { ThemeDefinition } from './types'\n\nexport interface ThemeCssVariables {\n '--varo-ui-white': string\n '--varo-ui-black': string\n '--varo-ui-bg': string\n '--varo-ui-surface': string\n '--varo-ui-surface-muted': string\n '--varo-ui-surface-overlay': string\n '--varo-ui-text': string\n '--varo-ui-text-regular': string\n '--varo-ui-text-muted': string\n '--varo-ui-text-placeholder': string\n '--varo-ui-text-disabled': string\n '--varo-ui-border': string\n '--varo-ui-border-strong': string\n '--varo-ui-border-dark': string\n '--varo-ui-border-light': string\n '--varo-ui-border-lighter': string\n '--varo-ui-border-extra-light': string\n '--varo-ui-fill': string\n '--varo-ui-fill-darker': string\n '--varo-ui-fill-dark': string\n '--varo-ui-fill-light': string\n '--varo-ui-fill-lighter': string\n '--varo-ui-fill-extra-light': string\n '--varo-ui-primary': string\n '--varo-ui-primary-dark': string\n '--varo-ui-primary-hover': string\n '--varo-ui-primary-soft': string\n '--varo-ui-primary-foreground': string\n '--varo-ui-primary-hover-foreground': string\n '--varo-ui-primary-text': string\n '--varo-ui-success': string\n '--varo-ui-success-dark': string\n '--varo-ui-success-hover': string\n '--varo-ui-success-soft': string\n '--varo-ui-success-foreground': string\n '--varo-ui-success-hover-foreground': string\n '--varo-ui-success-text': string\n '--varo-ui-warning': string\n '--varo-ui-warning-dark': string\n '--varo-ui-warning-hover': string\n '--varo-ui-warning-soft': string\n '--varo-ui-warning-foreground': string\n '--varo-ui-warning-hover-foreground': string\n '--varo-ui-warning-text': string\n '--varo-ui-danger': string\n '--varo-ui-danger-dark': string\n '--varo-ui-danger-hover': string\n '--varo-ui-danger-soft': string\n '--varo-ui-danger-foreground': string\n '--varo-ui-danger-hover-foreground': string\n '--varo-ui-danger-text': string\n '--varo-ui-info': string\n '--varo-ui-info-dark': string\n '--varo-ui-info-hover': string\n '--varo-ui-info-soft': string\n '--varo-ui-info-foreground': string\n '--varo-ui-info-hover-foreground': string\n '--varo-ui-info-text': string\n '--varo-ui-radius': string\n '--varo-ui-radius-sm': string\n '--varo-ui-button-radius': string\n '--varo-ui-button-height-sm': string\n '--varo-ui-button-height-md': string\n '--varo-ui-button-height-lg': string\n '--varo-ui-input-radius': string\n '--varo-ui-input-height-sm': string\n '--varo-ui-input-height-md': string\n '--varo-ui-input-height-lg': string\n '--varo-ui-shadow-sm': string\n '--varo-ui-shadow-md': string\n '--varo-ui-ring': string\n '--varo-ui-focus': string\n [name: `--${string}`]: string\n}\n\nexport type ThemeCssVariableOverrides = Partial<ThemeCssVariables>\n\nfunction colorWithAlpha(color: string, alpha: number): string {\n const value = color.slice(1)\n const normalized = value.length === 3\n ? value.split('').map(part => `${part}${part}`).join('')\n : value\n\n if (!color.startsWith('#') || !/^[\\da-f]{6}$/i.test(normalized)) {\n return color\n }\n\n const red = Number.parseInt(normalized.slice(0, 2), 16)\n const green = Number.parseInt(normalized.slice(2, 4), 16)\n const blue = Number.parseInt(normalized.slice(4, 6), 16)\n return `rgb(${red} ${green} ${blue} / ${alpha}%)`\n}\n\nfunction semanticTextColor(base: string, text: string): string {\n if (!/^#[\\da-f]{6}$/i.test(base) || !/^#[\\da-f]{6}$/i.test(text)) {\n return text\n }\n\n const channels = [1, 3, 5].map((offset) => {\n const baseChannel = Number.parseInt(base.slice(offset, offset + 2), 16)\n const textChannel = Number.parseInt(text.slice(offset, offset + 2), 16)\n return Math.round((baseChannel + textChannel) / 2)\n .toString(16)\n .padStart(2, '0')\n })\n\n return `#${channels.join('')}`\n}\n\nfunction relativeLuminance(color: string): number | undefined {\n const value = color.slice(1)\n const normalized = value.length === 3\n ? value.split('').map(part => `${part}${part}`).join('')\n : value\n\n if (!color.startsWith('#') || !/^[\\da-f]{6}$/i.test(normalized)) {\n return undefined\n }\n\n const channelLuminance = (offset: number) => {\n const channel = Number.parseInt(normalized.slice(offset, offset + 2), 16) / 255\n return channel <= 0.04045\n ? channel / 12.92\n : ((channel + 0.055) / 1.055) ** 2.4\n }\n return channelLuminance(0) * 0.2126\n + channelLuminance(2) * 0.7152\n + channelLuminance(4) * 0.0722\n}\n\nexport function contrastSafeForeground(background: string): '#000000' | '#ffffff' {\n const backgroundLuminance = relativeLuminance(background)\n if (backgroundLuminance == null) {\n throw new Error(`Contrast-safe foreground requires a hex color (#RGB or #RRGGBB): ${background}`)\n }\n\n const blackContrast = (backgroundLuminance + 0.05) / 0.05\n const whiteContrast = 1.05 / (backgroundLuminance + 0.05)\n return blackContrast >= whiteContrast ? '#000000' : '#ffffff'\n}\n\nexport function createThemeCssVariables(\n theme: ThemeDefinition,\n overrides: ThemeCssVariableOverrides = {},\n): ThemeCssVariables {\n return {\n '--varo-ui-white': theme.palette.neutral.white,\n '--varo-ui-black': theme.palette.neutral.black,\n '--varo-ui-bg': theme.semantic.surfaceElevated,\n '--varo-ui-surface': theme.semantic.surfaceBase,\n '--varo-ui-surface-muted': theme.semantic.fillLight,\n '--varo-ui-surface-overlay': theme.semantic.surfaceOverlay,\n '--varo-ui-text': theme.semantic.textBase,\n '--varo-ui-text-regular': theme.semantic.textRegular,\n '--varo-ui-text-muted': theme.semantic.textMuted,\n '--varo-ui-text-placeholder': theme.semantic.textPlaceholder,\n '--varo-ui-text-disabled': theme.semantic.textDisabled,\n '--varo-ui-border': theme.semantic.borderBase,\n '--varo-ui-border-strong': theme.semantic.borderStrong,\n '--varo-ui-border-dark': theme.palette.neutral['border-dark'],\n '--varo-ui-border-light': theme.semantic.borderLight,\n '--varo-ui-border-lighter': theme.semantic.borderLighter,\n '--varo-ui-border-extra-light': theme.palette.neutral['border-extra-light'],\n '--varo-ui-fill': theme.semantic.fillBase,\n '--varo-ui-fill-darker': theme.palette.neutral['fill-darker'],\n '--varo-ui-fill-dark': theme.palette.neutral['fill-dark'],\n '--varo-ui-fill-light': theme.semantic.fillLight,\n '--varo-ui-fill-lighter': theme.semantic.fillLighter,\n '--varo-ui-fill-extra-light': theme.palette.neutral['fill-extra-light'],\n '--varo-ui-primary': theme.semantic.primaryBase,\n '--varo-ui-primary-dark': theme.semantic.primaryDark,\n '--varo-ui-primary-hover': theme.semantic.primaryHover,\n '--varo-ui-primary-soft': theme.semantic.primarySoft,\n '--varo-ui-primary-foreground': contrastSafeForeground(theme.semantic.primaryBase),\n '--varo-ui-primary-hover-foreground': contrastSafeForeground(theme.semantic.primaryHover),\n '--varo-ui-primary-text': semanticTextColor(theme.semantic.primaryBase, theme.semantic.textBase),\n '--varo-ui-success': theme.semantic.successBase,\n '--varo-ui-success-dark': theme.semantic.successDark,\n '--varo-ui-success-hover': theme.semantic.successHover,\n '--varo-ui-success-soft': theme.semantic.successSoft,\n '--varo-ui-success-foreground': contrastSafeForeground(theme.semantic.successBase),\n '--varo-ui-success-hover-foreground': contrastSafeForeground(theme.semantic.successHover),\n '--varo-ui-success-text': semanticTextColor(theme.semantic.successBase, theme.semantic.textBase),\n '--varo-ui-warning': theme.semantic.warningBase,\n '--varo-ui-warning-dark': theme.semantic.warningDark,\n '--varo-ui-warning-hover': theme.semantic.warningHover,\n '--varo-ui-warning-soft': theme.semantic.warningSoft,\n '--varo-ui-warning-foreground': contrastSafeForeground(theme.semantic.warningBase),\n '--varo-ui-warning-hover-foreground': contrastSafeForeground(theme.semantic.warningHover),\n '--varo-ui-warning-text': semanticTextColor(theme.semantic.warningBase, theme.semantic.textBase),\n '--varo-ui-danger': theme.semantic.dangerBase,\n '--varo-ui-danger-dark': theme.semantic.dangerDark,\n '--varo-ui-danger-hover': theme.semantic.dangerHover,\n '--varo-ui-danger-soft': theme.semantic.dangerSoft,\n '--varo-ui-danger-foreground': contrastSafeForeground(theme.semantic.dangerBase),\n '--varo-ui-danger-hover-foreground': contrastSafeForeground(theme.semantic.dangerHover),\n '--varo-ui-danger-text': semanticTextColor(theme.semantic.dangerBase, theme.semantic.textBase),\n '--varo-ui-info': theme.semantic.infoBase,\n '--varo-ui-info-dark': theme.semantic.infoDark,\n '--varo-ui-info-hover': theme.semantic.infoHover,\n '--varo-ui-info-soft': theme.semantic.infoSoft,\n '--varo-ui-info-foreground': contrastSafeForeground(theme.semantic.infoBase),\n '--varo-ui-info-hover-foreground': contrastSafeForeground(theme.semantic.infoHover),\n '--varo-ui-info-text': semanticTextColor(theme.semantic.infoBase, theme.semantic.textBase),\n '--varo-ui-button-radius': theme.components.button.borderRadius,\n '--varo-ui-button-height-sm': theme.components.button.heightSm,\n '--varo-ui-button-height-md': theme.components.button.heightMd,\n '--varo-ui-button-height-lg': theme.components.button.heightLg,\n '--varo-ui-input-radius': theme.components.input.borderRadius,\n '--varo-ui-input-height-sm': theme.components.input.heightSm,\n '--varo-ui-input-height-md': theme.components.input.heightMd,\n '--varo-ui-input-height-lg': theme.components.input.heightLg,\n '--varo-ui-radius': 'var(--varo-ui-button-radius)',\n '--varo-ui-radius-sm': 'var(--varo-ui-input-radius)',\n '--varo-ui-shadow-sm': theme.seed.mode === 'dark'\n ? '0 1px 2px rgb(0 0 0 / 46%)'\n : '0 1px 2px rgb(48 49 51 / 6%)',\n '--varo-ui-shadow-md': theme.seed.mode === 'dark'\n ? '0 12px 32px 4px rgb(0 0 0 / 36%), 0 8px 20px rgb(0 0 0 / 72%)'\n : '0 12px 32px 4px rgb(0 0 0 / 4%), 0 8px 20px rgb(0 0 0 / 8%)',\n '--varo-ui-ring': colorWithAlpha(theme.semantic.primaryBase, 16),\n '--varo-ui-focus': contrastSafeForeground(theme.semantic.surfaceBase),\n ...overrides,\n }\n}\n\nexport function renderThemeCssVariables(selector: string, variables: ThemeCssVariables): string {\n const normalizedSelector = selector.trim()\n if (!normalizedSelector || /[{}]/.test(normalizedSelector)) {\n throw new Error(`Invalid theme CSS selector: ${selector}`)\n }\n\n const declarations = Object.entries(variables).map(([name, value]) => {\n if (/[;{}\\r\\n]/.test(value)) {\n throw new Error(`Invalid theme CSS variable value for ${name}`)\n }\n return ` ${name}: ${value};`\n })\n\n return `${normalizedSelector} {\\n${declarations.join('\\n')}\\n}`\n}\n","import type {\n ComponentTokens,\n SemanticTokens,\n ThemeDefinition,\n ThemeOverrides,\n ThemePalette,\n ThemeSeed,\n} from './types'\n\ninterface ColorScale {\n dark: string\n base: string\n light: string\n soft: string\n}\n\nconst REFERENCE_SCALES: Record<string, Omit<ColorScale, 'base'>> = {\n '#07c160': { dark: '#06ad56', light: '#38cd80', soft: '#e6f9ef' },\n '#007dff': { dark: '#006ad9', light: '#3397ff', soft: '#e5f2ff' },\n '#13b248': { dark: '#10973d', light: '#42c16d', soft: '#e7f7ec' },\n '#fa9200': { dark: '#d57c00', light: '#fba833', soft: '#fef4e5' },\n '#eb3437': { dark: '#c82c2f', light: '#ef5d5f', soft: '#fdeaeb' },\n '#73767a': { dark: '#5c5e62', light: '#8f9195', soft: '#f1f1f2' },\n}\n\nconst DARK_SOFT_COLORS: Record<string, string> = {\n '#07c160': '#122c1f',\n '#007dff': '#112335',\n '#13b248': '#142a1b',\n '#fa9200': '#342611',\n '#eb3437': '#321819',\n '#73767a': '#212222',\n}\n\nfunction mixHex(base: string, target: string, targetWeight: number): string {\n const normalizedBase = base.toLowerCase()\n if (!/^#[\\da-f]{6}$/.test(normalizedBase) || !/^#[\\da-f]{6}$/.test(target)) {\n return base\n }\n\n const channels = [1, 3, 5].map((offset) => {\n const baseChannel = Number.parseInt(normalizedBase.slice(offset, offset + 2), 16)\n const targetChannel = Number.parseInt(target.slice(offset, offset + 2), 16)\n return Math.round(baseChannel * (1 - targetWeight) + targetChannel * targetWeight)\n .toString(16)\n .padStart(2, '0')\n })\n\n return `#${channels.join('')}`\n}\n\nfunction createColorScale(base: string, mode: 'light' | 'dark'): Record<string, string> {\n const normalized = base.toLowerCase()\n const reference = REFERENCE_SCALES[normalized]\n const lightScale: ColorScale = reference\n ? { base, ...reference }\n : {\n base,\n dark: mixHex(base, '#000000', 0.15),\n light: mixHex(base, '#ffffff', 0.2),\n soft: mixHex(base, '#ffffff', 0.9),\n }\n const scale = mode === 'dark'\n ? {\n ...lightScale,\n soft: DARK_SOFT_COLORS[normalized] ?? mixHex(base, '#141414', 0.86),\n }\n : lightScale\n\n return {\n ...scale,\n 50: scale.soft,\n 500: scale.base,\n 600: scale.dark,\n }\n}\n\nexport function createPalette(seed: ThemeSeed): ThemePalette {\n const mode = seed.mode ?? 'light'\n const neutral = mode === 'dark'\n ? {\n '0': '#141414',\n '50': '#1d1d1d',\n '100': '#262727',\n '200': '#4c4d4f',\n '300': '#636466',\n '400': '#8d9095',\n '500': '#a3a6ad',\n '600': '#cfd3dc',\n '900': '#e5eaf3',\n '1000': '#e5eaf3',\n 'white': '#ffffff',\n 'black': '#000000',\n 'text-primary': '#e5eaf3',\n 'text-regular': '#cfd3dc',\n 'text-secondary': '#a3a6ad',\n 'text-placeholder': '#8d9095',\n 'text-disabled': '#6c6e72',\n 'border-darker': '#636466',\n 'border-dark': '#58585a',\n 'border-base': '#4c4d4f',\n 'border-light': '#414243',\n 'border-lighter': '#363637',\n 'border-extra-light': '#2a2b2c',\n 'fill-darker': '#424243',\n 'fill-dark': '#39393a',\n 'fill-base': '#303030',\n 'fill-light': '#262727',\n 'fill-lighter': '#1d1d1d',\n 'fill-extra-light': '#191919',\n 'bg-page': '#0a0a0a',\n 'bg-base': '#141414',\n 'bg-overlay': '#1d1e1f',\n }\n : {\n '0': '#ffffff',\n '50': '#fafafa',\n '100': '#f5f7fa',\n '200': '#dcdfe6',\n '300': '#cdd0d6',\n '400': '#a8abb2',\n '500': '#909399',\n '600': '#606266',\n '900': seed.neutral,\n '1000': seed.neutral,\n 'white': '#ffffff',\n 'black': '#000000',\n 'text-primary': seed.neutral,\n 'text-regular': '#606266',\n 'text-secondary': '#909399',\n 'text-placeholder': '#a8abb2',\n 'text-disabled': '#c0c4cc',\n 'border-darker': '#cdd0d6',\n 'border-dark': '#d4d7de',\n 'border-base': '#dcdfe6',\n 'border-light': '#e4e7ed',\n 'border-lighter': '#ebeef5',\n 'border-extra-light': '#f2f6fc',\n 'fill-darker': '#e6e8eb',\n 'fill-dark': '#ebedf0',\n 'fill-base': '#f0f2f5',\n 'fill-light': '#f5f7fa',\n 'fill-lighter': '#fafafa',\n 'fill-extra-light': '#fafcff',\n 'bg-page': '#f2f3f5',\n 'bg-base': '#ffffff',\n 'bg-overlay': '#ffffff',\n }\n\n return {\n primary: createColorScale(seed.primary, mode),\n success: createColorScale(seed.success, mode),\n warning: createColorScale(seed.warning, mode),\n error: createColorScale(seed.error, mode),\n info: createColorScale(seed.info ?? '#73767a', mode),\n neutral,\n }\n}\n\nexport function createSemanticTokens(palette: ThemePalette): SemanticTokens {\n return {\n textBase: palette.neutral['text-primary'],\n textRegular: palette.neutral['text-regular'],\n textMuted: palette.neutral['text-secondary'],\n textPlaceholder: palette.neutral['text-placeholder'],\n textDisabled: palette.neutral['text-disabled'],\n surfaceBase: palette.neutral['bg-base'],\n surfaceElevated: palette.neutral['bg-page'],\n surfaceOverlay: palette.neutral['bg-overlay'],\n fillBase: palette.neutral['fill-base'],\n fillLight: palette.neutral['fill-light'],\n fillLighter: palette.neutral['fill-lighter'],\n borderBase: palette.neutral['border-base'],\n borderStrong: palette.neutral['border-darker'],\n borderLight: palette.neutral['border-light'],\n borderLighter: palette.neutral['border-lighter'],\n primaryBase: palette.primary.base,\n primaryDark: palette.primary.dark,\n primaryHover: palette.primary.light,\n primarySoft: palette.primary.soft,\n successBase: palette.success.base,\n successDark: palette.success.dark,\n successHover: palette.success.light,\n successSoft: palette.success.soft,\n warningBase: palette.warning.base,\n warningDark: palette.warning.dark,\n warningHover: palette.warning.light,\n warningSoft: palette.warning.soft,\n dangerBase: palette.error.base,\n dangerDark: palette.error.dark,\n dangerHover: palette.error.light,\n dangerSoft: palette.error.soft,\n infoBase: palette.info.base,\n infoDark: palette.info.dark,\n infoHover: palette.info.light,\n infoSoft: palette.info.soft,\n }\n}\n\nexport function createComponentTokens(semantic: SemanticTokens): ComponentTokens {\n return {\n button: {\n borderRadius: '12px',\n heightSm: '36px',\n heightMd: '44px',\n heightLg: '48px',\n },\n dialog: {\n borderRadius: '16px',\n overlayColor: semantic.borderStrong,\n },\n input: {\n borderRadius: '12px',\n heightSm: '36px',\n heightMd: '44px',\n heightLg: '48px',\n },\n }\n}\n\nexport function createTheme(seed: ThemeSeed): ThemeDefinition {\n const palette = createPalette(seed)\n const semantic = createSemanticTokens(palette)\n const components = createComponentTokens(semantic)\n\n return {\n seed,\n palette,\n semantic,\n components,\n }\n}\n\nexport function mergeThemeOverrides(theme: ThemeDefinition, overrides: ThemeOverrides = {}): ThemeDefinition {\n return {\n ...theme,\n semantic: {\n ...theme.semantic,\n ...overrides.semantic,\n },\n components: {\n button: {\n ...theme.components.button,\n ...overrides.components?.button,\n },\n dialog: {\n ...theme.components.dialog,\n ...overrides.components?.dialog,\n },\n input: {\n ...theme.components.input,\n ...overrides.components?.input,\n },\n },\n }\n}\n"],"mappings":";AAgFA,SAAS,eAAe,OAAe,OAAuB;CAC5D,M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MAAM,WAAW;IACpB,GAAG,UAAU,YAAY;GAC3B;GACA,QAAQ;IACN,GAAG,MAAM,WAAW;IACpB,GAAG,UAAU,YAAY;GAC3B;GACA,OAAO;IACL,GAAG,MAAM,WAAW;IACpB,GAAG,UAAU,YAAY;GAC3B;EACF;CACF;AACF"}
@@ -0,0 +1,13 @@
1
+ import { c as ThemeDefinition, t as ThemeCssVariableOverrides } from "./css-D2jQSprg.mjs";
2
+ import { Plugin } from "vite";
3
+
4
+ //#region src/weapp-vite.d.ts
5
+ interface VaroWeappThemePluginOptions {
6
+ appStyle: string;
7
+ theme: ThemeDefinition;
8
+ variables?: ThemeCssVariableOverrides;
9
+ }
10
+ declare function createVaroWeappThemePlugin(options: VaroWeappThemePluginOptions): Plugin;
11
+ //#endregion
12
+ export { VaroWeappThemePluginOptions, createVaroWeappThemePlugin };
13
+ //# sourceMappingURL=weapp-vite.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"weapp-vite.d.mts","names":[],"sources":["../src/weapp-vite.ts"],"mappings":";;;;UAMiB,2BAAA;EACf,QAAA;EACA,KAAA,EAAO,eAAA;EACP,SAAA,GAAY,yBAAyB;AAAA;AAAA,iBAGvB,0BAAA,CAA2B,OAAA,EAAS,2BAAA,GAA8B,MAAM"}
@@ -0,0 +1,21 @@
1
+ import { renderWeappThemeCss } from "./weapp.mjs";
2
+ import { resolve } from "node:path";
3
+ //#region src/weapp-vite.ts
4
+ function createVaroWeappThemePlugin(options) {
5
+ const appStylePath = resolve(options.appStyle);
6
+ return {
7
+ name: "varo:weapp-theme",
8
+ enforce: "pre",
9
+ transform(source, id) {
10
+ if (resolve(id.split("?")[0]) !== appStylePath) return;
11
+ return {
12
+ code: `${source}\n${renderWeappThemeCss(options.theme, { variables: options.variables })}\n`,
13
+ map: null
14
+ };
15
+ }
16
+ };
17
+ }
18
+ //#endregion
19
+ export { createVaroWeappThemePlugin };
20
+
21
+ //# sourceMappingURL=weapp-vite.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"weapp-vite.mjs","names":[],"sources":["../src/weapp-vite.ts"],"sourcesContent":["import type { Plugin } from 'vite'\nimport type { ThemeCssVariableOverrides } from './css.ts'\nimport type { ThemeDefinition } from './types.ts'\nimport { resolve } from 'node:path'\nimport { renderWeappThemeCss } from './weapp.ts'\n\nexport interface VaroWeappThemePluginOptions {\n appStyle: string\n theme: ThemeDefinition\n variables?: ThemeCssVariableOverrides\n}\n\nexport function createVaroWeappThemePlugin(options: VaroWeappThemePluginOptions): Plugin {\n const appStylePath = resolve(options.appStyle)\n\n return {\n name: 'varo:weapp-theme',\n enforce: 'pre',\n transform(source, id) {\n if (resolve(id.split('?')[0]) !== appStylePath) {\n return\n }\n\n return {\n code: `${source}\\n${renderWeappThemeCss(options.theme, { variables: options.variables })}\\n`,\n map: null,\n }\n },\n }\n}\n"],"mappings":";;;AAYA,SAAgB,2BAA2B,SAA8C;CACvF,MAAM,eAAe,QAAQ,QAAQ,QAAQ;CAE7C,OAAO;EACL,MAAM;EACN,SAAS;EACT,UAAU,QAAQ,IAAI;GACpB,IAAI,QAAQ,GAAG,MAAM,GAAG,CAAC,CAAC,EAAE,MAAM,cAChC;GAGF,OAAO;IACL,MAAM,GAAG,OAAO,IAAI,oBAAoB,QAAQ,OAAO,EAAE,WAAW,QAAQ,UAAU,CAAC,EAAE;IACzF,KAAK;GACP;EACF;CACF;AACF"}
@@ -0,0 +1,12 @@
1
+ import { c as ThemeDefinition, n as ThemeCssVariables, r as contrastSafeForeground, t as ThemeCssVariableOverrides } from "./css-D2jQSprg.mjs";
2
+ import { a as mergeThemeOverrides, i as createTheme } from "./theme-B7G19AEI.mjs";
3
+
4
+ //#region src/weapp.d.ts
5
+ interface WeappThemeCssOptions {
6
+ variables?: ThemeCssVariableOverrides;
7
+ }
8
+ declare function createWeappThemeStyle(theme: ThemeDefinition, options?: WeappThemeCssOptions): ThemeCssVariables;
9
+ declare function renderWeappThemeCss(theme: ThemeDefinition, options?: WeappThemeCssOptions): string;
10
+ //#endregion
11
+ export { type ThemeCssVariableOverrides, type ThemeCssVariables, type ThemeDefinition, WeappThemeCssOptions, contrastSafeForeground, createTheme, createWeappThemeStyle, mergeThemeOverrides, renderWeappThemeCss };
12
+ //# sourceMappingURL=weapp.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"weapp.d.mts","names":[],"sources":["../src/weapp.ts"],"mappings":";;;;UAIiB,oBAAA;EACf,SAAA,GAAY,yBAAyB;AAAA;AAAA,iBAGvB,qBAAA,CACd,KAAA,EAAO,eAAA,EACP,OAAA,GAAS,oBAAA,GACR,iBAAA;AAAA,iBAIa,mBAAA,CACd,KAAA,EAAO,eAAA,EACP,OAAA,GAAS,oBAAyB"}
package/dist/weapp.mjs ADDED
@@ -0,0 +1,12 @@
1
+ import { a as mergeThemeOverrides, c as renderThemeCssVariables, i as createTheme, o as contrastSafeForeground, s as createThemeCssVariables } from "./theme-Bg24AjHw.mjs";
2
+ //#region src/weapp.ts
3
+ function createWeappThemeStyle(theme, options = {}) {
4
+ return createThemeCssVariables(theme, options.variables);
5
+ }
6
+ function renderWeappThemeCss(theme, options = {}) {
7
+ return renderThemeCssVariables("page", createWeappThemeStyle(theme, options));
8
+ }
9
+ //#endregion
10
+ export { contrastSafeForeground, createTheme, createWeappThemeStyle, mergeThemeOverrides, renderWeappThemeCss };
11
+
12
+ //# sourceMappingURL=weapp.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"weapp.mjs","names":[],"sources":["../src/weapp.ts"],"sourcesContent":["import type { ThemeCssVariableOverrides, ThemeCssVariables } from './css.ts'\nimport type { ThemeDefinition } from './types.ts'\nimport { createThemeCssVariables, renderThemeCssVariables } from './css.ts'\n\nexport interface WeappThemeCssOptions {\n variables?: ThemeCssVariableOverrides\n}\n\nexport function createWeappThemeStyle(\n theme: ThemeDefinition,\n options: WeappThemeCssOptions = {},\n): ThemeCssVariables {\n return createThemeCssVariables(theme, options.variables)\n}\n\nexport function renderWeappThemeCss(\n theme: ThemeDefinition,\n options: WeappThemeCssOptions = {},\n): string {\n return renderThemeCssVariables('page', createWeappThemeStyle(theme, options))\n}\n\nexport type { ThemeCssVariableOverrides, ThemeCssVariables } from './css.ts'\nexport { contrastSafeForeground } from './css.ts'\nexport { createTheme, mergeThemeOverrides } from './theme.ts'\nexport type { ThemeDefinition } from './types.ts'\n"],"mappings":";;AAQA,SAAgB,sBACd,OACA,UAAgC,CAAC,GACd;CACnB,OAAO,wBAAwB,OAAO,QAAQ,SAAS;AACzD;AAEA,SAAgB,oBACd,OACA,UAAgC,CAAC,GACzB;CACR,OAAO,wBAAwB,QAAQ,sBAAsB,OAAO,OAAO,CAAC;AAC9E"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@varo-ui/theme",
3
3
  "type": "module",
4
- "version": "1.1.0",
4
+ "version": "2.0.0",
5
5
  "description": "Token-driven themes and providers for Varo H5 and mini-program components.",
6
6
  "author": "daguanren21 <1363917353@qq.com>",
7
7
  "license": "MIT",
@@ -24,6 +24,14 @@
24
24
  "types": "./dist/index.d.mts",
25
25
  "import": "./dist/index.mjs"
26
26
  },
27
+ "./weapp": {
28
+ "types": "./dist/weapp.d.mts",
29
+ "import": "./dist/weapp.mjs"
30
+ },
31
+ "./weapp-vite": {
32
+ "types": "./dist/weapp-vite.d.mts",
33
+ "import": "./dist/weapp-vite.mjs"
34
+ },
27
35
  "./source": {
28
36
  "types": "./src/index.ts",
29
37
  "import": "./src/index.ts"
@@ -31,6 +39,14 @@
31
39
  "./source/theme": {
32
40
  "types": "./src/theme.ts",
33
41
  "import": "./src/theme.ts"
42
+ },
43
+ "./source/weapp": {
44
+ "types": "./src/weapp.ts",
45
+ "import": "./src/weapp.ts"
46
+ },
47
+ "./source/weapp-vite": {
48
+ "types": "./src/weapp-vite.ts",
49
+ "import": "./src/weapp-vite.ts"
34
50
  }
35
51
  },
36
52
  "main": "./dist/index.mjs",
@@ -41,7 +57,10 @@
41
57
  "src"
42
58
  ],
43
59
  "dependencies": {
44
- "vue": "^3.5.41"
60
+ "vue": "^3.5.42"
61
+ },
62
+ "devDependencies": {
63
+ "vite": "8.2.2"
45
64
  },
46
65
  "scripts": {
47
66
  "build": "tsdown",