@fvc/table 1.1.0 → 1.1.2-next-3607140332290efd627f3fac1cb34e4dcb36274e
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/README.md +169 -0
- package/dist/lib/index.js +1 -1
- package/dist/lib/table/src/Table.d.ts +1 -0
- package/package.json +20 -3
package/README.md
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
# @fvc/table
|
|
2
|
+
|
|
3
|
+
`@fvc/table` provides a data table component built on top of Ant Design's `Table`. It applies the FE-VIS class prefix and exposes the full Ant Design `Table` API so existing `antd` table knowledge transfers directly.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
bun add @fvc/table
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Peer Dependencies
|
|
12
|
+
|
|
13
|
+
The package expects these dependencies to be available in the consuming application:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
bun add react antd
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Import
|
|
20
|
+
|
|
21
|
+
```tsx
|
|
22
|
+
import { Table } from '@fvc/table';
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Quick Start
|
|
26
|
+
|
|
27
|
+
```tsx
|
|
28
|
+
import { Table } from '@fvc/table';
|
|
29
|
+
|
|
30
|
+
const columns = [
|
|
31
|
+
{ title: 'Name', dataIndex: 'name', key: 'name' },
|
|
32
|
+
{ title: 'Age', dataIndex: 'age', key: 'age' },
|
|
33
|
+
];
|
|
34
|
+
|
|
35
|
+
const data = [
|
|
36
|
+
{ key: '1', name: 'Alice', age: 30 },
|
|
37
|
+
{ key: '2', name: 'Bob', age: 25 },
|
|
38
|
+
];
|
|
39
|
+
|
|
40
|
+
export function UserTable() {
|
|
41
|
+
return <Table columns={columns} dataSource={data} />;
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Common Usage
|
|
46
|
+
|
|
47
|
+
### Sortable Columns
|
|
48
|
+
|
|
49
|
+
```tsx
|
|
50
|
+
const columns = [
|
|
51
|
+
{
|
|
52
|
+
title: 'Name',
|
|
53
|
+
dataIndex: 'name',
|
|
54
|
+
sorter: (a, b) => a.name.localeCompare(b.name),
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
title: 'Age',
|
|
58
|
+
dataIndex: 'age',
|
|
59
|
+
sorter: (a, b) => a.age - b.age,
|
|
60
|
+
},
|
|
61
|
+
];
|
|
62
|
+
|
|
63
|
+
<Table columns={columns} dataSource={data} />;
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Pagination
|
|
67
|
+
|
|
68
|
+
```tsx
|
|
69
|
+
<Table
|
|
70
|
+
columns={columns}
|
|
71
|
+
dataSource={data}
|
|
72
|
+
pagination={{ pageSize: 10, total: 100, current: page, onChange: setPage }}
|
|
73
|
+
/>
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Row Selection
|
|
77
|
+
|
|
78
|
+
```tsx
|
|
79
|
+
const [selectedRowKeys, setSelectedRowKeys] = useState([]);
|
|
80
|
+
|
|
81
|
+
<Table
|
|
82
|
+
columns={columns}
|
|
83
|
+
dataSource={data}
|
|
84
|
+
rowSelection={{
|
|
85
|
+
selectedRowKeys,
|
|
86
|
+
onChange: setSelectedRowKeys,
|
|
87
|
+
}}
|
|
88
|
+
/>;
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Loading State
|
|
92
|
+
|
|
93
|
+
```tsx
|
|
94
|
+
<Table columns={columns} dataSource={data} loading={isFetching} />
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Horizontal Scroll
|
|
98
|
+
|
|
99
|
+
```tsx
|
|
100
|
+
<Table columns={columns} dataSource={data} scroll={{ x: 1200 }} />
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## Props
|
|
104
|
+
|
|
105
|
+
Extends all [Ant Design `TableProps`](https://ant-design.antgroup.com/components/table#api).
|
|
106
|
+
|
|
107
|
+
| Prop | Type | Description |
|
|
108
|
+
| -------------- | -------------------- | ---------------------------------------------------- |
|
|
109
|
+
| `columns` | `ColumnsType` | Column definitions (title, dataIndex, render, etc.). |
|
|
110
|
+
| `dataSource` | `object[]` | Array of row data records. |
|
|
111
|
+
| `rowKey` | `string \| function` | Unique key for each row (defaults to `'key'`). |
|
|
112
|
+
| `loading` | `boolean` | Shows a loading indicator over the table. |
|
|
113
|
+
| `pagination` | `object \| false` | Pagination config; `false` to disable. |
|
|
114
|
+
| `rowSelection` | `object` | Checkbox selection config. |
|
|
115
|
+
| `onChange` | `function` | Callback when pagination, filters, or sorter change. |
|
|
116
|
+
| `scroll` | `object` | Enables horizontal or vertical scrolling. |
|
|
117
|
+
|
|
118
|
+
## TypeScript
|
|
119
|
+
|
|
120
|
+
The package ships with type definitions. No `@types/` install needed.
|
|
121
|
+
|
|
122
|
+
```ts
|
|
123
|
+
import type { TableProps } from '@fvc/table/types';
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## Consumer Example
|
|
127
|
+
|
|
128
|
+
```tsx
|
|
129
|
+
import { Table } from '@fvc/table';
|
|
130
|
+
import { useState } from 'react';
|
|
131
|
+
|
|
132
|
+
export function OrdersTable({ orders, loading }) {
|
|
133
|
+
const [page, setPage] = useState(1);
|
|
134
|
+
|
|
135
|
+
const columns = [
|
|
136
|
+
{ title: 'Order ID', dataIndex: 'id', key: 'id' },
|
|
137
|
+
{ title: 'Customer', dataIndex: 'customer', key: 'customer' },
|
|
138
|
+
{
|
|
139
|
+
title: 'Status',
|
|
140
|
+
dataIndex: 'status',
|
|
141
|
+
key: 'status',
|
|
142
|
+
filters: [
|
|
143
|
+
{ text: 'Pending', value: 'pending' },
|
|
144
|
+
{ text: 'Shipped', value: 'shipped' },
|
|
145
|
+
],
|
|
146
|
+
onFilter: (value, record) => record.status === value,
|
|
147
|
+
},
|
|
148
|
+
];
|
|
149
|
+
|
|
150
|
+
return (
|
|
151
|
+
<Table
|
|
152
|
+
columns={columns}
|
|
153
|
+
dataSource={orders}
|
|
154
|
+
loading={loading}
|
|
155
|
+
rowKey="id"
|
|
156
|
+
pagination={{ current: page, pageSize: 20, onChange: setPage }}
|
|
157
|
+
/>
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
## Development
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
bun run lint
|
|
166
|
+
bun run type-check
|
|
167
|
+
bun run test
|
|
168
|
+
bun run build
|
|
169
|
+
```
|
package/dist/lib/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import{Table as t}from"antd";import e from"react";var r;void 0===r&&(r={}),r.insertAt;const a=r=>e.createElement(t,Object.assign({},r,{prefixCls:"fvc-table"}));export{a as Table};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fvc/table",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2-next-3607140332290efd627f3fac1cb34e4dcb36274e",
|
|
4
4
|
"main": "./dist/lib/index.js",
|
|
5
5
|
"types": "./dist/lib/table/src/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -18,9 +18,26 @@
|
|
|
18
18
|
}
|
|
19
19
|
},
|
|
20
20
|
"scripts": {
|
|
21
|
-
"build": "
|
|
21
|
+
"build": "rollup -c ./rollup.config.mjs",
|
|
22
|
+
"clean": "rm -rf dist && rm -rf .rollup.cache && rm -rf .turbo",
|
|
23
|
+
"lint": "eslint --config ../../eslint.config.js \"src/**/*.{ts,tsx}\"",
|
|
24
|
+
"lint:fix": "eslint --config ../../eslint.config.js \"src/**/*.{ts,tsx}\" --fix",
|
|
25
|
+
"format": "prettier --write \"src/**/*.{ts,tsx}\"",
|
|
26
|
+
"type-check": "tsc --noEmit",
|
|
27
|
+
"test": "bun test --preload ../../tests/happydom.ts --preload ../../tests/testing-library.tsx"
|
|
22
28
|
},
|
|
23
|
-
"
|
|
29
|
+
"keywords": [
|
|
30
|
+
"react",
|
|
31
|
+
"react-component",
|
|
32
|
+
"fvc",
|
|
33
|
+
"fe-vis-core",
|
|
34
|
+
"ui",
|
|
35
|
+
"table",
|
|
36
|
+
"data-table",
|
|
37
|
+
"design-system",
|
|
38
|
+
"antd"
|
|
39
|
+
],
|
|
40
|
+
"peerDependencies": {
|
|
24
41
|
"react": "^18.0.0",
|
|
25
42
|
"antd": "^5.0.0"
|
|
26
43
|
}
|