@ishibashi0112/spreadsheet-grid-core 1.6.0 → 1.8.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/changeTracker.cjs +1 -0
- package/dist/controllers/changeTracker.d.ts +38 -0
- package/dist/controllers/changeTracker.js +233 -0
- package/dist/controllers/editController.cjs +1 -1
- package/dist/controllers/editController.d.ts +3 -2
- package/dist/controllers/editController.js +171 -152
- package/dist/controllers/historyController.cjs +1 -1
- package/dist/controllers/historyController.d.ts +1 -0
- package/dist/controllers/historyController.js +18 -15
- package/dist/controllers/searchSelectEditorController.cjs +1 -0
- package/dist/controllers/searchSelectEditorController.d.ts +48 -0
- package/dist/controllers/searchSelectEditorController.js +188 -0
- package/dist/engine/createGridEngine.cjs +1 -1
- package/dist/engine/createGridEngine.d.ts +2 -0
- package/dist/engine/createGridEngine.js +19 -18
- package/dist/engine/features.cjs +1 -1
- package/dist/engine/features.d.ts +5 -0
- package/dist/engine/features.js +24 -1
- package/dist/engine/fullFeatures.cjs +1 -1
- package/dist/engine/fullFeatures.js +33 -31
- package/dist/engine/gridApi.cjs +8 -7
- package/dist/engine/gridApi.d.ts +3 -0
- package/dist/engine/gridApi.js +115 -83
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +4 -4
- package/dist/locales/en.cjs +1 -1
- package/dist/locales/en.js +12 -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/contextMenuTarget.cjs +1 -1
- package/dist/logic/contextMenuTarget.d.ts +4 -3
- package/dist/logic/contextMenuTarget.js +42 -36
- package/dist/logic/fillHandle.cjs +1 -1
- package/dist/logic/fillHandle.js +127 -118
- package/dist/logic/gridAsk.cjs +2 -2
- package/dist/logic/gridAsk.js +71 -71
- package/dist/logic/groupExport.cjs +1 -1
- package/dist/logic/groupExport.js +12 -12
- package/dist/logic/imeInput.cjs +1 -1
- package/dist/logic/imeInput.js +14 -13
- package/dist/logic/localeTextFeatures.cjs +1 -1
- package/dist/logic/localeTextFeatures.d.ts +16 -0
- package/dist/logic/localeTextFeatures.js +20 -6
- package/dist/logic/selectEditorState.cjs +1 -1
- package/dist/logic/selectEditorState.d.ts +16 -1
- package/dist/logic/selectEditorState.js +30 -21
- package/dist/logic/selectFillRow.cjs +1 -0
- package/dist/logic/selectFillRow.d.ts +4 -0
- package/dist/logic/selectFillRow.js +25 -0
- package/dist/logic/selectLabels.cjs +1 -1
- package/dist/logic/selectLabels.js +25 -22
- package/dist/logic/selectSearch.cjs +1 -0
- package/dist/logic/selectSearch.d.ts +27 -0
- package/dist/logic/selectSearch.js +102 -0
- package/dist/logic/validation.cjs +1 -1
- package/dist/logic/validation.js +13 -13
- package/dist/model/gridTypes.core.d.ts +201 -9
- package/dist/model/gridTypes.unbound.d.ts +1 -0
- package/dist/utils/clipboard.cjs +1 -1
- package/dist/utils/clipboard.js +65 -65
- package/dist/utils/editorVisibleBounds.cjs +1 -1
- package/dist/utils/editorVisibleBounds.d.ts +4 -0
- package/dist/utils/editorVisibleBounds.js +12 -2
- package/dist/utils/overflowTitle.cjs +1 -0
- package/dist/utils/overflowTitle.d.ts +1 -0
- package/dist/utils/overflowTitle.js +7 -0
- 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/cellNote.js
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
//#region src/logic/cellNote.ts
|
|
2
|
-
var e = (e) => typeof e == "string" && e.trim() !== "" ? e : null, t = (e, t
|
|
2
|
+
var e = (e) => typeof e == "string" && e.trim() !== "" ? e : null, t = (e, t, n = null) => {
|
|
3
|
+
let r = null;
|
|
4
|
+
for (let i of [
|
|
5
|
+
e,
|
|
6
|
+
t,
|
|
7
|
+
n
|
|
8
|
+
]) i !== null && (r = r === null ? i : `${r}\n${i}`);
|
|
9
|
+
return r;
|
|
10
|
+
};
|
|
3
11
|
//#endregion
|
|
4
12
|
export { e as normalizeCellNote, t as resolveCellTooltipText };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../utils/permissions.cjs"),t=require("./checkboxEditor.cjs"),n=require("./localeTextFilters.cjs");var r=e=>!(e.getValue&&!e.setValue),i=e=>{let t=new Map;for(let n of e)r(n)&&!t.has(n.key)&&t.set(n.key,n);return t},a=(e,t)=>{let n=null;return r=>{if(n===null){n=new Map;for(let r=0;r<e.length;r+=1){let i=e[r];i!==void 0&&!n.has(t(i,r))&&n.set(t(i,r),r)}}return n.get(r)}},o=(e,t)=>{let n=a(e,t);return(r,i)=>{let a=e[i];return a!==void 0&&t(a,i)===r?i:n(r)}},s=(e,t,n,r,i)=>{if(t===n||i.size===0)return 0;let o=a(t,r),s=null,c=[],l=[];for(let[e,t]of i)c.push(e),l.push(t.getValue);let u=c.length,d=0;for(let i=0;i<n.length;i+=1){let a=n[i];if(a===void 0||a===t[i])continue;let f=r(a,i),p=t[i],m;if(p!==void 0&&r(p,i)===f)m=p;else{if(s??=new Set(t),s.has(a))continue;let e=o(f);m=e===void 0?void 0:t[e]}if(m===void 0)continue;let h=e.get(f)?.saved,g=null;for(let e=0;e<u;e+=1){let t=c[e],n=l[e],r=n?n(m):m[t],i=n?n(a):a[t];Object.is(r,i)||h?.has(t)||(g??=new Map(h),g.set(t,r))}g!==null&&(e.set(f,{saved:g,index:i,present:!0}),d+=1)}return d},c=new WeakMap,l=e=>{let t=c.get(e);if(!t){t=new Map;for(let n of e.keys())t.set(n,t.size);c.set(e,t)}return t},u=(t,n,r)=>{let i=[];for(let[a,o]of n){let n=r.get(a);n&&!Object.is(e.getCellValue(t,n),o)&&i.push(a)}if(i.length>1){let e=l(r);i.sort((t,n)=>(e.get(t)??0)-(e.get(n)??0))}return i},d=(t,n,r)=>r!==void 0&&r.has(n.key)&&!Object.is(e.getCellValue(t,n),r.get(n.key)),f=(t,n,r)=>{if(n===void 0)return!1;for(let[i,a]of n){let n=r.get(i);if(n&&!Object.is(e.getCellValue(t,n),a))return!0}return!1},p=(t,n,r,i,a)=>{if(t.size===0)return!1;let s=o(n,r),c=!1;for(let[r,o]of t){let l=s(r,o.index),u=l===void 0?void 0:n[l];if(l===void 0||u===void 0){a?o.present&&(t.set(r,{...o,present:!1}),c=!0):(t.delete(r),c=!0);continue}if(!o.present&&!a){t.delete(r),c=!0;continue}let d=null;for(let[t,n]of o.saved){let r=i.get(t);(!r||Object.is(e.getCellValue(u,r),n))&&(d??=new Map(o.saved),d.delete(t))}d!==null&&d.size===0?(t.delete(r),c=!0):(d!==null||l!==o.index||!o.present)&&(t.set(r,{saved:d??o.saved,index:l,present:!0}),c=c||d!==null||!o.present)}return c},m=e=>{let t=0,n=0;for(let r of e.values())r.present&&r.saved.size>0&&(t+=1,n+=r.saved.size);return{rowCount:t,cellCount:n}},h=(t,n,r,i)=>{let a=e.createCellWriteDraft(t);for(let t of r){let r=i.get(t);r&&e.writeCellValue(a,r,n.get(t))}return a.row},g={cell:`ssg-revert-cell`,row:`ssg-revert-row`,selection:`ssg-revert-selection`},_=e=>{let{selection:t,rowModel:n,orderedColumns:r,getUnsavedCells:i,trackedColumns:a}=e;if(!t)return[];let o=n.getRowCount(),s=0,c=o-1,l=0,d=r.length-1;t.type===`cell`?(s=Math.min(t.range.start.row,t.range.end.row),c=Math.max(t.range.start.row,t.range.end.row),l=Math.min(t.range.start.col,t.range.end.col),d=Math.max(t.range.start.col,t.range.end.col)):t.type===`row`?(s=Math.min(t.startRow,t.endRow),c=Math.max(t.startRow,t.endRow)):(l=Math.min(t.startCol,t.endCol),d=Math.max(t.startCol,t.endCol));let f=new Set;for(let e=Math.max(l,0);e<=d;e+=1){let t=r[e];t&&a.has(t.key)&&f.add(t.key)}let p=[];if(f.size===0)return p;for(let e=Math.max(s,0);e<=Math.min(c,o-1);e+=1){let t=n.getRow(e);if(t===void 0)continue;let r=n.getRowKey(e),o=i(r);if(o!==void 0)for(let e of u(t,o,a))f.has(e)&&p.push({rowKey:r,columnKey:e})}return p},v=e=>{let{target:t,getUnsavedCells:n,trackedColumns:r,revert:i,texts:a}=e,o=[],s=n(t.rowKey),c=s===void 0?[]:u(t.row,s,r),l=t.type===`cell`?t.column.key:void 0,d=l!==void 0&&c.includes(l);d&&o.push({id:g.cell,label:a.revertCellChanges,onSelect:()=>i([{rowKey:t.rowKey,columnKey:l}])});let f=c.length>+!!d;if(f&&o.push({id:g.row,label:a.revertRowChanges,onSelect:()=>i([{rowKey:t.rowKey}])}),e.isTargetSelected){let n=_(e),r=n.some(e=>e.rowKey!==t.rowKey||l!==void 0&&e.columnKey!==l),s=f&&n.length===c.length&&n.every(e=>e.rowKey===t.rowKey);r&&!s&&o.push({id:g.selection,label:a.revertSelectionChanges,onSelect:()=>i(n)})}return o},y=(e,r,i,a)=>{let o;return o=e.valueFormatter?e.valueFormatter({value:i,row:r,column:e}):e.editor?.type===`checkbox`?t.isCheckboxChecked(i,e.editor)?a.unsavedChecked:a.unsavedUnchecked:String(i??``),n.formatLocaleText(a.unsavedCell,{value:o.trim()===``?a.unsavedEmptyValue:o})},b=(e,t)=>e&&e.cellCount>0?n.formatLocaleText(t.unsavedChanges,{rows:e.rowCount,cells:e.cellCount}):null;exports.buildOriginalRow=h,exports.buildRevertMenuItems=v,exports.countUnsaved=m,exports.createRowLocator=o,exports.describeUnsavedCell=y,exports.formatUnsavedSummary=b,exports.hasUnsavedCells=f,exports.isTrackedColumn=r,exports.isUnsavedCell=d,exports.reconcileUnsavedRecords=p,exports.recordGridRowsChange=s,exports.resolveTrackedColumns=i,exports.resolveUnsavedColumnKeys=u;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { GridColumn, GridContextMenuItem, GridContextMenuTarget, GridRowKey, GridSelection, RowModel } from '../model/gridTypes.unbound.js';
|
|
2
|
+
import { type FeatureLocaleText } from './localeText.js';
|
|
3
|
+
import type { DEFAULT_CHANGE_TRACKING_LOCALE_TEXT } from './localeTextFeatures.js';
|
|
4
|
+
export type UnsavedCells = ReadonlyMap<string, unknown>;
|
|
5
|
+
export type UnsavedRowRecord = {
|
|
6
|
+
saved: UnsavedCells;
|
|
7
|
+
index: number;
|
|
8
|
+
present: boolean;
|
|
9
|
+
};
|
|
10
|
+
export type UnsavedRecords = Map<GridRowKey, UnsavedRowRecord>;
|
|
11
|
+
export declare const isTrackedColumn: <T>(column: GridColumn<T>) => boolean;
|
|
12
|
+
export declare const resolveTrackedColumns: <T>(columns: readonly GridColumn<T>[]) => Map<string, GridColumn<T>>;
|
|
13
|
+
type RowKeyGetter<T> = (row: T, index: number) => GridRowKey;
|
|
14
|
+
export declare const createRowLocator: <T>(rows: readonly T[], rowKeyGetter: RowKeyGetter<T>) => (key: GridRowKey, hint: number) => number | undefined;
|
|
15
|
+
export declare const recordGridRowsChange: <T>(records: UnsavedRecords, prev: readonly T[], next: readonly T[], rowKeyGetter: RowKeyGetter<T>, trackedColumns: ReadonlyMap<string, GridColumn<T>>) => number;
|
|
16
|
+
export declare const resolveUnsavedColumnKeys: <T>(row: T, saved: UnsavedCells, trackedColumns: ReadonlyMap<string, GridColumn<T>>) => string[];
|
|
17
|
+
export declare const isUnsavedCell: <T>(row: T, column: GridColumn<T>, saved: UnsavedCells | undefined) => boolean;
|
|
18
|
+
export declare const hasUnsavedCells: <T>(row: T, saved: UnsavedCells | undefined, columnsByKey: ReadonlyMap<string, GridColumn<T>>) => boolean;
|
|
19
|
+
export declare const reconcileUnsavedRecords: <T>(records: UnsavedRecords, rows: readonly T[], rowKeyGetter: RowKeyGetter<T>, trackedColumns: ReadonlyMap<string, GridColumn<T>>, keepDetached: boolean) => boolean;
|
|
20
|
+
export declare const countUnsaved: (records: UnsavedRecords) => {
|
|
21
|
+
rowCount: number;
|
|
22
|
+
cellCount: number;
|
|
23
|
+
};
|
|
24
|
+
export declare const buildOriginalRow: <T>(row: T, saved: UnsavedCells, columnKeys: readonly string[], trackedColumns: ReadonlyMap<string, GridColumn<T>>) => T;
|
|
25
|
+
export type RevertTargetInput = {
|
|
26
|
+
rowKey: GridRowKey;
|
|
27
|
+
columnKey?: string | undefined;
|
|
28
|
+
};
|
|
29
|
+
export type RevertMenuInput<T> = {
|
|
30
|
+
target: GridContextMenuTarget<T>;
|
|
31
|
+
isTargetSelected: boolean;
|
|
32
|
+
selection: GridSelection;
|
|
33
|
+
rowModel: RowModel<T>;
|
|
34
|
+
orderedColumns: readonly GridColumn<T>[];
|
|
35
|
+
getUnsavedCells: (rowKey: GridRowKey) => UnsavedCells | undefined;
|
|
36
|
+
trackedColumns: ReadonlyMap<string, GridColumn<T>>;
|
|
37
|
+
revert: (targets: readonly RevertTargetInput[]) => void;
|
|
38
|
+
texts: {
|
|
39
|
+
revertCellChanges: string;
|
|
40
|
+
revertRowChanges: string;
|
|
41
|
+
revertSelectionChanges: string;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
export declare const buildRevertMenuItems: <T>(input: RevertMenuInput<T>) => GridContextMenuItem[];
|
|
45
|
+
export type ChangeTrackingTexts = FeatureLocaleText<typeof DEFAULT_CHANGE_TRACKING_LOCALE_TEXT>;
|
|
46
|
+
export declare const describeUnsavedCell: <T>(column: GridColumn<T>, row: T, savedValue: unknown, texts: ChangeTrackingTexts) => string;
|
|
47
|
+
export declare const formatUnsavedSummary: (summary: {
|
|
48
|
+
rowCount: number;
|
|
49
|
+
cellCount: number;
|
|
50
|
+
} | null | undefined, texts: ChangeTrackingTexts) => string | null;
|
|
51
|
+
export {};
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { createCellWriteDraft as e, getCellValue as t, writeCellValue as n } from "../utils/permissions.js";
|
|
2
|
+
import { isCheckboxChecked as r } from "./checkboxEditor.js";
|
|
3
|
+
import { formatLocaleText as i } from "./localeTextFilters.js";
|
|
4
|
+
//#region src/logic/changeTracking.ts
|
|
5
|
+
var a = (e) => !(e.getValue && !e.setValue), o = (e) => {
|
|
6
|
+
let t = /* @__PURE__ */ new Map();
|
|
7
|
+
for (let n of e) a(n) && !t.has(n.key) && t.set(n.key, n);
|
|
8
|
+
return t;
|
|
9
|
+
}, s = (e, t) => {
|
|
10
|
+
let n = null;
|
|
11
|
+
return (r) => {
|
|
12
|
+
if (n === null) {
|
|
13
|
+
n = /* @__PURE__ */ new Map();
|
|
14
|
+
for (let r = 0; r < e.length; r += 1) {
|
|
15
|
+
let i = e[r];
|
|
16
|
+
i !== void 0 && !n.has(t(i, r)) && n.set(t(i, r), r);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return n.get(r);
|
|
20
|
+
};
|
|
21
|
+
}, c = (e, t) => {
|
|
22
|
+
let n = s(e, t);
|
|
23
|
+
return (r, i) => {
|
|
24
|
+
let a = e[i];
|
|
25
|
+
return a !== void 0 && t(a, i) === r ? i : n(r);
|
|
26
|
+
};
|
|
27
|
+
}, l = (e, t, n, r, i) => {
|
|
28
|
+
if (t === n || i.size === 0) return 0;
|
|
29
|
+
let a = s(t, r), o = null, c = [], l = [];
|
|
30
|
+
for (let [e, t] of i) c.push(e), l.push(t.getValue);
|
|
31
|
+
let u = c.length, d = 0;
|
|
32
|
+
for (let i = 0; i < n.length; i += 1) {
|
|
33
|
+
let s = n[i];
|
|
34
|
+
if (s === void 0 || s === t[i]) continue;
|
|
35
|
+
let f = r(s, i), p = t[i], m;
|
|
36
|
+
if (p !== void 0 && r(p, i) === f) m = p;
|
|
37
|
+
else {
|
|
38
|
+
if (o ??= new Set(t), o.has(s)) continue;
|
|
39
|
+
let e = a(f);
|
|
40
|
+
m = e === void 0 ? void 0 : t[e];
|
|
41
|
+
}
|
|
42
|
+
if (m === void 0) continue;
|
|
43
|
+
let h = e.get(f)?.saved, g = null;
|
|
44
|
+
for (let e = 0; e < u; e += 1) {
|
|
45
|
+
let t = c[e], n = l[e], r = n ? n(m) : m[t], i = n ? n(s) : s[t];
|
|
46
|
+
Object.is(r, i) || h?.has(t) || (g ??= new Map(h), g.set(t, r));
|
|
47
|
+
}
|
|
48
|
+
g !== null && (e.set(f, {
|
|
49
|
+
saved: g,
|
|
50
|
+
index: i,
|
|
51
|
+
present: !0
|
|
52
|
+
}), d += 1);
|
|
53
|
+
}
|
|
54
|
+
return d;
|
|
55
|
+
}, u = /* @__PURE__ */ new WeakMap(), d = (e) => {
|
|
56
|
+
let t = u.get(e);
|
|
57
|
+
if (!t) {
|
|
58
|
+
t = /* @__PURE__ */ new Map();
|
|
59
|
+
for (let n of e.keys()) t.set(n, t.size);
|
|
60
|
+
u.set(e, t);
|
|
61
|
+
}
|
|
62
|
+
return t;
|
|
63
|
+
}, f = (e, n, r) => {
|
|
64
|
+
let i = [];
|
|
65
|
+
for (let [a, o] of n) {
|
|
66
|
+
let n = r.get(a);
|
|
67
|
+
n && !Object.is(t(e, n), o) && i.push(a);
|
|
68
|
+
}
|
|
69
|
+
if (i.length > 1) {
|
|
70
|
+
let e = d(r);
|
|
71
|
+
i.sort((t, n) => (e.get(t) ?? 0) - (e.get(n) ?? 0));
|
|
72
|
+
}
|
|
73
|
+
return i;
|
|
74
|
+
}, p = (e, n, r) => r !== void 0 && r.has(n.key) && !Object.is(t(e, n), r.get(n.key)), m = (e, n, r) => {
|
|
75
|
+
if (n === void 0) return !1;
|
|
76
|
+
for (let [i, a] of n) {
|
|
77
|
+
let n = r.get(i);
|
|
78
|
+
if (n && !Object.is(t(e, n), a)) return !0;
|
|
79
|
+
}
|
|
80
|
+
return !1;
|
|
81
|
+
}, h = (e, n, r, i, a) => {
|
|
82
|
+
if (e.size === 0) return !1;
|
|
83
|
+
let o = c(n, r), s = !1;
|
|
84
|
+
for (let [r, c] of e) {
|
|
85
|
+
let l = o(r, c.index), u = l === void 0 ? void 0 : n[l];
|
|
86
|
+
if (l === void 0 || u === void 0) {
|
|
87
|
+
a ? c.present && (e.set(r, {
|
|
88
|
+
...c,
|
|
89
|
+
present: !1
|
|
90
|
+
}), s = !0) : (e.delete(r), s = !0);
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
if (!c.present && !a) {
|
|
94
|
+
e.delete(r), s = !0;
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
let d = null;
|
|
98
|
+
for (let [e, n] of c.saved) {
|
|
99
|
+
let r = i.get(e);
|
|
100
|
+
(!r || Object.is(t(u, r), n)) && (d ??= new Map(c.saved), d.delete(e));
|
|
101
|
+
}
|
|
102
|
+
d !== null && d.size === 0 ? (e.delete(r), s = !0) : (d !== null || l !== c.index || !c.present) && (e.set(r, {
|
|
103
|
+
saved: d ?? c.saved,
|
|
104
|
+
index: l,
|
|
105
|
+
present: !0
|
|
106
|
+
}), s = s || d !== null || !c.present);
|
|
107
|
+
}
|
|
108
|
+
return s;
|
|
109
|
+
}, g = (e) => {
|
|
110
|
+
let t = 0, n = 0;
|
|
111
|
+
for (let r of e.values()) r.present && r.saved.size > 0 && (t += 1, n += r.saved.size);
|
|
112
|
+
return {
|
|
113
|
+
rowCount: t,
|
|
114
|
+
cellCount: n
|
|
115
|
+
};
|
|
116
|
+
}, _ = (t, r, i, a) => {
|
|
117
|
+
let o = e(t);
|
|
118
|
+
for (let e of i) {
|
|
119
|
+
let t = a.get(e);
|
|
120
|
+
t && n(o, t, r.get(e));
|
|
121
|
+
}
|
|
122
|
+
return o.row;
|
|
123
|
+
}, v = {
|
|
124
|
+
cell: "ssg-revert-cell",
|
|
125
|
+
row: "ssg-revert-row",
|
|
126
|
+
selection: "ssg-revert-selection"
|
|
127
|
+
}, y = (e) => {
|
|
128
|
+
let { selection: t, rowModel: n, orderedColumns: r, getUnsavedCells: i, trackedColumns: a } = e;
|
|
129
|
+
if (!t) return [];
|
|
130
|
+
let o = n.getRowCount(), s = 0, c = o - 1, l = 0, u = r.length - 1;
|
|
131
|
+
t.type === "cell" ? (s = Math.min(t.range.start.row, t.range.end.row), c = Math.max(t.range.start.row, t.range.end.row), l = Math.min(t.range.start.col, t.range.end.col), u = Math.max(t.range.start.col, t.range.end.col)) : t.type === "row" ? (s = Math.min(t.startRow, t.endRow), c = Math.max(t.startRow, t.endRow)) : (l = Math.min(t.startCol, t.endCol), u = Math.max(t.startCol, t.endCol));
|
|
132
|
+
let d = /* @__PURE__ */ new Set();
|
|
133
|
+
for (let e = Math.max(l, 0); e <= u; e += 1) {
|
|
134
|
+
let t = r[e];
|
|
135
|
+
t && a.has(t.key) && d.add(t.key);
|
|
136
|
+
}
|
|
137
|
+
let p = [];
|
|
138
|
+
if (d.size === 0) return p;
|
|
139
|
+
for (let e = Math.max(s, 0); e <= Math.min(c, o - 1); e += 1) {
|
|
140
|
+
let t = n.getRow(e);
|
|
141
|
+
if (t === void 0) continue;
|
|
142
|
+
let r = n.getRowKey(e), o = i(r);
|
|
143
|
+
if (o !== void 0) for (let e of f(t, o, a)) d.has(e) && p.push({
|
|
144
|
+
rowKey: r,
|
|
145
|
+
columnKey: e
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
return p;
|
|
149
|
+
}, b = (e) => {
|
|
150
|
+
let { target: t, getUnsavedCells: n, trackedColumns: r, revert: i, texts: a } = e, o = [], s = n(t.rowKey), c = s === void 0 ? [] : f(t.row, s, r), l = t.type === "cell" ? t.column.key : void 0, u = l !== void 0 && c.includes(l);
|
|
151
|
+
u && o.push({
|
|
152
|
+
id: v.cell,
|
|
153
|
+
label: a.revertCellChanges,
|
|
154
|
+
onSelect: () => i([{
|
|
155
|
+
rowKey: t.rowKey,
|
|
156
|
+
columnKey: l
|
|
157
|
+
}])
|
|
158
|
+
});
|
|
159
|
+
let d = c.length > +!!u;
|
|
160
|
+
if (d && o.push({
|
|
161
|
+
id: v.row,
|
|
162
|
+
label: a.revertRowChanges,
|
|
163
|
+
onSelect: () => i([{ rowKey: t.rowKey }])
|
|
164
|
+
}), e.isTargetSelected) {
|
|
165
|
+
let n = y(e), r = n.some((e) => e.rowKey !== t.rowKey || l !== void 0 && e.columnKey !== l), s = d && n.length === c.length && n.every((e) => e.rowKey === t.rowKey);
|
|
166
|
+
r && !s && o.push({
|
|
167
|
+
id: v.selection,
|
|
168
|
+
label: a.revertSelectionChanges,
|
|
169
|
+
onSelect: () => i(n)
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
return o;
|
|
173
|
+
}, x = (e, t, n, a) => {
|
|
174
|
+
let o;
|
|
175
|
+
return o = e.valueFormatter ? e.valueFormatter({
|
|
176
|
+
value: n,
|
|
177
|
+
row: t,
|
|
178
|
+
column: e
|
|
179
|
+
}) : e.editor?.type === "checkbox" ? r(n, e.editor) ? a.unsavedChecked : a.unsavedUnchecked : String(n ?? ""), i(a.unsavedCell, { value: o.trim() === "" ? a.unsavedEmptyValue : o });
|
|
180
|
+
}, S = (e, t) => e && e.cellCount > 0 ? i(t.unsavedChanges, {
|
|
181
|
+
rows: e.rowCount,
|
|
182
|
+
cells: e.cellCount
|
|
183
|
+
}) : null;
|
|
184
|
+
//#endregion
|
|
185
|
+
export { _ as buildOriginalRow, b as buildRevertMenuItems, g as countUnsaved, c as createRowLocator, x as describeUnsavedCell, S as formatUnsavedSummary, m as hasUnsavedCells, a as isTrackedColumn, p as isUnsavedCell, h as reconcileUnsavedRecords, l as recordGridRowsChange, o as resolveTrackedColumns, f as resolveUnsavedColumnKeys };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../utils/permissions.cjs"),t=require("../model/gridSelectors.cjs"),n=require("./geometry.cjs"),r=require("./editorValues.cjs"),i=require("./validation.cjs");var a=(e,r,i,a)=>{if(i===0||a===0)return null;let o=i-1,s=a-1;if(e?.type===`cell`){let r=t.normalizeCellRange(e.range);return{startRow:n.clamp(r.start.row,0,o),endRow:n.clamp(r.end.row,0,o),startCol:n.clamp(r.start.col,0,s),endCol:n.clamp(r.end.col,0,s)}}if(e?.type===`row`){let r=t.normalizeRowRange(e.startRow,e.endRow);return{startRow:n.clamp(r.startRow,0,o),endRow:n.clamp(r.endRow,0,o),startCol:0,endCol:s}}if(e?.type===`col`){let r=t.normalizeColumnRange(e.startCol,e.endCol);return{startRow:0,endRow:o,startCol:n.clamp(r.startCol,0,s),endCol:n.clamp(r.endCol,0,s)}}return r?r.row>o||r.col>s?null:{startRow:r.row,endRow:r.row,startCol:r.col,endCol:r.col}:null},o=({rows:t,resolveSourceIndex:n,columns:
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../utils/permissions.cjs"),t=require("../model/gridSelectors.cjs"),n=require("./geometry.cjs"),r=require("./editorValues.cjs"),i=require("./validation.cjs");var a=(e,r,i,a)=>{if(i===0||a===0)return null;let o=i-1,s=a-1;if(e?.type===`cell`){let r=t.normalizeCellRange(e.range);return{startRow:n.clamp(r.start.row,0,o),endRow:n.clamp(r.end.row,0,o),startCol:n.clamp(r.start.col,0,s),endCol:n.clamp(r.end.col,0,s)}}if(e?.type===`row`){let r=t.normalizeRowRange(e.startRow,e.endRow);return{startRow:n.clamp(r.startRow,0,o),endRow:n.clamp(r.endRow,0,o),startCol:0,endCol:s}}if(e?.type===`col`){let r=t.normalizeColumnRange(e.startCol,e.endCol);return{startRow:0,endRow:o,startCol:n.clamp(r.startCol,0,s),endCol:n.clamp(r.endCol,0,s)}}return r?r.row>o||r.col>s?null:{startRow:r.row,endRow:r.row,startCol:r.col,endCol:r.col}:null},o=e=>e==null||e===``,s=({rows:t,resolveSourceIndex:n,columns:s,selection:c,activeCell:l,viewRowCount:u,canWriteCell:d})=>{let f=a(c,l,u,s.length);if(!f)return{nextRows:t,changed:!1};let p=[...t],m=!1;for(let t=f.startRow;t<=f.endRow;t+=1){let a=n(t);if(a===void 0)continue;let c=p[a];if(!c)continue;let l=e.createCellWriteDraft(c),u=!1;for(let n=f.startCol;n<=f.endCol;n+=1){let f=s[n];if(!f||!d(a,n,c,f,t))continue;let p=r.resolveCellParser(f)(``,c),m=e.getCellValue(l.row,f);Object.is(m,p)||o(m)&&o(p)||i.decideCellWrite(f,c,p).action!==`reject`&&(e.writeCellValue(l,f,p),u=!0)}u&&(p[a]=l.row,m=!0)}return m?{nextRows:p,changed:m}:{nextRows:t,changed:!1}},c=({getRow:t,columns:n,selection:s,activeCell:c,viewRowCount:l,canWriteCell:u})=>{let d=a(s,c,l,n.length);if(!d)return[];let f=[];for(let a=d.startRow;a<=d.endRow;a+=1){let s=t(a);if(s)for(let t=d.startCol;t<=d.endCol;t+=1){let c=n[t];if(!c||!u(a,t,s,c))continue;let l=r.resolveCellParser(c)(``,s),d=e.getCellValue(s,c);Object.is(d,l)||o(d)&&o(l)||i.decideCellWrite(c,s,l).action!==`reject`&&f.push({viewIndex:a,column:c,value:l})}}return f};exports.buildClearCellEdits=c,exports.clearCellsInSelection=s,exports.resolveClearTarget=a;
|
package/dist/logic/clearCells.js
CHANGED
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { normalizeCellRange as
|
|
3
|
-
import { clamp as
|
|
4
|
-
import { resolveCellParser as
|
|
5
|
-
import { decideCellWrite as
|
|
1
|
+
import { createCellWriteDraft as e, getCellValue as t, writeCellValue as n } from "../utils/permissions.js";
|
|
2
|
+
import { normalizeCellRange as r, normalizeColumnRange as i, normalizeRowRange as a } from "../model/gridSelectors.js";
|
|
3
|
+
import { clamp as o } from "./geometry.js";
|
|
4
|
+
import { resolveCellParser as s } from "./editorValues.js";
|
|
5
|
+
import { decideCellWrite as c } from "./validation.js";
|
|
6
6
|
//#region src/logic/clearCells.ts
|
|
7
|
-
var
|
|
8
|
-
if (
|
|
9
|
-
let c =
|
|
7
|
+
var l = (e, t, n, s) => {
|
|
8
|
+
if (n === 0 || s === 0) return null;
|
|
9
|
+
let c = n - 1, l = s - 1;
|
|
10
10
|
if (e?.type === "cell") {
|
|
11
|
-
let t =
|
|
11
|
+
let t = r(e.range);
|
|
12
12
|
return {
|
|
13
|
-
startRow:
|
|
14
|
-
endRow:
|
|
15
|
-
startCol:
|
|
16
|
-
endCol:
|
|
13
|
+
startRow: o(t.start.row, 0, c),
|
|
14
|
+
endRow: o(t.end.row, 0, c),
|
|
15
|
+
startCol: o(t.start.col, 0, l),
|
|
16
|
+
endCol: o(t.end.col, 0, l)
|
|
17
17
|
};
|
|
18
18
|
}
|
|
19
19
|
if (e?.type === "row") {
|
|
20
|
-
let t =
|
|
20
|
+
let t = a(e.startRow, e.endRow);
|
|
21
21
|
return {
|
|
22
|
-
startRow:
|
|
23
|
-
endRow:
|
|
22
|
+
startRow: o(t.startRow, 0, c),
|
|
23
|
+
endRow: o(t.endRow, 0, c),
|
|
24
24
|
startCol: 0,
|
|
25
25
|
endCol: l
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
28
|
if (e?.type === "col") {
|
|
29
|
-
let t =
|
|
29
|
+
let t = i(e.startCol, e.endCol);
|
|
30
30
|
return {
|
|
31
31
|
startRow: 0,
|
|
32
32
|
endRow: c,
|
|
33
|
-
startCol:
|
|
34
|
-
endCol:
|
|
33
|
+
startCol: o(t.startCol, 0, l),
|
|
34
|
+
endCol: o(t.endCol, 0, l)
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
37
|
return t ? t.row > c || t.col > l ? null : {
|
|
@@ -40,52 +40,52 @@ var c = (e, t, o, s) => {
|
|
|
40
40
|
startCol: t.col,
|
|
41
41
|
endCol: t.col
|
|
42
42
|
} : null;
|
|
43
|
-
},
|
|
44
|
-
let
|
|
45
|
-
if (!
|
|
46
|
-
nextRows:
|
|
43
|
+
}, u = (e) => e == null || e === "", d = ({ rows: r, resolveSourceIndex: i, columns: a, selection: o, activeCell: d, viewRowCount: f, canWriteCell: p }) => {
|
|
44
|
+
let m = l(o, d, f, a.length);
|
|
45
|
+
if (!m) return {
|
|
46
|
+
nextRows: r,
|
|
47
47
|
changed: !1
|
|
48
48
|
};
|
|
49
|
-
let
|
|
50
|
-
for (let
|
|
51
|
-
let
|
|
52
|
-
if (
|
|
53
|
-
let
|
|
54
|
-
if (!
|
|
55
|
-
let
|
|
56
|
-
for (let
|
|
57
|
-
let
|
|
58
|
-
if (!
|
|
59
|
-
let
|
|
60
|
-
Object.is(
|
|
49
|
+
let h = [...r], g = !1;
|
|
50
|
+
for (let r = m.startRow; r <= m.endRow; r += 1) {
|
|
51
|
+
let o = i(r);
|
|
52
|
+
if (o === void 0) continue;
|
|
53
|
+
let l = h[o];
|
|
54
|
+
if (!l) continue;
|
|
55
|
+
let d = e(l), f = !1;
|
|
56
|
+
for (let e = m.startCol; e <= m.endCol; e += 1) {
|
|
57
|
+
let i = a[e];
|
|
58
|
+
if (!i || !p(o, e, l, i, r)) continue;
|
|
59
|
+
let m = s(i)("", l), h = t(d.row, i);
|
|
60
|
+
Object.is(h, m) || u(h) && u(m) || c(i, l, m).action !== "reject" && (n(d, i, m), f = !0);
|
|
61
61
|
}
|
|
62
|
-
|
|
62
|
+
f && (h[o] = d.row, g = !0);
|
|
63
63
|
}
|
|
64
|
-
return
|
|
65
|
-
nextRows:
|
|
66
|
-
changed:
|
|
64
|
+
return g ? {
|
|
65
|
+
nextRows: h,
|
|
66
|
+
changed: g
|
|
67
67
|
} : {
|
|
68
|
-
nextRows:
|
|
68
|
+
nextRows: r,
|
|
69
69
|
changed: !1
|
|
70
70
|
};
|
|
71
|
-
},
|
|
72
|
-
let
|
|
73
|
-
if (!
|
|
74
|
-
let
|
|
75
|
-
for (let r =
|
|
76
|
-
let i =
|
|
77
|
-
if (i) for (let
|
|
78
|
-
let a = n[
|
|
79
|
-
if (!a || !
|
|
80
|
-
let
|
|
81
|
-
Object.is(
|
|
71
|
+
}, f = ({ getRow: e, columns: n, selection: r, activeCell: i, viewRowCount: a, canWriteCell: o }) => {
|
|
72
|
+
let d = l(r, i, a, n.length);
|
|
73
|
+
if (!d) return [];
|
|
74
|
+
let f = [];
|
|
75
|
+
for (let r = d.startRow; r <= d.endRow; r += 1) {
|
|
76
|
+
let i = e(r);
|
|
77
|
+
if (i) for (let e = d.startCol; e <= d.endCol; e += 1) {
|
|
78
|
+
let a = n[e];
|
|
79
|
+
if (!a || !o(r, e, i, a)) continue;
|
|
80
|
+
let l = s(a)("", i), d = t(i, a);
|
|
81
|
+
Object.is(d, l) || u(d) && u(l) || c(a, i, l).action !== "reject" && f.push({
|
|
82
82
|
viewIndex: r,
|
|
83
83
|
column: a,
|
|
84
|
-
value:
|
|
84
|
+
value: l
|
|
85
85
|
});
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
|
-
return
|
|
88
|
+
return f;
|
|
89
89
|
};
|
|
90
90
|
//#endregion
|
|
91
|
-
export {
|
|
91
|
+
export { f as buildClearCellEdits, d as clearCellsInSelection, l as resolveClearTarget };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../utils/permissions.cjs");var t=(e,t)=>e.findIndex(e=>e.key===t),n=(e,t,n)=>{if(!e)return!1;if(e.type===`row`)return t>=e.startRow&&t<=e.endRow;if(e.type===`col`)return n>=e.startCol&&n<=e.endCol;let{start:r,end:i}=e.range,a=Math.min(r.row,i.row),o=Math.max(r.row,i.row),s=Math.min(r.col,i.col),c=Math.max(r.col,i.col);return t>=a&&t<=o&&n>=s&&n<=c},r=(e,t)=>{if(!e)return!1;if(e.type===`row`)return t>=e.startRow&&t<=e.endRow;if(e.type===`cell`){let{start:n,end:r}=e.range,i=Math.min(n.row,r.row),a=Math.max(n.row,r.row);return t>=i&&t<=a}return!1},i=({cell:t,clientX:r,clientY:i,rowModel:a,orderedColumns:o,selection:s,activeCell:c})=>{let
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../utils/permissions.cjs");var t=(e,t)=>e.findIndex(e=>e.key===t),n=(e,t,n)=>{if(!e)return!1;if(e.type===`row`)return t>=e.startRow&&t<=e.endRow;if(e.type===`col`)return n>=e.startCol&&n<=e.endCol;let{start:r,end:i}=e.range,a=Math.min(r.row,i.row),o=Math.max(r.row,i.row),s=Math.min(r.col,i.col),c=Math.max(r.col,i.col);return t>=a&&t<=o&&n>=s&&n<=c},r=(e,t)=>{if(!e)return!1;if(e.type===`row`)return t>=e.startRow&&t<=e.endRow;if(e.type===`cell`){let{start:n,end:r}=e.range,i=Math.min(n.row,r.row),a=Math.max(n.row,r.row);return t>=i&&t<=a}return!1},i=({cell:t,clientX:r,clientY:i,rowModel:a,orderedColumns:o,selection:s,activeCell:c,resolveRevertItems:l})=>{let u=t.row,d=t.col,f=a.getRow(u),p=o[d];if(!f||!p)return null;let m={type:`cell`,rowIndex:u,colIndex:d,rowKey:a.getRowKey(u)??u,row:f,column:p,value:e.getCellValue(f,p)},h=n(s,u,d);return{target:m,clientX:r,clientY:i,selection:s,activeCell:c,isTargetSelected:h,revertItems:l?.(m,h)??[]}},a=({event:e,rowModel:n,orderedColumns:a,selection:o,activeCell:s,resolveRevertItems:c})=>{let l=e.target;if(!l||typeof l.closest!=`function`)return null;let u=l.closest(`[data-row-index]`);if(!u)return null;let d=u.dataset.rowIndex;if(d===void 0)return null;let f=Number(d);if(!Number.isInteger(f))return null;let p=n.getRow(f);if(!p)return null;let m=n.getRowKey(f)??f,h=l.closest(`[data-ssg-col-key]`),g=h?.dataset.ssgColKey;if(h&&g!==void 0){let r=t(a,g);return r<0?null:i({cell:{row:f,col:r},clientX:e.clientX,clientY:e.clientY,rowModel:n,orderedColumns:a,selection:o,activeCell:s,resolveRevertItems:c})}let _={type:`rowHeader`,rowIndex:f,rowKey:m,row:p},v=r(o,f);return{target:_,clientX:e.clientX,clientY:e.clientY,selection:o,activeCell:s,isTargetSelected:v,revertItems:c?.(_,v)??[]}};exports.buildBodyContextMenuParams=a,exports.buildCellContextMenuParams=i,exports.isContextMenuCellSelected=n,exports.isContextMenuRowSelected=r,exports.resolveContextMenuColIndex=t;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CellCoord, GridColumn, GridContextMenuParams, GridSelection, RowModel } from '../model/gridTypes.unbound.js';
|
|
1
|
+
import type { CellCoord, GridColumn, GridContextMenuItem, GridContextMenuParams, GridContextMenuTarget, GridSelection, RowModel } from '../model/gridTypes.unbound.js';
|
|
2
2
|
export declare const resolveContextMenuColIndex: <T>(orderedColumns: readonly GridColumn<T>[], columnKey: string) => number;
|
|
3
3
|
export declare const isContextMenuCellSelected: (selection: GridSelection, rowIndex: number, colIndex: number) => boolean;
|
|
4
4
|
export declare const isContextMenuRowSelected: (selection: GridSelection, rowIndex: number) => boolean;
|
|
@@ -10,6 +10,7 @@ export type CellContextMenuInput<T> = {
|
|
|
10
10
|
orderedColumns: readonly GridColumn<T>[];
|
|
11
11
|
selection: GridSelection;
|
|
12
12
|
activeCell: CellCoord | null;
|
|
13
|
+
resolveRevertItems?: ((target: GridContextMenuTarget<T>, isTargetSelected: boolean) => GridContextMenuItem[]) | undefined;
|
|
13
14
|
};
|
|
14
15
|
export type BodyContextMenuInput<T> = Omit<CellContextMenuInput<T>, 'cell' | 'clientX' | 'clientY'> & {
|
|
15
16
|
event: {
|
|
@@ -18,5 +19,5 @@ export type BodyContextMenuInput<T> = Omit<CellContextMenuInput<T>, 'cell' | 'cl
|
|
|
18
19
|
readonly clientY: number;
|
|
19
20
|
};
|
|
20
21
|
};
|
|
21
|
-
export declare const buildCellContextMenuParams: <T>({ cell, clientX, clientY, rowModel, orderedColumns, selection, activeCell, }: CellContextMenuInput<T>) => GridContextMenuParams<T> | null;
|
|
22
|
-
export declare const buildBodyContextMenuParams: <T>({ event, rowModel, orderedColumns, selection, activeCell, }: BodyContextMenuInput<T>) => GridContextMenuParams<T> | null;
|
|
22
|
+
export declare const buildCellContextMenuParams: <T>({ cell, clientX, clientY, rowModel, orderedColumns, selection, activeCell, resolveRevertItems, }: CellContextMenuInput<T>) => GridContextMenuParams<T> | null;
|
|
23
|
+
export declare const buildBodyContextMenuParams: <T>({ event, rowModel, orderedColumns, selection, activeCell, resolveRevertItems, }: BodyContextMenuInput<T>) => GridContextMenuParams<T> | null;
|
|
@@ -14,41 +14,44 @@ var t = (e, t) => e.findIndex((e) => e.key === t), n = (e, t, n) => {
|
|
|
14
14
|
return t >= i && t <= a;
|
|
15
15
|
}
|
|
16
16
|
return !1;
|
|
17
|
-
}, i = ({ cell: t, clientX: r, clientY: i, rowModel: a, orderedColumns: o, selection: s, activeCell: c }) => {
|
|
18
|
-
let
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
17
|
+
}, i = ({ cell: t, clientX: r, clientY: i, rowModel: a, orderedColumns: o, selection: s, activeCell: c, resolveRevertItems: l }) => {
|
|
18
|
+
let u = t.row, d = t.col, f = a.getRow(u), p = o[d];
|
|
19
|
+
if (!f || !p) return null;
|
|
20
|
+
let m = {
|
|
21
|
+
type: "cell",
|
|
22
|
+
rowIndex: u,
|
|
23
|
+
colIndex: d,
|
|
24
|
+
rowKey: a.getRowKey(u) ?? u,
|
|
25
|
+
row: f,
|
|
26
|
+
column: p,
|
|
27
|
+
value: e(f, p)
|
|
28
|
+
}, h = n(s, u, d);
|
|
29
|
+
return {
|
|
30
|
+
target: m,
|
|
29
31
|
clientX: r,
|
|
30
32
|
clientY: i,
|
|
31
33
|
selection: s,
|
|
32
34
|
activeCell: c,
|
|
33
|
-
isTargetSelected:
|
|
35
|
+
isTargetSelected: h,
|
|
36
|
+
revertItems: l?.(m, h) ?? []
|
|
34
37
|
};
|
|
35
|
-
}, a = ({ event: e, rowModel: n, orderedColumns: a, selection: o, activeCell: s }) => {
|
|
36
|
-
let
|
|
37
|
-
if (!
|
|
38
|
-
let
|
|
39
|
-
if (!
|
|
40
|
-
let
|
|
41
|
-
if (
|
|
42
|
-
let
|
|
43
|
-
if (!Number.isInteger(
|
|
44
|
-
let
|
|
45
|
-
if (!
|
|
46
|
-
let
|
|
47
|
-
if (
|
|
48
|
-
let r = t(a,
|
|
38
|
+
}, a = ({ event: e, rowModel: n, orderedColumns: a, selection: o, activeCell: s, resolveRevertItems: c }) => {
|
|
39
|
+
let l = e.target;
|
|
40
|
+
if (!l || typeof l.closest != "function") return null;
|
|
41
|
+
let u = l.closest("[data-row-index]");
|
|
42
|
+
if (!u) return null;
|
|
43
|
+
let d = u.dataset.rowIndex;
|
|
44
|
+
if (d === void 0) return null;
|
|
45
|
+
let f = Number(d);
|
|
46
|
+
if (!Number.isInteger(f)) return null;
|
|
47
|
+
let p = n.getRow(f);
|
|
48
|
+
if (!p) return null;
|
|
49
|
+
let m = n.getRowKey(f) ?? f, h = l.closest("[data-ssg-col-key]"), g = h?.dataset.ssgColKey;
|
|
50
|
+
if (h && g !== void 0) {
|
|
51
|
+
let r = t(a, g);
|
|
49
52
|
return r < 0 ? null : i({
|
|
50
53
|
cell: {
|
|
51
|
-
row:
|
|
54
|
+
row: f,
|
|
52
55
|
col: r
|
|
53
56
|
},
|
|
54
57
|
clientX: e.clientX,
|
|
@@ -56,21 +59,24 @@ var t = (e, t) => e.findIndex((e) => e.key === t), n = (e, t, n) => {
|
|
|
56
59
|
rowModel: n,
|
|
57
60
|
orderedColumns: a,
|
|
58
61
|
selection: o,
|
|
59
|
-
activeCell: s
|
|
62
|
+
activeCell: s,
|
|
63
|
+
resolveRevertItems: c
|
|
60
64
|
});
|
|
61
65
|
}
|
|
66
|
+
let _ = {
|
|
67
|
+
type: "rowHeader",
|
|
68
|
+
rowIndex: f,
|
|
69
|
+
rowKey: m,
|
|
70
|
+
row: p
|
|
71
|
+
}, v = r(o, f);
|
|
62
72
|
return {
|
|
63
|
-
target:
|
|
64
|
-
type: "rowHeader",
|
|
65
|
-
rowIndex: d,
|
|
66
|
-
rowKey: p,
|
|
67
|
-
row: f
|
|
68
|
-
},
|
|
73
|
+
target: _,
|
|
69
74
|
clientX: e.clientX,
|
|
70
75
|
clientY: e.clientY,
|
|
71
76
|
selection: o,
|
|
72
77
|
activeCell: s,
|
|
73
|
-
isTargetSelected:
|
|
78
|
+
isTargetSelected: v,
|
|
79
|
+
revertItems: c?.(_, v) ?? []
|
|
74
80
|
};
|
|
75
81
|
};
|
|
76
82
|
//#endregion
|
|
@@ -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,t,n,r)=>{let i=[];for(let a=e;n===1?a<=t:a>=t;a+=n)r(a)&&i.push(a);return i},
|
|
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;
|