You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
1.1 KiB
31 lines
1.1 KiB
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
import * as React from 'react';
|
|
import toArray from "rc-util/es/Children/toArray";
|
|
export function parseChildren(children, keyPath) {
|
|
return toArray(children).map(function (child, index) {
|
|
if ( /*#__PURE__*/React.isValidElement(child)) {
|
|
var _child$props$eventKey, _child$props;
|
|
|
|
var key = child.key;
|
|
var eventKey = (_child$props$eventKey = (_child$props = child.props) === null || _child$props === void 0 ? void 0 : _child$props.eventKey) !== null && _child$props$eventKey !== void 0 ? _child$props$eventKey : key;
|
|
var emptyKey = eventKey === null || eventKey === undefined;
|
|
|
|
if (emptyKey) {
|
|
eventKey = "tmp_key-".concat([].concat(_toConsumableArray(keyPath), [index]).join('-'));
|
|
}
|
|
|
|
var cloneProps = {
|
|
key: eventKey,
|
|
eventKey: eventKey
|
|
};
|
|
|
|
if (process.env.NODE_ENV !== 'production' && emptyKey) {
|
|
cloneProps.warnKey = true;
|
|
}
|
|
|
|
return /*#__PURE__*/React.cloneElement(child, cloneProps);
|
|
}
|
|
|
|
return child;
|
|
});
|
|
} |