@oiij/naive-ui 0.0.59 → 0.0.61
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/data-table-plus/index.d.ts +5 -1
- package/dist/components/icons/MageArrowUp.vue.d.ts +2 -0
- package/dist/components.cjs +23 -23
- package/dist/components.js +3027 -2843
- package/dist/components.umd.cjs +25 -25
- package/dist/composables/_helper.cjs +29 -0
- package/dist/composables/_helper.d.cts +10 -0
- package/dist/composables/_helper.d.ts +10 -0
- package/dist/composables/_helper.js +27 -0
- package/dist/composables/useDataRequest.d.ts +7 -7
- package/dist/composables/useNaiveForm.cjs +4 -2
- package/dist/composables/useNaiveForm.d.ts +5 -5
- package/dist/composables/useNaiveForm.js +3 -2
- package/dist/composables/useNaiveTheme.cjs +29 -59
- package/dist/composables/useNaiveTheme.d.cts +20 -20
- package/dist/composables/useNaiveTheme.d.ts +20 -20
- package/dist/composables/useNaiveTheme.js +28 -57
- package/package.json +7 -5
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
let colord = require("colord");
|
|
3
|
+
colord = require_rolldown_runtime.__toESM(colord);
|
|
4
|
+
|
|
5
|
+
//#region src/composables/_helper.ts
|
|
6
|
+
function getStatusColor(color) {
|
|
7
|
+
if (!color) return void 0;
|
|
8
|
+
const baseColor = (0, colord.colord)(color);
|
|
9
|
+
if (!baseColor.isValid()) return void 0;
|
|
10
|
+
return {
|
|
11
|
+
color,
|
|
12
|
+
hover: baseColor.lighten(.1).toHex(),
|
|
13
|
+
pressed: baseColor.darken(.1).toHex(),
|
|
14
|
+
suppl: baseColor.lighten(.1).toHex()
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
function getColors(colors) {
|
|
18
|
+
const { primary, info, success, warning, error } = colors ?? {};
|
|
19
|
+
return {
|
|
20
|
+
primary: getStatusColor(primary),
|
|
21
|
+
info: getStatusColor(info),
|
|
22
|
+
success: getStatusColor(success),
|
|
23
|
+
warning: getStatusColor(warning),
|
|
24
|
+
error: getStatusColor(error)
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
//#endregion
|
|
29
|
+
exports.getColors = getColors;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { colord } from "colord";
|
|
2
|
+
|
|
3
|
+
//#region src/composables/_helper.ts
|
|
4
|
+
function getStatusColor(color) {
|
|
5
|
+
if (!color) return void 0;
|
|
6
|
+
const baseColor = colord(color);
|
|
7
|
+
if (!baseColor.isValid()) return void 0;
|
|
8
|
+
return {
|
|
9
|
+
color,
|
|
10
|
+
hover: baseColor.lighten(.1).toHex(),
|
|
11
|
+
pressed: baseColor.darken(.1).toHex(),
|
|
12
|
+
suppl: baseColor.lighten(.1).toHex()
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
function getColors(colors) {
|
|
16
|
+
const { primary, info, success, warning, error } = colors ?? {};
|
|
17
|
+
return {
|
|
18
|
+
primary: getStatusColor(primary),
|
|
19
|
+
info: getStatusColor(info),
|
|
20
|
+
success: getStatusColor(success),
|
|
21
|
+
warning: getStatusColor(warning),
|
|
22
|
+
error: getStatusColor(error)
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
//#endregion
|
|
27
|
+
export { getColors };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _vueuse_core0 from "@vueuse/core";
|
|
2
|
-
import * as
|
|
2
|
+
import * as vue0 from "vue";
|
|
3
3
|
import { UseRequestOptions, UseRequestPlugin } from "vue-hooks-plus/es/useRequest/types";
|
|
4
4
|
|
|
5
5
|
//#region src/composables/useDataRequest.d.ts
|
|
@@ -24,12 +24,12 @@ type UseDataRequestPagination = {
|
|
|
24
24
|
itemCount: number;
|
|
25
25
|
};
|
|
26
26
|
declare function useDataRequest<P extends DataObject = DataObject, D extends DataObject = DataObject, R extends DataObject = DataObject>(api: (...args: P[]) => Promise<D>, options?: UseDataRequestOptions<P, D>): {
|
|
27
|
-
loading: Readonly<
|
|
28
|
-
data: Readonly<
|
|
29
|
-
error: Readonly<
|
|
30
|
-
params: Readonly<
|
|
31
|
-
list:
|
|
32
|
-
pagination:
|
|
27
|
+
loading: Readonly<vue0.Ref<boolean, boolean>>;
|
|
28
|
+
data: Readonly<vue0.Ref<D | undefined, D | undefined>>;
|
|
29
|
+
error: Readonly<vue0.Ref<Error | undefined, Error | undefined>>;
|
|
30
|
+
params: Readonly<vue0.Ref<[] | P[], [] | P[]>>;
|
|
31
|
+
list: vue0.ComputedRef<R[]>;
|
|
32
|
+
pagination: vue0.Ref<{
|
|
33
33
|
page: number;
|
|
34
34
|
pageSize: number;
|
|
35
35
|
itemCount: number;
|
|
@@ -3,6 +3,8 @@ let __vueuse_core = require("@vueuse/core");
|
|
|
3
3
|
__vueuse_core = require_rolldown_runtime.__toESM(__vueuse_core);
|
|
4
4
|
let vue = require("vue");
|
|
5
5
|
vue = require_rolldown_runtime.__toESM(vue);
|
|
6
|
+
let es_toolkit_object = require("es-toolkit/object");
|
|
7
|
+
es_toolkit_object = require_rolldown_runtime.__toESM(es_toolkit_object);
|
|
6
8
|
|
|
7
9
|
//#region src/composables/useNaiveForm.ts
|
|
8
10
|
function isObject(value) {
|
|
@@ -34,7 +36,7 @@ function deepMerge(target = {}, source = {}) {
|
|
|
34
36
|
}
|
|
35
37
|
function useNaiveForm(value, options) {
|
|
36
38
|
const { rules, clearRules } = options ?? {};
|
|
37
|
-
const cacheValue =
|
|
39
|
+
const cacheValue = (0, es_toolkit_object.cloneDeep)((0, vue.toValue)(value));
|
|
38
40
|
const formValue = (0, vue.ref)((0, vue.toValue)(value ?? {}));
|
|
39
41
|
const formRules = (0, vue.ref)((0, vue.toValue)(rules) ?? {});
|
|
40
42
|
const formRef = (0, vue.ref)();
|
|
@@ -64,7 +66,7 @@ function useNaiveForm(value, options) {
|
|
|
64
66
|
}
|
|
65
67
|
function resetForm() {
|
|
66
68
|
clear();
|
|
67
|
-
const _cacheValue =
|
|
69
|
+
const _cacheValue = (0, es_toolkit_object.cloneDeep)(cacheValue);
|
|
68
70
|
deepMerge(formValue.value, _cacheValue);
|
|
69
71
|
}
|
|
70
72
|
function reset() {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DataObject } from "./useDataRequest.js";
|
|
2
|
-
import * as
|
|
3
|
-
import * as
|
|
2
|
+
import * as _vueuse_core3 from "@vueuse/core";
|
|
3
|
+
import * as vue5 from "vue";
|
|
4
4
|
import { Ref } from "vue";
|
|
5
5
|
import { FormInst, FormItemRule, FormRules } from "naive-ui";
|
|
6
6
|
import { ValidateError } from "async-validator";
|
|
@@ -22,8 +22,8 @@ declare function useNaiveForm<T extends DataObject = DataObject>(value?: T | Ref
|
|
|
22
22
|
formRules: Ref<Partial<Record<keyof T, FormRules | FormItemRule | FormItemRule[]>>, Partial<Record<keyof T, FormRules | FormItemRule | FormItemRule[]>>>;
|
|
23
23
|
formProps: {
|
|
24
24
|
ref: Ref<FormInst | undefined, FormInst | undefined>;
|
|
25
|
-
model:
|
|
26
|
-
rules:
|
|
25
|
+
model: vue5.Reactive<T>;
|
|
26
|
+
rules: vue5.Reactive<Partial<Record<keyof T, FormRules | FormItemRule | FormItemRule[]>>>;
|
|
27
27
|
};
|
|
28
28
|
setValue: (_value: Partial<T>) => void;
|
|
29
29
|
validate: () => Promise<{
|
|
@@ -33,7 +33,7 @@ declare function useNaiveForm<T extends DataObject = DataObject>(value?: T | Ref
|
|
|
33
33
|
resetForm: () => void;
|
|
34
34
|
reset: () => void;
|
|
35
35
|
clear: () => void;
|
|
36
|
-
onValidated:
|
|
36
|
+
onValidated: _vueuse_core3.EventHookOn<[T]>;
|
|
37
37
|
};
|
|
38
38
|
type NaiveFormReturns<T extends DataObject = DataObject> = ReturnType<typeof useNaiveForm<T>>;
|
|
39
39
|
//#endregion
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createEventHook } from "@vueuse/core";
|
|
2
2
|
import { reactive, ref, toRaw, toValue } from "vue";
|
|
3
|
+
import { cloneDeep } from "es-toolkit/object";
|
|
3
4
|
|
|
4
5
|
//#region src/composables/useNaiveForm.ts
|
|
5
6
|
function isObject(value) {
|
|
@@ -31,7 +32,7 @@ function deepMerge(target = {}, source = {}) {
|
|
|
31
32
|
}
|
|
32
33
|
function useNaiveForm(value, options) {
|
|
33
34
|
const { rules, clearRules } = options ?? {};
|
|
34
|
-
const cacheValue =
|
|
35
|
+
const cacheValue = cloneDeep(toValue(value));
|
|
35
36
|
const formValue = ref(toValue(value ?? {}));
|
|
36
37
|
const formRules = ref(toValue(rules) ?? {});
|
|
37
38
|
const formRef = ref();
|
|
@@ -61,7 +62,7 @@ function useNaiveForm(value, options) {
|
|
|
61
62
|
}
|
|
62
63
|
function resetForm() {
|
|
63
64
|
clear();
|
|
64
|
-
const _cacheValue =
|
|
65
|
+
const _cacheValue = cloneDeep(cacheValue);
|
|
65
66
|
deepMerge(formValue.value, _cacheValue);
|
|
66
67
|
}
|
|
67
68
|
function reset() {
|
|
@@ -1,20 +1,11 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require__helper = require('./_helper.cjs');
|
|
2
3
|
let vue = require("vue");
|
|
3
4
|
vue = require_rolldown_runtime.__toESM(vue);
|
|
4
|
-
let colord = require("colord");
|
|
5
|
-
colord = require_rolldown_runtime.__toESM(colord);
|
|
6
5
|
let naive_ui = require("naive-ui");
|
|
7
6
|
naive_ui = require_rolldown_runtime.__toESM(naive_ui);
|
|
8
7
|
|
|
9
8
|
//#region src/composables/useNaiveTheme.ts
|
|
10
|
-
function getStatusColor(color = "#ff461f") {
|
|
11
|
-
return {
|
|
12
|
-
color,
|
|
13
|
-
hover: (0, colord.colord)(color).lighten(.1).toHex(),
|
|
14
|
-
pressed: (0, colord.colord)(color).darken(.1).toHex(),
|
|
15
|
-
suppl: (0, colord.colord)(color).lighten(.1).toHex()
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
9
|
const naiveLocaleMap = {
|
|
19
10
|
"zh-CN": {
|
|
20
11
|
name: "简体中文",
|
|
@@ -27,18 +18,8 @@ const naiveLocaleMap = {
|
|
|
27
18
|
locale: naive_ui.enUS
|
|
28
19
|
}
|
|
29
20
|
};
|
|
30
|
-
function getColors(color) {
|
|
31
|
-
const { primary, info, success, warning, error } = color;
|
|
32
|
-
return {
|
|
33
|
-
primary: getStatusColor(primary),
|
|
34
|
-
info: getStatusColor(info),
|
|
35
|
-
success: getStatusColor(success),
|
|
36
|
-
warning: getStatusColor(warning),
|
|
37
|
-
error: getStatusColor(error)
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
21
|
function useNaiveTheme(options) {
|
|
41
|
-
const { language, darkMode,
|
|
22
|
+
const { language, darkMode, colors, globalThemeOverrides } = options ?? {};
|
|
42
23
|
const languageRef = (0, vue.ref)((0, vue.toValue)(language));
|
|
43
24
|
(0, vue.watchEffect)(() => {
|
|
44
25
|
languageRef.value = (0, vue.toValue)(language);
|
|
@@ -47,55 +28,44 @@ function useNaiveTheme(options) {
|
|
|
47
28
|
(0, vue.watchEffect)(() => {
|
|
48
29
|
darkModeRef.value = (0, vue.toValue)(darkMode);
|
|
49
30
|
});
|
|
50
|
-
const { common
|
|
51
|
-
const colorRef = (0, vue.ref)({
|
|
52
|
-
primary: "#64748B",
|
|
53
|
-
info: "#06b6d4",
|
|
54
|
-
success: "#10b981",
|
|
55
|
-
warning: "#fbbf24",
|
|
56
|
-
error: "#f43f5e",
|
|
57
|
-
...color
|
|
58
|
-
});
|
|
31
|
+
const { common,...extra } = globalThemeOverrides ?? {};
|
|
32
|
+
const colorRef = (0, vue.ref)({ ...colors });
|
|
59
33
|
function setColor(v) {
|
|
60
|
-
colorRef.value =
|
|
34
|
+
colorRef.value = {
|
|
35
|
+
...colorRef.value,
|
|
36
|
+
...v
|
|
37
|
+
};
|
|
61
38
|
}
|
|
62
39
|
const theme = (0, vue.computed)(() => {
|
|
63
40
|
return darkModeRef?.value ? naive_ui.darkTheme : void 0;
|
|
64
41
|
});
|
|
65
42
|
const themeOverrides = (0, vue.computed)(() => {
|
|
66
|
-
const { primary, info, success, warning, error } = getColors(colorRef.value);
|
|
43
|
+
const { primary, info, success, warning, error } = require__helper.getColors(colorRef.value);
|
|
67
44
|
return {
|
|
68
45
|
common: {
|
|
69
46
|
bodyColor: darkModeRef?.value ? "#1f1f1f" : "#f5f5f5",
|
|
70
|
-
primaryColor: primary
|
|
71
|
-
primaryColorHover: primary
|
|
72
|
-
primaryColorPressed: primary
|
|
73
|
-
primaryColorSuppl: primary
|
|
74
|
-
infoColor: info
|
|
75
|
-
infoColorHover: info
|
|
76
|
-
infoColorPressed: info
|
|
77
|
-
infoColorSuppl: info
|
|
78
|
-
successColor: success
|
|
79
|
-
successColorHover: success
|
|
80
|
-
successColorPressed: success
|
|
81
|
-
successColorSuppl: success
|
|
82
|
-
warningColor: warning
|
|
83
|
-
warningColorHover: warning
|
|
84
|
-
warningColorPressed: warning
|
|
85
|
-
warningColorSuppl: warning
|
|
86
|
-
errorColor: error
|
|
87
|
-
errorColorHover: error
|
|
88
|
-
errorColorPressed: error
|
|
89
|
-
errorColorSuppl: error
|
|
90
|
-
borderRadius: "6px",
|
|
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,
|
|
91
67
|
...common
|
|
92
68
|
},
|
|
93
|
-
Dialog: {
|
|
94
|
-
borderRadius: "12px",
|
|
95
|
-
padding: "20px",
|
|
96
|
-
closeMargin: "20px 20px 0 0",
|
|
97
|
-
...Dialog
|
|
98
|
-
},
|
|
99
69
|
...extra
|
|
100
70
|
};
|
|
101
71
|
});
|
|
@@ -1,19 +1,13 @@
|
|
|
1
|
+
import { Colors } from "./_helper.cjs";
|
|
1
2
|
import { ComputedRef, Ref } from "vue";
|
|
2
3
|
import { GlobalThemeOverrides, NDateLocale } from "naive-ui";
|
|
3
4
|
import * as naive_ui_es_themes_interface0 from "naive-ui/es/themes/interface";
|
|
4
5
|
|
|
5
6
|
//#region src/composables/useNaiveTheme.d.ts
|
|
6
|
-
interface Color {
|
|
7
|
-
primary: string;
|
|
8
|
-
info: string;
|
|
9
|
-
success: string;
|
|
10
|
-
warning: string;
|
|
11
|
-
error: string;
|
|
12
|
-
}
|
|
13
7
|
interface NaiveThemeOptions {
|
|
14
8
|
language?: string | Ref<string>;
|
|
15
9
|
darkMode?: boolean | Ref<boolean>;
|
|
16
|
-
|
|
10
|
+
colors?: Colors;
|
|
17
11
|
globalThemeOverrides?: GlobalThemeOverrides;
|
|
18
12
|
}
|
|
19
13
|
declare function useNaiveTheme(options?: NaiveThemeOptions): {
|
|
@@ -152,19 +146,25 @@ declare function useNaiveTheme(options?: NaiveThemeOptions): {
|
|
|
152
146
|
}>;
|
|
153
147
|
dateLocale: ComputedRef<NDateLocale>;
|
|
154
148
|
color: Ref<{
|
|
155
|
-
primary
|
|
156
|
-
info
|
|
157
|
-
success
|
|
158
|
-
warning
|
|
159
|
-
error
|
|
160
|
-
},
|
|
161
|
-
primary
|
|
162
|
-
info
|
|
163
|
-
success
|
|
164
|
-
warning
|
|
165
|
-
error
|
|
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
166
|
}>;
|
|
167
|
-
setColor: (v:
|
|
167
|
+
setColor: (v: Partial<Colors>) => void;
|
|
168
168
|
};
|
|
169
169
|
type NaiveThemeReturns = ReturnType<typeof useNaiveTheme>;
|
|
170
170
|
//#endregion
|
|
@@ -1,19 +1,13 @@
|
|
|
1
|
+
import { Colors } from "./_helper.js";
|
|
1
2
|
import { ComputedRef, Ref } from "vue";
|
|
2
3
|
import { GlobalThemeOverrides, NDateLocale } from "naive-ui";
|
|
3
4
|
import * as naive_ui_es_themes_interface0 from "naive-ui/es/themes/interface";
|
|
4
5
|
|
|
5
6
|
//#region src/composables/useNaiveTheme.d.ts
|
|
6
|
-
interface Color {
|
|
7
|
-
primary: string;
|
|
8
|
-
info: string;
|
|
9
|
-
success: string;
|
|
10
|
-
warning: string;
|
|
11
|
-
error: string;
|
|
12
|
-
}
|
|
13
7
|
interface NaiveThemeOptions {
|
|
14
8
|
language?: string | Ref<string>;
|
|
15
9
|
darkMode?: boolean | Ref<boolean>;
|
|
16
|
-
|
|
10
|
+
colors?: Colors;
|
|
17
11
|
globalThemeOverrides?: GlobalThemeOverrides;
|
|
18
12
|
}
|
|
19
13
|
declare function useNaiveTheme(options?: NaiveThemeOptions): {
|
|
@@ -152,19 +146,25 @@ declare function useNaiveTheme(options?: NaiveThemeOptions): {
|
|
|
152
146
|
}>;
|
|
153
147
|
dateLocale: ComputedRef<NDateLocale>;
|
|
154
148
|
color: Ref<{
|
|
155
|
-
primary
|
|
156
|
-
info
|
|
157
|
-
success
|
|
158
|
-
warning
|
|
159
|
-
error
|
|
160
|
-
},
|
|
161
|
-
primary
|
|
162
|
-
info
|
|
163
|
-
success
|
|
164
|
-
warning
|
|
165
|
-
error
|
|
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
166
|
}>;
|
|
167
|
-
setColor: (v:
|
|
167
|
+
setColor: (v: Partial<Colors>) => void;
|
|
168
168
|
};
|
|
169
169
|
type NaiveThemeReturns = ReturnType<typeof useNaiveTheme>;
|
|
170
170
|
//#endregion
|
|
@@ -1,16 +1,8 @@
|
|
|
1
|
+
import { getColors } from "./_helper.js";
|
|
1
2
|
import { computed, ref, toValue, watchEffect } from "vue";
|
|
2
|
-
import { colord } from "colord";
|
|
3
3
|
import { darkTheme, dateEnUS, dateZhCN, enUS, zhCN } from "naive-ui";
|
|
4
4
|
|
|
5
5
|
//#region src/composables/useNaiveTheme.ts
|
|
6
|
-
function getStatusColor(color = "#ff461f") {
|
|
7
|
-
return {
|
|
8
|
-
color,
|
|
9
|
-
hover: colord(color).lighten(.1).toHex(),
|
|
10
|
-
pressed: colord(color).darken(.1).toHex(),
|
|
11
|
-
suppl: colord(color).lighten(.1).toHex()
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
6
|
const naiveLocaleMap = {
|
|
15
7
|
"zh-CN": {
|
|
16
8
|
name: "简体中文",
|
|
@@ -23,18 +15,8 @@ const naiveLocaleMap = {
|
|
|
23
15
|
locale: enUS
|
|
24
16
|
}
|
|
25
17
|
};
|
|
26
|
-
function getColors(color) {
|
|
27
|
-
const { primary, info, success, warning, error } = color;
|
|
28
|
-
return {
|
|
29
|
-
primary: getStatusColor(primary),
|
|
30
|
-
info: getStatusColor(info),
|
|
31
|
-
success: getStatusColor(success),
|
|
32
|
-
warning: getStatusColor(warning),
|
|
33
|
-
error: getStatusColor(error)
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
18
|
function useNaiveTheme(options) {
|
|
37
|
-
const { language, darkMode,
|
|
19
|
+
const { language, darkMode, colors, globalThemeOverrides } = options ?? {};
|
|
38
20
|
const languageRef = ref(toValue(language));
|
|
39
21
|
watchEffect(() => {
|
|
40
22
|
languageRef.value = toValue(language);
|
|
@@ -43,17 +25,13 @@ function useNaiveTheme(options) {
|
|
|
43
25
|
watchEffect(() => {
|
|
44
26
|
darkModeRef.value = toValue(darkMode);
|
|
45
27
|
});
|
|
46
|
-
const { common
|
|
47
|
-
const colorRef = ref({
|
|
48
|
-
primary: "#64748B",
|
|
49
|
-
info: "#06b6d4",
|
|
50
|
-
success: "#10b981",
|
|
51
|
-
warning: "#fbbf24",
|
|
52
|
-
error: "#f43f5e",
|
|
53
|
-
...color
|
|
54
|
-
});
|
|
28
|
+
const { common,...extra } = globalThemeOverrides ?? {};
|
|
29
|
+
const colorRef = ref({ ...colors });
|
|
55
30
|
function setColor(v) {
|
|
56
|
-
colorRef.value =
|
|
31
|
+
colorRef.value = {
|
|
32
|
+
...colorRef.value,
|
|
33
|
+
...v
|
|
34
|
+
};
|
|
57
35
|
}
|
|
58
36
|
const theme = computed(() => {
|
|
59
37
|
return darkModeRef?.value ? darkTheme : void 0;
|
|
@@ -63,35 +41,28 @@ function useNaiveTheme(options) {
|
|
|
63
41
|
return {
|
|
64
42
|
common: {
|
|
65
43
|
bodyColor: darkModeRef?.value ? "#1f1f1f" : "#f5f5f5",
|
|
66
|
-
primaryColor: primary
|
|
67
|
-
primaryColorHover: primary
|
|
68
|
-
primaryColorPressed: primary
|
|
69
|
-
primaryColorSuppl: primary
|
|
70
|
-
infoColor: info
|
|
71
|
-
infoColorHover: info
|
|
72
|
-
infoColorPressed: info
|
|
73
|
-
infoColorSuppl: info
|
|
74
|
-
successColor: success
|
|
75
|
-
successColorHover: success
|
|
76
|
-
successColorPressed: success
|
|
77
|
-
successColorSuppl: success
|
|
78
|
-
warningColor: warning
|
|
79
|
-
warningColorHover: warning
|
|
80
|
-
warningColorPressed: warning
|
|
81
|
-
warningColorSuppl: warning
|
|
82
|
-
errorColor: error
|
|
83
|
-
errorColorHover: error
|
|
84
|
-
errorColorPressed: error
|
|
85
|
-
errorColorSuppl: error
|
|
86
|
-
borderRadius: "6px",
|
|
44
|
+
primaryColor: primary?.color,
|
|
45
|
+
primaryColorHover: primary?.hover,
|
|
46
|
+
primaryColorPressed: primary?.pressed,
|
|
47
|
+
primaryColorSuppl: primary?.suppl,
|
|
48
|
+
infoColor: info?.color,
|
|
49
|
+
infoColorHover: info?.hover,
|
|
50
|
+
infoColorPressed: info?.pressed,
|
|
51
|
+
infoColorSuppl: info?.suppl,
|
|
52
|
+
successColor: success?.color,
|
|
53
|
+
successColorHover: success?.hover,
|
|
54
|
+
successColorPressed: success?.pressed,
|
|
55
|
+
successColorSuppl: success?.suppl,
|
|
56
|
+
warningColor: warning?.color,
|
|
57
|
+
warningColorHover: warning?.hover,
|
|
58
|
+
warningColorPressed: warning?.pressed,
|
|
59
|
+
warningColorSuppl: warning?.suppl,
|
|
60
|
+
errorColor: error?.color,
|
|
61
|
+
errorColorHover: error?.hover,
|
|
62
|
+
errorColorPressed: error?.pressed,
|
|
63
|
+
errorColorSuppl: error?.suppl,
|
|
87
64
|
...common
|
|
88
65
|
},
|
|
89
|
-
Dialog: {
|
|
90
|
-
borderRadius: "12px",
|
|
91
|
-
padding: "20px",
|
|
92
|
-
closeMargin: "20px 20px 0 0",
|
|
93
|
-
...Dialog
|
|
94
|
-
},
|
|
95
66
|
...extra
|
|
96
67
|
};
|
|
97
68
|
});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oiij/naive-ui",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.61",
|
|
5
5
|
"description": "Some Composable Functions And Components for Vue 3",
|
|
6
6
|
"author": "oiij",
|
|
7
7
|
"license": "MIT",
|
|
@@ -41,27 +41,29 @@
|
|
|
41
41
|
"@vueuse/core": "^13.9.0",
|
|
42
42
|
"async-validator": "^4.2.5",
|
|
43
43
|
"colord": "^2.9.3",
|
|
44
|
+
"es-toolkit": "^1.39.10",
|
|
44
45
|
"naive-ui": "^2.43.1",
|
|
45
46
|
"prismjs": "^1.30.0",
|
|
46
47
|
"vue": "^3.5.21",
|
|
47
48
|
"vue-hooks-plus": "^2.4.1",
|
|
49
|
+
"@oiij/use": "0.0.24",
|
|
48
50
|
"@oiij/css-render": "0.0.4",
|
|
49
|
-
"@oiij/markdown-it": "0.0.6"
|
|
50
|
-
"@oiij/use": "0.0.23"
|
|
51
|
+
"@oiij/markdown-it": "0.0.6"
|
|
51
52
|
},
|
|
52
53
|
"devDependencies": {
|
|
53
54
|
"@types/prismjs": "^1.26.5",
|
|
54
55
|
"@vueuse/core": "^13.9.0",
|
|
55
56
|
"async-validator": "^4.2.5",
|
|
56
57
|
"colord": "^2.9.3",
|
|
58
|
+
"es-toolkit": "^1.39.10",
|
|
57
59
|
"naive-ui": "^2.43.1",
|
|
58
60
|
"prismjs": "^1.30.0",
|
|
59
61
|
"vue": "^3.5.21",
|
|
60
62
|
"vue-component-type-helpers": "^3.0.7",
|
|
61
63
|
"vue-hooks-plus": "^2.4.1",
|
|
64
|
+
"@oiij/css-render": "0.0.4",
|
|
62
65
|
"@oiij/markdown-it": "0.0.6",
|
|
63
|
-
"@oiij/use": "0.0.
|
|
64
|
-
"@oiij/css-render": "0.0.4"
|
|
66
|
+
"@oiij/use": "0.0.24"
|
|
65
67
|
},
|
|
66
68
|
"publishConfig": {
|
|
67
69
|
"access": "public"
|