@zat-design/sisyphus-react 4.0.6 → 4.0.8

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 (51) hide show
  1. package/dist/index.esm.css +1 -1
  2. package/dist/less.esm.css +1 -1
  3. package/es/ProDrawerForm/components/ProDrawer/index.js +2 -2
  4. package/es/ProEditTable/index.js +1 -1
  5. package/es/ProEnum/index.js +1 -1
  6. package/es/ProForm/components/base/Input/index.js +75 -17
  7. package/es/ProForm/components/combination/FormList/components/BlockFields.js +2 -2
  8. package/es/ProForm/components/combination/Group/utils/index.d.ts +25 -25
  9. package/es/ProForm/components/render/ChangedWrapper.js +1 -3
  10. package/es/ProForm/style/index.less +18 -0
  11. package/es/ProIcon/index.js +115 -25
  12. package/es/ProIcon/propsTypes.d.ts +17 -11
  13. package/es/ProLayout/components/ProCollapse/index.js +1 -1
  14. package/es/ProLayout/components/ProHeader/index.js +2 -6
  15. package/es/ProSelect/index.js +1 -1
  16. package/es/ProTable/components/RenderColumn/index.js +1 -1
  17. package/es/ProTable/components/RenderTabs/index.js +9 -3
  18. package/es/ProThemeTools/component/ProTools/index.js +1 -1
  19. package/es/ProTreeModal/components/Trigger.js +34 -13
  20. package/es/ProTreeModal/index.js +6 -0
  21. package/es/ProTreeModal/style/index.less +41 -0
  22. package/es/ProUpload/components/ImageRender.js +1 -1
  23. package/es/ProViewer/index.js +2 -3
  24. package/es/style/theme/antd.less +0 -9
  25. package/es/style/theme/base.less +1 -1
  26. package/es/style/variables.less +1 -0
  27. package/lib/ProDrawerForm/components/ProDrawer/index.js +1 -1
  28. package/lib/ProEditTable/index.js +1 -1
  29. package/lib/ProEnum/index.js +1 -1
  30. package/lib/ProForm/components/base/Input/index.js +73 -16
  31. package/lib/ProForm/components/combination/FormList/components/BlockFields.js +2 -2
  32. package/lib/ProForm/components/combination/Group/utils/index.d.ts +25 -25
  33. package/lib/ProForm/components/render/ChangedWrapper.js +1 -3
  34. package/lib/ProForm/style/index.less +18 -0
  35. package/lib/ProIcon/index.js +117 -25
  36. package/lib/ProIcon/propsTypes.d.ts +17 -11
  37. package/lib/ProLayout/components/ProCollapse/index.js +1 -1
  38. package/lib/ProLayout/components/ProHeader/index.js +3 -6
  39. package/lib/ProSelect/index.js +1 -1
  40. package/lib/ProTable/components/RenderColumn/index.js +1 -1
  41. package/lib/ProTable/components/RenderTabs/index.js +9 -3
  42. package/lib/ProThemeTools/component/ProTools/index.js +1 -1
  43. package/lib/ProTreeModal/components/Trigger.js +34 -13
  44. package/lib/ProTreeModal/index.js +6 -0
  45. package/lib/ProTreeModal/style/index.less +41 -0
  46. package/lib/ProUpload/components/ImageRender.js +1 -1
  47. package/lib/ProViewer/index.js +3 -3
  48. package/lib/style/theme/antd.less +0 -9
  49. package/lib/style/theme/base.less +1 -1
  50. package/lib/style/variables.less +1 -0
  51. package/package.json +14 -14
@@ -19,7 +19,7 @@ import { Button, Drawer, Modal } from 'antd';
19
19
  import React, { useCallback, useState, useRef, useEffect } from 'react';
20
20
  import { useScroll } from 'ahooks';
21
21
  import classNames from 'classnames';
22
- import { isArray } from 'lodash';
22
+ import { isArray, omit } from 'lodash';
23
23
  import { ReactSVG } from 'react-svg';
24
24
  import closeSvg from "../../../assets/close.svg";
25
25
  import locale from "../../../locale";
