@oiij/naive-ui 0.0.68 → 0.0.70

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 (45) hide show
  1. package/dist/components/config-providers/ConfigProviders.js +1 -1
  2. package/dist/components/config-providers/ConfigProviders.vue.d.ts +3 -24
  3. package/dist/components/config-providers/index.d.ts +2 -2
  4. package/dist/components/copy-button/CopyButton.vue.d.ts +5 -18
  5. package/dist/components/data-table-plus/DataTablePlus.js +1 -1
  6. package/dist/components/data-table-plus/DataTablePlus.vue.d.ts +58 -114
  7. package/dist/components/data-table-plus/index.d.ts +1 -1
  8. package/dist/components/index.d.ts +1 -1
  9. package/dist/components/loading-provider/LoadingProvider.vue.d.ts +3 -19
  10. package/dist/components/preset-form/PresetForm.js +1 -1
  11. package/dist/components/preset-form/PresetForm.vue.d.ts +19 -19
  12. package/dist/components/preset-form/index.d.ts +2 -2
  13. package/dist/components/preset-input/PresetInput.vue.d.ts +3 -3
  14. package/dist/components/preset-picker/PresetPicker.vue.d.ts +5 -5
  15. package/dist/components/preset-picker/index.d.ts +1 -1
  16. package/dist/components/preset-select/PresetSelect.js +1 -1
  17. package/dist/components/preset-select/PresetSelect.vue.d.ts +32 -52
  18. package/dist/components/preset-select/index.d.ts +1 -1
  19. package/dist/components/remote-request/RemoteRequest.js +1 -1
  20. package/dist/components/remote-request/RemoteRequest.vue.d.ts +6 -10
  21. package/dist/components/remote-request/index.d.ts +1 -1
  22. package/dist/components/search-input/SearchInput.js +2 -2
  23. package/dist/components/search-input/SearchInput.vue.d.ts +5 -25
  24. package/dist/components/toggle-input/ToggleInput.vue.d.ts +1 -1
  25. package/dist/components/tooltip-button/TooltipButton.vue.d.ts +3 -13
  26. package/dist/components/transition/BaseTransition.vue.d.ts +3 -10
  27. package/dist/components/type-writer/TypeWriter.vue.d.ts +5 -18
  28. package/dist/components.d.ts +1 -1
  29. package/dist/composables/_helper.js +7 -1
  30. package/dist/composables/index.d.ts +4 -4
  31. package/dist/composables/index.js +4 -4
  32. package/dist/composables/{useDataRequest.d.ts → use-data-request.d.ts} +9 -13
  33. package/dist/composables/{useDataRequest.js → use-data-request.js} +1 -1
  34. package/dist/composables/use-loading.d.ts +6 -0
  35. package/dist/composables/{useLoading.js → use-loading.js} +1 -1
  36. package/dist/composables/{useNaiveForm.d.ts → use-naive-form.d.ts} +8 -8
  37. package/dist/composables/{useNaiveForm.js → use-naive-form.js} +1 -1
  38. package/dist/composables/use-naive-theme.d.ts +52 -0
  39. package/dist/composables/use-naive-theme.js +89 -0
  40. package/dist/index.d.ts +5 -5
  41. package/dist/index.js +4 -4
  42. package/package.json +7 -7
  43. package/dist/composables/useLoading.d.ts +0 -10
  44. package/dist/composables/useNaiveTheme.d.ts +0 -171
  45. package/dist/composables/useNaiveTheme.js +0 -86
