@bluemarble/bm-components 0.0.93 → 0.0.95
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 +82 -24
- package/dist/index.d.ts +82 -24
- package/dist/index.js +346 -92
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +360 -106
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -2
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,14 @@ 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>;
|
|
367
|
+
declare const AlertProvider: FC;
|
|
310
368
|
|
|
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 };
|
|
369
|
+
export { AlertContext, AlertProvider, 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
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,14 @@ 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>;
|
|
367
|
+
declare const AlertProvider: FC;
|
|
310
368
|
|
|
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 };
|
|
369
|
+
export { AlertContext, AlertProvider, 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 };
|