@zat-design/sisyphus-react 3.4.13 → 3.5.0-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.
- package/LICENSE +201 -21
- package/dist/index.esm.css +60 -0
- package/dist/less.esm.css +60 -0
- package/es/ProEditTable/components/DndWrapper/index.js +1 -0
- package/es/ProEditTable/index.d.ts +1 -1
- package/es/ProEditTable/index.js +8 -3
- package/es/ProEditTable/propsType.d.ts +1 -0
- package/es/ProForm/components/combination/FormList/components/ActionButton.js +1 -1
- package/es/ProForm/components/combination/FormList/components/ToolbarButton.js +1 -1
- package/es/ProForm/components/combination/ProModalSelect/index.js +1 -1
- package/es/ProForm/components/combination/ProNumberRange/index.js +28 -7
- package/es/ProForm/components/combination/ProNumberRange/propsType.d.ts +1 -2
- package/es/ProForm/utils/useForm.d.ts +5 -1
- package/es/ProForm/utils/useForm.js +22 -14
- package/es/ProForm/utils/valueType.d.ts +0 -6
- package/es/ProForm/utils/valueType.js +30 -2
- package/es/ProLayout/index.js +6 -2
- package/es/ProLayout/propTypes.d.ts +4 -0
- package/es/ProSelect/index.js +52 -45
- package/es/ProSelect/index.less +6 -0
- package/es/ProTable/components/DndWrapper/index.d.ts +15 -0
- package/es/ProTable/components/DndWrapper/index.js +94 -0
- package/es/ProTable/components/index.d.ts +1 -0
- package/es/ProTable/components/index.js +2 -1
- package/es/ProTable/index.d.ts +3 -0
- package/es/ProTable/index.js +177 -74
- package/es/ProTable/propsType.d.ts +5 -1
- package/es/ProTable/style/index.less +90 -0
- package/es/ProTree/utils.d.ts +1 -1
- package/es/ProTree/utils.js +1 -1
- package/es/ProTreeModal/index.js +10 -4
- package/es/ProTreeModal/style/index.less +1 -0
- package/lib/ProEditTable/components/DndWrapper/index.js +1 -0
- package/lib/ProEditTable/index.d.ts +1 -1
- package/lib/ProEditTable/index.js +8 -3
- package/lib/ProEditTable/propsType.d.ts +1 -0
- package/lib/ProForm/components/combination/FormList/components/ActionButton.js +1 -1
- package/lib/ProForm/components/combination/FormList/components/ToolbarButton.js +1 -1
- package/lib/ProForm/components/combination/ProModalSelect/index.js +1 -1
- package/lib/ProForm/components/combination/ProNumberRange/index.js +28 -7
- package/lib/ProForm/components/combination/ProNumberRange/propsType.d.ts +1 -2
- package/lib/ProForm/utils/useForm.d.ts +5 -1
- package/lib/ProForm/utils/useForm.js +22 -14
- package/lib/ProForm/utils/valueType.d.ts +0 -6
- package/lib/ProForm/utils/valueType.js +30 -2
- package/lib/ProLayout/index.js +6 -2
- package/lib/ProLayout/propTypes.d.ts +4 -0
- package/lib/ProSelect/index.js +54 -45
- package/lib/ProSelect/index.less +6 -0
- package/lib/ProTable/components/DndWrapper/index.d.ts +15 -0
- package/lib/ProTable/components/DndWrapper/index.js +101 -0
- package/lib/ProTable/components/index.d.ts +1 -0
- package/lib/ProTable/components/index.js +15 -1
- package/lib/ProTable/index.d.ts +3 -0
- package/lib/ProTable/index.js +173 -70
- package/lib/ProTable/propsType.d.ts +5 -1
- package/lib/ProTable/style/index.less +90 -0
- package/lib/ProTree/utils.d.ts +1 -1
- package/lib/ProTree/utils.js +1 -1
- package/lib/ProTreeModal/index.js +10 -4
- package/lib/ProTreeModal/style/index.less +1 -0
- package/package.json +2 -2
|
@@ -10,7 +10,9 @@ export var useForm = function useForm(originForm) {
|
|
|
10
10
|
form = _Form$useForm2[0];
|
|
11
11
|
var getFieldsValue = form.getFieldsValue,
|
|
12
12
|
validateFields = form.validateFields,
|
|
13
|
-
setFieldsValue = form.setFieldsValue
|
|
13
|
+
setFieldsValue = form.setFieldsValue,
|
|
14
|
+
isModified = form.isModified;
|
|
15
|
+
if (isModified) return [form];
|
|
14
16
|
// @ts-ignore
|
|
15
17
|
var _getFieldsValue = function _getFieldsValue(nameList, filterFunc) {
|
|
16
18
|
// 全部查询
|
|
@@ -38,7 +40,6 @@ export var useForm = function useForm(originForm) {
|
|
|
38
40
|
_form$getInternalHook,
|
|
39
41
|
getFields,
|
|
40
42
|
fieldsList,
|
|
41
|
-
_error$errorFields,
|
|
42
43
|
_error$errorFields$,
|
|
43
44
|
_args = arguments;
|
|
44
45
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
@@ -52,7 +53,7 @@ export var useForm = function useForm(originForm) {
|
|
|
52
53
|
isRecursive = rest === null || rest === void 0 ? void 0 : (_rest$ = rest[0]) === null || _rest$ === void 0 ? void 0 : _rest$.recursive;
|
|
53
54
|
validateNames = []; // 前缀校验模式
|
|
54
55
|
if (!isRecursive) {
|
|
55
|
-
_context.next =
|
|
56
|
+
_context.next = 12;
|
|
56
57
|
break;
|
|
57
58
|
}
|
|
58
59
|
// @ts-ignore
|
|
@@ -66,28 +67,34 @@ export var useForm = function useForm(originForm) {
|
|
|
66
67
|
});
|
|
67
68
|
// @ts-ignore
|
|
68
69
|
delete rest[0].recursive;
|
|
69
|
-
|
|
70
|
+
_context.next = 11;
|
|
71
|
+
return validateFields.apply(void 0, [validateNames].concat(rest)).then(function (values) {
|
|
70
72
|
return filterInternalFields(values);
|
|
71
|
-
})
|
|
72
|
-
case
|
|
73
|
-
return _context.abrupt("return",
|
|
73
|
+
});
|
|
74
|
+
case 11:
|
|
75
|
+
return _context.abrupt("return", _context.sent);
|
|
76
|
+
case 12:
|
|
77
|
+
_context.next = 14;
|
|
78
|
+
return validateFields.apply(void 0, [nameList].concat(rest)).then(function (values) {
|
|
74
79
|
return nameList ? values : _getFieldsValue();
|
|
75
|
-
})
|
|
76
|
-
case
|
|
77
|
-
_context.
|
|
80
|
+
});
|
|
81
|
+
case 14:
|
|
82
|
+
return _context.abrupt("return", _context.sent);
|
|
83
|
+
case 17:
|
|
84
|
+
_context.prev = 17;
|
|
78
85
|
_context.t0 = _context["catch"](0);
|
|
79
|
-
if (_context.t0
|
|
80
|
-
form
|
|
86
|
+
if (_context.t0 === null || _context.t0 === void 0 ? void 0 : _context.t0.errorFields) {
|
|
87
|
+
form.scrollToField((_error$errorFields$ = _context.t0.errorFields[0]) === null || _error$errorFields$ === void 0 ? void 0 : _error$errorFields$.name, {
|
|
81
88
|
block: 'center',
|
|
82
89
|
behavior: 'smooth'
|
|
83
90
|
});
|
|
84
91
|
}
|
|
85
92
|
throw _context.t0;
|
|
86
|
-
case
|
|
93
|
+
case 21:
|
|
87
94
|
case "end":
|
|
88
95
|
return _context.stop();
|
|
89
96
|
}
|
|
90
|
-
}, _callee, null, [[0,
|
|
97
|
+
}, _callee, null, [[0, 17]]);
|
|
91
98
|
}));
|
|
92
99
|
return function _validateFields(_x) {
|
|
93
100
|
return _ref.apply(this, arguments);
|
|
@@ -95,6 +102,7 @@ export var useForm = function useForm(originForm) {
|
|
|
95
102
|
}();
|
|
96
103
|
form.getFieldsValue = _getFieldsValue;
|
|
97
104
|
form.validateFields = _validateFields;
|
|
105
|
+
form.isModified = true;
|
|
98
106
|
// form.setFieldsValue = _setFieldsValue;
|
|
99
107
|
return [form];
|
|
100
108
|
};
|
|
@@ -34,9 +34,6 @@ declare const _default: {
|
|
|
34
34
|
type: any;
|
|
35
35
|
valueType: any;
|
|
36
36
|
}) => {
|
|
37
|
-
normalize?: undefined;
|
|
38
|
-
getValueProps?: undefined;
|
|
39
|
-
} | {
|
|
40
37
|
normalize: (value: any) => any;
|
|
41
38
|
getValueProps: (value: any) => {
|
|
42
39
|
value: any;
|
|
@@ -47,9 +44,6 @@ declare const _default: {
|
|
|
47
44
|
type: any;
|
|
48
45
|
valueType: any;
|
|
49
46
|
}) => {
|
|
50
|
-
normalize?: undefined;
|
|
51
|
-
getValueProps?: undefined;
|
|
52
|
-
} | {
|
|
53
47
|
normalize: (value: any) => any;
|
|
54
48
|
getValueProps: (value: any) => {
|
|
55
49
|
value: any;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
2
|
import Big from 'big.js';
|
|
3
|
+
import { isEqual } from 'lodash';
|
|
3
4
|
import { transforms } from '@zat-design/utils';
|
|
4
5
|
var transformDate = transforms.transformDate,
|
|
5
6
|
transformSwitch = transforms.transformSwitch;
|
|
@@ -13,8 +14,35 @@ var transformRatio = function transformRatio(_ref) {
|
|
|
13
14
|
precision = _ref$precision === void 0 ? 2 : _ref$precision,
|
|
14
15
|
valueType = _ref.valueType;
|
|
15
16
|
if (type === 'ProNumberRange' && ['permillage', 'percentage'].includes(valueType)) {
|
|
16
|
-
|
|
17
|
-
return {
|
|
17
|
+
var ref = null;
|
|
18
|
+
return {
|
|
19
|
+
normalize: function normalize(value) {
|
|
20
|
+
if (!value || !value.some(function (item) {
|
|
21
|
+
return item;
|
|
22
|
+
})) {
|
|
23
|
+
return {};
|
|
24
|
+
}
|
|
25
|
+
return [(value[0] || value[0] === 0) && Number.isFinite(value[0] - 0) ? Big(value[0] - 0).div(Math.pow(10, precision)).toNumber() : null, (value[1] || value[1] === 0) && Number.isFinite(value[1] - 0) ? Big(value[1] - 0).div(Math.pow(10, precision)).toNumber() : null];
|
|
26
|
+
},
|
|
27
|
+
getValueProps: function getValueProps(value) {
|
|
28
|
+
if (!value || !value.some(function (item) {
|
|
29
|
+
return item;
|
|
30
|
+
})) {
|
|
31
|
+
return {
|
|
32
|
+
value: []
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
if (isEqual(ref, value)) {
|
|
36
|
+
return {
|
|
37
|
+
value: [(value[0] || value[0] === 0) && Number.isFinite(value[0] - 0) ? Big(value[0] - 0).times(Math.pow(10, precision)).toNumber() : null, (value[1] || value[1] === 0) && Number.isFinite(value[1] - 0) ? Big(value[1] - 0).times(Math.pow(10, precision)).toNumber() : null]
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
ref = value;
|
|
41
|
+
return {
|
|
42
|
+
value: [(value[0] || value[0] === 0) && Number.isFinite(value[0] - 0) ? Big(value[0] - 0).times(Math.pow(10, precision)).toNumber() : null, (value[1] || value[1] === 0) && Number.isFinite(value[1] - 0) ? Big(value[1] - 0).times(Math.pow(10, precision)).toNumber() : null]
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
};
|
|
18
46
|
}
|
|
19
47
|
return {
|
|
20
48
|
normalize: function normalize(value) {
|
package/es/ProLayout/index.js
CHANGED
|
@@ -25,7 +25,8 @@ var ProLayout = function ProLayout(props) {
|
|
|
25
25
|
headerNotice = props.headerNotice,
|
|
26
26
|
noticeIn = props.notice,
|
|
27
27
|
dataSource = props.dataSource,
|
|
28
|
-
theme = props.theme
|
|
28
|
+
theme = props.theme,
|
|
29
|
+
onCollapsedChange = props.onCollapsedChange;
|
|
29
30
|
var _useSetState = useSetState({
|
|
30
31
|
notice: headerNotice || noticeIn,
|
|
31
32
|
menus: [],
|
|
@@ -86,7 +87,10 @@ var ProLayout = function ProLayout(props) {
|
|
|
86
87
|
dataSource: menus,
|
|
87
88
|
notice: notice,
|
|
88
89
|
collapsed: collapsed,
|
|
89
|
-
onToggle:
|
|
90
|
+
onToggle: function onToggle() {
|
|
91
|
+
toggle();
|
|
92
|
+
onCollapsedChange && onCollapsedChange(!collapsed);
|
|
93
|
+
}
|
|
90
94
|
})), _jsx("div", {
|
|
91
95
|
className: "pro-layout-content",
|
|
92
96
|
style: _objectSpread(_objectSpread({}, contentStyle), {}, {
|
|
@@ -51,6 +51,10 @@ export interface ProLayoutProps {
|
|
|
51
51
|
contentStyle?: CSSProperties;
|
|
52
52
|
waterMarkProps?: ProWaterMarkProps;
|
|
53
53
|
theme?: themeEnum;
|
|
54
|
+
/**
|
|
55
|
+
* 折叠回调事件
|
|
56
|
+
*/
|
|
57
|
+
onCollapsedChange?: (collapsed: any) => void;
|
|
54
58
|
[key: string]: any;
|
|
55
59
|
}
|
|
56
60
|
export interface ProLayoutStates {
|
package/es/ProSelect/index.js
CHANGED
|
@@ -27,7 +27,8 @@ export var ProSelect = function ProSelect(props, ref) {
|
|
|
27
27
|
var _ref = useProConfig('ProSelect') || {},
|
|
28
28
|
_ref$fieldNames = _ref.fieldNames,
|
|
29
29
|
proSelectFieldNames = _ref$fieldNames === void 0 ? {} : _ref$fieldNames,
|
|
30
|
-
showCodeName = _ref.showCodeName
|
|
30
|
+
showCodeName = _ref.showCodeName,
|
|
31
|
+
gViewportReady = _ref.viewportReady;
|
|
31
32
|
var label = 'label';
|
|
32
33
|
var code = 'value';
|
|
33
34
|
if (proSelectFieldNames && Object.keys(proSelectFieldNames).length) {
|
|
@@ -54,16 +55,16 @@ export var ProSelect = function ProSelect(props, ref) {
|
|
|
54
55
|
updateDataSource = props.updateDataSource,
|
|
55
56
|
transformResponse = props.transformResponse,
|
|
56
57
|
isViewPro = props.isView,
|
|
57
|
-
|
|
58
|
-
viewportReady = _props$viewportReady === void 0 ? false : _props$viewportReady,
|
|
58
|
+
__viewportReady = props.viewportReady,
|
|
59
59
|
selectProps = _objectWithoutProperties(props, _excluded);
|
|
60
|
+
var viewportReady = __viewportReady || gViewportReady;
|
|
60
61
|
/** 是否在可视区域出现过 */
|
|
61
62
|
var _useState = useState(false),
|
|
62
63
|
_useState2 = _slicedToArray(_useState, 2),
|
|
63
64
|
viewFlag = _useState2[0],
|
|
64
65
|
setViewFlag = _useState2[1];
|
|
65
|
-
var
|
|
66
|
-
var _useInViewport = useInViewport(
|
|
66
|
+
var refSelect1 = useRef();
|
|
67
|
+
var _useInViewport = useInViewport(refSelect1),
|
|
67
68
|
_useInViewport2 = _slicedToArray(_useInViewport, 1),
|
|
68
69
|
inViewport = _useInViewport2[0];
|
|
69
70
|
selectProps.showCodeName = (_selectProps$showCode = selectProps.showCodeName) !== null && _selectProps$showCode !== void 0 ? _selectProps$showCode : showCodeName;
|
|
@@ -299,45 +300,51 @@ export var ProSelect = function ProSelect(props, ref) {
|
|
|
299
300
|
fieldNames: fieldNames
|
|
300
301
|
});
|
|
301
302
|
}
|
|
302
|
-
return _jsx(
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
title: "".concat(item[code], "-").concat(item[label]),
|
|
336
|
-
children:
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
303
|
+
return _jsx("div", {
|
|
304
|
+
ref: refSelect1,
|
|
305
|
+
style: props.style,
|
|
306
|
+
className: "ant-select-compact-item-div",
|
|
307
|
+
children: _jsx(_Select, _objectSpread(_objectSpread({
|
|
308
|
+
// id={refSelect1.current}
|
|
309
|
+
placeholder: locale === null || locale === void 0 ? void 0 : (_locale$ProSelect = locale.ProSelect) === null || _locale$ProSelect === void 0 ? void 0 : _locale$ProSelect.select,
|
|
310
|
+
allowClear: true,
|
|
311
|
+
showArrow: true,
|
|
312
|
+
loading: fetchFunction === null || fetchFunction === void 0 ? void 0 : fetchFunction.loading,
|
|
313
|
+
onChange: handleChange,
|
|
314
|
+
optionLabelProp: "children" // 解决warning报错,添加默认值
|
|
315
|
+
,
|
|
316
|
+
showSearch: true,
|
|
317
|
+
filterOption: isFunction(_onSearch) ? false : function (input, option) {
|
|
318
|
+
var _option$children, _option$children$prop;
|
|
319
|
+
var value = isString(option === null || option === void 0 ? void 0 : option.children) ? option === null || option === void 0 ? void 0 : option.children : option === null || option === void 0 ? void 0 : (_option$children = option.children) === null || _option$children === void 0 ? void 0 : (_option$children$prop = _option$children.props) === null || _option$children$prop === void 0 ? void 0 : _option$children$prop.title;
|
|
320
|
+
return value.toLowerCase().includes(input.toLowerCase());
|
|
321
|
+
},
|
|
322
|
+
onSearch: function onSearch(value) {
|
|
323
|
+
_onSearch && _onSearch(value, _objectSpread({}, fetchFunction));
|
|
324
|
+
},
|
|
325
|
+
getPopupContainer: function getPopupContainer(trigger) {
|
|
326
|
+
return scrollFollowParent ? trigger.parentElement : document.body;
|
|
327
|
+
}
|
|
328
|
+
}, omit(cloneDeep(selectProps), ['isView', 'showCodeName', 'form', 'name', 'style'])), {}, {
|
|
329
|
+
value: transformValue(),
|
|
330
|
+
children: Array.isArray(newSelectList) && newSelectList.map(function (item) {
|
|
331
|
+
return _jsx(Option, {
|
|
332
|
+
value: item[code],
|
|
333
|
+
record: item,
|
|
334
|
+
disabled: !!item.disabled,
|
|
335
|
+
children: _jsx(TooltipOption, {
|
|
336
|
+
title: OptionRender ? OptionRender(item) : selectProps.showCodeName ? "".concat(item[code], "-").concat(item[label]) : item[label],
|
|
337
|
+
children: OptionRender ? _jsx("span", {
|
|
338
|
+
title: OptionRender(item),
|
|
339
|
+
children: OptionRender(item)
|
|
340
|
+
}) : _jsx("span", {
|
|
341
|
+
title: "".concat(item[code], "-").concat(item[label]),
|
|
342
|
+
children: selectProps.showCodeName ? "".concat(item[code], "-").concat(item[label]) : item[label]
|
|
343
|
+
})
|
|
344
|
+
}, item[code])
|
|
345
|
+
}, item[code]);
|
|
346
|
+
})
|
|
347
|
+
}))
|
|
348
|
+
});
|
|
342
349
|
};
|
|
343
350
|
export default /*#__PURE__*/forwardRef(ProSelect);
|
package/es/ProSelect/index.less
CHANGED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React, { FC } from 'react';
|
|
2
|
+
interface RowProps extends React.HTMLAttributes<HTMLTableRowElement> {
|
|
3
|
+
'data-row-key': string;
|
|
4
|
+
'data-hide'?: boolean;
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare const Row: FC<RowProps>;
|
|
8
|
+
declare const DndWrapper: ({ draggable, value, onChange, disabled, children }: {
|
|
9
|
+
draggable: any;
|
|
10
|
+
value: any;
|
|
11
|
+
onChange: any;
|
|
12
|
+
disabled: any;
|
|
13
|
+
children: any;
|
|
14
|
+
}) => any;
|
|
15
|
+
export default DndWrapper;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
|
+
var _excluded = ["disabled", "children"];
|
|
4
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import { DndContext } from '@dnd-kit/core';
|
|
7
|
+
import { arrayMove, useSortable, SortableContext, verticalListSortingStrategy } from '@dnd-kit/sortable';
|
|
8
|
+
import { CSS } from '@dnd-kit/utilities';
|
|
9
|
+
import ProIcon from '../../../ProIcon';
|
|
10
|
+
export var Row = function Row(props) {
|
|
11
|
+
var disabled = props.disabled,
|
|
12
|
+
children = props.children,
|
|
13
|
+
restProps = _objectWithoutProperties(props, _excluded);
|
|
14
|
+
var data = useSortable({
|
|
15
|
+
id: props['data-row-key'],
|
|
16
|
+
disabled: disabled
|
|
17
|
+
});
|
|
18
|
+
var attributes = data.attributes,
|
|
19
|
+
listeners = data.listeners,
|
|
20
|
+
setNodeRef = data.setNodeRef,
|
|
21
|
+
transform = data.transform,
|
|
22
|
+
transition = data.transition,
|
|
23
|
+
isDragging = data.isDragging;
|
|
24
|
+
var style = _objectSpread(_objectSpread({}, props.style), {}, {
|
|
25
|
+
transform: CSS.Transform.toString(transform && _objectSpread(_objectSpread({}, transform), {}, {
|
|
26
|
+
scaleY: 1
|
|
27
|
+
})),
|
|
28
|
+
transition: transition
|
|
29
|
+
}, isDragging ? {
|
|
30
|
+
position: 'relative',
|
|
31
|
+
zIndex: 2
|
|
32
|
+
} : {});
|
|
33
|
+
return _jsx("tr", _objectSpread(_objectSpread(_objectSpread({}, restProps), {}, {
|
|
34
|
+
ref: setNodeRef,
|
|
35
|
+
style: style
|
|
36
|
+
}, attributes), {}, {
|
|
37
|
+
children: React.Children.map(children, function (child) {
|
|
38
|
+
if (child.key === 'RC_TABLE_KEY') {
|
|
39
|
+
var _ref = (child === null || child === void 0 ? void 0 : child.props) || {},
|
|
40
|
+
render = _ref.render,
|
|
41
|
+
record = _ref.record,
|
|
42
|
+
renderIndex = _ref.renderIndex;
|
|
43
|
+
return /*#__PURE__*/React.cloneElement(child, {
|
|
44
|
+
children: _jsxs("span", {
|
|
45
|
+
className: "drag-wrapper".concat(props['data-hide'] ? ' no-check' : ''),
|
|
46
|
+
children: [_jsx(ProIcon, _objectSpread({
|
|
47
|
+
className: "drag-icon",
|
|
48
|
+
style: {
|
|
49
|
+
touchAction: 'none',
|
|
50
|
+
cursor: disabled ? 'no-drop' : 'move'
|
|
51
|
+
},
|
|
52
|
+
type: "drag",
|
|
53
|
+
size: 20
|
|
54
|
+
}, listeners)), props['data-hide'] ? null : render === null || render === void 0 ? void 0 : render(null, record, renderIndex)]
|
|
55
|
+
})
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
return child;
|
|
59
|
+
})
|
|
60
|
+
}));
|
|
61
|
+
};
|
|
62
|
+
var DndWrapper = function DndWrapper(_ref2) {
|
|
63
|
+
var _value$;
|
|
64
|
+
var draggable = _ref2.draggable,
|
|
65
|
+
value = _ref2.value,
|
|
66
|
+
onChange = _ref2.onChange,
|
|
67
|
+
disabled = _ref2.disabled,
|
|
68
|
+
children = _ref2.children;
|
|
69
|
+
var onDragEnd = function onDragEnd(_ref3) {
|
|
70
|
+
var active = _ref3.active,
|
|
71
|
+
over = _ref3.over;
|
|
72
|
+
if (active.id !== (over === null || over === void 0 ? void 0 : over.id)) {
|
|
73
|
+
var activeIndex = value.findIndex(function (i) {
|
|
74
|
+
return i.rowKey === active.id;
|
|
75
|
+
});
|
|
76
|
+
var overIndex = value.findIndex(function (i) {
|
|
77
|
+
return i.rowKey === (over === null || over === void 0 ? void 0 : over.id);
|
|
78
|
+
});
|
|
79
|
+
var nextValue = arrayMove(value, activeIndex, overIndex);
|
|
80
|
+
onChange(nextValue);
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
return draggable && !disabled ? _jsx(DndContext, {
|
|
84
|
+
onDragEnd: onDragEnd,
|
|
85
|
+
children: _jsx(SortableContext, {
|
|
86
|
+
items: (value === null || value === void 0 ? void 0 : (_value$ = value[0]) === null || _value$ === void 0 ? void 0 : _value$.rowKey) ? value.map(function (i) {
|
|
87
|
+
return i.rowKey;
|
|
88
|
+
}) : [],
|
|
89
|
+
strategy: verticalListSortingStrategy,
|
|
90
|
+
children: children
|
|
91
|
+
})
|
|
92
|
+
}) : children;
|
|
93
|
+
};
|
|
94
|
+
export default DndWrapper;
|
package/es/ProTable/index.d.ts
CHANGED