@@ -0,0 +1,52 @@
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
+ };
19
+ declare function useNaiveTheme<T extends string>(options?: NaiveThemeOptions<T>): {
20
+ language: Ref<T, T>;
21
+ darkMode: Ref<boolean | undefined, boolean | undefined>;
22
+ theme: ComputedRef<naive_ui_es_themes_interface0.BuiltInGlobalTheme | undefined>;
23
+ colors: Ref<{
24
+ primary?: string | undefined;
25
+ info?: string | undefined;
26
+ success?: string | undefined;
27
+ warning?: string | undefined;
28
+ error?: string | undefined;
29
+ }, Colors | {
30
+ primary?: string | undefined;
31
+ info?: string | undefined;
32
+ success?: string | undefined;
33
+ warning?: string | undefined;
34
+ error?: string | undefined;
35
+ }>;
36
+ themeColors: ComputedRef<{
37
+ primary?: string | undefined;
38
+ info?: string | undefined;
39
+ success?: string | undefined;
40
+ warning?: string | undefined;
41
+ error?: string | undefined;
42
+ } | {
43
+ [k: string]: string | undefined;
44
+ }>;
45
+ themeOverrides: ComputedRef<GlobalThemeOverrides>;
46
+ locales: Locales<T>;
47
+ locale: ComputedRef<Locales<T>[T]>;
48
+ setColor: (v: Partial<Colors>) => void;
49
+ };
50
+ type NaiveThemeReturns = ReturnType<typeof useNaiveTheme>;
51
+ //#endregion
52
+ export { NaiveThemeOptions, NaiveThemeReturns, useNaiveTheme };
@@ -0,0 +1,89 @@
1
+ import { getColors, getDarkColor } 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 } = 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
+ return darkModeRef.value ? Object.fromEntries(Object.entries(colorsRef.value).map(([k, v]) => [k, getDarkColor(v)])) : colorsRef.value;
32
+ });
33
+ function setColor(v) {
34
+ colorsRef.value = {
35
+ ...colorsRef.value,
36
+ ...v
37
+ };
38
+ }
39
+ const theme = computed(() => {
40
+ return darkModeRef?.value ? darkTheme : void 0;
41
+ });
42
+ const themeOverrides = computed(() => {
43
+ const { primary, info, success, warning, error } = getColors(themeColorsRef.value);
44
+ return {
45
+ common: {
46
+ primaryColor: primary?.color,
47
+ primaryColorHover: primary?.hover,
48
+ primaryColorPressed: primary?.pressed,
49
+ primaryColorSuppl: primary?.suppl,
50
+ infoColor: info?.color,
51
+ infoColorHover: info?.hover,
52
+ infoColorPressed: info?.pressed,
53
+ infoColorSuppl: info?.suppl,
54
+ successColor: success?.color,
55
+ successColorHover: success?.hover,
56
+ successColorPressed: success?.pressed,
57
+ successColorSuppl: success?.suppl,
58
+ warningColor: warning?.color,
59
+ warningColorHover: warning?.hover,
60
+ warningColorPressed: warning?.pressed,
61
+ warningColorSuppl: warning?.suppl,
62
+ errorColor: error?.color,
63
+ errorColorHover: error?.hover,
64
+ errorColorPressed: error?.pressed,
65
+ errorColorSuppl: error?.suppl,
66
+ ...common
67
+ },
68
+ ...extra
69
+ };
70
+ });
71
+ const _locales = {
72
+ ...naiveLocaleMap,
73
+ ...locales
74
+ };
75
+ return {
76
+ language: languageRef,
77
+ darkMode: darkModeRef,
78
+ theme,
79
+ colors: colorsRef,
80
+ themeColors: themeColorsRef,
81
+ themeOverrides,
82
+ locales: _locales,
83
+ locale: computed(() => _locales[languageRef.value] ?? naiveLocaleMap["zh-CN"]),
84
+ setColor
85
+ };
86
+ }
87
+
88
+ //#endregion
89
+ 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,7 @@
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";
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";
5
5
  import "./composables/index.js";
6
6
 
7
7
  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.68",
4
+ "version": "0.0.70",
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/markdown-it": "0.0.10",
49
- "@oiij/css-render": "0.0.8",
50
- "@oiij/use": "0.0.30"
48
+ "@oiij/css-render": "0.0.9",
49
+ "@oiij/use": "0.0.37",
50
+ "@oiij/markdown-it": "0.0.10"
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/markdown-it": "0.0.10",
64
- "@oiij/css-render": "0.0.8",
65
- "@oiij/use": "0.0.30"
63
+ "@oiij/css-render": "0.0.9",
64
+ "@oiij/use": "0.0.37",
65
+ "@oiij/markdown-it": "0.0.10"
66
66
  },
67
67
  "publishConfig": {
68
68
  "access": "public"
@@ -1,10 +0,0 @@
1
- //#region src/composables/useLoading.d.ts
2
- declare function useLoading(): {
3
- show: (options?: {
4
- text?: string;
5
- duration?: number;
6
- }) => void;
7
- hide: () => void;
8
- } | undefined;
9
- //#endregion
10
- export { useLoading };
@@ -1,171 +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
- interface 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
- }, {
155
- primary?: string;
156
- info?: string;
157
- success?: string;
158
- warning?: string;
159
- error?: string;
160
- } | {
161
- primary?: string | undefined;
162
- info?: string | undefined;
163
- success?: string | undefined;
164
- warning?: string | undefined;
165
- error?: string | undefined;
166
- }>;
167
- setColor: (v: Partial<Colors>) => void;
168
- };
169
- type NaiveThemeReturns = ReturnType<typeof useNaiveTheme>;
170
- //#endregion
171
- 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 };