mirror of
https://github.com/dbeaver/cloudbeaver.git
synced 2026-09-24 16:04:36 +08:00
* dbeaver/dbeaver-vscode#83 refactor: data grid * chore: try to fix build scripts * chore: commit artifacts * chore: update yarn.lock * fix: adjust grid auto-sizing * chore: fix prettier * chore: add documentation about typescript crashes * fix: cell menu * fix: grid inline editor styles * fix: cell menu styles * fix: cell items alignment * fix: data sync * feat: support reactive values in grid * chore: try to fix strange build bug * chore: restore original file name * fix: add specific to inline editor styles * fix: remove delete row shortcut (not working) * chore: enable common cache
1 line
220 KiB
Plaintext
1 line
220 KiB
Plaintext
{"version":3,"file":"bundle.cjs","names":["column: CalculatedColumn<R, SR>","lastFrozenColumnIndex: number","args: ColSpanArgs<R, SR>","event: React.SyntheticEvent","element: Maybe<Element>","event: E","e: React.KeyboardEvent","event: React.KeyboardEvent<HTMLDivElement>","CalculatedColumn","measuringCellClassname","renderMeasuringCells","viewportColumns","R","SR","map","key","idx","minWidth","maxWidth","gridColumnStart","row","column: CalculatedColumn<R, SR>","row: R","moveNext: boolean","moveNext","parent: CalculatedColumnParent<R, SR>","cell","cellClassname","cellFrozen","cellFrozenClassname","rowIdx: number","column: CalculatedColumnOrColumnGroup<R, SR>","rowSpan: number","column: CalculatedColumn<R, SR>","keyGetter: Maybe<(row: NoInfer<R>) => K>","width: number","column: CalculatedColumnOrColumnGroup<R, SR>","rowIdx: number","RenderCheckboxProps","checkbox","checkboxClassname","renderCheckbox","onChange","indeterminate","props","handleChange","e","React","ChangeEvent","HTMLInputElement","target","checked","nativeEvent","MouseEvent","shiftKey","el","RenderGroupCellProps","groupCellContent","groupCellContentClassname","caret","caretClassname","renderToggleGroup","props","R","SR","ToggleGroup","groupKey","isExpanded","tabIndex","toggleGroup","handleKeyDown","key","React","KeyboardEvent","HTMLSpanElement","d","props: RenderCellProps<R, SR>","renderCheckbox","props: RenderHeaderCellProps<unknown>","props: RenderCellProps<unknown>","props: RenderGroupCellProps<unknown>","SelectColumn: Column<any, any>","lastFrozenColumnIndex","headerRowsCount","columns: MutableCalculatedColumn<R, SR>[]","rawColumns: readonly ColumnOrColumnGroup<R, SR>[]","level: number","parent?: MutableCalculatedColumnParent<R, SR>","rawColumns","calculatedColumnParent: MutableCalculatedColumnParent<R, SR>","column: MutableCalculatedColumn<R, SR>","colSpanColumns: CalculatedColumn<R, SR>[]","columnMetrics","totalFrozenColumnWidth","templateColumns: string[]","layoutCssVars: Record<string, string>","colOverscanStartIdx","colOverscanEndIdx","column: MutableCalculatedColumn<R, SR> | MutableCalculatedColumnParent<R, SR>","index: number","useEffect","useOriginalLayoutEffect","columns: readonly CalculatedColumn<R, SR>[]","viewportColumns: readonly CalculatedColumn<R, SR>[]","templateColumns: readonly string[]","gridRef: React.RefObject<HTMLDivElement | null>","gridWidth: number","resizedColumnWidths: ReadonlyMap<string, number>","measuredColumnWidths: ReadonlyMap<string, number>","setResizedColumnWidths: StateSetter<ReadonlyMap<string, number>>","setMeasuredColumnWidths: StateSetter<ReadonlyMap<string, number>>","onColumnResize: DataGridProps<R, SR>['onColumnResize']","columnsCanFlex: boolean","ignorePreviouslyMeasuredColumns: boolean","columnsToMeasure: string[]","columnsToMeasure: readonly string[]","columnsToMeasure","measuredColumnWidths","column: CalculatedColumn<R, SR>","nextWidth: number | 'max-content'","newTemplateColumns","width","resizedColumnWidths","key: string","offsetHeight","clientHeight","fn: T","isSelected: boolean","event: React.FocusEvent<HTMLDivElement>","startIdx","colIdx: number","colSpan: number | undefined","row","viewportColumns: CalculatedColumn<R, SR>[]","rowIdx: number","offset: number","totalRowHeight","gridTemplateRows","row","forwardRef","memo","RefAttributes","useRovingTabIndex","createCellEvent","getCellClassname","getCellStyle","isCellEditableUtil","CellRendererProps","cellCopied","cellCopiedClassname","cellDraggedOver","cellDraggedOverClassname","Cell","column","colSpan","isCellSelected","isCopied","isDraggedOver","row","rowIdx","className","onClick","onDoubleClick","onContextMenu","onRowChange","selectCell","style","props","R","SR","ref","React","Ref","HTMLDivElement","tabIndex","childTabIndex","onFocus","cellClass","isEditable","selectCellWrapper","openEditor","idx","handleClick","event","MouseEvent","cellEvent","isGridDefaultPrevented","handleContextMenu","handleDoubleClick","handleRowChange","newRow","undefined","renderCell","isCellEditable","CellComponent","JSX","Element","defaultRenderCell","key","Key","clsx","getCellStyle","CalculatedColumn","FillEvent","Position","DataGridProps","SelectCellState","cellDragHandle","cellDragHandleFrozenClassname","cellDragHandleClassname","LatestDraggedOverRowIdxRef","current","Props","Pick","R","SR","gridRowStart","column","columnWidth","maxColIdx","isLastRow","selectedPosition","latestDraggedOverRowIdx","isCellEditable","position","onClick","onFill","event","setDragging","isDragging","setDraggedOverRowIdx","overRowIdx","DragHandle","rows","onRowsChange","idx","rowIdx","handleMouseDown","React","MouseEvent","HTMLDivElement","preventDefault","buttons","window","addEventListener","onMouseOver","onMouseUp","removeEventListener","handleDragEnd","undefined","startRowIndex","endRowIndex","updateRows","handleDoubleClick","stopPropagation","length","startRowIdx","endRowIdx","sourceRow","updatedRows","indexes","i","updatedRow","columnKey","key","targetRow","push","getStyle","CSSProperties","colSpan","type","row","insetInlineStart","style","marginEnd","isLastColumn","marginInlineEnd","marginBlockEnd","frozen","useEffect","useRef","useLatestFunc","createCellEvent","getCellClassname","getCellStyle","onEditorNavigation","CellKeyboardEvent","CellRendererProps","EditCellKeyDownArgs","Maybe","Omit","RenderEditCellProps","cellEditing","SharedCellRendererProps","Pick","R","SR","EditCellProps","rowIdx","onRowChange","row","commitChanges","shouldFocusCell","closeEditor","navigate","event","React","KeyboardEvent","HTMLDivElement","onKeyDown","args","EditCell","column","colSpan","frameRequestRef","undefined","commitOnOutsideClick","editorOptions","commitOnOutsideMouseDown","onClose","onWindowCaptureMouseDown","current","requestAnimationFrame","addEventListener","capture","removeEventListener","cancelFrameRequest","cancelAnimationFrame","handleKeyDown","cellEvent","mode","isGridDefaultPrevented","key","onEditorRowChange","commitChangesAndFocus","cellClass","className","displayCellContent","idx","renderEditCell","renderCell","isCellEditable","tabIndex","RenderHeaderCellProps","useDefaultRenderers","headerSortCellClassname","headerSortName","headerSortNameClassname","renderHeaderCell","column","sortDirection","priority","R","SR","sortable","name","SharedHeaderCellProps","Pick","SortableHeaderCellProps","children","React","ReactNode","SortableHeaderCell","renderSortStatus","useState","useRovingTabIndex","clampColumnWidth","getCellClassname","getCellStyle","getHeaderCellRowSpan","getHeaderCellStyle","stopPropagation","CalculatedColumn","SortColumn","HeaderRowProps","defaultRenderHeaderCell","cellSortableClassname","cellResizable","cellResizableClassname","resizeHandleClassname","cellDraggableClassname","cellDragging","cellDraggingClassname","cellOver","cellOverClassname","SharedHeaderRowProps","Pick","R","SR","React","Key","HeaderCellProps","column","colSpan","rowIdx","isCellSelected","dragDropKey","HeaderCell","onColumnResize","onColumnsReorder","sortColumns","onSortColumnsChange","selectCell","shouldFocusGrid","direction","isDragging","setIsDragging","isOver","setIsOver","isRtl","rowSpan","tabIndex","childTabIndex","onFocus","sortIndex","findIndex","sort","columnKey","key","sortColumn","undefined","sortDirection","priority","length","ariaSort","sortable","resizable","draggable","className","headerCellClass","renderHeaderCell","onPointerDown","event","PointerEvent","HTMLDivElement","pointerType","buttons","preventDefault","currentTarget","pointerId","headerCell","parentElement","right","left","getBoundingClientRect","offset","clientX","hasDoubleClicked","onPointerMove","width","newWidth","onDoubleClick","onLostPointerCapture","removeEventListener","setPointerCapture","addEventListener","onSort","ctrlClick","sortDescendingFirst","nextSort","nextSortColumn","nextSortColumns","splice","onClick","MouseEvent","HTMLSpanElement","idx","ctrlKey","metaKey","handleFocus","FocusEvent","onKeyDown","KeyboardEvent","onDragStart","DragEvent","dataTransfer","setData","dropEffect","onDragEnd","onDragOver","onDrop","types","includes","toLowerCase","sourceKey","getData","onDragEnter","isEventPertinent","onDragLeave","draggableProps","HTMLAttributes","relatedTarget","HTMLElement","contains","row","rowClassname","rowSelected","rowSelectedClassname","rowSelectedWithFrozenCell","topSummaryRowClassname","bottomSummaryRowClassname","memo","useId","clsx","getColSpan","CalculatedColumn","Direction","Position","DataGridProps","HeaderCell","rowSelectedClassname","SharedDataGridProps","React","Key","Pick","R","SR","K","HeaderRowProps","rowIdx","columns","onColumnResize","column","width","selectCell","position","lastFrozenColumnIndex","selectedCellIdx","shouldFocusGrid","direction","headerRow","headerRowClassname","HeaderRow","onColumnsReorder","sortColumns","onSortColumnsChange","dragDropKey","cells","index","length","colSpan","type","undefined","push","key","idx","props","JSX","Element","ref: React.Ref<HTMLDivElement>","column: CalculatedColumn<R, SR>","newRow: R","event: React.MouseEvent<HTMLDivElement>","row","key: React.Key","props: RenderRowProps<R, SR>","RenderSortIconProps","RenderSortPriorityProps","RenderSortStatusProps","arrow","arrowClassname","renderSortStatus","sortDirection","priority","renderSortIcon","renderSortPriority","undefined","root","rootClassname","viewportDragging","viewportDraggingClassname","focusSinkClassname","focusSinkHeaderAndSummaryClassname","memo","useRovingTabIndex","getCellClassname","getCellStyle","CellRendererProps","summaryCellClassname","SharedCellRendererProps","Pick","R","SR","SummaryCellProps","row","SummaryCell","column","colSpan","rowIdx","isCellSelected","selectCell","tabIndex","childTabIndex","onFocus","summaryCellClass","className","onClick","idx","renderSummaryCell","props","React","JSX","Element","memo","clsx","getColSpan","getRowStyle","RenderRowProps","bottomSummaryRowClassname","rowClassname","rowSelectedClassname","topSummaryRowClassname","SummaryCell","SharedRenderRowProps","Pick","R","SR","SummaryRowProps","row","top","bottom","lastFrozenColumnIndex","selectedCellIdx","isTop","summaryRow","topSummaryRow","summaryRowClassname","SummaryRow","rowIdx","gridRowStart","viewportColumns","selectCell","ariaRowIndex","cells","index","length","column","colSpan","type","undefined","isCellSelected","idx","push","key","React","CSSProperties","props","JSX","Element","props: DataGridProps<R, SR, K>","ref: React.Ref<DataGridHandle>","renderSortStatus","defaultRenderSortStatus","renderCheckbox","defaultRenderCheckbox","column: CalculatedColumn<R, SR>","row","rowIdx?: number","cell","args: SelectHeaderRowEvent","args: SelectRowEvent<R>","event: KeyboardEvent<HTMLDivElement>","event: React.UIEvent<HTMLDivElement>","scrollTop","scrollLeft","rowIdx: number","row: R","idx: number","position: Position","enableEditor?: Maybe<boolean>","key: string","ctrlKey: boolean","shiftKey: boolean","cellNavigationMode: CellNavigationMode","currentRowIdx: number","shouldFocusCell: boolean","shouldFocusCell","commitChanges: boolean","rowElements: React.ReactNode[]","key: K | number","GroupedColumnHeaderRow","HeaderRow","SummaryRow","gridEl: HTMLDivElement","p1: Position","p2: Position","memo","useMemo","clsx","RowSelectionProvider","RowSelectionContextValue","getRowStyle","BaseRenderRowProps","GroupRow","SELECT_COLUMN_KEY","GroupCell","rowClassname","rowSelectedClassname","groupRow","groupRowClassname","GroupRowRendererProps","R","SR","row","groupBy","toggleGroup","expandedGroupId","GroupedRow","className","rowIdx","viewportColumns","selectedCellIdx","isRowSelected","selectCell","gridRowStart","isRowSelectionDisabled","props","idx","key","level","handleSelectGroup","selectionValue","setSize","posInSet","isExpanded","map","column","id","groupKey","childRows","includes","React","JSX","Element","ref: React.Ref<DataGridHandle>","columns","groupBy: string[]","rows: readonly R[]","startRowIndex: number","groups: GroupByDictionary<R>","rows","isGroupRow","flattenedRows: Array<R | GroupRow<R>>","rows: GroupByDictionary<R> | readonly R[]","parentId: string | undefined","level: number","groupRow: GroupRow<R>","groupRow","row: R | GroupRow<R>","row","selectedRows","newSelectedRows: Set<Key>","args: CellKeyDownArgs<R, SR>","event: CellKeyboardEvent","updatedRows: R[]","rawIndexes: number[]","groupId: unknown","key: Key","GroupedRow","DataGrid","arr: unknown","RenderEditCellProps","textEditorInternalClassname","textEditorClassname","autoFocusAndSelect","input","HTMLInputElement","focus","select","textEditor","row","column","onRowChange","onClose","TRow","TSummaryRow","key","event","target","value"],"sources":["../src/utils/colSpanUtils.ts","../src/utils/domUtils.ts","../src/utils/eventUtils.ts","../src/utils/keyboardUtils.ts","../src/utils/renderMeasuringCells.tsx","../src/utils/selectedCellUtils.ts","../src/style/cell.ts","../src/utils/styleUtils.ts","../src/utils/index.ts","../src/cellRenderers/renderCheckbox.tsx","../src/cellRenderers/renderToggleGroup.tsx","../src/cellRenderers/renderValue.tsx","../src/DataGridDefaultRenderersProvider.ts","../src/cellRenderers/SelectCellFormatter.tsx","../src/hooks/useRowSelection.ts","../src/Columns.tsx","../src/hooks/useCalculatedColumns.ts","../src/hooks/useLayoutEffect.ts","../src/hooks/useColumnWidths.ts","../src/hooks/useGridDimensions.ts","../src/hooks/useLatestFunc.ts","../src/hooks/useRovingTabIndex.ts","../src/hooks/useViewportColumns.ts","../src/hooks/useViewportRows.ts","../src/Cell.tsx","../src/DragHandle.tsx","../src/EditCell.tsx","../src/GroupedColumnHeaderCell.tsx","../src/renderHeaderCell.tsx","../src/HeaderCell.tsx","../src/style/row.ts","../src/HeaderRow.tsx","../src/GroupedColumnHeaderRow.tsx","../src/Row.tsx","../src/ScrollToCell.tsx","../src/sortStatus.tsx","../src/style/core.ts","../src/SummaryCell.tsx","../src/SummaryRow.tsx","../src/DataGrid.tsx","../src/GroupCell.tsx","../src/GroupRow.tsx","../src/TreeDataGrid.tsx","../src/editors/textEditor.tsx"],"sourcesContent":["import type { CalculatedColumn, ColSpanArgs } from '../types';\n\nexport function getColSpan<R, SR>(\n column: CalculatedColumn<R, SR>,\n lastFrozenColumnIndex: number,\n args: ColSpanArgs<R, SR>\n): number | undefined {\n const colSpan = typeof column.colSpan === 'function' ? column.colSpan(args) : 1;\n if (\n Number.isInteger(colSpan) &&\n colSpan! > 1 &&\n // ignore colSpan if it spans over both frozen and regular columns\n (!column.frozen || column.idx + colSpan! - 1 <= lastFrozenColumnIndex)\n ) {\n return colSpan!;\n }\n return undefined;\n}\n","import type { Maybe } from '../types';\n\nexport function stopPropagation(event: React.SyntheticEvent) {\n event.stopPropagation();\n}\n\nexport function scrollIntoView(element: Maybe<Element>) {\n element?.scrollIntoView({ inline: 'nearest', block: 'nearest' });\n}\n","import type { CellEvent } from '../types';\n\nexport function createCellEvent<E extends React.SyntheticEvent<HTMLDivElement>>(\n event: E\n): CellEvent<E> {\n let defaultPrevented = false;\n const cellEvent = {\n ...event,\n preventGridDefault() {\n defaultPrevented = true;\n },\n isGridDefaultPrevented() {\n return defaultPrevented;\n }\n };\n\n Object.setPrototypeOf(cellEvent, Object.getPrototypeOf(event));\n\n return cellEvent;\n}\n","// https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values\nconst nonInputKeys = new Set([\n // Special keys\n 'Unidentified',\n // Modifier keys\n 'Alt',\n 'AltGraph',\n 'CapsLock',\n 'Control',\n 'Fn',\n 'FnLock',\n 'Meta',\n 'NumLock',\n 'ScrollLock',\n 'Shift',\n // Whitespace keys\n 'Tab',\n // Navigation keys\n 'ArrowDown',\n 'ArrowLeft',\n 'ArrowRight',\n 'ArrowUp',\n 'End',\n 'Home',\n 'PageDown',\n 'PageUp',\n // Editing\n 'Insert',\n // UI keys\n 'ContextMenu',\n 'Escape',\n 'Pause',\n 'Play',\n // Device keys\n 'PrintScreen',\n // Function keys\n 'F1',\n // 'F2', /!\\ specifically allowed, do not edit\n 'F3',\n 'F4',\n 'F5',\n 'F6',\n 'F7',\n 'F8',\n 'F9',\n 'F10',\n 'F11',\n 'F12'\n]);\n\nexport function isCtrlKeyHeldDown(e: React.KeyboardEvent): boolean {\n return (e.ctrlKey || e.metaKey) && e.key !== 'Control';\n}\n\nexport function isDefaultCellInput(event: React.KeyboardEvent<HTMLDivElement>): boolean {\n const vKey = 86;\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n if (isCtrlKeyHeldDown(event) && event.keyCode !== vKey) return false;\n return !nonInputKeys.has(event.key);\n}\n\n/**\n * By default, the following navigation keys are enabled while an editor is open, under specific conditions:\n * - Tab:\n * - The editor must be an <input>, a <textarea>, or a <select> element.\n * - The editor element must be the only immediate child of the editor container/a label.\n */\nexport function onEditorNavigation({ key, target }: React.KeyboardEvent<HTMLDivElement>): boolean {\n if (\n key === 'Tab' &&\n (target instanceof HTMLInputElement ||\n target instanceof HTMLTextAreaElement ||\n target instanceof HTMLSelectElement)\n ) {\n return (\n target.closest('.rdg-editor-container')?.querySelectorAll('input, textarea, select')\n .length === 1\n );\n }\n return false;\n}\n","import { css } from '@linaria/core';\n\nimport type { CalculatedColumn } from '../types';\n\nconst measuringCellClassname = css`\n @layer rdg.MeasuringCell {\n contain: strict;\n grid-row: 1;\n visibility: hidden;\n }\n`;\n\nexport function renderMeasuringCells<R, SR>(viewportColumns: readonly CalculatedColumn<R, SR>[]) {\n return viewportColumns.map(({ key, idx, minWidth, maxWidth }) => (\n <div\n key={key}\n className={measuringCellClassname}\n style={{ gridColumnStart: idx + 1, minWidth, maxWidth }}\n data-measuring-cell-key={key}\n />\n ));\n}\n","import type {\n CalculatedColumn,\n CalculatedColumnParent,\n CellNavigationMode,\n Maybe,\n Position\n} from '../types';\nimport { getColSpan } from './colSpanUtils';\n\ninterface IsSelectedCellEditableOpts<R, SR> {\n selectedPosition: Position;\n columns: readonly CalculatedColumn<R, SR>[];\n rows: readonly R[];\n}\n\nexport function isSelectedCellEditable<R, SR>({\n selectedPosition,\n columns,\n rows\n}: IsSelectedCellEditableOpts<R, SR>): boolean {\n const column = columns[selectedPosition.idx];\n const row = rows[selectedPosition.rowIdx];\n return isCellEditableUtil(column, row);\n}\n\n// https://github.com/vercel/next.js/issues/56480\nexport function isCellEditableUtil<R, SR>(column: CalculatedColumn<R, SR>, row: R): boolean {\n return (\n column.renderEditCell != null &&\n (typeof column.editable === 'function' ? column.editable(row) : column.editable) !== false\n );\n}\n\ninterface GetNextSelectedCellPositionOpts<R, SR> {\n moveUp: boolean;\n moveNext: boolean;\n cellNavigationMode: CellNavigationMode;\n columns: readonly CalculatedColumn<R, SR>[];\n colSpanColumns: readonly CalculatedColumn<R, SR>[];\n rows: readonly R[];\n topSummaryRows: Maybe<readonly SR[]>;\n bottomSummaryRows: Maybe<readonly SR[]>;\n minRowIdx: number;\n mainHeaderRowIdx: number;\n maxRowIdx: number;\n currentPosition: Position;\n nextPosition: Position;\n lastFrozenColumnIndex: number;\n isCellWithinBounds: (position: Position) => boolean;\n}\n\nfunction getSelectedCellColSpan<R, SR>({\n rows,\n topSummaryRows,\n bottomSummaryRows,\n rowIdx,\n mainHeaderRowIdx,\n lastFrozenColumnIndex,\n column\n}: Pick<\n GetNextSelectedCellPositionOpts<R, SR>,\n 'rows' | 'topSummaryRows' | 'bottomSummaryRows' | 'lastFrozenColumnIndex' | 'mainHeaderRowIdx'\n> & {\n rowIdx: number;\n column: CalculatedColumn<R, SR>;\n}) {\n const topSummaryRowsCount = topSummaryRows?.length ?? 0;\n if (rowIdx === mainHeaderRowIdx) {\n return getColSpan(column, lastFrozenColumnIndex, { type: 'HEADER' });\n }\n\n if (\n topSummaryRows &&\n rowIdx > mainHeaderRowIdx &&\n rowIdx <= topSummaryRowsCount + mainHeaderRowIdx\n ) {\n return getColSpan(column, lastFrozenColumnIndex, {\n type: 'SUMMARY',\n row: topSummaryRows[rowIdx + topSummaryRowsCount]\n });\n }\n\n if (rowIdx >= 0 && rowIdx < rows.length) {\n const row = rows[rowIdx];\n return getColSpan(column, lastFrozenColumnIndex, { type: 'ROW', row });\n }\n\n if (bottomSummaryRows) {\n return getColSpan(column, lastFrozenColumnIndex, {\n type: 'SUMMARY',\n row: bottomSummaryRows[rowIdx - rows.length]\n });\n }\n\n return undefined;\n}\n\nexport function getNextSelectedCellPosition<R, SR>({\n moveUp,\n moveNext,\n cellNavigationMode,\n columns,\n colSpanColumns,\n rows,\n topSummaryRows,\n bottomSummaryRows,\n minRowIdx,\n mainHeaderRowIdx,\n maxRowIdx,\n currentPosition: { idx: currentIdx, rowIdx: currentRowIdx },\n nextPosition,\n lastFrozenColumnIndex,\n isCellWithinBounds\n}: GetNextSelectedCellPositionOpts<R, SR>): Position {\n let { idx: nextIdx, rowIdx: nextRowIdx } = nextPosition;\n const columnsCount = columns.length;\n\n const setColSpan = (moveNext: boolean) => {\n // If a cell within the colspan range is selected then move to the\n // previous or the next cell depending on the navigation direction\n for (const column of colSpanColumns) {\n const colIdx = column.idx;\n if (colIdx > nextIdx) break;\n const colSpan = getSelectedCellColSpan({\n rows,\n topSummaryRows,\n bottomSummaryRows,\n rowIdx: nextRowIdx,\n mainHeaderRowIdx,\n lastFrozenColumnIndex,\n column\n });\n\n if (colSpan && nextIdx > colIdx && nextIdx < colSpan + colIdx) {\n nextIdx = colIdx + (moveNext ? colSpan : 0);\n break;\n }\n }\n };\n\n const getParentRowIdx = (parent: CalculatedColumnParent<R, SR>) => {\n return parent.level + mainHeaderRowIdx;\n };\n\n const setHeaderGroupColAndRowSpan = () => {\n if (moveNext) {\n // find the parent at the same row level\n const nextColumn = columns[nextIdx];\n let parent = nextColumn.parent;\n while (parent !== undefined) {\n const parentRowIdx = getParentRowIdx(parent);\n if (nextRowIdx === parentRowIdx) {\n nextIdx = parent.idx + parent.colSpan;\n break;\n }\n parent = parent.parent;\n }\n } else if (moveUp) {\n // find the first reachable parent\n const nextColumn = columns[nextIdx];\n let parent = nextColumn.parent;\n let found = false;\n while (parent !== undefined) {\n const parentRowIdx = getParentRowIdx(parent);\n if (nextRowIdx >= parentRowIdx) {\n nextIdx = parent.idx;\n nextRowIdx = parentRowIdx;\n found = true;\n break;\n }\n parent = parent.parent;\n }\n\n // keep the current position if there is no parent matching the new row position\n if (!found) {\n nextIdx = currentIdx;\n nextRowIdx = currentRowIdx;\n }\n }\n };\n\n if (isCellWithinBounds(nextPosition)) {\n setColSpan(moveNext);\n\n if (nextRowIdx < mainHeaderRowIdx) {\n setHeaderGroupColAndRowSpan();\n }\n }\n\n if (cellNavigationMode === 'CHANGE_ROW') {\n const isAfterLastColumn = nextIdx === columnsCount;\n const isBeforeFirstColumn = nextIdx === -1;\n\n if (isAfterLastColumn) {\n const isLastRow = nextRowIdx === maxRowIdx;\n if (!isLastRow) {\n nextIdx = 0;\n nextRowIdx += 1;\n }\n } else if (isBeforeFirstColumn) {\n const isFirstRow = nextRowIdx === minRowIdx;\n if (!isFirstRow) {\n nextRowIdx -= 1;\n nextIdx = columnsCount - 1;\n }\n setColSpan(false);\n }\n }\n\n if (nextRowIdx < mainHeaderRowIdx) {\n // Find the last reachable parent for the new rowIdx\n // This check is needed when navigating to a column\n // that does not have a parent matching the new rowIdx\n const nextColumn = columns[nextIdx];\n let parent = nextColumn.parent;\n const nextParentRowIdx = nextRowIdx;\n nextRowIdx = mainHeaderRowIdx;\n while (parent !== undefined) {\n const parentRowIdx = getParentRowIdx(parent);\n if (parentRowIdx >= nextParentRowIdx) {\n nextRowIdx = parentRowIdx;\n nextIdx = parent.idx;\n }\n parent = parent.parent;\n }\n }\n\n return { idx: nextIdx, rowIdx: nextRowIdx };\n}\n\ninterface CanExitGridOpts {\n maxColIdx: number;\n minRowIdx: number;\n maxRowIdx: number;\n selectedPosition: Position;\n shiftKey: boolean;\n}\n\nexport function canExitGrid({\n maxColIdx,\n minRowIdx,\n maxRowIdx,\n selectedPosition: { rowIdx, idx },\n shiftKey\n}: CanExitGridOpts): boolean {\n // Exit the grid if we're at the first or last cell of the grid\n const atLastCellInRow = idx === maxColIdx;\n const atFirstCellInRow = idx === 0;\n const atLastRow = rowIdx === maxRowIdx;\n const atFirstRow = rowIdx === minRowIdx;\n\n return shiftKey ? atFirstCellInRow && atFirstRow : atLastCellInRow && atLastRow;\n}\n","import { css } from '@linaria/core';\n\nexport const cell = css`\n @layer rdg.Cell {\n /* max-content does not work with size containment\n * dynamically switching between different containment styles incurs a heavy relayout penalty\n * Chromium bug: at odd zoom levels or subpixel positioning,\n * layout/paint/style containment can make cell borders disappear\n * https://bugs.chromium.org/p/chromium/issues/detail?id=1326946\n */\n position: relative; /* needed for absolute positioning to work */\n padding-block: 0;\n padding-inline: 8px;\n border-inline-end: 1px solid var(--rdg-border-color);\n border-block-end: 1px solid var(--rdg-border-color);\n grid-row-start: var(--rdg-grid-row-start);\n align-content: center;\n background-color: inherit;\n\n white-space: nowrap;\n overflow: clip;\n text-overflow: ellipsis;\n outline: none;\n\n &[aria-selected='true'] {\n outline: 2px solid var(--rdg-selection-color);\n outline-offset: -2px;\n }\n }\n`;\n\nexport const cellClassname = `rdg-cell ${cell}`;\n\nexport const cellFrozen = css`\n @layer rdg.Cell {\n position: sticky;\n /* Should have a higher value than 0 to show up above unfrozen cells */\n z-index: 1;\n\n /* Add box-shadow on the last frozen cell */\n &:nth-last-child(1 of &) {\n box-shadow: var(--rdg-cell-frozen-box-shadow);\n }\n }\n`;\n\nexport const cellFrozenClassname = `rdg-cell-frozen ${cellFrozen}`;\n","import type { CSSProperties } from 'react';\nimport clsx from 'clsx';\n\nimport type { CalculatedColumn, CalculatedColumnOrColumnGroup } from '../types';\nimport { cellClassname, cellFrozenClassname } from '../style/cell';\n\nexport function getRowStyle(rowIdx: number): CSSProperties {\n return { '--rdg-grid-row-start': rowIdx } as unknown as CSSProperties;\n}\n\nexport function getHeaderCellStyle<R, SR>(\n column: CalculatedColumnOrColumnGroup<R, SR>,\n rowIdx: number,\n rowSpan: number\n): React.CSSProperties {\n const gridRowEnd = rowIdx + 1;\n const paddingBlockStart = `calc(${rowSpan - 1} * var(--rdg-header-row-height))`;\n\n if (column.parent === undefined) {\n return {\n insetBlockStart: 0,\n gridRowStart: 1,\n gridRowEnd,\n paddingBlockStart\n };\n }\n\n return {\n insetBlockStart: `calc(${rowIdx - rowSpan} * var(--rdg-header-row-height))`,\n gridRowStart: gridRowEnd - rowSpan,\n gridRowEnd,\n paddingBlockStart\n };\n}\n\nexport function getCellStyle<R, SR>(\n column: CalculatedColumn<R, SR>,\n colSpan = 1\n): React.CSSProperties {\n const index = column.idx + 1;\n return {\n gridColumnStart: index,\n gridColumnEnd: index + colSpan,\n insetInlineStart: column.frozen ? `var(--rdg-frozen-left-${column.idx})` : undefined\n };\n}\n\nexport function getCellClassname<R, SR>(\n column: CalculatedColumn<R, SR>,\n ...extraClasses: Parameters<typeof clsx>\n): string {\n return clsx(\n cellClassname,\n {\n [cellFrozenClassname]: column.frozen\n },\n ...extraClasses\n );\n}\n","import type { CalculatedColumn, CalculatedColumnOrColumnGroup, Maybe } from '../types';\n\nexport * from './colSpanUtils';\nexport * from './domUtils';\nexport * from './eventUtils';\nexport * from './keyboardUtils';\nexport * from './renderMeasuringCells';\nexport * from './selectedCellUtils';\nexport * from './styleUtils';\n\nexport const { min, max, floor, sign, abs } = Math;\n\nexport function assertIsValidKeyGetter<R, K extends React.Key>(\n keyGetter: Maybe<(row: NoInfer<R>) => K>\n): asserts keyGetter is (row: R) => K {\n if (typeof keyGetter !== 'function') {\n throw new Error('Please specify the rowKeyGetter prop to use selection');\n }\n}\n\nexport function clampColumnWidth<R, SR>(\n width: number,\n { minWidth, maxWidth }: CalculatedColumn<R, SR>\n): number {\n width = max(width, minWidth);\n\n // ignore maxWidth if it less than minWidth\n if (typeof maxWidth === 'number' && maxWidth >= minWidth) {\n return min(width, maxWidth);\n }\n\n return width;\n}\n\nexport function getHeaderCellRowSpan<R, SR>(\n column: CalculatedColumnOrColumnGroup<R, SR>,\n rowIdx: number\n) {\n return column.parent === undefined ? rowIdx : column.level - column.parent.level;\n}\n","import { css } from '@linaria/core';\n\nimport type { RenderCheckboxProps } from '../types';\n\nconst checkbox = css`\n @layer rdg.CheckboxInput {\n display: block;\n margin: auto;\n inline-size: 20px;\n block-size: 20px;\n\n &:focus-visible {\n outline: 2px solid var(--rdg-checkbox-focus-color);\n outline-offset: -3px;\n }\n\n &:enabled {\n cursor: pointer;\n }\n }\n`;\n\nconst checkboxClassname = `rdg-checkbox-input ${checkbox}`;\n\nexport function renderCheckbox({ onChange, indeterminate, ...props }: RenderCheckboxProps) {\n function handleChange(e: React.ChangeEvent<HTMLInputElement>) {\n onChange(e.target.checked, (e.nativeEvent as MouseEvent).shiftKey);\n }\n\n return (\n <input\n ref={(el) => {\n if (el) {\n el.indeterminate = indeterminate === true;\n }\n }}\n type=\"checkbox\"\n className={checkboxClassname}\n onChange={handleChange}\n {...props}\n />\n );\n}\n","import { css } from '@linaria/core';\n\nimport type { RenderGroupCellProps } from '../types';\n\nconst groupCellContent = css`\n @layer rdg.GroupCellContent {\n outline: none;\n }\n`;\n\nconst groupCellContentClassname = `rdg-group-cell-content ${groupCellContent}`;\n\nconst caret = css`\n @layer rdg.GroupCellCaret {\n margin-inline-start: 4px;\n stroke: currentColor;\n stroke-width: 1.5px;\n fill: transparent;\n vertical-align: middle;\n\n > path {\n transition: d 0.1s;\n }\n }\n`;\n\nconst caretClassname = `rdg-caret ${caret}`;\n\nexport function renderToggleGroup<R, SR>(props: RenderGroupCellProps<R, SR>) {\n return <ToggleGroup {...props} />;\n}\n\nexport function ToggleGroup<R, SR>({\n groupKey,\n isExpanded,\n tabIndex,\n toggleGroup\n}: RenderGroupCellProps<R, SR>) {\n function handleKeyDown({ key }: React.KeyboardEvent<HTMLSpanElement>) {\n if (key === 'Enter') {\n toggleGroup();\n }\n }\n\n const d = isExpanded ? 'M1 1 L 7 7 L 13 1' : 'M1 7 L 7 1 L 13 7';\n\n return (\n <span className={groupCellContentClassname} tabIndex={tabIndex} onKeyDown={handleKeyDown}>\n {groupKey as string}\n <svg viewBox=\"0 0 14 8\" width=\"14\" height=\"8\" className={caretClassname} aria-hidden>\n <path d={d} />\n </svg>\n </span>\n );\n}\n","import type { RenderCellProps } from '../types';\n\nexport function renderValue<R, SR>(props: RenderCellProps<R, SR>) {\n try {\n return props.row[props.column.key as keyof R] as React.ReactNode;\n } catch {\n return null;\n }\n}\n","import { createContext, useContext } from 'react';\n\nimport type { Maybe, Renderers } from './types';\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst DataGridDefaultRenderersContext = createContext<Maybe<Renderers<any, any>>>(undefined);\n\nexport const DataGridDefaultRenderersProvider = DataGridDefaultRenderersContext.Provider;\n\nexport function useDefaultRenderers<R, SR>(): Maybe<Renderers<R, SR>> {\n return useContext(DataGridDefaultRenderersContext);\n}\n","import type { RenderCheckboxProps } from '../types';\nimport { useDefaultRenderers } from '../DataGridDefaultRenderersProvider';\n\ntype SharedInputProps = Pick<\n RenderCheckboxProps,\n 'disabled' | 'tabIndex' | 'aria-label' | 'aria-labelledby' | 'indeterminate' | 'onChange'\n>;\n\ninterface SelectCellFormatterProps extends SharedInputProps {\n value: boolean;\n}\n\nexport function SelectCellFormatter({\n value,\n tabIndex,\n indeterminate,\n disabled,\n onChange,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy\n}: SelectCellFormatterProps) {\n const renderCheckbox = useDefaultRenderers()!.renderCheckbox!;\n\n return renderCheckbox({\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n tabIndex,\n indeterminate,\n disabled,\n checked: value,\n onChange\n });\n}\n","import { createContext, useContext } from 'react';\n\nimport type { SelectHeaderRowEvent, SelectRowEvent } from '../types';\n\nexport interface RowSelectionContextValue {\n readonly isRowSelected: boolean;\n readonly isRowSelectionDisabled: boolean;\n}\n\nconst RowSelectionContext = createContext<RowSelectionContextValue | undefined>(undefined);\n\nexport const RowSelectionProvider = RowSelectionContext.Provider;\n\nconst RowSelectionChangeContext = createContext<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ((selectRowEvent: SelectRowEvent<any>) => void) | undefined\n>(undefined);\n\nexport const RowSelectionChangeProvider = RowSelectionChangeContext.Provider;\n\nexport function useRowSelection() {\n const rowSelectionContext = useContext(RowSelectionContext);\n const rowSelectionChangeContext = useContext(RowSelectionChangeContext);\n\n if (rowSelectionContext === undefined || rowSelectionChangeContext === undefined) {\n throw new Error('useRowSelection must be used within renderCell');\n }\n\n return {\n isRowSelectionDisabled: rowSelectionContext.isRowSelectionDisabled,\n isRowSelected: rowSelectionContext.isRowSelected,\n onRowSelectionChange: rowSelectionChangeContext\n };\n}\n\nexport interface HeaderRowSelectionContextValue {\n readonly isRowSelected: boolean;\n readonly isIndeterminate: boolean;\n}\n\nconst HeaderRowSelectionContext = createContext<HeaderRowSelectionContextValue | undefined>(\n undefined\n);\n\nexport const HeaderRowSelectionProvider = HeaderRowSelectionContext.Provider;\n\nconst HeaderRowSelectionChangeContext = createContext<\n ((selectRowEvent: SelectHeaderRowEvent) => void) | undefined\n>(undefined);\n\nexport const HeaderRowSelectionChangeProvider = HeaderRowSelectionChangeContext.Provider;\n\nexport function useHeaderRowSelection() {\n const headerRowSelectionContext = useContext(HeaderRowSelectionContext);\n const headerRowSelectionChangeContext = useContext(HeaderRowSelectionChangeContext);\n\n if (headerRowSelectionContext === undefined || headerRowSelectionChangeContext === undefined) {\n throw new Error('useHeaderRowSelection must be used within renderHeaderCell');\n }\n\n return {\n isIndeterminate: headerRowSelectionContext.isIndeterminate,\n isRowSelected: headerRowSelectionContext.isRowSelected,\n onRowSelectionChange: headerRowSelectionChangeContext\n };\n}\n","import { useHeaderRowSelection, useRowSelection } from './hooks/useRowSelection';\nimport type { Column, RenderCellProps, RenderGroupCellProps, RenderHeaderCellProps } from './types';\nimport { SelectCellFormatter } from './cellRenderers';\n\nexport const SELECT_COLUMN_KEY = 'rdg-select-column';\n\nfunction HeaderRenderer(props: RenderHeaderCellProps<unknown>) {\n const { isIndeterminate, isRowSelected, onRowSelectionChange } = useHeaderRowSelection();\n\n return (\n <SelectCellFormatter\n aria-label=\"Select All\"\n tabIndex={props.tabIndex}\n indeterminate={isIndeterminate}\n value={isRowSelected}\n onChange={(checked) => {\n onRowSelectionChange({ checked: isIndeterminate ? false : checked });\n }}\n />\n );\n}\n\nfunction SelectFormatter(props: RenderCellProps<unknown>) {\n const { isRowSelectionDisabled, isRowSelected, onRowSelectionChange } = useRowSelection();\n\n return (\n <SelectCellFormatter\n aria-label=\"Select\"\n tabIndex={props.tabIndex}\n disabled={isRowSelectionDisabled}\n value={isRowSelected}\n onChange={(checked, isShiftClick) => {\n onRowSelectionChange({ row: props.row, checked, isShiftClick });\n }}\n />\n );\n}\n\nfunction SelectGroupFormatter(props: RenderGroupCellProps<unknown>) {\n const { isRowSelected, onRowSelectionChange } = useRowSelection();\n\n return (\n <SelectCellFormatter\n aria-label=\"Select Group\"\n tabIndex={props.tabIndex}\n value={isRowSelected}\n onChange={(checked) => {\n onRowSelectionChange({ row: props.row, checked, isShiftClick: false });\n }}\n />\n );\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const SelectColumn: Column<any, any> = {\n key: SELECT_COLUMN_KEY,\n name: '',\n width: 35,\n minWidth: 35,\n maxWidth: 35,\n resizable: false,\n sortable: false,\n frozen: true,\n renderHeaderCell(props) {\n return <HeaderRenderer {...props} />;\n },\n renderCell(props) {\n return <SelectFormatter {...props} />;\n },\n renderGroupCell(props) {\n return <SelectGroupFormatter {...props} />;\n }\n};\n","import { useMemo } from 'react';\n\nimport { clampColumnWidth, max, min } from '../utils';\nimport type { CalculatedColumn, CalculatedColumnParent, ColumnOrColumnGroup, Omit } from '../types';\nimport { renderValue } from '../cellRenderers';\nimport { SELECT_COLUMN_KEY } from '../Columns';\nimport type { DataGridProps } from '../DataGrid';\n\ntype Mutable<T> = {\n -readonly [P in keyof T]: T[P] extends ReadonlyArray<infer V> ? Mutable<V>[] : T[P];\n};\n\ninterface WithParent<R, SR> {\n readonly parent: MutableCalculatedColumnParent<R, SR> | undefined;\n}\n\ntype MutableCalculatedColumnParent<R, SR> = Omit<Mutable<CalculatedColumnParent<R, SR>>, 'parent'> &\n WithParent<R, SR>;\ntype MutableCalculatedColumn<R, SR> = Omit<Mutable<CalculatedColumn<R, SR>>, 'parent'> &\n WithParent<R, SR>;\n\ninterface ColumnMetric {\n width: number;\n left: number;\n}\n\nconst DEFAULT_COLUMN_WIDTH = 'auto';\nconst DEFAULT_COLUMN_MIN_WIDTH = 50;\n\ninterface CalculatedColumnsArgs<R, SR> {\n rawColumns: readonly ColumnOrColumnGroup<R, SR>[];\n defaultColumnOptions: DataGridProps<R, SR>['defaultColumnOptions'];\n viewportWidth: number;\n scrollLeft: number;\n getColumnWidth: (column: CalculatedColumn<R, SR>) => string | number;\n enableVirtualization: boolean;\n}\n\nexport function useCalculatedColumns<R, SR>({\n rawColumns,\n defaultColumnOptions,\n getColumnWidth,\n viewportWidth,\n scrollLeft,\n enableVirtualization\n}: CalculatedColumnsArgs<R, SR>) {\n const defaultWidth = defaultColumnOptions?.width ?? DEFAULT_COLUMN_WIDTH;\n const defaultMinWidth = defaultColumnOptions?.minWidth ?? DEFAULT_COLUMN_MIN_WIDTH;\n const defaultMaxWidth = defaultColumnOptions?.maxWidth ?? undefined;\n const defaultCellRenderer = defaultColumnOptions?.renderCell ?? renderValue;\n const defaultSortable = defaultColumnOptions?.sortable ?? false;\n const defaultResizable = defaultColumnOptions?.resizable ?? false;\n const defaultDraggable = defaultColumnOptions?.draggable ?? false;\n\n const { columns, colSpanColumns, lastFrozenColumnIndex, headerRowsCount } = useMemo((): {\n readonly columns: readonly CalculatedColumn<R, SR>[];\n readonly colSpanColumns: readonly CalculatedColumn<R, SR>[];\n readonly lastFrozenColumnIndex: number;\n readonly headerRowsCount: number;\n } => {\n let lastFrozenColumnIndex = -1;\n let headerRowsCount = 1;\n const columns: MutableCalculatedColumn<R, SR>[] = [];\n\n collectColumns(rawColumns, 1);\n\n function collectColumns(\n rawColumns: readonly ColumnOrColumnGroup<R, SR>[],\n level: number,\n parent?: MutableCalculatedColumnParent<R, SR>\n ) {\n for (const rawColumn of rawColumns) {\n if ('children' in rawColumn) {\n const calculatedColumnParent: MutableCalculatedColumnParent<R, SR> = {\n name: rawColumn.name,\n parent,\n idx: -1,\n colSpan: 0,\n level: 0,\n headerCellClass: rawColumn.headerCellClass\n };\n\n collectColumns(rawColumn.children, level + 1, calculatedColumnParent);\n continue;\n }\n\n const frozen = rawColumn.frozen ?? false;\n\n const column: MutableCalculatedColumn<R, SR> = {\n ...rawColumn,\n parent,\n idx: 0,\n level: 0,\n frozen,\n width: rawColumn.width ?? defaultWidth,\n minWidth: rawColumn.minWidth ?? defaultMinWidth,\n maxWidth: rawColumn.maxWidth ?? defaultMaxWidth,\n sortable: rawColumn.sortable ?? defaultSortable,\n resizable: rawColumn.resizable ?? defaultResizable,\n draggable: rawColumn.draggable ?? defaultDraggable,\n renderCell: rawColumn.renderCell ?? defaultCellRenderer\n };\n\n columns.push(column);\n\n if (frozen) {\n lastFrozenColumnIndex++;\n }\n\n if (level > headerRowsCount) {\n headerRowsCount = level;\n }\n }\n }\n\n columns.sort(({ key: aKey, frozen: frozenA }, { key: bKey, frozen: frozenB }) => {\n // Sort select column first:\n if (aKey === SELECT_COLUMN_KEY) return -1;\n if (bKey === SELECT_COLUMN_KEY) return 1;\n\n // Sort frozen columns second:\n if (frozenA) {\n if (frozenB) return 0;\n return -1;\n }\n if (frozenB) return 1;\n\n // TODO: sort columns to keep them grouped if they have a parent\n\n // Sort other columns last:\n return 0;\n });\n\n const colSpanColumns: CalculatedColumn<R, SR>[] = [];\n columns.forEach((column, idx) => {\n column.idx = idx;\n updateColumnParent(column, idx, 0);\n\n if (column.colSpan != null) {\n colSpanColumns.push(column);\n }\n });\n\n return {\n columns,\n colSpanColumns,\n lastFrozenColumnIndex,\n headerRowsCount\n };\n }, [\n rawColumns,\n defaultWidth,\n defaultMinWidth,\n defaultMaxWidth,\n defaultCellRenderer,\n defaultResizable,\n defaultSortable,\n defaultDraggable\n ]);\n\n const { templateColumns, layoutCssVars, totalFrozenColumnWidth, columnMetrics } = useMemo((): {\n templateColumns: readonly string[];\n layoutCssVars: Readonly<Record<string, string>>;\n totalFrozenColumnWidth: number;\n columnMetrics: ReadonlyMap<CalculatedColumn<R, SR>, ColumnMetric>;\n } => {\n const columnMetrics = new Map<CalculatedColumn<R, SR>, ColumnMetric>();\n let left = 0;\n let totalFrozenColumnWidth = 0;\n const templateColumns: string[] = [];\n\n for (const column of columns) {\n let width = getColumnWidth(column);\n\n if (typeof width === 'number') {\n width = clampColumnWidth(width, column);\n } else {\n // This is a placeholder width so we can continue to use virtualization.\n // The actual value is set after the column is rendered\n width = column.minWidth;\n }\n templateColumns.push(`${width}px`);\n columnMetrics.set(column, { width, left });\n left += width;\n }\n\n if (lastFrozenColumnIndex !== -1) {\n const columnMetric = columnMetrics.get(columns[lastFrozenColumnIndex])!;\n totalFrozenColumnWidth = columnMetric.left + columnMetric.width;\n }\n\n const layoutCssVars: Record<string, string> = {};\n\n for (let i = 0; i <= lastFrozenColumnIndex; i++) {\n const column = columns[i];\n layoutCssVars[`--rdg-frozen-left-${column.idx}`] = `${columnMetrics.get(column)!.left}px`;\n }\n\n return { templateColumns, layoutCssVars, totalFrozenColumnWidth, columnMetrics };\n }, [getColumnWidth, columns, lastFrozenColumnIndex]);\n\n const [colOverscanStartIdx, colOverscanEndIdx] = useMemo((): [number, number] => {\n if (!enableVirtualization) {\n return [0, columns.length - 1];\n }\n // get the viewport's left side and right side positions for non-frozen columns\n const viewportLeft = scrollLeft + totalFrozenColumnWidth;\n const viewportRight = scrollLeft + viewportWidth;\n // get first and last non-frozen column indexes\n const lastColIdx = columns.length - 1;\n const firstUnfrozenColumnIdx = min(lastFrozenColumnIndex + 1, lastColIdx);\n\n // skip rendering non-frozen columns if the frozen columns cover the entire viewport\n if (viewportLeft >= viewportRight) {\n return [firstUnfrozenColumnIdx, firstUnfrozenColumnIdx];\n }\n\n // get the first visible non-frozen column index\n let colVisibleStartIdx = firstUnfrozenColumnIdx;\n while (colVisibleStartIdx < lastColIdx) {\n const { left, width } = columnMetrics.get(columns[colVisibleStartIdx])!;\n // if the right side of the columnn is beyond the left side of the available viewport,\n // then it is the first column that's at least partially visible\n if (left + width > viewportLeft) {\n break;\n }\n colVisibleStartIdx++;\n }\n\n // get the last visible non-frozen column index\n let colVisibleEndIdx = colVisibleStartIdx;\n while (colVisibleEndIdx < lastColIdx) {\n const { left, width } = columnMetrics.get(columns[colVisibleEndIdx])!;\n // if the right side of the column is beyond or equal to the right side of the available viewport,\n // then it the last column that's at least partially visible, as the previous column's right side is not beyond the viewport.\n if (left + width >= viewportRight) {\n break;\n }\n colVisibleEndIdx++;\n }\n\n const colOverscanStartIdx = max(firstUnfrozenColumnIdx, colVisibleStartIdx - 1);\n const colOverscanEndIdx = min(lastColIdx, colVisibleEndIdx + 1);\n\n return [colOverscanStartIdx, colOverscanEndIdx];\n }, [\n columnMetrics,\n columns,\n lastFrozenColumnIndex,\n scrollLeft,\n totalFrozenColumnWidth,\n viewportWidth,\n enableVirtualization\n ]);\n\n return {\n columns,\n colSpanColumns,\n colOverscanStartIdx,\n colOverscanEndIdx,\n templateColumns,\n layoutCssVars,\n headerRowsCount,\n lastFrozenColumnIndex,\n totalFrozenColumnWidth\n };\n}\n\nfunction updateColumnParent<R, SR>(\n column: MutableCalculatedColumn<R, SR> | MutableCalculatedColumnParent<R, SR>,\n index: number,\n level: number\n) {\n if (level < column.level) {\n column.level = level;\n }\n\n if (column.parent !== undefined) {\n const { parent } = column;\n if (parent.idx === -1) {\n parent.idx = index;\n }\n parent.colSpan += 1;\n updateColumnParent(parent, index, level - 1);\n }\n}\n","// eslint-disable-next-line @typescript-eslint/no-restricted-imports\nimport { useEffect, useLayoutEffect as useOriginalLayoutEffect } from 'react';\n\n// Silence silly warning\n// https://reactjs.org/link/uselayouteffect-ssr\nexport const useLayoutEffect = typeof window === 'undefined' ? useEffect : useOriginalLayoutEffect;\n","import { useRef } from 'react';\nimport { flushSync } from 'react-dom';\n\nimport type { CalculatedColumn, StateSetter } from '../types';\nimport { useLayoutEffect } from './useLayoutEffect';\nimport type { DataGridProps } from '../DataGrid';\n\nexport function useColumnWidths<R, SR>(\n columns: readonly CalculatedColumn<R, SR>[],\n viewportColumns: readonly CalculatedColumn<R, SR>[],\n templateColumns: readonly string[],\n gridRef: React.RefObject<HTMLDivElement | null>,\n gridWidth: number,\n resizedColumnWidths: ReadonlyMap<string, number>,\n measuredColumnWidths: ReadonlyMap<string, number>,\n setResizedColumnWidths: StateSetter<ReadonlyMap<string, number>>,\n setMeasuredColumnWidths: StateSetter<ReadonlyMap<string, number>>,\n onColumnResize: DataGridProps<R, SR>['onColumnResize']\n) {\n const prevGridWidthRef = useRef(gridWidth);\n const columnsCanFlex: boolean = columns.length === viewportColumns.length;\n // Allow columns to flex again when...\n const ignorePreviouslyMeasuredColumns: boolean =\n // there is enough space for columns to flex and the grid was resized\n columnsCanFlex && gridWidth !== prevGridWidthRef.current;\n const newTemplateColumns = [...templateColumns];\n const columnsToMeasure: string[] = [];\n\n for (const { key, idx, width } of viewportColumns) {\n if (\n typeof width === 'string' &&\n (ignorePreviouslyMeasuredColumns || !measuredColumnWidths.has(key)) &&\n !resizedColumnWidths.has(key)\n ) {\n newTemplateColumns[idx] = width;\n columnsToMeasure.push(key);\n }\n }\n\n const gridTemplateColumns = newTemplateColumns.join(' ');\n\n useLayoutEffect(() => {\n prevGridWidthRef.current = gridWidth;\n updateMeasuredWidths(columnsToMeasure);\n });\n\n function updateMeasuredWidths(columnsToMeasure: readonly string[]) {\n if (columnsToMeasure.length === 0) return;\n\n setMeasuredColumnWidths((measuredColumnWidths) => {\n const newMeasuredColumnWidths = new Map(measuredColumnWidths);\n let hasChanges = false;\n\n for (const key of columnsToMeasure) {\n const measuredWidth = measureColumnWidth(gridRef, key);\n hasChanges ||= measuredWidth !== measuredColumnWidths.get(key);\n if (measuredWidth === undefined) {\n newMeasuredColumnWidths.delete(key);\n } else {\n newMeasuredColumnWidths.set(key, measuredWidth);\n }\n }\n\n return hasChanges ? newMeasuredColumnWidths : measuredColumnWidths;\n });\n }\n\n function handleColumnResize(column: CalculatedColumn<R, SR>, nextWidth: number | 'max-content') {\n const { key: resizingKey } = column;\n const newTemplateColumns = [...templateColumns];\n const columnsToMeasure: string[] = [];\n\n for (const { key, idx, width } of viewportColumns) {\n if (resizingKey === key) {\n const width = typeof nextWidth === 'number' ? `${nextWidth}px` : nextWidth;\n newTemplateColumns[idx] = width;\n } else if (columnsCanFlex && typeof width === 'string' && !resizedColumnWidths.has(key)) {\n newTemplateColumns[idx] = width;\n columnsToMeasure.push(key);\n }\n }\n\n gridRef.current!.style.gridTemplateColumns = newTemplateColumns.join(' ');\n const measuredWidth =\n typeof nextWidth === 'number' ? nextWidth : measureColumnWidth(gridRef, resizingKey)!;\n\n // TODO: remove\n // need flushSync to keep frozen column offsets in sync\n // we may be able to use `startTransition` or even `requestIdleCallback` instead\n flushSync(() => {\n setResizedColumnWidths((resizedColumnWidths) => {\n const newResizedColumnWidths = new Map(resizedColumnWidths);\n newResizedColumnWidths.set(resizingKey, measuredWidth);\n return newResizedColumnWidths;\n });\n updateMeasuredWidths(columnsToMeasure);\n });\n\n onColumnResize?.(column, measuredWidth);\n }\n\n return {\n gridTemplateColumns,\n handleColumnResize\n } as const;\n}\n\nfunction measureColumnWidth(gridRef: React.RefObject<HTMLDivElement | null>, key: string) {\n const selector = `[data-measuring-cell-key=\"${CSS.escape(key)}\"]`;\n const measuringCell = gridRef.current?.querySelector(selector);\n return measuringCell?.getBoundingClientRect().width;\n}\n","import { useRef, useState } from 'react';\nimport { flushSync } from 'react-dom';\n\nimport { useLayoutEffect } from './useLayoutEffect';\n\nexport function useGridDimensions() {\n const gridRef = useRef<HTMLDivElement>(null);\n const [inlineSize, setInlineSize] = useState(1);\n const [blockSize, setBlockSize] = useState(1);\n const [horizontalScrollbarHeight, setHorizontalScrollbarHeight] = useState(0);\n\n useLayoutEffect(() => {\n const { ResizeObserver } = window;\n\n // don't break in Node.js (SSR), jsdom, and browsers that don't support ResizeObserver\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (ResizeObserver == null) return;\n\n const { clientWidth, clientHeight, offsetWidth, offsetHeight } = gridRef.current!;\n const { width, height } = gridRef.current!.getBoundingClientRect();\n const initialHorizontalScrollbarHeight = offsetHeight - clientHeight;\n const initialWidth = width - offsetWidth + clientWidth;\n const initialHeight = height - initialHorizontalScrollbarHeight;\n\n setInlineSize(initialWidth);\n setBlockSize(initialHeight);\n setHorizontalScrollbarHeight(initialHorizontalScrollbarHeight);\n\n const resizeObserver = new ResizeObserver((entries) => {\n const size = entries[0].contentBoxSize[0];\n const { clientHeight, offsetHeight } = gridRef.current!;\n\n // we use flushSync here to avoid flashing scrollbars\n flushSync(() => {\n setInlineSize(size.inlineSize);\n setBlockSize(size.blockSize);\n setHorizontalScrollbarHeight(offsetHeight - clientHeight);\n });\n });\n resizeObserver.observe(gridRef.current!);\n\n return () => {\n resizeObserver.disconnect();\n };\n }, []);\n\n return [gridRef, inlineSize, blockSize, horizontalScrollbarHeight] as const;\n}\n","import { useCallback, useEffect, useRef } from 'react';\n\nimport type { Maybe } from '../types';\n\n// https://reactjs.org/docs/hooks-faq.html#what-can-i-do-if-my-effect-dependencies-change-too-often\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function useLatestFunc<T extends Maybe<(...args: any[]) => any>>(fn: T): T {\n const ref = useRef(fn);\n\n useEffect(() => {\n ref.current = fn;\n });\n\n const callbackFn = useCallback((...args: Parameters<NonNullable<T>>) => {\n ref.current!(...args);\n }, []);\n\n // @ts-expect-error\n return fn ? callbackFn : fn;\n}\n","import { useState } from 'react';\n\n// https://www.w3.org/TR/wai-aria-practices-1.1/#kbd_roving_tabindex\nexport function useRovingTabIndex(isSelected: boolean) {\n // https://www.w3.org/TR/wai-aria-practices-1.1/#gridNav_focus\n const [isChildFocused, setIsChildFocused] = useState(false);\n\n if (isChildFocused && !isSelected) {\n setIsChildFocused(false);\n }\n\n function onFocus(event: React.FocusEvent<HTMLDivElement>) {\n if (event.target !== event.currentTarget) {\n setIsChildFocused(true);\n }\n }\n\n const isFocusable = isSelected && !isChildFocused;\n\n return {\n tabIndex: isFocusable ? 0 : -1,\n childTabIndex: isSelected ? 0 : -1,\n onFocus: isSelected ? onFocus : undefined\n };\n}\n","import { useMemo } from 'react';\n\nimport { getColSpan } from '../utils';\nimport type { CalculatedColumn, Maybe } from '../types';\n\ninterface ViewportColumnsArgs<R, SR> {\n columns: readonly CalculatedColumn<R, SR>[];\n colSpanColumns: readonly CalculatedColumn<R, SR>[];\n rows: readonly R[];\n topSummaryRows: Maybe<readonly SR[]>;\n bottomSummaryRows: Maybe<readonly SR[]>;\n colOverscanStartIdx: number;\n colOverscanEndIdx: number;\n lastFrozenColumnIndex: number;\n rowOverscanStartIdx: number;\n rowOverscanEndIdx: number;\n}\n\nexport function useViewportColumns<R, SR>({\n columns,\n colSpanColumns,\n rows,\n topSummaryRows,\n bottomSummaryRows,\n colOverscanStartIdx,\n colOverscanEndIdx,\n lastFrozenColumnIndex,\n rowOverscanStartIdx,\n rowOverscanEndIdx\n}: ViewportColumnsArgs<R, SR>) {\n // find the column that spans over a column within the visible columns range and adjust colOverscanStartIdx\n const startIdx = useMemo(() => {\n if (colOverscanStartIdx === 0) return 0;\n\n let startIdx = colOverscanStartIdx;\n\n const updateStartIdx = (colIdx: number, colSpan: number | undefined) => {\n if (colSpan !== undefined && colIdx + colSpan > colOverscanStartIdx) {\n // eslint-disable-next-line react-compiler/react-compiler\n startIdx = colIdx;\n return true;\n }\n return false;\n };\n\n for (const column of colSpanColumns) {\n // check header row\n const colIdx = column.idx;\n if (colIdx >= startIdx) break;\n if (updateStartIdx(colIdx, getColSpan(column, lastFrozenColumnIndex, { type: 'HEADER' }))) {\n break;\n }\n\n // check viewport rows\n for (let rowIdx = rowOverscanStartIdx; rowIdx <= rowOverscanEndIdx; rowIdx++) {\n const row = rows[rowIdx];\n if (\n updateStartIdx(colIdx, getColSpan(column, lastFrozenColumnIndex, { type: 'ROW', row }))\n ) {\n break;\n }\n }\n\n // check summary rows\n if (topSummaryRows != null) {\n for (const row of topSummaryRows) {\n if (\n updateStartIdx(\n colIdx,\n getColSpan(column, lastFrozenColumnIndex, { type: 'SUMMARY', row })\n )\n ) {\n break;\n }\n }\n }\n\n if (bottomSummaryRows != null) {\n for (const row of bottomSummaryRows) {\n if (\n updateStartIdx(\n colIdx,\n getColSpan(column, lastFrozenColumnIndex, { type: 'SUMMARY', row })\n )\n ) {\n break;\n }\n }\n }\n }\n\n return startIdx;\n }, [\n rowOverscanStartIdx,\n rowOverscanEndIdx,\n rows,\n topSummaryRows,\n bottomSummaryRows,\n colOverscanStartIdx,\n lastFrozenColumnIndex,\n colSpanColumns\n ]);\n\n return useMemo((): readonly CalculatedColumn<R, SR>[] => {\n const viewportColumns: CalculatedColumn<R, SR>[] = [];\n for (let colIdx = 0; colIdx <= colOverscanEndIdx; colIdx++) {\n const column = columns[colIdx];\n\n if (colIdx < startIdx && !column.frozen) continue;\n viewportColumns.push(column);\n }\n\n return viewportColumns;\n }, [startIdx, colOverscanEndIdx, columns]);\n}\n","import { useMemo } from 'react';\n\nimport { floor, max, min } from '../utils';\n\ninterface ViewportRowsArgs<R> {\n rows: readonly R[];\n rowHeight: number | ((row: R) => number);\n clientHeight: number;\n scrollTop: number;\n enableVirtualization: boolean;\n}\n\nexport function useViewportRows<R>({\n rows,\n rowHeight,\n clientHeight,\n scrollTop,\n enableVirtualization\n}: ViewportRowsArgs<R>) {\n const { totalRowHeight, gridTemplateRows, getRowTop, getRowHeight, findRowIdx } = useMemo(() => {\n if (typeof rowHeight === 'number') {\n return {\n totalRowHeight: rowHeight * rows.length,\n gridTemplateRows: ` repeat(${rows.length}, ${rowHeight}px)`,\n getRowTop: (rowIdx: number) => rowIdx * rowHeight,\n getRowHeight: () => rowHeight,\n findRowIdx: (offset: number) => floor(offset / rowHeight)\n };\n }\n\n let totalRowHeight = 0;\n let gridTemplateRows = ' ';\n // Calcule the height of all the rows upfront. This can cause performance issues\n // and we can consider using a similar approach as react-window\n // https://github.com/bvaughn/react-window/blob/b0a470cc264e9100afcaa1b78ed59d88f7914ad4/src/VariableSizeList.js#L68\n const rowPositions = rows.map((row) => {\n const currentRowHeight = rowHeight(row);\n const position = { top: totalRowHeight, height: currentRowHeight };\n gridTemplateRows += `${currentRowHeight}px `;\n totalRowHeight += currentRowHeight;\n return position;\n });\n\n const validateRowIdx = (rowIdx: number) => {\n return max(0, min(rows.length - 1, rowIdx));\n };\n\n return {\n totalRowHeight,\n gridTemplateRows,\n getRowTop: (rowIdx: number) => rowPositions[validateRowIdx(rowIdx)].top,\n getRowHeight: (rowIdx: number) => rowPositions[validateRowIdx(rowIdx)].height,\n findRowIdx(offset: number) {\n let start = 0;\n let end = rowPositions.length - 1;\n while (start <= end) {\n const middle = start + floor((end - start) / 2);\n const currentOffset = rowPositions[middle].top;\n\n if (currentOffset === offset) return middle;\n\n if (currentOffset < offset) {\n start = middle + 1;\n } else if (currentOffset > offset) {\n end = middle - 1;\n }\n\n if (start > end) return end;\n }\n return 0;\n }\n };\n }, [rowHeight, rows]);\n\n let rowOverscanStartIdx = 0;\n let rowOverscanEndIdx = rows.length - 1;\n\n if (enableVirtualization) {\n const overscanThreshold = 4;\n const rowVisibleStartIdx = findRowIdx(scrollTop);\n const rowVisibleEndIdx = findRowIdx(scrollTop + clientHeight);\n rowOverscanStartIdx = max(0, rowVisibleStartIdx - overscanThreshold);\n rowOverscanEndIdx = min(rows.length - 1, rowVisibleEndIdx + overscanThreshold);\n }\n\n return {\n rowOverscanStartIdx,\n rowOverscanEndIdx,\n totalRowHeight,\n gridTemplateRows,\n getRowTop,\n getRowHeight,\n findRowIdx\n };\n}\n","import { forwardRef, memo, type RefAttributes } from 'react';\nimport { css } from '@linaria/core';\n\nimport { useRovingTabIndex } from './hooks';\nimport { createCellEvent, getCellClassname, getCellStyle, isCellEditableUtil } from './utils';\nimport type { CellRendererProps } from './types';\n\nconst cellCopied = css`\n @layer rdg.Cell {\n background-color: #ccccff;\n }\n`;\n\nconst cellCopiedClassname = `rdg-cell-copied ${cellCopied}`;\n\nconst cellDraggedOver = css`\n @layer rdg.Cell {\n background-color: #ccccff;\n\n &.${cellCopied} {\n background-color: #9999ff;\n }\n }\n`;\n\nconst cellDraggedOverClassname = `rdg-cell-dragged-over ${cellDraggedOver}`;\n\nfunction Cell<R, SR>(\n {\n column,\n colSpan,\n isCellSelected,\n isCopied,\n isDraggedOver,\n row,\n rowIdx,\n className,\n onClick,\n onDoubleClick,\n onContextMenu,\n onRowChange,\n selectCell,\n style,\n ...props\n }: CellRendererProps<R, SR>,\n ref: React.Ref<HTMLDivElement>\n) {\n const { tabIndex, childTabIndex, onFocus } = useRovingTabIndex(isCellSelected);\n\n const { cellClass } = column;\n className = getCellClassname(\n column,\n {\n [cellCopiedClassname]: isCopied,\n [cellDraggedOverClassname]: isDraggedOver\n },\n typeof cellClass === 'function' ? cellClass(row) : cellClass,\n className\n );\n const isEditable = isCellEditableUtil(column, row);\n\n function selectCellWrapper(openEditor?: boolean) {\n selectCell({ rowIdx, idx: column.idx }, openEditor);\n }\n\n function handleClick(event: React.MouseEvent<HTMLDivElement>) {\n if (onClick) {\n const cellEvent = createCellEvent(event);\n onClick({ rowIdx, row, column, selectCell: selectCellWrapper }, cellEvent);\n if (cellEvent.isGridDefaultPrevented()) return;\n }\n selectCellWrapper();\n }\n\n function handleContextMenu(event: React.MouseEvent<HTMLDivElement>) {\n if (onContextMenu) {\n const cellEvent = createCellEvent(event);\n onContextMenu({ rowIdx, row, column, selectCell: selectCellWrapper }, cellEvent);\n if (cellEvent.isGridDefaultPrevented()) return;\n }\n selectCellWrapper();\n }\n\n function handleDoubleClick(event: React.MouseEvent<HTMLDivElement>) {\n if (onDoubleClick) {\n const cellEvent = createCellEvent(event);\n onDoubleClick({ rowIdx, row, column, selectCell: selectCellWrapper }, cellEvent);\n if (cellEvent.isGridDefaultPrevented()) return;\n }\n selectCellWrapper(true);\n }\n\n function handleRowChange(newRow: R) {\n onRowChange(column, newRow);\n }\n\n return (\n <div\n role=\"gridcell\"\n aria-colindex={column.idx + 1} // aria-colindex is 1-based\n aria-colspan={colSpan}\n aria-selected={isCellSelected}\n aria-readonly={!isEditable || undefined}\n ref={ref}\n tabIndex={tabIndex}\n className={className}\n style={{\n ...getCellStyle(column, colSpan),\n ...style\n }}\n onClick={handleClick}\n onDoubleClick={handleDoubleClick}\n onContextMenu={handleContextMenu}\n onFocus={onFocus}\n {...props}\n >\n {column.renderCell({\n column,\n row,\n rowIdx,\n isCellEditable: isEditable,\n tabIndex: childTabIndex,\n onRowChange: handleRowChange\n })}\n </div>\n );\n}\n\nconst CellComponent = memo(forwardRef(Cell)) as <R, SR>(\n props: CellRendererProps<R, SR> & RefAttributes<HTMLDivElement>\n) => React.JSX.Element;\n\nexport default CellComponent;\n\nexport function defaultRenderCell<R, SR>(key: React.Key, props: CellRendererProps<R, SR>) {\n return <CellComponent key={key} {...props} />;\n}\n","import { css } from '@linaria/core';\nimport clsx from 'clsx';\n\nimport { getCellStyle } from './utils';\nimport type { CalculatedColumn, FillEvent, Position } from './types';\nimport type { DataGridProps, SelectCellState } from './DataGrid';\n\nconst cellDragHandle = css`\n @layer rdg.DragHandle {\n --rdg-drag-handle-size: 8px;\n z-index: 0;\n cursor: move;\n inline-size: var(--rdg-drag-handle-size);\n block-size: var(--rdg-drag-handle-size);\n background-color: var(--rdg-selection-color);\n place-self: end;\n\n &:hover {\n --rdg-drag-handle-size: 16px;\n border: 2px solid var(--rdg-selection-color);\n background-color: var(--rdg-background-color);\n }\n }\n`;\n\nconst cellDragHandleFrozenClassname = css`\n @layer rdg.DragHandle {\n z-index: 1;\n position: sticky;\n }\n`;\n\nconst cellDragHandleClassname = `rdg-cell-drag-handle ${cellDragHandle}`;\n\n// TODO: replace with RefObject once we drop support for React 18\ninterface LatestDraggedOverRowIdxRef {\n readonly current: number | undefined;\n}\n\ninterface Props<R, SR> extends Pick<DataGridProps<R, SR>, 'rows' | 'onRowsChange'> {\n gridRowStart: number;\n column: CalculatedColumn<R, SR>;\n columnWidth: number | string;\n maxColIdx: number;\n isLastRow: boolean;\n selectedPosition: SelectCellState;\n latestDraggedOverRowIdx: LatestDraggedOverRowIdxRef;\n isCellEditable: (position: Position) => boolean;\n onClick: () => void;\n onFill: (event: FillEvent<R>) => R;\n setDragging: (isDragging: boolean) => void;\n setDraggedOverRowIdx: (overRowIdx: number | undefined) => void;\n}\n\nexport default function DragHandle<R, SR>({\n gridRowStart,\n rows,\n column,\n columnWidth,\n maxColIdx,\n isLastRow,\n selectedPosition,\n latestDraggedOverRowIdx,\n isCellEditable,\n onRowsChange,\n onFill,\n onClick,\n setDragging,\n setDraggedOverRowIdx\n}: Props<R, SR>) {\n const { idx, rowIdx } = selectedPosition;\n\n function handleMouseDown(event: React.MouseEvent<HTMLDivElement>) {\n // keep the focus on the cell\n event.preventDefault();\n if (event.buttons !== 1) return;\n setDragging(true);\n window.addEventListener('mouseover', onMouseOver);\n window.addEventListener('mouseup', onMouseUp);\n\n function onMouseOver(event: MouseEvent) {\n // Trigger onMouseup in edge cases where we release the mouse button but `mouseup` isn't triggered,\n // for example when releasing the mouse button outside the iframe the grid is rendered in.\n // https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons\n if (event.buttons !== 1) onMouseUp();\n }\n\n function onMouseUp() {\n window.removeEventListener('mouseover', onMouseOver);\n window.removeEventListener('mouseup', onMouseUp);\n setDragging(false);\n handleDragEnd();\n }\n }\n\n function handleDragEnd() {\n const overRowIdx = latestDraggedOverRowIdx.current;\n if (overRowIdx === undefined) return;\n\n const startRowIndex = rowIdx < overRowIdx ? rowIdx + 1 : overRowIdx;\n const endRowIndex = rowIdx < overRowIdx ? overRowIdx + 1 : rowIdx;\n updateRows(startRowIndex, endRowIndex);\n setDraggedOverRowIdx(undefined);\n }\n\n function handleDoubleClick(event: React.MouseEvent<HTMLDivElement>) {\n event.stopPropagation();\n updateRows(rowIdx + 1, rows.length);\n }\n\n function updateRows(startRowIdx: number, endRowIdx: number) {\n const sourceRow = rows[rowIdx];\n const updatedRows = [...rows];\n const indexes: number[] = [];\n for (let i = startRowIdx; i < endRowIdx; i++) {\n if (isCellEditable({ rowIdx: i, idx })) {\n const updatedRow = onFill({ columnKey: column.key, sourceRow, targetRow: rows[i] });\n if (updatedRow !== rows[i]) {\n updatedRows[i] = updatedRow;\n indexes.push(i);\n }\n }\n }\n\n if (indexes.length > 0) {\n onRowsChange?.(updatedRows, { indexes, column });\n }\n }\n\n function getStyle(): React.CSSProperties {\n const colSpan = column.colSpan?.({ type: 'ROW', row: rows[rowIdx] }) ?? 1;\n const { insetInlineStart, ...style } = getCellStyle(column, colSpan);\n const marginEnd = 'calc(var(--rdg-drag-handle-size) * -0.5 + 1px)';\n const isLastColumn = column.idx + colSpan - 1 === maxColIdx;\n\n return {\n ...style,\n gridRowStart,\n marginInlineEnd: isLastColumn ? undefined : marginEnd,\n marginBlockEnd: isLastRow ? undefined : marginEnd,\n insetInlineStart: insetInlineStart\n ? `calc(${insetInlineStart} + ${columnWidth}px + var(--rdg-drag-handle-size) * -0.5 - 1px)`\n : undefined\n };\n }\n\n return (\n <div\n style={getStyle()}\n className={clsx(cellDragHandleClassname, column.frozen && cellDragHandleFrozenClassname)}\n onClick={onClick}\n onMouseDown={handleMouseDown}\n onDoubleClick={handleDoubleClick}\n />\n );\n}\n","import { useEffect, useRef } from 'react';\nimport { css } from '@linaria/core';\n\nimport { useLatestFunc } from './hooks';\nimport { createCellEvent, getCellClassname, getCellStyle, onEditorNavigation } from './utils';\nimport type {\n CellKeyboardEvent,\n CellRendererProps,\n EditCellKeyDownArgs,\n Maybe,\n Omit,\n RenderEditCellProps\n} from './types';\n\n/*\n * To check for outside `mousedown` events, we listen to all `mousedown` events at their birth,\n * i.e. on the window during the capture phase, and at their death, i.e. on the window during the bubble phase.\n *\n * We schedule a check at the birth of the event, cancel the check when the event reaches the \"inside\" container,\n * and trigger the \"outside\" callback when the event bubbles back up to the window.\n *\n * The event can be `stopPropagation()`ed halfway through, so they may not always bubble back up to the window,\n * so an alternative check must be used. The check must happen after the event can reach the \"inside\" container,\n * and not before it run to completion. `requestAnimationFrame` is the best way we know how to achieve this.\n * Usually we want click event handlers from parent components to access the latest commited values,\n * so `mousedown` is used instead of `click`.\n *\n * We must also rely on React's event capturing/bubbling to handle elements rendered in a portal.\n */\n\nconst cellEditing = css`\n @layer rdg.EditCell {\n padding: 0;\n }\n`;\n\ntype SharedCellRendererProps<R, SR> = Pick<CellRendererProps<R, SR>, 'colSpan'>;\n\ninterface EditCellProps<R, SR>\n extends Omit<RenderEditCellProps<R, SR>, 'onRowChange' | 'onClose'>,\n SharedCellRendererProps<R, SR> {\n rowIdx: number;\n onRowChange: (row: R, commitChanges: boolean, shouldFocusCell: boolean) => void;\n closeEditor: (shouldFocusCell: boolean) => void;\n navigate: (event: React.KeyboardEvent<HTMLDivElement>) => void;\n onKeyDown: Maybe<(args: EditCellKeyDownArgs<R, SR>, event: CellKeyboardEvent) => void>;\n}\n\nexport default function EditCell<R, SR>({\n column,\n colSpan,\n row,\n rowIdx,\n onRowChange,\n closeEditor,\n onKeyDown,\n navigate\n}: EditCellProps<R, SR>) {\n const frameRequestRef = useRef<number | undefined>(undefined);\n const commitOnOutsideClick = column.editorOptions?.commitOnOutsideClick !== false;\n\n // We need to prevent the `useEffect` from cleaning up between re-renders,\n // as `onWindowCaptureMouseDown` might otherwise miss valid mousedown events.\n // To that end we instead access the latest props via useLatestFunc.\n const commitOnOutsideMouseDown = useLatestFunc(() => {\n onClose(true, false);\n });\n\n useEffect(() => {\n if (!commitOnOutsideClick) return;\n\n function onWindowCaptureMouseDown() {\n frameRequestRef.current = requestAnimationFrame(commitOnOutsideMouseDown);\n }\n\n addEventListener('mousedown', onWindowCaptureMouseDown, { capture: true });\n\n return () => {\n removeEventListener('mousedown', onWindowCaptureMouseDown, { capture: true });\n cancelFrameRequest();\n };\n }, [commitOnOutsideClick, commitOnOutsideMouseDown]);\n\n function cancelFrameRequest() {\n cancelAnimationFrame(frameRequestRef.current!);\n }\n\n function handleKeyDown(event: React.KeyboardEvent<HTMLDivElement>) {\n if (onKeyDown) {\n const cellEvent = createCellEvent(event);\n onKeyDown(\n {\n mode: 'EDIT',\n row,\n column,\n rowIdx,\n navigate() {\n navigate(event);\n },\n onClose\n },\n cellEvent\n );\n if (cellEvent.isGridDefaultPrevented()) return;\n }\n\n if (event.key === 'Escape') {\n // Discard changes\n onClose();\n } else if (event.key === 'Enter') {\n onClose(true);\n } else if (onEditorNavigation(event)) {\n navigate(event);\n }\n }\n\n function onClose(commitChanges = false, shouldFocusCell = true) {\n if (commitChanges) {\n onRowChange(row, true, shouldFocusCell);\n } else {\n closeEditor(shouldFocusCell);\n }\n }\n\n function onEditorRowChange(row: R, commitChangesAndFocus = false) {\n onRowChange(row, commitChangesAndFocus, commitChangesAndFocus);\n }\n\n const { cellClass } = column;\n const className = getCellClassname(\n column,\n 'rdg-editor-container',\n !column.editorOptions?.displayCellContent && cellEditing,\n typeof cellClass === 'function' ? cellClass(row) : cellClass\n );\n\n return (\n <div\n role=\"gridcell\"\n aria-colindex={column.idx + 1} // aria-colindex is 1-based\n aria-colspan={colSpan}\n aria-selected\n className={className}\n style={getCellStyle(column, colSpan)}\n onKeyDown={handleKeyDown}\n onMouseDownCapture={cancelFrameRequest}\n >\n {column.renderEditCell != null && (\n <>\n {column.renderEditCell({\n column,\n row,\n rowIdx,\n onRowChange: onEditorRowChange,\n onClose\n })}\n {column.editorOptions?.displayCellContent &&\n column.renderCell({\n column,\n row,\n rowIdx,\n isCellEditable: true,\n tabIndex: -1,\n onRowChange: onEditorRowChange\n })}\n </>\n )}\n </div>\n );\n}\n","import clsx from 'clsx';\n\nimport { useRovingTabIndex } from './hooks';\nimport { getHeaderCellRowSpan, getHeaderCellStyle } from './utils';\nimport type { CalculatedColumnParent } from './types';\nimport type { GroupedColumnHeaderRowProps } from './GroupedColumnHeaderRow';\nimport { cellClassname } from './style/cell';\n\ntype SharedGroupedColumnHeaderRowProps<R, SR> = Pick<\n GroupedColumnHeaderRowProps<R, SR>,\n 'rowIdx' | 'selectCell'\n>;\n\ninterface GroupedColumnHeaderCellProps<R, SR> extends SharedGroupedColumnHeaderRowProps<R, SR> {\n column: CalculatedColumnParent<R, SR>;\n isCellSelected: boolean;\n}\n\nexport default function GroupedColumnHeaderCell<R, SR>({\n column,\n rowIdx,\n isCellSelected,\n selectCell\n}: GroupedColumnHeaderCellProps<R, SR>) {\n const { tabIndex, onFocus } = useRovingTabIndex(isCellSelected);\n const { colSpan } = column;\n const rowSpan = getHeaderCellRowSpan(column, rowIdx);\n const index = column.idx + 1;\n\n function onClick() {\n selectCell({ idx: column.idx, rowIdx });\n }\n\n return (\n <div\n role=\"columnheader\"\n aria-colindex={index}\n aria-colspan={colSpan}\n aria-rowspan={rowSpan}\n aria-selected={isCellSelected}\n tabIndex={tabIndex}\n className={clsx(cellClassname, column.headerCellClass)}\n style={{\n ...getHeaderCellStyle(column, rowIdx, rowSpan),\n gridColumnStart: index,\n gridColumnEnd: index + colSpan\n }}\n onFocus={onFocus}\n onClick={onClick}\n >\n {column.name}\n </div>\n );\n}\n","import { css } from '@linaria/core';\n\nimport type { RenderHeaderCellProps } from './types';\nimport { useDefaultRenderers } from './DataGridDefaultRenderersProvider';\n\nconst headerSortCellClassname = css`\n @layer rdg.SortableHeaderCell {\n display: flex;\n }\n`;\n\nconst headerSortName = css`\n @layer rdg.SortableHeaderCellName {\n flex-grow: 1;\n overflow: clip;\n text-overflow: ellipsis;\n }\n`;\n\nconst headerSortNameClassname = `rdg-header-sort-name ${headerSortName}`;\n\nexport default function renderHeaderCell<R, SR>({\n column,\n sortDirection,\n priority\n}: RenderHeaderCellProps<R, SR>) {\n if (!column.sortable) return column.name;\n\n return (\n <SortableHeaderCell sortDirection={sortDirection} priority={priority}>\n {column.name}\n </SortableHeaderCell>\n );\n}\n\ntype SharedHeaderCellProps<R, SR> = Pick<\n RenderHeaderCellProps<R, SR>,\n 'sortDirection' | 'priority'\n>;\n\ninterface SortableHeaderCellProps<R, SR> extends SharedHeaderCellProps<R, SR> {\n children: React.ReactNode;\n}\n\nfunction SortableHeaderCell<R, SR>({\n sortDirection,\n priority,\n children\n}: SortableHeaderCellProps<R, SR>) {\n const renderSortStatus = useDefaultRenderers<R, SR>()!.renderSortStatus!;\n\n return (\n <span className={headerSortCellClassname}>\n <span className={headerSortNameClassname}>{children}</span>\n <span>{renderSortStatus({ sortDirection, priority })}</span>\n </span>\n );\n}\n","import { useState } from 'react';\nimport { css } from '@linaria/core';\n\nimport { useRovingTabIndex } from './hooks';\nimport {\n clampColumnWidth,\n getCellClassname,\n getCellStyle,\n getHeaderCellRowSpan,\n getHeaderCellStyle,\n stopPropagation\n} from './utils';\nimport type { CalculatedColumn, SortColumn } from './types';\nimport type { HeaderRowProps } from './HeaderRow';\nimport defaultRenderHeaderCell from './renderHeaderCell';\n\nconst cellSortableClassname = css`\n @layer rdg.HeaderCell {\n cursor: pointer;\n }\n`;\n\nconst cellResizable = css`\n @layer rdg.HeaderCell {\n touch-action: none;\n }\n`;\n\nconst cellResizableClassname = `rdg-cell-resizable ${cellResizable}`;\n\nexport const resizeHandleClassname = css`\n @layer rdg.HeaderCell {\n cursor: col-resize;\n position: absolute;\n inset-block-start: 0;\n inset-inline-end: 0;\n inset-block-end: 0;\n inline-size: 10px;\n }\n`;\n\nconst cellDraggableClassname = 'rdg-cell-draggable';\n\nconst cellDragging = css`\n opacity: 0.5;\n`;\n\nconst cellDraggingClassname = `rdg-cell-dragging ${cellDragging}`;\n\nconst cellOver = css`\n background-color: var(--rdg-header-draggable-background-color);\n`;\n\nconst cellOverClassname = `rdg-cell-drag-over ${cellOver}`;\n\ntype SharedHeaderRowProps<R, SR> = Pick<\n HeaderRowProps<R, SR, React.Key>,\n | 'sortColumns'\n | 'onSortColumnsChange'\n | 'selectCell'\n | 'onColumnResize'\n | 'shouldFocusGrid'\n | 'direction'\n | 'onColumnsReorder'\n>;\n\nexport interface HeaderCellProps<R, SR> extends SharedHeaderRowProps<R, SR> {\n column: CalculatedColumn<R, SR>;\n colSpan: number | undefined;\n rowIdx: number;\n isCellSelected: boolean;\n dragDropKey: string;\n}\n\nexport default function HeaderCell<R, SR>({\n column,\n colSpan,\n rowIdx,\n isCellSelected,\n onColumnResize,\n onColumnsReorder,\n sortColumns,\n onSortColumnsChange,\n selectCell,\n shouldFocusGrid,\n direction,\n dragDropKey\n}: HeaderCellProps<R, SR>) {\n const [isDragging, setIsDragging] = useState(false);\n const [isOver, setIsOver] = useState(false);\n const isRtl = direction === 'rtl';\n const rowSpan = getHeaderCellRowSpan(column, rowIdx);\n const { tabIndex, childTabIndex, onFocus } = useRovingTabIndex(isCellSelected);\n const sortIndex = sortColumns?.findIndex((sort) => sort.columnKey === column.key);\n const sortColumn =\n sortIndex !== undefined && sortIndex > -1 ? sortColumns![sortIndex] : undefined;\n const sortDirection = sortColumn?.direction;\n const priority = sortColumn !== undefined && sortColumns!.length > 1 ? sortIndex! + 1 : undefined;\n const ariaSort =\n sortDirection && !priority ? (sortDirection === 'ASC' ? 'ascending' : 'descending') : undefined;\n const { sortable, resizable, draggable } = column;\n\n const className = getCellClassname(column, column.headerCellClass, {\n [cellSortableClassname]: sortable,\n [cellResizableClassname]: resizable,\n [cellDraggableClassname]: draggable,\n [cellDraggingClassname]: isDragging,\n [cellOverClassname]: isOver\n });\n\n const renderHeaderCell = column.renderHeaderCell ?? defaultRenderHeaderCell;\n\n function onPointerDown(event: React.PointerEvent<HTMLDivElement>) {\n if (event.pointerType === 'mouse' && event.buttons !== 1) {\n return;\n }\n\n // Fix column resizing on a draggable column in FF\n event.preventDefault();\n\n const { currentTarget, pointerId } = event;\n const headerCell = currentTarget.parentElement!;\n const { right, left } = headerCell.getBoundingClientRect();\n const offset = isRtl ? event.clientX - left : right - event.clientX;\n let hasDoubleClicked = false;\n\n function onPointerMove(event: PointerEvent) {\n const { width, right, left } = headerCell.getBoundingClientRect();\n let newWidth = isRtl ? right + offset - event.clientX : event.clientX + offset - left;\n newWidth = clampColumnWidth(newWidth, column);\n if (width > 0 && newWidth !== width) {\n onColumnResize(column, newWidth);\n }\n }\n\n function onDoubleClick() {\n hasDoubleClicked = true;\n onColumnResize(column, 'max-content');\n }\n\n function onLostPointerCapture(event: PointerEvent) {\n // Handle final pointer position that may have been skipped by coalesced pointer move events.\n // Skip move pointer handling if the user double-clicked.\n if (!hasDoubleClicked) {\n onPointerMove(event);\n }\n\n currentTarget.removeEventListener('pointermove', onPointerMove);\n currentTarget.removeEventListener('dblclick', onDoubleClick);\n currentTarget.removeEventListener('lostpointercapture', onLostPointerCapture);\n }\n\n currentTarget.setPointerCapture(pointerId);\n currentTarget.addEventListener('pointermove', onPointerMove);\n currentTarget.addEventListener('dblclick', onDoubleClick);\n currentTarget.addEventListener('lostpointercapture', onLostPointerCapture);\n }\n\n function onSort(ctrlClick: boolean) {\n if (onSortColumnsChange == null) return;\n const { sortDescendingFirst } = column;\n if (sortColumn === undefined) {\n // not currently sorted\n const nextSort: SortColumn = {\n columnKey: column.key,\n direction: sortDescendingFirst ? 'DESC' : 'ASC'\n };\n onSortColumnsChange(sortColumns && ctrlClick ? [...sortColumns, nextSort] : [nextSort]);\n } else {\n let nextSortColumn: SortColumn | undefined;\n if (\n (sortDescendingFirst === true && sortDirection === 'DESC') ||\n (sortDescendingFirst !== true && sortDirection === 'ASC')\n ) {\n nextSortColumn = {\n columnKey: column.key,\n direction: sortDirection === 'ASC' ? 'DESC' : 'ASC'\n };\n }\n if (ctrlClick) {\n const nextSortColumns = [...sortColumns!];\n if (nextSortColumn) {\n // swap direction\n nextSortColumns[sortIndex!] = nextSortColumn;\n } else {\n // remove sort\n nextSortColumns.splice(sortIndex!, 1);\n }\n onSortColumnsChange(nextSortColumns);\n } else {\n onSortColumnsChange(nextSortColumn ? [nextSortColumn] : []);\n }\n }\n }\n\n function onClick(event: React.MouseEvent<HTMLSpanElement>) {\n selectCell({ idx: column.idx, rowIdx });\n\n if (sortable) {\n onSort(event.ctrlKey || event.metaKey);\n }\n }\n\n function handleFocus(event: React.FocusEvent<HTMLDivElement>) {\n onFocus?.(event);\n if (shouldFocusGrid) {\n // Select the first header cell if there is no selected cell\n selectCell({ idx: 0, rowIdx });\n }\n }\n\n function onKeyDown(event: React.KeyboardEvent<HTMLSpanElement>) {\n if (event.key === ' ' || event.key === 'Enter') {\n // prevent scrolling\n event.preventDefault();\n onSort(event.ctrlKey || event.metaKey);\n }\n }\n\n function onDragStart(event: React.DragEvent<HTMLDivElement>) {\n event.dataTransfer.setData(dragDropKey, column.key);\n event.dataTransfer.dropEffect = 'move';\n setIsDragging(true);\n }\n\n function onDragEnd() {\n setIsDragging(false);\n }\n\n function onDragOver(event: React.DragEvent<HTMLDivElement>) {\n // prevent default to allow drop\n event.preventDefault();\n event.dataTransfer.dropEffect = 'move';\n }\n\n function onDrop(event: React.DragEvent<HTMLDivElement>) {\n setIsOver(false);\n // The dragDropKey is derived from the useId() hook, which can sometimes generate keys with uppercase letters.\n // When setting data using event.dataTransfer.setData(), the key is automatically converted to lowercase in some browsers.\n // To ensure consistent comparison, we normalize the dragDropKey to lowercase before checking its presence in the event's dataTransfer types.\n // https://html.spec.whatwg.org/multipage/dnd.html#the-datatransfer-interface\n if (event.dataTransfer.types.includes(dragDropKey.toLowerCase())) {\n const sourceKey = event.dataTransfer.getData(dragDropKey.toLowerCase());\n if (sourceKey !== column.key) {\n event.preventDefault();\n onColumnsReorder?.(sourceKey, column.key);\n }\n }\n }\n\n function onDragEnter(event: React.DragEvent<HTMLDivElement>) {\n if (isEventPertinent(event)) {\n setIsOver(true);\n }\n }\n\n function onDragLeave(event: React.DragEvent<HTMLDivElement>) {\n if (isEventPertinent(event)) {\n setIsOver(false);\n }\n }\n\n let draggableProps: React.HTMLAttributes<HTMLDivElement> | undefined;\n if (draggable) {\n draggableProps = {\n draggable: true,\n /* events fired on the draggable target */\n onDragStart,\n onDragEnd,\n /* events fired on the drop targets */\n onDragOver,\n onDragEnter,\n onDragLeave,\n onDrop\n };\n }\n\n return (\n <div\n role=\"columnheader\"\n aria-colindex={column.idx + 1}\n aria-colspan={colSpan}\n aria-rowspan={rowSpan}\n aria-selected={isCellSelected}\n aria-sort={ariaSort}\n // set the tabIndex to 0 when there is no selected cell so grid can receive focus\n tabIndex={shouldFocusGrid ? 0 : tabIndex}\n className={className}\n style={{\n ...getHeaderCellStyle(column, rowIdx, rowSpan),\n ...getCellStyle(column, colSpan)\n }}\n onFocus={handleFocus}\n onClick={onClick}\n onKeyDown={sortable ? onKeyDown : undefined}\n {...draggableProps}\n >\n {renderHeaderCell({\n column,\n sortDirection,\n priority,\n tabIndex: childTabIndex\n })}\n\n {resizable && (\n <div\n className={resizeHandleClassname}\n onClick={stopPropagation}\n onPointerDown={onPointerDown}\n />\n )}\n </div>\n );\n}\n\n// only accept pertinent drag events:\n// - ignore drag events going from the container to an element inside the container\n// - ignore drag events going from an element inside the container to the container\nfunction isEventPertinent(event: React.DragEvent) {\n const relatedTarget = event.relatedTarget as HTMLElement | null;\n\n return !event.currentTarget.contains(relatedTarget);\n}\n","import { css } from '@linaria/core';\n\nexport const row = css`\n @layer rdg.Row {\n display: contents;\n background-color: var(--rdg-background-color);\n\n &:hover {\n background-color: var(--rdg-row-hover-background-color);\n }\n\n &[aria-selected='true'] {\n background-color: var(--rdg-row-selected-background-color);\n\n &:hover {\n background-color: var(--rdg-row-selected-hover-background-color);\n }\n }\n }\n`;\n\nexport const rowClassname = `rdg-row ${row}`;\n\nexport const rowSelected = css`\n @layer rdg.FocusSink {\n outline: 2px solid var(--rdg-selection-color);\n outline-offset: -2px;\n }\n`;\n\nexport const rowSelectedClassname = 'rdg-row-selected';\n\nexport const rowSelectedWithFrozenCell = css`\n @layer rdg.FocusSink {\n &::before {\n content: '';\n display: inline-block;\n block-size: 100%;\n position: sticky;\n inset-inline-start: 0;\n border-inline-start: 2px solid var(--rdg-selection-color);\n }\n }\n`;\n\nexport const topSummaryRowClassname = 'rdg-top-summary-row';\n\nexport const bottomSummaryRowClassname = 'rdg-bottom-summary-row';\n","import { memo, useId } from 'react';\nimport { css } from '@linaria/core';\nimport clsx from 'clsx';\n\nimport { getColSpan } from './utils';\nimport type { CalculatedColumn, Direction, Position } from './types';\nimport type { DataGridProps } from './DataGrid';\nimport HeaderCell from './HeaderCell';\nimport { cell, cellFrozen } from './style/cell';\nimport { rowSelectedClassname } from './style/row';\n\ntype SharedDataGridProps<R, SR, K extends React.Key> = Pick<\n DataGridProps<R, SR, K>,\n 'sortColumns' | 'onSortColumnsChange' | 'onColumnsReorder'\n>;\n\nexport interface HeaderRowProps<R, SR, K extends React.Key> extends SharedDataGridProps<R, SR, K> {\n rowIdx: number;\n columns: readonly CalculatedColumn<R, SR>[];\n onColumnResize: (column: CalculatedColumn<R, SR>, width: number | 'max-content') => void;\n selectCell: (position: Position) => void;\n lastFrozenColumnIndex: number;\n selectedCellIdx: number | undefined;\n shouldFocusGrid: boolean;\n direction: Direction;\n}\n\nconst headerRow = css`\n @layer rdg.HeaderRow {\n display: contents;\n background-color: var(--rdg-header-background-color);\n font-weight: bold;\n\n & > .${cell} {\n /* Should have a higher value than 1 to show up above regular cells and the focus sink */\n z-index: 2;\n position: sticky;\n }\n\n & > .${cellFrozen} {\n z-index: 3;\n }\n }\n`;\n\nexport const headerRowClassname = `rdg-header-row ${headerRow}`;\n\nfunction HeaderRow<R, SR, K extends React.Key>({\n rowIdx,\n columns,\n onColumnResize,\n onColumnsReorder,\n sortColumns,\n onSortColumnsChange,\n lastFrozenColumnIndex,\n selectedCellIdx,\n selectCell,\n shouldFocusGrid,\n direction\n}: HeaderRowProps<R, SR, K>) {\n // eslint-disable-next-line react-compiler/react-compiler\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const dragDropKey = useId();\n\n const cells = [];\n for (let index = 0; index < columns.length; index++) {\n const column = columns[index];\n const colSpan = getColSpan(column, lastFrozenColumnIndex, { type: 'HEADER' });\n if (colSpan !== undefined) {\n index += colSpan - 1;\n }\n\n cells.push(\n <HeaderCell<R, SR>\n key={column.key}\n column={column}\n colSpan={colSpan}\n rowIdx={rowIdx}\n isCellSelected={selectedCellIdx === column.idx}\n onColumnResize={onColumnResize}\n onColumnsReorder={onColumnsReorder}\n onSortColumnsChange={onSortColumnsChange}\n sortColumns={sortColumns}\n selectCell={selectCell}\n shouldFocusGrid={shouldFocusGrid && index === 0}\n direction={direction}\n dragDropKey={dragDropKey}\n />\n );\n }\n\n return (\n <div\n role=\"row\"\n aria-rowindex={rowIdx} // aria-rowindex is 1 based\n className={clsx(headerRowClassname, {\n [rowSelectedClassname]: selectedCellIdx === -1\n })}\n >\n {cells}\n </div>\n );\n}\n\nexport default memo(HeaderRow) as <R, SR, K extends React.Key>(\n props: HeaderRowProps<R, SR, K>\n) => React.JSX.Element;\n","import { memo } from 'react';\n\nimport type { CalculatedColumn, CalculatedColumnParent, Position } from './types';\nimport GroupedColumnHeaderCell from './GroupedColumnHeaderCell';\nimport { headerRowClassname } from './HeaderRow';\n\nexport interface GroupedColumnHeaderRowProps<R, SR> {\n rowIdx: number;\n level: number;\n columns: readonly CalculatedColumn<R, SR>[];\n selectCell: (position: Position) => void;\n selectedCellIdx: number | undefined;\n}\n\nfunction GroupedColumnHeaderRow<R, SR>({\n rowIdx,\n level,\n columns,\n selectedCellIdx,\n selectCell\n}: GroupedColumnHeaderRowProps<R, SR>) {\n const cells = [];\n const renderedParents = new Set<CalculatedColumnParent<R, SR>>();\n\n for (const column of columns) {\n let { parent } = column;\n\n if (parent === undefined) continue;\n\n while (parent.level > level) {\n if (parent.parent === undefined) break;\n parent = parent.parent;\n }\n\n if (parent.level === level && !renderedParents.has(parent)) {\n renderedParents.add(parent);\n const { idx } = parent;\n cells.push(\n <GroupedColumnHeaderCell<R, SR>\n key={idx}\n column={parent}\n rowIdx={rowIdx}\n isCellSelected={selectedCellIdx === idx}\n selectCell={selectCell}\n />\n );\n }\n }\n\n return (\n <div\n role=\"row\"\n aria-rowindex={rowIdx} // aria-rowindex is 1 based\n className={headerRowClassname}\n >\n {cells}\n </div>\n );\n}\n\nexport default memo(GroupedColumnHeaderRow) as <R, SR>(\n props: GroupedColumnHeaderRowProps<R, SR>\n) => React.JSX.Element;\n","import { forwardRef, memo, useMemo, type RefAttributes } from 'react';\nimport clsx from 'clsx';\n\nimport { RowSelectionProvider, useLatestFunc, type RowSelectionContextValue } from './hooks';\nimport { getColSpan, getRowStyle } from './utils';\nimport type { CalculatedColumn, RenderRowProps } from './types';\nimport { useDefaultRenderers } from './DataGridDefaultRenderersProvider';\nimport { rowClassname, rowSelectedClassname } from './style/row';\n\nfunction Row<R, SR>(\n {\n className,\n rowIdx,\n gridRowStart,\n selectedCellIdx,\n isRowSelectionDisabled,\n isRowSelected,\n copiedCellIdx,\n draggedOverCellIdx,\n lastFrozenColumnIndex,\n row,\n viewportColumns,\n selectedCellEditor,\n onCellClick,\n onCellDoubleClick,\n onCellContextMenu,\n rowClass,\n setDraggedOverRowIdx,\n onMouseEnter,\n onRowChange,\n selectCell,\n ...props\n }: RenderRowProps<R, SR>,\n ref: React.Ref<HTMLDivElement>\n) {\n const renderCell = useDefaultRenderers<R, SR>()!.renderCell!;\n\n const handleRowChange = useLatestFunc((column: CalculatedColumn<R, SR>, newRow: R) => {\n onRowChange(column, rowIdx, newRow);\n });\n\n function handleDragEnter(event: React.MouseEvent<HTMLDivElement>) {\n setDraggedOverRowIdx?.(rowIdx);\n onMouseEnter?.(event);\n }\n\n className = clsx(\n rowClassname,\n `rdg-row-${rowIdx % 2 === 0 ? 'even' : 'odd'}`,\n {\n [rowSelectedClassname]: selectedCellIdx === -1\n },\n rowClass?.(row, rowIdx),\n className\n );\n\n const cells = [];\n\n for (let index = 0; index < viewportColumns.length; index++) {\n const column = viewportColumns[index];\n const { idx } = column;\n const colSpan = getColSpan(column, lastFrozenColumnIndex, { type: 'ROW', row });\n if (colSpan !== undefined) {\n index += colSpan - 1;\n }\n\n const isCellSelected = selectedCellIdx === idx;\n\n if (isCellSelected && selectedCellEditor) {\n cells.push(selectedCellEditor);\n } else {\n cells.push(\n renderCell(column.key, {\n column,\n colSpan,\n row,\n rowIdx,\n isCopied: copiedCellIdx === idx,\n isDraggedOver: draggedOverCellIdx === idx,\n isCellSelected,\n onClick: onCellClick,\n onDoubleClick: onCellDoubleClick,\n onContextMenu: onCellContextMenu,\n onRowChange: handleRowChange,\n selectCell\n })\n );\n }\n }\n\n const selectionValue = useMemo(\n (): RowSelectionContextValue => ({ isRowSelected, isRowSelectionDisabled }),\n [isRowSelectionDisabled, isRowSelected]\n );\n\n return (\n <RowSelectionProvider value={selectionValue}>\n <div\n role=\"row\"\n ref={ref}\n className={className}\n onMouseEnter={handleDragEnter}\n style={getRowStyle(gridRowStart)}\n {...props}\n >\n {cells}\n </div>\n </RowSelectionProvider>\n );\n}\n\nconst RowComponent = memo(forwardRef(Row)) as <R, SR>(\n props: RenderRowProps<R, SR> & RefAttributes<HTMLDivElement>\n) => React.JSX.Element;\n\nexport default RowComponent;\n\nexport function defaultRenderRow<R, SR>(key: React.Key, props: RenderRowProps<R, SR>) {\n return <RowComponent key={key} {...props} />;\n}\n","import { useRef } from 'react';\n\nimport { useLayoutEffect } from './hooks';\nimport { scrollIntoView } from './utils';\n\nexport interface PartialPosition {\n readonly idx?: number | undefined;\n readonly rowIdx?: number | undefined;\n}\n\nexport default function ScrollToCell({\n scrollToPosition: { idx, rowIdx },\n gridRef,\n setScrollToCellPosition\n}: {\n scrollToPosition: PartialPosition;\n gridRef: React.RefObject<HTMLDivElement | null>;\n setScrollToCellPosition: (cell: null) => void;\n}) {\n const ref = useRef<HTMLDivElement>(null);\n\n useLayoutEffect(() => {\n // scroll until the cell is completely visible\n // this is needed if the grid has auto-sized columns\n scrollIntoView(ref.current);\n });\n\n useLayoutEffect(() => {\n function removeScrollToCell() {\n setScrollToCellPosition(null);\n }\n\n const observer = new IntersectionObserver(removeScrollToCell, {\n root: gridRef.current!,\n threshold: 1.0\n });\n\n observer.observe(ref.current!);\n\n return () => {\n observer.disconnect();\n };\n }, [gridRef, setScrollToCellPosition]);\n\n return (\n <div\n ref={ref}\n style={{\n gridColumn: idx === undefined ? '1/-1' : idx + 1,\n gridRow: rowIdx === undefined ? '1/-1' : rowIdx + 2\n }}\n />\n );\n}\n","import { css } from '@linaria/core';\n\nimport type { RenderSortIconProps, RenderSortPriorityProps, RenderSortStatusProps } from './types';\n\nconst arrow = css`\n @layer rdg.SortIcon {\n fill: currentColor;\n\n > path {\n transition: d 0.1s;\n }\n }\n`;\n\nconst arrowClassname = `rdg-sort-arrow ${arrow}`;\n\nexport default function renderSortStatus({ sortDirection, priority }: RenderSortStatusProps) {\n return (\n <>\n {renderSortIcon({ sortDirection })}\n {renderSortPriority({ priority })}\n </>\n );\n}\n\nexport function renderSortIcon({ sortDirection }: RenderSortIconProps) {\n if (sortDirection === undefined) return null;\n\n return (\n <svg viewBox=\"0 0 12 8\" width=\"12\" height=\"8\" className={arrowClassname} aria-hidden>\n <path d={sortDirection === 'ASC' ? 'M0 8 6 0 12 8' : 'M0 0 6 8 12 0'} />\n </svg>\n );\n}\n\nexport function renderSortPriority({ priority }: RenderSortPriorityProps) {\n return priority;\n}\n","import { css } from '@linaria/core';\n\nimport { cell } from './cell';\nimport { bottomSummaryRowClassname, row, topSummaryRowClassname } from './row';\n\nconst lightTheme = `\n --rdg-color: #000;\n --rdg-border-color: #ddd;\n --rdg-summary-border-color: #aaa;\n --rdg-background-color: hsl(0deg 0% 100%);\n --rdg-header-background-color: hsl(0deg 0% 97.5%);\n --rdg-header-draggable-background-color: hsl(0deg 0% 90.5%);\n --rdg-row-hover-background-color: hsl(0deg 0% 96%);\n --rdg-row-selected-background-color: hsl(207deg 76% 92%);\n --rdg-row-selected-hover-background-color: hsl(207deg 76% 88%);\n\n --rdg-checkbox-focus-color: hsl(207deg 100% 69%);\n`;\n\nconst darkTheme = `\n --rdg-color: #ddd;\n --rdg-border-color: #444;\n --rdg-summary-border-color: #555;\n --rdg-background-color: hsl(0deg 0% 13%);\n --rdg-header-background-color: hsl(0deg 0% 10.5%);\n --rdg-header-draggable-background-color: hsl(0deg 0% 17.5%);\n --rdg-row-hover-background-color: hsl(0deg 0% 9%);\n --rdg-row-selected-background-color: hsl(207deg 76% 42%);\n --rdg-row-selected-hover-background-color: hsl(207deg 76% 38%);\n\n --rdg-checkbox-focus-color: hsl(207deg 100% 89%);\n`;\n\nconst root = css`\n @layer rdg.Defaults {\n *,\n *::before,\n *::after {\n box-sizing: inherit;\n }\n }\n\n @layer rdg.Root {\n ${lightTheme}\n --rdg-selection-color: #66afe9;\n --rdg-font-size: 14px;\n --rdg-cell-frozen-box-shadow: 2px 0 5px -2px rgba(136, 136, 136, 0.3);\n\n &:dir(rtl) {\n --rdg-cell-frozen-box-shadow: -2px 0 5px -2px rgba(136, 136, 136, 0.3);\n }\n\n display: grid;\n\n color-scheme: var(--rdg-color-scheme, light dark);\n accent-color: light-dark(hsl(207deg 100% 29%), hsl(207deg 100% 79%));\n\n /* https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Positioning/Understanding_z_index/The_stacking_context */\n /* We set a stacking context so internal elements don't render on top of external elements. */\n /* size containment is not used as it could break \"width: min-content\" for example, and the grid would infinitely resize on Chromium browsers */\n contain: content;\n content-visibility: auto;\n block-size: 350px;\n border: 1px solid var(--rdg-border-color);\n box-sizing: border-box;\n overflow: auto;\n background-color: var(--rdg-background-color);\n color: var(--rdg-color);\n font-size: var(--rdg-font-size);\n\n /* needed on Firefox to fix scrollbars */\n &::before {\n content: '';\n grid-column: 1/-1;\n grid-row: 1/-1;\n }\n\n &.rdg-dark {\n --rdg-color-scheme: dark;\n ${darkTheme}\n }\n\n &.rdg-light {\n --rdg-color-scheme: light;\n }\n\n @media (prefers-color-scheme: dark) {\n &:not(.rdg-light) {\n ${darkTheme}\n }\n }\n\n > :nth-last-child(1 of .${topSummaryRowClassname}) {\n > .${cell} {\n border-block-end: 2px solid var(--rdg-summary-border-color);\n }\n }\n\n > :nth-child(1 of .${bottomSummaryRowClassname}) {\n > .${cell} {\n border-block-start: 2px solid var(--rdg-summary-border-color);\n }\n }\n }\n`;\n\nexport const rootClassname = `rdg ${root}`;\n\nconst viewportDragging = css`\n @layer rdg.Root {\n user-select: none;\n\n & .${row} {\n cursor: move;\n }\n }\n`;\n\nexport const viewportDraggingClassname = `rdg-viewport-dragging ${viewportDragging}`;\n\nexport const focusSinkClassname = css`\n @layer rdg.FocusSink {\n grid-column: 1/-1;\n pointer-events: none;\n /* Should have a higher value than 1 to show up above regular frozen cells */\n z-index: 1;\n }\n`;\n\nexport const focusSinkHeaderAndSummaryClassname = css`\n @layer rdg.FocusSink {\n /* Should have a higher value than 3 to show up above header and summary rows */\n z-index: 3;\n }\n`;\n","import { memo } from 'react';\nimport { css } from '@linaria/core';\n\nimport { useRovingTabIndex } from './hooks';\nimport { getCellClassname, getCellStyle } from './utils';\nimport type { CellRendererProps } from './types';\n\nexport const summaryCellClassname = css`\n @layer rdg.SummaryCell {\n inset-block-start: var(--rdg-summary-row-top);\n inset-block-end: var(--rdg-summary-row-bottom);\n }\n`;\n\ntype SharedCellRendererProps<R, SR> = Pick<\n CellRendererProps<R, SR>,\n 'rowIdx' | 'column' | 'colSpan' | 'isCellSelected' | 'selectCell'\n>;\n\ninterface SummaryCellProps<R, SR> extends SharedCellRendererProps<R, SR> {\n row: SR;\n}\n\nfunction SummaryCell<R, SR>({\n column,\n colSpan,\n row,\n rowIdx,\n isCellSelected,\n selectCell\n}: SummaryCellProps<R, SR>) {\n const { tabIndex, childTabIndex, onFocus } = useRovingTabIndex(isCellSelected);\n const { summaryCellClass } = column;\n const className = getCellClassname(\n column,\n summaryCellClassname,\n typeof summaryCellClass === 'function' ? summaryCellClass(row) : summaryCellClass\n );\n\n function onClick() {\n selectCell({ rowIdx, idx: column.idx });\n }\n\n return (\n <div\n role=\"gridcell\"\n aria-colindex={column.idx + 1}\n aria-colspan={colSpan}\n aria-selected={isCellSelected}\n tabIndex={tabIndex}\n className={className}\n style={getCellStyle(column, colSpan)}\n onClick={onClick}\n onFocus={onFocus}\n >\n {column.renderSummaryCell?.({ column, row, tabIndex: childTabIndex })}\n </div>\n );\n}\n\nexport default memo(SummaryCell) as <R, SR>(props: SummaryCellProps<R, SR>) => React.JSX.Element;\n","import { memo } from 'react';\nimport { css } from '@linaria/core';\nimport clsx from 'clsx';\n\nimport { getColSpan, getRowStyle } from './utils';\nimport type { RenderRowProps } from './types';\nimport { cell, cellFrozen } from './style/cell';\nimport {\n bottomSummaryRowClassname,\n rowClassname,\n rowSelectedClassname,\n topSummaryRowClassname\n} from './style/row';\nimport SummaryCell from './SummaryCell';\n\ntype SharedRenderRowProps<R, SR> = Pick<\n RenderRowProps<R, SR>,\n 'viewportColumns' | 'rowIdx' | 'gridRowStart' | 'selectCell'\n>;\n\ninterface SummaryRowProps<R, SR> extends SharedRenderRowProps<R, SR> {\n 'aria-rowindex': number;\n row: SR;\n top: number | undefined;\n bottom: number | undefined;\n lastFrozenColumnIndex: number;\n selectedCellIdx: number | undefined;\n isTop: boolean;\n}\n\nconst summaryRow = css`\n @layer rdg.SummaryRow {\n > .${cell} {\n position: sticky;\n }\n }\n`;\n\nconst topSummaryRow = css`\n @layer rdg.SummaryRow {\n > .${cell} {\n z-index: 2;\n }\n\n > .${cellFrozen} {\n z-index: 3;\n }\n }\n`;\n\nconst summaryRowClassname = `rdg-summary-row ${summaryRow}`;\n\nfunction SummaryRow<R, SR>({\n rowIdx,\n gridRowStart,\n row,\n viewportColumns,\n top,\n bottom,\n lastFrozenColumnIndex,\n selectedCellIdx,\n isTop,\n selectCell,\n 'aria-rowindex': ariaRowIndex\n}: SummaryRowProps<R, SR>) {\n const cells = [];\n for (let index = 0; index < viewportColumns.length; index++) {\n const column = viewportColumns[index];\n const colSpan = getColSpan(column, lastFrozenColumnIndex, { type: 'SUMMARY', row });\n if (colSpan !== undefined) {\n index += colSpan - 1;\n }\n\n const isCellSelected = selectedCellIdx === column.idx;\n\n cells.push(\n <SummaryCell<R, SR>\n key={column.key}\n column={column}\n colSpan={colSpan}\n row={row}\n rowIdx={rowIdx}\n isCellSelected={isCellSelected}\n selectCell={selectCell}\n />\n );\n }\n\n return (\n <div\n role=\"row\"\n aria-rowindex={ariaRowIndex}\n className={clsx(\n rowClassname,\n `rdg-row-${rowIdx % 2 === 0 ? 'even' : 'odd'}`,\n summaryRowClassname,\n {\n [rowSelectedClassname]: selectedCellIdx === -1,\n [`${topSummaryRowClassname} ${topSummaryRow}`]: isTop,\n [bottomSummaryRowClassname]: !isTop\n }\n )}\n style={\n {\n ...getRowStyle(gridRowStart),\n '--rdg-summary-row-top': top !== undefined ? `${top}px` : undefined,\n '--rdg-summary-row-bottom': bottom !== undefined ? `${bottom}px` : undefined\n } as unknown as React.CSSProperties\n }\n >\n {cells}\n </div>\n );\n}\n\nexport default memo(SummaryRow) as <R, SR>(props: SummaryRowProps<R, SR>) => React.JSX.Element;\n","import { forwardRef, useCallback, useImperativeHandle, useMemo, useRef, useState } from 'react';\nimport type { Key, KeyboardEvent, RefAttributes } from 'react';\nimport { flushSync } from 'react-dom';\nimport clsx from 'clsx';\n\nimport {\n HeaderRowSelectionChangeProvider,\n HeaderRowSelectionProvider,\n RowSelectionChangeProvider,\n useCalculatedColumns,\n useColumnWidths,\n useGridDimensions,\n useLatestFunc,\n useLayoutEffect,\n useViewportColumns,\n useViewportRows,\n type HeaderRowSelectionContextValue\n} from './hooks';\nimport {\n abs,\n assertIsValidKeyGetter,\n canExitGrid,\n createCellEvent,\n getColSpan,\n getNextSelectedCellPosition,\n isCtrlKeyHeldDown,\n isDefaultCellInput,\n isSelectedCellEditable,\n renderMeasuringCells,\n scrollIntoView,\n sign\n} from './utils';\nimport type {\n CalculatedColumn,\n CellClickArgs,\n CellKeyboardEvent,\n CellKeyDownArgs,\n CellMouseEvent,\n CellNavigationMode,\n CellSelectArgs,\n Column,\n ColumnOrColumnGroup,\n CopyEvent,\n Direction,\n FillEvent,\n Maybe,\n PasteEvent,\n Position,\n Renderers,\n RowsChangeData,\n SelectHeaderRowEvent,\n SelectRowEvent,\n SortColumn\n} from './types';\nimport { defaultRenderCell } from './Cell';\nimport { renderCheckbox as defaultRenderCheckbox } from './cellRenderers';\nimport {\n DataGridDefaultRenderersProvider,\n useDefaultRenderers\n} from './DataGridDefaultRenderersProvider';\nimport DragHandle from './DragHandle';\nimport EditCell from './EditCell';\nimport GroupedColumnHeaderRow from './GroupedColumnHeaderRow';\nimport HeaderRow from './HeaderRow';\nimport { defaultRenderRow } from './Row';\nimport type { PartialPosition } from './ScrollToCell';\nimport ScrollToCell from './ScrollToCell';\nimport { default as defaultRenderSortStatus } from './sortStatus';\nimport {\n focusSinkClassname,\n focusSinkHeaderAndSummaryClassname,\n rootClassname,\n viewportDraggingClassname\n} from './style/core';\nimport { rowSelected, rowSelectedWithFrozenCell } from './style/row';\nimport SummaryRow from './SummaryRow';\n\nexport interface SelectCellState extends Position {\n readonly mode: 'SELECT';\n}\n\ninterface EditCellState<R> extends Position {\n readonly mode: 'EDIT';\n readonly row: R;\n readonly originalRow: R;\n}\n\nexport type DefaultColumnOptions<R, SR> = Pick<\n Column<R, SR>,\n 'renderCell' | 'width' | 'minWidth' | 'maxWidth' | 'resizable' | 'sortable' | 'draggable'\n>;\n\nexport interface DataGridHandle {\n element: HTMLDivElement | null;\n scrollToCell: (position: PartialPosition) => void;\n selectCell: (position: Position, enableEditor?: Maybe<boolean>) => void;\n}\n\ntype SharedDivProps = Pick<\n React.HTMLAttributes<HTMLDivElement>,\n | 'role'\n | 'aria-label'\n | 'aria-labelledby'\n | 'aria-description'\n | 'aria-describedby'\n | 'aria-rowcount'\n | 'className'\n | 'style'\n>;\n\nexport interface DataGridProps<R, SR = unknown, K extends Key = Key> extends SharedDivProps {\n /**\n * Grid and data Props\n */\n /** An array of objects representing each column on the grid */\n columns: readonly ColumnOrColumnGroup<NoInfer<R>, NoInfer<SR>>[];\n /** A function called for each rendered row that should return a plain key/value pair object */\n rows: readonly R[];\n /**\n * Rows to be pinned at the top of the rows view for summary, the vertical scroll bar will not scroll these rows.\n */\n topSummaryRows?: Maybe<readonly SR[]>;\n /**\n * Rows to be pinned at the bottom of the rows view for summary, the vertical scroll bar will not scroll these rows.\n */\n bottomSummaryRows?: Maybe<readonly SR[]>;\n /** The getter should return a unique key for each row */\n rowKeyGetter?: Maybe<(row: NoInfer<R>) => K>;\n onRowsChange?: Maybe<(rows: NoInfer<R>[], data: RowsChangeData<NoInfer<R>, NoInfer<SR>>) => void>;\n\n /**\n * Dimensions props\n */\n /**\n * The height of each row in pixels\n * @default 35\n */\n rowHeight?: Maybe<number | ((row: NoInfer<R>) => number)>;\n /**\n * The height of the header row in pixels\n * @default 35\n */\n headerRowHeight?: Maybe<number>;\n /**\n * The height of each summary row in pixels\n * @default 35\n */\n summaryRowHeight?: Maybe<number>;\n\n /**\n * Feature props\n */\n /** Set of selected row keys */\n selectedRows?: Maybe<ReadonlySet<K>>;\n /** Determines if row selection is disabled, per row */\n isRowSelectionDisabled?: Maybe<(row: NoInfer<R>) => boolean>;\n /** Function called whenever row selection is changed */\n onSelectedRowsChange?: Maybe<(selectedRows: Set<NoInfer<K>>) => void>;\n /** Used for multi column sorting */\n sortColumns?: Maybe<readonly SortColumn[]>;\n onSortColumnsChange?: Maybe<(sortColumns: SortColumn[]) => void>;\n defaultColumnOptions?: Maybe<DefaultColumnOptions<NoInfer<R>, NoInfer<SR>>>;\n onFill?: Maybe<(event: FillEvent<NoInfer<R>>) => NoInfer<R>>;\n onCopy?: Maybe<(event: CopyEvent<NoInfer<R>>) => void>;\n onPaste?: Maybe<(event: PasteEvent<NoInfer<R>>) => NoInfer<R>>;\n\n /**\n * Event props\n */\n /** Function called whenever a cell is clicked */\n onCellClick?: Maybe<\n (args: CellClickArgs<NoInfer<R>, NoInfer<SR>>, event: CellMouseEvent) => void\n >;\n /** Function called whenever a cell is double clicked */\n onCellDoubleClick?: Maybe<\n (args: CellClickArgs<NoInfer<R>, NoInfer<SR>>, event: CellMouseEvent) => void\n >;\n /** Function called whenever a cell is right clicked */\n onCellContextMenu?: Maybe<\n (args: CellClickArgs<NoInfer<R>, NoInfer<SR>>, event: CellMouseEvent) => void\n >;\n onCellKeyDown?: Maybe<\n (args: CellKeyDownArgs<NoInfer<R>, NoInfer<SR>>, event: CellKeyboardEvent) => void\n >;\n /** Function called whenever cell selection is changed */\n onSelectedCellChange?: Maybe<(args: CellSelectArgs<NoInfer<R>, NoInfer<SR>>) => void>;\n /** Called when the grid is scrolled */\n onScroll?: Maybe<(event: React.UIEvent<HTMLDivElement>) => void>;\n /** Called when a column is resized */\n onColumnResize?: Maybe<(column: CalculatedColumn<R, SR>, width: number) => void>;\n /** Called when a column is reordered */\n onColumnsReorder?: Maybe<(sourceColumnKey: string, targetColumnKey: string) => void>;\n\n /**\n * Toggles and modes\n */\n /** @default true */\n enableVirtualization?: Maybe<boolean>;\n\n /**\n * Miscellaneous\n */\n renderers?: Maybe<Renderers<NoInfer<R>, NoInfer<SR>>>;\n rowClass?: Maybe<(row: NoInfer<R>, rowIdx: number) => Maybe<string>>;\n /** @default 'ltr' */\n direction?: Maybe<Direction>;\n 'data-testid'?: Maybe<string>;\n 'data-cy'?: Maybe<string>;\n}\n\n/**\n * Main API Component to render a data grid of rows and columns\n *\n * @example\n *\n * <DataGrid columns={columns} rows={rows} />\n */\nfunction DataGrid<R, SR, K extends Key>(\n props: DataGridProps<R, SR, K>,\n ref: React.Ref<DataGridHandle>\n) {\n const {\n // Grid and data Props\n columns: rawColumns,\n rows,\n topSummaryRows,\n bottomSummaryRows,\n rowKeyGetter,\n onRowsChange,\n // Dimensions props\n rowHeight: rawRowHeight,\n headerRowHeight: rawHeaderRowHeight,\n summaryRowHeight: rawSummaryRowHeight,\n // Feature props\n selectedRows,\n isRowSelectionDisabled,\n onSelectedRowsChange,\n sortColumns,\n onSortColumnsChange,\n defaultColumnOptions,\n // Event props\n onCellClick,\n onCellDoubleClick,\n onCellContextMenu,\n onCellKeyDown,\n onSelectedCellChange,\n onScroll,\n onColumnResize,\n onColumnsReorder,\n onFill,\n onCopy,\n onPaste,\n // Toggles and modes\n enableVirtualization: rawEnableVirtualization,\n // Miscellaneous\n renderers,\n className,\n style,\n rowClass,\n direction: rawDirection,\n // ARIA\n role: rawRole,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-description': ariaDescription,\n 'aria-describedby': ariaDescribedBy,\n 'aria-rowcount': rawAriaRowCount,\n 'data-testid': testId,\n 'data-cy': dataCy\n } = props;\n\n /**\n * defaults\n */\n const defaultRenderers = useDefaultRenderers<R, SR>();\n const role = rawRole ?? 'grid';\n const rowHeight = rawRowHeight ?? 35;\n const headerRowHeight = rawHeaderRowHeight ?? (typeof rowHeight === 'number' ? rowHeight : 35);\n const summaryRowHeight = rawSummaryRowHeight ?? (typeof rowHeight === 'number' ? rowHeight : 35);\n const renderRow = renderers?.renderRow ?? defaultRenderers?.renderRow ?? defaultRenderRow;\n const renderCell = renderers?.renderCell ?? defaultRenderers?.renderCell ?? defaultRenderCell;\n const renderSortStatus =\n renderers?.renderSortStatus ?? defaultRenderers?.renderSortStatus ?? defaultRenderSortStatus;\n const renderCheckbox =\n renderers?.renderCheckbox ?? defaultRenderers?.renderCheckbox ?? defaultRenderCheckbox;\n const noRowsFallback = renderers?.noRowsFallback ?? defaultRenderers?.noRowsFallback;\n const enableVirtualization = rawEnableVirtualization ?? true;\n const direction = rawDirection ?? 'ltr';\n\n /**\n * states\n */\n const [scrollTop, setScrollTop] = useState(0);\n const [scrollLeft, setScrollLeft] = useState(0);\n const [resizedColumnWidths, setResizedColumnWidths] = useState(\n (): ReadonlyMap<string, number> => new Map()\n );\n const [measuredColumnWidths, setMeasuredColumnWidths] = useState(\n (): ReadonlyMap<string, number> => new Map()\n );\n const [copiedCell, setCopiedCell] = useState<{ row: R; columnKey: string } | null>(null);\n const [isDragging, setDragging] = useState(false);\n const [draggedOverRowIdx, setOverRowIdx] = useState<number | undefined>(undefined);\n const [scrollToPosition, setScrollToPosition] = useState<PartialPosition | null>(null);\n const [shouldFocusCell, setShouldFocusCell] = useState(false);\n const [previousRowIdx, setPreviousRowIdx] = useState(-1);\n\n const getColumnWidth = useCallback(\n (column: CalculatedColumn<R, SR>) => {\n return (\n resizedColumnWidths.get(column.key) ?? measuredColumnWidths.get(column.key) ?? column.width\n );\n },\n [measuredColumnWidths, resizedColumnWidths]\n );\n\n const [gridRef, gridWidth, gridHeight, horizontalScrollbarHeight] = useGridDimensions();\n const {\n columns,\n colSpanColumns,\n lastFrozenColumnIndex,\n headerRowsCount,\n colOverscanStartIdx,\n colOverscanEndIdx,\n templateColumns,\n layoutCssVars,\n totalFrozenColumnWidth\n } = useCalculatedColumns({\n rawColumns,\n defaultColumnOptions,\n getColumnWidth,\n scrollLeft,\n viewportWidth: gridWidth,\n enableVirtualization\n });\n\n const topSummaryRowsCount = topSummaryRows?.length ?? 0;\n const bottomSummaryRowsCount = bottomSummaryRows?.length ?? 0;\n const summaryRowsCount = topSummaryRowsCount + bottomSummaryRowsCount;\n const headerAndTopSummaryRowsCount = headerRowsCount + topSummaryRowsCount;\n const groupedColumnHeaderRowsCount = headerRowsCount - 1;\n const minRowIdx = -headerAndTopSummaryRowsCount;\n const mainHeaderRowIdx = minRowIdx + groupedColumnHeaderRowsCount;\n const maxRowIdx = rows.length + bottomSummaryRowsCount - 1;\n\n const [selectedPosition, setSelectedPosition] = useState(\n (): SelectCellState | EditCellState<R> => ({ idx: -1, rowIdx: minRowIdx - 1, mode: 'SELECT' })\n );\n\n /**\n * refs\n */\n const latestDraggedOverRowIdx = useRef(draggedOverRowIdx);\n const focusSinkRef = useRef<HTMLDivElement>(null);\n\n /**\n * computed values\n */\n const isTreeGrid = role === 'treegrid';\n const headerRowsHeight = headerRowsCount * headerRowHeight;\n const summaryRowsHeight = summaryRowsCount * summaryRowHeight;\n const clientHeight = gridHeight - headerRowsHeight - summaryRowsHeight;\n const isSelectable = selectedRows != null && onSelectedRowsChange != null;\n const isRtl = direction === 'rtl';\n const leftKey = isRtl ? 'ArrowRight' : 'ArrowLeft';\n const rightKey = isRtl ? 'ArrowLeft' : 'ArrowRight';\n const ariaRowCount = rawAriaRowCount ?? headerRowsCount + rows.length + summaryRowsCount;\n\n const defaultGridComponents = useMemo(\n () => ({\n renderCheckbox,\n renderSortStatus,\n renderCell\n }),\n [renderCheckbox, renderSortStatus, renderCell]\n );\n\n const headerSelectionValue = useMemo((): HeaderRowSelectionContextValue => {\n // no rows to select = explicitely unchecked\n let hasSelectedRow = false;\n let hasUnselectedRow = false;\n\n if (rowKeyGetter != null && selectedRows != null && selectedRows.size > 0) {\n for (const row of rows) {\n if (selectedRows.has(rowKeyGetter(row))) {\n hasSelectedRow = true;\n } else {\n hasUnselectedRow = true;\n }\n\n if (hasSelectedRow && hasUnselectedRow) break;\n }\n }\n\n return {\n isRowSelected: hasSelectedRow && !hasUnselectedRow,\n isIndeterminate: hasSelectedRow && hasUnselectedRow\n };\n }, [rows, selectedRows, rowKeyGetter]);\n\n const {\n rowOverscanStartIdx,\n rowOverscanEndIdx,\n totalRowHeight,\n gridTemplateRows,\n getRowTop,\n getRowHeight,\n findRowIdx\n } = useViewportRows({\n rows,\n rowHeight,\n clientHeight,\n scrollTop,\n enableVirtualization\n });\n\n const viewportColumns = useViewportColumns({\n columns,\n colSpanColumns,\n colOverscanStartIdx,\n colOverscanEndIdx,\n lastFrozenColumnIndex,\n rowOverscanStartIdx,\n rowOverscanEndIdx,\n rows,\n topSummaryRows,\n bottomSummaryRows\n });\n\n const { gridTemplateColumns, handleColumnResize } = useColumnWidths(\n columns,\n viewportColumns,\n templateColumns,\n gridRef,\n gridWidth,\n resizedColumnWidths,\n measuredColumnWidths,\n setResizedColumnWidths,\n setMeasuredColumnWidths,\n onColumnResize\n );\n\n const minColIdx = isTreeGrid ? -1 : 0;\n const maxColIdx = columns.length - 1;\n const selectedCellIsWithinSelectionBounds = isCellWithinSelectionBounds(selectedPosition);\n const selectedCellIsWithinViewportBounds = isCellWithinViewportBounds(selectedPosition);\n const scrollHeight =\n headerRowHeight + totalRowHeight + summaryRowsHeight + horizontalScrollbarHeight;\n\n /**\n * The identity of the wrapper function is stable so it won't break memoization\n */\n const handleColumnResizeLatest = useLatestFunc(handleColumnResize);\n const onColumnsReorderLastest = useLatestFunc(onColumnsReorder);\n const onSortColumnsChangeLatest = useLatestFunc(onSortColumnsChange);\n const onCellClickLatest = useLatestFunc(onCellClick);\n const onCellDoubleClickLatest = useLatestFunc(onCellDoubleClick);\n const onCellContextMenuLatest = useLatestFunc(onCellContextMenu);\n const selectHeaderRowLatest = useLatestFunc(selectHeaderRow);\n const selectRowLatest = useLatestFunc(selectRow);\n const handleFormatterRowChangeLatest = useLatestFunc(updateRow);\n const selectCellLatest = useLatestFunc(selectCell);\n const selectHeaderCellLatest = useLatestFunc(({ idx, rowIdx }: Position) => {\n selectCell({ rowIdx: minRowIdx + rowIdx - 1, idx });\n });\n\n /**\n * callbacks\n */\n const setDraggedOverRowIdx = useCallback((rowIdx?: number) => {\n setOverRowIdx(rowIdx);\n latestDraggedOverRowIdx.current = rowIdx;\n }, []);\n\n const focusCellOrCellContent = useCallback(() => {\n const cell = getCellToScroll(gridRef.current!);\n if (cell === null) return;\n\n scrollIntoView(cell);\n // Focus cell content when available instead of the cell itself\n const elementToFocus = cell.querySelector<Element & HTMLOrSVGElement>('[tabindex=\"0\"]') ?? cell;\n elementToFocus.focus({ preventScroll: true });\n }, [gridRef]);\n\n /**\n * effects\n */\n useLayoutEffect(() => {\n if (\n focusSinkRef.current !== null &&\n selectedCellIsWithinSelectionBounds &&\n selectedPosition.idx === -1\n ) {\n focusSinkRef.current.focus({ preventScroll: true });\n scrollIntoView(focusSinkRef.current);\n }\n }, [selectedCellIsWithinSelectionBounds, selectedPosition]);\n\n useLayoutEffect(() => {\n if (shouldFocusCell) {\n setShouldFocusCell(false);\n focusCellOrCellContent();\n }\n }, [shouldFocusCell, focusCellOrCellContent]);\n\n useImperativeHandle(ref, () => ({\n element: gridRef.current,\n scrollToCell({ idx, rowIdx }) {\n const scrollToIdx =\n idx !== undefined && idx > lastFrozenColumnIndex && idx < columns.length ? idx : undefined;\n const scrollToRowIdx =\n rowIdx !== undefined && isRowIdxWithinViewportBounds(rowIdx) ? rowIdx : undefined;\n\n if (scrollToIdx !== undefined || scrollToRowIdx !== undefined) {\n setScrollToPosition({ idx: scrollToIdx, rowIdx: scrollToRowIdx });\n }\n },\n selectCell\n }));\n\n /**\n * event handlers\n */\n function selectHeaderRow(args: SelectHeaderRowEvent) {\n if (!onSelectedRowsChange) return;\n\n assertIsValidKeyGetter<R, K>(rowKeyGetter);\n\n const newSelectedRows = new Set(selectedRows);\n for (const row of rows) {\n if (isRowSelectionDisabled?.(row) === true) continue;\n const rowKey = rowKeyGetter(row);\n if (args.checked) {\n newSelectedRows.add(rowKey);\n } else {\n newSelectedRows.delete(rowKey);\n }\n }\n onSelectedRowsChange(newSelectedRows);\n }\n\n function selectRow(args: SelectRowEvent<R>) {\n if (!onSelectedRowsChange) return;\n\n assertIsValidKeyGetter<R, K>(rowKeyGetter);\n const { row, checked, isShiftClick } = args;\n if (isRowSelectionDisabled?.(row) === true) return;\n const newSelectedRows = new Set(selectedRows);\n const rowKey = rowKeyGetter(row);\n const rowIdx = rows.indexOf(row);\n setPreviousRowIdx(rowIdx);\n\n if (checked) {\n newSelectedRows.add(rowKey);\n } else {\n newSelectedRows.delete(rowKey);\n }\n\n if (\n isShiftClick &&\n previousRowIdx !== -1 &&\n previousRowIdx !== rowIdx &&\n previousRowIdx < rows.length\n ) {\n const step = sign(rowIdx - previousRowIdx);\n for (let i = previousRowIdx + step; i !== rowIdx; i += step) {\n const row = rows[i];\n if (isRowSelectionDisabled?.(row) === true) continue;\n if (checked) {\n newSelectedRows.add(rowKeyGetter(row));\n } else {\n newSelectedRows.delete(rowKeyGetter(row));\n }\n }\n }\n\n onSelectedRowsChange(newSelectedRows);\n }\n\n function handleKeyDown(event: KeyboardEvent<HTMLDivElement>) {\n const { idx, rowIdx, mode } = selectedPosition;\n if (mode === 'EDIT') return;\n\n if (onCellKeyDown && isRowIdxWithinViewportBounds(rowIdx)) {\n const row = rows[rowIdx];\n const cellEvent = createCellEvent(event);\n onCellKeyDown(\n {\n mode: 'SELECT',\n row,\n column: columns[idx],\n rowIdx,\n selectCell\n },\n cellEvent\n );\n if (cellEvent.isGridDefaultPrevented()) return;\n }\n if (!(event.target instanceof Element)) return;\n const isCellEvent = event.target.closest('.rdg-cell') !== null;\n const isRowEvent = isTreeGrid && event.target === focusSinkRef.current;\n if (!isCellEvent && !isRowEvent) return;\n\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n const { keyCode } = event;\n\n if (\n selectedCellIsWithinViewportBounds &&\n (onPaste != null || onCopy != null) &&\n isCtrlKeyHeldDown(event)\n ) {\n // event.key may differ by keyboard input language, so we use event.keyCode instead\n // event.nativeEvent.code cannot be used either as it would break copy/paste for the DVORAK layout\n const cKey = 67;\n const vKey = 86;\n if (keyCode === cKey) {\n // copy highlighted text only\n if (window.getSelection()?.isCollapsed === false) return;\n handleCopy();\n return;\n }\n if (keyCode === vKey) {\n handlePaste();\n return;\n }\n }\n\n switch (event.key) {\n case 'Escape':\n setCopiedCell(null);\n return;\n case 'ArrowUp':\n case 'ArrowDown':\n case 'ArrowLeft':\n case 'ArrowRight':\n case 'Tab':\n case 'Home':\n case 'End':\n case 'PageUp':\n case 'PageDown':\n navigate(event);\n break;\n default:\n handleCellInput(event);\n break;\n }\n }\n\n function handleScroll(event: React.UIEvent<HTMLDivElement>) {\n const { scrollTop, scrollLeft } = event.currentTarget;\n flushSync(() => {\n setScrollTop(scrollTop);\n // scrollLeft is nagative when direction is rtl\n setScrollLeft(abs(scrollLeft));\n });\n onScroll?.(event);\n }\n\n function updateRow(column: CalculatedColumn<R, SR>, rowIdx: number, row: R) {\n if (typeof onRowsChange !== 'function') return;\n if (row === rows[rowIdx]) return;\n const updatedRows = [...rows];\n updatedRows[rowIdx] = row;\n onRowsChange(updatedRows, {\n indexes: [rowIdx],\n column\n });\n }\n\n function commitEditorChanges() {\n if (selectedPosition.mode !== 'EDIT') return;\n updateRow(columns[selectedPosition.idx], selectedPosition.rowIdx, selectedPosition.row);\n }\n\n function handleCopy() {\n const { idx, rowIdx } = selectedPosition;\n const sourceRow = rows[rowIdx];\n const sourceColumnKey = columns[idx].key;\n setCopiedCell({ row: sourceRow, columnKey: sourceColumnKey });\n onCopy?.({ sourceRow, sourceColumnKey });\n }\n\n function handlePaste() {\n if (!onPaste || !onRowsChange || copiedCell === null || !isCellEditable(selectedPosition)) {\n return;\n }\n\n const { idx, rowIdx } = selectedPosition;\n const targetColumn = columns[idx];\n const targetRow = rows[rowIdx];\n\n const updatedTargetRow = onPaste({\n sourceRow: copiedCell.row,\n sourceColumnKey: copiedCell.columnKey,\n targetRow,\n targetColumnKey: targetColumn.key\n });\n\n updateRow(targetColumn, rowIdx, updatedTargetRow);\n }\n\n function handleCellInput(event: KeyboardEvent<HTMLDivElement>) {\n if (!selectedCellIsWithinViewportBounds) return;\n const row = rows[selectedPosition.rowIdx];\n const { key, shiftKey } = event;\n\n // Select the row on Shift + Space\n if (isSelectable && shiftKey && key === ' ') {\n assertIsValidKeyGetter<R, K>(rowKeyGetter);\n const rowKey = rowKeyGetter(row);\n selectRow({ row, checked: !selectedRows.has(rowKey), isShiftClick: false });\n // do not scroll\n event.preventDefault();\n return;\n }\n\n if (isCellEditable(selectedPosition) && isDefaultCellInput(event)) {\n setSelectedPosition(({ idx, rowIdx }) => ({\n idx,\n rowIdx,\n mode: 'EDIT',\n row,\n originalRow: row\n }));\n }\n }\n\n /**\n * utils\n */\n function isColIdxWithinSelectionBounds(idx: number) {\n return idx >= minColIdx && idx <= maxColIdx;\n }\n\n function isRowIdxWithinViewportBounds(rowIdx: number) {\n return rowIdx >= 0 && rowIdx < rows.length;\n }\n\n function isCellWithinSelectionBounds({ idx, rowIdx }: Position): boolean {\n return rowIdx >= minRowIdx && rowIdx <= maxRowIdx && isColIdxWithinSelectionBounds(idx);\n }\n\n function isCellWithinEditBounds({ idx, rowIdx }: Position): boolean {\n return isRowIdxWithinViewportBounds(rowIdx) && idx >= 0 && idx <= maxColIdx;\n }\n\n function isCellWithinViewportBounds({ idx, rowIdx }: Position): boolean {\n return isRowIdxWithinViewportBounds(rowIdx) && isColIdxWithinSelectionBounds(idx);\n }\n\n function isCellEditable(position: Position): boolean {\n return (\n isCellWithinEditBounds(position) &&\n isSelectedCellEditable({ columns, rows, selectedPosition: position })\n );\n }\n\n function selectCell(position: Position, enableEditor?: Maybe<boolean>): void {\n if (!isCellWithinSelectionBounds(position)) return;\n commitEditorChanges();\n\n const samePosition = isSamePosition(selectedPosition, position);\n\n if (enableEditor && isCellEditable(position)) {\n const row = rows[position.rowIdx];\n setSelectedPosition({ ...position, mode: 'EDIT', row, originalRow: row });\n } else if (samePosition) {\n // Avoid re-renders if the selected cell state is the same\n scrollIntoView(getCellToScroll(gridRef.current!));\n } else {\n setShouldFocusCell(true);\n setSelectedPosition({ ...position, mode: 'SELECT' });\n }\n\n if (onSelectedCellChange && !samePosition) {\n onSelectedCellChange({\n rowIdx: position.rowIdx,\n row: isRowIdxWithinViewportBounds(position.rowIdx) ? rows[position.rowIdx] : undefined,\n column: columns[position.idx]\n });\n }\n }\n\n function getNextPosition(key: string, ctrlKey: boolean, shiftKey: boolean): Position {\n const { idx, rowIdx } = selectedPosition;\n const isRowSelected = selectedCellIsWithinSelectionBounds && idx === -1;\n\n switch (key) {\n case 'ArrowUp':\n return { idx, rowIdx: rowIdx - 1 };\n case 'ArrowDown':\n return { idx, rowIdx: rowIdx + 1 };\n case leftKey:\n return { idx: idx - 1, rowIdx };\n case rightKey:\n return { idx: idx + 1, rowIdx };\n case 'Tab':\n return { idx: idx + (shiftKey ? -1 : 1), rowIdx };\n case 'Home':\n // If row is selected then move focus to the first row\n if (isRowSelected) return { idx, rowIdx: minRowIdx };\n return { idx: 0, rowIdx: ctrlKey ? minRowIdx : rowIdx };\n case 'End':\n // If row is selected then move focus to the last row.\n if (isRowSelected) return { idx, rowIdx: maxRowIdx };\n return { idx: maxColIdx, rowIdx: ctrlKey ? maxRowIdx : rowIdx };\n case 'PageUp': {\n if (selectedPosition.rowIdx === minRowIdx) return selectedPosition;\n const nextRowY = getRowTop(rowIdx) + getRowHeight(rowIdx) - clientHeight;\n return { idx, rowIdx: nextRowY > 0 ? findRowIdx(nextRowY) : 0 };\n }\n case 'PageDown': {\n if (selectedPosition.rowIdx >= rows.length) return selectedPosition;\n const nextRowY = getRowTop(rowIdx) + clientHeight;\n return { idx, rowIdx: nextRowY < totalRowHeight ? findRowIdx(nextRowY) : rows.length - 1 };\n }\n default:\n return selectedPosition;\n }\n }\n\n function navigate(event: KeyboardEvent<HTMLDivElement>) {\n const { key, shiftKey } = event;\n let cellNavigationMode: CellNavigationMode = 'NONE';\n if (key === 'Tab') {\n if (\n canExitGrid({\n shiftKey,\n maxColIdx,\n minRowIdx,\n maxRowIdx,\n selectedPosition\n })\n ) {\n commitEditorChanges();\n // Allow focus to leave the grid so the next control in the tab order can be focused\n return;\n }\n\n cellNavigationMode = 'CHANGE_ROW';\n }\n\n // Do not allow focus to leave and prevent scrolling\n event.preventDefault();\n\n const ctrlKey = isCtrlKeyHeldDown(event);\n const nextPosition = getNextPosition(key, ctrlKey, shiftKey);\n if (isSamePosition(selectedPosition, nextPosition)) return;\n\n const nextSelectedCellPosition = getNextSelectedCellPosition({\n moveUp: key === 'ArrowUp',\n moveNext: key === rightKey || (key === 'Tab' && !shiftKey),\n columns,\n colSpanColumns,\n rows,\n topSummaryRows,\n bottomSummaryRows,\n minRowIdx,\n mainHeaderRowIdx,\n maxRowIdx,\n lastFrozenColumnIndex,\n cellNavigationMode,\n currentPosition: selectedPosition,\n nextPosition,\n isCellWithinBounds: isCellWithinSelectionBounds\n });\n\n selectCell(nextSelectedCellPosition);\n }\n\n function getDraggedOverCellIdx(currentRowIdx: number): number | undefined {\n if (draggedOverRowIdx === undefined) return;\n const { rowIdx } = selectedPosition;\n\n const isDraggedOver =\n rowIdx < draggedOverRowIdx\n ? rowIdx < currentRowIdx && currentRowIdx <= draggedOverRowIdx\n : rowIdx > currentRowIdx && currentRowIdx >= draggedOverRowIdx;\n\n return isDraggedOver ? selectedPosition.idx : undefined;\n }\n\n function renderDragHandle() {\n if (\n onFill == null ||\n selectedPosition.mode === 'EDIT' ||\n !isCellWithinViewportBounds(selectedPosition)\n ) {\n return;\n }\n\n const { idx, rowIdx } = selectedPosition;\n const column = columns[idx];\n if (column.renderEditCell == null || column.editable === false) {\n return;\n }\n\n const columnWidth = getColumnWidth(column);\n\n return (\n <DragHandle\n gridRowStart={headerAndTopSummaryRowsCount + rowIdx + 1}\n rows={rows}\n column={column}\n columnWidth={columnWidth}\n maxColIdx={maxColIdx}\n isLastRow={rowIdx === maxRowIdx}\n selectedPosition={selectedPosition}\n isCellEditable={isCellEditable}\n latestDraggedOverRowIdx={latestDraggedOverRowIdx}\n onRowsChange={onRowsChange}\n onClick={focusCellOrCellContent}\n onFill={onFill}\n setDragging={setDragging}\n setDraggedOverRowIdx={setDraggedOverRowIdx}\n />\n );\n }\n\n function getCellEditor(rowIdx: number) {\n if (selectedPosition.rowIdx !== rowIdx || selectedPosition.mode === 'SELECT') return;\n\n const { idx, row } = selectedPosition;\n const column = columns[idx];\n const colSpan = getColSpan(column, lastFrozenColumnIndex, { type: 'ROW', row });\n\n const closeEditor = (shouldFocusCell: boolean) => {\n setShouldFocusCell(shouldFocusCell);\n setSelectedPosition(({ idx, rowIdx }) => ({ idx, rowIdx, mode: 'SELECT' }));\n };\n\n const onRowChange = (row: R, commitChanges: boolean, shouldFocusCell: boolean) => {\n if (commitChanges) {\n // Prevents two issues when editor is closed by clicking on a different cell\n //\n // Otherwise commitEditorChanges may be called before the cell state is changed to\n // SELECT and this results in onRowChange getting called twice.\n flushSync(() => {\n updateRow(column, selectedPosition.rowIdx, row);\n closeEditor(shouldFocusCell);\n });\n } else {\n setSelectedPosition((position) => ({ ...position, row }));\n }\n };\n\n if (rows[selectedPosition.rowIdx] !== selectedPosition.originalRow) {\n // Discard changes if rows are updated from outside\n closeEditor(false);\n }\n\n return (\n <EditCell\n key={column.key}\n column={column}\n colSpan={colSpan}\n row={row}\n rowIdx={rowIdx}\n onRowChange={onRowChange}\n closeEditor={closeEditor}\n onKeyDown={onCellKeyDown}\n navigate={navigate}\n />\n );\n }\n\n function getRowViewportColumns(rowIdx: number) {\n // idx can be -1 if grouping is enabled\n const selectedColumn = selectedPosition.idx === -1 ? undefined : columns[selectedPosition.idx];\n if (\n selectedColumn !== undefined &&\n selectedPosition.rowIdx === rowIdx &&\n !viewportColumns.includes(selectedColumn)\n ) {\n // Add the selected column to viewport columns if the cell is not within the viewport\n return selectedPosition.idx > colOverscanEndIdx\n ? [...viewportColumns, selectedColumn]\n : [\n ...viewportColumns.slice(0, lastFrozenColumnIndex + 1),\n selectedColumn,\n ...viewportColumns.slice(lastFrozenColumnIndex + 1)\n ];\n }\n return viewportColumns;\n }\n\n function getViewportRows() {\n const rowElements: React.ReactNode[] = [];\n\n const { idx: selectedIdx, rowIdx: selectedRowIdx } = selectedPosition;\n\n const startRowIdx =\n selectedCellIsWithinViewportBounds && selectedRowIdx < rowOverscanStartIdx\n ? rowOverscanStartIdx - 1\n : rowOverscanStartIdx;\n const endRowIdx =\n selectedCellIsWithinViewportBounds && selectedRowIdx > rowOverscanEndIdx\n ? rowOverscanEndIdx + 1\n : rowOverscanEndIdx;\n\n for (let viewportRowIdx = startRowIdx; viewportRowIdx <= endRowIdx; viewportRowIdx++) {\n const isRowOutsideViewport =\n viewportRowIdx === rowOverscanStartIdx - 1 || viewportRowIdx === rowOverscanEndIdx + 1;\n const rowIdx = isRowOutsideViewport ? selectedRowIdx : viewportRowIdx;\n\n let rowColumns = viewportColumns;\n const selectedColumn = selectedIdx === -1 ? undefined : columns[selectedIdx];\n if (selectedColumn !== undefined) {\n if (isRowOutsideViewport) {\n // if the row is outside the viewport then only render the selected cell\n rowColumns = [selectedColumn];\n } else {\n // if the row is within the viewport and cell is not, add the selected column to viewport columns\n rowColumns = getRowViewportColumns(rowIdx);\n }\n }\n\n const row = rows[rowIdx];\n const gridRowStart = headerAndTopSummaryRowsCount + rowIdx + 1;\n let key: K | number = rowIdx;\n let isRowSelected = false;\n if (typeof rowKeyGetter === 'function') {\n key = rowKeyGetter(row);\n isRowSelected = selectedRows?.has(key) ?? false;\n }\n\n rowElements.push(\n renderRow(key, {\n // aria-rowindex is 1 based\n 'aria-rowindex': headerAndTopSummaryRowsCount + rowIdx + 1,\n 'aria-selected': isSelectable ? isRowSelected : undefined,\n rowIdx,\n row,\n viewportColumns: rowColumns,\n isRowSelectionDisabled: isRowSelectionDisabled?.(row) ?? false,\n isRowSelected,\n onCellClick: onCellClickLatest,\n onCellDoubleClick: onCellDoubleClickLatest,\n onCellContextMenu: onCellContextMenuLatest,\n rowClass,\n gridRowStart,\n copiedCellIdx:\n copiedCell !== null && copiedCell.row === row\n ? columns.findIndex((c) => c.key === copiedCell.columnKey)\n : undefined,\n\n selectedCellIdx: selectedRowIdx === rowIdx ? selectedIdx : undefined,\n draggedOverCellIdx: getDraggedOverCellIdx(rowIdx),\n setDraggedOverRowIdx: isDragging ? setDraggedOverRowIdx : undefined,\n lastFrozenColumnIndex,\n onRowChange: handleFormatterRowChangeLatest,\n selectCell: selectCellLatest,\n selectedCellEditor: getCellEditor(rowIdx)\n })\n );\n }\n\n return rowElements;\n }\n\n // Reset the positions if the current values are no longer valid. This can happen if a column or row is removed\n if (selectedPosition.idx > maxColIdx || selectedPosition.rowIdx > maxRowIdx) {\n setSelectedPosition({ idx: -1, rowIdx: minRowIdx - 1, mode: 'SELECT' });\n setDraggedOverRowIdx(undefined);\n }\n\n let templateRows = `repeat(${headerRowsCount}, ${headerRowHeight}px)`;\n if (topSummaryRowsCount > 0) {\n templateRows += ` repeat(${topSummaryRowsCount}, ${summaryRowHeight}px)`;\n }\n if (rows.length > 0) {\n templateRows += gridTemplateRows;\n }\n if (bottomSummaryRowsCount > 0) {\n templateRows += ` repeat(${bottomSummaryRowsCount}, ${summaryRowHeight}px)`;\n }\n\n const isGroupRowFocused =\n selectedPosition.idx === -1 && selectedPosition.rowIdx !== minRowIdx - 1;\n\n return (\n // biome-ignore lint/a11y/useValidAriaProps: aria-description is a valid prop\n <div\n role={role}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n aria-description={ariaDescription}\n aria-describedby={ariaDescribedBy}\n aria-multiselectable={isSelectable ? true : undefined}\n aria-colcount={columns.length}\n aria-rowcount={ariaRowCount}\n className={clsx(\n rootClassname,\n {\n [viewportDraggingClassname]: isDragging\n },\n className\n )}\n style={\n {\n ...style,\n // set scrollPadding to correctly position non-sticky cells after scrolling\n scrollPaddingInlineStart:\n selectedPosition.idx > lastFrozenColumnIndex || scrollToPosition?.idx !== undefined\n ? `${totalFrozenColumnWidth}px`\n : undefined,\n scrollPaddingBlock:\n isRowIdxWithinViewportBounds(selectedPosition.rowIdx) ||\n scrollToPosition?.rowIdx !== undefined\n ? `${headerRowsHeight + topSummaryRowsCount * summaryRowHeight}px ${\n bottomSummaryRowsCount * summaryRowHeight\n }px`\n : undefined,\n gridTemplateColumns,\n gridTemplateRows: templateRows,\n '--rdg-header-row-height': `${headerRowHeight}px`,\n '--rdg-scroll-height': `${scrollHeight}px`,\n ...layoutCssVars\n } as unknown as React.CSSProperties\n }\n dir={direction}\n ref={gridRef}\n onScroll={handleScroll}\n onKeyDown={handleKeyDown}\n data-testid={testId}\n data-cy={dataCy}\n >\n <DataGridDefaultRenderersProvider value={defaultGridComponents}>\n <HeaderRowSelectionChangeProvider value={selectHeaderRowLatest}>\n <HeaderRowSelectionProvider value={headerSelectionValue}>\n {Array.from({ length: groupedColumnHeaderRowsCount }, (_, index) => (\n <GroupedColumnHeaderRow\n key={index}\n rowIdx={index + 1}\n level={-groupedColumnHeaderRowsCount + index}\n columns={getRowViewportColumns(minRowIdx + index)}\n selectedCellIdx={\n selectedPosition.rowIdx === minRowIdx + index ? selectedPosition.idx : undefined\n }\n selectCell={selectHeaderCellLatest}\n />\n ))}\n <HeaderRow\n rowIdx={headerRowsCount}\n columns={getRowViewportColumns(mainHeaderRowIdx)}\n onColumnResize={handleColumnResizeLatest}\n onColumnsReorder={onColumnsReorderLastest}\n sortColumns={sortColumns}\n onSortColumnsChange={onSortColumnsChangeLatest}\n lastFrozenColumnIndex={lastFrozenColumnIndex}\n selectedCellIdx={\n selectedPosition.rowIdx === mainHeaderRowIdx ? selectedPosition.idx : undefined\n }\n selectCell={selectHeaderCellLatest}\n shouldFocusGrid={!selectedCellIsWithinSelectionBounds}\n direction={direction}\n />\n </HeaderRowSelectionProvider>\n </HeaderRowSelectionChangeProvider>\n {rows.length === 0 && noRowsFallback ? (\n noRowsFallback\n ) : (\n <>\n {topSummaryRows?.map((row, rowIdx) => {\n const gridRowStart = headerRowsCount + 1 + rowIdx;\n const summaryRowIdx = mainHeaderRowIdx + 1 + rowIdx;\n const isSummaryRowSelected = selectedPosition.rowIdx === summaryRowIdx;\n const top = headerRowsHeight + summaryRowHeight * rowIdx;\n\n return (\n <SummaryRow\n key={rowIdx}\n aria-rowindex={gridRowStart}\n rowIdx={summaryRowIdx}\n gridRowStart={gridRowStart}\n row={row}\n top={top}\n bottom={undefined}\n viewportColumns={getRowViewportColumns(summaryRowIdx)}\n lastFrozenColumnIndex={lastFrozenColumnIndex}\n selectedCellIdx={isSummaryRowSelected ? selectedPosition.idx : undefined}\n isTop\n selectCell={selectCellLatest}\n />\n );\n })}\n <RowSelectionChangeProvider value={selectRowLatest}>\n {getViewportRows()}\n </RowSelectionChangeProvider>\n {bottomSummaryRows?.map((row, rowIdx) => {\n const gridRowStart = headerAndTopSummaryRowsCount + rows.length + rowIdx + 1;\n const summaryRowIdx = rows.length + rowIdx;\n const isSummaryRowSelected = selectedPosition.rowIdx === summaryRowIdx;\n const top =\n clientHeight > totalRowHeight\n ? gridHeight - summaryRowHeight * (bottomSummaryRows.length - rowIdx)\n : undefined;\n const bottom =\n top === undefined\n ? summaryRowHeight * (bottomSummaryRows.length - 1 - rowIdx)\n : undefined;\n\n return (\n <SummaryRow\n aria-rowindex={ariaRowCount - bottomSummaryRowsCount + rowIdx + 1}\n key={rowIdx}\n rowIdx={summaryRowIdx}\n gridRowStart={gridRowStart}\n row={row}\n top={top}\n bottom={bottom}\n viewportColumns={getRowViewportColumns(summaryRowIdx)}\n lastFrozenColumnIndex={lastFrozenColumnIndex}\n selectedCellIdx={isSummaryRowSelected ? selectedPosition.idx : undefined}\n isTop={false}\n selectCell={selectCellLatest}\n />\n );\n })}\n </>\n )}\n </DataGridDefaultRenderersProvider>\n\n {renderDragHandle()}\n\n {/* render empty cells that span only 1 column so we can safely measure column widths, regardless of colSpan */}\n {renderMeasuringCells(viewportColumns)}\n\n {/* extra div is needed for row navigation in a treegrid */}\n {isTreeGrid && (\n <div\n ref={focusSinkRef}\n tabIndex={isGroupRowFocused ? 0 : -1}\n className={clsx(focusSinkClassname, {\n [focusSinkHeaderAndSummaryClassname]: !isRowIdxWithinViewportBounds(\n selectedPosition.rowIdx\n ),\n [rowSelected]: isGroupRowFocused,\n [rowSelectedWithFrozenCell]: isGroupRowFocused && lastFrozenColumnIndex !== -1\n })}\n style={{\n gridRowStart: selectedPosition.rowIdx + headerAndTopSummaryRowsCount + 1\n }}\n />\n )}\n\n {scrollToPosition !== null && (\n <ScrollToCell\n scrollToPosition={scrollToPosition}\n setScrollToCellPosition={setScrollToPosition}\n gridRef={gridRef}\n />\n )}\n </div>\n );\n}\n\nfunction getCellToScroll(gridEl: HTMLDivElement) {\n return gridEl.querySelector<HTMLDivElement>(':scope > [role=\"row\"] > [tabindex=\"0\"]');\n}\n\nfunction isSamePosition(p1: Position, p2: Position) {\n return p1.idx === p2.idx && p1.rowIdx === p2.rowIdx;\n}\n\nexport default forwardRef(DataGrid) as <R, SR = unknown, K extends Key = Key>(\n props: DataGridProps<R, SR, K> & RefAttributes<DataGridHandle>\n) => React.JSX.Element;\n","import { memo } from 'react';\n\nimport { useRovingTabIndex } from './hooks';\nimport { getCellClassname, getCellStyle } from './utils';\nimport type { CalculatedColumn, GroupRow } from './types';\n\ninterface GroupCellProps<R, SR> {\n id: string;\n groupKey: unknown;\n childRows: readonly R[];\n toggleGroup: (expandedGroupId: unknown) => void;\n isExpanded: boolean;\n column: CalculatedColumn<R, SR>;\n row: GroupRow<R>;\n isCellSelected: boolean;\n groupColumnIndex: number;\n isGroupByColumn: boolean;\n}\n\nfunction GroupCell<R, SR>({\n id,\n groupKey,\n childRows,\n isExpanded,\n isCellSelected,\n column,\n row,\n groupColumnIndex,\n isGroupByColumn,\n toggleGroup: toggleGroupWrapper\n}: GroupCellProps<R, SR>) {\n const { tabIndex, childTabIndex, onFocus } = useRovingTabIndex(isCellSelected);\n\n function toggleGroup() {\n toggleGroupWrapper(id);\n }\n\n // Only make the cell clickable if the group level matches\n const isLevelMatching = isGroupByColumn && groupColumnIndex === column.idx;\n\n return (\n <div\n role=\"gridcell\"\n aria-colindex={column.idx + 1}\n aria-selected={isCellSelected}\n tabIndex={tabIndex}\n key={column.key}\n className={getCellClassname(column)}\n style={{\n ...getCellStyle(column),\n cursor: isLevelMatching ? 'pointer' : 'default'\n }}\n onClick={isLevelMatching ? toggleGroup : undefined}\n onFocus={onFocus}\n >\n {(!isGroupByColumn || isLevelMatching) &&\n column.renderGroupCell?.({\n groupKey,\n childRows,\n column,\n row,\n isExpanded,\n tabIndex: childTabIndex,\n toggleGroup\n })}\n </div>\n );\n}\n\nexport default memo(GroupCell) as <R, SR>(props: GroupCellProps<R, SR>) => React.JSX.Element;\n","import { memo, useMemo } from 'react';\nimport { css } from '@linaria/core';\nimport clsx from 'clsx';\n\nimport { RowSelectionProvider, type RowSelectionContextValue } from './hooks';\nimport { getRowStyle } from './utils';\nimport type { BaseRenderRowProps, GroupRow } from './types';\nimport { SELECT_COLUMN_KEY } from './Columns';\nimport GroupCell from './GroupCell';\nimport { cell, cellFrozen } from './style/cell';\nimport { rowClassname, rowSelectedClassname } from './style/row';\n\nconst groupRow = css`\n @layer rdg.GroupedRow {\n &:not([aria-selected='true']) {\n background-color: var(--rdg-header-background-color);\n }\n\n > .${cell}:not(:last-child, .${cellFrozen}),\n > :nth-last-child(n + 2 of .${cellFrozen}) {\n border-inline-end: none;\n }\n }\n`;\n\nconst groupRowClassname = `rdg-group-row ${groupRow}`;\n\ninterface GroupRowRendererProps<R, SR> extends BaseRenderRowProps<R, SR> {\n row: GroupRow<R>;\n groupBy: readonly string[];\n toggleGroup: (expandedGroupId: unknown) => void;\n}\n\nfunction GroupedRow<R, SR>({\n className,\n row,\n rowIdx,\n viewportColumns,\n selectedCellIdx,\n isRowSelected,\n selectCell,\n gridRowStart,\n groupBy,\n toggleGroup,\n isRowSelectionDisabled,\n ...props\n}: GroupRowRendererProps<R, SR>) {\n // Select is always the first column\n const idx = viewportColumns[0].key === SELECT_COLUMN_KEY ? row.level + 1 : row.level;\n\n function handleSelectGroup() {\n selectCell({ rowIdx, idx: -1 });\n }\n\n const selectionValue = useMemo(\n (): RowSelectionContextValue => ({ isRowSelectionDisabled: false, isRowSelected }),\n [isRowSelected]\n );\n\n return (\n <RowSelectionProvider value={selectionValue}>\n <div\n role=\"row\"\n aria-level={row.level + 1} // aria-level is 1-based\n aria-setsize={row.setSize}\n aria-posinset={row.posInSet + 1} // aria-posinset is 1-based\n aria-expanded={row.isExpanded}\n className={clsx(\n rowClassname,\n groupRowClassname,\n `rdg-row-${rowIdx % 2 === 0 ? 'even' : 'odd'}`,\n selectedCellIdx === -1 && rowSelectedClassname,\n className\n )}\n onClick={handleSelectGroup}\n style={getRowStyle(gridRowStart)}\n {...props}\n >\n {viewportColumns.map((column) => (\n <GroupCell\n key={column.key}\n id={row.id}\n groupKey={row.groupKey}\n childRows={row.childRows}\n isExpanded={row.isExpanded}\n isCellSelected={selectedCellIdx === column.idx}\n column={column}\n row={row}\n groupColumnIndex={idx}\n toggleGroup={toggleGroup}\n isGroupByColumn={groupBy.includes(column.key)}\n />\n ))}\n </div>\n </RowSelectionProvider>\n );\n}\n\nexport default memo(GroupedRow) as <R, SR>(\n props: GroupRowRendererProps<R, SR>\n) => React.JSX.Element;\n","import { forwardRef, useCallback, useMemo } from 'react';\nimport type { Key, RefAttributes } from 'react';\n\nimport { useLatestFunc } from './hooks';\nimport { assertIsValidKeyGetter, isCtrlKeyHeldDown } from './utils';\nimport type {\n CellKeyboardEvent,\n CellKeyDownArgs,\n Column,\n GroupRow,\n Maybe,\n Omit,\n RenderRowProps,\n RowHeightArgs,\n RowsChangeData\n} from './types';\nimport { renderToggleGroup } from './cellRenderers';\nimport { SELECT_COLUMN_KEY } from './Columns';\nimport DataGrid from './DataGrid';\nimport type { DataGridHandle, DataGridProps } from './DataGrid';\nimport { useDefaultRenderers } from './DataGridDefaultRenderersProvider';\nimport GroupedRow from './GroupRow';\nimport { defaultRenderRow } from './Row';\n\nexport interface TreeDataGridProps<R, SR = unknown, K extends Key = Key>\n extends Omit<\n DataGridProps<R, SR, K>,\n 'columns' | 'role' | 'aria-rowcount' | 'rowHeight' | 'onFill' | 'isRowSelectionDisabled'\n > {\n columns: readonly Column<NoInfer<R>, NoInfer<SR>>[];\n rowHeight?: Maybe<number | ((args: RowHeightArgs<NoInfer<R>>) => number)>;\n groupBy: readonly string[];\n rowGrouper: (\n rows: readonly NoInfer<R>[],\n columnKey: string\n ) => Record<string, readonly NoInfer<R>[]>;\n expandedGroupIds: ReadonlySet<unknown>;\n onExpandedGroupIdsChange: (expandedGroupIds: Set<unknown>) => void;\n}\n\ntype GroupByDictionary<TRow> = Record<\n string,\n {\n readonly childRows: readonly TRow[];\n readonly childGroups: readonly TRow[] | Readonly<GroupByDictionary<TRow>>;\n readonly startRowIndex: number;\n }\n>;\n\nfunction TreeDataGrid<R, SR, K extends Key>(\n {\n columns: rawColumns,\n rows: rawRows,\n rowHeight: rawRowHeight,\n rowKeyGetter: rawRowKeyGetter,\n onCellKeyDown: rawOnCellKeyDown,\n onRowsChange,\n selectedRows: rawSelectedRows,\n onSelectedRowsChange: rawOnSelectedRowsChange,\n renderers,\n groupBy: rawGroupBy,\n rowGrouper,\n expandedGroupIds,\n onExpandedGroupIdsChange,\n ...props\n }: TreeDataGridProps<R, SR, K>,\n ref: React.Ref<DataGridHandle>\n) {\n const defaultRenderers = useDefaultRenderers<R, SR>();\n const rawRenderRow = renderers?.renderRow ?? defaultRenderers?.renderRow ?? defaultRenderRow;\n const headerAndTopSummaryRowsCount = 1 + (props.topSummaryRows?.length ?? 0);\n const isRtl = props.direction === 'rtl';\n const leftKey = isRtl ? 'ArrowRight' : 'ArrowLeft';\n const rightKey = isRtl ? 'ArrowLeft' : 'ArrowRight';\n const toggleGroupLatest = useLatestFunc(toggleGroup);\n\n const { columns, groupBy } = useMemo(() => {\n const columns = [...rawColumns].sort(({ key: aKey }, { key: bKey }) => {\n // Sort select column first:\n if (aKey === SELECT_COLUMN_KEY) return -1;\n if (bKey === SELECT_COLUMN_KEY) return 1;\n\n // Sort grouped columns second, following the groupBy order:\n if (rawGroupBy.includes(aKey)) {\n if (rawGroupBy.includes(bKey)) {\n return rawGroupBy.indexOf(aKey) - rawGroupBy.indexOf(bKey);\n }\n return -1;\n }\n if (rawGroupBy.includes(bKey)) return 1;\n\n // Sort other columns last:\n return 0;\n });\n\n const groupBy: string[] = [];\n for (const [index, column] of columns.entries()) {\n if (rawGroupBy.includes(column.key)) {\n groupBy.push(column.key);\n columns[index] = {\n ...column,\n frozen: true,\n renderCell: () => null,\n renderGroupCell: column.renderGroupCell ?? renderToggleGroup,\n editable: false\n };\n }\n }\n\n return { columns, groupBy };\n }, [rawColumns, rawGroupBy]);\n\n const [groupedRows, rowsCount] = useMemo(() => {\n if (groupBy.length === 0) return [undefined, rawRows.length];\n\n const groupRows = (\n rows: readonly R[],\n [groupByKey, ...remainingGroupByKeys]: readonly string[],\n startRowIndex: number\n ): [Readonly<GroupByDictionary<R>>, number] => {\n let groupRowsCount = 0;\n const groups: GroupByDictionary<R> = {};\n for (const [key, childRows] of Object.entries(rowGrouper(rows, groupByKey))) {\n // Recursively group each parent group\n const [childGroups, childRowsCount] =\n remainingGroupByKeys.length === 0\n ? [childRows, childRows.length]\n : groupRows(childRows, remainingGroupByKeys, startRowIndex + groupRowsCount + 1); // 1 for parent row\n groups[key] = { childRows, childGroups, startRowIndex: startRowIndex + groupRowsCount };\n groupRowsCount += childRowsCount + 1; // 1 for parent row\n }\n\n return [groups, groupRowsCount];\n };\n\n return groupRows(rawRows, groupBy, 0);\n }, [groupBy, rowGrouper, rawRows]);\n\n const [rows, isGroupRow] = useMemo((): [\n ReadonlyArray<R | GroupRow<R>>,\n (row: R | GroupRow<R>) => row is GroupRow<R>\n ] => {\n const allGroupRows = new Set<unknown>();\n if (!groupedRows) return [rawRows, isGroupRow];\n\n const flattenedRows: Array<R | GroupRow<R>> = [];\n const expandGroup = (\n rows: GroupByDictionary<R> | readonly R[],\n parentId: string | undefined,\n level: number\n ): void => {\n if (isReadonlyArray(rows)) {\n flattenedRows.push(...rows);\n return;\n }\n Object.keys(rows).forEach((groupKey, posInSet, keys) => {\n // TODO: should users have control over the generated key?\n const id = parentId !== undefined ? `${parentId}__${groupKey}` : groupKey;\n const isExpanded = expandedGroupIds.has(id);\n const { childRows, childGroups, startRowIndex } = rows[groupKey];\n\n const groupRow: GroupRow<R> = {\n id,\n parentId,\n groupKey,\n isExpanded,\n childRows,\n level,\n posInSet,\n startRowIndex,\n setSize: keys.length\n };\n flattenedRows.push(groupRow);\n allGroupRows.add(groupRow);\n\n if (isExpanded) {\n expandGroup(childGroups, id, level + 1);\n }\n });\n };\n\n expandGroup(groupedRows, undefined, 0);\n return [flattenedRows, isGroupRow];\n\n function isGroupRow(row: R | GroupRow<R>): row is GroupRow<R> {\n return allGroupRows.has(row);\n }\n }, [expandedGroupIds, groupedRows, rawRows]);\n\n const rowHeight = useMemo(() => {\n if (typeof rawRowHeight === 'function') {\n return (row: R | GroupRow<R>): number => {\n if (isGroupRow(row)) {\n return rawRowHeight({ type: 'GROUP', row });\n }\n return rawRowHeight({ type: 'ROW', row });\n };\n }\n\n return rawRowHeight;\n }, [isGroupRow, rawRowHeight]);\n\n const getParentRowAndIndex = useCallback(\n (row: R | GroupRow<R>) => {\n const rowIdx = rows.indexOf(row);\n for (let i = rowIdx - 1; i >= 0; i--) {\n const parentRow = rows[i];\n if (isGroupRow(parentRow) && (!isGroupRow(row) || row.parentId === parentRow.id)) {\n return [parentRow, i] as const;\n }\n }\n\n return undefined;\n },\n [isGroupRow, rows]\n );\n\n const rowKeyGetter = useCallback(\n (row: R | GroupRow<R>) => {\n if (isGroupRow(row)) {\n return row.id;\n }\n\n if (typeof rawRowKeyGetter === 'function') {\n return rawRowKeyGetter(row);\n }\n\n const parentRowAndIndex = getParentRowAndIndex(row);\n if (parentRowAndIndex !== undefined) {\n const { startRowIndex, childRows } = parentRowAndIndex[0];\n const groupIndex = childRows.indexOf(row);\n return startRowIndex + groupIndex + 1;\n }\n\n return rows.indexOf(row);\n },\n [getParentRowAndIndex, isGroupRow, rawRowKeyGetter, rows]\n );\n\n const selectedRows = useMemo((): Maybe<ReadonlySet<Key>> => {\n if (rawSelectedRows == null) return null;\n\n assertIsValidKeyGetter<R, K>(rawRowKeyGetter);\n\n const selectedRows = new Set<Key>(rawSelectedRows);\n for (const row of rows) {\n if (isGroupRow(row)) {\n // select parent row if all the children are selected\n const isGroupRowSelected = row.childRows.every((cr) =>\n rawSelectedRows.has(rawRowKeyGetter(cr))\n );\n if (isGroupRowSelected) {\n selectedRows.add(row.id);\n }\n }\n }\n\n return selectedRows;\n }, [isGroupRow, rawRowKeyGetter, rawSelectedRows, rows]);\n\n function onSelectedRowsChange(newSelectedRows: Set<Key>) {\n if (!rawOnSelectedRowsChange) return;\n\n assertIsValidKeyGetter<R, K>(rawRowKeyGetter);\n\n const newRawSelectedRows = new Set(rawSelectedRows);\n for (const row of rows) {\n const key = rowKeyGetter(row);\n if (selectedRows?.has(key) && !newSelectedRows.has(key)) {\n if (isGroupRow(row)) {\n // select all children if the parent row is selected\n for (const cr of row.childRows) {\n newRawSelectedRows.delete(rawRowKeyGetter(cr));\n }\n } else {\n newRawSelectedRows.delete(key as K);\n }\n } else if (!selectedRows?.has(key) && newSelectedRows.has(key)) {\n if (isGroupRow(row)) {\n // unselect all children if the parent row is unselected\n for (const cr of row.childRows) {\n newRawSelectedRows.add(rawRowKeyGetter(cr));\n }\n } else {\n newRawSelectedRows.add(key as K);\n }\n }\n }\n\n rawOnSelectedRowsChange(newRawSelectedRows);\n }\n\n function handleKeyDown(args: CellKeyDownArgs<R, SR>, event: CellKeyboardEvent) {\n rawOnCellKeyDown?.(args, event);\n if (event.isGridDefaultPrevented()) return;\n\n if (args.mode === 'EDIT') return;\n const { column, rowIdx, selectCell } = args;\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n const idx = column?.idx ?? -1;\n const row = rows[rowIdx];\n\n if (!isGroupRow(row)) return;\n if (\n idx === -1 &&\n // Collapse the current group row if it is focused and is in expanded state\n ((event.key === leftKey && row.isExpanded) ||\n // Expand the current group row if it is focused and is in collapsed state\n (event.key === rightKey && !row.isExpanded))\n ) {\n event.preventDefault(); // Prevents scrolling\n event.preventGridDefault();\n toggleGroup(row.id);\n }\n\n // If a group row is focused, and it is collapsed, move to the parent group row (if there is one).\n if (idx === -1 && event.key === leftKey && !row.isExpanded && row.level !== 0) {\n const parentRowAndIndex = getParentRowAndIndex(row);\n if (parentRowAndIndex !== undefined) {\n event.preventGridDefault();\n selectCell({ idx, rowIdx: parentRowAndIndex[1] });\n }\n }\n\n // Prevent copy/paste on group rows\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n if (isCtrlKeyHeldDown(event) && (event.keyCode === 67 || event.keyCode === 86)) {\n event.preventGridDefault();\n }\n }\n\n function handleRowsChange(updatedRows: R[], { indexes, column }: RowsChangeData<R, SR>) {\n if (!onRowsChange) return;\n const updatedRawRows = [...rawRows];\n const rawIndexes: number[] = [];\n for (const index of indexes) {\n const rawIndex = rawRows.indexOf(rows[index] as R);\n updatedRawRows[rawIndex] = updatedRows[index];\n rawIndexes.push(rawIndex);\n }\n onRowsChange(updatedRawRows, {\n indexes: rawIndexes,\n column\n });\n }\n\n function toggleGroup(groupId: unknown) {\n const newExpandedGroupIds = new Set(expandedGroupIds);\n if (newExpandedGroupIds.has(groupId)) {\n newExpandedGroupIds.delete(groupId);\n } else {\n newExpandedGroupIds.add(groupId);\n }\n onExpandedGroupIdsChange(newExpandedGroupIds);\n }\n\n function renderRow(\n key: Key,\n {\n row,\n rowClass,\n onCellClick,\n onCellDoubleClick,\n onCellContextMenu,\n onRowChange,\n lastFrozenColumnIndex,\n copiedCellIdx,\n draggedOverCellIdx,\n setDraggedOverRowIdx,\n selectedCellEditor,\n ...rowProps\n }: RenderRowProps<R, SR>\n ) {\n if (isGroupRow(row)) {\n const { startRowIndex } = row;\n return (\n <GroupedRow\n key={key}\n {...rowProps}\n aria-rowindex={headerAndTopSummaryRowsCount + startRowIndex + 1}\n row={row}\n groupBy={groupBy}\n toggleGroup={toggleGroupLatest}\n />\n );\n }\n\n let ariaRowIndex = rowProps['aria-rowindex'];\n const parentRowAndIndex = getParentRowAndIndex(row);\n if (parentRowAndIndex !== undefined) {\n const { startRowIndex, childRows } = parentRowAndIndex[0];\n const groupIndex = childRows.indexOf(row);\n ariaRowIndex = startRowIndex + headerAndTopSummaryRowsCount + groupIndex + 2;\n }\n\n return rawRenderRow(key, {\n ...rowProps,\n 'aria-rowindex': ariaRowIndex,\n row,\n rowClass,\n onCellClick,\n onCellDoubleClick,\n onCellContextMenu,\n onRowChange,\n lastFrozenColumnIndex,\n copiedCellIdx,\n draggedOverCellIdx,\n setDraggedOverRowIdx,\n selectedCellEditor\n });\n }\n\n return (\n <DataGrid<R, SR>\n {...props}\n role=\"treegrid\"\n aria-rowcount={\n rowsCount + 1 + (props.topSummaryRows?.length ?? 0) + (props.bottomSummaryRows?.length ?? 0)\n }\n ref={ref}\n columns={columns}\n rows={rows as R[]} // TODO: check types\n rowHeight={rowHeight}\n rowKeyGetter={rowKeyGetter}\n onRowsChange={handleRowsChange}\n selectedRows={selectedRows}\n onSelectedRowsChange={onSelectedRowsChange}\n onCellKeyDown={handleKeyDown}\n renderers={{\n ...renderers,\n renderRow\n }}\n />\n );\n}\n\nfunction isReadonlyArray(arr: unknown): arr is readonly unknown[] {\n return Array.isArray(arr);\n}\n\nexport default forwardRef(TreeDataGrid) as <R, SR = unknown, K extends Key = Key>(\n props: TreeDataGridProps<R, SR, K> & RefAttributes<DataGridHandle>\n) => React.JSX.Element;\n","import { css } from '@linaria/core';\n\nimport type { RenderEditCellProps } from '../types';\n\nconst textEditorInternalClassname = css`\n @layer rdg.TextEditor {\n appearance: none;\n\n box-sizing: border-box;\n inline-size: 100%;\n block-size: 100%;\n padding-block: 0;\n padding-inline: 6px;\n border: 2px solid #ccc;\n vertical-align: top;\n color: var(--rdg-color);\n background-color: var(--rdg-background-color);\n\n font-family: inherit;\n font-size: var(--rdg-font-size);\n\n &:focus {\n border-color: var(--rdg-selection-color);\n outline: none;\n }\n\n &::placeholder {\n color: #999;\n opacity: 1;\n }\n }\n`;\n\nexport const textEditorClassname = `rdg-text-editor ${textEditorInternalClassname}`;\n\nfunction autoFocusAndSelect(input: HTMLInputElement | null) {\n input?.focus();\n input?.select();\n}\n\nexport default function textEditor<TRow, TSummaryRow>({\n row,\n column,\n onRowChange,\n onClose\n}: RenderEditCellProps<TRow, TSummaryRow>) {\n return (\n <input\n className={textEditorClassname}\n ref={autoFocusAndSelect}\n value={row[column.key as keyof TRow] as unknown as string}\n onChange={(event) => onRowChange({ ...row, [column.key]: event.target.value })}\n onBlur={() => onClose(true, false)}\n />\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEO,SAAS,WACdA,QACAC,uBACAC,MACoB;CACpB,MAAM,iBAAiB,OAAO,YAAY,aAAa,OAAO,QAAQ,KAAK,GAAG;AAC9E,KACE,OAAO,UAAU,QAAQ,IACzB,UAAW,OAET,OAAO,UAAU,OAAO,MAAM,UAAW,KAAK,uBAEhD,QAAO;AAET,QAAO;AACR;;;;ACfM,SAAS,gBAAgBC,OAA6B;AAC3D,OAAM,iBAAiB;AACxB;AAEM,SAAS,eAAeC,SAAyB;AACtD,UAAS,eAAe;EAAE,QAAQ;EAAW,OAAO;CAAW,EAAC;AACjE;;;;ACNM,SAAS,gBACdC,OACc;CACd,IAAI,mBAAmB;CACvB,MAAM,YAAY;EAChB,GAAG;EACH,qBAAqB;AACnB,sBAAmB;EACpB;EACD,yBAAyB;AACvB,UAAO;EACR;CACF;AAED,QAAO,eAAe,WAAW,OAAO,eAAe,MAAM,CAAC;AAE9D,QAAO;AACR;;;;AClBD,MAAM,eAAe,IAAI,IAAI;CAE3B;CAEA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CAEA;CACA;CAC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