@unicom-cloud/ui 0.8.66 → 0.8.67

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 (357) hide show
  1. package/Affix.js +79 -79
  2. package/Alert.js +46 -46
  3. package/Anchor.js +1 -1
  4. package/AutoComplete.js +74 -74
  5. package/Avatar.js +36 -36
  6. package/BackTop.js +35 -35
  7. package/Badge.js +55 -55
  8. package/Breadcrumb.js +42 -42
  9. package/Button.js +24 -24
  10. package/Calendar.js +230 -230
  11. package/Card.js +18 -18
  12. package/Carousel.js +165 -165
  13. package/Cascader.js +1 -1
  14. package/Checkbox.js +1 -1
  15. package/Collapse.js +1 -1
  16. package/ColorPicker.js +26 -26
  17. package/Comment.js +18 -18
  18. package/ConfigProvider.js +2 -2
  19. package/Copy.js +28 -27
  20. package/DatePicker.js +872 -871
  21. package/Descriptions.js +34 -34
  22. package/Divider.js +19 -19
  23. package/Draggable.js +27 -26
  24. package/Drawer.js +1 -1
  25. package/Dropdown.js +110 -110
  26. package/Empty.js +3 -3
  27. package/Form.js +984 -945
  28. package/Grid.js +34 -34
  29. package/Icon.js +16 -16
  30. package/IconHover.js +2 -2
  31. package/Image.js +2 -2
  32. package/Input.js +7 -6
  33. package/InputNumber.js +6 -6
  34. package/InputTag.js +1 -1
  35. package/Layout.js +24 -24
  36. package/Link.js +30 -30
  37. package/List.js +95 -95
  38. package/Mentions.js +85 -84
  39. package/Menu.js +2 -2
  40. package/Message.js +7 -6
  41. package/Modal.js +1 -1
  42. package/Notice.js +14 -3
  43. package/Notification.js +9 -7
  44. package/OverflowEllipsis.js +64 -62
  45. package/PageHeader.js +73 -73
  46. package/Pagination.js +1 -1
  47. package/Picker.js +1 -1
  48. package/Popconfirm.js +60 -60
  49. package/Popover.js +31 -31
  50. package/Portal.js +23 -31
  51. package/Progress.js +22 -22
  52. package/Radio.js +2 -2
  53. package/Rate.js +24 -24
  54. package/ResizeBox.js +274 -271
  55. package/Result.js +3 -3
  56. package/Select.js +4 -4
  57. package/SelectView.js +257 -238
  58. package/Skeleton.js +46 -46
  59. package/Slider.js +286 -283
  60. package/Space.js +28 -28
  61. package/SpeechSynthesis.js +62 -55
  62. package/Spin.js +23 -23
  63. package/Statistic.js +80 -80
  64. package/Steps.js +67 -67
  65. package/Switch.js +47 -47
  66. package/Table.js +1445 -1380
  67. package/Tabs.js +5 -5
  68. package/Tag.js +45 -45
  69. package/TimePicker.js +154 -154
  70. package/Timeline.js +2 -2
  71. package/Tooltip.js +80 -79
  72. package/Transfer.js +103 -102
  73. package/Tree.js +3 -2
  74. package/TreeSelect.js +2 -2
  75. package/Trigger.js +699 -772
  76. package/Typography.js +756 -6
  77. package/Upload.js +2 -2
  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/{BHgJ5Y3T.js → -UuKKT0Z.js} +29 -29
  83. package/chunk/{B8QV6E2b.js → AwZqeapI.js} +5 -5
  84. package/chunk/B5gK1Idp.js +19 -0
  85. package/chunk/B7FlazNB.js +24 -0
  86. package/chunk/{DTBtQQ2H.js → BBvWDeuZ.js} +67 -67
  87. package/chunk/BCftTxEy.js +626 -0
  88. package/chunk/{CZOP_ZHJ.js → BGny4zSb.js} +60 -60
  89. package/chunk/BHF15Dog.js +98 -0
  90. package/chunk/BJQ5UNa-.js +1585 -0
  91. package/chunk/BP9sYyk9.js +8 -0
  92. package/chunk/BUdtVdnv.js +38 -0
  93. package/chunk/BVQlOzTS.js +11 -0
  94. package/chunk/B__a_gb_.js +519 -0
  95. package/chunk/BbEYToV1.js +10 -0
  96. package/chunk/BbdDQAnm.js +15 -0
  97. package/chunk/BdUcgWdu.js +11 -0
  98. package/chunk/BfbXSG70.js +26 -0
  99. package/chunk/BndfNLK4.js +186 -0
  100. package/chunk/BoMCZV6K.js +1098 -0
  101. package/chunk/Br0B6y1T.js +18 -0
  102. package/chunk/BrOW642m.js +130 -0
  103. package/chunk/BxUs8_Cr.js +9 -0
  104. package/chunk/{CcV4wQB1.js → C42LIMP9.js} +244 -242
  105. package/chunk/C4YkFMzC.js +778 -0
  106. package/chunk/{Bh23P4l7.js → C9Wcraj7.js} +21 -21
  107. package/chunk/{4-gvEY5y.js → CANgSlh3.js} +10 -10
  108. package/chunk/CJ_o9tZM.js +5 -0
  109. package/chunk/{DNAigumg.js → CK5m7rLl.js} +36 -36
  110. package/chunk/{CANaGbGR.js → CKNyIitu.js} +57 -56
  111. package/chunk/CLiqJm_T.js +10 -0
  112. package/chunk/{BnSVm1YC.js → CNmmhbCn.js} +32 -32
  113. package/chunk/{BFipyA67.js → CP0odX99.js} +51 -51
  114. package/chunk/CPT-OZH2.js +14 -0
  115. package/chunk/CVSF8p0O.js +698 -0
  116. package/chunk/C_agcwLN.js +31 -0
  117. package/chunk/{jhQQCFMn.js → C_gJWGGh.js} +201 -201
  118. package/chunk/{Bc7t9jkb.js → CaasmWg_.js} +11 -11
  119. package/chunk/Ce1j9KTi.js +6 -0
  120. package/chunk/{D_-UD4vO.js → Cf5QNhkG.js} +18 -18
  121. package/chunk/CkNSv2U7.js +56 -0
  122. package/chunk/Cp2f70gB.js +9 -0
  123. package/chunk/CpegYjdC.js +16 -0
  124. package/chunk/CucI3KZr.js +20 -0
  125. package/chunk/CwoFBTYz.js +11 -0
  126. package/chunk/D2KPqPhV.js +17 -0
  127. package/chunk/D7NyvE5f.js +17 -0
  128. package/chunk/D8oTPQ2H.js +384 -0
  129. package/chunk/{CLBavO5c.js → DC1iHEiy.js} +87 -87
  130. package/chunk/{DnvO8A0Z.js → DFrfrmfK.js} +120 -119
  131. package/chunk/DGTIZ_0O.js +6 -0
  132. package/chunk/DJfpiZn_.js +25 -0
  133. package/chunk/DKr2_PYd.js +34 -0
  134. package/chunk/DNUz6zgo.js +11 -0
  135. package/chunk/DRtM649q.js +11 -0
  136. package/chunk/DS_mUWn6.js +41 -0
  137. package/chunk/DU6bs_19.js +10 -0
  138. package/chunk/DWdbwz22.js +10 -0
  139. package/chunk/DcveZuqd.js +6 -0
  140. package/chunk/DdVFknul.js +24 -0
  141. package/chunk/DgRfikwe.js +16 -0
  142. package/chunk/{znkyQ-HR.js → DkyR2EfG.js} +66 -66
  143. package/chunk/{DUeHQKtx.js → DleQ5HwG.js} +42 -42
  144. package/chunk/DnrZEnQ_.js +27 -0
  145. package/chunk/DsRSHWtX.js +1025 -0
  146. package/chunk/Dz5BdmXo.js +270 -0
  147. package/chunk/EANe01DF.js +1030 -0
  148. package/chunk/{CwhPMMWy.js → Ey4YJCkX.js} +7 -7
  149. package/chunk/GoNx5R4F.js +873 -0
  150. package/chunk/HDUQku8d.js +20 -0
  151. package/chunk/HrAP__Hi.js +25 -0
  152. package/chunk/JPPo5nY_.js +9 -0
  153. package/chunk/{Du-bw6qA.js → SLWP34OR.js} +90 -85
  154. package/chunk/VVKtwaGf.js +278 -0
  155. package/chunk/WPNpLxSI.js +16 -0
  156. package/chunk/{CPvvjMwZ.js → WpO_DsK4.js} +49 -48
  157. package/chunk/fdU3ang6.js +14 -0
  158. package/chunk/{DQAot004.js → fkclKOAL.js} +298 -292
  159. package/chunk/flvYlqx3.js +22 -0
  160. package/chunk/kTDayEpF.js +288 -0
  161. package/chunk/{CssIjN1g.js → pZoNQ75H.js} +31 -31
  162. package/chunk/qFf1w_Jq.js +8 -0
  163. package/chunk/{CHnFKgbk.js → w-kM1L5W.js} +155 -155
  164. package/hooks/index.js +53 -49
  165. package/hooks/useComputedState.js +2 -10
  166. package/hooks/useCreate.js +2 -7
  167. package/hooks/useForceUpdate.js +2 -7
  168. package/hooks/useId.js +2 -10
  169. package/hooks/useInView.js +2 -30
  170. package/hooks/useIntersectionObserver.js +2 -23
  171. package/hooks/useInterval.js +2 -17
  172. package/hooks/useIsFirstRender.js +2 -9
  173. package/hooks/useIsomorphicLayoutEffect.js +2 -5
  174. package/hooks/useKeyboardEvent.js +2 -16
  175. package/hooks/useMedia.js +2 -15
  176. package/hooks/useMergeProps.js +2 -18
  177. package/hooks/useMergeValue.js +2 -19
  178. package/hooks/useOnlineStatus.js +4 -0
  179. package/hooks/useOverflowHidden.js +2 -25
  180. package/hooks/useOverrideRef.js +2 -13
  181. package/hooks/usePersistCallback.js +2 -13
  182. package/hooks/usePrefersColorSchemeDark.js +4 -0
  183. package/hooks/usePrevious.js +2 -9
  184. package/hooks/useRefs.js +2 -9
  185. package/hooks/useResizeObserver.js +2 -15
  186. package/hooks/useStateCallback.js +2 -15
  187. package/hooks/useStateWithPromise.js +2 -24
  188. package/hooks/useUpdateEffect.js +2 -9
  189. package/hooks/useVerificationCode.js +73 -0
  190. package/hooks/useWatch.js +2 -10
  191. package/hooks/{use-watermark.js → useWatermark.js} +27 -26
  192. package/hooks/useWindowSize.js +2 -20
  193. package/index.js +571 -584
  194. package/locale/en-US.js +4 -2
  195. package/locale/interface.js +1 -4
  196. package/locale/ja-JP.js +3 -1
  197. package/locale/tr-TR.js +1 -1
  198. package/locale/zh-CN.js +3 -1
  199. package/locale/zh-HK.js +3 -1
  200. package/locale/zh-TW.js +3 -1
  201. package/package.json +1 -1
  202. package/style.css +1 -1
  203. package/types/anchor/util.d.ts +1 -1
  204. package/types/button/index.d.ts +2 -2
  205. package/types/color-picker/hooks/useColorPicker.d.ts +2 -2
  206. package/types/form/Control-old.d.ts +56 -0
  207. package/types/form/Control.d.ts +6 -54
  208. package/types/form/FormItem.d.ts +1 -1
  209. package/types/form/store.d.ts +0 -1
  210. package/types/hooks/index.d.ts +2 -0
  211. package/types/hooks/useComputedState.d.ts +1 -4
  212. package/types/hooks/useCreate.d.ts +1 -2
  213. package/types/hooks/useForceUpdate.d.ts +1 -2
  214. package/types/hooks/useId.d.ts +1 -2
  215. package/types/hooks/useInView.d.ts +1 -11
  216. package/types/hooks/useIntersectionObserver.d.ts +1 -7
  217. package/types/hooks/useInterval.d.ts +1 -2
  218. package/types/hooks/useIsFirstRender.d.ts +1 -2
  219. package/types/hooks/useIsomorphicLayoutEffect.d.ts +1 -3
  220. package/types/hooks/useKeyboardEvent.d.ts +1 -8
  221. package/types/hooks/useMedia.d.ts +1 -2
  222. package/types/hooks/useMergeProps.d.ts +1 -5
  223. package/types/hooks/useMergeValue.d.ts +1 -6
  224. package/types/hooks/useOnlineStatus.d.ts +1 -0
  225. package/types/hooks/useOverflowHidden.d.ts +1 -5
  226. package/types/hooks/useOverrideRef.d.ts +1 -6
  227. package/types/hooks/usePersistCallback.d.ts +1 -2
  228. package/types/hooks/usePrefersColorSchemeDark.d.ts +1 -0
  229. package/types/hooks/usePrevious.d.ts +1 -3
  230. package/types/hooks/useRefs.d.ts +1 -2
  231. package/types/hooks/useResizeObserver.d.ts +1 -6
  232. package/types/hooks/useStateCallback.d.ts +1 -5
  233. package/types/hooks/useStateWithPromise.d.ts +1 -2
  234. package/types/hooks/useUpdateEffect.d.ts +1 -3
  235. package/types/hooks/useWatch.d.ts +1 -3
  236. package/types/hooks/useWindowSize.d.ts +1 -5
  237. package/types/image/interface.d.ts +1 -0
  238. package/types/index.d.ts +157 -86
  239. package/types/input/Input.d.ts +1 -1
  240. package/types/input/Textarea.d.ts +2 -2
  241. package/types/locale/en-US.d.ts +2 -0
  242. package/types/locale/interface.d.ts +1 -2
  243. package/types/locale/ja-JP.d.ts +2 -0
  244. package/types/locale/zh-CN.d.ts +2 -0
  245. package/types/locale/zh-HK.d.ts +2 -0
  246. package/types/locale/zh-TW.d.ts +2 -0
  247. package/types/menu/context.d.ts +1 -1
  248. package/types/message/index.d.ts +14 -14
  249. package/types/message/interface.d.ts +2 -0
  250. package/types/modal/config.d.ts +0 -1
  251. package/types/modal/interface.d.ts +0 -1
  252. package/types/notice/index.d.ts +2 -27
  253. package/types/notification/index.d.ts +15 -16
  254. package/types/notification/interface.d.ts +2 -0
  255. package/types/notification/withNotification.d.ts +2 -0
  256. package/types/select/util.d.ts +1 -2
  257. package/types/select-view/interface.d.ts +2 -1
  258. package/types/speech-synthesis/index.d.ts +1 -1
  259. package/types/table/constant.d.ts +2 -0
  260. package/types/table/hook/useThResizable.d.ts +7 -0
  261. package/types/table/index.d.ts +10 -1
  262. package/types/table/style/index.d.ts +1 -0
  263. package/types/table/th-resizable/index.d.ts +2 -0
  264. package/types/table/thead/Column.d.ts +1 -2
  265. package/types/tree/Tree.d.ts +12 -67
  266. package/types/tree-select/Select.d.ts +2 -2
  267. package/types/trigger/index.d.ts +2 -120
  268. package/types/trigger/interface.d.ts +2 -1
  269. package/types/utils/CSSTransition.d.ts +2 -3
  270. package/types/utils/caseName.d.ts +1 -1
  271. package/types/utils/className.d.ts +1 -1
  272. package/types/utils/constant.d.ts +2 -2
  273. package/types/utils/copy.d.ts +1 -1
  274. package/types/utils/dayjs.d.ts +1 -21
  275. package/types/utils/dom.d.ts +1 -6
  276. package/types/utils/fileToURL.d.ts +1 -1
  277. package/types/utils/fillNBSP.d.ts +1 -1
  278. package/types/utils/getHighlightText.d.ts +1 -5
  279. package/types/utils/getHotkeyHandler.d.ts +1 -8
  280. package/types/utils/getStringLength.d.ts +1 -1
  281. package/types/utils/include.d.ts +1 -1
  282. package/types/utils/index.d.ts +3 -4
  283. package/types/utils/is.d.ts +1 -16
  284. package/types/utils/keyboardCode.d.ts +3 -0
  285. package/types/utils/lodash.d.ts +1 -17
  286. package/types/utils/mergeProps.d.ts +1 -1
  287. package/types/utils/mergedToString.d.ts +1 -1
  288. package/types/utils/omit.d.ts +1 -1
  289. package/types/utils/pad.d.ts +1 -2
  290. package/types/utils/pick.d.ts +2 -4
  291. package/types/utils/reactDOM.d.ts +1 -7
  292. package/types/utils/resizeObserverEffect.d.ts +2 -0
  293. package/types/utils/saveAs.d.ts +1 -1
  294. package/types/utils/screenfull.d.ts +2 -0
  295. package/types/utils/scrollIntoView.d.ts +1 -2
  296. package/types/utils/style.d.ts +1 -3
  297. package/types/utils/throttleByRaf.d.ts +1 -5
  298. package/types/utils/throttleByRaf2.d.ts +1 -0
  299. package/types/utils/warning.d.ts +1 -2
  300. package/types/version/index.d.ts +1 -1
  301. package/utils/CSSTransition.js +2 -6
  302. package/utils/className.js +2 -2
  303. package/utils/constant.js +8 -9
  304. package/utils/contextHolder.js +1 -1
  305. package/utils/copy.js +1 -1
  306. package/utils/dayjs.js +14 -173
  307. package/utils/dom.js +33 -29
  308. package/utils/fillNBSP.js +2 -4
  309. package/utils/getHighlightText.js +2 -38
  310. package/utils/getHotkeyHandler.js +2 -25
  311. package/utils/getStringLength.js +2 -7
  312. package/utils/include.js +2 -7
  313. package/utils/index.js +237 -240
  314. package/utils/is.js +116 -156
  315. package/utils/keyboardCode.js +27 -0
  316. package/utils/mergeProps.js +2 -9
  317. package/utils/mergedToString.js +2 -13
  318. package/utils/omit.js +2 -9
  319. package/utils/pad.js +12 -12
  320. package/utils/pick.js +4 -15
  321. package/utils/reactDOM.js +3 -54
  322. package/utils/resizeObserverEffect.js +4 -0
  323. package/utils/saveAs.js +1 -1
  324. package/utils/screenfull.js +4 -0
  325. package/utils/scrollIntoView.js +2 -21
  326. package/utils/style.js +12 -11
  327. package/utils/throttleByRaf.js +13 -12
  328. package/utils/throttleByRaf2.js +5 -0
  329. package/utils/warning.js +5 -4
  330. package/NotificationBase.js +0 -53
  331. package/chunk/-zpSUpGE.js +0 -1501
  332. package/chunk/BAWsPQBM.js +0 -11
  333. package/chunk/BIT0j3HT.js +0 -269
  334. package/chunk/BbLKnaNO.js +0 -871
  335. package/chunk/Bfhv56O2.js +0 -638
  336. package/chunk/C2lIz2F9.js +0 -60
  337. package/chunk/C6QWSzsM.js +0 -376
  338. package/chunk/CVkHTbic.js +0 -995
  339. package/chunk/CeGEvXby.js +0 -278
  340. package/chunk/D3NFxdmG.js +0 -518
  341. package/chunk/DApXtulb.js +0 -1102
  342. package/chunk/DPByB1ab.js +0 -698
  343. package/chunk/DV1Ab_cG.js +0 -284
  344. package/chunk/dBnNCOIU.js +0 -778
  345. package/chunk/it8qlDZ3.js +0 -1032
  346. package/chunk/l0sNRNKZ.js +0 -1
  347. package/chunk/te_43YrB.js +0 -776
  348. package/hooks/use-verification-code.js +0 -73
  349. package/types/notification-base/index.d.ts +0 -15
  350. package/types/notification-base/style/index.d.ts +0 -2
  351. package/types/trigger/Portal.d.ts +0 -7
  352. package/types/utils/keyCode.d.ts +0 -45
  353. package/types/utils/raf.d.ts +0 -3
  354. package/types/utils/throttleByRafV2.d.ts +0 -5
  355. package/utils/keyCode.js +0 -12
  356. package/utils/raf.js +0 -19
  357. package/utils/throttleByRafV2.js +0 -16
