@coreui/react-data-grid 0.1.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.
Files changed (104) hide show
  1. package/LICENSE +3 -0
  2. package/README.md +33 -0
  3. package/dist/cjs/CDataGrid.d.ts +8 -0
  4. package/dist/cjs/CDataGrid.js +903 -0
  5. package/dist/cjs/CDataGrid.js.map +1 -0
  6. package/dist/cjs/CDataGridBody.d.ts +40 -0
  7. package/dist/cjs/CDataGridBody.js +144 -0
  8. package/dist/cjs/CDataGridBody.js.map +1 -0
  9. package/dist/cjs/CDataGridCellEditor.d.ts +8 -0
  10. package/dist/cjs/CDataGridCellEditor.js +67 -0
  11. package/dist/cjs/CDataGridCellEditor.js.map +1 -0
  12. package/dist/cjs/CDataGridColumnChooser.d.ts +23 -0
  13. package/dist/cjs/CDataGridColumnChooser.js +71 -0
  14. package/dist/cjs/CDataGridColumnChooser.js.map +1 -0
  15. package/dist/cjs/CDataGridFilterMenu.d.ts +22 -0
  16. package/dist/cjs/CDataGridFilterMenu.js +177 -0
  17. package/dist/cjs/CDataGridFilterMenu.js.map +1 -0
  18. package/dist/cjs/CDataGridHeader.d.ts +36 -0
  19. package/dist/cjs/CDataGridHeader.js +232 -0
  20. package/dist/cjs/CDataGridHeader.js.map +1 -0
  21. package/dist/cjs/CDataGridHeaderMenu.d.ts +29 -0
  22. package/dist/cjs/CDataGridHeaderMenu.js +127 -0
  23. package/dist/cjs/CDataGridHeaderMenu.js.map +1 -0
  24. package/dist/cjs/CDataGridPagination.d.ts +18 -0
  25. package/dist/cjs/CDataGridPagination.js +39 -0
  26. package/dist/cjs/CDataGridPagination.js.map +1 -0
  27. package/dist/cjs/CDataGridToolbar.d.ts +32 -0
  28. package/dist/cjs/CDataGridToolbar.js +49 -0
  29. package/dist/cjs/CDataGridToolbar.js.map +1 -0
  30. package/dist/cjs/active-cell.d.ts +22 -0
  31. package/dist/cjs/active-cell.js +89 -0
  32. package/dist/cjs/active-cell.js.map +1 -0
  33. package/dist/cjs/columns.d.ts +37 -0
  34. package/dist/cjs/columns.js +170 -0
  35. package/dist/cjs/columns.js.map +1 -0
  36. package/dist/cjs/icons.d.ts +22 -0
  37. package/dist/cjs/icons.js +40 -0
  38. package/dist/cjs/icons.js.map +1 -0
  39. package/dist/cjs/index.d.ts +12 -0
  40. package/dist/cjs/index.js +39 -0
  41. package/dist/cjs/index.js.map +1 -0
  42. package/dist/cjs/labels.d.ts +7 -0
  43. package/dist/cjs/pinning.d.ts +19 -0
  44. package/dist/cjs/pinning.js +32 -0
  45. package/dist/cjs/pinning.js.map +1 -0
  46. package/dist/cjs/toolbar.d.ts +22 -0
  47. package/dist/cjs/toolbar.js +43 -0
  48. package/dist/cjs/toolbar.js.map +1 -0
  49. package/dist/cjs/tooltip.d.ts +10 -0
  50. package/dist/cjs/tooltip.js +102 -0
  51. package/dist/cjs/tooltip.js.map +1 -0
  52. package/dist/cjs/types.d.ts +287 -0
  53. package/dist/esm/CDataGrid.d.ts +8 -0
  54. package/dist/esm/CDataGrid.mjs +901 -0
  55. package/dist/esm/CDataGrid.mjs.map +1 -0
  56. package/dist/esm/CDataGridBody.d.ts +40 -0
  57. package/dist/esm/CDataGridBody.mjs +142 -0
  58. package/dist/esm/CDataGridBody.mjs.map +1 -0
  59. package/dist/esm/CDataGridCellEditor.d.ts +8 -0
  60. package/dist/esm/CDataGridCellEditor.mjs +65 -0
  61. package/dist/esm/CDataGridCellEditor.mjs.map +1 -0
  62. package/dist/esm/CDataGridColumnChooser.d.ts +23 -0
  63. package/dist/esm/CDataGridColumnChooser.mjs +69 -0
  64. package/dist/esm/CDataGridColumnChooser.mjs.map +1 -0
  65. package/dist/esm/CDataGridFilterMenu.d.ts +22 -0
  66. package/dist/esm/CDataGridFilterMenu.mjs +175 -0
  67. package/dist/esm/CDataGridFilterMenu.mjs.map +1 -0
  68. package/dist/esm/CDataGridHeader.d.ts +36 -0
  69. package/dist/esm/CDataGridHeader.mjs +230 -0
  70. package/dist/esm/CDataGridHeader.mjs.map +1 -0
  71. package/dist/esm/CDataGridHeaderMenu.d.ts +29 -0
  72. package/dist/esm/CDataGridHeaderMenu.mjs +125 -0
  73. package/dist/esm/CDataGridHeaderMenu.mjs.map +1 -0
  74. package/dist/esm/CDataGridPagination.d.ts +18 -0
  75. package/dist/esm/CDataGridPagination.mjs +37 -0
  76. package/dist/esm/CDataGridPagination.mjs.map +1 -0
  77. package/dist/esm/CDataGridToolbar.d.ts +32 -0
  78. package/dist/esm/CDataGridToolbar.mjs +47 -0
  79. package/dist/esm/CDataGridToolbar.mjs.map +1 -0
  80. package/dist/esm/active-cell.d.ts +22 -0
  81. package/dist/esm/active-cell.mjs +86 -0
  82. package/dist/esm/active-cell.mjs.map +1 -0
  83. package/dist/esm/columns.d.ts +37 -0
  84. package/dist/esm/columns.mjs +163 -0
  85. package/dist/esm/columns.mjs.map +1 -0
  86. package/dist/esm/icons.d.ts +22 -0
  87. package/dist/esm/icons.mjs +24 -0
  88. package/dist/esm/icons.mjs.map +1 -0
  89. package/dist/esm/index.d.mts +1 -0
  90. package/dist/esm/index.d.ts +12 -0
  91. package/dist/esm/index.mjs +5 -0
  92. package/dist/esm/index.mjs.map +1 -0
  93. package/dist/esm/labels.d.ts +7 -0
  94. package/dist/esm/pinning.d.ts +19 -0
  95. package/dist/esm/pinning.mjs +29 -0
  96. package/dist/esm/pinning.mjs.map +1 -0
  97. package/dist/esm/toolbar.d.ts +22 -0
  98. package/dist/esm/toolbar.mjs +41 -0
  99. package/dist/esm/toolbar.mjs.map +1 -0
  100. package/dist/esm/tooltip.d.ts +10 -0
  101. package/dist/esm/tooltip.mjs +100 -0
  102. package/dist/esm/tooltip.mjs.map +1 -0
  103. package/dist/esm/types.d.ts +287 -0
  104. package/package.json +92 -0
