You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

35 rivejä
911 B

  1. import _extends from "@babel/runtime/helpers/extends";
  2. import PropTypes from 'prop-types';
  3. import merge from './merge';
  4. function omit(input, fields) {
  5. const output = {};
  6. Object.keys(input).forEach(prop => {
  7. if (fields.indexOf(prop) === -1) {
  8. output[prop] = input[prop];
  9. }
  10. });
  11. return output;
  12. }
  13. function css(styleFunction) {
  14. const newStyleFunction = props => {
  15. const output = styleFunction(props);
  16. if (props.css) {
  17. return _extends({}, merge(output, styleFunction(_extends({
  18. theme: props.theme
  19. }, props.css))), omit(props.css, [styleFunction.filterProps]));
  20. }
  21. return output;
  22. };
  23. newStyleFunction.propTypes = process.env.NODE_ENV !== 'production' ? _extends({}, styleFunction.propTypes, {
  24. css: PropTypes.object
  25. }) : {};
  26. newStyleFunction.filterProps = ['css', ...styleFunction.filterProps];
  27. return newStyleFunction;
  28. }
  29. export default css;