@ishibashi0112/spreadsheet-grid-core 1.7.0 → 1.9.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/activeRowFollowController.cjs +1 -1
- package/dist/controllers/activeRowFollowController.d.ts +1 -0
- package/dist/controllers/activeRowFollowController.js +33 -24
- package/dist/controllers/changeTracker.cjs +1 -0
- package/dist/controllers/changeTracker.d.ts +39 -0
- package/dist/controllers/changeTracker.js +238 -0
- package/dist/controllers/clipboardController.cjs +1 -1
- package/dist/controllers/clipboardController.js +43 -40
- package/dist/controllers/columnAutosizeRunner.cjs +1 -1
- package/dist/controllers/columnAutosizeRunner.d.ts +3 -1
- package/dist/controllers/columnAutosizeRunner.js +12 -11
- package/dist/controllers/findController.cjs +1 -1
- package/dist/controllers/findController.d.ts +3 -1
- package/dist/controllers/findController.js +80 -75
- package/dist/controllers/historyController.cjs +1 -1
- package/dist/controllers/historyController.d.ts +25 -1
- package/dist/controllers/historyController.js +125 -71
- package/dist/controllers/keyboardController.cjs +1 -1
- package/dist/controllers/keyboardController.d.ts +1 -0
- package/dist/controllers/keyboardController.js +4 -0
- package/dist/engine/columnLayout.cjs +1 -1
- package/dist/engine/columnLayout.d.ts +1 -0
- package/dist/engine/columnLayout.js +10 -10
- package/dist/engine/createGridEngine.cjs +1 -1
- package/dist/engine/createGridEngine.d.ts +4 -1
- package/dist/engine/createGridEngine.js +48 -41
- package/dist/engine/exportCommands.cjs +2 -2
- package/dist/engine/exportCommands.js +82 -34
- package/dist/engine/features.cjs +1 -1
- package/dist/engine/features.d.ts +16 -0
- package/dist/engine/features.js +25 -1
- package/dist/engine/fullFeatures.cjs +1 -1
- package/dist/engine/fullFeatures.js +43 -31
- package/dist/engine/gridApi.cjs +9 -7
- package/dist/engine/gridApi.d.ts +23 -2
- package/dist/engine/gridApi.js +248 -96
- package/dist/engine/memo.cjs +1 -1
- package/dist/engine/memo.d.ts +1 -1
- package/dist/engine/memo.js +12 -11
- package/dist/engine/notifiers.cjs +1 -1
- package/dist/engine/notifiers.d.ts +9 -1
- package/dist/engine/notifiers.js +23 -8
- package/dist/engine/rowPipeline.cjs +1 -1
- package/dist/engine/rowPipeline.d.ts +29 -2
- package/dist/engine/rowPipeline.js +76 -50
- package/dist/engine/treeStage.cjs +1 -0
- package/dist/engine/treeStage.d.ts +46 -0
- package/dist/engine/treeStage.js +171 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +4 -4
- package/dist/locales/en.cjs +1 -1
- package/dist/locales/en.js +13 -0
- package/dist/logic/cellNote.cjs +1 -1
- package/dist/logic/cellNote.d.ts +1 -1
- package/dist/logic/cellNote.js +9 -1
- package/dist/logic/changeTracking.cjs +1 -0
- package/dist/logic/changeTracking.d.ts +51 -0
- package/dist/logic/changeTracking.js +185 -0
- package/dist/logic/clearCells.cjs +1 -1
- package/dist/logic/clearCells.js +54 -54
- package/dist/logic/columnAutosize.cjs +1 -1
- package/dist/logic/columnAutosize.d.ts +4 -1
- package/dist/logic/columnAutosize.js +89 -72
- package/dist/logic/conditionalFormat.cjs +1 -1
- package/dist/logic/conditionalFormat.js +8 -5
- package/dist/logic/contextMenuTarget.cjs +1 -1
- package/dist/logic/contextMenuTarget.d.ts +4 -3
- package/dist/logic/contextMenuTarget.js +42 -36
- package/dist/logic/exportCsv.cjs +2 -2
- package/dist/logic/exportCsv.d.ts +11 -1
- package/dist/logic/exportCsv.js +30 -22
- package/dist/logic/exportData.cjs +1 -1
- package/dist/logic/exportData.d.ts +3 -2
- package/dist/logic/exportData.js +40 -28
- package/dist/logic/fillHandle.cjs +1 -1
- package/dist/logic/fillHandle.js +109 -103
- package/dist/logic/find.cjs +1 -1
- package/dist/logic/find.d.ts +1 -1
- package/dist/logic/find.js +11 -9
- package/dist/logic/gridAsk.cjs +2 -2
- package/dist/logic/gridAsk.js +71 -71
- package/dist/logic/gridState.cjs +1 -1
- package/dist/logic/gridState.d.ts +3 -2
- package/dist/logic/gridState.js +6 -6
- package/dist/logic/groupExport.cjs +1 -1
- package/dist/logic/groupExport.js +12 -12
- package/dist/logic/localeTextFeatures.cjs +1 -1
- package/dist/logic/localeTextFeatures.d.ts +17 -0
- package/dist/logic/localeTextFeatures.js +22 -7
- package/dist/logic/selectionAggregates.cjs +1 -1
- package/dist/logic/selectionAggregates.js +2 -1
- package/dist/logic/sorting.cjs +1 -1
- package/dist/logic/sorting.d.ts +1 -1
- package/dist/logic/sorting.js +32 -32
- package/dist/logic/treeData.cjs +7 -0
- package/dist/logic/treeData.d.ts +83 -0
- package/dist/logic/treeData.js +438 -0
- package/dist/logic/validation.cjs +1 -1
- package/dist/logic/validation.d.ts +1 -1
- package/dist/logic/validation.js +23 -22
- package/dist/model/gridActions.cjs +1 -1
- package/dist/model/gridActions.d.ts +15 -0
- package/dist/model/gridActions.js +15 -0
- package/dist/model/gridReducer.cjs +1 -1
- package/dist/model/gridReducer.js +175 -156
- package/dist/model/gridTypes.core.d.ts +282 -6
- package/dist/utils/clipboard.cjs +1 -1
- package/dist/utils/clipboard.d.ts +1 -1
- package/dist/utils/clipboard.js +70 -67
- package/dist/utils/permissions.cjs +1 -1
- package/dist/utils/permissions.d.ts +6 -0
- package/dist/utils/permissions.js +11 -2
- package/package.json +1 -1
package/dist/logic/exportCsv.cjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../utils/permissions.cjs"),t=require("./selectLabels.cjs");var n=(e,t)=>e.includes(t)||e.includes(`"`)||e.includes(`
|
|
2
|
-
`)||e.includes(`\r`)?`"${e.replace(/"/g,`""`)}"`:e,r=/^[=+\-@\t\r]/,i=/^[+-]?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?$/i,a=e=>r.test(e)&&!i.test(e)?`'${e}`:e,o=(n,r)=>t.formatCellClipboardText(r,e.getCellValue(n,r),n),s=e=>e==null?``:String(e),
|
|
3
|
-
`);return
|
|
2
|
+
`)||e.includes(`\r`)?`"${e.replace(/"/g,`""`)}"`:e,r=/^[=+\-@\t\r]/,i=/^[+-]?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?$/i,a=e=>r.test(e)&&!i.test(e)?`'${e}`:e,o=(n,r)=>t.formatCellClipboardText(r,e.getCellValue(n,r),n),s=(t,n,r)=>r?.aggregates!==void 0&&n.key in r.aggregates?r.aggregates[n.key]:e.getCellValue(t,n),c=e=>e==null?``:String(e),l=e=>e==null?``:String(e),u=({getRow:e,startRow:r,endRow:i,columns:u,delimiter:d=`,`,includeHeaders:f=!0,bom:p=!1,escapeFormulas:m=!1,isRowIncluded:h,getLabelLine:g,totalLine:_,getGroupLine:v,pinnedTop:y,pinnedBottom:b,pinnedBottomAfterTotal:x,headerGroupLines:S,getTreeCell:C,treeIndent:w})=>{let T=[],E=e=>n(m?a(e):e,d);if(f){for(let e of S??[])T.push(e.map(e=>n(e,d)).join(d));T.push(u.map(e=>n(e.title||e.key,d)).join(d))}let D=e=>{for(let t of e??[])T.push(u.map(e=>E(o(t,e))).join(d))};D(y);for(let n=r;n<i;n+=1){let r=e(n);if(!r){let e=v?.(n);if(e){T.push(u.map((t,n)=>E(e.texts[n]??``)).join(d));continue}let t=g?.(n);t&&T.push(u.map((e,n)=>E(c(t[n]))).join(d));continue}if(h&&!h(r,n))continue;if(C){let e=C(n),i=u.map(n=>{let i=t.formatCellClipboardText(n,s(r,n,e),r);return E(w&&e&&n.key===w.columnKey?w.unit.repeat(e.level)+i:i)});T.push(i.join(d));continue}let i=u.map(e=>E(o(r,e)));T.push(i.join(d))}x!==!0&&D(b),_&&T.push(u.map((e,t)=>E(l(_[t]))).join(d)),x===!0&&D(b);let O=T.join(`\r
|
|
3
|
+
`);return p?`\uFEFF${O}`:O};exports.escapeCsvFormula=a,exports.labelExportCellText=c,exports.serializeRowsToCsv=u,exports.totalExportCellText=l,exports.treeExportCellValue=s;
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import type { GridColumn } from '../model/gridTypes.unbound.js';
|
|
2
2
|
import type { GroupSubtotalLine } from './groupExport.js';
|
|
3
3
|
export declare const escapeCsvFormula: (value: string) => string;
|
|
4
|
+
export type TreeExportCell = {
|
|
5
|
+
level: number;
|
|
6
|
+
aggregates: Record<string, unknown> | undefined;
|
|
7
|
+
};
|
|
8
|
+
export declare const treeExportCellValue: <T>(row: T, column: GridColumn<T>, tree: TreeExportCell | undefined) => unknown;
|
|
4
9
|
export type SerializeRowsToCsvParams<T> = {
|
|
5
10
|
getRow: (viewIndex: number) => T;
|
|
6
11
|
startRow: number;
|
|
@@ -18,8 +23,13 @@ export type SerializeRowsToCsvParams<T> = {
|
|
|
18
23
|
pinnedBottom?: readonly T[] | undefined;
|
|
19
24
|
pinnedBottomAfterTotal?: boolean | undefined;
|
|
20
25
|
headerGroupLines?: ReadonlyArray<ReadonlyArray<string>> | undefined;
|
|
26
|
+
getTreeCell?: ((rowIndex: number) => TreeExportCell | undefined) | undefined;
|
|
27
|
+
treeIndent?: {
|
|
28
|
+
columnKey: string;
|
|
29
|
+
unit: string;
|
|
30
|
+
} | undefined;
|
|
21
31
|
};
|
|
22
32
|
export type LabelExportLine = ReadonlyArray<string | number | null | undefined>;
|
|
23
33
|
export declare const labelExportCellText: (value: string | number | null | undefined) => string;
|
|
24
34
|
export declare const totalExportCellText: (value: unknown) => string;
|
|
25
|
-
export declare const serializeRowsToCsv: <T>({ getRow, startRow, endRow, columns, delimiter, includeHeaders, bom, escapeFormulas, isRowIncluded, getLabelLine, totalLine, getGroupLine, pinnedTop, pinnedBottom, pinnedBottomAfterTotal, headerGroupLines, }: SerializeRowsToCsvParams<T>) => string;
|
|
35
|
+
export declare const serializeRowsToCsv: <T>({ getRow, startRow, endRow, columns, delimiter, includeHeaders, bom, escapeFormulas, isRowIncluded, getLabelLine, totalLine, getGroupLine, pinnedTop, pinnedBottom, pinnedBottomAfterTotal, headerGroupLines, getTreeCell, treeIndent, }: SerializeRowsToCsvParams<T>) => string;
|
package/dist/logic/exportCsv.js
CHANGED
|
@@ -1,35 +1,43 @@
|
|
|
1
1
|
import { getCellValue as e } from "../utils/permissions.js";
|
|
2
2
|
import { formatCellClipboardText as t } from "./selectLabels.js";
|
|
3
3
|
//#region src/logic/exportCsv.ts
|
|
4
|
-
var n = (e, t) => e.includes(t) || e.includes("\"") || e.includes("\n") || e.includes("\r") ? `"${e.replace(/"/g, "\"\"")}"` : e, r = /^[=+\-@\t\r]/, i = /^[+-]?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?$/i, a = (e) => r.test(e) && !i.test(e) ? `'${e}` : e, o = (n, r) => t(r, e(n, r), n), s = (e) => e == null ? "" : String(e),
|
|
5
|
-
let
|
|
6
|
-
if (
|
|
7
|
-
for (let e of
|
|
8
|
-
|
|
4
|
+
var n = (e, t) => e.includes(t) || e.includes("\"") || e.includes("\n") || e.includes("\r") ? `"${e.replace(/"/g, "\"\"")}"` : e, r = /^[=+\-@\t\r]/, i = /^[+-]?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?$/i, a = (e) => r.test(e) && !i.test(e) ? `'${e}` : e, o = (n, r) => t(r, e(n, r), n), s = (t, n, r) => r?.aggregates !== void 0 && n.key in r.aggregates ? r.aggregates[n.key] : e(t, n), c = (e) => e == null ? "" : String(e), l = (e) => e == null ? "" : String(e), u = ({ getRow: e, startRow: r, endRow: i, columns: u, delimiter: d = ",", includeHeaders: f = !0, bom: p = !1, escapeFormulas: m = !1, isRowIncluded: h, getLabelLine: g, totalLine: _, getGroupLine: v, pinnedTop: y, pinnedBottom: b, pinnedBottomAfterTotal: x, headerGroupLines: S, getTreeCell: C, treeIndent: w }) => {
|
|
5
|
+
let T = [], E = (e) => n(m ? a(e) : e, d);
|
|
6
|
+
if (f) {
|
|
7
|
+
for (let e of S ?? []) T.push(e.map((e) => n(e, d)).join(d));
|
|
8
|
+
T.push(u.map((e) => n(e.title || e.key, d)).join(d));
|
|
9
9
|
}
|
|
10
|
-
let
|
|
11
|
-
for (let t of e ?? [])
|
|
10
|
+
let D = (e) => {
|
|
11
|
+
for (let t of e ?? []) T.push(u.map((e) => E(o(t, e))).join(d));
|
|
12
12
|
};
|
|
13
|
-
|
|
14
|
-
for (let n =
|
|
15
|
-
let
|
|
16
|
-
if (!
|
|
17
|
-
let e =
|
|
13
|
+
D(y);
|
|
14
|
+
for (let n = r; n < i; n += 1) {
|
|
15
|
+
let r = e(n);
|
|
16
|
+
if (!r) {
|
|
17
|
+
let e = v?.(n);
|
|
18
18
|
if (e) {
|
|
19
|
-
|
|
19
|
+
T.push(u.map((t, n) => E(e.texts[n] ?? "")).join(d));
|
|
20
20
|
continue;
|
|
21
21
|
}
|
|
22
|
-
let t =
|
|
23
|
-
t &&
|
|
22
|
+
let t = g?.(n);
|
|
23
|
+
t && T.push(u.map((e, n) => E(c(t[n]))).join(d));
|
|
24
24
|
continue;
|
|
25
25
|
}
|
|
26
|
-
if (
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
if (h && !h(r, n)) continue;
|
|
27
|
+
if (C) {
|
|
28
|
+
let e = C(n), i = u.map((n) => {
|
|
29
|
+
let i = t(n, s(r, n, e), r);
|
|
30
|
+
return E(w && e && n.key === w.columnKey ? w.unit.repeat(e.level) + i : i);
|
|
31
|
+
});
|
|
32
|
+
T.push(i.join(d));
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
let i = u.map((e) => E(o(r, e)));
|
|
36
|
+
T.push(i.join(d));
|
|
29
37
|
}
|
|
30
|
-
|
|
31
|
-
let
|
|
32
|
-
return
|
|
38
|
+
x !== !0 && D(b), _ && T.push(u.map((e, t) => E(l(_[t]))).join(d)), x === !0 && D(b);
|
|
39
|
+
let O = T.join("\r\n");
|
|
40
|
+
return p ? `\uFEFF${O}` : O;
|
|
33
41
|
};
|
|
34
42
|
//#endregion
|
|
35
|
-
export { a as escapeCsvFormula,
|
|
43
|
+
export { a as escapeCsvFormula, c as labelExportCellText, u as serializeRowsToCsv, l as totalExportCellText, s as treeExportCellValue };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../utils/permissions.cjs"),t=require("./selectLabels.cjs"),n=require("./exportCsv.cjs");var r=({getRow:r,startRow:i,endRow:a,columns:o,isRowIncluded:s,getLabelLine:c,totalLine:l,getGroupLine:u,pinnedTop:d,pinnedBottom:f,pinnedBottomAfterTotal:p})=>{let
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../utils/permissions.cjs"),t=require("./selectLabels.cjs"),n=require("./exportCsv.cjs");var r=({getRow:r,startRow:i,endRow:a,columns:o,isRowIncluded:s,getLabelLine:c,totalLine:l,getGroupLine:u,pinnedTop:d,pinnedBottom:f,pinnedBottomAfterTotal:p,getTreeCell:m})=>{let h=o.map(e=>({key:e.key,title:e.title||e.key})),g=[],_=c||l||u||d||f?[]:void 0,v=m?[]:void 0,y=(r,i)=>o.map(a=>{let o=i?n.treeExportCellValue(r,a,i):e.getCellValue(r,a);return{value:o,text:t.formatCellClipboardText(a,o,r)}}),b=e=>{for(let t of e??[])g.push(y(t)),_?.push(`pinned`),v?.push(null)};b(d);for(let e=i;e<a;e+=1){let t=r(e);if(!t){let t=u?.(e);if(t){g.push(o.map((e,n)=>({value:t.values[n]??null,text:t.texts[n]??``}))),_?.push(`group`),v?.push(null);continue}let r=c?.(e);r&&(g.push(o.map((e,t)=>{let i=r[t];return{value:i??null,text:n.labelExportCellText(i)}})),_?.push(`label`),v?.push(null));continue}if(!(s&&!s(t,e))){if(_?.push(`data`),m){let n=m(e);g.push(y(t,n)),v?.push(n?n.level:null);continue}g.push(y(t))}}p!==!0&&b(f),l&&(g.push(o.map((e,t)=>{let r=l[t];return{value:r??null,text:n.totalExportCellText(r)}})),_?.push(`total`),v?.push(null)),p===!0&&b(f);let x=_?{columns:h,rows:g,rowKinds:_}:{columns:h,rows:g};return v?{...x,treeLevels:v}:x};exports.buildGridExportData=r;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { GridColumn, GridExportData } from '../model/gridTypes.unbound.js';
|
|
2
2
|
import type { GroupSubtotalLine } from './groupExport.js';
|
|
3
|
-
import { type LabelExportLine } from './exportCsv.js';
|
|
3
|
+
import { type LabelExportLine, type TreeExportCell } from './exportCsv.js';
|
|
4
4
|
export type BuildGridExportDataParams<T> = {
|
|
5
5
|
getRow: (viewIndex: number) => T;
|
|
6
6
|
startRow: number;
|
|
@@ -13,5 +13,6 @@ export type BuildGridExportDataParams<T> = {
|
|
|
13
13
|
pinnedTop?: readonly T[] | undefined;
|
|
14
14
|
pinnedBottom?: readonly T[] | undefined;
|
|
15
15
|
pinnedBottomAfterTotal?: boolean | undefined;
|
|
16
|
+
getTreeCell?: ((rowIndex: number) => TreeExportCell | undefined) | undefined;
|
|
16
17
|
};
|
|
17
|
-
export declare const buildGridExportData: <T>({ getRow, startRow, endRow, columns, isRowIncluded, getLabelLine, totalLine, getGroupLine, pinnedTop, pinnedBottom, pinnedBottomAfterTotal, }: BuildGridExportDataParams<T>) => GridExportData;
|
|
18
|
+
export declare const buildGridExportData: <T>({ getRow, startRow, endRow, columns, isRowIncluded, getLabelLine, totalLine, getGroupLine, pinnedTop, pinnedBottom, pinnedBottomAfterTotal, getTreeCell, }: BuildGridExportDataParams<T>) => GridExportData;
|
package/dist/logic/exportData.js
CHANGED
|
@@ -1,58 +1,70 @@
|
|
|
1
1
|
import { getCellValue as e } from "../utils/permissions.js";
|
|
2
2
|
import { formatCellClipboardText as t } from "./selectLabels.js";
|
|
3
|
-
import { labelExportCellText as n, totalExportCellText as r } from "./exportCsv.js";
|
|
3
|
+
import { labelExportCellText as n, totalExportCellText as r, treeExportCellValue as i } from "./exportCsv.js";
|
|
4
4
|
//#region src/logic/exportData.ts
|
|
5
|
-
var
|
|
6
|
-
let
|
|
5
|
+
var a = ({ getRow: a, startRow: o, endRow: s, columns: c, isRowIncluded: l, getLabelLine: u, totalLine: d, getGroupLine: f, pinnedTop: p, pinnedBottom: m, pinnedBottomAfterTotal: h, getTreeCell: g }) => {
|
|
6
|
+
let _ = c.map((e) => ({
|
|
7
7
|
key: e.key,
|
|
8
8
|
title: e.title || e.key
|
|
9
|
-
})),
|
|
10
|
-
let
|
|
9
|
+
})), v = [], y = u || d || f || p || m ? [] : void 0, b = g ? [] : void 0, x = (n, r) => c.map((a) => {
|
|
10
|
+
let o = r ? i(n, a, r) : e(n, a);
|
|
11
11
|
return {
|
|
12
|
-
value:
|
|
13
|
-
text: t(
|
|
12
|
+
value: o,
|
|
13
|
+
text: t(a, o, n)
|
|
14
14
|
};
|
|
15
|
-
}),
|
|
16
|
-
for (let t of e ?? [])
|
|
15
|
+
}), S = (e) => {
|
|
16
|
+
for (let t of e ?? []) v.push(x(t)), y?.push("pinned"), b?.push(null);
|
|
17
17
|
};
|
|
18
|
-
|
|
19
|
-
for (let e =
|
|
20
|
-
let t =
|
|
18
|
+
S(p);
|
|
19
|
+
for (let e = o; e < s; e += 1) {
|
|
20
|
+
let t = a(e);
|
|
21
21
|
if (!t) {
|
|
22
|
-
let t =
|
|
22
|
+
let t = f?.(e);
|
|
23
23
|
if (t) {
|
|
24
|
-
|
|
24
|
+
v.push(c.map((e, n) => ({
|
|
25
25
|
value: t.values[n] ?? null,
|
|
26
26
|
text: t.texts[n] ?? ""
|
|
27
|
-
}))),
|
|
27
|
+
}))), y?.push("group"), b?.push(null);
|
|
28
28
|
continue;
|
|
29
29
|
}
|
|
30
|
-
let r =
|
|
31
|
-
r && (
|
|
30
|
+
let r = u?.(e);
|
|
31
|
+
r && (v.push(c.map((e, t) => {
|
|
32
32
|
let i = r[t];
|
|
33
33
|
return {
|
|
34
34
|
value: i ?? null,
|
|
35
35
|
text: n(i)
|
|
36
36
|
};
|
|
37
|
-
})),
|
|
37
|
+
})), y?.push("label"), b?.push(null));
|
|
38
38
|
continue;
|
|
39
39
|
}
|
|
40
|
-
|
|
40
|
+
if (!(l && !l(t, e))) {
|
|
41
|
+
if (y?.push("data"), g) {
|
|
42
|
+
let n = g(e);
|
|
43
|
+
v.push(x(t, n)), b?.push(n ? n.level : null);
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
v.push(x(t));
|
|
47
|
+
}
|
|
41
48
|
}
|
|
42
|
-
|
|
43
|
-
let n =
|
|
49
|
+
h !== !0 && S(m), d && (v.push(c.map((e, t) => {
|
|
50
|
+
let n = d[t];
|
|
44
51
|
return {
|
|
45
52
|
value: n ?? null,
|
|
46
53
|
text: r(n)
|
|
47
54
|
};
|
|
48
|
-
})),
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
55
|
+
})), y?.push("total"), b?.push(null)), h === !0 && S(m);
|
|
56
|
+
let C = y ? {
|
|
57
|
+
columns: _,
|
|
58
|
+
rows: v,
|
|
59
|
+
rowKinds: y
|
|
52
60
|
} : {
|
|
53
|
-
columns:
|
|
54
|
-
rows:
|
|
61
|
+
columns: _,
|
|
62
|
+
rows: v
|
|
55
63
|
};
|
|
64
|
+
return b ? {
|
|
65
|
+
...C,
|
|
66
|
+
treeLevels: b
|
|
67
|
+
} : C;
|
|
56
68
|
};
|
|
57
69
|
//#endregion
|
|
58
|
-
export {
|
|
70
|
+
export { a as buildGridExportData };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../utils/permissions.cjs"),t=require("./detailRow.cjs"),n=require("./geometry.cjs"),r=require("./validation.cjs"),i=require("./fillSeries.cjs");var a=(e,t,n,r)=>{let i;if(e?.type===`cell`){let{start:t,end:n}=e.range;i={startRow:Math.min(t.row,n.row),endRow:Math.max(t.row,n.row),startCol:Math.min(t.col,n.col),endCol:Math.max(t.col,n.col)}}else if(e===null&&t)i={startRow:t.row,endRow:t.row,startCol:t.col,endCol:t.col};else return null;return i.startRow<0||i.endRow>=n||i.startCol<0||i.endCol>=r?null:i},o=(e,t)=>({startRow:Math.min(e.startRow,t.range.startRow),endRow:Math.max(e.endRow,t.range.endRow),startCol:Math.min(e.startCol,t.range.startCol),endCol:Math.max(e.endCol,t.range.endCol)}),s=(e,t)=>e.startRow===t.startRow&&e.endRow===t.endRow&&e.startCol===t.startCol&&e.endCol===t.endCol,c=e=>{let n=-1,r=-1;return e.forEach((e,i)=>{t.isSyntheticColumnKey(e.key)||(n===-1&&(n=i),r=i)}),n===-1?null:{first:n,last:r}},l=(e,t,n,r)=>{if(n<=0)return null;let i=Math.min(Math.max(t.row,0),n-1),a=Math.min(Math.max(t.col,r.first),r.last),o=i-e.endRow,s=e.startRow-i,c=a-e.endCol,l=e.startCol-a,u=Math.max(o,s,0),d=Math.max(c,l,0);return u===0&&d===0?null:u>=d?o>0?{direction:`down`,range:{startRow:e.endRow+1,endRow:i,startCol:e.startCol,endCol:e.endCol}}:{direction:`up`,range:{startRow:i,endRow:e.startRow-1,startCol:e.startCol,endCol:e.endCol}}:c>0?{direction:`right`,range:{startRow:e.startRow,endRow:e.endRow,startCol:e.endCol+1,endCol:a}}:{direction:`left`,range:{startRow:e.startRow,endRow:e.endRow,startCol:a,endCol:e.startCol-1}}},u=(e,t)=>e.getLabelRow?.(t)!==void 0||e.getGroupRow?.(t)!==void 0,d=e=>e!=null&&e!==``,f=(e,n,r)=>{let i=!1;for(let n=e.startCol;n<=e.endCol;n+=1){let e=r[n];if(e!==void 0&&!t.isSyntheticColumnKey(e.key)){i=!0;break}}if(!i)return!1;for(let t=e.startRow;t<=e.endRow;t+=1)if(!u(n,t))return!0;return!1},p=(n,r,i)=>{let a=r.getRowCount(),o=n.endRow+1;if(o>=a)return null;let s=e=>u(r,e)?void 0:r.getRow(e),c=(e,n)=>{for(let r=e;r>=0&&r<i.length;r+=n)if(!t.isSyntheticColumnKey(i[r].key))return r;return-1},l=i.slice(n.startCol,n.endCol+1).filter(e=>!t.isSyntheticColumnKey(e.key));if(l.length===0)return null;for(let t of[c(n.startCol-1,-1),c(n.endCol+1,1)]){if(t===-1)continue;let r=i[t],c=n.endRow;for(let t=o;t<a;t+=1){let n=s(t);if(n===void 0||!d(e.getCellValue(n,r))||l.some(t=>d(e.getCellValue(n,t))))break;c=t}if(c>n.endRow)return{direction:`down`,range:{startRow:o,endRow:c,startCol:n.startCol,endCol:n.endCol}}}return null},m=e=>e.editor?.type===`select`,h=(e,t)=>t&&e.defaultKind===`series`?{...e,defaultKind:`copy`}:e,g=(e,t,n,r)=>{let i=[];for(let a=e;n===1?a<=t:a>=t;a+=n)r(a)&&i.push(a);return i},_=({rowModel:n,columns:a,source:o,target:s,request:c,canWriteCell:l,getFillValue:d})=>{let f=[],p=`copy`,_=!1,{direction:v,range:y}=s,b=v===`down`||v===`up`,x=v===`down`||v===`right`,S=(e,t,n,a=!1)=>{if(e.length===0||t.length===0)return;let o=h(i.analyzeFillLine(e,{backward:!x}),a),s=i.resolveFillLineKind(o,c);o.series!==null&&(_=!0),s===`series`&&(p=`series`);let u=i.createFillLineValues(e,o,s);t.forEach((t,i)=>{let{viewIndex:a,colIndex:o,row:c,column:p}=n(t);if(c===void 0||!l(a,o,c,p))return;let m=u(i),h=d?d({column:p,row:c,rowIndex:a,sourceValues:e,index:i,direction:v,kind:s,defaultValue:m}):m;r.decideCellWrite(p,c,h).action!==`reject`&&f.push({viewIndex:a,column:p,value:h})})};if(b){let r=e=>!u(n,e),i=x?g(o.startRow,o.endRow,1,r):g(o.endRow,o.startRow,-1,r),s=x?g(y.startRow,y.endRow,1,r):g(y.endRow,y.startRow,-1,r);for(let r=o.startCol;r<=o.endCol;r+=1){let o=a[r];if(!o||t.isSyntheticColumnKey(o.key))continue;let c=[],l=!0;for(let t of i){let r=n.getRow(t);if(r===void 0){l=!1;break}c.push(e.getCellValue(r,o))}l&&S(c,s,e=>({viewIndex:e,colIndex:r,row:n.getRow(e),column:o}),m(o))}}else{let r=e=>{let n=a[e];return n!==void 0&&!t.isSyntheticColumnKey(n.key)},i=x?g(o.startCol,o.endCol,1,r):g(o.endCol,o.startCol,-1,r),s=x?g(y.startCol,y.endCol,1,r):g(y.endCol,y.startCol,-1,r);for(let t=o.startRow;t<=o.endRow;t+=1){if(u(n,t))continue;let r=n.getRow(t);r!==void 0&&S(i.map(t=>e.getCellValue(r,a[t])),s,e=>({viewIndex:t,colIndex:e,row:r,column:a[e]}))}}return{edits:f,kind:p,seriesAvailable:_}},v=({rowModel:n,columns:r,source:a,target:o,request:s,canWriteCell:c,getFillValue:l})=>{let{direction:d,range:f}=o,p=d===`down`||d===`up`,_=d===`down`||d===`right`,v,y,b,x,S,C=!1,w;if(p){let i=g(a.startCol,a.endCol,1,e=>{let n=r[e];return n!==void 0&&!t.isSyntheticColumnKey(n.key)})[0];if(i===void 0)return null;b=i,y=r[b];let o=e=>!u(n,e),s=_?g(a.startRow,a.endRow,1,o):g(a.endRow,a.startRow,-1,o),c=_?g(f.startRow,f.endRow,1,o):g(f.endRow,f.startRow,-1,o);if(s.length===0||c.length===0)return null;v=[];let l;for(let t of s){if(l=n.getRow(t),l===void 0)return null;v.push(e.getCellValue(l,y))}w=c.length-1,x=c[w],S=n.getRow(x),C=S===void 0,S??=l}else{let i=g(a.startRow,a.endRow,1,e=>!u(n,e))[0];if(i===void 0)return null;let o=n.getRow(i);if(o===void 0)return null;let s=e=>{let n=r[e];return n!==void 0&&!t.isSyntheticColumnKey(n.key)},c=_?g(a.startCol,a.endCol,1,s):g(a.endCol,a.startCol,-1,s),l=_?g(f.startCol,f.endCol,1,s):g(f.endCol,f.startCol,-1,s);if(c.length===0||l.length===0)return null;v=c.map(t=>e.getCellValue(o,r[t])),w=l.length-1,b=l[w],y=r[b],x=i,S=o}let T=h(i.analyzeFillLine(v,{backward:!_}),p&&m(y)),E=i.resolveFillLineKind(T,s),D=i.createFillLineValues(v,T,E)(w),O=l&&S!==void 0&&!C&&(c===void 0||c(x,b,S,y))?l({column:y,row:S,rowIndex:x,sourceValues:v,index:w,direction:d,kind:E,defaultValue:D}):D;return{column:y,row:S,value:O}},y=(t,n,r)=>{if(r.length===0)return t;let i=[...t];for(let{viewIndex:t,column:
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../utils/permissions.cjs"),t=require("./detailRow.cjs"),n=require("./geometry.cjs"),r=require("./validation.cjs"),i=require("./fillSeries.cjs");var a=(e,t,n,r)=>{let i;if(e?.type===`cell`){let{start:t,end:n}=e.range;i={startRow:Math.min(t.row,n.row),endRow:Math.max(t.row,n.row),startCol:Math.min(t.col,n.col),endCol:Math.max(t.col,n.col)}}else if(e===null&&t)i={startRow:t.row,endRow:t.row,startCol:t.col,endCol:t.col};else return null;return i.startRow<0||i.endRow>=n||i.startCol<0||i.endCol>=r?null:i},o=(e,t)=>({startRow:Math.min(e.startRow,t.range.startRow),endRow:Math.max(e.endRow,t.range.endRow),startCol:Math.min(e.startCol,t.range.startCol),endCol:Math.max(e.endCol,t.range.endCol)}),s=(e,t)=>e.startRow===t.startRow&&e.endRow===t.endRow&&e.startCol===t.startCol&&e.endCol===t.endCol,c=e=>{let n=-1,r=-1;return e.forEach((e,i)=>{t.isSyntheticColumnKey(e.key)||(n===-1&&(n=i),r=i)}),n===-1?null:{first:n,last:r}},l=(e,t,n,r)=>{if(n<=0)return null;let i=Math.min(Math.max(t.row,0),n-1),a=Math.min(Math.max(t.col,r.first),r.last),o=i-e.endRow,s=e.startRow-i,c=a-e.endCol,l=e.startCol-a,u=Math.max(o,s,0),d=Math.max(c,l,0);return u===0&&d===0?null:u>=d?o>0?{direction:`down`,range:{startRow:e.endRow+1,endRow:i,startCol:e.startCol,endCol:e.endCol}}:{direction:`up`,range:{startRow:i,endRow:e.startRow-1,startCol:e.startCol,endCol:e.endCol}}:c>0?{direction:`right`,range:{startRow:e.startRow,endRow:e.endRow,startCol:e.endCol+1,endCol:a}}:{direction:`left`,range:{startRow:e.startRow,endRow:e.endRow,startCol:a,endCol:e.startCol-1}}},u=(e,t)=>e.getLabelRow?.(t)!==void 0||e.getGroupRow?.(t)!==void 0,d=e=>e!=null&&e!==``,f=(e,n,r)=>{let i=!1;for(let n=e.startCol;n<=e.endCol;n+=1){let e=r[n];if(e!==void 0&&!t.isSyntheticColumnKey(e.key)){i=!0;break}}if(!i)return!1;for(let t=e.startRow;t<=e.endRow;t+=1)if(!u(n,t))return!0;return!1},p=(n,r,i)=>{let a=r.getRowCount(),o=n.endRow+1;if(o>=a)return null;let s=e=>u(r,e)?void 0:r.getRow(e),c=(e,n)=>{for(let r=e;r>=0&&r<i.length;r+=n)if(!t.isSyntheticColumnKey(i[r].key))return r;return-1},l=i.slice(n.startCol,n.endCol+1).filter(e=>!t.isSyntheticColumnKey(e.key));if(l.length===0)return null;for(let t of[c(n.startCol-1,-1),c(n.endCol+1,1)]){if(t===-1)continue;let r=i[t],c=n.endRow;for(let t=o;t<a;t+=1){let n=s(t);if(n===void 0||!d(e.getCellValue(n,r))||l.some(t=>d(e.getCellValue(n,t))))break;c=t}if(c>n.endRow)return{direction:`down`,range:{startRow:o,endRow:c,startCol:n.startCol,endCol:n.endCol}}}return null},m=e=>e.editor?.type===`select`,h=(e,t)=>t&&e.defaultKind===`series`?{...e,defaultKind:`copy`}:e,g=(e,t,n,r)=>{let i=[];for(let a=e;n===1?a<=t:a>=t;a+=n)r(a)&&i.push(a);return i},_=({rowModel:n,columns:a,source:o,target:s,request:c,canWriteCell:l,getFillValue:d})=>{let f=[],p=`copy`,_=!1,{direction:v,range:y}=s,b=v===`down`||v===`up`,x=v===`down`||v===`right`,S=(e,t,n,a=!1)=>{if(e.length===0||t.length===0)return;let o=h(i.analyzeFillLine(e,{backward:!x}),a),s=i.resolveFillLineKind(o,c);o.series!==null&&(_=!0),s===`series`&&(p=`series`);let u=i.createFillLineValues(e,o,s);t.forEach((t,i)=>{let{viewIndex:a,colIndex:o,row:c,column:p}=n(t);if(c===void 0||!l(a,o,c,p))return;let m=u(i),h=d?d({column:p,row:c,rowIndex:a,sourceValues:e,index:i,direction:v,kind:s,defaultValue:m}):m;r.decideCellWrite(p,c,h).action!==`reject`&&f.push({viewIndex:a,column:p,value:h})})};if(b){let r=e=>!u(n,e),i=x?g(o.startRow,o.endRow,1,r):g(o.endRow,o.startRow,-1,r),s=x?g(y.startRow,y.endRow,1,r):g(y.endRow,y.startRow,-1,r);for(let r=o.startCol;r<=o.endCol;r+=1){let o=a[r];if(!o||t.isSyntheticColumnKey(o.key))continue;let c=[],l=!0;for(let t of i){let r=n.getRow(t);if(r===void 0){l=!1;break}c.push(e.getCellValue(r,o))}l&&S(c,s,e=>({viewIndex:e,colIndex:r,row:n.getRow(e),column:o}),m(o))}}else{let r=e=>{let n=a[e];return n!==void 0&&!t.isSyntheticColumnKey(n.key)},i=x?g(o.startCol,o.endCol,1,r):g(o.endCol,o.startCol,-1,r),s=x?g(y.startCol,y.endCol,1,r):g(y.endCol,y.startCol,-1,r);for(let t=o.startRow;t<=o.endRow;t+=1){if(u(n,t))continue;let r=n.getRow(t);r!==void 0&&S(i.map(t=>e.getCellValue(r,a[t])),s,e=>({viewIndex:t,colIndex:e,row:r,column:a[e]}))}}return{edits:f,kind:p,seriesAvailable:_}},v=({rowModel:n,columns:r,source:a,target:o,request:s,canWriteCell:c,getFillValue:l})=>{let{direction:d,range:f}=o,p=d===`down`||d===`up`,_=d===`down`||d===`right`,v,y,b,x,S,C=!1,w;if(p){let i=g(a.startCol,a.endCol,1,e=>{let n=r[e];return n!==void 0&&!t.isSyntheticColumnKey(n.key)})[0];if(i===void 0)return null;b=i,y=r[b];let o=e=>!u(n,e),s=_?g(a.startRow,a.endRow,1,o):g(a.endRow,a.startRow,-1,o),c=_?g(f.startRow,f.endRow,1,o):g(f.endRow,f.startRow,-1,o);if(s.length===0||c.length===0)return null;v=[];let l;for(let t of s){if(l=n.getRow(t),l===void 0)return null;v.push(e.getCellValue(l,y))}w=c.length-1,x=c[w],S=n.getRow(x),C=S===void 0,S??=l}else{let i=g(a.startRow,a.endRow,1,e=>!u(n,e))[0];if(i===void 0)return null;let o=n.getRow(i);if(o===void 0)return null;let s=e=>{let n=r[e];return n!==void 0&&!t.isSyntheticColumnKey(n.key)},c=_?g(a.startCol,a.endCol,1,s):g(a.endCol,a.startCol,-1,s),l=_?g(f.startCol,f.endCol,1,s):g(f.endCol,f.startCol,-1,s);if(c.length===0||l.length===0)return null;v=c.map(t=>e.getCellValue(o,r[t])),w=l.length-1,b=l[w],y=r[b],x=i,S=o}let T=h(i.analyzeFillLine(v,{backward:!_}),p&&m(y)),E=i.resolveFillLineKind(T,s),D=i.createFillLineValues(v,T,E)(w),O=l&&S!==void 0&&!C&&(c===void 0||c(x,b,S,y))?l({column:y,row:S,rowIndex:x,sourceValues:v,index:w,direction:d,kind:E,defaultValue:D}):D;return{column:y,row:S,value:O}},y=(t,n,r)=>{if(r.length===0)return t;let i=[...t],a=new Map;for(let{viewIndex:t,column:o,value:s}of r){let r=n.getSourceIndex(t);if(r===void 0)continue;let c=a.get(r);if(c===void 0){let t=i[r];if(t===void 0)continue;c=e.createCellWriteDraft(t),a.set(r,c)}e.writeCellValue(c,o,s)}for(let[e,t]of a)i[e]=t.row;return i},b=(e,t,r,i,a)=>{if(e.endRow<i||e.endRow>a)return null;let o=n.computeSinglePaneColumnExtent(t,e.endCol);return o?{pane:o.pane,x:o.extent.end,y:r.rowTop(e.endRow)+r.cellHeight(e.endRow),paneWidth:t[o.pane].totalWidth}:null},x=36,S=22,C=4,w=(e,t,n=1/0)=>({x:e.x+C+36<=e.paneWidth?e.x+C:Math.max(e.x-36-C,0),y:e.y+C+22<=Math.min(t,n)?e.y+C:Math.max(e.y-22-C,0)});exports.FILL_OPTIONS_CHIP_HEIGHT=S,exports.FILL_OPTIONS_CHIP_WIDTH=x,exports.applyFillEditsToRows=y,exports.buildFillEdits=_,exports.hasFillableSource=f,exports.isSameFillRange=s,exports.previewFillValue=v,exports.resolveFillColumnBounds=c,exports.resolveFillCornerPlacement=b,exports.resolveFillDoubleClickTarget=p,exports.resolveFillOptionsChipPosition=w,exports.resolveFillSource=a,exports.resolveFillTarget=l,exports.unionFillRange=o;
|
package/dist/logic/fillHandle.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { isSyntheticColumnKey as
|
|
3
|
-
import { computeSinglePaneColumnExtent as
|
|
4
|
-
import { decideCellWrite as
|
|
5
|
-
import { analyzeFillLine as
|
|
1
|
+
import { createCellWriteDraft as e, getCellValue as t, writeCellValue as n } from "../utils/permissions.js";
|
|
2
|
+
import { isSyntheticColumnKey as r } from "./detailRow.js";
|
|
3
|
+
import { computeSinglePaneColumnExtent as i } from "./geometry.js";
|
|
4
|
+
import { decideCellWrite as a } from "./validation.js";
|
|
5
|
+
import { analyzeFillLine as o, createFillLineValues as s, resolveFillLineKind as c } from "./fillSeries.js";
|
|
6
6
|
//#region src/logic/fillHandle.ts
|
|
7
|
-
var
|
|
7
|
+
var l = (e, t, n, r) => {
|
|
8
8
|
let i;
|
|
9
9
|
if (e?.type === "cell") {
|
|
10
10
|
let { start: t, end: n } = e.range;
|
|
@@ -22,20 +22,20 @@ var c = (e, t, n, r) => {
|
|
|
22
22
|
};
|
|
23
23
|
else return null;
|
|
24
24
|
return i.startRow < 0 || i.endRow >= n || i.startCol < 0 || i.endCol >= r ? null : i;
|
|
25
|
-
},
|
|
25
|
+
}, u = (e, t) => ({
|
|
26
26
|
startRow: Math.min(e.startRow, t.range.startRow),
|
|
27
27
|
endRow: Math.max(e.endRow, t.range.endRow),
|
|
28
28
|
startCol: Math.min(e.startCol, t.range.startCol),
|
|
29
29
|
endCol: Math.max(e.endCol, t.range.endCol)
|
|
30
|
-
}),
|
|
31
|
-
let t = -1,
|
|
30
|
+
}), d = (e, t) => e.startRow === t.startRow && e.endRow === t.endRow && e.startCol === t.startCol && e.endCol === t.endCol, f = (e) => {
|
|
31
|
+
let t = -1, n = -1;
|
|
32
32
|
return e.forEach((e, i) => {
|
|
33
|
-
|
|
33
|
+
r(e.key) || (t === -1 && (t = i), n = i);
|
|
34
34
|
}), t === -1 ? null : {
|
|
35
35
|
first: t,
|
|
36
|
-
last:
|
|
36
|
+
last: n
|
|
37
37
|
};
|
|
38
|
-
},
|
|
38
|
+
}, p = (e, t, n, r) => {
|
|
39
39
|
if (n <= 0) return null;
|
|
40
40
|
let i = Math.min(Math.max(t.row, 0), n - 1), a = Math.min(Math.max(t.col, r.first), r.last), o = i - e.endRow, s = e.startRow - i, c = a - e.endCol, l = e.startCol - a, u = Math.max(o, s, 0), d = Math.max(c, l, 0);
|
|
41
41
|
return u === 0 && d === 0 ? null : u >= d ? o > 0 ? {
|
|
@@ -71,155 +71,155 @@ var c = (e, t, n, r) => {
|
|
|
71
71
|
endCol: e.startCol - 1
|
|
72
72
|
}
|
|
73
73
|
};
|
|
74
|
-
},
|
|
74
|
+
}, m = (e, t) => e.getLabelRow?.(t) !== void 0 || e.getGroupRow?.(t) !== void 0, h = (e) => e != null && e !== "", g = (e, t, n) => {
|
|
75
75
|
let i = !1;
|
|
76
76
|
for (let t = e.startCol; t <= e.endCol; t += 1) {
|
|
77
|
-
let e =
|
|
78
|
-
if (e !== void 0 && !
|
|
77
|
+
let e = n[t];
|
|
78
|
+
if (e !== void 0 && !r(e.key)) {
|
|
79
79
|
i = !0;
|
|
80
80
|
break;
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
if (!i) return !1;
|
|
84
|
-
for (let n = e.startRow; n <= e.endRow; n += 1) if (!
|
|
84
|
+
for (let n = e.startRow; n <= e.endRow; n += 1) if (!m(t, n)) return !0;
|
|
85
85
|
return !1;
|
|
86
|
-
},
|
|
87
|
-
let a =
|
|
86
|
+
}, _ = (e, n, i) => {
|
|
87
|
+
let a = n.getRowCount(), o = e.endRow + 1;
|
|
88
88
|
if (o >= a) return null;
|
|
89
|
-
let s = (e) =>
|
|
90
|
-
for (let
|
|
89
|
+
let s = (e) => m(n, e) ? void 0 : n.getRow(e), c = (e, t) => {
|
|
90
|
+
for (let n = e; n >= 0 && n < i.length; n += t) if (!r(i[n].key)) return n;
|
|
91
91
|
return -1;
|
|
92
|
-
}, l = i.slice(
|
|
92
|
+
}, l = i.slice(e.startCol, e.endCol + 1).filter((e) => !r(e.key));
|
|
93
93
|
if (l.length === 0) return null;
|
|
94
|
-
for (let n of [c(
|
|
94
|
+
for (let n of [c(e.startCol - 1, -1), c(e.endCol + 1, 1)]) {
|
|
95
95
|
if (n === -1) continue;
|
|
96
|
-
let r = i[n], c =
|
|
97
|
-
for (let
|
|
98
|
-
let n = s(
|
|
99
|
-
if (n === void 0 || !
|
|
100
|
-
c =
|
|
96
|
+
let r = i[n], c = e.endRow;
|
|
97
|
+
for (let e = o; e < a; e += 1) {
|
|
98
|
+
let n = s(e);
|
|
99
|
+
if (n === void 0 || !h(t(n, r)) || l.some((e) => h(t(n, e)))) break;
|
|
100
|
+
c = e;
|
|
101
101
|
}
|
|
102
|
-
if (c >
|
|
102
|
+
if (c > e.endRow) return {
|
|
103
103
|
direction: "down",
|
|
104
104
|
range: {
|
|
105
105
|
startRow: o,
|
|
106
106
|
endRow: c,
|
|
107
|
-
startCol:
|
|
108
|
-
endCol:
|
|
107
|
+
startCol: e.startCol,
|
|
108
|
+
endCol: e.endCol
|
|
109
109
|
}
|
|
110
110
|
};
|
|
111
111
|
}
|
|
112
112
|
return null;
|
|
113
|
-
},
|
|
113
|
+
}, v = (e) => e.editor?.type === "select", y = (e, t) => t && e.defaultKind === "series" ? {
|
|
114
114
|
...e,
|
|
115
115
|
defaultKind: "copy"
|
|
116
|
-
} : e,
|
|
116
|
+
} : e, b = (e, t, n, r) => {
|
|
117
117
|
let i = [];
|
|
118
118
|
for (let a = e; n === 1 ? a <= t : a >= t; a += n) r(a) && i.push(a);
|
|
119
119
|
return i;
|
|
120
|
-
},
|
|
121
|
-
let
|
|
120
|
+
}, x = ({ rowModel: e, columns: n, source: i, target: l, request: u, canWriteCell: d, getFillValue: f }) => {
|
|
121
|
+
let p = [], h = "copy", g = !1, { direction: _, range: x } = l, S = _ === "down" || _ === "up", C = _ === "down" || _ === "right", w = (e, t, n, r = !1) => {
|
|
122
122
|
if (e.length === 0 || t.length === 0) return;
|
|
123
|
-
let
|
|
124
|
-
|
|
125
|
-
let
|
|
123
|
+
let i = y(o(e, { backward: !C }), r), l = c(i, u);
|
|
124
|
+
i.series !== null && (g = !0), l === "series" && (h = "series");
|
|
125
|
+
let m = s(e, i, l);
|
|
126
126
|
t.forEach((t, r) => {
|
|
127
|
-
let { viewIndex:
|
|
128
|
-
if (s === void 0 || !d(
|
|
129
|
-
let u =
|
|
127
|
+
let { viewIndex: i, colIndex: o, row: s, column: c } = n(t);
|
|
128
|
+
if (s === void 0 || !d(i, o, s, c)) return;
|
|
129
|
+
let u = m(r), h = f ? f({
|
|
130
130
|
column: c,
|
|
131
131
|
row: s,
|
|
132
|
-
rowIndex:
|
|
132
|
+
rowIndex: i,
|
|
133
133
|
sourceValues: e,
|
|
134
134
|
index: r,
|
|
135
|
-
direction:
|
|
135
|
+
direction: _,
|
|
136
136
|
kind: l,
|
|
137
137
|
defaultValue: u
|
|
138
138
|
}) : u;
|
|
139
|
-
|
|
140
|
-
viewIndex:
|
|
139
|
+
a(c, s, h).action !== "reject" && p.push({
|
|
140
|
+
viewIndex: i,
|
|
141
141
|
column: c,
|
|
142
142
|
value: h
|
|
143
143
|
});
|
|
144
144
|
});
|
|
145
145
|
};
|
|
146
146
|
if (S) {
|
|
147
|
-
let
|
|
148
|
-
for (let
|
|
149
|
-
let
|
|
150
|
-
if (!
|
|
147
|
+
let a = (t) => !m(e, t), o = C ? b(i.startRow, i.endRow, 1, a) : b(i.endRow, i.startRow, -1, a), s = C ? b(x.startRow, x.endRow, 1, a) : b(x.endRow, x.startRow, -1, a);
|
|
148
|
+
for (let a = i.startCol; a <= i.endCol; a += 1) {
|
|
149
|
+
let i = n[a];
|
|
150
|
+
if (!i || r(i.key)) continue;
|
|
151
151
|
let c = [], l = !0;
|
|
152
|
-
for (let n of
|
|
153
|
-
let r =
|
|
152
|
+
for (let n of o) {
|
|
153
|
+
let r = e.getRow(n);
|
|
154
154
|
if (r === void 0) {
|
|
155
155
|
l = !1;
|
|
156
156
|
break;
|
|
157
157
|
}
|
|
158
|
-
c.push(
|
|
158
|
+
c.push(t(r, i));
|
|
159
159
|
}
|
|
160
|
-
l && w(c,
|
|
161
|
-
viewIndex:
|
|
162
|
-
colIndex:
|
|
163
|
-
row:
|
|
164
|
-
column:
|
|
165
|
-
}),
|
|
160
|
+
l && w(c, s, (t) => ({
|
|
161
|
+
viewIndex: t,
|
|
162
|
+
colIndex: a,
|
|
163
|
+
row: e.getRow(t),
|
|
164
|
+
column: i
|
|
165
|
+
}), v(i));
|
|
166
166
|
}
|
|
167
167
|
} else {
|
|
168
|
-
let
|
|
169
|
-
let t =
|
|
170
|
-
return t !== void 0 && !
|
|
171
|
-
},
|
|
172
|
-
for (let
|
|
173
|
-
if (
|
|
174
|
-
let i =
|
|
175
|
-
i !== void 0 && w(
|
|
176
|
-
viewIndex:
|
|
168
|
+
let a = (e) => {
|
|
169
|
+
let t = n[e];
|
|
170
|
+
return t !== void 0 && !r(t.key);
|
|
171
|
+
}, o = C ? b(i.startCol, i.endCol, 1, a) : b(i.endCol, i.startCol, -1, a), s = C ? b(x.startCol, x.endCol, 1, a) : b(x.endCol, x.startCol, -1, a);
|
|
172
|
+
for (let r = i.startRow; r <= i.endRow; r += 1) {
|
|
173
|
+
if (m(e, r)) continue;
|
|
174
|
+
let i = e.getRow(r);
|
|
175
|
+
i !== void 0 && w(o.map((e) => t(i, n[e])), s, (e) => ({
|
|
176
|
+
viewIndex: r,
|
|
177
177
|
colIndex: e,
|
|
178
178
|
row: i,
|
|
179
|
-
column:
|
|
179
|
+
column: n[e]
|
|
180
180
|
}));
|
|
181
181
|
}
|
|
182
182
|
}
|
|
183
183
|
return {
|
|
184
|
-
edits:
|
|
184
|
+
edits: p,
|
|
185
185
|
kind: h,
|
|
186
186
|
seriesAvailable: g
|
|
187
187
|
};
|
|
188
|
-
},
|
|
189
|
-
let { direction: f, range:
|
|
188
|
+
}, S = ({ rowModel: e, columns: n, source: i, target: a, request: l, canWriteCell: u, getFillValue: d }) => {
|
|
189
|
+
let { direction: f, range: p } = a, h = f === "down" || f === "up", g = f === "down" || f === "right", _, x, S, C, w, T = !1, E;
|
|
190
190
|
if (h) {
|
|
191
|
-
let a =
|
|
192
|
-
let t =
|
|
193
|
-
return t !== void 0 && !
|
|
191
|
+
let a = b(i.startCol, i.endCol, 1, (e) => {
|
|
192
|
+
let t = n[e];
|
|
193
|
+
return t !== void 0 && !r(t.key);
|
|
194
194
|
})[0];
|
|
195
195
|
if (a === void 0) return null;
|
|
196
|
-
S = a, x =
|
|
197
|
-
let o = (
|
|
196
|
+
S = a, x = n[S];
|
|
197
|
+
let o = (t) => !m(e, t), s = g ? b(i.startRow, i.endRow, 1, o) : b(i.endRow, i.startRow, -1, o), c = g ? b(p.startRow, p.endRow, 1, o) : b(p.endRow, p.startRow, -1, o);
|
|
198
198
|
if (s.length === 0 || c.length === 0) return null;
|
|
199
|
-
|
|
199
|
+
_ = [];
|
|
200
200
|
let l;
|
|
201
201
|
for (let n of s) {
|
|
202
|
-
if (l =
|
|
203
|
-
|
|
202
|
+
if (l = e.getRow(n), l === void 0) return null;
|
|
203
|
+
_.push(t(l, x));
|
|
204
204
|
}
|
|
205
|
-
E = c.length - 1, C = c[E], w =
|
|
205
|
+
E = c.length - 1, C = c[E], w = e.getRow(C), T = w === void 0, w ??= l;
|
|
206
206
|
} else {
|
|
207
|
-
let a =
|
|
207
|
+
let a = b(i.startRow, i.endRow, 1, (t) => !m(e, t))[0];
|
|
208
208
|
if (a === void 0) return null;
|
|
209
|
-
let o =
|
|
209
|
+
let o = e.getRow(a);
|
|
210
210
|
if (o === void 0) return null;
|
|
211
211
|
let s = (e) => {
|
|
212
|
-
let t =
|
|
213
|
-
return t !== void 0 && !
|
|
214
|
-
}, c = g ?
|
|
212
|
+
let t = n[e];
|
|
213
|
+
return t !== void 0 && !r(t.key);
|
|
214
|
+
}, c = g ? b(i.startCol, i.endCol, 1, s) : b(i.endCol, i.startCol, -1, s), l = g ? b(p.startCol, p.endCol, 1, s) : b(p.endCol, p.startCol, -1, s);
|
|
215
215
|
if (c.length === 0 || l.length === 0) return null;
|
|
216
|
-
|
|
216
|
+
_ = c.map((e) => t(o, n[e])), E = l.length - 1, S = l[E], x = n[S], C = a, w = o;
|
|
217
217
|
}
|
|
218
|
-
let D =
|
|
218
|
+
let D = y(o(_, { backward: !g }), h && v(x)), O = c(D, l), k = s(_, D, O)(E), A = d && w !== void 0 && !T && (u === void 0 || u(C, S, w, x)) ? d({
|
|
219
219
|
column: x,
|
|
220
220
|
row: w,
|
|
221
221
|
rowIndex: C,
|
|
222
|
-
sourceValues:
|
|
222
|
+
sourceValues: _,
|
|
223
223
|
index: E,
|
|
224
224
|
direction: f,
|
|
225
225
|
kind: O,
|
|
@@ -230,28 +230,34 @@ var c = (e, t, n, r) => {
|
|
|
230
230
|
row: w,
|
|
231
231
|
value: A
|
|
232
232
|
};
|
|
233
|
-
},
|
|
234
|
-
if (
|
|
235
|
-
let
|
|
236
|
-
for (let { viewIndex:
|
|
237
|
-
let
|
|
238
|
-
if (
|
|
239
|
-
let
|
|
240
|
-
|
|
233
|
+
}, C = (t, r, i) => {
|
|
234
|
+
if (i.length === 0) return t;
|
|
235
|
+
let a = [...t], o = /* @__PURE__ */ new Map();
|
|
236
|
+
for (let { viewIndex: t, column: s, value: c } of i) {
|
|
237
|
+
let i = r.getSourceIndex(t);
|
|
238
|
+
if (i === void 0) continue;
|
|
239
|
+
let l = o.get(i);
|
|
240
|
+
if (l === void 0) {
|
|
241
|
+
let t = a[i];
|
|
242
|
+
if (t === void 0) continue;
|
|
243
|
+
l = e(t), o.set(i, l);
|
|
244
|
+
}
|
|
245
|
+
n(l, s, c);
|
|
241
246
|
}
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
247
|
+
for (let [e, t] of o) a[e] = t.row;
|
|
248
|
+
return a;
|
|
249
|
+
}, w = (e, t, n, r, a) => {
|
|
250
|
+
if (e.endRow < r || e.endRow > a) return null;
|
|
251
|
+
let o = i(t, e.endCol);
|
|
246
252
|
return o ? {
|
|
247
253
|
pane: o.pane,
|
|
248
254
|
x: o.extent.end,
|
|
249
255
|
y: n.rowTop(e.endRow) + n.cellHeight(e.endRow),
|
|
250
256
|
paneWidth: t[o.pane].totalWidth
|
|
251
257
|
} : null;
|
|
252
|
-
},
|
|
253
|
-
x: e.x +
|
|
254
|
-
y: e.y +
|
|
258
|
+
}, T = 36, E = 22, D = 4, O = (e, t, n = Infinity) => ({
|
|
259
|
+
x: e.x + D + 36 <= e.paneWidth ? e.x + D : Math.max(e.x - 36 - D, 0),
|
|
260
|
+
y: e.y + D + 22 <= Math.min(t, n) ? e.y + D : Math.max(e.y - 22 - D, 0)
|
|
255
261
|
});
|
|
256
262
|
//#endregion
|
|
257
|
-
export {
|
|
263
|
+
export { E as FILL_OPTIONS_CHIP_HEIGHT, T as FILL_OPTIONS_CHIP_WIDTH, C as applyFillEditsToRows, x as buildFillEdits, g as hasFillableSource, d as isSameFillRange, S as previewFillValue, f as resolveFillColumnBounds, w as resolveFillCornerPlacement, _ as resolveFillDoubleClickTarget, O as resolveFillOptionsChipPosition, l as resolveFillSource, p as resolveFillTarget, u as unionFillRange };
|
package/dist/logic/find.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../utils/permissions.cjs"),t=require("./conditionalFormat.cjs");var n=(n,r,i)=>{let a=e.getCellValue(r,n),o=n.valueFormatter?n.valueFormatter({value:a,row:r,column:n}):String(a??``),s=n.renderCell===void 0?n.conditionalFormat?.chips:void 0;if(s!==void 0&&i!==void 0){let e=t.resolveChipSpec(s,{...i,row:r,value:a,column:n,isActive:!1,isSelected:!1,isEditing:!1,readOnly:!1})?.label;if(e!==void 0)return e}return o},r=(e,t=!0)=>e.renderCell!==void 0||e.editor?.type!==`checkbox`&&(!t||e.conditionalFormat?.dataBar?.showValue!==!1),i=(e,t,n)=>{if(t.length===0||e.length===0)return[];let r=n?e:e.toLowerCase(),i=n?t:t.toLowerCase(),a=[],o=0;for(;o<=r.length-i.length;){let e=r.indexOf(i,o);if(e<0)break;a.push({start:e,length:i.length}),o=e+i.length}return a},a=e=>{let
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../utils/permissions.cjs"),t=require("./conditionalFormat.cjs");var n=(n,r,i)=>{let a=e.getCellValue(r,n),o=n.valueFormatter?n.valueFormatter({value:a,row:r,column:n}):String(a??``),s=n.renderCell===void 0?n.conditionalFormat?.chips:void 0;if(s!==void 0&&i!==void 0){let e=t.resolveChipSpec(s,{...i,row:r,value:a,column:n,isActive:!1,isSelected:!1,isEditing:!1,readOnly:!1})?.label;if(e!==void 0)return e}return o},r=(e,t=!0)=>e.renderCell!==void 0||e.editor?.type!==`checkbox`&&(!t||e.conditionalFormat?.dataBar?.showValue!==!1),i=(e,t,n)=>{if(t.length===0||e.length===0)return[];let r=n?e:e.toLowerCase(),i=n?t:t.toLowerCase(),a=[],o=0;for(;o<=r.length-i.length;){let e=r.indexOf(i,o);if(e<0)break;a.push({start:e,length:i.length}),o=e+i.length}return a},a=(e,t)=>{let n=new Map;return e.forEach((e,r)=>{let i=t?t(e.rowIndex):e.rowIndex;if(i<0)return;let a=n.get(i);a||(a=new Map,n.set(i,a));let o=a.get(e.colIndex);o||(o=[],a.set(e.colIndex,o)),o.push({start:e.start,length:e.length,matchIndex:r})}),n},o=(e,t)=>{let n=[],r=0;for(let i of t)i.start>r&&n.push({text:e.slice(r,i.start),range:null}),n.push({text:e.slice(i.start,i.start+i.length),range:i}),r=i.start+i.length;return r<e.length&&n.push({text:e.slice(r),range:null}),n},s=(e,t)=>{if(e.length===0)return null;if(t){let n=e.findIndex(e=>e.rowIndex===t.rowIndex&&e.colIndex===t.colIndex&&e.start===t.start);if(n>=0)return n}return 0},c=(e,t,n)=>t===0?null:e===null?n>0?0:t-1:(e+n+t)%t;exports.buildFindIndex=a,exports.findRangesInText=i,exports.isFindableColumn=r,exports.resolveCurrentAfterRescan=s,exports.resolveFindCellText=n,exports.splitTextByFindRanges=o,exports.stepFindIndex=c;
|
package/dist/logic/find.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ export declare const findRangesInText: (text: string, query: string, caseSensiti
|
|
|
19
19
|
start: number;
|
|
20
20
|
length: number;
|
|
21
21
|
}>;
|
|
22
|
-
export declare const buildFindIndex: (matches: readonly FindMatch[]) => FindIndex;
|
|
22
|
+
export declare const buildFindIndex: (matches: readonly FindMatch[], toViewRow?: ((rowIndex: number) => number) | undefined) => FindIndex;
|
|
23
23
|
export type FindTextSegment = {
|
|
24
24
|
text: string;
|
|
25
25
|
range: FindRange | null;
|