@ishibashi0112/spreadsheet-grid-core 0.59.0 → 0.61.0

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 (61) hide show
  1. package/README.md +2 -2
  2. package/dist/controllers/changeHighlightController.cjs +1 -1
  3. package/dist/controllers/changeHighlightController.js +54 -49
  4. package/dist/controllers/clipboardController.cjs +2 -2
  5. package/dist/controllers/clipboardController.js +71 -76
  6. package/dist/controllers/columnHeaderDragController.cjs +1 -1
  7. package/dist/controllers/columnHeaderDragController.js +74 -70
  8. package/dist/controllers/editController.cjs +1 -1
  9. package/dist/controllers/editController.js +90 -84
  10. package/dist/controllers/findController.cjs +1 -1
  11. package/dist/controllers/findController.js +71 -71
  12. package/dist/controllers/imeInputController.cjs +1 -1
  13. package/dist/controllers/imeInputController.js +68 -65
  14. package/dist/controllers/rowDragController.cjs +1 -1
  15. package/dist/controllers/rowDragController.d.ts +2 -0
  16. package/dist/controllers/rowDragController.js +153 -113
  17. package/dist/controllers/rowEnterController.cjs +1 -1
  18. package/dist/controllers/rowEnterController.js +49 -47
  19. package/dist/controllers/saveStatusController.cjs +1 -1
  20. package/dist/controllers/saveStatusController.js +54 -47
  21. package/dist/controllers/serverSideRowModel.cjs +1 -1
  22. package/dist/controllers/serverSideRowModel.js +42 -20
  23. package/dist/controllers/tooltipController.cjs +1 -1
  24. package/dist/controllers/tooltipController.js +38 -21
  25. package/dist/controllers/viewportSyncController.cjs +1 -1
  26. package/dist/controllers/viewportSyncController.d.ts +2 -1
  27. package/dist/controllers/viewportSyncController.js +3 -2
  28. package/dist/engine/columnLayout.cjs +1 -1
  29. package/dist/engine/columnLayout.d.ts +1 -0
  30. package/dist/engine/columnLayout.js +12 -11
  31. package/dist/engine/exportCommands.cjs +1 -1
  32. package/dist/engine/exportCommands.js +27 -25
  33. package/dist/engine/filterPopoverCommands.cjs +1 -1
  34. package/dist/engine/filterPopoverCommands.js +12 -7
  35. package/dist/engine/gridApi.cjs +1 -1
  36. package/dist/engine/gridApi.js +2 -2
  37. package/dist/logic/conditionalFormat.cjs +1 -1
  38. package/dist/logic/conditionalFormat.js +2 -2
  39. package/dist/logic/domGuards.cjs +1 -1
  40. package/dist/logic/domGuards.d.ts +4 -0
  41. package/dist/logic/domGuards.js +2 -2
  42. package/dist/logic/editorValues.cjs +1 -1
  43. package/dist/logic/editorValues.d.ts +2 -0
  44. package/dist/logic/editorValues.js +11 -2
  45. package/dist/logic/fillSeries.cjs +1 -1
  46. package/dist/logic/fillSeries.js +43 -36
  47. package/dist/logic/find.cjs +1 -1
  48. package/dist/logic/find.d.ts +1 -0
  49. package/dist/logic/find.js +6 -6
  50. package/dist/logic/gridState.cjs +1 -1
  51. package/dist/logic/gridState.js +72 -55
  52. package/dist/logic/selectionAggregates.cjs +1 -1
  53. package/dist/logic/selectionAggregates.js +5 -2
  54. package/dist/logic/serverSideEdits.cjs +1 -1
  55. package/dist/logic/serverSideEdits.d.ts +16 -2
  56. package/dist/logic/serverSideEdits.js +60 -14
  57. package/dist/model/gridTypes.core.d.ts +8 -5
  58. package/dist/utils/clipboard.cjs +5 -5
  59. package/dist/utils/clipboard.d.ts +3 -0
  60. package/dist/utils/clipboard.js +58 -65
  61. package/package.json +2 -2
@@ -1,137 +1,137 @@
1
1
  import { createValueStore as e } from "../logic/valueStore.js";
2
2
  import { runChunked as t } from "../logic/chunkedLoop.js";
3
3
  import { isSyntheticColumnKey as n } from "../logic/detailRow.js";
4
- import { buildFindIndex as r, findRangesInText as i, resolveCurrentAfterRescan as a, resolveFindCellText as o, stepFindIndex as s } from "../logic/find.js";
4
+ import { buildFindIndex as r, findRangesInText as i, isFindableColumn as a, resolveCurrentAfterRescan as o, resolveFindCellText as s, stepFindIndex as c } from "../logic/find.js";
5
5
  //#region src/controllers/findController.ts
