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.
Files changed (127) hide show
  1. package/dist/components/data/data-table/build-column-tree-from-grid.d.ts +1 -0
  2. package/dist/components/data/data-table/build-column-tree-from-grid.js +55 -50
  3. package/dist/components/data/data-table/column-picker-authority.d.ts +34 -0
  4. package/dist/components/data/data-table/column-picker-authority.js +116 -0
  5. package/dist/components/data/data-table/column-picker-drop-validation.d.ts +7 -0
  6. package/dist/components/data/data-table/column-picker-drop-validation.js +37 -0
  7. package/dist/components/data/data-table/data-table-column-apply.d.ts +2 -0
  8. package/dist/components/data/data-table/data-table-column-apply.js +84 -73
  9. package/dist/components/data/data-table/data-table-column-list-tree-apply.d.ts +10 -0
  10. package/dist/components/data/data-table/data-table-column-list-tree-apply.js +79 -0
  11. package/dist/components/data/data-table/data-table-column-list.js +94 -64
  12. package/dist/components/data/data-table/data-table-column-tree-cache.d.ts +12 -6
  13. package/dist/components/data/data-table/data-table-column-tree-cache.js +250 -131
  14. package/dist/components/data/data-table/data-table-flat-column-virtual-rows.d.ts +26 -0
  15. package/dist/components/data/data-table/data-table-flat-column-virtual-rows.js +195 -0
  16. package/dist/components/data/data-table/data-table-picker-column-eligibility.d.ts +1 -0
  17. package/dist/components/data/data-table/data-table-picker-column-eligibility.js +7 -0
  18. package/dist/components/data/data-table/patch-column-tree-indicators-from-grid.d.ts +5 -0
  19. package/dist/components/data/data-table/patch-column-tree-indicators-from-grid.js +28 -11
  20. package/dist/components/data/data-table/reconcile-column-tree-from-grid.d.ts +12 -0
  21. package/dist/components/data/data-table/reconcile-column-tree-from-grid.js +12 -0
  22. package/dist/components/data/data-table/use-data-table-column-list-sync.d.ts +10 -0
  23. package/dist/components/data/data-table/use-data-table-column-list-sync.js +250 -196
  24. package/dist/components/data/nested-list/components/NestedListContent.d.ts +10 -2
  25. package/dist/components/data/nested-list/components/NestedListContent.js +253 -138
  26. package/dist/components/data/nested-list/components/SortableItem.d.ts +2 -1
  27. package/dist/components/data/nested-list/components/SortableItem.js +62 -60
  28. package/dist/components/data/nested-list/hooks/useNestedListDragDrop.d.ts +10 -20
  29. package/dist/components/data/nested-list/hooks/useNestedListDragDrop.js +44 -233
  30. package/dist/components/data/nested-list/hooks/useVirtualNestedListDrag.d.ts +24 -0
  31. package/dist/components/data/nested-list/hooks/useVirtualNestedListDrag.js +128 -0
  32. package/dist/components/data/nested-list/nested-list-constants.d.ts +4 -1
  33. package/dist/components/data/nested-list/nested-list-constants.js +10 -4
  34. package/dist/components/data/nested-list/nested-list-display-utils.d.ts +11 -0
  35. package/dist/components/data/nested-list/nested-list-display-utils.js +74 -0
  36. package/dist/components/data/nested-list/nested-list-drop-engine.d.ts +31 -0
  37. package/dist/components/data/nested-list/nested-list-drop-engine.js +209 -0
  38. package/dist/components/data/nested-list/nested-list-flat-virtual-handlers.d.ts +26 -0
  39. package/dist/components/data/nested-list/nested-list-flat-virtual-handlers.js +67 -0
  40. package/dist/components/data/nested-list/nested-list-item-tree-mutations.d.ts +4 -0
  41. package/dist/components/data/nested-list/nested-list-item-tree-mutations.js +43 -0
  42. package/dist/components/data/nested-list/nested-list-lazy-flat-rows.d.ts +3 -0
  43. package/dist/components/data/nested-list/nested-list-lazy-flat-rows.js +34 -0
  44. package/dist/components/data/nested-list/nested-list-row-estimates.d.ts +9 -0
  45. package/dist/components/data/nested-list/nested-list-row-estimates.js +14 -0
  46. package/dist/components/data/nested-list/nested-list-scroll-anchor.d.ts +36 -0
  47. package/dist/components/data/nested-list/nested-list-scroll-anchor.js +47 -0
  48. package/dist/components/data/nested-list/nested-list-virtual-drop.d.ts +59 -0
  49. package/dist/components/data/nested-list/nested-list-virtual-drop.js +341 -0
  50. package/dist/components/data/nested-list/nested-list.js +322 -336
  51. package/dist/components/data/nested-list/nested-list.types.d.ts +17 -0
  52. package/dist/components/data-display/calendar/calendar-apply-validation.d.ts +0 -2
  53. package/dist/components/data-display/calendar/calendar-apply-validation.js +67 -64
  54. package/dist/components/data-display/calendar/calendar-config.js +1 -1
  55. package/dist/components/data-display/calendar/calendar-day-picker-components.d.ts +2 -4
  56. package/dist/components/data-display/calendar/calendar-day-picker-components.js +164 -234
  57. package/dist/components/data-display/calendar/calendar-day-picker-view.js +76 -77
  58. package/dist/components/data-display/calendar/calendar-fiscal-period-nav.d.ts +0 -6
  59. package/dist/components/data-display/calendar/calendar-fiscal-period-nav.js +18 -34
  60. package/dist/components/data-display/calendar/calendar-footer.js +21 -21
  61. package/dist/components/data-display/calendar/calendar-month-picker-panel.js +49 -50
  62. package/dist/components/data-display/calendar/calendar-month-utils.d.ts +0 -5
  63. package/dist/components/data-display/calendar/calendar-month-utils.js +64 -85
  64. package/dist/components/data-display/calendar/calendar-padding-week.utils.d.ts +1 -3
  65. package/dist/components/data-display/calendar/calendar-padding-week.utils.js +5 -7
  66. package/dist/components/data-display/calendar/calendar-period-cell.js +46 -45
  67. package/dist/components/data-display/calendar/calendar-quarter-panes.js +31 -33
  68. package/dist/components/data-display/calendar/calendar-selection-appearance.d.ts +0 -10
  69. package/dist/components/data-display/calendar/calendar-selection-appearance.js +39 -53
  70. package/dist/components/data-display/calendar/calendar-selection.d.ts +0 -25
  71. package/dist/components/data-display/calendar/calendar-selection.js +23 -52
  72. package/dist/components/data-display/calendar/calendar-week-number-cell.d.ts +1 -2
  73. package/dist/components/data-display/calendar/calendar-week-number-cell.js +45 -59
  74. package/dist/components/data-display/calendar/calendar-week-utils.d.ts +3 -13
  75. package/dist/components/data-display/calendar/calendar-week-utils.js +50 -59
  76. package/dist/components/data-display/calendar/calendar-year-panes.d.ts +0 -3
  77. package/dist/components/data-display/calendar/calendar-year-panes.js +49 -53
  78. package/dist/components/data-display/calendar/calendar.js +143 -146
  79. package/dist/components/data-display/calendar/calendar.types.d.ts +0 -5
  80. package/dist/components/data-display/calendar/use-calendar-day-picker-config.d.ts +1 -2
  81. package/dist/components/data-display/calendar/use-calendar-day-picker-config.js +74 -79
  82. package/dist/components/data-display/calendar/use-calendar-state.d.ts +1 -3
  83. package/dist/components/data-display/calendar/use-calendar-state.js +325 -403
  84. package/dist/components/forms/date-picker/date-picker.js +58 -60
  85. package/dist/components/forms/date-picker/date-picker.types.d.ts +0 -5
  86. package/dist/components/forms/date-picker/date-range-picker.js +64 -66
  87. package/dist/components/forms/date-picker/fiscal-pass-through.d.ts +0 -1
  88. package/dist/components/forms/date-picker/fiscal-pass-through.js +2 -3
  89. package/dist/components/forms/date-picker/month-picker.js +59 -61
  90. package/dist/components/forms/date-picker/month-range-picker.js +61 -63
  91. package/dist/components/forms/date-picker/multi-date-picker.js +49 -51
  92. package/dist/components/forms/date-picker/multi-month-picker.js +47 -49
  93. package/dist/components/forms/date-picker/multi-quarter-picker.js +47 -51
  94. package/dist/components/forms/date-picker/multi-week-picker.js +51 -53
  95. package/dist/components/forms/date-picker/multi-year-picker.js +49 -53
  96. package/dist/components/forms/date-picker/quarter-picker.js +47 -51
  97. package/dist/components/forms/date-picker/quarter-range-picker.js +46 -50
  98. package/dist/components/forms/date-picker/week-picker.js +66 -68
  99. package/dist/components/forms/date-picker/week-range-picker.js +80 -82
  100. package/dist/components/forms/date-picker/year-picker.js +48 -52
  101. package/dist/components/forms/date-picker/year-range-picker.js +48 -52
  102. package/dist/form-react/Fields/DateInputField.js +50 -51
  103. package/dist/form-react/Fields/DateRangeField.js +13 -14
  104. package/dist/form-react/Fields/MonthRangeField.js +28 -29
  105. package/dist/form-react/Fields/MultiMonthPickerField.js +12 -13
  106. package/dist/form-react/Fields/MultiWeekPickerField.js +27 -35
  107. package/dist/form-react/Fields/WeekRangePicker.js +32 -33
  108. package/dist/form-react/types/fields.types.d.ts +0 -14
  109. package/dist/impact-nova-components.css +6 -13
  110. package/dist/impact-nova.css +1 -1
  111. package/dist/lib/fiscal-calendar/week-selection.js +2 -2
  112. package/dist/lib/hash/fnv1a128.d.ts +16 -0
  113. package/dist/lib/hash/fnv1a128.js +21 -0
  114. package/dist/llms/rules/ag-grid.js +1 -1
  115. package/dist/llms/rules/installation.js +1 -1
  116. package/dist/llms/rules/requirements.js +1 -1
  117. package/package.json +1 -1
  118. package/dist/components/data-display/calendar/calendar-available-view.d.ts +0 -27
  119. package/dist/components/data-display/calendar/calendar-available-view.js +0 -85
  120. package/dist/components/data-display/calendar/calendar-fiscal-day-cell.d.ts +0 -9
  121. package/dist/components/data-display/calendar/calendar-fiscal-day-cell.js +0 -45
  122. package/dist/components/data-display/calendar/calendar-injected-week-row.d.ts +0 -5
  123. package/dist/components/data-display/calendar/calendar-injected-week-row.js +0 -92
  124. package/dist/components/data-display/calendar/calendar-leading-week.utils.d.ts +0 -16
  125. package/dist/components/data-display/calendar/calendar-leading-week.utils.js +0 -51
  126. package/dist/components/data-display/calendar/calendar-orphan-week.d.ts +0 -23
  127. 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 C, { useMemo as R } from "react";
