@bluemarble/bm-components 0.0.92 → 0.0.94
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 +81 -24
- package/dist/index.d.ts +368 -0
- package/dist/index.js +4404 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +307 -106
- package/dist/index.mjs.map +1 -1
- package/package.json +9 -5
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import React, { ReactNode, FC } from 'react';
|
|
2
|
-
import
|
|
2
|
+
import * as _mui_material from '@mui/material';
|
|
3
|
+
import { TableCellProps, TextFieldProps, TableRowProps, StandardTextFieldProps, SelectProps as SelectProps$1, FormControlProps, InputLabelProps, AutocompleteRenderInputParams, AutocompleteProps as AutocompleteProps$1, CheckboxProps as CheckboxProps$1, FormControlLabelProps, SwitchProps as SwitchProps$1, RadioGroupProps, ButtonProps, CircularProgressProps, SxProps, PaperProps, TableProps, TableHeadProps, TableBodyProps, ModalProps as ModalProps$1, DialogProps, AlertColor } from '@mui/material';
|
|
3
4
|
import IMask$1 from 'imask';
|
|
5
|
+
import { NextApiRequest, NextApiResponse } from 'next';
|
|
6
|
+
import { ZodTypeDef, ZodSchema } from 'zod';
|
|
7
|
+
import { AxiosInstance } from 'axios';
|
|
4
8
|
|
|
5
9
|
interface ColumnTitleProps {
|
|
6
10
|
name: string;
|
|
@@ -230,6 +234,75 @@ interface GridProps {
|
|
|
230
234
|
}
|
|
231
235
|
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): JSX.Element;
|
|
232
236
|
|
|
237
|
+
declare type ModalProps = {
|
|
238
|
+
open: boolean;
|
|
239
|
+
onClose: () => void;
|
|
240
|
+
} & ModalProps$1;
|
|
241
|
+
declare const Modal: ({ open, onClose, ...rest }: ModalProps) => JSX.Element;
|
|
242
|
+
|
|
243
|
+
declare function GetInputLabel<T extends Array<Record<string, any>>, K extends T[number]['name']>(columns: T): (columnName: K) => {
|
|
244
|
+
label: any;
|
|
245
|
+
name: any;
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
interface DialogOptionsProps {
|
|
249
|
+
label: string;
|
|
250
|
+
focus?: boolean;
|
|
251
|
+
cb(label: string): void;
|
|
252
|
+
}
|
|
253
|
+
interface DialogCustomProps extends DialogProps {
|
|
254
|
+
open: boolean;
|
|
255
|
+
title: string;
|
|
256
|
+
body: string;
|
|
257
|
+
options: DialogOptionsProps[];
|
|
258
|
+
loading: boolean;
|
|
259
|
+
}
|
|
260
|
+
declare const Dialog: ({ open, title, loading, body, options, ...rest }: DialogCustomProps) => JSX.Element;
|
|
261
|
+
|
|
262
|
+
declare class HttpError extends Error {
|
|
263
|
+
status: number;
|
|
264
|
+
constructor(status: number, message: any);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
declare type PossibleMethods = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
268
|
+
declare type HandlerProps = (req: NextApiRequest & {
|
|
269
|
+
user?: number;
|
|
270
|
+
}, res: NextApiResponse) => Promise<any>;
|
|
271
|
+
declare type MethodProps = Partial<Record<PossibleMethods, HandlerProps>>;
|
|
272
|
+
declare type MiddlewaresProps = ((handler: HandlerProps) => HandlerProps)[];
|
|
273
|
+
declare type ConstructorProps = {
|
|
274
|
+
middlewares?: MiddlewaresProps;
|
|
275
|
+
onFinally: () => void;
|
|
276
|
+
};
|
|
277
|
+
declare class ApiHelper {
|
|
278
|
+
middlewares: MiddlewaresProps;
|
|
279
|
+
private onFinally;
|
|
280
|
+
constructor(props?: ConstructorProps);
|
|
281
|
+
setMiddlewares(middlewares: any[]): this;
|
|
282
|
+
createMethods(methods: MethodProps): (req: NextApiRequest, res: NextApiResponse) => Promise<void>;
|
|
283
|
+
static parserErrorWrapper<Output, Def extends ZodTypeDef, Input>(body: Record<string, any>, parser: ZodSchema<Output, Def, Input>): Output;
|
|
284
|
+
static parseQueyFilters<T extends Record<string, any>>(filters: T): T;
|
|
285
|
+
static create({ onFinally }: {
|
|
286
|
+
onFinally: any;
|
|
287
|
+
}): ApiHelper;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
declare type Methods = 'get' | 'post' | 'put' | 'delete' | 'patch' | 'options';
|
|
291
|
+
declare type HandleProps = {
|
|
292
|
+
name: `${Methods}:${string}`;
|
|
293
|
+
};
|
|
294
|
+
declare type UseFormHelperProps = {
|
|
295
|
+
formatErrorMessage: (message: any) => string;
|
|
296
|
+
api: AxiosInstance;
|
|
297
|
+
};
|
|
298
|
+
declare function useFormHelper({ formatErrorMessage, api }: UseFormHelperProps): {
|
|
299
|
+
onSubmitWrapper: <T extends Record<string, any>>(fn: (fields: T, methods: any) => Promise<void>, { name }: HandleProps) => (fields: T, methods: any) => Promise<void>;
|
|
300
|
+
onRequestWrapper: <F extends (...args: Parameters<F>) => R, R>(fn: F, { name }: HandleProps) => (...params: Parameters<F>) => Promise<R>;
|
|
301
|
+
isLoading: (prop: string) => boolean;
|
|
302
|
+
setLoading: (prop: string, remove?: boolean) => void;
|
|
303
|
+
createAlert(message: string, type: _mui_material.AlertColor): void;
|
|
304
|
+
};
|
|
305
|
+
|
|
233
306
|
declare type FilterCompareType = 'gte' | 'lte' | 'lt' | 'gt' | 'equal' | 'in' | 'notEqual' | 'notIn';
|
|
234
307
|
declare type FilterProps = {
|
|
235
308
|
id?: string;
|
|
@@ -283,29 +356,13 @@ declare function useLoading<T = string>(): {
|
|
|
283
356
|
setLoading: (prop: T, remove?: boolean) => void;
|
|
284
357
|
};
|
|
285
358
|
|
|
286
|
-
declare
|
|
287
|
-
|
|
288
|
-
onClose: () => void;
|
|
289
|
-
} & ModalProps$1;
|
|
290
|
-
declare const Modal: ({ open, onClose, ...rest }: ModalProps) => JSX.Element;
|
|
291
|
-
|
|
292
|
-
declare function GetInputLabel<T extends Array<Record<string, any>>, K extends T[number]['name']>(columns: T): (columnName: K) => {
|
|
293
|
-
label: any;
|
|
294
|
-
name: any;
|
|
359
|
+
declare const useAlert: () => {
|
|
360
|
+
createAlert(message: string, type: _mui_material.AlertColor): void;
|
|
295
361
|
};
|
|
296
362
|
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
}
|
|
302
|
-
interface DialogCustomProps extends DialogProps {
|
|
303
|
-
open: boolean;
|
|
304
|
-
title: string;
|
|
305
|
-
body: string;
|
|
306
|
-
options: DialogOptionsProps[];
|
|
307
|
-
loading: boolean;
|
|
308
|
-
}
|
|
309
|
-
declare const Dialog: ({ open, title, loading, body, options, ...rest }: DialogCustomProps) => JSX.Element;
|
|
363
|
+
declare type AlertContextProps = {
|
|
364
|
+
createAlert(message: string, type: AlertColor): void;
|
|
365
|
+
};
|
|
366
|
+
declare const AlertContext: React.Context<AlertContextProps>;
|
|
310
367
|
|
|
311
|
-
export { Autocomplete, BaseGrid, Checkbox, type ColumnTitleProps, type ColumnsProps, Dialog, EditableTableCell, type FilterCompareType, type FilterProps, GetInputLabel, Grid, type IFilter, Input, InputMask, LargeButton, Modal, Radio, Select, Switch, TabPanel, type TabPanelProps, Td, Tr, createFilter, filterData, getTabProps, useEvent, useFilter, useGrid, useLoading };
|
|
368
|
+
export { AlertContext, ApiHelper, Autocomplete, BaseGrid, Checkbox, type ColumnTitleProps, type ColumnsProps, Dialog, EditableTableCell, type FilterCompareType, type FilterProps, GetInputLabel, Grid, HttpError, type IFilter, Input, InputMask, LargeButton, Modal, Radio, Select, Switch, TabPanel, type TabPanelProps, Td, Tr, createFilter, filterData, getTabProps, useAlert, useEvent, useFilter, useFormHelper, useGrid, useLoading };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,368 @@
|
|
|
1
|
+
import React, { ReactNode, FC } from 'react';
|
|
2
|
+
import * as _mui_material from '@mui/material';
|
|
3
|
+
import { TableCellProps, TextFieldProps, TableRowProps, StandardTextFieldProps, SelectProps as SelectProps$1, FormControlProps, InputLabelProps, AutocompleteRenderInputParams, AutocompleteProps as AutocompleteProps$1, CheckboxProps as CheckboxProps$1, FormControlLabelProps, SwitchProps as SwitchProps$1, RadioGroupProps, ButtonProps, CircularProgressProps, SxProps, PaperProps, TableProps, TableHeadProps, TableBodyProps, ModalProps as ModalProps$1, DialogProps, AlertColor } from '@mui/material';
|
|
4
|
+
import IMask$1 from 'imask';
|
|
5
|
+
import { NextApiRequest, NextApiResponse } from 'next';
|
|
6
|
+
import { ZodTypeDef, ZodSchema } from 'zod';
|
|
7
|
+
import { AxiosInstance } from 'axios';
|
|
8
|
+
|
|
9
|
+
interface ColumnTitleProps {
|
|
10
|
+
name: string;
|
|
11
|
+
label: string;
|
|
12
|
+
transformer?: (value: string | number | Date) => string;
|
|
13
|
+
sx?: TableCellProps['sx'];
|
|
14
|
+
}
|
|
15
|
+
interface FilterProps$1 {
|
|
16
|
+
column: string;
|
|
17
|
+
value: string;
|
|
18
|
+
transformer?: (value: string | number | Date) => string;
|
|
19
|
+
}
|
|
20
|
+
declare type IFilter = FilterProps$1;
|
|
21
|
+
interface GridProps$1<T> {
|
|
22
|
+
columnTitles: ColumnTitleProps[];
|
|
23
|
+
defaultData: T[];
|
|
24
|
+
tableData: T[];
|
|
25
|
+
selectedFilters: FilterProps$1[];
|
|
26
|
+
setSelectedFilters(value: FilterProps$1[]): void;
|
|
27
|
+
setTableData(value: T[]): void;
|
|
28
|
+
updateFilters(value: Record<string, any>[]): void;
|
|
29
|
+
rowOptions?: number[];
|
|
30
|
+
footer?: ReactNode;
|
|
31
|
+
customButtons?: ReactNode;
|
|
32
|
+
isLoading?: boolean;
|
|
33
|
+
noFilterButtons?: boolean;
|
|
34
|
+
noPagination?: boolean;
|
|
35
|
+
noFilters?: boolean;
|
|
36
|
+
primaryKey?: string;
|
|
37
|
+
}
|
|
38
|
+
declare const Grid: <ObjectType>(props: React.PropsWithChildren<GridProps$1<ObjectType>>) => JSX.Element;
|
|
39
|
+
|
|
40
|
+
declare function filterData<T>(filters: FilterProps$1[], defaultData: {
|
|
41
|
+
current: T[];
|
|
42
|
+
}): T[];
|
|
43
|
+
|
|
44
|
+
interface EditableTableCellProps extends TableCellProps {
|
|
45
|
+
name: string;
|
|
46
|
+
TextFieldProps?: TextFieldProps;
|
|
47
|
+
type?: TextFieldProps['type'];
|
|
48
|
+
fullWidth?: boolean;
|
|
49
|
+
rowData?: Record<string, any>;
|
|
50
|
+
mask?: IMask.AnyMaskedOptions;
|
|
51
|
+
bordered?: boolean;
|
|
52
|
+
rowIndex?: string | number;
|
|
53
|
+
formatCellValue?: (value: string) => string;
|
|
54
|
+
formatInputDefautvalue?: (value: string) => string;
|
|
55
|
+
onSave?: (props: OnSaveProps) => void;
|
|
56
|
+
onCancel?: () => void;
|
|
57
|
+
}
|
|
58
|
+
interface OnSaveProps {
|
|
59
|
+
name: string;
|
|
60
|
+
event: FocusEvent;
|
|
61
|
+
value: string;
|
|
62
|
+
data: Record<string, any>;
|
|
63
|
+
}
|
|
64
|
+
declare const EditableTableCell: (allProps: EditableTableCellProps) => JSX.Element;
|
|
65
|
+
|
|
66
|
+
interface CustomTableRowProps extends TableRowProps {
|
|
67
|
+
striped?: boolean;
|
|
68
|
+
bordered?: boolean;
|
|
69
|
+
index?: number;
|
|
70
|
+
rowData?: Record<string, any>;
|
|
71
|
+
onSave?: (props: OnSaveProps) => void;
|
|
72
|
+
children: React.ReactNode;
|
|
73
|
+
}
|
|
74
|
+
declare const Tr: React.MemoExoticComponent<(props: CustomTableRowProps) => JSX.Element>;
|
|
75
|
+
|
|
76
|
+
declare const Td: React.MemoExoticComponent<({ children, ...props }: TableCellProps) => JSX.Element>;
|
|
77
|
+
|
|
78
|
+
interface InputProps extends StandardTextFieldProps {
|
|
79
|
+
name: string;
|
|
80
|
+
label: string;
|
|
81
|
+
shrink?: boolean;
|
|
82
|
+
withFormik?: boolean;
|
|
83
|
+
}
|
|
84
|
+
declare const Input: FC<InputProps>;
|
|
85
|
+
|
|
86
|
+
interface InputMaskProps extends Partial<StandardTextFieldProps> {
|
|
87
|
+
name: string;
|
|
88
|
+
label: string;
|
|
89
|
+
withFormik?: boolean;
|
|
90
|
+
value?: string;
|
|
91
|
+
mask: IMask$1.AnyMaskedOptions;
|
|
92
|
+
onChangeValue?: (value: string, unmaskedValue: string) => void;
|
|
93
|
+
}
|
|
94
|
+
declare function InputMask({ withFormik, ...rest }: InputMaskProps): JSX.Element;
|
|
95
|
+
|
|
96
|
+
interface CustomInputLabelProps extends InputLabelProps {
|
|
97
|
+
size?: 'small';
|
|
98
|
+
}
|
|
99
|
+
interface SelectProps extends SelectProps$1 {
|
|
100
|
+
name: string;
|
|
101
|
+
label: string;
|
|
102
|
+
defaultValue?: string;
|
|
103
|
+
withFormik?: boolean;
|
|
104
|
+
FormControlProps?: Partial<FormControlProps>;
|
|
105
|
+
InputLabelProps?: Partial<CustomInputLabelProps>;
|
|
106
|
+
helperText?: string;
|
|
107
|
+
}
|
|
108
|
+
declare const Select: FC<SelectProps>;
|
|
109
|
+
|
|
110
|
+
declare type MuiAutocompleteBaseProps<T> = Omit<AutocompleteProps$1<T, boolean, undefined, boolean>, 'renderInput' | 'getOptionLabel'>;
|
|
111
|
+
interface AutocompleteWithoutProps<T> extends MuiAutocompleteBaseProps<T> {
|
|
112
|
+
name?: never;
|
|
113
|
+
withFormik: false;
|
|
114
|
+
getOptionValue?: never;
|
|
115
|
+
label?: string;
|
|
116
|
+
getOptionLabel: (option: T) => string;
|
|
117
|
+
renderInput?: (params: AutocompleteRenderInputParams) => ReactNode;
|
|
118
|
+
}
|
|
119
|
+
interface AutocompleteWithFormikProps<T> extends MuiAutocompleteBaseProps<T> {
|
|
120
|
+
name: string;
|
|
121
|
+
withFormik?: true;
|
|
122
|
+
label?: string;
|
|
123
|
+
option?: {
|
|
124
|
+
label?: keyof T;
|
|
125
|
+
value?: keyof T;
|
|
126
|
+
key?: string;
|
|
127
|
+
};
|
|
128
|
+
renderInput?: (params: AutocompleteRenderInputParams) => ReactNode;
|
|
129
|
+
getOptionLabel?: (option: T) => string;
|
|
130
|
+
getOptionValue?: (option: T) => string | number;
|
|
131
|
+
}
|
|
132
|
+
declare type AutocompleteProps<T> = AutocompleteWithoutProps<T> | AutocompleteWithFormikProps<T>;
|
|
133
|
+
declare function Autocomplete<T>({ withFormik, name, getOptionValue, ...rest }: AutocompleteProps<T>): JSX.Element;
|
|
134
|
+
|
|
135
|
+
declare type CheckboxProps = CheckboxWithFormik | CheckboxWithoutFormik;
|
|
136
|
+
interface CheckboxWithFormik extends CheckboxProps$1 {
|
|
137
|
+
name: string;
|
|
138
|
+
label?: string;
|
|
139
|
+
withFormik?: true;
|
|
140
|
+
FormControlLabelProps?: Partial<FormControlLabelProps>;
|
|
141
|
+
}
|
|
142
|
+
interface CheckboxWithoutFormik extends CheckboxProps$1 {
|
|
143
|
+
name?: never;
|
|
144
|
+
label?: string;
|
|
145
|
+
withFormik: false;
|
|
146
|
+
FormControlLabelProps?: Partial<FormControlLabelProps>;
|
|
147
|
+
}
|
|
148
|
+
declare const Checkbox: ({ withFormik, name, ...props }: CheckboxProps) => JSX.Element;
|
|
149
|
+
|
|
150
|
+
declare type SwitchProps = SwitchWithFormik | SwitchWithoutFormik;
|
|
151
|
+
interface SwitchWithFormik extends SwitchProps$1 {
|
|
152
|
+
name: string;
|
|
153
|
+
label?: string;
|
|
154
|
+
withFormik?: true;
|
|
155
|
+
FormControlLabelProps?: Partial<FormControlLabelProps>;
|
|
156
|
+
}
|
|
157
|
+
interface SwitchWithoutFormik extends SwitchProps$1 {
|
|
158
|
+
name?: never;
|
|
159
|
+
label?: string;
|
|
160
|
+
withFormik: false;
|
|
161
|
+
FormControlLabelProps?: Partial<FormControlLabelProps>;
|
|
162
|
+
}
|
|
163
|
+
declare const Switch: ({ withFormik, name, ...props }: SwitchProps) => JSX.Element;
|
|
164
|
+
|
|
165
|
+
declare type RadioOptionProps = {
|
|
166
|
+
value: string | number | boolean;
|
|
167
|
+
label: string;
|
|
168
|
+
};
|
|
169
|
+
declare type RadioOptionsProps = RadioWithFormik | RadioWithoutFormik;
|
|
170
|
+
interface RadioWithFormik extends RadioGroupProps {
|
|
171
|
+
name: string;
|
|
172
|
+
label?: string;
|
|
173
|
+
options: RadioOptionProps[];
|
|
174
|
+
withFormik?: true;
|
|
175
|
+
}
|
|
176
|
+
interface RadioWithoutFormik extends RadioGroupProps {
|
|
177
|
+
name?: never;
|
|
178
|
+
label?: string;
|
|
179
|
+
options: RadioOptionProps[];
|
|
180
|
+
withFormik: false;
|
|
181
|
+
}
|
|
182
|
+
declare const Radio: ({ name, withFormik, ...rest }: RadioOptionsProps) => JSX.Element;
|
|
183
|
+
|
|
184
|
+
interface LargeButtonProps extends ButtonProps {
|
|
185
|
+
loading?: boolean;
|
|
186
|
+
children: ReactNode;
|
|
187
|
+
CircularProgressProps?: CircularProgressProps;
|
|
188
|
+
}
|
|
189
|
+
declare const LargeButton: ({ loading, children, CircularProgressProps, sx, ...rest }: LargeButtonProps) => JSX.Element;
|
|
190
|
+
|
|
191
|
+
declare function getTabProps(index: string): {
|
|
192
|
+
id: string;
|
|
193
|
+
'aria-controls': string;
|
|
194
|
+
};
|
|
195
|
+
interface TabPanelProps {
|
|
196
|
+
children: React.ReactNode;
|
|
197
|
+
value: number;
|
|
198
|
+
index: number;
|
|
199
|
+
}
|
|
200
|
+
declare const TabPanel: (props: TabPanelProps) => JSX.Element;
|
|
201
|
+
|
|
202
|
+
interface ColumnsProps {
|
|
203
|
+
label: string;
|
|
204
|
+
name?: string;
|
|
205
|
+
width?: number;
|
|
206
|
+
sx?: SxProps;
|
|
207
|
+
canSort?: boolean;
|
|
208
|
+
children?: ReactNode;
|
|
209
|
+
}
|
|
210
|
+
interface GridProps {
|
|
211
|
+
columns: ColumnsProps[];
|
|
212
|
+
children: ReactNode;
|
|
213
|
+
prependColumn?: ReactNode;
|
|
214
|
+
appendColumn?: ReactNode;
|
|
215
|
+
fixedColumns?: boolean;
|
|
216
|
+
sortedBy: string;
|
|
217
|
+
sortedDirection: 'asc' | 'desc';
|
|
218
|
+
dense?: boolean;
|
|
219
|
+
onSortBy: (prop: string) => void;
|
|
220
|
+
paperProps?: PaperProps;
|
|
221
|
+
tableProps?: TableProps;
|
|
222
|
+
tableHeadProps?: TableHeadProps;
|
|
223
|
+
tableBodyProps?: TableBodyProps;
|
|
224
|
+
striped?: boolean;
|
|
225
|
+
bordered?: boolean;
|
|
226
|
+
currentPage: number;
|
|
227
|
+
totalNumberOfPages: number;
|
|
228
|
+
rowsPerPageOptions: number[];
|
|
229
|
+
rowsPerPage: number;
|
|
230
|
+
onPageChange: (pageNumber: number) => void;
|
|
231
|
+
setRowsPerPage: (rows: number) => void;
|
|
232
|
+
isLoading?: boolean;
|
|
233
|
+
hideFooter?: boolean;
|
|
234
|
+
}
|
|
235
|
+
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): JSX.Element;
|
|
236
|
+
|
|
237
|
+
declare type ModalProps = {
|
|
238
|
+
open: boolean;
|
|
239
|
+
onClose: () => void;
|
|
240
|
+
} & ModalProps$1;
|
|
241
|
+
declare const Modal: ({ open, onClose, ...rest }: ModalProps) => JSX.Element;
|
|
242
|
+
|
|
243
|
+
declare function GetInputLabel<T extends Array<Record<string, any>>, K extends T[number]['name']>(columns: T): (columnName: K) => {
|
|
244
|
+
label: any;
|
|
245
|
+
name: any;
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
interface DialogOptionsProps {
|
|
249
|
+
label: string;
|
|
250
|
+
focus?: boolean;
|
|
251
|
+
cb(label: string): void;
|
|
252
|
+
}
|
|
253
|
+
interface DialogCustomProps extends DialogProps {
|
|
254
|
+
open: boolean;
|
|
255
|
+
title: string;
|
|
256
|
+
body: string;
|
|
257
|
+
options: DialogOptionsProps[];
|
|
258
|
+
loading: boolean;
|
|
259
|
+
}
|
|
260
|
+
declare const Dialog: ({ open, title, loading, body, options, ...rest }: DialogCustomProps) => JSX.Element;
|
|
261
|
+
|
|
262
|
+
declare class HttpError extends Error {
|
|
263
|
+
status: number;
|
|
264
|
+
constructor(status: number, message: any);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
declare type PossibleMethods = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
268
|
+
declare type HandlerProps = (req: NextApiRequest & {
|
|
269
|
+
user?: number;
|
|
270
|
+
}, res: NextApiResponse) => Promise<any>;
|
|
271
|
+
declare type MethodProps = Partial<Record<PossibleMethods, HandlerProps>>;
|
|
272
|
+
declare type MiddlewaresProps = ((handler: HandlerProps) => HandlerProps)[];
|
|
273
|
+
declare type ConstructorProps = {
|
|
274
|
+
middlewares?: MiddlewaresProps;
|
|
275
|
+
onFinally: () => void;
|
|
276
|
+
};
|
|
277
|
+
declare class ApiHelper {
|
|
278
|
+
middlewares: MiddlewaresProps;
|
|
279
|
+
private onFinally;
|
|
280
|
+
constructor(props?: ConstructorProps);
|
|
281
|
+
setMiddlewares(middlewares: any[]): this;
|
|
282
|
+
createMethods(methods: MethodProps): (req: NextApiRequest, res: NextApiResponse) => Promise<void>;
|
|
283
|
+
static parserErrorWrapper<Output, Def extends ZodTypeDef, Input>(body: Record<string, any>, parser: ZodSchema<Output, Def, Input>): Output;
|
|
284
|
+
static parseQueyFilters<T extends Record<string, any>>(filters: T): T;
|
|
285
|
+
static create({ onFinally }: {
|
|
286
|
+
onFinally: any;
|
|
287
|
+
}): ApiHelper;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
declare type Methods = 'get' | 'post' | 'put' | 'delete' | 'patch' | 'options';
|
|
291
|
+
declare type HandleProps = {
|
|
292
|
+
name: `${Methods}:${string}`;
|
|
293
|
+
};
|
|
294
|
+
declare type UseFormHelperProps = {
|
|
295
|
+
formatErrorMessage: (message: any) => string;
|
|
296
|
+
api: AxiosInstance;
|
|
297
|
+
};
|
|
298
|
+
declare function useFormHelper({ formatErrorMessage, api }: UseFormHelperProps): {
|
|
299
|
+
onSubmitWrapper: <T extends Record<string, any>>(fn: (fields: T, methods: any) => Promise<void>, { name }: HandleProps) => (fields: T, methods: any) => Promise<void>;
|
|
300
|
+
onRequestWrapper: <F extends (...args: Parameters<F>) => R, R>(fn: F, { name }: HandleProps) => (...params: Parameters<F>) => Promise<R>;
|
|
301
|
+
isLoading: (prop: string) => boolean;
|
|
302
|
+
setLoading: (prop: string, remove?: boolean) => void;
|
|
303
|
+
createAlert(message: string, type: _mui_material.AlertColor): void;
|
|
304
|
+
};
|
|
305
|
+
|
|
306
|
+
declare type FilterCompareType = 'gte' | 'lte' | 'lt' | 'gt' | 'equal' | 'in' | 'notEqual' | 'notIn';
|
|
307
|
+
declare type FilterProps = {
|
|
308
|
+
id?: string;
|
|
309
|
+
prop: string;
|
|
310
|
+
value: unknown;
|
|
311
|
+
compareType: FilterCompareType;
|
|
312
|
+
};
|
|
313
|
+
declare function useFilter(): {
|
|
314
|
+
filters: FilterProps[];
|
|
315
|
+
filterBy: (newFilter: FilterProps) => void;
|
|
316
|
+
removeFilter: (prop: string, isId?: boolean) => void;
|
|
317
|
+
createFilter: typeof createFilter;
|
|
318
|
+
clearAllFilters: () => void;
|
|
319
|
+
};
|
|
320
|
+
declare function createFilter<T extends Record<string, any>>(filters: FilterProps[]): {
|
|
321
|
+
apply: (item: T) => boolean;
|
|
322
|
+
};
|
|
323
|
+
|
|
324
|
+
interface SearchOptions {
|
|
325
|
+
caseSensitive?: boolean;
|
|
326
|
+
exact?: boolean;
|
|
327
|
+
value: string;
|
|
328
|
+
}
|
|
329
|
+
interface UseGridProps {
|
|
330
|
+
columns: ColumnsProps[];
|
|
331
|
+
filters?: FilterProps[];
|
|
332
|
+
rowsPerPageOptions?: number[];
|
|
333
|
+
search?: SearchOptions;
|
|
334
|
+
}
|
|
335
|
+
declare function useGrid<T extends Record<string, any>>({ columns, filters, search, rowsPerPageOptions }: UseGridProps): {
|
|
336
|
+
data: T[];
|
|
337
|
+
set: (data: T[]) => void;
|
|
338
|
+
onSortBy: (prop: string) => void;
|
|
339
|
+
sortedBy: string;
|
|
340
|
+
defaultData: T[];
|
|
341
|
+
sortedDirection: "desc" | "asc";
|
|
342
|
+
columns: ColumnsProps[];
|
|
343
|
+
currentPage: number;
|
|
344
|
+
totalNumberOfPages: number;
|
|
345
|
+
onPageChange: (pageNumber: number) => void;
|
|
346
|
+
setRowsPerPage: (rows: number) => void;
|
|
347
|
+
rowsPerPageOptions: number[];
|
|
348
|
+
rowsPerPage: number;
|
|
349
|
+
setSort: (prop: string, direction: 'desc' | 'asc') => void;
|
|
350
|
+
};
|
|
351
|
+
|
|
352
|
+
declare function useEvent(event: keyof WindowEventMap, handler: (ev: any) => void, passive?: boolean): void;
|
|
353
|
+
|
|
354
|
+
declare function useLoading<T = string>(): {
|
|
355
|
+
isLoading: (prop: T) => boolean;
|
|
356
|
+
setLoading: (prop: T, remove?: boolean) => void;
|
|
357
|
+
};
|
|
358
|
+
|
|
359
|
+
declare const useAlert: () => {
|
|
360
|
+
createAlert(message: string, type: _mui_material.AlertColor): void;
|
|
361
|
+
};
|
|
362
|
+
|
|
363
|
+
declare type AlertContextProps = {
|
|
364
|
+
createAlert(message: string, type: AlertColor): void;
|
|
365
|
+
};
|
|
366
|
+
declare const AlertContext: React.Context<AlertContextProps>;
|
|
367
|
+
|
|
368
|
+
export { AlertContext, ApiHelper, Autocomplete, BaseGrid, Checkbox, type ColumnTitleProps, type ColumnsProps, Dialog, EditableTableCell, type FilterCompareType, type FilterProps, GetInputLabel, Grid, HttpError, type IFilter, Input, InputMask, LargeButton, Modal, Radio, Select, Switch, TabPanel, type TabPanelProps, Td, Tr, createFilter, filterData, getTabProps, useAlert, useEvent, useFilter, useFormHelper, useGrid, useLoading };
|