1 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,59 @@ |
1 |
+"use strict"; |
|
2 |
+ |
|
3 |
+exports.__esModule = true; |
|
4 |
+exports.getChildren = getChildren; |
|
5 |
+ |
|
6 |
+var _react = _interopRequireDefault(require("react")); |
|
7 |
+ |
|
8 |
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
|
9 |
+ |
|
10 |
+function processChildren(c) { |
|
11 |
+ var slides = []; |
|
12 |
+ |
|
13 |
+ _react.default.Children.toArray(c).forEach(function (child) { |
|
14 |
+ if (child.type && child.type.displayName === 'SwiperSlide') { |
|
15 |
+ slides.push(child); |
|
16 |
+ } else if (child.props && child.props.children) { |
|
17 |
+ processChildren(child.props.children).forEach(function (slide) { |
|
18 |
+ return slides.push(slide); |
|
19 |
+ }); |
|
20 |
+ } |
|
21 |
+ }); |
|
22 |
+ |
|
23 |
+ return slides; |
|
24 |
+} |
|
25 |
+ |
|
26 |
+function getChildren(c) { |
|
27 |
+ var slides = []; |
|
28 |
+ var slots = { |
|
29 |
+ 'container-start': [], |
|
30 |
+ 'container-end': [], |
|
31 |
+ 'wrapper-start': [], |
|
32 |
+ 'wrapper-end': [] |
|
33 |
+ }; |
|
34 |
+ |
|
35 |
+ _react.default.Children.toArray(c).forEach(function (child) { |
|
36 |
+ if (child.type && child.type.displayName === 'SwiperSlide') { |
|
37 |
+ slides.push(child); |
|
38 |
+ } else if (child.props && child.props.slot && slots[child.props.slot]) { |
|
39 |
+ slots[child.props.slot].push(child); |
|
40 |
+ } else if (child.props && child.props.children) { |
|
41 |
+ var foundSlides = processChildren(child.props.children); |
|
42 |
+ |
|
43 |
+ if (foundSlides.length > 0) { |
|
44 |
+ foundSlides.forEach(function (slide) { |
|
45 |
+ return slides.push(slide); |
|
46 |
+ }); |
|
47 |
+ } else { |
|
48 |
+ slots['container-end'].push(child); |
|
49 |
+ } |
|
50 |
+ } else { |
|
51 |
+ slots['container-end'].push(child); |
|
52 |
+ } |
|
53 |
+ }); |
|
54 |
+ |
|
55 |
+ return { |
|
56 |
+ slides: slides, |
|
57 |
+ slots: slots |
|
58 |
+ }; |
|
59 |
+} |
|
0 | 60 |
\ No newline at end of file |