@fe6/water-pro
Version:
An enterprise-class UI design language and Vue-based implementation
52 lines (40 loc) • 1.51 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.convertChildrenToData = convertChildrenToData;
var _vue = require("vue");
var _tslib = require("tslib");
var _propsUtil = require("../_util/props-util");
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
function convertChildrenToData(nodes) {
return (0, _propsUtil.flattenChildren)(nodes).map(function (node) {
if (!(0, _propsUtil.isValidElement)(node) || !node.type) {
return null;
}
var _a = node.children || {},
d = _a.default,
restSlot = (0, _tslib.__rest)(_a, ["default"]);
var children = d ? d() : [];
var key = node.key,
_b = node.props,
value = _b.value,
restProps = (0, _tslib.__rest)(_b, ["value"]);
var data = _extends({
key: key,
value: value
}, restProps);
Object.keys(restSlot).forEach(function (p) {
if (typeof restSlot[p] === 'function') {
data[p] = (0, _vue.createVNode)(_vue.Fragment, null, [restSlot[p]()]);
}
});
var childData = convertChildrenToData(children);
if (childData.length) {
data.children = childData;
}
return data;
}).filter(function (data) {
return data;
});
}