@bmsuisse/datagrid 0.38.0 → 0.39.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -121,6 +121,10 @@ interface FilterLabels {
121
121
  clear: string;
122
122
  /** NumberHistogramFilter's `loadValues` in-flight message. */
123
123
  loading: string;
124
+ /** NumberHistogramFilter: `loadValues` rejected. */
125
+ loadFailed: string;
126
+ /** NumberHistogramFilter: retry action next to `loadFailed`. */
127
+ retry: string;
124
128
  dateToday: string;
125
129
  dateLast7Days: string;
126
130
  dateThisMonth: string;
@@ -1483,6 +1487,28 @@ interface ActionsMenuProps<TRow> {
1483
1487
  */
1484
1488
  declare function ActionsMenu<TRow>({ items, ctx, triggerLabel }: ActionsMenuProps<TRow>): ReactElement | null;
1485
1489
 
1490
+ /** Structured error shown by the grid's error states. Same shape as `@bmsuisse/ui`'s `ErrorInfo`. */
1491
+ interface ErrorInfo {
1492
+ title?: string;
1493
+ message?: string;
1494
+ /** Technical details (stack, response body) — shown behind a "Show details" toggle. */
1495
+ details?: string;
1496
+ }
1497
+ /** What the grids accept for `error` — pass a TanStack Query / SWR / `catch` error straight through. */
1498
+ type ErrorInput = ErrorInfo | Error | string | null | undefined | false;
1499
+ declare function toErrorInfo(error: unknown): ErrorInfo | undefined;
1500
+ /** User-facing strings of the grid's loading/error/empty states. Anything omitted keeps its English default. */
1501
+ interface GridStatusLabels {
1502
+ loading: string;
1503
+ noResults: string;
1504
+ errorTitle: string;
1505
+ retry: string;
1506
+ showDetails: string;
1507
+ /** TreeDataGrid: shown on a node whose lazy children failed to load. */
1508
+ nodeLoadFailed: string;
1509
+ }
1510
+ declare const defaultGridStatusLabels: GridStatusLabels;
1511
+
1486
1512
  /**
1487
1513
  * `"client"`: the grid owns filtering/sorting/pagination and evaluates them
1488
1514
  * in-memory against the full `data` array (via `evaluateFilter`).
@@ -1537,6 +1563,17 @@ interface DataGridProps<TRow> {
1537
1563
  * The two are OR'd together if both happen to be set. Defaults to `false`.
1538
1564
  */
1539
1565
  loading?: boolean;
1566
+ /**
1567
+ * The data fetch failed. With no rows to show, the body is replaced by an error
1568
+ * state (title, message, collapsible details, Retry); with stale rows still shown,
1569
+ * they stay and a slim error banner appears above them. Accepts a string, an
1570
+ * `Error` (message + stack as details) or `{ title, message, details }`.
1571
+ */
1572
+ error?: ErrorInput;
1573
+ /** Shows a Retry action in the error state/banner. */
1574
+ onRetry?: () => void;
1575
+ /** Overrides the grid's "Loading...", "No results." and error-state strings. */
1576
+ statusLabels?: Partial<GridStatusLabels>;
1540
1577
  /** Per-row kebab menu. Evaluated with `ctx.row` set to that row. */
1541
1578
  rowActions?: MenuItem<TRow>[];
1542
1579
  /** Toolbar menu above the table. Evaluated with `ctx.selectedRows` set. */
@@ -1801,7 +1838,7 @@ interface DataGridProps<TRow> {
1801
1838
  * (`"server"`). Column filter UI defaults to the type-appropriate widget
1802
1839
  * from `src/filter` unless a column supplies its own `cell` renderer.
1803
1840
  */
1804
- 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, onGridStateChange, selectedIds: controlledSelectedIds, onSelectedIdsChange, testId, loading: loadingProp, groupBy, renderGroupHeader, defaultGroupsExpanded, expandedGroups: controlledExpandedGroups, onExpandedGroupsChange, zebra, showTotals, editing, cellEditing, filterLabels, }: DataGridProps<TRow>): ReactElement;
1841
+ 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, onGridStateChange, selectedIds: controlledSelectedIds, onSelectedIdsChange, testId, loading: loadingProp, error, onRetry, statusLabels, groupBy, renderGroupHeader, defaultGroupsExpanded, expandedGroups: controlledExpandedGroups, onExpandedGroupsChange, zebra, showTotals, editing, cellEditing, filterLabels, }: DataGridProps<TRow>): ReactElement;
1805
1842
 
