mirror of
				https://github.com/strapi/strapi.git
				synced 2025-11-04 03:43:34 +00:00 
			
		
		
		
	ReactSelect: Export styled async component from react-select
This commit is contained in:
		
							parent
							
								
									78c8651e1e
								
							
						
					
					
						commit
						884aee6e96
					
				@ -0,0 +1,41 @@
 | 
			
		||||
import PropTypes from 'prop-types';
 | 
			
		||||
import React from 'react';
 | 
			
		||||
import SelectAsync from 'react-select/async';
 | 
			
		||||
import { useTheme } from 'styled-components';
 | 
			
		||||
 | 
			
		||||
import ClearIndicator from '../components/ClearIndicator';
 | 
			
		||||
import DropdownIndicator from '../components/DropdownIndicator';
 | 
			
		||||
import IndicatorSeparator from '../components/IndicatorSeparator';
 | 
			
		||||
 | 
			
		||||
import getSelectStyles from '../utils/getSelectStyles';
 | 
			
		||||
 | 
			
		||||
const ReactSelectAsync = ({ components, styles, error, ariaErrorMessage, ...props }) => {
 | 
			
		||||
  const theme = useTheme();
 | 
			
		||||
  const customStyles = getSelectStyles(theme, error);
 | 
			
		||||
 | 
			
		||||
  return (
 | 
			
		||||
    <SelectAsync
 | 
			
		||||
      {...props}
 | 
			
		||||
      components={{ ClearIndicator, DropdownIndicator, IndicatorSeparator, ...components }}
 | 
			
		||||
      aria-errormessage={error && ariaErrorMessage}
 | 
			
		||||
      aria-invalid={!!error}
 | 
			
		||||
      styles={{ ...customStyles, ...styles }}
 | 
			
		||||
    />
 | 
			
		||||
  );
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export default ReactSelectAsync;
 | 
			
		||||
 | 
			
		||||
ReactSelectAsync.defaultProps = {
 | 
			
		||||
  ariaErrorMessage: undefined,
 | 
			
		||||
  components: undefined,
 | 
			
		||||
  error: undefined,
 | 
			
		||||
  styles: undefined,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
ReactSelectAsync.propTypes = {
 | 
			
		||||
  ariaErrorMessage: PropTypes.string,
 | 
			
		||||
  components: PropTypes.object,
 | 
			
		||||
  error: PropTypes.string,
 | 
			
		||||
  styles: PropTypes.object,
 | 
			
		||||
};
 | 
			
		||||
@ -0,0 +1 @@
 | 
			
		||||
export default from './Async';
 | 
			
		||||
@ -1,3 +1 @@
 | 
			
		||||
import ReactSelect from './ReactSelect';
 | 
			
		||||
 | 
			
		||||
export default ReactSelect;
 | 
			
		||||
export default from './ReactSelect';
 | 
			
		||||
 | 
			
		||||
@ -64,6 +64,7 @@ export { default as PageSizeURLQuery } from './components/PageSizeURLQuery';
 | 
			
		||||
export { default as RelativeTime } from './components/RelativeTime';
 | 
			
		||||
export { default as DateTimePicker } from './components/DateTimePicker';
 | 
			
		||||
export { default as ReactSelect } from './components/ReactSelect';
 | 
			
		||||
export { default as ReactSelectAsync } from './components/ReactSelect/Async';
 | 
			
		||||
export { default as Link } from './components/Link';
 | 
			
		||||
export { default as LinkButton } from './components/LinkButton';
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user