@ztwoint/z-ui 0.1.139 → 0.1.141
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/components/kpi-card/kpi-card.d.ts +3 -3
- package/dist/components/kpi-card/kpi-card.js +4 -4
- package/dist/components/primitives/table-card/Architecture.md +217 -0
- package/dist/components/table/Architecture.md +304 -0
- package/dist/components/table-filter/Architecture.md +284 -0
- package/dist/components/table-filter/table-filter-button.js +114 -105
- package/dist/components/table-filter/table-filter-column-button.js +69 -69
- package/dist/types/components/kpi-card/kpi-card.d.ts +3 -3
- package/package.json +1 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
2
|
declare const kpiCardVariants: (props?: ({
|
|
3
3
|
active?: boolean | null | undefined;
|
|
4
4
|
} & import('class-variance-authority/dist/types').ClassProp) | undefined) => string;
|
|
5
5
|
export interface KpiCardProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'title'> {
|
|
6
6
|
titleText?: string;
|
|
7
7
|
subtitleText?: string;
|
|
8
|
-
bottomText?: string;
|
|
8
|
+
bottomText?: string | ReactNode;
|
|
9
9
|
/** Whether the card is in an active/selected state */
|
|
10
10
|
active?: boolean;
|
|
11
11
|
/** React node to render in the top-right corner (e.g., action buttons) */
|
|
@@ -13,5 +13,5 @@ export interface KpiCardProps extends Omit<React.ButtonHTMLAttributes<HTMLButton
|
|
|
13
13
|
/** React node to render in the bottom-right corner (e.g., an icon) */
|
|
14
14
|
bottomRightIcon?: React.ReactNode;
|
|
15
15
|
}
|
|
16
|
-
declare const KpiCard:
|
|
16
|
+
declare const KpiCard: import('react').ForwardRefExoticComponent<KpiCardProps & import('react').RefAttributes<HTMLButtonElement>>;
|
|
17
17
|
export { KpiCard, kpiCardVariants };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsxs as r, jsx as e } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
2
|
+
import { cva as m } from "class-variance-authority";
|
|
3
|
+
import { forwardRef as p } from "react";
|
|
4
4
|
import { cn as f } from "../../lib/utils.js";
|
|
5
|
-
const x =
|
|
5
|
+
const x = m(
|
|
6
6
|
[
|
|
7
7
|
"flex flex-col gap-2 items-start overflow-clip text-left",
|
|
8
8
|
"px-3.5 py-3.5 rounded-xl border border-stroke-solid-high",
|
|
@@ -22,7 +22,7 @@ const x = p(
|
|
|
22
22
|
active: !1
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
|
-
), u =
|
|
25
|
+
), u = p(
|
|
26
26
|
({
|
|
27
27
|
className: t,
|
|
28
28
|
titleText: i = "Title Text",
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
# TableCard Architecture
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
|
|
5
|
+
`TableCard` is a high-level composite component that orchestrates the `Table` and `Filter` components to provide a complete data display solution with:
|
|
6
|
+
- Search functionality
|
|
7
|
+
- Advanced filtering
|
|
8
|
+
- Pagination with info and quick jumper
|
|
9
|
+
- Configurable table body with sorting
|
|
10
|
+
- Loading and error states
|
|
11
|
+
- Customizable header and footer sections
|
|
12
|
+
|
|
13
|
+
## File Structure
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
src/components/primitives/table-card/
|
|
17
|
+
├── index.ts # Public exports
|
|
18
|
+
├── table-card.tsx # Main component implementation
|
|
19
|
+
├── table-card.type.ts # TypeScript interfaces
|
|
20
|
+
├── table-card.stories.tsx # Storybook stories
|
|
21
|
+
└── Architecture.md # This file
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Component Hierarchy
|
|
25
|
+
|
|
26
|
+
```mermaid
|
|
27
|
+
flowchart TD
|
|
28
|
+
TableCard["TableCard"]
|
|
29
|
+
|
|
30
|
+
subgraph TableWrapper [Table Provider]
|
|
31
|
+
Table["Table"]
|
|
32
|
+
TableHeader["Table.Header"]
|
|
33
|
+
TableHeaderContent["Table.HeaderContent"]
|
|
34
|
+
TableSearch["Table.Search"]
|
|
35
|
+
TableBody["Table.Body"]
|
|
36
|
+
TableFooter["Table.Footer"]
|
|
37
|
+
TableFooterContent["Table.FooterContent"]
|
|
38
|
+
TablePagination["Table.Pagination"]
|
|
39
|
+
TablePaginationInfo["Table.PaginationInfo"]
|
|
40
|
+
TablePaginationQuickJumper["Table.PaginationQuickJumper"]
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
subgraph FilterWrapper [Filter Provider]
|
|
44
|
+
Filter["Filter"]
|
|
45
|
+
FilterButton["Filter.FilterButton"]
|
|
46
|
+
FilterColumnButton["Filter.FilterColumnButton"]
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
TableCard --> Table
|
|
50
|
+
Table --> TableHeader
|
|
51
|
+
TableHeader --> TableHeaderContent
|
|
52
|
+
TableHeaderContent --> TableSearch
|
|
53
|
+
TableHeaderContent --> Filter
|
|
54
|
+
Filter --> FilterButton
|
|
55
|
+
Filter --> FilterColumnButton
|
|
56
|
+
Table --> TableBody
|
|
57
|
+
Table --> TableFooter
|
|
58
|
+
TableFooter --> TableFooterContent
|
|
59
|
+
TableFooterContent --> TablePaginationInfo
|
|
60
|
+
TableFooterContent --> TablePaginationQuickJumper
|
|
61
|
+
TableFooterContent --> TablePagination
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Data Flow
|
|
65
|
+
|
|
66
|
+
```mermaid
|
|
67
|
+
flowchart LR
|
|
68
|
+
subgraph ExternalProps [External Props]
|
|
69
|
+
dataSource["dataSource"]
|
|
70
|
+
schema["schema"]
|
|
71
|
+
searchProps["search"]
|
|
72
|
+
filterProps["filter"]
|
|
73
|
+
paginationProps["pagination"]
|
|
74
|
+
bodyProps["body"]
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
subgraph TableCard [TableCard Component]
|
|
78
|
+
renderLogic["Render Logic"]
|
|
79
|
+
errorState["Error State"]
|
|
80
|
+
loadingOverlay["Loading Overlay"]
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
subgraph TableContext [Table Context]
|
|
84
|
+
tableData["dataSource, schema"]
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
subgraph FilterContext [Filter Context]
|
|
88
|
+
filterData["filterSchema, filter values"]
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
ExternalProps --> TableCard
|
|
92
|
+
TableCard --> TableContext
|
|
93
|
+
TableCard --> FilterContext
|
|
94
|
+
TableCard --> errorState
|
|
95
|
+
TableCard --> loadingOverlay
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Key Interfaces
|
|
99
|
+
|
|
100
|
+
### TableCardProps
|
|
101
|
+
|
|
102
|
+
```typescript
|
|
103
|
+
interface TableCardProps {
|
|
104
|
+
// Core table props
|
|
105
|
+
dataSource: Record<string, unknown>[];
|
|
106
|
+
schema: TableSchema;
|
|
107
|
+
|
|
108
|
+
// Layout props
|
|
109
|
+
className?: string;
|
|
110
|
+
rounded?: boolean;
|
|
111
|
+
bordered?: boolean;
|
|
112
|
+
|
|
113
|
+
// Header section
|
|
114
|
+
showHeader?: boolean;
|
|
115
|
+
headerClassName?: string;
|
|
116
|
+
search?: Partial<TableSearch> & { className?: string };
|
|
117
|
+
filter?: Partial<TableFilter> & {
|
|
118
|
+
quickFilters?: string[];
|
|
119
|
+
showFilterButton?: boolean;
|
|
120
|
+
filterSchema: FilterSchema;
|
|
121
|
+
onFilterClick?: (filters: FilterRule[], selectedColumn: string) => void;
|
|
122
|
+
};
|
|
123
|
+
headerLeftContent?: React.ReactNode;
|
|
124
|
+
headerActions?: React.ReactNode;
|
|
125
|
+
|
|
126
|
+
// Body section
|
|
127
|
+
body?: {
|
|
128
|
+
cell?: TableProps['cell'];
|
|
129
|
+
sort?: TableSort;
|
|
130
|
+
className?: string;
|
|
131
|
+
stickyHeader?: boolean;
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
// Footer section
|
|
135
|
+
showFooter?: boolean;
|
|
136
|
+
footerClassName?: string;
|
|
137
|
+
pagination?: PaginationProps;
|
|
138
|
+
paginationInfo?: PaginationInfoProps;
|
|
139
|
+
paginationQuickJumper?: PaginationQuickJumperProps;
|
|
140
|
+
|
|
141
|
+
// State props
|
|
142
|
+
loading?: boolean;
|
|
143
|
+
emptyMessage?: string;
|
|
144
|
+
dataSourceError?: boolean | string;
|
|
145
|
+
error?: boolean | string;
|
|
146
|
+
}
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
## Component Sections
|
|
150
|
+
|
|
151
|
+
### 1. Error State
|
|
152
|
+
When `error` prop is truthy, renders error UI instead of the table.
|
|
153
|
+
|
|
154
|
+
### 2. Header Section
|
|
155
|
+
Conditionally rendered when `showHeader=true` and has content:
|
|
156
|
+
- `headerLeftContent` - Custom left content
|
|
157
|
+
- `Table.Search` - Search input
|
|
158
|
+
- `Filter` - Filter system with FilterButton and quick filter buttons
|
|
159
|
+
- `headerActions` - Custom action buttons
|
|
160
|
+
|
|
161
|
+
### 3. Body Section
|
|
162
|
+
`Table.Body` renders the actual table with:
|
|
163
|
+
- TableHeader (column headers with optional sorting)
|
|
164
|
+
- TableRow (data rows)
|
|
165
|
+
- Empty/Error message states
|
|
166
|
+
|
|
167
|
+
### 4. Footer Section
|
|
168
|
+
Conditionally rendered when `showFooter=true` and has content:
|
|
169
|
+
- `Table.PaginationInfo` - "Showing X-Y of Z" text
|
|
170
|
+
- `Table.PaginationQuickJumper` - Go to page input
|
|
171
|
+
- `Table.Pagination` - Page navigation buttons
|
|
172
|
+
|
|
173
|
+
### 5. Loading Overlay
|
|
174
|
+
Absolute positioned overlay shown when `loading=true`.
|
|
175
|
+
|
|
176
|
+
## Subcomponent Architecture References
|
|
177
|
+
|
|
178
|
+
- **Table Component**: [src/components/table/Architecture.md](../../table/Architecture.md)
|
|
179
|
+
- **Filter Component**: [src/components/table-filter/Architecture.md](../../table-filter/Architecture.md)
|
|
180
|
+
|
|
181
|
+
## Usage Example
|
|
182
|
+
|
|
183
|
+
```tsx
|
|
184
|
+
<TableCard
|
|
185
|
+
dataSource={data}
|
|
186
|
+
schema={[
|
|
187
|
+
{ key: 'name', title: 'Name', cellType: 'text' },
|
|
188
|
+
{ key: 'amount', title: 'Amount', cellType: 'number' },
|
|
189
|
+
]}
|
|
190
|
+
search={{
|
|
191
|
+
value: searchValue,
|
|
192
|
+
onChange: setSearchValue,
|
|
193
|
+
placeholder: 'Search...',
|
|
194
|
+
}}
|
|
195
|
+
filter={{
|
|
196
|
+
filterSchema: [
|
|
197
|
+
{ filterKey: 'status', title: 'Status', type: 'checkbox', options: { Active: 10, Inactive: 5 } },
|
|
198
|
+
],
|
|
199
|
+
value: filters,
|
|
200
|
+
onChange: setFilters,
|
|
201
|
+
quickFilters: ['status'],
|
|
202
|
+
}}
|
|
203
|
+
pagination={{
|
|
204
|
+
currentPage: 1,
|
|
205
|
+
totalPage: 10,
|
|
206
|
+
onChange: setPage,
|
|
207
|
+
}}
|
|
208
|
+
loading={isLoading}
|
|
209
|
+
/>
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
## Dependencies
|
|
213
|
+
|
|
214
|
+
- `Table` from `../../table`
|
|
215
|
+
- `Filter` from `../../table-filter`
|
|
216
|
+
- `cn` utility from `../../../lib`
|
|
217
|
+
- `OctagonWarningCopy` icon for error state
|
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
# Table Architecture
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
|
|
5
|
+
The `Table` component is a compound component that provides a flexible and composable table system. It uses React Context to share state between its sub-components and follows the compound component pattern for maximum flexibility.
|
|
6
|
+
|
|
7
|
+
## File Structure
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
src/components/table/
|
|
11
|
+
├── index.ts # Public exports
|
|
12
|
+
├── table-provider.tsx # Main provider and compound component setup
|
|
13
|
+
├── table.tsx # TableBody implementation
|
|
14
|
+
├── table.context.ts # React Context definition
|
|
15
|
+
├── table.type.ts # TypeScript interfaces
|
|
16
|
+
├── table.const.ts # CSS classes and constants
|
|
17
|
+
├── table.utils.ts # Utility functions
|
|
18
|
+
├── table.stories.tsx # Storybook stories
|
|
19
|
+
├── Architecture.md # This file
|
|
20
|
+
└── components/
|
|
21
|
+
├── index.ts # Component exports
|
|
22
|
+
├── table-cell.tsx # Individual cell renderer
|
|
23
|
+
├── table-row.tsx # Row renderer
|
|
24
|
+
├── table-header-wrapper.tsx # Header container
|
|
25
|
+
├── table-header-content.tsx # Header content wrapper
|
|
26
|
+
├── table-footer.tsx # Footer container
|
|
27
|
+
├── table-footer-content.tsx # Footer content wrapper
|
|
28
|
+
├── table-message-state.tsx # Empty/Error state display
|
|
29
|
+
├── table-loading-state.tsx # Loading state display
|
|
30
|
+
├── table-header/ # Column header components
|
|
31
|
+
│ ├── index.ts
|
|
32
|
+
│ ├── table-header.tsx # Column headers with sorting
|
|
33
|
+
│ ├── table-header.utils.ts
|
|
34
|
+
│ └── table-sort-icon.tsx
|
|
35
|
+
├── table-search/ # Search component
|
|
36
|
+
│ ├── index.ts
|
|
37
|
+
│ └── table-search.tsx
|
|
38
|
+
├── pagination/ # Pagination components
|
|
39
|
+
│ ├── index.ts
|
|
40
|
+
│ ├── pagination.tsx
|
|
41
|
+
│ ├── pagination.hook.ts
|
|
42
|
+
│ ├── pagination.type.ts
|
|
43
|
+
│ ├── pagination.const.ts
|
|
44
|
+
│ ├── pagination.utils.ts
|
|
45
|
+
│ └── components/
|
|
46
|
+
│ ├── index.ts
|
|
47
|
+
│ ├── pagination-info.tsx
|
|
48
|
+
│ ├── pagination-quick-jumper.tsx
|
|
49
|
+
│ └── pagination-quick-jumper.hook.ts
|
|
50
|
+
└── cell/ # Cell type renderers
|
|
51
|
+
├── index.ts
|
|
52
|
+
├── number-cell.tsx
|
|
53
|
+
├── boolean-cell.tsx
|
|
54
|
+
├── link-cell.tsx
|
|
55
|
+
├── avatar-cell.tsx
|
|
56
|
+
├── label-cell.tsx
|
|
57
|
+
└── description-cell.tsx
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Component Hierarchy
|
|
61
|
+
|
|
62
|
+
```mermaid
|
|
63
|
+
flowchart TD
|
|
64
|
+
TableProvider["Table (TableProvider)"]
|
|
65
|
+
|
|
66
|
+
subgraph CompoundComponents [Compound Components]
|
|
67
|
+
TableBody["Table.Body"]
|
|
68
|
+
TableHeader["Table.Header (wrapper)"]
|
|
69
|
+
TableHeaderContent["Table.HeaderContent"]
|
|
70
|
+
TableSearch["Table.Search"]
|
|
71
|
+
TableFooter["Table.Footer"]
|
|
72
|
+
TableFooterContent["Table.FooterContent"]
|
|
73
|
+
TablePagination["Table.Pagination"]
|
|
74
|
+
TablePaginationInfo["Table.PaginationInfo"]
|
|
75
|
+
TablePaginationQuickJumper["Table.PaginationQuickJumper"]
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
subgraph BodyInternals [Table.Body Internals]
|
|
79
|
+
InternalHeader["TableHeader (columns)"]
|
|
80
|
+
TableRow["TableRow"]
|
|
81
|
+
TableCell["TableCell"]
|
|
82
|
+
TableMessageState["TableMessageState"]
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
subgraph CellTypes [Cell Type Renderers]
|
|
86
|
+
NumberCell["NumberCell"]
|
|
87
|
+
BooleanCell["BooleanCell"]
|
|
88
|
+
LinkCell["LinkCell"]
|
|
89
|
+
AvatarCell["AvatarCell"]
|
|
90
|
+
LabelCell["LabelCell"]
|
|
91
|
+
DescriptionCell["DescriptionCell"]
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
TableProvider --> CompoundComponents
|
|
95
|
+
TableBody --> BodyInternals
|
|
96
|
+
TableRow --> TableCell
|
|
97
|
+
TableCell --> CellTypes
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## Compound Component Pattern
|
|
101
|
+
|
|
102
|
+
The Table uses a compound component pattern where sub-components are attached to the main component:
|
|
103
|
+
|
|
104
|
+
```typescript
|
|
105
|
+
interface TableCompoundComponent extends React.FC<TableProviderProps> {
|
|
106
|
+
Body: typeof TableBody;
|
|
107
|
+
Search: typeof TableSearch;
|
|
108
|
+
Pagination: typeof Pagination;
|
|
109
|
+
PaginationInfo: typeof PaginationInfo;
|
|
110
|
+
PaginationQuickJumper: typeof PaginationQuickJumper;
|
|
111
|
+
Provider: typeof TableProvider;
|
|
112
|
+
Header: typeof TableHeaderWrapper;
|
|
113
|
+
HeaderContent: typeof TableHeaderContent;
|
|
114
|
+
Footer: typeof TableFooter;
|
|
115
|
+
FooterContent: typeof TableFooterContent;
|
|
116
|
+
}
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
## Data Flow
|
|
120
|
+
|
|
121
|
+
```mermaid
|
|
122
|
+
flowchart TD
|
|
123
|
+
subgraph Props [Table Props]
|
|
124
|
+
dataSource["dataSource"]
|
|
125
|
+
schema["schema"]
|
|
126
|
+
loading["loading"]
|
|
127
|
+
emptyMessage["emptyMessage"]
|
|
128
|
+
customCells["customCells"]
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
subgraph Context [TableContext]
|
|
132
|
+
contextValue["TableContextValue"]
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
subgraph Body [Table.Body]
|
|
136
|
+
renderLogic["Render Logic"]
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
subgraph Rendering [Render Output]
|
|
140
|
+
header["TableHeader (columns)"]
|
|
141
|
+
rows["TableRow[]"]
|
|
142
|
+
cells["TableCell[]"]
|
|
143
|
+
emptyState["TableMessageState"]
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
Props --> Context
|
|
147
|
+
Context --> Body
|
|
148
|
+
Body --> renderLogic
|
|
149
|
+
renderLogic -->|"dataSource.length > 0"| rows
|
|
150
|
+
renderLogic -->|"dataSource.length === 0"| emptyState
|
|
151
|
+
rows --> cells
|
|
152
|
+
Body --> header
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
## Key Interfaces
|
|
156
|
+
|
|
157
|
+
### TableProps
|
|
158
|
+
|
|
159
|
+
```typescript
|
|
160
|
+
type TableProps = {
|
|
161
|
+
cell?: {
|
|
162
|
+
hasBorder?: boolean;
|
|
163
|
+
};
|
|
164
|
+
dataSource: Record<string, unknown>[];
|
|
165
|
+
schema: TableSchema;
|
|
166
|
+
loading?: boolean;
|
|
167
|
+
emptyMessage?: string;
|
|
168
|
+
pagination?: TablePaginationConfig;
|
|
169
|
+
sort?: TableSort;
|
|
170
|
+
customCells?: Record<string, CellRenderer>;
|
|
171
|
+
};
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
### TableSchema
|
|
175
|
+
|
|
176
|
+
```typescript
|
|
177
|
+
type TableSchemaColumn = {
|
|
178
|
+
key: string;
|
|
179
|
+
title: string | React.ReactNode;
|
|
180
|
+
cellType: CellType; // 'number' | 'boolean' | 'checkbox' | 'link' | 'avatar' | 'label' | 'description' | 'text'
|
|
181
|
+
cellRenderer?: CellRenderer;
|
|
182
|
+
hideable?: boolean;
|
|
183
|
+
sortable?: boolean;
|
|
184
|
+
valueGetter?: (record: Record<string, unknown>) => CellValue | CellProps;
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
type TableSchema = TableSchemaColumn[];
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
### TableSort
|
|
191
|
+
|
|
192
|
+
```typescript
|
|
193
|
+
type SortDirection = 'asc' | 'desc' | null;
|
|
194
|
+
|
|
195
|
+
type SortColumn = {
|
|
196
|
+
field: string;
|
|
197
|
+
direction: SortDirection;
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
type TableSort = {
|
|
201
|
+
sortedColumns: SortColumn[];
|
|
202
|
+
onSort: (field: string, direction: SortDirection) => void;
|
|
203
|
+
};
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
### TableContextValue
|
|
207
|
+
|
|
208
|
+
```typescript
|
|
209
|
+
interface TableContextValue extends TableProps {
|
|
210
|
+
updateSort?: (sort: TableProps['sort']) => void;
|
|
211
|
+
}
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
## Sub-Components
|
|
215
|
+
|
|
216
|
+
### Table.Body (TableBody)
|
|
217
|
+
Main table rendering component that:
|
|
218
|
+
- Reads from TableContext
|
|
219
|
+
- Renders TableHeader (column headers)
|
|
220
|
+
- Maps dataSource to TableRow components
|
|
221
|
+
- Shows TableMessageState for empty/error states
|
|
222
|
+
- Handles loading overlay
|
|
223
|
+
|
|
224
|
+
### Table.Header (TableHeaderWrapper)
|
|
225
|
+
Container for header content with flex layout and styling.
|
|
226
|
+
|
|
227
|
+
### Table.HeaderContent (TableHeaderContent)
|
|
228
|
+
Wrapper for groups of header items (search, filters, actions).
|
|
229
|
+
|
|
230
|
+
### Table.Search (TableSearch)
|
|
231
|
+
Input component with magnifier icon for search functionality.
|
|
232
|
+
|
|
233
|
+
### Table.Footer (TableFooter)
|
|
234
|
+
Container for footer content with flex layout.
|
|
235
|
+
|
|
236
|
+
### Table.FooterContent (TableFooterContent)
|
|
237
|
+
Wrapper for groups of footer items.
|
|
238
|
+
|
|
239
|
+
### Table.Pagination (Pagination)
|
|
240
|
+
Page navigation with first/prev/next/last buttons and page numbers.
|
|
241
|
+
|
|
242
|
+
### Table.PaginationInfo (PaginationInfo)
|
|
243
|
+
Displays "Showing X-Y of Z" information.
|
|
244
|
+
|
|
245
|
+
### Table.PaginationQuickJumper (PaginationQuickJumper)
|
|
246
|
+
Input for jumping directly to a specific page.
|
|
247
|
+
|
|
248
|
+
## Cell Type Renderers
|
|
249
|
+
|
|
250
|
+
| Cell Type | Component | Description |
|
|
251
|
+
|-----------|-----------|-------------|
|
|
252
|
+
| `text` | LabelCell | Plain text display |
|
|
253
|
+
| `number` | NumberCell | Formatted number display |
|
|
254
|
+
| `boolean` | BooleanCell | Boolean indicator |
|
|
255
|
+
| `checkbox` | BooleanCell | Checkbox-style boolean |
|
|
256
|
+
| `link` | LinkCell | Clickable link |
|
|
257
|
+
| `avatar` | AvatarCell | Avatar image with optional text |
|
|
258
|
+
| `label` | LabelCell | Styled label text |
|
|
259
|
+
| `description` | DescriptionCell | Multi-line description |
|
|
260
|
+
|
|
261
|
+
## Usage Example
|
|
262
|
+
|
|
263
|
+
```tsx
|
|
264
|
+
<Table dataSource={data} schema={schema}>
|
|
265
|
+
<Table.Header>
|
|
266
|
+
<Table.HeaderContent>
|
|
267
|
+
<Table.Search search={{ value, onChange, placeholder: 'Search...' }} />
|
|
268
|
+
</Table.HeaderContent>
|
|
269
|
+
<Table.HeaderContent>
|
|
270
|
+
<Button>Export</Button>
|
|
271
|
+
</Table.HeaderContent>
|
|
272
|
+
</Table.Header>
|
|
273
|
+
|
|
274
|
+
<Table.Body
|
|
275
|
+
cell={{ hasBorder: true }}
|
|
276
|
+
sort={{ sortedColumns, onSort: handleSort }}
|
|
277
|
+
stickyHeader={true}
|
|
278
|
+
/>
|
|
279
|
+
|
|
280
|
+
<Table.Footer>
|
|
281
|
+
<Table.FooterContent>
|
|
282
|
+
<Table.PaginationInfo
|
|
283
|
+
showTotal={true}
|
|
284
|
+
totalItems={100}
|
|
285
|
+
currentPage={1}
|
|
286
|
+
itemsPerPage={10}
|
|
287
|
+
/>
|
|
288
|
+
</Table.FooterContent>
|
|
289
|
+
<Table.FooterContent>
|
|
290
|
+
<Table.Pagination
|
|
291
|
+
currentPage={1}
|
|
292
|
+
totalPage={10}
|
|
293
|
+
onChange={setPage}
|
|
294
|
+
/>
|
|
295
|
+
</Table.FooterContent>
|
|
296
|
+
</Table.Footer>
|
|
297
|
+
</Table>
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
## Dependencies
|
|
301
|
+
|
|
302
|
+
- `@radix-ui/react-popover` (used by search)
|
|
303
|
+
- Internal `Button`, `Input` components
|
|
304
|
+
- Internal icon components
|