@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
@@ -18,18 +18,36 @@ import { Icon } from "@hsu-react/ui";
18
18
 
19
19
  ## 基础用法
20
20
 
21
+ antd 图标名(驼峰):
22
+
21
23
  ```tsx
22
24
  import React from "react";
23
25
  import { Icon } from "@hsu-react/ui";
24
- import { Space } from "antd";
25
26
 
26
27
  export default () => (
27
- <Space size="large" style={{ fontSize: 22 }}>
28
+ <div style={{ display: "flex", gap: 20, alignItems: "center", fontSize: 22 }}>
28
29
  <Icon icon="UserOutlined" />
29
30
  <Icon icon="SettingOutlined" />
30
31
  <Icon icon="HomeOutlined" />
31
32
  <Icon icon="HeartFilled" style={{ color: "#eb2f96" }} />
32
- </Space>
33
+ </div>
34
+ );
35
+ ```
36
+
37
+ iconify 图标名(`集合:名称`,需先注册对应图标集):
38
+
39
+ ```tsx
40
+ import React from "react";
41
+ import { Icon } from "@hsu-react/ui";
42
+
43
+ export default () => (
44
+ <div style={{ display: "flex", gap: 20, alignItems: "center", fontSize: 22 }}>
45
+ <Icon icon="ph:user-bold" />
46
+ <Icon icon="mdi:home" />
47
+ <Icon icon="tabler:settings" />
48
+ <Icon icon="solar:heart-bold" style={{ color: "#eb2f96" }} />
49
+ <Icon icon="carbon:document" />
50
+ </div>
33
51
  );
34
52
  ```
35
53
 
@@ -4,7 +4,7 @@ import {
4
4
  IconProps as IconifyProps,
5
5
  } from "@iconify/react";
6
6
 
7
- import AntdIcon, * as AntdIcons from "@ant-design/icons";
7
+ import * as AntdIcons from "@ant-design/icons";
8
8
  import React, { useEffect, useRef } from "react";
9
9
  import classNames from "classnames";
10
10
  import styles from "./index.module.less";
@@ -74,46 +74,18 @@ const Icon: React.FC<IconProps> = (props) => {
74
74
  );
75
75
  }
76
76
 
77
+ // iconify 图标:直接用 span 承载 Iconify 自带的 svg,避免把它嵌套进 antd Icon
78
+ // 的 svg(其 viewBox 会把内层 svg 缩放成极小值导致图标不可见)。
77
79
  return (
78
- <AntdIcon
80
+ <span
79
81
  {...iconConfig}
80
- // 与 antd 缺省值一致;显式传入以消除开发态 viewBox 告警(子节点是 Iconify 自带 viewBox 的 svg)
81
- viewBox="0 0 1024 1024"
82
- className={classNames([styles.icon, className])}
82
+ role="img"
83
+ ref={ref as unknown as React.Ref<HTMLSpanElement>}
84
+ className={classNames(["anticon", styles.icon, className])}
83
85
  style={mergedStyle}
84
- ref={ref}
85
86
  >
86
- <Iconify
87
- {...iconProps}
88
- icon={icon}
89
- width="1em"
90
- height="1em"
91
- onLoad={() => {
92
- setTimeout(() => {
93
- if (ref.current) {
94
- const svg = ref.current.childNodes[0] as SVGSVGElement;
95
- const svg_i = svg.childNodes[0] as SVGSVGElement;
96
-
97
- const { height } = svg.getBoundingClientRect();
98
- const { height: height_i } = svg_i.getBoundingClientRect();
99
-
100
- const viewBox_i = svg_i.getAttribute("viewBox");
101
- const viewBox_i_height = viewBox_i?.split(" ")[3];
102
-
103
- if (Number(viewBox_i_height) <= 24) return;
104
-
105
- const y_i =
106
- Number(viewBox_i_height) - (Number(height) - Number(height_i));
107
-
108
- svg_i.setAttribute(
109
- "viewBox",
110
- `0 0 ${viewBox_i?.split(" ")[2]} ${y_i.toFixed(0)}`
111
- );
112
- }
113
- }, 1);
114
- }}
115
- />
116
- </AntdIcon>
87
+ <Iconify {...iconProps} icon={icon} width="1em" height="1em" />
88
+ </span>
117
89
  );
118
90
  };
119
91
 
@@ -10,22 +10,22 @@
10
10
  width: 100%;
11
11
  height: 100%;
12
12
 
