cs
This commit is contained in:
18
node_modules/@ant-design/cssinjs/es/Cache.d.ts
generated
vendored
Normal file
18
node_modules/@ant-design/cssinjs/es/Cache.d.ts
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
export type KeyType = string | number;
|
||||
type ValueType = [number, any];
|
||||
/** Connect key with `SPLIT` */
|
||||
export declare function pathKey(keys: KeyType[]): string;
|
||||
declare class Entity {
|
||||
instanceId: string;
|
||||
constructor(instanceId: string);
|
||||
/** @private Internal cache map. Do not access this directly */
|
||||
cache: Map<string, ValueType>;
|
||||
extracted: Set<string>;
|
||||
get(keys: KeyType[]): ValueType | null;
|
||||
/** A fast get cache with `get` concat. */
|
||||
opGet(keyPathStr: string): ValueType | null;
|
||||
update(keys: KeyType[], valueFn: (origin: ValueType | null) => ValueType | null): void;
|
||||
/** A fast get cache with `get` concat. */
|
||||
opUpdate(keyPathStr: string, valueFn: (origin: ValueType | null) => ValueType | null): void;
|
||||
}
|
||||
export default Entity;
|
||||
54
node_modules/@ant-design/cssinjs/es/Cache.js
generated
vendored
Normal file
54
node_modules/@ant-design/cssinjs/es/Cache.js
generated
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
||||
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
||||
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
||||
// [times, realValue]
|
||||
|
||||
var SPLIT = '%';
|
||||
|
||||
/** Connect key with `SPLIT` */
|
||||
export function pathKey(keys) {
|
||||
return keys.join(SPLIT);
|
||||
}
|
||||
var Entity = /*#__PURE__*/function () {
|
||||
function Entity(instanceId) {
|
||||
_classCallCheck(this, Entity);
|
||||
_defineProperty(this, "instanceId", void 0);
|
||||
/** @private Internal cache map. Do not access this directly */
|
||||
_defineProperty(this, "cache", new Map());
|
||||
_defineProperty(this, "extracted", new Set());
|
||||
this.instanceId = instanceId;
|
||||
}
|
||||
_createClass(Entity, [{
|
||||
key: "get",
|
||||
value: function get(keys) {
|
||||
return this.opGet(pathKey(keys));
|
||||
}
|
||||
|
||||
/** A fast get cache with `get` concat. */
|
||||
}, {
|
||||
key: "opGet",
|
||||
value: function opGet(keyPathStr) {
|
||||
return this.cache.get(keyPathStr) || null;
|
||||
}
|
||||
}, {
|
||||
key: "update",
|
||||
value: function update(keys, valueFn) {
|
||||
return this.opUpdate(pathKey(keys), valueFn);
|
||||
}
|
||||
|
||||
/** A fast get cache with `get` concat. */
|
||||
}, {
|
||||
key: "opUpdate",
|
||||
value: function opUpdate(keyPathStr, valueFn) {
|
||||
var prevValue = this.cache.get(keyPathStr);
|
||||
var nextValue = valueFn(prevValue);
|
||||
if (nextValue === null) {
|
||||
this.cache.delete(keyPathStr);
|
||||
} else {
|
||||
this.cache.set(keyPathStr, nextValue);
|
||||
}
|
||||
}
|
||||
}]);
|
||||
return Entity;
|
||||
}();
|
||||
export default Entity;
|
||||
9
node_modules/@ant-design/cssinjs/es/Keyframes.d.ts
generated
vendored
Normal file
9
node_modules/@ant-design/cssinjs/es/Keyframes.d.ts
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
import type { CSSInterpolation } from './hooks/useStyleRegister';
|
||||
declare class Keyframe {
|
||||
private name;
|
||||
style: CSSInterpolation;
|
||||
constructor(name: string, style: CSSInterpolation);
|
||||
getName(hashId?: string): string;
|
||||
_keyframe: boolean;
|
||||
}
|
||||
export default Keyframe;
|
||||
22
node_modules/@ant-design/cssinjs/es/Keyframes.js
generated
vendored
Normal file
22
node_modules/@ant-design/cssinjs/es/Keyframes.js
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
||||
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
||||
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
||||
var Keyframe = /*#__PURE__*/function () {
|
||||
function Keyframe(name, style) {
|
||||
_classCallCheck(this, Keyframe);
|
||||
_defineProperty(this, "name", void 0);
|
||||
_defineProperty(this, "style", void 0);
|
||||
_defineProperty(this, "_keyframe", true);
|
||||
this.name = name;
|
||||
this.style = style;
|
||||
}
|
||||
_createClass(Keyframe, [{
|
||||
key: "getName",
|
||||
value: function getName() {
|
||||
var hashId = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
||||
return hashId ? "".concat(hashId, "-").concat(this.name) : this.name;
|
||||
}
|
||||
}]);
|
||||
return Keyframe;
|
||||
}();
|
||||
export default Keyframe;
|
||||
44
node_modules/@ant-design/cssinjs/es/StyleContext.d.ts
generated
vendored
Normal file
44
node_modules/@ant-design/cssinjs/es/StyleContext.d.ts
generated
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
import * as React from 'react';
|
||||
import CacheEntity from './Cache';
|
||||
import type { Linter } from './linters/interface';
|
||||
import type { Transformer } from './transformers/interface';
|
||||
export declare const ATTR_TOKEN = "data-token-hash";
|
||||
export declare const ATTR_MARK = "data-css-hash";
|
||||
export declare const ATTR_CACHE_PATH = "data-cache-path";
|
||||
export declare const CSS_IN_JS_INSTANCE = "__cssinjs_instance__";
|
||||
export declare function createCache(): CacheEntity;
|
||||
export type HashPriority = 'low' | 'high';
|
||||
export interface StyleContextProps {
|
||||
autoClear?: boolean;
|
||||
/** @private Test only. Not work in production. */
|
||||
mock?: 'server' | 'client';
|
||||
/**
|
||||
* Only set when you need ssr to extract style on you own.
|
||||
* If not provided, it will auto create <style /> on the end of Provider in server side.
|
||||
*/
|
||||
cache: CacheEntity;
|
||||
/** Tell children that this context is default generated context */
|
||||
defaultCache: boolean;
|
||||
/** Use `:where` selector to reduce hashId css selector priority */
|
||||
hashPriority?: HashPriority;
|
||||
/** Tell cssinjs where to inject style in */
|
||||
container?: Element | ShadowRoot;
|
||||
/** Component wil render inline `<style />` for fallback in SSR. Not recommend. */
|
||||
ssrInline?: boolean;
|
||||
/** Transform css before inject in document. Please note that `transformers` do not support dynamic update */
|
||||
transformers?: Transformer[];
|
||||
/**
|
||||
* Linters to lint css before inject in document.
|
||||
* Styles will be linted after transforming.
|
||||
* Please note that `linters` do not support dynamic update.
|
||||
*/
|
||||
linters?: Linter[];
|
||||
/** Wrap css in a layer to avoid global style conflict */
|
||||
layer?: boolean;
|
||||
}
|
||||
declare const StyleContext: React.Context<StyleContextProps>;
|
||||
export type StyleProviderProps = Partial<StyleContextProps> & {
|
||||
children?: React.ReactNode;
|
||||
};
|
||||
export declare const StyleProvider: React.FC<StyleProviderProps>;
|
||||
export default StyleContext;
|
||||
75
node_modules/@ant-design/cssinjs/es/StyleContext.js
generated
vendored
Normal file
75
node_modules/@ant-design/cssinjs/es/StyleContext.js
generated
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
||||
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
||||
var _excluded = ["children"];
|
||||
import useMemo from "rc-util/es/hooks/useMemo";
|
||||
import isEqual from "rc-util/es/isEqual";
|
||||
import * as React from 'react';
|
||||
import CacheEntity from "./Cache";
|
||||
export var ATTR_TOKEN = 'data-token-hash';
|
||||
export var ATTR_MARK = 'data-css-hash';
|
||||
export var ATTR_CACHE_PATH = 'data-cache-path';
|
||||
|
||||
// Mark css-in-js instance in style element
|
||||
export var CSS_IN_JS_INSTANCE = '__cssinjs_instance__';
|
||||
export function createCache() {
|
||||
var cssinjsInstanceId = Math.random().toString(12).slice(2);
|
||||
|
||||
// Tricky SSR: Move all inline style to the head.
|
||||
// PS: We do not recommend tricky mode.
|
||||
if (typeof document !== 'undefined' && document.head && document.body) {
|
||||
var styles = document.body.querySelectorAll("style[".concat(ATTR_MARK, "]")) || [];
|
||||
var firstChild = document.head.firstChild;
|
||||
Array.from(styles).forEach(function (style) {
|
||||
style[CSS_IN_JS_INSTANCE] = style[CSS_IN_JS_INSTANCE] || cssinjsInstanceId;
|
||||
|
||||
// Not force move if no head
|
||||
if (style[CSS_IN_JS_INSTANCE] === cssinjsInstanceId) {
|
||||
document.head.insertBefore(style, firstChild);
|
||||
}
|
||||
});
|
||||
|
||||
// Deduplicate of moved styles
|
||||
var styleHash = {};
|
||||
Array.from(document.querySelectorAll("style[".concat(ATTR_MARK, "]"))).forEach(function (style) {
|
||||
var hash = style.getAttribute(ATTR_MARK);
|
||||
if (styleHash[hash]) {
|
||||
if (style[CSS_IN_JS_INSTANCE] === cssinjsInstanceId) {
|
||||
var _style$parentNode;
|
||||
(_style$parentNode = style.parentNode) === null || _style$parentNode === void 0 || _style$parentNode.removeChild(style);
|
||||
}
|
||||
} else {
|
||||
styleHash[hash] = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
return new CacheEntity(cssinjsInstanceId);
|
||||
}
|
||||
var StyleContext = /*#__PURE__*/React.createContext({
|
||||
hashPriority: 'low',
|
||||
cache: createCache(),
|
||||
defaultCache: true
|
||||
});
|
||||
export var StyleProvider = function StyleProvider(props) {
|
||||
var children = props.children,
|
||||
restProps = _objectWithoutProperties(props, _excluded);
|
||||
var parentContext = React.useContext(StyleContext);
|
||||
var context = useMemo(function () {
|
||||
var mergedContext = _objectSpread({}, parentContext);
|
||||
Object.keys(restProps).forEach(function (key) {
|
||||
var value = restProps[key];
|
||||
if (restProps[key] !== undefined) {
|
||||
mergedContext[key] = value;
|
||||
}
|
||||
});
|
||||
var cache = restProps.cache;
|
||||
mergedContext.cache = mergedContext.cache || createCache();
|
||||
mergedContext.defaultCache = !cache && parentContext.defaultCache;
|
||||
return mergedContext;
|
||||
}, [parentContext, restProps], function (prev, next) {
|
||||
return !isEqual(prev[0], next[0], true) || !isEqual(prev[1], next[1], true);
|
||||
});
|
||||
return /*#__PURE__*/React.createElement(StyleContext.Provider, {
|
||||
value: context
|
||||
}, children);
|
||||
};
|
||||
export default StyleContext;
|
||||
13
node_modules/@ant-design/cssinjs/es/extractStyle.d.ts
generated
vendored
Normal file
13
node_modules/@ant-design/cssinjs/es/extractStyle.d.ts
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
import type Cache from './Cache';
|
||||
declare const ExtractStyleFns: {
|
||||
style: import("./hooks/useGlobalCache").ExtractStyle<[styleStr: string, tokenKey: string, styleId: string, effectStyle: Record<string, string>, clientOnly: boolean | undefined, order: number]>;
|
||||
token: import("./hooks/useGlobalCache").ExtractStyle<[token: any, hashId: string, realToken: any, cssVarStr: string, cssVarKey: string]>;
|
||||
cssVar: import("./hooks/useGlobalCache").ExtractStyle<[cssVarToken: import("./util/css-variables").TokenWithCSSVar<any, Record<string, any>>, cssVarStr: string, styleId: string, cssVarKey: string]>;
|
||||
};
|
||||
type ExtractStyleType = keyof typeof ExtractStyleFns;
|
||||
export default function extractStyle(cache: Cache, options?: boolean | {
|
||||
plain?: boolean;
|
||||
types?: ExtractStyleType | ExtractStyleType[];
|
||||
once?: boolean;
|
||||
}): string;
|
||||
export {};
|
||||
76
node_modules/@ant-design/cssinjs/es/extractStyle.js
generated
vendored
Normal file
76
node_modules/@ant-design/cssinjs/es/extractStyle.js
generated
vendored
Normal file
@@ -0,0 +1,76 @@
|
||||
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
||||
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
||||
import { extract as tokenExtractStyle, TOKEN_PREFIX } from "./hooks/useCacheToken";
|
||||
import { CSS_VAR_PREFIX, extract as cssVarExtractStyle } from "./hooks/useCSSVarRegister";
|
||||
import { extract as styleExtractStyle, STYLE_PREFIX } from "./hooks/useStyleRegister";
|
||||
import { toStyleStr } from "./util";
|
||||
import { ATTR_CACHE_MAP, serialize as serializeCacheMap } from "./util/cacheMapUtil";
|
||||
var ExtractStyleFns = _defineProperty(_defineProperty(_defineProperty({}, STYLE_PREFIX, styleExtractStyle), TOKEN_PREFIX, tokenExtractStyle), CSS_VAR_PREFIX, cssVarExtractStyle);
|
||||
function isNotNull(value) {
|
||||
return value !== null;
|
||||
}
|
||||
export default function extractStyle(cache, options) {
|
||||
var _ref = typeof options === 'boolean' ? {
|
||||
plain: options
|
||||
} : options || {},
|
||||
_ref$plain = _ref.plain,
|
||||
plain = _ref$plain === void 0 ? false : _ref$plain,
|
||||
_ref$types = _ref.types,
|
||||
types = _ref$types === void 0 ? ['style', 'token', 'cssVar'] : _ref$types,
|
||||
_ref$once = _ref.once,
|
||||
once = _ref$once === void 0 ? false : _ref$once;
|
||||
var matchPrefixRegexp = new RegExp("^(".concat((typeof types === 'string' ? [types] : types).join('|'), ")%"));
|
||||
|
||||
// prefix with `style` is used for `useStyleRegister` to cache style context
|
||||
var styleKeys = Array.from(cache.cache.keys()).filter(function (key) {
|
||||
return matchPrefixRegexp.test(key);
|
||||
});
|
||||
|
||||
// Common effect styles like animation
|
||||
var effectStyles = {};
|
||||
|
||||
// Mapping of cachePath to style hash
|
||||
var cachePathMap = {};
|
||||
var styleText = '';
|
||||
styleKeys.map(function (key) {
|
||||
if (once && cache.extracted.has(key)) {
|
||||
return null; // Skip if already extracted
|
||||
}
|
||||
var cachePath = key.replace(matchPrefixRegexp, '').replace(/%/g, '|');
|
||||
var _key$split = key.split('%'),
|
||||
_key$split2 = _slicedToArray(_key$split, 1),
|
||||
prefix = _key$split2[0];
|
||||
var extractFn = ExtractStyleFns[prefix];
|
||||
var extractedStyle = extractFn(cache.cache.get(key)[1], effectStyles, {
|
||||
plain: plain
|
||||
});
|
||||
if (!extractedStyle) {
|
||||
return null;
|
||||
}
|
||||
var _extractedStyle = _slicedToArray(extractedStyle, 3),
|
||||
order = _extractedStyle[0],
|
||||
styleId = _extractedStyle[1],
|
||||
styleStr = _extractedStyle[2];
|
||||
if (key.startsWith('style')) {
|
||||
cachePathMap[cachePath] = styleId;
|
||||
}
|
||||
|
||||
// record that this style has been extracted
|
||||
cache.extracted.add(key);
|
||||
return [order, styleStr];
|
||||
}).filter(isNotNull).sort(function (_ref2, _ref3) {
|
||||
var _ref4 = _slicedToArray(_ref2, 1),
|
||||
o1 = _ref4[0];
|
||||
var _ref5 = _slicedToArray(_ref3, 1),
|
||||
o2 = _ref5[0];
|
||||
return o1 - o2;
|
||||
}).forEach(function (_ref6) {
|
||||
var _ref7 = _slicedToArray(_ref6, 2),
|
||||
style = _ref7[1];
|
||||
styleText += style;
|
||||
});
|
||||
|
||||
// ==================== Fill Cache Path ====================
|
||||
styleText += toStyleStr(".".concat(ATTR_CACHE_MAP, "{content:\"").concat(serializeCacheMap(cachePathMap), "\";}"), undefined, undefined, _defineProperty({}, ATTR_CACHE_MAP, ATTR_CACHE_MAP), plain);
|
||||
return styleText;
|
||||
}
|
||||
20
node_modules/@ant-design/cssinjs/es/hooks/useCSSVarRegister.d.ts
generated
vendored
Normal file
20
node_modules/@ant-design/cssinjs/es/hooks/useCSSVarRegister.d.ts
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
import type { TokenWithCSSVar } from '../util/css-variables';
|
||||
import type { ExtractStyle } from './useGlobalCache';
|
||||
export declare const CSS_VAR_PREFIX = "cssVar";
|
||||
type CSSVarCacheValue<V, T extends Record<string, V> = Record<string, V>> = [
|
||||
cssVarToken: TokenWithCSSVar<V, T>,
|
||||
cssVarStr: string,
|
||||
styleId: string,
|
||||
cssVarKey: string
|
||||
];
|
||||
declare const useCSSVarRegister: <V, T extends Record<string, V>>(config: {
|
||||
path: string[];
|
||||
key: string;
|
||||
prefix?: string;
|
||||
unitless?: Record<string, boolean>;
|
||||
ignore?: Record<string, boolean>;
|
||||
scope?: string;
|
||||
token: any;
|
||||
}, fn: () => T) => CSSVarCacheValue<V, T>;
|
||||
export declare const extract: ExtractStyle<CSSVarCacheValue<any>>;
|
||||
export default useCSSVarRegister;
|
||||
87
node_modules/@ant-design/cssinjs/es/hooks/useCSSVarRegister.js
generated
vendored
Normal file
87
node_modules/@ant-design/cssinjs/es/hooks/useCSSVarRegister.js
generated
vendored
Normal file
@@ -0,0 +1,87 @@
|
||||
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
||||
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
||||
import { removeCSS, updateCSS } from "rc-util/es/Dom/dynamicCSS";
|
||||
import { useContext } from 'react';
|
||||
import StyleContext, { ATTR_MARK, ATTR_TOKEN, CSS_IN_JS_INSTANCE } from "../StyleContext";
|
||||
import { isClientSide, toStyleStr } from "../util";
|
||||
import { transformToken } from "../util/css-variables";
|
||||
import useGlobalCache from "./useGlobalCache";
|
||||
import { uniqueHash } from "./useStyleRegister";
|
||||
export var CSS_VAR_PREFIX = 'cssVar';
|
||||
var useCSSVarRegister = function useCSSVarRegister(config, fn) {
|
||||
var key = config.key,
|
||||
prefix = config.prefix,
|
||||
unitless = config.unitless,
|
||||
ignore = config.ignore,
|
||||
token = config.token,
|
||||
_config$scope = config.scope,
|
||||
scope = _config$scope === void 0 ? '' : _config$scope;
|
||||
var _useContext = useContext(StyleContext),
|
||||
instanceId = _useContext.cache.instanceId,
|
||||
container = _useContext.container;
|
||||
var tokenKey = token._tokenKey;
|
||||
var stylePath = [].concat(_toConsumableArray(config.path), [key, scope, tokenKey]);
|
||||
var cache = useGlobalCache(CSS_VAR_PREFIX, stylePath, function () {
|
||||
var originToken = fn();
|
||||
var _transformToken = transformToken(originToken, key, {
|
||||
prefix: prefix,
|
||||
unitless: unitless,
|
||||
ignore: ignore,
|
||||
scope: scope
|
||||
}),
|
||||
_transformToken2 = _slicedToArray(_transformToken, 2),
|
||||
mergedToken = _transformToken2[0],
|
||||
cssVarsStr = _transformToken2[1];
|
||||
var styleId = uniqueHash(stylePath, cssVarsStr);
|
||||
return [mergedToken, cssVarsStr, styleId, key];
|
||||
}, function (_ref) {
|
||||
var _ref2 = _slicedToArray(_ref, 3),
|
||||
styleId = _ref2[2];
|
||||
if (isClientSide) {
|
||||
removeCSS(styleId, {
|
||||
mark: ATTR_MARK,
|
||||
attachTo: container
|
||||
});
|
||||
}
|
||||
}, function (_ref3) {
|
||||
var _ref4 = _slicedToArray(_ref3, 3),
|
||||
cssVarsStr = _ref4[1],
|
||||
styleId = _ref4[2];
|
||||
if (!cssVarsStr) {
|
||||
return;
|
||||
}
|
||||
var style = updateCSS(cssVarsStr, styleId, {
|
||||
mark: ATTR_MARK,
|
||||
prepend: 'queue',
|
||||
attachTo: container,
|
||||
priority: -999
|
||||
});
|
||||
style[CSS_IN_JS_INSTANCE] = instanceId;
|
||||
|
||||
// Used for `useCacheToken` to remove on batch when token removed
|
||||
style.setAttribute(ATTR_TOKEN, key);
|
||||
});
|
||||
return cache;
|
||||
};
|
||||
export var extract = function extract(cache, effectStyles, options) {
|
||||
var _cache = _slicedToArray(cache, 4),
|
||||
styleStr = _cache[1],
|
||||
styleId = _cache[2],
|
||||
cssVarKey = _cache[3];
|
||||
var _ref5 = options || {},
|
||||
plain = _ref5.plain;
|
||||
if (!styleStr) {
|
||||
return null;
|
||||
}
|
||||
var order = -999;
|
||||
|
||||
// ====================== Style ======================
|
||||
// Used for rc-util
|
||||
var sharedAttrs = {
|
||||
'data-rc-order': 'prependQueue',
|
||||
'data-rc-priority': "".concat(order)
|
||||
};
|
||||
var styleText = toStyleStr(styleStr, cssVarKey, styleId, sharedAttrs, plain);
|
||||
return [order, styleId, styleText];
|
||||
};
|
||||
export default useCSSVarRegister;
|
||||
68
node_modules/@ant-design/cssinjs/es/hooks/useCacheToken.d.ts
generated
vendored
Normal file
68
node_modules/@ant-design/cssinjs/es/hooks/useCacheToken.d.ts
generated
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
import type Theme from '../theme/Theme';
|
||||
import type { ExtractStyle } from './useGlobalCache';
|
||||
export interface Option<DerivativeToken, DesignToken> {
|
||||
/**
|
||||
* Generate token with salt.
|
||||
* This is used to generate different hashId even same derivative token for different version.
|
||||
*/
|
||||
salt?: string;
|
||||
override?: object;
|
||||
/**
|
||||
* Format token as you need. Such as:
|
||||
*
|
||||
* - rename token
|
||||
* - merge token
|
||||
* - delete token
|
||||
*
|
||||
* This should always be the same since it's one time process.
|
||||
* It's ok to useMemo outside but this has better cache strategy.
|
||||
*/
|
||||
formatToken?: (mergedToken: any) => DerivativeToken;
|
||||
/**
|
||||
* Get final token with origin token, override token and theme.
|
||||
* The parameters do not contain formatToken since it's passed by user.
|
||||
* @param origin The original token.
|
||||
* @param override Extra tokens to override.
|
||||
* @param theme Theme instance. Could get derivative token by `theme.getDerivativeToken`
|
||||
*/
|
||||
getComputedToken?: (origin: DesignToken, override: object, theme: Theme<any, any>) => DerivativeToken;
|
||||
/**
|
||||
* Transform token to css variables.
|
||||
*/
|
||||
cssVar?: {
|
||||
/** Prefix for css variables */
|
||||
prefix?: string;
|
||||
/** Tokens that should not be appended with unit */
|
||||
unitless?: Record<string, boolean>;
|
||||
/** Tokens that should not be transformed to css variables */
|
||||
ignore?: Record<string, boolean>;
|
||||
/** Tokens that preserves origin value */
|
||||
preserve?: Record<string, boolean>;
|
||||
/** Key for current theme. Useful for customizing and should be unique */
|
||||
key?: string;
|
||||
};
|
||||
}
|
||||
export declare const getComputedToken: <DerivativeToken = object, DesignToken = DerivativeToken>(originToken: DesignToken, overrideToken: object, theme: Theme<any, any>, format?: ((token: DesignToken) => DerivativeToken) | undefined) => any;
|
||||
export declare const TOKEN_PREFIX = "token";
|
||||
type TokenCacheValue<DerivativeToken> = [
|
||||
token: DerivativeToken & {
|
||||
_tokenKey: string;
|
||||
_themeKey: string;
|
||||
},
|
||||
hashId: string,
|
||||
realToken: DerivativeToken & {
|
||||
_tokenKey: string;
|
||||
},
|
||||
cssVarStr: string,
|
||||
cssVarKey: string
|
||||
];
|
||||
/**
|
||||
* Cache theme derivative token as global shared one
|
||||
* @param theme Theme entity
|
||||
* @param tokens List of tokens, used for cache. Please do not dynamic generate object directly
|
||||
* @param option Additional config
|
||||
* @returns Call Theme.getDerivativeToken(tokenObject) to get token
|
||||
*/
|
||||
export default function useCacheToken<DerivativeToken = object, DesignToken = DerivativeToken>(theme: Theme<any, any>, tokens: Partial<DesignToken>[], option?: Option<DerivativeToken, DesignToken>): TokenCacheValue<DerivativeToken>;
|
||||
export declare const extract: ExtractStyle<TokenCacheValue<any>>;
|
||||
export {};
|
||||
162
node_modules/@ant-design/cssinjs/es/hooks/useCacheToken.js
generated
vendored
Normal file
162
node_modules/@ant-design/cssinjs/es/hooks/useCacheToken.js
generated
vendored
Normal file
@@ -0,0 +1,162 @@
|
||||
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
||||
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
||||
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
||||
import hash from '@emotion/hash';
|
||||
import { updateCSS } from "rc-util/es/Dom/dynamicCSS";
|
||||
import { useContext } from 'react';
|
||||
import StyleContext, { ATTR_MARK, ATTR_TOKEN, CSS_IN_JS_INSTANCE } from "../StyleContext";
|
||||
import { flattenToken, memoResult, token2key, toStyleStr } from "../util";
|
||||
import { transformToken } from "../util/css-variables";
|
||||
import useGlobalCache from "./useGlobalCache";
|
||||
var EMPTY_OVERRIDE = {};
|
||||
|
||||
// Generate different prefix to make user selector break in production env.
|
||||
// This helps developer not to do style override directly on the hash id.
|
||||
var hashPrefix = process.env.NODE_ENV !== 'production' ? 'css-dev-only-do-not-override' : 'css';
|
||||
var tokenKeys = new Map();
|
||||
function recordCleanToken(tokenKey) {
|
||||
tokenKeys.set(tokenKey, (tokenKeys.get(tokenKey) || 0) + 1);
|
||||
}
|
||||
function removeStyleTags(key, instanceId) {
|
||||
if (typeof document !== 'undefined') {
|
||||
var styles = document.querySelectorAll("style[".concat(ATTR_TOKEN, "=\"").concat(key, "\"]"));
|
||||
styles.forEach(function (style) {
|
||||
if (style[CSS_IN_JS_INSTANCE] === instanceId) {
|
||||
var _style$parentNode;
|
||||
(_style$parentNode = style.parentNode) === null || _style$parentNode === void 0 || _style$parentNode.removeChild(style);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
var TOKEN_THRESHOLD = 0;
|
||||
|
||||
// Remove will check current keys first
|
||||
function cleanTokenStyle(tokenKey, instanceId) {
|
||||
tokenKeys.set(tokenKey, (tokenKeys.get(tokenKey) || 0) - 1);
|
||||
var cleanableKeyList = new Set();
|
||||
tokenKeys.forEach(function (value, key) {
|
||||
if (value <= 0) cleanableKeyList.add(key);
|
||||
});
|
||||
|
||||
// Should keep tokens under threshold for not to insert style too often
|
||||
if (tokenKeys.size - cleanableKeyList.size > TOKEN_THRESHOLD) {
|
||||
cleanableKeyList.forEach(function (key) {
|
||||
removeStyleTags(key, instanceId);
|
||||
tokenKeys.delete(key);
|
||||
});
|
||||
}
|
||||
}
|
||||
export var getComputedToken = function getComputedToken(originToken, overrideToken, theme, format) {
|
||||
var derivativeToken = theme.getDerivativeToken(originToken);
|
||||
|
||||
// Merge with override
|
||||
var mergedDerivativeToken = _objectSpread(_objectSpread({}, derivativeToken), overrideToken);
|
||||
|
||||
// Format if needed
|
||||
if (format) {
|
||||
mergedDerivativeToken = format(mergedDerivativeToken);
|
||||
}
|
||||
return mergedDerivativeToken;
|
||||
};
|
||||
export var TOKEN_PREFIX = 'token';
|
||||
/**
|
||||
* Cache theme derivative token as global shared one
|
||||
* @param theme Theme entity
|
||||
* @param tokens List of tokens, used for cache. Please do not dynamic generate object directly
|
||||
* @param option Additional config
|
||||
* @returns Call Theme.getDerivativeToken(tokenObject) to get token
|
||||
*/
|
||||
export default function useCacheToken(theme, tokens) {
|
||||
var option = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
||||
var _useContext = useContext(StyleContext),
|
||||
instanceId = _useContext.cache.instanceId,
|
||||
container = _useContext.container;
|
||||
var _option$salt = option.salt,
|
||||
salt = _option$salt === void 0 ? '' : _option$salt,
|
||||
_option$override = option.override,
|
||||
override = _option$override === void 0 ? EMPTY_OVERRIDE : _option$override,
|
||||
formatToken = option.formatToken,
|
||||
compute = option.getComputedToken,
|
||||
cssVar = option.cssVar;
|
||||
|
||||
// Basic - We do basic cache here
|
||||
var mergedToken = memoResult(function () {
|
||||
return Object.assign.apply(Object, [{}].concat(_toConsumableArray(tokens)));
|
||||
}, tokens);
|
||||
var tokenStr = flattenToken(mergedToken);
|
||||
var overrideTokenStr = flattenToken(override);
|
||||
var cssVarStr = cssVar ? flattenToken(cssVar) : '';
|
||||
var cachedToken = useGlobalCache(TOKEN_PREFIX, [salt, theme.id, tokenStr, overrideTokenStr, cssVarStr], function () {
|
||||
var _cssVar$key;
|
||||
var mergedDerivativeToken = compute ? compute(mergedToken, override, theme) : getComputedToken(mergedToken, override, theme, formatToken);
|
||||
|
||||
// Replace token value with css variables
|
||||
var actualToken = _objectSpread({}, mergedDerivativeToken);
|
||||
var cssVarsStr = '';
|
||||
if (!!cssVar) {
|
||||
var _transformToken = transformToken(mergedDerivativeToken, cssVar.key, {
|
||||
prefix: cssVar.prefix,
|
||||
ignore: cssVar.ignore,
|
||||
unitless: cssVar.unitless,
|
||||
preserve: cssVar.preserve
|
||||
});
|
||||
var _transformToken2 = _slicedToArray(_transformToken, 2);
|
||||
mergedDerivativeToken = _transformToken2[0];
|
||||
cssVarsStr = _transformToken2[1];
|
||||
}
|
||||
|
||||
// Optimize for `useStyleRegister` performance
|
||||
var tokenKey = token2key(mergedDerivativeToken, salt);
|
||||
mergedDerivativeToken._tokenKey = tokenKey;
|
||||
actualToken._tokenKey = token2key(actualToken, salt);
|
||||
var themeKey = (_cssVar$key = cssVar === null || cssVar === void 0 ? void 0 : cssVar.key) !== null && _cssVar$key !== void 0 ? _cssVar$key : tokenKey;
|
||||
mergedDerivativeToken._themeKey = themeKey;
|
||||
recordCleanToken(themeKey);
|
||||
var hashId = "".concat(hashPrefix, "-").concat(hash(tokenKey));
|
||||
mergedDerivativeToken._hashId = hashId; // Not used
|
||||
|
||||
return [mergedDerivativeToken, hashId, actualToken, cssVarsStr, (cssVar === null || cssVar === void 0 ? void 0 : cssVar.key) || ''];
|
||||
}, function (cache) {
|
||||
// Remove token will remove all related style
|
||||
cleanTokenStyle(cache[0]._themeKey, instanceId);
|
||||
}, function (_ref) {
|
||||
var _ref2 = _slicedToArray(_ref, 4),
|
||||
token = _ref2[0],
|
||||
cssVarsStr = _ref2[3];
|
||||
if (cssVar && cssVarsStr) {
|
||||
var style = updateCSS(cssVarsStr, hash("css-variables-".concat(token._themeKey)), {
|
||||
mark: ATTR_MARK,
|
||||
prepend: 'queue',
|
||||
attachTo: container,
|
||||
priority: -999
|
||||
});
|
||||
style[CSS_IN_JS_INSTANCE] = instanceId;
|
||||
|
||||
// Used for `useCacheToken` to remove on batch when token removed
|
||||
style.setAttribute(ATTR_TOKEN, token._themeKey);
|
||||
}
|
||||
});
|
||||
return cachedToken;
|
||||
}
|
||||
export var extract = function extract(cache, effectStyles, options) {
|
||||
var _cache = _slicedToArray(cache, 5),
|
||||
realToken = _cache[2],
|
||||
styleStr = _cache[3],
|
||||
cssVarKey = _cache[4];
|
||||
var _ref3 = options || {},
|
||||
plain = _ref3.plain;
|
||||
if (!styleStr) {
|
||||
return null;
|
||||
}
|
||||
var styleId = realToken._tokenKey;
|
||||
var order = -999;
|
||||
|
||||
// ====================== Style ======================
|
||||
// Used for rc-util
|
||||
var sharedAttrs = {
|
||||
'data-rc-order': 'prependQueue',
|
||||
'data-rc-priority': "".concat(order)
|
||||
};
|
||||
var styleText = toStyleStr(styleStr, cssVarKey, styleId, sharedAttrs, plain);
|
||||
return [order, styleId, styleText];
|
||||
};
|
||||
10
node_modules/@ant-design/cssinjs/es/hooks/useCompatibleInsertionEffect.d.ts
generated
vendored
Normal file
10
node_modules/@ant-design/cssinjs/es/hooks/useCompatibleInsertionEffect.d.ts
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
import type { EffectCallback } from 'react';
|
||||
import * as React from 'react';
|
||||
type UseCompatibleInsertionEffect = (renderEffect: EffectCallback, effect: (polyfill?: boolean) => ReturnType<EffectCallback>, deps: React.DependencyList) => void;
|
||||
/**
|
||||
* Compatible `useInsertionEffect`
|
||||
* will use `useInsertionEffect` if React version >= 18,
|
||||
* otherwise use `useInsertionEffectPolyfill`.
|
||||
*/
|
||||
declare const useCompatibleInsertionEffect: UseCompatibleInsertionEffect;
|
||||
export default useCompatibleInsertionEffect;
|
||||
34
node_modules/@ant-design/cssinjs/es/hooks/useCompatibleInsertionEffect.js
generated
vendored
Normal file
34
node_modules/@ant-design/cssinjs/es/hooks/useCompatibleInsertionEffect.js
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
||||
// import canUseDom from 'rc-util/lib/Dom/canUseDom';
|
||||
import useLayoutEffect from "rc-util/es/hooks/useLayoutEffect";
|
||||
import * as React from 'react';
|
||||
|
||||
// We need fully clone React function here
|
||||
// to avoid webpack warning React 17 do not export `useId`
|
||||
var fullClone = _objectSpread({}, React);
|
||||
var useInsertionEffect = fullClone.useInsertionEffect;
|
||||
/**
|
||||
* Polyfill `useInsertionEffect` for React < 18
|
||||
* @param renderEffect will be executed in `useMemo`, and do not have callback
|
||||
* @param effect will be executed in `useLayoutEffect`
|
||||
* @param deps
|
||||
*/
|
||||
var useInsertionEffectPolyfill = function useInsertionEffectPolyfill(renderEffect, effect, deps) {
|
||||
React.useMemo(renderEffect, deps);
|
||||
useLayoutEffect(function () {
|
||||
return effect(true);
|
||||
}, deps);
|
||||
};
|
||||
|
||||
/**
|
||||
* Compatible `useInsertionEffect`
|
||||
* will use `useInsertionEffect` if React version >= 18,
|
||||
* otherwise use `useInsertionEffectPolyfill`.
|
||||
*/
|
||||
var useCompatibleInsertionEffect = useInsertionEffect ? function (renderEffect, effect, deps) {
|
||||
return useInsertionEffect(function () {
|
||||
renderEffect();
|
||||
return effect();
|
||||
}, deps);
|
||||
} : useInsertionEffectPolyfill;
|
||||
export default useCompatibleInsertionEffect;
|
||||
3
node_modules/@ant-design/cssinjs/es/hooks/useEffectCleanupRegister.d.ts
generated
vendored
Normal file
3
node_modules/@ant-design/cssinjs/es/hooks/useEffectCleanupRegister.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import * as React from 'react';
|
||||
declare const useEffectCleanupRegister: (deps?: React.DependencyList) => (fn: () => void) => void;
|
||||
export default useEffectCleanupRegister;
|
||||
42
node_modules/@ant-design/cssinjs/es/hooks/useEffectCleanupRegister.js
generated
vendored
Normal file
42
node_modules/@ant-design/cssinjs/es/hooks/useEffectCleanupRegister.js
generated
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
||||
import { warning } from "rc-util/es/warning";
|
||||
import * as React from 'react';
|
||||
var fullClone = _objectSpread({}, React);
|
||||
var useInsertionEffect = fullClone.useInsertionEffect;
|
||||
|
||||
// DO NOT register functions in useEffect cleanup function, or functions that registered will never be called.
|
||||
var useCleanupRegister = function useCleanupRegister(deps) {
|
||||
var effectCleanups = [];
|
||||
var cleanupFlag = false;
|
||||
function register(fn) {
|
||||
if (cleanupFlag) {
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
warning(false, '[Ant Design CSS-in-JS] You are registering a cleanup function after unmount, which will not have any effect.');
|
||||
}
|
||||
return;
|
||||
}
|
||||
effectCleanups.push(fn);
|
||||
}
|
||||
React.useEffect(function () {
|
||||
// Compatible with strict mode
|
||||
cleanupFlag = false;
|
||||
return function () {
|
||||
cleanupFlag = true;
|
||||
if (effectCleanups.length) {
|
||||
effectCleanups.forEach(function (fn) {
|
||||
return fn();
|
||||
});
|
||||
}
|
||||
};
|
||||
}, deps);
|
||||
return register;
|
||||
};
|
||||
var useRun = function useRun() {
|
||||
return function (fn) {
|
||||
fn();
|
||||
};
|
||||
};
|
||||
|
||||
// Only enable register in React 18
|
||||
var useEffectCleanupRegister = typeof useInsertionEffect !== 'undefined' ? useCleanupRegister : useRun;
|
||||
export default useEffectCleanupRegister;
|
||||
5
node_modules/@ant-design/cssinjs/es/hooks/useGlobalCache.d.ts
generated
vendored
Normal file
5
node_modules/@ant-design/cssinjs/es/hooks/useGlobalCache.d.ts
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
import { type KeyType } from '../Cache';
|
||||
export type ExtractStyle<CacheValue> = (cache: CacheValue, effectStyles: Record<string, boolean>, options?: {
|
||||
plain?: boolean;
|
||||
}) => [order: number, styleId: string, style: string] | null;
|
||||
export default function useGlobalCache<CacheType>(prefix: string, keyPath: KeyType[], cacheFn: () => CacheType, onCacheRemove?: (cache: CacheType, fromHMR: boolean) => void, onCacheEffect?: (cachedValue: CacheType) => void): CacheType;
|
||||
98
node_modules/@ant-design/cssinjs/es/hooks/useGlobalCache.js
generated
vendored
Normal file
98
node_modules/@ant-design/cssinjs/es/hooks/useGlobalCache.js
generated
vendored
Normal file
@@ -0,0 +1,98 @@
|
||||
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
||||
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
||||
import * as React from 'react';
|
||||
import { pathKey } from "../Cache";
|
||||
import StyleContext from "../StyleContext";
|
||||
import useCompatibleInsertionEffect from "./useCompatibleInsertionEffect";
|
||||
import useEffectCleanupRegister from "./useEffectCleanupRegister";
|
||||
import useHMR from "./useHMR";
|
||||
export default function useGlobalCache(prefix, keyPath, cacheFn, onCacheRemove,
|
||||
// Add additional effect trigger by `useInsertionEffect`
|
||||
onCacheEffect) {
|
||||
var _React$useContext = React.useContext(StyleContext),
|
||||
globalCache = _React$useContext.cache;
|
||||
var fullPath = [prefix].concat(_toConsumableArray(keyPath));
|
||||
var fullPathStr = pathKey(fullPath);
|
||||
var register = useEffectCleanupRegister([fullPathStr]);
|
||||
var HMRUpdate = useHMR();
|
||||
var buildCache = function buildCache(updater) {
|
||||
globalCache.opUpdate(fullPathStr, function (prevCache) {
|
||||
var _ref = prevCache || [undefined, undefined],
|
||||
_ref2 = _slicedToArray(_ref, 2),
|
||||
_ref2$ = _ref2[0],
|
||||
times = _ref2$ === void 0 ? 0 : _ref2$,
|
||||
cache = _ref2[1];
|
||||
|
||||
// HMR should always ignore cache since developer may change it
|
||||
var tmpCache = cache;
|
||||
if (process.env.NODE_ENV !== 'production' && cache && HMRUpdate) {
|
||||
onCacheRemove === null || onCacheRemove === void 0 || onCacheRemove(tmpCache, HMRUpdate);
|
||||
tmpCache = null;
|
||||
}
|
||||
var mergedCache = tmpCache || cacheFn();
|
||||
var data = [times, mergedCache];
|
||||
|
||||
// Call updater if need additional logic
|
||||
return updater ? updater(data) : data;
|
||||
});
|
||||
};
|
||||
|
||||
// Create cache
|
||||
React.useMemo(function () {
|
||||
buildCache();
|
||||
}, /* eslint-disable react-hooks/exhaustive-deps */
|
||||
[fullPathStr]
|
||||
/* eslint-enable */);
|
||||
var cacheEntity = globalCache.opGet(fullPathStr);
|
||||
|
||||
// HMR clean the cache but not trigger `useMemo` again
|
||||
// Let's fallback of this
|
||||
// ref https://github.com/ant-design/cssinjs/issues/127
|
||||
if (process.env.NODE_ENV !== 'production' && !cacheEntity) {
|
||||
buildCache();
|
||||
cacheEntity = globalCache.opGet(fullPathStr);
|
||||
}
|
||||
var cacheContent = cacheEntity[1];
|
||||
|
||||
// Remove if no need anymore
|
||||
useCompatibleInsertionEffect(function () {
|
||||
onCacheEffect === null || onCacheEffect === void 0 || onCacheEffect(cacheContent);
|
||||
}, function (polyfill) {
|
||||
// It's bad to call build again in effect.
|
||||
// But we have to do this since StrictMode will call effect twice
|
||||
// which will clear cache on the first time.
|
||||
buildCache(function (_ref3) {
|
||||
var _ref4 = _slicedToArray(_ref3, 2),
|
||||
times = _ref4[0],
|
||||
cache = _ref4[1];
|
||||
if (polyfill && times === 0) {
|
||||
onCacheEffect === null || onCacheEffect === void 0 || onCacheEffect(cacheContent);
|
||||
}
|
||||
return [times + 1, cache];
|
||||
});
|
||||
return function () {
|
||||
globalCache.opUpdate(fullPathStr, function (prevCache) {
|
||||
var _ref5 = prevCache || [],
|
||||
_ref6 = _slicedToArray(_ref5, 2),
|
||||
_ref6$ = _ref6[0],
|
||||
times = _ref6$ === void 0 ? 0 : _ref6$,
|
||||
cache = _ref6[1];
|
||||
var nextCount = times - 1;
|
||||
if (nextCount === 0) {
|
||||
// Always remove styles in useEffect callback
|
||||
register(function () {
|
||||
// With polyfill, registered callback will always be called synchronously
|
||||
// But without polyfill, it will be called in effect clean up,
|
||||
// And by that time this cache is cleaned up.
|
||||
if (polyfill || !globalCache.opGet(fullPathStr)) {
|
||||
onCacheRemove === null || onCacheRemove === void 0 || onCacheRemove(cache, false);
|
||||
}
|
||||
});
|
||||
return null;
|
||||
}
|
||||
return [times - 1, cache];
|
||||
});
|
||||
};
|
||||
}, [fullPathStr]);
|
||||
return cacheContent;
|
||||
}
|
||||
3
node_modules/@ant-design/cssinjs/es/hooks/useHMR.d.ts
generated
vendored
Normal file
3
node_modules/@ant-design/cssinjs/es/hooks/useHMR.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
declare function useProdHMR(): boolean;
|
||||
declare const _default: typeof useProdHMR;
|
||||
export default _default;
|
||||
26
node_modules/@ant-design/cssinjs/es/hooks/useHMR.js
generated
vendored
Normal file
26
node_modules/@ant-design/cssinjs/es/hooks/useHMR.js
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
function useProdHMR() {
|
||||
return false;
|
||||
}
|
||||
var webpackHMR = false;
|
||||
function useDevHMR() {
|
||||
return webpackHMR;
|
||||
}
|
||||
export default process.env.NODE_ENV === 'production' ? useProdHMR : useDevHMR;
|
||||
|
||||
// Webpack `module.hot.accept` do not support any deps update trigger
|
||||
// We have to hack handler to force mark as HRM
|
||||
if (process.env.NODE_ENV !== 'production' && typeof module !== 'undefined' && module && module.hot && typeof window !== 'undefined') {
|
||||
// Use `globalThis` first, and `window` for older browsers
|
||||
// const win = globalThis as any;
|
||||
var win = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : null;
|
||||
if (win && typeof win.webpackHotUpdate === 'function') {
|
||||
var originWebpackHotUpdate = win.webpackHotUpdate;
|
||||
win.webpackHotUpdate = function () {
|
||||
webpackHMR = true;
|
||||
setTimeout(function () {
|
||||
webpackHMR = false;
|
||||
}, 0);
|
||||
return originWebpackHotUpdate.apply(void 0, arguments);
|
||||
};
|
||||
}
|
||||
}
|
||||
77
node_modules/@ant-design/cssinjs/es/hooks/useStyleRegister.d.ts
generated
vendored
Normal file
77
node_modules/@ant-design/cssinjs/es/hooks/useStyleRegister.d.ts
generated
vendored
Normal file
@@ -0,0 +1,77 @@
|
||||
import type * as CSS from 'csstype';
|
||||
import * as React from 'react';
|
||||
import type { Theme, Transformer } from '..';
|
||||
import type Keyframes from '../Keyframes';
|
||||
import type { Linter } from '../linters';
|
||||
import type { HashPriority } from '../StyleContext';
|
||||
import type { ExtractStyle } from './useGlobalCache';
|
||||
declare const SKIP_CHECK = "_skip_check_";
|
||||
declare const MULTI_VALUE = "_multi_value_";
|
||||
export interface LayerConfig {
|
||||
name: string;
|
||||
dependencies?: string[];
|
||||
}
|
||||
export type CSSProperties = Omit<CSS.PropertiesFallback<number | string>, 'animationName'> & {
|
||||
animationName?: CSS.PropertiesFallback<number | string>['animationName'] | Keyframes;
|
||||
};
|
||||
export type CSSPropertiesWithMultiValues = {
|
||||
[K in keyof CSSProperties]: CSSProperties[K] | readonly Extract<CSSProperties[K], string>[] | {
|
||||
[SKIP_CHECK]?: boolean;
|
||||
[MULTI_VALUE]?: boolean;
|
||||
value: CSSProperties[K] | CSSProperties[K][];
|
||||
};
|
||||
};
|
||||
export type CSSPseudos = {
|
||||
[K in CSS.Pseudos]?: CSSObject;
|
||||
};
|
||||
type ArrayCSSInterpolation = readonly CSSInterpolation[];
|
||||
export type InterpolationPrimitive = null | undefined | boolean | number | string | CSSObject;
|
||||
export type CSSInterpolation = InterpolationPrimitive | ArrayCSSInterpolation | Keyframes;
|
||||
export type CSSOthersObject = Record<string, CSSInterpolation>;
|
||||
export interface CSSObject extends CSSPropertiesWithMultiValues, CSSPseudos, CSSOthersObject {
|
||||
}
|
||||
export declare function normalizeStyle(styleStr: string): string;
|
||||
export interface ParseConfig {
|
||||
hashId?: string;
|
||||
hashPriority?: HashPriority;
|
||||
layer?: LayerConfig;
|
||||
path?: string;
|
||||
transformers?: Transformer[];
|
||||
linters?: Linter[];
|
||||
}
|
||||
export interface ParseInfo {
|
||||
root?: boolean;
|
||||
injectHash?: boolean;
|
||||
parentSelectors: string[];
|
||||
}
|
||||
export declare const parseStyle: (interpolation: CSSInterpolation, config?: ParseConfig, { root, injectHash, parentSelectors }?: ParseInfo) => [parsedStr: string, effectStyle: Record<string, string>];
|
||||
export declare function uniqueHash(path: (string | number)[], styleStr: string): string;
|
||||
export declare const STYLE_PREFIX = "style";
|
||||
type StyleCacheValue = [
|
||||
styleStr: string,
|
||||
tokenKey: string,
|
||||
styleId: string,
|
||||
effectStyle: Record<string, string>,
|
||||
clientOnly: boolean | undefined,
|
||||
order: number
|
||||
];
|
||||
/**
|
||||
* Register a style to the global style sheet.
|
||||
*/
|
||||
export default function useStyleRegister(info: {
|
||||
theme: Theme<any, any>;
|
||||
token: any;
|
||||
path: string[];
|
||||
hashId?: string;
|
||||
layer?: LayerConfig;
|
||||
nonce?: string | (() => string);
|
||||
clientOnly?: boolean;
|
||||
/**
|
||||
* Tell cssinjs the insert order of style.
|
||||
* It's useful when you need to insert style
|
||||
* before other style to overwrite for the same selector priority.
|
||||
*/
|
||||
order?: number;
|
||||
}, styleFn: () => CSSInterpolation): (node: React.ReactElement) => React.JSX.Element;
|
||||
export declare const extract: ExtractStyle<StyleCacheValue>;
|
||||
export {};
|
||||
424
node_modules/@ant-design/cssinjs/es/hooks/useStyleRegister.js
generated
vendored
Normal file
424
node_modules/@ant-design/cssinjs/es/hooks/useStyleRegister.js
generated
vendored
Normal file
@@ -0,0 +1,424 @@
|
||||
import _extends from "@babel/runtime/helpers/esm/extends";
|
||||
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
||||
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
||||
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
||||
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
||||
import _typeof from "@babel/runtime/helpers/esm/typeof";
|
||||
import hash from '@emotion/hash';
|
||||
import { removeCSS, updateCSS } from "rc-util/es/Dom/dynamicCSS";
|
||||
import * as React from 'react';
|
||||
// @ts-ignore
|
||||
import unitless from '@emotion/unitless';
|
||||
import { compile, serialize, stringify } from 'stylis';
|
||||
import { contentQuotesLinter, hashedAnimationLinter } from "../linters";
|
||||
import StyleContext, { ATTR_CACHE_PATH, ATTR_MARK, ATTR_TOKEN, CSS_IN_JS_INSTANCE } from "../StyleContext";
|
||||
import { isClientSide, toStyleStr } from "../util";
|
||||
import { CSS_FILE_STYLE, existPath, getStyleAndHash } from "../util/cacheMapUtil";
|
||||
import useGlobalCache from "./useGlobalCache";
|
||||
var SKIP_CHECK = '_skip_check_';
|
||||
var MULTI_VALUE = '_multi_value_';
|
||||
// ============================================================================
|
||||
// == Parser ==
|
||||
// ============================================================================
|
||||
// Preprocessor style content to browser support one
|
||||
export function normalizeStyle(styleStr) {
|
||||
var serialized = serialize(compile(styleStr), stringify);
|
||||
return serialized.replace(/\{%%%\:[^;];}/g, ';');
|
||||
}
|
||||
function isCompoundCSSProperty(value) {
|
||||
return _typeof(value) === 'object' && value && (SKIP_CHECK in value || MULTI_VALUE in value);
|
||||
}
|
||||
|
||||
// 注入 hash 值
|
||||
function injectSelectorHash(key, hashId, hashPriority) {
|
||||
if (!hashId) {
|
||||
return key;
|
||||
}
|
||||
var hashClassName = ".".concat(hashId);
|
||||
var hashSelector = hashPriority === 'low' ? ":where(".concat(hashClassName, ")") : hashClassName;
|
||||
|
||||
// 注入 hashId
|
||||
var keys = key.split(',').map(function (k) {
|
||||
var _firstPath$match;
|
||||
var fullPath = k.trim().split(/\s+/);
|
||||
|
||||
// 如果 Selector 第一个是 HTML Element,那我们就插到它的后面。反之,就插到最前面。
|
||||
var firstPath = fullPath[0] || '';
|
||||
var htmlElement = ((_firstPath$match = firstPath.match(/^\w+/)) === null || _firstPath$match === void 0 ? void 0 : _firstPath$match[0]) || '';
|
||||
firstPath = "".concat(htmlElement).concat(hashSelector).concat(firstPath.slice(htmlElement.length));
|
||||
return [firstPath].concat(_toConsumableArray(fullPath.slice(1))).join(' ');
|
||||
});
|
||||
return keys.join(',');
|
||||
}
|
||||
// Parse CSSObject to style content
|
||||
export var parseStyle = function parseStyle(interpolation) {
|
||||
var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
||||
var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
|
||||
root: true,
|
||||
parentSelectors: []
|
||||
},
|
||||
root = _ref.root,
|
||||
injectHash = _ref.injectHash,
|
||||
parentSelectors = _ref.parentSelectors;
|
||||
var hashId = config.hashId,
|
||||
layer = config.layer,
|
||||
path = config.path,
|
||||
hashPriority = config.hashPriority,
|
||||
_config$transformers = config.transformers,
|
||||
transformers = _config$transformers === void 0 ? [] : _config$transformers,
|
||||
_config$linters = config.linters,
|
||||
linters = _config$linters === void 0 ? [] : _config$linters;
|
||||
var styleStr = '';
|
||||
var effectStyle = {};
|
||||
function parseKeyframes(keyframes) {
|
||||
var animationName = keyframes.getName(hashId);
|
||||
if (!effectStyle[animationName]) {
|
||||
var _parseStyle = parseStyle(keyframes.style, config, {
|
||||
root: false,
|
||||
parentSelectors: parentSelectors
|
||||
}),
|
||||
_parseStyle2 = _slicedToArray(_parseStyle, 1),
|
||||
_parsedStr = _parseStyle2[0];
|
||||
effectStyle[animationName] = "@keyframes ".concat(keyframes.getName(hashId)).concat(_parsedStr);
|
||||
}
|
||||
}
|
||||
function flattenList(list) {
|
||||
var fullList = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
||||
list.forEach(function (item) {
|
||||
if (Array.isArray(item)) {
|
||||
flattenList(item, fullList);
|
||||
} else if (item) {
|
||||
fullList.push(item);
|
||||
}
|
||||
});
|
||||
return fullList;
|
||||
}
|
||||
var flattenStyleList = flattenList(Array.isArray(interpolation) ? interpolation : [interpolation]);
|
||||
flattenStyleList.forEach(function (originStyle) {
|
||||
// Only root level can use raw string
|
||||
var style = typeof originStyle === 'string' && !root ? {} : originStyle;
|
||||
if (typeof style === 'string') {
|
||||
styleStr += "".concat(style, "\n");
|
||||
} else if (style._keyframe) {
|
||||
// Keyframe
|
||||
parseKeyframes(style);
|
||||
} else {
|
||||
var mergedStyle = transformers.reduce(function (prev, trans) {
|
||||
var _trans$visit;
|
||||
return (trans === null || trans === void 0 || (_trans$visit = trans.visit) === null || _trans$visit === void 0 ? void 0 : _trans$visit.call(trans, prev)) || prev;
|
||||
}, style);
|
||||
|
||||
// Normal CSSObject
|
||||
Object.keys(mergedStyle).forEach(function (key) {
|
||||
var value = mergedStyle[key];
|
||||
if (_typeof(value) === 'object' && value && (key !== 'animationName' || !value._keyframe) && !isCompoundCSSProperty(value)) {
|
||||
var subInjectHash = false;
|
||||
|
||||
// 当成嵌套对象来处理
|
||||
var mergedKey = key.trim();
|
||||
// Whether treat child as root. In most case it is false.
|
||||
var nextRoot = false;
|
||||
|
||||
// 拆分多个选择器
|
||||
if ((root || injectHash) && hashId) {
|
||||
if (mergedKey.startsWith('@')) {
|
||||
// 略过媒体查询,交给子节点继续插入 hashId
|
||||
subInjectHash = true;
|
||||
} else if (mergedKey === '&') {
|
||||
// 抹掉 root selector 上的单个 &
|
||||
mergedKey = injectSelectorHash('', hashId, hashPriority);
|
||||
} else {
|
||||
// 注入 hashId
|
||||
mergedKey = injectSelectorHash(key, hashId, hashPriority);
|
||||
}
|
||||
} else if (root && !hashId && (mergedKey === '&' || mergedKey === '')) {
|
||||
// In case of `{ '&': { a: { color: 'red' } } }` or `{ '': { a: { color: 'red' } } }` without hashId,
|
||||
// we will get `&{a:{color:red;}}` or `{a:{color:red;}}` string for stylis to compile.
|
||||
// But it does not conform to stylis syntax,
|
||||
// and finally we will get `{color:red;}` as css, which is wrong.
|
||||
// So we need to remove key in root, and treat child `{ a: { color: 'red' } }` as root.
|
||||
mergedKey = '';
|
||||
nextRoot = true;
|
||||
}
|
||||
var _parseStyle3 = parseStyle(value, config, {
|
||||
root: nextRoot,
|
||||
injectHash: subInjectHash,
|
||||
parentSelectors: [].concat(_toConsumableArray(parentSelectors), [mergedKey])
|
||||
}),
|
||||
_parseStyle4 = _slicedToArray(_parseStyle3, 2),
|
||||
_parsedStr2 = _parseStyle4[0],
|
||||
childEffectStyle = _parseStyle4[1];
|
||||
effectStyle = _objectSpread(_objectSpread({}, effectStyle), childEffectStyle);
|
||||
styleStr += "".concat(mergedKey).concat(_parsedStr2);
|
||||
} else {
|
||||
var _value;
|
||||
function appendStyle(cssKey, cssValue) {
|
||||
if (process.env.NODE_ENV !== 'production' && (_typeof(value) !== 'object' || !(value !== null && value !== void 0 && value[SKIP_CHECK]))) {
|
||||
[contentQuotesLinter, hashedAnimationLinter].concat(_toConsumableArray(linters)).forEach(function (linter) {
|
||||
return linter(cssKey, cssValue, {
|
||||
path: path,
|
||||
hashId: hashId,
|
||||
parentSelectors: parentSelectors
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// 如果是样式则直接插入
|
||||
var styleName = cssKey.replace(/[A-Z]/g, function (match) {
|
||||
return "-".concat(match.toLowerCase());
|
||||
});
|
||||
|
||||
// Auto suffix with px
|
||||
var formatValue = cssValue;
|
||||
if (!unitless[cssKey] && typeof formatValue === 'number' && formatValue !== 0) {
|
||||
formatValue = "".concat(formatValue, "px");
|
||||
}
|
||||
|
||||
// handle animationName & Keyframe value
|
||||
if (cssKey === 'animationName' && cssValue !== null && cssValue !== void 0 && cssValue._keyframe) {
|
||||
parseKeyframes(cssValue);
|
||||
formatValue = cssValue.getName(hashId);
|
||||
}
|
||||
styleStr += "".concat(styleName, ":").concat(formatValue, ";");
|
||||
}
|
||||
var actualValue = (_value = value === null || value === void 0 ? void 0 : value.value) !== null && _value !== void 0 ? _value : value;
|
||||
if (_typeof(value) === 'object' && value !== null && value !== void 0 && value[MULTI_VALUE] && Array.isArray(actualValue)) {
|
||||
actualValue.forEach(function (item) {
|
||||
appendStyle(key, item);
|
||||
});
|
||||
} else {
|
||||
appendStyle(key, actualValue);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
if (!root) {
|
||||
styleStr = "{".concat(styleStr, "}");
|
||||
} else if (layer) {
|
||||
// fixme: https://github.com/thysultan/stylis/pull/339
|
||||
if (styleStr) {
|
||||
styleStr = "@layer ".concat(layer.name, " {").concat(styleStr, "}");
|
||||
}
|
||||
if (layer.dependencies) {
|
||||
effectStyle["@layer ".concat(layer.name)] = layer.dependencies.map(function (deps) {
|
||||
return "@layer ".concat(deps, ", ").concat(layer.name, ";");
|
||||
}).join('\n');
|
||||
}
|
||||
}
|
||||
return [styleStr, effectStyle];
|
||||
};
|
||||
|
||||
// ============================================================================
|
||||
// == Register ==
|
||||
// ============================================================================
|
||||
export function uniqueHash(path, styleStr) {
|
||||
return hash("".concat(path.join('%')).concat(styleStr));
|
||||
}
|
||||
function Empty() {
|
||||
return null;
|
||||
}
|
||||
export var STYLE_PREFIX = 'style';
|
||||
/**
|
||||
* Register a style to the global style sheet.
|
||||
*/
|
||||
export default function useStyleRegister(info, styleFn) {
|
||||
var token = info.token,
|
||||
path = info.path,
|
||||
hashId = info.hashId,
|
||||
layer = info.layer,
|
||||
nonce = info.nonce,
|
||||
clientOnly = info.clientOnly,
|
||||
_info$order = info.order,
|
||||
order = _info$order === void 0 ? 0 : _info$order;
|
||||
var _React$useContext = React.useContext(StyleContext),
|
||||
autoClear = _React$useContext.autoClear,
|
||||
mock = _React$useContext.mock,
|
||||
defaultCache = _React$useContext.defaultCache,
|
||||
hashPriority = _React$useContext.hashPriority,
|
||||
container = _React$useContext.container,
|
||||
ssrInline = _React$useContext.ssrInline,
|
||||
transformers = _React$useContext.transformers,
|
||||
linters = _React$useContext.linters,
|
||||
cache = _React$useContext.cache,
|
||||
enableLayer = _React$useContext.layer;
|
||||
var tokenKey = token._tokenKey;
|
||||
var fullPath = [tokenKey];
|
||||
if (enableLayer) {
|
||||
fullPath.push('layer');
|
||||
}
|
||||
fullPath.push.apply(fullPath, _toConsumableArray(path));
|
||||
|
||||
// Check if need insert style
|
||||
var isMergedClientSide = isClientSide;
|
||||
if (process.env.NODE_ENV !== 'production' && mock !== undefined) {
|
||||
isMergedClientSide = mock === 'client';
|
||||
}
|
||||
var _useGlobalCache = useGlobalCache(STYLE_PREFIX, fullPath,
|
||||
// Create cache if needed
|
||||
function () {
|
||||
var cachePath = fullPath.join('|');
|
||||
|
||||
// Get style from SSR inline style directly
|
||||
if (existPath(cachePath)) {
|
||||
var _getStyleAndHash = getStyleAndHash(cachePath),
|
||||
_getStyleAndHash2 = _slicedToArray(_getStyleAndHash, 2),
|
||||
inlineCacheStyleStr = _getStyleAndHash2[0],
|
||||
styleHash = _getStyleAndHash2[1];
|
||||
if (inlineCacheStyleStr) {
|
||||
return [inlineCacheStyleStr, tokenKey, styleHash, {}, clientOnly, order];
|
||||
}
|
||||
}
|
||||
|
||||
// Generate style
|
||||
var styleObj = styleFn();
|
||||
var _parseStyle5 = parseStyle(styleObj, {
|
||||
hashId: hashId,
|
||||
hashPriority: hashPriority,
|
||||
layer: enableLayer ? layer : undefined,
|
||||
path: path.join('-'),
|
||||
transformers: transformers,
|
||||
linters: linters
|
||||
}),
|
||||
_parseStyle6 = _slicedToArray(_parseStyle5, 2),
|
||||
parsedStyle = _parseStyle6[0],
|
||||
effectStyle = _parseStyle6[1];
|
||||
var styleStr = normalizeStyle(parsedStyle);
|
||||
var styleId = uniqueHash(fullPath, styleStr);
|
||||
return [styleStr, tokenKey, styleId, effectStyle, clientOnly, order];
|
||||
},
|
||||
// Remove cache if no need
|
||||
function (_ref2, fromHMR) {
|
||||
var _ref3 = _slicedToArray(_ref2, 3),
|
||||
styleId = _ref3[2];
|
||||
if ((fromHMR || autoClear) && isClientSide) {
|
||||
removeCSS(styleId, {
|
||||
mark: ATTR_MARK,
|
||||
attachTo: container
|
||||
});
|
||||
}
|
||||
},
|
||||
// Effect: Inject style here
|
||||
function (_ref4) {
|
||||
var _ref5 = _slicedToArray(_ref4, 4),
|
||||
styleStr = _ref5[0],
|
||||
_ = _ref5[1],
|
||||
styleId = _ref5[2],
|
||||
effectStyle = _ref5[3];
|
||||
if (isMergedClientSide && styleStr !== CSS_FILE_STYLE) {
|
||||
var mergedCSSConfig = {
|
||||
mark: ATTR_MARK,
|
||||
prepend: enableLayer ? false : 'queue',
|
||||
attachTo: container,
|
||||
priority: order
|
||||
};
|
||||
var nonceStr = typeof nonce === 'function' ? nonce() : nonce;
|
||||
if (nonceStr) {
|
||||
mergedCSSConfig.csp = {
|
||||
nonce: nonceStr
|
||||
};
|
||||
}
|
||||
|
||||
// ================= Split Effect Style =================
|
||||
// We will split effectStyle here since @layer should be at the top level
|
||||
var effectLayerKeys = [];
|
||||
var effectRestKeys = [];
|
||||
Object.keys(effectStyle).forEach(function (key) {
|
||||
if (key.startsWith('@layer')) {
|
||||
effectLayerKeys.push(key);
|
||||
} else {
|
||||
effectRestKeys.push(key);
|
||||
}
|
||||
});
|
||||
|
||||
// ================= Inject Layer Style =================
|
||||
// Inject layer style
|
||||
effectLayerKeys.forEach(function (effectKey) {
|
||||
updateCSS(normalizeStyle(effectStyle[effectKey]), "_layer-".concat(effectKey), _objectSpread(_objectSpread({}, mergedCSSConfig), {}, {
|
||||
prepend: true
|
||||
}));
|
||||
});
|
||||
|
||||
// ==================== Inject Style ====================
|
||||
// Inject style
|
||||
var style = updateCSS(styleStr, styleId, mergedCSSConfig);
|
||||
style[CSS_IN_JS_INSTANCE] = cache.instanceId;
|
||||
|
||||
// Used for `useCacheToken` to remove on batch when token removed
|
||||
style.setAttribute(ATTR_TOKEN, tokenKey);
|
||||
|
||||
// Debug usage. Dev only
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
style.setAttribute(ATTR_CACHE_PATH, fullPath.join('|'));
|
||||
}
|
||||
|
||||
// ================ Inject Effect Style =================
|
||||
// Inject client side effect style
|
||||
effectRestKeys.forEach(function (effectKey) {
|
||||
updateCSS(normalizeStyle(effectStyle[effectKey]), "_effect-".concat(effectKey), mergedCSSConfig);
|
||||
});
|
||||
}
|
||||
}),
|
||||
_useGlobalCache2 = _slicedToArray(_useGlobalCache, 3),
|
||||
cachedStyleStr = _useGlobalCache2[0],
|
||||
cachedTokenKey = _useGlobalCache2[1],
|
||||
cachedStyleId = _useGlobalCache2[2];
|
||||
return function (node) {
|
||||
var styleNode;
|
||||
if (!ssrInline || isMergedClientSide || !defaultCache) {
|
||||
styleNode = /*#__PURE__*/React.createElement(Empty, null);
|
||||
} else {
|
||||
styleNode = /*#__PURE__*/React.createElement("style", _extends({}, _defineProperty(_defineProperty({}, ATTR_TOKEN, cachedTokenKey), ATTR_MARK, cachedStyleId), {
|
||||
dangerouslySetInnerHTML: {
|
||||
__html: cachedStyleStr
|
||||
}
|
||||
}));
|
||||
}
|
||||
return /*#__PURE__*/React.createElement(React.Fragment, null, styleNode, node);
|
||||
};
|
||||
}
|
||||
export var extract = function extract(cache, effectStyles, options) {
|
||||
var _cache = _slicedToArray(cache, 6),
|
||||
styleStr = _cache[0],
|
||||
tokenKey = _cache[1],
|
||||
styleId = _cache[2],
|
||||
effectStyle = _cache[3],
|
||||
clientOnly = _cache[4],
|
||||
order = _cache[5];
|
||||
var _ref7 = options || {},
|
||||
plain = _ref7.plain;
|
||||
|
||||
// Skip client only style
|
||||
if (clientOnly) {
|
||||
return null;
|
||||
}
|
||||
var keyStyleText = styleStr;
|
||||
|
||||
// ====================== Share ======================
|
||||
// Used for rc-util
|
||||
var sharedAttrs = {
|
||||
'data-rc-order': 'prependQueue',
|
||||
'data-rc-priority': "".concat(order)
|
||||
};
|
||||
|
||||
// ====================== Style ======================
|
||||
keyStyleText = toStyleStr(styleStr, tokenKey, styleId, sharedAttrs, plain);
|
||||
|
||||
// =============== Create effect style ===============
|
||||
if (effectStyle) {
|
||||
Object.keys(effectStyle).forEach(function (effectKey) {
|
||||
// Effect style can be reused
|
||||
if (!effectStyles[effectKey]) {
|
||||
effectStyles[effectKey] = true;
|
||||
var effectStyleStr = normalizeStyle(effectStyle[effectKey]);
|
||||
var effectStyleHTML = toStyleStr(effectStyleStr, tokenKey, "_effect-".concat(effectKey), sharedAttrs, plain);
|
||||
if (effectKey.startsWith('@layer')) {
|
||||
keyStyleText = effectStyleHTML + keyStyleText;
|
||||
} else {
|
||||
keyStyleText += effectStyleHTML;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
return [order, styleId, keyStyleText];
|
||||
};
|
||||
22
node_modules/@ant-design/cssinjs/es/index.d.ts
generated
vendored
Normal file
22
node_modules/@ant-design/cssinjs/es/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
import extractStyle from './extractStyle';
|
||||
import useCacheToken, { getComputedToken } from './hooks/useCacheToken';
|
||||
import useCSSVarRegister from './hooks/useCSSVarRegister';
|
||||
import type { CSSInterpolation, CSSObject } from './hooks/useStyleRegister';
|
||||
import useStyleRegister from './hooks/useStyleRegister';
|
||||
import Keyframes from './Keyframes';
|
||||
import type { Linter } from './linters';
|
||||
import { legacyNotSelectorLinter, logicalPropertiesLinter, NaNLinter, parentSelectorLinter } from './linters';
|
||||
import type { StyleProviderProps } from './StyleContext';
|
||||
import StyleContext, { createCache, StyleProvider } from './StyleContext';
|
||||
import type { AbstractCalculator, DerivativeFunc, TokenType } from './theme';
|
||||
import { createTheme, genCalc, Theme } from './theme';
|
||||
import type { Transformer } from './transformers/interface';
|
||||
import legacyLogicalPropertiesTransformer from './transformers/legacyLogicalProperties';
|
||||
import px2remTransformer from './transformers/px2rem';
|
||||
import { unit } from './util';
|
||||
import { token2CSSVar } from './util/css-variables';
|
||||
export { Theme, createTheme, useStyleRegister, useCSSVarRegister, useCacheToken, createCache, StyleProvider, StyleContext, Keyframes, extractStyle, getComputedToken, legacyLogicalPropertiesTransformer, px2remTransformer, logicalPropertiesLinter, legacyNotSelectorLinter, parentSelectorLinter, NaNLinter, token2CSSVar, unit, genCalc, };
|
||||
export type { TokenType, CSSObject, CSSInterpolation, DerivativeFunc, Transformer, Linter, StyleProviderProps, AbstractCalculator, };
|
||||
export declare const _experimental: {
|
||||
supportModernCSS: () => boolean;
|
||||
};
|
||||
24
node_modules/@ant-design/cssinjs/es/index.js
generated
vendored
Normal file
24
node_modules/@ant-design/cssinjs/es/index.js
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
import extractStyle from "./extractStyle";
|
||||
import useCacheToken, { getComputedToken } from "./hooks/useCacheToken";
|
||||
import useCSSVarRegister from "./hooks/useCSSVarRegister";
|
||||
import useStyleRegister from "./hooks/useStyleRegister";
|
||||
import Keyframes from "./Keyframes";
|
||||
import { legacyNotSelectorLinter, logicalPropertiesLinter, NaNLinter, parentSelectorLinter } from "./linters";
|
||||
import StyleContext, { createCache, StyleProvider } from "./StyleContext";
|
||||
import { createTheme, genCalc, Theme } from "./theme";
|
||||
import legacyLogicalPropertiesTransformer from "./transformers/legacyLogicalProperties";
|
||||
import px2remTransformer from "./transformers/px2rem";
|
||||
import { supportLogicProps, supportWhere, unit } from "./util";
|
||||
import { token2CSSVar } from "./util/css-variables";
|
||||
export { Theme, createTheme, useStyleRegister, useCSSVarRegister, useCacheToken, createCache, StyleProvider, StyleContext, Keyframes, extractStyle, getComputedToken,
|
||||
// Transformer
|
||||
legacyLogicalPropertiesTransformer, px2remTransformer,
|
||||
// Linters
|
||||
logicalPropertiesLinter, legacyNotSelectorLinter, parentSelectorLinter, NaNLinter,
|
||||
// util
|
||||
token2CSSVar, unit, genCalc };
|
||||
export var _experimental = {
|
||||
supportModernCSS: function supportModernCSS() {
|
||||
return supportWhere() && supportLogicProps();
|
||||
}
|
||||
};
|
||||
3
node_modules/@ant-design/cssinjs/es/linters/NaNLinter.d.ts
generated
vendored
Normal file
3
node_modules/@ant-design/cssinjs/es/linters/NaNLinter.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import type { Linter } from './interface';
|
||||
declare const linter: Linter;
|
||||
export default linter;
|
||||
7
node_modules/@ant-design/cssinjs/es/linters/NaNLinter.js
generated
vendored
Normal file
7
node_modules/@ant-design/cssinjs/es/linters/NaNLinter.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
import { lintWarning } from "./utils";
|
||||
var linter = function linter(key, value, info) {
|
||||
if (typeof value === 'string' && /NaN/g.test(value) || Number.isNaN(value)) {
|
||||
lintWarning("Unexpected 'NaN' in property '".concat(key, ": ").concat(value, "'."), info);
|
||||
}
|
||||
};
|
||||
export default linter;
|
||||
3
node_modules/@ant-design/cssinjs/es/linters/contentQuotesLinter.d.ts
generated
vendored
Normal file
3
node_modules/@ant-design/cssinjs/es/linters/contentQuotesLinter.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import type { Linter } from './interface';
|
||||
declare const linter: Linter;
|
||||
export default linter;
|
||||
12
node_modules/@ant-design/cssinjs/es/linters/contentQuotesLinter.js
generated
vendored
Normal file
12
node_modules/@ant-design/cssinjs/es/linters/contentQuotesLinter.js
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
import { lintWarning } from "./utils";
|
||||
var linter = function linter(key, value, info) {
|
||||
if (key === 'content') {
|
||||
// From emotion: https://github.com/emotion-js/emotion/blob/main/packages/serialize/src/index.js#L63
|
||||
var contentValuePattern = /(attr|counters?|url|(((repeating-)?(linear|radial))|conic)-gradient)\(|(no-)?(open|close)-quote/;
|
||||
var contentValues = ['normal', 'none', 'initial', 'inherit', 'unset'];
|
||||
if (typeof value !== 'string' || contentValues.indexOf(value) === -1 && !contentValuePattern.test(value) && (value.charAt(0) !== value.charAt(value.length - 1) || value.charAt(0) !== '"' && value.charAt(0) !== "'")) {
|
||||
lintWarning("You seem to be using a value for 'content' without quotes, try replacing it with `content: '\"".concat(value, "\"'`."), info);
|
||||
}
|
||||
}
|
||||
};
|
||||
export default linter;
|
||||
3
node_modules/@ant-design/cssinjs/es/linters/hashedAnimationLinter.d.ts
generated
vendored
Normal file
3
node_modules/@ant-design/cssinjs/es/linters/hashedAnimationLinter.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import type { Linter } from './interface';
|
||||
declare const linter: Linter;
|
||||
export default linter;
|
||||
9
node_modules/@ant-design/cssinjs/es/linters/hashedAnimationLinter.js
generated
vendored
Normal file
9
node_modules/@ant-design/cssinjs/es/linters/hashedAnimationLinter.js
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
import { lintWarning } from "./utils";
|
||||
var linter = function linter(key, value, info) {
|
||||
if (key === 'animation') {
|
||||
if (info.hashId && value !== 'none') {
|
||||
lintWarning("You seem to be using hashed animation '".concat(value, "', in which case 'animationName' with Keyframe as value is recommended."), info);
|
||||
}
|
||||
}
|
||||
};
|
||||
export default linter;
|
||||
7
node_modules/@ant-design/cssinjs/es/linters/index.d.ts
generated
vendored
Normal file
7
node_modules/@ant-design/cssinjs/es/linters/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
export { default as contentQuotesLinter } from './contentQuotesLinter';
|
||||
export { default as hashedAnimationLinter } from './hashedAnimationLinter';
|
||||
export type { Linter } from './interface';
|
||||
export { default as legacyNotSelectorLinter } from './legacyNotSelectorLinter';
|
||||
export { default as logicalPropertiesLinter } from './logicalPropertiesLinter';
|
||||
export { default as NaNLinter } from './NaNLinter';
|
||||
export { default as parentSelectorLinter } from './parentSelectorLinter';
|
||||
6
node_modules/@ant-design/cssinjs/es/linters/index.js
generated
vendored
Normal file
6
node_modules/@ant-design/cssinjs/es/linters/index.js
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
export { default as contentQuotesLinter } from "./contentQuotesLinter";
|
||||
export { default as hashedAnimationLinter } from "./hashedAnimationLinter";
|
||||
export { default as legacyNotSelectorLinter } from "./legacyNotSelectorLinter";
|
||||
export { default as logicalPropertiesLinter } from "./logicalPropertiesLinter";
|
||||
export { default as NaNLinter } from "./NaNLinter";
|
||||
export { default as parentSelectorLinter } from "./parentSelectorLinter";
|
||||
8
node_modules/@ant-design/cssinjs/es/linters/interface.d.ts
generated
vendored
Normal file
8
node_modules/@ant-design/cssinjs/es/linters/interface.d.ts
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
export interface LinterInfo {
|
||||
path?: string;
|
||||
hashId?: string;
|
||||
parentSelectors: string[];
|
||||
}
|
||||
export interface Linter {
|
||||
(key: string, value: string | number, info: LinterInfo): void;
|
||||
}
|
||||
1
node_modules/@ant-design/cssinjs/es/linters/interface.js
generated
vendored
Normal file
1
node_modules/@ant-design/cssinjs/es/linters/interface.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export {};
|
||||
3
node_modules/@ant-design/cssinjs/es/linters/legacyNotSelectorLinter.d.ts
generated
vendored
Normal file
3
node_modules/@ant-design/cssinjs/es/linters/legacyNotSelectorLinter.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import type { Linter } from './interface';
|
||||
declare const linter: Linter;
|
||||
export default linter;
|
||||
28
node_modules/@ant-design/cssinjs/es/linters/legacyNotSelectorLinter.js
generated
vendored
Normal file
28
node_modules/@ant-design/cssinjs/es/linters/legacyNotSelectorLinter.js
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
import { lintWarning } from "./utils";
|
||||
function isConcatSelector(selector) {
|
||||
var _selector$match;
|
||||
var notContent = ((_selector$match = selector.match(/:not\(([^)]*)\)/)) === null || _selector$match === void 0 ? void 0 : _selector$match[1]) || '';
|
||||
|
||||
// split selector. e.g.
|
||||
// `h1#a.b` => ['h1', #a', '.b']
|
||||
var splitCells = notContent.split(/(\[[^[]*])|(?=[.#])/).filter(function (str) {
|
||||
return str;
|
||||
});
|
||||
return splitCells.length > 1;
|
||||
}
|
||||
function parsePath(info) {
|
||||
return info.parentSelectors.reduce(function (prev, cur) {
|
||||
if (!prev) {
|
||||
return cur;
|
||||
}
|
||||
return cur.includes('&') ? cur.replace(/&/g, prev) : "".concat(prev, " ").concat(cur);
|
||||
}, '');
|
||||
}
|
||||
var linter = function linter(key, value, info) {
|
||||
var parentSelectorPath = parsePath(info);
|
||||
var notList = parentSelectorPath.match(/:not\([^)]*\)/g) || [];
|
||||
if (notList.length > 0 && notList.some(isConcatSelector)) {
|
||||
lintWarning("Concat ':not' selector not support in legacy browsers.", info);
|
||||
}
|
||||
};
|
||||
export default linter;
|
||||
3
node_modules/@ant-design/cssinjs/es/linters/logicalPropertiesLinter.d.ts
generated
vendored
Normal file
3
node_modules/@ant-design/cssinjs/es/linters/logicalPropertiesLinter.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import type { Linter } from './interface';
|
||||
declare const linter: Linter;
|
||||
export default linter;
|
||||
78
node_modules/@ant-design/cssinjs/es/linters/logicalPropertiesLinter.js
generated
vendored
Normal file
78
node_modules/@ant-design/cssinjs/es/linters/logicalPropertiesLinter.js
generated
vendored
Normal file
@@ -0,0 +1,78 @@
|
||||
import { lintWarning } from "./utils";
|
||||
var linter = function linter(key, value, info) {
|
||||
switch (key) {
|
||||
case 'marginLeft':
|
||||
case 'marginRight':
|
||||
case 'paddingLeft':
|
||||
case 'paddingRight':
|
||||
case 'left':
|
||||
case 'right':
|
||||
case 'borderLeft':
|
||||
case 'borderLeftWidth':
|
||||
case 'borderLeftStyle':
|
||||
case 'borderLeftColor':
|
||||
case 'borderRight':
|
||||
case 'borderRightWidth':
|
||||
case 'borderRightStyle':
|
||||
case 'borderRightColor':
|
||||
case 'borderTopLeftRadius':
|
||||
case 'borderTopRightRadius':
|
||||
case 'borderBottomLeftRadius':
|
||||
case 'borderBottomRightRadius':
|
||||
lintWarning("You seem to be using non-logical property '".concat(key, "' which is not compatible with RTL mode. Please use logical properties and values instead. For more information: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Logical_Properties."), info);
|
||||
return;
|
||||
case 'margin':
|
||||
case 'padding':
|
||||
case 'borderWidth':
|
||||
case 'borderStyle':
|
||||
// case 'borderColor':
|
||||
if (typeof value === 'string') {
|
||||
var valueArr = value.split(' ').map(function (item) {
|
||||
return item.trim();
|
||||
});
|
||||
if (valueArr.length === 4 && valueArr[1] !== valueArr[3]) {
|
||||
lintWarning("You seem to be using '".concat(key, "' property with different left ").concat(key, " and right ").concat(key, ", which is not compatible with RTL mode. Please use logical properties and values instead. For more information: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Logical_Properties."), info);
|
||||
}
|
||||
}
|
||||
return;
|
||||
case 'clear':
|
||||
case 'textAlign':
|
||||
if (value === 'left' || value === 'right') {
|
||||
lintWarning("You seem to be using non-logical value '".concat(value, "' of ").concat(key, ", which is not compatible with RTL mode. Please use logical properties and values instead. For more information: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Logical_Properties."), info);
|
||||
}
|
||||
return;
|
||||
case 'borderRadius':
|
||||
if (typeof value === 'string') {
|
||||
var radiusGroups = value.split('/').map(function (item) {
|
||||
return item.trim();
|
||||
});
|
||||
var invalid = radiusGroups.reduce(function (result, group) {
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
var radiusArr = group.split(' ').map(function (item) {
|
||||
return item.trim();
|
||||
});
|
||||
// borderRadius: '2px 4px'
|
||||
if (radiusArr.length >= 2 && radiusArr[0] !== radiusArr[1]) {
|
||||
return true;
|
||||
}
|
||||
// borderRadius: '4px 4px 2px'
|
||||
if (radiusArr.length === 3 && radiusArr[1] !== radiusArr[2]) {
|
||||
return true;
|
||||
}
|
||||
// borderRadius: '4px 4px 2px 4px'
|
||||
if (radiusArr.length === 4 && radiusArr[2] !== radiusArr[3]) {
|
||||
return true;
|
||||
}
|
||||
return result;
|
||||
}, false);
|
||||
if (invalid) {
|
||||
lintWarning("You seem to be using non-logical value '".concat(value, "' of ").concat(key, ", which is not compatible with RTL mode. Please use logical properties and values instead. For more information: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Logical_Properties."), info);
|
||||
}
|
||||
}
|
||||
return;
|
||||
default:
|
||||
}
|
||||
};
|
||||
export default linter;
|
||||
3
node_modules/@ant-design/cssinjs/es/linters/parentSelectorLinter.d.ts
generated
vendored
Normal file
3
node_modules/@ant-design/cssinjs/es/linters/parentSelectorLinter.d.ts
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import type { Linter } from '..';
|
||||
declare const linter: Linter;
|
||||
export default linter;
|
||||
12
node_modules/@ant-design/cssinjs/es/linters/parentSelectorLinter.js
generated
vendored
Normal file
12
node_modules/@ant-design/cssinjs/es/linters/parentSelectorLinter.js
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
import { lintWarning } from "./utils";
|
||||
var linter = function linter(key, value, info) {
|
||||
if (info.parentSelectors.some(function (selector) {
|
||||
var selectors = selector.split(',');
|
||||
return selectors.some(function (item) {
|
||||
return item.split('&').length > 2;
|
||||
});
|
||||
})) {
|
||||
lintWarning('Should not use more than one `&` in a selector.', info);
|
||||
}
|
||||
};
|
||||
export default linter;
|
||||
2
node_modules/@ant-design/cssinjs/es/linters/utils.d.ts
generated
vendored
Normal file
2
node_modules/@ant-design/cssinjs/es/linters/utils.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
import type { LinterInfo } from './interface';
|
||||
export declare function lintWarning(message: string, info: LinterInfo): void;
|
||||
6
node_modules/@ant-design/cssinjs/es/linters/utils.js
generated
vendored
Normal file
6
node_modules/@ant-design/cssinjs/es/linters/utils.js
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
import devWarning from "rc-util/es/warning";
|
||||
export function lintWarning(message, info) {
|
||||
var path = info.path,
|
||||
parentSelectors = info.parentSelectors;
|
||||
devWarning(false, "[Ant Design CSS-in-JS] ".concat(path ? "Error in ".concat(path, ": ") : '').concat(message).concat(parentSelectors.length ? " Selector: ".concat(parentSelectors.join(' | ')) : ''));
|
||||
}
|
||||
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 {};
|
||||
4
node_modules/@ant-design/cssinjs/es/transformers/interface.d.ts
generated
vendored
Normal file
4
node_modules/@ant-design/cssinjs/es/transformers/interface.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
import type { CSSObject } from '..';
|
||||
export interface Transformer {
|
||||
visit?: (cssObj: CSSObject) => CSSObject;
|
||||
}
|
||||
1
node_modules/@ant-design/cssinjs/es/transformers/interface.js
generated
vendored
Normal file
1
node_modules/@ant-design/cssinjs/es/transformers/interface.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export {};
|
||||
12
node_modules/@ant-design/cssinjs/es/transformers/legacyLogicalProperties.d.ts
generated
vendored
Normal file
12
node_modules/@ant-design/cssinjs/es/transformers/legacyLogicalProperties.d.ts
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
import type { Transformer } from './interface';
|
||||
/**
|
||||
* Convert css logical properties to legacy properties.
|
||||
* Such as: `margin-block-start` to `margin-top`.
|
||||
* Transform list:
|
||||
* - inset
|
||||
* - margin
|
||||
* - padding
|
||||
* - border
|
||||
*/
|
||||
declare const transform: Transformer;
|
||||
export default transform;
|
||||
149
node_modules/@ant-design/cssinjs/es/transformers/legacyLogicalProperties.js
generated
vendored
Normal file
149
node_modules/@ant-design/cssinjs/es/transformers/legacyLogicalProperties.js
generated
vendored
Normal file
@@ -0,0 +1,149 @@
|
||||
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
||||
function splitValues(value) {
|
||||
if (typeof value === 'number') {
|
||||
return [[value], false];
|
||||
}
|
||||
var rawStyle = String(value).trim();
|
||||
var importantCells = rawStyle.match(/(.*)(!important)/);
|
||||
var splitStyle = (importantCells ? importantCells[1] : rawStyle).trim().split(/\s+/);
|
||||
|
||||
// Combine styles split in brackets, like `calc(1px + 2px)`
|
||||
var temp = [];
|
||||
var brackets = 0;
|
||||
return [splitStyle.reduce(function (list, item) {
|
||||
if (item.includes('(') || item.includes(')')) {
|
||||
var left = item.split('(').length - 1;
|
||||
var right = item.split(')').length - 1;
|
||||
brackets += left - right;
|
||||
}
|
||||
if (brackets >= 0) temp.push(item);
|
||||
if (brackets === 0) {
|
||||
list.push(temp.join(' '));
|
||||
temp = [];
|
||||
}
|
||||
return list;
|
||||
}, []), !!importantCells];
|
||||
}
|
||||
function noSplit(list) {
|
||||
list.notSplit = true;
|
||||
return list;
|
||||
}
|
||||
var keyMap = {
|
||||
// Inset
|
||||
inset: ['top', 'right', 'bottom', 'left'],
|
||||
insetBlock: ['top', 'bottom'],
|
||||
insetBlockStart: ['top'],
|
||||
insetBlockEnd: ['bottom'],
|
||||
insetInline: ['left', 'right'],
|
||||
insetInlineStart: ['left'],
|
||||
insetInlineEnd: ['right'],
|
||||
// Margin
|
||||
marginBlock: ['marginTop', 'marginBottom'],
|
||||
marginBlockStart: ['marginTop'],
|
||||
marginBlockEnd: ['marginBottom'],
|
||||
marginInline: ['marginLeft', 'marginRight'],
|
||||
marginInlineStart: ['marginLeft'],
|
||||
marginInlineEnd: ['marginRight'],
|
||||
// Padding
|
||||
paddingBlock: ['paddingTop', 'paddingBottom'],
|
||||
paddingBlockStart: ['paddingTop'],
|
||||
paddingBlockEnd: ['paddingBottom'],
|
||||
paddingInline: ['paddingLeft', 'paddingRight'],
|
||||
paddingInlineStart: ['paddingLeft'],
|
||||
paddingInlineEnd: ['paddingRight'],
|
||||
// Border
|
||||
borderBlock: noSplit(['borderTop', 'borderBottom']),
|
||||
borderBlockStart: noSplit(['borderTop']),
|
||||
borderBlockEnd: noSplit(['borderBottom']),
|
||||
borderInline: noSplit(['borderLeft', 'borderRight']),
|
||||
borderInlineStart: noSplit(['borderLeft']),
|
||||
borderInlineEnd: noSplit(['borderRight']),
|
||||
// Border width
|
||||
borderBlockWidth: ['borderTopWidth', 'borderBottomWidth'],
|
||||
borderBlockStartWidth: ['borderTopWidth'],
|
||||
borderBlockEndWidth: ['borderBottomWidth'],
|
||||
borderInlineWidth: ['borderLeftWidth', 'borderRightWidth'],
|
||||
borderInlineStartWidth: ['borderLeftWidth'],
|
||||
borderInlineEndWidth: ['borderRightWidth'],
|
||||
// Border style
|
||||
borderBlockStyle: ['borderTopStyle', 'borderBottomStyle'],
|
||||
borderBlockStartStyle: ['borderTopStyle'],
|
||||
borderBlockEndStyle: ['borderBottomStyle'],
|
||||
borderInlineStyle: ['borderLeftStyle', 'borderRightStyle'],
|
||||
borderInlineStartStyle: ['borderLeftStyle'],
|
||||
borderInlineEndStyle: ['borderRightStyle'],
|
||||
// Border color
|
||||
borderBlockColor: ['borderTopColor', 'borderBottomColor'],
|
||||
borderBlockStartColor: ['borderTopColor'],
|
||||
borderBlockEndColor: ['borderBottomColor'],
|
||||
borderInlineColor: ['borderLeftColor', 'borderRightColor'],
|
||||
borderInlineStartColor: ['borderLeftColor'],
|
||||
borderInlineEndColor: ['borderRightColor'],
|
||||
// Border radius
|
||||
borderStartStartRadius: ['borderTopLeftRadius'],
|
||||
borderStartEndRadius: ['borderTopRightRadius'],
|
||||
borderEndStartRadius: ['borderBottomLeftRadius'],
|
||||
borderEndEndRadius: ['borderBottomRightRadius']
|
||||
};
|
||||
function wrapImportantAndSkipCheck(value, important) {
|
||||
var parsedValue = value;
|
||||
if (important) {
|
||||
parsedValue = "".concat(parsedValue, " !important");
|
||||
}
|
||||
return {
|
||||
_skip_check_: true,
|
||||
value: parsedValue
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert css logical properties to legacy properties.
|
||||
* Such as: `margin-block-start` to `margin-top`.
|
||||
* Transform list:
|
||||
* - inset
|
||||
* - margin
|
||||
* - padding
|
||||
* - border
|
||||
*/
|
||||
var transform = {
|
||||
visit: function visit(cssObj) {
|
||||
var clone = {};
|
||||
Object.keys(cssObj).forEach(function (key) {
|
||||
var value = cssObj[key];
|
||||
var matchValue = keyMap[key];
|
||||
if (matchValue && (typeof value === 'number' || typeof value === 'string')) {
|
||||
var _splitValues = splitValues(value),
|
||||
_splitValues2 = _slicedToArray(_splitValues, 2),
|
||||
_values = _splitValues2[0],
|
||||
_important = _splitValues2[1];
|
||||
if (matchValue.length && matchValue.notSplit) {
|
||||
// not split means always give same value like border
|
||||
matchValue.forEach(function (matchKey) {
|
||||
clone[matchKey] = wrapImportantAndSkipCheck(value, _important);
|
||||
});
|
||||
} else if (matchValue.length === 1) {
|
||||
// Handle like `marginBlockStart` => `marginTop`
|
||||
clone[matchValue[0]] = wrapImportantAndSkipCheck(_values[0], _important);
|
||||
} else if (matchValue.length === 2) {
|
||||
// Handle like `marginBlock` => `marginTop` & `marginBottom`
|
||||
matchValue.forEach(function (matchKey, index) {
|
||||
var _values$index;
|
||||
clone[matchKey] = wrapImportantAndSkipCheck((_values$index = _values[index]) !== null && _values$index !== void 0 ? _values$index : _values[0], _important);
|
||||
});
|
||||
} else if (matchValue.length === 4) {
|
||||
// Handle like `inset` => `top` & `right` & `bottom` & `left`
|
||||
matchValue.forEach(function (matchKey, index) {
|
||||
var _ref, _values$index2;
|
||||
clone[matchKey] = wrapImportantAndSkipCheck((_ref = (_values$index2 = _values[index]) !== null && _values$index2 !== void 0 ? _values$index2 : _values[index - 2]) !== null && _ref !== void 0 ? _ref : _values[0], _important);
|
||||
});
|
||||
} else {
|
||||
clone[key] = value;
|
||||
}
|
||||
} else {
|
||||
clone[key] = value;
|
||||
}
|
||||
});
|
||||
return clone;
|
||||
}
|
||||
};
|
||||
export default transform;
|
||||
20
node_modules/@ant-design/cssinjs/es/transformers/px2rem.d.ts
generated
vendored
Normal file
20
node_modules/@ant-design/cssinjs/es/transformers/px2rem.d.ts
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
import type { Transformer } from './interface';
|
||||
interface Options {
|
||||
/**
|
||||
* The root font size.
|
||||
* @default 16
|
||||
*/
|
||||
rootValue?: number;
|
||||
/**
|
||||
* The decimal numbers to allow the REM units to grow to.
|
||||
* @default 5
|
||||
*/
|
||||
precision?: number;
|
||||
/**
|
||||
* Whether to allow px to be converted in media queries.
|
||||
* @default false
|
||||
*/
|
||||
mediaQuery?: boolean;
|
||||
}
|
||||
declare const transform: (options?: Options) => Transformer;
|
||||
export default transform;
|
||||
60
node_modules/@ant-design/cssinjs/es/transformers/px2rem.js
generated
vendored
Normal file
60
node_modules/@ant-design/cssinjs/es/transformers/px2rem.js
generated
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
||||
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
||||
/**
|
||||
* respect https://github.com/cuth/postcss-pxtorem
|
||||
*/
|
||||
// @ts-ignore
|
||||
import unitless from '@emotion/unitless';
|
||||
var pxRegex = /url\([^)]+\)|var\([^)]+\)|(\d*\.?\d+)px/g;
|
||||
function toFixed(number, precision) {
|
||||
var multiplier = Math.pow(10, precision + 1),
|
||||
wholeNumber = Math.floor(number * multiplier);
|
||||
return Math.round(wholeNumber / 10) * 10 / multiplier;
|
||||
}
|
||||
var transform = function transform() {
|
||||
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
||||
var _options$rootValue = options.rootValue,
|
||||
rootValue = _options$rootValue === void 0 ? 16 : _options$rootValue,
|
||||
_options$precision = options.precision,
|
||||
precision = _options$precision === void 0 ? 5 : _options$precision,
|
||||
_options$mediaQuery = options.mediaQuery,
|
||||
mediaQuery = _options$mediaQuery === void 0 ? false : _options$mediaQuery;
|
||||
var pxReplace = function pxReplace(m, $1) {
|
||||
if (!$1) return m;
|
||||
var pixels = parseFloat($1);
|
||||
// covenant: pixels <= 1, not transform to rem @zombieJ
|
||||
if (pixels <= 1) return m;
|
||||
var fixedVal = toFixed(pixels / rootValue, precision);
|
||||
return "".concat(fixedVal, "rem");
|
||||
};
|
||||
var visit = function visit(cssObj) {
|
||||
var clone = _objectSpread({}, cssObj);
|
||||
Object.entries(cssObj).forEach(function (_ref) {
|
||||
var _ref2 = _slicedToArray(_ref, 2),
|
||||
key = _ref2[0],
|
||||
value = _ref2[1];
|
||||
if (typeof value === 'string' && value.includes('px')) {
|
||||
var newValue = value.replace(pxRegex, pxReplace);
|
||||
clone[key] = newValue;
|
||||
}
|
||||
|
||||
// no unit
|
||||
if (!unitless[key] && typeof value === 'number' && value !== 0) {
|
||||
clone[key] = "".concat(value, "px").replace(pxRegex, pxReplace);
|
||||
}
|
||||
|
||||
// Media queries
|
||||
var mergedKey = key.trim();
|
||||
if (mergedKey.startsWith('@') && mergedKey.includes('px') && mediaQuery) {
|
||||
var newKey = key.replace(pxRegex, pxReplace);
|
||||
clone[newKey] = clone[key];
|
||||
delete clone[key];
|
||||
}
|
||||
});
|
||||
return clone;
|
||||
};
|
||||
return {
|
||||
visit: visit
|
||||
};
|
||||
};
|
||||
export default transform;
|
||||
14
node_modules/@ant-design/cssinjs/es/util/cacheMapUtil.d.ts
generated
vendored
Normal file
14
node_modules/@ant-design/cssinjs/es/util/cacheMapUtil.d.ts
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
export declare const ATTR_CACHE_MAP = "data-ant-cssinjs-cache-path";
|
||||
/**
|
||||
* This marks style from the css file.
|
||||
* Which means not exist in `<style />` tag.
|
||||
*/
|
||||
export declare const CSS_FILE_STYLE = "_FILE_STYLE__";
|
||||
export declare function serialize(cachePathMap: Record<string, string>): string;
|
||||
/**
|
||||
* @private Test usage only. Can save remove if no need.
|
||||
*/
|
||||
export declare function reset(mockCache?: Record<string, string>, fromFile?: boolean): void;
|
||||
export declare function prepare(): void;
|
||||
export declare function existPath(path: string): boolean;
|
||||
export declare function getStyleAndHash(path: string): [style: string | null, hash: string];
|
||||
82
node_modules/@ant-design/cssinjs/es/util/cacheMapUtil.js
generated
vendored
Normal file
82
node_modules/@ant-design/cssinjs/es/util/cacheMapUtil.js
generated
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
||||
import canUseDom from "rc-util/es/Dom/canUseDom";
|
||||
import { ATTR_MARK } from "../StyleContext";
|
||||
export var ATTR_CACHE_MAP = 'data-ant-cssinjs-cache-path';
|
||||
|
||||
/**
|
||||
* This marks style from the css file.
|
||||
* Which means not exist in `<style />` tag.
|
||||
*/
|
||||
export var CSS_FILE_STYLE = '_FILE_STYLE__';
|
||||
export function serialize(cachePathMap) {
|
||||
return Object.keys(cachePathMap).map(function (path) {
|
||||
var hash = cachePathMap[path];
|
||||
return "".concat(path, ":").concat(hash);
|
||||
}).join(';');
|
||||
}
|
||||
var cachePathMap;
|
||||
var fromCSSFile = true;
|
||||
|
||||
/**
|
||||
* @private Test usage only. Can save remove if no need.
|
||||
*/
|
||||
export function reset(mockCache) {
|
||||
var fromFile = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
||||
cachePathMap = mockCache;
|
||||
fromCSSFile = fromFile;
|
||||
}
|
||||
export function prepare() {
|
||||
if (!cachePathMap) {
|
||||
cachePathMap = {};
|
||||
if (canUseDom()) {
|
||||
var div = document.createElement('div');
|
||||
div.className = ATTR_CACHE_MAP;
|
||||
div.style.position = 'fixed';
|
||||
div.style.visibility = 'hidden';
|
||||
div.style.top = '-9999px';
|
||||
document.body.appendChild(div);
|
||||
var content = getComputedStyle(div).content || '';
|
||||
content = content.replace(/^"/, '').replace(/"$/, '');
|
||||
|
||||
// Fill data
|
||||
content.split(';').forEach(function (item) {
|
||||
var _item$split = item.split(':'),
|
||||
_item$split2 = _slicedToArray(_item$split, 2),
|
||||
path = _item$split2[0],
|
||||
hash = _item$split2[1];
|
||||
cachePathMap[path] = hash;
|
||||
});
|
||||
|
||||
// Remove inline record style
|
||||
var inlineMapStyle = document.querySelector("style[".concat(ATTR_CACHE_MAP, "]"));
|
||||
if (inlineMapStyle) {
|
||||
var _inlineMapStyle$paren;
|
||||
fromCSSFile = false;
|
||||
(_inlineMapStyle$paren = inlineMapStyle.parentNode) === null || _inlineMapStyle$paren === void 0 || _inlineMapStyle$paren.removeChild(inlineMapStyle);
|
||||
}
|
||||
document.body.removeChild(div);
|
||||
}
|
||||
}
|
||||
}
|
||||
export function existPath(path) {
|
||||
prepare();
|
||||
return !!cachePathMap[path];
|
||||
}
|
||||
export function getStyleAndHash(path) {
|
||||
var hash = cachePathMap[path];
|
||||
var styleStr = null;
|
||||
if (hash && canUseDom()) {
|
||||
if (fromCSSFile) {
|
||||
styleStr = CSS_FILE_STYLE;
|
||||
} else {
|
||||
var _style = document.querySelector("style[".concat(ATTR_MARK, "=\"").concat(cachePathMap[path], "\"]"));
|
||||
if (_style) {
|
||||
styleStr = _style.innerHTML;
|
||||
} else {
|
||||
// Clean up since not exist anymore
|
||||
delete cachePathMap[path];
|
||||
}
|
||||
}
|
||||
}
|
||||
return [styleStr, hash];
|
||||
}
|
||||
14
node_modules/@ant-design/cssinjs/es/util/css-variables.d.ts
generated
vendored
Normal file
14
node_modules/@ant-design/cssinjs/es/util/css-variables.d.ts
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
export declare const token2CSSVar: (token: string, prefix?: string) => string;
|
||||
export declare const serializeCSSVar: <T extends Record<string, any>>(cssVars: T, hashId: string, options?: {
|
||||
scope?: string;
|
||||
}) => string;
|
||||
export type TokenWithCSSVar<V, T extends Record<string, V> = Record<string, V>> = {
|
||||
[key in keyof T]?: string | V;
|
||||
};
|
||||
export declare const transformToken: <V, T extends Record<string, V> = Record<string, V>>(token: T, themeKey: string, config?: {
|
||||
prefix?: string | undefined;
|
||||
ignore?: { [key in keyof T]?: boolean | undefined; } | undefined;
|
||||
unitless?: { [key_1 in keyof T]?: boolean | undefined; } | undefined;
|
||||
preserve?: { [key_2 in keyof T]?: boolean | undefined; } | undefined;
|
||||
scope?: string | undefined;
|
||||
} | undefined) => [TokenWithCSSVar<V, T>, string];
|
||||
37
node_modules/@ant-design/cssinjs/es/util/css-variables.js
generated
vendored
Normal file
37
node_modules/@ant-design/cssinjs/es/util/css-variables.js
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
||||
export var token2CSSVar = function token2CSSVar(token) {
|
||||
var prefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
||||
return "--".concat(prefix ? "".concat(prefix, "-") : '').concat(token).replace(/([a-z0-9])([A-Z])/g, '$1-$2').replace(/([A-Z]+)([A-Z][a-z0-9]+)/g, '$1-$2').replace(/([a-z])([A-Z0-9])/g, '$1-$2').toLowerCase();
|
||||
};
|
||||
export var serializeCSSVar = function serializeCSSVar(cssVars, hashId, options) {
|
||||
if (!Object.keys(cssVars).length) {
|
||||
return '';
|
||||
}
|
||||
return ".".concat(hashId).concat(options !== null && options !== void 0 && options.scope ? ".".concat(options.scope) : '', "{").concat(Object.entries(cssVars).map(function (_ref) {
|
||||
var _ref2 = _slicedToArray(_ref, 2),
|
||||
key = _ref2[0],
|
||||
value = _ref2[1];
|
||||
return "".concat(key, ":").concat(value, ";");
|
||||
}).join(''), "}");
|
||||
};
|
||||
export var transformToken = function transformToken(token, themeKey, config) {
|
||||
var cssVars = {};
|
||||
var result = {};
|
||||
Object.entries(token).forEach(function (_ref3) {
|
||||
var _config$preserve, _config$ignore;
|
||||
var _ref4 = _slicedToArray(_ref3, 2),
|
||||
key = _ref4[0],
|
||||
value = _ref4[1];
|
||||
if (config !== null && config !== void 0 && (_config$preserve = config.preserve) !== null && _config$preserve !== void 0 && _config$preserve[key]) {
|
||||
result[key] = value;
|
||||
} else if ((typeof value === 'string' || typeof value === 'number') && !(config !== null && config !== void 0 && (_config$ignore = config.ignore) !== null && _config$ignore !== void 0 && _config$ignore[key])) {
|
||||
var _config$unitless;
|
||||
var cssVar = token2CSSVar(key, config === null || config === void 0 ? void 0 : config.prefix);
|
||||
cssVars[cssVar] = typeof value === 'number' && !(config !== null && config !== void 0 && (_config$unitless = config.unitless) !== null && _config$unitless !== void 0 && _config$unitless[key]) ? "".concat(value, "px") : String(value);
|
||||
result[key] = "var(".concat(cssVar, ")");
|
||||
}
|
||||
});
|
||||
return [result, serializeCSSVar(cssVars, themeKey, {
|
||||
scope: config === null || config === void 0 ? void 0 : config.scope
|
||||
})];
|
||||
};
|
||||
15
node_modules/@ant-design/cssinjs/es/util/index.d.ts
generated
vendored
Normal file
15
node_modules/@ant-design/cssinjs/es/util/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
export declare function memoResult<T extends object, R>(callback: () => R, deps: T[]): R;
|
||||
/**
|
||||
* Flatten token to string, this will auto cache the result when token not change
|
||||
*/
|
||||
export declare function flattenToken(token: any): string;
|
||||
/**
|
||||
* Convert derivative token to key string
|
||||
*/
|
||||
export declare function token2key(token: any, salt: string): string;
|
||||
export declare function supportLayer(): boolean;
|
||||
export declare function supportWhere(): boolean;
|
||||
export declare function supportLogicProps(): boolean;
|
||||
export declare const isClientSide: boolean;
|
||||
export declare function unit(num: string | number): string;
|
||||
export declare function toStyleStr(style: string, tokenKey?: string, styleId?: string, customizeAttrs?: Record<string, string>, plain?: boolean): string;
|
||||
141
node_modules/@ant-design/cssinjs/es/util/index.js
generated
vendored
Normal file
141
node_modules/@ant-design/cssinjs/es/util/index.js
generated
vendored
Normal file
@@ -0,0 +1,141 @@
|
||||
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
||||
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
||||
import _typeof from "@babel/runtime/helpers/esm/typeof";
|
||||
import hash from '@emotion/hash';
|
||||
import canUseDom from "rc-util/es/Dom/canUseDom";
|
||||
import { removeCSS, updateCSS } from "rc-util/es/Dom/dynamicCSS";
|
||||
import { ATTR_MARK, ATTR_TOKEN } from "../StyleContext";
|
||||
import { Theme } from "../theme";
|
||||
|
||||
// Create a cache for memo concat
|
||||
|
||||
var resultCache = new WeakMap();
|
||||
var RESULT_VALUE = {};
|
||||
export function memoResult(callback, deps) {
|
||||
var current = resultCache;
|
||||
for (var i = 0; i < deps.length; i += 1) {
|
||||
var dep = deps[i];
|
||||
if (!current.has(dep)) {
|
||||
current.set(dep, new WeakMap());
|
||||
}
|
||||
current = current.get(dep);
|
||||
}
|
||||
if (!current.has(RESULT_VALUE)) {
|
||||
current.set(RESULT_VALUE, callback());
|
||||
}
|
||||
return current.get(RESULT_VALUE);
|
||||
}
|
||||
|
||||
// Create a cache here to avoid always loop generate
|
||||
var flattenTokenCache = new WeakMap();
|
||||
|
||||
/**
|
||||
* Flatten token to string, this will auto cache the result when token not change
|
||||
*/
|
||||
export function flattenToken(token) {
|
||||
var str = flattenTokenCache.get(token) || '';
|
||||
if (!str) {
|
||||
Object.keys(token).forEach(function (key) {
|
||||
var value = token[key];
|
||||
str += key;
|
||||
if (value instanceof Theme) {
|
||||
str += value.id;
|
||||
} else if (value && _typeof(value) === 'object') {
|
||||
str += flattenToken(value);
|
||||
} else {
|
||||
str += value;
|
||||
}
|
||||
});
|
||||
|
||||
// https://github.com/ant-design/ant-design/issues/48386
|
||||
// Should hash the string to avoid style tag name too long
|
||||
str = hash(str);
|
||||
|
||||
// Put in cache
|
||||
flattenTokenCache.set(token, str);
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert derivative token to key string
|
||||
*/
|
||||
export function token2key(token, salt) {
|
||||
return hash("".concat(salt, "_").concat(flattenToken(token)));
|
||||
}
|
||||
var randomSelectorKey = "random-".concat(Date.now(), "-").concat(Math.random()).replace(/\./g, '');
|
||||
|
||||
// Magic `content` for detect selector support
|
||||
var checkContent = '_bAmBoO_';
|
||||
function supportSelector(styleStr, handleElement, supportCheck) {
|
||||
if (canUseDom()) {
|
||||
var _getComputedStyle$con, _ele$parentNode;
|
||||
updateCSS(styleStr, randomSelectorKey);
|
||||
var _ele = document.createElement('div');
|
||||
_ele.style.position = 'fixed';
|
||||
_ele.style.left = '0';
|
||||
_ele.style.top = '0';
|
||||
handleElement === null || handleElement === void 0 || handleElement(_ele);
|
||||
document.body.appendChild(_ele);
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
_ele.innerHTML = 'Test';
|
||||
_ele.style.zIndex = '9999999';
|
||||
}
|
||||
var support = supportCheck ? supportCheck(_ele) : (_getComputedStyle$con = getComputedStyle(_ele).content) === null || _getComputedStyle$con === void 0 ? void 0 : _getComputedStyle$con.includes(checkContent);
|
||||
(_ele$parentNode = _ele.parentNode) === null || _ele$parentNode === void 0 || _ele$parentNode.removeChild(_ele);
|
||||
removeCSS(randomSelectorKey);
|
||||
return support;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
var canLayer = undefined;
|
||||
export function supportLayer() {
|
||||
if (canLayer === undefined) {
|
||||
canLayer = supportSelector("@layer ".concat(randomSelectorKey, " { .").concat(randomSelectorKey, " { content: \"").concat(checkContent, "\"!important; } }"), function (ele) {
|
||||
ele.className = randomSelectorKey;
|
||||
});
|
||||
}
|
||||
return canLayer;
|
||||
}
|
||||
var canWhere = undefined;
|
||||
export function supportWhere() {
|
||||
if (canWhere === undefined) {
|
||||
canWhere = supportSelector(":where(.".concat(randomSelectorKey, ") { content: \"").concat(checkContent, "\"!important; }"), function (ele) {
|
||||
ele.className = randomSelectorKey;
|
||||
});
|
||||
}
|
||||
return canWhere;
|
||||
}
|
||||
var canLogic = undefined;
|
||||
export function supportLogicProps() {
|
||||
if (canLogic === undefined) {
|
||||
canLogic = supportSelector(".".concat(randomSelectorKey, " { inset-block: 93px !important; }"), function (ele) {
|
||||
ele.className = randomSelectorKey;
|
||||
}, function (ele) {
|
||||
return getComputedStyle(ele).bottom === '93px';
|
||||
});
|
||||
}
|
||||
return canLogic;
|
||||
}
|
||||
export var isClientSide = canUseDom();
|
||||
export function unit(num) {
|
||||
if (typeof num === 'number') {
|
||||
return "".concat(num, "px");
|
||||
}
|
||||
return num;
|
||||
}
|
||||
export function toStyleStr(style, tokenKey, styleId) {
|
||||
var customizeAttrs = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
||||
var plain = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
||||
if (plain) {
|
||||
return style;
|
||||
}
|
||||
var attrs = _objectSpread(_objectSpread({}, customizeAttrs), {}, _defineProperty(_defineProperty({}, ATTR_TOKEN, tokenKey), ATTR_MARK, styleId));
|
||||
var attrStr = Object.keys(attrs).map(function (attr) {
|
||||
var val = attrs[attr];
|
||||
return val ? "".concat(attr, "=\"").concat(val, "\"") : null;
|
||||
}).filter(function (v) {
|
||||
return v;
|
||||
}).join(' ');
|
||||
return "<style ".concat(attrStr, ">").concat(style, "</style>");
|
||||
}
|
||||
Reference in New Issue
Block a user