@agentscope-ai/design 1.0.27 → 1.0.28-beta.1769761940248

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.
@@ -1,3 +1,4 @@
1
+ import { Extension } from '@codemirror/state';
1
2
  export interface CodeBlockProps {
2
3
  /**
3
4
  * @description 语言
@@ -24,6 +25,12 @@ export interface CodeBlockProps {
24
25
  */
25
26
  readOnly?: boolean;
26
27
  onChange?: (value?: string) => void;
28
+ /**
29
+ * @description 扩展
30
+ * @descriptionEn Extensions
31
+ * @default []
32
+ */
33
+ extensions?: Extension[];
27
34
  }
28
35
  export declare const langExtensionsMap: Record<string, any[]>;
29
36
  export declare const beautifulJson: (val?: string, count?: number) => string;
@@ -78,9 +78,9 @@ var CodeMirrorWrapper = function CodeMirrorWrapper(props) {
78
78
  }
79
79
  return props.theme === 'dark' ? vscodeDark : vscodeLight;
80
80
  }, [isDarkMode, props.theme]);
81
- var extensions = typeof props.language === 'string' ? [].concat(_toConsumableArray(langExtensionsMap[props.language] || []), _toConsumableArray(props.value && props.language in lintExtensionsMap ? lintExtensionsMap[props.language] : [])) : props.language.reduce(function (ext, lang) {
81
+ var extensions = (props.extensions || []).concat(typeof props.language === 'string' ? [].concat(_toConsumableArray(langExtensionsMap[props.language] || []), _toConsumableArray(props.value && props.language in lintExtensionsMap ? lintExtensionsMap[props.language] : [])) : props.language.reduce(function (ext, lang) {
82
82
  return [].concat(_toConsumableArray(ext), [langExtensionsMap[lang]]);
83
- }, []);
83
+ }, []));
84
84
  var codeMirrorElement = /*#__PURE__*/_jsx("div", {
85
85
  className: cls("".concat(sparkPrefix, "-code-block"), props.className),
86
86
  children: /*#__PURE__*/_jsx(CodeMirror, _objectSpread({
@@ -1 +1,7 @@
1
+ /**
2
+ * CodeBlock 组件样式
3
+ * 所有 CodeMirror 相关样式都限定在组件根类名下,
4
+ * 通过选择器层级提高优先级,避免使用 !important,
5
+ * 方便外部业务覆盖样式
6
+ */
1
7
  export declare const useStyle: () => () => import("react/jsx-runtime").JSX.Element;
@@ -1,7 +1,14 @@
1
1
  var _templateObject;
2
2
  function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
3
3
  import createGlobalStyle from "../../../libs/createStyle";
4
- export var useStyle = createGlobalStyle(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n.", "-code-block {\n width: 100%;\n}\n\n.cm-theme {\n border: none !important;\n border-radius: 0 !important;\n}\n\n.cm-gutters {\n border-right: none !important;\n background-color: var(--", "-color-bg-base) !important;\n}\n\n.cm-editor {\n background-color: var(--", "-color-bg-base) !important;\n}\n\n.cm-gutterElement:not(:first-child) {\n color: var(--", "-color-text-tertiary);\n height: 24px !important;\n line-height: 24px !important;\n display: flex;\n align-items: center;\n justify-content: center;\n \n span:not([title*=\"Unfold line\"]) {\n height: 30px !important;\n }\n}\n\n.cm-line {\n height: 24px !important;\n line-height: 24px !important;\n}\n\n.cm-lineNumbers .cm-gutterElement {\n padding: 0px 4px 0px 12px !important;\n}\n\n.cm-activeLine,\n.cm-activeLineGutter {\n background-color: var(--", "-color-fill-secondary) !important;\n}\n\n.cm-button {\n background-image: none !important;\n background: var(--", "-color-bg-base) !important;\n border: 1px solid var(--", "-color-border-secondary) !important;\n border-radius: 4px !important;\n \n &:hover {\n color: var(--", "-color-text-secondary);\n cursor: pointer;\n }\n}\n\n.cm-search {\n background: var(--", "-color-fill-secondary) !important;\n}\n\n.cm-panel.cm-search label {\n display: inline-flex;\n align-items: center;\n}\n\n.cm-panel.cm-search [name=close] {\n right: 8px !important;\n background: none !important;\n font-size: 16px !important;\n color: var(--", "-color-text-tertiary) !important;\n}\n\n.cm-textfield {\n border-radius: 4px;\n}\n\n.cm-panel.cm-search input[type=checkbox] {\n border: 1px solid var(--", "-color-border-secondary) !important;\n}\n\n.cm-focused {\n outline: none !important;\n}\n"])), function (p) {
4
+
5
+ /**
6
+ * CodeBlock 组件样式
7
+ * 所有 CodeMirror 相关样式都限定在组件根类名下,
8
+ * 通过选择器层级提高优先级,避免使用 !important,
9
+ * 方便外部业务覆盖样式
10
+ */
11
+ export var useStyle = createGlobalStyle(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n.", "-code-block {\n width: 100%;\n\n /* CodeMirror \u4E3B\u9898\u6837\u5F0F */\n .cm-theme {\n border: none;\n border-radius: 0;\n }\n\n /* \u884C\u53F7\u69FD\u6837\u5F0F */\n .cm-gutters {\n border-right: none;\n background-color: var(--", "-color-bg-base);\n }\n\n /* \u7F16\u8F91\u5668\u80CC\u666F */\n .cm-editor {\n background-color: var(--", "-color-bg-base);\n }\n\n /* \u884C\u53F7\u5143\u7D20\u6837\u5F0F */\n .cm-gutterElement:not(:first-child) {\n color: var(--", "-color-text-tertiary);\n min-height: 24px;\n line-height: 24px;\n display: flex;\n align-items: flex-start;\n justify-content: center;\n padding-top: 0;\n }\n\n /* \u4EE3\u7801\u884C\u6837\u5F0F - \u4E0D\u8BBE\u7F6E\u56FA\u5B9A\u9AD8\u5EA6\uFF0C\u8BA9 CodeMirror \u81EA\u52A8\u8BA1\u7B97\u4EE5\u652F\u6301\u6362\u884C */\n .cm-line {\n min-height: 24px;\n line-height: 24px;\n }\n\n /* \u884C\u53F7\u5185\u8FB9\u8DDD */\n .cm-lineNumbers .cm-gutterElement {\n padding: 0px 4px 0px 12px;\n }\n\n /* \u5F53\u524D\u884C\u9AD8\u4EAE */\n .cm-activeLine,\n .cm-activeLineGutter {\n background-color: var(--", "-color-fill-secondary);\n }\n\n /* \u6309\u94AE\u6837\u5F0F */\n .cm-button {\n background-image: none;\n background: var(--", "-color-bg-base);\n border: 1px solid var(--", "-color-border-secondary);\n border-radius: 4px;\n \n &:hover {\n color: var(--", "-color-text-secondary);\n cursor: pointer;\n }\n }\n\n /* \u641C\u7D22\u9762\u677F\u6837\u5F0F */\n .cm-search {\n background: var(--", "-color-fill-secondary);\n }\n\n .cm-panel.cm-search label {\n display: inline-flex;\n align-items: center;\n }\n\n .cm-panel.cm-search [name=close] {\n right: 8px;\n background: none;\n font-size: 16px;\n color: var(--", "-color-text-tertiary);\n }\n\n /* \u6587\u672C\u8F93\u5165\u6846\u6837\u5F0F */\n .cm-textfield {\n border-radius: 4px;\n }\n\n .cm-panel.cm-search input[type=checkbox] {\n border: 1px solid var(--", "-color-border-secondary);\n }\n\n /* \u805A\u7126\u6837\u5F0F */\n .cm-focused {\n outline: none;\n }\n}\n"])), function (p) {
5
12
  return p.sparkPrefix;
6
13
  }, function (p) {
7
14
  return p.antPrefix;
@@ -16,13 +16,19 @@ import classNames from 'classnames';
16
16
  import { useStyle } from "./index.style";
17
17
 
18
18
  /**
19
- * 获取默认的分页大小选择器配置
20
- * 使用函数形式以支持动态国际化
19
+ * 获取默认的分页大小选项
21
20
  */
22
21
  import { jsx as _jsx } from "react/jsx-runtime";
23
22
  import { jsxs as _jsxs } from "react/jsx-runtime";
24
23
  import { Fragment as _Fragment } from "react/jsx-runtime";
25
- var getDefaultShowSizeChange = function getDefaultShowSizeChange() {
24
+ var DEFAULT_PAGE_SIZE_OPTIONS = [10, 20, 50, 100];
25
+
26
+ /**
27
+ * 根据 pageSizeOptions 生成带国际化文案的选项配置
28
+ * @param pageSizeOptions 分页大小选项数组
29
+ */
30
+ var getShowSizeChangeOptions = function getShowSizeChangeOptions() {
31
+ var pageSizeOptions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_PAGE_SIZE_OPTIONS;
26
32
  var itemsText = $i18n.get({
27
33
  id: 'components.commonComponents.Pagination.Items',
28
34
  dm: '条'
@@ -32,19 +38,12 @@ var getDefaultShowSizeChange = function getDefaultShowSizeChange() {
32
38
  dm: '页'
33
39
  });
34
40
  return {
35
- options: [{
36
- label: "10 ".concat(itemsText, " / ").concat(pageText),
37
- value: 10
38
- }, {
39
- label: "20 ".concat(itemsText, " / ").concat(pageText),
40
- value: 20
41
- }, {
42
- label: "50 ".concat(itemsText, " / ").concat(pageText),
43
- value: 50
44
- }, {
45
- label: "100 ".concat(itemsText, " / ").concat(pageText),
46
- value: 100
47
- }]
41
+ options: pageSizeOptions.map(function (size) {
42
+ return {
43
+ label: "".concat(size, " ").concat(itemsText, " / ").concat(pageText),
44
+ value: Number(size)
45
+ };
46
+ })
48
47
  };
49
48
  };
50
49
  export default (function (props) {
@@ -105,21 +104,21 @@ export default (function (props) {
105
104
  shouldShowSizeChanger = restProps.total && restProps.total > 50;
106
105
  }
107
106
  var getMergedShowSizeChange = function getMergedShowSizeChange() {
108
- if (props.showSizeChanger === true) {
109
- // 用户手动设置为 true,使用预置选项(动态获取以支持国际化)
110
- return getDefaultShowSizeChange();
111
- }
112
107
  if (props.showSizeChanger === false) {
113
108
  // 用户手动设为 false
114
109
  return false;
115
110
  }
116
111
  if (_typeof(props.showSizeChanger) === 'object' && props.showSizeChanger) {
117
- // 用户手动传入的优先
112
+ // 用户手动传入对象配置,优先使用
118
113
  return props.showSizeChanger;
119
114
  }
115
+ if (props.showSizeChanger === true) {
116
+ // 用户手动设置为 true,使用 pageSizeOptions 或预置选项
117
+ return getShowSizeChangeOptions(restProps.pageSizeOptions);
118
+ }
120
119
  if (restProps.total && restProps.total > 50) {
121
- // 数据量大于 50,使用预置选项(动态获取以支持国际化)
122
- return getDefaultShowSizeChange();
120
+ // 数据量大于 50,使用 pageSizeOptions 或预置选项
121
+ return getShowSizeChangeOptions(restProps.pageSizeOptions);
123
122
  }
124
123
  return false;
125
124
  };
@@ -9,7 +9,7 @@ export interface PromptsEditorProps {
9
9
  * @description 输入的内容
10
10
  * @descriptionEn Input content value
11
11
  */
12
- value: string;
12
+ value?: string;
13
13
  /**
14
14
  * @description 输入内容的类名
15
15
  * @descriptionEn CSS class name for the input content
@@ -42,6 +42,12 @@ export interface PromptsEditorProps {
42
42
  * @descriptionEn Text of the tips, set to false to hide the tips
43
43
  */
44
44
  tipsText?: string | React.ReactNode | false;
45
+ /**
46
+ * @description 仅可读
47
+ * @descriptionEn Read only
48
+ * @default false
49
+ */
50
+ readOnly?: boolean;
45
51
  }
46
52
  export declare const langExtensionsMap: Record<string, any[]>;
47
53
  declare const _default: React.MemoExoticComponent<(props: PromptsEditorProps) => import("react/jsx-runtime").JSX.Element>;
@@ -69,6 +69,7 @@ export var langExtensionsMap = {
69
69
  };
70
70
  var empty = [];
71
71
  var Editor = function Editor(props) {
72
+ var _props$value;
72
73
  var _useStyles = useStyles(),
73
74
  styles = _useStyles.styles;
74
75
  var variables = props.variables || empty;
@@ -128,11 +129,12 @@ var Editor = function Editor(props) {
128
129
  lineNumbers: false,
129
130
  foldGutter: false,
130
131
  highlightActiveLine: false
131
- }
132
+ },
133
+ readOnly: props.readOnly
132
134
  }, getTheme), /*#__PURE__*/_jsxs("div", {
133
135
  className: styles.footer,
134
136
  children: [tips, props.maxLength ? /*#__PURE__*/_jsxs("div", {
135
- children: [props.value.length, "/", props.maxLength]
137
+ children: [((_props$value = props.value) === null || _props$value === void 0 ? void 0 : _props$value.length) || 0, "/", props.maxLength]
136
138
  }) : null]
137
139
  })]
138
140
  });
@@ -7,6 +7,12 @@ export interface SparkTabsProps extends Omit<TabsProps, 'type'> {
7
7
  * @default true
8
8
  */
9
9
  type?: 'line' | 'card' | 'editable-card' | 'segmented';
10
+ /**
11
+ * @description 类名
12
+ * @descriptionEn ClassName
13
+ * @default ''
14
+ */
15
+ className?: string;
10
16
  }
11
17
  declare const SparkTabs: {
12
18
  (props: SparkTabsProps): import("react/jsx-runtime").JSX.Element;
@@ -1,5 +1,5 @@
1
1
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
- var _excluded = ["type", "centered"];
2
+ var _excluded = ["type", "centered", "className"];
3
3
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
4
4
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
5
5
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
@@ -25,6 +25,7 @@ import { jsxs as _jsxs } from "react/jsx-runtime";
25
25
  var SparkTabs = function SparkTabs(props) {
26
26
  var type = props.type,
27
27
  centered = props.centered,
28
+ className = props.className,
28
29
  restProps = _objectWithoutProperties(props, _excluded);
29
30
  var _getCommonConfig = getCommonConfig(),
30
31
  sparkPrefix = _getCommonConfig.sparkPrefix;
@@ -61,8 +62,8 @@ var SparkTabs = function SparkTabs(props) {
61
62
 
62
63
  // 缓存 className
63
64
  var segmentedClassName = useMemo(function () {
64
- return classNames("".concat(sparkPrefix, "-segmented-tab-bar"), _defineProperty({}, "".concat(sparkPrefix, "-segmented-tab-bar-centered"), centered));
65
- }, [sparkPrefix, centered]);
65
+ return classNames("".concat(sparkPrefix, "-segmented-tab-bar"), _defineProperty({}, "".concat(sparkPrefix, "-segmented-tab-bar-centered"), centered), className);
66
+ }, [sparkPrefix, centered, className]);
66
67
 
67
68
  // 获取当前选中 tab 的内容
68
69
  var activeContent = useMemo(function () {
@@ -89,8 +90,9 @@ var SparkTabs = function SparkTabs(props) {
89
90
  });
90
91
  }
91
92
  return /*#__PURE__*/_jsxs(_Fragment, {
92
- children: [/*#__PURE__*/_jsx(Style, {}), /*#__PURE__*/_jsx(Tabs, _objectSpread(_objectSpread({}, props), {}, {
93
- type: type
93
+ children: [/*#__PURE__*/_jsx(Style, {}), /*#__PURE__*/_jsx(Tabs, _objectSpread(_objectSpread({}, restProps), {}, {
94
+ type: type,
95
+ className: className
94
96
  }))]
95
97
  });
96
98
  };