@unicom-cloud/ui 0.8.96 → 0.8.98

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 (302) hide show
  1. package/Affix.js +1 -1
  2. package/Carousel.js +1 -1
  3. package/LiquidFill.js +4 -0
  4. package/OverflowEllipsis.js +1 -1
  5. package/PageHeader.js +1 -1
  6. package/QrCode.js +57 -0
  7. package/Tour.js +63 -0
  8. package/Trigger.js +1 -1
  9. package/_virtual/_commonjsHelpers.js +6 -0
  10. package/_virtual/index.js +7 -0
  11. package/_virtual/index2.js +4 -0
  12. package/affix/index.js +70 -72
  13. package/alert/index.js +56 -56
  14. package/anchor/Anchor.js +55 -55
  15. package/anchor/Link.js +34 -34
  16. package/anchor/util.js +5 -5
  17. package/auto-complete/index.js +116 -122
  18. package/avatar/Avatar.js +33 -33
  19. package/avatar/Group.js +26 -26
  20. package/back-top/index.js +58 -61
  21. package/badge/index.js +46 -46
  22. package/breadcrumb/Item.js +42 -43
  23. package/breadcrumb/index.js +47 -47
  24. package/button/Group.js +6 -6
  25. package/button/index.js +91 -91
  26. package/calendar/Month.js +75 -75
  27. package/calendar/Year.js +35 -35
  28. package/calendar/header/index.js +25 -25
  29. package/calendar/index.js +103 -103
  30. package/card/Grid.js +8 -8
  31. package/card/Meta.js +16 -16
  32. package/card/index.js +49 -49
  33. package/carousel/Arrow.js +19 -19
  34. package/carousel/Indicator.js +26 -26
  35. package/carousel/index.js +108 -108
  36. package/cascader/Cascader.js +178 -191
  37. package/cascader/base/node.js +133 -136
  38. package/cascader/base/store.js +82 -85
  39. package/cascader/panel/List.js +125 -129
  40. package/cascader/panel/Search.js +79 -81
  41. package/cascader/util.js +13 -13
  42. package/checkbox/Checkbox.js +94 -96
  43. package/checkbox/Group.js +54 -56
  44. package/checkbox/GroupBlock.js +28 -29
  45. package/collapse/Collapse.js +45 -45
  46. package/collapse/Item.js +53 -55
  47. package/color-picker/ControlBar.js +43 -43
  48. package/color-picker/InputAlpha.js +12 -12
  49. package/color-picker/InputHex.js +30 -31
  50. package/color-picker/InputRgb.js +24 -24
  51. package/color-picker/Palette.js +18 -18
  52. package/color-picker/Panel.js +122 -125
  53. package/color-picker/hooks/useColorPicker.js +85 -88
  54. package/color-picker/hooks/useControlBlock.js +38 -40
  55. package/color-picker/index.js +47 -47
  56. package/comment/index.js +29 -29
  57. package/components/common/higher-order/with-speech-synthesis/index.js +37 -40
  58. package/components/common/hooks/useId.js +8 -8
  59. package/components/common/hooks/useInView.js +16 -16
  60. package/components/common/hooks/useIntersectionObserver.js +1 -1
  61. package/components/common/hooks/useKeyboardEvent.js +9 -10
  62. package/components/common/hooks/useOverflowHidden.js +1 -4
  63. package/components/common/hooks/usePersistCallback.js +7 -7
  64. package/components/common/hooks/useStateCallback.js +9 -10
  65. package/components/common/hooks/useWindowSize.js +8 -8
  66. package/components/common/space/index.js +9 -7
  67. package/components/common/utils/convertToDurationBasedOnTimeUnits.js +6 -0
  68. package/components/common/utils/dom.js +27 -29
  69. package/components/common/utils/findScrollParent.js +17 -0
  70. package/components/common/utils/intersectionObserver.js +21 -0
  71. package/components/common/utils/is.js +99 -109
  72. package/components/common/utils/mutationObserver.js +19 -0
  73. package/components/common/utils/reactDOM.js +34 -34
  74. package/components/common/utils/resizeObserver.js +21 -0
  75. package/copy/index.js +38 -40
  76. package/date-picker/Picker.js +290 -295
  77. package/date-picker/RangePicker.js +367 -372
  78. package/date-picker/index.js +33 -35
  79. package/date-picker/panel/Body.js +46 -47
  80. package/date-picker/panel/Header.js +33 -33
  81. package/date-picker/panel/Shortcut.js +31 -31
  82. package/date-picker/panel/date/index.js +85 -85
  83. package/date-picker/panel/month/index.js +59 -59
  84. package/date-picker/panel/quarter/index.js +67 -70
  85. package/date-picker/panel/range/index.js +101 -101
  86. package/date-picker/panel/year/index.js +39 -39
  87. package/date-picker/util.js +17 -18
  88. package/descriptions/index.js +62 -62
  89. package/details/index.js +53 -55
  90. package/development/index.js +9 -9
  91. package/dist/tinycolor/chunk/BOzCVdr0.js +1 -1
  92. package/dist/validate/src/index.js +5 -5
  93. package/dist/validate/src/util.js +1 -1
  94. package/divider/index.js +21 -21
  95. package/draggable/Item.js +35 -35
  96. package/draggable/index.js +22 -22
  97. package/drawer/Drawer.js +142 -147
  98. package/dropdown/Button.js +48 -48
  99. package/dropdown/index.js +88 -92
  100. package/empty/index.js +16 -16
  101. package/form/Control.js +211 -225
  102. package/form/Form.js +109 -113
  103. package/form/FormItem.js +118 -120
  104. package/form/FormList.js +60 -66
  105. package/form/FormProvider.js +31 -34
  106. package/form/hook/useContext.js +17 -19
  107. package/form/hook/useState.js +22 -23
  108. package/form/hook/useWatch.js +26 -27
  109. package/form/promisify.js +14 -18
  110. package/form/store.js +304 -316
  111. package/form/util.js +14 -15
  112. package/grid/Col.js +64 -64
  113. package/grid/Grid.js +51 -51
  114. package/grid/GridItem.js +48 -48
  115. package/grid/Row.js +39 -39
  116. package/hooks/useVerificationCode.js +41 -43
  117. package/hooks/useWatermark.js +89 -92
  118. package/icon/index.js +23 -24
  119. package/icon-hover/index.js +16 -16
  120. package/icons/file.js +11 -11
  121. package/image/Image.js +140 -141
  122. package/image/ImagePreview.js +252 -255
  123. package/image/ImagePreviewArrow.js +25 -25
  124. package/image/ImagePreviewGroup.js +62 -62
  125. package/image/util/getScale.js +25 -28
  126. package/index.js +684 -675
  127. package/input/Button.js +48 -50
  128. package/input/Group.js +9 -9
  129. package/input/Input.js +145 -154
  130. package/input/InputElement.js +108 -115
  131. package/input/Password.js +38 -38
  132. package/input/Search.js +51 -55
  133. package/input/Textarea.js +80 -81
  134. package/input/useComposition.js +23 -23
  135. package/input-number/decimal.js +59 -62
  136. package/input-number/index.js +139 -141
  137. package/input-tag/InputTag.js +222 -230
  138. package/layout/Content.js +6 -6
  139. package/layout/Footer.js +8 -8
  140. package/layout/Header.js +7 -7
  141. package/layout/Sider.js +88 -90
  142. package/layout/index.js +30 -30
  143. package/link/index.js +45 -46
  144. package/liquid-fill/LiquidFill.js +226 -0
  145. package/liquid-fill/LiquidFill2.js +3 -0
  146. package/liquid-fill/index.js +4 -0
  147. package/list/Item.js +28 -28
  148. package/list/Meta.js +12 -12
  149. package/list/index.js +146 -148
  150. package/mentions/index.js +75 -76
  151. package/menu/Item.js +58 -58
  152. package/menu/Menu.js +125 -127
  153. package/menu/OverflowWrap.js +39 -40
  154. package/menu/sub-menu/Inline.js +45 -45
  155. package/menu/util.js +26 -28
  156. package/message/index.js +96 -99
  157. package/message/useMessage.js +26 -27
  158. package/modal/Confirm.js +47 -49
  159. package/modal/Modal.js +250 -257
  160. package/modal/use-modal/Hook.js +26 -28
  161. package/modal/use-modal/index.js +46 -49
  162. package/notice/index.js +89 -90
  163. package/notification/index.js +60 -65
  164. package/notification/withNotification.js +35 -35
  165. package/overflow-ellipsis/OverflowItem.js +19 -20
  166. package/overflow-ellipsis/index.js +45 -46
  167. package/package.json +1 -1
  168. package/page-header/index.js +45 -45
  169. package/pagination/PageItem.js +87 -91
  170. package/pagination/PageJumper.js +40 -41
  171. package/pagination/PageOption.js +31 -35
  172. package/pagination/Pagination.js +162 -163
  173. package/picker/Input.js +90 -96
  174. package/picker/InputRange.js +115 -122
  175. package/popconfirm/index.js +98 -100
  176. package/popover/index.js +28 -28
  177. package/portal/Portal.js +10 -11
  178. package/progress/index.js +36 -36
  179. package/qr-code/index.js +99 -0
  180. package/qr-code/interface.js +1 -0
  181. package/radio/Group.js +48 -48
  182. package/radio/GroupBlock.js +32 -33
  183. package/radio/Radio.js +62 -64
  184. package/rate/index.js +88 -88
  185. package/resize-box/ResizeTrigger.js +39 -39
  186. package/resize-box/Split.js +92 -96
  187. package/resize-box/SplitGroup.js +116 -122
  188. package/resize-box/index.js +112 -115
  189. package/result/index.js +44 -44
  190. package/select/Option.js +53 -56
  191. package/select/Select.js +365 -381
  192. package/select/util.js +95 -99
  193. package/select-view/Core.js +159 -160
  194. package/skeleton/index.js +23 -23
  195. package/slider/Button.js +84 -92
  196. package/slider/Input.js +47 -49
  197. package/slider/Tick.js +28 -31
  198. package/slider/index.js +107 -107
  199. package/space/index.js +26 -26
  200. package/space-/index.js +51 -51
  201. package/spin/DotLoading.js +8 -8
  202. package/spin/index.js +47 -47
  203. package/statistic/Countdown.js +37 -37
  204. package/statistic/index.js +58 -58
  205. package/steps/Step.js +42 -42
  206. package/steps/index.js +54 -54
  207. package/style.css +1 -1
  208. package/switch/index.js +77 -78
  209. package/table/ColGroup.js +36 -37
  210. package/table/Table.js +447 -450
  211. package/table/hook/useExpand.js +24 -24
  212. package/table/hook/useRowSelection.js +62 -62
  213. package/table/summary/Row.js +16 -17
  214. package/table/tbody/Td.js +119 -118
  215. package/table/tbody/Tr.js +119 -121
  216. package/table/tbody/index.js +62 -63
  217. package/table/th-resizable/index.js +30 -30
  218. package/table/thead/Column.js +148 -148
  219. package/table/thead/index.js +87 -88
  220. package/tabs/Tab.js +55 -55
  221. package/tabs/TabContent.js +8 -8
  222. package/tabs/TabPane.js +15 -15
  223. package/tabs/hook/useHeaderScroll.js +36 -36
  224. package/tabs/tab-header/TabInk.js +31 -33
  225. package/tabs/tab-header/TabNavIcon.js +34 -35
  226. package/tabs/tab-header/index.js +192 -195
  227. package/tag/index.js +94 -97
  228. package/time-picker/Picker.js +167 -172
  229. package/time-picker/RangePicker.js +28 -28
  230. package/time-picker/TimePicker.js +146 -146
  231. package/timeline/Item.js +46 -46
  232. package/timeline/Timeline.js +52 -52
  233. package/tooltip/index.js +89 -95
  234. package/tour/index.js +289 -0
  235. package/transfer/Item.js +54 -54
  236. package/transfer/List.js +134 -136
  237. package/transfer/index.js +91 -91
  238. package/tree/Animation.js +49 -52
  239. package/tree/Node.js +114 -122
  240. package/tree/NodeList.js +51 -51
  241. package/tree/Tree.js +386 -393
  242. package/tree-select/List.js +71 -72
  243. package/tree-select/Select.js +135 -143
  244. package/tree-select/hook/useKeyCache.js +39 -39
  245. package/tree-select/hook/useStateValue.js +12 -12
  246. package/trigger/getPopupStyle.js +60 -61
  247. package/trigger/index.js +337 -346
  248. package/types/common/space/interface.d.ts +1 -1
  249. package/types/common/utils/convertToDurationBasedOnTimeUnits.d.ts +3 -0
  250. package/types/common/utils/findScrollParent.d.ts +2 -0
  251. package/types/common/utils/index.d.ts +5 -0
  252. package/types/common/utils/intersectionObserver.d.ts +2 -0
  253. package/types/common/utils/mutationObserver.d.ts +2 -0
  254. package/types/common/utils/resizeObserver.d.ts +2 -0
  255. package/types/pc/config-provider/interface.d.ts +6 -0
  256. package/types/pc/index.d.ts +3 -0
  257. package/types/pc/liquid-fill/LiquidFill.d.ts +115 -0
  258. package/types/pc/liquid-fill/LiquidFill2.d.ts +1 -0
  259. package/types/pc/liquid-fill/index.d.ts +2 -0
  260. package/types/pc/qr-code/index.d.ts +34 -0
  261. package/types/pc/qr-code/interface.d.ts +39 -0
  262. package/types/pc/table/interface.d.ts +2 -2
  263. package/types/pc/tour/index.d.ts +42 -0
  264. package/types/pc/utils/convertToDurationBasedOnTimeUnits.d.ts +3 -0
  265. package/types/pc/utils/findScrollParent.d.ts +2 -0
  266. package/types/pc/utils/index.d.ts +5 -0
  267. package/types/pc/utils/intersectionObserver.d.ts +2 -0
  268. package/types/pc/utils/mutationObserver.d.ts +2 -0
  269. package/types/pc/utils/names.d.ts +18 -0
  270. package/types/pc/utils/resizeObserver.d.ts +2 -0
  271. package/typography/Base.js +79 -81
  272. package/typography/EditContent.js +30 -33
  273. package/typography/Ellipsis.js +77 -73
  274. package/typography/Operations.js +50 -52
  275. package/typography/Paragraph.js +7 -7
  276. package/typography/Typography.js +7 -7
  277. package/typography/useEllipsis.js +105 -106
  278. package/upload/TriggerNode.js +69 -76
  279. package/upload/Upload.js +84 -87
  280. package/upload/Uploader.js +115 -118
  281. package/upload/list/PictureItem.js +61 -71
  282. package/upload/list/TextItem.js +61 -67
  283. package/upload/list/UploadProgress.js +42 -49
  284. package/upload/list/index.js +48 -49
  285. package/upload/request_.js +37 -38
  286. package/upload/util.js +39 -39
  287. package/utils/convertToDurationBasedOnTimeUnits.js +6 -0
  288. package/utils/findScrollParent.js +4 -0
  289. package/utils/index.js +281 -278
  290. package/utils/intersectionObserver.js +4 -0
  291. package/utils/mutationObserver.js +4 -0
  292. package/utils/names.js +12 -0
  293. package/utils/resizeObserver.js +4 -0
  294. package/verification-code/VerificationCode.js +50 -51
  295. package/version/index.js +1 -1
  296. package/virtual-list/VirtualList.js +243 -244
  297. package/virtual-list/util/item.js +3 -4
  298. package/watermark/Watermark.js +27 -31
  299. package/components/common/utils/resizeObserverEffect.js +0 -23
  300. package/types/common/utils/resizeObserverEffect.d.ts +0 -2
  301. package/types/pc/utils/resizeObserverEffect.d.ts +0 -2
  302. package/utils/resizeObserverEffect.js +0 -4
