@syook/react-tabulous 4.0.3 → 4.0.4

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