cs
This commit is contained in:
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;
|
||||
Reference in New Issue
Block a user