@jielga/tmdatagrid 2.2.0 → 2.3.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.
Files changed (38) hide show
  1. package/dist/index.d.ts +41 -4
  2. package/dist/index.js +2087 -1968
  3. package/dist/index.js.map +1 -1
  4. package/dist/styles.css +1 -1
  5. package/docs/columns.md +2 -1
  6. package/docs/components.md +1 -0
  7. package/docs/filtering.md +3 -0
  8. package/docs/persistence.md +101 -2
  9. package/docs/row-details.md +5 -0
  10. package/docs/row-interaction.md +1 -1
  11. package/docs/row-styling.md +17 -0
  12. package/docs/use-tm-data-grid.md +6 -2
  13. package/package.json +1 -1
  14. package/skills/appearance/SKILL.md +1 -1
  15. package/skills/cell-selection/SKILL.md +1 -1
  16. package/skills/columns/SKILL.md +3 -3
  17. package/skills/columns/references/columns-api.md +1 -0
  18. package/skills/data/SKILL.md +1 -1
  19. package/skills/editing/SKILL.md +1 -1
  20. package/skills/filtering/SKILL.md +24 -12
  21. package/skills/getting-started/SKILL.md +1 -1
  22. package/skills/grouping/SKILL.md +1 -1
  23. package/skills/migrating-to-2/SKILL.md +1 -1
  24. package/skills/options/SKILL.md +81 -10
  25. package/skills/rows/SKILL.md +18 -9
  26. package/skills/server-side/SKILL.md +1 -1
  27. package/skills/testing/SKILL.md +1 -1
  28. package/skills/testing-components/SKILL.md +1 -1
  29. package/skills/testing-editing/SKILL.md +1 -1
  30. package/src/components/TMDataGridFilterPills.module.css +9 -7
  31. package/src/components/TMDataGridTable.module.css +15 -6
  32. package/src/components/TMDataGridTable.tsx +23 -11
  33. package/src/components/sticky.module.css +27 -7
  34. package/src/core/filterControls.ts +8 -0
  35. package/src/core/filterOperators.ts +13 -0
  36. package/src/core/persistence.ts +322 -26
  37. package/src/index.ts +1 -0
  38. package/src/useTMDataGrid.tsx +95 -14
package/dist/index.d.ts CHANGED
@@ -1037,6 +1037,14 @@ type TMDataGridColumnFilterOptions = {
1037
1037
  * See {@link TMDataGridFilterControlComponent}.
1038
1038
  */
1039
1039
  control?: TMDataGridFilterControlComponent;
1040
+ /**
1041
+ * Whether this column's filter goes into the `persist.urlKey` search param.
1042
+ * Defaults to `true`. `false` keeps it out of the param, on read and on
1043
+ * write. Only has an effect when `urlKey` carries `columnFilters`, and since such
1044
+ * a slice is not stored under `dataKey` either, the filter is then not
1045
+ * persisted anywhere.
1046
+ */
1047
+ url?: boolean;
1040
1048
  };
1041
1049
  //#endregion
1042
1050
  //#region .types-tmp/core/filterSurface.d.ts
@@ -1173,11 +1181,31 @@ type TMDataGridSettingsSlice = (typeof SETTINGS_STATE_SLICES)[number];
1173
1181
  type TMDataGridPersistKey<TSlice extends string> = string | readonly [key: string, slices: readonly TSlice[]];
1174
1182
  /** Same values as Mantine's `StorageType`, which the package does not re-export. */
1175
1183
  type TMDataGridStorageMode = "localStorage" | "sessionStorage";
