@ishibashi0112/spreadsheet-grid-core 0.42.0 → 0.43.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/engine/gridApi.cjs +1 -1
- package/dist/engine/gridApi.js +199 -183
- package/package.json +1 -1
package/dist/engine/gridApi.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../logic/grouping.cjs"),t=require("../logic/detailRow.cjs"),n=require("../model/gridActions.cjs"),r=require("../logic/geometry.cjs"),i=require("../model/gridSelectors.cjs"),a=require("../logic/validation.cjs"),o=require("../logic/verticalGeometry.cjs"),s=require("../logic/rowSelection.cjs"),c=require("../logic/gridState.cjs"),l=require("../logic/scrollTargets.cjs"),u=require("../logic/exportCsv.cjs"),d=require("../logic/exportData.cjs"),f=require("../logic/exportScope.cjs");var p=1e3,m=()=>{let m=null,h=null,g=(e,t,n=`auto`)=>{let r=Math.max(e.scrollHeight-e.clientHeight,0),i=Math.max(e.scrollWidth-e.clientWidth,0),a=Math.min(Math.max(t.top,0),r),o=Math.min(Math.max(t.left,0),i);(Math.round(a)!==Math.round(e.scrollTop)||Math.round(o)!==Math.round(e.scrollLeft))&&m?.markApiScroll(),e.scrollTo({top:a,left:o,behavior:n})},_=(e,t)=>{let n=m?.scrollContainerRef.current??null,r=m;!n||!r||g(n,{top:e===null?n.scrollTop:o.logicalToPhysicalScrollTop(e,r.verticalScaleFactor),left:t===null?n.scrollLeft:t})},v=(e,t)=>{let n=m?.scrollContainerRef.current??null,r=m;if(!n||!r||r.viewRowCount===0)return null;let i=Math.min(Math.max(e,0),r.viewRowCount-1);return l.computeVerticalScrollTarget({rowTop:r.rowMetrics.rowTop(i),rowHeight:r.rowMetrics.cellHeight(i),headerHeight:r.headerHeight,viewportHeight:n.clientHeight,currentScrollTop:o.physicalToLogicalScrollTop(n.scrollTop,r.verticalScaleFactor),align:t})},y=(e,t)=>{let n=m?.scrollContainerRef.current??null,i=m;if(!n||!i)return null;let a=r.computeSinglePaneColumnExtent(i.paneLayout,e);return!a||a.pane!==`center`?null:l.computeHorizontalScrollTarget({cellLeft:i.leftPaneTotalWidth+i.centerLeadingWidth+a.extent.start,cellWidth:a.extent.width,leftPaneWidth:i.leftPaneTotalWidth,rightPaneWidth:i.rightPaneTotalWidth,viewportWidth:n.clientWidth,currentScrollLeft:n.scrollLeft,align:t})},b=(e,t,n)=>{_(v(e,n),y(t,n))},x=e=>{let t=m;return t?{row:Math.min(Math.max(e.row,0),Math.max(t.viewRowCount-1,0)),col:Math.min(Math.max(e.col,0),Math.max(t.orderedColumns.length-1,0))}:e},S=(e,t=!1)=>{let n=m;if(!n)return null;let r=e=>n.rowModel.getRow(e),a=n.labelRowExport,o=e=>{if(!a)return[];let t=a.exportText?a.exportText(e):a.getLabel(e);return typeof t==`string`?[t]:t},s=t&&a&&n.rowModel.getLabelRow?e=>{let t=n.rowModel.getLabelRow?.(e);return t?o(t.row):void 0}:void 0,c=n.isRowExportable,l=c?(e,t)=>c(e,{viewRowIndex:t,rowKey:n.rowModel.getRowKey(t)??t}):void 0,u=c?(e,t)=>c(e,{viewRowIndex:t,rowKey:n.resolvedRowKeyGetter(e,t)}):void 0,d=f.normalizeExportScope(e);if(d===`raw`){if(n.isServerSide)return console.warn(`SpreadsheetGrid: scope 'raw' は serverSide では未ロード行を取得できないため、'view'(ロード済みビュー行)として扱います。全件エクスポートはサーバ側での実施を推奨します。`),{getRow:r,startRow:0,endRow:n.viewRowCount,columns:n.orderedColumns,isRowIncluded:l};let e=e=>a!==void 0&&n.rows[e]!==void 0&&a.isLabelRow(n.rows[e],e);return{getRow:t=>e(t)?void 0:n.rows[t],startRow:0,endRow:n.rows.length,columns:n.orderedColumns,isRowIncluded:u,getLabelLine:t&&a?t=>e(t)?o(n.rows[t]):void 0:void 0}}if(d===`rendered`)return{getRow:r,startRow:n.windowFirstRow,endRow:n.windowLastRow>=n.windowFirstRow?n.windowLastRow+1:n.windowFirstRow,columns:n.orderedColumns,isRowIncluded:l,getLabelLine:s};if(d===`selection`){let e=n.uiState.selection;if(!e)return null;if(e.type===`cell`){let t=i.normalizeCellRange(e.range);return{getRow:r,startRow:t.start.row,endRow:t.end.row+1,columns:n.orderedColumns.slice(t.start.col,t.end.col+1),isRowIncluded:l,getLabelLine:s}}if(e.type===`row`){let t=i.normalizeRowRange(e.startRow,e.endRow);return{getRow:r,startRow:t.startRow,endRow:t.endRow+1,columns:n.orderedColumns,isRowIncluded:l,getLabelLine:s}}let t=i.normalizeColumnRange(e.startCol,e.endCol);return{getRow:r,startRow:0,endRow:n.viewRowCount,columns:n.orderedColumns.slice(t.startCol,t.endCol+1),isRowIncluded:l,getLabelLine:s}}return{getRow:r,startRow:0,endRow:n.viewRowCount,columns:n.orderedColumns,isRowIncluded:l,getLabelLine:s}},C=e=>e.filter(e=>!t.isSyntheticColumnKey(e.key)),w=e=>{let t=S(e?.scope??`view`,e?.includeLabelRows===!0);return t?u.serializeRowsToCsv({getRow:t.getRow,startRow:t.startRow,endRow:t.endRow,columns:C(t.columns),delimiter:e?.delimiter,includeHeaders:e?.includeHeaders,bom:e?.bom,isRowIncluded:t.isRowIncluded,getLabelLine:t.getLabelLine}):e?.bom?``:``},T=e=>{let t=S(e?.scope??`view`,e?.includeLabelRows===!0);return t?d.buildGridExportData({getRow:t.getRow,startRow:t.startRow,endRow:t.endRow,columns:C(t.columns),isRowIncluded:t.isRowIncluded,getLabelLine:t.getLabelLine}):{columns:[],rows:[]}};return{update:e=>{let t=m?.physicalBodyHeight;if(m=e,h===null||t===e.physicalBodyHeight)return;let n=e.scrollContainerRef.current;if(!n||!e.measuredRowHeights||Date.now()>h.until||n.scrollTop<h.pinnedTop-1){h=null;return}g(n,{top:Math.max(e.headerHeight+e.physicalBodyHeight-n.clientHeight,0),left:n.scrollLeft}),h={...h,pinnedTop:n.scrollTop}},handle:{scrollToRow:(e,t)=>_(v(e,t?.align??`auto`),null),scrollToCell:(e,t,n)=>b(e,t,n?.align??`auto`),scrollToTop:()=>{let e=m?.scrollContainerRef.current??null;e&&g(e,{top:0,left:e.scrollLeft})},scrollToBottom:()=>{let e=m?.scrollContainerRef.current??null,t=m;!e||!t||(g(e,{top:Math.max(t.headerHeight+t.physicalBodyHeight-e.clientHeight,0),left:e.scrollLeft}),h=t.measuredRowHeights?{pinnedTop:e.scrollTop,until:Date.now()+p}:null)},getScrollPosition:()=>{let e=m?.scrollContainerRef.current??null;return e?{top:e.scrollTop,left:e.scrollLeft}:null},setScrollPosition:(e,t)=>{let n=m?.scrollContainerRef.current??null;n&&g(n,{top:e.top??n.scrollTop,left:e.left??n.scrollLeft},t?.behavior??`auto`)},getVisibleRowRange:()=>{let e=m;return!e||e.windowLastRow<e.windowFirstRow?null:{startIndex:e.windowFirstRow,endIndex:e.windowLastRow+1}},getActiveCell:()=>{let e=m?.uiState.activeCell;return e?{row:e.row,col:e.col}:null},setActiveCell:(e,t)=>{let r=m;if(!r)return;let i=e?x(e):null;r.dispatch(n.gridActions.activateCell(i)),i&&t?.scrollIntoView&&b(i.row,i.col,`auto`)},getSelection:()=>m?.uiState.selection??null,selectCell:(e,t,r)=>{let i=m;if(!i)return;let a=x({row:e,col:t});i.dispatch(n.gridActions.startSelection(a)),i.dispatch(n.gridActions.endSelection()),r?.scrollIntoView&&b(a.row,a.col,`auto`)},selectRange:(e,t)=>{let r=m;if(!r)return;let i=x(e.start),a=x(e.end);r.dispatch(n.gridActions.startSelection(i)),r.dispatch(n.gridActions.updateSelection(a)),r.dispatch(n.gridActions.endSelection()),t?.scrollIntoView&&b(a.row,a.col,`auto`)},clearSelection:()=>{m?.dispatch(n.gridActions.clearSelection())},getSelectedRows:()=>{let e=m;if(!e)return[];let t=e.uiState.selection;if(!t)return[];let n=[],r=t=>{let r=e.rowModel.getRow(t);r&&n.push(r)};if(t.type===`cell`){let e=i.normalizeCellRange(t.range);for(let t=e.start.row;t<=e.end.row;t+=1)r(t)}else if(t.type===`row`){let e=i.normalizeRowRange(t.startRow,t.endRow);for(let t=e.startRow;t<=e.endRow;t+=1)r(t)}else for(let t=0;t<e.viewRowCount;t+=1)r(t);return n},exportCsv:e=>w(e),downloadCsv:(e,t)=>{if(typeof document>`u`)return;let n=w({...t,bom:t?.bom??!0}),r=new Blob([n],{type:`text/csv;charset=utf-8;`}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=e??`export.csv`,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(i)},getExportData:e=>T(e),getState:()=>{let e=m;return e?c.buildGridState(e.uiState.columnWidths,e.uiState.filters,e.uiState.sort,c.extractColumnState(e.columns)):c.buildGridState({},{globalText:``,columnFilters:{}},[],[])},applyState:e=>{let t=m;if(!t)return;let r=c.migrateGridState(e);t.onColumnsChange&&r.columns&&t.onColumnsChange(c.applyColumnState(t.columns,r.columns,r.columnWidths)),t.dispatch(n.gridActions.resetColumnWidths(r.columnWidths)),t.dispatch(n.gridActions.setAllFilters(r.filters)),t.dispatch(n.gridActions.setSort(r.sort))},getRowSelection:()=>{let e=m;return e?s.rowSelectionToModel(e.uiState.rowSelection):{type:`include`,rowKeys:[]}},setRowSelection:e=>{m?.commitRowSelection(s.rowSelectionFromModel(e))},getSelectedRowKeys:()=>{let e=m;if(!e)return[];let t=e.uiState.rowSelection;if(t.mode===`include`)return Array.from(t.keys);let n=[],r=e.rowModel.getRowCount();for(let i=0;i<r;i+=1){if(!e.rowModel.getRow(i))continue;let r=e.rowModel.getRowKey(i)??i;t.keys.has(r)||n.push(r)}return n},getSelectedRowData:()=>{let e=m;if(!e)return[];let t=e.uiState.rowSelection,n=[],r=e.rowModel.getRowCount();for(let i=0;i<r;i+=1){let r=e.rowModel.getRow(i);r&&s.resolveIsRowSelected(t,e.rowModel.getRowKey(i)??i)&&n.push(r)}return n},getSelectedRowCount:()=>{let e=m;return e?s.countSelectedRows(e.uiState.rowSelection,e.leafRowCount):0},isRowSelected:e=>{let t=m;return t?s.resolveIsRowSelected(t.uiState.rowSelection,e):!1},selectAllRows:()=>{m?.commitRowSelection(s.selectAllRows())},clearRowSelection:()=>{m?.commitRowSelection(s.clearRowSelection())},undo:()=>{m?.undoRows()},redo:()=>{m?.redoRows()},canUndo:()=>m?.canUndoRows()??!1,canRedo:()=>m?.canRedoRows()??!1,clearUndoHistory:()=>{m?.clearUndoHistory()},setGroupCollapsed:(e,t)=>{m?.dispatch(n.gridActions.setGroupCollapsed(e,t))},expandAllGroups:()=>{m?.dispatch(n.gridActions.setCollapsedGroupKeys(new Set))},collapseAllGroups:()=>{let t=m;!t||!t.groupTree||t.dispatch(n.gridActions.setCollapsedGroupKeys(new Set(e.collectAllGroupKeys(t.groupTree))))},getGroupRows:()=>{let t=m;return t?.groupTree?e.collectAllGroupRows(t.groupTree):[]},setDetailRowExpanded:(e,r)=>{let i=m;if(!(!i||!i.detailRowEnabled)){if(r&&i.detailIsExpandable){let n=t.findDetailRowIndex(i.rowModel,e,i.detailIndexCacheRef.current,!i.isServerSide);if(n>=0){let t=i.rowModel.getRow(n);if(t!=null&&!i.detailIsExpandable(t,{rowKey:e,sourceRowIndex:i.rowModel.getSourceIndex(n)}))return}}i.dispatch(n.gridActions.setDetailRowExpanded(e,r))}},getExpandedDetailRowKeys:()=>{let e=m;return e&&e.detailRowEnabled?Array.from(e.uiState.expandedDetailRowKeys):[]},collapseAllDetailRows:()=>{let e=m;!e||!e.detailRowEnabled||e.dispatch(n.gridActions.setExpandedDetailRowKeys(new Set))},moveRow:(e,t)=>{m?.moveRowByKey(e,t)},getInvalidCells:()=>{let e=m;return e?e.isServerSide?(console.warn(`[SpreadsheetGrid] getInvalidCells は serverSide モードでは利用できません(空配列を返します)。`),[]):a.scanInvalidCells(e.rows,e.columns,e.resolvedRowKeyGetter):[]},refreshServerSide:()=>{let e=m;if(e){if(!e.isServerSide){console.warn(`[SpreadsheetGrid] refreshServerSide は clientSide(rows)モードでは何もしません(dataSource 指定時のみ有効です)。`);return}e.serverSideRefresh()}},retryServerSideLoads:()=>{let e=m;if(e){if(!e.isServerSide){console.warn(`[SpreadsheetGrid] retryServerSideLoads は clientSide(rows)モードでは何もしません(dataSource 指定時のみ有効です)。`);return}e.serverSideRetryFailed()}},openFilterManager:()=>{m?.openToolPanel(`filter`)},closeFilterManager:()=>{let e=m;e&&e.activeToolPanelTab===`filter`&&e.closeToolPanel()}},applyScroll:_,verticalTargetFor:v,horizontalTargetFor:y,scrollToCellInternal:b}};exports.createGridApi=m;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../logic/grouping.cjs"),t=require("../logic/detailRow.cjs"),n=require("../model/gridActions.cjs"),r=require("../logic/geometry.cjs"),i=require("../model/gridSelectors.cjs"),a=require("../logic/validation.cjs"),o=require("../logic/verticalGeometry.cjs"),s=require("../logic/rowSelection.cjs"),c=require("../logic/gridState.cjs"),l=require("../logic/scrollTargets.cjs"),u=require("../logic/exportCsv.cjs"),d=require("../logic/exportData.cjs"),f=require("../logic/exportScope.cjs");var p=1e3,m=new Set,h=()=>{let h=null,g=null,_=(e,t,n=`auto`)=>{let r=Math.max(e.scrollHeight-e.clientHeight,0),i=Math.max(e.scrollWidth-e.clientWidth,0),a=Math.min(Math.max(t.top,0),r),o=Math.min(Math.max(t.left,0),i);(Math.round(a)!==Math.round(e.scrollTop)||Math.round(o)!==Math.round(e.scrollLeft))&&h?.markApiScroll(),e.scrollTo({top:a,left:o,behavior:n})},v=(e,t)=>{let n=h?.scrollContainerRef.current??null,r=h;!n||!r||_(n,{top:e===null?n.scrollTop:o.logicalToPhysicalScrollTop(e,r.verticalScaleFactor),left:t===null?n.scrollLeft:t})},y=(e,t)=>{let n=h?.scrollContainerRef.current??null,r=h;if(!n||!r||r.viewRowCount===0)return null;let i=Math.min(Math.max(e,0),r.viewRowCount-1);return l.computeVerticalScrollTarget({rowTop:r.rowMetrics.rowTop(i),rowHeight:r.rowMetrics.cellHeight(i),headerHeight:r.headerHeight,viewportHeight:n.clientHeight,currentScrollTop:o.physicalToLogicalScrollTop(n.scrollTop,r.verticalScaleFactor),align:t})},b=(e,t)=>{let n=h?.scrollContainerRef.current??null,i=h;if(!n||!i)return null;let a=r.computeSinglePaneColumnExtent(i.paneLayout,e);return!a||a.pane!==`center`?null:l.computeHorizontalScrollTarget({cellLeft:i.leftPaneTotalWidth+i.centerLeadingWidth+a.extent.start,cellWidth:a.extent.width,leftPaneWidth:i.leftPaneTotalWidth,rightPaneWidth:i.rightPaneTotalWidth,viewportWidth:n.clientWidth,currentScrollLeft:n.scrollLeft,align:t})},x=(e,t,n)=>{v(y(e,n),b(t,n))},S=e=>{let t=h;return t?{row:Math.min(Math.max(e.row,0),Math.max(t.viewRowCount-1,0)),col:Math.min(Math.max(e.col,0),Math.max(t.orderedColumns.length-1,0))}:e},C=(t,n=!1)=>{let r=h;if(!r)return null;let a=e=>r.rowModel.getRow(e),o=r.labelRowExport,s=e=>{if(!o)return[];let t=o.exportText?o.exportText(e):o.getLabel(e);return typeof t==`string`?[t]:t},c=n&&o&&r.rowModel.getLabelRow?e=>{let t=r.rowModel.getLabelRow?.(e);return t?s(t.row):void 0}:void 0,l=r.isRowExportable,u=l?(e,t)=>l(e,{viewRowIndex:t,rowKey:r.rowModel.getRowKey(t)??t}):void 0,d=l?(e,t)=>l(e,{viewRowIndex:t,rowKey:r.resolvedRowKeyGetter(e,t)}):void 0,p=f.normalizeExportScope(t);if(p===`raw`){if(r.isServerSide)return console.warn(`SpreadsheetGrid: scope 'raw' は serverSide では未ロード行を取得できないため、'view'(ロード済みビュー行)として扱います。全件エクスポートはサーバ側での実施を推奨します。`),{getRow:a,startRow:0,endRow:r.viewRowCount,columns:r.orderedColumns,isRowIncluded:u};let e=e=>o!==void 0&&r.rows[e]!==void 0&&o.isLabelRow(r.rows[e],e);return{getRow:t=>e(t)?void 0:r.rows[t],startRow:0,endRow:r.rows.length,columns:r.orderedColumns,isRowIncluded:d,getLabelLine:n&&o?t=>e(t)?s(r.rows[t]):void 0:void 0}}if(p===`rendered`)return{getRow:a,startRow:r.windowFirstRow,endRow:r.windowLastRow>=r.windowFirstRow?r.windowLastRow+1:r.windowFirstRow,columns:r.orderedColumns,isRowIncluded:u,getLabelLine:c};if(p===`selection`){let e=r.uiState.selection;if(!e)return null;if(e.type===`cell`){let t=i.normalizeCellRange(e.range);return{getRow:a,startRow:t.start.row,endRow:t.end.row+1,columns:r.orderedColumns.slice(t.start.col,t.end.col+1),isRowIncluded:u,getLabelLine:c}}if(e.type===`row`){let t=i.normalizeRowRange(e.startRow,e.endRow);return{getRow:a,startRow:t.startRow,endRow:t.endRow+1,columns:r.orderedColumns,isRowIncluded:u,getLabelLine:c}}let t=i.normalizeColumnRange(e.startCol,e.endCol);return{getRow:a,startRow:0,endRow:r.viewRowCount,columns:r.orderedColumns.slice(t.startCol,t.endCol+1),isRowIncluded:u,getLabelLine:c}}if(r.groupTree){let t=e.flattenGroupTree(r.groupTree,m).displayOrder;return{getRow:n=>{let i=t[n];return i===void 0||e.isGroupOrderValue(i)?void 0:r.rows[i]},startRow:0,endRow:t.length,columns:r.orderedColumns,isRowIncluded:l?(e,n)=>l(e,{viewRowIndex:n,rowKey:r.resolvedRowKeyGetter(e,t[n]??n)}):void 0}}return{getRow:a,startRow:0,endRow:r.viewRowCount,columns:r.orderedColumns,isRowIncluded:u,getLabelLine:c}},w=e=>e.filter(e=>!t.isSyntheticColumnKey(e.key)),T=e=>{let t=C(e?.scope??`view`,e?.includeLabelRows===!0);return t?u.serializeRowsToCsv({getRow:t.getRow,startRow:t.startRow,endRow:t.endRow,columns:w(t.columns),delimiter:e?.delimiter,includeHeaders:e?.includeHeaders,bom:e?.bom,isRowIncluded:t.isRowIncluded,getLabelLine:t.getLabelLine}):e?.bom?``:``},E=e=>{let t=C(e?.scope??`view`,e?.includeLabelRows===!0);return t?d.buildGridExportData({getRow:t.getRow,startRow:t.startRow,endRow:t.endRow,columns:w(t.columns),isRowIncluded:t.isRowIncluded,getLabelLine:t.getLabelLine}):{columns:[],rows:[]}};return{update:e=>{let t=h?.physicalBodyHeight;if(h=e,g===null||t===e.physicalBodyHeight)return;let n=e.scrollContainerRef.current;if(!n||!e.measuredRowHeights||Date.now()>g.until||n.scrollTop<g.pinnedTop-1){g=null;return}_(n,{top:Math.max(e.headerHeight+e.physicalBodyHeight-n.clientHeight,0),left:n.scrollLeft}),g={...g,pinnedTop:n.scrollTop}},handle:{scrollToRow:(e,t)=>v(y(e,t?.align??`auto`),null),scrollToCell:(e,t,n)=>x(e,t,n?.align??`auto`),scrollToTop:()=>{let e=h?.scrollContainerRef.current??null;e&&_(e,{top:0,left:e.scrollLeft})},scrollToBottom:()=>{let e=h?.scrollContainerRef.current??null,t=h;!e||!t||(_(e,{top:Math.max(t.headerHeight+t.physicalBodyHeight-e.clientHeight,0),left:e.scrollLeft}),g=t.measuredRowHeights?{pinnedTop:e.scrollTop,until:Date.now()+p}:null)},getScrollPosition:()=>{let e=h?.scrollContainerRef.current??null;return e?{top:e.scrollTop,left:e.scrollLeft}:null},setScrollPosition:(e,t)=>{let n=h?.scrollContainerRef.current??null;n&&_(n,{top:e.top??n.scrollTop,left:e.left??n.scrollLeft},t?.behavior??`auto`)},getVisibleRowRange:()=>{let e=h;return!e||e.windowLastRow<e.windowFirstRow?null:{startIndex:e.windowFirstRow,endIndex:e.windowLastRow+1}},getActiveCell:()=>{let e=h?.uiState.activeCell;return e?{row:e.row,col:e.col}:null},setActiveCell:(e,t)=>{let r=h;if(!r)return;let i=e?S(e):null;r.dispatch(n.gridActions.activateCell(i)),i&&t?.scrollIntoView&&x(i.row,i.col,`auto`)},getSelection:()=>h?.uiState.selection??null,selectCell:(e,t,r)=>{let i=h;if(!i)return;let a=S({row:e,col:t});i.dispatch(n.gridActions.startSelection(a)),i.dispatch(n.gridActions.endSelection()),r?.scrollIntoView&&x(a.row,a.col,`auto`)},selectRange:(e,t)=>{let r=h;if(!r)return;let i=S(e.start),a=S(e.end);r.dispatch(n.gridActions.startSelection(i)),r.dispatch(n.gridActions.updateSelection(a)),r.dispatch(n.gridActions.endSelection()),t?.scrollIntoView&&x(a.row,a.col,`auto`)},clearSelection:()=>{h?.dispatch(n.gridActions.clearSelection())},getSelectedRows:()=>{let e=h;if(!e)return[];let t=e.uiState.selection;if(!t)return[];let n=[],r=t=>{let r=e.rowModel.getRow(t);r&&n.push(r)};if(t.type===`cell`){let e=i.normalizeCellRange(t.range);for(let t=e.start.row;t<=e.end.row;t+=1)r(t)}else if(t.type===`row`){let e=i.normalizeRowRange(t.startRow,t.endRow);for(let t=e.startRow;t<=e.endRow;t+=1)r(t)}else for(let t=0;t<e.viewRowCount;t+=1)r(t);return n},exportCsv:e=>T(e),downloadCsv:(e,t)=>{if(typeof document>`u`)return;let n=T({...t,bom:t?.bom??!0}),r=new Blob([n],{type:`text/csv;charset=utf-8;`}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=e??`export.csv`,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(i)},getExportData:e=>E(e),getState:()=>{let e=h;return e?c.buildGridState(e.uiState.columnWidths,e.uiState.filters,e.uiState.sort,c.extractColumnState(e.columns)):c.buildGridState({},{globalText:``,columnFilters:{}},[],[])},applyState:e=>{let t=h;if(!t)return;let r=c.migrateGridState(e);t.onColumnsChange&&r.columns&&t.onColumnsChange(c.applyColumnState(t.columns,r.columns,r.columnWidths)),t.dispatch(n.gridActions.resetColumnWidths(r.columnWidths)),t.dispatch(n.gridActions.setAllFilters(r.filters)),t.dispatch(n.gridActions.setSort(r.sort))},getRowSelection:()=>{let e=h;return e?s.rowSelectionToModel(e.uiState.rowSelection):{type:`include`,rowKeys:[]}},setRowSelection:e=>{h?.commitRowSelection(s.rowSelectionFromModel(e))},getSelectedRowKeys:()=>{let e=h;if(!e)return[];let t=e.uiState.rowSelection;if(t.mode===`include`)return Array.from(t.keys);let n=[],r=e.rowModel.getRowCount();for(let i=0;i<r;i+=1){if(!e.rowModel.getRow(i))continue;let r=e.rowModel.getRowKey(i)??i;t.keys.has(r)||n.push(r)}return n},getSelectedRowData:()=>{let e=h;if(!e)return[];let t=e.uiState.rowSelection,n=[],r=e.rowModel.getRowCount();for(let i=0;i<r;i+=1){let r=e.rowModel.getRow(i);r&&s.resolveIsRowSelected(t,e.rowModel.getRowKey(i)??i)&&n.push(r)}return n},getSelectedRowCount:()=>{let e=h;return e?s.countSelectedRows(e.uiState.rowSelection,e.leafRowCount):0},isRowSelected:e=>{let t=h;return t?s.resolveIsRowSelected(t.uiState.rowSelection,e):!1},selectAllRows:()=>{h?.commitRowSelection(s.selectAllRows())},clearRowSelection:()=>{h?.commitRowSelection(s.clearRowSelection())},undo:()=>{h?.undoRows()},redo:()=>{h?.redoRows()},canUndo:()=>h?.canUndoRows()??!1,canRedo:()=>h?.canRedoRows()??!1,clearUndoHistory:()=>{h?.clearUndoHistory()},setGroupCollapsed:(e,t)=>{h?.dispatch(n.gridActions.setGroupCollapsed(e,t))},expandAllGroups:()=>{h?.dispatch(n.gridActions.setCollapsedGroupKeys(new Set))},collapseAllGroups:()=>{let t=h;!t||!t.groupTree||t.dispatch(n.gridActions.setCollapsedGroupKeys(new Set(e.collectAllGroupKeys(t.groupTree))))},getGroupRows:()=>{let t=h;return t?.groupTree?e.collectAllGroupRows(t.groupTree):[]},setDetailRowExpanded:(e,r)=>{let i=h;if(!(!i||!i.detailRowEnabled)){if(r&&i.detailIsExpandable){let n=t.findDetailRowIndex(i.rowModel,e,i.detailIndexCacheRef.current,!i.isServerSide);if(n>=0){let t=i.rowModel.getRow(n);if(t!=null&&!i.detailIsExpandable(t,{rowKey:e,sourceRowIndex:i.rowModel.getSourceIndex(n)}))return}}i.dispatch(n.gridActions.setDetailRowExpanded(e,r))}},getExpandedDetailRowKeys:()=>{let e=h;return e&&e.detailRowEnabled?Array.from(e.uiState.expandedDetailRowKeys):[]},collapseAllDetailRows:()=>{let e=h;!e||!e.detailRowEnabled||e.dispatch(n.gridActions.setExpandedDetailRowKeys(new Set))},moveRow:(e,t)=>{h?.moveRowByKey(e,t)},getInvalidCells:()=>{let e=h;return e?e.isServerSide?(console.warn(`[SpreadsheetGrid] getInvalidCells は serverSide モードでは利用できません(空配列を返します)。`),[]):a.scanInvalidCells(e.rows,e.columns,e.resolvedRowKeyGetter):[]},refreshServerSide:()=>{let e=h;if(e){if(!e.isServerSide){console.warn(`[SpreadsheetGrid] refreshServerSide は clientSide(rows)モードでは何もしません(dataSource 指定時のみ有効です)。`);return}e.serverSideRefresh()}},retryServerSideLoads:()=>{let e=h;if(e){if(!e.isServerSide){console.warn(`[SpreadsheetGrid] retryServerSideLoads は clientSide(rows)モードでは何もしません(dataSource 指定時のみ有効です)。`);return}e.serverSideRetryFailed()}},openFilterManager:()=>{h?.openToolPanel(`filter`)},closeFilterManager:()=>{let e=h;e&&e.activeToolPanelTab===`filter`&&e.closeToolPanel()}},applyScroll:v,verticalTargetFor:y,horizontalTargetFor:b,scrollToCellInternal:x}};exports.createGridApi=h;
|
package/dist/engine/gridApi.js
CHANGED
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
import { collectAllGroupKeys as e, collectAllGroupRows as t } from "../logic/grouping.js";
|
|
2
|
-
import { findDetailRowIndex as
|
|
3
|
-
import { gridActions as
|
|
4
|
-
import { computeSinglePaneColumnExtent as
|
|
5
|
-
import { normalizeCellRange as
|
|
6
|
-
import { scanInvalidCells as
|
|
7
|
-
import { logicalToPhysicalScrollTop as
|
|
8
|
-
import { clearRowSelection as
|
|
9
|
-
import { applyColumnState as
|
|
10
|
-
import { computeHorizontalScrollTarget as
|
|
11
|
-
import { serializeRowsToCsv as
|
|
12
|
-
import { buildGridExportData as
|
|
13
|
-
import { normalizeExportScope as
|
|
1
|
+
import { collectAllGroupKeys as e, collectAllGroupRows as t, flattenGroupTree as n, isGroupOrderValue as r } from "../logic/grouping.js";
|
|
2
|
+
import { findDetailRowIndex as i, isSyntheticColumnKey as a } from "../logic/detailRow.js";
|
|
3
|
+
import { gridActions as o } from "../model/gridActions.js";
|
|
4
|
+
import { computeSinglePaneColumnExtent as s } from "../logic/geometry.js";
|
|
5
|
+
import { normalizeCellRange as c, normalizeColumnRange as l, normalizeRowRange as u } from "../model/gridSelectors.js";
|
|
6
|
+
import { scanInvalidCells as d } from "../logic/validation.js";
|
|
7
|
+
import { logicalToPhysicalScrollTop as f, physicalToLogicalScrollTop as p } from "../logic/verticalGeometry.js";
|
|
8
|
+
import { clearRowSelection as m, countSelectedRows as h, resolveIsRowSelected as g, rowSelectionFromModel as _, rowSelectionToModel as v, selectAllRows as y } from "../logic/rowSelection.js";
|
|
9
|
+
import { applyColumnState as b, buildGridState as x, extractColumnState as S, migrateGridState as C } from "../logic/gridState.js";
|
|
10
|
+
import { computeHorizontalScrollTarget as w, computeVerticalScrollTarget as T } from "../logic/scrollTargets.js";
|
|
11
|
+
import { serializeRowsToCsv as E } from "../logic/exportCsv.js";
|
|
12
|
+
import { buildGridExportData as D } from "../logic/exportData.js";
|
|
13
|
+
import { normalizeExportScope as O } from "../logic/exportScope.js";
|
|
14
14
|
//#region src/engine/gridApi.ts
|
|
15
|
-
var
|
|
16
|
-
let
|
|
15
|
+
var k = 1e3, A = /* @__PURE__ */ new Set(), j = () => {
|
|
16
|
+
let j = null, M = null, N = (e, t, n = "auto") => {
|
|
17
17
|
let r = Math.max(e.scrollHeight - e.clientHeight, 0), i = Math.max(e.scrollWidth - e.clientWidth, 0), a = Math.min(Math.max(t.top, 0), r), o = Math.min(Math.max(t.left, 0), i);
|
|
18
|
-
(Math.round(a) !== Math.round(e.scrollTop) || Math.round(o) !== Math.round(e.scrollLeft)) &&
|
|
18
|
+
(Math.round(a) !== Math.round(e.scrollTop) || Math.round(o) !== Math.round(e.scrollLeft)) && j?.markApiScroll(), e.scrollTo({
|
|
19
19
|
top: a,
|
|
20
20
|
left: o,
|
|
21
21
|
behavior: n
|
|
22
22
|
});
|
|
23
|
-
},
|
|
24
|
-
let n =
|
|
25
|
-
!n || !r ||
|
|
26
|
-
top: e === null ? n.scrollTop :
|
|
23
|
+
}, P = (e, t) => {
|
|
24
|
+
let n = j?.scrollContainerRef.current ?? null, r = j;
|
|
25
|
+
!n || !r || N(n, {
|
|
26
|
+
top: e === null ? n.scrollTop : f(e, r.verticalScaleFactor),
|
|
27
27
|
left: t === null ? n.scrollLeft : t
|
|
28
28
|
});
|
|
29
|
-
},
|
|
30
|
-
let n =
|
|
29
|
+
}, F = (e, t) => {
|
|
30
|
+
let n = j?.scrollContainerRef.current ?? null, r = j;
|
|
31
31
|
if (!n || !r || r.viewRowCount === 0) return null;
|
|
32
32
|
let i = Math.min(Math.max(e, 0), r.viewRowCount - 1);
|
|
33
|
-
return
|
|
33
|
+
return T({
|
|
34
34
|
rowTop: r.rowMetrics.rowTop(i),
|
|
35
35
|
rowHeight: r.rowMetrics.cellHeight(i),
|
|
36
36
|
headerHeight: r.headerHeight,
|
|
37
37
|
viewportHeight: n.clientHeight,
|
|
38
|
-
currentScrollTop:
|
|
38
|
+
currentScrollTop: p(n.scrollTop, r.verticalScaleFactor),
|
|
39
39
|
align: t
|
|
40
40
|
});
|
|
41
|
-
},
|
|
42
|
-
let n =
|
|
41
|
+
}, I = (e, t) => {
|
|
42
|
+
let n = j?.scrollContainerRef.current ?? null, r = j;
|
|
43
43
|
if (!n || !r) return null;
|
|
44
|
-
let i =
|
|
45
|
-
return !i || i.pane !== "center" ? null :
|
|
44
|
+
let i = s(r.paneLayout, e);
|
|
45
|
+
return !i || i.pane !== "center" ? null : w({
|
|
46
46
|
cellLeft: r.leftPaneTotalWidth + r.centerLeadingWidth + i.extent.start,
|
|
47
47
|
cellWidth: i.extent.width,
|
|
48
48
|
leftPaneWidth: r.leftPaneTotalWidth,
|
|
@@ -51,120 +51,136 @@ var D = 1e3, O = () => {
|
|
|
51
51
|
currentScrollLeft: n.scrollLeft,
|
|
52
52
|
align: t
|
|
53
53
|
});
|
|
54
|
-
},
|
|
55
|
-
|
|
56
|
-
},
|
|
57
|
-
let t =
|
|
54
|
+
}, L = (e, t, n) => {
|
|
55
|
+
P(F(e, n), I(t, n));
|
|
56
|
+
}, R = (e) => {
|
|
57
|
+
let t = j;
|
|
58
58
|
return t ? {
|
|
59
59
|
row: Math.min(Math.max(e.row, 0), Math.max(t.viewRowCount - 1, 0)),
|
|
60
60
|
col: Math.min(Math.max(e.col, 0), Math.max(t.orderedColumns.length - 1, 0))
|
|
61
61
|
} : e;
|
|
62
|
-
},
|
|
63
|
-
let
|
|
64
|
-
if (!
|
|
65
|
-
let
|
|
66
|
-
if (!
|
|
67
|
-
let t =
|
|
62
|
+
}, z = (e, t = !1) => {
|
|
63
|
+
let i = j;
|
|
64
|
+
if (!i) return null;
|
|
65
|
+
let a = (e) => i.rowModel.getRow(e), o = i.labelRowExport, s = (e) => {
|
|
66
|
+
if (!o) return [];
|
|
67
|
+
let t = o.exportText ? o.exportText(e) : o.getLabel(e);
|
|
68
68
|
return typeof t == "string" ? [t] : t;
|
|
69
|
-
},
|
|
70
|
-
let t =
|
|
71
|
-
return t ?
|
|
72
|
-
} : void 0,
|
|
69
|
+
}, d = t && o && i.rowModel.getLabelRow ? (e) => {
|
|
70
|
+
let t = i.rowModel.getLabelRow?.(e);
|
|
71
|
+
return t ? s(t.row) : void 0;
|
|
72
|
+
} : void 0, f = i.isRowExportable, p = f ? (e, t) => f(e, {
|
|
73
73
|
viewRowIndex: t,
|
|
74
|
-
rowKey:
|
|
75
|
-
}) : void 0,
|
|
74
|
+
rowKey: i.rowModel.getRowKey(t) ?? t
|
|
75
|
+
}) : void 0, m = f ? (e, t) => f(e, {
|
|
76
76
|
viewRowIndex: t,
|
|
77
|
-
rowKey:
|
|
78
|
-
}) : void 0,
|
|
79
|
-
if (
|
|
80
|
-
if (
|
|
81
|
-
getRow:
|
|
77
|
+
rowKey: i.resolvedRowKeyGetter(e, t)
|
|
78
|
+
}) : void 0, h = O(e);
|
|
79
|
+
if (h === "raw") {
|
|
80
|
+
if (i.isServerSide) return console.warn("SpreadsheetGrid: scope 'raw' は serverSide では未ロード行を取得できないため、'view'(ロード済みビュー行)として扱います。全件エクスポートはサーバ側での実施を推奨します。"), {
|
|
81
|
+
getRow: a,
|
|
82
82
|
startRow: 0,
|
|
83
|
-
endRow:
|
|
84
|
-
columns:
|
|
85
|
-
isRowIncluded:
|
|
83
|
+
endRow: i.viewRowCount,
|
|
84
|
+
columns: i.orderedColumns,
|
|
85
|
+
isRowIncluded: p
|
|
86
86
|
};
|
|
87
|
-
let e = (e) =>
|
|
87
|
+
let e = (e) => o !== void 0 && i.rows[e] !== void 0 && o.isLabelRow(i.rows[e], e);
|
|
88
88
|
return {
|
|
89
|
-
getRow: (t) => e(t) ? void 0 :
|
|
89
|
+
getRow: (t) => e(t) ? void 0 : i.rows[t],
|
|
90
90
|
startRow: 0,
|
|
91
|
-
endRow:
|
|
92
|
-
columns:
|
|
93
|
-
isRowIncluded:
|
|
94
|
-
getLabelLine: t &&
|
|
91
|
+
endRow: i.rows.length,
|
|
92
|
+
columns: i.orderedColumns,
|
|
93
|
+
isRowIncluded: m,
|
|
94
|
+
getLabelLine: t && o ? (t) => e(t) ? s(i.rows[t]) : void 0 : void 0
|
|
95
95
|
};
|
|
96
96
|
}
|
|
97
|
-
if (
|
|
98
|
-
getRow:
|
|
99
|
-
startRow:
|
|
100
|
-
endRow:
|
|
101
|
-
columns:
|
|
102
|
-
isRowIncluded:
|
|
103
|
-
getLabelLine:
|
|
97
|
+
if (h === "rendered") return {
|
|
98
|
+
getRow: a,
|
|
99
|
+
startRow: i.windowFirstRow,
|
|
100
|
+
endRow: i.windowLastRow >= i.windowFirstRow ? i.windowLastRow + 1 : i.windowFirstRow,
|
|
101
|
+
columns: i.orderedColumns,
|
|
102
|
+
isRowIncluded: p,
|
|
103
|
+
getLabelLine: d
|
|
104
104
|
};
|
|
105
|
-
if (
|
|
106
|
-
let e =
|
|
105
|
+
if (h === "selection") {
|
|
106
|
+
let e = i.uiState.selection;
|
|
107
107
|
if (!e) return null;
|
|
108
108
|
if (e.type === "cell") {
|
|
109
|
-
let t =
|
|
109
|
+
let t = c(e.range);
|
|
110
110
|
return {
|
|
111
|
-
getRow:
|
|
111
|
+
getRow: a,
|
|
112
112
|
startRow: t.start.row,
|
|
113
113
|
endRow: t.end.row + 1,
|
|
114
|
-
columns:
|
|
115
|
-
isRowIncluded:
|
|
116
|
-
getLabelLine:
|
|
114
|
+
columns: i.orderedColumns.slice(t.start.col, t.end.col + 1),
|
|
115
|
+
isRowIncluded: p,
|
|
116
|
+
getLabelLine: d
|
|
117
117
|
};
|
|
118
118
|
}
|
|
119
119
|
if (e.type === "row") {
|
|
120
|
-
let t =
|
|
120
|
+
let t = u(e.startRow, e.endRow);
|
|
121
121
|
return {
|
|
122
|
-
getRow:
|
|
122
|
+
getRow: a,
|
|
123
123
|
startRow: t.startRow,
|
|
124
124
|
endRow: t.endRow + 1,
|
|
125
|
-
columns:
|
|
126
|
-
isRowIncluded:
|
|
127
|
-
getLabelLine:
|
|
125
|
+
columns: i.orderedColumns,
|
|
126
|
+
isRowIncluded: p,
|
|
127
|
+
getLabelLine: d
|
|
128
128
|
};
|
|
129
129
|
}
|
|
130
|
-
let t =
|
|
130
|
+
let t = l(e.startCol, e.endCol);
|
|
131
131
|
return {
|
|
132
|
-
getRow:
|
|
132
|
+
getRow: a,
|
|
133
133
|
startRow: 0,
|
|
134
|
-
endRow:
|
|
135
|
-
columns:
|
|
136
|
-
isRowIncluded:
|
|
137
|
-
getLabelLine:
|
|
134
|
+
endRow: i.viewRowCount,
|
|
135
|
+
columns: i.orderedColumns.slice(t.startCol, t.endCol + 1),
|
|
136
|
+
isRowIncluded: p,
|
|
137
|
+
getLabelLine: d
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
if (i.groupTree) {
|
|
141
|
+
let e = n(i.groupTree, A).displayOrder;
|
|
142
|
+
return {
|
|
143
|
+
getRow: (t) => {
|
|
144
|
+
let n = e[t];
|
|
145
|
+
return n === void 0 || r(n) ? void 0 : i.rows[n];
|
|
146
|
+
},
|
|
147
|
+
startRow: 0,
|
|
148
|
+
endRow: e.length,
|
|
149
|
+
columns: i.orderedColumns,
|
|
150
|
+
isRowIncluded: f ? (t, n) => f(t, {
|
|
151
|
+
viewRowIndex: n,
|
|
152
|
+
rowKey: i.resolvedRowKeyGetter(t, e[n] ?? n)
|
|
153
|
+
}) : void 0
|
|
138
154
|
};
|
|
139
155
|
}
|
|
140
156
|
return {
|
|
141
|
-
getRow:
|
|
157
|
+
getRow: a,
|
|
142
158
|
startRow: 0,
|
|
143
|
-
endRow:
|
|
144
|
-
columns:
|
|
145
|
-
isRowIncluded:
|
|
146
|
-
getLabelLine:
|
|
159
|
+
endRow: i.viewRowCount,
|
|
160
|
+
columns: i.orderedColumns,
|
|
161
|
+
isRowIncluded: p,
|
|
162
|
+
getLabelLine: d
|
|
147
163
|
};
|
|
148
|
-
},
|
|
149
|
-
let t =
|
|
150
|
-
return t ?
|
|
164
|
+
}, B = (e) => e.filter((e) => !a(e.key)), V = (e) => {
|
|
165
|
+
let t = z(e?.scope ?? "view", e?.includeLabelRows === !0);
|
|
166
|
+
return t ? E({
|
|
151
167
|
getRow: t.getRow,
|
|
152
168
|
startRow: t.startRow,
|
|
153
169
|
endRow: t.endRow,
|
|
154
|
-
columns:
|
|
170
|
+
columns: B(t.columns),
|
|
155
171
|
delimiter: e?.delimiter,
|
|
156
172
|
includeHeaders: e?.includeHeaders,
|
|
157
173
|
bom: e?.bom,
|
|
158
174
|
isRowIncluded: t.isRowIncluded,
|
|
159
175
|
getLabelLine: t.getLabelLine
|
|
160
176
|
}) : e?.bom ? "" : "";
|
|
161
|
-
},
|
|
162
|
-
let t =
|
|
163
|
-
return t ?
|
|
177
|
+
}, H = (e) => {
|
|
178
|
+
let t = z(e?.scope ?? "view", e?.includeLabelRows === !0);
|
|
179
|
+
return t ? D({
|
|
164
180
|
getRow: t.getRow,
|
|
165
181
|
startRow: t.startRow,
|
|
166
182
|
endRow: t.endRow,
|
|
167
|
-
columns:
|
|
183
|
+
columns: B(t.columns),
|
|
168
184
|
isRowIncluded: t.isRowIncluded,
|
|
169
185
|
getLabelLine: t.getLabelLine
|
|
170
186
|
}) : {
|
|
@@ -174,96 +190,96 @@ var D = 1e3, O = () => {
|
|
|
174
190
|
};
|
|
175
191
|
return {
|
|
176
192
|
update: (e) => {
|
|
177
|
-
let t =
|
|
178
|
-
if (
|
|
193
|
+
let t = j?.physicalBodyHeight;
|
|
194
|
+
if (j = e, M === null || t === e.physicalBodyHeight) return;
|
|
179
195
|
let n = e.scrollContainerRef.current;
|
|
180
|
-
if (!n || !e.measuredRowHeights || Date.now() >
|
|
181
|
-
|
|
196
|
+
if (!n || !e.measuredRowHeights || Date.now() > M.until || n.scrollTop < M.pinnedTop - 1) {
|
|
197
|
+
M = null;
|
|
182
198
|
return;
|
|
183
199
|
}
|
|
184
|
-
|
|
200
|
+
N(n, {
|
|
185
201
|
top: Math.max(e.headerHeight + e.physicalBodyHeight - n.clientHeight, 0),
|
|
186
202
|
left: n.scrollLeft
|
|
187
|
-
}),
|
|
188
|
-
...
|
|
203
|
+
}), M = {
|
|
204
|
+
...M,
|
|
189
205
|
pinnedTop: n.scrollTop
|
|
190
206
|
};
|
|
191
207
|
},
|
|
192
208
|
handle: {
|
|
193
|
-
scrollToRow: (e, t) =>
|
|
194
|
-
scrollToCell: (e, t, n) =>
|
|
209
|
+
scrollToRow: (e, t) => P(F(e, t?.align ?? "auto"), null),
|
|
210
|
+
scrollToCell: (e, t, n) => L(e, t, n?.align ?? "auto"),
|
|
195
211
|
scrollToTop: () => {
|
|
196
|
-
let e =
|
|
197
|
-
e &&
|
|
212
|
+
let e = j?.scrollContainerRef.current ?? null;
|
|
213
|
+
e && N(e, {
|
|
198
214
|
top: 0,
|
|
199
215
|
left: e.scrollLeft
|
|
200
216
|
});
|
|
201
217
|
},
|
|
202
218
|
scrollToBottom: () => {
|
|
203
|
-
let e =
|
|
204
|
-
!e || !t || (
|
|
219
|
+
let e = j?.scrollContainerRef.current ?? null, t = j;
|
|
220
|
+
!e || !t || (N(e, {
|
|
205
221
|
top: Math.max(t.headerHeight + t.physicalBodyHeight - e.clientHeight, 0),
|
|
206
222
|
left: e.scrollLeft
|
|
207
|
-
}),
|
|
223
|
+
}), M = t.measuredRowHeights ? {
|
|
208
224
|
pinnedTop: e.scrollTop,
|
|
209
|
-
until: Date.now() +
|
|
225
|
+
until: Date.now() + k
|
|
210
226
|
} : null);
|
|
211
227
|
},
|
|
212
228
|
getScrollPosition: () => {
|
|
213
|
-
let e =
|
|
229
|
+
let e = j?.scrollContainerRef.current ?? null;
|
|
214
230
|
return e ? {
|
|
215
231
|
top: e.scrollTop,
|
|
216
232
|
left: e.scrollLeft
|
|
217
233
|
} : null;
|
|
218
234
|
},
|
|
219
235
|
setScrollPosition: (e, t) => {
|
|
220
|
-
let n =
|
|
221
|
-
n &&
|
|
236
|
+
let n = j?.scrollContainerRef.current ?? null;
|
|
237
|
+
n && N(n, {
|
|
222
238
|
top: e.top ?? n.scrollTop,
|
|
223
239
|
left: e.left ?? n.scrollLeft
|
|
224
240
|
}, t?.behavior ?? "auto");
|
|
225
241
|
},
|
|
226
242
|
getVisibleRowRange: () => {
|
|
227
|
-
let e =
|
|
243
|
+
let e = j;
|
|
228
244
|
return !e || e.windowLastRow < e.windowFirstRow ? null : {
|
|
229
245
|
startIndex: e.windowFirstRow,
|
|
230
246
|
endIndex: e.windowLastRow + 1
|
|
231
247
|
};
|
|
232
248
|
},
|
|
233
249
|
getActiveCell: () => {
|
|
234
|
-
let e =
|
|
250
|
+
let e = j?.uiState.activeCell;
|
|
235
251
|
return e ? {
|
|
236
252
|
row: e.row,
|
|
237
253
|
col: e.col
|
|
238
254
|
} : null;
|
|
239
255
|
},
|
|
240
256
|
setActiveCell: (e, t) => {
|
|
241
|
-
let n =
|
|
257
|
+
let n = j;
|
|
242
258
|
if (!n) return;
|
|
243
|
-
let r = e ?
|
|
244
|
-
n.dispatch(
|
|
259
|
+
let r = e ? R(e) : null;
|
|
260
|
+
n.dispatch(o.activateCell(r)), r && t?.scrollIntoView && L(r.row, r.col, "auto");
|
|
245
261
|
},
|
|
246
|
-
getSelection: () =>
|
|
262
|
+
getSelection: () => j?.uiState.selection ?? null,
|
|
247
263
|
selectCell: (e, t, n) => {
|
|
248
|
-
let r =
|
|
264
|
+
let r = j;
|
|
249
265
|
if (!r) return;
|
|
250
|
-
let
|
|
266
|
+
let i = R({
|
|
251
267
|
row: e,
|
|
252
268
|
col: t
|
|
253
269
|
});
|
|
254
|
-
r.dispatch(
|
|
270
|
+
r.dispatch(o.startSelection(i)), r.dispatch(o.endSelection()), n?.scrollIntoView && L(i.row, i.col, "auto");
|
|
255
271
|
},
|
|
256
272
|
selectRange: (e, t) => {
|
|
257
|
-
let n =
|
|
273
|
+
let n = j;
|
|
258
274
|
if (!n) return;
|
|
259
|
-
let r =
|
|
260
|
-
n.dispatch(
|
|
275
|
+
let r = R(e.start), i = R(e.end);
|
|
276
|
+
n.dispatch(o.startSelection(r)), n.dispatch(o.updateSelection(i)), n.dispatch(o.endSelection()), t?.scrollIntoView && L(i.row, i.col, "auto");
|
|
261
277
|
},
|
|
262
278
|
clearSelection: () => {
|
|
263
|
-
|
|
279
|
+
j?.dispatch(o.clearSelection());
|
|
264
280
|
},
|
|
265
281
|
getSelectedRows: () => {
|
|
266
|
-
let e =
|
|
282
|
+
let e = j;
|
|
267
283
|
if (!e) return [];
|
|
268
284
|
let t = e.uiState.selection;
|
|
269
285
|
if (!t) return [];
|
|
@@ -272,49 +288,49 @@ var D = 1e3, O = () => {
|
|
|
272
288
|
r && n.push(r);
|
|
273
289
|
};
|
|
274
290
|
if (t.type === "cell") {
|
|
275
|
-
let e =
|
|
291
|
+
let e = c(t.range);
|
|
276
292
|
for (let t = e.start.row; t <= e.end.row; t += 1) r(t);
|
|
277
293
|
} else if (t.type === "row") {
|
|
278
|
-
let e =
|
|
294
|
+
let e = u(t.startRow, t.endRow);
|
|
279
295
|
for (let t = e.startRow; t <= e.endRow; t += 1) r(t);
|
|
280
296
|
} else for (let t = 0; t < e.viewRowCount; t += 1) r(t);
|
|
281
297
|
return n;
|
|
282
298
|
},
|
|
283
|
-
exportCsv: (e) =>
|
|
299
|
+
exportCsv: (e) => V(e),
|
|
284
300
|
downloadCsv: (e, t) => {
|
|
285
301
|
if (typeof document > "u") return;
|
|
286
|
-
let n =
|
|
302
|
+
let n = V({
|
|
287
303
|
...t,
|
|
288
304
|
bom: t?.bom ?? !0
|
|
289
305
|
}), r = new Blob([n], { type: "text/csv;charset=utf-8;" }), i = URL.createObjectURL(r), a = document.createElement("a");
|
|
290
306
|
a.href = i, a.download = e ?? "export.csv", document.body.appendChild(a), a.click(), document.body.removeChild(a), URL.revokeObjectURL(i);
|
|
291
307
|
},
|
|
292
|
-
getExportData: (e) =>
|
|
308
|
+
getExportData: (e) => H(e),
|
|
293
309
|
getState: () => {
|
|
294
|
-
let e =
|
|
295
|
-
return e ?
|
|
310
|
+
let e = j;
|
|
311
|
+
return e ? x(e.uiState.columnWidths, e.uiState.filters, e.uiState.sort, S(e.columns)) : x({}, {
|
|
296
312
|
globalText: "",
|
|
297
313
|
columnFilters: {}
|
|
298
314
|
}, [], []);
|
|
299
315
|
},
|
|
300
316
|
applyState: (e) => {
|
|
301
|
-
let t =
|
|
317
|
+
let t = j;
|
|
302
318
|
if (!t) return;
|
|
303
|
-
let n =
|
|
304
|
-
t.onColumnsChange && n.columns && t.onColumnsChange(
|
|
319
|
+
let n = C(e);
|
|
320
|
+
t.onColumnsChange && n.columns && t.onColumnsChange(b(t.columns, n.columns, n.columnWidths)), t.dispatch(o.resetColumnWidths(n.columnWidths)), t.dispatch(o.setAllFilters(n.filters)), t.dispatch(o.setSort(n.sort));
|
|
305
321
|
},
|
|
306
322
|
getRowSelection: () => {
|
|
307
|
-
let e =
|
|
308
|
-
return e ?
|
|
323
|
+
let e = j;
|
|
324
|
+
return e ? v(e.uiState.rowSelection) : {
|
|
309
325
|
type: "include",
|
|
310
326
|
rowKeys: []
|
|
311
327
|
};
|
|
312
328
|
},
|
|
313
329
|
setRowSelection: (e) => {
|
|
314
|
-
|
|
330
|
+
j?.commitRowSelection(_(e));
|
|
315
331
|
},
|
|
316
332
|
getSelectedRowKeys: () => {
|
|
317
|
-
let e =
|
|
333
|
+
let e = j;
|
|
318
334
|
if (!e) return [];
|
|
319
335
|
let t = e.uiState.rowSelection;
|
|
320
336
|
if (t.mode === "include") return Array.from(t.keys);
|
|
@@ -327,87 +343,87 @@ var D = 1e3, O = () => {
|
|
|
327
343
|
return n;
|
|
328
344
|
},
|
|
329
345
|
getSelectedRowData: () => {
|
|
330
|
-
let e =
|
|
346
|
+
let e = j;
|
|
331
347
|
if (!e) return [];
|
|
332
348
|
let t = e.uiState.rowSelection, n = [], r = e.rowModel.getRowCount();
|
|
333
349
|
for (let i = 0; i < r; i += 1) {
|
|
334
350
|
let r = e.rowModel.getRow(i);
|
|
335
|
-
r &&
|
|
351
|
+
r && g(t, e.rowModel.getRowKey(i) ?? i) && n.push(r);
|
|
336
352
|
}
|
|
337
353
|
return n;
|
|
338
354
|
},
|
|
339
355
|
getSelectedRowCount: () => {
|
|
340
|
-
let e =
|
|
341
|
-
return e ?
|
|
356
|
+
let e = j;
|
|
357
|
+
return e ? h(e.uiState.rowSelection, e.leafRowCount) : 0;
|
|
342
358
|
},
|
|
343
359
|
isRowSelected: (e) => {
|
|
344
|
-
let t =
|
|
345
|
-
return t ?
|
|
360
|
+
let t = j;
|
|
361
|
+
return t ? g(t.uiState.rowSelection, e) : !1;
|
|
346
362
|
},
|
|
347
363
|
selectAllRows: () => {
|
|
348
|
-
|
|
364
|
+
j?.commitRowSelection(y());
|
|
349
365
|
},
|
|
350
366
|
clearRowSelection: () => {
|
|
351
|
-
|
|
367
|
+
j?.commitRowSelection(m());
|
|
352
368
|
},
|
|
353
369
|
undo: () => {
|
|
354
|
-
|
|
370
|
+
j?.undoRows();
|
|
355
371
|
},
|
|
356
372
|
redo: () => {
|
|
357
|
-
|
|
373
|
+
j?.redoRows();
|
|
358
374
|
},
|
|
359
|
-
canUndo: () =>
|
|
360
|
-
canRedo: () =>
|
|
375
|
+
canUndo: () => j?.canUndoRows() ?? !1,
|
|
376
|
+
canRedo: () => j?.canRedoRows() ?? !1,
|
|
361
377
|
clearUndoHistory: () => {
|
|
362
|
-
|
|
378
|
+
j?.clearUndoHistory();
|
|
363
379
|
},
|
|
364
380
|
setGroupCollapsed: (e, t) => {
|
|
365
|
-
|
|
381
|
+
j?.dispatch(o.setGroupCollapsed(e, t));
|
|
366
382
|
},
|
|
367
383
|
expandAllGroups: () => {
|
|
368
|
-
|
|
384
|
+
j?.dispatch(o.setCollapsedGroupKeys(/* @__PURE__ */ new Set()));
|
|
369
385
|
},
|
|
370
386
|
collapseAllGroups: () => {
|
|
371
|
-
let t =
|
|
372
|
-
!t || !t.groupTree || t.dispatch(
|
|
387
|
+
let t = j;
|
|
388
|
+
!t || !t.groupTree || t.dispatch(o.setCollapsedGroupKeys(new Set(e(t.groupTree))));
|
|
373
389
|
},
|
|
374
390
|
getGroupRows: () => {
|
|
375
|
-
let e =
|
|
391
|
+
let e = j;
|
|
376
392
|
return e?.groupTree ? t(e.groupTree) : [];
|
|
377
393
|
},
|
|
378
394
|
setDetailRowExpanded: (e, t) => {
|
|
379
|
-
let
|
|
380
|
-
if (!(!
|
|
381
|
-
if (t &&
|
|
382
|
-
let t = n
|
|
395
|
+
let n = j;
|
|
396
|
+
if (!(!n || !n.detailRowEnabled)) {
|
|
397
|
+
if (t && n.detailIsExpandable) {
|
|
398
|
+
let t = i(n.rowModel, e, n.detailIndexCacheRef.current, !n.isServerSide);
|
|
383
399
|
if (t >= 0) {
|
|
384
|
-
let
|
|
385
|
-
if (
|
|
400
|
+
let r = n.rowModel.getRow(t);
|
|
401
|
+
if (r != null && !n.detailIsExpandable(r, {
|
|
386
402
|
rowKey: e,
|
|
387
|
-
sourceRowIndex:
|
|
403
|
+
sourceRowIndex: n.rowModel.getSourceIndex(t)
|
|
388
404
|
})) return;
|
|
389
405
|
}
|
|
390
406
|
}
|
|
391
|
-
|
|
407
|
+
n.dispatch(o.setDetailRowExpanded(e, t));
|
|
392
408
|
}
|
|
393
409
|
},
|
|
394
410
|
getExpandedDetailRowKeys: () => {
|
|
395
|
-
let e =
|
|
411
|
+
let e = j;
|
|
396
412
|
return e && e.detailRowEnabled ? Array.from(e.uiState.expandedDetailRowKeys) : [];
|
|
397
413
|
},
|
|
398
414
|
collapseAllDetailRows: () => {
|
|
399
|
-
let e =
|
|
400
|
-
!e || !e.detailRowEnabled || e.dispatch(
|
|
415
|
+
let e = j;
|
|
416
|
+
!e || !e.detailRowEnabled || e.dispatch(o.setExpandedDetailRowKeys(/* @__PURE__ */ new Set()));
|
|
401
417
|
},
|
|
402
418
|
moveRow: (e, t) => {
|
|
403
|
-
|
|
419
|
+
j?.moveRowByKey(e, t);
|
|
404
420
|
},
|
|
405
421
|
getInvalidCells: () => {
|
|
406
|
-
let e =
|
|
407
|
-
return e ? e.isServerSide ? (console.warn("[SpreadsheetGrid] getInvalidCells は serverSide モードでは利用できません(空配列を返します)。"), []) :
|
|
422
|
+
let e = j;
|
|
423
|
+
return e ? e.isServerSide ? (console.warn("[SpreadsheetGrid] getInvalidCells は serverSide モードでは利用できません(空配列を返します)。"), []) : d(e.rows, e.columns, e.resolvedRowKeyGetter) : [];
|
|
408
424
|
},
|
|
409
425
|
refreshServerSide: () => {
|
|
410
|
-
let e =
|
|
426
|
+
let e = j;
|
|
411
427
|
if (e) {
|
|
412
428
|
if (!e.isServerSide) {
|
|
413
429
|
console.warn("[SpreadsheetGrid] refreshServerSide は clientSide(rows)モードでは何もしません(dataSource 指定時のみ有効です)。");
|
|
@@ -417,7 +433,7 @@ var D = 1e3, O = () => {
|
|
|
417
433
|
}
|
|
418
434
|
},
|
|
419
435
|
retryServerSideLoads: () => {
|
|
420
|
-
let e =
|
|
436
|
+
let e = j;
|
|
421
437
|
if (e) {
|
|
422
438
|
if (!e.isServerSide) {
|
|
423
439
|
console.warn("[SpreadsheetGrid] retryServerSideLoads は clientSide(rows)モードでは何もしません(dataSource 指定時のみ有効です)。");
|
|
@@ -427,18 +443,18 @@ var D = 1e3, O = () => {
|
|
|
427
443
|
}
|
|
428
444
|
},
|
|
429
445
|
openFilterManager: () => {
|
|
430
|
-
|
|
446
|
+
j?.openToolPanel("filter");
|
|
431
447
|
},
|
|
432
448
|
closeFilterManager: () => {
|
|
433
|
-
let e =
|
|
449
|
+
let e = j;
|
|
434
450
|
e && e.activeToolPanelTab === "filter" && e.closeToolPanel();
|
|
435
451
|
}
|
|
436
452
|
},
|
|
437
|
-
applyScroll:
|
|
438
|
-
verticalTargetFor:
|
|
439
|
-
horizontalTargetFor:
|
|
440
|
-
scrollToCellInternal:
|
|
453
|
+
applyScroll: P,
|
|
454
|
+
verticalTargetFor: F,
|
|
455
|
+
horizontalTargetFor: I,
|
|
456
|
+
scrollToCellInternal: L
|
|
441
457
|
};
|
|
442
458
|
};
|
|
443
459
|
//#endregion
|
|
444
|
-
export {
|
|
460
|
+
export { j as createGridApi };
|
package/package.json
CHANGED