@zat-design/sisyphus-react 4.3.3 → 4.3.4-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.
@@ -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,31 +75,32 @@ 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;
78
+ trigger?: string;
79
+ style?: React.CSSProperties;
80
+ hidden?: boolean;
81
+ layout?: import("antd/es/form/Form").FormItemLayout;
82
+ help?: React.ReactNode;
83
+ vertical?: boolean;
84
+ preserve?: boolean;
85
+ children?: React.ReactNode | ((form: FormInstance<any>) => React.ReactNode);
86
+ isView?: boolean;
79
87
  trim?: boolean;
80
88
  normalize?: (value: any, prevValue: any, allValues: import("@rc-component/form/lib/interface").Store) => any;
81
- children?: React.ReactNode | ((form: FormInstance<any>) => React.ReactNode);
82
89
  className?: string;
83
90
  status?: "" | "warning" | "error" | "success" | "validating";
84
- hidden?: boolean;
85
- id?: string;
86
- style?: React.CSSProperties;
87
- htmlFor?: string;
88
91
  prefixCls?: string;
89
- trigger?: string;
90
- isView?: boolean;
91
92
  rootClassName?: string;
93
+ id?: string;
94
+ onReset?: () => void;
92
95
  getValueProps?: ((value: any) => Record<string, unknown>) & ((value: any) => Record<string, unknown>);
93
- vertical?: boolean;
94
96
  desensitization?: [number, number] | ReactiveFunction<any, [number, number]>;
95
97
  validateTrigger?: string | false | string[];
96
- preserve?: boolean;
97
98
  clearNotShow?: boolean;
98
99
  labelAlign?: import("antd/es/form/interface").FormLabelAlign;
99
100
  colon?: boolean;
100
- layout?: import("antd/es/form/Form").FormItemLayout;
101
101
  labelCol?: import("antd").ColProps;
102
102
  wrapperCol?: import("antd").ColProps;
103
+ htmlFor?: string;
103
104
  getValueFromEvent?: (...args: import("@rc-component/form/lib/interface").EventArgs) => any;
104
105
  shouldUpdate?: import("@rc-component/form/lib/Field").ShouldUpdate<any>;
105
106
  validateDebounce?: number;
@@ -114,7 +115,6 @@ export declare const useFormItemProps: (column: FlexibleGroupColumnType, context
114
115
  icons: import("antd/es/form/FormItem").FeedbackIcons;
115
116
  };
116
117
  validateStatus?: "" | "warning" | "error" | "success" | "validating";
117
- help?: React.ReactNode;
118
118
  fieldId?: string;
119
119
  valueType?: import("../../../render/propsType").ProFormValueType;
120
120
  switchValue?: [any, 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,
@@ -59,6 +59,7 @@ export const Step = ({
59
59
  size: 32,
60
60
  actionMap: {}
61
61
  }), onOff && /*#__PURE__*/_jsx("div", {
62
+ className: "pro-step-menu-name",
62
63
  children: locale?.ProStep?.catalogue
63
64
  })]
