@kumix/ui 0.3.7 → 0.3.9
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 +26 -25
- package/dist/cascader-types-BnH6wYD-.d.ts +183 -0
- package/dist/cascader-types-BnH6wYD-.d.ts.map +1 -0
- package/dist/components/agents/ai-sidebar.js +3 -5
- package/dist/components/agents/ai-sidebar.js.map +1 -1
- package/dist/components/motion/animated-sidebar.d.ts.map +1 -1
- package/dist/components/motion/animated-sidebar.js +12 -3
- package/dist/components/motion/animated-sidebar.js.map +1 -1
- package/dist/components/motion/attachment-upload.d.ts.map +1 -1
- package/dist/components/motion/attachment-upload.js +9 -5
- package/dist/components/motion/attachment-upload.js.map +1 -1
- package/dist/components/motion/bottom-sheet.d.ts.map +1 -1
- package/dist/components/motion/bottom-sheet.js +77 -74
- package/dist/components/motion/bottom-sheet.js.map +1 -1
- package/dist/components/motion/center-morph-modal.d.ts.map +1 -1
- package/dist/components/motion/center-morph-modal.js +82 -88
- package/dist/components/motion/center-morph-modal.js.map +1 -1
- package/dist/components/motion/combobox/content.js +1 -1
- package/dist/components/motion/combobox/context.d.ts +6 -0
- package/dist/components/motion/combobox/context.d.ts.map +1 -1
- package/dist/components/motion/combobox/context.js +1 -233
- package/dist/components/motion/combobox/list.js +1 -1
- package/dist/components/motion/combobox/trigger.js +7 -8
- package/dist/components/motion/combobox/trigger.js.map +1 -1
- package/dist/components/motion/combobox.js +1 -1
- package/dist/components/motion/command-palette.d.ts.map +1 -1
- package/dist/components/motion/command-palette.js +62 -45
- package/dist/components/motion/command-palette.js.map +1 -1
- package/dist/components/motion/drawer.d.ts.map +1 -1
- package/dist/components/motion/drawer.js +30 -30
- package/dist/components/motion/drawer.js.map +1 -1
- package/dist/components/motion/loader.js +20 -22
- package/dist/components/motion/loader.js.map +1 -1
- package/dist/components/motion/morphing-modal.d.ts.map +1 -1
- package/dist/components/motion/morphing-modal.js +83 -83
- package/dist/components/motion/morphing-modal.js.map +1 -1
- package/dist/components/motion/morphing-search.d.ts +28 -0
- package/dist/components/motion/morphing-search.d.ts.map +1 -0
- package/dist/components/motion/morphing-search.js +422 -0
- package/dist/components/motion/morphing-search.js.map +1 -0
- package/dist/components/motion/project-folder.js +20 -20
- package/dist/components/motion/project-folder.js.map +1 -1
- package/dist/components/reui/alert.d.ts +1 -1
- package/dist/components/reui/badge.d.ts +1 -1
- package/dist/components/reui/cascader/cascader-async.d.ts +90 -0
- package/dist/components/reui/cascader/cascader-async.d.ts.map +1 -0
- package/dist/components/reui/cascader/cascader-async.js +549 -0
- package/dist/components/reui/cascader/cascader-async.js.map +1 -0
- package/dist/components/reui/cascader/cascader-columns.d.ts +29 -0
- package/dist/components/reui/cascader/cascader-columns.d.ts.map +1 -0
- package/dist/components/reui/cascader/cascader-columns.js +135 -0
- package/dist/components/reui/cascader/cascader-columns.js.map +1 -0
- package/dist/components/reui/cascader/cascader-context.d.ts +193 -0
- package/dist/components/reui/cascader/cascader-context.d.ts.map +1 -0
- package/dist/components/reui/cascader/cascader-context.js +59 -0
- package/dist/components/reui/cascader/cascader-context.js.map +1 -0
- package/dist/components/reui/cascader/cascader-footer.d.ts +85 -0
- package/dist/components/reui/cascader/cascader-footer.d.ts.map +1 -0
- package/dist/components/reui/cascader/cascader-footer.js +456 -0
- package/dist/components/reui/cascader/cascader-footer.js.map +1 -0
- package/dist/components/reui/cascader/cascader-i18n.d.ts +17 -0
- package/dist/components/reui/cascader/cascader-i18n.d.ts.map +1 -0
- package/dist/components/reui/cascader/cascader-i18n.js +68 -0
- package/dist/components/reui/cascader/cascader-i18n.js.map +1 -0
- package/dist/components/reui/cascader/cascader-item.d.ts +115 -0
- package/dist/components/reui/cascader/cascader-item.d.ts.map +1 -0
- package/dist/components/reui/cascader/cascader-item.js +530 -0
- package/dist/components/reui/cascader/cascader-item.js.map +1 -0
- package/dist/components/reui/cascader/cascader-lib.d.ts +141 -0
- package/dist/components/reui/cascader/cascader-lib.d.ts.map +1 -0
- package/dist/components/reui/cascader/cascader-lib.js +576 -0
- package/dist/components/reui/cascader/cascader-lib.js.map +1 -0
- package/dist/components/reui/cascader/cascader-nav.d.ts +59 -0
- package/dist/components/reui/cascader/cascader-nav.d.ts.map +1 -0
- package/dist/components/reui/cascader/cascader-nav.js +312 -0
- package/dist/components/reui/cascader/cascader-nav.js.map +1 -0
- package/dist/components/reui/cascader/cascader-types.d.ts +2 -0
- package/dist/components/reui/cascader/cascader-types.js +2 -0
- package/dist/components/reui/cascader/cascader-virtual.d.ts +65 -0
- package/dist/components/reui/cascader/cascader-virtual.d.ts.map +1 -0
- package/dist/components/reui/cascader/cascader-virtual.js +240 -0
- package/dist/components/reui/cascader/cascader-virtual.js.map +1 -0
- package/dist/components/reui/cascader/cascader.d.ts +322 -0
- package/dist/components/reui/cascader/cascader.d.ts.map +1 -0
- package/dist/components/reui/cascader/cascader.js +1459 -0
- package/dist/components/reui/cascader/cascader.js.map +1 -0
- package/dist/components/reui/event-calendar/event-calendar-event.d.ts +28 -47
- package/dist/components/reui/event-calendar/event-calendar-event.d.ts.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar-event.js +26 -44
- package/dist/components/reui/event-calendar/event-calendar-event.js.map +1 -1
- package/dist/components/reui/event-calendar/event-calendar-nav.js +1 -1
- package/dist/components/reui/event-calendar/event-calendar-types.d.ts +19 -57
- package/dist/components/reui/event-calendar/event-calendar-types.d.ts.map +1 -1
- package/dist/components/reui/filters/filters-advanced.d.ts +52 -0
- package/dist/components/reui/filters/filters-advanced.d.ts.map +1 -0
- package/dist/components/reui/filters/filters-advanced.js +1191 -0
- package/dist/components/reui/filters/filters-advanced.js.map +1 -0
- package/dist/components/reui/filters/filters-builder.d.ts +43 -0
- package/dist/components/reui/filters/filters-builder.d.ts.map +1 -0
- package/dist/components/reui/filters/filters-builder.js +152 -0
- package/dist/components/reui/filters/filters-builder.js.map +1 -0
- package/dist/components/reui/filters/filters-chip.d.ts +79 -0
- package/dist/components/reui/filters/filters-chip.d.ts.map +1 -0
- package/dist/components/reui/filters/filters-chip.js +553 -0
- package/dist/components/reui/filters/filters-chip.js.map +1 -0
- package/dist/components/reui/filters/filters-context.d.ts +290 -0
- package/dist/components/reui/filters/filters-context.d.ts.map +1 -0
- package/dist/components/reui/filters/filters-context.js +277 -0
- package/dist/components/reui/filters/filters-context.js.map +1 -0
- package/dist/components/reui/filters/filters-date.d.ts +43 -0
- package/dist/components/reui/filters/filters-date.d.ts.map +1 -0
- package/dist/components/reui/filters/filters-date.js +143 -0
- package/dist/components/reui/filters/filters-date.js.map +1 -0
- package/dist/components/reui/filters/filters-dnd.d.ts +101 -0
- package/dist/components/reui/filters/filters-dnd.d.ts.map +1 -0
- package/dist/components/reui/filters/filters-dnd.js +454 -0
- package/dist/components/reui/filters/filters-dnd.js.map +1 -0
- package/dist/components/reui/filters/filters-draft.d.ts +2 -0
- package/dist/components/reui/filters/filters-draft.js +128 -0
- package/dist/components/reui/filters/filters-draft.js.map +1 -0
- package/dist/components/reui/filters/filters-editors.d.ts +91 -0
- package/dist/components/reui/filters/filters-editors.d.ts.map +1 -0
- package/dist/components/reui/filters/filters-editors.js +773 -0
- package/dist/components/reui/filters/filters-editors.js.map +1 -0
- package/dist/components/reui/filters/filters-i18n.d.ts +24 -0
- package/dist/components/reui/filters/filters-i18n.d.ts.map +1 -0
- package/dist/components/reui/filters/filters-i18n.js +127 -0
- package/dist/components/reui/filters/filters-i18n.js.map +1 -0
- package/dist/components/reui/filters/filters-lib.d.ts +171 -0
- package/dist/components/reui/filters/filters-lib.d.ts.map +1 -0
- package/dist/components/reui/filters/filters-lib.js +336 -0
- package/dist/components/reui/filters/filters-lib.js.map +1 -0
- package/dist/components/reui/filters/filters-operators.d.ts +49 -0
- package/dist/components/reui/filters/filters-operators.d.ts.map +1 -0
- package/dist/components/reui/filters/filters-operators.js +300 -0
- package/dist/components/reui/filters/filters-operators.js.map +1 -0
- package/dist/components/reui/filters/filters-query.d.ts +132 -0
- package/dist/components/reui/filters/filters-query.d.ts.map +1 -0
- package/dist/components/reui/filters/filters-query.js +476 -0
- package/dist/components/reui/filters/filters-query.js.map +1 -0
- package/dist/components/reui/filters/filters-types.d.ts +452 -0
- package/dist/components/reui/filters/filters-types.d.ts.map +1 -0
- package/dist/components/reui/filters/filters-types.js +2 -0
- package/dist/components/reui/filters/filters.d.ts +114 -0
- package/dist/components/reui/filters/filters.d.ts.map +1 -0
- package/dist/components/reui/filters/filters.js +638 -0
- package/dist/components/reui/filters/filters.js.map +1 -0
- package/dist/components/reui/gantt/gantt-bar.js +1 -1
- package/dist/components/reui/gantt/gantt-nav.js +1 -1
- package/dist/components/reui/gantt/gantt-types.d.ts +25 -71
- package/dist/components/reui/gantt/gantt-types.d.ts.map +1 -1
- package/dist/components/reui/gantt/gantt-view.js +1 -1
- package/dist/components/ui/button.d.ts +1 -1
- package/dist/components/ui/checkbox.js +1 -1
- package/dist/components/ui/checkbox.js.map +1 -1
- package/dist/components/ui/field.js +2 -2
- package/dist/components/ui/field.js.map +1 -1
- package/dist/components/ui/radio-group.js +1 -1
- package/dist/components/ui/radio-group.js.map +1 -1
- package/dist/components/ui/sidebar.js +1 -1
- package/dist/components/ui/switch.js +1 -1
- package/dist/components/ui/switch.js.map +1 -1
- package/dist/context-BizvUNZv.js +298 -0
- package/dist/context-BizvUNZv.js.map +1 -0
- package/dist/filters-draft-DEAl3TO-.d.ts +70 -0
- package/dist/filters-draft-DEAl3TO-.d.ts.map +1 -0
- package/dist/hooks/use-on-open.d.ts +18 -0
- package/dist/hooks/use-on-open.d.ts.map +1 -0
- package/dist/hooks/use-on-open.js +27 -0
- package/dist/hooks/use-on-open.js.map +1 -0
- package/dist/hooks/use-row-cursor.d.ts +39 -0
- package/dist/hooks/use-row-cursor.d.ts.map +1 -0
- package/dist/hooks/use-row-cursor.js +77 -0
- package/dist/hooks/use-row-cursor.js.map +1 -0
- package/dist/lib/text-shimmer.d.ts +2 -2
- package/dist/lib/text-shimmer.d.ts.map +1 -1
- package/dist/lib/text-shimmer.js +2 -2
- package/dist/lib/text-shimmer.js.map +1 -1
- package/dist/presence-gate-BekdC4Bo.js +24 -0
- package/dist/presence-gate-BekdC4Bo.js.map +1 -0
- package/package.json +11 -11
- package/dist/components/motion/combobox/context.js.map +0 -1
- package/dist/components/reui/filters.d.ts +0 -176
- package/dist/components/reui/filters.d.ts.map +0 -1
- package/dist/components/reui/filters.js +0 -1223
- package/dist/components/reui/filters.js.map +0 -1
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import * as React$1 from "react";
|
|
2
|
+
//#region src/components/reui/filters/filters-dnd.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Gesture model copied from `event-calendar-dnd.tsx`, deliberately not
|
|
5
|
+
* imported: filters installs on its own and must not pull a whole calendar into
|
|
6
|
+
* `shadcn add filters`. Vanilla-DOM overlay, so a drag renders no React.
|
|
7
|
+
*/
|
|
8
|
+
declare const FILTER_DND_ACTIVATION: {
|
|
9
|
+
/** Mouse travel before a press becomes a drag. Below this it stays a click. */
|
|
10
|
+
readonly moveDistancePx: 5;
|
|
11
|
+
/** Touch long-press before a drag starts, so a swipe still scrolls. */
|
|
12
|
+
readonly touchDelayMs: 250;
|
|
13
|
+
readonly touchTolerancePx: 5;
|
|
14
|
+
readonly autoScrollEdgePx: 40;
|
|
15
|
+
readonly autoScrollMaxStepPx: 12;
|
|
16
|
+
/** A seed only: `createCarry` measures the real grab offset before paint. */
|
|
17
|
+
readonly carryPointerOffsetPx: 12;
|
|
18
|
+
};
|
|
19
|
+
/** One rule row, or one group's header row. Both are drag sources and targets. */
|
|
20
|
+
declare const FILTER_ROW_SELECTOR = "[data-slot=\"filter-row\"]";
|
|
21
|
+
/** Explicit "drop INSIDE": a row hit test can only ever say "beside". */
|
|
22
|
+
declare const FILTER_DROP_ZONE_SELECTOR = "[data-drop-parent]";
|
|
23
|
+
/** Marked alongside the zone, so lighting the group costs no `:has()`. */
|
|
24
|
+
declare const FILTER_GROUP_SELECTOR = "[data-slot=\"filter-group\"]";
|
|
25
|
+
/** Geometry only, so resolution is a pure function and a table test. */
|
|
26
|
+
interface FilterDropBox {
|
|
27
|
+
top: number;
|
|
28
|
+
bottom: number;
|
|
29
|
+
left: number;
|
|
30
|
+
right: number;
|
|
31
|
+
/** The group the drop writes into. */
|
|
32
|
+
parentId: string;
|
|
33
|
+
/** Where in that group's children the node lands, not a slot in this list. */
|
|
34
|
+
index: number;
|
|
35
|
+
/** How many rows enclose this box. Deeper wins. */
|
|
36
|
+
depth: number;
|
|
37
|
+
}
|
|
38
|
+
interface FilterDropResolution<T extends FilterDropBox> {
|
|
39
|
+
target: T;
|
|
40
|
+
/** Null for a zone: INTO the group rather than beside anything. */
|
|
41
|
+
edge: "before" | "after" | null;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* How far a ROW reaches past its own rect when hit tested: HALF the sibling
|
|
45
|
+
* gap, which is `gap-3`, so six. `FILTER_ROW_GAP_CLASS` is the other half of
|
|
46
|
+
* one measurement; this moves whenever that does.
|
|
47
|
+
*
|
|
48
|
+
* The seam between adjacent rows is inside NEITHER rect, so a pointer aimed
|
|
49
|
+
* between two rows fell through to whatever did enclose it: at the top level
|
|
50
|
+
* nothing did, so the cursor said `no-drop`; one level in it was the group.
|
|
51
|
+
* Half the gap makes siblings tile, and the depth sort keeps the child ahead of
|
|
52
|
+
* that group. Rows only: zones are explicit strips.
|
|
53
|
+
*/
|
|
54
|
+
declare const FILTER_ROW_SEAM_PX = 6;
|
|
55
|
+
/**
|
|
56
|
+
* Zones before rows, then the DEEPEST box: a group's rect encloses everything
|
|
57
|
+
* it holds, so a nested condition would otherwise resolve to its whole group.
|
|
58
|
+
* `seam` is a parameter, not the constant inlined, so the tiling rule itself is
|
|
59
|
+
* a table test.
|
|
60
|
+
*/
|
|
61
|
+
declare function resolveFilterDrop<T extends FilterDropBox>(zones: T[], rows: T[], x: number, y: number, seam?: number): FilterDropResolution<T> | null;
|
|
62
|
+
/** Where a dragged node started, which is what makes a drop a no-op or not. */
|
|
63
|
+
interface FilterDropOrigin {
|
|
64
|
+
parentId: string;
|
|
65
|
+
index: number;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Both indices name the slot the node already occupies, because
|
|
69
|
+
* `moveFilterNodeTo` closes the gap the detach leaves. Copy is never a no-op.
|
|
70
|
+
*/
|
|
71
|
+
declare function isFilterDropNoop(resolution: FilterDropResolution<FilterDropBox> | null, origin: FilterDropOrigin | null, copy: boolean): boolean;
|
|
72
|
+
/** Cancel and fully revert every in-flight filter row drag. */
|
|
73
|
+
declare function cancelActiveFilterDrags(): void;
|
|
74
|
+
/**
|
|
75
|
+
* Whether a drag ended within the last few frames. Exported: a consumer's own
|
|
76
|
+
* row click handler needs the same answer the suppressor below needs.
|
|
77
|
+
*/
|
|
78
|
+
declare function wasRecentFilterDrag(): boolean;
|
|
79
|
+
interface FilterDropDetails {
|
|
80
|
+
parentId: string;
|
|
81
|
+
index: number;
|
|
82
|
+
/** Alt was held at release: copy the node rather than moving it. */
|
|
83
|
+
copy: boolean;
|
|
84
|
+
}
|
|
85
|
+
interface FilterRowDragOptions {
|
|
86
|
+
/** The PANEL, not its body: the top-level append zone is in the footer. */
|
|
87
|
+
root: () => HTMLElement | null;
|
|
88
|
+
onDrop: (nodeId: string, details: FilterDropDetails) => void;
|
|
89
|
+
disabled?: boolean;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Only `onPointerDown`: the handle is a real button that Tab reaches, so it must
|
|
93
|
+
* not also be `draggable` and race the browser's HTML5 drag, with its ghost, no
|
|
94
|
+
* copy affordance and no way to report a drop into a nested target.
|
|
95
|
+
*/
|
|
96
|
+
declare function useFilterRowDrag(options: FilterRowDragOptions): (nodeId: string) => {
|
|
97
|
+
onPointerDown: (event: React$1.PointerEvent<HTMLElement>) => void;
|
|
98
|
+
};
|
|
99
|
+
//#endregion
|
|
100
|
+
export { FILTER_DND_ACTIVATION, FILTER_DROP_ZONE_SELECTOR, FILTER_GROUP_SELECTOR, FILTER_ROW_SEAM_PX, FILTER_ROW_SELECTOR, FilterDropBox, FilterDropDetails, FilterDropOrigin, FilterDropResolution, FilterRowDragOptions, cancelActiveFilterDrags, isFilterDropNoop, resolveFilterDrop, useFilterRowDrag, wasRecentFilterDrag };
|
|
101
|
+
//# sourceMappingURL=filters-dnd.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filters-dnd.d.ts","names":[],"sources":["../../../../src/components/reui/filters/filters-dnd.tsx"],"mappings":";;;;;;;cASa;;;;;;;;;;;;cAaA;;cAGA;;cAGA;;UAGI;EACf;EACA;EACA;EACA;;EAEA;;EAEA;;EAEA;;UAGe,qBAAqB,UAAU;EAC9C,QAAQ;;EAER;;;;;;;;;;;;;cAkBW;;;;;;;iBAQG,kBAAkB,UAAU,eAC1C,OAAO,KACP,MAAM,KACN,WACA,WACA,gBACC,qBAAqB;;UAyBP;EACf;EACA;;;;;;iBAOc,iBACd,YAAY,qBAAqB,uBACjC,QAAQ,yBACR;;iBAWc;;;;;iBAUA;UAiIC;EACf;EACA;;EAEA;;UAGe;;EAEf,YAAY;EACZ,SAAS,gBAAgB,SAAS;EAClC;;;;;;;iBA2Xc,iBAAiB,SAAS,wBAAoB;EAcjC,gBAAA,OAAA,QAAM,aAAa"}
|
|
@@ -0,0 +1,454 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import * as React$1 from "react";
|
|
3
|
+
//#region src/components/reui/filters/filters-dnd.tsx
|
|
4
|
+
/**
|
|
5
|
+
* Gesture model copied from `event-calendar-dnd.tsx`, deliberately not
|
|
6
|
+
* imported: filters installs on its own and must not pull a whole calendar into
|
|
7
|
+
* `shadcn add filters`. Vanilla-DOM overlay, so a drag renders no React.
|
|
8
|
+
*/
|
|
9
|
+
const FILTER_DND_ACTIVATION = {
|
|
10
|
+
/** Mouse travel before a press becomes a drag. Below this it stays a click. */
|
|
11
|
+
moveDistancePx: 5,
|
|
12
|
+
/** Touch long-press before a drag starts, so a swipe still scrolls. */
|
|
13
|
+
touchDelayMs: 250,
|
|
14
|
+
touchTolerancePx: 5,
|
|
15
|
+
autoScrollEdgePx: 40,
|
|
16
|
+
autoScrollMaxStepPx: 12,
|
|
17
|
+
/** A seed only: `createCarry` measures the real grab offset before paint. */
|
|
18
|
+
carryPointerOffsetPx: 12
|
|
19
|
+
};
|
|
20
|
+
/** One rule row, or one group's header row. Both are drag sources and targets. */
|
|
21
|
+
const FILTER_ROW_SELECTOR = "[data-slot=\"filter-row\"]";
|
|
22
|
+
/** Explicit "drop INSIDE": a row hit test can only ever say "beside". */
|
|
23
|
+
const FILTER_DROP_ZONE_SELECTOR = "[data-drop-parent]";
|
|
24
|
+
/** Marked alongside the zone, so lighting the group costs no `:has()`. */
|
|
25
|
+
const FILTER_GROUP_SELECTOR = "[data-slot=\"filter-group\"]";
|
|
26
|
+
function contains(box, x, y, grow = 0) {
|
|
27
|
+
return x >= box.left && x <= box.right && y >= box.top - grow && y <= box.bottom + grow;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* How far a ROW reaches past its own rect when hit tested: HALF the sibling
|
|
31
|
+
* gap, which is `gap-3`, so six. `FILTER_ROW_GAP_CLASS` is the other half of
|
|
32
|
+
* one measurement; this moves whenever that does.
|
|
33
|
+
*
|
|
34
|
+
* The seam between adjacent rows is inside NEITHER rect, so a pointer aimed
|
|
35
|
+
* between two rows fell through to whatever did enclose it: at the top level
|
|
36
|
+
* nothing did, so the cursor said `no-drop`; one level in it was the group.
|
|
37
|
+
* Half the gap makes siblings tile, and the depth sort keeps the child ahead of
|
|
38
|
+
* that group. Rows only: zones are explicit strips.
|
|
39
|
+
*/
|
|
40
|
+
const FILTER_ROW_SEAM_PX = 6;
|
|
41
|
+
/**
|
|
42
|
+
* Zones before rows, then the DEEPEST box: a group's rect encloses everything
|
|
43
|
+
* it holds, so a nested condition would otherwise resolve to its whole group.
|
|
44
|
+
* `seam` is a parameter, not the constant inlined, so the tiling rule itself is
|
|
45
|
+
* a table test.
|
|
46
|
+
*/
|
|
47
|
+
function resolveFilterDrop(zones, rows, x, y, seam = 6) {
|
|
48
|
+
let zone = null;
|
|
49
|
+
for (const candidate of zones) {
|
|
50
|
+
if (!contains(candidate, x, y)) continue;
|
|
51
|
+
if (!zone || candidate.depth > zone.depth) zone = candidate;
|
|
52
|
+
}
|
|
53
|
+
if (zone) return {
|
|
54
|
+
target: zone,
|
|
55
|
+
edge: null
|
|
56
|
+
};
|
|
57
|
+
let row = null;
|
|
58
|
+
for (const candidate of rows) {
|
|
59
|
+
if (!contains(candidate, x, y, seam)) continue;
|
|
60
|
+
if (!row || candidate.depth > row.depth) row = candidate;
|
|
61
|
+
}
|
|
62
|
+
if (!row) return null;
|
|
63
|
+
const after = y > row.top + (row.bottom - row.top) / 2;
|
|
64
|
+
return {
|
|
65
|
+
target: {
|
|
66
|
+
...row,
|
|
67
|
+
index: row.index + (after ? 1 : 0)
|
|
68
|
+
},
|
|
69
|
+
edge: after ? "after" : "before"
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Both indices name the slot the node already occupies, because
|
|
74
|
+
* `moveFilterNodeTo` closes the gap the detach leaves. Copy is never a no-op.
|
|
75
|
+
*/
|
|
76
|
+
function isFilterDropNoop(resolution, origin, copy) {
|
|
77
|
+
if (!resolution || !origin || copy) return false;
|
|
78
|
+
if (resolution.target.parentId !== origin.parentId) return false;
|
|
79
|
+
return resolution.target.index === origin.index || resolution.target.index === origin.index + 1;
|
|
80
|
+
}
|
|
81
|
+
/** Rows unmount mid-gesture, so it is the PANEL leaving that aborts a drag. */
|
|
82
|
+
const activeCancels = /* @__PURE__ */ new Set();
|
|
83
|
+
/** Cancel and fully revert every in-flight filter row drag. */
|
|
84
|
+
function cancelActiveFilterDrags() {
|
|
85
|
+
for (const cancel of [...activeCancels]) cancel();
|
|
86
|
+
}
|
|
87
|
+
let lastDragEndedAt = 0;
|
|
88
|
+
/**
|
|
89
|
+
* Whether a drag ended within the last few frames. Exported: a consumer's own
|
|
90
|
+
* row click handler needs the same answer the suppressor below needs.
|
|
91
|
+
*/
|
|
92
|
+
function wasRecentFilterDrag() {
|
|
93
|
+
return performance.now() - lastDragEndedAt < 250;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* NOT `{ once: true }` alone: a drag that ends over a different element fires
|
|
97
|
+
* no click at all, and a stale arming would eat the user's next click. The
|
|
98
|
+
* timestamp is what makes that stale arming harmless.
|
|
99
|
+
*/
|
|
100
|
+
function suppressTrailingClick(event) {
|
|
101
|
+
window.removeEventListener("click", suppressTrailingClick, true);
|
|
102
|
+
if (!wasRecentFilterDrag()) return;
|
|
103
|
+
event.stopPropagation();
|
|
104
|
+
event.preventDefault();
|
|
105
|
+
}
|
|
106
|
+
/** The carry is a compositing layer: a subpixel translate blurs its text. */
|
|
107
|
+
function snapToPixel(value) {
|
|
108
|
+
const dpr = typeof window !== "undefined" ? window.devicePixelRatio || 1 : 1;
|
|
109
|
+
return Math.round(value * dpr) / dpr;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* The nearest scroller, THIS ONE INCLUDED: the panel is exactly what a consumer
|
|
113
|
+
* caps with `overflow-y: auto`, and a walk from the parent answered null for it.
|
|
114
|
+
*/
|
|
115
|
+
function findScrollParent(el) {
|
|
116
|
+
let node = el ?? null;
|
|
117
|
+
while (node) {
|
|
118
|
+
const style = getComputedStyle(node);
|
|
119
|
+
const overflow = `${style.overflowY} ${style.overflow}`;
|
|
120
|
+
if (/(auto|scroll|overlay)/.test(overflow) && node.scrollHeight > node.clientHeight) return node;
|
|
121
|
+
node = node.parentElement;
|
|
122
|
+
}
|
|
123
|
+
return null;
|
|
124
|
+
}
|
|
125
|
+
function rowDepth(el, root) {
|
|
126
|
+
let depth = 0;
|
|
127
|
+
let node = el.parentElement;
|
|
128
|
+
while (node && node !== root) {
|
|
129
|
+
if (node.matches("[data-slot=\"filter-row\"]")) depth++;
|
|
130
|
+
node = node.parentElement;
|
|
131
|
+
}
|
|
132
|
+
return depth;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Measured once. DESCENDANTS of the dragged node are excluded rather than
|
|
136
|
+
* refused later: an indicator the drop ignores is a broken promise. The dragged
|
|
137
|
+
* row ITSELF is kept, so its own slot reads as a no-op, not as a hole.
|
|
138
|
+
*/
|
|
139
|
+
function collectSurface(root, dragged) {
|
|
140
|
+
const zones = [];
|
|
141
|
+
const rows = [];
|
|
142
|
+
for (const el of root.querySelectorAll(FILTER_DROP_ZONE_SELECTOR)) {
|
|
143
|
+
if (dragged.contains(el)) continue;
|
|
144
|
+
const parentId = el.dataset.dropParent;
|
|
145
|
+
if (!parentId) continue;
|
|
146
|
+
const rect = el.getBoundingClientRect();
|
|
147
|
+
zones.push({
|
|
148
|
+
el,
|
|
149
|
+
card: el.closest(FILTER_GROUP_SELECTOR),
|
|
150
|
+
top: rect.top,
|
|
151
|
+
bottom: rect.bottom,
|
|
152
|
+
left: rect.left,
|
|
153
|
+
right: rect.right,
|
|
154
|
+
parentId,
|
|
155
|
+
index: Number(el.dataset.dropIndex ?? 0),
|
|
156
|
+
depth: rowDepth(el, root)
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
for (const el of root.querySelectorAll(FILTER_ROW_SELECTOR)) {
|
|
160
|
+
if (el !== dragged && dragged.contains(el)) continue;
|
|
161
|
+
const parentId = el.dataset.parentId;
|
|
162
|
+
if (!parentId) continue;
|
|
163
|
+
const rect = el.getBoundingClientRect();
|
|
164
|
+
rows.push({
|
|
165
|
+
el,
|
|
166
|
+
card: null,
|
|
167
|
+
top: rect.top,
|
|
168
|
+
bottom: rect.bottom,
|
|
169
|
+
left: rect.left,
|
|
170
|
+
right: rect.right,
|
|
171
|
+
parentId,
|
|
172
|
+
index: Number(el.dataset.index ?? 0),
|
|
173
|
+
depth: rowDepth(el, root)
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
const viewport = findScrollParent(root);
|
|
177
|
+
return {
|
|
178
|
+
zones,
|
|
179
|
+
rows,
|
|
180
|
+
viewport,
|
|
181
|
+
viewportRect: viewport?.getBoundingClientRect() ?? null,
|
|
182
|
+
startScrollTop: viewport?.scrollTop ?? 0
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Straight to the DOM: a React state write per move is a tree render. A zone
|
|
187
|
+
* marks TWO elements, itself and its card, and both clear every frame.
|
|
188
|
+
*/
|
|
189
|
+
function paint(surface, hit) {
|
|
190
|
+
for (const box of surface.zones) {
|
|
191
|
+
delete box.el.dataset.dropInto;
|
|
192
|
+
if (box.card) delete box.card.dataset.dropInto;
|
|
193
|
+
}
|
|
194
|
+
for (const box of surface.rows) delete box.el.dataset.dropEdge;
|
|
195
|
+
if (!hit) return;
|
|
196
|
+
if (hit.edge) {
|
|
197
|
+
hit.target.el.dataset.dropEdge = hit.edge;
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
hit.target.el.dataset.dropInto = "";
|
|
201
|
+
if (hit.target.card) hit.target.card.dataset.dropInto = "";
|
|
202
|
+
}
|
|
203
|
+
function startDrag(event, nodeId, options) {
|
|
204
|
+
const handle = event.currentTarget;
|
|
205
|
+
const root = options.root();
|
|
206
|
+
const source = handle.closest(FILTER_ROW_SELECTOR);
|
|
207
|
+
if (!root || !source) return;
|
|
208
|
+
const pointerId = event.pointerId;
|
|
209
|
+
const isTouch = event.pointerType === "touch";
|
|
210
|
+
const startX = event.clientX;
|
|
211
|
+
const startY = event.clientY;
|
|
212
|
+
const origin = source.dataset.parentId ? {
|
|
213
|
+
parentId: source.dataset.parentId,
|
|
214
|
+
index: Number(source.dataset.index ?? 0)
|
|
215
|
+
} : null;
|
|
216
|
+
let active = false;
|
|
217
|
+
let finished = false;
|
|
218
|
+
let surface = null;
|
|
219
|
+
let hit = null;
|
|
220
|
+
let copy = event.altKey;
|
|
221
|
+
let lastEvent = null;
|
|
222
|
+
let touchTimer = null;
|
|
223
|
+
let rafScroll = 0;
|
|
224
|
+
let dropState = "none";
|
|
225
|
+
let carryEl = null;
|
|
226
|
+
let badgeEl = null;
|
|
227
|
+
let grabOffsetX = FILTER_DND_ACTIVATION.carryPointerOffsetPx;
|
|
228
|
+
let grabOffsetY = FILTER_DND_ACTIVATION.carryPointerOffsetPx;
|
|
229
|
+
const createCarry = () => {
|
|
230
|
+
const rect = source.getBoundingClientRect();
|
|
231
|
+
grabOffsetX = startX - rect.left;
|
|
232
|
+
grabOffsetY = startY - rect.top;
|
|
233
|
+
carryEl = document.createElement("div");
|
|
234
|
+
carryEl.setAttribute("data-slot", "filters-drag-carry");
|
|
235
|
+
carryEl.setAttribute("aria-hidden", "true");
|
|
236
|
+
carryEl.className = "pointer-events-none fixed top-0 left-0 z-100 opacity-95 will-change-transform data-drop-invalid:ring-destructive/70 data-drop-invalid:ring-2 data-drop-invalid:opacity-60";
|
|
237
|
+
carryEl.style.position = "fixed";
|
|
238
|
+
const clone = source.cloneNode(true);
|
|
239
|
+
delete clone.dataset.dragging;
|
|
240
|
+
delete clone.dataset.dropNoop;
|
|
241
|
+
delete clone.dataset.dropEdge;
|
|
242
|
+
if (rect.width > 0) clone.style.width = `${rect.width}px`;
|
|
243
|
+
const strip = (el) => {
|
|
244
|
+
el.removeAttribute("id");
|
|
245
|
+
el.removeAttribute("data-node-id");
|
|
246
|
+
el.removeAttribute("data-filter-cell");
|
|
247
|
+
if (el.dataset.slot === "filter-row") el.removeAttribute("data-slot");
|
|
248
|
+
el.setAttribute("tabindex", "-1");
|
|
249
|
+
};
|
|
250
|
+
strip(clone);
|
|
251
|
+
for (const el of clone.querySelectorAll("*")) strip(el);
|
|
252
|
+
const clip = document.createElement("div");
|
|
253
|
+
clip.className = "bg-background overflow-hidden rounded-md";
|
|
254
|
+
if (rect.width > 0) clip.style.width = `${rect.width}px`;
|
|
255
|
+
if (rect.height > 0) clip.style.height = `${rect.height}px`;
|
|
256
|
+
clip.appendChild(clone);
|
|
257
|
+
carryEl.appendChild(clip);
|
|
258
|
+
badgeEl = document.createElement("span");
|
|
259
|
+
badgeEl.setAttribute("data-slot", "filters-drag-copy");
|
|
260
|
+
badgeEl.className = "bg-primary text-primary-foreground absolute -end-1.5 -top-1.5 flex size-4 items-center justify-center rounded-full text-[10px] leading-none";
|
|
261
|
+
badgeEl.textContent = "+";
|
|
262
|
+
badgeEl.hidden = !copy;
|
|
263
|
+
carryEl.appendChild(badgeEl);
|
|
264
|
+
document.body.appendChild(carryEl);
|
|
265
|
+
positionCarry(startX, startY);
|
|
266
|
+
};
|
|
267
|
+
const positionCarry = (x, y) => {
|
|
268
|
+
if (!carryEl) return;
|
|
269
|
+
carryEl.style.transform = `translate3d(${snapToPixel(x - grabOffsetX)}px, ${snapToPixel(y - grabOffsetY)}px, 0)`;
|
|
270
|
+
};
|
|
271
|
+
const paintCursor = () => {
|
|
272
|
+
if (!active) return;
|
|
273
|
+
document.body.style.cursor = dropState === "none" ? "no-drop" : copy ? "copy" : "grabbing";
|
|
274
|
+
};
|
|
275
|
+
const setDropState = (next) => {
|
|
276
|
+
dropState = next;
|
|
277
|
+
if (next === "noop") source.dataset.dropNoop = "";
|
|
278
|
+
else delete source.dataset.dropNoop;
|
|
279
|
+
if (carryEl) {
|
|
280
|
+
if (next === "none") carryEl.dataset.dropInvalid = "";
|
|
281
|
+
else delete carryEl.dataset.dropInvalid;
|
|
282
|
+
}
|
|
283
|
+
paintCursor();
|
|
284
|
+
};
|
|
285
|
+
const setCopy = (next) => {
|
|
286
|
+
if (copy === next) return;
|
|
287
|
+
copy = next;
|
|
288
|
+
if (badgeEl) badgeEl.hidden = !next;
|
|
289
|
+
paintCursor();
|
|
290
|
+
if (lastEvent) hitTest(lastEvent.clientX, lastEvent.clientY);
|
|
291
|
+
};
|
|
292
|
+
const hitTest = (x, y) => {
|
|
293
|
+
if (!surface) return;
|
|
294
|
+
const drift = (surface.viewport?.scrollTop ?? surface.startScrollTop) - surface.startScrollTop;
|
|
295
|
+
const resolved = resolveFilterDrop(surface.zones, surface.rows, x, y + drift);
|
|
296
|
+
const noop = isFilterDropNoop(resolved, origin, copy);
|
|
297
|
+
hit = noop ? null : resolved;
|
|
298
|
+
paint(surface, hit);
|
|
299
|
+
setDropState(noop ? "noop" : hit ? "ok" : "none");
|
|
300
|
+
};
|
|
301
|
+
const autoScroll = (y) => {
|
|
302
|
+
if (rafScroll) cancelAnimationFrame(rafScroll);
|
|
303
|
+
rafScroll = 0;
|
|
304
|
+
const viewport = surface?.viewport;
|
|
305
|
+
const rect = surface?.viewportRect;
|
|
306
|
+
if (!viewport || !rect) return;
|
|
307
|
+
const edge = FILTER_DND_ACTIVATION.autoScrollEdgePx;
|
|
308
|
+
const step = FILTER_DND_ACTIVATION.autoScrollMaxStepPx;
|
|
309
|
+
let delta = 0;
|
|
310
|
+
if (y >= rect.top && y < rect.top + edge) delta = -step * ((rect.top + edge - y) / edge);
|
|
311
|
+
else if (y <= rect.bottom && y > rect.bottom - edge) delta = step * Math.min(1, (y - (rect.bottom - edge)) / edge);
|
|
312
|
+
if (delta === 0) return;
|
|
313
|
+
const tick = () => {
|
|
314
|
+
const before = viewport.scrollTop;
|
|
315
|
+
viewport.scrollTop = before + delta;
|
|
316
|
+
if (viewport.scrollTop === before) return;
|
|
317
|
+
if (lastEvent) hitTest(lastEvent.clientX, lastEvent.clientY);
|
|
318
|
+
rafScroll = requestAnimationFrame(tick);
|
|
319
|
+
};
|
|
320
|
+
rafScroll = requestAnimationFrame(tick);
|
|
321
|
+
};
|
|
322
|
+
/**
|
|
323
|
+
* A still pointer fires no `pointermove`, so a wheel mid-drag would leave the
|
|
324
|
+
* last answer painted while the rows slid out from under it. The overlap
|
|
325
|
+
* with the autoScroll tick is deliberate: this is arithmetic over boxes
|
|
326
|
+
* already measured, and one redundant pass per frame is cheaper than a rule
|
|
327
|
+
* about who owns the repaint.
|
|
328
|
+
*/
|
|
329
|
+
const onViewportScroll = () => {
|
|
330
|
+
if (!active || !lastEvent) return;
|
|
331
|
+
hitTest(lastEvent.clientX, lastEvent.clientY);
|
|
332
|
+
};
|
|
333
|
+
const activate = () => {
|
|
334
|
+
if (active) return;
|
|
335
|
+
active = true;
|
|
336
|
+
surface = collectSurface(root, source);
|
|
337
|
+
surface.viewport?.addEventListener("scroll", onViewportScroll, { passive: true });
|
|
338
|
+
source.dataset.dragging = "";
|
|
339
|
+
document.body.style.cursor = copy ? "copy" : "grabbing";
|
|
340
|
+
document.body.style.userSelect = "none";
|
|
341
|
+
createCarry();
|
|
342
|
+
window.addEventListener("blur", onWindowBlur);
|
|
343
|
+
};
|
|
344
|
+
const cleanup = () => {
|
|
345
|
+
if (finished) return;
|
|
346
|
+
finished = true;
|
|
347
|
+
activeCancels.delete(cancel);
|
|
348
|
+
window.removeEventListener("pointermove", onPointerMove);
|
|
349
|
+
window.removeEventListener("pointerup", onPointerUp);
|
|
350
|
+
window.removeEventListener("pointercancel", onPointerCancel);
|
|
351
|
+
window.removeEventListener("keydown", onKeyDown, true);
|
|
352
|
+
window.removeEventListener("keyup", onKeyUp, true);
|
|
353
|
+
window.removeEventListener("blur", onWindowBlur);
|
|
354
|
+
surface?.viewport?.removeEventListener("scroll", onViewportScroll);
|
|
355
|
+
if (touchTimer) clearTimeout(touchTimer);
|
|
356
|
+
if (rafScroll) cancelAnimationFrame(rafScroll);
|
|
357
|
+
if (surface) paint(surface, null);
|
|
358
|
+
delete source.dataset.dragging;
|
|
359
|
+
delete source.dataset.dropNoop;
|
|
360
|
+
carryEl?.remove();
|
|
361
|
+
carryEl = null;
|
|
362
|
+
badgeEl = null;
|
|
363
|
+
document.body.style.cursor = "";
|
|
364
|
+
document.body.style.userSelect = "";
|
|
365
|
+
};
|
|
366
|
+
/** A bare teardown: nothing is committed until release, so no snapshot. */
|
|
367
|
+
const cancel = () => {
|
|
368
|
+
if (active) lastDragEndedAt = performance.now();
|
|
369
|
+
cleanup();
|
|
370
|
+
};
|
|
371
|
+
const onWindowBlur = () => cancel();
|
|
372
|
+
const onKeyDown = (e) => {
|
|
373
|
+
if (e.key === "Escape" && active) {
|
|
374
|
+
e.stopPropagation();
|
|
375
|
+
e.preventDefault();
|
|
376
|
+
cancel();
|
|
377
|
+
return;
|
|
378
|
+
}
|
|
379
|
+
if (e.key === "Alt") setCopy(true);
|
|
380
|
+
};
|
|
381
|
+
const onKeyUp = (e) => {
|
|
382
|
+
if (e.key === "Alt") setCopy(false);
|
|
383
|
+
};
|
|
384
|
+
const onPointerMove = (e) => {
|
|
385
|
+
if (e.pointerId !== pointerId) return;
|
|
386
|
+
lastEvent = e;
|
|
387
|
+
if (!active) {
|
|
388
|
+
const distance = Math.hypot(e.clientX - startX, e.clientY - startY);
|
|
389
|
+
if (isTouch) {
|
|
390
|
+
if (distance > FILTER_DND_ACTIVATION.touchTolerancePx) cancel();
|
|
391
|
+
return;
|
|
392
|
+
}
|
|
393
|
+
if (distance < FILTER_DND_ACTIVATION.moveDistancePx) return;
|
|
394
|
+
activate();
|
|
395
|
+
}
|
|
396
|
+
setCopy(e.altKey);
|
|
397
|
+
positionCarry(e.clientX, e.clientY);
|
|
398
|
+
hitTest(e.clientX, e.clientY);
|
|
399
|
+
autoScroll(e.clientY);
|
|
400
|
+
};
|
|
401
|
+
const onPointerUp = (e) => {
|
|
402
|
+
if (e.pointerId !== pointerId) return;
|
|
403
|
+
const landed = active ? hit : null;
|
|
404
|
+
const wasCopy = copy;
|
|
405
|
+
cleanup();
|
|
406
|
+
if (!active) return;
|
|
407
|
+
lastDragEndedAt = performance.now();
|
|
408
|
+
window.addEventListener("click", suppressTrailingClick, true);
|
|
409
|
+
if (!landed) return;
|
|
410
|
+
options.onDrop(nodeId, {
|
|
411
|
+
parentId: landed.target.parentId,
|
|
412
|
+
index: landed.target.index,
|
|
413
|
+
copy: wasCopy
|
|
414
|
+
});
|
|
415
|
+
};
|
|
416
|
+
const onPointerCancel = (e) => {
|
|
417
|
+
if (e.pointerId !== pointerId) return;
|
|
418
|
+
cancel();
|
|
419
|
+
};
|
|
420
|
+
window.addEventListener("pointermove", onPointerMove);
|
|
421
|
+
window.addEventListener("pointerup", onPointerUp);
|
|
422
|
+
window.addEventListener("pointercancel", onPointerCancel);
|
|
423
|
+
window.addEventListener("keydown", onKeyDown, true);
|
|
424
|
+
window.addEventListener("keyup", onKeyUp, true);
|
|
425
|
+
activeCancels.add(cancel);
|
|
426
|
+
if (isTouch) touchTimer = setTimeout(() => {
|
|
427
|
+
activate();
|
|
428
|
+
if (lastEvent) {
|
|
429
|
+
positionCarry(lastEvent.clientX, lastEvent.clientY);
|
|
430
|
+
hitTest(lastEvent.clientX, lastEvent.clientY);
|
|
431
|
+
}
|
|
432
|
+
}, FILTER_DND_ACTIVATION.touchDelayMs);
|
|
433
|
+
}
|
|
434
|
+
/**
|
|
435
|
+
* Only `onPointerDown`: the handle is a real button that Tab reaches, so it must
|
|
436
|
+
* not also be `draggable` and race the browser's HTML5 drag, with its ghost, no
|
|
437
|
+
* copy affordance and no way to report a drop into a nested target.
|
|
438
|
+
*/
|
|
439
|
+
function useFilterRowDrag(options) {
|
|
440
|
+
const latest = React$1.useRef(options);
|
|
441
|
+
React$1.useEffect(() => {
|
|
442
|
+
latest.current = options;
|
|
443
|
+
});
|
|
444
|
+
React$1.useEffect(() => cancelActiveFilterDrags, []);
|
|
445
|
+
return React$1.useCallback((nodeId) => ({ onPointerDown: (event) => {
|
|
446
|
+
if (latest.current.disabled) return;
|
|
447
|
+
if (event.button !== 0) return;
|
|
448
|
+
startDrag(event, nodeId, latest.current);
|
|
449
|
+
} }), []);
|
|
450
|
+
}
|
|
451
|
+
//#endregion
|
|
452
|
+
export { FILTER_DND_ACTIVATION, FILTER_DROP_ZONE_SELECTOR, FILTER_GROUP_SELECTOR, FILTER_ROW_SEAM_PX, FILTER_ROW_SELECTOR, cancelActiveFilterDrags, isFilterDropNoop, resolveFilterDrop, useFilterRowDrag, wasRecentFilterDrag };
|
|
453
|
+
|
|
454
|
+
//# sourceMappingURL=filters-dnd.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filters-dnd.js","names":["React"],"sources":["../../../../src/components/reui/filters/filters-dnd.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\n\n/**\n * Gesture model copied from `event-calendar-dnd.tsx`, deliberately not\n * imported: filters installs on its own and must not pull a whole calendar into\n * `shadcn add filters`. Vanilla-DOM overlay, so a drag renders no React.\n */\nexport const FILTER_DND_ACTIVATION = {\n /** Mouse travel before a press becomes a drag. Below this it stays a click. */\n moveDistancePx: 5,\n /** Touch long-press before a drag starts, so a swipe still scrolls. */\n touchDelayMs: 250,\n touchTolerancePx: 5,\n autoScrollEdgePx: 40,\n autoScrollMaxStepPx: 12,\n /** A seed only: `createCarry` measures the real grab offset before paint. */\n carryPointerOffsetPx: 12,\n} as const;\n\n/** One rule row, or one group's header row. Both are drag sources and targets. */\nexport const FILTER_ROW_SELECTOR = '[data-slot=\"filter-row\"]';\n\n/** Explicit \"drop INSIDE\": a row hit test can only ever say \"beside\". */\nexport const FILTER_DROP_ZONE_SELECTOR = \"[data-drop-parent]\";\n\n/** Marked alongside the zone, so lighting the group costs no `:has()`. */\nexport const FILTER_GROUP_SELECTOR = '[data-slot=\"filter-group\"]';\n\n/** Geometry only, so resolution is a pure function and a table test. */\nexport interface FilterDropBox {\n top: number;\n bottom: number;\n left: number;\n right: number;\n /** The group the drop writes into. */\n parentId: string;\n /** Where in that group's children the node lands, not a slot in this list. */\n index: number;\n /** How many rows enclose this box. Deeper wins. */\n depth: number;\n}\n\nexport interface FilterDropResolution<T extends FilterDropBox> {\n target: T;\n /** Null for a zone: INTO the group rather than beside anything. */\n edge: \"before\" | \"after\" | null;\n}\n\nfunction contains(box: FilterDropBox, x: number, y: number, grow = 0): boolean {\n return x >= box.left && x <= box.right && y >= box.top - grow && y <= box.bottom + grow;\n}\n\n/**\n * How far a ROW reaches past its own rect when hit tested: HALF the sibling\n * gap, which is `gap-3`, so six. `FILTER_ROW_GAP_CLASS` is the other half of\n * one measurement; this moves whenever that does.\n *\n * The seam between adjacent rows is inside NEITHER rect, so a pointer aimed\n * between two rows fell through to whatever did enclose it: at the top level\n * nothing did, so the cursor said `no-drop`; one level in it was the group.\n * Half the gap makes siblings tile, and the depth sort keeps the child ahead of\n * that group. Rows only: zones are explicit strips.\n */\nexport const FILTER_ROW_SEAM_PX = 6;\n\n/**\n * Zones before rows, then the DEEPEST box: a group's rect encloses everything\n * it holds, so a nested condition would otherwise resolve to its whole group.\n * `seam` is a parameter, not the constant inlined, so the tiling rule itself is\n * a table test.\n */\nexport function resolveFilterDrop<T extends FilterDropBox>(\n zones: T[],\n rows: T[],\n x: number,\n y: number,\n seam: number = FILTER_ROW_SEAM_PX,\n): FilterDropResolution<T> | null {\n let zone: T | null = null;\n for (const candidate of zones) {\n if (!contains(candidate, x, y)) continue;\n if (!zone || candidate.depth > zone.depth) zone = candidate;\n }\n if (zone) return { target: zone, edge: null };\n\n let row: T | null = null;\n for (const candidate of rows) {\n if (!contains(candidate, x, y, seam)) continue;\n if (!row || candidate.depth > row.depth) row = candidate;\n }\n if (!row) return null;\n\n // The midpoint, not the nearest edge: a row is the width of the panel, so a\n // proximity test would leave the indicator undecided across most of one.\n const after = y > row.top + (row.bottom - row.top) / 2;\n return {\n target: { ...row, index: row.index + (after ? 1 : 0) },\n edge: after ? \"after\" : \"before\",\n };\n}\n\n/** Where a dragged node started, which is what makes a drop a no-op or not. */\nexport interface FilterDropOrigin {\n parentId: string;\n index: number;\n}\n\n/**\n * Both indices name the slot the node already occupies, because\n * `moveFilterNodeTo` closes the gap the detach leaves. Copy is never a no-op.\n */\nexport function isFilterDropNoop(\n resolution: FilterDropResolution<FilterDropBox> | null,\n origin: FilterDropOrigin | null,\n copy: boolean,\n): boolean {\n if (!resolution || !origin || copy) return false;\n if (resolution.target.parentId !== origin.parentId) return false;\n return resolution.target.index === origin.index || resolution.target.index === origin.index + 1;\n}\n\n/** Rows unmount mid-gesture, so it is the PANEL leaving that aborts a drag. */\nconst activeCancels = new Set<() => void>();\n\n/** Cancel and fully revert every in-flight filter row drag. */\nexport function cancelActiveFilterDrags(): void {\n for (const cancel of [...activeCancels]) cancel();\n}\n\nlet lastDragEndedAt = 0;\n\n/**\n * Whether a drag ended within the last few frames. Exported: a consumer's own\n * row click handler needs the same answer the suppressor below needs.\n */\nexport function wasRecentFilterDrag(): boolean {\n return performance.now() - lastDragEndedAt < 250;\n}\n\n/**\n * NOT `{ once: true }` alone: a drag that ends over a different element fires\n * no click at all, and a stale arming would eat the user's next click. The\n * timestamp is what makes that stale arming harmless.\n */\nfunction suppressTrailingClick(event: MouseEvent) {\n window.removeEventListener(\"click\", suppressTrailingClick, true);\n if (!wasRecentFilterDrag()) return;\n event.stopPropagation();\n event.preventDefault();\n}\n\n/** The carry is a compositing layer: a subpixel translate blurs its text. */\nfunction snapToPixel(value: number): number {\n const dpr = typeof window !== \"undefined\" ? window.devicePixelRatio || 1 : 1;\n return Math.round(value * dpr) / dpr;\n}\n\n/**\n * `card` is a ZONE's group, resolved once rather than walked per frame. Null on\n * a row, which stands for itself.\n */\ntype MeasuredBox = FilterDropBox & {\n el: HTMLElement;\n card: HTMLElement | null;\n};\n\ninterface Surface {\n zones: MeasuredBox[];\n rows: MeasuredBox[];\n /**\n * Rects are captured ONCE, so one subtraction against this scrollTop corrects\n * for scrolling instead of a per-move `getBoundingClientRect`. THE ELEMENT,\n * NOT A MIRRORED NUMBER: a mirror tracks only this engine's own scrolling, so\n * a wheel mid-gesture left the rects stale while the correction read zero,\n * painting the indicator 60px off the pointer.\n */\n viewport: HTMLElement | null;\n viewportRect: DOMRect | null;\n /** The one number kept: where the rects were taken, which cannot change. */\n startScrollTop: number;\n}\n\n/**\n * The nearest scroller, THIS ONE INCLUDED: the panel is exactly what a consumer\n * caps with `overflow-y: auto`, and a walk from the parent answered null for it.\n */\nfunction findScrollParent(el: HTMLElement | null): HTMLElement | null {\n let node = el ?? null;\n while (node) {\n const style = getComputedStyle(node);\n const overflow = `${style.overflowY} ${style.overflow}`;\n if (/(auto|scroll|overlay)/.test(overflow) && node.scrollHeight > node.clientHeight) {\n return node;\n }\n node = node.parentElement;\n }\n return null;\n}\n\nfunction rowDepth(el: HTMLElement, root: HTMLElement): number {\n let depth = 0;\n let node = el.parentElement;\n while (node && node !== root) {\n if (node.matches(FILTER_ROW_SELECTOR)) depth++;\n node = node.parentElement;\n }\n return depth;\n}\n\n/**\n * Measured once. DESCENDANTS of the dragged node are excluded rather than\n * refused later: an indicator the drop ignores is a broken promise. The dragged\n * row ITSELF is kept, so its own slot reads as a no-op, not as a hole.\n */\nfunction collectSurface(root: HTMLElement, dragged: HTMLElement): Surface {\n const zones: MeasuredBox[] = [];\n const rows: MeasuredBox[] = [];\n\n for (const el of root.querySelectorAll<HTMLElement>(FILTER_DROP_ZONE_SELECTOR)) {\n if (dragged.contains(el)) continue;\n const parentId = el.dataset.dropParent;\n if (!parentId) continue;\n const rect = el.getBoundingClientRect();\n zones.push({\n el,\n card: el.closest<HTMLElement>(FILTER_GROUP_SELECTOR),\n top: rect.top,\n bottom: rect.bottom,\n left: rect.left,\n right: rect.right,\n parentId,\n index: Number(el.dataset.dropIndex ?? 0),\n depth: rowDepth(el, root),\n });\n }\n\n for (const el of root.querySelectorAll<HTMLElement>(FILTER_ROW_SELECTOR)) {\n if (el !== dragged && dragged.contains(el)) continue;\n const parentId = el.dataset.parentId;\n if (!parentId) continue;\n const rect = el.getBoundingClientRect();\n rows.push({\n el,\n card: null,\n top: rect.top,\n bottom: rect.bottom,\n left: rect.left,\n right: rect.right,\n parentId,\n index: Number(el.dataset.index ?? 0),\n depth: rowDepth(el, root),\n });\n }\n\n const viewport = findScrollParent(root);\n return {\n zones,\n rows,\n viewport,\n viewportRect: viewport?.getBoundingClientRect() ?? null,\n startScrollTop: viewport?.scrollTop ?? 0,\n };\n}\n\nexport interface FilterDropDetails {\n parentId: string;\n index: number;\n /** Alt was held at release: copy the node rather than moving it. */\n copy: boolean;\n}\n\nexport interface FilterRowDragOptions {\n /** The PANEL, not its body: the top-level append zone is in the footer. */\n root: () => HTMLElement | null;\n onDrop: (nodeId: string, details: FilterDropDetails) => void;\n disabled?: boolean;\n}\n\n/**\n * Straight to the DOM: a React state write per move is a tree render. A zone\n * marks TWO elements, itself and its card, and both clear every frame.\n */\nfunction paint(surface: Surface, hit: FilterDropResolution<MeasuredBox> | null) {\n for (const box of surface.zones) {\n delete box.el.dataset.dropInto;\n if (box.card) delete box.card.dataset.dropInto;\n }\n for (const box of surface.rows) delete box.el.dataset.dropEdge;\n if (!hit) return;\n if (hit.edge) {\n hit.target.el.dataset.dropEdge = hit.edge;\n return;\n }\n hit.target.el.dataset.dropInto = \"\";\n if (hit.target.card) hit.target.card.dataset.dropInto = \"\";\n}\n\nfunction startDrag(\n event: React.PointerEvent<HTMLElement>,\n nodeId: string,\n options: FilterRowDragOptions,\n) {\n const handle = event.currentTarget;\n const root = options.root();\n const source = handle.closest<HTMLElement>(FILTER_ROW_SELECTOR);\n if (!root || !source) return;\n\n const pointerId = event.pointerId;\n const isTouch = event.pointerType === \"touch\";\n const startX = event.clientX;\n const startY = event.clientY;\n\n // Off the row's own attributes, which it already publishes for the hit test.\n // Asking the panel would mean threading a position through the drag context.\n const origin: FilterDropOrigin | null = source.dataset.parentId\n ? {\n parentId: source.dataset.parentId,\n index: Number(source.dataset.index ?? 0),\n }\n : null;\n\n let active = false;\n let finished = false;\n let surface: Surface | null = null;\n let hit: FilterDropResolution<MeasuredBox> | null = null;\n let copy = event.altKey;\n let lastEvent: PointerEvent | null = null;\n let touchTimer: ReturnType<typeof setTimeout> | null = null;\n let rafScroll = 0;\n\n // Three states, not a boolean: `\"ok\"` lands somewhere new, `\"noop\"` puts the\n // node back where it came from, `\"none\"` is over nothing at all.\n let dropState: \"ok\" | \"noop\" | \"none\" = \"none\";\n\n let carryEl: HTMLDivElement | null = null;\n let badgeEl: HTMLSpanElement | null = null;\n // Where inside the row the pointer went down, so the copy holds that spot.\n // Measured in `createCarry`, which runs before anything reads these.\n let grabOffsetX = FILTER_DND_ACTIVATION.carryPointerOffsetPx;\n let grabOffsetY = FILTER_DND_ACTIVATION.carryPointerOffsetPx;\n\n const createCarry = () => {\n const rect = source.getBoundingClientRect();\n grabOffsetX = startX - rect.left;\n grabOffsetY = startY - rect.top;\n\n carryEl = document.createElement(\"div\");\n carryEl.setAttribute(\"data-slot\", \"filters-drag-carry\");\n carryEl.setAttribute(\"aria-hidden\", \"true\");\n // `data-drop-invalid` rather than a toggled class name, so the style stays\n // one static string Tailwind can see at build time.\n //\n // Muted and translucent, no border or shadow: the clone carries the row's\n // own controls, and a box around them read as a card leaving the page. Only\n // the invalid state marks the clone, since nothing else says the drop is\n // dead, and it RINGS rather than going dashed: dashed is this builder's\n // word for \"a row can land here\", and the clone is not one.\n carryEl.className =\n \"pointer-events-none fixed \" +\n \"top-0 left-0 z-100 \" +\n \"opacity-95 will-change-transform \" +\n \"data-drop-invalid:ring-destructive/70 data-drop-invalid:ring-2 \" +\n \"data-drop-invalid:opacity-60\";\n // A bare anchor: the clip box below owns the size, and no overflow lets the\n // badge overhang.\n carryEl.style.position = \"fixed\";\n\n const clone = source.cloneNode(true) as HTMLElement;\n // The source is faded while in flight; its copy must not inherit that.\n delete clone.dataset.dragging;\n delete clone.dataset.dropNoop;\n delete clone.dataset.dropEdge;\n if (rect.width > 0) clone.style.width = `${rect.width}px`;\n\n /*\n SANITIZED, because the clone lives on `<body>`: two elements would claim\n one node id, `aria-hidden` leaves real buttons in the tab order and must\n never wrap a focused one, and cloned ids make a `for` resolve to a copy.\n */\n const strip = (el: HTMLElement) => {\n el.removeAttribute(\"id\");\n el.removeAttribute(\"data-node-id\");\n el.removeAttribute(\"data-filter-cell\");\n if (el.dataset.slot === \"filter-row\") el.removeAttribute(\"data-slot\");\n // `-1` rather than removed: the attribute is also how the roving scheme\n // marks its cells, and a row copied mid-gesture has one cell at `0`.\n el.setAttribute(\"tabindex\", \"-1\");\n };\n strip(clone);\n for (const el of clone.querySelectorAll<HTMLElement>(\"*\")) strip(el);\n\n /*\n The CLIPPING box is the inner one: the carry is the badge's containing\n block, so `overflow-hidden` there clipped the badge that overhangs it.\n */\n const clip = document.createElement(\"div\");\n clip.className = \"bg-background overflow-hidden rounded-md\";\n // Sized only when the rect is real: a document that is not being laid out\n // measures zero, and a copy pinned to `0px` is invisible.\n if (rect.width > 0) clip.style.width = `${rect.width}px`;\n if (rect.height > 0) clip.style.height = `${rect.height}px`;\n clip.appendChild(clone);\n carryEl.appendChild(clip);\n\n badgeEl = document.createElement(\"span\");\n badgeEl.setAttribute(\"data-slot\", \"filters-drag-copy\");\n badgeEl.className =\n \"bg-primary text-primary-foreground absolute -end-1.5 -top-1.5 flex \" +\n \"size-4 items-center justify-center rounded-full text-[10px] leading-none\";\n badgeEl.textContent = \"+\";\n // Legible BEFORE the release, or Alt is discoverable only by error.\n badgeEl.hidden = !copy;\n carryEl.appendChild(badgeEl);\n\n // <body>, not the panel: a transform or a `content-visibility` on a wrapper\n // becomes the containing block for `position: fixed`, and the clone jumps.\n document.body.appendChild(carryEl);\n positionCarry(startX, startY);\n };\n\n const positionCarry = (x: number, y: number) => {\n if (!carryEl) return;\n // THE GRAB OFFSET, not a fixed nudge: the grip sits at the row's trailing\n // edge, so anchoring at the pointer hung the copy a row's width away.\n carryEl.style.transform = `translate3d(${snapToPixel(x - grabOffsetX)}px, ${snapToPixel(y - grabOffsetY)}px, 0)`;\n };\n\n // Two things decide the cursor and the RESOLUTION outranks Alt, which is why\n // `none` is tested first: `copy` over nothing is still nothing.\n const paintCursor = () => {\n if (!active) return;\n document.body.style.cursor = dropState === \"none\" ? \"no-drop\" : copy ? \"copy\" : \"grabbing\";\n };\n\n // Deliberately NOT guarded on `dropState === next`: the first resolution of a\n // gesture is routinely `\"none\"`, which is also the initial value, so a guard\n // left the first frame of a drag onto nothing wearing no mark at all.\n const setDropState = (next: typeof dropState) => {\n dropState = next;\n // On the SOURCE: \"it stays here\" is a statement about the row carried.\n if (next === \"noop\") source.dataset.dropNoop = \"\";\n else delete source.dataset.dropNoop;\n // And on the CARRY: over nothing there is no target left to mark.\n if (carryEl) {\n if (next === \"none\") carryEl.dataset.dropInvalid = \"\";\n else delete carryEl.dataset.dropInvalid;\n }\n paintCursor();\n };\n\n const setCopy = (next: boolean) => {\n if (copy === next) return;\n copy = next;\n if (badgeEl) badgeEl.hidden = !next;\n paintCursor();\n // Alt changes the ANSWER, not just the cursor: a release beside yourself is\n // a no-op while moving and a duplicate in place while copying.\n if (lastEvent) hitTest(lastEvent.clientX, lastEvent.clientY);\n };\n\n const hitTest = (x: number, y: number) => {\n if (!surface) return;\n // One subtraction instead of a re-measure. Read off the ELEMENT every time:\n // see `Surface.viewport`, a mirror misses the user's own scroll.\n const scrolled = surface.viewport?.scrollTop ?? surface.startScrollTop;\n const drift = scrolled - surface.startScrollTop;\n const resolved = resolveFilterDrop(surface.zones, surface.rows, x, y + drift);\n const noop = isFilterDropNoop(resolved, origin, copy);\n // A no-op commits as NOTHING, not as a move the tree would discard.\n hit = noop ? null : resolved;\n paint(surface, hit);\n setDropState(noop ? \"noop\" : hit ? \"ok\" : \"none\");\n };\n\n const autoScroll = (y: number) => {\n if (rafScroll) cancelAnimationFrame(rafScroll);\n rafScroll = 0;\n const viewport = surface?.viewport;\n const rect = surface?.viewportRect;\n if (!viewport || !rect) return;\n\n const edge = FILTER_DND_ACTIVATION.autoScrollEdgePx;\n const step = FILTER_DND_ACTIVATION.autoScrollMaxStepPx;\n let delta = 0;\n if (y >= rect.top && y < rect.top + edge) {\n delta = -step * ((rect.top + edge - y) / edge);\n } else if (y <= rect.bottom && y > rect.bottom - edge) {\n delta = step * Math.min(1, (y - (rect.bottom - edge)) / edge);\n }\n if (delta === 0) return;\n\n const tick = () => {\n // The read-back STOPS the loop: the browser clamps at the scroll extent,\n // so a panel at its limit would keep asking for unusable frames.\n const before = viewport.scrollTop;\n viewport.scrollTop = before + delta;\n if (viewport.scrollTop === before) return;\n if (lastEvent) hitTest(lastEvent.clientX, lastEvent.clientY);\n rafScroll = requestAnimationFrame(tick);\n };\n rafScroll = requestAnimationFrame(tick);\n };\n\n /**\n * A still pointer fires no `pointermove`, so a wheel mid-drag would leave the\n * last answer painted while the rows slid out from under it. The overlap\n * with the autoScroll tick is deliberate: this is arithmetic over boxes\n * already measured, and one redundant pass per frame is cheaper than a rule\n * about who owns the repaint.\n */\n const onViewportScroll = () => {\n if (!active || !lastEvent) return;\n hitTest(lastEvent.clientX, lastEvent.clientY);\n };\n\n const activate = () => {\n if (active) return;\n active = true;\n surface = collectSurface(root, source);\n\n // Passive: nothing here calls `preventDefault`, and a non-passive listener\n // on a scroller is a frame of jank per notch.\n surface.viewport?.addEventListener(\"scroll\", onViewportScroll, {\n passive: true,\n });\n source.dataset.dragging = \"\";\n document.body.style.cursor = copy ? \"copy\" : \"grabbing\";\n document.body.style.userSelect = \"none\";\n createCarry();\n // Armed with the GESTURE, not the press: a press that never travels far\n // enough strands no overlay, no body style and no listener.\n window.addEventListener(\"blur\", onWindowBlur);\n };\n\n // Idempotent. pointerup, pointercancel, Escape, window blur and the panel's\n // own teardown can all race; whichever lands first wins and the rest no-op.\n const cleanup = () => {\n if (finished) return;\n finished = true;\n activeCancels.delete(cancel);\n window.removeEventListener(\"pointermove\", onPointerMove);\n window.removeEventListener(\"pointerup\", onPointerUp);\n window.removeEventListener(\"pointercancel\", onPointerCancel);\n window.removeEventListener(\"keydown\", onKeyDown, true);\n window.removeEventListener(\"keyup\", onKeyUp, true);\n window.removeEventListener(\"blur\", onWindowBlur);\n surface?.viewport?.removeEventListener(\"scroll\", onViewportScroll);\n if (touchTimer) clearTimeout(touchTimer);\n if (rafScroll) cancelAnimationFrame(rafScroll);\n if (surface) paint(surface, null);\n delete source.dataset.dragging;\n delete source.dataset.dropNoop;\n carryEl?.remove();\n carryEl = null;\n badgeEl = null;\n document.body.style.cursor = \"\";\n document.body.style.userSelect = \"\";\n };\n\n /** A bare teardown: nothing is committed until release, so no snapshot. */\n const cancel = () => {\n if (active) lastDragEndedAt = performance.now();\n cleanup();\n };\n\n const onWindowBlur = () => cancel();\n\n const onKeyDown = (e: KeyboardEvent) => {\n if (e.key === \"Escape\" && active) {\n // Stopped, or the popover the builder may be living in closes underneath\n // the gesture and takes the panel the drop was aimed at with it.\n e.stopPropagation();\n e.preventDefault();\n cancel();\n return;\n }\n if (e.key === \"Alt\") setCopy(true);\n };\n\n // Alt tracked on its own keys too: reaching for the modifier without moving\n // the mouse fires no pointermove, and the badge has to appear regardless.\n const onKeyUp = (e: KeyboardEvent) => {\n if (e.key === \"Alt\") setCopy(false);\n };\n\n const onPointerMove = (e: PointerEvent) => {\n // A second finger must not drive or cancel the gesture this one started.\n if (e.pointerId !== pointerId) return;\n lastEvent = e;\n\n if (!active) {\n const distance = Math.hypot(e.clientX - startX, e.clientY - startY);\n if (isTouch) {\n // Past the tolerance the user is scrolling, so the press stays a scroll.\n if (distance > FILTER_DND_ACTIVATION.touchTolerancePx) cancel();\n return;\n }\n if (distance < FILTER_DND_ACTIVATION.moveDistancePx) return;\n activate();\n }\n\n setCopy(e.altKey);\n positionCarry(e.clientX, e.clientY);\n hitTest(e.clientX, e.clientY);\n autoScroll(e.clientY);\n };\n\n const onPointerUp = (e: PointerEvent) => {\n if (e.pointerId !== pointerId) return;\n const landed = active ? hit : null;\n const wasCopy = copy;\n cleanup();\n if (!active) return;\n\n lastDragEndedAt = performance.now();\n // The trailing click belongs to the gesture, not to whatever it ended over.\n window.addEventListener(\"click\", suppressTrailingClick, true);\n\n if (!landed) return;\n options.onDrop(nodeId, {\n parentId: landed.target.parentId,\n index: landed.target.index,\n copy: wasCopy,\n });\n };\n\n const onPointerCancel = (e: PointerEvent) => {\n if (e.pointerId !== pointerId) return;\n cancel();\n };\n\n window.addEventListener(\"pointermove\", onPointerMove);\n window.addEventListener(\"pointerup\", onPointerUp);\n window.addEventListener(\"pointercancel\", onPointerCancel);\n window.addEventListener(\"keydown\", onKeyDown, true);\n window.addEventListener(\"keyup\", onKeyUp, true);\n activeCancels.add(cancel);\n\n if (isTouch) {\n touchTimer = setTimeout(() => {\n activate();\n if (lastEvent) {\n positionCarry(lastEvent.clientX, lastEvent.clientY);\n hitTest(lastEvent.clientX, lastEvent.clientY);\n }\n }, FILTER_DND_ACTIVATION.touchDelayMs);\n }\n}\n\n/**\n * Only `onPointerDown`: the handle is a real button that Tab reaches, so it must\n * not also be `draggable` and race the browser's HTML5 drag, with its ghost, no\n * copy affordance and no way to report a drop into a nested target.\n */\nexport function useFilterRowDrag(options: FilterRowDragOptions) {\n // Read at gesture time, not captured at wiring time, so the handler identity\n // is stable and a memoized row never re-renders on a re-created callback.\n const latest = React.useRef(options);\n React.useEffect(() => {\n latest.current = options;\n });\n\n // A gesture outlives its row by design, but never the panel: its listeners\n // are on `window` and its carry on `document.body`.\n React.useEffect(() => cancelActiveFilterDrags, []);\n\n return React.useCallback(\n (nodeId: string) => ({\n onPointerDown: (event: React.PointerEvent<HTMLElement>) => {\n if (latest.current.disabled) return;\n // Primary button only: a right press strands the drag under a menu.\n if (event.button !== 0) return;\n startDrag(event, nodeId, latest.current);\n },\n }),\n [],\n );\n}\n"],"mappings":";;;;;;;;AASA,MAAa,wBAAwB;;CAEnC,gBAAgB;;CAEhB,cAAc;CACd,kBAAkB;CAClB,kBAAkB;CAClB,qBAAqB;;CAErB,sBAAsB;AACxB;;AAGA,MAAa,sBAAsB;;AAGnC,MAAa,4BAA4B;;AAGzC,MAAa,wBAAwB;AAsBrC,SAAS,SAAS,KAAoB,GAAW,GAAW,OAAO,GAAY;CAC7E,OAAO,KAAK,IAAI,QAAQ,KAAK,IAAI,SAAS,KAAK,IAAI,MAAM,QAAQ,KAAK,IAAI,SAAS;AACrF;;;;;;;;;;;;AAaA,MAAa,qBAAqB;;;;;;;AAQlC,SAAgB,kBACd,OACA,MACA,GACA,GACA,OAAA,GACgC;CAChC,IAAI,OAAiB;CACrB,KAAK,MAAM,aAAa,OAAO;EAC7B,IAAI,CAAC,SAAS,W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