@gfazioli/mantine-split-pane 1.1.7 → 2.1.0
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.
- package/README.md +4 -2
- package/dist/cjs/Pane/SplitPane.cjs +108 -91
- package/dist/cjs/Pane/SplitPane.cjs.map +1 -1
- package/dist/cjs/Resizer/SplitPaneResizer.cjs +292 -111
- package/dist/cjs/Resizer/SplitPaneResizer.cjs.map +1 -1
- package/dist/cjs/Split.cjs +30 -16
- package/dist/cjs/Split.cjs.map +1 -1
- package/dist/cjs/Split.context.cjs +1 -4
- package/dist/cjs/Split.context.cjs.map +1 -1
- package/dist/cjs/index.cjs +2 -6
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/Pane/SplitPane.mjs +109 -92
- package/dist/esm/Pane/SplitPane.mjs.map +1 -1
- package/dist/esm/Resizer/SplitPaneResizer.mjs +293 -113
- package/dist/esm/Resizer/SplitPaneResizer.mjs.map +1 -1
- package/dist/esm/Split.context.mjs +2 -5
- package/dist/esm/Split.context.mjs.map +1 -1
- package/dist/esm/Split.mjs +31 -17
- package/dist/esm/Split.mjs.map +1 -1
- package/dist/esm/index.mjs +1 -3
- package/dist/esm/index.mjs.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/styles.layer.css +1 -1
- package/dist/types/Pane/SplitPane.d.ts +40 -6
- package/dist/types/Resizer/SplitPaneResizer.d.ts +35 -21
- package/dist/types/Split.context.d.ts +4 -2
- package/dist/types/Split.d.ts +5 -3
- package/dist/types/index.d.mts +4 -6
- package/dist/types/index.d.ts +4 -6
- package/package.json +1 -1
- package/dist/cjs/Split.errors.cjs +0 -8
- package/dist/cjs/Split.errors.cjs.map +0 -1
- package/dist/esm/Split.errors.mjs +0 -6
- package/dist/esm/Split.errors.mjs.map +0 -1
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
var React = require('react');
|
|
5
5
|
var core = require('@mantine/core');
|
|
6
|
+
var Split_context = require('../Split.context.cjs');
|
|
6
7
|
var SplitPaneResizer_module = require('./SplitPaneResizer.module.css.cjs');
|
|
7
8
|
|
|
8
9
|
const varsResolver = core.createVarsResolver(
|
|
@@ -22,40 +23,35 @@ const varsResolver = core.createVarsResolver(
|
|
|
22
23
|
spacing,
|
|
23
24
|
variant,
|
|
24
25
|
cursorVertical,
|
|
25
|
-
cursorHorizontal
|
|
26
|
+
cursorHorizontal,
|
|
27
|
+
gradient,
|
|
28
|
+
hoverGradient
|
|
26
29
|
}) => {
|
|
27
|
-
const colorDarkParsed = core.parseThemeColor({
|
|
28
|
-
color: color || "dark.5",
|
|
29
|
-
theme
|
|
30
|
-
});
|
|
31
|
-
const colorLightParsed = core.parseThemeColor({
|
|
32
|
-
color: color || "gray.3",
|
|
33
|
-
theme
|
|
34
|
-
});
|
|
35
|
-
const hoverColorDarkParsed = core.parseThemeColor({
|
|
36
|
-
color: hoverColor || "dark.3",
|
|
37
|
-
theme
|
|
38
|
-
});
|
|
39
|
-
const hoverColorLightParsed = core.parseThemeColor({
|
|
40
|
-
color: hoverColor || "gray.4",
|
|
41
|
-
theme
|
|
42
|
-
});
|
|
43
30
|
const knobVariant = variant === "dotted" || variant === "dashed";
|
|
31
|
+
const forceKnobOpacityValue = withKnob && knobAlwaysOn && !knobVariant ? knobOpacity : "0";
|
|
32
|
+
const colors = variantColorResolver({
|
|
33
|
+
color,
|
|
34
|
+
hover: hoverColor,
|
|
35
|
+
knob: knobColor,
|
|
36
|
+
hoverKnob: knobHoverColor,
|
|
37
|
+
theme,
|
|
38
|
+
gradient,
|
|
39
|
+
hoverGradient,
|
|
40
|
+
variant: variant || "filled"
|
|
41
|
+
});
|
|
44
42
|
return {
|
|
45
43
|
root: {
|
|
46
44
|
"--split-resizer-size": core.getSize(size, "split-resizer-size"),
|
|
47
|
-
"--split-resizer-color":
|
|
48
|
-
"--split-resizer-color
|
|
49
|
-
"--split-resizer-color-dark": core.rgba(colorDarkParsed.value, Number(opacity)),
|
|
50
|
-
"--split-resizer-hover-color-light": core.rgba(hoverColorLightParsed.value, 1),
|
|
51
|
-
"--split-resizer-hover-color-dark": core.rgba(hoverColorDarkParsed.value, 1),
|
|
45
|
+
"--split-resizer-color": colors.color,
|
|
46
|
+
"--split-resizer-hover-color": colors.hover,
|
|
52
47
|
"--split-resizer-radius": core.getRadius(radius),
|
|
48
|
+
"--split-resizer-opacity": opacity !== void 0 ? opacity : "1",
|
|
53
49
|
"--split-resizer-knob-size": core.getSize(knobSize, "split-resizer-knob-size"),
|
|
54
|
-
"--split-resizer-knob-opacity":
|
|
50
|
+
"--split-resizer-knob-opacity": forceKnobOpacityValue,
|
|
55
51
|
"--split-resizer-knob-hover-opacity": withKnob || knobVariant ? "1" : "0",
|
|
56
52
|
"--split-resizer-knob-radius": core.getRadius(knobRadius),
|
|
57
|
-
"--split-resizer-knob-color":
|
|
58
|
-
"--split-resizer-knob-hover-color":
|
|
53
|
+
"--split-resizer-knob-color": colors.knob,
|
|
54
|
+
"--split-resizer-knob-hover-color": colors.hoverKnob,
|
|
59
55
|
"--split-resizer-spacing": core.getSize(spacing, "split-resizer-spacing"),
|
|
60
56
|
"--split-resizer-cursor-vertical": cursorVertical || "col-resize",
|
|
61
57
|
"--split-resizer-cursor-horizontal": cursorHorizontal || "row-resize"
|
|
@@ -63,56 +59,79 @@ const varsResolver = core.createVarsResolver(
|
|
|
63
59
|
};
|
|
64
60
|
}
|
|
65
61
|
);
|
|
62
|
+
const variantColorResolver = ({
|
|
63
|
+
color,
|
|
64
|
+
hover,
|
|
65
|
+
knob,
|
|
66
|
+
hoverKnob,
|
|
67
|
+
theme,
|
|
68
|
+
variant,
|
|
69
|
+
gradient,
|
|
70
|
+
hoverGradient
|
|
71
|
+
}) => {
|
|
72
|
+
const parsedColor = color ? core.parseThemeColor({ color, theme }).value : void 0;
|
|
73
|
+
const parsedHover = hover ? core.parseThemeColor({ color: hover, theme }).value : void 0;
|
|
74
|
+
const parsedKnob = knob ? core.parseThemeColor({ color: knob, theme }).value : void 0;
|
|
75
|
+
const parsedHoverKnob = hoverKnob ? core.parseThemeColor({ color: hoverKnob, theme }).value : void 0;
|
|
76
|
+
const colors = {
|
|
77
|
+
color: parsedColor,
|
|
78
|
+
hover: parsedHover,
|
|
79
|
+
knob: parsedKnob,
|
|
80
|
+
hoverKnob: parsedHoverKnob
|
|
81
|
+
};
|
|
82
|
+
if (variant === "gradient") {
|
|
83
|
+
colors.color = core.getGradient(gradient, theme);
|
|
84
|
+
colors.hover = core.getGradient(hoverGradient || gradient, theme);
|
|
85
|
+
}
|
|
86
|
+
return colors;
|
|
87
|
+
};
|
|
66
88
|
const defaultProps = {
|
|
67
|
-
|
|
89
|
+
orientation: "vertical",
|
|
68
90
|
opacity: 0.8,
|
|
91
|
+
size: "sm",
|
|
69
92
|
radius: "xs",
|
|
70
|
-
|
|
93
|
+
withKnob: false,
|
|
94
|
+
knobAlwaysOn: true,
|
|
71
95
|
knobSize: "sm",
|
|
72
96
|
knobOpacity: 0.5,
|
|
73
97
|
knobRadius: "sm",
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
paneRef: { current: null },
|
|
78
|
-
variant: "default",
|
|
79
|
-
withKnob: false,
|
|
80
|
-
knobAlwaysOn: true,
|
|
98
|
+
knobColor: "white",
|
|
99
|
+
knobHoverColor: "white",
|
|
100
|
+
spacing: "xs",
|
|
81
101
|
step: 8,
|
|
82
102
|
shiftStep: 64,
|
|
83
103
|
cursorVertical: "col-resize",
|
|
84
104
|
cursorHorizontal: "row-resize"
|
|
85
105
|
};
|
|
86
|
-
const SplitPaneResizer = core.factory((_props,
|
|
87
|
-
const
|
|
106
|
+
const SplitPaneResizer = core.factory((_props, _) => {
|
|
107
|
+
const ctx = Split_context.useSplitContext();
|
|
108
|
+
const props = core.useProps("SplitPaneResizer", { ...defaultProps, ...ctx }, _props);
|
|
88
109
|
const {
|
|
89
|
-
|
|
110
|
+
orientation,
|
|
90
111
|
opacity,
|
|
112
|
+
size,
|
|
91
113
|
radius,
|
|
92
|
-
|
|
93
|
-
|
|
114
|
+
withKnob,
|
|
115
|
+
knobAlwaysOn,
|
|
94
116
|
knobSize,
|
|
95
117
|
knobOpacity,
|
|
96
118
|
knobRadius,
|
|
97
119
|
knobColor,
|
|
98
120
|
knobHoverColor,
|
|
99
|
-
minWidth,
|
|
100
|
-
minHeight,
|
|
101
|
-
maxWidth,
|
|
102
|
-
maxHeight,
|
|
103
|
-
orientation,
|
|
104
|
-
onResizeStart,
|
|
105
|
-
onResizing,
|
|
106
|
-
onResizeEnd,
|
|
107
|
-
paneRef,
|
|
108
|
-
variant,
|
|
109
|
-
withKnob,
|
|
110
|
-
knobAlwaysOn,
|
|
111
121
|
spacing,
|
|
112
122
|
step,
|
|
113
123
|
shiftStep,
|
|
114
124
|
cursorVertical,
|
|
115
125
|
cursorHorizontal,
|
|
126
|
+
color,
|
|
127
|
+
hoverColor,
|
|
128
|
+
variant,
|
|
129
|
+
onResizeStart,
|
|
130
|
+
onResizing,
|
|
131
|
+
onResizeEnd,
|
|
132
|
+
onDoubleClick,
|
|
133
|
+
__beforeRef: beforeRef,
|
|
134
|
+
__afterRef: afterRef,
|
|
116
135
|
className,
|
|
117
136
|
style,
|
|
118
137
|
classNames,
|
|
@@ -120,7 +139,7 @@ const SplitPaneResizer = core.factory((_props, ref) => {
|
|
|
120
139
|
unstyled,
|
|
121
140
|
vars,
|
|
122
141
|
mod,
|
|
123
|
-
...
|
|
142
|
+
...rest
|
|
124
143
|
} = props;
|
|
125
144
|
const getStyles = core.useStyles({
|
|
126
145
|
name: "SplitPaneResizer",
|
|
@@ -135,6 +154,150 @@ const SplitPaneResizer = core.factory((_props, ref) => {
|
|
|
135
154
|
varsResolver
|
|
136
155
|
});
|
|
137
156
|
const containerRef = React.useRef(null);
|
|
157
|
+
const processVerticalSize = (deltaX = 0) => {
|
|
158
|
+
const minBeforeWidth = beforeRef.current.getMinWidth();
|
|
159
|
+
const maxBeforeWidth = beforeRef.current.getMaxWidth();
|
|
160
|
+
const minAfterWidth = afterRef.current.getMinWidth();
|
|
161
|
+
const maxAfterWidth = afterRef.current.getMaxWidth();
|
|
162
|
+
const beforePane = beforeRef.current.splitPane;
|
|
163
|
+
const afterPane = afterRef.current.splitPane;
|
|
164
|
+
let beforeWidth = beforePane.getBoundingClientRect().width;
|
|
165
|
+
let afterWidth = afterPane.getBoundingClientRect().width;
|
|
166
|
+
const isBeforeWidthMaxExceeded = maxBeforeWidth && beforeWidth + deltaX > maxBeforeWidth;
|
|
167
|
+
const isAfterWidthMaxExceeded = maxAfterWidth && afterWidth - deltaX > maxAfterWidth;
|
|
168
|
+
const isBeforeWidthMinExceeded = minBeforeWidth && beforeWidth + deltaX < minBeforeWidth;
|
|
169
|
+
const isAfterWidthMinExceeded = minAfterWidth && afterWidth - deltaX < minAfterWidth;
|
|
170
|
+
const isBeforeWidthNegative = beforeWidth + deltaX < 0;
|
|
171
|
+
const isAfterWidthNegative = afterWidth - deltaX < 0;
|
|
172
|
+
function setVerticalSize() {
|
|
173
|
+
const beforeWidthString = `${beforeWidth}px`;
|
|
174
|
+
const afterWidthString = `${afterWidth}px`;
|
|
175
|
+
const beforePaneSizes = {
|
|
176
|
+
width: beforeWidth,
|
|
177
|
+
height: beforePane.getBoundingClientRect().height
|
|
178
|
+
};
|
|
179
|
+
const afterPaneSizes = {
|
|
180
|
+
width: afterWidth,
|
|
181
|
+
height: afterPane.getBoundingClientRect().height
|
|
182
|
+
};
|
|
183
|
+
beforeRef.current.onResizing?.(beforePaneSizes);
|
|
184
|
+
afterRef.current.onResizing?.(afterPaneSizes);
|
|
185
|
+
onResizing?.({
|
|
186
|
+
beforePane: beforePaneSizes,
|
|
187
|
+
afterPane: afterPaneSizes
|
|
188
|
+
});
|
|
189
|
+
beforePane.style.width = beforeWidthString;
|
|
190
|
+
afterPane.style.width = afterWidthString;
|
|
191
|
+
}
|
|
192
|
+
if (!isAfterWidthMaxExceeded && isBeforeWidthMinExceeded) {
|
|
193
|
+
afterWidth += beforeWidth - minBeforeWidth;
|
|
194
|
+
beforeWidth = minBeforeWidth;
|
|
195
|
+
return setVerticalSize();
|
|
196
|
+
}
|
|
197
|
+
if (!isAfterWidthMaxExceeded && isBeforeWidthNegative) {
|
|
198
|
+
afterWidth += beforeWidth;
|
|
199
|
+
beforeWidth = 0;
|
|
200
|
+
return setVerticalSize();
|
|
201
|
+
}
|
|
202
|
+
if (!isAfterWidthMinExceeded && !isAfterWidthNegative && isBeforeWidthMaxExceeded) {
|
|
203
|
+
afterWidth -= maxBeforeWidth - beforeWidth;
|
|
204
|
+
beforeWidth = maxBeforeWidth;
|
|
205
|
+
return setVerticalSize();
|
|
206
|
+
}
|
|
207
|
+
if (!isBeforeWidthMaxExceeded && isAfterWidthMinExceeded) {
|
|
208
|
+
beforeWidth += afterWidth - minAfterWidth;
|
|
209
|
+
afterWidth = minAfterWidth;
|
|
210
|
+
return setVerticalSize();
|
|
211
|
+
}
|
|
212
|
+
if (!isBeforeWidthMaxExceeded && isAfterWidthNegative) {
|
|
213
|
+
beforeWidth += afterWidth;
|
|
214
|
+
afterWidth = 0;
|
|
215
|
+
return setVerticalSize();
|
|
216
|
+
}
|
|
217
|
+
if (!isBeforeWidthMinExceeded && !isBeforeWidthNegative && isAfterWidthMaxExceeded) {
|
|
218
|
+
beforeWidth -= maxAfterWidth - afterWidth;
|
|
219
|
+
afterWidth = maxAfterWidth;
|
|
220
|
+
return setVerticalSize();
|
|
221
|
+
}
|
|
222
|
+
if (isBeforeWidthNegative || isAfterWidthNegative || isBeforeWidthMaxExceeded || isAfterWidthMaxExceeded || isBeforeWidthMinExceeded || isAfterWidthMinExceeded) {
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
beforeWidth += deltaX;
|
|
226
|
+
afterWidth -= deltaX;
|
|
227
|
+
setVerticalSize();
|
|
228
|
+
};
|
|
229
|
+
const processHorizontalSize = (deltaY = 0) => {
|
|
230
|
+
const minBeforeHeight = beforeRef.current.getMinHeight();
|
|
231
|
+
const maxBeforeHeight = beforeRef.current.getMaxHeight();
|
|
232
|
+
const minAfterHeight = afterRef.current.getMinHeight();
|
|
233
|
+
const maxAfterHeight = afterRef.current.getMaxHeight();
|
|
234
|
+
const beforePane = beforeRef.current.splitPane;
|
|
235
|
+
const afterPane = afterRef.current.splitPane;
|
|
236
|
+
let beforeHeight = beforePane.getBoundingClientRect().height;
|
|
237
|
+
let afterHeight = afterPane.getBoundingClientRect().height;
|
|
238
|
+
const isBeforeHeightMaxExceeded = maxBeforeHeight && beforeHeight + deltaY > maxBeforeHeight;
|
|
239
|
+
const isAfterHeightMaxExceeded = maxAfterHeight && afterHeight - deltaY > maxAfterHeight;
|
|
240
|
+
const isBeforeHeightMinExceeded = minBeforeHeight && beforeHeight + deltaY < minBeforeHeight;
|
|
241
|
+
const isAfterHeightMinExceeded = minAfterHeight && afterHeight - deltaY < minAfterHeight;
|
|
242
|
+
const isBeforeHeightNegative = beforeHeight + deltaY < 0;
|
|
243
|
+
const isAfterHeightNegative = afterHeight - deltaY < 0;
|
|
244
|
+
function setHorizontalSize() {
|
|
245
|
+
const beforeHeightString = `${beforeHeight}px`;
|
|
246
|
+
const afterHeightString = `${afterHeight}px`;
|
|
247
|
+
const beforePaneSizes = {
|
|
248
|
+
width: beforePane.getBoundingClientRect().width,
|
|
249
|
+
height: beforeHeight
|
|
250
|
+
};
|
|
251
|
+
const afterPaneSizes = {
|
|
252
|
+
width: afterPane.getBoundingClientRect().width,
|
|
253
|
+
height: afterHeight
|
|
254
|
+
};
|
|
255
|
+
onResizing?.({
|
|
256
|
+
beforePane: beforePaneSizes,
|
|
257
|
+
afterPane: afterPaneSizes
|
|
258
|
+
});
|
|
259
|
+
beforeRef.current.onResizing?.(beforePaneSizes);
|
|
260
|
+
afterRef.current.onResizing?.(afterPaneSizes);
|
|
261
|
+
beforePane.style.height = beforeHeightString;
|
|
262
|
+
afterPane.style.height = afterHeightString;
|
|
263
|
+
}
|
|
264
|
+
if (!isAfterHeightMaxExceeded && isBeforeHeightMinExceeded) {
|
|
265
|
+
afterHeight += beforeHeight - minBeforeHeight;
|
|
266
|
+
beforeHeight = minBeforeHeight;
|
|
267
|
+
return setHorizontalSize();
|
|
268
|
+
}
|
|
269
|
+
if (!isAfterHeightMaxExceeded && isBeforeHeightNegative) {
|
|
270
|
+
afterHeight += beforeHeight;
|
|
271
|
+
beforeHeight = 0;
|
|
272
|
+
return setHorizontalSize();
|
|
273
|
+
}
|
|
274
|
+
if (!isAfterHeightMinExceeded && !isAfterHeightNegative && isBeforeHeightMaxExceeded) {
|
|
275
|
+
afterHeight -= maxBeforeHeight - beforeHeight;
|
|
276
|
+
beforeHeight = maxBeforeHeight;
|
|
277
|
+
return setHorizontalSize();
|
|
278
|
+
}
|
|
279
|
+
if (!isBeforeHeightMaxExceeded && isAfterHeightMinExceeded) {
|
|
280
|
+
beforeHeight += afterHeight - minAfterHeight;
|
|
281
|
+
afterHeight = minAfterHeight;
|
|
282
|
+
return setHorizontalSize();
|
|
283
|
+
}
|
|
284
|
+
if (!isBeforeHeightMaxExceeded && isAfterHeightNegative) {
|
|
285
|
+
beforeHeight += afterHeight;
|
|
286
|
+
afterHeight = 0;
|
|
287
|
+
return setHorizontalSize();
|
|
288
|
+
}
|
|
289
|
+
if (!isBeforeHeightMinExceeded && !isBeforeHeightNegative && isAfterHeightMaxExceeded) {
|
|
290
|
+
beforeHeight -= maxAfterHeight - afterHeight;
|
|
291
|
+
afterHeight = maxAfterHeight;
|
|
292
|
+
return setHorizontalSize();
|
|
293
|
+
}
|
|
294
|
+
if (isBeforeHeightNegative || isAfterHeightNegative || isBeforeHeightMaxExceeded || isAfterHeightMaxExceeded || isBeforeHeightMinExceeded || isAfterHeightMinExceeded) {
|
|
295
|
+
return;
|
|
296
|
+
}
|
|
297
|
+
beforeHeight += deltaY;
|
|
298
|
+
afterHeight -= deltaY;
|
|
299
|
+
setHorizontalSize();
|
|
300
|
+
};
|
|
138
301
|
const handleStart = (event) => {
|
|
139
302
|
event.preventDefault();
|
|
140
303
|
event.stopPropagation();
|
|
@@ -149,110 +312,127 @@ const SplitPaneResizer = core.factory((_props, ref) => {
|
|
|
149
312
|
document.addEventListener("touchend", handleTouchEnd);
|
|
150
313
|
}
|
|
151
314
|
onResizeStart?.();
|
|
152
|
-
|
|
315
|
+
beforeRef.current.onResizeStart?.();
|
|
316
|
+
afterRef.current.onResizeStart?.();
|
|
317
|
+
document.body.style.cursor = orientation === "vertical" ? cursorVertical : cursorHorizontal;
|
|
153
318
|
};
|
|
154
319
|
const handleMove = (event) => {
|
|
155
|
-
if (!
|
|
320
|
+
if (!beforeRef.current || !afterRef.current) {
|
|
321
|
+
throw new Error("beforeRef or afterRef is not defined");
|
|
322
|
+
}
|
|
156
323
|
event.preventDefault();
|
|
157
324
|
event.stopPropagation();
|
|
158
325
|
const computedStyle = window.getComputedStyle(containerRef.current);
|
|
159
|
-
const clientX = "clientX" in event ? event.clientX : event.touches[0].clientX;
|
|
160
|
-
const clientY = "clientY" in event ? event.clientY : event.touches[0].clientY;
|
|
161
326
|
if (orientation === "vertical") {
|
|
162
|
-
const
|
|
163
|
-
const
|
|
164
|
-
const
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
paneRef.current.style.width = widthString;
|
|
173
|
-
} else {
|
|
174
|
-
const margin = parseFloat(computedStyle.getPropertyValue("margin-top")) + 1;
|
|
175
|
-
const delta = clientY - paneRef.current.getBoundingClientRect().bottom - margin;
|
|
176
|
-
const height = paneRef.current.getBoundingClientRect().height + delta;
|
|
177
|
-
const heightString = `${height}px`;
|
|
178
|
-
if (minHeight && height < minHeight) return;
|
|
179
|
-
if (maxHeight && height > maxHeight) return;
|
|
180
|
-
onResizing?.({
|
|
181
|
-
width: paneRef.current.style.width,
|
|
182
|
-
height: heightString
|
|
183
|
-
});
|
|
184
|
-
paneRef.current.style.height = heightString;
|
|
327
|
+
const size2 = parseFloat(computedStyle.getPropertyValue("width"));
|
|
328
|
+
const clientX = "clientX" in event ? event.clientX : event.touches[0].clientX;
|
|
329
|
+
const deltaX = clientX - containerRef.current.getBoundingClientRect().left - size2 / 2;
|
|
330
|
+
return processVerticalSize(deltaX);
|
|
331
|
+
}
|
|
332
|
+
if (orientation === "horizontal") {
|
|
333
|
+
const size2 = parseFloat(computedStyle.getPropertyValue("height"));
|
|
334
|
+
const clientY = "clientY" in event ? event.clientY : event.touches[0].clientY;
|
|
335
|
+
const deltaY = clientY - containerRef.current.getBoundingClientRect().top - size2 / 2;
|
|
336
|
+
return processHorizontalSize(deltaY);
|
|
185
337
|
}
|
|
186
338
|
};
|
|
187
339
|
const handleMouseUp = () => {
|
|
188
|
-
if (!
|
|
340
|
+
if (!beforeRef.current || !afterRef.current) {
|
|
341
|
+
throw new Error("beforeRef or afterRef is not defined");
|
|
342
|
+
}
|
|
189
343
|
document.body.style.userSelect = "initial";
|
|
190
344
|
document.body.style.webkitUserSelect = "initial";
|
|
191
345
|
document.removeEventListener("mousemove", handleMove);
|
|
192
346
|
document.removeEventListener("mouseup", handleMouseUp);
|
|
193
347
|
document.body.style.cursor = "initial";
|
|
194
|
-
const
|
|
195
|
-
|
|
348
|
+
const beforePane = beforeRef.current.splitPane;
|
|
349
|
+
const afterPane = afterRef.current.splitPane;
|
|
350
|
+
const beforePaneSizes = {
|
|
351
|
+
width: beforePane.getBoundingClientRect().width,
|
|
352
|
+
height: beforePane.getBoundingClientRect().height
|
|
353
|
+
};
|
|
354
|
+
const afterPaneSizes = {
|
|
355
|
+
width: afterPane.getBoundingClientRect().width,
|
|
356
|
+
height: afterPane.getBoundingClientRect().height
|
|
357
|
+
};
|
|
358
|
+
onResizeEnd?.({
|
|
359
|
+
beforePane: beforePaneSizes,
|
|
360
|
+
afterPane: afterPaneSizes
|
|
361
|
+
});
|
|
362
|
+
beforeRef.current.onResizeEnd?.(beforePaneSizes);
|
|
363
|
+
afterRef.current.onResizeEnd?.(afterPaneSizes);
|
|
196
364
|
};
|
|
197
365
|
const handleTouchEnd = () => {
|
|
198
|
-
if (!
|
|
366
|
+
if (!beforeRef.current || !afterRef.current) {
|
|
367
|
+
throw new Error("beforeRef or afterRef is not defined");
|
|
368
|
+
}
|
|
199
369
|
document.removeEventListener("touchmove", handleMove);
|
|
200
370
|
document.removeEventListener("touchend", handleTouchEnd);
|
|
201
371
|
document.body.style.cursor = "initial";
|
|
202
|
-
const
|
|
203
|
-
|
|
372
|
+
const beforePane = beforeRef.current.splitPane;
|
|
373
|
+
const afterPane = afterRef.current.splitPane;
|
|
374
|
+
const beforePaneSizes = {
|
|
375
|
+
width: beforePane.getBoundingClientRect().width,
|
|
376
|
+
height: beforePane.getBoundingClientRect().height
|
|
377
|
+
};
|
|
378
|
+
const afterPaneSizes = {
|
|
379
|
+
width: afterPane.getBoundingClientRect().width,
|
|
380
|
+
height: afterPane.getBoundingClientRect().height
|
|
381
|
+
};
|
|
382
|
+
onResizeEnd?.({
|
|
383
|
+
beforePane: beforePaneSizes,
|
|
384
|
+
afterPane: afterPaneSizes
|
|
385
|
+
});
|
|
386
|
+
beforeRef.current.onResizeEnd?.(beforePaneSizes);
|
|
387
|
+
afterRef.current.onResizeEnd?.(afterPaneSizes);
|
|
204
388
|
};
|
|
205
389
|
const handleKeyUp = (event) => {
|
|
206
390
|
if (containerRef.current !== document.activeElement) {
|
|
207
391
|
return;
|
|
208
392
|
}
|
|
393
|
+
const code = event.nativeEvent.code;
|
|
394
|
+
const arrowLeftRight = code === "ArrowRight" || code === "ArrowLeft";
|
|
395
|
+
const arrowUpDown = code === "ArrowUp" || code === "ArrowDown";
|
|
209
396
|
const delta = event.shiftKey ? shiftStep : step;
|
|
210
|
-
if (orientation === "vertical" &&
|
|
397
|
+
if (orientation === "vertical" && arrowLeftRight) {
|
|
211
398
|
event.preventDefault();
|
|
212
399
|
event.stopPropagation();
|
|
213
|
-
const deltaSign =
|
|
214
|
-
const
|
|
215
|
-
|
|
216
|
-
if (minWidth && width < minWidth) return;
|
|
217
|
-
if (maxWidth && width > maxWidth) return;
|
|
218
|
-
onResizing?.({
|
|
219
|
-
width: widthString,
|
|
220
|
-
height: paneRef.current.style.height
|
|
221
|
-
});
|
|
222
|
-
paneRef.current.style.width = widthString;
|
|
400
|
+
const deltaSign = code === "ArrowRight" ? 1 : -1;
|
|
401
|
+
const deltaX = delta * deltaSign;
|
|
402
|
+
return processVerticalSize(deltaX);
|
|
223
403
|
}
|
|
224
|
-
if (orientation === "horizontal" &&
|
|
404
|
+
if (orientation === "horizontal" && arrowUpDown) {
|
|
225
405
|
event.preventDefault();
|
|
226
406
|
event.stopPropagation();
|
|
227
|
-
const deltaSign =
|
|
228
|
-
const
|
|
229
|
-
|
|
230
|
-
if (minHeight && height < minHeight) return;
|
|
231
|
-
if (maxHeight && height > maxHeight) return;
|
|
232
|
-
onResizing?.({
|
|
233
|
-
width: paneRef.current.style.width,
|
|
234
|
-
height: heightString
|
|
235
|
-
});
|
|
236
|
-
paneRef.current.style.height = heightString;
|
|
407
|
+
const deltaSign = code === "ArrowDown" ? 1 : -1;
|
|
408
|
+
const deltaY = delta * deltaSign;
|
|
409
|
+
return processHorizontalSize(deltaY);
|
|
237
410
|
}
|
|
238
|
-
if (
|
|
411
|
+
if (code === "Escape") {
|
|
239
412
|
event.preventDefault();
|
|
240
413
|
event.stopPropagation();
|
|
241
414
|
containerRef.current.blur();
|
|
242
415
|
}
|
|
243
416
|
};
|
|
417
|
+
const handleDoubleClick = (e) => {
|
|
418
|
+
e.preventDefault();
|
|
419
|
+
e.stopPropagation();
|
|
420
|
+
beforeRef.current.resetInitialSize(e);
|
|
421
|
+
afterRef.current.resetInitialSize(e);
|
|
422
|
+
onDoubleClick?.(e);
|
|
423
|
+
};
|
|
244
424
|
return /* @__PURE__ */ React.createElement(
|
|
245
425
|
core.UnstyledButton,
|
|
246
426
|
{
|
|
247
|
-
onDoubleClick: props?.onDoubleClick,
|
|
248
427
|
ref: containerRef,
|
|
249
428
|
mod: { orientation },
|
|
250
429
|
onMouseDown: handleStart,
|
|
251
430
|
onKeyDown: handleKeyUp,
|
|
252
431
|
onTouchStart: handleStart,
|
|
432
|
+
onDoubleClick: handleDoubleClick,
|
|
253
433
|
"aria-label": "Resize",
|
|
254
|
-
...getStyles("root", { variant }),
|
|
255
|
-
...
|
|
434
|
+
...getStyles("root", { variant: variant || "default" }),
|
|
435
|
+
...rest
|
|
256
436
|
}
|
|
257
437
|
);
|
|
258
438
|
});
|
|
@@ -260,4 +440,5 @@ SplitPaneResizer.classes = SplitPaneResizer_module;
|
|
|
260
440
|
SplitPaneResizer.displayName = "SplitPaneResizer";
|
|
261
441
|
|
|
262
442
|
exports.SplitPaneResizer = SplitPaneResizer;
|
|
443
|
+
exports.defaultProps = defaultProps;
|
|
263
444
|
//# sourceMappingURL=SplitPaneResizer.cjs.map
|