@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.
Files changed (241) hide show
  1. package/es/ai-loading/types.d.ts +1 -0
  2. package/es/button/button.d.ts +1 -2
  3. package/es/button/button.js +13 -19
  4. package/es/button/group.js +5 -42
  5. package/es/button/main.scss +36 -77
  6. package/es/card/main.scss +1 -1
  7. package/es/checkbox-group/main.scss +6 -7
  8. package/es/checkbox-group/types.d.ts +6 -0
  9. package/es/code-view/index.d.ts +11 -0
  10. package/es/code-view/index.js +63 -0
  11. package/es/code-view/main.scss +54 -0
  12. package/es/code-view/style.d.ts +4 -0
  13. package/es/code-view/style.js +4 -0
  14. package/es/code-view/types.d.ts +27 -0
  15. package/es/code-view/types.js +1 -0
  16. package/es/collapse/index.d.ts +157 -0
  17. package/es/collapse/index.js +20 -0
  18. package/es/collapse/main.scss +97 -0
  19. package/es/collapse/style.d.ts +2 -0
  20. package/es/collapse/style.js +2 -0
  21. package/es/collapse/types.d.ts +82 -0
  22. package/es/collapse/types.js +2 -0
  23. package/es/core/variables.scss +27 -12
  24. package/es/date-picker/DatePicker.d.ts +5 -0
  25. package/es/date-picker/DatePicker.js +15 -0
  26. package/es/date-picker/MonthPicker.d.ts +4 -0
  27. package/es/date-picker/MonthPicker.js +15 -0
  28. package/es/date-picker/RangePicker.d.ts +4 -0
  29. package/es/date-picker/RangePicker.js +17 -0
  30. package/es/date-picker/YearPicker.d.ts +4 -0
  31. package/es/date-picker/YearPicker.js +15 -0
  32. package/es/date-picker/index.d.ts +5 -23
  33. package/es/date-picker/index.js +11 -29
  34. package/es/date-picker/main.scss +23 -1
  35. package/es/date-picker/style.d.ts +1 -0
  36. package/es/date-picker/style.js +1 -0
  37. package/es/date-picker/types.d.ts +161 -81
  38. package/es/float-button/hooks/useAutoAlign.d.ts +1 -1
  39. package/es/form/style.d.ts +0 -1
  40. package/es/form/style.js +2 -1
  41. package/es/form/types.d.ts +3 -517
  42. package/es/form/types.js +5 -1
  43. package/es/html-render/index.d.ts +1 -1
  44. package/es/html-render/index.js +118 -106
  45. package/es/html-render/main.scss +27 -8
  46. package/es/html-render/style.d.ts +1 -0
  47. package/es/html-render/style.js +1 -0
  48. package/es/icon/index.d.ts +1 -1
  49. package/es/index.d.ts +3 -0
  50. package/es/index.js +4 -1
  51. package/es/input/index.d.ts +1 -1
  52. package/es/input/index.js +16 -6
  53. package/es/input/main.scss +25 -0
  54. package/es/input/style.d.ts +1 -0
  55. package/es/input/style.js +1 -0
  56. package/es/input/types.d.ts +58 -15
  57. package/es/markdown/index.d.ts +1 -2
  58. package/es/markdown/index.js +26 -15
  59. package/es/markdown/main.scss +4 -3
  60. package/es/markdown/style.d.ts +2 -1
  61. package/es/markdown/style.js +2 -1
  62. package/es/markdown/types.d.ts +20 -9
  63. package/es/message/index.d.ts +4 -4
  64. package/es/person-picker/index.d.ts +3 -190
  65. package/es/person-picker/index.js +23 -21
  66. package/es/person-picker/main.scss +15 -1
  67. package/es/person-picker/types.d.ts +53 -11
  68. package/es/radio-group/index.d.ts +1 -1
  69. package/es/radio-group/index.js +9 -3
  70. package/es/radio-group/main.scss +13 -5
  71. package/es/radio-group/types.d.ts +5 -3
  72. package/es/reference/index.d.ts +1 -1
  73. package/es/reference/index.js +14 -15
  74. package/es/reference/main.scss +1 -1
  75. package/es/reference/types.d.ts +1 -0
  76. package/es/select/button.d.ts +3 -0
  77. package/es/select/button.js +70 -0
  78. package/es/select/index.d.ts +79 -79
  79. package/es/select/index.js +13 -57
  80. package/es/select/main.scss +22 -4
  81. package/es/select/types.d.ts +108 -1
  82. package/es/step/index.js +2 -2
  83. package/es/step/main.scss +115 -66
  84. package/es/step/types.d.ts +13 -2
  85. package/es/table/index.d.ts +12 -0
  86. package/es/table/index.js +23 -0
  87. package/es/table/main.scss +30 -0
  88. package/es/table/style.d.ts +2 -0
  89. package/es/table/style.js +2 -0
  90. package/es/table/types.d.ts +98 -0
  91. package/es/table/types.js +1 -0
  92. package/es/tag/index.d.ts +5 -3
  93. package/es/tag/index.js +18 -2
  94. package/es/tag/main.scss +20 -4
  95. package/es/tag/types.d.ts +55 -0
  96. package/es/text/index.js +1 -1
  97. package/es/text/main.scss +4 -1
  98. package/es/text/types.d.ts +8 -0
  99. package/es/time-picker/index.d.ts +6 -15
  100. package/es/time-picker/index.js +71 -24
  101. package/es/time-picker/main.scss +19 -1
  102. package/es/time-picker/style.d.ts +1 -0
  103. package/es/time-picker/style.js +1 -0
  104. package/es/time-picker/types.d.ts +133 -8
  105. package/es/tool-status/index.d.ts +1 -1
  106. package/es/tool-status/index.js +1 -1
  107. package/es/tool-status/main.scss +2 -1
  108. package/es/tool-status/types.d.ts +7 -2
  109. package/es/utils/func.d.ts +1 -0
  110. package/es/utils/func.js +13 -0
  111. package/es/utils/github-dark.scss +137 -0
  112. package/es/utils/github.scss +137 -0
  113. package/es/utils/hoc/main.scss +166 -0
  114. package/es/utils/hoc/withLabel.d.ts +94 -0
  115. package/es/utils/hoc/withLabel.js +57 -0
  116. package/es/utils/index.d.ts +1 -0
  117. package/es/utils/index.js +1 -0
  118. package/lib/ai-loading/types.d.ts +1 -0
  119. package/lib/button/button.d.ts +1 -2
  120. package/lib/button/button.js +13 -19
  121. package/lib/button/group.js +4 -41
  122. package/lib/button/main.scss +36 -77
  123. package/lib/card/main.scss +1 -1
  124. package/lib/checkbox-group/main.scss +6 -7
  125. package/lib/checkbox-group/types.d.ts +6 -0
  126. package/lib/code-view/index.d.ts +11 -0
  127. package/lib/code-view/index.js +66 -0
  128. package/lib/code-view/main.scss +54 -0
  129. package/lib/code-view/style.d.ts +4 -0
  130. package/lib/code-view/style.js +6 -0
  131. package/lib/code-view/types.d.ts +27 -0
  132. package/lib/code-view/types.js +2 -0
  133. package/lib/collapse/index.d.ts +157 -0
  134. package/lib/collapse/index.js +22 -0
  135. package/lib/collapse/main.scss +97 -0
  136. package/lib/collapse/style.d.ts +2 -0
  137. package/lib/collapse/style.js +4 -0
  138. package/lib/collapse/types.d.ts +82 -0
  139. package/lib/collapse/types.js +3 -0
  140. package/lib/core/variables.scss +27 -12
  141. package/lib/date-picker/DatePicker.d.ts +5 -0
  142. package/lib/date-picker/DatePicker.js +17 -0
  143. package/lib/date-picker/MonthPicker.d.ts +4 -0
  144. package/lib/date-picker/MonthPicker.js +17 -0
  145. package/lib/date-picker/RangePicker.d.ts +4 -0
  146. package/lib/date-picker/RangePicker.js +19 -0
  147. package/lib/date-picker/YearPicker.d.ts +4 -0
  148. package/lib/date-picker/YearPicker.js +17 -0
  149. package/lib/date-picker/index.d.ts +5 -23
  150. package/lib/date-picker/index.js +10 -27
  151. package/lib/date-picker/main.scss +23 -1
  152. package/lib/date-picker/style.d.ts +1 -0
  153. package/lib/date-picker/style.js +1 -0
  154. package/lib/date-picker/types.d.ts +161 -81
  155. package/lib/float-button/hooks/useAutoAlign.d.ts +1 -1
  156. package/lib/form/style.d.ts +0 -1
  157. package/lib/form/style.js +1 -2
  158. package/lib/form/types.d.ts +3 -517
  159. package/lib/form/types.js +4 -1
  160. package/lib/html-render/index.d.ts +1 -1
  161. package/lib/html-render/index.js +118 -106
  162. package/lib/html-render/main.scss +27 -8
  163. package/lib/html-render/style.d.ts +1 -0
  164. package/lib/html-render/style.js +1 -0
  165. package/lib/icon/index.d.ts +1 -1
  166. package/lib/index.d.ts +3 -0
  167. package/lib/index.js +8 -2
  168. package/lib/input/index.d.ts +1 -1
  169. package/lib/input/index.js +16 -6
  170. package/lib/input/main.scss +25 -0
  171. package/lib/input/style.d.ts +1 -0
  172. package/lib/input/style.js +1 -0
  173. package/lib/input/types.d.ts +58 -15
  174. package/lib/markdown/index.d.ts +1 -2
  175. package/lib/markdown/index.js +26 -15
  176. package/lib/markdown/main.scss +4 -3
  177. package/lib/markdown/style.d.ts +2 -1
  178. package/lib/markdown/style.js +2 -1
  179. package/lib/markdown/types.d.ts +20 -9
  180. package/lib/message/index.d.ts +4 -4
  181. package/lib/person-picker/index.d.ts +3 -190
  182. package/lib/person-picker/index.js +22 -20
  183. package/lib/person-picker/main.scss +15 -1
  184. package/lib/person-picker/types.d.ts +53 -11
  185. package/lib/radio-group/index.d.ts +1 -1
  186. package/lib/radio-group/index.js +8 -2
  187. package/lib/radio-group/main.scss +13 -5
  188. package/lib/radio-group/types.d.ts +5 -3
  189. package/lib/reference/index.d.ts +1 -1
  190. package/lib/reference/index.js +17 -18
  191. package/lib/reference/main.scss +1 -1
  192. package/lib/reference/types.d.ts +1 -0
  193. package/lib/select/button.d.ts +3 -0
  194. package/lib/select/button.js +74 -0
  195. package/lib/select/index.d.ts +79 -79
  196. package/lib/select/index.js +11 -55
  197. package/lib/select/main.scss +22 -4
  198. package/lib/select/types.d.ts +108 -1
  199. package/lib/step/index.js +2 -2
  200. package/lib/step/main.scss +115 -66
  201. package/lib/step/types.d.ts +13 -2
  202. package/lib/table/index.d.ts +12 -0
  203. package/lib/table/index.js +25 -0
  204. package/lib/table/main.scss +30 -0
  205. package/lib/table/style.d.ts +2 -0
  206. package/lib/table/style.js +4 -0
  207. package/lib/table/types.d.ts +98 -0
  208. package/lib/table/types.js +2 -0
  209. package/lib/tag/index.d.ts +5 -3
  210. package/lib/tag/index.js +17 -1
  211. package/lib/tag/main.scss +20 -4
  212. package/lib/tag/types.d.ts +55 -0
  213. package/lib/text/index.js +1 -1
  214. package/lib/text/main.scss +4 -1
  215. package/lib/text/types.d.ts +8 -0
  216. package/lib/time-picker/index.d.ts +6 -15
  217. package/lib/time-picker/index.js +71 -23
  218. package/lib/time-picker/main.scss +19 -1
  219. package/lib/time-picker/style.d.ts +1 -0
  220. package/lib/time-picker/style.js +1 -0
  221. package/lib/time-picker/types.d.ts +133 -8
  222. package/lib/tool-status/index.d.ts +1 -1
  223. package/lib/tool-status/index.js +1 -1
  224. package/lib/tool-status/main.scss +2 -1
  225. package/lib/tool-status/types.d.ts +7 -2
  226. package/lib/utils/func.d.ts +1 -0
  227. package/lib/utils/func.js +15 -0
  228. package/lib/utils/github-dark.scss +137 -0
  229. package/lib/utils/github.scss +137 -0
  230. package/lib/utils/hoc/main.scss +166 -0
  231. package/lib/utils/hoc/withLabel.d.ts +94 -0
  232. package/lib/utils/hoc/withLabel.js +60 -0
  233. package/lib/utils/index.d.ts +1 -0
  234. package/lib/utils/index.js +1 -0
  235. package/package.json +49 -4
  236. package/es/form/index.d.ts +0 -23
  237. package/es/form/index.js +0 -33
  238. package/es/form/main.scss +0 -5
  239. package/lib/form/index.d.ts +0 -23
  240. package/lib/form/index.js +0 -35
  241. package/lib/form/main.scss +0 -5
