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

3 лет назад
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. "use strict";
  2. var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
  3. Object.defineProperty(exports, "__esModule", {
  4. value: true
  5. });
  6. exports.handleBreakpoints = handleBreakpoints;
  7. exports.default = void 0;
  8. var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
  9. var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
  10. var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
  11. var _warning = _interopRequireDefault(require("warning"));
  12. var _propTypes = _interopRequireDefault(require("prop-types"));
  13. var _merge = _interopRequireDefault(require("./merge"));
  14. // The breakpoint **start** at this value.
  15. // For instance with the first breakpoint xs: [xs, sm[.
  16. var values = {
  17. xs: 0,
  18. sm: 600,
  19. md: 960,
  20. lg: 1280,
  21. xl: 1920
  22. };
  23. var defaultBreakpoints = {
  24. // Sorted ASC by size. That's important.
  25. // It can't be configured as it's used statically for propTypes.
  26. keys: ['xs', 'sm', 'md', 'lg', 'xl'],
  27. up: function up(key) {
  28. return "@media (min-width:".concat(values[key], "px)");
  29. }
  30. };
  31. function handleBreakpoints(props, propValue, styleFromPropValue) {
  32. process.env.NODE_ENV !== "production" ? (0, _warning.default)(props.theme, '@material-ui/system: you are calling a style function without a theme value.') : void 0;
  33. if (Array.isArray(propValue)) {
  34. var themeBreakpoints = props.theme.breakpoints || defaultBreakpoints;
  35. return propValue.reduce(function (acc, item, index) {
  36. acc[themeBreakpoints.up(themeBreakpoints.keys[index])] = styleFromPropValue(propValue[index]);
  37. return acc;
  38. }, {});
  39. }
  40. if ((0, _typeof2.default)(propValue) === 'object') {
  41. var _themeBreakpoints = props.theme.breakpoints || defaultBreakpoints;
  42. return Object.keys(propValue).reduce(function (acc, breakpoint) {
  43. acc[_themeBreakpoints.up(breakpoint)] = styleFromPropValue(propValue[breakpoint]);
  44. return acc;
  45. }, {});
  46. }
  47. var output = styleFromPropValue(propValue);
  48. return output;
  49. }
  50. function breakpoints(styleFunction) {
  51. var newStyleFunction = function newStyleFunction(props) {
  52. var base = styleFunction(props);
  53. var themeBreakpoints = props.theme.breakpoints || defaultBreakpoints;
  54. var extended = themeBreakpoints.keys.reduce(function (acc, key) {
  55. if (props[key]) {
  56. acc = acc || {};
  57. acc[themeBreakpoints.up(key)] = styleFunction((0, _extends2.default)({
  58. theme: props.theme
  59. }, props[key]));
  60. }
  61. return acc;
  62. }, null);
  63. return (0, _merge.default)(base, extended);
  64. };
  65. newStyleFunction.propTypes = process.env.NODE_ENV !== 'production' ? (0, _extends2.default)({}, styleFunction.propTypes, {
  66. xs: _propTypes.default.object,
  67. sm: _propTypes.default.object,
  68. md: _propTypes.default.object,
  69. lg: _propTypes.default.object,
  70. xl: _propTypes.default.object
  71. }) : {};
  72. newStyleFunction.filterProps = ['xs', 'sm', 'md', 'lg', 'xl'].concat((0, _toConsumableArray2.default)(styleFunction.filterProps));
  73. return newStyleFunction;
  74. }
  75. var _default = breakpoints;
  76. exports.default = _default;