package/menu/Item.js CHANGED
@@ -1,90 +1,90 @@
1
- import { jsxs as k, jsx as o, Fragment as D } from "react/jsx-runtime";
1
+ import { jsxs as N, jsx as o, Fragment as D } from "react/jsx-runtime";
2
2
  import F from "../dist/scroll-into-view-if-needed/src/index.js";
3
3
  import { forwardRef as O, useContext as j, useRef as B, useEffect as K } from "react";
4
4
  import U from "../components/common/hooks/useIsFirstRender.js";
5
5
  import z from "../tooltip/index.js";
6
6
  import A from "@unicom-cloud/utils/class-name";
7
7
  import { Enter as H } from "@unicom-cloud/utils/constant/keyboardCode";
8
- import { omit as x } from "../components/common/utils/omit.js";
8
+ import { omit as h } from "../components/common/utils/omit.js";
9
9
  import V from "./Indent.js";
10
10
  import W from "./context.js";
11
11
  import { PROPS_NEED_TO_BE_PASSED_IN_SUBMENU as q } from "./util.js";
12
- function G(T, p) {
12
+ function G(b, c) {
13
13
  const {
14
- _key: f,
15
- children: i,
16
- level: m,
14
+ _key: a,
15
+ children: s,
16
+ level: i,
17
17
  disabled: l,
18
- className: _,
19
- style: $,
20
- wrapper: S = "div",
21
- onClick: c,
22
- renderItemInTooltip: u,
23
- ...w
24
- } = T, {
18
+ className: x,
19
+ style: E,
20
+ wrapper: T = "div",
21
+ onClick: _,
22
+ renderItemInTooltip: d,
23
+ ...$
24
+ } = b, {
25
25
  prefixCls: t,
26
- mode: y,
27
- collapse: a,
28
- inDropdown: C,
29
- levelIndent: R,
30
- selectedKeys: I,
31
- autoScrollIntoView: g,
32
- scrollConfig: v,
33
- tooltipProps: r,
34
- onClickMenuItem: d
35
- } = j(W), n = B(null), M = U(), N = y === "vertical" && m > 1, P = a && !C && m === 1, s = I && ~I.indexOf(f);
26
+ mode: p,
27
+ collapse: m,
28
+ inDropdown: M,
29
+ levelIndent: P,
30
+ selectedKeys: f,
31
+ autoScrollIntoView: u,
32
+ scrollConfig: S,
33
+ tooltipProps: y,
34
+ onClickMenuItem: w
35
+ } = j(W), r = B(null), R = U(), I = p === "vertical" && i > 1, v = m && !M && i === 1, n = f && ~f.indexOf(a);
36
36
  K(() => {
37
- const e = s && g;
38
- n.current && e && setTimeout(
37
+ const e = n && u;
38
+ r.current && e && setTimeout(
39
39
  () => {
40
- n.current && F(n.current, {
40
+ r.current && F(r.current, {
41
41
  behavior: "smooth",
42
42
  block: "start",
43
43
  scrollMode: "if-needed",
44
44
  boundary: document.body,
45
- ...v
45
+ ...S
46
46
  });
47
47
  },
48
- M ? 500 : 0
48
+ R ? 500 : 0
49
49
  );
50
- }, [s, g]);
51
- const h = (e) => {
52
- l || (d == null || d(f, e), c == null || c(e));
53
- }, b = /* @__PURE__ */ k(
54
- S,
50
+ }, [n, u]);
51
+ const k = (e) => {
52
+ l || (w?.(a, e), _?.(e));
53
+ }, g = /* @__PURE__ */ N(
54
+ T,
55
55
  {
56
56
  tabIndex: l ? -1 : 0,
57
57
  role: "menuitem",
58
58
  ref: (e) => {
59
- p = e, n.current = p;
59
+ c = e, r.current = c;
60
60
  },
61
- style: $,
61
+ style: E,
62
62
  className: A(
63
63
  `${t}-item`,
64
64
  {
65
65
  [`${t}-disabled`]: l,
66
- [`${t}-selected`]: s,
66
+ [`${t}-selected`]: n,
67
67
  // 存在缩进dom
68
- [`${t}-item-indented`]: N && !a
68
+ [`${t}-item-indented`]: I && !m
69
69
  },
70
- _
70
+ x
71
71
  ),
72
- onClick: h,
72
+ onClick: k,
73
73
  onKeyDown: (e) => {
74
- e.key === H.key && h(e);
74
+ e.key === H.key && k(e);
75
75
  },
76
- ...x(
77
- w,
76
+ ...h(
77
+ $,
78
78
  ["key", "_key"].concat(q)
79
79
  ),
80
80
  children: [
81
- N && !a ? /* @__PURE__ */ k(D, { children: [
81
+ I && !m ? /* @__PURE__ */ N(D, { children: [
82
82
  /* @__PURE__ */ o(
83
83
  V,
84
84
  {
85
85
  prefixCls: t,
86
- levelIndent: R,
87
- level: m
86
+ levelIndent: P,
87
+ level: i
88
88
  }
89
89
  ),
90
90
  /* @__PURE__ */ o(
@@ -94,32 +94,32 @@ function G(T, p) {
94
94
  style: {
95
95
  display: "block"
96
96
  },
97
- children: i
97
+ children: s
98
98
  }
99
99
  )
100
- ] }) : i,
101
- s && y === "horizontal" ? /* @__PURE__ */ o("div", { className: `${t}-selected-label` }) : null
100
+ ] }) : s,
101
+ n && p === "horizontal" ? /* @__PURE__ */ o("div", { className: `${t}-selected-label` }) : null
102
102
  ]
103
103
  }
104
104
  );
105
- return P ? /* @__PURE__ */ o(
105
+ return v ? /* @__PURE__ */ o(
106
106
  z,
107
107
  {
108
108
  trigger: "hover",
109
109
  position: "right",
110
- content: typeof u == "function" ? u() : /* @__PURE__ */ o("span", { children: i }),
110
+ content: typeof d == "function" ? d() : /* @__PURE__ */ o("span", { children: s }),
111
111
  triggerProps: {
112
112
  className: `${t}-item-tooltip`,
113
- ...(r == null ? void 0 : r.triggerProps) || {}
113
+ ...y?.triggerProps || {}
114
114
  },
115
- ...x(r, ["triggerProps"]),
116
- children: b
115
+ ...h(y, ["triggerProps"]),
116
+ children: g
117
117
  }
118
- ) : b;
118
+ ) : g;
119
119
  }
120
- const J = O(G), E = J;
121
- E.displayName = "MenuItem";
122
- E.menuType = "MenuItem";
120
+ const J = O(G), C = J;
121
+ C.displayName = "MenuItem";
122
+ C.menuType = "MenuItem";
123
123
  export {
124
- E as default
124
+ C as default
125
125
  };
package/menu/Menu.js CHANGED
@@ -1,184 +1,182 @@
1
- import { jsx as c, jsxs as de, Fragment as fe } from "react/jsx-runtime";
2
- import Me from "@unicom-cloud/icons/IconUiMenuFold";
3
- import he from "@unicom-cloud/icons/IconUiMenuUnfold";
4
- import Ce from "lodash/isPlainObject";
5
- import { forwardRef as ve, useContext as y, useRef as U, useMemo as Ie, useEffect as xe } from "react";
1
+ import { jsx as c, jsxs as me, Fragment as de } from "react/jsx-runtime";
2
+ import fe from "@unicom-cloud/icons/IconUiMenuFold";
3
+ import Ce from "@unicom-cloud/icons/IconUiMenuUnfold";
4
+ import Me from "lodash/isPlainObject";
5
+ import { forwardRef as he, useContext as I, useRef as $, useMemo as Ie, useEffect as xe } from "react";
6
6
  import "../config-provider/ConfigProvider.js";
7
- import be from "../components/common/hooks/useForceUpdate.js";
8
- import Ke from "../components/common/hooks/useId.js";
9
- import ye from "../components/common/hooks/useKeyboardEvent.js";
10
- import Se from "../components/common/hooks/useMergeProps.js";
11
- import S from "../components/common/hooks/useMergeValue.js";
12
- import { SiderContext as $e } from "../layout/Sider.js";
13
- import ge from "@unicom-cloud/utils/class-name";
14
- import { omit as Oe } from "../components/common/utils/omit.js";
15
- import _ from "./context.js";
16
- import Pe from "./Item.js";
17
- import Ee from "./ItemGroup.js";
18
- import we from "./OverflowWrap.js";
19
- import Ne from "./sub-menu/index.js";
20
- import { generateInfoMap as Be, processChildren as Ue } from "./util.js";
21
- import _e from "../config-provider/context.js";
22
- const Fe = "light", ze = {
7
+ import ve from "../components/common/hooks/useForceUpdate.js";
8
+ import be from "../components/common/hooks/useId.js";
9
+ import ge from "../components/common/hooks/useKeyboardEvent.js";
10
+ import Ke from "../components/common/hooks/useMergeProps.js";
11
+ import x from "../components/common/hooks/useMergeValue.js";
12
+ import { SiderContext as ye } from "../layout/Sider.js";
13
+ import Se from "@unicom-cloud/utils/class-name";
14
+ import { omit as Pe } from "../components/common/utils/omit.js";
15
+ import O from "./context.js";
16
+ import $e from "./Item.js";
17
+ import Oe from "./ItemGroup.js";
18
+ import Ee from "./OverflowWrap.js";
19
+ import we from "./sub-menu/index.js";
20
+ import { generateInfoMap as Ne, processChildren as Be } from "./util.js";
21
+ import Ue from "../config-provider/context.js";
22
+ const _e = "light", Fe = {
23
23
  mode: "vertical",
24
24
  selectable: !0,
25
25
  ellipsis: !0
26
26
  };
27
- function Te(F, z) {
28
- const { getPrefixCls: f, componentConfig: M, rtl: T } = y(_e), V = Se(
29
- F,
30
- ze,
31
- M == null ? void 0 : M.Menu
27
+ function ze(E, w) {
28
+ const { getPrefixCls: N, componentConfig: B, rtl: U } = I(Ue), _ = Ke(
29
+ E,
30
+ Fe,
31
+ B?.Menu
32
32
  ), {
33
- style: j,
34
- children: h,
35
- className: A,
36
- prefixCls: D,
37
- mode: l,
38
- theme: G,
33
+ style: F,
34
+ children: f,
35
+ className: z,
36
+ prefixCls: T,
37
+ mode: r,
38
+ theme: V,
39
39
  icons: p,
40
- levelIndent: H,
41
- collapse: R,
40
+ levelIndent: j,
41
+ collapse: A,
42
42
  inDropdown: u,
43
- selectable: L,
44
- triggerProps: Q,
45
- tooltipProps: W,
43
+ selectable: D,
44
+ triggerProps: G,
45
+ tooltipProps: H,
46
46
  ellipsis: C,
47
- accordion: v,
48
- autoOpen: q,
49
- autoScrollIntoView: J,
50
- scrollConfig: X,
51
- hasCollapseButton: Y,
52
- defaultOpenKeys: Z,
53
- defaultSelectedKeys: k,
54
- openKeys: ee,
55
- selectedKeys: te,
56
- onClickSubMenu: I,
57
- onClickMenuItem: x,
58
- onCollapseChange: b,
47
+ accordion: M,
48
+ autoOpen: R,
49
+ autoScrollIntoView: L,
50
+ scrollConfig: k,
51
+ hasCollapseButton: Q,
52
+ defaultOpenKeys: W,
53
+ defaultSelectedKeys: q,
54
+ openKeys: J,
55
+ selectedKeys: X,
56
+ onClickSubMenu: Y,
57
+ onClickMenuItem: Z,
58
+ onCollapseChange: ee,
59
59
  onEllipsisChange: oe,
60
- ...$
61
- } = V, [r, g] = S([], {
62
- defaultValue: Z,
63
- value: ee
64
- }), [ne, re] = S([], {
65
- defaultValue: k,
66
- value: te
67
- }), [m, se] = S(!1, {
68
- value: R
69
- }), le = y(_), { siderCollapsed: ie } = y($e), o = D || (f == null ? void 0 : f("menu")), d = ie || m || u || l === "popButton", O = G || le.theme || Fe, i = U([]), P = U([]), ce = be(), pe = ye(), E = Ie(() => Be(h), [h]), ae = Ke(`${o}-`), K = $.id || ae;
60
+ ...v
61
+ } = _, [l, b] = x([], {
62
+ defaultValue: W,
63
+ value: J
64
+ }), [te, ne] = x([], {
65
+ defaultValue: q,
66
+ value: X
67
+ }), [m, re] = x(!1, {
68
+ value: A
69
+ }), se = I(O), { siderCollapsed: le } = I(ye), t = T || N?.("menu"), d = le || m || u || r === "popButton", g = V || se.theme || _e, i = $([]), K = $([]), ie = ve(), ce = ge(), y = Ie(() => Ne(f), [f]), pe = be(`${t}-`), h = v.id || pe;
70
70
  xe(() => {
71
- let e = r.filter(
72
- (t) => i.current.indexOf(t) !== -1
71
+ let e = l.filter(
72
+ (o) => i.current.indexOf(o) !== -1
73
73
  );
74
- if (q) {
75
- const t = i.current.filter(
76
- (n) => P.current.indexOf(n) === -1
74
+ if (R) {
75
+ const o = i.current.filter(
76
+ (s) => K.current.indexOf(s) === -1
77
77
  );
78
- e = r.concat(t);
78
+ e = l.concat(o);
79
79
  }
80
- g(v ? e.slice(0, 1) : e), P.current = i.current.slice();
80
+ b(M ? e.slice(0, 1) : e), K.current = i.current.slice();
81
81
  }, [i.current.toString()]);
82
- const w = l !== "horizontal" && l !== "popButton" && !u && Y, ue = () => {
83
- const e = Ue(h, { level: 1 }), t = m ? p && p.collapseActive || /* @__PURE__ */ c(he, {}) : p && p.collapseDefault || /* @__PURE__ */ c(Me, {}), n = () => {
84
- const s = !m;
85
- se(s), b == null || b(s);
82
+ const S = r !== "horizontal" && r !== "popButton" && !u && Q, ae = () => {
83
+ const e = Be(f, { level: 1 }), o = m ? p && p.collapseActive || /* @__PURE__ */ c(Ce, {}) : p && p.collapseDefault || /* @__PURE__ */ c(fe, {}), s = () => {
84
+ const n = !m;
85
+ re(n), ee?.(n);
86
86
  };
87
- return /* @__PURE__ */ de(fe, { children: [
88
- /* @__PURE__ */ c("div", { className: `${o}-inner`, children: l === "horizontal" && C !== !1 ? /* @__PURE__ */ c(
89
- we,
87
+ return /* @__PURE__ */ me(de, { children: [
88
+ /* @__PURE__ */ c("div", { className: `${t}-inner`, children: r === "horizontal" && C !== !1 ? /* @__PURE__ */ c(
89
+ Ee,
90
90
  {
91
- ellipsisText: Ce(C) ? C.text : "···",
91
+ ellipsisText: Me(C) ? C.text : "···",
92
92
  onEllipsisChange: oe,
93
93
  children: e
94
94
  }
95
95
  ) : e }),
96
- w && /* @__PURE__ */ c(
96
+ S && /* @__PURE__ */ c(
97
97
  "div",
98
98
  {
99
99
  tabIndex: 0,
100
100
  role: "button",
101
- "aria-controls": K,
101
+ "aria-controls": h,
102
102
  "aria-expanded": !m,
103
- className: `${o}-collapse-button`,
104
- onClick: n,
105
- ...pe({ onPressEnter: n }),
106
- children: t
103
+ className: `${t}-collapse-button`,
104
+ onClick: s,
105
+ ...ce({ onPressEnter: s }),
106
+ children: o
107
107
  }
108
108
  )
109
109
  ] });
110
- }, N = { ...j };
111
- return d && !u && delete N.width, /* @__PURE__ */ c(
110
+ }, P = { ...F };
111
+ return d && !u && delete P.width, /* @__PURE__ */ c(
112
112
  "div",
113
113
  {
114
- id: w ? K : void 0,
114
+ id: S ? h : void 0,
115
115
  role: "menu",
116
- ...Oe($, ["isMenu"]),
117
- ref: z,
118
- style: N,
119
- className: ge(
120
- o,
121
- `${o}-${O}`,
122
- `${o}-${l === "horizontal" ? "horizontal" : "vertical"}`,
116
+ ...Pe(v, ["isMenu"]),
117
+ ref: w,
118
+ style: P,
119
+ className: Se(
120
+ t,
121
+ `${t}-${g}`,
122
+ `${t}-${r === "horizontal" ? "horizontal" : "vertical"}`,
123
123
  {
124
- [`${o}-collapse`]: d,
124
+ [`${t}-collapse`]: d,
125
125
  // 缩起状态自动变成 pop 模式
126
- [`${o}-pop`]: l === "pop" || d,
127
- [`${o}-pop-button`]: l === "popButton",
128
- [`${o}-rtl`]: T
126
+ [`${t}-pop`]: r === "pop" || d,
127
+ [`${t}-pop-button`]: r === "popButton",
128
+ [`${t}-rtl`]: U
129
129
  },
130
- A
130
+ z
131
131
  ),
132
132
  children: /* @__PURE__ */ c(
133
- _.Provider,
133
+ O.Provider,
134
134
  {
135
135
  value: {
136
- mode: l,
137
- theme: O,
136
+ mode: r,
137
+ theme: g,
138
138
  collapse: d,
139
- levelIndent: H,
139
+ levelIndent: j,
140
140
  inDropdown: u,
141
- selectedKeys: ne,
142
- openKeys: r,
141
+ selectedKeys: te,
142
+ openKeys: l,
143
143
  icons: p,
144
- triggerProps: Q,
145
- tooltipProps: W,
146
- autoScrollIntoView: J,
147
- scrollConfig: X,
144
+ triggerProps: G,
145
+ tooltipProps: H,
146
+ autoScrollIntoView: L,
147
+ scrollConfig: k,
148
148
  // pass props directly
149
- id: K,
150
- prefixCls: o,
151
- collectInlineMenuKeys: (e, t) => {
152
- t ? i.current = i.current.filter(
153
- (n) => n !== e
154
- ) : i.current.push(e), ce();
149
+ id: h,
150
+ prefixCls: t,
151
+ collectInlineMenuKeys: (e, o) => {
152
+ o ? i.current = i.current.filter(
153
+ (s) => s !== e
154
+ ) : i.current.push(e), ie();
155
155
  },
156
- onClickMenuItem: (e, t) => {
157
- var n;
158
- L && re([e]), x == null || x(e, t, (n = E[e]) == null ? void 0 : n.keyPath);
156
+ onClickMenuItem: (e, o) => {
157
+ D && ne([e]), Z?.(e, o, y[e]?.keyPath);
159
158
  },
160
- onClickSubMenu: (e, t, n) => {
161
- var B;
162
- let s = [...r];
163
- n === "inline" && ((r == null ? void 0 : r.indexOf(e)) > -1 ? v && t === 1 ? s = [] : s = r.filter((me) => me !== e) : v && t === 1 ? s = [e] : s = r.concat([e])), g(s), I == null || I(e, s, (B = E[e]) == null ? void 0 : B.keyPath);
159
+ onClickSubMenu: (e, o, s) => {
160
+ let n = [...l];
161
+ s === "inline" && (l?.indexOf(e) > -1 ? M && o === 1 ? n = [] : n = l.filter((ue) => ue !== e) : M && o === 1 ? n = [e] : n = l.concat([e])), b(n), Y?.(e, n, y[e]?.keyPath);
164
162
  }
165
163
  },
166
- children: ue()
164
+ children: ae()
167
165
  }
168
166
  )
169
167
  }
170
168
  );
171
169
  }
172
- const Ve = ve(Te), a = Ve;
170
+ const Te = he(ze), a = Te;
173
171
  a.displayName = "Menu";
174
- a.Item = Pe;
175
- a.SubMenu = Ne;
176
- a.ItemGroup = Ee;
172
+ a.Item = $e;
173
+ a.SubMenu = we;
174
+ a.ItemGroup = Oe;
177
175
  a.__PQB_MENU__ = !0;
178
176
  export {
179
- Pe as MenuItem,
180
- Ee as MenuItemGroup,
181
- Ne as MenuSubMenu,
182
- Ne as SubMenu,
177
+ $e as MenuItem,
178
+ Oe as MenuItemGroup,
179
+ we as MenuSubMenu,
180
+ we as SubMenu,
183
181
  a as default
184
182
  };
@@ -1,89 +1,88 @@
1
- import { jsx as b } from "react/jsx-runtime";
2
- import p, { useContext as $, useRef as T, useState as k, useEffect as A } from "react";
1
+ import { jsx as h } from "react/jsx-runtime";
2
+ import a, { useContext as $, useRef as T, useState as k, useEffect as A } from "react";
3
3
  import H from "@unicom-cloud/utils/class-name";
4
- import { resizeObserverEffect as U } from "../components/common/utils/resizeObserverEffect.js";
5
- import { getStyle as x } from "../components/common/utils/style.js";
4
+ import { resizeObserver as U } from "../components/common/utils/resizeObserver.js";
5
+ import { getStyle as C } from "../components/common/utils/style.js";
6
6
  import j from "./context.js";
7
7
  import q from "./sub-menu/index.js";
8
8
  const z = 5;
9
- function C(o) {
9
+ function S(o) {
10
10
  return o && Math.ceil(+o.getBoundingClientRect().width);
11
11
  }
12
- function O(o) {
13
- const s = Number(o.replace("px", ""));
14
- return isNaN(s) ? 0 : s;
12
+ function g(o) {
13
+ const l = Number(o.replace("px", ""));
14
+ return isNaN(l) ? 0 : l;
15
15
  }
16
16
  const K = (o) => {
17
- const { children: s, ellipsisText: g = "···", onEllipsisChange: v } = o, { prefixCls: d } = $(j), c = T(null), [f, E] = k(null), M = `${d}-overflow-sub-menu`, R = `${d}-overflow-hidden-menu-item`, N = `${d}-overflow-sub-menu-mirror`, h = (e) => {
18
- if (e !== f) {
19
- const t = p.Children.toArray(s), n = e === null;
20
- v == null || v({
17
+ const { children: l, ellipsisText: x = "···", onEllipsisChange: O } = o, { prefixCls: d } = $(j), i = T(null), [c, E] = k(null), v = `${d}-overflow-sub-menu`, R = `${d}-overflow-hidden-menu-item`, w = `${d}-overflow-sub-menu-mirror`, b = (e) => {
18
+ if (e !== c) {
19
+ const t = a.Children.toArray(l), n = e === null;
20
+ O?.({
21
21
  lastVisibleIndex: n ? t.length - 1 : e,
22
22
  overflowNodes: n ? [] : t.slice(e + 1)
23
23
  }), E(e);
24
24
  }
25
25
  };
26
26
  function y() {
27
- if (!c.current)
27
+ if (!i.current)
28
28
  return;
29
- const e = c.current, t = C(e) - z, n = [].slice.call(e.children);
30
- let r = 0, l = 0, m = 0;
31
- for (let u = 0; u < n.length; u++) {
32
- const i = n[u], a = i.className.split(" "), L = a.indexOf(M) > -1, W = a.indexOf(N) > -1;
29
+ const e = i.current, t = S(e) - z, n = [].slice.call(e.children);
30
+ let s = 0, u = 0, f = 0;
31
+ for (let m = 0; m < n.length; m++) {
32
+ const r = n[m], N = r.className.split(" "), L = N.indexOf(v) > -1, W = N.indexOf(w) > -1;
33
33
  if (L)
34
34
  continue;
35
- const w = C(i) + O(x(i, "marginLeft")) + O(x(i, "marginRight"));
35
+ const p = S(r) + g(C(r, "marginLeft")) + g(C(r, "marginRight"));
36
36
  if (W) {
37
- m = w;
37
+ f = p;
38
38
  continue;
39
39
  }
40
- if (l += w, l > t) {
41
- h(
40
+ if (u += p, u > t) {
41
+ b(
42
42
  // 判断如果将最后一个菜单项换为 ... 是否会超出宽度
43
- r - (l - w + m <= t ? 1 : 2)
43
+ s - (u - p + f <= t ? 1 : 2)
44
44
  );
45
45
  return;
46
46
  }
47
- r++;
47
+ s++;
48
48
  }
49
- h(null);
49
+ b(null);
50
50
  }
51
- const S = (e, t = !1) => /* @__PURE__ */ b(
51
+ const M = (e, t = !1) => /* @__PURE__ */ h(
52
52
  q,
53
53
  {
54
- title: /* @__PURE__ */ b("span", { children: g }),
55
- className: t ? N : M,
54
+ title: /* @__PURE__ */ h("span", { children: x }),
55
+ className: t ? w : v,
56
56
  children: e
57
57
  },
58
58
  `pqb-menu-overflow-sub-menu${t ? "-mirror" : ""}`
59
59
  ), I = () => {
60
60
  let e = null;
61
- const t = S(null, !0), n = p.Children.map(s, (r, l) => {
62
- var u;
63
- let m = r;
64
- if (f !== null && (l > f && (m = p.cloneElement(r, {
61
+ const t = M(null, !0), n = a.Children.map(l, (s, u) => {
62
+ let f = s;
63
+ if (c !== null && (u > c && (f = a.cloneElement(s, {
65
64
  className: H(
66
65
  R,
67
- (u = r == null ? void 0 : r.props) == null ? void 0 : u.className
66
+ s?.props?.className
68
67
  )
69
- })), l === f + 1)) {
70
- const i = p.Children.toArray(s).slice(f + 1).map(
71
- (a) => p.cloneElement(a, {
72
- key: a.props._key
68
+ })), u === c + 1)) {
69
+ const m = a.Children.toArray(l).slice(c + 1).map(
70
+ (r) => a.cloneElement(r, {
71
+ key: r.props._key
73
72
  })
74
73
  );
75
- e = S(i);
74
+ e = M(m);
76
75
  }
77
- return m;
76
+ return f;
78
77
  }) ?? [];
79
78
  return [t, ...n, e];
80
79
  };
81
80
  return A(() => {
82
- const e = U([c.current], y);
81
+ const e = U([i.current], y);
83
82
  return () => {
84
83
  e();
85
84
  };
86
- }, [c.current]), /* @__PURE__ */ b("div", { className: `${d}-overflow-wrap`, ref: c, children: I() });
85
+ }, [i.current]), /* @__PURE__ */ h("div", { className: `${d}-overflow-wrap`, ref: i, children: I() });
87
86
  };
88
87
  export {
89
88
  K as default