@mortenbrudvik/waveui 0.13.0 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +302 -49
- package/dist/components/data-display/Avatar.context.cjs.map +1 -1
- package/dist/components/data-display/Avatar.context.mjs.map +1 -1
- package/dist/components/data-display/List.cjs +1 -1
- package/dist/components/data-display/List.cjs.map +1 -1
- package/dist/components/data-display/List.mjs +245 -195
- package/dist/components/data-display/List.mjs.map +1 -1
- package/dist/components/data-display/List.registry.cjs.map +1 -1
- package/dist/components/data-display/List.registry.mjs.map +1 -1
- package/dist/components/layout/Overflow.cjs +1 -1
- package/dist/components/layout/Overflow.cjs.map +1 -1
- package/dist/components/layout/Overflow.mjs +240 -192
- package/dist/components/layout/Overflow.mjs.map +1 -1
- package/dist/components/layout/Overflow.store.cjs +2 -0
- package/dist/components/layout/Overflow.store.cjs.map +1 -0
- package/dist/components/layout/Overflow.store.mjs +209 -0
- package/dist/components/layout/Overflow.store.mjs.map +1 -0
- package/dist/components/navigation/Breadcrumb.cjs +1 -1
- package/dist/components/navigation/Breadcrumb.cjs.map +1 -1
- package/dist/components/navigation/Breadcrumb.mjs +239 -84
- package/dist/components/navigation/Breadcrumb.mjs.map +1 -1
- package/dist/components/overlays/Dialog.slots.cjs +1 -1
- package/dist/components/overlays/Dialog.slots.cjs.map +1 -1
- package/dist/components/overlays/Dialog.slots.mjs +19 -15
- package/dist/components/overlays/Dialog.slots.mjs.map +1 -1
- package/dist/components/overlays/TeachingPopover.cjs +1 -1
- package/dist/components/overlays/TeachingPopover.cjs.map +1 -1
- package/dist/components/overlays/TeachingPopover.context.cjs +2 -0
- package/dist/components/overlays/TeachingPopover.context.cjs.map +1 -0
- package/dist/components/overlays/TeachingPopover.context.mjs +51 -0
- package/dist/components/overlays/TeachingPopover.context.mjs.map +1 -0
- package/dist/components/overlays/TeachingPopover.mjs +15 -185
- package/dist/components/overlays/TeachingPopover.mjs.map +1 -1
- package/dist/components/overlays/TeachingPopover.parts.cjs +2 -0
- package/dist/components/overlays/TeachingPopover.parts.cjs.map +1 -0
- package/dist/components/overlays/TeachingPopover.parts.mjs +398 -0
- package/dist/components/overlays/TeachingPopover.parts.mjs.map +1 -0
- package/dist/components/overlays/TeachingPopover.root.cjs +2 -0
- package/dist/components/overlays/TeachingPopover.root.cjs.map +1 -0
- package/dist/components/overlays/TeachingPopover.root.mjs +150 -0
- package/dist/components/overlays/TeachingPopover.root.mjs.map +1 -0
- package/dist/components/overlays/TeachingPopover.stack.cjs +2 -0
- package/dist/components/overlays/TeachingPopover.stack.cjs.map +1 -0
- package/dist/components/overlays/TeachingPopover.stack.mjs +86 -0
- package/dist/components/overlays/TeachingPopover.stack.mjs.map +1 -0
- package/dist/components/table/DataGrid.cjs +1 -1
- package/dist/components/table/DataGrid.cjs.map +1 -1
- package/dist/components/table/DataGrid.mjs +540 -311
- package/dist/components/table/DataGrid.mjs.map +1 -1
- package/dist/components/table/Table.cjs +1 -1
- package/dist/components/table/Table.cjs.map +1 -1
- package/dist/components/table/Table.mjs +183 -60
- package/dist/components/table/Table.mjs.map +1 -1
- package/dist/components/table/Table.shared.cjs +2 -0
- package/dist/components/table/Table.shared.cjs.map +1 -0
- package/dist/components/table/Table.shared.mjs +65 -0
- package/dist/components/table/Table.shared.mjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1742 -158
- package/dist/index.d.ts +1742 -158
- package/dist/index.mjs +135 -132
- package/dist/lib/breadcrumb.cjs +2 -0
- package/dist/lib/breadcrumb.cjs.map +1 -0
- package/dist/lib/breadcrumb.mjs +26 -0
- package/dist/lib/breadcrumb.mjs.map +1 -0
- package/dist/lib/classNames.cjs +1 -1
- package/dist/lib/classNames.cjs.map +1 -1
- package/dist/lib/classNames.mjs +66 -38
- package/dist/lib/classNames.mjs.map +1 -1
- package/dist/lib/events.cjs +1 -1
- package/dist/lib/events.cjs.map +1 -1
- package/dist/lib/events.mjs +35 -8
- package/dist/lib/events.mjs.map +1 -1
- package/dist/lib/icons.cjs +1 -1
- package/dist/lib/icons.cjs.map +1 -1
- package/dist/lib/icons.mjs +34 -20
- package/dist/lib/icons.mjs.map +1 -1
- package/dist/lib/table.cjs +2 -0
- package/dist/lib/table.cjs.map +1 -0
- package/dist/lib/table.mjs +16 -0
- package/dist/lib/table.mjs.map +1 -0
- package/dist/styles.css +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataGrid.mjs","names":["useId","_Fragment","useId$1","React","DEFAULT_SELECT_ALL_LABEL","DEFAULT_SELECTION_HEADER_LABEL","createSelectionStore","selected","initial","registered","selectedRegistered","selectAll","singleMode","initialSingleMode","singleId","rowListeners","selectAllListeners","notify","listener","listeners","getSingleId","first","rowId","onRegistrationChange","previous","updateSelectAll","next","subscribeTo","count","done","remaining","items","item","single","createHeaderSlotRegistry","slots","update","nextCell","slot","getCell","cell","DataGridContext","DataGridSortContext","DataGridSectionContext","DataGridHeaderSlotsContext","DataGridHeaderRowHintContext","INERT_CONTEXT","INERT_SORT_CONTEXT","useDataGridContext","reportMissingContext","component","useDataGridSortContext","EMPTY_ITEMS","toItems","keys","sameItems","a","b","index","renderFlatChild","node","key","warnDuplicateRowId","cellBase","selectionCell","nativeControl","DataGridRoot","sortProp","sortColumnProp","sortDirectionProp","selectedItemsProp","rest","props","usesSortApi","defaultSort","sortApiMode","setSortApiMode","objectCallbacks","legacySortControlled","warnDeprecated","defaultSortColumn","defaultSortDirection","mixedSortApi","warnOnce","legacyHalves","setLegacyHalves","legacyControlledSort","column","legacyDefaultSort","sort","setSort","useControllable","onSortChange","requestSort","columnId","sortContext","onSelectionChange","legacySelected","selectedKeys","legacyDefaultSelected","defaultSelectedKeys","controlledSelected","resolveDeprecatedProp","defaultSelected","defaultSelectedItems","setSelected","onSelectedItemsChange","selectionMode","store","toggleRow","effective","selectedCount","toggleAll","all","radioName","selectAllLabel","labels","selectionHeaderLabel","context","useGridNavigation","mergedRef","useMergedRefs","ref","gridRef","content","children","flatChildren","columns","flattenChildren","isElementOfType","DataGridHeader","isCaption","Fragment","DataGridHeaderCell","child","containerClassName","containerLabel","containerLabelledBy","containerRest","containerProps","containerHasRole","droppedContainerName","cn","dataGridClassNames","className","composeEventHandlers","onKeyDown","gridProps","onFocus","onBlur","DataGridSelectionHeaderCell","state","inputRef","clicks","setClicks","dataGridHeaderClassNames","focusRingInset","INERT_HEADER_SLOTS","DataGridSelectionHeaderSlot","cellRef","getIsFirst","initialFirst","getServerIsFirst","isFirst","withSelectionHeaderSlots","visit","nodes","thead","setThead","isDev","row","sortIcon","dataGridHeaderCellClassNames","direction","sortColumnId","sortable","sortedDirection","sortOnButtonClick","button","event","onClick","DataGridBody","dataGridBodyClassNames","DataGridRow","section","firstHeaderRowHint","inHeader","selectable","labelId","getSelected","isSelected","unregister","unlabelled","selectionLabel","handleKeyDown","target","labelledBy","idCellIndex","firstCellIndex","DataGridCell","firstCell","needsLabel","selectionCellElement","dataGridRowClassNames","forcedColors","dataGridCellClassNames","DataGrid"],"sources":["../../../src/components/table/DataGrid.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../lib/cn';\nimport {\n dataGridBodyClassNames,\n dataGridCellClassNames,\n dataGridClassNames,\n dataGridHeaderCellClassNames,\n dataGridHeaderClassNames,\n dataGridRowClassNames,\n} from '../../lib/classNames';\nimport { flattenChildren, isElementOfType } from '../../lib/children';\nimport { composeEventHandlers } from '../../lib/composeEventHandlers';\nimport {\n isDev,\n reportMissingContext,\n resolveDeprecatedProp,\n warnDeprecated,\n warnOnce,\n} from '../../lib/dev';\nimport { focusRingInset, forcedColors } from '../../lib/styles';\nimport type { SelectionMode } from '../../lib/types';\nimport { useControllable } from '../../hooks/useControllable';\nimport { useId } from '../../hooks/useId';\nimport { useMergedRefs } from '../../hooks/useMergedRefs';\nimport { useGridNavigation } from './useGridNavigation';\n\nexport type SortDirection = 'ascending' | 'descending';\n\n/** The sort state of a DataGrid: the sorted column and its direction. */\nexport interface DataGridSort {\n /** The `columnId` of the sorted column. */\n columnId: string;\n /** The sort direction. */\n direction: SortDirection;\n}\n\n/** Defines a column in the DataGrid. */\nexport interface DataGridColumn {\n /** Unique identifier for the column (the header cell's `columnId`). */\n id: string;\n /** Display label for the column header. */\n label: string;\n /** Whether the column supports sorting. */\n sortable?: boolean;\n}\n\n/** The built-in text of a DataGrid, for localization (see `DataGridBaseProps.labels`). */\nexport interface DataGridLabels {\n /** Accessible name of the select-all checkbox in the header (`selectionMode=\"multiple\"`).\n * @default 'Select all rows'\n */\n selectAll?: string;\n /**\n * Visually hidden text of the selection column's header cell (`selectionMode=\"single\"`), which\n * names that column.\n * @default 'Selection'\n */\n selectionHeader?: string;\n}\n\nconst DEFAULT_SELECT_ALL_LABEL = 'Select all rows';\nconst DEFAULT_SELECTION_HEADER_LABEL = 'Selection';\n\n/** Props of every DataGrid, whatever sort API it uses. */\nexport interface DataGridBaseProps extends React.HTMLAttributes<HTMLTableElement> {\n /**\n * Column definitions. When given and no `DataGrid.Header` child is present, the header row\n * (including the selection column) is rendered from them: `id` becomes the header cell's\n * `columnId`, `label` its content, `sortable` makes it a sort button.\n */\n columns?: readonly DataGridColumn[];\n /**\n * Row selection mode. `'multiple'` adds a checkbox column with a \"Select all rows\" header\n * checkbox; `'single'` adds a radio column (its header reads \"Selection\" to assistive\n * technology). `labels` localizes both texts.\n * @default 'none'\n */\n selectionMode?: 'none' | SelectionMode;\n /**\n * The name of the select-all checkbox and the header text of the selection column, for\n * localization. Unset members keep their English defaults. Rows are named with their own\n * `selectionLabel`.\n */\n labels?: DataGridLabels;\n /**\n * Controlled selected row ids (`DataGrid.Row` `rowId`). In single mode pass at most one id: with\n * several, only the first one whose row is rendered is selected (a development warning says so).\n */\n selectedItems?: readonly string[];\n /** Initially selected row ids (uncontrolled). In single mode, at most one (see `selectedItems`). */\n defaultSelectedItems?: readonly string[];\n /**\n * Called with the new selected row ids when the selection changes. Ids of rows that are not\n * rendered are left out of the reported selection and of the select-all state, so the next\n * change drops them. Until that change an uncontrolled grid still holds such an id: a row\n * re-added with the same `rowId` before then is shown selected again.\n */\n onSelectedItemsChange?: (selectedItems: string[]) => void;\n /** @deprecated Use `selectedItems` (an array). A `Set` or an array is accepted. */\n selectedKeys?: ReadonlySet<string> | readonly string[];\n /** @deprecated Use `defaultSelectedItems` (an array). A `Set` or an array is accepted. */\n defaultSelectedKeys?: ReadonlySet<string> | readonly string[];\n /** @deprecated Use `onSelectedItemsChange`, which receives an array. Both are called. */\n onSelectionChange?: (keys: Set<string>) => void;\n /**\n * Props for the wrapper `<div>` around the `<table>`: a horizontally scrollable container\n * (`overflow-x-auto`). Use it for its className, style (e.g. a max height) or ref. The wrapper\n * is not a tab stop (the grid's own cell tab stop scrolls it) and has no role, so its\n * `aria-label`/`aria-labelledby` are applied only together with a `role` (e.g. `'region'`);\n * without one they are dropped with a development warning. Name the grid with `aria-label`.\n */\n containerProps?: Omit<React.ComponentPropsWithRef<'div'>, 'children'>;\n /** DataGrid header, body, and row elements. */\n children: React.ReactNode;\n /** Ref to the `<table role=\"grid\">` element. */\n ref?: React.Ref<HTMLTableElement>;\n}\n\ninterface NoDeprecatedSortProps {\n sortColumn?: never;\n defaultSortColumn?: never;\n sortDirection?: never;\n defaultSortDirection?: never;\n}\n\n/** The 0.5 sort API, controlled: `sort` + `onSortChange(sort)`. */\nexport interface DataGridControlledSortProps extends NoDeprecatedSortProps {\n /** The controlled sort, or `null` for an unsorted grid. */\n sort: DataGridSort | null;\n /** Initial sort while `sort` is not given yet. */\n defaultSort?: DataGridSort | null;\n /**\n * Called with the new sort when a sortable header is activated. Sorting is controlled: the\n * consumer reorders the rows.\n */\n onSortChange?: (sort: DataGridSort) => void;\n}\n\n/** The 0.5 sort API, uncontrolled: `defaultSort` (`null` for none) + `onSortChange(sort)`. */\nexport interface DataGridUncontrolledSortProps extends NoDeprecatedSortProps {\n sort?: undefined;\n /** The initial sort, or `null` for an initially unsorted grid. */\n defaultSort: DataGridSort | null;\n /**\n * Called with the new sort when a sortable header is activated. Sorting is controlled: the\n * consumer reorders the rows.\n */\n onSortChange?: (sort: DataGridSort) => void;\n}\n\n/**\n * The 0.4 sort API: `onSortChange(columnId, direction)` and the deprecated `sortColumn`/\n * `sortDirection` props. It applies whenever neither `sort` nor `defaultSort` is given. As in 0.4,\n * the column and the direction can be controlled independently: the half that is not controlled is\n * kept internally and follows every sort request (mixed control, warned in development).\n */\nexport interface DataGridLegacySortProps {\n sort?: undefined;\n defaultSort?: undefined;\n /**\n * @deprecated Use `sort` (`{ columnId, direction }` or `null`). Without `sortDirection`, the\n * direction is kept internally (it toggles on repeated clicks).\n */\n sortColumn?: string;\n /** @deprecated Use `defaultSort`. */\n defaultSortColumn?: string;\n /**\n * @deprecated Use `sort`. Without `sortColumn`, the column is kept internally (it follows the\n * clicked header, starting from `defaultSortColumn`).\n */\n sortDirection?: SortDirection;\n /** @deprecated Use `defaultSort`. */\n defaultSortDirection?: SortDirection;\n /**\n * Called when a sortable header is activated, with the 0.4 arguments. Pass `sort` or\n * `defaultSort` to receive a `DataGridSort` object instead: `defaultSort={null}` turns the\n * object form on for an initially unsorted grid. A `sort` that is still `undefined` (e.g. while\n * data loads) does not: pass `sort={sort ?? null}`.\n *\n * @example\n * <DataGrid defaultSort={null} onSortChange={(sort) => setSort(sort)}>…</DataGrid>\n */\n onSortChange?: (columnId: string, direction: SortDirection) => void;\n}\n\n/**\n * Properties for the DataGrid component. The sort props form a union: `sort`/`defaultSort` with\n * `onSortChange(sort)` (0.5), or the 0.4 form `onSortChange(columnId, direction)` with the\n * deprecated `sortColumn`/`sortDirection`/`defaultSortColumn`/`defaultSortDirection`. The two\n * cannot be mixed.\n */\nexport type DataGridProps = DataGridBaseProps &\n (DataGridControlledSortProps | DataGridUncontrolledSortProps | DataGridLegacySortProps);\n\n/** Properties for the DataGridHeader sub-component. */\nexport interface DataGridHeaderProps extends React.HTMLAttributes<HTMLTableSectionElement> {\n /**\n * Header row elements. Each `<tr>` child (also inside a Fragment) gets the selection column's\n * header cell prepended when the grid is selectable; a header row rendered by another component\n * should be a `DataGrid.Row`, which adds the cell itself. With several header rows (a grouped\n * header), only the first one gets the \"Select all rows\" control; later rows get an empty cell.\n */\n children: React.ReactNode;\n /** Ref to the `<thead>` element. */\n ref?: React.Ref<HTMLTableSectionElement>;\n}\n\n/** Properties for the DataGridHeaderCell sub-component. */\nexport interface DataGridHeaderCellProps extends React.ThHTMLAttributes<HTMLTableCellElement> {\n /** Column ID used for sort tracking. Required for `sortable`. */\n columnId?: string;\n /**\n * Whether this column can be sorted. The content is rendered inside a `<button>`; the header\n * cell carries `aria-sort`. Ignored (with a development warning) without `columnId`.\n * @default false\n */\n sortable?: boolean;\n /** Header cell content. */\n children: React.ReactNode;\n /** Ref to the `<th>` element. */\n ref?: React.Ref<HTMLTableCellElement>;\n}\n\n/** Properties for the DataGridBody sub-component. */\nexport interface DataGridBodyProps extends React.HTMLAttributes<HTMLTableSectionElement> {\n /** DataGrid row elements. */\n children: React.ReactNode;\n /** Ref to the `<tbody>` element. */\n ref?: React.Ref<HTMLTableSectionElement>;\n}\n\n/** Properties for the DataGridRow sub-component. */\nexport interface DataGridRowProps extends React.HTMLAttributes<HTMLTableRowElement> {\n /**\n * Unique identifier for this row, used for selection (rows that share one are selected together;\n * a duplicate warns in development). A selectable grid renders no selection control (and warns\n * in development) for a row without it.\n */\n rowId?: string;\n /**\n * Accessible name of the row's selection control. Defaults to the row's first child that is a\n * `DataGrid.Cell`, `<td>` or `<th>` element (`aria-labelledby`); a cell that another component\n * renders is not seen, so pass `selectionLabel` when the row's first cell is one. Without such a\n * child the control is named \"Select row\" (with a development warning).\n */\n selectionLabel?: string;\n /** DataGrid cell elements. */\n children: React.ReactNode;\n /** Ref to the `<tr>` element. */\n ref?: React.Ref<HTMLTableRowElement>;\n}\n\n/** Properties for the DataGridCell sub-component. */\nexport interface DataGridCellProps extends React.TdHTMLAttributes<HTMLTableCellElement> {\n /** Cell content. */\n children: React.ReactNode;\n /** Ref to the `<td>` element. */\n ref?: React.Ref<HTMLTableCellElement>;\n}\n\n// ---------------------------------------------------------------------------\n// Selection store\n// ---------------------------------------------------------------------------\n\ntype SelectAllState = 'all' | 'some' | 'none';\n\n/**\n * Selection state shared with the rows through `useSyncExternalStore`, so toggling one row\n * re-renders only that row (and the select-all header cell). The root pushes the committed\n * selection in a layout effect; rows register their ids. The effective selection is always\n * `selected ∩ registered`, derived on read (no pruning effect).\n *\n * @internal Not exported from the package (exported for its unit tests).\n */\nexport interface SelectionStore {\n /**\n * Row subscription: notified only when the selection changes. Rows registering or unregistering\n * notify no row, so adding or removing k of n rows costs O(k), not O(k·n); the one exception is\n * single mode with several selected ids, where a row registering can move the selected row.\n */\n subscribe(listener: () => void): () => void;\n /**\n * Select-all subscription: notified only when {@link getSelectAllState} changes (through the\n * selection or through rows registering and unregistering).\n */\n subscribeSelectAll(listener: () => void): () => void;\n /** Registers a rendered row id; returns the unregister function. */\n register(rowId: string): () => void;\n /** How many rendered rows are registered with `rowId` (more than one: a duplicate). */\n countRegistrations(rowId: string): number;\n /** Sets the committed selection (layout effect of the root). */\n setSelected(items: readonly string[]): void;\n /**\n * Sets whether the grid is in single mode (layout effect of the root). Only then do rows\n * registering or unregistering re-check the one selected row of single mode and notify the rows.\n */\n setSingleMode(single: boolean): void;\n /**\n * Whether the row is selected. With `single`, only one row is: the first selected id (in\n * selection order) whose row is registered, else the first selected id (before any row\n * registered: the server render and the first client render).\n */\n isSelected(rowId: string, single?: boolean): boolean;\n /** Whether all, some or none of the registered rows are selected. O(1). */\n getSelectAllState(): SelectAllState;\n /** Registered row ids in registration order. */\n getRegistered(): string[];\n /** `items` restricted to registered rows (order of `items`). */\n prune(items: readonly string[]): string[];\n}\n\n/**\n * Creates the {@link SelectionStore} of one DataGrid.\n *\n * @internal Not exported from the package (exported for its unit tests).\n */\nexport function createSelectionStore(\n initial: readonly string[],\n initialSingleMode = false,\n): SelectionStore {\n let selected: ReadonlySet<string> = new Set(initial);\n /** Registered row id -> number of rows registered with it. */\n const registered = new Map<string, number>();\n /** How many registered row ids are selected (kept up to date, so select-all is O(1)). */\n let selectedRegistered = 0;\n let selectAll: SelectAllState = 'none';\n let singleMode = initialSingleMode;\n /** The one selected row of single mode (see `isSelected`); `undefined`: not computed yet. */\n let singleId: string | null | undefined;\n const rowListeners = new Set<() => void>();\n const selectAllListeners = new Set<() => void>();\n\n const notify = (listeners: Set<() => void>) => {\n for (const listener of Array.from(listeners)) listener();\n };\n\n /** Computed on read: O(selected ids) once per change, and only in single mode. */\n const getSingleId = (): string | null => {\n if (singleId !== undefined) return singleId;\n let first: string | null = null;\n for (const rowId of selected) {\n if (registered.has(rowId)) {\n first = rowId;\n break;\n }\n first ??= rowId;\n }\n singleId = first;\n return first;\n };\n\n /**\n * A row id registered or unregistered. With several selected ids, the one selected row of\n * single mode can move: in single mode it is re-checked and the rows are notified if it moved.\n */\n const onRegistrationChange = (rowId: string) => {\n if (selected.size < 2 || !selected.has(rowId)) return;\n const previous = singleId;\n singleId = undefined;\n if (singleMode && getSingleId() !== previous) notify(rowListeners);\n };\n\n const updateSelectAll = () => {\n const next: SelectAllState =\n selectedRegistered === 0 ? 'none' : selectedRegistered === registered.size ? 'all' : 'some';\n if (next === selectAll) return;\n selectAll = next;\n notify(selectAllListeners);\n };\n\n const subscribeTo = (listeners: Set<() => void>) => (listener: () => void) => {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n };\n\n return {\n subscribe: subscribeTo(rowListeners),\n subscribeSelectAll: subscribeTo(selectAllListeners),\n register(rowId) {\n const count = registered.get(rowId) ?? 0;\n registered.set(rowId, count + 1);\n if (count === 0 && selected.has(rowId)) selectedRegistered += 1;\n updateSelectAll();\n if (count === 0) onRegistrationChange(rowId);\n let done = false;\n return () => {\n if (done) return;\n done = true;\n const remaining = (registered.get(rowId) ?? 0) - 1;\n if (remaining > 0) {\n registered.set(rowId, remaining);\n return;\n }\n registered.delete(rowId);\n if (selected.has(rowId)) selectedRegistered -= 1;\n updateSelectAll();\n onRegistrationChange(rowId);\n };\n },\n setSelected(items) {\n const next = new Set(items);\n if (next.size === selected.size && items.every((item) => selected.has(item))) return;\n selected = next;\n singleId = undefined;\n selectedRegistered = 0;\n for (const rowId of next) if (registered.has(rowId)) selectedRegistered += 1;\n notify(rowListeners);\n updateSelectAll();\n },\n setSingleMode(single) {\n singleMode = single;\n },\n isSelected(rowId, single = false) {\n return single ? getSingleId() === rowId : selected.has(rowId);\n },\n countRegistrations(rowId) {\n return registered.get(rowId) ?? 0;\n },\n getSelectAllState() {\n return selectAll;\n },\n getRegistered() {\n return Array.from(registered.keys());\n },\n prune(items) {\n return items.filter((item) => registered.has(item));\n },\n };\n}\n\n// ---------------------------------------------------------------------------\n// Header selection slots\n// ---------------------------------------------------------------------------\n\n/**\n * The selection column's header slots of one `DataGrid.Header`, one per header row. Only the first\n * slot in document order renders the \"Select all rows\" control (the \"Selection\" text in single\n * mode); the others render an empty cell, so a grouped header (several header rows) has one control\n * and every header row keeps the selection column.\n */\ninterface HeaderSlotRegistry {\n subscribe(listener: () => void): () => void;\n /** Registers a slot and a getter for its current cell; returns the unregister function. */\n register(slot: object, getCell: () => Element | null): () => void;\n /** The first slot in document order, or `null` while no slot is registered. */\n getFirst(): object | null;\n /** Re-checks the order: header rows can move without a slot mounting or unmounting. */\n refresh(): void;\n}\n\nfunction createHeaderSlotRegistry(): HeaderSlotRegistry {\n const slots = new Map<object, () => Element | null>();\n const listeners = new Set<() => void>();\n let first: object | null = null;\n\n const update = () => {\n let next: object | null = null;\n let nextCell: Element | null = null;\n for (const [slot, getCell] of slots) {\n const cell = getCell();\n if (!cell) {\n // A slot whose cell is being replaced (control <-> empty cell): keep the current order\n // until the next registration or header commit sees every cell again.\n if (first !== null && slots.has(first)) return;\n continue;\n }\n if (!nextCell || cell.compareDocumentPosition(nextCell) & Node.DOCUMENT_POSITION_FOLLOWING) {\n next = slot;\n nextCell = cell;\n }\n }\n if (next === null) next = slots.keys().next().value ?? null;\n if (next === first) return;\n first = next;\n for (const listener of Array.from(listeners)) listener();\n };\n\n return {\n subscribe(listener) {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n },\n register(slot, getCell) {\n slots.set(slot, getCell);\n update();\n return () => {\n slots.delete(slot);\n update();\n };\n },\n getFirst: () => first,\n refresh: update,\n };\n}\n\n// ---------------------------------------------------------------------------\n// Contexts\n// ---------------------------------------------------------------------------\n\ninterface DataGridContextValue {\n selectionMode: 'none' | SelectionMode;\n store: SelectionStore;\n /** Toggles one row (single mode: selects it alone, or clears it). */\n toggleRow: (rowId: string) => void;\n /** Selects every rendered row, or clears the selection when all are selected. */\n toggleAll: () => void;\n /** Shared `name` of the single-mode radios (they are kept out of any form with `form=\"\"`). */\n radioName: string;\n /** Name of the select-all checkbox (multiple mode). */\n selectAllLabel: string;\n /** Hidden header text of the selection column (single mode). */\n selectionHeaderLabel: string;\n}\n\ninterface DataGridSortContextValue {\n sort: DataGridSort | null;\n requestSort: (columnId: string) => void;\n}\n\ntype DataGridSection = 'header' | 'body';\n\nconst DataGridContext = React.createContext<DataGridContextValue | null>(null);\nconst DataGridSortContext = React.createContext<DataGridSortContextValue | null>(null);\n/** Whether a row is rendered in the header or the body (rows in a header get a header cell). */\nconst DataGridSectionContext = React.createContext<DataGridSection>('body');\n/** The header's selection slots (see {@link HeaderSlotRegistry}). */\nconst DataGridHeaderSlotsContext = React.createContext<HeaderSlotRegistry | null>(null);\n/**\n * Whether the header row below is the header's first row, as far as the header can tell from its\n * children. Only the initial (and server) render uses it; the slots then follow the DOM order.\n */\nconst DataGridHeaderRowHintContext = React.createContext(true);\n\nconst INERT_STORE = createSelectionStore([]);\nconst INERT_CONTEXT: DataGridContextValue = {\n selectionMode: 'none',\n store: INERT_STORE,\n toggleRow: () => {},\n toggleAll: () => {},\n radioName: '',\n selectAllLabel: DEFAULT_SELECT_ALL_LABEL,\n selectionHeaderLabel: DEFAULT_SELECTION_HEADER_LABEL,\n};\nconst INERT_SORT_CONTEXT: DataGridSortContextValue = { sort: null, requestSort: () => {} };\n\nfunction useDataGridContext(component: string): DataGridContextValue {\n const ctx = React.useContext(DataGridContext);\n if (ctx) return ctx;\n reportMissingContext(component, 'DataGrid');\n return INERT_CONTEXT;\n}\n\nfunction useDataGridSortContext(component: string): DataGridSortContextValue {\n const ctx = React.useContext(DataGridSortContext);\n if (ctx) return ctx;\n reportMissingContext(component, 'DataGrid');\n return INERT_SORT_CONTEXT;\n}\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\nconst EMPTY_ITEMS: readonly string[] = [];\n\nfunction toItems(\n keys: ReadonlySet<string> | readonly string[] | undefined,\n): readonly string[] | undefined {\n return keys === undefined ? undefined : Array.from(keys);\n}\n\nfunction sameItems(a: readonly string[], b: readonly string[]): boolean {\n return a.length === b.length && a.every((item, index) => item === b[index]);\n}\n\n/** A child of {@link flattenChildren} under its flattened key (unique across the flattened list). */\nfunction renderFlatChild({ key, node }: { key: string; node: React.ReactNode }): React.ReactNode {\n return <React.Fragment key={key}>{node}</React.Fragment>;\n}\n\nfunction warnDuplicateRowId(rowId: string): void {\n warnOnce(\n `DataGrid:duplicate-rowId:${rowId}`,\n `DataGrid: several rows share the rowId \"${rowId}\". Row ids must be unique within a ` +\n 'DataGrid; rows with the same rowId are selected and deselected together.',\n );\n}\n\nconst cellBase = 'px-4 py-3 border-b border-border';\nconst selectionCell = 'w-10 px-3 py-3 border-b border-border';\nconst nativeControl = 'accent-primary cursor-pointer';\n\n// ---------------------------------------------------------------------------\n// DataGrid\n// ---------------------------------------------------------------------------\n\n// The component-level JSDoc sits on the exported `DataGrid` below.\nconst DataGridRoot = (props: DataGridProps) => {\n const {\n sort: sortProp,\n defaultSort,\n sortColumn: sortColumnProp,\n defaultSortColumn,\n sortDirection: sortDirectionProp,\n defaultSortDirection,\n onSortChange,\n selectionMode = 'none',\n selectedItems: selectedItemsProp,\n defaultSelectedItems,\n onSelectedItemsChange,\n selectedKeys,\n defaultSelectedKeys,\n onSelectionChange,\n labels,\n columns,\n containerProps,\n children,\n className,\n onKeyDown,\n onFocus,\n onBlur,\n ref,\n ...rest\n } = props;\n\n // --- sort -----------------------------------------------------------------\n /** 0.5 API: `onSortChange(sort)`. Sticky once `sort`/`defaultSort` was given. */\n const usesSortApi = sortProp !== undefined || defaultSort !== undefined;\n const [sortApiMode, setSortApiMode] = React.useState(usesSortApi);\n if (usesSortApi && !sortApiMode) setSortApiMode(true);\n const objectCallbacks = sortApiMode || usesSortApi;\n\n const legacySortControlled = sortColumnProp !== undefined || sortDirectionProp !== undefined;\n if (sortColumnProp !== undefined) warnDeprecated('DataGrid', 'sortColumn', 'sort');\n if (sortDirectionProp !== undefined) warnDeprecated('DataGrid', 'sortDirection', 'sort');\n if (defaultSortColumn !== undefined) {\n warnDeprecated('DataGrid', 'defaultSortColumn', 'defaultSort');\n }\n if (defaultSortDirection !== undefined) {\n warnDeprecated('DataGrid', 'defaultSortDirection', 'defaultSort');\n }\n const mixedSortApi =\n usesSortApi &&\n (legacySortControlled || defaultSortColumn !== undefined || defaultSortDirection !== undefined);\n\n React.useEffect(() => {\n if (mixedSortApi) {\n warnOnce(\n 'DataGrid:mixed-sort',\n 'DataGrid: do not mix `sort`/`defaultSort` with the deprecated `sortColumn`/`sortDirection`/' +\n '`defaultSortColumn`/`defaultSortDirection`. `sort`/`defaultSort` win.',\n );\n }\n }, [mixedSortApi]);\n // 0.4 mixed control: `sortColumn` and `sortDirection` are controlled independently. The half the\n // parent does not control is kept here (seeded from its default) and follows every sort request,\n // as 0.4 did, so repeated clicks still alternate and aria-sort shows what was reported.\n React.useEffect(() => {\n if (usesSortApi) return;\n if (sortColumnProp !== undefined && sortDirectionProp === undefined) {\n warnOnce(\n 'DataGrid:sortColumn-without-sortDirection',\n 'DataGrid: `sortColumn` is controlled but `sortDirection` is not (mixed control). The ' +\n 'direction is kept internally and toggles on repeated clicks, as in 0.4. Pass `sort` ' +\n '(`{ columnId, direction }`) to control both.',\n );\n } else if (sortDirectionProp !== undefined && sortColumnProp === undefined) {\n warnOnce(\n 'DataGrid:sortDirection-without-sortColumn',\n 'DataGrid: `sortDirection` is controlled but `sortColumn` is not (mixed control). The ' +\n 'column is kept internally and follows the clicked header, as in 0.4. Pass `sort` ' +\n '(`{ columnId, direction }`) to control both.',\n );\n }\n }, [usesSortApi, sortColumnProp, sortDirectionProp]);\n\n /** The uncontrolled halves of the 0.4 sort props (used while the other half is controlled). */\n const [legacyHalves, setLegacyHalves] = React.useState<{\n column: string;\n direction: SortDirection;\n }>(() => ({\n column: defaultSortColumn ?? '',\n direction: defaultSortDirection ?? 'ascending',\n }));\n\n const legacyControlledSort = React.useMemo<DataGridSort | null | undefined>(() => {\n if (sortColumnProp === undefined && sortDirectionProp === undefined) return undefined;\n const column = sortColumnProp ?? legacyHalves.column;\n return column === ''\n ? null\n : { columnId: column, direction: sortDirectionProp ?? legacyHalves.direction };\n }, [sortColumnProp, sortDirectionProp, legacyHalves]);\n\n const legacyDefaultSort = React.useMemo<DataGridSort | null>(\n () =>\n defaultSortColumn\n ? { columnId: defaultSortColumn, direction: defaultSortDirection ?? 'ascending' }\n : null,\n [defaultSortColumn, defaultSortDirection],\n );\n\n const controlledSort = usesSortApi ? sortProp : legacyControlledSort;\n const initialSort = defaultSort !== undefined ? defaultSort : legacyDefaultSort;\n\n const emitSortChange = (next: DataGridSort | null) => {\n if (!next) return;\n if (!usesSortApi) {\n setLegacyHalves((previous) =>\n previous.column === next.columnId && previous.direction === next.direction\n ? previous\n : { column: next.columnId, direction: next.direction },\n );\n }\n if (!onSortChange) return;\n if (objectCallbacks) {\n (onSortChange as (sort: DataGridSort) => void)(next);\n } else {\n const legacy = onSortChange as (columnId: string, direction: SortDirection) => void;\n legacy(next.columnId, next.direction);\n }\n };\n\n const [sort, setSort] = useControllable<DataGridSort | null>(\n controlledSort,\n initialSort,\n emitSortChange,\n );\n\n const requestSort = React.useCallback(\n (columnId: string) => {\n setSort((previous) => ({\n columnId,\n direction:\n previous?.columnId === columnId && previous.direction === 'ascending'\n ? 'descending'\n : 'ascending',\n }));\n },\n [setSort],\n );\n\n const sortContext = React.useMemo<DataGridSortContextValue>(\n () => ({ sort, requestSort }),\n [sort, requestSort],\n );\n\n // --- selection ------------------------------------------------------------\n if (onSelectionChange !== undefined) {\n warnDeprecated('DataGrid', 'onSelectionChange', 'onSelectedItemsChange');\n }\n const legacySelected = React.useMemo(() => toItems(selectedKeys), [selectedKeys]);\n const legacyDefaultSelected = React.useMemo(\n () => toItems(defaultSelectedKeys),\n [defaultSelectedKeys],\n );\n const controlledSelected = resolveDeprecatedProp(\n 'DataGrid',\n selectedItemsProp,\n legacySelected,\n 'selectedKeys',\n 'selectedItems',\n );\n const defaultSelected =\n resolveDeprecatedProp(\n 'DataGrid',\n defaultSelectedItems,\n legacyDefaultSelected,\n 'defaultSelectedKeys',\n 'defaultSelectedItems',\n ) ?? EMPTY_ITEMS;\n\n const emitSelectionChange = (next: readonly string[]) => {\n onSelectedItemsChange?.([...next]);\n onSelectionChange?.(new Set(next));\n };\n\n const [selected, setSelected] = useControllable<readonly string[]>(\n controlledSelected,\n defaultSelected,\n emitSelectionChange,\n );\n\n const single = selectionMode === 'single';\n const [store] = React.useState(() => createSelectionStore(selected, single));\n React.useLayoutEffect(() => {\n store.setSelected(selected);\n }, [store, selected]);\n React.useLayoutEffect(() => {\n store.setSingleMode(single);\n }, [store, single]);\n\n const toggleRow = React.useCallback(\n (rowId: string) => {\n setSelected((previous) => {\n const effective = store.prune(previous);\n let next: string[];\n if (single) {\n // Single mode shows the first selected row that is rendered (see the store).\n next = effective[0] === rowId ? [] : [rowId];\n } else {\n next = effective.includes(rowId)\n ? effective.filter((item) => item !== rowId)\n : [...effective, rowId];\n }\n return sameItems(next, previous) ? previous : next;\n });\n },\n [single, setSelected, store],\n );\n\n const selectedCount = selected.length;\n React.useEffect(() => {\n if (single && selectedCount > 1) {\n warnOnce(\n 'DataGrid:single-several-selected',\n `DataGrid: a single-selection grid (selectionMode \"single\") has ${selectedCount} selected row ids; only the first one that is rendered is selected. Pass at most one id in \\`selectedItems\\`/\\`defaultSelectedItems\\`, or use selectionMode=\"multiple\".`,\n );\n }\n }, [single, selectedCount]);\n\n const toggleAll = React.useCallback(() => {\n setSelected((previous) => {\n const effective = store.prune(previous);\n const all = store.getRegistered();\n const allSelected = all.length > 0 && all.every((rowId) => effective.includes(rowId));\n const next = allSelected ? [] : all;\n return sameItems(next, previous) ? previous : next;\n });\n }, [setSelected, store]);\n\n const radioName = useId('wave-datagrid-selection');\n const selectAllLabel = labels?.selectAll ?? DEFAULT_SELECT_ALL_LABEL;\n const selectionHeaderLabel = labels?.selectionHeader ?? DEFAULT_SELECTION_HEADER_LABEL;\n\n const context = React.useMemo<DataGridContextValue>(\n () => ({\n selectionMode,\n store,\n toggleRow,\n toggleAll,\n radioName,\n selectAllLabel,\n selectionHeaderLabel,\n }),\n [selectionMode, store, toggleRow, toggleAll, radioName, selectAllLabel, selectionHeaderLabel],\n );\n\n // --- keyboard -------------------------------------------------------------\n const { gridRef, gridProps } = useGridNavigation();\n const mergedRef = useMergedRefs<HTMLTableElement>(ref, gridRef);\n\n // --- header from columns ----------------------------------------------------\n let content: React.ReactNode = children;\n const flatChildren = columns ? flattenChildren(children) : [];\n if (columns && !flatChildren.some(({ node }) => isElementOfType(node, DataGridHeader))) {\n // A `<caption>` stays the table's first child, before the generated header.\n const isCaption = ({ node }: { node: React.ReactNode }) => isElementOfType(node, 'caption');\n content = (\n <>\n {flatChildren.filter(isCaption).map(renderFlatChild)}\n <DataGridHeader>\n <tr>\n {columns.map((column) => (\n <DataGridHeaderCell key={column.id} columnId={column.id} sortable={column.sortable}>\n {column.label}\n </DataGridHeaderCell>\n ))}\n </tr>\n </DataGridHeader>\n {flatChildren.filter((child) => !isCaption(child)).map(renderFlatChild)}\n </>\n );\n }\n\n const {\n className: containerClassName,\n 'aria-label': containerLabel,\n 'aria-labelledby': containerLabelledBy,\n ...containerRest\n } = containerProps ?? {};\n // The wrapper has no role of its own, and a name is prohibited on a role-less `<div>`: the\n // consumer's name is kept only together with a role.\n const containerHasRole = containerRest.role !== undefined;\n const droppedContainerName =\n !containerHasRole && (containerLabel !== undefined || containerLabelledBy !== undefined);\n\n React.useEffect(() => {\n if (droppedContainerName) {\n warnOnce(\n 'DataGrid:container-name-without-role',\n 'DataGrid: `containerProps[\"aria-label\"]`/`[\"aria-labelledby\"]` is ignored because the ' +\n 'wrapper has no role. Name the grid itself (`aria-label` on DataGrid), or pass a ' +\n '`role` (e.g. \"region\") in `containerProps` too.',\n );\n }\n }, [droppedContainerName]);\n\n return (\n <DataGridContext.Provider value={context}>\n <DataGridSortContext.Provider value={sortContext}>\n <div\n {...containerRest}\n aria-label={containerHasRole ? containerLabel : undefined}\n aria-labelledby={containerHasRole ? containerLabelledBy : undefined}\n className={cn(\n dataGridClassNames.container,\n 'overflow-x-auto rounded-md border border-border',\n containerClassName,\n )}\n >\n <table\n ref={mergedRef}\n role=\"grid\"\n aria-multiselectable={selectionMode === 'multiple' || undefined}\n className={cn(\n dataGridClassNames.root,\n 'w-full border-separate border-spacing-0',\n className,\n )}\n {...rest}\n onKeyDown={composeEventHandlers(onKeyDown, gridProps.onKeyDown)}\n onFocus={composeEventHandlers(onFocus, gridProps.onFocus, {\n checkDefaultPrevented: false,\n })}\n onBlur={composeEventHandlers(onBlur, gridProps.onBlur, {\n checkDefaultPrevented: false,\n })}\n >\n {content}\n </table>\n </div>\n </DataGridSortContext.Provider>\n </DataGridContext.Provider>\n );\n};\nDataGridRoot.displayName = 'DataGrid';\n\n// ---------------------------------------------------------------------------\n// Selection header cell (internal)\n// ---------------------------------------------------------------------------\n\nfunction DataGridSelectionHeaderCell({\n selectionMode,\n ref,\n}: {\n selectionMode: SelectionMode;\n ref?: React.Ref<HTMLTableCellElement>;\n}) {\n const { store, toggleAll, selectAllLabel, selectionHeaderLabel } =\n useDataGridContext('DataGrid.Header');\n const state = React.useSyncExternalStore(\n store.subscribeSelectAll,\n store.getSelectAllState,\n store.getSelectAllState,\n );\n const inputRef = React.useRef<HTMLInputElement>(null);\n // A click clears the checkbox's `indeterminate` flag (checkbox activation does) and React restores\n // only `checked`, so the flag is re-applied after every click, also when the select-all state\n // stays the same (a controlled parent that keeps the selection partial, or ignores the change).\n const [clicks, setClicks] = React.useState(0);\n\n React.useLayoutEffect(() => {\n if (inputRef.current) inputRef.current.indeterminate = state === 'some';\n }, [state, clicks]);\n\n return (\n <th\n ref={ref}\n scope=\"col\"\n data-selection-cell=\"\"\n className={cn(\n dataGridHeaderClassNames.selectionCell,\n selectionCell,\n 'text-start',\n focusRingInset,\n )}\n >\n {selectionMode === 'multiple' ? (\n <input\n ref={inputRef}\n type=\"checkbox\"\n aria-label={selectAllLabel}\n checked={state === 'all'}\n onChange={() => {\n setClicks((count) => count + 1);\n toggleAll();\n }}\n className={cn(dataGridHeaderClassNames.selectAllCheckbox, nativeControl, focusRingInset)}\n />\n ) : (\n <span className=\"sr-only\">{selectionHeaderLabel}</span>\n )}\n </th>\n );\n}\n\nconst INERT_HEADER_SLOTS: HeaderSlotRegistry = {\n subscribe: () => () => {},\n register: () => () => {},\n getFirst: () => null,\n refresh: () => {},\n};\n\n/**\n * The selection column's cell of one header row: the select-all header cell in the header's first\n * row (document order), an empty cell in every later row. `initialFirst` is the header's guess from\n * its children, used until the slots are registered (the initial and the server render).\n */\nfunction DataGridSelectionHeaderSlot({\n selectionMode,\n initialFirst,\n}: {\n selectionMode: SelectionMode;\n initialFirst: boolean;\n}) {\n const slots = React.useContext(DataGridHeaderSlotsContext) ?? INERT_HEADER_SLOTS;\n const [slot] = React.useState(() => ({}));\n const cellRef = React.useRef<HTMLTableCellElement | null>(null);\n\n const getIsFirst = React.useCallback(() => {\n const first = slots.getFirst();\n return first === null ? initialFirst : first === slot;\n }, [slots, slot, initialFirst]);\n const getServerIsFirst = React.useCallback(() => initialFirst, [initialFirst]);\n const isFirst = React.useSyncExternalStore(slots.subscribe, getIsFirst, getServerIsFirst);\n\n React.useLayoutEffect(() => slots.register(slot, () => cellRef.current), [slots, slot]);\n\n return isFirst ? (\n <DataGridSelectionHeaderCell ref={cellRef} selectionMode={selectionMode} />\n ) : (\n <td\n ref={cellRef}\n data-selection-cell=\"\"\n className={cn(dataGridHeaderClassNames.selectionCell, selectionCell, focusRingInset)}\n />\n );\n}\n\n// ---------------------------------------------------------------------------\n// Sub-components\n// ---------------------------------------------------------------------------\n\n/**\n * Prepends the selection column's header slot (or `null`) to every `<tr>` in `children`, looking\n * inside Fragments, and tells every other element child (a `DataGrid.Row`, or a component that\n * renders one) whether it is the header's first row. Every row gets the same child shape in every\n * selection mode, so switching `selectionMode` does not remount the header cells.\n */\nfunction withSelectionHeaderSlots(\n children: React.ReactNode,\n selectionMode: 'none' | SelectionMode,\n): React.ReactNode {\n let first = true;\n const visit = (nodes: React.ReactNode): React.ReactNode =>\n React.Children.map(nodes, (child) => {\n if (isElementOfType<{ children?: React.ReactNode }>(child, React.Fragment)) {\n return React.cloneElement(child, undefined, visit(child.props.children));\n }\n if (!React.isValidElement(child)) return child;\n const isFirst = first;\n first = false;\n if (isElementOfType<{ children?: React.ReactNode }>(child, 'tr')) {\n const slot =\n selectionMode === 'none' ? null : (\n <DataGridSelectionHeaderSlot selectionMode={selectionMode} initialFirst={isFirst} />\n );\n return React.cloneElement(child, undefined, slot, child.props.children);\n }\n return (\n <DataGridHeaderRowHintContext.Provider value={isFirst}>\n {child}\n </DataGridHeaderRowHintContext.Provider>\n );\n });\n return visit(children);\n}\n\n/**\n * The grid's `<thead>`. When the grid is selectable, it prepends the selection column's header\n * cell to each `<tr>` child, also inside a Fragment: the first header row gets the \"Select all\n * rows\" checkbox (multiple mode) or the \"Selection\" header (single mode; DataGrid's `labels`\n * localizes both), later rows of a grouped header an empty cell. A header row rendered by another\n * component cannot get it (a development warning says so): use `DataGrid.Row` for such a row,\n * which adds the cell itself.\n */\nconst DataGridHeader = ({ children, className, ref, ...rest }: DataGridHeaderProps) => {\n const { selectionMode } = useDataGridContext('DataGrid.Header');\n const [thead, setThead] = React.useState<HTMLTableSectionElement | null>(null);\n const mergedRef = useMergedRefs<HTMLTableSectionElement>(ref, setThead);\n const [slots] = React.useState(createHeaderSlotRegistry);\n const content = withSelectionHeaderSlots(children, selectionMode);\n\n // Every commit, after the rows' slots registered: header rows can move without a slot mounting.\n React.useLayoutEffect(() => {\n slots.refresh();\n });\n\n // Every commit: header rows can come from components the header cannot see into.\n React.useEffect(() => {\n if (!isDev || !thead || selectionMode === 'none') return;\n const missing = Array.from(thead.rows).some(\n (row) => row.cells.length > 0 && !row.cells[0].hasAttribute('data-selection-cell'),\n );\n if (missing) {\n warnOnce(\n 'DataGrid.Header:missing-selection-cell',\n 'DataGrid.Header: a header row has no selection column header cell, so the header has one ' +\n 'column fewer than the selectable rows. Render header rows as `<tr>` children of ' +\n 'DataGrid.Header (a Fragment is fine), or use `DataGrid.Row` for a header row that ' +\n 'another component renders.',\n );\n }\n });\n\n return (\n <DataGridSectionContext.Provider value=\"header\">\n <DataGridHeaderSlotsContext.Provider value={slots}>\n <thead\n ref={mergedRef}\n className={cn(dataGridHeaderClassNames.root, 'bg-card', className)}\n {...rest}\n >\n {content}\n </thead>\n </DataGridHeaderSlotsContext.Provider>\n </DataGridSectionContext.Provider>\n );\n};\nDataGridHeader.displayName = 'DataGridHeader';\n\nconst sortIcon = (direction: SortDirection) => (\n <svg\n className={cn(dataGridHeaderCellClassNames.sortIcon, 'h-3 w-3 shrink-0')}\n viewBox=\"0 0 12 12\"\n fill=\"currentColor\"\n aria-hidden=\"true\"\n focusable=\"false\"\n >\n {direction === 'ascending' ? <path d=\"M6 2L10 8H2L6 2Z\" /> : <path d=\"M6 10L2 4H10L6 10Z\" />}\n </svg>\n);\n\n/**\n * A column header cell. A `sortable` header (with a `columnId`) renders its content inside a\n * `<button type=\"button\">` that toggles the sort; the `<th>` carries `aria-sort`. A consumer\n * `onClick` (on the `<th>`) runs before the sort, and calling `preventDefault()` in it cancels the\n * sort (also for Enter/Space on the button, which click it).\n */\nconst DataGridHeaderCell = ({\n columnId,\n sortable = false,\n children,\n className,\n onClick,\n ref,\n ...rest\n}: DataGridHeaderCellProps) => {\n const { sort, requestSort } = useDataGridSortContext('DataGrid.HeaderCell');\n /** The column this header sorts, or `undefined` when it is not sortable. */\n const sortColumnId = sortable && columnId ? columnId : undefined;\n const sortedDirection =\n sortColumnId !== undefined && sort?.columnId === sortColumnId ? sort.direction : null;\n\n // The sort runs from the `<th>` once the button's click bubbled up to it, composed after the\n // consumer's `onClick` (C-COMPOSE): the consumer runs first and can cancel with preventDefault().\n // The sort button is the `<th>`'s only child; clicks elsewhere in the cell do not sort.\n const sortOnButtonClick = (event: React.MouseEvent<HTMLTableCellElement>) => {\n const button = event.currentTarget.firstElementChild;\n if (\n sortColumnId !== undefined &&\n button?.localName === 'button' &&\n button.contains(event.target as Node)\n ) {\n requestSort(sortColumnId);\n }\n };\n\n React.useEffect(() => {\n if (sortable && !columnId) {\n warnOnce(\n 'DataGrid.HeaderCell:sortable-without-columnId',\n 'DataGrid.HeaderCell: `sortable` needs a `columnId`; the header is rendered as not sortable.',\n );\n }\n }, [sortable, columnId]);\n\n return (\n <th\n ref={ref}\n scope=\"col\"\n aria-sort={sortColumnId !== undefined ? (sortedDirection ?? 'none') : undefined}\n className={cn(\n dataGridHeaderCellClassNames.root,\n cellBase,\n 'text-start align-middle font-semibold text-caption-1 uppercase tracking-wider',\n focusRingInset,\n sortColumnId !== undefined && 'p-0 hover:bg-subtle-hover',\n className,\n )}\n {...rest}\n onClick={\n sortColumnId !== undefined ? composeEventHandlers(onClick, sortOnButtonClick) : onClick\n }\n >\n {sortColumnId !== undefined ? (\n <button\n type=\"button\"\n className={cn(\n dataGridHeaderCellClassNames.button,\n 'inline-flex w-full cursor-pointer select-none items-center gap-1 border-0 bg-transparent px-4 py-3 text-start text-inherit [font:inherit] uppercase tracking-wider',\n focusRingInset,\n )}\n >\n {children}\n {sortedDirection && sortIcon(sortedDirection)}\n </button>\n ) : (\n <span className=\"inline-flex items-center gap-1\">{children}</span>\n )}\n </th>\n );\n};\nDataGridHeaderCell.displayName = 'DataGridHeaderCell';\n\n/** The grid's `<tbody>`. */\nconst DataGridBody = ({ children, className, ref, ...rest }: DataGridBodyProps) => (\n <DataGridSectionContext.Provider value=\"body\">\n <tbody ref={ref} className={cn(dataGridBodyClassNames.root, className)} {...rest}>\n {children}\n </tbody>\n </DataGridSectionContext.Provider>\n);\nDataGridBody.displayName = 'DataGridBody';\n\n/**\n * A grid row. In a selectable grid it starts with a selection cell (checkbox or radio) named\n * after the row's first cell (or `selectionLabel`); Space on one of its cells toggles the row.\n */\nconst DataGridRow = ({\n rowId,\n selectionLabel,\n children,\n className,\n onKeyDown,\n ref,\n ...rest\n}: DataGridRowProps) => {\n const { selectionMode, store, toggleRow, radioName } = useDataGridContext('DataGrid.Row');\n const section = React.useContext(DataGridSectionContext);\n const firstHeaderRowHint = React.useContext(DataGridHeaderRowHintContext);\n const inHeader = section === 'header';\n const selectable = selectionMode !== 'none' && !inHeader;\n const labelId = useId('wave-datagrid-row-label');\n\n const single = selectionMode === 'single';\n const getSelected = React.useCallback(\n () => rowId !== undefined && store.isSelected(rowId, single),\n [rowId, store, single],\n );\n // Notified only when the selection changes (in multiple mode, rows registering notify no row).\n const isSelected = React.useSyncExternalStore(store.subscribe, getSelected, getSelected);\n\n React.useLayoutEffect(() => {\n if (rowId === undefined || inHeader) return;\n const unregister = store.register(rowId);\n if (isDev && store.countRegistrations(rowId) > 1) warnDuplicateRowId(rowId);\n return unregister;\n }, [store, rowId, inHeader]);\n\n React.useEffect(() => {\n if (selectable && rowId === undefined) {\n warnOnce(\n 'DataGrid.Row:missing-rowId',\n 'DataGrid.Row: a selectable grid needs a `rowId` on every row; this row has no selection control.',\n );\n }\n }, [selectable, rowId]);\n\n const unlabelled = selectable && rowId !== undefined && selectionLabel === undefined;\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLTableRowElement>) => {\n if (!selectable || rowId === undefined || event.key !== ' ') return;\n const target = event.target as Element;\n // Only keys pressed on the row itself or on one of its own cells, never on a nested widget.\n if (target !== event.currentTarget && target.parentElement !== event.currentTarget) return;\n event.preventDefault();\n toggleRow(rowId);\n };\n\n // Name the selection control after the first cell (its own id, or a generated one). The children\n // are always flattened (Fragments too) and rendered under their flattened keys, whatever the\n // mode, so the keys stay the same when `selectionMode`, `selectionLabel` or `rowId` change and\n // the cells are not remounted.\n const flatChildren = flattenChildren(children);\n let labelledBy: string | undefined;\n let idCellIndex = -1;\n if (unlabelled) {\n const firstCellIndex = flatChildren.findIndex(({ node }) =>\n isElementOfType(node, DataGridCell, 'td', 'th'),\n );\n if (firstCellIndex >= 0) {\n const firstCell = flatChildren[firstCellIndex].node as React.ReactElement<{ id?: string }>;\n labelledBy = firstCell.props.id ?? labelId;\n if (firstCell.props.id === undefined) idCellIndex = firstCellIndex;\n }\n }\n const content = flatChildren.map(({ key, node }, index) =>\n renderFlatChild({\n key,\n node:\n index === idCellIndex\n ? React.cloneElement(node as React.ReactElement<{ id?: string }>, { id: labelId })\n : node,\n }),\n );\n\n const needsLabel = unlabelled && labelledBy === undefined;\n React.useEffect(() => {\n if (needsLabel) {\n warnOnce(\n 'DataGrid.Row:selection-label',\n 'DataGrid.Row: no child is a `DataGrid.Cell`, `<td>` or `<th>` element, so the row selection control is named \"Select row\". Pass `selectionLabel` (a cell rendered by another component is not seen).',\n );\n }\n }, [needsLabel]);\n\n let selectionCellElement: React.ReactNode = null;\n if (inHeader && selectionMode !== 'none') {\n selectionCellElement = (\n <DataGridSelectionHeaderSlot\n selectionMode={selectionMode}\n initialFirst={firstHeaderRowHint}\n />\n );\n } else if (selectable) {\n selectionCellElement = (\n <td\n role=\"gridcell\"\n data-selection-cell=\"\"\n className={cn(dataGridRowClassNames.selectionCell, selectionCell, focusRingInset)}\n >\n {rowId !== undefined && (\n <input\n type={selectionMode === 'multiple' ? 'checkbox' : 'radio'}\n name={selectionMode === 'single' ? radioName : undefined}\n // The shared name groups the radios. `form=\"\"` matches no form, so they have no form\n // owner (still one group: same name, both ownerless) and never add a generated field\n // to an enclosing form's submission.\n form={selectionMode === 'single' ? '' : undefined}\n checked={isSelected}\n onChange={() => toggleRow(rowId)}\n aria-label={selectionLabel ?? (labelledBy ? undefined : 'Select row')}\n aria-labelledby={selectionLabel === undefined ? labelledBy : undefined}\n className={cn(dataGridRowClassNames.selectionControl, nativeControl, focusRingInset)}\n />\n )}\n </td>\n );\n }\n\n return (\n <tr\n ref={ref}\n className={cn(\n dataGridRowClassNames.root,\n !inHeader &&\n 'hover:bg-subtle-hover data-[selected]:bg-selected transition-colors motion-reduce:transition-none',\n selectable && isSelected && forcedColors.selectedContainer,\n className,\n )}\n aria-selected={selectable ? isSelected : undefined}\n data-selected={selectable && isSelected ? '' : undefined}\n {...rest}\n onKeyDown={composeEventHandlers(onKeyDown, handleKeyDown)}\n >\n {selectionCellElement}\n {content}\n </tr>\n );\n};\nDataGridRow.displayName = 'DataGridRow';\n\n/** A grid cell (`<td>`), focusable through the grid's keyboard navigation. */\nconst DataGridCell = ({ children, className, ref, ...rest }: DataGridCellProps) => (\n <td\n ref={ref}\n role=\"gridcell\"\n className={cn(dataGridCellClassNames.root, cellBase, 'text-body-1', focusRingInset, className)}\n {...rest}\n >\n {children}\n </td>\n);\nDataGridCell.displayName = 'DataGridCell';\n\nexport { DataGridHeader, DataGridHeaderCell, DataGridBody, DataGridRow, DataGridCell };\n\n/**\n * An interactive data table (`role=\"grid\"`) following the APG Grid pattern: one tab stop,\n * arrow-key navigation between cells (Home/End, Ctrl+Home/Ctrl+End, PageUp/PageDown; Up/Down keep\n * the visual column, so a grouped header with spanning cells works), Enter/F2 to interact with a\n * cell's widgets and Escape to return to the cell. A composite widget in a cell (a Toolbar,\n * RadioGroup, TabList, …) is entered with Enter/F2 like a text field; it manages its own tab\n * indexes, so it keeps its own Tab stop. Supports sortable columns (controlled sorting:\n * `onSortChange` reports the new sort and the consumer reorders the rows) and single or multiple\n * row selection with a select-all header checkbox.\n *\n * Sub-components are available as `DataGrid.Header`, `DataGrid.HeaderCell`, `DataGrid.Body`,\n * `DataGrid.Row` and `DataGrid.Cell` in client components, and as the flat exports\n * `DataGridHeader`, `DataGridHeaderCell`, `DataGridBody`, `DataGridRow` and `DataGridCell` (the\n * form React Server Components can import).\n */\nexport const DataGrid = /* @__PURE__ */ Object.assign(DataGridRoot, {\n Header: DataGridHeader,\n HeaderCell: DataGridHeaderCell,\n Body: DataGridBody,\n Row: DataGridRow,\n Cell: DataGridCell,\n});\n"],"mappings":";;;;;;;;;;;;;;AA4DA,IAAMI,IAA2B,mBAC3BC,IAAiC;AA+PvC,SAAgBC,EACd,GACA,IAAoB,IACJ;CAChB,IAAIC,IAAgC,IAAI,IAAIC,CAAO,GAE7CC,oBAAa,IAAI,IAAoB,GAEvCC,IAAqB,GACrBC,IAA4B,QAC5BC,IAAaC,GAEbC,GACEC,oBAAe,IAAI,IAAgB,GACnCC,oBAAqB,IAAI,IAAgB,GAEzCC,KAAU,MAA+B;EAC7C,KAAK,IAAMC,KAAY,MAAM,KAAKC,CAAS,GAAG,EAAS;CACzD,GAGMC,UAAmC;EACvC,IAAIN,MAAa,KAAA,GAAW,OAAOA;EACnC,IAAIO,IAAuB;EAC3B,KAAK,IAAMC,KAASf,GAAU;GAC5B,IAAIE,EAAW,IAAIa,CAAK,GAAG;IACzB,IAAQA;IACR;GACF;GACA,MAAUA;EACZ;EAEA,OADA,IAAWD,GACJA;CACT,GAMME,KAAwB,MAAkB;EAC9C,IAAIhB,EAAS,OAAO,KAAK,CAACA,EAAS,IAAIe,CAAK,GAAG;EAC/C,IAAME,IAAWV;EAEjB,AADA,IAAW,KAAA,GACPF,KAAcQ,EAAY,MAAMI,KAAUP,EAAOF,CAAY;CACnE,GAEMU,UAAwB;EAC5B,IAAMC,IACJhB,MAAuB,IAAI,SAASA,MAAuBD,EAAW,OAAO,QAAQ;EACvF,AAAIiB,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AAD;EACO;EACL,WAAW6E,EACT6D,EAAsB,MACtB,CAACjB,KACC,qGACFC,KAAcG,KAAcc,EAAa,mBACzC5D,CACF;EACA,iBAAe2C,IAAaG,IAAa,KAAA;EACzC,iBAAeH,KAAcG,IAAa,KAAK,KAAA;EAC/C,GAAIvH;EACJ,WAAW0E,EAAqBC,GAAWgD,CAAa;EAZ1D,UAAA,CAcGQ,GACA9E,CACC;;AAER;AACA,EAAY,cAAc;AAG1B,IAAM2E,KAAgB,EAAE,aAAU,cAAW,QAAK,GAAGhI,QACnD,kBAAC,MAAD;CACO;CACL,MAAK;CACL,WAAWuE,EAAG+D,EAAuB,MAAM9I,GAAU,eAAe6F,GAAgBZ,CAAS;CAC7F,GAAIzE;CAEH;AACC,CAAA;AAEN,EAAa,cAAc;AAmB3B,IAAauI,KAA2B,uBAAO,OAAO5I,GAAc;CAClE,QAAQgE;CACR,YAAYG;CACZ,MAAMgD;CACN,KAAKE;CACL,MAAMgB;AACR,CAAC"}
|
|
1
|
+
{"version":3,"file":"DataGrid.mjs","names":["useId","useId$1","React","DEFAULT_SELECT_ALL_LABEL","DEFAULT_SELECTION_HEADER_LABEL","createSelectionStore","selected","initial","registered","disabled","enabledCount","selectedEnabled","selectAll","singleMode","initialSingleMode","singleId","rowListeners","selectAllListeners","notify","listener","listeners","getSingleId","first","rowId","onRegistrationChange","previous","updateSelectAll","next","isEnabled","changeRow","wasEnabled","nowEnabled","step","count","counts","subscribeTo","done","items","item","single","createHeaderSlotRegistry","slots","update","nextCell","slot","getCell","cell","DataGridContext","DataGridSortContext","DataGridSectionContext","DataGridHeaderSlotsContext","DataGridHeaderRowHintContext","DataGridItemsContext","DataGridRowIdContext","DataGridRowContext","INERT_CONTEXT","INERT_SORT_CONTEXT","INERT_ROW_CONTEXT","useDataGridContext","reportMissingContext","component","useDataGridRowContext","useDataGridSortContext","EMPTY_ITEMS","toItems","keys","sameItems","a","b","index","renderFlatChild","node","key","columnIdOf","resolveDeprecatedProp","column","warnDuplicateRowId","cellBase","BODY_ROW_CLASSES","isSelectionCellElement","getTablePartKind","DataGridRoot","sortProp","sortColumnProp","sortDirectionProp","selectedItemsProp","rest","props","hasItems","usesSortApi","defaultSort","legacySort","objectMode","setObjectMode","objectCallbacks","legacySortControlled","warnDeprecated","defaultSortColumn","defaultSortDirection","deprecatedSortProps","mixedSortApi","ignoredSortProps","warnOnce","legacyHalves","setLegacyHalves","legacyControlledSort","legacyDefaultSort","controlledSort","initialSort","sortDetailsRef","sort","setSort","useControllable","onSortChange","requestSort","columnId","sortContext","onSelectionChange","legacySelected","selectedKeys","legacyDefaultSelected","defaultSelectedKeys","controlledSelected","defaultSelected","defaultSelectedItems","selectionDetailsRef","setSelectedValue","onSelectedItemsChange","setSelected","selectionMode","store","toggleRow","event","effective","selectedCount","toggleAll","all","enabled","radioName","selectAllLabel","labels","selectionHeaderLabel","context","selectOnRowClick","selectionAppearance","subtleSelection","useGridNavigation","mergedRef","useMergedRefs","ref","gridRef","itemRows","getRowId","sortColumnId","sortDirection","sortCompare","columns","sortedRows","compare","renderColumnsRow","cellKeys","DataGridRow","DataGridCell","itemsContext","columnWithoutId","content","children","flatChildren","flattenChildren","hasChild","isElementOfType","part","generatedHeader","DataGridHeader","DataGridHeaderCell","generatedBody","DataGridBody","isCaption","others","child","footerIndex","bodyIndex","containerClassName","containerLabel","containerLabelledBy","containerRest","containerProps","containerHasRole","droppedContainerName","cn","dataGridClassNames","className","composeEventHandlers","onKeyDown","gridProps","onFocus","onBlur","DataGridSelectionHeaderCell","state","ariaLabel","ariaLabelledBy","ariaDescribedBy","cellProps","checked","stableClassName","dataGridHeaderClassNames","SELECTION_CELL_CLASSES","focusRingInset","TableSelectionControl","controlRef","INERT_HEADER_SLOTS","DataGridSelectionHeaderSlot","cellRef","getIsFirst","initialFirst","getServerIsFirst","isFirst","_disabled","_invisible","_controlRef","_ariaLabel","_ariaLabelledBy","_ariaDescribedBy","withSelectionHeaderSlots","visit","nodes","cells","thead","setThead","isDev","selectionCells","row","sortable","sortedDirection","sortOnButtonClick","button","dataGridHeaderCellClassNames","onClick","TableSortButton","DataGridItemRow","render","rows","renderWithoutItems","renderRows","dataGridBodyClassNames","rowIdProp","itemRowId","section","firstHeaderRowHint","inHeader","selectable","labelId","ownCellProps","hasSelectionCell","selectionDisabled","selectionCellProps","selectionInvisible","ownLabelledBy","ownLabel","selectionLabel","getSelected","isSelected","unregister","unlabelled","handleKeyDown","target","handleClick","isForeignEvent","element","endsTextSelection","labelledBy","idCellIndex","firstCellIndex","firstCell","needsLabel","controlLabelledBy","controlLabel","rowContext","selectionCellElement","DataGridBodySelectionCell","dataGridRowClassNames","forcedColors","DataGridSelectionCell","notSelectable","unseen","rowProps","dataGridSelectionCellClassNames","invisible","markTablePart","dataGridCellClassNames","DataGrid"],"sources":["../../../src/components/table/DataGrid.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../lib/cn';\nimport {\n dataGridBodyClassNames,\n dataGridCellClassNames,\n dataGridClassNames,\n dataGridHeaderCellClassNames,\n dataGridHeaderClassNames,\n dataGridRowClassNames,\n dataGridSelectionCellClassNames,\n} from '../../lib/classNames';\nimport { flattenChildren, isElementOfType } from '../../lib/children';\nimport { composeEventHandlers } from '../../lib/composeEventHandlers';\nimport {\n isDev,\n reportMissingContext,\n resolveDeprecatedProp,\n warnDeprecated,\n warnOnce,\n} from '../../lib/dev';\nimport { endsTextSelection, isForeignEvent } from '../../lib/events';\nimport type { Slot } from '../../lib/slot';\nimport { focusRingInset, forcedColors } from '../../lib/styles';\nimport type { SelectionMode } from '../../lib/types';\nimport { useControllable } from '../../hooks/useControllable';\nimport { useId } from '../../hooks/useId';\nimport { useMergedRefs } from '../../hooks/useMergedRefs';\nimport {\n SELECTION_CELL_CLASSES,\n TableSelectionControl,\n TableSortButton,\n getTablePartKind,\n markTablePart,\n} from './Table.shared';\nimport type { SortDirection } from './Table.shared';\nimport { useGridNavigation } from './useGridNavigation';\n\nexport type { SortDirection };\n\n/** The sort state of a DataGrid: the sorted column and its direction. */\nexport interface DataGridSort {\n /** The `columnId` of the sorted column. */\n columnId: string;\n /** The sort direction. */\n direction: SortDirection;\n}\n\n/** Second argument of `onSortChange` (the `DataGridSort` form): the event behind the sort. */\nexport interface DataGridSortChangeDetails {\n /** The DOM event behind the sort: the click of the sort button (Enter and Space click it). */\n event: Event;\n}\n\n/** Second argument of `onSelectedItemsChange`: the event behind the change. */\nexport interface DataGridSelectedItemsChangeDetails {\n /**\n * The DOM event behind the change: the click of a selection control (the select-all checkbox\n * included), or the key press of Space on a row.\n */\n event: Event;\n}\n\n/**\n * Defines a column of the DataGrid, typed by the grid's items (`T`): the header cell it renders\n * and, with `items`, the cell of each row. `createTableColumn` builds one with `sortable` resolved.\n * A column with functions (`compare`, `renderCell`, `renderHeaderCell`) cannot be passed from a\n * Server Component to the DataGrid, since functions are not serializable: define such columns in a\n * client component.\n */\nexport interface DataGridColumn<T = unknown> {\n /**\n * Unique identifier of the column: the `columnId` of its header cell (and of the grid's sort) and\n * the React key of its cells. Required in practice: a column without it (and without the\n * deprecated `id`) cannot sort, with a development warning.\n */\n columnId?: string;\n /**\n * @deprecated Use `columnId`. Read only when `columnId` is not given, with a development\n * warning.\n */\n id?: string;\n /** The header content (text or any React node), unless `renderHeaderCell` is given. */\n label: React.ReactNode;\n /**\n * Orders two items of the column, as for `Array.prototype.sort` (negative: `a` first). A column\n * with `compare` is sortable unless `sortable` is `false`. While the grid's sort names the column\n * (its own sort, or a controlled `sort`), a grid with `items` renders its rows in this order: a\n * stable sort of a copy of `items`, so items that compare equal keep their order in `items`,\n * in both directions (descending negates `compare`). Without `compare` the grid never reorders\n * the rows: leave it out when the rows arrive sorted (a server-sorted grid).\n */\n compare?: (a: T, b: T) => number;\n /**\n * Renders the content of the column's cell for one item (rows rendered from `items`). Without\n * it, the column's cells are empty.\n */\n renderCell?: (item: T) => React.ReactNode;\n /** Renders the header content, in place of `label`. */\n renderHeaderCell?: () => React.ReactNode;\n /**\n * Whether the column's header is a sort button (the header cell carries `aria-sort`).\n * @default compare !== undefined\n */\n sortable?: boolean;\n}\n\n/** The built-in text of a DataGrid, for localization (see `DataGridBaseProps.labels`). */\nexport interface DataGridLabels {\n /** Accessible name of the select-all checkbox in the header (`selectionMode=\"multiple\"`).\n * @default 'Select all rows'\n */\n selectAll?: string;\n /**\n * Visually hidden text of the selection column's header cell (`selectionMode=\"single\"`), which\n * names that column.\n * @default 'Selection'\n */\n selectionHeader?: string;\n}\n\nconst DEFAULT_SELECT_ALL_LABEL = 'Select all rows';\nconst DEFAULT_SELECTION_HEADER_LABEL = 'Selection';\n\n/**\n * How a selected row of a DataGrid is filled (`selectionAppearance`): `'brand'` with the selected\n * token, `'neutral'` with the subtle selected token, `'none'` not at all.\n */\nexport type DataGridSelectionAppearance = 'brand' | 'neutral' | 'none';\n\n/**\n * The props of a row's selection cell (`DataGrid.Row` `selectionCellProps`), the automatic cell or\n * a `DataGrid.SelectionCell` child (whose own props win).\n */\nexport interface DataGridRowSelectionCellProps {\n /**\n * Disables the row's selection control natively. The control is then no focus target of the grid\n * (the cell takes focus), and neither a row click (`selectOnRowClick`), Space on a cell nor\n * select-all changes the row's selection: select-all skips it, keeps it as it is, and tells its\n * state from the other rows. In a header row it disables the select-all checkbox.\n * @default false\n */\n disabled?: boolean;\n /**\n * Hides the selection control (it keeps its space and cannot be focused). The row is still\n * selected by a row click and Space, and tells its state with `aria-selected`.\n * @default false\n */\n invisible?: boolean;\n /** Class of the selection cell (`<td>`, or the `<th>` of a header row). */\n className?: string;\n /**\n * Accessible name of the selection control, in place of `selectionLabel` and the name taken from\n * the row's first cell; in a header row, the name of the select-all checkbox.\n */\n 'aria-label'?: string;\n}\n\n/** Properties for the DataGridSelectionCell sub-component. */\nexport interface DataGridSelectionCellProps\n extends\n Omit<React.TdHTMLAttributes<HTMLTableCellElement>, 'children'>,\n DataGridRowSelectionCellProps {\n /**\n * The cell holds no content of its own: the grid renders the selection control (or, in a\n * single-mode header row, the hidden \"Selection\" header text).\n */\n children?: never;\n /**\n * Accessible name of the control, in place of `aria-label` and the row's `selectionLabel`.\n * Routed to the control, as `aria-label` and `aria-describedby` are.\n */\n 'aria-labelledby'?: string;\n /** Ref to the selection control (`<input type=\"checkbox\">` or `<input type=\"radio\">`). */\n controlRef?: React.Ref<HTMLInputElement>;\n /** Ref to the cell element (`<td>`, or the `<th>` of a header row's select-all). */\n ref?: React.Ref<HTMLTableCellElement>;\n}\n\n/**\n * The `items` prop of a DataGrid that renders its rows from data, part of every sort form of\n * `DataGridProps` but the 0.4 one. `T` is the type of the items.\n */\nexport interface DataGridItemsProps<T = unknown> {\n /**\n * The grid's data, one body row per item, in this order unless the sorted column has `compare`\n * (see `DataGridColumn.compare`). With `columns` and no `DataGrid.Body` child (or one without\n * children), the grid renders the rows and cells from the columns; a `DataGrid.Body` whose child\n * is a render function renders the row of each item. Each row's `rowId` comes from `getRowId`.\n * The grid reads the array and never changes it. With `items`, `onSortChange` receives a\n * `DataGridSort` object and `details`, never the 0.4 arguments. `items` may not be `undefined`\n * unless `sort` or `defaultSort` is given; pass `items={data ?? []}` while loading.\n */\n items?: readonly T[];\n}\n\n/** Props of every DataGrid, whatever sort API it uses. `T` is the type of its `items`. */\nexport interface DataGridBaseProps<T = unknown> extends React.HTMLAttributes<HTMLTableElement> {\n /**\n * The row id of an item: the `rowId` of its row (for selection), for rows rendered from `items`.\n * A row's own `rowId` wins. Ids must be unique (a duplicate warns in development).\n * @default the item's index in `items`, as a string\n */\n getRowId?: (item: T) => string;\n /**\n * Column definitions. When given and no `DataGrid.Header` child is present, the header row\n * (including the selection column) is rendered from them: `columnId` becomes the header cell's\n * `columnId`, `renderHeaderCell()` (else `label`) its content, and `sortable` (by default, having\n * `compare`) makes it a sort button. With `items` and no `DataGrid.Body` child, the body rows are\n * rendered from them too: one `DataGrid.Cell` per column, filled by `renderCell`. Those rows\n * render again whenever the array changes, so keep it stable (defined outside the component, or\n * memoised).\n */\n columns?: readonly DataGridColumn<T>[];\n /**\n * Row selection mode. `'multiple'` adds a checkbox column with a \"Select all rows\" header\n * checkbox; `'single'` adds a radio column (its header reads \"Selection\" to assistive\n * technology). `labels` localizes both texts.\n * @default 'none'\n */\n selectionMode?: 'none' | SelectionMode;\n /**\n * The name of the select-all checkbox and the header text of the selection column, for\n * localization. Unset members keep their English defaults. Rows are named with their own\n * `selectionLabel`.\n */\n labels?: DataGridLabels;\n /**\n * Whether a click on a body row toggles its selection in a selectable grid (single mode: selects\n * the row alone, or clears it). The row's own `onClick` runs first; calling `preventDefault()`\n * in it keeps the selection. A click never toggles when it lands on an interactive element in\n * the row (a link, a button, an input, a label, an element with `tabindex` or a widget role, the\n * selection control included), comes from a popup portaled from the row (a Menu, a Popover), or\n * ends a text selection in the row (a drag across its text); nor does a click on a header row\n * or on a row whose selection is disabled (`selectionCellProps.disabled`). Space on a cell\n * toggles the row either way.\n * @default false\n */\n selectOnRowClick?: boolean;\n /**\n * How a selected row is filled: `'brand'` with the selected token, `'neutral'` with the subtle\n * selected token, `'none'` not at all (the selection control, `aria-selected` and, in forced\n * colors, the row's outline still show it). Rendered as `data-selection-appearance` on the grid.\n * @default 'brand'\n */\n selectionAppearance?: DataGridSelectionAppearance;\n /**\n * Subtle selection controls: a row's control is transparent while the row is not selected, until\n * the row is hovered or holds focus, and the select-all checkbox while no row is selected, until\n * the grid is hovered or holds focus. Forced colors and a coarse pointer (touch) always draw\n * them; they stay focusable and named. Rendered as `data-subtle-selection` on the grid.\n * @default false\n */\n subtleSelection?: boolean;\n /**\n * Controlled selected row ids (`DataGrid.Row` `rowId`). In single mode pass at most one id: with\n * several, only the first one whose row is rendered is selected (a development warning says so).\n */\n selectedItems?: readonly string[];\n /** Initially selected row ids (uncontrolled). In single mode, at most one (see `selectedItems`). */\n defaultSelectedItems?: readonly string[];\n /**\n * Called with the new selected row ids when the selection changes, then `details` (`{ event }`,\n * the click or key press behind the change). Ids of rows that are not rendered are left out of\n * the reported selection and of the select-all state, so the next change drops them. Until that\n * change an uncontrolled grid still holds such an id: a row re-added with the same `rowId` before\n * then is shown selected again.\n */\n onSelectedItemsChange?: (\n selectedItems: string[],\n details?: DataGridSelectedItemsChangeDetails,\n ) => void;\n /** @deprecated Use `selectedItems` (an array). A `Set` or an array is accepted. */\n selectedKeys?: ReadonlySet<string> | readonly string[];\n /** @deprecated Use `defaultSelectedItems` (an array). A `Set` or an array is accepted. */\n defaultSelectedKeys?: ReadonlySet<string> | readonly string[];\n /** @deprecated Use `onSelectedItemsChange`, which receives an array. Both are called. */\n onSelectionChange?: (keys: Set<string>) => void;\n /**\n * Props for the wrapper `<div>` around the `<table>`: a horizontally scrollable container\n * (`overflow-x-auto`). Use it for its className, style (e.g. a max height) or ref. The wrapper\n * is not a tab stop (the grid's own cell tab stop scrolls it) and has no role, so its\n * `aria-label`/`aria-labelledby` are applied only together with a `role` (e.g. `'region'`);\n * without one they are dropped with a development warning. Name the grid with `aria-label`.\n */\n containerProps?: Omit<React.ComponentPropsWithRef<'div'>, 'children'>;\n /**\n * DataGrid header, body, and row elements. Optional when `items` and `columns` render the grid;\n * a generated body is placed after the header and before a `<tfoot>` child.\n */\n children?: React.ReactNode;\n /** Ref to the `<table role=\"grid\">` element. */\n ref?: React.Ref<HTMLTableElement>;\n}\n\ninterface NoDeprecatedSortProps {\n sortColumn?: never;\n defaultSortColumn?: never;\n sortDirection?: never;\n defaultSortDirection?: never;\n}\n\n/** The 0.5 sort API, controlled: `sort` + `onSortChange(sort, details)`. */\nexport interface DataGridControlledSortProps extends NoDeprecatedSortProps {\n /** The controlled sort, or `null` for an unsorted grid. */\n sort: DataGridSort | null;\n /** Initial sort while `sort` is not given yet. */\n defaultSort?: DataGridSort | null;\n /**\n * Called with the new sort when a sortable header is activated, then `details` (`{ event }`).\n * With `items`, the grid orders its rows by the sorted column's `compare` (see\n * `DataGridColumn.compare`), also while `sort` is controlled; otherwise the consumer orders them.\n */\n onSortChange?: (sort: DataGridSort, details?: DataGridSortChangeDetails) => void;\n}\n\n/** The 0.5 sort API, uncontrolled: `defaultSort` (`null` for none) + `onSortChange(sort, details)`. */\nexport interface DataGridUncontrolledSortProps extends NoDeprecatedSortProps {\n sort?: undefined;\n /** The initial sort, or `null` for an initially unsorted grid. */\n defaultSort: DataGridSort | null;\n /**\n * Called with the new sort when a sortable header is activated, then `details` (`{ event }`).\n * With `items`, the grid orders its rows by the sorted column's `compare` (see\n * `DataGridColumn.compare`); otherwise the consumer orders them.\n */\n onSortChange?: (sort: DataGridSort, details?: DataGridSortChangeDetails) => void;\n}\n\n/**\n * The sort props of a grid with `items`: the 0.5 sort API, whether or not `sort` or `defaultSort`\n * is given (unsorted at first without them). The 0.4 positional `onSortChange` and the deprecated\n * sort props do not apply to such a grid.\n */\nexport interface DataGridItemsSortProps<T = unknown>\n extends DataGridItemsProps<T>, NoDeprecatedSortProps {\n /** The grid's data (see `DataGridItemsProps.items`). */\n items: readonly T[];\n /** The controlled sort, or `null` for an unsorted grid; `undefined` leaves the sort to the grid. */\n sort?: DataGridSort | null;\n /** The initial sort while `sort` is not given. */\n defaultSort?: DataGridSort | null;\n /**\n * Called with the new sort when a sortable header is activated, then `details` (`{ event }`).\n * The grid orders its rows by the sorted column's `compare` (see `DataGridColumn.compare`).\n */\n onSortChange?: (sort: DataGridSort, details?: DataGridSortChangeDetails) => void;\n}\n\n/**\n * The 0.4 sort API: `onSortChange(columnId, direction)` and the deprecated `sortColumn`/\n * `sortDirection` props. It applies whenever none of `items`, `sort` and `defaultSort` is given.\n * As in 0.4, the column and the direction can be controlled independently: the half that is not\n * controlled is kept internally and follows every sort request (mixed control, warned in\n * development).\n */\nexport interface DataGridLegacySortProps {\n /** A grid with `items` uses the 0.5 sort API (`DataGridItemsSortProps`). */\n items?: undefined;\n sort?: undefined;\n defaultSort?: undefined;\n /**\n * @deprecated Use `sort` (`{ columnId, direction }` or `null`). Without `sortDirection`, the\n * direction is kept internally (it toggles on repeated clicks).\n */\n sortColumn?: string;\n /** @deprecated Use `defaultSort`. */\n defaultSortColumn?: string;\n /**\n * @deprecated Use `sort`. Without `sortColumn`, the column is kept internally (it follows the\n * clicked header, starting from `defaultSortColumn`).\n */\n sortDirection?: SortDirection;\n /** @deprecated Use `defaultSort`. */\n defaultSortDirection?: SortDirection;\n /**\n * Called when a sortable header is activated, with the 0.4 arguments. Pass `items`, `sort` or\n * `defaultSort` to receive a `DataGridSort` object (and `details`) instead:\n * `defaultSort={null}` turns the object form on for an initially unsorted grid. A `sort` that is\n * still `undefined` (e.g. while data loads) does not: pass `sort={sort ?? null}`.\n *\n * @example\n * <DataGrid defaultSort={null} onSortChange={(sort) => setSort(sort)}>…</DataGrid>\n */\n onSortChange?: (columnId: string, direction: SortDirection) => void;\n}\n\n/**\n * Properties for the DataGrid component, whose `items` are of type `T`. The sort props form a\n * union: `sort`/`defaultSort` with `onSortChange(sort, details)` (0.5, also the form of every grid\n * with `items`), or the 0.4 form `onSortChange(columnId, direction)` with the deprecated\n * `sortColumn`/`sortDirection`/`defaultSortColumn`/`defaultSortDirection`, for a grid without\n * `items`. The two cannot be mixed.\n */\nexport type DataGridProps<T = unknown> = DataGridBaseProps<T> &\n (\n | (DataGridItemsProps<T> & DataGridControlledSortProps)\n | (DataGridItemsProps<T> & DataGridUncontrolledSortProps)\n | DataGridItemsSortProps<T>\n | DataGridLegacySortProps\n );\n\n/** Properties for the DataGridHeader sub-component. */\nexport interface DataGridHeaderProps extends React.HTMLAttributes<HTMLTableSectionElement> {\n /**\n * Header row elements. Each `<tr>` child (also inside a Fragment) gets the selection column's\n * header cell prepended when the grid is selectable, unless the row holds a\n * `DataGrid.SelectionCell` (which then is that cell, where it stands); a header row rendered by\n * another component should be a `DataGrid.Row`, which adds the cell itself. With several header\n * rows (a grouped header), only the first one gets the \"Select all rows\" control; later rows get\n * an empty cell.\n */\n children: React.ReactNode;\n /** Ref to the `<thead>` element. */\n ref?: React.Ref<HTMLTableSectionElement>;\n}\n\n/** Properties for the DataGridHeaderCell sub-component. */\nexport interface DataGridHeaderCellProps extends React.ThHTMLAttributes<HTMLTableCellElement> {\n /** Column ID used for sort tracking. Required for `sortable`. */\n columnId?: string;\n /**\n * Whether this column can be sorted. The content is rendered inside a `<button>`; the header\n * cell carries `aria-sort`. Ignored (with a development warning) without `columnId`.\n * @default false\n */\n sortable?: boolean;\n /**\n * The glyph a sortable header shows after its content while its column is sorted, in place of\n * the default arrow (up for ascending, down for descending). It is decorative (`aria-hidden`:\n * `aria-sort` on the header tells the direction) and carries `data-direction` (`ascending` or\n * `descending`), so one glyph can be turned by a selector on it. `null` and `undefined` keep the\n * arrow; `false`, or any value that renders nothing, shows no glyph. A `<button>` or `Button`\n * element (or a slot object whose `as` is one) is not nested in the sort button: its children\n * become the glyph and its props are dropped, with a development warning.\n */\n sortIcon?: Slot<'span'>;\n /** Header cell content. */\n children: React.ReactNode;\n /** Ref to the `<th>` element. */\n ref?: React.Ref<HTMLTableCellElement>;\n}\n\n/** Properties for the DataGridBody sub-component, in a grid whose `items` are of type `T`. */\nexport interface DataGridBodyProps<T = unknown> extends Omit<\n React.HTMLAttributes<HTMLTableSectionElement>,\n 'children'\n> {\n /**\n * The body rows: `DataGrid.Row` elements, or a render function called with each item of the\n * grid's `items` (in the grid's sort order) and the item's index in `items` (its position there,\n * whatever the sort), which returns the item's `DataGrid.Row`. The grid keys each returned row\n * by its row id and gives it that id as `rowId` (from `getRowId`), and renders it again only\n * when its item, its index or the function change (a sort moves the rows). Type the function\n * by annotating its item parameter (`(person: Person) => …`) or with `DataGrid.Body<Person>`.\n * Without children, a grid with `items` and `columns` renders the rows from the columns; empty\n * children are no rows.\n */\n children?: React.ReactNode | ((item: T, index: number) => React.ReactNode);\n /** Ref to the `<tbody>` element. */\n ref?: React.Ref<HTMLTableSectionElement>;\n}\n\n/** Properties for the DataGridRow sub-component. */\nexport interface DataGridRowProps extends React.HTMLAttributes<HTMLTableRowElement> {\n /**\n * Unique identifier for this row, used for selection (rows that share one are selected together;\n * a duplicate warns in development). A selectable grid renders no selection control (and warns\n * in development) for a row without it. A row rendered from the grid's `items` (by\n * `DataGrid.Body`'s render function or from `columns`) defaults to the item's row id\n * (`getRowId`).\n */\n rowId?: string;\n /**\n * Accessible name of the row's selection control. Defaults to the row's first child that is a\n * `DataGrid.Cell`, `<td>` or `<th>` element (`aria-labelledby`); a cell that another component\n * renders is not seen, so pass `selectionLabel` when the row's first cell is one. Without such a\n * child the control is named \"Select row\" (with a development warning). The selection cell's\n * `aria-label` (`selectionCellProps`, or a `DataGrid.SelectionCell` child's) wins over it.\n */\n selectionLabel?: string;\n /**\n * Props of the row's selection cell (`disabled`, `invisible`, `className`, `aria-label`): the\n * cell the row adds first in a selectable grid, or a `DataGrid.SelectionCell` child, whose own\n * props win (their classes are merged). In a header row they apply to the select-all cell.\n */\n selectionCellProps?: DataGridRowSelectionCellProps;\n /**\n * DataGrid cell elements. A `DataGrid.SelectionCell` child (also inside a Fragment) is the row's\n * selection cell, where it stands: the row then adds none.\n */\n children: React.ReactNode;\n /** Ref to the `<tr>` element. */\n ref?: React.Ref<HTMLTableRowElement>;\n}\n\n/** Properties for the DataGridCell sub-component. */\nexport interface DataGridCellProps extends React.TdHTMLAttributes<HTMLTableCellElement> {\n /** Cell content. */\n children: React.ReactNode;\n /** Ref to the `<td>` element. */\n ref?: React.Ref<HTMLTableCellElement>;\n}\n\n// ---------------------------------------------------------------------------\n// Selection store\n// ---------------------------------------------------------------------------\n\ntype SelectAllState = 'all' | 'some' | 'none';\n\n/**\n * Selection state shared with the rows through `useSyncExternalStore`, so toggling one row\n * re-renders only that row (and the select-all header cell). The root pushes the committed\n * selection in a layout effect; rows register their ids. The effective selection is always\n * `selected ∩ registered`, derived on read (no pruning effect).\n *\n * @internal Not exported from the package (exported for its unit tests).\n */\nexport interface SelectionStore {\n /**\n * Row subscription: notified only when the selection changes. Rows registering or unregistering\n * notify no row, so adding or removing k of n rows costs O(k), not O(k·n); the one exception is\n * single mode with several selected ids, where a row registering can move the selected row.\n */\n subscribe(listener: () => void): () => void;\n /**\n * Select-all subscription: notified only when {@link getSelectAllState} changes (through the\n * selection or through rows registering and unregistering).\n */\n subscribeSelectAll(listener: () => void): () => void;\n /** Registers a rendered row id; returns the unregister function. */\n register(rowId: string): () => void;\n /**\n * Marks a row's selection disabled (`selectionCellProps.disabled`): select-all skips it and its\n * state counts only the other rows. Returns the function that undoes it. A row id is disabled\n * while any row registered with it is.\n */\n disable(rowId: string): () => void;\n /** Whether the row's selection is disabled (see {@link disable}). */\n isDisabled(rowId: string): boolean;\n /** How many rendered rows are registered with `rowId` (more than one: a duplicate). */\n countRegistrations(rowId: string): number;\n /** Sets the committed selection (layout effect of the root). */\n setSelected(items: readonly string[]): void;\n /**\n * Sets whether the grid is in single mode (layout effect of the root). Only then do rows\n * registering or unregistering re-check the one selected row of single mode and notify the rows.\n */\n setSingleMode(single: boolean): void;\n /**\n * Whether the row is selected. With `single`, only one row is: the first selected id (in\n * selection order) whose row is registered, else the first selected id (before any row\n * registered: the server render and the first client render).\n */\n isSelected(rowId: string, single?: boolean): boolean;\n /**\n * Whether all, some or none of the registered rows whose selection is not disabled are selected\n * (`'none'` without such rows). O(1).\n */\n getSelectAllState(): SelectAllState;\n /** Registered row ids in registration order. */\n getRegistered(): string[];\n /** `items` restricted to registered rows (order of `items`). */\n prune(items: readonly string[]): string[];\n}\n\n/**\n * Creates the {@link SelectionStore} of one DataGrid.\n *\n * @internal Not exported from the package (exported for its unit tests).\n */\nexport function createSelectionStore(\n initial: readonly string[],\n initialSingleMode = false,\n): SelectionStore {\n let selected: ReadonlySet<string> = new Set(initial);\n /** Registered row id -> number of rows registered with it. */\n const registered = new Map<string, number>();\n /** Row id -> number of `disable` calls in effect for it. */\n const disabled = new Map<string, number>();\n /** Registered row ids whose selection is not disabled: the rows select-all changes. */\n let enabledCount = 0;\n /** How many of those are selected (kept up to date, so select-all is O(1)). */\n let selectedEnabled = 0;\n let selectAll: SelectAllState = 'none';\n let singleMode = initialSingleMode;\n /** The one selected row of single mode (see `isSelected`); `undefined`: not computed yet. */\n let singleId: string | null | undefined;\n const rowListeners = new Set<() => void>();\n const selectAllListeners = new Set<() => void>();\n\n const notify = (listeners: Set<() => void>) => {\n for (const listener of Array.from(listeners)) listener();\n };\n\n /** Computed on read: O(selected ids) once per change, and only in single mode. */\n const getSingleId = (): string | null => {\n if (singleId !== undefined) return singleId;\n let first: string | null = null;\n for (const rowId of selected) {\n if (registered.has(rowId)) {\n first = rowId;\n break;\n }\n first ??= rowId;\n }\n singleId = first;\n return first;\n };\n\n /**\n * A row id registered or unregistered. With several selected ids, the one selected row of\n * single mode can move: in single mode it is re-checked and the rows are notified if it moved.\n */\n const onRegistrationChange = (rowId: string) => {\n if (selected.size < 2 || !selected.has(rowId)) return;\n const previous = singleId;\n singleId = undefined;\n if (singleMode && getSingleId() !== previous) notify(rowListeners);\n };\n\n const updateSelectAll = () => {\n const next: SelectAllState =\n selectedEnabled === 0 ? 'none' : selectedEnabled === enabledCount ? 'all' : 'some';\n if (next === selectAll) return;\n selectAll = next;\n notify(selectAllListeners);\n };\n\n const isEnabled = (rowId: string) => registered.has(rowId) && !disabled.has(rowId);\n\n /**\n * Runs `change` (a registration or a `disable` of `rowId`) and keeps the counts of select-all in\n * step with whether the row is enabled before and after it.\n */\n const changeRow = (rowId: string, change: () => void) => {\n const wasEnabled = isEnabled(rowId);\n change();\n const nowEnabled = isEnabled(rowId);\n if (wasEnabled === nowEnabled) return;\n const step = nowEnabled ? 1 : -1;\n enabledCount += step;\n if (selected.has(rowId)) selectedEnabled += step;\n };\n\n /** Adds `step` to the count of `rowId` in `counts`, deleting it at zero. */\n const count = (counts: Map<string, number>, rowId: string, step: 1 | -1) => {\n const next = (counts.get(rowId) ?? 0) + step;\n if (next > 0) counts.set(rowId, next);\n else counts.delete(rowId);\n };\n\n const subscribeTo = (listeners: Set<() => void>) => (listener: () => void) => {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n };\n\n return {\n subscribe: subscribeTo(rowListeners),\n subscribeSelectAll: subscribeTo(selectAllListeners),\n register(rowId) {\n const first = !registered.has(rowId);\n changeRow(rowId, () => count(registered, rowId, 1));\n updateSelectAll();\n if (first) onRegistrationChange(rowId);\n let done = false;\n return () => {\n if (done) return;\n done = true;\n changeRow(rowId, () => count(registered, rowId, -1));\n if (registered.has(rowId)) return;\n updateSelectAll();\n onRegistrationChange(rowId);\n };\n },\n disable(rowId) {\n changeRow(rowId, () => count(disabled, rowId, 1));\n updateSelectAll();\n let done = false;\n return () => {\n if (done) return;\n done = true;\n changeRow(rowId, () => count(disabled, rowId, -1));\n updateSelectAll();\n };\n },\n isDisabled(rowId) {\n return disabled.has(rowId);\n },\n setSelected(items) {\n const next = new Set(items);\n if (next.size === selected.size && items.every((item) => selected.has(item))) return;\n selected = next;\n singleId = undefined;\n selectedEnabled = 0;\n for (const rowId of next) if (isEnabled(rowId)) selectedEnabled += 1;\n notify(rowListeners);\n updateSelectAll();\n },\n setSingleMode(single) {\n singleMode = single;\n },\n isSelected(rowId, single = false) {\n return single ? getSingleId() === rowId : selected.has(rowId);\n },\n countRegistrations(rowId) {\n return registered.get(rowId) ?? 0;\n },\n getSelectAllState() {\n return selectAll;\n },\n getRegistered() {\n return Array.from(registered.keys());\n },\n prune(items) {\n return items.filter((item) => registered.has(item));\n },\n };\n}\n\n// ---------------------------------------------------------------------------\n// Header selection slots\n// ---------------------------------------------------------------------------\n\n/**\n * The selection column's header slots of one `DataGrid.Header`, one per header row. Only the first\n * slot in document order renders the \"Select all rows\" control (the \"Selection\" text in single\n * mode); the others render an empty cell, so a grouped header (several header rows) has one control\n * and every header row keeps the selection column.\n */\ninterface HeaderSlotRegistry {\n subscribe(listener: () => void): () => void;\n /** Registers a slot and a getter for its current cell; returns the unregister function. */\n register(slot: object, getCell: () => Element | null): () => void;\n /** The first slot in document order, or `null` while no slot is registered. */\n getFirst(): object | null;\n /** Re-checks the order: header rows can move without a slot mounting or unmounting. */\n refresh(): void;\n}\n\nfunction createHeaderSlotRegistry(): HeaderSlotRegistry {\n const slots = new Map<object, () => Element | null>();\n const listeners = new Set<() => void>();\n let first: object | null = null;\n\n const update = () => {\n let next: object | null = null;\n let nextCell: Element | null = null;\n for (const [slot, getCell] of slots) {\n const cell = getCell();\n if (!cell) {\n // A slot whose cell is being replaced (control <-> empty cell): keep the current order\n // until the next registration or header commit sees every cell again.\n if (first !== null && slots.has(first)) return;\n continue;\n }\n if (!nextCell || cell.compareDocumentPosition(nextCell) & Node.DOCUMENT_POSITION_FOLLOWING) {\n next = slot;\n nextCell = cell;\n }\n }\n if (next === null) next = slots.keys().next().value ?? null;\n if (next === first) return;\n first = next;\n for (const listener of Array.from(listeners)) listener();\n };\n\n return {\n subscribe(listener) {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n },\n register(slot, getCell) {\n slots.set(slot, getCell);\n update();\n return () => {\n slots.delete(slot);\n update();\n };\n },\n getFirst: () => first,\n refresh: update,\n };\n}\n\n// ---------------------------------------------------------------------------\n// Contexts\n// ---------------------------------------------------------------------------\n\ninterface DataGridContextValue {\n selectionMode: 'none' | SelectionMode;\n store: SelectionStore;\n /** Toggles one row (single mode: selects it alone, or clears it); `event` goes to `details`. */\n toggleRow: (rowId: string, event: Event) => void;\n /** Selects every rendered row, or clears the selection when all are selected. */\n toggleAll: (event: Event) => void;\n /** Shared `name` of the single-mode radios (they are kept out of any form with `form=\"\"`). */\n radioName: string;\n /** Name of the select-all checkbox (multiple mode). */\n selectAllLabel: string;\n /** Hidden header text of the selection column (single mode). */\n selectionHeaderLabel: string;\n /** `selectOnRowClick` of the grid. */\n selectOnRowClick: boolean;\n /** `selectionAppearance` of the grid. */\n selectionAppearance: DataGridSelectionAppearance;\n /** `subtleSelection` of the grid. */\n subtleSelection: boolean;\n}\n\n/** What a row tells its selection cell, the automatic one or a `DataGrid.SelectionCell` child. */\ninterface DataGridRowContextValue {\n /** The row's `selectionCellProps`. */\n selectionCellProps: DataGridRowSelectionCellProps | undefined;\n /** Whether a `DataGrid.SelectionCell` child was seen (then the row adds no cell of its own). */\n hasSelectionCell: boolean;\n /** The row's id; `undefined` for a header row, or a body row without one (no control). */\n rowId: string | undefined;\n isSelected: boolean;\n /** Resolved from the cell's own props and `selectionCellProps`. */\n disabled: boolean;\n /** Resolved from the cell's own props and `selectionCellProps`. */\n invisible: boolean;\n /** The control's `aria-label`. */\n ariaLabel: string | undefined;\n /** The control's `aria-labelledby`. */\n ariaLabelledBy: string | undefined;\n}\n\ninterface DataGridSortContextValue {\n sort: DataGridSort | null;\n /** Sorts by the column (toggling its direction); `event` goes to `details`. */\n requestSort: (columnId: string, event: Event) => void;\n}\n\ntype DataGridSection = 'header' | 'body';\n\nconst DataGridContext = React.createContext<DataGridContextValue | null>(null);\nconst DataGridSortContext = React.createContext<DataGridSortContextValue | null>(null);\n/** Whether a row is rendered in the header or the body (rows in a header get a header cell). */\nconst DataGridSectionContext = React.createContext<DataGridSection>('body');\n/** The header's selection slots (see {@link HeaderSlotRegistry}). */\nconst DataGridHeaderSlotsContext = React.createContext<HeaderSlotRegistry | null>(null);\n/**\n * Whether the header row below is the header's first row, as far as the header can tell from its\n * children. Only the initial (and server) render uses it; the slots then follow the DOM order.\n */\nconst DataGridHeaderRowHintContext = React.createContext(true);\n\n/** Renders the row of one item of `items` (a `DataGrid.Body` render function, or from `columns`). */\ntype DataGridRenderRow = (item: unknown, index: number) => React.ReactNode;\n\n/** One row of the grid's `items`. */\ninterface DataGridItemRowData {\n item: unknown;\n /** The item's index in `items`. */\n index: number;\n rowId: string;\n /** The row's React key: its row id, made unique when the id repeats. */\n key: string;\n}\n\ninterface DataGridItemsContextValue {\n /** The rows of `items`, in the order they are rendered; `null` without `items`. */\n rows: readonly DataGridItemRowData[] | null;\n /** Renders a row from `columns`; `null` without `items` and `columns`. */\n renderColumnsRow: DataGridRenderRow | null;\n}\n\n/** The grid's `items`, for `DataGrid.Body` (optional: a body of JSX rows needs none). */\nconst DataGridItemsContext = React.createContext<DataGridItemsContextValue | null>(null);\n/**\n * The row id of the item a body row is rendered for, the default `rowId` of `DataGrid.Row`. The\n * grid resets it, so the rows of a grid nested in a cell do not take the outer row's id.\n */\nconst DataGridRowIdContext = React.createContext<string | null>(null);\n/** The row around a selection cell (see {@link DataGridRowContextValue}). */\nconst DataGridRowContext = React.createContext<DataGridRowContextValue | null>(null);\n\nconst INERT_STORE = createSelectionStore([]);\nconst INERT_CONTEXT: DataGridContextValue = {\n selectionMode: 'none',\n store: INERT_STORE,\n toggleRow: () => {},\n toggleAll: () => {},\n radioName: '',\n selectAllLabel: DEFAULT_SELECT_ALL_LABEL,\n selectionHeaderLabel: DEFAULT_SELECTION_HEADER_LABEL,\n selectOnRowClick: false,\n selectionAppearance: 'brand',\n subtleSelection: false,\n};\nconst INERT_SORT_CONTEXT: DataGridSortContextValue = { sort: null, requestSort: () => {} };\nconst INERT_ROW_CONTEXT: DataGridRowContextValue = {\n selectionCellProps: undefined,\n hasSelectionCell: true,\n rowId: undefined,\n isSelected: false,\n disabled: false,\n invisible: false,\n ariaLabel: undefined,\n ariaLabelledBy: undefined,\n};\n\nfunction useDataGridContext(component: string): DataGridContextValue {\n const ctx = React.useContext(DataGridContext);\n if (ctx) return ctx;\n reportMissingContext(component, 'DataGrid');\n return INERT_CONTEXT;\n}\n\nfunction useDataGridRowContext(component: string): DataGridRowContextValue {\n const ctx = React.useContext(DataGridRowContext);\n if (ctx) return ctx;\n reportMissingContext(component, 'DataGrid.Row');\n return INERT_ROW_CONTEXT;\n}\n\nfunction useDataGridSortContext(component: string): DataGridSortContextValue {\n const ctx = React.useContext(DataGridSortContext);\n if (ctx) return ctx;\n reportMissingContext(component, 'DataGrid');\n return INERT_SORT_CONTEXT;\n}\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\nconst EMPTY_ITEMS: readonly string[] = [];\n\nfunction toItems(\n keys: ReadonlySet<string> | readonly string[] | undefined,\n): readonly string[] | undefined {\n return keys === undefined ? undefined : Array.from(keys);\n}\n\nfunction sameItems(a: readonly string[], b: readonly string[]): boolean {\n return a.length === b.length && a.every((item, index) => item === b[index]);\n}\n\n/** A child of {@link flattenChildren} under its flattened key (unique across the flattened list). */\nfunction renderFlatChild({ key, node }: { key: string; node: React.ReactNode }): React.ReactNode {\n return <React.Fragment key={key}>{node}</React.Fragment>;\n}\n\n/** A column's id: `columnId`, else the deprecated `id` (warned once). */\nfunction columnIdOf<T>(column: DataGridColumn<T>): string | undefined {\n return resolveDeprecatedProp(\n 'DataGrid',\n column.columnId,\n column.id,\n 'columns[].id',\n 'columns[].columnId',\n );\n}\n\nfunction warnDuplicateRowId(rowId: string): void {\n warnOnce(\n `DataGrid:duplicate-rowId:${rowId}`,\n `DataGrid: several rows share the rowId \"${rowId}\". Row ids must be unique within a ` +\n 'DataGrid; rows with the same rowId are selected and deselected together.',\n );\n}\n\nconst cellBase = 'px-4 py-3 border-b border-border';\n\n/** A body row: its hover and, per `selectionAppearance`, the fill of a selected row. */\nconst BODY_ROW_CLASSES: Record<DataGridSelectionAppearance, string> = {\n brand:\n 'hover:bg-subtle-hover data-[selected]:bg-selected transition-colors motion-reduce:transition-none',\n neutral:\n 'hover:bg-subtle-hover data-[selected]:bg-subtle-selected transition-colors motion-reduce:transition-none',\n none: 'hover:bg-subtle-hover transition-colors motion-reduce:transition-none',\n};\n\n/** Whether `node` is an element of `DataGrid.SelectionCell` (lazy client references too). */\nfunction isSelectionCellElement(\n node: React.ReactNode,\n): node is React.ReactElement<DataGridSelectionCellProps> {\n return getTablePartKind(node) === 'dataGridSelectionCell';\n}\n\n// ---------------------------------------------------------------------------\n// DataGrid\n// ---------------------------------------------------------------------------\n\n// The component-level JSDoc sits on the exported `DataGrid` below.\n//\n// Two call signatures. The first takes only a grid with `items` (`DataGridItemsSortProps`), so an\n// inline `onSortChange={(sort, details) => …}` next to `items` has one contextual type: in the\n// union of the second, `items` cannot tell the members apart while `T` is still being inferred\n// from it. Every other grid, a generic wrapper's `DataGridProps<T>` included, takes the second.\nfunction DataGridRoot<T>(\n props: DataGridBaseProps<T> & DataGridItemsSortProps<T>,\n): React.JSX.Element;\nfunction DataGridRoot<T = unknown>(props: DataGridProps<T>): React.JSX.Element;\nfunction DataGridRoot<T>(props: DataGridProps<T>) {\n const {\n items,\n getRowId,\n sort: sortProp,\n defaultSort,\n sortColumn: sortColumnProp,\n defaultSortColumn,\n sortDirection: sortDirectionProp,\n defaultSortDirection,\n onSortChange,\n selectionMode = 'none',\n selectedItems: selectedItemsProp,\n defaultSelectedItems,\n onSelectedItemsChange,\n selectedKeys,\n defaultSelectedKeys,\n onSelectionChange,\n labels,\n selectOnRowClick = false,\n selectionAppearance = 'brand',\n subtleSelection = false,\n columns,\n containerProps,\n children,\n className,\n onKeyDown,\n onFocus,\n onBlur,\n ref,\n ...rest\n } = props;\n\n // --- sort -----------------------------------------------------------------\n const hasItems = items !== undefined;\n /** The 0.5 sort props, which win over the deprecated ones. */\n const usesSortApi = sortProp !== undefined || defaultSort !== undefined;\n /**\n * The 0.4 rules (the deprecated sort props, the positional callback) apply without `items`,\n * `sort` and `defaultSort`.\n */\n const legacySort = !usesSortApi && !hasItems;\n /** `onSortChange(sort, details)`; sticky, so the form never changes under the consumer. */\n const [objectMode, setObjectMode] = React.useState(!legacySort);\n if (!legacySort && !objectMode) setObjectMode(true);\n const objectCallbacks = objectMode || !legacySort;\n\n const legacySortControlled = sortColumnProp !== undefined || sortDirectionProp !== undefined;\n if (sortColumnProp !== undefined) warnDeprecated('DataGrid', 'sortColumn', 'sort');\n if (sortDirectionProp !== undefined) warnDeprecated('DataGrid', 'sortDirection', 'sort');\n if (defaultSortColumn !== undefined) {\n warnDeprecated('DataGrid', 'defaultSortColumn', 'defaultSort');\n }\n if (defaultSortDirection !== undefined) {\n warnDeprecated('DataGrid', 'defaultSortDirection', 'defaultSort');\n }\n const deprecatedSortProps =\n legacySortControlled || defaultSortColumn !== undefined || defaultSortDirection !== undefined;\n const mixedSortApi = usesSortApi && deprecatedSortProps;\n /** A grid with `items` (and no `sort`/`defaultSort`) ignores the deprecated sort props. */\n const ignoredSortProps = !legacySort && !usesSortApi && deprecatedSortProps;\n\n React.useEffect(() => {\n if (mixedSortApi) {\n warnOnce(\n 'DataGrid:mixed-sort',\n 'DataGrid: do not mix `sort`/`defaultSort` with the deprecated `sortColumn`/`sortDirection`/' +\n '`defaultSortColumn`/`defaultSortDirection`. `sort`/`defaultSort` win.',\n );\n } else if (ignoredSortProps) {\n warnOnce(\n 'DataGrid:items-deprecated-sort',\n 'DataGrid: the deprecated `sortColumn`/`sortDirection`/`defaultSortColumn`/' +\n '`defaultSortDirection` do not apply to a grid with `items` and are ignored. Pass `sort` ' +\n 'or `defaultSort`.',\n );\n }\n }, [mixedSortApi, ignoredSortProps]);\n // 0.4 mixed control: `sortColumn` and `sortDirection` are controlled independently. The half the\n // parent does not control is kept here (seeded from its default) and follows every sort request,\n // as 0.4 did, so repeated clicks still alternate and aria-sort shows what was reported.\n React.useEffect(() => {\n if (!legacySort) return;\n if (sortColumnProp !== undefined && sortDirectionProp === undefined) {\n warnOnce(\n 'DataGrid:sortColumn-without-sortDirection',\n 'DataGrid: `sortColumn` is controlled but `sortDirection` is not (mixed control). The ' +\n 'direction is kept internally and toggles on repeated clicks, as in 0.4. Pass `sort` ' +\n '(`{ columnId, direction }`) to control both.',\n );\n } else if (sortDirectionProp !== undefined && sortColumnProp === undefined) {\n warnOnce(\n 'DataGrid:sortDirection-without-sortColumn',\n 'DataGrid: `sortDirection` is controlled but `sortColumn` is not (mixed control). The ' +\n 'column is kept internally and follows the clicked header, as in 0.4. Pass `sort` ' +\n '(`{ columnId, direction }`) to control both.',\n );\n }\n }, [legacySort, sortColumnProp, sortDirectionProp]);\n\n /** The uncontrolled halves of the 0.4 sort props (used while the other half is controlled). */\n const [legacyHalves, setLegacyHalves] = React.useState<{\n column: string;\n direction: SortDirection;\n }>(() => ({\n column: defaultSortColumn ?? '',\n direction: defaultSortDirection ?? 'ascending',\n }));\n\n const legacyControlledSort = React.useMemo<DataGridSort | null | undefined>(() => {\n if (sortColumnProp === undefined && sortDirectionProp === undefined) return undefined;\n const column = sortColumnProp ?? legacyHalves.column;\n return column === ''\n ? null\n : { columnId: column, direction: sortDirectionProp ?? legacyHalves.direction };\n }, [sortColumnProp, sortDirectionProp, legacyHalves]);\n\n const legacyDefaultSort = React.useMemo<DataGridSort | null>(\n () =>\n defaultSortColumn\n ? { columnId: defaultSortColumn, direction: defaultSortDirection ?? 'ascending' }\n : null,\n [defaultSortColumn, defaultSortDirection],\n );\n\n const controlledSort = legacySort ? legacyControlledSort : sortProp;\n // A grid with `items` and no `defaultSort` starts unsorted: the deprecated defaults are ignored.\n let initialSort = legacyDefaultSort;\n if (defaultSort !== undefined) initialSort = defaultSort;\n else if (ignoredSortProps) initialSort = null;\n\n // The details of the sort being requested, set around the setter: useControllable calls its\n // onChange synchronously inside it, and only on change (the useCheckedValues pattern).\n const sortDetailsRef = React.useRef<DataGridSortChangeDetails | undefined>(undefined);\n\n const emitSortChange = (next: DataGridSort | null) => {\n if (!next) return;\n if (legacySort) {\n setLegacyHalves((previous) =>\n previous.column === next.columnId && previous.direction === next.direction\n ? previous\n : { column: next.columnId, direction: next.direction },\n );\n }\n if (!onSortChange) return;\n if (objectCallbacks) {\n const objectForm = onSortChange as NonNullable<DataGridItemsSortProps['onSortChange']>;\n objectForm(next, sortDetailsRef.current);\n } else {\n const legacy = onSortChange as (columnId: string, direction: SortDirection) => void;\n legacy(next.columnId, next.direction);\n }\n };\n\n const [sort, setSort] = useControllable<DataGridSort | null>(\n controlledSort,\n initialSort,\n emitSortChange,\n );\n\n const requestSort = React.useCallback(\n (columnId: string, event: Event) => {\n sortDetailsRef.current = { event };\n try {\n setSort((previous) => ({\n columnId,\n direction:\n previous?.columnId === columnId && previous.direction === 'ascending'\n ? 'descending'\n : 'ascending',\n }));\n } finally {\n sortDetailsRef.current = undefined;\n }\n },\n [setSort],\n );\n\n const sortContext = React.useMemo<DataGridSortContextValue>(\n () => ({ sort, requestSort }),\n [sort, requestSort],\n );\n\n // --- selection ------------------------------------------------------------\n if (onSelectionChange !== undefined) {\n warnDeprecated('DataGrid', 'onSelectionChange', 'onSelectedItemsChange');\n }\n const legacySelected = React.useMemo(() => toItems(selectedKeys), [selectedKeys]);\n const legacyDefaultSelected = React.useMemo(\n () => toItems(defaultSelectedKeys),\n [defaultSelectedKeys],\n );\n const controlledSelected = resolveDeprecatedProp(\n 'DataGrid',\n selectedItemsProp,\n legacySelected,\n 'selectedKeys',\n 'selectedItems',\n );\n const defaultSelected =\n resolveDeprecatedProp(\n 'DataGrid',\n defaultSelectedItems,\n legacyDefaultSelected,\n 'defaultSelectedKeys',\n 'defaultSelectedItems',\n ) ?? EMPTY_ITEMS;\n\n // The details of the change being made, set around the setter (as `sortDetailsRef`).\n const selectionDetailsRef = React.useRef<DataGridSelectedItemsChangeDetails | undefined>(\n undefined,\n );\n\n const emitSelectionChange = (next: readonly string[]) => {\n onSelectedItemsChange?.([...next], selectionDetailsRef.current);\n onSelectionChange?.(new Set(next));\n };\n\n const [selected, setSelectedValue] = useControllable<readonly string[]>(\n controlledSelected,\n defaultSelected,\n emitSelectionChange,\n );\n\n const setSelected = React.useCallback(\n (event: Event, update: (previous: readonly string[]) => readonly string[]) => {\n selectionDetailsRef.current = { event };\n try {\n setSelectedValue(update);\n } finally {\n selectionDetailsRef.current = undefined;\n }\n },\n [setSelectedValue],\n );\n\n const single = selectionMode === 'single';\n const [store] = React.useState(() => createSelectionStore(selected, single));\n React.useLayoutEffect(() => {\n store.setSelected(selected);\n }, [store, selected]);\n React.useLayoutEffect(() => {\n store.setSingleMode(single);\n }, [store, single]);\n\n const toggleRow = React.useCallback(\n (rowId: string, event: Event) => {\n setSelected(event, (previous) => {\n const effective = store.prune(previous);\n let next: string[];\n if (single) {\n // Single mode shows the first selected row that is rendered (see the store).\n next = effective[0] === rowId ? [] : [rowId];\n } else {\n next = effective.includes(rowId)\n ? effective.filter((item) => item !== rowId)\n : [...effective, rowId];\n }\n return sameItems(next, previous) ? previous : next;\n });\n },\n [single, setSelected, store],\n );\n\n const selectedCount = selected.length;\n React.useEffect(() => {\n if (single && selectedCount > 1) {\n warnOnce(\n 'DataGrid:single-several-selected',\n `DataGrid: a single-selection grid (selectionMode \"single\") has ${selectedCount} selected row ids; only the first one that is rendered is selected. Pass at most one id in \\`selectedItems\\`/\\`defaultSelectedItems\\`, or use selectionMode=\"multiple\".`,\n );\n }\n }, [single, selectedCount]);\n\n // Rows whose selection is disabled keep their state: select-all selects (or clears) the others.\n const toggleAll = React.useCallback(\n (event: Event) => {\n setSelected(event, (previous) => {\n const effective = new Set(store.prune(previous));\n const all = store.getRegistered();\n const enabled = all.filter((rowId) => !store.isDisabled(rowId));\n const allSelected = enabled.length > 0 && enabled.every((rowId) => effective.has(rowId));\n const next = allSelected\n ? all.filter((rowId) => store.isDisabled(rowId) && effective.has(rowId))\n : all.filter((rowId) => !store.isDisabled(rowId) || effective.has(rowId));\n return sameItems(next, previous) ? previous : next;\n });\n },\n [setSelected, store],\n );\n\n const radioName = useId('wave-datagrid-selection');\n const selectAllLabel = labels?.selectAll ?? DEFAULT_SELECT_ALL_LABEL;\n const selectionHeaderLabel = labels?.selectionHeader ?? DEFAULT_SELECTION_HEADER_LABEL;\n\n const context = React.useMemo<DataGridContextValue>(\n () => ({\n selectionMode,\n store,\n toggleRow,\n toggleAll,\n radioName,\n selectAllLabel,\n selectionHeaderLabel,\n selectOnRowClick,\n selectionAppearance,\n subtleSelection,\n }),\n [\n selectionMode,\n store,\n toggleRow,\n toggleAll,\n radioName,\n selectAllLabel,\n selectionHeaderLabel,\n selectOnRowClick,\n selectionAppearance,\n subtleSelection,\n ],\n );\n\n // --- keyboard -------------------------------------------------------------\n const { gridRef, gridProps } = useGridNavigation();\n const mergedRef = useMergedRefs<HTMLTableElement>(ref, gridRef);\n\n // --- items ------------------------------------------------------------------\n const itemRows = React.useMemo<readonly DataGridItemRowData[] | null>(() => {\n if (items === undefined) return null;\n const keys = new Set<string>();\n return items.map((item, index) => {\n const rowId = getRowId ? getRowId(item) : String(index);\n // A repeated id (the selection store warns about it) still gets a key of its own.\n const key = keys.has(rowId) ? `${rowId}\\u0000${index}` : rowId;\n keys.add(key);\n return { item, index, rowId, key };\n });\n }, [items, getRowId]);\n\n // Built-in sorting: by the `compare` of the sorted column (controlled `sort` included).\n const sortColumnId = sort?.columnId;\n const sortDirection = sort?.direction;\n const sortCompare = React.useMemo(() => {\n if (!hasItems || sortColumnId === undefined || !columns) return undefined;\n return columns.find((column) => columnIdOf(column) === sortColumnId)?.compare;\n }, [hasItems, sortColumnId, columns]);\n\n const sortedRows = React.useMemo(() => {\n if (itemRows === null || !sortCompare) return itemRows;\n // The rows hold the items as `unknown`; `compare` takes the grid's `T`.\n const compare = sortCompare as (a: unknown, b: unknown) => number;\n // A stable sort of a copy (never in place, never reversed): items that compare equal keep\n // their order in `items` in both directions, since descending negates `compare`.\n return itemRows\n .slice()\n .sort(\n sortDirection === 'descending'\n ? (a, b) => -compare(a.item, b.item)\n : (a, b) => compare(a.item, b.item),\n );\n }, [itemRows, sortCompare, sortDirection]);\n\n // Built only with `items`: the column ids are read (and the deprecated `id` warned) when used.\n const renderColumnsRow = React.useMemo<DataGridRenderRow | null>(() => {\n if (!columns || !hasItems) return null;\n const cellKeys = columns.map((column, index) => columnIdOf(column) ?? index);\n return (item) => (\n <DataGridRow>\n {columns.map((column, index) => (\n <DataGridCell key={cellKeys[index]}>{column.renderCell?.(item as T)}</DataGridCell>\n ))}\n </DataGridRow>\n );\n }, [columns, hasItems]);\n\n const itemsContext = React.useMemo<DataGridItemsContextValue>(\n () => ({ rows: sortedRows, renderColumnsRow }),\n [sortedRows, renderColumnsRow],\n );\n\n const columnWithoutId =\n columns?.some((column) => column.columnId === undefined && column.id === undefined) ?? false;\n React.useEffect(() => {\n if (columnWithoutId) {\n warnOnce(\n 'DataGrid:column-without-columnId',\n 'DataGrid: a column in `columns` has no `columnId` (nor the deprecated `id`), so its ' +\n 'header cannot sort. Give every column a unique `columnId`.',\n );\n }\n }, [columnWithoutId]);\n\n // --- header and body from columns -------------------------------------------\n let content: React.ReactNode = children;\n const flatChildren = columns ? flattenChildren(children) : [];\n const hasChild = (part: unknown) => flatChildren.some(({ node }) => isElementOfType(node, part));\n const generatedHeader =\n columns && !hasChild(DataGridHeader) ? (\n <DataGridHeader key=\"wave-generated-header\">\n <tr>\n {columns.map((column, index) => {\n const columnId = columnIdOf(column);\n return (\n <DataGridHeaderCell\n key={columnId ?? index}\n columnId={columnId}\n sortable={column.sortable ?? column.compare !== undefined}\n >\n {column.renderHeaderCell ? column.renderHeaderCell() : column.label}\n </DataGridHeaderCell>\n );\n })}\n </tr>\n </DataGridHeader>\n ) : null;\n // Without children, the body renders the rows from `columns` (see DataGrid.Body).\n const generatedBody =\n columns && hasItems && !hasChild(DataGridBody) ? (\n <DataGridBody key=\"wave-generated-body\" />\n ) : null;\n if (generatedHeader || generatedBody) {\n // A `<caption>` stays the table's first child, before the generated header; a generated body\n // goes before a `<tfoot>`, which ends the table.\n const isCaption = ({ node }: { node: React.ReactNode }) => isElementOfType(node, 'caption');\n const others = flatChildren.filter((child) => !isCaption(child));\n const footerIndex = generatedBody\n ? others.findIndex(({ node }) => isElementOfType(node, 'tfoot'))\n : -1;\n const bodyIndex = footerIndex >= 0 ? footerIndex : others.length;\n content = [\n ...flatChildren.filter(isCaption).map(renderFlatChild),\n generatedHeader,\n ...others.slice(0, bodyIndex).map(renderFlatChild),\n generatedBody,\n ...others.slice(bodyIndex).map(renderFlatChild),\n ];\n }\n\n const {\n className: containerClassName,\n 'aria-label': containerLabel,\n 'aria-labelledby': containerLabelledBy,\n ...containerRest\n } = containerProps ?? {};\n // The wrapper has no role of its own, and a name is prohibited on a role-less `<div>`: the\n // consumer's name is kept only together with a role.\n const containerHasRole = containerRest.role !== undefined;\n const droppedContainerName =\n !containerHasRole && (containerLabel !== undefined || containerLabelledBy !== undefined);\n\n React.useEffect(() => {\n if (droppedContainerName) {\n warnOnce(\n 'DataGrid:container-name-without-role',\n 'DataGrid: `containerProps[\"aria-label\"]`/`[\"aria-labelledby\"]` is ignored because the ' +\n 'wrapper has no role. Name the grid itself (`aria-label` on DataGrid), or pass a ' +\n '`role` (e.g. \"region\") in `containerProps` too.',\n );\n }\n }, [droppedContainerName]);\n\n return (\n <DataGridContext.Provider value={context}>\n <DataGridSortContext.Provider value={sortContext}>\n <DataGridItemsContext.Provider value={itemsContext}>\n {/* Reset for a grid nested in a cell: its rows are not the outer row. */}\n <DataGridRowContext.Provider value={null}>\n <DataGridRowIdContext.Provider value={null}>\n <div\n {...containerRest}\n aria-label={containerHasRole ? containerLabel : undefined}\n aria-labelledby={containerHasRole ? containerLabelledBy : undefined}\n className={cn(\n dataGridClassNames.container,\n 'overflow-x-auto rounded-md border border-border',\n containerClassName,\n )}\n >\n <table\n ref={mergedRef}\n role=\"grid\"\n aria-multiselectable={selectionMode === 'multiple' || undefined}\n data-selection-appearance={selectionAppearance}\n data-subtle-selection={subtleSelection ? '' : undefined}\n className={cn(\n dataGridClassNames.root,\n 'w-full border-separate border-spacing-0',\n // The group whose hover or focus draws the subtle select-all checkbox.\n subtleSelection && 'group/grid',\n className,\n )}\n {...rest}\n onKeyDown={composeEventHandlers(onKeyDown, gridProps.onKeyDown)}\n onFocus={composeEventHandlers(onFocus, gridProps.onFocus, {\n checkDefaultPrevented: false,\n })}\n onBlur={composeEventHandlers(onBlur, gridProps.onBlur, {\n checkDefaultPrevented: false,\n })}\n >\n {content}\n </table>\n </div>\n </DataGridRowIdContext.Provider>\n </DataGridRowContext.Provider>\n </DataGridItemsContext.Provider>\n </DataGridSortContext.Provider>\n </DataGridContext.Provider>\n );\n}\nDataGridRoot.displayName = 'DataGrid';\n\n// ---------------------------------------------------------------------------\n// Selection header cell (internal)\n// ---------------------------------------------------------------------------\n\n/**\n * The props of a header row's selection cell: the row's `selectionCellProps`, merged with a\n * `DataGrid.SelectionCell`'s own (whose `ref` is passed as `cellRef`).\n */\ntype HeaderSelectionCellProps = Omit<DataGridSelectionCellProps, 'ref'>;\n\ninterface DataGridSelectionHeaderCellProps {\n selectionMode: SelectionMode;\n /** The root class of `DataGrid.SelectionCell`, when the cell is one. */\n stableClassName?: string;\n cellProps?: HeaderSelectionCellProps;\n ref?: React.Ref<HTMLTableCellElement>;\n}\n\nfunction DataGridSelectionHeaderCell({\n selectionMode,\n stableClassName,\n cellProps,\n ref,\n}: DataGridSelectionHeaderCellProps) {\n const { store, toggleAll, selectAllLabel, selectionHeaderLabel, subtleSelection } =\n useDataGridContext('DataGrid.Header');\n const state = React.useSyncExternalStore(\n store.subscribeSelectAll,\n store.getSelectAllState,\n store.getSelectAllState,\n );\n const {\n className,\n disabled,\n invisible,\n controlRef,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n ...rest\n } = cellProps ?? {};\n\n let checked: boolean | 'mixed' = false;\n if (state === 'all') checked = true;\n else if (state === 'some') checked = 'mixed';\n\n return (\n <th\n scope=\"col\"\n {...rest}\n ref={ref}\n data-selection-cell=\"\"\n className={cn(\n stableClassName,\n dataGridHeaderClassNames.selectionCell,\n SELECTION_CELL_CLASSES,\n 'text-start',\n focusRingInset,\n className,\n )}\n >\n {selectionMode === 'multiple' ? (\n <TableSelectionControl\n ref={controlRef}\n type=\"checkbox\"\n aria-label={ariaLabel ?? (ariaLabelledBy === undefined ? selectAllLabel : undefined)}\n aria-labelledby={ariaLabelledBy}\n aria-describedby={ariaDescribedBy}\n checked={checked}\n disabled={disabled}\n invisible={invisible}\n subtle={subtleSelection}\n reveal=\"grid\"\n onChange={(event) => toggleAll(event.nativeEvent)}\n className={dataGridHeaderClassNames.selectAllCheckbox}\n />\n ) : (\n <span className=\"sr-only\">{selectionHeaderLabel}</span>\n )}\n </th>\n );\n}\n\nconst INERT_HEADER_SLOTS: HeaderSlotRegistry = {\n subscribe: () => () => {},\n register: () => () => {},\n getFirst: () => null,\n refresh: () => {},\n};\n\n/**\n * The selection column's cell of one header row: the select-all header cell in the header's first\n * row (document order), an empty cell in every later row. `initialFirst` is the header's guess from\n * its children, used until the slots are registered (the initial and the server render).\n */\nfunction DataGridSelectionHeaderSlot({\n selectionMode,\n initialFirst,\n stableClassName,\n cellProps,\n ref,\n}: DataGridSelectionHeaderCellProps & { initialFirst: boolean }) {\n const slots = React.useContext(DataGridHeaderSlotsContext) ?? INERT_HEADER_SLOTS;\n const [slot] = React.useState(() => ({}));\n const cellRef = React.useRef<HTMLTableCellElement | null>(null);\n const mergedRef = useMergedRefs<HTMLTableCellElement>(cellRef, ref);\n\n const getIsFirst = React.useCallback(() => {\n const first = slots.getFirst();\n return first === null ? initialFirst : first === slot;\n }, [slots, slot, initialFirst]);\n const getServerIsFirst = React.useCallback(() => initialFirst, [initialFirst]);\n const isFirst = React.useSyncExternalStore(slots.subscribe, getIsFirst, getServerIsFirst);\n\n React.useLayoutEffect(() => slots.register(slot, () => cellRef.current), [slots, slot]);\n\n if (isFirst) {\n return (\n <DataGridSelectionHeaderCell\n ref={mergedRef}\n selectionMode={selectionMode}\n stableClassName={stableClassName}\n cellProps={cellProps}\n />\n );\n }\n // A later header row's cell: none of the control's props apply.\n const {\n className,\n disabled: _disabled,\n invisible: _invisible,\n controlRef: _controlRef,\n 'aria-label': _ariaLabel,\n 'aria-labelledby': _ariaLabelledBy,\n 'aria-describedby': _ariaDescribedBy,\n ...rest\n } = cellProps ?? {};\n return (\n <td\n {...rest}\n ref={mergedRef}\n data-selection-cell=\"\"\n className={cn(\n stableClassName,\n dataGridHeaderClassNames.selectionCell,\n SELECTION_CELL_CLASSES,\n focusRingInset,\n className,\n )}\n />\n );\n}\n\n// ---------------------------------------------------------------------------\n// Sub-components\n// ---------------------------------------------------------------------------\n\n/**\n * Prepends the selection column's header slot (or `null`) to every `<tr>` in `children`, looking\n * inside Fragments, unless the row holds a `DataGrid.SelectionCell` (that cell is the slot), and\n * tells every row whether it is the header's first row: the cells of a `<tr>` and every other\n * element child (a `DataGrid.Row`, or a component that renders one). Every row gets the same child\n * shape in every selection mode, so switching `selectionMode` does not remount the header cells.\n */\nfunction withSelectionHeaderSlots(\n children: React.ReactNode,\n selectionMode: 'none' | SelectionMode,\n): React.ReactNode {\n let first = true;\n const visit = (nodes: React.ReactNode): React.ReactNode =>\n React.Children.map(nodes, (child) => {\n if (isElementOfType<{ children?: React.ReactNode }>(child, React.Fragment)) {\n return React.cloneElement(child, undefined, visit(child.props.children));\n }\n if (!React.isValidElement(child)) return child;\n const isFirst = first;\n first = false;\n if (isElementOfType<{ children?: React.ReactNode }>(child, 'tr')) {\n const cells = child.props.children;\n const slot =\n selectionMode === 'none' ||\n flattenChildren(cells).some(({ node }) => isSelectionCellElement(node)) ? null : (\n <DataGridSelectionHeaderSlot selectionMode={selectionMode} initialFirst={isFirst} />\n );\n return React.cloneElement(\n child,\n undefined,\n slot,\n <DataGridHeaderRowHintContext.Provider value={isFirst}>\n {cells}\n </DataGridHeaderRowHintContext.Provider>,\n );\n }\n return (\n <DataGridHeaderRowHintContext.Provider value={isFirst}>\n {child}\n </DataGridHeaderRowHintContext.Provider>\n );\n });\n return visit(children);\n}\n\n/**\n * The grid's `<thead>`. When the grid is selectable, it prepends the selection column's header\n * cell to each `<tr>` child, also inside a Fragment, unless the row holds a\n * `DataGrid.SelectionCell`: the first header row gets the \"Select all rows\" checkbox (multiple\n * mode) or the \"Selection\" header (single mode; DataGrid's `labels` localizes both), later rows of\n * a grouped header an empty cell. A header row rendered by another component cannot get it (a\n * development warning says so): use `DataGrid.Row` for such a row, which adds the cell itself.\n */\nconst DataGridHeader = ({ children, className, ref, ...rest }: DataGridHeaderProps) => {\n const { selectionMode } = useDataGridContext('DataGrid.Header');\n const [thead, setThead] = React.useState<HTMLTableSectionElement | null>(null);\n const mergedRef = useMergedRefs<HTMLTableSectionElement>(ref, setThead);\n const [slots] = React.useState(createHeaderSlotRegistry);\n const content = withSelectionHeaderSlots(children, selectionMode);\n\n // Every commit, after the rows' slots registered: header rows can move without a slot mounting.\n React.useLayoutEffect(() => {\n slots.refresh();\n });\n\n // Every commit: header rows can come from components the header cannot see into.\n React.useEffect(() => {\n if (!isDev || !thead || selectionMode === 'none') return;\n const selectionCells = Array.from(thead.rows, (row) =>\n Array.from(row.cells).filter((cell) => cell.hasAttribute('data-selection-cell')),\n );\n if (\n selectionCells.some(\n (cells, index) => cells.length === 0 && thead.rows[index].cells.length > 0,\n )\n ) {\n warnOnce(\n 'DataGrid.Header:missing-selection-cell',\n 'DataGrid.Header: a header row has no selection column header cell, so the header has one ' +\n 'column fewer than the selectable rows. Render header rows as `<tr>` children of ' +\n 'DataGrid.Header (a Fragment is fine), or use `DataGrid.Row` for a header row that ' +\n 'another component renders.',\n );\n }\n if (selectionCells.some((cells) => cells.length > 1)) {\n warnOnce(\n 'DataGrid.Header:several-selection-cells',\n 'DataGrid.Header: a header row has more than one selection cell. A DataGrid.SelectionCell ' +\n 'rendered by another component is not seen, so the row also gets the automatic cell: ' +\n 'render DataGrid.SelectionCell as a child of the row (a Fragment is fine).',\n );\n }\n });\n\n return (\n <DataGridSectionContext.Provider value=\"header\">\n <DataGridHeaderSlotsContext.Provider value={slots}>\n <thead\n ref={mergedRef}\n className={cn(dataGridHeaderClassNames.root, 'bg-card', className)}\n {...rest}\n >\n {content}\n </thead>\n </DataGridHeaderSlotsContext.Provider>\n </DataGridSectionContext.Provider>\n );\n};\nDataGridHeader.displayName = 'DataGridHeader';\n\n/**\n * A column header cell. A `sortable` header (with a `columnId`) renders its content inside a\n * `<button type=\"button\">` that toggles the sort, followed by the direction glyph (`sortIcon`)\n * while its column is sorted; the `<th>` carries `aria-sort`. A consumer `onClick` (on the `<th>`)\n * runs before the sort, and calling `preventDefault()` in it cancels the sort (also for\n * Enter/Space on the button, which click it).\n */\nconst DataGridHeaderCell = ({\n columnId,\n sortable = false,\n sortIcon,\n children,\n className,\n onClick,\n ref,\n ...rest\n}: DataGridHeaderCellProps) => {\n const { sort, requestSort } = useDataGridSortContext('DataGrid.HeaderCell');\n /** The column this header sorts, or `undefined` when it is not sortable. */\n const sortColumnId = sortable && columnId ? columnId : undefined;\n const sortedDirection =\n sortColumnId !== undefined && sort?.columnId === sortColumnId ? sort.direction : null;\n\n // The sort runs from the `<th>` once the button's click bubbled up to it, composed after the\n // consumer's `onClick` (C-COMPOSE): the consumer runs first and can cancel with preventDefault().\n // The sort button is the `<th>`'s only child; clicks elsewhere in the cell do not sort.\n const sortOnButtonClick = (event: React.MouseEvent<HTMLTableCellElement>) => {\n const button = event.currentTarget.firstElementChild;\n if (\n sortColumnId !== undefined &&\n button?.localName === 'button' &&\n button.contains(event.target as Node)\n ) {\n requestSort(sortColumnId, event.nativeEvent);\n }\n };\n\n React.useEffect(() => {\n if (sortable && !columnId) {\n warnOnce(\n 'DataGrid.HeaderCell:sortable-without-columnId',\n 'DataGrid.HeaderCell: `sortable` needs a `columnId`; the header is rendered as not sortable.',\n );\n }\n }, [sortable, columnId]);\n\n return (\n <th\n ref={ref}\n scope=\"col\"\n aria-sort={sortColumnId !== undefined ? (sortedDirection ?? 'none') : undefined}\n className={cn(\n dataGridHeaderCellClassNames.root,\n cellBase,\n 'text-start align-middle font-semibold text-caption-1 uppercase tracking-wider',\n focusRingInset,\n sortColumnId !== undefined && 'p-0 hover:bg-subtle-hover',\n className,\n )}\n {...rest}\n onClick={\n sortColumnId !== undefined ? composeEventHandlers(onClick, sortOnButtonClick) : onClick\n }\n >\n {sortColumnId !== undefined ? (\n <TableSortButton\n component=\"DataGrid.HeaderCell\"\n direction={sortedDirection}\n sortIcon={sortIcon}\n className={dataGridHeaderCellClassNames.button}\n iconClassName={dataGridHeaderCellClassNames.sortIcon}\n >\n {children}\n </TableSortButton>\n ) : (\n <span className=\"inline-flex items-center gap-1\">{children}</span>\n )}\n </th>\n );\n};\nDataGridHeaderCell.displayName = 'DataGridHeaderCell';\n\n/**\n * The row of one item of `items`, under its row id. Memoised, so a grid that renders again (a\n * sort, a parent update) renders the row again only when its item, its index or the render\n * function change.\n */\nconst DataGridItemRow = React.memo(function DataGridItemRow({\n item,\n index,\n rowId,\n render,\n}: {\n item: unknown;\n index: number;\n rowId: string;\n render: DataGridRenderRow;\n}) {\n return (\n <DataGridRowIdContext.Provider value={rowId}>\n {render(item, index)}\n </DataGridRowIdContext.Provider>\n );\n});\n\n/**\n * The grid's `<tbody>`. Its child can also be a render function, called with each item of the\n * grid's `items` (and its index there) to render the item's row; without children, a grid with\n * `items` and `columns` renders the rows from the columns.\n */\nconst DataGridBody = <T,>({ children, className, ref, ...rest }: DataGridBodyProps<T>) => {\n const itemsContext = React.useContext(DataGridItemsContext);\n const rows = itemsContext?.rows ?? null;\n const hasRenderFunction = typeof children === 'function';\n\n const renderWithoutItems = hasRenderFunction && rows === null;\n React.useEffect(() => {\n if (renderWithoutItems) {\n warnOnce(\n 'DataGrid.Body:render-without-items',\n \"DataGrid.Body: a render function child renders one row per item of the DataGrid's \" +\n '`items`, which is not set, so the body has no rows.',\n );\n }\n }, [renderWithoutItems]);\n\n const renderRows = (render: DataGridRenderRow | null) =>\n render &&\n rows?.map((row) => (\n <DataGridItemRow\n key={row.key}\n item={row.item}\n index={row.index}\n rowId={row.rowId}\n render={render}\n />\n ));\n\n let content: React.ReactNode;\n if (typeof children === 'function') {\n // The items are the grid's `T`, which the body cannot see: its own `T` types the function.\n content = renderRows(children as DataGridRenderRow);\n } else if (children === undefined) {\n content = renderRows(itemsContext?.renderColumnsRow ?? null);\n } else {\n content = children;\n }\n\n return (\n <DataGridSectionContext.Provider value=\"body\">\n <tbody ref={ref} className={cn(dataGridBodyClassNames.root, className)} {...rest}>\n {content}\n </tbody>\n </DataGridSectionContext.Provider>\n );\n};\nDataGridBody.displayName = 'DataGridBody';\n\n/**\n * A grid row. In a selectable grid it starts with a selection cell (checkbox or radio) named\n * after the row's first cell (or `selectionLabel`), unless a `DataGrid.SelectionCell` child is\n * its selection cell; Space on one of its cells toggles the row, and so does a click on the row\n * with the grid's `selectOnRowClick`.\n *\n * The row is the `group/table-row` group whose hover or focus draws a subtle selection control\n * (`subtleSelection`) and the `Table.CellActions` of its cells. A group is matched by any\n * ancestor, so the rows of a grid nested in a cell\n * share it: hovering the outer row also draws the subtle controls of the nested grid (a limit of\n * CSS groups). A Tree in a cell keeps its own rows' group.\n */\nconst DataGridRow = ({\n rowId: rowIdProp,\n selectionLabel,\n selectionCellProps,\n children,\n className,\n onClick,\n onKeyDown,\n ref,\n ...rest\n}: DataGridRowProps) => {\n const { selectionMode, store, toggleRow, selectOnRowClick, selectionAppearance } =\n useDataGridContext('DataGrid.Row');\n // A row rendered for an item of `items` defaults to the item's row id.\n const itemRowId = React.useContext(DataGridRowIdContext);\n const rowId = rowIdProp ?? itemRowId ?? undefined;\n const section = React.useContext(DataGridSectionContext);\n const firstHeaderRowHint = React.useContext(DataGridHeaderRowHintContext);\n const inHeader = section === 'header';\n const selectable = selectionMode !== 'none' && !inHeader;\n const labelId = useId('wave-datagrid-row-label');\n\n // The children are always flattened (Fragments too) and rendered under their flattened keys,\n // whatever the mode, so the keys stay the same when `selectionMode`, `selectionLabel` or `rowId`\n // change and the cells are not remounted.\n const flatChildren = flattenChildren(children);\n // A DataGrid.SelectionCell child is the row's selection cell; its own props win.\n let ownCellProps: DataGridSelectionCellProps | undefined;\n for (const { node } of flatChildren) {\n if (isSelectionCellElement(node)) {\n ownCellProps = node.props;\n break;\n }\n }\n const hasSelectionCell = ownCellProps !== undefined;\n const selectionDisabled = ownCellProps?.disabled ?? selectionCellProps?.disabled ?? false;\n const selectionInvisible = ownCellProps?.invisible ?? selectionCellProps?.invisible ?? false;\n const ownLabelledBy = ownCellProps?.['aria-labelledby'];\n const ownLabel =\n ownCellProps?.['aria-label'] ?? selectionCellProps?.['aria-label'] ?? selectionLabel;\n\n const single = selectionMode === 'single';\n const getSelected = React.useCallback(\n () => rowId !== undefined && store.isSelected(rowId, single),\n [rowId, store, single],\n );\n // Notified only when the selection changes (in multiple mode, rows registering notify no row).\n const isSelected = React.useSyncExternalStore(store.subscribe, getSelected, getSelected);\n\n React.useLayoutEffect(() => {\n if (rowId === undefined || inHeader) return;\n const unregister = store.register(rowId);\n if (isDev && store.countRegistrations(rowId) > 1) warnDuplicateRowId(rowId);\n return unregister;\n }, [store, rowId, inHeader]);\n\n // A row whose selection is disabled is left out of select-all.\n React.useLayoutEffect(() => {\n if (rowId === undefined || inHeader || !selectionDisabled) return;\n return store.disable(rowId);\n }, [store, rowId, inHeader, selectionDisabled]);\n\n React.useEffect(() => {\n if (selectable && rowId === undefined) {\n warnOnce(\n 'DataGrid.Row:missing-rowId',\n 'DataGrid.Row: a selectable grid needs a `rowId` on every row; this row has no selection control.',\n );\n }\n }, [selectable, rowId]);\n\n const unlabelled =\n selectable && rowId !== undefined && ownLabel === undefined && ownLabelledBy === undefined;\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLTableRowElement>) => {\n if (!selectable || rowId === undefined || event.key !== ' ') return;\n const target = event.target as Element;\n // Only keys pressed on the row itself or on one of its own cells, never on a nested widget.\n if (target !== event.currentTarget && target.parentElement !== event.currentTarget) return;\n // A row whose selection is disabled takes the key too (no page scroll), and stays as it is.\n event.preventDefault();\n if (!selectionDisabled) toggleRow(rowId, event.nativeEvent);\n };\n\n const handleClick = (event: React.MouseEvent<HTMLTableRowElement>) => {\n if (!selectOnRowClick || !selectable || rowId === undefined || selectionDisabled) return;\n const row = event.currentTarget;\n // The row's own cells carry the grid's tabindex; they are not widgets nested in the row.\n const nested = isForeignEvent(event, { isOwnPart: (element) => element.parentElement === row });\n if (nested || endsTextSelection(event)) return;\n toggleRow(rowId, event.nativeEvent);\n };\n\n // Name the selection control after the first cell (its own id, or a generated one).\n let labelledBy: string | undefined;\n let idCellIndex = -1;\n if (unlabelled) {\n const firstCellIndex = flatChildren.findIndex(({ node }) =>\n isElementOfType(node, DataGridCell, 'td', 'th'),\n );\n if (firstCellIndex >= 0) {\n const firstCell = flatChildren[firstCellIndex].node as React.ReactElement<{ id?: string }>;\n labelledBy = firstCell.props.id ?? labelId;\n if (firstCell.props.id === undefined) idCellIndex = firstCellIndex;\n }\n }\n const content = flatChildren.map(({ key, node }, index) =>\n renderFlatChild({\n key,\n node:\n index === idCellIndex\n ? React.cloneElement(node as React.ReactElement<{ id?: string }>, { id: labelId })\n : node,\n }),\n );\n\n const needsLabel = unlabelled && labelledBy === undefined;\n React.useEffect(() => {\n if (needsLabel) {\n warnOnce(\n 'DataGrid.Row:selection-label',\n 'DataGrid.Row: no child is a `DataGrid.Cell`, `<td>` or `<th>` element, so the row selection control is named \"Select row\". Pass `selectionLabel` (a cell rendered by another component is not seen).',\n );\n }\n }, [needsLabel]);\n\n // The selection control's name: the cell's own, else the row's first cell, else \"Select row\".\n const controlLabelledBy = ownLabelledBy ?? labelledBy;\n const controlLabel = ownLabel ?? (controlLabelledBy === undefined ? 'Select row' : undefined);\n\n const rowContext = React.useMemo<DataGridRowContextValue>(\n () => ({\n selectionCellProps,\n hasSelectionCell,\n rowId: selectable ? rowId : undefined,\n isSelected,\n disabled: selectionDisabled,\n invisible: selectionInvisible,\n ariaLabel: controlLabel,\n ariaLabelledBy: controlLabelledBy,\n }),\n [\n selectionCellProps,\n hasSelectionCell,\n selectable,\n rowId,\n isSelected,\n selectionDisabled,\n selectionInvisible,\n controlLabel,\n controlLabelledBy,\n ],\n );\n\n // The automatic selection cell, first; a DataGrid.SelectionCell child renders it where it stands.\n let selectionCellElement: React.ReactNode = null;\n if (!hasSelectionCell && inHeader && selectionMode !== 'none') {\n selectionCellElement = (\n <DataGridSelectionHeaderSlot\n selectionMode={selectionMode}\n initialFirst={firstHeaderRowHint}\n cellProps={selectionCellProps}\n />\n );\n } else if (!hasSelectionCell && selectable) {\n selectionCellElement = <DataGridBodySelectionCell component=\"DataGrid.Row\" />;\n }\n\n return (\n <DataGridRowContext.Provider value={rowContext}>\n <tr\n ref={ref}\n className={cn(\n dataGridRowClassNames.root,\n // The group whose hover or focus draws a subtle selection control (its own name: a\n // Tree in a cell keys its actions on its rows' `group/row`).\n 'group/table-row',\n !inHeader && BODY_ROW_CLASSES[selectionAppearance],\n selectable && isSelected && forcedColors.selectedContainer,\n className,\n )}\n aria-selected={selectable ? isSelected : undefined}\n data-selected={selectable && isSelected ? '' : undefined}\n {...rest}\n onClick={composeEventHandlers(onClick, handleClick)}\n onKeyDown={composeEventHandlers(onKeyDown, handleKeyDown)}\n >\n {selectionCellElement}\n {content}\n </tr>\n </DataGridRowContext.Provider>\n );\n};\nDataGridRow.displayName = 'DataGridRow';\n\n/** Props of {@link DataGridBodySelectionCell}: the cell's own, without what the row resolved. */\ninterface DataGridBodySelectionCellProps extends Omit<\n DataGridSelectionCellProps,\n 'disabled' | 'invisible' | 'aria-label' | 'aria-labelledby'\n> {\n /** The public name of the part that renders the cell, for the context errors. */\n component: string;\n /** The root class of `DataGrid.SelectionCell`, when the cell is one. */\n stableClassName?: string;\n}\n\n/**\n * The selection cell of a body row (internal): the row's checkbox (multiple mode) or radio (single\n * mode), the automatic first cell or a `DataGrid.SelectionCell`. Its state, `disabled`,\n * `invisible` and name come from the row.\n */\nfunction DataGridBodySelectionCell({\n component,\n stableClassName,\n className,\n controlRef,\n 'aria-describedby': ariaDescribedBy,\n ref,\n ...rest\n}: DataGridBodySelectionCellProps) {\n const { selectionMode, toggleRow, radioName, subtleSelection } = useDataGridContext(component);\n const row = useDataGridRowContext(component);\n const { rowId } = row;\n const single = selectionMode === 'single';\n return (\n <td\n role=\"gridcell\"\n {...rest}\n ref={ref}\n data-selection-cell=\"\"\n className={cn(\n stableClassName,\n dataGridRowClassNames.selectionCell,\n SELECTION_CELL_CLASSES,\n focusRingInset,\n row.selectionCellProps?.className,\n className,\n )}\n >\n {rowId !== undefined && selectionMode !== 'none' && (\n <TableSelectionControl\n ref={controlRef}\n type={single ? 'radio' : 'checkbox'}\n name={single ? radioName : undefined}\n // The shared name groups the radios. `form=\"\"` matches no form, so they have no form\n // owner (still one group: same name, both ownerless) and never add a generated field\n // to an enclosing form's submission.\n form={single ? '' : undefined}\n checked={row.isSelected}\n disabled={row.disabled}\n invisible={row.invisible}\n subtle={subtleSelection}\n onChange={(event) => toggleRow(rowId, event.nativeEvent)}\n aria-label={row.ariaLabel}\n aria-labelledby={row.ariaLabelledBy}\n aria-describedby={ariaDescribedBy}\n className={dataGridRowClassNames.selectionControl}\n />\n )}\n </td>\n );\n}\n\n/**\n * The selection cell of a row, rendered where it stands among the row's cells (the row and the\n * header then add none of their own). In a header row it is the select-all checkbox (multiple\n * mode; the \"Selection\" header text in single mode), the first header row's only, as the\n * automatic cell; in a body row (a `DataGrid.Row`) the row's checkbox or radio. It takes the\n * selection cell props of its row (`selectionCellProps`), its own winning. `aria-label`,\n * `aria-labelledby` and `aria-describedby` go to the control; the other props, `className` and\n * `ref` to the cell. In a grid without selection it renders nothing (with a development warning).\n */\nconst DataGridSelectionCell = ({\n disabled,\n invisible,\n className,\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n controlRef,\n ref,\n ...rest\n}: DataGridSelectionCellProps) => {\n const { selectionMode } = useDataGridContext('DataGrid.SelectionCell');\n const section = React.useContext(DataGridSectionContext);\n const firstHeaderRowHint = React.useContext(DataGridHeaderRowHintContext);\n const row = React.useContext(DataGridRowContext);\n const notSelectable = selectionMode === 'none';\n // A DataGrid.Row that did not see this cell among its children added its own cell too.\n const unseen = !notSelectable && row !== null && !row.hasSelectionCell;\n\n React.useEffect(() => {\n if (notSelectable) {\n warnOnce(\n 'DataGrid.SelectionCell:not-selectable',\n 'DataGrid.SelectionCell: the grid has no row selection (`selectionMode` is \"none\"), so the ' +\n 'cell renders nothing. Set `selectionMode` on the DataGrid, or remove the cell.',\n );\n }\n }, [notSelectable]);\n\n React.useEffect(() => {\n if (unseen) {\n warnOnce(\n 'DataGrid.SelectionCell:unseen',\n 'DataGrid.SelectionCell: rendered by another component, so its DataGrid.Row did not see ' +\n 'it and added its own selection cell. Render DataGrid.SelectionCell as a child of ' +\n 'DataGrid.Row (a Fragment is fine).',\n );\n }\n }, [unseen]);\n\n if (notSelectable) return null;\n if (section === 'header') {\n const rowProps = row?.selectionCellProps;\n return (\n <DataGridSelectionHeaderSlot\n ref={ref}\n selectionMode={selectionMode}\n initialFirst={firstHeaderRowHint}\n stableClassName={dataGridSelectionCellClassNames.root}\n cellProps={{\n ...rest,\n className: cn(rowProps?.className, className),\n disabled: disabled ?? rowProps?.disabled,\n invisible: invisible ?? rowProps?.invisible,\n 'aria-label': ariaLabel ?? rowProps?.['aria-label'],\n 'aria-labelledby': ariaLabelledBy,\n 'aria-describedby': ariaDescribedBy,\n controlRef,\n }}\n />\n );\n }\n return (\n <DataGridBodySelectionCell\n {...rest}\n ref={ref}\n component=\"DataGrid.SelectionCell\"\n stableClassName={dataGridSelectionCellClassNames.root}\n className={className}\n controlRef={controlRef}\n aria-describedby={ariaDescribedBy}\n />\n );\n};\nDataGridSelectionCell.displayName = 'DataGridSelectionCell';\nmarkTablePart(DataGridSelectionCell, 'dataGridSelectionCell');\n\n/**\n * A grid cell (`<td>`), focusable through the grid's keyboard navigation. It is the positioning\n * box of a `Table.CellActions` inside it.\n */\nconst DataGridCell = ({ children, className, ref, ...rest }: DataGridCellProps) => (\n <td\n ref={ref}\n role=\"gridcell\"\n className={cn(\n dataGridCellClassNames.root,\n cellBase,\n 'relative text-body-1',\n focusRingInset,\n className,\n )}\n {...rest}\n >\n {children}\n </td>\n);\nDataGridCell.displayName = 'DataGridCell';\n\nexport {\n DataGridHeader,\n DataGridHeaderCell,\n DataGridBody,\n DataGridRow,\n DataGridCell,\n DataGridSelectionCell,\n};\n\n/**\n * An interactive data table (`role=\"grid\"`) following the APG Grid pattern: one tab stop,\n * arrow-key navigation between cells (Home/End, Ctrl+Home/Ctrl+End, PageUp/PageDown; Up/Down keep\n * the visual column, so a grouped header with spanning cells works), Enter/F2 to interact with a\n * cell's widgets and Escape to return to the cell. A composite widget in a cell (a Toolbar,\n * RadioGroup, TabList, …) is entered with Enter/F2 like a text field; it manages its own tab\n * indexes, so it keeps its own Tab stop. Supports sortable columns (`onSortChange` reports the new\n * sort; a grid with `items` orders its rows by the sorted column's `compare`, otherwise the consumer\n * orders them) and single or multiple row selection with a select-all header checkbox.\n *\n * Selection is made with the row's control, Space on a cell, and, with `selectOnRowClick`, a\n * click on the row. `selectionAppearance` picks the fill of a selected row, `subtleSelection`\n * hides the unchecked controls until their row (or, for select-all, the grid) is hovered or holds\n * focus, and a row's `selectionCellProps` disables, hides or names its control. The selection\n * column comes first; a `DataGrid.SelectionCell` places it elsewhere in a row.\n *\n * The grid is composed from its parts, or rendered from data: with `items` and typed `columns`\n * (`DataGridColumn<T>`, see `createTableColumn`) it renders the header, the rows and the cells\n * itself, and `DataGrid.Body` also takes a render function that returns each item's row. Rows\n * rendered from `items` take their `rowId` from `getRowId` (by default the item's index).\n *\n * Sub-components are available as `DataGrid.Header`, `DataGrid.HeaderCell`, `DataGrid.Body`,\n * `DataGrid.Row`, `DataGrid.Cell` and `DataGrid.SelectionCell` in client components, and as the\n * flat exports `DataGridHeader`, `DataGridHeaderCell`, `DataGridBody`, `DataGridRow`,\n * `DataGridCell` and `DataGridSelectionCell` (the form React Server Components can import).\n */\nexport const DataGrid = /* @__PURE__ */ Object.assign(DataGridRoot, {\n Header: DataGridHeader,\n HeaderCell: DataGridHeaderCell,\n Body: DataGridBody,\n Row: DataGridRow,\n Cell: DataGridCell,\n SelectionCell: DataGridSelectionCell,\n});\n"],"mappings":";;;;;;;;;;;;;;;;AAwHA,IAAMG,IAA2B,mBAC3BC,IAAiC;AAicvC,SAAgBC,EACd,GACA,IAAoB,IACJ;CAChB,IAAIC,IAAgC,IAAI,IAAIC,CAAO,GAE7CC,oBAAa,IAAI,IAAoB,GAErCC,oBAAW,IAAI,IAAoB,GAErCC,IAAe,GAEfC,IAAkB,GAClBC,IAA4B,QAC5BC,IAAaC,GAEbC,GACEC,oBAAe,IAAI,IAAgB,GACnCC,oBAAqB,IAAI,IAAgB,GAEzCC,KAAU,MAA+B;E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B,AAAI0R,KACFtL,EACE,iCACA,4MAGF;CAEJ,GAAG,CAACsL,CAAM,CAAC,GAEPD,GAAe,OAAO;CAC1B,IAAIpC,MAAY,UAAU;EACxB,IAAMsC,IAAWtD,GAAK;EACtB,OACE,kBAACpB,IAAD;GACO;GACU;GACf,cAAcqC;GACd,iBAAiBsC,EAAgC;GACjD,WAAW;IACT,GAAGxM;IACH,WAAWuG,EAAGgG,GAAU,WAAW9F,CAAS;IAC5C,UAAUtL,KAAYoR,GAAU;IAChC,WAAWE,KAAaF,GAAU;IAClC,cAActF,KAAasF,IAAW;IACtC,mBAAmBrF;IACnB,oBAAoBC;IACpB;GACF;EACD,CAAA;CAEL;CACA,OACE,kBAAC8E,IAAD;EACE,GAAIjM;EACC;EACL,WAAU;EACV,iBAAiBwM,EAAgC;EACtC;EACC;EACZ,oBAAkBrF;CACnB,CAAA;AAEL;AACA,EAAsB,cAAc,yBACpCuF,GAAcN,GAAuB,uBAAuB;AAM5D,IAAMxH,KAAgB,EAAE,aAAU,cAAW,QAAK,GAAG5E,QACnD,kBAAC,MAAD;CACO;CACL,MAAK;CACL,WAAWuG,EACToG,EAAuB,MACvBpN,GACA,wBACAkI,GACAhB,CACF;CACA,GAAIzG;CAEH;AACC,CAAA;AAEN,EAAa,cAAc;AAqC3B,IAAa4M,KAA2B,uBAAO,OAAOjN,GAAc;CAClE,QAAQ4F;CACR,YAAYC;CACZ,MAAME;CACN,KAAKf;CACL,MAAMC;CACN,eAAewH;AACjB,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/cn.cjs"),n=require("../../lib/children.cjs"),r=require("../../lib/dev.cjs"),i=require("../../lib/
|
|
1
|
+
"use client";const e=require("../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/cn.cjs"),n=require("../../lib/children.cjs"),r=require("../../lib/dev.cjs"),i=require("../../lib/slot.cjs"),a=require("../../lib/composeEventHandlers.cjs"),o=require("../../lib/classNames.cjs"),s=require("../../hooks/useEventCallback.cjs"),c=require("../../hooks/useControllable.cjs"),l=require("../../hooks/useId.cjs"),u=require("../../hooks/useMergedRefs.cjs");require("../../lib/styles.cjs");const d=require("../../hooks/useFormReset.cjs"),f=require("../data-display/Avatar.context.cjs"),p=require("./Table.shared.cjs");let m=require("react");m=e.__toESM(m,1);let h=require("react/jsx-runtime");var g=()=>()=>{};function _(e){let t=m.useCallback(t=>{if(!e||typeof ResizeObserver>`u`)return()=>{};let n=new ResizeObserver(t);n.observe(e);for(let t of Array.from(e.children))n.observe(t);return()=>n.disconnect()},[e]),n=m.useCallback(()=>e?e.scrollWidth>e.clientWidth:!1,[e]);return m.useSyncExternalStore(e?t:g,n,()=>!1)}function v(e){return n.isElementOfType(e,`caption`)}var y=({striped:e=!1,containerProps:i,children:a,className:s,ref:c,...d})=>{let{className:f,ref:p,"aria-label":g,"aria-labelledby":y,...b}=i??{},[x,S]=m.useState(null),C=u.useMergedRefs(p,S),w=_(x),T=l.useId(`wave-table-caption`),E=n.flattenChildren(a),D=E.findIndex(({node:e})=>v(e)),O=D>=0?E[D].node:null,k=O?O.props.id??T:void 0,A=O&&O.props.id===void 0?E.map(({key:e,node:t},n)=>(0,h.jsx)(m.Fragment,{children:n===D?m.cloneElement(O,{id:T}):t},e)):a,j=g?void 0:y??k,M=!!(g||j),N=w&&M,P=b.role;return m.useEffect(()=>{w&&!M&&r.warnOnce(`Table:unnamed-scroll-region`,`Table: the table scrolls horizontally but its scroll region has no name. Add a <caption> or containerProps["aria-label"].`)},[w,M]),(0,h.jsx)(`div`,{...b,ref:C,role:N?`region`:P,tabIndex:w?0:b.tabIndex,"aria-label":w||P!==void 0?g:void 0,"aria-labelledby":N?j:P===void 0?void 0:y,className:t.cn(o.tableClassNames.container,`overflow-x-auto rounded-md border border-border`,w&&`focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring`,f),children:(0,h.jsx)(`table`,{ref:c,"data-striped":e?``:void 0,className:t.cn(o.tableClassNames.root,`w-full border-separate border-spacing-0`,e&&`[:where(&>tbody>tr:nth-child(odd))]:bg-card`,s),...d,children:A})})};y.displayName=`Table`;var b=({children:e,className:n,ref:r,...i})=>(0,h.jsx)(`thead`,{ref:r,...i,className:t.cn(o.tableHeaderClassNames.root,`bg-card`,n),children:e});b.displayName=`TableHeader`;var x=({sortable:e=!1,sortDirection:n,onSortClick:r,sortIcon:a,aside:s,children:c,className:l,ref:u,...d})=>{let f=i.slotRendersContent(s),m=f?i.renderSlot(s,`span`,t.cn(o.tableHeaderCellClassNames.aside,`inline-flex shrink-0 items-center`,e&&`pe-4`)):null,g=c;return e?g=(0,h.jsxs)(`div`,{className:`flex items-center`,children:[(0,h.jsx)(p.TableSortButton,{component:`Table.HeaderCell`,direction:n,sortIcon:a,className:o.tableHeaderCellClassNames.button,iconClassName:o.tableHeaderCellClassNames.sortIcon,onClick:r,children:c}),m]}):f&&(g=(0,h.jsxs)(`div`,{className:`flex items-center gap-2`,children:[c,m]})),(0,h.jsx)(`th`,{ref:u,scope:`col`,"aria-sort":e?n??`none`:void 0,className:t.cn(o.tableHeaderCellClassNames.root,`px-4 py-3 text-start font-semibold text-caption-1 uppercase tracking-wider border-b border-border`,e&&`p-0 hover:bg-subtle-hover`,l),...d,children:g})};x.displayName=`TableHeaderCell`;var S=e=>(r.warnDeprecated(`Table`,`Table.Head`,`Table.Header`),(0,h.jsx)(b,{...e}));S.displayName=`TableHead`;var C=e=>(r.warnDeprecated(`Table`,`Table.HeadCell`,`Table.HeaderCell`),(0,h.jsx)(x,{...e}));C.displayName=`TableHeadCell`;var w=({children:e,className:n,ref:r,...i})=>(0,h.jsx)(`tbody`,{ref:r,...i,className:t.cn(o.tableBodyClassNames.root,n),children:e});w.displayName=`TableBody`;var T=({children:e,className:n,ref:r,...i})=>(0,h.jsx)(`tr`,{ref:r,className:t.cn(o.tableRowClassNames.root,`group/table-row`,`hover:bg-subtle-hover transition-colors motion-reduce:transition-none`,n),...i,children:e});T.displayName=`TableRow`;var E=({children:e,className:n,ref:r,...i})=>(0,h.jsx)(`td`,{ref:r,className:t.cn(o.tableCellClassNames.root,`relative px-4 py-3 text-body-1 border-b border-border`,n),...i,children:e});E.displayName=`TableCell`;var D=({type:e=`checkbox`,checked:n,defaultChecked:i=!1,onCheckedChange:l,onChange:f,name:g,value:_,form:v,disabled:y,required:b,subtle:x=!1,invisible:S=!1,id:C,"aria-label":w,"aria-labelledby":T,"aria-describedby":E,"aria-invalid":D,"aria-required":O,"aria-errormessage":k,"aria-details":A,autoFocus:j,tabIndex:M,onFocus:N,onBlur:P,onKeyDown:F,onKeyUp:I,controlRef:L,className:R,ref:z,...B})=>{let V=m.useRef(void 0),[H,U,W]=c.useControllable(n,i,e=>{e!==`mixed`&&l?.(e,V.current)}),G=s.useEventCallback((e,t)=>{V.current={event:t};try{U(e)}finally{V.current=void 0}}),K=m.useRef(null),q=u.useMergedRefs(K,L);d.useFormReset(K,()=>U(i),v);let J=e===`radio`&&!W&&!!g;return m.useEffect(()=>{let e=K.current;if(!J||!e)return;let t=e.getRootNode(),n=t=>{let n=t.target;n!==e&&n instanceof HTMLInputElement&&n.type===`radio`&&n.name===e.name&&n.form===e.form&&n.checked&&G(!1,t)};return t.addEventListener(`click`,n,!0),()=>t.removeEventListener(`click`,n,!0)},[J,G]),m.useEffect(()=>{let e=K.current;!r.isDev||!e||w||T||(e.labels?.length??0)>0||r.warnOnce(`Table.SelectionCell:name`,'Table.SelectionCell: the selection control has no accessible name. Pass `aria-label` (e.g. "Select Alpha") or `aria-labelledby` (e.g. the id of the row’s first cell).')},[w,T,C]),(0,h.jsx)(`td`,{ref:z,"data-type":e,...B,className:t.cn(o.tableSelectionCellClassNames.root,p.SELECTION_CELL_CLASSES,R),children:(0,h.jsx)(p.TableSelectionControl,{ref:q,type:e,checked:H,subtle:x,invisible:S,id:C,name:g,value:_,form:v,disabled:y,required:b,"aria-label":w,"aria-labelledby":T,"aria-describedby":E,"aria-invalid":D,"aria-required":O,"aria-errormessage":k,"aria-details":A,autoFocus:j,tabIndex:M,onFocus:N,onBlur:P,onKeyDown:F,onKeyUp:I,onChange:a.composeEventHandlers(f,e=>G(e.currentTarget.checked,e.nativeEvent)),className:o.tableSelectionCellClassNames.control})})};D.displayName=`TableSelectionCell`;var O={size:32},k={default:`flex shrink-0 items-center [&>svg]:size-5`,primary:`flex shrink-0 items-center [&>svg]:size-6`},A=({media:e,description:n,truncate:r=!1,appearance:a,children:s,className:c,ref:l,...u})=>{let d=i.slotRendersContent(e),p=i.slotRendersContent(s),m=i.slotRendersContent(n),g=a===`primary`;return(0,h.jsxs)(`div`,{ref:l,"data-appearance":a,"data-truncate":r?``:void 0,...u,className:t.cn(o.tableCellLayoutClassNames.root,`flex items-center gap-2`,r&&`overflow-x-hidden`,c),children:[d&&(0,h.jsx)(f.AvatarSizeContext.Provider,{value:O,children:i.renderSlot(e,`span`,t.cn(o.tableCellLayoutClassNames.media,k[g?`primary`:`default`]))}),(p||m)&&(0,h.jsxs)(`div`,{className:t.cn(o.tableCellLayoutClassNames.content,`flex flex-col`,r&&`min-w-0 overflow-x-hidden`),children:[p&&(0,h.jsx)(`span`,{className:t.cn(o.tableCellLayoutClassNames.main,r&&`truncate`,g&&`font-semibold`),children:i.materialiseSlotContent(s)}),m&&i.renderSlot(n,`span`,t.cn(o.tableCellLayoutClassNames.description,`text-caption-1 text-muted-foreground`,r&&`truncate`))]})]})};A.displayName=`TableCellLayout`;var j=`absolute inset-y-0 end-0 flex items-center gap-1 px-1 bg-background group-hover/table-row:bg-subtle-hover [:where([data-striped]>tbody>tr:nth-child(odd)>*)>&]:bg-card [[data-selection-appearance=brand]>tbody>[data-selected]>*>&]:bg-selected [[data-selection-appearance=neutral]>tbody>[data-selected]>*>&]:bg-subtle-selected transition-[opacity,background-color] motion-reduce:transition-none`,M=`opacity-0 group-hover/table-row:opacity-100 group-focus-within/table-row:opacity-100 focus-within:opacity-100 forced-colors:opacity-100 pointer-coarse:opacity-100`,N=({visible:e=!1,className:n,ref:r,...i})=>(0,h.jsx)(`div`,{ref:r,"data-visible":e?``:void 0,...i,className:t.cn(o.tableCellActionsClassNames.root,j,e?void 0:M,n)});N.displayName=`TableCellActions`;var P=Object.assign(y,{Header:b,HeaderCell:x,Head:S,HeadCell:C,Body:w,Row:T,Cell:E,SelectionCell:D,CellLayout:A,CellActions:N});exports.Table=P,exports.TableBody=w,exports.TableCell=E,exports.TableCellActions=N,exports.TableCellLayout=A,exports.TableHead=S,exports.TableHeadCell=C,exports.TableHeader=b,exports.TableHeaderCell=x,exports.TableRow=T,exports.TableSelectionCell=D;
|
|
2
2
|
//# sourceMappingURL=Table.cjs.map
|