cs
This commit is contained in:
11
node_modules/@ant-design/cssinjs/es/theme/Theme.d.ts
generated
vendored
Normal file
11
node_modules/@ant-design/cssinjs/es/theme/Theme.d.ts
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
import type { DerivativeFunc, TokenType } from './interface';
|
||||
/**
|
||||
* Theme with algorithms to derive tokens from design tokens.
|
||||
* Use `createTheme` first which will help to manage the theme instance cache.
|
||||
*/
|
||||
export default class Theme<DesignToken extends TokenType, DerivativeToken extends TokenType> {
|
||||
private derivatives;
|
||||
readonly id: number;
|
||||
constructor(derivatives: DerivativeFunc<DesignToken, DerivativeToken> | DerivativeFunc<DesignToken, DerivativeToken>[]);
|
||||
getDerivativeToken(token: DesignToken): DerivativeToken;
|
||||
}
|
||||
33
node_modules/@ant-design/cssinjs/es/theme/Theme.js
generated
vendored
Normal file
33
node_modules/@ant-design/cssinjs/es/theme/Theme.js
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
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 };
|
||||
20
node_modules/@ant-design/cssinjs/es/theme/ThemeCache.d.ts
generated
vendored
Normal file
20
node_modules/@ant-design/cssinjs/es/theme/ThemeCache.d.ts
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
import type Theme from './Theme';
|
||||
import type { DerivativeFunc } from './interface';
|
||||
type DerivativeOptions = DerivativeFunc<any, any>[];
|
||||
export declare function sameDerivativeOption(left: DerivativeOptions, right: DerivativeOptions): boolean;
|
||||
export default class ThemeCache {
|
||||
static MAX_CACHE_SIZE: number;
|
||||
static MAX_CACHE_OFFSET: number;
|
||||
private readonly cache;
|
||||
private keys;
|
||||
private cacheCallTimes;
|
||||
constructor();
|
||||
size(): number;
|
||||
private internalGet;
|
||||
get(derivativeOption: DerivativeOptions): Theme<any, any> | undefined;
|
||||
has(derivativeOption: DerivativeOptions): boolean;
|
||||
set(derivativeOption: DerivativeOptions, value: Theme<any, any>): void;
|
||||
private deleteByPath;
|
||||
delete(derivativeOption: DerivativeOptions): Theme<any, any> | undefined;
|
||||
}
|
||||
export {};
|
||||
143
node_modules/@ant-design/cssinjs/es/theme/ThemeCache.js
generated
vendored
Normal file
143
node_modules/@ant-design/cssinjs/es/theme/ThemeCache.js
generated
vendored
Normal file
@@ -0,0 +1,143 @@
|
||||
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
||||
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
||||
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
||||
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
||||
// ================================== Cache ==================================
|
||||
|
||||
export function sameDerivativeOption(left, right) {
|
||||
if (left.length !== right.length) {
|
||||
return false;
|
||||
}
|
||||
for (var i = 0; i < left.length; i++) {
|
||||
if (left[i] !== right[i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
var ThemeCache = /*#__PURE__*/function () {
|
||||
function ThemeCache() {
|
||||
_classCallCheck(this, ThemeCache);
|
||||
_defineProperty(this, "cache", void 0);
|
||||
_defineProperty(this, "keys", void 0);
|
||||
_defineProperty(this, "cacheCallTimes", void 0);
|
||||
this.cache = new Map();
|
||||
this.keys = [];
|
||||
this.cacheCallTimes = 0;
|
||||
}
|
||||
_createClass(ThemeCache, [{
|
||||
key: "size",
|
||||
value: function size() {
|
||||
return this.keys.length;
|
||||
}
|
||||
}, {
|
||||
key: "internalGet",
|
||||
value: function internalGet(derivativeOption) {
|
||||
var _cache2, _cache3;
|
||||
var updateCallTimes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
||||
var cache = {
|
||||
map: this.cache
|
||||
};
|
||||
derivativeOption.forEach(function (derivative) {
|
||||
if (!cache) {
|
||||
cache = undefined;
|
||||
} else {
|
||||
var _cache;
|
||||
cache = (_cache = cache) === null || _cache === void 0 || (_cache = _cache.map) === null || _cache === void 0 ? void 0 : _cache.get(derivative);
|
||||
}
|
||||
});
|
||||
if ((_cache2 = cache) !== null && _cache2 !== void 0 && _cache2.value && updateCallTimes) {
|
||||
cache.value[1] = this.cacheCallTimes++;
|
||||
}
|
||||
return (_cache3 = cache) === null || _cache3 === void 0 ? void 0 : _cache3.value;
|
||||
}
|
||||
}, {
|
||||
key: "get",
|
||||
value: function get(derivativeOption) {
|
||||
var _this$internalGet;
|
||||
return (_this$internalGet = this.internalGet(derivativeOption, true)) === null || _this$internalGet === void 0 ? void 0 : _this$internalGet[0];
|
||||
}
|
||||
}, {
|
||||
key: "has",
|
||||
value: function has(derivativeOption) {
|
||||
return !!this.internalGet(derivativeOption);
|
||||
}
|
||||
}, {
|
||||
key: "set",
|
||||
value: function set(derivativeOption, value) {
|
||||
var _this = this;
|
||||
// New cache
|
||||
if (!this.has(derivativeOption)) {
|
||||
if (this.size() + 1 > ThemeCache.MAX_CACHE_SIZE + ThemeCache.MAX_CACHE_OFFSET) {
|
||||
var _this$keys$reduce = this.keys.reduce(function (result, key) {
|
||||
var _result = _slicedToArray(result, 2),
|
||||
callTimes = _result[1];
|
||||
if (_this.internalGet(key)[1] < callTimes) {
|
||||
return [key, _this.internalGet(key)[1]];
|
||||
}
|
||||
return result;
|
||||
}, [this.keys[0], this.cacheCallTimes]),
|
||||
_this$keys$reduce2 = _slicedToArray(_this$keys$reduce, 1),
|
||||
targetKey = _this$keys$reduce2[0];
|
||||
this.delete(targetKey);
|
||||
}
|
||||
this.keys.push(derivativeOption);
|
||||
}
|
||||
var cache = this.cache;
|
||||
derivativeOption.forEach(function (derivative, index) {
|
||||
if (index === derivativeOption.length - 1) {
|
||||
cache.set(derivative, {
|
||||
value: [value, _this.cacheCallTimes++]
|
||||
});
|
||||
} else {
|
||||
var cacheValue = cache.get(derivative);
|
||||
if (!cacheValue) {
|
||||
cache.set(derivative, {
|
||||
map: new Map()
|
||||
});
|
||||
} else if (!cacheValue.map) {
|
||||
cacheValue.map = new Map();
|
||||
}
|
||||
cache = cache.get(derivative).map;
|
||||
}
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: "deleteByPath",
|
||||
value: function deleteByPath(currentCache, derivatives) {
|
||||
var cache = currentCache.get(derivatives[0]);
|
||||
if (derivatives.length === 1) {
|
||||
var _cache$value;
|
||||
if (!cache.map) {
|
||||
currentCache.delete(derivatives[0]);
|
||||
} else {
|
||||
currentCache.set(derivatives[0], {
|
||||
map: cache.map
|
||||
});
|
||||
}
|
||||
return (_cache$value = cache.value) === null || _cache$value === void 0 ? void 0 : _cache$value[0];
|
||||
}
|
||||
var result = this.deleteByPath(cache.map, derivatives.slice(1));
|
||||
if ((!cache.map || cache.map.size === 0) && !cache.value) {
|
||||
currentCache.delete(derivatives[0]);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}, {
|
||||
key: "delete",
|
||||
value: function _delete(derivativeOption) {
|
||||
// If cache exists
|
||||
if (this.has(derivativeOption)) {
|
||||
this.keys = this.keys.filter(function (item) {
|
||||
return !sameDerivativeOption(item, derivativeOption);
|
||||
});
|
||||
return this.deleteByPath(this.cache, derivativeOption);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
}]);
|
||||
return ThemeCache;
|
||||
}();
|
||||
_defineProperty(ThemeCache, "MAX_CACHE_SIZE", 20);
|
||||
_defineProperty(ThemeCache, "MAX_CACHE_OFFSET", 5);
|
||||
export { ThemeCache as default };
|
||||
15
node_modules/@ant-design/cssinjs/es/theme/calc/CSSCalculator.d.ts
generated
vendored
Normal file
15
node_modules/@ant-design/cssinjs/es/theme/calc/CSSCalculator.d.ts
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
import AbstractCalculator from './calculator';
|
||||
export default class CSSCalculator extends AbstractCalculator {
|
||||
result: string;
|
||||
unitlessCssVar: Set<string>;
|
||||
lowPriority?: boolean;
|
||||
constructor(num: number | string | AbstractCalculator, unitlessCssVar: Set<string>);
|
||||
add(num: number | string | AbstractCalculator): this;
|
||||
sub(num: number | string | AbstractCalculator): this;
|
||||
mul(num: number | string | AbstractCalculator): this;
|
||||
div(num: number | string | AbstractCalculator): this;
|
||||
getResult(force?: boolean): string;
|
||||
equal(options?: {
|
||||
unit?: boolean;
|
||||
}): string;
|
||||
}
|
||||
116
node_modules/@ant-design/cssinjs/es/theme/calc/CSSCalculator.js
generated
vendored
Normal file
116
node_modules/@ant-design/cssinjs/es/theme/calc/CSSCalculator.js
generated
vendored
Normal file
@@ -0,0 +1,116 @@
|
||||
import _typeof from "@babel/runtime/helpers/esm/typeof";
|
||||
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
||||
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
||||
import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
|
||||
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
||||
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
||||
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
||||
import AbstractCalculator from "./calculator";
|
||||
var CALC_UNIT = 'CALC_UNIT';
|
||||
var regexp = new RegExp(CALC_UNIT, 'g');
|
||||
function unit(value) {
|
||||
if (typeof value === 'number') {
|
||||
return "".concat(value).concat(CALC_UNIT);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
var CSSCalculator = /*#__PURE__*/function (_AbstractCalculator) {
|
||||
_inherits(CSSCalculator, _AbstractCalculator);
|
||||
var _super = _createSuper(CSSCalculator);
|
||||
function CSSCalculator(num, unitlessCssVar) {
|
||||
var _this;
|
||||
_classCallCheck(this, CSSCalculator);
|
||||
_this = _super.call(this);
|
||||
_defineProperty(_assertThisInitialized(_this), "result", '');
|
||||
_defineProperty(_assertThisInitialized(_this), "unitlessCssVar", void 0);
|
||||
_defineProperty(_assertThisInitialized(_this), "lowPriority", void 0);
|
||||
var numType = _typeof(num);
|
||||
_this.unitlessCssVar = unitlessCssVar;
|
||||
if (num instanceof CSSCalculator) {
|
||||
_this.result = "(".concat(num.result, ")");
|
||||
} else if (numType === 'number') {
|
||||
_this.result = unit(num);
|
||||
} else if (numType === 'string') {
|
||||
_this.result = num;
|
||||
}
|
||||
return _this;
|
||||
}
|
||||
_createClass(CSSCalculator, [{
|
||||
key: "add",
|
||||
value: function add(num) {
|
||||
if (num instanceof CSSCalculator) {
|
||||
this.result = "".concat(this.result, " + ").concat(num.getResult());
|
||||
} else if (typeof num === 'number' || typeof num === 'string') {
|
||||
this.result = "".concat(this.result, " + ").concat(unit(num));
|
||||
}
|
||||
this.lowPriority = true;
|
||||
return this;
|
||||
}
|
||||
}, {
|
||||
key: "sub",
|
||||
value: function sub(num) {
|
||||
if (num instanceof CSSCalculator) {
|
||||
this.result = "".concat(this.result, " - ").concat(num.getResult());
|
||||
} else if (typeof num === 'number' || typeof num === 'string') {
|
||||
this.result = "".concat(this.result, " - ").concat(unit(num));
|
||||
}
|
||||
this.lowPriority = true;
|
||||
return this;
|
||||
}
|
||||
}, {
|
||||
key: "mul",
|
||||
value: function mul(num) {
|
||||
if (this.lowPriority) {
|
||||
this.result = "(".concat(this.result, ")");
|
||||
}
|
||||
if (num instanceof CSSCalculator) {
|
||||
this.result = "".concat(this.result, " * ").concat(num.getResult(true));
|
||||
} else if (typeof num === 'number' || typeof num === 'string') {
|
||||
this.result = "".concat(this.result, " * ").concat(num);
|
||||
}
|
||||
this.lowPriority = false;
|
||||
return this;
|
||||
}
|
||||
}, {
|
||||
key: "div",
|
||||
value: function div(num) {
|
||||
if (this.lowPriority) {
|
||||
this.result = "(".concat(this.result, ")");
|
||||
}
|
||||
if (num instanceof CSSCalculator) {
|
||||
this.result = "".concat(this.result, " / ").concat(num.getResult(true));
|
||||
} else if (typeof num === 'number' || typeof num === 'string') {
|
||||
this.result = "".concat(this.result, " / ").concat(num);
|
||||
}
|
||||
this.lowPriority = false;
|
||||
return this;
|
||||
}
|
||||
}, {
|
||||
key: "getResult",
|
||||
value: function getResult(force) {
|
||||
return this.lowPriority || force ? "(".concat(this.result, ")") : this.result;
|
||||
}
|
||||
}, {
|
||||
key: "equal",
|
||||
value: function equal(options) {
|
||||
var _this2 = this;
|
||||
var _ref = options || {},
|
||||
cssUnit = _ref.unit;
|
||||
var mergedUnit = true;
|
||||
if (typeof cssUnit === 'boolean') {
|
||||
mergedUnit = cssUnit;
|
||||
} else if (Array.from(this.unitlessCssVar).some(function (cssVar) {
|
||||
return _this2.result.includes(cssVar);
|
||||
})) {
|
||||
mergedUnit = false;
|
||||
}
|
||||
this.result = this.result.replace(regexp, mergedUnit ? 'px' : '');
|
||||
if (typeof this.lowPriority !== 'undefined') {
|
||||
return "calc(".concat(this.result, ")");
|
||||
}
|
||||
return this.result;
|
||||
}
|
||||
}]);
|
||||
return CSSCalculator;
|
||||
}(AbstractCalculator);
|
||||
export { CSSCalculator as default };
|
||||
10
node_modules/@ant-design/cssinjs/es/theme/calc/NumCalculator.d.ts
generated
vendored
Normal file
10
node_modules/@ant-design/cssinjs/es/theme/calc/NumCalculator.d.ts
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
import AbstractCalculator from './calculator';
|
||||
export default class NumCalculator extends AbstractCalculator {
|
||||
result: number;
|
||||
constructor(num: number | string | AbstractCalculator);
|
||||
add(num: number | string | AbstractCalculator): this;
|
||||
sub(num: number | string | AbstractCalculator): this;
|
||||
mul(num: number | string | AbstractCalculator): this;
|
||||
div(num: number | string | AbstractCalculator): this;
|
||||
equal(): number;
|
||||
}
|
||||
71
node_modules/@ant-design/cssinjs/es/theme/calc/NumCalculator.js
generated
vendored
Normal file
71
node_modules/@ant-design/cssinjs/es/theme/calc/NumCalculator.js
generated
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
||||
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
||||
import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
|
||||
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
||||
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
||||
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
||||
import AbstractCalculator from "./calculator";
|
||||
var NumCalculator = /*#__PURE__*/function (_AbstractCalculator) {
|
||||
_inherits(NumCalculator, _AbstractCalculator);
|
||||
var _super = _createSuper(NumCalculator);
|
||||
function NumCalculator(num) {
|
||||
var _this;
|
||||
_classCallCheck(this, NumCalculator);
|
||||
_this = _super.call(this);
|
||||
_defineProperty(_assertThisInitialized(_this), "result", 0);
|
||||
if (num instanceof NumCalculator) {
|
||||
_this.result = num.result;
|
||||
} else if (typeof num === 'number') {
|
||||
_this.result = num;
|
||||
}
|
||||
return _this;
|
||||
}
|
||||
_createClass(NumCalculator, [{
|
||||
key: "add",
|
||||
value: function add(num) {
|
||||
if (num instanceof NumCalculator) {
|
||||
this.result += num.result;
|
||||
} else if (typeof num === 'number') {
|
||||
this.result += num;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
}, {
|
||||
key: "sub",
|
||||
value: function sub(num) {
|
||||
if (num instanceof NumCalculator) {
|
||||
this.result -= num.result;
|
||||
} else if (typeof num === 'number') {
|
||||
this.result -= num;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
}, {
|
||||
key: "mul",
|
||||
value: function mul(num) {
|
||||
if (num instanceof NumCalculator) {
|
||||
this.result *= num.result;
|
||||
} else if (typeof num === 'number') {
|
||||
this.result *= num;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
}, {
|
||||
key: "div",
|
||||
value: function div(num) {
|
||||
if (num instanceof NumCalculator) {
|
||||
this.result /= num.result;
|
||||
} else if (typeof num === 'number') {
|
||||
this.result /= num;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
}, {
|
||||
key: "equal",
|
||||
value: function equal() {
|
||||
return this.result;
|
||||
}
|
||||
}]);
|
||||
return NumCalculator;
|
||||
}(AbstractCalculator);
|
||||
export { NumCalculator as default };
|
||||
30
node_modules/@ant-design/cssinjs/es/theme/calc/calculator.d.ts
generated
vendored
Normal file
30
node_modules/@ant-design/cssinjs/es/theme/calc/calculator.d.ts
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
declare abstract class AbstractCalculator {
|
||||
/**
|
||||
* @descCN 计算两数的和,例如:1 + 2
|
||||
* @descEN Calculate the sum of two numbers, e.g. 1 + 2
|
||||
*/
|
||||
abstract add(num: number | string | AbstractCalculator): this;
|
||||
/**
|
||||
* @descCN 计算两数的差,例如:1 - 2
|
||||
* @descEN Calculate the difference between two numbers, e.g. 1 - 2
|
||||
*/
|
||||
abstract sub(num: number | string | AbstractCalculator): this;
|
||||
/**
|
||||
* @descCN 计算两数的积,例如:1 * 2
|
||||
* @descEN Calculate the product of two numbers, e.g. 1 * 2
|
||||
*/
|
||||
abstract mul(num: number | string | AbstractCalculator): this;
|
||||
/**
|
||||
* @descCN 计算两数的商,例如:1 / 2
|
||||
* @descEN Calculate the quotient of two numbers, e.g. 1 / 2
|
||||
*/
|
||||
abstract div(num: number | string | AbstractCalculator): this;
|
||||
/**
|
||||
* @descCN 获取计算结果
|
||||
* @descEN Get the calculation result
|
||||
*/
|
||||
abstract equal(options?: {
|
||||
unit?: boolean;
|
||||
}): string | number;
|
||||
}
|
||||
export default AbstractCalculator;
|
||||
6
node_modules/@ant-design/cssinjs/es/theme/calc/calculator.js
generated
vendored
Normal file
6
node_modules/@ant-design/cssinjs/es/theme/calc/calculator.js
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
||||
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
||||
var AbstractCalculator = /*#__PURE__*/_createClass(function AbstractCalculator() {
|
||||
_classCallCheck(this, AbstractCalculator);
|
||||
});
|
||||
export default AbstractCalculator;
|
||||
5
node_modules/@ant-design/cssinjs/es/theme/calc/index.d.ts
generated
vendored
Normal file
5
node_modules/@ant-design/cssinjs/es/theme/calc/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
import type AbstractCalculator from './calculator';
|
||||
import CSSCalculator from './CSSCalculator';
|
||||
import NumCalculator from './NumCalculator';
|
||||
declare const genCalc: (type: 'css' | 'js', unitlessCssVar: Set<string>) => (num: number | string | AbstractCalculator) => CSSCalculator | NumCalculator;
|
||||
export default genCalc;
|
||||
9
node_modules/@ant-design/cssinjs/es/theme/calc/index.js
generated
vendored
Normal file
9
node_modules/@ant-design/cssinjs/es/theme/calc/index.js
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
import CSSCalculator from "./CSSCalculator";
|
||||
import NumCalculator from "./NumCalculator";
|
||||
var genCalc = function genCalc(type, unitlessCssVar) {
|
||||
var Calculator = type === 'css' ? CSSCalculator : NumCalculator;
|
||||
return function (num) {
|
||||
return new Calculator(num, unitlessCssVar);
|
||||
};
|
||||
};
|
||||
export default genCalc;
|
||||
6
node_modules/@ant-design/cssinjs/es/theme/createTheme.d.ts
generated
vendored
Normal file
6
node_modules/@ant-design/cssinjs/es/theme/createTheme.d.ts
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
import Theme from './Theme';
|
||||
import type { DerivativeFunc, TokenType } from './interface';
|
||||
/**
|
||||
* Same as new Theme, but will always return same one if `derivative` not changed.
|
||||
*/
|
||||
export default function createTheme<DesignToken extends TokenType, DerivativeToken extends TokenType>(derivatives: DerivativeFunc<DesignToken, DerivativeToken>[] | DerivativeFunc<DesignToken, DerivativeToken>): Theme<any, any>;
|
||||
17
node_modules/@ant-design/cssinjs/es/theme/createTheme.js
generated
vendored
Normal file
17
node_modules/@ant-design/cssinjs/es/theme/createTheme.js
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
import ThemeCache from "./ThemeCache";
|
||||
import Theme from "./Theme";
|
||||
var cacheThemes = new ThemeCache();
|
||||
|
||||
/**
|
||||
* Same as new Theme, but will always return same one if `derivative` not changed.
|
||||
*/
|
||||
export default function createTheme(derivatives) {
|
||||
var derivativeArr = Array.isArray(derivatives) ? derivatives : [derivatives];
|
||||
// Create new theme if not exist
|
||||
if (!cacheThemes.has(derivativeArr)) {
|
||||
cacheThemes.set(derivativeArr, new Theme(derivativeArr));
|
||||
}
|
||||
|
||||
// Get theme from cache and return
|
||||
return cacheThemes.get(derivativeArr);
|
||||
}
|
||||
6
node_modules/@ant-design/cssinjs/es/theme/index.d.ts
generated
vendored
Normal file
6
node_modules/@ant-design/cssinjs/es/theme/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
export { default as genCalc } from './calc';
|
||||
export type { default as AbstractCalculator } from './calc/calculator';
|
||||
export { default as createTheme } from './createTheme';
|
||||
export type { DerivativeFunc, TokenType } from './interface';
|
||||
export { default as Theme } from './Theme';
|
||||
export { default as ThemeCache } from './ThemeCache';
|
||||
4
node_modules/@ant-design/cssinjs/es/theme/index.js
generated
vendored
Normal file
4
node_modules/@ant-design/cssinjs/es/theme/index.js
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
export { default as genCalc } from "./calc";
|
||||
export { default as createTheme } from "./createTheme";
|
||||
export { default as Theme } from "./Theme";
|
||||
export { default as ThemeCache } from "./ThemeCache";
|
||||
2
node_modules/@ant-design/cssinjs/es/theme/interface.d.ts
generated
vendored
Normal file
2
node_modules/@ant-design/cssinjs/es/theme/interface.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
export type TokenType = object;
|
||||
export type DerivativeFunc<DesignToken extends TokenType, DerivativeToken extends TokenType> = (designToken: DesignToken, derivativeToken?: DerivativeToken) => DerivativeToken;
|
||||
1
node_modules/@ant-design/cssinjs/es/theme/interface.js
generated
vendored
Normal file
1
node_modules/@ant-design/cssinjs/es/theme/interface.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export {};
|
||||
Reference in New Issue
Block a user