@redsift/table 11.0.0-muiv5-alpha.0 → 11.0.0-muiv5-alpha.2

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 (4) hide show
  1. package/index.d.ts +206 -29
  2. package/index.js +7863 -7317
  3. package/index.js.map +1 -1
  4. package/package.json +2 -2
package/index.d.ts CHANGED
@@ -1,12 +1,23 @@
1
1
  import * as _mui_x_data_grid_pro from '@mui/x-data-grid-pro';
2
- import { GridFilterItem, GridCellParams, GridFilterOperator, GridFilterInputValue, GridFilterInputMultipleValue, DataGridProProps, GridPinnedColumns, GridFilterModel, GridToolbarExportProps, GridToolbarFilterButtonProps, GridToolbarColumnsButton, GridToolbarDensitySelector } from '@mui/x-data-grid-pro';
2
+ import { GridNativeColTypes, GridColumnTypesRecord, GridFilterItem, GridCellParams, GridFilterOperator, GridFilterInputValue, GridFilterInputMultipleValue, DataGridProProps, GridPinnedColumns, GridFilterModel, GridSortModel, GridSortItem, GridColumnVisibilityModel, GridSlotsComponent, GridSelectionModel, GridRowParams, GridToolbarExportProps, GridToolbarFilterButtonProps, GridToolbarColumnsButton, GridToolbarDensitySelector } from '@mui/x-data-grid-pro';
3
3
  export { GridAlignment, GridColDef, GridColumns, GridFilterItem, GridFilterModel, GridSelectionModel, getGridBooleanOperators, getGridDateOperators, getGridSingleSelectOperators } from '@mui/x-data-grid-pro';
4
- import { Theme, Comp, IconProps, NotificationsColorPalette, ProductColorPalette, ShieldVariant } from '@redsift/design-system';
5
- import React, { ReactNode, ComponentProps, RefObject } from 'react';
4
+ import React, { ReactNode, ComponentProps, MutableRefObject, RefObject } from 'react';
6
5
  import { TablePaginationProps } from '@mui/material';
6
+ import { Theme, Comp, IconProps, NotificationsColorPalette, ProductColorPalette, ShieldVariant } from '@redsift/design-system';
7
+ import { GridApiPro } from '@mui/x-data-grid-pro/models/gridApiPro';
7
8
 
8
9
  declare const DETAIL_PANEL_TOGGLE_COL_DEF: _mui_x_data_grid_pro.GridColDef<any, any, any>;
9
10
 
