@ishibashi0112/spreadsheet-grid-core 1.0.2 → 1.2.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 -0
- package/dist/controllers/activeRowFollowController.d.ts +18 -0
- package/dist/controllers/activeRowFollowController.js +68 -0
- package/dist/controllers/autoHeightMeasurer.cjs +1 -1
- package/dist/controllers/autoHeightMeasurer.js +17 -17
- package/dist/controllers/clipboardController.cjs +1 -1
- package/dist/controllers/clipboardController.d.ts +4 -0
- package/dist/controllers/clipboardController.js +82 -54
- package/dist/controllers/columnAutosizeRunner.cjs +1 -1
- package/dist/controllers/columnAutosizeRunner.d.ts +1 -0
- package/dist/controllers/columnAutosizeRunner.js +17 -16
- package/dist/controllers/columnHeaderDragController.cjs +1 -1
- package/dist/controllers/columnHeaderDragController.js +169 -168
- package/dist/controllers/columnMenuController.cjs +1 -1
- package/dist/controllers/columnMenuController.js +71 -69
- package/dist/controllers/contextMenuController.cjs +1 -1
- package/dist/controllers/contextMenuController.d.ts +5 -1
- package/dist/controllers/contextMenuController.js +62 -40
- package/dist/controllers/editController.cjs +1 -1
- package/dist/controllers/editController.d.ts +1 -0
- package/dist/controllers/editController.js +106 -99
- package/dist/controllers/fillHandleController.cjs +1 -1
- package/dist/controllers/fillHandleController.d.ts +1 -0
- package/dist/controllers/fillHandleController.js +157 -157
- package/dist/controllers/filterPopoverController.cjs +1 -1
- package/dist/controllers/filterPopoverController.js +6 -6
- package/dist/controllers/findController.cjs +1 -1
- package/dist/controllers/findController.d.ts +1 -0
- package/dist/controllers/findController.js +16 -15
- package/dist/controllers/historyController.cjs +1 -1
- package/dist/controllers/historyController.d.ts +6 -0
- package/dist/controllers/historyController.js +79 -37
- package/dist/controllers/imeInputController.cjs +1 -1
- package/dist/controllers/imeInputController.js +65 -54
- package/dist/controllers/keyboardController.cjs +1 -1
- package/dist/controllers/keyboardController.d.ts +1 -0
- package/dist/controllers/keyboardController.js +46 -42
- package/dist/controllers/pointerInteractionsController.cjs +1 -1
- package/dist/controllers/pointerInteractionsController.d.ts +1 -0
- package/dist/controllers/pointerInteractionsController.js +172 -172
- package/dist/controllers/popoverSupport.cjs +1 -1
- package/dist/controllers/popoverSupport.d.ts +1 -0
- package/dist/controllers/popoverSupport.js +9 -4
- package/dist/controllers/rowDragController.cjs +1 -1
- package/dist/controllers/rowDragController.d.ts +2 -0
- package/dist/controllers/rowDragController.js +160 -146
- package/dist/controllers/scrollSyncController.cjs +1 -1
- package/dist/controllers/scrollSyncController.js +45 -43
- package/dist/controllers/serverSideRowModel.cjs +1 -1
- package/dist/controllers/serverSideRowModel.js +19 -19
- package/dist/controllers/toolPanelController.cjs +1 -1
- package/dist/controllers/toolPanelController.js +26 -14
- package/dist/controllers/tooltipController.cjs +1 -1
- package/dist/controllers/tooltipController.js +74 -72
- package/dist/controllers/viewportSyncController.cjs +1 -1
- package/dist/controllers/viewportSyncController.d.ts +4 -1
- package/dist/controllers/viewportSyncController.js +66 -28
- package/dist/engine/columnCommands.cjs +1 -1
- package/dist/engine/columnCommands.js +113 -113
- package/dist/engine/createGridEngine.cjs +3 -3
- package/dist/engine/createGridEngine.d.ts +2 -0
- package/dist/engine/createGridEngine.js +72 -70
- package/dist/engine/exportCommands.cjs +1 -1
- package/dist/engine/exportCommands.js +18 -9
- package/dist/engine/fullFeatures.cjs +1 -1
- package/dist/engine/fullFeatures.js +6 -6
- package/dist/engine/gridApi.cjs +6 -6
- package/dist/engine/gridApi.d.ts +8 -2
- package/dist/engine/gridApi.js +197 -187
- package/dist/engine/notifiers.cjs +1 -1
- package/dist/engine/notifiers.d.ts +4 -0
- package/dist/engine/notifiers.js +7 -7
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +7 -6
- package/dist/locales/en.cjs +1 -1
- package/dist/locales/en.js +5 -0
- package/dist/logic/autoScrollGeometry.cjs +1 -1
- package/dist/logic/autoScrollGeometry.d.ts +2 -0
- package/dist/logic/autoScrollGeometry.js +3 -3
- package/dist/logic/editorValues.cjs +1 -1
- package/dist/logic/editorValues.js +37 -34
- package/dist/logic/exportCsv.cjs +3 -3
- package/dist/logic/exportCsv.d.ts +4 -1
- package/dist/logic/exportCsv.js +22 -20
- package/dist/logic/exportData.cjs +1 -1
- package/dist/logic/exportData.d.ts +4 -1
- package/dist/logic/exportData.js +40 -36
- package/dist/logic/filtering.cjs +1 -1
- package/dist/logic/filtering.d.ts +2 -1
- package/dist/logic/filtering.js +16 -3
- package/dist/logic/geometry.cjs +1 -1
- package/dist/logic/geometry.d.ts +2 -0
- package/dist/logic/geometry.js +41 -20
- package/dist/logic/gridState.cjs +1 -1
- package/dist/logic/gridState.d.ts +3 -2
- package/dist/logic/gridState.js +32 -23
- package/dist/logic/groupExport.cjs +1 -1
- package/dist/logic/groupExport.js +28 -27
- package/dist/logic/grouping.cjs +1 -1
- package/dist/logic/grouping.d.ts +1 -0
- package/dist/logic/grouping.js +52 -41
- package/dist/logic/historyRebase.cjs +1 -0
- package/dist/logic/historyRebase.d.ts +5 -0
- package/dist/logic/historyRebase.js +36 -0
- package/dist/logic/imeInput.cjs +1 -1
- package/dist/logic/imeInput.js +6 -4
- package/dist/logic/localeTextFeatures.cjs +1 -1
- package/dist/logic/localeTextFeatures.d.ts +8 -0
- package/dist/logic/localeTextFeatures.js +11 -5
- package/dist/logic/localeTextPopups.cjs +1 -1
- package/dist/logic/localeTextPopups.d.ts +1 -0
- package/dist/logic/localeTextPopups.js +1 -0
- package/dist/logic/pasteFill.cjs +1 -0
- package/dist/logic/pasteFill.d.ts +2 -0
- package/dist/logic/pasteFill.js +25 -0
- package/dist/logic/selectEditorState.cjs +1 -1
- package/dist/logic/selectEditorState.d.ts +4 -1
- package/dist/logic/selectEditorState.js +14 -14
- package/dist/logic/selectLabels.cjs +1 -0
- package/dist/logic/selectLabels.d.ts +3 -0
- package/dist/logic/selectLabels.js +41 -0
- package/dist/logic/selectionAggregates.cjs +1 -1
- package/dist/logic/selectionAggregates.js +2 -3
- package/dist/logic/validation.cjs +1 -1
- package/dist/logic/validation.d.ts +1 -1
- package/dist/logic/validation.js +21 -21
- package/dist/logic/valueParsers.cjs +1 -0
- package/dist/logic/valueParsers.d.ts +14 -0
- package/dist/logic/valueParsers.js +23 -0
- package/dist/model/gridActions.cjs +1 -1
- package/dist/model/gridActions.d.ts +13 -0
- package/dist/model/gridActions.js +11 -0
- package/dist/model/gridReducer.cjs +1 -1
- package/dist/model/gridReducer.js +128 -65
- package/dist/model/gridTypes.core.d.ts +345 -43
- package/dist/utils/clipboard.cjs +4 -4
- package/dist/utils/clipboard.d.ts +14 -2
- package/dist/utils/clipboard.js +101 -49
- package/dist/utils/gridVisibleBand.cjs +1 -0
- package/dist/utils/gridVisibleBand.d.ts +4 -0
- package/dist/utils/gridVisibleBand.js +24 -0
- package/dist/utils/popupContainer.cjs +1 -0
- package/dist/utils/popupContainer.d.ts +8 -0
- package/dist/utils/popupContainer.js +60 -0
- package/dist/utils/scrollBottom.cjs +1 -0
- package/dist/utils/scrollBottom.d.ts +1 -0
- package/dist/utils/scrollBottom.js +4 -0
- package/dist/utils/topAlignedInput.cjs +1 -0
- package/dist/utils/topAlignedInput.d.ts +3 -0
- package/dist/utils/topAlignedInput.js +23 -0
- package/package.json +1 -1
package/dist/logic/validation.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { getCellValue as e } from "../utils/permissions.js";
|
|
2
|
-
import { parseNumberText as t } from "./editorValues.js";
|
|
3
|
-
import { formatLocaleText as
|
|
4
|
-
import { DEFAULT_GRID_LOCALE_TEXT as
|
|
2
|
+
import { parseNumberText as t, toDateInputValue as n } from "./editorValues.js";
|
|
3
|
+
import { formatLocaleText as r } from "./localeTextFilters.js";
|
|
4
|
+
import { DEFAULT_GRID_LOCALE_TEXT as i } from "./localeText.js";
|
|
5
5
|
//#region src/logic/validation.ts
|
|
6
|
-
var
|
|
6
|
+
var a = i.invalidValue, o = (e, t = a) => e === !0 ? {
|
|
7
7
|
valid: !0,
|
|
8
8
|
message: ""
|
|
9
9
|
} : e === !1 ? {
|
|
@@ -15,38 +15,38 @@ var i = r.invalidValue, a = (e, t = i) => e === !0 ? {
|
|
|
15
15
|
} : {
|
|
16
16
|
valid: !1,
|
|
17
17
|
message: e.message || t
|
|
18
|
-
},
|
|
19
|
-
let a =
|
|
20
|
-
if (!a ||
|
|
21
|
-
let { min:
|
|
22
|
-
return Number.isFinite(l) ? a.integer && !Number.isInteger(l) ? i.enterInteger :
|
|
23
|
-
min:
|
|
18
|
+
}, s = ({ editor: e }) => e?.type === "number" && (e.min != null || e.max != null || e.integer || e.strict) ? e : void 0, c = ({ editor: e }) => e?.type === "date" && e.strict === !0, l = (e, t, r) => !c(e) || t == null || typeof t == "string" && !t.trim() || (t instanceof Date || typeof t == "string") && n(t) !== "" ? null : r.enterDate, u = (e, n, i) => {
|
|
19
|
+
let a = s(e);
|
|
20
|
+
if (!a || n == null || typeof n == "string" && !n.trim()) return null;
|
|
21
|
+
let { min: o, max: c } = a, l = typeof n == "string" ? t(n) ?? NaN : typeof n == "number" ? n : NaN;
|
|
22
|
+
return Number.isFinite(l) ? a.integer && !Number.isInteger(l) ? i.enterInteger : o != null && l < o || c != null && l > c ? c == null ? r(i.enterMin, { min: o }) : o == null ? r(i.enterMax, { max: c }) : r(i.enterRange, {
|
|
23
|
+
min: o,
|
|
24
24
|
max: c
|
|
25
25
|
}) : null : i.enterNumber;
|
|
26
|
-
},
|
|
26
|
+
}, d = (e) => !!(e.validate || s(e) || c(e)), f = (e, t, n, r = i) => {
|
|
27
27
|
if (e.validate) {
|
|
28
|
-
let
|
|
28
|
+
let i = o(e.validate({
|
|
29
29
|
value: n,
|
|
30
30
|
row: t,
|
|
31
31
|
column: e
|
|
32
|
-
}),
|
|
33
|
-
if (!
|
|
32
|
+
}), r.invalidValue);
|
|
33
|
+
if (!i.valid) return i.message;
|
|
34
34
|
}
|
|
35
|
-
return
|
|
36
|
-
},
|
|
35
|
+
return u(e, n, r) ?? l(e, n, r);
|
|
36
|
+
}, p = (e, t, n, r) => {
|
|
37
37
|
if ((e.validationMode ?? "mark") !== "reject") return { action: "write" };
|
|
38
|
-
let i =
|
|
38
|
+
let i = f(e, t, n, r);
|
|
39
39
|
return i === null ? { action: "write" } : {
|
|
40
40
|
action: "reject",
|
|
41
41
|
message: i
|
|
42
42
|
};
|
|
43
|
-
},
|
|
44
|
-
let o = n.filter(
|
|
43
|
+
}, m = (t, n, r, i, a) => {
|
|
44
|
+
let o = n.filter(d);
|
|
45
45
|
if (o.length === 0) return [];
|
|
46
46
|
let s = [];
|
|
47
47
|
return t.forEach((t, n) => {
|
|
48
48
|
if (!i?.(t, n)) for (let i of o) {
|
|
49
|
-
let o =
|
|
49
|
+
let o = f(i, t, e(t, i), a);
|
|
50
50
|
o !== null && s.push({
|
|
51
51
|
rowKey: r(t, n) ?? n,
|
|
52
52
|
sourceRowIndex: n,
|
|
@@ -57,4 +57,4 @@ var i = r.invalidValue, a = (e, t = i) => e === !0 ? {
|
|
|
57
57
|
}), s;
|
|
58
58
|
};
|
|
59
59
|
//#endregion
|
|
60
|
-
export {
|
|
60
|
+
export { a as DEFAULT_INVALID_MESSAGE, p as decideCellWrite, f as getInvalidMessage, d as hasCellValidation, o as normalizeValidationResult, m as scanInvalidCells };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./editorValues.cjs");var t=/^\s*[((]([^()()]*)[))]\s*$/,n=/^[\s\u3000]*[-+\u2212\uFF0D\uFF0B\u30FC]/;function r(r={}){let i=(r.strip??[]).filter(e=>e!==``),a=r.negativeParentheses===!0;return r=>{if(r.trim()===``)return null;let o=r;for(let e of i)o=o.split(e).join(``);let s=!1;if(a){let e=t.exec(o);if(e){if(o=e[1]??``,n.test(o))return r;s=!0}}let c=e.parseNumberText(o);return c===null?r:s&&c!==0?-c:c}}exports.numberParser=r;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** `numberParser` のオプション。 */
|
|
2
|
+
export type NumberParserOptions = {
|
|
3
|
+
/** 読む前に外す文字(通貨記号や単位。例: `['¥', '¥', '円', '$']`)。外したあとが数値でなければ元の文字のまま。 */
|
|
4
|
+
strip?: readonly string[] | undefined;
|
|
5
|
+
/** `true` で、かっこで囲んだ数(`(1,200)` / `(1,200)`。会計の書式)を負の数として読む。既定 `false`。 */
|
|
6
|
+
negativeParentheses?: boolean | undefined;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* 「文字列 → 数値」のパーサを作る(列の `parseClipboardValue` に渡す。貼り付け / Delete / エディタの確定で共通)。
|
|
10
|
+
* 読み方は number エディタの既定のパーサと同じ: 空・空白だけは `null`、数値として読める文字は `number`(全角の数字・符号・
|
|
11
|
+
* 小数点と 3 桁区切りも読む)、読めない文字は元の文字のまま(`validationMode` の `'mark'` なら印、`'reject'` なら書かない)。
|
|
12
|
+
* `strip` で通貨記号や単位を先に外し、`negativeParentheses` で `(1,200)` を `-1200` と読む。
|
|
13
|
+
*/
|
|
14
|
+
export declare function numberParser(options?: NumberParserOptions): (raw: string) => unknown;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { parseNumberText as e } from "./editorValues.js";
|
|
2
|
+
//#region src/logic/valueParsers.ts
|
|
3
|
+
var t = /^\s*[((]([^()()]*)[))]\s*$/, n = /^[\s\u3000]*[-+\u2212\uFF0D\uFF0B\u30FC]/;
|
|
4
|
+
function r(r = {}) {
|
|
5
|
+
let i = (r.strip ?? []).filter((e) => e !== ""), a = r.negativeParentheses === !0;
|
|
6
|
+
return (r) => {
|
|
7
|
+
if (r.trim() === "") return null;
|
|
8
|
+
let o = r;
|
|
9
|
+
for (let e of i) o = o.split(e).join("");
|
|
10
|
+
let s = !1;
|
|
11
|
+
if (a) {
|
|
12
|
+
let e = t.exec(o);
|
|
13
|
+
if (e) {
|
|
14
|
+
if (o = e[1] ?? "", n.test(o)) return r;
|
|
15
|
+
s = !0;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
let c = e(o);
|
|
19
|
+
return c === null ? r : s && c !== 0 ? -c : c;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
23
|
+
export { r as numberParser };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e={activateCell:e=>({type:`cell/activate`,cell:e}),startSelection:e=>({type:`selection/start`,cell:e}),updateSelection:e=>({type:`selection/update`,cell:e}),startRowSelection:(e,t)=>t===void 0?{type:`rowSelection/start`,row:e}:{type:`rowSelection/start`,row:e,col:t},updateRowSelection:e=>({type:`rowSelection/update`,row:e}),startColumnSelection:(e,t)=>t===void 0?{type:`columnSelection/start`,col:e}:{type:`columnSelection/start`,col:e,row:t},updateColumnSelection:e=>({type:`columnSelection/update`,col:e}),endSelection:()=>({type:`selection/end`}),clearSelection:()=>({type:`selection/clear`}),startEdit:e=>({type:`edit/start`,cell:e}),stopEdit:()=>({type:`edit/stop`}),startColumnResize:(e,t,n,r,i)=>({type:`column/resizeStart`,columnKey:e,startX:t,startWidth:n,minWidth:r,maxWidth:i}),updateColumnResize:e=>({type:`column/resizeUpdate`,clientX:e}),endColumnResize:()=>({type:`column/resizeEnd`}),syncColumnWidths:e=>({type:`columnWidths/sync`,widths:e}),resetColumnWidths:e=>({type:`columnWidths/reset`,widths:e}),clampSelectionToRowCount:(e,t)=>({type:`selection/clampToRowCount`,rowCount:e,...t===void 0?{}:{colCount:t}}),reconcileColumnWidths:(e,t)=>({type:`columnWidths/reconcile`,prevColumns:e,nextColumns:t}),setGlobalFilter:e=>({type:`filter/setGlobal`,value:e}),setColumnFilter:(e,t)=>({type:`filter/setColumn`,columnKey:e,value:t}),clearColumnFilter:e=>({type:`filter/clearColumn`,columnKey:e}),resetAllFilters:()=>({type:`filter/resetAll`}),setAllFilters:e=>({type:`filter/setAll`,filters:e}),setSort:e=>({type:`sort/set`,entries:e}),clearSort:()=>({type:`sort/clear`}),setRowSelectionState:e=>({type:`rowSelect/set`,state:e}),toggleGroupCollapsed:e=>({type:`group/toggleCollapsed`,groupKey:e}),setGroupCollapsed:(e,t)=>({type:`group/setCollapsed`,groupKey:e,collapsed:t}),setCollapsedGroupKeys:e=>({type:`group/setCollapsedKeys`,keys:e}),toggleDetailRow:e=>({type:`detail/toggle`,rowKey:e}),setDetailRowExpanded:(e,t)=>({type:`detail/setExpanded`,rowKey:e,expanded:t}),setExpandedDetailRowKeys:e=>({type:`detail/setKeys`,keys:e})};exports.gridActions=e;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e={activateCell:e=>({type:`cell/activate`,cell:e}),startSelection:e=>({type:`selection/start`,cell:e}),updateSelection:e=>({type:`selection/update`,cell:e}),startRowSelection:(e,t)=>t===void 0?{type:`rowSelection/start`,row:e}:{type:`rowSelection/start`,row:e,col:t},updateRowSelection:e=>({type:`rowSelection/update`,row:e}),startColumnSelection:(e,t)=>t===void 0?{type:`columnSelection/start`,col:e}:{type:`columnSelection/start`,col:e,row:t},updateColumnSelection:e=>({type:`columnSelection/update`,col:e}),endSelection:()=>({type:`selection/end`}),clearSelection:()=>({type:`selection/clear`}),startEdit:e=>({type:`edit/start`,cell:e}),stopEdit:()=>({type:`edit/stop`}),startColumnResize:(e,t,n,r,i)=>({type:`column/resizeStart`,columnKey:e,startX:t,startWidth:n,minWidth:r,maxWidth:i}),updateColumnResize:e=>({type:`column/resizeUpdate`,clientX:e}),endColumnResize:()=>({type:`column/resizeEnd`}),syncColumnWidths:e=>({type:`columnWidths/sync`,widths:e}),resetColumnWidths:e=>({type:`columnWidths/reset`,widths:e}),followActiveRow:(e,t)=>({type:`selection/followActiveRow`,row:e,rowCount:t}),retargetEdit:(e,t)=>({type:`edit/retarget`,cell:e,rowCount:t}),collapseSelectionToActiveCell:()=>({type:`selection/collapseToActiveCell`}),clampSelectionToRowCount:(e,t)=>({type:`selection/clampToRowCount`,rowCount:e,...t===void 0?{}:{colCount:t}}),reconcileColumnWidths:(e,t)=>({type:`columnWidths/reconcile`,prevColumns:e,nextColumns:t}),setGlobalFilter:e=>({type:`filter/setGlobal`,value:e}),setColumnFilter:(e,t)=>({type:`filter/setColumn`,columnKey:e,value:t}),clearColumnFilter:e=>({type:`filter/clearColumn`,columnKey:e}),resetAllFilters:()=>({type:`filter/resetAll`}),setAllFilters:e=>({type:`filter/setAll`,filters:e}),setSort:e=>({type:`sort/set`,entries:e}),clearSort:()=>({type:`sort/clear`}),setRowSelectionState:e=>({type:`rowSelect/set`,state:e}),toggleGroupCollapsed:e=>({type:`group/toggleCollapsed`,groupKey:e}),setGroupCollapsed:(e,t)=>({type:`group/setCollapsed`,groupKey:e,collapsed:t}),setCollapsedGroupKeys:e=>({type:`group/setCollapsedKeys`,keys:e}),toggleDetailRow:e=>({type:`detail/toggle`,rowKey:e}),setDetailRowExpanded:(e,t)=>({type:`detail/setExpanded`,rowKey:e,expanded:t}),setExpandedDetailRowKeys:e=>({type:`detail/setKeys`,keys:e})};exports.gridActions=e;
|
|
@@ -30,9 +30,19 @@ export type GridUiAction = {
|
|
|
30
30
|
type: 'selection/clampToRowCount';
|
|
31
31
|
rowCount: number;
|
|
32
32
|
colCount?: number;
|
|
33
|
+
} | {
|
|
34
|
+
type: 'selection/followActiveRow';
|
|
35
|
+
row: number;
|
|
36
|
+
rowCount?: number | undefined;
|
|
37
|
+
} | {
|
|
38
|
+
type: 'selection/collapseToActiveCell';
|
|
33
39
|
} | {
|
|
34
40
|
type: 'edit/start';
|
|
35
41
|
cell: CellCoord;
|
|
42
|
+
} | {
|
|
43
|
+
type: 'edit/retarget';
|
|
44
|
+
cell: CellCoord;
|
|
45
|
+
rowCount?: number | undefined;
|
|
36
46
|
} | {
|
|
37
47
|
type: 'edit/stop';
|
|
38
48
|
} | {
|
|
@@ -118,6 +128,9 @@ export declare const gridActions: {
|
|
|
118
128
|
endColumnResize: () => GridUiAction;
|
|
119
129
|
syncColumnWidths: (widths: Record<string, number>) => GridUiAction;
|
|
120
130
|
resetColumnWidths: (widths: Record<string, number>) => GridUiAction;
|
|
131
|
+
followActiveRow: (row: number, rowCount?: number) => GridUiAction;
|
|
132
|
+
retargetEdit: (cell: CellCoord, rowCount?: number) => GridUiAction;
|
|
133
|
+
collapseSelectionToActiveCell: () => GridUiAction;
|
|
121
134
|
clampSelectionToRowCount: (rowCount: number, colCount?: number) => GridUiAction;
|
|
122
135
|
reconcileColumnWidths: <T>(prevColumns: readonly GridColumn<T>[] | null, nextColumns: readonly GridColumn<T>[]) => GridUiAction;
|
|
123
136
|
setGlobalFilter: (value: string) => GridUiAction;
|
|
@@ -64,6 +64,17 @@ var e = {
|
|
|
64
64
|
type: "columnWidths/reset",
|
|
65
65
|
widths: e
|
|
66
66
|
}),
|
|
67
|
+
followActiveRow: (e, t) => ({
|
|
68
|
+
type: "selection/followActiveRow",
|
|
69
|
+
row: e,
|
|
70
|
+
rowCount: t
|
|
71
|
+
}),
|
|
72
|
+
retargetEdit: (e, t) => ({
|
|
73
|
+
type: "edit/retarget",
|
|
74
|
+
cell: e,
|
|
75
|
+
rowCount: t
|
|
76
|
+
}),
|
|
77
|
+
collapseSelectionToActiveCell: () => ({ type: "selection/collapseToActiveCell" }),
|
|
67
78
|
clampSelectionToRowCount: (e, t) => ({
|
|
68
79
|
type: "selection/clampToRowCount",
|
|
69
80
|
rowCount: e,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../logic/columnWidthState.cjs"),t=require("../logic/rowSelection.cjs"),n=require("../logic/gridState.cjs");var r=60,i=(e,t,n)=>Math.min(Math.max(e,t),n),a=(e,t)=>{let{activeCell:n,selection:r,dragState:i}=e;if(t<=0){let t=r!==null&&r.type!==`col`,a=i?.type===`selection`&&i.selectionKind!==`col`;return n===null&&!t&&!a?e:{...e,activeCell:null,selection:t?null:r,dragState:a?null:i}}let a=t-1,o=e;if(n!==null&&n.row>a&&(o={...o,activeCell:{row:a,col:n.col}}),r?.type===`cell`){let{start:e,end:t}=r.range;(e.row>a||t.row>a)&&(o={...o,selection:{type:`cell`,range:{start:{row:Math.min(e.row,a),col:e.col},end:{row:Math.min(t.row,a),col:t.col}}}})}else r?.type===`row`&&(r.startRow>a||r.endRow>a)&&(o={...o,selection:{type:`row`,startRow:Math.min(r.startRow,a),endRow:Math.min(r.endRow,a)}});return i?.type===`selection`&&(i.selectionKind===`cell`&&i.anchor.row>a?o={...o,dragState:{...i,anchor:{row:a,col:i.anchor.col}}}:i.selectionKind===`row`&&i.anchorRow>a&&(o={...o,dragState:{...i,anchorRow:a}})),o},o=(e,t)=>{let{activeCell:n,selection:r,dragState:i}=e;if(t<=0){let t=r!==null&&r.type!==`row`,a=i?.type===`selection`&&i.selectionKind!==`row`;return n===null&&!t&&!a?e:{...e,activeCell:null,selection:t?null:r,dragState:a?null:i}}let a=t-1,o=e;if(n!==null&&n.col>a&&(o={...o,activeCell:{row:n.row,col:a}}),r?.type===`cell`){let{start:e,end:t}=r.range;(e.col>a||t.col>a)&&(o={...o,selection:{type:`cell`,range:{start:{row:e.row,col:Math.min(e.col,a)},end:{row:t.row,col:Math.min(t.col,a)}}}})}else r?.type===`col`&&(r.startCol>a||r.endCol>a)&&(o={...o,selection:{type:`col`,startCol:Math.min(r.startCol,a),endCol:Math.min(r.endCol,a)}});return i?.type===`selection`&&(i.selectionKind===`cell`&&i.anchor.col>a?o={...o,dragState:{...i,anchor:{row:i.anchor.row,col:a}}}:i.selectionKind===`col`&&i.anchorCol>a&&(o={...o,dragState:{...i,anchorCol:a}})),o},
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../logic/columnWidthState.cjs"),t=require("../logic/rowSelection.cjs"),n=require("../logic/gridState.cjs");var r=60,i=(e,t,n)=>Math.min(Math.max(e,t),n),a=(e,t)=>{let{activeCell:n,selection:r,dragState:i}=e;if(t<=0){let t=r!==null&&r.type!==`col`,a=i?.type===`selection`&&i.selectionKind!==`col`;return n===null&&!t&&!a?e:{...e,activeCell:null,selection:t?null:r,dragState:a?null:i}}let a=t-1,o=e;if(n!==null&&n.row>a&&(o={...o,activeCell:{row:a,col:n.col}}),r?.type===`cell`){let{start:e,end:t}=r.range;(e.row>a||t.row>a)&&(o={...o,selection:{type:`cell`,range:{start:{row:Math.min(e.row,a),col:e.col},end:{row:Math.min(t.row,a),col:t.col}}}})}else r?.type===`row`&&(r.startRow>a||r.endRow>a)&&(o={...o,selection:{type:`row`,startRow:Math.min(r.startRow,a),endRow:Math.min(r.endRow,a)}});return i?.type===`selection`&&(i.selectionKind===`cell`&&i.anchor.row>a?o={...o,dragState:{...i,anchor:{row:a,col:i.anchor.col}}}:i.selectionKind===`row`&&i.anchorRow>a&&(o={...o,dragState:{...i,anchorRow:a}})),o},o=(e,t,n)=>{let{activeCell:r,selection:i}=e;if(r===null||r.row===t.row&&r.col===t.col)return e;let a=r.row,o=t.row,s=r.col===t.col,c={row:o,col:t.col},l={type:`cell`,range:{start:c,end:c}},u=(e,t)=>n!==void 0&&n>0&&Math.min(e,t)<=0&&Math.max(e,t)>=n-1,d=i;if(i?.type===`cell`){let{start:e,end:t}=i.range;d=e.row===a&&t.row===a&&s?{type:`cell`,range:{start:{row:o,col:e.col},end:{row:o,col:t.col}}}:u(e.row,t.row)&&s?i:l}else i?.type===`row`&&(d=i.startRow===a&&i.endRow===a?{type:`row`,startRow:o,endRow:o}:u(i.startRow,i.endRow)?i:l);return{...e,activeCell:c,selection:d}},s=(e,t)=>{let{activeCell:n,selection:r,dragState:i}=e;if(t<=0){let t=r!==null&&r.type!==`row`,a=i?.type===`selection`&&i.selectionKind!==`row`;return n===null&&!t&&!a?e:{...e,activeCell:null,selection:t?null:r,dragState:a?null:i}}let a=t-1,o=e;if(n!==null&&n.col>a&&(o={...o,activeCell:{row:n.row,col:a}}),r?.type===`cell`){let{start:e,end:t}=r.range;(e.col>a||t.col>a)&&(o={...o,selection:{type:`cell`,range:{start:{row:e.row,col:Math.min(e.col,a)},end:{row:t.row,col:Math.min(t.col,a)}}}})}else r?.type===`col`&&(r.startCol>a||r.endCol>a)&&(o={...o,selection:{type:`col`,startCol:Math.min(r.startCol,a),endCol:Math.min(r.endCol,a)}});return i?.type===`selection`&&(i.selectionKind===`cell`&&i.anchor.col>a?o={...o,dragState:{...i,anchor:{row:i.anchor.row,col:a}}}:i.selectionKind===`col`&&i.anchorCol>a&&(o={...o,dragState:{...i,anchorCol:a}})),o},c=(e,t,n)=>{if(t===null)return e;let r=new Set(n.map(e=>e.key)),i=new Set(t.filter(e=>!r.has(e.key)).map(e=>e.key));if(i.size===0)return e;let a=e,o=e.filters.columnFilters;if(Object.keys(o).some(e=>i.has(e))){let e={};for(let[t,n]of Object.entries(o))i.has(t)||(e[t]=n);a={...a,filters:{...a.filters,columnFilters:e}}}return e.sort.some(e=>i.has(e.columnKey))&&(a={...a,sort:e.sort.filter(e=>!i.has(e.columnKey))}),a},l=()=>({activeCell:null,selection:null,rowSelection:t.createEmptyRowSelection(),editingCell:null,dragState:null,columnWidths:{},filters:{globalText:``,columnFilters:{}},sort:[],collapsedGroupKeys:new Set,expandedDetailRowKeys:new Set}),u=(l,u)=>{switch(u.type){case`cell/activate`:return u.cell===l.activeCell||u.cell!==null&&l.activeCell!==null&&u.cell.row===l.activeCell.row&&u.cell.col===l.activeCell.col?l:{...l,activeCell:u.cell};case`selection/start`:return{...l,activeCell:u.cell,selection:{type:`cell`,range:{start:u.cell,end:u.cell}},dragState:{type:`selection`,selectionKind:`cell`,anchor:u.cell}};case`rowSelection/start`:return{...l,activeCell:{row:u.row,col:l.activeCell?.col??u.col??0},selection:{type:`row`,startRow:u.row,endRow:u.row},dragState:{type:`selection`,selectionKind:`row`,anchorRow:u.row}};case`rowSelection/update`:return l.dragState?.type!==`selection`||l.dragState.selectionKind!==`row`||l.selection?.type===`row`&&l.selection.endRow===u.row?l:{...l,selection:{type:`row`,startRow:l.dragState.anchorRow,endRow:u.row}};case`selection/update`:return l.dragState?.type!==`selection`||l.dragState.selectionKind!==`cell`||l.selection?.type===`cell`&&l.selection.range.end.row===u.cell.row&&l.selection.range.end.col===u.cell.col?l:{...l,selection:{type:`cell`,range:{start:l.dragState.anchor,end:u.cell}}};case`columnSelection/start`:return{...l,activeCell:{row:l.activeCell?.row??u.row??0,col:u.col},selection:{type:`col`,startCol:u.col,endCol:u.col},dragState:{type:`selection`,selectionKind:`col`,anchorCol:u.col}};case`columnSelection/update`:return l.dragState?.type!==`selection`||l.dragState.selectionKind!==`col`||l.selection?.type===`col`&&l.selection.endCol===u.col?l:{...l,selection:{type:`col`,startCol:l.dragState.anchorCol,endCol:u.col}};case`selection/end`:return l.dragState?.type===`selection`?{...l,dragState:null}:l;case`selection/clear`:return l.selection===null&&l.dragState===null?l:{...l,selection:null,dragState:null};case`selection/followActiveRow`:return l.activeCell===null?l:o(l,{row:u.row,col:l.activeCell.col},u.rowCount);case`selection/collapseToActiveCell`:{let{activeCell:e,selection:t}=l;return e===null||t?.type===`cell`&&t.range.start.row===e.row&&t.range.end.row===e.row&&t.range.start.col===e.col&&t.range.end.col===e.col?l:{...l,selection:{type:`cell`,range:{start:e,end:e}}}}case`selection/clampToRowCount`:{let e=a(l,u.rowCount);return u.colCount===void 0?e:s(e,u.colCount)}case`edit/start`:return{...l,editingCell:u.cell,activeCell:u.cell};case`edit/retarget`:{let e=o(l,u.cell,u.rowCount),t=l.editingCell;return t!==null&&t.row===u.cell.row&&t.col===u.cell.col&&e===l?l:{...e,editingCell:u.cell,activeCell:e.activeCell??u.cell}}case`edit/stop`:return l.editingCell===null?l:{...l,editingCell:null};case`column/resizeStart`:return{...l,dragState:{type:`columnResize`,columnKey:u.columnKey,startX:u.startX,startWidth:u.startWidth,minWidth:u.minWidth??r,maxWidth:u.maxWidth??1/0}};case`column/resizeUpdate`:{if(l.dragState?.type!==`columnResize`)return l;let e=i(l.dragState.startWidth+(u.clientX-l.dragState.startX),l.dragState.minWidth,l.dragState.maxWidth);return l.columnWidths[l.dragState.columnKey]===e?l:{...l,columnWidths:{...l.columnWidths,[l.dragState.columnKey]:e}}}case`column/resizeEnd`:return l.dragState?.type===`columnResize`?{...l,dragState:null}:l;case`columnWidths/sync`:return{...l,columnWidths:{...l.columnWidths,...u.widths}};case`columnWidths/reset`:return{...l,columnWidths:u.widths};case`columnWidths/reconcile`:{let t=e.reconcileColumnWidths(l.columnWidths,u.prevColumns,u.nextColumns);return c(t===l.columnWidths?l:{...l,columnWidths:t},u.prevColumns,u.nextColumns)}case`filter/setGlobal`:return l.filters.globalText===u.value?l:{...l,filters:{...l.filters,globalText:u.value}};case`filter/setColumn`:{let e=l.filters.columnFilters[u.columnKey];return e!==void 0&&(e===u.value||n.isSameColumnFilterValue(e,u.value))?l:{...l,filters:{...l.filters,columnFilters:{...l.filters.columnFilters,[u.columnKey]:u.value}}}}case`filter/clearColumn`:{if(!(u.columnKey in l.filters.columnFilters))return l;let e={...l.filters.columnFilters};return delete e[u.columnKey],{...l,filters:{...l.filters,columnFilters:e}}}case`filter/resetAll`:return l.filters.globalText===``&&Object.keys(l.filters.columnFilters).length===0?l:{...l,filters:{globalText:``,columnFilters:{}}};case`filter/setAll`:return{...l,filters:u.filters};case`sort/set`:return n.isSameSortState(l.sort,u.entries)?l:{...l,sort:u.entries};case`sort/clear`:return l.sort.length===0?l:{...l,sort:[]};case`rowSelect/set`:return t.rowSelectionStateEquals(l.rowSelection,u.state)?l:{...l,rowSelection:u.state};case`group/toggleCollapsed`:{let e=new Set(l.collapsedGroupKeys);return e.has(u.groupKey)?e.delete(u.groupKey):e.add(u.groupKey),{...l,collapsedGroupKeys:e}}case`group/setCollapsed`:{if(l.collapsedGroupKeys.has(u.groupKey)===u.collapsed)return l;let e=new Set(l.collapsedGroupKeys);return u.collapsed?e.add(u.groupKey):e.delete(u.groupKey),{...l,collapsedGroupKeys:e}}case`group/setCollapsedKeys`:return u.keys===l.collapsedGroupKeys||u.keys.size===0&&l.collapsedGroupKeys.size===0?l:{...l,collapsedGroupKeys:u.keys};case`detail/toggle`:{let e=new Set(l.expandedDetailRowKeys);return e.has(u.rowKey)?e.delete(u.rowKey):e.add(u.rowKey),{...l,expandedDetailRowKeys:e}}case`detail/setExpanded`:{if(l.expandedDetailRowKeys.has(u.rowKey)===u.expanded)return l;let e=new Set(l.expandedDetailRowKeys);return u.expanded?e.add(u.rowKey):e.delete(u.rowKey),{...l,expandedDetailRowKeys:e}}case`detail/setKeys`:return u.keys===l.expandedDetailRowKeys||u.keys.size===0&&l.expandedDetailRowKeys.size===0?l:{...l,expandedDetailRowKeys:u.keys};default:return l}};exports.createInitialGridUiState=l,exports.gridUiReducer=u;
|
|
@@ -62,7 +62,45 @@ var a = 60, o = (e, t, n) => Math.min(Math.max(e, t), n), s = (e, t) => {
|
|
|
62
62
|
anchorRow: a
|
|
63
63
|
}
|
|
64
64
|
})), o;
|
|
65
|
-
}, c = (e, t) => {
|
|
65
|
+
}, c = (e, t, n) => {
|
|
66
|
+
let { activeCell: r, selection: i } = e;
|
|
67
|
+
if (r === null || r.row === t.row && r.col === t.col) return e;
|
|
68
|
+
let a = r.row, o = t.row, s = r.col === t.col, c = {
|
|
69
|
+
row: o,
|
|
70
|
+
col: t.col
|
|
71
|
+
}, l = {
|
|
72
|
+
type: "cell",
|
|
73
|
+
range: {
|
|
74
|
+
start: c,
|
|
75
|
+
end: c
|
|
76
|
+
}
|
|
77
|
+
}, u = (e, t) => n !== void 0 && n > 0 && Math.min(e, t) <= 0 && Math.max(e, t) >= n - 1, d = i;
|
|
78
|
+
if (i?.type === "cell") {
|
|
79
|
+
let { start: e, end: t } = i.range;
|
|
80
|
+
d = e.row === a && t.row === a && s ? {
|
|
81
|
+
type: "cell",
|
|
82
|
+
range: {
|
|
83
|
+
start: {
|
|
84
|
+
row: o,
|
|
85
|
+
col: e.col
|
|
86
|
+
},
|
|
87
|
+
end: {
|
|
88
|
+
row: o,
|
|
89
|
+
col: t.col
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
} : u(e.row, t.row) && s ? i : l;
|
|
93
|
+
} else i?.type === "row" && (d = i.startRow === a && i.endRow === a ? {
|
|
94
|
+
type: "row",
|
|
95
|
+
startRow: o,
|
|
96
|
+
endRow: o
|
|
97
|
+
} : u(i.startRow, i.endRow) ? i : l);
|
|
98
|
+
return {
|
|
99
|
+
...e,
|
|
100
|
+
activeCell: c,
|
|
101
|
+
selection: d
|
|
102
|
+
};
|
|
103
|
+
}, l = (e, t) => {
|
|
66
104
|
let { activeCell: n, selection: r, dragState: i } = e;
|
|
67
105
|
if (t <= 0) {
|
|
68
106
|
let t = r !== null && r.type !== "row", a = i?.type === "selection" && i.selectionKind !== "row";
|
|
@@ -122,7 +160,7 @@ var a = 60, o = (e, t, n) => Math.min(Math.max(e, t), n), s = (e, t) => {
|
|
|
122
160
|
anchorCol: a
|
|
123
161
|
}
|
|
124
162
|
})), o;
|
|
125
|
-
},
|
|
163
|
+
}, u = (e, t, n) => {
|
|
126
164
|
if (t === null) return e;
|
|
127
165
|
let r = new Set(n.map((e) => e.key)), i = new Set(t.filter((e) => !r.has(e.key)).map((e) => e.key));
|
|
128
166
|
if (i.size === 0) return e;
|
|
@@ -142,7 +180,7 @@ var a = 60, o = (e, t, n) => Math.min(Math.max(e, t), n), s = (e, t) => {
|
|
|
142
180
|
...a,
|
|
143
181
|
sort: e.sort.filter((e) => !i.has(e.columnKey))
|
|
144
182
|
}), a;
|
|
145
|
-
},
|
|
183
|
+
}, d = () => ({
|
|
146
184
|
activeCell: null,
|
|
147
185
|
selection: null,
|
|
148
186
|
rowSelection: t(),
|
|
@@ -156,86 +194,86 @@ var a = 60, o = (e, t, n) => Math.min(Math.max(e, t), n), s = (e, t) => {
|
|
|
156
194
|
sort: [],
|
|
157
195
|
collapsedGroupKeys: /* @__PURE__ */ new Set(),
|
|
158
196
|
expandedDetailRowKeys: /* @__PURE__ */ new Set()
|
|
159
|
-
}),
|
|
160
|
-
switch (
|
|
161
|
-
case "cell/activate": return
|
|
197
|
+
}), f = (t, d) => {
|
|
198
|
+
switch (d.type) {
|
|
199
|
+
case "cell/activate": return d.cell === t.activeCell || d.cell !== null && t.activeCell !== null && d.cell.row === t.activeCell.row && d.cell.col === t.activeCell.col ? t : {
|
|
162
200
|
...t,
|
|
163
|
-
activeCell:
|
|
201
|
+
activeCell: d.cell
|
|
164
202
|
};
|
|
165
203
|
case "selection/start": return {
|
|
166
204
|
...t,
|
|
167
|
-
activeCell:
|
|
205
|
+
activeCell: d.cell,
|
|
168
206
|
selection: {
|
|
169
207
|
type: "cell",
|
|
170
208
|
range: {
|
|
171
|
-
start:
|
|
172
|
-
end:
|
|
209
|
+
start: d.cell,
|
|
210
|
+
end: d.cell
|
|
173
211
|
}
|
|
174
212
|
},
|
|
175
213
|
dragState: {
|
|
176
214
|
type: "selection",
|
|
177
215
|
selectionKind: "cell",
|
|
178
|
-
anchor:
|
|
216
|
+
anchor: d.cell
|
|
179
217
|
}
|
|
180
218
|
};
|
|
181
219
|
case "rowSelection/start": return {
|
|
182
220
|
...t,
|
|
183
221
|
activeCell: {
|
|
184
|
-
row:
|
|
185
|
-
col: t.activeCell?.col ??
|
|
222
|
+
row: d.row,
|
|
223
|
+
col: t.activeCell?.col ?? d.col ?? 0
|
|
186
224
|
},
|
|
187
225
|
selection: {
|
|
188
226
|
type: "row",
|
|
189
|
-
startRow:
|
|
190
|
-
endRow:
|
|
227
|
+
startRow: d.row,
|
|
228
|
+
endRow: d.row
|
|
191
229
|
},
|
|
192
230
|
dragState: {
|
|
193
231
|
type: "selection",
|
|
194
232
|
selectionKind: "row",
|
|
195
|
-
anchorRow:
|
|
233
|
+
anchorRow: d.row
|
|
196
234
|
}
|
|
197
235
|
};
|
|
198
|
-
case "rowSelection/update": return t.dragState?.type !== "selection" || t.dragState.selectionKind !== "row" || t.selection?.type === "row" && t.selection.endRow ===
|
|
236
|
+
case "rowSelection/update": return t.dragState?.type !== "selection" || t.dragState.selectionKind !== "row" || t.selection?.type === "row" && t.selection.endRow === d.row ? t : {
|
|
199
237
|
...t,
|
|
200
238
|
selection: {
|
|
201
239
|
type: "row",
|
|
202
240
|
startRow: t.dragState.anchorRow,
|
|
203
|
-
endRow:
|
|
241
|
+
endRow: d.row
|
|
204
242
|
}
|
|
205
243
|
};
|
|
206
|
-
case "selection/update": return t.dragState?.type !== "selection" || t.dragState.selectionKind !== "cell" || t.selection?.type === "cell" && t.selection.range.end.row ===
|
|
244
|
+
case "selection/update": return t.dragState?.type !== "selection" || t.dragState.selectionKind !== "cell" || t.selection?.type === "cell" && t.selection.range.end.row === d.cell.row && t.selection.range.end.col === d.cell.col ? t : {
|
|
207
245
|
...t,
|
|
208
246
|
selection: {
|
|
209
247
|
type: "cell",
|
|
210
248
|
range: {
|
|
211
249
|
start: t.dragState.anchor,
|
|
212
|
-
end:
|
|
250
|
+
end: d.cell
|
|
213
251
|
}
|
|
214
252
|
}
|
|
215
253
|
};
|
|
216
254
|
case "columnSelection/start": return {
|
|
217
255
|
...t,
|
|
218
256
|
activeCell: {
|
|
219
|
-
row: t.activeCell?.row ??
|
|
220
|
-
col:
|
|
257
|
+
row: t.activeCell?.row ?? d.row ?? 0,
|
|
258
|
+
col: d.col
|
|
221
259
|
},
|
|
222
260
|
selection: {
|
|
223
261
|
type: "col",
|
|
224
|
-
startCol:
|
|
225
|
-
endCol:
|
|
262
|
+
startCol: d.col,
|
|
263
|
+
endCol: d.col
|
|
226
264
|
},
|
|
227
265
|
dragState: {
|
|
228
266
|
type: "selection",
|
|
229
267
|
selectionKind: "col",
|
|
230
|
-
anchorCol:
|
|
268
|
+
anchorCol: d.col
|
|
231
269
|
}
|
|
232
270
|
};
|
|
233
|
-
case "columnSelection/update": return t.dragState?.type !== "selection" || t.dragState.selectionKind !== "col" || t.selection?.type === "col" && t.selection.endCol ===
|
|
271
|
+
case "columnSelection/update": return t.dragState?.type !== "selection" || t.dragState.selectionKind !== "col" || t.selection?.type === "col" && t.selection.endCol === d.col ? t : {
|
|
234
272
|
...t,
|
|
235
273
|
selection: {
|
|
236
274
|
type: "col",
|
|
237
275
|
startCol: t.dragState.anchorCol,
|
|
238
|
-
endCol:
|
|
276
|
+
endCol: d.col
|
|
239
277
|
}
|
|
240
278
|
};
|
|
241
279
|
case "selection/end": return t.dragState?.type === "selection" ? {
|
|
@@ -247,15 +285,40 @@ var a = 60, o = (e, t, n) => Math.min(Math.max(e, t), n), s = (e, t) => {
|
|
|
247
285
|
selection: null,
|
|
248
286
|
dragState: null
|
|
249
287
|
};
|
|
288
|
+
case "selection/followActiveRow": return t.activeCell === null ? t : c(t, {
|
|
289
|
+
row: d.row,
|
|
290
|
+
col: t.activeCell.col
|
|
291
|
+
}, d.rowCount);
|
|
292
|
+
case "selection/collapseToActiveCell": {
|
|
293
|
+
let { activeCell: e, selection: n } = t;
|
|
294
|
+
return e === null || n?.type === "cell" && n.range.start.row === e.row && n.range.end.row === e.row && n.range.start.col === e.col && n.range.end.col === e.col ? t : {
|
|
295
|
+
...t,
|
|
296
|
+
selection: {
|
|
297
|
+
type: "cell",
|
|
298
|
+
range: {
|
|
299
|
+
start: e,
|
|
300
|
+
end: e
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
};
|
|
304
|
+
}
|
|
250
305
|
case "selection/clampToRowCount": {
|
|
251
|
-
let e = s(t,
|
|
252
|
-
return
|
|
306
|
+
let e = s(t, d.rowCount);
|
|
307
|
+
return d.colCount === void 0 ? e : l(e, d.colCount);
|
|
253
308
|
}
|
|
254
309
|
case "edit/start": return {
|
|
255
310
|
...t,
|
|
256
|
-
editingCell:
|
|
257
|
-
activeCell:
|
|
311
|
+
editingCell: d.cell,
|
|
312
|
+
activeCell: d.cell
|
|
258
313
|
};
|
|
314
|
+
case "edit/retarget": {
|
|
315
|
+
let e = c(t, d.cell, d.rowCount), n = t.editingCell;
|
|
316
|
+
return n !== null && n.row === d.cell.row && n.col === d.cell.col && e === t ? t : {
|
|
317
|
+
...e,
|
|
318
|
+
editingCell: d.cell,
|
|
319
|
+
activeCell: e.activeCell ?? d.cell
|
|
320
|
+
};
|
|
321
|
+
}
|
|
259
322
|
case "edit/stop": return t.editingCell === null ? t : {
|
|
260
323
|
...t,
|
|
261
324
|
editingCell: null
|
|
@@ -264,16 +327,16 @@ var a = 60, o = (e, t, n) => Math.min(Math.max(e, t), n), s = (e, t) => {
|
|
|
264
327
|
...t,
|
|
265
328
|
dragState: {
|
|
266
329
|
type: "columnResize",
|
|
267
|
-
columnKey:
|
|
268
|
-
startX:
|
|
269
|
-
startWidth:
|
|
270
|
-
minWidth:
|
|
271
|
-
maxWidth:
|
|
330
|
+
columnKey: d.columnKey,
|
|
331
|
+
startX: d.startX,
|
|
332
|
+
startWidth: d.startWidth,
|
|
333
|
+
minWidth: d.minWidth ?? a,
|
|
334
|
+
maxWidth: d.maxWidth ?? Infinity
|
|
272
335
|
}
|
|
273
336
|
};
|
|
274
337
|
case "column/resizeUpdate": {
|
|
275
338
|
if (t.dragState?.type !== "columnResize") return t;
|
|
276
|
-
let e = o(t.dragState.startWidth + (
|
|
339
|
+
let e = o(t.dragState.startWidth + (d.clientX - t.dragState.startX), t.dragState.minWidth, t.dragState.maxWidth);
|
|
277
340
|
return t.columnWidths[t.dragState.columnKey] === e ? t : {
|
|
278
341
|
...t,
|
|
279
342
|
columnWidths: {
|
|
@@ -290,44 +353,44 @@ var a = 60, o = (e, t, n) => Math.min(Math.max(e, t), n), s = (e, t) => {
|
|
|
290
353
|
...t,
|
|
291
354
|
columnWidths: {
|
|
292
355
|
...t.columnWidths,
|
|
293
|
-
...
|
|
356
|
+
...d.widths
|
|
294
357
|
}
|
|
295
358
|
};
|
|
296
359
|
case "columnWidths/reset": return {
|
|
297
360
|
...t,
|
|
298
|
-
columnWidths:
|
|
361
|
+
columnWidths: d.widths
|
|
299
362
|
};
|
|
300
363
|
case "columnWidths/reconcile": {
|
|
301
|
-
let n = e(t.columnWidths,
|
|
302
|
-
return
|
|
364
|
+
let n = e(t.columnWidths, d.prevColumns, d.nextColumns);
|
|
365
|
+
return u(n === t.columnWidths ? t : {
|
|
303
366
|
...t,
|
|
304
367
|
columnWidths: n
|
|
305
|
-
},
|
|
368
|
+
}, d.prevColumns, d.nextColumns);
|
|
306
369
|
}
|
|
307
|
-
case "filter/setGlobal": return t.filters.globalText ===
|
|
370
|
+
case "filter/setGlobal": return t.filters.globalText === d.value ? t : {
|
|
308
371
|
...t,
|
|
309
372
|
filters: {
|
|
310
373
|
...t.filters,
|
|
311
|
-
globalText:
|
|
374
|
+
globalText: d.value
|
|
312
375
|
}
|
|
313
376
|
};
|
|
314
377
|
case "filter/setColumn": {
|
|
315
|
-
let e = t.filters.columnFilters[
|
|
316
|
-
return e !== void 0 && (e ===
|
|
378
|
+
let e = t.filters.columnFilters[d.columnKey];
|
|
379
|
+
return e !== void 0 && (e === d.value || r(e, d.value)) ? t : {
|
|
317
380
|
...t,
|
|
318
381
|
filters: {
|
|
319
382
|
...t.filters,
|
|
320
383
|
columnFilters: {
|
|
321
384
|
...t.filters.columnFilters,
|
|
322
|
-
[
|
|
385
|
+
[d.columnKey]: d.value
|
|
323
386
|
}
|
|
324
387
|
}
|
|
325
388
|
};
|
|
326
389
|
}
|
|
327
390
|
case "filter/clearColumn": {
|
|
328
|
-
if (!(
|
|
391
|
+
if (!(d.columnKey in t.filters.columnFilters)) return t;
|
|
329
392
|
let e = { ...t.filters.columnFilters };
|
|
330
|
-
return delete e[
|
|
393
|
+
return delete e[d.columnKey], {
|
|
331
394
|
...t,
|
|
332
395
|
filters: {
|
|
333
396
|
...t.filters,
|
|
@@ -344,60 +407,60 @@ var a = 60, o = (e, t, n) => Math.min(Math.max(e, t), n), s = (e, t) => {
|
|
|
344
407
|
};
|
|
345
408
|
case "filter/setAll": return {
|
|
346
409
|
...t,
|
|
347
|
-
filters:
|
|
410
|
+
filters: d.filters
|
|
348
411
|
};
|
|
349
|
-
case "sort/set": return i(t.sort,
|
|
412
|
+
case "sort/set": return i(t.sort, d.entries) ? t : {
|
|
350
413
|
...t,
|
|
351
|
-
sort:
|
|
414
|
+
sort: d.entries
|
|
352
415
|
};
|
|
353
416
|
case "sort/clear": return t.sort.length === 0 ? t : {
|
|
354
417
|
...t,
|
|
355
418
|
sort: []
|
|
356
419
|
};
|
|
357
|
-
case "rowSelect/set": return n(t.rowSelection,
|
|
420
|
+
case "rowSelect/set": return n(t.rowSelection, d.state) ? t : {
|
|
358
421
|
...t,
|
|
359
|
-
rowSelection:
|
|
422
|
+
rowSelection: d.state
|
|
360
423
|
};
|
|
361
424
|
case "group/toggleCollapsed": {
|
|
362
425
|
let e = new Set(t.collapsedGroupKeys);
|
|
363
|
-
return e.has(
|
|
426
|
+
return e.has(d.groupKey) ? e.delete(d.groupKey) : e.add(d.groupKey), {
|
|
364
427
|
...t,
|
|
365
428
|
collapsedGroupKeys: e
|
|
366
429
|
};
|
|
367
430
|
}
|
|
368
431
|
case "group/setCollapsed": {
|
|
369
|
-
if (t.collapsedGroupKeys.has(
|
|
432
|
+
if (t.collapsedGroupKeys.has(d.groupKey) === d.collapsed) return t;
|
|
370
433
|
let e = new Set(t.collapsedGroupKeys);
|
|
371
|
-
return
|
|
434
|
+
return d.collapsed ? e.add(d.groupKey) : e.delete(d.groupKey), {
|
|
372
435
|
...t,
|
|
373
436
|
collapsedGroupKeys: e
|
|
374
437
|
};
|
|
375
438
|
}
|
|
376
|
-
case "group/setCollapsedKeys": return
|
|
439
|
+
case "group/setCollapsedKeys": return d.keys === t.collapsedGroupKeys || d.keys.size === 0 && t.collapsedGroupKeys.size === 0 ? t : {
|
|
377
440
|
...t,
|
|
378
|
-
collapsedGroupKeys:
|
|
441
|
+
collapsedGroupKeys: d.keys
|
|
379
442
|
};
|
|
380
443
|
case "detail/toggle": {
|
|
381
444
|
let e = new Set(t.expandedDetailRowKeys);
|
|
382
|
-
return e.has(
|
|
445
|
+
return e.has(d.rowKey) ? e.delete(d.rowKey) : e.add(d.rowKey), {
|
|
383
446
|
...t,
|
|
384
447
|
expandedDetailRowKeys: e
|
|
385
448
|
};
|
|
386
449
|
}
|
|
387
450
|
case "detail/setExpanded": {
|
|
388
|
-
if (t.expandedDetailRowKeys.has(
|
|
451
|
+
if (t.expandedDetailRowKeys.has(d.rowKey) === d.expanded) return t;
|
|
389
452
|
let e = new Set(t.expandedDetailRowKeys);
|
|
390
|
-
return
|
|
453
|
+
return d.expanded ? e.add(d.rowKey) : e.delete(d.rowKey), {
|
|
391
454
|
...t,
|
|
392
455
|
expandedDetailRowKeys: e
|
|
393
456
|
};
|
|
394
457
|
}
|
|
395
|
-
case "detail/setKeys": return
|
|
458
|
+
case "detail/setKeys": return d.keys === t.expandedDetailRowKeys || d.keys.size === 0 && t.expandedDetailRowKeys.size === 0 ? t : {
|
|
396
459
|
...t,
|
|
397
|
-
expandedDetailRowKeys:
|
|
460
|
+
expandedDetailRowKeys: d.keys
|
|
398
461
|
};
|
|
399
462
|
default: return t;
|
|
400
463
|
}
|
|
401
464
|
};
|
|
402
465
|
//#endregion
|
|
403
|
-
export {
|
|
466
|
+
export { d as createInitialGridUiState, f as gridUiReducer };
|