impact-nova 2.5.12 → 2.5.13
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/components/data/data-table/build-column-tree-from-grid.d.ts +1 -0
- package/dist/components/data/data-table/build-column-tree-from-grid.js +55 -50
- package/dist/components/data/data-table/column-picker-authority.d.ts +34 -0
- package/dist/components/data/data-table/column-picker-authority.js +116 -0
- package/dist/components/data/data-table/column-picker-drop-validation.d.ts +7 -0
- package/dist/components/data/data-table/column-picker-drop-validation.js +37 -0
- package/dist/components/data/data-table/data-table-column-apply.d.ts +2 -0
- package/dist/components/data/data-table/data-table-column-apply.js +84 -73
- package/dist/components/data/data-table/data-table-column-list-tree-apply.d.ts +10 -0
- package/dist/components/data/data-table/data-table-column-list-tree-apply.js +79 -0
- package/dist/components/data/data-table/data-table-column-list.js +94 -64
- package/dist/components/data/data-table/data-table-column-tree-cache.d.ts +12 -6
- package/dist/components/data/data-table/data-table-column-tree-cache.js +250 -131
- package/dist/components/data/data-table/data-table-flat-column-virtual-rows.d.ts +26 -0
- package/dist/components/data/data-table/data-table-flat-column-virtual-rows.js +195 -0
- package/dist/components/data/data-table/data-table-picker-column-eligibility.d.ts +1 -0
- package/dist/components/data/data-table/data-table-picker-column-eligibility.js +7 -0
- package/dist/components/data/data-table/patch-column-tree-indicators-from-grid.d.ts +5 -0
- package/dist/components/data/data-table/patch-column-tree-indicators-from-grid.js +28 -11
- package/dist/components/data/data-table/reconcile-column-tree-from-grid.d.ts +12 -0
- package/dist/components/data/data-table/reconcile-column-tree-from-grid.js +12 -0
- package/dist/components/data/data-table/use-data-table-column-list-sync.d.ts +10 -0
- package/dist/components/data/data-table/use-data-table-column-list-sync.js +250 -196
- package/dist/components/data/nested-list/components/NestedListContent.d.ts +10 -2
- package/dist/components/data/nested-list/components/NestedListContent.js +253 -138
- package/dist/components/data/nested-list/components/SortableItem.d.ts +2 -1
- package/dist/components/data/nested-list/components/SortableItem.js +62 -60
- package/dist/components/data/nested-list/hooks/useNestedListDragDrop.d.ts +10 -20
- package/dist/components/data/nested-list/hooks/useNestedListDragDrop.js +44 -233
- package/dist/components/data/nested-list/hooks/useVirtualNestedListDrag.d.ts +24 -0
- package/dist/components/data/nested-list/hooks/useVirtualNestedListDrag.js +128 -0
- package/dist/components/data/nested-list/nested-list-constants.d.ts +4 -1
- package/dist/components/data/nested-list/nested-list-constants.js +10 -4
- package/dist/components/data/nested-list/nested-list-display-utils.d.ts +11 -0
- package/dist/components/data/nested-list/nested-list-display-utils.js +74 -0
- package/dist/components/data/nested-list/nested-list-drop-engine.d.ts +31 -0
- package/dist/components/data/nested-list/nested-list-drop-engine.js +209 -0
- package/dist/components/data/nested-list/nested-list-flat-virtual-handlers.d.ts +26 -0
- package/dist/components/data/nested-list/nested-list-flat-virtual-handlers.js +67 -0
- package/dist/components/data/nested-list/nested-list-item-tree-mutations.d.ts +4 -0
- package/dist/components/data/nested-list/nested-list-item-tree-mutations.js +43 -0
- package/dist/components/data/nested-list/nested-list-lazy-flat-rows.d.ts +3 -0
- package/dist/components/data/nested-list/nested-list-lazy-flat-rows.js +34 -0
- package/dist/components/data/nested-list/nested-list-row-estimates.d.ts +9 -0
- package/dist/components/data/nested-list/nested-list-row-estimates.js +14 -0
- package/dist/components/data/nested-list/nested-list-scroll-anchor.d.ts +36 -0
- package/dist/components/data/nested-list/nested-list-scroll-anchor.js +47 -0
- package/dist/components/data/nested-list/nested-list-virtual-drop.d.ts +59 -0
- package/dist/components/data/nested-list/nested-list-virtual-drop.js +341 -0
- package/dist/components/data/nested-list/nested-list.js +322 -336
- package/dist/components/data/nested-list/nested-list.types.d.ts +17 -0
- package/dist/components/data-display/calendar/calendar-apply-validation.d.ts +0 -2
- package/dist/components/data-display/calendar/calendar-apply-validation.js +67 -64
- package/dist/components/data-display/calendar/calendar-config.js +1 -1
- package/dist/components/data-display/calendar/calendar-day-picker-components.d.ts +2 -4
- package/dist/components/data-display/calendar/calendar-day-picker-components.js +164 -234
- package/dist/components/data-display/calendar/calendar-day-picker-view.js +76 -77
- package/dist/components/data-display/calendar/calendar-fiscal-period-nav.d.ts +0 -6
- package/dist/components/data-display/calendar/calendar-fiscal-period-nav.js +18 -34
- package/dist/components/data-display/calendar/calendar-footer.js +21 -21
- package/dist/components/data-display/calendar/calendar-month-picker-panel.js +49 -50
- package/dist/components/data-display/calendar/calendar-month-utils.d.ts +0 -5
- package/dist/components/data-display/calendar/calendar-month-utils.js +64 -85
- package/dist/components/data-display/calendar/calendar-padding-week.utils.d.ts +1 -3
- package/dist/components/data-display/calendar/calendar-padding-week.utils.js +5 -7
- package/dist/components/data-display/calendar/calendar-period-cell.js +46 -45
- package/dist/components/data-display/calendar/calendar-quarter-panes.js +31 -33
- package/dist/components/data-display/calendar/calendar-selection-appearance.d.ts +0 -10
- package/dist/components/data-display/calendar/calendar-selection-appearance.js +39 -53
- package/dist/components/data-display/calendar/calendar-selection.d.ts +0 -25
- package/dist/components/data-display/calendar/calendar-selection.js +23 -52
- package/dist/components/data-display/calendar/calendar-week-number-cell.d.ts +1 -2
- package/dist/components/data-display/calendar/calendar-week-number-cell.js +45 -59
- package/dist/components/data-display/calendar/calendar-week-utils.d.ts +3 -13
- package/dist/components/data-display/calendar/calendar-week-utils.js +50 -59
- package/dist/components/data-display/calendar/calendar-year-panes.d.ts +0 -3
- package/dist/components/data-display/calendar/calendar-year-panes.js +49 -53
- package/dist/components/data-display/calendar/calendar.js +143 -146
- package/dist/components/data-display/calendar/calendar.types.d.ts +0 -5
- package/dist/components/data-display/calendar/use-calendar-day-picker-config.d.ts +1 -2
- package/dist/components/data-display/calendar/use-calendar-day-picker-config.js +74 -79
- package/dist/components/data-display/calendar/use-calendar-state.d.ts +1 -3
- package/dist/components/data-display/calendar/use-calendar-state.js +325 -403
- package/dist/components/forms/date-picker/date-picker.js +58 -60
- package/dist/components/forms/date-picker/date-picker.types.d.ts +0 -5
- package/dist/components/forms/date-picker/date-range-picker.js +64 -66
- package/dist/components/forms/date-picker/fiscal-pass-through.d.ts +0 -1
- package/dist/components/forms/date-picker/fiscal-pass-through.js +2 -3
- package/dist/components/forms/date-picker/month-picker.js +59 -61
- package/dist/components/forms/date-picker/month-range-picker.js +61 -63
- package/dist/components/forms/date-picker/multi-date-picker.js +49 -51
- package/dist/components/forms/date-picker/multi-month-picker.js +47 -49
- package/dist/components/forms/date-picker/multi-quarter-picker.js +47 -51
- package/dist/components/forms/date-picker/multi-week-picker.js +51 -53
- package/dist/components/forms/date-picker/multi-year-picker.js +49 -53
- package/dist/components/forms/date-picker/quarter-picker.js +47 -51
- package/dist/components/forms/date-picker/quarter-range-picker.js +46 -50
- package/dist/components/forms/date-picker/week-picker.js +66 -68
- package/dist/components/forms/date-picker/week-range-picker.js +80 -82
- package/dist/components/forms/date-picker/year-picker.js +48 -52
- package/dist/components/forms/date-picker/year-range-picker.js +48 -52
- package/dist/form-react/Fields/DateInputField.js +50 -51
- package/dist/form-react/Fields/DateRangeField.js +13 -14
- package/dist/form-react/Fields/MonthRangeField.js +28 -29
- package/dist/form-react/Fields/MultiMonthPickerField.js +12 -13
- package/dist/form-react/Fields/MultiWeekPickerField.js +27 -35
- package/dist/form-react/Fields/WeekRangePicker.js +32 -33
- package/dist/form-react/types/fields.types.d.ts +0 -14
- package/dist/impact-nova-components.css +6 -13
- package/dist/impact-nova.css +1 -1
- package/dist/lib/fiscal-calendar/week-selection.js +2 -2
- package/dist/lib/hash/fnv1a128.d.ts +16 -0
- package/dist/lib/hash/fnv1a128.js +21 -0
- package/dist/llms/rules/ag-grid.js +1 -1
- package/dist/llms/rules/installation.js +1 -1
- package/dist/llms/rules/requirements.js +1 -1
- package/package.json +1 -1
- package/dist/components/data-display/calendar/calendar-available-view.d.ts +0 -27
- package/dist/components/data-display/calendar/calendar-available-view.js +0 -85
- package/dist/components/data-display/calendar/calendar-fiscal-day-cell.d.ts +0 -9
- package/dist/components/data-display/calendar/calendar-fiscal-day-cell.js +0 -45
- package/dist/components/data-display/calendar/calendar-injected-week-row.d.ts +0 -5
- package/dist/components/data-display/calendar/calendar-injected-week-row.js +0 -92
- package/dist/components/data-display/calendar/calendar-leading-week.utils.d.ts +0 -16
- package/dist/components/data-display/calendar/calendar-leading-week.utils.js +0 -51
- package/dist/components/data-display/calendar/calendar-orphan-week.d.ts +0 -23
- package/dist/components/forms/date-picker/fiscal-picker-fixtures.d.ts +0 -17
|
@@ -1,45 +1,46 @@
|
|
|
1
1
|
import { jsx as t, jsxs as c } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
3
|
-
import { useSortable as
|
|
4
|
-
import { useDroppable as
|
|
5
|
-
import { Checkbox as
|
|
6
|
-
import { ChevronRight as
|
|
2
|
+
import j, { useMemo as _ } from "react";
|
|
3
|
+
import { useSortable as D } from "@dnd-kit/sortable";
|
|
4
|
+
import { useDroppable as H } from "@dnd-kit/core";
|
|
5
|
+
import { Checkbox as $ } from "../../../forms/checkbox/checkbox.js";
|
|
6
|
+
import { ChevronRight as E, Drag as z } from "impact-nova-icons";
|
|
7
7
|
import { cn as d } from "../../../../lib/utils.js";
|
|
8
|
-
import { useImpactNovaI18n as
|
|
9
|
-
import { isNestedListSubtreeIndeterminate as
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
return e ? d(
|
|
13
|
-
},
|
|
14
|
-
const { t: n } =
|
|
15
|
-
setNodeRef:
|
|
8
|
+
import { useImpactNovaI18n as N } from "../../../../i18n/use-impact-nova-i18n.js";
|
|
9
|
+
import { isNestedListSubtreeIndeterminate as A } from "../nested-list-tree-utils.js";
|
|
10
|
+
const O = "flex shrink-0 items-center h-5 gap-0.5", P = "flex h-5 w-4 shrink-0 items-center justify-center", V = "flex h-5 w-5 shrink-0 cursor-grab active:cursor-grabbing items-center justify-center rounded-sm text-content-icon transition-colors hover:bg-canvas-muted hover:text-content", G = (e, r) => {
|
|
11
|
+
const a = "group flex items-start gap-2 py-1 pr-2 rounded transition-colors duration-150 min-w-0";
|
|
12
|
+
return e ? d(a, "opacity-40 bg-canvas-muted") : r ? d(a, "bg-feedback-error-surface border border-destructive animate-pulse") : d(a, "hover:bg-canvas-muted");
|
|
13
|
+
}, M = ({ item: e, isAnyDragging: r, renderActions: a }) => {
|
|
14
|
+
const { t: n } = N(), l = e.data?.hasVirtualColumnChildren === !0, s = (!e.children || e.children.length === 0) && !l, {
|
|
15
|
+
setNodeRef: h,
|
|
16
16
|
isOver: o
|
|
17
|
-
} =
|
|
17
|
+
} = H({
|
|
18
18
|
id: `droppable-${e.id}`,
|
|
19
19
|
data: { sectionId: e.id },
|
|
20
|
-
disabled: !
|
|
20
|
+
disabled: !s
|
|
21
21
|
});
|
|
22
|
-
return /* @__PURE__ */ c("div", { ref:
|
|
22
|
+
return /* @__PURE__ */ c("div", { ref: s ? h : void 0, children: [
|
|
23
23
|
/* @__PURE__ */ c(
|
|
24
24
|
"div",
|
|
25
25
|
{
|
|
26
26
|
className: d(
|
|
27
27
|
"flex items-center justify-between px-2 py-0 text-xs font-[500] leading-4 text-navigation-muted select-none",
|
|
28
28
|
e.id === "root-scrollable" ? "mt-2 pt-2 pb-1 border-t border-solid border-stroke-subtle" : "mt-1 pb-1",
|
|
29
|
-
o && r &&
|
|
29
|
+
o && r && s && "bg-canvas-tint rounded"
|
|
30
30
|
),
|
|
31
31
|
children: [
|
|
32
32
|
/* @__PURE__ */ c("div", { className: "flex items-center", children: [
|
|
33
33
|
e.label,
|
|
34
|
-
o && r &&
|
|
34
|
+
o && r && s && /* @__PURE__ */ t("span", { className: "ml-2 text-brand text-[11px]", children: n("nestedList.dropHere") })
|
|
35
35
|
] }),
|
|
36
|
-
|
|
36
|
+
a?.(e, { isLeaf: !1, level: 0 })
|
|
37
37
|
]
|
|
38
38
|
}
|
|
39
39
|
),
|
|
40
|
-
|
|
40
|
+
s && /* @__PURE__ */ t(
|
|
41
41
|
"div",
|
|
42
42
|
{
|
|
43
|
+
"data-section-droppable": e.id,
|
|
43
44
|
className: d(
|
|
44
45
|
"mx-2 my-1 rounded border-2 border-dashed min-h-[36px] flex items-center justify-center text-[11px] transition-colors",
|
|
45
46
|
o && r ? "border-brand bg-canvas-tint text-brand" : "border-stroke-hairline text-content-empty"
|
|
@@ -48,36 +49,37 @@ const z = "flex shrink-0 items-center h-5 gap-0.5", A = "flex h-5 w-4 shrink-0 i
|
|
|
48
49
|
}
|
|
49
50
|
)
|
|
50
51
|
] });
|
|
51
|
-
},
|
|
52
|
+
}, T = ({
|
|
52
53
|
item: e,
|
|
53
54
|
level: r,
|
|
54
|
-
indentLevel:
|
|
55
|
+
indentLevel: a,
|
|
55
56
|
isCollapsed: n,
|
|
56
|
-
onToggle:
|
|
57
|
-
onToggleCollapse:
|
|
58
|
-
isAnyDragging:
|
|
59
|
-
enableDragDrop:
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
57
|
+
onToggle: l,
|
|
58
|
+
onToggleCollapse: s,
|
|
59
|
+
isAnyDragging: h = !1,
|
|
60
|
+
enableDragDrop: o = !0,
|
|
61
|
+
dragMode: k = "sortable",
|
|
62
|
+
enableCollapse: L = !0,
|
|
63
|
+
shouldBlink: y = !1,
|
|
64
|
+
isDragDisabled: m = !1,
|
|
65
|
+
renderLabelExtras: x,
|
|
66
|
+
renderActions: v
|
|
65
67
|
}) => {
|
|
66
|
-
const { t:
|
|
67
|
-
attributes:
|
|
68
|
+
const { t: u } = N(), g = e.category === "structure", p = e.children && e.children.length > 0, b = !p && e.category !== "structure", C = _(() => !e.children || e.children.length === 0 ? !1 : A(e.children), [e.children]), f = k === "virtual-index", {
|
|
69
|
+
attributes: I,
|
|
68
70
|
listeners: S,
|
|
69
71
|
setNodeRef: w,
|
|
70
|
-
isDragging:
|
|
71
|
-
} =
|
|
72
|
+
isDragging: R
|
|
73
|
+
} = D({
|
|
72
74
|
id: e.id,
|
|
73
75
|
data: {
|
|
74
76
|
level: r,
|
|
75
77
|
hasChildren: p,
|
|
76
78
|
isExpanded: !n
|
|
77
79
|
},
|
|
78
|
-
disabled:
|
|
80
|
+
disabled: g || e.disabled || m || f
|
|
79
81
|
});
|
|
80
|
-
return
|
|
82
|
+
return g ? /* @__PURE__ */ t(M, { item: e, isAnyDragging: h, renderActions: v }) : /* @__PURE__ */ t(
|
|
81
83
|
"div",
|
|
82
84
|
{
|
|
83
85
|
ref: w,
|
|
@@ -90,24 +92,24 @@ const z = "flex shrink-0 items-center h-5 gap-0.5", A = "flex h-5 w-4 shrink-0 i
|
|
|
90
92
|
children: /* @__PURE__ */ c(
|
|
91
93
|
"div",
|
|
92
94
|
{
|
|
93
|
-
className:
|
|
95
|
+
className: G(R, y),
|
|
94
96
|
style: {
|
|
95
|
-
paddingLeft: `${8 +
|
|
97
|
+
paddingLeft: `${8 + a * 20}px`
|
|
96
98
|
},
|
|
97
99
|
children: [
|
|
98
|
-
/* @__PURE__ */ c("div", { className:
|
|
99
|
-
/* @__PURE__ */ t("div", { className:
|
|
100
|
+
/* @__PURE__ */ c("div", { className: O, children: [
|
|
101
|
+
/* @__PURE__ */ t("div", { className: P, children: L && p && /* @__PURE__ */ t(
|
|
100
102
|
"button",
|
|
101
103
|
{
|
|
102
104
|
type: "button",
|
|
103
105
|
onClick: (i) => {
|
|
104
|
-
i.stopPropagation(),
|
|
106
|
+
i.stopPropagation(), s(e.id);
|
|
105
107
|
},
|
|
106
108
|
onMouseDown: (i) => i.stopPropagation(),
|
|
107
109
|
className: "flex h-4 w-4 items-center justify-center rounded-full p-0 hover:bg-canvas-muted transition-colors text-content-icon hover:text-brand",
|
|
108
|
-
"aria-label":
|
|
110
|
+
"aria-label": u(n ? "nestedList.expand" : "nestedList.collapse"),
|
|
109
111
|
children: /* @__PURE__ */ t(
|
|
110
|
-
|
|
112
|
+
E,
|
|
111
113
|
{
|
|
112
114
|
size: "16px",
|
|
113
115
|
className: d("transition-transform", !n && "rotate-90")
|
|
@@ -116,23 +118,23 @@ const z = "flex shrink-0 items-center h-5 gap-0.5", A = "flex h-5 w-4 shrink-0 i
|
|
|
116
118
|
}
|
|
117
119
|
) }),
|
|
118
120
|
/* @__PURE__ */ t("div", { className: "flex h-5 w-4 shrink-0 items-center justify-center", children: /* @__PURE__ */ t(
|
|
119
|
-
|
|
121
|
+
$,
|
|
120
122
|
{
|
|
121
123
|
id: `checkbox-${e.id}`,
|
|
122
|
-
checked:
|
|
123
|
-
onCheckedChange: () =>
|
|
124
|
+
checked: C ? "indeterminate" : e.checked,
|
|
125
|
+
onCheckedChange: () => l(e.id),
|
|
124
126
|
disabled: e.disabled,
|
|
125
127
|
className: "mr-0",
|
|
126
128
|
"aria-label": e.label
|
|
127
129
|
}
|
|
128
130
|
) }),
|
|
129
|
-
|
|
131
|
+
o && !m ? /* @__PURE__ */ t(
|
|
130
132
|
"div",
|
|
131
133
|
{
|
|
132
|
-
...
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
134
|
+
...f ? {} : { ...I, ...S },
|
|
135
|
+
"aria-label": `${u("aria.dragHandle")}: ${e.label}`,
|
|
136
|
+
className: V,
|
|
137
|
+
"data-drag-handle": "true",
|
|
136
138
|
style: {
|
|
137
139
|
pointerEvents: "auto",
|
|
138
140
|
position: "relative",
|
|
@@ -140,9 +142,9 @@ const z = "flex shrink-0 items-center h-5 gap-0.5", A = "flex h-5 w-4 shrink-0 i
|
|
|
140
142
|
touchAction: "none"
|
|
141
143
|
},
|
|
142
144
|
onPointerDown: (i) => {
|
|
143
|
-
i.stopPropagation();
|
|
145
|
+
f || i.stopPropagation();
|
|
144
146
|
},
|
|
145
|
-
children: /* @__PURE__ */ t(
|
|
147
|
+
children: /* @__PURE__ */ t(z, { size: "14px" })
|
|
146
148
|
}
|
|
147
149
|
) : /* @__PURE__ */ t("div", { className: "w-5 shrink-0", "aria-hidden": !0 })
|
|
148
150
|
] }),
|
|
@@ -154,16 +156,16 @@ const z = "flex shrink-0 items-center h-5 gap-0.5", A = "flex h-5 w-4 shrink-0 i
|
|
|
154
156
|
children: /* @__PURE__ */ t("span", { className: "break-words", children: e.label })
|
|
155
157
|
}
|
|
156
158
|
),
|
|
157
|
-
|
|
158
|
-
/* @__PURE__ */ t("div", { className: "shrink-0 self-center flex items-center", children:
|
|
159
|
+
x?.(e, { isLeaf: b, level: r }) ? /* @__PURE__ */ t("div", { className: "shrink-0 self-center flex items-center", children: x(e, { isLeaf: b, level: r }) }) : null,
|
|
160
|
+
/* @__PURE__ */ t("div", { className: "shrink-0 self-center flex items-center", children: v?.(e, { isLeaf: b, level: r }) })
|
|
159
161
|
]
|
|
160
162
|
}
|
|
161
163
|
)
|
|
162
164
|
}
|
|
163
165
|
);
|
|
164
|
-
},
|
|
166
|
+
}, Y = j.memo(T);
|
|
165
167
|
export {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
168
|
+
V as DRAG_HANDLE_CLASS,
|
|
169
|
+
O as LEADING_RAIL_CLASS,
|
|
170
|
+
Y as SortableItem
|
|
169
171
|
};
|
|
@@ -1,34 +1,24 @@
|
|
|
1
1
|
import { DragEndEvent, CollisionDetection } from '@dnd-kit/core';
|
|
2
2
|
import { NestedListItem } from '../nested-list.types';
|
|
3
|
-
|
|
4
|
-
* Custom collision detection: closestCorners but filters out section header
|
|
5
|
-
* sortable nodes from results. This prevents headers from "stealing" drops
|
|
6
|
-
* that should target child items.
|
|
7
|
-
*
|
|
8
|
-
* - When children exist nearby: header is filtered → closest child wins →
|
|
9
|
-
* handleCrossParentReorder gives precise positioning
|
|
10
|
-
* - When section is empty: only the droppable node (droppable-root-*)
|
|
11
|
-
* exists → not filtered → handleDropOnSection handles it
|
|
12
|
-
* - Edge case (no children nearby): headers are included as fallback
|
|
13
|
-
*/
|
|
3
|
+
import { findNestedListItemLevel, findNestedListParentId } from '../nested-list-drop-engine';
|
|
14
4
|
export declare const customCollisionDetection: CollisionDetection;
|
|
15
|
-
declare function findItemLevel(items: NestedListItem[], itemId: string, currentLevel?: number): number | null;
|
|
16
|
-
declare function findParentId(items: NestedListItem[], itemId: string, parentId?: string | null): string | null;
|
|
17
|
-
/**
|
|
18
|
-
* Find the direct child of a section that contains (or is) the given item.
|
|
19
|
-
* Returns the level-1 ancestor's ID within the section.
|
|
20
|
-
*/
|
|
21
5
|
interface UseNestedListDragDropProps {
|
|
22
6
|
items: NestedListItem[];
|
|
23
7
|
onDragEnd?: (activeId: string, overId: string | null) => void;
|
|
24
8
|
collapsedItems?: Record<string, boolean>;
|
|
25
9
|
canDrag?: (item: NestedListItem, level: number) => boolean;
|
|
10
|
+
isValidDropTarget?: (options: {
|
|
11
|
+
activeItemId: string;
|
|
12
|
+
overItemId: string;
|
|
13
|
+
items: NestedListItem[];
|
|
14
|
+
insertAfter?: boolean;
|
|
15
|
+
}) => boolean;
|
|
26
16
|
}
|
|
27
|
-
export declare const useNestedListDragDrop: ({ items, onDragEnd, collapsedItems, canDrag, }: UseNestedListDragDropProps) => {
|
|
17
|
+
export declare const useNestedListDragDrop: ({ items, onDragEnd, collapsedItems, canDrag, isValidDropTarget, }: UseNestedListDragDropProps) => {
|
|
28
18
|
sensors: import('@dnd-kit/core').SensorDescriptor<import('@dnd-kit/core').SensorOptions>[];
|
|
29
19
|
handleDragEnd: (event: DragEndEvent, setItems: (updater: (prevItems: NestedListItem[]) => NestedListItem[]) => void) => void;
|
|
30
20
|
isValidDrop: (activeItemId: string | null, overItemId: string | null) => boolean;
|
|
31
|
-
findItemLevel: typeof
|
|
32
|
-
findParentId: typeof
|
|
21
|
+
findItemLevel: typeof findNestedListItemLevel;
|
|
22
|
+
findParentId: typeof findNestedListParentId;
|
|
33
23
|
};
|
|
34
24
|
export {};
|
|
@@ -1,247 +1,58 @@
|
|
|
1
|
-
import { useCallback as
|
|
2
|
-
import { useSensors as
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
if (_.has(r)) return r;
|
|
9
|
-
}
|
|
10
|
-
return null;
|
|
11
|
-
}
|
|
12
|
-
function q(f, r, d) {
|
|
13
|
-
return f.map((e) => {
|
|
14
|
-
if (e.children && e.children.length > 0) {
|
|
15
|
-
const C = e.children.findIndex(
|
|
16
|
-
(P) => P.id === r
|
|
17
|
-
), b = e.children.findIndex(
|
|
18
|
-
(P) => P.id === d
|
|
19
|
-
);
|
|
20
|
-
if (C !== -1 && b !== -1) {
|
|
21
|
-
const P = k(e.children, C, b);
|
|
22
|
-
return {
|
|
23
|
-
...e,
|
|
24
|
-
children: P
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
return {
|
|
28
|
-
...e,
|
|
29
|
-
children: q(e.children, r, d)
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
return e;
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
const nn = (f) => {
|
|
36
|
-
const r = p(f), d = r.filter(
|
|
37
|
-
(e) => !_.has(e.id)
|
|
1
|
+
import { useCallback as S } from "react";
|
|
2
|
+
import { useSensors as C, useSensor as N, MouseSensor as _, TouchSensor as b, closestCenter as x } from "@dnd-kit/core";
|
|
3
|
+
import { applyNestedListDragEndEvent as y, findNestedListItemById as P, findNestedListItemLevel as L, getSectionIdFromDroppable as k, findNestedListParentId as B } from "../nested-list-drop-engine.js";
|
|
4
|
+
import { NESTED_LIST_SECTION_IDS as d } from "../nested-list-constants.js";
|
|
5
|
+
const j = (r) => {
|
|
6
|
+
const u = x(r), l = u.filter(
|
|
7
|
+
(t) => !d.has(t.id)
|
|
38
8
|
);
|
|
39
|
-
return
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
if (e) return e;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
function T(f, r, d = 0) {
|
|
51
|
-
for (const e of f) {
|
|
52
|
-
if (e.id === r) return d;
|
|
53
|
-
if (e.children) {
|
|
54
|
-
const C = T(e.children, r, d + 1);
|
|
55
|
-
if (C !== null) return C;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
return null;
|
|
59
|
-
}
|
|
60
|
-
function G(f, r, d = null) {
|
|
61
|
-
for (const e of f) {
|
|
62
|
-
if (e.id === r) return d;
|
|
63
|
-
if (e.children) {
|
|
64
|
-
const C = G(e.children, r, e.id);
|
|
65
|
-
if (C !== null) return C;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
return null;
|
|
69
|
-
}
|
|
70
|
-
function j(f, r) {
|
|
71
|
-
for (const d of f) {
|
|
72
|
-
if (d.id === r) return null;
|
|
73
|
-
if (d.children && M(d.children, r))
|
|
74
|
-
return d.id;
|
|
75
|
-
}
|
|
76
|
-
return null;
|
|
77
|
-
}
|
|
78
|
-
const rn = ({
|
|
79
|
-
items: f,
|
|
80
|
-
onDragEnd: r,
|
|
81
|
-
collapsedItems: d = {},
|
|
82
|
-
canDrag: e
|
|
9
|
+
return l.length > 0 ? l : u;
|
|
10
|
+
}, q = ({
|
|
11
|
+
items: r,
|
|
12
|
+
onDragEnd: u,
|
|
13
|
+
collapsedItems: l = {},
|
|
14
|
+
canDrag: t,
|
|
15
|
+
isValidDropTarget: f
|
|
83
16
|
}) => {
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
),
|
|
88
|
-
(
|
|
89
|
-
const
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
const i = k(
|
|
98
|
-
o,
|
|
99
|
-
t,
|
|
100
|
-
n
|
|
101
|
-
);
|
|
102
|
-
return r?.(c, s), i;
|
|
103
|
-
}
|
|
104
|
-
return null;
|
|
105
|
-
},
|
|
106
|
-
[r]
|
|
107
|
-
), P = F(
|
|
108
|
-
(o, c, u) => {
|
|
109
|
-
const s = o.findIndex((t) => t.id === c), n = o.findIndex((t) => t.id === u);
|
|
110
|
-
if (s !== -1 && n !== -1) {
|
|
111
|
-
const t = k(o, s, n);
|
|
112
|
-
return r?.(c, u), t;
|
|
113
|
-
}
|
|
114
|
-
return null;
|
|
115
|
-
},
|
|
116
|
-
[r]
|
|
117
|
-
), z = F(
|
|
118
|
-
(o, c, u) => {
|
|
119
|
-
const s = q(o, c, u);
|
|
120
|
-
return r?.(c, u), s;
|
|
121
|
-
},
|
|
122
|
-
[r]
|
|
123
|
-
), w = F(
|
|
124
|
-
(o, c, u, s = !1) => {
|
|
125
|
-
const n = M(o, c);
|
|
126
|
-
if (!n) return null;
|
|
127
|
-
const t = (h) => h.filter((l) => l.id !== c).map(
|
|
128
|
-
(l) => l.children ? { ...l, children: t(l.children) } : l
|
|
129
|
-
).filter((l) => !(l.children && l.children.length === 0 && l.category === "group")), i = M(o, u), a = !n.children || n.children.length === 0, R = i?.children && i.children.length > 0, Y = d[u] === !0, B = a && R && !Y && s, N = (h) => {
|
|
130
|
-
for (let l = 0; l < h.length; l++) {
|
|
131
|
-
if (h[l].id === u)
|
|
132
|
-
if (B) {
|
|
133
|
-
const L = {
|
|
134
|
-
...h[l],
|
|
135
|
-
children: [n, ...h[l].children || []]
|
|
136
|
-
}, x = [...h];
|
|
137
|
-
return x[l] = L, { nodes: x, inserted: !0 };
|
|
138
|
-
} else {
|
|
139
|
-
const L = [...h], x = s ? l + 1 : l;
|
|
140
|
-
return L.splice(x, 0, n), { nodes: L, inserted: !0 };
|
|
141
|
-
}
|
|
142
|
-
if (h[l].children) {
|
|
143
|
-
const L = N(h[l].children);
|
|
144
|
-
if (L.inserted) {
|
|
145
|
-
const x = [...h];
|
|
146
|
-
return x[l] = { ...h[l], children: L.nodes }, { nodes: x, inserted: !0 };
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
return { nodes: h, inserted: !1 };
|
|
151
|
-
}, S = t(o), { nodes: O, inserted: g } = N(S);
|
|
152
|
-
return g ? (r?.(c, u), O) : null;
|
|
153
|
-
},
|
|
154
|
-
[r, d]
|
|
155
|
-
), A = F(
|
|
156
|
-
(o, c, u) => {
|
|
157
|
-
const s = M(o, c);
|
|
158
|
-
if (!s) return o;
|
|
159
|
-
const n = (i) => i.filter((a) => a.id !== c).map(
|
|
160
|
-
(a) => a.children ? { ...a, children: n(a.children) } : a
|
|
161
|
-
), t = o.map((i) => {
|
|
162
|
-
let a = i.children ? n(i.children) : [];
|
|
163
|
-
return i.id === u && (a = [s, ...a]), { ...i, children: a };
|
|
164
|
-
});
|
|
165
|
-
return r?.(c, u), t;
|
|
166
|
-
},
|
|
167
|
-
[r]
|
|
168
|
-
), J = F(
|
|
169
|
-
(o, c) => {
|
|
170
|
-
const { active: u, over: s } = o;
|
|
171
|
-
!s || u.id === s.id || c((n) => {
|
|
172
|
-
const t = u.id, i = s.id;
|
|
173
|
-
if (e) {
|
|
174
|
-
const S = M(n, t), O = T(n, t);
|
|
175
|
-
if (S && O !== null && !e(S, O))
|
|
176
|
-
return n;
|
|
177
|
-
}
|
|
178
|
-
const a = X(i);
|
|
179
|
-
if (a)
|
|
180
|
-
return A(n, t, a);
|
|
181
|
-
const R = T(n, t), Y = T(n, i), B = G(n, t), N = G(n, i);
|
|
182
|
-
if (_.has(i) && R !== null && R > 0)
|
|
183
|
-
return A(n, t, i);
|
|
184
|
-
if (R === 0 && Y !== null && Y > 0)
|
|
185
|
-
return b(
|
|
186
|
-
n,
|
|
187
|
-
t,
|
|
188
|
-
i
|
|
189
|
-
) || n;
|
|
190
|
-
if (R === null || Y === null)
|
|
191
|
-
return n;
|
|
192
|
-
if (R > 0 && Y > 0 && B !== N) {
|
|
193
|
-
const S = j(n, t), O = j(n, i);
|
|
194
|
-
if (S && O && S !== O) {
|
|
195
|
-
const x = u.rect.current.translated, y = s.rect;
|
|
196
|
-
let H = !1;
|
|
197
|
-
if (x && y) {
|
|
198
|
-
const Q = x.top + x.height / 2, U = y.top + y.height / 2;
|
|
199
|
-
H = Q > U;
|
|
200
|
-
}
|
|
201
|
-
return w(n, t, i, H) || n;
|
|
202
|
-
}
|
|
203
|
-
const g = u.rect.current.translated, h = s.rect;
|
|
204
|
-
let l = !1;
|
|
205
|
-
if (g && h) {
|
|
206
|
-
const x = g.top + g.height / 2, y = h.top + h.height / 2;
|
|
207
|
-
l = x > y;
|
|
208
|
-
}
|
|
209
|
-
return w(n, t, i, l) || n;
|
|
210
|
-
}
|
|
211
|
-
return R === 0 ? P(n, t, i) || n : z(n, t, i);
|
|
17
|
+
const h = C(
|
|
18
|
+
N(_),
|
|
19
|
+
N(b)
|
|
20
|
+
), p = S(
|
|
21
|
+
(n, e) => {
|
|
22
|
+
const { active: o, over: s } = n;
|
|
23
|
+
!s || o.id === s.id || e((i) => {
|
|
24
|
+
const c = y(i, n, {
|
|
25
|
+
collapsedItems: l,
|
|
26
|
+
canDrag: t,
|
|
27
|
+
isValidDropTarget: f
|
|
28
|
+
});
|
|
29
|
+
return c !== i && u?.(o.id, s.id), c;
|
|
212
30
|
});
|
|
213
31
|
},
|
|
214
|
-
[
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
w,
|
|
219
|
-
A,
|
|
220
|
-
e
|
|
221
|
-
]
|
|
222
|
-
), K = F(
|
|
223
|
-
(o, c) => {
|
|
224
|
-
if (!o || !c || o === c)
|
|
32
|
+
[l, t, f, u]
|
|
33
|
+
), E = S(
|
|
34
|
+
(n, e) => {
|
|
35
|
+
if (!n || !e || n === e || f && !f({ activeItemId: n, overItemId: e, items: r }))
|
|
225
36
|
return !1;
|
|
226
|
-
if (
|
|
227
|
-
const
|
|
228
|
-
if (
|
|
37
|
+
if (t) {
|
|
38
|
+
const i = P(r, n), c = L(r, n);
|
|
39
|
+
if (i && c !== null && !t(i, c))
|
|
229
40
|
return !1;
|
|
230
41
|
}
|
|
231
|
-
const
|
|
232
|
-
return
|
|
42
|
+
const o = n ? L(r, n) : null, s = e ? L(r, e) : null;
|
|
43
|
+
return k(e) !== null || d.has(e) ? !0 : o === null || s === null ? !1 : o === 0 && s > 0 || o === s || o > 0 && s > 0;
|
|
233
44
|
},
|
|
234
|
-
[
|
|
45
|
+
[r, t, f]
|
|
235
46
|
);
|
|
236
47
|
return {
|
|
237
|
-
sensors:
|
|
238
|
-
handleDragEnd:
|
|
239
|
-
isValidDrop:
|
|
240
|
-
findItemLevel:
|
|
241
|
-
findParentId:
|
|
48
|
+
sensors: h,
|
|
49
|
+
handleDragEnd: p,
|
|
50
|
+
isValidDrop: E,
|
|
51
|
+
findItemLevel: L,
|
|
52
|
+
findParentId: B
|
|
242
53
|
};
|
|
243
54
|
};
|
|
244
55
|
export {
|
|
245
|
-
|
|
246
|
-
|
|
56
|
+
j as customCollisionDetection,
|
|
57
|
+
q as useNestedListDragDrop
|
|
247
58
|
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { NestedListItem } from '../nested-list.types';
|
|
2
|
+
import { FlatNestedListRow, VirtualDropRowGeometry, VirtualDropTarget } from '../nested-list-virtual-drop';
|
|
3
|
+
export type VirtualDragSession = {
|
|
4
|
+
draggedId: string;
|
|
5
|
+
draggedItem: NestedListItem;
|
|
6
|
+
dropTarget: VirtualDropTarget | null;
|
|
7
|
+
pointerX: number;
|
|
8
|
+
pointerY: number;
|
|
9
|
+
isPointerInsideScrollContainer: boolean;
|
|
10
|
+
} | null;
|
|
11
|
+
export interface UseVirtualNestedListDragOptions {
|
|
12
|
+
items: FlatNestedListRow[];
|
|
13
|
+
scrollElementRef: React.RefObject<HTMLDivElement | null>;
|
|
14
|
+
virtualizer: VirtualDropRowGeometry;
|
|
15
|
+
estimateRowSize: (index: number) => number;
|
|
16
|
+
onDrop: (activeId: string, overId: string, insertAfter: boolean) => void;
|
|
17
|
+
collapsedItems?: Record<string, boolean>;
|
|
18
|
+
}
|
|
19
|
+
export declare function useVirtualNestedListDrag({ items, scrollElementRef, virtualizer, estimateRowSize, onDrop, collapsedItems, }: UseVirtualNestedListDragOptions): {
|
|
20
|
+
dragSession: VirtualDragSession;
|
|
21
|
+
handlePointerDown: (event: React.PointerEvent, itemId: string) => void;
|
|
22
|
+
handleKeyboardReorder: (itemId: string, direction: "up" | "down") => void;
|
|
23
|
+
isDragging: boolean;
|
|
24
|
+
};
|