@toolbox-web/grid-react 0.6.0 → 0.8.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 +158 -2
- package/chunks/feature-registry-Y3KvnN54.js +26 -0
- package/chunks/multi-sort-Ae2VVdZb.js +3 -0
- package/features/clipboard.d.ts +18 -0
- package/features/clipboard.d.ts.map +1 -0
- package/features/clipboard.js +6 -0
- package/features/column-virtualization.d.ts +16 -0
- package/features/column-virtualization.d.ts.map +1 -0
- package/features/column-virtualization.js +6 -0
- package/features/context-menu.d.ts +16 -0
- package/features/context-menu.d.ts.map +1 -0
- package/features/context-menu.js +6 -0
- package/features/editing.d.ts +16 -0
- package/features/editing.d.ts.map +1 -0
- package/features/editing.js +3 -0
- package/features/export.d.ts +16 -0
- package/features/export.d.ts.map +1 -0
- package/features/export.js +6 -0
- package/features/filtering.d.ts +16 -0
- package/features/filtering.d.ts.map +1 -0
- package/features/filtering.js +6 -0
- package/features/grouping-columns.d.ts +16 -0
- package/features/grouping-columns.d.ts.map +1 -0
- package/features/grouping-columns.js +6 -0
- package/features/grouping-rows.d.ts +16 -0
- package/features/grouping-rows.d.ts.map +1 -0
- package/features/grouping-rows.js +6 -0
- package/features/index.d.ts +1 -0
- package/features/index.d.ts.map +1 -0
- package/features/index.js +22 -0
- package/features/master-detail.d.ts +18 -0
- package/features/master-detail.d.ts.map +1 -0
- package/features/master-detail.js +6 -0
- package/features/multi-sort.d.ts +22 -0
- package/features/multi-sort.d.ts.map +1 -0
- package/features/pinned-columns.d.ts +16 -0
- package/features/pinned-columns.d.ts.map +1 -0
- package/features/pinned-columns.js +6 -0
- package/features/pinned-rows.d.ts +16 -0
- package/features/pinned-rows.d.ts.map +1 -0
- package/features/pinned-rows.js +6 -0
- package/features/pivot.d.ts +16 -0
- package/features/pivot.d.ts.map +1 -0
- package/features/pivot.js +3 -0
- package/features/print.d.ts +16 -0
- package/features/print.d.ts.map +1 -0
- package/features/print.js +3 -0
- package/features/reorder.d.ts +16 -0
- package/features/reorder.d.ts.map +1 -0
- package/features/reorder.js +6 -0
- package/features/responsive.d.ts +16 -0
- package/features/responsive.d.ts.map +1 -0
- package/features/responsive.js +6 -0
- package/features/row-reorder.d.ts +16 -0
- package/features/row-reorder.d.ts.map +1 -0
- package/features/row-reorder.js +3 -0
- package/features/selection.d.ts +16 -0
- package/features/selection.d.ts.map +1 -0
- package/features/selection.js +3 -0
- package/features/server-side.d.ts +16 -0
- package/features/server-side.d.ts.map +1 -0
- package/features/server-side.js +3 -0
- package/features/sorting.d.ts +1 -0
- package/features/sorting.d.ts.map +1 -0
- package/features/sorting.js +1 -0
- package/features/tree.d.ts +16 -0
- package/features/tree.d.ts.map +1 -0
- package/features/tree.js +6 -0
- package/features/undo-redo.d.ts +18 -0
- package/features/undo-redo.d.ts.map +1 -0
- package/features/undo-redo.js +6 -0
- package/features/visibility.d.ts +16 -0
- package/features/visibility.d.ts.map +1 -0
- package/features/visibility.js +6 -0
- package/index.d.ts +6 -3
- package/index.d.ts.map +1 -1
- package/index.js +625 -430
- package/lib/column-shorthand.d.ts +59 -0
- package/lib/column-shorthand.d.ts.map +1 -0
- package/lib/context-types.d.ts +1 -1
- package/lib/data-grid.d.ts +118 -26
- package/lib/data-grid.d.ts.map +1 -1
- package/lib/event-props.d.ts +305 -0
- package/lib/event-props.d.ts.map +1 -0
- package/lib/feature-props.d.ts +329 -0
- package/lib/feature-props.d.ts.map +1 -0
- package/lib/feature-registry.d.ts +56 -0
- package/lib/feature-registry.d.ts.map +1 -0
- package/lib/grid-column.d.ts +1 -1
- package/lib/grid-detail-panel.d.ts +3 -0
- package/lib/grid-detail-panel.d.ts.map +1 -1
- package/lib/grid-responsive-card.d.ts +3 -0
- package/lib/grid-responsive-card.d.ts.map +1 -1
- package/lib/grid-type-registry.d.ts +1 -1
- package/lib/grid-type-registry.d.ts.map +1 -1
- package/lib/react-column-config.d.ts +1 -1
- package/lib/react-grid-adapter.d.ts +1 -1
- package/lib/react-grid-adapter.d.ts.map +1 -1
- package/lib/use-grid-event.d.ts +23 -19
- package/lib/use-grid-event.d.ts.map +1 -1
- package/lib/use-grid.d.ts +46 -2
- package/lib/use-grid.d.ts.map +1 -1
- package/lib/use-sync-plugins.d.ts +21 -0
- package/lib/use-sync-plugins.d.ts.map +1 -0
- package/package.json +11 -1
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { ColumnConfig } from '@toolbox-web/grid';
|
|
2
|
+
/**
|
|
3
|
+
* Type for column shorthand notation.
|
|
4
|
+
*
|
|
5
|
+
* Supports:
|
|
6
|
+
* - Simple string: `'name'` → `{ field: 'name', header: 'Name' }`
|
|
7
|
+
* - With type: `'salary:number'` → `{ field: 'salary', header: 'Salary', type: 'number' }`
|
|
8
|
+
* - Full config object: `{ field: 'id', header: 'ID', width: 80 }` (passed through)
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```tsx
|
|
12
|
+
* // All equivalent:
|
|
13
|
+
* columns={['id', 'name', 'email']}
|
|
14
|
+
* columns={['id:number', 'name:string', 'email']}
|
|
15
|
+
* columns={[{ field: 'id' }, { field: 'name' }, { field: 'email' }]}
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export type ColumnShorthand<TRow = unknown> = string | ColumnConfig<TRow>;
|
|
19
|
+
/**
|
|
20
|
+
* Parse a column shorthand string into a ColumnConfig.
|
|
21
|
+
*
|
|
22
|
+
* Supports formats:
|
|
23
|
+
* - `'fieldName'` → `{ field: 'fieldName', header: 'Field Name' }`
|
|
24
|
+
* - `'fieldName:type'` → `{ field: 'fieldName', header: 'Field Name', type: 'type' }`
|
|
25
|
+
*
|
|
26
|
+
* @param shorthand - The shorthand string (e.g., 'name', 'salary:number')
|
|
27
|
+
* @returns A ColumnConfig object
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* parseColumnShorthand('name') → { field: 'name', header: 'Name' }
|
|
31
|
+
* parseColumnShorthand('salary:number') → { field: 'salary', header: 'Salary', type: 'number' }
|
|
32
|
+
*/
|
|
33
|
+
export declare function parseColumnShorthand<TRow = unknown>(shorthand: string): ColumnConfig<TRow>;
|
|
34
|
+
/**
|
|
35
|
+
* Normalize an array of column shorthands to ColumnConfig objects.
|
|
36
|
+
*
|
|
37
|
+
* @param columns - Array of column shorthands (strings or ColumnConfig objects)
|
|
38
|
+
* @returns Array of ColumnConfig objects
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```tsx
|
|
42
|
+
* normalizeColumns(['id:number', 'name', { field: 'email', width: 200 }])
|
|
43
|
+
* // Returns:
|
|
44
|
+
* // [
|
|
45
|
+
* // { field: 'id', header: 'ID', type: 'number' },
|
|
46
|
+
* // { field: 'name', header: 'Name' },
|
|
47
|
+
* // { field: 'email', width: 200 }
|
|
48
|
+
* // ]
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
export declare function normalizeColumns<TRow = unknown>(columns: ColumnShorthand<TRow>[]): ColumnConfig<TRow>[];
|
|
52
|
+
/**
|
|
53
|
+
* Check if an array of columns contains any shorthand strings.
|
|
54
|
+
*
|
|
55
|
+
* @param columns - Array to check
|
|
56
|
+
* @returns True if any element is a string shorthand
|
|
57
|
+
*/
|
|
58
|
+
export declare function hasColumnShorthands<TRow>(columns: ColumnShorthand<TRow>[]): boolean;
|
|
59
|
+
//# sourceMappingURL=column-shorthand.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"column-shorthand.d.ts","sourceRoot":"","sources":["../../../../libs/grid-react/src/lib/column-shorthand.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEtD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,eAAe,CAAC,IAAI,GAAG,OAAO,IAAI,MAAM,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;AA2C1E;;;;;;;;;;;;;GAaG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,GAAG,OAAO,EAAE,SAAS,EAAE,MAAM,GAAG,YAAY,CAAC,IAAI,CAAC,CAsB1F;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,GAAG,OAAO,EAAE,OAAO,EAAE,eAAe,CAAC,IAAI,CAAC,EAAE,GAAG,YAAY,CAAC,IAAI,CAAC,EAAE,CAOvG;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,OAAO,EAAE,eAAe,CAAC,IAAI,CAAC,EAAE,GAAG,OAAO,CAEnF"}
|
package/lib/context-types.d.ts
CHANGED
package/lib/data-grid.d.ts
CHANGED
|
@@ -1,10 +1,21 @@
|
|
|
1
|
-
import { ColumnConfig, DataGridElement, GridConfig } from '
|
|
1
|
+
import { BaseGridPlugin, ColumnConfig, DataGridElement, GridConfig } from '@toolbox-web/grid';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
|
+
import { ColumnShorthand } from './column-shorthand';
|
|
4
|
+
import { EventProps } from './event-props';
|
|
5
|
+
import { AllFeatureProps } from './feature-props';
|
|
3
6
|
import { ReactGridConfig } from './react-column-config';
|
|
4
7
|
/**
|
|
5
8
|
* Props for the DataGrid component.
|
|
9
|
+
*
|
|
10
|
+
* @template TRow - The row data type
|
|
11
|
+
*
|
|
12
|
+
* Combines:
|
|
13
|
+
* - Core props (rows, columns, gridConfig)
|
|
14
|
+
* - Feature props (selection, editing, filtering, etc.) - plugins loaded via side-effect imports
|
|
15
|
+
* - Event props (onCellClick, onSelectionChange, etc.)
|
|
16
|
+
* - SSR props (ssr)
|
|
6
17
|
*/
|
|
7
|
-
export interface DataGridProps<TRow = unknown> {
|
|
18
|
+
export interface DataGridProps<TRow = unknown> extends AllFeatureProps<TRow>, EventProps<TRow> {
|
|
8
19
|
/** Row data to display */
|
|
9
20
|
rows: TRow[];
|
|
10
21
|
/**
|
|
@@ -23,11 +34,98 @@ export interface DataGridProps<TRow = unknown> {
|
|
|
23
34
|
* ```
|
|
24
35
|
*/
|
|
25
36
|
gridConfig?: ReactGridConfig<TRow>;
|
|
26
|
-
/**
|
|
27
|
-
|
|
37
|
+
/**
|
|
38
|
+
* Column definitions. Supports shorthand syntax for quick definitions.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```tsx
|
|
42
|
+
* // Shorthand strings (auto-generate headers from field names)
|
|
43
|
+
* columns={['id:number', 'name', 'email', 'salary:currency']}
|
|
44
|
+
*
|
|
45
|
+
* // Mixed: shorthand + full config
|
|
46
|
+
* columns={['id:number', 'name', { field: 'status', editable: true }]}
|
|
47
|
+
*
|
|
48
|
+
* // Full config objects (standard usage)
|
|
49
|
+
* columns={[{ field: 'id', type: 'number' }, { field: 'name' }]}
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
columns?: ColumnShorthand<TRow>[];
|
|
53
|
+
/**
|
|
54
|
+
* Default column properties applied to all columns.
|
|
55
|
+
* Individual column definitions override these defaults.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```tsx
|
|
59
|
+
* <DataGrid
|
|
60
|
+
* columnDefaults={{ sortable: true, resizable: true }}
|
|
61
|
+
* columns={[
|
|
62
|
+
* { field: 'id', sortable: false }, // Override: not sortable
|
|
63
|
+
* { field: 'name' }, // Inherits: sortable, resizable
|
|
64
|
+
* ]}
|
|
65
|
+
* />
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
columnDefaults?: Partial<ColumnConfig<TRow>>;
|
|
28
69
|
/** Fit mode for column sizing */
|
|
29
70
|
fitMode?: 'stretch' | 'fit-columns' | 'auto-fit';
|
|
30
|
-
/**
|
|
71
|
+
/**
|
|
72
|
+
* Grid-wide sorting toggle.
|
|
73
|
+
* When false, disables sorting for all columns regardless of their individual `sortable` setting.
|
|
74
|
+
* When true (default), columns with `sortable: true` can be sorted.
|
|
75
|
+
*
|
|
76
|
+
* For multi-column sorting, also add the `multiSort` prop.
|
|
77
|
+
*
|
|
78
|
+
* @default true
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* ```tsx
|
|
82
|
+
* // Disable all sorting
|
|
83
|
+
* <DataGrid sortable={false} />
|
|
84
|
+
*
|
|
85
|
+
* // Enable sorting with multi-sort
|
|
86
|
+
* <DataGrid sortable multiSort />
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
89
|
+
sortable?: boolean;
|
|
90
|
+
/**
|
|
91
|
+
* Grid-wide filtering toggle.
|
|
92
|
+
* When false, disables filtering for all columns regardless of their individual `filterable` setting.
|
|
93
|
+
* When true (default), columns with `filterable: true` can be filtered.
|
|
94
|
+
*
|
|
95
|
+
* Requires the FilteringPlugin to be loaded (via `filtering` prop or feature import).
|
|
96
|
+
*
|
|
97
|
+
* @default true
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* ```tsx
|
|
101
|
+
* // Disable all filtering
|
|
102
|
+
* <DataGrid filterable={false} filtering />
|
|
103
|
+
*
|
|
104
|
+
* // Enable filtering (default)
|
|
105
|
+
* <DataGrid filterable filtering />
|
|
106
|
+
* ```
|
|
107
|
+
*/
|
|
108
|
+
filterable?: boolean;
|
|
109
|
+
/**
|
|
110
|
+
* Grid-wide selection toggle.
|
|
111
|
+
* When false, disables selection for all rows/cells.
|
|
112
|
+
* When true (default), selection is enabled based on plugin mode.
|
|
113
|
+
*
|
|
114
|
+
* Requires the SelectionPlugin to be loaded (via `selection` prop or feature import).
|
|
115
|
+
*
|
|
116
|
+
* @default true
|
|
117
|
+
*
|
|
118
|
+
* @example
|
|
119
|
+
* ```tsx
|
|
120
|
+
* // Disable all selection
|
|
121
|
+
* <DataGrid selectable={false} selection="range" />
|
|
122
|
+
*
|
|
123
|
+
* // Enable selection (default)
|
|
124
|
+
* <DataGrid selectable selection="range" />
|
|
125
|
+
* ```
|
|
126
|
+
*/
|
|
127
|
+
selectable?: boolean;
|
|
128
|
+
/** Edit trigger mode - DEPRECATED: use `editing` prop instead */
|
|
31
129
|
editOn?: 'click' | 'dblclick' | 'none';
|
|
32
130
|
/** Custom CSS styles to inject into grid shadow DOM */
|
|
33
131
|
customStyles?: string;
|
|
@@ -37,29 +135,23 @@ export interface DataGridProps<TRow = unknown> {
|
|
|
37
135
|
style?: React.CSSProperties;
|
|
38
136
|
/** Children (GridColumn components for custom renderers/editors) */
|
|
39
137
|
children?: ReactNode;
|
|
138
|
+
/**
|
|
139
|
+
* Escape hatch: manually provide plugin instances.
|
|
140
|
+
* When provided, feature props for those plugins are ignored.
|
|
141
|
+
* Useful for advanced configurations not covered by feature props.
|
|
142
|
+
*
|
|
143
|
+
* @example
|
|
144
|
+
* ```tsx
|
|
145
|
+
* import { SelectionPlugin } from '@toolbox-web/grid/plugins/selection';
|
|
146
|
+
*
|
|
147
|
+
* <DataGrid
|
|
148
|
+
* plugins={[new SelectionPlugin({ mode: 'range', checkbox: true })]}
|
|
149
|
+
* />
|
|
150
|
+
* ```
|
|
151
|
+
*/
|
|
152
|
+
plugins?: BaseGridPlugin[];
|
|
40
153
|
/** Fired when rows change (sorting, editing, etc.) */
|
|
41
154
|
onRowsChange?: (rows: TRow[]) => void;
|
|
42
|
-
/** Fired when a cell value is edited */
|
|
43
|
-
onCellEdit?: (event: CustomEvent<{
|
|
44
|
-
row: TRow;
|
|
45
|
-
field: string;
|
|
46
|
-
oldValue: unknown;
|
|
47
|
-
newValue: unknown;
|
|
48
|
-
}>) => void;
|
|
49
|
-
/** Fired when a row is clicked */
|
|
50
|
-
onRowClick?: (event: CustomEvent<{
|
|
51
|
-
row: TRow;
|
|
52
|
-
rowIndex: number;
|
|
53
|
-
}>) => void;
|
|
54
|
-
/** Fired when column state changes (resize, reorder, visibility) */
|
|
55
|
-
onColumnStateChange?: (event: CustomEvent<{
|
|
56
|
-
columns: ColumnConfig<TRow>[];
|
|
57
|
-
}>) => void;
|
|
58
|
-
/** Fired when sort changes */
|
|
59
|
-
onSortChange?: (event: CustomEvent<{
|
|
60
|
-
field: string;
|
|
61
|
-
direction: 'asc' | 'desc';
|
|
62
|
-
} | null>) => void;
|
|
63
155
|
}
|
|
64
156
|
/**
|
|
65
157
|
* Ref handle for the DataGrid component.
|
package/lib/data-grid.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-grid.d.ts","sourceRoot":"","sources":["../../../../libs/grid-react/src/lib/data-grid.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"data-grid.d.ts","sourceRoot":"","sources":["../../../../libs/grid-react/src/lib/data-grid.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEnG,OAAO,EASL,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AACf,OAAO,aAAa,CAAC;AACrB,OAAO,EAAoB,KAAK,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC5E,OAAO,EAAkB,KAAK,UAAU,EAAE,MAAM,eAAe,CAAC;AAChE,OAAO,EAAE,KAAK,eAAe,EAAqB,MAAM,iBAAiB,CAAC;AAI1E,OAAO,EAA0B,KAAK,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAoHrF;;;;;;;;;;GAUG;AACH,MAAM,WAAW,aAAa,CAAC,IAAI,GAAG,OAAO,CAAE,SAAQ,eAAe,CAAC,IAAI,CAAC,EAAE,UAAU,CAAC,IAAI,CAAC;IAC5F,0BAA0B;IAC1B,IAAI,EAAE,IAAI,EAAE,CAAC;IACb;;;;;;;;;;;;;;OAcG;IACH,UAAU,CAAC,EAAE,eAAe,CAAC,IAAI,CAAC,CAAC;IACnC;;;;;;;;;;;;;;OAcG;IACH,OAAO,CAAC,EAAE,eAAe,CAAC,IAAI,CAAC,EAAE,CAAC;IAClC;;;;;;;;;;;;;;OAcG;IACH,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KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5C,6BAA6B;IAC7B,cAAc,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAClD,+BAA+B;IAC/B,gBAAgB,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;CACxC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoEG;AACH,eAAO,MAAM,QAAQ,EAkaf,CAAC,IAAI,GAAG,OAAO,EAAE,KAAK,EAAE,aAAa,CAAC,IAAI,CAAC,GAAG;IAAE,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAA;CAAE,KAAK,KAAK,CAAC,YAAY,CAAC"}
|
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
import { CellActivateDetail, CellChangeDetail, CellClickDetail, CellCommitDetail, ColumnMoveDetail, ColumnResizeDetail, ColumnVisibilityDetail, CopyDetail, DetailExpandDetail, ExportCompleteDetail, FilterChangeDetail, GridColumnState, GroupToggleDetail, PasteDetail, PrintCompleteDetail, PrintStartDetail, ResponsiveChangeDetail, RowClickDetail, RowCommitDetail, RowMoveDetail, SelectionChangeDetail, SortChangeDetail, TreeExpandDetail, UndoRedoDetail } from '@toolbox-web/grid/all';
|
|
2
|
+
/**
|
|
3
|
+
* Event handler type with unwrapped detail.
|
|
4
|
+
* Pattern: `(detail: T, event?: CustomEvent) => void`
|
|
5
|
+
*/
|
|
6
|
+
export type EventHandler<T> = (detail: T, event?: CustomEvent<T>) => void;
|
|
7
|
+
/**
|
|
8
|
+
* Event handler props for grid events.
|
|
9
|
+
* All handlers receive the unwrapped detail as first argument,
|
|
10
|
+
* with optional access to the full CustomEvent for preventDefault().
|
|
11
|
+
*
|
|
12
|
+
* @template TRow - The row data type
|
|
13
|
+
*/
|
|
14
|
+
export interface EventProps<TRow = unknown> {
|
|
15
|
+
/**
|
|
16
|
+
* Fired when a cell is clicked.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```tsx
|
|
20
|
+
* onCellClick={(detail) => console.log('Clicked:', detail.field, detail.value)}
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
onCellClick?: EventHandler<CellClickDetail<TRow>>;
|
|
24
|
+
/**
|
|
25
|
+
* Fired when a row is clicked.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```tsx
|
|
29
|
+
* onRowClick={(detail) => navigateTo(`/employees/${detail.row.id}`)}
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
onRowClick?: EventHandler<RowClickDetail<TRow>>;
|
|
33
|
+
/**
|
|
34
|
+
* Fired when a cell is activated (Enter key or double-click).
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```tsx
|
|
38
|
+
* onCellActivate={(detail) => openEditor(detail.field, detail.row)}
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
onCellActivate?: EventHandler<CellActivateDetail<TRow>>;
|
|
42
|
+
/**
|
|
43
|
+
* Fired when a cell value changes (before commit).
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```tsx
|
|
47
|
+
* onCellChange={(detail) => validateChange(detail)}
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
onCellChange?: EventHandler<CellChangeDetail<TRow>>;
|
|
51
|
+
/**
|
|
52
|
+
* Fired when a cell edit is committed.
|
|
53
|
+
* Cancelable - call `event.preventDefault()` to reject the edit.
|
|
54
|
+
*
|
|
55
|
+
* @requires `import '@toolbox-web/grid-react/features/editing';`
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```tsx
|
|
59
|
+
* onCellCommit={(detail, event) => {
|
|
60
|
+
* if (!isValid(detail.value)) {
|
|
61
|
+
* event?.preventDefault();
|
|
62
|
+
* showError('Invalid value');
|
|
63
|
+
* }
|
|
64
|
+
* }}
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
onCellCommit?: EventHandler<CellCommitDetail<TRow>>;
|
|
68
|
+
/**
|
|
69
|
+
* Fired when all pending row edits are committed.
|
|
70
|
+
*
|
|
71
|
+
* @requires `import '@toolbox-web/grid-react/features/editing';`
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```tsx
|
|
75
|
+
* onRowCommit={(detail) => saveToServer(detail.row)}
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
onRowCommit?: EventHandler<RowCommitDetail<TRow>>;
|
|
79
|
+
/**
|
|
80
|
+
* Fired when sort state changes.
|
|
81
|
+
*
|
|
82
|
+
* @requires `import '@toolbox-web/grid-react/features/sorting';`
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* ```tsx
|
|
86
|
+
* onSortChange={(detail) => console.log('Sort:', detail.field, detail.direction)}
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
89
|
+
onSortChange?: EventHandler<SortChangeDetail>;
|
|
90
|
+
/**
|
|
91
|
+
* Fired when filter values change.
|
|
92
|
+
*
|
|
93
|
+
* @requires `import '@toolbox-web/grid-react/features/filtering';`
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* ```tsx
|
|
97
|
+
* onFilterChange={(detail) => console.log('Filters:', detail.activeFilters)}
|
|
98
|
+
* ```
|
|
99
|
+
*/
|
|
100
|
+
onFilterChange?: EventHandler<FilterChangeDetail>;
|
|
101
|
+
/**
|
|
102
|
+
* Fired when a column is resized.
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* ```tsx
|
|
106
|
+
* onColumnResize={(detail) => console.log('Resized:', detail.field, detail.width)}
|
|
107
|
+
* ```
|
|
108
|
+
*/
|
|
109
|
+
onColumnResize?: EventHandler<ColumnResizeDetail>;
|
|
110
|
+
/**
|
|
111
|
+
* Fired when a column is moved via drag-and-drop.
|
|
112
|
+
* Cancelable - call `event.preventDefault()` to cancel the move.
|
|
113
|
+
*
|
|
114
|
+
* @requires `import '@toolbox-web/grid-react/features/reorder';`
|
|
115
|
+
*
|
|
116
|
+
* @example
|
|
117
|
+
* ```tsx
|
|
118
|
+
* onColumnMove={(detail, event) => {
|
|
119
|
+
* if (detail.column.field === 'id') {
|
|
120
|
+
* event?.preventDefault(); // Don't allow moving ID column
|
|
121
|
+
* }
|
|
122
|
+
* }}
|
|
123
|
+
* ```
|
|
124
|
+
*/
|
|
125
|
+
onColumnMove?: EventHandler<ColumnMoveDetail>;
|
|
126
|
+
/**
|
|
127
|
+
* Fired when column visibility changes.
|
|
128
|
+
*
|
|
129
|
+
* @requires `import '@toolbox-web/grid-react/features/visibility';`
|
|
130
|
+
*
|
|
131
|
+
* @example
|
|
132
|
+
* ```tsx
|
|
133
|
+
* onColumnVisibility={(detail) => {
|
|
134
|
+
* console.log(detail.hidden ? 'Hidden:' : 'Shown:', detail.field);
|
|
135
|
+
* }}
|
|
136
|
+
* ```
|
|
137
|
+
*/
|
|
138
|
+
onColumnVisibility?: EventHandler<ColumnVisibilityDetail>;
|
|
139
|
+
/**
|
|
140
|
+
* Fired when column state changes (resize, reorder, visibility).
|
|
141
|
+
* Useful for persisting column state.
|
|
142
|
+
*
|
|
143
|
+
* @example
|
|
144
|
+
* ```tsx
|
|
145
|
+
* onColumnStateChange={(state) => saveToLocalStorage('gridState', state)}
|
|
146
|
+
* ```
|
|
147
|
+
*/
|
|
148
|
+
onColumnStateChange?: EventHandler<GridColumnState>;
|
|
149
|
+
/**
|
|
150
|
+
* Fired when selection changes.
|
|
151
|
+
*
|
|
152
|
+
* @requires `import '@toolbox-web/grid-react/features/selection';`
|
|
153
|
+
*
|
|
154
|
+
* @example
|
|
155
|
+
* ```tsx
|
|
156
|
+
* onSelectionChange={(detail) => {
|
|
157
|
+
* console.log('Selected ranges:', detail.ranges);
|
|
158
|
+
* console.log('Mode:', detail.mode);
|
|
159
|
+
* }}
|
|
160
|
+
* ```
|
|
161
|
+
*/
|
|
162
|
+
onSelectionChange?: EventHandler<SelectionChangeDetail>;
|
|
163
|
+
/**
|
|
164
|
+
* Fired when a row is moved via drag-and-drop.
|
|
165
|
+
* Cancelable - call `event.preventDefault()` to cancel the move.
|
|
166
|
+
*
|
|
167
|
+
* @requires `import '@toolbox-web/grid-react/features/row-reorder';`
|
|
168
|
+
*
|
|
169
|
+
* @example
|
|
170
|
+
* ```tsx
|
|
171
|
+
* onRowMove={(detail, event) => {
|
|
172
|
+
* if (!canMove(detail.row)) {
|
|
173
|
+
* event?.preventDefault();
|
|
174
|
+
* }
|
|
175
|
+
* }}
|
|
176
|
+
* ```
|
|
177
|
+
*/
|
|
178
|
+
onRowMove?: EventHandler<RowMoveDetail<TRow>>;
|
|
179
|
+
/**
|
|
180
|
+
* Fired when a group is expanded or collapsed.
|
|
181
|
+
*
|
|
182
|
+
* @requires `import '@toolbox-web/grid-react/features/grouping-rows';`
|
|
183
|
+
*
|
|
184
|
+
* @example
|
|
185
|
+
* ```tsx
|
|
186
|
+
* onGroupToggle={(detail) => {
|
|
187
|
+
* console.log(detail.expanded ? 'Expanded' : 'Collapsed', detail.key);
|
|
188
|
+
* }}
|
|
189
|
+
* ```
|
|
190
|
+
*/
|
|
191
|
+
onGroupToggle?: EventHandler<GroupToggleDetail>;
|
|
192
|
+
/**
|
|
193
|
+
* Fired when a tree node is expanded.
|
|
194
|
+
*
|
|
195
|
+
* @requires `import '@toolbox-web/grid-react/features/tree';`
|
|
196
|
+
*
|
|
197
|
+
* @example
|
|
198
|
+
* ```tsx
|
|
199
|
+
* onTreeExpand={(detail) => console.log('Expanded:', detail.row)}
|
|
200
|
+
* ```
|
|
201
|
+
*/
|
|
202
|
+
onTreeExpand?: EventHandler<TreeExpandDetail<TRow>>;
|
|
203
|
+
/**
|
|
204
|
+
* Fired when a detail panel is expanded or collapsed.
|
|
205
|
+
*
|
|
206
|
+
* @requires `import '@toolbox-web/grid-react/features/master-detail';`
|
|
207
|
+
*
|
|
208
|
+
* @example
|
|
209
|
+
* ```tsx
|
|
210
|
+
* onDetailExpand={(detail) => {
|
|
211
|
+
* if (detail.expanded) loadDetailData(detail.rowId);
|
|
212
|
+
* }}
|
|
213
|
+
* ```
|
|
214
|
+
*/
|
|
215
|
+
onDetailExpand?: EventHandler<DetailExpandDetail>;
|
|
216
|
+
/**
|
|
217
|
+
* Fired when responsive mode changes (table ↔ card).
|
|
218
|
+
*
|
|
219
|
+
* @requires `import '@toolbox-web/grid-react/features/responsive';`
|
|
220
|
+
*
|
|
221
|
+
* @example
|
|
222
|
+
* ```tsx
|
|
223
|
+
* onResponsiveChange={(detail) => {
|
|
224
|
+
* console.log('Mode:', detail.mode); // 'table' | 'card'
|
|
225
|
+
* }}
|
|
226
|
+
* ```
|
|
227
|
+
*/
|
|
228
|
+
onResponsiveChange?: EventHandler<ResponsiveChangeDetail>;
|
|
229
|
+
/**
|
|
230
|
+
* Fired when cells are copied to clipboard.
|
|
231
|
+
*
|
|
232
|
+
* @requires `import '@toolbox-web/grid-react/features/clipboard';`
|
|
233
|
+
*
|
|
234
|
+
* @example
|
|
235
|
+
* ```tsx
|
|
236
|
+
* onCopy={(detail) => console.log('Copied:', detail.text)}
|
|
237
|
+
* ```
|
|
238
|
+
*/
|
|
239
|
+
onCopy?: EventHandler<CopyDetail>;
|
|
240
|
+
/**
|
|
241
|
+
* Fired when cells are pasted from clipboard.
|
|
242
|
+
*
|
|
243
|
+
* @requires `import '@toolbox-web/grid-react/features/clipboard';`
|
|
244
|
+
*
|
|
245
|
+
* @example
|
|
246
|
+
* ```tsx
|
|
247
|
+
* onPaste={(detail) => console.log('Pasted:', detail.affectedCells.length, 'cells')}
|
|
248
|
+
* ```
|
|
249
|
+
*/
|
|
250
|
+
onPaste?: EventHandler<PasteDetail>;
|
|
251
|
+
/**
|
|
252
|
+
* Fired when undo/redo is performed.
|
|
253
|
+
*
|
|
254
|
+
* @requires `import '@toolbox-web/grid-react/features/undo-redo';`
|
|
255
|
+
*
|
|
256
|
+
* @example
|
|
257
|
+
* ```tsx
|
|
258
|
+
* onUndoRedo={(detail) => console.log(detail.type, '- Can undo:', detail.canUndo)}
|
|
259
|
+
* ```
|
|
260
|
+
*/
|
|
261
|
+
onUndoRedo?: EventHandler<UndoRedoDetail>;
|
|
262
|
+
/**
|
|
263
|
+
* Fired when export completes.
|
|
264
|
+
*
|
|
265
|
+
* @requires `import '@toolbox-web/grid-react/features/export';`
|
|
266
|
+
*
|
|
267
|
+
* @example
|
|
268
|
+
* ```tsx
|
|
269
|
+
* onExportComplete={(detail) => console.log('Exported:', detail.filename)}
|
|
270
|
+
* ```
|
|
271
|
+
*/
|
|
272
|
+
onExportComplete?: EventHandler<ExportCompleteDetail>;
|
|
273
|
+
/**
|
|
274
|
+
* Fired when print starts.
|
|
275
|
+
*
|
|
276
|
+
* @requires `import '@toolbox-web/grid-react/features/print';`
|
|
277
|
+
*
|
|
278
|
+
* @example
|
|
279
|
+
* ```tsx
|
|
280
|
+
* onPrintStart={(detail) => console.log('Printing:', detail.rowCount, 'rows')}
|
|
281
|
+
* ```
|
|
282
|
+
*/
|
|
283
|
+
onPrintStart?: EventHandler<PrintStartDetail>;
|
|
284
|
+
/**
|
|
285
|
+
* Fired when print completes.
|
|
286
|
+
*
|
|
287
|
+
* @requires `import '@toolbox-web/grid-react/features/print';`
|
|
288
|
+
*
|
|
289
|
+
* @example
|
|
290
|
+
* ```tsx
|
|
291
|
+
* onPrintComplete={() => console.log('Print complete')}
|
|
292
|
+
* ```
|
|
293
|
+
*/
|
|
294
|
+
onPrintComplete?: EventHandler<PrintCompleteDetail>;
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* Map of event handler prop names to their corresponding event names.
|
|
298
|
+
* Used internally to wire up event listeners.
|
|
299
|
+
*/
|
|
300
|
+
export declare const EVENT_PROP_MAP: Record<keyof EventProps, string>;
|
|
301
|
+
/**
|
|
302
|
+
* Gets all event prop names.
|
|
303
|
+
*/
|
|
304
|
+
export declare function getEventPropNames(): (keyof EventProps)[];
|
|
305
|
+
//# sourceMappingURL=event-props.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-props.d.ts","sourceRoot":"","sources":["../../../../libs/grid-react/src/lib/event-props.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAGH,OAAO,KAAK,EACV,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,kBAAkB,EAClB,sBAAsB,EACtB,UAAU,EACV,kBAAkB,EAClB,oBAAoB,EACpB,kBAAkB,EAClB,eAAe,EACf,iBAAiB,EACjB,WAAW,EACX,mBAAmB,EACnB,gBAAgB,EAChB,sBAAsB,EACtB,cAAc,EACd,eAAe,EACf,aAAa,EACb,qBAAqB,EACrB,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,EACf,MAAM,uBAAuB,CAAC;AAE/B;;;GAGG;AACH,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,KAAK,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;AAE1E;;;;;;GAMG;AACH,MAAM,WAAW,UAAU,CAAC,IAAI,GAAG,OAAO;IAKxC;;;;;;;OAOG;IACH,WAAW,CAAC,EAAE,YAAY,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC;IAElD;;;;;;;OAOG;IACH,UAAU,CAAC,EAAE,YAAY,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC;IAEhD;;;;;;;OAOG;IACH,cAAc,CAAC,EAAE,YAAY,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC,CAAC;IAExD;;;;;;;OAOG;IACH,YAAY,CAAC,EAAE,YAAY,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC;IAMpD;;;;;;;;;;;;;;;OAeG;IACH,YAAY,CAAC,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