Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 

35 строки
998 B

  1. import _extends from "@babel/runtime/helpers/extends";
  2. import merge from './merge';
  3. function compose(...styles) {
  4. const fn = props => styles.reduce((acc, style) => {
  5. const output = style(props);
  6. if (output) {
  7. return merge(acc, output);
  8. }
  9. return acc;
  10. }, {}); // Alternative approach that doesn't yield any performance gain.
  11. // const handlers = styles.reduce((acc, style) => {
  12. // style.filterProps.forEach(prop => {
  13. // acc[prop] = style;
  14. // });
  15. // return acc;
  16. // }, {});
  17. // const fn = props => {
  18. // return Object.keys(props).reduce((acc, prop) => {
  19. // if (handlers[prop]) {
  20. // return merge(acc, handlers[prop](props));
  21. // }
  22. // return acc;
  23. // }, {});
  24. // };
  25. fn.propTypes = process.env.NODE_ENV !== 'production' ? styles.reduce((acc, style) => _extends(acc, style.propTypes), {}) : {};
  26. fn.filterProps = styles.reduce((acc, style) => acc.concat(style.filterProps), []);
  27. return fn;
  28. }
  29. export default compose;