@bluemarble/bm-components 0.0.33 → 0.0.34

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,11 @@
1
+ declare type GridPaginationProps = {
2
+ dense: boolean;
3
+ currentPage: number;
4
+ totalNumberOfPages: number;
5
+ rowsPerPageOptions: number[];
6
+ rowsPerPage: number;
7
+ onPageChange: (prop: number) => void;
8
+ setRowsPerPage: (prop: number) => void;
9
+ };
10
+ export declare const GridPagination: ({ currentPage, totalNumberOfPages, onPageChange, rowsPerPageOptions, setRowsPerPage, rowsPerPage, dense, }: GridPaginationProps) => JSX.Element;
11
+ export {};
@@ -0,0 +1,32 @@
1
+ import { ReactNode } from "react";
2
+ import { PaperProps, SxProps, TableBodyProps, TableHeadProps, TableProps } from "@mui/material";
3
+ export interface ColumnsProps {
4
+ label: string;
5
+ name?: string;
6
+ width?: number;
7
+ sx?: SxProps;
8
+ canSort?: boolean;
9
+ }
10
+ interface GridProps {
11
+ columns: ColumnsProps[];
12
+ children: ReactNode;
13
+ fixedColumns?: boolean;
14
+ sortedBy: string;
15
+ sortedDirection: "asc" | "desc";
16
+ dense?: boolean;
17
+ onSortBy: (prop: string) => void;
18
+ paperProps?: PaperProps;
19
+ tableProps?: TableProps;
20
+ tableHeadProps?: TableHeadProps;
21
+ tableBodyProps?: TableBodyProps;
22
+ striped?: boolean;
23
+ bordered?: boolean;
24
+ currentPage: number;
25
+ totalNumberOfPages: number;
26
+ rowsPerPageOptions: number[];
27
+ rowsPerPage: number;
28
+ onPageChange: (pageNumber: number) => void;
29
+ setRowsPerPage: (rows: number) => void;
30
+ }
31
+ export declare function Grid<T>({ columns: columnsData, children, fixedColumns, paperProps, tableBodyProps, tableHeadProps, tableProps, sortedDirection, sortedBy, onSortBy, dense, striped, bordered, currentPage, totalNumberOfPages, onPageChange, rowsPerPage, setRowsPerPage, rowsPerPageOptions, }: GridProps): JSX.Element;
32
+ export {};
@@ -0,0 +1,17 @@
1
+ export declare type FilterCompareType = "gte" | "lte" | "lt" | "gt" | "equal" | "in";
2
+ export declare type FilterProps = {
3
+ id?: string;
4
+ prop: string;
5
+ value: unknown;
6
+ compareType: FilterCompareType;
7
+ };
8
+ export declare function useFilter(): {
9
+ filters: FilterProps[];
10
+ filterBy: (newFilter: FilterProps) => void;
11
+ removeFilter: (prop: string) => void;
12
+ createFilter: typeof createFilter;
13
+ clearAllFilters: () => void;
14
+ };
15
+ export declare function createFilter<T extends Record<string, any>>(filters: FilterProps[]): {
16
+ apply: (item: T) => boolean;
17
+ };
@@ -0,0 +1,23 @@
1
+ import { ColumnsProps } from "../BaseGrid";
2
+ import { FilterProps } from "./useFilter";
3
+ interface UseGridProps {
4
+ columns: ColumnsProps[];
5
+ filters?: FilterProps[];
6
+ rowsPerPageOptions?: number[];
7
+ }
8
+ export declare function useGrid<T extends Record<string, any>>({ columns, filters, rowsPerPageOptions, }: UseGridProps): {
9
+ data: any[];
10
+ defaultData: T[];
11
+ set: (data: T[]) => void;
12
+ onSortBy: (prop: string) => void;
13
+ sortedBy: string;
14
+ sortedDirection: "asc" | "desc";
15
+ columns: ColumnsProps[];
16
+ currentPage: number;
17
+ totalNumberOfPages: number;
18
+ onPageChange: (pageNumber: number) => void;
19
+ setRowsPerPage: (rows: number) => void;
20
+ rowsPerPageOptions: number[];
21
+ rowsPerPage: number;
22
+ };
23
+ export {};
@@ -1,4 +1,4 @@
1
- export { default as Grid, IFilter, ColumnTitleProps, FilterProps, filterData, Tr, Td, EditableTableCell, } from "./Grid";
1
+ export { default as Grid, IFilter, ColumnTitleProps, filterData, Tr, Td, EditableTableCell, } from "./Grid";
2
2
  export { Input } from "./Input";
3
3
  export { InputMask } from "./InputMask";
4
4
  export { Select } from "./Select";
@@ -8,3 +8,7 @@ export { Switch } from "./Switch";
8
8
  export { Radio } from "./Radio";
9
9
  export { LargeButton } from "./LargeButton";
10
10
  export { TabPanel, getTabProps, TabPanelProps } from "./TabPanel";
11
+ export { ColumnsProps, Grid as BaseGrid } from "./BaseGrid";
12
+ export { useGrid } from "./hooks/useGrid";
13
+ export { FilterCompareType, FilterProps, createFilter, useFilter, } from "./hooks/useFilter";
14
+ export { useEvent } from "./hooks/useEvent";
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import React, { ReactNode, FC } from 'react';
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 } 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 } from '@mui/material';
4
4
  import IMask$1 from 'imask';
5
5
 
