@dtjoy/dt-design 1.0.1 → 1.0.3

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 (155) hide show
  1. package/esm/_util/gapSize.d.ts +3 -0
  2. package/esm/_util/gapSize.js +10 -0
  3. package/esm/_util/hooks/index.d.ts +1 -0
  4. package/esm/_util/hooks/index.js +1 -0
  5. package/esm/_util/hooks/useOrientation.d.ts +2 -0
  6. package/esm/_util/hooks/useOrientation.js +19 -0
  7. package/esm/_util/isNonNullable.d.ts +2 -0
  8. package/esm/_util/isNonNullable.js +4 -0
  9. package/esm/_util/type.d.ts +2 -1
  10. package/esm/blockHeader/index.js +12 -11
  11. package/esm/blockHeader/style/index.d.ts +1 -1
  12. package/esm/blockHeader/style/index.js +1 -1
  13. package/esm/blockHeader/style/index.less +9 -8
  14. package/esm/button/style/index.less +60 -46
  15. package/esm/button/style/mixin.less +47 -0
  16. package/esm/collapsible/index.d.ts +97 -0
  17. package/esm/collapsible/index.js +234 -0
  18. package/esm/collapsible/style/index.d.ts +1 -0
  19. package/esm/collapsible/style/index.js +1 -0
  20. package/esm/collapsible/style/index.less +24 -0
  21. package/esm/collapsibleActionItems/index.d.ts +24 -0
  22. package/esm/collapsibleActionItems/index.js +74 -0
  23. package/esm/collapsibleActionItems/style/index.d.ts +2 -0
  24. package/esm/collapsibleActionItems/style/index.js +2 -0
  25. package/esm/collapsibleActionItems/style/index.less +7 -0
  26. package/esm/flex/index.d.ts +7 -0
  27. package/esm/flex/index.js +62 -0
  28. package/esm/flex/interface.d.ts +16 -0
  29. package/esm/flex/interface.js +1 -0
  30. package/esm/flex/style/index.d.ts +2 -0
  31. package/esm/flex/style/index.js +2 -0
  32. package/esm/flex/style/index.less +77 -0
  33. package/esm/flex/utils.d.ts +7 -0
  34. package/esm/flex/utils.js +33 -0
  35. package/esm/index.d.ts +10 -1
  36. package/esm/index.js +8 -6
  37. package/esm/overflowList/index.d.ts +39 -0
  38. package/esm/overflowList/index.js +165 -0
  39. package/esm/overflowList/style/index.d.ts +2 -0
  40. package/esm/overflowList/style/index.js +2 -0
  41. package/esm/overflowList/style/index.less +9 -0
  42. package/esm/resize/index.d.ts +8 -0
  43. package/esm/resize/index.js +29 -0
  44. package/esm/resizeObserver/index.d.ts +45 -0
  45. package/esm/resizeObserver/index.js +175 -0
  46. package/esm/splitter/Panel.d.ts +7 -0
  47. package/esm/splitter/Panel.js +38 -0
  48. package/esm/splitter/SplitBar.d.ts +24 -0
  49. package/esm/splitter/SplitBar.js +185 -0
  50. package/esm/splitter/Splitter.d.ts +5 -0
  51. package/esm/splitter/Splitter.js +197 -0
  52. package/esm/splitter/hooks/sizeUtil.d.ts +3 -0
  53. package/esm/splitter/hooks/sizeUtil.js +63 -0
  54. package/esm/splitter/hooks/useItems.d.ts +14 -0
  55. package/esm/splitter/hooks/useItems.js +44 -0
  56. package/esm/splitter/hooks/useResizable.d.ts +10 -0
  57. package/esm/splitter/hooks/useResizable.js +73 -0
  58. package/esm/splitter/hooks/useResize.d.ts +6 -0
  59. package/esm/splitter/hooks/useResize.js +158 -0
  60. package/esm/splitter/hooks/useSizes.d.ts +4 -0
  61. package/esm/splitter/hooks/useSizes.js +80 -0
  62. package/esm/splitter/index.d.ts +8 -0
  63. package/esm/splitter/index.js +5 -0
  64. package/esm/splitter/interface.d.ts +68 -0
  65. package/esm/splitter/interface.js +1 -0
  66. package/esm/splitter/style/index.d.ts +2 -0
  67. package/esm/splitter/style/index.js +2 -0
  68. package/esm/splitter/style/index.less +312 -0
  69. package/esm/statusTag/index.d.ts +28 -0
  70. package/esm/statusTag/index.js +122 -0
  71. package/esm/statusTag/style/index.d.ts +2 -0
  72. package/esm/statusTag/style/index.js +2 -0
  73. package/esm/statusTag/style/index.less +70 -0
  74. package/esm/statusTag/style/mixin.less +39 -0
  75. package/esm/style/mixins/index.less +0 -0
  76. package/esm/style/themes/index.less +2 -1
  77. package/esm/style/themes/variable.less +1 -0
  78. package/lib/_util/gapSize.d.ts +3 -0
  79. package/lib/_util/gapSize.js +17 -0
  80. package/lib/_util/hooks/index.d.ts +1 -0
  81. package/lib/_util/hooks/index.js +16 -0
  82. package/lib/_util/hooks/useOrientation.d.ts +2 -0
  83. package/lib/_util/hooks/useOrientation.js +26 -0
  84. package/lib/_util/isNonNullable.d.ts +2 -0
  85. package/lib/_util/isNonNullable.js +10 -0
  86. package/lib/_util/type.d.ts +2 -1
  87. package/lib/blockHeader/index.js +12 -12
  88. package/lib/blockHeader/style/index.d.ts +1 -1
  89. package/lib/blockHeader/style/index.js +1 -1
  90. package/lib/blockHeader/style/index.less +9 -8
  91. package/lib/button/style/index.less +60 -46
  92. package/lib/button/style/mixin.less +47 -0
  93. package/lib/collapsible/index.d.ts +97 -0
  94. package/lib/collapsible/index.js +199 -0
  95. package/lib/collapsible/style/index.d.ts +1 -0
  96. package/lib/collapsible/style/index.js +3 -0
  97. package/lib/collapsible/style/index.less +24 -0
  98. package/lib/collapsibleActionItems/index.d.ts +24 -0
  99. package/lib/collapsibleActionItems/index.js +68 -0
  100. package/lib/collapsibleActionItems/style/index.d.ts +2 -0
  101. package/lib/collapsibleActionItems/style/index.js +4 -0
  102. package/lib/collapsibleActionItems/style/index.less +7 -0
  103. package/lib/flex/index.d.ts +7 -0
  104. package/lib/flex/index.js +60 -0
  105. package/lib/flex/interface.d.ts +16 -0
  106. package/lib/flex/interface.js +5 -0
  107. package/lib/flex/style/index.d.ts +2 -0
  108. package/lib/flex/style/index.js +4 -0
  109. package/lib/flex/style/index.less +77 -0
  110. package/lib/flex/utils.d.ts +7 -0
  111. package/lib/flex/utils.js +40 -0
  112. package/lib/index.d.ts +10 -1
  113. package/lib/index.js +73 -1
  114. package/lib/overflowList/index.d.ts +39 -0
  115. package/lib/overflowList/index.js +143 -0
  116. package/lib/overflowList/style/index.d.ts +2 -0
  117. package/lib/overflowList/style/index.js +4 -0
  118. package/lib/overflowList/style/index.less +9 -0
  119. package/lib/resize/index.d.ts +8 -0
  120. package/lib/resize/index.js +38 -0
  121. package/lib/resizeObserver/index.d.ts +45 -0
  122. package/lib/resizeObserver/index.js +136 -0
  123. package/lib/splitter/Panel.d.ts +7 -0
  124. package/lib/splitter/Panel.js +44 -0
  125. package/lib/splitter/SplitBar.d.ts +24 -0
  126. package/lib/splitter/SplitBar.js +179 -0
  127. package/lib/splitter/Splitter.d.ts +5 -0
  128. package/lib/splitter/Splitter.js +186 -0
  129. package/lib/splitter/hooks/sizeUtil.d.ts +3 -0
  130. package/lib/splitter/hooks/sizeUtil.js +56 -0
  131. package/lib/splitter/hooks/useItems.d.ts +14 -0
  132. package/lib/splitter/hooks/useItems.js +46 -0
  133. package/lib/splitter/hooks/useResizable.d.ts +10 -0
  134. package/lib/splitter/hooks/useResizable.js +83 -0
  135. package/lib/splitter/hooks/useResize.d.ts +6 -0
  136. package/lib/splitter/hooks/useResize.js +142 -0
  137. package/lib/splitter/hooks/useSizes.d.ts +4 -0
  138. package/lib/splitter/hooks/useSizes.js +62 -0
  139. package/lib/splitter/index.d.ts +8 -0
  140. package/lib/splitter/index.js +12 -0
  141. package/lib/splitter/interface.d.ts +68 -0
  142. package/lib/splitter/interface.js +5 -0
  143. package/lib/splitter/style/index.d.ts +2 -0
  144. package/lib/splitter/style/index.js +4 -0
  145. package/lib/splitter/style/index.less +312 -0
  146. package/lib/statusTag/index.d.ts +28 -0
  147. package/lib/statusTag/index.js +125 -0
  148. package/lib/statusTag/style/index.d.ts +2 -0
  149. package/lib/statusTag/style/index.js +4 -0
  150. package/lib/statusTag/style/index.less +70 -0
  151. package/lib/statusTag/style/mixin.less +39 -0
  152. package/lib/style/mixins/index.less +0 -0
  153. package/lib/style/themes/index.less +2 -1
  154. package/lib/style/themes/variable.less +1 -0
  155. package/package.json +11 -19
