@snowpact/react-tanstack-query-table 1.4.4 → 1.5.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 CHANGED
@@ -18,19 +18,14 @@ export declare type ActionButtonVariant = 'default' | 'warning' | 'danger' | 'in
18
18
 
19
19
  export declare const ActionCell: typeof ActionCellInner;
20
20
 
21
- declare function ActionCellInner<T, K>({ item, actions, onAction }: ActionCellProps<T, K>): JSX.Element;
21
+ declare function ActionCellInner<T>({ item, actions, onAction }: ActionCellProps<T>): JSX.Element;
22
22
 
23
- declare interface ActionCellProps<T, K> {
23
+ declare interface ActionCellProps<T> {
24
24
  item: T;
25
- actions: TableAction<T, K>[];
26
- onAction: (action: TableAction<T, K>, item: T) => void;
25
+ actions: TableAction<T>[];
26
+ onAction: (action: TableAction<T>, item: T) => void;
27
27
  }
28
28
 
29
- /**
30
- * Confirm content can be static or a function receiving close helper
31
- */
32
- export declare type ActionConfirmContent = ReactNode | ((helpers: ConfirmCloseHelper) => ReactNode);
33
-
34
29
  export declare type BaseAction = {
35
30
  icon: IconComponent;
36
31
  label: string;
@@ -39,23 +34,15 @@ export declare type BaseAction = {
39
34
  hidden?: boolean;
40
35
  disabled?: boolean;
41
36
  showLabel?: boolean;
42
- confirm?: {
43
- title: string;
44
- content: ActionConfirmContent;
45
- subtitle?: string;
46
- confirmText?: string;
47
- cancelText?: string;
48
- hideButtons?: boolean;
49
- };
50
37
  };
51
38
 
52
39
  /**
53
40
  * Base props shared between SnowClientDataTable and SnowServerDataTable
54
41
  */
55
- export declare interface BaseSnowTableProps<T extends Record<string, unknown>, K> extends DataTableUIOptions<T> {
42
+ export declare interface BaseSnowTableProps<T extends Record<string, unknown>> extends DataTableUIOptions<T> {
56
43
  queryKey: string[];
57
44
  columnConfig: SnowColumnConfig<T>[];
58
- actions?: TableAction<T, K>[];
45
+ actions?: TableAction<T>[];
59
46
  filters?: FilterConfig<T>[];
60
47
  prefilters?: PreFilter[];
61
48
  defaultSortBy?: string;
@@ -94,23 +81,6 @@ export declare type ColumnConfigurationProps<T extends object> = {
94
81
  table: Table<T>;
95
82
  };
96
83
 
97
- export declare interface ConfirmCloseHelper {
98
- close: () => void;
99
- }
100
-
101
- export declare type ConfirmContent = ReactNode | ((helpers: ConfirmCloseHelper) => ReactNode);
102
-
103
- export declare type ConfirmFunction = (options: ConfirmOptions) => Promise<boolean>;
104
-
105
- declare interface ConfirmOptions {
106
- title: string;
107
- subtitle?: string;
108
- content: ConfirmContent;
109
- confirmText?: string;
110
- cancelText?: string;
111
- hideButtons?: boolean;
112
- }
113
-
114
84
  export declare function DataTable<Data extends object>({ data, columns, isLoading, isFetching, mode, pagination: externalPagination, onPaginationChange: externalOnPaginationChange, totalCount: externalTotalCount, globalFilter: externalGlobalFilter, onGlobalFilterChange: externalOnGlobalFilterChange, enableGlobalSearch, filters, columnFilters: externalColumnFilters, onColumnFiltersChange: externalOnColumnFiltersChange, prefilters, activePrefilter, onPrefilterChange, sorting: externalSorting, onSortingChange: externalOnSortingChange, enableSorting, columnVisibility: externalColumnVisibility, onColumnVisibilityChange: externalOnColumnVisibilityChange, enableColumnConfiguration, onRowClick, activeRowId, displayTotalNumber, enableElementLabel, enablePagination, paginationSizes, enableResponsive, texts, onResetFilters, }: DataTableProps<Data>): JSX.Element;
115
85
 
116
86
  export declare type DataTableProps<T extends object> = {
@@ -197,13 +167,6 @@ declare interface DropdownStyles {
197
167
  separator: string;
198
168
  }
199
169
 
200
- export declare type EndpointAction<T, K> = BaseAction & {
201
- type: 'endpoint';
202
- endpoint: (item: T) => Promise<K>;
203
- onSuccess?: (data: K, variables: T, context: unknown) => void;
204
- onError?: (error: ErrorResponse, variables: T, context: unknown) => void;
205
- };
206
-
207
170
  export declare type ErrorResponse = {
208
171
  message: string;
209
172
  status: number;
@@ -350,7 +313,6 @@ export declare const setupSnowTable: (options: SetupSnowTableOptions) => void;
350
313
  export declare interface SetupSnowTableOptions {
351
314
  t: (key: string) => string;
352
315
  LinkComponent: ComponentType<LinkProps>;
353
- confirm: ConfirmFunction;
354
316
  styles?: DeepPartial<SnowTableStyles>;
355
317
  }
356
318
 
@@ -362,12 +324,12 @@ export declare interface SingleFilterDropdownProps<T extends object> {
362
324
  onFilterChange: (key: keyof T, selectedValues: string[]) => void;
363
325
  }
364
326
 
365
- export declare const SnowClientDataTable: <T extends Record<string, unknown>, K>({ queryKey, columnConfig, actions, filters, prefilters, prefilterFn, defaultSortBy, defaultSortOrder, defaultPageSize, persistState, fetchAllItemsEndpoint, ...restProps }: SnowClientDataTableProps<T, K>) => JSX.Element;
327
+ export declare const SnowClientDataTable: <T extends Record<string, unknown>>({ queryKey, columnConfig, actions, filters, prefilters, prefilterFn, defaultSortBy, defaultSortOrder, defaultPageSize, persistState, fetchAllItemsEndpoint, ...restProps }: SnowClientDataTableProps<T>) => JSX.Element;
366
328
 
367
329
  /**
368
330
  * Props for SnowClientDataTable component (client-side filtering/sorting)
369
331
  */
370
- export declare interface SnowClientDataTableProps<T extends Record<string, unknown>, K> extends BaseSnowTableProps<T, K> {
332
+ export declare interface SnowClientDataTableProps<T extends Record<string, unknown>> extends BaseSnowTableProps<T> {
371
333
  fetchAllItemsEndpoint: () => Promise<T[]>;
372
334
  /** Optional function to filter items based on active prefilter */
373
335
  prefilterFn?: (item: T, prefilterId: string) => boolean;
@@ -383,12 +345,12 @@ export declare type SnowColumnConfig<T extends object> = {
383
345
  meta?: ColumnMeta<T, unknown>;
384
346
  };
385
347
 
386
- export declare const SnowServerDataTable: <T extends Record<string, unknown>, K>({ queryKey, columnConfig, actions, filters, prefilters, defaultSortBy, defaultSortOrder, defaultPageSize, persistState, fetchServerEndpoint, ...restProps }: SnowServerDataTableProps<T, K>) => JSX.Element;
348
+ export declare const SnowServerDataTable: <T extends Record<string, unknown>>({ queryKey, columnConfig, actions, filters, prefilters, defaultSortBy, defaultSortOrder, defaultPageSize, persistState, fetchServerEndpoint, ...restProps }: SnowServerDataTableProps<T>) => JSX.Element;
387
349
 
388
350
  /**
389
351
  * Props for SnowServerDataTable component (server-side pagination/filtering/sorting)
390
352
  */
391
- export declare interface SnowServerDataTableProps<T extends Record<string, unknown>, K> extends BaseSnowTableProps<T, K> {
353
+ export declare interface SnowServerDataTableProps<T extends Record<string, unknown>> extends BaseSnowTableProps<T> {
392
354
  fetchServerEndpoint: (params: ServerFetchParams) => Promise<ServerPaginatedResponse<T>>;
393
355
  filters?: FilterConfig<Record<string, unknown>>[];
394
356
  }
@@ -416,7 +378,7 @@ declare interface StateStyles {
416
378
  focus: string;
417
379
  }
418
380
 
419
- export declare type TableAction<T, K> = EndpointAction<T, K> | ClickAction<T> | LinkAction<T> | ((item: T) => EndpointAction<T, K>) | ((item: T) => ClickAction<T>) | ((item: T) => LinkAction<T>);
381
+ export declare type TableAction<T> = ClickAction<T> | LinkAction<T> | ((item: T) => ClickAction<T>) | ((item: T) => LinkAction<T>);
420
382
 
421
383
  declare interface TabsStyles {
422
384
  list: string;
@@ -430,13 +392,13 @@ declare interface TabsStyles {
430
392
  * Extracts the common logic for:
431
393
  * - Transforming SnowColumnConfig into TanStack Table ColumnDef
432
394
  * - Adding action column with ActionCell
433
- * - Handling action execution with confirmation dialogs and mutations
395
+ * - Handling action execution (click actions)
434
396
  */
435
- export declare const useSnowColumns: <T extends Record<string, unknown>, K>({ columnConfig, actions, filters, mode, }: UseSnowColumnsOptions<T, K>) => UseSnowColumnsReturn<T, K>;
397
+ export declare const useSnowColumns: <T extends Record<string, unknown>>({ columnConfig, actions, filters, mode, }: UseSnowColumnsOptions<T>) => UseSnowColumnsReturn<T>;
436
398
 
437
- export declare interface UseSnowColumnsOptions<T extends Record<string, unknown>, K> {
399
+ export declare interface UseSnowColumnsOptions<T extends Record<string, unknown>> {
438
400
  columnConfig: SnowColumnConfig<T>[];
439
- actions?: TableAction<T, K>[];
401
+ actions?: TableAction<T>[];
440
402
  filters?: FilterConfig<T>[];
441
403
  /**
442
404
  * Mode determines how global filter behaves:
@@ -446,9 +408,9 @@ export declare interface UseSnowColumnsOptions<T extends Record<string, unknown>
446
408
  mode: 'client' | 'server';
447
409
  }
448
410
 
449
- export declare interface UseSnowColumnsReturn<T extends Record<string, unknown>, K> {
411
+ export declare interface UseSnowColumnsReturn<T extends Record<string, unknown>> {
450
412
  columns: ColumnDef<T, unknown>[];
451
- handleAction: (action: TableAction<T, K>, item: T) => Promise<void>;
413
+ handleAction: (action: TableAction<T>, item: T) => void;
452
414
  }
453
415
 
454
416
  export declare const useTableStatePersist: ({ enabled, defaultPrefilter, defaultPageSize, defaultSortBy, defaultSortOrder, }: UseTableStatePersistOptions) => {