@ant-design/cssinjs
Advanced tools
Comparing version 1.14.0 to 1.15.0-alpha.0
@@ -1,3 +0,3 @@ | ||
export declare type KeyType = string | number; | ||
declare type ValueType = [number, any]; | ||
export type KeyType = string | number; | ||
type ValueType = [number, any]; | ||
declare class Entity { | ||
@@ -4,0 +4,0 @@ instanceId: string; |
import type Theme from '../theme/Theme'; | ||
export interface Option<DerivativeToken> { | ||
export interface Option<DerivativeToken, DesignToken> { | ||
/** | ||
@@ -20,2 +20,10 @@ * Generate token with salt. | ||
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; | ||
} | ||
@@ -30,4 +38,4 @@ export declare const getComputedToken: <DerivativeToken = object, DesignToken = DerivativeToken>(originToken: DesignToken, overrideToken: object, theme: Theme<any, any>, format?: ((token: DesignToken) => DerivativeToken) | undefined) => any; | ||
*/ | ||
export default function useCacheToken<DerivativeToken = object, DesignToken = DerivativeToken>(theme: Theme<any, any>, tokens: Partial<DesignToken>[], option?: Option<DerivativeToken>): [DerivativeToken & { | ||
export default function useCacheToken<DerivativeToken = object, DesignToken = DerivativeToken>(theme: Theme<any, any>, tokens: Partial<DesignToken>[], option?: Option<DerivativeToken, DesignToken>): [DerivativeToken & { | ||
_tokenKey: string; | ||
}, string]; |
@@ -76,3 +76,4 @@ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray"; | ||
override = _option$override === void 0 ? EMPTY_OVERRIDE : _option$override, | ||
formatToken = option.formatToken; | ||
formatToken = option.formatToken, | ||
compute = option.getComputedToken; | ||
@@ -90,3 +91,3 @@ // Basic - We do basic cache here | ||
var cachedToken = useGlobalCache('token', [salt, theme.id, tokenStr, overrideTokenStr], function () { | ||
var mergedDerivativeToken = getComputedToken(mergedToken, override, theme, formatToken); | ||
var mergedDerivativeToken = compute ? compute(mergedToken, override, theme) : getComputedToken(mergedToken, override, theme, formatToken); | ||
@@ -93,0 +94,0 @@ // Optimize for `useStyleRegister` performance |
import type { EffectCallback } from 'react'; | ||
import * as React from 'react'; | ||
declare type UseCompatibleInsertionEffect = (renderEffect: EffectCallback, effect: (polyfill?: boolean) => ReturnType<EffectCallback>, deps?: React.DependencyList) => void; | ||
type UseCompatibleInsertionEffect = (renderEffect: EffectCallback, effect: (polyfill?: boolean) => ReturnType<EffectCallback>, deps?: React.DependencyList) => void; | ||
/** | ||
@@ -5,0 +5,0 @@ * Compatible `useInsertionEffect` |
@@ -10,6 +10,6 @@ import type * as CSS from 'csstype'; | ||
declare const MULTI_VALUE = "_multi_value_"; | ||
export declare type CSSProperties = Omit<CSS.PropertiesFallback<number | string>, 'animationName'> & { | ||
export type CSSProperties = Omit<CSS.PropertiesFallback<number | string>, 'animationName'> & { | ||
animationName?: CSS.PropertiesFallback<number | string>['animationName'] | Keyframes; | ||
}; | ||
export declare type CSSPropertiesWithMultiValues = { | ||
export type CSSPropertiesWithMultiValues = { | ||
[K in keyof CSSProperties]: CSSProperties[K] | Extract<CSSProperties[K], string>[] | { | ||
@@ -21,9 +21,9 @@ [SKIP_CHECK]?: boolean; | ||
}; | ||
export declare type CSSPseudos = { | ||
export type CSSPseudos = { | ||
[K in CSS.Pseudos]?: CSSObject; | ||
}; | ||
declare type ArrayCSSInterpolation = CSSInterpolation[]; | ||
export declare type InterpolationPrimitive = null | undefined | boolean | number | string | CSSObject; | ||
export declare type CSSInterpolation = InterpolationPrimitive | ArrayCSSInterpolation | Keyframes; | ||
export declare type CSSOthersObject = Record<string, CSSInterpolation>; | ||
type ArrayCSSInterpolation = 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 { | ||
@@ -30,0 +30,0 @@ } |
@@ -10,3 +10,3 @@ import * as React from 'react'; | ||
export declare function createCache(): CacheEntity; | ||
export declare type HashPriority = 'low' | 'high'; | ||
export type HashPriority = 'low' | 'high'; | ||
export interface StyleContextProps { | ||
@@ -39,3 +39,3 @@ autoClear?: boolean; | ||
declare const StyleContext: React.Context<StyleContextProps>; | ||
export declare type StyleProviderProps = Partial<StyleContextProps> & { | ||
export type StyleProviderProps = Partial<StyleContextProps> & { | ||
children?: React.ReactNode; | ||
@@ -42,0 +42,0 @@ }; |
@@ -1,2 +0,2 @@ | ||
export declare type TokenType = object; | ||
export declare type DerivativeFunc<DesignToken extends TokenType, DerivativeToken extends TokenType> = (designToken: DesignToken, derivativeToken?: DerivativeToken) => DerivativeToken; | ||
export type TokenType = object; | ||
export type DerivativeFunc<DesignToken extends TokenType, DerivativeToken extends TokenType> = (designToken: DesignToken, derivativeToken?: DerivativeToken) => DerivativeToken; |
import type Theme from './Theme'; | ||
import type { DerivativeFunc } from './interface'; | ||
declare type DerivativeOptions = DerivativeFunc<any, any>[]; | ||
type DerivativeOptions = DerivativeFunc<any, any>[]; | ||
export declare function sameDerivativeOption(left: DerivativeOptions, right: DerivativeOptions): boolean; | ||
@@ -5,0 +5,0 @@ export default class ThemeCache { |
@@ -5,2 +5,3 @@ import _typeof from "@babel/runtime/helpers/esm/typeof"; | ||
import { removeCSS, updateCSS } from "rc-util/es/Dom/dynamicCSS"; | ||
import { Theme } from "./theme"; | ||
export function flattenToken(token) { | ||
@@ -11,3 +12,5 @@ var str = ''; | ||
str += key; | ||
if (value && _typeof(value) === 'object') { | ||
if (value instanceof Theme) { | ||
str += value.id; | ||
} else if (value && _typeof(value) === 'object') { | ||
str += flattenToken(value); | ||
@@ -14,0 +17,0 @@ } else { |
@@ -1,3 +0,3 @@ | ||
export declare type KeyType = string | number; | ||
declare type ValueType = [number, any]; | ||
export type KeyType = string | number; | ||
type ValueType = [number, any]; | ||
declare class Entity { | ||
@@ -4,0 +4,0 @@ instanceId: string; |
import type Theme from '../theme/Theme'; | ||
export interface Option<DerivativeToken> { | ||
export interface Option<DerivativeToken, DesignToken> { | ||
/** | ||
@@ -20,2 +20,10 @@ * Generate token with salt. | ||
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; | ||
} | ||
@@ -30,4 +38,4 @@ export declare const getComputedToken: <DerivativeToken = object, DesignToken = DerivativeToken>(originToken: DesignToken, overrideToken: object, theme: Theme<any, any>, format?: ((token: DesignToken) => DerivativeToken) | undefined) => any; | ||
*/ | ||
export default function useCacheToken<DerivativeToken = object, DesignToken = DerivativeToken>(theme: Theme<any, any>, tokens: Partial<DesignToken>[], option?: Option<DerivativeToken>): [DerivativeToken & { | ||
export default function useCacheToken<DerivativeToken = object, DesignToken = DerivativeToken>(theme: Theme<any, any>, tokens: Partial<DesignToken>[], option?: Option<DerivativeToken, DesignToken>): [DerivativeToken & { | ||
_tokenKey: string; | ||
}, string]; |
@@ -87,3 +87,4 @@ "use strict"; | ||
override = _option$override === void 0 ? EMPTY_OVERRIDE : _option$override, | ||
formatToken = option.formatToken; | ||
formatToken = option.formatToken, | ||
compute = option.getComputedToken; | ||
@@ -101,3 +102,3 @@ // Basic - We do basic cache here | ||
var cachedToken = (0, _useGlobalCache.default)('token', [salt, theme.id, tokenStr, overrideTokenStr], function () { | ||
var mergedDerivativeToken = getComputedToken(mergedToken, override, theme, formatToken); | ||
var mergedDerivativeToken = compute ? compute(mergedToken, override, theme) : getComputedToken(mergedToken, override, theme, formatToken); | ||
@@ -104,0 +105,0 @@ // Optimize for `useStyleRegister` performance |
import type { EffectCallback } from 'react'; | ||
import * as React from 'react'; | ||
declare type UseCompatibleInsertionEffect = (renderEffect: EffectCallback, effect: (polyfill?: boolean) => ReturnType<EffectCallback>, deps?: React.DependencyList) => void; | ||
type UseCompatibleInsertionEffect = (renderEffect: EffectCallback, effect: (polyfill?: boolean) => ReturnType<EffectCallback>, deps?: React.DependencyList) => void; | ||
/** | ||
@@ -5,0 +5,0 @@ * Compatible `useInsertionEffect` |
@@ -10,6 +10,6 @@ import type * as CSS from 'csstype'; | ||
declare const MULTI_VALUE = "_multi_value_"; | ||
export declare type CSSProperties = Omit<CSS.PropertiesFallback<number | string>, 'animationName'> & { | ||
export type CSSProperties = Omit<CSS.PropertiesFallback<number | string>, 'animationName'> & { | ||
animationName?: CSS.PropertiesFallback<number | string>['animationName'] | Keyframes; | ||
}; | ||
export declare type CSSPropertiesWithMultiValues = { | ||
export type CSSPropertiesWithMultiValues = { | ||
[K in keyof CSSProperties]: CSSProperties[K] | Extract<CSSProperties[K], string>[] | { | ||
@@ -21,9 +21,9 @@ [SKIP_CHECK]?: boolean; | ||
}; | ||
export declare type CSSPseudos = { | ||
export type CSSPseudos = { | ||
[K in CSS.Pseudos]?: CSSObject; | ||
}; | ||
declare type ArrayCSSInterpolation = CSSInterpolation[]; | ||
export declare type InterpolationPrimitive = null | undefined | boolean | number | string | CSSObject; | ||
export declare type CSSInterpolation = InterpolationPrimitive | ArrayCSSInterpolation | Keyframes; | ||
export declare type CSSOthersObject = Record<string, CSSInterpolation>; | ||
type ArrayCSSInterpolation = 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 { | ||
@@ -30,0 +30,0 @@ } |
@@ -10,3 +10,3 @@ import * as React from 'react'; | ||
export declare function createCache(): CacheEntity; | ||
export declare type HashPriority = 'low' | 'high'; | ||
export type HashPriority = 'low' | 'high'; | ||
export interface StyleContextProps { | ||
@@ -39,3 +39,3 @@ autoClear?: boolean; | ||
declare const StyleContext: React.Context<StyleContextProps>; | ||
export declare type StyleProviderProps = Partial<StyleContextProps> & { | ||
export type StyleProviderProps = Partial<StyleContextProps> & { | ||
children?: React.ReactNode; | ||
@@ -42,0 +42,0 @@ }; |
@@ -1,2 +0,2 @@ | ||
export declare type TokenType = object; | ||
export declare type DerivativeFunc<DesignToken extends TokenType, DerivativeToken extends TokenType> = (designToken: DesignToken, derivativeToken?: DerivativeToken) => DerivativeToken; | ||
export type TokenType = object; | ||
export type DerivativeFunc<DesignToken extends TokenType, DerivativeToken extends TokenType> = (designToken: DesignToken, derivativeToken?: DerivativeToken) => DerivativeToken; |
import type Theme from './Theme'; | ||
import type { DerivativeFunc } from './interface'; | ||
declare type DerivativeOptions = DerivativeFunc<any, any>[]; | ||
type DerivativeOptions = DerivativeFunc<any, any>[]; | ||
export declare function sameDerivativeOption(left: DerivativeOptions, right: DerivativeOptions): boolean; | ||
@@ -5,0 +5,0 @@ export default class ThemeCache { |
@@ -16,2 +16,3 @@ "use strict"; | ||
var _dynamicCSS = require("rc-util/lib/Dom/dynamicCSS"); | ||
var _theme = require("./theme"); | ||
function flattenToken(token) { | ||
@@ -22,3 +23,5 @@ var str = ''; | ||
str += key; | ||
if (value && (0, _typeof2.default)(value) === 'object') { | ||
if (value instanceof _theme.Theme) { | ||
str += value.id; | ||
} else if (value && (0, _typeof2.default)(value) === 'object') { | ||
str += flattenToken(value); | ||
@@ -25,0 +28,0 @@ } else { |
{ | ||
"name": "@ant-design/cssinjs", | ||
"version": "1.14.0", | ||
"version": "1.15.0-alpha.0", | ||
"description": "Component level cssinjs resolution for antd", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
171992
3877
1