@bluemarble/bm-components 1.4.1 → 1.5.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/dist/index.d.mts CHANGED
@@ -1,6 +1,7 @@
1
- import React, { ReactNode, FC, Provider } from 'react';
1
+ import * as React from 'react';
2
+ import React__default, { ReactNode, FC, Provider } from 'react';
2
3
  import * as _mui_material from '@mui/material';
3
- import { TableCellProps, TableCell, TextFieldProps, StandardTextFieldProps, SelectProps as SelectProps$1, FormControlProps, InputLabelProps, AutocompleteRenderInputParams, AutocompleteProps as AutocompleteProps$1, CheckboxProps as CheckboxProps$1, FormControlLabelProps, SwitchProps as SwitchProps$1, RadioGroupProps, ButtonProps, CircularProgressProps, Theme, SxProps, PaperProps, TableProps, TableHeadProps, TableBodyProps, ModalProps as ModalProps$1, DialogProps, AlertColor } from '@mui/material';
4
+ import { TableCellProps, TableCell, TextFieldProps, StandardTextFieldProps, SelectProps as SelectProps$1, FormControlProps, InputLabelProps, AutocompleteRenderInputParams, AutocompleteProps as AutocompleteProps$1, CheckboxProps as CheckboxProps$1, FormControlLabelProps, SwitchProps as SwitchProps$1, RadioGroupProps, ButtonProps, CircularProgressProps, Theme, SxProps, TableSortLabelProps, BoxProps, PaperProps, TableProps, TableHeadProps, TableBodyProps, ModalProps as ModalProps$1, DialogProps, AlertColor } from '@mui/material';
4
5
  import * as _mui_material_OverridableComponent from '@mui/material/OverridableComponent';
5
6
  import IMask$1 from 'imask';
6
7
  import { NextApiRequest, NextApiResponse, GetServerSidePropsContext } from 'next';
@@ -36,7 +37,7 @@ interface GridProps$1<T> {
36
37
  noFilters?: boolean;
37
38
  primaryKey?: string;
38
39
  }
39
- declare const Grid: <ObjectType>(props: React.PropsWithChildren<GridProps$1<ObjectType>>) => React.JSX.Element;
40
+ declare const Grid: <ObjectType>(props: React__default.PropsWithChildren<GridProps$1<ObjectType>>) => React__default.JSX.Element;
40
41
 
