@mistersee/global-table 0.1.8 → 0.1.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.
- package/README.md +319 -16
- package/dist/Checkbox.d.ts +17 -0
- package/dist/ColumnToggle.d.ts +11 -2
- package/dist/RowActionsMenu.d.ts +16 -0
- package/dist/SeeTable.d.ts +1 -1
- package/dist/SkeletonRows.d.ts +2 -1
- package/dist/global-table.js +1169 -821
- package/dist/icons/MenuIcon.d.ts +4 -0
- package/dist/index.d.ts +4 -1
- package/dist/types.d.ts +64 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,5 @@
|
|
|
1
1
|
export { MisterSeeGlobalTable, INDEX_COLUMN_KEY, DEFAULT_COL_MIN_WIDTH, DEFAULT_COL_MAX_WIDTH, } from './SeeTable';
|
|
2
|
-
export
|
|
2
|
+
export { RowActionsMenu } from './RowActionsMenu';
|
|
3
|
+
export type { RowActionsMenuProps } from './RowActionsMenu';
|
|
4
|
+
export { MenuIcon } from './icons/MenuIcon';
|
|
5
|
+
export type { ColumnDef, RowActionEntry, RowActionItem, RowActionLabel, RowActionSeparator, MisterSeeGlobalTableClassNames, MisterSeeGlobalTableProps, ColumnTogglePosition, SortDirection, SortState, TableFeature, TableFeatureState, StickySide, } from './types';
|
package/dist/types.d.ts
CHANGED
|
@@ -2,6 +2,9 @@ import type { ReactNode } from 'react';
|
|
|
2
2
|
export type StickySide = 'left' | 'right';
|
|
3
3
|
export type ColumnTogglePosition = 'after-skip' | 'before-limit' | 'end' | 'start';
|
|
4
4
|
export type SortDirection = 'asc' | 'desc';
|
|
5
|
+
/** Features users can switch on/off from the Columns popover → Features tab. */
|
|
6
|
+
export type TableFeature = 'rowSelection' | 'columnReorder' | 'sorting';
|
|
7
|
+
export type TableFeatureState = Record<TableFeature, boolean>;
|
|
5
8
|
export interface SortState {
|
|
6
9
|
key: string;
|
|
7
10
|
direction: SortDirection;
|
|
@@ -28,6 +31,30 @@ export interface ColumnDef<T> {
|
|
|
28
31
|
/** Optional custom sort comparison function for client-side sorting */
|
|
29
32
|
sortFn?: (a: T, b: T) => number;
|
|
30
33
|
}
|
|
34
|
+
export interface RowActionItem<T> {
|
|
35
|
+
type?: 'item';
|
|
36
|
+
key: string;
|
|
37
|
+
label: ReactNode;
|
|
38
|
+
/** Leading icon (any React node, e.g. an inline SVG). Sized to 16px. */
|
|
39
|
+
icon?: ReactNode;
|
|
40
|
+
/** Optional trailing hint such as a keyboard shortcut (`⌘E`). */
|
|
41
|
+
shortcut?: ReactNode;
|
|
42
|
+
/** `"danger"` renders the item in red (e.g. Delete). */
|
|
43
|
+
variant?: 'default' | 'danger';
|
|
44
|
+
disabled?: boolean | ((row: T, rowIndex: number) => boolean);
|
|
45
|
+
hidden?: boolean | ((row: T, rowIndex: number) => boolean);
|
|
46
|
+
onSelect: (row: T, rowIndex: number) => void;
|
|
47
|
+
}
|
|
48
|
+
export interface RowActionSeparator {
|
|
49
|
+
type: 'separator';
|
|
50
|
+
key: string;
|
|
51
|
+
}
|
|
52
|
+
export interface RowActionLabel {
|
|
53
|
+
type: 'label';
|
|
54
|
+
key: string;
|
|
55
|
+
label: ReactNode;
|
|
56
|
+
}
|
|
57
|
+
export type RowActionEntry<T> = RowActionItem<T> | RowActionSeparator | RowActionLabel;
|
|
31
58
|
export interface MisterSeeGlobalTableClassNames {
|
|
32
59
|
root?: string;
|
|
33
60
|
toolbar?: string;
|
|
@@ -41,6 +68,10 @@ export interface MisterSeeGlobalTableClassNames {
|
|
|
41
68
|
skeleton?: string;
|
|
42
69
|
columnToggle?: string;
|
|
43
70
|
pagination?: string;
|
|
71
|
+
/** Three-line trigger button of the row actions menu */
|
|
72
|
+
actionsTrigger?: string;
|
|
73
|
+
/** Floating dropdown panel of the row actions menu */
|
|
74
|
+
actionsMenu?: string;
|
|
44
75
|
}
|
|
45
76
|
export interface MisterSeeGlobalTableProps<T extends Record<string, unknown>> {
|
|
46
77
|
columns: ColumnDef<T>[];
|
|
@@ -74,7 +105,15 @@ export interface MisterSeeGlobalTableProps<T extends Record<string, unknown>> {
|
|
|
74
105
|
* If that column is missing, one is appended automatically.
|
|
75
106
|
*/
|
|
76
107
|
renderActions?: (row: T, rowIndex: number) => ReactNode;
|
|
77
|
-
/**
|
|
108
|
+
/**
|
|
109
|
+
* Dropdown menu items for each row, opened from a three-line button in the
|
|
110
|
+
* actions column. Pass an array, or a function to build items per row.
|
|
111
|
+
* Can be combined with `renderActions` (custom nodes render before the menu).
|
|
112
|
+
*/
|
|
113
|
+
rowActions?: RowActionEntry<T>[] | ((row: T, rowIndex: number) => RowActionEntry<T>[]);
|
|
114
|
+
/** Accessible label for the row actions trigger. Default: `"Open row actions"` */
|
|
115
|
+
rowActionsLabel?: string;
|
|
116
|
+
/** Column key used by `renderActions` / `rowActions`. Default: `"actions"` */
|
|
78
117
|
actionsKey?: string;
|
|
79
118
|
/** Header label when auto-creating the actions column. Default: `"Actions"` */
|
|
80
119
|
actionsHeader?: ReactNode;
|
|
@@ -118,6 +157,30 @@ export interface MisterSeeGlobalTableProps<T extends Record<string, unknown>> {
|
|
|
118
157
|
columnTogglePosition?: ColumnTogglePosition;
|
|
119
158
|
/** Label for the column visibility toggle button. Default: `"Columns"` */
|
|
120
159
|
columnsLabel?: ReactNode;
|
|
160
|
+
/**
|
|
161
|
+
* Show a checkbox per row in the leading `#` index column, plus a
|
|
162
|
+
* select-all (current page) checkbox in its header. Default: `false`.
|
|
163
|
+
* Users can also toggle it from the Columns popover → Features tab.
|
|
164
|
+
*/
|
|
165
|
+
enableRowSelection?: boolean;
|
|
166
|
+
/** Controlled selected row ids (ids come from `getRowId`). */
|
|
167
|
+
selectedRowIds?: string[];
|
|
168
|
+
/** Uncontrolled initial selected row ids. */
|
|
169
|
+
defaultSelectedRowIds?: string[];
|
|
170
|
+
/** Called with the selected ids and the matching rows when selection changes. */
|
|
171
|
+
onSelectionChange?: (selectedRowIds: string[], selectedRows: T[]) => void;
|
|
172
|
+
/**
|
|
173
|
+
* Show the Features tab (row checkboxes, drag & drop columns, sorting)
|
|
174
|
+
* in the Columns popover. Default: `true`.
|
|
175
|
+
*/
|
|
176
|
+
showFeatureToggles?: boolean;
|
|
177
|
+
/** Called when a user switches a feature in the Features tab. */
|
|
178
|
+
onFeaturesChange?: (features: TableFeatureState) => void;
|
|
179
|
+
/**
|
|
180
|
+
* Show soft vertical dividers between cells (rows always have a divider).
|
|
181
|
+
* Default: `true`. Pass `false` for horizontal row lines only.
|
|
182
|
+
*/
|
|
183
|
+
bordered?: boolean;
|
|
121
184
|
/**
|
|
122
185
|
* When true, shows a leading index column (`#`) at the front of the table.
|
|
123
186
|
* Numbering follows pagination: `skip + rowIndex + 1`.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mistersee/global-table",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/global-table.js",
|
|
6
6
|
"module": "./dist/global-table.js",
|
|
@@ -49,6 +49,6 @@
|
|
|
49
49
|
"tailwindcss": "^4.3.3",
|
|
50
50
|
"typescript": "~6.0.2",
|
|
51
51
|
"typescript-eslint": "^8.69.0",
|
|
52
|
-
"vite": "^8.3.
|
|
52
|
+
"vite": "^8.3.8"
|
|
53
53
|
}
|
|
54
54
|
}
|