@dazhicheng/ui 1.5.205 → 1.5.206

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 K, computed as d, toValue as V, ref as M, watch as O, onBeforeUnmount as R } from "vue";
2
- import { get as U, set as C, cloneDeep as y } from "lodash-es";
3
- import { FormContextKey as q } from "vee-validate";
4
- function J(g) {
5
- const r = K(q), i = d(() => V(g)), s = M([]);
6
- let E = 0, f;
7
- function a() {
8
- if (!r)
9
- return [];
10
- const t = U(r.values, i.value);
11
- return Array.isArray(t) ? t : [];
12
- }
13
- function c(t) {
14
- r && (C(r.values, i.value, t), f = a());
15
- }
16
- function A(t, e) {
17
- return d({
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 n = a(), u = s.value.findIndex((l) => l.key === t);
20
- return u === -1 ? e : n[u];
63
+ const r = l(), f = i.value.findIndex((o) => o.key === t);
64
+ return f === -1 ? n : r[f];
21
65
  },
22
- set(n) {
23
- const u = s.value.findIndex((l) => l.key === t);
24
- u !== -1 && F(u, n);
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 h() {
29
- const t = s.value.length;
30
- for (let e = 0; e < t; e++) {
31
- const n = s.value[e];
32
- n.isFirst = e === 0, n.isLast = e === t - 1;
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 o() {
36
- h(), r == null || r.validate({ mode: "silent" });
79
+ function y() {
80
+ O(), e == null || e.validate({ mode: "silent" });
37
81
  }
38
- function v(t, e, n) {
39
- if (n && e != null && n[e])
40
- return n[e];
41
- const u = E++;
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: u,
44
- value: A(u, t),
87
+ key: f,
88
+ value: $(f, t),
45
89
  isFirst: !1,
46
90
  isLast: !1
47
91
  };
48
92
  }
49
- function p() {
50
- const t = a(), e = s.value;
51
- s.value = t.map((n, u) => v(n, u, e)), f = a(), h();
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
- p(), O([() => a(), () => a().length], ([t]) => {
54
- const e = t.length !== s.value.length || t !== f;
55
- f = t, e && p();
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 I(t) {
58
- if (!r)
101
+ function M(t) {
102
+ if (!e)
59
103
  return;
60
- const e = [...a()];
61
- if (t < 0 || t >= e.length)
104
+ const n = [...l()];
105
+ if (t < 0 || t >= n.length)
62
106
  return;
63
- const n = `${i.value}[${t}]`;
64
- r.destroyPath(n), r.unsetInitialValue(n), e.splice(t, 1), c(e), s.value.splice(t, 1), o();
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 j(t) {
67
- if (!r)
110
+ function S(t) {
111
+ if (!e)
68
112
  return;
69
- const e = y(t), n = [...a(), e];
70
- r.stageInitialValue(`${i.value}[${n.length - 1}]`, e), c(n), s.value.push(v(e)), o();
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 k(t) {
73
- if (!r)
116
+ function w(t) {
117
+ if (!e)
74
118
  return;
75
- const e = y(t), n = [e, ...a()];
76
- r.stageInitialValue(`${i.value}[0]`, e), c(n), s.value.unshift(v(e)), o();
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 w(t, e) {
79
- if (!r)
122
+ function C(t, n) {
123
+ if (!e)
80
124
  return;
81
- const n = y(e), u = [...a()];
82
- t < 0 || t > u.length || (u.splice(t, 0, n), c(u), s.value.splice(t, 0, v(n)), o());
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 L(t) {
85
- r && (r.stageInitialValue(i.value, t), c(y(t)), p(), o());
128
+ function R(t) {
129
+ e && (e.stageInitialValue(c.value, t), p(m(t)), h(), y());
86
130
  }
87
- function F(t, e) {
88
- if (!r)
131
+ function V(t, n) {
132
+ if (!e)
89
133
  return;
90
- const n = a();
91
- t < 0 || t >= n.length || (C(r.values, `${i.value}[${t}]`, e), r.validate({ mode: "validated-only" }));
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 b(t, e) {
94
- if (!r)
137
+ function I(t, n) {
138
+ if (!e)
95
139
  return;
96
- const n = [...a()];
97
- if (!(t in n) || !(e in n))
140
+ const r = [...l()];
141
+ if (!(t in r) || !(n in r))
98
142
  return;
99
- const u = n[t];
100
- n[t] = n[e], n[e] = u;
101
- const l = [...s.value], m = l[t];
102
- l[t] = l[e], l[e] = m, c(n), s.value = l, h();
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 D(t, e) {
105
- if (!r)
148
+ function L(t, n) {
149
+ if (!e)
106
150
  return;
107
- const n = [...a()];
108
- if (!(t in n) || !(e in n))
151
+ const r = [...l()];
152
+ if (!(t in r) || !(n in r))
109
153
  return;
110
- const u = n.splice(t, 1)[0];
111
- n.splice(e, 0, u);
112
- const l = [...s.value], m = l.splice(t, 1)[0];
113
- l.splice(e, 0, m), c(n), s.value = l, o();
114
- }
115
- const $ = {
116
- fields: s,
117
- remove: I,
118
- push: j,
119
- prepend: k,
120
- insert: w,
121
- replace: L,
122
- update: F,
123
- swap: b,
124
- move: D
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 (r) {
127
- const t = Object.assign({ path: g, reset: p }, $);
128
- r.fieldArrays.push(t), R(() => {
129
- const e = r.fieldArrays.findIndex((n) => V(n.path) === V(g));
130
- e >= 0 && r.fieldArrays.splice(e, 1);
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
- J as useFieldArray
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.205",
3
+ "version": "1.5.206",
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.41",
60
- "@dazhicheng/utils": "1.3.38"
59
+ "@dazhicheng/utils": "1.3.39",
60
+ "@dazhicheng/hooks": "1.4.42"
61
61
  },
62
62
  "peerDependencies": {
63
63
  "@element-plus/icons-vue": "^2.3.2",