@paubox/ui 0.22.0 → 1.0.0
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/package.json
CHANGED
|
@@ -1,16 +1,33 @@
|
|
|
1
|
-
export interface
|
|
1
|
+
export interface PageInfoPageBased {
|
|
2
|
+
currentPage: number;
|
|
3
|
+
pageSize: number;
|
|
2
4
|
pageCount: number;
|
|
3
5
|
itemCount: number;
|
|
4
|
-
currentPage: number;
|
|
5
|
-
items: number;
|
|
6
6
|
}
|
|
7
|
-
interface
|
|
8
|
-
|
|
7
|
+
export interface PageInfoCursorBased {
|
|
8
|
+
pageSize: number;
|
|
9
|
+
itemCount: number;
|
|
10
|
+
currentCursor: string[];
|
|
11
|
+
hasNextPage: boolean;
|
|
12
|
+
hasPrevPage: boolean;
|
|
13
|
+
pageIndex: number;
|
|
14
|
+
}
|
|
15
|
+
interface BasePaginationProps {
|
|
9
16
|
isLoading: boolean;
|
|
10
17
|
subText?: string;
|
|
11
18
|
onPageSizeChange: (size: number) => void;
|
|
12
|
-
onPageChange: (page: number) => void;
|
|
13
19
|
testId?: string;
|
|
14
20
|
}
|
|
15
|
-
|
|
21
|
+
interface PagePaginationProps extends BasePaginationProps {
|
|
22
|
+
mode: 'page';
|
|
23
|
+
pageInfo: PageInfoPageBased;
|
|
24
|
+
onPageChange: (page: number) => void;
|
|
25
|
+
}
|
|
26
|
+
interface CursorPaginationProps extends BasePaginationProps {
|
|
27
|
+
mode: 'cursor';
|
|
28
|
+
pageInfo: PageInfoCursorBased;
|
|
29
|
+
onPageChange: (page: 'next' | 'prev') => void;
|
|
30
|
+
}
|
|
31
|
+
export type PaginationProps = PagePaginationProps | CursorPaginationProps;
|
|
32
|
+
export declare const Pagination: ({ mode, pageInfo, isLoading, onPageSizeChange, subText, onPageChange, testId, }: PaginationProps) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
16
33
|
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Dispatch, MutableRefObject, SetStateAction } from 'react';
|
|
2
|
+
export interface RowAction<T> {
|
|
3
|
+
label: string;
|
|
4
|
+
onClick: (row: T) => void;
|
|
5
|
+
icon?: React.ReactNode;
|
|
6
|
+
disabled?: boolean | ((row: T) => boolean);
|
|
7
|
+
}
|
|
8
|
+
interface RowContextMenuProps<T> {
|
|
9
|
+
anchorRef: MutableRefObject<HTMLElement | null>;
|
|
10
|
+
actions?: RowAction<T>[];
|
|
11
|
+
activeRow: T | null;
|
|
12
|
+
setActiveRow: Dispatch<SetStateAction<T | null>>;
|
|
13
|
+
}
|
|
14
|
+
export declare const RowContextMenu: <T extends object>({ anchorRef, actions, activeRow, setActiveRow, }: RowContextMenuProps<T>) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
15
|
+
export {};
|
package/src/lib/Table/Table.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { HTMLProps } from 'react';
|
|
2
2
|
import { ColumnDef, OnChangeFn, Row } from '@tanstack/react-table';
|
|
3
|
-
import {
|
|
3
|
+
import { PageInfoPageBased, PageInfoCursorBased } from '../Pagination/Pagination';
|
|
4
4
|
export declare const TableContainer: import("@emotion/styled").StyledComponent<Omit<HTMLProps<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement> & {
|
|
5
5
|
theme?: import("@emotion/react").Theme;
|
|
6
6
|
}, {}, {}>;
|
|
@@ -29,7 +29,6 @@ export interface RowAction<T> {
|
|
|
29
29
|
onClick: (row: T) => void;
|
|
30
30
|
icon?: React.ReactNode;
|
|
31
31
|
disabled?: boolean | ((row: T) => boolean);
|
|
32
|
-
show?: (row: T) => boolean;
|
|
33
32
|
}
|
|
34
33
|
interface TableStyleProps {
|
|
35
34
|
dense?: boolean;
|
|
@@ -44,10 +43,11 @@ interface TableRowProps<T> {
|
|
|
44
43
|
contextMenuActions?: RowAction<T>[];
|
|
45
44
|
}
|
|
46
45
|
interface PaginationProps {
|
|
47
|
-
|
|
46
|
+
paginationMode?: 'page' | 'cursor';
|
|
47
|
+
pageInfo?: PageInfoPageBased | PageInfoCursorBased;
|
|
48
48
|
subText?: string;
|
|
49
49
|
onPageSizeChange?: (size: number) => void;
|
|
50
|
-
onPageChange?: (page:
|
|
50
|
+
onPageChange?: (page: any) => void;
|
|
51
51
|
}
|
|
52
52
|
interface TableDataProps<T> {
|
|
53
53
|
columns: TableColumn<T>[];
|
|
@@ -62,5 +62,5 @@ interface TableDataProps<T> {
|
|
|
62
62
|
}
|
|
63
63
|
export interface TableProps<T extends object> extends TableStyleProps, TableRowProps<T>, TableDataProps<T>, PaginationProps {
|
|
64
64
|
}
|
|
65
|
-
export declare const Table: <T extends object>({ columns, data, getRowId, isLoading, pageInfo, subText, onPageSizeChange, onPageChange, sortBy, sortOrder, onSortChange, enableRowSelection, selectedRows, onRowSelectionChange, getRowDisabled, onRowClick, contextMenuActions, dense, height, error, testId, }: TableProps<T>) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
65
|
+
export declare const Table: <T extends object>({ columns, data, getRowId, isLoading, paginationMode, pageInfo, subText, onPageSizeChange, onPageChange, sortBy, sortOrder, onSortChange, enableRowSelection, selectedRows, onRowSelectionChange, getRowDisabled, onRowClick, contextMenuActions, dense, height, error, testId, }: TableProps<T>) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
66
66
|
export {};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Row } from '@tanstack/react-table';
|
|
2
|
-
import { RowAction } from './Table';
|
|
3
|
-
interface ContextMenuCellProps<T extends object> {
|
|
4
|
-
row: Row<T>;
|
|
5
|
-
setOpenMenuId: React.Dispatch<React.SetStateAction<string | null>>;
|
|
6
|
-
openMenuId: string | null;
|
|
7
|
-
contextMenuActions: RowAction<T>[];
|
|
8
|
-
testId?: string;
|
|
9
|
-
}
|
|
10
|
-
export declare const ContextMenuCell: <T extends object>({ row, setOpenMenuId, openMenuId, contextMenuActions, testId, }: ContextMenuCellProps<T>) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
11
|
-
export {};
|