@bluemarble/bm-components 0.0.92 → 0.0.93

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.
@@ -0,0 +1,311 @@
1
+ import React, { ReactNode, FC } from 'react';
2
+ 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 } from '@mui/material';
3
+ import IMask$1 from 'imask';
4
+
5
+ interface ColumnTitleProps {
6
+ name: string;
7
+ label: string;
8
+ transformer?: (value: string | number | Date) => string;
9
+ sx?: TableCellProps['sx'];
10
+ }
11
+ interface FilterProps$1 {
12
+ column: string;
13
+ value: string;
14
+ transformer?: (value: string | number | Date) => string;
15
+ }
16
+ declare type IFilter = FilterProps$1;
17
+ interface GridProps$1<T> {
18
+ columnTitles: ColumnTitleProps[];
19
+ defaultData: T[];
20
+ tableData: T[];
21
+ selectedFilters: FilterProps$1[];
22
+ setSelectedFilters(value: FilterProps$1[]): void;
23
+ setTableData(value: T[]): void;
24
+ updateFilters(value: Record<string, any>[]): void;
25
+ rowOptions?: number[];
26
+ footer?: ReactNode;
27
+ customButtons?: ReactNode;
28
+ isLoading?: boolean;
29
+ noFilterButtons?: boolean;
30
+ noPagination?: boolean;
31
+ noFilters?: boolean;
32
+ primaryKey?: string;
33
+ }
34
+ declare const Grid: <ObjectType>(props: React.PropsWithChildren<GridProps$1<ObjectType>>) => JSX.Element;
35
+
36
+ declare function filterData<T>(filters: FilterProps$1[], defaultData: {
37
+ current: T[];
38
+ }): T[];
39
+
40
+ interface EditableTableCellProps extends TableCellProps {
41
+ name: string;
42
+ TextFieldProps?: TextFieldProps;
43
+ type?: TextFieldProps['type'];
44
+ fullWidth?: boolean;
45
+ rowData?: Record<string, any>;
46
+ mask?: IMask.AnyMaskedOptions;
47
+ bordered?: boolean;
48
+ rowIndex?: string | number;
49
+ formatCellValue?: (value: string) => string;
50
+ formatInputDefautvalue?: (value: string) => string;
51
+ onSave?: (props: OnSaveProps) => void;
52
+ onCancel?: () => void;
53
+ }
54
+ interface OnSaveProps {
55
+ name: string;
56
+ event: FocusEvent;
57
+ value: string;
58
+ data: Record<string, any>;
59
+ }
60
+ declare const EditableTableCell: (allProps: EditableTableCellProps) => JSX.Element;
61
+
62
+ interface CustomTableRowProps extends TableRowProps {
63
+ striped?: boolean;
64
+ bordered?: boolean;
65
+ index?: number;
66
+ rowData?: Record<string, any>;
67
+ onSave?: (props: OnSaveProps) => void;
68
+ children: React.ReactNode;
69
+ }
70
+ declare const Tr: React.MemoExoticComponent<(props: CustomTableRowProps) => JSX.Element>;
71
+
72
+ declare const Td: React.MemoExoticComponent<({ children, ...props }: TableCellProps) => JSX.Element>;
73
+
74
+ interface InputProps extends StandardTextFieldProps {
75
+ name: string;
76
+ label: string;
77
+ shrink?: boolean;
78
+ withFormik?: boolean;
79
+ }
80
+ declare const Input: FC<InputProps>;
81
+
82
+ interface InputMaskProps extends Partial<StandardTextFieldProps> {
83
+ name: string;
84
+ label: string;
85
+ withFormik?: boolean;
86
+ value?: string;
87
+ mask: IMask$1.AnyMaskedOptions;
88
+ onChangeValue?: (value: string, unmaskedValue: string) => void;
89
+ }
90
+ declare function InputMask({ withFormik, ...rest }: InputMaskProps): JSX.Element;
91
+
92
+ interface CustomInputLabelProps extends InputLabelProps {
93
+ size?: 'small';
94
+ }
95
+ interface SelectProps extends SelectProps$1 {
96
+ name: string;
97
+ label: string;
98
+ defaultValue?: string;
99
+ withFormik?: boolean;
100
+ FormControlProps?: Partial<FormControlProps>;
101
+ InputLabelProps?: Partial<CustomInputLabelProps>;
102
+ helperText?: string;
103
+ }
104
+ declare const Select: FC<SelectProps>;
105
+
106
+ declare type MuiAutocompleteBaseProps<T> = Omit<AutocompleteProps$1<T, boolean, undefined, boolean>, 'renderInput' | 'getOptionLabel'>;
107
+ interface AutocompleteWithoutProps<T> extends MuiAutocompleteBaseProps<T> {
108
+ name?: never;
109
+ withFormik: false;
110
+ getOptionValue?: never;
111
+ label?: string;
112
+ getOptionLabel: (option: T) => string;
113
+ renderInput?: (params: AutocompleteRenderInputParams) => ReactNode;
114
+ }
115
+ interface AutocompleteWithFormikProps<T> extends MuiAutocompleteBaseProps<T> {
116
+ name: string;
117
+ withFormik?: true;
118
+ label?: string;
119
+ option?: {
120
+ label?: keyof T;
121
+ value?: keyof T;
122
+ key?: string;
123
+ };
124
+ renderInput?: (params: AutocompleteRenderInputParams) => ReactNode;
125
+ getOptionLabel?: (option: T) => string;
126
+ getOptionValue?: (option: T) => string | number;
127
+ }
128
+ declare type AutocompleteProps<T> = AutocompleteWithoutProps<T> | AutocompleteWithFormikProps<T>;
129
+ declare function Autocomplete<T>({ withFormik, name, getOptionValue, ...rest }: AutocompleteProps<T>): JSX.Element;
130
+
131
+ declare type CheckboxProps = CheckboxWithFormik | CheckboxWithoutFormik;
132
+ interface CheckboxWithFormik extends CheckboxProps$1 {
133
+ name: string;
134
+ label?: string;
135
+ withFormik?: true;
136
+ FormControlLabelProps?: Partial<FormControlLabelProps>;
137
+ }
138
+ interface CheckboxWithoutFormik extends CheckboxProps$1 {
139
+ name?: never;
140
+ label?: string;
141
+ withFormik: false;
142
+ FormControlLabelProps?: Partial<FormControlLabelProps>;
143
+ }
144
+ declare const Checkbox: ({ withFormik, name, ...props }: CheckboxProps) => JSX.Element;
145
+
146
+ declare type SwitchProps = SwitchWithFormik | SwitchWithoutFormik;
147
+ interface SwitchWithFormik extends SwitchProps$1 {
148
+ name: string;
149
+ label?: string;
150
+ withFormik?: true;
151
+ FormControlLabelProps?: Partial<FormControlLabelProps>;
152
+ }
153
+ interface SwitchWithoutFormik extends SwitchProps$1 {
154
+ name?: never;
155
+ label?: string;
156
+ withFormik: false;
157
+ FormControlLabelProps?: Partial<FormControlLabelProps>;
158
+ }
159
+ declare const Switch: ({ withFormik, name, ...props }: SwitchProps) => JSX.Element;
160
+
161
+ declare type RadioOptionProps = {
162
+ value: string | number | boolean;
163
+ label: string;
164
+ };
165
+ declare type RadioOptionsProps = RadioWithFormik | RadioWithoutFormik;
166
+ interface RadioWithFormik extends RadioGroupProps {
167
+ name: string;
168
+ label?: string;
169
+ options: RadioOptionProps[];
170
+ withFormik?: true;
171
+ }
172
+ interface RadioWithoutFormik extends RadioGroupProps {
173
+ name?: never;
174
+ label?: string;
175
+ options: RadioOptionProps[];
176
+ withFormik: false;
177
+ }
178
+ declare const Radio: ({ name, withFormik, ...rest }: RadioOptionsProps) => JSX.Element;
179
+
180
+ interface LargeButtonProps extends ButtonProps {
181
+ loading?: boolean;
182
+ children: ReactNode;
183
+ CircularProgressProps?: CircularProgressProps;
184
+ }
185
+ declare const LargeButton: ({ loading, children, CircularProgressProps, sx, ...rest }: LargeButtonProps) => JSX.Element;
186
+
187
+ declare function getTabProps(index: string): {
188
+ id: string;
189
+ 'aria-controls': string;
190
+ };
191
+ interface TabPanelProps {
192
+ children: React.ReactNode;
193
+ value: number;
194
+ index: number;
195
+ }
196
+ declare const TabPanel: (props: TabPanelProps) => JSX.Element;
197
+
198
+ interface ColumnsProps {
199
+ label: string;
200
+ name?: string;
201
+ width?: number;
202
+ sx?: SxProps;
203
+ canSort?: boolean;
204
+ children?: ReactNode;
205
+ }
206
+ interface GridProps {
207
+ columns: ColumnsProps[];
208
+ children: ReactNode;
209
+ prependColumn?: ReactNode;
210
+ appendColumn?: ReactNode;
211
+ fixedColumns?: boolean;
212
+ sortedBy: string;
213
+ sortedDirection: 'asc' | 'desc';
214
+ dense?: boolean;
215
+ onSortBy: (prop: string) => void;
216
+ paperProps?: PaperProps;
217
+ tableProps?: TableProps;
218
+ tableHeadProps?: TableHeadProps;
219
+ tableBodyProps?: TableBodyProps;
220
+ striped?: boolean;
221
+ bordered?: boolean;
222
+ currentPage: number;
223
+ totalNumberOfPages: number;
224
+ rowsPerPageOptions: number[];
225
+ rowsPerPage: number;
226
+ onPageChange: (pageNumber: number) => void;
227
+ setRowsPerPage: (rows: number) => void;
228
+ isLoading?: boolean;
229
+ hideFooter?: boolean;
230
+ }
231
+ 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
+
233
+ declare type FilterCompareType = 'gte' | 'lte' | 'lt' | 'gt' | 'equal' | 'in' | 'notEqual' | 'notIn';
234
+ declare type FilterProps = {
235
+ id?: string;
236
+ prop: string;
237
+ value: unknown;
238
+ compareType: FilterCompareType;
239
+ };
240
+ declare function useFilter(): {
241
+ filters: FilterProps[];
242
+ filterBy: (newFilter: FilterProps) => void;
243
+ removeFilter: (prop: string, isId?: boolean) => void;
244
+ createFilter: typeof createFilter;
245
+ clearAllFilters: () => void;
246
+ };
247
+ declare function createFilter<T extends Record<string, any>>(filters: FilterProps[]): {
248
+ apply: (item: T) => boolean;
249
+ };
250
+
251
+ interface SearchOptions {
252
+ caseSensitive?: boolean;
253
+ exact?: boolean;
254
+ value: string;
255
+ }
256
+ interface UseGridProps {
257
+ columns: ColumnsProps[];
258
+ filters?: FilterProps[];
259
+ rowsPerPageOptions?: number[];
260
+ search?: SearchOptions;
261
+ }
262
+ declare function useGrid<T extends Record<string, any>>({ columns, filters, search, rowsPerPageOptions }: UseGridProps): {
263
+ data: T[];
264
+ set: (data: T[]) => void;
265
+ onSortBy: (prop: string) => void;
266
+ sortedBy: string;
267
+ defaultData: T[];
268
+ sortedDirection: "desc" | "asc";
269
+ columns: ColumnsProps[];
270
+ currentPage: number;
271
+ totalNumberOfPages: number;
272
+ onPageChange: (pageNumber: number) => void;
273
+ setRowsPerPage: (rows: number) => void;
274
+ rowsPerPageOptions: number[];
275
+ rowsPerPage: number;
276
+ setSort: (prop: string, direction: 'desc' | 'asc') => void;
277
+ };
278
+
279
+ declare function useEvent(event: keyof WindowEventMap, handler: (ev: any) => void, passive?: boolean): void;
280
+
281
+ declare function useLoading<T = string>(): {
282
+ isLoading: (prop: T) => boolean;
283
+ setLoading: (prop: T, remove?: boolean) => void;
284
+ };
285
+
286
+ declare type ModalProps = {
287
+ open: boolean;
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;
295
+ };
296
+
297
+ interface DialogOptionsProps {
298
+ label: string;
299
+ focus?: boolean;
300
+ cb(label: string): void;
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;
310
+
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 };