@@ -252,7 +252,7 @@ var ProDrawer = _ref => {
252
252
  closable: false,
253
253
  onClose: onCancel,
254
254
  zIndex: zIndex
255
- }, restDrawerProps), {}, {
255
+ }, omit(restDrawerProps, 'width')), {}, {
256
256
  children: [/*#__PURE__*/_jsx("div", {
257
257
  className: "pro-drawer-close",
258
258
  onClick: onConfirm,
@@ -463,7 +463,7 @@ var ProEditTable = (_ref, ref) => {
463
463
  className: "pro-edit-table-footer",
464
464
  children: footerRender
465
465
  }) : null, pagination ? /*#__PURE__*/_jsx("div", {
466
- id: `pro-edit-table-pagination-${config.name.join('-')}`,
466
+ id: `pro-edit-table-pagination-${Array.isArray(config.name) ? config.name.filter(Boolean).join('-') : config.name || 'default'}`,
467
467
  onClick: () => {
468
468
  onPageCheck({
469
469
  form,
@@ -264,7 +264,7 @@ var ProEnum = props => {
264
264
  arr.push(props.optionRender(item));
265
265
  });
266
266
  return /*#__PURE__*/_jsx(Space, {
267
- direction: "vertical",
267
+ orientation: "vertical",
268
268
  size: 4,
269
269
  children: arr.map(item => /*#__PURE__*/_jsx(React.Fragment, {
270
270
  children: item
@@ -1,4 +1,5 @@
1
- var _excluded = ["label", "form", "placeholder", "fieldName", "otherProps", "desensitization"];
1
+ var _excluded = ["label", "form", "placeholder", "fieldName", "otherProps", "desensitization"],
2
+ _excluded2 = ["addonBefore", "addonAfter"];
2
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; }
3
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; }
4
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; }
@@ -7,7 +8,7 @@ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e =
7
8
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
8
9
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
9
10
  import React from 'react';
10
- import { Input as AntInput } from 'antd';
11
+ import { Input as AntInput, Space, Button } from 'antd';
11
12
  import { isFunction, omit } from 'lodash';
12
13
  import { useProConfig } from "../../../../ProConfigProvider";
13
14
  import Container from "../../Container";
@@ -18,6 +19,7 @@ import { maskStringRangeWithRegex } from "../../../utils/valueType";
18
19
  // 参数优先级
19
20
  // 组件内默认值 < config默认值 < props
20
21
  import { jsx as _jsx } from "react/jsx-runtime";
22
+ import { jsxs as _jsxs } from "react/jsx-runtime";
21
23
  var Input = function Input(props) {
22
24
  var label = props.label,
23
25
  form = props.form,
@@ -31,43 +33,99 @@ var Input = function Input(props) {
31
33
  viewEmpty = _ref.viewEmpty;
32
34
  var isView = typeof props.isView === 'boolean' ? props.isView : isViewCon; // 组件可直接接收isView参数, 优先级高
33
35
  var initialConfig = useProConfig('Input');
34
- if (typeof rest.value === 'number') {
35
- var _rest$value, _rest$value$toString;
36
- rest.value = rest === null || rest === void 0 || (_rest$value = rest.value) === null || _rest$value === void 0 || (_rest$value$toString = _rest$value.toString) === null || _rest$value$toString === void 0 ? void 0 : _rest$value$toString.call(_rest$value);
36
+
37
+ // 提取 addonBefore 和 addonAfter(antd 6 已废弃,需要使用 Space.Compact)
38
+ var addonBefore = rest.addonBefore,
39
+ addonAfter = rest.addonAfter,
40
+ restProps = _objectWithoutProperties(rest, _excluded2);
41
+ if (typeof restProps.value === 'number') {
42
+ var _restProps$value, _restProps$value$toSt;
43
+ restProps.value = restProps === null || restProps === void 0 || (_restProps$value = restProps.value) === null || _restProps$value === void 0 || (_restProps$value$toSt = _restProps$value.toString) === null || _restProps$value$toSt === void 0 ? void 0 : _restProps$value$toSt.call(_restProps$value);
37
44
  }
38
45
  if (isView) {
39
46
  if ((Array.isArray(desensitization) || isFunction(desensitization)) && props !== null && props !== void 0 && props.disabled) {
40
- if (typeof rest.value === 'number') {
41
- var _rest$value2, _rest$value2$toString;
42
- rest.value = rest === null || rest === void 0 || (_rest$value2 = rest.value) === null || _rest$value2 === void 0 || (_rest$value2$toString = _rest$value2.toString) === null || _rest$value2$toString === void 0 ? void 0 : _rest$value2$toString.call(_rest$value2);
47
+ if (typeof restProps.value === 'number') {
48
+ var _restProps$value2, _restProps$value2$toS;
49
+ restProps.value = restProps === null || restProps === void 0 || (_restProps$value2 = restProps.value) === null || _restProps$value2 === void 0 || (_restProps$value2$toS = _restProps$value2.toString) === null || _restProps$value2$toS === void 0 ? void 0 : _restProps$value2$toS.call(_restProps$value2);
43
50
  }
44
51
  return /*#__PURE__*/_jsx(Container, {
45
52
  viewEmpty: viewEmpty,
46
- children: maskStringRangeWithRegex(rest.value, desensitization)
53
+ children: maskStringRangeWithRegex(restProps.value, desensitization)
47
54
  });
48
55
  }
49
56
  return /*#__PURE__*/_jsx(Container, {
50
57
  viewEmpty: viewEmpty,
51
- children: rest.value
58
+ children: restProps.value
52
59
  });
53
60
  }
54
- var ComInput = /*#__PURE__*/_jsx(AntInput, _objectSpread(_objectSpread({
61
+
62
+ // 构建 Input 组件
63
+ var buildInput = inputProps => /*#__PURE__*/_jsx(AntInput, _objectSpread(_objectSpread({
55
64
  autoComplete: "off",
56
65
  placeholder: placeholder || `${locale.ProForm.inputPlaceholder}`
57
- }, omit(initialConfig, ['trim', 'upperCase'])), rest));
66
+ }, omit(initialConfig, ['trim', 'upperCase'])), inputProps));
67
+
68
+ // 如果存在 addonBefore 或 addonAfter,使用 Space.Compact 包装
69
+ if (addonBefore || addonAfter) {
70
+ // 确保 Input 在 Space.Compact 中能自动扩展宽度
71
+ var inputPropsWithFlex = _objectSpread(_objectSpread({}, restProps), {}, {
72
+ style: _objectSpread(_objectSpread({}, restProps.style), {}, {
73
+ flex: 1
74
+ })
75
+ });
76
+ var _ComInput = buildInput(inputPropsWithFlex);
77
+
78
+ // 仅查看模式下进行数据脱敏
79
+ if ((Array.isArray(desensitization) || isFunction(desensitization)) && props !== null && props !== void 0 && props.disabled) {
80
+ if (typeof restProps.value === 'number') {
81
+ var _restProps$value3, _restProps$value3$toS;
82
+ restProps.value = restProps === null || restProps === void 0 || (_restProps$value3 = restProps.value) === null || _restProps$value3 === void 0 || (_restProps$value3$toS = _restProps$value3.toString) === null || _restProps$value3$toS === void 0 ? void 0 : _restProps$value3$toS.call(_restProps$value3);
83
+ }
84
+ var maskedInput = /*#__PURE__*/React.cloneElement(_ComInput, _objectSpread(_objectSpread(_objectSpread({
85
+ allowClear: true,
86
+ autoComplete: 'off',
87
+ placeholder: placeholder || `${locale.ProForm.inputPlaceholder}`
88
+ }, omit(initialConfig, ['trim', 'upperCase'])), inputPropsWithFlex), {}, {
89
+ value: maskStringRangeWithRegex(restProps.value, desensitization)
90
+ }));
91
+ return /*#__PURE__*/_jsxs(Space.Compact, {
92
+ block: true,
93
+ className: "pro-form-input-space-compact",
94
+ children: [addonBefore ? /*#__PURE__*/_jsx(Button, {
95
+ disabled: true,
96
+ children: addonBefore
97
+ }) : null, maskedInput, addonAfter ? /*#__PURE__*/_jsx(Button, {
98
+ disabled: true,
99
+ children: addonAfter
100
+ }) : null]
101
+ });
102
+ }
103
+ return /*#__PURE__*/_jsxs(Space.Compact, {
104
+ block: true,
105
+ className: "pro-form-input-space-compact",
106
+ children: [addonBefore ? /*#__PURE__*/_jsx(Button, {
107
+ disabled: true,
108
+ children: addonBefore
109
+ }) : null, _ComInput, addonAfter ? /*#__PURE__*/_jsx(Button, {
110
+ disabled: true,
111
+ children: addonAfter
112
+ }) : null]
113
+ });
114
+ }
115
+ var ComInput = buildInput(restProps);
58
116
 
59
117
  // 仅查看模式下进行数据脱敏
60
118
  if ((Array.isArray(desensitization) || isFunction(desensitization)) && props !== null && props !== void 0 && props.disabled) {
61
- if (typeof rest.value === 'number') {
62
- var _rest$value3, _rest$value3$toString;
63
- rest.value = rest === null || rest === void 0 || (_rest$value3 = rest.value) === null || _rest$value3 === void 0 || (_rest$value3$toString = _rest$value3.toString) === null || _rest$value3$toString === void 0 ? void 0 : _rest$value3$toString.call(_rest$value3);
119
+ if (typeof restProps.value === 'number') {
120
+ var _restProps$value4, _restProps$value4$toS;
121
+ restProps.value = restProps === null || restProps === void 0 || (_restProps$value4 = restProps.value) === null || _restProps$value4 === void 0 || (_restProps$value4$toS = _restProps$value4.toString) === null || _restProps$value4$toS === void 0 ? void 0 : _restProps$value4$toS.call(_restProps$value4);
64
122
  }
65
123
  return /*#__PURE__*/React.cloneElement(ComInput, _objectSpread(_objectSpread(_objectSpread({
66
124
  allowClear: true,
67
125
  autoComplete: 'off',
68
126
  placeholder: placeholder || `${locale.ProForm.inputPlaceholder}`
69
- }, omit(initialConfig, ['trim', 'upperCase'])), rest), {}, {
70
- value: maskStringRangeWithRegex(rest.value, desensitization)
127
+ }, omit(initialConfig, ['trim', 'upperCase'])), restProps), {}, {
128
+ value: maskStringRangeWithRegex(restProps.value, desensitization)
71
129
  }));
72
130
  }
73
131
  return ComInput;
@@ -47,7 +47,7 @@ var BlockFields = props => {
47
47
  // 左侧标题布局
48
48
  if (titlePosition === 'left') {
49
49
  return /*#__PURE__*/_jsx(Space, {
50
- direction: "vertical",
50
+ orientation: "vertical",
51
51
  className: cls,
52
52
  id: id,
53
53
  children: /*#__PURE__*/_jsxs("div", {
@@ -98,7 +98,7 @@ var BlockFields = props => {
98
98
 
99
99
  // 默认顶部标题布局
100
100
  return /*#__PURE__*/_jsx(Space, {
101
- direction: "vertical",
101
+ orientation: "vertical",
102
102
  className: cls,
103
103
  id: id,
104
104
  children: /*#__PURE__*/_jsx(ProCollapse, {
@@ -75,38 +75,28 @@ export declare const useFormItemProps: (column: FlexibleGroupColumnType, context
75
75
  confirm?: boolean | import("antd").ModalFuncProps | import("../../../render/propsType").FunctionArgs<any, boolean | import("antd").ModalFuncProps>;
76
76
  show?: boolean | ReactiveFunction<any, boolean>;
77
77
  component?: React.ReactNode | ReactiveFunction<any, React.ReactNode>;
78
- className?: string;
79
78
  trim?: boolean;
80
79
  normalize?: (value: any, prevValue: any, allValues: import("@rc-component/form/lib/interface").Store) => any;
81
80
  children?: React.ReactNode | ((form: FormInstance<any>) => React.ReactNode);
82
- isView?: boolean;
83
- style?: React.CSSProperties;
84
- prefixCls?: string;
85
- rootClassName?: string;
86
81
  id?: string;
87
- vertical?: boolean;
88
- status?: "" | "error" | "success" | "warning" | "validating";
82
+ className?: string;
89
83
  hidden?: boolean;
84
+ style?: React.CSSProperties;
90
85
  onReset?: () => void;
91
- htmlFor?: string;
92
- valueType?: import("../../../render/propsType").ProFormValueType;
93
- trigger?: string;
94
- viewRender?: (value: any, record: any, { form, index, namePath, }: {
95
- [key: string]: any;
96
- form: FormInstance<any>;
97
- index?: number;
98
- }) => string | React.ReactElement<any, any>;
99
- desensitization?: [number, number] | ReactiveFunction<any, [number, number]>;
100
- layout?: import("antd/es/form/Form").FormItemLayout;
101
- help?: React.ReactNode;
102
- preserve?: boolean;
103
- viewType?: import("../../../render/propsType").ViewType;
86
+ prefixCls?: string;
87
+ rootClassName?: string;
88
+ status?: "" | "warning" | "error" | "success" | "validating";
104
89
  validateTrigger?: string | false | string[];
90
+ preserve?: boolean;
91
+ labelCol?: import("antd").ColProps;
92
+ wrapperCol?: import("antd").ColProps;
105
93
  colon?: boolean;
94
+ htmlFor?: string;
106
95
  labelAlign?: import("antd/es/form/interface").FormLabelAlign;
107
- labelCol?: import("antd").ColProps;
96
+ vertical?: boolean;
108
97
  getValueFromEvent?: (...args: import("@rc-component/form/lib/interface").EventArgs) => any;
109
98
  shouldUpdate?: import("@rc-component/form/lib/Field").ShouldUpdate<any>;
99
+ trigger?: string;
110
100
  validateDebounce?: number;
111
101
  valuePropName?: string;
112
102
  getValueProps?: ((value: any) => Record<string, unknown>) & ((value: any) => Record<string, unknown>);
@@ -115,15 +105,25 @@ export declare const useFormItemProps: (column: FlexibleGroupColumnType, context
115
105
  onMetaChange?: (meta: import("@rc-component/form/lib/Field").MetaEvent) => void;
116
106
  isListField?: boolean;
117
107
  isList?: boolean;
108
+ upperCase?: boolean;
109
+ desensitization?: [number, number] | ReactiveFunction<any, [number, number]>;
110
+ isView?: boolean;
118
111
  noStyle?: boolean;
119
112
  hasFeedback?: boolean | {
120
113
  icons: import("antd/es/form/FormItem").FeedbackIcons;
121
114
  };
122
- validateStatus?: "" | "error" | "success" | "warning" | "validating";
123
- wrapperCol?: import("antd").ColProps;
115
+ validateStatus?: "" | "warning" | "error" | "success" | "validating";
116
+ layout?: import("antd/es/form/Form").FormItemLayout;
117
+ help?: React.ReactNode;
124
118
  fieldId?: string;
119
+ valueType?: import("../../../render/propsType").ProFormValueType;
125
120
  switchValue?: [any, any];
126
- upperCase?: boolean;
121
+ viewRender?: (value: any, record: any, { form, index, namePath, }: {
122
+ [key: string]: any;
123
+ form: FormInstance<any>;
124
+ index?: number;
125
+ }) => string | React.ReactElement<any, any>;
126
+ viewType?: import("../../../render/propsType").ViewType;
127
127
  toISOString?: boolean;
128
128
  toCSTString?: boolean;
129
129
  clearNotShow?: boolean;
@@ -141,7 +141,7 @@ export declare const useFormItemProps: (column: FlexibleGroupColumnType, context
141
141
  * 创建组件属性
142
142
  */
143
143
  export declare const createComponentProps: (column: FlexibleGroupColumnType, formItemProps: any) => {
144
- componentProps: import("lodash").Omit<any, "format" | "valueType" | "precision" | "switchValue" | "dependNames" | "toISOString" | "toCSTString" | "clearNotShow">;
144
+ componentProps: import("lodash").Omit<any, "format" | "precision" | "valueType" | "switchValue" | "dependNames" | "toISOString" | "toCSTString" | "clearNotShow">;
145
145
  formItemTransform: {
146
146
  getValueProps: any;
147
147
  normalize: any;
@@ -87,8 +87,6 @@ var ChangedWrapper = props => {
87
87
  originalValues: isNestedField ? originalValues : undefined
88
88
  }, children.props), rest));
89
89
  }
90
-
91
- // eslint-disable-next-line react-hooks/rules-of-hooks
92
90
  var tipOpenCalc = () => {
93
91
  if (!toolTip) return false;
94
92
 
@@ -119,7 +117,7 @@ var ChangedWrapper = props => {
119
117
  placement: "topLeft",
120
118
  autoAdjustOverflow: false,
121
119
  title: /*#__PURE__*/_jsxs(Space, {
122
- direction: "vertical",
120
+ orientation: "vertical",
123
121
  className: "changed-tooltip",
124
122
  children: [/*#__PURE__*/_jsxs(Space, {
125
123
  align: "start",
@@ -177,6 +177,12 @@
177
177
  margin-left: @zaui-space-size-sm;
178
178
  }
179
179
 
180
+ .pro-form-input-space-compact{
181
+ .@{ant-prefix}-btn{
182
+ color: #333;
183
+ }
184
+ }
185
+
180
186
  .@{ant-prefix}-form-item-has-error {
181
187
  .group-separator {
182
188
  color: #ff4d4f;
@@ -186,6 +192,18 @@
186
192
  .site-input-split {
187
193
  border-color: @zaui-danger;
188
194
  }
195
+ .pro-form-input-space-compact{
196
+ .@{ant-prefix}-btn{
197
+ color: @zaui-danger;
198
+ border-color: @zaui-danger;
199
+ }
200
+ }
201
+ .pro-tree-modal{
202
+ .pro-enum-input-addonAfter{
203
+ border-color: @zaui-danger;
204
+ color: @zaui-danger;
205
+ }
206
+ }
189
207
  }
190
208
 
191
209
  .site-input-group-wrapper {
@@ -1,4 +1,4 @@
1
- var _excluded = ["type", "onClick", "size", "color", "className", "style", "spin", "rotate", "theme", "disabled", "mode", "buttonProps", "children", "mapList", "src", "actionMap", "tooltip", "buttonIcon"];
1
+ var _excluded = ["type", "onClick", "size", "color", "className", "style", "spin", "rotate", "theme", "disabled", "mode", "buttonProps", "children", "mapList", "component", "src", "actionMap", "tooltip", "buttonIcon"];
2
2
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
3
3
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
4
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
@@ -17,7 +17,7 @@ import { Button, Tooltip, Space } from 'antd';
17
17
  import classNames from 'classnames';
18
18
  import { uniqBy } from 'lodash';
19
19
  import { ReactSVG } from 'react-svg';
20
- import { useEffect } from 'react';
20
+ import React, { useEffect } from 'react';
21
21
  import { useProConfig } from "../ProConfigProvider";
22
22
  import { iconMap } from "./config";
23
23
  import { onBeforeInjection } from "./utils";
@@ -55,6 +55,7 @@ var ProIcon = props => {
55
55
  children = _config.children,
56
56
  _config$mapList = _config.mapList,
57
57
  mapList = _config$mapList === void 0 ? [] : _config$mapList,
58
+ component = _config.component,
58
59
  src = _config.src,
59
60
  actionMap = _config.actionMap,
60
61
  tooltip = _config.tooltip,
@@ -145,37 +146,126 @@ var ProIcon = props => {
145
146
  height: size
146
147
  }, rotateStyle), style)
147
148
  };
148
- var icon = !src ? /*#__PURE__*/_jsx("svg", _objectSpread(_objectSpread({}, svgProps), {}, {
149
- style: _objectSpread({
150
- color
151
- }, svgProps === null || svgProps === void 0 ? void 0 : svgProps.style),
152
- onClick: onClick,
153
- "aria-hidden": "true",
154
- children: /*#__PURE__*/_jsx("use", {
155
- xlinkHref: `#icon-${_type}`
156
- })
157
- })) : /*#__PURE__*/_jsx(ReactSVG, _objectSpread(_objectSpread({}, svgProps), {}, {
158
- // @ts-ignore
159
- onClick: onClick,
160
- "aria-hidden": "true",
161
- src: src,
162
- beforeInjection: svg => {
163
- onBeforeInjection({
164
- svg,
165
- actionMap,
166
- primaryColor: isQiankun ? qiankunPrimaryColor : primaryColor
149
+
150
+ // 渲染 icon 的优先级:component > src > type
151
+ var icon;
152
+ if (component) {
153
+ // 判断 component 的类型
154
+ if (typeof component === 'string') {
155
+ // 字符串类型:当作 SVG 文件路径处理,使用 ReactSVG 加载
156
+ icon = /*#__PURE__*/_jsx(ReactSVG, {
157
+ className: proIconClassNames
158
+ // @ts-ignore
159
+ ,
160
+ onClick: onClick,
161
+ src: component,
162
+ beforeInjection: svg => {
163
+ // 设置 SVG 的宽高
164
+ svg.setAttribute('width', String(size));
165
+ svg.setAttribute('height', String(size));
166
+ svg.setAttribute('aria-hidden', 'true');
167
+
168
+ // 应用旋转
169
+ if (rotate) {
170
+ var transform = svg.getAttribute('transform') || '';
171
+ svg.setAttribute('transform', `${transform} rotate(${rotate})`);
172
+ svg.style.transform = `rotate(${rotate}deg)`;
173
+ }
174
+
175
+ // 应用颜色 - 设置 fill 和 currentColor
176
+ if (color) {
177
+ svg.setAttribute('fill', color);
178
+ svg.style.color = color;
179
+ // 遍历所有路径元素,设置 fill
180
+ var paths = svg.querySelectorAll('path, circle, rect, polygon, ellipse');
181
+ paths.forEach(path => {
182
+ var currentFill = path.getAttribute('fill');
183
+ // 只修改使用 currentColor 或没有设置 fill 的元素
184
+ if (!currentFill || currentFill === 'currentColor') {
185
+ path.setAttribute('fill', color);
186
+ }
187
+ });
188
+ } else {
189
+ // 没有指定颜色时,使用 currentColor
190
+ svg.style.color = 'currentColor';
191
+ }
192
+
193
+ // 应用自定义样式
194
+ if (style) {
195
+ Object.keys(style).forEach(key => {
196
+ svg.style[key] = style[key];
197
+ });
198
+ }
199
+
200
+ // 应用 actionMap 的主题配置
201
+ onBeforeInjection({
202
+ svg,
203
+ actionMap,
204
+ primaryColor: isQiankun ? qiankunPrimaryColor : primaryColor
205
+ });
206
+ }
167
207
  });
168
- if (color) {
169
- svg.setAttribute('fill', color);
208
+ } else {
209
+ // 处理自定义组件
210
+ var componentProps = _objectSpread(_objectSpread({}, svgProps), {}, {
211
+ style: _objectSpread({
212
+ color
213
+ }, svgProps === null || svgProps === void 0 ? void 0 : svgProps.style),
214
+ onClick,
215
+ 'aria-hidden': 'true'
216
+ });
217
+
218
+ // 判断是组件类型还是组件实例
219
+ if ( /*#__PURE__*/React.isValidElement(component)) {
220
+ // 组件实例:使用 cloneElement
221
+ icon = /*#__PURE__*/React.cloneElement(component, componentProps);
222
+ } else {
223
+ // 组件类型:直接渲染
224
+ var ComponentType = component;
225
+ icon = /*#__PURE__*/_jsx(ComponentType, _objectSpread({}, componentProps));
170
226
  }
171
227
  }
172
- }));
228
+ } else if (src) {
229
+ // 使用 ReactSVG 加载外部 SVG
230
+ icon = /*#__PURE__*/_jsx(ReactSVG, _objectSpread(_objectSpread({}, svgProps), {}, {
231
+ // @ts-ignore
232
+ onClick: onClick,
233
+ "aria-hidden": "true",
234
+ src: src,
235
+ beforeInjection: svg => {
236
+ onBeforeInjection({
237
+ svg,
238
+ actionMap,
239
+ primaryColor: isQiankun ? qiankunPrimaryColor : primaryColor
240
+ });
241
+ if (color) {
242
+ svg.setAttribute('fill', color);
243
+ }
244
+ }
245
+ }));
246
+ } else {
247
+ // 使用 symbol icon
248
+ icon = /*#__PURE__*/_jsx("svg", _objectSpread(_objectSpread({}, svgProps), {}, {
249
+ style: _objectSpread({
250
+ color
251
+ }, svgProps === null || svgProps === void 0 ? void 0 : svgProps.style),
252
+ onClick: onClick,
253
+ "aria-hidden": "true",
254
+ children: /*#__PURE__*/_jsx("use", {
255
+ xlinkHref: `#icon-${_type}`
256
+ })
257
+ }));
258
+ }
259
+
260
+ // 判断 RenderIcon 是否会被外层 Button 包裹
261
+ // 如果会被包裹(isExtendButtonMode && isIconMode),则内部不使用 Button,避免 button 嵌套
262
+ var willBeWrappedByButton = isExtendButtonMode && isIconMode;
173
263
  var RenderIcon = /*#__PURE__*/_jsx("span", _objectSpread(_objectSpread({
174
264
  className: "anticon"
175
265
  }, reset), {}, {
176
266
  children: /*#__PURE__*/_jsx(Tooltip, {
177
267
  title: iconText,
178
- children: buttonIcon ? /*#__PURE__*/_jsx(Button, _objectSpread({
268
+ children: buttonIcon && !willBeWrappedByButton ? /*#__PURE__*/_jsx(Button, _objectSpread({
179
269
  style: {
180
270
  width: size,
181
271
  height: size,
@@ -1,4 +1,4 @@
1
- import { CSSProperties, ReactNode, MouseEventHandler } from 'react';
1
+ import { CSSProperties, ReactNode, MouseEventHandler, ComponentType, ReactElement } from 'react';
2
2
  import { ButtonProps } from 'antd/lib/button';
3
3
  /**
4
4
  * 图标模式
@@ -69,24 +69,30 @@ interface ProIconActionMapType {
69
69
  fill?: string[];
70
70
  }
71
71
  export interface ProIconType {
72
+ /**
73
+ * 自定义 SVG 组件
74
+ * @description 自定义 SVG React 组件或 SVG 文件路径,支持传入组件类型、组件实例或字符串路径,优先级高于 src 和 type
75
+ * @default undefined
76
+ */
77
+ component?: ComponentType<any> | ReactElement | string;
72
78
  /**
73
79
  * 图标路径
74
80
  * @description 本地import引入的图标路径
75
- * @default ""
81
+ * @default undefined
76
82
  */
77
83
  src?: string;
78
84
  /**
79
85
  * 图标名称
80
86
  * @description 图标的类型名称,用于识别特定图标
81
- * @default undefined
87
+ * @default null
82
88
  */
83
- type?: string;
89
+ type?: string | null;
84
90
  /**
85
91
  * 图标大小
86
92
  * @description 图标的大小,同时设置图标的width以及height
87
- * @default 14
93
+ * @default '1em'
88
94
  */
89
- size?: number;
95
+ size?: number | string;
90
96
  /**
91
97
  * 旋转角度
92
98
  * @description 图标旋转角度(IE9 无效)
@@ -126,7 +132,7 @@ export interface ProIconType {
126
132
  /**
127
133
  * 点击事件
128
134
  * @description 图标的点击事件处理函数
129
- * @default () => {}
135
+ * @default undefined
130
136
  */
131
137
  onClick?: MouseEventHandler<SVGSVGElement>;
132
138
  /**
@@ -138,7 +144,7 @@ export interface ProIconType {
138
144
  /**
139
145
  * 自定义样式
140
146
  * @description 计算后的svg元素样式,优先级高于size/color/rotate属性
141
- * @default undefined
147
+ * @default {}
142
148
  */
143
149
  style?: CSSProperties;
144
150
  /**
@@ -150,13 +156,13 @@ export interface ProIconType {
150
156
  /**
151
157
  * 按钮属性
152
158
  * @description mode为button时的按钮属性,与antd Button接收props一致
153
- * @default { type: 'link' }
159
+ * @default {}
154
160
  */
155
161
  buttonProps?: ButtonProps;
156
162
  /**
157
163
  * 图标映射表
158
164
  * @description 图标与中英文文本的映射表
159
- * @default 项目内默认映射
165
+ * @default []
160
166
  */
161
167
  mapList?: ProIconMapType[];
162
168
  /**
@@ -168,7 +174,7 @@ export interface ProIconType {
168
174
  /**
169
175
  * 按钮图标标记
170
176
  * @description 内部使用,标记图标作为按钮使用
171
- * @default undefined
177
+ * @default true
172
178
  */
173
179
  buttonIcon?: boolean;
174
180
  }
@@ -181,7 +181,7 @@ var ProCollapse = props => {
181
181
  rotate: isActive ? -90 : 90
182
182
  });
183
183
  },
184
- expandIconPosition: "end",
184
+ expandIconPlacement: "end",
185
185
  defaultActiveKey: folding ? [] : ['1'],
186
186
  onChange: onChange,
187
187
  items: getCollapseItems()
@@ -12,7 +12,6 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
12
12
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
13
13
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
14
14
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
15
- /* eslint-disable react/no-array-index-key */
16
15
  import { Space, Divider, Breadcrumb, Tooltip, Modal } from 'antd';
17
16
  import React, { memo, useEffect, useState, useRef } from 'react';
18
17
  import { tools } from '@zat-design/utils';
@@ -143,10 +142,7 @@ var ProHeader = props => {
143
142
  return /*#__PURE__*/_jsxs(Space, {
144
143
  size: 4,
145
144
  align: params !== null && params !== void 0 && params.tag ? 'baseline' : 'center',
146
- children: [params !== null && params !== void 0 && params.link ?
147
- /*#__PURE__*/
148
- // eslint-disable-next-line jsx-a11y/anchor-is-valid
149
- _jsx("a", {
145
+ children: [params !== null && params !== void 0 && params.link ? /*#__PURE__*/_jsx("a", {
150
146
  onClick: () => {
151
147
  var newWindow = window.open(params.link);
152
148
  newWindow.opener = null;
@@ -292,7 +288,7 @@ var ProHeader = props => {
292
288
  if (Array.isArray(actionRender) && actionRender.length) {
293
289
  return /*#__PURE__*/_jsx(Space, {
294
290
  separator: /*#__PURE__*/_jsx(Divider, {
295
- type: "vertical"
291
+ orientation: "vertical"
296
292
  }),
297
293
  children: actionRender.map((item, index) => {
298
294
  var _item$props;
@@ -212,7 +212,7 @@ export var ProSelect = (props, ref) => {
212
212
  arr.push(props.optionRender(item));
213
213
  });
214
214
  return /*#__PURE__*/_jsx(Space, {
215
- direction: "vertical",
215
+ orientation: "vertical",
216
216
  size: 4,
217
217
  children: arr.map(item => /*#__PURE__*/_jsx(React.Fragment, {
218
218
  children: item
@@ -144,7 +144,7 @@ var RenderColumn = props => {
144
144
  placement: "topLeft",
145
145
  autoAdjustOverflow: false,
146
146
  title: /*#__PURE__*/_jsx(Space, {
147
- direction: "vertical",
147
+ orientation: "vertical",
148
148
  className: "changed-tooltip",
149
149
  children: props !== null && props !== void 0 && props.isChanged && !(props !== null && props !== void 0 && props.isAddCell) ? /*#__PURE__*/_jsxs(_Fragment, {
150
150
  children: [/*#__PURE__*/_jsxs(Space, {