@jielga/tmdatagrid 2.0.0-beta.7 → 2.0.0-beta.9

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.
Files changed (38) hide show
  1. package/dist/index.d.ts +47 -33
  2. package/dist/index.js +1517 -1262
  3. package/dist/index.js.map +1 -1
  4. package/dist/styles.css +1 -1
  5. package/package.json +2 -1
  6. package/skills/appearance/SKILL.md +1 -1
  7. package/skills/cell-selection/SKILL.md +25 -33
  8. package/skills/columns/SKILL.md +1 -1
  9. package/skills/data/SKILL.md +1 -1
  10. package/skills/editing/SKILL.md +19 -13
  11. package/skills/editing/references/editing-api.md +9 -4
  12. package/skills/filtering/SKILL.md +1 -1
  13. package/skills/getting-started/SKILL.md +1 -1
  14. package/skills/grouping/SKILL.md +1 -1
  15. package/skills/options/SKILL.md +2 -2
  16. package/skills/rows/SKILL.md +1 -1
  17. package/skills/server-side/SKILL.md +1 -1
  18. package/skills/testing/SKILL.md +1 -1
  19. package/src/tmdatagrid/TMDataGridContext.ts +7 -19
  20. package/src/tmdatagrid/components/TMDataGrid.module.css +7 -1
  21. package/src/tmdatagrid/components/TMDataGridCellEditor.tsx +21 -1
  22. package/src/tmdatagrid/components/TMDataGridDetailsColumn.tsx +4 -4
  23. package/src/tmdatagrid/components/TMDataGridEditColumn.tsx +11 -4
  24. package/src/tmdatagrid/components/TMDataGridEntryRows.tsx +8 -23
  25. package/src/tmdatagrid/components/TMDataGridFooter.tsx +5 -5
  26. package/src/tmdatagrid/components/TMDataGridGroupColumn.tsx +4 -3
  27. package/src/tmdatagrid/components/TMDataGridHeaderCell.tsx +59 -14
  28. package/src/tmdatagrid/components/TMDataGridSelectColumn.tsx +4 -5
  29. package/src/tmdatagrid/components/TMDataGridTable.module.css +22 -12
  30. package/src/tmdatagrid/components/TMDataGridTable.tsx +447 -63
  31. package/src/tmdatagrid/components/TMDataGridToolbar.tsx +2 -1
  32. package/src/tmdatagrid/core/capabilities.ts +5 -5
  33. package/src/tmdatagrid/core/editEngine.ts +150 -13
  34. package/src/tmdatagrid/core/editorFocus.ts +8 -4
  35. package/src/tmdatagrid/core/resizePreview.ts +141 -0
  36. package/src/tmdatagrid/core/useSettledTableState.ts +36 -0
  37. package/src/tmdatagrid/index.ts +1 -1
  38. package/src/tmdatagrid/useTMDataGrid.tsx +154 -25
package/dist/index.d.ts CHANGED
@@ -41,28 +41,6 @@ type TMDataGridContextValue = TMDataGridApi<TMDataGridRowData> & {
41
41
  controlSize: TMDataGridSize;
42
42
  };
43
43
  declare function useTMDataGridContext(): TMDataGridContextValue;
44
- /**
45
- * What a control inside a *body* cell should put in its `tabIndex`.
46
- *
47
- * `-1` once cell selection is on, and this is what makes the promise of one tab
48
- * stop true. Without it the browser walks Tab into the checkbox of every
49
- * mounted row - a grid showing twenty rows would be twenty tab stops, and
50
- * scrolling would change how many. Enter or F2 steps into the cell instead,
51
- * which reaches a `-1` control perfectly well.
52
- *
53
- * Header controls are not covered: the header row is not part of cell
54
- * navigation, so its sort buttons and menus stay in the tab order, where they
55
- * are the only way to reach them.
56
- *
57
- * A custom cell renderer with a control in it wants the same:
58
- *
59
- * ```tsx
60
- * cell: ({ row }) => (
61
- * <Button tabIndex={useCellControlTabIndex()} onClick={...}>Open</Button>
62
- * )
63
- * ```
64
- */
65
- declare function useCellControlTabIndex(): 0 | -1;
66
44
  //#endregion
67
45
  //#region .types-tmp/core/columnOptions.d.ts
68
46
  /**
@@ -369,6 +347,16 @@ type TMDataGridEditState = {
369
347
  * consumer and the form is dropped, so this stays empty.
370
348
  */
371
349
  committedRowIds: ReadonlyArray<string>;
