@ishibashi0112/spreadsheet-grid-core 0.48.0 → 0.49.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.
- package/dist/controllers/autoHeightMeasurer.cjs +1 -1
- package/dist/controllers/autoHeightMeasurer.js +4 -2
- package/dist/controllers/clipboardController.cjs +1 -1
- package/dist/controllers/clipboardController.d.ts +2 -1
- package/dist/controllers/clipboardController.js +67 -61
- package/dist/controllers/columnAutosizeRunner.cjs +1 -1
- package/dist/controllers/columnAutosizeRunner.d.ts +3 -0
- package/dist/controllers/columnAutosizeRunner.js +40 -24
- package/dist/controllers/columnHeaderDragController.cjs +1 -1
- package/dist/controllers/columnHeaderDragController.js +5 -2
- package/dist/controllers/editController.cjs +1 -1
- package/dist/controllers/editController.js +2 -2
- package/dist/controllers/fillHandleController.cjs +1 -0
- package/dist/controllers/fillHandleController.d.ts +87 -0
- package/dist/controllers/fillHandleController.js +346 -0
- package/dist/controllers/filterPopoverController.cjs +1 -1
- package/dist/controllers/filterPopoverController.js +55 -46
- package/dist/controllers/globalFilteredOrder.cjs +1 -1
- package/dist/controllers/globalFilteredOrder.js +5 -5
- package/dist/controllers/historyController.cjs +1 -1
- package/dist/controllers/historyController.d.ts +1 -0
- package/dist/controllers/historyController.js +8 -5
- package/dist/controllers/keyboardController.cjs +1 -1
- package/dist/controllers/keyboardController.js +2 -2
- package/dist/controllers/pointerInteractionsController.cjs +1 -1
- package/dist/controllers/pointerInteractionsController.d.ts +2 -0
- package/dist/controllers/pointerInteractionsController.js +136 -132
- package/dist/controllers/rowDragController.cjs +1 -1
- package/dist/controllers/rowDragController.d.ts +1 -0
- package/dist/controllers/rowDragController.js +104 -97
- package/dist/controllers/scrollSyncController.cjs +1 -1
- package/dist/controllers/scrollSyncController.d.ts +1 -0
- package/dist/controllers/scrollSyncController.js +32 -21
- package/dist/controllers/selectOptionsCollector.cjs +1 -1
- package/dist/controllers/selectOptionsCollector.js +5 -5
- package/dist/controllers/selectionAggregatesRunner.cjs +1 -0
- package/dist/controllers/selectionAggregatesRunner.d.ts +27 -0
- package/dist/controllers/selectionAggregatesRunner.js +65 -0
- package/dist/controllers/serverSideRowModel.cjs +1 -1
- package/dist/controllers/serverSideRowModel.js +75 -69
- package/dist/controllers/tooltipController.cjs +1 -1
- package/dist/controllers/tooltipController.js +44 -43
- package/dist/controllers/viewportSyncController.cjs +1 -1
- package/dist/controllers/viewportSyncController.d.ts +3 -2
- package/dist/controllers/viewportSyncController.js +6 -4
- package/dist/engine/columnCommands.cjs +1 -1
- package/dist/engine/columnCommands.js +1 -1
- package/dist/engine/columnLayout.cjs +1 -1
- package/dist/engine/columnLayout.js +1 -1
- package/dist/engine/createGridEngine.cjs +1 -1
- package/dist/engine/createGridEngine.d.ts +2 -0
- package/dist/engine/createGridEngine.js +43 -41
- package/dist/engine/gridApi.cjs +1 -1
- package/dist/engine/gridApi.d.ts +6 -0
- package/dist/engine/gridApi.js +134 -123
- package/dist/logic/aggregation.cjs +1 -1
- package/dist/logic/aggregation.d.ts +1 -0
- package/dist/logic/aggregation.js +16 -7
- package/dist/logic/autoScrollGeometry.cjs +1 -1
- package/dist/logic/autoScrollGeometry.d.ts +1 -0
- package/dist/logic/autoScrollGeometry.js +3 -3
- package/dist/logic/clearCells.cjs +1 -1
- package/dist/logic/clearCells.d.ts +1 -1
- package/dist/logic/clearCells.js +7 -7
- package/dist/logic/columnAutosize.cjs +1 -1
- package/dist/logic/columnAutosize.d.ts +6 -0
- package/dist/logic/columnAutosize.js +60 -39
- package/dist/logic/exportCsv.cjs +2 -2
- package/dist/logic/exportCsv.d.ts +5 -1
- package/dist/logic/exportCsv.js +16 -15
- package/dist/logic/exportData.cjs +1 -1
- package/dist/logic/exportData.d.ts +2 -1
- package/dist/logic/exportData.js +27 -21
- package/dist/logic/fillHandle.cjs +1 -0
- package/dist/logic/fillHandle.d.ts +69 -0
- package/dist/logic/fillHandle.js +254 -0
- package/dist/logic/fillSeries.cjs +1 -0
- package/dist/logic/fillSeries.d.ts +11 -0
- package/dist/logic/fillSeries.js +239 -0
- package/dist/logic/filtering.cjs +1 -1
- package/dist/logic/filtering.js +37 -37
- package/dist/logic/gridState.cjs +1 -1
- package/dist/logic/gridState.js +1 -1
- package/dist/logic/imeInput.cjs +1 -1
- package/dist/logic/imeInput.js +2 -2
- package/dist/logic/labelRows.cjs +1 -1
- package/dist/logic/labelRows.js +1 -1
- package/dist/logic/selectOptions.cjs +1 -1
- package/dist/logic/selectOptions.js +1 -1
- package/dist/logic/selectionAggregates.cjs +1 -0
- package/dist/logic/selectionAggregates.d.ts +25 -0
- package/dist/logic/selectionAggregates.js +74 -0
- package/dist/logic/totalRow.cjs +1 -0
- package/dist/logic/totalRow.d.ts +25 -0
- package/dist/logic/totalRow.js +90 -0
- package/dist/model/gridReducer.cjs +1 -1
- package/dist/model/gridReducer.js +1 -1
- package/dist/model/gridTypes.core.d.ts +202 -16
- package/dist/model/gridTypes.unbound.d.ts +4 -0
- package/dist/utils/clipboard.cjs +1 -1
- package/dist/utils/clipboard.d.ts +1 -1
- package/dist/utils/clipboard.js +9 -9
- package/dist/utils/permissions.cjs +1 -1
- package/dist/utils/permissions.d.ts +6 -2
- package/dist/utils/permissions.js +8 -2
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../logic/valueStore.cjs"),t=require("../logic/rowHeightStore.cjs"),n=require("../logic/detailRow.cjs");var r=(e,t)=>e.autoHeightActive===t.autoHeightActive&&e.rowHeightStore===t.rowHeightStore&&e.rowMetrics===t.rowMetrics&&e.rowModel===t.rowModel&&e.virtualRows===t.virtualRows&&e.viewportHeight===t.viewportHeight&&e.version===t.version&&e.nonce===t.nonce,i=()=>{let i=e.createValueStore({version:0,nonce:0}),a=new Map,o=null,s=new Set,c=null,l=()=>{o?.disconnect(),o=null,s.clear()},u=()=>{let e=i.getSnapshot();i.setSnapshot({...e,version:e.version+1})},d=()=>{let e=i.getSnapshot();i.setSnapshot({...e,nonce:e.nonce+1})},f=e=>{let{autoHeightActive:r,rowHeightStore:i,rowMetrics:a,rowModel:c}=e,f=e.scrollContainerRef.current;if(!r||!i){l();return}if(!f)return;let p=f.querySelectorAll(`[data-autoheight-cell]`);if(p.length>0){let e=new Map;p.forEach(t=>{if(n.isInsideDetailCardOf(f,t))return;let r=t.closest(`[data-row-index]`);if(!r)return;let i=Number(r.dataset.rowIndex);if(!Number.isFinite(i))return;let a=Math.ceil(t.getBoundingClientRect().height),o=e.get(i);(o===void 0||a>o)&&e.set(i,a)});let r=!1,o=1/0;if(e.forEach((e,n)=>{let a=c.getRowKey(n)??n;t.setMeasuredRowHeight(i,n,a,e)&&(r=!0,n<o&&(o=n))}),r){let e=f.scrollTop,n=a.rowAtContentY(e),r=e-a.rowTop(n);t.rebuildPrefixFrom(i,o),f.scrollTop=
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../logic/valueStore.cjs"),t=require("../logic/rowHeightStore.cjs"),n=require("../logic/detailRow.cjs");var r=(e,t)=>e.autoHeightActive===t.autoHeightActive&&e.rowHeightStore===t.rowHeightStore&&e.rowMetrics===t.rowMetrics&&e.rowModel===t.rowModel&&e.virtualRows===t.virtualRows&&e.viewportHeight===t.viewportHeight&&e.version===t.version&&e.nonce===t.nonce,i=()=>{let i=e.createValueStore({version:0,nonce:0}),a=new Map,o=null,s=new Set,c=null,l=()=>{o?.disconnect(),o=null,s.clear()},u=()=>{let e=i.getSnapshot();i.setSnapshot({...e,version:e.version+1})},d=()=>{let e=i.getSnapshot();i.setSnapshot({...e,nonce:e.nonce+1})},f=e=>{let{autoHeightActive:r,rowHeightStore:i,rowMetrics:a,rowModel:c}=e,f=e.scrollContainerRef.current;if(!r||!i){l();return}if(!f)return;let p=f.querySelectorAll(`[data-autoheight-cell]`);if(p.length>0){let e=new Map;p.forEach(t=>{if(n.isInsideDetailCardOf(f,t))return;let r=t.closest(`[data-row-index]`);if(!r)return;let i=Number(r.dataset.rowIndex);if(!Number.isFinite(i))return;let a=Math.ceil(t.getBoundingClientRect().height),o=e.get(i);(o===void 0||a>o)&&e.set(i,a)});let r=!1,o=1/0;if(e.forEach((e,n)=>{let a=c.getRowKey(n)??n;t.setMeasuredRowHeight(i,n,a,e)&&(r=!0,n<o&&(o=n))}),r){let e=f.scrollTop,n=a.rowAtContentY(e),r=e-a.rowTop(n);t.rebuildPrefixFrom(i,o),f.scrollTop=a.rowTop(n)+r,u()}}o===null&&(o=new ResizeObserver(d));let m=o,h=new Set;p.forEach(e=>{h.add(e),s.has(e)||(m.observe(e),s.add(e))});let g=[];s.forEach(e=>{h.has(e)||g.push(e)}),g.forEach(e=>{m.unobserve(e),s.delete(e)})};return{update:e=>{c!==null&&r(c,e)||(c=e,f(e))},getSnapshot:i.getSnapshot,subscribe:i.subscribe,measuredHeights:a,dispose:()=>{l(),c=null}}};exports.createAutoHeightMeasurer=i;
|
|
@@ -45,7 +45,7 @@ var i = (e, t) => e.autoHeightActive === t.autoHeightActive && e.rowHeightStore
|
|
|
45
45
|
n(a, t, r, e) && (i = !0, t < s && (s = t));
|
|
46
46
|
}), i) {
|
|
47
47
|
let e = p.scrollTop, n = o.rowAtContentY(e), r = e - o.rowTop(n);
|
|
48
|
-
t(a, s), p.scrollTop =
|
|
48
|
+
t(a, s), p.scrollTop = o.rowTop(n) + r, d();
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
s === null && (s = new ResizeObserver(f));
|
|
@@ -67,7 +67,9 @@ var i = (e, t) => e.autoHeightActive === t.autoHeightActive && e.rowHeightStore
|
|
|
67
67
|
getSnapshot: a.getSnapshot,
|
|
68
68
|
subscribe: a.subscribe,
|
|
69
69
|
measuredHeights: o,
|
|
70
|
-
dispose:
|
|
70
|
+
dispose: () => {
|
|
71
|
+
u(), l = null;
|
|
72
|
+
}
|
|
71
73
|
};
|
|
72
74
|
};
|
|
73
75
|
//#endregion
|
|
@@ -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)&&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,
|
|
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,rowKeyGetter:h,createRow:g,createOverflowColumn:_,onRowsChange:v,onColumnsChange:y,applyServerSideCellEdits:b,dispatch:x}=s;if(f.editingCell||r.shouldIgnoreGridKeydown(o.target??null)||p||!v&&!b||!f.activeCell)return;let S=o.clipboardData?.getData(`text/plain`)??``;if(!S)return;o.preventDefault();let C=i.parseClipboardText(S);if(C.length===0)return;let w=C.reduce((e,t)=>Math.max(e,t.length),0);if(w===0)return;let T=f.activeCell.row,E=f.activeCell.col,D=l.getLabelRow===void 0?null:a.resolvePasteTargetViewIndexes(l,T,C.length),O=e=>D?D[e-T]:e,k=D?D[D.length-1]:f.activeCell.row+Math.max(C.length-1,0);if(b){let r=i.buildClipboardCellEdits(e=>l.getRow(O(e)),d,C,T,E,(t,n,r,i)=>e.isViewCellEditable({readOnly:p,canEditCell:m},l,O(t),n,r,i)).map(e=>({...e,viewIndex:O(e.viewIndex)}));r.length>0&&b(r);let a=n.clamp(k,0,Math.max(l.getRowCount()-1,0)),o=n.clamp(f.activeCell.col+Math.max(w-1,0),0,Math.max(d.length-1,0));x(t.gridActions.startSelection(f.activeCell)),x(t.gridActions.updateSelection({row:a,col:o})),x(t.gridActions.endSelection()),x(t.gridActions.activateCell(f.activeCell));return}if(!v||l.getSourceIndex(T)===void 0)return;let A=f.activeCell.col,j=[...c],M=[...d],N=l.getRowCount(),P=j.length,F=e=>{let t=O(e);return t<N?l.getSourceIndex(t):P+(t-N)},I=Math.max(k+1-N,0),L=j.length+I;if(L>j.length&&g)for(;j.length<L;)j.push(g());let R=A+w;if(R>M.length&&y&&_){let e=[];for(;M.length<R;){let t=_(M.length);M.push(t),e.push(t)}y(u?[...u,...e]:M)}let z=i.applyClipboardMatrixToRows(j,F,M,C,T,A,(t,n,r,i,a)=>{let o=O(a),s=o<N?l.getRowKey(o):h?.(r,t)??t;return e.isCellEditable({readOnly:p,canEditCell:m},o,n,r,i,{sourceRowIndex:t,rowKey:s??t})}),B=n.clamp(k,0,Math.max(Math.max(l.getRowCount()-1,0),k)),V=n.clamp(f.activeCell.col+Math.max(w-1,0),0,Math.max(Math.max(M.length-1,0),A+w-1));v(z),x(t.gridActions.startSelection(f.activeCell)),x(t.gridActions.updateSelection({row:B,col:V})),x(t.gridActions.endSelection()),x(t.gridActions.activateCell(f.activeCell))}}};exports.computeIsWholeGridSelected=o,exports.createClipboardController=s;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type GridUiAction } from '../model/gridActions.js';
|
|
2
|
-
import type { GridColumn, GridSelection, GridUiState, RowModel, SpreadsheetGridProps } from '../model/gridTypes.unbound.js';
|
|
2
|
+
import type { GridColumn, GridRowKey, GridSelection, GridUiState, RowModel, SpreadsheetGridProps } from '../model/gridTypes.unbound.js';
|
|
3
3
|
import type { ServerSideCellEditInput } from '../logic/serverSideEdits.js';
|
|
4
4
|
export type ClipboardEventLike = {
|
|
5
5
|
clipboardData: {
|
|
@@ -16,6 +16,7 @@ export type ClipboardControllerArgs<T extends object> = {
|
|
|
16
16
|
uiState: GridUiState;
|
|
17
17
|
readOnly: boolean;
|
|
18
18
|
canEditCell: SpreadsheetGridProps<T>['canEditCell'];
|
|
19
|
+
rowKeyGetter?: (row: T, sourceIndex: number) => GridRowKey;
|
|
19
20
|
createRow?: () => T;
|
|
20
21
|
createOverflowColumn?: (columnIndex: number) => GridColumn<T>;
|
|
21
22
|
onRowsChange?: (nextRows: T[]) => void;
|
|
@@ -1,98 +1,104 @@
|
|
|
1
|
-
import { getCellValue as e, isCellEditable as t } from "../utils/permissions.js";
|
|
2
|
-
import { gridActions as
|
|
3
|
-
import { clamp as
|
|
4
|
-
import { shouldIgnoreGridKeydown as
|
|
5
|
-
import { applyClipboardMatrixToRows as
|
|
6
|
-
import { resolvePasteTargetViewIndexes as
|
|
1
|
+
import { getCellValue as e, isCellEditable as t, isViewCellEditable as n } from "../utils/permissions.js";
|
|
2
|
+
import { gridActions as r } from "../model/gridActions.js";
|
|
3
|
+
import { clamp as i } from "../logic/geometry.js";
|
|
4
|
+
import { shouldIgnoreGridKeydown as a } from "../logic/domGuards.js";
|
|
5
|
+
import { applyClipboardMatrixToRows as o, buildClipboardCellEdits as s, joinTsvRow as c, parseClipboardText as l, serializeSelectionToTsv as u, writeTextToClipboard as d } from "../utils/clipboard.js";
|
|
6
|
+
import { resolvePasteTargetViewIndexes as f } from "../logic/labelRows.js";
|
|
7
7
|
//#region src/controllers/clipboardController.ts
|
|
8
|
-
var
|
|
8
|
+
var p = (e, t, n) => {
|
|
9
9
|
if (t === 0 || n === 0 || e?.type !== "cell") return !1;
|
|
10
10
|
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);
|
|
11
11
|
return a === 0 && o === 0 && s === t - 1 && c === n - 1;
|
|
12
|
-
},
|
|
13
|
-
let
|
|
14
|
-
|
|
15
|
-
},
|
|
12
|
+
}, m = () => {
|
|
13
|
+
let m = null, h = (e) => {
|
|
14
|
+
m = e;
|
|
15
|
+
}, g = (e) => {
|
|
16
16
|
let { isRowExportable: t, rowModel: n } = e;
|
|
17
17
|
if (t) return (e, r) => t(e, {
|
|
18
18
|
viewRowIndex: r,
|
|
19
19
|
rowKey: n.getRowKey(r) ?? r
|
|
20
20
|
});
|
|
21
|
-
},
|
|
21
|
+
}, _ = (t) => {
|
|
22
22
|
let { rowModel: n, visibleColumns: r } = t, i = n.getRowCount();
|
|
23
23
|
if (i === 0 || r.length === 0) return "";
|
|
24
|
-
let a =
|
|
24
|
+
let a = g(t), o = [];
|
|
25
25
|
for (let t = 0; t < i; t += 1) {
|
|
26
26
|
let i = n.getRow(t);
|
|
27
27
|
if (!i || a && !a(i, t)) continue;
|
|
28
|
-
let
|
|
28
|
+
let s = r.map((t) => {
|
|
29
29
|
let n = e(i, t);
|
|
30
30
|
return t.formatClipboardValue ? t.formatClipboardValue(n, i) : String(n ?? "");
|
|
31
31
|
});
|
|
32
|
-
o.push(s
|
|
32
|
+
o.push(c(s));
|
|
33
33
|
}
|
|
34
34
|
return o.join("\n");
|
|
35
35
|
};
|
|
36
36
|
return {
|
|
37
|
-
update:
|
|
37
|
+
update: h,
|
|
38
38
|
handleCopy: async () => {
|
|
39
|
-
if (
|
|
40
|
-
let e =
|
|
41
|
-
i && await
|
|
39
|
+
if (m === null) return;
|
|
40
|
+
let e = m, { rowModel: t, visibleColumns: n, uiState: r } = e, i = p(r.selection, t.getRowCount(), n.length) ? _(e) : u(t.getRow, t.getRowCount(), n, r.selection, g(e));
|
|
41
|
+
i && await d(i) && r.selection && e.onCopied?.(r.selection);
|
|
42
42
|
},
|
|
43
43
|
handlePaste: (e) => {
|
|
44
|
-
if (
|
|
45
|
-
let { rows:
|
|
46
|
-
if (
|
|
47
|
-
let
|
|
48
|
-
if (!
|
|
44
|
+
if (m === null) return;
|
|
45
|
+
let { rows: c, rowModel: u, columns: d, visibleColumns: p, uiState: h, readOnly: g, canEditCell: _, rowKeyGetter: v, createRow: y, createOverflowColumn: b, onRowsChange: x, onColumnsChange: S, applyServerSideCellEdits: C, dispatch: w } = m;
|
|
46
|
+
if (h.editingCell || a(e.target ?? null) || g || !x && !C || !h.activeCell) return;
|
|
47
|
+
let T = e.clipboardData?.getData("text/plain") ?? "";
|
|
48
|
+
if (!T) return;
|
|
49
49
|
e.preventDefault();
|
|
50
|
-
let
|
|
51
|
-
if (
|
|
52
|
-
let
|
|
53
|
-
if (
|
|
54
|
-
let
|
|
55
|
-
if (
|
|
56
|
-
let e =
|
|
57
|
-
readOnly:
|
|
58
|
-
canEditCell:
|
|
59
|
-
},
|
|
50
|
+
let E = l(T);
|
|
51
|
+
if (E.length === 0) return;
|
|
52
|
+
let D = E.reduce((e, t) => Math.max(e, t.length), 0);
|
|
53
|
+
if (D === 0) return;
|
|
54
|
+
let O = h.activeCell.row, k = h.activeCell.col, A = u.getLabelRow === void 0 ? null : f(u, O, E.length), j = (e) => A ? A[e - O] : e, M = A ? A[A.length - 1] : h.activeCell.row + Math.max(E.length - 1, 0);
|
|
55
|
+
if (C) {
|
|
56
|
+
let e = s((e) => u.getRow(j(e)), p, E, O, k, (e, t, r, i) => n({
|
|
57
|
+
readOnly: g,
|
|
58
|
+
canEditCell: _
|
|
59
|
+
}, u, j(e), t, r, i)).map((e) => ({
|
|
60
60
|
...e,
|
|
61
|
-
viewIndex:
|
|
61
|
+
viewIndex: j(e.viewIndex)
|
|
62
62
|
}));
|
|
63
|
-
e.length > 0 &&
|
|
64
|
-
let
|
|
65
|
-
|
|
66
|
-
row:
|
|
63
|
+
e.length > 0 && C(e);
|
|
64
|
+
let t = i(M, 0, Math.max(u.getRowCount() - 1, 0)), a = i(h.activeCell.col + Math.max(D - 1, 0), 0, Math.max(p.length - 1, 0));
|
|
65
|
+
w(r.startSelection(h.activeCell)), w(r.updateSelection({
|
|
66
|
+
row: t,
|
|
67
67
|
col: a
|
|
68
|
-
})),
|
|
68
|
+
})), w(r.endSelection()), w(r.activateCell(h.activeCell));
|
|
69
69
|
return;
|
|
70
70
|
}
|
|
71
|
-
if (!
|
|
72
|
-
let
|
|
73
|
-
let t =
|
|
74
|
-
return t <
|
|
75
|
-
},
|
|
76
|
-
if (
|
|
77
|
-
let
|
|
78
|
-
if (
|
|
71
|
+
if (!x || u.getSourceIndex(O) === void 0) return;
|
|
72
|
+
let N = h.activeCell.col, P = [...c], F = [...p], I = u.getRowCount(), L = P.length, R = (e) => {
|
|
73
|
+
let t = j(e);
|
|
74
|
+
return t < I ? u.getSourceIndex(t) : L + (t - I);
|
|
75
|
+
}, z = Math.max(M + 1 - I, 0), B = P.length + z;
|
|
76
|
+
if (B > P.length && y) for (; P.length < B;) P.push(y());
|
|
77
|
+
let V = N + D;
|
|
78
|
+
if (V > F.length && S && b) {
|
|
79
79
|
let e = [];
|
|
80
|
-
for (;
|
|
81
|
-
let t =
|
|
82
|
-
|
|
80
|
+
for (; F.length < V;) {
|
|
81
|
+
let t = b(F.length);
|
|
82
|
+
F.push(t), e.push(t);
|
|
83
83
|
}
|
|
84
|
-
|
|
84
|
+
S(d ? [...d, ...e] : F);
|
|
85
85
|
}
|
|
86
|
-
let
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
86
|
+
let H = o(P, R, F, E, O, N, (e, n, r, i, a) => {
|
|
87
|
+
let o = j(a), s = o < I ? u.getRowKey(o) : v?.(r, e) ?? e;
|
|
88
|
+
return t({
|
|
89
|
+
readOnly: g,
|
|
90
|
+
canEditCell: _
|
|
91
|
+
}, o, n, r, i, {
|
|
92
|
+
sourceRowIndex: e,
|
|
93
|
+
rowKey: s ?? e
|
|
94
|
+
});
|
|
95
|
+
}), U = i(M, 0, Math.max(Math.max(u.getRowCount() - 1, 0), M)), W = i(h.activeCell.col + Math.max(D - 1, 0), 0, Math.max(Math.max(F.length - 1, 0), N + D - 1));
|
|
96
|
+
x(H), w(r.startSelection(h.activeCell)), w(r.updateSelection({
|
|
97
|
+
row: U,
|
|
98
|
+
col: W
|
|
99
|
+
})), w(r.endSelection()), w(r.activateCell(h.activeCell));
|
|
94
100
|
}
|
|
95
101
|
};
|
|
96
102
|
};
|
|
97
103
|
//#endregion
|
|
98
|
-
export {
|
|
104
|
+
export { p as computeIsWholeGridSelected, m as createClipboardController };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../logic/valueStore.cjs"),t=require("../logic/chunkedLoop.cjs"),n=require("../model/gridActions.cjs"),r=require("../logic/columnAutosize.cjs"),i=require("../logic/autoSizeOnData.cjs");var a=180,o=()=>{let i=null,o=e.createValueStore(!1),s=0,c=null,l=()=>{c!==null&&(clearTimeout(c),c=null)};return{update:e=>{i=e},runAutosize:async e=>{if(i===null||e.length===0||!r.canMeasureAutosize())return;let{rowModel:u,gridRootRef:d,columnWidths:f,dispatch:p}=i,
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../logic/valueStore.cjs"),t=require("../logic/chunkedLoop.cjs"),n=require("../model/gridActions.cjs"),r=require("../logic/columnAutosize.cjs"),i=require("../logic/autoSizeOnData.cjs");var a=180,o=()=>{let i=null,o=e.createValueStore(!1),s=0,c=null,l=()=>{c!==null&&(clearTimeout(c),c=null)};return{update:e=>{i=e},runAutosize:async e=>{if(i===null||e.length===0||!r.canMeasureAutosize())return;let{rowModel:u,gridRootRef:d,columnWidths:f,dispatch:p,totalRowTexts:m}=i,h=s+=1;l();let g=u.getRowCount(),_=d.current,v=r.createColumnWidthAccumulator(e);c=setTimeout(()=>{s===h&&o.setSnapshot(!0)},a);try{if(!await t.runChunked(g,e=>{let t=u.getRow(e);t&&v.collect(t)},{isCancelled:()=>s!==h||i?.rowModel!==u}))return;let e=v.finalize({gridRoot:_,currentWidths:f,totalRowTexts:m});Object.keys(e).length>0&&p(n.gridActions.syncColumnWidths(e))}finally{s===h&&(l(),o.setSnapshot(!1))}},subscribe:o.subscribe,getSnapshot:o.getSnapshot,dispose:()=>{s+=1,l()}}},s=()=>{let e=null,t=!1,n=!1,r=0;return{dispose:()=>{e=null,r+=1,n&&(n=!1,t=!1)},update:a=>{if(e!==null&&e.mode===a.mode&&e.isServerSide===a.isServerSide&&e.rows===a.rows&&e.runAutosize===a.runAutosize){e=a;return}e=a;let{shouldRun:o,nextHasAutoSizedOnMount:s}=i.resolveAutoSizeOnData({mode:a.mode,isServerSide:a.isServerSide,rowCount:a.rows.length,hasAutoSizedOnMount:t});if(t=s,o){if(a.mode!==`onMount`){a.runAutosize(a.visibleColumns);return}n=!0;let e=r;a.runAutosize(a.visibleColumns).finally(()=>{e===r&&(n=!1)})}}}};exports.createAutoSizeOnDataTrigger=s,exports.createColumnAutosizeRunner=o;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type AutosizeTotalRowTexts } from '../logic/columnAutosize.js';
|
|
1
2
|
import { gridActions } from '../model/gridActions.js';
|
|
2
3
|
import type { AutoSizeColumnsMode, GridColumn, RowModel } from '../model/gridTypes.unbound.js';
|
|
3
4
|
type ReadonlyRef<V> = {
|
|
@@ -8,6 +9,7 @@ export type ColumnAutosizeRunnerArgs<T> = {
|
|
|
8
9
|
gridRootRef: ReadonlyRef<HTMLElement | null>;
|
|
9
10
|
columnWidths: Record<string, number>;
|
|
10
11
|
dispatch: (action: ReturnType<typeof gridActions.syncColumnWidths>) => void;
|
|
12
|
+
totalRowTexts?: AutosizeTotalRowTexts;
|
|
11
13
|
};
|
|
12
14
|
export type ColumnAutosizeRunner<T> = {
|
|
13
15
|
update: (args: ColumnAutosizeRunnerArgs<T>) => void;
|
|
@@ -26,6 +28,7 @@ export type AutoSizeOnDataArgs<T> = {
|
|
|
26
28
|
};
|
|
27
29
|
export type AutoSizeOnDataTrigger<T> = {
|
|
28
30
|
update: (args: AutoSizeOnDataArgs<T>) => void;
|
|
31
|
+
dispose: () => void;
|
|
29
32
|
};
|
|
30
33
|
export declare const createAutoSizeOnDataTrigger: <T>() => AutoSizeOnDataTrigger<T>;
|
|
31
34
|
export {};
|
|
@@ -14,24 +14,25 @@ var o = 180, s = () => {
|
|
|
14
14
|
},
|
|
15
15
|
runAutosize: async (e) => {
|
|
16
16
|
if (a === null || e.length === 0 || !r()) return;
|
|
17
|
-
let { rowModel: d, gridRootRef: f, columnWidths: p, dispatch: m } = a,
|
|
17
|
+
let { rowModel: d, gridRootRef: f, columnWidths: p, dispatch: m, totalRowTexts: h } = a, g = c += 1;
|
|
18
18
|
u();
|
|
19
|
-
let
|
|
19
|
+
let _ = d.getRowCount(), v = f.current, y = i(e);
|
|
20
20
|
l = setTimeout(() => {
|
|
21
|
-
c ===
|
|
21
|
+
c === g && s.setSnapshot(!0);
|
|
22
22
|
}, o);
|
|
23
23
|
try {
|
|
24
|
-
if (!await t(
|
|
24
|
+
if (!await t(_, (e) => {
|
|
25
25
|
let t = d.getRow(e);
|
|
26
|
-
t &&
|
|
27
|
-
}, { isCancelled: () => c !==
|
|
28
|
-
let e =
|
|
29
|
-
gridRoot:
|
|
30
|
-
currentWidths: p
|
|
26
|
+
t && y.collect(t);
|
|
27
|
+
}, { isCancelled: () => c !== g || a?.rowModel !== d })) return;
|
|
28
|
+
let e = y.finalize({
|
|
29
|
+
gridRoot: v,
|
|
30
|
+
currentWidths: p,
|
|
31
|
+
totalRowTexts: h
|
|
31
32
|
});
|
|
32
33
|
Object.keys(e).length > 0 && m(n.syncColumnWidths(e));
|
|
33
34
|
} finally {
|
|
34
|
-
c ===
|
|
35
|
+
c === g && (u(), s.setSnapshot(!1));
|
|
35
36
|
}
|
|
36
37
|
},
|
|
37
38
|
subscribe: s.subscribe,
|
|
@@ -41,21 +42,36 @@ var o = 180, s = () => {
|
|
|
41
42
|
}
|
|
42
43
|
};
|
|
43
44
|
}, c = () => {
|
|
44
|
-
let e = null, t = !1;
|
|
45
|
-
return {
|
|
46
|
-
|
|
47
|
-
e = n;
|
|
48
|
-
|
|
45
|
+
let e = null, t = !1, n = !1, r = 0;
|
|
46
|
+
return {
|
|
47
|
+
dispose: () => {
|
|
48
|
+
e = null, r += 1, n && (n = !1, t = !1);
|
|
49
|
+
},
|
|
50
|
+
update: (i) => {
|
|
51
|
+
if (e !== null && e.mode === i.mode && e.isServerSide === i.isServerSide && e.rows === i.rows && e.runAutosize === i.runAutosize) {
|
|
52
|
+
e = i;
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
e = i;
|
|
56
|
+
let { shouldRun: o, nextHasAutoSizedOnMount: s } = a({
|
|
57
|
+
mode: i.mode,
|
|
58
|
+
isServerSide: i.isServerSide,
|
|
59
|
+
rowCount: i.rows.length,
|
|
60
|
+
hasAutoSizedOnMount: t
|
|
61
|
+
});
|
|
62
|
+
if (t = s, o) {
|
|
63
|
+
if (i.mode !== "onMount") {
|
|
64
|
+
i.runAutosize(i.visibleColumns);
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
n = !0;
|
|
68
|
+
let e = r;
|
|
69
|
+
i.runAutosize(i.visibleColumns).finally(() => {
|
|
70
|
+
e === r && (n = !1);
|
|
71
|
+
});
|
|
72
|
+
}
|
|
49
73
|
}
|
|
50
|
-
|
|
51
|
-
let { shouldRun: r, nextHasAutoSizedOnMount: i } = a({
|
|
52
|
-
mode: n.mode,
|
|
53
|
-
isServerSide: n.isServerSide,
|
|
54
|
-
rowCount: n.rows.length,
|
|
55
|
-
hasAutoSizedOnMount: t
|
|
56
|
-
});
|
|
57
|
-
t = i, r && n.runAutosize(n.visibleColumns);
|
|
58
|
-
} };
|
|
74
|
+
};
|
|
59
75
|
};
|
|
60
76
|
//#endregion
|
|
61
77
|
export { c as createAutoSizeOnDataTrigger, s as createColumnAutosizeRunner };
|
|
@@ -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]}function a(n,r,i,a){let o=n.filter(e=>t.getColumnPane(e)===i&&e.visible!==!1).map(e=>e.key),{entries:s}=r;for(let t=Math.max(a,0);t<s.length;t+=1){let n=s[t].column.key;if(e.isSyntheticColumnKey(n))continue;let r=o.indexOf(n);return r<0?o.length:r}return o.length}var o=t=>{let n=0;for(;n<t.entries.length&&e.isSyntheticColumnKey(t.entries[n].column.key);)n+=1;return n},s=32,c=2,l=14,u=12,d=14,f=e=>`<svg viewBox="0 0 24 24" width="`+e+`" height="`+e+`" 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>`,p=e=>`<svg viewBox="0 0 24 24" width="`+e+`" height="`+e+`" 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>`,m=f(d),h=p(d),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)`,ee=e=>e?.closest(`.ssg-motion-off`)!=null,te=160,b=`transform ${te}ms ${y}`,x=`data-ssg-col-dragging`,ne=`4`,re=`9`,ie=`ssg-col-drag-float`,ae=`ssg-col-drag-pin`,oe=12,se=`ssg-col-drop-indicator`,ce=`ssg-header-cell`,le=[`data-ssg-col-key`,`data-ssg-tooltip`,`data-autoheight-cell`,`id`,`tabindex`],ue=180,de=400,S=t=>{let n=[];return t.querySelectorAll(`[data-ssg-col-key]`).forEach(r=>{e.isInsideDetailCardOf(t,r)||n.push(r)}),n},fe=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},pe=e=>{let t=getComputedStyle(e).transform,n=/^matrix(3d)?\(([^)]*)\)$/.exec(t);if(n===null)return 0;let r=Number(n[2].split(`,`)[n[1]===`3d`?12:4]);return Number.isFinite(r)?r:0},C=()=>{let d=null,C=null,w=null,T=null,E={x:0,y:0},D=null,O=!1,k=null,A=null,j=null,M=null,N=null,P=null,F=null,I=null,me=0,L=null,R=null,z=``,B=null,V=0,H=null,U=null,he=()=>d?.motion===`live`,W=()=>({left:d?.leftIndicatorRef.current??null,center:d?.centerIndicatorRef.current??null,right:d?.rightIndicatorRef.current??null}),G=()=>{for(let e of Object.values(W()))e&&(e.style.display=`none`)},ge=e=>{if(N)return;let t=document.createElement(`div`);t.setAttribute(`data-grid-drag-ghost`,``),d?.scrollContainerRef.current?.closest(`.ssg-theme-dark`)!=null&&t.classList.add(`ssg-theme-dark`),d?.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,d?.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),N=t,P=n,F=null},_e=e=>{let t=N;if(!t)return;t.style.transform=`translate(`+(E.x+l)+`px,`+(E.y+u)+`px)`;let n=e??`out`;if(F===n)return;F=n;let r=P;n===`out`?(t.style.opacity=_,r&&(r.innerHTML=g)):(t.style.opacity=`1`,r&&(r.innerHTML=n===`center`?m:h))},K=()=>{N&&N.parentNode&&N.parentNode.removeChild(N),N=null,P=null,F=null},ve=(e,n)=>{if(d===null)return null;let{paneLayout:r,leftPaneScrollRef:i,rightPaneScrollRef:a,bodyScrollRef:l,scrollContainerRef:u,leftLeadingWidth:f,centerLeadingWidth:p,rightLeadingWidth:m}=d,h=u.current;if(h){let t=h.getBoundingClientRect();if(e<t.left||e>t.right||n<t.top||n>t.bottom)return null}let g=i.current,_=a.current;if(g&&r.left.entries.length===0&&e<=g.getBoundingClientRect().left+s)return{pane:`left`,slot:0,leftPx:c};if(g&&r.left.entries.length>0){let n=g.getBoundingClientRect();if(e<n.right){let i=e-n.left-f,a=Math.max(t.findPaneDropSlot(r.left,i),o(r.left));return{pane:`left`,slot:a,leftPx:f+t.paneDropSlotBoundaryX(r.left,a)}}}if(_&&r.right.entries.length===0&&e>=_.getBoundingClientRect().left-s)return{pane:`right`,slot:0,leftPx:-2};if(_&&r.right.entries.length>0){let n=_.getBoundingClientRect();if(e>=n.left){let i=e-n.left-m,a=Math.max(t.findPaneDropSlot(r.right,i),o(r.right));return{pane:`right`,slot:a,leftPx:m+t.paneDropSlotBoundaryX(r.right,a)}}}let v=l.current;if(v&&r.center.entries.length>0){let n=v.getBoundingClientRect(),i=v.scrollLeft+e-n.left-p,a=Math.max(t.findPaneDropSlot(r.center,Math.max(i,0)),o(r.center));return{pane:`center`,slot:a,leftPx:p+t.paneDropSlotBoundaryX(r.center,a)}}return null},ye=e=>{let t=W();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`)}},be=(e,t)=>{let n=R?.get(t);n!==void 0&&R?.delete(t),e.set(t,n??{zIndex:t.style.zIndex,visibility:t.style.visibility})},q=(e,t)=>{let n=[],r=L,i=C,a=I;if(!r||i===null||a===null||d===null)return n;let o=d.scrollContainerRef.current;if(!o)return n;let s=d.paneLayout[a].entries,c=s.findIndex(e=>e.column.key===i);if(c<0)return n;let l=s[c].paneLocalSize,u=t===`lift-out`?s.length-1:t===`rest`||e===null?c:e>c?e-1:e,f=new Map;for(let e=Math.min(c,u);e<=Math.max(c,u);e+=1)e!==c&&f.set(s[e].column.key,e>c?-l:l);let p=a===`center`?o.scrollLeft-me:0,m=(D?E.x-D.x:0)+p,h=U,g=new WeakSet;U=g;for(let e of S(o)){let a=e.dataset.ssgColKey;if(a===void 0)continue;g.add(e);let o=h!==null&&!h.has(e)?`none`:b;if(a===i){n.push(e),r.has(e)||(be(r,e),e.style.zIndex=ne,e.style.willChange=`transform`);let i=r.get(e);t===`follow`?(e.style.visibility=i?.visibility??``,e.setAttribute(x,`live`),e.style.transition=`none`,e.style.transform=`translateX(${m}px)`):t===`lift-out`?(e.style.visibility=`hidden`,e.removeAttribute(x),e.style.transition=`none`,e.style.transform=`translateX(0px)`):(e.style.visibility=i?.visibility??``,e.removeAttribute(x),e.style.transition=o,e.style.transform=`translateX(0px)`);continue}let s=f.get(a)??0;if(s===0&&!r.has(e))continue;r.has(e)||be(r,e);let c=`translateX(${s}px)`;e.style.transform!==c&&(e.style.transition=o,e.style.transform=c)}return n},J=e=>{e.forEach((e,t)=>{t.style.transition=``,t.style.transform=``,t.style.willChange=``,t.style.zIndex=e.zIndex,t.style.visibility=e.visibility,t.removeAttribute(x)})},xe=e=>{let t=e=>{for(let t of le)e.removeAttribute(t)};t(e),e.querySelectorAll(`*`).forEach(t),e.querySelectorAll(`.ssg-header-actions`).forEach(e=>e.remove())},Se=(e,t,n)=>{let r=B;if(r===null){let e=document.createElement(`div`);e.className=ie,e.setAttribute(`aria-hidden`,`true`),e.setAttribute(`inert`,``);let n=document.createElement(`div`);n.style.cssText=`position:absolute;top:0;left:0;height:100%;will-change:transform`;let i=document.createElement(`div`);i.className=se,i.style.cssText=`position:absolute;display:none`,e.append(n,i),t.appendChild(e),r={layer:e,column:n,guide:i,badge:null,badgeKind:null,layerWidth:0,columnWidth:0,scrollTop:0,cellCount:0},B=r}let i=t.getBoundingClientRect(),a=e.getBoundingClientRect(),o=a.left+e.clientLeft,s=a.top+e.clientTop;r.layer.style.cssText=[`position:absolute`,`left:${o-i.left-t.clientLeft+t.scrollLeft}px`,`top:${s-i.top-t.clientTop+t.scrollTop}px`,`width:${e.clientWidth}px`,`height:${e.clientHeight}px`,`overflow:hidden`,`pointer-events:none`,`z-index:${re}`].join(`;`);let c=[],l=[],u=0;for(let e of n){let t=e.getBoundingClientRect(),n=e.cloneNode(!0);xe(n),n.setAttribute(x,`live`);let r=n.style;r.position=`absolute`,r.left=`0px`,r.top=`${t.top-s}px`,r.width=`${t.width}px`,r.minWidth=`${t.width}px`,r.height=`${t.height}px`,r.transform=``,r.transition=``,r.visibility=``,r.willChange=``,r.zIndex=``,u=Math.max(u,t.width),(n.classList.contains(ce)?l:c).push(n)}let d=null;for(let e of l)e.style.zIndex=`1`,d===null&&(d=document.createElement(`span`),d.className=ae,e.insertBefore(d,e.firstChild));return r.column.replaceChildren(...c,...l),r.column.style.width=`${u}px`,r.badge=d,r.badgeKind=null,r.layerWidth=e.clientWidth,r.columnWidth=u,r.scrollTop=e.scrollTop,r.cellCount=n.length,r},Ce=e=>{let t=d?.scrollContainerRef.current??null,n=t?.parentElement??null;return!t||!n?null:e.length===0||B!==null&&B.scrollTop===t.scrollTop&&B.cellCount===e.length?B:Se(t,n,e)},we=e=>{if(d===null)return!1;let t=d.leftPaneScrollRef.current;if(t&&d.paneLayout.left.entries.length>0&&e<t.getBoundingClientRect().right-.5)return!0;let n=d.rightPaneScrollRef.current;return!!(n&&d.paneLayout.right.entries.length>0&&e>n.getBoundingClientRect().left+.5)},Te=(e,t,n)=>{let r=e.guide,i=t===null?null:W()[t];if(!i||i.style.display!==`block`){r.style.display=`none`;return}let a=i.getBoundingClientRect();if(t===`center`&&we(a.left+a.width/2)){r.style.display=`none`;return}r.style.left=`${a.left-n.left}px`,r.style.top=`${a.top-n.top}px`,r.style.height=`${a.height}px`,r.style.display=`block`},Ee=(e,t)=>{let n=e.layer.getBoundingClientRect(),r=Math.max(e.layerWidth-e.columnWidth,0),i=Math.min(Math.max(E.x-V-n.left,0),r);e.column.style.transition=`none`,e.column.style.transform=`translateX(${i}px)`;let a=t===null?`none`:t===`center`?`move`:`pin`;e.badge!==null&&e.badgeKind!==a&&(e.badgeKind=a,e.badge.innerHTML=a===`none`?``:a===`move`?f(oe):p(oe),e.badge.style.display=a===`none`?`none`:``),Te(e,t,n)},Y=()=>{B?.layer.remove(),B=null},De=(e,t,n)=>{let r=e.layer.getBoundingClientRect();e.column.style.transition=`transform ${n}ms ${y}`,e.column.style.transform=`translateX(${t-r.left}px)`,e.badge?.remove(),e.guide.style.display=`none`},X=()=>{let e=H;if(H=null,e!==null){e.timer!==null&&window.clearTimeout(e.timer);for(let[t,n]of e.hiddenCells)t.style.visibility=n;e.float.layer.remove()}},Oe=()=>{let e=H;if(e===null||e.key===null)return;let t=e.key;if(e.pane!==null&&!d?.paneLayout[e.pane].entries.some(e=>e.column.key===t))return;e.key=null;let n=d?.scrollContainerRef.current??null,r=n?S(n).filter(e=>e.dataset.ssgColKey===t):[];if(r.length===0){X();return}let i=r[0].getBoundingClientRect().left;for(let t of r)e.hiddenCells.push([t,t.style.visibility]),t.style.visibility=`hidden`;De(e.float,i,ue),e.timer!==null&&window.clearTimeout(e.timer),e.timer=window.setTimeout(X,220)},Z=()=>{let e=ve(E.x,E.y);if(he()){e&&(w={pane:e.pane,slot:e.slot});let t=w;if(t!==null&&t.pane!==I){if(e&&ye(e),(d?.scrollContainerRef.current??null)?.parentElement!=null){let e=Ce(q(null,`lift-out`));if(e!==null){K(),Ee(e,t.pane);return}}Y(),ge(z),_e(t.pane),q(null,`rest`);return}if(K(),G(),q(t===null?null:t.slot,`follow`).length===0&&B!==null){Ee(B,null);return}Y();return}if(_e(e?e.pane:null),!e){w=null,G();return}w={pane:e.pane,slot:e.slot},ye(e)},Q=()=>{if(C===null){j=null;return}let e=d?.scrollContainerRef.current??null;if(e&&(O||(!D||n.hasPointerLeftActivationRadius(D,E,6))&&(O=!0),O)){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(E.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`})}Z(),j=requestAnimationFrame(Q)},$=e=>{j!==null&&(cancelAnimationFrame(j),j=null),document.body.style.cursor=``,G(),K();let n=C,r=w;C=null,A=null,U=null,w=null,D=null;let o=L;L=null,I=null;let s=n!==null&&r!==null&&d!==null?d.paneLayout[r.pane].entries.findIndex(e=>e.column.key===n):-1,c=r!==null&&s>=0&&(r.slot===s||r.slot===s+1),l=e&&n&&r&&d!==null&&!c?i(d.columns,n,r.pane,a(d.columns,d.paneLayout[r.pane],r.pane,r.slot)):null,u=B;if(B=null,o&&!l){o.forEach((e,t)=>{t.isConnected&&(t.style.transition=b,t.style.transform=`translateX(0px)`)});let e=null;if(u!==null){let t=null;for(let e of o.keys())if(e.isConnected&&e.dataset.ssgColKey===n){t=e;break}t===null?u.layer.remove():(De(u,t.getBoundingClientRect().left,te),e={float:u,key:null,pane:null,timer:null,hiddenCells:[]},H=e)}R=o,window.setTimeout(()=>{J(o),R===o&&(R=null),e!==null&&H===e&&X()},200)}else u!==null&&!l&&u.layer.remove();if(!l||!n||!r||d===null)return;let{columns:f,applyColumnOrderAndPin:p,scrollContainerRef:m}=d,h=f.find(e=>e.key===n),g=h?t.getColumnPane(h):null;T=g!==null&&g===r.pane&&!ee(m.current)?fe(m.current):null,o&&J(o),u!==null&&(u.badge?.remove(),u.guide.style.display=`none`,H={float:u,key:n,pane:r.pane,timer:window.setTimeout(X,de),hiddenCells:[]}),p(l,new Map([[n,r.pane===`center`?void 0:r.pane]]))},ke=()=>{Oe();let t=T;if(T=null,!t)return;let n=d?.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)return;n.getBoundingClientRect();for(let e of a)e.style.transition=`transform ${v}ms ${y}`,e.style.transform=`translateX(0)`;Ae();let o=()=>{for(let e of a)e.style.transition=``,e.style.transform=``,e.style.willChange=``},s={run:o,timer:window.setTimeout(()=>{M===s&&(M=null),o()},280)};M=s},Ae=()=>{let e=M;M=null,e!==null&&(window.clearTimeout(e.timer),e.run())};return{update:e=>{d=e},onColumnDragHandlePointerDown:(e,n)=>{if(d===null||!d.enabled||n.button!==0)return;if(n.stopPropagation(),n.preventDefault(),C!==null){if(n.pointerId!==A)return;k?.(),$(!1)}if(Ae(),X(),Y(),R?.forEach((e,t)=>{t.style.visibility=e.visibility}),C=e.key,A=n.pointerId,w=null,U=null,E={x:n.clientX,y:n.clientY},D={x:n.clientX,y:n.clientY},O=!1,document.body.style.cursor=`grabbing`,z=e.title||e.key,he()){let r=d.scrollContainerRef.current;I=t.getColumnPane(e),me=r?.scrollLeft??0,L=new Map;let i=r?S(r).find(t=>t.dataset.ssgColKey===e.key):void 0;V=i?n.clientX-(i.getBoundingClientRect().left-pe(i)):(d.paneLayout[I].entries.find(t=>t.column.key===e.key)?.paneLocalSize??0)/2}else ge(z);let r=n.currentTarget,i=n.pointerId;try{r.setPointerCapture(i)}catch{}let a=e=>{e.pointerId===i&&(E={x:e.clientX,y:e.clientY},Z())},o=()=>{window.removeEventListener(`pointermove`,a),window.removeEventListener(`pointerup`,s),window.removeEventListener(`pointercancel`,c),window.removeEventListener(`keydown`,l),k=null;try{r.releasePointerCapture(i)}catch{}};function s(e){e.pointerId===i&&(o(),$(!0))}function c(e){e.pointerId===i&&(o(),$(!1))}function l(e){e.key===`Escape`&&(o(),$(!1))}window.addEventListener(`pointermove`,a),window.addEventListener(`pointerup`,s),window.addEventListener(`pointercancel`,c),window.addEventListener(`keydown`,l),k=o,Z(),j=requestAnimationFrame(Q)},applyReorderSettle:ke,dispose:()=>{k?.(),k=null,j!==null&&(cancelAnimationFrame(j),j=null),C=null,A=null,w=null,document.body.style.cursor=``,K(),L&&J(L),L=null,I=null,Y(),X()}}};exports.computeHeaderReorderedKeys=i,exports.createColumnHeaderDragController=C,exports.resolveConsumerDropSlot=a;
|
|
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]}function a(n,r,i,a){let o=n.filter(e=>t.getColumnPane(e)===i&&e.visible!==!1).map(e=>e.key),{entries:s}=r;for(let t=Math.max(a,0);t<s.length;t+=1){let n=s[t].column.key;if(e.isSyntheticColumnKey(n))continue;let r=o.indexOf(n);return r<0?o.length:r}return o.length}var o=t=>{let n=0;for(;n<t.entries.length&&e.isSyntheticColumnKey(t.entries[n].column.key);)n+=1;return n},s=32,c=2,l=14,u=12,d=14,f=e=>`<svg viewBox="0 0 24 24" width="`+e+`" height="`+e+`" 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>`,p=e=>`<svg viewBox="0 0 24 24" width="`+e+`" height="`+e+`" 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>`,m=f(d),h=p(d),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)`,ee=e=>e?.closest(`.ssg-motion-off`)!=null,te=160,b=`transform ${te}ms ${y}`,x=`data-ssg-col-dragging`,ne=`4`,re=`9`,ie=`ssg-col-drag-float`,ae=`ssg-col-drag-pin`,oe=12,se=`ssg-col-drop-indicator`,ce=`ssg-header-cell`,le=[`data-ssg-col-key`,`data-ssg-tooltip`,`data-autoheight-cell`,`id`,`tabindex`],ue=180,de=400,S=t=>{let n=[];return t.querySelectorAll(`[data-ssg-col-key]`).forEach(r=>{e.isInsideDetailCardOf(t,r)||n.push(r)}),n},fe=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},pe=e=>{let t=getComputedStyle(e).transform,n=/^matrix(3d)?\(([^)]*)\)$/.exec(t);if(n===null)return 0;let r=Number(n[2].split(`,`)[n[1]===`3d`?12:4]);return Number.isFinite(r)?r:0},C=()=>{let d=null,C=null,w=null,T=null,E={x:0,y:0},D=null,O=!1,k=null,A=null,j=null,M=null,N=null,P=null,F=null,I=null,me=0,L=null,R=null,z=``,B=null,V=0,H=null,U=null,he=()=>d?.motion===`live`,W=()=>({left:d?.leftIndicatorRef.current??null,center:d?.centerIndicatorRef.current??null,right:d?.rightIndicatorRef.current??null}),G=()=>{for(let e of Object.values(W()))e&&(e.style.display=`none`)},ge=e=>{if(N)return;let t=document.createElement(`div`);t.setAttribute(`data-grid-drag-ghost`,``),d?.scrollContainerRef.current?.closest(`.ssg-theme-dark`)!=null&&t.classList.add(`ssg-theme-dark`),d?.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,d?.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),N=t,P=n,F=null},_e=e=>{let t=N;if(!t)return;t.style.transform=`translate(`+(E.x+l)+`px,`+(E.y+u)+`px)`;let n=e??`out`;if(F===n)return;F=n;let r=P;n===`out`?(t.style.opacity=_,r&&(r.innerHTML=g)):(t.style.opacity=`1`,r&&(r.innerHTML=n===`center`?m:h))},K=()=>{N&&N.parentNode&&N.parentNode.removeChild(N),N=null,P=null,F=null},ve=(e,n)=>{if(d===null)return null;let{paneLayout:r,leftPaneScrollRef:i,rightPaneScrollRef:a,bodyScrollRef:l,scrollContainerRef:u,leftLeadingWidth:f,centerLeadingWidth:p,rightLeadingWidth:m}=d,h=u.current;if(h){let t=h.getBoundingClientRect();if(e<t.left||e>t.right||n<t.top||n>t.bottom)return null}let g=i.current,_=a.current;if(g&&r.left.entries.length===0&&e<=g.getBoundingClientRect().left+s)return{pane:`left`,slot:0,leftPx:c};if(g&&r.left.entries.length>0){let n=g.getBoundingClientRect();if(e<n.right){let i=e-n.left-f,a=Math.max(t.findPaneDropSlot(r.left,i),o(r.left));return{pane:`left`,slot:a,leftPx:f+t.paneDropSlotBoundaryX(r.left,a)}}}if(_&&r.right.entries.length===0&&e>=_.getBoundingClientRect().left-s)return{pane:`right`,slot:0,leftPx:-2};if(_&&r.right.entries.length>0){let n=_.getBoundingClientRect();if(e>=n.left){let i=e-n.left-m,a=Math.max(t.findPaneDropSlot(r.right,i),o(r.right));return{pane:`right`,slot:a,leftPx:m+t.paneDropSlotBoundaryX(r.right,a)}}}let v=l.current;if(v&&r.center.entries.length>0){let n=v.getBoundingClientRect(),i=v.scrollLeft+e-n.left-p,a=Math.max(t.findPaneDropSlot(r.center,Math.max(i,0)),o(r.center));return{pane:`center`,slot:a,leftPx:p+t.paneDropSlotBoundaryX(r.center,a)}}return null},ye=e=>{let t=W();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`)}},be=(e,t)=>{let n=R?.get(t);n!==void 0&&R?.delete(t),e.set(t,n??{zIndex:t.style.zIndex,visibility:t.style.visibility})},q=(e,t)=>{let n=[],r=L,i=C,a=I;if(!r||i===null||a===null||d===null)return n;let o=d.scrollContainerRef.current;if(!o)return n;let s=d.paneLayout[a].entries,c=s.findIndex(e=>e.column.key===i);if(c<0)return n;let l=s[c].paneLocalSize,u=t===`lift-out`?s.length-1:t===`rest`||e===null?c:e>c?e-1:e,f=new Map;for(let e=Math.min(c,u);e<=Math.max(c,u);e+=1)e!==c&&f.set(s[e].column.key,e>c?-l:l);let p=a===`center`?o.scrollLeft-me:0,m=(D?E.x-D.x:0)+p,h=U,g=new WeakSet;U=g;for(let e of S(o)){let a=e.dataset.ssgColKey;if(a===void 0)continue;g.add(e);let o=h!==null&&!h.has(e)?`none`:b;if(a===i){n.push(e),r.has(e)||(be(r,e),e.style.zIndex=ne,e.style.willChange=`transform`);let i=r.get(e);t===`follow`?(e.style.visibility=i?.visibility??``,e.setAttribute(x,`live`),e.style.transition=`none`,e.style.transform=`translateX(${m}px)`):t===`lift-out`?(e.style.visibility=`hidden`,e.removeAttribute(x),e.style.transition=`none`,e.style.transform=`translateX(0px)`):(e.style.visibility=i?.visibility??``,e.removeAttribute(x),e.style.transition=o,e.style.transform=`translateX(0px)`);continue}let s=f.get(a)??0;if(s===0&&!r.has(e))continue;r.has(e)||be(r,e);let c=`translateX(${s}px)`;e.style.transform!==c&&(e.style.transition=o,e.style.transform=c)}return n},J=e=>{e.forEach((e,t)=>{t.style.transition=``,t.style.transform=``,t.style.willChange=``,t.style.zIndex=e.zIndex,t.style.visibility=e.visibility,t.removeAttribute(x)})},xe=e=>{let t=e=>{for(let t of le)e.removeAttribute(t)};t(e),e.querySelectorAll(`*`).forEach(t),e.querySelectorAll(`.ssg-header-actions`).forEach(e=>e.remove())},Se=(e,t,n)=>{let r=B;if(r===null){let e=document.createElement(`div`);e.className=ie,e.setAttribute(`aria-hidden`,`true`),e.setAttribute(`inert`,``);let n=document.createElement(`div`);n.style.cssText=`position:absolute;top:0;left:0;height:100%;will-change:transform`;let i=document.createElement(`div`);i.className=se,i.style.cssText=`position:absolute;display:none`,e.append(n,i),t.appendChild(e),r={layer:e,column:n,guide:i,badge:null,badgeKind:null,layerWidth:0,columnWidth:0,scrollTop:0,cellCount:0},B=r}let i=t.getBoundingClientRect(),a=e.getBoundingClientRect(),o=a.left+e.clientLeft,s=a.top+e.clientTop;r.layer.style.cssText=[`position:absolute`,`left:${o-i.left-t.clientLeft+t.scrollLeft}px`,`top:${s-i.top-t.clientTop+t.scrollTop}px`,`width:${e.clientWidth}px`,`height:${e.clientHeight}px`,`overflow:hidden`,`pointer-events:none`,`z-index:${re}`].join(`;`);let c=[],l=[],u=0;for(let e of n){let t=e.getBoundingClientRect(),n=e.cloneNode(!0);xe(n),n.setAttribute(x,`live`);let r=n.style;r.position=`absolute`,r.left=`0px`,r.top=`${t.top-s}px`,r.width=`${t.width}px`,r.minWidth=`${t.width}px`,r.height=`${t.height}px`,r.transform=``,r.transition=``,r.visibility=``,r.willChange=``,r.zIndex=``,u=Math.max(u,t.width),(n.classList.contains(ce)?l:c).push(n)}let d=null;for(let e of l)e.style.zIndex=`1`,d===null&&(d=document.createElement(`span`),d.className=ae,e.insertBefore(d,e.firstChild));return r.column.replaceChildren(...c,...l),r.column.style.width=`${u}px`,r.badge=d,r.badgeKind=null,r.layerWidth=e.clientWidth,r.columnWidth=u,r.scrollTop=e.scrollTop,r.cellCount=n.length,r},Ce=e=>{let t=d?.scrollContainerRef.current??null,n=t?.parentElement??null;return!t||!n?null:e.length===0||B!==null&&B.scrollTop===t.scrollTop&&B.cellCount===e.length?B:Se(t,n,e)},we=e=>{if(d===null)return!1;let t=d.leftPaneScrollRef.current;if(t&&d.paneLayout.left.entries.length>0&&e<t.getBoundingClientRect().right-.5)return!0;let n=d.rightPaneScrollRef.current;return!!(n&&d.paneLayout.right.entries.length>0&&e>n.getBoundingClientRect().left+.5)},Te=(e,t,n)=>{let r=e.guide,i=t===null?null:W()[t];if(!i||i.style.display!==`block`){r.style.display=`none`;return}let a=i.getBoundingClientRect();if(t===`center`&&we(a.left+a.width/2)){r.style.display=`none`;return}r.style.left=`${a.left-n.left}px`,r.style.top=`${a.top-n.top}px`,r.style.height=`${a.height}px`,r.style.display=`block`},Ee=(e,t)=>{let n=e.layer.getBoundingClientRect(),r=Math.max(e.layerWidth-e.columnWidth,0),i=Math.min(Math.max(E.x-V-n.left,0),r);e.column.style.transition=`none`,e.column.style.transform=`translateX(${i}px)`;let a=t===null?`none`:t===`center`?`move`:`pin`;e.badge!==null&&e.badgeKind!==a&&(e.badgeKind=a,e.badge.innerHTML=a===`none`?``:a===`move`?f(oe):p(oe),e.badge.style.display=a===`none`?`none`:``),Te(e,t,n)},Y=()=>{B?.layer.remove(),B=null},De=(e,t,n)=>{let r=e.layer.getBoundingClientRect();e.column.style.transition=`transform ${n}ms ${y}`,e.column.style.transform=`translateX(${t-r.left}px)`,e.badge?.remove(),e.guide.style.display=`none`},X=()=>{let e=H;if(H=null,e!==null){e.timer!==null&&window.clearTimeout(e.timer);for(let[t,n]of e.hiddenCells)t.style.visibility=n;e.float.layer.remove()}},Oe=()=>{let e=H;if(e===null||e.key===null)return;let t=e.key;if(e.pane!==null&&!d?.paneLayout[e.pane].entries.some(e=>e.column.key===t))return;e.key=null;let n=d?.scrollContainerRef.current??null,r=n?S(n).filter(e=>e.dataset.ssgColKey===t):[];if(r.length===0){X();return}let i=r[0].getBoundingClientRect().left;for(let t of r)e.hiddenCells.push([t,t.style.visibility]),t.style.visibility=`hidden`;De(e.float,i,ue),e.timer!==null&&window.clearTimeout(e.timer),e.timer=window.setTimeout(X,220)},Z=()=>{let e=ve(E.x,E.y);if(he()){e&&(w={pane:e.pane,slot:e.slot});let t=w;if(t!==null&&t.pane!==I){if(e&&ye(e),(d?.scrollContainerRef.current??null)?.parentElement!=null){let e=Ce(q(null,`lift-out`));if(e!==null){K(),Ee(e,t.pane);return}}Y(),ge(z),_e(t.pane),q(null,`rest`);return}if(K(),G(),q(t===null?null:t.slot,`follow`).length===0&&B!==null){Ee(B,null);return}Y();return}if(_e(e?e.pane:null),!e){w=null,G();return}w={pane:e.pane,slot:e.slot},ye(e)},Q=()=>{if(C===null){j=null;return}let e=d?.scrollContainerRef.current??null;if(e&&(O||(!D||n.hasPointerLeftActivationRadius(D,E,6))&&(O=!0),O)){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(E.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`})}Z(),j=requestAnimationFrame(Q)},$=e=>{j!==null&&(cancelAnimationFrame(j),j=null),document.body.style.cursor=``,G(),K();let n=C,r=w;C=null,A=null,U=null,w=null,D=null;let o=L;L=null,I=null;let s=n!==null&&r!==null&&d!==null?d.paneLayout[r.pane].entries.findIndex(e=>e.column.key===n):-1,c=r!==null&&s>=0&&(r.slot===s||r.slot===s+1),l=e&&n&&r&&d!==null&&!c?i(d.columns,n,r.pane,a(d.columns,d.paneLayout[r.pane],r.pane,r.slot)):null,u=B;if(B=null,o&&!l){o.forEach((e,t)=>{t.isConnected&&(t.style.transition=b,t.style.transform=`translateX(0px)`)});let e=null;if(u!==null){let t=null;for(let e of o.keys())if(e.isConnected&&e.dataset.ssgColKey===n){t=e;break}t===null?u.layer.remove():(De(u,t.getBoundingClientRect().left,te),e={float:u,key:null,pane:null,timer:null,hiddenCells:[]},H=e)}R=o,window.setTimeout(()=>{J(o),R===o&&(R=null),e!==null&&H===e&&X()},200)}else u!==null&&!l&&u.layer.remove();if(!l||!n||!r||d===null)return;let{columns:f,applyColumnOrderAndPin:p,scrollContainerRef:m}=d,h=f.find(e=>e.key===n),g=h?t.getColumnPane(h):null;T=g!==null&&g===r.pane&&!ee(m.current)?fe(m.current):null,o&&J(o),u!==null&&(u.badge?.remove(),u.guide.style.display=`none`,H={float:u,key:n,pane:r.pane,timer:window.setTimeout(X,de),hiddenCells:[]}),p(l,new Map([[n,r.pane===`center`?void 0:r.pane]]))},ke=()=>{Oe();let t=T;if(T=null,!t)return;let n=d?.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)return;n.getBoundingClientRect();for(let e of a)e.style.transition=`transform ${v}ms ${y}`,e.style.transform=`translateX(0)`;Ae();let o=()=>{for(let e of a)e.style.transition=``,e.style.transform=``,e.style.willChange=``},s={run:o,timer:window.setTimeout(()=>{M===s&&(M=null),o()},280)};M=s},Ae=()=>{let e=M;M=null,e!==null&&(window.clearTimeout(e.timer),e.run())};return{update:e=>{d=e},onColumnDragHandlePointerDown:(e,n)=>{if(d===null||!d.enabled||n.button!==0)return;if(n.stopPropagation(),n.preventDefault(),C!==null){if(n.pointerId!==A)return;k?.(),$(!1)}if(Ae(),X(),Y(),R?.forEach((e,t)=>{t.style.visibility=e.visibility}),C=e.key,A=n.pointerId,w=null,U=null,E={x:n.clientX,y:n.clientY},D={x:n.clientX,y:n.clientY},O=!1,document.body.style.cursor=`grabbing`,z=e.title||e.key,he()){let r=d.scrollContainerRef.current;I=t.getColumnPane(e),me=r?.scrollLeft??0,L=new Map;let i=r?S(r).find(t=>t.dataset.ssgColKey===e.key):void 0;V=i?n.clientX-(i.getBoundingClientRect().left-pe(i)):(d.paneLayout[I].entries.find(t=>t.column.key===e.key)?.paneLocalSize??0)/2}else ge(z);let r=n.currentTarget,i=n.pointerId;try{r.setPointerCapture(i)}catch{}let a=e=>{e.pointerId===i&&(E={x:e.clientX,y:e.clientY},Z())},o=()=>{window.removeEventListener(`pointermove`,a),window.removeEventListener(`pointerup`,s),window.removeEventListener(`pointercancel`,c),window.removeEventListener(`keydown`,l),window.removeEventListener(`blur`,u),k=null;try{r.releasePointerCapture(i)}catch{}};function s(e){e.pointerId===i&&(o(),$(!0))}function c(e){e.pointerId===i&&(o(),$(!1))}function l(e){e.key===`Escape`&&(o(),$(!1))}function u(){o(),$(!1)}window.addEventListener(`pointermove`,a),window.addEventListener(`pointerup`,s),window.addEventListener(`pointercancel`,c),window.addEventListener(`keydown`,l),window.addEventListener(`blur`,u),k=o,Z(),j=requestAnimationFrame(Q)},applyReorderSettle:ke,dispose:()=>{k?.(),k=null,j!==null&&(cancelAnimationFrame(j),j=null),C=null,A=null,w=null,document.body.style.cursor=``,K(),L&&J(L),L=null,I=null,Y(),X()}}};exports.computeHeaderReorderedKeys=i,exports.createColumnHeaderDragController=C,exports.resolveConsumerDropSlot=a;
|
|
@@ -477,7 +477,7 @@ var f = (e) => {
|
|
|
477
477
|
y: e.clientY
|
|
478
478
|
}, Z());
|
|
479
479
|
}, s = () => {
|
|
480
|
-
window.removeEventListener("pointermove", o), window.removeEventListener("pointerup", c), window.removeEventListener("pointercancel", l), window.removeEventListener("keydown", u), A = null;
|
|
480
|
+
window.removeEventListener("pointermove", o), window.removeEventListener("pointerup", c), window.removeEventListener("pointercancel", l), window.removeEventListener("keydown", u), window.removeEventListener("blur", d), A = null;
|
|
481
481
|
try {
|
|
482
482
|
i.releasePointerCapture(a);
|
|
483
483
|
} catch {}
|
|
@@ -491,7 +491,10 @@ var f = (e) => {
|
|
|
491
491
|
function u(e) {
|
|
492
492
|
e.key === "Escape" && (s(), Q(!1));
|
|
493
493
|
}
|
|
494
|
-
|
|
494
|
+
function d() {
|
|
495
|
+
s(), Q(!1);
|
|
496
|
+
}
|
|
497
|
+
window.addEventListener("pointermove", o), window.addEventListener("pointerup", c), window.addEventListener("pointercancel", l), window.addEventListener("keydown", u), window.addEventListener("blur", d), A = s, Z(), M = requestAnimationFrame(Pe);
|
|
495
498
|
},
|
|
496
499
|
applyReorderSettle: Fe,
|
|
497
500
|
dispose: () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../utils/permissions.cjs"),t=require("../logic/detailRow.cjs"),n=require("../model/gridActions.cjs"),r=require("../logic/geometry.cjs"),i=require("../logic/editorValues.cjs"),a=require("../logic/validation.cjs");var o=(e,t)=>t.activeCell!==e.activeCell||t.selection!==e.selection,s=e=>{if(t.isFocusInsideDetailCard())return!1;let n=e.ownerDocument,r=n.activeElement;return r===null||r===n.body||r===n.documentElement||e.contains(r)},c=()=>{let t=null,c=null,l=(e,t)=>{let n=e.visibleColumns[t.col];return!n||t.row<0||t.row>=e.rowModel.getRowCount()||e.rowModel.getRow(t.row)===void 0?null:{rowKey:e.rowModel.getRowKey(t.row),columnKey:n.key}},u=(e,t)=>{let n=e.visibleColumns.findIndex(e=>e.key===t.columnKey);if(n<0)return null;let r=e.rowModel.getRowCount();for(let i=0;i<r;i+=1)if(e.rowModel.getRow(i)!==void 0&&Object.is(e.rowModel.getRowKey(i),t.rowKey))return{row:i,col:n};return null},d=e=>{t=e;let r=e.uiState.editingCell;if(!r){c=null;return}let i=l(e,r);if(c!==null&&i!==null&&Object.is(i.rowKey,c.rowKey)&&i.columnKey===c.columnKey){c={...c,cell:r};return}let a=c!==null&&c.cell.row===r.row&&c.cell.col===r.col;if(c===null||!a){c=i?{...i,cell:r}:null;return}let o=u(e,c);o?(c={...c,cell:o},e.dispatch(n.gridActions.startEdit(o))):(c=null,e.dispatch(n.gridActions.stopEdit()))},f=e=>{t!==null&&(t.dispatch(n.gridActions.startSelection(e)),t.dispatch(n.gridActions.endSelection()),t.dispatch(n.gridActions.activateCell(e)))},p=(e,r)=>{t!==null&&(t.setEditorInitialValue(r),t.dispatch(n.gridActions.startEdit(e)))},m=(e,n=null)=>{let i=t;i!==null&&requestAnimationFrame(()=>{let a=i.gridRootRef.current;if(a!==null&&s(a)&&a.focus(),e!==null&&t!==null&&!(n!==null&&o(n,t.uiState))){let n=t.rowModel.getRowCount(),i=t.visibleColumns.length;f({row:r.clamp(e.row,0,Math.max(n-1,0)),col:r.clamp(e.col,0,Math.max(i-1,0))})}i.editorActionGuardRef.current=!1})};return{update:d,activateSingleCell:f,startEditWithValue:p,commitEdit:(r,o)=>{if(t===null)return{status:`noop`};let{uiState:s,visibleColumns:c,rowModel:l,rows:u,applyServerSideCellEdits:d,onRowsChange:f,dispatch:p,editorActionGuardRef:h}=t;if(h.current||!s.editingCell)return{status:`noop`};let g=s.editingCell,_=o===`down`?{row:g.row+1,col:g.col}:o===`up`?{row:g.row-1,col:g.col}:o===`right`?{row:g.row,col:g.col+1}:o===`left`?{row:g.row,col:g.col-1}:g,v=c[g.col],y=l.getSourceIndex(g.row),b=d?l.getRow(g.row):u[y];if(!v||!b)return p(n.gridActions.stopEdit()),{status:`noop`};if(!e.
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../utils/permissions.cjs"),t=require("../logic/detailRow.cjs"),n=require("../model/gridActions.cjs"),r=require("../logic/geometry.cjs"),i=require("../logic/editorValues.cjs"),a=require("../logic/validation.cjs");var o=(e,t)=>t.activeCell!==e.activeCell||t.selection!==e.selection,s=e=>{if(t.isFocusInsideDetailCard())return!1;let n=e.ownerDocument,r=n.activeElement;return r===null||r===n.body||r===n.documentElement||e.contains(r)},c=()=>{let t=null,c=null,l=(e,t)=>{let n=e.visibleColumns[t.col];return!n||t.row<0||t.row>=e.rowModel.getRowCount()||e.rowModel.getRow(t.row)===void 0?null:{rowKey:e.rowModel.getRowKey(t.row),columnKey:n.key}},u=(e,t)=>{let n=e.visibleColumns.findIndex(e=>e.key===t.columnKey);if(n<0)return null;let r=e.rowModel.getRowCount();for(let i=0;i<r;i+=1)if(e.rowModel.getRow(i)!==void 0&&Object.is(e.rowModel.getRowKey(i),t.rowKey))return{row:i,col:n};return null},d=e=>{t=e;let r=e.uiState.editingCell;if(!r){c=null;return}let i=l(e,r);if(c!==null&&i!==null&&Object.is(i.rowKey,c.rowKey)&&i.columnKey===c.columnKey){c={...c,cell:r};return}let a=c!==null&&c.cell.row===r.row&&c.cell.col===r.col;if(c===null||!a){c=i?{...i,cell:r}:null;return}let o=u(e,c);o?(c={...c,cell:o},e.dispatch(n.gridActions.startEdit(o))):(c=null,e.dispatch(n.gridActions.stopEdit()))},f=e=>{t!==null&&(t.dispatch(n.gridActions.startSelection(e)),t.dispatch(n.gridActions.endSelection()),t.dispatch(n.gridActions.activateCell(e)))},p=(e,r)=>{t!==null&&(t.setEditorInitialValue(r),t.dispatch(n.gridActions.startEdit(e)))},m=(e,n=null)=>{let i=t;i!==null&&requestAnimationFrame(()=>{let a=i.gridRootRef.current;if(a!==null&&s(a)&&a.focus(),e!==null&&t!==null&&!(n!==null&&o(n,t.uiState))){let n=t.rowModel.getRowCount(),i=t.visibleColumns.length;f({row:r.clamp(e.row,0,Math.max(n-1,0)),col:r.clamp(e.col,0,Math.max(i-1,0))})}i.editorActionGuardRef.current=!1})};return{update:d,activateSingleCell:f,startEditWithValue:p,commitEdit:(r,o)=>{if(t===null)return{status:`noop`};let{uiState:s,visibleColumns:c,rowModel:l,rows:u,applyServerSideCellEdits:d,onRowsChange:f,dispatch:p,editorActionGuardRef:h}=t;if(h.current||!s.editingCell)return{status:`noop`};let g=s.editingCell,_=o===`down`?{row:g.row+1,col:g.col}:o===`up`?{row:g.row-1,col:g.col}:o===`right`?{row:g.row,col:g.col+1}:o===`left`?{row:g.row,col:g.col-1}:g,v=c[g.col],y=l.getSourceIndex(g.row),b=d?l.getRow(g.row):u[y];if(!v||!b)return p(n.gridActions.stopEdit()),{status:`noop`};if(!e.isViewCellEditable({readOnly:t.readOnly,canEditCell:t.canEditCell},l,g.row,g.col,b,v))return h.current=!0,p(n.gridActions.stopEdit()),m(null),{status:`noop`};if(d){let e=i.parseCommittedValue(v,r,b),t=a.decideCellWrite(v,b,e);if(t.action===`reject`)return{status:`rejected`,message:t.message};d([{viewIndex:g.row,column:v,value:e}])}else if(f){let e=i.parseCommittedValue(v,r,b),t=a.decideCellWrite(v,b,e);if(t.action===`reject`)return{status:`rejected`,message:t.message};f(i.writeRowsCell(u,y,v,e))}return h.current=!0,m(_,o===void 0?{activeCell:s.activeCell,selection:s.selection}:null),p(n.gridActions.stopEdit()),{status:`committed`}},cancelEdit:()=>{t===null||t.editorActionGuardRef.current||(t.editorActionGuardRef.current=!0,t.dispatch(n.gridActions.stopEdit()),m(null))}}};exports.createEditController=c;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isViewCellEditable as e } from "../utils/permissions.js";
|
|
2
2
|
import { isFocusInsideDetailCard as t } from "../logic/detailRow.js";
|
|
3
3
|
import { gridActions as n } from "../model/gridActions.js";
|
|
4
4
|
import { clamp as r } from "../logic/geometry.js";
|
|
@@ -96,7 +96,7 @@ var s = (e, t) => t.activeCell !== e.activeCell || t.selection !== e.selection,
|
|
|
96
96
|
if (!e({
|
|
97
97
|
readOnly: t.readOnly,
|
|
98
98
|
canEditCell: t.canEditCell
|
|
99
|
-
}, _.row, _.col, x, y)) return g.current = !0, m(n.stopEdit()), h(null), { status: "noop" };
|
|
99
|
+
}, u, _.row, _.col, x, y)) return g.current = !0, m(n.stopEdit()), h(null), { status: "noop" };
|
|
100
100
|
if (f) {
|
|
101
101
|
let e = i(y, r, x), t = o(y, x, e);
|
|
102
102
|
if (t.action === "reject") return {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../logic/valueStore.cjs"),t=require("../utils/permissions.cjs"),n=require("../model/gridActions.cjs"),r=require("../logic/autoScrollGeometry.cjs"),i=require("./popoverSupport.cjs"),a=require("../logic/fillHandle.cjs");var o=168,s=84,c=8,l={status:`idle`},u=(e,t,n)=>{if(e.valueFormatter)try{return e.valueFormatter({value:n,row:t,column:e})}catch{return String(n??``)}return String(n??``)},d=(e,t)=>e===t||e.length===t.length&&e.every((e,n)=>e.key===t[n].key),f=500,p=6,m=2,h=e=>{let t=e.currentTarget;if(!(t instanceof Element))return!0;let n=t.getBoundingClientRect();return e.clientX>=n.left-m&&e.clientX<=n.right+m&&e.clientY>=n.top-m&&e.clientY<=n.bottom+m},g=(e,t)=>e===t||e!==void 0&&t!==void 0&&e.length===t.length&&e.every((e,n)=>Object.is(e,t[n])),_=(e,t)=>Object.is(e,t)||e instanceof Date&&t instanceof Date&&e.getTime()===t.getTime(),v=(e,t)=>e.length===t.length&&e.every((e,n)=>e.viewIndex===t[n].viewIndex&&e.column.key===t[n].column.key&&_(e.value,t[n].value)),y=()=>{let m=null,_=e.createValueStore(l),y=e.createValueStore(null),b={current:null},x={current:null},S=null,C=null,w=null,T=e=>e?`toggled`:`auto`,E=e=>(n,r,i,a)=>t.isViewCellEditable({readOnly:e.readOnly,canEditCell:e.canEditCell},e.rowModel,n,r,i,a),D=()=>{if(w===null||m===null)return;let e=_.getSnapshot();if(e.status===`dragging`&&e.toggled===w.toggled&&(e.target===w.target||e.target!==null&&w.target!==null&&e.target.direction===w.target.direction&&a.isSameFillRange(e.target.range,w.target.range)))return;let t=null;if(w.target!==null){let e=a.previewFillValue({rowModel:m.rowModel,columns:m.columns,source:w.source,target:w.target,request:T(w.toggled),canWriteCell:E(m),getFillValue:m.getFillValue});t=e&&u(e.column,e.row,e.value)||null}_.setSnapshot({status:`dragging`,source:w.source,target:w.target,toggled:w.toggled,previewText:t})},O=()=>{if(w===null||m===null)return;let e=a.resolveFillColumnBounds(m.columns),t=m.hitTest(w.pointer.x,w.pointer.y);e===null||t===null||(w.target=a.resolveFillTarget(w.source,t,m.rowModel.getRowCount(),e),D())},k=()=>{if(w===null||m===null)return;let e=w;e.rafId=requestAnimationFrame(k);let t=m.scrollContainerRef.current;if(!t)return;if(!e.armed){if(!r.hasPointerLeftActivationRadius(e.origin,e.pointer,6))return;e.armed=!0}let n=t.getBoundingClientRect(),i=r.resolveScrollContentBox({rectLeft:n.left,rectTop:n.top,clientLeft:t.clientLeft,clientTop:t.clientTop,clientWidth:t.clientWidth,clientHeight:t.clientHeight}),a=r.computeNextScrollPosition(t.scrollTop,r.resolveAutoScrollAxisDirection(e.pointer.y,i.top,i.bottom-(m.footerHeight??0),24),18,t.scrollHeight-t.clientHeight),o=r.computeNextScrollPosition(t.scrollLeft,r.resolveAutoScrollAxisDirection(e.pointer.x,i.left,i.right,24),18,t.scrollWidth-t.clientWidth);(a!==t.scrollTop||o!==t.scrollLeft)&&(t.scrollTo({top:a,left:o,behavior:`auto`}),O())},A=(e,t)=>{let n=w;if(n!==null){if(w=null,n.cleanup(),n.rafId!==null&&cancelAnimationFrame(n.rafId),y.setSnapshot(null),_.setSnapshot(l),e&&n.target!==null){C=null,N(n.source,n.target,T(n.toggled),n.activeCell);return}C=e&&t!==void 0&&n.onSquare?{time:t,x:n.origin.x,y:n.origin.y}:null}},j=(e,t)=>{if(m===null)return;let{dispatch:r}=m;r(n.gridActions.startSelection({row:e.startRow,col:e.startCol})),r(n.gridActions.updateSelection({row:e.endRow,col:e.endCol})),r(n.gridActions.endSelection()),r(n.gridActions.activateCell(t??{row:e.startRow,col:e.startCol}))},M=(e,t)=>{let n=[];for(let r=t.startRow;r<=t.endRow;r+=1)n.push(e.getRowKey(r));return n},N=(e,t,n,r)=>{if(m===null||!m.enabled)return;let i=m,o=a.buildFillEdits({rowModel:i.rowModel,columns:i.columns,source:e,target:t,request:n,canWriteCell:E(i),getFillValue:i.getFillValue});if(o.edits.length===0)return;let s=a.unionFillRange(e,t),c=null,l=[],u=null;if(i.isServerSide){if(!i.applyServerSideCellEdits)return;u=M(i.rowModel,s),i.applyServerSideCellEdits(o.edits)}else{if(!i.applyRowsChange)return;let e=a.applyFillEditsToRows(i.rows,i.rowModel,o.edits);if(e===i.rows)return;c=i.rows,l.push(e),i.applyRowsChange(e)}S={source:e,target:t,range:s,previousSource:e,selectionConfirmed:!1,columns:i.columns,viewKey:i.viewKey,request:n,edits:o.edits,baseRows:c,baseRowModel:i.isServerSide?null:i.rowModel,emittedRows:l,rowKeys:u},j(s,r),_.setSnapshot({status:`filled`,range:s,kind:o.kind,seriesAvailable:o.seriesAvailable,menu:null})},P=i.createPopoverWindowBindings({onScroll:e=>{e.target instanceof Node&&b.current?.contains(e.target)||I(!1)},onResize:()=>I(!1),isInside:e=>b.current?.contains(e)===!0||x.current?.contains(e)===!0,onOutsidePointerDown:e=>I(m!==null&&i.isInsideGridRoot(m.gridRootRef,e)),onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),I(!0))}}),F=e=>{let t=_.getSnapshot();t.status!==`filled`||t.menu===e||_.setSnapshot({...t,menu:e})},I=e=>{P.detach(),F(null),e&&m!==null&&i.restoreGridFocus(m.gridRootRef)},L=()=>{let e=typeof document<`u`&&b.current?.contains(document.activeElement)===!0;S=null,P.detach(),_.getSnapshot().status===`filled`&&_.setSnapshot(l),e&&m!==null&&i.restoreGridFocus(m.gridRootRef)},R=e=>{let t=_.getSnapshot();if(t.status!==`filled`)return;if(t.menu!==null){I(!0);return}let n=Math.min(e.left,window.innerWidth-o-c);n=Math.max(c,n);let r=e.bottom+4;r+s>window.innerHeight-c&&(r=Math.max(c,e.top-4-s)),F({top:r,left:n}),P.attach()},z=(e,t)=>{let n=t.rowKeys;if(n===null)return!1;for(let r=0;r<n.length;r+=1)if(e.getRowKey(t.range.startRow+r)!==n[r])return!1;return!0},B=e=>{let n=_.getSnapshot(),r=S;if(I(!0),m===null||r===null||n.status!==`filled`||r.request===e)return;let i=m;if(i.isServerSide){if(!i.applyServerSideCellEdits||!z(i.rowModel,r)){L();return}let t=a.buildFillEdits({rowModel:i.rowModel,columns:r.columns,source:r.source,target:r.target,request:e,canWriteCell:E(i),getFillValue:i.getFillValue});r.request=e,t.edits.length>0&&!v(t.edits,r.edits)&&i.applyServerSideCellEdits(t.edits),r.edits=t.edits,_.setSnapshot({...n,kind:t.kind,menu:null});return}if(!i.amendRowsChange||r.baseRows===null||r.baseRowModel===null){L();return}let o=r.baseRowModel,s=a.buildFillEdits({rowModel:o,columns:r.columns,source:r.source,target:r.target,request:e,canWriteCell:(e,n,r,a)=>t.isViewCellEditable({readOnly:i.readOnly,canEditCell:i.canEditCell},o,e,n,r,a),getFillValue:i.getFillValue});if(r.request=e,!v(s.edits,r.edits)){let e=a.applyFillEditsToRows(r.baseRows,o,s.edits);r.emittedRows.push(e),r.edits=s.edits,i.amendRowsChange(e)}_.setSnapshot({...n,kind:s.kind,menu:null})},V=(e,t)=>{if(e?.type!==`cell`)return!1;let{start:n,end:r}=e.range;return a.isSameFillRange(t,{startRow:Math.min(n.row,r.row),endRow:Math.max(n.row,r.row),startCol:Math.min(n.col,r.col),endCol:Math.max(n.col,r.col)})},H=e=>{let t=S;if(t!==null){if(!e.enabled||e.editing||!d(e.columns,t.columns)||!g(e.viewKey,t.viewKey)){L();return}if(!e.isServerSide&&e.rows!==t.baseRows&&!t.emittedRows.includes(e.rows)){L();return}if(V(e.selection,t.range)){t.selectionConfirmed=!0;return}!t.selectionConfirmed&&V(e.selection,t.previousSource)||L()}},U=e=>{if(m===null||e.button!==0||(e.preventDefault(),w!==null||!m.enabled||m.editing))return;let t=a.resolveFillSource(m.selection,m.activeCell,m.rowModel.getRowCount(),m.columns.length);if(t===null)return;let n=C;C=null;let r=h(e);if(n!==null&&r&&e.timeStamp-n.time<=f&&Math.abs(e.clientX-n.x)<=p&&Math.abs(e.clientY-n.y)<=p){m.gridRootRef.current?.focus({preventScroll:!0}),W();return}L(),m.gridRootRef.current?.focus({preventScroll:!0});let i=e.pointerId,o=e=>{w===null||e.pointerId!==i||(w.pointer={x:e.clientX,y:e.clientY},w.toggled=e.ctrlKey||e.metaKey,y.setSnapshot(w.pointer),O())},s=e=>{w===null||e.pointerId!==i||(w.toggled=e.ctrlKey||e.metaKey,A(!0,e.timeStamp))},c=e=>{e.pointerId===i&&A(!1)},l=e=>{if(w===null)return;if(e.preventDefault(),e.stopPropagation(),e.type===`keydown`&&e.key===`Escape`){A(!1);return}let t=e.ctrlKey||e.metaKey;t!==w.toggled&&(w.toggled=t,D())},u=()=>A(!1);window.addEventListener(`pointermove`,o),window.addEventListener(`pointerup`,s),window.addEventListener(`pointercancel`,c),window.addEventListener(`keydown`,l,!0),window.addEventListener(`keyup`,l,!0),window.addEventListener(`blur`,u);let d={x:e.clientX,y:e.clientY};w={pointerId:i,source:t,activeCell:m.activeCell,origin:d,onSquare:r,pointer:d,toggled:e.ctrlKey||e.metaKey,target:null,armed:!1,rafId:null,cleanup:()=>{window.removeEventListener(`pointermove`,o),window.removeEventListener(`pointerup`,s),window.removeEventListener(`pointercancel`,c),window.removeEventListener(`keydown`,l,!0),window.removeEventListener(`keyup`,l,!0),window.removeEventListener(`blur`,u)}},y.setSnapshot(d),D(),w.rafId=requestAnimationFrame(k)},W=()=>{if(m===null||w!==null||!m.enabled||m.editing)return;let e=a.resolveFillSource(m.selection,m.activeCell,m.rowModel.getRowCount(),m.columns.length);if(e===null)return;let t=a.resolveFillDoubleClickTarget(e,m.rowModel,m.columns);t!==null&&(L(),N(e,t,`auto`,m.activeCell))};return{update:e=>{m=e,w!==null&&(!e.enabled||e.editing)&&A(!1),H(e)},subscribe:_.subscribe,getSnapshot:_.getSnapshot,subscribePointer:y.subscribe,getPointerSnapshot:y.getSnapshot,handlePointerDown:U,handleDoubleClick:W,toggleMenu:R,closeMenu:()=>I(!0),chooseKind:B,menuPanel:b,chipElement:x,dispose:()=>{A(!1),P.detach(),S=null}}};exports.createFillHandleController=y;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { type GridUiAction } from '../model/gridActions.js';
|
|
2
|
+
import type { CellCoord, GridColumn, GridFillKind, GridFillValueParams, GridSelection, RowModel, SpreadsheetGridProps } from '../model/gridTypes.unbound.js';
|
|
3
|
+
import { type FillCellEdit, type FillRange, type FillTarget } from '../logic/fillHandle.js';
|
|
4
|
+
type ReadonlyRef<V> = {
|
|
5
|
+
readonly current: V;
|
|
6
|
+
};
|
|
7
|
+
export type FillMenuLayout = {
|
|
8
|
+
top: number;
|
|
9
|
+
left: number;
|
|
10
|
+
};
|
|
11
|
+
export type FillHandleSnapshot = {
|
|
12
|
+
status: 'idle';
|
|
13
|
+
} | {
|
|
14
|
+
status: 'dragging';
|
|
15
|
+
source: FillRange;
|
|
16
|
+
target: FillTarget | null;
|
|
17
|
+
toggled: boolean;
|
|
18
|
+
previewText: string | null;
|
|
19
|
+
} | {
|
|
20
|
+
status: 'filled';
|
|
21
|
+
range: FillRange;
|
|
22
|
+
kind: GridFillKind;
|
|
23
|
+
seriesAvailable: boolean;
|
|
24
|
+
menu: FillMenuLayout | null;
|
|
25
|
+
};
|
|
26
|
+
export type FillHandleControllerArgs<T> = {
|
|
27
|
+
enabled: boolean;
|
|
28
|
+
isServerSide: boolean;
|
|
29
|
+
rows: readonly T[];
|
|
30
|
+
rowModel: RowModel<T>;
|
|
31
|
+
columns: GridColumn<T>[];
|
|
32
|
+
selection: GridSelection;
|
|
33
|
+
activeCell: CellCoord | null;
|
|
34
|
+
editing: boolean;
|
|
35
|
+
viewKey?: readonly unknown[];
|
|
36
|
+
readOnly: boolean;
|
|
37
|
+
canEditCell: SpreadsheetGridProps<T>['canEditCell'];
|
|
38
|
+
getFillValue?: (params: GridFillValueParams<T>) => unknown;
|
|
39
|
+
dispatch: (action: GridUiAction) => void;
|
|
40
|
+
hitTest: (clientX: number, clientY: number) => CellCoord | null;
|
|
41
|
+
scrollContainerRef: ReadonlyRef<HTMLElement | null>;
|
|
42
|
+
gridRootRef: ReadonlyRef<HTMLElement | null>;
|
|
43
|
+
footerHeight?: number;
|
|
44
|
+
applyRowsChange?: (nextRows: T[]) => void;
|
|
45
|
+
amendRowsChange?: (nextRows: T[]) => void;
|
|
46
|
+
applyServerSideCellEdits?: (edits: FillCellEdit<T>[]) => number;
|
|
47
|
+
};
|
|
48
|
+
export type FillHandlePointerEvent = {
|
|
49
|
+
button: number;
|
|
50
|
+
pointerId: number;
|
|
51
|
+
clientX: number;
|
|
52
|
+
clientY: number;
|
|
53
|
+
ctrlKey: boolean;
|
|
54
|
+
metaKey: boolean;
|
|
55
|
+
timeStamp: number;
|
|
56
|
+
currentTarget?: EventTarget | null;
|
|
57
|
+
preventDefault: () => void;
|
|
58
|
+
stopPropagation?: () => void;
|
|
59
|
+
};
|
|
60
|
+
export type FillHandleController<T> = {
|
|
61
|
+
update: (args: FillHandleControllerArgs<T>) => void;
|
|
62
|
+
subscribe: (listener: () => void) => () => void;
|
|
63
|
+
getSnapshot: () => FillHandleSnapshot;
|
|
64
|
+
subscribePointer: (listener: () => void) => () => void;
|
|
65
|
+
getPointerSnapshot: () => {
|
|
66
|
+
x: number;
|
|
67
|
+
y: number;
|
|
68
|
+
} | null;
|
|
69
|
+
handlePointerDown: (event: FillHandlePointerEvent) => void;
|
|
70
|
+
handleDoubleClick: () => void;
|
|
71
|
+
toggleMenu: (anchor: {
|
|
72
|
+
left: number;
|
|
73
|
+
top: number;
|
|
74
|
+
bottom: number;
|
|
75
|
+
}) => void;
|
|
76
|
+
closeMenu: () => void;
|
|
77
|
+
chooseKind: (kind: GridFillKind) => void;
|
|
78
|
+
menuPanel: {
|
|
79
|
+
current: HTMLDivElement | null;
|
|
80
|
+
};
|
|
81
|
+
chipElement: {
|
|
82
|
+
current: HTMLButtonElement | null;
|
|
83
|
+
};
|
|
84
|
+
dispose: () => void;
|
|
85
|
+
};
|
|
86
|
+
export declare const createFillHandleController: <T>() => FillHandleController<T>;
|
|
87
|
+
export {};
|