@amateescu/portal-ui-components 0.0.24 → 0.0.25-react19

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.
Files changed (47) hide show
  1. package/dist/Box-DQNjUj2G.js +102 -0
  2. package/dist/Button-D2XVkO19.js +676 -0
  3. package/dist/ButtonBase-D-XlpvIZ.js +954 -0
  4. package/dist/CircularProgress-BOkP0juA.js +247 -0
  5. package/dist/{EllipsisOutlined-CtmB5yDB.js → EllipsisOutlined-DfTPoz8U.js} +667 -672
  6. package/dist/PurePanel-ByiFMw5U.js +2213 -0
  7. package/dist/{Skeleton-XFbjx7LJ.js → Skeleton-Imy-56Lv.js} +161 -158
  8. package/dist/{UserInfoDropdown-DGaplQo6.js → UserInfoDropdown-6aB5cQyF.js} +1540 -1505
  9. package/dist/_commonjsHelpers-C6fGbg64.js +6 -0
  10. package/dist/components/ConfirmationModal/ConfirmationModal.js +1 -1
  11. package/dist/components/ConfirmationModal/ConfirmationModal.stories.js +1 -1
  12. package/dist/components/CustomButton/CustomButton.js +1 -1
  13. package/dist/components/CustomPagination/CustomPagination.js +455 -344
  14. package/dist/components/ErrorModal/ErrorModal.js +5 -6
  15. package/dist/components/ErrorModal/ErrorModal.stories.js +1 -1
  16. package/dist/components/InfoModal/InfoModal.js +1 -1
  17. package/dist/components/InfoModal/InfoModal.stories.js +1 -1
  18. package/dist/components/KpiCard/KpiCard.js +1003 -892
  19. package/dist/components/LoadingAnimation/LoadingAnimation.js +6 -215
  20. package/dist/components/Login/Login.js +4485 -3820
  21. package/dist/components/Login/Login.stories.js +1586 -1546
  22. package/dist/components/SideMenu/SideMenu.js +1 -1
  23. package/dist/components/SideMenu/SideMenu.types.d.ts +1 -0
  24. package/dist/components/TotalDataGrid/TotalDataGrid.js +6 -6
  25. package/dist/components/UserInfoDropdown/UserInfoDropdown.js +1 -1
  26. package/dist/components/UserInfoDropdown/UserInfoDropdown.stories.js +1 -1
  27. package/dist/components/index.js +1 -1
  28. package/dist/context-D_FWkiDE.js +7383 -0
  29. package/dist/createSimplePaletteValueFilter-CshNo3IR.js +3439 -0
  30. package/dist/index-CR8gh-dS.js +1689 -0
  31. package/dist/index-CyFfYou3.js +411 -0
  32. package/dist/main.js +1 -1
  33. package/dist/objectWithoutPropertiesLoose-BTau6TOn.js +33 -0
  34. package/dist/portal-utils/formatters.js +68 -0
  35. package/dist/useSlot-kDVPuVrn.js +431 -0
  36. package/package.json +38 -38
  37. package/dist/Box-CmKt1PwF.js +0 -68
  38. package/dist/Button-BT8r3F_d.js +0 -355
  39. package/dist/ButtonBase-By486Sca.js +0 -966
  40. package/dist/PurePanel-CfZ1n-M8.js +0 -4782
  41. package/dist/assertThisInitialized-BUtkG-md.js +0 -13
  42. package/dist/createSvgIcon-B8ya7kb4.js +0 -250
  43. package/dist/generateUtilityClasses-Bhjgm_6-.js +0 -3270
  44. package/dist/index-1vDmwq0E.js +0 -19089
  45. package/dist/index-DsP9yT3s.js +0 -1551
  46. package/dist/objectWithoutPropertiesLoose-CIT-1_kH.js +0 -227
  47. package/dist/useId-DbfH3PlN.js +0 -5397
