@agentscope-ai/design 1.0.27-beta.1769499161692 → 1.0.27-beta.1769678521654

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({
@@ -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
  };
@@ -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>;
@@ -128,7 +128,8 @@ var Editor = function Editor(props) {
128
128
  lineNumbers: false,
129
129
  foldGutter: false,
130
130
  highlightActiveLine: false
131
- }
131
+ },
132
+ readOnly: props.readOnly
132
133
  }, getTheme), /*#__PURE__*/_jsxs("div", {
133
134
  className: styles.footer,
134
135
  children: [tips, props.maxLength ? /*#__PURE__*/_jsxs("div", {