@dazhicheng/ui 1.5.205 → 1.5.207
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.
|
@@ -1,137 +1,181 @@
|
|
|
1
|
-
import { inject as
|
|
2
|
-
import { get as
|
|
3
|
-
import { FormContextKey as
|
|
4
|
-
function
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
1
|
+
import { inject as P, computed as F, toValue as A, ref as Y, watch as q, onBeforeUnmount as D } from "vue";
|
|
2
|
+
import { get as K, set as E, cloneDeep as m } from "lodash-es";
|
|
3
|
+
import { FormContextKey as T } from "vee-validate";
|
|
4
|
+
function z(s) {
|
|
5
|
+
return typeof File < "u" && s instanceof File;
|
|
6
|
+
}
|
|
7
|
+
function d(s, e) {
|
|
8
|
+
if (s === e) return !0;
|
|
9
|
+
if (s && e && typeof s == "object" && typeof e == "object") {
|
|
10
|
+
if (s.constructor !== e.constructor) return !1;
|
|
11
|
+
if (Array.isArray(s)) {
|
|
12
|
+
if (s.length !== e.length) return !1;
|
|
13
|
+
for (let u = s.length; u-- !== 0; ) if (!d(s[u], e[u])) return !1;
|
|
14
|
+
return !0;
|
|
15
|
+
}
|
|
16
|
+
if (s instanceof Map && e instanceof Map) {
|
|
17
|
+
if (s.size !== e.size) return !1;
|
|
18
|
+
for (const u of s.keys()) if (!e.has(u)) return !1;
|
|
19
|
+
for (const [u, a] of s) if (!d(a, e.get(u))) return !1;
|
|
20
|
+
return !0;
|
|
21
|
+
}
|
|
22
|
+
if (s instanceof Set && e instanceof Set) {
|
|
23
|
+
if (s.size !== e.size) return !1;
|
|
24
|
+
for (const u of s) if (!e.has(u)) return !1;
|
|
25
|
+
return !0;
|
|
26
|
+
}
|
|
27
|
+
if (ArrayBuffer.isView(s) && ArrayBuffer.isView(e)) {
|
|
28
|
+
const u = s, a = e;
|
|
29
|
+
if (u.length !== a.length) return !1;
|
|
30
|
+
for (let v = u.length; v-- !== 0; ) if (u[v] !== a[v]) return !1;
|
|
31
|
+
return !0;
|
|
32
|
+
}
|
|
33
|
+
if (s instanceof RegExp && e instanceof RegExp)
|
|
34
|
+
return s.source === e.source && s.flags === e.flags;
|
|
35
|
+
if (z(s) && z(e))
|
|
36
|
+
return s.size === e.size && s.name === e.name && s.lastModified === e.lastModified && s.type === e.type;
|
|
37
|
+
if (s.valueOf !== Object.prototype.valueOf) return s.valueOf() === e.valueOf();
|
|
38
|
+
if (s.toString !== Object.prototype.toString) return s.toString() === e.toString();
|
|
39
|
+
const c = Object.keys(s).filter((u) => s[u] !== void 0), i = Object.keys(e).filter((u) => e[u] !== void 0);
|
|
40
|
+
if (c.length !== i.length) return !1;
|
|
41
|
+
for (const u of c)
|
|
42
|
+
if (!Object.prototype.hasOwnProperty.call(e, u) || !d(s[u], e[u])) return !1;
|
|
43
|
+
return !0;
|
|
44
|
+
}
|
|
45
|
+
return s !== s && e !== e;
|
|
46
|
+
}
|
|
47
|
+
function G(s) {
|
|
48
|
+
const e = P(T), c = F(() => A(s)), i = Y([]);
|
|
49
|
+
let u = 0, a;
|
|
50
|
+
const v = Object.freeze([]);
|
|
51
|
+
function l() {
|
|
52
|
+
if (!e)
|
|
53
|
+
return v;
|
|
54
|
+
const t = K(e.values, c.value);
|
|
55
|
+
return Array.isArray(t) ? t : v;
|
|
56
|
+
}
|
|
57
|
+
function p(t) {
|
|
58
|
+
e && (E(e.values, c.value, t), a = l());
|
|
59
|
+
}
|
|
60
|
+
function $(t, n) {
|
|
61
|
+
return F({
|
|
18
62
|
get() {
|
|
19
|
-
const
|
|
20
|
-
return
|
|
63
|
+
const r = l(), f = i.value.findIndex((o) => o.key === t);
|
|
64
|
+
return f === -1 ? n : r[f];
|
|
21
65
|
},
|
|
22
|
-
set(
|
|
23
|
-
const
|
|
24
|
-
|
|
66
|
+
set(r) {
|
|
67
|
+
const f = i.value.findIndex((o) => o.key === t);
|
|
68
|
+
f !== -1 && V(f, r);
|
|
25
69
|
}
|
|
26
70
|
});
|
|
27
71
|
}
|
|
28
|
-
function
|
|
29
|
-
const t =
|
|
30
|
-
for (let
|
|
31
|
-
const
|
|
32
|
-
|
|
72
|
+
function O() {
|
|
73
|
+
const t = i.value.length;
|
|
74
|
+
for (let n = 0; n < t; n++) {
|
|
75
|
+
const r = i.value[n];
|
|
76
|
+
r.isFirst = n === 0, r.isLast = n === t - 1;
|
|
33
77
|
}
|
|
34
78
|
}
|
|
35
|
-
function
|
|
36
|
-
|
|
79
|
+
function y() {
|
|
80
|
+
O(), e == null || e.validate({ mode: "silent" });
|
|
37
81
|
}
|
|
38
|
-
function
|
|
39
|
-
if (
|
|
40
|
-
return n
|
|
41
|
-
const
|
|
82
|
+
function g(t, n, r) {
|
|
83
|
+
if (r && n != null && r[n])
|
|
84
|
+
return r[n];
|
|
85
|
+
const f = u++;
|
|
42
86
|
return {
|
|
43
|
-
key:
|
|
44
|
-
value:
|
|
87
|
+
key: f,
|
|
88
|
+
value: $(f, t),
|
|
45
89
|
isFirst: !1,
|
|
46
90
|
isLast: !1
|
|
47
91
|
};
|
|
48
92
|
}
|
|
49
|
-
function
|
|
50
|
-
const t =
|
|
51
|
-
|
|
93
|
+
function h() {
|
|
94
|
+
const t = l(), n = i.value;
|
|
95
|
+
i.value = t.map((r, f) => g(r, f, n)), a = l(), O();
|
|
52
96
|
}
|
|
53
|
-
|
|
54
|
-
const
|
|
55
|
-
|
|
97
|
+
h(), q([() => l(), () => l().length], ([t]) => {
|
|
98
|
+
const n = t.length !== i.value.length || t !== a;
|
|
99
|
+
a = t, n && h();
|
|
56
100
|
});
|
|
57
|
-
function
|
|
58
|
-
if (!
|
|
101
|
+
function M(t) {
|
|
102
|
+
if (!e)
|
|
59
103
|
return;
|
|
60
|
-
const
|
|
61
|
-
if (t < 0 || t >=
|
|
104
|
+
const n = [...l()];
|
|
105
|
+
if (t < 0 || t >= n.length)
|
|
62
106
|
return;
|
|
63
|
-
const
|
|
64
|
-
|
|
107
|
+
const r = `${c.value}[${t}]`;
|
|
108
|
+
e.destroyPath(r), e.unsetInitialValue(r), n.splice(t, 1), p(n), i.value.splice(t, 1), y();
|
|
65
109
|
}
|
|
66
|
-
function
|
|
67
|
-
if (!
|
|
110
|
+
function S(t) {
|
|
111
|
+
if (!e)
|
|
68
112
|
return;
|
|
69
|
-
const
|
|
70
|
-
|
|
113
|
+
const n = m(t), r = [...l(), n];
|
|
114
|
+
e.stageInitialValue(`${c.value}[${r.length - 1}]`, n), p(r), i.value.push(g(n)), y();
|
|
71
115
|
}
|
|
72
|
-
function
|
|
73
|
-
if (!
|
|
116
|
+
function w(t) {
|
|
117
|
+
if (!e)
|
|
74
118
|
return;
|
|
75
|
-
const
|
|
76
|
-
|
|
119
|
+
const n = m(t), r = [n, ...l()];
|
|
120
|
+
e.stageInitialValue(`${c.value}[0]`, n), p(r), i.value.unshift(g(n)), y();
|
|
77
121
|
}
|
|
78
|
-
function
|
|
79
|
-
if (!
|
|
122
|
+
function C(t, n) {
|
|
123
|
+
if (!e)
|
|
80
124
|
return;
|
|
81
|
-
const
|
|
82
|
-
t < 0 || t >
|
|
125
|
+
const r = m(n), f = [...l()];
|
|
126
|
+
t < 0 || t > f.length || (f.splice(t, 0, r), p(f), i.value.splice(t, 0, g(r)), y());
|
|
83
127
|
}
|
|
84
|
-
function
|
|
85
|
-
|
|
128
|
+
function R(t) {
|
|
129
|
+
e && (e.stageInitialValue(c.value, t), p(m(t)), h(), y());
|
|
86
130
|
}
|
|
87
|
-
function
|
|
88
|
-
if (!
|
|
131
|
+
function V(t, n) {
|
|
132
|
+
if (!e)
|
|
89
133
|
return;
|
|
90
|
-
const
|
|
91
|
-
t < 0 || t >=
|
|
134
|
+
const r = l();
|
|
135
|
+
t < 0 || t >= r.length || (d(r[t], n) || E(e.values, `${c.value}[${t}]`, n), e.validate({ mode: "validated-only" }));
|
|
92
136
|
}
|
|
93
|
-
function
|
|
94
|
-
if (!
|
|
137
|
+
function I(t, n) {
|
|
138
|
+
if (!e)
|
|
95
139
|
return;
|
|
96
|
-
const
|
|
97
|
-
if (!(t in
|
|
140
|
+
const r = [...l()];
|
|
141
|
+
if (!(t in r) || !(n in r))
|
|
98
142
|
return;
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
const
|
|
102
|
-
|
|
143
|
+
const f = r[t];
|
|
144
|
+
r[t] = r[n], r[n] = f;
|
|
145
|
+
const o = [...i.value], k = o[t];
|
|
146
|
+
o[t] = o[n], o[n] = k, p(r), i.value = o, O();
|
|
103
147
|
}
|
|
104
|
-
function
|
|
105
|
-
if (!
|
|
148
|
+
function L(t, n) {
|
|
149
|
+
if (!e)
|
|
106
150
|
return;
|
|
107
|
-
const
|
|
108
|
-
if (!(t in
|
|
151
|
+
const r = [...l()];
|
|
152
|
+
if (!(t in r) || !(n in r))
|
|
109
153
|
return;
|
|
110
|
-
const
|
|
111
|
-
|
|
112
|
-
const
|
|
113
|
-
|
|
114
|
-
}
|
|
115
|
-
const
|
|
116
|
-
fields:
|
|
117
|
-
remove:
|
|
118
|
-
push:
|
|
119
|
-
prepend:
|
|
120
|
-
insert:
|
|
121
|
-
replace:
|
|
122
|
-
update:
|
|
123
|
-
swap:
|
|
124
|
-
move:
|
|
154
|
+
const f = r.splice(t, 1)[0];
|
|
155
|
+
r.splice(n, 0, f);
|
|
156
|
+
const o = [...i.value], k = o.splice(t, 1)[0];
|
|
157
|
+
o.splice(n, 0, k), p(r), i.value = o, y();
|
|
158
|
+
}
|
|
159
|
+
const j = {
|
|
160
|
+
fields: i,
|
|
161
|
+
remove: M,
|
|
162
|
+
push: S,
|
|
163
|
+
prepend: w,
|
|
164
|
+
insert: C,
|
|
165
|
+
replace: R,
|
|
166
|
+
update: V,
|
|
167
|
+
swap: I,
|
|
168
|
+
move: L
|
|
125
169
|
};
|
|
126
|
-
if (
|
|
127
|
-
const t = Object.assign({ path:
|
|
128
|
-
|
|
129
|
-
const
|
|
130
|
-
|
|
170
|
+
if (e) {
|
|
171
|
+
const t = Object.assign({ path: s, reset: h }, j);
|
|
172
|
+
e.fieldArrays.push(t), D(() => {
|
|
173
|
+
const n = e.fieldArrays.findIndex((r) => A(r.path) === A(s));
|
|
174
|
+
n >= 0 && e.fieldArrays.splice(n, 1);
|
|
131
175
|
});
|
|
132
176
|
}
|
|
133
|
-
return
|
|
177
|
+
return j;
|
|
134
178
|
}
|
|
135
179
|
export {
|
|
136
|
-
|
|
180
|
+
G as useFieldArray
|
|
137
181
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dazhicheng/ui",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.207",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -56,8 +56,8 @@
|
|
|
56
56
|
"vee-validate": "^4.15.1",
|
|
57
57
|
"xe-utils": "^4.0.0",
|
|
58
58
|
"zod": "^4.3.6",
|
|
59
|
-
"@dazhicheng/hooks": "1.4.
|
|
60
|
-
"@dazhicheng/utils": "1.3.
|
|
59
|
+
"@dazhicheng/hooks": "1.4.43",
|
|
60
|
+
"@dazhicheng/utils": "1.3.40"
|
|
61
61
|
},
|
|
62
62
|
"peerDependencies": {
|
|
63
63
|
"@element-plus/icons-vue": "^2.3.2",
|