@ishibashi0112/spreadsheet-grid-core 0.60.0 → 0.61.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/controllers/changeHighlightController.cjs +1 -1
- package/dist/controllers/changeHighlightController.js +54 -49
- package/dist/controllers/clipboardController.cjs +2 -2
- package/dist/controllers/clipboardController.js +71 -76
- package/dist/controllers/columnHeaderDragController.cjs +1 -1
- package/dist/controllers/columnHeaderDragController.js +74 -70
- package/dist/controllers/editController.cjs +1 -1
- package/dist/controllers/editController.js +90 -84
- package/dist/controllers/findController.cjs +1 -1
- package/dist/controllers/findController.js +71 -71
- package/dist/controllers/imeInputController.cjs +1 -1
- package/dist/controllers/imeInputController.js +68 -65
- package/dist/controllers/rowDragController.cjs +1 -1
- package/dist/controllers/rowDragController.d.ts +2 -0
- package/dist/controllers/rowDragController.js +153 -113
- package/dist/controllers/rowEnterController.cjs +1 -1
- package/dist/controllers/rowEnterController.js +49 -47
- package/dist/controllers/saveStatusController.cjs +1 -1
- package/dist/controllers/saveStatusController.js +54 -47
- package/dist/controllers/serverSideRowModel.cjs +1 -1
- package/dist/controllers/serverSideRowModel.js +42 -20
- package/dist/controllers/tooltipController.cjs +1 -1
- package/dist/controllers/tooltipController.js +38 -21
- package/dist/controllers/viewportSyncController.cjs +1 -1
- package/dist/controllers/viewportSyncController.d.ts +2 -1
- package/dist/controllers/viewportSyncController.js +3 -2
- package/dist/engine/columnLayout.cjs +1 -1
- package/dist/engine/columnLayout.d.ts +1 -0
- package/dist/engine/columnLayout.js +12 -11
- package/dist/engine/exportCommands.cjs +1 -1
- package/dist/engine/exportCommands.js +27 -25
- package/dist/engine/filterPopoverCommands.cjs +1 -1
- package/dist/engine/filterPopoverCommands.js +12 -7
- package/dist/engine/gridApi.cjs +1 -1
- package/dist/engine/gridApi.js +2 -2
- package/dist/logic/conditionalFormat.cjs +1 -1
- package/dist/logic/conditionalFormat.js +2 -2
- package/dist/logic/domGuards.cjs +1 -1
- package/dist/logic/domGuards.d.ts +4 -0
- package/dist/logic/domGuards.js +2 -2
- package/dist/logic/editorValues.cjs +1 -1
- package/dist/logic/editorValues.d.ts +2 -0
- package/dist/logic/editorValues.js +11 -2
- package/dist/logic/fillSeries.cjs +1 -1
- package/dist/logic/fillSeries.js +43 -36
- package/dist/logic/find.cjs +1 -1
- package/dist/logic/find.d.ts +1 -0
- package/dist/logic/find.js +6 -6
- package/dist/logic/gridState.cjs +1 -1
- package/dist/logic/gridState.js +72 -55
- package/dist/logic/selectionAggregates.cjs +1 -1
- package/dist/logic/selectionAggregates.js +5 -2
- package/dist/logic/serverSideEdits.cjs +1 -1
- package/dist/logic/serverSideEdits.d.ts +16 -2
- package/dist/logic/serverSideEdits.js +60 -14
- package/dist/model/gridTypes.core.d.ts +8 -5
- package/dist/utils/clipboard.cjs +5 -5
- package/dist/utils/clipboard.d.ts +3 -0
- package/dist/utils/clipboard.js +58 -65
- package/package.json +1 -6
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@ Docs and live demos: [datasheet-grid.vercel.app](https://datasheet-grid.vercel.a
|
|
|
9
9
|
## What is in here
|
|
10
10
|
|
|
11
11
|
- Public type definitions with JSDoc. The field docs of `SpreadsheetGridProps`, `GridColumn`, `SpreadsheetGridHandle` and the other option types are in `dist/model/gridTypes.core.d.ts`; they match the tables in `API_REFERENCE.md` of the React package.
|
|
12
|
-
- Framework-agnostic modules under `@ishibashi0112/spreadsheet-grid-core/internal/<dir>/<module>` (`model` / `logic` / `controllers` / `engine` / `utils`). They are internal building blocks for the framework adapters (the React package uses them, and depends on the core of exactly the same version), are not covered by `API_REFERENCE.md` or semver, and may change in any release. The old subpaths without `internal/` (`@ishibashi0112/spreadsheet-grid-core/<dir>/<module>`)
|
|
12
|
+
- Framework-agnostic modules under `@ishibashi0112/spreadsheet-grid-core/internal/<dir>/<module>` (`model` / `logic` / `controllers` / `engine` / `utils`). They are internal building blocks for the framework adapters (the React package uses them, and depends on the core of exactly the same version), are not covered by `API_REFERENCE.md` or semver, and may change in any release. The old subpaths without `internal/` (`@ishibashi0112/spreadsheet-grid-core/<dir>/<module>`) were deprecated in 0.60.0 and removed in 0.61.0; import from the entry point `@ishibashi0112/spreadsheet-grid-core` instead. If you use the core directly alongside the React package, install the same version of both (a different version installs a second copy of the core). The public entry points are `@ishibashi0112/spreadsheet-grid-core` and `/testing` ([Versioning](https://datasheet-grid.vercel.app/docs/versioning), Japanese).
|
|
13
13
|
|
|
14
14
|
## License
|
|
15
15
|
|
|
@@ -26,4 +26,4 @@ MIT
|
|
|
26
26
|
ドキュメントとライブデモ: [datasheet-grid.vercel.app](https://datasheet-grid.vercel.app) · 変更履歴: [CHANGELOG.md](https://github.com/ishibashi0112/datasheet-grid/blob/main/CHANGELOG.md)
|
|
27
27
|
|
|
28
28
|
- 公開型の定義(JSDoc 付き)。`SpreadsheetGridProps` / `GridColumn` / `SpreadsheetGridHandle` などのフィールドの説明は `dist/model/gridTypes.core.d.ts` にあり、React 版パッケージ同梱の `API_REFERENCE.md` の表と同じ内容です。
|
|
29
|
-
- `@ishibashi0112/spreadsheet-grid-core/internal/<dir>/<module>`(`model` / `logic` / `controllers` / `engine` / `utils`)のモジュールは、各フレームワーク版(アダプタ)が使う内部の部品です(React 版が使っていて、同じ版の core に固定で依存します)。`API_REFERENCE.md` と semver の対象外で、どの版でも変わることがあります。`internal/` の無い旧サブパス(`@ishibashi0112/spreadsheet-grid-core/<dir>/<module>`)は 0.60.0
|
|
29
|
+
- `@ishibashi0112/spreadsheet-grid-core/internal/<dir>/<module>`(`model` / `logic` / `controllers` / `engine` / `utils`)のモジュールは、各フレームワーク版(アダプタ)が使う内部の部品です(React 版が使っていて、同じ版の core に固定で依存します)。`API_REFERENCE.md` と semver の対象外で、どの版でも変わることがあります。`internal/` の無い旧サブパス(`@ishibashi0112/spreadsheet-grid-core/<dir>/<module>`)は 0.60.0 で非推奨にし、0.61.0 で消しました。代わりに入口 `@ishibashi0112/spreadsheet-grid-core` から import してください。React 版と一緒に core も直接使うときは、両方を同じ版にそろえてください(違う版だと core が 2 つ入ります)。公開の入口は `@ishibashi0112/spreadsheet-grid-core` と `/testing` です([バージョンと互換性](https://datasheet-grid.vercel.app/docs/versioning))。
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../utils/permissions.cjs");var
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../utils/permissions.cjs"),t=require("../logic/detailRow.cjs");var n=`ssg-body-cell--changed`,r=5e3,i=2e3,a=200,o=1500,s=260,c=(e,t,n)=>e.valueFormatter?e.valueFormatter({value:n,row:t,column:e}):String(n??``),l=e=>typeof e==`number`&&Number.isFinite(e),u=(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},d=(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},f=e=>typeof CSS<`u`&&typeof CSS.escape==`function`?CSS.escape(e):e.replace(/["\\]/g,`\\$&`),p=()=>{let e=null,r=new Map,i=new Set,a=new WeakMap,p=e=>{e.classList.remove(n);let t=r.get(e);t!==void 0&&(clearTimeout(t),r.delete(e))},m=e=>{p(e),e.offsetWidth,e.classList.add(n);let t=()=>{e.removeEventListener(`animationend`,t),p(e)};e.addEventListener(`animationend`,t),r.set(e,setTimeout(()=>{e.removeEventListener(`animationend`,t),p(e)},o))},h=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},g=(e,t,n)=>{if(!l(t.prevValue)||!l(t.nextValue)||n<=0||typeof requestAnimationFrame!=`function`)return;let r=h(e);if(!r)return;let o=r.nodeValue??``,s=t.prevValue,u=t.nextValue,d=/\.(\d+)$/.exec(String(u)),f=Math.min(2,d?d[1].length:0),p=performance.now(),m=c(t.column,t.row,s);r.nodeValue=m;let g={};a.set(r,g);let _=e=>{if(i.delete(v),a.get(r)!==g||r.nodeValue!==m)return;let l=Math.min(1,(e-p)/n);if(l>=1||r.parentNode===null){r.nodeValue=o;return}let d=1-(1-l)**3,h=Number((s+(u-s)*d).toFixed(f));m=c(t.column,t.row,h),r.nodeValue=m,v=requestAnimationFrame(_),i.add(v)},v=requestAnimationFrame(_);i.add(v)};return{update:n=>{let{enabled:r,rows:i,rowKeyGetter:o,columns:c,scrollContainerRef:l}=n,p=e;if(e={rows:i,rowKeyGetter:o},!r||p===null||p.rows===i)return;let _=l.current;if(!_)return;let v=d(p.rows,p.rowKeyGetter,i,o,c);if(!v||v.length===0)return;let y=u(getComputedStyle(_).getPropertyValue(`--ssg-motion-base`),s),b=v.length<=200;for(let e of v){let n=`.ssg-body-row[data-row-key="${f(String(e.rowKey))}"] .ssg-body-cell[data-ssg-col-key="${f(String(e.column.key))}"]`;_.querySelectorAll(n).forEach(n=>{if(t.isInsideDetailCardOf(_,n))return;let r=h(n);r&&a.delete(r),m(n),b&&!e.column.renderCell&&g(n,e,y)})}},dispose:()=>{for(let e of Array.from(r.keys()))p(e);if(typeof cancelAnimationFrame==`function`)for(let e of i)cancelAnimationFrame(e);i.clear(),e=null}}};exports.CHANGED_CLASS_NAME=n,exports.CHANGED_FALLBACK_MS=o,exports.MAX_CHANGED_ROWS=r,exports.MAX_FLASH_CELLS=i,exports.MAX_TWEEN_CELLS=a,exports.createChangeHighlightController=p,exports.diffChangedCells=d,exports.parseCssDuration=u;
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { getCellValue as e } from "../utils/permissions.js";
|
|
2
|
+
import { isInsideDetailCardOf as t } from "../logic/detailRow.js";
|
|
2
3
|
//#region src/controllers/changeHighlightController.ts
|
|
3
|
-
var
|
|
4
|
+
var n = "ssg-body-cell--changed", r = 5e3, i = 2e3, a = 200, o = 1500, s = 260, c = (e, t, n) => e.valueFormatter ? e.valueFormatter({
|
|
4
5
|
value: n,
|
|
5
6
|
row: t,
|
|
6
7
|
column: e
|
|
7
|
-
}) : String(n ?? ""),
|
|
8
|
+
}) : String(n ?? ""), l = (e) => typeof e == "number" && Number.isFinite(e), u = (e, t) => {
|
|
8
9
|
if (!e) return t;
|
|
9
10
|
let n = e.trim(), r = /^(-?[\d.]+)\s*(ms|s)$/.exec(n);
|
|
10
11
|
if (!r) return t;
|
|
11
12
|
let i = Number(r[1]);
|
|
12
13
|
return Number.isFinite(i) ? r[2] === "s" ? i * 1e3 : i : t;
|
|
13
|
-
},
|
|
14
|
+
}, d = (t, n, r, i, a) => {
|
|
14
15
|
if (t.length !== r.length) return null;
|
|
15
16
|
let o = [], s = 0;
|
|
16
17
|
for (let c = 0; c < r.length; c += 1) {
|
|
@@ -31,67 +32,71 @@ var t = "ssg-body-cell--changed", n = 5e3, r = 2e3, i = 200, a = 1500, o = 260,
|
|
|
31
32
|
}
|
|
32
33
|
}
|
|
33
34
|
return o;
|
|
34
|
-
},
|
|
35
|
-
let e = null,
|
|
36
|
-
e.classList.remove(
|
|
37
|
-
let
|
|
38
|
-
|
|
39
|
-
},
|
|
40
|
-
|
|
41
|
-
let
|
|
42
|
-
e.removeEventListener("animationend",
|
|
35
|
+
}, f = (e) => typeof CSS < "u" && typeof CSS.escape == "function" ? CSS.escape(e) : e.replace(/["\\]/g, "\\$&"), p = () => {
|
|
36
|
+
let e = null, r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new WeakMap(), p = (e) => {
|
|
37
|
+
e.classList.remove(n);
|
|
38
|
+
let t = r.get(e);
|
|
39
|
+
t !== void 0 && (clearTimeout(t), r.delete(e));
|
|
40
|
+
}, m = (e) => {
|
|
41
|
+
p(e), e.offsetWidth, e.classList.add(n);
|
|
42
|
+
let t = () => {
|
|
43
|
+
e.removeEventListener("animationend", t), p(e);
|
|
43
44
|
};
|
|
44
|
-
e.addEventListener("animationend",
|
|
45
|
-
e.removeEventListener("animationend",
|
|
46
|
-
},
|
|
47
|
-
},
|
|
45
|
+
e.addEventListener("animationend", t), r.set(e, setTimeout(() => {
|
|
46
|
+
e.removeEventListener("animationend", t), p(e);
|
|
47
|
+
}, o));
|
|
48
|
+
}, h = (e) => {
|
|
48
49
|
let t = e.firstElementChild;
|
|
49
50
|
if (!t || t.childNodes.length !== 1) return null;
|
|
50
51
|
let n = t.firstChild;
|
|
51
52
|
return n && n.nodeType === Node.TEXT_NODE ? n : null;
|
|
52
|
-
},
|
|
53
|
-
if (!
|
|
54
|
-
let
|
|
55
|
-
if (!
|
|
56
|
-
let
|
|
57
|
-
|
|
58
|
-
let
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
if (
|
|
62
|
-
|
|
53
|
+
}, g = (e, t, n) => {
|
|
54
|
+
if (!l(t.prevValue) || !l(t.nextValue) || n <= 0 || typeof requestAnimationFrame != "function") return;
|
|
55
|
+
let r = h(e);
|
|
56
|
+
if (!r) return;
|
|
57
|
+
let o = r.nodeValue ?? "", s = t.prevValue, u = t.nextValue, d = /\.(\d+)$/.exec(String(u)), f = Math.min(2, d ? d[1].length : 0), p = performance.now(), m = c(t.column, t.row, s);
|
|
58
|
+
r.nodeValue = m;
|
|
59
|
+
let g = {};
|
|
60
|
+
a.set(r, g);
|
|
61
|
+
let _ = (e) => {
|
|
62
|
+
if (i.delete(v), a.get(r) !== g || r.nodeValue !== m) return;
|
|
63
|
+
let l = Math.min(1, (e - p) / n);
|
|
64
|
+
if (l >= 1 || r.parentNode === null) {
|
|
65
|
+
r.nodeValue = o;
|
|
63
66
|
return;
|
|
64
67
|
}
|
|
65
|
-
let
|
|
66
|
-
|
|
67
|
-
},
|
|
68
|
-
|
|
68
|
+
let d = 1 - (1 - l) ** 3, h = Number((s + (u - s) * d).toFixed(f));
|
|
69
|
+
m = c(t.column, t.row, h), r.nodeValue = m, v = requestAnimationFrame(_), i.add(v);
|
|
70
|
+
}, v = requestAnimationFrame(_);
|
|
71
|
+
i.add(v);
|
|
69
72
|
};
|
|
70
73
|
return {
|
|
71
|
-
update: (
|
|
72
|
-
let { enabled:
|
|
74
|
+
update: (n) => {
|
|
75
|
+
let { enabled: r, rows: i, rowKeyGetter: o, columns: c, scrollContainerRef: l } = n, p = e;
|
|
73
76
|
if (e = {
|
|
74
|
-
rows:
|
|
75
|
-
rowKeyGetter:
|
|
76
|
-
}, !
|
|
77
|
-
let
|
|
78
|
-
if (!
|
|
79
|
-
let
|
|
80
|
-
if (!
|
|
81
|
-
let
|
|
82
|
-
for (let e of
|
|
83
|
-
let
|
|
84
|
-
|
|
85
|
-
|
|
77
|
+
rows: i,
|
|
78
|
+
rowKeyGetter: o
|
|
79
|
+
}, !r || p === null || p.rows === i) return;
|
|
80
|
+
let _ = l.current;
|
|
81
|
+
if (!_) return;
|
|
82
|
+
let v = d(p.rows, p.rowKeyGetter, i, o, c);
|
|
83
|
+
if (!v || v.length === 0) return;
|
|
84
|
+
let y = u(getComputedStyle(_).getPropertyValue("--ssg-motion-base"), s), b = v.length <= 200;
|
|
85
|
+
for (let e of v) {
|
|
86
|
+
let n = `.ssg-body-row[data-row-key="${f(String(e.rowKey))}"] .ssg-body-cell[data-ssg-col-key="${f(String(e.column.key))}"]`;
|
|
87
|
+
_.querySelectorAll(n).forEach((n) => {
|
|
88
|
+
if (t(_, n)) return;
|
|
89
|
+
let r = h(n);
|
|
90
|
+
r && a.delete(r), m(n), b && !e.column.renderCell && g(n, e, y);
|
|
86
91
|
});
|
|
87
92
|
}
|
|
88
93
|
},
|
|
89
94
|
dispose: () => {
|
|
90
|
-
for (let e of Array.from(
|
|
91
|
-
if (typeof cancelAnimationFrame == "function") for (let e of
|
|
92
|
-
|
|
95
|
+
for (let e of Array.from(r.keys())) p(e);
|
|
96
|
+
if (typeof cancelAnimationFrame == "function") for (let e of i) cancelAnimationFrame(e);
|
|
97
|
+
i.clear(), e = null;
|
|
93
98
|
}
|
|
94
99
|
};
|
|
95
100
|
};
|
|
96
101
|
//#endregion
|
|
97
|
-
export {
|
|
102
|
+
export { n as CHANGED_CLASS_NAME, o as CHANGED_FALLBACK_MS, r as MAX_CHANGED_ROWS, i as MAX_FLASH_CELLS, a as MAX_TWEEN_CELLS, p as createChangeHighlightController, d as diffChangedCells, u as parseCssDuration };
|
|
@@ -1,2 +1,2 @@
|
|
|
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=
|
|
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),
|
|
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=e=>{let{rowModel:t}=e,n=i.filterClipboardColumns(e.visibleColumns),r=t.getRowCount();if(r===0||n.length===0)return``;let a=l(e),o=[];for(let e=0;e<r;e+=1){let r=t.getRow(e);r&&(a&&!a(r,e)||o.push(i.joinTsvRow(n.map(e=>i.formatClipboardCell(r,e)))))}return o.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,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=i.resolvePasteColumnIndexes(d,E,w),O=D[D.length-1]??E,k=l.getLabelRow===void 0?null:a.resolvePasteTargetViewIndexes(l,T,C.length),A=e=>k?k[e-T]:e,j=k?k[k.length-1]:f.activeCell.row+Math.max(C.length-1,0);if(b){let r=i.buildClipboardCellEdits(e=>l.getRow(A(e)),d,C,T,E,(t,n,r,i)=>e.isViewCellEditable({readOnly:p,canEditCell:m},l,A(t),n,r,i)).map(e=>({...e,viewIndex:A(e.viewIndex)}));r.length>0&&b(r);let a=n.clamp(j,0,Math.max(l.getRowCount()-1,0)),o=n.clamp(O,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 M=f.activeCell.col,N=[...c],P=[...d],F=l.getRowCount(),I=N.length,L=e=>{let t=A(e);return t<F?l.getSourceIndex(t):I+(t-F)},R=Math.max(j+1-F,0),z=N.length+R;if(z>N.length&&g)for(;N.length<z;)N.push(g());let B=O+1;if(B>P.length&&y&&_){let e=[];for(;P.length<B;){let t=_(P.length);P.push(t),e.push(t)}y(u?[...u,...e]:P)}let V=i.applyClipboardMatrixToRows(N,L,P,C,T,M,(t,n,r,i,a)=>{let o=A(a),s=o<F?l.getRowKey(o):h?.(r,t)??t;return e.isCellEditable({readOnly:p,canEditCell:m},o,n,r,i,{sourceRowIndex:t,rowKey:s??t})}),H=n.clamp(j,0,Math.max(Math.max(l.getRowCount()-1,0),j)),U=n.clamp(O,0,Math.max(Math.max(P.length-1,0),O));v(V),x(t.gridActions.startSelection(f.activeCell)),x(t.gridActions.updateSelection({row:H,col:U})),x(t.gridActions.endSelection()),x(t.gridActions.activateCell(f.activeCell))}}};exports.computeIsWholeGridSelected=o,exports.createClipboardController=s;
|
|
@@ -1,104 +1,99 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { gridActions as
|
|
3
|
-
import { clamp as
|
|
4
|
-
import { shouldIgnoreGridKeydown as
|
|
5
|
-
import { applyClipboardMatrixToRows as
|
|
6
|
-
import { resolvePasteTargetViewIndexes as
|
|
1
|
+
import { isCellEditable as e, isViewCellEditable as t } from "../utils/permissions.js";
|
|
2
|
+
import { gridActions as n } from "../model/gridActions.js";
|
|
3
|
+
import { clamp as r } from "../logic/geometry.js";
|
|
4
|
+
import { shouldIgnoreGridKeydown as i } from "../logic/domGuards.js";
|
|
5
|
+
import { applyClipboardMatrixToRows as a, buildClipboardCellEdits as o, filterClipboardColumns as s, formatClipboardCell as c, joinTsvRow as l, parseClipboardText as u, resolvePasteColumnIndexes as d, serializeSelectionToTsv as f, writeTextToClipboard as p } from "../utils/clipboard.js";
|
|
6
|
+
import { resolvePasteTargetViewIndexes as m } from "../logic/labelRows.js";
|
|
7
7
|
//#region src/controllers/clipboardController.ts
|
|
8
|
-
var
|
|
8
|
+
var h = (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
|
+
}, g = () => {
|
|
13
|
+
let g = null, _ = (e) => {
|
|
14
|
+
g = e;
|
|
15
|
+
}, v = (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
|
-
},
|
|
22
|
-
let { rowModel:
|
|
23
|
-
if (
|
|
24
|
-
let
|
|
25
|
-
for (let
|
|
26
|
-
let
|
|
27
|
-
|
|
28
|
-
let s = r.map((t) => {
|
|
29
|
-
let n = e(i, t);
|
|
30
|
-
return t.formatClipboardValue ? t.formatClipboardValue(n, i) : String(n ?? "");
|
|
31
|
-
});
|
|
32
|
-
o.push(c(s));
|
|
21
|
+
}, y = (e) => {
|
|
22
|
+
let { rowModel: t } = e, n = s(e.visibleColumns), r = t.getRowCount();
|
|
23
|
+
if (r === 0 || n.length === 0) return "";
|
|
24
|
+
let i = v(e), a = [];
|
|
25
|
+
for (let e = 0; e < r; e += 1) {
|
|
26
|
+
let r = t.getRow(e);
|
|
27
|
+
r && (i && !i(r, e) || a.push(l(n.map((e) => c(r, e)))));
|
|
33
28
|
}
|
|
34
|
-
return
|
|
29
|
+
return a.join("\n");
|
|
35
30
|
};
|
|
36
31
|
return {
|
|
37
|
-
update:
|
|
32
|
+
update: _,
|
|
38
33
|
handleCopy: async () => {
|
|
39
|
-
if (
|
|
40
|
-
let e =
|
|
41
|
-
i && await
|
|
34
|
+
if (g === null) return;
|
|
35
|
+
let e = g, { rowModel: t, visibleColumns: n, uiState: r } = e, i = h(r.selection, t.getRowCount(), n.length) ? y(e) : f(t.getRow, t.getRowCount(), n, r.selection, v(e));
|
|
36
|
+
i && await p(i) && r.selection && e.onCopied?.(r.selection);
|
|
42
37
|
},
|
|
43
|
-
handlePaste: (
|
|
44
|
-
if (
|
|
45
|
-
let { rows: c, rowModel:
|
|
46
|
-
if (h.editingCell ||
|
|
47
|
-
let
|
|
48
|
-
if (!
|
|
49
|
-
|
|
50
|
-
let
|
|
51
|
-
if (
|
|
52
|
-
let
|
|
53
|
-
if (
|
|
54
|
-
let
|
|
55
|
-
if (
|
|
56
|
-
let e =
|
|
57
|
-
readOnly:
|
|
58
|
-
canEditCell:
|
|
59
|
-
},
|
|
38
|
+
handlePaste: (s) => {
|
|
39
|
+
if (g === null) return;
|
|
40
|
+
let { rows: c, rowModel: l, columns: f, visibleColumns: p, uiState: h, readOnly: _, canEditCell: v, rowKeyGetter: y, createRow: b, createOverflowColumn: x, onRowsChange: S, onColumnsChange: C, applyServerSideCellEdits: w, dispatch: T } = g;
|
|
41
|
+
if (h.editingCell || i(s.target ?? null) || _ || !S && !w || !h.activeCell) return;
|
|
42
|
+
let E = s.clipboardData?.getData("text/plain") ?? "";
|
|
43
|
+
if (!E) return;
|
|
44
|
+
s.preventDefault();
|
|
45
|
+
let D = u(E);
|
|
46
|
+
if (D.length === 0) return;
|
|
47
|
+
let O = D.reduce((e, t) => Math.max(e, t.length), 0);
|
|
48
|
+
if (O === 0) return;
|
|
49
|
+
let k = h.activeCell.row, A = h.activeCell.col, j = d(p, A, O), M = j[j.length - 1] ?? A, N = l.getLabelRow === void 0 ? null : m(l, k, D.length), P = (e) => N ? N[e - k] : e, F = N ? N[N.length - 1] : h.activeCell.row + Math.max(D.length - 1, 0);
|
|
50
|
+
if (w) {
|
|
51
|
+
let e = o((e) => l.getRow(P(e)), p, D, k, A, (e, n, r, i) => t({
|
|
52
|
+
readOnly: _,
|
|
53
|
+
canEditCell: v
|
|
54
|
+
}, l, P(e), n, r, i)).map((e) => ({
|
|
60
55
|
...e,
|
|
61
|
-
viewIndex:
|
|
56
|
+
viewIndex: P(e.viewIndex)
|
|
62
57
|
}));
|
|
63
|
-
e.length > 0 &&
|
|
64
|
-
let
|
|
65
|
-
|
|
66
|
-
row:
|
|
58
|
+
e.length > 0 && w(e);
|
|
59
|
+
let i = r(F, 0, Math.max(l.getRowCount() - 1, 0)), a = r(M, 0, Math.max(p.length - 1, 0));
|
|
60
|
+
T(n.startSelection(h.activeCell)), T(n.updateSelection({
|
|
61
|
+
row: i,
|
|
67
62
|
col: a
|
|
68
|
-
})),
|
|
63
|
+
})), T(n.endSelection()), T(n.activateCell(h.activeCell));
|
|
69
64
|
return;
|
|
70
65
|
}
|
|
71
|
-
if (!
|
|
72
|
-
let
|
|
73
|
-
let t =
|
|
74
|
-
return t <
|
|
75
|
-
},
|
|
76
|
-
if (
|
|
77
|
-
let
|
|
78
|
-
if (
|
|
66
|
+
if (!S || l.getSourceIndex(k) === void 0) return;
|
|
67
|
+
let I = h.activeCell.col, L = [...c], R = [...p], z = l.getRowCount(), B = L.length, V = (e) => {
|
|
68
|
+
let t = P(e);
|
|
69
|
+
return t < z ? l.getSourceIndex(t) : B + (t - z);
|
|
70
|
+
}, H = Math.max(F + 1 - z, 0), U = L.length + H;
|
|
71
|
+
if (U > L.length && b) for (; L.length < U;) L.push(b());
|
|
72
|
+
let W = M + 1;
|
|
73
|
+
if (W > R.length && C && x) {
|
|
79
74
|
let e = [];
|
|
80
|
-
for (;
|
|
81
|
-
let t =
|
|
82
|
-
|
|
75
|
+
for (; R.length < W;) {
|
|
76
|
+
let t = x(R.length);
|
|
77
|
+
R.push(t), e.push(t);
|
|
83
78
|
}
|
|
84
|
-
|
|
79
|
+
C(f ? [...f, ...e] : R);
|
|
85
80
|
}
|
|
86
|
-
let
|
|
87
|
-
let o =
|
|
88
|
-
return
|
|
89
|
-
readOnly:
|
|
90
|
-
canEditCell:
|
|
81
|
+
let G = a(L, V, R, D, k, I, (t, n, r, i, a) => {
|
|
82
|
+
let o = P(a), s = o < z ? l.getRowKey(o) : y?.(r, t) ?? t;
|
|
83
|
+
return e({
|
|
84
|
+
readOnly: _,
|
|
85
|
+
canEditCell: v
|
|
91
86
|
}, o, n, r, i, {
|
|
92
|
-
sourceRowIndex:
|
|
93
|
-
rowKey: s ??
|
|
87
|
+
sourceRowIndex: t,
|
|
88
|
+
rowKey: s ?? t
|
|
94
89
|
});
|
|
95
|
-
}),
|
|
96
|
-
|
|
97
|
-
row:
|
|
98
|
-
col:
|
|
99
|
-
})),
|
|
90
|
+
}), K = r(F, 0, Math.max(Math.max(l.getRowCount() - 1, 0), F)), q = r(M, 0, Math.max(Math.max(R.length - 1, 0), M));
|
|
91
|
+
S(G), T(n.startSelection(h.activeCell)), T(n.updateSelection({
|
|
92
|
+
row: K,
|
|
93
|
+
col: q
|
|
94
|
+
})), T(n.endSelection()), T(n.activateCell(h.activeCell));
|
|
100
95
|
}
|
|
101
96
|
};
|
|
102
97
|
};
|
|
103
98
|
//#endregion
|
|
104
|
-
export {
|
|
99
|
+
export { h as computeIsWholeGridSelected, g as createClipboardController };
|
|
@@ -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),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;
|
|
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:[]});let _=new Map([[n,r.pane===`center`?void 0:r.pane]]),v=T;p(l,_),v!==null&&requestAnimationFrame(()=>{T===v&&(T=null)})},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;
|