@unicom-cloud/ui 0.8.57 → 0.8.59

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 (260) hide show
  1. package/Affix.js +15 -15
  2. package/Alert.js +5 -5
  3. package/Anchor.js +1 -1
  4. package/AutoComplete.js +28 -28
  5. package/Avatar.js +11 -11
  6. package/BackTop.js +28 -28
  7. package/Badge.js +10 -10
  8. package/Breadcrumb.js +6 -6
  9. package/Button.js +11 -10
  10. package/Calendar.js +8 -8
  11. package/Card.js +3 -3
  12. package/Carousel.js +7 -7
  13. package/Cascader.js +1 -1
  14. package/Checkbox.js +1 -1
  15. package/Collapse.js +1 -1
  16. package/ColorPicker.js +582 -11
  17. package/Comment.js +7 -7
  18. package/ConfigProvider.js +2 -2
  19. package/Copy.js +6 -6
  20. package/DatePicker.js +14 -12
  21. package/Descriptions.js +3 -3
  22. package/Divider.js +3 -3
  23. package/Draggable.js +12 -12
  24. package/Drawer.js +1 -1
  25. package/Dropdown.js +5 -5
  26. package/Empty.js +3 -3
  27. package/Form.js +1410 -10
  28. package/Grid.js +14 -14
  29. package/Icon.js +2 -2
  30. package/IconHover.js +2 -2
  31. package/Image.js +1 -1
  32. package/Input.js +2 -2
  33. package/InputNumber.js +8 -8
  34. package/InputTag.js +1 -1
  35. package/Layout.js +8 -8
  36. package/Link.js +13 -13
  37. package/List.js +21 -21
  38. package/Mentions.js +30 -30
  39. package/Menu.js +1 -1
  40. package/Message.js +3 -3
  41. package/Modal.js +1 -1
  42. package/Notice.js +3 -3
  43. package/Notification.js +4 -4
  44. package/OverflowEllipsis.js +9 -9
  45. package/PageHeader.js +10 -10
  46. package/Pagination.js +1 -1
  47. package/Picker.js +1 -1
  48. package/Popconfirm.js +5 -5
  49. package/Popover.js +7 -7
  50. package/Portal.js +1 -1
  51. package/Progress.js +15 -15
  52. package/Radio.js +2 -2
  53. package/Rate.js +10 -10
  54. package/ResizeBox.js +10 -11
  55. package/Result.js +11 -11
  56. package/Select.js +1 -1
  57. package/SelectView.js +40 -41
  58. package/Skeleton.js +4 -4
  59. package/Slider.js +9 -9
  60. package/Space.js +12 -12
  61. package/SpeechSynthesis.js +1 -1
  62. package/Spin.js +11 -11
  63. package/Statistic.js +43 -43
  64. package/Steps.js +5 -5
  65. package/Switch.js +15 -16
  66. package/Table.js +17 -17
  67. package/Tabs.js +1 -1
  68. package/Tag.js +5 -5
  69. package/TimePicker.js +38 -38
  70. package/Timeline.js +1 -1
  71. package/Tooltip.js +9 -9
  72. package/Transfer.js +26 -26
  73. package/Tree.js +1 -1
  74. package/TreeSelect.js +1 -1
  75. package/Trigger.js +11 -11
  76. package/Typography.js +1 -1
  77. package/Upload.js +4 -1
  78. package/VerificationCode.js +1 -1
  79. package/Version.js +1 -1
  80. package/VirtualList.js +1 -1
  81. package/Watermark.js +1 -1
  82. package/chunk/{m_kOQCiU.js → -LZOUh53.js} +1 -1
  83. package/chunk/{CXNW5Y2a.js → -jdfq71f.js} +1 -1
  84. package/chunk/{CkAOsst1.js → 4-gvEY5y.js} +30 -30
  85. package/chunk/{DQXq1QT0.js → B0GOLsj_.js} +1 -1
  86. package/chunk/{BMvZCjSU.js → B16KHtX-.js} +16 -16
  87. package/chunk/{CggcswbO.js → B2vORJQ8.js} +19 -15
  88. package/chunk/{BCk8e9fj.js → B7Zsp3gO.js} +1 -1
  89. package/chunk/B8QV6E2b.js +34 -0
  90. package/chunk/{BeM2hfks.js → BBVjSFnw.js} +27 -23
  91. package/chunk/{1mEO29GP.js → BDjXkzNj.js} +1 -1
  92. package/chunk/{BuEC_zcc.js → BEDYCG-I.js} +31 -31
  93. package/chunk/{B45v5S9k.js → BHn4xgbv.js} +1 -1
  94. package/chunk/{CF3Telny.js → BJ_7JTqC.js} +3 -3
  95. package/chunk/{BM6dpkeM.js → BLSiP_gg.js} +1 -1
  96. package/chunk/{9Gh1afjL.js → BMJfSSLX.js} +1 -1
  97. package/chunk/{DBJ8d0o0.js → BNHrEI0Y.js} +31 -31
  98. package/chunk/{BP7xX86Q.js → BPZ-6HKJ.js} +131 -134
  99. package/chunk/{DxNRWF67.js → BVLwPZis.js} +11 -11
  100. package/chunk/{BpwDupra.js → BYhtrDV3.js} +9 -9
  101. package/chunk/{D6mVoX-C.js → B_nfMl0e.js} +1 -1
  102. package/chunk/{BWx1cVT_.js → BcS17Pzy.js} +1 -1
  103. package/chunk/Bdh4XVuf.js +1487 -0
  104. package/chunk/{BkHxm4sv.js → BdiEwtQO.js} +1 -1
  105. package/chunk/{DDda6s72.js → BjSHZA0m.js} +6 -6
  106. package/chunk/{C7Okdv4u.js → Bpug_KxP.js} +1 -1
  107. package/chunk/BzPkh4Zv.js +11 -0
  108. package/chunk/{CwXmtKib.js → C1D7T29r.js} +35 -35
  109. package/chunk/{DYZzQ2uT.js → C1u_ckwU.js} +1 -1
  110. package/chunk/C1xMmQIZ.js +468 -0
  111. package/chunk/C2lIz2F9.js +60 -0
  112. package/chunk/{Be7oeWU8.js → C43Hv2Bl.js} +1 -1
  113. package/chunk/{CR4u270n.js → C5AQWbC4.js} +79 -79
  114. package/chunk/{fqgc8r6C.js → C9vsih_D.js} +1 -1
  115. package/chunk/CANaGbGR.js +154 -0
  116. package/chunk/{BA02BFUV.js → CAfR2wLq.js} +1 -1
  117. package/chunk/{CcX2pBUh.js → CAfecMDF.js} +1 -1
  118. package/chunk/{BHK9zpXn.js → CKp4rZnD.js} +1 -1
  119. package/chunk/CTxjmYmx.js +19 -0
  120. package/chunk/{BqxwlITu.js → CV2Aqv9q.js} +1 -1
  121. package/chunk/{bsawGxt8.js → CYdarMv9.js} +1 -1
  122. package/chunk/{DafaH1Qt.js → C_S5Mdvd.js} +43 -44
  123. package/chunk/{DkIjpuBZ.js → Cbd50gx8.js} +11 -11
  124. package/chunk/{D5p8q9Pa.js → CbiWdbr_.js} +12 -12
  125. package/chunk/{cUuQh7L_.js → CmB-TL7C.js} +1 -1
  126. package/chunk/{BbYzi8M0.js → CuOl4X0X.js} +4 -4
  127. package/chunk/{BHLTzWzi.js → D-ER56Sf.js} +1 -1
  128. package/chunk/{BK1FKNAX.js → D-aYnb6u.js} +1 -1
  129. package/chunk/{DalIRWr7.js → D2HkyI6A.js} +9 -9
  130. package/chunk/D3NFxdmG.js +518 -0
  131. package/chunk/{C2fspJbE.js → D3xQFJcO.js} +1 -1
  132. package/chunk/{Lk60-jkf.js → DApXtulb.js} +4 -0
  133. package/chunk/{sl8s35SK.js → DJcEys80.js} +1 -1
  134. package/chunk/{B1S1OEw6.js → DLIm6rRJ.js} +1 -1
  135. package/chunk/{C95ipQ6b.js → DOWEHtqM.js} +1 -1
  136. package/chunk/{aM2ePYrq.js → DSGRHf-1.js} +132 -132
  137. package/chunk/{D9TqtOhq.js → DT37l12z.js} +1 -1
  138. package/chunk/{B6fn5y_s.js → DW-B7npC.js} +1 -1
  139. package/chunk/D_-UD4vO.js +119 -0
  140. package/chunk/{Dtnux4qL.js → D_MTFBb0.js} +1 -1
  141. package/chunk/{WkB0MERB.js → DhBo0pPJ.js} +27 -27
  142. package/chunk/DmUhn9ib.js +961 -0
  143. package/chunk/{Bny52uiG.js → DpfUGhi4.js} +10 -10
  144. package/chunk/{DhLbnw3R.js → Dx_5J4fO.js} +1 -1
  145. package/chunk/{B9PsJar0.js → Dy487FZ1.js} +1 -1
  146. package/chunk/{D6RTBH4C.js → IooeSKJJ.js} +10 -10
  147. package/chunk/Kbr6FzOG.js +745 -0
  148. package/chunk/{CwjaGytU.js → RMBPs_Ry.js} +32 -32
  149. package/chunk/Uz-rNulO.js +98 -0
  150. package/chunk/V6euPXVB.js +1025 -0
  151. package/chunk/{Bv8ZRDFt.js → YIlBPVAs.js} +14 -14
  152. package/chunk/{DPvnQJ-H.js → cDZI_t6o.js} +1 -1
  153. package/chunk/{C-w9pFY-.js → cZiP8FvM.js} +3 -3
  154. package/chunk/{DJmWXheU.js → eK7lxdak.js} +8 -8
  155. package/chunk/{Dg2DmtzA.js → gIbzjQ-X.js} +5 -6
  156. package/chunk/{CPl52AZh.js → sScV-J56.js} +1 -1
  157. package/chunk/{BbI3gqVr.js → wI2I1qb0.js} +1 -1
  158. package/hooks/index.js +32 -32
  159. package/hooks/use-verification-code.js +23 -22
  160. package/hooks/use-watermark.js +2 -1
  161. package/hooks/useComputedState.js +2 -1
  162. package/hooks/useCreate.js +2 -1
  163. package/hooks/useForceUpdate.js +2 -1
  164. package/hooks/useId.js +2 -1
  165. package/hooks/useInView.js +5 -4
  166. package/hooks/useIntersectionObserver.js +11 -11
  167. package/hooks/useIsFirstRender.js +2 -1
  168. package/hooks/useIsomorphicLayoutEffect.js +2 -1
  169. package/hooks/useKeyboardEvent.js +3 -2
  170. package/hooks/useMedia.js +2 -1
  171. package/hooks/useMergeProps.js +2 -1
  172. package/hooks/useMergeValue.js +4 -3
  173. package/hooks/useOverflowHidden.js +2 -1
  174. package/hooks/useOverrideRef.js +2 -1
  175. package/hooks/usePersistCallback.js +2 -1
  176. package/hooks/usePrevious.js +2 -1
  177. package/hooks/useRefs.js +2 -1
  178. package/hooks/useResizeObserver.js +2 -1
  179. package/hooks/useStateCallback.js +2 -1
  180. package/hooks/useStateWithPromise.js +2 -1
  181. package/hooks/useUpdateEffect.js +2 -1
  182. package/hooks/useWatch.js +3 -2
  183. package/hooks/useWindowSize.js +2 -1
  184. package/icons.js +35 -35
  185. package/index.js +484 -376
  186. package/locale/en-US.js +3 -11
  187. package/locale/tr-TR.js +3 -11
  188. package/package.json +1 -1
  189. package/style.css +1 -1
  190. package/types/anchor/Anchor.d.ts +1 -1
  191. package/types/button/index.d.ts +3 -2
  192. package/types/color-picker/hooks/useColorPicker.d.ts +1 -1
  193. package/types/color-picker/hooks/useControlBlock.d.ts +1 -1
  194. package/types/config-provider/interface.d.ts +1 -0
  195. package/types/date-picker/PickerRange.d.ts +1 -1
  196. package/types/hooks/use-verification-code/index.d.ts +2 -1
  197. package/types/hooks/use-watermark/index.d.ts +2 -1
  198. package/types/hooks/useComputedState.d.ts +2 -2
  199. package/types/hooks/useCreate.d.ts +2 -1
  200. package/types/hooks/useForceUpdate.d.ts +2 -1
  201. package/types/hooks/useId.d.ts +2 -1
  202. package/types/hooks/useInView.d.ts +1 -1
  203. package/types/hooks/useIntersectionObserver.d.ts +1 -1
  204. package/types/hooks/useIsFirstRender.d.ts +2 -1
  205. package/types/hooks/useIsomorphicLayoutEffect.d.ts +1 -1
  206. package/types/hooks/useKeyboardEvent.d.ts +2 -2
  207. package/types/hooks/useMedia.d.ts +1 -1
  208. package/types/hooks/useMergeProps.d.ts +2 -1
  209. package/types/hooks/useMergeValue.d.ts +2 -1
  210. package/types/hooks/useOverflowHidden.d.ts +2 -2
  211. package/types/hooks/useOverrideRef.d.ts +2 -1
  212. package/types/hooks/usePersistCallback.d.ts +2 -1
  213. package/types/hooks/usePrevious.d.ts +2 -1
  214. package/types/hooks/useRefs.d.ts +2 -1
  215. package/types/hooks/useResizeObserver.d.ts +2 -1
  216. package/types/hooks/useStateCallback.d.ts +1 -1
  217. package/types/hooks/useStateWithPromise.d.ts +1 -1
  218. package/types/hooks/useUpdateEffect.d.ts +2 -1
  219. package/types/hooks/useWatch.d.ts +2 -1
  220. package/types/hooks/useWindowSize.d.ts +1 -1
  221. package/types/image/interface.d.ts +1 -1
  222. package/types/index.d.ts +13 -22
  223. package/types/table/interface.d.ts +3 -1
  224. package/types/upload/Upload.d.ts +2 -1
  225. package/types/upload/index.d.ts +3 -1
  226. package/types/upload/request_.d.ts +3 -0
  227. package/types/utils/caseName.d.ts +2 -0
  228. package/types/utils/fileToURL.d.ts +2 -0
  229. package/types/utils/fillNBSP.d.ts +1 -1
  230. package/types/utils/index.d.ts +37 -0
  231. package/types/utils/is.d.ts +2 -2
  232. package/types/utils/lodash.d.ts +4 -0
  233. package/types/utils/scrollIntoView.d.ts +2 -1
  234. package/types/version/index.d.ts +1 -1
  235. package/utils/CSSTransition.js +1 -1
  236. package/utils/caseName.js +20 -0
  237. package/utils/className.js +1 -1
  238. package/utils/contextHolder.js +1 -1
  239. package/utils/fileToURL.js +4 -0
  240. package/utils/index.js +219 -0
  241. package/utils/is.js +95 -93
  242. package/utils/keyCode.js +10 -46
  243. package/utils/lodash.js +8 -0
  244. package/utils/mergedToString.js +11 -10
  245. package/utils/reactDOM.js +1 -1
  246. package/utils/saveAs.js +1 -1
  247. package/utils/scrollIntoView.js +8 -7
  248. package/chunk/5pZ3ayqs.js +0 -29
  249. package/chunk/Bl-ODC57.js +0 -945
  250. package/chunk/BlKc_pDZ.js +0 -678
  251. package/chunk/CiEln_Q1.js +0 -517
  252. package/chunk/CiZVOdJ3.js +0 -122
  253. package/chunk/DMWMrXg1.js +0 -964
  254. package/chunk/DUxWiN2U.js +0 -1465
  255. package/chunk/Dbk4DVhB.js +0 -855
  256. package/chunk/Do1aMgY3.js +0 -12
  257. package/chunk/HlP8inLK.js +0 -1796
  258. package/chunk/V_IcWDFx.js +0 -49
  259. /package/types/utils/{mergeProp.d.ts → mergeProps.d.ts} +0 -0
  260. /package/utils/{mergeProp.js → mergeProps.js} +0 -0
