@unicom-cloud/ui 0.8.99 → 0.8.101

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 (293) hide show
  1. package/Anchor.js +3 -1
  2. package/Badge.js +7 -6
  3. package/Copy.js +49 -2
  4. package/Details.js +13 -2
  5. package/Divider.js +3 -2
  6. package/Flex.js +22 -0
  7. package/Grid.js +1 -1
  8. package/LiquidFill.js +3 -2
  9. package/Loading.js +16 -3
  10. package/Marquee.js +3 -2
  11. package/QrCode.js +3 -2
  12. package/Space.js +3 -3
  13. package/Splitter.js +5 -5
  14. package/SuspenseFallbackTest.js +2 -4
  15. package/Tag.js +3 -2
  16. package/Tour.js +3 -2
  17. package/alert/index.js +61 -64
  18. package/anchor/index.js +5 -3
  19. package/back-top/index.js +32 -33
  20. package/badge/index.js +19 -18
  21. package/calendar/index.js +85 -84
  22. package/components/common/development/index.js +44 -29
  23. package/components/common/empty/index.js +35 -23
  24. package/components/common/flex/index.js +64 -0
  25. package/components/common/flex/interface.js +9 -0
  26. package/components/common/higher-order/with-speech-synthesis/index.js +79 -55
  27. package/components/common/space/index.js +71 -91
  28. package/components/common/suspense-fallback-test/index.js +16 -0
  29. package/components/common/utils/toArray.js +12 -0
  30. package/copy/index.js +83 -35
  31. package/details/index.js +102 -62
  32. package/divider/index.js +27 -21
  33. package/empty/index.js +13 -13
  34. package/flex/index.js +47 -0
  35. package/flex/interface.js +1 -0
  36. package/grid/{GridItem.js → Item.js} +15 -15
  37. package/grid/index.js +1 -1
  38. package/icon/interface.js +1 -0
  39. package/icon-hover/interface.js +1 -0
  40. package/index.js +610 -599
  41. package/input/Button.js +39 -34
  42. package/input/Textarea.js +108 -104
  43. package/liquid-fill/index.js +3 -2
  44. package/loading/index.js +72 -53
  45. package/loading/interface.js +1 -0
  46. package/marquee/index.js +3 -2
  47. package/modal/Modal.js +73 -74
  48. package/package.json +1 -1
  49. package/portal/interface.js +1 -0
  50. package/qr-code/index.js +3 -2
  51. package/segmented/index.js +113 -105
  52. package/space/index.js +41 -35
  53. package/speech-synthesis/interface.js +1 -0
  54. package/spin/index.js +75 -62
  55. package/splitter/Panel.js +39 -0
  56. package/splitter/SplitBar.js +157 -0
  57. package/splitter/Splitter.js +135 -0
  58. package/splitter/hooks/useEvent.js +12 -0
  59. package/splitter/hooks/useItems.js +26 -0
  60. package/splitter/hooks/useResizable.js +26 -0
  61. package/splitter/hooks/useResize.js +68 -0
  62. package/splitter/hooks/useSizes.js +60 -0
  63. package/splitter/index.js +6 -115
  64. package/style.css +1 -1
  65. package/suspense-fallback-test/index.js +2 -11
  66. package/suspense-fallback-test/interface.js +1 -0
  67. package/table/Table.js +38 -38
  68. package/table/hook/useThResizable.js +72 -26
  69. package/table/tbody/Td.js +80 -77
  70. package/table/th-resizable/index.js +92 -35
  71. package/tag/index.js +42 -41
  72. package/tooltip/index.js +89 -82
  73. package/tour/index.js +5 -6
  74. package/trigger/index.js +67 -70
  75. package/types/common/development/index.d.ts +7 -1
  76. package/types/common/development/interface.d.ts +22 -0
  77. package/types/common/empty/index.d.ts +2 -1
  78. package/types/common/flex/index.d.ts +14 -0
  79. package/types/common/flex/interface.d.ts +62 -0
  80. package/types/common/higher-order/with-speech-synthesis/index.d.ts +6 -1
  81. package/types/common/higher-order/with-speech-synthesis/interface.d.ts +13 -0
  82. package/types/common/space/index.d.ts +4 -3
  83. package/types/common/space/interface.d.ts +10 -18
  84. package/types/common/suspense-fallback-test/index.d.ts +7 -0
  85. package/types/common/suspense-fallback-test/interface.d.ts +1 -0
  86. package/types/common/utils/PqbCSSTransition.d.ts +1 -1
  87. package/types/common/utils/toArray.d.ts +13 -0
  88. package/types/pc/affix/interface.d.ts +0 -2
  89. package/types/pc/alert/index.d.ts +3 -2
  90. package/types/pc/alert/interface.d.ts +7 -1
  91. package/types/pc/anchor/index.d.ts +2 -1
  92. package/types/pc/anchor/interface.d.ts +0 -2
  93. package/types/pc/auto-complete/interface.d.ts +0 -6
  94. package/types/pc/avatar/interface.d.ts +0 -4
  95. package/types/pc/badge/Count.d.ts +1 -1
  96. package/types/pc/breadcrumb/Item.d.ts +1 -1
  97. package/types/pc/breadcrumb/interface.d.ts +0 -3
  98. package/types/pc/calendar/Month.d.ts +1 -1
  99. package/types/pc/calendar/WeekList.d.ts +1 -1
  100. package/types/pc/calendar/Year.d.ts +1 -1
  101. package/types/pc/calendar/header/Panel.d.ts +1 -1
  102. package/types/pc/calendar/header/index.d.ts +1 -1
  103. package/types/pc/calendar/index.d.ts +1 -1
  104. package/types/pc/calendar/interface.d.ts +2 -1
  105. package/types/pc/carousel/interface.d.ts +2 -6
  106. package/types/pc/cascader/interface.d.ts +7 -19
  107. package/types/pc/cascader/panel/List.d.ts +1 -1
  108. package/types/pc/cascader/panel/Option.d.ts +1 -1
  109. package/types/pc/cascader/panel/Search.d.ts +1 -1
  110. package/types/pc/checkbox/Group.d.ts +2 -2
  111. package/types/pc/checkbox/GroupBlock.d.ts +1 -1
  112. package/types/pc/checkbox/IconCheck.d.ts +1 -1
  113. package/types/pc/checkbox/interface.d.ts +0 -1
  114. package/types/pc/collapse/interface.d.ts +0 -2
  115. package/types/pc/color-picker/InputRgb.d.ts +1 -1
  116. package/types/pc/color-picker/Palette.d.ts +1 -1
  117. package/types/pc/color-picker/interface.d.ts +0 -2
  118. package/types/pc/config-provider/ConfigProvider.d.ts +1 -1
  119. package/types/pc/config-provider/interface.d.ts +17 -17
  120. package/types/pc/copy/index.d.ts +1 -1
  121. package/types/pc/copy/interface.d.ts +2 -1
  122. package/types/pc/date-picker/interface.d.ts +0 -17
  123. package/types/pc/date-picker/panel/Body.d.ts +1 -1
  124. package/types/pc/date-picker/panel/Footer.d.ts +1 -1
  125. package/types/pc/date-picker/panel/Header.d.ts +1 -1
  126. package/types/pc/date-picker/panel/WeekList.d.ts +1 -1
  127. package/types/pc/date-picker/panel/date/index.d.ts +1 -1
  128. package/types/pc/date-picker/panel/month/index.d.ts +1 -1
  129. package/types/pc/date-picker/panel/quarter/index.d.ts +1 -1
  130. package/types/pc/date-picker/panel/range/index.d.ts +1 -1
  131. package/types/pc/date-picker/panel/week/index.d.ts +1 -1
  132. package/types/pc/date-picker/panel/year/index.d.ts +1 -1
  133. package/types/pc/descriptions/index.d.ts +1 -1
  134. package/types/pc/descriptions/interface.d.ts +0 -1
  135. package/types/pc/details/index.d.ts +3 -2
  136. package/types/pc/details/interface.d.ts +16 -0
  137. package/types/pc/development/index.d.ts +2 -1
  138. package/types/pc/development/interface.d.ts +15 -0
  139. package/types/pc/divider/index.d.ts +7 -2
  140. package/types/pc/draggable/Item.d.ts +1 -1
  141. package/types/pc/draggable/index.d.ts +1 -1
  142. package/types/pc/drawer/interface.d.ts +0 -7
  143. package/types/pc/dropdown/interface.d.ts +0 -1
  144. package/types/pc/flex/index.d.ts +9 -0
  145. package/types/pc/flex/interface.d.ts +16 -0
  146. package/types/pc/form/Control.d.ts +1 -1
  147. package/types/pc/form/FormList.d.ts +1 -1
  148. package/types/pc/form/IconSymbol.d.ts +1 -1
  149. package/types/pc/form/interface.d.ts +9 -22
  150. package/types/pc/form/util.d.ts +1 -1
  151. package/types/pc/grid/index.d.ts +3 -3
  152. package/types/pc/grid/interface.d.ts +1 -6
  153. package/types/pc/icon/addFromIconFontCn.d.ts +1 -7
  154. package/types/pc/icon/index.d.ts +2 -7
  155. package/types/pc/icon/interface.d.ts +13 -0
  156. package/types/pc/icon-hover/index.d.ts +2 -8
  157. package/types/pc/icon-hover/interface.d.ts +8 -0
  158. package/types/pc/image/ImageFooter.d.ts +1 -1
  159. package/types/pc/image/ImagePreviewArrow.d.ts +1 -1
  160. package/types/pc/image/TriggerForToolbar.d.ts +1 -1
  161. package/types/pc/image/interface.d.ts +0 -13
  162. package/types/pc/index.d.ts +63 -50
  163. package/types/pc/input/Textarea.d.ts +2 -6
  164. package/types/pc/input/interface.d.ts +5 -13
  165. package/types/pc/input-number/interface.d.ts +0 -4
  166. package/types/pc/input-tag/interface.d.ts +0 -13
  167. package/types/pc/layout/interface.d.ts +0 -1
  168. package/types/pc/link/interface.d.ts +0 -1
  169. package/types/pc/list/interface.d.ts +0 -4
  170. package/types/pc/loading/index.d.ts +4 -3
  171. package/types/pc/loading/interface.d.ts +6 -0
  172. package/types/pc/menu/Indent.d.ts +1 -1
  173. package/types/pc/menu/OverflowWrap.d.ts +1 -1
  174. package/types/pc/menu/interface.d.ts +0 -8
  175. package/types/pc/menu/sub-menu/Inline.d.ts +1 -1
  176. package/types/pc/menu/sub-menu/Pop.d.ts +1 -1
  177. package/types/pc/message/interface.d.ts +0 -2
  178. package/types/pc/modal/interface.d.ts +0 -5
  179. package/types/pc/notification/interface.d.ts +0 -1
  180. package/types/pc/overflow-ellipsis/OverflowItem.d.ts +1 -1
  181. package/types/pc/overflow-ellipsis/index.d.ts +1 -1
  182. package/types/pc/pagination/PageItem.d.ts +3 -3
  183. package/types/pc/pagination/PageJumper.d.ts +1 -1
  184. package/types/pc/pagination/PageOption.d.ts +1 -1
  185. package/types/pc/pagination/interface.d.ts +0 -2
  186. package/types/pc/popconfirm/interface.d.ts +8 -10
  187. package/types/pc/popover/interface.d.ts +0 -1
  188. package/types/pc/portal/Portal.d.ts +2 -6
  189. package/types/pc/portal/index.d.ts +2 -9
  190. package/types/pc/portal/interface.d.ts +14 -0
  191. package/types/pc/progress/CircleProgress.d.ts +1 -1
  192. package/types/pc/progress/LineProgess.d.ts +1 -1
  193. package/types/pc/progress/StepProgress.d.ts +1 -1
  194. package/types/pc/progress/interface.d.ts +0 -3
  195. package/types/pc/radio/Group.d.ts +2 -2
  196. package/types/pc/radio/GroupBlock.d.ts +1 -1
  197. package/types/pc/radio/Radio.d.ts +1 -1
  198. package/types/pc/resize-box/ResizeTrigger.d.ts +1 -1
  199. package/types/pc/resize-box/interface.d.ts +1 -7
  200. package/types/pc/result/403.d.ts +1 -1
  201. package/types/pc/result/404.d.ts +1 -1
  202. package/types/pc/result/500.d.ts +1 -1
  203. package/types/pc/segmented/interface.d.ts +6 -6
  204. package/types/pc/select/interface.d.ts +0 -12
  205. package/types/pc/select-view/interface.d.ts +0 -7
  206. package/types/pc/skeleton/Image.d.ts +1 -1
  207. package/types/pc/skeleton/Text.d.ts +2 -1
  208. package/types/pc/slider/Button.d.ts +1 -1
  209. package/types/pc/slider/Input.d.ts +1 -1
  210. package/types/pc/slider/Tick.d.ts +1 -1
  211. package/types/pc/slider/interface.d.ts +0 -4
  212. package/types/pc/space/index.d.ts +7 -5
  213. package/types/pc/speech-synthesis/index.d.ts +3 -1
  214. package/types/pc/speech-synthesis/interface.d.ts +7 -0
  215. package/types/pc/spin/DotLoading.d.ts +1 -1
  216. package/types/pc/spin/interface.d.ts +4 -1
  217. package/types/pc/splitter/Panel.d.ts +8 -0
  218. package/types/pc/splitter/SplitBar.d.ts +21 -0
  219. package/types/pc/splitter/Splitter.d.ts +4 -0
  220. package/types/pc/splitter/hooks/useEvent.d.ts +3 -0
  221. package/types/pc/splitter/hooks/useItems.d.ts +10 -0
  222. package/types/pc/splitter/hooks/useResizable.d.ts +8 -0
  223. package/types/pc/splitter/hooks/useResize.d.ts +4 -0
  224. package/types/pc/splitter/hooks/useSizes.d.ts +5 -0
  225. package/types/pc/splitter/index.d.ts +8 -3
  226. package/types/pc/splitter/interface.d.ts +181 -38
  227. package/types/pc/statistic/interface.d.ts +0 -4
  228. package/types/pc/steps/interface.d.ts +0 -3
  229. package/types/pc/suspense-fallback-test/index.d.ts +2 -3
  230. package/types/pc/suspense-fallback-test/interface.d.ts +2 -0
  231. package/types/pc/table/ColGroup.d.ts +1 -1
  232. package/types/pc/table/hook/useThResizable.d.ts +2 -2
  233. package/types/pc/table/interface.d.ts +4 -15
  234. package/types/pc/table/summary/Cell.d.ts +1 -1
  235. package/types/pc/table/summary/Row.d.ts +1 -1
  236. package/types/pc/table/tbody/Td.d.ts +1 -1
  237. package/types/pc/table/tbody/index.d.ts +1 -1
  238. package/types/pc/table/tfoot/index.d.ts +1 -1
  239. package/types/pc/table/th-resizable/index.d.ts +1 -1
  240. package/types/pc/table/thead/Column.d.ts +1 -1
  241. package/types/pc/table/thead/index.d.ts +1 -1
  242. package/types/pc/tabs/TabContent.d.ts +1 -1
  243. package/types/pc/tabs/interface.d.ts +0 -7
  244. package/types/pc/tabs/tab-header/DropdownIcon.d.ts +1 -1
  245. package/types/pc/tabs/tab-header/TabInk.d.ts +1 -1
  246. package/types/pc/tabs/tab-header/TabNavIcon.d.ts +1 -1
  247. package/types/pc/tag/index.d.ts +2 -0
  248. package/types/pc/tag/interface.d.ts +0 -1
  249. package/types/pc/time-picker/Picker.d.ts +1 -1
  250. package/types/pc/time-picker/RangePicker.d.ts +1 -1
  251. package/types/pc/time-picker/TimeColumn.d.ts +1 -1
  252. package/types/pc/time-picker/TimePicker.d.ts +1 -1
  253. package/types/pc/time-picker/index.d.ts +1 -1
  254. package/types/pc/time-picker/interface.d.ts +0 -7
  255. package/types/pc/tooltip/interface.d.ts +4 -1
  256. package/types/pc/transfer/Item.d.ts +1 -1
  257. package/types/pc/transfer/List.d.ts +1 -1
  258. package/types/pc/transfer/interface.d.ts +2 -9
  259. package/types/pc/tree/Animation.d.ts +1 -1
  260. package/types/pc/tree/interface.d.ts +2 -8
  261. package/types/pc/tree-select/interface.d.ts +0 -8
  262. package/types/pc/trigger/interface.d.ts +0 -5
  263. package/types/pc/typography/EditContent.d.ts +2 -1
  264. package/types/pc/typography/Operations.d.ts +1 -1
  265. package/types/pc/typography/interface.d.ts +45 -30
  266. package/types/pc/upload/interface.d.ts +6 -11
  267. package/types/pc/upload/list/index.d.ts +1 -1
  268. package/types/pc/utils/index.d.ts +1 -0
  269. package/types/pc/utils/names.d.ts +6 -0
  270. package/types/pc/utils/toArray.d.ts +3 -0
  271. package/types/pc/verification-code/VerificationCode.d.ts +1 -1
  272. package/types/pc/verification-code/interface.d.ts +0 -2
  273. package/types/pc/virtual-list/VirtualList.d.ts +2 -38
  274. package/types/pc/virtual-list/index.d.ts +2 -1
  275. package/types/pc/virtual-list/interface.d.ts +56 -0
  276. package/types/pc/watermark/Watermark.d.ts +1 -1
  277. package/types/pc/watermark/interface.d.ts +0 -2
  278. package/typography/Base.js +73 -73
  279. package/typography/EditContent.js +43 -33
  280. package/typography/Ellipsis.js +117 -184
  281. package/typography/Operations.js +97 -49
  282. package/typography/useCssEllipsis.js +7 -6
  283. package/utils/index.js +117 -115
  284. package/utils/names.js +4 -0
  285. package/utils/toArray.js +5 -0
  286. package/version/index.js +1 -1
  287. package/virtual-list/interface.js +1 -0
  288. package/components/common/space/toArray.js +0 -11
  289. package/loading/style/index.module.less.js +0 -4
  290. package/types/common/space/toArray.d.ts +0 -3
  291. package/types/pc/suspense-fallback-test/style/index.d.ts +0 -1
  292. /package/{suspense-fallback-test/style/index.less.js → development/interface.js} +0 -0
  293. /package/types/pc/grid/{GridItem.d.ts → Item.d.ts} +0 -0