1184
+ /**
1185
+ * Reads and writes the one URL search param that `urlKey` names. Replaces the
1186
+ * default, which reads `window.location.search` and writes with
1187
+ * `history.replaceState`, for a router that owns the URL.
1188
+ */
1189
+ type TMDataGridUrlStorage = {
1190
+ /** The param's current value, or `null` when the URL has none. */
1191
+ get(name: string): string | null;
1192
+ /** Sets the param to `value`, or removes it when `value` is `null`. */
1193
+ set(name: string, value: string | null): void;
1194
+ };
1176
1195
  type TMDataGridPersistence = {
1177
1196
  /** Key for filters, global filter, sorting and pagination. */
1178
1197
  dataKey?: TMDataGridPersistKey<TMDataGridDataSlice>;
1179
1198
  /** Key for column visibility, sizing, order and pinning. */
1180
1199
  settingsKey?: TMDataGridPersistKey<TMDataGridSettingsSlice>;
1200
+ /**
1201
+ * Search param for data slices kept in the URL, so a link opens the grid on
1202
+ * the same state. Takes the slices it lists away from `dataKey`. The param
1203
+ * holds only the slices that differ from the initial state, and carries no
1204
+ * version stamp.
1205
+ */
1206
+ urlKey?: TMDataGridPersistKey<TMDataGridDataSlice>;
1207
+ /** Where `urlKey` reads and writes. Defaults to the browser's URL. */
1208
+ urlStorage?: TMDataGridUrlStorage;
1181
1209
  /** Which storage area to use. Defaults to `"localStorage"`. */
1182
1210
  storageMode?: TMDataGridStorageMode;
1183
1211
  /** Serializes a payload before it is stored. Defaults to `JSON.stringify`. */
@@ -2310,8 +2338,9 @@ type UseTMDataGridOptions<TData extends RowData> = Omit<TableOptions<TMDataGridF
2310
2338
  getRowId: NonNullable<TableOptions<TMDataGridFeatures, TData>["getRowId"]>;
2311
2339
  }) & {
2312
2340
  /**
2313
- * Restore and persist table state across mounts. Two keys, because the two
2314
- * kinds of state have different lifetimes - see {@link TMDataGridPersistence}.
2341
+ * Restore and persist table state across mounts. Two storage keys, because
2342
+ * the two kinds of state have different lifetimes, and a URL search param
2343
+ * for the data slices a link should carry - see {@link TMDataGridPersistence}.
2315
2344
  *
2316
2345
  * Keep the object referentially stable (module scope or `useMemo`); it is a
2317
2346
  * dependency of the subscription that writes back.
@@ -3321,6 +3350,14 @@ type TMDataGridTableProps<TData extends RowData> = {
3321
3350
  * stay put while the virtualizer mounts and unmounts rows.
3322
3351
  */
3323
3352
  striped?: boolean;
3353
+ /**
3354
+ * Whether a body row takes the hover tint under the pointer. Unset, a row
3355
+ * takes it when the row itself answers a gesture: `selectionMode: "row"`,
3356
+ * a highlight mode, `onRowClick` or `renderRowContextMenu`. Group rows sit
3357
+ * out those gestures and so sit out the tint too. `true` tints every row,
3358
+ * `false` none. The row carries `data-highlight-on-hover` while it applies.
3359
+ */
3360
+ highlightOnHover?: boolean;
3324
3361
  /**
3325
3362
  * Called when the scroll *arrives* at an edge - once per arrival, not per
3326
3363
  * scroll event, and not on mount (the grid starts at the top-left edge).
@@ -3432,7 +3469,7 @@ type TMDataGridTableProps<TData extends RowData> = {
3432
3469
  * no-pagination mode work at any row count. Pagination is opt in through
3433
3470
  * `enablePagination`, or implied by `manualPagination`.
3434
3471
  */
3435
- declare function TMDataGridTable$1<TData extends RowData = TMDataGridRowData>({ onRowClick, onCellClick, onCellDoubleClick, onCellContextMenu, rowClassName, rowStyle, striped, onScrollToTop, onScrollToBottom, onScrollToLeft, onScrollToRight, renderEmptyState, renderRowContextMenu, renderColumnMenuItems, rowContextMenuProps, onReachEnd, reachEndThreshold, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy }: TMDataGridTableProps<TData>): import("react").JSX.Element;
3472
+ declare function TMDataGridTable$1<TData extends RowData = TMDataGridRowData>({ onRowClick, onCellClick, onCellDoubleClick, onCellContextMenu, rowClassName, rowStyle, striped, highlightOnHover, onScrollToTop, onScrollToBottom, onScrollToLeft, onScrollToRight, renderEmptyState, renderRowContextMenu, renderColumnMenuItems, rowContextMenuProps, onReachEnd, reachEndThreshold, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy }: TMDataGridTableProps<TData>): import("react").JSX.Element;
3436
3473
  //#endregion
3437
3474
  //#region .types-tmp/components/TMDataGridToolbar.d.ts
3438
3475
  type TMDataGridToolbarProps = BoxProps & {
@@ -4003,4 +4040,4 @@ declare function getSelectableRowIds<TData extends RowData>(row: Row<TMDataGridF
4003
4040
  */
4004
4041
  declare function resolveRowSelectionClick<TData extends RowData>({ rows, rowId, anchorRowId, modifiers, selection, canReplaceSelection }: ResolveRowSelectionClickArgs<TData>): ResolvedRowSelection;
4005
4042
  //#endregion
4006
- export { type BuildExportDataArgs, type ColumnStepArgs, DATA_STATE_SLICES, DEFAULT_EXPORT_OPTIONS, DEFAULT_TMDATAGRID_SIZE, DETAILS_COLUMN_ID, DgAutocompleteFilter, DgDateRangeFilter, DgRangeSliderFilter, DgTriStateFilter, EDIT_COLUMN_ID, type ExportGridArgs, FILTER_OPERATOR_LABELS, GROUP_COLUMN_ID, type MoveColumnArgs, PERSIST_PAYLOAD_VERSION, ROW_NUMBER_COLUMN_ID, 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 TMDataGridCellEventArgs, type TMDataGridCellPosition, type TMDataGridCellRange, type TMDataGridCellSelectionMode, type TMDataGridClipboardTextOptions, type TMDataGridColSpanArgs, type TMDataGridColumnCapabilities, type TMDataGridColumnEditOptions, type TMDataGridColumnFilter, type TMDataGridColumnFilterOptions, type TMDataGridColumnHelper, type TMDataGridColumnMenuItemsArgs, type TMDataGridColumnMenuItemsRenderer, type TMDataGridColumnMeta, type TMDataGridColumnRegion, type TMDataGridColumnSearchable, type TMDataGridColumnType, type TMDataGridColumnsPanelProps, type TMDataGridCommitAllResult, type TMDataGridContextValue, type TMDataGridCsvFormatOptions, 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 TMDataGridEditField, type TMDataGridEditMode, type TMDataGridEditRowProjection, type TMDataGridEditRowSnapshot, type TMDataGridEditState, type TMDataGridEditValueMap, type TMDataGridEditValueMapArgs, type TMDataGridEditingOptions, type TMDataGridEditorArgs, type TMDataGridEditorComponent, type TMDataGridExpandAllArgs, type TMDataGridExpandTarget, type TMDataGridExportApi, type TMDataGridExportColumns, type TMDataGridExportData, type TMDataGridExportFormat, type TMDataGridExportOptions, type TMDataGridExportPickerRequest, type TMDataGridExportRows, type TMDataGridExportSettings, type TMDataGridExportValueGetter, type TMDataGridExportWriteOptions, type TMDataGridFeatureFlags, type TMDataGridFeatures, type TMDataGridFieldValidate, type TMDataGridFilterControlArgs, type TMDataGridFilterControlComponent, type TMDataGridFilterControlLayout, type TMDataGridFilterFn, type TMDataGridFilterOperator, type TMDataGridFilterPanelLayout, type TMDataGridFilterPanelProps, TMDataGridFilterPills, type TMDataGridFilterPillsProps, type TMDataGridFilterSidebarSide, type TMDataGridFilterSurface, type TMDataGridFilterValue, TMDataGridFilterValueInput, type TMDataGridFilterValueShape, type TMDataGridFiltersOptions, type TMDataGridFiltersSettings, type TMDataGridFooterProps, type TMDataGridJsonFormatOptions, type TMDataGridLabels, type TMDataGridLabelsOverride, type TMDataGridMenuColumnsProps, type TMDataGridMenuExportProps, type TMDataGridMenuProps, 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 TMDataGridSaveDraftsResponse, 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 TMDataGridToolbarProps, type TMDataGridTsvFormatOptions, type TMDataGridUiActions, type TMDataGridUiState, type TMDataGridUiStore, type UseTMDataGridOptions, activeColumnFilters, aggregateColumn, areAllRowsExpanded, autosizeColumn, buildExportData, clearedValueForType, countSelectedExportRows, createTMDataGridColumnHelper, csvExcelFormat, csvFormat, downloadFile, emptyValueForOperator, exportGrid, filterValueShape, formatExportValue, formatFilterLabel, formatGroupValue, fuzzyGlobalFilterFn, getColumnCapabilities, getColumnDefaultOperator, getColumnLabel, getColumnOperators, getColumnRegion, getColumnType, getDisplayedRows, getEditFieldName, getExportableColumns, getGridCapabilities, getGroupDataRows, getOperatorsForType, getSelectableRowIds, getStepTargetColumn, getTMDataGridPaginationApi, guardFormula, hasPendingEdits, isControlColumn, isFilterActive, isGeneratedColumn, isPagingActive, jsonFormat, keepGeneratedColumnsOutermost, matchesFilter, mergeLabels, moveColumn, moveColumnByStep, normalizeFieldValidate, openColumnFilter, operatorNeedsValue, operatorTakesArrayValue, operatorTakesRangeValue, optionsToComboboxData, readFeatureFlags, resolveColumnOptions, resolveExpandAll, resolveExportOptions, resolveRangeBounds, resolveRowSelectionClick, tmDataGridFilterFn, toClipboardText, tsvFormat, useTMDataGrid, useTMDataGridContext, useTMDataGridExport, writeClipboardText, writeExportFile };
4043
+ export { type BuildExportDataArgs, type ColumnStepArgs, DATA_STATE_SLICES, DEFAULT_EXPORT_OPTIONS, DEFAULT_TMDATAGRID_SIZE, DETAILS_COLUMN_ID, DgAutocompleteFilter, DgDateRangeFilter, DgRangeSliderFilter, DgTriStateFilter, EDIT_COLUMN_ID, type ExportGridArgs, FILTER_OPERATOR_LABELS, GROUP_COLUMN_ID, type MoveColumnArgs, PERSIST_PAYLOAD_VERSION, ROW_NUMBER_COLUMN_ID, 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 TMDataGridCellEventArgs, type TMDataGridCellPosition, type TMDataGridCellRange, type TMDataGridCellSelectionMode, type TMDataGridClipboardTextOptions, type TMDataGridColSpanArgs, type TMDataGridColumnCapabilities, type TMDataGridColumnEditOptions, type TMDataGridColumnFilter, type TMDataGridColumnFilterOptions, type TMDataGridColumnHelper, type TMDataGridColumnMenuItemsArgs, type TMDataGridColumnMenuItemsRenderer, type TMDataGridColumnMeta, type TMDataGridColumnRegion, type TMDataGridColumnSearchable, type TMDataGridColumnType, type TMDataGridColumnsPanelProps, type TMDataGridCommitAllResult, type TMDataGridContextValue, type TMDataGridCsvFormatOptions, 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 TMDataGridEditField, type TMDataGridEditMode, type TMDataGridEditRowProjection, type TMDataGridEditRowSnapshot, type TMDataGridEditState, type TMDataGridEditValueMap, type TMDataGridEditValueMapArgs, type TMDataGridEditingOptions, type TMDataGridEditorArgs, type TMDataGridEditorComponent, type TMDataGridExpandAllArgs, type TMDataGridExpandTarget, type TMDataGridExportApi, type TMDataGridExportColumns, type TMDataGridExportData, type TMDataGridExportFormat, type TMDataGridExportOptions, type TMDataGridExportPickerRequest, type TMDataGridExportRows, type TMDataGridExportSettings, type TMDataGridExportValueGetter, type TMDataGridExportWriteOptions, type TMDataGridFeatureFlags, type TMDataGridFeatures, type TMDataGridFieldValidate, type TMDataGridFilterControlArgs, type TMDataGridFilterControlComponent, type TMDataGridFilterControlLayout, type TMDataGridFilterFn, type TMDataGridFilterOperator, type TMDataGridFilterPanelLayout, type TMDataGridFilterPanelProps, TMDataGridFilterPills, type TMDataGridFilterPillsProps, type TMDataGridFilterSidebarSide, type TMDataGridFilterSurface, type TMDataGridFilterValue, TMDataGridFilterValueInput, type TMDataGridFilterValueShape, type TMDataGridFiltersOptions, type TMDataGridFiltersSettings, type TMDataGridFooterProps, type TMDataGridJsonFormatOptions, type TMDataGridLabels, type TMDataGridLabelsOverride, type TMDataGridMenuColumnsProps, type TMDataGridMenuExportProps, type TMDataGridMenuProps, 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 TMDataGridSaveDraftsResponse, 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 TMDataGridToolbarProps, type TMDataGridTsvFormatOptions, type TMDataGridUiActions, type TMDataGridUiState, type TMDataGridUiStore, type TMDataGridUrlStorage, type UseTMDataGridOptions, activeColumnFilters, aggregateColumn, areAllRowsExpanded, autosizeColumn, buildExportData, clearedValueForType, countSelectedExportRows, createTMDataGridColumnHelper, csvExcelFormat, csvFormat, downloadFile, emptyValueForOperator, exportGrid, filterValueShape, formatExportValue, formatFilterLabel, formatGroupValue, fuzzyGlobalFilterFn, getColumnCapabilities, getColumnDefaultOperator, getColumnLabel, getColumnOperators, getColumnRegion, getColumnType, getDisplayedRows, getEditFieldName, getExportableColumns, getGridCapabilities, getGroupDataRows, getOperatorsForType, getSelectableRowIds, getStepTargetColumn, getTMDataGridPaginationApi, guardFormula, hasPendingEdits, isControlColumn, isFilterActive, isGeneratedColumn, isPagingActive, jsonFormat, keepGeneratedColumnsOutermost, matchesFilter, mergeLabels, moveColumn, moveColumnByStep, normalizeFieldValidate, openColumnFilter, operatorNeedsValue, operatorTakesArrayValue, operatorTakesRangeValue, optionsToComboboxData, readFeatureFlags, resolveColumnOptions, resolveExpandAll, resolveExportOptions, resolveRangeBounds, resolveRowSelectionClick, tmDataGridFilterFn, toClipboardText, tsvFormat, useTMDataGrid, useTMDataGridContext, useTMDataGridExport, writeClipboardText, writeExportFile };