3
- import { useSortable as j } from "@dnd-kit/sortable";
4
- import { useDroppable as _ } from "@dnd-kit/core";
5
- import { Checkbox as H } from "../../../forms/checkbox/checkbox.js";
6
- import { ChevronRight as D, Drag as $ } from "impact-nova-icons";
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 v } from "../../../../i18n/use-impact-nova-i18n.js";
9
- import { isNestedListSubtreeIndeterminate as E } from "../nested-list-tree-utils.js";
10
- const z = "flex shrink-0 items-center h-5 gap-0.5", A = "flex h-5 w-4 shrink-0 items-center justify-center", O = "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", P = (e, r) => {
11
- const s = "group flex items-start gap-2 py-1 pr-2 rounded transition-colors duration-150 min-w-0";
12
- return e ? d(s, "opacity-40 bg-canvas-muted") : r ? d(s, "bg-feedback-error-surface border border-destructive animate-pulse") : d(s, "hover:bg-canvas-muted");
13
- }, G = ({ item: e, isAnyDragging: r, renderActions: s }) => {
14
- const { t: n } = v(), a = !e.children || e.children.length === 0, {
15
- setNodeRef: l,
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: !a
20
+ disabled: !s
21
21
  });
22
- return /* @__PURE__ */ c("div", { ref: a ? l : void 0, children: [
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 && a && "bg-canvas-tint rounded"
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 && a && /* @__PURE__ */ t("span", { className: "ml-2 text-brand text-[11px]", children: n("nestedList.dropHere") })
34
+ o && r && s && /* @__PURE__ */ t("span", { className: "ml-2 text-brand text-[11px]", children: n("nestedList.dropHere") })
35
35
  ] }),
