@bmsuisse/datagrid 0.23.4 → 0.24.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +75 -2
- package/dist/index.js +286 -61
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -762,6 +762,37 @@ interface DataGridProps<TRow> {
|
|
|
762
762
|
* a page with more than one.
|
|
763
763
|
*/
|
|
764
764
|
testId?: string;
|
|
765
|
+
/**
|
|
766
|
+
* Buckets the grid's already-filtered/sorted/paginated `rows` into groups,
|
|
767
|
+
* rendering one full-width `colSpan`'d group-header row before each
|
|
768
|
+
* bucket's own rows, in first-seen bucket order (rows are never re-sorted
|
|
769
|
+
* to cluster a group together — the caller's own sort already determines
|
|
770
|
+
* which key appears first). Single level only — no nested grouping, no
|
|
771
|
+
* aggregate/summary calculation; a caller wanting a subtotal computes it
|
|
772
|
+
* themselves in `renderGroupHeader` off that bucket's own row array.
|
|
773
|
+
* Operates on whatever `rows` already resolved to — i.e. the current page,
|
|
774
|
+
* if paginated — with no special-casing; pair with a large `pageSize`/
|
|
775
|
+
* `showPagination: false` if a group's full membership should never be
|
|
776
|
+
* split across pages. Omit entirely to disable — no grouping, no header
|
|
777
|
+
* rows, unchanged default rendering.
|
|
778
|
+
*
|
|
779
|
+
* Not supported together with `virtualize` yet — when both are set,
|
|
780
|
+
* virtualization is silently disabled and the grid renders as a plain,
|
|
781
|
+
* fully-rendered (but still grouped) `<table>` instead. See AGENTS.md's
|
|
782
|
+
* "Known limitations."
|
|
783
|
+
*/
|
|
784
|
+
groupBy?: (row: TRow) => string;
|
|
785
|
+
/** Customizes a group-header row's content. Defaults to `` `${key} (${rows.length})` ``. */
|
|
786
|
+
renderGroupHeader?: (key: string, rows: TRow[], expanded: boolean) => ReactNode;
|
|
787
|
+
/** Whether a newly-seen group starts expanded. Defaults to true. */
|
|
788
|
+
defaultGroupsExpanded?: boolean;
|
|
789
|
+
/**
|
|
790
|
+
* Controlled per-group expand/collapse state, keyed by the `groupBy` key.
|
|
791
|
+
* Both must be supplied together to control it — omit both for
|
|
792
|
+
* `<DataGrid>` to own this state internally.
|
|
793
|
+
*/
|
|
794
|
+
expandedGroups?: Record<string, boolean>;
|
|
795
|
+
onExpandedGroupsChange?: (expanded: Record<string, boolean>) => void;
|
|
765
796
|
}
|
|
766
797
|
|
|
767
798
|
/**
|
|
@@ -772,7 +803,7 @@ interface DataGridProps<TRow> {
|
|
|
772
803
|
* (`"server"`). Column filter UI defaults to the type-appropriate widget
|
|
773
804
|
* from `src/filter` unless a column supplies its own `cell` renderer.
|
|
774
805
|
*/
|
|
775
|
-
declare function DataGrid<TRow extends RowData>({ columns, dataSource, getRowId, rowActions, headerActions, enableMultiSort, initialState, columnVisibility, renderDetail, enableColumnResizing, columnResizeMode, columnSizing: controlledColumnSizing, onColumnSizingChange, virtualize, showPagination, getRowProps, getRowTestId, gridState, selectedIds: controlledSelectedIds, onSelectedIdsChange, testId, loading: loadingProp, }: DataGridProps<TRow>): ReactElement;
|
|
806
|
+
declare function DataGrid<TRow extends RowData>({ columns, dataSource, getRowId, rowActions, headerActions, enableMultiSort, initialState, columnVisibility, renderDetail, enableColumnResizing, columnResizeMode, columnSizing: controlledColumnSizing, onColumnSizingChange, virtualize, showPagination, getRowProps, getRowTestId, gridState, selectedIds: controlledSelectedIds, onSelectedIdsChange, testId, loading: loadingProp, groupBy, renderGroupHeader, defaultGroupsExpanded, expandedGroups: controlledExpandedGroups, onExpandedGroupsChange, }: DataGridProps<TRow>): ReactElement;
|
|
776
807
|
|
|
777
808
|
interface GridStateController {
|
|
778
809
|
state: GridState;
|
|
@@ -954,6 +985,48 @@ interface TreeDataGridProps<TRow> extends TreeAccessors<TRow> {
|
|
|
954
985
|
estimatedRowHeight?: number;
|
|
955
986
|
/** Max height of the scrollable table body in pixels. Required for virtualization to have a viewport to scroll within. Defaults to 480. */
|
|
956
987
|
maxBodyHeight?: number;
|
|
988
|
+
/**
|
|
989
|
+
* Controlled row selection — same convention as `<DataGrid>`'s own
|
|
990
|
+
* `selectedIds`/`onSelectedIdsChange`. Both must be supplied together to
|
|
991
|
+
* render a checkbox column at all; there is no internal/uncontrolled
|
|
992
|
+
* fallback here, unlike `<DataGrid>` — `<TreeDataGrid>` has no
|
|
993
|
+
* `headerActions` bulk-toolbar concept that would need selection state
|
|
994
|
+
* even without external control, so there's nothing for an uncontrolled
|
|
995
|
+
* default to serve.
|
|
996
|
+
*
|
|
997
|
+
* Clicking a row's checkbox always toggles exactly that row's own id in
|
|
998
|
+
* this set — never its children or parent. Any cascade ("select whole
|
|
999
|
+
* group" / "select all descendants") is the caller's job, done by
|
|
1000
|
+
* recomputing the desired final set inside `onSelectedIdsChange` before
|
|
1001
|
+
* committing it to their own state.
|
|
1002
|
+
*/
|
|
1003
|
+
selectedIds?: ReadonlySet<string>;
|
|
1004
|
+
onSelectedIdsChange?: (ids: ReadonlySet<string>) => void;
|
|
1005
|
+
/**
|
|
1006
|
+
* Fully overrides a row's checked/indeterminate display, replacing the
|
|
1007
|
+
* default derivation below. Needed for selection semantics this component
|
|
1008
|
+
* won't build in — e.g. a "select whole group vs. split into individual
|
|
1009
|
+
* children once loaded" cascade, where a parent should read as checked
|
|
1010
|
+
* even though not every descendant id is literally in `selectedIds`.
|
|
1011
|
+
* Return `undefined` for a given row to fall back to the default
|
|
1012
|
+
* derivation for just that row.
|
|
1013
|
+
*
|
|
1014
|
+
* Omitted (the default): `checked` is exactly `selectedIds.has(getRowId(row))`
|
|
1015
|
+
* — `selectedIds` always stays the single source of truth for "is this id
|
|
1016
|
+
* selected." `indeterminate` is true only when the row itself isn't
|
|
1017
|
+
* checked but at least one *currently loaded* descendant (recursively, via
|
|
1018
|
+
* the same `getChildren`/`onLoadChildren` cache this component already
|
|
1019
|
+
* maintains) is checked or itself indeterminate. A selected descendant
|
|
1020
|
+
* hidden behind a node that's never been expanded (so its children were
|
|
1021
|
+
* never fetched) can't be inspected — that ancestor reads as unchecked,
|
|
1022
|
+
* not indeterminate, until the fetch happens.
|
|
1023
|
+
*/
|
|
1024
|
+
getRowSelectionState?: (row: TRow) => {
|
|
1025
|
+
checked: boolean;
|
|
1026
|
+
indeterminate?: boolean;
|
|
1027
|
+
} | undefined;
|
|
1028
|
+
/** Disables just the checkbox for a specific row. Defaults to `() => false`. */
|
|
1029
|
+
isRowSelectionDisabled?: (row: TRow) => boolean;
|
|
957
1030
|
}
|
|
958
1031
|
|
|
959
1032
|
/**
|
|
@@ -970,7 +1043,7 @@ interface TreeDataGridProps<TRow> extends TreeAccessors<TRow> {
|
|
|
970
1043
|
* column's cell matches `treeColumnId` (defaults to `columns[0]`); every
|
|
971
1044
|
* other column renders exactly like it would in `<DataGrid>`.
|
|
972
1045
|
*/
|
|
973
|
-
declare function TreeDataGrid<TRow>({ columns, data, treeColumnId, getRowId, getChildren, hasChildren, onLoadChildren, initialExpandedLevel, expanded: controlledExpanded, onExpandedChange, indentSize, getRowProps, getRowTestId, rowActions, virtualizeThreshold, estimatedRowHeight, maxBodyHeight, }: TreeDataGridProps<TRow>): ReactElement;
|
|
1046
|
+
declare function TreeDataGrid<TRow>({ columns, data, treeColumnId, getRowId, getChildren, hasChildren, onLoadChildren, initialExpandedLevel, expanded: controlledExpanded, onExpandedChange, indentSize, getRowProps, getRowTestId, rowActions, virtualizeThreshold, estimatedRowHeight, maxBodyHeight, selectedIds: controlledSelectedIds, onSelectedIdsChange, getRowSelectionState, isRowSelectionDisabled, }: TreeDataGridProps<TRow>): ReactElement;
|
|
974
1047
|
|
|
975
1048
|
interface FlatTreeRow<TRow> {
|
|
976
1049
|
row: TRow;
|