@bluemarble/bm-components 2.4.0 → 2.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -5,25 +5,26 @@ import { TableCellProps, TableCell, TextFieldProps, StandardTextFieldProps, Sele
5
5
  import * as _mui_material_OverridableComponent from '@mui/material/OverridableComponent';
6
6
  import { FactoryOpts } from 'imask';
7
7
  import { IconType } from 'react-icons';
8
- import * as next from 'next';
9
- import { NextApiRequest, NextApiResponse, GetServerSidePropsContext } from 'next';
10
8
  import { ZodSchema } from 'zod';
11
9
  import { AxiosInstance } from 'axios';
12
10
  import * as cookie from 'cookie';
13
- import * as express from 'express';
14
11
 
12
+ /** @deprecated Use {@link ColumnsProps} from `BaseGrid` instead. */
15
13
  interface ColumnTitleProps {
16
14
  name: string;
17
15
  label: string;
18
16
  transformer?: (value: string | number | Date) => string;
19
17
  sx?: TableCellProps['sx'];
20
18
  }
19
+ /** @deprecated Use {@link FilterProps} from `useFilter` instead. */
21
20
  interface FilterProps$1 {
22
21
  column: string;
23
22
  value: string;
24
23
  transformer?: (value: string | number | Date) => string;
25
24
  }
25
+ /** @deprecated Use {@link FilterProps} from `useFilter` instead. */
26
26
  type IFilter = FilterProps$1;
27
+ /** @deprecated */
27
28
  interface GridProps$1<T> {
28
29
  columnTitles: ColumnTitleProps[];
29
30
  defaultData: T[];
@@ -41,14 +42,22 @@ interface GridProps$1<T> {
41
42
  noFilters?: boolean;
42
43
  primaryKey?: string;
43
44
  }
45
+ /**
46
+ * @deprecated Use {@link BaseGrid} with the {@link useGrid} or {@link useAsyncGrid} hook instead.
47
+ * `BaseGrid` separates rendering from state management, eliminating the need to pass
48
+ * `tableData`, `setTableData`, `selectedFilters`, and `updateFilters` as props.
49
+ */
44
50
  declare const Grid: <ObjectType>(props: PropsWithChildren<GridProps$1<ObjectType>>) => React__default.JSX.Element;
45
51
 
52
+ /** @deprecated Use the `useFilter` hook instead. */
46
53
  declare function filterData<T>(filters: FilterProps$1[], defaultData: {
47
54
  current: T[];
48
55
  }): T[];
49
56
 
57
+ /** @deprecated Use `TableRow` from `@mui/material` directly. */
50
58
  declare const Tr: _mui_material_OverridableComponent.OverridableComponent<_mui_material.TableRowTypeMap<{}, "tr">>;
51
59
 
60
+ /** @deprecated Use `TableCell` from `@mui/material` directly. */
52
61
  declare const Td: typeof TableCell;
53
62
 
54
63
  interface EditableTableCellProps extends TableCellProps {
@@ -103,7 +112,7 @@ type SelectProps<T> = MuiSelectPropsWithouVariant<T> & {
103
112
  InputLabelProps?: Partial<CustomInputLabelProps>;
104
113
  helperText?: string;
105
114
  };
106
- declare function Select<T>({ withFormik, ...rest }: SelectProps<T>): React__default.JSX.Element;
115
+ declare function Select<T>({ withFormik, helperText, ...rest }: SelectProps<T>): React__default.JSX.Element;
107
116
 
108
117
  type MuiAutocompleteBaseProps<T> = Omit<AutocompleteProps$1<T, boolean, undefined, boolean>, 'renderInput' | 'getOptionLabel'>;
109
118
  interface AutocompleteWithoutProps<T> extends MuiAutocompleteBaseProps<T> {
@@ -138,12 +147,14 @@ type CheckboxProps = CheckboxWithFormik | CheckboxWithoutFormik;
138
147
  interface CheckboxWithFormik extends CheckboxProps$1 {
139
148
  name: string;
140
149
  label?: string;
150
+ helperText?: string;
141
151
  withFormik?: true;
142
152
  FormControlLabelProps?: Partial<FormControlLabelProps>;
143
153
  }
144
154
  interface CheckboxWithoutFormik extends CheckboxProps$1 {
145
155
  name?: never;
146
156
  label?: string;
157
+ helperText?: string;
147
158
  withFormik: false;
148
159
  FormControlLabelProps?: Partial<FormControlLabelProps>;
149
160
  }
@@ -153,12 +164,14 @@ type SwitchProps = SwitchWithFormik | SwitchWithoutFormik;
153
164
  interface SwitchWithFormik extends SwitchProps$1 {
154
165
  name: string;
155
166
  label?: string;
167
+ helperText?: string;
156
168
  withFormik?: true;
157
169
  FormControlLabelProps?: Partial<FormControlLabelProps>;
158
170
  }
159
171
  interface SwitchWithoutFormik extends SwitchProps$1 {
160
172
  name?: never;
161
173
  label?: string;
174
+ helperText?: string;
162
175
  withFormik: false;
163
176
  FormControlLabelProps?: Partial<FormControlLabelProps>;
164
177
  }
@@ -173,12 +186,14 @@ interface RadioWithFormik extends RadioGroupProps {
173
186
  name: string;
174
187
  label?: string;
175
188
  options: RadioOptionProps[];
189
+ helperText?: string;
176
190
  withFormik?: true;
177
191
  }
178
192
  interface RadioWithoutFormik extends RadioGroupProps {
179
193
  name?: never;
180
194
  label?: string;
181
195
  options: RadioOptionProps[];
196
+ helperText?: string;
182
197
  withFormik: false;
183
198
  }
184
199
  declare const Radio: ({ name, withFormik, ...rest }: RadioOptionsProps) => React__default.JSX.Element;
@@ -314,6 +329,9 @@ type TModalProps = {
314
329
  children: React__default.ReactNode;
315
330
  BoxProps?: BoxProps;
316
331
  } & Omit<ModalProps, 'children'>;
332
+ /**
333
+ * @deprecated Use `Dialog` or `BaseDialog` instead. `Modal` will be removed in a future release.
334
+ */
317
335
  declare const Modal: ({ open, onClose, BoxProps, ...rest }: TModalProps) => React__default.JSX.Element;
318
336
 
319
337
  declare function GetInputLabel<T extends Array<Record<string, any>>, K extends T[number]['name']>(columns: T): (columnName: K) => {
@@ -433,18 +451,44 @@ declare class DomainError extends Error {
433
451
  constructor(message: any);
434
452
  }
435
453
 
454
+ interface HelperRequest {
455
+ url?: string;
456
+ method?: string;
457
+ headers: {
458
+ authorization?: string;
459
+ cookie?: string;
460
+ [key: string]: string | string[] | undefined;
461
+ };
462
+ cookies: Record<string, string>;
463
+ body?: any;
464
+ query?: Record<string, string | string[] | undefined>;
465
+ user?: any;
466
+ }
467
+ interface HelperResponse {
468
+ finished?: boolean;
469
+ status(code: number): HelperResponse;
470
+ json(data: any): any;
471
+ end(data?: any): any;
472
+ getHeader(name: string): string | string[] | number | undefined;
473
+ setHeader(name: string, value: string | readonly string[]): any;
474
+ }
475
+ interface ServerSidePropsContext {
476
+ query: Record<string, string | string[] | undefined>;
477
+ res: HelperResponse;
478
+ }
479
+
436
480
  type PossibleMethods = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'ALL';
437
- type NextHandlerApiRequest<T = string> = NextApiRequest & {
481
+ type NextHandlerApiRequest<T = string> = HelperRequest & {
438
482
  user?: T;
439
483
  };
440
- type HandlerProps<UserKeyType> = (req: NextHandlerApiRequest<UserKeyType>, res: NextApiResponse, options?: TApiOptions) => Promise<any>;
484
+ type HandlerProps<UserKeyType> = (req: NextHandlerApiRequest<UserKeyType>, res: HelperResponse, options?: TApiOptions) => Promise<any>;
441
485
  type MethodProps<T> = Partial<Record<PossibleMethods, HandlerProps<T>>>;
442
486
  type MiddlewaresProps<T> = ((handler: HandlerProps<T>, options?: TApiOptions) => HandlerProps<T>)[];
443
487
  type ConstructorProps$1<T> = {
444
488
  public?: boolean;
445
489
  middlewares?: MiddlewaresProps<T>;
446
- onFinally?: (req: NextApiRequest, res: NextApiResponse) => Promise<void>;
447
- onError?: (req: NextApiRequest, res: NextApiResponse) => Promise<void>;
490
+ onFinally?: (req: HelperRequest, res: HelperResponse) => Promise<void>;
491
+ onError?: (req: HelperRequest, res: HelperResponse) => Promise<void>;
448
492
  };
449
493
  type TApiOptions = {
450
494
  public?: boolean;
@@ -456,9 +500,9 @@ declare class ApiHelper<T> {
456
500
  private onFinally;
457
501
  private onError;
458
502
  constructor(props?: ConstructorProps$1<T>);
459
- createMethods(methods: MethodProps<T>): (req: NextApiRequest, res: NextApiResponse) => Promise<any>;
503
+ createMethods(methods: MethodProps<T>): (req: HelperRequest, res: HelperResponse) => Promise<any>;
460
504
  private buildFactory;
461
- static build(factory: (req: NextHandlerApiRequest, res: NextApiResponse) => MethodProps<string>, options?: TApiOptions): (req: NextHandlerApiRequest, res: NextApiResponse) => Promise<any>;
505
+ static build(factory: (req: NextHandlerApiRequest, res: HelperResponse) => MethodProps<string>, options?: TApiOptions): (req: NextHandlerApiRequest, res: HelperResponse) => Promise<any>;
462
506
  static parse<Output, Def>(body: Record<string, any>, parser: ZodSchema<Output, Def>): Output;
463
507
  /** @deprecated Use {@link ApiHelper.parser} instead. */
464
508
  static parserErrorWrapper: typeof ApiHelper.parse;
@@ -468,23 +512,11 @@ declare class ApiHelper<T> {
468
512
  }): ApiHelper<unknown>;
469
513
  }
470
514
 
471
- type Methods = 'get' | 'post' | 'put' | 'delete' | 'patch' | 'options';
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 & {
515
+ type AuthRequest = HelperRequest & {
484
516
  user?: any;
485
517
  };
486
518
  interface OnLoginSuccessResponse {
487
- status: 'sucess';
519
+ status: 'success';
488
520
  userId: string;
489
521
  }
490
522
  interface OnLoginFailedResponse {
@@ -525,7 +557,7 @@ declare class AuthHelper {
525
557
  onCreateRefreshToken: ConstructorProps['onCreateRefreshToken'];
526
558
  onGetUserData: ConstructorProps['onGetUserData'];
527
559
  constructor({ cookies, oauth, tokenExpTimeInSeconds, onLogin, onValidateRefreshToken, onInvalidateRefreshToken, onCreateRefreshToken, onGetUserData }: ConstructorProps);
528
- handler(req: NextApiRequestWithAuth, res: NextApiResponse): Promise<void>;
560
+ handler(req: AuthRequest, res: HelperResponse): Promise<any>;
529
561
  oauthSignInCallback(code: string): Promise<{
530
562
  decodedToken: {
531
563
  upn: string;
@@ -538,7 +570,7 @@ declare class AuthHelper {
538
570
  createOauthCallbackGetServerSideProps({ onSuccessDestination, onFailedDestination }: {
539
571
  onSuccessDestination: string;
540
572
  onFailedDestination?: string;
541
- }): (ctx: GetServerSidePropsContext) => Promise<{
573
+ }): (ctx: ServerSidePropsContext) => Promise<{
542
574
  redirect: {
543
575
  permanent: boolean;
544
576
  destination: string;
@@ -551,7 +583,7 @@ declare class AuthHelper {
551
583
  redirect?: undefined;
552
584
  }>;
553
585
  private generateJwtAndRefreshToken;
554
- invalidateCookies: (res: NextApiResponse) => NextApiResponse;
586
+ invalidateCookies: (res: HelperResponse) => any;
555
587
  }
556
588
 
557
589
  type SortedDirectionProps = 'asc' | 'desc';
@@ -620,6 +652,18 @@ declare const useAlert: () => {
620
652
  createAlert(message: string, type: _mui_material.AlertColor): void;
621
653
  };
622
654
 
655
+ type Methods = 'get' | 'post' | 'put' | 'delete' | 'patch' | 'options';
656
+ type HandleProps = {
657
+ name: `${Methods}:${string}`;
658
+ };
659
+ declare function useFormHelper(): {
660
+ onSubmitWrapper: <T extends Record<string, any>>(fn: (fields: T, methods: any) => Promise<void>, { name }: HandleProps) => (fields: T, methods: any) => Promise<void>;
661
+ onRequestWrapper: <F extends (...args: Parameters<F>) => R, R>(fn: F, { name }: HandleProps) => (...params: Parameters<F>) => Promise<R>;
662
+ isLoading: (prop: string) => boolean;
663
+ setLoading: (prop: string, remove?: boolean) => void;
664
+ createAlert(message: string, type: _mui_material.AlertColor): void;
665
+ };
666
+
623
667
  type FormHelperContextProps = {
624
668
  formatErrorMessage: (message: any) => string;
625
669
  api: AxiosInstance;
@@ -656,41 +700,46 @@ declare function CreateAuthProvider<T>({ api, children, sessionTokenName, Provid
656
700
  sessionTokenName: string;
657
701
  }): React__default.JSX.Element;
658
702
 
703
+ interface NookiesRequest {
704
+ headers?: {
705
+ cookie?: string;
706
+ };
707
+ }
708
+ interface NookiesResponse {
709
+ finished?: boolean;
710
+ getHeader(name: string): string | string[] | number | undefined;
711
+ setHeader(name: string, value: string | readonly string[]): any;
712
+ }
713
+
659
714
  /**
660
715
  * Parses cookies.
661
716
  *
662
- * @param ctx NextJS page or API context, express context, null or undefined.
717
+ * @param ctx Object with a `req` property, null or undefined.
663
718
  * @param options Options that we pass down to `cookie` library.
664
719
  */
665
- declare function parseCookies(ctx?: Pick<next.NextPageContext, 'req'> | {
666
- req: next.NextApiRequest;
667
- } | {
668
- req: express.Request;
720
+ declare function parseCookies(ctx?: {
721
+ req: NookiesRequest;
669
722
  } | null | undefined, options?: cookie.ParseOptions): cookie.Cookies;
670
723
  /**
671
724
  * Sets a cookie.
672
725
  *
673
- * @param ctx NextJS page or API context, express context, null or undefined.
726
+ * @param ctx Object with a `res` property, null or undefined.
674
727
  * @param name The name of your cookie.
675
728
  * @param value The value of your cookie.
676
729
  * @param options Options that we pass down to `cookie` library.
677
730
  */
678
- declare function setCookie(ctx: Pick<next.NextPageContext, 'res'> | {
679
- res: next.NextApiResponse;
680
- } | {
681
- res: express.Response;
731
+ declare function setCookie(ctx: {
732
+ res: NookiesResponse;
682
733
  } | null | undefined, name: string, value: string, options?: cookie.SerializeOptions): {};
683
734
  /**
684
735
  * Destroys a cookie with a particular name.
685
736
  *
686
- * @param ctx NextJS page or API context, express context, null or undefined.
737
+ * @param ctx Object with a `res` property, null or undefined.
687
738
  * @param name Cookie name.
688
739
  * @param options Options that we pass down to `cookie` library.
689
740
  */
690
- declare function destroyCookie(ctx: Pick<next.NextPageContext, 'res'> | {
691
- res: next.NextApiResponse;
692
- } | {
693
- res: express.Response;
741
+ declare function destroyCookie(ctx: {
742
+ res: NookiesResponse;
694
743
  } | null | undefined, name: string, options?: cookie.SerializeOptions): {};
695
744
  declare const nookies: {
696
745
  set: typeof setCookie;
@@ -698,4 +747,4 @@ declare const nookies: {
698
747
  destroy: typeof destroyCookie;
699
748
  };
700
749
 
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 };
750
+ 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, type NookiesRequest, type NookiesResponse, 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 };
package/dist/index.d.ts CHANGED
@@ -5,25 +5,26 @@ import { TableCellProps, TableCell, TextFieldProps, StandardTextFieldProps, Sele
5
5
  import * as _mui_material_OverridableComponent from '@mui/material/OverridableComponent';
6
6
  import { FactoryOpts } from 'imask';
7
7
  import { IconType } from 'react-icons';
8
- import * as next from 'next';
9
- import { NextApiRequest, NextApiResponse, GetServerSidePropsContext } from 'next';
10
8
  import { ZodSchema } from 'zod';
11
9
  import { AxiosInstance } from 'axios';
12
10
  import * as cookie from 'cookie';
13
- import * as express from 'express';
14
11
 
12
+ /** @deprecated Use {@link ColumnsProps} from `BaseGrid` instead. */
15
13
  interface ColumnTitleProps {
16
14
  name: string;
17
15
  label: string;
18
16
  transformer?: (value: string | number | Date) => string;
19
17
  sx?: TableCellProps['sx'];
20
18
  }
19
+ /** @deprecated Use {@link FilterProps} from `useFilter` instead. */
21
20
  interface FilterProps$1 {
22
21
  column: string;
23
22
  value: string;
24
23
  transformer?: (value: string | number | Date) => string;
25
24
  }
25
+ /** @deprecated Use {@link FilterProps} from `useFilter` instead. */
26
26
  type IFilter = FilterProps$1;
27
+ /** @deprecated */
27
28
  interface GridProps$1<T> {
28
29
  columnTitles: ColumnTitleProps[];
29
30
  defaultData: T[];
@@ -41,14 +42,22 @@ interface GridProps$1<T> {
41
42
  noFilters?: boolean;
42
43
  primaryKey?: string;
43
44
  }
45
+ /**
46
+ * @deprecated Use {@link BaseGrid} with the {@link useGrid} or {@link useAsyncGrid} hook instead.
47
+ * `BaseGrid` separates rendering from state management, eliminating the need to pass
48
+ * `tableData`, `setTableData`, `selectedFilters`, and `updateFilters` as props.
49
+ */
44
50
  declare const Grid: <ObjectType>(props: PropsWithChildren<GridProps$1<ObjectType>>) => React__default.JSX.Element;
45
51
 
52
+ /** @deprecated Use the `useFilter` hook instead. */
46
53
  declare function filterData<T>(filters: FilterProps$1[], defaultData: {
47
54
  current: T[];
48
55
  }): T[];
49
56
 
57
+ /** @deprecated Use `TableRow` from `@mui/material` directly. */
50
58
  declare const Tr: _mui_material_OverridableComponent.OverridableComponent<_mui_material.TableRowTypeMap<{}, "tr">>;
51
59
 
60
+ /** @deprecated Use `TableCell` from `@mui/material` directly. */
52
61
  declare const Td: typeof TableCell;
53
62
 
54
63
  interface EditableTableCellProps extends TableCellProps {
@@ -103,7 +112,7 @@ type SelectProps<T> = MuiSelectPropsWithouVariant<T> & {
103
112
  InputLabelProps?: Partial<CustomInputLabelProps>;
104
113
  helperText?: string;
105
114
  };
106
- declare function Select<T>({ withFormik, ...rest }: SelectProps<T>): React__default.JSX.Element;
115
+ declare function Select<T>({ withFormik, helperText, ...rest }: SelectProps<T>): React__default.JSX.Element;
107
116
 
108
117
  type MuiAutocompleteBaseProps<T> = Omit<AutocompleteProps$1<T, boolean, undefined, boolean>, 'renderInput' | 'getOptionLabel'>;
109
118
  interface AutocompleteWithoutProps<T> extends MuiAutocompleteBaseProps<T> {
@@ -138,12 +147,14 @@ type CheckboxProps = CheckboxWithFormik | CheckboxWithoutFormik;
138
147
  interface CheckboxWithFormik extends CheckboxProps$1 {
139
148
  name: string;
140
149
  label?: string;
150
+ helperText?: string;
141
151
  withFormik?: true;
142
152
  FormControlLabelProps?: Partial<FormControlLabelProps>;
143
153
  }
144
154
  interface CheckboxWithoutFormik extends CheckboxProps$1 {
145
155
  name?: never;
146
156
  label?: string;
157
+ helperText?: string;
147
158
  withFormik: false;
148
159
  FormControlLabelProps?: Partial<FormControlLabelProps>;
149
160
  }
@@ -153,12 +164,14 @@ type SwitchProps = SwitchWithFormik | SwitchWithoutFormik;
153
164
  interface SwitchWithFormik extends SwitchProps$1 {
154
165
  name: string;
155
166
  label?: string;
167
+ helperText?: string;
156
168
  withFormik?: true;
157
169
  FormControlLabelProps?: Partial<FormControlLabelProps>;
158
170
  }
159
171
  interface SwitchWithoutFormik extends SwitchProps$1 {
160
172
  name?: never;
161
173
  label?: string;
174
+ helperText?: string;
162
175
  withFormik: false;
163
176
  FormControlLabelProps?: Partial<FormControlLabelProps>;
164
177
  }
@@ -173,12 +186,14 @@ interface RadioWithFormik extends RadioGroupProps {
173
186
  name: string;
174
187
  label?: string;
175
188
  options: RadioOptionProps[];
189
+ helperText?: string;
176
190
  withFormik?: true;
177
191
  }
178
192
  interface RadioWithoutFormik extends RadioGroupProps {
179
193
  name?: never;
180
194
  label?: string;
181
195
  options: RadioOptionProps[];
196
+ helperText?: string;
182
197
  withFormik: false;
183
198
  }
184
199
  declare const Radio: ({ name, withFormik, ...rest }: RadioOptionsProps) => React__default.JSX.Element;
@@ -314,6 +329,9 @@ type TModalProps = {
314
329
  children: React__default.ReactNode;
315
330
  BoxProps?: BoxProps;
316
331
  } & Omit<ModalProps, 'children'>;
332
+ /**
333
+ * @deprecated Use `Dialog` or `BaseDialog` instead. `Modal` will be removed in a future release.
334
+ */
317
335
  declare const Modal: ({ open, onClose, BoxProps, ...rest }: TModalProps) => React__default.JSX.Element;
318
336
 
319
337
  declare function GetInputLabel<T extends Array<Record<string, any>>, K extends T[number]['name']>(columns: T): (columnName: K) => {
@@ -433,18 +451,44 @@ declare class DomainError extends Error {
433
451
  constructor(message: any);
434
452
  }
435
453
 
454
+ interface HelperRequest {
455
+ url?: string;
456
+ method?: string;
457
+ headers: {
458
+ authorization?: string;
459
+ cookie?: string;
460
+ [key: string]: string | string[] | undefined;
461
+ };
462
+ cookies: Record<string, string>;
463
+ body?: any;
464
+ query?: Record<string, string | string[] | undefined>;
465
+ user?: any;
466
+ }
467
+ interface HelperResponse {
468
+ finished?: boolean;
469
+ status(code: number): HelperResponse;
470
+ json(data: any): any;
471
+ end(data?: any): any;
472
+ getHeader(name: string): string | string[] | number | undefined;
473
+ setHeader(name: string, value: string | readonly string[]): any;
474
+ }
475
+ interface ServerSidePropsContext {
476
+ query: Record<string, string | string[] | undefined>;
477
+ res: HelperResponse;
478
+ }
479
+
436
480
  type PossibleMethods = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'ALL';
437
- type NextHandlerApiRequest<T = string> = NextApiRequest & {
481
+ type NextHandlerApiRequest<T = string> = HelperRequest & {
438
482
  user?: T;
439
483
  };
440
- type HandlerProps<UserKeyType> = (req: NextHandlerApiRequest<UserKeyType>, res: NextApiResponse, options?: TApiOptions) => Promise<any>;
484
+ type HandlerProps<UserKeyType> = (req: NextHandlerApiRequest<UserKeyType>, res: HelperResponse, options?: TApiOptions) => Promise<any>;
441
485
  type MethodProps<T> = Partial<Record<PossibleMethods, HandlerProps<T>>>;
442
486
  type MiddlewaresProps<T> = ((handler: HandlerProps<T>, options?: TApiOptions) => HandlerProps<T>)[];
443
487
  type ConstructorProps$1<T> = {
444
488
  public?: boolean;
445
489
  middlewares?: MiddlewaresProps<T>;
446
- onFinally?: (req: NextApiRequest, res: NextApiResponse) => Promise<void>;
447
- onError?: (req: NextApiRequest, res: NextApiResponse) => Promise<void>;
490
+ onFinally?: (req: HelperRequest, res: HelperResponse) => Promise<void>;
491
+ onError?: (req: HelperRequest, res: HelperResponse) => Promise<void>;
448
492
  };
449
493
  type TApiOptions = {
450
494
  public?: boolean;
@@ -456,9 +500,9 @@ declare class ApiHelper<T> {
456
500
  private onFinally;
457
501
  private onError;
458
502
  constructor(props?: ConstructorProps$1<T>);
459
- createMethods(methods: MethodProps<T>): (req: NextApiRequest, res: NextApiResponse) => Promise<any>;
503
+ createMethods(methods: MethodProps<T>): (req: HelperRequest, res: HelperResponse) => Promise<any>;
460
504
  private buildFactory;
461
- static build(factory: (req: NextHandlerApiRequest, res: NextApiResponse) => MethodProps<string>, options?: TApiOptions): (req: NextHandlerApiRequest, res: NextApiResponse) => Promise<any>;
505
+ static build(factory: (req: NextHandlerApiRequest, res: HelperResponse) => MethodProps<string>, options?: TApiOptions): (req: NextHandlerApiRequest, res: HelperResponse) => Promise<any>;
462
506
  static parse<Output, Def>(body: Record<string, any>, parser: ZodSchema<Output, Def>): Output;
463
507
  /** @deprecated Use {@link ApiHelper.parser} instead. */
464
508
  static parserErrorWrapper: typeof ApiHelper.parse;
@@ -468,23 +512,11 @@ declare class ApiHelper<T> {
468
512
  }): ApiHelper<unknown>;
469
513
  }
470
514
 
471
- type Methods = 'get' | 'post' | 'put' | 'delete' | 'patch' | 'options';
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 & {
515
+ type AuthRequest = HelperRequest & {
484
516
  user?: any;
485
517
  };
486
518
  interface OnLoginSuccessResponse {
487
- status: 'sucess';
519
+ status: 'success';
488
520
  userId: string;
489
521
  }
490
522
  interface OnLoginFailedResponse {
@@ -525,7 +557,7 @@ declare class AuthHelper {
525
557
  onCreateRefreshToken: ConstructorProps['onCreateRefreshToken'];
526
558
  onGetUserData: ConstructorProps['onGetUserData'];
527
559
  constructor({ cookies, oauth, tokenExpTimeInSeconds, onLogin, onValidateRefreshToken, onInvalidateRefreshToken, onCreateRefreshToken, onGetUserData }: ConstructorProps);
528
- handler(req: NextApiRequestWithAuth, res: NextApiResponse): Promise<void>;
560
+ handler(req: AuthRequest, res: HelperResponse): Promise<any>;
529
561
  oauthSignInCallback(code: string): Promise<{
530
562
  decodedToken: {
531
563
  upn: string;
@@ -538,7 +570,7 @@ declare class AuthHelper {
538
570
  createOauthCallbackGetServerSideProps({ onSuccessDestination, onFailedDestination }: {
539
571
  onSuccessDestination: string;
540
572
  onFailedDestination?: string;
541
- }): (ctx: GetServerSidePropsContext) => Promise<{
573
+ }): (ctx: ServerSidePropsContext) => Promise<{
542
574
  redirect: {
543
575
  permanent: boolean;
544
576
  destination: string;
@@ -551,7 +583,7 @@ declare class AuthHelper {
551
583
  redirect?: undefined;
552
584
  }>;
553
585
  private generateJwtAndRefreshToken;
554
- invalidateCookies: (res: NextApiResponse) => NextApiResponse;
586
+ invalidateCookies: (res: HelperResponse) => any;
555
587
  }
556
588
 
557
589
  type SortedDirectionProps = 'asc' | 'desc';
@@ -620,6 +652,18 @@ declare const useAlert: () => {
620
652
  createAlert(message: string, type: _mui_material.AlertColor): void;
621
653
  };
622
654
 
655
+ type Methods = 'get' | 'post' | 'put' | 'delete' | 'patch' | 'options';
656
+ type HandleProps = {
657
+ name: `${Methods}:${string}`;
658
+ };
659
+ declare function useFormHelper(): {
660
+ onSubmitWrapper: <T extends Record<string, any>>(fn: (fields: T, methods: any) => Promise<void>, { name }: HandleProps) => (fields: T, methods: any) => Promise<void>;
661
+ onRequestWrapper: <F extends (...args: Parameters<F>) => R, R>(fn: F, { name }: HandleProps) => (...params: Parameters<F>) => Promise<R>;
662
+ isLoading: (prop: string) => boolean;
663
+ setLoading: (prop: string, remove?: boolean) => void;
664
+ createAlert(message: string, type: _mui_material.AlertColor): void;
665
+ };
666
+
623
667
  type FormHelperContextProps = {
624
668
  formatErrorMessage: (message: any) => string;
625
669
  api: AxiosInstance;
@@ -656,41 +700,46 @@ declare function CreateAuthProvider<T>({ api, children, sessionTokenName, Provid
656
700
  sessionTokenName: string;
657
701
  }): React__default.JSX.Element;
658
702
 
703
+ interface NookiesRequest {
704
+ headers?: {
705
+ cookie?: string;
706
+ };
707
+ }
708
+ interface NookiesResponse {
709
+ finished?: boolean;
710
+ getHeader(name: string): string | string[] | number | undefined;
711
+ setHeader(name: string, value: string | readonly string[]): any;
712
+ }
713
+
659
714
  /**
660
715
  * Parses cookies.
661
716
  *
662
- * @param ctx NextJS page or API context, express context, null or undefined.
717
+ * @param ctx Object with a `req` property, null or undefined.
663
718
  * @param options Options that we pass down to `cookie` library.
664
719
  */
665
- declare function parseCookies(ctx?: Pick<next.NextPageContext, 'req'> | {
666
- req: next.NextApiRequest;
667
- } | {
668
- req: express.Request;
720
+ declare function parseCookies(ctx?: {
721
+ req: NookiesRequest;
669
722
  } | null | undefined, options?: cookie.ParseOptions): cookie.Cookies;
670
723
  /**
671
724
  * Sets a cookie.
672
725
  *
673
- * @param ctx NextJS page or API context, express context, null or undefined.
726
+ * @param ctx Object with a `res` property, null or undefined.
674
727
  * @param name The name of your cookie.
675
728
  * @param value The value of your cookie.
676
729
  * @param options Options that we pass down to `cookie` library.
677
730
  */
678
- declare function setCookie(ctx: Pick<next.NextPageContext, 'res'> | {
679
- res: next.NextApiResponse;
680
- } | {
681
- res: express.Response;
731
+ declare function setCookie(ctx: {
732
+ res: NookiesResponse;
682
733
  } | null | undefined, name: string, value: string, options?: cookie.SerializeOptions): {};
683
734
  /**
684
735
  * Destroys a cookie with a particular name.
685
736
  *
686
- * @param ctx NextJS page or API context, express context, null or undefined.
737
+ * @param ctx Object with a `res` property, null or undefined.
687
738
  * @param name Cookie name.
688
739
  * @param options Options that we pass down to `cookie` library.
689
740
  */
690
- declare function destroyCookie(ctx: Pick<next.NextPageContext, 'res'> | {
691
- res: next.NextApiResponse;
692
- } | {
693
- res: express.Response;
741
+ declare function destroyCookie(ctx: {
742
+ res: NookiesResponse;
694
743
  } | null | undefined, name: string, options?: cookie.SerializeOptions): {};
695
744
  declare const nookies: {
696
745
  set: typeof setCookie;
@@ -698,4 +747,4 @@ declare const nookies: {
698
747
  destroy: typeof destroyCookie;
699
748
  };
700
749
 
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 };
750
+ 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, type NookiesRequest, type NookiesResponse, 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 };