@hsu-react/ui 0.0.1 → 0.0.2

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.
Files changed (147) hide show
  1. package/es/components/ChainGraph/index.module.less +1 -1
  2. package/es/components/Chat/ChatInput/_components/SendButton/index.module.less +1 -1
  3. package/es/components/Chat/ChatInput/_components/UploadButton/index.module.less +1 -1
  4. package/es/components/Chat/ChatInput/index.module.less +2 -2
  5. package/es/components/Chat/ChatList/_components/Assistant/AssistantItem/index.module.less +1 -1
  6. package/es/components/Checkbox/CheckboxGroup/index.module.less +16 -16
  7. package/es/components/Checkbox/index.module.less +13 -13
  8. package/es/components/CodeMirror/index.module.less +4 -4
  9. package/es/components/DatePicker/RangePicker/index.module.less +1 -1
  10. package/es/components/DatePicker/StepPicker/index.module.less +1 -1
  11. package/es/components/DatePicker/index.module.less +1 -1
  12. package/es/components/Form/DrawerForm/index.module.less +2 -2
  13. package/es/components/FormItem/FormRadio/index.module.less +9 -9
  14. package/es/components/FormItem/FormSegmented/index.module.less +2 -2
  15. package/es/components/FormItem/FormUpload/index.module.less +4 -4
  16. package/es/components/FormItem/ItemContainer/index.module.less +22 -22
  17. package/es/components/Icon/index.js +9 -24
  18. package/es/components/Input/Number/index.module.less +9 -9
  19. package/es/components/Input/Password/index.module.less +3 -3
  20. package/es/components/Input/Search/index.module.less +5 -5
  21. package/es/components/Input/TextArea/index.module.less +5 -5
  22. package/es/components/Input/index.module.less +4 -4
  23. package/es/components/Modal/index.module.less +2 -2
  24. package/es/components/Operate/index.module.less +2 -2
  25. package/es/components/Panel/IframePanel/index.module.less +1 -1
  26. package/es/components/Panel/ListPanel/_components/ColumnMgt/index.module.less +1 -1
  27. package/es/components/Search/index.module.less +2 -2
  28. package/es/components/Select/AutoCompleteSelect/index.module.less +35 -35
  29. package/es/components/Select/IconSelect/index.module.less +3 -3
  30. package/es/components/Select/TreeSelect/index.module.less +17 -17
  31. package/es/components/Select/index.module.less +34 -34
  32. package/es/components/Slider/index.module.less +4 -4
  33. package/es/components/Spreadsheet/index.module.less +4 -4
  34. package/es/components/Table/_components/Pagination/index.module.less +23 -23
  35. package/es/components/Table/index.module.less +61 -61
  36. package/es/components/Tree/index.module.less +11 -11
  37. package/es/components/Upload/index.module.less +3 -3
  38. package/es/styles/antd-overload.less +1 -1
  39. package/lib/components/ChainGraph/index.module.less +1 -1
  40. package/lib/components/Chat/ChatInput/_components/SendButton/index.module.less +1 -1
  41. package/lib/components/Chat/ChatInput/_components/UploadButton/index.module.less +1 -1
  42. package/lib/components/Chat/ChatInput/index.module.less +2 -2
  43. package/lib/components/Chat/ChatList/_components/Assistant/AssistantItem/index.module.less +1 -1
  44. package/lib/components/Checkbox/CheckboxGroup/index.module.less +16 -16
  45. package/lib/components/Checkbox/index.module.less +13 -13
  46. package/lib/components/CodeMirror/index.module.less +4 -4
  47. package/lib/components/DatePicker/RangePicker/index.module.less +1 -1
  48. package/lib/components/DatePicker/StepPicker/index.module.less +1 -1
  49. package/lib/components/DatePicker/index.module.less +1 -1
  50. package/lib/components/Form/DrawerForm/index.module.less +2 -2
  51. package/lib/components/FormItem/FormRadio/index.module.less +9 -9
  52. package/lib/components/FormItem/FormSegmented/index.module.less +2 -2
  53. package/lib/components/FormItem/FormUpload/index.module.less +4 -4
  54. package/lib/components/FormItem/ItemContainer/index.module.less +22 -22
  55. package/lib/components/Icon/index.js +9 -27
  56. package/lib/components/Input/Number/index.module.less +9 -9
  57. package/lib/components/Input/Password/index.module.less +3 -3
  58. package/lib/components/Input/Search/index.module.less +5 -5
  59. package/lib/components/Input/TextArea/index.module.less +5 -5
  60. package/lib/components/Input/index.module.less +4 -4
  61. package/lib/components/Modal/index.module.less +2 -2
  62. package/lib/components/Operate/index.module.less +2 -2
  63. package/lib/components/Panel/IframePanel/index.module.less +1 -1
  64. package/lib/components/Panel/ListPanel/_components/ColumnMgt/index.module.less +1 -1
  65. package/lib/components/Search/index.module.less +2 -2
  66. package/lib/components/Select/AutoCompleteSelect/index.module.less +35 -35
  67. package/lib/components/Select/IconSelect/index.module.less +3 -3
  68. package/lib/components/Select/TreeSelect/index.module.less +17 -17
  69. package/lib/components/Select/index.module.less +34 -34
  70. package/lib/components/Slider/index.module.less +4 -4
  71. package/lib/components/Spreadsheet/index.module.less +4 -4
  72. package/lib/components/Table/_components/Pagination/index.module.less +23 -23
  73. package/lib/components/Table/index.module.less +61 -61
  74. package/lib/components/Tree/index.module.less +11 -11
  75. package/lib/components/Upload/index.module.less +3 -3
  76. package/lib/styles/antd-overload.less +1 -1
  77. package/package.json +1 -1
  78. package/src/components/Button/index.md +2 -3
  79. package/src/components/ChainGraph/index.md +66 -1
  80. package/src/components/ChainGraph/index.module.less +1 -1
  81. package/src/components/Chart/index.md +78 -1
  82. package/src/components/Chat/ChatInput/_components/SendButton/index.module.less +1 -1
  83. package/src/components/Chat/ChatInput/_components/UploadButton/index.module.less +1 -1
  84. package/src/components/Chat/ChatInput/index.module.less +2 -2
  85. package/src/components/Chat/ChatList/_components/Assistant/AssistantItem/index.module.less +1 -1
  86. package/src/components/Chat/index.md +97 -1
  87. package/src/components/Checkbox/CheckboxGroup/index.module.less +16 -16
  88. package/src/components/Checkbox/index.md +53 -1
  89. package/src/components/Checkbox/index.module.less +13 -13
  90. package/src/components/CodeMirror/index.md +41 -1
  91. package/src/components/CodeMirror/index.module.less +4 -4
  92. package/src/components/DatePicker/RangePicker/index.module.less +1 -1
  93. package/src/components/DatePicker/StepPicker/index.module.less +1 -1
  94. package/src/components/DatePicker/index.md +43 -1
  95. package/src/components/DatePicker/index.module.less +1 -1
  96. package/src/components/Descriptions/index.md +45 -1
  97. package/src/components/Editor/index.md +40 -1
  98. package/src/components/FileCol/index.md +24 -1
  99. package/src/components/FilePreview/index.md +45 -1
  100. package/src/components/FlexFill/index.md +46 -1
  101. package/src/components/Form/DrawerForm/index.module.less +2 -2
  102. package/src/components/Form/index.md +92 -1
  103. package/src/components/FormItem/FormRadio/index.module.less +9 -9
  104. package/src/components/FormItem/FormSegmented/index.module.less +2 -2
  105. package/src/components/FormItem/FormUpload/index.module.less +4 -4
  106. package/src/components/FormItem/ItemContainer/index.module.less +22 -22
  107. package/src/components/FormItem/index.md +459 -1
  108. package/src/components/Icon/index.md +21 -3
  109. package/src/components/Icon/index.tsx +9 -37
  110. package/src/components/Input/Number/index.module.less +9 -9
  111. package/src/components/Input/Password/index.module.less +3 -3
  112. package/src/components/Input/Search/index.module.less +5 -5
  113. package/src/components/Input/TextArea/index.module.less +5 -5
  114. package/src/components/Input/index.md +35 -1
  115. package/src/components/Input/index.module.less +4 -4
  116. package/src/components/Markdown/index.md +71 -1
  117. package/src/components/Modal/index.md +43 -1
  118. package/src/components/Modal/index.module.less +2 -2
  119. package/src/components/Operate/index.md +43 -1
  120. package/src/components/Operate/index.module.less +2 -2
  121. package/src/components/Panel/IframePanel/index.module.less +1 -1
  122. package/src/components/Panel/ListPanel/_components/ColumnMgt/index.module.less +1 -1
  123. package/src/components/Panel/index.md +146 -1
  124. package/src/components/Search/index.md +73 -1
  125. package/src/components/Search/index.module.less +2 -2
  126. package/src/components/SecondConf/index.md +39 -1
  127. package/src/components/Select/AutoCompleteSelect/index.module.less +35 -35
  128. package/src/components/Select/IconSelect/index.module.less +3 -3
  129. package/src/components/Select/TreeSelect/index.module.less +17 -17
  130. package/src/components/Select/index.md +47 -1
  131. package/src/components/Select/index.module.less +34 -34
  132. package/src/components/Slider/index.md +29 -1
  133. package/src/components/Slider/index.module.less +4 -4
  134. package/src/components/Spreadsheet/index.md +42 -1
  135. package/src/components/Spreadsheet/index.module.less +4 -4
  136. package/src/components/Switch/index.md +33 -1
  137. package/src/components/TabBar/index.md +53 -1
  138. package/src/components/Table/_components/Pagination/index.module.less +23 -23
  139. package/src/components/Table/index.md +60 -1
  140. package/src/components/Table/index.module.less +61 -61
  141. package/src/components/Tags/index.md +23 -1
  142. package/src/components/TextEllipsis/index.md +29 -1
  143. package/src/components/Tree/index.md +66 -1
  144. package/src/components/Tree/index.module.less +11 -11
  145. package/src/components/Upload/index.md +72 -1
  146. package/src/components/Upload/index.module.less +3 -3
  147. package/src/styles/antd-overload.less +1 -1