6
- var c = 1e4, l = /* @__PURE__ */ new Map(), u = () => {
7
- let c = null, u = 0, d = null, f = e({
6
+ var l = 1e4, u = /* @__PURE__ */ new Map(), d = () => {
7
+ let l = null, d = 0, f = null, p = e({
8
8
  open: !1,
9
9
  query: "",
10
10
  matches: [],
11
- index: l,
11
+ index: u,
12
12
  currentIndex: null,
13
13
  scanning: !1,
14
14
  truncated: !1
15
- }), p = (e) => {
16
- f.setSnapshot({
17
- ...f.getSnapshot(),
15
+ }), m = (e) => {
16
+ p.setSnapshot({
17
+ ...p.getSnapshot(),
18
18
  ...e
19
19
  });
20
- }, m = null, h = () => {
21
- let e = f.getSnapshot(), t = {
20
+ }, h = null, g = () => {
21
+ let e = p.getSnapshot(), t = {
22
22
  query: e.query,
23
23
  matchCount: e.matches.length,
24
24
  currentIndex: e.currentIndex,
25
25
  open: e.open
26
26
  };
27
- m !== null && m.query === t.query && m.matchCount === t.matchCount && m.currentIndex === t.currentIndex && m.open === t.open || (m = t, c?.onChange?.(t));
28
- }, g = () => {
29
- let e = f.getSnapshot();
27
+ h !== null && h.query === t.query && h.matchCount === t.matchCount && h.currentIndex === t.currentIndex && h.open === t.open || (h = t, l?.onChange?.(t));
28
+ }, _ = () => {
29
+ let e = p.getSnapshot();
30
30
  if (e.currentIndex === null) return;
31
31
  let t = e.matches[e.currentIndex];
32
- t && c?.onNavigate(t.rowIndex, t.colIndex);
33
- }, _ = () => {
34
- u += 1, d = null, p({
32
+ t && l?.onNavigate(t.rowIndex, t.colIndex);
33
+ }, v = () => {
34
+ d += 1, f = null, m({
35
35
  matches: [],
36
- index: l,
36
+ index: u,
37
37
  currentIndex: null,
38
38
  scanning: !1,
39
39
  truncated: !1
40
40
  });
41
- }, v = (e) => {
42
- let s = c, l = f.getSnapshot();
43
- if (!s || !l.open || l.query.length === 0) {
44
- _(), h();
41
+ }, y = (e) => {
42
+ let c = l, u = p.getSnapshot();
43
+ if (!c || !u.open || u.query.length === 0) {
44
+ v(), g();
45
45
  return;
46
46
  }
47
- u += 1;
48
- let m = u, { rowModel: v, columns: y, caseSensitive: b } = s, x = l.query;
49
- d = {
50
- rowModel: v,
51
- columns: y,
52
- query: x,
53
- caseSensitive: b
47
+ d += 1;
48
+ let h = d, { rowModel: y, columns: b, caseSensitive: x } = c, S = u.query;
49
+ f = {
50
+ rowModel: y,
51
+ columns: b,
52
+ query: S,
53
+ caseSensitive: x
54
54
  };
55
- let S = l.currentIndex === null ? null : l.matches[l.currentIndex] ?? null, C = [], w = !1, T = v.getRowCount();
56
- p({ scanning: !0 }), t(T, (e) => {
57
- if (w) return;
58
- let t = v.getRow(e);
59
- t !== void 0 && y.forEach((r, a) => {
60
- if (w || n(r.key)) return;
61
- let s = o(r, t);
62
- for (let t of i(s, x, b)) {
63
- if (C.length >= 1e4) {
64
- w = !0;
55
+ let C = u.currentIndex === null ? null : u.matches[u.currentIndex] ?? null, w = [], T = !1, E = y.getRowCount();
56
+ m({ scanning: !0 }), t(E, (e) => {
57
+ if (T) return;
58
+ let t = y.getRow(e);
59
+ t !== void 0 && b.forEach((r, o) => {
60
+ if (T || n(r.key) || !a(r)) return;
61
+ let c = s(r, t);
62
+ for (let t of i(c, S, x)) {
63
+ if (w.length >= 1e4) {
64
+ T = !0;
65
65
  return;
66
66
  }
67
- C.push({
67
+ w.push({
68
68
  rowIndex: e,
69
- colIndex: a,
69
+ colIndex: o,
70
70
  columnKey: String(r.key),
71
71
  start: t.start,
72
72
  length: t.length
73
73
  });
74
74
  }
75
75
  });
76
- }, { isCancelled: () => u !== m }).then((t) => {
77
- if (!t || u !== m) return;
78
- let n = a(C, S);
79
- p({
80
- matches: C,
81
- index: r(C),
76
+ }, { isCancelled: () => d !== h }).then((t) => {
77
+ if (!t || d !== h) return;
78
+ let n = o(w, C);
79
+ m({
80
+ matches: w,
81
+ index: r(w),
82
82
  currentIndex: n,
83
83
  scanning: !1,
84
- truncated: w
85
- }), h(), e && g();
84
+ truncated: T
85
+ }), g(), e && _();
86
86
  });
87
- }, y = () => {
88
- let e = f.getSnapshot();
89
- return !c || !e.open || e.query.length === 0 ? !1 : d === null || d.rowModel !== c.rowModel || d.columns !== c.columns || d.query !== e.query || d.caseSensitive !== c.caseSensitive;
87
+ }, b = () => {
88
+ let e = p.getSnapshot();
89
+ return !l || !e.open || e.query.length === 0 ? !1 : f === null || f.rowModel !== l.rowModel || f.columns !== l.columns || f.query !== e.query || f.caseSensitive !== l.caseSensitive;
90
90
  };
91
91
  return {
92
92
  update: (e) => {
93
- let t = c;
94
- if (c = e, !e.enabled) {
95
- f.getSnapshot().open && (p({
93
+ let t = l;
94
+ if (l = e, !e.enabled) {
95
+ p.getSnapshot().open && (m({
96
96
  open: !1,
97
97
  query: ""
98
- }), _(), h());
98
+ }), v(), g());
99
99
  return;
100
100
  }
101
- t !== e && y() && v(!1);
101
+ t !== e && b() && y(!1);
102
102
  },
103
103
  open: (e) => {
104
- if (!c?.enabled) return;
105
- let t = f.getSnapshot(), n = e ?? t.query;
106
- p({
104
+ if (!l?.enabled) return;
105
+ let t = p.getSnapshot(), n = e ?? t.query;
106
+ m({
107
107
  open: !0,
108
108
  query: n
109
- }), n !== t.query || !t.open ? v(!0) : h();
109
+ }), n !== t.query || !t.open ? y(!0) : g();
110
110
  },
111
111
  close: () => {
112
- f.getSnapshot().open && (p({
112
+ p.getSnapshot().open && (m({
113
113
  open: !1,
114
114
  query: ""
115
- }), _(), h());
115
+ }), v(), g());
116
116
  },
117
117
  setQuery: (e) => {
118
- let t = f.getSnapshot();
119
- !t.open || e === t.query || (p({ query: e }), v(!0));
118
+ let t = p.getSnapshot();
119
+ !t.open || e === t.query || (m({ query: e }), y(!0));
120
120
  },
121
121
  next: () => {
122
- let e = f.getSnapshot(), t = s(e.currentIndex, e.matches.length, 1);
123
- p({ currentIndex: t }), h(), g();
122
+ let e = p.getSnapshot(), t = c(e.currentIndex, e.matches.length, 1);
123
+ m({ currentIndex: t }), g(), _();
124
124
  },
125
125
  prev: () => {
126
- let e = f.getSnapshot(), t = s(e.currentIndex, e.matches.length, -1);
127
- p({ currentIndex: t }), h(), g();
126
+ let e = p.getSnapshot(), t = c(e.currentIndex, e.matches.length, -1);
127
+ m({ currentIndex: t }), g(), _();
128
128
  },
129
- subscribe: f.subscribe,
130
- getSnapshot: f.getSnapshot,
129
+ subscribe: p.subscribe,
130
+ getSnapshot: p.getSnapshot,
131
131
  dispose: () => {
132
- u += 1, c = null;
132
+ d += 1, l = null;
133
133
  }
134
134
  };
135
135
  };
136
136
  //#endregion
137
- export { c as MAX_FIND_MATCHES, u as createFindController };
137
+ export { l as MAX_FIND_MATCHES, d as createFindController };
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=`ssg-ime-input--composing`,t=(e,t,n)=>{let r=e.querySelectorAll(`.ssg-body-row[data-row-index="${t.row}"]`);for(let e of Array.from(r)){let t=e.querySelectorAll(`.ssg-body-cell`);for(let e of Array.from(t))if(e.getAttribute(`data-ssg-col-key`)===n)return e}return null},n=(e,t)=>e===t||e!==null&&t!==null&&e.row===t.row&&e.col===t.col,r=()=>{let r=null,i=null,a=null,o=null,s=!1,c=null,l=!1,u=!1,d=!1,f=null,p=()=>r?.gridRootRef.current??null,m=()=>{i&&i.ownerDocument.activeElement!==i&&i.focus({preventScroll:!0})},h=(e,n)=>{let a=p(),o=r?.resolveCell(e)??null;if(!i||!a||!o)return!1;let s=t(a,e,o.colKey);if(!s)return!1;let c=a.getBoundingClientRect(),l=s.getBoundingClientRect();return i.style.left=`${l.left-c.left-a.clientLeft}px`,i.style.top=`${l.top-c.top-a.clientTop}px`,i.style.width=`${l.width}px`,i.style.height=`${l.height}px`,i.style.textAlign=n&&o.align?o.align:``,!0},g=()=>{i&&(i.classList.remove(e),i.value=``,i.style.textAlign=``)},_=e=>{r===null||!r.enabled||r.editing||u||e.target===a&&m()},v=()=>{if(r===null||!r.enabled||r.editing||r.activeCell===null){c=null;return}let t=r.activeCell,n=r.canStartEdit(t);c={cell:t,allowed:n},d=!1,n&&(h(t,!0),f=t,i?.classList.add(e))},y=e=>{let t=c;c=null;let n=d;if(d=!1,!i||t===null||!t.allowed||n){g();return}let a=i.value||e.data||``;queueMicrotask(()=>{let e=i;if(r===null||!r.enabled||!e||a===``||e.ownerDocument.activeElement!==e||!r.canStartEdit(t.cell)){g();return}let n=r.resolveEditText?r.resolveEditText(t.cell,a):a;if(n===null||n===``){g();return}l=!0,r.startEdit(t.cell,n),requestAnimationFrame(()=>{l&&r!==null&&!r.editing&&(l=!1,g())})})},b=()=>{c===null&&!l&&i&&(i.value=``)},x=e=>{if(e.target!==i||e.key!==`Tab`||e.defaultPrevented||e.isComposing)return;let t=p();if(t){u=!0;try{t.focus({preventScroll:!0})}finally{u=!1}}},S=()=>{c!==null&&(d=!0)},C=e=>{a!==e&&(a?.removeEventListener(`focus`,_),a=e,a?.addEventListener(`focus`,_))},w=e=>{typeof document>`u`||s===e||(s=e,e?(document.addEventListener(`keydown`,x),document.addEventListener(`pointerdown`,S,!0)):(document.removeEventListener(`keydown`,x),document.removeEventListener(`pointerdown`,S,!0)))},T=e=>{o!==e&&(o&&(o.removeEventListener(`compositionstart`,v),o.removeEventListener(`compositionend`,y),o.removeEventListener(`input`,b)),o=e,o&&(o.addEventListener(`compositionstart`,v),o.addEventListener(`compositionend`,y),o.addEventListener(`input`,b)))};return{update:e=>{r=e;let t=e.gridRootRef.current;if(C(e.enabled?t:null),T(e.enabled?i:null),w(e.enabled),!e.enabled){c=null,l=!1,g(),i&&t&&i.ownerDocument.activeElement===i&&t.focus({preventScroll:!0});return}l&&e.editing&&(l=!1,g()),!(c!==null||l)&&(e.activeCell!==null&&!n(f,e.activeCell)&&h(e.activeCell,!1)&&(f=e.activeCell),!e.editing&&t&&t.ownerDocument.activeElement===t&&m())},attach:e=>{i!==e&&(i=e,T(r?.enabled?i:null),i&&(typeof matchMedia==`function`&&matchMedia(`(pointer: coarse)`).matches&&(i.inputMode=`none`),f=null))},dispose:()=>{T(null),C(null),w(!1),c=null,l=!1,r=null}}};exports.IME_INPUT_COMPOSING_CLASS=e,exports.createImeInputController=r;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../logic/detailRow.cjs"),t=require("../logic/domGuards.cjs");var n=`ssg-ime-input--composing`,r=(t,n,r)=>{let i=t.querySelectorAll(`.ssg-body-row[data-row-index="${n.row}"]`);for(let n of Array.from(i)){if(e.isInsideDetailCardOf(t,n))continue;let i=n.querySelectorAll(`.ssg-body-cell`);for(let e of Array.from(i))if(e.getAttribute(`data-ssg-col-key`)===r)return e}return null},i=(e,t)=>e===t||e!==null&&t!==null&&e.row===t.row&&e.col===t.col,a=()=>{let e=null,a=null,o=null,s=null,c=!1,l=null,u=!1,d=!1,f=!1,p=null,m=()=>e?.gridRootRef.current??null,h=()=>{a&&a.ownerDocument.activeElement!==a&&a.focus({preventScroll:!0})},g=(t,n)=>{let i=m(),o=e?.resolveCell(t)??null;if(!a||!i||!o)return!1;let s=r(i,t,o.colKey);if(!s)return!1;let c=i.getBoundingClientRect(),l=s.getBoundingClientRect();return a.style.left=`${l.left-c.left-i.clientLeft}px`,a.style.top=`${l.top-c.top-i.clientTop}px`,a.style.width=`${l.width}px`,a.style.height=`${l.height}px`,a.style.textAlign=n&&o.align?o.align:``,!0},_=()=>{a&&(a.classList.remove(n),a.value=``,a.style.textAlign=``)},v=t=>{e===null||!e.enabled||e.editing||d||t.target===o&&h()},y=()=>{if(e===null||!e.enabled||e.editing||e.activeCell===null){l=null;return}let t=e.activeCell,r=e.canStartEdit(t);l={cell:t,allowed:r},f=!1,r&&(g(t,!0),p=t,a?.classList.add(n))},b=t=>{let n=l;l=null;let r=f;if(f=!1,!a||n===null||!n.allowed||r){_();return}let i=a.value||t.data||``;queueMicrotask(()=>{let t=a;if(e===null||!e.enabled||!t||i===``||t.ownerDocument.activeElement!==t||!e.canStartEdit(n.cell)){_();return}let r=e.resolveEditText?e.resolveEditText(n.cell,i):i;if(r===null||r===``){_();return}u=!0,e.startEdit(n.cell,r),requestAnimationFrame(()=>{u&&e!==null&&!e.editing&&(u=!1,_())})})},x=()=>{l===null&&!u&&a&&(a.value=``)},S=e=>{if(e.target!==a||e.key!==`Tab`||e.defaultPrevented||t.isImeComposingKeyEvent(e))return;let n=m();if(n){d=!0;try{n.focus({preventScroll:!0})}finally{d=!1}}},C=()=>{l!==null&&(f=!0)},w=e=>{o!==e&&(o?.removeEventListener(`focus`,v),o=e,o?.addEventListener(`focus`,v))},T=e=>{typeof document>`u`||c===e||(c=e,e?(document.addEventListener(`keydown`,S),document.addEventListener(`pointerdown`,C,!0)):(document.removeEventListener(`keydown`,S),document.removeEventListener(`pointerdown`,C,!0)))},E=e=>{s!==e&&(s&&(s.removeEventListener(`compositionstart`,y),s.removeEventListener(`compositionend`,b),s.removeEventListener(`input`,x)),s=e,s&&(s.addEventListener(`compositionstart`,y),s.addEventListener(`compositionend`,b),s.addEventListener(`input`,x)))};return{update:t=>{e=t;let n=t.gridRootRef.current;if(w(t.enabled?n:null),E(t.enabled?a:null),T(t.enabled),!t.enabled){l=null,u=!1,_(),a&&n&&a.ownerDocument.activeElement===a&&n.focus({preventScroll:!0});return}u&&t.editing&&(u=!1,_()),!(l!==null||u)&&(t.activeCell!==null&&!i(p,t.activeCell)&&g(t.activeCell,!1)&&(p=t.activeCell),!t.editing&&n&&n.ownerDocument.activeElement===n&&h())},attach:t=>{a!==t&&(a=t,E(e?.enabled?a:null),a&&(typeof matchMedia==`function`&&matchMedia(`(pointer: coarse)`).matches&&(a.inputMode=`none`),p=null))},dispose:()=>{E(null),w(null),T(!1),l=null,u=!1,e=null}}};exports.IME_INPUT_COMPOSING_CLASS=n,exports.createImeInputController=a;
@@ -1,98 +1,101 @@
1
+ import { isInsideDetailCardOf as e } from "../logic/detailRow.js";
2
+ import { isImeComposingKeyEvent as t } from "../logic/domGuards.js";
1
3
  //#region src/controllers/imeInputController.ts
2
- var e = "ssg-ime-input--composing", t = (e, t, n) => {
3
- let r = e.querySelectorAll(`.ssg-body-row[data-row-index="${t.row}"]`);
4
- for (let e of Array.from(r)) {
5
- let t = e.querySelectorAll(".ssg-body-cell");
6
- for (let e of Array.from(t)) if (e.getAttribute("data-ssg-col-key") === n) return e;
4
+ var n = "ssg-ime-input--composing", r = (t, n, r) => {
5
+ let i = t.querySelectorAll(`.ssg-body-row[data-row-index="${n.row}"]`);
6
+ for (let n of Array.from(i)) {
7
+ if (e(t, n)) continue;
8
+ let i = n.querySelectorAll(".ssg-body-cell");
9
+ for (let e of Array.from(i)) if (e.getAttribute("data-ssg-col-key") === r) return e;
7
10
  }
8
11
  return null;
9
- }, n = (e, t) => e === t || e !== null && t !== null && e.row === t.row && e.col === t.col, r = () => {
10
- let r = null, i = null, a = null, o = null, s = !1, c = null, l = !1, u = !1, d = !1, f = null, p = () => r?.gridRootRef.current ?? null, m = () => {
11
- i && i.ownerDocument.activeElement !== i && i.focus({ preventScroll: !0 });
12
- }, h = (e, n) => {
13
- let a = p(), o = r?.resolveCell(e) ?? null;
14
- if (!i || !a || !o) return !1;
15
- let s = t(a, e, o.colKey);
12
+ }, i = (e, t) => e === t || e !== null && t !== null && e.row === t.row && e.col === t.col, a = () => {
13
+ let e = null, a = null, o = null, s = null, c = !1, l = null, u = !1, d = !1, f = !1, p = null, m = () => e?.gridRootRef.current ?? null, h = () => {
14
+ a && a.ownerDocument.activeElement !== a && a.focus({ preventScroll: !0 });
15
+ }, g = (t, n) => {
16
+ let i = m(), o = e?.resolveCell(t) ?? null;
17
+ if (!a || !i || !o) return !1;
18
+ let s = r(i, t, o.colKey);
16
19
  if (!s) return !1;
17
- let c = a.getBoundingClientRect(), l = s.getBoundingClientRect();
18
- return i.style.left = `${l.left - c.left - a.clientLeft}px`, i.style.top = `${l.top - c.top - a.clientTop}px`, i.style.width = `${l.width}px`, i.style.height = `${l.height}px`, i.style.textAlign = n && o.align ? o.align : "", !0;
19
- }, g = () => {
20
- i && (i.classList.remove(e), i.value = "", i.style.textAlign = "");
21
- }, _ = (e) => {
22
- r === null || !r.enabled || r.editing || u || e.target === a && m();
23
- }, v = () => {
24
- if (r === null || !r.enabled || r.editing || r.activeCell === null) {
25
- c = null;
20
+ let c = i.getBoundingClientRect(), l = s.getBoundingClientRect();
21
+ return a.style.left = `${l.left - c.left - i.clientLeft}px`, a.style.top = `${l.top - c.top - i.clientTop}px`, a.style.width = `${l.width}px`, a.style.height = `${l.height}px`, a.style.textAlign = n && o.align ? o.align : "", !0;
22
+ }, _ = () => {
23
+ a && (a.classList.remove(n), a.value = "", a.style.textAlign = "");
24
+ }, v = (t) => {
25
+ e === null || !e.enabled || e.editing || d || t.target === o && h();
26
+ }, y = () => {
27
+ if (e === null || !e.enabled || e.editing || e.activeCell === null) {
28
+ l = null;
26
29
  return;
27
30
  }
28
- let t = r.activeCell, n = r.canStartEdit(t);
29
- c = {
31
+ let t = e.activeCell, r = e.canStartEdit(t);
32
+ l = {
30
33
  cell: t,
31
- allowed: n
32
- }, d = !1, n && (h(t, !0), f = t, i?.classList.add(e));
33
- }, y = (e) => {
34
- let t = c;
35
- c = null;
36
- let n = d;
37
- if (d = !1, !i || t === null || !t.allowed || n) {
38
- g();
34
+ allowed: r
35
+ }, f = !1, r && (g(t, !0), p = t, a?.classList.add(n));
36
+ }, b = (t) => {
37
+ let n = l;
38
+ l = null;
39
+ let r = f;
40
+ if (f = !1, !a || n === null || !n.allowed || r) {
41
+ _();
39
42
  return;
40
43
  }
41
- let a = i.value || e.data || "";
44
+ let i = a.value || t.data || "";
42
45
  queueMicrotask(() => {
43
- let e = i;
44
- if (r === null || !r.enabled || !e || a === "" || e.ownerDocument.activeElement !== e || !r.canStartEdit(t.cell)) {
45
- g();
46
+ let t = a;
47
+ if (e === null || !e.enabled || !t || i === "" || t.ownerDocument.activeElement !== t || !e.canStartEdit(n.cell)) {
48
+ _();
46
49
  return;
47
50
  }
48
- let n = r.resolveEditText ? r.resolveEditText(t.cell, a) : a;
49
- if (n === null || n === "") {
50
- g();
51
+ let r = e.resolveEditText ? e.resolveEditText(n.cell, i) : i;
52
+ if (r === null || r === "") {
53
+ _();
51
54
  return;
52
55
  }
53
- l = !0, r.startEdit(t.cell, n), requestAnimationFrame(() => {
54
- l && r !== null && !r.editing && (l = !1, g());
56
+ u = !0, e.startEdit(n.cell, r), requestAnimationFrame(() => {
57
+ u && e !== null && !e.editing && (u = !1, _());
55
58
  });
56
59
  });
57
- }, b = () => {
58
- c === null && !l && i && (i.value = "");
59
- }, x = (e) => {
60
- if (e.target !== i || e.key !== "Tab" || e.defaultPrevented || e.isComposing) return;
61
- let t = p();
62
- if (t) {
63
- u = !0;
60
+ }, x = () => {
61
+ l === null && !u && a && (a.value = "");
62
+ }, S = (e) => {
63
+ if (e.target !== a || e.key !== "Tab" || e.defaultPrevented || t(e)) return;
64
+ let n = m();
65
+ if (n) {
66
+ d = !0;
64
67
  try {
65
- t.focus({ preventScroll: !0 });
68
+ n.focus({ preventScroll: !0 });
66
69
  } finally {
67
- u = !1;
70
+ d = !1;
68
71
  }
69
72
  }
70
- }, S = () => {
71
- c !== null && (d = !0);
72
- }, C = (e) => {
73
- a !== e && (a?.removeEventListener("focus", _), a = e, a?.addEventListener("focus", _));
73
+ }, C = () => {
74
+ l !== null && (f = !0);
74
75
  }, w = (e) => {
75
- typeof document > "u" || s === e || (s = e, e ? (document.addEventListener("keydown", x), document.addEventListener("pointerdown", S, !0)) : (document.removeEventListener("keydown", x), document.removeEventListener("pointerdown", S, !0)));
76
+ o !== e && (o?.removeEventListener("focus", v), o = e, o?.addEventListener("focus", v));
76
77
  }, T = (e) => {
77
- o !== e && (o && (o.removeEventListener("compositionstart", v), o.removeEventListener("compositionend", y), o.removeEventListener("input", b)), o = e, o && (o.addEventListener("compositionstart", v), o.addEventListener("compositionend", y), o.addEventListener("input", b)));
78
+ typeof document > "u" || c === e || (c = e, e ? (document.addEventListener("keydown", S), document.addEventListener("pointerdown", C, !0)) : (document.removeEventListener("keydown", S), document.removeEventListener("pointerdown", C, !0)));
79
+ }, E = (e) => {
80
+ s !== e && (s && (s.removeEventListener("compositionstart", y), s.removeEventListener("compositionend", b), s.removeEventListener("input", x)), s = e, s && (s.addEventListener("compositionstart", y), s.addEventListener("compositionend", b), s.addEventListener("input", x)));
78
81
  };
79
82
  return {
80
- update: (e) => {
81
- r = e;
82
- let t = e.gridRootRef.current;
83
- if (C(e.enabled ? t : null), T(e.enabled ? i : null), w(e.enabled), !e.enabled) {
84
- c = null, l = !1, g(), i && t && i.ownerDocument.activeElement === i && t.focus({ preventScroll: !0 });
83
+ update: (t) => {
84
+ e = t;
85
+ let n = t.gridRootRef.current;
86
+ if (w(t.enabled ? n : null), E(t.enabled ? a : null), T(t.enabled), !t.enabled) {
87
+ l = null, u = !1, _(), a && n && a.ownerDocument.activeElement === a && n.focus({ preventScroll: !0 });
85
88
  return;
86
89
  }
87
- l && e.editing && (l = !1, g()), !(c !== null || l) && (e.activeCell !== null && !n(f, e.activeCell) && h(e.activeCell, !1) && (f = e.activeCell), !e.editing && t && t.ownerDocument.activeElement === t && m());
90
+ u && t.editing && (u = !1, _()), !(l !== null || u) && (t.activeCell !== null && !i(p, t.activeCell) && g(t.activeCell, !1) && (p = t.activeCell), !t.editing && n && n.ownerDocument.activeElement === n && h());
88
91
  },
89
- attach: (e) => {
90
- i !== e && (i = e, T(r?.enabled ? i : null), i && (typeof matchMedia == "function" && matchMedia("(pointer: coarse)").matches && (i.inputMode = "none"), f = null));
92
+ attach: (t) => {
93
+ a !== t && (a = t, E(e?.enabled ? a : null), a && (typeof matchMedia == "function" && matchMedia("(pointer: coarse)").matches && (a.inputMode = "none"), p = null));
91
94
  },
92
95
  dispose: () => {
93
- T(null), C(null), w(!1), c = null, l = !1, r = null;
96
+ E(null), w(null), T(!1), l = null, u = !1, e = null;
94
97
  }
95
98
  };
96
99
  };
97
100
  //#endregion
98
- export { e as IME_INPUT_COMPOSING_CLASS, r as createImeInputController };
101
+ export { n as IME_INPUT_COMPOSING_CLASS, a as createImeInputController };
@@ -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");var i=14,a=12,o=`0.5`,s=`<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>`,c=`<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>`,l=200,u=`cubic-bezier(0.2, 0.7, 0.3, 1)`,d=`transform 160ms ${u}`,f=`data-ssg-row-dragging`,p=e=>e?.closest(`.ssg-motion-off`)!=null,m=/translateY\((-?[\d.]+)px\)/,h=e=>{let n=[];return e.querySelectorAll(`.ssg-body-row[data-row-index]`).forEach(r=>{t.isInsideDetailCardOf(e,r)||n.push(r)}),n},g=()=>{let g=null,_=null,v=null,y={x:0,y:0},b=null,x=!1,S=null,C=null,w=null,T=null,E=null,D=0,O=()=>g?.motion===`live`,k=null,A=null,j=null,M=()=>[g?.leftIndicatorRef.current??null,g?.centerIndicatorRef.current??null,g?.rightIndicatorRef.current??null],N=()=>{for(let e of M())e&&(e.style.display=`none`)},P=e=>{if(k)return;let t=document.createElement(`div`);t.setAttribute(`data-grid-drag-ghost`,``),g?.scrollContainerRef.current?.closest(`.ssg-theme-dark`)!=null&&t.classList.add(`ssg-theme-dark`),g?.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,g?.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 i=document.createElement(`span`);i.style.cssText=`overflow:hidden;text-overflow:ellipsis`,i.textContent=e,t.appendChild(n),t.appendChild(i),document.body.appendChild(t),k=t,A=n,j=null},F=e=>{let t=k;if(!t)return;t.style.transform=`translate(`+(y.x+i)+`px,`+(y.y+a)+`px)`;let n=e?`move`:`out`;if(j===n)return;j=n;let r=A;n===`out`?(t.style.opacity=o,r&&(r.innerHTML=c)):(t.style.opacity=`1`,r&&(r.innerHTML=s))},I=()=>{k&&k.parentNode&&k.parentNode.removeChild(k),k=null,A=null,j=null},L=(e,n)=>{let r=g?.scrollContainerRef.current??null;!r||e===null||r.querySelectorAll(`.ssg-body-row[data-row-index="${e}"]`).forEach(e=>{t.isInsideDetailCardOf(r,e)||(n?e.setAttribute(f,O()?`live`:``):e.removeAttribute(f))})},R=()=>{let e=g?.scrollContainerRef.current??null;if(!e)return null;let t=new Map;for(let n of h(e)){let e=m.exec(n.style.transform);e&&t.set(n,{index:Number(n.getAttribute(`data-row-index`)),baseY:parseFloat(e[1])})}return t},z=t=>{let n=E,r=_;if(!n||r===null||g===null)return;let i=g.scrollContainerRef.current;if(!i)return;for(let e of h(i)){if(n.has(e))continue;let t=m.exec(e.style.transform);t&&n.set(e,{index:Number(e.getAttribute(`data-row-index`)),baseY:parseFloat(t[1])})}let a=g.rowMetrics.rowsHeight(r,r),o=(i.scrollTop-D)*g.verticalScaleFactor,s=(b?y.y-b.y:0)+o,c=t===null?null:e.resolveMoveTargetIndex(r,t);n.forEach(({index:e,baseY:t},i)=>{if(!i.isConnected){n.delete(i);return}if(e===r){i.style.transition=`none`,i.style.transform=`translateY(${t+s}px)`,i.style.willChange=`transform`;return}let o=0;c!==null&&(r<e&&e<=c?o=-a:c<=e&&e<r&&(o=a)),i.style.transition=d,i.style.transform=`translateY(${t+o}px)`})},B=(t,r)=>{if(g===null)return null;let{scrollContainerRef:i,bodyScrollRef:a,rowMetrics:o,headerHeight:s,verticalScaleFactor:c,windowBaseOffsetPx:l}=g,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,g.footerHeight??0),m=d.getBoundingClientRect(),h=e.resolveRowDropSlot(d.scrollTop+p-m.top-s-u.scrollTop*(1-c),o);return{slot:h,top:s+e.resolveRowDropSlotTop(h,o)-l}},V=()=>{let t=B(y.x,y.y),n=_;if(O()){t&&n!==null&&(v=e.resolveMoveTargetIndex(n,t.slot)===null?null:t.slot),N(),z(v);return}if(F(t),!t||n===null||e.resolveMoveTargetIndex(n,t.slot)===null){v=null,N();return}v=t.slot;for(let e of M())e&&(e.style.top=`${t.top}px`,e.style.display=`block`)},H=()=>{if(_===null){w=null;return}let e=g?.scrollContainerRef.current??null;if(e&&(x||(!b||n.hasPointerLeftActivationRadius(b,y,6))&&(x=!0),x)){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(y.y,r.top,r.bottom-(g?.footerHeight??0),24),a=n.computeNextScrollPosition(e.scrollTop,i,18,e.scrollHeight-e.clientHeight);a!==e.scrollTop&&e.scrollTo({top:a,behavior:`auto`})}V(),w=requestAnimationFrame(H)},U=()=>{let e=g?.scrollContainerRef.current??null;if(!e)return null;let t=new Map;for(let n of h(e))t.set(n,n.getBoundingClientRect().top);return t},W=t=>{w!==null&&(cancelAnimationFrame(w),w=null),document.body.style.cursor=``,N(),I();let n=_,r=v;L(n,!1),_=null,v=null,b=null,C=null;let i=n===null||r===null?null:e.resolveMoveTargetIndex(n,r),a=t&&n!==null&&i!==null&&g!==null,o=E;if(E=null,o)if(a)o.forEach((e,t)=>{t.style.transition=``,t.style.willChange=``});else{let e=[];o.forEach(({baseY:t},n)=>{n.isConnected&&(n.style.transition=d,n.style.transform=`translateY(${t}px)`,e.push(n))}),window.setTimeout(()=>{for(let t of e)t.style.transition=``,t.style.willChange=``},200)}!a||n===null||i===null||g===null||(T=p(g.scrollContainerRef.current)?null:U(),g.commitRowMove(n,i))};return{update:e=>{g=e},onRowDragHandlePointerDown:(e,t)=>{if(g===null||!g.enabled||t.button!==0)return;if(t.stopPropagation(),t.preventDefault(),_!==null){if(t.pointerId!==C)return;S?.(),W(!1)}_=e,C=t.pointerId,v=null,y={x:t.clientX,y:t.clientY},b={x:t.clientX,y:t.clientY},x=!1,document.body.style.cursor=`grabbing`,O()?(E=R(),D=g.scrollContainerRef.current?.scrollTop??0):P(g.getRowDragLabel(e)),L(e,!0);let n=t.currentTarget,r=t.pointerId;try{n.setPointerCapture(r)}catch{}let i=e=>{e.pointerId===r&&(y={x:e.clientX,y:e.clientY},V())},a=()=>{window.removeEventListener(`pointermove`,i),window.removeEventListener(`pointerup`,o),window.removeEventListener(`pointercancel`,s),window.removeEventListener(`keydown`,c),window.removeEventListener(`blur`,l),S=null;try{n.releasePointerCapture(r)}catch{}};function o(e){e.pointerId===r&&(a(),W(!0))}function s(e){e.pointerId===r&&(a(),W(!1))}function c(e){e.key===`Escape`&&(a(),W(!1))}function l(){a(),W(!1)}window.addEventListener(`pointermove`,i),window.addEventListener(`pointerup`,o),window.addEventListener(`pointercancel`,s),window.addEventListener(`keydown`,c),window.addEventListener(`blur`,l),S=a,V(),w=requestAnimationFrame(H)},applyReorderSettle:()=>{let e=T;if(T=null,!e)return;let t=g?.scrollContainerRef.current??null;if(!t)return;let n=[],r=new Map;if(e.forEach((e,t)=>{if(!t.isConnected)return;let i=e-t.getBoundingClientRect().top;if(Math.abs(i)<.5)return;let a=m.exec(t.style.transform);if(!a)return;let o=parseFloat(a[1]);r.set(t,o),t.style.transition=`none`,t.style.transform=`translateY(${o+i}px)`,t.style.willChange=`transform`,n.push(t)}),n.length!==0){t.getBoundingClientRect();for(let e of n)e.style.transition=`transform ${l}ms ${u}`,e.style.transform=`translateY(${r.get(e)??0}px)`;window.setTimeout(()=>{for(let e of n)e.style.transition=``,e.style.willChange=``},280)}},dispose:()=>{S?.(),S=null,w!==null&&(cancelAnimationFrame(w),w=null),document.body.style.cursor=``,I(),L(_,!1),_=null,v=null,E=null}}};exports.createRowDragController=g;
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");var i=14,a=12,o=`0.5`,s=`<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>`,c=`<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>`,l=200,u=`cubic-bezier(0.2, 0.7, 0.3, 1)`,d=`transform 160ms ${u}`,f=`data-ssg-row-dragging`,p=e=>e?.closest(`.ssg-motion-off`)!=null,m=/translateY\((-?[\d.]+)px\)/,h=e=>{let n=[];return e.querySelectorAll(`.ssg-body-row[data-row-index]`).forEach(r=>{t.isInsideDetailCardOf(e,r)||n.push(r)}),n},g=()=>{let g=null,_=null,v=null,y={x:0,y:0},b=null,x=!1,S=null,C=null,w=null,T=null,E=null,D=null,O=0,k=()=>g?.motion===`live`,A=null,j=null,M=null,N=()=>[g?.leftIndicatorRef.current??null,g?.centerIndicatorRef.current??null,g?.rightIndicatorRef.current??null],P=()=>{for(let e of N())e&&(e.style.display=`none`)},F=e=>{if(A)return;let t=document.createElement(`div`);t.setAttribute(`data-grid-drag-ghost`,``),g?.scrollContainerRef.current?.closest(`.ssg-theme-dark`)!=null&&t.classList.add(`ssg-theme-dark`),g?.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,g?.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 i=document.createElement(`span`);i.style.cssText=`overflow:hidden;text-overflow:ellipsis`,i.textContent=e,t.appendChild(n),t.appendChild(i),document.body.appendChild(t),A=t,j=n,M=null},I=e=>{let t=A;if(!t)return;t.style.transform=`translate(`+(y.x+i)+`px,`+(y.y+a)+`px)`;let n=e?`move`:`out`;if(M===n)return;M=n;let r=j;n===`out`?(t.style.opacity=o,r&&(r.innerHTML=c)):(t.style.opacity=`1`,r&&(r.innerHTML=s))},L=()=>{A&&A.parentNode&&A.parentNode.removeChild(A),A=null,j=null,M=null},R=(e,n)=>{let r=g?.scrollContainerRef.current??null;!r||n&&e===null||r.querySelectorAll(n?`.ssg-body-row[data-row-index="${e}"]`:`.ssg-body-row[${f}]`).forEach(e=>{t.isInsideDetailCardOf(r,e)||(n?e.setAttribute(f,k()?`live`:``):e.removeAttribute(f))})},z=()=>{let e=g?.scrollContainerRef.current??null;if(!e)return null;let t=new Map;for(let n of h(e)){let e=m.exec(n.style.transform);e&&t.set(n,{index:Number(n.getAttribute(`data-row-index`)),baseY:parseFloat(e[1])})}return t},B=t=>{let n=D,r=_;if(!n||r===null||g===null)return;let i=g.scrollContainerRef.current;if(!i)return;for(let e of h(i)){if(n.has(e))continue;let t=m.exec(e.style.transform);t&&n.set(e,{index:Number(e.getAttribute(`data-row-index`)),baseY:parseFloat(t[1])})}let a=g.rowMetrics.rowsHeight(r,r),o=(i.scrollTop-O)*g.verticalScaleFactor,s=(b?y.y-b.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=d,t.style.transform=`translateY(${o+l}px)`,e.applied=t.style.transform})},V=(t,r)=>{if(g===null)return null;let{scrollContainerRef:i,bodyScrollRef:a,rowMetrics:o,headerHeight:s,verticalScaleFactor:c,windowBaseOffsetPx:l}=g,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,g.footerHeight??0),m=d.getBoundingClientRect(),h=e.resolveRowDropSlot(d.scrollTop+p-m.top-s-u.scrollTop*(1-c),o);return{slot:h,top:s+e.resolveRowDropSlotTop(h,o)-l}},H=()=>{let t=V(y.x,y.y),n=_;if(k()){t&&n!==null&&(v=e.resolveMoveTargetIndex(n,t.slot)===null?null:t.slot),P(),B(v);return}if(I(t),!t||n===null||e.resolveMoveTargetIndex(n,t.slot)===null){v=null,P();return}v=t.slot;for(let e of N())e&&(e.style.top=`${t.top}px`,e.style.display=`block`)},U=()=>{if(_===null){w=null;return}let e=g?.scrollContainerRef.current??null;if(e&&(x||(!b||n.hasPointerLeftActivationRadius(b,y,6))&&(x=!0),x)){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(y.y,r.top,r.bottom-(g?.footerHeight??0),24),a=n.computeNextScrollPosition(e.scrollTop,i,18,e.scrollHeight-e.clientHeight);a!==e.scrollTop&&e.scrollTo({top:a,behavior:`auto`})}H(),w=requestAnimationFrame(U)},W=(e,t)=>`${e.getAttribute(`data-pane`)??``}|${t}`,G=()=>{let e=g?.scrollContainerRef.current??null;if(!e)return null;let t=new Map;for(let n of h(e))t.set(W(n,Number(n.getAttribute(`data-row-index`))),n.getBoundingClientRect().top);return t},K=t=>{w!==null&&(cancelAnimationFrame(w),w=null),document.body.style.cursor=``,P(),L();let n=_,r=v,i=E;R(n,!1),_=null,E=null,v=null,b=null,C=null;let a=n===null||r===null?null:e.resolveMoveTargetIndex(n,r),o=t&&n!==null&&a!==null&&g!==null,s=D;D=null;let c=s&&o&&g!==null&&!p(g.scrollContainerRef.current)?G():null;if(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=d,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||g===null)return;let l=c??(p(g.scrollContainerRef.current)?null:G()),u=l?{tops:l,from:n,to:a,row:i}:null;T=u,g.commitRowMove(n,a),u&&requestAnimationFrame(()=>{T===u&&(T=null)})},q=()=>{let e=T;if(T=null,!e)return;let t=g?.scrollContainerRef.current??null;if(!t)return;let{tops:n,from:r,to:i}=e;if(g?.locateDragRow&&e.row!==null&&g.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;if(h(t).forEach(e=>{let t=n.get(W(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=m.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)}),o.length!==0){t.getBoundingClientRect();for(let e of o)e.style.transition=`transform ${l}ms ${u}`,e.style.transform=`translateY(${s.get(e)??0}px)`;window.setTimeout(()=>{for(let e of o)e.style.transition=``,e.style.willChange=``},280)}},J=(e,t)=>{if(g===null||!g.enabled||t.button!==0)return;if(t.stopPropagation(),t.preventDefault(),_!==null){if(t.pointerId!==C)return;S?.(),K(!1)}_=e,E=g.getDragRow?.(e)??null,C=t.pointerId,v=null,y={x:t.clientX,y:t.clientY},b={x:t.clientX,y:t.clientY},x=!1,document.body.style.cursor=`grabbing`,k()?(D=z(),O=g.scrollContainerRef.current?.scrollTop??0):F(g.getRowDragLabel(e)),R(e,!0);let n=t.currentTarget,r=t.pointerId;try{n.setPointerCapture(r)}catch{}let i=e=>{e.pointerId===r&&(y={x:e.clientX,y:e.clientY},H())},a=()=>{window.removeEventListener(`pointermove`,i),window.removeEventListener(`pointerup`,o),window.removeEventListener(`pointercancel`,s),window.removeEventListener(`keydown`,c),window.removeEventListener(`blur`,l),S=null;try{n.releasePointerCapture(r)}catch{}};function o(e){e.pointerId===r&&(a(),K(!0))}function s(e){e.pointerId===r&&(a(),K(!1))}function c(e){e.key===`Escape`&&(a(),K(!1))}function l(){a(),K(!1)}window.addEventListener(`pointermove`,i),window.addEventListener(`pointerup`,o),window.addEventListener(`pointercancel`,s),window.addEventListener(`keydown`,c),window.addEventListener(`blur`,l),S=a,H(),w=requestAnimationFrame(U)},Y=e=>{if(_===null||E==null||g?.locateDragRow===void 0)return;let t=g.locateDragRow(E,_);if(D&&D.forEach((e,t)=>{if(!t.isConnected){D?.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=m.exec(t.style.transform);if(!r){D?.delete(t);return}e.index=n,e.baseY=parseFloat(r[1]),e.applied=void 0}),t===null){S?.(),K(!1);return}D&&t!==_&&b!==null&&e!==null&&(b={x:b.x,y:b.y+g.rowMetrics.rowTop(t)-e.rowTop(_)}),t!==_&&(R(null,!1),_=t,R(t,!0)),H()};return{update:e=>{let t=g;g=e,_!==null&&t!==null&&t.locateDragRow!==e.locateDragRow&&Y(t.rowMetrics)},onRowDragHandlePointerDown:J,applyReorderSettle:q,dispose:()=>{S?.(),S=null,w!==null&&(cancelAnimationFrame(w),w=null),document.body.style.cursor=``,L(),R(_,!1),_=null,E=null,v=null,D=null,T=null}}};exports.createRowDragController=g;
@@ -19,6 +19,8 @@ export type RowDragArgs = {
19
19
  commitRowMove: (fromIndex: number, toIndex: number) => void;
20
20
  ghostSlot?: GridResolvedSlot;
21
21
  motion?: 'ghost' | 'live';
22
+ getDragRow?: (viewIndex: number) => unknown;
23
+ locateDragRow?: (dragRow: unknown, hint: number) => number | null;
22
24
  };
23
25
  export type RowDragHandlePointerEvent = {
24
26
  button: number;