@agentscope-ai/design 1.0.19 → 1.0.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.
Files changed (60) hide show
  1. package/lib/components/commonComponents/CodeBlock/index.js +21 -12
  2. package/llms/all.llms.txt +4976 -0
  3. package/llms/components/commonComponents/Alert/index.zh-CN.llms.txt +32 -0
  4. package/llms/components/commonComponents/AlertDialog/index.zh-CN.llms.txt +171 -0
  5. package/llms/components/commonComponents/Anchor/index.zh-CN.llms.txt +51 -0
  6. package/llms/components/commonComponents/Audio/index.zh-CN.llms.txt +7 -0
  7. package/llms/components/commonComponents/Avatar/index.zh-CN.llms.txt +37 -0
  8. package/llms/components/commonComponents/Breadcrumb/index.zh-CN.llms.txt +117 -0
  9. package/llms/components/commonComponents/Button/index.zh-CN.llms.txt +54 -0
  10. package/llms/components/commonComponents/Card/index.zh-CN.llms.txt +61 -0
  11. package/llms/components/commonComponents/Checkbox/index.zh-CN.llms.txt +69 -0
  12. package/llms/components/commonComponents/CodeBlock/index.zh-CN.llms.txt +13 -0
  13. package/llms/components/commonComponents/Collapse/index.zh-CN.llms.txt +56 -0
  14. package/llms/components/commonComponents/CollapsePanel/index.zh-CN.llms.txt +69 -0
  15. package/llms/components/commonComponents/DatePicker/index.zh-CN.llms.txt +221 -0
  16. package/llms/components/commonComponents/Descriptions/index.zh-CN.llms.txt +37 -0
  17. package/llms/components/commonComponents/Drawer/index.zh-CN.llms.txt +62 -0
  18. package/llms/components/commonComponents/Dropdown/index.zh-CN.llms.txt +149 -0
  19. package/llms/components/commonComponents/Empty/index.zh-CN.llms.txt +41 -0
  20. package/llms/components/commonComponents/FloatButton/index.zh-CN.llms.txt +51 -0
  21. package/llms/components/commonComponents/Form/index.zh-CN.llms.txt +558 -0
  22. package/llms/components/commonComponents/IconButton/index.zh-CN.llms.txt +45 -0
  23. package/llms/components/commonComponents/Image/index.zh-CN.llms.txt +165 -0
  24. package/llms/components/commonComponents/Input/index.zh-CN.llms.txt +133 -0
  25. package/llms/components/commonComponents/InputNumber/index.zh-CN.llms.txt +51 -0
  26. package/llms/components/commonComponents/Message/index.zh-CN.llms.txt +98 -0
  27. package/llms/components/commonComponents/Modal/index.zh-CN.llms.txt +168 -0
  28. package/llms/components/commonComponents/Notification/index.zh-CN.llms.txt +94 -0
  29. package/llms/components/commonComponents/Pagination/index.zh-CN.llms.txt +45 -0
  30. package/llms/components/commonComponents/Popconfirm/index.zh-CN.llms.txt +55 -0
  31. package/llms/components/commonComponents/Popover/index.zh-CN.llms.txt +43 -0
  32. package/llms/components/commonComponents/Progress/index.zh-CN.llms.txt +50 -0
  33. package/llms/components/commonComponents/PromptsEditor/index.zh-CN.llms.txt +15 -0
  34. package/llms/components/commonComponents/Radio/index.zh-CN.llms.txt +66 -0
  35. package/llms/components/commonComponents/RadioButton/index.zh-CN.llms.txt +73 -0
  36. package/llms/components/commonComponents/Result/index.zh-CN.llms.txt +10 -0
  37. package/llms/components/commonComponents/Select/index.zh-CN.llms.txt +96 -0
  38. package/llms/components/commonComponents/Skeleton/index.zh-CN.llms.txt +59 -0
  39. package/llms/components/commonComponents/Slider/index.zh-CN.llms.txt +62 -0
  40. package/llms/components/commonComponents/Spinner/index.zh-CN.llms.txt +15 -0
  41. package/llms/components/commonComponents/Statistic/index.zh-CN.llms.txt +58 -0
  42. package/llms/components/commonComponents/Steps/index.zh-CN.llms.txt +57 -0
  43. package/llms/components/commonComponents/Switch/index.zh-CN.llms.txt +39 -0
  44. package/llms/components/commonComponents/Table/index.zh-CN.llms.txt +254 -0
  45. package/llms/components/commonComponents/Tabs/index.zh-CN.llms.txt +68 -0
  46. package/llms/components/commonComponents/Tag/index.zh-CN.llms.txt +33 -0
  47. package/llms/components/commonComponents/TimePicker/index.zh-CN.llms.txt +111 -0
  48. package/llms/components/commonComponents/Tooltip/index.zh-CN.llms.txt +45 -0
  49. package/llms/components/commonComponents/Upload/index.zh-CN.llms.txt +95 -0
  50. package/llms/components/commonComponents/Video/index.zh-CN.llms.txt +11 -0
  51. package/llms/docs/guide/fromAntd.zh-CN.llms.txt +156 -0
  52. package/llms/docs/guide/fromScratch.zh-CN.llms.txt +83 -0
  53. package/llms/docs/guide/iconfont.zh-CN.llms.txt +69 -0
  54. package/llms/docs/guide/overview.zh-CN.llms.txt +51 -0
  55. package/llms/docs/guide/sparkIcons.zh-CN.llms.txt +25 -0
  56. package/llms/docs/guide/theme.zh-CN.llms.txt +61 -0
  57. package/llms/docs/guide/tokens&variables.zh-CN.llms.txt +433 -0
  58. package/llms/docs/guide/vibe-coding.zh-CN.llms.txt +29 -0
  59. package/llms/index.llms.txt +58 -0
  60. package/package.json +4 -2
