@pk-design/react-tailwind 1.2.0 → 1.4.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/dist/react-tailwind.cjs.js +122 -65
- package/dist/react-tailwind.cjs.js.map +1 -1
- package/dist/react-tailwind.es.js +122 -65
- package/dist/react-tailwind.es.js.map +1 -1
- package/dist/types/components/DataTable/DataTable.d.ts +4 -1
- package/dist/types/components/DataTable/DataTable.types.d.ts +68 -16
- package/dist/types/components/Table/Table.types.d.ts +6 -4
- package/dist/types/components/Tabs/Tabs.types.d.ts +28 -22
- package/dist/types/components/VirtualizedDataTable/VirtualizedDataTable.d.ts +2 -3
- package/dist/types/components/VirtualizedDataTable/VirtualizedDataTable.types.d.ts +31 -7
- package/dist/types/components/VirtualizedDataTable/VirtualizedRow.d.ts +2 -6
- package/package.json +1 -1
|
@@ -1,2 +1,5 @@
|
|
|
1
1
|
import type { DataTableProps } from './DataTable.types';
|
|
2
|
-
export declare
|
|
2
|
+
export declare function DataTable<T extends Record<string, any> = Record<string, any>>({ items, columns, sorting, onSort, loading, pagination, setPagination, emptyMessage, containerClass, wrapperClass, tableClass, headClass, footerRow, rowKey, onRowClick, rowClass, density, striped, layout, }: DataTableProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
export declare namespace DataTable {
|
|
4
|
+
var displayName: string;
|
|
5
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
2
|
import type { TPagination } from '../Pagination';
|
|
3
3
|
/**
|
|
4
|
-
* Allowed column value data types
|
|
5
|
-
* Used only to influence sorting logic
|
|
4
|
+
* Allowed column value data types.
|
|
5
|
+
* Used only to influence sorting logic.
|
|
6
6
|
*/
|
|
7
7
|
export type DataValueType = 'string' | 'number' | 'date';
|
|
8
8
|
/**
|
|
@@ -13,9 +13,15 @@ export type Sorting = 'asc' | 'desc' | '1' | '-1';
|
|
|
13
13
|
export type SortIconKey = Extract<Sorting, 'asc' | 'desc' | '1' | '-1'>;
|
|
14
14
|
export type SortQuery = Record<string, Sorting>;
|
|
15
15
|
/**
|
|
16
|
-
*
|
|
16
|
+
* Cell padding preset.
|
|
17
|
+
* @default 'default'
|
|
17
18
|
*/
|
|
18
|
-
export
|
|
19
|
+
export type DataTableDensity = 'compact' | 'default' | 'spacious';
|
|
20
|
+
/**
|
|
21
|
+
* Column definition for DataTable.
|
|
22
|
+
* @template T Shape of each data row
|
|
23
|
+
*/
|
|
24
|
+
export interface DataTableColumn<T = any> {
|
|
19
25
|
/** Unique key used to extract column data (supports nested paths) */
|
|
20
26
|
name: string;
|
|
21
27
|
/** Display label for the header */
|
|
@@ -25,39 +31,85 @@ export interface DataTableColumn {
|
|
|
25
31
|
/** Text alignment for body cells */
|
|
26
32
|
align?: 'left' | 'center' | 'right';
|
|
27
33
|
/** Custom cell renderer (highest priority) */
|
|
28
|
-
render?: (item:
|
|
34
|
+
render?: (item: T) => ReactNode;
|
|
29
35
|
/** Optional fixed width (px, %, rem) */
|
|
30
36
|
width?: string | number;
|
|
31
37
|
/** Enables sorting when true */
|
|
32
38
|
sortable?: boolean;
|
|
33
|
-
/** Type of cell value
|
|
39
|
+
/** Type of cell value — influences sort logic */
|
|
34
40
|
type?: DataValueType;
|
|
35
|
-
/** Sticks cell to
|
|
41
|
+
/** Sticks cell to the given side on horizontal scroll */
|
|
36
42
|
sticky?: 'left' | 'right';
|
|
43
|
+
/** Extra classes applied to the header cell (`<th>`) for this column */
|
|
44
|
+
headerClass?: string;
|
|
45
|
+
/**
|
|
46
|
+
* Extra classes applied to each body cell (`<td>`) for this column.
|
|
47
|
+
* Pass a function to vary styles per row value.
|
|
48
|
+
* @example cellClass={(item) => item.status === 'error' ? 'text-red-600' : ''}
|
|
49
|
+
*/
|
|
50
|
+
cellClass?: string | ((item: T) => string);
|
|
37
51
|
}
|
|
38
52
|
/**
|
|
39
53
|
* DataTable props
|
|
54
|
+
* @template T Shape of each data row
|
|
40
55
|
*/
|
|
41
|
-
export interface DataTableProps {
|
|
56
|
+
export interface DataTableProps<T = any> {
|
|
42
57
|
/** Array of data items */
|
|
43
|
-
items:
|
|
58
|
+
items: T[];
|
|
44
59
|
/** Column definitions */
|
|
45
|
-
columns: DataTableColumn[];
|
|
60
|
+
columns: DataTableColumn<T>[];
|
|
46
61
|
/** Sorting state, keyed by column name */
|
|
47
62
|
sorting?: Record<string, Sorting>;
|
|
48
|
-
/** Loading state
|
|
63
|
+
/** Loading state — shows skeleton rows instead of data */
|
|
49
64
|
loading?: boolean;
|
|
50
65
|
/** Pagination config */
|
|
51
66
|
pagination?: TPagination;
|
|
52
|
-
/**
|
|
67
|
+
/** Message or node shown when the items array is empty */
|
|
53
68
|
emptyMessage?: ReactNode;
|
|
54
|
-
/** External sorting handler */
|
|
55
|
-
onSort?: (column: DataTableColumn) => void;
|
|
69
|
+
/** External sorting handler. When omitted, DataTable auto-sorts internally. */
|
|
70
|
+
onSort?: (column: DataTableColumn<T>) => void;
|
|
56
71
|
/** Pagination setter */
|
|
57
72
|
setPagination?: (pagination: Partial<TPagination>) => void;
|
|
58
|
-
/**
|
|
73
|
+
/** Table layout algorithm */
|
|
59
74
|
layout?: 'fixed' | 'auto';
|
|
60
|
-
/**
|
|
75
|
+
/**
|
|
76
|
+
* Determines the stable React key for each row.
|
|
77
|
+
* Pass a field name string or a function returning a unique value.
|
|
78
|
+
* @default 'id'
|
|
79
|
+
*/
|
|
80
|
+
rowKey?: string | ((item: T) => string | number);
|
|
81
|
+
/**
|
|
82
|
+
* Callback fired when a row is clicked.
|
|
83
|
+
* Rows become visually interactive (pointer cursor) when this is set.
|
|
84
|
+
*/
|
|
85
|
+
onRowClick?: (item: T, index: number) => void;
|
|
86
|
+
/**
|
|
87
|
+
* Extra class(es) applied to each `<tr>` in the body.
|
|
88
|
+
* Pass a function to vary classes per row.
|
|
89
|
+
* @example rowClass={(item, i) => item.active ? 'font-semibold' : ''}
|
|
90
|
+
*/
|
|
91
|
+
rowClass?: string | ((item: T, index: number) => string);
|
|
92
|
+
/**
|
|
93
|
+
* Cell padding preset.
|
|
94
|
+
* @default 'default'
|
|
95
|
+
*/
|
|
96
|
+
density?: DataTableDensity;
|
|
97
|
+
/**
|
|
98
|
+
* Applies an alternating background to odd-indexed rows.
|
|
99
|
+
* @default false
|
|
100
|
+
*/
|
|
101
|
+
striped?: boolean;
|
|
102
|
+
/**
|
|
103
|
+
* Node(s) rendered inside `<tfoot><tr>` as a summary or totals row.
|
|
104
|
+
* Should be a set of `<td>` elements matching the column count.
|
|
105
|
+
*/
|
|
106
|
+
footerRow?: ReactNode;
|
|
107
|
+
/** Optional classes applied to the outer container div */
|
|
61
108
|
containerClass?: string;
|
|
109
|
+
/** Optional classes applied to the scroll wrapper div */
|
|
62
110
|
wrapperClass?: string;
|
|
111
|
+
/** Optional classes applied directly to the `<table>` element */
|
|
112
|
+
tableClass?: string;
|
|
113
|
+
/** Optional classes applied to the `<thead>` element */
|
|
114
|
+
headClass?: string;
|
|
63
115
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { HTMLAttributes, ReactNode, TdHTMLAttributes
|
|
1
|
+
import type { HTMLAttributes, ReactNode, TdHTMLAttributes } from 'react';
|
|
2
2
|
/**
|
|
3
3
|
* Root <Table /> props.
|
|
4
4
|
*/
|
|
@@ -11,6 +11,8 @@ export interface TableProps {
|
|
|
11
11
|
className?: string;
|
|
12
12
|
/** Table content (Head + Body + Foot) */
|
|
13
13
|
children: ReactNode;
|
|
14
|
+
/** Accessible caption rendered as a <caption> element above the header */
|
|
15
|
+
caption?: ReactNode;
|
|
14
16
|
}
|
|
15
17
|
/**
|
|
16
18
|
* <TableHead /> — table header section
|
|
@@ -29,8 +31,8 @@ export interface TableBodyProps {
|
|
|
29
31
|
className?: string;
|
|
30
32
|
/** Show loading shimmer (overrides children) */
|
|
31
33
|
loading?: boolean;
|
|
32
|
-
/** Number of columns — needed for shimmer loader layout */
|
|
33
|
-
colSize
|
|
34
|
+
/** Number of columns — needed for shimmer loader layout. Defaults to 1 when not provided. */
|
|
35
|
+
colSize?: number;
|
|
34
36
|
/** Number of shimmer rows to show when loading */
|
|
35
37
|
rowSize?: number;
|
|
36
38
|
/** Actual table rows */
|
|
@@ -67,7 +69,7 @@ export interface TableCellProps extends TdHTMLAttributes<HTMLTableCellElement> {
|
|
|
67
69
|
/**
|
|
68
70
|
* <TableRow /> — regular row
|
|
69
71
|
*/
|
|
70
|
-
export interface TableRowProps extends
|
|
72
|
+
export interface TableRowProps extends HTMLAttributes<HTMLTableRowElement> {
|
|
71
73
|
/** Whether the row highlights on hover */
|
|
72
74
|
hoverable?: boolean;
|
|
73
75
|
}
|
|
@@ -7,42 +7,48 @@ export type TabsItem = {
|
|
|
7
7
|
label: ReactNode;
|
|
8
8
|
/** Content rendered inside the TabPanel for this tab */
|
|
9
9
|
content: ReactNode;
|
|
10
|
-
/** Optional icon
|
|
10
|
+
/** Optional icon rendered before the label */
|
|
11
11
|
icon?: ReactNode;
|
|
12
|
-
/**
|
|
12
|
+
/** Unique key for this tab; falls back to index when omitted */
|
|
13
13
|
id?: string | number;
|
|
14
|
+
/** Prevents this tab from being selected */
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
/** Extra classes applied to this specific tab button */
|
|
17
|
+
tabClass?: string;
|
|
18
|
+
/** Override the default panel className for this specific tab */
|
|
19
|
+
panelClass?: string;
|
|
14
20
|
};
|
|
15
21
|
/**
|
|
16
22
|
* Tabs component props
|
|
17
23
|
*/
|
|
18
24
|
export interface TabsProps {
|
|
19
|
-
/**
|
|
20
|
-
* Tabs data (label + panel). Order defines visual order.
|
|
21
|
-
*/
|
|
25
|
+
/** Tab data array. Order defines visual order. */
|
|
22
26
|
tabs: TabsItem[];
|
|
23
27
|
/**
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
* - "
|
|
28
|
-
* - "segmented": segmented pill style where selected tab looks like a pill
|
|
29
|
-
* - "solid": solid nav tabs (selected tab has solid background)
|
|
28
|
+
* Visual style of the tab list.
|
|
29
|
+
* - "underline" (default): active tab shows a bottom indicator line
|
|
30
|
+
* - "segmented": active tab renders as a filled pill
|
|
31
|
+
* - "solid": active tab renders with a solid block background
|
|
30
32
|
*/
|
|
31
33
|
variant?: 'underline' | 'segmented' | 'solid';
|
|
32
|
-
/**
|
|
33
|
-
* Starting tab index (controlled by TabGroup defaultIndex)
|
|
34
|
-
*/
|
|
34
|
+
/** Initial selected index (uncontrolled) */
|
|
35
35
|
defaultIndex?: number;
|
|
36
|
+
/** Controlled selected index — pair with onChange */
|
|
37
|
+
selectedIndex?: number;
|
|
38
|
+
/** Called with the new index whenever the selected tab changes */
|
|
39
|
+
onChange?: (index: number) => void;
|
|
36
40
|
/**
|
|
37
|
-
*
|
|
41
|
+
* Layout direction of the tab list.
|
|
42
|
+
* - "horizontal" (default): tabs sit in a row above the panel
|
|
43
|
+
* - "vertical": tabs sit in a column to the left of the panel
|
|
38
44
|
*/
|
|
45
|
+
orientation?: 'horizontal' | 'vertical';
|
|
46
|
+
/** Stretch tabs to fill equal width across the tab list (horizontal only) */
|
|
47
|
+
stretch?: boolean;
|
|
48
|
+
/** Extra classes for the outer TabGroup container */
|
|
39
49
|
className?: string;
|
|
40
|
-
/**
|
|
41
|
-
* Extra classes to apply to the TabList wrapper
|
|
42
|
-
*/
|
|
50
|
+
/** Extra classes for the TabList wrapper */
|
|
43
51
|
listClass?: string;
|
|
44
|
-
/**
|
|
45
|
-
|
|
46
|
-
*/
|
|
47
|
-
panelClass?: string;
|
|
52
|
+
/** Extra classes for the TabPanels wrapper */
|
|
53
|
+
panelsClass?: string;
|
|
48
54
|
}
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
export declare const VirtualizedDataTable: React.FC<VirtualizedDataTableProps>;
|
|
1
|
+
import type { VirtualizedDataTableProps } from './VirtualizedDataTable.types';
|
|
2
|
+
export declare function VirtualizedDataTable<T extends Record<string, any> = Record<string, any>>({ items, columns, sorting, onSort, loading, emptyMessage, containerClass, wrapperClass, onRowClick, rowClass, density, striped, rowHeight, maxHeight, overscanCount, }: VirtualizedDataTableProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,18 +1,42 @@
|
|
|
1
|
-
import { DataTableColumn, DataTableProps } from '../DataTable';
|
|
1
|
+
import type { DataTableColumn, DataTableDensity, DataTableProps } from '../DataTable';
|
|
2
2
|
/**
|
|
3
|
-
* Props
|
|
3
|
+
* Props shared with DataTable but not applicable to virtualized tables are omitted:
|
|
4
|
+
* pagination, setPagination, layout, footerRow, rowKey, tableClass, headClass.
|
|
4
5
|
*/
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
type VirtualizedBase<T = any> = Omit<DataTableProps<T>, 'pagination' | 'setPagination' | 'layout' | 'footerRow' | 'rowKey' | 'tableClass' | 'headClass'>;
|
|
7
|
+
/**
|
|
8
|
+
* Props for VirtualizedDataTable.
|
|
9
|
+
* @template T Shape of each data row
|
|
10
|
+
*/
|
|
11
|
+
export interface VirtualizedDataTableProps<T = any> extends VirtualizedBase<T> {
|
|
12
|
+
/** Height of each row in pixels. Required for react-window's fixed-size virtualization.
|
|
13
|
+
* @default 48
|
|
14
|
+
*/
|
|
7
15
|
rowHeight?: number;
|
|
8
|
-
/**
|
|
16
|
+
/** Maximum height of the scrollable body in pixels.
|
|
17
|
+
* @default 400
|
|
18
|
+
*/
|
|
9
19
|
maxHeight?: number;
|
|
20
|
+
/**
|
|
21
|
+
* Number of extra rows rendered outside the visible area.
|
|
22
|
+
* Higher values reduce blank flicker during fast scrolling at the cost of more DOM nodes.
|
|
23
|
+
* Maps directly to react-window's overscanCount.
|
|
24
|
+
* @default 3
|
|
25
|
+
*/
|
|
26
|
+
overscanCount?: number;
|
|
10
27
|
}
|
|
11
28
|
/**
|
|
12
|
-
*
|
|
13
|
-
*
|
|
29
|
+
* Data object passed to each virtualized row via react-window's itemData.
|
|
30
|
+
* Items and columns use any internally because react-window's generic inference
|
|
31
|
+
* does not flow through to ComponentType children.
|
|
14
32
|
*/
|
|
15
33
|
export type VirtualizedRowProps = {
|
|
16
34
|
items: any[];
|
|
17
35
|
columns: DataTableColumn[];
|
|
36
|
+
gridTemplate: string;
|
|
37
|
+
onRowClick?: (item: any, index: number) => void;
|
|
38
|
+
rowClass?: string | ((item: any, index: number) => string);
|
|
39
|
+
density?: DataTableDensity;
|
|
40
|
+
striped?: boolean;
|
|
18
41
|
};
|
|
42
|
+
export {};
|
|
@@ -1,7 +1,3 @@
|
|
|
1
1
|
import { ListChildComponentProps } from 'react-window';
|
|
2
|
-
import { VirtualizedRowProps } from './VirtualizedDataTable.types';
|
|
3
|
-
|
|
4
|
-
gridTemplate: string;
|
|
5
|
-
}
|
|
6
|
-
export declare const VirtualizedRow: ({ index, style, data }: ListChildComponentProps<RowData>) => import("react/jsx-runtime").JSX.Element;
|
|
7
|
-
export {};
|
|
2
|
+
import type { VirtualizedRowProps } from './VirtualizedDataTable.types';
|
|
3
|
+
export declare const VirtualizedRow: ({ index, style, data, }: ListChildComponentProps<VirtualizedRowProps>) => import("react/jsx-runtime").JSX.Element;
|