1806
1843
  interface GridStateController {
1807
1844
  state: GridState;
@@ -1985,6 +2022,16 @@ interface TreeDataGridProps<TRow> extends TreeAccessors<TRow> {
1985
2022
  * Defaults to `false`.
1986
2023
  */
1987
2024
  loading?: boolean;
2025
+ /**
2026
+ * The root data fetch failed. With no rows, the body shows an error state (title,
2027
+ * message, collapsible details, Retry); with rows, they stay and a slim banner
2028
+ * appears above. Per-node lazy-load failures are handled separately (inline, per row).
2029
+ */
2030
+ error?: ErrorInput;
2031
+ /** Shows a Retry action in the error state/banner. */
2032
+ onRetry?: () => void;
2033
+ /** Overrides the grid's "Loading...", "No results." and error-state strings. */
2034
+ statusLabels?: Partial<GridStatusLabels>;
1988
2035
  /**
1989
2036
  * The column whose cell gets the depth indentation + expand/collapse
1990
2037
  * chevron prepended. Defaults to the first column in `columns`.
@@ -2216,7 +2263,7 @@ interface TreeDataGridProps<TRow> extends TreeAccessors<TRow> {
2216
2263
  * column's cell matches `treeColumnId` (defaults to `columns[0]`); every
2217
2264
  * other column renders exactly like it would in `<DataGrid>`.
2218
2265
  */
2219
- declare function TreeDataGrid<TRow>({ columns, data, loading, treeColumnId, columnVisibility, getRowId, getChildren, hasChildren, onLoadChildren, initialExpandedLevel, expanded: controlledExpanded, onExpandedChange, childrenMap: controlledChildrenMap, onChildrenMapChange, indentSize, getRowProps, getRowTestId, rowActions, virtualizeThreshold, estimatedRowHeight, maxBodyHeight, testId, selectedIds: controlledSelectedIds, onSelectedIdsChange, getRowSelectionState, isRowSelectionDisabled, groupBy, renderGroupHeader, defaultGroupsExpanded, expandedGroups: controlledExpandedGroups, onExpandedGroupsChange, zebra, showTotals, editing, }: TreeDataGridProps<TRow>): ReactElement;
2266
+ declare function TreeDataGrid<TRow>({ columns, data, loading, error, onRetry, statusLabels, treeColumnId, columnVisibility, getRowId, getChildren, hasChildren, onLoadChildren, initialExpandedLevel, expanded: controlledExpanded, onExpandedChange, childrenMap: controlledChildrenMap, onChildrenMapChange, indentSize, getRowProps, getRowTestId, rowActions, virtualizeThreshold, estimatedRowHeight, maxBodyHeight, testId, selectedIds: controlledSelectedIds, onSelectedIdsChange, getRowSelectionState, isRowSelectionDisabled, groupBy, renderGroupHeader, defaultGroupsExpanded, expandedGroups: controlledExpandedGroups, onExpandedGroupsChange, zebra, showTotals, editing, }: TreeDataGridProps<TRow>): ReactElement;
2220
2267
 
2221
2268
  interface FlatTreeRow<TRow> {
2222
2269
  row: TRow;
@@ -2272,4 +2319,4 @@ interface UseTreeStateOptions<TRow> extends TreeAccessors<TRow> {
2272
2319
  */
2273
2320
  declare function useTreeState<TRow>({ data, getRowId, getChildren, hasChildren, onLoadChildren, expanded: controlledExpanded, onExpandedChange, childrenMap: controlledChildrenMap, onChildrenMapChange, }: UseTreeStateOptions<TRow>): TreeStateController<TRow>;
2274
2321
 
2275
- export { ActionsMenu, type BaseColumn, type BooleanColumn, BooleanEditor, BooleanFilter, type CellAddress, type CellChange, type CellEditingCellContext, type CellEditingOptions, type CellEditingState, type CellRange, type CellSelectionController, type CellSelectionOptions, type ClientProcessingResult, type ColumnAlign, type ColumnDef, type ColumnGroup, ColumnSelector, type ColumnSelectorProps, type ColumnVisibility, type CompositeFilterDescriptor, DataGrid, type DataGridProps, type DataSource, type DateColumn, DateEditor, DateRangeFilter, type DebouncedCallback, EditFieldError, type EditWidgetProps, type EditedRow, EditingBar, type EditingBarProps, type EditingCellContext, type EditingOptions, type EditingState, type EnumColumn, EnumEditor, EnumFilter, type EnumOption, type FilterDescriptor, type FilterLabels, FilterLabelsProvider, type FilterOperator, type FilterWidgetProps, type FlatTreeRow, type GridState, type GridStateController, type GroupExpansionController, type MenuItem, type MenuItemContext, MultilineStringEditor, type NavigationDirection, type NormalizedRange, type NumberColumn, NumberComparisonFilter, NumberEditor, NumberHistogramFilter, type NumberHistogramFilterProps, NumberRangeFilter, type PendingRowEdit, type ResolvedMenuItem, SelectionOverlay, type SortDescriptor, type StickyGroupHeaderTop, type StringColumn, StringEditor, StringFilter, type TreeAccessors, TreeDataGrid, type TreeDataGridProps, type TreeStateController, UNARY_OPERATORS, type UseTreeStateOptions, alignClassName, applyColumnOrder, buildIndexMap, canHideColumn, canHideGroup, cellsInRange, coerceValueForColumn, computeFillChanges, countVisible, defaultAlign, defaultFilterLabels, defaultFormat, editErrorId, evaluateFilter, extendRangeForFill, facetedNumberValues, fieldKey, flattenTree, getColumnValue, groupColumns, isCellInRange, isColumnVisible, isCompositeFilterDescriptor, isEditable, isFilterDescriptor, isFilterable, isSortable, mergeFilterLabels, moveColumnBefore, normalizeRange, orderStorageKeyFor, parseTsv, processClientData, rangeToTsv, renderCellModeCell, renderDefaultEditWidget, renderDefaultFilterWidget, renderEditableCell, resolveMenuItems, storageKeyFor, toDate, useCellEditingState, useCellSelection, useDebouncedCallback, useEditingState, useFilterLabels, useGridState, useGroupExpansion, useStickyGroupHeaderTop, useTreeState, useVisibleColumns };
2322
+ export { ActionsMenu, type BaseColumn, type BooleanColumn, BooleanEditor, BooleanFilter, type CellAddress, type CellChange, type CellEditingCellContext, type CellEditingOptions, type CellEditingState, type CellRange, type CellSelectionController, type CellSelectionOptions, type ClientProcessingResult, type ColumnAlign, type ColumnDef, type ColumnGroup, ColumnSelector, type ColumnSelectorProps, type ColumnVisibility, type CompositeFilterDescriptor, DataGrid, type DataGridProps, type DataSource, type DateColumn, DateEditor, DateRangeFilter, type DebouncedCallback, EditFieldError, type EditWidgetProps, type EditedRow, EditingBar, type EditingBarProps, type EditingCellContext, type EditingOptions, type EditingState, type EnumColumn, EnumEditor, EnumFilter, type EnumOption, type ErrorInfo, type ErrorInput, type FilterDescriptor, type FilterLabels, FilterLabelsProvider, type FilterOperator, type FilterWidgetProps, type FlatTreeRow, type GridState, type GridStateController, type GridStatusLabels, type GroupExpansionController, type MenuItem, type MenuItemContext, MultilineStringEditor, type NavigationDirection, type NormalizedRange, type NumberColumn, NumberComparisonFilter, NumberEditor, NumberHistogramFilter, type NumberHistogramFilterProps, NumberRangeFilter, type PendingRowEdit, type ResolvedMenuItem, SelectionOverlay, type SortDescriptor, type StickyGroupHeaderTop, type StringColumn, StringEditor, StringFilter, type TreeAccessors, TreeDataGrid, type TreeDataGridProps, type TreeStateController, UNARY_OPERATORS, type UseTreeStateOptions, alignClassName, applyColumnOrder, buildIndexMap, canHideColumn, canHideGroup, cellsInRange, coerceValueForColumn, computeFillChanges, countVisible, defaultAlign, defaultFilterLabels, defaultFormat, defaultGridStatusLabels, editErrorId, evaluateFilter, extendRangeForFill, facetedNumberValues, fieldKey, flattenTree, getColumnValue, groupColumns, isCellInRange, isColumnVisible, isCompositeFilterDescriptor, isEditable, isFilterDescriptor, isFilterable, isSortable, mergeFilterLabels, moveColumnBefore, normalizeRange, orderStorageKeyFor, parseTsv, processClientData, rangeToTsv, renderCellModeCell, renderDefaultEditWidget, renderDefaultFilterWidget, renderEditableCell, resolveMenuItems, storageKeyFor, toDate, toErrorInfo, useCellEditingState, useCellSelection, useDebouncedCallback, useEditingState, useFilterLabels, useGridState, useGroupExpansion, useStickyGroupHeaderTop, useTreeState, useVisibleColumns };