@zat-design/sisyphus-react 3.13.1-beta.6 → 3.13.1-beta.7

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.
@@ -10,6 +10,7 @@ import * as componentMap from '../index';
10
10
  import { isSelect } from '../../utils';
11
11
  import { FieldProvider } from '../../utils/useFieldProps';
12
12
  import locale from '../../../locale';
13
+ import processDependencies from '../../utils/processDependencies';
13
14
  var RenderFields = function RenderFields(props) {
14
15
  var isView = props.isView,
15
16
  _props$columns = props.columns,
@@ -80,10 +81,13 @@ var RenderFields = function RenderFields(props) {
80
81
  var component = column.component;
81
82
  var _isView = typeof column.isView === 'boolean' ? column.isView : isView;
82
83
  var defaultProps = getDefaultProps(column);
84
+ // 处理dependencies,支持namesPaths格式
85
+ var processedDeps = processDependencies(column.dependencies);
83
86
  // 允许formItem的属性放在column最外层 并优先级高于 formItemProps 内部参数
84
87
  var _formItemProps = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, defaultProps), formItemProps), otherFormItemProps), {}, {
85
88
  required: columnRequired !== null && columnRequired !== void 0 ? columnRequired : required,
86
- clearNotShow: clearNotShow
89
+ clearNotShow: clearNotShow,
90
+ dependencies: processedDeps
87
91
  });
88
92
  _formItemProps.labelWidth = _formItemProps.labelWidth || labelWidth; // 接收Form中的labelWidth
