Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var recursive = function recursive(children) {
// Note: if use `React.Children.map`, the node's key will be modified.
return toArray(children).map(function handler(child) {
// eslint-disable-line
if (!child) {
return null;
}
if (child && child.props.children) {
// null or String has no Prop
return React.createElement(
TreeNode,
_extends({}, child.props, { key: child.key }),
recursive(child.props.children)
);
}
return React.createElement(TreeNode, _extends({}, child.props, { key: child.key }));
});
};
// const s = Date.now();
var generateChildrenRows = function generateChildrenRows(children, column) {
var rows = [];
var columns = null;
var leftSpans;
var itemNodes = toArray(children);
itemNodes.forEach(function (node, index) {
var itemNode = node;
if (!columns) {
leftSpans = column;
columns = [];
rows.push(columns);
} // Always set last span to align the end of Descriptions
var lastItem = index === itemNodes.length - 1;
var lastSpanSame = true;
if (lastItem) {
lastSpanSame = !itemNode.props.span || itemNode.props.span === leftSpans;
itemNode = React.cloneElement(itemNode, {
value: function syncEllipsis() {
var _this$state = this.state,
ellipsisText = _this$state.ellipsisText,
isEllipsis = _this$state.isEllipsis,
expanded = _this$state.expanded;
var _this$getEllipsis3 = this.getEllipsis(),
rows = _this$getEllipsis3.rows;
var children = this.props.children;
if (!rows || rows < 0 || !this.content || expanded) return; // Do not measure if css already support ellipsis
if (this.canUseCSSEllipsis()) return;
warning(toArray(children).every(function (child) {
return typeof child === 'string';
}), 'Typography', '`ellipsis` should use string as children only.');
var _measure = measure(this.content, rows, children, this.renderOperations(true), ELLIPSIS_STR),
content = _measure.content,
text = _measure.text,
ellipsis = _measure.ellipsis;
if (ellipsisText !== text || isEllipsis !== ellipsis) {
this.setState({
ellipsisText: text,
ellipsisContent: content,
isEllipsis: ellipsis
});
}
}
function filterFragment(children) {
return toArray(children).map(function (element) {
if (React.isValidElement(element) && element.type === React.Fragment) {
var props = element.props;
return props.children;
}
return element;
});
}
var prefixCls = _ref2.prefixCls;
var renderCol = function renderCol(colItem, type, idx) {
return React.createElement(Col, {
child: colItem,
bordered: bordered,
colon: colon,
type: type,
key: "".concat(type, "-").concat(colItem.key || idx),
layout: layout
});
};
var cloneChildren = [];
var cloneContentChildren = [];
toArray(children).forEach(function (childrenItem, idx) {
cloneChildren.push(renderCol(childrenItem, 'label', idx));
if (layout === 'vertical') {
cloneContentChildren.push(renderCol(childrenItem, 'content', idx));
} else if (bordered) {
cloneChildren.push(renderCol(childrenItem, 'content', idx));
}
});
if (layout === 'vertical') {
return [React.createElement("tr", {
className: "".concat(prefixCls, "-row"),
key: "label-".concat(index)
}, cloneChildren), React.createElement("tr", {
className: "".concat(prefixCls, "-row"),
key: "content-".concat(index)
customizePrefixCls = _this3$props.prefixCls,
title = _this3$props.title,
size = _this3$props.size,
children = _this3$props.children,
_this3$props$bordered = _this3$props.bordered,
bordered = _this3$props$bordered === void 0 ? false : _this3$props$bordered,
_this3$props$layout = _this3$props.layout,
layout = _this3$props$layout === void 0 ? 'horizontal' : _this3$props$layout,
_this3$props$colon = _this3$props.colon,
colon = _this3$props$colon === void 0 ? true : _this3$props$colon,
style = _this3$props.style;
var prefixCls = getPrefixCls('descriptions', customizePrefixCls);
var column = _this3.getColumn();
var cloneChildren = toArray(children).map(function (child) {
if (React.isValidElement(child)) {
return React.cloneElement(child, {
prefixCls: prefixCls
});
}
return null;
}).filter(function (node) {
return node;
});
var childrenArray = generateChildrenRows(cloneChildren, column);
return React.createElement("div", {
className: classNames(prefixCls, className, (_classNames = {}, _defineProperty(_classNames, "".concat(prefixCls, "-").concat(size), size !== 'default'), _defineProperty(_classNames, "".concat(prefixCls, "-bordered"), !!bordered), _classNames)),
style: style
}, title && React.createElement("div", {
className: "".concat(prefixCls, "-title")
clonedMenuItems = menuItems.map(function (item) {
if (item.type.isMenuItemGroup) {
var children = toArray(item.props.children).map(clone);
return cloneElement(item, {}, children);
}
return clone(item);
});
}