@varo-ui/theme 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 daguanren21
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,26 @@
1
+ # @varo-ui/theme
2
+
3
+ Token-driven themes and providers for Varo H5 and mini-program components.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ pnpm add @varo-ui/theme
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```ts
14
+ import { createTheme, provideVaroTheme } from '@varo-ui/theme'
15
+
16
+ const theme = createTheme({
17
+ primary: '#3b82f6',
18
+ success: '#16a34a',
19
+ warning: '#d97706',
20
+ error: '#dc2626',
21
+ neutral: '#0f172a'
22
+ })
23
+ provideVaroTheme({ theme })
24
+ ```
25
+
26
+ [Theme documentation](https://daguanren21.github.io/Varo/guide/theme) · [Repository](https://github.com/daguanren21/Varo)
package/dist/index.d.mts CHANGED
@@ -69,7 +69,7 @@ interface ThemeConfig {
69
69
  declare function provideVaroTheme(config: ThemeConfig): void;
70
70
  declare function useVaroTheme(): import("vue").ComputedRef<ThemeDefinition>;
71
71
  declare const VaroConfigProvider: {
72
- install(app: App, config: ThemeConfig): void;
72
+ install(app: App, config?: ThemeConfig): void;
73
73
  };
74
74
  //#endregion
75
75
  //#region src/theme.d.ts
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../src/types.ts","../src/types-runtime.ts","../src/provider.ts","../src/theme.ts"],"mappings":";;;UAAiB,SAAA;EACf,OAAA;EACA,OAAA;EACA,OAAA;EACA,KAAA;EACA,OAAA;AAAA;AAAA,UAGe,YAAA;EACf,OAAA,EAAS,MAAA;EACT,OAAA,EAAS,MAAA;EACT,OAAA,EAAS,MAAA;EACT,OAAA,EAAS,MAAA;EACT,KAAA,EAAO,MAAA;AAAA;AAAA,UAGQ,cAAA;EACf,QAAA;EACA,SAAA;EACA,WAAA;EACA,eAAA;EACA,UAAA;EACA,YAAA;EACA,WAAA;EACA,YAAA;EACA,UAAA;AAAA;AAAA,UAGe,eAAA;EACf,MAAA;IACE,YAAA;IACA,QAAA;IACA,QAAA;IACA,QAAA;EAAA;EAEF,MAAA;IACE,YAAA;IACA,YAAA;EAAA;EAEF,KAAA;IACE,YAAA;IACA,QAAA;IACA,QAAA;IACA,QAAA;EAAA;AAAA;AAAA,UAIa,eAAA;EACf,IAAA,EAAM,SAAA;EACN,OAAA,EAAS,YAAA;EACT,QAAA,EAAU,cAAA;EACV,UAAA,EAAY,eAAA;AAAA;AAAA,UAGG,cAAA;EACf,QAAA,GAAW,OAAA,CAAQ,cAAA;EACnB,UAAA,GAAa,OAAA;IACX,MAAA,EAAQ,OAAA,CAAQ,eAAA;IAChB,MAAA,EAAQ,OAAA,CAAQ,eAAA;IAChB,KAAA,EAAO,OAAA,CAAQ,eAAA;EAAA;AAAA;;;UCzDF,WAAA;EACf,KAAA,EAAO,eAAA;EACP,SAAA,GAAY,cAAc;AAAA;;;iBCGZ,gBAAA,CAAiB,MAAmB,EAAX,WAAW;AAAA,iBAIpC,YAAA,kBAAY,WAAA,CAAA,eAAA;AAAA,cAkBf,kBAAA;eACE,GAAA,EAAG,MAAA,EAAU,WAAW;AAAA;;;iBCrBvB,aAAA,CAAc,IAAA,EAAM,SAAA,GAAY,YAAY;AAAA,iBA2B5C,oBAAA,CAAqB,OAAA,EAAS,YAAA,GAAe,cAAc;AAAA,iBAc3D,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"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/types.ts","../src/types-runtime.ts","../src/provider.ts","../src/theme.ts"],"mappings":";;;UAAiB,SAAA;EACf,OAAA;EACA,OAAA;EACA,OAAA;EACA,KAAA;EACA,OAAA;AAAA;AAAA,UAGe,YAAA;EACf,OAAA,EAAS,MAAA;EACT,OAAA,EAAS,MAAA;EACT,OAAA,EAAS,MAAA;EACT,OAAA,EAAS,MAAA;EACT,KAAA,EAAO,MAAA;AAAA;AAAA,UAGQ,cAAA;EACf,QAAA;EACA,SAAA;EACA,WAAA;EACA,eAAA;EACA,UAAA;EACA,YAAA;EACA,WAAA;EACA,YAAA;EACA,UAAA;AAAA;AAAA,UAGe,eAAA;EACf,MAAA;IACE,YAAA;IACA,QAAA;IACA,QAAA;IACA,QAAA;EAAA;EAEF,MAAA;IACE,YAAA;IACA,YAAA;EAAA;EAEF,KAAA;IACE,YAAA;IACA,QAAA;IACA,QAAA;IACA,QAAA;EAAA;AAAA;AAAA,UAIa,eAAA;EACf,IAAA,EAAM,SAAA;EACN,OAAA,EAAS,YAAA;EACT,QAAA,EAAU,cAAA;EACV,UAAA,EAAY,eAAA;AAAA;AAAA,UAGG,cAAA;EACf,QAAA,GAAW,OAAA,CAAQ,cAAA;EACnB,UAAA,GAAa,OAAA;IACX,MAAA,EAAQ,OAAA,CAAQ,eAAA;IAChB,MAAA,EAAQ,OAAA,CAAQ,eAAA;IAChB,KAAA,EAAO,OAAA,CAAQ,eAAA;EAAA;AAAA;;;UCzDF,WAAA;EACf,KAAA,EAAO,eAAA;EACP,SAAA,GAAY,cAAc;AAAA;;;iBCIZ,gBAAA,CAAiB,MAAmB,EAAX,WAAW;AAAA,iBAIpC,YAAA,kBAAY,WAAA,CAAA,eAAA;AAAA,cAkBf,kBAAA;eACE,GAAA,EAAG,MAAA,GAAW,WAAW;AAAA;;;iBCtBxB,aAAA,CAAc,IAAA,EAAM,SAAA,GAAY,YAAY;AAAA,iBA2B5C,oBAAA,CAAqB,OAAA,EAAS,YAAA,GAAe,cAAc;AAAA,iBAc3D,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"}
package/dist/index.mjs CHANGED
@@ -104,6 +104,7 @@ function useVaroTheme() {
104
104
  return computed(() => config.theme);
105
105
  }