@@ -2,6 +2,7 @@ import React from 'react';
2
2
  import { type CommonProps } from '@alifd/next';
3
3
  /**
4
4
  * AI Loading 属性
5
+ * @api
5
6
  */
6
7
  export interface AILoadingProps extends React.HTMLAttributes<HTMLElement>, CommonProps {
7
8
  className?: string;
@@ -2,8 +2,7 @@
2
2
  * @component 按钮
3
3
  * @en Button
4
4
  * @type 通用 - General
5
- * @remarks Next Button,按钮用于开始一个即时操作。- Same as Next.Button, Button used to trigger an action.
6
- * @when 标记一个(或封装一组)操作命令,响应用户点击行为,触发相应的业务逻辑。- Buttons are used for emphasizing important functions on your page.
5
+ * @remarks [按钮组件] 是一个 [操作类] UI 组件,用于 [触发用户交互动作],包括点击、悬停等行为,使用户能够 [执行命令、提交表单、切换状态等]。它在卡片中扮演 [核心操作入口] 的角色,通常用于 [表单提交、功能切换、数据操作等场景]。
7
6
  * @others
8
7
  * ## 无障碍键盘操作指南
9
8
  * | 按键 | 说明 |
@@ -2,8 +2,7 @@
2
2
  * @component 按钮
3
3
  * @en Button
4
4
  * @type 通用 - General
5
- * @remarks Next Button,按钮用于开始一个即时操作。- Same as Next.Button, Button used to trigger an action.
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
- const iconNode = renderCommonIcon(icon, 'xs');
29
- const getChatButtonType = (type) => {
30
- if (type === 'secondary') {
31
- return 'normal';
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
- // 目前会把secondary和text都设置为normal, 后续如果需要区分,需要后端配合
39
- const validType = getChatButtonType(type);
40
- return (React.createElement(NextButton, Object.assign({}, rest, { className: cs(`${PREFIX_DEFAULT}button ${size} ${type}`, className), size: size, type: validType, ref: ref }),
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);
@@ -18,26 +18,13 @@
18
18
  * | SPACE | Trigger the onClick event |
19
19
  */
20
20
  import { __rest } from "tslib";
21
- import React, { forwardRef, useEffect, useState } from 'react';
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 + '_' + buttonStatus}`, type: button.buttonType, warning: buttonStatus === 'warning' ? true : false, text: buttonType === 'text' ? true : false, disabled: buttonStatus === 'disabled' ? true : false, loading: buttonStatus === 'loading' ? true : false, icon: icon, size: size }, others), label));
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
- let actionItems = renderRowButtons(dataSource);
48
+ const actionItems = renderRowButtons(dataSource);
86
49
  return (React.createElement("div", { className: `button-group ${type}` },
87
- type == 'row' && actionItems,
88
- type == 'column' && renderColumnButtons()));
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
  });
@@ -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% - 3px); // 修改为50%宽度,每个按钮间隔6px,所以是3px
34
+ flex: 1 0 calc(50% - 4px); // 修改为50%宽度,每个按钮间隔6px,所以是3px
11
35
  text-align: center;
12
- margin-right: 6px;
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
- &.secondary:not[disabled] {
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
- &:focus {
104
- color: $color-brand1-8 !important;
105
- background-color: $color-brand1-2 !important;
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
@@ -39,7 +39,7 @@
39
39
  &-inner {
40
40
  display: flex;
41
41
  flex-direction: column;
42
- background-color: #fff;
42
+ background-color: var(--color-bg-1, #ffffff);
43
43
  @include size(
44
44
  $shadow-2,
45
45
  $size-base * 3,
@@ -4,25 +4,25 @@
4
4
  .checkbox-item {
5
5
  display: flex;
6
6
  align-items: flex-start;
7
- padding: 10px;
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: $color-fill1-1;
10
+ background-color: var(--color-fill1-1, #F6F8FC);
11
11
  cursor: pointer;
12
12
 
13
13
  &:hover {
14
- background-color: $color-fill1-2;
14
+ background-color: var(--color-fill1-2, #F0F2F5);
15
15
  }
16
16
 
17
17
  &.active {
18
- background-color: $color-fill1-2;
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
  }
@@ -1,8 +1,14 @@
1
+ /**
2
+ * @api
3
+ */
1
4
  export interface CheckboxItem {
2
5
  label: string;
3
6
  value: string;
4
7
  description?: string;
5
8
  }
9
+ /**
10
+ * @api
11
+ */
6
12
  export interface CheckboxGroupProps {
7
13
  options: CheckboxItem[];
8
14
  value: string[];
@@ -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, '&amp;')
22
+ .replace(/</g, '&lt;')
23
+ .replace(/>/g, '&gt;')
24
+ .replace(/"/g, '&quot;')
25
+ .replace(/'/g, '&#039;');
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,4 @@
1
+ import '@alifd/next/lib/message/style2';
2
+ import '../utils/github.scss';
3
+ import '../utils/github-dark.scss';
4
+ import './main.scss';
@@ -0,0 +1,4 @@
1
+ import '@alifd/next/lib/message/style2';
2
+ import '../utils/github.scss';
3
+ import '../utils/github-dark.scss';
4
+ import './main.scss';
@@ -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 {};