@zat-design/sisyphus-react 4.3.3 → 4.3.4-beta.1

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.
@@ -61,7 +61,6 @@ const Row = props => {
61
61
  component: dragSvg,
62
62
  size: 20,
63
63
  color: "#949599",
64
- buttonIcon: false,
65
64
  style: {
66
65
  touchAction: 'none',
67
66
  cursor: disabled ? 'no-drop' : 'move'
@@ -41,12 +41,10 @@ const getDefaultActions = mode => {
41
41
  icon: mode === 'less' ? /*#__PURE__*/_jsx(ProIcon, {
42
42
  component: close2Svg,
43
43
  size: 14,
44
- className: "single-delete",
45
- buttonIcon: false
44
+ className: "single-delete"
46
45
  }) : /*#__PURE__*/_jsx(ProIcon, {
47
46
  component: deleteSvg,
48
- size: 18,
49
- buttonIcon: false
47
+ size: 18
50
48
  })
51
49
  },
52
50
  copy: {
@@ -68,8 +68,7 @@ const LineFields = props => {
68
68
  children: /*#__PURE__*/_jsx(ProIcon, {
69
69
  component: dragSvg,
70
70
  size: 20,
71
- color: "#949599",
72
- buttonIcon: false
71
+ color: "#949599"
73
72
  })
74
73
  }), /*#__PURE__*/_jsx(Row, {
75
74
  gutter: isLess ? 0 : 24,
@@ -75,38 +75,35 @@ 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
- onReset?: () => void;
79
- trim?: boolean;
80
- normalize?: (value: any, prevValue: any, allValues: import("@rc-component/form/lib/interface").Store) => any;
81
- children?: React.ReactNode | ((form: FormInstance<any>) => React.ReactNode);
82
- className?: string;
83
78
  status?: "" | "warning" | "error" | "success" | "validating";
79
+ className?: string;
84
80
  hidden?: boolean;
85
81
  id?: string;
86
82
  style?: React.CSSProperties;
87
- htmlFor?: string;
83
+ children?: React.ReactNode | ((form: FormInstance<any>) => React.ReactNode);
84
+ onReset?: () => void;
88
85
  prefixCls?: string;
89
- trigger?: string;
90
- isView?: boolean;
91
86
  rootClassName?: string;
92
- getValueProps?: ((value: any) => Record<string, unknown>) & ((value: any) => Record<string, unknown>);
87
+ isView?: boolean;
93
88
  vertical?: boolean;
94
- desensitization?: [number, number] | ReactiveFunction<any, [number, number]>;
95
- validateTrigger?: string | false | string[];
96
- preserve?: boolean;
89
+ trim?: boolean;
90
+ normalize?: (value: any, prevValue: any, allValues: import("@rc-component/form/lib/interface").Store) => any;
91
+ trigger?: string;
92
+ htmlFor?: string;
97
93
  clearNotShow?: boolean;
98
- labelAlign?: import("antd/es/form/interface").FormLabelAlign;
99
94
  colon?: boolean;
100
- layout?: import("antd/es/form/Form").FormItemLayout;
95
+ labelAlign?: import("antd/es/form/interface").FormLabelAlign;
101
96
  labelCol?: import("antd").ColProps;
102
- wrapperCol?: import("antd").ColProps;
103
97
  getValueFromEvent?: (...args: import("@rc-component/form/lib/interface").EventArgs) => any;
104
98
  shouldUpdate?: import("@rc-component/form/lib/Field").ShouldUpdate<any>;
99
+ validateTrigger?: string | false | string[];
105
100
  validateDebounce?: number;
106
101
  valuePropName?: string;
102
+ getValueProps?: ((value: any) => Record<string, unknown>) & ((value: any) => Record<string, unknown>);
107
103
  messageVariables?: Record<string, string>;
108
104
  initialValue?: any;
109
105
  onMetaChange?: (meta: import("@rc-component/form/lib/Field").MetaEvent) => void;
106
+ preserve?: boolean;
110
107
  isListField?: boolean;
111
108
  isList?: boolean;
112
109
  noStyle?: boolean;
@@ -114,6 +111,8 @@ export declare const useFormItemProps: (column: FlexibleGroupColumnType, context
114
111
  icons: import("antd/es/form/FormItem").FeedbackIcons;
115
112
  };
116
113
  validateStatus?: "" | "warning" | "error" | "success" | "validating";
114
+ layout?: import("antd/es/form/Form").FormItemLayout;
115
+ wrapperCol?: import("antd").ColProps;
117
116
  help?: React.ReactNode;
118
117
  fieldId?: string;
119
118
  valueType?: import("../../../render/propsType").ProFormValueType;
@@ -127,6 +126,7 @@ export declare const useFormItemProps: (column: FlexibleGroupColumnType, context
127
126
  upperCase?: boolean;
128
127
  toISOString?: boolean;
129
128
  toCSTString?: boolean;
129
+ desensitization?: [number, number] | ReactiveFunction<any, [number, number]>;
130
130
  name: any;
131
131
  dependencies: any[];
132
132
  tooltip: string | {
@@ -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" | "clearNotShow" | "valueType" | "switchValue" | "dependNames" | "toISOString" | "toCSTString" | "precision">;
144
+ componentProps: import("lodash").Omit<any, "clearNotShow" | "format" | "valueType" | "switchValue" | "dependNames" | "toISOString" | "toCSTString" | "precision">;
145
145
  formItemTransform: {
146
146
  getValueProps: any;
147
147
  normalize: any;
@@ -1,16 +1,16 @@
1
1
  import _uniqBy from "lodash/uniqBy";
2
- import { useLocalStorageState, useSetState, useDeepCompareLayoutEffect } from 'ahooks';
3
- import { Button, Tooltip, Space } from 'antd';
2
+ import { useLocalStorageState } from 'ahooks';
3
+ import { Button, Tooltip } from 'antd';
4
4
  import classNames from 'classnames';
5
5
  import { ReactSVG } from 'react-svg';
6
- import React, { useEffect } from 'react';
6
+ import React, { useEffect, useRef } from 'react';
7
7
  import { useProConfig } from "../ProConfigProvider";
8
8
  import { iconMap } from "./config";
9
9
  import { onBeforeInjection } from "./utils";
10
10
  import locale from "../locale";
11
11
 
12
12
  // 提取主题色相关辅助函数
13
- import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
13
+ import { jsx as _jsx } from "react/jsx-runtime";
14
14
  const extractThemeColor = target => {
15
15
  if (!target) return null;
16
16
  const styleAttr = Object.values(target.attributes ?? {})
@@ -85,14 +85,8 @@ const ProIcon = props => {
85
85
  src,
86
86
  actionMap,
87
87
  tooltip,
88
- buttonIcon = true,
89
88
  ...reset
90
89
  } = _config;
91
- const [{
92
- IconInstance
93
- }, setState] = useSetState({
94
- IconInstance: /*#__PURE__*/_jsx(_Fragment, {})
95
- });
96
90
 
97
91
  // 主题色 primaryColor 用于单应用或处于组件库文档内 qiankunPrimaryColor用于主子应用
98
92
  const {
@@ -119,26 +113,23 @@ const ProIcon = props => {
119
113
  const proIconClassNames = classNames(className, {
120
114
  'pro-icon': !disabled,
121
115
  'pro-icon-spin': !!spin,
122
- 'pro-icon-with-theme': theme,
123
- 'pro-icon-btn': disabled
116
+ 'pro-icon-with-theme': theme
124
117
  });
125
- let _mode = mode || 'icon';
126
-
127
- // 观察者实例
128
- let observer;
129
118
 
130
119
  // 特殊情况,如果指定了type,并且没有接收到组件内的mode,那模式就是icon
120
+ let _mode = mode || 'icon';
131
121
  if (type && !props.mode) {
132
122
  _mode = 'icon';
133
123
  }
134
- const targetTextFill = `text-${language}`; // text-cn text-en
135
-
136
124
  const isIconMode = _mode === 'icon';
137
- const isExtendButtonMode = !isIconMode || isIconMode && disabled;
125
+
126
+ // 观察者实例(主题色同步用)
127
+ const observerRef = useRef(null);
128
+ const targetTextFill = `text-${language}`; // text-cn text-en
138
129
  const mergedMapList = _uniqBy(mapList.concat(iconMap), targetTextFill);
139
130
  let _type = type;
140
131
  let _text = children;
141
- // svg图标对应文本
132
+ // svg 图标对应文本
142
133
  let iconText = tooltip || '';
143
134
 
144
135
  // 文本和类型映射处理函数
@@ -171,6 +162,9 @@ const ProIcon = props => {
171
162
  _text = mappingResult.text;
172
163
  }
173
164
  }
165
+
166
+ // disabled 时,icon 模式下拦截 onClick,仅保留视觉降级
167
+ const effectiveOnClick = disabled ? undefined : onClick;
174
168
  const svgProps = {
175
169
  className: proIconClassNames,
176
170
  fill: 'currentColor',
@@ -241,28 +235,26 @@ const ProIcon = props => {
241
235
  };
242
236
 
243
237
  // 渲染自定义组件 icon
244
- const renderComponentIcon = (component, svgProps, color, onClick) => {
238
+ // 注意:icon 本身不绑定 onClick,点击由外层容器(span Button)统一处理,避免重复触发
239
+ const renderComponentIcon = (component, svgProps, color) => {
245
240
  const componentProps = {
246
241
  ...svgProps,
247
242
  style: {
248
243
  color,
249
244
  ...svgProps?.style
250
245
  },
251
- onClick,
252
246
  'aria-hidden': 'true'
253
247
  };
254
248
  return /*#__PURE__*/React.isValidElement(component) ? /*#__PURE__*/React.cloneElement(component, componentProps) : /*#__PURE__*/React.createElement(component, componentProps);
255
249
  };
256
250
 
257
251
  // 渲染 icon 的优先级:component > src > type
252
+ // 所有分支都不绑定 onClick,交由外层容器处理,避免 svg + span 双重触发
258
253
  const renderIcon = () => {
259
254
  // component 字符串类型:当作 SVG 文件路径处理
260
255
  if (component && typeof component === 'string') {
261
256
  return /*#__PURE__*/_jsx(ReactSVG, {
262
- className: proIconClassNames
263
- // @ts-ignore
264
- ,
265
- onClick: onClick,
257
+ className: proIconClassNames,
266
258
  src: component,
267
259
  beforeInjection: createSvgBeforeInjection(true)
268
260
  });
@@ -270,15 +262,13 @@ const ProIcon = props => {
270
262
 
271
263
  // component 组件类型或实例(排除字符串类型)
272
264
  if (component && typeof component !== 'string') {
273
- return renderComponentIcon(component, svgProps, color, onClick);
265
+ return renderComponentIcon(component, svgProps, color);
274
266
  }
275
267
 
276
268
  // src 类型:使用 ReactSVG 加载外部 SVG
277
269
  if (src) {
278
270
  return /*#__PURE__*/_jsx(ReactSVG, {
279
271
  ...svgProps,
280
- // @ts-ignore
281
- onClick: onClick,
282
272
  "aria-hidden": "true",
283
273
  src: src,
284
274
  beforeInjection: createSvgBeforeInjection()
@@ -292,7 +282,6 @@ const ProIcon = props => {
292
282
  color,
293
283
  ...svgProps?.style
294
284
  },
295
- onClick: onClick,
296
285
  "aria-hidden": "true",
297
286
  children: /*#__PURE__*/_jsx("use", {
298
287
  xlinkHref: `#icon-${_type}`
@@ -300,42 +289,13 @@ const ProIcon = props => {
300
289
  });
301
290
  };
302
291
  const icon = renderIcon();
303
-
304
- // 判断 RenderIcon 是否会被外层 Button 包裹
305
- // 如果会被包裹(isExtendButtonMode && isIconMode),则内部不使用 Button,避免 button 嵌套
306
- const willBeWrappedByButton = isExtendButtonMode && isIconMode;
307
- const RenderIcon = /*#__PURE__*/_jsx("span", {
308
- className: "anticon",
309
- ...reset,
310
- children: /*#__PURE__*/_jsx(Tooltip, {
311
- title: iconText,
312
- children: buttonIcon && !willBeWrappedByButton ? /*#__PURE__*/_jsx(Button, {
313
- className: "pro-icon-btn-inner",
314
- style: {
315
- width: size,
316
- height: size
317
- },
318
- type: "text",
319
- icon: icon,
320
- ...buttonProps
321
- }) : /*#__PURE__*/_jsx(Space, {
322
- children: /*#__PURE__*/_jsx("span", {
323
- className: "pro-icon-wrapper",
324
- style: {
325
- width: size,
326
- height: size
327
- },
328
- children: icon
329
- })
330
- })
331
- })
332
- });
333
292
  useEffect(() => {
334
293
  // 处于主子应用情况下才会执行下方逻辑,主题色的变更以主框架的为准
335
294
  if (!actionMap || !isQiankun) return;
336
- observer = new MutationObserver(mutationsList => {
295
+ const observer = new MutationObserver(mutationsList => {
337
296
  handleMutation(mutationsList, dispatch, primaryColor, qiankunPrimaryColor);
338
297
  });
298
+ observerRef.current = observer;
339
299
  const mainWindow = getMainAppWindow();
340
300
  const zaAccessibilityTarget = mainWindow.document.documentElement;
341
301
  observer.observe(zaAccessibilityTarget, {
@@ -348,29 +308,47 @@ const ProIcon = props => {
348
308
  if (extendFromMainColor && qiankunPrimaryColor !== extendFromMainColor) {
349
309
  updateThemeColor(extendFromMainColor, dispatch, primaryColor);
350
310
  }
351
- }, []);
352
- useEffect(() => {
353
311
  return () => {
354
- if (observer) {
355
- observer.disconnect();
356
- }
312
+ observer.disconnect();
313
+ observerRef.current = null;
357
314
  };
358
315
  }, []);
359
- useDeepCompareLayoutEffect(() => {
360
- setState({
361
- IconInstance: RenderIcon
316
+
317
+ // mode=button:唯一走 Button 的分支
318
+ if (!isIconMode) {
319
+ return /*#__PURE__*/_jsx(Tooltip, {
320
+ title: tooltip,
321
+ children: /*#__PURE__*/_jsx(Button, {
322
+ type: buttonProps?.type || 'link',
323
+ className: proIconClassNames,
324
+ disabled: disabled,
325
+ icon: null,
326
+ onClick: effectiveOnClick,
327
+ ...reset,
328
+ ...buttonProps,
329
+ children: _text
330
+ })
362
331
  });
363
- }, [_config, primaryColor, qiankunPrimaryColor, language, svgProps]);
364
- return !isExtendButtonMode ? IconInstance : /*#__PURE__*/_jsx(Tooltip, {
365
- title: tooltip,
366
- children: /*#__PURE__*/_jsx(Button, {
367
- type: isIconMode ? 'text' : buttonProps?.type || 'link',
368
- className: proIconClassNames,
369
- disabled: disabled,
370
- icon: isIconMode ? RenderIcon : null,
332
+ }
333
+
334
+ // mode=icon(默认):不套 Button
335
+ const wrapperClassName = classNames('anticon', proIconClassNames, {
336
+ 'pro-icon-disabled': disabled
337
+ });
338
+ return /*#__PURE__*/_jsx(Tooltip, {
339
+ title: tooltip || iconText,
340
+ children: /*#__PURE__*/_jsx("span", {
341
+ className: wrapperClassName,
342
+ style: {
343
+ display: 'inline-flex',
344
+ alignItems: 'center',
345
+ justifyContent: 'center',
346
+ width: size,
347
+ height: size
348
+ },
349
+ onClick: effectiveOnClick,
371
350
  ...reset,
372
- ...buttonProps,
373
- children: _text
351
+ children: icon
374
352
  })
375
353
  });
376
354
  };
@@ -171,11 +171,5 @@ export interface ProIconType {
171
171
  * @default undefined
172
172
  */
173
173
  actionMap?: ProIconActionMapType;
174
- /**
175
- * 按钮图标标记
176
- * @description 内部使用,标记图标作为按钮使用
177
- * @default true
178
- */
179
- buttonIcon?: boolean;
180
174
  }
181
175
  export {};
@@ -12,25 +12,20 @@
12
12
  }
13
13
  }
14
14
 
15
- // 内层图标容器(buttonIcon=false 时的 span,buttonIcon=true 时的 Button)
16
- // 静态样式统一在此,动态 width/height 通过内联 style 传入
17
- .pro-icon-wrapper,
18
- .pro-icon-btn-inner {
19
- display: inline-block;
15
+ // icon 模式外层容器
16
+ .pro-icon-wrapper {
17
+ display: inline-flex;
18
+ align-items: center;
19
+ justify-content: center;
20
20
  border: none;
21
21
  border-radius: 0;
22
22
  padding: 0;
23
23
  vertical-align: baseline;
24
24
  }
25
25
 
26
- .pro-icon-btn {
27
- .anticon {
28
- display: inline-block;
29
- }
30
-
31
- &.@{ant-prefix}-btn-icon-only {
32
- width: auto;
33
- height: auto;
34
- vertical-align: 0;
35
- }
26
+ // icon 模式 disabled 视觉降级(onClick 已在 JS 层拦截)
27
+ .pro-icon-disabled {
28
+ cursor: not-allowed;
29
+ color: rgba(0, 0, 0, 0.25);
30
+ opacity: 0.45;
36
31
  }
@@ -82,7 +82,6 @@ const FoldMenu = props => {
82
82
  }) : /*#__PURE__*/_jsx(ProIcon, {
83
83
  type: icon || '',
84
84
  size: "20px",
85
- buttonIcon: false,
86
85
  color: currentKeyIdPath.includes(id) ? '#fff' : undefined
87
86
  }), /*#__PURE__*/_jsx("h2", {
88
87
  children: name
@@ -70,8 +70,7 @@ const OpenMenu = props => {
70
70
  alt: "icon"
71
71
  }) : item.icon && isFirstMenu ? /*#__PURE__*/_jsx(ProIcon, {
72
72
  type: item.icon || '',
73
- size: "20px",
74
- buttonIcon: false
73
+ size: "20px"
75
74
  }) : /*#__PURE__*/_jsx("span", {
76
75
  className: classnames({
77
76
  'pro-layout-icon': true,
@@ -11,8 +11,7 @@ const EditIcon = ({
11
11
  onClick: onClick,
12
12
  children: /*#__PURE__*/_jsx(ProIcon, {
13
13
  src: editSvg,
14
- size: "20px",
15
- buttonIcon: false
14
+ size: "20px"
16
15
  })
17
16
  });
18
17
  };
@@ -58,7 +58,6 @@ export const Row = props => {
58
58
  component: dragSvg,
59
59
  size: 20,
60
60
  color: "#949599",
61
- buttonIcon: false,
62
61
  style: {
63
62
  touchAction: 'none',
64
63
  cursor: disabled ? 'no-drop' : 'move'
@@ -57,13 +57,11 @@ const SortableItem = props => {
57
57
  children: [drag ? isItemDisabled ? /*#__PURE__*/_jsx(ProIcon, {
58
58
  className: "disabled-icon",
59
59
  component: disabledSvg,
60
- size: 16,
61
- buttonIcon: false
60
+ size: 16
62
61
  }) : /*#__PURE__*/_jsx(ProIcon, {
63
62
  component: dragSvg,
64
63
  size: 20,
65
64
  color: "#949599",
66
- buttonIcon: false,
67
65
  ...listeners
68
66
  }) : null, /*#__PURE__*/_jsx(ProTooltip, {
69
67
  mode: "auto",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zat-design/sisyphus-react",
3
- "version": "4.3.3",
3
+ "version": "4.3.4-beta.1",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "es",