13
- .ant-input-number-wrapper {
13
+ :global(.ant-input-number-wrapper) {
14
14
  height: 100%;
15
15
  min-height: inherit;
16
16
 
17
- > .ant-input-number,
18
- > .ant-input-number-affix-wrapper {
17
+ > :global(.ant-input-number),
18
+ > :global(.ant-input-number-affix-wrapper) {
19
19
  height: 100%;
20
20
  min-height: inherit;
21
21
  }
22
22
 
23
- > .ant-input-number {
24
- > .ant-input-number-input-wrap {
23
+ > :global(.ant-input-number) {
24
+ > :global(.ant-input-number-input-wrap) {
25
25
  height: 100%;
26
26
  min-height: inherit;
27
27
 
28
- > .ant-input-number-input {
28
+ > :global(.ant-input-number-input) {
29
29
  height: 100%;
30
30
  min-height: inherit;
31
31
  }
@@ -33,11 +33,11 @@
33
33
  }
34
34
  }
35
35
 
36
- > .ant-input-number-input-wrap {
36
+ > :global(.ant-input-number-input-wrap) {
37
37
  height: 100%;
38
38
  min-height: inherit;
39
39
 
40
- > .ant-input-number-input {
40
+ > :global(.ant-input-number-input) {
41
41
  height: 100%;
42
42
  }
43
43
  }
@@ -66,7 +66,7 @@
66
66
  }
67
67
 
68
68
  // 当存在 addonAfter 时,调整清除图标位置
69
- // Ant Design 的 addonAfter 会生成 .ant-input-number-group-addon
69
+ // Ant Design 的 addonAfter 会生成 :global(.ant-input-number-group-addon)
70
70
  // 清除图标需要向左偏移,避免与 addon 重叠
71
71
  // 使用 CSS 变量来动态设置 addon 宽度,默认值 60px 是合理的估算
72
72
  // 通过 JS 动态计算实际宽度并设置 CSS 变量来覆盖
@@ -2,12 +2,12 @@
2
2
  width: 100%;
3
3
  height: 100%;
4
4
 
5
- .ant-input-wrapper {
5
+ :global(.ant-input-wrapper) {
6
6
  height: 100%;
7
7
  min-height: inherit;
8
8
 
9
- > .ant-input,
10
- > .ant-input-affix-wrapper {
9
+ > :global(.ant-input),
10
+ > :global(.ant-input-affix-wrapper) {
11
11
  height: 100%;
12
12
  min-height: inherit;
13
13
  }
@@ -2,18 +2,18 @@
2
2
  width: 100%;
3
3
  height: 100%;
4
4
 
5
- .ant-input-wrapper {
5
+ :global(.ant-input-wrapper) {
6
6
  height: 100%;
7
7
  min-height: inherit;
8
8
 
9
- > .ant-input,
10
- > .ant-input-affix-wrapper {
9
+ > :global(.ant-input),
10
+ > :global(.ant-input-affix-wrapper) {
11
11
  height: 100%;
12
12
  min-height: inherit;
13
13
  }
14
14
 
15
- > .ant-input-group-addon {
16
- > .ant-btn {
15
+ > :global(.ant-input-group-addon) {
16
+ > :global(.ant-btn) {
17
17
  height: 100%;
18
18
  min-height: inherit;
19
19
  }
@@ -61,7 +61,7 @@
61
61
 
62
62
  background-color: transparent !important;
63
63
 
64
- &.ant-input-textarea-affix-wrapper {
64
+ &:global(.ant-input-textarea-affix-wrapper) {
65
65
  position: relative;
66
66
 
67
67
  padding: 0px;
@@ -76,13 +76,13 @@
76
76
  font-family: inherit;
77
77
  }
78
78
 
79
- .ant-input-suffix {
79
+ :global(.ant-input-suffix) {
80
80
  position: absolute;
81
81
  top: 50%;
82
82
  right: 10px;
83
83
  transform: translateY(-50%);
84
84
 
85
- .ant-input-data-count {
85
+ :global(.ant-input-data-count) {
86
86
  position: relative;
87
87
  bottom: auto;
88
88
 
@@ -90,7 +90,7 @@
90
90
  font-size: 14px;
91
91
  }
92
92
 
93
- .ant-input-clear-icon {
93
+ :global(.ant-input-clear-icon) {
94
94
  position: relative;
95
95
 
96
96
  inset-inline-end: 0;
@@ -121,7 +121,7 @@
121
121
 
122
122
  box-shadow: 0 0 0 2px rgba(255, 38, 5, 0.06);
123
123
 
124
- .ant-input-status-error {
124
+ :global(.ant-input-status-error) {
125
125
  border: none !important;
126
126
 
127
127
  box-shadow: none !important;
@@ -8,10 +8,44 @@ title: Input 输入框
8
8
 
9
9
  # Input 输入框
10
10
 
11
- > `Input` 组件。完整 API 见源码类型定义,下方为基础用法。
11
+ 基于 antd `Input` 封装的受控输入框,内置中文输入法合成处理、防抖 `onChange`(返回纯字符串)、自动 `allowClear`、可选 `Tooltip` 及字符转义能力。
12
12
 
13
13
  ## 引入
14
14
 
15
15
  ```ts
16
16
  import { Input } from "@hsu-react/ui";
17
17
  ```
18
+
19
+ ## 基础用法
20
+
21
+ ```tsx
22
+ import React from "react";
23
+ import { Input } from "@hsu-react/ui";
24
+
25
+ export default () => {
26
+ const [value, setValue] = React.useState("");
27
+
28
+ return (
29
+ <div style={{ display: "flex", flexDirection: "column", gap: 12, width: 240 }}>
30
+ <Input placeholder="请输入" value={value} onChange={setValue} />
31
+ <Input placeholder="禁用状态" disabled />
32
+ <div>当前值:{value}</div>
33
+ </div>
34
+ );
35
+ };
36
+ ```
37
+
38
+ ## API
39
+
40
+ 在 [antd InputProps](https://ant.design/components/input-cn) 基础上扩展(并移除了 `onCompositionStart`、`onCompositionEnd`、`ref`,重写了 `onChange`):
41
+
42
+ | 属性 | 说明 | 类型 | 默认值 |
43
+ | --- | --- | --- | --- |
44
+ | onChange | 值变化回调,经过合成与防抖处理后返回纯字符串 | `(value: string) => void` | - |
45
+ | getRef | 获取内部 antd `InputRef` 的回调 | `(ref: InputRef \| null) => void` | - |
46
+ | en | 是否英文模式,开启后不受 `maxLength` 限制 | `boolean` | `false` |
47
+ | word | 是否为字数/单词相关模式 | `boolean` | - |
48
+ | tooltip | 透传给外层 `Tooltip` 的配置 | `TooltipProps` | - |
49
+ | escapeCharacters | 需要自动转义/去转义的字符列表 | `string[]` | - |
50
+
51
+ > 另提供子组件:`Input.Search`、`Input.TextArea`、`Input.Password`、`Input.Number`(数字输入,`onChange` 返回字符串)、`Input.Range`(范围输入)。
@@ -2,16 +2,16 @@
2
2
  width: 100%;
3
3
  height: 100%;
4
4
 
5
- .ant-input-clear-icon {
5
+ :global(.ant-input-clear-icon) {
6
6
  font-size: 14px;
7
7
  }
8
8
 
9
- .ant-input-wrapper {
9
+ :global(.ant-input-wrapper) {
10
10
  height: 100%;
11
11
  min-height: inherit;
12
12
 
13
- > .ant-input,
14
- > .ant-input-affix-wrapper {
13
+ > :global(.ant-input),
14
+ > :global(.ant-input-affix-wrapper) {
15
15
  height: 100%;
16
16
  min-height: inherit;
17
17
  }
@@ -8,10 +8,80 @@ title: Markdown 渲染
8
8
 
9
9
  # Markdown 渲染
10
10
 
11
- > `Markdown` 组件。完整 API 见源码类型定义,下方为基础用法。
11
+ Markdown 渲染与编辑组件,`Markdown.Views` 用于渲染展示(支持 GFM、KaTeX 公式、代码高亮、Mermaid 图与 HTML/SVG Artifacts 预览),`Markdown.Editor` 提供所见即所得编辑器。
12
12
 
13
13
  ## 引入
14
14
 
15
15
  ```ts
16
16
  import { Markdown } from "@hsu-react/ui";
17
17
  ```
18
+
19
+ ## 基础用法
20
+
21
+ `Markdown.Views` 渲染(依赖 KaTeX / highlight.js / Mermaid 等样式,建议在应用环境内使用):
22
+
23
+ ```tsx
24
+ import React from "react";
25
+ import { Markdown } from "@hsu-react/ui";
26
+
27
+ const content = `# 标题
28
+
29
+ 这是一段包含 **加粗** 文本的说明。
30
+
31
+ - 列表项一
32
+ - 列表项二
33
+ - 列表项三
34
+
35
+ \`\`\`ts
36
+ const a = 1;
37
+ const b = a + 1;
38
+ \`\`\`
39
+ `;
40
+
41
+ export default () => <Markdown.Views>{content}</Markdown.Views>;
42
+ ```
43
+
44
+ `Markdown.Editor` 编辑:
45
+
46
+ ```tsx
47
+ import React from "react";
48
+ import { Markdown } from "@hsu-react/ui";
49
+
50
+ export default () => {
51
+ const [value, setValue] = React.useState("# Hello\n\n开始编辑 **Markdown** 内容吧。");
52
+
53
+ return (
54
+ <div style={{ height: 240 }}>
55
+ <Markdown.Editor
56
+ value={value}
57
+ onChange={setValue}
58
+ view={{ menu: true, md: true, html: true }}
59
+ />
60
+ </div>
61
+ );
62
+ };
63
+ ```
64
+
65
+ ## API
66
+
67
+ ### Markdown.Views
68
+
69
+ 继承 [react-markdown Options](https://github.com/remarkjs/react-markdown)(markdown 文本通过 `children` 传入),新增属性:
70
+
71
+ | 属性 | 说明 | 类型 | 默认值 |
72
+ | --- | --- | --- | --- |
73
+ | children | 待渲染的 markdown 文本 | `string` | - |
74
+ | copyProps | 代码块复制按钮配置 | `Omit<CopyProps, 'id'>` | - |
75
+ | className | 自定义类名 | `string` | - |
76
+
77
+ ### Markdown.Editor
78
+
79
+ | 属性 | 说明 | 类型 | 默认值 |
80
+ | --- | --- | --- | --- |
81
+ | value | 编辑器内容 | `string` | `''` |
82
+ | onChange | 内容变化回调 | `(value: string) => void` | - |
83
+ | buttonGroup | 顶部自定义按钮组 | `ButtonProps[]` | - |
84
+ | className | 自定义类名 | `string` | - |
85
+ | disabled | 是否禁用 | `boolean` | - |
86
+ | readOnly | 是否只读 | `boolean` | - |
87
+ | view | 视图区域配置 | `{ menu?: boolean; md?: boolean; html?: boolean }` | `{ menu: true, md: true, html: true }` |
@@ -8,10 +8,52 @@ title: Modal 对话框
8
8
 
9
9
  # Modal 对话框
10
10
 
11
- > `Modal` 组件。完整 API 见源码类型定义,下方为基础用法。
11
+ antd `Modal` 之上增强:默认垂直居中、可拖拽移动、边缘检测、一键全屏,并支持在标题区放置按钮组。
12
12
 
13
13
  ## 引入
14
14
 
15
15
  ```ts
16
16
  import { Modal } from "@hsu-react/ui";
17
17
  ```
18
+
19
+ ## 基础用法
20
+
21
+ 通过 `open` 受控显隐,配合 `Button` 切换状态。默认弹窗可按住标题栏拖动。
22
+
23
+ ```tsx
24
+ import React, { useState } from "react";
25
+ import { Modal, Button } from "@hsu-react/ui";
26
+
27
+ export default () => {
28
+ const [open, setOpen] = useState(false);
29
+
30
+ return (
31
+ <>
32
+ <Button type="primary" onClick={() => setOpen(true)}>
33
+ 打开对话框
34
+ </Button>
35
+ <Modal
36
+ title="标题"
37
+ open={open}
38
+ onOk={() => setOpen(false)}
39
+ onCancel={() => setOpen(false)}
40
+ >
41
+ <p>这是一段对话框内容,可按住标题栏拖动弹窗。</p>
42
+ </Modal>
43
+ </>
44
+ );
45
+ };
46
+ ```
47
+
48
+ ## API
49
+
50
+ 在 [antd ModalProps](https://ant.design/components/modal-cn) 基础上扩展:
51
+
52
+ | 属性 | 说明 | 类型 | 默认值 |
53
+ | --- | --- | --- | --- |
54
+ | moveable | 是否可拖拽标题栏移动弹窗 | `boolean` | `true` |
55
+ | edgeDetection | 拖拽时是否进行边缘检测,防止拖出视口 | `boolean` | `true` |
56
+ | full | 是否以全屏方式展示 | `boolean` | `false` |
57
+ | titleButtonGroup | 标题区右侧的按钮组配置 | `ButtonProps[]` | - |
58
+
59
+ > 其余属性(`open`、`onOk`、`onCancel`、`footer`、`width` 等)与 antd `Modal` 一致;`destroyOnClose` 默认为 `true`。
@@ -24,7 +24,7 @@
24
24
  padding: 0px 0px 15px;
25
25
  }
26
26
 
27
- .ant-modal-close {
27
+ :global(.ant-modal-close) {
28
28
  top: 15px;
29
29
  inset-inline-end: 10px;
30
30
  }
@@ -47,7 +47,7 @@
47
47
  }
48
48
  }
49
49
 
50
- .ant-modal-title {
50
+ :global(.ant-modal-title) {
51
51
  display: flex;
52
52
  align-items: center;
53
53
  justify-content: space-between;
@@ -8,10 +8,52 @@ title: Operate 操作
8
8
 
9
9
  # Operate 操作
10
10
 
11
- > `Operate` 组件。完整 API 见源码类型定义,下方为基础用法。
11
+ 表格操作列组件,支持单个操作按钮或一组操作按钮,内置二次确认、权限过滤,并在数量超出时自动收纳到「更多」下拉中。
12
12
 
13
13
  ## 引入
14
14
 
15
15
  ```ts
16
16
  import { Operate } from "@hsu-react/ui";
17
17
  ```
18
+
19
+ ## 基础用法
20
+
21
+ ```tsx
22
+ import React from "react";
23
+ import { Operate } from "@hsu-react/ui";
24
+ import { message } from "antd";
25
+
26
+ export default () => (
27
+ <Operate
28
+ title="更多"
29
+ menu={[
30
+ { title: "查看", onClick: () => message.info("查看") },
31
+ { title: "编辑", onClick: () => message.info("编辑") },
32
+ {
33
+ title: "删除",
34
+ delete: true,
35
+ onConfirm: () => message.success("已删除"),
36
+ },
37
+ ]}
38
+ />
39
+ );
40
+ ```
41
+
42
+ ## API
43
+
44
+ 在 antd `ButtonProps`(已排除 `children`、`title`、`onClick`、`hasPermi`)基础上扩展:
45
+
46
+ | 属性 | 说明 | 类型 | 默认值 |
47
+ | --- | --- | --- | --- |
48
+ | title | 按钮文本 | `ReactNode` | - |
49
+ | menu | 操作项列表(递归同 `OperateProps`),存在时渲染为按钮组 | `OperateProps[]` | `[]` |
50
+ | onClick | 点击回调 | `() => void` | - |
51
+ | onConfirm | 二次确认回调,存在时点击弹出 Popconfirm | `() => void` | - |
52
+ | icon | 自定义图标,`false` 时不显示 | `ReactNode \| false` | - |
53
+ | delete | 是否为删除操作(红色样式,默认删除图标) | `boolean` | - |
54
+ | popconfirm | Popconfirm 配置 | `Omit<PopconfirmProps, 'title'> & { title?: ReactNode }` | - |
55
+ | hidden | 是否隐藏(不渲染) | `boolean` | - |
56
+ | hasPermi | 权限码;无权限时不渲染 | `string[]` | - |
57
+ | maxVisible | 收纳前最多展示的操作数量 | `number` | `3` |
58
+ | enableEllipsis | 操作超出时是否启用「更多」收纳 | `boolean` | `true` |
59
+ | moreIcon | 「更多」按钮自定义图标,`false` 时不显示 | `ReactNode \| false` | - |
@@ -42,13 +42,13 @@
42
42
  }
43
43
 
44
44
  .moreButton {
45
- &.ant-btn-icon-only {
45
+ &:global(.ant-btn-icon-only) {
46
46
  width: max-content;
47
47
 
48
48
  padding-inline: 4px;
49
49
  }
50
50
 
51
- .ant-btn-icon {
51
+ :global(.ant-btn-icon) {
52
52
  display: inline-flex;
53
53
  align-items: center;
54
54
 
@@ -30,7 +30,7 @@
30
30
  width: 100%;
31
31
  height: 100%;
32
32
 
33
- > .ant-spin-container {
33
+ > :global(.ant-spin-container) {
34
34
  width: 100%;
35
35
  height: 100%;
36
36
 
@@ -25,7 +25,7 @@
25
25
  }
26
26
 
27
27
  .checkbox {
28
- .ant-checkbox {
28
+ :global(.ant-checkbox) {
29
29
  width: 14px;
30
30
  min-width: 14px;
31
31
  height: 14px;