106
106
  const VaroConfigProvider = { install(app, config) {
107
+ if (!config) throw new Error("VaroConfigProvider requires a theme configuration.");
107
108
  app.provide(ThemeKey, config);
108
109
  } };
109
110
  //#endregion
@@ -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 { computed, inject, provide, type App, type InjectionKey } from 'vue'\nimport { createTheme } from './theme'\nimport type { ThemeDefinition } from './types'\nimport type { ThemeConfig } from './types-runtime'\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 app.provide(ThemeKey, config)\n }\n}\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,aAAa,QAAQ,QAAQ;EAC7B,cAAc,QAAQ,QAAQ;EAC9B,YAAY,QAAQ,MAAM;CAC5B;AACF;AAEA,SAAgB,sBAAsB,UAA2C;CAC/E,OAAO;EACL,QAAQ;GACN,cAAc;GACd,UAAU;GACV,UAAU;GACV,UAAU;EACZ;EACA,QAAQ;GACN,cAAc;GACd,cAAc,SAAS;EACzB;EACA,OAAO;GACL,cAAc;GACd,UAAU;GACV,UAAU;GACV,UAAU;EACZ;CACF;AACF;AAEA,SAAgB,YAAY,MAAkC;CAC5D,MAAM,UAAU,cAAc,IAAI;CAClC,MAAM,WAAW,qBAAqB,OAAO;CAG7C,OAAO;EACL;EACA;EACA;EACA,YANiB,sBAAsB,QAM9B;CACX;AACF;AAEA,SAAgB,oBAAoB,OAAwB,YAA4B,CAAC,GAAoB;CAC3G,OAAO;EACL,GAAG;EACH,UAAU;GACR,GAAG,MAAM;GACT,GAAG,UAAU;EACf;EACA,YAAY;GACV,QAAQ;IACN,GAAG,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;;;ACrGA,MAAM,WAAsC,OAAO,YAAY;AAE/D,SAAgB,iBAAiB,QAAqB;CACpD,QAAQ,UAAU,MAAM;AAC1B;AAEA,SAAgB,eAAe;CAC7B,MAAM,SAAS,OAAO,UAAU,KAAA,CAAS;CAEzC,IAAI,CAAC,QACH,OAAO,eACL,YAAY;EACV,SAAS;EACT,SAAS;EACT,SAAS;EACT,OAAO;EACP,SAAS;CACX,CAAC,CACH;CAGF,OAAO,eAAe,OAAO,KAAK;AACpC;AAEA,MAAa,qBAAqB,EAChC,QAAQ,KAAU,QAAqB;CACrC,IAAI,QAAQ,UAAU,MAAM;AAC9B,EACF"}
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,aAAa,QAAQ,QAAQ;EAC7B,cAAc,QAAQ,QAAQ;EAC9B,YAAY,QAAQ,MAAM;CAC5B;AACF;AAEA,SAAgB,sBAAsB,UAA2C;CAC/E,OAAO;EACL,QAAQ;GACN,cAAc;GACd,UAAU;GACV,UAAU;GACV,UAAU;EACZ;EACA,QAAQ;GACN,cAAc;GACd,cAAc,SAAS;EACzB;EACA,OAAO;GACL,cAAc;GACd,UAAU;GACV,UAAU;GACV,UAAU;EACZ;CACF;AACF;AAEA,SAAgB,YAAY,MAAkC;CAC5D,MAAM,UAAU,cAAc,IAAI;CAClC,MAAM,WAAW,qBAAqB,OAAO;CAG7C,OAAO;EACL;EACA;EACA;EACA,YANiB,sBAAsB,QAM9B;CACX;AACF;AAEA,SAAgB,oBAAoB,OAAwB,YAA4B,CAAC,GAAoB;CAC3G,OAAO;EACL,GAAG;EACH,UAAU;GACR,GAAG,MAAM;GACT,GAAG,UAAU;EACf;EACA,YAAY;GACV,QAAQ;IACN,GAAG,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;;;ACpGA,MAAM,WAAsC,OAAO,YAAY;AAE/D,SAAgB,iBAAiB,QAAqB;CACpD,QAAQ,UAAU,MAAM;AAC1B;AAEA,SAAgB,eAAe;CAC7B,MAAM,SAAS,OAAO,UAAU,KAAA,CAAS;CAEzC,IAAI,CAAC,QACH,OAAO,eACL,YAAY;EACV,SAAS;EACT,SAAS;EACT,SAAS;EACT,OAAO;EACP,SAAS;CACX,CAAC,CACH;CAGF,OAAO,eAAe,OAAO,KAAK;AACpC;AAEA,MAAa,qBAAqB,EAChC,QAAQ,KAAU,QAAsB;CACtC,IAAI,CAAC,QAAU,MAAM,IAAI,MAAM,oDAAoD;CACnF,IAAI,QAAQ,UAAU,MAAM;AAC9B,EACF"}
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@varo-ui/theme",
3
- "version": "1.0.0",
3
+ "type": "module",
4
+ "version": "1.1.0",
4
5
  "description": "Token-driven themes and providers for Varo H5 and mini-program components.",
