@coreui/react-data-grid 0.1.0-rc.0 → 0.2.0-rc.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 +3 -2
- package/dist/cjs/CDataGrid.d.ts +11 -1
- package/dist/cjs/CDataGrid.js +228 -43
- package/dist/cjs/CDataGrid.js.map +1 -1
- package/dist/cjs/CDataGridBody.d.ts +9 -4
- package/dist/cjs/CDataGridBody.js +54 -11
- package/dist/cjs/CDataGridBody.js.map +1 -1
- package/dist/cjs/CDataGridColumnChooser.d.ts +2 -3
- package/dist/cjs/CDataGridColumnChooser.js.map +1 -1
- package/dist/cjs/CDataGridFilterMenu.d.ts +2 -3
- package/dist/cjs/CDataGridFilterMenu.js.map +1 -1
- package/dist/cjs/CDataGridHeader.d.ts +4 -4
- package/dist/cjs/CDataGridHeader.js +25 -66
- package/dist/cjs/CDataGridHeader.js.map +1 -1
- package/dist/cjs/CDataGridHeaderMenu.d.ts +2 -3
- package/dist/cjs/CDataGridHeaderMenu.js.map +1 -1
- package/dist/cjs/CDataGridPagination.d.ts +2 -3
- package/dist/cjs/CDataGridPagination.js +1 -1
- package/dist/cjs/CDataGridPagination.js.map +1 -1
- package/dist/cjs/CDataGridToolbar.d.ts +8 -6
- package/dist/cjs/CDataGridToolbar.js +7 -2
- package/dist/cjs/CDataGridToolbar.js.map +1 -1
- package/dist/cjs/columns.d.ts +38 -12
- package/dist/cjs/columns.js +51 -31
- package/dist/cjs/columns.js.map +1 -1
- package/dist/cjs/features.d.ts +52 -0
- package/dist/cjs/features.js +66 -0
- package/dist/cjs/features.js.map +1 -0
- package/dist/cjs/icons.d.ts +6 -4
- package/dist/cjs/icons.js +12 -8
- package/dist/cjs/icons.js.map +1 -1
- package/dist/cjs/index.d.ts +2 -1
- package/dist/cjs/index.js +3 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/pinning.d.ts +4 -5
- package/dist/cjs/pinning.js +10 -8
- package/dist/cjs/pinning.js.map +1 -1
- package/dist/cjs/toolbar.d.ts +3 -2
- package/dist/cjs/toolbar.js +5 -2
- package/dist/cjs/toolbar.js.map +1 -1
- package/dist/cjs/types.d.ts +81 -29
- package/dist/esm/CDataGrid.d.ts +11 -1
- package/dist/esm/CDataGrid.mjs +231 -46
- package/dist/esm/CDataGrid.mjs.map +1 -1
- package/dist/esm/CDataGridBody.d.ts +9 -4
- package/dist/esm/CDataGridBody.mjs +55 -12
- package/dist/esm/CDataGridBody.mjs.map +1 -1
- package/dist/esm/CDataGridColumnChooser.d.ts +2 -3
- package/dist/esm/CDataGridColumnChooser.mjs.map +1 -1
- package/dist/esm/CDataGridFilterMenu.d.ts +2 -3
- package/dist/esm/CDataGridFilterMenu.mjs.map +1 -1
- package/dist/esm/CDataGridHeader.d.ts +4 -4
- package/dist/esm/CDataGridHeader.mjs +27 -68
- package/dist/esm/CDataGridHeader.mjs.map +1 -1
- package/dist/esm/CDataGridHeaderMenu.d.ts +2 -3
- package/dist/esm/CDataGridHeaderMenu.mjs.map +1 -1
- package/dist/esm/CDataGridPagination.d.ts +2 -3
- package/dist/esm/CDataGridPagination.mjs +1 -1
- package/dist/esm/CDataGridPagination.mjs.map +1 -1
- package/dist/esm/CDataGridToolbar.d.ts +8 -6
- package/dist/esm/CDataGridToolbar.mjs +7 -2
- package/dist/esm/CDataGridToolbar.mjs.map +1 -1
- package/dist/esm/columns.d.ts +38 -12
- package/dist/esm/columns.mjs +51 -32
- package/dist/esm/columns.mjs.map +1 -1
- package/dist/esm/features.d.ts +52 -0
- package/dist/esm/features.mjs +63 -0
- package/dist/esm/features.mjs.map +1 -0
- package/dist/esm/icons.d.ts +6 -4
- package/dist/esm/icons.mjs +7 -5
- package/dist/esm/icons.mjs.map +1 -1
- package/dist/esm/index.d.ts +2 -1
- package/dist/esm/index.mjs +1 -0
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/pinning.d.ts +4 -5
- package/dist/esm/pinning.mjs +10 -8
- package/dist/esm/pinning.mjs.map +1 -1
- package/dist/esm/toolbar.d.ts +3 -2
- package/dist/esm/toolbar.mjs +5 -2
- package/dist/esm/toolbar.mjs.map +1 -1
- package/dist/esm/types.d.ts +81 -29
- package/package.json +6 -6
package/dist/cjs/types.d.ts
CHANGED
|
@@ -4,28 +4,33 @@
|
|
|
4
4
|
* License (https://coreui.io/pro/license/)
|
|
5
5
|
* --------------------------------------------------------------------------
|
|
6
6
|
*/
|
|
7
|
-
import type { DataGridColumn, DataGridColumnSizingOptions, DataGridDataRequest, DataGridDataResponse, DataGridEditCommitEvent, DataGridItem, DataGridLabels, DataGridPaginationOptions, DataGridRowSelectionOptions, DataGridSortingOptions } from '@coreui/data-grid';
|
|
8
|
-
import type {
|
|
9
|
-
import type { Column, ColumnFiltersState, ColumnOrderState, ColumnPinningState, ColumnSizingState, PaginationState, RowSelectionState, SortingState, Table, VisibilityState } from '@tanstack/react-table';
|
|
7
|
+
import type { DataGridColumn, DataGridColumnSizingOptions, DataGridDataRequest, DataGridDataResponse, DataGridEditCommitEvent, DataGridExportOptions, DataGridInfiniteScrollOptions, DataGridItem, DataGridLabels, DataGridPaginationOptions, DataGridRowSelectionOptions, DataGridSortingOptions } from '@coreui/data-grid';
|
|
8
|
+
import type { Column, ColumnFiltersState, ColumnOrderState, ColumnPinningState, ColumnSizingState, ColumnVisibilityState, PaginationState, ReactTable, Row, RowSelectionState, SortingState, TableFeatures } from '@tanstack/react-table';
|
|
10
9
|
import type { ComponentType, CSSProperties, HTMLAttributes, ReactNode, Ref } from 'react';
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
import type { DataGridFeatures } from './features';
|
|
11
|
+
export type CDataGridTable<TFeatures extends TableFeatures = DataGridFeatures> = ReactTable<TFeatures, DataGridItem>;
|
|
12
|
+
export type CDataGridRow<TFeatures extends TableFeatures = DataGridFeatures> = Row<TFeatures, DataGridItem>;
|
|
13
|
+
export type CDataGridColumnInstance<TFeatures extends TableFeatures = DataGridFeatures> = Column<TFeatures, DataGridItem, unknown>;
|
|
14
|
+
export type CDataGridColumnPinning = Partial<ColumnPinningState>;
|
|
15
|
+
export interface CDataGridSlotProps<TFeatures extends TableFeatures = DataGridFeatures> {
|
|
16
|
+
table: CDataGridTable<TFeatures>;
|
|
13
17
|
labels: DataGridLabels;
|
|
14
18
|
}
|
|
15
|
-
export interface CDataGridSlots {
|
|
16
|
-
toolbar: ComponentType<CDataGridSlotProps
|
|
17
|
-
pagination: ComponentType<CDataGridSlotProps
|
|
18
|
-
empty: ComponentType<CDataGridSlotProps
|
|
19
|
+
export interface CDataGridSlots<TFeatures extends TableFeatures = DataGridFeatures> {
|
|
20
|
+
toolbar: ComponentType<CDataGridSlotProps<TFeatures>>;
|
|
21
|
+
pagination: ComponentType<CDataGridSlotProps<TFeatures>>;
|
|
22
|
+
empty: ComponentType<CDataGridSlotProps<TFeatures>>;
|
|
19
23
|
}
|
|
20
24
|
export interface CDataGridToolbarOptions {
|
|
21
25
|
columns?: boolean;
|
|
22
|
-
export?: boolean |
|
|
26
|
+
export?: boolean | DataGridExportOptions;
|
|
23
27
|
history?: boolean;
|
|
28
|
+
print?: boolean;
|
|
24
29
|
search?: boolean;
|
|
25
30
|
}
|
|
26
|
-
export interface CDataGridColumnFilterProps {
|
|
27
|
-
column:
|
|
28
|
-
table:
|
|
31
|
+
export interface CDataGridColumnFilterProps<TFeatures extends TableFeatures = DataGridFeatures> {
|
|
32
|
+
column: CDataGridColumnInstance<TFeatures>;
|
|
33
|
+
table: CDataGridTable<TFeatures>;
|
|
29
34
|
labels: DataGridLabels;
|
|
30
35
|
}
|
|
31
36
|
export interface CDataGridEditorHandle {
|
|
@@ -43,13 +48,19 @@ export interface CDataGridEditorProps {
|
|
|
43
48
|
cancel: () => void;
|
|
44
49
|
handleRef: (handle: CDataGridEditorHandle | null) => void;
|
|
45
50
|
}
|
|
46
|
-
export interface CDataGridColumn extends Omit<DataGridColumn, 'editor' | 'filter' | 'render' | 'style'> {
|
|
51
|
+
export interface CDataGridColumn<TFeatures extends TableFeatures = DataGridFeatures> extends Omit<DataGridColumn, 'editor' | 'filter' | 'render' | 'style'> {
|
|
47
52
|
editor?: ComponentType<CDataGridEditorProps>;
|
|
48
53
|
editorPopup?: boolean;
|
|
49
|
-
filter?: ComponentType<CDataGridColumnFilterProps
|
|
54
|
+
filter?: ComponentType<CDataGridColumnFilterProps<TFeatures>>;
|
|
50
55
|
render?: (item: DataGridItem, index: number) => ReactNode;
|
|
51
56
|
style?: CSSProperties;
|
|
52
57
|
}
|
|
58
|
+
export interface CDataGridRowOrderEvent {
|
|
59
|
+
items: DataGridItem[];
|
|
60
|
+
item: DataGridItem;
|
|
61
|
+
oldIndex: number;
|
|
62
|
+
newIndex: number;
|
|
63
|
+
}
|
|
53
64
|
export interface CDataGridMenuAction {
|
|
54
65
|
key: string;
|
|
55
66
|
label: string;
|
|
@@ -63,11 +74,19 @@ export interface CDataGridColumnMenuContext {
|
|
|
63
74
|
defaultActions: CDataGridMenuAction[];
|
|
64
75
|
}
|
|
65
76
|
export type CDataGridColumnMenuBuilder = (context: CDataGridColumnMenuContext) => CDataGridMenuAction[];
|
|
66
|
-
export interface CDataGridProps extends HTMLAttributes<HTMLDivElement> {
|
|
77
|
+
export interface CDataGridProps<TFeatures extends TableFeatures = DataGridFeatures> extends HTMLAttributes<HTMLDivElement> {
|
|
78
|
+
/**
|
|
79
|
+
* Measures each rendered row instead of trusting `rowHeight`, so rows grow with their content (wrapping cells, custom renderers). `rowHeight` stays the estimate for rows that have not been rendered yet. Requires virtualization.
|
|
80
|
+
*/
|
|
81
|
+
autoRowHeight?: boolean;
|
|
67
82
|
/**
|
|
68
83
|
* APG grid keyboard navigation — `role="grid"`, a roving-tabindex active cell, and arrow-key movement across header and data cells.
|
|
69
84
|
*/
|
|
70
85
|
cellNavigation?: boolean;
|
|
86
|
+
/**
|
|
87
|
+
* Spreadsheet-style cell ranges — shift-click, drag and shift+arrows, with Ctrl/Cmd+C copying the range as TSV and Ctrl/Cmd+A selecting everything. Implies `cellNavigation`.
|
|
88
|
+
*/
|
|
89
|
+
cellSelection?: boolean;
|
|
71
90
|
/**
|
|
72
91
|
* Renders a filter row in the header with an input per filterable column.
|
|
73
92
|
*/
|
|
@@ -85,9 +104,9 @@ export interface CDataGridProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
85
104
|
*/
|
|
86
105
|
columnOrder?: boolean | ColumnOrderState;
|
|
87
106
|
/**
|
|
88
|
-
* Freezes columns (by `key`) to the
|
|
107
|
+
* Freezes columns (by `key`) to the start/end edge with sticky positioning; `true` enables the feature with no initial pins.
|
|
89
108
|
*/
|
|
90
|
-
columnPinning?: boolean |
|
|
109
|
+
columnPinning?: boolean | CDataGridColumnPinning;
|
|
91
110
|
/**
|
|
92
111
|
* Enables column resize handles; `mode` controls whether widths update while dragging (`'onChange'`, the default) or on release (`'onEnd'`).
|
|
93
112
|
*/
|
|
@@ -95,11 +114,11 @@ export interface CDataGridProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
95
114
|
/**
|
|
96
115
|
* Enables hiding/showing columns via `column.toggleVisibility()`; an object sets the initial visibility.
|
|
97
116
|
*/
|
|
98
|
-
columnVisibility?: boolean |
|
|
117
|
+
columnVisibility?: boolean | ColumnVisibilityState;
|
|
99
118
|
/**
|
|
100
119
|
* Column definitions.
|
|
101
120
|
*/
|
|
102
|
-
columns: CDataGridColumn
|
|
121
|
+
columns: Array<CDataGridColumn<TFeatures>>;
|
|
103
122
|
/**
|
|
104
123
|
* Server-side mode: the grid requests data on every sorting/filter/page change; implies pagination.
|
|
105
124
|
*/
|
|
@@ -112,6 +131,10 @@ export interface CDataGridProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
112
131
|
* Content (ReactNode) shown when no rows match.
|
|
113
132
|
*/
|
|
114
133
|
empty?: ReactNode;
|
|
134
|
+
/**
|
|
135
|
+
* The registered TanStack feature set — pass `dataGridLiteFeatures` (or a custom `tableFeatures({...})` set) so the app bundle only carries the features it uses; defaults to the full `dataGridFeatures`.
|
|
136
|
+
*/
|
|
137
|
+
features?: TFeatures;
|
|
115
138
|
/** Icon for the per-column filter button. */
|
|
116
139
|
filterIcon?: ReactNode;
|
|
117
140
|
/**
|
|
@@ -126,6 +149,10 @@ export interface CDataGridProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
126
149
|
* Custom hide-column menu action icon (ReactNode) replacing the default one.
|
|
127
150
|
*/
|
|
128
151
|
hideColumnIcon?: ReactNode;
|
|
152
|
+
/**
|
|
153
|
+
* Appends each loaded page to the rows already in view instead of replacing them; requires `dataProvider` and `virtualization`, cannot be combined with `pagination`.
|
|
154
|
+
*/
|
|
155
|
+
infiniteScroll?: boolean | DataGridInfiniteScrollOptions;
|
|
129
156
|
/**
|
|
130
157
|
* Stable row id — required for selection to survive sorting and filtering.
|
|
131
158
|
*/
|
|
@@ -141,11 +168,11 @@ export interface CDataGridProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
141
168
|
/**
|
|
142
169
|
* Custom move-left menu action icon (ReactNode) replacing the default one.
|
|
143
170
|
*/
|
|
144
|
-
|
|
171
|
+
moveStartIcon?: ReactNode;
|
|
145
172
|
/**
|
|
146
173
|
* Custom move-right menu action icon (ReactNode) replacing the default one.
|
|
147
174
|
*/
|
|
148
|
-
|
|
175
|
+
moveEndIcon?: ReactNode;
|
|
149
176
|
/**
|
|
150
177
|
* Fires when the data provider rejects, with the error (server-side mode).
|
|
151
178
|
*/
|
|
@@ -189,6 +216,16 @@ export interface CDataGridProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
189
216
|
/**
|
|
190
217
|
* Fires when a column is resized, with the TanStack columnSizing state.
|
|
191
218
|
*/
|
|
219
|
+
/**
|
|
220
|
+
* Fires when a row is dragged to a new position, with the reordered `items` array ready to assign — the grid never mutates `items` itself.
|
|
221
|
+
*/
|
|
222
|
+
/**
|
|
223
|
+
* Fires after Ctrl/Cmd+C copies a cell selection, with the text written to the clipboard.
|
|
224
|
+
*/
|
|
225
|
+
onCellCopy?: (event: {
|
|
226
|
+
text: string;
|
|
227
|
+
}) => void;
|
|
228
|
+
onRowOrderChange?: (event: CDataGridRowOrderEvent) => void;
|
|
192
229
|
onSizingChange?: (columnSizing: ColumnSizingState) => void;
|
|
193
230
|
/**
|
|
194
231
|
* Fires when sorting changes, with the TanStack sorting state.
|
|
@@ -197,7 +234,7 @@ export interface CDataGridProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
197
234
|
/**
|
|
198
235
|
* Fires when column visibility changes, with the TanStack columnVisibility state.
|
|
199
236
|
*/
|
|
200
|
-
onVisibilityChange?: (columnVisibility:
|
|
237
|
+
onVisibilityChange?: (columnVisibility: ColumnVisibilityState) => void;
|
|
201
238
|
/**
|
|
202
239
|
* Extra rows rendered above and below the visible window.
|
|
203
240
|
*/
|
|
@@ -209,15 +246,27 @@ export interface CDataGridProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
209
246
|
/**
|
|
210
247
|
* Custom pin-left menu action icon (ReactNode) replacing the default one.
|
|
211
248
|
*/
|
|
212
|
-
|
|
249
|
+
pinStartIcon?: ReactNode;
|
|
213
250
|
/**
|
|
214
251
|
* Custom pin-right menu action icon (ReactNode) replacing the default one.
|
|
215
252
|
*/
|
|
216
|
-
|
|
253
|
+
pinEndIcon?: ReactNode;
|
|
254
|
+
/**
|
|
255
|
+
* Heading printed above the table when the print action runs; omitted when unset.
|
|
256
|
+
*/
|
|
257
|
+
printTitle?: string;
|
|
258
|
+
/**
|
|
259
|
+
* Custom row drag-handle icon (ReactNode) replacing the default grip.
|
|
260
|
+
*/
|
|
261
|
+
rowHandleIcon?: ReactNode;
|
|
217
262
|
/**
|
|
218
263
|
* Estimated row height in px used by the virtualizer.
|
|
219
264
|
*/
|
|
220
265
|
rowHeight?: number;
|
|
266
|
+
/**
|
|
267
|
+
* Adds a drag handle per row for reordering; the grid emits `onRowOrderChange` with the reordered array instead of mutating `items`.
|
|
268
|
+
*/
|
|
269
|
+
rowOrder?: boolean;
|
|
221
270
|
/**
|
|
222
271
|
* Checkbox selection with select-all and shift+click ranges.
|
|
223
272
|
*/
|
|
@@ -225,7 +274,7 @@ export interface CDataGridProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
225
274
|
/**
|
|
226
275
|
* Replaces built-in chrome — each slot is a component rendered with `{ table, labels }`.
|
|
227
276
|
*/
|
|
228
|
-
slots?: Partial<CDataGridSlots
|
|
277
|
+
slots?: Partial<CDataGridSlots<TFeatures>>;
|
|
229
278
|
/**
|
|
230
279
|
* Custom ascending sort indicator icon (ReactNode) replacing the default one.
|
|
231
280
|
*/
|
|
@@ -253,7 +302,7 @@ export interface CDataGridProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
253
302
|
/**
|
|
254
303
|
* Ref that receives the TanStack table instance.
|
|
255
304
|
*/
|
|
256
|
-
tableRef?: Ref<
|
|
305
|
+
tableRef?: Ref<CDataGridTable<TFeatures>>;
|
|
257
306
|
/**
|
|
258
307
|
* Adds a built-in toolbar above the grid — `true` enables every action whose feature is on (column chooser, CSV export, global search); an object picks each individually.
|
|
259
308
|
*/
|
|
@@ -266,6 +315,8 @@ export interface CDataGridProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
266
315
|
* Custom toolbar export button icon (ReactNode) replacing the default one.
|
|
267
316
|
*/
|
|
268
317
|
toolbarExportIcon?: ReactNode;
|
|
318
|
+
/** Icon for the toolbar's print button. */
|
|
319
|
+
toolbarPrintIcon?: ReactNode;
|
|
269
320
|
/**
|
|
270
321
|
* Custom toolbar redo button icon (ReactNode) replacing the default one.
|
|
271
322
|
*/
|
|
@@ -283,5 +334,6 @@ export interface CDataGridProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
283
334
|
*/
|
|
284
335
|
virtualization?: boolean;
|
|
285
336
|
}
|
|
286
|
-
export { type Column, type ColumnFiltersState, type ColumnOrderState, type ColumnPinningState, type ColumnSizingState, type PaginationState, type RowSelectionState, type SortingState, type Table, type
|
|
287
|
-
export { type
|
|
337
|
+
export { type Column, type ColumnFiltersState, type ColumnOrderState, type ColumnPinningPosition, type ColumnPinningState, type ColumnSizingState, type ColumnVisibilityState, type PaginationState, type Row, type RowSelectionState, type SortingState, type Table, type TableFeatures } from '@tanstack/react-table';
|
|
338
|
+
export { type DataGridFeatures, type DataGridLiteFeatures } from './features';
|
|
339
|
+
export { type DataGridColumnFilterValue, type DataGridColumnSizingOptions, type DataGridDataRequest, type DataGridDataResponse, type DataGridEditableOptions, type DataGridEditCommitEvent, type DataGridEditorType, type DataGridFilterCondition, type DataGridFilterOperator, type DataGridFilterType, type DataGridInfiniteScrollOptions, type DataGridItem, type DataGridLabels, type DataGridPaginationOptions, type DataGridRowSelectionOptions, type DataGridSortingOptions, type DataGridState } from '@coreui/data-grid';
|
package/dist/esm/CDataGrid.d.ts
CHANGED
|
@@ -4,5 +4,15 @@
|
|
|
4
4
|
* License (https://coreui.io/pro/license/)
|
|
5
5
|
* --------------------------------------------------------------------------
|
|
6
6
|
*/
|
|
7
|
+
import { type TableFeatures } from '@tanstack/react-table';
|
|
8
|
+
import { type ReactNode, type Ref } from 'react';
|
|
9
|
+
import { type DataGridFeatures } from './features';
|
|
7
10
|
import type { CDataGridProps } from './types';
|
|
8
|
-
|
|
11
|
+
interface CDataGridComponent {
|
|
12
|
+
<TFeatures extends TableFeatures = DataGridFeatures>(props: CDataGridProps<TFeatures> & {
|
|
13
|
+
ref?: Ref<HTMLDivElement>;
|
|
14
|
+
}): ReactNode;
|
|
15
|
+
displayName?: string;
|
|
16
|
+
}
|
|
17
|
+
export declare const CDataGrid: CDataGridComponent;
|
|
18
|
+
export {};
|