@@ -1,4782 +0,0 @@
1
- import * as $ from "react";
2
- import L, { useContext as Oe, useRef as ce, forwardRef as ke, useState as Ke, useEffect as Me, useMemo as be, createRef as nn, Children as an } from "react";
3
- import { I as on, R as Nt, s as Vt, f as ee, d as T, ad as sn, ae as ln, w as Ye, n as Fr, c as ne, a1 as _t, a as _e, j as It, a4 as cn, Z as un, g as Er, m as Be, A as wr, t as Sr, h as m, V as Lt, W as Ce, X as Ht, l as De, Y as Fe, b as de, q as xr, E as dn, K as ue, af as ot, y as fn, u as je, Q as gn, ag as hn, o as mn, p as re, ah as vn, ai as pn, _ as B, aj as He, ak as pe, al as ve, a7 as tr, C as yn } from "./useId-DbfH3PlN.js";
4
- import { R as bn } from "./index-1vDmwq0E.js";
5
- import { a as $e } from "./objectWithoutPropertiesLoose-CIT-1_kH.js";
6
- import { _ as Or, a as W } from "./assertThisInitialized-BUtkG-md.js";
7
- function Cn(e) {
8
- return e && /* @__PURE__ */ L.isValidElement(e) && e.type === L.Fragment;
9
- }
10
- const Fn = (e, t, r) => /* @__PURE__ */ L.isValidElement(e) ? /* @__PURE__ */ L.cloneElement(e, typeof r == "function" ? r(e.props || {}) : r) : t;
11
- function $r(e, t) {
12
- return Fn(e, e, t);
13
- }
14
- var En = { icon: { tag: "svg", attrs: { viewBox: "0 0 1024 1024", focusable: "false" }, children: [{ tag: "path", attrs: { d: "M988 548c-19.9 0-36-16.1-36-36 0-59.4-11.6-117-34.6-171.3a440.45 440.45 0 00-94.3-139.9 437.71 437.71 0 00-139.9-94.3C629 83.6 571.4 72 512 72c-19.9 0-36-16.1-36-36s16.1-36 36-36c69.1 0 136.2 13.5 199.3 40.3C772.3 66 827 103 874 150c47 47 83.9 101.8 109.7 162.7 26.7 63.1 40.2 130.2 40.2 199.3.1 19.9-16 36-35.9 36z" } }] }, name: "loading", theme: "outlined" }, wn = function(t, r) {
15
- return /* @__PURE__ */ $.createElement(on, $e({}, t, {
16
- ref: r,
17
- icon: En
18
- }));
19
- }, Pr = /* @__PURE__ */ $.forwardRef(wn);
20
- process.env.NODE_ENV !== "production" && (Pr.displayName = "LoadingOutlined");
21
- const Rr = /* @__PURE__ */ L.createContext(void 0);
22
- process.env.NODE_ENV !== "production" && (Rr.displayName = "zIndexContext");
23
- const ge = 100, Sn = 10, xn = ge * Sn, On = xn + ge, Nr = {
24
- Modal: ge,
25
- Drawer: ge,
26
- Popover: ge,
27
- Popconfirm: ge,
28
- Tooltip: ge,
29
- Tour: ge,
30
- FloatButton: ge
31
- }, $n = {
32
- SelectLike: 50,
33
- Dropdown: 50,
34
- DatePicker: 50,
35
- Menu: 50,
36
- ImagePreview: 1
37
- };
38
- function Pn(e) {
39
- return e in Nr;
40
- }
41
- const co = (e, t) => {
42
- const [, r] = Nt(), i = L.useContext(Rr), n = Pn(e);
43
- let a;
44
- if (t !== void 0)
45
- a = [t, t];
46
- else {
47
- let o = i ?? 0;
48
- n ? o += // Use preset token zIndex by default but not stack when has parent container
49
- (i ? 0 : r.zIndexPopupBase) + // Container offset
50
- Nr[e] : o += $n[e], a = [i === void 0 ? t : o, o];
51
- }
52
- if (process.env.NODE_ENV !== "production") {
53
- const o = Vt(e), s = r.zIndexPopupBase + On, c = a[0] || 0;
54
- process.env.NODE_ENV !== "production" && o(t !== void 0 || c <= s, "usage", "`zIndex` is over design token `zIndexPopupBase` too much. It may cause unexpected override.");
55
- }
56
- return a;
57
- };
58
- function ie() {
59
- ie = function() {
60
- return t;
61
- };
62
- var e, t = {}, r = Object.prototype, i = r.hasOwnProperty, n = Object.defineProperty || function(F, y, E) {
63
- F[y] = E.value;
64
- }, a = typeof Symbol == "function" ? Symbol : {}, o = a.iterator || "@@iterator", s = a.asyncIterator || "@@asyncIterator", c = a.toStringTag || "@@toStringTag";
65
- function u(F, y, E) {
66
- return Object.defineProperty(F, y, {
67
- value: E,
68
- enumerable: !0,
69
- configurable: !0,
70
- writable: !0
71
- }), F[y];
72
- }
73
- try {
74
- u({}, "");
75
- } catch {
76
- u = function(E, x, H) {
77
- return E[x] = H;
78
- };
79
- }
80
- function l(F, y, E, x) {
81
- var H = y && y.prototype instanceof C ? y : C, N = Object.create(H.prototype), U = new A(x || []);
82
- return n(N, "_invoke", {
83
- value: I(F, E, U)
84
- }), N;
85
- }
86
- function f(F, y, E) {
87
- try {
88
- return {
89
- type: "normal",
90
- arg: F.call(y, E)
91
- };
92
- } catch (x) {
93
- return {
94
- type: "throw",
95
- arg: x
96
- };
97
- }
98
- }
99
- t.wrap = l;
100
- var g = "suspendedStart", O = "suspendedYield", v = "executing", p = "completed", d = {};
101
- function C() {
102
- }
103
- function h() {
104
- }
105
- function b() {
106
- }
107
- var S = {};
108
- u(S, o, function() {
109
- return this;
110
- });
111
- var w = Object.getPrototypeOf, V = w && w(w(K([])));
112
- V && V !== r && i.call(V, o) && (S = V);
113
- var R = b.prototype = C.prototype = Object.create(S);
114
- function _(F) {
115
- ["next", "throw", "return"].forEach(function(y) {
116
- u(F, y, function(E) {
117
- return this._invoke(y, E);
118
- });
119
- });
120
- }
121
- function P(F, y) {
122
- function E(H, N, U, Y) {
123
- var q = f(F[H], F, N);
124
- if (q.type !== "throw") {
125
- var te = q.arg, k = te.value;
126
- return k && ee(k) == "object" && i.call(k, "__await") ? y.resolve(k.__await).then(function(ae) {
127
- E("next", ae, U, Y);
128
- }, function(ae) {
129
- E("throw", ae, U, Y);
130
- }) : y.resolve(k).then(function(ae) {
131
- te.value = ae, U(te);
132
- }, function(ae) {
133
- return E("throw", ae, U, Y);
134
- });
135
- }
136
- Y(q.arg);
137
- }
138
- var x;
139
- n(this, "_invoke", {
140
- value: function(N, U) {
141
- function Y() {
142
- return new y(function(q, te) {
143
- E(N, U, q, te);
144
- });
145
- }
146
- return x = x ? x.then(Y, Y) : Y();
147
- }
148
- });
149
- }
150
- function I(F, y, E) {
151
- var x = g;
152
- return function(H, N) {
153
- if (x === v) throw Error("Generator is already running");
154
- if (x === p) {
155
- if (H === "throw") throw N;
156
- return {
157
- value: e,
158
- done: !0
159
- };
160
- }
161
- for (E.method = H, E.arg = N; ; ) {
162
- var U = E.delegate;
163
- if (U) {
164
- var Y = M(U, E);
165
- if (Y) {
166
- if (Y === d) continue;
167
- return Y;
168
- }
169
- }
170
- if (E.method === "next") E.sent = E._sent = E.arg;
171
- else if (E.method === "throw") {
172
- if (x === g) throw x = p, E.arg;
173
- E.dispatchException(E.arg);
174
- } else E.method === "return" && E.abrupt("return", E.arg);
175
- x = v;
176
- var q = f(F, y, E);
177
- if (q.type === "normal") {
178
- if (x = E.done ? p : O, q.arg === d) continue;
179
- return {
180
- value: q.arg,
181
- done: E.done
182
- };
183
- }
184
- q.type === "throw" && (x = p, E.method = "throw", E.arg = q.arg);
185
- }
186
- };
187
- }
188
- function M(F, y) {
189
- var E = y.method, x = F.iterator[E];
190
- if (x === e) return y.delegate = null, E === "throw" && F.iterator.return && (y.method = "return", y.arg = e, M(F, y), y.method === "throw") || E !== "return" && (y.method = "throw", y.arg = new TypeError("The iterator does not provide a '" + E + "' method")), d;
191
- var H = f(x, F.iterator, y.arg);
192
- if (H.type === "throw") return y.method = "throw", y.arg = H.arg, y.delegate = null, d;
193
- var N = H.arg;
194
- return N ? N.done ? (y[F.resultName] = N.value, y.next = F.nextLoc, y.method !== "return" && (y.method = "next", y.arg = e), y.delegate = null, d) : N : (y.method = "throw", y.arg = new TypeError("iterator result is not an object"), y.delegate = null, d);
195
- }
196
- function z(F) {
197
- var y = {
198
- tryLoc: F[0]
199
- };
200
- 1 in F && (y.catchLoc = F[1]), 2 in F && (y.finallyLoc = F[2], y.afterLoc = F[3]), this.tryEntries.push(y);
201
- }
202
- function j(F) {
203
- var y = F.completion || {};
204
- y.type = "normal", delete y.arg, F.completion = y;
205
- }
206
- function A(F) {
207
- this.tryEntries = [{
208
- tryLoc: "root"
209
- }], F.forEach(z, this), this.reset(!0);
210
- }
211
- function K(F) {
212
- if (F || F === "") {
213
- var y = F[o];
214
- if (y) return y.call(F);
215
- if (typeof F.next == "function") return F;
216
- if (!isNaN(F.length)) {
217
- var E = -1, x = function H() {
218
- for (; ++E < F.length; ) if (i.call(F, E)) return H.value = F[E], H.done = !1, H;
219
- return H.value = e, H.done = !0, H;
220
- };
221
- return x.next = x;
222
- }
223
- }
224
- throw new TypeError(ee(F) + " is not iterable");
225
- }
226
- return h.prototype = b, n(R, "constructor", {
227
- value: b,
228
- configurable: !0
229
- }), n(b, "constructor", {
230
- value: h,
231
- configurable: !0
232
- }), h.displayName = u(b, c, "GeneratorFunction"), t.isGeneratorFunction = function(F) {
233
- var y = typeof F == "function" && F.constructor;
234
- return !!y && (y === h || (y.displayName || y.name) === "GeneratorFunction");
235
- }, t.mark = function(F) {
236
- return Object.setPrototypeOf ? Object.setPrototypeOf(F, b) : (F.__proto__ = b, u(F, c, "GeneratorFunction")), F.prototype = Object.create(R), F;
237
- }, t.awrap = function(F) {
238
- return {
239
- __await: F
240
- };
241
- }, _(P.prototype), u(P.prototype, s, function() {
242
- return this;
243
- }), t.AsyncIterator = P, t.async = function(F, y, E, x, H) {
244
- H === void 0 && (H = Promise);
245
- var N = new P(l(F, y, E, x), H);
246
- return t.isGeneratorFunction(y) ? N : N.next().then(function(U) {
247
- return U.done ? U.value : N.next();
248
- });
249
- }, _(R), u(R, c, "Generator"), u(R, o, function() {
250
- return this;
251
- }), u(R, "toString", function() {
252
- return "[object Generator]";
253
- }), t.keys = function(F) {
254
- var y = Object(F), E = [];
255
- for (var x in y) E.push(x);
256
- return E.reverse(), function H() {
257
- for (; E.length; ) {
258
- var N = E.pop();
259
- if (N in y) return H.value = N, H.done = !1, H;
260
- }
261
- return H.done = !0, H;
262
- };
263
- }, t.values = K, A.prototype = {
264
- constructor: A,
265
- reset: function(y) {
266
- if (this.prev = 0, this.next = 0, this.sent = this._sent = e, this.done = !1, this.delegate = null, this.method = "next", this.arg = e, this.tryEntries.forEach(j), !y) for (var E in this) E.charAt(0) === "t" && i.call(this, E) && !isNaN(+E.slice(1)) && (this[E] = e);
267
- },
268
- stop: function() {
269
- this.done = !0;
270
- var y = this.tryEntries[0].completion;
271
- if (y.type === "throw") throw y.arg;
272
- return this.rval;
273
- },
274
- dispatchException: function(y) {
275
- if (this.done) throw y;
276
- var E = this;
277
- function x(te, k) {
278
- return U.type = "throw", U.arg = y, E.next = te, k && (E.method = "next", E.arg = e), !!k;
279
- }
280
- for (var H = this.tryEntries.length - 1; H >= 0; --H) {
281
- var N = this.tryEntries[H], U = N.completion;
282
- if (N.tryLoc === "root") return x("end");
283
- if (N.tryLoc <= this.prev) {
284
- var Y = i.call(N, "catchLoc"), q = i.call(N, "finallyLoc");
285
- if (Y && q) {
286
- if (this.prev < N.catchLoc) return x(N.catchLoc, !0);
287
- if (this.prev < N.finallyLoc) return x(N.finallyLoc);
288
- } else if (Y) {
289
- if (this.prev < N.catchLoc) return x(N.catchLoc, !0);
290
- } else {
291
- if (!q) throw Error("try statement without catch or finally");
292
- if (this.prev < N.finallyLoc) return x(N.finallyLoc);
293
- }
294
- }
295
- }
296
- },
297
- abrupt: function(y, E) {
298
- for (var x = this.tryEntries.length - 1; x >= 0; --x) {
299
- var H = this.tryEntries[x];
300
- if (H.tryLoc <= this.prev && i.call(H, "finallyLoc") && this.prev < H.finallyLoc) {
301
- var N = H;
302
- break;
303
- }
304
- }
305
- N && (y === "break" || y === "continue") && N.tryLoc <= E && E <= N.finallyLoc && (N = null);
306
- var U = N ? N.completion : {};
307
- return U.type = y, U.arg = E, N ? (this.method = "next", this.next = N.finallyLoc, d) : this.complete(U);
308
- },
309
- complete: function(y, E) {
310
- if (y.type === "throw") throw y.arg;
311
- return y.type === "break" || y.type === "continue" ? this.next = y.arg : y.type === "return" ? (this.rval = this.arg = y.arg, this.method = "return", this.next = "end") : y.type === "normal" && E && (this.next = E), d;
312
- },
313
- finish: function(y) {
314
- for (var E = this.tryEntries.length - 1; E >= 0; --E) {
315
- var x = this.tryEntries[E];
316
- if (x.finallyLoc === y) return this.complete(x.completion, x.afterLoc), j(x), d;
317
- }
318
- },
319
- catch: function(y) {
320
- for (var E = this.tryEntries.length - 1; E >= 0; --E) {
321
- var x = this.tryEntries[E];
322
- if (x.tryLoc === y) {
323
- var H = x.completion;
324
- if (H.type === "throw") {
325
- var N = H.arg;
326
- j(x);
327
- }
328
- return N;
329
- }
330
- }
331
- throw Error("illegal catch attempt");
332
- },
333
- delegateYield: function(y, E, x) {
334
- return this.delegate = {
335
- iterator: K(y),
336
- resultName: E,
337
- nextLoc: x
338
- }, this.method === "next" && (this.arg = e), d;
339
- }
340
- }, t;
341
- }
342
- function rr(e, t, r, i, n, a, o) {
343
- try {
344
- var s = e[a](o), c = s.value;
345
- } catch (u) {
346
- return void r(u);
347
- }
348
- s.done ? t(c) : Promise.resolve(c).then(i, n);
349
- }
350
- function Ee(e) {
351
- return function() {
352
- var t = this, r = arguments;
353
- return new Promise(function(i, n) {
354
- var a = e.apply(t, r);
355
- function o(c) {
356
- rr(a, i, n, o, s, "next", c);
357
- }
358
- function s(c) {
359
- rr(a, i, n, o, s, "throw", c);
360
- }
361
- o(void 0);
362
- });
363
- };
364
- }
365
- var ze = T({}, bn), Rn = ze.version, Nn = ze.render, Vn = ze.unmountComponentAtNode, Je;
366
- try {
367
- var _n = Number((Rn || "").split(".")[0]);
368
- _n >= 18 && (Je = ze.createRoot);
369
- } catch {
370
- }
371
- function nr(e) {
372
- var t = ze.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
373
- t && ee(t) === "object" && (t.usingClientEntryPoint = e);
374
- }
375
- var Ze = "__rc_react_root__";
376
- function In(e, t) {
377
- nr(!0);
378
- var r = t[Ze] || Je(t);
379
- nr(!1), r.render(e), t[Ze] = r;
380
- }
381
- function Ln(e, t) {
382
- Nn(e, t);
383
- }
384
- function Hn(e, t) {
385
- if (Je) {
386
- In(e, t);
387
- return;
388
- }
389
- Ln(e, t);
390
- }
391
- function Tn(e) {
392
- return vt.apply(this, arguments);
393
- }
394
- function vt() {
395
- return vt = Ee(/* @__PURE__ */ ie().mark(function e(t) {
396
- return ie().wrap(function(i) {
397
- for (; ; ) switch (i.prev = i.next) {
398
- case 0:
399
- return i.abrupt("return", Promise.resolve().then(function() {
400
- var n;
401
- (n = t[Ze]) === null || n === void 0 || n.unmount(), delete t[Ze];
402
- }));
403
- case 1:
404
- case "end":
405
- return i.stop();
406
- }
407
- }, e);
408
- })), vt.apply(this, arguments);
409
- }
410
- function An(e) {
411
- Vn(e);
412
- }
413
- function Mn(e) {
414
- return pt.apply(this, arguments);
415
- }
416
- function pt() {
417
- return pt = Ee(/* @__PURE__ */ ie().mark(function e(t) {
418
- return ie().wrap(function(i) {
419
- for (; ; ) switch (i.prev = i.next) {
420
- case 0:
421
- if (Je === void 0) {
422
- i.next = 2;
423
- break;
424
- }
425
- return i.abrupt("return", Tn(t));
426
- case 2:
427
- An(t);
428
- case 3:
429
- case "end":
430
- return i.stop();
431
- }
432
- }, e);
433
- })), pt.apply(this, arguments);
434
- }
435
- const jn = (e) => {
436
- const {
437
- componentCls: t,
438
- colorPrimary: r
439
- } = e;
440
- return {
441
- [t]: {
442
- position: "absolute",
443
- background: "transparent",
444
- pointerEvents: "none",
445
- boxSizing: "border-box",
446
- color: `var(--wave-color, ${r})`,
447
- boxShadow: "0 0 0 0 currentcolor",
448
- opacity: 0.2,
449
- // =================== Motion ===================
450
- "&.wave-motion-appear": {
451
- transition: [`box-shadow 0.4s ${e.motionEaseOutCirc}`, `opacity 2s ${e.motionEaseOutCirc}`].join(","),
452
- "&-active": {
453
- boxShadow: "0 0 0 6px currentcolor",
454
- opacity: 0
455
- },
456
- "&.wave-quick": {
457
- transition: [`box-shadow ${e.motionDurationSlow} ${e.motionEaseInOut}`, `opacity ${e.motionDurationSlow} ${e.motionEaseInOut}`].join(",")
458
- }
459
- }
460
- }
461
- };
462
- }, Bn = sn("Wave", (e) => [jn(e)]), Vr = `${ln}-wave-target`;
463
- function st(e) {
464
- return e && e !== "#fff" && e !== "#ffffff" && e !== "rgb(255, 255, 255)" && e !== "rgba(255, 255, 255, 1)" && !/rgba\((?:\d*, ){3}0\)/.test(e) && // any transparent rgba color
465
- e !== "transparent";
466
- }
467
- function Dn(e) {
468
- const {
469
- borderTopColor: t,
470
- borderColor: r,
471
- backgroundColor: i
472
- } = getComputedStyle(e);
473
- return st(t) ? t : st(r) ? r : st(i) ? i : null;
474
- }
475
- function lt(e) {
476
- return Number.isNaN(e) ? 0 : e;
477
- }
478
- const zn = (e) => {
479
- const {
480
- className: t,
481
- target: r,
482
- component: i
483
- } = e, n = $.useRef(null), [a, o] = $.useState(null), [s, c] = $.useState([]), [u, l] = $.useState(0), [f, g] = $.useState(0), [O, v] = $.useState(0), [p, d] = $.useState(0), [C, h] = $.useState(!1), b = {
484
- left: u,
485
- top: f,
486
- width: O,
487
- height: p,
488
- borderRadius: s.map((V) => `${V}px`).join(" ")
489
- };
490
- a && (b["--wave-color"] = a);
491
- function S() {
492
- const V = getComputedStyle(r);
493
- o(Dn(r));
494
- const R = V.position === "static", {
495
- borderLeftWidth: _,
496
- borderTopWidth: P
497
- } = V;
498
- l(R ? r.offsetLeft : lt(-parseFloat(_))), g(R ? r.offsetTop : lt(-parseFloat(P))), v(r.offsetWidth), d(r.offsetHeight);
499
- const {
500
- borderTopLeftRadius: I,
501
- borderTopRightRadius: M,
502
- borderBottomLeftRadius: z,
503
- borderBottomRightRadius: j
504
- } = V;
505
- c([I, M, j, z].map((A) => lt(parseFloat(A))));
506
- }
507
- if ($.useEffect(() => {
508
- if (r) {
509
- const V = Ye(() => {
510
- S(), h(!0);
511
- });
512
- let R;
513
- return typeof ResizeObserver < "u" && (R = new ResizeObserver(S), R.observe(r)), () => {
514
- Ye.cancel(V), R == null || R.disconnect();
515
- };
516
- }
517
- }, []), !C)
518
- return null;
519
- const w = (i === "Checkbox" || i === "Radio") && (r == null ? void 0 : r.classList.contains(Vr));
520
- return /* @__PURE__ */ $.createElement(Fr, {
521
- visible: !0,
522
- motionAppear: !0,
523
- motionName: "wave-motion",
524
- motionDeadline: 5e3,
525
- onAppearEnd: (V, R) => {
526
- var _;
527
- if (R.deadline || R.propertyName === "opacity") {
528
- const P = (_ = n.current) === null || _ === void 0 ? void 0 : _.parentElement;
529
- Mn(P).then(() => {
530
- P == null || P.remove();
531
- });
532
- }
533
- return !1;
534
- }
535
- }, (V, R) => {
536
- let {
537
- className: _
538
- } = V;
539
- return /* @__PURE__ */ $.createElement("div", {
540
- ref: _t(n, R),
541
- className: ne(t, _, {
542
- "wave-quick": w
543
- }),
544
- style: b
545
- });
546
- });
547
- }, Wn = (e, t) => {
548
- var r;
549
- const {
550
- component: i
551
- } = t;
552
- if (i === "Checkbox" && !(!((r = e.querySelector("input")) === null || r === void 0) && r.checked))
553
- return;
554
- const n = document.createElement("div");
555
- n.style.position = "absolute", n.style.left = "0px", n.style.top = "0px", e == null || e.insertBefore(n, e == null ? void 0 : e.firstChild), Hn(/* @__PURE__ */ $.createElement(zn, Object.assign({}, t, {
556
- target: e
557
- })), n);
558
- }, qn = (e, t, r) => {
559
- const {
560
- wave: i
561
- } = $.useContext(_e), [, n, a] = Nt(), o = It((u) => {
562
- const l = e.current;
563
- if (i != null && i.disabled || !l)
564
- return;
565
- const f = l.querySelector(`.${Vr}`) || l, {
566
- showEffect: g
567
- } = i || {};
568
- (g || Wn)(f, {
569
- className: t,
570
- token: n,
571
- component: r,
572
- event: u,
573
- hashId: a
574
- });
575
- }), s = $.useRef();
576
- return (u) => {
577
- Ye.cancel(s.current), s.current = Ye(() => {
578
- o(u);
579
- });
580
- };
581
- }, _r = (e) => {
582
- const {
583
- children: t,
584
- disabled: r,
585
- component: i
586
- } = e, {
587
- getPrefixCls: n
588
- } = Oe(_e), a = ce(null), o = n("wave"), [, s] = Bn(o), c = qn(a, ne(o, s), i);
589
- if (L.useEffect(() => {
590
- const l = a.current;
591
- if (!l || l.nodeType !== 1 || r)
592
- return;
593
- const f = (g) => {
594
- !cn(g.target) || // No need wave
595
- !l.getAttribute || l.getAttribute("disabled") || l.disabled || l.className.includes("disabled") || l.className.includes("-leave") || c(g);
596
- };
597
- return l.addEventListener("click", f, !0), () => {
598
- l.removeEventListener("click", f, !0);
599
- };
600
- }, [r]), !/* @__PURE__ */ L.isValidElement(t))
601
- return t ?? null;
602
- const u = un(t) ? _t(t.ref, a) : a;
603
- return $r(t, {
604
- ref: u
605
- });
606
- };
607
- process.env.NODE_ENV !== "production" && (_r.displayName = "Wave");
608
- const Gn = (e) => {
609
- const {
610
- componentCls: t
611
- } = e;
612
- return {
613
- [t]: {
614
- "&-block": {
615
- display: "flex",
616
- width: "100%"
617
- },
618
- "&-vertical": {
619
- flexDirection: "column"
620
- }
621
- }
622
- };
623
- }, Un = (e) => {
624
- const {
625
- componentCls: t,
626
- antCls: r
627
- } = e;
628
- return {
629
- [t]: {
630
- display: "inline-flex",
631
- "&-rtl": {
632
- direction: "rtl"
633
- },
634
- "&-vertical": {
635
- flexDirection: "column"
636
- },
637
- "&-align": {
638
- flexDirection: "column",
639
- "&-center": {
640
- alignItems: "center"
641
- },
642
- "&-start": {
643
- alignItems: "flex-start"
644
- },
645
- "&-end": {
646
- alignItems: "flex-end"
647
- },
648
- "&-baseline": {
649
- alignItems: "baseline"
650
- }
651
- },
652
- [`${t}-item:empty`]: {
653
- display: "none"
654
- },
655
- // https://github.com/ant-design/ant-design/issues/47875
656
- [`${t}-item > ${r}-badge-not-a-wrapper:only-child`]: {
657
- display: "block"
658
- }
659
- }
660
- };
661
- }, Kn = (e) => {
662
- const {
663
- componentCls: t
664
- } = e;
665
- return {
666
- [t]: {
667
- "&-gap-row-small": {
668
- rowGap: e.spaceGapSmallSize
669
- },
670
- "&-gap-row-middle": {
671
- rowGap: e.spaceGapMiddleSize
672
- },
673
- "&-gap-row-large": {
674
- rowGap: e.spaceGapLargeSize
675
- },
676
- "&-gap-col-small": {
677
- columnGap: e.spaceGapSmallSize
678
- },
679
- "&-gap-col-middle": {
680
- columnGap: e.spaceGapMiddleSize
681
- },
682
- "&-gap-col-large": {
683
- columnGap: e.spaceGapLargeSize
684
- }
685
- }
686
- };
687
- }, Yn = Er("Space", (e) => {
688
- const t = Be(e, {
689
- spaceGapSmallSize: e.paddingXS,
690
- spaceGapMiddleSize: e.padding,
691
- spaceGapLargeSize: e.paddingLG
692
- });
693
- return [Un(t), Kn(t), Gn(t)];
694
- }, () => ({}), {
695
- // Space component don't apply extra font style
696
- // https://github.com/ant-design/ant-design/issues/40315
697
- resetStyle: !1
698
- });
699
- var Ir = function(e, t) {
700
- var r = {};
701
- for (var i in e) Object.prototype.hasOwnProperty.call(e, i) && t.indexOf(i) < 0 && (r[i] = e[i]);
702
- if (e != null && typeof Object.getOwnPropertySymbols == "function") for (var n = 0, i = Object.getOwnPropertySymbols(e); n < i.length; n++)
703
- t.indexOf(i[n]) < 0 && Object.prototype.propertyIsEnumerable.call(e, i[n]) && (r[i[n]] = e[i[n]]);
704
- return r;
705
- };
706
- const Qe = /* @__PURE__ */ $.createContext(null), Zn = (e, t) => {
707
- const r = $.useContext(Qe), i = $.useMemo(() => {
708
- if (!r)
709
- return "";
710
- const {
711
- compactDirection: n,
712
- isFirstItem: a,
713
- isLastItem: o
714
- } = r, s = n === "vertical" ? "-vertical-" : "-";
715
- return ne(`${e}-compact${s}item`, {
716
- [`${e}-compact${s}first-item`]: a,
717
- [`${e}-compact${s}last-item`]: o,
718
- [`${e}-compact${s}item-rtl`]: t === "rtl"
719
- });
720
- }, [e, t, r]);
721
- return {
722
- compactSize: r == null ? void 0 : r.compactSize,
723
- compactDirection: r == null ? void 0 : r.compactDirection,
724
- compactItemClassnames: i
725
- };
726
- }, Xn = (e) => {
727
- let {
728
- children: t
729
- } = e;
730
- return /* @__PURE__ */ $.createElement(Qe.Provider, {
731
- value: null
732
- }, t);
733
- }, kn = (e) => {
734
- var {
735
- children: t
736
- } = e, r = Ir(e, ["children"]);
737
- return /* @__PURE__ */ $.createElement(Qe.Provider, {
738
- value: r
739
- }, t);
740
- }, uo = (e) => {
741
- const {
742
- getPrefixCls: t,
743
- direction: r
744
- } = $.useContext(_e), {
745
- size: i,
746
- direction: n,
747
- block: a,
748
- prefixCls: o,
749
- className: s,
750
- rootClassName: c,
751
- children: u
752
- } = e, l = Ir(e, ["size", "direction", "block", "prefixCls", "className", "rootClassName", "children"]), f = wr((b) => i ?? b), g = t("space-compact", o), [O, v] = Yn(g), p = ne(g, v, {
753
- [`${g}-rtl`]: r === "rtl",
754
- [`${g}-block`]: a,
755
- [`${g}-vertical`]: n === "vertical"
756
- }, s, c), d = $.useContext(Qe), C = Sr(u), h = $.useMemo(() => C.map((b, S) => {
757
- const w = (b == null ? void 0 : b.key) || `${g}-item-${S}`;
758
- return /* @__PURE__ */ $.createElement(kn, {
759
- key: w,
760
- compactSize: f,
761
- compactDirection: n,
762
- isFirstItem: S === 0 && (!d || (d == null ? void 0 : d.isFirstItem)),
763
- isLastItem: S === C.length - 1 && (!d || (d == null ? void 0 : d.isLastItem))
764
- }, b);
765
- }), [i, C, d]);
766
- return C.length === 0 ? null : O(/* @__PURE__ */ $.createElement("div", Object.assign({
767
- className: p
768
- }, l), h));
769
- };
770
- var Jn = function(e, t) {
771
- var r = {};
772
- for (var i in e) Object.prototype.hasOwnProperty.call(e, i) && t.indexOf(i) < 0 && (r[i] = e[i]);
773
- if (e != null && typeof Object.getOwnPropertySymbols == "function") for (var n = 0, i = Object.getOwnPropertySymbols(e); n < i.length; n++)
774
- t.indexOf(i[n]) < 0 && Object.prototype.propertyIsEnumerable.call(e, i[n]) && (r[i[n]] = e[i[n]]);
775
- return r;
776
- };
777
- const Lr = /* @__PURE__ */ $.createContext(void 0), Qn = (e) => {
778
- const {
779
- getPrefixCls: t,
780
- direction: r
781
- } = $.useContext(_e), {
782
- prefixCls: i,
783
- size: n,
784
- className: a
785
- } = e, o = Jn(e, ["prefixCls", "size", "className"]), s = t("btn-group", i), [, , c] = Nt();
786
- let u = "";
787
- switch (n) {
788
- case "large":
789
- u = "lg";
790
- break;
791
- case "small":
792
- u = "sm";
793
- break;
794
- }
795
- if (process.env.NODE_ENV !== "production") {
796
- const f = Vt("Button.Group");
797
- process.env.NODE_ENV !== "production" && f(!n || ["large", "small", "middle"].includes(n), "usage", "Invalid prop `size`.");
798
- }
799
- const l = ne(s, {
800
- [`${s}-${u}`]: u,
801
- [`${s}-rtl`]: r === "rtl"
802
- }, a, c);
803
- return /* @__PURE__ */ $.createElement(Lr.Provider, {
804
- value: n
805
- }, /* @__PURE__ */ $.createElement("div", Object.assign({}, o, {
806
- className: l
807
- })));
808
- }, ir = /^[\u4E00-\u9FA5]{2}$/, yt = ir.test.bind(ir);
809
- function fo(e) {
810
- return e === "danger" ? {
811
- danger: !0
812
- } : {
813
- type: e
814
- };
815
- }
816
- function ar(e) {
817
- return typeof e == "string";
818
- }
819
- function Ge(e) {
820
- return e === "text" || e === "link";
821
- }
822
- function ei(e, t) {
823
- if (e == null)
824
- return;
825
- const r = t ? " " : "";
826
- return typeof e != "string" && typeof e != "number" && ar(e.type) && yt(e.props.children) ? $r(e, {
827
- children: e.props.children.split("").join(r)
828
- }) : ar(e) ? yt(e) ? /* @__PURE__ */ L.createElement("span", null, e.split("").join(r)) : /* @__PURE__ */ L.createElement("span", null, e) : Cn(e) ? /* @__PURE__ */ L.createElement("span", null, e) : e;
829
- }
830
- function ti(e, t) {
831
- let r = !1;
832
- const i = [];
833
- return L.Children.forEach(e, (n) => {
834
- const a = typeof n, o = a === "string" || a === "number";
835
- if (r && o) {
836
- const s = i.length - 1, c = i[s];
837
- i[s] = `${c}${n}`;
838
- } else
839
- i.push(n);
840
- r = o;
841
- }), L.Children.map(i, (n) => ei(n, t));
842
- }
843
- const Hr = /* @__PURE__ */ ke((e, t) => {
844
- const {
845
- className: r,
846
- style: i,
847
- children: n,
848
- prefixCls: a
849
- } = e, o = ne(`${a}-icon`, r);
850
- return /* @__PURE__ */ L.createElement("span", {
851
- ref: t,
852
- className: o,
853
- style: i
854
- }, n);
855
- }), or = /* @__PURE__ */ ke((e, t) => {
856
- const {
857
- prefixCls: r,
858
- className: i,
859
- style: n,
860
- iconClassName: a
861
- } = e, o = ne(`${r}-loading-icon`, i);
862
- return /* @__PURE__ */ L.createElement(Hr, {
863
- prefixCls: r,
864
- className: o,
865
- style: n,
866
- ref: t
867
- }, /* @__PURE__ */ L.createElement(Pr, {
868
- className: a
869
- }));
870
- }), ct = () => ({
871
- width: 0,
872
- opacity: 0,
873
- transform: "scale(0)"
874
- }), ut = (e) => ({
875
- width: e.scrollWidth,
876
- opacity: 1,
877
- transform: "scale(1)"
878
- }), ri = (e) => {
879
- const {
880
- prefixCls: t,
881
- loading: r,
882
- existIcon: i,
883
- className: n,
884
- style: a
885
- } = e, o = !!r;
886
- return i ? /* @__PURE__ */ L.createElement(or, {
887
- prefixCls: t,
888
- className: n,
889
- style: a
890
- }) : /* @__PURE__ */ L.createElement(Fr, {
891
- visible: o,
892
- // We do not really use this motionName
893
- motionName: `${t}-loading-icon-motion`,
894
- motionLeave: o,
895
- removeOnLeave: !0,
896
- onAppearStart: ct,
897
- onAppearActive: ut,
898
- onEnterStart: ct,
899
- onEnterActive: ut,
900
- onLeaveStart: ut,
901
- onLeaveActive: ct
902
- }, (s, c) => {
903
- let {
904
- className: u,
905
- style: l
906
- } = s;
907
- return /* @__PURE__ */ L.createElement(or, {
908
- prefixCls: t,
909
- className: n,
910
- style: Object.assign(Object.assign({}, a), l),
911
- ref: c,
912
- iconClassName: u
913
- });
914
- });
915
- }, sr = (e, t) => ({
916
- // Border
917
- [`> span, > ${e}`]: {
918
- "&:not(:last-child)": {
919
- [`&, & > ${e}`]: {
920
- "&:not(:disabled)": {
921
- borderInlineEndColor: t
922
- }
923
- }
924
- },
925
- "&:not(:first-child)": {
926
- [`&, & > ${e}`]: {
927
- "&:not(:disabled)": {
928
- borderInlineStartColor: t
929
- }
930
- }
931
- }
932
- }
933
- }), ni = (e) => {
934
- const {
935
- componentCls: t,
936
- fontSize: r,
937
- lineWidth: i,
938
- groupBorderColor: n,
939
- colorErrorHover: a
940
- } = e;
941
- return {
942
- [`${t}-group`]: [
943
- {
944
- position: "relative",
945
- display: "inline-flex",
946
- // Border
947
- [`> span, > ${t}`]: {
948
- "&:not(:last-child)": {
949
- [`&, & > ${t}`]: {
950
- borderStartEndRadius: 0,
951
- borderEndEndRadius: 0
952
- }
953
- },
954
- "&:not(:first-child)": {
955
- marginInlineStart: e.calc(i).mul(-1).equal(),
956
- [`&, & > ${t}`]: {
957
- borderStartStartRadius: 0,
958
- borderEndStartRadius: 0
959
- }
960
- }
961
- },
962
- [t]: {
963
- position: "relative",
964
- zIndex: 1,
965
- "&:hover, &:focus, &:active": {
966
- zIndex: 2
967
- },
968
- "&[disabled]": {
969
- zIndex: 0
970
- }
971
- },
972
- [`${t}-icon-only`]: {
973
- fontSize: r
974
- }
975
- },
976
- // Border Color
977
- sr(`${t}-primary`, n),
978
- sr(`${t}-danger`, a)
979
- ]
980
- };
981
- }, Q = Math.round;
982
- function dt(e, t) {
983
- const r = e.replace(/^[^(]*\((.*)/, "$1").replace(/\).*/, "").match(/\d*\.?\d+%?/g) || [], i = r.map((n) => parseFloat(n));
984
- for (let n = 0; n < 3; n += 1)
985
- i[n] = t(i[n] || 0, r[n] || "", n);
986
- return r[3] ? i[3] = r[3].includes("%") ? i[3] / 100 : i[3] : i[3] = 1, i;
987
- }
988
- const lr = (e, t, r) => r === 0 ? e : e / 100;
989
- function Le(e, t) {
990
- const r = t || 255;
991
- return e > r ? r : e < 0 ? 0 : e;
992
- }
993
- class et {
994
- constructor(t) {
995
- m(this, "isValid", !0), m(this, "r", 0), m(this, "g", 0), m(this, "b", 0), m(this, "a", 1), m(this, "_h", void 0), m(this, "_s", void 0), m(this, "_l", void 0), m(this, "_v", void 0), m(this, "_max", void 0), m(this, "_min", void 0), m(this, "_brightness", void 0);
996
- function r(i) {
997
- return i[0] in t && i[1] in t && i[2] in t;
998
- }
999
- if (t) if (typeof t == "string") {
1000
- let n = function(a) {
1001
- return i.startsWith(a);
1002
- };
1003
- const i = t.trim();
1004
- /^#?[A-F\d]{3,8}$/i.test(i) ? this.fromHexString(i) : n("rgb") ? this.fromRgbString(i) : n("hsl") ? this.fromHslString(i) : (n("hsv") || n("hsb")) && this.fromHsvString(i);
1005
- } else if (t instanceof et)
1006
- this.r = t.r, this.g = t.g, this.b = t.b, this.a = t.a, this._h = t._h, this._s = t._s, this._l = t._l, this._v = t._v;
1007
- else if (r("rgb"))
1008
- this.r = Le(t.r), this.g = Le(t.g), this.b = Le(t.b), this.a = typeof t.a == "number" ? Le(t.a, 1) : 1;
1009
- else if (r("hsl"))
1010
- this.fromHsl(t);
1011
- else if (r("hsv"))
1012
- this.fromHsv(t);
1013
- else
1014
- throw new Error("@ant-design/fast-color: unsupported input " + JSON.stringify(t));
1015
- }
1016
- // ======================= Setter =======================
1017
- setR(t) {
1018
- return this._sc("r", t);
1019
- }
1020
- setG(t) {
1021
- return this._sc("g", t);
1022
- }
1023
- setB(t) {
1024
- return this._sc("b", t);
1025
- }
1026
- setA(t) {
1027
- return this._sc("a", t, 1);
1028
- }
1029
- setHue(t) {
1030
- const r = this.toHsv();
1031
- return r.h = t, this._c(r);
1032
- }
1033
- // ======================= Getter =======================
1034
- /**
1035
- * Returns the perceived luminance of a color, from 0-1.
1036
- * @see http://www.w3.org/TR/2008/REC-WCAG20-20081211/#relativeluminancedef
1037
- */
1038
- getLuminance() {
1039
- function t(a) {
1040
- const o = a / 255;
1041
- return o <= 0.03928 ? o / 12.92 : Math.pow((o + 0.055) / 1.055, 2.4);
1042
- }
1043
- const r = t(this.r), i = t(this.g), n = t(this.b);
1044
- return 0.2126 * r + 0.7152 * i + 0.0722 * n;
1045
- }
1046
- getHue() {
1047
- if (typeof this._h > "u") {
1048
- const t = this.getMax() - this.getMin();
1049
- t === 0 ? this._h = 0 : this._h = Q(60 * (this.r === this.getMax() ? (this.g - this.b) / t + (this.g < this.b ? 6 : 0) : this.g === this.getMax() ? (this.b - this.r) / t + 2 : (this.r - this.g) / t + 4));
1050
- }
1051
- return this._h;
1052
- }
1053
- getSaturation() {
1054
- if (typeof this._s > "u") {
1055
- const t = this.getMax() - this.getMin();
1056
- t === 0 ? this._s = 0 : this._s = t / this.getMax();
1057
- }
1058
- return this._s;
1059
- }
1060
- getLightness() {
1061
- return typeof this._l > "u" && (this._l = (this.getMax() + this.getMin()) / 510), this._l;
1062
- }
1063
- getValue() {
1064
- return typeof this._v > "u" && (this._v = this.getMax() / 255), this._v;
1065
- }
1066
- /**
1067
- * Returns the perceived brightness of the color, from 0-255.
1068
- * Note: this is not the b of HSB
1069
- * @see http://www.w3.org/TR/AERT#color-contrast
1070
- */
1071
- getBrightness() {
1072
- return typeof this._brightness > "u" && (this._brightness = (this.r * 299 + this.g * 587 + this.b * 114) / 1e3), this._brightness;
1073
- }
1074
- // ======================== Func ========================
1075
- darken(t = 10) {
1076
- const r = this.getHue(), i = this.getSaturation();
1077
- let n = this.getLightness() - t / 100;
1078
- return n < 0 && (n = 0), this._c({
1079
- h: r,
1080
- s: i,
1081
- l: n,
1082
- a: this.a
1083
- });
1084
- }
1085
- lighten(t = 10) {
1086
- const r = this.getHue(), i = this.getSaturation();
1087
- let n = this.getLightness() + t / 100;
1088
- return n > 1 && (n = 1), this._c({
1089
- h: r,
1090
- s: i,
1091
- l: n,
1092
- a: this.a
1093
- });
1094
- }
1095
- /**
1096
- * Mix the current color a given amount with another color, from 0 to 100.
1097
- * 0 means no mixing (return current color).
1098
- */
1099
- mix(t, r = 50) {
1100
- const i = this._c(t), n = r / 100, a = (s) => (i[s] - this[s]) * n + this[s], o = {
1101
- r: Q(a("r")),
1102
- g: Q(a("g")),
1103
- b: Q(a("b")),
1104
- a: Q(a("a") * 100) / 100
1105
- };
1106
- return this._c(o);
1107
- }
1108
- /**
1109
- * Mix the color with pure white, from 0 to 100.
1110
- * Providing 0 will do nothing, providing 100 will always return white.
1111
- */
1112
- tint(t = 10) {
1113
- return this.mix({
1114
- r: 255,
1115
- g: 255,
1116
- b: 255,
1117
- a: 1
1118
- }, t);
1119
- }
1120
- /**
1121
- * Mix the color with pure black, from 0 to 100.
1122
- * Providing 0 will do nothing, providing 100 will always return black.
1123
- */
1124
- shade(t = 10) {
1125
- return this.mix({
1126
- r: 0,
1127
- g: 0,
1128
- b: 0,
1129
- a: 1
1130
- }, t);
1131
- }
1132
- onBackground(t) {
1133
- const r = this._c(t), i = this.a + r.a * (1 - this.a), n = (a) => Q((this[a] * this.a + r[a] * r.a * (1 - this.a)) / i);
1134
- return this._c({
1135
- r: n("r"),
1136
- g: n("g"),
1137
- b: n("b"),
1138
- a: i
1139
- });
1140
- }
1141
- // ======================= Status =======================
1142
- isDark() {
1143
- return this.getBrightness() < 128;
1144
- }
1145
- isLight() {
1146
- return this.getBrightness() >= 128;
1147
- }
1148
- // ======================== MISC ========================
1149
- equals(t) {
1150
- return this.r === t.r && this.g === t.g && this.b === t.b && this.a === t.a;
1151
- }
1152
- clone() {
1153
- return this._c(this);
1154
- }
1155
- // ======================= Format =======================
1156
- toHexString() {
1157
- let t = "#";
1158
- const r = (this.r || 0).toString(16);
1159
- t += r.length === 2 ? r : "0" + r;
1160
- const i = (this.g || 0).toString(16);
1161
- t += i.length === 2 ? i : "0" + i;
1162
- const n = (this.b || 0).toString(16);
1163
- if (t += n.length === 2 ? n : "0" + n, typeof this.a == "number" && this.a >= 0 && this.a < 1) {
1164
- const a = Q(this.a * 255).toString(16);
1165
- t += a.length === 2 ? a : "0" + a;
1166
- }
1167
- return t;
1168
- }
1169
- /** CSS support color pattern */
1170
- toHsl() {
1171
- return {
1172
- h: this.getHue(),
1173
- s: this.getSaturation(),
1174
- l: this.getLightness(),
1175
- a: this.a
1176
- };
1177
- }
1178
- /** CSS support color pattern */
1179
- toHslString() {
1180
- const t = this.getHue(), r = Q(this.getSaturation() * 100), i = Q(this.getLightness() * 100);
1181
- return this.a !== 1 ? `hsla(${t},${r}%,${i}%,${this.a})` : `hsl(${t},${r}%,${i}%)`;
1182
- }
1183
- /** Same as toHsb */
1184
- toHsv() {
1185
- return {
1186
- h: this.getHue(),
1187
- s: this.getSaturation(),
1188
- v: this.getValue(),
1189
- a: this.a
1190
- };
1191
- }
1192
- toRgb() {
1193
- return {
1194
- r: this.r,
1195
- g: this.g,
1196
- b: this.b,
1197
- a: this.a
1198
- };
1199
- }
1200
- toRgbString() {
1201
- return this.a !== 1 ? `rgba(${this.r},${this.g},${this.b},${this.a})` : `rgb(${this.r},${this.g},${this.b})`;
1202
- }
1203
- toString() {
1204
- return this.toRgbString();
1205
- }
1206
- // ====================== Privates ======================
1207
- /** Return a new FastColor object with one channel changed */
1208
- _sc(t, r, i) {
1209
- const n = this.clone();
1210
- return n[t] = Le(r, i), n;
1211
- }
1212
- _c(t) {
1213
- return new this.constructor(t);
1214
- }
1215
- getMax() {
1216
- return typeof this._max > "u" && (this._max = Math.max(this.r, this.g, this.b)), this._max;
1217
- }
1218
- getMin() {
1219
- return typeof this._min > "u" && (this._min = Math.min(this.r, this.g, this.b)), this._min;
1220
- }
1221
- fromHexString(t) {
1222
- const r = t.replace("#", "");
1223
- function i(n, a) {
1224
- return parseInt(r[n] + r[a || n], 16);
1225
- }
1226
- r.length < 6 ? (this.r = i(0), this.g = i(1), this.b = i(2), this.a = r[3] ? i(3) / 255 : 1) : (this.r = i(0, 1), this.g = i(2, 3), this.b = i(4, 5), this.a = r[6] ? i(6, 7) / 255 : 1);
1227
- }
1228
- fromHsl({
1229
- h: t,
1230
- s: r,
1231
- l: i,
1232
- a: n
1233
- }) {
1234
- if (this._h = t % 360, this._s = r, this._l = i, this.a = typeof n == "number" ? n : 1, r <= 0) {
1235
- const g = Q(i * 255);
1236
- this.r = g, this.g = g, this.b = g;
1237
- }
1238
- let a = 0, o = 0, s = 0;
1239
- const c = t / 60, u = (1 - Math.abs(2 * i - 1)) * r, l = u * (1 - Math.abs(c % 2 - 1));
1240
- c >= 0 && c < 1 ? (a = u, o = l) : c >= 1 && c < 2 ? (a = l, o = u) : c >= 2 && c < 3 ? (o = u, s = l) : c >= 3 && c < 4 ? (o = l, s = u) : c >= 4 && c < 5 ? (a = l, s = u) : c >= 5 && c < 6 && (a = u, s = l);
1241
- const f = i - u / 2;
1242
- this.r = Q((a + f) * 255), this.g = Q((o + f) * 255), this.b = Q((s + f) * 255);
1243
- }
1244
- fromHsv({
1245
- h: t,
1246
- s: r,
1247
- v: i,
1248
- a: n
1249
- }) {
1250
- this._h = t % 360, this._s = r, this._v = i, this.a = typeof n == "number" ? n : 1;
1251
- const a = Q(i * 255);
1252
- if (this.r = a, this.g = a, this.b = a, r <= 0)
1253
- return;
1254
- const o = t / 60, s = Math.floor(o), c = o - s, u = Q(i * (1 - r) * 255), l = Q(i * (1 - r * c) * 255), f = Q(i * (1 - r * (1 - c)) * 255);
1255
- switch (s) {
1256
- case 0:
1257
- this.g = f, this.b = u;
1258
- break;
1259
- case 1:
1260
- this.r = l, this.b = u;
1261
- break;
1262
- case 2:
1263
- this.r = u, this.b = f;
1264
- break;
1265
- case 3:
1266
- this.r = u, this.g = l;
1267
- break;
1268
- case 4:
1269
- this.r = f, this.g = u;
1270
- break;
1271
- case 5:
1272
- default:
1273
- this.g = u, this.b = l;
1274
- break;
1275
- }
1276
- }
1277
- fromHsvString(t) {
1278
- const r = dt(t, lr);
1279
- this.fromHsv({
1280
- h: r[0],
1281
- s: r[1],
1282
- v: r[2],
1283
- a: r[3]
1284
- });
1285
- }
1286
- fromHslString(t) {
1287
- const r = dt(t, lr);
1288
- this.fromHsl({
1289
- h: r[0],
1290
- s: r[1],
1291
- l: r[2],
1292
- a: r[3]
1293
- });
1294
- }
1295
- fromRgbString(t) {
1296
- const r = dt(t, (i, n) => (
1297
- // Convert percentage to number. e.g. 50% -> 128
1298
- n.includes("%") ? Q(i / 100 * 255) : i
1299
- ));
1300
- this.r = r[0], this.g = r[1], this.b = r[2], this.a = r[3];
1301
- }
1302
- }
1303
- var ii = ["b"], ai = ["v"], ft = function(t) {
1304
- return Math.round(Number(t || 0));
1305
- }, oi = function(t) {
1306
- if (t instanceof et)
1307
- return t;
1308
- if (t && ee(t) === "object" && "h" in t && "b" in t) {
1309
- var r = t, i = r.b, n = De(r, ii);
1310
- return T(T({}, n), {}, {
1311
- v: i
1312
- });
1313
- }
1314
- return typeof t == "string" && /hsb/.test(t) ? t.replace(/hsb/, "hsv") : t;
1315
- }, he = /* @__PURE__ */ function(e) {
1316
- Lt(r, e);
1317
- var t = Ht(r);
1318
- function r(i) {
1319
- return Ce(this, r), t.call(this, oi(i));
1320
- }
1321
- return Fe(r, [{
1322
- key: "toHsbString",
1323
- value: function() {
1324
- var n = this.toHsb(), a = ft(n.s * 100), o = ft(n.b * 100), s = ft(n.h), c = n.a, u = "hsb(".concat(s, ", ").concat(a, "%, ").concat(o, "%)"), l = "hsba(".concat(s, ", ").concat(a, "%, ").concat(o, "%, ").concat(c.toFixed(c === 0 ? 0 : 2), ")");
1325
- return c === 1 ? u : l;
1326
- }
1327
- }, {
1328
- key: "toHsb",
1329
- value: function() {
1330
- var n = this.toHsv(), a = n.v, o = De(n, ai);
1331
- return T(T({}, o), {}, {
1332
- b: a,
1333
- a: this.a
1334
- });
1335
- }
1336
- }]), r;
1337
- }(et), si = "rc-color-picker", Pe = function(t) {
1338
- return t instanceof he ? t : new he(t);
1339
- }, li = Pe("#1677ff"), Tr = function(t) {
1340
- var r = t.offset, i = t.targetRef, n = t.containerRef, a = t.color, o = t.type, s = n.current.getBoundingClientRect(), c = s.width, u = s.height, l = i.current.getBoundingClientRect(), f = l.width, g = l.height, O = f / 2, v = g / 2, p = (r.x + O) / c, d = 1 - (r.y + v) / u, C = a.toHsb(), h = p, b = (r.x + O) / c * 360;
1341
- if (o)
1342
- switch (o) {
1343
- case "hue":
1344
- return Pe(T(T({}, C), {}, {
1345
- h: b <= 0 ? 0 : b
1346
- }));
1347
- case "alpha":
1348
- return Pe(T(T({}, C), {}, {
1349
- a: h <= 0 ? 0 : h
1350
- }));
1351
- }
1352
- return Pe({
1353
- h: C.h,
1354
- s: p <= 0 ? 0 : p,
1355
- b: d >= 1 ? 1 : d,
1356
- a: C.a
1357
- });
1358
- }, Ar = function(t, r) {
1359
- var i = t.toHsb();
1360
- switch (r) {
1361
- case "hue":
1362
- return {
1363
- x: i.h / 360 * 100,
1364
- y: 50
1365
- };
1366
- case "alpha":
1367
- return {
1368
- x: t.a * 100,
1369
- y: 50
1370
- };
1371
- default:
1372
- return {
1373
- x: i.s * 100,
1374
- y: (1 - i.b) * 100
1375
- };
1376
- }
1377
- }, ci = function(t) {
1378
- var r = t.color, i = t.prefixCls, n = t.className, a = t.style, o = t.onClick, s = "".concat(i, "-color-block");
1379
- return /* @__PURE__ */ L.createElement("div", {
1380
- className: ne(s, n),
1381
- style: a,
1382
- onClick: o
1383
- }, /* @__PURE__ */ L.createElement("div", {
1384
- className: "".concat(s, "-inner"),
1385
- style: {
1386
- background: r
1387
- }
1388
- }));
1389
- };
1390
- function ui(e) {
1391
- var t = "touches" in e ? e.touches[0] : e, r = document.documentElement.scrollLeft || document.body.scrollLeft || window.pageXOffset, i = document.documentElement.scrollTop || document.body.scrollTop || window.pageYOffset;
1392
- return {
1393
- pageX: t.pageX - r,
1394
- pageY: t.pageY - i
1395
- };
1396
- }
1397
- function Mr(e) {
1398
- var t = e.targetRef, r = e.containerRef, i = e.direction, n = e.onDragChange, a = e.onDragChangeComplete, o = e.calculate, s = e.color, c = e.disabledDrag, u = Ke({
1399
- x: 0,
1400
- y: 0
1401
- }), l = de(u, 2), f = l[0], g = l[1], O = ce(null), v = ce(null);
1402
- Me(function() {
1403
- g(o());
1404
- }, [s]), Me(function() {
1405
- return function() {
1406
- document.removeEventListener("mousemove", O.current), document.removeEventListener("mouseup", v.current), document.removeEventListener("touchmove", O.current), document.removeEventListener("touchend", v.current), O.current = null, v.current = null;
1407
- };
1408
- }, []);
1409
- var p = function(S) {
1410
- var w = ui(S), V = w.pageX, R = w.pageY, _ = r.current.getBoundingClientRect(), P = _.x, I = _.y, M = _.width, z = _.height, j = t.current.getBoundingClientRect(), A = j.width, K = j.height, F = A / 2, y = K / 2, E = Math.max(0, Math.min(V - P, M)) - F, x = Math.max(0, Math.min(R - I, z)) - y, H = {
1411
- x: E,
1412
- y: i === "x" ? f.y : x
1413
- };
1414
- if (A === 0 && K === 0 || A !== K)
1415
- return !1;
1416
- n == null || n(H);
1417
- }, d = function(S) {
1418
- S.preventDefault(), p(S);
1419
- }, C = function(S) {
1420
- S.preventDefault(), document.removeEventListener("mousemove", O.current), document.removeEventListener("mouseup", v.current), document.removeEventListener("touchmove", O.current), document.removeEventListener("touchend", v.current), O.current = null, v.current = null, a == null || a();
1421
- }, h = function(S) {
1422
- document.removeEventListener("mousemove", O.current), document.removeEventListener("mouseup", v.current), !c && (p(S), document.addEventListener("mousemove", d), document.addEventListener("mouseup", C), document.addEventListener("touchmove", d), document.addEventListener("touchend", C), O.current = d, v.current = C);
1423
- };
1424
- return [f, h];
1425
- }
1426
- var jr = function(t) {
1427
- var r = t.size, i = r === void 0 ? "default" : r, n = t.color, a = t.prefixCls;
1428
- return /* @__PURE__ */ L.createElement("div", {
1429
- className: ne("".concat(a, "-handler"), m({}, "".concat(a, "-handler-sm"), i === "small")),
1430
- style: {
1431
- backgroundColor: n
1432
- }
1433
- });
1434
- }, Br = function(t) {
1435
- var r = t.children, i = t.style, n = t.prefixCls;
1436
- return /* @__PURE__ */ L.createElement("div", {
1437
- className: "".concat(n, "-palette"),
1438
- style: T({
1439
- position: "relative"
1440
- }, i)
1441
- }, r);
1442
- }, Dr = /* @__PURE__ */ ke(function(e, t) {
1443
- var r = e.children, i = e.x, n = e.y;
1444
- return /* @__PURE__ */ L.createElement("div", {
1445
- ref: t,
1446
- style: {
1447
- position: "absolute",
1448
- left: "".concat(i, "%"),
1449
- top: "".concat(n, "%"),
1450
- zIndex: 1,
1451
- transform: "translate(-50%, -50%)"
1452
- }
1453
- }, r);
1454
- }), di = function(t) {
1455
- var r = t.color, i = t.onChange, n = t.prefixCls, a = t.onChangeComplete, o = t.disabled, s = ce(), c = ce(), u = ce(r), l = It(function(p) {
1456
- var d = Tr({
1457
- offset: p,
1458
- targetRef: c,
1459
- containerRef: s,
1460
- color: r
1461
- });
1462
- u.current = d, i(d);
1463
- }), f = Mr({
1464
- color: r,
1465
- containerRef: s,
1466
- targetRef: c,
1467
- calculate: function() {
1468
- return Ar(r);
1469
- },
1470
- onDragChange: l,
1471
- onDragChangeComplete: function() {
1472
- return a == null ? void 0 : a(u.current);
1473
- },
1474
- disabledDrag: o
1475
- }), g = de(f, 2), O = g[0], v = g[1];
1476
- return /* @__PURE__ */ L.createElement("div", {
1477
- ref: s,
1478
- className: "".concat(n, "-select"),
1479
- onMouseDown: v,
1480
- onTouchStart: v
1481
- }, /* @__PURE__ */ L.createElement(Br, {
1482
- prefixCls: n
1483
- }, /* @__PURE__ */ L.createElement(Dr, {
1484
- x: O.x,
1485
- y: O.y,
1486
- ref: c
1487
- }, /* @__PURE__ */ L.createElement(jr, {
1488
- color: r.toRgbString(),
1489
- prefixCls: n
1490
- })), /* @__PURE__ */ L.createElement("div", {
1491
- className: "".concat(n, "-saturation"),
1492
- style: {
1493
- backgroundColor: "hsl(".concat(r.toHsb().h, ",100%, 50%)"),
1494
- backgroundImage: "linear-gradient(0deg, #000, transparent),linear-gradient(90deg, #fff, hsla(0, 0%, 100%, 0))"
1495
- }
1496
- })));
1497
- }, fi = function(t, r) {
1498
- var i = xr(t, {
1499
- value: r
1500
- }), n = de(i, 2), a = n[0], o = n[1], s = be(function() {
1501
- return Pe(a);
1502
- }, [a]);
1503
- return [s, o];
1504
- }, gi = function(t) {
1505
- var r = t.colors, i = t.children, n = t.direction, a = n === void 0 ? "to right" : n, o = t.type, s = t.prefixCls, c = be(function() {
1506
- return r.map(function(u, l) {
1507
- var f = Pe(u);
1508
- return o === "alpha" && l === r.length - 1 && (f = new he(f.setA(1))), f.toRgbString();
1509
- }).join(",");
1510
- }, [r, o]);
1511
- return /* @__PURE__ */ L.createElement("div", {
1512
- className: "".concat(s, "-gradient"),
1513
- style: {
1514
- position: "absolute",
1515
- inset: 0,
1516
- background: "linear-gradient(".concat(a, ", ").concat(c, ")")
1517
- }
1518
- }, i);
1519
- }, hi = function(t) {
1520
- var r = t.prefixCls, i = t.colors, n = t.disabled, a = t.onChange, o = t.onChangeComplete, s = t.color, c = t.type, u = ce(), l = ce(), f = ce(s), g = function(w) {
1521
- return c === "hue" ? w.getHue() : w.a * 100;
1522
- }, O = It(function(S) {
1523
- var w = Tr({
1524
- offset: S,
1525
- targetRef: l,
1526
- containerRef: u,
1527
- color: s,
1528
- type: c
1529
- });
1530
- f.current = w, a(g(w));
1531
- }), v = Mr({
1532
- color: s,
1533
- targetRef: l,
1534
- containerRef: u,
1535
- calculate: function() {
1536
- return Ar(s, c);
1537
- },
1538
- onDragChange: O,
1539
- onDragChangeComplete: function() {
1540
- o(g(f.current));
1541
- },
1542
- direction: "x",
1543
- disabledDrag: n
1544
- }), p = de(v, 2), d = p[0], C = p[1], h = L.useMemo(function() {
1545
- if (c === "hue") {
1546
- var S = s.toHsb();
1547
- S.s = 1, S.b = 1, S.a = 1;
1548
- var w = new he(S);
1549
- return w;
1550
- }
1551
- return s;
1552
- }, [s, c]), b = L.useMemo(function() {
1553
- return i.map(function(S) {
1554
- return "".concat(S.color, " ").concat(S.percent, "%");
1555
- });
1556
- }, [i]);
1557
- return /* @__PURE__ */ L.createElement("div", {
1558
- ref: u,
1559
- className: ne("".concat(r, "-slider"), "".concat(r, "-slider-").concat(c)),
1560
- onMouseDown: C,
1561
- onTouchStart: C
1562
- }, /* @__PURE__ */ L.createElement(Br, {
1563
- prefixCls: r
1564
- }, /* @__PURE__ */ L.createElement(Dr, {
1565
- x: d.x,
1566
- y: d.y,
1567
- ref: l
1568
- }, /* @__PURE__ */ L.createElement(jr, {
1569
- size: "small",
1570
- color: h.toHexString(),
1571
- prefixCls: r
1572
- })), /* @__PURE__ */ L.createElement(gi, {
1573
- colors: b,
1574
- type: c,
1575
- prefixCls: r
1576
- })));
1577
- };
1578
- function mi(e) {
1579
- return $.useMemo(function() {
1580
- var t = e || {}, r = t.slider;
1581
- return [r || hi];
1582
- }, [e]);
1583
- }
1584
- var vi = [{
1585
- color: "rgb(255, 0, 0)",
1586
- percent: 0
1587
- }, {
1588
- color: "rgb(255, 255, 0)",
1589
- percent: 17
1590
- }, {
1591
- color: "rgb(0, 255, 0)",
1592
- percent: 33
1593
- }, {
1594
- color: "rgb(0, 255, 255)",
1595
- percent: 50
1596
- }, {
1597
- color: "rgb(0, 0, 255)",
1598
- percent: 67
1599
- }, {
1600
- color: "rgb(255, 0, 255)",
1601
- percent: 83
1602
- }, {
1603
- color: "rgb(255, 0, 0)",
1604
- percent: 100
1605
- }], pi = /* @__PURE__ */ ke(function(e, t) {
1606
- var r = e.value, i = e.defaultValue, n = e.prefixCls, a = n === void 0 ? si : n, o = e.onChange, s = e.onChangeComplete, c = e.className, u = e.style, l = e.panelRender, f = e.disabledAlpha, g = f === void 0 ? !1 : f, O = e.disabled, v = O === void 0 ? !1 : O, p = e.components, d = mi(p), C = de(d, 1), h = C[0], b = fi(i || li, r), S = de(b, 2), w = S[0], V = S[1], R = be(function() {
1607
- return w.setA(1).toRgbString();
1608
- }, [w]), _ = function(x, H) {
1609
- r || V(x), o == null || o(x, H);
1610
- }, P = function(x) {
1611
- return new he(w.setHue(x));
1612
- }, I = function(x) {
1613
- return new he(w.setA(x / 100));
1614
- }, M = function(x) {
1615
- _(P(x), {
1616
- type: "hue",
1617
- value: x
1618
- });
1619
- }, z = function(x) {
1620
- _(I(x), {
1621
- type: "alpha",
1622
- value: x
1623
- });
1624
- }, j = function(x) {
1625
- s && s(P(x));
1626
- }, A = function(x) {
1627
- s && s(I(x));
1628
- }, K = ne("".concat(a, "-panel"), c, m({}, "".concat(a, "-panel-disabled"), v)), F = {
1629
- prefixCls: a,
1630
- disabled: v,
1631
- color: w
1632
- }, y = /* @__PURE__ */ L.createElement(L.Fragment, null, /* @__PURE__ */ L.createElement(di, $e({
1633
- onChange: _
1634
- }, F, {
1635
- onChangeComplete: s
1636
- })), /* @__PURE__ */ L.createElement("div", {
1637
- className: "".concat(a, "-slider-container")
1638
- }, /* @__PURE__ */ L.createElement("div", {
1639
- className: ne("".concat(a, "-slider-group"), m({}, "".concat(a, "-slider-group-disabled-alpha"), g))
1640
- }, /* @__PURE__ */ L.createElement(h, $e({}, F, {
1641
- type: "hue",
1642
- colors: vi,
1643
- min: 0,
1644
- max: 359,
1645
- value: w.getHue(),
1646
- onChange: M,
1647
- onChangeComplete: j
1648
- })), !g && /* @__PURE__ */ L.createElement(h, $e({}, F, {
1649
- type: "alpha",
1650
- colors: [{
1651
- percent: 0,
1652
- color: "rgba(255, 0, 4, 0)"
1653
- }, {
1654
- percent: 100,
1655
- color: R
1656
- }],
1657
- min: 0,
1658
- max: 100,
1659
- value: w.a * 100,
1660
- onChange: z,
1661
- onChangeComplete: A
1662
- }))), /* @__PURE__ */ L.createElement(ci, {
1663
- color: w.toRgbString(),
1664
- prefixCls: a
1665
- })));
1666
- return /* @__PURE__ */ L.createElement("div", {
1667
- className: K,
1668
- style: u,
1669
- ref: t
1670
- }, typeof l == "function" ? l(y) : y);
1671
- });
1672
- process.env.NODE_ENV !== "production" && (pi.displayName = "ColorPicker");
1673
- const yi = (e, t) => (e == null ? void 0 : e.replace(/[^\w/]/g, "").slice(0, t ? 8 : 6)) || "", bi = (e, t) => e ? yi(e, t) : "";
1674
- let Ci = /* @__PURE__ */ function() {
1675
- function e(t) {
1676
- Ce(this, e);
1677
- var r;
1678
- if (this.cleared = !1, t instanceof e) {
1679
- this.metaColor = t.metaColor.clone(), this.colors = (r = t.colors) === null || r === void 0 ? void 0 : r.map((n) => ({
1680
- color: new e(n.color),
1681
- percent: n.percent
1682
- })), this.cleared = t.cleared;
1683
- return;
1684
- }
1685
- const i = Array.isArray(t);
1686
- i && t.length ? (this.colors = t.map((n) => {
1687
- let {
1688
- color: a,
1689
- percent: o
1690
- } = n;
1691
- return {
1692
- color: new e(a),
1693
- percent: o
1694
- };
1695
- }), this.metaColor = new he(this.colors[0].color.metaColor)) : this.metaColor = new he(i ? "" : t), (!t || i && !this.colors) && (this.metaColor = this.metaColor.setA(0), this.cleared = !0);
1696
- }
1697
- return Fe(e, [{
1698
- key: "toHsb",
1699
- value: function() {
1700
- return this.metaColor.toHsb();
1701
- }
1702
- }, {
1703
- key: "toHsbString",
1704
- value: function() {
1705
- return this.metaColor.toHsbString();
1706
- }
1707
- }, {
1708
- key: "toHex",
1709
- value: function() {
1710
- return bi(this.toHexString(), this.metaColor.a < 1);
1711
- }
1712
- }, {
1713
- key: "toHexString",
1714
- value: function() {
1715
- return this.metaColor.toHexString();
1716
- }
1717
- }, {
1718
- key: "toRgb",
1719
- value: function() {
1720
- return this.metaColor.toRgb();
1721
- }
1722
- }, {
1723
- key: "toRgbString",
1724
- value: function() {
1725
- return this.metaColor.toRgbString();
1726
- }
1727
- }, {
1728
- key: "isGradient",
1729
- value: function() {
1730
- return !!this.colors && !this.cleared;
1731
- }
1732
- }, {
1733
- key: "getColors",
1734
- value: function() {
1735
- return this.colors || [{
1736
- color: this,
1737
- percent: 0
1738
- }];
1739
- }
1740
- }, {
1741
- key: "toCssString",
1742
- value: function() {
1743
- const {
1744
- colors: r
1745
- } = this;
1746
- return r ? `linear-gradient(90deg, ${r.map((n) => `${n.color.toRgbString()} ${n.percent}%`).join(", ")})` : this.metaColor.toRgbString();
1747
- }
1748
- }, {
1749
- key: "equals",
1750
- value: function(r) {
1751
- return !r || this.isGradient() !== r.isGradient() ? !1 : this.isGradient() ? this.colors.length === r.colors.length && this.colors.every((i, n) => {
1752
- const a = r.colors[n];
1753
- return i.percent === a.percent && i.color.equals(a.color);
1754
- }) : this.toHexString() === r.toHexString();
1755
- }
1756
- }]);
1757
- }();
1758
- const Fi = new ue("antZoomIn", {
1759
- "0%": {
1760
- transform: "scale(0.2)",
1761
- opacity: 0
1762
- },
1763
- "100%": {
1764
- transform: "scale(1)",
1765
- opacity: 1
1766
- }
1767
- }), Ei = new ue("antZoomOut", {
1768
- "0%": {
1769
- transform: "scale(1)"
1770
- },
1771
- "100%": {
1772
- transform: "scale(0.2)",
1773
- opacity: 0
1774
- }
1775
- }), cr = new ue("antZoomBigIn", {
1776
- "0%": {
1777
- transform: "scale(0.8)",
1778
- opacity: 0
1779
- },
1780
- "100%": {
1781
- transform: "scale(1)",
1782
- opacity: 1
1783
- }
1784
- }), ur = new ue("antZoomBigOut", {
1785
- "0%": {
1786
- transform: "scale(1)"
1787
- },
1788
- "100%": {
1789
- transform: "scale(0.8)",
1790
- opacity: 0
1791
- }
1792
- }), wi = new ue("antZoomUpIn", {
1793
- "0%": {
1794
- transform: "scale(0.8)",
1795
- transformOrigin: "50% 0%",
1796
- opacity: 0
1797
- },
1798
- "100%": {
1799
- transform: "scale(1)",
1800
- transformOrigin: "50% 0%"
1801
- }
1802
- }), Si = new ue("antZoomUpOut", {
1803
- "0%": {
1804
- transform: "scale(1)",
1805
- transformOrigin: "50% 0%"
1806
- },
1807
- "100%": {
1808
- transform: "scale(0.8)",
1809
- transformOrigin: "50% 0%",
1810
- opacity: 0
1811
- }
1812
- }), xi = new ue("antZoomLeftIn", {
1813
- "0%": {
1814
- transform: "scale(0.8)",
1815
- transformOrigin: "0% 50%",
1816
- opacity: 0
1817
- },
1818
- "100%": {
1819
- transform: "scale(1)",
1820
- transformOrigin: "0% 50%"
1821
- }
1822
- }), Oi = new ue("antZoomLeftOut", {
1823
- "0%": {
1824
- transform: "scale(1)",
1825
- transformOrigin: "0% 50%"
1826
- },
1827
- "100%": {
1828
- transform: "scale(0.8)",
1829
- transformOrigin: "0% 50%",
1830
- opacity: 0
1831
- }
1832
- }), $i = new ue("antZoomRightIn", {
1833
- "0%": {
1834
- transform: "scale(0.8)",
1835
- transformOrigin: "100% 50%",
1836
- opacity: 0
1837
- },
1838
- "100%": {
1839
- transform: "scale(1)",
1840
- transformOrigin: "100% 50%"
1841
- }
1842
- }), Pi = new ue("antZoomRightOut", {
1843
- "0%": {
1844
- transform: "scale(1)",
1845
- transformOrigin: "100% 50%"
1846
- },
1847
- "100%": {
1848
- transform: "scale(0.8)",
1849
- transformOrigin: "100% 50%",
1850
- opacity: 0
1851
- }
1852
- }), Ri = new ue("antZoomDownIn", {
1853
- "0%": {
1854
- transform: "scale(0.8)",
1855
- transformOrigin: "50% 100%",
1856
- opacity: 0
1857
- },
1858
- "100%": {
1859
- transform: "scale(1)",
1860
- transformOrigin: "50% 100%"
1861
- }
1862
- }), Ni = new ue("antZoomDownOut", {
1863
- "0%": {
1864
- transform: "scale(1)",
1865
- transformOrigin: "50% 100%"
1866
- },
1867
- "100%": {
1868
- transform: "scale(0.8)",
1869
- transformOrigin: "50% 100%",
1870
- opacity: 0
1871
- }
1872
- }), Vi = {
1873
- zoom: {
1874
- inKeyframes: Fi,
1875
- outKeyframes: Ei
1876
- },
1877
- "zoom-big": {
1878
- inKeyframes: cr,
1879
- outKeyframes: ur
1880
- },
1881
- "zoom-big-fast": {
1882
- inKeyframes: cr,
1883
- outKeyframes: ur
1884
- },
1885
- "zoom-left": {
1886
- inKeyframes: xi,
1887
- outKeyframes: Oi
1888
- },
1889
- "zoom-right": {
1890
- inKeyframes: $i,
1891
- outKeyframes: Pi
1892
- },
1893
- "zoom-up": {
1894
- inKeyframes: wi,
1895
- outKeyframes: Si
1896
- },
1897
- "zoom-down": {
1898
- inKeyframes: Ri,
1899
- outKeyframes: Ni
1900
- }
1901
- }, go = (e, t) => {
1902
- const {
1903
- antCls: r
1904
- } = e, i = `${r}-${t}`, {
1905
- inKeyframes: n,
1906
- outKeyframes: a
1907
- } = Vi[t];
1908
- return [dn(i, n, a, t === "zoom-big-fast" ? e.motionDurationFast : e.motionDurationMid), {
1909
- [`
1910
- ${i}-enter,
1911
- ${i}-appear
1912
- `]: {
1913
- transform: "scale(0)",
1914
- opacity: 0,
1915
- animationTimingFunction: e.motionEaseOutCirc,
1916
- "&-prepare": {
1917
- transform: "none"
1918
- }
1919
- },
1920
- [`${i}-leave`]: {
1921
- animationTimingFunction: e.motionEaseInOutCirc
1922
- }
1923
- }];
1924
- }, _i = (e, t) => {
1925
- const {
1926
- r,
1927
- g: i,
1928
- b: n,
1929
- a
1930
- } = e.toRgb(), o = new he(e.toRgbString()).onBackground(t).toHsv();
1931
- return a <= 0.5 ? o.v > 0.5 : r * 0.299 + i * 0.587 + n * 0.114 > 192;
1932
- }, zr = (e) => {
1933
- const {
1934
- paddingInline: t,
1935
- onlyIconSize: r,
1936
- paddingBlock: i
1937
- } = e;
1938
- return Be(e, {
1939
- buttonPaddingHorizontal: t,
1940
- buttonPaddingVertical: i,
1941
- buttonIconOnlyFontSize: r
1942
- });
1943
- }, Wr = (e) => {
1944
- var t, r, i, n, a, o;
1945
- const s = (t = e.contentFontSize) !== null && t !== void 0 ? t : e.fontSize, c = (r = e.contentFontSizeSM) !== null && r !== void 0 ? r : e.fontSize, u = (i = e.contentFontSizeLG) !== null && i !== void 0 ? i : e.fontSizeLG, l = (n = e.contentLineHeight) !== null && n !== void 0 ? n : ot(s), f = (a = e.contentLineHeightSM) !== null && a !== void 0 ? a : ot(c), g = (o = e.contentLineHeightLG) !== null && o !== void 0 ? o : ot(u), O = _i(new Ci(e.colorBgSolid), "#fff") ? "#000" : "#fff";
1946
- return {
1947
- fontWeight: 400,
1948
- defaultShadow: `0 ${e.controlOutlineWidth}px 0 ${e.controlTmpOutline}`,
1949
- primaryShadow: `0 ${e.controlOutlineWidth}px 0 ${e.controlOutline}`,
1950
- dangerShadow: `0 ${e.controlOutlineWidth}px 0 ${e.colorErrorOutline}`,
1951
- primaryColor: e.colorTextLightSolid,
1952
- dangerColor: e.colorTextLightSolid,
1953
- borderColorDisabled: e.colorBorder,
1954
- defaultGhostColor: e.colorBgContainer,
1955
- ghostBg: "transparent",
1956
- defaultGhostBorderColor: e.colorBgContainer,
1957
- paddingInline: e.paddingContentHorizontal - e.lineWidth,
1958
- paddingInlineLG: e.paddingContentHorizontal - e.lineWidth,
1959
- paddingInlineSM: 8 - e.lineWidth,
1960
- onlyIconSize: e.fontSizeLG,
1961
- onlyIconSizeSM: e.fontSizeLG - 2,
1962
- onlyIconSizeLG: e.fontSizeLG + 2,
1963
- groupBorderColor: e.colorPrimaryHover,
1964
- linkHoverBg: "transparent",
1965
- textTextColor: e.colorText,
1966
- textTextHoverColor: e.colorText,
1967
- textTextActiveColor: e.colorText,
1968
- textHoverBg: e.colorFillTertiary,
1969
- defaultColor: e.colorText,
1970
- defaultBg: e.colorBgContainer,
1971
- defaultBorderColor: e.colorBorder,
1972
- defaultBorderColorDisabled: e.colorBorder,
1973
- defaultHoverBg: e.colorBgContainer,
1974
- defaultHoverColor: e.colorPrimaryHover,
1975
- defaultHoverBorderColor: e.colorPrimaryHover,
1976
- defaultActiveBg: e.colorBgContainer,
1977
- defaultActiveColor: e.colorPrimaryActive,
1978
- defaultActiveBorderColor: e.colorPrimaryActive,
1979
- solidTextColor: O,
1980
- contentFontSize: s,
1981
- contentFontSizeSM: c,
1982
- contentFontSizeLG: u,
1983
- contentLineHeight: l,
1984
- contentLineHeightSM: f,
1985
- contentLineHeightLG: g,
1986
- paddingBlock: Math.max((e.controlHeight - s * l) / 2 - e.lineWidth, 0),
1987
- paddingBlockSM: Math.max((e.controlHeightSM - c * f) / 2 - e.lineWidth, 0),
1988
- paddingBlockLG: Math.max((e.controlHeightLG - u * g) / 2 - e.lineWidth, 0)
1989
- };
1990
- }, Ii = (e) => {
1991
- const {
1992
- componentCls: t,
1993
- iconCls: r,
1994
- fontWeight: i
1995
- } = e;
1996
- return {
1997
- [t]: {
1998
- outline: "none",
1999
- position: "relative",
2000
- display: "inline-flex",
2001
- gap: e.marginXS,
2002
- alignItems: "center",
2003
- justifyContent: "center",
2004
- fontWeight: i,
2005
- whiteSpace: "nowrap",
2006
- textAlign: "center",
2007
- backgroundImage: "none",
2008
- background: "transparent",
2009
- border: `${je(e.lineWidth)} ${e.lineType} transparent`,
2010
- cursor: "pointer",
2011
- transition: `all ${e.motionDurationMid} ${e.motionEaseInOut}`,
2012
- userSelect: "none",
2013
- touchAction: "manipulation",
2014
- color: e.colorText,
2015
- "&:disabled > *": {
2016
- pointerEvents: "none"
2017
- },
2018
- "> span": {
2019
- display: "inline-block"
2020
- },
2021
- [`${t}-icon`]: {
2022
- lineHeight: 1
2023
- },
2024
- "> a": {
2025
- color: "currentColor"
2026
- },
2027
- "&:not(:disabled)": Object.assign({}, fn(e)),
2028
- [`&${t}-two-chinese-chars::first-letter`]: {
2029
- letterSpacing: "0.34em"
2030
- },
2031
- [`&${t}-two-chinese-chars > *:not(${r})`]: {
2032
- marginInlineEnd: "-0.34em",
2033
- letterSpacing: "0.34em"
2034
- },
2035
- // iconPosition="end"
2036
- "&-icon-end": {
2037
- flexDirection: "row-reverse"
2038
- }
2039
- }
2040
- };
2041
- }, qr = (e, t, r) => ({
2042
- [`&:not(:disabled):not(${e}-disabled)`]: {
2043
- "&:hover": t,
2044
- "&:active": r
2045
- }
2046
- }), Li = (e) => ({
2047
- minWidth: e.controlHeight,
2048
- paddingInlineStart: 0,
2049
- paddingInlineEnd: 0,
2050
- borderRadius: "50%"
2051
- }), Hi = (e) => ({
2052
- borderRadius: e.controlHeight,
2053
- paddingInlineStart: e.calc(e.controlHeight).div(2).equal(),
2054
- paddingInlineEnd: e.calc(e.controlHeight).div(2).equal()
2055
- }), Ti = (e) => ({
2056
- cursor: "not-allowed",
2057
- borderColor: e.borderColorDisabled,
2058
- color: e.colorTextDisabled,
2059
- background: e.colorBgContainerDisabled,
2060
- boxShadow: "none"
2061
- }), Tt = (e, t, r, i, n, a, o, s) => ({
2062
- [`&${e}-background-ghost`]: Object.assign(Object.assign({
2063
- color: r || void 0,
2064
- background: t,
2065
- borderColor: i || void 0,
2066
- boxShadow: "none"
2067
- }, qr(e, Object.assign({
2068
- background: t
2069
- }, o), Object.assign({
2070
- background: t
2071
- }, s))), {
2072
- "&:disabled": {
2073
- cursor: "not-allowed",
2074
- color: n || void 0,
2075
- borderColor: a || void 0
2076
- }
2077
- })
2078
- }), Ai = (e) => ({
2079
- [`&:disabled, &${e.componentCls}-disabled`]: Object.assign({}, Ti(e))
2080
- }), Mi = (e) => ({
2081
- [`&:disabled, &${e.componentCls}-disabled`]: {
2082
- cursor: "not-allowed",
2083
- color: e.colorTextDisabled
2084
- }
2085
- }), tt = (e, t, r, i) => {
2086
- const a = i && ["link", "text"].includes(i) ? Mi : Ai;
2087
- return Object.assign(Object.assign({}, a(e)), qr(e.componentCls, t, r));
2088
- }, At = (e, t, r, i, n) => ({
2089
- [`&${e.componentCls}-variant-solid`]: Object.assign({
2090
- color: t,
2091
- background: r
2092
- }, tt(e, i, n))
2093
- }), Mt = (e, t, r, i, n) => ({
2094
- [`&${e.componentCls}-variant-outlined, &${e.componentCls}-variant-dashed`]: Object.assign({
2095
- borderColor: t,
2096
- background: r
2097
- }, tt(e, i, n))
2098
- }), jt = (e) => ({
2099
- [`&${e.componentCls}-variant-dashed`]: {
2100
- borderStyle: "dashed"
2101
- }
2102
- }), Bt = (e, t, r, i) => ({
2103
- [`&${e.componentCls}-variant-filled`]: Object.assign({
2104
- boxShadow: "none",
2105
- background: t
2106
- }, tt(e, r, i))
2107
- }), Ne = (e, t, r, i, n) => ({
2108
- [`&${e.componentCls}-variant-${r}`]: Object.assign({
2109
- color: t,
2110
- boxShadow: "none"
2111
- }, tt(e, i, n, r))
2112
- }), ji = (e) => Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({
2113
- color: e.defaultColor,
2114
- boxShadow: e.defaultShadow
2115
- }, At(e, e.solidTextColor, e.colorBgSolid, {
2116
- background: e.colorBgSolidHover
2117
- }, {
2118
- background: e.colorBgSolidActive
2119
- })), jt(e)), Bt(e, e.colorFillTertiary, {
2120
- background: e.colorFillSecondary
2121
- }, {
2122
- background: e.colorFill
2123
- })), Ne(e, e.textTextColor, "link", {
2124
- color: e.colorLinkHover,
2125
- background: e.linkHoverBg
2126
- }, {
2127
- color: e.colorLinkActive
2128
- })), Tt(e.componentCls, e.ghostBg, e.defaultGhostColor, e.defaultGhostBorderColor, e.colorTextDisabled, e.colorBorder)), Bi = (e) => Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({
2129
- color: e.colorPrimary,
2130
- boxShadow: e.primaryShadow
2131
- }, Mt(e, e.colorPrimary, e.colorBgContainer, {
2132
- color: e.colorPrimaryTextHover,
2133
- borderColor: e.colorPrimaryHover,
2134
- background: e.colorBgContainer
2135
- }, {
2136
- color: e.colorPrimaryTextActive,
2137
- borderColor: e.colorPrimaryActive,
2138
- background: e.colorBgContainer
2139
- })), jt(e)), Bt(e, e.colorPrimaryBg, {
2140
- background: e.colorPrimaryBgHover
2141
- }, {
2142
- background: e.colorPrimaryBorder
2143
- })), Ne(e, e.colorLink, "text", {
2144
- color: e.colorPrimaryTextHover,
2145
- background: e.colorPrimaryBg
2146
- }, {
2147
- color: e.colorPrimaryTextActive,
2148
- background: e.colorPrimaryBorder
2149
- })), Tt(e.componentCls, e.ghostBg, e.colorPrimary, e.colorPrimary, e.colorTextDisabled, e.colorBorder, {
2150
- color: e.colorPrimaryHover,
2151
- borderColor: e.colorPrimaryHover
2152
- }, {
2153
- color: e.colorPrimaryActive,
2154
- borderColor: e.colorPrimaryActive
2155
- })), Di = (e) => Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({
2156
- color: e.colorError,
2157
- boxShadow: e.dangerShadow
2158
- }, At(e, e.dangerColor, e.colorError, {
2159
- background: e.colorErrorHover
2160
- }, {
2161
- background: e.colorErrorActive
2162
- })), Mt(e, e.colorError, e.colorBgContainer, {
2163
- color: e.colorErrorHover,
2164
- borderColor: e.colorErrorBorderHover
2165
- }, {
2166
- color: e.colorErrorActive,
2167
- borderColor: e.colorErrorActive
2168
- })), jt(e)), Bt(e, e.colorErrorBg, {
2169
- background: e.colorErrorBgFilledHover
2170
- }, {
2171
- background: e.colorErrorBgActive
2172
- })), Ne(e, e.colorError, "text", {
2173
- color: e.colorErrorHover,
2174
- background: e.colorErrorBg
2175
- }, {
2176
- color: e.colorErrorHover,
2177
- background: e.colorErrorBgActive
2178
- })), Ne(e, e.colorError, "link", {
2179
- color: e.colorErrorHover
2180
- }, {
2181
- color: e.colorErrorActive
2182
- })), Tt(e.componentCls, e.ghostBg, e.colorError, e.colorError, e.colorTextDisabled, e.colorBorder, {
2183
- color: e.colorErrorHover,
2184
- borderColor: e.colorErrorHover
2185
- }, {
2186
- color: e.colorErrorActive,
2187
- borderColor: e.colorErrorActive
2188
- })), zi = (e) => {
2189
- const {
2190
- componentCls: t
2191
- } = e;
2192
- return {
2193
- [`${t}-color-default`]: ji(e),
2194
- [`${t}-color-primary`]: Bi(e),
2195
- [`${t}-color-dangerous`]: Di(e)
2196
- };
2197
- }, Wi = (e) => Object.assign(Object.assign(Object.assign(Object.assign({}, Mt(e, e.defaultBorderColor, e.defaultBg, {
2198
- color: e.defaultHoverColor,
2199
- borderColor: e.defaultHoverBorderColor,
2200
- background: e.defaultHoverBg
2201
- }, {
2202
- color: e.defaultActiveColor,
2203
- borderColor: e.defaultActiveBorderColor,
2204
- background: e.defaultActiveBg
2205
- })), Ne(e, e.textTextColor, "text", {
2206
- color: e.textTextHoverColor,
2207
- background: e.textHoverBg
2208
- }, {
2209
- color: e.textTextActiveColor,
2210
- background: e.colorBgTextActive
2211
- })), At(e, e.primaryColor, e.colorPrimary, {
2212
- background: e.colorPrimaryHover,
2213
- color: e.primaryColor
2214
- }, {
2215
- background: e.colorPrimaryActive,
2216
- color: e.primaryColor
2217
- })), Ne(e, e.colorLink, "link", {
2218
- color: e.colorLinkHover,
2219
- background: e.linkHoverBg
2220
- }, {
2221
- color: e.colorLinkActive
2222
- })), Dt = function(e) {
2223
- let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "";
2224
- const {
2225
- componentCls: r,
2226
- controlHeight: i,
2227
- fontSize: n,
2228
- lineHeight: a,
2229
- borderRadius: o,
2230
- buttonPaddingHorizontal: s,
2231
- iconCls: c,
2232
- buttonPaddingVertical: u
2233
- } = e, l = `${r}-icon-only`;
2234
- return [
2235
- {
2236
- [t]: {
2237
- fontSize: n,
2238
- lineHeight: a,
2239
- height: i,
2240
- padding: `${je(u)} ${je(s)}`,
2241
- borderRadius: o,
2242
- [`&${l}`]: {
2243
- width: i,
2244
- paddingInline: 0,
2245
- // make `btn-icon-only` not too narrow
2246
- [`&${r}-compact-item`]: {
2247
- flex: "none"
2248
- },
2249
- [`&${r}-round`]: {
2250
- width: "auto"
2251
- },
2252
- [c]: {
2253
- fontSize: e.buttonIconOnlyFontSize
2254
- }
2255
- },
2256
- // Loading
2257
- [`&${r}-loading`]: {
2258
- opacity: e.opacityLoading,
2259
- cursor: "default"
2260
- },
2261
- [`${r}-loading-icon`]: {
2262
- transition: `width ${e.motionDurationSlow} ${e.motionEaseInOut}, opacity ${e.motionDurationSlow} ${e.motionEaseInOut}`
2263
- }
2264
- }
2265
- },
2266
- // Shape - patch prefixCls again to override solid border radius style
2267
- {
2268
- [`${r}${r}-circle${t}`]: Li(e)
2269
- },
2270
- {
2271
- [`${r}${r}-round${t}`]: Hi(e)
2272
- }
2273
- ];
2274
- }, qi = (e) => {
2275
- const t = Be(e, {
2276
- fontSize: e.contentFontSize,
2277
- lineHeight: e.contentLineHeight
2278
- });
2279
- return Dt(t, e.componentCls);
2280
- }, Gi = (e) => {
2281
- const t = Be(e, {
2282
- controlHeight: e.controlHeightSM,
2283
- fontSize: e.contentFontSizeSM,
2284
- lineHeight: e.contentLineHeightSM,
2285
- padding: e.paddingXS,
2286
- buttonPaddingHorizontal: e.paddingInlineSM,
2287
- buttonPaddingVertical: e.paddingBlockSM,
2288
- borderRadius: e.borderRadiusSM,
2289
- buttonIconOnlyFontSize: e.onlyIconSizeSM
2290
- });
2291
- return Dt(t, `${e.componentCls}-sm`);
2292
- }, Ui = (e) => {
2293
- const t = Be(e, {
2294
- controlHeight: e.controlHeightLG,
2295
- fontSize: e.contentFontSizeLG,
2296
- lineHeight: e.contentLineHeightLG,
2297
- buttonPaddingHorizontal: e.paddingInlineLG,
2298
- buttonPaddingVertical: e.paddingBlockLG,
2299
- borderRadius: e.borderRadiusLG,
2300
- buttonIconOnlyFontSize: e.onlyIconSizeLG
2301
- });
2302
- return Dt(t, `${e.componentCls}-lg`);
2303
- }, Ki = (e) => {
2304
- const {
2305
- componentCls: t
2306
- } = e;
2307
- return {
2308
- [t]: {
2309
- [`&${t}-block`]: {
2310
- width: "100%"
2311
- }
2312
- }
2313
- };
2314
- }, Yi = Er("Button", (e) => {
2315
- const t = zr(e);
2316
- return [
2317
- // Shared
2318
- Ii(t),
2319
- // Size
2320
- qi(t),
2321
- Gi(t),
2322
- Ui(t),
2323
- // Block
2324
- Ki(t),
2325
- // Color
2326
- zi(t),
2327
- // https://github.com/ant-design/ant-design/issues/50969
2328
- Wi(t),
2329
- // Button Group
2330
- ni(t)
2331
- ];
2332
- }, Wr, {
2333
- unitless: {
2334
- fontWeight: !0,
2335
- contentLineHeight: !0,
2336
- contentLineHeightSM: !0,
2337
- contentLineHeightLG: !0
2338
- }
2339
- });
2340
- function Zi(e, t, r) {
2341
- const {
2342
- focusElCls: i,
2343
- focus: n,
2344
- borderElCls: a
2345
- } = r, o = a ? "> *" : "", s = ["hover", n ? "focus" : null, "active"].filter(Boolean).map((c) => `&:${c} ${o}`).join(",");
2346
- return {
2347
- [`&-item:not(${t}-last-item)`]: {
2348
- marginInlineEnd: e.calc(e.lineWidth).mul(-1).equal()
2349
- },
2350
- "&-item": Object.assign(Object.assign({
2351
- [s]: {
2352
- zIndex: 2
2353
- }
2354
- }, i ? {
2355
- [`&${i}`]: {
2356
- zIndex: 2
2357
- }
2358
- } : {}), {
2359
- [`&[disabled] ${o}`]: {
2360
- zIndex: 0
2361
- }
2362
- })
2363
- };
2364
- }
2365
- function Xi(e, t, r) {
2366
- const {
2367
- borderElCls: i
2368
- } = r, n = i ? `> ${i}` : "";
2369
- return {
2370
- [`&-item:not(${t}-first-item):not(${t}-last-item) ${n}`]: {
2371
- borderRadius: 0
2372
- },
2373
- [`&-item:not(${t}-last-item)${t}-first-item`]: {
2374
- [`& ${n}, &${e}-sm ${n}, &${e}-lg ${n}`]: {
2375
- borderStartEndRadius: 0,
2376
- borderEndEndRadius: 0
2377
- }
2378
- },
2379
- [`&-item:not(${t}-first-item)${t}-last-item`]: {
2380
- [`& ${n}, &${e}-sm ${n}, &${e}-lg ${n}`]: {
2381
- borderStartStartRadius: 0,
2382
- borderEndStartRadius: 0
2383
- }
2384
- }
2385
- };
2386
- }
2387
- function ki(e) {
2388
- let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {
2389
- focus: !0
2390
- };
2391
- const {
2392
- componentCls: r
2393
- } = e, i = `${r}-compact`;
2394
- return {
2395
- [i]: Object.assign(Object.assign({}, Zi(e, i, t)), Xi(r, i, t))
2396
- };
2397
- }
2398
- function Ji(e, t) {
2399
- return {
2400
- // border collapse
2401
- [`&-item:not(${t}-last-item)`]: {
2402
- marginBottom: e.calc(e.lineWidth).mul(-1).equal()
2403
- },
2404
- "&-item": {
2405
- "&:hover,&:focus,&:active": {
2406
- zIndex: 2
2407
- },
2408
- "&[disabled]": {
2409
- zIndex: 0
2410
- }
2411
- }
2412
- };
2413
- }
2414
- function Qi(e, t) {
2415
- return {
2416
- [`&-item:not(${t}-first-item):not(${t}-last-item)`]: {
2417
- borderRadius: 0
2418
- },
2419
- [`&-item${t}-first-item:not(${t}-last-item)`]: {
2420
- [`&, &${e}-sm, &${e}-lg`]: {
2421
- borderEndEndRadius: 0,
2422
- borderEndStartRadius: 0
2423
- }
2424
- },
2425
- [`&-item${t}-last-item:not(${t}-first-item)`]: {
2426
- [`&, &${e}-sm, &${e}-lg`]: {
2427
- borderStartStartRadius: 0,
2428
- borderStartEndRadius: 0
2429
- }
2430
- }
2431
- };
2432
- }
2433
- function ea(e) {
2434
- const t = `${e.componentCls}-compact-vertical`;
2435
- return {
2436
- [t]: Object.assign(Object.assign({}, Ji(e, t)), Qi(e.componentCls, t))
2437
- };
2438
- }
2439
- const ta = (e) => {
2440
- const {
2441
- componentCls: t,
2442
- calc: r
2443
- } = e;
2444
- return {
2445
- [t]: {
2446
- // Special styles for Primary Button
2447
- [`&-compact-item${t}-primary`]: {
2448
- [`&:not([disabled]) + ${t}-compact-item${t}-primary:not([disabled])`]: {
2449
- position: "relative",
2450
- "&:before": {
2451
- position: "absolute",
2452
- top: r(e.lineWidth).mul(-1).equal(),
2453
- insetInlineStart: r(e.lineWidth).mul(-1).equal(),
2454
- display: "inline-block",
2455
- width: e.lineWidth,
2456
- height: `calc(100% + ${je(e.lineWidth)} * 2)`,
2457
- backgroundColor: e.colorPrimaryHover,
2458
- content: '""'
2459
- }
2460
- }
2461
- },
2462
- // Special styles for Primary Button
2463
- "&-compact-vertical-item": {
2464
- [`&${t}-primary`]: {
2465
- [`&:not([disabled]) + ${t}-compact-vertical-item${t}-primary:not([disabled])`]: {
2466
- position: "relative",
2467
- "&:before": {
2468
- position: "absolute",
2469
- top: r(e.lineWidth).mul(-1).equal(),
2470
- insetInlineStart: r(e.lineWidth).mul(-1).equal(),
2471
- display: "inline-block",
2472
- width: `calc(100% + ${je(e.lineWidth)} * 2)`,
2473
- height: e.lineWidth,
2474
- backgroundColor: e.colorPrimaryHover,
2475
- content: '""'
2476
- }
2477
- }
2478
- }
2479
- }
2480
- }
2481
- };
2482
- }, ra = gn(["Button", "compact"], (e) => {
2483
- const t = zr(e);
2484
- return [
2485
- // Space Compact
2486
- ki(t),
2487
- ea(t),
2488
- ta(t)
2489
- ];
2490
- }, Wr);
2491
- var na = function(e, t) {
2492
- var r = {};
2493
- for (var i in e) Object.prototype.hasOwnProperty.call(e, i) && t.indexOf(i) < 0 && (r[i] = e[i]);
2494
- if (e != null && typeof Object.getOwnPropertySymbols == "function") for (var n = 0, i = Object.getOwnPropertySymbols(e); n < i.length; n++)
2495
- t.indexOf(i[n]) < 0 && Object.prototype.propertyIsEnumerable.call(e, i[n]) && (r[i[n]] = e[i[n]]);
2496
- return r;
2497
- };
2498
- function ia(e) {
2499
- if (typeof e == "object" && e) {
2500
- let t = e == null ? void 0 : e.delay;
2501
- return t = !Number.isNaN(t) && typeof t == "number" ? t : 0, {
2502
- loading: t <= 0,
2503
- delay: t
2504
- };
2505
- }
2506
- return {
2507
- loading: !!e,
2508
- delay: 0
2509
- };
2510
- }
2511
- const aa = {
2512
- default: ["default", "outlined"],
2513
- primary: ["primary", "solid"],
2514
- dashed: ["default", "dashed"],
2515
- link: ["primary", "link"],
2516
- text: ["default", "text"]
2517
- }, oa = /* @__PURE__ */ L.forwardRef((e, t) => {
2518
- var r, i, n, a;
2519
- const {
2520
- loading: o = !1,
2521
- prefixCls: s,
2522
- color: c,
2523
- variant: u,
2524
- type: l,
2525
- danger: f = !1,
2526
- shape: g = "default",
2527
- size: O,
2528
- styles: v,
2529
- disabled: p,
2530
- className: d,
2531
- rootClassName: C,
2532
- children: h,
2533
- icon: b,
2534
- iconPosition: S = "start",
2535
- ghost: w = !1,
2536
- block: V = !1,
2537
- // React does not recognize the `htmlType` prop on a DOM element. Here we pick it out of `rest`.
2538
- htmlType: R = "button",
2539
- classNames: _,
2540
- style: P = {},
2541
- autoInsertSpace: I
2542
- } = e, M = na(e, ["loading", "prefixCls", "color", "variant", "type", "danger", "shape", "size", "styles", "disabled", "className", "rootClassName", "children", "icon", "iconPosition", "ghost", "block", "htmlType", "classNames", "style", "autoInsertSpace"]), z = l || "default", [j, A] = be(() => {
2543
- if (c && u)
2544
- return [c, u];
2545
- const J = aa[z] || [];
2546
- return f ? ["danger", J[1]] : J;
2547
- }, [l, c, u, f]), F = j === "danger" ? "dangerous" : j, {
2548
- getPrefixCls: y,
2549
- direction: E,
2550
- button: x
2551
- } = Oe(_e), H = (r = I ?? (x == null ? void 0 : x.autoInsertSpace)) !== null && r !== void 0 ? r : !0, N = y("btn", s), [U, Y, q] = Yi(N), te = Oe(hn), k = p ?? te, ae = Oe(Lr), Ie = be(() => ia(o), [o]), [me, qt] = Ke(Ie.loading), [rt, Gt] = Ke(!1), we = _t(t, /* @__PURE__ */ nn()), Ut = an.count(h) === 1 && !b && !Ge(A);
2552
- Me(() => {
2553
- let J = null;
2554
- Ie.delay > 0 ? J = setTimeout(() => {
2555
- J = null, qt(!0);
2556
- }, Ie.delay) : qt(Ie.loading);
2557
- function fe() {
2558
- J && (clearTimeout(J), J = null);
2559
- }
2560
- return fe;
2561
- }, [Ie]), Me(() => {
2562
- if (!we || !we.current || !H)
2563
- return;
2564
- const J = we.current.textContent;
2565
- Ut && yt(J) ? rt || Gt(!0) : rt && Gt(!1);
2566
- }, [we]);
2567
- const Kt = L.useCallback((J) => {
2568
- var fe;
2569
- if (me || k) {
2570
- J.preventDefault();
2571
- return;
2572
- }
2573
- (fe = e.onClick) === null || fe === void 0 || fe.call(e, J);
2574
- }, [e.onClick, me, k]);
2575
- if (process.env.NODE_ENV !== "production") {
2576
- const J = Vt("Button");
2577
- process.env.NODE_ENV !== "production" && J(!(typeof b == "string" && b.length > 2), "breaking", `\`icon\` is using ReactNode instead of string naming in v4. Please check \`${b}\` at https://ant.design/components/icon`), process.env.NODE_ENV !== "production" && J(!(w && Ge(A)), "usage", "`link` or `text` button can't be a `ghost` button.");
2578
- }
2579
- const {
2580
- compactSize: Jr,
2581
- compactItemClassnames: Yt
2582
- } = Zn(N, E), Qr = {
2583
- large: "lg",
2584
- small: "sm",
2585
- middle: void 0
2586
- }, Zt = wr((J) => {
2587
- var fe, at;
2588
- return (at = (fe = O ?? Jr) !== null && fe !== void 0 ? fe : ae) !== null && at !== void 0 ? at : J;
2589
- }), Xt = Zt && (i = Qr[Zt]) !== null && i !== void 0 ? i : "", en = me ? "loading" : b, nt = mn(M, ["navigate"]), kt = ne(N, Y, q, {
2590
- [`${N}-${g}`]: g !== "default" && g,
2591
- // line(253 - 254): Compatible with versions earlier than 5.21.0
2592
- [`${N}-${z}`]: z,
2593
- [`${N}-dangerous`]: f,
2594
- [`${N}-color-${F}`]: F,
2595
- [`${N}-variant-${A}`]: A,
2596
- [`${N}-${Xt}`]: Xt,
2597
- [`${N}-icon-only`]: !h && h !== 0 && !!en,
2598
- [`${N}-background-ghost`]: w && !Ge(A),
2599
- [`${N}-loading`]: me,
2600
- [`${N}-two-chinese-chars`]: rt && H && !me,
2601
- [`${N}-block`]: V,
2602
- [`${N}-rtl`]: E === "rtl",
2603
- [`${N}-icon-end`]: S === "end"
2604
- }, Yt, d, C, x == null ? void 0 : x.className), Jt = Object.assign(Object.assign({}, x == null ? void 0 : x.style), P), tn = ne(_ == null ? void 0 : _.icon, (n = x == null ? void 0 : x.classNames) === null || n === void 0 ? void 0 : n.icon), rn = Object.assign(Object.assign({}, (v == null ? void 0 : v.icon) || {}), ((a = x == null ? void 0 : x.styles) === null || a === void 0 ? void 0 : a.icon) || {}), Qt = b && !me ? /* @__PURE__ */ L.createElement(Hr, {
2605
- prefixCls: N,
2606
- className: tn,
2607
- style: rn
2608
- }, b) : /* @__PURE__ */ L.createElement(ri, {
2609
- existIcon: !!b,
2610
- prefixCls: N,
2611
- loading: me
2612
- }), er = h || h === 0 ? ti(h, Ut && H) : null;
2613
- if (nt.href !== void 0)
2614
- return U(/* @__PURE__ */ L.createElement("a", Object.assign({}, nt, {
2615
- className: ne(kt, {
2616
- [`${N}-disabled`]: k
2617
- }),
2618
- href: k ? void 0 : nt.href,
2619
- style: Jt,
2620
- onClick: Kt,
2621
- ref: we,
2622
- tabIndex: k ? -1 : 0
2623
- }), Qt, er));
2624
- let it = /* @__PURE__ */ L.createElement("button", Object.assign({}, M, {
2625
- type: R,
2626
- className: kt,
2627
- style: Jt,
2628
- onClick: Kt,
2629
- disabled: k,
2630
- ref: we
2631
- }), Qt, er, !!Yt && /* @__PURE__ */ L.createElement(ra, {
2632
- key: "compact",
2633
- prefixCls: N
2634
- }));
2635
- return Ge(A) || (it = /* @__PURE__ */ L.createElement(_r, {
2636
- component: "Button",
2637
- disabled: me
2638
- }, it)), U(it);
2639
- }), zt = oa;
2640
- zt.Group = Qn;
2641
- zt.__ANT_BUTTON = !0;
2642
- process.env.NODE_ENV !== "production" && (zt.displayName = "Button");
2643
- var ye = "RC_FORM_INTERNAL_HOOKS", G = function() {
2644
- re(!1, "Can not find FormContext. Please make sure you wrap Field under Form.");
2645
- }, Ve = /* @__PURE__ */ $.createContext({
2646
- getFieldValue: G,
2647
- getFieldsValue: G,
2648
- getFieldError: G,
2649
- getFieldWarning: G,
2650
- getFieldsError: G,
2651
- isFieldsTouched: G,
2652
- isFieldTouched: G,
2653
- isFieldValidating: G,
2654
- isFieldsValidating: G,
2655
- resetFields: G,
2656
- setFields: G,
2657
- setFieldValue: G,
2658
- setFieldsValue: G,
2659
- validateFields: G,
2660
- submit: G,
2661
- getInternalHooks: function() {
2662
- return G(), {
2663
- dispatch: G,
2664
- initEntityValue: G,
2665
- registerField: G,
2666
- useSubscribe: G,
2667
- setInitialValues: G,
2668
- destroyForm: G,
2669
- setCallbacks: G,
2670
- registerWatch: G,
2671
- getFields: G,
2672
- setValidateMessages: G,
2673
- setPreserve: G,
2674
- getInitialValue: G
2675
- };
2676
- }
2677
- }), Xe = /* @__PURE__ */ $.createContext(null);
2678
- function bt(e) {
2679
- return e == null ? [] : Array.isArray(e) ? e : [e];
2680
- }
2681
- function sa(e) {
2682
- return e && !!e._init;
2683
- }
2684
- function Ct() {
2685
- return {
2686
- default: "Validation error on field %s",
2687
- required: "%s is required",
2688
- enum: "%s must be one of %s",
2689
- whitespace: "%s cannot be empty",
2690
- date: {
2691
- format: "%s date %s is invalid for format %s",
2692
- parse: "%s date could not be parsed, %s is invalid ",
2693
- invalid: "%s date %s is invalid"
2694
- },
2695
- types: {
2696
- string: "%s is not a %s",
2697
- method: "%s is not a %s (function)",
2698
- array: "%s is not an %s",
2699
- object: "%s is not an %s",
2700
- number: "%s is not a %s",
2701
- date: "%s is not a %s",
2702
- boolean: "%s is not a %s",
2703
- integer: "%s is not an %s",
2704
- float: "%s is not a %s",
2705
- regexp: "%s is not a valid %s",
2706
- email: "%s is not a valid %s",
2707
- url: "%s is not a valid %s",
2708
- hex: "%s is not a valid %s"
2709
- },
2710
- string: {
2711
- len: "%s must be exactly %s characters",
2712
- min: "%s must be at least %s characters",
2713
- max: "%s cannot be longer than %s characters",
2714
- range: "%s must be between %s and %s characters"
2715
- },
2716
- number: {
2717
- len: "%s must equal %s",
2718
- min: "%s cannot be less than %s",
2719
- max: "%s cannot be greater than %s",
2720
- range: "%s must be between %s and %s"
2721
- },
2722
- array: {
2723
- len: "%s must be exactly %s in length",
2724
- min: "%s cannot be less than %s in length",
2725
- max: "%s cannot be greater than %s in length",
2726
- range: "%s must be between %s and %s in length"
2727
- },
2728
- pattern: {
2729
- mismatch: "%s value %s does not match pattern %s"
2730
- },
2731
- clone: function() {
2732
- var t = JSON.parse(JSON.stringify(this));
2733
- return t.clone = this.clone, t;
2734
- }
2735
- };
2736
- }
2737
- var Ft = Ct();
2738
- function la(e) {
2739
- try {
2740
- return Function.toString.call(e).indexOf("[native code]") !== -1;
2741
- } catch {
2742
- return typeof e == "function";
2743
- }
2744
- }
2745
- function ca(e, t, r) {
2746
- if (vn()) return Reflect.construct.apply(null, arguments);
2747
- var i = [null];
2748
- i.push.apply(i, t);
2749
- var n = new (e.bind.apply(e, i))();
2750
- return r && Or(n, r.prototype), n;
2751
- }
2752
- function Et(e) {
2753
- var t = typeof Map == "function" ? /* @__PURE__ */ new Map() : void 0;
2754
- return Et = function(i) {
2755
- if (i === null || !la(i)) return i;
2756
- if (typeof i != "function") throw new TypeError("Super expression must either be null or a function");
2757
- if (t !== void 0) {
2758
- if (t.has(i)) return t.get(i);
2759
- t.set(i, n);
2760
- }
2761
- function n() {
2762
- return ca(i, arguments, pn(this).constructor);
2763
- }
2764
- return n.prototype = Object.create(i.prototype, {
2765
- constructor: {
2766
- value: n,
2767
- enumerable: !1,
2768
- writable: !0,
2769
- configurable: !0
2770
- }
2771
- }), Or(n, i);
2772
- }, Et(e);
2773
- }
2774
- var ua = /%[sdj%]/g, Gr = function() {
2775
- };
2776
- typeof process < "u" && process.env && process.env.NODE_ENV !== "production" && typeof window < "u" && typeof document < "u" && (Gr = function(t, r) {
2777
- typeof console < "u" && console.warn && typeof ASYNC_VALIDATOR_NO_WARNING > "u" && r.every(function(i) {
2778
- return typeof i == "string";
2779
- }) && console.warn(t, r);
2780
- });
2781
- function wt(e) {
2782
- if (!e || !e.length) return null;
2783
- var t = {};
2784
- return e.forEach(function(r) {
2785
- var i = r.field;
2786
- t[i] = t[i] || [], t[i].push(r);
2787
- }), t;
2788
- }
2789
- function se(e) {
2790
- for (var t = arguments.length, r = new Array(t > 1 ? t - 1 : 0), i = 1; i < t; i++)
2791
- r[i - 1] = arguments[i];
2792
- var n = 0, a = r.length;
2793
- if (typeof e == "function")
2794
- return e.apply(null, r);
2795
- if (typeof e == "string") {
2796
- var o = e.replace(ua, function(s) {
2797
- if (s === "%%")
2798
- return "%";
2799
- if (n >= a)
2800
- return s;
2801
- switch (s) {
2802
- case "%s":
2803
- return String(r[n++]);
2804
- case "%d":
2805
- return Number(r[n++]);
2806
- case "%j":
2807
- try {
2808
- return JSON.stringify(r[n++]);
2809
- } catch {
2810
- return "[Circular]";
2811
- }
2812
- break;
2813
- default:
2814
- return s;
2815
- }
2816
- });
2817
- return o;
2818
- }
2819
- return e;
2820
- }
2821
- function da(e) {
2822
- return e === "string" || e === "url" || e === "hex" || e === "email" || e === "date" || e === "pattern";
2823
- }
2824
- function X(e, t) {
2825
- return !!(e == null || t === "array" && Array.isArray(e) && !e.length || da(t) && typeof e == "string" && !e);
2826
- }
2827
- function fa(e, t, r) {
2828
- var i = [], n = 0, a = e.length;
2829
- function o(s) {
2830
- i.push.apply(i, B(s || [])), n++, n === a && r(i);
2831
- }
2832
- e.forEach(function(s) {
2833
- t(s, o);
2834
- });
2835
- }
2836
- function dr(e, t, r) {
2837
- var i = 0, n = e.length;
2838
- function a(o) {
2839
- if (o && o.length) {
2840
- r(o);
2841
- return;
2842
- }
2843
- var s = i;
2844
- i = i + 1, s < n ? t(e[s], a) : r([]);
2845
- }
2846
- a([]);
2847
- }
2848
- function ga(e) {
2849
- var t = [];
2850
- return Object.keys(e).forEach(function(r) {
2851
- t.push.apply(t, B(e[r] || []));
2852
- }), t;
2853
- }
2854
- var fr = /* @__PURE__ */ function(e) {
2855
- Lt(r, e);
2856
- var t = Ht(r);
2857
- function r(i, n) {
2858
- var a;
2859
- return Ce(this, r), a = t.call(this, "Async Validation Error"), m(W(a), "errors", void 0), m(W(a), "fields", void 0), a.errors = i, a.fields = n, a;
2860
- }
2861
- return Fe(r);
2862
- }(/* @__PURE__ */ Et(Error));
2863
- function ha(e, t, r, i, n) {
2864
- if (t.first) {
2865
- var a = new Promise(function(g, O) {
2866
- var v = function(C) {
2867
- return i(C), C.length ? O(new fr(C, wt(C))) : g(n);
2868
- }, p = ga(e);
2869
- dr(p, r, v);
2870
- });
2871
- return a.catch(function(g) {
2872
- return g;
2873
- }), a;
2874
- }
2875
- var o = t.firstFields === !0 ? Object.keys(e) : t.firstFields || [], s = Object.keys(e), c = s.length, u = 0, l = [], f = new Promise(function(g, O) {
2876
- var v = function(d) {
2877
- if (l.push.apply(l, d), u++, u === c)
2878
- return i(l), l.length ? O(new fr(l, wt(l))) : g(n);
2879
- };
2880
- s.length || (i(l), g(n)), s.forEach(function(p) {
2881
- var d = e[p];
2882
- o.indexOf(p) !== -1 ? dr(d, r, v) : fa(d, r, v);
2883
- });
2884
- });
2885
- return f.catch(function(g) {
2886
- return g;
2887
- }), f;
2888
- }
2889
- function ma(e) {
2890
- return !!(e && e.message !== void 0);
2891
- }
2892
- function va(e, t) {
2893
- for (var r = e, i = 0; i < t.length; i++) {
2894
- if (r == null)
2895
- return r;
2896
- r = r[t[i]];
2897
- }
2898
- return r;
2899
- }
2900
- function gr(e, t) {
2901
- return function(r) {
2902
- var i;
2903
- return e.fullFields ? i = va(t, e.fullFields) : i = t[r.field || e.fullField], ma(r) ? (r.field = r.field || e.fullField, r.fieldValue = i, r) : {
2904
- message: typeof r == "function" ? r() : r,
2905
- fieldValue: i,
2906
- field: r.field || e.fullField
2907
- };
2908
- };
2909
- }
2910
- function hr(e, t) {
2911
- if (t) {
2912
- for (var r in t)
2913
- if (t.hasOwnProperty(r)) {
2914
- var i = t[r];
2915
- ee(i) === "object" && ee(e[r]) === "object" ? e[r] = T(T({}, e[r]), i) : e[r] = i;
2916
- }
2917
- }
2918
- return e;
2919
- }
2920
- var Se = "enum", pa = function(t, r, i, n, a) {
2921
- t[Se] = Array.isArray(t[Se]) ? t[Se] : [], t[Se].indexOf(r) === -1 && n.push(se(a.messages[Se], t.fullField, t[Se].join(", ")));
2922
- }, ya = function(t, r, i, n, a) {
2923
- if (t.pattern) {
2924
- if (t.pattern instanceof RegExp)
2925
- t.pattern.lastIndex = 0, t.pattern.test(r) || n.push(se(a.messages.pattern.mismatch, t.fullField, r, t.pattern));
2926
- else if (typeof t.pattern == "string") {
2927
- var o = new RegExp(t.pattern);
2928
- o.test(r) || n.push(se(a.messages.pattern.mismatch, t.fullField, r, t.pattern));
2929
- }
2930
- }
2931
- }, ba = function(t, r, i, n, a) {
2932
- var o = typeof t.len == "number", s = typeof t.min == "number", c = typeof t.max == "number", u = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g, l = r, f = null, g = typeof r == "number", O = typeof r == "string", v = Array.isArray(r);
2933
- if (g ? f = "number" : O ? f = "string" : v && (f = "array"), !f)
2934
- return !1;
2935
- v && (l = r.length), O && (l = r.replace(u, "_").length), o ? l !== t.len && n.push(se(a.messages[f].len, t.fullField, t.len)) : s && !c && l < t.min ? n.push(se(a.messages[f].min, t.fullField, t.min)) : c && !s && l > t.max ? n.push(se(a.messages[f].max, t.fullField, t.max)) : s && c && (l < t.min || l > t.max) && n.push(se(a.messages[f].range, t.fullField, t.min, t.max));
2936
- }, Ur = function(t, r, i, n, a, o) {
2937
- t.required && (!i.hasOwnProperty(t.field) || X(r, o || t.type)) && n.push(se(a.messages.required, t.fullField));
2938
- }, Ue;
2939
- const Ca = function() {
2940
- if (Ue)
2941
- return Ue;
2942
- var e = "[a-fA-F\\d:]", t = function(V) {
2943
- return V && V.includeBoundaries ? "(?:(?<=\\s|^)(?=".concat(e, ")|(?<=").concat(e, ")(?=\\s|$))") : "";
2944
- }, r = "(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}", i = "[a-fA-F\\d]{1,4}", n = [
2945
- "(?:".concat(i, ":){7}(?:").concat(i, "|:)"),
2946
- // 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:8
2947
- "(?:".concat(i, ":){6}(?:").concat(r, "|:").concat(i, "|:)"),
2948
- // 1:2:3:4:5:6:: 1:2:3:4:5:6::8 1:2:3:4:5:6::8 1:2:3:4:5:6::
2949
- "(?:".concat(i, ":){5}(?::").concat(r, "|(?::").concat(i, "){1,2}|:)"),
2950
- // 1:2:3:4:5:: 1:2:3:4:5::7:8 1:2:3:4:5::8 1:2:3:4:5::
2951
- "(?:".concat(i, ":){4}(?:(?::").concat(i, "){0,1}:").concat(r, "|(?::").concat(i, "){1,3}|:)"),
2952
- // 1:2:3:4:: 1:2:3:4::6:7:8 1:2:3:4::8 1:2:3:4::
2953
- "(?:".concat(i, ":){3}(?:(?::").concat(i, "){0,2}:").concat(r, "|(?::").concat(i, "){1,4}|:)"),
2954
- // 1:2:3:: 1:2:3::5:6:7:8 1:2:3::8 1:2:3::
2955
- "(?:".concat(i, ":){2}(?:(?::").concat(i, "){0,3}:").concat(r, "|(?::").concat(i, "){1,5}|:)"),
2956
- // 1:2:: 1:2::4:5:6:7:8 1:2::8 1:2::
2957
- "(?:".concat(i, ":){1}(?:(?::").concat(i, "){0,4}:").concat(r, "|(?::").concat(i, "){1,6}|:)"),
2958
- // 1:: 1::3:4:5:6:7:8 1::8 1::
2959
- "(?::(?:(?::".concat(i, "){0,5}:").concat(r, "|(?::").concat(i, "){1,7}|:))")
2960
- // ::2:3:4:5:6:7:8 ::2:3:4:5:6:7:8 ::8 ::
2961
- ], a = "(?:%[0-9a-zA-Z]{1,})?", o = "(?:".concat(n.join("|"), ")").concat(a), s = new RegExp("(?:^".concat(r, "$)|(?:^").concat(o, "$)")), c = new RegExp("^".concat(r, "$")), u = new RegExp("^".concat(o, "$")), l = function(V) {
2962
- return V && V.exact ? s : new RegExp("(?:".concat(t(V)).concat(r).concat(t(V), ")|(?:").concat(t(V)).concat(o).concat(t(V), ")"), "g");
2963
- };
2964
- l.v4 = function(w) {
2965
- return w && w.exact ? c : new RegExp("".concat(t(w)).concat(r).concat(t(w)), "g");
2966
- }, l.v6 = function(w) {
2967
- return w && w.exact ? u : new RegExp("".concat(t(w)).concat(o).concat(t(w)), "g");
2968
- };
2969
- var f = "(?:(?:[a-z]+:)?//)", g = "(?:\\S+(?::\\S*)?@)?", O = l.v4().source, v = l.v6().source, p = "(?:(?:[a-z\\u00a1-\\uffff0-9][-_]*)*[a-z\\u00a1-\\uffff0-9]+)", d = "(?:\\.(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)*", C = "(?:\\.(?:[a-z\\u00a1-\\uffff]{2,}))", h = "(?::\\d{2,5})?", b = '(?:[/?#][^\\s"]*)?', S = "(?:".concat(f, "|www\\.)").concat(g, "(?:localhost|").concat(O, "|").concat(v, "|").concat(p).concat(d).concat(C, ")").concat(h).concat(b);
2970
- return Ue = new RegExp("(?:^".concat(S, "$)"), "i"), Ue;
2971
- };
2972
- var mr = {
2973
- // http://emailregex.com/
2974
- email: /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+\.)+[a-zA-Z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{2,}))$/,
2975
- // url: new RegExp(
2976
- // '^(?!mailto:)(?:(?:http|https|ftp)://|//)(?:\\S+(?::\\S*)?@)?(?:(?:(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[0-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(?:(?:[a-z\\u00a1-\\uffff0-9]+-*)*[a-z\\u00a1-\\uffff0-9]+)(?:\\.(?:[a-z\\u00a1-\\uffff0-9]+-*)*[a-z\\u00a1-\\uffff0-9]+)*(?:\\.(?:[a-z\\u00a1-\\uffff]{2,})))|localhost)(?::\\d{2,5})?(?:(/|\\?|#)[^\\s]*)?$',
2977
- // 'i',
2978
- // ),
2979
- hex: /^#?([a-f0-9]{6}|[a-f0-9]{3})$/i
2980
- }, Te = {
2981
- integer: function(t) {
2982
- return Te.number(t) && parseInt(t, 10) === t;
2983
- },
2984
- float: function(t) {
2985
- return Te.number(t) && !Te.integer(t);
2986
- },
2987
- array: function(t) {
2988
- return Array.isArray(t);
2989
- },
2990
- regexp: function(t) {
2991
- if (t instanceof RegExp)
2992
- return !0;
2993
- try {
2994
- return !!new RegExp(t);
2995
- } catch {
2996
- return !1;
2997
- }
2998
- },
2999
- date: function(t) {
3000
- return typeof t.getTime == "function" && typeof t.getMonth == "function" && typeof t.getYear == "function" && !isNaN(t.getTime());
3001
- },
3002
- number: function(t) {
3003
- return isNaN(t) ? !1 : typeof t == "number";
3004
- },
3005
- object: function(t) {
3006
- return ee(t) === "object" && !Te.array(t);
3007
- },
3008
- method: function(t) {
3009
- return typeof t == "function";
3010
- },
3011
- email: function(t) {
3012
- return typeof t == "string" && t.length <= 320 && !!t.match(mr.email);
3013
- },
3014
- url: function(t) {
3015
- return typeof t == "string" && t.length <= 2048 && !!t.match(Ca());
3016
- },
3017
- hex: function(t) {
3018
- return typeof t == "string" && !!t.match(mr.hex);
3019
- }
3020
- }, Fa = function(t, r, i, n, a) {
3021
- if (t.required && r === void 0) {
3022
- Ur(t, r, i, n, a);
3023
- return;
3024
- }
3025
- var o = ["integer", "float", "array", "regexp", "object", "method", "email", "number", "date", "url", "hex"], s = t.type;
3026
- o.indexOf(s) > -1 ? Te[s](r) || n.push(se(a.messages.types[s], t.fullField, t.type)) : s && ee(r) !== t.type && n.push(se(a.messages.types[s], t.fullField, t.type));
3027
- }, Ea = function(t, r, i, n, a) {
3028
- (/^\s+$/.test(r) || r === "") && n.push(se(a.messages.whitespace, t.fullField));
3029
- };
3030
- const D = {
3031
- required: Ur,
3032
- whitespace: Ea,
3033
- type: Fa,
3034
- range: ba,
3035
- enum: pa,
3036
- pattern: ya
3037
- };
3038
- var wa = function(t, r, i, n, a) {
3039
- var o = [], s = t.required || !t.required && n.hasOwnProperty(t.field);
3040
- if (s) {
3041
- if (X(r) && !t.required)
3042
- return i();
3043
- D.required(t, r, n, o, a);
3044
- }
3045
- i(o);
3046
- }, Sa = function(t, r, i, n, a) {
3047
- var o = [], s = t.required || !t.required && n.hasOwnProperty(t.field);
3048
- if (s) {
3049
- if (r == null && !t.required)
3050
- return i();
3051
- D.required(t, r, n, o, a, "array"), r != null && (D.type(t, r, n, o, a), D.range(t, r, n, o, a));
3052
- }
3053
- i(o);
3054
- }, xa = function(t, r, i, n, a) {
3055
- var o = [], s = t.required || !t.required && n.hasOwnProperty(t.field);
3056
- if (s) {
3057
- if (X(r) && !t.required)
3058
- return i();
3059
- D.required(t, r, n, o, a), r !== void 0 && D.type(t, r, n, o, a);
3060
- }
3061
- i(o);
3062
- }, Oa = function(t, r, i, n, a) {
3063
- var o = [], s = t.required || !t.required && n.hasOwnProperty(t.field);
3064
- if (s) {
3065
- if (X(r, "date") && !t.required)
3066
- return i();
3067
- if (D.required(t, r, n, o, a), !X(r, "date")) {
3068
- var c;
3069
- r instanceof Date ? c = r : c = new Date(r), D.type(t, c, n, o, a), c && D.range(t, c.getTime(), n, o, a);
3070
- }
3071
- }
3072
- i(o);
3073
- }, $a = "enum", Pa = function(t, r, i, n, a) {
3074
- var o = [], s = t.required || !t.required && n.hasOwnProperty(t.field);
3075
- if (s) {
3076
- if (X(r) && !t.required)
3077
- return i();
3078
- D.required(t, r, n, o, a), r !== void 0 && D[$a](t, r, n, o, a);
3079
- }
3080
- i(o);
3081
- }, Ra = function(t, r, i, n, a) {
3082
- var o = [], s = t.required || !t.required && n.hasOwnProperty(t.field);
3083
- if (s) {
3084
- if (X(r) && !t.required)
3085
- return i();
3086
- D.required(t, r, n, o, a), r !== void 0 && (D.type(t, r, n, o, a), D.range(t, r, n, o, a));
3087
- }
3088
- i(o);
3089
- }, Na = function(t, r, i, n, a) {
3090
- var o = [], s = t.required || !t.required && n.hasOwnProperty(t.field);
3091
- if (s) {
3092
- if (X(r) && !t.required)
3093
- return i();
3094
- D.required(t, r, n, o, a), r !== void 0 && (D.type(t, r, n, o, a), D.range(t, r, n, o, a));
3095
- }
3096
- i(o);
3097
- }, Va = function(t, r, i, n, a) {
3098
- var o = [], s = t.required || !t.required && n.hasOwnProperty(t.field);
3099
- if (s) {
3100
- if (X(r) && !t.required)
3101
- return i();
3102
- D.required(t, r, n, o, a), r !== void 0 && D.type(t, r, n, o, a);
3103
- }
3104
- i(o);
3105
- }, _a = function(t, r, i, n, a) {
3106
- var o = [], s = t.required || !t.required && n.hasOwnProperty(t.field);
3107
- if (s) {
3108
- if (r === "" && (r = void 0), X(r) && !t.required)
3109
- return i();
3110
- D.required(t, r, n, o, a), r !== void 0 && (D.type(t, r, n, o, a), D.range(t, r, n, o, a));
3111
- }
3112
- i(o);
3113
- }, Ia = function(t, r, i, n, a) {
3114
- var o = [], s = t.required || !t.required && n.hasOwnProperty(t.field);
3115
- if (s) {
3116
- if (X(r) && !t.required)
3117
- return i();
3118
- D.required(t, r, n, o, a), r !== void 0 && D.type(t, r, n, o, a);
3119
- }
3120
- i(o);
3121
- }, La = function(t, r, i, n, a) {
3122
- var o = [], s = t.required || !t.required && n.hasOwnProperty(t.field);
3123
- if (s) {
3124
- if (X(r, "string") && !t.required)
3125
- return i();
3126
- D.required(t, r, n, o, a), X(r, "string") || D.pattern(t, r, n, o, a);
3127
- }
3128
- i(o);
3129
- }, Ha = function(t, r, i, n, a) {
3130
- var o = [], s = t.required || !t.required && n.hasOwnProperty(t.field);
3131
- if (s) {
3132
- if (X(r) && !t.required)
3133
- return i();
3134
- D.required(t, r, n, o, a), X(r) || D.type(t, r, n, o, a);
3135
- }
3136
- i(o);
3137
- }, Ta = function(t, r, i, n, a) {
3138
- var o = [], s = Array.isArray(r) ? "array" : ee(r);
3139
- D.required(t, r, n, o, a, s), i(o);
3140
- }, Aa = function(t, r, i, n, a) {
3141
- var o = [], s = t.required || !t.required && n.hasOwnProperty(t.field);
3142
- if (s) {
3143
- if (X(r, "string") && !t.required)
3144
- return i();
3145
- D.required(t, r, n, o, a, "string"), X(r, "string") || (D.type(t, r, n, o, a), D.range(t, r, n, o, a), D.pattern(t, r, n, o, a), t.whitespace === !0 && D.whitespace(t, r, n, o, a));
3146
- }
3147
- i(o);
3148
- }, gt = function(t, r, i, n, a) {
3149
- var o = t.type, s = [], c = t.required || !t.required && n.hasOwnProperty(t.field);
3150
- if (c) {
3151
- if (X(r, o) && !t.required)
3152
- return i();
3153
- D.required(t, r, n, s, a, o), X(r, o) || D.type(t, r, n, s, a);
3154
- }
3155
- i(s);
3156
- };
3157
- const Ae = {
3158
- string: Aa,
3159
- method: Va,
3160
- number: _a,
3161
- boolean: xa,
3162
- regexp: Ha,
3163
- integer: Na,
3164
- float: Ra,
3165
- array: Sa,
3166
- object: Ia,
3167
- enum: Pa,
3168
- pattern: La,
3169
- date: Oa,
3170
- url: gt,
3171
- hex: gt,
3172
- email: gt,
3173
- required: Ta,
3174
- any: wa
3175
- };
3176
- var We = /* @__PURE__ */ function() {
3177
- function e(t) {
3178
- Ce(this, e), m(this, "rules", null), m(this, "_messages", Ft), this.define(t);
3179
- }
3180
- return Fe(e, [{
3181
- key: "define",
3182
- value: function(r) {
3183
- var i = this;
3184
- if (!r)
3185
- throw new Error("Cannot configure a schema with no rules");
3186
- if (ee(r) !== "object" || Array.isArray(r))
3187
- throw new Error("Rules must be an object");
3188
- this.rules = {}, Object.keys(r).forEach(function(n) {
3189
- var a = r[n];
3190
- i.rules[n] = Array.isArray(a) ? a : [a];
3191
- });
3192
- }
3193
- }, {
3194
- key: "messages",
3195
- value: function(r) {
3196
- return r && (this._messages = hr(Ct(), r)), this._messages;
3197
- }
3198
- }, {
3199
- key: "validate",
3200
- value: function(r) {
3201
- var i = this, n = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, a = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : function() {
3202
- }, o = r, s = n, c = a;
3203
- if (typeof s == "function" && (c = s, s = {}), !this.rules || Object.keys(this.rules).length === 0)
3204
- return c && c(null, o), Promise.resolve(o);
3205
- function u(v) {
3206
- var p = [], d = {};
3207
- function C(b) {
3208
- if (Array.isArray(b)) {
3209
- var S;
3210
- p = (S = p).concat.apply(S, B(b));
3211
- } else
3212
- p.push(b);
3213
- }
3214
- for (var h = 0; h < v.length; h++)
3215
- C(v[h]);
3216
- p.length ? (d = wt(p), c(p, d)) : c(null, o);
3217
- }
3218
- if (s.messages) {
3219
- var l = this.messages();
3220
- l === Ft && (l = Ct()), hr(l, s.messages), s.messages = l;
3221
- } else
3222
- s.messages = this.messages();
3223
- var f = {}, g = s.keys || Object.keys(this.rules);
3224
- g.forEach(function(v) {
3225
- var p = i.rules[v], d = o[v];
3226
- p.forEach(function(C) {
3227
- var h = C;
3228
- typeof h.transform == "function" && (o === r && (o = T({}, o)), d = o[v] = h.transform(d), d != null && (h.type = h.type || (Array.isArray(d) ? "array" : ee(d)))), typeof h == "function" ? h = {
3229
- validator: h
3230
- } : h = T({}, h), h.validator = i.getValidationMethod(h), h.validator && (h.field = v, h.fullField = h.fullField || v, h.type = i.getType(h), f[v] = f[v] || [], f[v].push({
3231
- rule: h,
3232
- value: d,
3233
- source: o,
3234
- field: v
3235
- }));
3236
- });
3237
- });
3238
- var O = {};
3239
- return ha(f, s, function(v, p) {
3240
- var d = v.rule, C = (d.type === "object" || d.type === "array") && (ee(d.fields) === "object" || ee(d.defaultField) === "object");
3241
- C = C && (d.required || !d.required && v.value), d.field = v.field;
3242
- function h(R, _) {
3243
- return T(T({}, _), {}, {
3244
- fullField: "".concat(d.fullField, ".").concat(R),
3245
- fullFields: d.fullFields ? [].concat(B(d.fullFields), [R]) : [R]
3246
- });
3247
- }
3248
- function b() {
3249
- var R = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [], _ = Array.isArray(R) ? R : [R];
3250
- !s.suppressWarning && _.length && e.warning("async-validator:", _), _.length && d.message !== void 0 && (_ = [].concat(d.message));
3251
- var P = _.map(gr(d, o));
3252
- if (s.first && P.length)
3253
- return O[d.field] = 1, p(P);
3254
- if (!C)
3255
- p(P);
3256
- else {
3257
- if (d.required && !v.value)
3258
- return d.message !== void 0 ? P = [].concat(d.message).map(gr(d, o)) : s.error && (P = [s.error(d, se(s.messages.required, d.field))]), p(P);
3259
- var I = {};
3260
- d.defaultField && Object.keys(v.value).map(function(j) {
3261
- I[j] = d.defaultField;
3262
- }), I = T(T({}, I), v.rule.fields);
3263
- var M = {};
3264
- Object.keys(I).forEach(function(j) {
3265
- var A = I[j], K = Array.isArray(A) ? A : [A];
3266
- M[j] = K.map(h.bind(null, j));
3267
- });
3268
- var z = new e(M);
3269
- z.messages(s.messages), v.rule.options && (v.rule.options.messages = s.messages, v.rule.options.error = s.error), z.validate(v.value, v.rule.options || s, function(j) {
3270
- var A = [];
3271
- P && P.length && A.push.apply(A, B(P)), j && j.length && A.push.apply(A, B(j)), p(A.length ? A : null);
3272
- });
3273
- }
3274
- }
3275
- var S;
3276
- if (d.asyncValidator)
3277
- S = d.asyncValidator(d, v.value, b, v.source, s);
3278
- else if (d.validator) {
3279
- try {
3280
- S = d.validator(d, v.value, b, v.source, s);
3281
- } catch (R) {
3282
- var w, V;
3283
- (w = (V = console).error) === null || w === void 0 || w.call(V, R), s.suppressValidatorError || setTimeout(function() {
3284
- throw R;
3285
- }, 0), b(R.message);
3286
- }
3287
- S === !0 ? b() : S === !1 ? b(typeof d.message == "function" ? d.message(d.fullField || d.field) : d.message || "".concat(d.fullField || d.field, " fails")) : S instanceof Array ? b(S) : S instanceof Error && b(S.message);
3288
- }
3289
- S && S.then && S.then(function() {
3290
- return b();
3291
- }, function(R) {
3292
- return b(R);
3293
- });
3294
- }, function(v) {
3295
- u(v);
3296
- }, o);
3297
- }
3298
- }, {
3299
- key: "getType",
3300
- value: function(r) {
3301
- if (r.type === void 0 && r.pattern instanceof RegExp && (r.type = "pattern"), typeof r.validator != "function" && r.type && !Ae.hasOwnProperty(r.type))
3302
- throw new Error(se("Unknown rule type %s", r.type));
3303
- return r.type || "string";
3304
- }
3305
- }, {
3306
- key: "getValidationMethod",
3307
- value: function(r) {
3308
- if (typeof r.validator == "function")
3309
- return r.validator;
3310
- var i = Object.keys(r), n = i.indexOf("message");
3311
- return n !== -1 && i.splice(n, 1), i.length === 1 && i[0] === "required" ? Ae.required : Ae[this.getType(r)] || void 0;
3312
- }
3313
- }]), e;
3314
- }();
3315
- m(We, "register", function(t, r) {
3316
- if (typeof r != "function")
3317
- throw new Error("Cannot register a validator by type, validator is not a function");
3318
- Ae[t] = r;
3319
- });
3320
- m(We, "warning", Gr);
3321
- m(We, "messages", Ft);
3322
- m(We, "validators", Ae);
3323
- var oe = "'${name}' is not a valid ${type}", Kr = {
3324
- default: "Validation error on field '${name}'",
3325
- required: "'${name}' is required",
3326
- enum: "'${name}' must be one of [${enum}]",
3327
- whitespace: "'${name}' cannot be empty",
3328
- date: {
3329
- format: "'${name}' is invalid for format date",
3330
- parse: "'${name}' could not be parsed as date",
3331
- invalid: "'${name}' is invalid date"
3332
- },
3333
- types: {
3334
- string: oe,
3335
- method: oe,
3336
- array: oe,
3337
- object: oe,
3338
- number: oe,
3339
- date: oe,
3340
- boolean: oe,
3341
- integer: oe,
3342
- float: oe,
3343
- regexp: oe,
3344
- email: oe,
3345
- url: oe,
3346
- hex: oe
3347
- },
3348
- string: {
3349
- len: "'${name}' must be exactly ${len} characters",
3350
- min: "'${name}' must be at least ${min} characters",
3351
- max: "'${name}' cannot be longer than ${max} characters",
3352
- range: "'${name}' must be between ${min} and ${max} characters"
3353
- },
3354
- number: {
3355
- len: "'${name}' must equal ${len}",
3356
- min: "'${name}' cannot be less than ${min}",
3357
- max: "'${name}' cannot be greater than ${max}",
3358
- range: "'${name}' must be between ${min} and ${max}"
3359
- },
3360
- array: {
3361
- len: "'${name}' must be exactly ${len} in length",
3362
- min: "'${name}' cannot be less than ${min} in length",
3363
- max: "'${name}' cannot be greater than ${max} in length",
3364
- range: "'${name}' must be between ${min} and ${max} in length"
3365
- },
3366
- pattern: {
3367
- mismatch: "'${name}' does not match pattern ${pattern}"
3368
- }
3369
- }, vr = We;
3370
- function Ma(e, t) {
3371
- return e.replace(/\\?\$\{\w+\}/g, function(r) {
3372
- if (r.startsWith("\\"))
3373
- return r.slice(1);
3374
- var i = r.slice(2, -1);
3375
- return t[i];
3376
- });
3377
- }
3378
- var pr = "CODE_LOGIC_ERROR";
3379
- function St(e, t, r, i, n) {
3380
- return xt.apply(this, arguments);
3381
- }
3382
- function xt() {
3383
- return xt = Ee(/* @__PURE__ */ ie().mark(function e(t, r, i, n, a) {
3384
- var o, s, c, u, l, f, g, O, v;
3385
- return ie().wrap(function(d) {
3386
- for (; ; ) switch (d.prev = d.next) {
3387
- case 0:
3388
- return o = T({}, i), delete o.ruleIndex, vr.warning = function() {
3389
- }, o.validator && (s = o.validator, o.validator = function() {
3390
- try {
3391
- return s.apply(void 0, arguments);
3392
- } catch (C) {
3393
- return console.error(C), Promise.reject(pr);
3394
- }
3395
- }), c = null, o && o.type === "array" && o.defaultField && (c = o.defaultField, delete o.defaultField), u = new vr(m({}, t, [o])), l = He(Kr, n.validateMessages), u.messages(l), f = [], d.prev = 10, d.next = 13, Promise.resolve(u.validate(m({}, t, r), T({}, n)));
3396
- case 13:
3397
- d.next = 18;
3398
- break;
3399
- case 15:
3400
- d.prev = 15, d.t0 = d.catch(10), d.t0.errors && (f = d.t0.errors.map(function(C, h) {
3401
- var b = C.message, S = b === pr ? l.default : b;
3402
- return /* @__PURE__ */ $.isValidElement(S) ? (
3403
- // Wrap ReactNode with `key`
3404
- /* @__PURE__ */ $.cloneElement(S, {
3405
- key: "error_".concat(h)
3406
- })
3407
- ) : S;
3408
- }));
3409
- case 18:
3410
- if (!(!f.length && c)) {
3411
- d.next = 23;
3412
- break;
3413
- }
3414
- return d.next = 21, Promise.all(r.map(function(C, h) {
3415
- return St("".concat(t, ".").concat(h), C, c, n, a);
3416
- }));
3417
- case 21:
3418
- return g = d.sent, d.abrupt("return", g.reduce(function(C, h) {
3419
- return [].concat(B(C), B(h));
3420
- }, []));
3421
- case 23:
3422
- return O = T(T({}, i), {}, {
3423
- name: t,
3424
- enum: (i.enum || []).join(", ")
3425
- }, a), v = f.map(function(C) {
3426
- return typeof C == "string" ? Ma(C, O) : C;
3427
- }), d.abrupt("return", v);
3428
- case 26:
3429
- case "end":
3430
- return d.stop();
3431
- }
3432
- }, e, null, [[10, 15]]);
3433
- })), xt.apply(this, arguments);
3434
- }
3435
- function ja(e, t, r, i, n, a) {
3436
- var o = e.join("."), s = r.map(function(l, f) {
3437
- var g = l.validator, O = T(T({}, l), {}, {
3438
- ruleIndex: f
3439
- });
3440
- return g && (O.validator = function(v, p, d) {
3441
- var C = !1, h = function() {
3442
- for (var w = arguments.length, V = new Array(w), R = 0; R < w; R++)
3443
- V[R] = arguments[R];
3444
- Promise.resolve().then(function() {
3445
- re(!C, "Your validator function has already return a promise. `callback` will be ignored."), C || d.apply(void 0, V);
3446
- });
3447
- }, b = g(v, p, h);
3448
- C = b && typeof b.then == "function" && typeof b.catch == "function", re(C, "`callback` is deprecated. Please return a promise instead."), C && b.then(function() {
3449
- d();
3450
- }).catch(function(S) {
3451
- d(S || " ");
3452
- });
3453
- }), O;
3454
- }).sort(function(l, f) {
3455
- var g = l.warningOnly, O = l.ruleIndex, v = f.warningOnly, p = f.ruleIndex;
3456
- return !!g == !!v ? O - p : g ? 1 : -1;
3457
- }), c;
3458
- if (n === !0)
3459
- c = new Promise(/* @__PURE__ */ function() {
3460
- var l = Ee(/* @__PURE__ */ ie().mark(function f(g, O) {
3461
- var v, p, d;
3462
- return ie().wrap(function(h) {
3463
- for (; ; ) switch (h.prev = h.next) {
3464
- case 0:
3465
- v = 0;
3466
- case 1:
3467
- if (!(v < s.length)) {
3468
- h.next = 12;
3469
- break;
3470
- }
3471
- return p = s[v], h.next = 5, St(o, t, p, i, a);
3472
- case 5:
3473
- if (d = h.sent, !d.length) {
3474
- h.next = 9;
3475
- break;
3476
- }
3477
- return O([{
3478
- errors: d,
3479
- rule: p
3480
- }]), h.abrupt("return");
3481
- case 9:
3482
- v += 1, h.next = 1;
3483
- break;
3484
- case 12:
3485
- g([]);
3486
- case 13:
3487
- case "end":
3488
- return h.stop();
3489
- }
3490
- }, f);
3491
- }));
3492
- return function(f, g) {
3493
- return l.apply(this, arguments);
3494
- };
3495
- }());
3496
- else {
3497
- var u = s.map(function(l) {
3498
- return St(o, t, l, i, a).then(function(f) {
3499
- return {
3500
- errors: f,
3501
- rule: l
3502
- };
3503
- });
3504
- });
3505
- c = (n ? Da(u) : Ba(u)).then(function(l) {
3506
- return Promise.reject(l);
3507
- });
3508
- }
3509
- return c.catch(function(l) {
3510
- return l;
3511
- }), c;
3512
- }
3513
- function Ba(e) {
3514
- return Ot.apply(this, arguments);
3515
- }
3516
- function Ot() {
3517
- return Ot = Ee(/* @__PURE__ */ ie().mark(function e(t) {
3518
- return ie().wrap(function(i) {
3519
- for (; ; ) switch (i.prev = i.next) {
3520
- case 0:
3521
- return i.abrupt("return", Promise.all(t).then(function(n) {
3522
- var a, o = (a = []).concat.apply(a, B(n));
3523
- return o;
3524
- }));
3525
- case 1:
3526
- case "end":
3527
- return i.stop();
3528
- }
3529
- }, e);
3530
- })), Ot.apply(this, arguments);
3531
- }
3532
- function Da(e) {
3533
- return $t.apply(this, arguments);
3534
- }
3535
- function $t() {
3536
- return $t = Ee(/* @__PURE__ */ ie().mark(function e(t) {
3537
- var r;
3538
- return ie().wrap(function(n) {
3539
- for (; ; ) switch (n.prev = n.next) {
3540
- case 0:
3541
- return r = 0, n.abrupt("return", new Promise(function(a) {
3542
- t.forEach(function(o) {
3543
- o.then(function(s) {
3544
- s.errors.length && a([s]), r += 1, r === t.length && a([]);
3545
- });
3546
- });
3547
- }));
3548
- case 2:
3549
- case "end":
3550
- return n.stop();
3551
- }
3552
- }, e);
3553
- })), $t.apply(this, arguments);
3554
- }
3555
- function Z(e) {
3556
- return bt(e);
3557
- }
3558
- function yr(e, t) {
3559
- var r = {};
3560
- return t.forEach(function(i) {
3561
- var n = pe(e, i);
3562
- r = ve(r, i, n);
3563
- }), r;
3564
- }
3565
- function Re(e, t) {
3566
- var r = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : !1;
3567
- return e && e.some(function(i) {
3568
- return Yr(t, i, r);
3569
- });
3570
- }
3571
- function Yr(e, t) {
3572
- var r = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : !1;
3573
- return !e || !t || !r && e.length !== t.length ? !1 : t.every(function(i, n) {
3574
- return e[n] === i;
3575
- });
3576
- }
3577
- function za(e, t) {
3578
- if (e === t)
3579
- return !0;
3580
- if (!e && t || e && !t || !e || !t || ee(e) !== "object" || ee(t) !== "object")
3581
- return !1;
3582
- var r = Object.keys(e), i = Object.keys(t), n = new Set([].concat(r, i));
3583
- return B(n).every(function(a) {
3584
- var o = e[a], s = t[a];
3585
- return typeof o == "function" && typeof s == "function" ? !0 : o === s;
3586
- });
3587
- }
3588
- function Wa(e) {
3589
- var t = arguments.length <= 1 ? void 0 : arguments[1];
3590
- return t && t.target && ee(t.target) === "object" && e in t.target ? t.target[e] : t;
3591
- }
3592
- function br(e, t, r) {
3593
- var i = e.length;
3594
- if (t < 0 || t >= i || r < 0 || r >= i)
3595
- return e;
3596
- var n = e[t], a = t - r;
3597
- return a > 0 ? [].concat(B(e.slice(0, r)), [n], B(e.slice(r, t)), B(e.slice(t + 1, i))) : a < 0 ? [].concat(B(e.slice(0, t)), B(e.slice(t + 1, r + 1)), [n], B(e.slice(r + 1, i))) : e;
3598
- }
3599
- var qa = ["name"], le = [];
3600
- function ht(e, t, r, i, n, a) {
3601
- return typeof e == "function" ? e(t, r, "source" in a ? {
3602
- source: a.source
3603
- } : {}) : i !== n;
3604
- }
3605
- var Wt = /* @__PURE__ */ function(e) {
3606
- Lt(r, e);
3607
- var t = Ht(r);
3608
- function r(i) {
3609
- var n;
3610
- if (Ce(this, r), n = t.call(this, i), m(W(n), "state", {
3611
- resetCount: 0
3612
- }), m(W(n), "cancelRegisterFunc", null), m(W(n), "mounted", !1), m(W(n), "touched", !1), m(W(n), "dirty", !1), m(W(n), "validatePromise", void 0), m(W(n), "prevValidating", void 0), m(W(n), "errors", le), m(W(n), "warnings", le), m(W(n), "cancelRegister", function() {
3613
- var c = n.props, u = c.preserve, l = c.isListField, f = c.name;
3614
- n.cancelRegisterFunc && n.cancelRegisterFunc(l, u, Z(f)), n.cancelRegisterFunc = null;
3615
- }), m(W(n), "getNamePath", function() {
3616
- var c = n.props, u = c.name, l = c.fieldContext, f = l.prefixName, g = f === void 0 ? [] : f;
3617
- return u !== void 0 ? [].concat(B(g), B(u)) : [];
3618
- }), m(W(n), "getRules", function() {
3619
- var c = n.props, u = c.rules, l = u === void 0 ? [] : u, f = c.fieldContext;
3620
- return l.map(function(g) {
3621
- return typeof g == "function" ? g(f) : g;
3622
- });
3623
- }), m(W(n), "refresh", function() {
3624
- n.mounted && n.setState(function(c) {
3625
- var u = c.resetCount;
3626
- return {
3627
- resetCount: u + 1
3628
- };
3629
- });
3630
- }), m(W(n), "metaCache", null), m(W(n), "triggerMetaEvent", function(c) {
3631
- var u = n.props.onMetaChange;
3632
- if (u) {
3633
- var l = T(T({}, n.getMeta()), {}, {
3634
- destroy: c
3635
- });
3636
- tr(n.metaCache, l) || u(l), n.metaCache = l;
3637
- } else
3638
- n.metaCache = null;
3639
- }), m(W(n), "onStoreChange", function(c, u, l) {
3640
- var f = n.props, g = f.shouldUpdate, O = f.dependencies, v = O === void 0 ? [] : O, p = f.onReset, d = l.store, C = n.getNamePath(), h = n.getValue(c), b = n.getValue(d), S = u && Re(u, C);
3641
- switch (l.type === "valueUpdate" && l.source === "external" && !tr(h, b) && (n.touched = !0, n.dirty = !0, n.validatePromise = null, n.errors = le, n.warnings = le, n.triggerMetaEvent()), l.type) {
3642
- case "reset":
3643
- if (!u || S) {
3644
- n.touched = !1, n.dirty = !1, n.validatePromise = void 0, n.errors = le, n.warnings = le, n.triggerMetaEvent(), p == null || p(), n.refresh();
3645
- return;
3646
- }
3647
- break;
3648
- case "remove": {
3649
- if (g && ht(g, c, d, h, b, l)) {
3650
- n.reRender();
3651
- return;
3652
- }
3653
- break;
3654
- }
3655
- case "setField": {
3656
- var w = l.data;
3657
- if (S) {
3658
- "touched" in w && (n.touched = w.touched), "validating" in w && !("originRCField" in w) && (n.validatePromise = w.validating ? Promise.resolve([]) : null), "errors" in w && (n.errors = w.errors || le), "warnings" in w && (n.warnings = w.warnings || le), n.dirty = !0, n.triggerMetaEvent(), n.reRender();
3659
- return;
3660
- } else if ("value" in w && Re(u, C, !0)) {
3661
- n.reRender();
3662
- return;
3663
- }
3664
- if (g && !C.length && ht(g, c, d, h, b, l)) {
3665
- n.reRender();
3666
- return;
3667
- }
3668
- break;
3669
- }
3670
- case "dependenciesUpdate": {
3671
- var V = v.map(Z);
3672
- if (V.some(function(R) {
3673
- return Re(l.relatedFields, R);
3674
- })) {
3675
- n.reRender();
3676
- return;
3677
- }
3678
- break;
3679
- }
3680
- default:
3681
- if (S || (!v.length || C.length || g) && ht(g, c, d, h, b, l)) {
3682
- n.reRender();
3683
- return;
3684
- }
3685
- break;
3686
- }
3687
- g === !0 && n.reRender();
3688
- }), m(W(n), "validateRules", function(c) {
3689
- var u = n.getNamePath(), l = n.getValue(), f = c || {}, g = f.triggerName, O = f.validateOnly, v = O === void 0 ? !1 : O, p = Promise.resolve().then(/* @__PURE__ */ Ee(/* @__PURE__ */ ie().mark(function d() {
3690
- var C, h, b, S, w, V, R;
3691
- return ie().wrap(function(P) {
3692
- for (; ; ) switch (P.prev = P.next) {
3693
- case 0:
3694
- if (n.mounted) {
3695
- P.next = 2;
3696
- break;
3697
- }
3698
- return P.abrupt("return", []);
3699
- case 2:
3700
- if (C = n.props, h = C.validateFirst, b = h === void 0 ? !1 : h, S = C.messageVariables, w = C.validateDebounce, V = n.getRules(), g && (V = V.filter(function(I) {
3701
- return I;
3702
- }).filter(function(I) {
3703
- var M = I.validateTrigger;
3704
- if (!M)
3705
- return !0;
3706
- var z = bt(M);
3707
- return z.includes(g);
3708
- })), !(w && g)) {
3709
- P.next = 10;
3710
- break;
3711
- }
3712
- return P.next = 8, new Promise(function(I) {
3713
- setTimeout(I, w);
3714
- });
3715
- case 8:
3716
- if (n.validatePromise === p) {
3717
- P.next = 10;
3718
- break;
3719
- }
3720
- return P.abrupt("return", []);
3721
- case 10:
3722
- return R = ja(u, l, V, c, b, S), R.catch(function(I) {
3723
- return I;
3724
- }).then(function() {
3725
- var I = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : le;
3726
- if (n.validatePromise === p) {
3727
- var M;
3728
- n.validatePromise = null;
3729
- var z = [], j = [];
3730
- (M = I.forEach) === null || M === void 0 || M.call(I, function(A) {
3731
- var K = A.rule.warningOnly, F = A.errors, y = F === void 0 ? le : F;
3732
- K ? j.push.apply(j, B(y)) : z.push.apply(z, B(y));
3733
- }), n.errors = z, n.warnings = j, n.triggerMetaEvent(), n.reRender();
3734
- }
3735
- }), P.abrupt("return", R);
3736
- case 13:
3737
- case "end":
3738
- return P.stop();
3739
- }
3740
- }, d);
3741
- })));
3742
- return v || (n.validatePromise = p, n.dirty = !0, n.errors = le, n.warnings = le, n.triggerMetaEvent(), n.reRender()), p;
3743
- }), m(W(n), "isFieldValidating", function() {
3744
- return !!n.validatePromise;
3745
- }), m(W(n), "isFieldTouched", function() {
3746
- return n.touched;
3747
- }), m(W(n), "isFieldDirty", function() {
3748
- if (n.dirty || n.props.initialValue !== void 0)
3749
- return !0;
3750
- var c = n.props.fieldContext, u = c.getInternalHooks(ye), l = u.getInitialValue;
3751
- return l(n.getNamePath()) !== void 0;
3752
- }), m(W(n), "getErrors", function() {
3753
- return n.errors;
3754
- }), m(W(n), "getWarnings", function() {
3755
- return n.warnings;
3756
- }), m(W(n), "isListField", function() {
3757
- return n.props.isListField;
3758
- }), m(W(n), "isList", function() {
3759
- return n.props.isList;
3760
- }), m(W(n), "isPreserve", function() {
3761
- return n.props.preserve;
3762
- }), m(W(n), "getMeta", function() {
3763
- n.prevValidating = n.isFieldValidating();
3764
- var c = {
3765
- touched: n.isFieldTouched(),
3766
- validating: n.prevValidating,
3767
- errors: n.errors,
3768
- warnings: n.warnings,
3769
- name: n.getNamePath(),
3770
- validated: n.validatePromise === null
3771
- };
3772
- return c;
3773
- }), m(W(n), "getOnlyChild", function(c) {
3774
- if (typeof c == "function") {
3775
- var u = n.getMeta();
3776
- return T(T({}, n.getOnlyChild(c(n.getControlled(), u, n.props.fieldContext))), {}, {
3777
- isFunction: !0
3778
- });
3779
- }
3780
- var l = Sr(c);
3781
- return l.length !== 1 || !/* @__PURE__ */ $.isValidElement(l[0]) ? {
3782
- child: l,
3783
- isFunction: !1
3784
- } : {
3785
- child: l[0],
3786
- isFunction: !1
3787
- };
3788
- }), m(W(n), "getValue", function(c) {
3789
- var u = n.props.fieldContext.getFieldsValue, l = n.getNamePath();
3790
- return pe(c || u(!0), l);
3791
- }), m(W(n), "getControlled", function() {
3792
- var c = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, u = n.props, l = u.name, f = u.trigger, g = u.validateTrigger, O = u.getValueFromEvent, v = u.normalize, p = u.valuePropName, d = u.getValueProps, C = u.fieldContext, h = g !== void 0 ? g : C.validateTrigger, b = n.getNamePath(), S = C.getInternalHooks, w = C.getFieldsValue, V = S(ye), R = V.dispatch, _ = n.getValue(), P = d || function(A) {
3793
- return m({}, p, A);
3794
- }, I = c[f], M = l !== void 0 ? P(_) : {};
3795
- process.env.NODE_ENV !== "production" && M && Object.keys(M).forEach(function(A) {
3796
- re(typeof M[A] != "function", "It's not recommended to generate dynamic function prop by `getValueProps`. Please pass it to child component directly (prop: ".concat(A, ")"));
3797
- });
3798
- var z = T(T({}, c), M);
3799
- z[f] = function() {
3800
- n.touched = !0, n.dirty = !0, n.triggerMetaEvent();
3801
- for (var A, K = arguments.length, F = new Array(K), y = 0; y < K; y++)
3802
- F[y] = arguments[y];
3803
- O ? A = O.apply(void 0, F) : A = Wa.apply(void 0, [p].concat(F)), v && (A = v(A, _, w(!0))), A !== _ && R({
3804
- type: "updateValue",
3805
- namePath: b,
3806
- value: A
3807
- }), I && I.apply(void 0, F);
3808
- };
3809
- var j = bt(h || []);
3810
- return j.forEach(function(A) {
3811
- var K = z[A];
3812
- z[A] = function() {
3813
- K && K.apply(void 0, arguments);
3814
- var F = n.props.rules;
3815
- F && F.length && R({
3816
- type: "validateField",
3817
- namePath: b,
3818
- triggerName: A
3819
- });
3820
- };
3821
- }), z;
3822
- }), i.fieldContext) {
3823
- var a = i.fieldContext.getInternalHooks, o = a(ye), s = o.initEntityValue;
3824
- s(W(n));
3825
- }
3826
- return n;
3827
- }
3828
- return Fe(r, [{
3829
- key: "componentDidMount",
3830
- value: function() {
3831
- var n = this.props, a = n.shouldUpdate, o = n.fieldContext;
3832
- if (this.mounted = !0, o) {
3833
- var s = o.getInternalHooks, c = s(ye), u = c.registerField;
3834
- this.cancelRegisterFunc = u(this);
3835
- }
3836
- a === !0 && this.reRender();
3837
- }
3838
- }, {
3839
- key: "componentWillUnmount",
3840
- value: function() {
3841
- this.cancelRegister(), this.triggerMetaEvent(!0), this.mounted = !1;
3842
- }
3843
- }, {
3844
- key: "reRender",
3845
- value: function() {
3846
- this.mounted && this.forceUpdate();
3847
- }
3848
- }, {
3849
- key: "render",
3850
- value: function() {
3851
- var n = this.state.resetCount, a = this.props.children, o = this.getOnlyChild(a), s = o.child, c = o.isFunction, u;
3852
- return c ? u = s : /* @__PURE__ */ $.isValidElement(s) ? u = /* @__PURE__ */ $.cloneElement(s, this.getControlled(s.props)) : (re(!s, "`children` of Field is not validate ReactElement."), u = s), /* @__PURE__ */ $.createElement($.Fragment, {
3853
- key: n
3854
- }, u);
3855
- }
3856
- }]), r;
3857
- }($.Component);
3858
- m(Wt, "contextType", Ve);
3859
- m(Wt, "defaultProps", {
3860
- trigger: "onChange",
3861
- valuePropName: "value"
3862
- });
3863
- function Zr(e) {
3864
- var t = e.name, r = De(e, qa), i = $.useContext(Ve), n = $.useContext(Xe), a = t !== void 0 ? Z(t) : void 0, o = "keep";
3865
- return r.isListField || (o = "_".concat((a || []).join("_"))), process.env.NODE_ENV !== "production" && r.preserve === !1 && r.isListField && a.length <= 1 && re(!1, "`preserve` should not apply on Form.List fields."), /* @__PURE__ */ $.createElement(Wt, $e({
3866
- key: o,
3867
- name: a,
3868
- isListField: !!n
3869
- }, r, {
3870
- fieldContext: i
3871
- }));
3872
- }
3873
- function Ga(e) {
3874
- var t = e.name, r = e.initialValue, i = e.children, n = e.rules, a = e.validateTrigger, o = e.isListField, s = $.useContext(Ve), c = $.useContext(Xe), u = $.useRef({
3875
- keys: [],
3876
- id: 0
3877
- }), l = u.current, f = $.useMemo(function() {
3878
- var p = Z(s.prefixName) || [];
3879
- return [].concat(B(p), B(Z(t)));
3880
- }, [s.prefixName, t]), g = $.useMemo(function() {
3881
- return T(T({}, s), {}, {
3882
- prefixName: f
3883
- });
3884
- }, [s, f]), O = $.useMemo(function() {
3885
- return {
3886
- getKey: function(d) {
3887
- var C = f.length, h = d[C];
3888
- return [l.keys[h], d.slice(C + 1)];
3889
- }
3890
- };
3891
- }, [f]);
3892
- if (typeof i != "function")
3893
- return re(!1, "Form.List only accepts function as children."), null;
3894
- var v = function(d, C, h) {
3895
- var b = h.source;
3896
- return b === "internal" ? !1 : d !== C;
3897
- };
3898
- return /* @__PURE__ */ $.createElement(Xe.Provider, {
3899
- value: O
3900
- }, /* @__PURE__ */ $.createElement(Ve.Provider, {
3901
- value: g
3902
- }, /* @__PURE__ */ $.createElement(Zr, {
3903
- name: [],
3904
- shouldUpdate: v,
3905
- rules: n,
3906
- validateTrigger: a,
3907
- initialValue: r,
3908
- isList: !0,
3909
- isListField: o ?? !!c
3910
- }, function(p, d) {
3911
- var C = p.value, h = C === void 0 ? [] : C, b = p.onChange, S = s.getFieldValue, w = function() {
3912
- var P = S(f || []);
3913
- return P || [];
3914
- }, V = {
3915
- add: function(P, I) {
3916
- var M = w();
3917
- I >= 0 && I <= M.length ? (l.keys = [].concat(B(l.keys.slice(0, I)), [l.id], B(l.keys.slice(I))), b([].concat(B(M.slice(0, I)), [P], B(M.slice(I))))) : (process.env.NODE_ENV !== "production" && (I < 0 || I > M.length) && re(!1, "The second parameter of the add function should be a valid positive number."), l.keys = [].concat(B(l.keys), [l.id]), b([].concat(B(M), [P]))), l.id += 1;
3918
- },
3919
- remove: function(P) {
3920
- var I = w(), M = new Set(Array.isArray(P) ? P : [P]);
3921
- M.size <= 0 || (l.keys = l.keys.filter(function(z, j) {
3922
- return !M.has(j);
3923
- }), b(I.filter(function(z, j) {
3924
- return !M.has(j);
3925
- })));
3926
- },
3927
- move: function(P, I) {
3928
- if (P !== I) {
3929
- var M = w();
3930
- P < 0 || P >= M.length || I < 0 || I >= M.length || (l.keys = br(l.keys, P, I), b(br(M, P, I)));
3931
- }
3932
- }
3933
- }, R = h || [];
3934
- return Array.isArray(R) || (R = [], process.env.NODE_ENV !== "production" && re(!1, "Current value of '".concat(f.join(" > "), "' is not an array type."))), i(R.map(function(_, P) {
3935
- var I = l.keys[P];
3936
- return I === void 0 && (l.keys[P] = l.id, I = l.keys[P], l.id += 1), {
3937
- name: P,
3938
- key: I,
3939
- isListField: !0
3940
- };
3941
- }), V, d);
3942
- })));
3943
- }
3944
- function Ua(e) {
3945
- var t = !1, r = e.length, i = [];
3946
- return e.length ? new Promise(function(n, a) {
3947
- e.forEach(function(o, s) {
3948
- o.catch(function(c) {
3949
- return t = !0, c;
3950
- }).then(function(c) {
3951
- r -= 1, i[s] = c, !(r > 0) && (t && a(i), n(i));
3952
- });
3953
- });
3954
- }) : Promise.resolve([]);
3955
- }
3956
- var Xr = "__@field_split__";
3957
- function mt(e) {
3958
- return e.map(function(t) {
3959
- return "".concat(ee(t), ":").concat(t);
3960
- }).join(Xr);
3961
- }
3962
- var xe = /* @__PURE__ */ function() {
3963
- function e() {
3964
- Ce(this, e), m(this, "kvs", /* @__PURE__ */ new Map());
3965
- }
3966
- return Fe(e, [{
3967
- key: "set",
3968
- value: function(r, i) {
3969
- this.kvs.set(mt(r), i);
3970
- }
3971
- }, {
3972
- key: "get",
3973
- value: function(r) {
3974
- return this.kvs.get(mt(r));
3975
- }
3976
- }, {
3977
- key: "update",
3978
- value: function(r, i) {
3979
- var n = this.get(r), a = i(n);
3980
- a ? this.set(r, a) : this.delete(r);
3981
- }
3982
- }, {
3983
- key: "delete",
3984
- value: function(r) {
3985
- this.kvs.delete(mt(r));
3986
- }
3987
- // Since we only use this in test, let simply realize this
3988
- }, {
3989
- key: "map",
3990
- value: function(r) {
3991
- return B(this.kvs.entries()).map(function(i) {
3992
- var n = de(i, 2), a = n[0], o = n[1], s = a.split(Xr);
3993
- return r({
3994
- key: s.map(function(c) {
3995
- var u = c.match(/^([^:]*):(.*)$/), l = de(u, 3), f = l[1], g = l[2];
3996
- return f === "number" ? Number(g) : g;
3997
- }),
3998
- value: o
3999
- });
4000
- });
4001
- }
4002
- }, {
4003
- key: "toJSON",
4004
- value: function() {
4005
- var r = {};
4006
- return this.map(function(i) {
4007
- var n = i.key, a = i.value;
4008
- return r[n.join(".")] = a, null;
4009
- }), r;
4010
- }
4011
- }]), e;
4012
- }(), Ka = ["name"], Ya = /* @__PURE__ */ Fe(function e(t) {
4013
- var r = this;
4014
- Ce(this, e), m(this, "formHooked", !1), m(this, "forceRootUpdate", void 0), m(this, "subscribable", !0), m(this, "store", {}), m(this, "fieldEntities", []), m(this, "initialValues", {}), m(this, "callbacks", {}), m(this, "validateMessages", null), m(this, "preserve", null), m(this, "lastValidatePromise", null), m(this, "getForm", function() {
4015
- return {
4016
- getFieldValue: r.getFieldValue,
4017
- getFieldsValue: r.getFieldsValue,
4018
- getFieldError: r.getFieldError,
4019
- getFieldWarning: r.getFieldWarning,
4020
- getFieldsError: r.getFieldsError,
4021
- isFieldsTouched: r.isFieldsTouched,
4022
- isFieldTouched: r.isFieldTouched,
4023
- isFieldValidating: r.isFieldValidating,
4024
- isFieldsValidating: r.isFieldsValidating,
4025
- resetFields: r.resetFields,
4026
- setFields: r.setFields,
4027
- setFieldValue: r.setFieldValue,
4028
- setFieldsValue: r.setFieldsValue,
4029
- validateFields: r.validateFields,
4030
- submit: r.submit,
4031
- _init: !0,
4032
- getInternalHooks: r.getInternalHooks
4033
- };
4034
- }), m(this, "getInternalHooks", function(i) {
4035
- return i === ye ? (r.formHooked = !0, {
4036
- dispatch: r.dispatch,
4037
- initEntityValue: r.initEntityValue,
4038
- registerField: r.registerField,
4039
- useSubscribe: r.useSubscribe,
4040
- setInitialValues: r.setInitialValues,
4041
- destroyForm: r.destroyForm,
4042
- setCallbacks: r.setCallbacks,
4043
- setValidateMessages: r.setValidateMessages,
4044
- getFields: r.getFields,
4045
- setPreserve: r.setPreserve,
4046
- getInitialValue: r.getInitialValue,
4047
- registerWatch: r.registerWatch
4048
- }) : (re(!1, "`getInternalHooks` is internal usage. Should not call directly."), null);
4049
- }), m(this, "useSubscribe", function(i) {
4050
- r.subscribable = i;
4051
- }), m(this, "prevWithoutPreserves", null), m(this, "setInitialValues", function(i, n) {
4052
- if (r.initialValues = i || {}, n) {
4053
- var a, o = He(i, r.store);
4054
- (a = r.prevWithoutPreserves) === null || a === void 0 || a.map(function(s) {
4055
- var c = s.key;
4056
- o = ve(o, c, pe(i, c));
4057
- }), r.prevWithoutPreserves = null, r.updateStore(o);
4058
- }
4059
- }), m(this, "destroyForm", function(i) {
4060
- if (i)
4061
- r.updateStore({});
4062
- else {
4063
- var n = new xe();
4064
- r.getFieldEntities(!0).forEach(function(a) {
4065
- r.isMergedPreserve(a.isPreserve()) || n.set(a.getNamePath(), !0);
4066
- }), r.prevWithoutPreserves = n;
4067
- }
4068
- }), m(this, "getInitialValue", function(i) {
4069
- var n = pe(r.initialValues, i);
4070
- return i.length ? He(n) : n;
4071
- }), m(this, "setCallbacks", function(i) {
4072
- r.callbacks = i;
4073
- }), m(this, "setValidateMessages", function(i) {
4074
- r.validateMessages = i;
4075
- }), m(this, "setPreserve", function(i) {
4076
- r.preserve = i;
4077
- }), m(this, "watchList", []), m(this, "registerWatch", function(i) {
4078
- return r.watchList.push(i), function() {
4079
- r.watchList = r.watchList.filter(function(n) {
4080
- return n !== i;
4081
- });
4082
- };
4083
- }), m(this, "notifyWatch", function() {
4084
- var i = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [];
4085
- if (r.watchList.length) {
4086
- var n = r.getFieldsValue(), a = r.getFieldsValue(!0);
4087
- r.watchList.forEach(function(o) {
4088
- o(n, a, i);
4089
- });
4090
- }
4091
- }), m(this, "timeoutId", null), m(this, "warningUnhooked", function() {
4092
- process.env.NODE_ENV !== "production" && !r.timeoutId && typeof window < "u" && (r.timeoutId = setTimeout(function() {
4093
- r.timeoutId = null, r.formHooked || re(!1, "Instance created by `useForm` is not connected to any Form element. Forget to pass `form` prop?");
4094
- }));
4095
- }), m(this, "updateStore", function(i) {
4096
- r.store = i;
4097
- }), m(this, "getFieldEntities", function() {
4098
- var i = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : !1;
4099
- return i ? r.fieldEntities.filter(function(n) {
4100
- return n.getNamePath().length;
4101
- }) : r.fieldEntities;
4102
- }), m(this, "getFieldsMap", function() {
4103
- var i = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : !1, n = new xe();
4104
- return r.getFieldEntities(i).forEach(function(a) {
4105
- var o = a.getNamePath();
4106
- n.set(o, a);
4107
- }), n;
4108
- }), m(this, "getFieldEntitiesForNamePathList", function(i) {
4109
- if (!i)
4110
- return r.getFieldEntities(!0);
4111
- var n = r.getFieldsMap(!0);
4112
- return i.map(function(a) {
4113
- var o = Z(a);
4114
- return n.get(o) || {
4115
- INVALIDATE_NAME_PATH: Z(a)
4116
- };
4117
- });
4118
- }), m(this, "getFieldsValue", function(i, n) {
4119
- r.warningUnhooked();
4120
- var a, o, s;
4121
- if (i === !0 || Array.isArray(i) ? (a = i, o = n) : i && ee(i) === "object" && (s = i.strict, o = i.filter), a === !0 && !o)
4122
- return r.store;
4123
- var c = r.getFieldEntitiesForNamePathList(Array.isArray(a) ? a : null), u = [];
4124
- return c.forEach(function(l) {
4125
- var f, g, O = "INVALIDATE_NAME_PATH" in l ? l.INVALIDATE_NAME_PATH : l.getNamePath();
4126
- if (s) {
4127
- var v, p;
4128
- if ((v = (p = l).isList) !== null && v !== void 0 && v.call(p))
4129
- return;
4130
- } else if (!a && (f = (g = l).isListField) !== null && f !== void 0 && f.call(g))
4131
- return;
4132
- if (!o)
4133
- u.push(O);
4134
- else {
4135
- var d = "getMeta" in l ? l.getMeta() : null;
4136
- o(d) && u.push(O);
4137
- }
4138
- }), yr(r.store, u.map(Z));
4139
- }), m(this, "getFieldValue", function(i) {
4140
- r.warningUnhooked();
4141
- var n = Z(i);
4142
- return pe(r.store, n);
4143
- }), m(this, "getFieldsError", function(i) {
4144
- r.warningUnhooked();
4145
- var n = r.getFieldEntitiesForNamePathList(i);
4146
- return n.map(function(a, o) {
4147
- return a && !("INVALIDATE_NAME_PATH" in a) ? {
4148
- name: a.getNamePath(),
4149
- errors: a.getErrors(),
4150
- warnings: a.getWarnings()
4151
- } : {
4152
- name: Z(i[o]),
4153
- errors: [],
4154
- warnings: []
4155
- };
4156
- });
4157
- }), m(this, "getFieldError", function(i) {
4158
- r.warningUnhooked();
4159
- var n = Z(i), a = r.getFieldsError([n])[0];
4160
- return a.errors;
4161
- }), m(this, "getFieldWarning", function(i) {
4162
- r.warningUnhooked();
4163
- var n = Z(i), a = r.getFieldsError([n])[0];
4164
- return a.warnings;
4165
- }), m(this, "isFieldsTouched", function() {
4166
- r.warningUnhooked();
4167
- for (var i = arguments.length, n = new Array(i), a = 0; a < i; a++)
4168
- n[a] = arguments[a];
4169
- var o = n[0], s = n[1], c, u = !1;
4170
- n.length === 0 ? c = null : n.length === 1 ? Array.isArray(o) ? (c = o.map(Z), u = !1) : (c = null, u = o) : (c = o.map(Z), u = s);
4171
- var l = r.getFieldEntities(!0), f = function(d) {
4172
- return d.isFieldTouched();
4173
- };
4174
- if (!c)
4175
- return u ? l.every(function(p) {
4176
- return f(p) || p.isList();
4177
- }) : l.some(f);
4178
- var g = new xe();
4179
- c.forEach(function(p) {
4180
- g.set(p, []);
4181
- }), l.forEach(function(p) {
4182
- var d = p.getNamePath();
4183
- c.forEach(function(C) {
4184
- C.every(function(h, b) {
4185
- return d[b] === h;
4186
- }) && g.update(C, function(h) {
4187
- return [].concat(B(h), [p]);
4188
- });
4189
- });
4190
- });
4191
- var O = function(d) {
4192
- return d.some(f);
4193
- }, v = g.map(function(p) {
4194
- var d = p.value;
4195
- return d;
4196
- });
4197
- return u ? v.every(O) : v.some(O);
4198
- }), m(this, "isFieldTouched", function(i) {
4199
- return r.warningUnhooked(), r.isFieldsTouched([i]);
4200
- }), m(this, "isFieldsValidating", function(i) {
4201
- r.warningUnhooked();
4202
- var n = r.getFieldEntities();
4203
- if (!i)
4204
- return n.some(function(o) {
4205
- return o.isFieldValidating();
4206
- });
4207
- var a = i.map(Z);
4208
- return n.some(function(o) {
4209
- var s = o.getNamePath();
4210
- return Re(a, s) && o.isFieldValidating();
4211
- });
4212
- }), m(this, "isFieldValidating", function(i) {
4213
- return r.warningUnhooked(), r.isFieldsValidating([i]);
4214
- }), m(this, "resetWithFieldInitialValue", function() {
4215
- var i = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, n = new xe(), a = r.getFieldEntities(!0);
4216
- a.forEach(function(c) {
4217
- var u = c.props.initialValue, l = c.getNamePath();
4218
- if (u !== void 0) {
4219
- var f = n.get(l) || /* @__PURE__ */ new Set();
4220
- f.add({
4221
- entity: c,
4222
- value: u
4223
- }), n.set(l, f);
4224
- }
4225
- });
4226
- var o = function(u) {
4227
- u.forEach(function(l) {
4228
- var f = l.props.initialValue;
4229
- if (f !== void 0) {
4230
- var g = l.getNamePath(), O = r.getInitialValue(g);
4231
- if (O !== void 0)
4232
- re(!1, "Form already set 'initialValues' with path '".concat(g.join("."), "'. Field can not overwrite it."));
4233
- else {
4234
- var v = n.get(g);
4235
- if (v && v.size > 1)
4236
- re(!1, "Multiple Field with path '".concat(g.join("."), "' set 'initialValue'. Can not decide which one to pick."));
4237
- else if (v) {
4238
- var p = r.getFieldValue(g), d = l.isListField();
4239
- !d && (!i.skipExist || p === void 0) && r.updateStore(ve(r.store, g, B(v)[0].value));
4240
- }
4241
- }
4242
- }
4243
- });
4244
- }, s;
4245
- i.entities ? s = i.entities : i.namePathList ? (s = [], i.namePathList.forEach(function(c) {
4246
- var u = n.get(c);
4247
- if (u) {
4248
- var l;
4249
- (l = s).push.apply(l, B(B(u).map(function(f) {
4250
- return f.entity;
4251
- })));
4252
- }
4253
- })) : s = a, o(s);
4254
- }), m(this, "resetFields", function(i) {
4255
- r.warningUnhooked();
4256
- var n = r.store;
4257
- if (!i) {
4258
- r.updateStore(He(r.initialValues)), r.resetWithFieldInitialValue(), r.notifyObservers(n, null, {
4259
- type: "reset"
4260
- }), r.notifyWatch();
4261
- return;
4262
- }
4263
- var a = i.map(Z);
4264
- a.forEach(function(o) {
4265
- var s = r.getInitialValue(o);
4266
- r.updateStore(ve(r.store, o, s));
4267
- }), r.resetWithFieldInitialValue({
4268
- namePathList: a
4269
- }), r.notifyObservers(n, a, {
4270
- type: "reset"
4271
- }), r.notifyWatch(a);
4272
- }), m(this, "setFields", function(i) {
4273
- r.warningUnhooked();
4274
- var n = r.store, a = [];
4275
- i.forEach(function(o) {
4276
- var s = o.name, c = De(o, Ka), u = Z(s);
4277
- a.push(u), "value" in c && r.updateStore(ve(r.store, u, c.value)), r.notifyObservers(n, [u], {
4278
- type: "setField",
4279
- data: o
4280
- });
4281
- }), r.notifyWatch(a);
4282
- }), m(this, "getFields", function() {
4283
- var i = r.getFieldEntities(!0), n = i.map(function(a) {
4284
- var o = a.getNamePath(), s = a.getMeta(), c = T(T({}, s), {}, {
4285
- name: o,
4286
- value: r.getFieldValue(o)
4287
- });
4288
- return Object.defineProperty(c, "originRCField", {
4289
- value: !0
4290
- }), c;
4291
- });
4292
- return n;
4293
- }), m(this, "initEntityValue", function(i) {
4294
- var n = i.props.initialValue;
4295
- if (n !== void 0) {
4296
- var a = i.getNamePath(), o = pe(r.store, a);
4297
- o === void 0 && r.updateStore(ve(r.store, a, n));
4298
- }
4299
- }), m(this, "isMergedPreserve", function(i) {
4300
- var n = i !== void 0 ? i : r.preserve;
4301
- return n ?? !0;
4302
- }), m(this, "registerField", function(i) {
4303
- r.fieldEntities.push(i);
4304
- var n = i.getNamePath();
4305
- if (r.notifyWatch([n]), i.props.initialValue !== void 0) {
4306
- var a = r.store;
4307
- r.resetWithFieldInitialValue({
4308
- entities: [i],
4309
- skipExist: !0
4310
- }), r.notifyObservers(a, [i.getNamePath()], {
4311
- type: "valueUpdate",
4312
- source: "internal"
4313
- });
4314
- }
4315
- return function(o, s) {
4316
- var c = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : [];
4317
- if (r.fieldEntities = r.fieldEntities.filter(function(f) {
4318
- return f !== i;
4319
- }), !r.isMergedPreserve(s) && (!o || c.length > 1)) {
4320
- var u = o ? void 0 : r.getInitialValue(n);
4321
- if (n.length && r.getFieldValue(n) !== u && r.fieldEntities.every(function(f) {
4322
- return (
4323
- // Only reset when no namePath exist
4324
- !Yr(f.getNamePath(), n)
4325
- );
4326
- })) {
4327
- var l = r.store;
4328
- r.updateStore(ve(l, n, u, !0)), r.notifyObservers(l, [n], {
4329
- type: "remove"
4330
- }), r.triggerDependenciesUpdate(l, n);
4331
- }
4332
- }
4333
- r.notifyWatch([n]);
4334
- };
4335
- }), m(this, "dispatch", function(i) {
4336
- switch (i.type) {
4337
- case "updateValue": {
4338
- var n = i.namePath, a = i.value;
4339
- r.updateValue(n, a);
4340
- break;
4341
- }
4342
- case "validateField": {
4343
- var o = i.namePath, s = i.triggerName;
4344
- r.validateFields([o], {
4345
- triggerName: s
4346
- });
4347
- break;
4348
- }
4349
- }
4350
- }), m(this, "notifyObservers", function(i, n, a) {
4351
- if (r.subscribable) {
4352
- var o = T(T({}, a), {}, {
4353
- store: r.getFieldsValue(!0)
4354
- });
4355
- r.getFieldEntities().forEach(function(s) {
4356
- var c = s.onStoreChange;
4357
- c(i, n, o);
4358
- });
4359
- } else
4360
- r.forceRootUpdate();
4361
- }), m(this, "triggerDependenciesUpdate", function(i, n) {
4362
- var a = r.getDependencyChildrenFields(n);
4363
- return a.length && r.validateFields(a), r.notifyObservers(i, a, {
4364
- type: "dependenciesUpdate",
4365
- relatedFields: [n].concat(B(a))
4366
- }), a;
4367
- }), m(this, "updateValue", function(i, n) {
4368
- var a = Z(i), o = r.store;
4369
- r.updateStore(ve(r.store, a, n)), r.notifyObservers(o, [a], {
4370
- type: "valueUpdate",
4371
- source: "internal"
4372
- }), r.notifyWatch([a]);
4373
- var s = r.triggerDependenciesUpdate(o, a), c = r.callbacks.onValuesChange;
4374
- if (c) {
4375
- var u = yr(r.store, [a]);
4376
- c(u, r.getFieldsValue());
4377
- }
4378
- r.triggerOnFieldsChange([a].concat(B(s)));
4379
- }), m(this, "setFieldsValue", function(i) {
4380
- r.warningUnhooked();
4381
- var n = r.store;
4382
- if (i) {
4383
- var a = He(r.store, i);
4384
- r.updateStore(a);
4385
- }
4386
- r.notifyObservers(n, null, {
4387
- type: "valueUpdate",
4388
- source: "external"
4389
- }), r.notifyWatch();
4390
- }), m(this, "setFieldValue", function(i, n) {
4391
- r.setFields([{
4392
- name: i,
4393
- value: n
4394
- }]);
4395
- }), m(this, "getDependencyChildrenFields", function(i) {
4396
- var n = /* @__PURE__ */ new Set(), a = [], o = new xe();
4397
- r.getFieldEntities().forEach(function(c) {
4398
- var u = c.props.dependencies;
4399
- (u || []).forEach(function(l) {
4400
- var f = Z(l);
4401
- o.update(f, function() {
4402
- var g = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : /* @__PURE__ */ new Set();
4403
- return g.add(c), g;
4404
- });
4405
- });
4406
- });
4407
- var s = function c(u) {
4408
- var l = o.get(u) || /* @__PURE__ */ new Set();
4409
- l.forEach(function(f) {
4410
- if (!n.has(f)) {
4411
- n.add(f);
4412
- var g = f.getNamePath();
4413
- f.isFieldDirty() && g.length && (a.push(g), c(g));
4414
- }
4415
- });
4416
- };
4417
- return s(i), a;
4418
- }), m(this, "triggerOnFieldsChange", function(i, n) {
4419
- var a = r.callbacks.onFieldsChange;
4420
- if (a) {
4421
- var o = r.getFields();
4422
- if (n) {
4423
- var s = new xe();
4424
- n.forEach(function(u) {
4425
- var l = u.name, f = u.errors;
4426
- s.set(l, f);
4427
- }), o.forEach(function(u) {
4428
- u.errors = s.get(u.name) || u.errors;
4429
- });
4430
- }
4431
- var c = o.filter(function(u) {
4432
- var l = u.name;
4433
- return Re(i, l);
4434
- });
4435
- c.length && a(c, o);
4436
- }
4437
- }), m(this, "validateFields", function(i, n) {
4438
- r.warningUnhooked();
4439
- var a, o;
4440
- Array.isArray(i) || typeof i == "string" || typeof n == "string" ? (a = i, o = n) : o = i;
4441
- var s = !!a, c = s ? a.map(Z) : [], u = [], l = String(Date.now()), f = /* @__PURE__ */ new Set(), g = o || {}, O = g.recursive, v = g.dirty;
4442
- r.getFieldEntities(!0).forEach(function(h) {
4443
- if (s || c.push(h.getNamePath()), !(!h.props.rules || !h.props.rules.length) && !(v && !h.isFieldDirty())) {
4444
- var b = h.getNamePath();
4445
- if (f.add(b.join(l)), !s || Re(c, b, O)) {
4446
- var S = h.validateRules(T({
4447
- validateMessages: T(T({}, Kr), r.validateMessages)
4448
- }, o));
4449
- u.push(S.then(function() {
4450
- return {
4451
- name: b,
4452
- errors: [],
4453
- warnings: []
4454
- };
4455
- }).catch(function(w) {
4456
- var V, R = [], _ = [];
4457
- return (V = w.forEach) === null || V === void 0 || V.call(w, function(P) {
4458
- var I = P.rule.warningOnly, M = P.errors;
4459
- I ? _.push.apply(_, B(M)) : R.push.apply(R, B(M));
4460
- }), R.length ? Promise.reject({
4461
- name: b,
4462
- errors: R,
4463
- warnings: _
4464
- }) : {
4465
- name: b,
4466
- errors: R,
4467
- warnings: _
4468
- };
4469
- }));
4470
- }
4471
- }
4472
- });
4473
- var p = Ua(u);
4474
- r.lastValidatePromise = p, p.catch(function(h) {
4475
- return h;
4476
- }).then(function(h) {
4477
- var b = h.map(function(S) {
4478
- var w = S.name;
4479
- return w;
4480
- });
4481
- r.notifyObservers(r.store, b, {
4482
- type: "validateFinish"
4483
- }), r.triggerOnFieldsChange(b, h);
4484
- });
4485
- var d = p.then(function() {
4486
- return r.lastValidatePromise === p ? Promise.resolve(r.getFieldsValue(c)) : Promise.reject([]);
4487
- }).catch(function(h) {
4488
- var b = h.filter(function(S) {
4489
- return S && S.errors.length;
4490
- });
4491
- return Promise.reject({
4492
- values: r.getFieldsValue(c),
4493
- errorFields: b,
4494
- outOfDate: r.lastValidatePromise !== p
4495
- });
4496
- });
4497
- d.catch(function(h) {
4498
- return h;
4499
- });
4500
- var C = c.filter(function(h) {
4501
- return f.has(h.join(l));
4502
- });
4503
- return r.triggerOnFieldsChange(C), d;
4504
- }), m(this, "submit", function() {
4505
- r.warningUnhooked(), r.validateFields().then(function(i) {
4506
- var n = r.callbacks.onFinish;
4507
- if (n)
4508
- try {
4509
- n(i);
4510
- } catch (a) {
4511
- console.error(a);
4512
- }
4513
- }).catch(function(i) {
4514
- var n = r.callbacks.onFinishFailed;
4515
- n && n(i);
4516
- });
4517
- }), this.forceRootUpdate = t;
4518
- });
4519
- function kr(e) {
4520
- var t = $.useRef(), r = $.useState({}), i = de(r, 2), n = i[1];
4521
- if (!t.current)
4522
- if (e)
4523
- t.current = e;
4524
- else {
4525
- var a = function() {
4526
- n({});
4527
- }, o = new Ya(a);
4528
- t.current = o.getForm();
4529
- }
4530
- return [t.current];
4531
- }
4532
- var Pt = /* @__PURE__ */ $.createContext({
4533
- triggerFormChange: function() {
4534
- },
4535
- triggerFormFinish: function() {
4536
- },
4537
- registerForm: function() {
4538
- },
4539
- unregisterForm: function() {
4540
- }
4541
- }), Za = function(t) {
4542
- var r = t.validateMessages, i = t.onFormChange, n = t.onFormFinish, a = t.children, o = $.useContext(Pt), s = $.useRef({});
4543
- return /* @__PURE__ */ $.createElement(Pt.Provider, {
4544
- value: T(T({}, o), {}, {
4545
- validateMessages: T(T({}, o.validateMessages), r),
4546
- // =========================================================
4547
- // = Global Form Control =
4548
- // =========================================================
4549
- triggerFormChange: function(u, l) {
4550
- i && i(u, {
4551
- changedFields: l,
4552
- forms: s.current
4553
- }), o.triggerFormChange(u, l);
4554
- },
4555
- triggerFormFinish: function(u, l) {
4556
- n && n(u, {
4557
- values: l,
4558
- forms: s.current
4559
- }), o.triggerFormFinish(u, l);
4560
- },
4561
- registerForm: function(u, l) {
4562
- u && (s.current = T(T({}, s.current), {}, m({}, u, l))), o.registerForm(u, l);
4563
- },
4564
- unregisterForm: function(u) {
4565
- var l = T({}, s.current);
4566
- delete l[u], s.current = l, o.unregisterForm(u);
4567
- }
4568
- })
4569
- }, a);
4570
- }, Xa = ["name", "initialValues", "fields", "form", "preserve", "children", "component", "validateMessages", "validateTrigger", "onValuesChange", "onFieldsChange", "onFinish", "onFinishFailed", "clearOnDestroy"], ka = function(t, r) {
4571
- var i = t.name, n = t.initialValues, a = t.fields, o = t.form, s = t.preserve, c = t.children, u = t.component, l = u === void 0 ? "form" : u, f = t.validateMessages, g = t.validateTrigger, O = g === void 0 ? "onChange" : g, v = t.onValuesChange, p = t.onFieldsChange, d = t.onFinish, C = t.onFinishFailed, h = t.clearOnDestroy, b = De(t, Xa), S = $.useRef(null), w = $.useContext(Pt), V = kr(o), R = de(V, 1), _ = R[0], P = _.getInternalHooks(ye), I = P.useSubscribe, M = P.setInitialValues, z = P.setCallbacks, j = P.setValidateMessages, A = P.setPreserve, K = P.destroyForm;
4572
- $.useImperativeHandle(r, function() {
4573
- return T(T({}, _), {}, {
4574
- nativeElement: S.current
4575
- });
4576
- }), $.useEffect(function() {
4577
- return w.registerForm(i, _), function() {
4578
- w.unregisterForm(i);
4579
- };
4580
- }, [w, _, i]), j(T(T({}, w.validateMessages), f)), z({
4581
- onValuesChange: v,
4582
- onFieldsChange: function(q) {
4583
- if (w.triggerFormChange(i, q), p) {
4584
- for (var te = arguments.length, k = new Array(te > 1 ? te - 1 : 0), ae = 1; ae < te; ae++)
4585
- k[ae - 1] = arguments[ae];
4586
- p.apply(void 0, [q].concat(k));
4587
- }
4588
- },
4589
- onFinish: function(q) {
4590
- w.triggerFormFinish(i, q), d && d(q);
4591
- },
4592
- onFinishFailed: C
4593
- }), A(s);
4594
- var F = $.useRef(null);
4595
- M(n, !F.current), F.current || (F.current = !0), $.useEffect(
4596
- function() {
4597
- return function() {
4598
- return K(h);
4599
- };
4600
- },
4601
- // eslint-disable-next-line react-hooks/exhaustive-deps
4602
- []
4603
- );
4604
- var y, E = typeof c == "function";
4605
- if (E) {
4606
- var x = _.getFieldsValue(!0);
4607
- y = c(x, _);
4608
- } else
4609
- y = c;
4610
- I(!E);
4611
- var H = $.useRef();
4612
- $.useEffect(function() {
4613
- za(H.current || [], a || []) || _.setFields(a || []), H.current = a;
4614
- }, [a, _]);
4615
- var N = $.useMemo(function() {
4616
- return T(T({}, _), {}, {
4617
- validateTrigger: O
4618
- });
4619
- }, [_, O]), U = /* @__PURE__ */ $.createElement(Xe.Provider, {
4620
- value: null
4621
- }, /* @__PURE__ */ $.createElement(Ve.Provider, {
4622
- value: N
4623
- }, y));
4624
- return l === !1 ? U : /* @__PURE__ */ $.createElement(l, $e({}, b, {
4625
- ref: S,
4626
- onSubmit: function(q) {
4627
- q.preventDefault(), q.stopPropagation(), _.submit();
4628
- },
4629
- onReset: function(q) {
4630
- var te;
4631
- q.preventDefault(), _.resetFields(), (te = b.onReset) === null || te === void 0 || te.call(b, q);
4632
- }
4633
- }), U);
4634
- };
4635
- function Cr(e) {
4636
- try {
4637
- return JSON.stringify(e);
4638
- } catch {
4639
- return Math.random();
4640
- }
4641
- }
4642
- var Ja = process.env.NODE_ENV !== "production" ? function(e) {
4643
- var t = e.join("__RC_FIELD_FORM_SPLIT__"), r = ce(t);
4644
- re(r.current === t, "`useWatch` is not support dynamic `namePath`. Please provide static instead.");
4645
- } : function() {
4646
- };
4647
- function Qa() {
4648
- for (var e = arguments.length, t = new Array(e), r = 0; r < e; r++)
4649
- t[r] = arguments[r];
4650
- var i = t[0], n = t[1], a = n === void 0 ? {} : n, o = sa(a) ? {
4651
- form: a
4652
- } : a, s = o.form, c = Ke(), u = de(c, 2), l = u[0], f = u[1], g = be(function() {
4653
- return Cr(l);
4654
- }, [l]), O = ce(g);
4655
- O.current = g;
4656
- var v = Oe(Ve), p = s || v, d = p && p._init;
4657
- process.env.NODE_ENV !== "production" && re(t.length === 2 ? s ? d : !0 : d, "useWatch requires a form instance since it can not auto detect from context.");
4658
- var C = Z(i), h = ce(C);
4659
- return h.current = C, Ja(C), Me(
4660
- function() {
4661
- if (d) {
4662
- var b = p.getFieldsValue, S = p.getInternalHooks, w = S(ye), V = w.registerWatch, R = function(M, z) {
4663
- var j = o.preserve ? z : M;
4664
- return typeof i == "function" ? i(j) : pe(j, h.current);
4665
- }, _ = V(function(I, M) {
4666
- var z = R(I, M), j = Cr(z);
4667
- O.current !== j && (O.current = j, f(z));
4668
- }), P = R(b(), b(!0));
4669
- return l !== P && f(P), _;
4670
- }
4671
- },
4672
- // We do not need re-register since namePath content is the same
4673
- // eslint-disable-next-line react-hooks/exhaustive-deps
4674
- [d]
4675
- ), l;
4676
- }
4677
- var eo = /* @__PURE__ */ $.forwardRef(ka), qe = eo;
4678
- qe.FormProvider = Za;
4679
- qe.Field = Zr;
4680
- qe.List = Ga;
4681
- qe.useForm = kr;
4682
- qe.useWatch = Qa;
4683
- const Rt = /* @__PURE__ */ $.createContext({});
4684
- process.env.NODE_ENV !== "production" && (Rt.displayName = "FormItemInputContext");
4685
- const to = (e) => {
4686
- let {
4687
- children: t,
4688
- status: r,
4689
- override: i
4690
- } = e;
4691
- const n = Oe(Rt), a = be(() => {
4692
- const o = Object.assign({}, n);
4693
- return i && delete o.isFormItemInput, r && (delete o.status, delete o.hasFeedback, delete o.feedbackIcon), o;
4694
- }, [r, i, n]);
4695
- return /* @__PURE__ */ $.createElement(Rt.Provider, {
4696
- value: a
4697
- }, t);
4698
- }, ho = (e) => {
4699
- const {
4700
- space: t,
4701
- form: r,
4702
- children: i
4703
- } = e;
4704
- if (i == null)
4705
- return null;
4706
- let n = i;
4707
- return r && (n = /* @__PURE__ */ L.createElement(to, {
4708
- override: !0,
4709
- status: !0
4710
- }, n)), t && (n = /* @__PURE__ */ L.createElement(Xn, null, n)), n;
4711
- };
4712
- function ro(e) {
4713
- return (t) => /* @__PURE__ */ $.createElement(yn, {
4714
- theme: {
4715
- token: {
4716
- motion: !1,
4717
- zIndexPopupBase: 0
4718
- }
4719
- }
4720
- }, /* @__PURE__ */ $.createElement(e, Object.assign({}, t)));
4721
- }
4722
- const mo = (e, t, r, i) => ro((a) => {
4723
- const {
4724
- prefixCls: o,
4725
- style: s
4726
- } = a, c = $.useRef(null), [u, l] = $.useState(0), [f, g] = $.useState(0), [O, v] = xr(!1, {
4727
- value: a.open
4728
- }), {
4729
- getPrefixCls: p
4730
- } = $.useContext(_e), d = p(t, o);
4731
- $.useEffect(() => {
4732
- if (v(!0), typeof ResizeObserver < "u") {
4733
- const b = new ResizeObserver((w) => {
4734
- const V = w[0].target;
4735
- l(V.offsetHeight + 8), g(V.offsetWidth);
4736
- }), S = setInterval(() => {
4737
- var w;
4738
- const V = r ? `.${r(d)}` : `.${d}-dropdown`, R = (w = c.current) === null || w === void 0 ? void 0 : w.querySelector(V);
4739
- R && (clearInterval(S), b.observe(R));
4740
- }, 10);
4741
- return () => {
4742
- clearInterval(S), b.disconnect();
4743
- };
4744
- }
4745
- }, []);
4746
- let C = Object.assign(Object.assign({}, a), {
4747
- style: Object.assign(Object.assign({}, s), {
4748
- margin: 0
4749
- }),
4750
- open: O,
4751
- visible: O,
4752
- getPopupContainer: () => c.current
4753
- });
4754
- i && (C = i(C));
4755
- const h = {
4756
- paddingBottom: u,
4757
- position: "relative",
4758
- minWidth: f
4759
- };
4760
- return /* @__PURE__ */ $.createElement("div", {
4761
- ref: c,
4762
- style: h
4763
- }, /* @__PURE__ */ $.createElement(e, Object.assign({}, C)));
4764
- });
4765
- export {
4766
- zt as B,
4767
- ho as C,
4768
- xn as a,
4769
- Mn as b,
4770
- fo as c,
4771
- Cn as d,
4772
- $r as e,
4773
- Yn as f,
4774
- mo as g,
4775
- uo as h,
4776
- go as i,
4777
- Zn as j,
4778
- Hn as r,
4779
- co as u,
4780
- ro as w,
4781
- Rr as z
4782
- };