cs
This commit is contained in:
15
node_modules/@ant-design/cssinjs-utils/es/util/calc/CSSCalculator.d.ts
generated
vendored
Normal file
15
node_modules/@ant-design/cssinjs-utils/es/util/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-utils/es/util/calc/CSSCalculator.js
generated
vendored
Normal file
116
node_modules/@ant-design/cssinjs-utils/es/util/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 };
|
||||
11
node_modules/@ant-design/cssinjs-utils/es/util/calc/NumCalculator.d.ts
generated
vendored
Normal file
11
node_modules/@ant-design/cssinjs-utils/es/util/calc/NumCalculator.d.ts
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
import AbstractCalculator from './calculator';
|
||||
declare 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;
|
||||
}
|
||||
export default NumCalculator;
|
||||
71
node_modules/@ant-design/cssinjs-utils/es/util/calc/NumCalculator.js
generated
vendored
Normal file
71
node_modules/@ant-design/cssinjs-utils/es/util/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 default NumCalculator;
|
||||
30
node_modules/@ant-design/cssinjs-utils/es/util/calc/calculator.d.ts
generated
vendored
Normal file
30
node_modules/@ant-design/cssinjs-utils/es/util/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-utils/es/util/calc/calculator.js
generated
vendored
Normal file
6
node_modules/@ant-design/cssinjs-utils/es/util/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-utils/es/util/calc/index.d.ts
generated
vendored
Normal file
5
node_modules/@ant-design/cssinjs-utils/es/util/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-utils/es/util/calc/index.js
generated
vendored
Normal file
9
node_modules/@ant-design/cssinjs-utils/es/util/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;
|
||||
116
node_modules/@ant-design/cssinjs-utils/es/util/genStyleUtils.d.ts
generated
vendored
Normal file
116
node_modules/@ant-design/cssinjs-utils/es/util/genStyleUtils.d.ts
generated
vendored
Normal file
@@ -0,0 +1,116 @@
|
||||
import React from 'react';
|
||||
import type { CSSInterpolation, CSSObject, TokenType } from '@ant-design/cssinjs';
|
||||
import { useStyleRegister } from '@ant-design/cssinjs';
|
||||
import type { ComponentTokenKey, GlobalTokenWithComponent, TokenMap, TokenMapKey, UseComponentStyleResult } from '../interface';
|
||||
import type AbstractCalculator from './calc/calculator';
|
||||
import type { UseCSP } from '../hooks/useCSP';
|
||||
import type { UsePrefix } from '../hooks/usePrefix';
|
||||
import type { UseToken } from '../hooks/useToken';
|
||||
type LayerConfig = Parameters<typeof useStyleRegister>[0]['layer'];
|
||||
export interface StyleInfo {
|
||||
hashId: string;
|
||||
prefixCls: string;
|
||||
rootPrefixCls: string;
|
||||
iconPrefixCls: string;
|
||||
}
|
||||
export type CSSUtil = {
|
||||
calc: (number: any) => AbstractCalculator;
|
||||
max: (...values: (number | string)[]) => number | string;
|
||||
min: (...values: (number | string)[]) => number | string;
|
||||
};
|
||||
export type TokenWithCommonCls<T> = T & {
|
||||
/** Wrap component class with `.` prefix */
|
||||
componentCls: string;
|
||||
/** Origin prefix which do not have `.` prefix */
|
||||
prefixCls: string;
|
||||
/** Wrap icon class with `.` prefix */
|
||||
iconCls: string;
|
||||
/** Wrap ant prefixCls class with `.` prefix */
|
||||
antCls: string;
|
||||
} & CSSUtil;
|
||||
export type FullToken<CompTokenMap extends TokenMap, AliasToken extends TokenType, C extends TokenMapKey<CompTokenMap>> = TokenWithCommonCls<GlobalTokenWithComponent<CompTokenMap, AliasToken, C>>;
|
||||
export type GenStyleFn<CompTokenMap extends TokenMap, AliasToken extends TokenType, C extends TokenMapKey<CompTokenMap>> = (token: FullToken<CompTokenMap, AliasToken, C>, info: StyleInfo) => CSSInterpolation;
|
||||
export type GetDefaultTokenFn<CompTokenMap extends TokenMap, AliasToken extends TokenType, C extends TokenMapKey<CompTokenMap>> = (token: AliasToken & Partial<CompTokenMap[C]>) => CompTokenMap[C];
|
||||
export type GetDefaultToken<CompTokenMap extends TokenMap, AliasToken extends TokenType, C extends TokenMapKey<CompTokenMap>> = null | CompTokenMap[C] | GetDefaultTokenFn<CompTokenMap, AliasToken, C>;
|
||||
export interface SubStyleComponentProps {
|
||||
prefixCls: string;
|
||||
rootCls?: string;
|
||||
}
|
||||
export type CSSVarRegisterProps = {
|
||||
rootCls: string;
|
||||
component: string;
|
||||
cssVar: {
|
||||
prefix?: string;
|
||||
key?: string;
|
||||
};
|
||||
};
|
||||
type GetResetStylesConfig = {
|
||||
prefix: ReturnType<UsePrefix>;
|
||||
csp: ReturnType<UseCSP>;
|
||||
};
|
||||
export type GetResetStyles<AliasToken extends TokenType> = (token: AliasToken, config?: GetResetStylesConfig) => CSSInterpolation;
|
||||
export type GetCompUnitless<CompTokenMap extends TokenMap, AliasToken extends TokenType> = <C extends TokenMapKey<CompTokenMap>>(component: C | [C, string]) => Partial<Record<ComponentTokenKey<CompTokenMap, AliasToken, C>, boolean>>;
|
||||
declare function genStyleUtils<CompTokenMap extends TokenMap, AliasToken extends TokenType, DesignToken extends TokenType>(config: {
|
||||
usePrefix: UsePrefix;
|
||||
useToken: UseToken<CompTokenMap, AliasToken, DesignToken>;
|
||||
useCSP?: UseCSP;
|
||||
getResetStyles?: GetResetStyles<AliasToken>;
|
||||
getCommonStyle?: (token: AliasToken, componentPrefixCls: string, rootCls?: string, resetFont?: boolean) => CSSObject;
|
||||
getCompUnitless?: GetCompUnitless<CompTokenMap, AliasToken>;
|
||||
layer?: LayerConfig;
|
||||
}): {
|
||||
genStyleHooks: <C extends TokenMapKey<CompTokenMap>>(component: C | [C, string], styleFn: GenStyleFn<CompTokenMap, AliasToken, C>, getDefaultToken?: GetDefaultToken<CompTokenMap, AliasToken, C>, options?: {
|
||||
resetStyle?: boolean;
|
||||
resetFont?: boolean;
|
||||
deprecatedTokens?: [keyof Exclude<import("../interface").OverrideTokenMap<CompTokenMap, AliasToken>[C], undefined>, keyof Exclude<import("../interface").OverrideTokenMap<CompTokenMap, AliasToken>[C], undefined>][];
|
||||
/**
|
||||
* Component tokens that do not need unit.
|
||||
*/
|
||||
unitless?: Partial<Record<keyof Exclude<import("../interface").OverrideTokenMap<CompTokenMap, AliasToken>[C], undefined>, boolean>>;
|
||||
/**
|
||||
* Only use component style in client side. Ignore in SSR.
|
||||
*/
|
||||
clientOnly?: boolean;
|
||||
/**
|
||||
* Set order of component style.
|
||||
* @default -999
|
||||
*/
|
||||
order?: number;
|
||||
/**
|
||||
* Whether generate styles
|
||||
* @default true
|
||||
*/
|
||||
injectStyle?: boolean;
|
||||
}) => (prefixCls: string, rootCls?: string) => readonly [(node: React.ReactElement) => React.ReactElement, string, string];
|
||||
genSubStyleComponent: <C_1 extends TokenMapKey<CompTokenMap>>(componentName: C_1 | [C_1, string], styleFn: GenStyleFn<CompTokenMap, AliasToken, C_1>, getDefaultToken?: GetDefaultToken<CompTokenMap, AliasToken, C_1>, options?: {
|
||||
resetStyle?: boolean;
|
||||
resetFont?: boolean;
|
||||
deprecatedTokens?: [keyof Exclude<import("../interface").OverrideTokenMap<CompTokenMap, AliasToken>[C_1], undefined>, keyof Exclude<import("../interface").OverrideTokenMap<CompTokenMap, AliasToken>[C_1], undefined>][];
|
||||
/**
|
||||
* Only use component style in client side. Ignore in SSR.
|
||||
*/
|
||||
clientOnly?: boolean;
|
||||
/**
|
||||
* Set order of component style. Default is -999.
|
||||
*/
|
||||
order?: number;
|
||||
injectStyle?: boolean;
|
||||
unitless?: Partial<Record<keyof Exclude<import("../interface").OverrideTokenMap<CompTokenMap, AliasToken>[C_1], undefined>, boolean>>;
|
||||
}) => React.FunctionComponent<SubStyleComponentProps>;
|
||||
genComponentStyleHook: <C_2 extends TokenMapKey<CompTokenMap>>(componentName: C_2 | [C_2, string], styleFn: GenStyleFn<CompTokenMap, AliasToken, C_2>, getDefaultToken?: GetDefaultToken<CompTokenMap, AliasToken, C_2>, options?: {
|
||||
resetStyle?: boolean;
|
||||
resetFont?: boolean;
|
||||
deprecatedTokens?: [keyof Exclude<import("../interface").OverrideTokenMap<CompTokenMap, AliasToken>[C_2], undefined>, keyof Exclude<import("../interface").OverrideTokenMap<CompTokenMap, AliasToken>[C_2], undefined>][];
|
||||
/**
|
||||
* Only use component style in client side. Ignore in SSR.
|
||||
*/
|
||||
clientOnly?: boolean;
|
||||
/**
|
||||
* Set order of component style. Default is -999.
|
||||
*/
|
||||
order?: number;
|
||||
injectStyle?: boolean;
|
||||
unitless?: Partial<Record<keyof Exclude<import("../interface").OverrideTokenMap<CompTokenMap, AliasToken>[C_2], undefined>, boolean>>;
|
||||
}) => (prefixCls: string, rootCls?: string) => UseComponentStyleResult;
|
||||
};
|
||||
export default genStyleUtils;
|
||||
245
node_modules/@ant-design/cssinjs-utils/es/util/genStyleUtils.js
generated
vendored
Normal file
245
node_modules/@ant-design/cssinjs-utils/es/util/genStyleUtils.js
generated
vendored
Normal file
@@ -0,0 +1,245 @@
|
||||
import _typeof from "@babel/runtime/helpers/esm/typeof";
|
||||
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
||||
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
||||
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
||||
import React from 'react';
|
||||
import { token2CSSVar, useCSSVarRegister, useStyleRegister } from '@ant-design/cssinjs';
|
||||
import genCalc from "./calc";
|
||||
import getCompVarPrefix from "./getCompVarPrefix";
|
||||
import getComponentToken from "./getComponentToken";
|
||||
import getDefaultComponentToken from "./getDefaultComponentToken";
|
||||
import genMaxMin from "./maxmin";
|
||||
import statisticToken, { merge as mergeToken } from "./statistic";
|
||||
import useUniqueMemo from "../_util/hooks/useUniqueMemo";
|
||||
import useDefaultCSP from "../hooks/useCSP";
|
||||
function genStyleUtils(config) {
|
||||
// Dependency inversion for preparing basic config.
|
||||
var _config$useCSP = config.useCSP,
|
||||
useCSP = _config$useCSP === void 0 ? useDefaultCSP : _config$useCSP,
|
||||
useToken = config.useToken,
|
||||
usePrefix = config.usePrefix,
|
||||
getResetStyles = config.getResetStyles,
|
||||
getCommonStyle = config.getCommonStyle,
|
||||
getCompUnitless = config.getCompUnitless;
|
||||
function genStyleHooks(component, styleFn, getDefaultToken, options) {
|
||||
var componentName = Array.isArray(component) ? component[0] : component;
|
||||
function prefixToken(key) {
|
||||
return "".concat(String(componentName)).concat(key.slice(0, 1).toUpperCase()).concat(key.slice(1));
|
||||
}
|
||||
|
||||
// Fill unitless
|
||||
var originUnitless = (options === null || options === void 0 ? void 0 : options.unitless) || {};
|
||||
var originCompUnitless = typeof getCompUnitless === 'function' ? getCompUnitless(component) : {};
|
||||
var compUnitless = _objectSpread(_objectSpread({}, originCompUnitless), {}, _defineProperty({}, prefixToken('zIndexPopup'), true));
|
||||
Object.keys(originUnitless).forEach(function (key) {
|
||||
compUnitless[prefixToken(key)] = originUnitless[key];
|
||||
});
|
||||
|
||||
// Options
|
||||
var mergedOptions = _objectSpread(_objectSpread({}, options), {}, {
|
||||
unitless: compUnitless,
|
||||
prefixToken: prefixToken
|
||||
});
|
||||
|
||||
// Hooks
|
||||
var useStyle = genComponentStyleHook(component, styleFn, getDefaultToken, mergedOptions);
|
||||
var useCSSVar = genCSSVarRegister(componentName, getDefaultToken, mergedOptions);
|
||||
return function (prefixCls) {
|
||||
var rootCls = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : prefixCls;
|
||||
var _useStyle = useStyle(prefixCls, rootCls),
|
||||
_useStyle2 = _slicedToArray(_useStyle, 2),
|
||||
hashId = _useStyle2[1];
|
||||
var _useCSSVar = useCSSVar(rootCls),
|
||||
_useCSSVar2 = _slicedToArray(_useCSSVar, 2),
|
||||
wrapCSSVar = _useCSSVar2[0],
|
||||
cssVarCls = _useCSSVar2[1];
|
||||
return [wrapCSSVar, hashId, cssVarCls];
|
||||
};
|
||||
}
|
||||
function genCSSVarRegister(component, getDefaultToken, options) {
|
||||
var compUnitless = options.unitless,
|
||||
_options$injectStyle = options.injectStyle,
|
||||
injectStyle = _options$injectStyle === void 0 ? true : _options$injectStyle,
|
||||
prefixToken = options.prefixToken,
|
||||
ignore = options.ignore;
|
||||
var CSSVarRegister = function CSSVarRegister(_ref) {
|
||||
var rootCls = _ref.rootCls,
|
||||
_ref$cssVar = _ref.cssVar,
|
||||
cssVar = _ref$cssVar === void 0 ? {} : _ref$cssVar;
|
||||
var _useToken = useToken(),
|
||||
realToken = _useToken.realToken;
|
||||
useCSSVarRegister({
|
||||
path: [component],
|
||||
prefix: cssVar.prefix,
|
||||
key: cssVar.key,
|
||||
unitless: compUnitless,
|
||||
ignore: ignore,
|
||||
token: realToken,
|
||||
scope: rootCls
|
||||
}, function () {
|
||||
var defaultToken = getDefaultComponentToken(component, realToken, getDefaultToken);
|
||||
var componentToken = getComponentToken(component, realToken, defaultToken, {
|
||||
deprecatedTokens: options === null || options === void 0 ? void 0 : options.deprecatedTokens
|
||||
});
|
||||
Object.keys(defaultToken).forEach(function (key) {
|
||||
componentToken[prefixToken(key)] = componentToken[key];
|
||||
delete componentToken[key];
|
||||
});
|
||||
return componentToken;
|
||||
});
|
||||
return null;
|
||||
};
|
||||
var useCSSVar = function useCSSVar(rootCls) {
|
||||
var _useToken2 = useToken(),
|
||||
cssVar = _useToken2.cssVar;
|
||||
return [function (node) {
|
||||
return injectStyle && cssVar ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(CSSVarRegister, {
|
||||
rootCls: rootCls,
|
||||
cssVar: cssVar,
|
||||
component: component
|
||||
}), node) : node;
|
||||
}, cssVar === null || cssVar === void 0 ? void 0 : cssVar.key];
|
||||
};
|
||||
return useCSSVar;
|
||||
}
|
||||
function genComponentStyleHook(componentName, styleFn, getDefaultToken) {
|
||||
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
||||
var cells = Array.isArray(componentName) ? componentName : [componentName, componentName];
|
||||
var _cells = _slicedToArray(cells, 1),
|
||||
component = _cells[0];
|
||||
var concatComponent = cells.join('-');
|
||||
var mergedLayer = config.layer || {
|
||||
name: 'antd'
|
||||
};
|
||||
|
||||
// Return new style hook
|
||||
return function (prefixCls) {
|
||||
var rootCls = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : prefixCls;
|
||||
var _useToken3 = useToken(),
|
||||
theme = _useToken3.theme,
|
||||
realToken = _useToken3.realToken,
|
||||
hashId = _useToken3.hashId,
|
||||
token = _useToken3.token,
|
||||
cssVar = _useToken3.cssVar;
|
||||
var _usePrefix = usePrefix(),
|
||||
rootPrefixCls = _usePrefix.rootPrefixCls,
|
||||
iconPrefixCls = _usePrefix.iconPrefixCls;
|
||||
var csp = useCSP();
|
||||
var type = cssVar ? 'css' : 'js';
|
||||
|
||||
// Use unique memo to share the result across all instances
|
||||
var calc = useUniqueMemo(function () {
|
||||
var unitlessCssVar = new Set();
|
||||
if (cssVar) {
|
||||
Object.keys(options.unitless || {}).forEach(function (key) {
|
||||
// Some component proxy the AliasToken (e.g. Image) and some not (e.g. Modal)
|
||||
// We should both pass in `unitlessCssVar` to make sure the CSSVar can be unitless.
|
||||
unitlessCssVar.add(token2CSSVar(key, cssVar.prefix));
|
||||
unitlessCssVar.add(token2CSSVar(key, getCompVarPrefix(component, cssVar.prefix)));
|
||||
});
|
||||
}
|
||||
return genCalc(type, unitlessCssVar);
|
||||
}, [type, component, cssVar === null || cssVar === void 0 ? void 0 : cssVar.prefix]);
|
||||
var _genMaxMin = genMaxMin(type),
|
||||
max = _genMaxMin.max,
|
||||
min = _genMaxMin.min;
|
||||
|
||||
// Shared config
|
||||
var sharedConfig = {
|
||||
theme: theme,
|
||||
token: token,
|
||||
hashId: hashId,
|
||||
nonce: function nonce() {
|
||||
return csp.nonce;
|
||||
},
|
||||
clientOnly: options.clientOnly,
|
||||
layer: mergedLayer,
|
||||
// antd is always at top of styles
|
||||
order: options.order || -999
|
||||
};
|
||||
|
||||
// This if statement is safe, as it will only be used if the generator has the function. It's not dynamic.
|
||||
if (typeof getResetStyles === 'function') {
|
||||
// Generate style for all need reset tags.
|
||||
useStyleRegister(_objectSpread(_objectSpread({}, sharedConfig), {}, {
|
||||
clientOnly: false,
|
||||
path: ['Shared', rootPrefixCls]
|
||||
}), function () {
|
||||
return getResetStyles(token, {
|
||||
prefix: {
|
||||
rootPrefixCls: rootPrefixCls,
|
||||
iconPrefixCls: iconPrefixCls
|
||||
},
|
||||
csp: csp
|
||||
});
|
||||
});
|
||||
}
|
||||
var wrapSSR = useStyleRegister(_objectSpread(_objectSpread({}, sharedConfig), {}, {
|
||||
path: [concatComponent, prefixCls, iconPrefixCls]
|
||||
}), function () {
|
||||
if (options.injectStyle === false) {
|
||||
return [];
|
||||
}
|
||||
var _statisticToken = statisticToken(token),
|
||||
proxyToken = _statisticToken.token,
|
||||
flush = _statisticToken.flush;
|
||||
var defaultComponentToken = getDefaultComponentToken(component, realToken, getDefaultToken);
|
||||
var componentCls = ".".concat(prefixCls);
|
||||
var componentToken = getComponentToken(component, realToken, defaultComponentToken, {
|
||||
deprecatedTokens: options.deprecatedTokens
|
||||
});
|
||||
if (cssVar && defaultComponentToken && _typeof(defaultComponentToken) === 'object') {
|
||||
Object.keys(defaultComponentToken).forEach(function (key) {
|
||||
defaultComponentToken[key] = "var(".concat(token2CSSVar(key, getCompVarPrefix(component, cssVar.prefix)), ")");
|
||||
});
|
||||
}
|
||||
var mergedToken = mergeToken(proxyToken, {
|
||||
componentCls: componentCls,
|
||||
prefixCls: prefixCls,
|
||||
iconCls: ".".concat(iconPrefixCls),
|
||||
antCls: ".".concat(rootPrefixCls),
|
||||
calc: calc,
|
||||
// @ts-ignore
|
||||
max: max,
|
||||
// @ts-ignore
|
||||
min: min
|
||||
}, cssVar ? defaultComponentToken : componentToken);
|
||||
var styleInterpolation = styleFn(mergedToken, {
|
||||
hashId: hashId,
|
||||
prefixCls: prefixCls,
|
||||
rootPrefixCls: rootPrefixCls,
|
||||
iconPrefixCls: iconPrefixCls
|
||||
});
|
||||
flush(component, componentToken);
|
||||
var commonStyle = typeof getCommonStyle === 'function' ? getCommonStyle(mergedToken, prefixCls, rootCls, options.resetFont) : null;
|
||||
return [options.resetStyle === false ? null : commonStyle, styleInterpolation];
|
||||
});
|
||||
return [wrapSSR, hashId];
|
||||
};
|
||||
}
|
||||
function genSubStyleComponent(componentName, styleFn, getDefaultToken) {
|
||||
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
||||
var useStyle = genComponentStyleHook(componentName, styleFn, getDefaultToken, _objectSpread({
|
||||
resetStyle: false,
|
||||
// Sub Style should default after root one
|
||||
order: -998
|
||||
}, options));
|
||||
var StyledComponent = function StyledComponent(_ref2) {
|
||||
var prefixCls = _ref2.prefixCls,
|
||||
_ref2$rootCls = _ref2.rootCls,
|
||||
rootCls = _ref2$rootCls === void 0 ? prefixCls : _ref2$rootCls;
|
||||
useStyle(prefixCls, rootCls);
|
||||
return null;
|
||||
};
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
StyledComponent.displayName = "SubStyle_".concat(String(Array.isArray(componentName) ? componentName.join('.') : componentName));
|
||||
}
|
||||
return StyledComponent;
|
||||
}
|
||||
return {
|
||||
genStyleHooks: genStyleHooks,
|
||||
genSubStyleComponent: genSubStyleComponent,
|
||||
genComponentStyleHook: genComponentStyleHook
|
||||
};
|
||||
}
|
||||
export default genStyleUtils;
|
||||
2
node_modules/@ant-design/cssinjs-utils/es/util/getCompVarPrefix.d.ts
generated
vendored
Normal file
2
node_modules/@ant-design/cssinjs-utils/es/util/getCompVarPrefix.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
declare const getCompVarPrefix: (component: string, prefix?: string) => string;
|
||||
export default getCompVarPrefix;
|
||||
4
node_modules/@ant-design/cssinjs-utils/es/util/getCompVarPrefix.js
generated
vendored
Normal file
4
node_modules/@ant-design/cssinjs-utils/es/util/getCompVarPrefix.js
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
var getCompVarPrefix = function getCompVarPrefix(component, prefix) {
|
||||
return "".concat([prefix, component.replace(/([A-Z]+)([A-Z][a-z]+)/g, '$1-$2').replace(/([a-z])([A-Z])/g, '$1-$2')].filter(Boolean).join('-'));
|
||||
};
|
||||
export default getCompVarPrefix;
|
||||
9
node_modules/@ant-design/cssinjs-utils/es/util/getComponentToken.d.ts
generated
vendored
Normal file
9
node_modules/@ant-design/cssinjs-utils/es/util/getComponentToken.d.ts
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
import type { TokenMap, TokenMapKey, ComponentTokenKey, GlobalToken } from '../interface';
|
||||
import type { TokenType } from '@ant-design/cssinjs';
|
||||
declare function getComponentToken<CompTokenMap extends TokenMap, AliasToken extends TokenType, C extends TokenMapKey<CompTokenMap>>(component: C, token: GlobalToken<CompTokenMap, AliasToken>, defaultToken: CompTokenMap[C], options?: {
|
||||
deprecatedTokens?: [
|
||||
ComponentTokenKey<CompTokenMap, AliasToken, C>,
|
||||
ComponentTokenKey<CompTokenMap, AliasToken, C>
|
||||
][];
|
||||
}): any;
|
||||
export default getComponentToken;
|
||||
33
node_modules/@ant-design/cssinjs-utils/es/util/getComponentToken.js
generated
vendored
Normal file
33
node_modules/@ant-design/cssinjs-utils/es/util/getComponentToken.js
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
||||
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
||||
import { warning } from 'rc-util';
|
||||
function getComponentToken(component, token, defaultToken, options) {
|
||||
var customToken = _objectSpread({}, token[component]);
|
||||
if (options !== null && options !== void 0 && options.deprecatedTokens) {
|
||||
var deprecatedTokens = options.deprecatedTokens;
|
||||
deprecatedTokens.forEach(function (_ref) {
|
||||
var _ref2 = _slicedToArray(_ref, 2),
|
||||
oldTokenKey = _ref2[0],
|
||||
newTokenKey = _ref2[1];
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
warning(!(customToken !== null && customToken !== void 0 && customToken[oldTokenKey]), "Component Token `".concat(String(oldTokenKey), "` of ").concat(String(component), " is deprecated. Please use `").concat(String(newTokenKey), "` instead."));
|
||||
}
|
||||
|
||||
// Should wrap with `if` clause, or there will be `undefined` in object.
|
||||
if (customToken !== null && customToken !== void 0 && customToken[oldTokenKey] || customToken !== null && customToken !== void 0 && customToken[newTokenKey]) {
|
||||
var _customToken$newToken;
|
||||
(_customToken$newToken = customToken[newTokenKey]) !== null && _customToken$newToken !== void 0 ? _customToken$newToken : customToken[newTokenKey] = customToken === null || customToken === void 0 ? void 0 : customToken[oldTokenKey];
|
||||
}
|
||||
});
|
||||
}
|
||||
var mergedToken = _objectSpread(_objectSpread({}, defaultToken), customToken);
|
||||
|
||||
// Remove same value as global token to minimize size
|
||||
Object.keys(mergedToken).forEach(function (key) {
|
||||
if (mergedToken[key] === token[key]) {
|
||||
delete mergedToken[key];
|
||||
}
|
||||
});
|
||||
return mergedToken;
|
||||
}
|
||||
export default getComponentToken;
|
||||
5
node_modules/@ant-design/cssinjs-utils/es/util/getDefaultComponentToken.d.ts
generated
vendored
Normal file
5
node_modules/@ant-design/cssinjs-utils/es/util/getDefaultComponentToken.d.ts
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
import type { TokenType } from '@ant-design/cssinjs';
|
||||
import type { GetDefaultToken } from './genStyleUtils';
|
||||
import type { GlobalToken, TokenMap, TokenMapKey } from '../interface';
|
||||
declare function getDefaultComponentToken<CompTokenMap extends TokenMap, AliasToken extends TokenType, C extends TokenMapKey<CompTokenMap>>(component: C, token: GlobalToken<CompTokenMap, AliasToken>, getDefaultToken: GetDefaultToken<CompTokenMap, AliasToken, C>): any;
|
||||
export default getDefaultComponentToken;
|
||||
9
node_modules/@ant-design/cssinjs-utils/es/util/getDefaultComponentToken.js
generated
vendored
Normal file
9
node_modules/@ant-design/cssinjs-utils/es/util/getDefaultComponentToken.js
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
import { merge as mergeToken } from "./statistic";
|
||||
function getDefaultComponentToken(component, token, getDefaultToken) {
|
||||
if (typeof getDefaultToken === 'function') {
|
||||
var _token$component;
|
||||
return getDefaultToken(mergeToken(token, (_token$component = token[component]) !== null && _token$component !== void 0 ? _token$component : {}));
|
||||
}
|
||||
return getDefaultToken !== null && getDefaultToken !== void 0 ? getDefaultToken : {};
|
||||
}
|
||||
export default getDefaultComponentToken;
|
||||
8
node_modules/@ant-design/cssinjs-utils/es/util/maxmin.d.ts
generated
vendored
Normal file
8
node_modules/@ant-design/cssinjs-utils/es/util/maxmin.d.ts
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
declare function genMaxMin(type: 'css' | 'js'): {
|
||||
max: (...values: number[]) => number;
|
||||
min: (...values: number[]) => number;
|
||||
} | {
|
||||
max: (...args: (string | number)[]) => string;
|
||||
min: (...args: (string | number)[]) => string;
|
||||
};
|
||||
export default genMaxMin;
|
||||
28
node_modules/@ant-design/cssinjs-utils/es/util/maxmin.js
generated
vendored
Normal file
28
node_modules/@ant-design/cssinjs-utils/es/util/maxmin.js
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
import { unit } from '@ant-design/cssinjs';
|
||||
function genMaxMin(type) {
|
||||
if (type === 'js') {
|
||||
return {
|
||||
max: Math.max,
|
||||
min: Math.min
|
||||
};
|
||||
}
|
||||
return {
|
||||
max: function max() {
|
||||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
||||
args[_key] = arguments[_key];
|
||||
}
|
||||
return "max(".concat(args.map(function (value) {
|
||||
return unit(value);
|
||||
}).join(','), ")");
|
||||
},
|
||||
min: function min() {
|
||||
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
||||
args[_key2] = arguments[_key2];
|
||||
}
|
||||
return "min(".concat(args.map(function (value) {
|
||||
return unit(value);
|
||||
}).join(','), ")");
|
||||
}
|
||||
};
|
||||
}
|
||||
export default genMaxMin;
|
||||
20
node_modules/@ant-design/cssinjs-utils/es/util/statistic.d.ts
generated
vendored
Normal file
20
node_modules/@ant-design/cssinjs-utils/es/util/statistic.d.ts
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
import type { TokenMap } from '../interface';
|
||||
/**
|
||||
* This function will do as `Object.assign` in production. But will use Object.defineProperty:get to
|
||||
* pass all value access in development. To support statistic field usage with alias token.
|
||||
*/
|
||||
export declare function merge<CompTokenMap extends TokenMap>(...objs: Partial<CompTokenMap>[]): CompTokenMap;
|
||||
/** @internal Internal Usage. Not use in your production. */
|
||||
export declare const statistic: Record<string, {
|
||||
global: string[];
|
||||
component: Record<string, string | number>;
|
||||
}>;
|
||||
/** @internal Internal Usage. Not use in your production. */
|
||||
export declare const _statistic_build_: typeof statistic;
|
||||
/** Statistic token usage case. Should use `merge` function if you do not want spread record. */
|
||||
declare const statisticToken: <CompTokenMap extends TokenMap>(token: CompTokenMap) => {
|
||||
token: CompTokenMap;
|
||||
keys: Set<string>;
|
||||
flush: (componentName: string, componentToken: Record<string, string | number>) => void;
|
||||
};
|
||||
export default statisticToken;
|
||||
78
node_modules/@ant-design/cssinjs-utils/es/util/statistic.js
generated
vendored
Normal file
78
node_modules/@ant-design/cssinjs-utils/es/util/statistic.js
generated
vendored
Normal file
@@ -0,0 +1,78 @@
|
||||
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
||||
import _typeof from "@babel/runtime/helpers/esm/typeof";
|
||||
var enableStatistic = process.env.NODE_ENV !== 'production' || typeof CSSINJS_STATISTIC !== 'undefined';
|
||||
var recording = true;
|
||||
|
||||
/**
|
||||
* This function will do as `Object.assign` in production. But will use Object.defineProperty:get to
|
||||
* pass all value access in development. To support statistic field usage with alias token.
|
||||
*/
|
||||
export function merge() {
|
||||
for (var _len = arguments.length, objs = new Array(_len), _key = 0; _key < _len; _key++) {
|
||||
objs[_key] = arguments[_key];
|
||||
}
|
||||
/* istanbul ignore next */
|
||||
if (!enableStatistic) {
|
||||
return Object.assign.apply(Object, [{}].concat(objs));
|
||||
}
|
||||
recording = false;
|
||||
var ret = {};
|
||||
objs.forEach(function (obj) {
|
||||
if (_typeof(obj) !== 'object') {
|
||||
return;
|
||||
}
|
||||
var keys = Object.keys(obj);
|
||||
keys.forEach(function (key) {
|
||||
Object.defineProperty(ret, key, {
|
||||
configurable: true,
|
||||
enumerable: true,
|
||||
get: function get() {
|
||||
return obj[key];
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
recording = true;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/** @internal Internal Usage. Not use in your production. */
|
||||
export var statistic = {};
|
||||
|
||||
/** @internal Internal Usage. Not use in your production. */
|
||||
export var _statistic_build_ = {};
|
||||
|
||||
/* istanbul ignore next */
|
||||
function noop() {}
|
||||
|
||||
/** Statistic token usage case. Should use `merge` function if you do not want spread record. */
|
||||
var statisticToken = function statisticToken(token) {
|
||||
var tokenKeys;
|
||||
var proxy = token;
|
||||
var flush = noop;
|
||||
if (enableStatistic && typeof Proxy !== 'undefined') {
|
||||
tokenKeys = new Set();
|
||||
proxy = new Proxy(token, {
|
||||
get: function get(obj, prop) {
|
||||
if (recording) {
|
||||
var _tokenKeys;
|
||||
(_tokenKeys = tokenKeys) === null || _tokenKeys === void 0 || _tokenKeys.add(prop);
|
||||
}
|
||||
return obj[prop];
|
||||
}
|
||||
});
|
||||
flush = function flush(componentName, componentToken) {
|
||||
var _statistic$componentN;
|
||||
statistic[componentName] = {
|
||||
global: Array.from(tokenKeys),
|
||||
component: _objectSpread(_objectSpread({}, (_statistic$componentN = statistic[componentName]) === null || _statistic$componentN === void 0 ? void 0 : _statistic$componentN.component), componentToken)
|
||||
};
|
||||
};
|
||||
}
|
||||
return {
|
||||
token: proxy,
|
||||
keys: tokenKeys,
|
||||
flush: flush
|
||||
};
|
||||
};
|
||||
export default statisticToken;
|
||||
Reference in New Issue
Block a user