@unicom-cloud/ui 0.8.95 → 0.8.97

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 (326) hide show
  1. package/Affix.js +1 -1
  2. package/Carousel.js +1 -1
  3. package/LiquidFill.js +4 -0
  4. package/Message.js +1 -1
  5. package/Notification.js +1 -1
  6. package/OverflowEllipsis.js +1 -1
  7. package/PageHeader.js +1 -1
  8. package/QrCode.js +57 -0
  9. package/Switch.js +1 -1
  10. package/Tour.js +63 -0
  11. package/Trigger.js +2 -2
  12. package/_virtual/_commonjsHelpers.js +6 -0
  13. package/_virtual/index.js +7 -0
  14. package/_virtual/index2.js +4 -0
  15. package/affix/index.js +70 -72
  16. package/alert/index.js +52 -51
  17. package/anchor/Anchor.js +55 -55
  18. package/anchor/Link.js +34 -34
  19. package/anchor/util.js +5 -5
  20. package/auto-complete/index.js +116 -122
  21. package/avatar/Avatar.js +33 -33
  22. package/avatar/Group.js +26 -26
  23. package/back-top/index.js +58 -61
  24. package/badge/index.js +46 -46
  25. package/breadcrumb/Item.js +42 -43
  26. package/breadcrumb/index.js +47 -47
  27. package/button/Group.js +6 -6
  28. package/button/index.js +91 -91
  29. package/calendar/Month.js +75 -75
  30. package/calendar/Year.js +35 -35
  31. package/calendar/header/index.js +25 -25
  32. package/calendar/index.js +103 -103
  33. package/card/Grid.js +8 -8
  34. package/card/Meta.js +16 -16
  35. package/card/index.js +49 -49
  36. package/carousel/Arrow.js +19 -19
  37. package/carousel/Indicator.js +26 -26
  38. package/carousel/index.js +108 -108
  39. package/cascader/Cascader.js +178 -191
  40. package/cascader/base/node.js +133 -136
  41. package/cascader/base/store.js +82 -85
  42. package/cascader/panel/List.js +126 -130
  43. package/cascader/panel/Search.js +79 -81
  44. package/cascader/util.js +13 -13
  45. package/checkbox/Checkbox.js +94 -96
  46. package/checkbox/Group.js +54 -56
  47. package/checkbox/GroupBlock.js +28 -29
  48. package/collapse/Collapse.js +45 -45
  49. package/collapse/Item.js +53 -55
  50. package/color-picker/ControlBar.js +43 -43
  51. package/color-picker/InputAlpha.js +12 -12
  52. package/color-picker/InputHex.js +30 -31
  53. package/color-picker/InputRgb.js +24 -24
  54. package/color-picker/Palette.js +18 -18
  55. package/color-picker/Panel.js +122 -125
  56. package/color-picker/hooks/useColorPicker.js +85 -88
  57. package/color-picker/hooks/useControlBlock.js +38 -40
  58. package/color-picker/index.js +47 -47
  59. package/comment/index.js +29 -29
  60. package/components/common/higher-order/with-speech-synthesis/index.js +37 -40
  61. package/components/common/hooks/useForceUpdate.js +6 -2
  62. package/components/common/hooks/useId.js +4 -4
  63. package/components/common/hooks/useInView.js +16 -16
  64. package/components/common/hooks/useIntersectionObserver.js +1 -1
  65. package/components/common/hooks/useKeyboardEvent.js +9 -10
  66. package/components/common/hooks/useOverflowHidden.js +1 -4
  67. package/components/common/hooks/usePersistCallback.js +7 -7
  68. package/components/common/hooks/useStateCallback.js +9 -10
  69. package/components/common/hooks/useWindowSize.js +8 -8
  70. package/components/common/space/index.js +11 -10
  71. package/components/common/utils/PqbCSSTransition.js +1 -1
  72. package/components/common/utils/convertToDurationBasedOnTimeUnits.js +6 -0
  73. package/components/common/utils/dom.js +27 -29
  74. package/components/common/utils/findScrollParent.js +17 -0
  75. package/components/common/utils/intersectionObserver.js +21 -0
  76. package/components/common/utils/is.js +99 -109
  77. package/components/common/utils/mutationObserver.js +19 -0
  78. package/components/common/utils/reactDOM.js +34 -34
  79. package/components/common/utils/resizeObserver.js +21 -0
  80. package/copy/index.js +38 -40
  81. package/date-picker/Picker.js +290 -295
  82. package/date-picker/RangePicker.js +367 -372
  83. package/date-picker/index.js +33 -35
  84. package/date-picker/panel/Body.js +46 -47
  85. package/date-picker/panel/Header.js +33 -33
  86. package/date-picker/panel/Shortcut.js +31 -31
  87. package/date-picker/panel/date/index.js +85 -85
  88. package/date-picker/panel/month/index.js +59 -59
  89. package/date-picker/panel/quarter/index.js +67 -70
  90. package/date-picker/panel/range/index.js +101 -101
  91. package/date-picker/panel/year/index.js +39 -39
  92. package/date-picker/util.js +17 -18
  93. package/descriptions/index.js +62 -62
  94. package/details/index.js +55 -56
  95. package/development/index.js +9 -9
  96. package/dist/react-transition-group/src/CSSTransition.js +1 -1
  97. package/dist/react-transition-group/src/SwitchTransition.js +1 -1
  98. package/dist/tinycolor/chunk/BOzCVdr0.js +1 -1
  99. package/dist/tween/src/tween.js +24 -25
  100. package/dist/validate/src/index.js +5 -5
  101. package/dist/validate/src/util.js +1 -1
  102. package/divider/index.js +21 -21
  103. package/draggable/Item.js +35 -35
  104. package/draggable/index.js +22 -22
  105. package/drawer/Drawer.js +142 -147
  106. package/dropdown/Button.js +48 -48
  107. package/dropdown/index.js +88 -92
  108. package/empty/index.js +16 -16
  109. package/form/Control.js +211 -225
  110. package/form/Form.js +109 -113
  111. package/form/FormItem.js +118 -120
  112. package/form/FormList.js +60 -66
  113. package/form/FormProvider.js +31 -34
  114. package/form/hook/useContext.js +17 -19
  115. package/form/hook/useState.js +22 -23
  116. package/form/hook/useWatch.js +26 -27
  117. package/form/promisify.js +14 -18
  118. package/form/store.js +304 -316
  119. package/form/util.js +14 -15
  120. package/grid/Col.js +64 -64
  121. package/grid/Grid.js +51 -51
  122. package/grid/GridItem.js +48 -48
  123. package/grid/Row.js +39 -39
  124. package/hooks/index.js +50 -52
  125. package/hooks/useVerificationCode.js +41 -43
  126. package/hooks/useWatermark.js +89 -92
  127. package/icon/index.js +23 -24
  128. package/icon-hover/index.js +16 -16
  129. package/icons/file.js +11 -11
  130. package/image/Image.js +140 -141
  131. package/image/ImagePreview.js +252 -255
  132. package/image/ImagePreviewArrow.js +25 -25
  133. package/image/ImagePreviewGroup.js +62 -62
  134. package/image/util/getScale.js +25 -28
  135. package/index.js +682 -679
  136. package/input/Button.js +48 -50
  137. package/input/Group.js +9 -9
  138. package/input/Input.js +145 -154
  139. package/input/InputElement.js +108 -115
  140. package/input/Password.js +38 -38
  141. package/input/Search.js +51 -55
  142. package/input/Textarea.js +80 -81
  143. package/input/useComposition.js +23 -23
  144. package/input-number/decimal.js +59 -62
  145. package/input-number/index.js +139 -141
  146. package/input-tag/InputTag.js +223 -231
  147. package/layout/Content.js +6 -6
  148. package/layout/Footer.js +8 -8
  149. package/layout/Header.js +7 -7
  150. package/layout/Sider.js +88 -90
  151. package/layout/index.js +30 -30
  152. package/link/index.js +45 -46
  153. package/liquid-fill/LiquidFill.js +189 -0
  154. package/liquid-fill/LiquidFill2.js +3 -0
  155. package/liquid-fill/index.js +4 -0
  156. package/liquid-fill/interface.js +1 -0
  157. package/list/Item.js +28 -28
  158. package/list/Meta.js +12 -12
  159. package/list/index.js +146 -148
  160. package/mentions/index.js +75 -76
  161. package/menu/Item.js +58 -58
  162. package/menu/Menu.js +125 -127
  163. package/menu/OverflowWrap.js +39 -40
  164. package/menu/sub-menu/Inline.js +45 -45
  165. package/menu/util.js +26 -28
  166. package/message/index.js +97 -100
  167. package/message/useMessage.js +26 -27
  168. package/modal/Confirm.js +47 -49
  169. package/modal/Modal.js +250 -257
  170. package/modal/use-modal/Hook.js +26 -28
  171. package/modal/use-modal/index.js +46 -49
  172. package/notice/index.js +89 -90
  173. package/notification/index.js +61 -66
  174. package/notification/withNotification.js +35 -35
  175. package/overflow-ellipsis/OverflowItem.js +19 -20
  176. package/overflow-ellipsis/index.js +45 -46
  177. package/package.json +1 -1
  178. package/page-header/index.js +45 -45
  179. package/pagination/PageItem.js +87 -91
  180. package/pagination/PageJumper.js +40 -41
  181. package/pagination/PageOption.js +31 -35
  182. package/pagination/Pagination.js +162 -163
  183. package/picker/Input.js +90 -96
  184. package/picker/InputRange.js +115 -122
  185. package/popconfirm/index.js +98 -100
  186. package/popover/index.js +28 -28
  187. package/portal/Portal.js +10 -11
  188. package/progress/index.js +36 -36
  189. package/qr-code/index.js +99 -0
  190. package/qr-code/interface.js +1 -0
  191. package/radio/Group.js +48 -48
  192. package/radio/GroupBlock.js +32 -33
  193. package/radio/Radio.js +62 -64
  194. package/rate/index.js +88 -88
  195. package/resize-box/ResizeTrigger.js +39 -39
  196. package/resize-box/Split.js +92 -96
  197. package/resize-box/SplitGroup.js +116 -122
  198. package/resize-box/index.js +112 -115
  199. package/result/index.js +44 -44
  200. package/select/Option.js +53 -56
  201. package/select/Select.js +365 -381
  202. package/select/util.js +95 -99
  203. package/select-view/Core.js +159 -160
  204. package/skeleton/index.js +23 -23
  205. package/slider/Button.js +84 -92
  206. package/slider/Input.js +47 -49
  207. package/slider/Tick.js +28 -31
  208. package/slider/index.js +108 -108
  209. package/slider/util.js +1 -1
  210. package/space/index.js +26 -26
  211. package/space-/index.js +51 -51
  212. package/spin/DotLoading.js +8 -8
  213. package/spin/index.js +47 -47
  214. package/statistic/Countdown.js +37 -37
  215. package/statistic/index.js +61 -61
  216. package/steps/Step.js +42 -42
  217. package/steps/index.js +54 -54
  218. package/style.css +1 -1
  219. package/switch/index.js +78 -79
  220. package/table/ColGroup.js +36 -37
  221. package/table/Table.js +447 -450
  222. package/table/hook/useExpand.js +24 -24
  223. package/table/hook/useRowSelection.js +62 -62
  224. package/table/summary/Row.js +16 -17
  225. package/table/tbody/Td.js +119 -118
  226. package/table/tbody/Tr.js +119 -121
  227. package/table/tbody/index.js +62 -63
  228. package/table/th-resizable/index.js +30 -30
  229. package/table/thead/Column.js +148 -148
  230. package/table/thead/index.js +87 -88
  231. package/tabs/Tab.js +55 -55
  232. package/tabs/TabContent.js +8 -8
  233. package/tabs/TabPane.js +15 -15
  234. package/tabs/hook/useHeaderScroll.js +36 -36
  235. package/tabs/tab-header/TabInk.js +31 -33
  236. package/tabs/tab-header/TabNavIcon.js +34 -35
  237. package/tabs/tab-header/index.js +192 -195
  238. package/tag/index.js +94 -97
  239. package/time-picker/Picker.js +167 -172
  240. package/time-picker/RangePicker.js +28 -28
  241. package/time-picker/TimePicker.js +146 -146
  242. package/time-picker/util.js +4 -4
  243. package/timeline/Item.js +46 -46
  244. package/timeline/Timeline.js +52 -52
  245. package/tooltip/index.js +89 -95
  246. package/tour/index.js +289 -0
  247. package/transfer/Item.js +54 -54
  248. package/transfer/List.js +134 -136
  249. package/transfer/index.js +91 -91
  250. package/tree/Animation.js +49 -52
  251. package/tree/Node.js +114 -122
  252. package/tree/NodeList.js +51 -51
  253. package/tree/Tree.js +386 -393
  254. package/tree-select/List.js +71 -72
  255. package/tree-select/Select.js +135 -143
  256. package/tree-select/hook/useKeyCache.js +39 -39
  257. package/tree-select/hook/useStateValue.js +12 -12
  258. package/trigger/getPopupStyle.js +60 -61
  259. package/trigger/index.js +338 -347
  260. package/types/common/space/interface.d.ts +1 -1
  261. package/types/common/utils/convertToDurationBasedOnTimeUnits.d.ts +3 -0
  262. package/types/common/utils/findScrollParent.d.ts +2 -0
  263. package/types/common/utils/index.d.ts +5 -0
  264. package/types/common/utils/intersectionObserver.d.ts +2 -0
  265. package/types/common/utils/math.d.ts +1 -1
  266. package/types/common/utils/mutationObserver.d.ts +2 -0
  267. package/types/common/utils/resizeObserver.d.ts +2 -0
  268. package/types/pc/alert/interface.d.ts +2 -2
  269. package/types/pc/details/interface.d.ts +2 -2
  270. package/types/pc/hooks/index.d.ts +0 -1
  271. package/types/pc/index.d.ts +3 -0
  272. package/types/pc/liquid-fill/LiquidFill.d.ts +30 -0
  273. package/types/pc/liquid-fill/LiquidFill2.d.ts +1 -0
  274. package/types/pc/liquid-fill/index.d.ts +4 -0
  275. package/types/pc/liquid-fill/interface.d.ts +0 -0
  276. package/types/pc/qr-code/index.d.ts +34 -0
  277. package/types/pc/qr-code/interface.d.ts +39 -0
  278. package/types/pc/table/interface.d.ts +2 -2
  279. package/types/pc/tour/index.d.ts +42 -0
  280. package/types/pc/utils/convertToDurationBasedOnTimeUnits.d.ts +3 -0
  281. package/types/pc/utils/findScrollParent.d.ts +2 -0
  282. package/types/pc/utils/index.d.ts +5 -0
  283. package/types/pc/utils/intersectionObserver.d.ts +2 -0
  284. package/types/pc/utils/math.d.ts +1 -1
  285. package/types/pc/utils/mutationObserver.d.ts +2 -0
  286. package/types/pc/utils/names.d.ts +18 -0
  287. package/types/pc/utils/resizeObserver.d.ts +2 -0
  288. package/typography/Base.js +79 -81
  289. package/typography/EditContent.js +30 -33
  290. package/typography/Ellipsis.js +78 -75
  291. package/typography/Operations.js +50 -52
  292. package/typography/Paragraph.js +7 -7
  293. package/typography/Typography.js +7 -7
  294. package/typography/useEllipsis.js +105 -106
  295. package/upload/TriggerNode.js +69 -76
  296. package/upload/Upload.js +84 -87
  297. package/upload/Uploader.js +115 -118
  298. package/upload/list/PictureItem.js +61 -71
  299. package/upload/list/TextItem.js +61 -67
  300. package/upload/list/UploadProgress.js +42 -49
  301. package/upload/list/index.js +49 -50
  302. package/upload/request_.js +37 -38
  303. package/upload/util.js +39 -39
  304. package/utils/convertToDurationBasedOnTimeUnits.js +6 -0
  305. package/utils/findScrollParent.js +4 -0
  306. package/utils/index.js +274 -275
  307. package/utils/intersectionObserver.js +4 -0
  308. package/utils/math.js +7 -11
  309. package/utils/mutationObserver.js +4 -0
  310. package/utils/names.js +12 -0
  311. package/utils/reactTransitionGroup.js +1 -1
  312. package/utils/resizeObserver.js +4 -0
  313. package/verification-code/VerificationCode.js +50 -51
  314. package/version/index.js +1 -1
  315. package/virtual-list/VirtualList.js +243 -244
  316. package/virtual-list/util/item.js +3 -4
  317. package/watermark/Watermark.js +27 -31
  318. package/components/common/hooks/useComputedState.js +0 -11
  319. package/components/common/utils/resizeObserverEffect.js +0 -23
  320. package/hooks/useComputedState.js +0 -4
  321. package/types/common/hooks/useComputedState.d.ts +0 -4
  322. package/types/common/utils/resizeObserverEffect.d.ts +0 -2
  323. package/types/pc/hooks/useComputedState.d.ts +0 -1
  324. package/types/pc/utils/resizeObserverEffect.d.ts +0 -2
  325. package/utils/resizeObserverEffect.js +0 -4
  326. /package/dist/react-transition-group/chunk/{C6QwjD4L.js → CPfP7aNL.js} +0 -0
