@canvas-components/react-components 0.3.19 → 0.3.20
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 +138 -20
- package/THIRD_PARTY_NOTICES.md +30 -0
- package/dist/index.cjs +4277 -77
- package/dist/index.d.cts +2896 -81
- package/dist/index.d.ts +2896 -81
- package/dist/index.js +2565 -76
- package/package.json +6 -2
package/README.md
CHANGED
|
@@ -25,6 +25,8 @@ pnpm add @canvas-components/react-components react@^16.8 react-dom@^16.8
|
|
|
25
25
|
|
|
26
26
|
```tsx
|
|
27
27
|
import {
|
|
28
|
+
ReactHomeOutlined,
|
|
29
|
+
ReactIcon,
|
|
28
30
|
ReactPopconfirm,
|
|
29
31
|
ReactPopup,
|
|
30
32
|
ReactTransition,
|
|
@@ -32,30 +34,100 @@ import {
|
|
|
32
34
|
|
|
33
35
|
function Demo() {
|
|
34
36
|
return (
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
37
|
+
<>
|
|
38
|
+
<ReactIcon name="HomeOutlined" size={20} aria-label="首页" />
|
|
39
|
+
<ReactHomeOutlined size={20} aria-hidden="true" />
|
|
40
|
+
<ReactPopconfirm
|
|
41
|
+
title="确认删除这条记录?"
|
|
42
|
+
description="删除后不可恢复"
|
|
43
|
+
onConfirm={() => console.log("confirmed")}
|
|
44
|
+
>
|
|
45
|
+
<button type="button">删除</button>
|
|
46
|
+
</ReactPopconfirm>
|
|
47
|
+
</>
|
|
42
48
|
);
|
|
43
49
|
}
|
|
44
50
|
```
|
|
45
51
|
|
|
52
|
+
### 表单组件
|
|
53
|
+
|
|
54
|
+
组件可作为受控输入使用,也可以放进普通 HTML 表单或 `ReactForm` 中。以下示例组合文本框、可搜索选择器、日期选择器、复选框、按钮和确认气泡:
|
|
55
|
+
|
|
56
|
+
```tsx
|
|
57
|
+
import { useState } from "react";
|
|
58
|
+
import {
|
|
59
|
+
ReactButton,
|
|
60
|
+
ReactCheckbox,
|
|
61
|
+
ReactDatePicker,
|
|
62
|
+
ReactFlex,
|
|
63
|
+
ReactInput,
|
|
64
|
+
ReactPopconfirm,
|
|
65
|
+
ReactSelect,
|
|
66
|
+
} from "@canvas-components/react-components";
|
|
67
|
+
|
|
68
|
+
export function ProfileForm() {
|
|
69
|
+
const [name, setName] = useState("林晨");
|
|
70
|
+
const [team, setTeam] = useState("design");
|
|
71
|
+
const [date, setDate] = useState("2026-10-18");
|
|
72
|
+
const [subscribed, setSubscribed] = useState(true);
|
|
73
|
+
|
|
74
|
+
return (
|
|
75
|
+
<form onSubmit={(event) => event.preventDefault()}>
|
|
76
|
+
<label>
|
|
77
|
+
姓名
|
|
78
|
+
<ReactInput value={name} onChange={(event) => setName(event.currentTarget.value)} />
|
|
79
|
+
</label>
|
|
80
|
+
<label>
|
|
81
|
+
团队
|
|
82
|
+
<ReactSelect
|
|
83
|
+
value={team}
|
|
84
|
+
showSearch
|
|
85
|
+
options={[
|
|
86
|
+
{ value: "design", label: "设计团队" },
|
|
87
|
+
{ value: "engineering", label: "研发团队" },
|
|
88
|
+
]}
|
|
89
|
+
onChange={setTeam}
|
|
90
|
+
/>
|
|
91
|
+
</label>
|
|
92
|
+
<ReactDatePicker value={date} onChange={setDate} />
|
|
93
|
+
<ReactCheckbox
|
|
94
|
+
checked={subscribed}
|
|
95
|
+
onChange={(event) => setSubscribed(event.currentTarget.checked)}
|
|
96
|
+
>
|
|
97
|
+
接收团队动态
|
|
98
|
+
</ReactCheckbox>
|
|
99
|
+
<ReactFlex gap={8}>
|
|
100
|
+
<ReactButton type="primary" htmlType="submit">保存</ReactButton>
|
|
101
|
+
<ReactPopconfirm title="确认删除?" onConfirm={() => setName("")}>
|
|
102
|
+
<ReactButton danger>删除</ReactButton>
|
|
103
|
+
</ReactPopconfirm>
|
|
104
|
+
</ReactFlex>
|
|
105
|
+
</form>
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
文档站「React Components」目录为每个组件提供了独立示例,包含组件用途、属性说明和可复制的 JSX 用法;图标目录也列出全部具名图标。
|
|
111
|
+
|
|
46
112
|
## 组件列表
|
|
47
113
|
|
|
48
|
-
###
|
|
114
|
+
### 表单与选择
|
|
49
115
|
|
|
50
116
|
- `ReactInput`
|
|
51
117
|
- `ReactNumberInput`
|
|
52
118
|
- `ReactInputNumber`
|
|
53
|
-
- `
|
|
54
|
-
- `
|
|
55
|
-
- `
|
|
56
|
-
- `
|
|
57
|
-
- `
|
|
58
|
-
- `
|
|
119
|
+
- `ReactInputRange`
|
|
120
|
+
- `ReactCheckbox`
|
|
121
|
+
- `ReactRadio`
|
|
122
|
+
- `ReactSelect`
|
|
123
|
+
- `ReactAutoComplete`
|
|
124
|
+
- `ReactCascader`
|
|
125
|
+
- `ReactTreeSelect`
|
|
126
|
+
- `ReactColorPicker`
|
|
127
|
+
- `ReactTextArea`
|
|
128
|
+
- `ReactForm`
|
|
129
|
+
|
|
130
|
+
`ReactNumberInput` 和 `ReactInputRange` 默认不使用鼠标滚轮调整数值;需要该行为时传入 `changeOnWheel`,例如 `<ReactNumberInput value={count} onChange={setCount} changeOnWheel />`。
|
|
59
131
|
|
|
60
132
|
### 日期时间
|
|
61
133
|
|
|
@@ -69,21 +141,47 @@ function Demo() {
|
|
|
69
141
|
- `ReactQuarterPicker`
|
|
70
142
|
- `ReactYearPicker`
|
|
71
143
|
|
|
72
|
-
###
|
|
144
|
+
### 弹层与反馈
|
|
73
145
|
|
|
74
146
|
- `ReactPopup`
|
|
147
|
+
- `ReactDropdown`
|
|
148
|
+
- `ReactModal`
|
|
149
|
+
- `ReactDrawer`
|
|
75
150
|
- `ReactPopconfirm`
|
|
151
|
+
- `ReactTooltip`
|
|
76
152
|
- `ReactTransition`
|
|
153
|
+
- `reactMessage`
|
|
154
|
+
|
|
155
|
+
### 展示、布局与交互
|
|
156
|
+
|
|
77
157
|
- `ReactPagination`
|
|
78
158
|
- `ReactVirtualList`
|
|
79
|
-
- `
|
|
80
|
-
- `
|
|
81
|
-
- `
|
|
82
|
-
- `
|
|
83
|
-
- `
|
|
159
|
+
- `ReactWaterfall`
|
|
160
|
+
- `ReactResizablePanels`
|
|
161
|
+
- `ReactImagePreview`
|
|
162
|
+
- `ReactButton`
|
|
163
|
+
- `ReactIcon` 与 831 个 Ant Design 风格具名 SVG 图标(例如 `ReactHomeOutlined`)
|
|
164
|
+
- `ReactFlex` / `ReactRow` / `ReactCol`
|
|
165
|
+
- `ReactFilterPanel`
|
|
84
166
|
|
|
85
167
|
## 属性说明
|
|
86
168
|
|
|
169
|
+
### `ReactDropdown`
|
|
170
|
+
|
|
171
|
+
```tsx
|
|
172
|
+
<ReactDropdown
|
|
173
|
+
items={[
|
|
174
|
+
{ key: "json", label: "导出 JSON" },
|
|
175
|
+
{ key: "pdf", label: "导出 PDF", description: "实验性功能" },
|
|
176
|
+
]}
|
|
177
|
+
onSelect={(key) => exportFile(key)}
|
|
178
|
+
>
|
|
179
|
+
导出
|
|
180
|
+
</ReactDropdown>
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
`children` 可省略;只传 `icon` 时触发按钮显示居中的图标,建议同时通过 `triggerProps` 提供 `aria-label`。菜单项支持禁用、图标、说明、拖拽事件和指针进入事件。可用 `open`、`defaultOpen`、`onOpenChange` 控制展开状态;支持方向键、Home、End 和 Esc。
|
|
184
|
+
|
|
87
185
|
### `ReactPopupProps`
|
|
88
186
|
|
|
89
187
|
| 属性 | 类型 | 说明 |
|
|
@@ -173,3 +271,23 @@ function Demo() {
|
|
|
173
271
|
## 说明
|
|
174
272
|
|
|
175
273
|
这个包的导出面比较大,输入类组件大多保持接近原生表单语义;如果需要精确字段,请优先查看对应组件的 `Props` 类型定义。
|
|
274
|
+
|
|
275
|
+
图标组件使用包内自包含的 SVG 路径数据,不需要安装 Ant Design 或图标数据包。图标名称、尺寸、颜色、旋转和加载动画由 `ReactIconProps` 提供;也可以直接使用 `ReactHomeOutlined` 等具名组件。SVG 路径数据的上游许可和版权信息见随包发布的 `THIRD_PARTY_NOTICES.md`。
|
|
276
|
+
|
|
277
|
+
### 通用折叠面板
|
|
278
|
+
|
|
279
|
+
`ReactCollapsePanel` 使用现有方向图标,支持鼠标及 Enter / 空格展开折叠。折叠时保留内容节点和输入草稿。
|
|
280
|
+
|
|
281
|
+
```tsx
|
|
282
|
+
<ReactCollapsePanel title="位置与尺寸" defaultOpen>
|
|
283
|
+
<ReactInput placeholder="输入名称" />
|
|
284
|
+
</ReactCollapsePanel>
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
通过 `open` 与 `onOpenChange` 控制展开状态;`disabled` 禁止切换,`contentClassName` 可定制内容区样式。默认收起。
|
|
288
|
+
|
|
289
|
+
### 通用拖拽排序
|
|
290
|
+
|
|
291
|
+
`ReactSortableList` 统一提供与 ListTable 工具栏列排序一致的浮动行、实时让位动画、边缘自动滚动和全屏浮层。通过 `items`(包含 `key`、`parentKey`、`label`)、`renderItem(item, handleProps)` 和 `onOrderChange(parentKey, orderedKeys)` 接入;把 `handleProps` 传给使用现有图标的拖拽手柄。`scrollContainerRef` 指向滚动容器,`disabled` 禁止拖拽,`dragThreshold` 默认 4px。Esc、失焦和指针取消会丢弃排序,放下才提交一次顺序。后续拖拽排序统一复用此组件。
|
|
292
|
+
|
|
293
|
+
大量节点可传入 `virtual={{ height: 360, itemHeight: 34, overscan: 6 }}` 启用固定行高虚拟列表;组件使用内部滚动容器自动滚动,拖拽命中按完整列表计算,包含尚未挂载的节点。
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# 第三方版权声明
|
|
2
|
+
|
|
3
|
+
## Ant Design Icons
|
|
4
|
+
|
|
5
|
+
本包通过 `@canvas-components/icons` 使用 Ant Design Icons 项目的 SVG 图标路径数据。许可声明随共享图标包发布。
|
|
6
|
+
|
|
7
|
+
```text
|
|
8
|
+
MIT LICENSE
|
|
9
|
+
|
|
10
|
+
Copyright (c) 2018-present Ant UED, https://xtech.antfin.com/
|
|
11
|
+
|
|
12
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
13
|
+
a copy of this software and associated documentation files (the
|
|
14
|
+
"Software"), to deal in the Software without restriction, including
|
|
15
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
16
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
17
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
18
|
+
the following conditions:
|
|
19
|
+
|
|
20
|
+
The above copyright notice and this permission notice shall be
|
|
21
|
+
included in all copies or substantial portions of the Software.
|
|
22
|
+
|
|
23
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
24
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
25
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
26
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
27
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
28
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
29
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
30
|
+
```
|