package/chunk/CVkHTbic.js DELETED
@@ -1,995 +0,0 @@
1
- var he = Object.defineProperty;
2
- var fe = (r, p, e) => p in r ? he(r, p, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[p] = e;
3
- var y = (r, p, e) => fe(r, typeof p != "symbol" ? p + "" : p, e);
4
- import { jsx as b, jsxs as j, Fragment as pe } from "react/jsx-runtime";
5
- import Y, { createContext as ye, useContext as U, useRef as A, useEffect as ee, useMemo as H, forwardRef as ne, useState as ge, useCallback as V, useImperativeHandle as ue, createElement as q, Component as Ke } from "react";
6
- import { G as ke } from "./CSC_V_25.js";
7
- import O from "lodash/get";
8
- import B from "lodash/has";
9
- import me from "lodash/isArray";
10
- import I from "lodash/isEqualWith";
11
- import $ from "lodash/isFunction";
12
- import te from "lodash/isUndefined";
13
- import { d as z, I as xe } from "./-zpSUpGE.js";
14
- import { y as M } from "./BAWsPQBM.js";
15
- import { pickDataAttributes as Ne } from "../utils/pick.js";
16
- import be from "@unicom-cloud/icons/IconUiCaretDown";
17
- import De from "@unicom-cloud/icons/IconUiDragDotVertical";
18
- import Ce from "@unicom-cloud/icons/IconUiFile";
19
- import Pe from "@unicom-cloud/icons/IconUiLoading";
20
- import { C as Ee } from "./znkyQ-HR.js";
21
- import we from "../utils/throttleByRaf.js";
22
- import Se from "lodash/isNumber";
23
- import { P as _e } from "./CLBavO5c.js";
24
- import { V as ie } from "./D3NFxdmG.js";
25
- import Le from "../utils/scrollIntoView.js";
26
- const G = ye({});
27
- function ve(r) {
28
- return r.key || r._key;
29
- }
30
- const Oe = (r) => {
31
- var g;
32
- const p = U(G), { getPrefixCls: e } = U(z), n = e("tree-node"), { expandedKeys: s, currentExpandKeys: t } = p.getTreeState(), i = r.expanded, a = A(r.childrenData);
33
- a.current = r.childrenData, ee(() => () => {
34
- var l;
35
- (l = p.onExpandEnd) == null || l.call(p, r._key);
36
- }, []);
37
- const d = H(() => {
38
- const l = [], k = (x) => {
39
- x.forEach((m) => {
40
- const c = p.getFieldInfo(m);
41
- l.push(c), c.children && c.children.length && k(c.children);
42
- });
43
- };
44
- return k(a.current || []), l;
45
- }, [i]), o = H(() => {
46
- const l = [];
47
- if (d.length) {
48
- const k = new Set(s || []);
49
- d.forEach((x) => {
50
- var C;
51
- let m;
52
- const c = {
53
- ...p.key2nodeProps[x.key]
54
- };
55
- if (i)
56
- m = c.parentKey === r._key || ((C = c.pathParentKeys) == null ? void 0 : C.every((D) => k.has(D)));
57
- else if (c.pathParentKeys) {
58
- const D = c.pathParentKeys.indexOf(r._key);
59
- m = c.pathParentKeys.slice(D + 1).every((N) => k.has(N));
60
- }
61
- m && l.push({
62
- ...c,
63
- key: x.key
64
- });
65
- });
66
- }
67
- return p.getNodeProps(l);
68
- }, [d, r._key, i, s]);
69
- let u = (g = p.virtualListProps) == null ? void 0 : g.height;
70
- return u = Se(u) ? u : 0, ee(() => {
71
- t.indexOf(r._key) > -1 && o.length === 0 && p.onExpandEnd(r._key);
72
- }, [o, t]), /* @__PURE__ */ b(
73
- _e,
74
- {
75
- in: t.indexOf(r._key) > -1 && o.length > 0,
76
- unmountOnExit: !0,
77
- classNames: "tree-slide-expand",
78
- timeout: {
79
- enter: 200,
80
- exit: 0
81
- },
82
- onEnter: (l) => {
83
- if (!l) return;
84
- const k = l.scrollHeight;
85
- l.style.height = i ? 0 : `${Math.min(u || k, l.scrollHeight)}px`;
86
- },
87
- onEntering: (l) => {
88
- if (!l) return;
89
- const k = l.scrollHeight;
90
- l.style.height = i ? `${Math.min(u || k, k)}px` : 0;
91
- },
92
- onEntered: (l) => {
93
- l && (l.style.height = r.expanded ? "" : 0, p.onExpandEnd(r._key));
94
- },
95
- onExit: (l) => {
96
- l && (l.style.display = "none");
97
- },
98
- children: /* @__PURE__ */ b(
99
- ie,
100
- {
101
- itemKey: ve,
102
- className: `${n}-list`,
103
- isStaticItemHeight: !1,
104
- ...p.virtualListProps,
105
- data: o,
106
- "aria-hidden": !0,
107
- style: { overflow: "hidden" },
108
- children: (l) => {
109
- const { key: k, ...x } = l ?? {};
110
- return /* @__PURE__ */ b(R, { ...x }, k);
111
- }
112
- }
113
- )
114
- }
115
- );
116
- };
117
- function Ie(r, p) {
118
- const e = U(G), { getPrefixCls: n } = U(z), s = A(), [t, i] = ge({
119
- isAllowDrop: !0,
120
- isDragOver: !1,
121
- dragPosition: 0,
122
- isDragging: !1
123
- }), {
124
- _key: a = "",
125
- title: d,
126
- icon: o,
127
- checkable: u,
128
- selected: g,
129
- disabled: l,
130
- disableCheckbox: k,
131
- isLeaf: x,
132
- draggable: m,
133
- expanded: c,
134
- showLine: C,
135
- loading: D,
136
- selectable: N = !0
137
- } = r, h = n("tree-node"), w = M(
138
- h,
139
- {
140
- [`${h}-selected`]: g,
141
- [`${h}-is-leaf`]: x,
142
- [`${h}-expanded`]: c,
143
- [`${h}-disabled-selectable`]: !N,
144
- [`${h}-disabled`]: l,
145
- [`${h}-draggable`]: m
146
- },
147
- r.className
148
- ), S = (() => {
149
- const f = $(e.icons) ? e.icons(r) : e.icons, K = $(r.icons) ? r.icons(r) : r.icons;
150
- return { ...f, ...K };
151
- })(), E = V(
152
- (f) => {
153
- var K;
154
- f !== c && ((K = e.onExpand) == null || K.call(e, f, a));
155
- },
156
- [c, e.onExpand]
157
- ), L = V(async () => {
158
- var P;
159
- const { isLeaf: f, expanded: K } = r;
160
- f || (!((P = r.childrenData) != null && P.length) && $(e.loadMore) && !K ? await e.loadMore(r) : E(!K));
161
- }, [r, E, e.loadMore]), ce = () => {
162
- if (D)
163
- return "loadingIcon" in S ? S.loadingIcon : /* @__PURE__ */ b(Pe, {});
164
- let f = null, K = !1;
165
- if (x)
166
- C && (f = "switcherIcon" in S ? S.switcherIcon : /* @__PURE__ */ b(Ce, {}), K = !0);
167
- else {
168
- const P = C ? /* @__PURE__ */ b("span", { className: `${h}-${c ? "minus" : "plus"}-icon` }) : /* @__PURE__ */ b(be, {});
169
- f = "switcherIcon" in S ? S.switcherIcon : P, K = !C;
170
- }
171
- if (f)
172
- return f = /* @__PURE__ */ b(
173
- "span",
174
- {
175
- className: `${h}-switcher-icon`,
176
- "aria-label": c ? "fold button" : "expand button",
177
- role: "button",
178
- tabIndex: 0,
179
- onClick: L,
180
- children: f
181
- }
182
- ), K ? /* @__PURE__ */ b(xe, { prefix: h, children: f }) : f;
183
- }, F = V(
184
- we((f) => {
185
- var Z;
186
- const K = s.current;
187
- if (!K) return;
188
- const P = K.getBoundingClientRect(), T = window.pageYOffset + P.top, v = f.pageY, Q = P.height / 4, X = v - T, W = X < Q ? -1 : X < P.height - Q ? 0 : 1, le = e.allowDrop(r, W);
189
- i({
190
- ...t,
191
- isAllowDrop: le,
192
- isDragOver: !0,
193
- dragPosition: W
194
- }), (Z = e.onNodeDragOver) == null || Z.call(e, f, r, W);
195
- }),
196
- [e.onNodeDragOver]
197
- ), J = V(
198
- (f, K) => {
199
- var v;
200
- const { disableCheckbox: P, disabled: T } = r;
201
- P || T || (v = e.onCheck) == null || v.call(e, f, a, K);
202
- },
203
- [r.disabled, r.disableCheckbox]
204
- );
205
- return /* @__PURE__ */ j(pe, { children: [
206
- /* @__PURE__ */ j(
207
- "div",
208
- {
209
- style: r.style,
210
- className: w,
211
- ref: p,
212
- role: "treeitem",
213
- "aria-disabled": l,
214
- "aria-expanded": c,
215
- "aria-level": r._level,
216
- children: [
217
- /* @__PURE__ */ b("span", { className: `${h}-indent`, "aria-hidden": !0, children: [...Array(r._level)].map((f, K) => /* @__PURE__ */ b(
218
- "span",
219
- {
220
- className: M(`${h}-indent-block`, {
221
- [`${h}-indent-block-lineless`]: r._lineless && r._lineless[K]
222
- })
223
- },
224
- K
225
- )) }),
226
- /* @__PURE__ */ b(
227
- "span",
228
- {
229
- className: M(`${h}-switcher`, {
230
- [`${h}-switcher-expanded`]: c
231
- }),
232
- children: ce()
233
- }
234
- ),
235
- u ? /* @__PURE__ */ b(
236
- Ee,
237
- {
238
- disabled: k || l,
239
- value: a,
240
- indeterminate: r.indeterminated,
241
- checked: r.checked,
242
- onChange: J
243
- }
244
- ) : null,
245
- /* @__PURE__ */ j(
246
- "span",
247
- {
248
- "aria-grabbed": t.isDragging,
249
- ref: s,
250
- className: M(`${h}-title`, {
251
- [`${h}-title-draggable`]: m,
252
- [`${h}-title-gap-top`]: t.isDragOver && t.isAllowDrop && t.dragPosition < 0,
253
- [`${h}-title-gap-bottom`]: t.isDragOver && t.isAllowDrop && t.dragPosition > 0,
254
- [`${h}-title-highlight`]: !t.isDragging && t.isDragOver && t.isAllowDrop && t.dragPosition === 0,
255
- [`${h}-title-dragging`]: t.isDragging,
256
- [`${h}-title-block`]: r.blockNode
257
- }),
258
- onClick: (f) => {
259
- const {
260
- onSelect: K,
261
- onSelect_: P,
262
- // 潘启宝添加
263
- actionOnClick: T
264
- } = e;
265
- if (!r.disabled) {
266
- const v = [].concat(T);
267
- N && v.indexOf("select") > -1 && (K == null || K(a, f)), P == null || P(r), v.indexOf("expand") > -1 && L(), u && v.indexOf("check") > -1 && J(!r.checked, f);
268
- }
269
- },
270
- draggable: m,
271
- onDrop: (f) => {
272
- var K;
273
- f.stopPropagation(), f.preventDefault(), (K = e.onNodeDrop) == null || K.call(e, f, r, t.dragPosition), F.cancel(), i({
274
- ...t,
275
- isDragOver: !1,
276
- dragPosition: 0
277
- });
278
- },
279
- onDragStart: (f) => {
280
- var K;
281
- if (m) {
282
- f.stopPropagation(), i({ ...t, isDragging: !0 });
283
- try {
284
- f.dataTransfer.setData("text/plain", "");
285
- } catch {
286
- }
287
- (K = e.onNodeDragStart) == null || K.call(e, f, r);
288
- }
289
- },
290
- onDragEnd: (f) => {
291
- var K;
292
- m && (f.stopPropagation(), F.cancel(), i({ ...t, isDragOver: !1, isDragging: !1 }), (K = e.onNodeDragEnd) == null || K.call(e, f, r));
293
- },
294
- onDragOver: (f) => {
295
- f.preventDefault(), f.stopPropagation(), f.persist(), F(f);
296
- },
297
- onDragLeave: (f) => {
298
- var K;
299
- m && (f.stopPropagation(), F.cancel(), i({ ...t, isDragOver: !1 }), (K = e.onNodeDragLeave) == null || K.call(e, f, r));
300
- },
301
- children: [
302
- o && /* @__PURE__ */ b("span", { className: `${h}-icon ${h}-custom-icon`, children: o }),
303
- /* @__PURE__ */ b("span", { className: `${h}-title-text`, children: $(e.renderTitle) ? e.renderTitle(r) : d }),
304
- m && /* @__PURE__ */ b("span", { className: `${h}-icon ${h}-drag-icon`, children: "dragIcon" in S ? S.dragIcon : /* @__PURE__ */ b(De, {}) })
305
- ]
306
- }
307
- ),
308
- $(e.renderExtra) && e.renderExtra(r)
309
- ]
310
- }
311
- ),
312
- e.animation && /* @__PURE__ */ b(Oe, { ...r })
313
- ] });
314
- }
315
- const re = ne(Ie);
316
- re.displayName = "TreeNode";
317
- const R = Y.memo(re);
318
- function $e(r) {
319
- return r.key || r._key;
320
- }
321
- function Me(r, p) {
322
- const {
323
- className: e,
324
- style: n,
325
- filterNode: s,
326
- virtualListProps: t,
327
- expandedKeys: i,
328
- currentExpandKeys: a,
329
- nodeList: d,
330
- getNodeProps: o,
331
- getDataSet: u
332
- } = r, g = (t == null ? void 0 : t.threshold) !== null, l = A(), k = A(), x = A(), m = H(() => new Set(i), [i]), c = H(() => {
333
- const N = /* @__PURE__ */ new Set(), h = new Set(a);
334
- return d.forEach((w) => {
335
- (w.pathParentKeys || []).every(
336
- (E) => !h.has(E) && m.has(E)
337
- ) && N.add(w._key);
338
- }), N;
339
- }, [m, a, d]), C = () => d.filter((N) => !!((!s || (s == null ? void 0 : s(N))) && c.has(N.key))), D = H(() => C(), [d, s, c]);
340
- return ue(p, () => ({
341
- // index: 第几个dom元素, 如果传入的是字符串,会作为 node 的 key去查找。
342
- // nodeProps: _index 是 key 时,对应的node
343
- scrollIntoView: (N, h) => {
344
- let w = N;
345
- if (typeof N == "string") {
346
- let E = N;
347
- !c.has(N) && h && h.pathParentKeys && (E = [...h.pathParentKeys].reverse().find((L) => c.has(L)) || w), w = D.findIndex(({ _key: L }) => L === E);
348
- }
349
- if (!g && k.current) {
350
- const E = k.current, L = E ? E.children[w] : null;
351
- L && Le(L, {
352
- boundary: E.parentElement
353
- });
354
- } else l.current && l.current.scrollTo({ index: w });
355
- }
356
- })), g ? /* @__PURE__ */ b(
357
- ie,
358
- {
359
- className: e,
360
- style: n,
361
- ref: l,
362
- data: D,
363
- isStaticItemHeight: !1,
364
- itemKey: $e,
365
- onMouseDown: r.onMouseDown,
366
- ...r.ariaProps,
367
- ...t,
368
- children: (N, h, { itemIndex: w }) => {
369
- w === 0 && (x.current = u());
370
- const S = o(N, x.current);
371
- return /* @__PURE__ */ q(R, { ...N, key: N.key, ...S });
372
- }
373
- }
374
- ) : /* @__PURE__ */ b(
375
- "div",
376
- {
377
- role: "tree",
378
- tabIndex: 0,
379
- className: e,
380
- style: n,
381
- ref: k,
382
- ...r.ariaProps,
383
- onMouseDown: r.onMouseDown,
384
- children: D.map((N) => {
385
- const h = o(N);
386
- return /* @__PURE__ */ q(R, { ...h, key: N.key });
387
- })
388
- }
389
- );
390
- }
391
- const Te = ne(Me), Ae = (r) => {
392
- const p = (e) => Y.Children.map(e, (n) => {
393
- if (!Y.isValidElement(n))
394
- return;
395
- const s = n.key;
396
- return {
397
- ...n.props,
398
- key: s,
399
- children: p(n.props.children)
400
- };
401
- });
402
- return p(r);
403
- };
404
- function ae(r, p) {
405
- const e = /* @__PURE__ */ new Set(), n = (s) => {
406
- s.map((t) => {
407
- const i = t.key, a = p[i];
408
- !a || a.disabled || a.disableCheckbox || a.checkable === !1 || (e.add(i), n(a.children || []));
409
- });
410
- };
411
- return r && n(r.children || []), e;
412
- }
413
- const oe = (r, p, e, n) => {
414
- [...p[r].pathParentKeys].reverse().some((t) => {
415
- const i = p[t];
416
- if (i && !i.disabled && !i.disableCheckbox && i.checkable !== !1) {
417
- let a = 0, d = 0;
418
- i.children.some(({ key: o }) => {
419
- const u = p[o];
420
- if (!u || u.disabled || u.disableCheckbox || u.checkable === !1)
421
- return !1;
422
- if (a++, e.has(o))
423
- d++;
424
- else if (n.has(o))
425
- return d += 0.5, !0;
426
- }), !d || d === a ? n.delete(t) : n.add(t), d && d === a ? e.add(t) : e.delete(t);
427
- } else
428
- return !0;
429
- });
430
- };
431
- function He(r, p) {
432
- const e = new Set(r || []), n = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Set();
433
- return r.forEach((t) => {
434
- s.has(t) || ae(p[t], p).forEach((a) => {
435
- s.add(a);
436
- }), p[t] && !p[t].pathParentKeys.some(
437
- (i) => e.has(i)
438
- ) && oe(t, p, e, n);
439
- }), {
440
- checkedKeys: [.../* @__PURE__ */ new Set([...e, ...s])],
441
- indeterminateKeys: [...n]
442
- };
443
- }
444
- function Re(r, p, e, n, s) {
445
- if (!n[r])
446
- return {
447
- checkedKeys: e,
448
- indeterminateKeys: s
449
- };
450
- const t = new Set(e), i = new Set(s), a = ae(n[r], n), d = t;
451
- return p ? (d.add(r), i.delete(r), a.forEach((o) => {
452
- d.add(o);
453
- })) : (i.delete(r), d.delete(r), a.forEach((o) => {
454
- d.delete(o);
455
- })), oe(r, n, t, i), {
456
- checkedKeys: [...d],
457
- indeterminateKeys: [...i]
458
- };
459
- }
460
- const de = {
461
- key: "key",
462
- title: "title",
463
- children: "children",
464
- selectable: "selectable",
465
- disabled: "disabled",
466
- disableCheckbox: "disableCheckbox",
467
- checkable: "checkable",
468
- isLeaf: "isLeaf"
469
- }, Fe = {
470
- selectable: !0,
471
- autoExpandParent: !0,
472
- checkedStrategy: "all",
473
- actionOnClick: "select",
474
- allowDrop: () => !0,
475
- fieldNames: de,
476
- animation: !0
477
- }, Ve = [
478
- "style",
479
- "className",
480
- "height",
481
- "size",
482
- "blockNode",
483
- "autoExpandParent",
484
- "checkedStrategy",
485
- "fieldNames",
486
- "icons",
487
- "virtualListProps",
488
- "showLine",
489
- "selectable",
490
- "allowDrop",
491
- "actionOnClick",
492
- "animation"
493
- ], _ = class _ extends Ke {
494
- constructor(e, n) {
495
- super(e, n);
496
- y(this, "context");
497
- y(this, "key2nodeProps", {});
498
- y(this, "dragNode");
499
- y(this, "nodeListRef");
500
- y(this, "dropPosition");
501
- y(this, "getMergedProps", (e) => {
502
- const { componentConfig: n } = this.context ?? {}, s = e || this.props, t = (n == null ? void 0 : n.Tree) || {}, i = {};
503
- return Ve.forEach((a) => {
504
- te(s[a]) ? te(t[a]) ? i[a] = Fe[a] : i[a] = t[a] : i[a] = s[a];
505
- }), i;
506
- });
507
- // index: 第几个dom元素, 如果传入的是字符串,会作为 node 的 key去查找。
508
- // nodeProps 参数似乎咩有什么用。。。但是不知道外部有没有调用,就当key用吧。。
509
- y(this, "scrollIntoView", (e, n) => {
510
- let s = e;
511
- n && (s = n._key), this.nodeListRef && this.nodeListRef.scrollIntoView(
512
- s,
513
- n || this.key2nodeProps[s]
514
- );
515
- });
516
- y(this, "getTreeData", () => "treeData" in this.props ? this.props.treeData : Ae(this.props.children));
517
- // 以下外部传入的属性改变时,需要更新nodeList
518
- y(this, "needUpdateTreeData", (e, n) => {
519
- const s = [
520
- "fieldNames",
521
- "selectable",
522
- "draggable",
523
- "checkStrictly",
524
- "showLine",
525
- "blockNode",
526
- "checkable",
527
- "treeData",
528
- "children"
529
- ];
530
- return e.treeData !== n.treeData || e.children !== n.children || s.some((t) => I(e[t], n[t]));
531
- });
532
- // 根据 fieldNames 获取节点数据
533
- y(this, "getFieldInfo", (e) => {
534
- const n = this.getMergedProps(), { selectable: s } = n, t = {
535
- ...de,
536
- ..."treeData" in this.props ? n.fieldNames : {}
537
- }, i = {
538
- children: O(e, t.children),
539
- selectable: B(e, t.selectable) ? O(e, t.selectable) : s,
540
- checkable: B(e, t.checkable) ? O(e, t.checkable) : this.props.checkable,
541
- title: O(e, t.title),
542
- disabled: O(e, t.disabled),
543
- disableCheckbox: O(e, t.disableCheckbox),
544
- isLeaf: O(e, t.isLeaf),
545
- key: O(e, t.key)
546
- };
547
- return B(e, t.key) || delete i.key, i;
548
- });
549
- y(this, "getNodeList", (e, n) => {
550
- this.key2nodeProps = {};
551
- const s = n || this.context.getPrefixCls("tree"), t = [];
552
- let i = 0;
553
- const { showLine: a, blockNode: d } = this.getMergedProps(), o = (u, g) => {
554
- const l = u.length;
555
- return u.map((k, x) => {
556
- const {
557
- children: m,
558
- selectable: c,
559
- checkable: C,
560
- key: D = `${(g == null ? void 0 : g._key) || ""}-${x}`,
561
- ...N
562
- } = this.getFieldInfo(k), h = {
563
- // data 中含有dataRef时,优先级较高
564
- dataRef: k,
565
- draggable: this.props.draggable,
566
- selectable: c,
567
- checkable: C,
568
- showLine: a,
569
- blockNode: d,
570
- ...k,
571
- ...N,
572
- key: D,
573
- children: m,
574
- _key: D,
575
- _index: i++,
576
- parentKey: g ? g._key : void 0,
577
- pathParentKeys: g && g.pathParentKeys || [],
578
- _level: g._level || 0,
579
- // 保存node在sowLine模式下是否显示缩进线。如果父节点是其所在层级的最后一个节点,那么所有的子节点(包括孙子节点等)在父节点所在层级的缩进格都不显示缩进线。
580
- _lineless: g && g._lineless ? [...g._lineless || [], g._isTail] : []
581
- };
582
- return l === x + 1 && (h.className = M(
583
- `${s}-node-is-tail`,
584
- h.className
585
- )), t.push(h), this.key2nodeProps[D] = h, m && m.length && (this.key2nodeProps[D].children = o(m, {
586
- _key: D,
587
- _level: h._level + 1,
588
- _lineless: h._lineless,
589
- _isTail: l === x + 1,
590
- pathParentKeys: [...(g == null ? void 0 : g.pathParentKeys) || [], D]
591
- })), h;
592
- });
593
- };
594
- return o(e || [], {}), t;
595
- });
596
- y(this, "getInitExpandedKeys", (e) => {
597
- if (!this.getMergedProps().autoExpandParent)
598
- return e || [];
599
- if (!e)
600
- return Object.keys(this.key2nodeProps).filter((s) => {
601
- const t = this.key2nodeProps[s];
602
- return t.children && t.children.length;
603
- });
604
- const n = {};
605
- return e.forEach((s) => {
606
- const t = this.key2nodeProps[s];
607
- t && (n[s] = 1, t.pathParentKeys && t.pathParentKeys.forEach((i) => {
608
- n[i] = 1;
609
- }));
610
- }), Object.keys(n);
611
- });
612
- y(this, "getInitCheckedKeys", (e) => {
613
- if (!this.props.checkStrictly) {
614
- const { checkedKeys: n, indeterminateKeys: s } = He(
615
- e,
616
- this.key2nodeProps
617
- );
618
- return {
619
- checkedKeys: n,
620
- halfCheckedKeys: s
621
- };
622
- }
623
- return {
624
- checkedKeys: e,
625
- halfCheckedKeys: this.props.halfCheckedKeys || []
626
- };
627
- });
628
- y(this, "handleSelect", (e, n) => {
629
- const { onSelect: s } = this.props, t = { e: n, node: this.getCacheNode([e])[0] };
630
- if (this.props.multiple) {
631
- const i = [...this.state.selectedKeys], a = i.indexOf(e);
632
- a > -1 ? (i.splice(a, 1), t.selected = !1) : (t.selected = !0, i.push(e)), t.selectedNodes = this.getCacheNode(i), "selectedKeys" in this.props || this.setState({ selectedKeys: i }), s == null || s(i, t);
633
- } else
634
- t.selected = !0, t.selectedNodes = this.getCacheNode([e]), "selectedKeys" in this.props || this.setState({ selectedKeys: [e] }), s == null || s([e], t);
635
- });
636
- y(this, "handleCheck", (e, n, s) => {
637
- const { checkedStrategy: t } = this.getMergedProps(), { onCheck: i, checkStrictly: a } = this.props, d = { e: s, node: this.getCacheNode([n])[0] };
638
- let o = this.state.checkedKeys, u = this.state.halfCheckedKeys;
639
- if (a) {
640
- e ? o = o.concat(n) : o = o.filter((l) => l !== n);
641
- const g = {};
642
- "checkedKeys" in this.props || (g.checkedKeys = o), "halfCheckedKeys" in this.props || (g.halfCheckedKeys = u), ke(g) || this.setState({ ...g });
643
- } else {
644
- const { checkedKeys: g, indeterminateKeys: l } = Re(
645
- n,
646
- e,
647
- o,
648
- this.key2nodeProps,
649
- u
650
- );
651
- o = g, u = l, "checkedKeys" in this.props ? this.setState({ halfCheckedKeys: u }) : this.setState({ checkedKeys: o, halfCheckedKeys: u }), t === _.SHOW_PARENT ? o = o.filter((k) => {
652
- const x = this.key2nodeProps[k];
653
- if (!x || o.indexOf(x.parentKey) === -1)
654
- return !0;
655
- }) : t === _.SHOW_CHILD && (o = o.filter((k) => {
656
- var m, c;
657
- const x = this.key2nodeProps[k];
658
- if (!x || !((m = x.children) != null && m.length) || (c = x.children) != null && c.every((C) => o.indexOf(C._key) === -1))
659
- return !0;
660
- }));
661
- }
662
- i == null || i(o, {
663
- checkedNodes: this.getCacheNode(o),
664
- checked: e,
665
- halfCheckedKeys: u,
666
- halfCheckedNodes: this.getCacheNode(u),
667
- ...d
668
- });
669
- });
670
- y(this, "handleLoadMore", (e) => {
671
- const { loadMore: n } = this.props;
672
- if ($(n)) {
673
- const { loadingKeys: s = [], loadedKeys: t } = this.state;
674
- this.setState(
675
- {
676
- loadingKeys: Array.from(/* @__PURE__ */ new Set([...s, e._key])),
677
- loadedKeys: t.filter((i) => i !== e._key)
678
- },
679
- async () => {
680
- try {
681
- await n(this.getCacheNode([e._key])[0]), this.setState({
682
- loadedKeys: Array.from(
683
- /* @__PURE__ */ new Set([...this.state.loadedKeys, e._key])
684
- ),
685
- loadingKeys: this.state.loadingKeys.filter(
686
- (i) => i !== e._key
687
- )
688
- }), this.handleExpand(!e.expanded, e._key);
689
- } catch (i) {
690
- console.error("[tree]load data error: ", i), this.setState({
691
- loadingKeys: this.state.loadingKeys.filter(
692
- (a) => a !== e._key
693
- )
694
- });
695
- }
696
- }
697
- );
698
- }
699
- });
700
- y(this, "handleNodeDragStart", (e, n) => {
701
- this.dragNode = this.getCacheNode([n._key])[0], this.dropPosition = 0;
702
- const { onDragStart: s } = this.props;
703
- s == null || s(e, this.getCacheNode([n._key])[0]);
704
- });
705
- y(this, "handleNodeDragEnd", (e, n) => {
706
- this.dragNode = null, this.dropPosition = 0;
707
- const { onDragEnd: s } = this.props;
708
- s == null || s(e, this.getCacheNode([n._key])[0]);
709
- });
710
- y(this, "handleNodeDragOver", (e, n, s) => {
711
- this.dropPosition = s;
712
- const { onDragOver: t } = this.props;
713
- t == null || t(e, this.getCacheNode([n._key])[0]);
714
- });
715
- y(this, "handleNodeDragLeave", (e, n) => {
716
- this.dropPosition = 0;
717
- const { onDragLeave: s } = this.props;
718
- s == null || s(e, this.getCacheNode([n._key])[0]);
719
- });
720
- y(this, "isChildOfNode", (e, n) => {
721
- let s = this.key2nodeProps[e.parentKey];
722
- for (; s; ) {
723
- const { _key: t, parentKey: i } = s;
724
- if (t === n.props._key)
725
- return !0;
726
- if (i === t) return;
727
- s = this.key2nodeProps[i];
728
- }
729
- });
730
- y(this, "isSameNode", (e, n) => {
731
- if (e === void 0 || n === void 0) return !1;
732
- if (e === n) return !0;
733
- const s = e.key, t = n.key;
734
- if (s !== void 0 || t !== void 0) return s === t;
735
- const i = e.props._key, a = n.props._key;
736
- return i === void 0 && a === void 0 ? !1 : i === a;
737
- });
738
- y(this, "handleNodeDrop", (e, n, s) => {
739
- if (this.dragNode) {
740
- const { allowDrop: t } = this.getMergedProps(), { onDrop: i } = this.props, a = this.getCacheNode([n._key])[0];
741
- if (i && !this.isChildOfNode(n, this.dragNode) && !this.isSameNode(this.dragNode, a)) {
742
- if (t && !t({
743
- dropNode: a,
744
- dragNode: this.dragNode,
745
- dropPosition: s
746
- }))
747
- return;
748
- i({
749
- dragNode: this.dragNode,
750
- dropNode: a,
751
- dropPosition: s,
752
- e
753
- });
754
- }
755
- }
756
- });
757
- y(this, "handleAllowDrop", (e, n) => {
758
- const { allowDrop: s } = this.getMergedProps();
759
- let t = !0;
760
- return typeof s == "function" && (t = s({
761
- dropNode: this.getCacheNode([e._key])[0],
762
- dragNode: this.dragNode,
763
- dropPosition: n
764
- })), t;
765
- });
766
- y(this, "handleExpand", (e, n) => {
767
- const { currentExpandKeys: s, expandedKeys: t = [] } = this.state, { animation: i } = this.getMergedProps(), { onExpand: a } = this.props;
768
- if (s.indexOf(n) > -1)
769
- return;
770
- let d = [];
771
- e ? d = Array.from(/* @__PURE__ */ new Set([...t, n])) : d = t.filter((o) => o !== n), "expandedKeys" in this.props || this.setState({
772
- expandedKeys: d,
773
- currentExpandKeys: i ? [...s, n] : []
774
- }), a == null || a(d, {
775
- expanded: e,
776
- node: this.getCacheNode([n])[0],
777
- expandedNodes: this.getCacheNode(d)
778
- });
779
- });
780
- y(this, "getCacheNode", (e) => {
781
- const { __PqbAdapterMode__: n } = this.props, s = [];
782
- return [].concat(e).forEach((i) => {
783
- const a = this.key2nodeProps[i];
784
- a && s.push(a);
785
- }), this.getNodeProps(s).map((i) => n ? {
786
- props: i,
787
- key: e
788
- } : /* @__PURE__ */ q(R, { ...i, key: i.key }));
789
- });
790
- // 转换为 set 类型,便于查找。主要是传递给node-list使用
791
- y(this, "getDataSet", (e) => {
792
- var n, s, t, i;
793
- return {
794
- expandedKeysSet: (e == null ? void 0 : e.expandedKeysSet) || new Set(((n = this.state) == null ? void 0 : n.expandedKeys) || []),
795
- checkedKeysSet: (e == null ? void 0 : e.checkedKeysSet) || new Set(((s = this.state) == null ? void 0 : s.checkedKeys) || []),
796
- selectedKeysSet: (e == null ? void 0 : e.selectedKeysSet) || new Set(((t = this.state) == null ? void 0 : t.selectedKeys) || []),
797
- halfCheckedKeysSet: (e == null ? void 0 : e.halfCheckedKeysSet) || new Set(((i = this.state) == null ? void 0 : i.halfCheckedKeys) || [])
798
- };
799
- });
800
- // dataSet:传入构建好的expandedKeysSet,, checkedKeysSet, halfCheckedKeysSet ,性能优化
801
- y(this, "getNodeProps", (e, n) => {
802
- const { autoExpandParent: s } = this.getMergedProps(), { loadMore: t } = this.props, {
803
- selectedKeys: i,
804
- expandedKeys: a,
805
- checkedKeys: d,
806
- loadingKeys: o = [],
807
- loadedKeys: u = []
808
- } = this.state, {
809
- expandedKeysSet: g,
810
- checkedKeysSet: l,
811
- selectedKeysSet: k,
812
- halfCheckedKeysSet: x
813
- } = this.getDataSet(n), m = (c) => {
814
- const C = c.children && c.children.length, D = {
815
- isLeaf: !C,
816
- autoExpandParent: C ? s : !1,
817
- expanded: g ? g.has(c._key) : a.indexOf(c._key) > -1
818
- };
819
- if (t) {
820
- const N = u.indexOf(c._key) > -1;
821
- D.loaded = N, D.isLeaf = C ? !1 : c.isLeaf;
822
- }
823
- return {
824
- ...c,
825
- ...D,
826
- selected: k.has(c._key),
827
- indeterminated: x.has(c._key),
828
- loading: o.indexOf(c._key) > -1,
829
- checked: l.has(c._key),
830
- selectedKeys: i,
831
- checkedKeys: d,
832
- loadingKeys: o,
833
- loadedKeys: u,
834
- expandedKeys: a,
835
- childrenData: c.children || [],
836
- children: null
837
- };
838
- };
839
- return me(e) ? e.map((c) => m(c)) : m(e);
840
- });
841
- y(this, "handleExpandEnd", (e) => {
842
- this.setState((n) => {
843
- const { currentExpandKeys: s } = n;
844
- return s.indexOf(e) > -1 ? {
845
- currentExpandKeys: s.filter((t) => t !== e)
846
- } : {};
847
- });
848
- });
849
- // 获取tree的state数据,在子组件里使用。
850
- y(this, "getTreeState", () => this.state);
851
- this.state = {};
852
- const s = this.getTreeData(), t = this.getNodeList(s, n.getPrefixCls("tree")), { checkedKeys: i, halfCheckedKeys: a } = this.getInitCheckedKeys(
853
- e.checkedKeys || e.defaultCheckedKeys || []
854
- );
855
- this.state = {
856
- selectedKeys: e.selectedKeys || e.defaultSelectedKeys || [],
857
- checkedKeys: i,
858
- halfCheckedKeys: a,
859
- expandedKeys: this.getInitExpandedKeys(
860
- e.expandedKeys || e.defaultExpandedKeys
861
- ),
862
- loadedKeys: [],
863
- loadingKeys: [],
864
- currentExpandKeys: [],
865
- nodeList: t
866
- };
867
- }
868
- static getDerivedStateFromProps(e, n) {
869
- const s = {};
870
- return "selectedKeys" in e && !I(e.selectedKeys, n.selectedKeys) && (s.selectedKeys = e.selectedKeys || []), Object.keys(s).length ? s : null;
871
- }
872
- componentDidUpdate(e) {
873
- const n = this.getMergedProps(e), s = this.getMergedProps();
874
- if (e !== this.props || !I(n, s)) {
875
- const t = {};
876
- if (this.needUpdateTreeData(
877
- { prevMergedProps: n, ...e },
878
- { ...s, ...this.props }
879
- )) {
880
- const a = this.getTreeData(), d = this.getNodeList(a);
881
- t.treeData = a, t.nodeList = d;
882
- }
883
- if (t.treeData || "checkedKeys" in this.props && !I(e.checkedKeys, this.props.checkedKeys)) {
884
- const a = "checkedKeys" in this.props ? this.props.checkedKeys : this.state.checkedKeys, { halfCheckedKeys: d, checkedKeys: o } = this.getInitCheckedKeys(
885
- a || []
886
- );
887
- I(o, this.state.checkedKeys) || (t.checkedKeys = o), I(d, this.state.halfCheckedKeys) || (t.halfCheckedKeys = d);
888
- }
889
- this.props.checkStrictly && "halfCheckedKeys" in this.props && !I(e.halfCheckedKeys, this.props.halfCheckedKeys) && (t.halfCheckedKeys = this.props.halfCheckedKeys), "expandedKeys" in this.props && !I(this.props.expandedKeys, e.expandedKeys) && (t.expandedKeys = this.props.expandedKeys, t.currentExpandKeys = s.animation ? [
890
- ...t.expandedKeys ?? [],
891
- ...this.state.expandedKeys ?? []
892
- ].reduce((a, d) => {
893
- const o = a.indexOf(d);
894
- return o === -1 ? a.push(d) : a.splice(o, 1), a;
895
- }, []).filter((a, d, o) => {
896
- var u;
897
- if (this.key2nodeProps[a])
898
- return this.key2nodeProps[a].pathParentKeys.some((l) => o.indexOf(l) > -1) ? !1 : (u = this.key2nodeProps[a].children) == null ? void 0 : u.length;
899
- }) : []);
900
- const i = t.currentExpandKeys || this.state.currentExpandKeys;
901
- t.treeData && i && (t.currentExpandKeys = i.filter((a) => {
902
- const d = t.treeData.find((o) => o.key === a);
903
- return d && d.children && d.children.length;
904
- })), Object.keys(t).length && this.setState(t);
905
- }
906
- }
907
- render() {
908
- const {
909
- className: e,
910
- showLine: n,
911
- size: s,
912
- virtualListProps: t,
913
- height: i,
914
- style: a,
915
- icons: d,
916
- actionOnClick: o,
917
- animation: u
918
- } = this.getMergedProps(), { loadMore: g, checkable: l } = this.props, k = t ? {
919
- threshold: 100,
920
- ...t
921
- } : i ? { height: i, threshold: 100 } : {
922
- threshold: null
923
- }, { getPrefixCls: x, rtl: m } = this.context, c = x("tree");
924
- return /* @__PURE__ */ b(
925
- G.Provider,
926
- {
927
- value: {
928
- icons: d,
929
- animation: u,
930
- key2nodeProps: this.key2nodeProps,
931
- getFieldInfo: this.getFieldInfo,
932
- getTreeState: this.getTreeState,
933
- getNodeProps: this.getNodeProps,
934
- onExpandEnd: u ? this.handleExpandEnd : () => {
935
- },
936
- onSelect: this.handleSelect,
937
- onCheck: this.handleCheck,
938
- onNodeDragStart: this.handleNodeDragStart,
939
- onNodeDragEnd: this.handleNodeDragEnd,
940
- onNodeDragLeave: this.handleNodeDragLeave,
941
- onNodeDragOver: this.handleNodeDragOver,
942
- onNodeDrop: this.handleNodeDrop,
943
- onExpand: this.handleExpand,
944
- renderExtra: this.props.renderExtra,
945
- renderTitle: this.props.renderTitle,
946
- loadMore: g && this.handleLoadMore,
947
- allowDrop: this.handleAllowDrop,
948
- actionOnClick: o,
949
- virtualListProps: k
950
- },
951
- children: /* @__PURE__ */ b(
952
- Te,
953
- {
954
- ref: (C) => {
955
- this.nodeListRef = C;
956
- },
957
- className: M(
958
- c,
959
- {
960
- [`${c}-checkable`]: l,
961
- [`${c}-show-line`]: n,
962
- [`${c}-size-${s}`]: s,
963
- [`${c}-rtl`]: m
964
- },
965
- e
966
- ),
967
- style: a,
968
- filterNode: this.props.filterNode,
969
- virtualListProps: k,
970
- expandedKeys: this.state.expandedKeys,
971
- currentExpandKeys: this.state.currentExpandKeys,
972
- getNodeProps: this.getNodeProps,
973
- getDataSet: this.getDataSet,
974
- nodeList: this.state.nodeList,
975
- onMouseDown: this.props.onMouseDown,
976
- ariaProps: {
977
- role: "tree",
978
- "aria-multiselectable": this.props.multiple,
979
- tabIndex: 0,
980
- ...Ne(this.props)
981
- }
982
- }
983
- )
984
- }
985
- );
986
- }
987
- };
988
- y(_, "displayName", "Tree"), y(_, "SHOW_PARENT", "parent"), y(_, "SHOW_ALL", "all"), y(_, "SHOW_CHILD", "child"), y(_, "Node", R), y(_, "contextType", z);
989
- let se = _;
990
- export {
991
- se as T,
992
- Ae as a,
993
- Re as b,
994
- He as g
995
- };