package/form/Form.js CHANGED
@@ -1,22 +1,22 @@
1
1
  import { jsx as d } from "react/jsx-runtime";
2
- import O from "../dist/scroll-into-view-if-needed/src/index.js";
3
- import A from "lodash/isPlainObject";
4
- import _ from "lodash/merge";
5
- import { forwardRef as H, useContext as V, useRef as U, useEffect as W, useImperativeHandle as X } from "react";
6
- import B from "../config-provider/ConfigProvider.js";
7
- import G from "../components/common/hooks/useCreate.js";
8
- import J from "../components/common/hooks/useMergeProps.js";
9
- import K from "@unicom-cloud/utils/class-name";
10
- import { omit as L } from "../components/common/utils/omit.js";
11
- import { FormProviderContext as Q, FormContext as Y } from "./context.js";
12
- import Z from "./hook/useForm.js";
13
- import { ID_SUFFIX as ee } from "./util.js";
14
- import oe from "../config-provider/context.js";
15
- function f(a, u) {
16
- const n = u.replace(/[[.]/g, "_").replace(/\]/g, "");
17
- return a ? `${a}-${n}` : `${n}`;
2
+ import q from "../dist/scroll-into-view-if-needed/src/index.js";
3
+ import D from "lodash/isPlainObject";
4
+ import j from "lodash/merge";
5
+ import { forwardRef as k, useContext as h, useRef as O, useEffect as A, useImperativeHandle as _ } from "react";
6
+ import H from "../config-provider/ConfigProvider.js";
7
+ import U from "../components/common/hooks/useCreate.js";
8
+ import W from "../components/common/hooks/useMergeProps.js";
9
+ import X from "@unicom-cloud/utils/class-name";
10
+ import { omit as B } from "../components/common/utils/omit.js";
11
+ import { FormProviderContext as G, FormContext as J } from "./context.js";
12
+ import K from "./hook/useForm.js";
13
+ import { ID_SUFFIX as L } from "./util.js";
14
+ import Q from "../config-provider/context.js";
15
+ function u(i, c) {
16
+ const t = c.replace(/[[.]/g, "_").replace(/\]/g, "");
17
+ return i ? `${i}-${t}` : `${t}`;
18
18
  }
19
- const re = {
19
+ const Y = {
20
20
  layout: "horizontal",
21
21
  labelCol: { span: 5, offset: 0 },
22
22
  labelAlign: "right",
@@ -24,106 +24,102 @@ const re = {
24
24
  requiredSymbol: !0,
25
25
  wrapper: "form",
26
26
  validateTrigger: "onChange"
27
- }, te = (a, u) => {
28
- var h, S, $, y;
29
- const n = V(oe), t = V(Q), p = U(null), [l] = Z(
30
- a.form
31
- ), e = J(
32
- a,
33
- re,
34
- (h = n.componentConfig) == null ? void 0 : h.Form
27
+ }, Z = (i, c) => {
28
+ const t = h(Q), s = h(G), p = O(null), [n] = K(
29
+ i.form
30
+ ), o = W(
31
+ i,
32
+ Y,
33
+ t.componentConfig?.Form
35
34
  ), {
36
- layout: g,
37
- labelCol: R,
38
- wrapperCol: w,
39
- wrapper: I,
40
- id: F,
41
- requiredSymbol: M,
42
- labelAlign: N,
43
- disabled: z,
44
- colon: T,
45
- className: E,
46
- validateTrigger: P,
47
- prefixCls: q,
48
- validateMessages: D,
49
- ...j
50
- } = e, m = q || ((S = n.getPrefixCls) == null ? void 0 : S.call(n, "form")), k = n.rtl, b = "size" in e ? e.size : n.size, C = l.getInnerMethods(!0);
51
- G(() => {
52
- C.innerSetInitialValues(e.initialValues);
53
- }), W(() => {
54
- let o;
55
- return t.register && (o = t.register(e.id, l)), o;
56
- }, [e.id, l]), l.scrollToField = (o, s) => {
57
- const r = p.current, i = e.id;
58
- if (!r)
35
+ layout: f,
36
+ labelCol: S,
37
+ wrapperCol: x,
38
+ wrapper: P,
39
+ id: g,
40
+ requiredSymbol: $,
41
+ labelAlign: v,
42
+ disabled: y,
43
+ colon: V,
44
+ className: R,
45
+ validateTrigger: w,
46
+ prefixCls: I,
47
+ validateMessages: M,
48
+ ...N
49
+ } = o, l = I || t.getPrefixCls?.("form"), z = t.rtl, C = "size" in o ? o.size : t.size, F = n.getInnerMethods(!0);
50
+ U(() => {
51
+ F.innerSetInitialValues(o.initialValues);
52
+ }), A(() => {
53
+ let e;
54
+ return s.register && (e = s.register(o.id, n)), e;
55
+ }, [o.id, n]), n.scrollToField = (e, r) => {
56
+ const a = p.current, b = o.id;
57
+ if (!a)
59
58
  return;
60
- let c = r.querySelector(
61
- `#${f(i, o)}`
59
+ let m = a.querySelector(
60
+ `#${u(b, e)}`
62
61
  );
63
- c || (c = r.querySelector(
64
- `#${f(i, o)}${ee}`
65
- )), c && O(c, {
62
+ m || (m = a.querySelector(
63
+ `#${u(b, e)}${L}`
64
+ )), m && q(m, {
66
65
  behavior: "smooth",
67
66
  block: "nearest",
68
67
  scrollMode: "if-needed",
69
- ...s
68
+ ...r
70
69
  });
71
- }, C.innerSetCallbacks({
72
- onValuesChange: (o, s) => {
73
- var r, i;
74
- (r = e.onValuesChange) == null || r.call(e, o, s), (i = t.onFormValuesChange) == null || i.call(t, e.id, o);
70
+ }, F.innerSetCallbacks({
71
+ onValuesChange: (e, r) => {
72
+ o.onValuesChange?.(e, r), s.onFormValuesChange?.(o.id, e);
75
73
  },
76
- onChange: e.onChange,
77
- onValidateFail: (o) => {
78
- const s = e.scrollToFirstError;
79
- if (s) {
80
- const r = A(s) ? s : {};
81
- l.scrollToField(
82
- Object.keys(o)[0],
83
- r
74
+ onChange: o.onChange,
75
+ onValidateFail: (e) => {
76
+ const r = o.scrollToFirstError;
77
+ if (r) {
78
+ const a = D(r) ? r : {};
79
+ n.scrollToField(
80
+ Object.keys(e)[0],
81
+ a
84
82
  );
85
83
  }
86
84
  },
87
- onSubmitFailed: e.onSubmitFailed,
88
- onSubmit: (o) => {
89
- var r, i;
90
- const s = (r = e.onSubmit) == null ? void 0 : r.call(e, o);
91
- return (i = t.onFormSubmit) == null || i.call(t, e.id, o), s;
85
+ onSubmitFailed: o.onSubmitFailed,
86
+ onSubmit: (e) => {
87
+ const r = o.onSubmit?.(e);
88
+ return s.onFormSubmit?.(o.id, e), r;
92
89
  },
93
- onReset: (o) => {
94
- var r, i;
95
- const s = (r = e.onReset) == null ? void 0 : r.call(e, o);
96
- return (i = t == null ? void 0 : t.onFormReset) == null || i.call(t, e.id, o), s;
90
+ onReset: (e) => {
91
+ const r = o.onReset?.(e);
92
+ return s?.onFormReset?.(o.id, e), r;
97
93
  }
98
94
  });
99
- const v = {
100
- requiredSymbol: M,
101
- labelAlign: N,
102
- disabled: z,
103
- colon: T,
104
- labelCol: R,
105
- wrapperCol: w,
106
- layout: g,
107
- store: l,
108
- prefixCls: m,
109
- validateTrigger: P,
110
- validateMessages: _(
95
+ const T = {
96
+ requiredSymbol: $,
97
+ labelAlign: v,
98
+ disabled: y,
99
+ colon: V,
100
+ labelCol: S,
101
+ wrapperCol: x,
102
+ layout: f,
103
+ store: n,
104
+ prefixCls: l,
105
+ validateTrigger: w,
106
+ validateMessages: j(
111
107
  {},
112
- (y = ($ = n.locale) == null ? void 0 : $.Form) == null ? void 0 : y.validateMessages,
113
- D
108
+ t.locale?.Form?.validateMessages,
109
+ M
114
110
  ),
115
- getFormElementId: (o) => f(F, o)
116
- }, x = Y;
117
- return X(u, () => ({
118
- ...l,
111
+ getFormElementId: (e) => u(g, e)
112
+ }, E = J;
113
+ return _(c, () => ({
114
+ ...n,
119
115
  getRootDOMNode() {
120
116
  return p.current;
121
117
  }
122
- })), /* @__PURE__ */ d(B, { ...n, childrenName: "Form", size: b, children: /* @__PURE__ */ d(x.Provider, { value: v, children: /* @__PURE__ */ d(
123
- I,
118
+ })), /* @__PURE__ */ d(H, { ...t, childrenName: "Form", size: C, children: /* @__PURE__ */ d(E.Provider, { value: T, children: /* @__PURE__ */ d(
119
+ P,
124
120
  {
125
121
  ref: p,
126
- ...L(j, [
122
+ ...B(N, [
127
123
  "form",
128
124
  "size",
129
125
  "initialValues",
@@ -135,27 +131,27 @@ const re = {
135
131
  "onSubmitFailed",
136
132
  "onReset"
137
133
  ]),
138
- ...e.wrapperProps,
139
- className: K(
140
- m,
141
- `${m}-${g}`,
142
- `${m}-size-${b}`,
143
- { [`${m}-rtl`]: k },
144
- E
134
+ ...o.wrapperProps,
135
+ className: X(
136
+ l,
137
+ `${l}-${f}`,
138
+ `${l}-size-${C}`,
139
+ { [`${l}-rtl`]: z },
140
+ R
145
141
  ),
146
- style: e.style,
147
- onSubmit: (o) => {
148
- o.preventDefault(), o.stopPropagation(), l.submit();
142
+ style: o.style,
143
+ onSubmit: (e) => {
144
+ e.preventDefault(), e.stopPropagation(), n.submit();
149
145
  },
150
- onReset: (o) => {
151
- o.preventDefault(), o.stopPropagation(), l.resetFields();
146
+ onReset: (e) => {
147
+ e.preventDefault(), e.stopPropagation(), n.resetFields();
152
148
  },
153
- id: F,
154
- children: e.children
149
+ id: g,
150
+ children: o.children
155
151
  }
156
152
  ) }) });
157
- }, ne = H(te);
158
- ne.displayName = "Form";
153
+ }, ee = k(Z);
154
+ ee.displayName = "Form";
159
155
  export {
160
- ne as default
156
+ ee as default
161
157
  };
package/form/FormItem.js CHANGED
@@ -1,39 +1,39 @@
1
- import { jsx as i, jsxs as q, Fragment as pe } from "react/jsx-runtime";
2
- import L, { forwardRef as ue, useContext as N, useState as W, useRef as fe, useEffect as be, useMemo as G, createElement as K, cloneElement as B } from "react";
3
- import he from "lodash/isArray";
4
- import ge from "lodash/isFunction";
5
- import v from "lodash/isPlainObject";
6
- import F from "lodash/isUndefined";
1
+ import { jsx as i, jsxs as E, Fragment as ie } from "react/jsx-runtime";
2
+ import V, { forwardRef as ae, useContext as F, useState as O, useRef as me, useEffect as de, useMemo as U, createElement as _, cloneElement as z } from "react";
3
+ import ce from "lodash/isArray";
4
+ import pe from "lodash/isFunction";
5
+ import h from "lodash/isPlainObject";
6
+ import y from "lodash/isUndefined";
7
7
  import "../config-provider/ConfigProvider.js";
8
- import Y from "../grid/index.js";
9
- import Ce from "../components/common/hooks/useMergeProps.js";
10
- import { PqbCSSTransition as ye } from "../components/common/utils/PqbCSSTransition.js";
11
- import w from "@unicom-cloud/utils/class-name";
12
- import { omit as ve } from "../components/common/utils/omit.js";
13
- import S from "./Control.js";
14
- import we from "./FormLabel.js";
15
- import { FormItemContext as J, FormListContext as Fe, FormContext as Q } from "./context.js";
16
- import { VALIDATE_STATUS as T } from "./interface.js";
17
- import { formatValidateMsg as $e } from "./util.js";
18
- import Ie from "../config-provider/context.js";
19
- const Ne = Y.Row, X = Y.Col, Se = ({
20
- prefixCls: h,
21
- help: g,
8
+ import K from "../grid/index.js";
9
+ import ue from "../components/common/hooks/useMergeProps.js";
10
+ import { PqbCSSTransition as fe } from "../components/common/utils/PqbCSSTransition.js";
11
+ import C from "@unicom-cloud/utils/class-name";
12
+ import { omit as be } from "../components/common/utils/omit.js";
13
+ import $ from "./Control.js";
14
+ import ge from "./FormLabel.js";
15
+ import { FormItemContext as H, FormListContext as he, FormContext as W } from "./context.js";
16
+ import { VALIDATE_STATUS as k } from "./interface.js";
17
+ import { formatValidateMsg as Ce } from "./util.js";
18
+ import ye from "../config-provider/context.js";
19
+ const xe = K.Row, G = K.Col, ve = ({
20
+ prefixCls: f,
21
+ help: b,
22
22
  errors: e,
23
- warnings: C
23
+ warnings: I
24
24
  }) => {
25
- const y = e.map((p, d) => {
25
+ const g = e.map((p, d) => {
26
26
  if (p)
27
27
  return /* @__PURE__ */ i("div", { role: "alert", children: p.message }, d);
28
28
  }), c = [];
29
- C.map((p, d) => {
29
+ I.map((p, d) => {
30
30
  c.push(
31
- /* @__PURE__ */ i("div", { role: "alert", className: `${h}-message-help-warning`, children: p }, d)
31
+ /* @__PURE__ */ i("div", { role: "alert", className: `${f}-message-help-warning`, children: p }, d)
32
32
  );
33
33
  });
34
- const m = !F(g) || !!c.length, u = m || !!y.length;
34
+ const x = !y(b) || !!c.length, u = x || !!g.length;
35
35
  return u && /* @__PURE__ */ i(
36
- ye,
36
+ fe,
37
37
  {
38
38
  in: u,
39
39
  appear: !0,
@@ -43,111 +43,109 @@ const Ne = Y.Row, X = Y.Col, Se = ({
43
43
  children: /* @__PURE__ */ i(
44
44
  "div",
45
45
  {
46
- className: w(`${h}-message`, {
47
- [`${h}-message-help`]: m
46
+ className: C(`${f}-message`, {
47
+ [`${f}-message-help`]: x
48
48
  }),
49
- children: F(g) ? /* @__PURE__ */ q(pe, { children: [
50
- y.length > 0 && y,
49
+ children: y(b) ? /* @__PURE__ */ E(ie, { children: [
50
+ g.length > 0 && g,
51
51
  c.length > 0 && c
52
- ] }) : g
52
+ ] }) : b
53
53
  }
54
54
  )
55
55
  }
56
56
  );
57
- }, xe = {
57
+ }, we = {
58
58
  trigger: "onChange",
59
59
  triggerPropName: "value"
60
- }, ke = (h, g) => {
61
- var U, _, z;
62
- const e = Ce(h, xe), { getPrefixCls: C, prefixCls: y } = N(Ie), c = N(J), m = N(Fe), [u, p] = W(null), [d, A] = W(null), r = N(Q), l = r.prefixCls || (C == null ? void 0 : C("form")), D = e.layout || r.layout, Z = e.labelAlign || r.labelAlign, x = fe(!1), ee = (n, t = {}) => {
63
- if (x.current)
60
+ }, Fe = (f, b) => {
61
+ const e = ue(f, we), { getPrefixCls: I, prefixCls: g } = F(ye), c = F(H), x = F(he), [u, p] = O(null), [d, T] = O(null), r = F(W), l = r.prefixCls || I?.("form"), q = e.layout || r.layout, B = e.labelAlign || r.labelAlign, N = me(!1), J = (n, t = {}) => {
62
+ if (N.current)
64
63
  return;
65
- const { errors: a, warnings: f } = t || {};
66
- p((b) => {
67
- const o = { ...b || {} };
68
- return a ? o[n] = a : delete o[n], o;
69
- }), A((b) => {
70
- const o = { ...b || {} };
71
- return f && f.length ? o[n] = f : delete o[n], o;
64
+ const { errors: m, warnings: s } = t || {};
65
+ p((o) => {
66
+ const a = { ...o || {} };
67
+ return m ? a[n] = m : delete a[n], a;
68
+ }), T((o) => {
69
+ const a = { ...o || {} };
70
+ return s && s.length ? a[n] = s : delete a[n], a;
72
71
  });
73
- }, re = v(e.noStyle) && e.noStyle.showErrorTip && c.updateFormItem ? c.updateFormItem : ee;
74
- be(() => (x.current = !1, () => {
75
- x.current = !0, p(null), A(null);
72
+ }, Q = h(e.noStyle) && e.noStyle.showErrorTip && c.updateFormItem ? c.updateFormItem : J;
73
+ de(() => (N.current = !1, () => {
74
+ N.current = !0, p(null), T(null);
76
75
  }), []);
77
- const te = {
76
+ const X = {
78
77
  ...r,
79
- validateMessages: r.validateMessages && $e(r.validateMessages, {
78
+ validateMessages: r.validateMessages && Ce(r.validateMessages, {
80
79
  label: e.label
81
80
  }),
82
81
  prefixCls: l,
83
- updateFormItem: re,
82
+ updateFormItem: Q,
84
83
  disabled: "disabled" in e ? e.disabled : r.disabled
85
- }, { label: M, extra: j, className: oe, style: le, validateStatus: $, hidden: ne, ...se } = e, ie = w(`${l}-label-item`, {
86
- [`${l}-label-item-left`]: Z === "left"
87
- }), R = u ? Object.values(u) : [], k = d ? Object.values(d).reduce((n, t) => n.concat(t), []) : [], I = G(() => {
88
- if ($)
89
- return $;
90
- if (R.length)
91
- return T.error;
92
- if (k.length)
93
- return T.warning;
94
- }, [u, d, $]), V = G(() => !F(e.help) || k.length > 0, [e.help, d]), ae = w(
84
+ }, { label: A, extra: D, className: Y, style: Z, validateStatus: v, hidden: ee, ...re } = e, te = C(`${l}-label-item`, {
85
+ [`${l}-label-item-left`]: B === "left"
86
+ }), L = u ? Object.values(u) : [], S = d ? Object.values(d).reduce((n, t) => n.concat(t), []) : [], w = U(() => {
87
+ if (v)
88
+ return v;
89
+ if (L.length)
90
+ return k.error;
91
+ if (S.length)
92
+ return k.warning;
93
+ }, [u, d, v]), M = U(() => !y(e.help) || S.length > 0, [e.help, d]), oe = C(
95
94
  `${l}-item`,
96
95
  {
97
- [`${l}-item-error`]: V || !$ && I === T.error,
98
- [`${l}-item-status-${I}`]: I,
99
- [`${l}-item-has-help`]: V,
100
- [`${l}-item-hidden`]: ne,
101
- [`${l}-item-has-feedback`]: I && e.hasFeedback
96
+ [`${l}-item-error`]: M || !v && w === k.error,
97
+ [`${l}-item-status-${w}`]: w,
98
+ [`${l}-item-has-help`]: M,
99
+ [`${l}-item-hidden`]: ee,
100
+ [`${l}-item-has-feedback`]: w && e.hasFeedback
102
101
  },
103
- `${l}-layout-${D}`,
104
- oe
105
- ), O = () => {
106
- var f, b;
107
- const { field: n, children: t } = e, a = "disabled" in e ? e.disabled : r.disabled;
108
- if (ge(t)) {
109
- const { key: o, ...s } = e ?? {};
110
- return /* @__PURE__ */ K(
111
- S,
102
+ `${l}-layout-${q}`,
103
+ Y
104
+ ), j = () => {
105
+ const { field: n, children: t } = e, m = "disabled" in e ? e.disabled : r.disabled;
106
+ if (pe(t)) {
107
+ const { key: s, ...o } = e ?? {};
108
+ return /* @__PURE__ */ _(
109
+ $,
112
110
  {
113
- disabled: a,
114
- ...s,
115
- key: n || o,
116
- _key: n || o
111
+ disabled: m,
112
+ ...o,
113
+ key: n || s,
114
+ _key: n || s
117
115
  },
118
- (...P) => t(
119
- ...P
116
+ (...a) => t(
117
+ ...a
120
118
  )
121
119
  );
122
120
  }
123
- if (he(t)) {
124
- const o = L.Children.map(t, (s, P) => {
125
- const H = v(s) && s.key || P, de = v(s) && "disabled" in s.props, ce = !F(a) && !de ? { key: H, disabled: a } : { key: H };
126
- return v(s) ? B(s, ce) : s;
121
+ if (ce(t)) {
122
+ const s = V.Children.map(t, (o, a) => {
123
+ const R = h(o) && o.key || a, ne = h(o) && "disabled" in o.props, se = !y(m) && !ne ? { key: R, disabled: m } : { key: R };
124
+ return h(o) ? z(o, se) : o;
127
125
  });
128
- return /* @__PURE__ */ i(S, { ...e, field: void 0, children: o });
126
+ return /* @__PURE__ */ i($, { ...e, field: void 0, children: s });
129
127
  }
130
- if (L.Children.count(t) == 1) {
128
+ if (V.Children.count(t) == 1) {
131
129
  if (n) {
132
- const o = ((f = m == null ? void 0 : m.getItemKey) == null ? void 0 : f.call(m, n)) || n;
133
- return /* @__PURE__ */ K(S, { disabled: a, ...e, key: o, _key: o }, t);
130
+ const s = x?.getItemKey?.(n) || n;
131
+ return /* @__PURE__ */ _($, { disabled: m, ...e, key: s, _key: s }, t);
134
132
  }
135
- if (v(t)) {
136
- if ((b = t.type) != null && b.isFormControl)
133
+ if (h(t)) {
134
+ if (t.type?.isFormControl)
137
135
  return t;
138
- const s = !("disabled" in t.props) && !F(a) ? { disabled: a } : null;
139
- return /* @__PURE__ */ i(S, { ...e, field: void 0, children: s ? B(t, s) : t });
136
+ const o = !("disabled" in t.props) && !y(m) ? { disabled: m } : null;
137
+ return /* @__PURE__ */ i($, { ...e, field: void 0, children: o ? z(t, o) : t });
140
138
  }
141
139
  }
142
140
  return t;
143
- }, me = J, E = {
141
+ }, le = H, P = {
144
142
  ...r
145
143
  };
146
- return e.noStyle || (E.wrapperCol = void 0, E.labelCol = void 0), /* @__PURE__ */ i(Q.Provider, { value: E, children: /* @__PURE__ */ i(me.Provider, { value: te, children: e.noStyle ? O() : /* @__PURE__ */ q(
147
- Ne,
144
+ return e.noStyle || (P.wrapperCol = void 0, P.labelCol = void 0), /* @__PURE__ */ i(W.Provider, { value: P, children: /* @__PURE__ */ i(le.Provider, { value: X, children: e.noStyle ? j() : /* @__PURE__ */ E(
145
+ xe,
148
146
  {
149
- ref: g,
150
- ...ve(se, [
147
+ ref: b,
148
+ ...be(re, [
151
149
  "tooltip",
152
150
  "children",
153
151
  "prefixCls",
@@ -177,29 +175,29 @@ const Ne = Y.Row, X = Y.Col, Se = ({
177
175
  "requiredSymbol",
178
176
  "isFormList"
179
177
  ]),
180
- className: ae,
181
- div: D !== "horizontal",
182
- style: le,
178
+ className: oe,
179
+ div: q !== "horizontal",
180
+ style: Z,
183
181
  children: [
184
- M ? /* @__PURE__ */ i(
185
- X,
182
+ A ? /* @__PURE__ */ i(
183
+ G,
186
184
  {
187
185
  ...e.labelCol || r.labelCol,
188
- className: w(
189
- ie,
190
- (U = e.labelCol) == null ? void 0 : U.className,
191
- (_ = r.labelCol) == null ? void 0 : _.className,
186
+ className: C(
187
+ te,
188
+ e.labelCol?.className,
189
+ r.labelCol?.className,
192
190
  {
193
191
  [`${l}-label-item-flex`]: !e.labelCol && !r.labelCol
194
192
  }
195
193
  ),
196
194
  children: /* @__PURE__ */ i(
197
- we,
195
+ ge,
198
196
  {
199
197
  tooltip: e.tooltip,
200
- htmlFor: e.field && ((z = r == null ? void 0 : r.getFormElementId) == null ? void 0 : z.call(r, e.field)),
201
- label: M,
202
- prefix: y,
198
+ htmlFor: e.field && r?.getFormElementId?.(e.field),
199
+ label: A,
200
+ prefix: g,
203
201
  requiredSymbol: "requiredSymbol" in e ? e.requiredSymbol : r.requiredSymbol,
204
202
  required: e.required,
205
203
  rules: e.rules,
@@ -208,33 +206,33 @@ const Ne = Y.Row, X = Y.Col, Se = ({
208
206
  )
209
207
  }
210
208
  ) : null,
211
- /* @__PURE__ */ q(
212
- X,
209
+ /* @__PURE__ */ E(
210
+ G,
213
211
  {
214
- className: w(`${l}-item-wrapper`, {
212
+ className: C(`${l}-item-wrapper`, {
215
213
  [`${l}-item-wrapper-flex`]: !e.wrapperCol && !r.wrapperCol
216
214
  }),
217
215
  ...e.wrapperCol || r.wrapperCol,
218
216
  children: [
219
- O(),
217
+ j(),
220
218
  /* @__PURE__ */ i(
221
- Se,
219
+ ve,
222
220
  {
223
221
  prefixCls: l,
224
222
  help: e.help,
225
- errors: R,
226
- warnings: k
223
+ errors: L,
224
+ warnings: S
227
225
  }
228
226
  ),
229
- j && /* @__PURE__ */ i("div", { className: `${l}-extra`, children: j })
227
+ D && /* @__PURE__ */ i("div", { className: `${l}-extra`, children: D })
230
228
  ]
231
229
  }
232
230
  )
233
231
  ]
234
232
  }
235
233
  ) }) });
236
- }, Ee = ue(ke);
237
- Ee.displayName = "FormItem";
234
+ }, $e = ae(Fe);
235
+ $e.displayName = "FormItem";
238
236
  export {
239
- Ee as default
237
+ $e as default
240
238
  };