mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-10-31 04:31:15 -06:00 
			
		
		
		
	 b4ffa91cb4
			
		
	
	
		b4ffa91cb4
		
	
	
	
	
		
			
			Change-Id: I066c0e7f8ce87ec00b1141a1b44430444a819b42 (cherry picked from commit 05907a1a42da82737090d55046974d401f8af057)
		
			
				
	
	
		
			46 lines
		
	
	
		
			No EOL
		
	
	
		
			1.2 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			46 lines
		
	
	
		
			No EOL
		
	
	
		
			1.2 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| import React from 'react';
 | |
| 
 | |
| function processChildren(c) {
 | |
|   const slides = [];
 | |
|   React.Children.toArray(c).forEach(child => {
 | |
|     if (child.type && child.type.displayName === 'SwiperSlide') {
 | |
|       slides.push(child);
 | |
|     } else if (child.props && child.props.children) {
 | |
|       processChildren(child.props.children).forEach(slide => slides.push(slide));
 | |
|     }
 | |
|   });
 | |
|   return slides;
 | |
| }
 | |
| 
 | |
| function getChildren(c) {
 | |
|   const slides = [];
 | |
|   const slots = {
 | |
|     'container-start': [],
 | |
|     'container-end': [],
 | |
|     'wrapper-start': [],
 | |
|     'wrapper-end': []
 | |
|   };
 | |
|   React.Children.toArray(c).forEach(child => {
 | |
|     if (child.type && child.type.displayName === 'SwiperSlide') {
 | |
|       slides.push(child);
 | |
|     } else if (child.props && child.props.slot && slots[child.props.slot]) {
 | |
|       slots[child.props.slot].push(child);
 | |
|     } else if (child.props && child.props.children) {
 | |
|       const foundSlides = processChildren(child.props.children);
 | |
| 
 | |
|       if (foundSlides.length > 0) {
 | |
|         foundSlides.forEach(slide => slides.push(slide));
 | |
|       } else {
 | |
|         slots['container-end'].push(child);
 | |
|       }
 | |
|     } else {
 | |
|       slots['container-end'].push(child);
 | |
|     }
 | |
|   });
 | |
|   return {
 | |
|     slides,
 | |
|     slots
 | |
|   };
 | |
| }
 | |
| 
 | |
| export { getChildren }; |