41
42
  declare function filterData<T>(filters: FilterProps$1[], defaultData: {
42
43
  current: T[];
@@ -66,7 +67,7 @@ interface OnSaveProps {
66
67
  value: string;
67
68
  data: Record<string, any>;
68
69
  }
69
- declare const EditableTableCell: (allProps: EditableTableCellProps) => React.JSX.Element;
70
+ declare const EditableTableCell: (allProps: EditableTableCellProps) => React__default.JSX.Element;
70
71
 
71
72
  interface InputProps extends StandardTextFieldProps {
72
73
  name: string;
@@ -84,7 +85,7 @@ interface InputMaskProps extends Partial<StandardTextFieldProps> {
84
85
  mask: IMask$1.AnyMaskedOptions;
85
86
  onChangeValue?: (value: string, unmaskedValue: string) => void;
86
87
  }
87
- declare function InputMask({ withFormik, ...rest }: InputMaskProps): React.JSX.Element;
88
+ declare function InputMask({ withFormik, ...rest }: InputMaskProps): React__default.JSX.Element;
88
89
 
89
90
  interface CustomInputLabelProps extends InputLabelProps {
90
91
  size?: 'small';
@@ -99,7 +100,7 @@ type SelectProps<T> = MuiSelectPropsWithouVariant<T> & {
99
100
  InputLabelProps?: Partial<CustomInputLabelProps>;
100
101
  helperText?: string;
101
102
  };
102
- declare function Select<T>({ withFormik, ...rest }: SelectProps<T>): React.JSX.Element;
103
+ declare function Select<T>({ withFormik, ...rest }: SelectProps<T>): React__default.JSX.Element;
103
104
 
104
105
  type MuiAutocompleteBaseProps<T> = Omit<AutocompleteProps$1<T, boolean, undefined, boolean>, 'renderInput' | 'getOptionLabel'>;
105
106
  interface AutocompleteWithoutProps<T> extends MuiAutocompleteBaseProps<T> {
@@ -124,7 +125,7 @@ interface AutocompleteWithFormikProps<T> extends MuiAutocompleteBaseProps<T> {
124
125
  getOptionValue?: (option: T) => string | number;
125
126
  }
126
127
  type AutocompleteProps<T> = AutocompleteWithoutProps<T> | AutocompleteWithFormikProps<T>;
127
- declare function Autocomplete<T>({ withFormik, name, getOptionValue, ...rest }: AutocompleteProps<T>): React.JSX.Element;
128
+ declare function Autocomplete<T>({ withFormik, name, getOptionValue, ...rest }: AutocompleteProps<T>): React__default.JSX.Element;
128
129
 
129
130
  type CheckboxProps = CheckboxWithFormik | CheckboxWithoutFormik;
130
131
  interface CheckboxWithFormik extends CheckboxProps$1 {
@@ -139,7 +140,7 @@ interface CheckboxWithoutFormik extends CheckboxProps$1 {
139
140
  withFormik: false;
140
141
  FormControlLabelProps?: Partial<FormControlLabelProps>;
141
142
  }
142
- declare const Checkbox: ({ withFormik, name, ...props }: CheckboxProps) => React.JSX.Element;
143
+ declare const Checkbox: ({ withFormik, name, ...props }: CheckboxProps) => React__default.JSX.Element;
143
144
 
144
145
  type SwitchProps = SwitchWithFormik | SwitchWithoutFormik;
145
146
  interface SwitchWithFormik extends SwitchProps$1 {
@@ -154,7 +155,7 @@ interface SwitchWithoutFormik extends SwitchProps$1 {
154
155
  withFormik: false;
155
156
  FormControlLabelProps?: Partial<FormControlLabelProps>;
156
157
  }
157
- declare const Switch: ({ withFormik, name, ...props }: SwitchProps) => React.JSX.Element;
158
+ declare const Switch: ({ withFormik, name, ...props }: SwitchProps) => React__default.JSX.Element;
158
159
 
159
160
  type RadioOptionProps = {
160
161
  value: string | number | boolean;
@@ -173,25 +174,78 @@ interface RadioWithoutFormik extends RadioGroupProps {
173
174
  options: RadioOptionProps[];
174
175
  withFormik: false;
175
176
  }
176
- declare const Radio: ({ name, withFormik, ...rest }: RadioOptionsProps) => React.JSX.Element;
177
+ declare const Radio: ({ name, withFormik, ...rest }: RadioOptionsProps) => React__default.JSX.Element;
177
178
 
178
179
  interface LargeButtonProps extends ButtonProps {
179
180
  loading?: boolean;
180
181
  children: ReactNode;
181
182
  CircularProgressProps?: CircularProgressProps;
182
183
  }
183
- declare const LargeButton: ({ loading, children, CircularProgressProps, sx, ...rest }: LargeButtonProps) => React.JSX.Element;
184
+ declare const LargeButton: ({ loading, children, CircularProgressProps, sx, ...rest }: LargeButtonProps) => React__default.JSX.Element;
184
185
 
185
186
  declare function getTabProps(index: string): {
186
187
  id: string;
187
188
  'aria-controls': string;
188
189
  };
189
190
  interface TabPanelProps {
190
- children: React.ReactNode;
191
+ children: React__default.ReactNode;
191
192
  value: number;
192
193
  index: number;
193
194
  }
194
- declare const TabPanel: (props: TabPanelProps) => React.JSX.Element;
195
+ declare const TabPanel: (props: TabPanelProps) => React__default.JSX.Element;
196
+
197
+ type FilterCompareType = 'gte' | 'lte' | 'lt' | 'gt' | 'equal' | 'in' | 'notEqual' | 'notIn';
198
+ type FilterProps = {
199
+ id?: string;
200
+ prop: string;
201
+ value: unknown;
202
+ compareType: FilterCompareType;
203
+ };
204
+ declare function useFilter(): {
205
+ filters: FilterProps[];
206
+ filterBy: (newFilter: FilterProps) => void;
207
+ removeFilter: (prop: string, isId?: boolean) => void;
208
+ createFilter: typeof createFilter;
209
+ clearAllFilters: () => void;
210
+ };
211
+ declare function createFilter<T extends Record<string, any>>(filters: FilterProps[]): {
212
+ apply: (item: T) => boolean;
213
+ };
214
+
215
+ type SortedDirectionProps$1 = 'asc' | 'desc';
216
+ interface SortedByProps$1 {
217
+ prop: string;
218
+ direction: SortedDirectionProps$1;
219
+ }
220
+ interface SearchOptions$1 {
221
+ caseSensitive?: boolean;
222
+ exact?: boolean;
223
+ value: string;
224
+ }
225
+ interface UseGridProps$1<T> {
226
+ columns: ColumnsProps[];
227
+ filters?: FilterProps[];
228
+ rowsPerPageOptions?: number[];
229
+ search?: SearchOptions$1;
230
+ defaultCurrentPage?: number;
231
+ defaultSortedBy?: SortedByProps$1[];
232
+ defaultData?: T[];
233
+ }
234
+ declare function useGrid<T extends Record<string, any>>({ columns, filters, search, rowsPerPageOptions, defaultData: externalDefaultData, defaultCurrentPage, defaultSortedBy }: UseGridProps$1<T>): {
235
+ data: T[];
236
+ set: (data: T[]) => void;
237
+ onSortBy: (prop: string) => void;
238
+ sortedBy: SortedByProps$1[];
239
+ defaultData: T[];
240
+ columns: ColumnsProps<_mui_material.Theme>[];
241
+ currentPage: number;
242
+ totalNumberOfPages: number;
243
+ onPageChange: (pageNumber: number) => void;
244
+ setRowsPerPage: (rows: number) => void;
245
+ rowsPerPageOptions: number[];
246
+ rowsPerPage: number;
247
+ setSort: (prop: string, direction: 'desc' | 'asc') => void;
248
+ };
195
249
 
196
250
  interface ColumnsProps<T extends object = Theme> {
197
251
  label: string;
@@ -207,10 +261,11 @@ interface GridProps {
207
261
  prependColumn?: ReactNode;
208
262
  appendColumn?: ReactNode;
209
263
  fixedColumns?: boolean;
210
- sortedBy: string;
211
- sortedDirection: 'asc' | 'desc';
264
+ sortedBy: SortedByProps$1[];
212
265
  dense?: boolean;
213
- onSortBy: (prop: string) => void;
266
+ loadingColSpan?: number;
267
+ tableSortLabelProps?: TableSortLabelProps;
268
+ boxContainerProps?: BoxProps;
214
269
  paperProps?: PaperProps;
215
270
  tableProps?: TableProps;
216
271
  tableHeadProps?: TableHeadProps;
@@ -223,17 +278,25 @@ interface GridProps {
223
278
  rowsPerPage: number;
224
279
  onPageChange: (pageNumber: number) => void;
225
280
  setRowsPerPage: (rows: number) => void;
281
+ onSortBy: (prop: string) => void;
226
282
  isLoading?: boolean;
227
283
  hideFooter?: boolean;
228
284
  }
229
- declare function BaseGrid({ columns, children, paperProps, tableBodyProps, tableHeadProps, tableProps, sortedDirection, sortedBy, onSortBy, dense, striped, bordered, currentPage, totalNumberOfPages, onPageChange, rowsPerPage, setRowsPerPage, rowsPerPageOptions, hideFooter, prependColumn, appendColumn, isLoading }: GridProps): React.JSX.Element;
285
+ declare function BaseGrid({ columns, children, paperProps, tableBodyProps, tableHeadProps, tableProps, sortedBy, onSortBy, dense, striped, bordered, currentPage, totalNumberOfPages, tableSortLabelProps, boxContainerProps, onPageChange, rowsPerPage, setRowsPerPage, rowsPerPageOptions, hideFooter, prependColumn, appendColumn, loadingColSpan, isLoading }: GridProps): React__default.JSX.Element;
286
+
287
+ interface BaseGridAutoRowsProps<T> {
288
+ columns: ColumnsProps<any>[];
289
+ data: T[];
290
+ rowKey: keyof T;
291
+ }
292
+ declare function BaseGridAutoRows<T>({ data, columns, rowKey }: BaseGridAutoRowsProps<T>): React__default.JSX.Element;
230
293
 
231
294
  type ModalProps = {
232
295
  open: boolean;
233
296
  onClose: () => void;
234
- children: React.ReactNode;
297
+ children: React__default.ReactNode;
235
298
  } & Omit<ModalProps$1, 'children'>;
236
- declare const Modal: ({ open, onClose, ...rest }: ModalProps) => React.JSX.Element;
299
+ declare const Modal: ({ open, onClose, ...rest }: ModalProps) => React__default.JSX.Element;
237
300
 
238
301
  declare function GetInputLabel<T extends Array<Record<string, any>>, K extends T[number]['name']>(columns: T): (columnName: K) => {
239
302
  label: any;
@@ -252,7 +315,7 @@ interface DialogCustomProps extends DialogProps {
252
315
  options: DialogOptionsProps[];
253
316
  loading: boolean;
254
317
  }
255
- declare const Dialog: ({ open, title, loading, body, options, ...rest }: DialogCustomProps) => React.JSX.Element;
318
+ declare const Dialog: ({ open, title, loading, body, options, ...rest }: DialogCustomProps) => React__default.JSX.Element;
256
319
 
257
320
  declare class HttpError extends Error {
258
321
  status: number;
@@ -370,42 +433,49 @@ declare class AuthHelper {
370
433
  invalidateCookies: (res: NextApiResponse) => NextApiResponse<any>;
371
434
  }
372
435
 
373
- type FilterCompareType = 'gte' | 'lte' | 'lt' | 'gt' | 'equal' | 'in' | 'notEqual' | 'notIn';
374
- type FilterProps = {
375
- id?: string;
436
+ type SortedDirectionProps = 'asc' | 'desc';
437
+ interface SortedByProps {
376
438
  prop: string;
377
- value: unknown;
378
- compareType: FilterCompareType;
379
- };
380
- declare function useFilter(): {
381
- filters: FilterProps[];
382
- filterBy: (newFilter: FilterProps) => void;
383
- removeFilter: (prop: string, isId?: boolean) => void;
384
- createFilter: typeof createFilter;
385
- clearAllFilters: () => void;
386
- };
387
- declare function createFilter<T extends Record<string, any>>(filters: FilterProps[]): {
388
- apply: (item: T) => boolean;
389
- };
390
-
439
+ direction: SortedDirectionProps;
440
+ }
391
441
  interface SearchOptions {
392
442
  caseSensitive?: boolean;
393
443
  exact?: boolean;
394
444
  value: string;
395
445
  }
396
- interface UseGridProps {
446
+ interface UseGridBaseProps<T> {
397
447
  columns: ColumnsProps[];
398
448
  filters?: FilterProps[];
399
449
  rowsPerPageOptions?: number[];
400
450
  search?: SearchOptions;
451
+ defaultCurrentPage?: number;
452
+ defaultSortedBy?: SortedByProps[];
453
+ defaultSortedDirection?: SortedDirectionProps;
454
+ defaultData?: T[];
401
455
  }
402
- declare function useGrid<T extends Record<string, any>>({ columns, filters, search, rowsPerPageOptions }: UseGridProps): {
456
+ type UseGridPropsOnRequest<T> = {
457
+ onRequest(props: {
458
+ filters: FilterProps[];
459
+ page: number;
460
+ rowsPerPage: number;
461
+ search?: SearchOptions;
462
+ sortedBy: SortedByProps[];
463
+ }): Promise<T[]>;
464
+ axiosInstance?: never;
465
+ url?: never;
466
+ };
467
+ type UseGridPropsAxios = {
468
+ axiosInstance: AxiosInstance;
469
+ url: string;
470
+ onRequest?: never;
471
+ };
472
+ type UseGridProps<T> = UseGridBaseProps<T> & (UseGridPropsOnRequest<T> | UseGridPropsAxios);
473
+ declare function useAsyncGrid<T extends Record<string, any>>({ columns, filters, search, rowsPerPageOptions, onRequest, axiosInstance, url, defaultData: externalDefaultData, defaultCurrentPage, defaultSortedBy }: UseGridProps<T>): {
403
474
  data: T[];
404
475
  set: (data: T[]) => void;
405
- onSortBy: (prop: string) => void;
406
- sortedBy: string;
476
+ onSortBy: (prop: string) => Promise<void>;
477
+ sortedBy: SortedByProps[];
407
478
  defaultData: T[];
408
- sortedDirection: "desc" | "asc";
409
479
  columns: ColumnsProps<_mui_material.Theme>[];
410
480
  currentPage: number;
411
481
  totalNumberOfPages: number;
@@ -414,6 +484,8 @@ declare function useGrid<T extends Record<string, any>>({ columns, filters, sear
414
484
  rowsPerPageOptions: number[];
415
485
  rowsPerPage: number;
416
486
  setSort: (prop: string, direction: 'desc' | 'asc') => void;
487
+ isLoading: boolean;
488
+ setIsLoading: React.Dispatch<React.SetStateAction<boolean>>;
417
489
  };
418
490
 
419
491
  declare function useEvent(event: keyof WindowEventMap, handler: (ev: any) => void, passive?: boolean): void;
@@ -431,22 +503,22 @@ type FormHelperContextProps = {
431
503
  formatErrorMessage: (message: any) => string;
432
504
  api: AxiosInstance;
433
505
  };
434
- declare const FormHelperContext: React.Context<FormHelperContextProps>;
506
+ declare const FormHelperContext: React__default.Context<FormHelperContextProps>;
435
507
  type FormHelperProviderProps = {
436
508
  formatErrorMessage: (message: any) => string;
437
509
  children: ReactNode;
438
510
  api: AxiosInstance;
439
511
  };
440
- declare const FormHelperProvider: ({ formatErrorMessage, api, children }: FormHelperProviderProps) => React.JSX.Element;
512
+ declare const FormHelperProvider: ({ formatErrorMessage, api, children }: FormHelperProviderProps) => React__default.JSX.Element;
441
513
 
442
514
  type AlertContextProps = {
443
515
  createAlert(message: string, type: AlertColor): void;
444
516
  };
445
- declare const AlertContext: React.Context<AlertContextProps>;
517
+ declare const AlertContext: React__default.Context<AlertContextProps>;
446
518
  type AlertProviderProps = {
447
519
  children: ReactNode;
448
520
  };
449
- declare const AlertProvider: ({ children }: AlertProviderProps) => React.JSX.Element;
521
+ declare const AlertProvider: ({ children }: AlertProviderProps) => React__default.JSX.Element;
450
522
 
451
523
  type AuthenticateStatus = 'autenticated' | 'unauthenticated' | 'loading';
452
524
  interface AuthContextProps<T> {
@@ -455,12 +527,12 @@ interface AuthContextProps<T> {
455
527
  signIn(credentials: Record<string, any>): Promise<boolean>;
456
528
  signOut: () => Promise<void>;
457
529
  }
458
- declare function createAuthContext<T>(): React.Context<AuthContextProps<T>>;
530
+ declare function createAuthContext<T>(): React__default.Context<AuthContextProps<T>>;
459
531
  declare function CreateAuthProvider<T>({ api, children, sessionTokenName, Provider }: {
460
532
  Provider: Provider<AuthContextProps<T>>;
461
533
  children: ReactNode;
462
534
  api: AxiosInstance;
463
535
  sessionTokenName: string;
464
- }): React.JSX.Element;
536
+ }): React__default.JSX.Element;
465
537
 
466
- export { AlertContext, AlertProvider, ApiHelper, type AuthContextProps, AuthHelper, Autocomplete, BaseGrid, Checkbox, type ColumnTitleProps, type ColumnsProps, CreateAuthProvider, Dialog, EditableTableCell, type FilterCompareType, type FilterProps, FormHelperContext, FormHelperProvider, GetInputLabel, Grid, HttpError, type IFilter, Input, InputMask, LargeButton, Modal, Radio, Select, Switch, TabPanel, type TabPanelProps, Td, Tr, createAuthContext, createFilter, filterData, getTabProps, useAlert, useEvent, useFilter, useFormHelper, useGrid, useLoading };
538
+ export { AlertContext, AlertProvider, ApiHelper, type AuthContextProps, AuthHelper, Autocomplete, BaseGrid, BaseGridAutoRows, Checkbox, type ColumnTitleProps, type ColumnsProps, CreateAuthProvider, Dialog, EditableTableCell, type FilterCompareType, type FilterProps, FormHelperContext, FormHelperProvider, GetInputLabel, Grid, HttpError, type IFilter, Input, InputMask, LargeButton, Modal, Radio, Select, Switch, TabPanel, type TabPanelProps, Td, Tr, createAuthContext, createFilter, filterData, getTabProps, useAlert, useAsyncGrid, useEvent, useFilter, useFormHelper, useGrid, useLoading };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
- import React, { ReactNode, FC, Provider } from 'react';
1
+ import * as React from 'react';
2
+ import React__default, { ReactNode, FC, Provider } from 'react';
2
3
  import * as _mui_material from '@mui/material';
3
- import { TableCellProps, TableCell, TextFieldProps, StandardTextFieldProps, SelectProps as SelectProps$1, FormControlProps, InputLabelProps, AutocompleteRenderInputParams, AutocompleteProps as AutocompleteProps$1, CheckboxProps as CheckboxProps$1, FormControlLabelProps, SwitchProps as SwitchProps$1, RadioGroupProps, ButtonProps, CircularProgressProps, Theme, SxProps, PaperProps, TableProps, TableHeadProps, TableBodyProps, ModalProps as ModalProps$1, DialogProps, AlertColor } from '@mui/material';
4
+ import { TableCellProps, TableCell, TextFieldProps, StandardTextFieldProps, SelectProps as SelectProps$1, FormControlProps, InputLabelProps, AutocompleteRenderInputParams, AutocompleteProps as AutocompleteProps$1, CheckboxProps as CheckboxProps$1, FormControlLabelProps, SwitchProps as SwitchProps$1, RadioGroupProps, ButtonProps, CircularProgressProps, Theme, SxProps, TableSortLabelProps, BoxProps, PaperProps, TableProps, TableHeadProps, TableBodyProps, ModalProps as ModalProps$1, DialogProps, AlertColor } from '@mui/material';
4
5
  import * as _mui_material_OverridableComponent from '@mui/material/OverridableComponent';
5
6
  import IMask$1 from 'imask';
6
7
  import { NextApiRequest, NextApiResponse, GetServerSidePropsContext } from 'next';
@@ -36,7 +37,7 @@ interface GridProps$1<T> {
36
37
  noFilters?: boolean;
37
38
  primaryKey?: string;
38
39
  }
39
- declare const Grid: <ObjectType>(props: React.PropsWithChildren<GridProps$1<ObjectType>>) => React.JSX.Element;
40
+ declare const Grid: <ObjectType>(props: React__default.PropsWithChildren<GridProps$1<ObjectType>>) => React__default.JSX.Element;
40
41
 
41
42
  declare function filterData<T>(filters: FilterProps$1[], defaultData: {
42
43
  current: T[];
@@ -66,7 +67,7 @@ interface OnSaveProps {
66
67
  value: string;
67
68
  data: Record<string, any>;
68
69
  }
69
- declare const EditableTableCell: (allProps: EditableTableCellProps) => React.JSX.Element;
70
+ declare const EditableTableCell: (allProps: EditableTableCellProps) => React__default.JSX.Element;
70
71
 
71
72
  interface InputProps extends StandardTextFieldProps {
72
73
  name: string;
@@ -84,7 +85,7 @@ interface InputMaskProps extends Partial<StandardTextFieldProps> {
84
85
  mask: IMask$1.AnyMaskedOptions;
85
86
  onChangeValue?: (value: string, unmaskedValue: string) => void;
86
87
  }
87
- declare function InputMask({ withFormik, ...rest }: InputMaskProps): React.JSX.Element;
88
+ declare function InputMask({ withFormik, ...rest }: InputMaskProps): React__default.JSX.Element;
88
89
 
89
90
  interface CustomInputLabelProps extends InputLabelProps {
90
91
  size?: 'small';
@@ -99,7 +100,7 @@ type SelectProps<T> = MuiSelectPropsWithouVariant<T> & {
99
100
  InputLabelProps?: Partial<CustomInputLabelProps>;
100
101
  helperText?: string;
101
102
  };
102
- declare function Select<T>({ withFormik, ...rest }: SelectProps<T>): React.JSX.Element;
103
+ declare function Select<T>({ withFormik, ...rest }: SelectProps<T>): React__default.JSX.Element;
103
104
 
104
105
  type MuiAutocompleteBaseProps<T> = Omit<AutocompleteProps$1<T, boolean, undefined, boolean>, 'renderInput' | 'getOptionLabel'>;
105
106
  interface AutocompleteWithoutProps<T> extends MuiAutocompleteBaseProps<T> {
@@ -124,7 +125,7 @@ interface AutocompleteWithFormikProps<T> extends MuiAutocompleteBaseProps<T> {
124
125
  getOptionValue?: (option: T) => string | number;
125
126
  }
126
127
  type AutocompleteProps<T> = AutocompleteWithoutProps<T> | AutocompleteWithFormikProps<T>;
127
- declare function Autocomplete<T>({ withFormik, name, getOptionValue, ...rest }: AutocompleteProps<T>): React.JSX.Element;
128
+ declare function Autocomplete<T>({ withFormik, name, getOptionValue, ...rest }: AutocompleteProps<T>): React__default.JSX.Element;
128
129
 
129
130
  type CheckboxProps = CheckboxWithFormik | CheckboxWithoutFormik;
130
131
  interface CheckboxWithFormik extends CheckboxProps$1 {
@@ -139,7 +140,7 @@ interface CheckboxWithoutFormik extends CheckboxProps$1 {
139
140
  withFormik: false;
140
141
  FormControlLabelProps?: Partial<FormControlLabelProps>;
141
142
  }
142
- declare const Checkbox: ({ withFormik, name, ...props }: CheckboxProps) => React.JSX.Element;
143
+ declare const Checkbox: ({ withFormik, name, ...props }: CheckboxProps) => React__default.JSX.Element;
143
144
 
144
145
  type SwitchProps = SwitchWithFormik | SwitchWithoutFormik;
145
146
  interface SwitchWithFormik extends SwitchProps$1 {
@@ -154,7 +155,7 @@ interface SwitchWithoutFormik extends SwitchProps$1 {
154
155
  withFormik: false;
155
156
  FormControlLabelProps?: Partial<FormControlLabelProps>;
156
157
  }
157
- declare const Switch: ({ withFormik, name, ...props }: SwitchProps) => React.JSX.Element;
158
+ declare const Switch: ({ withFormik, name, ...props }: SwitchProps) => React__default.JSX.Element;
158
159
 
159
160
  type RadioOptionProps = {
160
161
  value: string | number | boolean;
@@ -173,25 +174,78 @@ interface RadioWithoutFormik extends RadioGroupProps {
173
174
  options: RadioOptionProps[];
174
175
  withFormik: false;
175
176
  }
176
- declare const Radio: ({ name, withFormik, ...rest }: RadioOptionsProps) => React.JSX.Element;
177
+ declare const Radio: ({ name, withFormik, ...rest }: RadioOptionsProps) => React__default.JSX.Element;
177
178
 
178
179
  interface LargeButtonProps extends ButtonProps {
179
180
  loading?: boolean;
180
181
  children: ReactNode;
181
182
  CircularProgressProps?: CircularProgressProps;
182
183
  }
183
- declare const LargeButton: ({ loading, children, CircularProgressProps, sx, ...rest }: LargeButtonProps) => React.JSX.Element;
184
+ declare const LargeButton: ({ loading, children, CircularProgressProps, sx, ...rest }: LargeButtonProps) => React__default.JSX.Element;
184
185
 
185
186
  declare function getTabProps(index: string): {
186
187
  id: string;
187
188
  'aria-controls': string;
188
189
  };
189
190
  interface TabPanelProps {
190
- children: React.ReactNode;
191
+ children: React__default.ReactNode;
191
192
  value: number;
192
193
  index: number;
193
194
  }
194
- declare const TabPanel: (props: TabPanelProps) => React.JSX.Element;
195
+ declare const TabPanel: (props: TabPanelProps) => React__default.JSX.Element;
196
+
197
+ type FilterCompareType = 'gte' | 'lte' | 'lt' | 'gt' | 'equal' | 'in' | 'notEqual' | 'notIn';
198
+ type FilterProps = {
199
+ id?: string;
200
+ prop: string;
201
+ value: unknown;
202
+ compareType: FilterCompareType;
203
+ };
204
+ declare function useFilter(): {
205
+ filters: FilterProps[];
206
+ filterBy: (newFilter: FilterProps) => void;
207
+ removeFilter: (prop: string, isId?: boolean) => void;
208
+ createFilter: typeof createFilter;
209
+ clearAllFilters: () => void;
210
+ };
211
+ declare function createFilter<T extends Record<string, any>>(filters: FilterProps[]): {
212
+ apply: (item: T) => boolean;
213
+ };
214
+
215
+ type SortedDirectionProps$1 = 'asc' | 'desc';
216
+ interface SortedByProps$1 {
217
+ prop: string;
218
+ direction: SortedDirectionProps$1;
219
+ }
220
+ interface SearchOptions$1 {
221
+ caseSensitive?: boolean;
222
+ exact?: boolean;
223
+ value: string;
224
+ }
225
+ interface UseGridProps$1<T> {
226
+ columns: ColumnsProps[];
227
+ filters?: FilterProps[];
228
+ rowsPerPageOptions?: number[];
229
+ search?: SearchOptions$1;
230
+ defaultCurrentPage?: number;
231
+ defaultSortedBy?: SortedByProps$1[];
232
+ defaultData?: T[];
233
+ }
234
+ declare function useGrid<T extends Record<string, any>>({ columns, filters, search, rowsPerPageOptions, defaultData: externalDefaultData, defaultCurrentPage, defaultSortedBy }: UseGridProps$1<T>): {
235
+ data: T[];
236
+ set: (data: T[]) => void;
237
+ onSortBy: (prop: string) => void;
238
+ sortedBy: SortedByProps$1[];
239
+ defaultData: T[];
240
+ columns: ColumnsProps<_mui_material.Theme>[];
241
+ currentPage: number;
242
+ totalNumberOfPages: number;
243
+ onPageChange: (pageNumber: number) => void;
244
+ setRowsPerPage: (rows: number) => void;
245
+ rowsPerPageOptions: number[];
246
+ rowsPerPage: number;
247
+ setSort: (prop: string, direction: 'desc' | 'asc') => void;
248
+ };
195
249
 
196
250
  interface ColumnsProps<T extends object = Theme> {
197
251
  label: string;
@@ -207,10 +261,11 @@ interface GridProps {
207
261
  prependColumn?: ReactNode;
208
262
  appendColumn?: ReactNode;
209
263
  fixedColumns?: boolean;
210
- sortedBy: string;
211
- sortedDirection: 'asc' | 'desc';
264
+ sortedBy: SortedByProps$1[];
212
265
  dense?: boolean;
213
- onSortBy: (prop: string) => void;
266
+ loadingColSpan?: number;
267
+ tableSortLabelProps?: TableSortLabelProps;
268
+ boxContainerProps?: BoxProps;
214
269
  paperProps?: PaperProps;
215
270
  tableProps?: TableProps;
216
271
  tableHeadProps?: TableHeadProps;
@@ -223,17 +278,25 @@ interface GridProps {
223
278
  rowsPerPage: number;
224
279
  onPageChange: (pageNumber: number) => void;
225
280
  setRowsPerPage: (rows: number) => void;
281
+ onSortBy: (prop: string) => void;
226
282
  isLoading?: boolean;
227
283
  hideFooter?: boolean;
228
284
  }
229
- declare function BaseGrid({ columns, children, paperProps, tableBodyProps, tableHeadProps, tableProps, sortedDirection, sortedBy, onSortBy, dense, striped, bordered, currentPage, totalNumberOfPages, onPageChange, rowsPerPage, setRowsPerPage, rowsPerPageOptions, hideFooter, prependColumn, appendColumn, isLoading }: GridProps): React.JSX.Element;
285
+ declare function BaseGrid({ columns, children, paperProps, tableBodyProps, tableHeadProps, tableProps, sortedBy, onSortBy, dense, striped, bordered, currentPage, totalNumberOfPages, tableSortLabelProps, boxContainerProps, onPageChange, rowsPerPage, setRowsPerPage, rowsPerPageOptions, hideFooter, prependColumn, appendColumn, loadingColSpan, isLoading }: GridProps): React__default.JSX.Element;
286
+
287
+ interface BaseGridAutoRowsProps<T> {
288
+ columns: ColumnsProps<any>[];
289
+ data: T[];
290
+ rowKey: keyof T;
291
+ }
292
+ declare function BaseGridAutoRows<T>({ data, columns, rowKey }: BaseGridAutoRowsProps<T>): React__default.JSX.Element;
230
293
 
231
294
  type ModalProps = {
232
295
  open: boolean;
233
296
  onClose: () => void;
234
- children: React.ReactNode;
297
+ children: React__default.ReactNode;
235
298
  } & Omit<ModalProps$1, 'children'>;
236
- declare const Modal: ({ open, onClose, ...rest }: ModalProps) => React.JSX.Element;
299
+ declare const Modal: ({ open, onClose, ...rest }: ModalProps) => React__default.JSX.Element;
237
300
 
238
301
  declare function GetInputLabel<T extends Array<Record<string, any>>, K extends T[number]['name']>(columns: T): (columnName: K) => {
239
302
  label: any;
@@ -252,7 +315,7 @@ interface DialogCustomProps extends DialogProps {
252
315
  options: DialogOptionsProps[];
253
316
  loading: boolean;
254
317
  }
255
- declare const Dialog: ({ open, title, loading, body, options, ...rest }: DialogCustomProps) => React.JSX.Element;
318
+ declare const Dialog: ({ open, title, loading, body, options, ...rest }: DialogCustomProps) => React__default.JSX.Element;
256
319
 
257
320
  declare class HttpError extends Error {
258
321
  status: number;
@@ -370,42 +433,49 @@ declare class AuthHelper {
370
433
  invalidateCookies: (res: NextApiResponse) => NextApiResponse<any>;
371
434
  }
372
435
 
373
- type FilterCompareType = 'gte' | 'lte' | 'lt' | 'gt' | 'equal' | 'in' | 'notEqual' | 'notIn';
374
- type FilterProps = {
375
- id?: string;
436
+ type SortedDirectionProps = 'asc' | 'desc';
437
+ interface SortedByProps {
376
438
  prop: string;
377
- value: unknown;
378
- compareType: FilterCompareType;
379
- };
380
- declare function useFilter(): {
381
- filters: FilterProps[];
382
- filterBy: (newFilter: FilterProps) => void;
383
- removeFilter: (prop: string, isId?: boolean) => void;
384
- createFilter: typeof createFilter;
385
- clearAllFilters: () => void;
386
- };
387
- declare function createFilter<T extends Record<string, any>>(filters: FilterProps[]): {
388
- apply: (item: T) => boolean;
389
- };
390
-
439
+ direction: SortedDirectionProps;
440
+ }
391
441
  interface SearchOptions {
392
442
  caseSensitive?: boolean;
393
443
  exact?: boolean;
394
444
  value: string;
395
445
  }
396
- interface UseGridProps {
446
+ interface UseGridBaseProps<T> {
397
447
  columns: ColumnsProps[];
398
448
  filters?: FilterProps[];
399
449
  rowsPerPageOptions?: number[];
400
450
  search?: SearchOptions;
451
+ defaultCurrentPage?: number;
452
+ defaultSortedBy?: SortedByProps[];
453
+ defaultSortedDirection?: SortedDirectionProps;
454
+ defaultData?: T[];
401
455
  }
402
- declare function useGrid<T extends Record<string, any>>({ columns, filters, search, rowsPerPageOptions }: UseGridProps): {
456
+ type UseGridPropsOnRequest<T> = {
457
+ onRequest(props: {
458
+ filters: FilterProps[];
459
+ page: number;
460
+ rowsPerPage: number;
461
+ search?: SearchOptions;
462
+ sortedBy: SortedByProps[];
463
+ }): Promise<T[]>;
464
+ axiosInstance?: never;
465
+ url?: never;
466
+ };
467
+ type UseGridPropsAxios = {
468
+ axiosInstance: AxiosInstance;
469
+ url: string;
470
+ onRequest?: never;
471
+ };
472
+ type UseGridProps<T> = UseGridBaseProps<T> & (UseGridPropsOnRequest<T> | UseGridPropsAxios);
473
+ declare function useAsyncGrid<T extends Record<string, any>>({ columns, filters, search, rowsPerPageOptions, onRequest, axiosInstance, url, defaultData: externalDefaultData, defaultCurrentPage, defaultSortedBy }: UseGridProps<T>): {
403
474
  data: T[];
404
475
  set: (data: T[]) => void;
405
- onSortBy: (prop: string) => void;
406
- sortedBy: string;
476
+ onSortBy: (prop: string) => Promise<void>;
477
+ sortedBy: SortedByProps[];
407
478
  defaultData: T[];
408
- sortedDirection: "desc" | "asc";
409
479
  columns: ColumnsProps<_mui_material.Theme>[];
410
480
  currentPage: number;
411
481
  totalNumberOfPages: number;
@@ -414,6 +484,8 @@ declare function useGrid<T extends Record<string, any>>({ columns, filters, sear
414
484
  rowsPerPageOptions: number[];
415
485
  rowsPerPage: number;
416
486
  setSort: (prop: string, direction: 'desc' | 'asc') => void;
487
+ isLoading: boolean;
488
+ setIsLoading: React.Dispatch<React.SetStateAction<boolean>>;
417
489
  };
418
490
 
419
491
  declare function useEvent(event: keyof WindowEventMap, handler: (ev: any) => void, passive?: boolean): void;
@@ -431,22 +503,22 @@ type FormHelperContextProps = {
431
503
  formatErrorMessage: (message: any) => string;
432
504
  api: AxiosInstance;
433
505
  };
434
- declare const FormHelperContext: React.Context<FormHelperContextProps>;
506
+ declare const FormHelperContext: React__default.Context<FormHelperContextProps>;
435
507
  type FormHelperProviderProps = {
436
508
  formatErrorMessage: (message: any) => string;
437
509
  children: ReactNode;
438
510
  api: AxiosInstance;
439
511
  };
440
- declare const FormHelperProvider: ({ formatErrorMessage, api, children }: FormHelperProviderProps) => React.JSX.Element;
512
+ declare const FormHelperProvider: ({ formatErrorMessage, api, children }: FormHelperProviderProps) => React__default.JSX.Element;
441
513
 
442
514
  type AlertContextProps = {
443
515
  createAlert(message: string, type: AlertColor): void;
444
516
  };
445
- declare const AlertContext: React.Context<AlertContextProps>;
517
+ declare const AlertContext: React__default.Context<AlertContextProps>;
446
518
  type AlertProviderProps = {
447
519
  children: ReactNode;
448
520
  };
449
- declare const AlertProvider: ({ children }: AlertProviderProps) => React.JSX.Element;
521
+ declare const AlertProvider: ({ children }: AlertProviderProps) => React__default.JSX.Element;
450
522
 
451
523
  type AuthenticateStatus = 'autenticated' | 'unauthenticated' | 'loading';
452
524
  interface AuthContextProps<T> {
@@ -455,12 +527,12 @@ interface AuthContextProps<T> {
455
527
  signIn(credentials: Record<string, any>): Promise<boolean>;
456
528
  signOut: () => Promise<void>;
457
529
  }
458
- declare function createAuthContext<T>(): React.Context<AuthContextProps<T>>;
530
+ declare function createAuthContext<T>(): React__default.Context<AuthContextProps<T>>;
459
531
  declare function CreateAuthProvider<T>({ api, children, sessionTokenName, Provider }: {
460
532
  Provider: Provider<AuthContextProps<T>>;
461
533
  children: ReactNode;
462
534
  api: AxiosInstance;
463
535
  sessionTokenName: string;
464
- }): React.JSX.Element;
536
+ }): React__default.JSX.Element;
465
537
 
466
- export { AlertContext, AlertProvider, ApiHelper, type AuthContextProps, AuthHelper, Autocomplete, BaseGrid, Checkbox, type ColumnTitleProps, type ColumnsProps, CreateAuthProvider, Dialog, EditableTableCell, type FilterCompareType, type FilterProps, FormHelperContext, FormHelperProvider, GetInputLabel, Grid, HttpError, type IFilter, Input, InputMask, LargeButton, Modal, Radio, Select, Switch, TabPanel, type TabPanelProps, Td, Tr, createAuthContext, createFilter, filterData, getTabProps, useAlert, useEvent, useFilter, useFormHelper, useGrid, useLoading };
538
+ export { AlertContext, AlertProvider, ApiHelper, type AuthContextProps, AuthHelper, Autocomplete, BaseGrid, BaseGridAutoRows, Checkbox, type ColumnTitleProps, type ColumnsProps, CreateAuthProvider, Dialog, EditableTableCell, type FilterCompareType, type FilterProps, FormHelperContext, FormHelperProvider, GetInputLabel, Grid, HttpError, type IFilter, Input, InputMask, LargeButton, Modal, Radio, Select, Switch, TabPanel, type TabPanelProps, Td, Tr, createAuthContext, createFilter, filterData, getTabProps, useAlert, useAsyncGrid, useEvent, useFilter, useFormHelper, useGrid, useLoading };