@oiij/naive-ui 0.0.69 → 0.0.71

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.
Files changed (60) hide show
  1. package/dist/components/config-providers/ConfigProviders.js +1 -3
  2. package/dist/components/config-providers/index.d.ts +1 -1
  3. package/dist/components/copy-button/CopyButton.vue.d.ts +4 -4
  4. package/dist/components/data-table-plus/DataTablePlus.js +1 -2
  5. package/dist/components/data-table-plus/DataTablePlus.vue.d.ts +2 -2
  6. package/dist/components/data-table-plus/index.d.ts +1 -1
  7. package/dist/components/index.d.ts +1 -1
  8. package/dist/components/loading-provider/LoadingProvider.js +0 -1
  9. package/dist/components/loading-provider/LoadingProvider.vue.d.ts +2 -2
  10. package/dist/components/loading-provider/loading-provider.cssr.js +0 -1
  11. package/dist/components/preset-form/PresetForm.js +1 -2
  12. package/dist/components/preset-form/PresetForm.vue.d.ts +15 -15
  13. package/dist/components/preset-form/index.d.ts +2 -2
  14. package/dist/components/preset-input/PresetInput.js +0 -1
  15. package/dist/components/preset-input/PresetInput.vue.d.ts +3 -3
  16. package/dist/components/preset-picker/PresetPicker.vue.d.ts +5 -5
  17. package/dist/components/preset-picker/index.d.ts +1 -1
  18. package/dist/components/preset-select/PresetSelect.js +1 -1
  19. package/dist/components/preset-select/PresetSelect.vue.d.ts +27 -27
  20. package/dist/components/preset-select/index.d.ts +1 -1
  21. package/dist/components/remote-request/RemoteRequest.js +1 -1
  22. package/dist/components/remote-request/RemoteRequest.vue.d.ts +11 -11
  23. package/dist/components/remote-request/index.d.ts +1 -1
  24. package/dist/components/search-input/SearchInput.vue.d.ts +4 -4
  25. package/dist/components/transition/BaseTransition.vue.d.ts +2 -2
  26. package/dist/components/type-writer/TypeWriter.js +0 -1
  27. package/dist/components/type-writer/type-writer.cssr.js +0 -1
  28. package/dist/components.d.ts +1 -1
  29. package/dist/components.js +0 -1
  30. package/dist/composables/_helper.js +21 -6
  31. package/dist/composables/index.d.ts +4 -4
  32. package/dist/composables/{useDataRequest.d.ts → use-data-request.d.ts} +1 -1
  33. package/dist/composables/{useDataRequest.js → use-data-request.js} +1 -1
  34. package/dist/composables/{useLoading.d.ts → use-loading.d.ts} +1 -1
  35. package/dist/composables/{useLoading.js → use-loading.js} +1 -1
  36. package/dist/composables/{useNaiveForm.d.ts → use-naive-form.d.ts} +2 -2
  37. package/dist/composables/{useNaiveForm.js → use-naive-form.js} +1 -1
  38. package/dist/composables/use-naive-theme.d.ts +51 -0
  39. package/dist/composables/use-naive-theme.js +103 -0
  40. package/dist/index.d.ts +5 -5
  41. package/dist/index.js +4 -5
  42. package/package.json +5 -5
  43. package/dist/components/_utils/index.js +0 -2
  44. package/dist/components/config-providers/index.js +0 -1
  45. package/dist/components/copy-button/index.js +0 -1
  46. package/dist/components/data-table-plus/index.js +0 -1
  47. package/dist/components/index.js +0 -28
  48. package/dist/components/preset-form/index.js +0 -1
  49. package/dist/components/preset-input/index.js +0 -1
  50. package/dist/components/preset-picker/index.js +0 -1
  51. package/dist/components/preset-select/index.js +0 -1
  52. package/dist/components/remote-request/index.js +0 -1
  53. package/dist/components/search-input/index.js +0 -1
  54. package/dist/components/toggle-input/index.js +0 -1
  55. package/dist/components/tooltip-button/index.js +0 -1
  56. package/dist/components/transition/index.js +0 -1
  57. package/dist/components/type-writer/index.js +0 -1
  58. package/dist/composables/index.js +0 -4
  59. package/dist/composables/useNaiveTheme.d.ts +0 -165
  60. package/dist/composables/useNaiveTheme.js +0 -86