@@ -0,0 +1,287 @@
1
+ /**
2
+ * --------------------------------------------------------------------------
3
+ * CoreUI PRO react-data-grid types.ts
4
+ * License (https://coreui.io/pro/license/)
5
+ * --------------------------------------------------------------------------
6
+ */
7
+ import type { DataGridColumn, DataGridColumnSizingOptions, DataGridDataRequest, DataGridDataResponse, DataGridEditCommitEvent, DataGridItem, DataGridLabels, DataGridPaginationOptions, DataGridRowSelectionOptions, DataGridSortingOptions } from '@coreui/data-grid';
8
+ import type { CsvDownloadOptions } from '@coreui/data-grid/csv';
9
+ import type { Column, ColumnFiltersState, ColumnOrderState, ColumnPinningState, ColumnSizingState, PaginationState, RowSelectionState, SortingState, Table, VisibilityState } from '@tanstack/react-table';
10
+ import type { ComponentType, CSSProperties, HTMLAttributes, ReactNode, Ref } from 'react';
11
+ export interface CDataGridSlotProps {
12
+ table: Table<DataGridItem>;
13
+ labels: DataGridLabels;
14
+ }
15
+ export interface CDataGridSlots {
16
+ toolbar: ComponentType<CDataGridSlotProps>;
17
+ pagination: ComponentType<CDataGridSlotProps>;
18
+ empty: ComponentType<CDataGridSlotProps>;
19
+ }
20
+ export interface CDataGridToolbarOptions {
21
+ columns?: boolean;
22
+ export?: boolean | CsvDownloadOptions;
23
+ history?: boolean;
24
+ search?: boolean;
25
+ }
26
+ export interface CDataGridColumnFilterProps {
27
+ column: Column<DataGridItem, unknown>;
28
+ table: Table<DataGridItem>;
29
+ labels: DataGridLabels;
30
+ }
31
+ export interface CDataGridEditorHandle {
32
+ contains?: (target: Node) => boolean;
33
+ focus?: () => void;
34
+ getValue?: () => unknown;
35
+ }
36
+ export interface CDataGridEditorProps {
37
+ column: CDataGridColumn;
38
+ item: DataGridItem;
39
+ value: unknown;
40
+ invalid: string | null;
41
+ labels: DataGridLabels;
42
+ commit: (value: unknown) => void;
43
+ cancel: () => void;
44
+ handleRef: (handle: CDataGridEditorHandle | null) => void;
45
+ }
46
+ export interface CDataGridColumn extends Omit<DataGridColumn, 'editor' | 'filter' | 'render' | 'style'> {
47
+ editor?: ComponentType<CDataGridEditorProps>;
48
+ editorPopup?: boolean;
49
+ filter?: ComponentType<CDataGridColumnFilterProps>;
50
+ render?: (item: DataGridItem, index: number) => ReactNode;
51
+ style?: CSSProperties;
52
+ }
53
+ export interface CDataGridMenuAction {
54
+ key: string;
55
+ label: string;
56
+ disabled?: boolean;
57
+ group?: string;
58
+ icon?: ReactNode;
59
+ run: () => void;
60
+ }
61
+ export interface CDataGridColumnMenuContext {
62
+ column: CDataGridColumn;
63
+ defaultActions: CDataGridMenuAction[];
64
+ }
65
+ export type CDataGridColumnMenuBuilder = (context: CDataGridColumnMenuContext) => CDataGridMenuAction[];
66
+ export interface CDataGridProps extends HTMLAttributes<HTMLDivElement> {
67
+ /**
68
+ * APG grid keyboard navigation — `role="grid"`, a roving-tabindex active cell, and arrow-key movement across header and data cells.
69
+ */
70
+ cellNavigation?: boolean;
71
+ /**
72
+ * Renders a filter row in the header with an input per filterable column.
73
+ */
74
+ columnFilters?: boolean;
75
+ /**
76
+ * Adds a per-column header menu — `true` builds it from the enabled features (sort/pin/move/hide); a builder `({ column, defaultActions }) => actions` returns the final item list.
77
+ */
78
+ columnMenu?: boolean | CDataGridColumnMenuBuilder;
79
+ /**
80
+ * Custom column menu button icon (ReactNode) replacing the default one.
81
+ */
82
+ columnMenuIcon?: ReactNode;
83
+ /**
84
+ * Enables drag-and-drop column reordering; an array sets the initial order.
85
+ */
86
+ columnOrder?: boolean | ColumnOrderState;
87
+ /**
88
+ * Freezes columns (by `key`) to the left/right edge with sticky positioning; `true` enables the feature with no initial pins.
89
+ */
90
+ columnPinning?: boolean | ColumnPinningState;
91
+ /**
92
+ * Enables column resize handles; `mode` controls whether widths update while dragging (`'onChange'`, the default) or on release (`'onEnd'`).
93
+ */
94
+ columnSizing?: boolean | DataGridColumnSizingOptions;
95
+ /**
96
+ * Enables hiding/showing columns via `column.toggleVisibility()`; an object sets the initial visibility.
97
+ */
98
+ columnVisibility?: boolean | VisibilityState;
99
+ /**
100
+ * Column definitions.
101
+ */
102
+ columns: CDataGridColumn[];
103
+ /**
104
+ * Server-side mode: the grid requests data on every sorting/filter/page change; implies pagination.
105
+ */
106
+ dataProvider?: (request: DataGridDataRequest) => Promise<DataGridDataResponse>;
107
+ /**
108
+ * Inline cell editing on Enter/F2/double-click for columns opting in via `editable`/`editor`; implies `cellNavigation`.
109
+ */
110
+ editing?: boolean;
111
+ /**
112
+ * Content (ReactNode) shown when no rows match.
113
+ */
114
+ empty?: ReactNode;
115
+ /** Icon for the per-column filter button. */
116
+ filterIcon?: ReactNode;
117
+ /**
118
+ * Renders a search input above the grid that filters across all columns.
119
+ */
120
+ globalFilter?: boolean;
121
+ /**
122
+ * Undo/redo history of edit commits — Ctrl/Cmd+Z and Ctrl+Shift+Z/Ctrl+Y plus toolbar buttons; requires `editing`.
123
+ */
124
+ history?: boolean;
125
+ /**
126
+ * Custom hide-column menu action icon (ReactNode) replacing the default one.
127
+ */
128
+ hideColumnIcon?: ReactNode;
129
+ /**
130
+ * Stable row id — required for selection to survive sorting and filtering.
131
+ */
132
+ itemKey?: (item: DataGridItem, index: number) => string;
133
+ /**
134
+ * Row data.
135
+ */
136
+ items?: DataGridItem[];
137
+ /**
138
+ * UI strings (i18n), merged over the defaults; supports `{token}` interpolation.
139
+ */
140
+ labels?: Partial<DataGridLabels>;
141
+ /**
142
+ * Custom move-left menu action icon (ReactNode) replacing the default one.
143
+ */
144
+ moveLeftIcon?: ReactNode;
145
+ /**
146
+ * Custom move-right menu action icon (ReactNode) replacing the default one.
147
+ */
148
+ moveRightIcon?: ReactNode;
149
+ /**
150
+ * Fires when the data provider rejects, with the error (server-side mode).
151
+ */
152
+ onDataError?: (error: unknown) => void;
153
+ /**
154
+ * Fires when the data provider resolves, with the `{ items, totalRows }` response (server-side mode).
155
+ */
156
+ onDataLoad?: (response: DataGridDataResponse) => void;
157
+ /**
158
+ * Fires when an edit is cancelled, with the item and column key.
159
+ */
160
+ onEditCancel?: (item: DataGridItem, columnId: string) => void;
161
+ /**
162
+ * Fires when an edit commits, with `{ item, columnId, value, previousValue }` — the grid never mutates `items`; apply the change and re-render.
163
+ */
164
+ onEditCommit?: (event: DataGridEditCommitEvent) => void;
165
+ /**
166
+ * Fires when a cell enters edit mode, with the item and column key.
167
+ */
168
+ onEditStart?: (item: DataGridItem, columnId: string) => void;
169
+ /**
170
+ * Fires when column filters or the global filter change, with both filter states.
171
+ */
172
+ onFilterChange?: (columnFilters: ColumnFiltersState, globalFilter: string) => void;
173
+ /**
174
+ * Fires when columns are reordered, with the TanStack columnOrder state.
175
+ */
176
+ onOrderChange?: (columnOrder: ColumnOrderState) => void;
177
+ /**
178
+ * Fires when the page or page size changes, with the TanStack pagination state.
179
+ */
180
+ onPaginationChange?: (pagination: PaginationState) => void;
181
+ /**
182
+ * Fires when column pinning changes, with the TanStack columnPinning state.
183
+ */
184
+ onPinningChange?: (columnPinning: ColumnPinningState) => void;
185
+ /**
186
+ * Fires when the row selection changes, with the TanStack rowSelection state and the selected items.
187
+ */
188
+ onSelectionChange?: (rowSelection: RowSelectionState, selectedItems: DataGridItem[]) => void;
189
+ /**
190
+ * Fires when a column is resized, with the TanStack columnSizing state.
191
+ */
192
+ onSizingChange?: (columnSizing: ColumnSizingState) => void;
193
+ /**
194
+ * Fires when sorting changes, with the TanStack sorting state.
195
+ */
196
+ onSortingChange?: (sorting: SortingState) => void;
197
+ /**
198
+ * Fires when column visibility changes, with the TanStack columnVisibility state.
199
+ */
200
+ onVisibilityChange?: (columnVisibility: VisibilityState) => void;
201
+ /**
202
+ * Extra rows rendered above and below the visible window.
203
+ */
204
+ overscan?: number;
205
+ /**
206
+ * Pagination mode — mutually exclusive with virtualization.
207
+ */
208
+ pagination?: boolean | DataGridPaginationOptions;
209
+ /**
210
+ * Custom pin-left menu action icon (ReactNode) replacing the default one.
211
+ */
212
+ pinLeftIcon?: ReactNode;
213
+ /**
214
+ * Custom pin-right menu action icon (ReactNode) replacing the default one.
215
+ */
216
+ pinRightIcon?: ReactNode;
217
+ /**
218
+ * Estimated row height in px used by the virtualizer.
219
+ */
220
+ rowHeight?: number;
221
+ /**
222
+ * Checkbox selection with select-all and shift+click ranges.
223
+ */
224
+ rowSelection?: boolean | DataGridRowSelectionOptions;
225
+ /**
226
+ * Replaces built-in chrome — each slot is a component rendered with `{ table, labels }`.
227
+ */
228
+ slots?: Partial<CDataGridSlots>;
229
+ /**
230
+ * Custom ascending sort indicator icon (ReactNode) replacing the default one.
231
+ */
232
+ sortAscendingIcon?: ReactNode;
233
+ /**
234
+ * Custom descending sort indicator icon (ReactNode) replacing the default one.
235
+ */
236
+ sortDescendingIcon?: ReactNode;
237
+ /**
238
+ * Custom unsorted sort indicator icon (ReactNode) replacing the default one.
239
+ */
240
+ sortNeutralIcon?: ReactNode;
241
+ /**
242
+ * Controls when the neutral (unsorted) sort icon is shown on sortable columns: `'always'` keeps it visible, `'hover'` reveals it on header hover/focus. Omit to hide it until the column is sorted.
243
+ */
244
+ sorterVisibility?: 'always' | 'hover';
245
+ /**
246
+ * Column sorting; shift+click adds columns to the sort.
247
+ */
248
+ sorting?: boolean | DataGridSortingOptions;
249
+ /**
250
+ * Persists the grid state (sorting, filters, order, sizing, visibility, pinning, selection, page) to localStorage under this key — autosaved on every change and restored on mount.
251
+ */
252
+ stateKey?: string;
253
+ /**
254
+ * Ref that receives the TanStack table instance.
255
+ */
256
+ tableRef?: Ref<Table<DataGridItem>>;
257
+ /**
258
+ * 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
+ */
260
+ toolbar?: boolean | CDataGridToolbarOptions;
261
+ /**
262
+ * Custom toolbar column-chooser button icon (ReactNode) replacing the default one.
263
+ */
264
+ toolbarColumnsIcon?: ReactNode;
265
+ /**
266
+ * Custom toolbar export button icon (ReactNode) replacing the default one.
267
+ */
268
+ toolbarExportIcon?: ReactNode;
269
+ /**
270
+ * Custom toolbar redo button icon (ReactNode) replacing the default one.
271
+ */
272
+ toolbarRedoIcon?: ReactNode;
273
+ /**
274
+ * Custom toolbar undo button icon (ReactNode) replacing the default one.
275
+ */
276
+ toolbarUndoIcon?: ReactNode;
277
+ /**
278
+ * Custom unpin menu action icon (ReactNode) replacing the default one.
279
+ */
280
+ unpinIcon?: ReactNode;
281
+ /**
282
+ * Windowed rendering for large datasets.
283
+ */
284
+ virtualization?: boolean;
285
+ }
286
+ export { type Column, type ColumnFiltersState, type ColumnOrderState, type ColumnPinningState, type ColumnSizingState, type PaginationState, type RowSelectionState, type SortingState, type Table, type VisibilityState } from '@tanstack/react-table';
287
+ export { type DataGridColumnFilterValue, type DataGridColumnSizingOptions, type DataGridDataRequest, type DataGridDataResponse, type DataGridEditableOptions, type DataGridEditCommitEvent, type DataGridEditorType, type DataGridFilterCondition, type DataGridFilterOperator, type DataGridFilterType, type DataGridItem, type DataGridLabels, type DataGridPaginationOptions, type DataGridRowSelectionOptions, type DataGridSortingOptions, type DataGridState } from '@coreui/data-grid';
@@ -0,0 +1,8 @@
1
+ /**
2
+ * --------------------------------------------------------------------------
3
+ * CoreUI PRO react-data-grid CDataGrid.tsx
4
+ * License (https://coreui.io/pro/license/)
5
+ * --------------------------------------------------------------------------
6
+ */
7
+ import type { CDataGridProps } from './types';
8
+ export declare const CDataGrid: import("react").ForwardRefExoticComponent<CDataGridProps & import("react").RefAttributes<HTMLDivElement>>;