UNPKG

1.03 kBJavaScriptView Raw
1"use strict";
2
3exports.__esModule = true;
4exports.getChildren = getChildren;
5
6var _react = _interopRequireDefault(require("react"));
7
8function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
10function getChildren(children) {
11 var slides = [];
12 var slots = {
13 'container-start': [],
14 'container-end': [],
15 'wrapper-start': [],
16 'wrapper-end': []
17 };
18
19 function processChildren(c) {
20 _react.default.Children.toArray(c).forEach(function (child) {
21 if (child.type === _react.default.Fragment && child.props.children) {
22 processChildren(child.props.children);
23 return;
24 }
25
26 if (child.type && child.type.displayName === 'SwiperSlide') {
27 slides.push(child);
28 } else if (child.props && child.props.slot && slots[child.props.slot]) {
29 slots[child.props.slot].push(child);
30 } else {
31 slots['container-end'].push(child);
32 }
33 });
34 }
35
36 processChildren(children);
37 return {
38 slides: slides,
39 slots: slots
40 };
41}
\No newline at end of file