@@ -0,0 +1,165 @@
1
+
2
+
3
+ <DemoTitle title="Image" desc="可预览的图片">
4
+ #### API
5
+
6
+ <AntdApiRef url="https://ant.design/components/image-cn/#api"></AntdApiRef>
7
+
8
+
9
+ ## antd API
10
+
11
+ 通用属性参考:[通用属性](/docs/react/common-props)
12
+
13
+ ### Image
14
+
15
+ | 参数 | 说明 | 类型 | 默认值 | 版本 |
16
+ |--------|--------|--------|--------|--------|
17
+ | alt | 图像描述 | string | - | 4.6.0 |
18
+ | fallback | 加载失败容错地址 | string | - | 4.6.0 |
19
+ | height | 图像高度 | string \| number | - | 4.6.0 |
20
+ | placeholder | 加载占位,为 | ReactNode | - | 4.6.0 |
21
+ | preview | 预览参数,为 | boolean \| | true | 4.6.0 |
22
+ | src | 图片地址 | string | - | 4.6.0 |
23
+ | width | 图像宽度 | string \| number | - | 4.6.0 |
24
+ | onError | 加载错误回调 | (event: Event) => void | - | 4.12.0 |
25
+
26
+
27
+ 其他属性见 [<img>](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img#Attributes)
28
+
29
+ ### PreviewType
30
+
31
+ | 参数 | 说明 | 类型 | 默认值 | 版本 |
32
+ |--------|--------|--------|--------|--------|
33
+ | visible | 是否显示 | boolean | - | - |
34
+ | src | 自定义预览 src | string | - | 4.10.0 |
35
+ | getContainer | 指定预览挂载的节点,但依旧为全屏展示,false 为挂载在当前位置 | string \| HTMLElement \| (() => HTMLElement) \| false | - | 4.8.0 |
36
+ | movable | 是否可移动 | boolean | true | 5.8.0 |
37
+ | mask | 缩略图遮罩 | ReactNode | - | 4.9.0 |
38
+ | maskClassName | 缩略图遮罩类名 | string | - | 4.11.0 |
39
+ | rootClassName | 预览图的根 DOM 类名 | string | - | 5.4.0 |
40
+ | scaleStep | 1 + scaleStep | number | 0.5 | - |
41
+ | minScale | 最小缩放倍数 | number | 1 | 5.7.0 |
42
+ | maxScale | 最大放大倍数 | number | 50 | 5.7.0 |
43
+ | closeIcon | 自定义关闭 Icon | React.ReactNode | - | 5.7.0 |
44
+ | forceRender | 强制渲染预览图 | boolean | - | - |
45
+ | toolbarRender | 自定义工具栏 | (originalNode: React.ReactElement, info: Omit< | - | 5.7.0, |
46
+ | imageRender | 自定义预览内容 | (originalNode: React.ReactElement, info: { transform: | - | 5.7.0, image: 5.18.0 |
47
+ | destroyOnHidden | 关闭预览时销毁子元素 | boolean | false | 5.25.0 |
48
+ | onTransform | 预览图 transform 变化的回调 | { transform: | - | 5.7.0 |
49
+ | onVisibleChange | 当 | (visible: boolean, prevVisible: boolean) => void | - | - |
50
+
51
+
52
+ ## PreviewGroup
53
+
54
+ | 参数 | 说明 | 类型 | 默认值 | 版本 |
55
+ |--------|--------|--------|--------|--------|
56
+ | preview | 预览参数,为 | boolean \| | true | 4.6.0 |
57
+ | items | 预览数组 | string[] \| { src: string, crossOrigin: string, ... }[] | - | 5.7.0 |
58
+ | fallback | 加载失败容错地址 | string | - | 5.7.0 |
59
+
60
+
61
+ ### PreviewGroupType
62
+
63
+ | 参数 | 说明 | 类型 | 默认值 | 版本 |
64
+ |--------|--------|--------|--------|--------|
65
+ | visible | 是否显示 | boolean | - | - |
66
+ | getContainer | 指定预览挂载的节点,但依旧为全屏展示,false 为挂载在当前位置 | string \| HTMLElement \| (() => HTMLElement) \| false | - | 4.8.0 |
67
+ | movable | 是否可移动 | boolean | true | 5.8.0 |
68
+ | current | 当前预览图的 index | number | - | 4.12.0 |
69
+ | mask | 缩略图遮罩 | ReactNode | - | 4.9.0 |
70
+ | maskClassName | 缩略图遮罩类名 | string | - | 4.11.0 |
71
+ | scaleStep | 1 + scaleStep | number | 0.5 | - |
72
+ | minScale | 最小缩放倍数 | number | 1 | 5.7.0 |
73
+ | maxScale | 最大放大倍数 | number | 50 | 5.7.0 |
74
+ | closeIcon | 自定义关闭 Icon | React.ReactNode | - | 5.7.0 |
75
+ | forceRender | 强制渲染预览图 | boolean | - | - |
76
+ | countRender | 自定义预览计数内容 | (current: number, total: number) => React.ReactNode | - | 4.20.0 |
77
+ | toolbarRender | 自定义工具栏 | (originalNode: React.ReactElement, info: | - | 5.7.0, |
78
+ | imageRender | 自定义预览内容 | (originalNode: React.ReactElement, info: { transform: | - | 5.7.0, image: 5.18.0 |
79
+ | onTransform | 预览图 transform 变化的回调 | { transform: | - | 5.7.0 |
80
+ | onChange | 切换预览图的回调 | (current: number, prevCurrent: number) => void | - | 5.3.0 |
81
+ | onVisibleChange | 当 | (visible: boolean, prevVisible: boolean, current: number) => void | - | current 参数 5.3.0 |
82
+
83
+
84
+ ## Interface
85
+
86
+ ### TransformType
87
+
88
+
89
+ ```typescript
90
+ {
91
+ x: number;
92
+ y: number;
93
+ rotate: number;
94
+ scale: number;
95
+ flipX: boolean;
96
+ flipY: boolean;
97
+ }
98
+ ```
99
+
100
+
101
+ ### TransformAction
102
+
103
+
104
+ ```typescript
105
+ type TransformAction =
106
+ | 'flipY'
107
+ | 'flipX'
108
+ | 'rotateLeft'
109
+ | 'rotateRight'
110
+ | 'zoomIn'
111
+ | 'zoomOut'
112
+ | 'close'
113
+ | 'prev'
114
+ | 'next'
115
+ | 'wheel'
116
+ | 'doubleClick'
117
+ | 'move'
118
+ | 'dragRebound'
119
+ | 'reset';
120
+ ```
121
+
122
+
123
+ ### ToolbarRenderInfoType
124
+
125
+
126
+ ```typescript
127
+ {
128
+ icons: {
129
+ flipYIcon: React.ReactNode;
130
+ flipXIcon: React.ReactNode;
131
+ rotateLeftIcon: React.ReactNode;
132
+ rotateRightIcon: React.ReactNode;
133
+ zoomOutIcon: React.ReactNode;
134
+ zoomInIcon: React.ReactNode;
135
+ };
136
+ actions: {
137
+ onActive?: (index: number) => void; // 5.21.0 之后支持
138
+ onFlipY: () => void;
139
+ onFlipX: () => void;
140
+ onRotateLeft: () => void;
141
+ onRotateRight: () => void;
142
+ onZoomOut: () => void;
143
+ onZoomIn: () => void;
144
+ onReset: () => void; // 5.17.3 之后支持
145
+ onClose: () => void;
146
+ };
147
+ transform: TransformType,
148
+ current: number;
149
+ total: number;
150
+ image: ImgInfo
151
+ }
152
+ ```
153
+
154
+
155
+ ### ImgInfo
156
+
157
+
158
+ ```typescript
159
+ {
160
+ url: string;
161
+ alt: string;
162
+ width: string | number;
163
+ height: string | number;
164
+ }
165
+ ```
@@ -0,0 +1,133 @@
1
+
2
+
3
+ <DemoTitle title="Input" desc="通过鼠标或键盘输入内容,为表单提供输入字段的基础容器。。">
4
+ #### API
5
+
6
+ | 属性名 | 描述 | 类型 | 默认值 |
7
+ |--------|--------|--------|--------|
8
+ | shape | 形态 | 'default' \| 'round' | default 默认 |
9
+
10
+
11
+ <AntdApiRef url="https://ant.design/components/input-cn/#api"></AntdApiRef>
12
+
13
+
14
+ ## antd API
15
+
16
+ 通用属性参考:[通用属性](/docs/react/common-props)
17
+
18
+ ### Input
19
+
20
+ | 参数 | 说明 | 类型 | 默认值 | 版本 |
21
+ |--------|--------|--------|--------|--------|
22
+ | addonAfter | 带标签的 input,设置后置标签 | ReactNode | - | |
23
+ | addonBefore | 带标签的 input,设置前置标签 | ReactNode | - | |
24
+ | allowClear | 可以点击清除图标删除内容 | boolean \| { clearIcon: ReactNode } | - | |
25
+ | classNames | 语义化结构 class | Record< | - | 5.4.0 |
26
+ | count | 字符计数配置 | | - | 5.10.0 |
27
+ | defaultValue | 输入框默认内容 | string | - | |
28
+ | disabled | 是否禁用状态,默认为 false | boolean | false | |
29
+ | id | 输入框的 id | string | - | |
30
+ | maxLength | 最大长度 | number | - | |
31
+ | prefix | 带有前缀图标的 input | ReactNode | - | |
32
+ | showCount | 是否展示字数 | boolean \| { formatter: (info: { value: string, count: number, maxLength?: number }) => ReactNode } | false | 4.18.0 info.value: 4.23.0 |
33
+ | status | 设置校验状态 | 'error' \| 'warning' | - | 4.19.0 |
34
+ | styles | 语义化结构 style | Record< | - | 5.4.0 |
35
+ | size | 控件大小。注:标准表单内的输入框大小限制为 | large | - | |
36
+ | suffix | 带有后缀图标的 input | ReactNode | - | |
37
+ | type | 声明 input 类型,同原生 input 标签的 type 属性,见: | string | text | |
38
+ | value | 输入框内容 | string | - | |
39
+ | variant | 形态变体 | outlined | outlined | 5.13.0 \| |
40
+ | onChange | 输入框内容变化时的回调 | function(e) | - | |
41
+ | onPressEnter | 按下回车的回调 | function(e) | - | |
42
+ | onClear | 按下清除按钮的回调 | () => void | - | 5.20.0 |
43
+
44
+
45
+ 如果 `Input` 在 `Form.Item` 内,并且 `Form.Item` 设置了 `id` 属性,则 `value` `defaultValue` 和 `id` 属性会被自动设置。
46
+
47
+ Input 的其他属性和 React 自带的 [input](https://reactjs.org/docs/dom-elements.html#all-supported-html-attributes) 一致。
48
+
49
+ #### CountConfig
50
+
51
+
52
+ ```tsx
53
+ interface CountConfig {
54
+ // 最大字符数,不同于原生 `maxLength`,超出后标红但不会截断
55
+ max?: number;
56
+ // 自定义字符计数,例如标准 emoji 长度大于 1,可以自定义计数策略将其改为 1
57
+ strategy?: (value: string) => number;
58
+ // 同 `showCount`
59
+ show?: boolean | ((args: { value: string; count: number; maxLength?: number }) => ReactNode);
60
+ // 当字符数超出 `count.max` 时的自定义裁剪逻辑,不配置时不进行裁剪
61
+ exceedFormatter?: (value: string, config: { max: number }) => string;
62
+ }
63
+ ```
64
+
65
+
66
+ ### Input.TextArea
67
+
68
+ 同 Input 属性,外加:
69
+
70
+ | 参数 | 说明 | 类型 | 默认值 | 版本 |
71
+ |--------|--------|--------|--------|--------|
72
+ | autoSize | 自适应内容高度,可设置为 true \| false 或对象:{ minRows: 2, maxRows: 6 } | boolean \| object | false | |
73
+ | classNames | 语义化结构 class | Record< | - | 5.4.0 |
74
+ | styles | 语义化结构 style | Record< | - | 5.4.0 |
75
+
76
+
77
+ `Input.TextArea` 的其他属性和浏览器自带的 [textarea](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/textarea) 一致。
78
+
79
+ ### Input.Search
80
+
81
+ | 参数 | 说明 | 类型 | 默认值 |
82
+ |--------|--------|--------|--------|
83
+ | enterButton | 是否有确认按钮,可设为按钮文字。该属性会与 | ReactNode | false |
84
+ | loading | 搜索 loading | boolean | false |
85
+ | onSearch | 点击搜索图标、清除图标,或按下回车键时的回调 | function(value, event, { source: "input" \| "clear" }) | - |
86
+
87
+
88
+ 其余属性和 Input 一致。
89
+
90
+ ### Input.Password
91
+
92
+ | 参数 | 说明 | 类型 | 默认值 | 版本 |
93
+ |--------|--------|--------|--------|--------|
94
+ | iconRender | 自定义切换按钮 | (visible) => ReactNode | (visible) => (visible ? : ) | 4.3.0 |
95
+ | visibilityToggle | 是否显示切换按钮或者控制密码显隐 | boolean \| | true | |
96
+
97
+
98
+ ### Input.OTP
99
+
100
+ `5.16.0` 新增。
101
+
102
+ 开发者注意事项:当 `mask` 属性的类型为 string 时,我们强烈推荐接收单个字符或单个 emoji,如果传入多个字符或多个 emoji,则会在控制台抛出警告。
103
+
104
+ | 参数 | 说明 | 类型 | 默认值 | 版本 |
105
+ |--------|--------|--------|--------|--------|
106
+ | defaultValue | 默认值 | string | - | |
107
+ | disabled | 是否禁用 | boolean | false | |
108
+ | formatter | 格式化展示,留空字段会被 | (value: string) => string | - | |
109
+ | separator | 分隔符,在指定索引的输入框后渲染分隔符 | ReactNode \|((i: number) => ReactNode) | - | 5.24.0 |
110
+ | mask | 自定义展示,和 | boolean \| string | false | 5.17.0 |
111
+ | length | 输入元素数量 | number | 6 | |
112
+ | status | 设置校验状态 | 'error' \| 'warning' | - | |
113
+ | size | 输入框大小 | small | middle | |
114
+ | variant | 形态变体 | outlined | outlined | underlined |
115
+ | value | 输入框内容 | string | - | |
116
+ | onChange | 当输入框内容全部填充时触发回调 | (value: string) => void | - | |
117
+ | onInput | 输入值变化时触发的回调 | (value: string[]) => void | - | 5.22.0 |
118
+
119
+
120
+ #### VisibilityToggle
121
+
122
+ | Property | Description | Type | Default | Version |
123
+ |--------|--------|--------|--------|--------|
124
+ | visible | 用于手动控制密码显隐 | boolean | false | 4.24 |
125
+ | onVisibleChange | 显隐密码的回调 | (visible) => void | - | 4.24 |
126
+
127
+
128
+ #### Input Methods
129
+
130
+ | 名称 | 说明 | 参数 | 版本 |
131
+ |--------|--------|--------|--------|
132
+ | blur | 取消焦点 | - | |
133
+ | focus | 获取焦点 | (option?: { preventScroll?: boolean, cursor?: 'start' \| 'end' \| 'all' }) | option - 4.10.0 |
@@ -0,0 +1,51 @@
1
+
2
+
3
+ <DemoTitle title="InputNumber" desc="通过鼠标或键盘,输入范围内的数值。">
4
+ #### API
5
+
6
+ <AntdApiRef url="https://ant.design/components/input-number-cn/#api"></AntdApiRef>
7
+
8
+
9
+ ## antd API
10
+
11
+ 通用属性参考:[通用属性](/docs/react/common-props)
12
+
13
+ | 参数 | 说明 | 类型 | 默认值 | 版本 |
14
+ |--------|--------|--------|--------|--------|
15
+ | addonAfter | 带标签的 input,设置后置标签 | ReactNode | - | 4.17.0 |
16
+ | addonBefore | 带标签的 input,设置前置标签 | ReactNode | - | 4.17.0 |
17
+ | autoFocus | 自动获取焦点 | boolean | false | - |
18
+ | changeOnBlur | 是否在失去焦点时,触发 | boolean | true | 5.11.0 |
19
+ | changeOnWheel | 允许鼠标滚轮改变数值 | boolean | - | 5.14.0 |
20
+ | controls | 是否显示增减按钮,也可设置自定义箭头图标 | boolean \| { upIcon?: React.ReactNode; downIcon?: React.ReactNode; } | - | 4.19.0 |
21
+ | decimalSeparator | 小数点 | string | - | - |
22
+ | placeholder | 占位符 | string | - | |
23
+ | defaultValue | 初始值 | number | - | - |
24
+ | disabled | 禁用 | boolean | false | - |
25
+ | formatter | 指定输入框展示值的格式 | function(value: number \| string, info: { userTyping: boolean, input: string }): string | - | info: 4.17.0 |
26
+ | keyboard | 是否启用键盘快捷行为 | boolean | true | 4.12.0 |
27
+ | max | 最大值 | number | | - |
28
+ | min | 最小值 | number | | - |
29
+ | parser | 指定从 | function(string): number | - | - |
30
+ | precision | 数值精度,配置 | number | - | - |
31
+ | readOnly | 只读 | boolean | false | - |
32
+ | status | 设置校验状态 | 'error' \| 'warning' | - | 4.19.0 |
33
+ | prefix | 带有前缀图标的 input | ReactNode | - | 4.17.0 |
34
+ | suffix | 带有后缀图标的 input | ReactNode | - | 5.20.0 |
35
+ | size | 输入框大小 | large | - | - |
36
+ | step | 每次改变步数,可以为小数 | number \| string | 1 | - |
37
+ | stringMode | 字符值模式,开启后支持高精度小数。同时 | boolean | false | 4.13.0 |
38
+ | value | 当前值 | number | - | - |
39
+ | variant | 形态变体 | outlined | outlined | 5.13.0 \| |
40
+ | onChange | 变化回调 | function(value: number \| string \| null) | - | - |
41
+ | onPressEnter | 按下回车的回调 | function(e) | - | - |
42
+ | onStep | 点击上下箭头的回调 | (value: number, info: { offset: number, type: 'up' \| 'down' }) => void | - | 4.7.0 |
43
+
44
+
45
+ ## Ref
46
+
47
+ | 名称 | 说明 | 参数 | 版本 |
48
+ |--------|--------|--------|--------|
49
+ | blur() | 移除焦点 | - | |
50
+ | focus() | 获取焦点 | (option?: { preventScroll?: boolean, cursor?: 'start' \| 'end' \| 'all' }) | cursor - 5.22.0 |
51
+ | nativeElement | 获取原生 DOM 元素 | - | 5.17.3 |
@@ -0,0 +1,98 @@
1
+
2
+
3
+ <DemoTitle title="Message" desc="一条简洁且临时显示的消息,为操作提供全局反馈">
4
+ #### API
5
+
6
+ | 属性名 | 描述 | 类型 | 默认值 |
7
+ |--------|--------|--------|--------|
8
+ | conent | 显示的内容 | string | "" |
9
+
10
+ <AntdApiRef url="https://ant.design/components/message-cn/#api"></AntdApiRef>
11
+
12
+
13
+ ## antd API
14
+
15
+ 通用属性参考:[通用属性](/docs/react/common-props)
16
+
17
+ 组件提供了一些静态方法,使用方式和参数如下:
18
+
19
+
20
+ - `message.success(content, [duration], onClose)`
21
+ - `message.error(content, [duration], onClose)`
22
+ - `message.info(content, [duration], onClose)`
23
+ - `message.warning(content, [duration], onClose)`
24
+ - `message.loading(content, [duration], onClose)`
25
+
26
+ | 参数 | 说明 | 类型 | 默认值 |
27
+ |--------|--------|--------|--------|
28
+ | content | 提示内容 | ReactNode \| config | - |
29
+ | duration | 自动关闭的延时,单位秒。设为 0 时不自动关闭 | number | 3 |
30
+ | onClose | 关闭时触发的回调函数 | function | - |
31
+
32
+
33
+ 组件同时提供 promise 接口。
34
+
35
+
36
+ - `message[level](content, [duration]).then(afterClose)`
37
+ - `message[level](content, [duration], onClose).then(afterClose)`
38
+
39
+ 其中 `message[level]` 是组件已经提供的静态方法。`then` 接口返回值是 Promise。
40
+
41
+ 也可以对象的形式传递参数:
42
+
43
+
44
+ - `message.open(config)`
45
+ - `message.success(config)`
46
+ - `message.error(config)`
47
+ - `message.info(config)`
48
+ - `message.warning(config)`
49
+ - `message.loading(config)`
50
+
51
+ `config` 对象属性如下:
52
+
53
+ | 参数 | 说明 | 类型 | 默认值 |
54
+ |--------|--------|--------|--------|
55
+ | className | 自定义 CSS class | string | - |
56
+ | content | 提示内容 | ReactNode | - |
57
+ | duration | 自动关闭的延时,单位秒。设为 0 时不自动关闭 | number | 3 |
58
+ | icon | 自定义图标 | ReactNode | - |
59
+ | key | 当前提示的唯一标志 | string \| number | - |
60
+ | style | 自定义内联样式 | | - |
61
+ | onClick | 点击 message 时触发的回调函数 | function | - |
62
+ | onClose | 关闭时触发的回调函数 | function | - |
63
+
64
+
65
+ ### 全局方法
66
+
67
+ 还提供了全局配置和全局销毁方法:
68
+
69
+
70
+ - `message.config(options)`
71
+ - `message.destroy()`
72
+
73
+ 也可通过 `message.destroy(key)` 来关闭一条消息。
74
+
75
+ #### message.config
76
+
77
+ 当你使用 `ConfigProvider` 进行全局化配置时,系统会默认自动开启 RTL 模式。(4.3.0+)当你想单独使用,可通过如下设置开启 RTL 模式。
78
+
79
+
80
+ ```js
81
+ message.config({
82
+ top: 100,
83
+ duration: 2,
84
+ maxCount: 3,
85
+ rtl: true,
86
+ prefixCls: 'my-message',
87
+ });
88
+ ```
89
+
90
+
91
+ | 参数 | 说明 | 类型 | 默认值 | 版本 |
92
+ |--------|--------|--------|--------|--------|
93
+ | duration | 默认自动关闭延时,单位秒 | number | 3 | |
94
+ | getContainer | 配置渲染节点的输出位置,但依旧为全屏展示 | () => HTMLElement | () => document.body | |
95
+ | maxCount | 最大显示数,超过限制时,最早的消息会被自动关闭 | number | - | |
96
+ | prefixCls | 消息节点的 className 前缀 | string | ant-message | 4.5.0 |
97
+ | rtl | 是否开启 RTL 模式 | boolean | false | |
98
+ | top | 消息距离顶部的位置 | string \| number | 8 | |
@@ -0,0 +1,168 @@
1
+
2
+
3
+ <DemoTitle title="Modal" desc="用于叠加当前页面上的对话框窗口,提供标题、内容区、操作区。">
4
+ #### API
5
+
6
+ | 属性名 | 描述 | 类型 | 默认值 |
7
+ |--------|--------|--------|--------|
8
+ | info | 底部额外内容 | string \| React.ReactNode | |
9
+ | showDivider | 是否显示分割线 | boolean | true |
10
+
11
+ <AntdApiRef url="https://ant.design/components/modal-cn/#api"></AntdApiRef>
12
+
13
+
14
+ ## antd API
15
+
16
+ 通用属性参考:[通用属性](/docs/react/common-props)
17
+
18
+ | 参数 | 说明 | 类型 | 默认值 | 版本 |
19
+ |--------|--------|--------|--------|--------|
20
+ | afterClose | Modal 完全关闭后的回调 | function | - | |
21
+ | classNames | 配置弹窗内置模块的 className | | - | |
22
+ | styles | 配置弹窗内置模块的 style | | - | 5.10.0 |
23
+ | cancelButtonProps | cancel 按钮 props | | - | |
24
+ | cancelText | 取消按钮文字 | ReactNode | 取消 | |
25
+ | centered | 垂直居中展示 Modal | boolean | false | |
26
+ | closable | 是否显示右上角的关闭按钮 | boolean \| { closeIcon?: React.ReactNode; disabled?: boolean; } | true | |
27
+ | closeIcon | 自定义关闭图标。5.7.0:设置为 | ReactNode | | |
28
+ | confirmLoading | 确定按钮 loading | boolean | false | |
29
+ | destroyOnHidden | 关闭时销毁 Modal 里的子元素 | boolean | false | 5.25.0 |
30
+ | focusTriggerAfterClose | 对话框关闭后是否需要聚焦触发元素 | boolean | true | 4.9.0 |
31
+ | footer | 底部内容,当不需要默认底部按钮时,可以设为 | ReactNode \| (originNode: ReactNode, extra: { OkBtn: React.FC, CancelBtn: React.FC }) => ReactNode | (确定取消按钮) | renderFunction: 5.9.0 |
32
+ | forceRender | 强制渲染 Modal | boolean | false | |
33
+ | getContainer | 指定 Modal 挂载的节点,但依旧为全屏展示, | HTMLElement \| () => HTMLElement \| Selectors \| false | document.body | |
34
+ | keyboard | 是否支持键盘 esc 关闭 | boolean | true | |
35
+ | mask | 是否展示遮罩 | boolean | true | |
36
+ | maskClosable | 点击蒙层是否允许关闭 | boolean | true | |
37
+ | modalRender | 自定义渲染对话框 | (node: ReactNode) => ReactNode | - | 4.7.0 |
38
+ | okButtonProps | ok 按钮 props | | - | |
39
+ | okText | 确认按钮文字 | ReactNode | 确定 | |
40
+ | okType | 确认按钮类型 | string | primary | |
41
+ | style | 可用于设置浮层的样式,调整浮层位置等 | CSSProperties | - | |
42
+ | loading | 显示骨架屏 | boolean | | 5.18.0 |
43
+ | title | 标题 | ReactNode | - | |
44
+ | open | 对话框是否可见 | boolean | - | |
45
+ | width | 宽度 | string \| number \| | 520 | Breakpoint: 5.23.0 |
46
+ | wrapClassName | 对话框外层容器的类名 | string | - | |
47
+ | zIndex | 设置 Modal 的 | number | 1000 | |
48
+ | onCancel | 点击遮罩层或右上角叉或取消按钮的回调 | function(e) | - | |
49
+ | onOk | 点击确定回调 | function(e) | - | |
50
+ | afterOpenChange | 打开和关闭 Modal 时动画结束后的回调 | (open: boolean) => void | - | 5.4.0 |
51
+
52
+
53
+ #### 注意
54
+
55
+
56
+ - `<Modal />` 默认关闭后状态不会自动清空,如果希望每次打开都是新内容,请设置 `destroyOnHidden`。
57
+ - `<Modal />` 和 Form 一起配合使用时,设置 `destroyOnHidden` 也不会在 Modal 关闭时销毁表单字段数据,需要设置 `<Form preserve={false} />`。
58
+ - `Modal.method()` RTL 模式仅支持 hooks 用法。
59
+
60
+ ### Modal.method()
61
+
62
+ 包括:
63
+
64
+
65
+ - `Modal.info`
66
+ - `Modal.success`
67
+ - `Modal.error`
68
+ - `Modal.warning`
69
+ - `Modal.confirm`
70
+
71
+ 以上均为一个函数,参数为 object,具体属性如下:
72
+
73
+ | 参数 | 说明 | 类型 | 默认值 | 版本 |
74
+ |--------|--------|--------|--------|--------|
75
+ | afterClose | Modal 完全关闭后的回调 | function | - | 4.9.0 |
76
+ | autoFocusButton | 指定自动获得焦点的按钮 | null \| | ok | |
77
+ | cancelButtonProps | cancel 按钮 props | | - | |
78
+ | cancelText | 设置 Modal.confirm 取消按钮文字 | string | 取消 | |
79
+ | centered | 垂直居中展示 Modal | boolean | false | |
80
+ | className | 容器类名 | string | - | |
81
+ | closable | 是否显示右上角的关闭按钮 | boolean | false | 4.9.0 |
82
+ | closeIcon | 自定义关闭图标 | ReactNode | undefined | 4.9.0 |
83
+ | content | 内容 | ReactNode | - | |
84
+ | footer | 底部内容,当不需要默认底部按钮时,可以设为 | ReactNode \| (originNode: ReactNode, extra: { OkBtn: React.FC, CancelBtn: React.FC }) => ReactNode | - | renderFunction: 5.9.0 |
85
+ | getContainer | 指定 Modal 挂载的 HTML 节点,false 为挂载在当前 dom | HTMLElement \| () => HTMLElement \| Selectors \| false | document.body | |
86
+ | icon | 自定义图标 | ReactNode | | |
87
+ | keyboard | 是否支持键盘 esc 关闭 | boolean | true | |
88
+ | mask | 是否展示遮罩 | boolean | true | |
89
+ | maskClosable | 点击蒙层是否允许关闭 | boolean | false | |
90
+ | okButtonProps | ok 按钮 props | | - | |
91
+ | okText | 确认按钮文字 | string | 确定 | |
92
+ | okType | 确认按钮类型 | string | primary | |
93
+ | style | 可用于设置浮层的样式,调整浮层位置等 | CSSProperties | - | |
94
+ | title | 标题 | ReactNode | - | |
95
+ | width | 宽度 | string \| number | 416 | |
96
+ | wrapClassName | 对话框外层容器的类名 | string | - | 4.18.0 |
97
+ | zIndex | 设置 Modal 的 | number | 1000 | |
98
+ | onCancel | 点击取消回调,参数为关闭函数,若返回 promise 时 resolve 为正常关闭, reject 为不关闭 | function(close) | - | |
99
+ | onOk | 点击确定回调,参数为关闭函数,若返回 promise 时 resolve 为正常关闭, reject 为不关闭 | function(close) | - | |
100
+
101
+
102
+ 以上函数调用后,会返回一个引用,可以通过该引用更新和关闭弹窗。
103
+
104
+
105
+ ```jsx
106
+ const modal = Modal.info();
107
+
108
+ modal.update({
109
+ title: '修改的标题',
110
+ content: '修改的内容',
111
+ });
112
+
113
+ // 在 4.8.0 或更高版本中,可以通过传入函数的方式更新弹窗
114
+ modal.update((prevConfig) => ({
115
+ ...prevConfig,
116
+ title: `${prevConfig.title}(新)`,
117
+ }));
118
+
119
+ modal.destroy();
120
+ ```
121
+
122
+
123
+
124
+ - `Modal.destroyAll`
125
+
126
+ 使用 `Modal.destroyAll()` 可以销毁弹出的确认窗(即上述的 `Modal.info`、`Modal.success`、`Modal.error`、`Modal.warning`、`Modal.confirm`)。通常用于路由监听当中,处理路由前进、后退不能销毁确认对话框的问题,而不用各处去使用实例的返回值进行关闭(`modal.destroy()` 适用于主动关闭,而不是路由这样被动关闭)
127
+
128
+
129
+ ```jsx
130
+ import { browserHistory } from 'react-router';
131
+
132
+ // router change
133
+ browserHistory.listen(() => {
134
+ Modal.destroyAll();
135
+ });
136
+ ```
137
+
138
+
139
+ ### Modal.useModal()
140
+
141
+ 当你需要使用 Context 时,可以通过 `Modal.useModal` 创建一个 `contextHolder` 插入子节点中。通过 hooks 创建的临时 Modal 将会得到 `contextHolder` 所在位置的所有上下文。创建的 `modal` 对象拥有与 [`Modal.method`](#modalmethod) 相同的创建通知方法。
142
+
143
+
144
+ ```jsx
145
+ const [modal, contextHolder] = Modal.useModal();
146
+
147
+ React.useEffect(() => {
148
+ modal.confirm({
149
+ // ...
150
+ });
151
+ }, []);
152
+
153
+ return <div>{contextHolder}</div>;
154
+ ```
155
+
156
+
157
+ `modal.confirm` 返回方法:
158
+
159
+
160
+ - `destroy`:销毁当前窗口
161
+ - `update`:更新当前窗口
162
+ - `then`:Promise 链式调用,支持 `await` 操作。该方法为 Hooks 仅有
163
+
164
+
165
+ ```tsx
166
+ //点击 `onOk` 时返回 `true`,点击 `onCancel` 时返回 `false`
167
+ const confirmed = await modal.confirm({ ... });
168
+ ```