@@ -2,7 +2,7 @@ import * as _vueuse_core0 from "@vueuse/core";
2
2
  import * as vue0 from "vue";
3
3
  import { UseRequestOptions, UseRequestPlugin } from "vue-hooks-plus/es/useRequest/types";
4
4
 
5
- //#region src/composables/useDataRequest.d.ts
5
+ //#region src/composables/use-data-request.d.ts
6
6
  type DataObject = Record<string, any>;
7
7
  type DataRequestFields = Record<string, string | undefined> & {
8
8
  page?: string;
@@ -2,7 +2,7 @@ import { createEventHook } from "@vueuse/core";
2
2
  import { computed, ref } from "vue";
3
3
  import useRequest from "vue-hooks-plus/es/useRequest";
4
4
 
5
- //#region src/composables/useDataRequest.ts
5
+ //#region src/composables/use-data-request.ts
6
6
  function useDataRequest(api, options) {
7
7
  const { defaultParams, manual, fields, requestOptions, requestPlugins } = options ?? {};
8
8
  const _fields = {
@@ -1,6 +1,6 @@
1
1
  import { LoadingProviderInst } from "../components/loading-provider/index.js";
2
2
 
3
- //#region src/composables/useLoading.d.ts
3
+ //#region src/composables/use-loading.d.ts
4
4
  declare function useLoading(): LoadingProviderInst | undefined;
5
5
  //#endregion
6
6
  export { useLoading };
@@ -1,7 +1,7 @@
1
1
  import { loadingProviderInjectionKey } from "../components/loading-provider/index.js";
2
2
  import { inject } from "vue";
3
3
 
4
- //#region src/composables/useLoading.ts
4
+ //#region src/composables/use-loading.ts
5
5
  function useLoading() {
6
6
  return inject(loadingProviderInjectionKey);
7
7
  }
@@ -1,11 +1,11 @@
1
- import { DataObject } from "./useDataRequest.js";
1
+ import { DataObject } from "./use-data-request.js";
2
2
  import * as _vueuse_core3 from "@vueuse/core";
3
3
  import * as vue5 from "vue";
4
4
  import { Ref, TemplateRef } from "vue";
5
5
  import { FormInst, FormItemRule, FormRules } from "naive-ui";
6
6
  import { ValidateError } from "async-validator";
7
7
 
8
- //#region src/composables/useNaiveForm.d.ts
8
+ //#region src/composables/use-naive-form.d.ts
9
9
  type NaiveFormClearRules = {
10
10
  string?: string | null;
11
11
  number?: number | null;
@@ -2,7 +2,7 @@ import { createEventHook } from "@vueuse/core";
2
2
  import { reactive, ref, toRaw, toValue } from "vue";
3
3
  import { cloneDeep } from "es-toolkit/object";
4
4
 
5
- //#region src/composables/useNaiveForm.ts
5
+ //#region src/composables/use-naive-form.ts
6
6
  function isObject(value) {
7
7
  return typeof value === "object" && value !== null && !Array.isArray(value);
8
8
  }
@@ -0,0 +1,51 @@
1
+ import { Colors } from "./_helper.js";
2
+ import { ComputedRef, Ref } from "vue";
3
+ import { GlobalThemeOverrides, NDateLocale, zhCN } from "naive-ui";
4
+ import * as naive_ui_es_themes_interface0 from "naive-ui/es/themes/interface";
5
+
6
+ //#region src/composables/use-naive-theme.d.ts
7
+ type Locales<T extends string = string> = Record<T, {
8
+ name: string;
9
+ dateLocale: NDateLocale;
10
+ locale: typeof zhCN;
11
+ }>;
12
+ type NaiveThemeOptions<T extends string> = {
13
+ language?: T | Ref<T>;
14
+ darkMode?: boolean | Ref<boolean>;
15
+ colors?: Colors;
16
+ globalThemeOverrides?: GlobalThemeOverrides;
17
+ locales?: Partial<Locales<T>>;
18
+ darkColors?: Colors | ((colors: Colors) => Colors);
19
+ };
20
+ declare function useNaiveTheme<T extends string>(options?: NaiveThemeOptions<T>): {
21
+ language: Ref<T, T>;
22
+ darkMode: Ref<boolean | undefined, boolean | undefined>;
23
+ theme: ComputedRef<naive_ui_es_themes_interface0.BuiltInGlobalTheme | undefined>;
24
+ colors: Ref<{
25
+ primary?: string | undefined;
26
+ info?: string | undefined;
27
+ success?: string | undefined;
28
+ warning?: string | undefined;
29
+ error?: string | undefined;
30
+ }, Colors | {
31
+ primary?: string | undefined;
32
+ info?: string | undefined;
33
+ success?: string | undefined;
34
+ warning?: string | undefined;
35
+ error?: string | undefined;
36
+ }>;
37
+ themeColors: ComputedRef<{
38
+ primary?: string | undefined;
39
+ info?: string | undefined;
40
+ success?: string | undefined;
41
+ warning?: string | undefined;
42
+ error?: string | undefined;
43
+ }>;
44
+ themeOverrides: ComputedRef<GlobalThemeOverrides>;
45
+ locales: Locales<T>;
46
+ locale: ComputedRef<Locales<T>[T]>;
47
+ setColor: (v: Partial<Colors>) => void;
48
+ };
49
+ type NaiveThemeReturns = ReturnType<typeof useNaiveTheme>;
50
+ //#endregion
51
+ export { NaiveThemeOptions, NaiveThemeReturns, useNaiveTheme };
@@ -0,0 +1,103 @@
1
+ import { getColors, getDarkColors } from "./_helper.js";
2
+ import { computed, ref, toValue, watchEffect } from "vue";
3
+ import { darkTheme, dateEnUS, dateZhCN, enUS, zhCN } from "naive-ui";
4
+
5
+ //#region src/composables/use-naive-theme.ts
6
+ const naiveLocaleMap = {
7
+ "zh-CN": {
8
+ name: "简体中文",
9
+ dateLocale: dateZhCN,
10
+ locale: zhCN
11
+ },
12
+ "en-US": {
13
+ name: "English",
14
+ dateLocale: dateEnUS,
15
+ locale: enUS
16
+ }
17
+ };
18
+ function useNaiveTheme(options) {
19
+ const { language = "zh-CN", darkMode, colors, globalThemeOverrides, locales, darkColors } = options ?? {};
20
+ const languageRef = ref(toValue(language));
21
+ watchEffect(() => {
22
+ languageRef.value = toValue(language);
23
+ });
24
+ const darkModeRef = ref(toValue(darkMode));
25
+ watchEffect(() => {
26
+ darkModeRef.value = toValue(darkMode);
27
+ });
28
+ const { common, ...extra } = globalThemeOverrides ?? {};
29
+ const colorsRef = ref({ ...colors });
30
+ const themeColorsRef = computed(() => {
31
+ if (darkModeRef.value) {
32
+ if (typeof darkColors === "function") {
33
+ const darkColorsResult = darkColors(colorsRef.value);
34
+ return {
35
+ ...colorsRef.value,
36
+ ...darkColorsResult
37
+ };
38
+ }
39
+ if (typeof darkColors === "object") return {
40
+ ...colorsRef.value,
41
+ ...darkColors
42
+ };
43
+ return getDarkColors(colorsRef.value);
44
+ }
45
+ return colorsRef.value;
46
+ });
47
+ function setColor(v) {
48
+ colorsRef.value = {
49
+ ...colorsRef.value,
50
+ ...v
51
+ };
52
+ }
53
+ const theme = computed(() => {
54
+ return darkModeRef?.value ? darkTheme : void 0;
55
+ });
56
+ const themeOverrides = computed(() => {
57
+ const { primary, info, success, warning, error } = getColors(themeColorsRef.value);
58
+ return {
59
+ common: {
60
+ primaryColor: primary?.color,
61
+ primaryColorHover: primary?.hover,
62
+ primaryColorPressed: primary?.pressed,
63
+ primaryColorSuppl: primary?.suppl,
64
+ infoColor: info?.color,
65
+ infoColorHover: info?.hover,
66
+ infoColorPressed: info?.pressed,
67
+ infoColorSuppl: info?.suppl,
68
+ successColor: success?.color,
69
+ successColorHover: success?.hover,
70
+ successColorPressed: success?.pressed,
71
+ successColorSuppl: success?.suppl,
72
+ warningColor: warning?.color,
73
+ warningColorHover: warning?.hover,
74
+ warningColorPressed: warning?.pressed,
75
+ warningColorSuppl: warning?.suppl,
76
+ errorColor: error?.color,
77
+ errorColorHover: error?.hover,
78
+ errorColorPressed: error?.pressed,
79
+ errorColorSuppl: error?.suppl,
80
+ ...common
81
+ },
82
+ ...extra
83
+ };
84
+ });
85
+ const _locales = {
86
+ ...naiveLocaleMap,
87
+ ...locales
88
+ };
89
+ return {
90
+ language: languageRef,
91
+ darkMode: darkModeRef,
92
+ theme,
93
+ colors: colorsRef,
94
+ themeColors: themeColorsRef,
95
+ themeOverrides,
96
+ locales: _locales,
97
+ locale: computed(() => _locales[languageRef.value] ?? naiveLocaleMap["zh-CN"]),
98
+ setColor
99
+ };
100
+ }
101
+
102
+ //#endregion
103
+ export { useNaiveTheme };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { DataObject, DataRequestFields, UseDataRequestOptions, UseDataRequestPagination, UseDataRequestReturns, useDataRequest } from "./composables/useDataRequest.js";
2
- import { useLoading } from "./composables/useLoading.js";
3
- import { NaiveFormClearRules, NaiveFormOptions, NaiveFormReturns, NaiveFormRules, useNaiveForm } from "./composables/useNaiveForm.js";
4
- import { NaiveThemeReturns, useNaiveTheme } from "./composables/useNaiveTheme.js";
1
+ import { DataObject, DataRequestFields, UseDataRequestOptions, UseDataRequestPagination, UseDataRequestReturns, useDataRequest } from "./composables/use-data-request.js";
2
+ import { useLoading } from "./composables/use-loading.js";
3
+ import { NaiveFormClearRules, NaiveFormOptions, NaiveFormReturns, NaiveFormRules, useNaiveForm } from "./composables/use-naive-form.js";
4
+ import { NaiveThemeOptions, NaiveThemeReturns, useNaiveTheme } from "./composables/use-naive-theme.js";
5
5
  import "./composables/index.js";
6
- export { DataObject, DataRequestFields, NaiveFormClearRules, NaiveFormOptions, NaiveFormReturns, NaiveFormRules, NaiveThemeReturns, UseDataRequestOptions, UseDataRequestPagination, UseDataRequestReturns, useDataRequest, useLoading, useNaiveForm, useNaiveTheme };
6
+ export { DataObject, DataRequestFields, NaiveFormClearRules, NaiveFormOptions, NaiveFormReturns, NaiveFormRules, NaiveThemeOptions, NaiveThemeReturns, UseDataRequestOptions, UseDataRequestPagination, UseDataRequestReturns, useDataRequest, useLoading, useNaiveForm, useNaiveTheme };
package/dist/index.js CHANGED
@@ -1,7 +1,6 @@
1
- import { useDataRequest } from "./composables/useDataRequest.js";
2
- import { useLoading } from "./composables/useLoading.js";
3
- import { useNaiveForm } from "./composables/useNaiveForm.js";
4
- import { useNaiveTheme } from "./composables/useNaiveTheme.js";
5
- import "./composables/index.js";
1
+ import { useDataRequest } from "./composables/use-data-request.js";
2
+ import { useLoading } from "./composables/use-loading.js";
3
+ import { useNaiveForm } from "./composables/use-naive-form.js";
4
+ import { useNaiveTheme } from "./composables/use-naive-theme.js";
6
5
 
7
6
  export { useDataRequest, useLoading, useNaiveForm, useNaiveTheme };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@oiij/naive-ui",
3
3
  "type": "module",
4
- "version": "0.0.69",
4
+ "version": "0.0.71",
5
5
  "description": "Some Composable Functions And Components for Vue 3",
6
6
  "author": "oiij",
7
7
  "license": "MIT",
@@ -45,9 +45,9 @@
45
45
  "vue": "^3.5.26",
46
46
  "vue-component-type-helpers": "^3.2.1",
47
47
  "vue-hooks-plus": "^2.4.1",
48
- "@oiij/use": "0.0.32",
48
+ "@oiij/markdown-it": "0.0.10",
49
49
  "@oiij/css-render": "0.0.9",
50
- "@oiij/markdown-it": "0.0.10"
50
+ "@oiij/use": "0.0.37"
51
51
  },
52
52
  "devDependencies": {
53
53
  "@types/prismjs": "^1.26.5",
@@ -60,9 +60,9 @@
60
60
  "vue": "^3.5.26",
61
61
  "vue-component-type-helpers": "^3.2.1",
62
62
  "vue-hooks-plus": "^2.4.1",
63
+ "@oiij/css-render": "0.0.9",
63
64
  "@oiij/markdown-it": "0.0.10",
64
- "@oiij/use": "0.0.32",
65
- "@oiij/css-render": "0.0.9"
65
+ "@oiij/use": "0.0.37"
66
66
  },
67
67
  "publishConfig": {
68
68
  "access": "public"
@@ -1,2 +0,0 @@
1
- import { cssr, namespace, plugin } from "./cssr-bem.js";
2
- import { highlight } from "./prismjs.js";
@@ -1 +0,0 @@
1
- import ConfigProviders_default from "./ConfigProviders.js";
@@ -1 +0,0 @@
1
- import CopyButton_default from "./CopyButton.js";
@@ -1 +0,0 @@
1
- import DataTablePlus_default from "./DataTablePlus.js";
@@ -1,28 +0,0 @@
1
- import BaseTransition_default from "./transition/BaseTransition.js";
2
- import "./transition/index.js";
3
- import LoadingProvider_default from "./loading-provider/LoadingProvider.js";
4
- import { loadingProviderInjectionKey } from "./loading-provider/index.js";
5
- import ConfigProviders_default from "./config-providers/ConfigProviders.js";
6
- import "./config-providers/index.js";
7
- import CopyButton_default from "./copy-button/CopyButton.js";
8
- import "./copy-button/index.js";
9
- import SearchInput_default from "./search-input/SearchInput.js";
10
- import "./search-input/index.js";
11
- import DataTablePlus_default from "./data-table-plus/DataTablePlus.js";
12
- import "./data-table-plus/index.js";
13
- import PresetInput_default from "./preset-input/PresetInput.js";
14
- import "./preset-input/index.js";
15
- import PresetForm_default from "./preset-form/PresetForm.js";
16
- import "./preset-form/index.js";
17
- import PresetPicker_default from "./preset-picker/PresetPicker.js";
18
- import "./preset-picker/index.js";
19
- import PresetSelect_default from "./preset-select/PresetSelect.js";
20
- import "./preset-select/index.js";
21
- import RemoteRequest_default from "./remote-request/RemoteRequest.js";
22
- import "./remote-request/index.js";
23
- import ToggleInput_default from "./toggle-input/ToggleInput.js";
24
- import "./toggle-input/index.js";
25
- import TooltipButton_default from "./tooltip-button/TooltipButton.js";
26
- import "./tooltip-button/index.js";
27
- import TypeWriter_default from "./type-writer/TypeWriter.js";
28
- import "./type-writer/index.js";
@@ -1 +0,0 @@
1
- import PresetForm_default from "./PresetForm.js";
@@ -1 +0,0 @@
1
- import PresetInput_default from "./PresetInput.js";
@@ -1 +0,0 @@
1
- import PresetPicker_default from "./PresetPicker.js";
@@ -1 +0,0 @@
1
- import PresetSelect_default from "./PresetSelect.js";
@@ -1 +0,0 @@
1
- import RemoteRequest_default from "./RemoteRequest.js";
@@ -1 +0,0 @@
1
- import SearchInput_default from "./SearchInput.js";
@@ -1 +0,0 @@
1
- import ToggleInput_default from "./ToggleInput.js";
@@ -1 +0,0 @@
1
- import TooltipButton_default from "./TooltipButton.js";
@@ -1 +0,0 @@
1
- import BaseTransition_default from "./BaseTransition.js";
@@ -1 +0,0 @@
1
- import TypeWriter_default from "./TypeWriter.js";
@@ -1,4 +0,0 @@
1
- import { useDataRequest } from "./useDataRequest.js";
2
- import { useLoading } from "./useLoading.js";
3
- import { useNaiveForm } from "./useNaiveForm.js";
4
- import { useNaiveTheme } from "./useNaiveTheme.js";
@@ -1,165 +0,0 @@
1
- import { Colors } from "./_helper.js";
2
- import { ComputedRef, Ref } from "vue";
3
- import { GlobalThemeOverrides, NDateLocale } from "naive-ui";
4
- import * as naive_ui_es_themes_interface0 from "naive-ui/es/themes/interface";
5
-
6
- //#region src/composables/useNaiveTheme.d.ts
7
- type NaiveThemeOptions = {
8
- language?: string | Ref<string>;
9
- darkMode?: boolean | Ref<boolean>;
10
- colors?: Colors;
11
- globalThemeOverrides?: GlobalThemeOverrides;
12
- };
13
- declare function useNaiveTheme(options?: NaiveThemeOptions): {
14
- language: Ref<string | undefined, string | undefined>;
15
- darkMode: Ref<boolean | undefined, boolean | undefined>;
16
- theme: ComputedRef<naive_ui_es_themes_interface0.BuiltInGlobalTheme | undefined>;
17
- themeOverrides: ComputedRef<GlobalThemeOverrides>;
18
- locale: ComputedRef<{
19
- name: string;
20
- global: {
21
- undo: string;
22
- redo: string;
23
- confirm: string;
24
- clear: string;
25
- };
26
- Popconfirm: {
27
- positiveText: string;
28
- negativeText: string;
29
- };
30
- Cascader: {
31
- placeholder: string;
32
- loading: string;
33
- loadingRequiredMessage: (label: string) => string;
34
- };
35
- Time: {
36
- dateFormat: string;
37
- dateTimeFormat: string;
38
- };
39
- DatePicker: {
40
- yearFormat: string;
41
- monthFormat: string;
42
- dayFormat: string;
43
- yearTypeFormat: string;
44
- monthTypeFormat: string;
45
- dateFormat: string;
46
- dateTimeFormat: string;
47
- quarterFormat: string;
48
- weekFormat: string;
49
- clear: string;
50
- now: string;
51
- confirm: string;
52
- selectTime: string;
53
- selectDate: string;
54
- datePlaceholder: string;
55
- datetimePlaceholder: string;
56
- monthPlaceholder: string;
57
- yearPlaceholder: string;
58
- quarterPlaceholder: string;
59
- weekPlaceholder: string;
60
- startDatePlaceholder: string;
61
- endDatePlaceholder: string;
62
- startDatetimePlaceholder: string;
63
- endDatetimePlaceholder: string;
64
- startMonthPlaceholder: string;
65
- endMonthPlaceholder: string;
66
- monthBeforeYear: boolean;
67
- firstDayOfWeek: 0 | 1 | 2 | 3 | 4 | 5 | 6;
68
- today: string;
69
- };
70
- DataTable: {
71
- checkTableAll: string;
72
- uncheckTableAll: string;
73
- confirm: string;
74
- clear: string;
75
- };
76
- LegacyTransfer: {
77
- sourceTitle: string;
78
- targetTitle: string;
79
- };
80
- Transfer: {
81
- selectAll: string;
82
- unselectAll: string;
83
- clearAll: string;
84
- total: (num: number) => string;
85
- selected: (num: number) => string;
86
- };
87
- Empty: {
88
- description: string;
89
- };
90
- Select: {
91
- placeholder: string;
92
- };
93
- TimePicker: {
94
- placeholder: string;
95
- positiveText: string;
96
- negativeText: string;
97
- now: string;
98
- clear: string;
99
- };
100
- Pagination: {
101
- goto: string;
102
- selectionSuffix: string;
103
- };
104
- DynamicTags: {
105
- add: string;
106
- };
107
- Log: {
108
- loading: string;
109
- };
110
- Input: {
111
- placeholder: string;
112
- };
113
- InputNumber: {
114
- placeholder: string;
115
- };
116
- DynamicInput: {
117
- create: string;
118
- };
119
- ThemeEditor: {
120
- title: string;
121
- clearAllVars: string;
122
- clearSearch: string;
123
- filterCompName: string;
124
- filterVarName: string;
125
- import: string;
126
- export: string;
127
- restore: string;
128
- };
129
- Image: {
130
- tipPrevious: string;
131
- tipNext: string;
132
- tipCounterclockwise: string;
133
- tipClockwise: string;
134
- tipZoomOut: string;
135
- tipZoomIn: string;
136
- tipDownload: string;
137
- tipClose: string;
138
- tipOriginalSize: string;
139
- };
140
- Heatmap: {
141
- less: string;
142
- more: string;
143
- monthFormat: string;
144
- weekdayFormat: string;
145
- };
146
- }>;
147
- dateLocale: ComputedRef<NDateLocale>;
148
- color: Ref<{
149
- primary?: string | undefined;
150
- info?: string | undefined;
151
- success?: string | undefined;
152
- warning?: string | undefined;
153
- error?: string | undefined;
154
- }, Colors | {
155
- primary?: string | undefined;
156
- info?: string | undefined;
157
- success?: string | undefined;
158
- warning?: string | undefined;
159
- error?: string | undefined;
160
- }>;
161
- setColor: (v: Partial<Colors>) => void;
162
- };
163
- type NaiveThemeReturns = ReturnType<typeof useNaiveTheme>;
164
- //#endregion
165
- export { NaiveThemeReturns, useNaiveTheme };
@@ -1,86 +0,0 @@
1
- import { getColors } from "./_helper.js";
2
- import { computed, ref, toValue, watchEffect } from "vue";
3
- import { darkTheme, dateEnUS, dateZhCN, enUS, zhCN } from "naive-ui";
4
-
5
- //#region src/composables/useNaiveTheme.ts
6
- const naiveLocaleMap = {
7
- "zh-CN": {
8
- name: "简体中文",
9
- dateLocale: dateZhCN,
10
- locale: zhCN
11
- },
12
- "en-US": {
13
- name: "English",
14
- dateLocale: dateEnUS,
15
- locale: enUS
16
- }
17
- };
18
- function useNaiveTheme(options) {
19
- const { language, darkMode, colors, globalThemeOverrides } = options ?? {};
20
- const languageRef = ref(toValue(language));
21
- watchEffect(() => {
22
- languageRef.value = toValue(language);
23
- });
24
- const darkModeRef = ref(toValue(darkMode));
25
- watchEffect(() => {
26
- darkModeRef.value = toValue(darkMode);
27
- });
28
- const { common, ...extra } = globalThemeOverrides ?? {};
29
- const colorRef = ref({ ...colors });
30
- function setColor(v) {
31
- colorRef.value = {
32
- ...colorRef.value,
33
- ...v
34
- };
35
- }
36
- return {
37
- language: languageRef,
38
- darkMode: darkModeRef,
39
- theme: computed(() => {
40
- return darkModeRef?.value ? darkTheme : void 0;
41
- }),
42
- themeOverrides: computed(() => {
43
- const { primary, info, success, warning, error } = getColors(colorRef.value);
44
- return {
45
- common: {
46
- bodyColor: darkModeRef?.value ? "#1f1f1f" : "#f5f5f5",
47
- primaryColor: primary?.color,
48
- primaryColorHover: primary?.hover,
49
- primaryColorPressed: primary?.pressed,
50
- primaryColorSuppl: primary?.suppl,
51
- infoColor: info?.color,
52
- infoColorHover: info?.hover,
53
- infoColorPressed: info?.pressed,
54
- infoColorSuppl: info?.suppl,
55
- successColor: success?.color,
56
- successColorHover: success?.hover,
57
- successColorPressed: success?.pressed,
58
- successColorSuppl: success?.suppl,
59
- warningColor: warning?.color,
60
- warningColorHover: warning?.hover,
61
- warningColorPressed: warning?.pressed,
62
- warningColorSuppl: warning?.suppl,
63
- errorColor: error?.color,
64
- errorColorHover: error?.hover,
65
- errorColorPressed: error?.pressed,
66
- errorColorSuppl: error?.suppl,
67
- ...common
68
- },
69
- ...extra
70
- };
71
- }),
72
- locale: computed(() => {
73
- if (!languageRef?.value || !naiveLocaleMap[languageRef.value]) return naiveLocaleMap["zh-CN"].locale;
74
- return naiveLocaleMap[languageRef.value].locale;
75
- }),
76
- dateLocale: computed(() => {
77
- if (!languageRef?.value || !naiveLocaleMap[languageRef.value]) return naiveLocaleMap["zh-CN"].dateLocale;
78
- return naiveLocaleMap[languageRef.value].dateLocale;
79
- }),
80
- color: colorRef,
81
- setColor
82
- };
83
- }
84
-
85
- //#endregion
86
- export { useNaiveTheme };