UNPKG

1.91 kBJavaScriptView Raw
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.convertChildrenToData = convertChildrenToData;
7
8var _vue = require("vue");
9
10var _propsUtil = require("../_util/props-util");
11
12function _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); }
13
14var __rest = void 0 && (void 0).__rest || function (s, e) {
15 var t = {};
16
17 for (var p in s) {
18 if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
19 }
20
21 if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
22 if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
23 }
24 return t;
25};
26
27function convertChildrenToData(nodes) {
28 return (0, _propsUtil.flattenChildren)(nodes).map(function (node) {
29 if (!(0, _propsUtil.isValidElement)(node) || !node.type) {
30 return null;
31 }
32
33 var _a = node.children || {},
34 d = _a.default,
35 restSlot = __rest(_a, ["default"]);
36
37 var children = d ? d() : [];
38
39 var key = node.key,
40 _b = node.props,
41 value = _b.value,
42 restProps = __rest(_b, ["value"]);
43
44 var data = _extends({
45 key: key,
46 value: value
47 }, restProps);
48
49 Object.keys(restSlot).forEach(function (p) {
50 if (typeof restSlot[p] === 'function') {
51 data[p] = (0, _vue.createVNode)(_vue.Fragment, null, [restSlot[p]()]);
52 }
53 });
54 var childData = convertChildrenToData(children);
55
56 if (childData.length) {
57 data.children = childData;
58 }
59
60 return data;
61 }).filter(function (data) {
62 return data;
63 });
64}
\No newline at end of file