@yuntijs/ui 1.0.0-beta.101 → 1.0.0-beta.103
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/es/Form/collapse-list/hooks.d.ts +4 -1
- package/es/Form/collapse-list/hooks.js +72 -21
- package/es/Form/collapse-list/index.d.ts +8 -4
- package/es/Form/collapse-list/index.js +24 -12
- package/es/Form/collapse-list/utils.d.ts +4 -4
- package/es/Form/collapse-list/utils.js +0 -29
- package/package.json +1 -1
- package/umd/index.min.js +1 -1
- package/umd/index.min.js.map +1 -1
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { type FormListOperation } from 'antd';
|
|
2
2
|
import React from 'react';
|
|
3
|
+
import type { FormCollapseListColumn } from '.';
|
|
3
4
|
import { ListFieldValue } from './utils';
|
|
4
|
-
export declare const useFormCollapseListHooks: (name: string) => {
|
|
5
|
+
export declare const useFormCollapseListHooks: (name: string, childrenColumnName: string, columns: FormCollapseListColumn[]) => {
|
|
5
6
|
expandedRowKeys: readonly React.Key[];
|
|
6
7
|
setExpandedRowKeys: React.Dispatch<React.SetStateAction<readonly React.Key[]>>;
|
|
7
8
|
fieldsToDataSource: (fields: [ListFieldValue]) => {
|
|
8
9
|
dataSource: ListFieldValue[];
|
|
9
10
|
allExpandRowKeys: React.Key[];
|
|
10
11
|
};
|
|
12
|
+
getFieldPath: (fieldKeyPath: number[], fieldName?: string) => any;
|
|
11
13
|
getFormListOperation: (operation: FormListOperation, record: ListFieldValue) => FormListOperation;
|
|
14
|
+
firstColumnFormItemName: any;
|
|
12
15
|
};
|
|
@@ -1,30 +1,46 @@
|
|
|
1
1
|
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
2
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
3
3
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
4
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
5
|
+
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); }
|
|
6
|
+
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; }
|
|
4
7
|
import { Form } from 'antd';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
+
import { cloneDeep } from 'lodash-es';
|
|
9
|
+
import { useCallback, useMemo, useState } from 'react';
|
|
10
|
+
import { FIELD_KEY_PATH, toRowKey } from "./utils";
|
|
11
|
+
export var useFormCollapseListHooks = function useFormCollapseListHooks(name, childrenColumnName, columns) {
|
|
12
|
+
var _useMemo;
|
|
8
13
|
var form = Form.useFormInstance();
|
|
9
14
|
var _useState = useState([]),
|
|
10
15
|
_useState2 = _slicedToArray(_useState, 2),
|
|
11
16
|
expandedRowKeys = _useState2[0],
|
|
12
17
|
setExpandedRowKeys = _useState2[1];
|
|
18
|
+
var firstColumnFormItemName = (_useMemo = useMemo(function () {
|
|
19
|
+
return columns.find(function (item) {
|
|
20
|
+
return !!item.name && !item.noStyle;
|
|
21
|
+
});
|
|
22
|
+
}, [columns])) === null || _useMemo === void 0 ? void 0 : _useMemo.name;
|
|
13
23
|
var fieldsToDataSource = useCallback(function (fields) {
|
|
24
|
+
if (!name) {
|
|
25
|
+
return {
|
|
26
|
+
dataSource: [],
|
|
27
|
+
allExpandRowKeys: []
|
|
28
|
+
};
|
|
29
|
+
}
|
|
14
30
|
var allExpandRowKeys = [];
|
|
15
31
|
var _setFieldPath = function _setFieldPath(field, index, path) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
32
|
+
var item = cloneDeep(field);
|
|
33
|
+
if (!item) {
|
|
34
|
+
item = _defineProperty({}, FIELD_KEY_PATH, []);
|
|
19
35
|
}
|
|
20
|
-
|
|
21
|
-
if (
|
|
22
|
-
allExpandRowKeys.push(toRowKey(
|
|
23
|
-
|
|
24
|
-
return _setFieldPath(
|
|
36
|
+
item[FIELD_KEY_PATH] = [].concat(_toConsumableArray(path), [index]);
|
|
37
|
+
if (item[childrenColumnName] && Array.isArray(item[childrenColumnName])) {
|
|
38
|
+
allExpandRowKeys.push(toRowKey(item[FIELD_KEY_PATH]));
|
|
39
|
+
item[childrenColumnName] = item[childrenColumnName].map(function (child, index) {
|
|
40
|
+
return _setFieldPath(child, index, item[FIELD_KEY_PATH]);
|
|
25
41
|
});
|
|
26
42
|
}
|
|
27
|
-
return
|
|
43
|
+
return item;
|
|
28
44
|
};
|
|
29
45
|
return {
|
|
30
46
|
dataSource: (fields === null || fields === void 0 ? void 0 : fields.map(function (field, index) {
|
|
@@ -32,17 +48,49 @@ export var useFormCollapseListHooks = function useFormCollapseListHooks(name) {
|
|
|
32
48
|
})) || [],
|
|
33
49
|
allExpandRowKeys: allExpandRowKeys
|
|
34
50
|
};
|
|
35
|
-
}, []);
|
|
51
|
+
}, [childrenColumnName, name]);
|
|
52
|
+
var getFieldPath = useCallback(function (fieldKeyPath, fieldName) {
|
|
53
|
+
var fieldPath = [];
|
|
54
|
+
var _iterator = _createForOfIteratorHelper(fieldKeyPath.entries()),
|
|
55
|
+
_step;
|
|
56
|
+
try {
|
|
57
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
58
|
+
var _step$value = _slicedToArray(_step.value, 2),
|
|
59
|
+
index = _step$value[0],
|
|
60
|
+
key = _step$value[1];
|
|
61
|
+
if (index === fieldKeyPath.length - 1) {
|
|
62
|
+
fieldPath.push(key);
|
|
63
|
+
if (fieldName) {
|
|
64
|
+
fieldPath.push(fieldName);
|
|
65
|
+
}
|
|
66
|
+
} else {
|
|
67
|
+
fieldPath.push(key, childrenColumnName);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
} catch (err) {
|
|
71
|
+
_iterator.e(err);
|
|
72
|
+
} finally {
|
|
73
|
+
_iterator.f();
|
|
74
|
+
}
|
|
75
|
+
return fieldPath;
|
|
76
|
+
}, [childrenColumnName]);
|
|
36
77
|
var getFormListOperation = useCallback(function (operation, record) {
|
|
37
78
|
var fieldKeyPath = record[FIELD_KEY_PATH];
|
|
38
79
|
return {
|
|
39
80
|
add: function add(defaultValue, insertIndex) {
|
|
40
81
|
var fieldPath = getFieldPath(fieldKeyPath);
|
|
41
|
-
var fieldName = [name].concat(_toConsumableArray(fieldPath), [
|
|
42
|
-
var fieldValue = form.getFieldValue(fieldName) || [];
|
|
43
|
-
fieldValue.
|
|
44
|
-
fieldValue.splice(
|
|
82
|
+
var fieldName = [name].concat(_toConsumableArray(fieldPath), [childrenColumnName]);
|
|
83
|
+
var fieldValue = cloneDeep(form.getFieldValue(fieldName)) || [];
|
|
84
|
+
var index = insertIndex !== null && insertIndex !== void 0 ? insertIndex : fieldValue.length;
|
|
85
|
+
fieldValue.splice(index, 0, defaultValue);
|
|
45
86
|
form.setFieldValue(fieldName, fieldValue);
|
|
87
|
+
if (firstColumnFormItemName) {
|
|
88
|
+
var fileNamePath = [].concat(_toConsumableArray(fieldName), [index, firstColumnFormItemName]);
|
|
89
|
+
// Scroll and focus new item which is just added
|
|
90
|
+
setTimeout(function () {
|
|
91
|
+
form.focusField(fileNamePath);
|
|
92
|
+
}, 200);
|
|
93
|
+
}
|
|
46
94
|
setExpandedRowKeys(_toConsumableArray(new Set([].concat(_toConsumableArray(expandedRowKeys), [toRowKey(fieldKeyPath)]))));
|
|
47
95
|
},
|
|
48
96
|
remove: function remove(index) {
|
|
@@ -50,7 +98,7 @@ export var useFormCollapseListHooks = function useFormCollapseListHooks(name) {
|
|
|
50
98
|
return operation.remove(index);
|
|
51
99
|
}
|
|
52
100
|
var fieldName = [name].concat(_toConsumableArray(getFieldPath(fieldKeyPath).slice(0, -1)));
|
|
53
|
-
var fieldValue = form.getFieldValue(fieldName) || [];
|
|
101
|
+
var fieldValue = cloneDeep(form.getFieldValue(fieldName)) || [];
|
|
54
102
|
var indexs = [];
|
|
55
103
|
if (Array.isArray(index)) {
|
|
56
104
|
indexs.push.apply(indexs, _toConsumableArray(index));
|
|
@@ -67,7 +115,7 @@ export var useFormCollapseListHooks = function useFormCollapseListHooks(name) {
|
|
|
67
115
|
return operation.move(from, to);
|
|
68
116
|
}
|
|
69
117
|
var fieldName = [name].concat(_toConsumableArray(getFieldPath(fieldKeyPath).slice(0, -1)));
|
|
70
|
-
var fieldValue = form.getFieldValue(fieldName) || [];
|
|
118
|
+
var fieldValue = cloneDeep(form.getFieldValue(fieldName)) || [];
|
|
71
119
|
// 检查索引是否有效
|
|
72
120
|
if (from < 0 || to < 0 || from >= fieldValue.length || to >= fieldValue.length) {
|
|
73
121
|
console.warn(new Error('索引超出数组范围'));
|
|
@@ -80,11 +128,14 @@ export var useFormCollapseListHooks = function useFormCollapseListHooks(name) {
|
|
|
80
128
|
form.setFieldValue(fieldName, fieldValue);
|
|
81
129
|
}
|
|
82
130
|
};
|
|
83
|
-
}, [expandedRowKeys, form, name]);
|
|
131
|
+
}, [childrenColumnName, expandedRowKeys, firstColumnFormItemName, form, getFieldPath, name]);
|
|
84
132
|
return {
|
|
85
133
|
expandedRowKeys: expandedRowKeys,
|
|
86
134
|
setExpandedRowKeys: setExpandedRowKeys,
|
|
87
135
|
fieldsToDataSource: fieldsToDataSource,
|
|
88
|
-
|
|
136
|
+
getFieldPath: getFieldPath,
|
|
137
|
+
getFormListOperation: getFormListOperation,
|
|
138
|
+
// 首个表单输入列 (用于新增表达后 foucs 等)
|
|
139
|
+
firstColumnFormItemName: firstColumnFormItemName
|
|
89
140
|
};
|
|
90
141
|
};
|
|
@@ -4,9 +4,11 @@ import React from 'react';
|
|
|
4
4
|
import { CollapseGroupProps } from '../../CollapseGroup';
|
|
5
5
|
import { FieldPath } from './utils';
|
|
6
6
|
export interface FormCollapseListColumnItem extends Omit<FormItemProps, 'dependencies' | 'rules' | 'tooltip' | 'labelAlign' | 'labelCol' | 'colon' | 'children'> {
|
|
7
|
-
render?: (fieldName: number, index: number, operation: FormListOperation,
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
render?: (fieldName: number, index: number, operation: FormListOperation,
|
|
8
|
+
/** 当前 item 的 path */
|
|
9
|
+
fieldPath: FieldPath) => React.ReactElement;
|
|
10
|
+
rules?: FormItemProps['rules'] | ((parentFieldPath: FieldPath, index: number) => FormItemProps['rules']);
|
|
11
|
+
dependencies?: FormItemProps['dependencies'] | ((parentFieldPath: FieldPath, index: number) => FormItemProps['dependencies']);
|
|
10
12
|
}
|
|
11
13
|
export interface FormListOperationAddParams {
|
|
12
14
|
defaultValue?: any;
|
|
@@ -39,8 +41,10 @@ export interface FormCollapseListProps extends Omit<AntFormListProps, 'name' | '
|
|
|
39
41
|
fieldRemoveButton?: boolean;
|
|
40
42
|
/** [树形数据] 初始时,是否展开所有行 */
|
|
41
43
|
defaultExpandAllRows?: boolean;
|
|
42
|
-
/** [树形数据] 每层缩进的宽度,以 px 为单位, 默认为
|
|
44
|
+
/** [树形数据] 每层缩进的宽度,以 px 为单位, 默认为 16 */
|
|
43
45
|
indentSize?: number;
|
|
46
|
+
/** [树形数据] 指定树形结构的列名,默认为 children */
|
|
47
|
+
childrenColumnName?: string;
|
|
44
48
|
/** 表格行是否开启 hover 交互, 默认为启用 */
|
|
45
49
|
rowHoverable?: boolean;
|
|
46
50
|
}
|
|
@@ -2,7 +2,7 @@ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
|
2
2
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
3
3
|
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
4
4
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
5
|
-
var _excluded = ["extra", "expandIcon", "icon", "title", "variant", "defaultActive", "empty", "columns", "disabled", "readOnly", "addOneFieldDefault", "disableRemoveWhenOneField", "maxFileds", "name", "addParams", "className", "onRemove", "fieldRemoveButton", "style", "defaultExpandAllRows", "indentSize", "rowHoverable"],
|
|
5
|
+
var _excluded = ["extra", "expandIcon", "icon", "title", "variant", "defaultActive", "empty", "columns", "disabled", "readOnly", "addOneFieldDefault", "disableRemoveWhenOneField", "maxFileds", "name", "addParams", "className", "onRemove", "fieldRemoveButton", "style", "defaultExpandAllRows", "indentSize", "childrenColumnName", "rowHoverable"],
|
|
6
6
|
_excluded2 = ["label", "name", "render", "dependencies", "rules", "align", "ellipsis", "fixed", "responsive", "shouldCellUpdate", "width", "className"],
|
|
7
7
|
_excluded3 = ["key"];
|
|
8
8
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
@@ -16,7 +16,7 @@ import React, { useCallback, useEffect, useMemo, useRef } from 'react';
|
|
|
16
16
|
import { CollapseGroup } from "../../CollapseGroup";
|
|
17
17
|
import { useFormCollapseListHooks } from "./hooks";
|
|
18
18
|
import { useStyles } from "./style";
|
|
19
|
-
import { FIELD_KEY_PATH,
|
|
19
|
+
import { FIELD_KEY_PATH, toRowKey } from "./utils";
|
|
20
20
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
21
21
|
export var FormCollapseList = function FormCollapseList(_ref) {
|
|
22
22
|
var extra = _ref.extra,
|
|
@@ -42,7 +42,10 @@ export var FormCollapseList = function FormCollapseList(_ref) {
|
|
|
42
42
|
fieldRemoveButton = _ref$fieldRemoveButto === void 0 ? true : _ref$fieldRemoveButto,
|
|
43
43
|
style = _ref.style,
|
|
44
44
|
defaultExpandAllRows = _ref.defaultExpandAllRows,
|
|
45
|
-
indentSize = _ref.indentSize,
|
|
45
|
+
_ref$indentSize = _ref.indentSize,
|
|
46
|
+
indentSize = _ref$indentSize === void 0 ? 16 : _ref$indentSize,
|
|
47
|
+
_ref$childrenColumnNa = _ref.childrenColumnName,
|
|
48
|
+
childrenColumnName = _ref$childrenColumnNa === void 0 ? 'children' : _ref$childrenColumnNa,
|
|
46
49
|
_ref$rowHoverable = _ref.rowHoverable,
|
|
47
50
|
rowHoverable = _ref$rowHoverable === void 0 ? true : _ref$rowHoverable,
|
|
48
51
|
formListProps = _objectWithoutProperties(_ref, _excluded);
|
|
@@ -52,11 +55,13 @@ export var FormCollapseList = function FormCollapseList(_ref) {
|
|
|
52
55
|
var listAdd = useRef();
|
|
53
56
|
var form = Form.useFormInstance();
|
|
54
57
|
var fieldsWatch = Form.useWatch(name, form);
|
|
55
|
-
var _useFormCollapseListH = useFormCollapseListHooks(name),
|
|
58
|
+
var _useFormCollapseListH = useFormCollapseListHooks(name, childrenColumnName, columns),
|
|
56
59
|
expandedRowKeys = _useFormCollapseListH.expandedRowKeys,
|
|
57
60
|
setExpandedRowKeys = _useFormCollapseListH.setExpandedRowKeys,
|
|
58
61
|
fieldsToDataSource = _useFormCollapseListH.fieldsToDataSource,
|
|
59
|
-
getFormListOperation = _useFormCollapseListH.getFormListOperation
|
|
62
|
+
getFormListOperation = _useFormCollapseListH.getFormListOperation,
|
|
63
|
+
getFieldPath = _useFormCollapseListH.getFieldPath,
|
|
64
|
+
firstColumnFormItemName = _useFormCollapseListH.firstColumnFormItemName;
|
|
60
65
|
var _useMemo = useMemo(function () {
|
|
61
66
|
return fieldsToDataSource(fieldsWatch);
|
|
62
67
|
}, [fieldsWatch, fieldsToDataSource]),
|
|
@@ -85,8 +90,12 @@ export var FormCollapseList = function FormCollapseList(_ref) {
|
|
|
85
90
|
if (addOneFieldDefault && (!(form !== null && form !== void 0 && form.getFieldValue(name)) || (form === null || form === void 0 || (_form$getFieldValue = form.getFieldValue(name)) === null || _form$getFieldValue === void 0 ? void 0 : _form$getFieldValue.length) === 0)) {
|
|
86
91
|
var _listAdd$current;
|
|
87
92
|
(_listAdd$current = listAdd.current) === null || _listAdd$current === void 0 || _listAdd$current.call.apply(_listAdd$current, [listAdd].concat(_toConsumableArray(getAddParams())));
|
|
93
|
+
// Scroll and focus new item which is just added
|
|
94
|
+
setTimeout(function () {
|
|
95
|
+
form.focusField([name, 0, firstColumnFormItemName]);
|
|
96
|
+
}, 200);
|
|
88
97
|
}
|
|
89
|
-
}, [addOneFieldDefault, getAddParams, form, name]);
|
|
98
|
+
}, [addOneFieldDefault, getAddParams, form, name, firstColumnFormItemName]);
|
|
90
99
|
return /*#__PURE__*/_jsx(CollapseGroup, {
|
|
91
100
|
extra: extra === undefined ? name && !readOnly && /*#__PURE__*/_jsx(Tooltip, {
|
|
92
101
|
title: maxFileds && "\u6700\u591A\u6DFB\u52A0 ".concat(maxFileds, " \u9879"),
|
|
@@ -97,6 +106,10 @@ export var FormCollapseList = function FormCollapseList(_ref) {
|
|
|
97
106
|
var _listAdd$current2;
|
|
98
107
|
e.stopPropagation();
|
|
99
108
|
(_listAdd$current2 = listAdd.current) === null || _listAdd$current2 === void 0 || _listAdd$current2.call.apply(_listAdd$current2, [listAdd].concat(_toConsumableArray(getAddParams())));
|
|
109
|
+
// Scroll and focus new item which is just added
|
|
110
|
+
setTimeout(function () {
|
|
111
|
+
form.focusField([name, form.getFieldValue(name).length - 1, firstColumnFormItemName]);
|
|
112
|
+
}, 200);
|
|
100
113
|
},
|
|
101
114
|
size: "small",
|
|
102
115
|
type: "text"
|
|
@@ -147,7 +160,8 @@ export var FormCollapseList = function FormCollapseList(_ref) {
|
|
|
147
160
|
var field = fields[index] || {};
|
|
148
161
|
var fieldName = field.name;
|
|
149
162
|
var fieldKeyPath = record[FIELD_KEY_PATH];
|
|
150
|
-
var fieldPath = getFieldPath(fieldKeyPath)
|
|
163
|
+
var fieldPath = [name].concat(_toConsumableArray(getFieldPath(fieldKeyPath)));
|
|
164
|
+
var parentFieldPath = fieldPath.slice(0, -1);
|
|
151
165
|
var key = field.key,
|
|
152
166
|
restField = _objectWithoutProperties(field, _excluded3);
|
|
153
167
|
var children = fieldRender === null || fieldRender === void 0 ? void 0 : fieldRender(fieldName !== null && fieldName !== void 0 ? fieldName : fieldKeyPath.at(-1), index, getFormListOperation(operation, record), fieldPath);
|
|
@@ -177,11 +191,11 @@ export var FormCollapseList = function FormCollapseList(_ref) {
|
|
|
177
191
|
return /*#__PURE__*/_jsx(Form.Item, _objectSpread(_objectSpread(_objectSpread({
|
|
178
192
|
className: className
|
|
179
193
|
}, restField), {}, {
|
|
180
|
-
dependencies: typeof dependencies === 'function' ? dependencies(
|
|
194
|
+
dependencies: typeof dependencies === 'function' ? dependencies(parentFieldPath, index) : dependencies,
|
|
181
195
|
name: getFieldPath(fieldKeyPath, itemName)
|
|
182
196
|
// label={getFieldPath(fieldKeyPath, itemName).join('/')}
|
|
183
197
|
,
|
|
184
|
-
rules: typeof rules === 'function' ? rules(
|
|
198
|
+
rules: typeof rules === 'function' ? rules(parentFieldPath, index) : rules
|
|
185
199
|
}, itemProps), {}, {
|
|
186
200
|
children: children && /*#__PURE__*/React.cloneElement(children, chidrenProps)
|
|
187
201
|
}), key);
|
|
@@ -230,9 +244,7 @@ export var FormCollapseList = function FormCollapseList(_ref) {
|
|
|
230
244
|
dataSource: dataSource,
|
|
231
245
|
expandable: {
|
|
232
246
|
expandedRowKeys: expandedRowKeys,
|
|
233
|
-
|
|
234
|
-
children: "columnTitle"
|
|
235
|
-
}),
|
|
247
|
+
childrenColumnName: childrenColumnName,
|
|
236
248
|
onExpandedRowsChange: function onExpandedRowsChange(expandedKeys) {
|
|
237
249
|
setExpandedRowKeys(expandedKeys);
|
|
238
250
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { NamePath } from 'antd/es/form/interface';
|
|
2
2
|
export declare const FIELD_KEY_PATH = "__YUNTI_FORM_COLLAPSE_LIST_FIELD_KEY_PATH";
|
|
3
|
-
export
|
|
3
|
+
export type ListFieldValue<K extends string = 'children'> = {
|
|
4
|
+
[P in K]?: ListFieldValue[];
|
|
5
|
+
} & {
|
|
4
6
|
[key: string]: any;
|
|
5
7
|
[FIELD_KEY_PATH]: number[];
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
+
};
|
|
8
9
|
export type FieldPath = NamePath<any>;
|
|
9
|
-
export declare const getFieldPath: (fieldKeyPath: number[], fieldName?: string) => any;
|
|
10
10
|
export declare const toRowKey: (keyPath: number[]) => string;
|
|
@@ -1,33 +1,4 @@
|
|
|
1
|
-
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
-
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
3
|
-
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); }
|
|
4
|
-
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; }
|
|
5
1
|
export var FIELD_KEY_PATH = '__YUNTI_FORM_COLLAPSE_LIST_FIELD_KEY_PATH';
|
|
6
|
-
export var getFieldPath = function getFieldPath(fieldKeyPath, fieldName) {
|
|
7
|
-
var fieldPath = [];
|
|
8
|
-
var _iterator = _createForOfIteratorHelper(fieldKeyPath.entries()),
|
|
9
|
-
_step;
|
|
10
|
-
try {
|
|
11
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
12
|
-
var _step$value = _slicedToArray(_step.value, 2),
|
|
13
|
-
index = _step$value[0],
|
|
14
|
-
_key = _step$value[1];
|
|
15
|
-
if (index === fieldKeyPath.length - 1) {
|
|
16
|
-
fieldPath.push(_key);
|
|
17
|
-
if (fieldName) {
|
|
18
|
-
fieldPath.push(fieldName);
|
|
19
|
-
}
|
|
20
|
-
} else {
|
|
21
|
-
fieldPath.push(_key, 'children');
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
} catch (err) {
|
|
25
|
-
_iterator.e(err);
|
|
26
|
-
} finally {
|
|
27
|
-
_iterator.f();
|
|
28
|
-
}
|
|
29
|
-
return fieldPath;
|
|
30
|
-
};
|
|
31
2
|
export var toRowKey = function toRowKey(keyPath) {
|
|
32
3
|
return keyPath.join('-');
|
|
33
4
|
};
|