@bluemarble/bm-components 2.4.1 → 3.0.0-beta.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.cjs +1600 -1365
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +251 -154
- package/dist/index.d.ts +251 -154
- package/dist/index.js +1918 -1683
- package/dist/index.js.map +1 -1
- package/package.json +26 -29
package/dist/index.d.cts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import * as cookie from 'cookie';
|
|
2
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
1
3
|
import * as React from 'react';
|
|
2
4
|
import React__default, { PropsWithChildren, ReactNode, FC, Provider } from 'react';
|
|
3
5
|
import * as _mui_material from '@mui/material';
|
|
@@ -5,25 +7,118 @@ import { TableCellProps, TableCell, TextFieldProps, StandardTextFieldProps, Sele
|
|
|
5
7
|
import * as _mui_material_OverridableComponent from '@mui/material/OverridableComponent';
|
|
6
8
|
import { FactoryOpts } from 'imask';
|
|
7
9
|
import { IconType } from 'react-icons';
|
|
8
|
-
import * as next from 'next';
|
|
9
|
-
import { NextApiRequest, NextApiResponse, GetServerSidePropsContext } from 'next';
|
|
10
10
|
import { ZodSchema } from 'zod';
|
|
11
|
-
import { AxiosInstance } from 'axios';
|
|
12
|
-
import * as cookie from 'cookie';
|
|
13
|
-
import * as express from 'express';
|
|
14
11
|
|
|
12
|
+
interface AuthConfig {
|
|
13
|
+
getToken: () => string | null | Promise<string | null>;
|
|
14
|
+
refreshToken?: () => Promise<string | null>;
|
|
15
|
+
maxRetries?: number;
|
|
16
|
+
}
|
|
17
|
+
interface HttpClientConfig {
|
|
18
|
+
baseURL?: string;
|
|
19
|
+
headers?: Record<string, string>;
|
|
20
|
+
timeout?: number;
|
|
21
|
+
auth?: AuthConfig;
|
|
22
|
+
}
|
|
23
|
+
interface RequestConfig {
|
|
24
|
+
method?: string;
|
|
25
|
+
url: string;
|
|
26
|
+
headers?: Record<string, string>;
|
|
27
|
+
params?: Record<string, string | number | boolean | undefined>;
|
|
28
|
+
data?: unknown;
|
|
29
|
+
timeout?: number;
|
|
30
|
+
signal?: AbortSignal;
|
|
31
|
+
responseType?: 'json' | 'text' | 'arraybuffer' | 'blob';
|
|
32
|
+
}
|
|
33
|
+
interface HttpResponse<T = any> {
|
|
34
|
+
data: T;
|
|
35
|
+
status: number;
|
|
36
|
+
statusText: string;
|
|
37
|
+
headers: Record<string, string>;
|
|
38
|
+
}
|
|
39
|
+
interface HttpClient {
|
|
40
|
+
request<T = any>(config: RequestConfig): Promise<HttpResponse<T>>;
|
|
41
|
+
get<T = any>(url: string, config?: Omit<RequestConfig, 'url' | 'method' | 'data'>): Promise<HttpResponse<T>>;
|
|
42
|
+
post<T = any>(url: string, data?: unknown, config?: Omit<RequestConfig, 'url' | 'method' | 'data'>): Promise<HttpResponse<T>>;
|
|
43
|
+
put<T = any>(url: string, data?: unknown, config?: Omit<RequestConfig, 'url' | 'method' | 'data'>): Promise<HttpResponse<T>>;
|
|
44
|
+
patch<T = any>(url: string, data?: unknown, config?: Omit<RequestConfig, 'url' | 'method' | 'data'>): Promise<HttpResponse<T>>;
|
|
45
|
+
delete<T = any>(url: string, config?: Omit<RequestConfig, 'url' | 'method' | 'data'>): Promise<HttpResponse<T>>;
|
|
46
|
+
setHeader(key: string, value: string | null): void;
|
|
47
|
+
abort(): void;
|
|
48
|
+
}
|
|
49
|
+
declare class HttpClientError extends Error {
|
|
50
|
+
status: number;
|
|
51
|
+
statusText: string;
|
|
52
|
+
data: unknown;
|
|
53
|
+
constructor(status: number, statusText: string, data: unknown);
|
|
54
|
+
static isHttpClientError(e: unknown): e is HttpClientError;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
declare function createHttpClient(clientConfig?: HttpClientConfig): HttpClient;
|
|
58
|
+
|
|
59
|
+
interface NookiesRequest {
|
|
60
|
+
headers?: {
|
|
61
|
+
cookie?: string;
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
interface NookiesResponse {
|
|
65
|
+
finished?: boolean;
|
|
66
|
+
getHeader(name: string): string | string[] | number | undefined;
|
|
67
|
+
setHeader(name: string, value: string | readonly string[]): any;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Parses cookies.
|
|
72
|
+
*
|
|
73
|
+
* @param ctx Object with a `req` property, null or undefined.
|
|
74
|
+
* @param options Options that we pass down to `cookie` library.
|
|
75
|
+
*/
|
|
76
|
+
declare function parseCookies(ctx?: {
|
|
77
|
+
req: NookiesRequest;
|
|
78
|
+
} | null | undefined, options?: cookie.ParseOptions): cookie.Cookies;
|
|
79
|
+
/**
|
|
80
|
+
* Sets a cookie.
|
|
81
|
+
*
|
|
82
|
+
* @param ctx Object with a `res` property, null or undefined.
|
|
83
|
+
* @param name The name of your cookie.
|
|
84
|
+
* @param value The value of your cookie.
|
|
85
|
+
* @param options Options that we pass down to `cookie` library.
|
|
86
|
+
*/
|
|
87
|
+
declare function setCookie(ctx: {
|
|
88
|
+
res: NookiesResponse;
|
|
89
|
+
} | null | undefined, name: string, value: string, options?: cookie.SerializeOptions): {};
|
|
90
|
+
/**
|
|
91
|
+
* Destroys a cookie with a particular name.
|
|
92
|
+
*
|
|
93
|
+
* @param ctx Object with a `res` property, null or undefined.
|
|
94
|
+
* @param name Cookie name.
|
|
95
|
+
* @param options Options that we pass down to `cookie` library.
|
|
96
|
+
*/
|
|
97
|
+
declare function destroyCookie(ctx: {
|
|
98
|
+
res: NookiesResponse;
|
|
99
|
+
} | null | undefined, name: string, options?: cookie.SerializeOptions): {};
|
|
100
|
+
declare const nookies: {
|
|
101
|
+
set: typeof setCookie;
|
|
102
|
+
get: typeof parseCookies;
|
|
103
|
+
destroy: typeof destroyCookie;
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
/** @deprecated Use {@link ColumnsProps} from `BaseGrid` instead. */
|
|
15
107
|
interface ColumnTitleProps {
|
|
16
108
|
name: string;
|
|
17
109
|
label: string;
|
|
18
110
|
transformer?: (value: string | number | Date) => string;
|
|
19
111
|
sx?: TableCellProps['sx'];
|
|
20
112
|
}
|
|
113
|
+
/** @deprecated Use {@link FilterProps} from `useFilter` instead. */
|
|
21
114
|
interface FilterProps$1 {
|
|
22
115
|
column: string;
|
|
23
116
|
value: string;
|
|
24
117
|
transformer?: (value: string | number | Date) => string;
|
|
25
118
|
}
|
|
119
|
+
/** @deprecated Use {@link FilterProps} from `useFilter` instead. */
|
|
26
120
|
type IFilter = FilterProps$1;
|
|
121
|
+
/** @deprecated */
|
|
27
122
|
interface GridProps$1<T> {
|
|
28
123
|
columnTitles: ColumnTitleProps[];
|
|
29
124
|
defaultData: T[];
|
|
@@ -41,14 +136,22 @@ interface GridProps$1<T> {
|
|
|
41
136
|
noFilters?: boolean;
|
|
42
137
|
primaryKey?: string;
|
|
43
138
|
}
|
|
44
|
-
|
|
139
|
+
/**
|
|
140
|
+
* @deprecated Use {@link BaseGrid} with the {@link useGrid} or {@link useAsyncGrid} hook instead.
|
|
141
|
+
* `BaseGrid` separates rendering from state management, eliminating the need to pass
|
|
142
|
+
* `tableData`, `setTableData`, `selectedFilters`, and `updateFilters` as props.
|
|
143
|
+
*/
|
|
144
|
+
declare const Grid: <ObjectType>(props: PropsWithChildren<GridProps$1<ObjectType>>) => react_jsx_runtime.JSX.Element;
|
|
45
145
|
|
|
146
|
+
/** @deprecated Use the `useFilter` hook instead. */
|
|
46
147
|
declare function filterData<T>(filters: FilterProps$1[], defaultData: {
|
|
47
148
|
current: T[];
|
|
48
149
|
}): T[];
|
|
49
150
|
|
|
151
|
+
/** @deprecated Use `TableRow` from `@mui/material` directly. */
|
|
50
152
|
declare const Tr: _mui_material_OverridableComponent.OverridableComponent<_mui_material.TableRowTypeMap<{}, "tr">>;
|
|
51
153
|
|
|
154
|
+
/** @deprecated Use `TableCell` from `@mui/material` directly. */
|
|
52
155
|
declare const Td: typeof TableCell;
|
|
53
156
|
|
|
54
157
|
interface EditableTableCellProps extends TableCellProps {
|
|
@@ -71,7 +174,7 @@ interface OnSaveProps {
|
|
|
71
174
|
value: string;
|
|
72
175
|
data: Record<string, any>;
|
|
73
176
|
}
|
|
74
|
-
declare const EditableTableCell: (allProps: EditableTableCellProps) =>
|
|
177
|
+
declare const EditableTableCell: (allProps: EditableTableCellProps) => react_jsx_runtime.JSX.Element;
|
|
75
178
|
|
|
76
179
|
interface InputProps extends StandardTextFieldProps {
|
|
77
180
|
name: string;
|
|
@@ -89,7 +192,7 @@ interface InputMaskProps extends Partial<StandardTextFieldProps> {
|
|
|
89
192
|
mask: FactoryOpts;
|
|
90
193
|
onChangeValue?: (value: string, unmaskedValue: string) => void;
|
|
91
194
|
}
|
|
92
|
-
declare function InputMask({ withFormik, ...rest }: InputMaskProps):
|
|
195
|
+
declare function InputMask({ withFormik, ...rest }: InputMaskProps): react_jsx_runtime.JSX.Element;
|
|
93
196
|
|
|
94
197
|
interface CustomInputLabelProps extends InputLabelProps {
|
|
95
198
|
size?: 'small';
|
|
@@ -103,7 +206,7 @@ type SelectProps<T> = MuiSelectPropsWithouVariant<T> & {
|
|
|
103
206
|
InputLabelProps?: Partial<CustomInputLabelProps>;
|
|
104
207
|
helperText?: string;
|
|
105
208
|
};
|
|
106
|
-
declare function Select<T>({ withFormik, ...rest }: SelectProps<T>):
|
|
209
|
+
declare function Select<T>({ withFormik, helperText, ...rest }: SelectProps<T>): react_jsx_runtime.JSX.Element;
|
|
107
210
|
|
|
108
211
|
type MuiAutocompleteBaseProps<T> = Omit<AutocompleteProps$1<T, boolean, undefined, boolean>, 'renderInput' | 'getOptionLabel'>;
|
|
109
212
|
interface AutocompleteWithoutProps<T> extends MuiAutocompleteBaseProps<T> {
|
|
@@ -132,37 +235,41 @@ interface AutocompleteWithFormikProps<T> extends MuiAutocompleteBaseProps<T> {
|
|
|
132
235
|
getOptionValue?: (option: T) => string | number;
|
|
133
236
|
}
|
|
134
237
|
type AutocompleteProps<T> = AutocompleteWithoutProps<T> | AutocompleteWithFormikProps<T>;
|
|
135
|
-
declare function Autocomplete<T>({ withFormik, name, getOptionValue, ...rest }: AutocompleteProps<T>):
|
|
238
|
+
declare function Autocomplete<T>({ withFormik, name, getOptionValue, ...rest }: AutocompleteProps<T>): react_jsx_runtime.JSX.Element;
|
|
136
239
|
|
|
137
240
|
type CheckboxProps = CheckboxWithFormik | CheckboxWithoutFormik;
|
|
138
241
|
interface CheckboxWithFormik extends CheckboxProps$1 {
|
|
139
242
|
name: string;
|
|
140
243
|
label?: string;
|
|
244
|
+
helperText?: string;
|
|
141
245
|
withFormik?: true;
|
|
142
246
|
FormControlLabelProps?: Partial<FormControlLabelProps>;
|
|
143
247
|
}
|
|
144
248
|
interface CheckboxWithoutFormik extends CheckboxProps$1 {
|
|
145
249
|
name?: never;
|
|
146
250
|
label?: string;
|
|
251
|
+
helperText?: string;
|
|
147
252
|
withFormik: false;
|
|
148
253
|
FormControlLabelProps?: Partial<FormControlLabelProps>;
|
|
149
254
|
}
|
|
150
|
-
declare const Checkbox: ({ withFormik, name, ...props }: CheckboxProps) =>
|
|
255
|
+
declare const Checkbox: ({ withFormik, name, ...props }: CheckboxProps) => react_jsx_runtime.JSX.Element;
|
|
151
256
|
|
|
152
257
|
type SwitchProps = SwitchWithFormik | SwitchWithoutFormik;
|
|
153
258
|
interface SwitchWithFormik extends SwitchProps$1 {
|
|
154
259
|
name: string;
|
|
155
260
|
label?: string;
|
|
261
|
+
helperText?: string;
|
|
156
262
|
withFormik?: true;
|
|
157
263
|
FormControlLabelProps?: Partial<FormControlLabelProps>;
|
|
158
264
|
}
|
|
159
265
|
interface SwitchWithoutFormik extends SwitchProps$1 {
|
|
160
266
|
name?: never;
|
|
161
267
|
label?: string;
|
|
268
|
+
helperText?: string;
|
|
162
269
|
withFormik: false;
|
|
163
270
|
FormControlLabelProps?: Partial<FormControlLabelProps>;
|
|
164
271
|
}
|
|
165
|
-
declare const Switch: ({ withFormik, name, ...props }: SwitchProps) =>
|
|
272
|
+
declare const Switch: ({ withFormik, name, ...props }: SwitchProps) => react_jsx_runtime.JSX.Element;
|
|
166
273
|
|
|
167
274
|
type RadioOptionProps = {
|
|
168
275
|
value: string | number | boolean;
|
|
@@ -173,22 +280,24 @@ interface RadioWithFormik extends RadioGroupProps {
|
|
|
173
280
|
name: string;
|
|
174
281
|
label?: string;
|
|
175
282
|
options: RadioOptionProps[];
|
|
283
|
+
helperText?: string;
|
|
176
284
|
withFormik?: true;
|
|
177
285
|
}
|
|
178
286
|
interface RadioWithoutFormik extends RadioGroupProps {
|
|
179
287
|
name?: never;
|
|
180
288
|
label?: string;
|
|
181
289
|
options: RadioOptionProps[];
|
|
290
|
+
helperText?: string;
|
|
182
291
|
withFormik: false;
|
|
183
292
|
}
|
|
184
|
-
declare const Radio: ({ name, withFormik, ...rest }: RadioOptionsProps) =>
|
|
293
|
+
declare const Radio: ({ name, withFormik, ...rest }: RadioOptionsProps) => react_jsx_runtime.JSX.Element;
|
|
185
294
|
|
|
186
295
|
interface LargeButtonProps extends ButtonProps {
|
|
187
296
|
loading?: boolean;
|
|
188
297
|
children: ReactNode;
|
|
189
298
|
CircularProgressProps?: CircularProgressProps;
|
|
190
299
|
}
|
|
191
|
-
declare const LargeButton: ({ loading, children, CircularProgressProps, sx, ...rest }: LargeButtonProps) =>
|
|
300
|
+
declare const LargeButton: ({ loading, children, CircularProgressProps, sx, ...rest }: LargeButtonProps) => react_jsx_runtime.JSX.Element;
|
|
192
301
|
|
|
193
302
|
declare function getTabProps(index: string): {
|
|
194
303
|
id: string;
|
|
@@ -199,7 +308,7 @@ interface TabPanelProps {
|
|
|
199
308
|
value: number;
|
|
200
309
|
index: number;
|
|
201
310
|
}
|
|
202
|
-
declare const TabPanel: (props: TabPanelProps) =>
|
|
311
|
+
declare const TabPanel: (props: TabPanelProps) => react_jsx_runtime.JSX.Element;
|
|
203
312
|
|
|
204
313
|
type FilterCompareType = 'gte' | 'lte' | 'lt' | 'gt' | 'equal' | 'valueIn' | 'in' | 'notEqual' | 'valueNotIn' | 'notIn';
|
|
205
314
|
type FilterProps = {
|
|
@@ -299,14 +408,14 @@ interface GridProps {
|
|
|
299
408
|
isLoading?: boolean;
|
|
300
409
|
hideFooter?: boolean;
|
|
301
410
|
}
|
|
302
|
-
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):
|
|
411
|
+
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_jsx_runtime.JSX.Element;
|
|
303
412
|
|
|
304
413
|
interface BaseGridAutoRowsProps<T> {
|
|
305
414
|
columns: ColumnsProps<any>[];
|
|
306
415
|
data: T[];
|
|
307
416
|
rowKey: keyof T;
|
|
308
417
|
}
|
|
309
|
-
declare function BaseGridAutoRows<T>({ data, columns, rowKey }: BaseGridAutoRowsProps<T>):
|
|
418
|
+
declare function BaseGridAutoRows<T>({ data, columns, rowKey }: BaseGridAutoRowsProps<T>): react_jsx_runtime.JSX.Element;
|
|
310
419
|
|
|
311
420
|
type TModalProps = {
|
|
312
421
|
open: boolean;
|
|
@@ -314,7 +423,10 @@ type TModalProps = {
|
|
|
314
423
|
children: React__default.ReactNode;
|
|
315
424
|
BoxProps?: BoxProps;
|
|
316
425
|
} & Omit<ModalProps, 'children'>;
|
|
317
|
-
|
|
426
|
+
/**
|
|
427
|
+
* @deprecated Use `Dialog` or `BaseDialog` instead. `Modal` will be removed in a future release.
|
|
428
|
+
*/
|
|
429
|
+
declare const Modal: ({ open, onClose, BoxProps, ...rest }: TModalProps) => react_jsx_runtime.JSX.Element;
|
|
318
430
|
|
|
319
431
|
declare function GetInputLabel<T extends Array<Record<string, any>>, K extends T[number]['name']>(columns: T): (columnName: K) => {
|
|
320
432
|
label: any;
|
|
@@ -333,7 +445,7 @@ interface DialogCustomProps extends DialogProps {
|
|
|
333
445
|
options: DialogOptionsProps[];
|
|
334
446
|
loading: boolean;
|
|
335
447
|
}
|
|
336
|
-
declare const Dialog: ({ open, title, loading, body, options, ...rest }: DialogCustomProps) =>
|
|
448
|
+
declare const Dialog: ({ open, title, loading, body, options, ...rest }: DialogCustomProps) => react_jsx_runtime.JSX.Element;
|
|
337
449
|
|
|
338
450
|
interface IDialogChildrenProps {
|
|
339
451
|
onConfirm: (fn: (...params: any[]) => Promise<void>) => (...params: any[]) => Promise<void>;
|
|
@@ -357,7 +469,7 @@ declare function UseDialogConfirm(): {
|
|
|
357
469
|
onProceed: (event: any) => Promise<void>;
|
|
358
470
|
};
|
|
359
471
|
|
|
360
|
-
declare const DialogConfirm: (props: IDialogConfirmProps) =>
|
|
472
|
+
declare const DialogConfirm: (props: IDialogConfirmProps) => react_jsx_runtime.JSX.Element;
|
|
361
473
|
|
|
362
474
|
interface DialogHeaderProps extends StackProps {
|
|
363
475
|
title: string;
|
|
@@ -391,39 +503,75 @@ interface IBaseDialogContainerProps extends Omit<TModalProps, 'children' | 'open
|
|
|
391
503
|
close: () => void;
|
|
392
504
|
}) => React__default.ReactNode);
|
|
393
505
|
}
|
|
394
|
-
declare const BaseDialogContainer: ({ children, ...rest }: IBaseDialogContainerProps) =>
|
|
506
|
+
declare const BaseDialogContainer: ({ children, ...rest }: IBaseDialogContainerProps) => react_jsx_runtime.JSX.Element;
|
|
395
507
|
interface IBaseDialogBodyProps extends BoxProps {
|
|
396
508
|
}
|
|
397
|
-
declare const BaseDialogBody: (props: IBaseDialogBodyProps) =>
|
|
509
|
+
declare const BaseDialogBody: (props: IBaseDialogBodyProps) => react_jsx_runtime.JSX.Element;
|
|
398
510
|
interface IBaseDialogTriggerProps extends Omit<ButtonProps, 'name'> {
|
|
399
511
|
name: symbol;
|
|
400
512
|
}
|
|
401
|
-
declare const BaseDialogTrigger: ({ name, onClick, ...props }: IBaseDialogTriggerProps) =>
|
|
513
|
+
declare const BaseDialogTrigger: ({ name, onClick, ...props }: IBaseDialogTriggerProps) => react_jsx_runtime.JSX.Element;
|
|
402
514
|
declare const BaseDialogCreate: (name?: symbol) => {
|
|
403
515
|
name: symbol;
|
|
404
|
-
Trigger: (props: Omit<IBaseDialogTriggerProps, "name">) =>
|
|
405
|
-
Root: (props: Omit<IBaseDialogInstanceProviderProps, "name">) =>
|
|
406
|
-
Container: ({ children, ...rest }: IBaseDialogContainerProps) =>
|
|
407
|
-
Header: ({ title, onClose, IconButtonProps, TypographyProps, ...props }: DialogHeaderProps) =>
|
|
408
|
-
Body: (props: IBaseDialogBodyProps) =>
|
|
516
|
+
Trigger: (props: Omit<IBaseDialogTriggerProps, "name">) => react_jsx_runtime.JSX.Element;
|
|
517
|
+
Root: (props: Omit<IBaseDialogInstanceProviderProps, "name">) => react_jsx_runtime.JSX.Element;
|
|
518
|
+
Container: ({ children, ...rest }: IBaseDialogContainerProps) => react_jsx_runtime.JSX.Element;
|
|
519
|
+
Header: ({ title, onClose, IconButtonProps, TypographyProps, ...props }: DialogHeaderProps) => react_jsx_runtime.JSX.Element;
|
|
520
|
+
Body: (props: IBaseDialogBodyProps) => react_jsx_runtime.JSX.Element;
|
|
409
521
|
};
|
|
410
522
|
declare const BaseDialog: {
|
|
411
523
|
Create: (name?: symbol) => {
|
|
412
524
|
name: symbol;
|
|
413
|
-
Trigger: (props: Omit<IBaseDialogTriggerProps, "name">) =>
|
|
414
|
-
Root: (props: Omit<IBaseDialogInstanceProviderProps, "name">) =>
|
|
415
|
-
Container: ({ children, ...rest }: IBaseDialogContainerProps) =>
|
|
416
|
-
Header: ({ title, onClose, IconButtonProps, TypographyProps, ...props }: DialogHeaderProps) =>
|
|
417
|
-
Body: (props: IBaseDialogBodyProps) =>
|
|
525
|
+
Trigger: (props: Omit<IBaseDialogTriggerProps, "name">) => react_jsx_runtime.JSX.Element;
|
|
526
|
+
Root: (props: Omit<IBaseDialogInstanceProviderProps, "name">) => react_jsx_runtime.JSX.Element;
|
|
527
|
+
Container: ({ children, ...rest }: IBaseDialogContainerProps) => react_jsx_runtime.JSX.Element;
|
|
528
|
+
Header: ({ title, onClose, IconButtonProps, TypographyProps, ...props }: DialogHeaderProps) => react_jsx_runtime.JSX.Element;
|
|
529
|
+
Body: (props: IBaseDialogBodyProps) => react_jsx_runtime.JSX.Element;
|
|
418
530
|
};
|
|
419
|
-
Trigger: ({ name, onClick, ...props }: IBaseDialogTriggerProps) =>
|
|
420
|
-
Provider: (props: any) =>
|
|
421
|
-
Root: (props: IBaseDialogInstanceProviderProps) =>
|
|
422
|
-
Container: ({ children, ...rest }: IBaseDialogContainerProps) =>
|
|
423
|
-
Header: ({ title, onClose, IconButtonProps, TypographyProps, ...props }: DialogHeaderProps) =>
|
|
424
|
-
Body: (props: IBaseDialogBodyProps) =>
|
|
531
|
+
Trigger: ({ name, onClick, ...props }: IBaseDialogTriggerProps) => react_jsx_runtime.JSX.Element;
|
|
532
|
+
Provider: (props: any) => react_jsx_runtime.JSX.Element;
|
|
533
|
+
Root: (props: IBaseDialogInstanceProviderProps) => react_jsx_runtime.JSX.Element;
|
|
534
|
+
Container: ({ children, ...rest }: IBaseDialogContainerProps) => react_jsx_runtime.JSX.Element;
|
|
535
|
+
Header: ({ title, onClose, IconButtonProps, TypographyProps, ...props }: DialogHeaderProps) => react_jsx_runtime.JSX.Element;
|
|
536
|
+
Body: (props: IBaseDialogBodyProps) => react_jsx_runtime.JSX.Element;
|
|
425
537
|
};
|
|
426
538
|
|
|
539
|
+
type FormHelperContextProps = {
|
|
540
|
+
formatErrorMessage: (message: any) => string;
|
|
541
|
+
api: HttpClient;
|
|
542
|
+
};
|
|
543
|
+
declare const FormHelperContext: React__default.Context<FormHelperContextProps>;
|
|
544
|
+
type FormHelperProviderProps = {
|
|
545
|
+
formatErrorMessage: (message: any) => string;
|
|
546
|
+
children: ReactNode;
|
|
547
|
+
api: HttpClient;
|
|
548
|
+
};
|
|
549
|
+
declare const FormHelperProvider: ({ formatErrorMessage, api, children }: FormHelperProviderProps) => react_jsx_runtime.JSX.Element;
|
|
550
|
+
|
|
551
|
+
type AlertContextProps = {
|
|
552
|
+
createAlert(message: string, type: AlertColor): void;
|
|
553
|
+
};
|
|
554
|
+
declare const AlertContext: React__default.Context<AlertContextProps>;
|
|
555
|
+
type AlertProviderProps = {
|
|
556
|
+
children: ReactNode;
|
|
557
|
+
};
|
|
558
|
+
declare const AlertProvider: ({ children }: AlertProviderProps) => react_jsx_runtime.JSX.Element;
|
|
559
|
+
|
|
560
|
+
type AuthenticateStatus = 'autenticated' | 'unauthenticated' | 'loading';
|
|
561
|
+
interface AuthContextProps<T> {
|
|
562
|
+
user?: T;
|
|
563
|
+
status: AuthenticateStatus;
|
|
564
|
+
signIn(credentials: Record<string, any>): Promise<boolean>;
|
|
565
|
+
signOut: () => Promise<void>;
|
|
566
|
+
}
|
|
567
|
+
declare function createAuthContext<T>(): React.Context<AuthContextProps<T>>;
|
|
568
|
+
declare function CreateAuthProvider<T>({ api, children, sessionTokenName, Provider }: {
|
|
569
|
+
Provider: Provider<AuthContextProps<T>>;
|
|
570
|
+
children: ReactNode;
|
|
571
|
+
api: HttpClient;
|
|
572
|
+
sessionTokenName: string;
|
|
573
|
+
}): react_jsx_runtime.JSX.Element;
|
|
574
|
+
|
|
427
575
|
declare class HttpError extends Error {
|
|
428
576
|
status: number;
|
|
429
577
|
constructor(status: number, message: any);
|
|
@@ -433,58 +581,73 @@ declare class DomainError extends Error {
|
|
|
433
581
|
constructor(message: any);
|
|
434
582
|
}
|
|
435
583
|
|
|
584
|
+
interface ApiHelperRequest {
|
|
585
|
+
url?: string;
|
|
586
|
+
method?: string;
|
|
587
|
+
headers: {
|
|
588
|
+
authorization?: string;
|
|
589
|
+
cookie?: string;
|
|
590
|
+
[key: string]: string | string[] | undefined;
|
|
591
|
+
};
|
|
592
|
+
cookies: Partial<Record<string, string | string[] | undefined>>;
|
|
593
|
+
body?: any;
|
|
594
|
+
query: Partial<{
|
|
595
|
+
[key: string]: string | string[];
|
|
596
|
+
}>;
|
|
597
|
+
user?: any;
|
|
598
|
+
}
|
|
599
|
+
interface ApiHelperResponse {
|
|
600
|
+
finished?: boolean;
|
|
601
|
+
status(code: number): ApiHelperResponse;
|
|
602
|
+
json(data: any): any;
|
|
603
|
+
end(data?: any): any;
|
|
604
|
+
getHeader(name: string): string | string[] | number | undefined;
|
|
605
|
+
setHeader(name: string, value: string | readonly string[]): any;
|
|
606
|
+
}
|
|
607
|
+
interface ServerSidePropsContext {
|
|
608
|
+
query: Record<string, string | string[] | undefined>;
|
|
609
|
+
res: ApiHelperResponse;
|
|
610
|
+
}
|
|
611
|
+
|
|
436
612
|
type PossibleMethods = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'ALL';
|
|
437
|
-
type NextHandlerApiRequest<
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
type
|
|
441
|
-
type
|
|
442
|
-
type
|
|
443
|
-
type ConstructorProps$1<T> = {
|
|
613
|
+
type NextHandlerApiRequest<Req extends ApiHelperRequest = ApiHelperRequest> = Req;
|
|
614
|
+
type HandlerProps<Req extends ApiHelperRequest = ApiHelperRequest, Res extends ApiHelperResponse = ApiHelperResponse> = (req: NextHandlerApiRequest<Req>, res: Res, options?: TApiOptions<Req, Res>) => Promise<any>;
|
|
615
|
+
type MethodProps<Req extends ApiHelperRequest = ApiHelperRequest, Res extends ApiHelperResponse = ApiHelperResponse> = Partial<Record<PossibleMethods, HandlerProps<Req, Res>>>;
|
|
616
|
+
type MiddlewareHandler<Req extends ApiHelperRequest = ApiHelperRequest, Res extends ApiHelperResponse = ApiHelperResponse> = (handler: HandlerProps<Req, Res>, options?: TApiOptions<Req, Res>) => HandlerProps<Req, Res>;
|
|
617
|
+
type MiddlewaresProps<Req extends ApiHelperRequest = ApiHelperRequest, Res extends ApiHelperResponse = ApiHelperResponse> = MiddlewareHandler<Req, Res>[];
|
|
618
|
+
type ConstructorProps$1<Req extends ApiHelperRequest = ApiHelperRequest, Res extends ApiHelperResponse = ApiHelperResponse> = {
|
|
444
619
|
public?: boolean;
|
|
445
|
-
middlewares?: MiddlewaresProps<
|
|
446
|
-
onFinally?: (req:
|
|
447
|
-
onError?: (req:
|
|
620
|
+
middlewares?: MiddlewaresProps<Req, Res>;
|
|
621
|
+
onFinally?: (req: Req, res: Res) => Promise<void>;
|
|
622
|
+
onError?: (req: Req, res: Res) => Promise<void>;
|
|
448
623
|
};
|
|
449
|
-
type TApiOptions = {
|
|
624
|
+
type TApiOptions<Req extends ApiHelperRequest = ApiHelperRequest, Res extends ApiHelperResponse = ApiHelperResponse> = {
|
|
450
625
|
public?: boolean;
|
|
451
|
-
middlewares?: MiddlewaresProps<
|
|
626
|
+
middlewares?: MiddlewaresProps<Req, Res>;
|
|
452
627
|
};
|
|
453
|
-
declare class ApiHelper<
|
|
628
|
+
declare class ApiHelper<Req extends ApiHelperRequest = ApiHelperRequest, Res extends ApiHelperResponse = ApiHelperResponse> {
|
|
454
629
|
private middlewares;
|
|
455
630
|
private public;
|
|
456
631
|
private onFinally;
|
|
457
632
|
private onError;
|
|
458
|
-
constructor(props?: ConstructorProps$1<
|
|
459
|
-
createMethods(methods: MethodProps<
|
|
633
|
+
constructor(props?: ConstructorProps$1<Req, Res>);
|
|
634
|
+
createMethods(methods: MethodProps<Req, Res>): (req: Req, res: Res) => Promise<any>;
|
|
460
635
|
private buildFactory;
|
|
461
|
-
static build(factory: (req:
|
|
636
|
+
static build<Req extends ApiHelperRequest = ApiHelperRequest, Res extends ApiHelperResponse = ApiHelperResponse>(factory: (req: Req, res: Res) => MethodProps<Req, Res>, options?: TApiOptions<Req, Res>): (req: Req, res: Res) => Promise<any>;
|
|
462
637
|
static parse<Output, Def>(body: Record<string, any>, parser: ZodSchema<Output, Def>): Output;
|
|
463
638
|
/** @deprecated Use {@link ApiHelper.parser} instead. */
|
|
464
639
|
static parserErrorWrapper: typeof ApiHelper.parse;
|
|
465
640
|
/** @deprecated Use {@Link ApiHelper.build} instead. */
|
|
466
641
|
static create({ onFinally }: {
|
|
467
642
|
onFinally: any;
|
|
468
|
-
}): ApiHelper<
|
|
643
|
+
}): ApiHelper<ApiHelperRequest, ApiHelperResponse>;
|
|
469
644
|
}
|
|
470
645
|
|
|
471
|
-
type
|
|
472
|
-
type HandleProps = {
|
|
473
|
-
name: `${Methods}:${string}`;
|
|
474
|
-
};
|
|
475
|
-
declare function useFormHelper(): {
|
|
476
|
-
onSubmitWrapper: <T extends Record<string, any>>(fn: (fields: T, methods: any) => Promise<void>, { name }: HandleProps) => (fields: T, methods: any) => Promise<void>;
|
|
477
|
-
onRequestWrapper: <F extends (...args: Parameters<F>) => R, R>(fn: F, { name }: HandleProps) => (...params: Parameters<F>) => Promise<R>;
|
|
478
|
-
isLoading: (prop: string) => boolean;
|
|
479
|
-
setLoading: (prop: string, remove?: boolean) => void;
|
|
480
|
-
createAlert(message: string, type: _mui_material.AlertColor): void;
|
|
481
|
-
};
|
|
482
|
-
|
|
483
|
-
type NextApiRequestWithAuth = NextApiRequest & {
|
|
646
|
+
type AuthRequest = ApiHelperRequest & {
|
|
484
647
|
user?: any;
|
|
485
648
|
};
|
|
486
649
|
interface OnLoginSuccessResponse {
|
|
487
|
-
status: '
|
|
650
|
+
status: 'success';
|
|
488
651
|
userId: string;
|
|
489
652
|
}
|
|
490
653
|
interface OnLoginFailedResponse {
|
|
@@ -525,7 +688,7 @@ declare class AuthHelper {
|
|
|
525
688
|
onCreateRefreshToken: ConstructorProps['onCreateRefreshToken'];
|
|
526
689
|
onGetUserData: ConstructorProps['onGetUserData'];
|
|
527
690
|
constructor({ cookies, oauth, tokenExpTimeInSeconds, onLogin, onValidateRefreshToken, onInvalidateRefreshToken, onCreateRefreshToken, onGetUserData }: ConstructorProps);
|
|
528
|
-
handler(req:
|
|
691
|
+
handler(req: AuthRequest, res: ApiHelperResponse): Promise<any>;
|
|
529
692
|
oauthSignInCallback(code: string): Promise<{
|
|
530
693
|
decodedToken: {
|
|
531
694
|
upn: string;
|
|
@@ -538,7 +701,7 @@ declare class AuthHelper {
|
|
|
538
701
|
createOauthCallbackGetServerSideProps({ onSuccessDestination, onFailedDestination }: {
|
|
539
702
|
onSuccessDestination: string;
|
|
540
703
|
onFailedDestination?: string;
|
|
541
|
-
}): (ctx:
|
|
704
|
+
}): (ctx: ServerSidePropsContext) => Promise<{
|
|
542
705
|
redirect: {
|
|
543
706
|
permanent: boolean;
|
|
544
707
|
destination: string;
|
|
@@ -551,7 +714,7 @@ declare class AuthHelper {
|
|
|
551
714
|
redirect?: undefined;
|
|
552
715
|
}>;
|
|
553
716
|
private generateJwtAndRefreshToken;
|
|
554
|
-
invalidateCookies: (res:
|
|
717
|
+
invalidateCookies: (res: ApiHelperResponse) => any;
|
|
555
718
|
}
|
|
556
719
|
|
|
557
720
|
type SortedDirectionProps = 'asc' | 'desc';
|
|
@@ -582,16 +745,16 @@ type UseGridPropsOnRequest<T> = {
|
|
|
582
745
|
search?: SearchOptions;
|
|
583
746
|
sortedBy: SortedByProps[];
|
|
584
747
|
}): Promise<T[]>;
|
|
585
|
-
|
|
748
|
+
httpClient?: never;
|
|
586
749
|
url?: never;
|
|
587
750
|
};
|
|
588
|
-
type
|
|
589
|
-
|
|
751
|
+
type UseGridPropsHttpClient = {
|
|
752
|
+
httpClient: HttpClient;
|
|
590
753
|
url: string;
|
|
591
754
|
onRequest?: never;
|
|
592
755
|
};
|
|
593
|
-
type UseGridProps<T> = UseGridBaseProps<T> & (UseGridPropsOnRequest<T> |
|
|
594
|
-
declare function useAsyncGrid<T extends Record<string, any>>({ columns, filters, search, rowsPerPageOptions, onRequest,
|
|
756
|
+
type UseGridProps<T> = UseGridBaseProps<T> & (UseGridPropsOnRequest<T> | UseGridPropsHttpClient);
|
|
757
|
+
declare function useAsyncGrid<T extends Record<string, any>>({ columns, filters, search, rowsPerPageOptions, onRequest, httpClient, url, defaultData: externalDefaultData, defaultCurrentPage, defaultSortedBy }: UseGridProps<T>): {
|
|
595
758
|
data: T[];
|
|
596
759
|
set: (data: T[]) => void;
|
|
597
760
|
onSortBy: (prop: string) => Promise<void>;
|
|
@@ -620,82 +783,16 @@ declare const useAlert: () => {
|
|
|
620
783
|
createAlert(message: string, type: _mui_material.AlertColor): void;
|
|
621
784
|
};
|
|
622
785
|
|
|
623
|
-
type
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
};
|
|
627
|
-
declare const FormHelperContext: React__default.Context<FormHelperContextProps>;
|
|
628
|
-
type FormHelperProviderProps = {
|
|
629
|
-
formatErrorMessage: (message: any) => string;
|
|
630
|
-
children: ReactNode;
|
|
631
|
-
api: AxiosInstance;
|
|
632
|
-
};
|
|
633
|
-
declare const FormHelperProvider: ({ formatErrorMessage, api, children }: FormHelperProviderProps) => React__default.JSX.Element;
|
|
634
|
-
|
|
635
|
-
type AlertContextProps = {
|
|
636
|
-
createAlert(message: string, type: AlertColor): void;
|
|
637
|
-
};
|
|
638
|
-
declare const AlertContext: React__default.Context<AlertContextProps>;
|
|
639
|
-
type AlertProviderProps = {
|
|
640
|
-
children: ReactNode;
|
|
786
|
+
type Methods = 'get' | 'post' | 'put' | 'delete' | 'patch' | 'options';
|
|
787
|
+
type HandleProps = {
|
|
788
|
+
name: `${Methods}:${string}`;
|
|
641
789
|
};
|
|
642
|
-
declare
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
signIn(credentials: Record<string, any>): Promise<boolean>;
|
|
649
|
-
signOut: () => Promise<void>;
|
|
650
|
-
}
|
|
651
|
-
declare function createAuthContext<T>(): React__default.Context<AuthContextProps<T>>;
|
|
652
|
-
declare function CreateAuthProvider<T>({ api, children, sessionTokenName, Provider }: {
|
|
653
|
-
Provider: Provider<AuthContextProps<T>>;
|
|
654
|
-
children: ReactNode;
|
|
655
|
-
api: AxiosInstance;
|
|
656
|
-
sessionTokenName: string;
|
|
657
|
-
}): React__default.JSX.Element;
|
|
658
|
-
|
|
659
|
-
/**
|
|
660
|
-
* Parses cookies.
|
|
661
|
-
*
|
|
662
|
-
* @param ctx NextJS page or API context, express context, null or undefined.
|
|
663
|
-
* @param options Options that we pass down to `cookie` library.
|
|
664
|
-
*/
|
|
665
|
-
declare function parseCookies(ctx?: Pick<next.NextPageContext, 'req'> | {
|
|
666
|
-
req: next.NextApiRequest;
|
|
667
|
-
} | {
|
|
668
|
-
req: express.Request;
|
|
669
|
-
} | null | undefined, options?: cookie.ParseOptions): cookie.Cookies;
|
|
670
|
-
/**
|
|
671
|
-
* Sets a cookie.
|
|
672
|
-
*
|
|
673
|
-
* @param ctx NextJS page or API context, express context, null or undefined.
|
|
674
|
-
* @param name The name of your cookie.
|
|
675
|
-
* @param value The value of your cookie.
|
|
676
|
-
* @param options Options that we pass down to `cookie` library.
|
|
677
|
-
*/
|
|
678
|
-
declare function setCookie(ctx: Pick<next.NextPageContext, 'res'> | {
|
|
679
|
-
res: next.NextApiResponse;
|
|
680
|
-
} | {
|
|
681
|
-
res: express.Response;
|
|
682
|
-
} | null | undefined, name: string, value: string, options?: cookie.SerializeOptions): {};
|
|
683
|
-
/**
|
|
684
|
-
* Destroys a cookie with a particular name.
|
|
685
|
-
*
|
|
686
|
-
* @param ctx NextJS page or API context, express context, null or undefined.
|
|
687
|
-
* @param name Cookie name.
|
|
688
|
-
* @param options Options that we pass down to `cookie` library.
|
|
689
|
-
*/
|
|
690
|
-
declare function destroyCookie(ctx: Pick<next.NextPageContext, 'res'> | {
|
|
691
|
-
res: next.NextApiResponse;
|
|
692
|
-
} | {
|
|
693
|
-
res: express.Response;
|
|
694
|
-
} | null | undefined, name: string, options?: cookie.SerializeOptions): {};
|
|
695
|
-
declare const nookies: {
|
|
696
|
-
set: typeof setCookie;
|
|
697
|
-
get: typeof parseCookies;
|
|
698
|
-
destroy: typeof destroyCookie;
|
|
790
|
+
declare function useFormHelper(): {
|
|
791
|
+
onSubmitWrapper: <T extends Record<string, any>>(fn: (fields: T, methods: any) => Promise<void>, { name }: HandleProps) => (fields: T, methods: any) => Promise<void>;
|
|
792
|
+
onRequestWrapper: <F extends (...args: Parameters<F>) => R, R>(fn: F, { name }: HandleProps) => (...params: Parameters<F>) => Promise<R>;
|
|
793
|
+
isLoading: (prop: string) => boolean;
|
|
794
|
+
setLoading: (prop: string, remove?: boolean) => void;
|
|
795
|
+
createAlert(message: string, type: _mui_material.AlertColor): void;
|
|
699
796
|
};
|
|
700
797
|
|
|
701
|
-
export { AlertContext, AlertProvider, ApiHelper, type AuthContextProps, AuthHelper, Autocomplete, BaseDialog, BaseDialogBody, BaseDialogContainer, BaseDialogCreate, BaseDialogTrigger, BaseGrid, BaseGridAutoRows, Checkbox, type ColumnTitleProps, type ColumnsProps, CreateAuthProvider, Dialog, DialogConfirm, DomainError, EditableTableCell, type FilterCompareType, type FilterProps, FormHelperContext, FormHelperProvider, GetInputLabel, Grid, type HandlerProps, HttpError, type IBaseDialogBodyProps, type IBaseDialogContainerProps, type IBaseDialogTriggerProps, type IDialogConfirmProps, type IFilter, Input, InputMask, LargeButton, type MethodProps, Modal, Radio, Select, type SortedByProps$1 as SortedByProps, Switch, type TApiOptions, type TUseDialogConfirm, TabPanel, type TabPanelProps, Td, Tr, UseDialogConfirm, createAuthContext, createFilter, destroyCookie, filterData, getTabProps, nookies, parseCookies, setCookie, useAlert, useAsyncGrid, useBaseDialog, useBaseDialogInstance, useEvent, useFilter, useFormHelper, useGrid, useLoading };
|
|
798
|
+
export { AlertContext, AlertProvider, ApiHelper, type ApiHelperRequest, type ApiHelperResponse, type AuthConfig, type AuthContextProps, AuthHelper, Autocomplete, BaseDialog, BaseDialogBody, BaseDialogContainer, BaseDialogCreate, BaseDialogTrigger, BaseGrid, BaseGridAutoRows, Checkbox, type ColumnTitleProps, type ColumnsProps, CreateAuthProvider, Dialog, DialogConfirm, DomainError, EditableTableCell, type FilterCompareType, type FilterProps, FormHelperContext, FormHelperProvider, GetInputLabel, Grid, type HandlerProps, type HttpClient, type HttpClientConfig, HttpClientError, HttpError, type HttpResponse, type IBaseDialogBodyProps, type IBaseDialogContainerProps, type IBaseDialogTriggerProps, type IDialogConfirmProps, type IFilter, Input, InputMask, LargeButton, type MethodProps, Modal, type NookiesRequest, type NookiesResponse, Radio, type RequestConfig, Select, type SortedByProps$1 as SortedByProps, Switch, type TApiOptions, type TUseDialogConfirm, TabPanel, type TabPanelProps, Td, Tr, UseDialogConfirm, createAuthContext, createFilter, createHttpClient, destroyCookie, filterData, getTabProps, nookies, parseCookies, setCookie, useAlert, useAsyncGrid, useBaseDialog, useBaseDialogInstance, useEvent, useFilter, useFormHelper, useGrid, useLoading };
|