@@ -0,0 +1,179 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _react = _interopRequireWildcard(require("react"));
8
+ var _icons = require("@ant-design/icons");
9
+ var _classnames = _interopRequireDefault(require("classnames"));
10
+ var _useEvent = _interopRequireDefault(require("rc-util/lib/hooks/useEvent"));
11
+ var _useLayoutEffect = _interopRequireDefault(require("rc-util/lib/hooks/useLayoutEffect"));
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
14
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
15
+ function getValidNumber(num) {
16
+ return typeof num === 'number' && !Number.isNaN(num) && Number.isFinite(num) ? Math.round(num) : 0;
17
+ }
18
+ const SplitBar = props => {
19
+ const {
20
+ prefixCls,
21
+ vertical,
22
+ index,
23
+ active,
24
+ ariaNow,
25
+ ariaMin,
26
+ ariaMax,
27
+ resizable,
28
+ startCollapsible,
29
+ endCollapsible,
30
+ onOffsetStart,
31
+ onOffsetUpdate,
32
+ onOffsetEnd,
33
+ onCollapse,
34
+ lazy,
35
+ containerSize,
36
+ showStartCollapsibleIcon,
37
+ showEndCollapsibleIcon
38
+ } = props;
39
+ const splitBarPrefixCls = `${prefixCls}-bar`;
40
+ const [startPos, setStartPos] = (0, _react.useState)(null);
41
+ const [constrainedOffset, setConstrainedOffset] = (0, _react.useState)(0);
42
+ const constrainedOffsetX = vertical ? 0 : constrainedOffset;
43
+ const constrainedOffsetY = vertical ? constrainedOffset : 0;
44
+ const onMouseDown = e => {
45
+ if (resizable && e.currentTarget) {
46
+ setStartPos([e.pageX, e.pageY]);
47
+ onOffsetStart(index);
48
+ }
49
+ };
50
+ const onTouchStart = e => {
51
+ if (resizable && e.touches.length === 1) {
52
+ const touch = e.touches[0];
53
+ setStartPos([touch.pageX, touch.pageY]);
54
+ onOffsetStart(index);
55
+ }
56
+ };
57
+ const getConstrainedOffset = rawOffset => {
58
+ const currentPos = containerSize * ariaNow / 100;
59
+ const newPos = currentPos + rawOffset;
60
+ const minAllowed = Math.max(0, containerSize * ariaMin / 100);
61
+ const maxAllowed = Math.min(containerSize, containerSize * ariaMax / 100);
62
+ const clampedPos = Math.max(minAllowed, Math.min(maxAllowed, newPos));
63
+ return clampedPos - currentPos;
64
+ };
65
+ const handleLazyMove = (0, _useEvent.default)((offsetX, offsetY) => {
66
+ const constrainedOffsetValue = getConstrainedOffset(vertical ? offsetY : offsetX);
67
+ setConstrainedOffset(constrainedOffsetValue);
68
+ });
69
+ const handleLazyEnd = (0, _useEvent.default)(() => {
70
+ onOffsetUpdate(index, constrainedOffsetX, constrainedOffsetY, true);
71
+ setConstrainedOffset(0);
72
+ onOffsetEnd(true);
73
+ });
74
+ const getVisibilityClass = mode => {
75
+ switch (mode) {
76
+ case true:
77
+ return `${splitBarPrefixCls}-collapse-bar-always-visible`;
78
+ case false:
79
+ return `${splitBarPrefixCls}-collapse-bar-always-hidden`;
80
+ case 'auto':
81
+ return `${splitBarPrefixCls}-collapse-bar-hover-only`;
82
+ }
83
+ };
84
+ (0, _useLayoutEffect.default)(() => {
85
+ if (!startPos) {
86
+ return;
87
+ }
88
+ const onMouseMove = e => {
89
+ const {
90
+ pageX,
91
+ pageY
92
+ } = e;
93
+ const offsetX = pageX - startPos[0];
94
+ const offsetY = pageY - startPos[1];
95
+ if (lazy) {
96
+ handleLazyMove(offsetX, offsetY);
97
+ } else {
98
+ onOffsetUpdate(index, offsetX, offsetY);
99
+ }
100
+ };
101
+ const onMouseUp = () => {
102
+ if (lazy) {
103
+ handleLazyEnd();
104
+ } else {
105
+ onOffsetEnd();
106
+ }
107
+ setStartPos(null);
108
+ };
109
+ const handleTouchMove = e => {
110
+ if (e.touches.length === 1) {
111
+ const touch = e.touches[0];
112
+ const offsetX = touch.pageX - startPos[0];
113
+ const offsetY = touch.pageY - startPos[1];
114
+ if (lazy) {
115
+ handleLazyMove(offsetX, offsetY);
116
+ } else {
117
+ onOffsetUpdate(index, offsetX, offsetY);
118
+ }
119
+ }
120
+ };
121
+ const handleTouchEnd = () => {
122
+ if (lazy) {
123
+ handleLazyEnd();
124
+ } else {
125
+ onOffsetEnd();
126
+ }
127
+ setStartPos(null);
128
+ };
129
+ const eventHandlerMap = {
130
+ mousemove: onMouseMove,
131
+ mouseup: onMouseUp,
132
+ touchmove: handleTouchMove,
133
+ touchend: handleTouchEnd
134
+ };
135
+ for (const [event, handler] of Object.entries(eventHandlerMap)) {
136
+ window.addEventListener(event, handler);
137
+ }
138
+ return () => {
139
+ for (const [event, handler] of Object.entries(eventHandlerMap)) {
140
+ window.removeEventListener(event, handler);
141
+ }
142
+ };
143
+ }, [startPos, index, lazy]);
144
+ const transformStyle = {
145
+ [`--${splitBarPrefixCls}-preview-offset`]: `${constrainedOffset}px`
146
+ };
147
+ const StartIcon = vertical ? _icons.UpOutlined : _icons.LeftOutlined;
148
+ const EndIcon = vertical ? _icons.DownOutlined : _icons.RightOutlined;
149
+ return /*#__PURE__*/_react.default.createElement("div", {
150
+ className: splitBarPrefixCls,
151
+ role: "separator",
152
+ "aria-valuenow": getValidNumber(ariaNow),
153
+ "aria-valuemin": getValidNumber(ariaMin),
154
+ "aria-valuemax": getValidNumber(ariaMax)
155
+ }, lazy && /*#__PURE__*/_react.default.createElement("div", {
156
+ className: (0, _classnames.default)(`${splitBarPrefixCls}-preview`, {
157
+ [`${splitBarPrefixCls}-preview-active`]: !!constrainedOffset
158
+ }),
159
+ style: transformStyle
160
+ }), /*#__PURE__*/_react.default.createElement("div", {
161
+ className: (0, _classnames.default)(`${splitBarPrefixCls}-dragger`, {
162
+ [`${splitBarPrefixCls}-dragger-disabled`]: !resizable,
163
+ [`${splitBarPrefixCls}-dragger-active`]: active
164
+ }),
165
+ onMouseDown: onMouseDown,
166
+ onTouchStart: onTouchStart
167
+ }), startCollapsible && /*#__PURE__*/_react.default.createElement("div", {
168
+ className: (0, _classnames.default)(`${splitBarPrefixCls}-collapse-bar`, `${splitBarPrefixCls}-collapse-bar-start`, getVisibilityClass(showStartCollapsibleIcon)),
169
+ onClick: () => onCollapse(index, 'start')
170
+ }, /*#__PURE__*/_react.default.createElement(StartIcon, {
171
+ className: (0, _classnames.default)(`${splitBarPrefixCls}-collapse-icon`, `${splitBarPrefixCls}-collapse-start`)
172
+ })), endCollapsible && /*#__PURE__*/_react.default.createElement("div", {
173
+ className: (0, _classnames.default)(`${splitBarPrefixCls}-collapse-bar`, `${splitBarPrefixCls}-collapse-bar-end`, getVisibilityClass(showEndCollapsibleIcon)),
174
+ onClick: () => onCollapse(index, 'end')
175
+ }, /*#__PURE__*/_react.default.createElement(EndIcon, {
176
+ className: (0, _classnames.default)(`${splitBarPrefixCls}-collapse-icon`, `${splitBarPrefixCls}-collapse-end`)
177
+ })));
178
+ };
179
+ var _default = exports.default = SplitBar;
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ import type { SplitterProps } from './interface';
3
+ import './style/index.less';
4
+ declare const Splitter: React.FC<React.PropsWithChildren<SplitterProps>>;
5
+ export default Splitter;
@@ -0,0 +1,186 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _react = _interopRequireWildcard(require("react"));
8
+ var _configProvider = require("antd/es/config-provider");
9
+ var _classnames = _interopRequireDefault(require("classnames"));
10
+ var _rcResizeObserver = _interopRequireDefault(require("rc-resize-observer"));
11
+ var _useEvent = _interopRequireDefault(require("rc-util/es/hooks/useEvent"));
12
+ var _warning = _interopRequireDefault(require("rc-util/es/warning"));
13
+ var _useItems = _interopRequireDefault(require("./hooks/useItems"));
14
+ var _useResizable = _interopRequireDefault(require("./hooks/useResizable"));
15
+ var _useResize = _interopRequireDefault(require("./hooks/useResize"));
16
+ var _useSizes = _interopRequireDefault(require("./hooks/useSizes"));
17
+ var _Panel = require("./Panel");
18
+ var _SplitBar = _interopRequireDefault(require("./SplitBar"));
19
+ require("./style/index.less");
20
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
22
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
23
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
24
+ const Splitter = props => {
25
+ const {
26
+ prefixCls: customizePrefixCls,
27
+ className,
28
+ style,
29
+ layout = 'horizontal',
30
+ children,
31
+ rootClassName,
32
+ onResizeStart,
33
+ onResize,
34
+ onResizeEnd,
35
+ lazy
36
+ } = props;
37
+ const {
38
+ getPrefixCls,
39
+ direction
40
+ } = (0, _react.useContext)(_configProvider.ConfigContext);
41
+ const prefixCls = getPrefixCls('splitter', customizePrefixCls);
42
+
43
+ // ======================== Direct ========================
44
+ const isVertical = layout === 'vertical';
45
+ const isRTL = direction === 'rtl';
46
+ const reverse = !isVertical && isRTL;
47
+
48
+ // ====================== Items Data ======================
49
+ const items = (0, _useItems.default)(children);
50
+
51
+ // >>> Warning 适配 v4
52
+ if (process.env.NODE_ENV !== 'production') {
53
+ let existSize = false;
54
+ let existUndefinedSize = false;
55
+ items.forEach(item => {
56
+ if (item.size !== undefined) {
57
+ existSize = true;
58
+ } else {
59
+ existUndefinedSize = true;
60
+ }
61
+ });
62
+ if (existSize && existUndefinedSize && !onResize) {
63
+ (0, _warning.default)(false, 'When part of `Splitter.Panel` has `size`, `onResize` is required or change `size` to `defaultSize`.');
64
+ }
65
+ }
66
+
67
+ // ====================== Container =======================
68
+ const [containerSize, setContainerSize] = (0, _react.useState)();
69
+ const onContainerResize = size => {
70
+ const {
71
+ offsetWidth,
72
+ offsetHeight
73
+ } = size;
74
+ const containerSize = isVertical ? offsetHeight : offsetWidth;
75
+ if (containerSize === 0) {
76
+ return;
77
+ }
78
+ setContainerSize(containerSize);
79
+ };
80
+
81
+ // ========================= Size =========================
82
+ const [panelSizes, itemPxSizes, itemPtgSizes, itemPtgMinSizes, itemPtgMaxSizes, updateSizes] = (0, _useSizes.default)(items, containerSize);
83
+
84
+ // ====================== Resizable =======================
85
+ const resizableInfos = (0, _useResizable.default)(items, itemPxSizes, isRTL);
86
+ const [onOffsetStart, onOffsetUpdate, onOffsetEnd, onCollapse, movingIndex] = (0, _useResize.default)(items, resizableInfos, itemPtgSizes, containerSize, updateSizes, isRTL);
87
+
88
+ // ======================== Events ========================
89
+ const onInternalResizeStart = (0, _useEvent.default)(index => {
90
+ onOffsetStart(index);
91
+ onResizeStart?.(itemPxSizes);
92
+ });
93
+ const onInternalResizeUpdate = (0, _useEvent.default)((index, offset, lazyEnd) => {
94
+ const nextSizes = onOffsetUpdate(index, offset);
95
+ if (lazyEnd) {
96
+ onResizeEnd?.(nextSizes);
97
+ } else {
98
+ onResize?.(nextSizes);
99
+ }
100
+ });
101
+ const onInternalResizeEnd = (0, _useEvent.default)(lazyEnd => {
102
+ onOffsetEnd();
103
+ if (!lazyEnd) {
104
+ onResizeEnd?.(itemPxSizes);
105
+ }
106
+ });
107
+ const onInternalCollapse = (0, _useEvent.default)((index, type) => {
108
+ const nextSizes = onCollapse(index, type);
109
+ onResize?.(nextSizes);
110
+ onResizeEnd?.(nextSizes);
111
+ });
112
+ const containerClassName = (0, _classnames.default)(prefixCls, className, `${prefixCls}-${layout}`, {
113
+ [`${prefixCls}-rtl`]: isRTL
114
+ }, rootClassName);
115
+
116
+ // ======================== Render ========================
117
+ const maskCls = `${prefixCls}-mask`;
118
+ const stackSizes = _react.default.useMemo(() => {
119
+ const mergedSizes = [];
120
+ let stack = 0;
121
+ for (let i = 0; i < items.length; i += 1) {
122
+ stack += itemPtgSizes[i];
123
+ mergedSizes.push(stack);
124
+ }
125
+ return mergedSizes;
126
+ }, [itemPtgSizes]);
127
+ const mergedStyle = {
128
+ ...style
129
+ };
130
+ return /*#__PURE__*/_react.default.createElement(_rcResizeObserver.default, {
131
+ onResize: onContainerResize
132
+ }, /*#__PURE__*/_react.default.createElement("div", {
133
+ style: mergedStyle,
134
+ className: containerClassName
135
+ }, items.map((item, idx) => {
136
+ // Panel
137
+ const panel = /*#__PURE__*/_react.default.createElement(_Panel.InternalPanel, _extends({}, item, {
138
+ prefixCls: prefixCls,
139
+ size: panelSizes[idx]
140
+ }));
141
+ let splitBar = null;
142
+ const resizableInfo = resizableInfos[idx];
143
+ if (resizableInfo) {
144
+ const ariaMinStart = (stackSizes[idx - 1] || 0) + itemPtgMinSizes[idx];
145
+ const ariaMinEnd = (stackSizes[idx + 1] || 100) - itemPtgMaxSizes[idx + 1];
146
+ const ariaMaxStart = (stackSizes[idx - 1] || 0) + itemPtgMaxSizes[idx];
147
+ const ariaMaxEnd = (stackSizes[idx + 1] || 100) - itemPtgMinSizes[idx + 1];
148
+ splitBar = /*#__PURE__*/_react.default.createElement(_SplitBar.default, {
149
+ lazy: lazy,
150
+ index: idx,
151
+ active: movingIndex === idx,
152
+ prefixCls: prefixCls,
153
+ vertical: isVertical,
154
+ resizable: resizableInfo.resizable,
155
+ ariaNow: stackSizes[idx] * 100,
156
+ ariaMin: Math.max(ariaMinStart, ariaMinEnd) * 100,
157
+ ariaMax: Math.min(ariaMaxStart, ariaMaxEnd) * 100,
158
+ startCollapsible: resizableInfo.startCollapsible,
159
+ endCollapsible: resizableInfo.endCollapsible,
160
+ showStartCollapsibleIcon: resizableInfo.showStartCollapsibleIcon,
161
+ showEndCollapsibleIcon: resizableInfo.showEndCollapsibleIcon,
162
+ onOffsetStart: onInternalResizeStart,
163
+ onOffsetUpdate: (index, offsetX, offsetY, lazyEnd) => {
164
+ let offset = isVertical ? offsetY : offsetX;
165
+ if (reverse) {
166
+ offset = -offset;
167
+ }
168
+ onInternalResizeUpdate(index, offset, lazyEnd);
169
+ },
170
+ onOffsetEnd: onInternalResizeEnd,
171
+ onCollapse: onInternalCollapse,
172
+ containerSize: containerSize || 0
173
+ });
174
+ }
175
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, {
176
+ key: `split-panel-${idx}`
177
+ }, panel, splitBar);
178
+ }), typeof movingIndex === 'number' && /*#__PURE__*/_react.default.createElement("div", {
179
+ "aria-hidden": true,
180
+ className: (0, _classnames.default)(maskCls, `${maskCls}-${layout}`)
181
+ })));
182
+ };
183
+ if (process.env.NODE_ENV !== 'production') {
184
+ Splitter.displayName = 'Splitter';
185
+ }
186
+ var _default = exports.default = Splitter;
@@ -0,0 +1,3 @@
1
+ declare type SizeUnit = number | undefined;
2
+ export declare function autoPtgSizes(ptgSizes: SizeUnit[], minPtgSizes: SizeUnit[], maxPtgSizes: SizeUnit[]): number[];
3
+ export {};
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.autoPtgSizes = autoPtgSizes;
7
+ function autoPtgSizes(ptgSizes, minPtgSizes, maxPtgSizes) {
8
+ let currentTotalPtg = 0;
9
+ const undefinedIndexes = [];
10
+ ptgSizes.forEach((size, index) => {
11
+ if (size === undefined) {
12
+ undefinedIndexes.push(index);
13
+ } else {
14
+ currentTotalPtg += size;
15
+ }
16
+ });
17
+ const restPtg = 1 - currentTotalPtg;
18
+ const undefinedCount = undefinedIndexes.length;
19
+ if (restPtg < 0) {
20
+ const scale = 1 / currentTotalPtg;
21
+ return ptgSizes.map(size => size === undefined ? 0 : size * scale);
22
+ }
23
+ let sumMin = 0;
24
+ let sumMax = 0;
25
+ let limitMin = 0;
26
+ let limitMax = 1;
27
+ for (const index of undefinedIndexes) {
28
+ const min = minPtgSizes[index] || 0;
29
+ const max = maxPtgSizes[index] || 1;
30
+ sumMin += min;
31
+ sumMax += max;
32
+ limitMin = Math.max(limitMin, min);
33
+ limitMax = Math.min(limitMax, max);
34
+ }
35
+ if (sumMin > 1 && sumMax < 1) {
36
+ const avg = 1 / undefinedCount;
37
+ return ptgSizes.map(size => size === undefined ? avg : size);
38
+ }
39
+ const restAvg = restPtg / undefinedCount;
40
+ if (limitMin <= restAvg && restAvg <= limitMax) {
41
+ return ptgSizes.map(size => size === undefined ? restAvg : size);
42
+ }
43
+ const result = [...ptgSizes];
44
+ let remain = restPtg - sumMin;
45
+ for (let i = 0; i < undefinedCount; i += 1) {
46
+ const index = undefinedIndexes[i];
47
+ const min = minPtgSizes[index] || 0;
48
+ const max = maxPtgSizes[index] || 1;
49
+ result[index] = min;
50
+ const canAdd = max - min;
51
+ const add = Math.min(canAdd, remain);
52
+ result[index] += add;
53
+ remain -= add;
54
+ }
55
+ return result;
56
+ }
@@ -0,0 +1,14 @@
1
+ import * as React from 'react';
2
+ import type { PanelProps } from '../interface';
3
+ export declare type ItemType = Omit<PanelProps, 'collapsible'> & {
4
+ collapsible: {
5
+ start?: boolean;
6
+ end?: boolean;
7
+ showCollapsibleIcon: 'auto' | boolean;
8
+ };
9
+ };
10
+ /**
11
+ * Convert `children` into `items`.
12
+ */
13
+ declare function useItems(children: React.ReactNode): ItemType[];
14
+ export default useItems;
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var React = _interopRequireWildcard(require("react"));
8
+ var _toArray = _interopRequireDefault(require("rc-util/lib/Children/toArray"));
9
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
11
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
12
+ function getCollapsible(collapsible) {
13
+ if (collapsible && typeof collapsible === 'object') {
14
+ return {
15
+ ...collapsible,
16
+ showCollapsibleIcon: collapsible.showCollapsibleIcon === undefined ? 'auto' : collapsible.showCollapsibleIcon
17
+ };
18
+ }
19
+ const mergedCollapsible = !!collapsible;
20
+ return {
21
+ start: mergedCollapsible,
22
+ end: mergedCollapsible,
23
+ showCollapsibleIcon: 'auto'
24
+ };
25
+ }
26
+
27
+ /**
28
+ * Convert `children` into `items`.
29
+ */
30
+ function useItems(children) {
31
+ const items = React.useMemo(() => (0, _toArray.default)(children).filter(item => /*#__PURE__*/React.isValidElement(item)).map(node => {
32
+ const {
33
+ props
34
+ } = node;
35
+ const {
36
+ collapsible,
37
+ ...restProps
38
+ } = props;
39
+ return {
40
+ ...restProps,
41
+ collapsible: getCollapsible(collapsible)
42
+ };
43
+ }), [children]);
44
+ return items;
45
+ }
46
+ var _default = exports.default = useItems;
@@ -0,0 +1,10 @@
1
+ import type { ShowCollapsibleIconMode } from '../SplitBar';
2
+ import type { ItemType } from './useItems';
3
+ export declare type ResizableInfo = {
4
+ resizable: boolean;
5
+ startCollapsible: boolean;
6
+ endCollapsible: boolean;
7
+ showStartCollapsibleIcon: ShowCollapsibleIconMode;
8
+ showEndCollapsibleIcon: ShowCollapsibleIconMode;
9
+ };
10
+ export default function useResizable(items: ItemType[], pxSizes: number[], isRTL: boolean): ResizableInfo[];
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = useResizable;
7
+ var React = _interopRequireWildcard(require("react"));
8
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
9
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
10
+ function getShowCollapsibleIcon(prev, next) {
11
+ if (prev.collapsible && next.collapsible) {
12
+ if (prev.showCollapsibleIcon === true || next.showCollapsibleIcon === true) {
13
+ return true;
14
+ }
15
+ if (prev.showCollapsibleIcon === 'auto' || next.showCollapsibleIcon === 'auto') {
16
+ return 'auto';
17
+ }
18
+ return false;
19
+ }
20
+ if (prev.collapsible) {
21
+ return prev.showCollapsibleIcon;
22
+ }
23
+ if (next.collapsible) {
24
+ return next.showCollapsibleIcon;
25
+ }
26
+ return false;
27
+ }
28
+ function useResizable(items, pxSizes, isRTL) {
29
+ return React.useMemo(() => {
30
+ const resizeInfos = [];
31
+ for (let i = 0; i < items.length - 1; i += 1) {
32
+ const prevItem = items[i];
33
+ const nextItem = items[i + 1];
34
+ const prevSize = pxSizes[i];
35
+ const nextSize = pxSizes[i + 1];
36
+ const {
37
+ resizable: prevResizable = true,
38
+ min: prevMin,
39
+ collapsible: prevCollapsible
40
+ } = prevItem;
41
+ const {
42
+ resizable: nextResizable = true,
43
+ min: nextMin,
44
+ collapsible: nextCollapsible
45
+ } = nextItem;
46
+ const mergedResizable =
47
+ // Both need to be resizable
48
+ prevResizable && nextResizable && (
49
+ // Prev is not collapsed and limit min size
50
+ prevSize !== 0 || !prevMin) && (
51
+ // Next is not collapsed and limit min size
52
+ nextSize !== 0 || !nextMin);
53
+ const prevEndCollapsible = !!prevCollapsible.end && prevSize > 0;
54
+ const nextStartExpandable = !!nextCollapsible.start && nextSize === 0 && prevSize > 0;
55
+ const startCollapsible = prevEndCollapsible || nextStartExpandable;
56
+ const nextStartCollapsible = !!nextCollapsible.start && nextSize > 0;
57
+ const prevEndExpandable = !!prevCollapsible.end && prevSize === 0 && nextSize > 0;
58
+ const endCollapsible = nextStartCollapsible || prevEndExpandable;
59
+ const showStartCollapsibleIcon = getShowCollapsibleIcon({
60
+ collapsible: prevEndCollapsible,
61
+ showCollapsibleIcon: prevCollapsible.showCollapsibleIcon
62
+ }, {
63
+ collapsible: nextStartExpandable,
64
+ showCollapsibleIcon: nextCollapsible.showCollapsibleIcon
65
+ });
66
+ const showEndCollapsibleIcon = getShowCollapsibleIcon({
67
+ collapsible: nextStartCollapsible,
68
+ showCollapsibleIcon: nextCollapsible.showCollapsibleIcon
69
+ }, {
70
+ collapsible: prevEndExpandable,
71
+ showCollapsibleIcon: prevCollapsible.showCollapsibleIcon
72
+ });
73
+ resizeInfos[i] = {
74
+ resizable: mergedResizable,
75
+ startCollapsible: !!(isRTL ? endCollapsible : startCollapsible),
76
+ endCollapsible: !!(isRTL ? startCollapsible : endCollapsible),
77
+ showStartCollapsibleIcon: isRTL ? showEndCollapsibleIcon : showStartCollapsibleIcon,
78
+ showEndCollapsibleIcon: isRTL ? showStartCollapsibleIcon : showEndCollapsibleIcon
79
+ };
80
+ }
81
+ return resizeInfos;
82
+ }, [pxSizes, items]);
83
+ }
@@ -0,0 +1,6 @@
1
+ import type { ItemType } from './useItems';
2
+ import type { ResizableInfo } from './useResizable';
3
+ /**
4
+ * Handle user drag resize logic.
5
+ */
6
+ export default function useResize(items: ItemType[], resizableInfos: ResizableInfo[], percentSizes: number[], containerSize: number | undefined, updateSizes: (sizes: number[]) => void, isRTL: boolean): readonly [(index: number) => void, (index: number, offset: number) => number[], () => void, (index: number, type: 'start' | 'end') => number[], number | undefined];