@tcn/ui 0.1.1 → 0.2.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 +38 -3
- package/dist/draggable.css +1 -0
- package/dist/feedback/progress/progress_bar.js +1 -1
- package/dist/form/field/common/field_description.js +1 -1
- package/dist/form/field/common/field_error.js +1 -1
- package/dist/form/field/common/field_label.js +1 -1
- package/dist/inputs/date_picker/date_picker_date.js +1 -1
- package/dist/inputs/date_picker/date_picker_day.js +1 -1
- package/dist/inputs/date_picker/date_picker_time_selector.js +1 -1
- package/dist/inputs/date_picker/date_picker_year_selector.js +1 -1
- package/dist/inputs/phone_number_input/phone_number_input.d.ts +2 -0
- package/dist/inputs/phone_number_input/phone_number_input.d.ts.map +1 -1
- package/dist/inputs/phone_number_input/phone_number_input.js +159 -153
- package/dist/inputs/phone_number_input/phone_number_input.js.map +1 -1
- package/dist/inputs/suggestions/suggestion_list.js +1 -1
- package/dist/inputs/textarea/textarea.d.ts +2 -2
- package/dist/inputs/textarea/textarea.d.ts.map +1 -1
- package/dist/inputs/textarea/textarea.js.map +1 -1
- package/dist/layouts/header/header.d.ts.map +1 -1
- package/dist/layouts/header/header.js.map +1 -1
- package/dist/overlay/frame/frame.d.ts +11 -0
- package/dist/overlay/frame/frame.d.ts.map +1 -0
- package/dist/overlay/frame/frame.js +18 -0
- package/dist/overlay/frame/frame.js.map +1 -0
- package/dist/overlay/index.d.ts +1 -0
- package/dist/overlay/index.d.ts.map +1 -1
- package/dist/overlay/index.js +4 -2
- package/dist/overlay/index.js.map +1 -1
- package/dist/stacks/box/box.d.ts +1 -1
- package/dist/stacks/box/box.d.ts.map +1 -1
- package/dist/stacks/box/box.js.map +1 -1
- package/dist/surfaces/index.d.ts +2 -2
- package/dist/surfaces/index.d.ts.map +1 -1
- package/dist/surfaces/index.js +22 -22
- package/dist/surfaces/modal/modal.d.ts +3 -2
- package/dist/surfaces/modal/modal.d.ts.map +1 -1
- package/dist/surfaces/modal/modal.js +14 -13
- package/dist/surfaces/modal/modal.js.map +1 -1
- package/dist/surfaces/window/window.d.ts +3 -2
- package/dist/surfaces/window/window.d.ts.map +1 -1
- package/dist/surfaces/window/window.js +17 -7
- package/dist/surfaces/window/window.js.map +1 -1
- package/dist/themes/themes/ergo/ergo_theme.js +69 -0
- package/dist/themes/themes/ergo/ergo_theme.js.map +1 -1
- package/dist/typography/title/title.d.ts +2 -1
- package/dist/typography/title/title.d.ts.map +1 -1
- package/dist/typography/title/title.js +23 -22
- package/dist/typography/title/title.js.map +1 -1
- package/dist/utils/dnd/context.d.ts +4 -0
- package/dist/utils/dnd/context.d.ts.map +1 -0
- package/dist/utils/dnd/context.js +20 -0
- package/dist/utils/dnd/context.js.map +1 -0
- package/dist/utils/dnd/draggable/draggable.d.ts +7 -0
- package/dist/utils/dnd/draggable/draggable.d.ts.map +1 -0
- package/dist/utils/dnd/draggable/draggable.js +27 -0
- package/dist/utils/dnd/draggable/draggable.js.map +1 -0
- package/dist/utils/dnd/handle.d.ts +6 -0
- package/dist/utils/dnd/handle.d.ts.map +1 -0
- package/dist/utils/dnd/handle.js +22 -0
- package/dist/utils/dnd/handle.js.map +1 -0
- package/dist/utils/dnd/hooks/use_drag_container.d.ts +7 -0
- package/dist/utils/dnd/hooks/use_drag_container.d.ts.map +1 -0
- package/dist/utils/dnd/hooks/use_drag_container.js +30 -0
- package/dist/utils/dnd/hooks/use_drag_container.js.map +1 -0
- package/dist/utils/{hooks → dnd/hooks}/use_draggable.d.ts +3 -3
- package/dist/utils/dnd/hooks/use_draggable.d.ts.map +1 -0
- package/dist/utils/dnd/hooks/use_draggable.js +41 -0
- package/dist/utils/dnd/hooks/use_draggable.js.map +1 -0
- package/dist/utils/dnd/types.d.ts +10 -0
- package/dist/utils/dnd/types.d.ts.map +1 -0
- package/dist/utils/dnd/types.js +2 -0
- package/dist/utils/dnd/types.js.map +1 -0
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +1 -1
- package/package.json +9 -3
- package/src/inputs/phone_number_input/phone_number_input.tsx +8 -0
- package/src/inputs/textarea/textarea.tsx +2 -2
- package/src/layouts/header/header.tsx +0 -1
- package/src/overlay/frame/frame.stories.tsx +40 -0
- package/src/overlay/frame/frame.tsx +34 -0
- package/src/overlay/frame/frame_stories.module.css +14 -0
- package/src/overlay/index.ts +1 -0
- package/src/stacks/box/box.tsx +8 -2
- package/src/surfaces/index.ts +2 -2
- package/src/surfaces/modal/__stories__/modal.stories.tsx +19 -27
- package/src/surfaces/modal/modal.tsx +13 -10
- package/src/surfaces/window/window.stories.tsx +37 -4
- package/src/surfaces/window/window.tsx +14 -6
- package/src/themes/themes/ergo/ergo_theme.css +69 -0
- package/src/typography/title/title.tsx +22 -18
- package/src/utils/dnd/__stories__/draggable.stories.tsx +48 -0
- package/src/utils/dnd/__stories__/draggable_stories.module.css +21 -0
- package/src/utils/{__stories__ → dnd/__stories__}/use_draggable.stories.tsx +15 -10
- package/src/utils/dnd/context.ts +24 -0
- package/src/utils/dnd/draggable/draggable.module.css +8 -0
- package/src/utils/dnd/draggable/draggable.tsx +42 -0
- package/src/utils/dnd/handle.tsx +32 -0
- package/src/utils/dnd/hooks/use_drag_container.ts +42 -0
- package/src/utils/{hooks → dnd/hooks}/use_draggable.ts +23 -17
- package/src/utils/dnd/types.ts +6 -0
- package/src/utils/index.ts +1 -1
- package/dist/title.module-B16de2jd.js +0 -5
- package/dist/title.module-B16de2jd.js.map +0 -1
- package/dist/utils/hooks/use_draggable.d.ts.map +0 -1
- package/dist/utils/hooks/use_draggable.js +0 -30
- package/dist/utils/hooks/use_draggable.js.map +0 -1
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { createContext, useContext } from 'react';
|
|
2
|
+
import type { DragContainer } from './types.js';
|
|
3
|
+
|
|
4
|
+
const defaultValue: DragContainer = {
|
|
5
|
+
registerHandle: () => {},
|
|
6
|
+
unregisterHandle: () => {},
|
|
7
|
+
isDragging: false,
|
|
8
|
+
position: { x: 0, y: 0 },
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const DragContainerContext = createContext<DragContainer>(defaultValue);
|
|
12
|
+
|
|
13
|
+
export function useDragContainer(): DragContainer {
|
|
14
|
+
const context = useContext(DragContainerContext);
|
|
15
|
+
|
|
16
|
+
if (context === defaultValue) {
|
|
17
|
+
// biome-ignore lint/suspicious/noConsole: Let devs know if they're not using the context correctly
|
|
18
|
+
console.warn(
|
|
19
|
+
'useDragContainer: No DragContainerContext found. Handles may will not register or trigger drag events.'
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return context;
|
|
24
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import React, { useMemo, type CSSProperties } from 'react';
|
|
2
|
+
|
|
3
|
+
import { DragContainerContext } from '../context.js';
|
|
4
|
+
import clsx from 'clsx';
|
|
5
|
+
import { useMakeDragContainer } from '../hooks/use_drag_container.js';
|
|
6
|
+
|
|
7
|
+
import styles from './draggable.module.css';
|
|
8
|
+
|
|
9
|
+
export interface DraggableProps {
|
|
10
|
+
children: React.ReactElement;
|
|
11
|
+
draggable?: boolean;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const Draggable: React.FC<DraggableProps> = ({
|
|
15
|
+
children,
|
|
16
|
+
draggable: isDraggable = true,
|
|
17
|
+
}) => {
|
|
18
|
+
const context = useMakeDragContainer({});
|
|
19
|
+
|
|
20
|
+
const cssVariables = useMemo(
|
|
21
|
+
() =>
|
|
22
|
+
({
|
|
23
|
+
'--position-x': `${context.position.x}px`,
|
|
24
|
+
'--position-y': `${context.position.y}px`,
|
|
25
|
+
}) as CSSProperties,
|
|
26
|
+
|
|
27
|
+
[context.position]
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
const clonedChildren = React.cloneElement(children, {
|
|
31
|
+
className: clsx('tcn-draggable', styles.draggable, children.props.className),
|
|
32
|
+
style: { ...cssVariables, ...children.props.style },
|
|
33
|
+
'data-is-dragging': context.isDragging,
|
|
34
|
+
'data-is-draggable': isDraggable,
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<DragContainerContext.Provider value={context}>
|
|
39
|
+
{clonedChildren}
|
|
40
|
+
</DragContainerContext.Provider>
|
|
41
|
+
);
|
|
42
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React, { useEffect, useRef } from 'react';
|
|
2
|
+
import clsx from 'clsx';
|
|
3
|
+
import { useDragContainer } from './context.js';
|
|
4
|
+
import { useForkRef } from '../hooks/use_fork_ref.js';
|
|
5
|
+
|
|
6
|
+
export interface DragHandleProps {
|
|
7
|
+
children: React.ReactElement;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const DragHandle: React.FC<DragHandleProps> = ({ children }) => {
|
|
11
|
+
const { registerHandle, unregisterHandle } = useDragContainer();
|
|
12
|
+
const ref = useRef<HTMLElement | null>(null);
|
|
13
|
+
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
if (ref.current == null) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
registerHandle(ref);
|
|
19
|
+
return () => {
|
|
20
|
+
if (ref.current == null) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
unregisterHandle(ref);
|
|
24
|
+
};
|
|
25
|
+
}, [registerHandle, unregisterHandle]);
|
|
26
|
+
|
|
27
|
+
const mergedRef = useForkRef(ref, children.props.ref);
|
|
28
|
+
return React.cloneElement(children, {
|
|
29
|
+
className: clsx('tcn-drag-handle', children.props.className),
|
|
30
|
+
ref: mergedRef,
|
|
31
|
+
});
|
|
32
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { useCallback, useRef, useState } from 'react';
|
|
2
|
+
import { useDraggable } from './use_draggable.js';
|
|
3
|
+
import type { Position } from '../../index.js';
|
|
4
|
+
import type { DragContainer } from '../types.js';
|
|
5
|
+
|
|
6
|
+
export interface UseDragContainerOptions {
|
|
7
|
+
initialPosition?: Position;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function useMakeDragContainer(options: UseDragContainerOptions): DragContainer {
|
|
11
|
+
const [handles, setHandles] = useState<React.RefObject<HTMLElement>[]>([]);
|
|
12
|
+
const positionRef = useRef<Position>(options.initialPosition ?? { x: 0, y: 0 });
|
|
13
|
+
const [position, setPosition] = useState(positionRef.current);
|
|
14
|
+
const [isDragging, setIsDragging] = useState(false);
|
|
15
|
+
|
|
16
|
+
useDraggable({
|
|
17
|
+
handles: handles,
|
|
18
|
+
startDragCallback: () => {
|
|
19
|
+
setIsDragging(true);
|
|
20
|
+
},
|
|
21
|
+
dragCallback: (deltaX, deltaY) => {
|
|
22
|
+
setPosition({
|
|
23
|
+
x: positionRef.current.x + deltaX,
|
|
24
|
+
y: positionRef.current.y + deltaY,
|
|
25
|
+
});
|
|
26
|
+
},
|
|
27
|
+
endDragCallback: () => {
|
|
28
|
+
setIsDragging(false);
|
|
29
|
+
positionRef.current = position;
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
const registerHandle = useCallback((handle: React.RefObject<HTMLElement>) => {
|
|
34
|
+
setHandles(prev => [...prev, handle]);
|
|
35
|
+
}, []);
|
|
36
|
+
|
|
37
|
+
const unregisterHandle = useCallback((handle: React.RefObject<HTMLElement>) => {
|
|
38
|
+
setHandles(prev => prev.filter(h => h !== handle));
|
|
39
|
+
}, []);
|
|
40
|
+
|
|
41
|
+
return { registerHandle, unregisterHandle, position, isDragging };
|
|
42
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useEffect, useRef } from 'react';
|
|
2
2
|
|
|
3
|
-
interface
|
|
3
|
+
export interface UseDraggableOptions {
|
|
4
4
|
startDragCallback: (startX: number, startY: number) => void;
|
|
5
5
|
dragCallback: (deltaX: number, deltaY: number, startX: number, startY: number) => void;
|
|
6
6
|
endDragCallback: (
|
|
@@ -9,16 +9,10 @@ interface DraggableOptions {
|
|
|
9
9
|
startX: number,
|
|
10
10
|
startY: number
|
|
11
11
|
) => void;
|
|
12
|
+
handles?: React.RefObject<HTMLElement>[] | React.RefObject<HTMLElement>;
|
|
12
13
|
}
|
|
13
14
|
|
|
14
|
-
|
|
15
|
-
// (startX: number, startY: number) => {},
|
|
16
|
-
// (deltaX: number, deltaY: number, startX: number, startY: number) => {},
|
|
17
|
-
// (deltaX: number, deltaY: number, startX: number, startY: number) => {}
|
|
18
|
-
// );
|
|
19
|
-
|
|
20
|
-
export function useDraggable(options: DraggableOptions) {
|
|
21
|
-
const ref = useRef<HTMLElement | null>(null);
|
|
15
|
+
export function useDraggable(options: UseDraggableOptions) {
|
|
22
16
|
const startDragCallbackRef = useRef(options.startDragCallback);
|
|
23
17
|
startDragCallbackRef.current = options.startDragCallback;
|
|
24
18
|
const dragCallbackRef = useRef(options.dragCallback);
|
|
@@ -27,7 +21,8 @@ export function useDraggable(options: DraggableOptions) {
|
|
|
27
21
|
endDragCallbackRef.current = options.endDragCallback;
|
|
28
22
|
|
|
29
23
|
useEffect(() => {
|
|
30
|
-
const
|
|
24
|
+
const handles = options.handles;
|
|
25
|
+
if (handles === undefined) return;
|
|
31
26
|
let startX = 0;
|
|
32
27
|
let startY = 0;
|
|
33
28
|
|
|
@@ -58,17 +53,28 @@ export function useDraggable(options: DraggableOptions) {
|
|
|
58
53
|
document.body.addEventListener('mouseleave', endDrag);
|
|
59
54
|
}
|
|
60
55
|
|
|
61
|
-
if (
|
|
62
|
-
|
|
56
|
+
if (Array.isArray(handles)) {
|
|
57
|
+
for (const element of handles) {
|
|
58
|
+
if (element != null) {
|
|
59
|
+
element.current?.addEventListener('mousedown', startDrag);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
} else {
|
|
63
|
+
handles?.current?.addEventListener('mousedown', startDrag);
|
|
63
64
|
}
|
|
64
|
-
|
|
65
65
|
return () => {
|
|
66
|
-
|
|
66
|
+
if (Array.isArray(handles)) {
|
|
67
|
+
for (const element of handles) {
|
|
68
|
+
if (element != null) {
|
|
69
|
+
element.current?.removeEventListener('mousedown', startDrag);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
} else {
|
|
73
|
+
handles?.current?.removeEventListener('mousedown', startDrag);
|
|
74
|
+
}
|
|
67
75
|
document.body.removeEventListener('mousemove', drag);
|
|
68
76
|
document.body.removeEventListener('mouseup', endDrag);
|
|
69
77
|
document.body.removeEventListener('mouseleave', endDrag);
|
|
70
78
|
};
|
|
71
|
-
}, []);
|
|
72
|
-
|
|
73
|
-
return ref;
|
|
79
|
+
}, [options.handles]);
|
|
74
80
|
}
|
package/src/utils/index.ts
CHANGED
|
@@ -3,7 +3,7 @@ export * from './click_away_listener.js';
|
|
|
3
3
|
export * from './scroll_away_listener.js';
|
|
4
4
|
|
|
5
5
|
export * from './hooks/make_context_hook.js';
|
|
6
|
-
export * from './hooks/use_draggable.js';
|
|
6
|
+
export * from './dnd/hooks/use_draggable.js';
|
|
7
7
|
export * from './hooks/use_fork_ref.js';
|
|
8
8
|
export * from './hooks/use_media_query.js';
|
|
9
9
|
export * from './hooks/use_resize_observer.js';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"title.module-B16de2jd.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"use_draggable.d.ts","sourceRoot":"","sources":["../../../src/utils/hooks/use_draggable.ts"],"names":[],"mappings":"AAEA,UAAU,gBAAgB;IACxB,iBAAiB,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5D,YAAY,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACvF,eAAe,EAAE,CACf,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,KACX,IAAI,CAAC;CACX;AAQD,wBAAgB,YAAY,CAAC,OAAO,EAAE,gBAAgB,wDAsDrD"}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { useRef as o, useEffect as g } from "react";
|
|
2
|
-
function E(t) {
|
|
3
|
-
const s = o(null), m = o(t.startDragCallback);
|
|
4
|
-
m.current = t.startDragCallback;
|
|
5
|
-
const i = o(t.dragCallback);
|
|
6
|
-
i.current = t.dragCallback;
|
|
7
|
-
const v = o(t.endDragCallback);
|
|
8
|
-
return v.current = t.endDragCallback, g(() => {
|
|
9
|
-
const c = s.current;
|
|
10
|
-
let n = 0, r = 0;
|
|
11
|
-
function d(e) {
|
|
12
|
-
const l = e.clientX - n, u = e.clientY - r;
|
|
13
|
-
i.current(l, u, n, r);
|
|
14
|
-
}
|
|
15
|
-
function a(e) {
|
|
16
|
-
const l = e.clientX !== void 0 ? e.clientX - n : 0, u = e.clientY !== void 0 ? e.clientY - r : 0;
|
|
17
|
-
v.current(l, u, n, r), document.body.removeEventListener("mousemove", d), document.body.removeEventListener("mouseup", a), document.body.removeEventListener("mouseleave", a);
|
|
18
|
-
}
|
|
19
|
-
function b(e) {
|
|
20
|
-
n = e.clientX, r = e.clientY, m.current(n, r), document.body.addEventListener("mousemove", d), document.body.addEventListener("mouseup", a), document.body.addEventListener("mouseleave", a);
|
|
21
|
-
}
|
|
22
|
-
return c?.addEventListener("mousedown", b), () => {
|
|
23
|
-
c?.removeEventListener("mousedown", b), document.body.removeEventListener("mousemove", d), document.body.removeEventListener("mouseup", a), document.body.removeEventListener("mouseleave", a);
|
|
24
|
-
};
|
|
25
|
-
}, []), s;
|
|
26
|
-
}
|
|
27
|
-
export {
|
|
28
|
-
E as useDraggable
|
|
29
|
-
};
|
|
30
|
-
//# sourceMappingURL=use_draggable.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"use_draggable.js","sources":["../../../src/utils/hooks/use_draggable.ts"],"sourcesContent":["import { useEffect, useRef } from 'react';\n\ninterface DraggableOptions {\n startDragCallback: (startX: number, startY: number) => void;\n dragCallback: (deltaX: number, deltaY: number, startX: number, startY: number) => void;\n endDragCallback: (\n deltaX: number,\n deltaY: number,\n startX: number,\n startY: number\n ) => void;\n}\n\n// const handleRef: Ref<HTMLElement> = useDraggable(\n// (startX: number, startY: number) => {},\n// (deltaX: number, deltaY: number, startX: number, startY: number) => {},\n// (deltaX: number, deltaY: number, startX: number, startY: number) => {}\n// );\n\nexport function useDraggable(options: DraggableOptions) {\n const ref = useRef<HTMLElement | null>(null);\n const startDragCallbackRef = useRef(options.startDragCallback);\n startDragCallbackRef.current = options.startDragCallback;\n const dragCallbackRef = useRef(options.dragCallback);\n dragCallbackRef.current = options.dragCallback;\n const endDragCallbackRef = useRef(options.endDragCallback);\n endDragCallbackRef.current = options.endDragCallback;\n\n useEffect(() => {\n const element = ref.current;\n let startX = 0;\n let startY = 0;\n\n function drag(event: MouseEvent) {\n const deltaX = event.clientX - startX;\n const deltaY = event.clientY - startY;\n\n dragCallbackRef.current(deltaX, deltaY, startX, startY);\n }\n\n function endDrag(event: MouseEvent) {\n const deltaX = event.clientX !== undefined ? event.clientX - startX : 0;\n const deltaY = event.clientY !== undefined ? event.clientY - startY : 0;\n endDragCallbackRef.current(deltaX, deltaY, startX, startY);\n document.body.removeEventListener('mousemove', drag);\n document.body.removeEventListener('mouseup', endDrag);\n document.body.removeEventListener('mouseleave', endDrag);\n }\n\n function startDrag(event: MouseEvent) {\n startX = event.clientX;\n startY = event.clientY;\n\n startDragCallbackRef.current(startX, startY);\n\n document.body.addEventListener('mousemove', drag);\n document.body.addEventListener('mouseup', endDrag);\n document.body.addEventListener('mouseleave', endDrag);\n }\n\n if (element != null) {\n element.addEventListener('mousedown', startDrag);\n }\n\n return () => {\n element?.removeEventListener('mousedown', startDrag);\n document.body.removeEventListener('mousemove', drag);\n document.body.removeEventListener('mouseup', endDrag);\n document.body.removeEventListener('mouseleave', endDrag);\n };\n }, []);\n\n return ref;\n}\n"],"names":["useDraggable","options","ref","useRef","startDragCallbackRef","dragCallbackRef","endDragCallbackRef","useEffect","element","startX","startY","drag","event","deltaX","deltaY","endDrag","startDrag"],"mappings":";AAmBO,SAASA,EAAaC,GAA2B;AACtD,QAAMC,IAAMC,EAA2B,IAAI,GACrCC,IAAuBD,EAAOF,EAAQ,iBAAiB;AAC7D,EAAAG,EAAqB,UAAUH,EAAQ;AACvC,QAAMI,IAAkBF,EAAOF,EAAQ,YAAY;AACnD,EAAAI,EAAgB,UAAUJ,EAAQ;AAClC,QAAMK,IAAqBH,EAAOF,EAAQ,eAAe;AACzD,SAAAK,EAAmB,UAAUL,EAAQ,iBAErCM,EAAU,MAAM;AACd,UAAMC,IAAUN,EAAI;AACpB,QAAIO,IAAS,GACTC,IAAS;AAEb,aAASC,EAAKC,GAAmB;AAC/B,YAAMC,IAASD,EAAM,UAAUH,GACzBK,IAASF,EAAM,UAAUF;AAE/B,MAAAL,EAAgB,QAAQQ,GAAQC,GAAQL,GAAQC,CAAM;AAAA,IACxD;AAEA,aAASK,EAAQH,GAAmB;AAClC,YAAMC,IAASD,EAAM,YAAY,SAAYA,EAAM,UAAUH,IAAS,GAChEK,IAASF,EAAM,YAAY,SAAYA,EAAM,UAAUF,IAAS;AACtE,MAAAJ,EAAmB,QAAQO,GAAQC,GAAQL,GAAQC,CAAM,GACzD,SAAS,KAAK,oBAAoB,aAAaC,CAAI,GACnD,SAAS,KAAK,oBAAoB,WAAWI,CAAO,GACpD,SAAS,KAAK,oBAAoB,cAAcA,CAAO;AAAA,IACzD;AAEA,aAASC,EAAUJ,GAAmB;AACpC,MAAAH,IAASG,EAAM,SACfF,IAASE,EAAM,SAEfR,EAAqB,QAAQK,GAAQC,CAAM,GAE3C,SAAS,KAAK,iBAAiB,aAAaC,CAAI,GAChD,SAAS,KAAK,iBAAiB,WAAWI,CAAO,GACjD,SAAS,KAAK,iBAAiB,cAAcA,CAAO;AAAA,IACtD;AAEA,WACEP,GAAQ,iBAAiB,aAAaQ,CAAS,GAG1C,MAAM;AACX,MAAAR,GAAS,oBAAoB,aAAaQ,CAAS,GACnD,SAAS,KAAK,oBAAoB,aAAaL,CAAI,GACnD,SAAS,KAAK,oBAAoB,WAAWI,CAAO,GACpD,SAAS,KAAK,oBAAoB,cAAcA,CAAO;AAAA,IACzD;AAAA,EACF,GAAG,CAAA,CAAE,GAEEb;AACT;"}
|