@bmsuisse/datagrid 0.30.0 → 0.31.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 +49 -6
- package/dist/index.js +338 -120
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -668,7 +668,11 @@ declare function BooleanEditor<TRow>({ column, rowId, value, onChange, error, au
|
|
|
668
668
|
declare function DateEditor<TRow>({ column, rowId, value, onChange, error, autoFocus, }: EditWidgetProps<DateColumn<TRow>>): ReactElement;
|
|
669
669
|
|
|
670
670
|
/** Default inline editor for `type: "enum"` columns: a single-value select over `column.options`. */
|
|
671
|
-
declare function EnumEditor<TRow>({ column, rowId, value, onChange, error, autoFocus, }: EditWidgetProps<EnumColumn<TRow>>
|
|
671
|
+
declare function EnumEditor<TRow>({ column, rowId, value, onChange, error, autoFocus, open, onOpenChange, }: EditWidgetProps<EnumColumn<TRow>> & {
|
|
672
|
+
/** Controls the dropdown's own open state — omit to let `<Select>` manage it itself (the default, used everywhere except `AlwaysEditCell`; see that file's own doc for why it needs control here). */
|
|
673
|
+
open?: boolean;
|
|
674
|
+
onOpenChange?: (open: boolean) => void;
|
|
675
|
+
}): ReactElement;
|
|
672
676
|
|
|
673
677
|
/**
|
|
674
678
|
* Default inline editor for a `type: "string"` column with `multiline: true`:
|
|
@@ -863,6 +867,18 @@ interface CellEditingOptions<TRow> {
|
|
|
863
867
|
onCellsChange: (changes: CellChange<TRow>[]) => void | Promise<void>;
|
|
864
868
|
/** Disables all cell-editing interaction — e.g. while a previous gesture's `onCellsChange` is still in flight. Defaults to false. */
|
|
865
869
|
disabled?: boolean;
|
|
870
|
+
/**
|
|
871
|
+
* Renders every editable cell's editor directly, all the time — no click,
|
|
872
|
+
* double-click, F2, or typed character needed to open one first. Selection
|
|
873
|
+
* (drag/shift+click/shift+arrow), copy, paste, and the fill-handle all
|
|
874
|
+
* still work exactly as they do without this flag; only the single-cell
|
|
875
|
+
* "one cell editing at a time" gate is gone, since with this on every
|
|
876
|
+
* editable cell already IS its own editor. A buffered (string/number/
|
|
877
|
+
* currency) editor still only commits on blur/Enter/Tab, same as always —
|
|
878
|
+
* this flag just means it's already open, not that it types straight
|
|
879
|
+
* through to `onCellsChange` on every keystroke. Defaults to false.
|
|
880
|
+
*/
|
|
881
|
+
alwaysEdit?: boolean;
|
|
866
882
|
}
|
|
867
883
|
|
|
868
884
|
/** Maps each id to its position in `ids` — built once per (rowIds|columnIds) identity change, then reused for every lookup during a drag, rather than an O(n) `indexOf` per cell per mousemove. */
|
|
@@ -972,7 +988,11 @@ declare function useCellSelection({ rowIds, columnIds, onNavigateToRow }: CellSe
|
|
|
972
988
|
* table body.
|
|
973
989
|
*/
|
|
974
990
|
interface CellEditingCellContext<TRow> {
|
|
975
|
-
/**
|
|
991
|
+
/** Mirrors `CellEditingOptions.alwaysEdit` — every editable cell renders `AlwaysEditCell` instead of going through `editingCell`/`onBeginEdit` at all when this is set. */
|
|
992
|
+
alwaysEdit: boolean;
|
|
993
|
+
/** Mirrors `CellEditingOptions.disabled`. Click-to-edit mode blocks interaction by simply never opening an editor while this is set (see `onBeginEdit`'s own gate) — `AlwaysEditCell`'s editors are always open regardless, so it reads this directly to disable its rendered form control instead. */
|
|
994
|
+
disabled: boolean;
|
|
995
|
+
/** The one cell currently showing its editor, or `undefined` — at most one at a time, the same convention `EditingCellContext.activeRowId` uses at row granularity. Meaningless (always `undefined`) under `alwaysEdit`, where every editable cell already has its own editor. */
|
|
976
996
|
editingCell: CellAddress | undefined;
|
|
977
997
|
/** Replaces (doesn't append to) the editor's starting value when editing began by typing a printable character directly (Excel's "just start typing" gesture) rather than double-click/Enter/F2, which start from the cell's current value. `undefined` means "start from the current value." */
|
|
978
998
|
initialText: string | undefined;
|
|
@@ -1015,6 +1035,8 @@ interface CellEditingCellContext<TRow> {
|
|
|
1015
1035
|
*/
|
|
1016
1036
|
onCommitValue: (row: TRow, previousValue: unknown, value: unknown) => void;
|
|
1017
1037
|
onSetError: (rowId: string, columnId: string, message: string | undefined) => void;
|
|
1038
|
+
/** Commits one independently-managed cell's change directly — for `AlwaysEditCell`, which owns its own draft state locally rather than through `editingCell`/`onChangeDraft`/`onCommitEdit`'s single shared slot (every editable cell needs its own simultaneous editor under `alwaysEdit`, not just one at a time). */
|
|
1039
|
+
applyChange: (change: CellChange<TRow>) => void;
|
|
1018
1040
|
/**
|
|
1019
1041
|
* Reads (and clears) whether `onCommitEdit`/`onCommitValue` committed
|
|
1020
1042
|
* synchronously during the current call stack. `<DataGrid>`'s own keydown
|
|
@@ -1112,6 +1134,8 @@ declare function SelectionOverlay({ containerRef, range, fillPreviewRange, onFil
|
|
|
1112
1134
|
* `null` for `number`/`currency` (pasting a blank cell over a numeric one
|
|
1113
1135
|
* clears it, matching `NumberEditor`'s own null-for-cleared convention) —
|
|
1114
1136
|
* `string` columns instead treat an empty string as itself a valid value.
|
|
1137
|
+
* An Excel/Sheets error string (`#N/A`, `#DIV/0!`, etc.) pasted into any
|
|
1138
|
+
* column but `string` is likewise skipped rather than coerced.
|
|
1115
1139
|
*/
|
|
1116
1140
|
declare function coerceValueForColumn<TRow>(column: ColumnDef<TRow>, raw: string): {
|
|
1117
1141
|
value: unknown;
|
|
@@ -1400,9 +1424,18 @@ interface DataGridProps<TRow> {
|
|
|
1400
1424
|
/**
|
|
1401
1425
|
* Renders the built-in Previous/Next pagination footer. Defaults to true.
|
|
1402
1426
|
* Set to false when a caller renders its own pagination UI instead (e.g.
|
|
1403
|
-
* one with specific `data-testid`s an existing test suite depends on)
|
|
1404
|
-
*
|
|
1405
|
-
*
|
|
1427
|
+
* one with specific `data-testid`s an existing test suite depends on), or
|
|
1428
|
+
* to disable pagination altogether and render every row.
|
|
1429
|
+
*
|
|
1430
|
+
* When `false` and no explicit `pageSize` is given (via `initialState` or
|
|
1431
|
+
* `gridState`), the effective page size becomes unbounded instead of
|
|
1432
|
+
* defaulting to 20 — hiding the pagination UI with no page size in mind
|
|
1433
|
+
* means "show every row," not "silently truncate to the first page." A
|
|
1434
|
+
* caller who explicitly sets `pageSize` alongside `showPagination: false`
|
|
1435
|
+
* still gets exactly that page size (deliberate fixed-size chunking with
|
|
1436
|
+
* no UI). This only affects `"client"` mode's own row slicing; in
|
|
1437
|
+
* `"server"` mode, whether every row actually comes back is up to your
|
|
1438
|
+
* `dataSource`.
|
|
1406
1439
|
*/
|
|
1407
1440
|
showPagination?: boolean;
|
|
1408
1441
|
/**
|
|
@@ -1589,8 +1622,18 @@ interface GridStateController {
|
|
|
1589
1622
|
* across the component's lifetime — start controlled and stay controlled,
|
|
1590
1623
|
* or start uncontrolled and stay uncontrolled; toggling to `undefined`
|
|
1591
1624
|
* later does not hand ownership back, it just stops resyncing.
|
|
1625
|
+
*
|
|
1626
|
+
* `showPagination`, when `false` and the caller did NOT explicitly provide
|
|
1627
|
+
* `initialState.pageSize`, seeds `pageSize` as effectively unbounded instead
|
|
1628
|
+
* of `DEFAULT_STATE`'s 20 — "hide the pagination controls" means "no
|
|
1629
|
+
* pagination" by default, matching `<DataGrid>`'s `showPagination` doc. A
|
|
1630
|
+
* caller who explicitly sets `initialState.pageSize` (deliberate fixed-size
|
|
1631
|
+
* chunking with no UI, alongside `showPagination: false`) still gets exactly
|
|
1632
|
+
* that value; this only changes what happens when they didn't ask for a
|
|
1633
|
+
* particular page size at all. Has no effect once `externalState` is in
|
|
1634
|
+
* play — a controlled `GridState` is always fully caller-specified.
|
|
1592
1635
|
*/
|
|
1593
|
-
declare function useGridState<TRow>(dataSource: DataSource<TRow>, initialState?: Partial<GridState>, externalState?: GridState): GridStateController;
|
|
1636
|
+
declare function useGridState<TRow>(dataSource: DataSource<TRow>, initialState?: Partial<GridState>, externalState?: GridState, showPagination?: boolean): GridStateController;
|
|
1594
1637
|
|
|
1595
1638
|
interface ClientProcessingResult<TRow> {
|
|
1596
1639
|
rows: TRow[];
|