@ishibashi0112/spreadsheet-grid-core 0.46.0 → 0.46.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.
- package/dist/controllers/changeHighlightController.cjs +1 -0
- package/dist/controllers/changeHighlightController.d.ts +31 -0
- package/dist/controllers/changeHighlightController.js +97 -0
- package/dist/controllers/clipboardController.cjs +1 -1
- package/dist/controllers/clipboardController.d.ts +1 -0
- package/dist/controllers/clipboardController.js +1 -1
- package/dist/controllers/columnHeaderDragController.cjs +1 -1
- package/dist/controllers/columnHeaderDragController.js +3 -3
- package/dist/controllers/findController.cjs +1 -0
- package/dist/controllers/findController.d.ts +38 -0
- package/dist/controllers/findController.js +137 -0
- package/dist/controllers/keyboardController.cjs +1 -1
- package/dist/controllers/keyboardController.d.ts +1 -0
- package/dist/controllers/keyboardController.js +14 -10
- package/dist/controllers/pointerInteractionsController.cjs +1 -1
- package/dist/controllers/pointerInteractionsController.d.ts +1 -0
- package/dist/controllers/pointerInteractionsController.js +1 -1
- package/dist/controllers/reducedMotionStore.cjs +1 -0
- package/dist/controllers/reducedMotionStore.d.ts +5 -0
- package/dist/controllers/reducedMotionStore.js +18 -0
- package/dist/controllers/rowDragController.cjs +1 -1
- package/dist/controllers/rowDragController.d.ts +1 -0
- package/dist/controllers/rowDragController.js +121 -70
- package/dist/controllers/rowEnterController.cjs +1 -0
- package/dist/controllers/rowEnterController.d.ts +18 -0
- package/dist/controllers/rowEnterController.js +53 -0
- package/dist/controllers/saveStatusController.cjs +1 -0
- package/dist/controllers/saveStatusController.d.ts +30 -0
- package/dist/controllers/saveStatusController.js +74 -0
- package/dist/controllers/scrollSyncController.cjs +1 -1
- package/dist/controllers/scrollSyncController.d.ts +2 -0
- package/dist/controllers/scrollSyncController.js +36 -34
- package/dist/controllers/serverSideRowModel.cjs +1 -1
- package/dist/controllers/serverSideRowModel.d.ts +8 -0
- package/dist/controllers/serverSideRowModel.js +21 -6
- package/dist/controllers/tooltipController.cjs +1 -1
- package/dist/controllers/tooltipController.js +1 -1
- package/dist/engine/createGridEngine.cjs +1 -1
- package/dist/engine/createGridEngine.d.ts +10 -0
- package/dist/engine/createGridEngine.js +56 -46
- package/dist/engine/gridApi.cjs +1 -1
- package/dist/engine/gridApi.d.ts +6 -0
- package/dist/engine/gridApi.js +12 -0
- package/dist/logic/conditionalFormat.cjs +1 -0
- package/dist/logic/conditionalFormat.d.ts +19 -0
- package/dist/logic/conditionalFormat.js +88 -0
- package/dist/logic/find.cjs +1 -0
- package/dist/logic/find.d.ts +27 -0
- package/dist/logic/find.js +56 -0
- package/dist/logic/motion.cjs +1 -0
- package/dist/logic/motion.d.ts +4 -0
- package/dist/logic/motion.js +4 -0
- package/dist/logic/selectionOverlayGeometry.cjs +1 -0
- package/dist/logic/selectionOverlayGeometry.d.ts +15 -0
- package/dist/logic/selectionOverlayGeometry.js +43 -0
- package/dist/model/gridStore.cjs +1 -1
- package/dist/model/gridStore.d.ts +13 -1
- package/dist/model/gridStore.js +11 -5
- package/dist/model/gridTypes.core.d.ts +187 -0
- package/dist/model/gridTypes.unbound.d.ts +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../utils/permissions.cjs");var t=`ssg-body-cell--changed`,n=5e3,r=2e3,i=200,a=1500,o=260,s=(e,t,n)=>e.valueFormatter?e.valueFormatter({value:n,row:t,column:e}):String(n??``),c=e=>typeof e==`number`&&Number.isFinite(e),l=(e,t)=>{if(!e)return t;let n=e.trim(),r=/^(-?[\d.]+)\s*(ms|s)$/.exec(n);if(!r)return t;let i=Number(r[1]);return Number.isFinite(i)?r[2]===`s`?i*1e3:i:t},u=(t,n,r,i,a)=>{if(t.length!==r.length)return null;let o=[],s=0;for(let c=0;c<r.length;c+=1){let l=t[c],u=r[c];if(l===u)continue;if(s+=1,s>5e3)return null;let d=i(u,c);if(n(l,c)!==d)return null;for(let t of a){let n=e.getCellValue(l,t),r=e.getCellValue(u,t);if(!Object.is(n,r)&&(o.push({rowKey:d,column:t,row:u,prevValue:n,nextValue:r}),o.length>2e3))return null}}return o},d=e=>typeof CSS<`u`&&typeof CSS.escape==`function`?CSS.escape(e):e.replace(/["\\]/g,`\\$&`),f=()=>{let e=null,n=new Map,r=new Set,i=e=>{e.classList.remove(t);let r=n.get(e);r!==void 0&&(clearTimeout(r),n.delete(e))},f=e=>{i(e),e.offsetWidth,e.classList.add(t);let r=()=>{e.removeEventListener(`animationend`,r),i(e)};e.addEventListener(`animationend`,r),n.set(e,setTimeout(()=>{e.removeEventListener(`animationend`,r),i(e)},a))},p=e=>{let t=e.firstElementChild;if(!t||t.childNodes.length!==1)return null;let n=t.firstChild;return n&&n.nodeType===Node.TEXT_NODE?n:null},m=(e,t,n)=>{if(!c(t.prevValue)||!c(t.nextValue)||n<=0||typeof requestAnimationFrame!=`function`)return;let i=p(e);if(!i)return;let a=i.nodeValue??``,o=t.prevValue,l=t.nextValue,u=/\.(\d+)$/.exec(String(l)),d=Math.min(2,u?u[1].length:0),f=performance.now();i.nodeValue=s(t.column,t.row,o);let m=e=>{r.delete(h);let c=Math.min(1,(e-f)/n);if(c>=1||i.parentNode===null){i.nodeValue=a;return}let u=1-(1-c)**3,p=Number((o+(l-o)*u).toFixed(d));i.nodeValue=s(t.column,t.row,p),h=requestAnimationFrame(m),r.add(h)},h=requestAnimationFrame(m);r.add(h)};return{update:t=>{let{enabled:n,rows:r,rowKeyGetter:i,columns:a,scrollContainerRef:s}=t,c=e;if(e={rows:r,rowKeyGetter:i},!n||c===null||c.rows===r)return;let p=s.current;if(!p)return;let h=u(c.rows,c.rowKeyGetter,r,i,a);if(!h||h.length===0)return;let g=l(getComputedStyle(p).getPropertyValue(`--ssg-motion-base`),o),_=h.length<=200;for(let e of h){let t=`.ssg-body-row[data-row-key="${d(String(e.rowKey))}"] .ssg-body-cell[data-ssg-col-key="${d(String(e.column.key))}"]`;p.querySelectorAll(t).forEach(t=>{f(t),_&&!e.column.renderCell&&m(t,e,g)})}},dispose:()=>{for(let e of Array.from(n.keys()))i(e);if(typeof cancelAnimationFrame==`function`)for(let e of r)cancelAnimationFrame(e);r.clear(),e=null}}};exports.CHANGED_CLASS_NAME=t,exports.CHANGED_FALLBACK_MS=a,exports.MAX_CHANGED_ROWS=n,exports.MAX_FLASH_CELLS=r,exports.MAX_TWEEN_CELLS=i,exports.createChangeHighlightController=f,exports.diffChangedCells=u,exports.parseCssDuration=l;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { GridColumn, GridRowKey } from '../model/gridTypes.unbound.js';
|
|
2
|
+
type ReadonlyRef<V> = {
|
|
3
|
+
readonly current: V;
|
|
4
|
+
};
|
|
5
|
+
export type ChangeHighlightArgs<T> = {
|
|
6
|
+
enabled: boolean;
|
|
7
|
+
rows: readonly T[];
|
|
8
|
+
rowKeyGetter: (row: T, index: number) => GridRowKey;
|
|
9
|
+
columns: readonly GridColumn<T>[];
|
|
10
|
+
scrollContainerRef: ReadonlyRef<HTMLElement | null>;
|
|
11
|
+
};
|
|
12
|
+
export type ChangeHighlightController<T> = {
|
|
13
|
+
update: (args: ChangeHighlightArgs<T>) => void;
|
|
14
|
+
dispose: () => void;
|
|
15
|
+
};
|
|
16
|
+
export declare const CHANGED_CLASS_NAME = "ssg-body-cell--changed";
|
|
17
|
+
export declare const MAX_CHANGED_ROWS = 5000;
|
|
18
|
+
export declare const MAX_FLASH_CELLS = 2000;
|
|
19
|
+
export declare const MAX_TWEEN_CELLS = 200;
|
|
20
|
+
export declare const CHANGED_FALLBACK_MS = 1500;
|
|
21
|
+
type ChangedCell<T> = {
|
|
22
|
+
rowKey: GridRowKey;
|
|
23
|
+
column: GridColumn<T>;
|
|
24
|
+
row: T;
|
|
25
|
+
prevValue: unknown;
|
|
26
|
+
nextValue: unknown;
|
|
27
|
+
};
|
|
28
|
+
export declare const parseCssDuration: (raw: string | null | undefined, fallback: number) => number;
|
|
29
|
+
export declare const diffChangedCells: <T>(prevRows: readonly T[], prevKeyOf: (row: T, index: number) => GridRowKey, nextRows: readonly T[], nextKeyOf: (row: T, index: number) => GridRowKey, columns: readonly GridColumn<T>[]) => ChangedCell<T>[] | null;
|
|
30
|
+
export declare const createChangeHighlightController: <T>() => ChangeHighlightController<T>;
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { getCellValue as e } from "../utils/permissions.js";
|
|
2
|
+
//#region src/controllers/changeHighlightController.ts
|
|
3
|
+
var t = "ssg-body-cell--changed", n = 5e3, r = 2e3, i = 200, a = 1500, o = 260, s = (e, t, n) => e.valueFormatter ? e.valueFormatter({
|
|
4
|
+
value: n,
|
|
5
|
+
row: t,
|
|
6
|
+
column: e
|
|
7
|
+
}) : String(n ?? ""), c = (e) => typeof e == "number" && Number.isFinite(e), l = (e, t) => {
|
|
8
|
+
if (!e) return t;
|
|
9
|
+
let n = e.trim(), r = /^(-?[\d.]+)\s*(ms|s)$/.exec(n);
|
|
10
|
+
if (!r) return t;
|
|
11
|
+
let i = Number(r[1]);
|
|
12
|
+
return Number.isFinite(i) ? r[2] === "s" ? i * 1e3 : i : t;
|
|
13
|
+
}, u = (t, n, r, i, a) => {
|
|
14
|
+
if (t.length !== r.length) return null;
|
|
15
|
+
let o = [], s = 0;
|
|
16
|
+
for (let c = 0; c < r.length; c += 1) {
|
|
17
|
+
let l = t[c], u = r[c];
|
|
18
|
+
if (l === u) continue;
|
|
19
|
+
if (s += 1, s > 5e3) return null;
|
|
20
|
+
let d = i(u, c);
|
|
21
|
+
if (n(l, c) !== d) return null;
|
|
22
|
+
for (let t of a) {
|
|
23
|
+
let n = e(l, t), r = e(u, t);
|
|
24
|
+
if (!Object.is(n, r) && (o.push({
|
|
25
|
+
rowKey: d,
|
|
26
|
+
column: t,
|
|
27
|
+
row: u,
|
|
28
|
+
prevValue: n,
|
|
29
|
+
nextValue: r
|
|
30
|
+
}), o.length > 2e3)) return null;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return o;
|
|
34
|
+
}, d = (e) => typeof CSS < "u" && typeof CSS.escape == "function" ? CSS.escape(e) : e.replace(/["\\]/g, "\\$&"), f = () => {
|
|
35
|
+
let e = null, n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Set(), i = (e) => {
|
|
36
|
+
e.classList.remove(t);
|
|
37
|
+
let r = n.get(e);
|
|
38
|
+
r !== void 0 && (clearTimeout(r), n.delete(e));
|
|
39
|
+
}, f = (e) => {
|
|
40
|
+
i(e), e.offsetWidth, e.classList.add(t);
|
|
41
|
+
let r = () => {
|
|
42
|
+
e.removeEventListener("animationend", r), i(e);
|
|
43
|
+
};
|
|
44
|
+
e.addEventListener("animationend", r), n.set(e, setTimeout(() => {
|
|
45
|
+
e.removeEventListener("animationend", r), i(e);
|
|
46
|
+
}, a));
|
|
47
|
+
}, p = (e) => {
|
|
48
|
+
let t = e.firstElementChild;
|
|
49
|
+
if (!t || t.childNodes.length !== 1) return null;
|
|
50
|
+
let n = t.firstChild;
|
|
51
|
+
return n && n.nodeType === Node.TEXT_NODE ? n : null;
|
|
52
|
+
}, m = (e, t, n) => {
|
|
53
|
+
if (!c(t.prevValue) || !c(t.nextValue) || n <= 0 || typeof requestAnimationFrame != "function") return;
|
|
54
|
+
let i = p(e);
|
|
55
|
+
if (!i) return;
|
|
56
|
+
let a = i.nodeValue ?? "", o = t.prevValue, l = t.nextValue, u = /\.(\d+)$/.exec(String(l)), d = Math.min(2, u ? u[1].length : 0), f = performance.now();
|
|
57
|
+
i.nodeValue = s(t.column, t.row, o);
|
|
58
|
+
let m = (e) => {
|
|
59
|
+
r.delete(h);
|
|
60
|
+
let c = Math.min(1, (e - f) / n);
|
|
61
|
+
if (c >= 1 || i.parentNode === null) {
|
|
62
|
+
i.nodeValue = a;
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
let u = 1 - (1 - c) ** 3, p = Number((o + (l - o) * u).toFixed(d));
|
|
66
|
+
i.nodeValue = s(t.column, t.row, p), h = requestAnimationFrame(m), r.add(h);
|
|
67
|
+
}, h = requestAnimationFrame(m);
|
|
68
|
+
r.add(h);
|
|
69
|
+
};
|
|
70
|
+
return {
|
|
71
|
+
update: (t) => {
|
|
72
|
+
let { enabled: n, rows: r, rowKeyGetter: i, columns: a, scrollContainerRef: s } = t, c = e;
|
|
73
|
+
if (e = {
|
|
74
|
+
rows: r,
|
|
75
|
+
rowKeyGetter: i
|
|
76
|
+
}, !n || c === null || c.rows === r) return;
|
|
77
|
+
let p = s.current;
|
|
78
|
+
if (!p) return;
|
|
79
|
+
let h = u(c.rows, c.rowKeyGetter, r, i, a);
|
|
80
|
+
if (!h || h.length === 0) return;
|
|
81
|
+
let g = l(getComputedStyle(p).getPropertyValue("--ssg-motion-base"), o), _ = h.length <= 200;
|
|
82
|
+
for (let e of h) {
|
|
83
|
+
let t = `.ssg-body-row[data-row-key="${d(String(e.rowKey))}"] .ssg-body-cell[data-ssg-col-key="${d(String(e.column.key))}"]`;
|
|
84
|
+
p.querySelectorAll(t).forEach((t) => {
|
|
85
|
+
f(t), _ && !e.column.renderCell && m(t, e, g);
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
dispose: () => {
|
|
90
|
+
for (let e of Array.from(n.keys())) i(e);
|
|
91
|
+
if (typeof cancelAnimationFrame == "function") for (let e of r) cancelAnimationFrame(e);
|
|
92
|
+
r.clear(), e = null;
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
//#endregion
|
|
97
|
+
export { t as CHANGED_CLASS_NAME, a as CHANGED_FALLBACK_MS, n as MAX_CHANGED_ROWS, r as MAX_FLASH_CELLS, i as MAX_TWEEN_CELLS, f as createChangeHighlightController, u as diffChangedCells, l as parseCssDuration };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../utils/permissions.cjs"),t=require("../model/gridActions.cjs"),n=require("../logic/geometry.cjs"),r=require("../logic/domGuards.cjs"),i=require("../utils/clipboard.cjs"),a=require("../logic/labelRows.cjs");var o=(e,t,n)=>{if(t===0||n===0||e?.type!==`cell`)return!1;let{start:r,end:i}=e.range,a=Math.min(r.row,i.row),o=Math.min(r.col,i.col),s=Math.max(r.row,i.row),c=Math.max(r.col,i.col);return a===0&&o===0&&s===t-1&&c===n-1},s=()=>{let s=null,c=e=>{s=e},l=e=>{let{isRowExportable:t,rowModel:n}=e;if(t)return(e,r)=>t(e,{viewRowIndex:r,rowKey:n.getRowKey(r)??r})},u=t=>{let{rowModel:n,visibleColumns:r}=t,a=n.getRowCount();if(a===0||r.length===0)return``;let o=l(t),s=[];for(let t=0;t<a;t+=1){let a=n.getRow(t);if(!a||o&&!o(a,t))continue;let c=r.map(t=>{let n=e.getCellValue(a,t);return t.formatClipboardValue?t.formatClipboardValue(n,a):String(n??``)});s.push(i.joinTsvRow(c))}return s.join(`
|
|
2
|
-
`)};return{update:c,handleCopy:async()=>{if(s===null)return;let e=s,{rowModel:t,visibleColumns:n,uiState:r}=e,a=o(r.selection,t.getRowCount(),n.length)?u(e):i.serializeSelectionToTsv(t.getRow,t.getRowCount(),n,r.selection,l(e));a&&await i.writeTextToClipboard(a)},handlePaste:o=>{if(s===null)return;let{rows:c,rowModel:l,columns:u,visibleColumns:d,uiState:f,readOnly:p,canEditCell:m,createRow:h,createOverflowColumn:g,onRowsChange:_,onColumnsChange:v,applyServerSideCellEdits:y,dispatch:b}=s;if(f.editingCell||r.shouldIgnoreGridKeydown(o.target??null)||p||!_&&!y||!f.activeCell)return;let x=o.clipboardData?.getData(`text/plain`)??``;if(!x)return;o.preventDefault();let S=i.parseClipboardText(x);if(S.length===0)return;let C=S.reduce((e,t)=>Math.max(e,t.length),0);if(C===0)return;let w=f.activeCell.row,T=f.activeCell.col,E=l.getLabelRow===void 0?null:a.resolvePasteTargetViewIndexes(l,w,S.length),D=e=>E?E[e-w]:e,O=E?E[E.length-1]:f.activeCell.row+Math.max(S.length-1,0);if(y){let r=i.buildClipboardCellEdits(e=>l.getRow(D(e)),d,S,w,T,(t,n,r,i)=>e.isCellEditable({readOnly:p,canEditCell:m},D(t),n,r,i)).map(e=>({...e,viewIndex:D(e.viewIndex)}));r.length>0&&y(r);let a=n.clamp(O,0,Math.max(l.getRowCount()-1,0)),o=n.clamp(f.activeCell.col+Math.max(C-1,0),0,Math.max(d.length-1,0));b(t.gridActions.startSelection(f.activeCell)),b(t.gridActions.updateSelection({row:a,col:o})),b(t.gridActions.endSelection()),b(t.gridActions.activateCell(f.activeCell));return}if(!_||l.getSourceIndex(w)===void 0)return;let k=f.activeCell.col,A=[...c],j=[...d],M=l.getRowCount(),N=A.length,P=e=>{let t=D(e);return t<M?l.getSourceIndex(t):N+(t-M)},F=Math.max(O+1-M,0),I=A.length+F;if(I>A.length&&h)for(;A.length<I;)A.push(h());let L=k+C;if(L>j.length&&v&&g){let e=[];for(;j.length<L;){let t=g(j.length);j.push(t),e.push(t)}v(u?[...u,...e]:j)}let R=i.applyClipboardMatrixToRows(A,P,j,S,w,k,(t,n,r,i)=>e.isCellEditable({readOnly:p,canEditCell:m},t,n,r,i)),z=n.clamp(O,0,Math.max(Math.max(l.getRowCount()-1,0),O)),B=n.clamp(f.activeCell.col+Math.max((S[0]?.length??1)-1,0),0,Math.max(Math.max(j.length-1,0),k+C-1));_(R),b(t.gridActions.startSelection(f.activeCell)),b(t.gridActions.updateSelection({row:z,col:B})),b(t.gridActions.endSelection()),b(t.gridActions.activateCell(f.activeCell))}}};exports.computeIsWholeGridSelected=o,exports.createClipboardController=s;
|
|
2
|
+
`)};return{update:c,handleCopy:async()=>{if(s===null)return;let e=s,{rowModel:t,visibleColumns:n,uiState:r}=e,a=o(r.selection,t.getRowCount(),n.length)?u(e):i.serializeSelectionToTsv(t.getRow,t.getRowCount(),n,r.selection,l(e));a&&await i.writeTextToClipboard(a)&&r.selection&&e.onCopied?.(r.selection)},handlePaste:o=>{if(s===null)return;let{rows:c,rowModel:l,columns:u,visibleColumns:d,uiState:f,readOnly:p,canEditCell:m,createRow:h,createOverflowColumn:g,onRowsChange:_,onColumnsChange:v,applyServerSideCellEdits:y,dispatch:b}=s;if(f.editingCell||r.shouldIgnoreGridKeydown(o.target??null)||p||!_&&!y||!f.activeCell)return;let x=o.clipboardData?.getData(`text/plain`)??``;if(!x)return;o.preventDefault();let S=i.parseClipboardText(x);if(S.length===0)return;let C=S.reduce((e,t)=>Math.max(e,t.length),0);if(C===0)return;let w=f.activeCell.row,T=f.activeCell.col,E=l.getLabelRow===void 0?null:a.resolvePasteTargetViewIndexes(l,w,S.length),D=e=>E?E[e-w]:e,O=E?E[E.length-1]:f.activeCell.row+Math.max(S.length-1,0);if(y){let r=i.buildClipboardCellEdits(e=>l.getRow(D(e)),d,S,w,T,(t,n,r,i)=>e.isCellEditable({readOnly:p,canEditCell:m},D(t),n,r,i)).map(e=>({...e,viewIndex:D(e.viewIndex)}));r.length>0&&y(r);let a=n.clamp(O,0,Math.max(l.getRowCount()-1,0)),o=n.clamp(f.activeCell.col+Math.max(C-1,0),0,Math.max(d.length-1,0));b(t.gridActions.startSelection(f.activeCell)),b(t.gridActions.updateSelection({row:a,col:o})),b(t.gridActions.endSelection()),b(t.gridActions.activateCell(f.activeCell));return}if(!_||l.getSourceIndex(w)===void 0)return;let k=f.activeCell.col,A=[...c],j=[...d],M=l.getRowCount(),N=A.length,P=e=>{let t=D(e);return t<M?l.getSourceIndex(t):N+(t-M)},F=Math.max(O+1-M,0),I=A.length+F;if(I>A.length&&h)for(;A.length<I;)A.push(h());let L=k+C;if(L>j.length&&v&&g){let e=[];for(;j.length<L;){let t=g(j.length);j.push(t),e.push(t)}v(u?[...u,...e]:j)}let R=i.applyClipboardMatrixToRows(A,P,j,S,w,k,(t,n,r,i)=>e.isCellEditable({readOnly:p,canEditCell:m},t,n,r,i)),z=n.clamp(O,0,Math.max(Math.max(l.getRowCount()-1,0),O)),B=n.clamp(f.activeCell.col+Math.max((S[0]?.length??1)-1,0),0,Math.max(Math.max(j.length-1,0),k+C-1));_(R),b(t.gridActions.startSelection(f.activeCell)),b(t.gridActions.updateSelection({row:z,col:B})),b(t.gridActions.endSelection()),b(t.gridActions.activateCell(f.activeCell))}}};exports.computeIsWholeGridSelected=o,exports.createClipboardController=s;
|
|
@@ -23,6 +23,7 @@ export type ClipboardControllerArgs<T extends object> = {
|
|
|
23
23
|
applyServerSideCellEdits?: (edits: ServerSideCellEditInput<T>[]) => number;
|
|
24
24
|
isRowExportable?: SpreadsheetGridProps<T>['isRowExportable'];
|
|
25
25
|
dispatch: (action: GridUiAction) => void;
|
|
26
|
+
onCopied?: (selection: NonNullable<GridSelection>) => void;
|
|
26
27
|
};
|
|
27
28
|
export type ClipboardController<T extends object> = {
|
|
28
29
|
update: (args: ClipboardControllerArgs<T>) => void;
|
|
@@ -38,7 +38,7 @@ var f = (e, t, n) => {
|
|
|
38
38
|
handleCopy: async () => {
|
|
39
39
|
if (p === null) return;
|
|
40
40
|
let e = p, { rowModel: t, visibleColumns: n, uiState: r } = e, i = f(r.selection, t.getRowCount(), n.length) ? g(e) : l(t.getRow, t.getRowCount(), n, r.selection, h(e));
|
|
41
|
-
i && await u(i);
|
|
41
|
+
i && await u(i) && r.selection && e.onCopied?.(r.selection);
|
|
42
42
|
},
|
|
43
43
|
handlePaste: (e) => {
|
|
44
44
|
if (p === null) return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../logic/detailRow.cjs"),t=require("../logic/geometry.cjs"),n=require("../logic/autoScrollGeometry.cjs"),r=require("../logic/slotDom.cjs");function i(e,n,r,i){let a=e.find(e=>e.key===n);if(!a)return null;let o=t.getColumnPane(a),s={left:[],center:[],right:[]},c=new Map;for(let n of e)s[t.getColumnPane(n)].push(n.key),c.set(n.key,n.visible!==!1);let l=s[r].filter(e=>c.get(e)).indexOf(n),u=s[o].indexOf(n);if(u<0)return null;s[o].splice(u,1);let d=i;o===r&&l>=0&&d>l&&--d;let f=s[r].filter(e=>c.get(e));if(d=Math.max(0,Math.min(d,f.length)),o===r&&l>=0&&d===l)return null;let p;return p=d>=f.length?s[r].length:s[r].indexOf(f[d]),s[r].splice(p,0,n),[...s.left,...s.center,...s.right]}var a=32,o=2,s=14,c=12,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="5 9 2 12 5 15"/><polyline points="9 5 12 2 15 5"/><polyline points="15 19 12 22 9 19"/><polyline points="19 9 22 12 19 15"/><line x1="2" y1="12" x2="22" y2="12"/><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"><line x1="12" y1="17" x2="12" y2="22"/><path d="M5 17h14v-1.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V6h1a2 2 0 0 0 0-4H8a2 2 0 0 0 0 4h1v4.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24Z"/></svg>`,d=`<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>`,f=`0.5`,p=200,m=`cubic-bezier(0.2, 0.7, 0.3, 1)`,h=
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../logic/detailRow.cjs"),t=require("../logic/geometry.cjs"),n=require("../logic/autoScrollGeometry.cjs"),r=require("../logic/slotDom.cjs");function i(e,n,r,i){let a=e.find(e=>e.key===n);if(!a)return null;let o=t.getColumnPane(a),s={left:[],center:[],right:[]},c=new Map;for(let n of e)s[t.getColumnPane(n)].push(n.key),c.set(n.key,n.visible!==!1);let l=s[r].filter(e=>c.get(e)).indexOf(n),u=s[o].indexOf(n);if(u<0)return null;s[o].splice(u,1);let d=i;o===r&&l>=0&&d>l&&--d;let f=s[r].filter(e=>c.get(e));if(d=Math.max(0,Math.min(d,f.length)),o===r&&l>=0&&d===l)return null;let p;return p=d>=f.length?s[r].length:s[r].indexOf(f[d]),s[r].splice(p,0,n),[...s.left,...s.center,...s.right]}var a=32,o=2,s=14,c=12,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="5 9 2 12 5 15"/><polyline points="9 5 12 2 15 5"/><polyline points="15 19 12 22 9 19"/><polyline points="19 9 22 12 19 15"/><line x1="2" y1="12" x2="22" y2="12"/><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"><line x1="12" y1="17" x2="12" y2="22"/><path d="M5 17h14v-1.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V6h1a2 2 0 0 0 0-4H8a2 2 0 0 0 0 4h1v4.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24Z"/></svg>`,d=`<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>`,f=`0.5`,p=200,m=`cubic-bezier(0.2, 0.7, 0.3, 1)`,h=e=>e?.closest(`.ssg-motion-off`)!=null,g=t=>{if(!t)return null;let n=new Map;return t.querySelectorAll(`[data-ssg-col-key]`).forEach(r=>{if(e.isInsideDetailCardOf(t,r))return;let i=r.dataset.ssgColKey;i&&!n.has(i)&&n.set(i,r.getBoundingClientRect().left)}),n},_=()=>{let _=null,v=null,y=null,b=null,x={x:0,y:0},S=null,C=!1,w=null,T=null,E=null,D=null,O=null,k=()=>({left:_?.leftIndicatorRef.current??null,center:_?.centerIndicatorRef.current??null,right:_?.rightIndicatorRef.current??null}),A=()=>{for(let e of Object.values(k()))e&&(e.style.display=`none`)},j=e=>{if(E)return;let t=document.createElement(`div`);t.setAttribute(`data-grid-drag-ghost`,``),_?.scrollContainerRef.current?.closest(`.ssg-theme-dark`)!=null&&t.classList.add(`ssg-theme-dark`),_?.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`,`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,_?.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.textContent=e,t.appendChild(n),t.appendChild(i),document.body.appendChild(t),E=t,D=n,O=null},M=e=>{let t=E;if(!t)return;t.style.transform=`translate(`+(x.x+s)+`px,`+(x.y+c)+`px)`;let n=e??`out`;if(O===n)return;O=n;let r=D;n===`out`?(t.style.opacity=f,r&&(r.innerHTML=d)):(t.style.opacity=`1`,r&&(r.innerHTML=n===`center`?l:u))},N=()=>{E&&E.parentNode&&E.parentNode.removeChild(E),E=null,D=null,O=null},P=(e,n)=>{if(_===null)return null;let{paneLayout:r,leftPaneScrollRef:i,rightPaneScrollRef:s,bodyScrollRef:c,scrollContainerRef:l,leftLeadingWidth:u,centerLeadingWidth:d,rightLeadingWidth:f}=_,p=l.current;if(p){let t=p.getBoundingClientRect();if(e<t.left||e>t.right||n<t.top||n>t.bottom)return null}let m=i.current,h=s.current;if(m&&r.left.entries.length===0&&e<=m.getBoundingClientRect().left+a)return{pane:`left`,slot:0,leftPx:o};if(m&&r.left.entries.length>0){let n=m.getBoundingClientRect();if(e<n.right){let i=e-n.left-u,a=t.findPaneDropSlot(r.left,i);return{pane:`left`,slot:a,leftPx:u+t.paneDropSlotBoundaryX(r.left,a)}}}if(h&&r.right.entries.length===0&&e>=h.getBoundingClientRect().left-a)return{pane:`right`,slot:0,leftPx:-2};if(h&&r.right.entries.length>0){let n=h.getBoundingClientRect();if(e>=n.left){let i=e-n.left-f,a=t.findPaneDropSlot(r.right,i);return{pane:`right`,slot:a,leftPx:f+t.paneDropSlotBoundaryX(r.right,a)}}}let g=c.current;if(g&&r.center.entries.length>0){let n=g.getBoundingClientRect(),i=g.scrollLeft+e-n.left-d,a=t.findPaneDropSlot(r.center,Math.max(i,0));return{pane:`center`,slot:a,leftPx:d+t.paneDropSlotBoundaryX(r.center,a)}}return null},F=()=>{let e=P(x.x,x.y);if(M(e?e.pane:null),!e){y=null,A();return}y={pane:e.pane,slot:e.slot};let t=k();for(let n of[`left`,`center`,`right`]){let r=t[n];r&&(n===e.pane?(r.style.left=`${e.leftPx}px`,r.style.display=`block`):r.style.display=`none`)}},I=()=>{if(v===null){T=null;return}let e=_?.scrollContainerRef.current??null;if(e&&(C||(!S||n.hasPointerLeftActivationRadius(S,x,6))&&(C=!0),C)){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(x.x,r.left,r.right,24),a=n.computeNextScrollPosition(e.scrollLeft,i,18,e.scrollWidth-e.clientWidth);a!==e.scrollLeft&&e.scrollTo({left:a,behavior:`auto`})}F(),T=requestAnimationFrame(I)},L=e=>{T!==null&&(cancelAnimationFrame(T),T=null),document.body.style.cursor=``,A(),N();let n=v,r=y;if(v=null,y=null,!e||!n||!r||_===null)return;let{columns:a,applyColumnOrderAndPin:o,scrollContainerRef:s}=_,c=i(a,n,r.pane,r.slot);if(!c)return;let l=a.find(e=>e.key===n),u=l?t.getColumnPane(l):null;b=u!==null&&u===r.pane&&!h(s.current)?g(s.current):null,o(c,new Map([[n,r.pane===`center`?void 0:r.pane]]))};return{update:e=>{_=e},onColumnDragHandlePointerDown:(e,t)=>{if(_===null||!_.enabled||t.button!==0)return;t.stopPropagation(),t.preventDefault(),v=e.key,x={x:t.clientX,y:t.clientY},S={x:t.clientX,y:t.clientY},C=!1,document.body.style.cursor=`grabbing`,j(e.title||e.key);let n=t.currentTarget,r=t.pointerId;try{n.setPointerCapture(r)}catch{}let i=e=>{e.pointerId===r&&(x={x:e.clientX,y:e.clientY},F())},a=()=>{window.removeEventListener(`pointermove`,i),window.removeEventListener(`pointerup`,o),window.removeEventListener(`pointercancel`,s),w=null;try{n.releasePointerCapture(r)}catch{}};function o(e){e.pointerId===r&&(a(),L(!0))}function s(e){e.pointerId===r&&(a(),L(!1))}window.addEventListener(`pointermove`,i),window.addEventListener(`pointerup`,o),window.addEventListener(`pointercancel`,s),w=a,F(),T=requestAnimationFrame(I)},applyReorderSettle:()=>{let t=b;if(b=null,!t)return;let n=_?.scrollContainerRef.current??null;if(!n)return;let r=new Map,i=new Map;n.querySelectorAll(`[data-ssg-col-key]`).forEach(a=>{if(e.isInsideDetailCardOf(n,a))return;let o=a.dataset.ssgColKey;if(!o||!t.has(o))return;let s=r.get(o);s?s.push(a):(r.set(o,[a]),i.set(o,a.getBoundingClientRect().left))});let a=[];if(r.forEach((e,n)=>{let r=t.get(n),o=i.get(n);if(r===void 0||o===void 0)return;let s=r-o;if(!(Math.abs(s)<.5))for(let t of e)t.style.transition=`none`,t.style.transform=`translateX(${s}px)`,t.style.willChange=`transform`,a.push(t)}),a.length!==0){n.getBoundingClientRect();for(let e of a)e.style.transition=`transform ${p}ms ${m}`,e.style.transform=`translateX(0)`;window.setTimeout(()=>{for(let e of a)e.style.transition=``,e.style.transform=``,e.style.willChange=``},280)}},dispose:()=>{w?.(),w=null,T!==null&&(cancelAnimationFrame(T),T=null),v=null,y=null,document.body.style.cursor=``,N()}}};exports.computeHeaderReorderedKeys=i,exports.createColumnHeaderDragController=_;
|
|
@@ -26,7 +26,7 @@ function l(e, t, r, i) {
|
|
|
26
26
|
...s.right
|
|
27
27
|
];
|
|
28
28
|
}
|
|
29
|
-
var u = 32, d = 2, f = 14, p = 12, m = "<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=\"5 9 2 12 5 15\"/><polyline points=\"9 5 12 2 15 5\"/><polyline points=\"15 19 12 22 9 19\"/><polyline points=\"19 9 22 12 19 15\"/><line x1=\"2\" y1=\"12\" x2=\"22\" y2=\"12\"/><line x1=\"12\" y1=\"2\" x2=\"12\" y2=\"22\"/></svg>", h = "<svg viewBox=\"0 0 24 24\" width=\"14\" height=\"14\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><line x1=\"12\" y1=\"17\" x2=\"12\" y2=\"22\"/><path d=\"M5 17h14v-1.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V6h1a2 2 0 0 0 0-4H8a2 2 0 0 0 0 4h1v4.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24Z\"/></svg>", g = "<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>", _ = "0.5", v = 200, y = "cubic-bezier(0.2, 0.7, 0.3, 1)", b = () =>
|
|
29
|
+
var u = 32, d = 2, f = 14, p = 12, m = "<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=\"5 9 2 12 5 15\"/><polyline points=\"9 5 12 2 15 5\"/><polyline points=\"15 19 12 22 9 19\"/><polyline points=\"19 9 22 12 19 15\"/><line x1=\"2\" y1=\"12\" x2=\"22\" y2=\"12\"/><line x1=\"12\" y1=\"2\" x2=\"12\" y2=\"22\"/></svg>", h = "<svg viewBox=\"0 0 24 24\" width=\"14\" height=\"14\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><line x1=\"12\" y1=\"17\" x2=\"12\" y2=\"22\"/><path d=\"M5 17h14v-1.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V6h1a2 2 0 0 0 0-4H8a2 2 0 0 0 0 4h1v4.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24Z\"/></svg>", g = "<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>", _ = "0.5", v = 200, y = "cubic-bezier(0.2, 0.7, 0.3, 1)", b = (e) => e?.closest(".ssg-motion-off") != null, x = (t) => {
|
|
30
30
|
if (!t) return null;
|
|
31
31
|
let n = /* @__PURE__ */ new Map();
|
|
32
32
|
return t.querySelectorAll("[data-ssg-col-key]").forEach((r) => {
|
|
@@ -47,7 +47,7 @@ var u = 32, d = 2, f = 14, p = 12, m = "<svg viewBox=\"0 0 24 24\" width=\"14\"
|
|
|
47
47
|
}, I = (e) => {
|
|
48
48
|
if (j) return;
|
|
49
49
|
let t = document.createElement("div");
|
|
50
|
-
t.setAttribute("data-grid-drag-ghost", ""), S?.scrollContainerRef.current?.closest(".ssg-theme-dark") != null && t.classList.add("ssg-theme-dark"), t.style.cssText = [
|
|
50
|
+
t.setAttribute("data-grid-drag-ghost", ""), S?.scrollContainerRef.current?.closest(".ssg-theme-dark") != null && t.classList.add("ssg-theme-dark"), S?.scrollContainerRef.current?.closest(".ssg-motion-off") != null && t.classList.add("ssg-motion-off"), t.style.cssText = [
|
|
51
51
|
"position:fixed",
|
|
52
52
|
"top:0",
|
|
53
53
|
"left:0",
|
|
@@ -182,7 +182,7 @@ var u = 32, d = 2, f = 14, p = 12, m = "<svg viewBox=\"0 0 24 24\" width=\"14\"
|
|
|
182
182
|
let { columns: i, applyColumnOrderAndPin: a, scrollContainerRef: o } = S, s = l(i, t, r.pane, r.slot);
|
|
183
183
|
if (!s) return;
|
|
184
184
|
let c = i.find((e) => e.key === t), u = c ? n(c) : null;
|
|
185
|
-
T = u !== null && u === r.pane && !b() ? x(o.current) : null, a(s, /* @__PURE__ */ new Map([[t, r.pane === "center" ? void 0 : r.pane]]));
|
|
185
|
+
T = u !== null && u === r.pane && !b(o.current) ? x(o.current) : null, a(s, /* @__PURE__ */ new Map([[t, r.pane === "center" ? void 0 : r.pane]]));
|
|
186
186
|
};
|
|
187
187
|
return {
|
|
188
188
|
update: (e) => {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../logic/valueStore.cjs"),t=require("../logic/chunkedLoop.cjs"),n=require("../logic/detailRow.cjs"),r=require("../logic/find.cjs");var i=1e4,a=new Map,o=()=>{let i=null,o=0,s=null,c=e.createValueStore({open:!1,query:``,matches:[],index:a,currentIndex:null,scanning:!1,truncated:!1}),l=e=>{c.setSnapshot({...c.getSnapshot(),...e})},u=()=>{let e=c.getSnapshot();i?.onChange?.({query:e.query,matchCount:e.matches.length,currentIndex:e.currentIndex,open:e.open})},d=()=>{let e=c.getSnapshot();if(e.currentIndex===null)return;let t=e.matches[e.currentIndex];t&&i?.onNavigate(t.rowIndex,t.colIndex)},f=()=>{o+=1,s=null,l({matches:[],index:a,currentIndex:null,scanning:!1,truncated:!1})},p=e=>{let a=i,p=c.getSnapshot();if(!a||!p.open||p.query.length===0){f(),u();return}o+=1;let m=o,{rowModel:h,columns:g,caseSensitive:_}=a,v=p.query;s={rowModel:h,columns:g,query:v,caseSensitive:_};let y=p.currentIndex===null?null:p.matches[p.currentIndex]??null,b=[],x=!1,S=h.getRowCount();l({scanning:!0}),t.runChunked(S,e=>{if(x)return;let t=h.getRow(e);t!==void 0&&g.forEach((i,a)=>{if(x||n.isSyntheticColumnKey(i.key))return;let o=r.resolveFindCellText(i,t);for(let t of r.findRangesInText(o,v,_)){if(b.length>=1e4){x=!0;return}b.push({rowIndex:e,colIndex:a,columnKey:String(i.key),start:t.start,length:t.length})}})},{isCancelled:()=>o!==m}).then(t=>{if(!t||o!==m)return;let n=r.resolveCurrentAfterRescan(b,y);l({matches:b,index:r.buildFindIndex(b),currentIndex:n,scanning:!1,truncated:x}),u(),e&&d()})},m=()=>{let e=c.getSnapshot();return!i||!e.open||e.query.length===0?!1:s===null||s.rowModel!==i.rowModel||s.columns!==i.columns||s.query!==e.query||s.caseSensitive!==i.caseSensitive};return{update:e=>{let t=i;if(i=e,!e.enabled){c.getSnapshot().open&&(l({open:!1,query:``}),f(),u());return}t!==e&&m()&&p(!1)},open:e=>{if(!i?.enabled)return;let t=c.getSnapshot(),n=e??t.query;l({open:!0,query:n}),n!==t.query||!t.open?p(!0):u()},close:()=>{c.getSnapshot().open&&(l({open:!1,query:``}),f(),u())},setQuery:e=>{let t=c.getSnapshot();!t.open||e===t.query||(l({query:e}),p(!0))},next:()=>{let e=c.getSnapshot(),t=r.stepFindIndex(e.currentIndex,e.matches.length,1);l({currentIndex:t}),u(),d()},prev:()=>{let e=c.getSnapshot(),t=r.stepFindIndex(e.currentIndex,e.matches.length,-1);l({currentIndex:t}),u(),d()},subscribe:c.subscribe,getSnapshot:c.getSnapshot,dispose:()=>{o+=1,i=null}}};exports.MAX_FIND_MATCHES=i,exports.createFindController=o;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { GridColumn, RowModel } from '../model/gridTypes.unbound.js';
|
|
2
|
+
import { type FindIndex, type FindMatch } from '../logic/find.js';
|
|
3
|
+
export type FindChangeParams = {
|
|
4
|
+
query: string;
|
|
5
|
+
matchCount: number;
|
|
6
|
+
currentIndex: number | null;
|
|
7
|
+
open: boolean;
|
|
8
|
+
};
|
|
9
|
+
export type FindArgs<T> = {
|
|
10
|
+
enabled: boolean;
|
|
11
|
+
rowModel: RowModel<T>;
|
|
12
|
+
columns: readonly GridColumn<T>[];
|
|
13
|
+
caseSensitive: boolean;
|
|
14
|
+
onNavigate: (rowIndex: number, colIndex: number) => void;
|
|
15
|
+
onChange?: (params: FindChangeParams) => void;
|
|
16
|
+
};
|
|
17
|
+
export type FindSnapshot = {
|
|
18
|
+
open: boolean;
|
|
19
|
+
query: string;
|
|
20
|
+
matches: readonly FindMatch[];
|
|
21
|
+
index: FindIndex;
|
|
22
|
+
currentIndex: number | null;
|
|
23
|
+
scanning: boolean;
|
|
24
|
+
truncated: boolean;
|
|
25
|
+
};
|
|
26
|
+
export type FindController<T> = {
|
|
27
|
+
update: (args: FindArgs<T>) => void;
|
|
28
|
+
open: (query?: string) => void;
|
|
29
|
+
close: () => void;
|
|
30
|
+
setQuery: (query: string) => void;
|
|
31
|
+
next: () => void;
|
|
32
|
+
prev: () => void;
|
|
33
|
+
subscribe: (listener: () => void) => () => void;
|
|
34
|
+
getSnapshot: () => FindSnapshot;
|
|
35
|
+
dispose: () => void;
|
|
36
|
+
};
|
|
37
|
+
export declare const MAX_FIND_MATCHES = 10000;
|
|
38
|
+
export declare const createFindController: <T>() => FindController<T>;
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { createValueStore as e } from "../logic/valueStore.js";
|
|
2
|
+
import { runChunked as t } from "../logic/chunkedLoop.js";
|
|
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";
|
|
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({
|
|
8
|
+
open: !1,
|
|
9
|
+
query: "",
|
|
10
|
+
matches: [],
|
|
11
|
+
index: l,
|
|
12
|
+
currentIndex: null,
|
|
13
|
+
scanning: !1,
|
|
14
|
+
truncated: !1
|
|
15
|
+
}), p = (e) => {
|
|
16
|
+
f.setSnapshot({
|
|
17
|
+
...f.getSnapshot(),
|
|
18
|
+
...e
|
|
19
|
+
});
|
|
20
|
+
}, m = () => {
|
|
21
|
+
let e = f.getSnapshot();
|
|
22
|
+
c?.onChange?.({
|
|
23
|
+
query: e.query,
|
|
24
|
+
matchCount: e.matches.length,
|
|
25
|
+
currentIndex: e.currentIndex,
|
|
26
|
+
open: e.open
|
|
27
|
+
});
|
|
28
|
+
}, h = () => {
|
|
29
|
+
let e = f.getSnapshot();
|
|
30
|
+
if (e.currentIndex === null) return;
|
|
31
|
+
let t = e.matches[e.currentIndex];
|
|
32
|
+
t && c?.onNavigate(t.rowIndex, t.colIndex);
|
|
33
|
+
}, g = () => {
|
|
34
|
+
u += 1, d = null, p({
|
|
35
|
+
matches: [],
|
|
36
|
+
index: l,
|
|
37
|
+
currentIndex: null,
|
|
38
|
+
scanning: !1,
|
|
39
|
+
truncated: !1
|
|
40
|
+
});
|
|
41
|
+
}, _ = (e) => {
|
|
42
|
+
let s = c, l = f.getSnapshot();
|
|
43
|
+
if (!s || !l.open || l.query.length === 0) {
|
|
44
|
+
g(), m();
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
u += 1;
|
|
48
|
+
let _ = 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
|
|
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;
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
C.push({
|
|
68
|
+
rowIndex: e,
|
|
69
|
+
colIndex: a,
|
|
70
|
+
columnKey: String(r.key),
|
|
71
|
+
start: t.start,
|
|
72
|
+
length: t.length
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
}, { isCancelled: () => u !== _ }).then((t) => {
|
|
77
|
+
if (!t || u !== _) return;
|
|
78
|
+
let n = a(C, S);
|
|
79
|
+
p({
|
|
80
|
+
matches: C,
|
|
81
|
+
index: r(C),
|
|
82
|
+
currentIndex: n,
|
|
83
|
+
scanning: !1,
|
|
84
|
+
truncated: w
|
|
85
|
+
}), m(), e && h();
|
|
86
|
+
});
|
|
87
|
+
}, v = () => {
|
|
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;
|
|
90
|
+
};
|
|
91
|
+
return {
|
|
92
|
+
update: (e) => {
|
|
93
|
+
let t = c;
|
|
94
|
+
if (c = e, !e.enabled) {
|
|
95
|
+
f.getSnapshot().open && (p({
|
|
96
|
+
open: !1,
|
|
97
|
+
query: ""
|
|
98
|
+
}), g(), m());
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
t !== e && v() && _(!1);
|
|
102
|
+
},
|
|
103
|
+
open: (e) => {
|
|
104
|
+
if (!c?.enabled) return;
|
|
105
|
+
let t = f.getSnapshot(), n = e ?? t.query;
|
|
106
|
+
p({
|
|
107
|
+
open: !0,
|
|
108
|
+
query: n
|
|
109
|
+
}), n !== t.query || !t.open ? _(!0) : m();
|
|
110
|
+
},
|
|
111
|
+
close: () => {
|
|
112
|
+
f.getSnapshot().open && (p({
|
|
113
|
+
open: !1,
|
|
114
|
+
query: ""
|
|
115
|
+
}), g(), m());
|
|
116
|
+
},
|
|
117
|
+
setQuery: (e) => {
|
|
118
|
+
let t = f.getSnapshot();
|
|
119
|
+
!t.open || e === t.query || (p({ query: e }), _(!0));
|
|
120
|
+
},
|
|
121
|
+
next: () => {
|
|
122
|
+
let e = f.getSnapshot(), t = s(e.currentIndex, e.matches.length, 1);
|
|
123
|
+
p({ currentIndex: t }), m(), h();
|
|
124
|
+
},
|
|
125
|
+
prev: () => {
|
|
126
|
+
let e = f.getSnapshot(), t = s(e.currentIndex, e.matches.length, -1);
|
|
127
|
+
p({ currentIndex: t }), m(), h();
|
|
128
|
+
},
|
|
129
|
+
subscribe: f.subscribe,
|
|
130
|
+
getSnapshot: f.getSnapshot,
|
|
131
|
+
dispose: () => {
|
|
132
|
+
u += 1, c = null;
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
};
|
|
136
|
+
//#endregion
|
|
137
|
+
export { c as MAX_FIND_MATCHES, u as createFindController };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../utils/permissions.cjs"),t=require("../model/gridActions.cjs"),n=require("../logic/geometry.cjs"),r=require("../logic/domGuards.cjs");var i=()=>{let i=null,a=e=>{i=e},o=(e,r,a)=>{if(i===null)return;let{uiState:o,rowModel:s,visibleColumns:c,dispatch:l}=i,u=s.getRowCount();if(u===0||c.length===0)return;let d=o.activeCell??{row:0,col:0},f=n.clamp(d.row+e,0,u-1);if(e!==0&&s.getLabelRow){let t=e>0?1:-1,n=f;for(;n>=0&&n<u&&s.getLabelRow(n);)n+=t;f=n>=0&&n<u?n:d.row}let p={row:f,col:n.clamp(d.col+r,0,c.length-1)};if(a){let e=o.selection?.type===`cell`?o.selection.range.start:d;l(t.gridActions.startSelection(e)),l(t.gridActions.updateSelection(p)),l(t.gridActions.endSelection()),l(t.gridActions.activateCell(p));return}l(t.gridActions.startSelection(p)),l(t.gridActions.endSelection()),l(t.gridActions.activateCell(p))};return{update:a,handleKeyDown:async n=>{if(i===null)return;let{uiState:a,rowModel:s,visibleColumns:c,readOnly:l,canEditCell:u,setEditorInitialValue:d,dispatch:f,handleCopy:p,
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../utils/permissions.cjs"),t=require("../model/gridActions.cjs"),n=require("../logic/geometry.cjs"),r=require("../logic/domGuards.cjs");var i=()=>{let i=null,a=e=>{i=e},o=(e,r,a)=>{if(i===null)return;let{uiState:o,rowModel:s,visibleColumns:c,dispatch:l}=i,u=s.getRowCount();if(u===0||c.length===0)return;let d=o.activeCell??{row:0,col:0},f=n.clamp(d.row+e,0,u-1);if(e!==0&&s.getLabelRow){let t=e>0?1:-1,n=f;for(;n>=0&&n<u&&s.getLabelRow(n);)n+=t;f=n>=0&&n<u?n:d.row}let p={row:f,col:n.clamp(d.col+r,0,c.length-1)};if(a){let e=o.selection?.type===`cell`?o.selection.range.start:d;l(t.gridActions.startSelection(e)),l(t.gridActions.updateSelection(p)),l(t.gridActions.endSelection()),l(t.gridActions.activateCell(p));return}l(t.gridActions.startSelection(p)),l(t.gridActions.endSelection()),l(t.gridActions.activateCell(p))};return{update:a,handleKeyDown:async n=>{if(i===null)return;let{uiState:a,rowModel:s,visibleColumns:c,readOnly:l,canEditCell:u,setEditorInitialValue:d,dispatch:f,handleCopy:p,openFind:m,handleCellDoubleClick:h,isWholeGridSelected:g,selectEntireGrid:_,onUndo:v,onRedo:y,onClearSelection:b,enableClearOnDelete:x,onToggleCheckboxCell:S,onToggleGroup:C}=i;if(!r.shouldIgnoreGridKeydown(n.target)&&!a.editingCell&&!(n.isComposing&&r.isImeInputTarget(n.target))){if((n.ctrlKey||n.metaKey)&&n.key.toLowerCase()===`c`){n.preventDefault(),await p();return}if((n.ctrlKey||n.metaKey)&&n.key.toLowerCase()===`f`&&m){n.preventDefault(),m();return}if((n.ctrlKey||n.metaKey)&&n.key.toLowerCase()===`a`){if(n.preventDefault(),g){f(t.gridActions.clearSelection()),f(t.gridActions.activateCell(null));return}_();return}if((n.ctrlKey||n.metaKey)&&!n.isComposing){if(n.key.toLowerCase()===`z`){n.preventDefault(),n.shiftKey?y():v();return}if(n.key.toLowerCase()===`y`&&!n.shiftKey){n.preventDefault(),y();return}}if(n.key===`ArrowUp`){n.preventDefault(),o(-1,0,n.shiftKey);return}if(n.key===`ArrowDown`){n.preventDefault(),o(1,0,n.shiftKey);return}if(n.key===`ArrowLeft`){n.preventDefault(),o(0,-1,n.shiftKey);return}if(n.key===`ArrowRight`){n.preventDefault(),o(0,1,n.shiftKey);return}if(n.key===`Tab`){let e=a.activeCell?.col??0;if(n.shiftKey?e<=0:e>=i.visibleColumns.length-1)return;n.preventDefault(),o(0,n.shiftKey?-1:1,!1);return}if(n.key===`Escape`){n.preventDefault(),f(t.gridActions.clearSelection());return}if((n.key===`Delete`||n.key===`Backspace`)&&x){n.preventDefault(),b();return}if((n.key===`Enter`||n.key===` `)&&a.activeCell){let e=s.getGroupRow?.(a.activeCell.row);if(e){n.preventDefault(),C(e.groupKey);return}}if(n.key===`Enter`||n.key===`F2`){n.preventDefault(),a.activeCell&&h(a.activeCell);return}if(r.isPrintableKey(n)&&a.activeCell){let r=s.getRow(a.activeCell.row),i=c[a.activeCell.col];if(!r||!i||!e.isCellEditable({readOnly:l,canEditCell:u},a.activeCell.row,a.activeCell.col,r,i))return;if(i.editor?.type===`checkbox`){n.preventDefault(),n.key===` `&&S(a.activeCell);return}n.preventDefault(),d(n.key),f(t.gridActions.startEdit(a.activeCell))}}}}};exports.createKeyboardController=i;
|
|
@@ -19,6 +19,7 @@ export type KeyboardControllerArgs<T> = {
|
|
|
19
19
|
setEditorInitialValue: (value: string) => void;
|
|
20
20
|
dispatch: (action: GridUiAction) => void;
|
|
21
21
|
handleCopy: () => Promise<void>;
|
|
22
|
+
openFind?: () => void;
|
|
22
23
|
handleCellDoubleClick: (cell: CellCoord) => void;
|
|
23
24
|
isWholeGridSelected: boolean;
|
|
24
25
|
selectEntireGrid: () => void;
|
|
@@ -34,27 +34,31 @@ var o = () => {
|
|
|
34
34
|
update: s,
|
|
35
35
|
handleKeyDown: async (n) => {
|
|
36
36
|
if (o === null) return;
|
|
37
|
-
let { uiState: s, rowModel: l, visibleColumns: u, readOnly: d, canEditCell: f, setEditorInitialValue: p, dispatch: m, handleCopy: h,
|
|
37
|
+
let { uiState: s, rowModel: l, visibleColumns: u, readOnly: d, canEditCell: f, setEditorInitialValue: p, dispatch: m, handleCopy: h, openFind: g, handleCellDoubleClick: _, isWholeGridSelected: v, selectEntireGrid: y, onUndo: b, onRedo: x, onClearSelection: S, enableClearOnDelete: C, onToggleCheckboxCell: w, onToggleGroup: T } = o;
|
|
38
38
|
if (!a(n.target) && !s.editingCell && !(n.isComposing && r(n.target))) {
|
|
39
39
|
if ((n.ctrlKey || n.metaKey) && n.key.toLowerCase() === "c") {
|
|
40
40
|
n.preventDefault(), await h();
|
|
41
41
|
return;
|
|
42
42
|
}
|
|
43
|
+
if ((n.ctrlKey || n.metaKey) && n.key.toLowerCase() === "f" && g) {
|
|
44
|
+
n.preventDefault(), g();
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
43
47
|
if ((n.ctrlKey || n.metaKey) && n.key.toLowerCase() === "a") {
|
|
44
|
-
if (n.preventDefault(),
|
|
48
|
+
if (n.preventDefault(), v) {
|
|
45
49
|
m(t.clearSelection()), m(t.activateCell(null));
|
|
46
50
|
return;
|
|
47
51
|
}
|
|
48
|
-
|
|
52
|
+
y();
|
|
49
53
|
return;
|
|
50
54
|
}
|
|
51
55
|
if ((n.ctrlKey || n.metaKey) && !n.isComposing) {
|
|
52
56
|
if (n.key.toLowerCase() === "z") {
|
|
53
|
-
n.preventDefault(), n.shiftKey ?
|
|
57
|
+
n.preventDefault(), n.shiftKey ? x() : b();
|
|
54
58
|
return;
|
|
55
59
|
}
|
|
56
60
|
if (n.key.toLowerCase() === "y" && !n.shiftKey) {
|
|
57
|
-
n.preventDefault(),
|
|
61
|
+
n.preventDefault(), x();
|
|
58
62
|
return;
|
|
59
63
|
}
|
|
60
64
|
}
|
|
@@ -84,19 +88,19 @@ var o = () => {
|
|
|
84
88
|
n.preventDefault(), m(t.clearSelection());
|
|
85
89
|
return;
|
|
86
90
|
}
|
|
87
|
-
if ((n.key === "Delete" || n.key === "Backspace") &&
|
|
88
|
-
n.preventDefault(),
|
|
91
|
+
if ((n.key === "Delete" || n.key === "Backspace") && C) {
|
|
92
|
+
n.preventDefault(), S();
|
|
89
93
|
return;
|
|
90
94
|
}
|
|
91
95
|
if ((n.key === "Enter" || n.key === " ") && s.activeCell) {
|
|
92
96
|
let e = l.getGroupRow?.(s.activeCell.row);
|
|
93
97
|
if (e) {
|
|
94
|
-
n.preventDefault(),
|
|
98
|
+
n.preventDefault(), T(e.groupKey);
|
|
95
99
|
return;
|
|
96
100
|
}
|
|
97
101
|
}
|
|
98
102
|
if (n.key === "Enter" || n.key === "F2") {
|
|
99
|
-
n.preventDefault(), s.activeCell &&
|
|
103
|
+
n.preventDefault(), s.activeCell && _(s.activeCell);
|
|
100
104
|
return;
|
|
101
105
|
}
|
|
102
106
|
if (i(n) && s.activeCell) {
|
|
@@ -106,7 +110,7 @@ var o = () => {
|
|
|
106
110
|
canEditCell: f
|
|
107
111
|
}, s.activeCell.row, s.activeCell.col, r, i)) return;
|
|
108
112
|
if (i.editor?.type === "checkbox") {
|
|
109
|
-
n.preventDefault(), n.key === " " &&
|
|
113
|
+
n.preventDefault(), n.key === " " && w(s.activeCell);
|
|
110
114
|
return;
|
|
111
115
|
}
|
|
112
116
|
n.preventDefault(), p(n.key), m(t.startEdit(s.activeCell));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../logic/sorting.cjs"),t=require("../logic/detailRow.cjs"),n=require("../model/gridActions.cjs"),r=require("../logic/geometry.cjs"),i=require("../logic/autoScrollGeometry.cjs"),a=require("../logic/verticalGeometry.cjs");var o=10,s=300,c=()=>{let o=null,s=!1,c=!1,l=null,u=null,d=`mouse`,f=null,p=null,m=!1,h=!1,g=()=>o?.uiState.dragState??null,_=(e,t)=>{if(o===null)return null;let{bodyScrollRef:n,scrollContainerRef:i,leftPaneScrollRef:s,rightPaneScrollRef:c,filteredRowsLength:l,visibleColumnsLength:u,paneLayout:d,leftLeadingWidth:f,centerLeadingWidth:p,rightLeadingWidth:m,headerHeight:h,rowMetrics:g,verticalScaleFactor:_}=o,v=n.current;if(!v||l===0||u===0)return null;let y=v.getBoundingClientRect(),b=a.clientYToRowIndex(v.scrollTop+t-y.top-h,i.current?.scrollTop??0,_,g),x=null,S=s.current;if(x===null&&S&&d.left.entries.length>0){let t=S.getBoundingClientRect();if(e<t.right){let n=e-t.left-f;x=r.findLogicalIndexFromPaneOffset(d.left,n)}}let C=c.current;if(x===null&&C&&d.right.entries.length>0){let t=C.getBoundingClientRect();if(e>=t.left){let n=e-t.left-m;x=r.findLogicalIndexFromPaneOffset(d.right,n)}}if(x===null&&d.center.entries.length>0){let t=v.scrollLeft+e-y.left-p;x=r.findLogicalIndexFromPaneOffset(d.center,Math.max(t,0))}return x===null?null:{row:b,col:r.clamp(x,0,u-1)}},v=(e,t)=>{let r=g();if(o===null||!r||r.type!==`selection`)return;let i=_(e,t);if(i){if(r.selectionKind===`cell`){o.dispatch(n.gridActions.updateSelection(i));return}if(r.selectionKind===`row`){o.dispatch(n.gridActions.updateRowSelection(i.row));return}r.selectionKind===`col`&&o.dispatch(n.gridActions.updateColumnSelection(i.col))}},y=(e,t)=>{let r=t.timeStamp;if(o===null)return;let{gridRootRef:i,dispatch:a,enableRangeSelection:s,enableRowSelection:c,onGutterRowSelect:l,onCellDoubleClickRef:d}=o;i.current?.focus({preventScroll:!0});let{target:f}=e;if(f.kind===`cell`){let e=u;if(e&&e.cell.row===f.cell.row&&e.cell.col===f.cell.col&&r-e.time<300){u=null,d.current(f.cell,t);return}u={cell:f.cell,time:r},a(n.gridActions.activateCell(f.cell)),s&&(a(n.gridActions.startSelection(f.cell)),a(n.gridActions.endSelection()));return}if(u=null,f.kind===`row`){if(c){l(f.rowIndex,{shiftKey:!1});return}a(n.gridActions.startRowSelection(f.rowIndex)),a(n.gridActions.endSelection());return}a(n.gridActions.startColumnSelection(f.colIndex)),a(n.gridActions.endSelection())},b=()=>{o!==null&&(c=!1,o.dispatch(n.gridActions.endSelection()),o.dispatch(n.gridActions.endColumnResize()))},x=e=>{o!==null&&(o.pointerClientRef.current={x:e.clientX,y:e.clientY},g()?.type===`columnResize`&&o.dispatch(n.gridActions.updateColumnResize(e.clientX)))},S=e=>{let t=l;t&&(l=null,e.pointerId===t.pointerId&&Math.abs(e.clientX-t.x)<10&&Math.abs(e.clientY-t.y)<10&&y(t,e)),b()},C=()=>{l=null,b()},w=()=>{s||(s=!0,window.addEventListener(`pointermove`,x),window.addEventListener(`pointerup`,S),window.addEventListener(`pointercancel`,C))},T=()=>{s&&(s=!1,window.removeEventListener(`pointermove`,x),window.removeEventListener(`pointerup`,S),window.removeEventListener(`pointercancel`,C))},E=()=>{h=!1,o!==null&&o.autoScrollFrameRef.current!==null&&(cancelAnimationFrame(o.autoScrollFrameRef.current),o.autoScrollFrameRef.current=null)},D=()=>{if(o===null||!h)return;let{scrollContainerRef:e,pointerClientRef:t,autoScrollFrameRef:n}=o,r=e.current,a=t.current;if(!r||!a){n.current=requestAnimationFrame(D);return}if(!m){let e=p;if(e&&!i.hasPointerLeftActivationRadius(e,a,6)){n.current=requestAnimationFrame(D);return}m=!0}let s=r.getBoundingClientRect(),c=i.resolveScrollContentBox({rectLeft:s.left,rectTop:s.top,clientLeft:r.clientLeft,clientTop:r.clientTop,clientWidth:r.clientWidth,clientHeight:r.clientHeight}),l=g(),u=l?.type===`selection`&&l.selectionKind===`col`,d=l?.type===`selection`&&l.selectionKind===`row`,f=u?0:i.resolveAutoScrollAxisDirection(a.y,c.top,c.bottom,24),_=d?0:i.resolveAutoScrollAxisDirection(a.x,c.left,c.right,24),y=i.computeNextScrollPosition(r.scrollTop,f,18,r.scrollHeight-r.clientHeight),b=i.computeNextScrollPosition(r.scrollLeft,_,18,r.scrollWidth-r.clientWidth);(y!==r.scrollTop||b!==r.scrollLeft)&&(r.scrollTo({top:y,left:b,behavior:`auto`}),v(a.x,a.y)),n.current=requestAnimationFrame(D)},O=()=>{let e=g()?.type===`selection`;e&&!h?(h=!0,o!==null&&(o.autoScrollFrameRef.current=requestAnimationFrame(D))):!e&&h&&E()},k=()=>{if(f!==null)return;let e=()=>{if(!c||o===null){f=null;return}let{scrollContainerRef:t,pointerClientRef:n,onGutterRowSelectDrag:r}=o,a=t.current,s=n.current;if(!a||!s){f=requestAnimationFrame(e);return}if(!m){let t=p;if(t&&!i.hasPointerLeftActivationRadius(t,s,6)){f=requestAnimationFrame(e);return}m=!0}let l=a.getBoundingClientRect(),u=i.resolveScrollContentBox({rectLeft:l.left,rectTop:l.top,clientLeft:a.clientLeft,clientTop:a.clientTop,clientWidth:a.clientWidth,clientHeight:a.clientHeight}),d=i.resolveAutoScrollAxisDirection(s.y,u.top,u.bottom,24),h=i.computeNextScrollPosition(a.scrollTop,d,18,a.scrollHeight-a.clientHeight);if(h!==a.scrollTop){a.scrollTo({top:h,left:a.scrollLeft,behavior:`auto`});let e=_(s.x,s.y);e&&r(e.row)}f=requestAnimationFrame(e)};f=requestAnimationFrame(e)},A=(e,t)=>(e.preventDefault(),o===null||e.button!==0?!1:(d=e.pointerType,e.pointerType===`touch`?(l={pointerId:e.pointerId,x:e.clientX,y:e.clientY,target:t},!1):(o.gridRootRef.current?.focus({preventScroll:!0}),o.pointerClientRef.current={x:e.clientX,y:e.clientY},p={x:e.clientX,y:e.clientY},m=!1,!0)));return{update:e=>{o=e,w(),O()},updateSelectionFromPointer:v,handleCellPointerDown:(e,t)=>{!A(t,{kind:`cell`,cell:e})||o===null||(o.dispatch(n.gridActions.activateCell(e)),o.enableRangeSelection&&o.dispatch(n.gridActions.startSelection(e)))},handleCellDoubleClick:(e,t)=>{d===`touch`||o===null||o.onCellDoubleClickRef.current(e,t)},handleCellPointerEnter:(e,t)=>{if(o===null||(o.enableRowHover&&o.setHoveredRowIndex(e.row),!o.enableRangeSelection))return;let r=g();r?.type!==`selection`||r.selectionKind!==`cell`||(o.pointerClientRef.current={x:t.clientX,y:t.clientY},o.dispatch(n.gridActions.updateSelection(e)))},handleNativeDragStart:e=>{e.preventDefault()},handleRowHeaderPointerDown:(e,t)=>{if(!(!A(t,{kind:`row`,rowIndex:e})||o===null)){if(o.enableRowSelection){c=!0,o.onGutterRowSelect(e,{shiftKey:t.shiftKey}),k();return}o.dispatch(n.gridActions.startRowSelection(e))}},handleRowHeaderPointerEnter:(e,t)=>{if(o===null)return;if(o.enableRowHover&&o.setHoveredRowIndex(e),c){o.pointerClientRef.current={x:t.clientX,y:t.clientY},o.onGutterRowSelectDrag(e);return}let r=g();r?.type!==`selection`||r.selectionKind!==`row`||(o.pointerClientRef.current={x:t.clientX,y:t.clientY},o.dispatch(n.gridActions.updateRowSelection(e)))},handleColumnHeaderPointerDown:(r,i)=>{if(!(!A(i,{kind:`col`,colIndex:r})||o===null)){if(i.shiftKey&&o.enableSorting){let i=o.orderedColumns[r];if(i&&!t.isSyntheticColumnKey(i.key)){let t=o.uiState.sort,r=t.find(e=>e.columnKey===i.key)?.direction?`desc`:`asc`,a=e.nextSortEntries(t,i.key,r,!0);o.dispatch(a.length===0?n.gridActions.clearSort():n.gridActions.setSort(a))}return}o.dispatch(n.gridActions.startColumnSelection(r))}},handleColumnHeaderPointerEnter:(e,t)=>{if(o===null)return;o.setHoveredRowIndex(null),o.enableColumnHeaderHover&&o.setHoveredColumnIndex(e);let r=g();r?.type!==`selection`||r.selectionKind!==`col`||(o.pointerClientRef.current={x:t.clientX,y:t.clientY},o.dispatch(n.gridActions.updateColumnSelection(e)))},dispose:()=>{T(),E(),f!==null&&(cancelAnimationFrame(f),f=null)}}};exports.TOUCH_DOUBLE_TAP_MS=s,exports.TOUCH_TAP_SLOP_PX=o,exports.createPointerInteractionsController=c;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../logic/sorting.cjs"),t=require("../logic/detailRow.cjs"),n=require("../model/gridActions.cjs"),r=require("../logic/geometry.cjs"),i=require("../logic/autoScrollGeometry.cjs"),a=require("../logic/verticalGeometry.cjs");var o=10,s=300,c=()=>{let o=null,s=!1,c=!1,l=null,u=null,d=`mouse`,f=null,p=null,m=!1,h=!1,g=()=>o?.uiState.dragState??null,_=(e,t)=>{if(o===null)return null;let{bodyScrollRef:n,scrollContainerRef:i,leftPaneScrollRef:s,rightPaneScrollRef:c,filteredRowsLength:l,visibleColumnsLength:u,paneLayout:d,leftLeadingWidth:f,centerLeadingWidth:p,rightLeadingWidth:m,headerHeight:h,rowMetrics:g,verticalScaleFactor:_}=o,v=n.current;if(!v||l===0||u===0)return null;let y=v.getBoundingClientRect(),b=a.clientYToRowIndex(v.scrollTop+t-y.top-h,i.current?.scrollTop??0,_,g),x=null,S=s.current;if(x===null&&S&&d.left.entries.length>0){let t=S.getBoundingClientRect();if(e<t.right){let n=e-t.left-f;x=r.findLogicalIndexFromPaneOffset(d.left,n)}}let C=c.current;if(x===null&&C&&d.right.entries.length>0){let t=C.getBoundingClientRect();if(e>=t.left){let n=e-t.left-m;x=r.findLogicalIndexFromPaneOffset(d.right,n)}}if(x===null&&d.center.entries.length>0){let t=v.scrollLeft+e-y.left-p;x=r.findLogicalIndexFromPaneOffset(d.center,Math.max(t,0))}return x===null?null:{row:b,col:r.clamp(x,0,u-1)}},v=(e,t)=>{let r=g();if(o===null||!r||r.type!==`selection`)return;let i=_(e,t);if(i){if(r.selectionKind===`cell`){o.dispatch(n.gridActions.updateSelection(i));return}if(r.selectionKind===`row`){o.dispatch(n.gridActions.updateRowSelection(i.row));return}r.selectionKind===`col`&&o.dispatch(n.gridActions.updateColumnSelection(i.col))}},y=(e,t)=>{let r=t.timeStamp;if(o===null)return;let{gridRootRef:i,dispatch:a,enableRangeSelection:s,enableRowSelection:c,onGutterRowSelect:l,onCellDoubleClickRef:d}=o;i.current?.focus({preventScroll:!0});let{target:f}=e;if(f.kind===`cell`){let e=u;if(e&&e.cell.row===f.cell.row&&e.cell.col===f.cell.col&&r-e.time<300){u=null,d.current(f.cell,t);return}u={cell:f.cell,time:r},a(n.gridActions.activateCell(f.cell)),s&&(a(n.gridActions.startSelection(f.cell)),a(n.gridActions.endSelection()));return}if(u=null,f.kind===`row`){if(c){l(f.rowIndex,{shiftKey:!1});return}a(n.gridActions.startRowSelection(f.rowIndex)),a(n.gridActions.endSelection());return}a(n.gridActions.startColumnSelection(f.colIndex)),a(n.gridActions.endSelection())},b=()=>{o!==null&&(c=!1,o.dispatch(n.gridActions.endSelection()),o.dispatch(n.gridActions.endColumnResize()))},x=e=>{o!==null&&(o.pointerClientRef.current={x:e.clientX,y:e.clientY},g()?.type===`columnResize`&&o.dispatch(n.gridActions.updateColumnResize(e.clientX)))},S=e=>{let t=l;t&&(l=null,e.pointerId===t.pointerId&&Math.abs(e.clientX-t.x)<10&&Math.abs(e.clientY-t.y)<10&&y(t,e)),b()},C=()=>{l=null,b()},w=()=>{s||(s=!0,window.addEventListener(`pointermove`,x),window.addEventListener(`pointerup`,S),window.addEventListener(`pointercancel`,C))},T=()=>{s&&(s=!1,window.removeEventListener(`pointermove`,x),window.removeEventListener(`pointerup`,S),window.removeEventListener(`pointercancel`,C))},E=()=>{h=!1,o!==null&&o.autoScrollFrameRef.current!==null&&(cancelAnimationFrame(o.autoScrollFrameRef.current),o.autoScrollFrameRef.current=null)},D=()=>{if(o===null||!h)return;let{scrollContainerRef:e,pointerClientRef:t,autoScrollFrameRef:n}=o,r=e.current,a=t.current;if(!r||!a){n.current=requestAnimationFrame(D);return}if(!m){let e=p;if(e&&!i.hasPointerLeftActivationRadius(e,a,6)){n.current=requestAnimationFrame(D);return}m=!0}let s=r.getBoundingClientRect(),c=i.resolveScrollContentBox({rectLeft:s.left,rectTop:s.top,clientLeft:r.clientLeft,clientTop:r.clientTop,clientWidth:r.clientWidth,clientHeight:r.clientHeight}),l=g(),u=l?.type===`selection`&&l.selectionKind===`col`,d=l?.type===`selection`&&l.selectionKind===`row`,f=u?0:i.resolveAutoScrollAxisDirection(a.y,c.top,c.bottom,24),_=d?0:i.resolveAutoScrollAxisDirection(a.x,c.left,c.right,24),y=i.computeNextScrollPosition(r.scrollTop,f,18,r.scrollHeight-r.clientHeight),b=i.computeNextScrollPosition(r.scrollLeft,_,18,r.scrollWidth-r.clientWidth);(y!==r.scrollTop||b!==r.scrollLeft)&&(r.scrollTo({top:y,left:b,behavior:`auto`}),v(a.x,a.y)),n.current=requestAnimationFrame(D)},O=()=>{let e=g()?.type===`selection`;e&&!h?(h=!0,o!==null&&(o.autoScrollFrameRef.current=requestAnimationFrame(D))):!e&&h&&E()},k=()=>{if(f!==null)return;let e=()=>{if(!c||o===null){f=null;return}let{scrollContainerRef:t,pointerClientRef:n,onGutterRowSelectDrag:r}=o,a=t.current,s=n.current;if(!a||!s){f=requestAnimationFrame(e);return}if(!m){let t=p;if(t&&!i.hasPointerLeftActivationRadius(t,s,6)){f=requestAnimationFrame(e);return}m=!0}let l=a.getBoundingClientRect(),u=i.resolveScrollContentBox({rectLeft:l.left,rectTop:l.top,clientLeft:a.clientLeft,clientTop:a.clientTop,clientWidth:a.clientWidth,clientHeight:a.clientHeight}),d=i.resolveAutoScrollAxisDirection(s.y,u.top,u.bottom,24),h=i.computeNextScrollPosition(a.scrollTop,d,18,a.scrollHeight-a.clientHeight);if(h!==a.scrollTop){a.scrollTo({top:h,left:a.scrollLeft,behavior:`auto`});let e=_(s.x,s.y);e&&r(e.row)}f=requestAnimationFrame(e)};f=requestAnimationFrame(e)},A=(e,t)=>(e.preventDefault(),o===null||e.button!==0?!1:(d=e.pointerType,e.pointerType===`touch`?(l={pointerId:e.pointerId,x:e.clientX,y:e.clientY,target:t},!1):(o.gridRootRef.current?.focus({preventScroll:!0}),o.pointerClientRef.current={x:e.clientX,y:e.clientY},p={x:e.clientX,y:e.clientY},m=!1,!0)));return{update:e=>{o=e,w(),O()},updateSelectionFromPointer:v,handleCellPointerDown:(e,t)=>{!A(t,{kind:`cell`,cell:e})||o===null||(o.dispatch(n.gridActions.activateCell(e)),o.enableRangeSelection&&o.dispatch(n.gridActions.startSelection(e)))},handleCellDoubleClick:(e,t)=>{d===`touch`||o===null||o.onCellDoubleClickRef.current(e,t)},handleCellPointerEnter:(e,t)=>{if(o===null||(o.enableRowHover&&o.setHoveredRowIndex(e.row),o.enableColumnHover&&o.setHoveredColumnIndex(e.col),!o.enableRangeSelection))return;let r=g();r?.type!==`selection`||r.selectionKind!==`cell`||(o.pointerClientRef.current={x:t.clientX,y:t.clientY},o.dispatch(n.gridActions.updateSelection(e)))},handleNativeDragStart:e=>{e.preventDefault()},handleRowHeaderPointerDown:(e,t)=>{if(!(!A(t,{kind:`row`,rowIndex:e})||o===null)){if(o.enableRowSelection){c=!0,o.onGutterRowSelect(e,{shiftKey:t.shiftKey}),k();return}o.dispatch(n.gridActions.startRowSelection(e))}},handleRowHeaderPointerEnter:(e,t)=>{if(o===null)return;if(o.enableRowHover&&o.setHoveredRowIndex(e),c){o.pointerClientRef.current={x:t.clientX,y:t.clientY},o.onGutterRowSelectDrag(e);return}let r=g();r?.type!==`selection`||r.selectionKind!==`row`||(o.pointerClientRef.current={x:t.clientX,y:t.clientY},o.dispatch(n.gridActions.updateRowSelection(e)))},handleColumnHeaderPointerDown:(r,i)=>{if(!(!A(i,{kind:`col`,colIndex:r})||o===null)){if(i.shiftKey&&o.enableSorting){let i=o.orderedColumns[r];if(i&&!t.isSyntheticColumnKey(i.key)){let t=o.uiState.sort,r=t.find(e=>e.columnKey===i.key)?.direction?`desc`:`asc`,a=e.nextSortEntries(t,i.key,r,!0);o.dispatch(a.length===0?n.gridActions.clearSort():n.gridActions.setSort(a))}return}o.dispatch(n.gridActions.startColumnSelection(r))}},handleColumnHeaderPointerEnter:(e,t)=>{if(o===null)return;o.setHoveredRowIndex(null),o.enableColumnHeaderHover&&o.setHoveredColumnIndex(e);let r=g();r?.type!==`selection`||r.selectionKind!==`col`||(o.pointerClientRef.current={x:t.clientX,y:t.clientY},o.dispatch(n.gridActions.updateColumnSelection(e)))},dispose:()=>{T(),E(),f!==null&&(cancelAnimationFrame(f),f=null)}}};exports.TOUCH_DOUBLE_TAP_MS=s,exports.TOUCH_TAP_SLOP_PX=o,exports.createPointerInteractionsController=c;
|
|
@@ -48,6 +48,7 @@ export type PointerInteractionsArgs<T> = {
|
|
|
48
48
|
setHoveredColumnIndex: (value: number | null) => void;
|
|
49
49
|
enableRowHover: boolean;
|
|
50
50
|
enableColumnHeaderHover: boolean;
|
|
51
|
+
enableColumnHover?: boolean;
|
|
51
52
|
enableRowSelection: boolean;
|
|
52
53
|
onGutterRowSelect: (viewIndex: number, opts: {
|
|
53
54
|
shiftKey: boolean;
|
|
@@ -192,7 +192,7 @@ var u = 10, d = 300, f = () => {
|
|
|
192
192
|
h === "touch" || u === null || u.onCellDoubleClickRef.current(e, t);
|
|
193
193
|
},
|
|
194
194
|
handleCellPointerEnter: (e, t) => {
|
|
195
|
-
if (u === null || (u.enableRowHover && u.setHoveredRowIndex(e.row), !u.enableRangeSelection)) return;
|
|
195
|
+
if (u === null || (u.enableRowHover && u.setHoveredRowIndex(e.row), u.enableColumnHover && u.setHoveredColumnIndex(e.col), !u.enableRangeSelection)) return;
|
|
196
196
|
let r = b();
|
|
197
197
|
r?.type !== "selection" || r.selectionKind !== "cell" || (u.pointerClientRef.current = {
|
|
198
198
|
x: t.clientX,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=`(prefers-reduced-motion: reduce)`,t=()=>typeof window<`u`&&typeof window.matchMedia==`function`,n={subscribe(n){if(!t())return()=>{};let r=window.matchMedia(e);return r.addEventListener(`change`,n),()=>{r.removeEventListener(`change`,n)}},getSnapshot(){return t()?window.matchMedia(e).matches:!1},getServerSnapshot(){return!1}};exports.reducedMotionStore=n;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
//#region src/controllers/reducedMotionStore.ts
|
|
2
|
+
var e = "(prefers-reduced-motion: reduce)", t = () => typeof window < "u" && typeof window.matchMedia == "function", n = {
|
|
3
|
+
subscribe(n) {
|
|
4
|
+
if (!t()) return () => {};
|
|
5
|
+
let r = window.matchMedia(e);
|
|
6
|
+
return r.addEventListener("change", n), () => {
|
|
7
|
+
r.removeEventListener("change", n);
|
|
8
|
+
};
|
|
9
|
+
},
|
|
10
|
+
getSnapshot() {
|
|
11
|
+
return t() ? window.matchMedia(e).matches : !1;
|
|
12
|
+
},
|
|
13
|
+
getServerSnapshot() {
|
|
14
|
+
return !1;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
//#endregion
|
|
18
|
+
export { n as reducedMotionStore };
|