89
93
  if (type && component) {
@@ -31,6 +31,7 @@ import type { GroupType as GroupCopyProps } from '../combination/Group/propsType
31
31
  import type { ProCollapseProps } from '../../../ProLayout/components/ProCollapse/PropTypes';
32
32
  import type { DistributiveOmit, DiffConfigType } from '../../propsType';
33
33
  import type { DiffOriginalParams } from '../../utils/diffOriginal';
34
+ import { NamePathsDependencyType } from '../../utils/processDependencies';
34
35
  type ValidateKey = keyof typeof validate;
35
36
  type RegExpKey = keyof typeof regExp;
36
37
  export interface ProRule extends Omit<RuleObject, 'type'> {
@@ -230,7 +231,11 @@ export interface ProFormColumn<Values = any> extends Omit<FormItemProps<Values>,
230
231
  /** 脱敏数据位置下标 */
231
232
  desensitization?: [number, number] | ReactiveFunction<Values, [number, number]>;
232
233
  }
233
- export type ProFormColumnType<T = any> = ProFormColumn<T> & ColumnTypeMap<T, 'ProForm'>;
234
+ export interface ProFormColumnWithExtendedDeps<Values = any> extends Omit<ProFormColumn<Values>, 'dependencies'> {
235
+ /** 表单项依赖关系,扩展支持namesPaths类型 */
236
+ dependencies?: NamePath[] | (NamePath | NamePathsDependencyType)[];
237
+ }
238
+ export type ProFormColumnType<T = any> = ProFormColumnWithExtendedDeps<T> & ColumnTypeMap<T, 'ProForm'>;
234
239
  /**
235
240
  * 表单渲染类型
236
241
  */
@@ -0,0 +1,29 @@
1
+ import type { NamePath } from 'antd/es/form/interface';
2
+ /**
3
+ * 定义支持多字段依赖的类型
4
+ */
5
+ export interface NamePathsDependencyType {
6
+ type: 'namesPaths';
7
+ paths: NamePath[][];
8
+ }
9
+ /**
10
+ * dependencies支持的类型
11
+ */
12
+ export type Dependencies = NamePath[] | NamePathsDependencyType;
13
+ /**
14
+ * 处理表单依赖项
15
+ *
16
+ * 将常规的依赖项数组与namesPaths类型的依赖项进行处理
17
+ * 对于namesPaths类型,将其转换为特定格式的字符串:
18
+ * - 同一路径内的多级通过下划线(_)连接
19
+ * - 不同路径之间通过连字符(-)连接
20
+ *
21
+ * 例如:
22
+ * { type: 'namesPaths', paths: [['a', 'b'], ['c', 'd']] }
23
+ * 会被转换成: ['a_b-c_d']
24
+ *
25
+ * @param dependencies 依赖项配置
26
+ * @returns 处理后的依赖项数组
27
+ */
28
+ export declare function processDependencies(dependencies?: any): any;
29
+ export default processDependencies;
@@ -0,0 +1,55 @@
1
+ import _typeof from "@babel/runtime/helpers/esm/typeof";
2
+ /**
3
+ * 处理表单依赖项
4
+ *
5
+ * 将常规的依赖项数组与namesPaths类型的依赖项进行处理
6
+ * 对于namesPaths类型,将其转换为特定格式的字符串:
7
+ * - 同一路径内的多级通过下划线(_)连接
8
+ * - 不同路径之间通过连字符(-)连接
9
+ *
10
+ * 例如:
11
+ * { type: 'namesPaths', paths: [['a', 'b'], ['c', 'd']] }
12
+ * 会被转换成: ['a_b-c_d']
13
+ *
14
+ * @param dependencies 依赖项配置
15
+ * @returns 处理后的依赖项数组
16
+ */
17
+ export function processDependencies(dependencies) {
18
+ /**
19
+ * 1、没有 dependencies,直接返回
20
+ */
21
+ if (!dependencies) return undefined;
22
+ /**
23
+ * 2、如果是数组,处理可能包含多种类型的元素
24
+ */
25
+ if (Array.isArray(dependencies)) {
26
+ return dependencies.map(function (item) {
27
+ // 处理数组中的namesPaths类型元素
28
+ if (_typeof(item) === 'object' && item !== null && 'type' in item && item.type === 'namesPaths') {
29
+ // 安全类型转换
30
+ var itemWithPaths = item;
31
+ var paths = itemWithPaths.paths;
32
+ return paths.map(function (path) {
33
+ return Array.isArray(path) ? path.join('_') : String(path);
34
+ }).join('-');
35
+ }
36
+ // 其他类型元素保持不变
37
+ return item;
38
+ });
39
+ }
40
+ /**
41
+ * 3、如果是单个namesPaths对象,转换为特定的字符串形式
42
+ * 例如:[['a','b','c'], ['a','b','d']] => 'a_b_c-a_b_d'
43
+ */
44
+ if ('type' in dependencies && dependencies.type === 'namesPaths') {
45
+ var paths = dependencies.paths;
46
+ return [paths.map(function (path) {
47
+ return Array.isArray(path) ? path.join('_') : String(path);
48
+ }).join('-')];
49
+ }
50
+ /**
51
+ * 4、如果是普通的 dependencies,直接返回
52
+ */
53
+ return dependencies;
54
+ }
55
+ export default processDependencies;
@@ -13,8 +13,8 @@ import { isBoolean } from 'lodash';
13
13
  import classNames from 'classnames';
14
14
  import { CheckOutlined } from '@ant-design/icons';
15
15
  import { ReactSVG } from 'react-svg';
16
- import { getPadding, parseWidth } from '../../utils';
17
- import { isEmpty } from '../../../utils';
16
+ import { parseWidth } from '../../utils';
17
+ import { isEmpty, isEllipsisActive } from '../../../utils';
18
18
  import copySvg from '../../../assets/copy.svg';
19
19
  var Paragraph = _Typography.Paragraph,
20
20
  Text = _Typography.Text;
@@ -57,25 +57,9 @@ var RenderColumn = function RenderColumn(props) {
57
57
  'varied-cell': props === null || props === void 0 ? void 0 : props.isChanged,
58
58
  'add-cell': props === null || props === void 0 ? void 0 : props.isAddCell
59
59
  });
60
- var checkEllipsis = function checkEllipsis(box) {
61
- var range = document.createRange();
62
- range.setStart(box, 0);
63
- range.setEnd(box, box.childNodes.length);
64
- var rangeWidth = range.getBoundingClientRect().width;
65
- var _getPadding = getPadding(box),
66
- pLeft = _getPadding.pLeft,
67
- pRight = _getPadding.pRight,
68
- pTop = _getPadding.pTop,
69
- pBottom = _getPadding.pBottom;
70
- var horizontalPadding = pLeft + pRight;
71
- if (rangeWidth + horizontalPadding > box.clientWidth) {
72
- return true;
73
- }
74
- return false;
75
- };
76
60
  var handleMouseOver = function handleMouseOver(e) {
77
61
  setState({
78
- tooltip: checkEllipsis(e.target)
62
+ tooltip: isEllipsisActive(e.target)
79
63
  });
80
64
  };