@@ -56,25 +56,25 @@
56
56
  overflow-y: auto;
57
57
  scrollbar-gutter: stable;
58
58
 
59
- .ant-tree-treenode {
59
+ :global(.ant-tree-treenode) {
60
60
  &:hover {
61
61
  background: var(--cf-subtle);
62
62
  }
63
63
 
64
- &:has(> .ant-tree-node-selected) {
64
+ &:has(> :global(.ant-tree-node-selected)) {
65
65
  background-color: #e6f4ff;
66
66
 
67
- .ant-tree-node-selected {
67
+ :global(.ant-tree-node-selected) {
68
68
  background-color: transparent;
69
69
  }
70
70
  }
71
71
  }
72
72
 
73
- .ant-tree-indent-unit {
73
+ :global(.ant-tree-indent-unit) {
74
74
  width: var(--tree-indent-unit-width);
75
75
  }
76
76
 
77
- .ant-tree-switcher {
77
+ :global(.ant-tree-switcher) {
78
78
  display: inline-flex;
79
79
  align-items: center;
80
80
  justify-content: center;
@@ -95,7 +95,7 @@
95
95
  }
96
96
  }
97
97
 
98
- .ant-tree-node-content-wrapper {
98
+ :global(.ant-tree-node-content-wrapper) {
99
99
  display: inline-flex;
100
100
  align-items: center;
101
101
  column-gap: 4px;
@@ -105,7 +105,7 @@
105
105
 
106
106
  padding: 2px 0px;
107
107
 
108
- .ant-tree-title {
108
+ :global(.ant-tree-title) {
109
109
  display: inline-block;
110
110
  }
111
111
 
@@ -113,7 +113,7 @@
113
113
  background: transparent;
114
114
  }
115
115
 
116
- .ant-tree-iconEle {
116
+ :global(.ant-tree-iconEle) {
117
117
  display: inline-flex;
118
118
  align-items: center;
119
119
 
@@ -123,17 +123,17 @@
123
123
  }
124
124
 
125
125
  &.hideLeafExpand {
126
- .ant-tree-switcher-noop {
126
+ :global(.ant-tree-switcher-noop) {
127
127
  display: none;
128
128
  }
129
129
  }
130
130
 
131
131
  &.legacyHasSelectedNodeBackground {
132
132
  .treeContainer {
133
- .ant-tree-treenode.ant-tree-treenode-selected {
133
+ :global(.ant-tree-treenode):global(.ant-tree-treenode-selected) {
134
134
  background-color: #e6f4ff;
135
135
 
136
- .ant-tree-node-selected {
136
+ :global(.ant-tree-node-selected) {
137
137
  background-color: transparent;
138
138
  }
139
139
  }
@@ -4,18 +4,18 @@
4
4
  width: 100%;
5
5
  height: 100%;
6
6
 
7
- span.ant-upload {
7
+ span:global(.ant-upload) {
8
8
  display: inline-flex;
9
9
  }
10
10
 
11
- .ant-upload-list {
11
+ :global(.ant-upload-list) {
12
12
  display: flex;
13
13
  flex-direction: column;
14
14
  row-gap: 5px;
15
15
 
16
16
  width: 100%;
17
17
 
18
- &.ant-upload-list-picture-card {
18
+ &:global(.ant-upload-list-picture-card) {
19
19
  flex-direction: row;
20
20
  flex-wrap: wrap;
21
21
  gap: 5px;
@@ -130,4 +130,4 @@
130
130
  }
131
131
  }
132
132
  }
133
- }
133
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hsu-react/ui",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "一套基于 React + Ant Design 的中后台业务组件库",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -21,10 +21,9 @@ import { Button } from "@hsu-react/ui";
21
21
  ```tsx
22
22
  import React from "react";
23
23
  import { Button } from "@hsu-react/ui";
24
- import { Space } from "antd";
25
24
 
26
25
  export default () => (
27
- <Space>
26
+ <div style={{ display: "flex", gap: 12, flexWrap: "wrap", alignItems: "center" }}>
28
27
  <Button type="primary">主要按钮</Button>
29
28
  <Button>默认按钮</Button>
30
29
  <Button type="dashed">虚线按钮</Button>
@@ -32,7 +31,7 @@ export default () => (
32
31
  <Button type="primary" disabled>
33
32
  禁用
34
33
  </Button>
35
- </Space>
34
+ </div>
36
35
  );
37
36
  ```
38
37
 
@@ -8,10 +8,75 @@ title: ChainGraph 关系图
8
8
 
9
9
  # ChainGraph 关系图
10
10
 
11
- > `ChainGraph` 组件。完整 API 见源码类型定义,下方为基础用法。
11
+ 基于 `@antv/g6` 封装的树状关系图,支持节点展开/收起、搜索、缩略图、自适应布局与自定义节点渲染。
12
12
 
13
13
  ## 引入
14
14
 
15
15
  ```ts
16
16
  import { ChainGraph } from "@hsu-react/ui";
17
17
  ```
18
+
19
+ ## 基础用法
20
+
21
+ ```tsx
22
+ import React from "react";
23
+ import { ChainGraph } from "@hsu-react/ui";
24
+
25
+ // TreeGraphData:每个节点含 id / label / 可选 children;level 用于标记根节点层级
26
+ const data = {
27
+ id: "root",
28
+ label: "根节点",
29
+ level: 1,
30
+ children: [
31
+ { id: "a", label: "节点 A", level: 2 },
32
+ {
33
+ id: "b",
34
+ label: "节点 B",
35
+ level: 2,
36
+ children: [{ id: "b-1", label: "节点 B-1", level: 3 }],
37
+ },
38
+ ],
39
+ };
40
+
41
+ export default () => (
42
+ <div style={{ height: 320, width: "100%" }}>
43
+ <ChainGraph
44
+ data={data}
45
+ showSearch
46
+ showMiniMap
47
+ showExpandBtn
48
+ onClick={(node) => console.log(node)}
49
+ />
50
+ </div>
51
+ );
52
+ ```
53
+
54
+ ## API
55
+
56
+ | 属性 | 说明 | 类型 | 默认值 |
57
+ | --- | --- | --- | --- |
58
+ | data | 树状图数据(可携带 `origin` 原始数据) | `TreeGraphData` | - |
59
+ | octopus | 是否启用八爪鱼(双向)布局 | `boolean` | - |
60
+ | level | 默认展开层级 | `number` | `1` |
61
+ | rootLevel | 根节点层级 | `number` | `1` |
62
+ | onClick | 节点点击回调 | `(node?: TreeGraphData) => void` | - |
63
+ | styles | 节点样式配置 | `ChainGraphServicesStyles` | - |
64
+ | showPort | 是否显示连接端点 | `boolean` | `true` |
65
+ | showMiniMap | 是否显示缩略图 | `boolean` | `true` |
66
+ | miniMapSize | 缩略图尺寸 | `[number, number]` | `[200, 150]` |
67
+ | getImage | 获取图表快照(base64) | `(img: string) => void` | - |
68
+ | className | 内层容器类名 | `string` | - |
69
+ | wrapperClassName | 外层(Spin)容器类名 | `string` | - |
70
+ | showSearch | 是否显示搜索框 | `boolean` | `true` |
71
+ | showExpandBtn | 是否显示展开/收起按钮 | `boolean` | `true` |
72
+ | expandClassName | 展开按钮类名 | `string` | - |
73
+ | resize | 是否监听容器尺寸自适应 | `boolean` | `true` |
74
+ | offset | 容器宽高偏移 `[x, y]` | `[number, number]` | `[0, 0]` |
75
+ | fitLeft | 是否左对齐布局 | `boolean` | `false` |
76
+ | paddingLeft | 左侧内边距 | `number` | `20` |
77
+ | loading | 是否加载中 | `boolean` | `false` |
78
+ | hasHover | 是否启用 hover 效果 | `boolean` | `true` |
79
+ | hasSelected | 是否启用选中效果 | `boolean` | `true` |
80
+ | minZoom | 最小缩放比例 | `number` | - |
81
+ | labelRender | 自定义节点文本 | `(label: TreeGraphData) => string` | - |
82
+ | addShape | 自定义节点图形绘制 | `(group: IGroup, cfg: ModelConfig & { origin?: Record<string, unknown> }) => void` | - |
@@ -2,7 +2,7 @@
2
2
  width: 100%;
3
3
  height: 100%;
4
4
 
5
- .ant-spin-container {
5
+ :global(.ant-spin-container) {
6
6
  width: 100%;
7
7
  height: 100%;
8
8
  }
@@ -8,10 +8,87 @@ title: Chart 图表
8
8
 
9
9
  # Chart 图表
10
10
 
11
- > `Chart` 组件。完整 API 见源码类型定义,下方为基础用法。
11
+ 基于 echarts 封装的图表集合,以 `Chart.Line`、`Chart.Bar`、`Chart.Pie` 等子组件形式提供常用图表,自动处理实例创建、容器自适应与销毁。
12
12
 
13
13
  ## 引入
14
14
 
15
15
  ```ts
16
16
  import { Chart } from "@hsu-react/ui";
17
17
  ```
18
+
19
+ ## 基础用法
20
+
21
+ 以 `Chart.Line` 为例,传入 `xAxisData` 与 `seriesData` 即可渲染折线图:
22
+
23
+ ```tsx
24
+ import React from "react";
25
+ import { Chart } from "@hsu-react/ui";
26
+
27
+ export default () => (
28
+ <Chart.Line
29
+ style={{ height: 300 }}
30
+ legendData={["销量"]}
31
+ xAxisData={["周一", "周二", "周三", "周四", "周五", "周六", "周日"]}
32
+ seriesData={[120, 200, 150, 80, 70, 110, 130]}
33
+ />
34
+ );
35
+ ```
36
+
37
+ ## 子组件
38
+
39
+ `Chart` 提供以下子组件:
40
+
41
+ | 子组件 | 说明 |
42
+ | --- | --- |
43
+ | Chart.Line | 折线图 |
44
+ | Chart.Bar | 柱状图 |
45
+ | Chart.Pie | 饼图(另含 `Chart.Pie.Three` 3D 饼图) |
46
+ | Chart.Polar | 极坐标图 |
47
+ | Chart.Gauge | 仪表盘 |
48
+ | Chart.Sankey | 桑基图 |
49
+ | Chart.Tree | 树图 |
50
+ | Chart.Bubble | 气泡图 |
51
+ | Chart.Heatmap | 热力图 |
52
+ | Chart.Radar | 雷达图 |
53
+ | Chart.Group | 组合图表(可在 `Line`/`Bar`/`Pie` 间切换) |
54
+ | Chart.Common | 通用图表,直接透传 echarts 的 `EChartsOption` |
55
+
56
+ ## API
57
+
58
+ ### Chart.Line / Chart.Bar
59
+
60
+ 在 echarts `EChartsOption` 基础上扩展(`Chart.Bar` 同此表):
61
+
62
+ | 属性 | 说明 | 类型 | 默认值 |
63
+ | --- | --- | --- | --- |
64
+ | xAxisData | X 轴类目数据 | `string[]` | - |
65
+ | seriesData | 系列数据,可为数字数组或带 `name`/`series` 的对象数组 | `SeriesDataType` | - |
66
+ | legendData | 图例数据 | `string[]` | - |
67
+ | chartTitle | 图表标题 | `string` | - |
68
+ | scrollConfig | 滚动/缩放配置 | `ChartScrollConfig` | - |
69
+ | insideDataZoom | 内置型数据缩放配置 | `DataZoomComponentOption` | - |
70
+ | sliderDataZoom | 滑动条型数据缩放配置 | `DataZoomComponentOption` | - |
71
+ | enableLegendAutoScroll | 是否启用图例自动滚动 | `boolean` | `false` |
72
+ | legendVisibleCount | 图例每页可见数量 | `number` | `8` |
73
+ | legendScrollInterval | 图例滚动间隔(ms) | `number` | `1500` |
74
+ | onClick | 图元点击回调 | `(event: ECElementEvent) => void` | - |
75
+ | className | 容器类名 | `string` | - |
76
+ | style | 容器样式 | `ChartCSSProperties` | - |
77
+
78
+ > `Chart.Line` 额外支持 `yAxisNameOffsets?: number[]`;其余 echarts 原生配置项(`grid`、`xAxis`、`yAxis`、`tooltip`、`series` 等)均可直接透传。
79
+
80
+ ### Chart.Pie
81
+
82
+ | 属性 | 说明 | 类型 | 默认值 |
83
+ | --- | --- | --- | --- |
84
+ | seriesData | 系列数据 | `SeriesDataType` | - |
85
+ | chartTitle | 图表中心标题 | `string` | - |
86
+ | extendSeries | 追加的额外系列 | `Series[]` | `[]` |
87
+ | isSemiCircle | 是否为半圆 | `boolean` | `false` |
88
+ | position | 半圆贴边位置 | `'top' \| 'bottom' \| 'left' \| 'right'` | `'bottom'` |
89
+ | spanAngle | 显示角度 | `number` | `180` |
90
+ | center | 中心位置 | `[string, string]` | - |
91
+ | radius | 半径配置 | `[string, string]` | - |
92
+ | enableLegendAutoScroll | 是否启用图例自动滚动 | `boolean` | `false` |
93
+ | onClick | 图元点击回调 | `(event: ECElementEvent) => void` | - |
94
+ | onChart | 图表实例就绪回调 | `(chart: EChartsType) => void` | - |
@@ -10,7 +10,7 @@
10
10
  border: none;
11
11
  border-radius: 4px;
12
12
 
13
- .ant-btn-icon {
13
+ :global(.ant-btn-icon) {
14
14
  display: flex;
15
15
  align-items: center;
16
16
  justify-content: center;
@@ -4,7 +4,7 @@
4
4
 
5
5
  border-radius: 4px;
6
6
 
7
- .ant-btn-icon {
7
+ :global(.ant-btn-icon) {
8
8
  display: flex;
9
9
  align-items: center;
10
10
  justify-content: center;
@@ -57,7 +57,7 @@
57
57
  opacity: 0.8;
58
58
  width: 140px;
59
59
  height: 100%;
60
- .ant-select-selector {
60
+ :global(.ant-select-selector) {
61
61
  border: none;
62
62
  margin: 1px 0 0;
63
63
  }
@@ -92,7 +92,7 @@
92
92
 
93
93
  border-radius: 4px;
94
94
 
95
- .ant-btn-icon {
95
+ :global(.ant-btn-icon) {
96
96
  display: flex;
97
97
  align-items: center;
98
98
  justify-content: center;
@@ -20,7 +20,7 @@
20
20
  }
21
21
 
22
22
  .answerBubble {
23
- .ant-bubble-dot {
23
+ :global(.ant-bubble-dot) {
24
24
  column-gap: var(--ant-margin-xxs);
25
25
  }
26
26
 
@@ -8,10 +8,106 @@ title: Chat 对话
8
8
 
9
9
  # Chat 对话
10
10
 
11
- > `Chat` 组件。完整 API 见源码类型定义,下方为基础用法。
11
+ 基于 `@ant-design/x` 封装的 AI 对话组件集合,以 `Chat.List`(消息列表)、`Chat.Input`(输入框)、`Chat.History`(历史会话)三个子组件构成完整对话界面。
12
12
 
13
13
  ## 引入
14
14
 
15
15
  ```ts
16
16
  import { Chat } from "@hsu-react/ui";
17
17
  ```
18
+
19
+ ## 基础用法
20
+
21
+ ```tsx
22
+ import React, { useState } from "react";
23
+ import { Chat } from "@hsu-react/ui";
24
+
25
+ export default () => {
26
+ const [list, setList] = useState([
27
+ {
28
+ query: { query: "你好,请介绍一下你自己" },
29
+ answers: [
30
+ { answer: "你好!我是 AI 助手,有什么可以帮你的吗?", messageId: "1" },
31
+ ],
32
+ },
33
+ ]);
34
+
35
+ const handleSend = (value) => {
36
+ setList((prev) => [
37
+ ...prev,
38
+ {
39
+ query: { query: value },
40
+ answers: [{ answer: `已收到:${value}`, messageId: String(Date.now()) }],
41
+ },
42
+ ]);
43
+ };
44
+
45
+ return (
46
+ <div style={{ display: "flex", flexDirection: "column", height: 420 }}>
47
+ <div style={{ flex: 1, overflow: "auto" }}>
48
+ <Chat.List list={list} />
49
+ </div>
50
+ <Chat.Input onSend={handleSend} uploadEnabled={false} />
51
+ </div>
52
+ );
53
+ };
54
+ ```
55
+
56
+ ## Chat.List
57
+
58
+ 消息列表,渲染用户提问与 AI 回答。
59
+
60
+ | 属性 | 说明 | 类型 | 默认值 |
61
+ | --- | --- | --- | --- |
62
+ | list | 消息列表数据 | `ChatMessage[]` | `[]` |
63
+ | assistanting | AI 是否正在回答中 | `boolean` | - |
64
+ | onAgain | 重新生成回调 | `(query: string) => void` | - |
65
+ | onLikeChange | 点赞/点踩变化回调 | `(messageId: string, like: boolean \| null, content: string) => void` | - |
66
+ | hideTool | 是否隐藏消息工具栏 | `boolean` | - |
67
+ | defaultAnswer | 默认(空态)回答内容 | `string` | - |
68
+ | userName / assistantName | 用户/助手名称 | `string` | - |
69
+ | userAvatar / assistantAvatar | 用户/助手头像 | `ReactNode` | - |
70
+ | userRenderContent | 自定义用户消息内容 | `(originContent: ReactNode, item: QueryMessage) => ReactNode` | - |
71
+ | userRenderQuery | 自定义用户提问文本 | `(query: string \| undefined, item: QueryMessage) => string \| undefined` | - |
72
+ | noAnswerTip | 无回答时的提示文案 | `string` | - |
73
+ | className | 容器类名 | `string` | - |
74
+
75
+ > 另有 `defaultAnswerClassName`、`userClassName`、`assistantClassName`、`userHeaderClassName`、`assistantHeaderClassName` 等多个样式类名属性。
76
+
77
+ ## Chat.Input
78
+
79
+ 对话输入框,支持文件上传、模型切换、功能(agent)开关。
80
+
81
+ | 属性 | 说明 | 类型 | 默认值 |
82
+ | --- | --- | --- | --- |
83
+ | onSend | 发送回调 | `(value: string) => void` | - |
84
+ | assistanting | AI 是否回答中(显示停止按钮) | `boolean` | - |
85
+ | onStop | 停止回答回调 | `() => void` | - |
86
+ | fileList | 文件列表 | `UploadFile[]` | `[]` |
87
+ | onFileListChange | 文件列表变化回调 | `(fileList: UploadFile[]) => void` | - |
88
+ | uploadEnabled | 是否启用上传 | `boolean` | `true` |
89
+ | uploadConfig | 上传配置 | `UploadConfig` | - |
90
+ | modelConfig | 模型切换配置 | `{ modelList: ModelConfig[]; modelType: string; setModelType: (value: string) => void }` | - |
91
+ | agents | 功能开关配置 | `AgentToggleConfig[]` | `[]` |
92
+ | agentsState | 功能开关状态(受控) | `AgentConfig[]` | - |
93
+ | onAgentsChange | 功能开关变化回调 | `(agents: AgentConfig[]) => void` | - |
94
+ | placeholder | 占位提示文字 | `string` | `'询问问题'` |
95
+ | sendIcon / stopIcon | 发送/停止图标 | `string` | - |
96
+ | buttonGroup | 额外按钮组 | `ButtonProps[]` | - |
97
+ | wrapperClassName | 容器类名 | `string` | - |
98
+
99
+ ## Chat.History
100
+
101
+ 历史会话列表,支持新建、重命名、删除会话。
102
+
103
+ | 属性 | 说明 | 类型 | 默认值 |
104
+ | --- | --- | --- | --- |
105
+ | historyList | 分组历史会话数据 | `Record<string, ChatHistoryData[]>` | - |
106
+ | currentChatId | 当前选中的会话 id | `string` | - |
107
+ | onNewChat | 新建会话回调 | `() => void` | - |
108
+ | onChatItemClick | 会话点击回调 | `(item: ChatHistoryData) => void` | - |
109
+ | updateTitle | 重命名回调 | `(chatId: string, title: string) => void` | - |
110
+ | deleteHistory | 删除会话回调 | `(item?: ChatHistoryData) => void` | - |
111
+ | onScrollEnd | 滚动到底部回调(加载更多) | `() => void` | - |
112
+ | width | 容器宽度 | `string` | - |
113
+ | tools | 顶部自定义工具区 | `ReactNode` | - |
@@ -10,7 +10,7 @@
10
10
  height: 100%;
11
11
 
12
12
  // 当 hasAll 为 true 时,Group 作为子元素
13
- > .ant-checkbox-group {
13
+ > :global(.ant-checkbox-group) {
14
14
  display: flex;
15
15
  flex-direction: column;
16
16
  row-gap: 8px;
@@ -28,9 +28,9 @@
28
28
  }
29
29
 
30
30
  &.outline {
31
- .ant-checkbox-wrapper {
32
- .ant-checkbox {
33
- .ant-checkbox-inner {
31
+ :global(.ant-checkbox-wrapper) {
32
+ :global(.ant-checkbox) {
33
+ :global(.ant-checkbox-inner) {
34
34
  border-color: rgba(204, 204, 204, 1) !important;
35
35
 
36
36
  background: transparent !important;
@@ -41,16 +41,16 @@
41
41
  }
42
42
  }
43
43
 
44
- &.ant-checkbox-checked {
45
- .ant-checkbox-inner {
44
+ &:global(.ant-checkbox-checked) {
45
+ :global(.ant-checkbox-inner) {
46
46
  background: rgba(255, 255, 255, 1) !important;
47
47
  }
48
48
  }
49
49
  }
50
50
 
51
- &.ant-checkbox-wrapper-disabled {
52
- .ant-checkbox {
53
- .ant-checkbox-inner {
51
+ &:global(.ant-checkbox-wrapper-disabled) {
52
+ :global(.ant-checkbox) {
53
+ :global(.ant-checkbox-inner) {
54
54
  background: rgba(0, 0, 0, 0.04) !important;
55
55
 
56
56
  &::after {
@@ -58,8 +58,8 @@
58
58
  }
59
59
  }
60
60
 
61
- &.ant-checkbox-checked {
62
- .ant-checkbox-inner {
61
+ &:global(.ant-checkbox-checked) {
62
+ :global(.ant-checkbox-inner) {
63
63
  background: rgba(0, 0, 0, 0.04) !important;
64
64
  }
65
65
  }
@@ -68,7 +68,7 @@
68
68
  }
69
69
  }
70
70
 
71
- .ant-checkbox-wrapper {
71
+ :global(.ant-checkbox-wrapper) {
72
72
  align-items: center;
73
73
 
74
74
  font-family: inherit;
@@ -76,7 +76,7 @@
76
76
  font-weight: inherit;
77
77
  color: inherit;
78
78
 
79
- .ant-checkbox {
79
+ :global(.ant-checkbox) {
80
80
  width: 16px;
81
81
  min-width: 16px;
82
82
  height: 16px;
@@ -84,12 +84,12 @@
84
84
 
85
85
  border-radius: 2px;
86
86
 
87
- input[type="checkbox"].ant-checkbox-input {
87
+ input[type="checkbox"]:global(.ant-checkbox-input) {
88
88
  width: 100%;
89
89
  height: 100%;
90
90
  }
91
91
 
92
- .ant-checkbox-inner {
92
+ :global(.ant-checkbox-inner) {
93
93
  width: 100%;
94
94
  height: 100%;
95
95
 
@@ -106,7 +106,7 @@
106
106
  }
107
107
 
108
108
  &-indeterminate {
109
- .ant-checkbox-inner {
109
+ :global(.ant-checkbox-inner) {
110
110
  &::after {
111
111
  left: 50%;
112
112
  top: 50%;
@@ -8,10 +8,62 @@ title: Checkbox 多选框
8
8
 
9
9
  # Checkbox 多选框
10
10
 
11
- > `Checkbox` 组件。完整 API 见源码类型定义,下方为基础用法。
11
+ 基于 antd `Checkbox` 封装的多选框,额外提供 `outline` 描边样式,并附带支持全选、布局方向的 `Checkbox.Group`。
12
12
 
13
13
  ## 引入
14
14
 
15
15
  ```ts
16
16
  import { Checkbox } from "@hsu-react/ui";
17
17
  ```
18
+
19
+ ## 基础用法
20
+
21
+ ```tsx
22
+ import React from "react";
23
+ import { Checkbox } from "@hsu-react/ui";
24
+
25
+ const options = [
26
+ { label: "苹果", value: "apple" },
27
+ { label: "香蕉", value: "banana" },
28
+ { label: "橙子", value: "orange" },
29
+ ];
30
+
31
+ export default () => {
32
+ const [value, setValue] = React.useState(["apple"]);
33
+
34
+ return (
35
+ <div
36
+ style={{
37
+ display: "flex",
38
+ flexDirection: "column",
39
+ gap: 12,
40
+ alignItems: "flex-start",
41
+ }}
42
+ >
43
+ <Checkbox outline>描边多选框</Checkbox>
44
+ <Checkbox.Group options={options} value={value} onChange={setValue} />
45
+ </div>
46
+ );
47
+ };
48
+ ```
49
+
50
+ ## API
51
+
52
+ ### Checkbox
53
+
54
+ 在 [antd CheckboxProps](https://ant.design/components/checkbox-cn) 基础上扩展:
55
+
56
+ | 属性 | 说明 | 类型 | 默认值 |
57
+ | --- | --- | --- | --- |
58
+ | outline | 是否使用描边样式 | `boolean` | - |
59
+
60
+ ### Checkbox.Group
61
+
62
+ 在 antd `Checkbox.Group` 基础上扩展:
63
+
64
+ | 属性 | 说明 | 类型 | 默认值 |
65
+ | --- | --- | --- | --- |
66
+ | outline | 是否使用描边样式 | `boolean` | - |
67
+ | hasAll | 是否显示"全选"选项 | `boolean` | - |
68
+ | layout | 选项排列方向 | `'vertical' \| 'horizontal'` | `'horizontal'` |
69
+ | allMaxHeight | 含全选时容器最大高度(px) | `number` | - |