@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/tree/Node.js CHANGED
@@ -1,130 +1,126 @@
1
- import { jsxs as w, Fragment as z, jsx as r } from "react/jsx-runtime";
2
- import G from "@unicom-cloud/icons/IconUiCaretDown";
3
- import J from "@unicom-cloud/icons/IconUiDragDotVertical";
4
- import K from "@unicom-cloud/icons/IconUiFile";
5
- import Q from "@unicom-cloud/icons/IconUiLoading";
1
+ import { jsxs as N, Fragment as q, jsx as r } from "react/jsx-runtime";
2
+ import z from "@unicom-cloud/icons/IconUiCaretDown";
3
+ import G from "@unicom-cloud/icons/IconUiDragDotVertical";
4
+ import J from "@unicom-cloud/icons/IconUiFile";
5
+ import K from "@unicom-cloud/icons/IconUiLoading";
6
6
  import m from "lodash/isFunction";
7
- import W, { forwardRef as X, useContext as _, useRef as Z, useState as ee, useCallback as I } from "react";
8
- import ne from "../checkbox/Checkbox.js";
7
+ import Q, { forwardRef as W, useContext as E, useRef as X, useState as Z, useCallback as v } from "react";
8
+ import ee from "../checkbox/Checkbox.js";
9
9
  import "../checkbox/Group.js";
10
10
  import "../config-provider/ConfigProvider.js";
