@oiij/naive-ui 0.0.1 → 0.0.2
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/README.md +9 -15
- package/dist/components/config-providers/ConfigProviders.vue.d.ts +36 -0
- package/dist/components/config-providers/index.d.ts +1 -0
- package/dist/components/copy-button/CopyButton.vue.d.ts +31 -0
- package/dist/components/copy-button/index.d.ts +1 -0
- package/dist/components/index.d.ts +4 -0
- package/dist/components/search-input/SearchInput.vue.d.ts +30 -0
- package/dist/components/search-input/index.d.ts +1 -0
- package/dist/components/tooltip-button/TooltipButton.vue.d.ts +29 -0
- package/dist/components/tooltip-button/index.d.ts +1 -0
- package/dist/components.cjs +1 -0
- package/dist/components.d.ts +1 -0
- package/dist/components.js +237 -0
- package/dist/components.umd.cjs +1 -0
- package/dist/index.cjs +165 -156
- package/dist/index.d.cts +45 -172
- package/dist/index.d.ts +45 -172
- package/dist/index.js +149 -143
- package/package.json +111 -93
package/dist/index.d.ts
CHANGED
|
@@ -1,178 +1,51 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import { FormRules, FormItemRule, FormInst, GlobalThemeOverrides, NDateLocale } from 'naive-ui';
|
|
5
|
-
import * as naive_ui_es_themes_interface from 'naive-ui/es/themes/interface';
|
|
1
|
+
import { ComputedRef, Reactive, Ref } from "vue";
|
|
2
|
+
import { FormInst, FormItemRule, FormRules, GlobalThemeOverrides, NDateLocale, darkTheme, enUS, zhCN } from "naive-ui";
|
|
3
|
+
import { ValidateError } from "async-validator";
|
|
6
4
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
//#region src/composables/useNaiveForm.d.ts
|
|
6
|
+
type ExtendsType = Record<string, unknown>;
|
|
7
|
+
type NaiveFormRules<T extends ExtendsType> = Partial<Record<keyof T, FormRules | FormItemRule | FormItemRule[]>> | undefined;
|
|
8
|
+
interface NaiveFormOptions<T extends ExtendsType> {
|
|
9
|
+
value?: T;
|
|
10
|
+
rules?: NaiveFormRules<T>;
|
|
10
11
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
rules:
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
12
|
+
interface NaiveFormReturns<T extends ExtendsType> {
|
|
13
|
+
formRef: Ref<FormInst | undefined>;
|
|
14
|
+
formValue: Ref<T>;
|
|
15
|
+
rules: NaiveFormRules<T>;
|
|
16
|
+
formProps: {
|
|
17
|
+
ref: Ref<FormInst | undefined>;
|
|
18
|
+
model: Reactive<T>;
|
|
19
|
+
rules: NaiveFormRules<T>;
|
|
20
|
+
};
|
|
21
|
+
validate: () => Promise<{
|
|
22
|
+
warnings: ValidateError[][] | undefined;
|
|
23
|
+
}> | undefined;
|
|
24
|
+
resetValidation: () => void;
|
|
25
|
+
resetForm: () => void;
|
|
26
|
+
clear: () => void;
|
|
27
|
+
reset: () => void;
|
|
28
|
+
}
|
|
29
|
+
declare function useNaiveForm<T extends ExtendsType>(options?: NaiveFormOptions<T>): NaiveFormReturns<T>;
|
|
27
30
|
|
|
31
|
+
//#endregion
|
|
32
|
+
//#region src/composables/useNaiveTheme.d.ts
|
|
28
33
|
interface Color {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
+
primary: string;
|
|
35
|
+
info: string;
|
|
36
|
+
success: string;
|
|
37
|
+
warning: string;
|
|
38
|
+
error: string;
|
|
39
|
+
}
|
|
40
|
+
interface NaiveThemeReturns {
|
|
41
|
+
theme: ComputedRef<typeof darkTheme | undefined>;
|
|
42
|
+
themeOverrides: ComputedRef<GlobalThemeOverrides>;
|
|
43
|
+
locale: ComputedRef<typeof zhCN | typeof enUS>;
|
|
44
|
+
dateLocale: ComputedRef<NDateLocale>;
|
|
45
|
+
color: Ref<Color>;
|
|
46
|
+
setColor: (v: Color) => void;
|
|
34
47
|
}
|
|
35
|
-
declare function useNaiveTheme(darkMode?: ComputedRef<boolean>, language?: ComputedRef<
|
|
36
|
-
theme: ComputedRef<naive_ui_es_themes_interface.BuiltInGlobalTheme | undefined>;
|
|
37
|
-
themeOverrides: ComputedRef<GlobalThemeOverrides>;
|
|
38
|
-
locale: ComputedRef<{
|
|
39
|
-
name: string;
|
|
40
|
-
global: {
|
|
41
|
-
undo: string;
|
|
42
|
-
redo: string;
|
|
43
|
-
confirm: string;
|
|
44
|
-
clear: string;
|
|
45
|
-
};
|
|
46
|
-
Popconfirm: {
|
|
47
|
-
positiveText: string;
|
|
48
|
-
negativeText: string;
|
|
49
|
-
};
|
|
50
|
-
Cascader: {
|
|
51
|
-
placeholder: string;
|
|
52
|
-
loading: string;
|
|
53
|
-
loadingRequiredMessage: (label: string) => string;
|
|
54
|
-
};
|
|
55
|
-
Time: {
|
|
56
|
-
dateFormat: string;
|
|
57
|
-
dateTimeFormat: string;
|
|
58
|
-
};
|
|
59
|
-
DatePicker: {
|
|
60
|
-
yearFormat: string;
|
|
61
|
-
monthFormat: string;
|
|
62
|
-
dayFormat: string;
|
|
63
|
-
yearTypeFormat: string;
|
|
64
|
-
monthTypeFormat: string;
|
|
65
|
-
dateFormat: string;
|
|
66
|
-
dateTimeFormat: string;
|
|
67
|
-
quarterFormat: string;
|
|
68
|
-
weekFormat: string;
|
|
69
|
-
clear: string;
|
|
70
|
-
now: string;
|
|
71
|
-
confirm: string;
|
|
72
|
-
selectTime: string;
|
|
73
|
-
selectDate: string;
|
|
74
|
-
datePlaceholder: string;
|
|
75
|
-
datetimePlaceholder: string;
|
|
76
|
-
monthPlaceholder: string;
|
|
77
|
-
yearPlaceholder: string;
|
|
78
|
-
quarterPlaceholder: string;
|
|
79
|
-
weekPlaceholder: string;
|
|
80
|
-
startDatePlaceholder: string;
|
|
81
|
-
endDatePlaceholder: string;
|
|
82
|
-
startDatetimePlaceholder: string;
|
|
83
|
-
endDatetimePlaceholder: string;
|
|
84
|
-
startMonthPlaceholder: string;
|
|
85
|
-
endMonthPlaceholder: string;
|
|
86
|
-
monthBeforeYear: boolean;
|
|
87
|
-
firstDayOfWeek: 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
88
|
-
today: string;
|
|
89
|
-
};
|
|
90
|
-
DataTable: {
|
|
91
|
-
checkTableAll: string;
|
|
92
|
-
uncheckTableAll: string;
|
|
93
|
-
confirm: string;
|
|
94
|
-
clear: string;
|
|
95
|
-
};
|
|
96
|
-
LegacyTransfer: {
|
|
97
|
-
sourceTitle: string;
|
|
98
|
-
targetTitle: string;
|
|
99
|
-
};
|
|
100
|
-
Transfer: {
|
|
101
|
-
selectAll: string;
|
|
102
|
-
unselectAll: string;
|
|
103
|
-
clearAll: string;
|
|
104
|
-
total: (num: number) => string;
|
|
105
|
-
selected: (num: number) => string;
|
|
106
|
-
};
|
|
107
|
-
Empty: {
|
|
108
|
-
description: string;
|
|
109
|
-
};
|
|
110
|
-
Select: {
|
|
111
|
-
placeholder: string;
|
|
112
|
-
};
|
|
113
|
-
TimePicker: {
|
|
114
|
-
placeholder: string;
|
|
115
|
-
positiveText: string;
|
|
116
|
-
negativeText: string;
|
|
117
|
-
now: string;
|
|
118
|
-
clear: string;
|
|
119
|
-
};
|
|
120
|
-
Pagination: {
|
|
121
|
-
goto: string;
|
|
122
|
-
selectionSuffix: string;
|
|
123
|
-
};
|
|
124
|
-
DynamicTags: {
|
|
125
|
-
add: string;
|
|
126
|
-
};
|
|
127
|
-
Log: {
|
|
128
|
-
loading: string;
|
|
129
|
-
};
|
|
130
|
-
Input: {
|
|
131
|
-
placeholder: string;
|
|
132
|
-
};
|
|
133
|
-
InputNumber: {
|
|
134
|
-
placeholder: string;
|
|
135
|
-
};
|
|
136
|
-
DynamicInput: {
|
|
137
|
-
create: string;
|
|
138
|
-
};
|
|
139
|
-
ThemeEditor: {
|
|
140
|
-
title: string;
|
|
141
|
-
clearAllVars: string;
|
|
142
|
-
clearSearch: string;
|
|
143
|
-
filterCompName: string;
|
|
144
|
-
filterVarName: string;
|
|
145
|
-
import: string;
|
|
146
|
-
export: string;
|
|
147
|
-
restore: string;
|
|
148
|
-
};
|
|
149
|
-
Image: {
|
|
150
|
-
tipPrevious: string;
|
|
151
|
-
tipNext: string;
|
|
152
|
-
tipCounterclockwise: string;
|
|
153
|
-
tipClockwise: string;
|
|
154
|
-
tipZoomOut: string;
|
|
155
|
-
tipZoomIn: string;
|
|
156
|
-
tipDownload: string;
|
|
157
|
-
tipClose: string;
|
|
158
|
-
tipOriginalSize: string;
|
|
159
|
-
};
|
|
160
|
-
}>;
|
|
161
|
-
dateLocale: ComputedRef<NDateLocale>;
|
|
162
|
-
color: vue.Ref<{
|
|
163
|
-
primary: string;
|
|
164
|
-
info: string;
|
|
165
|
-
success: string;
|
|
166
|
-
warning: string;
|
|
167
|
-
error: string;
|
|
168
|
-
}, Color | {
|
|
169
|
-
primary: string;
|
|
170
|
-
info: string;
|
|
171
|
-
success: string;
|
|
172
|
-
warning: string;
|
|
173
|
-
error: string;
|
|
174
|
-
}>;
|
|
175
|
-
setColor: (v: Color) => void;
|
|
176
|
-
};
|
|
48
|
+
declare function useNaiveTheme<T extends 'zh-CN' | 'en-US'>(darkMode?: ComputedRef<boolean> | Ref<boolean>, language?: ComputedRef<T> | Ref<T>, globalThemeOverrides?: GlobalThemeOverrides): NaiveThemeReturns;
|
|
177
49
|
|
|
178
|
-
|
|
50
|
+
//#endregion
|
|
51
|
+
export { NaiveFormOptions, NaiveFormReturns, NaiveFormRules, NaiveThemeReturns, useNaiveForm, useNaiveTheme };
|
package/dist/index.js
CHANGED
|
@@ -1,151 +1,157 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { computed, reactive, ref, toValue } from "vue";
|
|
2
|
+
import { colord } from "colord";
|
|
3
|
+
import { darkTheme, dateEnUS, dateZhCN, enUS, zhCN } from "naive-ui";
|
|
4
|
+
|
|
5
|
+
//#region src/composables/useNaiveForm.ts
|
|
6
|
+
function clearObjectValues(obj) {
|
|
7
|
+
if (Array.isArray(obj)) {
|
|
8
|
+
obj.length = 0;
|
|
9
|
+
return obj;
|
|
10
|
+
}
|
|
11
|
+
if (typeof obj === "object" && obj !== null) {
|
|
12
|
+
for (const key in obj) if (Object.prototype.hasOwnProperty.call(obj, key)) obj[key] = clearObjectValues(obj[key]);
|
|
13
|
+
return obj;
|
|
14
|
+
}
|
|
15
|
+
if (typeof obj === "string") return "";
|
|
16
|
+
if (typeof obj === "number") return 0;
|
|
17
|
+
if (typeof obj === "boolean") return false;
|
|
18
|
+
return obj;
|
|
19
|
+
}
|
|
4
20
|
function useNaiveForm(options) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
resetForm,
|
|
43
|
-
reset,
|
|
44
|
-
clear
|
|
45
|
-
};
|
|
21
|
+
const { value, rules } = options ?? {};
|
|
22
|
+
const formValue = ref(structuredClone(value));
|
|
23
|
+
const formRules = rules;
|
|
24
|
+
const formRef = ref();
|
|
25
|
+
const formProps = {
|
|
26
|
+
ref: formRef,
|
|
27
|
+
model: reactive(toValue(formValue)),
|
|
28
|
+
rules: formRules
|
|
29
|
+
};
|
|
30
|
+
function validate() {
|
|
31
|
+
return formRef.value?.validate();
|
|
32
|
+
}
|
|
33
|
+
function resetValidation() {
|
|
34
|
+
formRef.value?.restoreValidation();
|
|
35
|
+
}
|
|
36
|
+
function clear() {
|
|
37
|
+
clearObjectValues(formValue.value);
|
|
38
|
+
}
|
|
39
|
+
function resetForm() {
|
|
40
|
+
clear();
|
|
41
|
+
Object.assign(formValue.value, structuredClone(value));
|
|
42
|
+
}
|
|
43
|
+
function reset() {
|
|
44
|
+
resetValidation();
|
|
45
|
+
resetForm();
|
|
46
|
+
}
|
|
47
|
+
return {
|
|
48
|
+
formRef,
|
|
49
|
+
formValue,
|
|
50
|
+
rules: formRules,
|
|
51
|
+
formProps,
|
|
52
|
+
validate,
|
|
53
|
+
resetValidation,
|
|
54
|
+
resetForm,
|
|
55
|
+
reset,
|
|
56
|
+
clear
|
|
57
|
+
};
|
|
46
58
|
}
|
|
47
59
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
import {
|
|
51
|
-
darkTheme,
|
|
52
|
-
dateEnUS,
|
|
53
|
-
dateZhCN,
|
|
54
|
-
enUS,
|
|
55
|
-
zhCN
|
|
56
|
-
} from "naive-ui";
|
|
57
|
-
import { computed, ref as ref2 } from "vue";
|
|
60
|
+
//#endregion
|
|
61
|
+
//#region src/composables/useNaiveTheme.ts
|
|
58
62
|
function getStatusColor(color = "#ff461f") {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
return {
|
|
64
|
+
color,
|
|
65
|
+
hover: colord(color).lighten(.1).toHex(),
|
|
66
|
+
pressed: colord(color).darken(.1).toHex(),
|
|
67
|
+
suppl: colord(color).lighten(.1).toHex()
|
|
68
|
+
};
|
|
65
69
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
70
|
+
const naiveLocaleMap = {
|
|
71
|
+
"zh-CN": {
|
|
72
|
+
name: "简体中文",
|
|
73
|
+
dateLocale: dateZhCN,
|
|
74
|
+
locale: zhCN
|
|
75
|
+
},
|
|
76
|
+
"en-US": {
|
|
77
|
+
name: "English",
|
|
78
|
+
dateLocale: dateEnUS,
|
|
79
|
+
locale: enUS
|
|
80
|
+
}
|
|
77
81
|
};
|
|
78
82
|
function useNaiveTheme(darkMode, language, globalThemeOverrides) {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
83
|
+
const { common, Dialog,...extra } = globalThemeOverrides || {};
|
|
84
|
+
const color = ref({
|
|
85
|
+
primary: "#64748B",
|
|
86
|
+
info: "#06b6d4",
|
|
87
|
+
success: "#10b981",
|
|
88
|
+
warning: "#fbbf24",
|
|
89
|
+
error: "#f43f5e"
|
|
90
|
+
});
|
|
91
|
+
function setColor(v) {
|
|
92
|
+
color.value = v;
|
|
93
|
+
}
|
|
94
|
+
const theme = computed(() => {
|
|
95
|
+
return darkMode?.value ? darkTheme : void 0;
|
|
96
|
+
});
|
|
97
|
+
const themeOverrides = computed(() => {
|
|
98
|
+
const primary = getStatusColor(color.value.primary);
|
|
99
|
+
const info = getStatusColor(color.value.info);
|
|
100
|
+
const success = getStatusColor(color.value.success);
|
|
101
|
+
const warning = getStatusColor(color.value.warning);
|
|
102
|
+
const error = getStatusColor(color.value.error);
|
|
103
|
+
return {
|
|
104
|
+
common: {
|
|
105
|
+
bodyColor: darkMode?.value ? "#1f1f1f" : "#f5f5f5",
|
|
106
|
+
primaryColor: primary.color,
|
|
107
|
+
primaryColorHover: primary.hover,
|
|
108
|
+
primaryColorPressed: primary.pressed,
|
|
109
|
+
primaryColorSuppl: primary.suppl,
|
|
110
|
+
infoColor: info.color,
|
|
111
|
+
infoColorHover: info.hover,
|
|
112
|
+
infoColorPressed: info.pressed,
|
|
113
|
+
infoColorSuppl: info.suppl,
|
|
114
|
+
successColor: success.color,
|
|
115
|
+
successColorHover: success.hover,
|
|
116
|
+
successColorPressed: success.pressed,
|
|
117
|
+
successColorSuppl: success.suppl,
|
|
118
|
+
warningColor: warning.color,
|
|
119
|
+
warningColorHover: warning.hover,
|
|
120
|
+
warningColorPressed: warning.pressed,
|
|
121
|
+
warningColorSuppl: warning.suppl,
|
|
122
|
+
errorColor: error.color,
|
|
123
|
+
errorColorHover: error.hover,
|
|
124
|
+
errorColorPressed: error.pressed,
|
|
125
|
+
errorColorSuppl: error.suppl,
|
|
126
|
+
borderRadius: "6px",
|
|
127
|
+
...common
|
|
128
|
+
},
|
|
129
|
+
Dialog: {
|
|
130
|
+
borderRadius: "12px",
|
|
131
|
+
padding: "20px",
|
|
132
|
+
closeMargin: "20px 20px 0 0",
|
|
133
|
+
...Dialog
|
|
134
|
+
},
|
|
135
|
+
...extra
|
|
136
|
+
};
|
|
137
|
+
});
|
|
138
|
+
const locale = computed(() => {
|
|
139
|
+
if (!language?.value || !naiveLocaleMap[language.value]) return naiveLocaleMap["zh-CN"].locale;
|
|
140
|
+
return naiveLocaleMap[language.value].locale;
|
|
141
|
+
});
|
|
142
|
+
const dateLocale = computed(() => {
|
|
143
|
+
if (!language?.value || !naiveLocaleMap[language.value]) return naiveLocaleMap["zh-CN"].dateLocale;
|
|
144
|
+
return naiveLocaleMap[language.value].dateLocale;
|
|
145
|
+
});
|
|
146
|
+
return {
|
|
147
|
+
theme,
|
|
148
|
+
themeOverrides,
|
|
149
|
+
locale,
|
|
150
|
+
dateLocale,
|
|
151
|
+
color,
|
|
152
|
+
setColor
|
|
153
|
+
};
|
|
147
154
|
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
};
|
|
155
|
+
|
|
156
|
+
//#endregion
|
|
157
|
+
export { useNaiveForm, useNaiveTheme };
|