@burdenoff/microfe-bigconsole 2026.1124.8 → 2026.1124.10

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.
@@ -0,0 +1,41 @@
1
+ import { DragEvent, MouseEvent } from 'react';
2
+ export interface DragBoard {
3
+ id: string;
4
+ name: string;
5
+ }
6
+ interface Options<T extends DragBoard> {
7
+ canPickUp: (board: T) => boolean;
8
+ canDrop: (dragged: T, target: T) => boolean;
9
+ onDrop: (dragged: T, target: T) => void;
10
+ }
11
+ export interface DragProps {
12
+ draggable?: true;
13
+ onMouseDown?: (event: MouseEvent) => void;
14
+ onDragStart?: (event: DragEvent) => void;
15
+ onDragEnd?: () => void;
16
+ }
17
+ /** Marks a control a card can be dragged by (the board's name): a press on it still starts the drag. */
18
+ export declare const DRAG_THROUGH = "data-drag-through";
19
+ export interface DropProps {
20
+ onDragOver: (event: DragEvent) => void;
21
+ onDragLeave: (event: DragEvent) => void;
22
+ onDrop: (event: DragEvent) => void;
23
+ }
24
+ /** Everything a board card needs to take part in a drag: its handlers, and whether it is held or a target now. */
25
+ export interface BoardDnd {
26
+ drag: DragProps;
27
+ drop: DropProps;
28
+ dragging: boolean;
29
+ target: boolean;
30
+ }
31
+ interface UseBoardDragLinkResult<T extends DragBoard> {
32
+ /** The board being dragged, to show it as picked up. */
33
+ draggingId: string | null;
34
+ /** The board a drop would land on right now, to show it as a target. */
35
+ overId: string | null;
36
+ dndOf: (board: T) => BoardDnd;
37
+ /** Forgets a drag in progress (the workspace or account changed). */
38
+ reset: () => void;
39
+ }
40
+ export declare function useBoardDragLink<T extends DragBoard>(options: Options<T>): UseBoardDragLinkResult<T>;
41
+ export {};
@@ -0,0 +1,62 @@
1
+ import { useCallback as e, useEffect as t, useRef as n, useState as r } from "react";
2
+ // src/bigconsole/hooks/useBoardDragLink.ts
3
+ var i = "data-drag-through", a = "button, a, input, select, textarea, label, summary, [role=\"button\"], [role=\"menuitem\"], [contenteditable]";
4
+ function o(i) {
5
+ let [o, s] = r(null), [c, l] = r(null), u = n(null), d = n(null), f = n(i);
6
+ t(() => {
7
+ f.current = i;
8
+ }, [i]);
9
+ let p = e(() => {
10
+ u.current = null, s(null), l(null);
11
+ }, []), m = (e) => i.canPickUp(e) ? {
12
+ draggable: !0,
13
+ onMouseDown: (e) => {
14
+ d.current = e.target;
15
+ },
16
+ onDragStart: (t) => {
17
+ let n = d.current;
18
+ if (d.current = null, n instanceof Element) {
19
+ let e = n.closest(a);
20
+ if (e && !e.hasAttribute("data-drag-through") && e !== t.currentTarget && t.currentTarget.contains(e)) {
21
+ t.preventDefault();
22
+ return;
23
+ }
24
+ }
25
+ t.target === t.currentTarget && (u.current = e, t.dataTransfer.effectAllowed = "link", t.dataTransfer.setData("text/plain", e.name), setTimeout(() => {
26
+ u.current?.id === e.id && s(e.id);
27
+ }, 0));
28
+ },
29
+ onDragEnd: p
30
+ } : { onDragEnd: p }, h = (e) => ({
31
+ onDragOver: (t) => {
32
+ let n = u.current;
33
+ n && f.current.canDrop(n, e) && (t.preventDefault(), t.dataTransfer.dropEffect = "link", l((t) => t === e.id ? t : e.id));
34
+ },
35
+ onDragLeave: (t) => {
36
+ let n = t.relatedTarget;
37
+ if (!(n instanceof Node && t.currentTarget.contains(n))) {
38
+ if (n === null) {
39
+ let e = t.currentTarget.getBoundingClientRect();
40
+ if (t.clientX > e.left && t.clientX < e.right && t.clientY > e.top && t.clientY < e.bottom) return;
41
+ }
42
+ l((t) => t === e.id ? null : t);
43
+ }
44
+ },
45
+ onDrop: (t) => {
46
+ let n = u.current;
47
+ n && f.current.canDrop(n, e) && (t.preventDefault(), p(), f.current.onDrop(n, e));
48
+ }
49
+ });
50
+ return {
51
+ draggingId: o,
52
+ overId: c,
53
+ dndOf: (e) => ({
54
+ drag: m(e),
55
+ drop: h(e),
56
+ dragging: o === e.id,
57
+ target: c === e.id
58
+ }),
59
+ reset: p
60
+ };
61
+ }
62
+ export { i as DRAG_THROUGH, o as useBoardDragLink };