Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

getDynamicStyles.js 976 B

3 lat temu
123456789101112131415161718192021222324252627282930313233
  1. 'use strict';
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  6. exports['default'] = getDynamicStyles;
  7. /**
  8. * Extracts a styles object with only props that contain function values.
  9. */
  10. function getDynamicStyles(styles) {
  11. var to = null;
  12. for (var key in styles) {
  13. var value = styles[key];
  14. var type = typeof value === 'undefined' ? 'undefined' : _typeof(value);
  15. if (type === 'function') {
  16. if (!to) to = {};
  17. to[key] = value;
  18. } else if (type === 'object' && value !== null && !Array.isArray(value)) {
  19. var extracted = getDynamicStyles(value);
  20. if (extracted) {
  21. if (!to) to = {};
  22. to[key] = extracted;
  23. }
  24. }
  25. }
  26. return to;
  27. }