36
- s?.(e, { isLeaf: !1, level: 0 })
36
+ a?.(e, { isLeaf: !1, level: 0 })
37
37
  ]
38
38
  }
39
39
  ),
40
- a && /* @__PURE__ */ t(
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
- }, M = ({
52
+ }, T = ({
52
53
  item: e,
53
54
  level: r,
54
- indentLevel: s,
55
+ indentLevel: a,
55
56
  isCollapsed: n,
56
- onToggle: a,
57
- onToggleCollapse: l,
58
- isAnyDragging: o = !1,
59
- enableDragDrop: N = !0,
60
- enableCollapse: g = !0,
61
- shouldBlink: k = !1,
62
- isDragDisabled: u = !1,
63
- renderLabelExtras: f,
64
- renderActions: m
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: h } = v(), x = e.category === "structure", p = e.children && e.children.length > 0, b = !p && e.category !== "structure", L = R(() => !e.children || e.children.length === 0 ? !1 : E(e.children), [e.children]), {
67
- attributes: y,
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: I
71
- } = j({
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: x || e.disabled || u
80
+ disabled: g || e.disabled || m || f
79
81
  });
80
- return x ? /* @__PURE__ */ t(G, { item: e, isAnyDragging: o, renderActions: m }) : /* @__PURE__ */ t(
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: P(I, k),
95
+ className: G(R, y),
94
96
  style: {
95
- paddingLeft: `${8 + s * 20}px`
97
+ paddingLeft: `${8 + a * 20}px`
96
98
  },
97
99
  children: [
98
- /* @__PURE__ */ c("div", { className: z, children: [
99
- /* @__PURE__ */ t("div", { className: A, children: g && p && /* @__PURE__ */ t(
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(), l(e.id);
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": h(n ? "nestedList.expand" : "nestedList.collapse"),
110
+ "aria-label": u(n ? "nestedList.expand" : "nestedList.collapse"),
109
111
  children: /* @__PURE__ */ t(
110
- D,
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
- H,
121
+ $,
120
122
  {
121
123
  id: `checkbox-${e.id}`,
122
- checked: L ? "indeterminate" : e.checked,
123
- onCheckedChange: () => a(e.id),
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
- N && !u ? /* @__PURE__ */ t(
131
+ o && !m ? /* @__PURE__ */ t(
130
132
  "div",
131
133
  {
132
- ...y,
133
- ...S,
134
- "aria-label": `${h("aria.dragHandle")}: ${e.label}`,
135
- className: O,
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($, { size: "14px" })
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
- f?.(e, { isLeaf: b, level: r }) ? /* @__PURE__ */ t("div", { className: "shrink-0 self-center flex items-center", children: f(e, { isLeaf: b, level: r }) }) : null,
158
- /* @__PURE__ */ t("div", { className: "shrink-0 self-center flex items-center", children: m?.(e, { isLeaf: b, level: r }) })
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
- }, W = C.memo(M);
166
+ }, Y = j.memo(T);
165
167
  export {
166
- O as DRAG_HANDLE_CLASS,
167
- z as LEADING_RAIL_CLASS,
168
- W as SortableItem
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 findItemLevel;
32
- findParentId: typeof findParentId;
21
+ findItemLevel: typeof findNestedListItemLevel;
22
+ findParentId: typeof findNestedListParentId;
33
23
  };
34
24
  export {};
@@ -1,247 +1,58 @@
1
- import { useCallback as F } from "react";
2
- import { useSensors as Z, useSensor as V, MouseSensor as $, TouchSensor as E, closestCenter as p } from "@dnd-kit/core";
3
- import { arrayMove as k } from "@dnd-kit/sortable";
4
- const W = "droppable-", _ = /* @__PURE__ */ new Set(["root-frozen", "root-scrollable"]);
5
- function X(f) {
6
- if (f.startsWith(W)) {
7
- const r = f.slice(W.length);
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 d.length > 0 ? d : r;
40
- };
41
- function M(f, r) {
42
- for (const d of f) {
43
- if (d.id === r) return d;
44
- if (d.children) {
45
- const e = M(d.children, r);
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 C = Z(
85
- V($),
86
- V(E)
87
- ), b = F(
88
- (o, c, u) => {
89
- const s = G(o, u);
90
- if (!s) return null;
91
- const n = o.findIndex(
92
- (i) => i.id === s
93
- ), t = o.findIndex(
94
- (i) => i.id === c
95
- );
96
- if (n !== -1 && t !== -1) {
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
- b,
216
- P,
217
- z,
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 (e) {
227
- const n = M(f, o), t = T(f, o);
228
- if (n && t !== null && !e(n, t))
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 u = o ? T(f, o) : null, s = c ? T(f, c) : null;
232
- return X(c) !== null || _.has(c) ? !0 : u === null || s === null ? !1 : u === 0 && s > 0 || u === s || u > 0 && s > 0;
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
- [f, e]
45
+ [r, t, f]
235
46
  );
236
47
  return {
237
- sensors: C,
238
- handleDragEnd: J,
239
- isValidDrop: K,
240
- findItemLevel: T,
241
- findParentId: G
48
+ sensors: h,
49
+ handleDragEnd: p,
50
+ isValidDrop: E,
51
+ findItemLevel: L,
52
+ findParentId: B
242
53
  };
243
54
  };
244
55
  export {
245
- nn as customCollisionDetection,
246
- rn as useNestedListDragDrop
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
+ };