@ishibashi0112/spreadsheet-grid-core 0.65.0 → 1.0.1

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 (106) hide show
  1. package/dist/controllers/clipboardController.cjs +2 -2
  2. package/dist/controllers/clipboardController.d.ts +2 -1
  3. package/dist/controllers/clipboardController.js +78 -62
  4. package/dist/controllers/columnAutosizeRunner.cjs +1 -1
  5. package/dist/controllers/columnAutosizeRunner.d.ts +2 -0
  6. package/dist/controllers/columnAutosizeRunner.js +49 -23
  7. package/dist/controllers/columnHeaderDragController.cjs +1 -1
  8. package/dist/controllers/columnHeaderDragController.d.ts +4 -0
  9. package/dist/controllers/columnHeaderDragController.js +140 -124
  10. package/dist/controllers/dateRolloverStore.cjs +1 -1
  11. package/dist/controllers/dateRolloverStore.js +1 -1
  12. package/dist/controllers/editController.cjs +1 -1
  13. package/dist/controllers/editController.js +71 -55
  14. package/dist/controllers/escapeClaimController.cjs +1 -0
  15. package/dist/controllers/escapeClaimController.d.ts +18 -0
  16. package/dist/controllers/escapeClaimController.js +30 -0
  17. package/dist/controllers/fillHandleController.cjs +1 -1
  18. package/dist/controllers/fillHandleController.js +129 -127
  19. package/dist/controllers/findController.cjs +1 -1
  20. package/dist/controllers/findController.d.ts +1 -0
  21. package/dist/controllers/findController.js +96 -75
  22. package/dist/controllers/globalFilteredOrder.cjs +1 -1
  23. package/dist/controllers/globalFilteredOrder.js +52 -21
  24. package/dist/controllers/keyboardController.cjs +1 -1
  25. package/dist/controllers/keyboardController.js +98 -97
  26. package/dist/controllers/pointerInteractionsController.cjs +1 -1
  27. package/dist/controllers/pointerInteractionsController.js +159 -144
  28. package/dist/controllers/popoverSupport.cjs +1 -1
  29. package/dist/controllers/popoverSupport.js +4 -1
  30. package/dist/controllers/rowDragController.cjs +1 -1
  31. package/dist/controllers/rowDragController.d.ts +1 -0
  32. package/dist/controllers/rowDragController.js +122 -120
  33. package/dist/controllers/scrollSyncController.cjs +1 -1
  34. package/dist/controllers/scrollSyncController.d.ts +1 -1
  35. package/dist/controllers/scrollSyncController.js +7 -4
  36. package/dist/controllers/selectOptionsCollector.cjs +1 -1
  37. package/dist/controllers/selectOptionsCollector.d.ts +5 -2
  38. package/dist/controllers/selectOptionsCollector.js +39 -27
  39. package/dist/controllers/toolPanelController.cjs +1 -1
  40. package/dist/controllers/toolPanelController.d.ts +6 -0
  41. package/dist/controllers/toolPanelController.js +69 -59
  42. package/dist/controllers/tooltipController.cjs +1 -1
  43. package/dist/controllers/tooltipController.d.ts +2 -0
  44. package/dist/controllers/tooltipController.js +68 -38
  45. package/dist/controllers/viewportSyncController.cjs +1 -1
  46. package/dist/controllers/viewportSyncController.d.ts +4 -0
  47. package/dist/controllers/viewportSyncController.js +18 -8
  48. package/dist/engine/columnCommands.cjs +1 -1
  49. package/dist/engine/columnCommands.js +2 -1
  50. package/dist/engine/columnLayout.cjs +1 -1
  51. package/dist/engine/columnLayout.d.ts +2 -0
  52. package/dist/engine/columnLayout.js +51 -18
  53. package/dist/engine/exportCommands.cjs +2 -2
  54. package/dist/engine/exportCommands.js +37 -38
  55. package/dist/engine/gridApi.cjs +2 -2
  56. package/dist/engine/gridApi.d.ts +1 -1
  57. package/dist/engine/gridApi.js +8 -8
  58. package/dist/engine/rowPipeline.cjs +1 -1
  59. package/dist/engine/rowPipeline.js +46 -46
  60. package/dist/engine/rowSelectionCommands.cjs +1 -1
  61. package/dist/engine/rowSelectionCommands.d.ts +8 -1
  62. package/dist/engine/rowSelectionCommands.js +36 -25
  63. package/dist/locales/en.cjs +1 -1
  64. package/dist/locales/en.js +1 -1
  65. package/dist/logic/autoScrollGeometry.cjs +1 -1
  66. package/dist/logic/autoScrollGeometry.d.ts +5 -1
  67. package/dist/logic/autoScrollGeometry.js +6 -6
  68. package/dist/logic/clearCells.cjs +1 -1
  69. package/dist/logic/clearCells.js +13 -13
  70. package/dist/logic/columnReset.cjs +1 -1
  71. package/dist/logic/columnReset.d.ts +1 -0
  72. package/dist/logic/columnReset.js +21 -19
  73. package/dist/logic/editorValues.cjs +1 -1
  74. package/dist/logic/editorValues.js +41 -15
  75. package/dist/logic/elementScale.cjs +1 -0
  76. package/dist/logic/elementScale.d.ts +8 -0
  77. package/dist/logic/elementScale.js +14 -0
  78. package/dist/logic/filtering.cjs +1 -1
  79. package/dist/logic/filtering.js +14 -11
  80. package/dist/logic/focusCycle.cjs +1 -0
  81. package/dist/logic/focusCycle.d.ts +1 -0
  82. package/dist/logic/focusCycle.js +15 -0
  83. package/dist/logic/labelRows.cjs +1 -1
  84. package/dist/logic/labelRows.d.ts +2 -0
  85. package/dist/logic/labelRows.js +8 -4
  86. package/dist/logic/localeText.cjs +1 -1
  87. package/dist/logic/localeText.js +1 -1
  88. package/dist/logic/rowSelection.cjs +1 -1
  89. package/dist/logic/rowSelection.d.ts +4 -0
  90. package/dist/logic/rowSelection.js +31 -8
  91. package/dist/logic/selectOptions.cjs +1 -1
  92. package/dist/logic/selectOptions.d.ts +2 -2
  93. package/dist/logic/selectOptions.js +16 -12
  94. package/dist/logic/selectionOverlayGeometry.cjs +1 -1
  95. package/dist/logic/selectionOverlayGeometry.js +12 -12
  96. package/dist/logic/sorting.cjs +1 -1
  97. package/dist/logic/sorting.d.ts +1 -0
  98. package/dist/logic/sorting.js +24 -12
  99. package/dist/model/gridTypes.core.d.ts +48 -28
  100. package/dist/utils/deprecation.cjs +1 -1
  101. package/dist/utils/deprecation.d.ts +1 -30
  102. package/dist/utils/deprecation.js +1 -30
  103. package/package.json +1 -1
  104. package/dist/logic/exportScope.cjs +0 -1
  105. package/dist/logic/exportScope.d.ts +0 -3
  106. package/dist/logic/exportScope.js +0 -5
@@ -3,281 +3,296 @@ import { isSyntheticColumnKey as t } from "../logic/detailRow.js";
3
3
  import { gridActions as n } from "../model/gridActions.js";
4
4
  import { clamp as r, findLogicalIndexFromPaneOffset as i } from "../logic/geometry.js";
5
5
  import { clampClientYAboveFooter as a, computeNextScrollPosition as o, hasPointerLeftActivationRadius as s, resolveAutoScrollAxisDirection as c, resolveScrollContentBox as l } from "../logic/autoScrollGeometry.js";
6
- import { clientYToRowIndex as u } from "../logic/verticalGeometry.js";
6
+ import { resolveElementScale as u } from "../logic/elementScale.js";
7
+ import { clientYToRowIndex as d } from "../logic/verticalGeometry.js";
7
8
  //#region src/controllers/pointerInteractionsController.ts
