@rowakit/table 0.3.0 → 0.5.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/README.md +137 -1414
- package/dist/index.cjs +1256 -428
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +49 -4
- package/dist/index.d.ts +49 -4
- package/dist/index.js +1258 -430
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/styles/table.css +56 -1
package/dist/index.d.cts
CHANGED
|
@@ -39,23 +39,45 @@ type FilterValue = {
|
|
|
39
39
|
* Undefined values represent cleared filters.
|
|
40
40
|
*/
|
|
41
41
|
type Filters = Record<string, FilterValue | undefined>;
|
|
42
|
+
/**
|
|
43
|
+
* Sort column definition for multi-column sorting.
|
|
44
|
+
*
|
|
45
|
+
* Stage E adds multi-column sorting support:
|
|
46
|
+
* - sorts is an array of sort configurations (primary, secondary, etc.)
|
|
47
|
+
* - Ctrl/Cmd + click on header adds secondary sort
|
|
48
|
+
* - Click on header performs primary sort only
|
|
49
|
+
*/
|
|
50
|
+
interface SortColumn {
|
|
51
|
+
/** Field name to sort by */
|
|
52
|
+
field: string;
|
|
53
|
+
/** Sort direction */
|
|
54
|
+
direction: 'asc' | 'desc';
|
|
55
|
+
/** Sort priority (0 = primary, 1 = secondary, etc.) */
|
|
56
|
+
priority: number;
|
|
57
|
+
}
|
|
42
58
|
/**
|
|
43
59
|
* Query parameters passed to the fetcher function.
|
|
44
60
|
*
|
|
45
61
|
* All pagination, sorting, and filtering state is passed through this query.
|
|
62
|
+
*
|
|
63
|
+
* Stage E changes:
|
|
64
|
+
* - sort is deprecated in favor of sorts array (backward compatible)
|
|
65
|
+
* - sorts supports multi-column sorting
|
|
46
66
|
*/
|
|
47
67
|
interface FetcherQuery {
|
|
48
68
|
/** Current page number (1-based) */
|
|
49
69
|
page: number;
|
|
50
70
|
/** Number of items per page */
|
|
51
71
|
pageSize: number;
|
|
52
|
-
/** Optional sorting configuration */
|
|
72
|
+
/** Optional sorting configuration - DEPRECATED, use sorts instead */
|
|
53
73
|
sort?: {
|
|
54
74
|
/** Field name to sort by */
|
|
55
75
|
field: string;
|
|
56
76
|
/** Sort direction */
|
|
57
77
|
direction: 'asc' | 'desc';
|
|
58
78
|
};
|
|
79
|
+
/** Multi-column sorting configuration (Stage E+) */
|
|
80
|
+
sorts?: SortColumn[];
|
|
59
81
|
/** Optional filters (omitted when empty) */
|
|
60
82
|
filters?: Filters;
|
|
61
83
|
}
|
|
@@ -215,6 +237,11 @@ interface ActionDef<T> {
|
|
|
215
237
|
disabled?: boolean | ((row: T) => boolean);
|
|
216
238
|
}
|
|
217
239
|
|
|
240
|
+
type ExporterResult = {
|
|
241
|
+
url: string;
|
|
242
|
+
} | Blob;
|
|
243
|
+
type Exporter = (query: FetcherQuery) => Promise<ExporterResult>;
|
|
244
|
+
|
|
218
245
|
/**
|
|
219
246
|
* Column helper factory functions
|
|
220
247
|
*
|
|
@@ -452,6 +479,16 @@ declare const col: {
|
|
|
452
479
|
readonly custom: typeof custom;
|
|
453
480
|
};
|
|
454
481
|
|
|
482
|
+
interface BulkActionDef {
|
|
483
|
+
id: string;
|
|
484
|
+
label: string;
|
|
485
|
+
confirm?: {
|
|
486
|
+
title: string;
|
|
487
|
+
description?: string;
|
|
488
|
+
};
|
|
489
|
+
onClick: (selectedKeys: Array<string | number>) => void;
|
|
490
|
+
}
|
|
491
|
+
|
|
455
492
|
interface SmartTableProps<T> {
|
|
456
493
|
/** Server-side data fetcher function */
|
|
457
494
|
fetcher: Fetcher<T>;
|
|
@@ -473,6 +510,14 @@ interface SmartTableProps<T> {
|
|
|
473
510
|
syncToUrl?: boolean;
|
|
474
511
|
/** Stage C: Enable saved views feature (default: false) */
|
|
475
512
|
enableSavedViews?: boolean;
|
|
513
|
+
/** Stage E: Enable row selection (default: false) */
|
|
514
|
+
enableRowSelection?: boolean;
|
|
515
|
+
/** Stage E: Selection change callback */
|
|
516
|
+
onSelectionChange?: (keys: Array<string | number>) => void;
|
|
517
|
+
/** Stage E: Bulk actions based on selection */
|
|
518
|
+
bulkActions?: BulkActionDef[];
|
|
519
|
+
/** Stage E: Export CSV (server-triggered) */
|
|
520
|
+
exporter?: Exporter;
|
|
476
521
|
}
|
|
477
522
|
/**
|
|
478
523
|
* RowaKitTable - Server-side table component for internal/business apps.
|
|
@@ -525,7 +570,7 @@ interface SmartTableProps<T> {
|
|
|
525
570
|
* }
|
|
526
571
|
* ```
|
|
527
572
|
*/
|
|
528
|
-
declare function RowaKitTable<T>({ fetcher, columns, defaultPageSize, pageSizeOptions, rowKey, className, enableFilters, enableColumnResizing, syncToUrl, enableSavedViews, }: SmartTableProps<T>): react_jsx_runtime.JSX.Element;
|
|
573
|
+
declare function RowaKitTable<T>({ fetcher, columns, defaultPageSize, pageSizeOptions, rowKey, className, enableFilters, enableColumnResizing, syncToUrl, enableSavedViews, enableRowSelection, onSelectionChange, bulkActions, exporter, }: SmartTableProps<T>): react_jsx_runtime.JSX.Element;
|
|
529
574
|
/**
|
|
530
575
|
* @deprecated Use RowaKitTable instead. SmartTable is kept as an alias for backward compatibility.
|
|
531
576
|
*/
|
|
@@ -539,6 +584,6 @@ declare const SmartTable: typeof RowaKitTable;
|
|
|
539
584
|
* @packageDocumentation
|
|
540
585
|
*/
|
|
541
586
|
|
|
542
|
-
declare const VERSION
|
|
587
|
+
declare const VERSION: string;
|
|
543
588
|
|
|
544
|
-
export { type ActionDef, type ActionsColumnDef, type BadgeColumnDef, type BadgeTone, type BaseColumnDef, type BooleanColumnDef, type ColumnDef, type ColumnKind, type CustomColumnDef, type DateColumnDef, type Fetcher, type FetcherQuery, type FetcherResult, type FilterValue, type Filters, type NumberColumnDef, RowaKitTable, SmartTable, type SmartTableProps, type TextColumnDef, VERSION, col };
|
|
589
|
+
export { type ActionDef, type ActionsColumnDef, type BadgeColumnDef, type BadgeTone, type BaseColumnDef, type BooleanColumnDef, type ColumnDef, type ColumnKind, type CustomColumnDef, type DateColumnDef, type Exporter, type ExporterResult, type Fetcher, type FetcherQuery, type FetcherResult, type FilterValue, type Filters, type NumberColumnDef, RowaKitTable, SmartTable, type SmartTableProps, type TextColumnDef, VERSION, col };
|
package/dist/index.d.ts
CHANGED
|
@@ -39,23 +39,45 @@ type FilterValue = {
|
|
|
39
39
|
* Undefined values represent cleared filters.
|
|
40
40
|
*/
|
|
41
41
|
type Filters = Record<string, FilterValue | undefined>;
|
|
42
|
+
/**
|
|
43
|
+
* Sort column definition for multi-column sorting.
|
|
44
|
+
*
|
|
45
|
+
* Stage E adds multi-column sorting support:
|
|
46
|
+
* - sorts is an array of sort configurations (primary, secondary, etc.)
|
|
47
|
+
* - Ctrl/Cmd + click on header adds secondary sort
|
|
48
|
+
* - Click on header performs primary sort only
|
|
49
|
+
*/
|
|
50
|
+
interface SortColumn {
|
|
51
|
+
/** Field name to sort by */
|
|
52
|
+
field: string;
|
|
53
|
+
/** Sort direction */
|
|
54
|
+
direction: 'asc' | 'desc';
|
|
55
|
+
/** Sort priority (0 = primary, 1 = secondary, etc.) */
|
|
56
|
+
priority: number;
|
|
57
|
+
}
|
|
42
58
|
/**
|
|
43
59
|
* Query parameters passed to the fetcher function.
|
|
44
60
|
*
|
|
45
61
|
* All pagination, sorting, and filtering state is passed through this query.
|
|
62
|
+
*
|
|
63
|
+
* Stage E changes:
|
|
64
|
+
* - sort is deprecated in favor of sorts array (backward compatible)
|
|
65
|
+
* - sorts supports multi-column sorting
|
|
46
66
|
*/
|
|
47
67
|
interface FetcherQuery {
|
|
48
68
|
/** Current page number (1-based) */
|
|
49
69
|
page: number;
|
|
50
70
|
/** Number of items per page */
|
|
51
71
|
pageSize: number;
|
|
52
|
-
/** Optional sorting configuration */
|
|
72
|
+
/** Optional sorting configuration - DEPRECATED, use sorts instead */
|
|
53
73
|
sort?: {
|
|
54
74
|
/** Field name to sort by */
|
|
55
75
|
field: string;
|
|
56
76
|
/** Sort direction */
|
|
57
77
|
direction: 'asc' | 'desc';
|
|
58
78
|
};
|
|
79
|
+
/** Multi-column sorting configuration (Stage E+) */
|
|
80
|
+
sorts?: SortColumn[];
|
|
59
81
|
/** Optional filters (omitted when empty) */
|
|
60
82
|
filters?: Filters;
|
|
61
83
|
}
|
|
@@ -215,6 +237,11 @@ interface ActionDef<T> {
|
|
|
215
237
|
disabled?: boolean | ((row: T) => boolean);
|
|
216
238
|
}
|
|
217
239
|
|
|
240
|
+
type ExporterResult = {
|
|
241
|
+
url: string;
|
|
242
|
+
} | Blob;
|
|
243
|
+
type Exporter = (query: FetcherQuery) => Promise<ExporterResult>;
|
|
244
|
+
|
|
218
245
|
/**
|
|
219
246
|
* Column helper factory functions
|
|
220
247
|
*
|
|
@@ -452,6 +479,16 @@ declare const col: {
|
|
|
452
479
|
readonly custom: typeof custom;
|
|
453
480
|
};
|
|
454
481
|
|
|
482
|
+
interface BulkActionDef {
|
|
483
|
+
id: string;
|
|
484
|
+
label: string;
|
|
485
|
+
confirm?: {
|
|
486
|
+
title: string;
|
|
487
|
+
description?: string;
|
|
488
|
+
};
|
|
489
|
+
onClick: (selectedKeys: Array<string | number>) => void;
|
|
490
|
+
}
|
|
491
|
+
|
|
455
492
|
interface SmartTableProps<T> {
|
|
456
493
|
/** Server-side data fetcher function */
|
|
457
494
|
fetcher: Fetcher<T>;
|
|
@@ -473,6 +510,14 @@ interface SmartTableProps<T> {
|
|
|
473
510
|
syncToUrl?: boolean;
|
|
474
511
|
/** Stage C: Enable saved views feature (default: false) */
|
|
475
512
|
enableSavedViews?: boolean;
|
|
513
|
+
/** Stage E: Enable row selection (default: false) */
|
|
514
|
+
enableRowSelection?: boolean;
|
|
515
|
+
/** Stage E: Selection change callback */
|
|
516
|
+
onSelectionChange?: (keys: Array<string | number>) => void;
|
|
517
|
+
/** Stage E: Bulk actions based on selection */
|
|
518
|
+
bulkActions?: BulkActionDef[];
|
|
519
|
+
/** Stage E: Export CSV (server-triggered) */
|
|
520
|
+
exporter?: Exporter;
|
|
476
521
|
}
|
|
477
522
|
/**
|
|
478
523
|
* RowaKitTable - Server-side table component for internal/business apps.
|
|
@@ -525,7 +570,7 @@ interface SmartTableProps<T> {
|
|
|
525
570
|
* }
|
|
526
571
|
* ```
|
|
527
572
|
*/
|
|
528
|
-
declare function RowaKitTable<T>({ fetcher, columns, defaultPageSize, pageSizeOptions, rowKey, className, enableFilters, enableColumnResizing, syncToUrl, enableSavedViews, }: SmartTableProps<T>): react_jsx_runtime.JSX.Element;
|
|
573
|
+
declare function RowaKitTable<T>({ fetcher, columns, defaultPageSize, pageSizeOptions, rowKey, className, enableFilters, enableColumnResizing, syncToUrl, enableSavedViews, enableRowSelection, onSelectionChange, bulkActions, exporter, }: SmartTableProps<T>): react_jsx_runtime.JSX.Element;
|
|
529
574
|
/**
|
|
530
575
|
* @deprecated Use RowaKitTable instead. SmartTable is kept as an alias for backward compatibility.
|
|
531
576
|
*/
|
|
@@ -539,6 +584,6 @@ declare const SmartTable: typeof RowaKitTable;
|
|
|
539
584
|
* @packageDocumentation
|
|
540
585
|
*/
|
|
541
586
|
|
|
542
|
-
declare const VERSION
|
|
587
|
+
declare const VERSION: string;
|
|
543
588
|
|
|
544
|
-
export { type ActionDef, type ActionsColumnDef, type BadgeColumnDef, type BadgeTone, type BaseColumnDef, type BooleanColumnDef, type ColumnDef, type ColumnKind, type CustomColumnDef, type DateColumnDef, type Fetcher, type FetcherQuery, type FetcherResult, type FilterValue, type Filters, type NumberColumnDef, RowaKitTable, SmartTable, type SmartTableProps, type TextColumnDef, VERSION, col };
|
|
589
|
+
export { type ActionDef, type ActionsColumnDef, type BadgeColumnDef, type BadgeTone, type BaseColumnDef, type BooleanColumnDef, type ColumnDef, type ColumnKind, type CustomColumnDef, type DateColumnDef, type Exporter, type ExporterResult, type Fetcher, type FetcherQuery, type FetcherResult, type FilterValue, type Filters, type NumberColumnDef, RowaKitTable, SmartTable, type SmartTableProps, type TextColumnDef, VERSION, col };
|