11
+ declare const getRsStringColumnType: () => {
12
+ extendType: GridNativeColTypes;
13
+ filterOperators: _mui_x_data_grid_pro.GridFilterOperator<any, string | number | null, any>[];
14
+ };
15
+ declare const getRsNumberColumnType: () => {
16
+ extendType: GridNativeColTypes;
17
+ filterOperators: _mui_x_data_grid_pro.GridFilterOperator<any, string | number | null, any>[];
18
+ };
19
+ declare const customColumnTypes: GridColumnTypesRecord;
20
+
10
21
  declare const IS_BETWEEN: {
11
22
  label: string;
12
23
  value: string;
@@ -89,6 +100,22 @@ declare const operatorList: {
89
100
 
90
101
  declare function getCompletion(text: string, role: string, openai_api_key: string | undefined, model?: string): Promise<string>;
91
102
 
103
+ declare const PAGINATION_MODEL_KEY = "paginationModel";
104
+ declare const FILTER_MODEL_KEY = "filterModel";
105
+ declare const SORT_MODEL_KEY = "sortModel";
106
+ declare const VISIBILITY_MODEL_KEY = "visibilityModel";
107
+ declare const PINNED_COLUMNS = "pinnedColumns";
108
+ declare const DIMENSION_MODEL_KEY = "dimension";
109
+ declare const FILTER_SEARCH_KEY = "searchModel";
110
+ declare const CATEGORIES: readonly ["paginationModel", "filterModel", "sortModel", "visibilityModel", "dimension", "searchModel", "pinnedColumns"];
111
+ type Category = (typeof CATEGORIES)[number];
112
+ declare const buildStorageKey: ({ id, version, category }: {
113
+ id: string;
114
+ version: number;
115
+ category: Category;
116
+ }) => `${string}:${number}:paginationModel` | `${string}:${number}:filterModel` | `${string}:${number}:sortModel` | `${string}:${number}:visibilityModel` | `${string}:${number}:pinnedColumns` | `${string}:${number}:dimension` | `${string}:${number}:searchModel`;
117
+ declare const clearPreviousVersionStorage: (id: string, currentVersion: number) => void;
118
+
92
119
  interface DataGridProps extends Partial<Pick<DataGridProProps, 'rows'>>, Omit<DataGridProProps, 'rows'> {
93
120
  /** License key for MUI Datagrid Pro. */
94
121
  license?: string;
@@ -130,6 +157,89 @@ type StyledDataGridProps = {
130
157
 
131
158
  declare const DataGrid: Comp<DataGridProps, HTMLDivElement>;
132
159
 
160
+ interface ExtendedGridPaginationModel {
161
+ page: number;
162
+ pageSize: number;
163
+ direction?: 'next' | 'back';
164
+ }
165
+
166
+ type OperatorValue = string | string[];
167
+ declare const decodeValue: (value: string) => OperatorValue;
168
+ declare const encodeValue: (value: string | undefined) => string;
169
+ declare const urlSearchParamsToString: (searchParams: URLSearchParams) => string;
170
+ declare const numberOperatorEncoder: Record<string, string>;
171
+ declare const numberOperatorDecoder: Record<string, string>;
172
+ /** FILTERS */
173
+ declare const getFilterModelFromString: (searchString: string, columns: DataGridProps['columns']) => GridFilterModel;
174
+ declare const getSearchParamsFromFilterModel: (filterModel: GridFilterModel) => URLSearchParams;
175
+ /** SORT */
176
+ declare const getSortingFromString: (searchString: string, columns: DataGridProps['columns']) => GridSortModel | null;
177
+ declare const getSearchParamsFromSorting: (sorting: GridSortItem[]) => URLSearchParams;
178
+ /** PAGINATION */
179
+ declare const getPaginationFromString: (searchString: string) => ExtendedGridPaginationModel | null;
180
+ declare const getSearchParamsFromPagination: (pagination: ExtendedGridPaginationModel) => URLSearchParams;
181
+ /** COLUMN VISIBILITY */
182
+ declare const getSearchParamsFromColumnVisibility: (columnVisibility: GridColumnVisibilityModel, columns: DataGridProps['columns']) => URLSearchParams;
183
+ declare const getColumnVisibilityFromString: (notParsed: string, tableColumns: DataGridProps['columns']) => GridColumnVisibilityModel | null;
184
+ declare const getPinnedColumnsFromString: (notParsed: string, tableColumns: DataGridProps['columns']) => PinnedColumns | null;
185
+ declare const getSearchParamsFromPinnedColumns: (pinnedColumns: GridPinnedColumns) => URLSearchParams;
186
+ declare const getSearchParamsFromTab: (search: string) => URLSearchParams;
187
+ type FinalSearchInput = {
188
+ filterModel: GridFilterModel;
189
+ sortModel: GridSortModel;
190
+ paginationModel: ExtendedGridPaginationModel;
191
+ columnsVisibilityModel: GridColumnVisibilityModel;
192
+ pinnedColumnsModel: GridPinnedColumns;
193
+ search: string;
194
+ columns: DataGridProps['columns'];
195
+ };
196
+ declare const getFinalSearch: ({ search, filterModel, sortModel, paginationModel, columnsVisibilityModel, pinnedColumnsModel, columns, }: FinalSearchInput) => URLSearchParams;
197
+ type PinnedColumns = {
198
+ left: string[];
199
+ right: string[];
200
+ };
201
+ type ModelsLocalStorage = {
202
+ localStorageFilters: string;
203
+ setLocalStorageFilters: (search: string) => void;
204
+ localStorageSorting: string;
205
+ setLocalStorageSorting: (search: string) => void;
206
+ localStoragePagination: string;
207
+ setLocalStoragePagination: (search: string) => void;
208
+ localStorageColumnsVisibility: string;
209
+ setLocalStorageColumnsVisibility: (search: string) => void;
210
+ localStoragePinnedColumns: string;
211
+ setLocalStoragePinnedColumns: (search: string) => void;
212
+ };
213
+ type ModelsTable = {
214
+ filterModel: GridFilterModel;
215
+ sortModel: GridSortModel;
216
+ paginationModel: ExtendedGridPaginationModel;
217
+ columnVisibilityModel: GridColumnVisibilityModel;
218
+ pinnedColumnsModel: PinnedColumns;
219
+ };
220
+ /** Return the state of the table given the URL and the local storage state */
221
+ declare const getModelsParsedOrUpdateLocalStorage: (search: string, columns: DataGridProps['columns'], historyReplace: (newSearch: string) => void, localStorage: ModelsLocalStorage) => ModelsTable;
222
+ type DataGridModel = {
223
+ filterModel: GridFilterModel;
224
+ sortModel: GridSortModel;
225
+ paginationModel: ExtendedGridPaginationModel;
226
+ columnsModel: GridColumnVisibilityModel;
227
+ pinnedColumnsModel: GridPinnedColumns;
228
+ };
229
+ declare const updateUrl: ({ filterModel, sortModel, paginationModel, columnsModel: columnsVisibilityModel, pinnedColumnsModel }: DataGridModel, search: string, historyReplace: (newSearch: string) => void, columns: DataGridProps['columns']) => void;
230
+ declare const areFilterModelsEquivalent: (filterModel: GridFilterModel, filterModelToMatch: GridFilterModel) => boolean;
231
+
232
+ declare const BaseButton: React.JSXElementConstructor<any>;
233
+
234
+ declare const BaseCheckbox: React.JSXElementConstructor<any>;
235
+
236
+ declare const muiIconToDSIcon: Partial<Record<keyof GridSlotsComponent, string>>;
237
+ declare const BaseIcon: React.JSXElementConstructor<any>;
238
+
239
+ declare const BasePopper: React.JSXElementConstructor<any>;
240
+
241
+ declare const BaseTextField: React.JSXElementConstructor<any>;
242
+
133
243
  interface CompletionResponseItem {
134
244
  columnField: string;
135
245
  operatorValue: string;
@@ -176,6 +286,78 @@ declare const DEFAULT_OPERATORS: {
176
286
  */
177
287
  declare const GridToolbarFilterSemanticField: Comp<GridToolbarFilterSemanticFieldProps, HTMLFormElement>;
178
288
 
289
+ type ControlledPaginationProps = {
290
+ displaySelection?: boolean;
291
+ displayRowsPerPage?: boolean;
292
+ displayPagination?: boolean;
293
+ selectionStatus: SelectionStatus;
294
+ apiRef: MutableRefObject<GridApiPro>;
295
+ page: number;
296
+ onPageChange: (page: number) => void;
297
+ pageSize: number;
298
+ onPageSizeChange: (pageSize: number) => void;
299
+ rowsPerPageOptions?: number[];
300
+ isRowSelectable?: DataGridProps['isRowSelectable'];
301
+ paginationProps?: DataGridProps['paginationProps'];
302
+ };
303
+ declare const ControlledPagination: React.FC<ControlledPaginationProps>;
304
+
305
+ type ServerSideControlledPaginationProps = {
306
+ displaySelection?: boolean;
307
+ displayRowsPerPage?: boolean;
308
+ displayPagination?: boolean;
309
+ selectionStatus: SelectionStatus;
310
+ page: number;
311
+ onPageChange: (page: number) => void;
312
+ pageSize: number;
313
+ onPageSizeChange: (pageSize: number) => void;
314
+ rowsPerPageOptions?: number[];
315
+ paginationProps?: DataGridProps['paginationProps'];
316
+ rowCount: number;
317
+ loading?: boolean;
318
+ };
319
+ declare const onServerSideSelectionStatusChange: (newSelectionModel: GridSelectionModel, apiRef: React.MutableRefObject<GridApiPro>, selectionStatus: React.MutableRefObject<SelectionStatus>, isRowSelectable: ((params: GridRowParams<any>) => boolean) | undefined, page: number, pageSize: number) => void;
320
+ declare const ServerSideControlledPagination: React.FC<ServerSideControlledPaginationProps>;
321
+
322
+ interface StatefulDataGridProps extends DataGridProps {
323
+ /** Hook returning pathname, search params and a method to update query params. */
324
+ useRouter: () => {
325
+ pathname: string;
326
+ search: string;
327
+ historyReplace: (newSearch: string) => void;
328
+ };
329
+ /** Pinned custom columns. */
330
+ pinnedCustomColumns?: Required<GridPinnedColumns>;
331
+ }
332
+
333
+ declare const StatefulDataGrid: Comp<StatefulDataGridProps, HTMLDivElement>;
334
+
335
+ interface TextCellProps extends ComponentProps<'div'> {
336
+ /** Including Badge Component. */
337
+ badge?: ReactNode;
338
+ /**
339
+ * Can be a string or an array of strings containing `d` property of the `path` SVG element.<br />
340
+ * Can also be a ReactElement.
341
+ */
342
+ leftIcon?: IconProps['icon'];
343
+ /** Left Icon Color variant. */
344
+ leftIconColor?: NotificationsColorPalette | ProductColorPalette | (string & {});
345
+ /**
346
+ * Can be a string or an array of strings containing `d` property of the `path` SVG element.<br />
347
+ * Can also be a ReactElement.
348
+ */
349
+ rightIcon?: IconProps['icon'];
350
+ /** Right Icon Color variant. */
351
+ rightIconColor?: NotificationsColorPalette | ProductColorPalette | (string & {});
352
+ /** Shield variant. */
353
+ shieldVariant?: ShieldVariant;
354
+ }
355
+
356
+ /**
357
+ * The Cell component.
358
+ */
359
+ declare const TextCell: Comp<TextCellProps, HTMLDivElement>;
360
+
179
361
  type GridToolbarColumnsProps = Omit<typeof GridToolbarColumnsButton, 'ref'>;
180
362
  type GridToolbarDensityProps = Omit<typeof GridToolbarDensitySelector, 'ref'>;
181
363
  type GridToolbarFilterSemanticProps = Omit<GridToolbarFilterSemanticFieldProps, 'ref'>;
@@ -225,30 +407,25 @@ declare global {
225
407
  /** ------ */
226
408
  declare const Toolbar: React.FC<ToolbarProps>;
227
409
 
228
- interface TextCellProps extends ComponentProps<'div'> {
229
- /** Including Badge Component. */
230
- badge?: ReactNode;
231
- /**
232
- * Can be a string or an array of strings containing `d` property of the `path` SVG element.<br />
233
- * Can also be a ReactElement.
234
- */
235
- leftIcon?: IconProps['icon'];
236
- /** Left Icon Color variant. */
237
- leftIconColor?: NotificationsColorPalette | ProductColorPalette | (string & {});
238
- /**
239
- * Can be a string or an array of strings containing `d` property of the `path` SVG element.<br />
240
- * Can also be a ReactElement.
241
- */
242
- rightIcon?: IconProps['icon'];
243
- /** Right Icon Color variant. */
244
- rightIconColor?: NotificationsColorPalette | ProductColorPalette | (string & {});
245
- /** Shield variant. */
246
- shieldVariant?: ShieldVariant;
247
- }
248
-
249
- /**
250
- * The Cell component.
251
- */
252
- declare const TextCell: Comp<TextCellProps, HTMLDivElement>;
410
+ type ToolbarWrapperProps = {
411
+ hideToolbar: DataGridProps['hideToolbar'];
412
+ RenderedToolbar: React.JSXElementConstructor<any>;
413
+ filterModel: DataGridProps['filterModel'];
414
+ onFilterModelChange: DataGridProps['onFilterModelChange'];
415
+ pagination: DataGridProps['pagination'];
416
+ paginationPlacement: DataGridProps['paginationPlacement'];
417
+ selectionStatus: React.MutableRefObject<SelectionStatus>;
418
+ apiRef: DataGridProps['apiRef'];
419
+ isRowSelectable: DataGridProps['isRowSelectable'];
420
+ page: DataGridProps['page'];
421
+ onPageChange: DataGridProps['onPageChange'];
422
+ pageSize: DataGridProps['pageSize'];
423
+ onPageSizeChange: DataGridProps['onPageSizeChange'];
424
+ rowsPerPageOptions: DataGridProps['rowsPerPageOptions'];
425
+ paginationProps: DataGridProps['paginationProps'];
426
+ paginationMode?: DataGridProps['paginationMode'];
427
+ rowCount?: DataGridProps['rowCount'];
428
+ };
429
+ declare const ToolbarWrapper: React.FC<ToolbarWrapperProps>;
253
430
 
254
- export { CONTAINS_ANY_OF, CONTAINS_ANY_OF_I, CompletionResponse, DEFAULT_OPERATORS, DETAIL_PANEL_TOGGLE_COL_DEF, DOES_NOT_CONTAIN, DOES_NOT_EQUAL, DataGrid, DataGridProps, ENDS_WITH_ANY_OF, FilterConfig, GridToolbarFilterSemanticField, GridToolbarFilterSemanticFieldProps, IS_ANY_OF, IS_BETWEEN, IS_NOT_ANY_OF, STARTS_WITH_ANY_OF, SelectionStatus, StyledDataGridProps, TextCell, Toolbar, getCompletion, getGridNumericOperators, getGridStringArrayOperators, getGridStringOperators, operatorList };
431
+ export { BaseButton, BaseCheckbox, BaseIcon, BasePopper, BaseTextField, CATEGORIES, CONTAINS_ANY_OF, CONTAINS_ANY_OF_I, Category, CompletionResponse, ControlledPagination, ControlledPaginationProps, DEFAULT_OPERATORS, DETAIL_PANEL_TOGGLE_COL_DEF, DIMENSION_MODEL_KEY, DOES_NOT_CONTAIN, DOES_NOT_EQUAL, DataGrid, DataGridModel, DataGridProps, ENDS_WITH_ANY_OF, FILTER_MODEL_KEY, FILTER_SEARCH_KEY, FilterConfig, GridToolbarFilterSemanticField, GridToolbarFilterSemanticFieldProps, IS_ANY_OF, IS_BETWEEN, IS_NOT_ANY_OF, PAGINATION_MODEL_KEY, PINNED_COLUMNS, PinnedColumns, SORT_MODEL_KEY, STARTS_WITH_ANY_OF, SelectionStatus, ServerSideControlledPagination, ServerSideControlledPaginationProps, StatefulDataGrid, StatefulDataGridProps, StyledDataGridProps, TextCell, Toolbar, ToolbarWrapper, ToolbarWrapperProps, VISIBILITY_MODEL_KEY, areFilterModelsEquivalent, buildStorageKey, clearPreviousVersionStorage, customColumnTypes, decodeValue, encodeValue, getColumnVisibilityFromString, getCompletion, getFilterModelFromString, getFinalSearch, getGridNumericOperators, getGridStringArrayOperators, getGridStringOperators, getModelsParsedOrUpdateLocalStorage, getPaginationFromString, getPinnedColumnsFromString, getRsNumberColumnType, getRsStringColumnType, getSearchParamsFromColumnVisibility, getSearchParamsFromFilterModel, getSearchParamsFromPagination, getSearchParamsFromPinnedColumns, getSearchParamsFromSorting, getSearchParamsFromTab, getSortingFromString, muiIconToDSIcon, numberOperatorDecoder, numberOperatorEncoder, onServerSideSelectionStatusChange, operatorList, updateUrl, urlSearchParamsToString };