amis-rpc-design/node_modules/@ant-design/cssinjs/es/theme/Theme.js
2023-10-07 19:42:30 +08:00

33 lines
1.2 KiB
JavaScript

import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
import _createClass from "@babel/runtime/helpers/esm/createClass";
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
import { warning } from "rc-util/es/warning";
var uuid = 0;
/**
* Theme with algorithms to derive tokens from design tokens.
* Use `createTheme` first which will help to manage the theme instance cache.
*/
var Theme = /*#__PURE__*/function () {
function Theme(derivatives) {
_classCallCheck(this, Theme);
_defineProperty(this, "derivatives", void 0);
_defineProperty(this, "id", void 0);
this.derivatives = Array.isArray(derivatives) ? derivatives : [derivatives];
this.id = uuid;
if (derivatives.length === 0) {
warning(derivatives.length > 0, '[Ant Design CSS-in-JS] Theme should have at least one derivative function.');
}
uuid += 1;
}
_createClass(Theme, [{
key: "getDerivativeToken",
value: function getDerivativeToken(token) {
return this.derivatives.reduce(function (result, derivative) {
return derivative(token, result);
}, undefined);
}
}]);
return Theme;
}();
export { Theme as default };