6
6
  interface ColumnTitleProps {
@@ -9,18 +9,18 @@ interface ColumnTitleProps {
9
9
  transformer?: (value: string | number | Date) => string;
10
10
  sx?: TableCellProps["sx"];
11
11
  }
12
- interface FilterProps {
12
+ interface FilterProps$1 {
13
13
  column: string;
14
14
  value: string;
15
15
  transformer?: (value: string | number | Date) => string;
16
16
  }
17
- declare type IFilter = FilterProps;
18
- interface GridProps<T> {
17
+ declare type IFilter = FilterProps$1;
18
+ interface GridProps$1<T> {
19
19
  columnTitles: ColumnTitleProps[];
20
20
  defaultData: T[];
21
21
  tableData: T[];
22
- selectedFilters: FilterProps[];
23
- setSelectedFilters(value: FilterProps[]): void;
22
+ selectedFilters: FilterProps$1[];
23
+ setSelectedFilters(value: FilterProps$1[]): void;
24
24
  setTableData(value: T[]): void;
25
25
  updateFilters(value: Record<string, any>[]): void;
26
26
  rowOptions?: number[];
@@ -32,9 +32,9 @@ interface GridProps<T> {
32
32
  noFilters?: boolean;
33
33
  primaryKey?: string;
34
34
  }
35
- declare const Grid: <ObjectType>(props: React.PropsWithChildren<GridProps<ObjectType>>) => JSX.Element;
35
+ declare const Grid$1: <ObjectType>(props: React.PropsWithChildren<GridProps$1<ObjectType>>) => JSX.Element;
36
36
 
37
- declare function filterData<T>(filters: FilterProps[], defaultData: {
37
+ declare function filterData<T>(filters: FilterProps$1[], defaultData: {
38
38
  current: T[];
39
39
  }): T[];
40
40
 
@@ -194,4 +194,75 @@ interface TabPanelProps {
194
194
  }
195
195
  declare const TabPanel: (props: TabPanelProps) => JSX.Element;
196
196
 
197
- export { Autocomplete, Checkbox, ColumnTitleProps, EditableTableCell, FilterProps, Grid, IFilter, Input, InputMask, LargeButton, Radio, Select, Switch, TabPanel, TabPanelProps, Td, Tr, filterData, getTabProps };
197
+ interface ColumnsProps {
198
+ label: string;
199
+ name?: string;
200
+ width?: number;
201
+ sx?: SxProps;
202
+ canSort?: boolean;
203
+ }
204
+ interface GridProps {
205
+ columns: ColumnsProps[];
206
+ children: ReactNode;
207
+ fixedColumns?: boolean;
208
+ sortedBy: string;
209
+ sortedDirection: "asc" | "desc";
210
+ dense?: boolean;
211
+ onSortBy: (prop: string) => void;
212
+ paperProps?: PaperProps;
213
+ tableProps?: TableProps;
214
+ tableHeadProps?: TableHeadProps;
215
+ tableBodyProps?: TableBodyProps;
216
+ striped?: boolean;
217
+ bordered?: boolean;
218
+ currentPage: number;
219
+ totalNumberOfPages: number;
220
+ rowsPerPageOptions: number[];
221
+ rowsPerPage: number;
222
+ onPageChange: (pageNumber: number) => void;
223
+ setRowsPerPage: (rows: number) => void;
224
+ }
225
+ declare function Grid<T>({ columns: columnsData, children, fixedColumns, paperProps, tableBodyProps, tableHeadProps, tableProps, sortedDirection, sortedBy, onSortBy, dense, striped, bordered, currentPage, totalNumberOfPages, onPageChange, rowsPerPage, setRowsPerPage, rowsPerPageOptions, }: GridProps): JSX.Element;
226
+
227
+ declare type FilterCompareType = "gte" | "lte" | "lt" | "gt" | "equal" | "in";
228
+ declare type FilterProps = {
229
+ id?: string;
230
+ prop: string;
231
+ value: unknown;
232
+ compareType: FilterCompareType;
233
+ };
234
+ declare function useFilter(): {
235
+ filters: FilterProps[];
236
+ filterBy: (newFilter: FilterProps) => void;
237
+ removeFilter: (prop: string) => void;
238
+ createFilter: typeof createFilter;
239
+ clearAllFilters: () => void;
240
+ };
241
+ declare function createFilter<T extends Record<string, any>>(filters: FilterProps[]): {
242
+ apply: (item: T) => boolean;
243
+ };
244
+
245
+ interface UseGridProps {
246
+ columns: ColumnsProps[];
247
+ filters?: FilterProps[];
248
+ rowsPerPageOptions?: number[];
249
+ }
250
+ declare function useGrid<T extends Record<string, any>>({ columns, filters, rowsPerPageOptions, }: UseGridProps): {
251
+ data: any[];
252
+ defaultData: T[];
253
+ set: (data: T[]) => void;
254
+ onSortBy: (prop: string) => void;
255
+ sortedBy: string;
256
+ sortedDirection: "asc" | "desc";
257
+ columns: ColumnsProps[];
258
+ currentPage: number;
259
+ totalNumberOfPages: number;
260
+ onPageChange: (pageNumber: number) => void;
261
+ setRowsPerPage: (rows: number) => void;
262
+ rowsPerPageOptions: number[];
263
+ rowsPerPage: number;
264
+ };
265
+
266
+ declare function useEvent(event: keyof WindowEventMap, handler: (ev: any) => void, passive?: boolean): void;
267
+
268
+ export { Autocomplete, Grid as BaseGrid, Checkbox, ColumnTitleProps, ColumnsProps, EditableTableCell, FilterCompareType, FilterProps, Grid$1 as Grid, IFilter, Input, InputMask, LargeButton, Radio, Select, Switch, TabPanel, TabPanelProps, Td, Tr, createFilter, filterData, getTabProps, useEvent, useFilter, useGrid };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bluemarble/bm-components",
3
- "version": "0.0.33",
3
+ "version": "0.0.34",
4
4
  "description": "BM components",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",