@alifd/chat 0.3.40-beta.0 → 0.3.40-beta.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.
- package/es/ai-loading/types.d.ts +1 -0
- package/es/button/button.d.ts +1 -2
- package/es/button/button.js +13 -19
- package/es/button/group.js +5 -42
- package/es/button/main.scss +36 -77
- package/es/card/main.scss +1 -1
- package/es/checkbox-group/main.scss +6 -7
- package/es/checkbox-group/types.d.ts +6 -0
- package/es/code-view/index.d.ts +11 -0
- package/es/code-view/index.js +63 -0
- package/es/code-view/main.scss +54 -0
- package/es/code-view/style.d.ts +4 -0
- package/es/code-view/style.js +4 -0
- package/es/code-view/types.d.ts +27 -0
- package/es/code-view/types.js +1 -0
- package/es/collapse/index.d.ts +157 -0
- package/es/collapse/index.js +20 -0
- package/es/collapse/main.scss +97 -0
- package/es/collapse/style.d.ts +2 -0
- package/es/collapse/style.js +2 -0
- package/es/collapse/types.d.ts +82 -0
- package/es/collapse/types.js +2 -0
- package/es/core/variables.scss +27 -12
- package/es/date-picker/DatePicker.d.ts +5 -0
- package/es/date-picker/DatePicker.js +15 -0
- package/es/date-picker/MonthPicker.d.ts +4 -0
- package/es/date-picker/MonthPicker.js +15 -0
- package/es/date-picker/RangePicker.d.ts +4 -0
- package/es/date-picker/RangePicker.js +17 -0
- package/es/date-picker/YearPicker.d.ts +4 -0
- package/es/date-picker/YearPicker.js +15 -0
- package/es/date-picker/index.d.ts +5 -23
- package/es/date-picker/index.js +11 -29
- package/es/date-picker/main.scss +23 -1
- package/es/date-picker/style.d.ts +1 -0
- package/es/date-picker/style.js +1 -0
- package/es/date-picker/types.d.ts +161 -81
- package/es/float-button/hooks/useAutoAlign.d.ts +1 -1
- package/es/form/style.d.ts +0 -1
- package/es/form/style.js +2 -1
- package/es/form/types.d.ts +3 -517
- package/es/form/types.js +5 -1
- package/es/html-render/index.d.ts +1 -1
- package/es/html-render/index.js +118 -106
- package/es/html-render/main.scss +27 -8
- package/es/html-render/style.d.ts +1 -0
- package/es/html-render/style.js +1 -0
- package/es/icon/index.d.ts +1 -1
- package/es/index.d.ts +3 -0
- package/es/index.js +4 -1
- package/es/input/index.d.ts +1 -1
- package/es/input/index.js +16 -6
- package/es/input/main.scss +25 -0
- package/es/input/style.d.ts +1 -0
- package/es/input/style.js +1 -0
- package/es/input/types.d.ts +58 -15
- package/es/markdown/index.d.ts +1 -2
- package/es/markdown/index.js +26 -15
- package/es/markdown/main.scss +4 -3
- package/es/markdown/style.d.ts +2 -1
- package/es/markdown/style.js +2 -1
- package/es/markdown/types.d.ts +20 -9
- package/es/message/index.d.ts +4 -4
- package/es/person-picker/index.d.ts +3 -190
- package/es/person-picker/index.js +23 -21
- package/es/person-picker/main.scss +15 -1
- package/es/person-picker/types.d.ts +53 -11
- package/es/radio-group/index.d.ts +1 -1
- package/es/radio-group/index.js +9 -3
- package/es/radio-group/main.scss +13 -5
- package/es/radio-group/types.d.ts +5 -3
- package/es/reference/index.d.ts +1 -1
- package/es/reference/index.js +14 -15
- package/es/reference/main.scss +1 -1
- package/es/reference/types.d.ts +1 -0
- package/es/select/button.d.ts +3 -0
- package/es/select/button.js +70 -0
- package/es/select/index.d.ts +79 -79
- package/es/select/index.js +13 -57
- package/es/select/main.scss +22 -4
- package/es/select/types.d.ts +108 -1
- package/es/step/index.js +2 -2
- package/es/step/main.scss +115 -66
- package/es/step/types.d.ts +13 -2
- package/es/table/index.d.ts +12 -0
- package/es/table/index.js +23 -0
- package/es/table/main.scss +30 -0
- package/es/table/style.d.ts +2 -0
- package/es/table/style.js +2 -0
- package/es/table/types.d.ts +98 -0
- package/es/table/types.js +1 -0
- package/es/tag/index.d.ts +5 -3
- package/es/tag/index.js +18 -2
- package/es/tag/main.scss +20 -4
- package/es/tag/types.d.ts +55 -0
- package/es/text/index.js +1 -1
- package/es/text/main.scss +4 -1
- package/es/text/types.d.ts +8 -0
- package/es/time-picker/index.d.ts +6 -15
- package/es/time-picker/index.js +71 -24
- package/es/time-picker/main.scss +19 -1
- package/es/time-picker/style.d.ts +1 -0
- package/es/time-picker/style.js +1 -0
- package/es/time-picker/types.d.ts +133 -8
- package/es/tool-status/index.d.ts +1 -1
- package/es/tool-status/index.js +1 -1
- package/es/tool-status/main.scss +2 -1
- package/es/tool-status/types.d.ts +7 -2
- package/es/utils/func.d.ts +1 -0
- package/es/utils/func.js +13 -0
- package/es/utils/github-dark.scss +137 -0
- package/es/utils/github.scss +137 -0
- package/es/utils/hoc/main.scss +166 -0
- package/es/utils/hoc/withLabel.d.ts +94 -0
- package/es/utils/hoc/withLabel.js +57 -0
- package/es/utils/index.d.ts +1 -0
- package/es/utils/index.js +1 -0
- package/lib/ai-loading/types.d.ts +1 -0
- package/lib/button/button.d.ts +1 -2
- package/lib/button/button.js +13 -19
- package/lib/button/group.js +4 -41
- package/lib/button/main.scss +36 -77
- package/lib/card/main.scss +1 -1
- package/lib/checkbox-group/main.scss +6 -7
- package/lib/checkbox-group/types.d.ts +6 -0
- package/lib/code-view/index.d.ts +11 -0
- package/lib/code-view/index.js +66 -0
- package/lib/code-view/main.scss +54 -0
- package/lib/code-view/style.d.ts +4 -0
- package/lib/code-view/style.js +6 -0
- package/lib/code-view/types.d.ts +27 -0
- package/lib/code-view/types.js +2 -0
- package/lib/collapse/index.d.ts +157 -0
- package/lib/collapse/index.js +22 -0
- package/lib/collapse/main.scss +97 -0
- package/lib/collapse/style.d.ts +2 -0
- package/lib/collapse/style.js +4 -0
- package/lib/collapse/types.d.ts +82 -0
- package/lib/collapse/types.js +3 -0
- package/lib/core/variables.scss +27 -12
- package/lib/date-picker/DatePicker.d.ts +5 -0
- package/lib/date-picker/DatePicker.js +17 -0
- package/lib/date-picker/MonthPicker.d.ts +4 -0
- package/lib/date-picker/MonthPicker.js +17 -0
- package/lib/date-picker/RangePicker.d.ts +4 -0
- package/lib/date-picker/RangePicker.js +19 -0
- package/lib/date-picker/YearPicker.d.ts +4 -0
- package/lib/date-picker/YearPicker.js +17 -0
- package/lib/date-picker/index.d.ts +5 -23
- package/lib/date-picker/index.js +10 -27
- package/lib/date-picker/main.scss +23 -1
- package/lib/date-picker/style.d.ts +1 -0
- package/lib/date-picker/style.js +1 -0
- package/lib/date-picker/types.d.ts +161 -81
- package/lib/float-button/hooks/useAutoAlign.d.ts +1 -1
- package/lib/form/style.d.ts +0 -1
- package/lib/form/style.js +1 -2
- package/lib/form/types.d.ts +3 -517
- package/lib/form/types.js +4 -1
- package/lib/html-render/index.d.ts +1 -1
- package/lib/html-render/index.js +118 -106
- package/lib/html-render/main.scss +27 -8
- package/lib/html-render/style.d.ts +1 -0
- package/lib/html-render/style.js +1 -0
- package/lib/icon/index.d.ts +1 -1
- package/lib/index.d.ts +3 -0
- package/lib/index.js +8 -2
- package/lib/input/index.d.ts +1 -1
- package/lib/input/index.js +16 -6
- package/lib/input/main.scss +25 -0
- package/lib/input/style.d.ts +1 -0
- package/lib/input/style.js +1 -0
- package/lib/input/types.d.ts +58 -15
- package/lib/markdown/index.d.ts +1 -2
- package/lib/markdown/index.js +26 -15
- package/lib/markdown/main.scss +4 -3
- package/lib/markdown/style.d.ts +2 -1
- package/lib/markdown/style.js +2 -1
- package/lib/markdown/types.d.ts +20 -9
- package/lib/message/index.d.ts +4 -4
- package/lib/person-picker/index.d.ts +3 -190
- package/lib/person-picker/index.js +22 -20
- package/lib/person-picker/main.scss +15 -1
- package/lib/person-picker/types.d.ts +53 -11
- package/lib/radio-group/index.d.ts +1 -1
- package/lib/radio-group/index.js +8 -2
- package/lib/radio-group/main.scss +13 -5
- package/lib/radio-group/types.d.ts +5 -3
- package/lib/reference/index.d.ts +1 -1
- package/lib/reference/index.js +17 -18
- package/lib/reference/main.scss +1 -1
- package/lib/reference/types.d.ts +1 -0
- package/lib/select/button.d.ts +3 -0
- package/lib/select/button.js +74 -0
- package/lib/select/index.d.ts +79 -79
- package/lib/select/index.js +11 -55
- package/lib/select/main.scss +22 -4
- package/lib/select/types.d.ts +108 -1
- package/lib/step/index.js +2 -2
- package/lib/step/main.scss +115 -66
- package/lib/step/types.d.ts +13 -2
- package/lib/table/index.d.ts +12 -0
- package/lib/table/index.js +25 -0
- package/lib/table/main.scss +30 -0
- package/lib/table/style.d.ts +2 -0
- package/lib/table/style.js +4 -0
- package/lib/table/types.d.ts +98 -0
- package/lib/table/types.js +2 -0
- package/lib/tag/index.d.ts +5 -3
- package/lib/tag/index.js +17 -1
- package/lib/tag/main.scss +20 -4
- package/lib/tag/types.d.ts +55 -0
- package/lib/text/index.js +1 -1
- package/lib/text/main.scss +4 -1
- package/lib/text/types.d.ts +8 -0
- package/lib/time-picker/index.d.ts +6 -15
- package/lib/time-picker/index.js +71 -23
- package/lib/time-picker/main.scss +19 -1
- package/lib/time-picker/style.d.ts +1 -0
- package/lib/time-picker/style.js +1 -0
- package/lib/time-picker/types.d.ts +133 -8
- package/lib/tool-status/index.d.ts +1 -1
- package/lib/tool-status/index.js +1 -1
- package/lib/tool-status/main.scss +2 -1
- package/lib/tool-status/types.d.ts +7 -2
- package/lib/utils/func.d.ts +1 -0
- package/lib/utils/func.js +15 -0
- package/lib/utils/github-dark.scss +137 -0
- package/lib/utils/github.scss +137 -0
- package/lib/utils/hoc/main.scss +166 -0
- package/lib/utils/hoc/withLabel.d.ts +94 -0
- package/lib/utils/hoc/withLabel.js +60 -0
- package/lib/utils/index.d.ts +1 -0
- package/lib/utils/index.js +1 -0
- package/package.json +49 -4
- package/es/form/index.d.ts +0 -23
- package/es/form/index.js +0 -33
- package/es/form/main.scss +0 -5
- package/lib/form/index.d.ts +0 -23
- package/lib/form/index.js +0 -35
- package/lib/form/main.scss +0 -5
package/es/ai-loading/types.d.ts
CHANGED
package/es/button/button.d.ts
CHANGED
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
* @component 按钮
|
|
3
3
|
* @en Button
|
|
4
4
|
* @type 通用 - General
|
|
5
|
-
* @remarks
|
|
6
|
-
* @when 标记一个(或封装一组)操作命令,响应用户点击行为,触发相应的业务逻辑。- Buttons are used for emphasizing important functions on your page.
|
|
5
|
+
* @remarks [按钮组件] 是一个 [操作类] UI 组件,用于 [触发用户交互动作],包括点击、悬停等行为,使用户能够 [执行命令、提交表单、切换状态等]。它在卡片中扮演 [核心操作入口] 的角色,通常用于 [表单提交、功能切换、数据操作等场景]。
|
|
7
6
|
* @others
|
|
8
7
|
* ## 无障碍键盘操作指南
|
|
9
8
|
* | 按键 | 说明 |
|
package/es/button/button.js
CHANGED
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
* @component 按钮
|
|
3
3
|
* @en Button
|
|
4
4
|
* @type 通用 - General
|
|
5
|
-
* @remarks
|
|
6
|
-
* @when 标记一个(或封装一组)操作命令,响应用户点击行为,触发相应的业务逻辑。- Buttons are used for emphasizing important functions on your page.
|
|
5
|
+
* @remarks [按钮组件] 是一个 [操作类] UI 组件,用于 [触发用户交互动作],包括点击、悬停等行为,使用户能够 [执行命令、提交表单、切换状态等]。它在卡片中扮演 [核心操作入口] 的角色,通常用于 [表单提交、功能切换、数据操作等场景]。
|
|
7
6
|
* @others
|
|
8
7
|
* ## 无障碍键盘操作指南
|
|
9
8
|
* | 按键 | 说明 |
|
|
@@ -24,25 +23,20 @@ import cs from 'classnames';
|
|
|
24
23
|
import { PREFIX_DEFAULT } from '../utils';
|
|
25
24
|
import { renderCommonIcon } from '../icon';
|
|
26
25
|
const Button = forwardRef((props, ref) => {
|
|
27
|
-
const { className, size = 'small', icon, type, children } = props, rest = __rest(props, ["className", "size", "icon", "type", "children"]);
|
|
28
|
-
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
if (type === 'normal') {
|
|
34
|
-
return 'secondary';
|
|
35
|
-
}
|
|
36
|
-
return type;
|
|
26
|
+
const { className, size = 'small', icon, type = 'primary', children, text } = props, rest = __rest(props, ["className", "size", "icon", "type", "children", "text"]);
|
|
27
|
+
// 根据按钮大小设置对应的图标尺寸
|
|
28
|
+
const iconSizeMap = {
|
|
29
|
+
small: 'xs',
|
|
30
|
+
medium: 'xs',
|
|
31
|
+
large: 'small'
|
|
37
32
|
};
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
33
|
+
const iconNode = renderCommonIcon(icon, iconSizeMap[size]);
|
|
34
|
+
// 文字按钮,只有 Primary 类型
|
|
35
|
+
const buttonType = text ? 'primary' : type;
|
|
36
|
+
return (React.createElement(NextButton, Object.assign({}, rest, { className: cs(`${PREFIX_DEFAULT}button`, size, buttonType, {
|
|
37
|
+
[`${PREFIX_DEFAULT}button-with-icon`]: !!icon || rest.loading
|
|
38
|
+
}, className), size: size, type: buttonType, ref: ref, text: text }),
|
|
41
39
|
iconNode,
|
|
42
40
|
children));
|
|
43
41
|
});
|
|
44
|
-
// const ButtonWithSub = assignSubComponent(Button, {
|
|
45
|
-
// displayName: 'Button',
|
|
46
|
-
// });
|
|
47
|
-
// export * from './types';
|
|
48
42
|
export default ConfigProvider.config(Button);
|
package/es/button/group.js
CHANGED
|
@@ -18,26 +18,13 @@
|
|
|
18
18
|
* | SPACE | Trigger the onClick event |
|
|
19
19
|
*/
|
|
20
20
|
import { __rest } from "tslib";
|
|
21
|
-
import React, { forwardRef
|
|
21
|
+
import React, { forwardRef } from 'react';
|
|
22
22
|
import { ConfigProvider } from '@alifd/next';
|
|
23
23
|
import cs from 'classnames';
|
|
24
24
|
import { PREFIX_DEFAULT } from '../utils';
|
|
25
25
|
import Button from './button';
|
|
26
|
-
const ADAPTOR_WIDTH = 600;
|
|
27
26
|
const ButtonGroup = forwardRef((props, ref) => {
|
|
28
27
|
const { className, size = 'small', type = 'row', dataSource, children } = props;
|
|
29
|
-
const [clientWidth, setClientWidth] = useState(document.documentElement.clientWidth);
|
|
30
|
-
useEffect(() => {
|
|
31
|
-
const handleResize = () => {
|
|
32
|
-
setTimeout(() => {
|
|
33
|
-
setClientWidth(document.documentElement.clientWidth);
|
|
34
|
-
}, 100);
|
|
35
|
-
};
|
|
36
|
-
window.addEventListener('resize', handleResize);
|
|
37
|
-
return () => {
|
|
38
|
-
window.removeEventListener('resize', handleResize);
|
|
39
|
-
};
|
|
40
|
-
}, []);
|
|
41
28
|
const renderRowButtons = (items) => {
|
|
42
29
|
if (!items || !items.length) {
|
|
43
30
|
return null;
|
|
@@ -48,33 +35,9 @@ const ButtonGroup = forwardRef((props, ref) => {
|
|
|
48
35
|
}
|
|
49
36
|
// Button组件的有些属性不太符合需求, text是一种type
|
|
50
37
|
const _a = button || {}, { buttonType, buttonStatus, label, icon } = _a, others = __rest(_a, ["buttonType", "buttonStatus", "label", "icon"]);
|
|
51
|
-
return (React.createElement(Button, Object.assign({ className: `single-button ${buttonType
|
|
38
|
+
return (React.createElement(Button, Object.assign({ className: `single-button ${`${buttonType}_${buttonStatus}`}`, type: buttonType === 'text' ? 'primary' : buttonType, key: button.label, warning: buttonStatus === 'warning', text: buttonType === 'text', disabled: buttonStatus === 'disabled', loading: buttonStatus === 'loading', icon: icon, size: size }, others), label));
|
|
52
39
|
});
|
|
53
40
|
};
|
|
54
|
-
// 设计稿地址:https://mgdone.alibaba-inc.com/file/141793008176403?fileOpenFrom=home&fileTileSwitch=false&page_id=154%3A8248
|
|
55
|
-
// 大于600: 1,2,3:1行等距展示; 大于等于4个:每行两个,每行一个或2个
|
|
56
|
-
// 小于 600, 从上往下排
|
|
57
|
-
const renderColumnButtons = () => {
|
|
58
|
-
if (!dataSource || !dataSource.length) {
|
|
59
|
-
return null;
|
|
60
|
-
}
|
|
61
|
-
// const screenWidth = clientWidth;
|
|
62
|
-
if (clientWidth < ADAPTOR_WIDTH) {
|
|
63
|
-
return renderRowButtons(dataSource);
|
|
64
|
-
}
|
|
65
|
-
// 1,2,3:1行等距展示;
|
|
66
|
-
if (dataSource.length <= 3) {
|
|
67
|
-
return renderRowButtons(dataSource);
|
|
68
|
-
}
|
|
69
|
-
// 大于等于4个:每行两个
|
|
70
|
-
const rows = Math.ceil(dataSource.length / 2);
|
|
71
|
-
const buttonRows = Array.from({ length: rows }, (_, index) => {
|
|
72
|
-
const start = index * 2;
|
|
73
|
-
const end = Math.min(start + 2, dataSource.length); // Ensure end does not exceed array length
|
|
74
|
-
return React.createElement("div", { className: 'button-group sub' }, renderRowButtons(dataSource.slice(start, end)));
|
|
75
|
-
});
|
|
76
|
-
return buttonRows;
|
|
77
|
-
};
|
|
78
41
|
const renderButtons = () => {
|
|
79
42
|
if (React.isValidElement(children)) {
|
|
80
43
|
return children;
|
|
@@ -82,10 +45,10 @@ const ButtonGroup = forwardRef((props, ref) => {
|
|
|
82
45
|
if (!dataSource || !dataSource.length) {
|
|
83
46
|
return null;
|
|
84
47
|
}
|
|
85
|
-
|
|
48
|
+
const actionItems = renderRowButtons(dataSource);
|
|
86
49
|
return (React.createElement("div", { className: `button-group ${type}` },
|
|
87
|
-
type
|
|
88
|
-
type
|
|
50
|
+
type === 'row' && actionItems,
|
|
51
|
+
type === 'column' && actionItems));
|
|
89
52
|
};
|
|
90
53
|
return (React.createElement("div", { className: cs(`${PREFIX_DEFAULT}button-group ${type}`, className), ref: ref }, renderButtons()));
|
|
91
54
|
});
|
package/es/button/main.scss
CHANGED
|
@@ -1,43 +1,42 @@
|
|
|
1
1
|
@import "../core/variables.scss";
|
|
2
2
|
|
|
3
3
|
.#{$prefix}button {
|
|
4
|
+
&.next-btn-text {
|
|
5
|
+
line-height: var(--common-text-line-height);
|
|
6
|
+
|
|
7
|
+
.next-btn-helper {
|
|
8
|
+
vertical-align: baseline;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
&-with-icon {
|
|
13
|
+
&.large {
|
|
14
|
+
padding: 0 var(--btn-size-m-padding, 16px);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
&.medium {
|
|
18
|
+
padding: 0 var(--btn-size-s-padding, 12px);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
&.small {
|
|
22
|
+
padding: 0 var(--btn-size-xs-padding, 8px);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
4
26
|
.common-icon {
|
|
5
|
-
margin-right: 4px;
|
|
27
|
+
margin-right: var(--s-1, 4px);
|
|
28
|
+
display: inline-flex;
|
|
29
|
+
align-items: center;
|
|
6
30
|
}
|
|
7
31
|
|
|
8
32
|
&-group {
|
|
9
33
|
.single-button {
|
|
10
|
-
flex: 1 0 calc(50% -
|
|
34
|
+
flex: 1 0 calc(50% - 4px); // 修改为50%宽度,每个按钮间隔6px,所以是3px
|
|
11
35
|
text-align: center;
|
|
12
|
-
margin-right:
|
|
36
|
+
margin-right: 0px;
|
|
13
37
|
max-width: 100%;
|
|
14
38
|
overflow: hidden;
|
|
15
|
-
|
|
16
|
-
&:nth-child(n+3) {
|
|
17
|
-
margin-top: 8px;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
// 使用nth-child选择器处理偶数按钮的右边距
|
|
21
|
-
&:nth-child(2n) {
|
|
22
|
-
margin-right: 0;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
// 最后一个按钮不需要右边距
|
|
26
|
-
&:last-child {
|
|
27
|
-
margin-right: 0;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// 当按钮数量小于等于3个时,恢复为三等分布局
|
|
31
|
-
&:first-child:nth-last-child(-n+3),
|
|
32
|
-
&:first-child:nth-last-child(-n+3) ~ .single-button {
|
|
33
|
-
flex: 1 0 calc(33.33% - 6px);
|
|
34
|
-
margin-top: 0;
|
|
35
|
-
|
|
36
|
-
// 重置偶数按钮的右边距规则
|
|
37
|
-
&:nth-child(2n) {
|
|
38
|
-
margin-right: 6px;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
39
|
+
flex-shrink: 1;
|
|
41
40
|
|
|
42
41
|
.next-btn-helper {
|
|
43
42
|
max-width: 100%;
|
|
@@ -52,57 +51,17 @@
|
|
|
52
51
|
justify-content: space-between; /* 这里可能不再需要,因为我们通过flex-basis控制每行按钮数 */
|
|
53
52
|
align-items: center;
|
|
54
53
|
width: 100%;
|
|
55
|
-
margin-bottom: 8px;
|
|
56
|
-
&:last-child{
|
|
57
|
-
margin-bottom: 0px;
|
|
58
|
-
}
|
|
59
|
-
&.column {
|
|
60
|
-
.single-button {
|
|
61
|
-
width: 100%;
|
|
62
|
-
margin-bottom: 8px;
|
|
63
|
-
&:last-child {
|
|
64
|
-
margin-bottom: 0px;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
display: block;
|
|
68
|
-
// 如果设计调整对应的适配宽度,需要调整这里的值
|
|
69
|
-
@media (min-width: 600px) {
|
|
70
|
-
display: flex;
|
|
71
|
-
.single-button {
|
|
72
|
-
margin-bottom: 0px;
|
|
73
|
-
flex: 1 0 calc(33.33% - 6px); /* 每个按钮占据33.33%的宽度减去左右各3px的间隔(总共6px)来保证每行三个 */
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
&.sub {
|
|
79
|
-
.single-button {
|
|
80
|
-
max-width: calc(50% - 6px);
|
|
81
|
-
margin-bottom: 0;
|
|
82
|
-
}
|
|
83
|
-
@media (max-width: 600px) {
|
|
84
|
-
display: block;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
54
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
border: none !important;
|
|
93
|
-
background-color: $color-brand1-1 !important;
|
|
94
|
-
color: $color-brand1-6 !important;
|
|
95
|
-
|
|
96
|
-
&:hover {
|
|
97
|
-
opacity: 0.8;
|
|
98
|
-
border: none !important;
|
|
99
|
-
color: $color-brand1-6 !important;
|
|
100
|
-
background-color: $color-brand1-1 !important;
|
|
55
|
+
.row {
|
|
56
|
+
display: flex;
|
|
57
|
+
flex-wrap: nowrap;
|
|
58
|
+
gap: var(--s-2, 8px);
|
|
101
59
|
}
|
|
102
60
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
61
|
+
.column {
|
|
62
|
+
display: flex;
|
|
63
|
+
flex-wrap: wrap;
|
|
64
|
+
gap: var(--s-2, 8px);
|
|
106
65
|
}
|
|
107
66
|
}
|
|
108
67
|
}
|
package/es/card/main.scss
CHANGED
|
@@ -4,25 +4,25 @@
|
|
|
4
4
|
.checkbox-item {
|
|
5
5
|
display: flex;
|
|
6
6
|
align-items: flex-start;
|
|
7
|
-
padding:
|
|
8
|
-
margin-bottom: 8px;
|
|
7
|
+
padding: var(--s-2, 8px);
|
|
8
|
+
margin-bottom: var(--s-2, 8px);
|
|
9
9
|
border-radius: 6px;
|
|
10
|
-
background-color:
|
|
10
|
+
background-color: var(--color-fill1-1, #F6F8FC);
|
|
11
11
|
cursor: pointer;
|
|
12
12
|
|
|
13
13
|
&:hover {
|
|
14
|
-
background-color:
|
|
14
|
+
background-color: var(--color-fill1-2, #F0F2F5);
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
&.active {
|
|
18
|
-
background-color:
|
|
18
|
+
background-color: var(--color-fill1-2, #F0F2F5);
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
.checkbox-item-checkbox {
|
|
23
23
|
flex-shrink: 0;
|
|
24
24
|
flex-grow: 0;
|
|
25
|
-
margin-right: 8px;
|
|
25
|
+
margin-right: var(--s-2, 8px);
|
|
26
26
|
height: 22px;
|
|
27
27
|
display: flex;
|
|
28
28
|
align-items: center;
|
|
@@ -58,6 +58,5 @@
|
|
|
58
58
|
|
|
59
59
|
.confirm-button {
|
|
60
60
|
width: 100%;
|
|
61
|
-
margin-top: 4px;
|
|
62
61
|
}
|
|
63
62
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @component 代码视图
|
|
3
|
+
* @en CodeView
|
|
4
|
+
* @type 展示 - Display
|
|
5
|
+
* @remarks 用于展示代码块的组件,支持语法高亮和复制功能。
|
|
6
|
+
*/
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import type { CodeViewProps } from './types';
|
|
9
|
+
export * from './types';
|
|
10
|
+
declare const _default: import("@alifd/next/types/config-provider/types").ConfiguredComponentClass<Pick<CodeViewProps & React.RefAttributes<HTMLDivElement>, "key" | keyof CodeViewProps> & import("@alifd/next/types/config-provider/types").ComponentCommonProps, HTMLDivElement, {}>;
|
|
11
|
+
export default _default;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @component 代码视图
|
|
3
|
+
* @en CodeView
|
|
4
|
+
* @type 展示 - Display
|
|
5
|
+
* @remarks 用于展示代码块的组件,支持语法高亮和复制功能。
|
|
6
|
+
*/
|
|
7
|
+
import React, { forwardRef, useMemo, useRef } from 'react';
|
|
8
|
+
import { ConfigProvider, Icon } from '@alifd/next';
|
|
9
|
+
import classnames from 'classnames';
|
|
10
|
+
import hljs from 'highlight.js';
|
|
11
|
+
import { PREFIX_DEFAULT, defaultCopyText } from '../utils';
|
|
12
|
+
const CodeView = forwardRef((props, ref) => {
|
|
13
|
+
const { className, code, language = '', showCopyButton, theme = 'light', } = props;
|
|
14
|
+
const codeRef = useRef(null);
|
|
15
|
+
// 使用 useMemo 缓存高亮结果,只在 code 或 language 变化时重新计算
|
|
16
|
+
const highlightedCode = useMemo(() => {
|
|
17
|
+
if (!code)
|
|
18
|
+
return '';
|
|
19
|
+
// 先转义 HTML 特殊字符防止 XSS
|
|
20
|
+
const escapedCode = code
|
|
21
|
+
.replace(/&/g, '&')
|
|
22
|
+
.replace(/</g, '<')
|
|
23
|
+
.replace(/>/g, '>')
|
|
24
|
+
.replace(/"/g, '"')
|
|
25
|
+
.replace(/'/g, ''');
|
|
26
|
+
try {
|
|
27
|
+
// 创建临时元素进行高亮
|
|
28
|
+
const tempElement = document.createElement('code');
|
|
29
|
+
tempElement.className = `language-${language}`;
|
|
30
|
+
tempElement.innerHTML = escapedCode;
|
|
31
|
+
// 执行语法高亮
|
|
32
|
+
hljs.highlightElement(tempElement);
|
|
33
|
+
return tempElement.innerHTML;
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
// 降级方案:返回转义后的原始代码
|
|
37
|
+
return escapedCode;
|
|
38
|
+
}
|
|
39
|
+
}, [code, language]);
|
|
40
|
+
const handleCopy = () => {
|
|
41
|
+
if (!codeRef.current)
|
|
42
|
+
return;
|
|
43
|
+
const content = codeRef.current.innerText;
|
|
44
|
+
defaultCopyText(content);
|
|
45
|
+
};
|
|
46
|
+
const handleKeyDown = (event) => {
|
|
47
|
+
if (event.key === 'Enter' || event.key === ' ') {
|
|
48
|
+
event.preventDefault();
|
|
49
|
+
handleCopy();
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
return (React.createElement("div", { className: classnames(`${PREFIX_DEFAULT}code-view`, `${PREFIX_DEFAULT}hljs-${theme}`, className), ref: ref },
|
|
53
|
+
React.createElement("div", { className: `${PREFIX_DEFAULT}code-view-header` },
|
|
54
|
+
React.createElement("div", { className: `${PREFIX_DEFAULT}code-view-language` }, language),
|
|
55
|
+
showCopyButton !== false && (React.createElement("div", { className: `${PREFIX_DEFAULT}code-view-copy`, onClick: handleCopy, onKeyDown: handleKeyDown, role: "button", tabIndex: 0, title: "\u590D\u5236\u4EE3\u7801" },
|
|
56
|
+
React.createElement(Icon, { size: 'xs', type: "copy" })))),
|
|
57
|
+
React.createElement("div", { className: `${PREFIX_DEFAULT}code-view-container` },
|
|
58
|
+
React.createElement("pre", null,
|
|
59
|
+
React.createElement("code", { ref: codeRef, className: `${PREFIX_DEFAULT}code-view-content hljs language-${language}`, dangerouslySetInnerHTML: { __html: highlightedCode }, "data-highlighted": "yes" })))));
|
|
60
|
+
});
|
|
61
|
+
CodeView.displayName = 'CodeView';
|
|
62
|
+
export * from './types';
|
|
63
|
+
export default ConfigProvider.config(CodeView);
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
@import '../core/variables.scss';
|
|
2
|
+
|
|
3
|
+
.#{$prefix}code-view {
|
|
4
|
+
// border: 4px solid var(--color-bg-1, #ffffff);
|
|
5
|
+
border-radius: var(--corner-2, 8px);
|
|
6
|
+
overflow: hidden;
|
|
7
|
+
background-color: var(--color-fill1-1);
|
|
8
|
+
position: relative;
|
|
9
|
+
|
|
10
|
+
pre {
|
|
11
|
+
margin: 0;
|
|
12
|
+
|
|
13
|
+
code.hljs {
|
|
14
|
+
padding: var(--s-2, 8px) var(--s-3, 12px);
|
|
15
|
+
|
|
16
|
+
&.ct-code-view-content {
|
|
17
|
+
padding: var(--s-2, 8px) var(--s-3, 12px);
|
|
18
|
+
background-color: var(--color-fill1-1);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
&-header {
|
|
24
|
+
display: flex;
|
|
25
|
+
justify-content: space-between;
|
|
26
|
+
align-items: center;
|
|
27
|
+
padding: var(--s-2, 8px) var(--s-3, 12px);
|
|
28
|
+
line-height: 22px;
|
|
29
|
+
background-color: var(--color-fill1-2);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
&-language {
|
|
33
|
+
color: var(--color-text1-3);
|
|
34
|
+
font-size: 14px;
|
|
35
|
+
font-weight: 600;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
&-copy {
|
|
39
|
+
cursor: pointer;
|
|
40
|
+
height: 22px;
|
|
41
|
+
color: var(--color-text1-2);
|
|
42
|
+
|
|
43
|
+
&:hover {
|
|
44
|
+
color: var(--color-text1-3);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
&-container {
|
|
49
|
+
max-height: 500px;
|
|
50
|
+
overflow-y: auto;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @api
|
|
3
|
+
*/
|
|
4
|
+
export interface CodeViewProps {
|
|
5
|
+
/**
|
|
6
|
+
* 自定义类名
|
|
7
|
+
*/
|
|
8
|
+
className?: string;
|
|
9
|
+
/**
|
|
10
|
+
* 代码内容
|
|
11
|
+
*/
|
|
12
|
+
code: string;
|
|
13
|
+
/**
|
|
14
|
+
* 编程语言
|
|
15
|
+
*/
|
|
16
|
+
language?: string;
|
|
17
|
+
/**
|
|
18
|
+
* 是否显示复制按钮
|
|
19
|
+
* @defaultValue true
|
|
20
|
+
*/
|
|
21
|
+
showCopyButton?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* 主题模式
|
|
24
|
+
* @defaultValue 'light'
|
|
25
|
+
*/
|
|
26
|
+
theme?: 'light' | 'dark';
|
|
27
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|