@bluemarble/bm-components 0.2.1 → 0.2.3
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 +28 -32
- package/dist/index.d.ts +28 -32
- package/dist/index.js +9 -32
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +122 -145
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { ReactNode, FC } from 'react';
|
|
2
2
|
import * as _mui_material from '@mui/material';
|
|
3
|
-
import { TableCellProps,
|
|
3
|
+
import { TableCellProps, TableCell, TextFieldProps, StandardTextFieldProps, SelectProps as SelectProps$1, FormControlProps, InputLabelProps, AutocompleteRenderInputParams, AutocompleteProps as AutocompleteProps$1, CheckboxProps as CheckboxProps$1, FormControlLabelProps, SwitchProps as SwitchProps$1, RadioGroupProps, ButtonProps, CircularProgressProps, Theme, SxProps, PaperProps, TableProps, TableHeadProps, TableBodyProps, ModalProps as ModalProps$1, DialogProps, AlertColor } from '@mui/material';
|
|
4
|
+
import * as _mui_material_OverridableComponent from '@mui/material/OverridableComponent';
|
|
4
5
|
import IMask$1 from 'imask';
|
|
5
6
|
import { NextApiRequest, NextApiResponse } from 'next';
|
|
6
7
|
import { ZodTypeDef, ZodSchema } from 'zod';
|
|
@@ -41,6 +42,10 @@ declare function filterData<T>(filters: FilterProps$1[], defaultData: {
|
|
|
41
42
|
current: T[];
|
|
42
43
|
}): T[];
|
|
43
44
|
|
|
45
|
+
declare const Tr: _mui_material_OverridableComponent.OverridableComponent<_mui_material.TableRowTypeMap<{}, "tr">>;
|
|
46
|
+
|
|
47
|
+
declare const Td: typeof TableCell;
|
|
48
|
+
|
|
44
49
|
interface EditableTableCellProps extends TableCellProps {
|
|
45
50
|
name: string;
|
|
46
51
|
TextFieldProps?: TextFieldProps;
|
|
@@ -63,18 +68,6 @@ interface OnSaveProps {
|
|
|
63
68
|
}
|
|
64
69
|
declare const EditableTableCell: (allProps: EditableTableCellProps) => React.JSX.Element;
|
|
65
70
|
|
|
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) => React.JSX.Element>;
|
|
75
|
-
|
|
76
|
-
declare const Td: React.MemoExoticComponent<({ children, ...props }: TableCellProps) => React.JSX.Element>;
|
|
77
|
-
|
|
78
71
|
interface InputProps extends StandardTextFieldProps {
|
|
79
72
|
name: string;
|
|
80
73
|
label: string;
|
|
@@ -96,15 +89,17 @@ declare function InputMask({ withFormik, ...rest }: InputMaskProps): React.JSX.E
|
|
|
96
89
|
interface CustomInputLabelProps extends InputLabelProps {
|
|
97
90
|
size?: 'small';
|
|
98
91
|
}
|
|
99
|
-
|
|
92
|
+
type MuiSelectPropsWithouVariant<T> = Omit<SelectProps$1<T>, 'variant'>;
|
|
93
|
+
type SelectProps<T> = MuiSelectPropsWithouVariant<T> & {
|
|
100
94
|
name: string;
|
|
101
95
|
label: string;
|
|
102
96
|
withFormik?: boolean;
|
|
97
|
+
variant?: SelectProps$1<T>['variant'];
|
|
103
98
|
FormControlProps?: Partial<FormControlProps>;
|
|
104
99
|
InputLabelProps?: Partial<CustomInputLabelProps>;
|
|
105
100
|
helperText?: string;
|
|
106
|
-
}
|
|
107
|
-
declare
|
|
101
|
+
};
|
|
102
|
+
declare function Select<T>({ withFormik, ...rest }: SelectProps<T>): React.JSX.Element;
|
|
108
103
|
|
|
109
104
|
type MuiAutocompleteBaseProps<T> = Omit<AutocompleteProps$1<T, boolean, undefined, boolean>, 'renderInput' | 'getOptionLabel'>;
|
|
110
105
|
interface AutocompleteWithoutProps<T> extends MuiAutocompleteBaseProps<T> {
|
|
@@ -198,11 +193,11 @@ interface TabPanelProps {
|
|
|
198
193
|
}
|
|
199
194
|
declare const TabPanel: (props: TabPanelProps) => React.JSX.Element;
|
|
200
195
|
|
|
201
|
-
interface ColumnsProps {
|
|
196
|
+
interface ColumnsProps<T extends object = Theme> {
|
|
202
197
|
label: string;
|
|
203
198
|
name?: string;
|
|
204
199
|
width?: number;
|
|
205
|
-
sx?: SxProps
|
|
200
|
+
sx?: SxProps<T>;
|
|
206
201
|
canSort?: boolean;
|
|
207
202
|
children?: ReactNode;
|
|
208
203
|
}
|
|
@@ -236,7 +231,8 @@ declare function BaseGrid({ columns, children, paperProps, tableBodyProps, table
|
|
|
236
231
|
type ModalProps = {
|
|
237
232
|
open: boolean;
|
|
238
233
|
onClose: () => void;
|
|
239
|
-
|
|
234
|
+
children: React.ReactNode;
|
|
235
|
+
} & Omit<ModalProps$1, 'children'>;
|
|
240
236
|
declare const Modal: ({ open, onClose, ...rest }: ModalProps) => React.JSX.Element;
|
|
241
237
|
|
|
242
238
|
declare function GetInputLabel<T extends Array<Record<string, any>>, K extends T[number]['name']>(columns: T): (columnName: K) => {
|
|
@@ -263,27 +259,27 @@ declare class HttpError extends Error {
|
|
|
263
259
|
constructor(status: number, message: any);
|
|
264
260
|
}
|
|
265
261
|
|
|
266
|
-
type PossibleMethods =
|
|
267
|
-
type HandlerProps = (req: NextApiRequest & {
|
|
268
|
-
user?:
|
|
262
|
+
type PossibleMethods = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
263
|
+
type HandlerProps<UserKeyType> = (req: NextApiRequest & {
|
|
264
|
+
user?: UserKeyType;
|
|
269
265
|
}, res: NextApiResponse) => Promise<any>;
|
|
270
|
-
type MethodProps = Partial<Record<PossibleMethods, HandlerProps
|
|
271
|
-
type MiddlewaresProps = ((handler: HandlerProps) => HandlerProps)[];
|
|
272
|
-
type ConstructorProps = {
|
|
273
|
-
middlewares?: MiddlewaresProps
|
|
266
|
+
type MethodProps<T> = Partial<Record<PossibleMethods, HandlerProps<T>>>;
|
|
267
|
+
type MiddlewaresProps<T> = ((handler: HandlerProps<T>) => HandlerProps<T>)[];
|
|
268
|
+
type ConstructorProps<T> = {
|
|
269
|
+
middlewares?: MiddlewaresProps<T>;
|
|
274
270
|
onFinally: (req: NextApiRequest) => Promise<void>;
|
|
275
271
|
};
|
|
276
|
-
declare class ApiHelper {
|
|
277
|
-
middlewares: MiddlewaresProps
|
|
272
|
+
declare class ApiHelper<T> {
|
|
273
|
+
middlewares: MiddlewaresProps<T>;
|
|
278
274
|
private onFinally;
|
|
279
|
-
constructor(props?: ConstructorProps);
|
|
275
|
+
constructor(props?: ConstructorProps<T>);
|
|
280
276
|
setMiddlewares(middlewares: any[]): this;
|
|
281
|
-
createMethods(methods: MethodProps): (req: NextApiRequest, res: NextApiResponse) => Promise<void | NextApiResponse<any>>;
|
|
277
|
+
createMethods(methods: MethodProps<T>): (req: NextApiRequest, res: NextApiResponse) => Promise<void | NextApiResponse<any>>;
|
|
282
278
|
static parserErrorWrapper<Output, Def extends ZodTypeDef, Input>(body: Record<string, any>, parser: ZodSchema<Output, Def, Input>): Output;
|
|
283
279
|
static parseQueyFilters<T extends Record<string, any>>(filters: T): T;
|
|
284
280
|
static create({ onFinally }: {
|
|
285
281
|
onFinally: any;
|
|
286
|
-
}): ApiHelper
|
|
282
|
+
}): ApiHelper<unknown>;
|
|
287
283
|
}
|
|
288
284
|
|
|
289
285
|
type Methods = 'get' | 'post' | 'put' | 'delete' | 'patch' | 'options';
|
|
@@ -334,7 +330,7 @@ declare function useGrid<T extends Record<string, any>>({ columns, filters, sear
|
|
|
334
330
|
sortedBy: string;
|
|
335
331
|
defaultData: T[];
|
|
336
332
|
sortedDirection: "desc" | "asc";
|
|
337
|
-
columns: ColumnsProps[];
|
|
333
|
+
columns: ColumnsProps<_mui_material.Theme>[];
|
|
338
334
|
currentPage: number;
|
|
339
335
|
totalNumberOfPages: number;
|
|
340
336
|
onPageChange: (pageNumber: number) => void;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { ReactNode, FC } from 'react';
|
|
2
2
|
import * as _mui_material from '@mui/material';
|
|
3
|
-
import { TableCellProps,
|
|
3
|
+
import { TableCellProps, TableCell, TextFieldProps, StandardTextFieldProps, SelectProps as SelectProps$1, FormControlProps, InputLabelProps, AutocompleteRenderInputParams, AutocompleteProps as AutocompleteProps$1, CheckboxProps as CheckboxProps$1, FormControlLabelProps, SwitchProps as SwitchProps$1, RadioGroupProps, ButtonProps, CircularProgressProps, Theme, SxProps, PaperProps, TableProps, TableHeadProps, TableBodyProps, ModalProps as ModalProps$1, DialogProps, AlertColor } from '@mui/material';
|
|
4
|
+
import * as _mui_material_OverridableComponent from '@mui/material/OverridableComponent';
|
|
4
5
|
import IMask$1 from 'imask';
|
|
5
6
|
import { NextApiRequest, NextApiResponse } from 'next';
|
|
6
7
|
import { ZodTypeDef, ZodSchema } from 'zod';
|
|
@@ -41,6 +42,10 @@ declare function filterData<T>(filters: FilterProps$1[], defaultData: {
|
|
|
41
42
|
current: T[];
|
|
42
43
|
}): T[];
|
|
43
44
|
|
|
45
|
+
declare const Tr: _mui_material_OverridableComponent.OverridableComponent<_mui_material.TableRowTypeMap<{}, "tr">>;
|
|
46
|
+
|
|
47
|
+
declare const Td: typeof TableCell;
|
|
48
|
+
|
|
44
49
|
interface EditableTableCellProps extends TableCellProps {
|
|
45
50
|
name: string;
|
|
46
51
|
TextFieldProps?: TextFieldProps;
|
|
@@ -63,18 +68,6 @@ interface OnSaveProps {
|
|
|
63
68
|
}
|
|
64
69
|
declare const EditableTableCell: (allProps: EditableTableCellProps) => React.JSX.Element;
|
|
65
70
|
|
|
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) => React.JSX.Element>;
|
|
75
|
-
|
|
76
|
-
declare const Td: React.MemoExoticComponent<({ children, ...props }: TableCellProps) => React.JSX.Element>;
|
|
77
|
-
|
|
78
71
|
interface InputProps extends StandardTextFieldProps {
|
|
79
72
|
name: string;
|
|
80
73
|
label: string;
|
|
@@ -96,15 +89,17 @@ declare function InputMask({ withFormik, ...rest }: InputMaskProps): React.JSX.E
|
|
|
96
89
|
interface CustomInputLabelProps extends InputLabelProps {
|
|
97
90
|
size?: 'small';
|
|
98
91
|
}
|
|
99
|
-
|
|
92
|
+
type MuiSelectPropsWithouVariant<T> = Omit<SelectProps$1<T>, 'variant'>;
|
|
93
|
+
type SelectProps<T> = MuiSelectPropsWithouVariant<T> & {
|
|
100
94
|
name: string;
|
|
101
95
|
label: string;
|
|
102
96
|
withFormik?: boolean;
|
|
97
|
+
variant?: SelectProps$1<T>['variant'];
|
|
103
98
|
FormControlProps?: Partial<FormControlProps>;
|
|
104
99
|
InputLabelProps?: Partial<CustomInputLabelProps>;
|
|
105
100
|
helperText?: string;
|
|
106
|
-
}
|
|
107
|
-
declare
|
|
101
|
+
};
|
|
102
|
+
declare function Select<T>({ withFormik, ...rest }: SelectProps<T>): React.JSX.Element;
|
|
108
103
|
|
|
109
104
|
type MuiAutocompleteBaseProps<T> = Omit<AutocompleteProps$1<T, boolean, undefined, boolean>, 'renderInput' | 'getOptionLabel'>;
|
|
110
105
|
interface AutocompleteWithoutProps<T> extends MuiAutocompleteBaseProps<T> {
|
|
@@ -198,11 +193,11 @@ interface TabPanelProps {
|
|
|
198
193
|
}
|
|
199
194
|
declare const TabPanel: (props: TabPanelProps) => React.JSX.Element;
|
|
200
195
|
|
|
201
|
-
interface ColumnsProps {
|
|
196
|
+
interface ColumnsProps<T extends object = Theme> {
|
|
202
197
|
label: string;
|
|
203
198
|
name?: string;
|
|
204
199
|
width?: number;
|
|
205
|
-
sx?: SxProps
|
|
200
|
+
sx?: SxProps<T>;
|
|
206
201
|
canSort?: boolean;
|
|
207
202
|
children?: ReactNode;
|
|
208
203
|
}
|
|
@@ -236,7 +231,8 @@ declare function BaseGrid({ columns, children, paperProps, tableBodyProps, table
|
|
|
236
231
|
type ModalProps = {
|
|
237
232
|
open: boolean;
|
|
238
233
|
onClose: () => void;
|
|
239
|
-
|
|
234
|
+
children: React.ReactNode;
|
|
235
|
+
} & Omit<ModalProps$1, 'children'>;
|
|
240
236
|
declare const Modal: ({ open, onClose, ...rest }: ModalProps) => React.JSX.Element;
|
|
241
237
|
|
|
242
238
|
declare function GetInputLabel<T extends Array<Record<string, any>>, K extends T[number]['name']>(columns: T): (columnName: K) => {
|
|
@@ -263,27 +259,27 @@ declare class HttpError extends Error {
|
|
|
263
259
|
constructor(status: number, message: any);
|
|
264
260
|
}
|
|
265
261
|
|
|
266
|
-
type PossibleMethods =
|
|
267
|
-
type HandlerProps = (req: NextApiRequest & {
|
|
268
|
-
user?:
|
|
262
|
+
type PossibleMethods = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
263
|
+
type HandlerProps<UserKeyType> = (req: NextApiRequest & {
|
|
264
|
+
user?: UserKeyType;
|
|
269
265
|
}, res: NextApiResponse) => Promise<any>;
|
|
270
|
-
type MethodProps = Partial<Record<PossibleMethods, HandlerProps
|
|
271
|
-
type MiddlewaresProps = ((handler: HandlerProps) => HandlerProps)[];
|
|
272
|
-
type ConstructorProps = {
|
|
273
|
-
middlewares?: MiddlewaresProps
|
|
266
|
+
type MethodProps<T> = Partial<Record<PossibleMethods, HandlerProps<T>>>;
|
|
267
|
+
type MiddlewaresProps<T> = ((handler: HandlerProps<T>) => HandlerProps<T>)[];
|
|
268
|
+
type ConstructorProps<T> = {
|
|
269
|
+
middlewares?: MiddlewaresProps<T>;
|
|
274
270
|
onFinally: (req: NextApiRequest) => Promise<void>;
|
|
275
271
|
};
|
|
276
|
-
declare class ApiHelper {
|
|
277
|
-
middlewares: MiddlewaresProps
|
|
272
|
+
declare class ApiHelper<T> {
|
|
273
|
+
middlewares: MiddlewaresProps<T>;
|
|
278
274
|
private onFinally;
|
|
279
|
-
constructor(props?: ConstructorProps);
|
|
275
|
+
constructor(props?: ConstructorProps<T>);
|
|
280
276
|
setMiddlewares(middlewares: any[]): this;
|
|
281
|
-
createMethods(methods: MethodProps): (req: NextApiRequest, res: NextApiResponse) => Promise<void | NextApiResponse<any>>;
|
|
277
|
+
createMethods(methods: MethodProps<T>): (req: NextApiRequest, res: NextApiResponse) => Promise<void | NextApiResponse<any>>;
|
|
282
278
|
static parserErrorWrapper<Output, Def extends ZodTypeDef, Input>(body: Record<string, any>, parser: ZodSchema<Output, Def, Input>): Output;
|
|
283
279
|
static parseQueyFilters<T extends Record<string, any>>(filters: T): T;
|
|
284
280
|
static create({ onFinally }: {
|
|
285
281
|
onFinally: any;
|
|
286
|
-
}): ApiHelper
|
|
282
|
+
}): ApiHelper<unknown>;
|
|
287
283
|
}
|
|
288
284
|
|
|
289
285
|
type Methods = 'get' | 'post' | 'put' | 'delete' | 'patch' | 'options';
|
|
@@ -334,7 +330,7 @@ declare function useGrid<T extends Record<string, any>>({ columns, filters, sear
|
|
|
334
330
|
sortedBy: string;
|
|
335
331
|
defaultData: T[];
|
|
336
332
|
sortedDirection: "desc" | "asc";
|
|
337
|
-
columns: ColumnsProps[];
|
|
333
|
+
columns: ColumnsProps<_mui_material.Theme>[];
|
|
338
334
|
currentPage: number;
|
|
339
335
|
totalNumberOfPages: number;
|
|
340
336
|
onPageChange: (pageNumber: number) => void;
|
package/dist/index.js
CHANGED
|
@@ -2554,34 +2554,11 @@ function getPropertyValue(obj, property) {
|
|
|
2554
2554
|
|
|
2555
2555
|
// src/components/Grid/Td.tsx
|
|
2556
2556
|
|
|
2557
|
-
|
|
2558
|
-
var CustomTableCell = (_a) => {
|
|
2559
|
-
var _b = _a, { children } = _b, props = __objRest(_b, ["children"]);
|
|
2560
|
-
return /* @__PURE__ */ React2.default.createElement(_material.TableCell, __spreadValues({}, props), children);
|
|
2561
|
-
};
|
|
2562
|
-
var Td = _react.memo.call(void 0, CustomTableCell);
|
|
2557
|
+
var Td = _material.TableCell;
|
|
2563
2558
|
|
|
2564
2559
|
// src/components/Grid/Tr.tsx
|
|
2565
2560
|
|
|
2566
|
-
|
|
2567
|
-
var CustomTableRow = (props) => {
|
|
2568
|
-
const _a = props, { children, sx, striped = true, bordered = void 0 } = _a, rest = __objRest(_a, ["children", "sx", "striped", "bordered"]);
|
|
2569
|
-
return /* @__PURE__ */ React2.default.createElement(
|
|
2570
|
-
_material.TableRow,
|
|
2571
|
-
__spreadValues({
|
|
2572
|
-
sx: __spreadValues({
|
|
2573
|
-
"&:nth-of-type(even)": { bgcolor: striped ? "action.selected" : "" }
|
|
2574
|
-
}, sx)
|
|
2575
|
-
}, rest),
|
|
2576
|
-
React2.default.Children.map(
|
|
2577
|
-
children,
|
|
2578
|
-
(child) => React2.default.cloneElement(child, {
|
|
2579
|
-
bordered
|
|
2580
|
-
})
|
|
2581
|
-
)
|
|
2582
|
-
);
|
|
2583
|
-
};
|
|
2584
|
-
var Tr = _react.memo.call(void 0, CustomTableRow);
|
|
2561
|
+
var Tr = _material.TableRow;
|
|
2585
2562
|
|
|
2586
2563
|
// src/components/Grid/AutoCreatedRows.tsx
|
|
2587
2564
|
var AutoCreatedRows = ({
|
|
@@ -3300,14 +3277,14 @@ function FormikInputMask(_a) {
|
|
|
3300
3277
|
|
|
3301
3278
|
|
|
3302
3279
|
var CustomInputLabel = _material.InputLabel;
|
|
3303
|
-
|
|
3280
|
+
function Select(_a) {
|
|
3304
3281
|
var _b = _a, { withFormik = true } = _b, rest = __objRest(_b, ["withFormik"]);
|
|
3305
3282
|
if (withFormik)
|
|
3306
3283
|
return /* @__PURE__ */ React2.default.createElement(FormikSelect, __spreadValues({}, rest));
|
|
3307
3284
|
else
|
|
3308
3285
|
return /* @__PURE__ */ React2.default.createElement(BaseSelect, __spreadValues({}, rest));
|
|
3309
|
-
}
|
|
3310
|
-
|
|
3286
|
+
}
|
|
3287
|
+
function BaseSelect(_a) {
|
|
3311
3288
|
var _b = _a, {
|
|
3312
3289
|
name,
|
|
3313
3290
|
label,
|
|
@@ -3332,8 +3309,8 @@ var BaseSelect = (_a) => {
|
|
|
3332
3309
|
}, rest),
|
|
3333
3310
|
children
|
|
3334
3311
|
));
|
|
3335
|
-
}
|
|
3336
|
-
|
|
3312
|
+
}
|
|
3313
|
+
function FormikSelect(_a) {
|
|
3337
3314
|
var _b = _a, {
|
|
3338
3315
|
name,
|
|
3339
3316
|
label,
|
|
@@ -3366,7 +3343,7 @@ var FormikSelect = (_a) => {
|
|
|
3366
3343
|
}),
|
|
3367
3344
|
children
|
|
3368
3345
|
), /* @__PURE__ */ React2.default.createElement(_material.FormHelperText, null, helperText || (meta == null ? void 0 : meta.error)));
|
|
3369
|
-
}
|
|
3346
|
+
}
|
|
3370
3347
|
|
|
3371
3348
|
// src/components/Autocomplete/index.tsx
|
|
3372
3349
|
|
|
@@ -3911,7 +3888,7 @@ function BaseGrid({
|
|
|
3911
3888
|
|
|
3912
3889
|
var Modal = (_a) => {
|
|
3913
3890
|
var _b = _a, { open, onClose } = _b, rest = __objRest(_b, ["open", "onClose"]);
|
|
3914
|
-
return /* @__PURE__ */ React2.default.createElement(_material.Modal, __spreadValues({ open, onClose
|
|
3891
|
+
return /* @__PURE__ */ React2.default.createElement(_material.Modal, __spreadValues({ open, onClose }, rest), /* @__PURE__ */ React2.default.createElement(
|
|
3915
3892
|
_material.Box,
|
|
3916
3893
|
{
|
|
3917
3894
|
sx: {
|