81
65
  var tooltipProps = _objectSpread({
@@ -111,9 +95,6 @@ var RenderColumn = function RenderColumn(props) {
111
95
  if (ellipsis) {
112
96
  return _jsx(_Tooltip, _objectSpread(_objectSpread({
113
97
  title: currentValue,
114
- getTooltipContainer: function getTooltipContainer() {
115
- return document.body;
116
- },
117
98
  onOpenChange: function onOpenChange(open) {
118
99
  setState({
119
100
  tooltip: false
@@ -33,12 +33,6 @@ export declare const getRowKey: (rowKey: any, record: any) => any;
33
33
  export declare const removeEmptyKeys: (obj?: Record<string, any>) => {
34
34
  [k: string]: any;
35
35
  };
36
- export declare const getPadding: (el: HTMLElement) => {
37
- pLeft: number;
38
- pRight: number;
39
- pTop: number;
40
- pBottom: number;
41
- };
42
36
  /** 判断是有值的对象 */
43
37
  export declare const isNonEmptyObject: (obj: any) => obj is Record<string, any>;
44
38
  /** 解析宽度值 */
@@ -88,20 +88,6 @@ export var removeEmptyKeys = function removeEmptyKeys(obj) {
88
88
  // 使用 Object.fromEntries() 将过滤后的键值对数组转换回对象
89
89
  return Object.fromEntries(filteredEntries);
90
90
  };
91
- /* 获取边距 */
92
- export var getPadding = function getPadding(el) {
93
- var style = window.getComputedStyle(el, null);
94
- var paddingLeft = Number.parseInt(style.paddingLeft, 10) || 0;
95
- var paddingRight = Number.parseInt(style.paddingRight, 10) || 0;
96
- var paddingTop = Number.parseInt(style.paddingTop, 10) || 0;
97
- var paddingBottom = Number.parseInt(style.paddingBottom, 10) || 0;
98
- return {
99
- pLeft: paddingLeft,
100
- pRight: paddingRight,
101
- pTop: paddingTop,
102
- pBottom: paddingBottom
103
- };
104
- };
105
91
  /** 判断是有值的对象 */
106
92
  export var isNonEmptyObject = function isNonEmptyObject(obj) {
107
93
  return obj !== null && _typeof(obj) === 'object' && !Array.isArray(obj) && Object.keys(obj).length > 0;
@@ -17,6 +17,7 @@ var componentMap = _interopRequireWildcard(require("../index"));
17
17
  var _utils = require("../../utils");
18
18
  var _useFieldProps = require("../../utils/useFieldProps");
19
19
  var _locale = _interopRequireDefault(require("../../../locale"));
20
+ var _processDependencies = _interopRequireDefault(require("../../utils/processDependencies"));
20
21
  var _excluded = ["show", "type", "viewRender", "viewType", "valueType", "formItemProps", "colProps", "formItemChildProps", "fieldProps", "onDiff", "clearNotShow", "required", "confirm", "desensitization", "span"];
21
22
  var RenderFields = function RenderFields(props) {
22
23
  var isView = props.isView,
@@ -88,10 +89,13 @@ var RenderFields = function RenderFields(props) {
88
89
  var component = column.component;
89
90
  var _isView = typeof column.isView === 'boolean' ? column.isView : isView;
90
91
  var defaultProps = (0, _getDefaultProps.getDefaultProps)(column);
92
+ // 处理dependencies,支持namesPaths格式
93
+ var processedDeps = (0, _processDependencies.default)(column.dependencies);
91
94
  // 允许formItem的属性放在column最外层 并优先级高于 formItemProps 内部参数
92
95
  var _formItemProps = (0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)((0, _objectSpread2.default)({}, defaultProps), formItemProps), otherFormItemProps), {}, {
93
96
  required: columnRequired !== null && columnRequired !== void 0 ? columnRequired : required,
94
- clearNotShow: clearNotShow
97
+ clearNotShow: clearNotShow,
98
+ dependencies: processedDeps
95
99
  });
96
100
  _formItemProps.labelWidth = _formItemProps.labelWidth || labelWidth; // 接收Form中的labelWidth
97
101
  if (type && component) {
@@ -31,6 +31,7 @@ import type { GroupType as GroupCopyProps } from '../combination/Group/propsType
31
31
  import type { ProCollapseProps } from '../../../ProLayout/components/ProCollapse/PropTypes';
32
32
  import type { DistributiveOmit, DiffConfigType } from '../../propsType';
33
33
  import type { DiffOriginalParams } from '../../utils/diffOriginal';
34
+ import { NamePathsDependencyType } from '../../utils/processDependencies';
34
35
  type ValidateKey = keyof typeof validate;
35
36
  type RegExpKey = keyof typeof regExp;
36
37
  export interface ProRule extends Omit<RuleObject, 'type'> {
@@ -230,7 +231,11 @@ export interface ProFormColumn<Values = any> extends Omit<FormItemProps<Values>,
230
231
  /** 脱敏数据位置下标 */
231
232
  desensitization?: [number, number] | ReactiveFunction<Values, [number, number]>;
232
233
  }
233
- export type ProFormColumnType<T = any> = ProFormColumn<T> & ColumnTypeMap<T, 'ProForm'>;
234
+ export interface ProFormColumnWithExtendedDeps<Values = any> extends Omit<ProFormColumn<Values>, 'dependencies'> {
235
+ /** 表单项依赖关系,扩展支持namesPaths类型 */
236
+ dependencies?: NamePath[] | (NamePath | NamePathsDependencyType)[];
237
+ }
238
+ export type ProFormColumnType<T = any> = ProFormColumnWithExtendedDeps<T> & ColumnTypeMap<T, 'ProForm'>;
234
239
  /**
235
240
  * 表单渲染类型
236
241
  */
@@ -0,0 +1,29 @@
1
+ import type { NamePath } from 'antd/es/form/interface';
2
+ /**
3
+ * 定义支持多字段依赖的类型
4
+ */
5
+ export interface NamePathsDependencyType {
6
+ type: 'namesPaths';
7
+ paths: NamePath[][];
8
+ }
9
+ /**
10
+ * dependencies支持的类型
11
+ */
12
+ export type Dependencies = NamePath[] | NamePathsDependencyType;
13
+ /**
14
+ * 处理表单依赖项
15
+ *
16
+ * 将常规的依赖项数组与namesPaths类型的依赖项进行处理
17
+ * 对于namesPaths类型,将其转换为特定格式的字符串:
18
+ * - 同一路径内的多级通过下划线(_)连接
19
+ * - 不同路径之间通过连字符(-)连接
20
+ *
21
+ * 例如:
22
+ * { type: 'namesPaths', paths: [['a', 'b'], ['c', 'd']] }
23
+ * 会被转换成: ['a_b-c_d']
24
+ *
25
+ * @param dependencies 依赖项配置
26
+ * @returns 处理后的依赖项数组
27
+ */
28
+ export declare function processDependencies(dependencies?: any): any;
29
+ export default processDependencies;
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ exports.processDependencies = processDependencies;
9
+ var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
10
+ /**
11
+ * 处理表单依赖项
12
+ *
13
+ * 将常规的依赖项数组与namesPaths类型的依赖项进行处理
14
+ * 对于namesPaths类型,将其转换为特定格式的字符串:
15
+ * - 同一路径内的多级通过下划线(_)连接
16
+ * - 不同路径之间通过连字符(-)连接
17
+ *
18
+ * 例如:
19
+ * { type: 'namesPaths', paths: [['a', 'b'], ['c', 'd']] }
20
+ * 会被转换成: ['a_b-c_d']
21
+ *
22
+ * @param dependencies 依赖项配置
23
+ * @returns 处理后的依赖项数组
24
+ */
25
+ function processDependencies(dependencies) {
26
+ /**
27
+ * 1、没有 dependencies,直接返回
28
+ */
29
+ if (!dependencies) return undefined;
30
+ /**
31
+ * 2、如果是数组,处理可能包含多种类型的元素
32
+ */
33
+ if (Array.isArray(dependencies)) {
34
+ return dependencies.map(function (item) {
35
+ // 处理数组中的namesPaths类型元素
36
+ if ((0, _typeof2.default)(item) === 'object' && item !== null && 'type' in item && item.type === 'namesPaths') {
37
+ // 安全类型转换
38
+ var itemWithPaths = item;
39
+ var paths = itemWithPaths.paths;
40
+ return paths.map(function (path) {
41
+ return Array.isArray(path) ? path.join('_') : String(path);
42
+ }).join('-');
43
+ }
44
+ // 其他类型元素保持不变
45
+ return item;
46
+ });
47
+ }
48
+ /**
49
+ * 3、如果是单个namesPaths对象,转换为特定的字符串形式
50
+ * 例如:[['a','b','c'], ['a','b','d']] => 'a_b_c-a_b_d'
51
+ */
52
+ if ('type' in dependencies && dependencies.type === 'namesPaths') {
53
+ var paths = dependencies.paths;
54
+ return [paths.map(function (path) {
55
+ return Array.isArray(path) ? path.join('_') : String(path);
56
+ }).join('-')];
57
+ }
58
+ /**
59
+ * 4、如果是普通的 dependencies,直接返回
60
+ */
61
+ return dependencies;
62
+ }
63
+ var _default = exports.default = processDependencies;
@@ -59,25 +59,9 @@ var RenderColumn = function RenderColumn(props) {
59
59
  'varied-cell': props === null || props === void 0 ? void 0 : props.isChanged,
60
60
  'add-cell': props === null || props === void 0 ? void 0 : props.isAddCell
61
61
  });
62
- var checkEllipsis = function checkEllipsis(box) {
63
- var range = document.createRange();
64
- range.setStart(box, 0);
65
- range.setEnd(box, box.childNodes.length);
66
- var rangeWidth = range.getBoundingClientRect().width;
67
- var _getPadding = (0, _utils.getPadding)(box),
68
- pLeft = _getPadding.pLeft,
69
- pRight = _getPadding.pRight,
70
- pTop = _getPadding.pTop,
71
- pBottom = _getPadding.pBottom;
72
- var horizontalPadding = pLeft + pRight;
73
- if (rangeWidth + horizontalPadding > box.clientWidth) {
74
- return true;
75
- }
76
- return false;
77
- };
78
62
  var handleMouseOver = function handleMouseOver(e) {
79
63
  setState({
80
- tooltip: checkEllipsis(e.target)
64
+ tooltip: (0, _utils2.isEllipsisActive)(e.target)
81
65
  });
82
66
  };
83
67
  var tooltipProps = (0, _objectSpread2.default)({
@@ -113,9 +97,6 @@ var RenderColumn = function RenderColumn(props) {
113
97
  if (ellipsis) {
114
98
  return (0, _jsxRuntime.jsx)(_antd.Tooltip, (0, _objectSpread2.default)((0, _objectSpread2.default)({
115
99
  title: currentValue,
116
- getTooltipContainer: function getTooltipContainer() {
117
- return document.body;
118
- },
119
100
  onOpenChange: function onOpenChange(open) {
120
101
  setState({
121
102
  tooltip: false
@@ -33,12 +33,6 @@ export declare const getRowKey: (rowKey: any, record: any) => any;
33
33
  export declare const removeEmptyKeys: (obj?: Record<string, any>) => {
34
34
  [k: string]: any;
35
35
  };
36
- export declare const getPadding: (el: HTMLElement) => {
37
- pLeft: number;
38
- pRight: number;
39
- pTop: number;
40
- pBottom: number;
41
- };
42
36
  /** 判断是有值的对象 */
43
37
  export declare const isNonEmptyObject: (obj: any) => obj is Record<string, any>;
44
38
  /** 解析宽度值 */
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.removeEmptyKeys = exports.parseWidth = exports.isNonEmptyObject = exports.isListResult = exports.getRowKey = exports.getPadding = exports.getOriginalValue = exports.getDecimalDigits = exports.getColumnDataIndex = void 0;
7
+ exports.removeEmptyKeys = exports.parseWidth = exports.isNonEmptyObject = exports.isListResult = exports.getRowKey = exports.getOriginalValue = exports.getDecimalDigits = exports.getColumnDataIndex = void 0;
8
8
  var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
9
9
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
10
10
  var _lodash = require("lodash");
@@ -95,20 +95,6 @@ var removeEmptyKeys = exports.removeEmptyKeys = function removeEmptyKeys(obj) {
95
95
  // 使用 Object.fromEntries() 将过滤后的键值对数组转换回对象
96
96
  return Object.fromEntries(filteredEntries);
97
97
  };
98
- /* 获取边距 */
99
- var getPadding = exports.getPadding = function getPadding(el) {
100
- var style = window.getComputedStyle(el, null);
101
- var paddingLeft = Number.parseInt(style.paddingLeft, 10) || 0;
102
- var paddingRight = Number.parseInt(style.paddingRight, 10) || 0;
103
- var paddingTop = Number.parseInt(style.paddingTop, 10) || 0;
104
- var paddingBottom = Number.parseInt(style.paddingBottom, 10) || 0;
105
- return {
106
- pLeft: paddingLeft,
107
- pRight: paddingRight,
108
- pTop: paddingTop,
109
- pBottom: paddingBottom
110
- };
111
- };
112
98
  /** 判断是有值的对象 */
113
99
  var isNonEmptyObject = exports.isNonEmptyObject = function isNonEmptyObject(obj) {
114
100
  return obj !== null && (0, _typeof2.default)(obj) === 'object' && !Array.isArray(obj) && Object.keys(obj).length > 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zat-design/sisyphus-react",
3
- "version": "3.13.1-beta.6",
3
+ "version": "3.13.1-beta.7",
4
4
  "license": "MIT",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",