8
- var d = 10, f = 300, p = () => {
9
- let d = null, f = !1, p = !1, m = null, h = null, g = "mouse", _ = null, v = null, y = !1, b = !1, x = () => d?.uiState.dragState ?? null, S = (e) => {
10
- let t = d?.footerHeight ?? 0, n = d?.scrollContainerRef.current ?? null;
11
- return t <= 0 || !n ? e : a(e, n.getBoundingClientRect().top + n.clientTop + n.clientHeight, t);
12
- }, C = (e, t) => {
13
- if (d === null) return null;
14
- let { bodyScrollRef: n, scrollContainerRef: a, leftPaneScrollRef: o, rightPaneScrollRef: s, filteredRowsLength: c, visibleColumnsLength: l, paneLayout: f, leftLeadingWidth: p, centerLeadingWidth: m, rightLeadingWidth: h, headerHeight: g, rowMetrics: _, verticalScaleFactor: v } = d, y = n.current;
15
- if (!y || c === 0 || l === 0) return null;
16
- let b = y.getBoundingClientRect(), x = u(y.scrollTop + S(t) - b.top - g, a.current?.scrollTop ?? 0, v, _), C = null, w = o.current;
17
- if (C === null && w && f.left.entries.length > 0) {
18
- let t = w.getBoundingClientRect();
9
+ var f = 10, p = 300, m = () => {
10
+ let f = null, p = !1, m = !1, h = null, g = null, _ = "mouse", v = null, y = null, b = !1, x = !1, S = () => f?.uiState.dragState ?? null, C = null, w = (e) => {
11
+ let t = f?.footerHeight ?? 0, n = f?.scrollContainerRef.current ?? null;
12
+ if (t <= 0 || !n) return e;
13
+ let r = n.getBoundingClientRect(), i = u(n, r);
14
+ return a(e, r.top + (n.clientTop + n.clientHeight) * i.y, t * i.y);
15
+ }, T = (e, t) => {
16
+ if (f === null) return null;
17
+ let { bodyScrollRef: n, scrollContainerRef: a, leftPaneScrollRef: o, rightPaneScrollRef: s, filteredRowsLength: c, visibleColumnsLength: l, paneLayout: p, leftLeadingWidth: m, centerLeadingWidth: h, rightLeadingWidth: g, headerHeight: _, rowMetrics: v, verticalScaleFactor: y } = f, b = n.current;
18
+ if (!b || c === 0 || l === 0) return null;
19
+ let x = b.getBoundingClientRect(), S = u(b, x), C = d(b.scrollTop + (w(t) - x.top) / S.y - _, a.current?.scrollTop ?? 0, y, v), T = null, E = o.current;
20
+ if (T === null && E && p.left.entries.length > 0) {
21
+ let t = E.getBoundingClientRect();
19
22
  if (e < t.right) {
20
- let n = e - t.left - p;
21
- C = i(f.left, n);
23
+ let n = (e - t.left) / S.x - m;
24
+ T = i(p.left, n);
22
25
  }
23
26
  }
24
- let T = s.current;
25
- if (C === null && T && f.right.entries.length > 0) {
26
- let t = T.getBoundingClientRect();
27
+ let D = s.current;
28
+ if (T === null && D && p.right.entries.length > 0) {
29
+ let t = D.getBoundingClientRect();
27
30
  if (e >= t.left) {
28
- let n = e - t.left - h;
29
- C = i(f.right, n);
31
+ let n = (e - t.left) / S.x - g;
32
+ T = i(p.right, n);
30
33
  }
31
34
  }
32
- if (C === null && f.center.entries.length > 0) {
33
- let t = w && f.left.entries.length === 0 ? Math.max(e, w.getBoundingClientRect().left + p) : e, n = y.scrollLeft + t - b.left - m;
34
- C = i(f.center, Math.max(n, 0));
35
+ if (T === null && p.center.entries.length > 0) {
36
+ let t = E && p.left.entries.length === 0 ? Math.max(e, E.getBoundingClientRect().left + m * S.x) : e, n = b.scrollLeft + (t - x.left) / S.x - h;
37
+ T = i(p.center, Math.max(n, 0));
35
38
  }
36
- return C === null ? null : {
37
- row: x,
38
- col: r(C, 0, l - 1)
39
+ return T === null ? null : {
40
+ row: C,
41
+ col: r(T, 0, l - 1)
39
42
  };
40
- }, w = (e, t) => {
41
- let r = x();
42
- if (d === null || !r || r.type !== "selection") return;
43
- let i = C(e, t);
43
+ }, E = (e, t) => {
44
+ let r = S();
45
+ if (f === null || !r || r.type !== "selection") return;
46
+ let i = T(e, t);
44
47
  if (i) {
45
48
  if (r.selectionKind === "cell") {
46
- d.dispatch(n.updateSelection(i));
49
+ f.dispatch(n.updateSelection(i));
47
50
  return;
48
51
  }
49
52
  if (r.selectionKind === "row") {
50
- d.dispatch(n.updateRowSelection(i.row));
53
+ f.dispatch(n.updateRowSelection(i.row));
51
54
  return;
52
55
  }
53
- r.selectionKind === "col" && d.dispatch(n.updateColumnSelection(i.col));
56
+ r.selectionKind === "col" && f.dispatch(n.updateColumnSelection(i.col));
54
57
  }
55
- }, T = (e, t) => {
58
+ }, D = (e, t) => {
56
59
  let r = t.timeStamp;
57
- if (d === null) return;
58
- let { gridRootRef: i, dispatch: a, enableRangeSelection: o, enableRowSelection: s, onGutterRowSelect: c, onCellDoubleClickRef: l, resolveFirstDataCell: u } = d;
60
+ if (f === null) return;
61
+ let { gridRootRef: i, dispatch: a, enableRangeSelection: o, enableRowSelection: s, onGutterRowSelect: c, onCellDoubleClickRef: l, resolveFirstDataCell: u } = f;
59
62
  i.current?.focus({ preventScroll: !0 });
60
- let { target: f } = e;
61
- if (f.kind === "cell") {
62
- let e = h;
63
- if (e && e.cell.row === f.cell.row && e.cell.col === f.cell.col && r - e.time < 300) {
64
- h = null, l.current(f.cell, t);
63
+ let { target: d } = e;
64
+ if (d.kind === "cell") {
65
+ let e = g;
66
+ if (e && e.cell.row === d.cell.row && e.cell.col === d.cell.col && r - e.time < 300) {
67
+ g = null, l.current(d.cell, t);
65
68
  return;
66
69
  }
67
- h = {
68
- cell: f.cell,
70
+ g = {
71
+ cell: d.cell,
69
72
  time: r
70
- }, a(n.activateCell(f.cell)), o && (a(n.startSelection(f.cell)), a(n.endSelection()));
73
+ }, a(n.activateCell(d.cell)), o && (a(n.startSelection(d.cell)), a(n.endSelection()));
71
74
  return;
72
75
  }
73
- if (h = null, f.kind === "row") {
76
+ if (g = null, d.kind === "row") {
74
77
  if (s) {
75
- c(f.rowIndex, { shiftKey: !1 });
78
+ c(d.rowIndex, { shiftKey: !1 });
76
79
  return;
77
80
  }
78
- a(n.startRowSelection(f.rowIndex, u?.().col)), a(n.endSelection());
81
+ a(n.startRowSelection(d.rowIndex, u?.().col)), a(n.endSelection());
79
82
  return;
80
83
  }
81
- a(n.startColumnSelection(f.colIndex, u?.().row)), a(n.endSelection());
82
- }, E = () => {
83
- d !== null && (p = !1, d.dispatch(n.endSelection()), d.dispatch(n.endColumnResize()));
84
- }, D = (e) => {
85
- d !== null && (d.pointerClientRef.current = {
84
+ a(n.startColumnSelection(d.colIndex, u?.().row)), a(n.endSelection());
85
+ }, O = () => {
86
+ f !== null && (m = !1, f.dispatch(n.endSelection()), f.dispatch(n.endColumnResize()));
87
+ }, k = (e) => {
88
+ if (f === null) return;
89
+ f.pointerClientRef.current = {
86
90
  x: e.clientX,
87
91
  y: e.clientY
88
- }, x()?.type === "columnResize" && d.dispatch(n.updateColumnResize(e.clientX)));
89
- }, O = (e) => {
90
- let t = m;
91
- t && (m = null, e.pointerId === t.pointerId && Math.abs(e.clientX - t.x) < 10 && Math.abs(e.clientY - t.y) < 10 && T(t, e)), E();
92
- }, k = () => {
93
- m = null, E();
94
- }, A = () => {
95
- f || (f = !0, window.addEventListener("pointermove", D), window.addEventListener("pointerup", O), window.addEventListener("pointercancel", k));
92
+ };
93
+ let t = S();
94
+ if (t?.type === "columnResize") {
95
+ (C === null || C.drag !== t) && (C = {
96
+ drag: t,
97
+ x: u(f.scrollContainerRef.current).x
98
+ });
99
+ let r = C.x === 1 ? e.clientX : t.startX + (e.clientX - t.startX) / C.x;
100
+ f.dispatch(n.updateColumnResize(r));
101
+ }
102
+ }, A = (e) => {
103
+ let t = h;
104
+ t && (h = null, e.pointerId === t.pointerId && Math.abs(e.clientX - t.x) < 10 && Math.abs(e.clientY - t.y) < 10 && D(t, e)), O();
96
105
  }, j = () => {
97
- f && (f = !1, window.removeEventListener("pointermove", D), window.removeEventListener("pointerup", O), window.removeEventListener("pointercancel", k));
106
+ h = null, O();
98
107
  }, M = () => {
99
- b = !1, d !== null && d.autoScrollFrameRef.current !== null && (cancelAnimationFrame(d.autoScrollFrameRef.current), d.autoScrollFrameRef.current = null);
108
+ p || (p = !0, window.addEventListener("pointermove", k), window.addEventListener("pointerup", A), window.addEventListener("pointercancel", j));
100
109
  }, N = () => {
101
- if (d === null || !b) return;
102
- let { scrollContainerRef: e, pointerClientRef: t, autoScrollFrameRef: n } = d, r = e.current, i = t.current;
110
+ p && (p = !1, window.removeEventListener("pointermove", k), window.removeEventListener("pointerup", A), window.removeEventListener("pointercancel", j));
111
+ }, P = () => {
112
+ x = !1, f !== null && f.autoScrollFrameRef.current !== null && (cancelAnimationFrame(f.autoScrollFrameRef.current), f.autoScrollFrameRef.current = null);
113
+ }, F = () => {
114
+ if (f === null || !x) return;
115
+ let { scrollContainerRef: e, pointerClientRef: t, autoScrollFrameRef: n } = f, r = e.current, i = t.current;
103
116
  if (!r || !i) {
104
- n.current = requestAnimationFrame(N);
117
+ n.current = requestAnimationFrame(F);
105
118
  return;
106
119
  }
107
- if (!y) {
108
- let e = v;
120
+ if (!b) {
121
+ let e = y;
109
122
  if (e && !s(e, i, 6)) {
110
- n.current = requestAnimationFrame(N);
123
+ n.current = requestAnimationFrame(F);
111
124
  return;
112
125
  }
113
- y = !0;
126
+ b = !0;
114
127
  }
115
- let a = r.getBoundingClientRect(), u = l({
128
+ let a = r.getBoundingClientRect(), d = l({
116
129
  rectLeft: a.left,
117
130
  rectTop: a.top,
118
131
  clientLeft: r.clientLeft,
119
132
  clientTop: r.clientTop,
120
133
  clientWidth: r.clientWidth,
121
- clientHeight: r.clientHeight
122
- }), f = x(), p = f?.type === "selection" && f.selectionKind === "col", m = f?.type === "selection" && f.selectionKind === "row", h = p ? 0 : c(i.y, u.top, u.bottom - (d.footerHeight ?? 0), 24), g = m ? 0 : c(i.x, u.left, u.right, 24), _ = o(r.scrollTop, h, 18, r.scrollHeight - r.clientHeight), S = o(r.scrollLeft, g, 18, r.scrollWidth - r.clientWidth);
123
- (_ !== r.scrollTop || S !== r.scrollLeft) && (r.scrollTo({
124
- top: _,
125
- left: S,
134
+ clientHeight: r.clientHeight,
135
+ scale: u(r, a)
136
+ }), p = S(), m = p?.type === "selection" && p.selectionKind === "col", h = p?.type === "selection" && p.selectionKind === "row", g = m ? 0 : c(i.y, d.top, d.bottom - (f.footerHeight ?? 0), 24), _ = h ? 0 : c(i.x, d.left, d.right, 24), v = o(r.scrollTop, g, 18, r.scrollHeight - r.clientHeight), C = o(r.scrollLeft, _, 18, r.scrollWidth - r.clientWidth);
137
+ (v !== r.scrollTop || C !== r.scrollLeft) && (r.scrollTo({
138
+ top: v,
139
+ left: C,
126
140
  behavior: "auto"
127
- }), w(i.x, i.y)), n.current = requestAnimationFrame(N);
128
- }, P = () => {
129
- let e = x()?.type === "selection";
130
- e && !b ? (b = !0, d !== null && (d.autoScrollFrameRef.current = requestAnimationFrame(N))) : !e && b && M();
131
- }, F = () => {
132
- if (_ !== null) return;
141
+ }), E(i.x, i.y)), n.current = requestAnimationFrame(F);
142
+ }, I = () => {
143
+ let e = S()?.type === "selection";
144
+ e && !x ? (x = !0, f !== null && (f.autoScrollFrameRef.current = requestAnimationFrame(F))) : !e && x && P();
145
+ }, L = () => {
146
+ if (v !== null) return;
133
147
  let e = () => {
134
- if (!p || d === null) {
135
- _ = null;
148
+ if (!m || f === null) {
149
+ v = null;
136
150
  return;
137
151
  }
138
- let { scrollContainerRef: t, pointerClientRef: n, onGutterRowSelectDrag: r } = d, i = t.current, a = n.current;
152
+ let { scrollContainerRef: t, pointerClientRef: n, onGutterRowSelectDrag: r } = f, i = t.current, a = n.current;
139
153
  if (!i || !a) {
140
- _ = requestAnimationFrame(e);
154
+ v = requestAnimationFrame(e);
141
155
  return;
142
156
  }
143
- if (!y) {
144
- let t = v;
157
+ if (!b) {
158
+ let t = y;
145
159
  if (t && !s(t, a, 6)) {
146
- _ = requestAnimationFrame(e);
160
+ v = requestAnimationFrame(e);
147
161
  return;
148
162
  }
149
- y = !0;
163
+ b = !0;
150
164
  }
151
- let u = i.getBoundingClientRect(), f = l({
152
- rectLeft: u.left,
153
- rectTop: u.top,
165
+ let d = i.getBoundingClientRect(), p = l({
166
+ rectLeft: d.left,
167
+ rectTop: d.top,
154
168
  clientLeft: i.clientLeft,
155
169
  clientTop: i.clientTop,
156
170
  clientWidth: i.clientWidth,
157
- clientHeight: i.clientHeight
158
- }), m = c(a.y, f.top, f.bottom - (d.footerHeight ?? 0), 24), h = o(i.scrollTop, m, 18, i.scrollHeight - i.clientHeight);
159
- if (h !== i.scrollTop) {
171
+ clientHeight: i.clientHeight,
172
+ scale: u(i, d)
173
+ }), h = c(a.y, p.top, p.bottom - (f.footerHeight ?? 0), 24), g = o(i.scrollTop, h, 18, i.scrollHeight - i.clientHeight);
174
+ if (g !== i.scrollTop) {
160
175
  i.scrollTo({
161
- top: h,
176
+ top: g,
162
177
  left: i.scrollLeft,
163
178
  behavior: "auto"
164
179
  });
165
- let e = C(a.x, a.y);
180
+ let e = T(a.x, a.y);
166
181
  e && r(e.row);
167
182
  }
168
- _ = requestAnimationFrame(e);
183
+ v = requestAnimationFrame(e);
169
184
  };
170
- _ = requestAnimationFrame(e);
171
- }, I = (e, t) => (e.preventDefault(), d === null || e.button !== 0 ? !1 : (g = e.pointerType, e.pointerType === "touch" ? (m = {
185
+ v = requestAnimationFrame(e);
186
+ }, R = (e, t) => (e.preventDefault(), f === null || e.button !== 0 ? !1 : (_ = e.pointerType, e.pointerType === "touch" ? (h = {
172
187
  pointerId: e.pointerId,
173
188
  x: e.clientX,
174
189
  y: e.clientY,
175
190
  target: t
176
- }, !1) : (d.gridRootRef.current?.focus({ preventScroll: !0 }), d.pointerClientRef.current = {
191
+ }, !1) : (f.gridRootRef.current?.focus({ preventScroll: !0 }), f.pointerClientRef.current = {
177
192
  x: e.clientX,
178
193
  y: e.clientY
179
- }, v = {
194
+ }, y = {
180
195
  x: e.clientX,
181
196
  y: e.clientY
182
- }, y = !1, !0)));
197
+ }, b = !1, !0)));
183
198
  return {
184
199
  update: (e) => {
185
- d = e, A(), P();
200
+ f = e, M(), I();
186
201
  },
187
- getCellCoordFromClientPoint: C,
188
- updateSelectionFromPointer: w,
202
+ getCellCoordFromClientPoint: T,
203
+ updateSelectionFromPointer: E,
189
204
  handleCellPointerDown: (e, t) => {
190
- if (!(!I(t, {
205
+ if (!(!R(t, {
191
206
  kind: "cell",
192
207
  cell: e
193
- }) || d === null)) {
194
- if (t.shiftKey && d.enableRangeSelection) {
195
- let { selection: t, activeCell: r } = d.uiState, i = t?.type === "cell" ? t.range.start : r;
208
+ }) || f === null)) {
209
+ if (t.shiftKey && f.enableRangeSelection) {
210
+ let { selection: t, activeCell: r } = f.uiState, i = t?.type === "cell" ? t.range.start : r;
196
211
  if (i) {
197
- d.dispatch(n.startSelection(i)), d.dispatch(n.updateSelection(e));
212
+ f.dispatch(n.startSelection(i)), f.dispatch(n.updateSelection(e));
198
213
  return;
199
214
  }
200
215
  }
201
- d.dispatch(n.activateCell(e)), d.enableRangeSelection && d.dispatch(n.startSelection(e));
216
+ f.dispatch(n.activateCell(e)), f.enableRangeSelection && f.dispatch(n.startSelection(e));
202
217
  }
203
218
  },
204
219
  handleCellDoubleClick: (e, t) => {
205
- g === "touch" || d === null || d.onCellDoubleClickRef.current(e, t);
220
+ _ === "touch" || f === null || f.onCellDoubleClickRef.current(e, t);
206
221
  },
207
222
  handleCellPointerEnter: (e, t) => {
208
- if (d === null || (d.enableRowHover && d.setHoveredRowIndex(e.row), d.enableColumnHover && d.setHoveredColumnIndex(e.col), !d.enableRangeSelection)) return;
209
- let r = x();
210
- r?.type !== "selection" || r.selectionKind !== "cell" || (d.pointerClientRef.current = {
223
+ if (f === null || (f.enableRowHover && f.setHoveredRowIndex(e.row), f.enableColumnHover && f.setHoveredColumnIndex(e.col), !f.enableRangeSelection)) return;
224
+ let r = S();
225
+ r?.type !== "selection" || r.selectionKind !== "cell" || (f.pointerClientRef.current = {
211
226
  x: t.clientX,
212
227
  y: t.clientY
213
- }, d.dispatch(n.updateSelection(e)));
228
+ }, f.dispatch(n.updateSelection(e)));
214
229
  },
215
230
  handleNativeDragStart: (e) => {
216
231
  e.preventDefault();
217
232
  },
218
233
  handleRowHeaderPointerDown: (e, t) => {
219
- if (!(!I(t, {
234
+ if (!(!R(t, {
220
235
  kind: "row",
221
236
  rowIndex: e
222
- }) || d === null)) {
223
- if (d.enableRowSelection) {
224
- p = !0, d.onGutterRowSelect(e, { shiftKey: t.shiftKey }), F();
237
+ }) || f === null)) {
238
+ if (f.enableRowSelection) {
239
+ m = !0, f.onGutterRowSelect(e, { shiftKey: t.shiftKey }), L();
225
240
  return;
226
241
  }
227
242
  if (t.shiftKey) {
228
- let { selection: t, activeCell: r } = d.uiState, i = t?.type === "row" ? t.startRow : r?.row;
243
+ let { selection: t, activeCell: r } = f.uiState, i = t?.type === "row" ? t.startRow : r?.row;
229
244
  if (i !== void 0) {
230
- d.dispatch(n.startRowSelection(i, d.resolveFirstDataCell?.().col)), d.dispatch(n.updateRowSelection(e));
245
+ f.dispatch(n.startRowSelection(i, f.resolveFirstDataCell?.().col)), f.dispatch(n.updateRowSelection(e));
231
246
  return;
232
247
  }
233
248
  }
234
- d.dispatch(n.startRowSelection(e, d.resolveFirstDataCell?.().col));
249
+ f.dispatch(n.startRowSelection(e, f.resolveFirstDataCell?.().col));
235
250
  }
236
251
  },
237
252
  handleRowHeaderPointerEnter: (e, t) => {
238
- if (d === null) return;
239
- if (d.enableRowHover && d.setHoveredRowIndex(e), p) {
240
- d.pointerClientRef.current = {
253
+ if (f === null) return;
254
+ if (f.enableRowHover && f.setHoveredRowIndex(e), m) {
255
+ f.pointerClientRef.current = {
241
256
  x: t.clientX,
242
257
  y: t.clientY
243
- }, d.onGutterRowSelectDrag(e);
258
+ }, f.onGutterRowSelectDrag(e);
244
259
  return;
245
260
  }
246
- let r = x();
247
- r?.type !== "selection" || r.selectionKind !== "row" || (d.pointerClientRef.current = {
261
+ let r = S();
262
+ r?.type !== "selection" || r.selectionKind !== "row" || (f.pointerClientRef.current = {
248
263
  x: t.clientX,
249
264
  y: t.clientY
250
- }, d.dispatch(n.updateRowSelection(e)));
265
+ }, f.dispatch(n.updateRowSelection(e)));
251
266
  },
252
267
  handleColumnHeaderPointerDown: (r, i) => {
253
- if (!(!I(i, {
268
+ if (!(!R(i, {
254
269
  kind: "col",
255
270
  colIndex: r
256
- }) || d === null)) {
257
- if (i.shiftKey && d.enableSorting) {
258
- let i = d.orderedColumns[r];
271
+ }) || f === null)) {
272
+ if (i.shiftKey && f.enableSorting) {
273
+ let i = f.orderedColumns[r];
259
274
  if (i && !t(i.key)) {
260
- let t = d.uiState.sort, r = t.find((e) => e.columnKey === i.key)?.direction ? "desc" : "asc", a = e(t, i.key, r, !0);
261
- d.dispatch(a.length === 0 ? n.clearSort() : n.setSort(a));
275
+ let t = f.uiState.sort, r = t.find((e) => e.columnKey === i.key)?.direction ? "desc" : "asc", a = e(t, i.key, r, !0);
276
+ f.dispatch(a.length === 0 ? n.clearSort() : n.setSort(a));
262
277
  }
263
278
  return;
264
279
  }
265
- d.dispatch(n.startColumnSelection(r, d.resolveFirstDataCell?.().row));
280
+ f.dispatch(n.startColumnSelection(r, f.resolveFirstDataCell?.().row));
266
281
  }
267
282
  },
268
283
  handleColumnHeaderPointerEnter: (e, t) => {
269
- if (d === null) return;
270
- d.setHoveredRowIndex(null), d.enableColumnHeaderHover && d.setHoveredColumnIndex(e);
271
- let r = x();
272
- r?.type !== "selection" || r.selectionKind !== "col" || (d.pointerClientRef.current = {
284
+ if (f === null) return;
285
+ f.setHoveredRowIndex(null), f.enableColumnHeaderHover && f.setHoveredColumnIndex(e);
286
+ let r = S();
287
+ r?.type !== "selection" || r.selectionKind !== "col" || (f.pointerClientRef.current = {
273
288
  x: t.clientX,
274
289
  y: t.clientY
275
- }, d.dispatch(n.updateColumnSelection(e)));
290
+ }, f.dispatch(n.updateColumnSelection(e)));
276
291
  },
277
292
  dispose: () => {
278
- j(), M(), _ !== null && (cancelAnimationFrame(_), _ = null);
293
+ N(), P(), v !== null && (cancelAnimationFrame(v), v = null);
279
294
  }
280
295
  };
281
296
  };
282
297
  //#endregion
283
- export { f as TOUCH_DOUBLE_TAP_MS, d as TOUCH_TAP_SLOP_PX, p as createPointerInteractionsController };
298
+ export { p as TOUCH_DOUBLE_TAP_MS, f as TOUCH_TAP_SLOP_PX, m as createPointerInteractionsController };
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../logic/detailRow.cjs");var t=e=>{document.activeElement instanceof HTMLElement&&document.activeElement.blur(),e?.blur()},n=t=>{requestAnimationFrame(()=>{e.isFocusInsideDetailCard()||t.current?.focus()})},r=(e,t)=>e.current?.contains(t)===!0,i=(e,t,n=`[role="menuitem"]`)=>{let r=document.activeElement,i=r instanceof HTMLElement&&e.contains(r);if(i&&!r.matches(n))return!1;let a=t.key;if(a===`ArrowDown`||a===`ArrowUp`||a===`Home`||a===`End`){t.preventDefault();let o=Array.from(e.querySelectorAll(`${n}:not(:disabled):not([aria-disabled="true"])`));if(o.length===0)return!0;let s=i?o.indexOf(r):-1,c;return c=a===`Home`?0:a===`End`?o.length-1:a===`ArrowDown`?s<0?0:(s+1)%o.length:s<0?o.length-1:(s-1+o.length)%o.length,o[c]?.focus(),!0}return!i&&(a===`PageUp`||a===`PageDown`||a===` `||a===`ArrowLeft`||a===`ArrowRight`)?(t.preventDefault(),!0):!1},a=e=>{let t=!1,n=()=>e.onResize?.(),r=t=>e.onScroll?.(t),i=t=>{let n=t.target;n&&(e.isInside(n)||e.onOutsidePointerDown(n))},a=t=>e.onKeyDown?.(t),o=null,s=()=>{let n=e.getGridRoot?.()??null,r=e.onGridHidden;!n||!r||typeof ResizeObserver>`u`||(o=new ResizeObserver(e=>{let i=e[e.length-1];if(!t||!i||i.contentRect.width!==0||i.contentRect.height!==0)return;let a=n.getBoundingClientRect();a.width===0&&a.height===0&&r()}),o.observe(n))};return{attach:()=>{t||(t=!0,window.addEventListener(`resize`,n),window.addEventListener(`scroll`,r,!0),window.addEventListener(`pointerdown`,i),window.addEventListener(`keydown`,a,!0),s())},detach:()=>{t&&(t=!1,o?.disconnect(),o=null,window.removeEventListener(`resize`,n),window.removeEventListener(`scroll`,r,!0),window.removeEventListener(`pointerdown`,i),window.removeEventListener(`keydown`,a,!0))},isAttached:()=>t}};exports.blurForPopover=t,exports.createPopoverWindowBindings=a,exports.handleMenuKeyNavigation=i,exports.isInsideGridRoot=r,exports.restoreGridFocus=n;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../logic/detailRow.cjs");var t=e=>{document.activeElement instanceof HTMLElement&&document.activeElement.blur(),e?.blur()},n=t=>{requestAnimationFrame(()=>{let n=t.current;if(n===null||e.isFocusInsideDetailCard())return;let r=n.ownerDocument.activeElement;r!==null&&r!==n&&n.contains(r)&&r.closest(`.ssg-cell-editor`)!==null||n.focus()})},r=(e,t)=>e.current?.contains(t)===!0,i=(e,t,n=`[role="menuitem"]`)=>{let r=document.activeElement,i=r instanceof HTMLElement&&e.contains(r);if(i&&!r.matches(n))return!1;let a=t.key;if(a===`ArrowDown`||a===`ArrowUp`||a===`Home`||a===`End`){t.preventDefault();let o=Array.from(e.querySelectorAll(`${n}:not(:disabled):not([aria-disabled="true"])`));if(o.length===0)return!0;let s=i?o.indexOf(r):-1,c;return c=a===`Home`?0:a===`End`?o.length-1:a===`ArrowDown`?s<0?0:(s+1)%o.length:s<0?o.length-1:(s-1+o.length)%o.length,o[c]?.focus(),!0}return!i&&(a===`PageUp`||a===`PageDown`||a===` `||a===`ArrowLeft`||a===`ArrowRight`)?(t.preventDefault(),!0):!1},a=e=>{let t=!1,n=()=>e.onResize?.(),r=t=>e.onScroll?.(t),i=t=>{let n=t.target;n&&(e.isInside(n)||e.onOutsidePointerDown(n))},a=t=>e.onKeyDown?.(t),o=null,s=()=>{let n=e.getGridRoot?.()??null,r=e.onGridHidden;!n||!r||typeof ResizeObserver>`u`||(o=new ResizeObserver(e=>{let i=e[e.length-1];if(!t||!i||i.contentRect.width!==0||i.contentRect.height!==0)return;let a=n.getBoundingClientRect();a.width===0&&a.height===0&&r()}),o.observe(n))};return{attach:()=>{t||(t=!0,window.addEventListener(`resize`,n),window.addEventListener(`scroll`,r,!0),window.addEventListener(`pointerdown`,i),window.addEventListener(`keydown`,a,!0),s())},detach:()=>{t&&(t=!1,o?.disconnect(),o=null,window.removeEventListener(`resize`,n),window.removeEventListener(`scroll`,r,!0),window.removeEventListener(`pointerdown`,i),window.removeEventListener(`keydown`,a,!0))},isAttached:()=>t}};exports.blurForPopover=t,exports.createPopoverWindowBindings=a,exports.handleMenuKeyNavigation=i,exports.isInsideGridRoot=r,exports.restoreGridFocus=n;
@@ -4,7 +4,10 @@ var t = (e) => {
4
4
  document.activeElement instanceof HTMLElement && document.activeElement.blur(), e?.blur();
5
5
  }, n = (t) => {
6
6
  requestAnimationFrame(() => {
7
- e() || t.current?.focus();
7
+ let n = t.current;
8
+ if (n === null || e()) return;
9
+ let r = n.ownerDocument.activeElement;
10
+ r !== null && r !== n && n.contains(r) && r.closest(".ssg-cell-editor") !== null || n.focus();
8
11
  });
9
12
  }, r = (e, t) => e.current?.contains(t) === !0, i = (e, t, n = "[role=\"menuitem\"]") => {
10
13
  let r = document.activeElement, i = r instanceof HTMLElement && e.contains(r);
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../logic/rowReorder.cjs"),t=require("../logic/detailRow.cjs"),n=require("../logic/autoScrollGeometry.cjs"),r=require("../logic/slotDom.cjs"),i=require("../utils/portalTokens.cjs");var a=14,o=12,s=`0.5`,c=`<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="8 6 12 2 16 6"/><polyline points="16 18 12 22 8 18"/><line x1="12" y1="2" x2="12" y2="22"/></svg>`,l=`<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><line x1="4.9" y1="4.9" x2="19.1" y2="19.1"/></svg>`,u=200,d=`cubic-bezier(0.2, 0.7, 0.3, 1)`,f=`transform 160ms ${d}`,p=`data-ssg-row-dragging`,m=e=>e?.closest(`.ssg-motion-off`)!=null,h=/translateY\((-?[\d.]+)px\)/,g=e=>{let n=[];return e.querySelectorAll(`.ssg-body-row[data-row-index]`).forEach(r=>{t.isInsideDetailCardOf(e,r)||n.push(r)}),n},_=e=>{let n=[],r=new Map;return e.querySelectorAll(`.ssg-detail-band[data-detail-row-index]`).forEach(i=>{if(t.isInsideDetailCardOf(e,i))return;let a=Number(i.getAttribute(`data-detail-row-index`)),o=r.get(a)??0;r.set(a,o+1),n.push({el:i,index:a,key:`band|${o}|${a}`})}),n},v=e=>{e.style.transition=``,e.style.transform=``,e.style.willChange=``,e.style.zIndex=``},y=()=>{let y=null,b=null,x=null,S={x:0,y:0},C=null,w=!1,T=null,E=null,D=null,O=null,k=null,A=null,j=0,M=null,N=()=>y?.motion===`live`,P=null,F=null,I=null,L=()=>[y?.leftIndicatorRef.current??null,y?.centerIndicatorRef.current??null,y?.rightIndicatorRef.current??null],R=()=>{for(let e of L())e&&(e.style.display=`none`)},z=e=>{if(P)return;let t=document.createElement(`div`);t.setAttribute(`data-grid-drag-ghost`,``),y?.scrollContainerRef.current?.closest(`.ssg-theme-dark`)!=null&&t.classList.add(`ssg-theme-dark`),y?.scrollContainerRef.current?.closest(`.ssg-theme-class`)!=null&&t.classList.add(`ssg-theme-class`),y?.scrollContainerRef.current?.closest(`.ssg-motion-off`)!=null&&t.classList.add(`ssg-motion-off`),t.style.cssText=[`position:fixed`,`top:0`,`left:0`,`display:inline-flex`,`align-items:center`,`gap:7px`,`padding:7px 12px 7px 10px`,`border-radius:9px`,`border:1px solid var(--ssg-ghost-border)`,`background:var(--ssg-ghost-bg)`,`color:var(--ssg-ghost-text)`,`font-size:12px`,`font-weight:600`,`line-height:1`,`white-space:nowrap`,`max-width:280px`,`overflow:hidden`,`text-overflow:ellipsis`,`box-shadow:var(--ssg-ghost-shadow)`,`pointer-events:none`,`user-select:none`,`z-index:9999`,`will-change:transform`,`transform:translate(-9999px,-9999px)`].join(`;`),r.applySlotToElement(t,y?.ghostSlot);let n=document.createElement(`span`);n.style.cssText=`display:inline-flex;align-items:center;justify-content:center;width:14px;height:14px;flex:none`;let a=document.createElement(`span`);a.style.cssText=`overflow:hidden;text-overflow:ellipsis`,a.textContent=e,t.appendChild(n),t.appendChild(a),document.body.appendChild(t),i.syncPortalTokens(y?.scrollContainerRef.current,t),P=t,F=n,I=null},B=e=>{let t=P;if(!t)return;t.style.transform=`translate(`+(S.x+a)+`px,`+(S.y+o)+`px)`;let n=e?`move`:`out`;if(I===n)return;I=n;let r=F;n===`out`?(t.style.opacity=s,r&&(r.innerHTML=l)):(t.style.opacity=`1`,r&&(r.innerHTML=c))},V=()=>{P&&P.parentNode&&P.parentNode.removeChild(P),P=null,F=null,I=null},H=(e,n)=>{let r=y?.scrollContainerRef.current??null;!r||n&&e===null||r.querySelectorAll(n?`.ssg-body-row[data-row-index="${e}"]`:`.ssg-body-row[${p}]`).forEach(e=>{t.isInsideDetailCardOf(r,e)||(n?e.setAttribute(p,N()?`live`:``):e.removeAttribute(p))})},U=()=>{let e=y?.scrollContainerRef.current??null;if(!e)return null;let t=new Map;for(let n of g(e)){let e=h.exec(n.style.transform);e&&t.set(n,{index:Number(n.getAttribute(`data-row-index`)),baseY:parseFloat(e[1])})}return t},W=t=>{let n=A,r=b;if(!n||r===null||y===null)return;let i=y.scrollContainerRef.current;if(!i)return;for(let e of g(i)){if(n.has(e))continue;let t=h.exec(e.style.transform);t&&n.set(e,{index:Number(e.getAttribute(`data-row-index`)),baseY:parseFloat(t[1])})}let a=y.rowMetrics.rowsHeight(r,r),o=(i.scrollTop-j)*y.verticalScaleFactor,s=(C?S.y-C.y:0)+o,c=t===null?null:e.resolveMoveTargetIndex(r,t);n.forEach((e,t)=>{let{index:i,baseY:o}=e;if(!t.isConnected){n.delete(t);return}if(i===r){t.style.transition=`none`,t.style.transform=`translateY(${o+s}px)`,t.style.willChange=`transform`,e.applied=t.style.transform;return}let l=0;c!==null&&(r<i&&i<=c?l=-a:c<=i&&i<r&&(l=a)),t.style.transition=f,t.style.transform=`translateY(${o+l}px)`,e.applied=t.style.transform});let l=M??new Set;M=l;for(let{el:e,index:t}of _(i)){if(l.add(e),t===r){e.style.transition=`none`,e.style.transform=`translateY(${s}px)`,e.style.willChange=`transform`,e.style.zIndex=`10`;continue}let n=0;c!==null&&(r<t&&t<=c?n=-a:c<=t&&t<r&&(n=a)),e.style.transition=f,e.style.transform=`translateY(${n}px)`,e.style.zIndex=``}},G=(t,r)=>{if(y===null)return null;let{scrollContainerRef:i,bodyScrollRef:a,rowMetrics:o,headerHeight:s,verticalScaleFactor:c,windowBaseOffsetPx:l}=y,u=i.current,d=a.current;if(!u||!d)return null;let f=u.getBoundingClientRect();if(t<f.left||t>f.right||r<f.top||r>f.bottom)return null;let p=n.clampClientYAboveFooter(r,f.top+u.clientTop+u.clientHeight,y.footerHeight??0),m=d.getBoundingClientRect(),h=d.scrollTop+p-m.top-s-u.scrollTop*(1-c),g=e.resolveRowDropSlot(h,o),_=b,v=_!==null&&N()?o.detailHeight(_):0;if(_!==null&&v>0){let t=e.resolveRowDropSlot(h+v,o);t>_+1&&(g=t)}let x=e.resolveRowDropSlotTop(g,o);return{slot:g,top:s+x-l}},K=()=>{let t=G(S.x,S.y),n=b;if(N()){t&&n!==null&&(x=e.resolveMoveTargetIndex(n,t.slot)===null?null:t.slot),R(),W(x);return}if(B(t),!t||n===null||e.resolveMoveTargetIndex(n,t.slot)===null){x=null,R();return}x=t.slot;for(let e of L())e&&(e.style.top=`${t.top}px`,e.style.display=`block`)},q=()=>{if(b===null){D=null;return}let e=y?.scrollContainerRef.current??null;if(e&&(w||(!C||n.hasPointerLeftActivationRadius(C,S,6))&&(w=!0),w)){let t=e.getBoundingClientRect(),r=n.resolveScrollContentBox({rectLeft:t.left,rectTop:t.top,clientLeft:e.clientLeft,clientTop:e.clientTop,clientWidth:e.clientWidth,clientHeight:e.clientHeight}),i=n.resolveAutoScrollAxisDirection(S.y,r.top,r.bottom-(y?.footerHeight??0),24),a=n.computeNextScrollPosition(e.scrollTop,i,18,e.scrollHeight-e.clientHeight);a!==e.scrollTop&&e.scrollTo({top:a,behavior:`auto`})}K(),D=requestAnimationFrame(q)},J=(e,t)=>`${e.getAttribute(`data-pane`)??``}|${t}`,Y=()=>{let e=y?.scrollContainerRef.current??null;if(!e)return null;let t=new Map;for(let n of g(e))t.set(J(n,Number(n.getAttribute(`data-row-index`))),n.getBoundingClientRect().top);for(let n of _(e))t.set(n.key,n.el.getBoundingClientRect().top);return t},X=t=>{D!==null&&(cancelAnimationFrame(D),D=null),document.body.style.cursor=``,R(),V();let n=b,r=x,i=k;H(n,!1),b=null,k=null,x=null,C=null,E=null;let a=n===null||r===null?null:e.resolveMoveTargetIndex(n,r),o=t&&n!==null&&a!==null&&y!==null,s=A;A=null;let c=s&&o&&y!==null&&!m(y.scrollContainerRef.current)?Y():null,l=M;if(M=null,l&&(o?l.forEach(v):(l.forEach(e=>{e.isConnected&&(e.style.transition=f,e.style.transform=`translateY(0px)`,e.style.zIndex=``)}),window.setTimeout(()=>{l.forEach(e=>{M?.has(e)||v(e)})},200))),s)if(o)s.forEach(({baseY:e},t)=>{t.style.transition=``,t.style.willChange=``,t.isConnected&&(t.style.transform=`translateY(${e}px)`)});else{let e=[];s.forEach(({baseY:t},n)=>{n.isConnected&&(n.style.transition=f,n.style.transform=`translateY(${t}px)`,e.push(n))}),window.setTimeout(()=>{for(let t of e)t.style.transition=``,t.style.willChange=``},200)}if(!o||n===null||a===null||y===null)return;let u=c??(m(y.scrollContainerRef.current)?null:Y()),d=u?{tops:u,from:n,to:a,row:i}:null;O=d,y.commitRowMove(n,a),d&&requestAnimationFrame(()=>{O===d&&(O=null)})},Z=()=>{let e=O;if(O=null,!e)return;let t=y?.scrollContainerRef.current??null;if(!t)return;let{tops:n,from:r,to:i}=e;if(y?.locateDragRow&&e.row!==null&&y.locateDragRow(e.row,i)!==i)return;let a=e=>e===i?r:r<i&&e>=r&&e<i?e+1:i<r&&e>i&&e<=r?e-1:e,o=[],s=new Map;g(t).forEach(e=>{let t=n.get(J(e,a(Number(e.getAttribute(`data-row-index`)))));if(t===void 0)return;let r=t-e.getBoundingClientRect().top;if(Math.abs(r)<.5)return;let i=h.exec(e.style.transform);if(!i)return;let c=parseFloat(i[1]);s.set(e,c),e.style.transition=`none`,e.style.transform=`translateY(${c+r}px)`,e.style.willChange=`transform`,o.push(e)});let c=[];if(_(t).forEach(({el:e,index:t,key:r})=>{let i=a(t),o=n.get(r.slice(0,r.lastIndexOf(`|`)+1)+i);if(o===void 0)return;let s=o-e.getBoundingClientRect().top;Math.abs(s)<.5||(e.style.transition=`none`,e.style.transform=`translateY(${s}px)`,e.style.willChange=`transform`,c.push(e))}),!(o.length===0&&c.length===0)){t.getBoundingClientRect();for(let e of o)e.style.transition=`transform ${u}ms ${d}`,e.style.transform=`translateY(${s.get(e)??0}px)`;for(let e of c)e.style.transition=`transform ${u}ms ${d}`,e.style.transform=`translateY(0px)`;window.setTimeout(()=>{for(let e of o)e.style.transition=``,e.style.willChange=``;for(let e of c)M?.has(e)||v(e)},280)}},Q=(e,t)=>{if(y===null||!y.enabled||t.button!==0)return;if(t.stopPropagation(),t.preventDefault(),b!==null){if(t.pointerId!==E)return;T?.(),X(!1)}b=e,k=y.getDragRow?.(e)??null,E=t.pointerId,x=null,S={x:t.clientX,y:t.clientY},C={x:t.clientX,y:t.clientY},w=!1,document.body.style.cursor=`grabbing`,N()?(A=U(),j=y.scrollContainerRef.current?.scrollTop??0):z(y.getRowDragLabel(e)),H(e,!0);let n=t.currentTarget,r=t.pointerId;try{n.setPointerCapture(r)}catch{}let i=e=>{e.pointerId===r&&(S={x:e.clientX,y:e.clientY},K())},a=()=>{window.removeEventListener(`pointermove`,i),window.removeEventListener(`pointerup`,o),window.removeEventListener(`pointercancel`,s),window.removeEventListener(`keydown`,c),window.removeEventListener(`blur`,l),T=null;try{n.releasePointerCapture(r)}catch{}};function o(e){e.pointerId===r&&(a(),X(!0))}function s(e){e.pointerId===r&&(a(),X(!1))}function c(e){e.key===`Escape`&&(a(),X(!1))}function l(){a(),X(!1)}window.addEventListener(`pointermove`,i),window.addEventListener(`pointerup`,o),window.addEventListener(`pointercancel`,s),window.addEventListener(`keydown`,c),window.addEventListener(`blur`,l),T=a,K(),D=requestAnimationFrame(q)},$=e=>{if(b===null||k==null||y?.locateDragRow===void 0)return;let t=y.locateDragRow(k,b);if(A&&A.forEach((e,t)=>{if(!t.isConnected){A?.delete(t);return}let n=Number(t.getAttribute(`data-row-index`));if(n===e.index&&(e.applied===void 0||t.style.transform===e.applied))return;let r=h.exec(t.style.transform);if(!r){A?.delete(t);return}e.index=n,e.baseY=parseFloat(r[1]),e.applied=void 0}),t===null){T?.(),X(!1);return}A&&t!==b&&C!==null&&e!==null&&(C={x:C.x,y:C.y+y.rowMetrics.rowTop(t)-e.rowTop(b)}),t!==b&&(H(null,!1),b=t,H(t,!0)),K()};return{update:e=>{let t=y;y=e,b!==null&&t!==null&&t.locateDragRow!==e.locateDragRow&&$(t.rowMetrics)},onRowDragHandlePointerDown:Q,applyReorderSettle:Z,dispose:()=>{T?.(),T=null,D!==null&&(cancelAnimationFrame(D),D=null),document.body.style.cursor=``,V(),H(b,!1),b=null,k=null,x=null,A=null,M?.forEach(v),M=null,O=null}}};exports.createRowDragController=y;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../logic/rowReorder.cjs"),t=require("../logic/detailRow.cjs"),n=require("../logic/autoScrollGeometry.cjs"),r=require("../logic/elementScale.cjs"),i=require("../logic/slotDom.cjs"),a=require("../utils/portalTokens.cjs");var o=14,s=12,c=`0.5`,l=`<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="8 6 12 2 16 6"/><polyline points="16 18 12 22 8 18"/><line x1="12" y1="2" x2="12" y2="22"/></svg>`,u=`<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><line x1="4.9" y1="4.9" x2="19.1" y2="19.1"/></svg>`,d=200,f=`cubic-bezier(0.2, 0.7, 0.3, 1)`,p=`transform 160ms ${f}`,m=`data-ssg-row-dragging`,h=e=>e?.closest(`.ssg-motion-off`)!=null,g=/translateY\((-?[\d.]+)px\)/,_=e=>{let n=[];return e.querySelectorAll(`.ssg-body-row[data-row-index]`).forEach(r=>{t.isInsideDetailCardOf(e,r)||n.push(r)}),n},v=e=>{let n=[],r=new Map;return e.querySelectorAll(`.ssg-detail-band[data-detail-row-index]`).forEach(i=>{if(t.isInsideDetailCardOf(e,i))return;let a=Number(i.getAttribute(`data-detail-row-index`)),o=r.get(a)??0;r.set(a,o+1),n.push({el:i,index:a,key:`band|${o}|${a}`})}),n},y=e=>{e.style.transition=``,e.style.transform=``,e.style.willChange=``,e.style.zIndex=``},b=()=>{let b=null,x=null,S=null,C={x:0,y:0},w=null,T=!1,E=null,D=null,O=null,k=null,A=null,j=null,M=0,N=null,P=()=>b?.motion===`live`,F=null,I=null,L=null,R=()=>[b?.leftIndicatorRef.current??null,b?.centerIndicatorRef.current??null,b?.rightIndicatorRef.current??null],z=()=>{for(let e of R())e&&(e.style.display=`none`)},B=e=>{if(F)return;let t=document.createElement(`div`);t.setAttribute(`data-grid-drag-ghost`,``),b?.scrollContainerRef.current?.closest(`.ssg-theme-dark`)!=null&&t.classList.add(`ssg-theme-dark`),b?.scrollContainerRef.current?.closest(`.ssg-theme-class`)!=null&&t.classList.add(`ssg-theme-class`),b?.scrollContainerRef.current?.closest(`.ssg-motion-off`)!=null&&t.classList.add(`ssg-motion-off`),t.style.cssText=[`position:fixed`,`top:0`,`left:0`,`display:inline-flex`,`align-items:center`,`gap:7px`,`padding:7px 12px 7px 10px`,`border-radius:9px`,`border:1px solid var(--ssg-ghost-border)`,`background:var(--ssg-ghost-bg)`,`color:var(--ssg-ghost-text)`,`font-size:12px`,`font-weight:600`,`line-height:1`,`white-space:nowrap`,`max-width:280px`,`overflow:hidden`,`text-overflow:ellipsis`,`box-shadow:var(--ssg-ghost-shadow)`,`pointer-events:none`,`user-select:none`,`z-index:9999`,`will-change:transform`,`transform:translate(-9999px,-9999px)`].join(`;`),i.applySlotToElement(t,b?.ghostSlot);let n=document.createElement(`span`);n.style.cssText=`display:inline-flex;align-items:center;justify-content:center;width:14px;height:14px;flex:none`;let r=document.createElement(`span`);r.style.cssText=`overflow:hidden;text-overflow:ellipsis`,r.textContent=e,t.appendChild(n),t.appendChild(r),document.body.appendChild(t),a.syncPortalTokens(b?.scrollContainerRef.current,t),F=t,I=n,L=null},V=e=>{let t=F;if(!t)return;t.style.transform=`translate(`+(C.x+o)+`px,`+(C.y+s)+`px)`;let n=e?`move`:`out`;if(L===n)return;L=n;let r=I;n===`out`?(t.style.opacity=c,r&&(r.innerHTML=u)):(t.style.opacity=`1`,r&&(r.innerHTML=l))},H=()=>{F&&F.parentNode&&F.parentNode.removeChild(F),F=null,I=null,L=null},U=(e,n)=>{let r=b?.scrollContainerRef.current??null;!r||n&&e===null||r.querySelectorAll(n?`.ssg-body-row[data-row-index="${e}"]`:`.ssg-body-row[${m}]`).forEach(e=>{t.isInsideDetailCardOf(r,e)||(n?e.setAttribute(m,P()?`live`:``):e.removeAttribute(m))})},W=()=>{let e=b?.scrollContainerRef.current??null;if(!e)return null;let t=new Map;for(let n of _(e)){let e=g.exec(n.style.transform);e&&t.set(n,{index:Number(n.getAttribute(`data-row-index`)),baseY:parseFloat(e[1])})}return t},G=t=>{let n=j,r=x;if(!n||r===null||b===null)return;let i=b.scrollContainerRef.current;if(!i)return;for(let e of _(i)){if(n.has(e))continue;let t=g.exec(e.style.transform);t&&n.set(e,{index:Number(e.getAttribute(`data-row-index`)),baseY:parseFloat(t[1])})}let a=b.rowMetrics.rowsHeight(r,r),o=(i.scrollTop-M)*b.verticalScaleFactor,s=(w?C.y-w.y:0)+o,c=t===null?null:e.resolveMoveTargetIndex(r,t);n.forEach((e,t)=>{let{index:i,baseY:o}=e;if(!t.isConnected){n.delete(t);return}if(i===r){t.style.transition=`none`,t.style.transform=`translateY(${o+s}px)`,t.style.willChange=`transform`,e.applied=t.style.transform;return}let l=0;c!==null&&(r<i&&i<=c?l=-a:c<=i&&i<r&&(l=a)),t.style.transition=p,t.style.transform=`translateY(${o+l}px)`,e.applied=t.style.transform});let l=N??new Set;N=l;for(let{el:e,index:t}of v(i)){if(l.add(e),t===r){e.style.transition=`none`,e.style.transform=`translateY(${s}px)`,e.style.willChange=`transform`,e.style.zIndex=`10`;continue}let n=0;c!==null&&(r<t&&t<=c?n=-a:c<=t&&t<r&&(n=a)),e.style.transition=p,e.style.transform=`translateY(${n}px)`,e.style.zIndex=``}},K=(t,r)=>{if(b===null)return null;let{scrollContainerRef:i,bodyScrollRef:a,rowMetrics:o,headerHeight:s,verticalScaleFactor:c,windowBaseOffsetPx:l}=b,u=i.current,d=a.current;if(!u||!d)return null;let f=u.getBoundingClientRect();if(t<f.left||t>f.right||r<f.top||r>f.bottom)return null;let p=n.clampClientYAboveFooter(r,f.top+u.clientTop+u.clientHeight,b.footerHeight??0),m=d.getBoundingClientRect(),h=d.scrollTop+p-m.top-s-u.scrollTop*(1-c),g=e.resolveRowDropSlot(h,o),_=x,v=_!==null&&P()?o.detailHeight(_):0;if(_!==null&&v>0){let t=e.resolveRowDropSlot(h+v,o);t>_+1&&(g=t)}let y=e.resolveRowDropSlotTop(g,o);return{slot:g,top:s+y-l}},q=()=>{let t=K(C.x,C.y),n=x;if(P()){t&&n!==null&&(S=e.resolveMoveTargetIndex(n,t.slot)===null?null:t.slot),z(),G(S);return}if(V(t),!t||n===null||e.resolveMoveTargetIndex(n,t.slot)===null){S=null,z();return}S=t.slot;for(let e of R())e&&(e.style.top=`${t.top}px`,e.style.display=`block`)},J=()=>{if(x===null){O=null;return}let e=b?.scrollContainerRef.current??null;if(e&&(T||(!w||n.hasPointerLeftActivationRadius(w,C,6))&&(T=!0),T)){let t=e.getBoundingClientRect(),i=n.resolveScrollContentBox({rectLeft:t.left,rectTop:t.top,clientLeft:e.clientLeft,clientTop:e.clientTop,clientWidth:e.clientWidth,clientHeight:e.clientHeight,scale:r.resolveElementScale(e,t)}),a=n.resolveAutoScrollAxisDirection(C.y,i.top,i.bottom-(b?.footerHeight??0),24),o=n.computeNextScrollPosition(e.scrollTop,a,18,e.scrollHeight-e.clientHeight);o!==e.scrollTop&&e.scrollTo({top:o,behavior:`auto`})}q(),O=requestAnimationFrame(J)},Y=(e,t)=>`${e.getAttribute(`data-pane`)??``}|${t}`,X=()=>{let e=b?.scrollContainerRef.current??null;if(!e)return null;let t=new Map;for(let n of _(e))t.set(Y(n,Number(n.getAttribute(`data-row-index`))),n.getBoundingClientRect().top);for(let n of v(e))t.set(n.key,n.el.getBoundingClientRect().top);return t},Z=t=>{O!==null&&(cancelAnimationFrame(O),O=null),document.body.style.cursor=``,z(),H();let n=x,r=S,i=A;U(n,!1),x=null,A=null,S=null,w=null,D=null;let a=n===null||r===null?null:e.resolveMoveTargetIndex(n,r),o=t&&n!==null&&a!==null&&b!==null,s=j;j=null;let c=s&&o&&b!==null&&!h(b.scrollContainerRef.current)?X():null,l=N;if(N=null,l&&(o?l.forEach(y):(l.forEach(e=>{e.isConnected&&(e.style.transition=p,e.style.transform=`translateY(0px)`,e.style.zIndex=``)}),window.setTimeout(()=>{l.forEach(e=>{N?.has(e)||y(e)})},200))),s)if(o)s.forEach(({baseY:e},t)=>{t.style.transition=``,t.style.willChange=``,t.isConnected&&(t.style.transform=`translateY(${e}px)`)});else{let e=[];s.forEach(({baseY:t},n)=>{n.isConnected&&(n.style.transition=p,n.style.transform=`translateY(${t}px)`,e.push(n))}),window.setTimeout(()=>{for(let t of e)t.style.transition=``,t.style.willChange=``},200)}if(!o||n===null||a===null||b===null)return;let u=c??(h(b.scrollContainerRef.current)?null:X()),d=u?{tops:u,from:n,to:a,row:i}:null;k=d,b.commitRowMove(n,a),d&&requestAnimationFrame(()=>{k===d&&(k=null)})},Q=()=>{let e=k;if(k=null,!e)return;let t=b?.scrollContainerRef.current??null;if(!t)return;let{tops:n,from:r,to:i}=e;if(b?.locateDragRow&&e.row!==null&&b.locateDragRow(e.row,i)!==i)return;let a=e=>e===i?r:r<i&&e>=r&&e<i?e+1:i<r&&e>i&&e<=r?e-1:e,o=[],s=new Map;_(t).forEach(e=>{let t=n.get(Y(e,a(Number(e.getAttribute(`data-row-index`)))));if(t===void 0)return;let r=t-e.getBoundingClientRect().top;if(Math.abs(r)<.5)return;let i=g.exec(e.style.transform);if(!i)return;let c=parseFloat(i[1]);s.set(e,c),e.style.transition=`none`,e.style.transform=`translateY(${c+r}px)`,e.style.willChange=`transform`,o.push(e)});let c=[];if(v(t).forEach(({el:e,index:t,key:r})=>{let i=a(t),o=n.get(r.slice(0,r.lastIndexOf(`|`)+1)+i);if(o===void 0)return;let s=o-e.getBoundingClientRect().top;Math.abs(s)<.5||(e.style.transition=`none`,e.style.transform=`translateY(${s}px)`,e.style.willChange=`transform`,c.push(e))}),!(o.length===0&&c.length===0)){t.getBoundingClientRect();for(let e of o)e.style.transition=`transform ${d}ms ${f}`,e.style.transform=`translateY(${s.get(e)??0}px)`;for(let e of c)e.style.transition=`transform ${d}ms ${f}`,e.style.transform=`translateY(0px)`;window.setTimeout(()=>{for(let e of o)e.style.transition=``,e.style.willChange=``;for(let e of c)N?.has(e)||y(e)},280)}},$=(e,t)=>{if(b===null||!b.enabled||t.button!==0)return;if(t.stopPropagation(),t.preventDefault(),b.gridRootRef?.current?.focus({preventScroll:!0}),x!==null){if(t.pointerId!==D)return;E?.(),Z(!1)}x=e,A=b.getDragRow?.(e)??null,D=t.pointerId,S=null,C={x:t.clientX,y:t.clientY},w={x:t.clientX,y:t.clientY},T=!1,document.body.style.cursor=`grabbing`,P()?(j=W(),M=b.scrollContainerRef.current?.scrollTop??0):B(b.getRowDragLabel(e)),U(e,!0);let n=t.currentTarget,r=t.pointerId;try{n.setPointerCapture(r)}catch{}let i=e=>{e.pointerId===r&&(C={x:e.clientX,y:e.clientY},q())},a=()=>{window.removeEventListener(`pointermove`,i),window.removeEventListener(`pointerup`,o),window.removeEventListener(`pointercancel`,s),window.removeEventListener(`keydown`,c),window.removeEventListener(`blur`,l),E=null;try{n.releasePointerCapture(r)}catch{}};function o(e){e.pointerId===r&&(a(),Z(!0))}function s(e){e.pointerId===r&&(a(),Z(!1))}function c(e){e.key===`Escape`&&(a(),Z(!1))}function l(){a(),Z(!1)}window.addEventListener(`pointermove`,i),window.addEventListener(`pointerup`,o),window.addEventListener(`pointercancel`,s),window.addEventListener(`keydown`,c),window.addEventListener(`blur`,l),E=a,q(),O=requestAnimationFrame(J)},ee=e=>{if(x===null||A==null||b?.locateDragRow===void 0)return;let t=b.locateDragRow(A,x);if(j&&j.forEach((e,t)=>{if(!t.isConnected){j?.delete(t);return}let n=Number(t.getAttribute(`data-row-index`));if(n===e.index&&(e.applied===void 0||t.style.transform===e.applied))return;let r=g.exec(t.style.transform);if(!r){j?.delete(t);return}e.index=n,e.baseY=parseFloat(r[1]),e.applied=void 0}),t===null){E?.(),Z(!1);return}j&&t!==x&&w!==null&&e!==null&&(w={x:w.x,y:w.y+b.rowMetrics.rowTop(t)-e.rowTop(x)}),t!==x&&(U(null,!1),x=t,U(t,!0)),q()};return{update:e=>{let t=b;b=e,x!==null&&t!==null&&t.locateDragRow!==e.locateDragRow&&ee(t.rowMetrics)},onRowDragHandlePointerDown:$,applyReorderSettle:Q,dispose:()=>{E?.(),E=null,O!==null&&(cancelAnimationFrame(O),O=null),document.body.style.cursor=``,H(),U(x,!1),x=null,A=null,S=null,j=null,N?.forEach(y),N=null,k=null}}};exports.createRowDragController=b;
@@ -21,6 +21,7 @@ export type RowDragArgs = {
21
21
  motion?: 'ghost' | 'live';
22
22
  getDragRow?: (viewIndex: number) => unknown;
23
23
  locateDragRow?: (dragRow: unknown, hint: number) => number | null;
24
+ gridRootRef?: ReadonlyRef<HTMLElement | null>;
24
25
  };
25
26
  export type RowDragHandlePointerEvent = {
26
27
  button: number;