@ishibashi0112/spreadsheet-grid-core 1.1.0 → 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.
Files changed (105) hide show
  1. package/dist/controllers/activeRowFollowController.cjs +1 -0
  2. package/dist/controllers/activeRowFollowController.d.ts +18 -0
  3. package/dist/controllers/activeRowFollowController.js +68 -0
  4. package/dist/controllers/autoHeightMeasurer.cjs +1 -1
  5. package/dist/controllers/autoHeightMeasurer.js +17 -17
  6. package/dist/controllers/clipboardController.cjs +1 -1
  7. package/dist/controllers/clipboardController.d.ts +1 -0
  8. package/dist/controllers/clipboardController.js +58 -49
  9. package/dist/controllers/columnAutosizeRunner.cjs +1 -1
  10. package/dist/controllers/columnAutosizeRunner.js +10 -10
  11. package/dist/controllers/contextMenuController.cjs +1 -1
  12. package/dist/controllers/contextMenuController.d.ts +1 -0
  13. package/dist/controllers/contextMenuController.js +12 -7
  14. package/dist/controllers/editController.cjs +1 -1
  15. package/dist/controllers/editController.d.ts +1 -0
  16. package/dist/controllers/editController.js +106 -99
  17. package/dist/controllers/fillHandleController.cjs +1 -1
  18. package/dist/controllers/fillHandleController.js +78 -78
  19. package/dist/controllers/filterPopoverController.cjs +1 -1
  20. package/dist/controllers/filterPopoverController.js +6 -6
  21. package/dist/controllers/findController.cjs +1 -1
  22. package/dist/controllers/findController.d.ts +1 -0
  23. package/dist/controllers/findController.js +16 -15
  24. package/dist/controllers/imeInputController.cjs +1 -1
  25. package/dist/controllers/imeInputController.js +65 -54
  26. package/dist/controllers/keyboardController.cjs +1 -1
  27. package/dist/controllers/keyboardController.js +43 -43
  28. package/dist/controllers/pointerInteractionsController.cjs +1 -1
  29. package/dist/controllers/pointerInteractionsController.js +64 -64
  30. package/dist/controllers/rowDragController.cjs +1 -1
  31. package/dist/controllers/rowDragController.d.ts +1 -0
  32. package/dist/controllers/rowDragController.js +117 -104
  33. package/dist/controllers/scrollSyncController.cjs +1 -1
  34. package/dist/controllers/scrollSyncController.js +45 -43
  35. package/dist/controllers/serverSideRowModel.cjs +1 -1
  36. package/dist/controllers/serverSideRowModel.js +19 -19
  37. package/dist/controllers/viewportSyncController.cjs +1 -1
  38. package/dist/controllers/viewportSyncController.d.ts +1 -0
  39. package/dist/controllers/viewportSyncController.js +1 -1
  40. package/dist/engine/columnCommands.cjs +1 -1
  41. package/dist/engine/columnCommands.js +113 -113
  42. package/dist/engine/createGridEngine.cjs +3 -3
  43. package/dist/engine/createGridEngine.d.ts +2 -0
  44. package/dist/engine/createGridEngine.js +72 -70
  45. package/dist/engine/exportCommands.cjs +1 -1
  46. package/dist/engine/exportCommands.js +4 -2
  47. package/dist/engine/fullFeatures.cjs +1 -1
  48. package/dist/engine/fullFeatures.js +6 -6
  49. package/dist/engine/gridApi.cjs +6 -6
  50. package/dist/engine/gridApi.d.ts +2 -0
  51. package/dist/engine/gridApi.js +193 -183
  52. package/dist/engine/notifiers.cjs +1 -1
  53. package/dist/engine/notifiers.d.ts +4 -0
  54. package/dist/engine/notifiers.js +7 -7
  55. package/dist/index.cjs +1 -1
  56. package/dist/index.d.ts +1 -1
  57. package/dist/index.js +4 -4
  58. package/dist/locales/en.cjs +1 -1
  59. package/dist/locales/en.js +2 -0
  60. package/dist/logic/exportCsv.cjs +2 -2
  61. package/dist/logic/exportCsv.d.ts +2 -1
  62. package/dist/logic/exportCsv.js +13 -13
  63. package/dist/logic/exportData.cjs +1 -1
  64. package/dist/logic/exportData.d.ts +2 -1
  65. package/dist/logic/exportData.js +18 -18
  66. package/dist/logic/geometry.cjs +1 -1
  67. package/dist/logic/geometry.d.ts +2 -0
  68. package/dist/logic/geometry.js +41 -20
  69. package/dist/logic/gridState.cjs +1 -1
  70. package/dist/logic/gridState.d.ts +3 -2
  71. package/dist/logic/gridState.js +32 -23
  72. package/dist/logic/grouping.cjs +1 -1
  73. package/dist/logic/grouping.js +1 -1
  74. package/dist/logic/imeInput.cjs +1 -1
  75. package/dist/logic/imeInput.js +6 -4
  76. package/dist/logic/localeTextFeatures.cjs +1 -1
  77. package/dist/logic/localeTextFeatures.d.ts +4 -0
  78. package/dist/logic/localeTextFeatures.js +8 -5
  79. package/dist/logic/pasteFill.cjs +1 -0
  80. package/dist/logic/pasteFill.d.ts +2 -0
  81. package/dist/logic/pasteFill.js +25 -0
  82. package/dist/logic/selectEditorState.cjs +1 -1
  83. package/dist/logic/selectEditorState.d.ts +4 -1
  84. package/dist/logic/selectEditorState.js +14 -14
  85. package/dist/logic/selectionAggregates.cjs +1 -1
  86. package/dist/logic/selectionAggregates.js +2 -3
  87. package/dist/logic/validation.cjs +1 -1
  88. package/dist/logic/validation.d.ts +1 -1
  89. package/dist/logic/validation.js +21 -21
  90. package/dist/model/gridActions.cjs +1 -1
  91. package/dist/model/gridActions.d.ts +13 -0
  92. package/dist/model/gridActions.js +11 -0
  93. package/dist/model/gridReducer.cjs +1 -1
  94. package/dist/model/gridReducer.js +128 -65
  95. package/dist/model/gridTypes.core.d.ts +172 -26
  96. package/dist/utils/gridVisibleBand.cjs +1 -0
  97. package/dist/utils/gridVisibleBand.d.ts +4 -0
  98. package/dist/utils/gridVisibleBand.js +24 -0
  99. package/dist/utils/scrollBottom.cjs +1 -0
  100. package/dist/utils/scrollBottom.d.ts +1 -0
  101. package/dist/utils/scrollBottom.js +4 -0
  102. package/dist/utils/topAlignedInput.cjs +1 -0
  103. package/dist/utils/topAlignedInput.d.ts +3 -0
  104. package/dist/utils/topAlignedInput.js +23 -0
  105. package/package.json +1 -1
