@ishibashi0112/spreadsheet-grid-core 1.3.0 → 1.4.1

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/README.md CHANGED
@@ -9,7 +9,7 @@ Docs and live demos: [datasheet-grid.vercel.app](https://datasheet-grid.vercel.a
9
9
  ## What is in here
10
10
 
11
11
  - Public type definitions with JSDoc. The field docs of `SpreadsheetGridProps`, `GridColumn`, `SpreadsheetGridHandle` and the other option types are in `dist/model/gridTypes.core.d.ts`; they match the tables in `API_REFERENCE.md` of the React package.
12
- - Framework-agnostic modules under `@ishibashi0112/spreadsheet-grid-core/internal/<dir>/<module>` (`model` / `logic` / `controllers` / `engine` / `utils`). They are internal building blocks for the framework adapters (the React package uses them, and depends on the core of exactly the same version), are not covered by `API_REFERENCE.md` or semver, and may change in any release. The old subpaths without `internal/` (`@ishibashi0112/spreadsheet-grid-core/<dir>/<module>`) were deprecated in 0.60.0 and removed in 0.61.0; import from the entry point `@ishibashi0112/spreadsheet-grid-core` instead. If you use the core directly alongside the React package, install the same version of both (a different version installs a second copy of the core). The public entry points are `@ishibashi0112/spreadsheet-grid-core` and `/testing` ([Versioning](https://datasheet-grid.vercel.app/docs/versioning), Japanese).
12
+ - Framework-agnostic modules under `@ishibashi0112/spreadsheet-grid-core/internal/<dir>/<module>` (`model` / `logic` / `controllers` / `engine` / `utils`). They are internal building blocks for the framework adapters (the React and Solid packages use them, and depend on the core of exactly the same version), are not covered by `API_REFERENCE.md` or semver, and may change in any release. The old subpaths without `internal/` (`@ishibashi0112/spreadsheet-grid-core/<dir>/<module>`) were deprecated in 0.60.0 and removed in 0.61.0; import from the entry point `@ishibashi0112/spreadsheet-grid-core` instead. If you use the core directly alongside the React or Solid package, install the same version of both (a different version installs a second copy of the core). The public entry points are `@ishibashi0112/spreadsheet-grid-core` and `/testing` ([Versioning](https://datasheet-grid.vercel.app/docs/versioning), Japanese).
13
13
 
14
14
  ## License
15
15
 
@@ -26,4 +26,4 @@ MIT
26
26
  ドキュメントとライブデモ: [datasheet-grid.vercel.app](https://datasheet-grid.vercel.app) · 変更履歴: [CHANGELOG.md](https://github.com/ishibashi0112/datasheet-grid/blob/main/CHANGELOG.md)
27
27
 
28
28
  - 公開型の定義(JSDoc 付き)。`SpreadsheetGridProps` / `GridColumn` / `SpreadsheetGridHandle` などのフィールドの説明は `dist/model/gridTypes.core.d.ts` にあり、React 版パッケージ同梱の `API_REFERENCE.md` の表と同じ内容です。
29
- - `@ishibashi0112/spreadsheet-grid-core/internal/<dir>/<module>`(`model` / `logic` / `controllers` / `engine` / `utils`)のモジュールは、各フレームワーク版(アダプタ)が使う内部の部品です(React 版が使っていて、同じ版の core に固定で依存します)。`API_REFERENCE.md` と semver の対象外で、どの版でも変わることがあります。`internal/` の無い旧サブパス(`@ishibashi0112/spreadsheet-grid-core/<dir>/<module>`)は 0.60.0 で非推奨にし、0.61.0 で消しました。代わりに入口 `@ishibashi0112/spreadsheet-grid-core` から import してください。React 版と一緒に core も直接使うときは、両方を同じ版にそろえてください(違う版だと core が 2 つ入ります)。公開の入口は `@ishibashi0112/spreadsheet-grid-core` と `/testing` です([バージョンと互換性](https://datasheet-grid.vercel.app/docs/versioning))。
29
+ - `@ishibashi0112/spreadsheet-grid-core/internal/<dir>/<module>`(`model` / `logic` / `controllers` / `engine` / `utils`)のモジュールは、各フレームワーク版(アダプタ)が使う内部の部品です(React 版と Solid 版が使っていて、どちらも同じ版の core に固定で依存します)。`API_REFERENCE.md` と semver の対象外で、どの版でも変わることがあります。`internal/` の無い旧サブパス(`@ishibashi0112/spreadsheet-grid-core/<dir>/<module>`)は 0.60.0 で非推奨にし、0.61.0 で消しました。代わりに入口 `@ishibashi0112/spreadsheet-grid-core` から import してください。React 版や Solid 版と一緒に core も直接使うときは、両方を同じ版にそろえてください(違う版だと core が 2 つ入ります)。公開の入口は `@ishibashi0112/spreadsheet-grid-core` と `/testing` です([バージョンと互換性](https://datasheet-grid.vercel.app/docs/versioning))。
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../model/gridActions.cjs"),t=require("../utils/permissions.cjs"),n=require("../utils/shadowDom.cjs"),r=require("../logic/detailRow.cjs"),i=require("../logic/geometry.cjs"),a=require("../logic/editorValues.cjs"),o=require("../logic/validation.cjs");var s=(e,t)=>t.activeCell!==e.activeCell||t.selection!==e.selection,c=e=>{if(r.isFocusInsideDetailCard(e))return!1;let t=e.ownerDocument,i=n.getActiveElement(e);return i===null||i===t.body||i===t.documentElement||e.contains(i)},l=e=>{let t=e.ownerDocument,r=n.getActiveElement(e);return r===null||r===t.body||r===t.documentElement},u=e=>{if(e===null)return!1;let t=n.getActiveElement(e);return t!==null&&t!==e&&e.contains(t)&&typeof t.closest==`function`&&t.closest(`.ssg-cell-editor`)!==null&&!r.isFocusInsideDetailCard(e)},d=()=>{let n=null,d=null,f=null,p=null,m=!1,h=!1,g=null,_=(e,t)=>{let n=e.visibleColumns[t.col];return!n||t.row<0||t.row>=e.rowModel.getRowCount()||e.rowModel.getRow(t.row)===void 0?null:{rowKey:e.rowModel.getRowKey(t.row),columnKey:n.key}},v=(e,t)=>{let n=e.visibleColumns.findIndex(e=>e.key===t.columnKey);if(n<0)return null;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},y=t=>{n=t;let r=t.uiState.editingCell;if(!r){d=null,g=null;return}let i=_(t,r);if(d!==null&&i!==null&&Object.is(i.rowKey,d.rowKey)&&i.columnKey===d.columnKey){d={...d,cell:r};return}let a=d!==null&&d.cell.row===r.row&&d.cell.col===r.col;if(d===null||!a){d=i?{...i,cell:r}:null,f!==null&&(f.superseded=!0,f=null,t.editorActionGuardRef.current=!1);return}let o=v(t,d);if(o)d={...d,cell:o},t.dispatch(e.gridActions.retargetEdit(o,t.rowModel.getRowCount()));else{let e=d;d=null,b(t,e)}},b=(t,n)=>{if(t.editorActionGuardRef.current){t.dispatch(e.gridActions.stopEdit());return}let r=t.visibleColumns.find(e=>e.key===n.columnKey),i=r===void 0||t.applyServerSideCellEdits!==void 0||t.onRowsChange===void 0?-1:x(t,n.rowKey);p=r!==void 0&&i>=0?{sourceIndex:i,column:r,cell:n.cell,rowKey:n.rowKey}:null,m=!1;let a=g;g=null,h=!0;let o;try{a!==null&&(a(),p=null),o=D()}finally{h=!1,p=null}let s=t.gridRootRef.current;if(!o&&s!==null&&s.isConnected&&l(s)&&(s.focus({preventScroll:!0}),o=!0),m&&t.editorActionGuardRef.current){m=!1;return}m=!1,t.editorActionGuardRef.current=!0,t.dispatch(e.gridActions.stopEdit()),E(null,null,void 0,o)},x=(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},S=(e,n,r)=>{let{rows:i,onRowsChange:s}=e,c=i[n.sourceIndex];if(c===void 0||s===void 0||!t.isCellEditable({readOnly:e.readOnly,canEditCell:e.canEditCell},n.cell.row,n.cell.col,c,n.column,{sourceRowIndex:n.sourceIndex,rowKey:n.rowKey}))return{status:`noop`};if(a.isUnchangedEditorCommit(n.column,t.getCellValue(c,n.column),r))return{status:`committed`};let l=a.parseCommittedValue(n.column,r,c);return o.decideCellWrite(n.column,c,l,e.localeTexts).action===`reject`?{status:`noop`}:(s(a.writeRowsCell(i,n.sourceIndex,n.column,l)),{status:`committed`})},C=t=>{n!==null&&(n.dispatch(e.gridActions.startSelection(t)),n.dispatch(e.gridActions.endSelection()),n.dispatch(e.gridActions.activateCell(t)))},w=(t,r)=>{n!==null&&(n.setEditorInitialValue(r),n.dispatch(e.gridActions.startEdit(t)))},T=(e,t,n)=>{let r=e.getRowCount(),a=i.clamp(t,0,Math.max(r-1,0)),{getLabelRow:o}=e;if(o&&n!==void 0&&a!==n){let e=a>n?1:-1;for(;a>=0&&a<r&&o(a);)a+=e;(a<0||a>=r)&&(a=i.clamp(n,0,Math.max(r-1,0)))}return a},E=(e,t=null,a,o=!1,l)=>{let u=n;if(u===null)return;let d=!1,p={superseded:!1};f=p;let m=u.uiState.editingCell,h=o=>{if(d)return;if(p.superseded){d=!0;return}let h=n===null?null:n.getUiState?.()??null;if(h!==null&&h.editingCell!==null&&h.editingCell!==m){d=!0,f===p&&(f=null),u.editorActionGuardRef.current=!1;return}if(!o&&(n===null||n.uiState.editingCell!==null))return;d=!0,f===p&&(f=null);let g=u.gridRootRef.current;if(g!==null&&c(g)&&g.focus(),e!==null&&n!==null&&!(t!==null&&s(t,n.uiState))){let t=n.visibleColumns.length,o=l===void 0?-1:r.findViewRowIndexByKey(n.rowModel,l,new Map),s=o>=0?o:T(n.rowModel,e.row,a);C({row:s,col:i.clamp(e.col,0,Math.max(t-1,0))})}u.editorActionGuardRef.current=!1};o&&queueMicrotask(()=>h(!1)),requestAnimationFrame(()=>h(!0))},D=()=>{let e=n?.gridRootRef.current??null;return u(e)?(e.focus({preventScroll:!0}),!0):!1};return{update:y,activateSingleCell:C,startEditWithValue:w,commitEdit:(i,s)=>{if(n===null)return{status:`noop`};let{uiState:c,visibleColumns:l,rowModel:u,rows:d,applyServerSideCellEdits:f,onRowsChange:m,dispatch:g,editorActionGuardRef:_}=n;if(_.current||!c.editingCell)return{status:`noop`};if(h){let e=p;return p=null,e===null?{status:`noop`}:S(n,e,i)}let v=c.editingCell,y=s===`down`?{row:v.row+1,col:v.col}:s===`up`?{row:v.row-1,col:v.col}:s===`right`?{row:v.row,col:v.col+1}:s===`left`?{row:v.row,col:Math.max(v.col-1,r.resolveFirstDataColIndex(l))}:v,b=l[v.col],x=u.getSourceIndex(v.row),C=f?u.getRow(v.row):d[x];if(!b||!C)return g(e.gridActions.stopEdit()),{status:`noop`};if(!t.isViewCellEditable({readOnly:n.readOnly,canEditCell:n.canEditCell},u,v.row,v.col,C,b))return _.current=!0,g(e.gridActions.stopEdit()),E(null),{status:`noop`};let w=a.isUnchangedEditorCommit(b,t.getCellValue(C,b),i);if(!w&&f){let e=a.parseCommittedValue(b,i,C),t=o.decideCellWrite(b,C,e,n.localeTexts);if(t.action===`reject`)return{status:`rejected`,message:t.message};f([{viewIndex:v.row,column:b,value:e}])}else if(!w&&m){let e=a.parseCommittedValue(b,i,C),t=o.decideCellWrite(b,C,e,n.localeTexts);if(t.action===`reject`)return{status:`rejected`,message:t.message};m(a.writeRowsCell(d,x,b,e))}_.current=!0;let O=D(),k;if(n.followsRow===!0){let e=T(u,y.row,v.row);(u.getRow(e)!=null||u.getLabelRow?.(e)!==void 0)&&(k=u.getRowKey(e))}return E(y,s===void 0?{activeCell:c.activeCell,selection:c.selection}:null,v.row,O,k),g(e.gridActions.stopEdit()),{status:`committed`}},cancelEdit:()=>{if(n===null||n.editorActionGuardRef.current)return;m=!0,p=null,n.editorActionGuardRef.current=!0;let t=D();n.dispatch(e.gridActions.stopEdit()),E(null,null,void 0,t)},registerDraftFlush:e=>{g=e}}};exports.createEditController=d;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../model/gridActions.cjs"),t=require("../utils/permissions.cjs"),n=require("../utils/shadowDom.cjs"),r=require("../logic/detailRow.cjs"),i=require("../logic/geometry.cjs"),a=require("../logic/editorValues.cjs"),o=require("../logic/validation.cjs"),s=require("./liveUiState.cjs");var c=(e,t)=>t.activeCell!==e.activeCell||t.selection!==e.selection,l=e=>{if(r.isFocusInsideDetailCard(e))return!1;let t=e.ownerDocument,i=n.getActiveElement(e);return i===null||i===t.body||i===t.documentElement||e.contains(i)},u=e=>{let t=e.ownerDocument,r=n.getActiveElement(e);return r===null||r===t.body||r===t.documentElement},d=e=>{if(e===null)return!1;let t=n.getActiveElement(e);return t!==null&&t!==e&&e.contains(t)&&typeof t.closest==`function`&&t.closest(`.ssg-cell-editor`)!==null&&!r.isFocusInsideDetailCard(e)},f=()=>{let n=null,f=null,p=null,m=null,h=!1,g=!1,_=null,v=null,y=null,b=(e,t)=>{let n=e.visibleColumns[t.col];return!n||t.row<0||t.row>=e.rowModel.getRowCount()||e.rowModel.getRow(t.row)===void 0?null:{rowKey:e.rowModel.getRowKey(t.row),columnKey:n.key}},x=(e,t)=>{let n=e.visibleColumns.findIndex(e=>e.key===t.columnKey);if(n<0)return null;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},S=t=>{n=t;let r=t.uiState.editingCell;if(!r){f=null,_=null;return}let i=b(t,r);if(f!==null&&i!==null&&Object.is(i.rowKey,f.rowKey)&&i.columnKey===f.columnKey){f={...f,cell:r};return}let a=f!==null&&f.cell.row===r.row&&f.cell.col===r.col;if(f===null||!a){f=i?{...i,cell:r}:null,p!==null&&(p.superseded=!0,p=null,t.editorActionGuardRef.current=!1);return}let o=x(t,f);if(o)f={...f,cell:o},t.dispatch(e.gridActions.retargetEdit(o,t.rowModel.getRowCount()));else{let e=f;f=null,C(t,e)}},C=(t,n)=>{if(t.editorActionGuardRef.current){t.dispatch(e.gridActions.stopEdit());return}m=n,h=!1;let r=_;_=null,g=!0;let i;try{r!==null&&(r(),m=null),i=k()}finally{g=!1,m=null}let a=t.gridRootRef.current;if(!i&&a!==null&&a.isConnected&&u(a)&&(a.focus({preventScroll:!0}),i=!0),h&&t.editorActionGuardRef.current){h=!1;return}h=!1,t.editorActionGuardRef.current=!0,t.dispatch(e.gridActions.stopEdit()),O(null,null,void 0,i)},w=(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},T=t=>{n!==null&&(n.dispatch(e.gridActions.startSelection(t)),n.dispatch(e.gridActions.endSelection()),n.dispatch(e.gridActions.activateCell(t)))},E=(t,r)=>{n!==null&&(n.setEditorInitialValue(r),n.dispatch(e.gridActions.startEdit(t)))},D=(e,t,n)=>{let r=e.getRowCount(),a=i.clamp(t,0,Math.max(r-1,0)),{getLabelRow:o}=e;if(o&&n!==void 0&&a!==n){let e=a>n?1:-1;for(;a>=0&&a<r&&o(a);)a+=e;(a<0||a>=r)&&(a=i.clamp(n,0,Math.max(r-1,0)))}return a},O=(e,t=null,a,o=!1,s)=>{let u=n;if(u===null)return;let d=!1,f={superseded:!1};p=f;let m=u.uiState.editingCell,h=o=>{if(d)return;if(f.superseded){d=!0;return}let h=n===null?null:n.getUiState?.()??null;if(h!==null&&h.editingCell!==null&&h.editingCell!==m){d=!0,p===f&&(p=null),u.editorActionGuardRef.current=!1;return}if(!o&&(n===null||n.uiState.editingCell!==null))return;d=!0,p===f&&(p=null);let g=u.gridRootRef.current;if(g!==null&&l(g)&&g.focus(),e!==null&&n!==null&&!(t!==null&&c(t,n.uiState))){let t=n.visibleColumns.length,o=s===void 0?-1:r.findViewRowIndexByKey(n.rowModel,s,new Map),c=o>=0?o:D(n.rowModel,e.row,a);T({row:c,col:i.clamp(e.col,0,Math.max(t-1,0))})}u.editorActionGuardRef.current=!1};o&&queueMicrotask(()=>h(!1)),requestAnimationFrame(()=>h(!0))},k=()=>{let e=n?.gridRootRef.current??null;return d(e)?(e.focus({preventScroll:!0}),!0):!1},A=(i,s)=>{if(n===null)return{status:`noop`};let{uiState:c,visibleColumns:l,rowModel:u,rows:d,applyServerSideCellEdits:f,onRowsChange:p,dispatch:h,editorActionGuardRef:_}=n;if(_.current||!c.editingCell)return{status:`noop`};if(g){let e=m;return m=null,e===null?{status:`noop`}:N(n,e,i,!0)}let v=c.editingCell,y=s===`down`?{row:v.row+1,col:v.col}:s===`up`?{row:v.row-1,col:v.col}:s===`right`?{row:v.row,col:v.col+1}:s===`left`?{row:v.row,col:Math.max(v.col-1,r.resolveFirstDataColIndex(l))}:v,b=l[v.col],x=u.getSourceIndex(v.row),S=f?u.getRow(v.row):d[x];if(!b||!S)return h(e.gridActions.stopEdit()),{status:`noop`};if(!t.isViewCellEditable({readOnly:n.readOnly,canEditCell:n.canEditCell},u,v.row,v.col,S,b))return _.current=!0,h(e.gridActions.stopEdit()),O(null),{status:`noop`};let C=a.isUnchangedEditorCommit(b,t.getCellValue(S,b),i);if(!C&&f){let e=a.parseCommittedValue(b,i,S),t=o.decideCellWrite(b,S,e,n.localeTexts);if(t.action===`reject`)return{status:`rejected`,message:t.message};f([{viewIndex:v.row,column:b,value:e}])}else if(!C&&p){let e=a.parseCommittedValue(b,i,S),t=o.decideCellWrite(b,S,e,n.localeTexts);if(t.action===`reject`)return{status:`rejected`,message:t.message};p(a.writeRowsCell(d,x,b,e))}_.current=!0;let w=k(),T;if(n.followsRow===!0){let e=D(u,y.row,v.row);(u.getRow(e)!=null||u.getLabelRow?.(e)!==void 0)&&(T=u.getRowKey(e))}return O(y,s===void 0?{activeCell:c.activeCell,selection:c.selection}:null,v.row,w,T),h(e.gridActions.stopEdit()),{status:`committed`}},j=()=>{if(n===null||n.editorActionGuardRef.current)return;h=!0,m=null,n.editorActionGuardRef.current=!0;let t=k();n.dispatch(e.gridActions.stopEdit()),O(null,null,void 0,t)},M=e=>{_=e},N=(e,n,r,i)=>{let c=e.visibleColumns.find(e=>e.key===n.columnKey),l=i?null:s.readLiveUiState(e).editingCell,u=l&&b(e,l);if(c===void 0||u&&Object.is(u.rowKey,n.rowKey)&&u.columnKey===n.columnKey)return{status:`noop`};let d=x(e,n),f,p=-1,m=y!==null&&y.from===e.rows?y.rows:e.rows;e.applyServerSideCellEdits===void 0?e.onRowsChange!==void 0&&(p=w(e,n.rowKey),f=p<0?void 0:m[p]):f=d===null?void 0:e.rowModel.getRow(d.row);let h=d??n.cell;if(f===void 0||!t.isCellEditable({readOnly:e.readOnly,canEditCell:e.canEditCell},h.row,h.col,f,c,{sourceRowIndex:p>=0?p:e.rowModel.getSourceIndex(h.row),rowKey:n.rowKey}))return{status:`noop`};if(a.isUnchangedEditorCommit(c,t.getCellValue(f,c),r))return{status:`committed`};let g=a.parseCommittedValue(c,r,f),_=o.decideCellWrite(c,f,g,e.localeTexts);if(_.action===`reject`)return i?{status:`noop`}:{status:`rejected`,message:_.message};if(e.applyServerSideCellEdits!==void 0&&d!==null)e.applyServerSideCellEdits([{viewIndex:d.row,column:c,value:g}]);else if(e.onRowsChange!==void 0&&p>=0){let t=a.writeRowsCell(m,p,c,g);y={from:e.rows,rows:t},e.onRowsChange(t)}return{status:`committed`}};return{update:S,activateSingleCell:T,startEditWithValue:E,commitEdit:A,cancelEdit:j,registerDraftFlush:M,endEditLeftOpen:()=>{let t=n;if(t===null||t.editorActionGuardRef.current)return;let r=s.readLiveUiState(t).editingCell;if(r===null||t.visibleColumns[r.col]?.editor?.type!==`custom`)return;let i=f??b(t,r),a=v;if(i!==null&&a!==null){let e={...i,cell:r},t=!1;a(r=>t||n===null?{status:`noop`}:(t=!0,N(n,e,r)))}t.editorActionGuardRef.current=!0,t.dispatch(e.gridActions.stopEdit()),O(null)},registerLateCommitReceiver:e=>(v=e,()=>{v===e&&(v=null)}),dispose:()=>{n=null,v=null}}};exports.createEditController=f;
@@ -24,6 +24,8 @@ export type EditControllerArgs<T extends object> = {
24
24
  getUiState?: (() => GridUiState) | undefined;
25
25
  rowKeyGetter?: ((row: T, index: number) => GridRowKey) | undefined;
26
26
  };
27
+ export type LateEditCommit = (value: unknown) => EditorCommitResult;
28
+ export type LateEditCommitReceiver = (commit: LateEditCommit) => void;
27
29
  export type EditController<T extends object> = {
28
30
  update: (args: EditControllerArgs<T>) => void;
29
31
  activateSingleCell: (cell: CellCoord) => void;
@@ -31,5 +33,8 @@ export type EditController<T extends object> = {
31
33
  commitEdit: (committedValue: unknown, direction?: EditorCommitDirection) => EditorCommitResult;
32
34
  cancelEdit: () => void;
33
35
  registerDraftFlush: (flush: (() => void) | null) => void;
36
+ endEditLeftOpen: () => void;
37
+ registerLateCommitReceiver: (receiver: LateEditCommitReceiver) => () => void;
38
+ dispose: () => void;
34
39
  };
35
40
  export declare const createEditController: <T extends object>() => EditController<T>;
@@ -5,26 +5,27 @@ import { findViewRowIndexByKey as a, isFocusInsideDetailCard as o, resolveFirstD
5
5
  import { clamp as c } from "../logic/geometry.js";
6
6
  import { isUnchangedEditorCommit as l, parseCommittedValue as u, writeRowsCell as d } from "../logic/editorValues.js";
7
7
  import { decideCellWrite as f } from "../logic/validation.js";
8
+ import { readLiveUiState as p } from "./liveUiState.js";
8
9
  //#region src/controllers/editController.ts
9
- var p = (e, t) => t.activeCell !== e.activeCell || t.selection !== e.selection, m = (e) => {
10
+ var m = (e, t) => t.activeCell !== e.activeCell || t.selection !== e.selection, h = (e) => {
10
11
  if (o(e)) return !1;
11
12
  let t = e.ownerDocument, n = i(e);
12
13
  return n === null || n === t.body || n === t.documentElement || e.contains(n);
13
- }, h = (e) => {
14
+ }, g = (e) => {
14
15
  let t = e.ownerDocument, n = i(e);
15
16
  return n === null || n === t.body || n === t.documentElement;
16
- }, g = (e) => {
17
+ }, _ = (e) => {
17
18
  if (e === null) return !1;
18
19
  let t = i(e);
19
20
  return t !== null && t !== e && e.contains(t) && typeof t.closest == "function" && t.closest(".ssg-cell-editor") !== null && !o(e);
20
- }, _ = () => {
21
- let i = null, o = null, _ = null, v = null, y = !1, b = !1, x = null, S = (e, t) => {
21
+ }, v = () => {
22
+ let i = null, o = null, v = null, y = null, b = !1, x = !1, S = null, C = null, w = null, T = (e, t) => {
22
23
  let n = e.visibleColumns[t.col];
23
24
  return !n || t.row < 0 || t.row >= e.rowModel.getRowCount() || e.rowModel.getRow(t.row) === void 0 ? null : {
24
25
  rowKey: e.rowModel.getRowKey(t.row),
25
26
  columnKey: n.key
26
27
  };
27
- }, C = (e, t) => {
28
+ }, E = (e, t) => {
28
29
  let n = e.visibleColumns.findIndex((e) => e.key === t.columnKey);
29
30
  if (n < 0) return null;
30
31
  let r = e.rowModel.getRowCount();
@@ -33,14 +34,14 @@ var p = (e, t) => t.activeCell !== e.activeCell || t.selection !== e.selection,
33
34
  col: n
34
35
  };
35
36
  return null;
36
- }, w = (t) => {
37
+ }, D = (t) => {
37
38
  i = t;
38
39
  let n = t.uiState.editingCell;
39
40
  if (!n) {
40
- o = null, x = null;
41
+ o = null, S = null;
41
42
  return;
42
43
  }
43
- let r = S(t, n);
44
+ let r = T(t, n);
44
45
  if (o !== null && r !== null && Object.is(r.rowKey, o.rowKey) && r.columnKey === o.columnKey) {
45
46
  o = {
46
47
  ...o,
@@ -53,68 +54,50 @@ var p = (e, t) => t.activeCell !== e.activeCell || t.selection !== e.selection,
53
54
  o = r ? {
54
55
  ...r,
55
56
  cell: n
56
- } : null, _ !== null && (_.superseded = !0, _ = null, t.editorActionGuardRef.current = !1);
57
+ } : null, v !== null && (v.superseded = !0, v = null, t.editorActionGuardRef.current = !1);
57
58
  return;
58
59
  }
59
- let s = C(t, o);
60
+ let s = E(t, o);
60
61
  if (s) o = {
61
62
  ...o,
62
63
  cell: s
63
64
  }, t.dispatch(e.retargetEdit(s, t.rowModel.getRowCount()));
64
65
  else {
65
66
  let e = o;
66
- o = null, T(t, e);
67
+ o = null, O(t, e);
67
68
  }
68
- }, T = (t, n) => {
69
+ }, O = (t, n) => {
69
70
  if (t.editorActionGuardRef.current) {
70
71
  t.dispatch(e.stopEdit());
71
72
  return;
72
73
  }
73
- let r = t.visibleColumns.find((e) => e.key === n.columnKey), i = r === void 0 || t.applyServerSideCellEdits !== void 0 || t.onRowsChange === void 0 ? -1 : E(t, n.rowKey);
74
- v = r !== void 0 && i >= 0 ? {
75
- sourceIndex: i,
76
- column: r,
77
- cell: n.cell,
78
- rowKey: n.rowKey
79
- } : null, y = !1;
80
- let a = x;
81
- x = null, b = !0;
82
- let o;
74
+ y = n, b = !1;
75
+ let r = S;
76
+ S = null, x = !0;
77
+ let i;
83
78
  try {
84
- a !== null && (a(), v = null), o = M();
79
+ r !== null && (r(), y = null), i = P();
85
80
  } finally {
86
- b = !1, v = null;
81
+ x = !1, y = null;
87
82
  }
88
- let s = t.gridRootRef.current;
89
- if (!o && s !== null && s.isConnected && h(s) && (s.focus({ preventScroll: !0 }), o = !0), y && t.editorActionGuardRef.current) {
90
- y = !1;
83
+ let a = t.gridRootRef.current;
84
+ if (!i && a !== null && a.isConnected && g(a) && (a.focus({ preventScroll: !0 }), i = !0), b && t.editorActionGuardRef.current) {
85
+ b = !1;
91
86
  return;
92
87
  }
93
- y = !1, t.editorActionGuardRef.current = !0, t.dispatch(e.stopEdit()), j(null, null, void 0, o);
94
- }, E = (e, t) => {
88
+ b = !1, t.editorActionGuardRef.current = !0, t.dispatch(e.stopEdit()), N(null, null, void 0, i);
89
+ }, k = (e, t) => {
95
90
  let { rows: n, rowKeyGetter: r } = e;
96
91
  for (let e = 0; e < n.length; e += 1) {
97
92
  let i = n[e];
98
93
  if (i !== void 0 && Object.is(r ? r(i, e) : e, t)) return e;
99
94
  }
100
95
  return -1;
101
- }, D = (e, r, i) => {
102
- let { rows: a, onRowsChange: o } = e, s = a[r.sourceIndex];
103
- if (s === void 0 || o === void 0 || !n({
104
- readOnly: e.readOnly,
105
- canEditCell: e.canEditCell
106
- }, r.cell.row, r.cell.col, s, r.column, {
107
- sourceRowIndex: r.sourceIndex,
108
- rowKey: r.rowKey
109
- })) return { status: "noop" };
110
- if (l(r.column, t(s, r.column), i)) return { status: "committed" };
111
- let c = u(r.column, i, s);
112
- return f(r.column, s, c, e.localeTexts).action === "reject" ? { status: "noop" } : (o(d(a, r.sourceIndex, r.column, c)), { status: "committed" });
113
- }, O = (t) => {
96
+ }, A = (t) => {
114
97
  i !== null && (i.dispatch(e.startSelection(t)), i.dispatch(e.endSelection()), i.dispatch(e.activateCell(t)));
115
- }, k = (t, n) => {
98
+ }, j = (t, n) => {
116
99
  i !== null && (i.setEditorInitialValue(n), i.dispatch(e.startEdit(t)));
117
- }, A = (e, t, n) => {
100
+ }, M = (e, t, n) => {
118
101
  let r = e.getRowCount(), i = c(t, 0, Math.max(r - 1, 0)), { getLabelRow: a } = e;
119
102
  if (a && n !== void 0 && i !== n) {
120
103
  let e = i > n ? 1 : -1;
@@ -122,11 +105,11 @@ var p = (e, t) => t.activeCell !== e.activeCell || t.selection !== e.selection,
122
105
  (i < 0 || i >= r) && (i = c(n, 0, Math.max(r - 1, 0)));
123
106
  }
124
107
  return i;
125
- }, j = (e, t = null, n, r = !1, o) => {
108
+ }, N = (e, t = null, n, r = !1, o) => {
126
109
  let s = i;
127
110
  if (s === null) return;
128
111
  let l = !1, u = { superseded: !1 };
129
- _ = u;
112
+ v = u;
130
113
  let d = s.uiState.editingCell, f = (r) => {
131
114
  if (l) return;
132
115
  if (u.superseded) {
@@ -135,15 +118,15 @@ var p = (e, t) => t.activeCell !== e.activeCell || t.selection !== e.selection,
135
118
  }
136
119
  let f = i === null ? null : i.getUiState?.() ?? null;
137
120
  if (f !== null && f.editingCell !== null && f.editingCell !== d) {
138
- l = !0, _ === u && (_ = null), s.editorActionGuardRef.current = !1;
121
+ l = !0, v === u && (v = null), s.editorActionGuardRef.current = !1;
139
122
  return;
140
123
  }
141
124
  if (!r && (i === null || i.uiState.editingCell !== null)) return;
142
- l = !0, _ === u && (_ = null);
143
- let h = s.gridRootRef.current;
144
- if (h !== null && m(h) && h.focus(), e !== null && i !== null && !(t !== null && p(t, i.uiState))) {
145
- let t = i.visibleColumns.length, r = o === void 0 ? -1 : a(i.rowModel, o, /* @__PURE__ */ new Map()), s = r >= 0 ? r : A(i.rowModel, e.row, n);
146
- O({
125
+ l = !0, v === u && (v = null);
126
+ let p = s.gridRootRef.current;
127
+ if (p !== null && h(p) && p.focus(), e !== null && i !== null && !(t !== null && m(t, i.uiState))) {
128
+ let t = i.visibleColumns.length, r = o === void 0 ? -1 : a(i.rowModel, o, /* @__PURE__ */ new Map()), s = r >= 0 ? r : M(i.rowModel, e.row, n);
129
+ A({
147
130
  row: s,
148
131
  col: c(e.col, 0, Math.max(t - 1, 0))
149
132
  });
@@ -151,81 +134,134 @@ var p = (e, t) => t.activeCell !== e.activeCell || t.selection !== e.selection,
151
134
  s.editorActionGuardRef.current = !1;
152
135
  };
153
136
  r && queueMicrotask(() => f(!1)), requestAnimationFrame(() => f(!0));
154
- }, M = () => {
137
+ }, P = () => {
155
138
  let e = i?.gridRootRef.current ?? null;
156
- return g(e) ? (e.focus({ preventScroll: !0 }), !0) : !1;
139
+ return _(e) ? (e.focus({ preventScroll: !0 }), !0) : !1;
140
+ }, F = (n, a) => {
141
+ if (i === null) return { status: "noop" };
142
+ let { uiState: o, visibleColumns: c, rowModel: p, rows: m, applyServerSideCellEdits: h, onRowsChange: g, dispatch: _, editorActionGuardRef: v } = i;
143
+ if (v.current || !o.editingCell) return { status: "noop" };
144
+ if (x) {
145
+ let e = y;
146
+ return y = null, e === null ? { status: "noop" } : R(i, e, n, !0);
147
+ }
148
+ let b = o.editingCell, S = a === "down" ? {
149
+ row: b.row + 1,
150
+ col: b.col
151
+ } : a === "up" ? {
152
+ row: b.row - 1,
153
+ col: b.col
154
+ } : a === "right" ? {
155
+ row: b.row,
156
+ col: b.col + 1
157
+ } : a === "left" ? {
158
+ row: b.row,
159
+ col: Math.max(b.col - 1, s(c))
160
+ } : b, C = c[b.col], w = p.getSourceIndex(b.row), T = h ? p.getRow(b.row) : m[w];
161
+ if (!C || !T) return _(e.stopEdit()), { status: "noop" };
162
+ if (!r({
163
+ readOnly: i.readOnly,
164
+ canEditCell: i.canEditCell
165
+ }, p, b.row, b.col, T, C)) return v.current = !0, _(e.stopEdit()), N(null), { status: "noop" };
166
+ let E = l(C, t(T, C), n);
167
+ if (!E && h) {
168
+ let e = u(C, n, T), t = f(C, T, e, i.localeTexts);
169
+ if (t.action === "reject") return {
170
+ status: "rejected",
171
+ message: t.message
172
+ };
173
+ h([{
174
+ viewIndex: b.row,
175
+ column: C,
176
+ value: e
177
+ }]);
178
+ } else if (!E && g) {
179
+ let e = u(C, n, T), t = f(C, T, e, i.localeTexts);
180
+ if (t.action === "reject") return {
181
+ status: "rejected",
182
+ message: t.message
183
+ };
184
+ g(d(m, w, C, e));
185
+ }
186
+ v.current = !0;
187
+ let D = P(), O;
188
+ if (i.followsRow === !0) {
189
+ let e = M(p, S.row, b.row);
190
+ (p.getRow(e) != null || p.getLabelRow?.(e) !== void 0) && (O = p.getRowKey(e));
191
+ }
192
+ return N(S, a === void 0 ? {
193
+ activeCell: o.activeCell,
194
+ selection: o.selection
195
+ } : null, b.row, D, O), _(e.stopEdit()), { status: "committed" };
196
+ }, I = () => {
197
+ if (i === null || i.editorActionGuardRef.current) return;
198
+ b = !0, y = null, i.editorActionGuardRef.current = !0;
199
+ let t = P();
200
+ i.dispatch(e.stopEdit()), N(null, null, void 0, t);
201
+ }, L = (e) => {
202
+ S = e;
203
+ }, R = (e, r, i, a) => {
204
+ let o = e.visibleColumns.find((e) => e.key === r.columnKey), s = a ? null : p(e).editingCell, c = s && T(e, s);
205
+ if (o === void 0 || c && Object.is(c.rowKey, r.rowKey) && c.columnKey === r.columnKey) return { status: "noop" };
206
+ let m = E(e, r), h, g = -1, _ = w !== null && w.from === e.rows ? w.rows : e.rows;
207
+ e.applyServerSideCellEdits === void 0 ? e.onRowsChange !== void 0 && (g = k(e, r.rowKey), h = g < 0 ? void 0 : _[g]) : h = m === null ? void 0 : e.rowModel.getRow(m.row);
208
+ let v = m ?? r.cell;
209
+ if (h === void 0 || !n({
210
+ readOnly: e.readOnly,
211
+ canEditCell: e.canEditCell
212
+ }, v.row, v.col, h, o, {
213
+ sourceRowIndex: g >= 0 ? g : e.rowModel.getSourceIndex(v.row),
214
+ rowKey: r.rowKey
215
+ })) return { status: "noop" };
216
+ if (l(o, t(h, o), i)) return { status: "committed" };
217
+ let y = u(o, i, h), b = f(o, h, y, e.localeTexts);
218
+ if (b.action === "reject") return a ? { status: "noop" } : {
219
+ status: "rejected",
220
+ message: b.message
221
+ };
222
+ if (e.applyServerSideCellEdits !== void 0 && m !== null) e.applyServerSideCellEdits([{
223
+ viewIndex: m.row,
224
+ column: o,
225
+ value: y
226
+ }]);
227
+ else if (e.onRowsChange !== void 0 && g >= 0) {
228
+ let t = d(_, g, o, y);
229
+ w = {
230
+ from: e.rows,
231
+ rows: t
232
+ }, e.onRowsChange(t);
233
+ }
234
+ return { status: "committed" };
157
235
  };
158
236
  return {
159
- update: w,
160
- activateSingleCell: O,
161
- startEditWithValue: k,
162
- commitEdit: (n, a) => {
163
- if (i === null) return { status: "noop" };
164
- let { uiState: o, visibleColumns: c, rowModel: p, rows: m, applyServerSideCellEdits: h, onRowsChange: g, dispatch: _, editorActionGuardRef: y } = i;
165
- if (y.current || !o.editingCell) return { status: "noop" };
166
- if (b) {
167
- let e = v;
168
- return v = null, e === null ? { status: "noop" } : D(i, e, n);
169
- }
170
- let x = o.editingCell, S = a === "down" ? {
171
- row: x.row + 1,
172
- col: x.col
173
- } : a === "up" ? {
174
- row: x.row - 1,
175
- col: x.col
176
- } : a === "right" ? {
177
- row: x.row,
178
- col: x.col + 1
179
- } : a === "left" ? {
180
- row: x.row,
181
- col: Math.max(x.col - 1, s(c))
182
- } : x, C = c[x.col], w = p.getSourceIndex(x.row), T = h ? p.getRow(x.row) : m[w];
183
- if (!C || !T) return _(e.stopEdit()), { status: "noop" };
184
- if (!r({
185
- readOnly: i.readOnly,
186
- canEditCell: i.canEditCell
187
- }, p, x.row, x.col, T, C)) return y.current = !0, _(e.stopEdit()), j(null), { status: "noop" };
188
- let E = l(C, t(T, C), n);
189
- if (!E && h) {
190
- let e = u(C, n, T), t = f(C, T, e, i.localeTexts);
191
- if (t.action === "reject") return {
192
- status: "rejected",
193
- message: t.message
194
- };
195
- h([{
196
- viewIndex: x.row,
197
- column: C,
198
- value: e
199
- }]);
200
- } else if (!E && g) {
201
- let e = u(C, n, T), t = f(C, T, e, i.localeTexts);
202
- if (t.action === "reject") return {
203
- status: "rejected",
204
- message: t.message
205
- };
206
- g(d(m, w, C, e));
237
+ update: D,
238
+ activateSingleCell: A,
239
+ startEditWithValue: j,
240
+ commitEdit: F,
241
+ cancelEdit: I,
242
+ registerDraftFlush: L,
243
+ endEditLeftOpen: () => {
244
+ let t = i;
245
+ if (t === null || t.editorActionGuardRef.current) return;
246
+ let n = p(t).editingCell;
247
+ if (n === null || t.visibleColumns[n.col]?.editor?.type !== "custom") return;
248
+ let r = o ?? T(t, n), a = C;
249
+ if (r !== null && a !== null) {
250
+ let e = {
251
+ ...r,
252
+ cell: n
253
+ }, t = !1;
254
+ a((n) => t || i === null ? { status: "noop" } : (t = !0, R(i, e, n)));
207
255
  }
208
- y.current = !0;
209
- let O = M(), k;
210
- if (i.followsRow === !0) {
211
- let e = A(p, S.row, x.row);
212
- (p.getRow(e) != null || p.getLabelRow?.(e) !== void 0) && (k = p.getRowKey(e));
213
- }
214
- return j(S, a === void 0 ? {
215
- activeCell: o.activeCell,
216
- selection: o.selection
217
- } : null, x.row, O, k), _(e.stopEdit()), { status: "committed" };
218
- },
219
- cancelEdit: () => {
220
- if (i === null || i.editorActionGuardRef.current) return;
221
- y = !0, v = null, i.editorActionGuardRef.current = !0;
222
- let t = M();
223
- i.dispatch(e.stopEdit()), j(null, null, void 0, t);
256
+ t.editorActionGuardRef.current = !0, t.dispatch(e.stopEdit()), N(null);
224
257
  },
225
- registerDraftFlush: (e) => {
226
- x = e;
258
+ registerLateCommitReceiver: (e) => (C = e, () => {
259
+ C === e && (C = null);
260
+ }),
261
+ dispose: () => {
262
+ i = null, C = null;
227
263
  }
228
264
  };
229
265
  };
230
266
  //#endregion
231
- export { _ as createEditController };
267
+ export { v as createEditController };
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../model/gridActions.cjs"),t=require("../logic/sorting.cjs"),n=require("../logic/detailRow.cjs"),r=require("../logic/geometry.cjs"),i=require("./liveUiState.cjs"),a=require("../logic/autoScrollGeometry.cjs"),o=require("../logic/elementScale.cjs"),s=require("../logic/verticalGeometry.cjs");var c=10,l=300,u=()=>{let c=null,l=!1,u=!1,d=null,f=null,p=`mouse`,m=null,h=null,g=!1,_=!1,v=()=>c===null?null:i.readLiveUiState(c).dragState??null,y=null,b=e=>{let t=c?.footerHeight??0,n=c?.stickyTopHeight??0,r=c?.scrollContainerRef.current??null;if(t<=0&&n<=0||!r)return e;let i=r.getBoundingClientRect(),s=o.resolveElementScale(r,i);return a.clampClientYBelowHeader(a.clampClientYAboveFooter(e,i.top+(r.clientTop+r.clientHeight)*s.y,t*s.y),i.top+r.clientTop*s.y,n*s.y)},x=(e,t)=>{if(c===null)return null;let{bodyScrollRef:n,scrollContainerRef:i,leftPaneScrollRef:a,rightPaneScrollRef:l,filteredRowsLength:u,visibleColumnsLength:d,paneLayout:f,leftLeadingWidth:p,centerLeadingWidth:m,rightLeadingWidth:h,headerHeight:g,rowMetrics:_,verticalScaleFactor:v}=c,y=n.current;if(!y||u===0||d===0)return null;let x=y.getBoundingClientRect(),S=o.resolveElementScale(y,x),C=s.clientYToRowIndex(y.scrollTop+(b(t)-x.top)/S.y-g,i.current?.scrollTop??0,v,_),w=null,T=a.current;if(w===null&&T&&f.left.entries.length>0){let t=T.getBoundingClientRect();if(e<t.right){let n=(e-t.left)/S.x-p;w=r.findLogicalIndexFromPaneOffset(f.left,n)}}let E=l.current;if(w===null&&E&&f.right.entries.length>0){let t=E.getBoundingClientRect();if(e>=t.left){let n=(e-t.left)/S.x-h;w=r.findLogicalIndexFromPaneOffset(f.right,n)}}if(w===null&&f.center.entries.length>0){let t=T&&f.left.entries.length===0?Math.max(e,T.getBoundingClientRect().left+p*S.x):e,n=y.scrollLeft+(t-x.left)/S.x-m;w=r.findLogicalIndexFromPaneOffset(f.center,Math.max(n,0))}return w===null?null:{row:C,col:r.clamp(w,0,d-1)}},S=(t,n)=>{let r=v();if(c===null||!r||r.type!==`selection`)return;let i=x(t,n);if(i){if(r.selectionKind===`cell`){c.dispatch(e.gridActions.updateSelection(i));return}if(r.selectionKind===`row`){c.dispatch(e.gridActions.updateRowSelection(i.row));return}r.selectionKind===`col`&&c.dispatch(e.gridActions.updateColumnSelection(i.col))}},C=(t,n)=>{let r=n.timeStamp;if(c===null)return;let{gridRootRef:i,dispatch:a,enableRangeSelection:o,enableRowSelection:s,onGutterRowSelect:l,onCellDoubleClickRef:u,resolveFirstDataCell:d}=c;i.current?.focus({preventScroll:!0});let{target:p}=t;if(p.kind===`cell`){let t=f;if(t&&t.cell.row===p.cell.row&&t.cell.col===p.cell.col&&r-t.time<300){f=null,u.current(p.cell,n);return}f={cell:p.cell,time:r},a(e.gridActions.activateCell(p.cell)),o&&(a(e.gridActions.startSelection(p.cell)),a(e.gridActions.endSelection()));return}if(f=null,p.kind===`row`){if(s){l(p.rowIndex,{shiftKey:!1});return}a(e.gridActions.startRowSelection(p.rowIndex,d?.().col)),a(e.gridActions.endSelection());return}a(e.gridActions.startColumnSelection(p.colIndex,d?.().row)),a(e.gridActions.endSelection())},w=()=>{c!==null&&(u=!1,c.dispatch(e.gridActions.endSelection()),c.dispatch(e.gridActions.endColumnResize()))},T=t=>{if(c===null)return;c.pointerClientRef.current={x:t.clientX,y:t.clientY};let n=v();if(n?.type===`columnResize`){(y===null||y.drag!==n)&&(y={drag:n,x:o.resolveElementScale(c.scrollContainerRef.current).x});let r=y.x===1?t.clientX:n.startX+(t.clientX-n.startX)/y.x;c.dispatch(e.gridActions.updateColumnResize(r))}},E=e=>{let t=d;t&&(d=null,e.pointerId===t.pointerId&&Math.abs(e.clientX-t.x)<10&&Math.abs(e.clientY-t.y)<10&&C(t,e)),w()},D=()=>{d=null,w()},O=()=>{l||(l=!0,window.addEventListener(`pointermove`,T),window.addEventListener(`pointerup`,E),window.addEventListener(`pointercancel`,D))},k=()=>{l&&(l=!1,window.removeEventListener(`pointermove`,T),window.removeEventListener(`pointerup`,E),window.removeEventListener(`pointercancel`,D))},A=()=>{_=!1,c!==null&&c.autoScrollFrameRef.current!==null&&(cancelAnimationFrame(c.autoScrollFrameRef.current),c.autoScrollFrameRef.current=null)},j=()=>{if(c===null||!_)return;let{scrollContainerRef:e,pointerClientRef:t,autoScrollFrameRef:n}=c,r=e.current,i=t.current;if(!r||!i){n.current=requestAnimationFrame(j);return}if(!g){let e=h;if(e&&!a.hasPointerLeftActivationRadius(e,i,6)){n.current=requestAnimationFrame(j);return}g=!0}let s=r.getBoundingClientRect(),l=o.resolveElementScale(r,s),u=a.resolveScrollContentBox({rectLeft:s.left,rectTop:s.top,clientLeft:r.clientLeft,clientTop:r.clientTop,clientWidth:r.clientWidth,clientHeight:r.clientHeight,scale:l}),d=v(),f=d?.type===`selection`&&d.selectionKind===`col`,p=d?.type===`selection`&&d.selectionKind===`row`,m=f?0:a.resolveAutoScrollAxisDirection(i.y,a.resolveTopAutoScrollStart(u.top,(c.stickyTopHeight??0)*l.y,24),u.bottom-(c.footerHeight??0),24),y=p?0:a.resolveAutoScrollAxisDirection(i.x,u.left,u.right,24),b=a.computeNextScrollPosition(r.scrollTop,m,18,r.scrollHeight-r.clientHeight),x=a.computeNextScrollPosition(r.scrollLeft,y,18,r.scrollWidth-r.clientWidth);(b!==r.scrollTop||x!==r.scrollLeft)&&(r.scrollTo({top:b,left:x,behavior:`auto`}),S(i.x,i.y)),n.current=requestAnimationFrame(j)},M=()=>{let e=v()?.type===`selection`;e&&!_?(_=!0,c!==null&&(c.autoScrollFrameRef.current=requestAnimationFrame(j))):!e&&_&&A()},N=()=>{if(m!==null)return;let e=()=>{if(!u||c===null){m=null;return}let{scrollContainerRef:t,pointerClientRef:n,onGutterRowSelectDrag:r}=c,i=t.current,s=n.current;if(!i||!s){m=requestAnimationFrame(e);return}if(!g){let t=h;if(t&&!a.hasPointerLeftActivationRadius(t,s,6)){m=requestAnimationFrame(e);return}g=!0}let l=i.getBoundingClientRect(),d=o.resolveElementScale(i,l),f=a.resolveScrollContentBox({rectLeft:l.left,rectTop:l.top,clientLeft:i.clientLeft,clientTop:i.clientTop,clientWidth:i.clientWidth,clientHeight:i.clientHeight,scale:d}),p=a.resolveAutoScrollAxisDirection(s.y,a.resolveTopAutoScrollStart(f.top,(c.stickyTopHeight??0)*d.y,24),f.bottom-(c.footerHeight??0),24),_=a.computeNextScrollPosition(i.scrollTop,p,18,i.scrollHeight-i.clientHeight);if(_!==i.scrollTop){i.scrollTo({top:_,left:i.scrollLeft,behavior:`auto`});let e=x(s.x,s.y);e&&r(e.row)}m=requestAnimationFrame(e)};m=requestAnimationFrame(e)},P=(e,t)=>(e.preventDefault(),c===null||e.button!==0?!1:(p=e.pointerType,e.pointerType===`touch`?(d={pointerId:e.pointerId,x:e.clientX,y:e.clientY,target:t},!1):(c.gridRootRef.current?.focus({preventScroll:!0}),c.pointerClientRef.current={x:e.clientX,y:e.clientY},h={x:e.clientX,y:e.clientY},g=!1,!0)));return{update:e=>{c=e,O(),M()},getCellCoordFromClientPoint:x,updateSelectionFromPointer:S,handleCellPointerDown:(t,n)=>{if(!(!P(n,{kind:`cell`,cell:t})||c===null)){if(n.shiftKey&&c.enableRangeSelection){let{selection:n,activeCell:r}=i.readLiveUiState(c),a=n?.type===`cell`?n.range.start:r;if(a){c.dispatch(e.gridActions.startSelection(a)),c.dispatch(e.gridActions.updateSelection(t));return}}c.dispatch(e.gridActions.activateCell(t)),c.enableRangeSelection&&c.dispatch(e.gridActions.startSelection(t))}},handleCellDoubleClick:(e,t)=>{p===`touch`||c===null||c.onCellDoubleClickRef.current(e,t)},handleCellPointerEnter:(t,n)=>{if(c===null||(c.enableRowHover&&c.setHoveredRowIndex(t.row),c.enableColumnHover&&c.setHoveredColumnIndex(t.col),!c.enableRangeSelection))return;let r=v();r?.type!==`selection`||r.selectionKind!==`cell`||(c.pointerClientRef.current={x:n.clientX,y:n.clientY},c.dispatch(e.gridActions.updateSelection(t)))},handleNativeDragStart:e=>{e.preventDefault()},handleRowHeaderPointerDown:(t,n)=>{if(!(!P(n,{kind:`row`,rowIndex:t})||c===null)){if(c.enableRowSelection){u=!0,c.onGutterRowSelect(t,{shiftKey:n.shiftKey}),N();return}if(n.shiftKey){let{selection:n,activeCell:r}=i.readLiveUiState(c),a=n?.type===`row`?n.startRow:r?.row;if(a!==void 0){c.dispatch(e.gridActions.startRowSelection(a,c.resolveFirstDataCell?.().col)),c.dispatch(e.gridActions.updateRowSelection(t));return}}c.dispatch(e.gridActions.startRowSelection(t,c.resolveFirstDataCell?.().col))}},handleRowHeaderPointerEnter:(t,n)=>{if(c===null)return;if(c.enableRowHover&&c.setHoveredRowIndex(t),u){c.pointerClientRef.current={x:n.clientX,y:n.clientY},c.onGutterRowSelectDrag(t);return}let r=v();r?.type!==`selection`||r.selectionKind!==`row`||(c.pointerClientRef.current={x:n.clientX,y:n.clientY},c.dispatch(e.gridActions.updateRowSelection(t)))},handleColumnHeaderPointerDown:(r,a)=>{if(!(!P(a,{kind:`col`,colIndex:r})||c===null)){if(a.shiftKey&&c.enableSorting){let a=c.orderedColumns[r];if(a&&!n.isSyntheticColumnKey(a.key)){let n=i.readLiveUiState(c).sort,r=n.find(e=>e.columnKey===a.key)?.direction?`desc`:`asc`,o=t.nextSortEntries(n,a.key,r,!0);c.dispatch(o.length===0?e.gridActions.clearSort():e.gridActions.setSort(o))}return}c.dispatch(e.gridActions.startColumnSelection(r,c.resolveFirstDataCell?.().row))}},handleColumnHeaderPointerEnter:(t,n)=>{if(c===null)return;c.setHoveredRowIndex(null),c.enableColumnHeaderHover&&c.setHoveredColumnIndex(t);let r=v();r?.type!==`selection`||r.selectionKind!==`col`||(c.pointerClientRef.current={x:n.clientX,y:n.clientY},c.dispatch(e.gridActions.updateColumnSelection(t)))},dispose:()=>{k(),A(),m!==null&&(cancelAnimationFrame(m),m=null)}}};exports.TOUCH_DOUBLE_TAP_MS=l,exports.TOUCH_TAP_SLOP_PX=c,exports.createPointerInteractionsController=u;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../model/gridActions.cjs"),t=require("../logic/sorting.cjs"),n=require("../logic/detailRow.cjs"),r=require("../logic/geometry.cjs"),i=require("./liveUiState.cjs"),a=require("../logic/autoScrollGeometry.cjs"),o=require("../logic/elementScale.cjs"),s=require("../logic/verticalGeometry.cjs");var c=10,l=300,u=()=>{let c=null,l=!1,u=!1,d=null,f=null,p=`mouse`,m=null,h=null,g=!1,_=!1,v=()=>c===null?null:i.readLiveUiState(c).dragState??null,y=null,b=e=>{let t=c?.footerHeight??0,n=c?.stickyTopHeight??0,r=c?.scrollContainerRef.current??null;if(t<=0&&n<=0||!r)return e;let i=r.getBoundingClientRect(),s=o.resolveElementScale(r,i);return a.clampClientYBelowHeader(a.clampClientYAboveFooter(e,i.top+(r.clientTop+r.clientHeight)*s.y,t*s.y),i.top+r.clientTop*s.y,n*s.y)},x=(e,t)=>{if(c===null)return null;let{bodyScrollRef:n,scrollContainerRef:i,leftPaneScrollRef:a,rightPaneScrollRef:l,filteredRowsLength:u,visibleColumnsLength:d,paneLayout:f,leftLeadingWidth:p,centerLeadingWidth:m,rightLeadingWidth:h,headerHeight:g,rowMetrics:_,verticalScaleFactor:v}=c,y=n.current;if(!y||u===0||d===0)return null;let x=y.getBoundingClientRect(),S=o.resolveElementScale(y,x),C=s.clientYToRowIndex(y.scrollTop+(b(t)-x.top)/S.y-g,i.current?.scrollTop??0,v,_),w=null,T=a.current;if(w===null&&T&&f.left.entries.length>0){let t=T.getBoundingClientRect();if(e<t.right){let n=(e-t.left)/S.x-p;w=r.findLogicalIndexFromPaneOffset(f.left,n)}}let E=l.current;if(w===null&&E&&f.right.entries.length>0){let t=E.getBoundingClientRect();if(e>=t.left){let n=(e-t.left)/S.x-h;w=r.findLogicalIndexFromPaneOffset(f.right,n)}}if(w===null&&f.center.entries.length>0){let t=T&&f.left.entries.length===0?Math.max(e,T.getBoundingClientRect().left+p*S.x):e,n=y.scrollLeft+(t-x.left)/S.x-m;w=r.findLogicalIndexFromPaneOffset(f.center,Math.max(n,0))}return w===null?null:{row:C,col:r.clamp(w,0,d-1)}},S=(t,n)=>{let r=v();if(c===null||!r||r.type!==`selection`)return;let i=x(t,n);if(i){if(r.selectionKind===`cell`){c.dispatch(e.gridActions.updateSelection(i));return}if(r.selectionKind===`row`){c.dispatch(e.gridActions.updateRowSelection(i.row));return}r.selectionKind===`col`&&c.dispatch(e.gridActions.updateColumnSelection(i.col))}},C=(t,n)=>{let r=n.timeStamp;if(c===null)return;let{gridRootRef:i,dispatch:a,enableRangeSelection:o,enableRowSelection:s,onGutterRowSelect:l,onCellDoubleClickRef:u,resolveFirstDataCell:d}=c;i.current?.focus({preventScroll:!0}),c.endEditLeftOpen?.();let{target:p}=t;if(p.kind===`cell`){let t=f;if(t&&t.cell.row===p.cell.row&&t.cell.col===p.cell.col&&r-t.time<300){f=null,u.current(p.cell,n);return}f={cell:p.cell,time:r},a(e.gridActions.activateCell(p.cell)),o&&(a(e.gridActions.startSelection(p.cell)),a(e.gridActions.endSelection()));return}if(f=null,p.kind===`row`){if(s){l(p.rowIndex,{shiftKey:!1});return}a(e.gridActions.startRowSelection(p.rowIndex,d?.().col)),a(e.gridActions.endSelection());return}a(e.gridActions.startColumnSelection(p.colIndex,d?.().row)),a(e.gridActions.endSelection())},w=()=>{c!==null&&(u=!1,c.dispatch(e.gridActions.endSelection()),c.dispatch(e.gridActions.endColumnResize()))},T=t=>{if(c===null)return;c.pointerClientRef.current={x:t.clientX,y:t.clientY};let n=v();if(n?.type===`columnResize`){(y===null||y.drag!==n)&&(y={drag:n,x:o.resolveElementScale(c.scrollContainerRef.current).x});let r=y.x===1?t.clientX:n.startX+(t.clientX-n.startX)/y.x;c.dispatch(e.gridActions.updateColumnResize(r))}},E=e=>{let t=d;t&&(d=null,e.pointerId===t.pointerId&&Math.abs(e.clientX-t.x)<10&&Math.abs(e.clientY-t.y)<10&&C(t,e)),w()},D=()=>{d=null,w()},O=()=>{l||(l=!0,window.addEventListener(`pointermove`,T),window.addEventListener(`pointerup`,E),window.addEventListener(`pointercancel`,D))},k=()=>{l&&(l=!1,window.removeEventListener(`pointermove`,T),window.removeEventListener(`pointerup`,E),window.removeEventListener(`pointercancel`,D))},A=()=>{_=!1,c!==null&&c.autoScrollFrameRef.current!==null&&(cancelAnimationFrame(c.autoScrollFrameRef.current),c.autoScrollFrameRef.current=null)},j=()=>{if(c===null||!_)return;let{scrollContainerRef:e,pointerClientRef:t,autoScrollFrameRef:n}=c,r=e.current,i=t.current;if(!r||!i){n.current=requestAnimationFrame(j);return}if(!g){let e=h;if(e&&!a.hasPointerLeftActivationRadius(e,i,6)){n.current=requestAnimationFrame(j);return}g=!0}let s=r.getBoundingClientRect(),l=o.resolveElementScale(r,s),u=a.resolveScrollContentBox({rectLeft:s.left,rectTop:s.top,clientLeft:r.clientLeft,clientTop:r.clientTop,clientWidth:r.clientWidth,clientHeight:r.clientHeight,scale:l}),d=v(),f=d?.type===`selection`&&d.selectionKind===`col`,p=d?.type===`selection`&&d.selectionKind===`row`,m=f?0:a.resolveAutoScrollAxisDirection(i.y,a.resolveTopAutoScrollStart(u.top,(c.stickyTopHeight??0)*l.y,24),u.bottom-(c.footerHeight??0),24),y=p?0:a.resolveAutoScrollAxisDirection(i.x,u.left,u.right,24),b=a.computeNextScrollPosition(r.scrollTop,m,18,r.scrollHeight-r.clientHeight),x=a.computeNextScrollPosition(r.scrollLeft,y,18,r.scrollWidth-r.clientWidth);(b!==r.scrollTop||x!==r.scrollLeft)&&(r.scrollTo({top:b,left:x,behavior:`auto`}),S(i.x,i.y)),n.current=requestAnimationFrame(j)},M=()=>{let e=v()?.type===`selection`;e&&!_?(_=!0,c!==null&&(c.autoScrollFrameRef.current=requestAnimationFrame(j))):!e&&_&&A()},N=()=>{if(m!==null)return;let e=()=>{if(!u||c===null){m=null;return}let{scrollContainerRef:t,pointerClientRef:n,onGutterRowSelectDrag:r}=c,i=t.current,s=n.current;if(!i||!s){m=requestAnimationFrame(e);return}if(!g){let t=h;if(t&&!a.hasPointerLeftActivationRadius(t,s,6)){m=requestAnimationFrame(e);return}g=!0}let l=i.getBoundingClientRect(),d=o.resolveElementScale(i,l),f=a.resolveScrollContentBox({rectLeft:l.left,rectTop:l.top,clientLeft:i.clientLeft,clientTop:i.clientTop,clientWidth:i.clientWidth,clientHeight:i.clientHeight,scale:d}),p=a.resolveAutoScrollAxisDirection(s.y,a.resolveTopAutoScrollStart(f.top,(c.stickyTopHeight??0)*d.y,24),f.bottom-(c.footerHeight??0),24),_=a.computeNextScrollPosition(i.scrollTop,p,18,i.scrollHeight-i.clientHeight);if(_!==i.scrollTop){i.scrollTo({top:_,left:i.scrollLeft,behavior:`auto`});let e=x(s.x,s.y);e&&r(e.row)}m=requestAnimationFrame(e)};m=requestAnimationFrame(e)},P=(e,t)=>{if(e.preventDefault(),c===null||e.button!==0)return!1;let n=i.readLiveUiState(c).editingCell;return t.kind===`cell`&&n!==null&&n.row===t.cell.row&&n.col===t.cell.col&&c.orderedColumns[n.col]?.editor?.type===`custom`?!1:(p=e.pointerType,e.pointerType===`touch`?(d={pointerId:e.pointerId,x:e.clientX,y:e.clientY,target:t},!1):(c.gridRootRef.current?.focus({preventScroll:!0}),c.endEditLeftOpen?.(),c.pointerClientRef.current={x:e.clientX,y:e.clientY},h={x:e.clientX,y:e.clientY},g=!1,!0))};return{update:e=>{c=e,O(),M()},getCellCoordFromClientPoint:x,updateSelectionFromPointer:S,handleCellPointerDown:(t,n)=>{if(!(!P(n,{kind:`cell`,cell:t})||c===null)){if(n.shiftKey&&c.enableRangeSelection){let{selection:n,activeCell:r}=i.readLiveUiState(c),a=n?.type===`cell`?n.range.start:r;if(a){c.dispatch(e.gridActions.startSelection(a)),c.dispatch(e.gridActions.updateSelection(t));return}}c.dispatch(e.gridActions.activateCell(t)),c.enableRangeSelection&&c.dispatch(e.gridActions.startSelection(t))}},handleCellDoubleClick:(e,t)=>{p===`touch`||c===null||c.onCellDoubleClickRef.current(e,t)},handleCellPointerEnter:(t,n)=>{if(c===null||(c.enableRowHover&&c.setHoveredRowIndex(t.row),c.enableColumnHover&&c.setHoveredColumnIndex(t.col),!c.enableRangeSelection))return;let r=v();r?.type!==`selection`||r.selectionKind!==`cell`||(c.pointerClientRef.current={x:n.clientX,y:n.clientY},c.dispatch(e.gridActions.updateSelection(t)))},handleNativeDragStart:e=>{e.preventDefault()},handleRowHeaderPointerDown:(t,n)=>{if(!(!P(n,{kind:`row`,rowIndex:t})||c===null)){if(c.enableRowSelection){u=!0,c.onGutterRowSelect(t,{shiftKey:n.shiftKey}),N();return}if(n.shiftKey){let{selection:n,activeCell:r}=i.readLiveUiState(c),a=n?.type===`row`?n.startRow:r?.row;if(a!==void 0){c.dispatch(e.gridActions.startRowSelection(a,c.resolveFirstDataCell?.().col)),c.dispatch(e.gridActions.updateRowSelection(t));return}}c.dispatch(e.gridActions.startRowSelection(t,c.resolveFirstDataCell?.().col))}},handleRowHeaderPointerEnter:(t,n)=>{if(c===null)return;if(c.enableRowHover&&c.setHoveredRowIndex(t),u){c.pointerClientRef.current={x:n.clientX,y:n.clientY},c.onGutterRowSelectDrag(t);return}let r=v();r?.type!==`selection`||r.selectionKind!==`row`||(c.pointerClientRef.current={x:n.clientX,y:n.clientY},c.dispatch(e.gridActions.updateRowSelection(t)))},handleColumnHeaderPointerDown:(r,a)=>{if(!(!P(a,{kind:`col`,colIndex:r})||c===null)){if(a.shiftKey&&c.enableSorting){let a=c.orderedColumns[r];if(a&&!n.isSyntheticColumnKey(a.key)){let n=i.readLiveUiState(c).sort,r=n.find(e=>e.columnKey===a.key)?.direction?`desc`:`asc`,o=t.nextSortEntries(n,a.key,r,!0);c.dispatch(o.length===0?e.gridActions.clearSort():e.gridActions.setSort(o))}return}c.dispatch(e.gridActions.startColumnSelection(r,c.resolveFirstDataCell?.().row))}},handleColumnHeaderPointerEnter:(t,n)=>{if(c===null)return;c.setHoveredRowIndex(null),c.enableColumnHeaderHover&&c.setHoveredColumnIndex(t);let r=v();r?.type!==`selection`||r.selectionKind!==`col`||(c.pointerClientRef.current={x:n.clientX,y:n.clientY},c.dispatch(e.gridActions.updateColumnSelection(t)))},dispose:()=>{k(),A(),m!==null&&(cancelAnimationFrame(m),m=null)}}};exports.TOUCH_DOUBLE_TAP_MS=l,exports.TOUCH_TAP_SLOP_PX=c,exports.createPointerInteractionsController=u;
@@ -59,6 +59,7 @@ export type PointerInteractionsArgs<T> = {
59
59
  }) => void;
60
60
  onGutterRowSelectDrag: (viewIndex: number) => void;
61
61
  onCellDoubleClickRef: ReadonlyRef<(cell: CellCoord, event: MouseEvent) => void>;
62
+ endEditLeftOpen?: (() => void) | undefined;
62
63
  };
63
64
  export type PointerInteractionsController<T> = {
64
65
  update: (args: PointerInteractionsArgs<T>) => void;
@@ -60,7 +60,7 @@ var h = 10, g = 300, _ = () => {
60
60
  let r = n.timeStamp;
61
61
  if (h === null) return;
62
62
  let { gridRootRef: i, dispatch: a, enableRangeSelection: o, enableRowSelection: s, onGutterRowSelect: c, onCellDoubleClickRef: l, resolveFirstDataCell: u } = h;
63
- i.current?.focus({ preventScroll: !0 });
63
+ i.current?.focus({ preventScroll: !0 }), h.endEditLeftOpen?.();
64
64
  let { target: d } = t;
65
65
  if (d.kind === "cell") {
66
66
  let t = y;
@@ -184,18 +184,22 @@ var h = 10, g = 300, _ = () => {
184
184
  x = requestAnimationFrame(e);
185
185
  };
186
186
  x = requestAnimationFrame(e);
187
- }, V = (e, t) => (e.preventDefault(), h === null || e.button !== 0 ? !1 : (b = e.pointerType, e.pointerType === "touch" ? (v = {
188
- pointerId: e.pointerId,
189
- x: e.clientX,
190
- y: e.clientY,
191
- target: t
192
- }, !1) : (h.gridRootRef.current?.focus({ preventScroll: !0 }), h.pointerClientRef.current = {
193
- x: e.clientX,
194
- y: e.clientY
195
- }, S = {
196
- x: e.clientX,
197
- y: e.clientY
198
- }, C = !1, !0)));
187
+ }, V = (e, t) => {
188
+ if (e.preventDefault(), h === null || e.button !== 0) return !1;
189
+ let n = a(h).editingCell;
190
+ return t.kind === "cell" && n !== null && n.row === t.cell.row && n.col === t.cell.col && h.orderedColumns[n.col]?.editor?.type === "custom" ? !1 : (b = e.pointerType, e.pointerType === "touch" ? (v = {
191
+ pointerId: e.pointerId,
192
+ x: e.clientX,
193
+ y: e.clientY,
194
+ target: t
195
+ }, !1) : (h.gridRootRef.current?.focus({ preventScroll: !0 }), h.endEditLeftOpen?.(), h.pointerClientRef.current = {
196
+ x: e.clientX,
197
+ y: e.clientY
198
+ }, S = {
199
+ x: e.clientX,
200
+ y: e.clientY
201
+ }, C = !1, !0));
202
+ };
199
203
  return {
200
204
  update: (e) => {
201
205
  h = e, F(), z();
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../logic/rowReorder.cjs"),t=require("../logic/detailRow.cjs"),n=require("../logic/autoScrollGeometry.cjs"),r=require("../logic/elementScale.cjs"),i=require("./escapeClaimController.cjs"),a=require("../logic/slotDom.cjs"),o=require("../utils/portalTokens.cjs"),s=require("../utils/popupContainer.cjs");var c=14,l=12,u=`0.5`,d=`<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="8 6 12 2 16 6"/><polyline points="16 18 12 22 8 18"/><line x1="12" y1="2" x2="12" y2="22"/></svg>`,f=`<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><line x1="4.9" y1="4.9" x2="19.1" y2="19.1"/></svg>`,p=200,m=`cubic-bezier(0.2, 0.7, 0.3, 1)`,h=`transform 160ms ${m}`,g=`data-ssg-row-dragging`,_=e=>e?.closest(`.ssg-motion-off`)!=null,v=/translateY\((-?[\d.]+)px\)/,y=e=>{let n=[];return e.querySelectorAll(`.ssg-body-row[data-row-index]`).forEach(r=>{t.isInsideDetailCardOf(e,r)||n.push(r)}),n},b=e=>{let n=[],r=new Map;return e.querySelectorAll(`.ssg-detail-band[data-detail-row-index]`).forEach(i=>{if(t.isInsideDetailCardOf(e,i))return;let a=Number(i.getAttribute(`data-detail-row-index`)),o=r.get(a)??0;r.set(a,o+1),n.push({el:i,index:a,key:`band|${o}|${a}`})}),n},x=e=>{e.style.transition=``,e.style.transform=``,e.style.willChange=``,e.style.zIndex=``},S=()=>{let S=null,C=null,w=null,T=null,E=(e,t)=>{let n=S?.canDropAt;if(!n)return!0;if(T!==null&&T.from===e&&T.slot===t)return T.allowed;let r=n(e,t);return T={from:e,slot:t,allowed:r},r},D={x:0,y:0},O=null,k=!1,A=null,j=null,M=null,N=null,P=null,F=null,I=0,L=null,R=()=>S?.motion===`live`,z=null,B=null,V=null,H=()=>[S?.leftIndicatorRef.current??null,S?.centerIndicatorRef.current??null,S?.rightIndicatorRef.current??null],U=()=>{for(let e of H())e&&(e.style.display=`none`)},W=e=>{if(z)return;let t=document.createElement(`div`);t.setAttribute(`data-grid-drag-ghost`,``),S?.scrollContainerRef.current?.closest(`.ssg-theme-dark`)!=null&&t.classList.add(`ssg-theme-dark`),S?.scrollContainerRef.current?.closest(`.ssg-theme-class`)!=null&&t.classList.add(`ssg-theme-class`),S?.scrollContainerRef.current?.closest(`.ssg-motion-off`)!=null&&t.classList.add(`ssg-motion-off`),t.style.cssText=[`position:fixed`,`top:0`,`left:0`,`display:inline-flex`,`align-items:center`,`gap:7px`,`padding:7px 12px 7px 10px`,`border-radius:9px`,`border:1px solid var(--ssg-ghost-border)`,`background:var(--ssg-ghost-bg)`,`color:var(--ssg-ghost-text)`,`font-size:12px`,`font-weight:600`,`line-height:1`,`white-space:nowrap`,`max-width:280px`,`overflow:hidden`,`text-overflow:ellipsis`,`box-shadow:var(--ssg-ghost-shadow)`,`pointer-events:none`,`user-select:none`,`z-index:9999`,`will-change:transform`,`transform:translate(-9999px,-9999px)`].join(`;`),a.applySlotToElement(t,S?.ghostSlot);let n=document.createElement(`span`);n.style.cssText=`display:inline-flex;align-items:center;justify-content:center;width:14px;height:14px;flex:none`;let r=document.createElement(`span`);r.style.cssText=`overflow:hidden;text-overflow:ellipsis`,r.textContent=e,t.appendChild(n),t.appendChild(r),s.appendToPopupContainer(t,s.getPopupContainerFor(S?.scrollContainerRef.current)),o.syncPortalTokens(S?.scrollContainerRef.current,t),z=t,B=n,V=null},G=e=>{let t=z;if(!t)return;t.style.transform=`translate(`+(D.x+c)+`px,`+(D.y+l)+`px)`;let n=e?`move`:`out`;if(V===n)return;V=n;let r=B;n===`out`?(t.style.opacity=u,r&&(r.innerHTML=f)):(t.style.opacity=`1`,r&&(r.innerHTML=d))},K=()=>{z&&z.parentNode&&z.parentNode.removeChild(z),z=null,B=null,V=null},q=(e,n)=>{let r=S?.scrollContainerRef.current??null;!r||n&&e===null||r.querySelectorAll(n?`.ssg-body-row[data-row-index="${e}"]`:`.ssg-body-row[${g}]`).forEach(e=>{t.isInsideDetailCardOf(r,e)||(n?e.setAttribute(g,R()?`live`:``):e.removeAttribute(g))})},J=()=>{let e=S?.scrollContainerRef.current??null;if(!e)return null;let t=new Map;for(let n of y(e)){let e=v.exec(n.style.transform);e&&t.set(n,{index:Number(n.getAttribute(`data-row-index`)),baseY:parseFloat(e[1])})}return t},ee=t=>{let n=F,r=C;if(!n||r===null||S===null)return;let i=S.scrollContainerRef.current;if(!i)return;for(let e of y(i)){if(n.has(e))continue;let t=v.exec(e.style.transform);t&&n.set(e,{index:Number(e.getAttribute(`data-row-index`)),baseY:parseFloat(t[1])})}let a=S.rowMetrics.rowsHeight(r,r),o=(i.scrollTop-I)*S.verticalScaleFactor,s=(O?D.y-O.y:0)+o,c=t===null?null:e.resolveMoveTargetIndex(r,t);n.forEach((e,t)=>{let{index:i,baseY:o}=e;if(!t.isConnected){n.delete(t);return}if(i===r){t.style.transition=`none`,t.style.transform=`translateY(${o+s}px)`,t.style.willChange=`transform`,e.applied=t.style.transform;return}let l=0;c!==null&&(r<i&&i<=c?l=-a:c<=i&&i<r&&(l=a)),t.style.transition=h,t.style.transform=`translateY(${o+l}px)`,e.applied=t.style.transform});let l=L??new Set;L=l;for(let{el:e,index:t}of b(i)){if(l.add(e),t===r){e.style.transition=`none`,e.style.transform=`translateY(${s}px)`,e.style.willChange=`transform`,e.style.zIndex=`10`;continue}let n=0;c!==null&&(r<t&&t<=c?n=-a:c<=t&&t<r&&(n=a)),e.style.transition=h,e.style.transform=`translateY(${n}px)`,e.style.zIndex=``}},te=(t,r)=>{if(S===null)return null;let{scrollContainerRef:i,bodyScrollRef:a,rowMetrics:o,headerHeight:s,verticalScaleFactor:c,windowBaseOffsetPx:l}=S,u=i.current,d=a.current;if(!u||!d)return null;let f=u.getBoundingClientRect();if(t<f.left||t>f.right||r<f.top||r>f.bottom)return null;let p=n.clampClientYBelowHeader(n.clampClientYAboveFooter(r,f.top+u.clientTop+u.clientHeight,S.footerHeight??0),f.top+u.clientTop,S.stickyTopHeight??0),m=d.getBoundingClientRect(),h=d.scrollTop+p-m.top-s-u.scrollTop*(1-c),g=e.resolveRowDropSlot(h,o),_=C,v=_!==null&&R()?o.detailHeight(_):0;if(_!==null&&v>0){let t=e.resolveRowDropSlot(h+v,o);t>_+1&&(g=t)}let y=e.resolveRowDropSlotTop(g,o);return{slot:g,top:s+y-l}},Y=()=>{let t=te(D.x,D.y),n=C;if(R()){t&&n!==null&&(e.resolveMoveTargetIndex(n,t.slot)===null?w=null:E(n,t.slot)&&(w=t.slot)),U(),ee(w);return}let r=t!==null&&n!==null&&e.resolveMoveTargetIndex(n,t.slot)!==null&&!E(n,t.slot);if(G(r?null:t),!t||n===null||r||e.resolveMoveTargetIndex(n,t.slot)===null){w=null,U();return}w=t.slot;for(let e of H())e&&(e.style.top=`${t.top}px`,e.style.display=`block`)},X=()=>{if(C===null){M=null;return}let e=S?.scrollContainerRef.current??null;if(e&&(k||(!O||n.hasPointerLeftActivationRadius(O,D,6))&&(k=!0),k)){let t=e.getBoundingClientRect(),i=r.resolveElementScale(e,t),a=n.resolveScrollContentBox({rectLeft:t.left,rectTop:t.top,clientLeft:e.clientLeft,clientTop:e.clientTop,clientWidth:e.clientWidth,clientHeight:e.clientHeight,scale:i}),o=n.resolveAutoScrollAxisDirection(D.y,n.resolveTopAutoScrollStart(a.top,(S?.stickyTopHeight??0)*i.y,24),a.bottom-(S?.footerHeight??0),24),s=n.computeNextScrollPosition(e.scrollTop,o,18,e.scrollHeight-e.clientHeight);s!==e.scrollTop&&e.scrollTo({top:s,behavior:`auto`})}Y(),M=requestAnimationFrame(X)},Z=(e,t)=>`${e.getAttribute(`data-pane`)??``}|${t}`,Q=()=>{let e=S?.scrollContainerRef.current??null;if(!e)return null;let t=new Map;for(let n of y(e))t.set(Z(n,Number(n.getAttribute(`data-row-index`))),n.getBoundingClientRect().top);for(let n of b(e))t.set(n.key,n.el.getBoundingClientRect().top);return t},$=t=>{M!==null&&(cancelAnimationFrame(M),M=null),document.body.style.cursor=``,U(),K();let n=C,r=w,i=P;q(n,!1),C=null,P=null,w=null,O=null,j=null;let a=n===null||r===null?null:e.resolveMoveTargetIndex(n,r),o=a!==null&&n!==null&&r!==null&&t&&!E(n,r)?null:a;T=null;let s=t&&n!==null&&o!==null&&S!==null,c=F;F=null;let l=c&&s&&S!==null&&!_(S.scrollContainerRef.current)?Q():null,u=L;if(L=null,u&&(s?u.forEach(x):(u.forEach(e=>{e.isConnected&&(e.style.transition=h,e.style.transform=`translateY(0px)`,e.style.zIndex=``)}),window.setTimeout(()=>{u.forEach(e=>{L?.has(e)||x(e)})},200))),c)if(s)c.forEach(({baseY:e},t)=>{t.style.transition=``,t.style.willChange=``,t.isConnected&&(t.style.transform=`translateY(${e}px)`)});else{let e=[];c.forEach(({baseY:t},n)=>{n.isConnected&&(n.style.transition=h,n.style.transform=`translateY(${t}px)`,e.push(n))}),window.setTimeout(()=>{for(let t of e)t.style.transition=``,t.style.willChange=``},200)}if(!s||n===null||o===null||S===null)return;let d=l??(_(S.scrollContainerRef.current)?null:Q()),f=d?{tops:d,from:n,to:o,row:i}:null;N=f,S.commitRowMove(n,o),f&&requestAnimationFrame(()=>{N===f&&(N=null)})},ne=()=>{let e=N;if(N=null,!e)return;let t=S?.scrollContainerRef.current??null;if(!t)return;let{tops:n,from:r,to:i}=e;if(S?.locateDragRow&&e.row!==null&&S.locateDragRow(e.row,i)!==i)return;let a=e=>e===i?r:r<i&&e>=r&&e<i?e+1:i<r&&e>i&&e<=r?e-1:e,o=[],s=new Map;y(t).forEach(e=>{let t=n.get(Z(e,a(Number(e.getAttribute(`data-row-index`)))));if(t===void 0)return;let r=t-e.getBoundingClientRect().top;if(Math.abs(r)<.5)return;let i=v.exec(e.style.transform);if(!i)return;let c=parseFloat(i[1]);s.set(e,c),e.style.transition=`none`,e.style.transform=`translateY(${c+r}px)`,e.style.willChange=`transform`,o.push(e)});let c=[];if(b(t).forEach(({el:e,index:t,key:r})=>{let i=a(t),o=n.get(r.slice(0,r.lastIndexOf(`|`)+1)+i);if(o===void 0)return;let s=o-e.getBoundingClientRect().top;Math.abs(s)<.5||(e.style.transition=`none`,e.style.transform=`translateY(${s}px)`,e.style.willChange=`transform`,c.push(e))}),!(o.length===0&&c.length===0)){t.getBoundingClientRect();for(let e of o)e.style.transition=`transform ${p}ms ${m}`,e.style.transform=`translateY(${s.get(e)??0}px)`;for(let e of c)e.style.transition=`transform ${p}ms ${m}`,e.style.transform=`translateY(0px)`;window.setTimeout(()=>{for(let e of o)e.style.transition=``,e.style.willChange=``;for(let e of c)L?.has(e)||x(e)},280)}},re=(e,t)=>{if(S===null||!S.enabled||t.button!==0)return;if(t.stopPropagation(),t.preventDefault(),S.gridRootRef?.current?.focus({preventScroll:!0}),C!==null){if(t.pointerId!==j)return;A?.(),$(!1)}C=e,P=S.getDragRow?.(e)??null,j=t.pointerId,w=null,D={x:t.clientX,y:t.clientY},O={x:t.clientX,y:t.clientY},k=!1,document.body.style.cursor=`grabbing`,R()?(F=J(),I=S.scrollContainerRef.current?.scrollTop??0):W(S.getRowDragLabel(e)),q(e,!0);let n=t.currentTarget,r=t.pointerId;try{n.setPointerCapture(r)}catch{}let a=e=>{e.pointerId===r&&(D={x:e.clientX,y:e.clientY},Y())},o=i.beginEscapeCancelableDrag(),s=()=>{window.removeEventListener(`pointermove`,a),window.removeEventListener(`pointerup`,c),window.removeEventListener(`pointercancel`,l),window.removeEventListener(`keydown`,u,!0),window.removeEventListener(`blur`,d),o(),A=null;try{n.releasePointerCapture(r)}catch{}};function c(e){e.pointerId===r&&(s(),$(!0))}function l(e){e.pointerId===r&&(s(),$(!1))}function u(e){e.key===`Escape`&&(s(),$(!1))}function d(){s(),$(!1)}window.addEventListener(`pointermove`,a),window.addEventListener(`pointerup`,c),window.addEventListener(`pointercancel`,l),window.addEventListener(`keydown`,u,!0),window.addEventListener(`blur`,d),A=s,Y(),M=requestAnimationFrame(X)},ie=e=>{if(C===null||P==null||S?.locateDragRow===void 0)return;let t=S.locateDragRow(P,C);if(F&&F.forEach((e,t)=>{if(!t.isConnected){F?.delete(t);return}let n=Number(t.getAttribute(`data-row-index`));if(n===e.index&&(e.applied===void 0||t.style.transform===e.applied))return;let r=v.exec(t.style.transform);if(!r){F?.delete(t);return}e.index=n,e.baseY=parseFloat(r[1]),e.applied=void 0}),t===null){A?.(),$(!1);return}F&&t!==C&&O!==null&&e!==null&&(O={x:O.x,y:O.y+S.rowMetrics.rowTop(t)-e.rowTop(C)}),t!==C&&(q(null,!1),C=t,q(t,!0)),Y()};return{update:e=>{let t=S;S=e,t?.canDropAt!==e.canDropAt&&(T=null),C!==null&&t!==null&&t.locateDragRow!==e.locateDragRow&&ie(t.rowMetrics)},onRowDragHandlePointerDown:re,applyReorderSettle:ne,dispose:()=>{A?.(),A=null,M!==null&&(cancelAnimationFrame(M),M=null),document.body.style.cursor=``,K(),q(C,!1),C=null,P=null,w=null,T=null,F=null,L?.forEach(x),L=null,N=null}}};exports.createRowDragController=S;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../logic/rowReorder.cjs"),t=require("../logic/detailRow.cjs"),n=require("../logic/autoScrollGeometry.cjs"),r=require("../logic/elementScale.cjs"),i=require("./escapeClaimController.cjs"),a=require("../logic/slotDom.cjs"),o=require("../utils/portalTokens.cjs"),s=require("../utils/popupContainer.cjs");var c=14,l=12,u=`0.5`,d=`<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="8 6 12 2 16 6"/><polyline points="16 18 12 22 8 18"/><line x1="12" y1="2" x2="12" y2="22"/></svg>`,f=`<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><line x1="4.9" y1="4.9" x2="19.1" y2="19.1"/></svg>`,p=200,m=`cubic-bezier(0.2, 0.7, 0.3, 1)`,h=`transform 160ms ${m}`,g=`data-ssg-row-dragging`,_=e=>e?.closest(`.ssg-motion-off`)!=null,v=/translateY\((-?[\d.]+)px\)/,y=e=>{let n=[];return e.querySelectorAll(`.ssg-body-row[data-row-index]`).forEach(r=>{t.isInsideDetailCardOf(e,r)||n.push(r)}),n},b=e=>{let n=[],r=new Map;return e.querySelectorAll(`.ssg-detail-band[data-detail-row-index]`).forEach(i=>{if(t.isInsideDetailCardOf(e,i))return;let a=Number(i.getAttribute(`data-detail-row-index`)),o=r.get(a)??0;r.set(a,o+1),n.push({el:i,index:a,key:`band|${o}|${a}`})}),n},x=e=>{e.style.transition=``,e.style.transform=``,e.style.willChange=``,e.style.zIndex=``},S=()=>{let S=null,C=null,w=null,T=null,E=(e,t)=>{let n=S?.canDropAt;if(!n)return!0;if(T!==null&&T.from===e&&T.slot===t)return T.allowed;let r=n(e,t);return T={from:e,slot:t,allowed:r},r},D={x:0,y:0},O=null,k=!1,A=null,j=null,M=null,N=null,P=null,F=null,I=0,L=null,R=()=>S?.motion===`live`,z=null,B=null,V=null,H=()=>[S?.leftIndicatorRef.current??null,S?.centerIndicatorRef.current??null,S?.rightIndicatorRef.current??null],U=()=>{for(let e of H())e&&(e.style.display=`none`)},W=e=>{if(z)return;let t=document.createElement(`div`);t.setAttribute(`data-grid-drag-ghost`,``),S?.scrollContainerRef.current?.closest(`.ssg-theme-dark`)!=null&&t.classList.add(`ssg-theme-dark`),S?.scrollContainerRef.current?.closest(`.ssg-theme-class`)!=null&&t.classList.add(`ssg-theme-class`),S?.scrollContainerRef.current?.closest(`.ssg-motion-off`)!=null&&t.classList.add(`ssg-motion-off`),t.style.cssText=[`position:fixed`,`top:0`,`left:0`,`display:inline-flex`,`align-items:center`,`gap:7px`,`padding:7px 12px 7px 10px`,`border-radius:9px`,`border:1px solid var(--ssg-ghost-border)`,`background:var(--ssg-ghost-bg)`,`color:var(--ssg-ghost-text)`,`font-size:12px`,`font-weight:600`,`line-height:1`,`white-space:nowrap`,`max-width:280px`,`overflow:hidden`,`text-overflow:ellipsis`,`box-shadow:var(--ssg-ghost-shadow)`,`pointer-events:none`,`user-select:none`,`z-index:9999`,`will-change:transform`,`transform:translate(-9999px,-9999px)`].join(`;`),a.applySlotToElement(t,S?.ghostSlot);let n=document.createElement(`span`);n.style.cssText=`display:inline-flex;align-items:center;justify-content:center;width:14px;height:14px;flex:none`;let r=document.createElement(`span`);r.style.cssText=`overflow:hidden;text-overflow:ellipsis`,r.textContent=e,t.appendChild(n),t.appendChild(r),s.appendToPopupContainer(t,s.getPopupContainerFor(S?.scrollContainerRef.current)),o.syncPortalTokens(S?.scrollContainerRef.current,t),z=t,B=n,V=null},G=e=>{let t=z;if(!t)return;t.style.transform=`translate(`+(D.x+c)+`px,`+(D.y+l)+`px)`;let n=e?`move`:`out`;if(V===n)return;V=n;let r=B;n===`out`?(t.style.opacity=u,r&&(r.innerHTML=f)):(t.style.opacity=`1`,r&&(r.innerHTML=d))},K=()=>{z&&z.parentNode&&z.parentNode.removeChild(z),z=null,B=null,V=null},q=(e,n)=>{let r=S?.scrollContainerRef.current??null;!r||n&&e===null||r.querySelectorAll(n?`.ssg-body-row[data-row-index="${e}"]`:`.ssg-body-row[${g}]`).forEach(e=>{t.isInsideDetailCardOf(r,e)||(n?e.setAttribute(g,R()?`live`:``):e.removeAttribute(g))})},J=()=>{let e=S?.scrollContainerRef.current??null;if(!e)return null;let t=new Map;for(let n of y(e)){let e=v.exec(n.style.transform);e&&t.set(n,{index:Number(n.getAttribute(`data-row-index`)),baseY:parseFloat(e[1])})}return t},ee=t=>{let n=F,r=C;if(!n||r===null||S===null)return;let i=S.scrollContainerRef.current;if(!i)return;for(let e of y(i)){if(n.has(e))continue;let t=v.exec(e.style.transform);t&&n.set(e,{index:Number(e.getAttribute(`data-row-index`)),baseY:parseFloat(t[1])})}let a=S.rowMetrics.rowsHeight(r,r),o=(i.scrollTop-I)*S.verticalScaleFactor,s=(O?D.y-O.y:0)+o,c=t===null?null:e.resolveMoveTargetIndex(r,t);n.forEach((e,t)=>{let{index:i,baseY:o}=e;if(!t.isConnected){n.delete(t);return}if(i===r){t.style.transition=`none`,t.style.transform=`translateY(${o+s}px)`,t.style.willChange=`transform`,e.applied=t.style.transform;return}let l=0;c!==null&&(r<i&&i<=c?l=-a:c<=i&&i<r&&(l=a)),t.style.transition=h,t.style.transform=`translateY(${o+l}px)`,e.applied=t.style.transform});let l=L??new Set;L=l;for(let{el:e,index:t}of b(i)){if(l.add(e),t===r){e.style.transition=`none`,e.style.transform=`translateY(${s}px)`,e.style.willChange=`transform`,e.style.zIndex=`10`;continue}let n=0;c!==null&&(r<t&&t<=c?n=-a:c<=t&&t<r&&(n=a)),e.style.transition=h,e.style.transform=`translateY(${n}px)`,e.style.zIndex=``}},te=(t,r)=>{if(S===null)return null;let{scrollContainerRef:i,bodyScrollRef:a,rowMetrics:o,headerHeight:s,verticalScaleFactor:c,windowBaseOffsetPx:l}=S,u=i.current,d=a.current;if(!u||!d)return null;let f=u.getBoundingClientRect();if(t<f.left||t>f.right||r<f.top||r>f.bottom)return null;let p=n.clampClientYBelowHeader(n.clampClientYAboveFooter(r,f.top+u.clientTop+u.clientHeight,S.footerHeight??0),f.top+u.clientTop,S.stickyTopHeight??0),m=d.getBoundingClientRect(),h=d.scrollTop+p-m.top-s-u.scrollTop*(1-c),g=e.resolveRowDropSlot(h,o),_=C,v=_!==null&&R()?o.detailHeight(_):0;if(_!==null&&v>0){let t=e.resolveRowDropSlot(h+v,o);t>_+1&&(g=t)}let y=e.resolveRowDropSlotTop(g,o);return{slot:g,top:s+y-l}},Y=()=>{let t=te(D.x,D.y),n=C;if(R()){t&&n!==null&&(e.resolveMoveTargetIndex(n,t.slot)===null?w=null:E(n,t.slot)&&(w=t.slot)),U(),ee(w);return}let r=t!==null&&n!==null&&e.resolveMoveTargetIndex(n,t.slot)!==null&&!E(n,t.slot);if(G(r?null:t),!t||n===null||r||e.resolveMoveTargetIndex(n,t.slot)===null){w=null,U();return}w=t.slot;for(let e of H())e&&(e.style.top=`${t.top}px`,e.style.display=`block`)},X=()=>{if(C===null){M=null;return}let e=S?.scrollContainerRef.current??null;if(e&&(k||(!O||n.hasPointerLeftActivationRadius(O,D,6))&&(k=!0),k)){let t=e.getBoundingClientRect(),i=r.resolveElementScale(e,t),a=n.resolveScrollContentBox({rectLeft:t.left,rectTop:t.top,clientLeft:e.clientLeft,clientTop:e.clientTop,clientWidth:e.clientWidth,clientHeight:e.clientHeight,scale:i}),o=n.resolveAutoScrollAxisDirection(D.y,n.resolveTopAutoScrollStart(a.top,(S?.stickyTopHeight??0)*i.y,24),a.bottom-(S?.footerHeight??0),24),s=n.computeNextScrollPosition(e.scrollTop,o,18,e.scrollHeight-e.clientHeight);s!==e.scrollTop&&e.scrollTo({top:s,behavior:`auto`})}Y(),M=requestAnimationFrame(X)},Z=(e,t)=>`${e.getAttribute(`data-pane`)??``}|${t}`,Q=()=>{let e=S?.scrollContainerRef.current??null;if(!e)return null;let t=new Map;for(let n of y(e))t.set(Z(n,Number(n.getAttribute(`data-row-index`))),n.getBoundingClientRect().top);for(let n of b(e))t.set(n.key,n.el.getBoundingClientRect().top);return t},$=t=>{M!==null&&(cancelAnimationFrame(M),M=null),document.body.style.cursor=``,U(),K();let n=C,r=w,i=P;q(n,!1),C=null,P=null,w=null,O=null,j=null;let a=n===null||r===null?null:e.resolveMoveTargetIndex(n,r),o=a!==null&&n!==null&&r!==null&&t&&!E(n,r)?null:a;T=null;let s=t&&n!==null&&o!==null&&S!==null,c=F;F=null;let l=c&&s&&S!==null&&!_(S.scrollContainerRef.current)?Q():null,u=L;if(L=null,u&&(s?u.forEach(x):(u.forEach(e=>{e.isConnected&&(e.style.transition=h,e.style.transform=`translateY(0px)`,e.style.zIndex=``)}),window.setTimeout(()=>{u.forEach(e=>{L?.has(e)||x(e)})},200))),c)if(s)c.forEach(({baseY:e},t)=>{t.style.transition=``,t.style.willChange=``,t.isConnected&&(t.style.transform=`translateY(${e}px)`)});else{let e=[];c.forEach(({baseY:t},n)=>{n.isConnected&&(n.style.transition=h,n.style.transform=`translateY(${t}px)`,e.push(n))}),window.setTimeout(()=>{for(let t of e)t.style.transition=``,t.style.willChange=``},200)}if(!s||n===null||o===null||S===null)return;let d=l??(_(S.scrollContainerRef.current)?null:Q()),f=d?{tops:d,from:n,to:o,row:i}:null;N=f,S.commitRowMove(n,o),f&&requestAnimationFrame(()=>{N===f&&(N=null)})},ne=()=>{let e=N;if(N=null,!e)return;let t=S?.scrollContainerRef.current??null;if(!t)return;let{tops:n,from:r,to:i}=e;if(S?.locateDragRow&&e.row!==null&&S.locateDragRow(e.row,i)!==i)return;let a=e=>e===i?r:r<i&&e>=r&&e<i?e+1:i<r&&e>i&&e<=r?e-1:e,o=[],s=new Map;y(t).forEach(e=>{let t=n.get(Z(e,a(Number(e.getAttribute(`data-row-index`)))));if(t===void 0)return;let r=t-e.getBoundingClientRect().top;if(Math.abs(r)<.5)return;let i=v.exec(e.style.transform);if(!i)return;let c=parseFloat(i[1]);s.set(e,c),e.style.transition=`none`,e.style.transform=`translateY(${c+r}px)`,e.style.willChange=`transform`,o.push(e)});let c=[];if(b(t).forEach(({el:e,index:t,key:r})=>{let i=a(t),o=n.get(r.slice(0,r.lastIndexOf(`|`)+1)+i);if(o===void 0)return;let s=o-e.getBoundingClientRect().top;Math.abs(s)<.5||(e.style.transition=`none`,e.style.transform=`translateY(${s}px)`,e.style.willChange=`transform`,c.push(e))}),!(o.length===0&&c.length===0)){t.getBoundingClientRect();for(let e of o)e.style.transition=`transform ${p}ms ${m}`,e.style.transform=`translateY(${s.get(e)??0}px)`;for(let e of c)e.style.transition=`transform ${p}ms ${m}`,e.style.transform=`translateY(0px)`;window.setTimeout(()=>{for(let e of o)e.style.transition=``,e.style.willChange=``;for(let e of c)L?.has(e)||x(e)},280)}},re=(e,t)=>{if(S===null||!S.enabled||t.button!==0)return;if(t.stopPropagation(),t.preventDefault(),S.gridRootRef?.current?.focus({preventScroll:!0}),S.endEditLeftOpen?.(),C!==null){if(t.pointerId!==j)return;A?.(),$(!1)}C=e,P=S.getDragRow?.(e)??null,j=t.pointerId,w=null,D={x:t.clientX,y:t.clientY},O={x:t.clientX,y:t.clientY},k=!1,document.body.style.cursor=`grabbing`,R()?(F=J(),I=S.scrollContainerRef.current?.scrollTop??0):W(S.getRowDragLabel(e)),q(e,!0);let n=t.currentTarget,r=t.pointerId;try{n.setPointerCapture(r)}catch{}let a=e=>{e.pointerId===r&&(D={x:e.clientX,y:e.clientY},Y())},o=i.beginEscapeCancelableDrag(),s=()=>{window.removeEventListener(`pointermove`,a),window.removeEventListener(`pointerup`,c),window.removeEventListener(`pointercancel`,l),window.removeEventListener(`keydown`,u,!0),window.removeEventListener(`blur`,d),o(),A=null;try{n.releasePointerCapture(r)}catch{}};function c(e){e.pointerId===r&&(s(),$(!0))}function l(e){e.pointerId===r&&(s(),$(!1))}function u(e){e.key===`Escape`&&(s(),$(!1))}function d(){s(),$(!1)}window.addEventListener(`pointermove`,a),window.addEventListener(`pointerup`,c),window.addEventListener(`pointercancel`,l),window.addEventListener(`keydown`,u,!0),window.addEventListener(`blur`,d),A=s,Y(),M=requestAnimationFrame(X)},ie=e=>{if(C===null||P==null||S?.locateDragRow===void 0)return;let t=S.locateDragRow(P,C);if(F&&F.forEach((e,t)=>{if(!t.isConnected){F?.delete(t);return}let n=Number(t.getAttribute(`data-row-index`));if(n===e.index&&(e.applied===void 0||t.style.transform===e.applied))return;let r=v.exec(t.style.transform);if(!r){F?.delete(t);return}e.index=n,e.baseY=parseFloat(r[1]),e.applied=void 0}),t===null){A?.(),$(!1);return}F&&t!==C&&O!==null&&e!==null&&(O={x:O.x,y:O.y+S.rowMetrics.rowTop(t)-e.rowTop(C)}),t!==C&&(q(null,!1),C=t,q(t,!0)),Y()};return{update:e=>{let t=S;S=e,t?.canDropAt!==e.canDropAt&&(T=null),C!==null&&t!==null&&t.locateDragRow!==e.locateDragRow&&ie(t.rowMetrics)},onRowDragHandlePointerDown:re,applyReorderSettle:ne,dispose:()=>{A?.(),A=null,M!==null&&(cancelAnimationFrame(M),M=null),document.body.style.cursor=``,K(),q(C,!1),C=null,P=null,w=null,T=null,F=null,L?.forEach(x),L=null,N=null}}};exports.createRowDragController=S;
@@ -23,6 +23,7 @@ export type RowDragArgs = {
23
23
  getDragRow?: (viewIndex: number) => unknown;
24
24
  locateDragRow?: (dragRow: unknown, hint: number) => number | null;
25
25
  gridRootRef?: ReadonlyRef<HTMLElement | null>;
26
+ endEditLeftOpen?: (() => void) | undefined;
26
27
  canDropAt?: (fromIndex: number, slot: number) => boolean;
27
28
  };
28
29
  export type RowDragHandlePointerEvent = {
@@ -272,7 +272,7 @@ var g = 14, _ = 12, v = "0.5", y = "<svg viewBox=\"0 0 24 24\" width=\"14\" heig
272
272
  }
273
273
  }, fe = (e, t) => {
274
274
  if (O === null || !O.enabled || t.button !== 0) return;
275
- if (t.stopPropagation(), t.preventDefault(), O.gridRootRef?.current?.focus({ preventScroll: !0 }), k !== null) {
275
+ if (t.stopPropagation(), t.preventDefault(), O.gridRootRef?.current?.focus({ preventScroll: !0 }), O.endEditLeftOpen?.(), k !== null) {
276
276
  if (t.pointerId !== L) return;
277
277
  I?.(), $(!1);
278
278
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ishibashi0112/spreadsheet-grid-core",
3
- "version": "1.3.0",
3
+ "version": "1.4.1",
4
4
  "description": "SpreadsheetGrid のフレームワーク非依存コア(状態 / 派生値計算 / コマンド / DOM コントローラ)。React 版 @ishibashi0112/spreadsheet-grid と将来の Solid 版が共有します。",
5
5
  "keywords": [
6
6
  "grid",