Theme.js 918 B

123456789101112131415161718192021222324252627
  1. "use strict";
  2. var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
  3. Object.defineProperty(exports, "__esModule", {
  4. value: true
  5. });
  6. exports.default = void 0;
  7. var _warning = _interopRequireDefault(require("../../warning"));
  8. let uuid = 0;
  9. /**
  10. * Theme with algorithms to derive tokens from design tokens.
  11. * Use `createTheme` first which will help to manage the theme instance cache.
  12. */
  13. class Theme {
  14. constructor(derivatives) {
  15. this.derivatives = Array.isArray(derivatives) ? derivatives : [derivatives];
  16. this.id = uuid;
  17. if (derivatives.length === 0) {
  18. (0, _warning.default)(derivatives.length > 0, '[Ant Design Vue CSS-in-JS] Theme should have at least one derivative function.');
  19. }
  20. uuid += 1;
  21. }
  22. getDerivativeToken(token) {
  23. return this.derivatives.reduce((result, derivative) => derivative(token, result), undefined);
  24. }
  25. }
  26. exports.default = Theme;