@ishibashi0112/spreadsheet-grid-core 1.11.0 → 1.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/controllers/changeTracker.cjs +1 -1
- package/dist/controllers/changeTracker.d.ts +9 -0
- package/dist/controllers/changeTracker.js +205 -145
- package/dist/controllers/clipboardController.cjs +3 -1
- package/dist/controllers/clipboardController.d.ts +8 -0
- package/dist/controllers/clipboardController.js +251 -135
- package/dist/controllers/editController.cjs +1 -1
- package/dist/controllers/editController.js +109 -103
- package/dist/controllers/findController.cjs +1 -1
- package/dist/controllers/findController.d.ts +17 -0
- package/dist/controllers/findController.js +149 -93
- package/dist/controllers/findReplaceController.cjs +1 -0
- package/dist/controllers/findReplaceController.d.ts +61 -0
- package/dist/controllers/findReplaceController.js +324 -0
- package/dist/controllers/keyboardController.cjs +1 -1
- package/dist/controllers/keyboardController.d.ts +2 -0
- package/dist/controllers/keyboardController.js +13 -1
- package/dist/controllers/rowDiffer.cjs +2 -0
- package/dist/controllers/rowDiffer.d.ts +19 -0
- package/dist/controllers/rowDiffer.js +131 -0
- package/dist/engine/createGridEngine.cjs +1 -1
- package/dist/engine/createGridEngine.d.ts +2 -0
- package/dist/engine/createGridEngine.js +52 -51
- package/dist/engine/diffStage.cjs +1 -0
- package/dist/engine/diffStage.d.ts +26 -0
- package/dist/engine/diffStage.js +117 -0
- package/dist/engine/exportCommands.cjs +2 -2
- package/dist/engine/exportCommands.js +10 -10
- package/dist/engine/features.cjs +1 -1
- package/dist/engine/features.d.ts +13 -0
- package/dist/engine/features.js +39 -15
- package/dist/engine/fullFeatures.cjs +1 -1
- package/dist/engine/fullFeatures.js +37 -27
- package/dist/engine/gridApi.cjs +9 -8
- package/dist/engine/gridApi.d.ts +11 -2
- package/dist/engine/gridApi.js +294 -217
- package/dist/engine/newRowController.cjs +1 -1
- package/dist/engine/newRowController.js +1 -0
- package/dist/engine/rowPipeline.cjs +1 -1
- package/dist/engine/rowPipeline.d.ts +8 -1
- package/dist/engine/rowPipeline.js +32 -22
- package/dist/engine/treeStage.cjs +1 -1
- package/dist/engine/treeStage.d.ts +1 -0
- package/dist/engine/treeStage.js +2 -2
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +4 -4
- package/dist/locales/en.cjs +1 -1
- package/dist/locales/en.js +32 -0
- package/dist/logic/changeNavigation.cjs +1 -0
- package/dist/logic/changeNavigation.d.ts +25 -0
- package/dist/logic/changeNavigation.js +62 -0
- package/dist/logic/changeTracking.cjs +1 -1
- package/dist/logic/changeTracking.d.ts +1 -0
- package/dist/logic/changeTracking.js +8 -5
- package/dist/logic/clipboardHtml.cjs +1 -0
- package/dist/logic/clipboardHtml.d.ts +40 -0
- package/dist/logic/clipboardHtml.js +168 -0
- package/dist/logic/diffView.cjs +1 -0
- package/dist/logic/diffView.d.ts +20 -0
- package/dist/logic/diffView.js +51 -0
- package/dist/logic/find.cjs +1 -1
- package/dist/logic/find.js +35 -11
- package/dist/logic/findReplace.cjs +1 -0
- package/dist/logic/findReplace.d.ts +35 -0
- package/dist/logic/findReplace.js +84 -0
- package/dist/logic/localeTextFeatures.cjs +1 -1
- package/dist/logic/localeTextFeatures.d.ts +36 -0
- package/dist/logic/localeTextFeatures.js +41 -7
- package/dist/logic/multiSelect.cjs +1 -1
- package/dist/logic/multiSelect.js +1 -1
- package/dist/logic/rangeDecorations.cjs +4 -0
- package/dist/logic/rangeDecorations.d.ts +78 -0
- package/dist/logic/rangeDecorations.js +223 -0
- package/dist/logic/rowDiff.cjs +1 -0
- package/dist/logic/rowDiff.d.ts +57 -0
- package/dist/logic/rowDiff.js +169 -0
- package/dist/logic/selectionOverlayGeometry.cjs +1 -1
- package/dist/logic/selectionOverlayGeometry.d.ts +14 -0
- package/dist/logic/selectionOverlayGeometry.js +36 -4
- package/dist/logic/sorting.cjs +1 -1
- package/dist/logic/sorting.d.ts +1 -0
- package/dist/logic/sorting.js +42 -27
- package/dist/model/gridStore.d.ts +4 -1
- package/dist/model/gridTypes.core.d.ts +218 -26
- package/dist/utils/clipboard.cjs +5 -4
- package/dist/utils/clipboard.d.ts +10 -1
- package/dist/utils/clipboard.js +48 -33
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../model/gridActions.cjs"),t=require("../utils/permissions.cjs"),n=require("../logic/columnEditor.cjs"),r=require("../utils/shadowDom.cjs"),i=require("../logic/detailRow.cjs"),a=require("../logic/geometry.cjs"),o=require("../logic/editorValues.cjs"),s=require("../logic/validation.cjs"),c=require("../logic/newRow.cjs"),l=require("./liveUiState.cjs"),u=require("../logic/selectFillRow.cjs");var d=(e,t)=>{let r=e.visibleColumns[t.col];if(!(!r||!n.hasRowEditor(r)||c.isNewRowAt(e.rowModel,t.row)))return n.editorKindOf(n.resolveColumnEditor(r,e.rowModel.getRow(t.row)))},f=(e,t)=>t.activeCell!==e.activeCell||t.selection!==e.selection,p=e=>{if(i.isFocusInsideDetailCard(e))return!1;let t=e.ownerDocument,n=r.getActiveElement(e);return n===null||n===t.body||n===t.documentElement||e.contains(n)},m=e=>{let t=e.ownerDocument,n=r.getActiveElement(e);return n===null||n===t.body||n===t.documentElement},h=e=>{if(e===null)return!1;let t=r.getActiveElement(e);return t!==null&&t!==e&&e.contains(t)&&typeof t.closest==`function`&&t.closest(`.ssg-cell-editor`)!==null&&!i.isFocusInsideDetailCard(e)},g=(e,n,r,i,a)=>e.map((e,o)=>o===n?{...t.setCellValue(e,r,i),...a}:e),_=(e,t)=>e===null?[]:Object.keys(e).map(n=>({viewIndex:t,column:u.toFillRowColumn(n),value:e[n]})),v=()=>{let r=null,v=null,y=null,b=null,x=!1,S=!1,C=null,w=null,T=null,E=(e,t)=>{let n=e.visibleColumns[t.col];return!n||t.row<0||t.row>=e.rowModel.getRowCount()?null:c.isNewRowAt(e.rowModel,t.row)?{rowKey:c.NEW_ROW_KEY,columnKey:n.key}:e.rowModel.getRow(t.row)===void 0?null:{rowKey:e.rowModel.getRowKey(t.row),columnKey:n.key}},D=(e,t)=>{let n=e.visibleColumns.findIndex(e=>e.key===t.columnKey);if(n<0)return null;if(Object.is(t.rowKey,`__ssg_new_row__`)){let t=e.rowModel.newRow;return t===void 0?null:{row:t.index,col:n}}let r=e.rowModel.getRowCount();for(let i=0;i<r;i+=1)if(e.rowModel.getRow(i)!==void 0&&Object.is(e.rowModel.getRowKey(i),t.rowKey))return{row:i,col:n};return null},O=t=>{r=t;let n=t.uiState.editingCell;if(!n){v=null,C=null;return}let i=E(t,n);if(v!==null&&i!==null&&Object.is(i.rowKey,v.rowKey)&&i.columnKey===v.columnKey){v={...v,cell:n},k(t,n);return}let a=v!==null&&v.cell.row===n.row&&v.cell.col===n.col;if(v===null||!a){v=i?{...i,cell:n,editorKind:d(t,n)}:null,y!==null&&(y.superseded=!0,y=null,t.editorActionGuardRef.current=!1);return}let o=D(t,v);if(o)v={...v,cell:o},t.dispatch(e.gridActions.retargetEdit(o,t.rowModel.getRowCount())),k(t,o);else{let e=v;v=null,A(t,e)}},k=(e,t)=>{v===null||v.editorKind===void 0||d(e,t)===v.editorKind||(v=null,C=null,V())},A=(t,n)=>{if(t.editorActionGuardRef.current){t.dispatch(e.gridActions.stopEdit());return}b=n,x=!1;let r=C;C=null,S=!0;let i;try{r!==null&&(r(),b=null),i=L()}finally{S=!1,b=null}let a=t.gridRootRef.current;if(!i&&a!==null&&a.isConnected&&m(a)&&(a.focus({preventScroll:!0}),i=!0),x&&t.editorActionGuardRef.current){x=!1;return}x=!1,t.editorActionGuardRef.current=!0,t.dispatch(e.gridActions.stopEdit()),I(null,null,void 0,i)},j=(e,t)=>{let{rows:n,rowKeyGetter:r}=e;for(let e=0;e<n.length;e+=1){let i=n[e];if(i!==void 0&&Object.is(r?r(i,e):e,t))return e}return-1},M=t=>{r!==null&&(r.dispatch(e.gridActions.startSelection(t)),r.dispatch(e.gridActions.endSelection()),r.dispatch(e.gridActions.activateCell(t)))},N=(t,n)=>{r!==null&&(r.setEditorInitialValue(n),r.dispatch(e.gridActions.startEdit(t)))},P=(e,i)=>{if(r===null)return;let a=c.resolveEditRow(r.rowModel,e.row),o=r.visibleColumns[e.col];!a||!o||n.resolveColumnEditor(o,a)?.type===`checkbox`||!t.isViewCellEditable({readOnly:r.readOnly,canEditCell:r.canEditCell},r.rowModel,e.row,e.col,a,o)||N(e,i)},F=(e,t,n)=>{let r=e.getRowCount(),i=a.clamp(t,0,Math.max(r-1,0)),{getLabelRow:o}=e;if(o&&n!==void 0&&i!==n){let e=i>n?1:-1;for(;i>=0&&i<r&&o(i);)i+=e;(i<0||i>=r)&&(i=a.clamp(n,0,Math.max(r-1,0)))}return i},I=(e,t=null,n,o=!1,s,c)=>{let l=r;if(l===null)return;let u=!1,d={superseded:!1};y=d;let m=l.uiState.editingCell,h=o=>{if(u)return;if(d.superseded){u=!0;return}let h=r===null?null:r.getUiState?.()??null;if(h!==null&&h.editingCell!==null&&h.editingCell!==m){u=!0,y===d&&(y=null),l.editorActionGuardRef.current=!1;return}if(!o&&(r===null||r.uiState.editingCell!==null))return;u=!0,y===d&&(y=null);let g=l.gridRootRef.current;if(g!==null&&p(g)&&g.focus(),e!==null&&r!==null&&!(t!==null&&f(t,r.uiState))){let t=r.visibleColumns.length,o=s===void 0?-1:Object.is(s,`__ssg_new_row__`)?r.rowModel.newRow?.index??-1:i.findViewRowIndexByKey(r.rowModel,s,new Map),u={row:o>=0?o:F(r.rowModel,e.row,n),col:a.clamp(e.col,0,Math.max(t-1,0))};M(u),l.editorActionGuardRef.current=!1,c!==void 0&&c!==``&&P(u,c);return}l.editorActionGuardRef.current=!1};o&&queueMicrotask(()=>h(!1)),requestAnimationFrame(()=>h(!0))},L=()=>{let e=r?.gridRootRef.current??null;return h(e)?(e.focus({preventScroll:!0}),!0):!1},R=(e,t,n,r,i)=>i===void 0?null:u.resolveSelectFillRow(t,n,e.rowModel.getRowKey(r),i,e.columns??e.visibleColumns,e.localeTexts),z=(n,r,i,a,l,d,f)=>{let{rowModel:p,visibleColumns:m,uiState:h,dispatch:g,editorActionGuardRef:_}=n,v=p.newRow,y=m[r.col],b=v?.ensureRow();if(!v||!y||!b)return g(e.gridActions.stopEdit()),{status:`noop`};if(!t.isViewCellEditable({readOnly:n.readOnly,canEditCell:n.canEditCell},p,r.row,r.col,b,y))return _.current=!0,g(e.gridActions.stopEdit()),I(null),{status:`noop`};if(!o.isUnchangedEditorCommit(y,t.getCellValue(b,y),a,b)){let e=o.parseCommittedValue(y,a,b,n.localeTexts?.multiSelectSeparator),i=s.decideCellWrite(y,b,e,n.localeTexts);if(i.action===`reject`)return{status:`rejected`,message:i.message};let c=d===void 0?null:u.resolveSelectFillRow(y,b,n.rowModel.getRowKey(r.row)??`__ssg_new_row__`,d,n.columns??m,n.localeTexts),l=c===null?t.setCellValue(b,y,e):{...t.setCellValue(b,y,e),...c};v.writeRow(l)}let x=l===`right`&&(i.col>m.length-1||!(()=>{let e=v.peekRow()??b;for(let i=r.col+1;i<m.length;i+=1){let a=m[i];if(a!==void 0&&t.isViewCellEditable({readOnly:n.readOnly,canEditCell:n.canEditCell},p,r.row,i,e,a))return!0}return!1})()),S=i,C=i.row===r.row?c.NEW_ROW_KEY:void 0;if((l===`down`||x)&&v.hasDraft()){v.commit();let e=c.resolveFirstEditableColIndex(m,n.readOnly);S={row:r.row,col:x&&e>=0?e:r.col},C=c.NEW_ROW_KEY}else l===`down`&&(C=c.NEW_ROW_KEY);_.current=!0;let w=L();return I(S,l===void 0?{activeCell:h.activeCell,selection:h.selection}:null,r.row,w,C,l===void 0?void 0:f),g(e.gridActions.stopEdit()),{status:`committed`}},B=(n,a,l,u)=>{if(r===null)return{status:`noop`};let{uiState:d,visibleColumns:f,rowModel:p,rows:m,applyServerSideCellEdits:h,onRowsChange:v,dispatch:y,editorActionGuardRef:x}=r;if(x.current||!d.editingCell)return{status:`noop`};if(S){let e=b;return b=null,e===null?{status:`noop`}:U(r,e,n,!0,l)}let C=d.editingCell,w=a===`down`?{row:C.row+1,col:C.col}:a===`up`?{row:C.row-1,col:C.col}:a===`right`?{row:C.row,col:C.col+1}:a===`left`?{row:C.row,col:Math.max(C.col-1,i.resolveFirstDataColIndex(f))}:C;if(c.isNewRowAt(p,C.row))return z(r,C,w,n,a,l,u);let T=f[C.col],E=p.getSourceIndex(C.row),D=h?p.getRow(C.row):m[E];if(!T||!D)return y(e.gridActions.stopEdit()),{status:`noop`};if(!t.isViewCellEditable({readOnly:r.readOnly,canEditCell:r.canEditCell},p,C.row,C.col,D,T))return x.current=!0,y(e.gridActions.stopEdit()),I(null),{status:`noop`};let O=o.isUnchangedEditorCommit(T,t.getCellValue(D,T),n,D);if(!O&&h){let e=o.parseCommittedValue(T,n,D,r.localeTexts?.multiSelectSeparator),t=s.decideCellWrite(T,D,e,r.localeTexts);if(t.action===`reject`)return{status:`rejected`,message:t.message};let i=R(r,T,D,C.row,l);h([{viewIndex:C.row,column:T,value:e},..._(i,C.row)])}else if(!O&&v){let e=o.parseCommittedValue(T,n,D,r.localeTexts?.multiSelectSeparator),t=s.decideCellWrite(T,D,e,r.localeTexts);if(t.action===`reject`)return{status:`rejected`,message:t.message};let i=R(r,T,D,C.row,l);v(i===null?o.writeRowsCell(m,E,T,e):g(m,E,T,e,i))}x.current=!0;let k=L(),A;if(r.followsRow===!0){let e=F(p,w.row,C.row);(p.getRow(e)!=null||p.getLabelRow?.(e)!==void 0)&&(A=p.getRowKey(e))}return I(w,a===void 0?{activeCell:d.activeCell,selection:d.selection}:null,C.row,k,A,a===void 0?void 0:u),y(e.gridActions.stopEdit()),{status:`committed`}},V=()=>{if(r===null||r.editorActionGuardRef.current)return;x=!0,b=null,r.editorActionGuardRef.current=!0;let t=L();r.dispatch(e.gridActions.stopEdit()),I(null,null,void 0,t)},H=e=>{C=e},U=(e,n,r,i,a)=>{let c=e.visibleColumns.find(e=>e.key===n.columnKey),d=i?null:l.readLiveUiState(e).editingCell,f=d&&E(e,d);if(c===void 0||f&&Object.is(f.rowKey,n.rowKey)&&f.columnKey===n.columnKey)return{status:`noop`};if(Object.is(n.rowKey,`__ssg_new_row__`)){let n=e.rowModel.newRow,a=n?.peekRow();if(!n||a===void 0)return{status:`noop`};let l=e.visibleColumns.indexOf(c);if(!t.isViewCellEditable({readOnly:e.readOnly,canEditCell:e.canEditCell},e.rowModel,n.index,l,a,c))return{status:`noop`};if(o.isUnchangedEditorCommit(c,t.getCellValue(a,c),r,a))return{status:`committed`};let u=o.parseCommittedValue(c,r,a,e.localeTexts?.multiSelectSeparator),d=s.decideCellWrite(c,a,u,e.localeTexts);return d.action===`reject`?i?{status:`noop`}:{status:`rejected`,message:d.message}:(n.writeRow(t.setCellValue(a,c,u)),{status:`committed`})}let p=D(e,n),m,h=-1,v=T!==null&&T.from===e.rows?T.rows:e.rows;e.applyServerSideCellEdits===void 0?e.onRowsChange!==void 0&&(h=j(e,n.rowKey),m=h<0?void 0:v[h]):m=p===null?void 0:e.rowModel.getRow(p.row);let y=p??n.cell;if(m===void 0||!t.isCellEditable({readOnly:e.readOnly,canEditCell:e.canEditCell},y.row,y.col,m,c,{sourceRowIndex:h>=0?h:e.rowModel.getSourceIndex(y.row),rowKey:n.rowKey}))return{status:`noop`};if(o.isUnchangedEditorCommit(c,t.getCellValue(m,c),r,m))return{status:`committed`};let b=o.parseCommittedValue(c,r,m,e.localeTexts?.multiSelectSeparator),x=s.decideCellWrite(c,m,b,e.localeTexts);if(x.action===`reject`)return i?{status:`noop`}:{status:`rejected`,message:x.message};let S=a===void 0?null:u.resolveSelectFillRow(c,m,n.rowKey,a,e.columns??e.visibleColumns,e.localeTexts);if(e.applyServerSideCellEdits!==void 0&&p!==null)e.applyServerSideCellEdits([{viewIndex:p.row,column:c,value:b},..._(S,p.row)]);else if(e.onRowsChange!==void 0&&h>=0){let t=S===null?o.writeRowsCell(v,h,c,b):g(v,h,c,b,S);T={from:e.rows,rows:t},e.onRowsChange(t)}return{status:`committed`}};return{update:O,activateSingleCell:M,startEditWithValue:N,commitEdit:B,cancelEdit:V,registerDraftFlush:H,endEditLeftOpen:()=>{let t=r;if(t===null||t.editorActionGuardRef.current)return;let i=l.readLiveUiState(t).editingCell;if(i===null)return;let a=t.visibleColumns[i.col];if(a===void 0||n.resolveColumnEditor(a,c.peekEditRow(t.rowModel,i.row))?.type!==`custom`)return;let o=v??E(t,i),s=w;if(o!==null&&s!==null){let e={...o,cell:i},t=!1;s(n=>t||r===null?{status:`noop`}:(t=!0,U(r,e,n)))}t.editorActionGuardRef.current=!0,t.dispatch(e.gridActions.stopEdit()),I(null)},registerLateCommitReceiver:e=>(w=e,()=>{w===e&&(w=null)}),dispose:()=>{r=null,w=null}}};exports.createEditController=v;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../model/gridActions.cjs"),t=require("../utils/permissions.cjs"),n=require("../logic/columnEditor.cjs"),r=require("../utils/shadowDom.cjs"),i=require("../logic/detailRow.cjs"),a=require("../logic/geometry.cjs"),o=require("../logic/editorValues.cjs"),s=require("../logic/validation.cjs"),c=require("../logic/newRow.cjs"),l=require("./liveUiState.cjs"),u=require("../logic/selectFillRow.cjs");var d=(e,t)=>{let r=e.visibleColumns[t.col];if(!(!r||!n.hasRowEditor(r)||c.isNewRowAt(e.rowModel,t.row)))return n.editorKindOf(n.resolveColumnEditor(r,e.rowModel.getRow(t.row)))},f=(e,n)=>{let r=e.visibleColumns[n.col];if(!r||c.isNewRowAt(e.rowModel,n.row))return;let i=e.rowModel.getRow(n.row);return i==null?void 0:{value:t.getCellValue(i,r)}},p=(e,t)=>t.activeCell!==e.activeCell||t.selection!==e.selection,m=e=>{if(i.isFocusInsideDetailCard(e))return!1;let t=e.ownerDocument,n=r.getActiveElement(e);return n===null||n===t.body||n===t.documentElement||e.contains(n)},h=e=>{let t=e.ownerDocument,n=r.getActiveElement(e);return n===null||n===t.body||n===t.documentElement},g=e=>{if(e===null)return!1;let t=r.getActiveElement(e);return t!==null&&t!==e&&e.contains(t)&&typeof t.closest==`function`&&t.closest(`.ssg-cell-editor`)!==null&&!i.isFocusInsideDetailCard(e)},_=(e,n,r,i,a)=>e.map((e,o)=>o===n?{...t.setCellValue(e,r,i),...a}:e),v=(e,t)=>e===null?[]:Object.keys(e).map(n=>({viewIndex:t,column:u.toFillRowColumn(n),value:e[n]})),y=()=>{let r=null,y=null,b=null,x=null,S=!1,C=!1,w=null,T=null,E=null,D=(e,t)=>{let n=e.visibleColumns[t.col];return!n||t.row<0||t.row>=e.rowModel.getRowCount()?null:c.isNewRowAt(e.rowModel,t.row)?{rowKey:c.NEW_ROW_KEY,columnKey:n.key}:e.rowModel.getRow(t.row)===void 0?null:{rowKey:e.rowModel.getRowKey(t.row),columnKey:n.key}},O=(e,t)=>{let n=e.visibleColumns.findIndex(e=>e.key===t.columnKey);if(n<0)return null;if(Object.is(t.rowKey,`__ssg_new_row__`)){let t=e.rowModel.newRow;return t===void 0?null:{row:t.index,col:n}}let r=e.rowModel.getRowCount();for(let i=0;i<r;i+=1)if(e.rowModel.getRow(i)!==void 0&&Object.is(e.rowModel.getRowKey(i),t.rowKey))return{row:i,col:n};return null},k=t=>{r=t;let n=t.uiState.editingCell;if(!n){y=null,w=null;return}let i=D(t,n);if(y!==null&&i!==null&&Object.is(i.rowKey,y.rowKey)&&i.columnKey===y.columnKey){y={...y,cell:n},A(t,n);return}let a=y!==null&&y.cell.row===n.row&&y.cell.col===n.col;if(y===null||!a){y=i?{...i,cell:n,editorKind:d(t,n),startValue:f(t,n)}:null,b!==null&&(b.superseded=!0,b=null,t.editorActionGuardRef.current=!1);return}let o=O(t,y);if(o)y={...y,cell:o},t.dispatch(e.gridActions.retargetEdit(o,t.rowModel.getRowCount())),A(t,o);else{let e=y;y=null,j(t,e)}},A=(e,t)=>{y===null||y.editorKind===void 0||d(e,t)===y.editorKind||(y=null,w=null,H())},j=(t,n)=>{if(t.editorActionGuardRef.current){t.dispatch(e.gridActions.stopEdit());return}x=n,S=!1;let r=w;w=null,C=!0;let i;try{r!==null&&(r(),x=null),i=R()}finally{C=!1,x=null}let a=t.gridRootRef.current;if(!i&&a!==null&&a.isConnected&&h(a)&&(a.focus({preventScroll:!0}),i=!0),S&&t.editorActionGuardRef.current){S=!1;return}S=!1,t.editorActionGuardRef.current=!0,t.dispatch(e.gridActions.stopEdit()),L(null,null,void 0,i)},M=(e,t)=>{let{rows:n,rowKeyGetter:r}=e;for(let e=0;e<n.length;e+=1){let i=n[e];if(i!==void 0&&Object.is(r?r(i,e):e,t))return e}return-1},N=t=>{r!==null&&(r.dispatch(e.gridActions.startSelection(t)),r.dispatch(e.gridActions.endSelection()),r.dispatch(e.gridActions.activateCell(t)))},P=(t,n)=>{r!==null&&(r.setEditorInitialValue(n),r.dispatch(e.gridActions.startEdit(t)))},F=(e,i)=>{if(r===null)return;let a=c.resolveEditRow(r.rowModel,e.row),o=r.visibleColumns[e.col];!a||!o||n.resolveColumnEditor(o,a)?.type===`checkbox`||!t.isViewCellEditable({readOnly:r.readOnly,canEditCell:r.canEditCell},r.rowModel,e.row,e.col,a,o)||P(e,i)},I=(e,t,n)=>{let r=e.getRowCount(),i=a.clamp(t,0,Math.max(r-1,0)),{getLabelRow:o}=e;if(o&&n!==void 0&&i!==n){let e=i>n?1:-1;for(;i>=0&&i<r&&o(i);)i+=e;(i<0||i>=r)&&(i=a.clamp(n,0,Math.max(r-1,0)))}return i},L=(e,t=null,n,o=!1,s,c)=>{let l=r;if(l===null)return;let u=!1,d={superseded:!1};b=d;let f=l.uiState.editingCell,h=o=>{if(u)return;if(d.superseded){u=!0;return}let h=r===null?null:r.getUiState?.()??null;if(h!==null&&h.editingCell!==null&&h.editingCell!==f){u=!0,b===d&&(b=null),l.editorActionGuardRef.current=!1;return}if(!o&&(r===null||r.uiState.editingCell!==null))return;u=!0,b===d&&(b=null);let g=l.gridRootRef.current;if(g!==null&&m(g)&&g.focus(),e!==null&&r!==null&&!(t!==null&&p(t,r.uiState))){let t=r.visibleColumns.length,o=s===void 0?-1:Object.is(s,`__ssg_new_row__`)?r.rowModel.newRow?.index??-1:i.findViewRowIndexByKey(r.rowModel,s,new Map),u={row:o>=0?o:I(r.rowModel,e.row,n),col:a.clamp(e.col,0,Math.max(t-1,0))};N(u),l.editorActionGuardRef.current=!1,c!==void 0&&c!==``&&F(u,c);return}l.editorActionGuardRef.current=!1};o&&queueMicrotask(()=>h(!1)),requestAnimationFrame(()=>h(!0))},R=()=>{let e=r?.gridRootRef.current??null;return g(e)?(e.focus({preventScroll:!0}),!0):!1},z=(e,t,n,r,i)=>i===void 0?null:u.resolveSelectFillRow(t,n,e.rowModel.getRowKey(r),i,e.columns??e.visibleColumns,e.localeTexts),B=(n,r,i,a,l,d,f)=>{let{rowModel:p,visibleColumns:m,uiState:h,dispatch:g,editorActionGuardRef:_}=n,v=p.newRow,y=m[r.col],b=v?.ensureRow();if(!v||!y||!b)return g(e.gridActions.stopEdit()),{status:`noop`};if(!t.isViewCellEditable({readOnly:n.readOnly,canEditCell:n.canEditCell},p,r.row,r.col,b,y))return _.current=!0,g(e.gridActions.stopEdit()),L(null),{status:`noop`};if(!o.isUnchangedEditorCommit(y,t.getCellValue(b,y),a,b)){let e=o.parseCommittedValue(y,a,b,n.localeTexts?.multiSelectSeparator),i=s.decideCellWrite(y,b,e,n.localeTexts);if(i.action===`reject`)return{status:`rejected`,message:i.message};let c=d===void 0?null:u.resolveSelectFillRow(y,b,n.rowModel.getRowKey(r.row)??`__ssg_new_row__`,d,n.columns??m,n.localeTexts),l=c===null?t.setCellValue(b,y,e):{...t.setCellValue(b,y,e),...c};v.writeRow(l)}let x=l===`right`&&(i.col>m.length-1||!(()=>{let e=v.peekRow()??b;for(let i=r.col+1;i<m.length;i+=1){let a=m[i];if(a!==void 0&&t.isViewCellEditable({readOnly:n.readOnly,canEditCell:n.canEditCell},p,r.row,i,e,a))return!0}return!1})()),S=i,C=i.row===r.row?c.NEW_ROW_KEY:void 0;if((l===`down`||x)&&v.hasDraft()){v.commit();let e=c.resolveFirstEditableColIndex(m,n.readOnly);S={row:r.row,col:x&&e>=0?e:r.col},C=c.NEW_ROW_KEY}else l===`down`&&(C=c.NEW_ROW_KEY);_.current=!0;let w=R();return L(S,l===void 0?{activeCell:h.activeCell,selection:h.selection}:null,r.row,w,C,l===void 0?void 0:f),g(e.gridActions.stopEdit()),{status:`committed`}},V=(n,a,l,u)=>{if(r===null)return{status:`noop`};let{uiState:d,visibleColumns:f,rowModel:p,rows:m,applyServerSideCellEdits:h,onRowsChange:g,dispatch:b,editorActionGuardRef:S}=r;if(S.current||!d.editingCell)return{status:`noop`};if(C){let e=x;return x=null,e===null?{status:`noop`}:W(r,e,n,!0,l)}let w=d.editingCell,T=a===`down`?{row:w.row+1,col:w.col}:a===`up`?{row:w.row-1,col:w.col}:a===`right`?{row:w.row,col:w.col+1}:a===`left`?{row:w.row,col:Math.max(w.col-1,i.resolveFirstDataColIndex(f))}:w;if(c.isNewRowAt(p,w.row))return B(r,w,T,n,a,l,u);let E=f[w.col],D=p.getSourceIndex(w.row),O=h?p.getRow(w.row):m[D];if(!E||!O)return b(e.gridActions.stopEdit()),{status:`noop`};if(!t.isViewCellEditable({readOnly:r.readOnly,canEditCell:r.canEditCell},p,w.row,w.col,O,E))return S.current=!0,b(e.gridActions.stopEdit()),L(null),{status:`noop`};let k=t.getCellValue(O,E),A=y!==null&&y.cell.row===w.row&&y.cell.col===w.col?y.startValue:void 0,j=o.isUnchangedEditorCommit(E,k,n,O)||A!==void 0&&!Object.is(A.value,k)&&o.isUnchangedEditorCommit(E,A.value,n,O);if(!j&&h){let e=o.parseCommittedValue(E,n,O,r.localeTexts?.multiSelectSeparator),t=s.decideCellWrite(E,O,e,r.localeTexts);if(t.action===`reject`)return{status:`rejected`,message:t.message};let i=z(r,E,O,w.row,l);h([{viewIndex:w.row,column:E,value:e},...v(i,w.row)])}else if(!j&&g){let e=o.parseCommittedValue(E,n,O,r.localeTexts?.multiSelectSeparator),t=s.decideCellWrite(E,O,e,r.localeTexts);if(t.action===`reject`)return{status:`rejected`,message:t.message};let i=z(r,E,O,w.row,l);g(i===null?o.writeRowsCell(m,D,E,e):_(m,D,E,e,i))}S.current=!0;let M=R(),N;if(r.followsRow===!0){let e=I(p,T.row,w.row);(p.getRow(e)!=null||p.getLabelRow?.(e)!==void 0)&&(N=p.getRowKey(e))}return L(T,a===void 0?{activeCell:d.activeCell,selection:d.selection}:null,w.row,M,N,a===void 0?void 0:u),b(e.gridActions.stopEdit()),{status:`committed`}},H=()=>{if(r===null||r.editorActionGuardRef.current)return;S=!0,x=null,r.editorActionGuardRef.current=!0;let t=R();r.dispatch(e.gridActions.stopEdit()),L(null,null,void 0,t)},U=e=>{w=e},W=(e,n,r,i,a)=>{let c=e.visibleColumns.find(e=>e.key===n.columnKey),d=i?null:l.readLiveUiState(e).editingCell,f=d&&D(e,d);if(c===void 0||f&&Object.is(f.rowKey,n.rowKey)&&f.columnKey===n.columnKey)return{status:`noop`};if(Object.is(n.rowKey,`__ssg_new_row__`)){let n=e.rowModel.newRow,a=n?.peekRow();if(!n||a===void 0)return{status:`noop`};let l=e.visibleColumns.indexOf(c);if(!t.isViewCellEditable({readOnly:e.readOnly,canEditCell:e.canEditCell},e.rowModel,n.index,l,a,c))return{status:`noop`};if(o.isUnchangedEditorCommit(c,t.getCellValue(a,c),r,a))return{status:`committed`};let u=o.parseCommittedValue(c,r,a,e.localeTexts?.multiSelectSeparator),d=s.decideCellWrite(c,a,u,e.localeTexts);return d.action===`reject`?i?{status:`noop`}:{status:`rejected`,message:d.message}:(n.writeRow(t.setCellValue(a,c,u)),{status:`committed`})}let p=O(e,n),m,h=-1,g=E!==null&&E.from===e.rows?E.rows:e.rows;e.applyServerSideCellEdits===void 0?e.onRowsChange!==void 0&&(h=M(e,n.rowKey),m=h<0?void 0:g[h]):m=p===null?void 0:e.rowModel.getRow(p.row);let y=p??n.cell;if(m===void 0||!t.isCellEditable({readOnly:e.readOnly,canEditCell:e.canEditCell},y.row,y.col,m,c,{sourceRowIndex:h>=0?h:e.rowModel.getSourceIndex(y.row),rowKey:n.rowKey}))return{status:`noop`};if(o.isUnchangedEditorCommit(c,t.getCellValue(m,c),r,m))return{status:`committed`};let b=o.parseCommittedValue(c,r,m,e.localeTexts?.multiSelectSeparator),x=s.decideCellWrite(c,m,b,e.localeTexts);if(x.action===`reject`)return i?{status:`noop`}:{status:`rejected`,message:x.message};let S=a===void 0?null:u.resolveSelectFillRow(c,m,n.rowKey,a,e.columns??e.visibleColumns,e.localeTexts);if(e.applyServerSideCellEdits!==void 0&&p!==null)e.applyServerSideCellEdits([{viewIndex:p.row,column:c,value:b},...v(S,p.row)]);else if(e.onRowsChange!==void 0&&h>=0){let t=S===null?o.writeRowsCell(g,h,c,b):_(g,h,c,b,S);E={from:e.rows,rows:t},e.onRowsChange(t)}return{status:`committed`}};return{update:k,activateSingleCell:N,startEditWithValue:P,commitEdit:V,cancelEdit:H,registerDraftFlush:U,endEditLeftOpen:()=>{let t=r;if(t===null||t.editorActionGuardRef.current)return;let i=l.readLiveUiState(t).editingCell;if(i===null)return;let a=t.visibleColumns[i.col];if(a===void 0||n.resolveColumnEditor(a,c.peekEditRow(t.rowModel,i.row))?.type!==`custom`)return;let o=y??D(t,i),s=T;if(o!==null&&s!==null){let e={...o,cell:i},t=!1;s(n=>t||r===null?{status:`noop`}:(t=!0,W(r,e,n)))}t.editorActionGuardRef.current=!0,t.dispatch(e.gridActions.stopEdit()),L(null)},registerLateCommitReceiver:e=>(T=e,()=>{T===e&&(T=null)}),dispose:()=>{r=null,T=null}}};exports.createEditController=y;
|
|
@@ -13,26 +13,31 @@ import { resolveSelectFillRow as C, toFillRowColumn as w } from "../logic/select
|
|
|
13
13
|
var T = (e, t) => {
|
|
14
14
|
let n = e.visibleColumns[t.col];
|
|
15
15
|
if (!(!n || !o(n) || v(e.rowModel, t.row))) return a(s(n, e.rowModel.getRow(t.row)));
|
|
16
|
-
}, E = (e,
|
|
16
|
+
}, E = (e, n) => {
|
|
17
|
+
let r = e.visibleColumns[n.col];
|
|
18
|
+
if (!r || v(e.rowModel, n.row)) return;
|
|
19
|
+
let i = e.rowModel.getRow(n.row);
|
|
20
|
+
return i == null ? void 0 : { value: t(i, r) };
|
|
21
|
+
}, D = (e, t) => t.activeCell !== e.activeCell || t.selection !== e.selection, O = (e) => {
|
|
17
22
|
if (u(e)) return !1;
|
|
18
23
|
let t = e.ownerDocument, n = c(e);
|
|
19
24
|
return n === null || n === t.body || n === t.documentElement || e.contains(n);
|
|
20
|
-
},
|
|
25
|
+
}, k = (e) => {
|
|
21
26
|
let t = e.ownerDocument, n = c(e);
|
|
22
27
|
return n === null || n === t.body || n === t.documentElement;
|
|
23
|
-
},
|
|
28
|
+
}, A = (e) => {
|
|
24
29
|
if (e === null) return !1;
|
|
25
30
|
let t = c(e);
|
|
26
31
|
return t !== null && t !== e && e.contains(t) && typeof t.closest == "function" && t.closest(".ssg-cell-editor") !== null && !u(e);
|
|
27
|
-
},
|
|
32
|
+
}, j = (e, t, n, r, a) => e.map((e, o) => o === t ? {
|
|
28
33
|
...i(e, n, r),
|
|
29
34
|
...a
|
|
30
|
-
} : e),
|
|
35
|
+
} : e), M = (e, t) => e === null ? [] : Object.keys(e).map((n) => ({
|
|
31
36
|
viewIndex: t,
|
|
32
37
|
column: w(n),
|
|
33
38
|
value: e[n]
|
|
34
|
-
})),
|
|
35
|
-
let a = null, o = null, c = null, u = null, w = !1,
|
|
39
|
+
})), N = () => {
|
|
40
|
+
let a = null, o = null, c = null, u = null, w = !1, N = !1, P = null, F = null, I = null, L = (e, t) => {
|
|
36
41
|
let n = e.visibleColumns[t.col];
|
|
37
42
|
return !n || t.row < 0 || t.row >= e.rowModel.getRowCount() ? null : v(e.rowModel, t.row) ? {
|
|
38
43
|
rowKey: _,
|
|
@@ -41,7 +46,7 @@ var T = (e, t) => {
|
|
|
41
46
|
rowKey: e.rowModel.getRowKey(t.row),
|
|
42
47
|
columnKey: n.key
|
|
43
48
|
};
|
|
44
|
-
},
|
|
49
|
+
}, R = (e, t) => {
|
|
45
50
|
let n = e.visibleColumns.findIndex((e) => e.key === t.columnKey);
|
|
46
51
|
if (n < 0) return null;
|
|
47
52
|
if (Object.is(t.rowKey, "__ssg_new_row__")) {
|
|
@@ -57,19 +62,19 @@ var T = (e, t) => {
|
|
|
57
62
|
col: n
|
|
58
63
|
};
|
|
59
64
|
return null;
|
|
60
|
-
},
|
|
65
|
+
}, z = (t) => {
|
|
61
66
|
a = t;
|
|
62
67
|
let n = t.uiState.editingCell;
|
|
63
68
|
if (!n) {
|
|
64
|
-
o = null,
|
|
69
|
+
o = null, P = null;
|
|
65
70
|
return;
|
|
66
71
|
}
|
|
67
|
-
let r =
|
|
72
|
+
let r = L(t, n);
|
|
68
73
|
if (o !== null && r !== null && Object.is(r.rowKey, o.rowKey) && r.columnKey === o.columnKey) {
|
|
69
74
|
o = {
|
|
70
75
|
...o,
|
|
71
76
|
cell: n
|
|
72
|
-
},
|
|
77
|
+
}, B(t, n);
|
|
73
78
|
return;
|
|
74
79
|
}
|
|
75
80
|
let i = o !== null && o.cell.row === n.row && o.cell.col === n.col;
|
|
@@ -77,60 +82,61 @@ var T = (e, t) => {
|
|
|
77
82
|
o = r ? {
|
|
78
83
|
...r,
|
|
79
84
|
cell: n,
|
|
80
|
-
editorKind: T(t, n)
|
|
85
|
+
editorKind: T(t, n),
|
|
86
|
+
startValue: E(t, n)
|
|
81
87
|
} : null, c !== null && (c.superseded = !0, c = null, t.editorActionGuardRef.current = !1);
|
|
82
88
|
return;
|
|
83
89
|
}
|
|
84
|
-
let s =
|
|
90
|
+
let s = R(t, o);
|
|
85
91
|
if (s) o = {
|
|
86
92
|
...o,
|
|
87
93
|
cell: s
|
|
88
|
-
}, t.dispatch(e.retargetEdit(s, t.rowModel.getRowCount())),
|
|
94
|
+
}, t.dispatch(e.retargetEdit(s, t.rowModel.getRowCount())), B(t, s);
|
|
89
95
|
else {
|
|
90
96
|
let e = o;
|
|
91
|
-
o = null,
|
|
97
|
+
o = null, V(t, e);
|
|
92
98
|
}
|
|
93
|
-
},
|
|
94
|
-
o === null || o.editorKind === void 0 || T(e, t) === o.editorKind || (o = null,
|
|
95
|
-
},
|
|
99
|
+
}, B = (e, t) => {
|
|
100
|
+
o === null || o.editorKind === void 0 || T(e, t) === o.editorKind || (o = null, P = null, Q());
|
|
101
|
+
}, V = (t, n) => {
|
|
96
102
|
if (t.editorActionGuardRef.current) {
|
|
97
103
|
t.dispatch(e.stopEdit());
|
|
98
104
|
return;
|
|
99
105
|
}
|
|
100
106
|
u = n, w = !1;
|
|
101
|
-
let r =
|
|
102
|
-
|
|
107
|
+
let r = P;
|
|
108
|
+
P = null, N = !0;
|
|
103
109
|
let i;
|
|
104
110
|
try {
|
|
105
|
-
r !== null && (r(), u = null), i =
|
|
111
|
+
r !== null && (r(), u = null), i = J();
|
|
106
112
|
} finally {
|
|
107
|
-
|
|
113
|
+
N = !1, u = null;
|
|
108
114
|
}
|
|
109
115
|
let a = t.gridRootRef.current;
|
|
110
|
-
if (!i && a !== null && a.isConnected &&
|
|
116
|
+
if (!i && a !== null && a.isConnected && k(a) && (a.focus({ preventScroll: !0 }), i = !0), w && t.editorActionGuardRef.current) {
|
|
111
117
|
w = !1;
|
|
112
118
|
return;
|
|
113
119
|
}
|
|
114
|
-
w = !1, t.editorActionGuardRef.current = !0, t.dispatch(e.stopEdit()),
|
|
115
|
-
},
|
|
120
|
+
w = !1, t.editorActionGuardRef.current = !0, t.dispatch(e.stopEdit()), q(null, null, void 0, i);
|
|
121
|
+
}, H = (e, t) => {
|
|
116
122
|
let { rows: n, rowKeyGetter: r } = e;
|
|
117
123
|
for (let e = 0; e < n.length; e += 1) {
|
|
118
124
|
let i = n[e];
|
|
119
125
|
if (i !== void 0 && Object.is(r ? r(i, e) : e, t)) return e;
|
|
120
126
|
}
|
|
121
127
|
return -1;
|
|
122
|
-
},
|
|
128
|
+
}, U = (t) => {
|
|
123
129
|
a !== null && (a.dispatch(e.startSelection(t)), a.dispatch(e.endSelection()), a.dispatch(e.activateCell(t)));
|
|
124
|
-
},
|
|
130
|
+
}, W = (t, n) => {
|
|
125
131
|
a !== null && (a.setEditorInitialValue(n), a.dispatch(e.startEdit(t)));
|
|
126
|
-
},
|
|
132
|
+
}, G = (e, t) => {
|
|
127
133
|
if (a === null) return;
|
|
128
134
|
let n = b(a.rowModel, e.row), i = a.visibleColumns[e.col];
|
|
129
135
|
!n || !i || s(i, n)?.type === "checkbox" || !r({
|
|
130
136
|
readOnly: a.readOnly,
|
|
131
137
|
canEditCell: a.canEditCell
|
|
132
|
-
}, a.rowModel, e.row, e.col, n, i) ||
|
|
133
|
-
},
|
|
138
|
+
}, a.rowModel, e.row, e.col, n, i) || W(e, t);
|
|
139
|
+
}, K = (e, t, n) => {
|
|
134
140
|
let r = e.getRowCount(), i = f(t, 0, Math.max(r - 1, 0)), { getLabelRow: a } = e;
|
|
135
141
|
if (a && n !== void 0 && i !== n) {
|
|
136
142
|
let e = i > n ? 1 : -1;
|
|
@@ -138,7 +144,7 @@ var T = (e, t) => {
|
|
|
138
144
|
(i < 0 || i >= r) && (i = f(n, 0, Math.max(r - 1, 0)));
|
|
139
145
|
}
|
|
140
146
|
return i;
|
|
141
|
-
},
|
|
147
|
+
}, q = (e, t = null, n, r = !1, i, o) => {
|
|
142
148
|
let s = a;
|
|
143
149
|
if (s === null) return;
|
|
144
150
|
let u = !1, d = { superseded: !1 };
|
|
@@ -157,27 +163,27 @@ var T = (e, t) => {
|
|
|
157
163
|
if (!r && (a === null || a.uiState.editingCell !== null)) return;
|
|
158
164
|
u = !0, c === d && (c = null);
|
|
159
165
|
let h = s.gridRootRef.current;
|
|
160
|
-
if (h !== null &&
|
|
166
|
+
if (h !== null && O(h) && h.focus(), e !== null && a !== null && !(t !== null && D(t, a.uiState))) {
|
|
161
167
|
let t = a.visibleColumns.length, r = i === void 0 ? -1 : Object.is(i, "__ssg_new_row__") ? a.rowModel.newRow?.index ?? -1 : l(a.rowModel, i, /* @__PURE__ */ new Map()), c = {
|
|
162
|
-
row: r >= 0 ? r :
|
|
168
|
+
row: r >= 0 ? r : K(a.rowModel, e.row, n),
|
|
163
169
|
col: f(e.col, 0, Math.max(t - 1, 0))
|
|
164
170
|
};
|
|
165
|
-
|
|
171
|
+
U(c), s.editorActionGuardRef.current = !1, o !== void 0 && o !== "" && G(c, o);
|
|
166
172
|
return;
|
|
167
173
|
}
|
|
168
174
|
s.editorActionGuardRef.current = !1;
|
|
169
175
|
};
|
|
170
176
|
r && queueMicrotask(() => m(!1)), requestAnimationFrame(() => m(!0));
|
|
171
|
-
},
|
|
177
|
+
}, J = () => {
|
|
172
178
|
let e = a?.gridRootRef.current ?? null;
|
|
173
|
-
return
|
|
174
|
-
},
|
|
179
|
+
return A(e) ? (e.focus({ preventScroll: !0 }), !0) : !1;
|
|
180
|
+
}, Y = (e, t, n, r, i) => i === void 0 ? null : C(t, n, e.rowModel.getRowKey(r), i, e.columns ?? e.visibleColumns, e.localeTexts), X = (n, a, o, s, c, l, u) => {
|
|
175
181
|
let { rowModel: d, visibleColumns: f, uiState: h, dispatch: v, editorActionGuardRef: y } = n, b = d.newRow, S = f[a.col], w = b?.ensureRow();
|
|
176
182
|
if (!b || !S || !w) return v(e.stopEdit()), { status: "noop" };
|
|
177
183
|
if (!r({
|
|
178
184
|
readOnly: n.readOnly,
|
|
179
185
|
canEditCell: n.canEditCell
|
|
180
|
-
}, d, a.row, a.col, w, S)) return y.current = !0, v(e.stopEdit()),
|
|
186
|
+
}, d, a.row, a.col, w, S)) return y.current = !0, v(e.stopEdit()), q(null), { status: "noop" };
|
|
181
187
|
if (!p(S, t(w, S), s, w)) {
|
|
182
188
|
let e = m(S, s, w, n.localeTexts?.multiSelectSeparator), t = g(S, w, e, n.localeTexts);
|
|
183
189
|
if (t.action === "reject") return {
|
|
@@ -210,80 +216,80 @@ var T = (e, t) => {
|
|
|
210
216
|
}, D = _;
|
|
211
217
|
} else c === "down" && (D = _);
|
|
212
218
|
y.current = !0;
|
|
213
|
-
let O =
|
|
214
|
-
return
|
|
219
|
+
let O = J();
|
|
220
|
+
return q(E, c === void 0 ? {
|
|
215
221
|
activeCell: h.activeCell,
|
|
216
222
|
selection: h.selection
|
|
217
223
|
} : null, a.row, O, D, c === void 0 ? void 0 : u), v(e.stopEdit()), { status: "committed" };
|
|
218
|
-
},
|
|
224
|
+
}, Z = (n, i, s, c) => {
|
|
219
225
|
if (a === null) return { status: "noop" };
|
|
220
|
-
let { uiState:
|
|
221
|
-
if (
|
|
222
|
-
if (
|
|
226
|
+
let { uiState: l, visibleColumns: f, rowModel: _, rows: y, applyServerSideCellEdits: b, onRowsChange: x, dispatch: S, editorActionGuardRef: C } = a;
|
|
227
|
+
if (C.current || !l.editingCell) return { status: "noop" };
|
|
228
|
+
if (N) {
|
|
223
229
|
let e = u;
|
|
224
|
-
return u = null, e === null ? { status: "noop" } : $(a, e, n, !0,
|
|
230
|
+
return u = null, e === null ? { status: "noop" } : $(a, e, n, !0, s);
|
|
225
231
|
}
|
|
226
|
-
let
|
|
227
|
-
row:
|
|
228
|
-
col:
|
|
232
|
+
let w = l.editingCell, T = i === "down" ? {
|
|
233
|
+
row: w.row + 1,
|
|
234
|
+
col: w.col
|
|
229
235
|
} : i === "up" ? {
|
|
230
|
-
row:
|
|
231
|
-
col:
|
|
236
|
+
row: w.row - 1,
|
|
237
|
+
col: w.col
|
|
232
238
|
} : i === "right" ? {
|
|
233
|
-
row:
|
|
234
|
-
col:
|
|
239
|
+
row: w.row,
|
|
240
|
+
col: w.col + 1
|
|
235
241
|
} : i === "left" ? {
|
|
236
|
-
row:
|
|
237
|
-
col: Math.max(
|
|
238
|
-
} :
|
|
239
|
-
if (v(
|
|
240
|
-
let
|
|
241
|
-
if (!
|
|
242
|
+
row: w.row,
|
|
243
|
+
col: Math.max(w.col - 1, d(f))
|
|
244
|
+
} : w;
|
|
245
|
+
if (v(_, w.row)) return X(a, w, T, n, i, s, c);
|
|
246
|
+
let E = f[w.col], D = _.getSourceIndex(w.row), O = b ? _.getRow(w.row) : y[D];
|
|
247
|
+
if (!E || !O) return S(e.stopEdit()), { status: "noop" };
|
|
242
248
|
if (!r({
|
|
243
249
|
readOnly: a.readOnly,
|
|
244
250
|
canEditCell: a.canEditCell
|
|
245
|
-
},
|
|
246
|
-
let O = p(
|
|
247
|
-
if (!
|
|
248
|
-
let e = m(
|
|
251
|
+
}, _, w.row, w.col, O, E)) return C.current = !0, S(e.stopEdit()), q(null), { status: "noop" };
|
|
252
|
+
let k = t(O, E), A = o !== null && o.cell.row === w.row && o.cell.col === w.col ? o.startValue : void 0, P = p(E, k, n, O) || A !== void 0 && !Object.is(A.value, k) && p(E, A.value, n, O);
|
|
253
|
+
if (!P && b) {
|
|
254
|
+
let e = m(E, n, O, a.localeTexts?.multiSelectSeparator), t = g(E, O, e, a.localeTexts);
|
|
249
255
|
if (t.action === "reject") return {
|
|
250
256
|
status: "rejected",
|
|
251
257
|
message: t.message
|
|
252
258
|
};
|
|
253
|
-
let r =
|
|
254
|
-
|
|
255
|
-
viewIndex:
|
|
256
|
-
column:
|
|
259
|
+
let r = Y(a, E, O, w.row, s);
|
|
260
|
+
b([{
|
|
261
|
+
viewIndex: w.row,
|
|
262
|
+
column: E,
|
|
257
263
|
value: e
|
|
258
|
-
}, ...
|
|
259
|
-
} else if (!
|
|
260
|
-
let e = m(
|
|
264
|
+
}, ...M(r, w.row)]);
|
|
265
|
+
} else if (!P && x) {
|
|
266
|
+
let e = m(E, n, O, a.localeTexts?.multiSelectSeparator), t = g(E, O, e, a.localeTexts);
|
|
261
267
|
if (t.action === "reject") return {
|
|
262
268
|
status: "rejected",
|
|
263
269
|
message: t.message
|
|
264
270
|
};
|
|
265
|
-
let r =
|
|
266
|
-
|
|
271
|
+
let r = Y(a, E, O, w.row, s);
|
|
272
|
+
x(r === null ? h(y, D, E, e) : j(y, D, E, e, r));
|
|
267
273
|
}
|
|
268
|
-
|
|
269
|
-
let
|
|
274
|
+
C.current = !0;
|
|
275
|
+
let F = J(), I;
|
|
270
276
|
if (a.followsRow === !0) {
|
|
271
|
-
let e =
|
|
272
|
-
(
|
|
277
|
+
let e = K(_, T.row, w.row);
|
|
278
|
+
(_.getRow(e) != null || _.getLabelRow?.(e) !== void 0) && (I = _.getRowKey(e));
|
|
273
279
|
}
|
|
274
|
-
return
|
|
275
|
-
activeCell:
|
|
276
|
-
selection:
|
|
277
|
-
} : null,
|
|
278
|
-
},
|
|
280
|
+
return q(T, i === void 0 ? {
|
|
281
|
+
activeCell: l.activeCell,
|
|
282
|
+
selection: l.selection
|
|
283
|
+
} : null, w.row, F, I, i === void 0 ? void 0 : c), S(e.stopEdit()), { status: "committed" };
|
|
284
|
+
}, Q = () => {
|
|
279
285
|
if (a === null || a.editorActionGuardRef.current) return;
|
|
280
286
|
w = !0, u = null, a.editorActionGuardRef.current = !0;
|
|
281
|
-
let t =
|
|
282
|
-
a.dispatch(e.stopEdit()),
|
|
283
|
-
},
|
|
284
|
-
|
|
287
|
+
let t = J();
|
|
288
|
+
a.dispatch(e.stopEdit()), q(null, null, void 0, t);
|
|
289
|
+
}, ee = (e) => {
|
|
290
|
+
P = e;
|
|
285
291
|
}, $ = (e, a, o, s, c) => {
|
|
286
|
-
let l = e.visibleColumns.find((e) => e.key === a.columnKey), u = s ? null : S(e).editingCell, d = u &&
|
|
292
|
+
let l = e.visibleColumns.find((e) => e.key === a.columnKey), u = s ? null : S(e).editingCell, d = u && L(e, u);
|
|
287
293
|
if (l === void 0 || d && Object.is(d.rowKey, a.rowKey) && d.columnKey === a.columnKey) return { status: "noop" };
|
|
288
294
|
if (Object.is(a.rowKey, "__ssg_new_row__")) {
|
|
289
295
|
let n = e.rowModel.newRow, a = n?.peekRow();
|
|
@@ -300,8 +306,8 @@ var T = (e, t) => {
|
|
|
300
306
|
message: d.message
|
|
301
307
|
} : (n.writeRow(i(a, l, u)), { status: "committed" });
|
|
302
308
|
}
|
|
303
|
-
let f =
|
|
304
|
-
e.applyServerSideCellEdits === void 0 ? e.onRowsChange !== void 0 && (v =
|
|
309
|
+
let f = R(e, a), _, v = -1, y = I !== null && I.from === e.rows ? I.rows : e.rows;
|
|
310
|
+
e.applyServerSideCellEdits === void 0 ? e.onRowsChange !== void 0 && (v = H(e, a.rowKey), _ = v < 0 ? void 0 : y[v]) : _ = f === null ? void 0 : e.rowModel.getRow(f.row);
|
|
305
311
|
let b = f ?? a.cell;
|
|
306
312
|
if (_ === void 0 || !n({
|
|
307
313
|
readOnly: e.readOnly,
|
|
@@ -321,10 +327,10 @@ var T = (e, t) => {
|
|
|
321
327
|
viewIndex: f.row,
|
|
322
328
|
column: l,
|
|
323
329
|
value: x
|
|
324
|
-
}, ...
|
|
330
|
+
}, ...M(T, f.row)]);
|
|
325
331
|
else if (e.onRowsChange !== void 0 && v >= 0) {
|
|
326
|
-
let t = T === null ? h(y, v, l, x) :
|
|
327
|
-
|
|
332
|
+
let t = T === null ? h(y, v, l, x) : j(y, v, l, x, T);
|
|
333
|
+
I = {
|
|
328
334
|
from: e.rows,
|
|
329
335
|
rows: t
|
|
330
336
|
}, e.onRowsChange(t);
|
|
@@ -332,12 +338,12 @@ var T = (e, t) => {
|
|
|
332
338
|
return { status: "committed" };
|
|
333
339
|
};
|
|
334
340
|
return {
|
|
335
|
-
update:
|
|
336
|
-
activateSingleCell:
|
|
337
|
-
startEditWithValue:
|
|
338
|
-
commitEdit:
|
|
339
|
-
cancelEdit:
|
|
340
|
-
registerDraftFlush:
|
|
341
|
+
update: z,
|
|
342
|
+
activateSingleCell: U,
|
|
343
|
+
startEditWithValue: W,
|
|
344
|
+
commitEdit: Z,
|
|
345
|
+
cancelEdit: Q,
|
|
346
|
+
registerDraftFlush: ee,
|
|
341
347
|
endEditLeftOpen: () => {
|
|
342
348
|
let t = a;
|
|
343
349
|
if (t === null || t.editorActionGuardRef.current) return;
|
|
@@ -345,7 +351,7 @@ var T = (e, t) => {
|
|
|
345
351
|
if (n === null) return;
|
|
346
352
|
let r = t.visibleColumns[n.col];
|
|
347
353
|
if (r === void 0 || s(r, y(t.rowModel, n.row))?.type !== "custom") return;
|
|
348
|
-
let i = o ??
|
|
354
|
+
let i = o ?? L(t, n), c = F;
|
|
349
355
|
if (i !== null && c !== null) {
|
|
350
356
|
let e = {
|
|
351
357
|
...i,
|
|
@@ -353,15 +359,15 @@ var T = (e, t) => {
|
|
|
353
359
|
}, t = !1;
|
|
354
360
|
c((n) => t || a === null ? { status: "noop" } : (t = !0, $(a, e, n)));
|
|
355
361
|
}
|
|
356
|
-
t.editorActionGuardRef.current = !0, t.dispatch(e.stopEdit()),
|
|
362
|
+
t.editorActionGuardRef.current = !0, t.dispatch(e.stopEdit()), q(null);
|
|
357
363
|
},
|
|
358
|
-
registerLateCommitReceiver: (e) => (
|
|
359
|
-
|
|
364
|
+
registerLateCommitReceiver: (e) => (F = e, () => {
|
|
365
|
+
F === e && (F = null);
|
|
360
366
|
}),
|
|
361
367
|
dispose: () => {
|
|
362
|
-
a = null,
|
|
368
|
+
a = null, F = null;
|
|
363
369
|
}
|
|
364
370
|
};
|
|
365
371
|
};
|
|
366
372
|
//#endregion
|
|
367
|
-
export {
|
|
373
|
+
export { N as createEditController };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../logic/detailRow.cjs"),t=require("../logic/valueStore.cjs"),n=require("../logic/chunkedLoop.cjs"),r=require("../logic/find.cjs");var i=
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../logic/detailRow.cjs"),t=require("../logic/valueStore.cjs"),n=require("../logic/chunkedLoop.cjs"),r=require("../logic/find.cjs");var i=(e,t,n)=>t>=e.startRow&&t<=e.endRow&&n>=e.startCol&&n<=e.endCol&&(e.rows===void 0||e.rows.has(t)),a=e=>{if(e.rows===void 0)return[{startRow:e.startRow,endRow:e.endRow}];let t=[...e.rows].sort((e,t)=>e-t),n=[];for(let e of t){let t=n[n.length-1];t&&e===t.endRow+1?t.endRow=e:n.push({startRow:e,endRow:e})}return n},o=(e,t,n)=>{if(e.length===0)return null;let r=e.findIndex(e=>e.rowIndex>t||e.rowIndex===t&&e.colIndex>n);return r<0?0:r},s=(e,t,n)=>{if(e.length===0)return null;if(n.rowKey===void 0)return o(e,n.rowIndex,n.colIndex);let r=e.findIndex(e=>e.columnKey===n.columnKey&&t.getRowKey(e.rowIndex)===n.rowKey);if(r>=0)return r;let i=e.findIndex(e=>e.rowIndex>n.rowIndex||e.rowIndex===n.rowIndex&&e.colIndex>=n.colIndex);return i<0?0:i},c=1e4,l=5e4,u=new Map,d=[],f=(e,t)=>e.length===t.length&&e.every((e,n)=>{let r=t[n];return e.rowIndex===r.rowIndex&&e.colIndex===r.colIndex&&e.columnKey===r.columnKey&&e.start===r.start&&e.length===r.length}),p=()=>{let a=null,c=0,p=null,m=!1,h=!1,g=null,_,v=null,y=t.createValueStore({open:!1,query:``,matches:[],index:u,currentIndex:null,scanning:!1,truncated:!1,focusRequest:0}),b=e=>{y.setSnapshot({...y.getSnapshot(),...e})},x=null,S=()=>{let e=y.getSnapshot(),t={query:e.query,matchCount:e.matches.length,currentIndex:e.currentIndex,open:e.open,truncated:e.truncated};x!==null&&x.query===t.query&&x.matchCount===t.matchCount&&x.currentIndex===t.currentIndex&&x.open===t.open&&x.truncated===t.truncated||(x=t,a?.onChange?.(t))},C=e=>{let t=y.getSnapshot();if(t.currentIndex===null)return;let n=t.matches[t.currentIndex];n&&a?.onNavigate(n.rowIndex,n.colIndex,e)},w=()=>{c+=1,v=null,p=null,m=!1,h=!1,g=null,b({matches:[],index:u,currentIndex:null,scanning:!1,truncated:!1})},T=(t,o=!1)=>{let u=a,x=y.getSnapshot();if(!u||!x.open||x.query.length===0){w(),S();return}c+=1;let E=c,{rowModel:D,columns:O,caseSensitive:k}=u,A=u.conditionalFormat!==!1,j=u.multiSelectSeparator,M=u.scope??null,N=u.toViewRow,P=x.query,F=v!==null&&v.query===P&&v.caseSensitive===k;v={rowModel:D,columns:O,query:P,caseSensitive:k,conditionalFormatShown:A,separator:j,scope:M},(o||p===null||p.columns!==O||p.query!==P||p.caseSensitive!==k||p.conditionalFormatShown!==A||p.separator!==j)&&(p={columns:O,query:P,caseSensitive:k,conditionalFormatShown:A,separator:j,byRow:new WeakMap});let I=p.byRow,L=0,R=t||m;m=R;let z=x.currentIndex===null?null:x.matches[x.currentIndex]??null,B=[],V=!1,H=D.getRowCount(),U=H>l,W=(t,n)=>{let i=[];return O.forEach((a,o)=>{if(e.isSyntheticColumnKey(a.key)||!r.isFindableColumn(a,A,t))return;let s=r.resolveFindCellText(a,t,!A||a.conditionalFormat?.chips===void 0?void 0:{rowIndex:n,sourceRowIndex:D.getSourceIndex(n)??n,rowKey:D.getRowKey(n)??n,colIndex:o},j);for(let e of r.findRangesInCell(a,t,s,P,k,j))i.push({colIndex:o,columnKey:String(a.key),start:e.start,length:e.length})}),i.length===0?d:i};!F&&!x.scanning&&b({scanning:!0}),n.runChunked(H,e=>{if(V)return;let t=D.getRow(e);if(t===void 0)return;let n=D.getTreeRow?.(e)?.aggregates,r;U&&typeof t==`object`&&t?(r=I.get(t),r===void 0?(r=W(t,e),I.set(t,r)):L+=1):r=W(t,e);let a=M===null?e:N?N(e):e;for(let t of r)if(!(n!==void 0&&t.columnKey in n)&&!(M!==null&&!i(M,a,t.colIndex))){if(B.length>=1e4){V=!0;return}B.push({rowIndex:e,colIndex:t.colIndex,columnKey:t.columnKey,start:t.start,length:t.length})}},{isCancelled:()=>c!==E}).then(e=>{if(!e||c!==E)return;m=!1;let t=h;if(h=!1,o&&V===y.getSnapshot().truncated&&f(y.getSnapshot().matches,B))return;let n=g;g=null;let i=n===null?r.resolveCurrentAfterRescan(B,z):s(B,D,n);b({matches:B,index:r.buildFindIndex(B,a?.toViewRow),currentIndex:i,scanning:!1,truncated:V}),_=a?.toViewRow,S(),R?C(`query`):(n!==null||t)&&C(`step`),!o&&L>0&&T(!1,!0)})},E=()=>{let e=y.getSnapshot();return!a||!e.open||e.query.length===0?!1:v===null||v.rowModel!==a.rowModel||v.columns!==a.columns||v.query!==e.query||v.caseSensitive!==a.caseSensitive||v.conditionalFormatShown!==(a.conditionalFormat!==!1)||v.separator!==a.multiSelectSeparator||v.scope!==(a.scope??null)};return{update:e=>{let t=a;if(a=e,!e.enabled){y.getSnapshot().open&&(b({open:!1,query:``}),w(),S());return}if(t!==e&&E()){T(!1);return}let n=y.getSnapshot();e.toViewRow!==_&&!n.scanning&&(_=e.toViewRow,n.matches.length>0&&b({index:r.buildFindIndex(n.matches,e.toViewRow)}))},open:e=>{if(!a?.enabled)return;let t=y.getSnapshot(),n=e??t.query;b({open:!0,query:n,focusRequest:t.focusRequest+1}),n!==t.query||!t.open?T(!0):S()},close:()=>{y.getSnapshot().open&&(b({open:!1,query:``}),w(),S())},setQuery:e=>{let t=y.getSnapshot();!t.open||e===t.query||(g=null,b({query:e}),T(!0))},next:()=>{let e=y.getSnapshot(),t=r.stepFindIndex(e.currentIndex,e.matches.length,1);b({currentIndex:t}),S(),C(`step`)},prev:()=>{let e=y.getSnapshot(),t=r.stepFindIndex(e.currentIndex,e.matches.length,-1);b({currentIndex:t}),S(),C(`step`)},continueAfter:(e,t,n)=>{if(n){let n=y.getSnapshot(),r=o(n.matches,e,t),i=r===null?void 0:n.matches[r];g=i===void 0||!a?{rowIndex:e,colIndex:t,rowKey:void 0,columnKey:``}:{rowIndex:i.rowIndex,colIndex:i.colIndex,rowKey:a.rowModel.getRowKey(i.rowIndex),columnKey:i.columnKey};return}let r=y.getSnapshot();b({currentIndex:o(r.matches,e,t)}),S(),C(`step`)},navigateAfterRescan:()=>{h=!0},subscribe:y.subscribe,getSnapshot:y.getSnapshot,dispose:()=>{c+=1,a=null}}};exports.FIND_HIT_CACHE_ROW_THRESHOLD=l,exports.MAX_FIND_MATCHES=c,exports.createFindController=p,exports.findScopeRowRuns=a,exports.firstFindMatchAfter=o,exports.isInFindScope=i;
|
|
@@ -18,7 +18,20 @@ export type FindArgs<T> = {
|
|
|
18
18
|
conditionalFormat?: boolean | undefined;
|
|
19
19
|
toViewRow?: ((rowIndex: number) => number) | undefined;
|
|
20
20
|
multiSelectSeparator?: string | undefined;
|
|
21
|
+
scope?: FindScope | null | undefined;
|
|
21
22
|
};
|
|
23
|
+
export type FindScope = {
|
|
24
|
+
startRow: number;
|
|
25
|
+
endRow: number;
|
|
26
|
+
startCol: number;
|
|
27
|
+
endCol: number;
|
|
28
|
+
rows?: ReadonlySet<number> | undefined;
|
|
29
|
+
};
|
|
30
|
+
export declare const isInFindScope: (scope: FindScope, viewRow: number, colIndex: number) => boolean;
|
|
31
|
+
export declare const findScopeRowRuns: (scope: FindScope) => Array<{
|
|
32
|
+
startRow: number;
|
|
33
|
+
endRow: number;
|
|
34
|
+
}>;
|
|
22
35
|
export type FindSnapshot = {
|
|
23
36
|
open: boolean;
|
|
24
37
|
query: string;
|
|
@@ -27,6 +40,7 @@ export type FindSnapshot = {
|
|
|
27
40
|
currentIndex: number | null;
|
|
28
41
|
scanning: boolean;
|
|
29
42
|
truncated: boolean;
|
|
43
|
+
focusRequest: number;
|
|
30
44
|
};
|
|
31
45
|
export type FindController<T> = {
|
|
32
46
|
update: (args: FindArgs<T>) => void;
|
|
@@ -35,10 +49,13 @@ export type FindController<T> = {
|
|
|
35
49
|
setQuery: (query: string) => void;
|
|
36
50
|
next: () => void;
|
|
37
51
|
prev: () => void;
|
|
52
|
+
continueAfter: (rowIndex: number, colIndex: number, afterRescan: boolean) => void;
|
|
53
|
+
navigateAfterRescan: () => void;
|
|
38
54
|
subscribe: (listener: () => void) => () => void;
|
|
39
55
|
getSnapshot: () => FindSnapshot;
|
|
40
56
|
dispose: () => void;
|
|
41
57
|
};
|
|
58
|
+
export declare const firstFindMatchAfter: (matches: readonly FindMatch[], rowIndex: number, colIndex: number) => number | null;
|
|
42
59
|
export declare const MAX_FIND_MATCHES = 10000;
|
|
43
60
|
export declare const FIND_HIT_CACHE_ROW_THRESHOLD = 50000;
|
|
44
61
|
export declare const createFindController: <T>() => FindController<T>;
|