@syook/react-tabulous 4.0.3 → 4.0.5
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 +1 -1
- package/lib/index.d.ts +334 -0
- package/lib/index.esm.js +2 -3
- package/lib/index.js +2 -3
- package/lib/types/reactTabulous/helpers/select.d.ts +1 -1
- package/lib/types/reactTabulous/hooks/useDebounce.d.ts +2 -0
- package/lib/types/reactTabulous/models/columnDef/columnDef.d.ts +5 -0
- package/package.json +10 -13
- package/lib/index.esm.js.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/types/__tests__/reactTabulous/helpers/debounce.test.d.ts +0 -1
- package/lib/types/reactTabulous/helpers/debounce.d.ts +0 -1
package/README.md
CHANGED
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
import React$1, { ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
type NativeColTypes = 'string' | 'number' | 'date' | 'dateTime' | 'boolean' | 'singleSelect' | 'actions';
|
|
4
|
+
type ColumnType = NativeColTypes | string;
|
|
5
|
+
|
|
6
|
+
type GridRowId = string | number;
|
|
7
|
+
type GridValidRowModel = Record<string, any>;
|
|
8
|
+
|
|
9
|
+
interface GridPinnedColumns {
|
|
10
|
+
left?: string[];
|
|
11
|
+
right?: string[];
|
|
12
|
+
}
|
|
13
|
+
type GridColumnPinningState = GridPinnedColumns;
|
|
14
|
+
declare enum GridPinnedPosition {
|
|
15
|
+
left = "left",
|
|
16
|
+
right = "right"
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* The column pinning API interface that is available in the grid [[apiRef]].
|
|
20
|
+
*/
|
|
21
|
+
interface GridColumnPinningApi {
|
|
22
|
+
/**
|
|
23
|
+
* Pins a column to the left or right side of the grid.
|
|
24
|
+
* @param {string} field The column field to pin.
|
|
25
|
+
* @param {GridPinnedPosition} side Which side to pin the column.
|
|
26
|
+
*/
|
|
27
|
+
pinColumn: (field: string, side: GridPinnedPosition) => void;
|
|
28
|
+
/**
|
|
29
|
+
* Unpins a column.
|
|
30
|
+
* @param {string} field The column field to unpin.
|
|
31
|
+
*/
|
|
32
|
+
unpinColumn: (field: string) => void;
|
|
33
|
+
/**
|
|
34
|
+
* Returns which columns are pinned.
|
|
35
|
+
* @returns {GridPinnedColumns} An object containing the pinned columns.
|
|
36
|
+
*/
|
|
37
|
+
getPinnedColumns: () => GridPinnedColumns;
|
|
38
|
+
/**
|
|
39
|
+
* Changes the pinned columns.
|
|
40
|
+
* @param {GridPinnedColumns} pinnedColumns An object containing the columns to pin.
|
|
41
|
+
*/
|
|
42
|
+
setPinnedColumns: (pinnedColumns: GridPinnedColumns) => void;
|
|
43
|
+
/**
|
|
44
|
+
* Returns which side a column is pinned to.
|
|
45
|
+
* @param {string} field The column field to check.
|
|
46
|
+
* @returns {string | false} Which side the column is pinned or `false` if not pinned.
|
|
47
|
+
*/
|
|
48
|
+
isColumnPinned: (field: string) => GridPinnedPosition | false;
|
|
49
|
+
}
|
|
50
|
+
interface GridColumnPinningInternalCache {
|
|
51
|
+
/**
|
|
52
|
+
* Stores the fields in their original position, before being pinned.
|
|
53
|
+
*/
|
|
54
|
+
orderedFieldsBeforePinningColumns: string[] | null;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
type GridActionsCellItemProps = {
|
|
58
|
+
label: string;
|
|
59
|
+
icon?: React.ReactElement;
|
|
60
|
+
} & ({
|
|
61
|
+
showInMenu?: false;
|
|
62
|
+
icon: React.ReactElement;
|
|
63
|
+
} | {
|
|
64
|
+
showInMenu: true;
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
type ValueType = string | number | boolean;
|
|
68
|
+
interface OptionInterface {
|
|
69
|
+
value: ValueType;
|
|
70
|
+
label: string | number;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
interface GridBaseColDef<R extends GridValidRowModel = GridValidRowModel, V = any, F = V> {
|
|
74
|
+
/**
|
|
75
|
+
* The column identifier. It's used to map with [[GridRowModel]] values.
|
|
76
|
+
*/
|
|
77
|
+
field: string;
|
|
78
|
+
/**
|
|
79
|
+
* The title of the column rendered in the column header cell.
|
|
80
|
+
*/
|
|
81
|
+
headerName: string;
|
|
82
|
+
/**
|
|
83
|
+
* Get the values to be displayed in the table cell.
|
|
84
|
+
*/
|
|
85
|
+
valueGetter?: (row: any, index?: number) => string | number | boolean;
|
|
86
|
+
/**
|
|
87
|
+
* The cell which has JSX will be displayed.
|
|
88
|
+
*/
|
|
89
|
+
renderCell?: HTMLElement | JSX.Element | Element | ((row: any, index: number) => JSX.Element);
|
|
90
|
+
/**
|
|
91
|
+
* The description of the column rendered as tooltip if the column header name is not fully displayed.
|
|
92
|
+
*/
|
|
93
|
+
description?: string;
|
|
94
|
+
/**
|
|
95
|
+
* The column is visible or not.
|
|
96
|
+
*/
|
|
97
|
+
isVisible?: boolean;
|
|
98
|
+
/**
|
|
99
|
+
* Type allows to merge this object with a default definition [[GridColDef]].
|
|
100
|
+
* @default 'string'
|
|
101
|
+
*/
|
|
102
|
+
type?: ColumnType;
|
|
103
|
+
/**
|
|
104
|
+
* Allows column to pin.
|
|
105
|
+
* @default null
|
|
106
|
+
*/
|
|
107
|
+
pinned?: GridPinnedPosition | null;
|
|
108
|
+
/**
|
|
109
|
+
* Allows column to set width.
|
|
110
|
+
* @default 'max-content'
|
|
111
|
+
*/
|
|
112
|
+
width?: number | string;
|
|
113
|
+
/**
|
|
114
|
+
* The column to search or not.
|
|
115
|
+
*/
|
|
116
|
+
isSearchable?: boolean;
|
|
117
|
+
/**
|
|
118
|
+
* The column to sortable or not.
|
|
119
|
+
*/
|
|
120
|
+
isSortable?: boolean;
|
|
121
|
+
/**
|
|
122
|
+
* The column to sortable or not.
|
|
123
|
+
*/
|
|
124
|
+
isFilterable?: boolean;
|
|
125
|
+
/**
|
|
126
|
+
* The column to show options in filter.
|
|
127
|
+
*/
|
|
128
|
+
options?: OptionInterface[];
|
|
129
|
+
}
|
|
130
|
+
interface GridActionsColDef<R extends GridValidRowModel = any, V = any, F = V> extends GridBaseColDef<R, V, F> {
|
|
131
|
+
/**
|
|
132
|
+
* Type allows to merge this object with a default definition [[GridColDef]].
|
|
133
|
+
* @default 'actions'
|
|
134
|
+
*/
|
|
135
|
+
type: 'actions';
|
|
136
|
+
/**
|
|
137
|
+
* Function that returns the actions to be shown.
|
|
138
|
+
* @param {GridRowParams} params The params for each row.
|
|
139
|
+
* @returns {React.ReactElement<GridActionsCellItemProps>[]} An array of [[GridActionsCell]] elements.
|
|
140
|
+
*/
|
|
141
|
+
getActions: () => Array<React.ReactElement<GridActionsCellItemProps>>;
|
|
142
|
+
}
|
|
143
|
+
type GridColDef<R extends GridValidRowModel = any, V = any, F = V> = GridBaseColDef<R, V, F> | GridActionsColDef<R, V, F>;
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Available densities.
|
|
147
|
+
*/
|
|
148
|
+
type GridDensity = 'compact' | 'standard' | 'comfortable';
|
|
149
|
+
|
|
150
|
+
type GridSortDirection = 'asc' | 'desc' | null | undefined;
|
|
151
|
+
|
|
152
|
+
interface Logger {
|
|
153
|
+
debug: (...args: any[]) => void;
|
|
154
|
+
info: (...args: any[]) => void;
|
|
155
|
+
warn: (...args: any[]) => void;
|
|
156
|
+
error: (...args: any[]) => void;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
interface FilterFieldProps {
|
|
160
|
+
condition: string;
|
|
161
|
+
column: string;
|
|
162
|
+
type: 'string' | 'number' | 'date' | 'dateTime' | 'boolean' | 'singleSelect';
|
|
163
|
+
operator: string;
|
|
164
|
+
value: any;
|
|
165
|
+
field: string;
|
|
166
|
+
options?: string[];
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
interface DataGridPropsWithDefaultValues {
|
|
170
|
+
data: any;
|
|
171
|
+
rootData: [];
|
|
172
|
+
filteredAndSortedData: [];
|
|
173
|
+
defaultPageSize: number;
|
|
174
|
+
columns: GridColDef[];
|
|
175
|
+
density: GridDensity;
|
|
176
|
+
emptyPlaceholder: string;
|
|
177
|
+
loading: boolean;
|
|
178
|
+
page: number;
|
|
179
|
+
pageSizeOptions: number[];
|
|
180
|
+
sortingOrder: GridSortDirection[];
|
|
181
|
+
sortField: string;
|
|
182
|
+
sortFieldType: string;
|
|
183
|
+
sortBy: GridSortDirection;
|
|
184
|
+
logger: Logger;
|
|
185
|
+
showColumnToolbar: boolean;
|
|
186
|
+
showFilterToolbar: boolean;
|
|
187
|
+
isShowSerialNumber: boolean;
|
|
188
|
+
searchKeys: string[];
|
|
189
|
+
searchText: string;
|
|
190
|
+
/**
|
|
191
|
+
* If `true`, column filters are disabled.
|
|
192
|
+
* @default false
|
|
193
|
+
*/
|
|
194
|
+
disableColumnFilter: boolean;
|
|
195
|
+
/**
|
|
196
|
+
* If `true`, the column menu is disabled.
|
|
197
|
+
* @default false
|
|
198
|
+
*/
|
|
199
|
+
disableColumnMenu: boolean;
|
|
200
|
+
/**
|
|
201
|
+
* If `true`, the column pinning is disabled.
|
|
202
|
+
* @default false
|
|
203
|
+
*/
|
|
204
|
+
disableColumnPinning: boolean;
|
|
205
|
+
/**
|
|
206
|
+
* If `true`, reordering columns is disabled.
|
|
207
|
+
* @default false
|
|
208
|
+
*/
|
|
209
|
+
disableColumnReorder: boolean;
|
|
210
|
+
/**
|
|
211
|
+
* If `true`, resizing columns is disabled.
|
|
212
|
+
* @default false
|
|
213
|
+
*/
|
|
214
|
+
disableColumnResize: boolean;
|
|
215
|
+
/**
|
|
216
|
+
* If `true`, hiding/showing columns is disabled.
|
|
217
|
+
* @default false
|
|
218
|
+
*/
|
|
219
|
+
disableColumnSelector: boolean;
|
|
220
|
+
/**
|
|
221
|
+
* If `true`, the density selector is disabled.
|
|
222
|
+
* @default false
|
|
223
|
+
*/
|
|
224
|
+
disableDensitySelector: boolean;
|
|
225
|
+
/**
|
|
226
|
+
* If `true`, sorting with multiple columns is disabled.
|
|
227
|
+
* @default false
|
|
228
|
+
*/
|
|
229
|
+
disableMultipleColumnsSorting: boolean;
|
|
230
|
+
/**
|
|
231
|
+
* If `true`, quick search will be disabled.
|
|
232
|
+
* @default false
|
|
233
|
+
*/
|
|
234
|
+
disableSearch: boolean;
|
|
235
|
+
/**
|
|
236
|
+
* If `true`, export will be disabled.
|
|
237
|
+
* @default false
|
|
238
|
+
*/
|
|
239
|
+
disableColumnExport: boolean;
|
|
240
|
+
/**
|
|
241
|
+
* If `true`, there won't be any footer or pagination.
|
|
242
|
+
* @default false
|
|
243
|
+
*/
|
|
244
|
+
hideFooter: boolean;
|
|
245
|
+
/**
|
|
246
|
+
* If `true`, the row count in pagination component in the footer is hidden.
|
|
247
|
+
* @default false
|
|
248
|
+
*/
|
|
249
|
+
hideFooterRowCount: boolean;
|
|
250
|
+
/**
|
|
251
|
+
* If `true`, the pagination component in the footer is hidden but row count will be shown.
|
|
252
|
+
* @default false
|
|
253
|
+
*/
|
|
254
|
+
hidePagination: boolean;
|
|
255
|
+
/**
|
|
256
|
+
* If `true`, the selected row count in the footer is hidden.
|
|
257
|
+
* @default false
|
|
258
|
+
*/
|
|
259
|
+
pagination: boolean;
|
|
260
|
+
/**
|
|
261
|
+
* Pagination can be processed on the server or client-side.
|
|
262
|
+
* Set it to 'client' if you would like to handle the pagination on the client-side.
|
|
263
|
+
* Set it to 'server' if you would like to handle the pagination on the server-side.
|
|
264
|
+
* @default "client"
|
|
265
|
+
*/
|
|
266
|
+
filters: FilterFieldProps[];
|
|
267
|
+
/**
|
|
268
|
+
* If `true`, the grid will have checkbox selection.
|
|
269
|
+
* @default false
|
|
270
|
+
*/
|
|
271
|
+
checkboxSelection: boolean;
|
|
272
|
+
selectedRows: GridRowId[];
|
|
273
|
+
paginatedSelectedRows: GridRowId[];
|
|
274
|
+
/**
|
|
275
|
+
* If `true`, the columns will be updated with every props - Use it if the data update is real time.
|
|
276
|
+
* @default false
|
|
277
|
+
*/
|
|
278
|
+
isRealTimeDataUpdate: boolean;
|
|
279
|
+
/**
|
|
280
|
+
* Bulk actions to be displayed in the toolbar.
|
|
281
|
+
* @default []
|
|
282
|
+
* @example ['delete']
|
|
283
|
+
*/
|
|
284
|
+
bulkActions: string[] | any[];
|
|
285
|
+
/**
|
|
286
|
+
* Callback fired when a bulk action is clicked.
|
|
287
|
+
* @param {string} action The action clicked.
|
|
288
|
+
* @param {GridRowId[]} selectedRows The selected rows.
|
|
289
|
+
*/
|
|
290
|
+
onBulkActionClick: (action: string, selectedRows: GridRowId[]) => void;
|
|
291
|
+
/**
|
|
292
|
+
* The text to be displayed when the grid is empty.
|
|
293
|
+
* @default 'No rows'
|
|
294
|
+
* @example 'No rows'
|
|
295
|
+
* @example <span>No rows</span>
|
|
296
|
+
* @example <MyEmptyPlaceholder />
|
|
297
|
+
*/
|
|
298
|
+
noRowsOverlay: ReactNode | string;
|
|
299
|
+
/**
|
|
300
|
+
* The custom component to render next to search.
|
|
301
|
+
*/
|
|
302
|
+
children: null | ((filteredAndSortedData: any, searchText: string, columns: any) => JSX.Element | ReactNode);
|
|
303
|
+
/**
|
|
304
|
+
* Callback fired when the page, page size, sort or sort direction is changed.
|
|
305
|
+
* @param {number} page The page selected.
|
|
306
|
+
* @param {number} pageSize The number of rows in a page.
|
|
307
|
+
* @param {string} sort The field sorted.
|
|
308
|
+
* @param {string} sortDirection The direction of the sort.
|
|
309
|
+
* @param {boolean} fetchOnPageChange If `true`, the callback is fired when the page is changed.
|
|
310
|
+
*/
|
|
311
|
+
fetchOnPageChange: null | ((page: number, pageSize: number, searchText: string, sort: string, sortDirection: GridSortDirection) => void);
|
|
312
|
+
/**
|
|
313
|
+
* for paginated api as the table does not have all the data to calculate the total number of rows
|
|
314
|
+
*/
|
|
315
|
+
rowsCount: null | number;
|
|
316
|
+
/**
|
|
317
|
+
*
|
|
318
|
+
* if the export is custom.
|
|
319
|
+
*
|
|
320
|
+
*/
|
|
321
|
+
customExport: null | ((filteredAndSortedData: any, searchText: string, columns: any) => void);
|
|
322
|
+
/**
|
|
323
|
+
* custom placeholder for the search field.
|
|
324
|
+
*/
|
|
325
|
+
searchPlaceholder: string;
|
|
326
|
+
}
|
|
327
|
+
type DataGridProps<R extends GridValidRowModel = any> = Partial<DataGridPropsWithDefaultValues> & {
|
|
328
|
+
pagination?: true;
|
|
329
|
+
};
|
|
330
|
+
|
|
331
|
+
type DataGridComponent = React$1.ForwardRefExoticComponent<DataGridProps<GridValidRowModel> & React$1.RefAttributes<HTMLDivElement>>;
|
|
332
|
+
declare const ReactTabulous: DataGridComponent;
|
|
333
|
+
|
|
334
|
+
export { ColumnType, DataGridProps, DataGridPropsWithDefaultValues, FilterFieldProps, GridActionsColDef, GridBaseColDef, GridColDef, GridColumnPinningApi, GridColumnPinningInternalCache, GridColumnPinningState, GridDensity, GridPinnedColumns, GridPinnedPosition, GridRowId, GridSortDirection, GridValidRowModel, Logger, NativeColTypes, ReactTabulous };
|