@@ -0,0 +1,157 @@
1
+ import { jsxs as H, jsx as l } from "react/jsx-runtime";
2
+ import J from "@unicom-cloud/icons/IconUiDown";
3
+ import K from "@unicom-cloud/icons/IconUiLeft";
4
+ import Q from "@unicom-cloud/icons/IconUiRight";
5
+ import W from "@unicom-cloud/icons/IconUiUp";
6
+ import x from "react";
7
+ import "../config-provider/ConfigProvider.js";
8
+ import d from "@unicom-cloud/utils/class-name";
9
+ import y from "./hooks/useEvent.js";
10
+ import Z from "../config-provider/context.js";
11
+ function L(f) {
12
+ return typeof f == "number" && !Number.isNaN(f) ? Math.round(f) : 0;
13
+ }
14
+ const le = (f) => {
15
+ const { getPrefixCls: z } = x.useContext(Z), {
16
+ prefixCls: I,
17
+ vertical: n,
18
+ index: s,
19
+ active: T,
20
+ ariaNow: $,
21
+ ariaMin: C,
22
+ ariaMax: E,
23
+ resizable: M,
24
+ startCollapsible: j,
25
+ endCollapsible: k,
26
+ onOffsetStart: O,
27
+ onOffsetUpdate: N,
28
+ onOffsetEnd: b,
29
+ onCollapse: S,
30
+ lazy: a,
31
+ containerSize: m
32
+ } = f, e = z?.("bar", I), [r, v] = x.useState(
33
+ null
34
+ ), [h, P] = x.useState(0), A = n ? 0 : h, D = n ? h : 0, R = (t) => {
35
+ M && t.currentTarget && (v([t.pageX, t.pageY]), O(s));
36
+ }, V = (t) => {
37
+ if (M && t.touches.length === 1) {
38
+ const o = t.touches[0];
39
+ v([o.pageX, o.pageY]), O(s);
40
+ }
41
+ }, B = (t) => {
42
+ const o = m * $ / 100, c = o + t, w = Math.max(0, m * C / 100), i = Math.min(m, m * E / 100);
43
+ return Math.max(w, Math.min(i, c)) - o;
44
+ }, U = y((t, o) => {
45
+ const c = B(
46
+ n ? o : t
47
+ );
48
+ P(c);
49
+ }), X = y(() => {
50
+ N(s, A, D, !0), P(0), b(!0);
51
+ });
52
+ x.useEffect(() => {
53
+ if (r) {
54
+ const t = (i) => {
55
+ const { pageX: u, pageY: g } = i, p = u - r[0], Y = g - r[1];
56
+ a ? U(p, Y) : N(s, p, Y);
57
+ }, o = () => {
58
+ a ? X() : b(), v(null);
59
+ }, c = (i) => {
60
+ if (i.touches.length === 1) {
61
+ const u = i.touches[0], g = u.pageX - r[0], p = u.pageY - r[1];
62
+ a ? U(g, p) : N(s, g, p);
63
+ }
64
+ }, w = () => {
65
+ a ? X() : b(), v(null);
66
+ };
67
+ return window.addEventListener("touchmove", c), window.addEventListener("touchend", w), window.addEventListener("mousemove", t), window.addEventListener("mouseup", o), () => {
68
+ window.removeEventListener("mousemove", t), window.removeEventListener("mouseup", o), window.removeEventListener("touchmove", c), window.removeEventListener("touchend", w);
69
+ };
70
+ }
71
+ }, [
72
+ r,
73
+ a,
74
+ n,
75
+ s,
76
+ m,
77
+ $,
78
+ C,
79
+ E
80
+ ]);
81
+ const q = {
82
+ [`--${e}-preview-offset`]: `${h}px`
83
+ }, F = n ? W : K, G = n ? J : Q;
84
+ return /* @__PURE__ */ H(
85
+ "div",
86
+ {
87
+ className: e,
88
+ role: "separator",
89
+ "aria-valuenow": L($),
90
+ "aria-valuemin": L(C),
91
+ "aria-valuemax": L(E),
92
+ children: [
93
+ a && /* @__PURE__ */ l(
94
+ "div",
95
+ {
96
+ className: d(`${e}-preview`, {
97
+ [`${e}-preview-active`]: !!h
98
+ }),
99
+ style: q
100
+ }
101
+ ),
102
+ /* @__PURE__ */ l(
103
+ "div",
104
+ {
105
+ className: d(`${e}-dragger`, {
106
+ [`${e}-dragger-disabled`]: !M,
107
+ [`${e}-dragger-active`]: T
108
+ }),
109
+ onMouseDown: R,
110
+ onTouchStart: V
111
+ }
112
+ ),
113
+ j && /* @__PURE__ */ l(
114
+ "div",
115
+ {
116
+ className: d(
117
+ `${e}-collapse-bar`,
118
+ `${e}-collapse-bar-start`
119
+ ),
120
+ onClick: () => S(s, "start"),
121
+ children: /* @__PURE__ */ l(
122
+ F,
123
+ {
124
+ className: d(
125
+ `${e}-collapse-icon`,
126
+ `${e}-collapse-start`
127
+ )
128
+ }
129
+ )
130
+ }
131
+ ),
132
+ k && /* @__PURE__ */ l(
133
+ "div",
134
+ {
135
+ className: d(
136
+ `${e}-collapse-bar`,
137
+ `${e}-collapse-bar-end`
138
+ ),
139
+ onClick: () => S(s, "end"),
140
+ children: /* @__PURE__ */ l(
141
+ G,
142
+ {
143
+ className: d(
144
+ `${e}-collapse-icon`,
145
+ `${e}-collapse-end`
146
+ )
147
+ }
148
+ )
149
+ }
150
+ )
151
+ ]
152
+ }
153
+ );
154
+ };
155
+ export {
156
+ le as default
157
+ };
@@ -0,0 +1,135 @@
1
+ import { jsxs as I, jsx as h } from "react/jsx-runtime";
2
+ import p, { useState as re, useRef as ie, useEffect as ae, useImperativeHandle as le } from "react";
3
+ import "../config-provider/ConfigProvider.js";
4
+ import ce from "../components/common/hooks/useMergeProps.js";
5
+ import fe from "@unicom-cloud/utils/class-name";
6
+ import { resizeObserver as me } from "../components/common/utils/resizeObserver.js";
7
+ import m from "./hooks/useEvent.js";
8
+ import pe from "./hooks/useItems.js";
9
+ import ue from "./hooks/useResizable.js";
10
+ import ze from "./hooks/useResize.js";
11
+ import Se from "./hooks/useSizes.js";
12
+ import { InternalPanel as Ce } from "./Panel.js";
13
+ import de from "./SplitBar.js";
14
+ import he from "../config-provider/context.js";
15
+ const ge = {
16
+ layout: "horizontal"
17
+ };
18
+ function Me(N, P) {
19
+ const { getPrefixCls: O, componentConfig: x, rtl: l } = p.useContext(he), y = ce(
20
+ N,
21
+ ge,
22
+ x?.Splitter
23
+ ), {
24
+ prefixCls: $,
25
+ className: k,
26
+ style: H,
27
+ layout: g = "horizontal",
28
+ children: U,
29
+ onResizeStart: j,
30
+ onResize: M,
31
+ onResizeEnd: u,
32
+ lazy: w,
33
+ ...B
34
+ } = y, n = O?.("splitter", $), c = g === "vertical", r = pe(U), [z, D] = re(), o = ie(null), V = () => {
35
+ const t = o.current?.offsetWidth, e = o.current?.offsetHeight, s = c ? e : t;
36
+ s !== 0 && D(s);
37
+ }, [
38
+ W,
39
+ S,
40
+ C,
41
+ R,
42
+ b,
43
+ F
44
+ ] = Se(r, z), v = ue(r, S, l), [_, q, A, G, E] = ze(
45
+ r,
46
+ v,
47
+ C,
48
+ z,
49
+ F,
50
+ l
51
+ ), J = m((t) => {
52
+ _(t), j?.(S);
53
+ }), K = m(
54
+ (t, e, s) => {
55
+ const a = q(t, e);
56
+ s ? u?.(a) : M?.(a);
57
+ }
58
+ ), L = m((t) => {
59
+ A(), t || u?.(S);
60
+ }), Q = m(
61
+ (t, e) => {
62
+ const s = G(t, e);
63
+ M?.(s), u?.(s);
64
+ }
65
+ ), T = fe(
66
+ n,
67
+ k,
68
+ `${n}-${g}`,
69
+ l && [`${n}-rtl`]
70
+ ), i = p.useMemo(() => {
71
+ const t = [];
72
+ let e = 0;
73
+ for (let s = 0; s < r.length; s += 1)
74
+ e += C[s], t.push(e);
75
+ return t;
76
+ }, [C]);
77
+ return ae(() => {
78
+ const t = me([o.current], () => {
79
+ V();
80
+ });
81
+ return () => {
82
+ t();
83
+ };
84
+ }, [o.current]), le(P, () => ({ dom: o.current })), /* @__PURE__ */ I("div", { style: H, className: T, ref: o, ...B, children: [
85
+ r.map((t, e) => {
86
+ const s = /* @__PURE__ */ h(
87
+ Ce,
88
+ {
89
+ ...t,
90
+ prefixCls: n,
91
+ size: W[e]
92
+ }
93
+ );
94
+ let a = null;
95
+ const f = v[e];
96
+ if (f) {
97
+ const X = (i[e - 1] || 0) + R[e], Y = (i[e + 1] || 100) - b[e + 1], Z = (i[e - 1] || 0) + b[e], ee = (i[e + 1] || 100) - R[e + 1];
98
+ a = /* @__PURE__ */ h(
99
+ de,
100
+ {
101
+ lazy: w,
102
+ index: e,
103
+ active: E === e,
104
+ prefixCls: n,
105
+ vertical: c,
106
+ resizable: f.resizable,
107
+ ariaNow: i[e] * 100,
108
+ ariaMin: Math.max(X, Y) * 100,
109
+ ariaMax: Math.min(Z, ee) * 100,
110
+ startCollapsible: f.startCollapsible,
111
+ endCollapsible: f.endCollapsible,
112
+ onOffsetStart: J,
113
+ onOffsetUpdate: (te, se, ne, oe) => {
114
+ let d = c ? ne : se;
115
+ l && !c && (d = -d), K(te, d, oe);
116
+ },
117
+ onOffsetEnd: L,
118
+ onCollapse: Q,
119
+ containerSize: z || 0
120
+ }
121
+ );
122
+ }
123
+ return /* @__PURE__ */ I(p.Fragment, { children: [
124
+ s,
125
+ a
126
+ ] }, `split-panel-${e}`);
127
+ }),
128
+ typeof E == "number" && /* @__PURE__ */ h("div", { "aria-hidden": !0, className: `${n}-mask` })
129
+ ] });
130
+ }
131
+ const Re = p.forwardRef(Me);
132
+ process.env.NODE_ENV !== "production" && (Re.displayName = "Splitter");
133
+ export {
134
+ Re as default
135
+ };
@@ -0,0 +1,12 @@
1
+ import n from "react";
2
+ function c(r) {
3
+ const e = n.useRef();
4
+ return e.current = r, n.useCallback(function(...t) {
5
+ if (!e.current)
6
+ throw new Error("Callback is not defined");
7
+ return e.current.apply(void 0, t);
8
+ }, []);
9
+ }
10
+ export {
11
+ c as default
12
+ };
@@ -0,0 +1,26 @@
1
+ import o from "react";
2
+ import { toArray as i } from "../../components/common/utils/toArray.js";
3
+ function p(t) {
4
+ if (t && typeof t == "object")
5
+ return t;
6
+ const e = !!t;
7
+ return {
8
+ start: e,
9
+ end: e
10
+ };
11
+ }
12
+ function f(t) {
13
+ return o.useMemo(
14
+ () => i(t).filter((r) => o.isValidElement(r)).map((r) => {
15
+ const { props: s } = r, { collapsible: n, ...m } = s;
16
+ return {
17
+ ...m,
18
+ collapsible: p(n)
19
+ };
20
+ }),
21
+ [t]
22
+ );
23
+ }
24
+ export {
25
+ f as default
26
+ };
@@ -0,0 +1,26 @@
1
+ import v from "react";
2
+ function I(l, s, o) {
3
+ return v.useMemo(() => {
4
+ const r = [];
5
+ for (let e = 0; e < l.length - 1; e += 1) {
6
+ const p = l[e], u = l[e + 1], t = s[e], n = s[e + 1], {
7
+ resizable: z = !0,
8
+ min: d,
9
+ collapsible: a
10
+ } = p, {
11
+ resizable: C = !0,
12
+ min: f,
13
+ collapsible: i
14
+ } = u, m = z && C && (t !== 0 || !d) && (n !== 0 || !f), b = a.end && t > 0 || i.start && n === 0 && t > 0, c = i.start && n > 0 || a.end && t === 0 && n > 0;
15
+ r[e] = {
16
+ resizable: m,
17
+ startCollapsible: !!(o ? c : b),
18
+ endCollapsible: !!(o ? b : c)
19
+ };
20
+ }
21
+ return r;
22
+ }, [s, l, o]);
23
+ }
24
+ export {
25
+ I as default
26
+ };
@@ -0,0 +1,68 @@
1
+ import x from "react";
2
+ import { getPtg as q } from "./useSizes.js";
3
+ function J(b, v, P, j, C, k) {
4
+ const i = b.map((t) => [t.min, t.max]), S = j || 0, M = (t) => t * S;
5
+ function a(t, f) {
6
+ return typeof t == "string" ? M(q(t)) : t ?? f;
7
+ }
8
+ const [O, y] = x.useState([]), I = x.useRef([]), [g, p] = x.useState(null), U = () => P.map(M);
9
+ return [
10
+ (t) => {
11
+ y(U()), p({
12
+ index: t,
13
+ confirmed: !1
14
+ });
15
+ },
16
+ (t, f) => {
17
+ let n = null;
18
+ if ((!g || !g.confirmed) && f !== 0) {
19
+ if (f > 0)
20
+ n = t, p({
21
+ index: t,
22
+ confirmed: !0
23
+ });
24
+ else
25
+ for (let r = t; r >= 0; r -= 1)
26
+ if (O[r] > 0 && v[r].resizable) {
27
+ n = r, p({
28
+ index: r,
29
+ confirmed: !0
30
+ });
31
+ break;
32
+ }
33
+ }
34
+ const c = n ?? g?.index ?? t, e = [...O], s = c + 1, l = a(i[c][0], 0), d = a(i[s][0], 0), u = a(
35
+ i[c][1],
36
+ S
37
+ ), m = a(
38
+ i[s][1],
39
+ S
40
+ );
41
+ let o = f;
42
+ return e[c] + o < l && (o = l - e[c]), e[s] - o < d && (o = e[s] - d), e[c] + o > u && (o = u - e[c]), e[s] - o > m && (o = e[s] - m), e[c] += o, e[s] -= o, C(e), e;
43
+ },
44
+ () => {
45
+ p(null);
46
+ },
47
+ (t, f) => {
48
+ const n = U(), c = k ? f === "start" ? "end" : "start" : f, e = c === "start" ? t : t + 1, s = c === "start" ? t + 1 : t, l = n[e], d = n[s];
49
+ if (l !== 0 && d !== 0)
50
+ n[e] = 0, n[s] += l, I.current[t] = l;
51
+ else {
52
+ const u = l + d, m = a(i[e][0], 0), o = a(
53
+ i[e][1],
54
+ S
55
+ ), r = a(i[s][0], 0), E = a(
56
+ i[s][1],
57
+ S
58
+ ), L = Math.max(m, u - E), T = Math.min(o, u - r), R = r || (T - L) / 2, z = I.current[t], h = u - z;
59
+ z && z <= E && z >= r && h <= o && h >= m ? (n[s] = z, n[e] = h) : (n[e] -= R, n[s] += R);
60
+ }
61
+ return C(n), n;
62
+ },
63
+ g?.index
64
+ ];
65
+ }
66
+ export {
67
+ J as default
68
+ };
@@ -0,0 +1,60 @@
1
+ import i from "react";
2
+ function l(s) {
3
+ return Number(s.slice(0, -1)) / 100;
4
+ }
5
+ function z(s) {
6
+ return typeof s == "string" && s.endsWith("%");
7
+ }
8
+ function C(s, u) {
9
+ const S = s.map((e) => e.size), c = s.length, o = u || 0, M = (e) => e * o, [d, x] = i.useState(() => s.map((e) => e.defaultSize)), a = i.useMemo(() => {
10
+ const e = [];
11
+ for (let r = 0; r < c; r += 1)
12
+ e[r] = S[r] ?? d[r];
13
+ return e;
14
+ }, [c, d, S]), p = i.useMemo(() => {
15
+ let e = [], r = 0;
16
+ for (let n = 0; n < c; n += 1) {
17
+ const t = a[n];
18
+ if (z(t))
19
+ e[n] = l(t);
20
+ else if (t || t === 0) {
21
+ const g = Number(t);
22
+ Number.isNaN(g) || (e[n] = g / o);
23
+ } else
24
+ r += 1, e[n] = void 0;
25
+ }
26
+ const f = e.reduce((n, t) => n + (t || 0), 0);
27
+ if (f > 1 || !r) {
28
+ const n = 1 / f;
29
+ e = e.map((t) => t === void 0 ? 0 : t * n);
30
+ } else {
31
+ const n = (1 - f) / r;
32
+ e = e.map((t) => t === void 0 ? n : t);
33
+ }
34
+ return e;
35
+ }, [a, o]), m = i.useMemo(
36
+ () => p.map(M),
37
+ [p, o]
38
+ ), P = i.useMemo(
39
+ () => s.map((e) => z(e.min) ? l(e.min) : (e.min || 0) / o),
40
+ [s, o]
41
+ ), N = i.useMemo(
42
+ () => s.map((e) => z(e.max) ? l(e.max) : (e.max || o) / o),
43
+ [s, o]
44
+ );
45
+ return [
46
+ i.useMemo(
47
+ () => u ? m : a,
48
+ [m, u]
49
+ ),
50
+ m,
51
+ p,
52
+ P,
53
+ N,
54
+ x
55
+ ];
56
+ }
57
+ export {
58
+ C as default,
59
+ l as getPtg
60
+ };
package/splitter/index.js CHANGED
@@ -1,117 +1,8 @@
1
- import { jsxs as k, jsx as f } from "react/jsx-runtime";
2
- import { useState as P, useRef as m, useCallback as i, useEffect as C } from "react";
3
- const I = {
4
- direction: "horizontal",
5
- initialSize: 0.5,
6
- minSize: "10%",
7
- maxSize: "90%",
8
- gutterSize: 8,
9
- disabled: !1
10
- }, A = (b) => {
11
- const {
12
- direction: e,
13
- initialSize: D,
14
- minSize: M,
15
- maxSize: E,
16
- gutterSize: c,
17
- gutterStyle: W,
18
- disabled: a,
19
- onDragStart: h,
20
- onDragEnd: z,
21
- onDrag: p,
22
- firstPane: L,
23
- secondPane: N,
24
- style: H,
25
- className: R
26
- } = { ...I, ...b }, [o, j] = P(D), [r, S] = P(!1), n = m(null), g = m(0), v = m(0), y = i(
27
- (t) => {
28
- if (typeof t == "string") {
29
- if (t.endsWith("%"))
30
- return parseFloat(t) / 100;
31
- if (t.endsWith("px") && n.current) {
32
- const w = parseFloat(t), d = e === "horizontal" ? n.current.offsetWidth : n.current.offsetHeight;
33
- return w / d;
34
- }
35
- }
36
- return t;
37
- },
38
- [e]
39
- ), x = y(M), $ = y(E), F = i(
40
- (t) => {
41
- a || (S(!0), g.current = e === "horizontal" ? t.clientX : t.clientY, v.current = o, document.body.style.cursor = e === "horizontal" ? "col-resize" : "row-resize", document.body.style.userSelect = "none", h?.());
42
- },
43
- [e, a, o, h]
44
- ), l = i(
45
- (t) => {
46
- if (!r || !n.current) return;
47
- const d = (e === "horizontal" ? t.clientX : t.clientY) - g.current, Y = e === "horizontal" ? n.current.offsetWidth : n.current.offsetHeight;
48
- let s = v.current + d / Y;
49
- s = Math.max(x, Math.min($, s)), j(s), p?.(s);
50
- },
51
- [r, e, x, $, p]
52
- ), u = i(() => {
53
- r && (S(!1), document.body.style.cursor = "", document.body.style.userSelect = "", z?.(o));
54
- }, [r, o, z]);
55
- C(() => (document.addEventListener("mousemove", l), document.addEventListener("mouseup", u), () => {
56
- document.removeEventListener("mousemove", l), document.removeEventListener("mouseup", u);
57
- }), [l, u]);
58
- const V = `calc(${o * 100}% - ${c / 2}px)`, X = `calc(${(1 - o) * 100}% - ${c / 2}px)`;
59
- return /* @__PURE__ */ k(
60
- "div",
61
- {
62
- ref: n,
63
- className: `splitter-container ${e} ${R}`,
64
- style: {
65
- display: "flex",
66
- flexDirection: e === "horizontal" ? "row" : "column",
67
- width: "100%",
68
- height: "100%",
69
- overflow: "hidden",
70
- ...H
71
- },
72
- children: [
73
- /* @__PURE__ */ f(
74
- "div",
75
- {
76
- className: "splitter-pane first",
77
- style: {
78
- flex: `0 0 ${V}`,
79
- overflow: "auto",
80
- minWidth: 0,
81
- minHeight: 0
82
- },
83
- children: L
84
- }
85
- ),
86
- /* @__PURE__ */ f(
87
- "div",
88
- {
89
- className: `splitter-gutter ${e} ${r ? "active" : ""} ${a ? "disabled" : ""}`,
90
- style: {
91
- [e === "horizontal" ? "width" : "height"]: c,
92
- ...W
93
- },
94
- onMouseDown: F
95
- }
96
- ),
97
- /* @__PURE__ */ f(
98
- "div",
99
- {
100
- className: "splitter-pane second",
101
- style: {
102
- flex: `0 0 ${X}`,
103
- overflow: "auto",
104
- minWidth: 0,
105
- minHeight: 0
106
- },
107
- children: N
108
- }
109
- )
110
- ]
111
- }
112
- );
113
- };
1
+ import t from "./Panel.js";
2
+ import e from "./Splitter.js";
3
+ const r = e;
4
+ r.Panel = t;
114
5
  export {
115
- A as Splitter,
116
- A as default
6
+ t as SplitterPanel,
7
+ r as default
117
8
  };