6
+ "author": "daguanren21 <1363917353@qq.com>",
5
7
  "license": "MIT",
6
8
  "homepage": "https://daguanren21.github.io/Varo/",
7
- "type": "module",
8
- "sideEffects": false,
9
9
  "repository": {
10
10
  "type": "git",
11
11
  "url": "git+https://github.com/daguanren21/Varo.git",
@@ -15,13 +15,10 @@
15
15
  "access": "public",
16
16
  "registry": "https://registry.npmjs.org/"
17
17
  },
18
- "main": "./dist/index.mjs",
19
- "module": "./dist/index.mjs",
20
- "types": "./dist/index.d.mts",
21
- "files": [
22
- "dist",
23
- "src"
24
- ],
18
+ "bugs": {
19
+ "url": "https://github.com/daguanren21/Varo/issues"
20
+ },
21
+ "sideEffects": false,
25
22
  "exports": {
26
23
  ".": {
27
24
  "types": "./dist/index.d.mts",
@@ -30,8 +27,22 @@
30
27
  "./source": {
31
28
  "types": "./src/index.ts",
32
29
  "import": "./src/index.ts"
30
+ },
31
+ "./source/theme": {
32
+ "types": "./src/theme.ts",
33
+ "import": "./src/theme.ts"
33
34
  }
34
35
  },
36
+ "main": "./dist/index.mjs",
37
+ "module": "./dist/index.mjs",
38
+ "types": "./dist/index.d.mts",
39
+ "files": [
40
+ "dist",
41
+ "src"
42
+ ],
43
+ "dependencies": {
44
+ "vue": "^3.5.41"
45
+ },
35
46
  "scripts": {
36
47
  "build": "tsdown",
37
48
  "clean": "rimraf dist",
@@ -40,12 +51,5 @@
40
51
  "typecheck": "tsc -p tsconfig.json --noEmit",
41
52
  "test": "vitest run --passWithNoTests",
42
53
  "test:e2e": "echo theme has no e2e"
43
- },
44
- "dependencies": {
45
- "vue": "^3.5.41"
46
- },
47
- "bugs": {
48
- "url": "https://github.com/daguanren21/Varo/issues"
49
- },
50
- "author": "daguanren21 <1363917353@qq.com>"
51
- }
54
+ }
55
+ }
package/src/provider.ts CHANGED
@@ -1,7 +1,8 @@
1
- import { computed, inject, provide, type App, type InjectionKey } from 'vue'
2
- import { createTheme } from './theme'
1
+ import type { App, InjectionKey, Plugin } from 'vue'
3
2
  import type { ThemeDefinition } from './types'
4
3
  import type { ThemeConfig } from './types-runtime'
4
+ import { computed, inject, provide } from 'vue'
5
+ import { createTheme } from './theme'
5
6
 
6
7
  const ThemeKey: InjectionKey<ThemeConfig> = Symbol('varo-theme')
7
8
 
@@ -19,8 +20,8 @@ export function useVaroTheme() {
19
20
  success: '#16a34a',
20
21
  warning: '#d97706',
21
22
  error: '#dc2626',
22
- neutral: '#0f172a'
23
- })
23
+ neutral: '#0f172a',
24
+ }),
24
25
  )
25
26
  }
26
27
 
@@ -28,7 +29,8 @@ export function useVaroTheme() {
28
29
  }
29
30
 
30
31
  export const VaroConfigProvider = {
31
- install(app: App, config: ThemeConfig) {
32
+ install(app: App, config?: ThemeConfig) {
33
+ if (!config) { throw new Error('VaroConfigProvider requires a theme configuration.') }
32
34
  app.provide(ThemeKey, config)
33
- }
34
- }
35
+ },
36
+ } satisfies Plugin