@gfazioli/mantine-split-pane 0.3.7 → 1.0.1
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/dist/cjs/Resizer/SplitPaneResizer.cjs +200 -170
- package/dist/cjs/Resizer/SplitPaneResizer.cjs.map +1 -1
- package/dist/esm/Resizer/SplitPaneResizer.mjs +200 -170
- package/dist/esm/Resizer/SplitPaneResizer.mjs.map +1 -1
- package/dist/styles.css +3 -1
- package/dist/styles.layer.css +3 -1
- package/dist/types/Resizer/SplitPaneResizer.d.ts +8 -8
- package/package.json +1 -1
|
@@ -44,17 +44,33 @@ const varsResolver = core.createVarsResolver(
|
|
|
44
44
|
return {
|
|
45
45
|
root: {
|
|
46
46
|
"--split-resizer-size": core.getSize(size, "split-resizer-size"),
|
|
47
|
-
"--split-resizer-color
|
|
48
|
-
"--split-resizer-color-
|
|
49
|
-
|
|
47
|
+
"--split-resizer-color": core.rgba(colorLightParsed.value, Number(opacity)),
|
|
48
|
+
"--split-resizer-color-light": core.rgba(
|
|
49
|
+
colorLightParsed.value,
|
|
50
|
+
Number(opacity)
|
|
51
|
+
),
|
|
52
|
+
"--split-resizer-color-dark": core.rgba(
|
|
53
|
+
colorDarkParsed.value,
|
|
54
|
+
Number(opacity)
|
|
55
|
+
),
|
|
56
|
+
"--split-resizer-hover-color-light": core.rgba(
|
|
57
|
+
hoverColorLightParsed.value,
|
|
58
|
+
1
|
|
59
|
+
),
|
|
50
60
|
"--split-resizer-hover-color-dark": core.rgba(hoverColorDarkParsed.value, 1),
|
|
51
61
|
"--split-resizer-radius": core.getRadius(radius),
|
|
52
|
-
"--split-resizer-knob-size": core.getSize(
|
|
62
|
+
"--split-resizer-knob-size": core.getSize(
|
|
63
|
+
knobSize,
|
|
64
|
+
"split-resizer-knob-size"
|
|
65
|
+
),
|
|
53
66
|
"--split-resizer-knob-opacity": withKnob && knobAlwaysOn && !knobVariant ? knobOpacity : "0",
|
|
54
67
|
"--split-resizer-knob-hover-opacity": withKnob || knobVariant ? "1" : "0",
|
|
55
68
|
"--split-resizer-knob-radius": core.getRadius(knobRadius),
|
|
56
69
|
"--split-resizer-knob-color": core.getThemeColor(knobColor, theme),
|
|
57
|
-
"--split-resizer-knob-hover-color": core.getThemeColor(
|
|
70
|
+
"--split-resizer-knob-hover-color": core.getThemeColor(
|
|
71
|
+
knobHoverColor,
|
|
72
|
+
theme
|
|
73
|
+
),
|
|
58
74
|
"--split-resizer-spacing": core.getSize(spacing, "split-resizer-spacing"),
|
|
59
75
|
"--split-resizer-cursor-vertical": cursorVertical || "col-resize",
|
|
60
76
|
"--split-resizer-cursor-horizontal": cursorHorizontal || "row-resize"
|
|
@@ -82,178 +98,192 @@ const defaultProps = {
|
|
|
82
98
|
cursorVertical: "col-resize",
|
|
83
99
|
cursorHorizontal: "row-resize"
|
|
84
100
|
};
|
|
85
|
-
const SplitPaneResizer = core.factory(
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
event
|
|
139
|
-
event.stopPropagation();
|
|
140
|
-
document.body.style.userSelect = "none";
|
|
141
|
-
document.body.style.webkitUserSelect = "none";
|
|
142
|
-
if (event.type === "mousedown") {
|
|
143
|
-
document.addEventListener("mousemove", handleMove);
|
|
144
|
-
document.addEventListener("mouseup", handleMouseUp);
|
|
145
|
-
}
|
|
146
|
-
if (event.type === "touchstart") {
|
|
147
|
-
document.addEventListener("touchmove", handleMove);
|
|
148
|
-
document.addEventListener("touchend", handleTouchEnd);
|
|
149
|
-
}
|
|
150
|
-
onResizeStart?.();
|
|
151
|
-
document.body.style.cursor = "col-resize";
|
|
152
|
-
};
|
|
153
|
-
const handleMove = (event) => {
|
|
154
|
-
if (!paneRef.current)
|
|
155
|
-
return;
|
|
156
|
-
event.preventDefault();
|
|
157
|
-
event.stopPropagation();
|
|
158
|
-
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
|
-
if (orientation === "vertical") {
|
|
162
|
-
const margin = parseFloat(computedStyle.getPropertyValue("margin-left")) + 1;
|
|
163
|
-
const delta = clientX - paneRef.current.getBoundingClientRect().right - margin;
|
|
164
|
-
const width = paneRef.current.getBoundingClientRect().width + delta;
|
|
165
|
-
const widthString = `${width}px`;
|
|
166
|
-
if (minWidth && width < minWidth)
|
|
167
|
-
return;
|
|
168
|
-
if (maxWidth && width > maxWidth)
|
|
169
|
-
return;
|
|
170
|
-
onResizing?.({ width: widthString, height: paneRef.current.style.height });
|
|
171
|
-
paneRef.current.style.width = widthString;
|
|
172
|
-
} else {
|
|
173
|
-
const margin = parseFloat(computedStyle.getPropertyValue("margin-top")) + 1;
|
|
174
|
-
const delta = clientY - paneRef.current.getBoundingClientRect().bottom - margin;
|
|
175
|
-
const height = paneRef.current.getBoundingClientRect().height + delta;
|
|
176
|
-
const heightString = `${height}px`;
|
|
177
|
-
if (minHeight && height < minHeight)
|
|
178
|
-
return;
|
|
179
|
-
if (maxHeight && height > maxHeight)
|
|
180
|
-
return;
|
|
181
|
-
onResizing?.({ width: paneRef.current.style.width, height: heightString });
|
|
182
|
-
paneRef.current.style.height = heightString;
|
|
183
|
-
}
|
|
184
|
-
};
|
|
185
|
-
const handleMouseUp = () => {
|
|
186
|
-
if (!paneRef.current)
|
|
187
|
-
return;
|
|
188
|
-
document.body.style.userSelect = "initial";
|
|
189
|
-
document.body.style.webkitUserSelect = "initial";
|
|
190
|
-
document.removeEventListener("mousemove", handleMove);
|
|
191
|
-
document.removeEventListener("mouseup", handleMouseUp);
|
|
192
|
-
document.body.style.cursor = "initial";
|
|
193
|
-
const { width, height } = paneRef.current.style || {};
|
|
194
|
-
onResizeEnd?.({ width, height });
|
|
195
|
-
};
|
|
196
|
-
const handleTouchEnd = () => {
|
|
197
|
-
if (!paneRef.current)
|
|
198
|
-
return;
|
|
199
|
-
document.removeEventListener("touchmove", handleMove);
|
|
200
|
-
document.removeEventListener("touchend", handleTouchEnd);
|
|
201
|
-
document.body.style.cursor = "initial";
|
|
202
|
-
const { width, height } = paneRef.current.style || {};
|
|
203
|
-
onResizeEnd?.({ width, height });
|
|
204
|
-
};
|
|
205
|
-
const handleKeyUp = (event) => {
|
|
206
|
-
if (containerRef.current !== document.activeElement) {
|
|
207
|
-
return;
|
|
208
|
-
}
|
|
209
|
-
const delta = event.shiftKey ? shiftStep : step;
|
|
210
|
-
if (orientation === "vertical" && (event.nativeEvent.code === "ArrowRight" || event.nativeEvent.code === "ArrowLeft")) {
|
|
101
|
+
const SplitPaneResizer = core.factory(
|
|
102
|
+
(_props, ref) => {
|
|
103
|
+
const props = core.useProps("Resizer", defaultProps, _props);
|
|
104
|
+
const {
|
|
105
|
+
size,
|
|
106
|
+
opacity,
|
|
107
|
+
radius,
|
|
108
|
+
color,
|
|
109
|
+
hoverColor,
|
|
110
|
+
knobSize,
|
|
111
|
+
knobOpacity,
|
|
112
|
+
knobRadius,
|
|
113
|
+
knobColor,
|
|
114
|
+
knobHoverColor,
|
|
115
|
+
minWidth,
|
|
116
|
+
minHeight,
|
|
117
|
+
maxWidth,
|
|
118
|
+
maxHeight,
|
|
119
|
+
orientation,
|
|
120
|
+
onResizeStart,
|
|
121
|
+
onResizing,
|
|
122
|
+
onResizeEnd,
|
|
123
|
+
paneRef,
|
|
124
|
+
variant,
|
|
125
|
+
withKnob,
|
|
126
|
+
knobAlwaysOn,
|
|
127
|
+
spacing,
|
|
128
|
+
step,
|
|
129
|
+
shiftStep,
|
|
130
|
+
cursorVertical,
|
|
131
|
+
cursorHorizontal,
|
|
132
|
+
className,
|
|
133
|
+
style,
|
|
134
|
+
classNames,
|
|
135
|
+
styles,
|
|
136
|
+
unstyled,
|
|
137
|
+
vars,
|
|
138
|
+
mod,
|
|
139
|
+
...others
|
|
140
|
+
} = props;
|
|
141
|
+
const getStyles = core.useStyles({
|
|
142
|
+
name: "SplitPaneResizer",
|
|
143
|
+
classes: SplitPaneResizer_module,
|
|
144
|
+
props,
|
|
145
|
+
className,
|
|
146
|
+
style,
|
|
147
|
+
classNames,
|
|
148
|
+
styles,
|
|
149
|
+
unstyled,
|
|
150
|
+
vars,
|
|
151
|
+
varsResolver
|
|
152
|
+
});
|
|
153
|
+
const containerRef = React.useRef(null);
|
|
154
|
+
const handleStart = (event) => {
|
|
211
155
|
event.preventDefault();
|
|
212
156
|
event.stopPropagation();
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
157
|
+
document.body.style.userSelect = "none";
|
|
158
|
+
document.body.style.webkitUserSelect = "none";
|
|
159
|
+
if (event.type === "mousedown") {
|
|
160
|
+
document.addEventListener("mousemove", handleMove);
|
|
161
|
+
document.addEventListener("mouseup", handleMouseUp);
|
|
162
|
+
}
|
|
163
|
+
if (event.type === "touchstart") {
|
|
164
|
+
document.addEventListener("touchmove", handleMove);
|
|
165
|
+
document.addEventListener("touchend", handleTouchEnd);
|
|
166
|
+
}
|
|
167
|
+
onResizeStart?.();
|
|
168
|
+
document.body.style.cursor = "col-resize";
|
|
169
|
+
};
|
|
170
|
+
const handleMove = (event) => {
|
|
171
|
+
if (!paneRef.current)
|
|
219
172
|
return;
|
|
220
|
-
onResizing?.({ width: widthString, height: paneRef.current.style.height });
|
|
221
|
-
paneRef.current.style.width = widthString;
|
|
222
|
-
}
|
|
223
|
-
if (orientation === "horizontal" && (event.nativeEvent.code === "ArrowUp" || event.nativeEvent.code === "ArrowDown")) {
|
|
224
173
|
event.preventDefault();
|
|
225
174
|
event.stopPropagation();
|
|
226
|
-
const
|
|
227
|
-
const
|
|
228
|
-
const
|
|
229
|
-
if (
|
|
175
|
+
const computedStyle = window.getComputedStyle(containerRef.current);
|
|
176
|
+
const clientX = "clientX" in event ? event.clientX : event.touches[0].clientX;
|
|
177
|
+
const clientY = "clientY" in event ? event.clientY : event.touches[0].clientY;
|
|
178
|
+
if (orientation === "vertical") {
|
|
179
|
+
const margin = parseFloat(computedStyle.getPropertyValue("margin-left")) + 1;
|
|
180
|
+
const delta = clientX - paneRef.current.getBoundingClientRect().right - margin;
|
|
181
|
+
const width = paneRef.current.getBoundingClientRect().width + delta;
|
|
182
|
+
const widthString = `${width}px`;
|
|
183
|
+
if (minWidth && width < minWidth)
|
|
184
|
+
return;
|
|
185
|
+
if (maxWidth && width > maxWidth)
|
|
186
|
+
return;
|
|
187
|
+
onResizing?.({
|
|
188
|
+
width: widthString,
|
|
189
|
+
height: paneRef.current.style.height
|
|
190
|
+
});
|
|
191
|
+
paneRef.current.style.width = widthString;
|
|
192
|
+
} else {
|
|
193
|
+
const margin = parseFloat(computedStyle.getPropertyValue("margin-top")) + 1;
|
|
194
|
+
const delta = clientY - paneRef.current.getBoundingClientRect().bottom - margin;
|
|
195
|
+
const height = paneRef.current.getBoundingClientRect().height + delta;
|
|
196
|
+
const heightString = `${height}px`;
|
|
197
|
+
if (minHeight && height < minHeight)
|
|
198
|
+
return;
|
|
199
|
+
if (maxHeight && height > maxHeight)
|
|
200
|
+
return;
|
|
201
|
+
onResizing?.({
|
|
202
|
+
width: paneRef.current.style.width,
|
|
203
|
+
height: heightString
|
|
204
|
+
});
|
|
205
|
+
paneRef.current.style.height = heightString;
|
|
206
|
+
}
|
|
207
|
+
};
|
|
208
|
+
const handleMouseUp = () => {
|
|
209
|
+
if (!paneRef.current)
|
|
230
210
|
return;
|
|
231
|
-
|
|
211
|
+
document.body.style.userSelect = "initial";
|
|
212
|
+
document.body.style.webkitUserSelect = "initial";
|
|
213
|
+
document.removeEventListener("mousemove", handleMove);
|
|
214
|
+
document.removeEventListener("mouseup", handleMouseUp);
|
|
215
|
+
document.body.style.cursor = "initial";
|
|
216
|
+
const { width, height } = paneRef.current.style || {};
|
|
217
|
+
onResizeEnd?.({ width, height });
|
|
218
|
+
};
|
|
219
|
+
const handleTouchEnd = () => {
|
|
220
|
+
if (!paneRef.current)
|
|
232
221
|
return;
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
222
|
+
document.removeEventListener("touchmove", handleMove);
|
|
223
|
+
document.removeEventListener("touchend", handleTouchEnd);
|
|
224
|
+
document.body.style.cursor = "initial";
|
|
225
|
+
const { width, height } = paneRef.current.style || {};
|
|
226
|
+
onResizeEnd?.({ width, height });
|
|
227
|
+
};
|
|
228
|
+
const handleKeyUp = (event) => {
|
|
229
|
+
if (containerRef.current !== document.activeElement) {
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
const delta = event.shiftKey ? shiftStep : step;
|
|
233
|
+
if (orientation === "vertical" && (event.nativeEvent.code === "ArrowRight" || event.nativeEvent.code === "ArrowLeft")) {
|
|
234
|
+
event.preventDefault();
|
|
235
|
+
event.stopPropagation();
|
|
236
|
+
const deltaSign = event.nativeEvent.code === "ArrowRight" ? 1 : -1;
|
|
237
|
+
const width = paneRef.current.getBoundingClientRect().width + delta * deltaSign;
|
|
238
|
+
const widthString = `${width}px`;
|
|
239
|
+
if (minWidth && width < minWidth)
|
|
240
|
+
return;
|
|
241
|
+
if (maxWidth && width > maxWidth)
|
|
242
|
+
return;
|
|
243
|
+
onResizing?.({
|
|
244
|
+
width: widthString,
|
|
245
|
+
height: paneRef.current.style.height
|
|
246
|
+
});
|
|
247
|
+
paneRef.current.style.width = widthString;
|
|
248
|
+
}
|
|
249
|
+
if (orientation === "horizontal" && (event.nativeEvent.code === "ArrowUp" || event.nativeEvent.code === "ArrowDown")) {
|
|
250
|
+
event.preventDefault();
|
|
251
|
+
event.stopPropagation();
|
|
252
|
+
const deltaSign = event.nativeEvent.code === "ArrowDown" ? 1 : -1;
|
|
253
|
+
const height = paneRef.current.getBoundingClientRect().height + delta * deltaSign;
|
|
254
|
+
const heightString = `${height}px`;
|
|
255
|
+
if (minHeight && height < minHeight)
|
|
256
|
+
return;
|
|
257
|
+
if (maxHeight && height > maxHeight)
|
|
258
|
+
return;
|
|
259
|
+
onResizing?.({
|
|
260
|
+
width: paneRef.current.style.width,
|
|
261
|
+
height: heightString
|
|
262
|
+
});
|
|
263
|
+
paneRef.current.style.height = heightString;
|
|
264
|
+
}
|
|
265
|
+
if (event.nativeEvent.code === "Escape") {
|
|
266
|
+
event.preventDefault();
|
|
267
|
+
event.stopPropagation();
|
|
268
|
+
containerRef.current.blur();
|
|
269
|
+
}
|
|
270
|
+
};
|
|
271
|
+
return /* @__PURE__ */ React.createElement(
|
|
272
|
+
core.UnstyledButton,
|
|
273
|
+
{
|
|
274
|
+
onDoubleClick: props?.onDoubleClick,
|
|
275
|
+
ref: containerRef,
|
|
276
|
+
mod: { orientation },
|
|
277
|
+
onMouseDown: handleStart,
|
|
278
|
+
onKeyDown: handleKeyUp,
|
|
279
|
+
onTouchStart: handleStart,
|
|
280
|
+
"aria-label": "Resize",
|
|
281
|
+
...getStyles("root", { variant }),
|
|
282
|
+
...others
|
|
283
|
+
}
|
|
284
|
+
);
|
|
285
|
+
}
|
|
286
|
+
);
|
|
257
287
|
SplitPaneResizer.classes = SplitPaneResizer_module;
|
|
258
288
|
SplitPaneResizer.displayName = "SplitPaneResizer";
|
|
259
289
|
|