@ishibashi0112/spreadsheet-grid-core 0.41.1 → 0.42.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/asyncSelectOptionsSource.d.ts +2 -2
- package/dist/controllers/autoHeightMeasurer.d.ts +3 -3
- package/dist/controllers/clipboardController.cjs +2 -2
- package/dist/controllers/clipboardController.d.ts +5 -3
- package/dist/controllers/clipboardController.js +60 -57
- package/dist/controllers/columnAutosizeRunner.d.ts +2 -2
- package/dist/controllers/columnHeaderDragController.d.ts +2 -2
- package/dist/controllers/columnMenuController.cjs +1 -1
- package/dist/controllers/columnMenuController.d.ts +2 -2
- package/dist/controllers/columnMenuController.js +60 -60
- package/dist/controllers/contextMenuController.cjs +1 -1
- package/dist/controllers/contextMenuController.d.ts +2 -2
- package/dist/controllers/contextMenuController.js +32 -32
- package/dist/controllers/editController.cjs +1 -1
- package/dist/controllers/editController.d.ts +5 -3
- package/dist/controllers/editController.js +97 -51
- package/dist/controllers/filterPopoverController.cjs +1 -1
- package/dist/controllers/filterPopoverController.d.ts +5 -5
- package/dist/controllers/filterPopoverController.js +78 -78
- package/dist/controllers/globalFilteredOrder.d.ts +2 -2
- package/dist/controllers/historyController.d.ts +2 -2
- package/dist/controllers/keyboardController.cjs +1 -1
- package/dist/controllers/keyboardController.d.ts +2 -2
- package/dist/controllers/keyboardController.js +2 -0
- package/dist/controllers/pointerInteractionsController.d.ts +4 -4
- package/dist/controllers/popoverSupport.cjs +1 -1
- package/dist/controllers/popoverSupport.d.ts +2 -1
- package/dist/controllers/popoverSupport.js +3 -3
- package/dist/controllers/rowDragController.d.ts +2 -2
- package/dist/controllers/scrollSyncController.d.ts +2 -2
- package/dist/controllers/selectOptionsCollector.d.ts +2 -2
- package/dist/controllers/serverSideRowModel.cjs +1 -1
- package/dist/controllers/serverSideRowModel.d.ts +2 -2
- package/dist/controllers/serverSideRowModel.js +5 -3
- package/dist/controllers/toolPanelController.cjs +1 -1
- package/dist/controllers/toolPanelController.d.ts +1 -1
- package/dist/controllers/toolPanelController.js +53 -53
- package/dist/controllers/tooltipController.d.ts +1 -1
- package/dist/controllers/viewportSyncController.d.ts +2 -2
- package/dist/engine/columnCommands.cjs +1 -1
- package/dist/engine/columnCommands.d.ts +4 -4
- package/dist/engine/columnCommands.js +2 -2
- package/dist/engine/columnLayout.d.ts +2 -2
- package/dist/engine/createGridEngine.cjs +1 -1
- package/dist/engine/createGridEngine.d.ts +14 -14
- package/dist/engine/createGridEngine.js +1 -1
- package/dist/engine/filterPopoverCommands.d.ts +7 -7
- package/dist/engine/gridApi.cjs +1 -1
- package/dist/engine/gridApi.d.ts +10 -8
- package/dist/engine/gridApi.js +115 -79
- package/dist/engine/notifiers.d.ts +1 -1
- package/dist/engine/rowPipeline.cjs +1 -1
- package/dist/engine/rowPipeline.d.ts +5 -5
- package/dist/engine/rowPipeline.js +1 -1
- package/dist/engine/rowSelectionCommands.d.ts +2 -2
- package/dist/engine/verticalLayout.d.ts +5 -5
- package/dist/index.d.ts +8 -8
- package/dist/logic/aggregation.d.ts +1 -1
- package/dist/logic/autoSizeOnData.d.ts +1 -1
- package/dist/logic/clearCells.d.ts +2 -2
- package/dist/logic/columnAutosize.d.ts +1 -1
- package/dist/logic/columnFlex.d.ts +1 -1
- package/dist/logic/columnReset.d.ts +1 -1
- package/dist/logic/columnWidthState.cjs +1 -0
- package/dist/logic/columnWidthState.d.ts +2 -0
- package/dist/logic/columnWidthState.js +30 -0
- package/dist/logic/contextMenuTarget.d.ts +1 -1
- package/dist/logic/dateFilterCondition.d.ts +2 -2
- package/dist/logic/dateFilterPresets.d.ts +1 -1
- package/dist/logic/detailRow.d.ts +2 -2
- package/dist/logic/domGuards.cjs +1 -1
- package/dist/logic/domGuards.js +1 -1
- package/dist/logic/editorValues.d.ts +1 -1
- package/dist/logic/exportCsv.d.ts +1 -1
- package/dist/logic/exportData.d.ts +2 -2
- package/dist/logic/exportScope.d.ts +1 -1
- package/dist/logic/filterSummary.d.ts +2 -2
- package/dist/logic/filtering.d.ts +2 -2
- package/dist/logic/geometry.d.ts +1 -1
- package/dist/logic/gridState.cjs +1 -1
- package/dist/logic/gridState.d.ts +1 -1
- package/dist/logic/gridState.js +59 -44
- package/dist/logic/grouping.d.ts +3 -3
- package/dist/logic/inferFilterType.d.ts +1 -1
- package/dist/logic/labelRows.d.ts +2 -2
- package/dist/logic/numberFilterCondition.d.ts +1 -1
- package/dist/logic/rowHeightStore.d.ts +2 -2
- package/dist/logic/rowReorder.d.ts +1 -1
- package/dist/logic/rowSelection.d.ts +1 -1
- package/dist/logic/scrollHint.d.ts +1 -1
- package/dist/logic/scrollTargets.d.ts +1 -1
- package/dist/logic/selectEditorState.d.ts +1 -1
- package/dist/logic/serverSideEdits.d.ts +1 -1
- package/dist/logic/serverSideQuery.d.ts +1 -1
- package/dist/logic/sorting.cjs +1 -1
- package/dist/logic/sorting.d.ts +3 -2
- package/dist/logic/sorting.js +81 -50
- package/dist/logic/textFilterCondition.d.ts +1 -1
- package/dist/logic/theme.d.ts +1 -1
- package/dist/logic/validation.d.ts +1 -1
- package/dist/logic/valueFormatters.cjs +1 -1
- package/dist/logic/valueFormatters.d.ts +1 -1
- package/dist/logic/valueFormatters.js +12 -9
- package/dist/model/gridActions.cjs +1 -1
- package/dist/model/gridActions.d.ts +10 -1
- package/dist/model/gridActions.js +9 -0
- package/dist/model/gridReducer.cjs +1 -1
- package/dist/model/gridReducer.d.ts +3 -3
- package/dist/model/gridReducer.js +178 -110
- package/dist/model/gridSelectors.d.ts +3 -3
- package/dist/model/gridStore.d.ts +2 -2
- package/dist/model/gridTypes.core.d.ts +47 -9
- package/dist/model/gridTypes.unbound.d.ts +2 -2
- package/dist/utils/clipboard.cjs +6 -5
- package/dist/utils/clipboard.d.ts +4 -2
- package/dist/utils/clipboard.js +52 -17
- package/dist/utils/permissions.d.ts +1 -1
- package/package.json +4 -3
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
//#region src/logic/valueFormatters.ts
|
|
2
2
|
function e(e = {}) {
|
|
3
|
-
let { locale: t, useGrouping: n = !0, minimumFractionDigits: r, maximumFractionDigits: i, emptyText: a = "" } = e
|
|
3
|
+
let { locale: t, useGrouping: n = !0, minimumFractionDigits: r, maximumFractionDigits: i, emptyText: a = "" } = e, o = /* @__PURE__ */ new Map(), s = (e, r) => {
|
|
4
|
+
let i = `${e}:${r}`, a = o.get(i);
|
|
5
|
+
return a || (a = new Intl.NumberFormat(t, {
|
|
6
|
+
useGrouping: n,
|
|
7
|
+
minimumFractionDigits: e,
|
|
8
|
+
maximumFractionDigits: r
|
|
9
|
+
}), o.set(i, a)), a;
|
|
10
|
+
};
|
|
4
11
|
return ({ value: e }) => {
|
|
5
12
|
if (e == null || e === "") return a;
|
|
6
|
-
let
|
|
7
|
-
if (!Number.isFinite(
|
|
8
|
-
let
|
|
9
|
-
return
|
|
10
|
-
useGrouping: n,
|
|
11
|
-
minimumFractionDigits: u,
|
|
12
|
-
maximumFractionDigits: d
|
|
13
|
-
}).format(o);
|
|
13
|
+
let t = typeof e == "number" ? e : Number(e);
|
|
14
|
+
if (!Number.isFinite(t)) return String(e);
|
|
15
|
+
let n = Math.abs(t).toString(), o = n.indexOf("."), c = o === -1 ? 0 : n.length - o - 1, l = r ?? 0;
|
|
16
|
+
return s(l, Math.max(l, i ?? Math.min(c, 20))).format(t);
|
|
14
17
|
};
|
|
15
18
|
}
|
|
16
19
|
//#endregion
|
|
@@ -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=>({type:`rowSelection/start`,row:e}),updateRowSelection:e=>({type:`rowSelection/update`,row:e}),startColumnSelection:e=>({type:`columnSelection/start`,col:e}),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}),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=>({type:`rowSelection/start`,row:e}),updateRowSelection:e=>({type:`rowSelection/update`,row:e}),startColumnSelection:e=>({type:`columnSelection/start`,col:e}),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=>({type:`selection/clampToRowCount`,rowCount:e}),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,4 +1,4 @@
|
|
|
1
|
-
import type { CellCoord, ColumnFilterValue, GridFilterState, GridRowKey, GridSortEntry, RowSelectionState } from './gridTypes.unbound';
|
|
1
|
+
import type { CellCoord, ColumnFilterValue, GridColumn, GridFilterState, GridRowKey, GridSortEntry, RowSelectionState } from './gridTypes.unbound.js';
|
|
2
2
|
export type GridUiAction = {
|
|
3
3
|
type: 'cell/activate';
|
|
4
4
|
cell: CellCoord | null;
|
|
@@ -24,6 +24,9 @@ export type GridUiAction = {
|
|
|
24
24
|
type: 'selection/end';
|
|
25
25
|
} | {
|
|
26
26
|
type: 'selection/clear';
|
|
27
|
+
} | {
|
|
28
|
+
type: 'selection/clampToRowCount';
|
|
29
|
+
rowCount: number;
|
|
27
30
|
} | {
|
|
28
31
|
type: 'edit/start';
|
|
29
32
|
cell: CellCoord;
|
|
@@ -47,6 +50,10 @@ export type GridUiAction = {
|
|
|
47
50
|
} | {
|
|
48
51
|
type: 'columnWidths/reset';
|
|
49
52
|
widths: Record<string, number>;
|
|
53
|
+
} | {
|
|
54
|
+
type: 'columnWidths/reconcile';
|
|
55
|
+
prevColumns: readonly GridColumn<unknown>[] | null;
|
|
56
|
+
nextColumns: readonly GridColumn<unknown>[];
|
|
50
57
|
} | {
|
|
51
58
|
type: 'filter/setGlobal';
|
|
52
59
|
value: string;
|
|
@@ -108,6 +115,8 @@ export declare const gridActions: {
|
|
|
108
115
|
endColumnResize: () => GridUiAction;
|
|
109
116
|
syncColumnWidths: (widths: Record<string, number>) => GridUiAction;
|
|
110
117
|
resetColumnWidths: (widths: Record<string, number>) => GridUiAction;
|
|
118
|
+
clampSelectionToRowCount: (rowCount: number) => GridUiAction;
|
|
119
|
+
reconcileColumnWidths: <T>(prevColumns: readonly GridColumn<T>[] | null, nextColumns: readonly GridColumn<T>[]) => GridUiAction;
|
|
111
120
|
setGlobalFilter: (value: string) => GridUiAction;
|
|
112
121
|
setColumnFilter: (columnKey: string, value: ColumnFilterValue) => GridUiAction;
|
|
113
122
|
clearColumnFilter: (columnKey: string) => GridUiAction;
|
|
@@ -56,6 +56,15 @@ var e = {
|
|
|
56
56
|
type: "columnWidths/reset",
|
|
57
57
|
widths: e
|
|
58
58
|
}),
|
|
59
|
+
clampSelectionToRowCount: (e) => ({
|
|
60
|
+
type: "selection/clampToRowCount",
|
|
61
|
+
rowCount: e
|
|
62
|
+
}),
|
|
63
|
+
reconcileColumnWidths: (e, t) => ({
|
|
64
|
+
type: "columnWidths/reconcile",
|
|
65
|
+
prevColumns: e,
|
|
66
|
+
nextColumns: t
|
|
67
|
+
}),
|
|
59
68
|
setGlobalFilter: (e) => ({
|
|
60
69
|
type: "filter/setGlobal",
|
|
61
70
|
value: e
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../logic/
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../logic/columnWidthState.cjs"),t=require("../logic/rowSelection.cjs");var n=60,r=(e,t,n)=>Math.min(Math.max(e,t),n),i=(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},a=()=>({activeCell:null,selection:null,rowSelection:t.createEmptyRowSelection(),editingCell:null,dragState:null,columnWidths:{},filters:{globalText:``,columnFilters:{}},sort:[],collapsedGroupKeys:new Set,expandedDetailRowKeys:new Set}),o=(a,o)=>{switch(o.type){case`cell/activate`:return{...a,activeCell:o.cell};case`selection/start`:return{...a,activeCell:o.cell,selection:{type:`cell`,range:{start:o.cell,end:o.cell}},dragState:{type:`selection`,selectionKind:`cell`,anchor:o.cell}};case`rowSelection/start`:return{...a,activeCell:{row:o.row,col:a.activeCell?.col??0},selection:{type:`row`,startRow:o.row,endRow:o.row},dragState:{type:`selection`,selectionKind:`row`,anchorRow:o.row}};case`rowSelection/update`:return a.dragState?.type!==`selection`||a.dragState.selectionKind!==`row`||a.selection?.type===`row`&&a.selection.endRow===o.row?a:{...a,selection:{type:`row`,startRow:a.dragState.anchorRow,endRow:o.row}};case`selection/update`:return a.dragState?.type!==`selection`||a.dragState.selectionKind!==`cell`||a.selection?.type===`cell`&&a.selection.range.end.row===o.cell.row&&a.selection.range.end.col===o.cell.col?a:{...a,selection:{type:`cell`,range:{start:a.dragState.anchor,end:o.cell}}};case`columnSelection/start`:return{...a,activeCell:{row:a.activeCell?.row??0,col:o.col},selection:{type:`col`,startCol:o.col,endCol:o.col},dragState:{type:`selection`,selectionKind:`col`,anchorCol:o.col}};case`columnSelection/update`:return a.dragState?.type!==`selection`||a.dragState.selectionKind!==`col`||a.selection?.type===`col`&&a.selection.endCol===o.col?a:{...a,selection:{type:`col`,startCol:a.dragState.anchorCol,endCol:o.col}};case`selection/end`:return a.dragState?.type===`selection`?{...a,dragState:null}:a;case`selection/clear`:return{...a,selection:null,dragState:null};case`selection/clampToRowCount`:return i(a,o.rowCount);case`edit/start`:return{...a,editingCell:o.cell,activeCell:o.cell};case`edit/stop`:return{...a,editingCell:null};case`column/resizeStart`:return{...a,dragState:{type:`columnResize`,columnKey:o.columnKey,startX:o.startX,startWidth:o.startWidth,minWidth:o.minWidth||n,maxWidth:o.maxWidth??1/0}};case`column/resizeUpdate`:{if(a.dragState?.type!==`columnResize`)return a;let e=r(a.dragState.startWidth+(o.clientX-a.dragState.startX),a.dragState.minWidth,a.dragState.maxWidth);return a.columnWidths[a.dragState.columnKey]===e?a:{...a,columnWidths:{...a.columnWidths,[a.dragState.columnKey]:e}}}case`column/resizeEnd`:return a.dragState?.type===`columnResize`?{...a,dragState:null}:a;case`columnWidths/sync`:return{...a,columnWidths:{...a.columnWidths,...o.widths}};case`columnWidths/reset`:return{...a,columnWidths:o.widths};case`columnWidths/reconcile`:{let t=e.reconcileColumnWidths(a.columnWidths,o.prevColumns,o.nextColumns);return t===a.columnWidths?a:{...a,columnWidths:t}}case`filter/setGlobal`:return{...a,filters:{...a.filters,globalText:o.value}};case`filter/setColumn`:return{...a,filters:{...a.filters,columnFilters:{...a.filters.columnFilters,[o.columnKey]:o.value}}};case`filter/clearColumn`:{let e={...a.filters.columnFilters};return delete e[o.columnKey],{...a,filters:{...a.filters,columnFilters:e}}}case`filter/resetAll`:return{...a,filters:{globalText:``,columnFilters:{}}};case`filter/setAll`:return{...a,filters:o.filters};case`sort/set`:return{...a,sort:o.entries};case`sort/clear`:return{...a,sort:[]};case`rowSelect/set`:return t.rowSelectionStateEquals(a.rowSelection,o.state)?a:{...a,rowSelection:o.state};case`group/toggleCollapsed`:{let e=new Set(a.collapsedGroupKeys);return e.has(o.groupKey)?e.delete(o.groupKey):e.add(o.groupKey),{...a,collapsedGroupKeys:e}}case`group/setCollapsed`:{if(a.collapsedGroupKeys.has(o.groupKey)===o.collapsed)return a;let e=new Set(a.collapsedGroupKeys);return o.collapsed?e.add(o.groupKey):e.delete(o.groupKey),{...a,collapsedGroupKeys:e}}case`group/setCollapsedKeys`:return o.keys===a.collapsedGroupKeys||o.keys.size===0&&a.collapsedGroupKeys.size===0?a:{...a,collapsedGroupKeys:o.keys};case`detail/toggle`:{let e=new Set(a.expandedDetailRowKeys);return e.has(o.rowKey)?e.delete(o.rowKey):e.add(o.rowKey),{...a,expandedDetailRowKeys:e}}case`detail/setExpanded`:{if(a.expandedDetailRowKeys.has(o.rowKey)===o.expanded)return a;let e=new Set(a.expandedDetailRowKeys);return o.expanded?e.add(o.rowKey):e.delete(o.rowKey),{...a,expandedDetailRowKeys:e}}case`detail/setKeys`:return o.keys===a.expandedDetailRowKeys||o.keys.size===0&&a.expandedDetailRowKeys.size===0?a:{...a,expandedDetailRowKeys:o.keys};default:return a}};exports.createInitialGridUiState=a,exports.gridUiReducer=o;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { GridUiAction } from './gridActions';
|
|
2
|
-
import type {
|
|
3
|
-
export declare const createInitialGridUiState:
|
|
1
|
+
import type { GridUiAction } from './gridActions.js';
|
|
2
|
+
import type { GridUiState } from './gridTypes.unbound.js';
|
|
3
|
+
export declare const createInitialGridUiState: () => GridUiState;
|
|
4
4
|
export declare const gridUiReducer: (state: GridUiState, action: GridUiAction) => GridUiState;
|
|
@@ -1,13 +1,73 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { reconcileColumnWidths as e } from "../logic/columnWidthState.js";
|
|
2
2
|
import { createEmptyRowSelection as t, rowSelectionStateEquals as n } from "../logic/rowSelection.js";
|
|
3
3
|
//#region src/model/gridReducer.ts
|
|
4
|
-
var r = 60, i = (e, t, n) => Math.min(Math.max(e, t), n), a = (
|
|
4
|
+
var r = 60, i = (e, t, n) => Math.min(Math.max(e, t), n), a = (e, t) => {
|
|
5
|
+
let { activeCell: n, selection: r, dragState: i } = e;
|
|
6
|
+
if (t <= 0) {
|
|
7
|
+
let t = r !== null && r.type !== "col", a = i?.type === "selection" && i.selectionKind !== "col";
|
|
8
|
+
return n === null && !t && !a ? e : {
|
|
9
|
+
...e,
|
|
10
|
+
activeCell: null,
|
|
11
|
+
selection: t ? null : r,
|
|
12
|
+
dragState: a ? null : i
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
let a = t - 1, o = e;
|
|
16
|
+
if (n !== null && n.row > a && (o = {
|
|
17
|
+
...o,
|
|
18
|
+
activeCell: {
|
|
19
|
+
row: a,
|
|
20
|
+
col: n.col
|
|
21
|
+
}
|
|
22
|
+
}), r?.type === "cell") {
|
|
23
|
+
let { start: e, end: t } = r.range;
|
|
24
|
+
(e.row > a || t.row > a) && (o = {
|
|
25
|
+
...o,
|
|
26
|
+
selection: {
|
|
27
|
+
type: "cell",
|
|
28
|
+
range: {
|
|
29
|
+
start: {
|
|
30
|
+
row: Math.min(e.row, a),
|
|
31
|
+
col: e.col
|
|
32
|
+
},
|
|
33
|
+
end: {
|
|
34
|
+
row: Math.min(t.row, a),
|
|
35
|
+
col: t.col
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
} else r?.type === "row" && (r.startRow > a || r.endRow > a) && (o = {
|
|
41
|
+
...o,
|
|
42
|
+
selection: {
|
|
43
|
+
type: "row",
|
|
44
|
+
startRow: Math.min(r.startRow, a),
|
|
45
|
+
endRow: Math.min(r.endRow, a)
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
return i?.type === "selection" && (i.selectionKind === "cell" && i.anchor.row > a ? o = {
|
|
49
|
+
...o,
|
|
50
|
+
dragState: {
|
|
51
|
+
...i,
|
|
52
|
+
anchor: {
|
|
53
|
+
row: a,
|
|
54
|
+
col: i.anchor.col
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
} : i.selectionKind === "row" && i.anchorRow > a && (o = {
|
|
58
|
+
...o,
|
|
59
|
+
dragState: {
|
|
60
|
+
...i,
|
|
61
|
+
anchorRow: a
|
|
62
|
+
}
|
|
63
|
+
})), o;
|
|
64
|
+
}, o = () => ({
|
|
5
65
|
activeCell: null,
|
|
6
66
|
selection: null,
|
|
7
67
|
rowSelection: t(),
|
|
8
68
|
editingCell: null,
|
|
9
69
|
dragState: null,
|
|
10
|
-
columnWidths:
|
|
70
|
+
columnWidths: {},
|
|
11
71
|
filters: {
|
|
12
72
|
globalText: "",
|
|
13
73
|
columnFilters: {}
|
|
@@ -15,232 +75,240 @@ var r = 60, i = (e, t, n) => Math.min(Math.max(e, t), n), a = (t) => t.reduce((t
|
|
|
15
75
|
sort: [],
|
|
16
76
|
collapsedGroupKeys: /* @__PURE__ */ new Set(),
|
|
17
77
|
expandedDetailRowKeys: /* @__PURE__ */ new Set()
|
|
18
|
-
}), s = (
|
|
19
|
-
switch (
|
|
78
|
+
}), s = (t, o) => {
|
|
79
|
+
switch (o.type) {
|
|
20
80
|
case "cell/activate": return {
|
|
21
|
-
...
|
|
22
|
-
activeCell:
|
|
81
|
+
...t,
|
|
82
|
+
activeCell: o.cell
|
|
23
83
|
};
|
|
24
84
|
case "selection/start": return {
|
|
25
|
-
...
|
|
26
|
-
activeCell:
|
|
85
|
+
...t,
|
|
86
|
+
activeCell: o.cell,
|
|
27
87
|
selection: {
|
|
28
88
|
type: "cell",
|
|
29
89
|
range: {
|
|
30
|
-
start:
|
|
31
|
-
end:
|
|
90
|
+
start: o.cell,
|
|
91
|
+
end: o.cell
|
|
32
92
|
}
|
|
33
93
|
},
|
|
34
94
|
dragState: {
|
|
35
95
|
type: "selection",
|
|
36
96
|
selectionKind: "cell",
|
|
37
|
-
anchor:
|
|
97
|
+
anchor: o.cell
|
|
38
98
|
}
|
|
39
99
|
};
|
|
40
100
|
case "rowSelection/start": return {
|
|
41
|
-
...
|
|
101
|
+
...t,
|
|
42
102
|
activeCell: {
|
|
43
|
-
row:
|
|
44
|
-
col:
|
|
103
|
+
row: o.row,
|
|
104
|
+
col: t.activeCell?.col ?? 0
|
|
45
105
|
},
|
|
46
106
|
selection: {
|
|
47
107
|
type: "row",
|
|
48
|
-
startRow:
|
|
49
|
-
endRow:
|
|
108
|
+
startRow: o.row,
|
|
109
|
+
endRow: o.row
|
|
50
110
|
},
|
|
51
111
|
dragState: {
|
|
52
112
|
type: "selection",
|
|
53
113
|
selectionKind: "row",
|
|
54
|
-
anchorRow:
|
|
114
|
+
anchorRow: o.row
|
|
55
115
|
}
|
|
56
116
|
};
|
|
57
|
-
case "rowSelection/update": return
|
|
58
|
-
...
|
|
117
|
+
case "rowSelection/update": return t.dragState?.type !== "selection" || t.dragState.selectionKind !== "row" || t.selection?.type === "row" && t.selection.endRow === o.row ? t : {
|
|
118
|
+
...t,
|
|
59
119
|
selection: {
|
|
60
120
|
type: "row",
|
|
61
|
-
startRow:
|
|
62
|
-
endRow:
|
|
121
|
+
startRow: t.dragState.anchorRow,
|
|
122
|
+
endRow: o.row
|
|
63
123
|
}
|
|
64
124
|
};
|
|
65
|
-
case "selection/update": return
|
|
66
|
-
...
|
|
125
|
+
case "selection/update": return t.dragState?.type !== "selection" || t.dragState.selectionKind !== "cell" || t.selection?.type === "cell" && t.selection.range.end.row === o.cell.row && t.selection.range.end.col === o.cell.col ? t : {
|
|
126
|
+
...t,
|
|
67
127
|
selection: {
|
|
68
128
|
type: "cell",
|
|
69
129
|
range: {
|
|
70
|
-
start:
|
|
71
|
-
end:
|
|
130
|
+
start: t.dragState.anchor,
|
|
131
|
+
end: o.cell
|
|
72
132
|
}
|
|
73
133
|
}
|
|
74
134
|
};
|
|
75
135
|
case "columnSelection/start": return {
|
|
76
|
-
...
|
|
136
|
+
...t,
|
|
77
137
|
activeCell: {
|
|
78
|
-
row:
|
|
79
|
-
col:
|
|
138
|
+
row: t.activeCell?.row ?? 0,
|
|
139
|
+
col: o.col
|
|
80
140
|
},
|
|
81
141
|
selection: {
|
|
82
142
|
type: "col",
|
|
83
|
-
startCol:
|
|
84
|
-
endCol:
|
|
143
|
+
startCol: o.col,
|
|
144
|
+
endCol: o.col
|
|
85
145
|
},
|
|
86
146
|
dragState: {
|
|
87
147
|
type: "selection",
|
|
88
148
|
selectionKind: "col",
|
|
89
|
-
anchorCol:
|
|
149
|
+
anchorCol: o.col
|
|
90
150
|
}
|
|
91
151
|
};
|
|
92
|
-
case "columnSelection/update": return
|
|
93
|
-
...
|
|
152
|
+
case "columnSelection/update": return t.dragState?.type !== "selection" || t.dragState.selectionKind !== "col" || t.selection?.type === "col" && t.selection.endCol === o.col ? t : {
|
|
153
|
+
...t,
|
|
94
154
|
selection: {
|
|
95
155
|
type: "col",
|
|
96
|
-
startCol:
|
|
97
|
-
endCol:
|
|
156
|
+
startCol: t.dragState.anchorCol,
|
|
157
|
+
endCol: o.col
|
|
98
158
|
}
|
|
99
159
|
};
|
|
100
|
-
case "selection/end": return
|
|
101
|
-
...
|
|
160
|
+
case "selection/end": return t.dragState?.type === "selection" ? {
|
|
161
|
+
...t,
|
|
102
162
|
dragState: null
|
|
103
|
-
} :
|
|
163
|
+
} : t;
|
|
104
164
|
case "selection/clear": return {
|
|
105
|
-
...
|
|
165
|
+
...t,
|
|
106
166
|
selection: null,
|
|
107
167
|
dragState: null
|
|
108
168
|
};
|
|
169
|
+
case "selection/clampToRowCount": return a(t, o.rowCount);
|
|
109
170
|
case "edit/start": return {
|
|
110
|
-
...
|
|
111
|
-
editingCell:
|
|
112
|
-
activeCell:
|
|
171
|
+
...t,
|
|
172
|
+
editingCell: o.cell,
|
|
173
|
+
activeCell: o.cell
|
|
113
174
|
};
|
|
114
175
|
case "edit/stop": return {
|
|
115
|
-
...
|
|
176
|
+
...t,
|
|
116
177
|
editingCell: null
|
|
117
178
|
};
|
|
118
179
|
case "column/resizeStart": return {
|
|
119
|
-
...
|
|
180
|
+
...t,
|
|
120
181
|
dragState: {
|
|
121
182
|
type: "columnResize",
|
|
122
|
-
columnKey:
|
|
123
|
-
startX:
|
|
124
|
-
startWidth:
|
|
125
|
-
minWidth:
|
|
126
|
-
maxWidth:
|
|
183
|
+
columnKey: o.columnKey,
|
|
184
|
+
startX: o.startX,
|
|
185
|
+
startWidth: o.startWidth,
|
|
186
|
+
minWidth: o.minWidth || r,
|
|
187
|
+
maxWidth: o.maxWidth ?? Infinity
|
|
127
188
|
}
|
|
128
189
|
};
|
|
129
190
|
case "column/resizeUpdate": {
|
|
130
|
-
if (
|
|
131
|
-
let
|
|
132
|
-
return
|
|
133
|
-
...
|
|
191
|
+
if (t.dragState?.type !== "columnResize") return t;
|
|
192
|
+
let e = i(t.dragState.startWidth + (o.clientX - t.dragState.startX), t.dragState.minWidth, t.dragState.maxWidth);
|
|
193
|
+
return t.columnWidths[t.dragState.columnKey] === e ? t : {
|
|
194
|
+
...t,
|
|
134
195
|
columnWidths: {
|
|
135
|
-
...
|
|
136
|
-
[
|
|
196
|
+
...t.columnWidths,
|
|
197
|
+
[t.dragState.columnKey]: e
|
|
137
198
|
}
|
|
138
199
|
};
|
|
139
200
|
}
|
|
140
|
-
case "column/resizeEnd": return
|
|
141
|
-
...
|
|
201
|
+
case "column/resizeEnd": return t.dragState?.type === "columnResize" ? {
|
|
202
|
+
...t,
|
|
142
203
|
dragState: null
|
|
143
|
-
} :
|
|
204
|
+
} : t;
|
|
144
205
|
case "columnWidths/sync": return {
|
|
145
|
-
...
|
|
206
|
+
...t,
|
|
146
207
|
columnWidths: {
|
|
147
|
-
...
|
|
148
|
-
...
|
|
208
|
+
...t.columnWidths,
|
|
209
|
+
...o.widths
|
|
149
210
|
}
|
|
150
211
|
};
|
|
151
212
|
case "columnWidths/reset": return {
|
|
152
|
-
...
|
|
153
|
-
columnWidths:
|
|
213
|
+
...t,
|
|
214
|
+
columnWidths: o.widths
|
|
154
215
|
};
|
|
216
|
+
case "columnWidths/reconcile": {
|
|
217
|
+
let n = e(t.columnWidths, o.prevColumns, o.nextColumns);
|
|
218
|
+
return n === t.columnWidths ? t : {
|
|
219
|
+
...t,
|
|
220
|
+
columnWidths: n
|
|
221
|
+
};
|
|
222
|
+
}
|
|
155
223
|
case "filter/setGlobal": return {
|
|
156
|
-
...
|
|
224
|
+
...t,
|
|
157
225
|
filters: {
|
|
158
|
-
...
|
|
159
|
-
globalText:
|
|
226
|
+
...t.filters,
|
|
227
|
+
globalText: o.value
|
|
160
228
|
}
|
|
161
229
|
};
|
|
162
230
|
case "filter/setColumn": return {
|
|
163
|
-
...
|
|
231
|
+
...t,
|
|
164
232
|
filters: {
|
|
165
|
-
...
|
|
233
|
+
...t.filters,
|
|
166
234
|
columnFilters: {
|
|
167
|
-
...
|
|
168
|
-
[
|
|
235
|
+
...t.filters.columnFilters,
|
|
236
|
+
[o.columnKey]: o.value
|
|
169
237
|
}
|
|
170
238
|
}
|
|
171
239
|
};
|
|
172
240
|
case "filter/clearColumn": {
|
|
173
|
-
let
|
|
174
|
-
return delete
|
|
175
|
-
...
|
|
241
|
+
let e = { ...t.filters.columnFilters };
|
|
242
|
+
return delete e[o.columnKey], {
|
|
243
|
+
...t,
|
|
176
244
|
filters: {
|
|
177
|
-
...
|
|
178
|
-
columnFilters:
|
|
245
|
+
...t.filters,
|
|
246
|
+
columnFilters: e
|
|
179
247
|
}
|
|
180
248
|
};
|
|
181
249
|
}
|
|
182
250
|
case "filter/resetAll": return {
|
|
183
|
-
...
|
|
251
|
+
...t,
|
|
184
252
|
filters: {
|
|
185
253
|
globalText: "",
|
|
186
254
|
columnFilters: {}
|
|
187
255
|
}
|
|
188
256
|
};
|
|
189
257
|
case "filter/setAll": return {
|
|
190
|
-
...
|
|
191
|
-
filters:
|
|
258
|
+
...t,
|
|
259
|
+
filters: o.filters
|
|
192
260
|
};
|
|
193
261
|
case "sort/set": return {
|
|
194
|
-
...
|
|
195
|
-
sort:
|
|
262
|
+
...t,
|
|
263
|
+
sort: o.entries
|
|
196
264
|
};
|
|
197
265
|
case "sort/clear": return {
|
|
198
|
-
...
|
|
266
|
+
...t,
|
|
199
267
|
sort: []
|
|
200
268
|
};
|
|
201
|
-
case "rowSelect/set": return n(
|
|
202
|
-
...
|
|
203
|
-
rowSelection:
|
|
269
|
+
case "rowSelect/set": return n(t.rowSelection, o.state) ? t : {
|
|
270
|
+
...t,
|
|
271
|
+
rowSelection: o.state
|
|
204
272
|
};
|
|
205
273
|
case "group/toggleCollapsed": {
|
|
206
|
-
let
|
|
207
|
-
return
|
|
208
|
-
...
|
|
209
|
-
collapsedGroupKeys:
|
|
274
|
+
let e = new Set(t.collapsedGroupKeys);
|
|
275
|
+
return e.has(o.groupKey) ? e.delete(o.groupKey) : e.add(o.groupKey), {
|
|
276
|
+
...t,
|
|
277
|
+
collapsedGroupKeys: e
|
|
210
278
|
};
|
|
211
279
|
}
|
|
212
280
|
case "group/setCollapsed": {
|
|
213
|
-
if (
|
|
214
|
-
let
|
|
215
|
-
return
|
|
216
|
-
...
|
|
217
|
-
collapsedGroupKeys:
|
|
281
|
+
if (t.collapsedGroupKeys.has(o.groupKey) === o.collapsed) return t;
|
|
282
|
+
let e = new Set(t.collapsedGroupKeys);
|
|
283
|
+
return o.collapsed ? e.add(o.groupKey) : e.delete(o.groupKey), {
|
|
284
|
+
...t,
|
|
285
|
+
collapsedGroupKeys: e
|
|
218
286
|
};
|
|
219
287
|
}
|
|
220
|
-
case "group/setCollapsedKeys": return
|
|
221
|
-
...
|
|
222
|
-
collapsedGroupKeys:
|
|
288
|
+
case "group/setCollapsedKeys": return o.keys === t.collapsedGroupKeys || o.keys.size === 0 && t.collapsedGroupKeys.size === 0 ? t : {
|
|
289
|
+
...t,
|
|
290
|
+
collapsedGroupKeys: o.keys
|
|
223
291
|
};
|
|
224
292
|
case "detail/toggle": {
|
|
225
|
-
let
|
|
226
|
-
return
|
|
227
|
-
...
|
|
228
|
-
expandedDetailRowKeys:
|
|
293
|
+
let e = new Set(t.expandedDetailRowKeys);
|
|
294
|
+
return e.has(o.rowKey) ? e.delete(o.rowKey) : e.add(o.rowKey), {
|
|
295
|
+
...t,
|
|
296
|
+
expandedDetailRowKeys: e
|
|
229
297
|
};
|
|
230
298
|
}
|
|
231
299
|
case "detail/setExpanded": {
|
|
232
|
-
if (
|
|
233
|
-
let
|
|
234
|
-
return
|
|
235
|
-
...
|
|
236
|
-
expandedDetailRowKeys:
|
|
300
|
+
if (t.expandedDetailRowKeys.has(o.rowKey) === o.expanded) return t;
|
|
301
|
+
let e = new Set(t.expandedDetailRowKeys);
|
|
302
|
+
return o.expanded ? e.add(o.rowKey) : e.delete(o.rowKey), {
|
|
303
|
+
...t,
|
|
304
|
+
expandedDetailRowKeys: e
|
|
237
305
|
};
|
|
238
306
|
}
|
|
239
|
-
case "detail/setKeys": return
|
|
240
|
-
...
|
|
241
|
-
expandedDetailRowKeys:
|
|
307
|
+
case "detail/setKeys": return o.keys === t.expandedDetailRowKeys || o.keys.size === 0 && t.expandedDetailRowKeys.size === 0 ? t : {
|
|
308
|
+
...t,
|
|
309
|
+
expandedDetailRowKeys: o.keys
|
|
242
310
|
};
|
|
243
|
-
default: return
|
|
311
|
+
default: return t;
|
|
244
312
|
}
|
|
245
313
|
};
|
|
246
314
|
//#endregion
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CellCoord, CellRange, GridUiState } from './gridTypes.unbound';
|
|
1
|
+
import type { CellCoord, CellRange, GridUiState } from './gridTypes.unbound.js';
|
|
2
2
|
export declare const normalizeCellRange: (range: CellRange) => CellRange;
|
|
3
3
|
export declare const normalizeRowRange: (startRow: number, endRow: number) => {
|
|
4
4
|
startRow: number;
|
|
@@ -9,11 +9,11 @@ export declare const normalizeColumnRange: (startCol: number, endCol: number) =>
|
|
|
9
9
|
endCol: number;
|
|
10
10
|
};
|
|
11
11
|
export declare const selectActiveCell: (state: GridUiState) => CellCoord | null;
|
|
12
|
-
export declare const selectSelection: (state: GridUiState) => import("./gridTypes.core").GridSelection;
|
|
12
|
+
export declare const selectSelection: (state: GridUiState) => import("./gridTypes.core.js").GridSelection;
|
|
13
13
|
export declare const selectEditingCell: (state: GridUiState) => CellCoord | null;
|
|
14
14
|
export declare const selectColumnWidth: (state: GridUiState, columnKey: string) => number;
|
|
15
15
|
export declare const selectGlobalFilter: (state: GridUiState) => string;
|
|
16
|
-
export declare const selectColumnFilter: (state: GridUiState, columnKey: string) => import("./gridTypes.core").ColumnFilterValue;
|
|
16
|
+
export declare const selectColumnFilter: (state: GridUiState, columnKey: string) => import("./gridTypes.core.js").ColumnFilterValue;
|
|
17
17
|
export declare const selectIsActiveCell: (state: GridUiState, rowIndex: number, colIndex: number) => boolean;
|
|
18
18
|
export declare const selectIsEditingCell: (state: GridUiState, rowIndex: number, colIndex: number) => boolean;
|
|
19
19
|
export declare const selectIsCellSelected: (state: GridUiState, rowIndex: number, colIndex: number) => boolean;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { GridUiAction } from './gridActions';
|
|
2
|
-
import type { GridUiState } from './gridTypes.unbound';
|
|
1
|
+
import type { GridUiAction } from './gridActions.js';
|
|
2
|
+
import type { GridUiState } from './gridTypes.unbound.js';
|
|
3
3
|
export type GridStoreListener = () => void;
|
|
4
4
|
export type GridViewState = {
|
|
5
5
|
scrollTop: number;
|