@@ -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},s=(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},c=()=>({activeCell:null,selection:null,rowSelection:t.createEmptyRowSelection(),editingCell:null,dragState:null,columnWidths:{},filters:{globalText:``,columnFilters:{}},sort:[],collapsedGroupKeys:new Set,expandedDetailRowKeys:new Set}),l=(c,l)=>{switch(l.type){case`cell/activate`:return l.cell===c.activeCell||l.cell!==null&&c.activeCell!==null&&l.cell.row===c.activeCell.row&&l.cell.col===c.activeCell.col?c:{...c,activeCell:l.cell};case`selection/start`:return{...c,activeCell:l.cell,selection:{type:`cell`,range:{start:l.cell,end:l.cell}},dragState:{type:`selection`,selectionKind:`cell`,anchor:l.cell}};case`rowSelection/start`:return{...c,activeCell:{row:l.row,col:c.activeCell?.col??l.col??0},selection:{type:`row`,startRow:l.row,endRow:l.row},dragState:{type:`selection`,selectionKind:`row`,anchorRow:l.row}};case`rowSelection/update`:return c.dragState?.type!==`selection`||c.dragState.selectionKind!==`row`||c.selection?.type===`row`&&c.selection.endRow===l.row?c:{...c,selection:{type:`row`,startRow:c.dragState.anchorRow,endRow:l.row}};case`selection/update`:return c.dragState?.type!==`selection`||c.dragState.selectionKind!==`cell`||c.selection?.type===`cell`&&c.selection.range.end.row===l.cell.row&&c.selection.range.end.col===l.cell.col?c:{...c,selection:{type:`cell`,range:{start:c.dragState.anchor,end:l.cell}}};case`columnSelection/start`:return{...c,activeCell:{row:c.activeCell?.row??l.row??0,col:l.col},selection:{type:`col`,startCol:l.col,endCol:l.col},dragState:{type:`selection`,selectionKind:`col`,anchorCol:l.col}};case`columnSelection/update`:return c.dragState?.type!==`selection`||c.dragState.selectionKind!==`col`||c.selection?.type===`col`&&c.selection.endCol===l.col?c:{...c,selection:{type:`col`,startCol:c.dragState.anchorCol,endCol:l.col}};case`selection/end`:return c.dragState?.type===`selection`?{...c,dragState:null}:c;case`selection/clear`:return c.selection===null&&c.dragState===null?c:{...c,selection:null,dragState:null};case`selection/clampToRowCount`:{let e=a(c,l.rowCount);return l.colCount===void 0?e:o(e,l.colCount)}case`edit/start`:return{...c,editingCell:l.cell,activeCell:l.cell};case`edit/stop`:return c.editingCell===null?c:{...c,editingCell:null};case`column/resizeStart`:return{...c,dragState:{type:`columnResize`,columnKey:l.columnKey,startX:l.startX,startWidth:l.startWidth,minWidth:l.minWidth??r,maxWidth:l.maxWidth??1/0}};case`column/resizeUpdate`:{if(c.dragState?.type!==`columnResize`)return c;let e=i(c.dragState.startWidth+(l.clientX-c.dragState.startX),c.dragState.minWidth,c.dragState.maxWidth);return c.columnWidths[c.dragState.columnKey]===e?c:{...c,columnWidths:{...c.columnWidths,[c.dragState.columnKey]:e}}}case`column/resizeEnd`:return c.dragState?.type===`columnResize`?{...c,dragState:null}:c;case`columnWidths/sync`:return{...c,columnWidths:{...c.columnWidths,...l.widths}};case`columnWidths/reset`:return{...c,columnWidths:l.widths};case`columnWidths/reconcile`:{let t=e.reconcileColumnWidths(c.columnWidths,l.prevColumns,l.nextColumns);return s(t===c.columnWidths?c:{...c,columnWidths:t},l.prevColumns,l.nextColumns)}case`filter/setGlobal`:return c.filters.globalText===l.value?c:{...c,filters:{...c.filters,globalText:l.value}};case`filter/setColumn`:{let e=c.filters.columnFilters[l.columnKey];return e!==void 0&&(e===l.value||n.isSameColumnFilterValue(e,l.value))?c:{...c,filters:{...c.filters,columnFilters:{...c.filters.columnFilters,[l.columnKey]:l.value}}}}case`filter/clearColumn`:{if(!(l.columnKey in c.filters.columnFilters))return c;let e={...c.filters.columnFilters};return delete e[l.columnKey],{...c,filters:{...c.filters,columnFilters:e}}}case`filter/resetAll`:return c.filters.globalText===``&&Object.keys(c.filters.columnFilters).length===0?c:{...c,filters:{globalText:``,columnFilters:{}}};case`filter/setAll`:return{...c,filters:l.filters};case`sort/set`:return n.isSameSortState(c.sort,l.entries)?c:{...c,sort:l.entries};case`sort/clear`:return c.sort.length===0?c:{...c,sort:[]};case`rowSelect/set`:return t.rowSelectionStateEquals(c.rowSelection,l.state)?c:{...c,rowSelection:l.state};case`group/toggleCollapsed`:{let e=new Set(c.collapsedGroupKeys);return e.has(l.groupKey)?e.delete(l.groupKey):e.add(l.groupKey),{...c,collapsedGroupKeys:e}}case`group/setCollapsed`:{if(c.collapsedGroupKeys.has(l.groupKey)===l.collapsed)return c;let e=new Set(c.collapsedGroupKeys);return l.collapsed?e.add(l.groupKey):e.delete(l.groupKey),{...c,collapsedGroupKeys:e}}case`group/setCollapsedKeys`:return l.keys===c.collapsedGroupKeys||l.keys.size===0&&c.collapsedGroupKeys.size===0?c:{...c,collapsedGroupKeys:l.keys};case`detail/toggle`:{let e=new Set(c.expandedDetailRowKeys);return e.has(l.rowKey)?e.delete(l.rowKey):e.add(l.rowKey),{...c,expandedDetailRowKeys:e}}case`detail/setExpanded`:{if(c.expandedDetailRowKeys.has(l.rowKey)===l.expanded)return c;let e=new Set(c.expandedDetailRowKeys);return l.expanded?e.add(l.rowKey):e.delete(l.rowKey),{...c,expandedDetailRowKeys:e}}case`detail/setKeys`:return l.keys===c.expandedDetailRowKeys||l.keys.size===0&&c.expandedDetailRowKeys.size===0?c:{...c,expandedDetailRowKeys:l.keys};default:return c}};exports.createInitialGridUiState=c,exports.gridUiReducer=l;
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
- }, l = (e, t, n) => {
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
- }, u = () => ({
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
- }), d = (t, u) => {
160
- switch (u.type) {
161
- case "cell/activate": return u.cell === t.activeCell || u.cell !== null && t.activeCell !== null && u.cell.row === t.activeCell.row && u.cell.col === t.activeCell.col ? t : {
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: u.cell
201
+ activeCell: d.cell
164
202
  };
165
203
  case "selection/start": return {
166
204
  ...t,
167
- activeCell: u.cell,
205
+ activeCell: d.cell,
168
206
  selection: {
169
207
  type: "cell",
170
208
  range: {
171
- start: u.cell,
172
- end: u.cell
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: u.cell
216
+ anchor: d.cell
179
217
  }
180
218
  };
181
219
  case "rowSelection/start": return {
182
220
  ...t,
183
221
  activeCell: {
184
- row: u.row,
185
- col: t.activeCell?.col ?? u.col ?? 0
222
+ row: d.row,
223
+ col: t.activeCell?.col ?? d.col ?? 0
186
224
  },
187
225
  selection: {
188
226
  type: "row",
189
- startRow: u.row,
190
- endRow: u.row
227
+ startRow: d.row,
228
+ endRow: d.row
191
229
  },
192
230
  dragState: {
193
231
  type: "selection",
194
232
  selectionKind: "row",
195
- anchorRow: u.row
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 === u.row ? t : {
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: u.row
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 === u.cell.row && t.selection.range.end.col === u.cell.col ? t : {
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: u.cell
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 ?? u.row ?? 0,
220
- col: u.col
257
+ row: t.activeCell?.row ?? d.row ?? 0,
258
+ col: d.col
221
259
  },
222
260
  selection: {
223
261
  type: "col",
224
- startCol: u.col,
225
- endCol: u.col
262
+ startCol: d.col,
263
+ endCol: d.col
226
264
  },
227
265
  dragState: {
228
266
  type: "selection",
229
267
  selectionKind: "col",
230
- anchorCol: u.col
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 === u.col ? t : {
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: u.col
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, u.rowCount);
252
- return u.colCount === void 0 ? e : c(e, u.colCount);
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: u.cell,
257
- activeCell: u.cell
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: u.columnKey,
268
- startX: u.startX,
269
- startWidth: u.startWidth,
270
- minWidth: u.minWidth ?? a,
271
- maxWidth: u.maxWidth ?? Infinity
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 + (u.clientX - t.dragState.startX), t.dragState.minWidth, t.dragState.maxWidth);
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
- ...u.widths
356
+ ...d.widths
294
357
  }
295
358
  };
296
359
  case "columnWidths/reset": return {
297
360
  ...t,
298
- columnWidths: u.widths
361
+ columnWidths: d.widths
299
362
  };
300
363
  case "columnWidths/reconcile": {
301
- let n = e(t.columnWidths, u.prevColumns, u.nextColumns);
302
- return l(n === t.columnWidths ? t : {
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
- }, u.prevColumns, u.nextColumns);
368
+ }, d.prevColumns, d.nextColumns);
306
369
  }
307
- case "filter/setGlobal": return t.filters.globalText === u.value ? t : {
370
+ case "filter/setGlobal": return t.filters.globalText === d.value ? t : {
308
371
  ...t,
309
372
  filters: {
310
373
  ...t.filters,
311
- globalText: u.value
374
+ globalText: d.value
312
375
  }
313
376
  };
314
377
  case "filter/setColumn": {
315
- let e = t.filters.columnFilters[u.columnKey];
316
- return e !== void 0 && (e === u.value || r(e, u.value)) ? t : {
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
- [u.columnKey]: u.value
385
+ [d.columnKey]: d.value
323
386
  }
324
387
  }
325
388
  };
326
389
  }
327
390
  case "filter/clearColumn": {
328
- if (!(u.columnKey in t.filters.columnFilters)) return t;
391
+ if (!(d.columnKey in t.filters.columnFilters)) return t;
329
392
  let e = { ...t.filters.columnFilters };
330
- return delete e[u.columnKey], {
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: u.filters
410
+ filters: d.filters
348
411
  };
349
- case "sort/set": return i(t.sort, u.entries) ? t : {
412
+ case "sort/set": return i(t.sort, d.entries) ? t : {
350
413
  ...t,
351
- sort: u.entries
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, u.state) ? t : {
420
+ case "rowSelect/set": return n(t.rowSelection, d.state) ? t : {
358
421
  ...t,
359
- rowSelection: u.state
422
+ rowSelection: d.state
360
423
  };
361
424
  case "group/toggleCollapsed": {
362
425
  let e = new Set(t.collapsedGroupKeys);
363
- return e.has(u.groupKey) ? e.delete(u.groupKey) : e.add(u.groupKey), {
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(u.groupKey) === u.collapsed) return t;
432
+ if (t.collapsedGroupKeys.has(d.groupKey) === d.collapsed) return t;
370
433
  let e = new Set(t.collapsedGroupKeys);
371
- return u.collapsed ? e.add(u.groupKey) : e.delete(u.groupKey), {
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 u.keys === t.collapsedGroupKeys || u.keys.size === 0 && t.collapsedGroupKeys.size === 0 ? t : {
439
+ case "group/setCollapsedKeys": return d.keys === t.collapsedGroupKeys || d.keys.size === 0 && t.collapsedGroupKeys.size === 0 ? t : {
377
440
  ...t,
378
- collapsedGroupKeys: u.keys
441
+ collapsedGroupKeys: d.keys
379
442
  };
380
443
  case "detail/toggle": {
381
444
  let e = new Set(t.expandedDetailRowKeys);
382
- return e.has(u.rowKey) ? e.delete(u.rowKey) : e.add(u.rowKey), {
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(u.rowKey) === u.expanded) return t;
451
+ if (t.expandedDetailRowKeys.has(d.rowKey) === d.expanded) return t;
389
452
  let e = new Set(t.expandedDetailRowKeys);
390
- return u.expanded ? e.add(u.rowKey) : e.delete(u.rowKey), {
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 u.keys === t.expandedDetailRowKeys || u.keys.size === 0 && t.expandedDetailRowKeys.size === 0 ? t : {
458
+ case "detail/setKeys": return d.keys === t.expandedDetailRowKeys || d.keys.size === 0 && t.expandedDetailRowKeys.size === 0 ? t : {
396
459
  ...t,
397
- expandedDetailRowKeys: u.keys
460
+ expandedDetailRowKeys: d.keys
398
461
  };
399
462
  default: return t;
400
463
  }
401
464
  };
402
465
  //#endregion
403
- export { u as createInitialGridUiState, d as gridUiReducer };
466
+ export { d as createInitialGridUiState, f as gridUiReducer };