ant-design-x-vue 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +64 -0
- package/dist/index.mjs +3477 -0
- package/dist/index.umd.js +57 -0
- package/dist/typings/_util/cssinjs/Cache.d.ts +11 -0
- package/dist/typings/_util/cssinjs/Keyframes.d.ts +9 -0
- package/dist/typings/_util/cssinjs/StyleContext.d.ts +508 -0
- package/dist/typings/_util/cssinjs/hooks/useCSSVarRegister.d.ts +20 -0
- package/dist/typings/_util/cssinjs/hooks/useCacheToken.d.ts +40 -0
- package/dist/typings/_util/cssinjs/hooks/useGlobalCache.d.ts +6 -0
- package/dist/typings/_util/cssinjs/hooks/useHMR.d.ts +3 -0
- package/dist/typings/_util/cssinjs/hooks/useStyleRegister/cacheMapUtil.d.ts +14 -0
- package/dist/typings/_util/cssinjs/hooks/useStyleRegister/index.d.ts +69 -0
- package/dist/typings/_util/cssinjs/index.d.ts +197 -0
- package/dist/typings/_util/cssinjs/linters/contentQuotesLinter.d.ts +3 -0
- package/dist/typings/_util/cssinjs/linters/hashedAnimationLinter.d.ts +3 -0
- package/dist/typings/_util/cssinjs/linters/index.d.ts +6 -0
- package/dist/typings/_util/cssinjs/linters/interface.d.ts +8 -0
- package/dist/typings/_util/cssinjs/linters/legacyNotSelectorLinter.d.ts +3 -0
- package/dist/typings/_util/cssinjs/linters/logicalPropertiesLinter.d.ts +3 -0
- package/dist/typings/_util/cssinjs/linters/parentSelectorLinter.d.ts +3 -0
- package/dist/typings/_util/cssinjs/linters/utils.d.ts +2 -0
- package/dist/typings/_util/cssinjs/theme/Theme.d.ts +11 -0
- package/dist/typings/_util/cssinjs/theme/ThemeCache.d.ts +20 -0
- package/dist/typings/_util/cssinjs/theme/createTheme.d.ts +6 -0
- package/dist/typings/_util/cssinjs/theme/index.d.ts +4 -0
- package/dist/typings/_util/cssinjs/theme/interface.d.ts +2 -0
- package/dist/typings/_util/cssinjs/transformers/interface.d.ts +4 -0
- package/dist/typings/_util/cssinjs/transformers/legacyLogicalProperties.d.ts +12 -0
- package/dist/typings/_util/cssinjs/transformers/px2rem.d.ts +20 -0
- package/dist/typings/_util/cssinjs/util.d.ts +28 -0
- package/dist/typings/_util/cssinjs-utils/_util/hooks/useUniqueMemo.d.ts +5 -0
- package/dist/typings/_util/cssinjs-utils/hooks/useCSP.d.ts +8 -0
- package/dist/typings/_util/cssinjs-utils/hooks/usePrefix.d.ts +11 -0
- package/dist/typings/_util/cssinjs-utils/hooks/useToken.d.ts +20 -0
- package/dist/typings/_util/cssinjs-utils/index.d.ts +6 -0
- package/dist/typings/_util/cssinjs-utils/interface/components.d.ts +10 -0
- package/dist/typings/_util/cssinjs-utils/interface/index.d.ts +3 -0
- package/dist/typings/_util/cssinjs-utils/util/calc/CSSCalculator.d.ts +15 -0
- package/dist/typings/_util/cssinjs-utils/util/calc/NumCalculator.d.ts +11 -0
- package/dist/typings/_util/cssinjs-utils/util/calc/calculator.d.ts +30 -0
- package/dist/typings/_util/cssinjs-utils/util/calc/index.d.ts +5 -0
- package/dist/typings/_util/cssinjs-utils/util/genStyleUtils.d.ts +116 -0
- package/dist/typings/_util/cssinjs-utils/util/getCompVarPrefix.d.ts +2 -0
- package/dist/typings/_util/cssinjs-utils/util/getComponentToken.d.ts +9 -0
- package/dist/typings/_util/cssinjs-utils/util/getDefaultComponentToken.d.ts +5 -0
- package/dist/typings/_util/cssinjs-utils/util/maxmin.d.ts +8 -0
- package/dist/typings/_util/cssinjs-utils/util/statistic.d.ts +20 -0
- package/dist/typings/_util/hooks/use-event-callback.d.ts +1 -0
- package/dist/typings/_util/hooks/use-state.d.ts +2 -0
- package/dist/typings/_util/hooks/use-x-component-config.d.ts +4 -0
- package/dist/typings/_util/pick-attrs.d.ts +11 -0
- package/dist/typings/_util/type.d.ts +62 -0
- package/dist/typings/_util/warning.d.ts +47 -0
- package/dist/typings/bubble/Bubble.vue.d.ts +5 -0
- package/dist/typings/bubble/BubbleList.vue.d.ts +11 -0
- package/dist/typings/bubble/context.d.ts +21 -0
- package/dist/typings/bubble/hooks/useDisplayData.d.ts +5 -0
- package/dist/typings/bubble/hooks/useListData.d.ts +5 -0
- package/dist/typings/bubble/hooks/useTypedEffect.d.ts +7 -0
- package/dist/typings/bubble/hooks/useTypingConfig.d.ts +5 -0
- package/dist/typings/bubble/index.d.ts +5 -0
- package/dist/typings/bubble/interface.d.ts +67 -0
- package/dist/typings/bubble/loading.vue.d.ts +5 -0
- package/dist/typings/bubble/style/content.d.ts +4 -0
- package/dist/typings/bubble/style/index.d.ts +8 -0
- package/dist/typings/bubble/style/list.d.ts +4 -0
- package/dist/typings/index.d.ts +2 -0
- package/dist/typings/theme/components.d.ts +4 -0
- package/dist/typings/theme/cssinjs-utils.d.ts +14 -0
- package/dist/typings/theme/genStyleUtils.d.ts +27 -0
- package/dist/typings/theme/patch-antd.d.ts +28 -0
- package/dist/typings/theme/useToken.d.ts +18 -0
- package/dist/typings/vc-util/Dom/canUseDom.d.ts +1 -0
- package/dist/typings/vc-util/Dom/contains.d.ts +1 -0
- package/dist/typings/vc-util/Dom/dynamicCSS.d.ts +20 -0
- package/dist/typings/vc-util/warning.d.ts +7 -0
- package/dist/typings/version/index.d.ts +2 -0
- package/dist/typings/version/version.d.ts +2 -0
- package/dist/typings/x-provider/context.d.ts +36 -0
- package/dist/typings/x-provider/hooks/use-x-provider-context.d.ts +9 -0
- package/dist/typings/x-provider/index.d.ts +5 -0
- package/dist/typings/x-provider/index.vue.d.ts +20 -0
- package/package.json +125 -0
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import useCacheToken from './hooks/useCacheToken';
|
|
2
|
+
import useCSSVarRegister from './hooks/useCSSVarRegister';
|
|
3
|
+
import type { CSSInterpolation, CSSObject } from './hooks/useStyleRegister';
|
|
4
|
+
import useStyleRegister, { extractStyle } from './hooks/useStyleRegister';
|
|
5
|
+
import Keyframes from './Keyframes';
|
|
6
|
+
import type { Linter } from './linters';
|
|
7
|
+
import { legacyNotSelectorLinter, logicalPropertiesLinter, parentSelectorLinter } from './linters';
|
|
8
|
+
import type { StyleContextProps, StyleProviderProps } from './StyleContext';
|
|
9
|
+
import { createCache, useStyleInject, useStyleProvider, StyleProvider } from './StyleContext';
|
|
10
|
+
import type { DerivativeFunc, TokenType } from './theme';
|
|
11
|
+
import { createTheme, Theme } from './theme';
|
|
12
|
+
import type { Transformer } from './transformers/interface';
|
|
13
|
+
import legacyLogicalPropertiesTransformer from './transformers/legacyLogicalProperties';
|
|
14
|
+
import px2remTransformer from './transformers/px2rem';
|
|
15
|
+
import { unit, token2CSSVar } from './util';
|
|
16
|
+
declare const cssinjs: {
|
|
17
|
+
Theme: typeof Theme;
|
|
18
|
+
createTheme: typeof createTheme;
|
|
19
|
+
useStyleRegister: typeof useStyleRegister;
|
|
20
|
+
useCacheToken: typeof useCacheToken;
|
|
21
|
+
createCache: typeof createCache;
|
|
22
|
+
useStyleInject: () => import("vue").ShallowRef<Partial<StyleContextProps>>;
|
|
23
|
+
useStyleProvider: (props: import("./StyleContext").UseStyleProviderProps) => import("vue").ShallowRef<Partial<StyleContextProps>, Partial<StyleContextProps>>;
|
|
24
|
+
Keyframes: typeof Keyframes;
|
|
25
|
+
extractStyle: typeof extractStyle;
|
|
26
|
+
legacyLogicalPropertiesTransformer: Transformer;
|
|
27
|
+
px2remTransformer: (options?: import("./transformers/px2rem").Options) => Transformer;
|
|
28
|
+
logicalPropertiesLinter: Linter;
|
|
29
|
+
legacyNotSelectorLinter: Linter;
|
|
30
|
+
parentSelectorLinter: Linter;
|
|
31
|
+
StyleProvider: {
|
|
32
|
+
new (...args: any[]): import("vue").CreateComponentPublicInstanceWithMixins<Readonly<import("vue").ExtractPropTypes<{
|
|
33
|
+
autoClear: {
|
|
34
|
+
type: BooleanConstructor;
|
|
35
|
+
default: boolean;
|
|
36
|
+
};
|
|
37
|
+
mock: {
|
|
38
|
+
type: import("vue").PropType<"server" | "client">;
|
|
39
|
+
default: "server" | "client";
|
|
40
|
+
};
|
|
41
|
+
cache: {
|
|
42
|
+
type: import("vue").PropType<import("./Cache").default>;
|
|
43
|
+
default: import("./Cache").default;
|
|
44
|
+
};
|
|
45
|
+
defaultCache: {
|
|
46
|
+
type: BooleanConstructor;
|
|
47
|
+
default: boolean;
|
|
48
|
+
};
|
|
49
|
+
hashPriority: {
|
|
50
|
+
type: import("vue").PropType<import("./StyleContext").HashPriority>;
|
|
51
|
+
default: import("./StyleContext").HashPriority;
|
|
52
|
+
};
|
|
53
|
+
container: {
|
|
54
|
+
type: import("vue").PropType<Element | ShadowRoot>;
|
|
55
|
+
default: Element | ShadowRoot;
|
|
56
|
+
};
|
|
57
|
+
ssrInline: {
|
|
58
|
+
type: BooleanConstructor;
|
|
59
|
+
default: boolean;
|
|
60
|
+
};
|
|
61
|
+
transformers: {
|
|
62
|
+
type: import("vue").PropType<Transformer[]>;
|
|
63
|
+
default: Transformer[];
|
|
64
|
+
};
|
|
65
|
+
linters: {
|
|
66
|
+
type: import("vue").PropType<Linter[]>;
|
|
67
|
+
default: Linter[];
|
|
68
|
+
};
|
|
69
|
+
}>> & Readonly<{}>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
70
|
+
[key: string]: any;
|
|
71
|
+
}>[], {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, import("vue").PublicProps, {
|
|
72
|
+
autoClear: boolean;
|
|
73
|
+
mock: "server" | "client";
|
|
74
|
+
cache: import("./Cache").default;
|
|
75
|
+
defaultCache: boolean;
|
|
76
|
+
hashPriority: import("./StyleContext").HashPriority;
|
|
77
|
+
container: Element | ShadowRoot;
|
|
78
|
+
ssrInline: boolean;
|
|
79
|
+
transformers: Transformer[];
|
|
80
|
+
linters: Linter[];
|
|
81
|
+
}, true, {}, {}, import("vue").GlobalComponents, import("vue").GlobalDirectives, string, {}, any, import("vue").ComponentProvideOptions, {
|
|
82
|
+
P: {};
|
|
83
|
+
B: {};
|
|
84
|
+
D: {};
|
|
85
|
+
C: {};
|
|
86
|
+
M: {};
|
|
87
|
+
Defaults: {};
|
|
88
|
+
}, Readonly<import("vue").ExtractPropTypes<{
|
|
89
|
+
autoClear: {
|
|
90
|
+
type: BooleanConstructor;
|
|
91
|
+
default: boolean;
|
|
92
|
+
};
|
|
93
|
+
mock: {
|
|
94
|
+
type: import("vue").PropType<"server" | "client">;
|
|
95
|
+
default: "server" | "client";
|
|
96
|
+
};
|
|
97
|
+
cache: {
|
|
98
|
+
type: import("vue").PropType<import("./Cache").default>;
|
|
99
|
+
default: import("./Cache").default;
|
|
100
|
+
};
|
|
101
|
+
defaultCache: {
|
|
102
|
+
type: BooleanConstructor;
|
|
103
|
+
default: boolean;
|
|
104
|
+
};
|
|
105
|
+
hashPriority: {
|
|
106
|
+
type: import("vue").PropType<import("./StyleContext").HashPriority>;
|
|
107
|
+
default: import("./StyleContext").HashPriority;
|
|
108
|
+
};
|
|
109
|
+
container: {
|
|
110
|
+
type: import("vue").PropType<Element | ShadowRoot>;
|
|
111
|
+
default: Element | ShadowRoot;
|
|
112
|
+
};
|
|
113
|
+
ssrInline: {
|
|
114
|
+
type: BooleanConstructor;
|
|
115
|
+
default: boolean;
|
|
116
|
+
};
|
|
117
|
+
transformers: {
|
|
118
|
+
type: import("vue").PropType<Transformer[]>;
|
|
119
|
+
default: Transformer[];
|
|
120
|
+
};
|
|
121
|
+
linters: {
|
|
122
|
+
type: import("vue").PropType<Linter[]>;
|
|
123
|
+
default: Linter[];
|
|
124
|
+
};
|
|
125
|
+
}>> & Readonly<{}>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
126
|
+
[key: string]: any;
|
|
127
|
+
}>[], {}, {}, {}, {
|
|
128
|
+
autoClear: boolean;
|
|
129
|
+
mock: "server" | "client";
|
|
130
|
+
cache: import("./Cache").default;
|
|
131
|
+
defaultCache: boolean;
|
|
132
|
+
hashPriority: import("./StyleContext").HashPriority;
|
|
133
|
+
container: Element | ShadowRoot;
|
|
134
|
+
ssrInline: boolean;
|
|
135
|
+
transformers: Transformer[];
|
|
136
|
+
linters: Linter[];
|
|
137
|
+
}>;
|
|
138
|
+
__isFragment?: never;
|
|
139
|
+
__isTeleport?: never;
|
|
140
|
+
__isSuspense?: never;
|
|
141
|
+
} & import("vue").ComponentOptionsBase<Readonly<import("vue").ExtractPropTypes<{
|
|
142
|
+
autoClear: {
|
|
143
|
+
type: BooleanConstructor;
|
|
144
|
+
default: boolean;
|
|
145
|
+
};
|
|
146
|
+
mock: {
|
|
147
|
+
type: import("vue").PropType<"server" | "client">;
|
|
148
|
+
default: "server" | "client";
|
|
149
|
+
};
|
|
150
|
+
cache: {
|
|
151
|
+
type: import("vue").PropType<import("./Cache").default>;
|
|
152
|
+
default: import("./Cache").default;
|
|
153
|
+
};
|
|
154
|
+
defaultCache: {
|
|
155
|
+
type: BooleanConstructor;
|
|
156
|
+
default: boolean;
|
|
157
|
+
};
|
|
158
|
+
hashPriority: {
|
|
159
|
+
type: import("vue").PropType<import("./StyleContext").HashPriority>;
|
|
160
|
+
default: import("./StyleContext").HashPriority;
|
|
161
|
+
};
|
|
162
|
+
container: {
|
|
163
|
+
type: import("vue").PropType<Element | ShadowRoot>;
|
|
164
|
+
default: Element | ShadowRoot;
|
|
165
|
+
};
|
|
166
|
+
ssrInline: {
|
|
167
|
+
type: BooleanConstructor;
|
|
168
|
+
default: boolean;
|
|
169
|
+
};
|
|
170
|
+
transformers: {
|
|
171
|
+
type: import("vue").PropType<Transformer[]>;
|
|
172
|
+
default: Transformer[];
|
|
173
|
+
};
|
|
174
|
+
linters: {
|
|
175
|
+
type: import("vue").PropType<Linter[]>;
|
|
176
|
+
default: Linter[];
|
|
177
|
+
};
|
|
178
|
+
}>> & Readonly<{}>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
179
|
+
[key: string]: any;
|
|
180
|
+
}>[], {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, {
|
|
181
|
+
autoClear: boolean;
|
|
182
|
+
mock: "server" | "client";
|
|
183
|
+
cache: import("./Cache").default;
|
|
184
|
+
defaultCache: boolean;
|
|
185
|
+
hashPriority: import("./StyleContext").HashPriority;
|
|
186
|
+
container: Element | ShadowRoot;
|
|
187
|
+
ssrInline: boolean;
|
|
188
|
+
transformers: Transformer[];
|
|
189
|
+
linters: Linter[];
|
|
190
|
+
}, {}, string, {}, import("vue").GlobalComponents, import("vue").GlobalDirectives, string, import("vue").ComponentProvideOptions> & (import("vue").VNodeProps & (import("vue").AllowedComponentProps & import("vue").ComponentCustomProps & import("vue").Plugin));
|
|
191
|
+
};
|
|
192
|
+
export { Theme, createTheme, useStyleRegister, useCacheToken, createCache, useStyleInject, useStyleProvider, Keyframes, extractStyle, legacyLogicalPropertiesTransformer, px2remTransformer, logicalPropertiesLinter, legacyNotSelectorLinter, parentSelectorLinter, StyleProvider, unit, token2CSSVar, useCSSVarRegister, };
|
|
193
|
+
export type { TokenType, CSSObject, CSSInterpolation, DerivativeFunc, Transformer, Linter, StyleContextProps, StyleProviderProps, };
|
|
194
|
+
export declare const _experimental: {
|
|
195
|
+
supportModernCSS: () => boolean;
|
|
196
|
+
};
|
|
197
|
+
export default cssinjs;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { default as contentQuotesLinter } from './contentQuotesLinter';
|
|
2
|
+
export { default as hashedAnimationLinter } from './hashedAnimationLinter';
|
|
3
|
+
export type { Linter } from './interface';
|
|
4
|
+
export { default as legacyNotSelectorLinter } from './legacyNotSelectorLinter';
|
|
5
|
+
export { default as logicalPropertiesLinter } from './logicalPropertiesLinter';
|
|
6
|
+
export { default as parentSelectorLinter } from './parentSelectorLinter';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { DerivativeFunc, TokenType } from './interface';
|
|
2
|
+
/**
|
|
3
|
+
* Theme with algorithms to derive tokens from design tokens.
|
|
4
|
+
* Use `createTheme` first which will help to manage the theme instance cache.
|
|
5
|
+
*/
|
|
6
|
+
export default class Theme<DesignToken extends TokenType, DerivativeToken extends TokenType> {
|
|
7
|
+
private derivatives;
|
|
8
|
+
readonly id: number;
|
|
9
|
+
constructor(derivatives: DerivativeFunc<DesignToken, DerivativeToken> | DerivativeFunc<DesignToken, DerivativeToken>[]);
|
|
10
|
+
getDerivativeToken(token: DesignToken): DerivativeToken;
|
|
11
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type Theme from './Theme';
|
|
2
|
+
import type { DerivativeFunc } from './interface';
|
|
3
|
+
type DerivativeOptions = DerivativeFunc<any, any>[];
|
|
4
|
+
export declare function sameDerivativeOption(left: DerivativeOptions, right: DerivativeOptions): boolean;
|
|
5
|
+
export default class ThemeCache {
|
|
6
|
+
static MAX_CACHE_SIZE: number;
|
|
7
|
+
static MAX_CACHE_OFFSET: number;
|
|
8
|
+
private readonly cache;
|
|
9
|
+
private keys;
|
|
10
|
+
private cacheCallTimes;
|
|
11
|
+
constructor();
|
|
12
|
+
size(): number;
|
|
13
|
+
private internalGet;
|
|
14
|
+
get(derivativeOption: DerivativeOptions): Theme<any, any> | undefined;
|
|
15
|
+
has(derivativeOption: DerivativeOptions): boolean;
|
|
16
|
+
set(derivativeOption: DerivativeOptions, value: Theme<any, any>): void;
|
|
17
|
+
private deleteByPath;
|
|
18
|
+
delete(derivativeOption: DerivativeOptions): Theme<any, any> | undefined;
|
|
19
|
+
}
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import Theme from './Theme';
|
|
2
|
+
import type { DerivativeFunc, TokenType } from './interface';
|
|
3
|
+
/**
|
|
4
|
+
* Same as new Theme, but will always return same one if `derivative` not changed.
|
|
5
|
+
*/
|
|
6
|
+
export default function createTheme<DesignToken extends TokenType, DerivativeToken extends TokenType>(derivatives: DerivativeFunc<DesignToken, DerivativeToken>[] | DerivativeFunc<DesignToken, DerivativeToken>): Theme<any, any>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Transformer } from './interface';
|
|
2
|
+
/**
|
|
3
|
+
* Convert css logical properties to legacy properties.
|
|
4
|
+
* Such as: `margin-block-start` to `margin-top`.
|
|
5
|
+
* Transform list:
|
|
6
|
+
* - inset
|
|
7
|
+
* - margin
|
|
8
|
+
* - padding
|
|
9
|
+
* - border
|
|
10
|
+
*/
|
|
11
|
+
declare const transform: Transformer;
|
|
12
|
+
export default transform;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Transformer } from './interface';
|
|
2
|
+
export interface Options {
|
|
3
|
+
/**
|
|
4
|
+
* The root font size.
|
|
5
|
+
* @default 16
|
|
6
|
+
*/
|
|
7
|
+
rootValue?: number;
|
|
8
|
+
/**
|
|
9
|
+
* The decimal numbers to allow the REM units to grow to.
|
|
10
|
+
* @default 5
|
|
11
|
+
*/
|
|
12
|
+
precision?: number;
|
|
13
|
+
/**
|
|
14
|
+
* Whether to allow px to be converted in media queries.
|
|
15
|
+
* @default false
|
|
16
|
+
*/
|
|
17
|
+
mediaQuery?: boolean;
|
|
18
|
+
}
|
|
19
|
+
declare const transform: (options?: Options) => Transformer;
|
|
20
|
+
export default transform;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export declare const ATTR_TOKEN = "data-token-hash";
|
|
2
|
+
export declare const ATTR_MARK = "data-css-hash";
|
|
3
|
+
export declare const ATTR_CACHE_PATH = "data-cache-path";
|
|
4
|
+
export type TokenWithCSSVar<V, T extends Record<string, V> = Record<string, V>> = {
|
|
5
|
+
[key in keyof T]?: string | V;
|
|
6
|
+
};
|
|
7
|
+
export declare function flattenToken(token: any): string;
|
|
8
|
+
/**
|
|
9
|
+
* Convert derivative token to key string
|
|
10
|
+
*/
|
|
11
|
+
export declare function token2key(token: any, salt: string): string;
|
|
12
|
+
export declare function supportLayer(): boolean;
|
|
13
|
+
export declare function supportWhere(): boolean;
|
|
14
|
+
export declare function supportLogicProps(): boolean;
|
|
15
|
+
export declare const isClientSide: boolean;
|
|
16
|
+
export declare function unit(num: string | number): string;
|
|
17
|
+
export declare const token2CSSVar: (token: string, prefix?: string) => string;
|
|
18
|
+
export declare function toStyleStr(style: string, tokenKey?: string, styleId?: string, customizeAttrs?: Record<string, string>, plain?: boolean): string;
|
|
19
|
+
export declare const serializeCSSVar: <T extends Record<string, any>>(cssVars: T, hashId: string, options?: {
|
|
20
|
+
scope?: string;
|
|
21
|
+
}) => string;
|
|
22
|
+
export declare const transformToken: <V, T extends Record<string, V> = Record<string, V>>(token: T, themeKey: string, config?: {
|
|
23
|
+
prefix?: string;
|
|
24
|
+
ignore?: { [key in keyof T]?: boolean; };
|
|
25
|
+
unitless?: { [key in keyof T]?: boolean; };
|
|
26
|
+
preserve?: { [key in keyof T]?: boolean; };
|
|
27
|
+
scope?: string;
|
|
28
|
+
}) => [TokenWithCSSVar<V, T>, string];
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type UsePrefix = () => {
|
|
2
|
+
/**
|
|
3
|
+
* All the component use `@ant-design/cssinjs-utils` should have same `rootPrefixCls`.
|
|
4
|
+
*/
|
|
5
|
+
rootPrefixCls: string;
|
|
6
|
+
/**
|
|
7
|
+
* `iconPrefixCls` comes from the setting of `@ant-design/icons`.
|
|
8
|
+
* Here maybe little coupling but everyone need use this.
|
|
9
|
+
*/
|
|
10
|
+
iconPrefixCls: string;
|
|
11
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Theme, TokenType } from '../../cssinjs';
|
|
2
|
+
import type { OverrideTokenMap, TokenMap, GlobalToken } from '../interface';
|
|
3
|
+
export type TokenMapWithTheme<CompTokenMap extends TokenMap, AliasToken extends TokenType, DesignToken extends TokenType> = {
|
|
4
|
+
[key in keyof OverrideTokenMap<CompTokenMap, AliasToken>]?: OverrideTokenMap<CompTokenMap, AliasToken>[key] & {
|
|
5
|
+
theme?: Theme<DesignToken, AliasToken>;
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
export interface UseTokenReturn<CompTokenMap extends TokenMap, AliasToken extends TokenType, DesignToken extends TokenType> {
|
|
9
|
+
token: GlobalToken<CompTokenMap, AliasToken>;
|
|
10
|
+
realToken?: GlobalToken<CompTokenMap, AliasToken>;
|
|
11
|
+
theme?: Theme<DesignToken, AliasToken>;
|
|
12
|
+
components?: TokenMapWithTheme<CompTokenMap, DesignToken, AliasToken>;
|
|
13
|
+
hashId?: string;
|
|
14
|
+
hashed?: string | boolean;
|
|
15
|
+
cssVar?: {
|
|
16
|
+
prefix?: string;
|
|
17
|
+
key?: string;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
export type UseToken<CompTokenMap extends TokenMap, DesignToken extends TokenType, AliasToken extends TokenType> = () => UseTokenReturn<CompTokenMap, DesignToken, AliasToken>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { default as genStyleUtils } from './util/genStyleUtils';
|
|
2
|
+
export { default as genCalc } from './util/calc';
|
|
3
|
+
export { default as statisticToken, merge as mergeToken, statistic } from './util/statistic';
|
|
4
|
+
export type { OverrideTokenMap, TokenMap, TokenMapKey, GlobalTokenWithComponent, ComponentToken, ComponentTokenKey, GlobalToken, } from './interface';
|
|
5
|
+
export type { default as AbstractCalculator } from './util/calc/calculator';
|
|
6
|
+
export type { FullToken, GetDefaultToken, GetDefaultTokenFn, GenStyleFn, TokenWithCommonCls, CSSUtil, } from './util/genStyleUtils';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { TokenType } from '../../cssinjs';
|
|
2
|
+
export type TokenMap = Record<PropertyKey, any>;
|
|
3
|
+
export type TokenMapKey<CompTokenMap extends TokenMap> = Extract<keyof CompTokenMap, string>;
|
|
4
|
+
export type GlobalToken<CompTokenMap extends TokenMap, AliasToken extends TokenType> = AliasToken & CompTokenMap;
|
|
5
|
+
export type OverrideTokenMap<CompTokenMap extends TokenMap, AliasToken extends TokenType> = {
|
|
6
|
+
[key in keyof CompTokenMap]: Partial<CompTokenMap[key]> & Partial<AliasToken>;
|
|
7
|
+
};
|
|
8
|
+
export type GlobalTokenWithComponent<CompTokenMap extends TokenMap, AliasToken extends TokenType, C extends TokenMapKey<CompTokenMap>> = GlobalToken<CompTokenMap, AliasToken> & CompTokenMap[C];
|
|
9
|
+
export type ComponentToken<CompTokenMap extends TokenMap, AliasToken extends TokenType, C extends TokenMapKey<CompTokenMap>> = Exclude<OverrideTokenMap<CompTokenMap, AliasToken>[C], undefined>;
|
|
10
|
+
export type ComponentTokenKey<CompTokenMap extends TokenMap, AliasToken extends TokenType, C extends TokenMapKey<CompTokenMap>> = keyof ComponentToken<CompTokenMap, AliasToken, C>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import AbstractCalculator from './calculator';
|
|
2
|
+
export default class CSSCalculator extends AbstractCalculator {
|
|
3
|
+
result: string;
|
|
4
|
+
unitlessCssVar: Set<string>;
|
|
5
|
+
lowPriority?: boolean;
|
|
6
|
+
constructor(num: number | string | AbstractCalculator, unitlessCssVar: Set<string>);
|
|
7
|
+
add(num: number | string | AbstractCalculator): this;
|
|
8
|
+
sub(num: number | string | AbstractCalculator): this;
|
|
9
|
+
mul(num: number | string | AbstractCalculator): this;
|
|
10
|
+
div(num: number | string | AbstractCalculator): this;
|
|
11
|
+
getResult(force?: boolean): string;
|
|
12
|
+
equal(options?: {
|
|
13
|
+
unit?: boolean;
|
|
14
|
+
}): string;
|
|
15
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import AbstractCalculator from './calculator';
|
|
2
|
+
declare class NumCalculator extends AbstractCalculator {
|
|
3
|
+
result: number;
|
|
4
|
+
constructor(num: number | string | AbstractCalculator);
|
|
5
|
+
add(num: number | string | AbstractCalculator): this;
|
|
6
|
+
sub(num: number | string | AbstractCalculator): this;
|
|
7
|
+
mul(num: number | string | AbstractCalculator): this;
|
|
8
|
+
div(num: number | string | AbstractCalculator): this;
|
|
9
|
+
equal(): number;
|
|
10
|
+
}
|
|
11
|
+
export default NumCalculator;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
declare abstract class AbstractCalculator {
|
|
2
|
+
/**
|
|
3
|
+
* @descCN 计算两数的和,例如:1 + 2
|
|
4
|
+
* @descEN Calculate the sum of two numbers, e.g. 1 + 2
|
|
5
|
+
*/
|
|
6
|
+
abstract add(num: number | string | AbstractCalculator): this;
|
|
7
|
+
/**
|
|
8
|
+
* @descCN 计算两数的差,例如:1 - 2
|
|
9
|
+
* @descEN Calculate the difference between two numbers, e.g. 1 - 2
|
|
10
|
+
*/
|
|
11
|
+
abstract sub(num: number | string | AbstractCalculator): this;
|
|
12
|
+
/**
|
|
13
|
+
* @descCN 计算两数的积,例如:1 * 2
|
|
14
|
+
* @descEN Calculate the product of two numbers, e.g. 1 * 2
|
|
15
|
+
*/
|
|
16
|
+
abstract mul(num: number | string | AbstractCalculator): this;
|
|
17
|
+
/**
|
|
18
|
+
* @descCN 计算两数的商,例如:1 / 2
|
|
19
|
+
* @descEN Calculate the quotient of two numbers, e.g. 1 / 2
|
|
20
|
+
*/
|
|
21
|
+
abstract div(num: number | string | AbstractCalculator): this;
|
|
22
|
+
/**
|
|
23
|
+
* @descCN 获取计算结果
|
|
24
|
+
* @descEN Get the calculation result
|
|
25
|
+
*/
|
|
26
|
+
abstract equal(options?: {
|
|
27
|
+
unit?: boolean;
|
|
28
|
+
}): string | number;
|
|
29
|
+
}
|
|
30
|
+
export default AbstractCalculator;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type AbstractCalculator from './calculator';
|
|
2
|
+
import CSSCalculator from './CSSCalculator';
|
|
3
|
+
import NumCalculator from './NumCalculator';
|
|
4
|
+
declare const genCalc: (type: "css" | "js", unitlessCssVar: Set<string>) => (num: number | string | AbstractCalculator) => CSSCalculator | NumCalculator;
|
|
5
|
+
export default genCalc;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import type { CSSInterpolation, CSSObject, TokenType } from '../../cssinjs';
|
|
2
|
+
import { useStyleRegister } from '../../cssinjs';
|
|
3
|
+
import type { ComponentTokenKey, GlobalTokenWithComponent, TokenMap, TokenMapKey, UseComponentStyleResult } from '../interface';
|
|
4
|
+
import type AbstractCalculator from './calc/calculator';
|
|
5
|
+
import { MaybeRefOrGetter, type VNode } from 'vue';
|
|
6
|
+
import type { UseCSP } from '../hooks/useCSP';
|
|
7
|
+
import type { UsePrefix } from '../hooks/usePrefix';
|
|
8
|
+
import type { UseToken } from '../hooks/useToken';
|
|
9
|
+
type LayerConfig = Parameters<typeof useStyleRegister>[0]['layer'];
|
|
10
|
+
export interface StyleInfo {
|
|
11
|
+
hashId: string;
|
|
12
|
+
prefixCls: string;
|
|
13
|
+
rootPrefixCls: string;
|
|
14
|
+
iconPrefixCls: string;
|
|
15
|
+
}
|
|
16
|
+
export type CSSUtil = {
|
|
17
|
+
calc: (number: any) => AbstractCalculator;
|
|
18
|
+
max: (...values: (number | string)[]) => number | string;
|
|
19
|
+
min: (...values: (number | string)[]) => number | string;
|
|
20
|
+
};
|
|
21
|
+
export type TokenWithCommonCls<T> = T & {
|
|
22
|
+
/** Wrap component class with `.` prefix */
|
|
23
|
+
componentCls: string;
|
|
24
|
+
/** Origin prefix which do not have `.` prefix */
|
|
25
|
+
prefixCls: string;
|
|
26
|
+
/** Wrap icon class with `.` prefix */
|
|
27
|
+
iconCls: string;
|
|
28
|
+
/** Wrap ant prefixCls class with `.` prefix */
|
|
29
|
+
antCls: string;
|
|
30
|
+
} & CSSUtil;
|
|
31
|
+
export type FullToken<CompTokenMap extends TokenMap, AliasToken extends TokenType, C extends TokenMapKey<CompTokenMap>> = TokenWithCommonCls<GlobalTokenWithComponent<CompTokenMap, AliasToken, C>>;
|
|
32
|
+
export type GenStyleFn<CompTokenMap extends TokenMap, AliasToken extends TokenType, C extends TokenMapKey<CompTokenMap>> = (token: FullToken<CompTokenMap, AliasToken, C>, info: StyleInfo) => CSSInterpolation;
|
|
33
|
+
export type GetDefaultTokenFn<CompTokenMap extends TokenMap, AliasToken extends TokenType, C extends TokenMapKey<CompTokenMap>> = (token: AliasToken & Partial<CompTokenMap[C]>) => CompTokenMap[C];
|
|
34
|
+
export type GetDefaultToken<CompTokenMap extends TokenMap, AliasToken extends TokenType, C extends TokenMapKey<CompTokenMap>> = null | CompTokenMap[C] | GetDefaultTokenFn<CompTokenMap, AliasToken, C>;
|
|
35
|
+
export interface SubStyleComponentProps {
|
|
36
|
+
prefixCls: string;
|
|
37
|
+
rootCls?: string;
|
|
38
|
+
}
|
|
39
|
+
export type CSSVarRegisterProps = {
|
|
40
|
+
rootCls: string;
|
|
41
|
+
component: string;
|
|
42
|
+
cssVar: {
|
|
43
|
+
prefix?: string;
|
|
44
|
+
key?: string;
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
type GetResetStylesConfig = {
|
|
48
|
+
prefix: ReturnType<UsePrefix>;
|
|
49
|
+
csp: ReturnType<UseCSP>;
|
|
50
|
+
};
|
|
51
|
+
export type GetResetStyles<AliasToken extends TokenType> = (token: AliasToken, config?: GetResetStylesConfig) => CSSInterpolation;
|
|
52
|
+
export type GetCompUnitless<CompTokenMap extends TokenMap, AliasToken extends TokenType> = <C extends TokenMapKey<CompTokenMap>>(component: C | [C, string]) => Partial<Record<ComponentTokenKey<CompTokenMap, AliasToken, C>, boolean>>;
|
|
53
|
+
declare function genStyleUtils<CompTokenMap extends TokenMap, AliasToken extends TokenType, DesignToken extends TokenType>(config: {
|
|
54
|
+
usePrefix: UsePrefix;
|
|
55
|
+
useToken: UseToken<CompTokenMap, AliasToken, DesignToken>;
|
|
56
|
+
useCSP?: UseCSP;
|
|
57
|
+
getResetStyles?: GetResetStyles<AliasToken>;
|
|
58
|
+
getCommonStyle?: (token: AliasToken, componentPrefixCls: string, rootCls?: string, resetFont?: boolean) => CSSObject;
|
|
59
|
+
getCompUnitless?: GetCompUnitless<CompTokenMap, AliasToken>;
|
|
60
|
+
layer?: LayerConfig;
|
|
61
|
+
}): {
|
|
62
|
+
genStyleHooks: <C extends TokenMapKey<CompTokenMap>>(component: C | [C, string], styleFn: GenStyleFn<CompTokenMap, AliasToken, C>, getDefaultToken?: GetDefaultToken<CompTokenMap, AliasToken, C>, options?: {
|
|
63
|
+
resetStyle?: boolean;
|
|
64
|
+
resetFont?: boolean;
|
|
65
|
+
deprecatedTokens?: [ComponentTokenKey<CompTokenMap, AliasToken, C>, ComponentTokenKey<CompTokenMap, AliasToken, C>][];
|
|
66
|
+
/**
|
|
67
|
+
* Component tokens that do not need unit.
|
|
68
|
+
*/
|
|
69
|
+
unitless?: Partial<Record<ComponentTokenKey<CompTokenMap, AliasToken, C>, boolean>>;
|
|
70
|
+
/**
|
|
71
|
+
* Only use component style in client side. Ignore in SSR.
|
|
72
|
+
*/
|
|
73
|
+
clientOnly?: boolean;
|
|
74
|
+
/**
|
|
75
|
+
* Set order of component style.
|
|
76
|
+
* @default -999
|
|
77
|
+
*/
|
|
78
|
+
order?: number;
|
|
79
|
+
/**
|
|
80
|
+
* Whether generate styles
|
|
81
|
+
* @default true
|
|
82
|
+
*/
|
|
83
|
+
injectStyle?: boolean;
|
|
84
|
+
}) => (prefixCls: MaybeRefOrGetter<string>, rootCls?: string) => readonly [(node: VNode) => VNode, string, string];
|
|
85
|
+
genSubStyleComponent: <C extends TokenMapKey<CompTokenMap>>(componentName: C | [C, string], styleFn: GenStyleFn<CompTokenMap, AliasToken, C>, getDefaultToken?: GetDefaultToken<CompTokenMap, AliasToken, C>, options?: {
|
|
86
|
+
resetStyle?: boolean;
|
|
87
|
+
resetFont?: boolean;
|
|
88
|
+
deprecatedTokens?: [ComponentTokenKey<CompTokenMap, AliasToken, C>, ComponentTokenKey<CompTokenMap, AliasToken, C>][];
|
|
89
|
+
/**
|
|
90
|
+
* Only use component style in client side. Ignore in SSR.
|
|
91
|
+
*/
|
|
92
|
+
clientOnly?: boolean;
|
|
93
|
+
/**
|
|
94
|
+
* Set order of component style. Default is -999.
|
|
95
|
+
*/
|
|
96
|
+
order?: number;
|
|
97
|
+
injectStyle?: boolean;
|
|
98
|
+
unitless?: Partial<Record<ComponentTokenKey<CompTokenMap, AliasToken, C>, boolean>>;
|
|
99
|
+
}) => any;
|
|
100
|
+
genComponentStyleHook: <C extends TokenMapKey<CompTokenMap>>(componentName: C | [C, string], styleFn: GenStyleFn<CompTokenMap, AliasToken, C>, getDefaultToken?: GetDefaultToken<CompTokenMap, AliasToken, C>, options?: {
|
|
101
|
+
resetStyle?: boolean;
|
|
102
|
+
resetFont?: boolean;
|
|
103
|
+
deprecatedTokens?: [ComponentTokenKey<CompTokenMap, AliasToken, C>, ComponentTokenKey<CompTokenMap, AliasToken, C>][];
|
|
104
|
+
/**
|
|
105
|
+
* Only use component style in client side. Ignore in SSR.
|
|
106
|
+
*/
|
|
107
|
+
clientOnly?: boolean;
|
|
108
|
+
/**
|
|
109
|
+
* Set order of component style. Default is -999.
|
|
110
|
+
*/
|
|
111
|
+
order?: number;
|
|
112
|
+
injectStyle?: boolean;
|
|
113
|
+
unitless?: Partial<Record<ComponentTokenKey<CompTokenMap, AliasToken, C>, boolean>>;
|
|
114
|
+
}) => (prefixCls: string, rootCls?: string) => UseComponentStyleResult;
|
|
115
|
+
};
|
|
116
|
+
export default genStyleUtils;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { TokenMap, TokenMapKey, ComponentTokenKey, GlobalToken } from '../interface';
|
|
2
|
+
import type { TokenType } from '../../cssinjs';
|
|
3
|
+
declare function getComponentToken<CompTokenMap extends TokenMap, AliasToken extends TokenType, C extends TokenMapKey<CompTokenMap>>(component: C, token: GlobalToken<CompTokenMap, AliasToken>, defaultToken: CompTokenMap[C], options?: {
|
|
4
|
+
deprecatedTokens?: [
|
|
5
|
+
ComponentTokenKey<CompTokenMap, AliasToken, C>,
|
|
6
|
+
ComponentTokenKey<CompTokenMap, AliasToken, C>
|
|
7
|
+
][];
|
|
8
|
+
}): any;
|
|
9
|
+
export default getComponentToken;
|