11
- import ae from "../icon-hover/index.js";
12
- import b from "@unicom-cloud/utils/class-name";
13
- import { throttleByRaf as ie } from "../components/common/utils/throttleByRaf.js";
14
- import oe from "./Animation.js";
15
- import { TreeContext as te } from "./Context.js";
16
- import re from "../config-provider/context.js";
17
- function se(i, U) {
18
- const n = _(te), { getPrefixCls: $ } = _(re), p = Z(), [t, f] = ee({
11
+ import ne from "../icon-hover/index.js";
12
+ import D from "@unicom-cloud/utils/class-name";
13
+ import { throttleByRaf as te } from "../components/common/utils/throttleByRaf.js";
14
+ import ie from "./Animation.js";
15
+ import { TreeContext as ae } from "./Context.js";
16
+ import oe from "../config-provider/context.js";
17
+ function re(n, S) {
18
+ const i = E(ae), { getPrefixCls: R } = E(oe), C = X(), [o, f] = Z({
19
19
  isAllowDrop: !0,
20
20
  isDragOver: !1,
21
21
  dragPosition: 0,
22
22
  isDragging: !1
23
23
  }), {
24
24
  _key: h = "",
25
- title: Y,
26
- icon: x,
27
- checkable: O,
28
- selected: F,
29
- disabled: N,
30
- disableCheckbox: H,
31
- isLeaf: P,
25
+ title: _,
26
+ icon: k,
27
+ checkable: w,
28
+ selected: U,
29
+ disabled: b,
30
+ disableCheckbox: Y,
31
+ isLeaf: I,
32
32
  draggable: l,
33
33
  expanded: d,
34
- showLine: v,
35
- loading: M,
36
- selectable: T = !0
37
- } = i, o = $ == null ? void 0 : $("tree-node"), j = b(
38
- o,
34
+ showLine: x,
35
+ loading: F,
36
+ selectable: p = !0
37
+ } = n, t = R?.("tree-node"), H = D(
38
+ t,
39
39
  {
40
- [`${o}-selected`]: F,
41
- [`${o}-is-leaf`]: P,
42
- [`${o}-expanded`]: d,
43
- [`${o}-disabled-selectable`]: !T,
44
- [`${o}-disabled`]: N,
45
- [`${o}-draggable`]: l
40
+ [`${t}-selected`]: U,
41
+ [`${t}-is-leaf`]: I,
42
+ [`${t}-expanded`]: d,
43
+ [`${t}-disabled-selectable`]: !p,
44
+ [`${t}-disabled`]: b,
45
+ [`${t}-draggable`]: l
46
46
  },
47
- i.className
47
+ n.className
48
48
  ), c = (() => {
49
- const e = m(n.icons) ? n.icons(i) : n.icons, a = m(i.icons) ? i.icons(i) : i.icons;
49
+ const e = m(i.icons) ? i.icons(n) : i.icons, a = m(n.icons) ? n.icons(n) : n.icons;
50
50
  return { ...e, ...a };
51
- })(), y = I(
51
+ })(), O = v(
52
52
  (e) => {
53
- var a;
54
- e !== d && ((a = n.onExpand) == null || a.call(n, e, h));
53
+ e !== d && i.onExpand?.(e, h);
55
54
  },
56
- [d, n.onExpand]
57
- ), A = I(async () => {
58
- var s;
59
- const { isLeaf: e, expanded: a } = i;
60
- e || (!((s = i.childrenData) != null && s.length) && m(n.loadMore) && !a ? await n.loadMore(i) : y(!a));
61
- }, [i, y, n.loadMore]), B = () => {
62
- if (M)
63
- return "loadingIcon" in c ? c.loadingIcon : /* @__PURE__ */ r(Q, {});
55
+ [d, i.onExpand]
56
+ ), P = v(async () => {
57
+ const { isLeaf: e, expanded: a } = n;
58
+ e || (!n.childrenData?.length && m(i.loadMore) && !a ? await i.loadMore(n) : O(!a));
59
+ }, [n, O, i.loadMore]), M = () => {
60
+ if (F)
61
+ return "loadingIcon" in c ? c.loadingIcon : /* @__PURE__ */ r(K, {});
64
62
  let e = null, a = !1;
65
- if (P)
66
- v && (e = "switcherIcon" in c ? c.switcherIcon : /* @__PURE__ */ r(K, {}), a = !0);
63
+ if (I)
64
+ x && (e = "switcherIcon" in c ? c.switcherIcon : /* @__PURE__ */ r(J, {}), a = !0);
67
65
  else {
68
- const s = v ? /* @__PURE__ */ r("span", { className: `${o}-${d ? "minus" : "plus"}-icon` }) : /* @__PURE__ */ r(G, {});
69
- e = "switcherIcon" in c ? c.switcherIcon : s, a = !v;
66
+ const s = x ? /* @__PURE__ */ r("span", { className: `${t}-${d ? "minus" : "plus"}-icon` }) : /* @__PURE__ */ r(z, {});
67
+ e = "switcherIcon" in c ? c.switcherIcon : s, a = !x;
70
68
  }
71
69
  if (e)
72
70
  return e = /* @__PURE__ */ r(
73
71
  "span",
74
72
  {
75
- className: `${o}-switcher-icon`,
73
+ className: `${t}-switcher-icon`,
76
74
  "aria-label": d ? "fold button" : "expand button",
77
75
  role: "button",
78
76
  tabIndex: 0,
79
- onClick: A,
77
+ onClick: P,
80
78
  children: e
81
79
  }
82
- ), a ? /* @__PURE__ */ r(ae, { prefix: o, children: e }) : e;
83
- }, u = I(
84
- ie((e) => {
85
- var R;
86
- const a = p.current;
80
+ ), a ? /* @__PURE__ */ r(ne, { prefix: t, children: e }) : e;
81
+ }, u = v(
82
+ te((e) => {
83
+ const a = C.current;
87
84
  if (!a)
88
85
  return;
89
- const s = a.getBoundingClientRect(), g = window.pageYOffset + s.top, D = e.pageY, E = s.height / 4, L = D - g, k = L < E ? -1 : L < s.height - E ? 0 : 1, q = n.allowDrop(i, k);
86
+ const s = a.getBoundingClientRect(), g = window.pageYOffset + s.top, B = e.pageY, y = s.height / 4, A = B - g, $ = A < y ? -1 : A < s.height - y ? 0 : 1, V = i.allowDrop(n, $);
90
87
  f({
91
- ...t,
92
- isAllowDrop: q,
88
+ ...o,
89
+ isAllowDrop: V,
93
90
  isDragOver: !0,
94
- dragPosition: k
95
- }), (R = n.onNodeDragOver) == null || R.call(n, e, i, k);
91
+ dragPosition: $
92
+ }), i.onNodeDragOver?.(e, n, $);
96
93
  }),
97
- [n.onNodeDragOver]
94
+ [i.onNodeDragOver]
98
95
  );
99
- function C(e, a) {
100
- var D;
101
- const { disableCheckbox: s, disabled: g } = i;
102
- s || g || (D = n.onCheck) == null || D.call(n, e, h, a);
96
+ function T(e, a) {
97
+ const { disableCheckbox: s, disabled: g } = n;
98
+ s || g || i.onCheck?.(e, h, a);
103
99
  }
104
- function V(e) {
105
- const { onSelect: a, actionOnClick: s } = n;
106
- if (i.disabled)
100
+ function j(e) {
101
+ const { onSelect: a, actionOnClick: s } = i;
102
+ if (n.disabled)
107
103
  return;
108
104
  const g = [].concat(s);
109
- T && g.indexOf("select") > -1 && (a == null || a(h, e)), g.indexOf("expand") > -1 && A(), O && g.indexOf("check") > -1 && C(!i.checked, e);
105
+ p && g.indexOf("select") > -1 && a?.(h, e), g.indexOf("expand") > -1 && P(), w && g.indexOf("check") > -1 && T(!n.checked, e);
110
106
  }
111
- return /* @__PURE__ */ w(z, { children: [
112
- /* @__PURE__ */ w(
107
+ return /* @__PURE__ */ N(q, { children: [
108
+ /* @__PURE__ */ N(
113
109
  "div",
114
110
  {
115
- style: i.style,
116
- className: j,
117
- ref: U,
111
+ style: n.style,
112
+ className: H,
113
+ ref: S,
118
114
  role: "treeitem",
119
- "aria-disabled": N,
115
+ "aria-disabled": b,
120
116
  "aria-expanded": d,
121
- "aria-level": i._level,
117
+ "aria-level": n._level,
122
118
  children: [
123
- /* @__PURE__ */ r("span", { className: `${o}-indent`, "aria-hidden": !0, children: [...Array(i._level)].map((e, a) => /* @__PURE__ */ r(
119
+ /* @__PURE__ */ r("span", { className: `${t}-indent`, "aria-hidden": !0, children: [...Array(n._level)].map((e, a) => /* @__PURE__ */ r(
124
120
  "span",
125
121
  {
126
- className: b(`${o}-indent-block`, {
127
- [`${o}-indent-block-lineless`]: i._lineless && i._lineless[a]
122
+ className: D(`${t}-indent-block`, {
123
+ [`${t}-indent-block-lineless`]: n._lineless && n._lineless[a]
128
124
  })
129
125
  },
130
126
  a
@@ -132,85 +128,81 @@ function se(i, U) {
132
128
  /* @__PURE__ */ r(
133
129
  "span",
134
130
  {
135
- className: b(`${o}-switcher`, {
136
- [`${o}-switcher-expanded`]: d
131
+ className: D(`${t}-switcher`, {
132
+ [`${t}-switcher-expanded`]: d
137
133
  }),
138
- children: B()
134
+ children: M()
139
135
  }
140
136
  ),
141
- O ? /* @__PURE__ */ r(
142
- ne,
137
+ w ? /* @__PURE__ */ r(
138
+ ee,
143
139
  {
144
- disabled: H || N,
140
+ disabled: Y || b,
145
141
  value: h,
146
- indeterminate: i.indeterminated,
147
- checked: i.checked,
148
- onChange: C
142
+ indeterminate: n.indeterminated,
143
+ checked: n.checked,
144
+ onChange: T
149
145
  }
150
146
  ) : null,
151
- /* @__PURE__ */ w(
147
+ /* @__PURE__ */ N(
152
148
  "span",
153
149
  {
154
- "aria-grabbed": t.isDragging,
155
- ref: p,
156
- className: b(`${o}-title`, {
157
- [`${o}-title-draggable`]: l,
158
- [`${o}-title-gap-top`]: t.isDragOver && t.isAllowDrop && t.dragPosition < 0,
159
- [`${o}-title-gap-bottom`]: t.isDragOver && t.isAllowDrop && t.dragPosition > 0,
160
- [`${o}-title-highlight`]: !t.isDragging && t.isDragOver && t.isAllowDrop && t.dragPosition === 0,
161
- [`${o}-title-dragging`]: t.isDragging,
162
- [`${o}-title-block`]: i.blockNode
150
+ "aria-grabbed": o.isDragging,
151
+ ref: C,
152
+ className: D(`${t}-title`, {
153
+ [`${t}-title-draggable`]: l,
154
+ [`${t}-title-gap-top`]: o.isDragOver && o.isAllowDrop && o.dragPosition < 0,
155
+ [`${t}-title-gap-bottom`]: o.isDragOver && o.isAllowDrop && o.dragPosition > 0,
156
+ [`${t}-title-highlight`]: !o.isDragging && o.isDragOver && o.isAllowDrop && o.dragPosition === 0,
157
+ [`${t}-title-dragging`]: o.isDragging,
158
+ [`${t}-title-block`]: n.blockNode
163
159
  }),
164
- onClick: V,
160
+ onClick: j,
165
161
  draggable: l,
166
162
  onDrop: (e) => {
167
- var a;
168
- e.stopPropagation(), e.preventDefault(), (a = n.onNodeDrop) == null || a.call(n, e, i, t.dragPosition), u.cancel(), f({
169
- ...t,
163
+ e.stopPropagation(), e.preventDefault(), i.onNodeDrop?.(e, n, o.dragPosition), u.cancel(), f({
164
+ ...o,
170
165
  isDragOver: !1,
171
166
  dragPosition: 0
172
167
  });
173
168
  },
174
169
  onDragStart: (e) => {
175
- var a;
176
170
  if (l) {
177
- e.stopPropagation(), f({ ...t, isDragging: !0 });
171
+ e.stopPropagation(), f({ ...o, isDragging: !0 });
178
172
  try {
179
173
  e.dataTransfer.setData("text/plain", "");
180
- } catch (s) {
181
- console.error(s);
174
+ } catch (a) {
175
+ console.error(a);
182
176
  }
183
- (a = n.onNodeDragStart) == null || a.call(n, e, i);
177
+ i.onNodeDragStart?.(e, n);
184
178
  }
185
179
  },
186
180
  onDragEnd: (e) => {
187
- var a;
188
- l && (e.stopPropagation(), u.cancel(), f({ ...t, isDragOver: !1, isDragging: !1 }), (a = n.onNodeDragEnd) == null || a.call(n, e, i));
181
+ l && (e.stopPropagation(), u.cancel(), f({ ...o, isDragOver: !1, isDragging: !1 }), i.onNodeDragEnd?.(e, n));
189
182
  },
190
183
  onDragOver: (e) => {
191
184
  e.preventDefault(), e.stopPropagation(), e.persist(), u(e);
192
185
  },
193
186
  onDragLeave: (e) => {
194
- var a;
195
- l && (e.stopPropagation(), u.cancel(), f({ ...t, isDragOver: !1 }), (a = n.onNodeDragLeave) == null || a.call(n, e, i));
187
+ l && (e.stopPropagation(), u.cancel(), f({ ...o, isDragOver: !1 }), i.onNodeDragLeave?.(e, n));
196
188
  },
197
189
  children: [
198
- x && /* @__PURE__ */ r("span", { className: `${o}-icon ${o}-custom-icon`, children: x }),
199
- /* @__PURE__ */ r("span", { className: `${o}-title-text`, children: m(n.renderTitle) ? n.renderTitle(i) : Y }),
200
- l && /* @__PURE__ */ r("span", { className: `${o}-icon ${o}-drag-icon`, children: "dragIcon" in c ? c.dragIcon : /* @__PURE__ */ r(J, {}) })
190
+ k && /* @__PURE__ */ r("span", { className: `${t}-icon ${t}-custom-icon`, children: k }),
191
+ /* @__PURE__ */ r("span", { className: `${t}-title-text`, children: m(i.renderTitle) ? i.renderTitle(n) : _ }),
192
+ l && /* @__PURE__ */ r("span", { className: `${t}-icon ${t}-drag-icon`, children: "dragIcon" in c ? c.dragIcon : /* @__PURE__ */ r(G, {}) })
201
193
  ]
202
194
  }
203
195
  ),
204
- m(n.renderExtra) && n.renderExtra(i)
196
+ m(i.renderExtra) && i.renderExtra(n)
205
197
  ]
206
198
  }
207
199
  ),
208
- n.animation && /* @__PURE__ */ r(oe, { ...i })
200
+ i.animation && /* @__PURE__ */ r(ie, { ...n })
209
201
  ] });
210
202
  }
211
- const S = X(se);
212
- S.displayName = "TreeNode";
213
- const pe = W.memo(S);
203
+ const L = W(re);
204
+ L.displayName = "TreeNode";
205
+ const ke = Q.memo(L);
214
206
  export {
215
- pe as default
207
+ ke as default
216
208
  };
package/tree/NodeList.js CHANGED
@@ -1,82 +1,82 @@
1
- import { jsx as L } from "react/jsx-runtime";
2
- import { forwardRef as N, useRef as h, useMemo as m, useImperativeHandle as V, createElement as g } from "react";
3
- import { scrollIntoView as b } from "../components/common/utils/scrollIntoView.js";
4
- import P from "../virtual-list/VirtualList.js";
5
- import v from "./Node.js";
6
- function H(s) {
7
- return s.key || s._key;
1
+ import { jsx as x } from "react/jsx-runtime";
2
+ import { forwardRef as M, useRef as y, useMemo as p, useImperativeHandle as R, createElement as D } from "react";
3
+ import { scrollIntoView as V } from "../components/common/utils/scrollIntoView.js";
4
+ import b from "../virtual-list/VirtualList.js";
5
+ import I from "./Node.js";
6
+ function H(n) {
7
+ return n.key || n._key;
8
8
  }
9
- function j(s, E) {
9
+ function j(n, N) {
10
10
  const {
11
- className: K,
12
- style: p,
13
- filterNode: a,
14
- virtualListProps: c,
11
+ className: h,
12
+ style: m,
13
+ filterNode: i,
14
+ virtualListProps: K,
15
15
  expandedKeys: w,
16
- currentExpandKeys: k,
17
- nodeList: i,
18
- getNodeProps: S,
19
- getDataSet: M
20
- } = s, x = (c == null ? void 0 : c.threshold) !== null, l = h(), f = h(), D = h(), I = m(() => new Set(w), [w]), u = m(() => {
21
- const e = /* @__PURE__ */ new Set(), t = new Set(k);
22
- return i.forEach((n) => {
23
- (n.pathParentKeys || []).every(
24
- (r) => !t.has(r) && I.has(r)
25
- ) && e.add(n._key);
16
+ currentExpandKeys: P,
17
+ nodeList: a,
18
+ getNodeProps: k,
19
+ getDataSet: g
20
+ } = n, L = K?.threshold !== null, l = y(), u = y(), S = y(), v = p(() => new Set(w), [w]), c = p(() => {
21
+ const e = /* @__PURE__ */ new Set(), s = new Set(P);
22
+ return a.forEach((t) => {
23
+ (t.pathParentKeys || []).every(
24
+ (r) => !s.has(r) && v.has(r)
25
+ ) && e.add(t._key);
26
26
  }), e;
27
- }, [I, k, i]), R = () => i.filter((e) => !!((!a || (a == null ? void 0 : a(e))) && u.has(e.key))), d = m(() => R(), [i, a, u]);
28
- return V(E, () => ({
27
+ }, [v, P, a]), E = () => a.filter((e) => !!((!i || i?.(e)) && c.has(e.key))), d = p(() => E(), [a, i, c]);
28
+ return R(N, () => ({
29
29
  // index: 第几个dom元素, 如果传入的是字符串,会作为 node 的 key去查找。
30
30
  // nodeProps: _index 是 key 时,对应的node
31
- scrollIntoView: (e, t) => {
32
- let n = e;
31
+ scrollIntoView: (e, s) => {
32
+ let t = e;
33
33
  if (typeof e == "string") {
34
34
  let r = e;
35
- !u.has(e) && (t != null && t.pathParentKeys) && (r = [...t.pathParentKeys].reverse().find((o) => u.has(o)) || n), n = d.findIndex(({ _key: o }) => o === r);
35
+ !c.has(e) && s?.pathParentKeys && (r = [...s.pathParentKeys].reverse().find((o) => c.has(o)) || t), t = d.findIndex(({ _key: o }) => o === r);
36
36
  }
37
- if (!x && f.current) {
38
- const r = f.current, o = r ? r.children[n] : null;
39
- o && b(o, {
37
+ if (!L && u.current) {
38
+ const r = u.current, o = r ? r.children[t] : null;
39
+ o && V(o, {
40
40
  boundary: r.parentElement
41
41
  });
42
- } else l.current && l.current.scrollTo({ index: n });
42
+ } else l.current && l.current.scrollTo({ index: t });
43
43
  }
44
- })), x ? /* @__PURE__ */ L(
45
- P,
44
+ })), L ? /* @__PURE__ */ x(
45
+ b,
46
46
  {
47
- className: K,
48
- style: p,
47
+ className: h,
48
+ style: m,
49
49
  ref: l,
50
50
  data: d,
51
51
  isStaticItemHeight: !1,
52
52
  itemKey: H,
53
- onMouseDown: s.onMouseDown,
54
- ...s.ariaProps,
55
- ...c,
56
- children: (e, t, { itemIndex: n }) => {
57
- n === 0 && (D.current = M());
58
- const y = S(e, D.current);
59
- return /* @__PURE__ */ g(v, { ...e, key: e.key, ...y });
53
+ onMouseDown: n.onMouseDown,
54
+ ...n.ariaProps,
55
+ ...K,
56
+ children: (e, s, { itemIndex: t }) => {
57
+ t === 0 && (S.current = g());
58
+ const f = k(e, S.current);
59
+ return /* @__PURE__ */ D(I, { ...e, key: e.key, ...f });
60
60
  }
61
61
  }
62
- ) : /* @__PURE__ */ L(
62
+ ) : /* @__PURE__ */ x(
63
63
  "div",
64
64
  {
65
65
  role: "tree",
66
66
  tabIndex: 0,
67
- className: K,
68
- style: p,
69
- ref: f,
70
- ...s.ariaProps,
71
- onMouseDown: s.onMouseDown,
67
+ className: h,
68
+ style: m,
69
+ ref: u,
70
+ ...n.ariaProps,
71
+ onMouseDown: n.onMouseDown,
72
72
  children: d.map((e) => {
73
- const t = S(e);
74
- return /* @__PURE__ */ g(v, { ...t, key: e.key });
73
+ const s = k(e);
74
+ return /* @__PURE__ */ D(I, { ...s, key: e.key });
75
75
  })
76
76
  }
77
77
  );
78
78
  }
79
- const z = N(j);
79
+ const z = M(j);
80
80
  export {
81
81
  z as default
82
82
  };