@vaebe/ccui 2.0.0-beta.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 +201 -0
- package/README.md +31 -0
- package/affix/ccui-cli.css +2 -0
- package/affix/index.es.js +132 -0
- package/affix/index.umd.js +1 -0
- package/alert/ccui-cli.css +2 -0
- package/alert/index.es.js +127 -0
- package/alert/index.umd.js +1 -0
- package/anchor/ccui-cli.css +2 -0
- package/anchor/index.es.js +160 -0
- package/anchor/index.umd.js +1 -0
- package/avatar/ccui-cli.css +2 -0
- package/avatar/index.es.js +235 -0
- package/avatar/index.umd.js +1 -0
- package/badge/ccui-cli.css +2 -0
- package/badge/index.es.js +146 -0
- package/badge/index.umd.js +1 -0
- package/breadcrumb/ccui-cli.css +2 -0
- package/breadcrumb/index.es.js +89 -0
- package/breadcrumb/index.umd.js +1 -0
- package/button/ccui-cli.css +2 -0
- package/button/index.es.js +1236 -0
- package/button/index.umd.js +1 -0
- package/button-3d/ccui-cli.css +2 -0
- package/button-3d/index.es.js +80 -0
- package/button-3d/index.umd.js +1 -0
- package/calendar/ccui-cli.css +2 -0
- package/calendar/index.es.js +450 -0
- package/calendar/index.umd.js +1 -0
- package/card/ccui-cli.css +2 -0
- package/card/index.es.js +78 -0
- package/card/index.umd.js +1 -0
- package/ccui-cli.css +2 -0
- package/check-box/ccui-cli.css +2 -0
- package/check-box/index.es.js +173 -0
- package/check-box/index.umd.js +1 -0
- package/collapse/ccui-cli.css +2 -0
- package/collapse/index.es.js +176 -0
- package/collapse/index.umd.js +1 -0
- package/config-provider/index.es.js +204 -0
- package/config-provider/index.umd.js +1 -0
- package/date-picker/ccui-cli.css +2 -0
- package/date-picker/index.es.js +2447 -0
- package/date-picker/index.umd.js +1 -0
- package/descriptions/ccui-cli.css +2 -0
- package/descriptions/index.es.js +175 -0
- package/descriptions/index.umd.js +1 -0
- package/divider/ccui-cli.css +2 -0
- package/divider/index.es.js +78 -0
- package/divider/index.umd.js +1 -0
- package/drawer/ccui-cli.css +2 -0
- package/drawer/index.es.js +1320 -0
- package/drawer/index.umd.js +1 -0
- package/dropdown/ccui-cli.css +2 -0
- package/dropdown/index.es.js +606 -0
- package/dropdown/index.umd.js +1 -0
- package/empty/ccui-cli.css +2 -0
- package/empty/index.es.js +173 -0
- package/empty/index.umd.js +1 -0
- package/flex/ccui-cli.css +2 -0
- package/flex/index.es.js +87 -0
- package/flex/index.umd.js +1 -0
- package/float-button/ccui-cli.css +2 -0
- package/float-button/index.es.js +169 -0
- package/float-button/index.umd.js +1 -0
- package/form/ccui-cli.css +2 -0
- package/form/index.es.js +752 -0
- package/form/index.umd.js +1 -0
- package/grid/ccui-cli.css +2 -0
- package/grid/index.es.js +207 -0
- package/grid/index.umd.js +1 -0
- package/icon/ccui-cli.css +2 -0
- package/icon/index.es.js +1228 -0
- package/icon/index.umd.js +1 -0
- package/image/ccui-cli.css +2 -0
- package/image/index.es.js +276 -0
- package/image/index.umd.js +1 -0
- package/index.d.ts +7 -0
- package/input/ccui-cli.css +2 -0
- package/input/index.es.js +1293 -0
- package/input/index.umd.js +1 -0
- package/input-number/ccui-cli.css +2 -0
- package/input-number/index.es.js +263 -0
- package/input-number/index.umd.js +1 -0
- package/layout/ccui-cli.css +2 -0
- package/layout/index.es.js +184 -0
- package/layout/index.umd.js +1 -0
- package/masonry/ccui-cli.css +2 -0
- package/masonry/index.es.js +119 -0
- package/masonry/index.umd.js +1 -0
- package/menu/ccui-cli.css +2 -0
- package/menu/index.es.js +385 -0
- package/menu/index.umd.js +1 -0
- package/message/ccui-cli.css +2 -0
- package/message/index.es.js +351 -0
- package/message/index.umd.js +1 -0
- package/modal/ccui-cli.css +2 -0
- package/modal/index.es.js +1553 -0
- package/modal/index.umd.js +1 -0
- package/notification/ccui-cli.css +2 -0
- package/notification/index.es.js +347 -0
- package/notification/index.umd.js +1 -0
- package/nuxt/components/category.js +2 -0
- package/nuxt/components/install.js +2 -0
- package/nuxt/components/status.js +2 -0
- package/nuxt/components/title.js +2 -0
- package/nuxt/index.js +13 -0
- package/package.json +53 -0
- package/pagination/ccui-cli.css +2 -0
- package/pagination/index.es.js +296 -0
- package/pagination/index.umd.js +1 -0
- package/popconfirm/ccui-cli.css +2 -0
- package/popconfirm/index.es.js +735 -0
- package/popconfirm/index.umd.js +1 -0
- package/popover/ccui-cli.css +2 -0
- package/popover/index.es.js +530 -0
- package/popover/index.umd.js +1 -0
- package/progress/ccui-cli.css +2 -0
- package/progress/index.es.js +167 -0
- package/progress/index.umd.js +1 -0
- package/radio/ccui-cli.css +2 -0
- package/radio/index.es.js +157 -0
- package/radio/index.umd.js +1 -0
- package/rate/ccui-cli.css +2 -0
- package/rate/index.es.js +115 -0
- package/rate/index.umd.js +1 -0
- package/result/ccui-cli.css +2 -0
- package/result/index.es.js +90 -0
- package/result/index.umd.js +1 -0
- package/segmented/ccui-cli.css +2 -0
- package/segmented/index.es.js +99 -0
- package/segmented/index.umd.js +1 -0
- package/select/ccui-cli.css +2 -0
- package/select/index.es.js +1885 -0
- package/select/index.umd.js +1 -0
- package/skeleton/ccui-cli.css +2 -0
- package/skeleton/index.es.js +117 -0
- package/skeleton/index.umd.js +1 -0
- package/slider/ccui-cli.css +2 -0
- package/slider/index.es.js +1071 -0
- package/slider/index.umd.js +1 -0
- package/space/ccui-cli.css +2 -0
- package/space/index.es.js +108 -0
- package/space/index.umd.js +1 -0
- package/spin/ccui-cli.css +2 -0
- package/spin/index.es.js +86 -0
- package/spin/index.umd.js +1 -0
- package/splitter/ccui-cli.css +2 -0
- package/splitter/index.es.js +198 -0
- package/splitter/index.umd.js +1 -0
- package/status/ccui-cli.css +2 -0
- package/status/index.es.js +44 -0
- package/status/index.umd.js +1 -0
- package/steps/ccui-cli.css +2 -0
- package/steps/index.es.js +118 -0
- package/steps/index.umd.js +1 -0
- package/switch/ccui-cli.css +2 -0
- package/switch/index.es.js +118 -0
- package/switch/index.umd.js +1 -0
- package/table/ccui-cli.css +2 -0
- package/table/index.es.js +553 -0
- package/table/index.umd.js +1 -0
- package/tabs/ccui-cli.css +2 -0
- package/tabs/index.es.js +128 -0
- package/tabs/index.umd.js +1 -0
- package/tag/ccui-cli.css +2 -0
- package/tag/index.es.js +116 -0
- package/tag/index.umd.js +1 -0
- package/theme/darkTheme.css +352 -0
- package/theme/theme.scss +703 -0
- package/timeline/ccui-cli.css +2 -0
- package/timeline/index.es.js +113 -0
- package/timeline/index.umd.js +1 -0
- package/tooltip/ccui-cli.css +2 -0
- package/tooltip/index.es.js +423 -0
- package/tooltip/index.umd.js +1 -0
- package/tree/ccui-cli.css +2 -0
- package/tree/index.es.js +810 -0
- package/tree/index.umd.js +1 -0
- package/typography/ccui-cli.css +2 -0
- package/typography/index.es.js +270 -0
- package/typography/index.umd.js +1 -0
- package/util/index.es.js +78 -0
- package/util/index.umd.js +1 -0
- package/vue-ccui.es.js +18989 -0
- package/vue-ccui.umd.js +1 -0
- package/watermark/ccui-cli.css +2 -0
- package/watermark/index.es.js +179 -0
- package/watermark/index.umd.js +1 -0
package/form/index.es.js
ADDED
|
@@ -0,0 +1,752 @@
|
|
|
1
|
+
import { computed as e, defineComponent as t, getCurrentInstance as n, h as r, inject as i, onMounted as a, onUnmounted as o, provide as s, reactive as c, ref as l, toRef as u, watch as d } from "vue";
|
|
2
|
+
//#region ../ccui/ui/shared/hooks/use-namespace.ts
|
|
3
|
+
function f(e, t, n) {
|
|
4
|
+
let r = e;
|
|
5
|
+
return t && (r += `__${t}`), n && (r += `--${n}`), r;
|
|
6
|
+
}
|
|
7
|
+
function p(e, t = !1) {
|
|
8
|
+
let n = t ? `.ccui-${e}` : `ccui-${e}`;
|
|
9
|
+
return {
|
|
10
|
+
b: () => f(n),
|
|
11
|
+
e: (e) => e ? f(n, e) : "",
|
|
12
|
+
m: (e) => e ? f(n, "", e) : "",
|
|
13
|
+
em: (e, t) => e && t ? f(n, e, t) : "",
|
|
14
|
+
is: (e) => `is-${e}`
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
//#endregion
|
|
18
|
+
//#region ../ccui/ui/form/src/form-types.ts
|
|
19
|
+
var m = Symbol("ccuiForm"), h = Symbol("ccuiFormItem"), g = Symbol("ccuiFormList"), _ = Symbol("ccuiFormProvider"), v = {
|
|
20
|
+
model: {
|
|
21
|
+
type: Object,
|
|
22
|
+
default: () => ({})
|
|
23
|
+
},
|
|
24
|
+
rules: {
|
|
25
|
+
type: Object,
|
|
26
|
+
default: () => ({})
|
|
27
|
+
},
|
|
28
|
+
initialValues: {
|
|
29
|
+
type: Object,
|
|
30
|
+
default: () => ({})
|
|
31
|
+
},
|
|
32
|
+
labelWidth: {
|
|
33
|
+
type: [String, Number],
|
|
34
|
+
default: ""
|
|
35
|
+
},
|
|
36
|
+
labelPosition: {
|
|
37
|
+
type: String,
|
|
38
|
+
default: "right"
|
|
39
|
+
},
|
|
40
|
+
disabled: {
|
|
41
|
+
type: Boolean,
|
|
42
|
+
default: !1
|
|
43
|
+
},
|
|
44
|
+
layout: {
|
|
45
|
+
type: String,
|
|
46
|
+
default: "horizontal"
|
|
47
|
+
},
|
|
48
|
+
colon: {
|
|
49
|
+
type: Boolean,
|
|
50
|
+
default: !0
|
|
51
|
+
},
|
|
52
|
+
requiredMark: {
|
|
53
|
+
type: [Boolean, String],
|
|
54
|
+
default: !0
|
|
55
|
+
},
|
|
56
|
+
validateMessages: {
|
|
57
|
+
type: Object,
|
|
58
|
+
default: () => ({})
|
|
59
|
+
},
|
|
60
|
+
validateOnRuleChange: {
|
|
61
|
+
type: Boolean,
|
|
62
|
+
default: !0
|
|
63
|
+
},
|
|
64
|
+
scrollToFirstError: {
|
|
65
|
+
type: [Boolean, Object],
|
|
66
|
+
default: !1
|
|
67
|
+
},
|
|
68
|
+
name: {
|
|
69
|
+
type: String,
|
|
70
|
+
default: ""
|
|
71
|
+
},
|
|
72
|
+
preserve: {
|
|
73
|
+
type: Boolean,
|
|
74
|
+
default: !0
|
|
75
|
+
},
|
|
76
|
+
labelCol: {
|
|
77
|
+
type: Object,
|
|
78
|
+
default: void 0
|
|
79
|
+
},
|
|
80
|
+
wrapperCol: {
|
|
81
|
+
type: Object,
|
|
82
|
+
default: void 0
|
|
83
|
+
},
|
|
84
|
+
hasFeedback: {
|
|
85
|
+
type: Boolean,
|
|
86
|
+
default: !1
|
|
87
|
+
}
|
|
88
|
+
}, y = {
|
|
89
|
+
name: {
|
|
90
|
+
type: [
|
|
91
|
+
String,
|
|
92
|
+
Number,
|
|
93
|
+
Array
|
|
94
|
+
],
|
|
95
|
+
default: void 0
|
|
96
|
+
},
|
|
97
|
+
label: {
|
|
98
|
+
type: String,
|
|
99
|
+
default: ""
|
|
100
|
+
},
|
|
101
|
+
prop: {
|
|
102
|
+
type: [
|
|
103
|
+
String,
|
|
104
|
+
Number,
|
|
105
|
+
Array
|
|
106
|
+
],
|
|
107
|
+
default: void 0
|
|
108
|
+
},
|
|
109
|
+
initialValue: {
|
|
110
|
+
type: null,
|
|
111
|
+
default: void 0
|
|
112
|
+
},
|
|
113
|
+
required: {
|
|
114
|
+
type: Boolean,
|
|
115
|
+
default: !1
|
|
116
|
+
},
|
|
117
|
+
rules: {
|
|
118
|
+
type: [
|
|
119
|
+
Object,
|
|
120
|
+
Array,
|
|
121
|
+
Function
|
|
122
|
+
],
|
|
123
|
+
default: void 0
|
|
124
|
+
},
|
|
125
|
+
help: {
|
|
126
|
+
type: String,
|
|
127
|
+
default: ""
|
|
128
|
+
},
|
|
129
|
+
validateStatus: {
|
|
130
|
+
type: String,
|
|
131
|
+
default: ""
|
|
132
|
+
},
|
|
133
|
+
extra: {
|
|
134
|
+
type: String,
|
|
135
|
+
default: ""
|
|
136
|
+
},
|
|
137
|
+
htmlFor: {
|
|
138
|
+
type: String,
|
|
139
|
+
default: ""
|
|
140
|
+
},
|
|
141
|
+
colon: {
|
|
142
|
+
type: Boolean,
|
|
143
|
+
default: void 0
|
|
144
|
+
},
|
|
145
|
+
hidden: {
|
|
146
|
+
type: Boolean,
|
|
147
|
+
default: !1
|
|
148
|
+
},
|
|
149
|
+
noStyle: {
|
|
150
|
+
type: Boolean,
|
|
151
|
+
default: !1
|
|
152
|
+
},
|
|
153
|
+
dependencies: {
|
|
154
|
+
type: Array,
|
|
155
|
+
default: () => []
|
|
156
|
+
},
|
|
157
|
+
preserve: {
|
|
158
|
+
type: Boolean,
|
|
159
|
+
default: void 0
|
|
160
|
+
},
|
|
161
|
+
shouldUpdate: {
|
|
162
|
+
type: [Boolean, Function],
|
|
163
|
+
default: void 0
|
|
164
|
+
},
|
|
165
|
+
hasFeedback: {
|
|
166
|
+
type: Boolean,
|
|
167
|
+
default: void 0
|
|
168
|
+
},
|
|
169
|
+
labelCol: {
|
|
170
|
+
type: Object,
|
|
171
|
+
default: void 0
|
|
172
|
+
},
|
|
173
|
+
wrapperCol: {
|
|
174
|
+
type: Object,
|
|
175
|
+
default: void 0
|
|
176
|
+
},
|
|
177
|
+
validateDebounce: {
|
|
178
|
+
type: Number,
|
|
179
|
+
default: 0
|
|
180
|
+
},
|
|
181
|
+
normalize: {
|
|
182
|
+
type: Function,
|
|
183
|
+
default: void 0
|
|
184
|
+
}
|
|
185
|
+
}, b = {
|
|
186
|
+
name: {
|
|
187
|
+
type: [
|
|
188
|
+
String,
|
|
189
|
+
Number,
|
|
190
|
+
Array
|
|
191
|
+
],
|
|
192
|
+
required: !0
|
|
193
|
+
},
|
|
194
|
+
initialValue: {
|
|
195
|
+
type: Array,
|
|
196
|
+
default: void 0
|
|
197
|
+
}
|
|
198
|
+
}, x = {};
|
|
199
|
+
//#endregion
|
|
200
|
+
//#region ../ccui/ui/form/src/utils.ts
|
|
201
|
+
function S(e) {
|
|
202
|
+
return e == null || e === "" ? [] : Array.isArray(e) ? [...e] : typeof e == "number" ? [e] : e.replace(/\[(\w+)\]/g, ".$1").split(".").filter(Boolean);
|
|
203
|
+
}
|
|
204
|
+
function C(e) {
|
|
205
|
+
return S(e).join(".");
|
|
206
|
+
}
|
|
207
|
+
function w(e, t) {
|
|
208
|
+
let n = S(t);
|
|
209
|
+
if (n.length !== 0) return n.reduce((e, t) => e?.[t], e);
|
|
210
|
+
}
|
|
211
|
+
function T(e, t, n) {
|
|
212
|
+
let r = S(t), i = r.pop();
|
|
213
|
+
if (i === void 0) return;
|
|
214
|
+
let a = r.reduce((e, t) => ((!e[t] || typeof e[t] != "object") && (e[t] = {}), e[t]), e);
|
|
215
|
+
a[i] = n;
|
|
216
|
+
}
|
|
217
|
+
function E(e, t) {
|
|
218
|
+
let n = S(t);
|
|
219
|
+
if (n.length === 0) return;
|
|
220
|
+
let r = n.pop(), i = e;
|
|
221
|
+
for (let e of n) {
|
|
222
|
+
if (i?.[e] === void 0 || i[e] === null) return;
|
|
223
|
+
i = i[e];
|
|
224
|
+
}
|
|
225
|
+
i && typeof i == "object" && (Array.isArray(i) && typeof r == "number" ? i.splice(r, 1) : delete i[r]);
|
|
226
|
+
}
|
|
227
|
+
function D(e) {
|
|
228
|
+
if (e == null) return e;
|
|
229
|
+
if (typeof structuredClone == "function") try {
|
|
230
|
+
return structuredClone(e);
|
|
231
|
+
} catch {}
|
|
232
|
+
return JSON.parse(JSON.stringify(e));
|
|
233
|
+
}
|
|
234
|
+
function O(e) {
|
|
235
|
+
return e ? Array.isArray(e) ? e : [e] : [];
|
|
236
|
+
}
|
|
237
|
+
function k(e, t) {
|
|
238
|
+
return t ? e.filter((e) => e.trigger ? (Array.isArray(e.trigger) ? e.trigger : [e.trigger]).includes(t) : !0) : e;
|
|
239
|
+
}
|
|
240
|
+
function A(e) {
|
|
241
|
+
return e == null || e === "" || Array.isArray(e) && e.length === 0;
|
|
242
|
+
}
|
|
243
|
+
function j(e, t) {
|
|
244
|
+
return A(t) || !e.type ? !0 : e.type === "email" ? typeof t == "string" && /^[^\s@]+@[^\s@][^\s.@]*\.[^\s@]+$/.test(t) : e.type === "url" ? typeof t == "string" && /^https?:\/\/\S+$/i.test(t) : e.type === "array" ? Array.isArray(t) : e.type === "object" ? typeof t == "object" && !Array.isArray(t) : typeof t === e.type;
|
|
245
|
+
}
|
|
246
|
+
function M(e) {
|
|
247
|
+
if (typeof e == "string" || Array.isArray(e)) return e.length;
|
|
248
|
+
if (typeof e == "number") return e;
|
|
249
|
+
}
|
|
250
|
+
var N = {
|
|
251
|
+
default: "${label} is invalid",
|
|
252
|
+
required: "${label} is required",
|
|
253
|
+
enum: "${label} must be one of ${enum}",
|
|
254
|
+
whitespace: "${label} cannot be empty",
|
|
255
|
+
pattern: "${label} is invalid",
|
|
256
|
+
types: {
|
|
257
|
+
string: "${label} is not a valid string",
|
|
258
|
+
number: "${label} is not a valid number",
|
|
259
|
+
boolean: "${label} is not a valid boolean",
|
|
260
|
+
array: "${label} is not a valid array",
|
|
261
|
+
object: "${label} is not a valid object",
|
|
262
|
+
email: "${label} is not a valid email",
|
|
263
|
+
url: "${label} is not a valid url"
|
|
264
|
+
},
|
|
265
|
+
string: {
|
|
266
|
+
len: "${label} must be ${len} characters",
|
|
267
|
+
min: "${label} must be at least ${min} characters",
|
|
268
|
+
max: "${label} must be up to ${max} characters",
|
|
269
|
+
range: "${label} must be between ${min} and ${max} characters"
|
|
270
|
+
},
|
|
271
|
+
number: {
|
|
272
|
+
len: "${label} must equal ${len}",
|
|
273
|
+
min: "${label} must be at least ${min}",
|
|
274
|
+
max: "${label} must be up to ${max}",
|
|
275
|
+
range: "${label} must be between ${min} and ${max}"
|
|
276
|
+
},
|
|
277
|
+
array: {
|
|
278
|
+
len: "${label} must contain ${len} items",
|
|
279
|
+
min: "${label} must contain at least ${min} items",
|
|
280
|
+
max: "${label} must contain up to ${max} items",
|
|
281
|
+
range: "${label} must contain between ${min} and ${max} items"
|
|
282
|
+
}
|
|
283
|
+
};
|
|
284
|
+
function P(e, t) {
|
|
285
|
+
return e.replace(/\$\{(\w+)\}/g, (e, n) => String(t[n] ?? ""));
|
|
286
|
+
}
|
|
287
|
+
function F(e, t, n, r, i, a) {
|
|
288
|
+
if (e.message) return e.message;
|
|
289
|
+
let o = {
|
|
290
|
+
...N,
|
|
291
|
+
...r,
|
|
292
|
+
types: {
|
|
293
|
+
...N.types,
|
|
294
|
+
...r.types
|
|
295
|
+
},
|
|
296
|
+
string: {
|
|
297
|
+
...N.string,
|
|
298
|
+
...r.string
|
|
299
|
+
},
|
|
300
|
+
number: {
|
|
301
|
+
...N.number,
|
|
302
|
+
...r.number
|
|
303
|
+
},
|
|
304
|
+
array: {
|
|
305
|
+
...N.array,
|
|
306
|
+
...r.array
|
|
307
|
+
}
|
|
308
|
+
};
|
|
309
|
+
return P((a && i && typeof o[i] == "object" ? o[i]?.[a] : void 0) || (i === "types" && e.type ? o.types?.[e.type] : void 0) || (i ? o[i] : void 0) || o.default || "${label} is invalid", {
|
|
310
|
+
label: n || t,
|
|
311
|
+
name: t,
|
|
312
|
+
field: t,
|
|
313
|
+
enum: e.enum?.join(", "),
|
|
314
|
+
len: e.len,
|
|
315
|
+
min: e.min,
|
|
316
|
+
max: e.max
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
function I(e, t) {
|
|
320
|
+
return e.type === "array" || Array.isArray(t) ? "array" : typeof t == "number" ? "number" : "string";
|
|
321
|
+
}
|
|
322
|
+
async function ee(e, t, n, r, i = r, a = {}) {
|
|
323
|
+
if (e.required && A(t)) return {
|
|
324
|
+
field: r,
|
|
325
|
+
message: F(e, r, i, a, "required")
|
|
326
|
+
};
|
|
327
|
+
if (e.whitespace && typeof t == "string" && t.trim() === "") return {
|
|
328
|
+
field: r,
|
|
329
|
+
message: F(e, r, i, a, "whitespace")
|
|
330
|
+
};
|
|
331
|
+
if (e.enum && !A(t) && !e.enum.includes(t)) return {
|
|
332
|
+
field: r,
|
|
333
|
+
message: F(e, r, i, a, "enum")
|
|
334
|
+
};
|
|
335
|
+
if (!j(e, t)) return {
|
|
336
|
+
field: r,
|
|
337
|
+
message: F(e, r, i, a, "types")
|
|
338
|
+
};
|
|
339
|
+
let o = M(t);
|
|
340
|
+
if (o !== void 0) {
|
|
341
|
+
let n = I(e, t);
|
|
342
|
+
if (e.len !== void 0 && o !== e.len) return {
|
|
343
|
+
field: r,
|
|
344
|
+
message: F(e, r, i, a, n, "len")
|
|
345
|
+
};
|
|
346
|
+
if (e.min !== void 0 && e.max !== void 0 && (o < e.min || o > e.max)) return {
|
|
347
|
+
field: r,
|
|
348
|
+
message: F(e, r, i, a, n, "range")
|
|
349
|
+
};
|
|
350
|
+
if (e.min !== void 0 && o < e.min) return {
|
|
351
|
+
field: r,
|
|
352
|
+
message: F(e, r, i, a, n, "min")
|
|
353
|
+
};
|
|
354
|
+
if (e.max !== void 0 && o > e.max) return {
|
|
355
|
+
field: r,
|
|
356
|
+
message: F(e, r, i, a, n, "max")
|
|
357
|
+
};
|
|
358
|
+
}
|
|
359
|
+
if (e.pattern && !e.pattern.test(String(t))) return {
|
|
360
|
+
field: r,
|
|
361
|
+
message: F(e, r, i, a, "pattern")
|
|
362
|
+
};
|
|
363
|
+
if (e.validator) {
|
|
364
|
+
let o = await e.validator(e, t, n);
|
|
365
|
+
if (o === !1) return {
|
|
366
|
+
field: r,
|
|
367
|
+
message: F(e, r, i, a)
|
|
368
|
+
};
|
|
369
|
+
if (typeof o == "string") return {
|
|
370
|
+
field: r,
|
|
371
|
+
message: o
|
|
372
|
+
};
|
|
373
|
+
if (o instanceof Error) return {
|
|
374
|
+
field: r,
|
|
375
|
+
message: o.message
|
|
376
|
+
};
|
|
377
|
+
}
|
|
378
|
+
return null;
|
|
379
|
+
}
|
|
380
|
+
//#endregion
|
|
381
|
+
//#region ../ccui/ui/form/src/form.tsx
|
|
382
|
+
var L = /* @__PURE__ */ t({
|
|
383
|
+
name: "CForm",
|
|
384
|
+
props: v,
|
|
385
|
+
emits: [
|
|
386
|
+
"submit",
|
|
387
|
+
"validate",
|
|
388
|
+
"validate-failed",
|
|
389
|
+
"values-change"
|
|
390
|
+
],
|
|
391
|
+
setup(t, { emit: n, expose: c, slots: f }) {
|
|
392
|
+
let h = p("form"), g = l([]), v = i(_, null), y = (e) => {
|
|
393
|
+
if (e === void 0) return g.value;
|
|
394
|
+
if (!Array.isArray(e)) {
|
|
395
|
+
let t = C(e);
|
|
396
|
+
return g.value.filter((e) => e.field === t);
|
|
397
|
+
}
|
|
398
|
+
let t = C(e);
|
|
399
|
+
if (g.value.some((e) => e.field === t)) return g.value.filter((e) => e.field === t);
|
|
400
|
+
let n = new Set(e.map((e) => C(e)));
|
|
401
|
+
return g.value.filter((e) => n.has(e.field));
|
|
402
|
+
}, b = (e) => {
|
|
403
|
+
e.field && !g.value.includes(e) && g.value.push(e);
|
|
404
|
+
}, x = (e) => {
|
|
405
|
+
g.value = g.value.filter((t) => t !== e);
|
|
406
|
+
}, S = (e, t, r) => {
|
|
407
|
+
n("validate", e, t, r);
|
|
408
|
+
}, w = (e, r) => {
|
|
409
|
+
n("values-change", {
|
|
410
|
+
name: e,
|
|
411
|
+
value: r
|
|
412
|
+
}, t.model), t.name && v && v.triggerFormChange(t.name, [{
|
|
413
|
+
name: e,
|
|
414
|
+
value: r
|
|
415
|
+
}]);
|
|
416
|
+
}, T = e(() => ({
|
|
417
|
+
[h.b()]: !0,
|
|
418
|
+
[h.m(`label-${t.labelPosition}`)]: !!t.labelPosition,
|
|
419
|
+
[h.m(t.layout)]: !!t.layout,
|
|
420
|
+
[h.m("disabled")]: t.disabled
|
|
421
|
+
})), E = async (e) => {
|
|
422
|
+
let r = [];
|
|
423
|
+
for (let e of g.value) !await e.validate() && e.prop && r.push({
|
|
424
|
+
field: e.field,
|
|
425
|
+
message: e.getValidateMessage()
|
|
426
|
+
});
|
|
427
|
+
let i = r.length === 0;
|
|
428
|
+
return e?.(i, r), i || (n("validate-failed", r), t.scrollToFirstError && A(r[0].field, t.scrollToFirstError === !0 ? void 0 : t.scrollToFirstError)), i;
|
|
429
|
+
}, D = async (e, t) => {
|
|
430
|
+
let n = y(e);
|
|
431
|
+
return (await Promise.all(n.map((e) => e.validate(t)))).every(Boolean);
|
|
432
|
+
}, O = (e) => {
|
|
433
|
+
y(e).forEach((e) => e.resetField());
|
|
434
|
+
}, k = (e) => {
|
|
435
|
+
y(e).forEach((e) => e.clearValidate());
|
|
436
|
+
}, A = (e, t) => {
|
|
437
|
+
y(e)[0]?.getElement()?.scrollIntoView(t ?? { block: "nearest" });
|
|
438
|
+
}, j = () => t.model, M = async (e) => {
|
|
439
|
+
e.preventDefault();
|
|
440
|
+
let r = await E();
|
|
441
|
+
n("submit", r, e), r && t.name && v && v.triggerFormFinish(t.name, t.model);
|
|
442
|
+
};
|
|
443
|
+
d(() => t.rules, () => {
|
|
444
|
+
t.validateOnRuleChange && k();
|
|
445
|
+
}), d(() => t.model, () => {
|
|
446
|
+
g.value.forEach((e) => {
|
|
447
|
+
e.dependencies.length > 0 && e.validate();
|
|
448
|
+
});
|
|
449
|
+
}, { deep: !0 });
|
|
450
|
+
let N = {
|
|
451
|
+
validate: E,
|
|
452
|
+
validateField: D,
|
|
453
|
+
resetFields: O,
|
|
454
|
+
clearValidate: k,
|
|
455
|
+
scrollToField: A,
|
|
456
|
+
getFieldsValue: j
|
|
457
|
+
};
|
|
458
|
+
return c(N), a(() => {
|
|
459
|
+
t.name && v && v.registerForm(t.name, N);
|
|
460
|
+
}), o(() => {
|
|
461
|
+
t.name && v && v.unregisterForm(t.name);
|
|
462
|
+
}), s(m, {
|
|
463
|
+
model: u(t, "model"),
|
|
464
|
+
rules: u(t, "rules"),
|
|
465
|
+
initialValues: u(t, "initialValues"),
|
|
466
|
+
validateMessages: u(t, "validateMessages"),
|
|
467
|
+
disabled: u(t, "disabled"),
|
|
468
|
+
labelWidth: u(t, "labelWidth"),
|
|
469
|
+
labelPosition: u(t, "labelPosition"),
|
|
470
|
+
layout: u(t, "layout"),
|
|
471
|
+
colon: u(t, "colon"),
|
|
472
|
+
requiredMark: u(t, "requiredMark"),
|
|
473
|
+
preserve: u(t, "preserve"),
|
|
474
|
+
labelCol: u(t, "labelCol"),
|
|
475
|
+
wrapperCol: u(t, "wrapperCol"),
|
|
476
|
+
hasFeedback: u(t, "hasFeedback"),
|
|
477
|
+
addField: b,
|
|
478
|
+
removeField: x,
|
|
479
|
+
emitValidate: S,
|
|
480
|
+
validateField: D,
|
|
481
|
+
notifyFieldChange: w
|
|
482
|
+
}), () => r("form", {
|
|
483
|
+
class: T.value,
|
|
484
|
+
novalidate: !0,
|
|
485
|
+
onSubmit: M
|
|
486
|
+
}, f.default?.());
|
|
487
|
+
}
|
|
488
|
+
}), R = /* @__PURE__ */ new Set();
|
|
489
|
+
function te(e, t, n) {
|
|
490
|
+
let r = `${e}.${t}`;
|
|
491
|
+
R.has(r) || (R.add(r), typeof console < "u" && console.warn(`[ccui][${e}] ${t} 已 deprecated,请改用 ${n}。`));
|
|
492
|
+
}
|
|
493
|
+
function ne(e, t, n) {
|
|
494
|
+
return e ? Object.prototype.hasOwnProperty.call(e, t) || Object.prototype.hasOwnProperty.call(e, n) : !1;
|
|
495
|
+
}
|
|
496
|
+
//#endregion
|
|
497
|
+
//#region ../ccui/ui/form/src/form-item.tsx
|
|
498
|
+
function z(e) {
|
|
499
|
+
if (!e) return {};
|
|
500
|
+
let t = {};
|
|
501
|
+
return e.flex !== void 0 && (t.flex = typeof e.flex == "number" ? `${e.flex} ${e.flex} auto` : e.flex), e.span !== void 0 && (t.width = `${e.span / 24 * 100}%`), e.offset !== void 0 && e.offset > 0 && (t.marginInlineStart = `${e.offset / 24 * 100}%`), t;
|
|
502
|
+
}
|
|
503
|
+
var B = /* @__PURE__ */ t({
|
|
504
|
+
name: "CFormItem",
|
|
505
|
+
props: y,
|
|
506
|
+
setup(t, { expose: c, slots: u }) {
|
|
507
|
+
let f = p("form-item"), _ = n()?.vnode.props;
|
|
508
|
+
ne(_, "prop", "prop") && te("FormItem", "prop", "name");
|
|
509
|
+
let v = i(m, null), y = i(g, null), b = l(""), x = l(""), A = l(!1), j = l(null), M = e(() => t.name ?? t.prop), N = e(() => {
|
|
510
|
+
let e = M.value;
|
|
511
|
+
if (!y) return e;
|
|
512
|
+
let t = y.prefixName.value;
|
|
513
|
+
return e == null || e === "" ? t.length ? [...t] : void 0 : [...t, ...S(e)];
|
|
514
|
+
}), P = e(() => C(N.value)), F = e(() => t.label || P.value), I = l(), L = () => {
|
|
515
|
+
if (t.initialValue !== void 0) return t.initialValue;
|
|
516
|
+
let e = v ? w(v.initialValues.value, N.value) : void 0;
|
|
517
|
+
return e === void 0 ? v ? w(v.model.value, N.value) : void 0 : e;
|
|
518
|
+
}, R = () => {
|
|
519
|
+
let e = t.rules;
|
|
520
|
+
return typeof e == "function" ? e(v?.model.value ?? {}) : e;
|
|
521
|
+
}, B = e(() => {
|
|
522
|
+
let e = [...O(v?.rules.value?.[P.value]), ...O(R())];
|
|
523
|
+
return t.required && !e.some((e) => e.required) && e.unshift({ required: !0 }), e;
|
|
524
|
+
}), V = e(() => t.required || B.value.some((e) => e.required)), H = e(() => t.validateStatus ? t.validateStatus : A.value ? "warning" : b.value), U = e(() => x.value || t.help), W = e(() => !V.value && v?.requiredMark.value === "optional"), re = e(() => V.value && v?.requiredMark.value !== !1), ie = e(() => t.colon ?? v?.colon.value ?? !0), G = e(() => t.hasFeedback === void 0 ? !!v?.hasFeedback.value : t.hasFeedback), K = e(() => t.labelCol ?? v?.labelCol.value), ae = e(() => t.wrapperCol ?? v?.wrapperCol.value), oe = e(() => K.value ? z(K.value) : !v?.labelWidth.value || v.labelPosition.value === "top" || v.layout.value === "vertical" ? {} : { width: typeof v.labelWidth.value == "number" ? `${v.labelWidth.value}px` : v.labelWidth.value }), se = e(() => z(ae.value)), q = e(() => ({
|
|
525
|
+
[f.b()]: !0,
|
|
526
|
+
[f.m(H.value)]: !!H.value,
|
|
527
|
+
[f.m("required")]: re.value,
|
|
528
|
+
[f.m("optional")]: W.value,
|
|
529
|
+
[f.m("no-style")]: t.noStyle,
|
|
530
|
+
[f.m("hidden")]: t.hidden,
|
|
531
|
+
[f.m("top")]: v?.labelPosition.value === "top" || v?.layout.value === "vertical"
|
|
532
|
+
})), J = () => {
|
|
533
|
+
b.value = "", x.value = "", A.value = !1;
|
|
534
|
+
}, Y = null, X = async (e) => {
|
|
535
|
+
if (!P.value || !v) return !0;
|
|
536
|
+
let t = k(B.value, e);
|
|
537
|
+
if (t.length === 0) return J(), !0;
|
|
538
|
+
b.value = "validating";
|
|
539
|
+
let n = w(v.model.value, N.value), r = "";
|
|
540
|
+
for (let e of t) {
|
|
541
|
+
let t = await ee(e, n, v.model.value, P.value, F.value, v.validateMessages.value);
|
|
542
|
+
if (t) {
|
|
543
|
+
if (e.warningOnly) {
|
|
544
|
+
r = t.message;
|
|
545
|
+
continue;
|
|
546
|
+
}
|
|
547
|
+
return b.value = "error", x.value = t.message, v.emitValidate(P.value, !1, t.message), !1;
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
return r ? (b.value = "success", x.value = r, A.value = !0, v.emitValidate(P.value, !0, r), !0) : (A.value = !1, b.value = "success", x.value = "", v.emitValidate(P.value, !0, ""), !0);
|
|
551
|
+
}, Z = async (e) => t.validateDebounce > 0 ? (Y && clearTimeout(Y), new Promise((n) => {
|
|
552
|
+
Y = setTimeout(() => {
|
|
553
|
+
X(e).then(n);
|
|
554
|
+
}, t.validateDebounce);
|
|
555
|
+
})) : X(e), Q = () => {
|
|
556
|
+
P.value && v && T(v.model.value, N.value, D(I.value)), J();
|
|
557
|
+
}, ce = {
|
|
558
|
+
get prop() {
|
|
559
|
+
return N.value;
|
|
560
|
+
},
|
|
561
|
+
get field() {
|
|
562
|
+
return P.value;
|
|
563
|
+
},
|
|
564
|
+
get dependencies() {
|
|
565
|
+
return t.dependencies;
|
|
566
|
+
},
|
|
567
|
+
validate: Z,
|
|
568
|
+
resetField: Q,
|
|
569
|
+
clearValidate: J,
|
|
570
|
+
getValidateMessage: () => x.value,
|
|
571
|
+
getElement: () => j.value
|
|
572
|
+
}, le = (e) => {
|
|
573
|
+
if (t.normalize && v && N.value !== void 0) {
|
|
574
|
+
let e = w(v.model.value, N.value), n = D(e), r = t.normalize(e, n, v.model.value);
|
|
575
|
+
r !== e && T(v.model.value, N.value, r);
|
|
576
|
+
}
|
|
577
|
+
if (Z("change"), v && N.value !== void 0) {
|
|
578
|
+
let e = w(v.model.value, N.value);
|
|
579
|
+
v.notifyFieldChange(N.value, e);
|
|
580
|
+
}
|
|
581
|
+
}, ue = () => {
|
|
582
|
+
Z("blur");
|
|
583
|
+
};
|
|
584
|
+
a(() => {
|
|
585
|
+
if (I.value = D(L()), N.value && v && w(v.model.value, N.value) === void 0) {
|
|
586
|
+
let e = L();
|
|
587
|
+
e !== void 0 && T(v.model.value, N.value, D(e));
|
|
588
|
+
}
|
|
589
|
+
v?.addField(ce);
|
|
590
|
+
}), o(() => {
|
|
591
|
+
v?.removeField(ce);
|
|
592
|
+
let e = t.preserve, n = v?.preserve.value ?? !0;
|
|
593
|
+
!(e === void 0 ? n : e) && v && N.value !== void 0 && E(v.model.value, N.value);
|
|
594
|
+
}), c({
|
|
595
|
+
validate: Z,
|
|
596
|
+
resetField: Q,
|
|
597
|
+
clearValidate: J
|
|
598
|
+
}), s(h, {
|
|
599
|
+
validateStatus: H,
|
|
600
|
+
isInsideForm: !!v,
|
|
601
|
+
validate: Z
|
|
602
|
+
});
|
|
603
|
+
let $;
|
|
604
|
+
d(() => v?.model.value, (e) => {
|
|
605
|
+
if (t.shouldUpdate !== void 0) {
|
|
606
|
+
if (typeof t.shouldUpdate == "function") {
|
|
607
|
+
if (!t.shouldUpdate($, e)) {
|
|
608
|
+
$ = D(e);
|
|
609
|
+
return;
|
|
610
|
+
}
|
|
611
|
+
} else if (!t.shouldUpdate) {
|
|
612
|
+
$ = D(e);
|
|
613
|
+
return;
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
$ = D(e), t.dependencies.length > 0 && Z();
|
|
617
|
+
}, { deep: !0 });
|
|
618
|
+
let de = () => {
|
|
619
|
+
if (!t.label && !u.label) return null;
|
|
620
|
+
let e = [u.label?.() || t.label, W.value ? r("span", { class: f.e("optional") }, " (optional)") : null];
|
|
621
|
+
return r("label", {
|
|
622
|
+
class: [f.e("label"), ie.value && f.em("label", "colon")],
|
|
623
|
+
style: oe.value,
|
|
624
|
+
for: t.htmlFor || void 0
|
|
625
|
+
}, e);
|
|
626
|
+
}, fe = () => {
|
|
627
|
+
if (!G.value) return null;
|
|
628
|
+
let e = H.value;
|
|
629
|
+
if (!e) return null;
|
|
630
|
+
let t = e === "success" ? "✓" : e === "error" ? "✕" : e === "warning" ? "!" : e === "validating" ? "◌" : "";
|
|
631
|
+
return t ? r("span", {
|
|
632
|
+
class: [f.e("feedback"), f.em("feedback", e)],
|
|
633
|
+
"aria-hidden": "true"
|
|
634
|
+
}, t) : null;
|
|
635
|
+
}, pe = () => r("div", {
|
|
636
|
+
class: f.e("content"),
|
|
637
|
+
style: se.value
|
|
638
|
+
}, [
|
|
639
|
+
r("div", { class: [f.e("control"), G.value && f.em("control", "has-feedback")] }, [u.default?.(), fe()]),
|
|
640
|
+
U.value ? r("div", {
|
|
641
|
+
class: f.e("message"),
|
|
642
|
+
role: "alert"
|
|
643
|
+
}, U.value) : null,
|
|
644
|
+
t.extra ? r("div", { class: f.e("extra") }, t.extra) : null
|
|
645
|
+
]);
|
|
646
|
+
return () => t.noStyle ? r("div", {
|
|
647
|
+
ref: j,
|
|
648
|
+
class: q.value,
|
|
649
|
+
"data-field": P.value || void 0,
|
|
650
|
+
onChangeCapture: le,
|
|
651
|
+
onFocusoutCapture: ue
|
|
652
|
+
}, u.default?.()) : r("div", {
|
|
653
|
+
ref: j,
|
|
654
|
+
class: q.value,
|
|
655
|
+
"data-field": P.value || void 0,
|
|
656
|
+
"aria-invalid": H.value === "error" ? "true" : void 0,
|
|
657
|
+
onChangeCapture: le,
|
|
658
|
+
onFocusoutCapture: ue
|
|
659
|
+
}, [de(), pe()]);
|
|
660
|
+
}
|
|
661
|
+
}), V = /* @__PURE__ */ t({
|
|
662
|
+
name: "CFormList",
|
|
663
|
+
props: b,
|
|
664
|
+
setup(t, { slots: n }) {
|
|
665
|
+
let r = i(m, null), o = e(() => S(t.name)), l = () => {
|
|
666
|
+
if (!r) return [];
|
|
667
|
+
let e = w(r.model.value, t.name);
|
|
668
|
+
if (Array.isArray(e)) return e;
|
|
669
|
+
let n = t.initialValue ?? w(r.initialValues.value, t.name), i = Array.isArray(n) ? D(n) : [];
|
|
670
|
+
return T(r.model.value, t.name, i), i;
|
|
671
|
+
}, u = c({
|
|
672
|
+
keys: [],
|
|
673
|
+
seed: 0
|
|
674
|
+
}), f = (e) => {
|
|
675
|
+
for (; u.keys.length < e;) u.keys.push(u.seed++);
|
|
676
|
+
u.keys.length > e && (u.keys.length = e);
|
|
677
|
+
};
|
|
678
|
+
a(() => {
|
|
679
|
+
f(l().length);
|
|
680
|
+
}), d(() => r ? w(r.model.value, t.name) : void 0, (e) => {
|
|
681
|
+
Array.isArray(e) && e.length !== u.keys.length && f(e.length);
|
|
682
|
+
}, { deep: !1 });
|
|
683
|
+
let p = {
|
|
684
|
+
add(e, t) {
|
|
685
|
+
if (!r) return;
|
|
686
|
+
let n = l(), i = D(e), a = t === void 0 ? n.length : Math.max(0, Math.min(t, n.length));
|
|
687
|
+
n.splice(a, 0, i), u.keys.splice(a, 0, u.seed++);
|
|
688
|
+
},
|
|
689
|
+
remove(e) {
|
|
690
|
+
if (!r) return;
|
|
691
|
+
let t = l(), n = (Array.isArray(e) ? e : [e]).filter((e) => e >= 0 && e < t.length).sort((e, t) => t - e);
|
|
692
|
+
for (let e of n) t.splice(e, 1), u.keys.splice(e, 1);
|
|
693
|
+
},
|
|
694
|
+
move(e, t) {
|
|
695
|
+
if (!r) return;
|
|
696
|
+
let n = l();
|
|
697
|
+
if (e === t || e < 0 || t < 0 || e >= n.length || t >= n.length) return;
|
|
698
|
+
let [i] = n.splice(e, 1);
|
|
699
|
+
n.splice(t, 0, i);
|
|
700
|
+
let [a] = u.keys.splice(e, 1);
|
|
701
|
+
u.keys.splice(t, 0, a);
|
|
702
|
+
}
|
|
703
|
+
};
|
|
704
|
+
return s(g, { prefixName: o }), () => {
|
|
705
|
+
let e = u.keys.map((e, t) => ({
|
|
706
|
+
key: e,
|
|
707
|
+
name: t
|
|
708
|
+
}));
|
|
709
|
+
return n.default?.(e, p) ?? null;
|
|
710
|
+
};
|
|
711
|
+
}
|
|
712
|
+
}), H = /* @__PURE__ */ t({
|
|
713
|
+
name: "CFormProvider",
|
|
714
|
+
props: x,
|
|
715
|
+
emits: ["form-change", "form-finish"],
|
|
716
|
+
setup(e, { emit: t, slots: n }) {
|
|
717
|
+
let r = {};
|
|
718
|
+
return s(_, {
|
|
719
|
+
registerForm: (e, t) => {
|
|
720
|
+
e && (r[e] = t);
|
|
721
|
+
},
|
|
722
|
+
unregisterForm: (e) => {
|
|
723
|
+
e && delete r[e];
|
|
724
|
+
},
|
|
725
|
+
triggerFormChange: (e, n) => {
|
|
726
|
+
e && t("form-change", e, {
|
|
727
|
+
changedFields: n,
|
|
728
|
+
forms: r
|
|
729
|
+
});
|
|
730
|
+
},
|
|
731
|
+
triggerFormFinish: (e, n) => {
|
|
732
|
+
e && t("form-finish", e, {
|
|
733
|
+
values: n,
|
|
734
|
+
forms: r
|
|
735
|
+
});
|
|
736
|
+
}
|
|
737
|
+
}), () => n.default?.() ?? null;
|
|
738
|
+
}
|
|
739
|
+
}), U = L;
|
|
740
|
+
U.install = function(e) {
|
|
741
|
+
e.component(L.name, L), e.component(B.name, B), e.component(V.name, V), e.component(H.name, H);
|
|
742
|
+
};
|
|
743
|
+
var W = {
|
|
744
|
+
title: "Form 表单",
|
|
745
|
+
category: "数据录入",
|
|
746
|
+
status: "95%",
|
|
747
|
+
install(e) {
|
|
748
|
+
e.component(L.name, L), e.component(B.name, B), e.component(V.name, V), e.component(H.name, H);
|
|
749
|
+
}
|
|
750
|
+
};
|
|
751
|
+
//#endregion
|
|
752
|
+
export { L as Form, B as FormItem, V as FormList, H as FormProvider, W as default };
|