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.
45 lines
1.5 KiB
45 lines
1.5 KiB
"use strict";
|
|
|
|
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
|
|
|
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.parseChildren = parseChildren;
|
|
|
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
|
|
var React = _interopRequireWildcard(require("react"));
|
|
|
|
var _toArray = _interopRequireDefault(require("rc-util/lib/Children/toArray"));
|
|
|
|
function parseChildren(children, keyPath) {
|
|
return (0, _toArray.default)(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((0, _toConsumableArray2.default)(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;
|
|
});
|
|
} |