64
65
  }), options.map(item => {
@@ -22,10 +22,14 @@
22
22
  > .pro-step-menu {
23
23
  display: flex;
24
24
  align-items: center;
25
+ padding-left: 8px;
25
26
  width: 100%;
26
27
  height: 48px;
27
28
  font-size: var(--zaui-font-size-lg, 16px);
28
29
  border-bottom: 1px solid var(--zaui-line, #dddddd);
30
+ .pro-step-menu-name{
31
+ margin-left: 8px;
32
+ }
29
33
  > .anticon {
30
34
  display: flex;
31
35
  align-items: center;
@@ -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'
@@ -100,7 +100,7 @@
100
100
  }
101
101
  .pro-table-drag-wrapper {
102
102
  display: flex;
103
- justify-content: flex-end;
103
+ justify-content: center;
104
104
  margin-right: 8px;
105
105
  .@{ant-prefix}-btn:hover {
106
106
  background: #fff !important;
@@ -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",
@@ -293,7 +293,7 @@ const ProTreeModal = props => {
293
293
  /**
294
294
  * clear all checked
295
295
  */
296
- const handleClearAll = () => {
296
+ const handleClearAll = (immediateSubmit = false) => {
297
297
  // 处理 ProTable 场景下 disabled 的不需要被清理
298
298
  const _checkedValues = span ? state.flatTreeData.filter(item => item.disabled)?.map(item => item[fieldNameValue]) : [];
299
299
  setState({
@@ -303,11 +303,12 @@ const ProTreeModal = props => {
303
303
  treeViewData: [],
304
304
  checkAll: false
305
305
  });
306
- // 通知父组件更新 value prop,确保清空操作被正确保存
307
- if (labelInValue) {
308
- onChange?.([]);
309
- } else {
310
- onChange?.(_checkedValues);
306
+ if (immediateSubmit) {
307
+ if (labelInValue) {
308
+ onChange?.([]);
309
+ } else {
310
+ onChange?.(_checkedValues);
311
+ }
311
312
  }
312
313
  };
313
314
 
@@ -580,7 +581,7 @@ const ProTreeModal = props => {
580
581
  allValue: allValue,
581
582
  label: props?.otherProps?.label,
582
583
  handleClick: handleClick,
583
- handleClearAll: handleClearAll,
584
+ handleClearAll: () => handleClearAll(true),
584
585
  appointChange: appointChange,
585
586
  appointProps: appointProps
586
587
  });
@@ -798,7 +799,7 @@ const ProTreeModal = props => {
798
799
  }), !isView ? /*#__PURE__*/_jsx(Button, {
799
800
  disabled: disabled,
800
801
  type: "link",
801
- onClick: handleClearAll,
802
+ onClick: () => handleClearAll(false),
802
803
  children: locale?.ProTreeModal?.clearAll
803
804
  }) : null]
804
805
  }), /*#__PURE__*/_jsx("div", {
@@ -328,7 +328,7 @@
328
328
  }
329
329
  .checked-item.checked-item-0.disabled {
330
330
  .disabled-icon {
331
- margin: 4px 0 0 2px;
331
+ margin: 2px 0 0 2px;
332
332
  }
333
333
  }
334
334
  .checked-item {
@@ -351,6 +351,14 @@
351
351
  }
352
352
  }
353
353
 
354
+ &.dragable:not(.disabled) {
355
+ .pro-icon,
356
+ .pro-icon > div,
357
+ .pro-icon svg {
358
+ cursor: move;
359
+ }
360
+ }
361
+
354
362
  &:first-child {
355
363
  margin-top: 0;
356
364
  }
@@ -375,8 +383,8 @@
375
383
 
376
384
  .disabled-icon {
377
385
  height: 20px;
378
- margin-right: var(--zaui-space-size-xs, 4px);
379
- margin-left: 6px;
386
+ margin-right: 0;
387
+ margin-left: 2px;
380
388
  margin-top: 2px;
381
389
  }
382
390
 
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.2",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "es",
@@ -98,15 +98,13 @@
98
98
  "react-docgen-typescript-dumi-tmp": {
99
99
  "typescript": "^4.9.5"
100
100
  },
101
- "esbuild": "0.21.4",
102
- "@umijs/bundler-utils": "^4.6.35"
101
+ "esbuild": "0.21.4"
103
102
  },
104
103
  "resolutions": {
105
104
  "react-resizable/react-draggable": "<4.5.0",
106
105
  "@babel/core": "^7.26.0",
107
106
  "react-docgen-typescript-dumi-tmp/typescript": "^4.9.5",
108
- "esbuild": "0.21.4",
109
- "@umijs/bundler-utils": "^4.6.35"
107
+ "esbuild": "0.21.4"
110
108
  },
111
109
  "dependencies": {
112
110
  "@dnd-kit/core": "^6.0.8",
@@ -137,6 +135,7 @@
137
135
  "@babel/runtime": "^7.28.4",
138
136
  "@commitlint/cli": "^12.1.1",
139
137
  "@commitlint/config-conventional": "^12.1.1",
138
+ "@locator/babel-jsx": "^0.5.1",
140
139
  "@testing-library/dom": "^10.0.0",
141
140
  "@testing-library/jest-dom": "^6.0.0",
142
141
  "@testing-library/react": "^16.0.0",