@forgeax/app-shell 0.6.1 → 0.7.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/dist/react.d.ts +5 -1
- package/dist/react.js +28 -12
- package/package.json +1 -1
package/dist/react.d.ts
CHANGED
|
@@ -12,9 +12,13 @@ declare function useLocalSize(key: string, initial: number, min: number, max: nu
|
|
|
12
12
|
interface ResizeHandleProps {
|
|
13
13
|
orientation: 'col' | 'row';
|
|
14
14
|
onDrag: (delta: number) => void;
|
|
15
|
+
onDragStart?: () => void;
|
|
16
|
+
onDragEnd?: () => void;
|
|
17
|
+
className?: string;
|
|
18
|
+
ariaLabel?: string;
|
|
15
19
|
title?: string;
|
|
16
20
|
}
|
|
17
|
-
declare function ResizeHandle({ orientation, onDrag, title }: ResizeHandleProps): react.JSX.Element;
|
|
21
|
+
declare function ResizeHandle({ orientation, onDrag, onDragStart, onDragEnd, className, ariaLabel, title, }: ResizeHandleProps): react.JSX.Element;
|
|
18
22
|
|
|
19
23
|
type ShellSlotElement = 'aside' | 'div' | 'main' | 'section';
|
|
20
24
|
interface ShellSlotProps extends HTMLAttributes<HTMLElement> {
|
package/dist/react.js
CHANGED
|
@@ -192,49 +192,65 @@ function useLocalSize(key, initial, min, max) {
|
|
|
192
192
|
};
|
|
193
193
|
return [value, setValue];
|
|
194
194
|
}
|
|
195
|
-
function ResizeHandle({
|
|
195
|
+
function ResizeHandle({
|
|
196
|
+
orientation,
|
|
197
|
+
onDrag,
|
|
198
|
+
onDragStart,
|
|
199
|
+
onDragEnd,
|
|
200
|
+
className,
|
|
201
|
+
ariaLabel,
|
|
202
|
+
title
|
|
203
|
+
}) {
|
|
196
204
|
const startRef = useRef(null);
|
|
205
|
+
const onDragEndRef = useRef(onDragEnd);
|
|
206
|
+
onDragEndRef.current = onDragEnd;
|
|
197
207
|
const resetGlobalDragStyles = () => {
|
|
198
208
|
document.body.style.cursor = "";
|
|
199
209
|
document.body.style.userSelect = "";
|
|
200
210
|
};
|
|
201
|
-
|
|
202
|
-
if (startRef.current)
|
|
203
|
-
|
|
211
|
+
const finishDrag = () => {
|
|
212
|
+
if (!startRef.current) return;
|
|
213
|
+
startRef.current = null;
|
|
214
|
+
resetGlobalDragStyles();
|
|
215
|
+
onDragEndRef.current?.();
|
|
216
|
+
};
|
|
217
|
+
useEffect2(() => finishDrag, []);
|
|
204
218
|
const onPointerDown = (event) => {
|
|
219
|
+
if (startRef.current) return;
|
|
205
220
|
event.preventDefault();
|
|
206
221
|
event.currentTarget.setPointerCapture(event.pointerId);
|
|
207
|
-
startRef.current = { x: event.clientX, y: event.clientY };
|
|
222
|
+
startRef.current = { pointerId: event.pointerId, x: event.clientX, y: event.clientY };
|
|
208
223
|
document.body.style.cursor = orientation === "col" ? "col-resize" : "row-resize";
|
|
209
224
|
document.body.style.userSelect = "none";
|
|
225
|
+
onDragStart?.();
|
|
210
226
|
};
|
|
211
227
|
const onPointerMove = (event) => {
|
|
212
|
-
if (!startRef.current) return;
|
|
228
|
+
if (!startRef.current || startRef.current.pointerId !== event.pointerId) return;
|
|
213
229
|
const deltaX = event.clientX - startRef.current.x;
|
|
214
230
|
const deltaY = event.clientY - startRef.current.y;
|
|
215
|
-
startRef.current = { x: event.clientX, y: event.clientY };
|
|
231
|
+
startRef.current = { pointerId: event.pointerId, x: event.clientX, y: event.clientY };
|
|
216
232
|
onDrag(orientation === "col" ? deltaX : deltaY);
|
|
217
233
|
};
|
|
218
234
|
const finish = (event) => {
|
|
219
|
-
if (!startRef.current) return;
|
|
220
|
-
startRef.current = null;
|
|
235
|
+
if (!startRef.current || startRef.current.pointerId !== event.pointerId) return;
|
|
221
236
|
try {
|
|
222
237
|
event.currentTarget.releasePointerCapture(event.pointerId);
|
|
223
238
|
} catch {
|
|
224
239
|
}
|
|
225
|
-
|
|
240
|
+
finishDrag();
|
|
226
241
|
};
|
|
227
242
|
return /* @__PURE__ */ jsx2(
|
|
228
243
|
"div",
|
|
229
244
|
{
|
|
230
|
-
className: `resize-handle resize-handle-${orientation}`,
|
|
245
|
+
className: `resize-handle resize-handle-${orientation}${className ? ` ${className}` : ""}`,
|
|
231
246
|
onPointerDown,
|
|
232
247
|
onPointerMove,
|
|
233
248
|
onPointerUp: finish,
|
|
234
249
|
onPointerCancel: finish,
|
|
235
250
|
title,
|
|
236
251
|
role: "separator",
|
|
237
|
-
"aria-orientation": orientation === "col" ? "vertical" : "horizontal"
|
|
252
|
+
"aria-orientation": orientation === "col" ? "vertical" : "horizontal",
|
|
253
|
+
"aria-label": ariaLabel
|
|
238
254
|
}
|
|
239
255
|
);
|
|
240
256
|
}
|