package/chunk/HlP8inLK.js DELETED
@@ -1,1796 +0,0 @@
1
- var lt = Object.defineProperty;
2
- var ot = (r, e, t) => e in r ? lt(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
3
- var u = (r, e, t) => ot(r, typeof e != "symbol" ? e + "" : e, t);
4
- import { jsx as p, jsxs as Q, Fragment as qe } from "react/jsx-runtime";
5
- import { y as at } from "./CiZVOdJ3.js";
6
- import R from "lodash/isPlainObject";
7
- import Oe from "lodash/merge";
8
- import K, { createContext as pe, useRef as L, forwardRef as we, useContext as U, useEffect as he, useImperativeHandle as ht, Component as ut, isValidElement as Se, useState as me, useMemo as ke, createElement as xe, cloneElement as Re, useCallback as ne } from "react";
9
- import { b as De, C as ct } from "./DUxWiN2U.js";
10
- import dt from "../hooks/useCreate.js";
11
- import gt from "../hooks/useMergeProps.js";
12
- import { y as B } from "./Do1aMgY3.js";
13
- import Ue from "../utils/omit.js";
14
- import { NOOP as y } from "../utils/constant.js";
15
- import M from "lodash/get";
16
- import ze from "lodash/has";
17
- import S from "lodash/isArray";
18
- import _ from "lodash/isFunction";
19
- import mt from "lodash/omit";
20
- import Ge from "lodash/setWith";
21
- import { isExist as Ne } from "../utils/is.js";
22
- import A from "lodash/isObject";
23
- import Ae from "lodash/isEqual";
24
- import { G as Y, V as Be, z as ft } from "./BeM2hfks.js";
25
- import fe from "lodash/isString";
26
- import { t as pt } from "./V_IcWDFx.js";
27
- import He from "lodash/isBoolean";
28
- import Ft from "lodash/isNumber";
29
- import Je from "lodash/cloneDeepWith";
30
- import Ze from "lodash/set";
31
- import { b as bt, c as vt, a as yt, e as Vt } from "./B45v5S9k.js";
32
- import je from "lodash/isEqualWith";
33
- import St from "lodash/isNil";
34
- import oe from "../utils/warning.js";
35
- import le from "lodash/isUndefined";
36
- import Ye from "../Grid.js";
37
- import { P as jt } from "./BP7xX86Q.js";
38
- import { I as Et } from "./Be7oeWU8.js";
39
- import wt from "../Tooltip.js";
40
- import Ct from "../hooks/useForceUpdate.js";
41
- const It = (r, e) => {
42
- const t = {};
43
- return Object.keys(r).forEach((s) => {
44
- const i = r[s], l = e && e[s];
45
- t[s] = A(i) ? {
46
- ...i,
47
- ...l
48
- } : l || i;
49
- }), t;
50
- }, Mt = (r, e) => {
51
- const t = e.split(".");
52
- let s = r;
53
- for (let i = 0; i < t.length; i++)
54
- if (s = s && s[t[i]], s === void 0)
55
- return s;
56
- return s;
57
- };
58
- var $t = Object.defineProperty, Tt = (r, e, t) => e in r ? $t(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, G = (r, e, t) => Tt(r, typeof e != "symbol" ? e + "" : e, t);
59
- class X {
60
- constructor(e, t) {
61
- G(this, "obj"), G(this, "message"), G(this, "type"), G(this, "error"), G(this, "_not"), G(this, "validateMessages"), G(this, "field"), G(this, "getValidateMsg", (s, i = {}) => {
62
- const l = {
63
- ...i,
64
- value: this.obj,
65
- field: this.field,
66
- type: this.type
67
- }, n = Mt(this.validateMessages, s);
68
- return _(n) ? n(l) : fe(n) ? n.replace(/\#\{.+?\}/g, (o) => {
69
- const a = o.slice(2, -1);
70
- if (a in l) {
71
- if (A(l[a]) || S(l[a]))
72
- try {
73
- return JSON.stringify(l[a]);
74
- } catch {
75
- return l[a];
76
- }
77
- return String(l[a]);
78
- }
79
- return o;
80
- }) : n;
81
- }), A(t) && fe(e) && t.trim ? this.obj = e.trim() : A(t) && t.ignoreEmptyString && e === "" ? this.obj = void 0 : this.obj = e, this.message = t.message, this.type = t.type, this.error = null, this.field = t.field || t.type, this.validateMessages = It(
82
- pt,
83
- t.validateMessages
84
- );
85
- }
86
- get not() {
87
- return this._not = !this._not, this;
88
- }
89
- get isRequired() {
90
- if (Y(this.obj) || Be(this.obj)) {
91
- const e = this.getValidateMsg("required");
92
- this.error = {
93
- value: this.obj,
94
- type: this.type,
95
- requiredError: !0,
96
- message: this.message || (A(e) ? e : `${this._not ? "[NOT MODE]:" : ""}${e}`)
97
- };
98
- }
99
- return this;
100
- }
101
- get end() {
102
- return this.error;
103
- }
104
- addError(e) {
105
- !this.error && e && (this.error = {
106
- value: this.obj,
107
- type: this.type,
108
- message: this.message || (A(e) ? e : `${this._not ? "[NOT MODE]:" : ""}${e}`)
109
- });
110
- }
111
- validate(e, t) {
112
- return (this._not ? e : !e) && this.addError(t), this;
113
- }
114
- collect(e) {
115
- e == null || e(this.error);
116
- }
117
- }
118
- class kt extends X {
119
- constructor(e, t) {
120
- super(e, {
121
- ...t,
122
- type: "array"
123
- }), this.validate(
124
- t && t.strict ? S(this.obj) : !0,
125
- this.getValidateMsg("type.array", { value: this.obj, type: this.type })
126
- );
127
- }
128
- length(e) {
129
- return this.obj ? this.validate(
130
- this.obj.length === e,
131
- this.getValidateMsg("array.length", { value: this.obj, length: e })
132
- ) : this;
133
- }
134
- minLength(e) {
135
- return this.obj ? this.validate(
136
- this.obj.length >= e,
137
- this.getValidateMsg("array.minLength", {
138
- value: this.obj,
139
- minLength: e
140
- })
141
- ) : this;
142
- }
143
- maxLength(e) {
144
- return this.obj ? this.validate(
145
- this.obj.length <= e,
146
- this.getValidateMsg("array.maxLength", {
147
- value: this.obj,
148
- maxLength: e
149
- })
150
- ) : this;
151
- }
152
- includes(e) {
153
- return this.obj ? this.validate(
154
- e.every((t) => this.obj.indexOf(t) !== -1),
155
- this.getValidateMsg("array.includes", {
156
- value: this.obj,
157
- includes: e
158
- })
159
- ) : this;
160
- }
161
- deepEqual(e) {
162
- return this.obj ? this.validate(
163
- Ae(this.obj, e),
164
- this.getValidateMsg("array.deepEqual", {
165
- value: this.obj,
166
- deepEqual: e
167
- })
168
- ) : this;
169
- }
170
- get empty() {
171
- return this.validate(
172
- Be(this.obj),
173
- this.getValidateMsg("array.empty", { value: this.obj })
174
- );
175
- }
176
- }
177
- let xt = class extends X {
178
- constructor(e, t) {
179
- super(e, {
180
- ...t,
181
- type: "boolean"
182
- }), this.validate(
183
- t && t.strict ? He(this.obj) : !0,
184
- this.getValidateMsg("type.boolean")
185
- );
186
- }
187
- get true() {
188
- return this.validate(
189
- this.obj === !0,
190
- this.getValidateMsg("boolean.true")
191
- );
192
- }
193
- get false() {
194
- return this.validate(
195
- this.obj === !1,
196
- this.getValidateMsg("boolean.false")
197
- );
198
- }
199
- }, Rt = class extends X {
200
- constructor(e, t) {
201
- super(e, {
202
- ...t,
203
- type: "custom"
204
- });
205
- }
206
- get validate() {
207
- const e = this;
208
- return function(t, s) {
209
- let i;
210
- if (t)
211
- return i = t(e.obj, e.addError.bind(e)), i && i.then ? (s && i.then(
212
- () => {
213
- s == null || s(e.error);
214
- },
215
- (l) => {
216
- console.error(l);
217
- }
218
- ), [i, e]) : (s == null || s(e.error), e.error);
219
- };
220
- }
221
- }, Nt = class extends X {
222
- constructor(e, t) {
223
- super(e, {
224
- ...t,
225
- type: "number"
226
- }), this.validate(
227
- t && t.strict ? Ft(this.obj) : !0,
228
- this.getValidateMsg("type.number")
229
- );
230
- }
231
- min(e) {
232
- return Y(this.obj) ? this : this.validate(
233
- this.obj >= e,
234
- this.getValidateMsg("number.min", { min: e })
235
- );
236
- }
237
- max(e) {
238
- return Y(this.obj) ? this : this.validate(
239
- this.obj <= e,
240
- this.getValidateMsg("number.max", { max: e })
241
- );
242
- }
243
- equal(e) {
244
- return Y(this.obj) ? this : this.validate(
245
- this.obj === e,
246
- this.getValidateMsg("number.equal", { equal: e })
247
- );
248
- }
249
- range(e, t) {
250
- return Y(this.obj) ? this : this.validate(
251
- this.obj >= e && this.obj <= t,
252
- this.getValidateMsg("number.range", { min: e, max: t })
253
- );
254
- }
255
- get positive() {
256
- return Y(this.obj) ? this : this.validate(this.obj > 0, this.getValidateMsg("number.positive"));
257
- }
258
- get negative() {
259
- return Y(this.obj) ? this : this.validate(this.obj < 0, this.getValidateMsg("number.negative"));
260
- }
261
- };
262
- class Pt extends X {
263
- constructor(e, t) {
264
- super(e, {
265
- ...t,
266
- type: "object"
267
- }), this.validate(
268
- t && t.strict ? A(this.obj) : !0,
269
- this.getValidateMsg("type.object")
270
- );
271
- }
272
- deepEqual(e) {
273
- return this.obj ? this.validate(
274
- Ae(this.obj, e),
275
- this.getValidateMsg("object.deepEqual", { deepEqual: e })
276
- ) : this;
277
- }
278
- hasKeys(e) {
279
- return this.obj ? this.validate(
280
- e.every((t) => this.obj[t]),
281
- this.getValidateMsg("object.hasKeys", { keys: e })
282
- ) : this;
283
- }
284
- get empty() {
285
- return this.validate(
286
- ft(this.obj),
287
- this.getValidateMsg("object.empty")
288
- );
289
- }
290
- }
291
- class Wt extends X {
292
- constructor(e, t) {
293
- super(e, {
294
- ...t,
295
- type: "string"
296
- }), this.validate(
297
- t && t.strict ? fe(this.obj) : !0,
298
- this.getValidateMsg("type.string")
299
- );
300
- }
301
- maxLength(e) {
302
- return this.obj ? this.validate(
303
- this.obj.length <= e,
304
- this.getValidateMsg("string.maxLength", { maxLength: e })
305
- ) : this;
306
- }
307
- minLength(e) {
308
- return this.obj ? this.validate(
309
- this.obj.length >= e,
310
- this.getValidateMsg("string.minLength", { minLength: e })
311
- ) : this;
312
- }
313
- length(e) {
314
- return this.obj ? this.validate(
315
- this.obj.length === e,
316
- this.getValidateMsg("string.length", { length: e })
317
- ) : this;
318
- }
319
- match(e) {
320
- const t = e instanceof RegExp;
321
- return t && (e.lastIndex = 0), this.validate(
322
- this.obj === void 0 || t && e.test(this.obj),
323
- this.getValidateMsg("string.match", { pattern: e })
324
- );
325
- }
326
- get uppercase() {
327
- return this.obj ? this.validate(
328
- this.obj.toUpperCase() === this.obj,
329
- this.getValidateMsg("string.uppercase")
330
- ) : this;
331
- }
332
- get lowercase() {
333
- return this.obj ? this.validate(
334
- this.obj.toLowerCase() === this.obj,
335
- this.getValidateMsg("string.lowercase")
336
- ) : this;
337
- }
338
- }
339
- const _t = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/, Lt = new RegExp(
340
- "^(?!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]*)?$",
341
- "i"
342
- ), qt = /^(2(5[0-5]{1}|[0-4]\d{1})|[0-1]?\d{1,2})(\.(2(5[0-5]{1}|[0-4]\d{1})|[0-1]?\d{1,2})){3}$/;
343
- class Ot extends X {
344
- constructor(e, t) {
345
- super(e, {
346
- ...t,
347
- type: "type"
348
- });
349
- }
350
- get email() {
351
- return this.type = "email", this.validate(
352
- this.obj === void 0 || _t.test(this.obj),
353
- this.getValidateMsg("type.email")
354
- );
355
- }
356
- get url() {
357
- return this.type = "url", this.validate(
358
- this.obj === void 0 || Lt.test(this.obj),
359
- this.getValidateMsg("type.url")
360
- );
361
- }
362
- get ip() {
363
- return this.type = "ip", this.validate(
364
- this.obj === void 0 || qt.test(this.obj),
365
- this.getValidateMsg("type.ip")
366
- );
367
- }
368
- }
369
- var Dt = Object.defineProperty, Ut = (r, e, t) => e in r ? Dt(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, O = (r, e, t) => Ut(r, typeof e != "symbol" ? e + "" : e, t);
370
- class zt {
371
- constructor(e, t) {
372
- O(this, "number"), O(this, "string"), O(this, "array"), O(this, "object"), O(this, "boolean"), O(this, "type"), O(this, "custom"), this.string = new Wt(e, t), this.number = new Nt(e, t), this.array = new kt(e, t), this.object = new Pt(e, t), this.boolean = new xt(e, t), this.type = new Ot(e, t), this.custom = new Rt(e, t);
373
- }
374
- }
375
- class Gt {
376
- constructor(e, t = {}) {
377
- O(this, "schema"), O(this, "options"), this.schema = e, this.options = t;
378
- }
379
- validate(e, t) {
380
- if (!A(e))
381
- return;
382
- const s = [];
383
- let i = null;
384
- function l(n, o) {
385
- i || (i = {}), (!i[n] || o.requiredError) && (i[n] = o);
386
- }
387
- this.schema && Object.keys(this.schema).forEach((n) => {
388
- if (S(this.schema[n]))
389
- for (let o = 0; o < this.schema[n].length; o++) {
390
- const a = this.schema[n][o], c = a.type, h = a.message;
391
- if (!c && !a.validator)
392
- throw `You must specify a type to field ${n}!`;
393
- const d = new zt(e[n], {
394
- ...this.options,
395
- message: h,
396
- field: n
397
- });
398
- let g = d.type[c] || null;
399
- if (!g)
400
- if (a.validator) {
401
- g = d.custom.validate(a.validator), S(g) && g[0].then ? s.push({
402
- function: g[0],
403
- _this: g[1],
404
- key: n
405
- }) : g && l(n, g);
406
- continue;
407
- } else
408
- g = d[c];
409
- if (Object.keys(a).forEach((m) => {
410
- a.required && (g = g.isRequired), m !== "message" && g[m] && a[m] && typeof g[m] == "object" && (g = g[m]), g[m] && a[m] !== void 0 && typeof g[m] == "function" && (g = g[m](a[m]));
411
- }), g.collect((m) => {
412
- m && l(n, m);
413
- }), i)
414
- break;
415
- }
416
- }), s.length > 0 ? Promise.all(s.map((n) => n.function)).then(() => {
417
- s.forEach((n) => {
418
- n._this.error && l(n.key, n._this.error);
419
- }), t == null || t(i);
420
- }) : t == null || t(i);
421
- }
422
- }
423
- const ae = pe({
424
- layout: "horizontal",
425
- labelCol: { span: 5, offset: 0 },
426
- labelAlign: "right",
427
- wrapperCol: { span: 19, offset: 0 },
428
- requiredSymbol: !0,
429
- getFormElementId: () => "pqb-",
430
- store: {
431
- clearFields: y,
432
- getFieldsValue: y,
433
- getFieldValue: y,
434
- getFieldError: y,
435
- getFieldsError: y,
436
- getTouchedFields: y,
437
- getFields: y,
438
- getInitialValues: y,
439
- setInitialValues: y,
440
- setInitialValue: y,
441
- setFieldValue: y,
442
- setFieldsValue: y,
443
- setFields: y,
444
- resetFields: y,
445
- submit: y,
446
- validate: y,
447
- getFieldsState: y,
448
- scrollToField: y,
449
- getInnerMethods: () => ({
450
- registerField: y,
451
- innerGetStore: y,
452
- registerStateWatcher: y,
453
- registerWatcher: y,
454
- innerGetStoreStatus: y
455
- })
456
- }
457
- }), Ee = pe({}), Ke = pe({}), Qe = pe({}), ye = {
458
- error: "error",
459
- success: "success",
460
- warning: "warning",
461
- validating: "validating"
462
- };
463
- var D = /* @__PURE__ */ ((r) => (r.init = "init", r.error = "error", r.success = "success", r.submitting = "submitting", r))(D || {});
464
- class At extends Error {
465
- constructor(t) {
466
- super("form validate error, get errors by error.errors");
467
- u(this, "errors", {});
468
- this.errors = t;
469
- }
470
- }
471
- function Bt(r) {
472
- return Object.defineProperty(
473
- (...e) => typeof e[e.length - 1] == "function" ? r.apply(this, e) : new Promise((t, s) => (e[e.length] = (i, l) => {
474
- if (i) return s(new At(i));
475
- t(l);
476
- }, e.length++, r.apply(this, e))),
477
- "name",
478
- { value: r.name }
479
- );
480
- }
481
- function ie(r) {
482
- return Je(r, (e) => {
483
- if (!R(e) && !S(e))
484
- return e;
485
- });
486
- }
487
- const Ht = (r, e) => Je(r, (t) => {
488
- if (_(t))
489
- return (s) => t(s, e);
490
- });
491
- function x(r, e, t) {
492
- return Ze(r, e, ie(t)), r;
493
- }
494
- function Pe(r, e = "") {
495
- const t = /* @__PURE__ */ new Set(), s = (i, l = "") => i ? t.has(i) ? [] : (t.add(i), Object.keys(i).map((n) => (R(i[n]) || S(i[n])) && Object.keys(i[n]).length && !K.isValidElement(i[n]) ? s(i[n], `${l + n}.`) : l + n).flat()) : [];
496
- return s(r, e);
497
- }
498
- function Xe(r) {
499
- var e;
500
- return ((e = r == null ? void 0 : r.constructor) == null ? void 0 : e.name) === "SyntheticEvent" || (r == null ? void 0 : r.nativeEvent) instanceof Event;
501
- }
502
- async function We(r, e, t, s) {
503
- const i = [...t || []];
504
- let l = 0;
505
- return new Promise(async (n) => {
506
- const o = [], a = async (c) => {
507
- const h = () => l < i.length - 1 ? (l++, a(i[l])) : n({ error: null, warning: o });
508
- if (!c)
509
- return h();
510
- const d = { ...c };
511
- !d.type && !d.validator && (d.type = "string"), new Gt({ [r]: [d] }, {
512
- ignoreEmptyString: !0,
513
- validateMessages: s
514
- }).validate({ [r]: e }, (m) => {
515
- if (m)
516
- if (c.validateLevel === "warning")
517
- o.push(m[r].message);
518
- else
519
- return n({
520
- error: m,
521
- warning: o
522
- });
523
- return h();
524
- });
525
- };
526
- a(i[l]);
527
- });
528
- }
529
- function ge(r, e) {
530
- const t = Ge({}, r, void 0, Object);
531
- return e.some((s) => ze(t, s));
532
- }
533
- const Ce = "_input";
534
- class Jt {
535
- constructor() {
536
- // 表示的 Form 的提交状态而非单个字段的提交状态。
537
- // 只有在触发表单 reset(原生 reset,而非当前的 resetFields) 时,才会回到 init 状态(目前没有支持 form.reset,所以没有这块逻辑)
538
- u(this, "submitStatus", D.init);
539
- u(this, "registerFields", []);
540
- // 所有 form item value 的变动,都会通知这里注册到的 watcher
541
- u(this, "registerWatchers", []);
542
- // 所有 form item 内部 errors, validating, touched 状态的变化,都会通知这里注册到的 watcher
543
- // TODO: 合并 registerWatchers
544
- u(this, "registerStateWatchers", []);
545
- // 所有 form 整体 的变动,都会通知这里注册到的 watcher
546
- u(this, "registerFormWatchers", []);
547
- // 和formControl 的 touched属性不一样。 只要被改过的字段,这里就会存储。并且不会跟随formControl被卸载而清除。
548
- // reset 的时候清除
549
- u(this, "touchedFields", {});
550
- u(this, "store", {});
551
- u(this, "initialValues", {});
552
- u(this, "callbacks", {});
553
- // 告知 form 状态改变,进行状态收集
554
- u(this, "innerCollectFormState", () => {
555
- this.notifyStateWatchers();
556
- });
557
- u(this, "innerSetCallbacks", (e) => {
558
- this.callbacks = e;
559
- });
560
- u(this, "registerFormWatcher", (e) => (this.registerFormWatchers.push(e), () => {
561
- this.registerFormWatchers = this.registerFormWatchers.filter(
562
- (t) => t !== e
563
- );
564
- }));
565
- u(this, "registerStateWatcher", (e) => (this.registerStateWatchers.push(e), () => {
566
- this.registerStateWatchers = this.registerStateWatchers.filter(
567
- (t) => t !== e
568
- );
569
- }));
570
- u(this, "registerWatcher", (e) => (this.registerWatchers.push(e), () => {
571
- this.registerWatchers = this.registerWatchers.filter((t) => t !== e);
572
- }));
573
- // 收集所有control字段,并在组件卸载时移除
574
- u(this, "registerField", (e) => (this.registerFields.push(e), this.notifyWatchers(), () => {
575
- this.registerFields = this.registerFields.filter((t) => t !== e), this.notifyWatchers();
576
- }));
577
- // hasField为true时,只返回传入field属性的control实例
578
- // isFormList 目前只在校验时需要包含
579
- // TODO formlist 实现缺陷,待优化
580
- u(this, "getRegisteredFields", (e, t) => e ? this.registerFields.filter(
581
- (s) => {
582
- var i;
583
- return s.hasFieldProps() && ((t == null ? void 0 : t.containFormList) || !((i = s.props) != null && i.isFormList));
584
- }
585
- ) : this.registerFields);
586
- // 获取props.field === field 的control组件。
587
- u(this, "getRegisteredField", (e) => this.registerFields.filter((t) => t.props.field === e)[0]);
588
- // 通知所有的FormItem进行更新。
589
- // setFieldValue: 外部调用setFieldsValue (setFieldValue等)方法触发更新
590
- // innerSetValue: 控件例如Input,通过onChange事件触发的更新
591
- // reset:重置
592
- u(this, "notify", (e, t) => {
593
- (e === "setFieldValue" || e === "innerSetValue" && !t.ignore) && this._pushTouchField(
594
- t.changeValues ? Pe(t.changeValues) : this._getIterativelyKeysByField(t.field)
595
- ), this.registerFields.forEach((s) => {
596
- var i;
597
- (i = s == null ? void 0 : s.onStoreChange) == null || i.call(s, e, {
598
- ...t,
599
- current: this.store
600
- });
601
- });
602
- });
603
- u(this, "innerSetInitialValues", (e) => {
604
- e && (this.initialValues = Oe(this.initialValues, ie(e)), Object.keys(e).forEach((t) => {
605
- x(this.store, t, e[t]);
606
- }));
607
- });
608
- u(this, "innerSetInitialValue", (e, t) => {
609
- e && (this.initialValues[e] = t, this._inTouchFields(e) || x(this.store, e, M(this.initialValues, e)));
610
- });
611
- /**
612
- *
613
- * 内部使用,更新value,会同时触发onChange 和 onValuesChange
614
- * @options.isFormList 强制更新field对应的组件包括其子组件,form
615
- */
616
- u(this, "innerSetFieldValue", (e, t, s) => {
617
- if (!e) return;
618
- const i = this.getFields();
619
- x(this.store, e, t), this.triggerValuesChange({
620
- [e]: t
621
- }), this.triggerTouchChange({ [e]: t }), this.notify("innerSetValue", {
622
- prev: i,
623
- field: e,
624
- ...s,
625
- changeValues: { [e]: t }
626
- });
627
- });
628
- // 内部使用
629
- u(this, "innerGetStore", () => this.store);
630
- // 目前返回提交状态,后续统一维护 errors,warnings 后,这里可进行拓展
631
- u(this, "innerGetStoreStatus", () => ({
632
- submitStatus: this.submitStatus
633
- }));
634
- // 内部使用,返回原始对象,注入到组件的 value 都从这里获取值,cloneDeep 后的值每次引用地址是不同的
635
- u(this, "innerGetFieldValue", (e) => M(this.store, e));
636
- // 获取所有被操作过的字段
637
- u(this, "getTouchedFields", () => this.getRegisteredFields(!0).filter((e) => e.isTouched()).map((e) => e.props.field));
638
- // 外部调用设置表单字段值
639
- u(this, "setFieldValue", (e, t) => {
640
- e && this.setFields({
641
- [e]: { value: t }
642
- });
643
- });
644
- // 外部调用,设置多个表单控件的值
645
- u(this, "setFieldsValue", (e) => {
646
- if (R(e)) {
647
- const t = Object.keys(e), s = {};
648
- t.forEach((i) => {
649
- s[i] = {
650
- value: e[i]
651
- };
652
- }), this.setFields(s);
653
- }
654
- });
655
- // 外部调用,设置多个表单控件的值,以及 error,touch 信息。
656
- u(this, "setFields", (e) => {
657
- const t = Object.keys(e), s = {};
658
- t.forEach((i) => {
659
- const l = e[i], n = this.getFields();
660
- if (l) {
661
- const o = {};
662
- "error" in l && (o.errors = l.error), "warning" in l && (o.warnings = l.warning), "touched" in l && (o.touched = l.touched), "value" in l && (x(this.store, i, l.value), s[i] = l.value), this.notify("setFieldValue", {
663
- data: o,
664
- prev: n,
665
- field: i,
666
- changeValues: { [i]: l.value }
667
- });
668
- }
669
- }), this.triggerValuesChange(s);
670
- });
671
- u(this, "getFieldValue", (e) => ie(M(this.store, e)));
672
- // 获取单个字段的错误信息。
673
- u(this, "getFieldError", (e) => {
674
- const t = this.getRegisteredField(e);
675
- return t ? t.getErrors() : null;
676
- });
677
- // 获取传入字段/全部的错误信息
678
- u(this, "getFieldsError", (e) => {
679
- const t = {};
680
- return S(e) ? e.map((s) => {
681
- const i = this.getFieldError(s);
682
- i && (t[s] = i);
683
- }) : this.getRegisteredFields(!0, { containFormList: !0 }).forEach(
684
- (s) => {
685
- s.getErrors() && (t[s.props.field] = s.getErrors());
686
- }
687
- ), t;
688
- });
689
- u(this, "getFields", () => ie(this.store));
690
- u(this, "getFieldsValue", (e) => {
691
- const t = {};
692
- return S(e) ? (e.forEach((s) => {
693
- x(t, s, this.getFieldValue(s));
694
- }), t) : (this.getRegisteredFields(!0).forEach(({ props: { field: s } }) => {
695
- const i = M(this.store, s);
696
- x(t, s, i);
697
- }), t);
698
- });
699
- u(this, "getInitialValues", () => this.initialValues);
700
- u(this, "setInitialValues", (e) => {
701
- this.innerSetInitialValues(e), this.setFieldsValue(e);
702
- });
703
- u(this, "setInitialValue", (e, t) => {
704
- this.innerSetInitialValue(e, t), this.setFieldValue(e, t);
705
- });
706
- u(this, "resetFields", (e) => {
707
- const t = this.getFields(), s = Ne(e) && !S(e) ? [e] : e;
708
- let i = {};
709
- if (s && S(s))
710
- s.forEach((n) => {
711
- x(
712
- this.store,
713
- n,
714
- this.initialValues[n]
715
- ), i[n] = M(this.store, n);
716
- }), this.triggerValuesChange(i), this.notify("reset", { prev: t, field: s }), this._popTouchField(s);
717
- else {
718
- const n = {};
719
- i = this.getFields(), Object.keys(this.initialValues).forEach((o) => {
720
- x(n, o, this.initialValues[o]);
721
- }), this.store = n, this.getRegisteredFields(!0).forEach((o) => {
722
- const a = o.props.field;
723
- x(i, a, M(this.store, a));
724
- }), this.triggerValuesChange(i), this._popTouchField(), this.notify("reset", {
725
- prev: t,
726
- field: Object.keys(i)
727
- });
728
- }
729
- const { onReset: l } = this.callbacks;
730
- l == null || l(i);
731
- });
732
- u(this, "validate", Bt(
733
- (e, t, s) => {
734
- const i = this.getRegisteredFields(!0, {
735
- containFormList: !0
736
- }), l = S(e) && e.length ? i.filter(
737
- (h) => e.indexOf(h.props.field) > -1
738
- ) : i, n = R(e) ? e : R(t) ? t : {}, o = _(e) ? e : _(t) ? t : s || (() => {
739
- }), a = l.map(
740
- (h) => n != null && n.validateOnly ? h.validateFieldOnly() : h.validateField()
741
- ), c = (h) => {
742
- if (!(n != null && n.validateOnly)) {
743
- const { onValidateFail: d } = this.callbacks;
744
- d == null || d(h);
745
- }
746
- };
747
- Promise.all(a).then((h) => {
748
- let d = {};
749
- const g = {};
750
- h.map((v) => {
751
- var F;
752
- v.error && (d = { ...d, ...v.error });
753
- const f = this.getRegisteredField(v.field);
754
- (F = f == null ? void 0 : f.props) != null && F.isFormList || x(g, v.field, v.value);
755
- });
756
- let m;
757
- return Object.keys(d).length ? (c == null || c(d), m = o == null ? void 0 : o(d, ie(g))) : m = o == null ? void 0 : o(null, ie(g)), m;
758
- });
759
- }
760
- ));
761
- u(this, "toggleSubmitStatus", (e) => {
762
- this.submitStatus = e, this.innerCollectFormState(), this.notifyFormWatcher();
763
- });
764
- u(this, "submit", () => (this.toggleSubmitStatus(D.submitting), this.validate((e, t) => {
765
- let s;
766
- const { onSubmit: i, onSubmitFailed: l } = this.callbacks;
767
- !e && i && (s = i(t)), e && l && (s = l(e)), s && s.then ? s.then((n) => (this.toggleSubmitStatus(D.success), n)).catch((n) => (this.toggleSubmitStatus(D.error), Promise.reject(n))) : this.toggleSubmitStatus(
768
- e ? D.error : D.success
769
- );
770
- })));
771
- u(this, "getFieldsState", (e) => {
772
- const t = {}, s = (i) => {
773
- if (!i)
774
- return null;
775
- const l = i.getErrors();
776
- return {
777
- errors: l ? [l] : [],
778
- warnings: i.getWarnings(),
779
- validateStatus: i.getValidateStatus(),
780
- isSubmitting: this.submitStatus === D.submitting,
781
- isTouched: i.isTouched(),
782
- value: this.getFieldValue(i.props.field)
783
- };
784
- };
785
- return S(e) ? (e.forEach((i) => {
786
- t[i] = s(this.getRegisteredField(i));
787
- }), t) : (this.getRegisteredFields(!0).forEach((i) => {
788
- t[i.props.field] = s(i);
789
- }), t);
790
- });
791
- u(this, "clearFields", (e) => {
792
- const t = this.getFields(), s = Ne(e) && !S(e) ? [e] : e;
793
- if (s && S(s)) {
794
- const i = {};
795
- s.forEach((l) => {
796
- x(this.store, l, void 0), i[l] = M(this.store, l);
797
- }), this.triggerValuesChange(i), this.notify("setFieldValue", {
798
- prev: t,
799
- field: s,
800
- data: {
801
- errors: null,
802
- warnings: null
803
- }
804
- });
805
- } else {
806
- const i = {};
807
- this.store = {}, this.getRegisteredFields(!0).forEach((l) => {
808
- const n = l.props.field;
809
- x(i, n, void 0);
810
- }), this.triggerValuesChange(i), this.notify("setFieldValue", {
811
- prev: t,
812
- field: Object.keys(i),
813
- data: {
814
- errors: null,
815
- warnings: null
816
- }
817
- });
818
- }
819
- });
820
- }
821
- notifyWatchers() {
822
- this.registerWatchers.forEach((e) => {
823
- e();
824
- });
825
- }
826
- // 注册监听全局状态的 watcher
827
- notifyFormWatcher() {
828
- this.registerFormWatchers.forEach((e) => {
829
- e();
830
- });
831
- }
832
- notifyStateWatchers() {
833
- this.registerStateWatchers.forEach((e) => {
834
- e();
835
- });
836
- }
837
- triggerValuesChange(e) {
838
- if (e && Object.keys(e).length) {
839
- const { onValuesChange: t } = this.callbacks;
840
- t == null || t(e, this.getFields());
841
- }
842
- this.notifyWatchers();
843
- }
844
- triggerTouchChange(e) {
845
- if (e && Object.keys(e).length) {
846
- const { onChange: t } = this.callbacks;
847
- t == null || t(e, this.getFields());
848
- }
849
- }
850
- _getIterativelyKeysByField(e) {
851
- if (!e)
852
- return [];
853
- const s = [].concat(e).map((i) => Pe(x({}, i, void 0))).reduce((i, l) => i.concat(l), []);
854
- return [e, ...s];
855
- }
856
- _inTouchFields(e) {
857
- return this._getIterativelyKeysByField(e).some((s) => ze(this.touchedFields, s));
858
- }
859
- _popTouchField(e) {
860
- e === void 0 && (this.touchedFields = {});
861
- const t = this._getIterativelyKeysByField(e);
862
- this.touchedFields = mt(this.touchedFields, t);
863
- }
864
- _pushTouchField(e) {
865
- [].concat(e).forEach((t) => {
866
- Ge(this.touchedFields, t, void 0, Object);
867
- });
868
- }
869
- }
870
- function Zt() {
871
- const r = new Jt();
872
- return {
873
- getFieldsValue: r.getFieldsValue,
874
- getFieldValue: r.getFieldValue,
875
- getFieldError: r.getFieldError,
876
- getFieldsError: r.getFieldsError,
877
- getTouchedFields: r.getTouchedFields,
878
- getFields: r.getFields,
879
- getInitialValues: r.getInitialValues,
880
- setInitialValues: r.setInitialValues,
881
- setInitialValue: r.setInitialValue,
882
- setFieldValue: r.setFieldValue,
883
- setFieldsValue: r.setFieldsValue,
884
- setFields: r.setFields,
885
- resetFields: r.resetFields,
886
- clearFields: r.clearFields,
887
- submit: r.submit,
888
- validate: r.validate,
889
- scrollToField: () => {
890
- },
891
- getFieldsState: r.getFieldsState,
892
- getInnerMethods: (e) => {
893
- const t = {};
894
- return e && [
895
- "registerField",
896
- "registerWatcher",
897
- "registerStateWatcher",
898
- "registerFormWatcher",
899
- "innerSetInitialValues",
900
- "innerSetInitialValue",
901
- "innerSetCallbacks",
902
- "innerSetFieldValue",
903
- "innerGetStore",
904
- "innerGetStoreStatus",
905
- "innerGetFieldValue",
906
- "innerCollectFormState"
907
- ].map((s) => {
908
- t[s] = r[s];
909
- }), t;
910
- }
911
- };
912
- }
913
- function et(r) {
914
- const e = L(r);
915
- return e.current || (r ? e.current = r : e.current = Zt()), [e.current];
916
- }
917
- function Ve(r, e) {
918
- const t = e.replace(/[[.]/g, "_").replace(/\]/g, "");
919
- return r ? `${r}-${t}` : `${t}`;
920
- }
921
- const Yt = {
922
- layout: "horizontal",
923
- labelCol: { span: 5, offset: 0 },
924
- labelAlign: "right",
925
- wrapperCol: { span: 19, offset: 0 },
926
- requiredSymbol: !0,
927
- wrapper: "form",
928
- validateTrigger: "onChange"
929
- }, Kt = (r, e) => {
930
- var te, Z;
931
- const t = U(De), s = U(Ke), i = L(null), [l] = et(
932
- r.form
933
- ), n = gt(
934
- r,
935
- Yt,
936
- (te = t.componentConfig) == null ? void 0 : te.Form
937
- ), {
938
- layout: o,
939
- labelCol: a,
940
- wrapperCol: c,
941
- wrapper: h,
942
- id: d,
943
- requiredSymbol: g,
944
- labelAlign: m,
945
- disabled: v,
946
- colon: f,
947
- className: F,
948
- validateTrigger: V,
949
- prefixCls: j,
950
- validateMessages: w,
951
- ...$
952
- } = n, T = j || t.getPrefixCls("form"), ee = t.rtl, ue = "size" in n ? n.size : t.size, ce = l.getInnerMethods(!0);
953
- dt(() => {
954
- ce.innerSetInitialValues(n.initialValues);
955
- }), he(() => {
956
- let b;
957
- return s.register && (b = s.register(n.id, l)), b;
958
- }, [n.id, l]), l.scrollToField = (b, W) => {
959
- const I = i.current, k = n.id;
960
- if (!I)
961
- return;
962
- let z = I.querySelector(
963
- `#${Ve(k, b)}`
964
- );
965
- z || (z = I.querySelector(
966
- `#${Ve(k, b)}${Ce}`
967
- )), z && at(z, {
968
- behavior: "smooth",
969
- block: "nearest",
970
- scrollMode: "if-needed",
971
- ...W
972
- });
973
- }, ce.innerSetCallbacks({
974
- onValuesChange: (b, W) => {
975
- var I, k;
976
- (I = n.onValuesChange) == null || I.call(n, b, W), (k = s.onFormValuesChange) == null || k.call(s, n.id, b);
977
- },
978
- onChange: n.onChange,
979
- onValidateFail: (b) => {
980
- if (n.scrollToFirstError) {
981
- const W = R(n.scrollToFirstError) ? n.scrollToFirstError : {};
982
- l.scrollToField(
983
- Object.keys(b)[0],
984
- W
985
- );
986
- }
987
- },
988
- onSubmitFailed: n.onSubmitFailed,
989
- onSubmit: (b) => {
990
- var I, k;
991
- const W = (I = n.onSubmit) == null ? void 0 : I.call(n, b);
992
- return (k = s.onFormSubmit) == null || k.call(s, n.id, b), W;
993
- },
994
- onReset: (b) => {
995
- var I, k;
996
- const W = (I = n.onReset) == null ? void 0 : I.call(n, b);
997
- return (k = s == null ? void 0 : s.onFormReset) == null || k.call(s, n.id, b), W;
998
- }
999
- });
1000
- const be = {
1001
- requiredSymbol: g,
1002
- labelAlign: m,
1003
- disabled: v,
1004
- colon: f,
1005
- labelCol: a,
1006
- wrapperCol: c,
1007
- layout: o,
1008
- store: l,
1009
- prefixCls: T,
1010
- validateTrigger: V,
1011
- validateMessages: Oe(
1012
- {},
1013
- (Z = t.locale.Form) == null ? void 0 : Z.validateMessages,
1014
- w
1015
- ),
1016
- getFormElementId: (b) => Ve(d, b)
1017
- }, de = ae;
1018
- return ht(e, () => ({
1019
- ...l,
1020
- getRootDOMNode() {
1021
- return i.current;
1022
- }
1023
- })), /* @__PURE__ */ p(ct, { ...t, size: ue, children: /* @__PURE__ */ p(de.Provider, { value: be, children: /* @__PURE__ */ p(
1024
- h,
1025
- {
1026
- ref: i,
1027
- ...Ue($, [
1028
- "form",
1029
- "size",
1030
- "initialValues",
1031
- "onValuesChange",
1032
- "onChange",
1033
- "wrapperProps",
1034
- "scrollToFirstError",
1035
- "onSubmit",
1036
- "onSubmitFailed",
1037
- "onReset"
1038
- ]),
1039
- ...n.wrapperProps,
1040
- className: B(
1041
- T,
1042
- `${T}-${o}`,
1043
- `${T}-size-${ue}`,
1044
- { [`${T}-rtl`]: ee },
1045
- F
1046
- ),
1047
- style: n.style,
1048
- onSubmit: (b) => {
1049
- b.preventDefault(), b.stopPropagation(), l.submit();
1050
- },
1051
- onReset: (b) => {
1052
- b.preventDefault(), b.stopPropagation(), l.resetFields();
1053
- },
1054
- id: d,
1055
- children: n.children
1056
- }
1057
- ) }) });
1058
- }, tt = we(Kt);
1059
- tt.displayName = "Form";
1060
- class H extends ut {
1061
- constructor(t, s) {
1062
- var i, l;
1063
- super(t);
1064
- u(this, "context");
1065
- // 校验信息
1066
- u(this, "errors", null);
1067
- // 校验 warning 信息
1068
- u(this, "warnings", null);
1069
- // undefined => validating => success / error => (validating or undefined)
1070
- u(this, "validateStatus");
1071
- // 是否被用户操作过
1072
- u(this, "touched");
1073
- u(this, "isDestroyed", !1);
1074
- // 保存 props.children 或函数类型 props.children() 的返回值
1075
- u(this, "childrenElement", null);
1076
- u(this, "removeRegisterField");
1077
- // 触发 store 进行状态收集
1078
- // TODO: error, validateStatus ,touched 状态和 UI 组件解耦,统一维护在 store 内部
1079
- u(this, "triggerStateCollect", () => {
1080
- const { innerCollectFormState: t } = this.context.store.getInnerMethods(!0);
1081
- t();
1082
- });
1083
- // 切换校验状态
1084
- u(this, "toggleValidateStatus", (t) => {
1085
- this.validateStatus = t, this.triggerStateCollect();
1086
- });
1087
- // 切换 touch 状态
1088
- u(this, "toggleTouched", (t) => {
1089
- this.touched = He(t) ? t : !this.touched, this.triggerStateCollect();
1090
- });
1091
- u(this, "setWarnings", (t) => {
1092
- this.warnings = t, this.triggerStateCollect();
1093
- });
1094
- u(this, "setErrors", (t) => {
1095
- this.errors = t, this.triggerStateCollect();
1096
- });
1097
- u(this, "getErrors", () => this.errors);
1098
- u(this, "getWarnings", () => this.warnings || []);
1099
- u(this, "isTouched", () => this.touched);
1100
- u(this, "getValidateStatus", () => this.props.validateStatus ? this.props.validateStatus : this.validateStatus);
1101
- u(this, "hasFieldProps", () => !!this.props.field);
1102
- u(this, "clearFormItemError", (t = this.props.field) => {
1103
- const { updateFormItem: s } = this.context;
1104
- s == null || s(t, { errors: null, warnings: null });
1105
- });
1106
- u(this, "updateFormItem", () => {
1107
- if (this.isDestroyed) return;
1108
- this.forceUpdate();
1109
- const { updateFormItem: t } = this.context;
1110
- t == null || t(this.props.field, {
1111
- errors: this.errors,
1112
- warnings: this.warnings
1113
- });
1114
- });
1115
- u(this, "getFieldValue", () => {
1116
- const t = this.props.field, s = this.context.store;
1117
- return t ? s.getInnerMethods(!0).innerGetFieldValue(t) : void 0;
1118
- });
1119
- u(this, "onStoreChange", (t, s) => {
1120
- const i = S(s.field) ? s.field : [s.field], { field: l, shouldUpdate: n, dependencies: o } = this.props, a = (c) => {
1121
- if (o && n && oe(!0, "`shouldUpdate` of the `Form.Item` will be ignored."), o)
1122
- (S(o) || o.some(
1123
- (h) => ge(h, i)
1124
- )) && this.isTouched() && this.validateField();
1125
- else if (n) {
1126
- let h = !1;
1127
- _(n) ? h = n(s.prev, s.current, {
1128
- field: s.field,
1129
- ...c
1130
- }) : h = !je(s.prev, s.current), h && this.updateFormItem();
1131
- }
1132
- };
1133
- switch (t) {
1134
- case "reset":
1135
- this.toggleTouched(!1), this.toggleValidateStatus(void 0), this.setErrors(null), this.setWarnings(null), o || n ? a() : this.updateFormItem();
1136
- break;
1137
- case "innerSetValue":
1138
- if (ge(l, i)) {
1139
- this.toggleTouched(!0), this.updateFormItem();
1140
- return;
1141
- }
1142
- a({
1143
- isInner: !0,
1144
- isFormList: s.isFormList
1145
- });
1146
- break;
1147
- case "setFieldValue":
1148
- if (ge(l, i)) {
1149
- this.toggleTouched(!0), s.data && "touched" in s.data && this.toggleTouched(s.data.touched), s.data && "warnings" in s.data && this.setWarnings(
1150
- St(s.data.warnings) ? [] : [].concat(s.data.warnings)
1151
- ), s.data && "errors" in s.data ? this.setErrors(s.data.errors) : je(M(s.prev, l), M(s.current, l)) || this.setErrors(null), this.updateFormItem();
1152
- return;
1153
- }
1154
- a();
1155
- break;
1156
- }
1157
- });
1158
- u(this, "innerSetFieldValue", (t, s) => {
1159
- var o, a;
1160
- if (!t) return;
1161
- const { store: i } = this.context;
1162
- i.getInnerMethods(!0).innerSetFieldValue(t, s);
1163
- const n = {};
1164
- Ze(n, t, s), (a = (o = this.props) == null ? void 0 : o.onValuesChange) == null || a.call(o, n, {
1165
- ...i.getFieldsValue()
1166
- });
1167
- });
1168
- // 仅仅校验下值,不做任何状态变更
1169
- u(this, "validateFieldOnly", () => {
1170
- const { validateMessages: t } = this.context, { field: s, rules: i } = this.props, l = this.getFieldValue();
1171
- return We(s, l, i, t).then(
1172
- ({ error: n, warning: o }) => Promise.resolve({ error: n, value: l, warning: o, field: s })
1173
- );
1174
- });
1175
- /**
1176
- *
1177
- * @param triggerType the value of validateTrigger.
1178
- * @returns
1179
- */
1180
- u(this, "validateField", (t) => {
1181
- const { validateTrigger: s, validateMessages: i } = this.context, { field: l, rules: n, validateTrigger: o } = this.props, a = this.getFieldValue(), c = () => {
1182
- var g;
1183
- const d = this.errors || ((g = this.warnings) == null ? void 0 : g.length);
1184
- this.toggleValidateStatus("validating"), this.setErrors(null), this.setWarnings(null), d && this.updateFormItem();
1185
- }, h = t ? (n || []).filter((d) => [].concat(
1186
- d.validateTrigger || o || s
1187
- ).indexOf(t) > -1) : n;
1188
- return h && h.length && l ? (c(), We(l, a, h, i).then(
1189
- ({ error: d, warning: g }) => {
1190
- var m;
1191
- return this.setErrors(d ? d[l] : null), this.setWarnings(g || null), this.toggleValidateStatus(
1192
- this.errors ? "error" : (m = this.warnings) != null && m.length ? "warning" : "success"
1193
- ), this.updateFormItem(), Promise.resolve({ error: d, value: a, field: l });
1194
- }
1195
- )) : Promise.resolve({ error: null, value: a, field: l });
1196
- });
1197
- // 每次 render 都会作为 onChange 传递给 children,需要保证引用地址不变
1198
- // 所以 handleTrigger 需要声明在类上,并且直接作为 children.props.onChange
1199
- u(this, "handleTrigger", (t, ...s) => {
1200
- const i = this.childrenElement || this.props.children, { store: l } = this.context, { field: n, trigger: o, normalize: a, getValueFromEvent: c } = this.props, h = _(c) ? c(t, ...s) : t;
1201
- let d = h;
1202
- if (Xe(h)) {
1203
- oe(
1204
- !0,
1205
- "changed value missed, please check whether extra elements is outta input/select controled by Form.Item"
1206
- ), h.stopPropagation();
1207
- return;
1208
- }
1209
- typeof a == "function" && (d = a(h, l.getFieldValue(n), {
1210
- ...l.getFieldsValue()
1211
- })), this.toggleTouched(!0), this.innerSetFieldValue(n, d), this.validateField(o), Se(i) && i.props && i.props[o] && (this.props.isFormList || i.props[o](d, ...s));
1212
- });
1213
- u(this, "getChild", () => {
1214
- const { children: t } = this.props, { store: s } = this.context;
1215
- let i = t;
1216
- return _(t) && (i = t(
1217
- s.getFields(),
1218
- {
1219
- ...s
1220
- },
1221
- this.props.isFormList && {
1222
- value: this.getFieldValue(),
1223
- onChange: this.handleTrigger
1224
- }
1225
- )), this.childrenElement = i, i;
1226
- });
1227
- "initialValue" in t && this.hasFieldProps() && ((l = (i = s == null ? void 0 : s.store) == null ? void 0 : i.setInitialValue) == null || l.call(i, t.field, t.initialValue));
1228
- }
1229
- componentDidMount() {
1230
- const { store: t } = this.context ?? {};
1231
- if (t) {
1232
- const s = t.getInnerMethods(!0);
1233
- this.removeRegisterField = s.registerField(this);
1234
- }
1235
- this.isDestroyed = !1;
1236
- }
1237
- componentDidUpdate(t) {
1238
- (t.field !== this.props.field && this.props._key && t._key === this.props._key || /* 以下条件判断潘启宝添加于 2023年10月23日 星期一 13时10分43秒 CST */
1239
- this.props.disabled !== t.disabled && this.props.disabled || this.props.rules !== t.rules && !this.props.rules) && (this.updateFormItem(), this.clearFormItemError(t.field));
1240
- }
1241
- componentWillUnmount() {
1242
- var t;
1243
- (t = this.removeRegisterField) == null || t.call(this), this.removeRegisterField = null, this.clearFormItemError(), this.isDestroyed = !0;
1244
- }
1245
- /**
1246
- * 收集rules里的validateTrigger字段
1247
- */
1248
- getValidateTrigger() {
1249
- const t = this.props.validateTrigger || this.context.validateTrigger || "onChange", s = this.props.rules || [];
1250
- let i = [];
1251
- return s.map((l) => {
1252
- i = i.concat(l.validateTrigger || t);
1253
- }), Array.from(new Set(i));
1254
- }
1255
- renderControl(t, s) {
1256
- var f;
1257
- const {
1258
- field: i,
1259
- trigger: l = "onChange",
1260
- triggerPropName: n = "value",
1261
- validateStatus: o,
1262
- formatter: a
1263
- } = this.props, { store: c, disabled: h } = this.context, d = "disabled" in this.props ? this.props.disabled : h, g = K.Children.only(t), m = {
1264
- // used by label
1265
- id: B(((f = g.props) == null ? void 0 : f.id) || { [`${s}${Ce}`]: s })
1266
- };
1267
- this.getValidateTrigger().forEach((F) => {
1268
- m[F] = (V) => {
1269
- var j, w;
1270
- this.validateField(F), (w = (j = g.props) == null ? void 0 : j[F]) == null || w.call(j, V);
1271
- };
1272
- }), m[l] = this.handleTrigger, d !== void 0 && !("disabled" in g.props) && (m.disabled = d);
1273
- let v = M(c.getInnerMethods(!0).innerGetStore(), i);
1274
- return _(a) && (v = a(v)), m[n] = v, !o && this.errors && (m.error = !0), K.cloneElement(g, m);
1275
- }
1276
- render() {
1277
- const { noStyle: t, field: s, isFormList: i, hasFeedback: l } = this.props, n = this.getValidateStatus(), { prefixCls: o, getFormElementId: a } = this.context;
1278
- let c = this.getChild();
1279
- const h = this.hasFieldProps() ? a == null ? void 0 : a(s) : void 0;
1280
- return this.hasFieldProps() && !i && K.Children.count(c) === 1 && (c = this.renderControl(c, h)), t ? c : /* @__PURE__ */ p("div", { className: `${o}-item-control-wrapper`, children: /* @__PURE__ */ p("div", { className: `${o}-item-control`, id: h, children: /* @__PURE__ */ Q("div", { className: `${o}-item-control-children`, children: [
1281
- c,
1282
- n && l && /* @__PURE__ */ Q(
1283
- "div",
1284
- {
1285
- className: `${o}-item-feedback ${o}-item-feedback-${n}`,
1286
- children: [
1287
- n === "warning" && /* @__PURE__ */ p(bt, {}),
1288
- n === "success" && /* @__PURE__ */ p(vt, {}),
1289
- n === "error" && /* @__PURE__ */ p(yt, {}),
1290
- n === "validating" && /* @__PURE__ */ p(Vt, {})
1291
- ]
1292
- }
1293
- )
1294
- ] }) }) });
1295
- }
1296
- }
1297
- u(H, "defaultProps", {
1298
- trigger: "onChange",
1299
- triggerPropName: "value"
1300
- }), u(H, "isFormControl", !0), u(H, "contextType", Ee);
1301
- function Qt(r) {
1302
- return /* @__PURE__ */ p(
1303
- "svg",
1304
- {
1305
- width: "1em",
1306
- height: "1em",
1307
- "aria-hidden": !0,
1308
- focusable: !1,
1309
- fill: "currentColor",
1310
- stroke: "none",
1311
- viewBox: "0 0 48 48",
1312
- ...r,
1313
- children: /* @__PURE__ */ p("path", { d: "M30.841,46.115l5.864,-2.824l-6.841,-14.205l15.371,3.508l1.449,-6.345l-15.372,-3.509l12.327,-9.83l-4.058,-5.088l-12.327,9.83l0,-15.767l-6.508,0l-0,15.767l-12.327,-9.83l-4.058,5.088l12.327,9.83l-15.372,3.509l1.449,6.345l15.371,-3.508l-6.841,14.205l5.864,2.824l6.841,-14.206l6.841,14.206Z" })
1314
- }
1315
- );
1316
- }
1317
- const Xt = ({
1318
- htmlFor: r,
1319
- showColon: e,
1320
- label: t,
1321
- requiredSymbol: s,
1322
- required: i,
1323
- rules: l,
1324
- prefix: n,
1325
- tooltip: o
1326
- }) => {
1327
- const a = S(l) && l.some((g) => g && g.required), c = R(s) ? s.position : "end", h = (i || a) && !!s && /* @__PURE__ */ p("strong", { className: `${n}-form-item-symbol`, children: /* @__PURE__ */ p(Qt, {}) }), d = () => {
1328
- if (!o)
1329
- return null;
1330
- const g = `${n}-form-item-tooltip`;
1331
- let m = {}, v = /* @__PURE__ */ p(Et, { className: g });
1332
- if (!R(o) || Se(o))
1333
- m = {
1334
- content: o
1335
- };
1336
- else {
1337
- const { icon: f, ...F } = o;
1338
- m = F, f && (v = Se(f) ? K.cloneElement(f, {
1339
- className: B(
1340
- g,
1341
- f.props.className
1342
- )
1343
- }) : f);
1344
- }
1345
- return /* @__PURE__ */ p(wt, { ...m, children: v });
1346
- };
1347
- return t ? /* @__PURE__ */ Q("label", { htmlFor: r && `${r}${Ce}`, children: [
1348
- c !== "end" && h,
1349
- " ",
1350
- t,
1351
- d(),
1352
- c === "end" && /* @__PURE__ */ Q(qe, { children: [
1353
- " ",
1354
- h
1355
- ] }),
1356
- e ? e === !0 ? ":" : e : ""
1357
- ] }) : null;
1358
- }, es = Ye.Row, _e = Ye.Col, ts = ({
1359
- prefixCls: r,
1360
- help: e,
1361
- errors: t,
1362
- warnings: s
1363
- }) => {
1364
- const i = t.map((a, c) => {
1365
- if (a)
1366
- return /* @__PURE__ */ p("div", { role: "alert", children: a.message }, c);
1367
- }), l = [];
1368
- s.map((a, c) => {
1369
- l.push(
1370
- /* @__PURE__ */ p("div", { role: "alert", className: `${r}-message-help-warning`, children: a }, c)
1371
- );
1372
- });
1373
- const n = !le(e) || !!l.length, o = n || !!i.length;
1374
- return o && /* @__PURE__ */ p(
1375
- jt,
1376
- {
1377
- in: o,
1378
- appear: !0,
1379
- classNames: "formblink",
1380
- timeout: 300,
1381
- unmountOnExit: !0,
1382
- children: /* @__PURE__ */ p(
1383
- "div",
1384
- {
1385
- className: B(`${r}-message`, {
1386
- [`${r}-message-help`]: n
1387
- }),
1388
- children: le(e) ? /* @__PURE__ */ Q(qe, { children: [
1389
- i.length > 0 && i,
1390
- l.length > 0 && l
1391
- ] }) : e
1392
- }
1393
- )
1394
- }
1395
- );
1396
- }, ss = (r, e) => {
1397
- var Ie, Me, $e;
1398
- const { getPrefixCls: t, prefixCls: s } = U(De), i = U(Ee), l = U(Qe), [n, o] = me(null), [a, c] = me(null), h = U(ae), d = h.prefixCls || t("form"), g = r.layout || h.layout, m = r.labelAlign || h.labelAlign, v = L(!1), f = (N, E = {}) => {
1399
- if (v.current)
1400
- return;
1401
- const { errors: q, warnings: se } = E || {};
1402
- o((re) => {
1403
- const C = { ...re || {} };
1404
- return q ? C[N] = q : delete C[N], C;
1405
- }), c((re) => {
1406
- const C = { ...re || {} };
1407
- return se && se.length ? C[N] = se : delete C[N], C;
1408
- });
1409
- }, F = R(r.noStyle) && r.noStyle.showErrorTip && i.updateFormItem ? i.updateFormItem : f;
1410
- he(() => (v.current = !1, () => {
1411
- v.current = !0, o(null), c(null);
1412
- }), []);
1413
- const V = {
1414
- ...h,
1415
- validateMessages: h.validateMessages && Ht(h.validateMessages, {
1416
- label: r.label
1417
- }),
1418
- prefixCls: d,
1419
- updateFormItem: F,
1420
- disabled: "disabled" in r ? r.disabled : h.disabled
1421
- }, { label: j, extra: w, className: $, style: T, validateStatus: ee, hidden: ue, ...ce } = r, be = B(`${d}-label-item`, {
1422
- [`${d}-label-item-left`]: m === "left"
1423
- }), de = n ? Object.values(n) : [], te = a ? Object.values(a).reduce((N, E) => N.concat(E), []) : [], Z = ke(() => {
1424
- if (ee)
1425
- return ee;
1426
- if (de.length)
1427
- return ye.error;
1428
- if (te.length)
1429
- return ye.warning;
1430
- }, [n, a, ee]), b = ke(() => !le(r.help) || te.length > 0, [r.help, a]), W = B(
1431
- `${d}-item`,
1432
- {
1433
- [`${d}-item-error`]: b || !ee && Z === ye.error,
1434
- [`${d}-item-status-${Z}`]: Z,
1435
- [`${d}-item-has-help`]: b,
1436
- [`${d}-item-hidden`]: ue,
1437
- [`${d}-item-has-feedback`]: Z && r.hasFeedback
1438
- },
1439
- `${d}-layout-${g}`,
1440
- $
1441
- ), I = () => {
1442
- var se, re;
1443
- const { field: N, children: E } = r, q = "disabled" in r ? r.disabled : h.disabled;
1444
- if (_(E)) {
1445
- let { key: C, ...P } = r ?? {};
1446
- return /* @__PURE__ */ xe(
1447
- H,
1448
- {
1449
- disabled: q,
1450
- ...P,
1451
- key: N || C,
1452
- _key: N || C
1453
- },
1454
- (...ve) => E(
1455
- ...ve
1456
- )
1457
- );
1458
- }
1459
- if (S(E)) {
1460
- const C = K.Children.map(E, (P, ve) => {
1461
- const Te = R(P) && P.key || ve, it = R(P) && "disabled" in P.props, nt = !le(q) && !it ? { key: Te, disabled: q } : { key: Te };
1462
- return R(P) ? Re(P, nt) : P;
1463
- });
1464
- return /* @__PURE__ */ p(H, { ...r, field: void 0, children: C });
1465
- }
1466
- if (K.Children.count(E) == 1) {
1467
- if (N) {
1468
- const C = ((se = l == null ? void 0 : l.getItemKey) == null ? void 0 : se.call(l, N)) || N;
1469
- return /* @__PURE__ */ xe(H, { disabled: q, ...r, key: C, _key: C }, E);
1470
- }
1471
- if (R(E)) {
1472
- if ((re = E.type) != null && re.isFormControl)
1473
- return E;
1474
- const P = !("disabled" in E.props) && !le(q) ? { disabled: q } : null;
1475
- return /* @__PURE__ */ p(H, { ...r, field: void 0, children: P ? Re(E, P) : E });
1476
- }
1477
- }
1478
- return E;
1479
- }, k = Ee, z = {
1480
- ...h
1481
- };
1482
- return r.noStyle || (z.wrapperCol = void 0, z.labelCol = void 0), /* @__PURE__ */ p(ae.Provider, { value: z, children: /* @__PURE__ */ p(k.Provider, { value: V, children: r.noStyle ? I() : /* @__PURE__ */ Q(
1483
- es,
1484
- {
1485
- ref: e,
1486
- ...Ue(ce, [
1487
- "tooltip",
1488
- "children",
1489
- "prefixCls",
1490
- "store",
1491
- "initialValue",
1492
- "field",
1493
- "labelCol",
1494
- "wrapperCol",
1495
- "colon",
1496
- "disabled",
1497
- "rules",
1498
- "trigger",
1499
- "triggerPropName",
1500
- "validateTrigger",
1501
- "noStyle",
1502
- "required",
1503
- "hasFeedback",
1504
- "help",
1505
- "normalize",
1506
- "formatter",
1507
- "getValueFromEvent",
1508
- "shouldUpdate",
1509
- "field",
1510
- "isInner",
1511
- "labelAlign",
1512
- "layout",
1513
- "requiredSymbol",
1514
- "isFormList"
1515
- ]),
1516
- className: W,
1517
- div: g !== "horizontal",
1518
- style: T,
1519
- children: [
1520
- j ? /* @__PURE__ */ p(
1521
- _e,
1522
- {
1523
- ...r.labelCol || h.labelCol,
1524
- className: B(
1525
- be,
1526
- (Ie = r.labelCol) == null ? void 0 : Ie.className,
1527
- (Me = h.labelCol) == null ? void 0 : Me.className,
1528
- {
1529
- [`${d}-label-item-flex`]: !r.labelCol && !h.labelCol
1530
- }
1531
- ),
1532
- children: /* @__PURE__ */ p(
1533
- Xt,
1534
- {
1535
- tooltip: r.tooltip,
1536
- htmlFor: r.field && (($e = h == null ? void 0 : h.getFormElementId) == null ? void 0 : $e.call(h, r.field)),
1537
- label: j,
1538
- prefix: s,
1539
- requiredSymbol: "requiredSymbol" in r ? r.requiredSymbol : h.requiredSymbol,
1540
- required: r.required,
1541
- rules: r.rules,
1542
- showColon: "colon" in r ? r.colon : h.colon
1543
- }
1544
- )
1545
- }
1546
- ) : null,
1547
- /* @__PURE__ */ Q(
1548
- _e,
1549
- {
1550
- className: B(`${d}-item-wrapper`, {
1551
- [`${d}-item-wrapper-flex`]: !r.wrapperCol && !h.wrapperCol
1552
- }),
1553
- ...r.wrapperCol || h.wrapperCol,
1554
- children: [
1555
- I(),
1556
- /* @__PURE__ */ p(
1557
- ts,
1558
- {
1559
- prefixCls: d,
1560
- help: r.help,
1561
- errors: de,
1562
- warnings: te
1563
- }
1564
- ),
1565
- w && /* @__PURE__ */ p("div", { className: `${d}-extra`, children: w })
1566
- ]
1567
- }
1568
- )
1569
- ]
1570
- }
1571
- ) }) });
1572
- }, Fe = we(ss);
1573
- Fe.defaultProps = {
1574
- trigger: "onChange",
1575
- triggerPropName: "value"
1576
- };
1577
- Fe.displayName = "FormItem";
1578
- const Le = (r, e) => !le(r) && r >= 0 && r < e.length, st = (r) => {
1579
- const { field: e, children: t, initialValue: s } = r, i = L({
1580
- id: 0,
1581
- keys: []
1582
- }), l = "initialValue" in r ? { initialValue: s } : {}, n = i.current.keys;
1583
- return /* @__PURE__ */ p(
1584
- Qe.Provider,
1585
- {
1586
- value: {
1587
- getItemKey: (o) => {
1588
- const a = o == null ? void 0 : o.replace(/\[|\]/g, ".").split("."), c = a.indexOf(e), h = a[c + 1];
1589
- return `${e}_${n.indexOf(h)}_${a.slice(c + 2).join("_")}`;
1590
- }
1591
- },
1592
- children: /* @__PURE__ */ p(
1593
- Fe,
1594
- {
1595
- field: e,
1596
- ...l,
1597
- isFormList: !0,
1598
- rules: r.rules,
1599
- wrapperCol: { span: 24 },
1600
- noStyle: "noStyle" in r ? r.noStyle : !r.rules,
1601
- shouldUpdate: (o, a, c) => {
1602
- var h, d;
1603
- return !!(c && !c.isInner && ge(c.field, [e]) && ((h = M(o, e)) == null ? void 0 : h.length) !== ((d = M(a, e)) == null ? void 0 : d.length));
1604
- },
1605
- children: (o, a, { value: c, onChange: h }) => {
1606
- const d = c || [], g = function(f, F) {
1607
- var T;
1608
- if (Xe(f)) {
1609
- oe(
1610
- !0,
1611
- "Form.List: The event object cannot be used as a parameter of the add method"
1612
- );
1613
- return;
1614
- }
1615
- const V = ((T = a.getInnerMethods(!0)) == null ? void 0 : T.innerGetFieldValue(e)) || [], j = i.current.id;
1616
- i.current.id += 1;
1617
- const w = V || [];
1618
- let $ = w;
1619
- F !== void 0 && F >= 0 && F <= w.length ? (n.splice(F, 0, j), $ = [
1620
- ...w.slice(0, F),
1621
- f,
1622
- ...w.slice(F)
1623
- ]) : (n.push(j), $ = [...w, f]), h($, {
1624
- isFormList: !0,
1625
- ignore: f === void 0
1626
- });
1627
- }, m = function(f) {
1628
- var j;
1629
- const V = (((j = a.getInnerMethods(!0)) == null ? void 0 : j.innerGetFieldValue(e)) || []).filter((w, $) => $ !== f);
1630
- n.splice(f, 1), h([...V], { isFormList: !0 });
1631
- }, v = function(f, F) {
1632
- var T;
1633
- const V = ((T = a.getInnerMethods(!0)) == null ? void 0 : T.innerGetFieldValue(e)) || [];
1634
- if (f === F || !Le(f, V) || !Le(F, V))
1635
- return;
1636
- const j = n[f];
1637
- n.splice(f, 1), n.splice(F, 0, j);
1638
- const w = V[f], $ = [...V];
1639
- $.splice(f, 1), $.splice(F, 0, w), h($, { isFormList: !0 });
1640
- };
1641
- return _(t) && t(
1642
- d.map((f, F) => {
1643
- let V = n[F];
1644
- return V === void 0 && (V = i.current.id, n.push(V), i.current.id += 1), {
1645
- field: `${e}[${F}]`,
1646
- key: V
1647
- };
1648
- }),
1649
- {
1650
- add: g,
1651
- remove: m,
1652
- move: v
1653
- }
1654
- );
1655
- }
1656
- }
1657
- )
1658
- }
1659
- );
1660
- };
1661
- st.displayName = "FormList";
1662
- const rs = (r, e) => {
1663
- const t = L({}), s = ne((o, a) => (o && (t.current[o] = a), () => {
1664
- delete t.current[o];
1665
- }), []), i = ne(
1666
- (o, a) => {
1667
- var c;
1668
- (c = r.onFormSubmit) == null || c.call(r, o, a, {
1669
- forms: t.current
1670
- });
1671
- },
1672
- [r.onFormSubmit]
1673
- ), l = ne(
1674
- (o, a) => {
1675
- var c;
1676
- (c = r.onFormReset) == null || c.call(r, o, a, {
1677
- forms: t.current
1678
- });
1679
- },
1680
- [r.onFormReset]
1681
- ), n = ne(
1682
- (o, a) => {
1683
- var c;
1684
- (c = r.onFormValuesChange) == null || c.call(r, o, a, {
1685
- forms: t.current
1686
- });
1687
- },
1688
- [r.onFormValuesChange]
1689
- );
1690
- return /* @__PURE__ */ p(
1691
- Ke.Provider,
1692
- {
1693
- value: {
1694
- onFormValuesChange: n,
1695
- onFormSubmit: i,
1696
- onFormReset: l,
1697
- register: s
1698
- },
1699
- children: r.children
1700
- }
1701
- );
1702
- }, rt = we(rs);
1703
- rt.displayName = "FormProvider";
1704
- const is = () => {
1705
- const r = U(ae), e = r.store, t = L(!1), s = Ct(), i = ne(() => {
1706
- var o, a, c;
1707
- const { submitStatus: l } = ((c = (a = (o = e == null ? void 0 : e.getInnerMethods) == null ? void 0 : o.call(e, !0)) == null ? void 0 : a.innerGetStoreStatus) == null ? void 0 : c.call(a)) ?? {}, n = l === D.submitting;
1708
- n !== t.current && (t.current = n, s());
1709
- }, []);
1710
- return he(() => {
1711
- var a;
1712
- if (!e) {
1713
- oe(!0, "formInstance is not available");
1714
- return;
1715
- }
1716
- const { registerFormWatcher: l } = ((a = e == null ? void 0 : e.getInnerMethods) == null ? void 0 : a.call(e, !0)) ?? {}, n = () => i();
1717
- n();
1718
- const o = (l == null ? void 0 : l(n)) ?? {};
1719
- return () => {
1720
- o == null || o();
1721
- };
1722
- }, []), {
1723
- form: e,
1724
- disabled: r.disabled,
1725
- isSubmitting: t.current
1726
- };
1727
- }, ns = (r, e) => {
1728
- const t = U(ae), s = e || t.store, i = L(r);
1729
- i.current = r;
1730
- const l = ne(() => {
1731
- const c = i.current, h = s.getFieldsState([c]);
1732
- return h == null ? void 0 : h[c];
1733
- }, []), [n, o] = me(l), a = L(n);
1734
- return he(() => {
1735
- var g;
1736
- if (!s) {
1737
- oe(!0, "formInstance is not available");
1738
- return;
1739
- }
1740
- const { registerStateWatcher: c } = ((g = s == null ? void 0 : s.getInnerMethods) == null ? void 0 : g.call(s, !0)) ?? {}, h = () => {
1741
- const m = l();
1742
- je(a.current, m) || (o(m), a.current = m);
1743
- };
1744
- h();
1745
- const d = c == null ? void 0 : c(h);
1746
- return () => {
1747
- d == null || d();
1748
- };
1749
- }, []), n;
1750
- }, ls = (r, e) => {
1751
- const t = U(ae), s = e || t.store, [i, l] = me(() => {
1752
- const a = s == null ? void 0 : s.getFieldsValue([].concat(r));
1753
- return fe(r) ? M(a, r) : a;
1754
- }), n = L(r);
1755
- n.current = r;
1756
- const o = L(JSON.stringify(i));
1757
- return he(() => {
1758
- var d;
1759
- if (!s) {
1760
- oe(!0, "formInstance is not available");
1761
- return;
1762
- }
1763
- const { registerWatcher: a } = ((d = s == null ? void 0 : s.getInnerMethods) == null ? void 0 : d.call(s, !0)) ?? {}, c = () => {
1764
- const g = n.current, m = s.getFieldsValue([].concat(g));
1765
- let v = m;
1766
- S(g) || (v = M(m, g));
1767
- const f = JSON.stringify(v);
1768
- o.current !== f && (l(v), o.current = f);
1769
- };
1770
- c();
1771
- const h = a == null ? void 0 : a(c);
1772
- return () => {
1773
- h == null || h();
1774
- };
1775
- }, []), i;
1776
- }, J = tt;
1777
- J.Provider = rt;
1778
- J.Item = Fe;
1779
- J.List = st;
1780
- J.Control = H;
1781
- J.useForm = et;
1782
- J.useFormContext = is;
1783
- J.useWatch = ls;
1784
- J.useFormState = ns;
1785
- export {
1786
- H as C,
1787
- J as F,
1788
- Fe as I,
1789
- st as L,
1790
- Gt as Y,
1791
- rt as a,
1792
- is as b,
1793
- ns as c,
1794
- ls as d,
1795
- et as u
1796
- };