@pdg/react-table 1.0.21 → 1.0.23

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.
@@ -1,4 +1,8 @@
1
1
  import React from 'react';
2
2
  import { SearchTableProps, SearchTableCommands } from './SearchTable.types';
3
- declare const SearchTable: React.ForwardRefExoticComponent<SearchTableProps & React.RefAttributes<SearchTableCommands>>;
3
+ import { TableItem } from '../Table';
4
+ interface WithForwardRefType<T = TableItem> extends React.FC<SearchTableProps<T>> {
5
+ <T = TableItem>(props: SearchTableProps<T> & React.RefAttributes<SearchTableCommands<T>>): ReturnType<React.FC<SearchTableProps<T>>>;
6
+ }
7
+ declare const SearchTable: WithForwardRefType;
4
8
  export default SearchTable;
@@ -3,32 +3,32 @@ import { TableProps, TableCommands, TableItem } from '../Table';
3
3
  import { FormValueMap, SearchCommands, SearchProps } from '@pdg/react-form';
4
4
  import { ReactNode } from 'react';
5
5
  import { CommonSxProps } from '../@types';
6
- export interface SearchTableData {
7
- items: TableProps['items'];
8
- paging?: TableProps['paging'];
6
+ export interface SearchTableData<T = TableItem> {
7
+ items: TableProps<T>['items'];
8
+ paging?: TableProps<T>['paging'];
9
9
  }
10
10
  export interface SearchTableSearchProps extends Omit<SearchProps, 'ref' | 'color' | 'autoSubmit' | 'onSubmit'> {
11
11
  ref?: React.ForwardedRef<SearchCommands>;
12
12
  searchGroups?: ReactNode;
13
13
  }
14
14
  export interface SearchTableTableProps<T = TableItem> extends Omit<TableProps<T>, 'ref' | 'items' | 'paging' | 'onPageChange'> {
15
- ref?: React.ForwardedRef<TableCommands>;
15
+ ref?: React.ForwardedRef<TableCommands<T>>;
16
16
  }
17
- export interface SearchTableProps extends CommonSxProps {
17
+ export interface SearchTableProps<T = TableItem> extends CommonSxProps {
18
18
  color?: SearchProps['color'];
19
19
  hash?: boolean;
20
20
  stickyHeader?: boolean;
21
21
  fullHeight?: boolean;
22
22
  search?: SearchTableSearchProps;
23
- table: SearchTableTableProps;
23
+ table: SearchTableTableProps<T>;
24
24
  betweenSearchTableComponent?: ReactNode;
25
- onGetData?(data: FormValueMap): Promise<SearchTableData>;
25
+ onGetData?(data: FormValueMap): Promise<SearchTableData<T>>;
26
26
  onRequestHashChange?(hash: string): void;
27
27
  }
28
28
  export declare const SearchTableDefaultProps: {};
29
- export interface SearchTableCommands {
29
+ export interface SearchTableCommands<T = TableItem> {
30
30
  reload(page?: number): void;
31
31
  getLastLoadData(): FormValueMap;
32
32
  getSearch(): SearchCommands | undefined;
33
- getTable(): TableCommands | undefined;
33
+ getTable(): TableCommands<T> | undefined;
34
34
  }
@@ -1,5 +1,8 @@
1
1
  import React from 'react';
2
2
  import { TableProps, TableCommands, TableItem } from './Table.types';
3
3
  import 'simplebar-react/dist/simplebar.min.css';
4
- declare const Table: React.ForwardRefExoticComponent<TableProps<TableItem> & React.RefAttributes<TableCommands>>;
4
+ interface WithForwardRefType<T = TableItem> extends React.FC<TableProps<T>> {
5
+ <T = TableItem>(props: TableProps<T> & React.RefAttributes<TableCommands<T>>): ReturnType<React.FC<TableProps<T>>>;
6
+ }
7
+ declare const Table: WithForwardRefType;
5
8
  export default Table;
@@ -6,7 +6,8 @@ export interface TableItem {
6
6
  [key: string]: any;
7
7
  }
8
8
  export interface TableColumn<T = TableItem> {
9
- type?: 'text' | 'number' | 'date' | 'datetime' | 'img' | 'button' | 'buttons';
9
+ id: string;
10
+ type?: 'text' | 'number' | 'date' | 'datetime' | 'img' | 'button' | 'buttons' | 'check';
10
11
  label?: ReactNode;
11
12
  name?: string;
12
13
  align?: TableCellProps['align'];
@@ -43,6 +44,9 @@ export interface TableColumn<T = TableItem> {
43
44
  onGetTooltip?(item: T, index: number): ReactNode;
44
45
  onRender?(item: T, index: number): ReactNode;
45
46
  onClick?(item: T, index: number): void;
47
+ onInitChecked?(item: T): boolean;
48
+ onCheckDisabled?(item: T): boolean;
49
+ onCheckChange?(item: T, checked: boolean): void;
46
50
  }
47
51
  export interface TableProps<T = TableItem> extends CommonSxProps {
48
52
  columns?: (TableColumn<T> | false | undefined | null)[];
@@ -71,13 +75,15 @@ export interface TableProps<T = TableItem> extends CommonSxProps {
71
75
  onGetBodyRowSx?(item: T, index: number): CommonSxProps['sx'] | undefined;
72
76
  onPageChange?(page: number): void;
73
77
  onSortChange?(items: T[]): void;
78
+ onCheckChange?(columnId: string, items: T[]): void;
74
79
  }
75
80
  export declare const TableDefaultProps: Pick<TableProps, 'defaultAlign' | 'pagingAlign' | 'cellPadding'>;
76
- export interface TableCommands {
77
- getColumns(): TableProps['columns'];
78
- setColumns(columns: TableProps['columns']): void;
79
- getItems(): TableProps['items'];
80
- getPaging(): TableProps['paging'];
81
- setItemsPaging(items: TableProps['items'], paging: TableProps['paging']): void;
81
+ export interface TableCommands<T = TableItem> {
82
+ getColumns(): TableProps<T>['columns'];
83
+ setColumns(columns: TableProps<T>['columns']): void;
84
+ getItems(): TableProps<T>['items'];
85
+ getPaging(): TableProps<T>['paging'];
86
+ setItemsPaging(items: TableProps<T>['items'], paging: TableProps<T>['paging']): void;
82
87
  resetSort(): void;
88
+ getCheckedItems(columnId: string): T[];
83
89
  }
@@ -1,4 +1,8 @@
1
1
  import { TableColumn, TableItem, TableProps } from '../Table/Table.types';
2
+ export interface TableBodyCellCommands {
3
+ setCheckDisabled(disabled: boolean): void;
4
+ setChecked(checked: boolean): void;
5
+ }
2
6
  export interface TableBodyCellProps {
3
7
  index: number;
4
8
  item: TableItem;
@@ -6,4 +10,5 @@ export interface TableBodyCellProps {
6
10
  defaultAlign?: TableProps['defaultAlign'];
7
11
  defaultEllipsis?: boolean;
8
12
  onClick: TableProps['onClick'];
13
+ onCheckChange(item: TableItem, column: TableColumn, checked: boolean): void;
9
14
  }
@@ -1,5 +1,6 @@
1
1
  import { TableCellProps, TableRowProps } from '@mui/material';
2
2
  import { TableColumn, TableItem, TableProps } from '../Table';
3
+ import { TableBodyCellProps } from '../TableBodyCell';
3
4
  export interface TableBodyRowProps extends Omit<TableRowProps, 'id' | 'onClick'> {
4
5
  id: string | number;
5
6
  index: number;
@@ -9,5 +10,6 @@ export interface TableBodyRowProps extends Omit<TableRowProps, 'id' | 'onClick'>
9
10
  columns: TableColumn<TableItem>[];
10
11
  item: TableItem;
11
12
  onClick: TableProps['onClick'];
13
+ onCheckChange: TableBodyCellProps['onCheckChange'];
12
14
  }
13
15
  export declare const TableBodyRowDefaultProps: {};
@@ -1,6 +1,14 @@
1
+ import { TableColumn, TableItem } from '../Table';
2
+ import { TableBodyCellCommands } from '../TableBodyCell';
3
+ import { TableHeadCellCommands } from '../TableHeadCell';
1
4
  export interface TableContextValue {
2
5
  menuOpen: boolean;
3
6
  openMenuId?: string;
4
7
  setMenuOpen(menuOpen: boolean, openMenuId?: string): void;
8
+ setItemColumnChecked(item: TableItem, column: TableColumn, checked: boolean): void;
9
+ setItemColumnCheckDisabled(item: TableItem, column: TableColumn, checkDisabled: boolean): void;
10
+ setItemColumnCommands(item: TableItem, column: TableColumn, commands: TableBodyCellCommands): void;
11
+ setHeadColumnChecked(column: TableColumn, checked: boolean): void;
12
+ setHeadColumnCommands(column: TableColumn, commands: TableHeadCellCommands): void;
5
13
  }
6
14
  export declare const TableContextDefaultValue: TableContextValue;
@@ -1,5 +1,9 @@
1
1
  import { TableColumn, TableProps } from '../Table/Table.types';
2
+ export interface TableHeadCellCommands {
3
+ setChecked(checked: boolean): void;
4
+ }
2
5
  export interface TableHeadCellProps {
3
6
  column: TableColumn;
4
7
  defaultAlign?: TableProps['defaultAlign'];
8
+ onCheckChange(column: TableColumn, checked: boolean): void;
5
9
  }