350
+ /**
351
+ * The draft store's values, per row - what a committed row *is* to the
352
+ * table. Snapshotted when a row commits (existing and entry rows alike)
353
+ * and kept across a reopen until the row commits again or is dropped, so
354
+ * a row keeps its place in the sort while a second cell is being typed
355
+ * into. The hook feeds these into the table's `data` in place of the
356
+ * consumer's records, which is how sorting, filtering, grouping and
357
+ * aggregates see a draft.
358
+ */
359
+ committedValues: Readonly<Record<string, TMDataGridRowData>>;
372
360
  /**
373
361
  * Rows being created, not yet in `data`. `committed` is the draft store's
374
362
  * add slice: the entry row passed its submit and renders as a value row
@@ -584,6 +572,17 @@ type TMDataGridAddRowsResult = {
584
572
  */
585
573
  open: Array<string>;
586
574
  };
575
+ /** One row of {@link TMDataGridEditApi.getRows}. */
576
+ type TMDataGridEditRowSnapshot<TData extends RowData = TMDataGridRowData> = {
577
+ /** The row's id - `addRow`'s temp id for an entry row. */
578
+ rowId: string;
579
+ /** The row as shown: its draft where a form holds one, else `data`'s value. */
580
+ value: TData;
581
+ /** An entry row, not yet in `data`. */
582
+ isNew: boolean;
583
+ /** Marked deleted, awaiting `saveDrafts`. */
584
+ deleted: boolean;
585
+ };
587
586
  /**
588
587
  * The engine plus its store - `api.edit`.
589
588
  *
@@ -598,6 +597,20 @@ type TMDataGridEditApi<TData extends RowData = TMDataGridRowData> = {
598
597
  readonly state: TMDataGridEditState;
599
598
  /** rowId → live form. The source of truth for everything mid-edit. */
600
599
  getForm: (rowId: string) => TMDataGridRowEditForm | undefined;
600
+ /**
601
+ * The row as shown: its draft values where a form holds one - open or
602
+ * parked in the draft store - else what `data` says. `undefined` when no
603
+ * such row exists. A deletion mark does not change the answer; check
604
+ * `state.deletedRowIds` for that.
605
+ */
606
+ getRowValues: (rowId: string) => TData | undefined;
607
+ /**
608
+ * Every row as shown, nothing filtered out: data rows overlaid with their
609
+ * drafts, entry rows appended, deletion-marked rows included and flagged.
610
+ * Built from the core row model, so it is unfiltered, unsorted and never
611
+ * contains group rows. Filter on `deleted` / `isNew` for the set you want.
612
+ */
613
+ getRows: () => ReadonlyArray<TMDataGridEditRowSnapshot<TData>>;
601
614
  /**
602
615
  * Whether this cell may open an editor: the column maps to a field, nothing
603
616
  * switched it off, and the row takes edits at all.
@@ -1135,11 +1148,11 @@ type TMDataGridFeatureFlags = {
1135
1148
  */
1136
1149
  editDraft: boolean;
1137
1150
  /**
1138
- * Whether a parked entry row stays pinned in the sticky entry block until
1139
- * the draft store is saved - `editing.newRowsSticky`, which needs
1140
- * `editing.draft`. Off by default: a parked row joins the scrolling flow
1141
- * instead, so entering many rows cannot fill the viewport with sticky
1142
- * chrome.
1151
+ * Whether a committed entry row stays pinned in the sticky entry block
1152
+ * until the draft store is saved - `editing.newRowsSticky`, which needs
1153
+ * `editing.draft`. Off by default: a committed row joins the body rows
1154
+ * instead, sorted and filtered with them, so entering many rows cannot
1155
+ * fill the viewport with sticky chrome.
1143
1156
  */
1144
1157
  editNewRowsSticky: boolean;
1145
1158
  /** The generated row-number gutter - `enableRowNumbers`. Off by default. */
@@ -1869,11 +1882,12 @@ type TMDataGridEditingOptions<TData extends RowData> = TMDataGridEditingCallback
1869
1882
  */
1870
1883
  onCommitDrafts?: (args: TMDataGridSaveDraftsArgs<TData>) => void | TMDataGridSaveDraftsResult | Promise<void | TMDataGridSaveDraftsResult>;
1871
1884
  /**
1872
- * Keep parked entry rows pinned in the sticky entry block until
1873
- * the draft store is saved. Off by default: a parked row joins the
1874
- * scrolling flow above the body rows instead - the block a row is
1875
- * *typed* into is always sticky, but parked rows scroll, so
1876
- * entering many cannot fill the viewport with sticky chrome.
1885
+ * Keep committed entry rows pinned in the sticky entry block until
1886
+ * the draft store is saved, out of the body's sort. Off by default:
1887
+ * a committed row joins the body rows instead, sorted and filtered
1888
+ * with them - the block a row is *typed* into is always sticky, but
1889
+ * committed rows scroll, so entering many cannot fill the viewport
1890
+ * with sticky chrome.
1877
1891
  */
1878
1892
  newRowsSticky?: boolean;
1879
1893
  } | {
@@ -3430,4 +3444,4 @@ declare function getSelectableRowIds<TData extends RowData>(row: Row<TMDataGridF
3430
3444
  */
3431
3445
  declare function resolveRowSelectionClick<TData extends RowData>({ rows, rowId, anchorRowId, modifiers, selection, canReplaceSelection }: ResolveRowSelectionClickArgs<TData>): ResolvedRowSelection;
3432
3446
  //#endregion
3433
- export { type BuildCellMatrixArgs, type ColumnStepArgs, DATA_STATE_SLICES, DEFAULT_CELL_EXPORT_OPTIONS, DEFAULT_TMDATAGRID_SIZE, DETAILS_COLUMN_ID, DgAutocompleteFilter, DgDateRangeFilter, DgRangeSliderFilter, DgTriStateFilter, EDIT_COLUMN_ID, FILTER_OPERATOR_LABELS, GROUP_COLUMN_ID, type MoveColumnArgs, PERSIST_PAYLOAD_VERSION, ROW_NUMBER_COLUMN_ID, type ResolveCellMoveArgs, type ResolveRangeBoundsArgs, type ResolveRowSelectionClickArgs, type ResolvedRowSelection, SELECT_COLUMN_ID, SETTINGS_STATE_SLICES, SIZE_CONTROL_SIZE, SIZE_ROW_HEIGHT, TMDATAGRID_LABELS_EN, TMDATAGRID_LABELS_SV, TMDataGrid, type TMDataGridAddRowsOptions, type TMDataGridAddRowsResult, type TMDataGridAggregationName, type TMDataGridApi, TMDataGridBooleanEditor, type TMDataGridCapabilities, type TMDataGridCellCoords, type TMDataGridCellEventArgs, type TMDataGridCellExportOptions, type TMDataGridCellMatrix, type TMDataGridCellNav, type TMDataGridCellPosition, type TMDataGridCellRange, type TMDataGridCellSelectionMode, type TMDataGridColumnCapabilities, type TMDataGridColumnEditOptions, type TMDataGridColumnFilterOptions, type TMDataGridColumnLayout, type TMDataGridColumnMenuItemsArgs, type TMDataGridColumnMenuItemsRenderer, type TMDataGridColumnMeta, type TMDataGridColumnRegion, type TMDataGridColumnType, type TMDataGridContextValue, type TMDataGridDataSlice, TMDataGridDateEditor, type TMDataGridDetailsArgs, type TMDataGridDetailsRenderer, TMDataGridDraftActions, type TMDataGridDraftActionsActions, type TMDataGridDraftActionsControls, type TMDataGridDraftActionsProps, type TMDataGridDraftActionsSlotArgs, type TMDataGridDraftActionsState, type TMDataGridDropSide, type TMDataGridEditApi, type TMDataGridEditChange, type TMDataGridEditCommitArgs, type TMDataGridEditCommitDraftsArgs, type TMDataGridEditField, type TMDataGridEditMode, type TMDataGridEditRowProjection, type TMDataGridEditState, type TMDataGridEditValueMap, type TMDataGridEditValueMapArgs, type TMDataGridEditingOptions, type TMDataGridEditorArgs, type TMDataGridEditorComponent, type TMDataGridExpandAllArgs, type TMDataGridExpandTarget, type TMDataGridFeatureFlags, type TMDataGridFeatures, type TMDataGridFieldValidate, type TMDataGridFilterControlArgs, type TMDataGridFilterControlComponent, type TMDataGridFilterOperator, TMDataGridFilterPills, type TMDataGridFilterPillsProps, type TMDataGridFilterValue, TMDataGridFilterValueInput, type TMDataGridFooterProps, type TMDataGridLabels, type TMDataGridLabelsOverride, TMDataGridMultiSelectEditor, TMDataGridNumberEditor, type TMDataGridOption, type TMDataGridOptionsArgs, type TMDataGridOptionsSource, type TMDataGridPaginationActions, type TMDataGridPaginationApi, type TMDataGridPaginationControls, type TMDataGridPaginationSlotArgs, type TMDataGridPaginationState, type TMDataGridPersistKey, type TMDataGridPersistence, type TMDataGridProps, type TMDataGridQuickSearchMode, type TMDataGridRangeBounds, type TMDataGridRowAddArgs, type TMDataGridRowClickModifiers, type TMDataGridRowContextMenuArgs, type TMDataGridRowContextMenuRenderer, type TMDataGridRowData, type TMDataGridRowDeleteArgs, type TMDataGridRowEditForm, type TMDataGridRowStyle, type TMDataGridRowValidators, type TMDataGridSaveDraftsArgs, type TMDataGridSaveDraftsResult, type TMDataGridSaveOutcomes, type TMDataGridScrollAlign, type TMDataGridScrollToRowArgs, TMDataGridSearch, type TMDataGridSearchProps, TMDataGridSelectEditor, type TMDataGridSelectionMode, type TMDataGridSettingsSlice, type TMDataGridSize, type TMDataGridStorageMode, TMDataGridStringEditor, type TMDataGridTable, type TMDataGridTableMeta, type TMDataGridTableProps, type TMDataGridTableValidateArgs, type TMDataGridTableValidators, type TMDataGridUiActions, type TMDataGridUiState, type TMDataGridUiStore, type UseTMDataGridOptions, aggregateColumn, areAllRowsExpanded, autosizeColumn, boundsCellCount, boundsEdges, buildCellMatrix, buildGridCellMatrix, clearedValueForType, createTMDataGridColumnHelper, downloadTextFile, emptyValueForOperator, exportGridToCsv, formatExportValue, formatFilterLabel, formatGroupValue, fuzzyGlobalFilterFn, getColumnCapabilities, getColumnDefaultOperator, getColumnFilterControl, getColumnLabel, getColumnRegion, getColumnType, getDefaultOperator, getDisplayedRows, getEditFieldName, getGridCapabilities, getGroupDataRows, getOperatorsForType, getSelectableRowIds, getStepTargetColumn, getTMDataGridPaginationApi, isColumnEditableForRow, isColumnReorderable, isControlColumn, isFilterActive, isGeneratedColumn, isPagingActive, isSameCell, isWithinBounds, keepGeneratedColumnsOutermost, measureColumnContentWidth, mergeLabels, moveColumn, moveColumnByStep, normalizeFieldValidate, openColumnFilter, operatorNeedsValue, operatorTakesArrayValue, operatorTakesRangeValue, optionsToComboboxData, readFeatureFlags, resolveCellMove, resolveColumnOptions, resolveExpandAll, resolveRangeBounds, resolveRowSelectionClick, tmDataGridFeatures, toClipboardText, toExcelCsv, useCellControlTabIndex, useTMDataGrid, useTMDataGridContext, writeClipboardText };
3447
+ export { type BuildCellMatrixArgs, type ColumnStepArgs, DATA_STATE_SLICES, DEFAULT_CELL_EXPORT_OPTIONS, DEFAULT_TMDATAGRID_SIZE, DETAILS_COLUMN_ID, DgAutocompleteFilter, DgDateRangeFilter, DgRangeSliderFilter, DgTriStateFilter, EDIT_COLUMN_ID, FILTER_OPERATOR_LABELS, GROUP_COLUMN_ID, type MoveColumnArgs, PERSIST_PAYLOAD_VERSION, ROW_NUMBER_COLUMN_ID, type ResolveCellMoveArgs, type ResolveRangeBoundsArgs, type ResolveRowSelectionClickArgs, type ResolvedRowSelection, SELECT_COLUMN_ID, SETTINGS_STATE_SLICES, SIZE_CONTROL_SIZE, SIZE_ROW_HEIGHT, TMDATAGRID_LABELS_EN, TMDATAGRID_LABELS_SV, TMDataGrid, type TMDataGridAddRowsOptions, type TMDataGridAddRowsResult, type TMDataGridAggregationName, type TMDataGridApi, TMDataGridBooleanEditor, type TMDataGridCapabilities, type TMDataGridCellCoords, type TMDataGridCellEventArgs, type TMDataGridCellExportOptions, type TMDataGridCellMatrix, type TMDataGridCellNav, type TMDataGridCellPosition, type TMDataGridCellRange, type TMDataGridCellSelectionMode, type TMDataGridColumnCapabilities, type TMDataGridColumnEditOptions, type TMDataGridColumnFilterOptions, type TMDataGridColumnLayout, type TMDataGridColumnMenuItemsArgs, type TMDataGridColumnMenuItemsRenderer, type TMDataGridColumnMeta, type TMDataGridColumnRegion, type TMDataGridColumnType, type TMDataGridContextValue, type TMDataGridDataSlice, TMDataGridDateEditor, type TMDataGridDetailsArgs, type TMDataGridDetailsRenderer, TMDataGridDraftActions, type TMDataGridDraftActionsActions, type TMDataGridDraftActionsControls, type TMDataGridDraftActionsProps, type TMDataGridDraftActionsSlotArgs, type TMDataGridDraftActionsState, type TMDataGridDropSide, type TMDataGridEditApi, type TMDataGridEditChange, type TMDataGridEditCommitArgs, type TMDataGridEditCommitDraftsArgs, type TMDataGridEditField, type TMDataGridEditMode, type TMDataGridEditRowProjection, type TMDataGridEditRowSnapshot, type TMDataGridEditState, type TMDataGridEditValueMap, type TMDataGridEditValueMapArgs, type TMDataGridEditingOptions, type TMDataGridEditorArgs, type TMDataGridEditorComponent, type TMDataGridExpandAllArgs, type TMDataGridExpandTarget, type TMDataGridFeatureFlags, type TMDataGridFeatures, type TMDataGridFieldValidate, type TMDataGridFilterControlArgs, type TMDataGridFilterControlComponent, type TMDataGridFilterOperator, TMDataGridFilterPills, type TMDataGridFilterPillsProps, type TMDataGridFilterValue, TMDataGridFilterValueInput, type TMDataGridFooterProps, type TMDataGridLabels, type TMDataGridLabelsOverride, TMDataGridMultiSelectEditor, TMDataGridNumberEditor, type TMDataGridOption, type TMDataGridOptionsArgs, type TMDataGridOptionsSource, type TMDataGridPaginationActions, type TMDataGridPaginationApi, type TMDataGridPaginationControls, type TMDataGridPaginationSlotArgs, type TMDataGridPaginationState, type TMDataGridPersistKey, type TMDataGridPersistence, type TMDataGridProps, type TMDataGridQuickSearchMode, type TMDataGridRangeBounds, type TMDataGridRowAddArgs, type TMDataGridRowClickModifiers, type TMDataGridRowContextMenuArgs, type TMDataGridRowContextMenuRenderer, type TMDataGridRowData, type TMDataGridRowDeleteArgs, type TMDataGridRowEditForm, type TMDataGridRowStyle, type TMDataGridRowValidators, type TMDataGridSaveDraftsArgs, type TMDataGridSaveDraftsResult, type TMDataGridSaveOutcomes, type TMDataGridScrollAlign, type TMDataGridScrollToRowArgs, TMDataGridSearch, type TMDataGridSearchProps, TMDataGridSelectEditor, type TMDataGridSelectionMode, type TMDataGridSettingsSlice, type TMDataGridSize, type TMDataGridStorageMode, TMDataGridStringEditor, type TMDataGridTable, type TMDataGridTableMeta, type TMDataGridTableProps, type TMDataGridTableValidateArgs, type TMDataGridTableValidators, type TMDataGridUiActions, type TMDataGridUiState, type TMDataGridUiStore, type UseTMDataGridOptions, aggregateColumn, areAllRowsExpanded, autosizeColumn, boundsCellCount, boundsEdges, buildCellMatrix, buildGridCellMatrix, clearedValueForType, createTMDataGridColumnHelper, downloadTextFile, emptyValueForOperator, exportGridToCsv, formatExportValue, formatFilterLabel, formatGroupValue, fuzzyGlobalFilterFn, getColumnCapabilities, getColumnDefaultOperator, getColumnFilterControl, getColumnLabel, getColumnRegion, getColumnType, getDefaultOperator, getDisplayedRows, getEditFieldName, getGridCapabilities, getGroupDataRows, getOperatorsForType, getSelectableRowIds, getStepTargetColumn, getTMDataGridPaginationApi, isColumnEditableForRow, isColumnReorderable, isControlColumn, isFilterActive, isGeneratedColumn, isPagingActive, isSameCell, isWithinBounds, keepGeneratedColumnsOutermost, measureColumnContentWidth, mergeLabels, moveColumn, moveColumnByStep, normalizeFieldValidate, openColumnFilter, operatorNeedsValue, operatorTakesArrayValue, operatorTakesRangeValue, optionsToComboboxData, readFeatureFlags, resolveCellMove, resolveColumnOptions, resolveExpandAll, resolveRangeBounds, resolveRowSelectionClick, tmDataGridFeatures, toClipboardText, toExcelCsv, useTMDataGrid, useTMDataGridContext, writeClipboardText };