@antdv-vue/pro-provider 0.0.0-stage → 2.0.0

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.
Files changed (92) hide show
  1. package/CHANGELOG.md +68 -0
  2. package/README.md +136 -2
  3. package/dist/ConfigProviderContainer.d.ts +10 -0
  4. package/dist/ConfigProviderContainer.js +207 -0
  5. package/dist/ProConfigProvider.d.ts +12 -0
  6. package/dist/ProConfigProvider.js +115 -0
  7. package/dist/context.d.ts +2810 -0
  8. package/dist/context.js +37 -0
  9. package/dist/index.d.ts +8 -0
  10. package/dist/index.js +7 -0
  11. package/dist/intl.d.ts +220 -0
  12. package/dist/intl.js +188 -0
  13. package/dist/locale/ar_EG.d.ts +6 -0
  14. package/dist/locale/ar_EG.js +99 -0
  15. package/dist/locale/ca_ES.d.ts +6 -0
  16. package/dist/locale/ca_ES.js +99 -0
  17. package/dist/locale/cs_CZ.d.ts +6 -0
  18. package/dist/locale/cs_CZ.js +99 -0
  19. package/dist/locale/de_DE.d.ts +6 -0
  20. package/dist/locale/de_DE.js +99 -0
  21. package/dist/locale/en_GB.d.ts +6 -0
  22. package/dist/locale/en_GB.js +99 -0
  23. package/dist/locale/en_US.d.ts +6 -0
  24. package/dist/locale/en_US.js +99 -0
  25. package/dist/locale/es_ES.d.ts +6 -0
  26. package/dist/locale/es_ES.js +99 -0
  27. package/dist/locale/fa_IR.d.ts +6 -0
  28. package/dist/locale/fa_IR.js +99 -0
  29. package/dist/locale/fr_FR.d.ts +6 -0
  30. package/dist/locale/fr_FR.js +99 -0
  31. package/dist/locale/he_IL.d.ts +6 -0
  32. package/dist/locale/he_IL.js +99 -0
  33. package/dist/locale/hr_HR.d.ts +6 -0
  34. package/dist/locale/hr_HR.js +99 -0
  35. package/dist/locale/id_ID.d.ts +6 -0
  36. package/dist/locale/id_ID.js +99 -0
  37. package/dist/locale/it_IT.d.ts +6 -0
  38. package/dist/locale/it_IT.js +99 -0
  39. package/dist/locale/ja_JP.d.ts +6 -0
  40. package/dist/locale/ja_JP.js +99 -0
  41. package/dist/locale/ko_KR.d.ts +6 -0
  42. package/dist/locale/ko_KR.js +99 -0
  43. package/dist/locale/mn_MN.d.ts +6 -0
  44. package/dist/locale/mn_MN.js +99 -0
  45. package/dist/locale/ms_MY.d.ts +6 -0
  46. package/dist/locale/ms_MY.js +99 -0
  47. package/dist/locale/nl_NL.d.ts +6 -0
  48. package/dist/locale/nl_NL.js +99 -0
  49. package/dist/locale/pl_PL.d.ts +6 -0
  50. package/dist/locale/pl_PL.js +99 -0
  51. package/dist/locale/pt_BR.d.ts +6 -0
  52. package/dist/locale/pt_BR.js +99 -0
  53. package/dist/locale/ro_RO.d.ts +6 -0
  54. package/dist/locale/ro_RO.js +99 -0
  55. package/dist/locale/ru_RU.d.ts +6 -0
  56. package/dist/locale/ru_RU.js +99 -0
  57. package/dist/locale/sk_SK.d.ts +6 -0
  58. package/dist/locale/sk_SK.js +99 -0
  59. package/dist/locale/sr_RS.d.ts +6 -0
  60. package/dist/locale/sr_RS.js +99 -0
  61. package/dist/locale/sv_SE.d.ts +6 -0
  62. package/dist/locale/sv_SE.js +99 -0
  63. package/dist/locale/th_TH.d.ts +6 -0
  64. package/dist/locale/th_TH.js +99 -0
  65. package/dist/locale/tr_TR.d.ts +6 -0
  66. package/dist/locale/tr_TR.js +99 -0
  67. package/dist/locale/uk_UA.d.ts +6 -0
  68. package/dist/locale/uk_UA.js +99 -0
  69. package/dist/locale/uz_UZ.d.ts +6 -0
  70. package/dist/locale/uz_UZ.js +99 -0
  71. package/dist/locale/vi_VN.d.ts +6 -0
  72. package/dist/locale/vi_VN.js +99 -0
  73. package/dist/locale/zh_CN.d.ts +112 -0
  74. package/dist/locale/zh_CN.js +106 -0
  75. package/dist/locale/zh_HK.d.ts +6 -0
  76. package/dist/locale/zh_HK.js +99 -0
  77. package/dist/locale/zh_TW.d.ts +6 -0
  78. package/dist/locale/zh_TW.js +99 -0
  79. package/dist/pro-provider.esm.js +4147 -0
  80. package/dist/typing/layoutToken.d.ts +625 -0
  81. package/dist/typing/layoutToken.js +72 -0
  82. package/dist/typing.d.ts +99 -0
  83. package/dist/typing.js +1 -0
  84. package/dist/useStyle/index.d.ts +162 -0
  85. package/dist/useStyle/index.js +254 -0
  86. package/dist/useStyle/token.d.ts +35 -0
  87. package/dist/useStyle/token.js +421 -0
  88. package/dist/utils/index.d.ts +13 -0
  89. package/dist/utils/index.js +21 -0
  90. package/dist/utils/merge.d.ts +20 -0
  91. package/dist/utils/merge.js +36 -0
  92. package/package.json +65 -3
@@ -0,0 +1,99 @@
1
+ import { IntlType } from "./intl.js";
2
+ import { DeepPartial } from "./typing/layoutToken.js";
3
+ import { ProAliasToken } from "./useStyle/index.js";
4
+ import { VueNode } from "@v-c/util/dist/type";
5
+ import { Key } from "antdv-next/dist/table/interface";
6
+
7
+ //#region src/typing.d.ts
8
+ interface ProConfigProviderProps {
9
+ dark?: boolean;
10
+ compact?: boolean;
11
+ needDeps?: boolean;
12
+ token?: DeepPartial<ProAliasToken>;
13
+ prefixCls?: string;
14
+ valueTypeMap?: Record<string, ProRenderFieldPropsType>;
15
+ hashed?: boolean;
16
+ intl?: IntlType;
17
+ }
18
+ /**
19
+ * 用于配置 ValueEnum 的通用配置
20
+ */
21
+ interface ProSchemaValueEnumType {
22
+ /** @name text 演示的文案 */
23
+ text: VueNode;
24
+ /** @name status 预定的颜色 */
25
+ status?: string;
26
+ /** @name color 自定义的颜色 */
27
+ color?: string;
28
+ /** @name disabled 是否禁用 */
29
+ disabled?: boolean;
30
+ }
31
+ /**
32
+ * 支持 Map 和 Object
33
+ *
34
+ * @name ProSchemaValueEnumMap ValueEnum 的类型
35
+ */
36
+ type ProSchemaValueEnumMap = Map<string | number | boolean, ProSchemaValueEnumType | VueNode>;
37
+ /**
38
+ * 支持 Map 和 Object
39
+ */
40
+ type ProSchemaValueEnumObj = Record<string, ProSchemaValueEnumType | VueNode>;
41
+ type ProFieldFCMode = 'read' | 'edit' | 'update';
42
+ /**
43
+ * BaseProFieldFC 的类型设置
44
+ */
45
+ interface BaseProFieldFC<T = any> {
46
+ /** 值的类型 */
47
+ text?: VueNode;
48
+ 'onUpdate:text'?: (text: VueNode) => void;
49
+ /** 放置到组件上 props */
50
+ fieldProps?: T;
51
+ /**
52
+ * 组件的渲染模式类型
53
+ * @option read 渲染只读模式
54
+ * @option edit 渲染编辑模式
55
+ * @option update 渲染更新模式
56
+ */
57
+ mode?: ProFieldFCMode;
58
+ /** 轻量模式 */
59
+ light?: boolean;
60
+ /** Label */
61
+ label?: VueNode;
62
+ /** 映射值的类型 */
63
+ valueEnum?: ProSchemaValueEnumObj | ProSchemaValueEnumMap;
64
+ /** 唯一的key,用于网络请求 */
65
+ proFieldKey?: Key;
66
+ }
67
+ /** Render 第二个参数,里面包含了一些常用的参数 */
68
+ type ProFieldFCRenderProps<T = any> = {
69
+ mode?: ProFieldFCMode;
70
+ readonly?: boolean;
71
+ placeholder?: string | string[];
72
+ value?: any;
73
+ 'onUpdate:value'?: (value: any) => void;
74
+ onChange?: (...rest: any[]) => void;
75
+ } & BaseProFieldFC<T>;
76
+ interface ProRenderFieldPropsType<T = any> {
77
+ /**
78
+ * 自定义只读模式的渲染器
79
+ * @params props 关于dom的配置
80
+ * @params dom 默认的 dom
81
+ * @return 返回一个用于读的 dom
82
+ */
83
+ render?: ((text: any, props: Omit<ProFieldFCRenderProps<T>, 'value' | 'onUpdate:value' | 'onChange'> & {
84
+ [key: string]: any;
85
+ }, dom: VueNode) => VueNode);
86
+ /**
87
+ * 一个自定义的编辑渲染器。
88
+ * @params text 默认的值类型
89
+ * @params props 关于dom的配置
90
+ * @params dom 默认的 dom
91
+ * @return 返回一个用于编辑的dom
92
+ */
93
+ formItemRender?: ((text: any, props: ProFieldFCRenderProps<T> & {
94
+ [key: string]: any;
95
+ }, dom: VueNode) => VueNode);
96
+ }
97
+ type ParamsType = Record<string, any>;
98
+ //#endregion
99
+ export { BaseProFieldFC, ParamsType, ProConfigProviderProps, ProFieldFCMode, ProFieldFCRenderProps, ProRenderFieldPropsType, ProSchemaValueEnumType };
package/dist/typing.js ADDED
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,162 @@
1
+ import { ProFlattenTokenType, ProTokenType } from "../typing/layoutToken.js";
2
+ import { hashCode } from "./token.js";
3
+ import * as _$vue from "vue";
4
+ import { Ref } from "vue";
5
+ import * as _$_antdv_next_cssinjs0 from "@antdv-next/cssinjs";
6
+ import { CSSObject, StyleInfo, Theme, TokenMap, genCalc } from "@antdv-next/cssinjs";
7
+ import { GlobalToken } from "antdv-next";
8
+ import genMaxMin from "@antdv-next/cssinjs/dist/cssinjs-utils/util/maxmin";
9
+ import * as _$antdv_next_dist_theme_internal0 from "antdv-next/dist/theme/internal";
10
+ import * as _$antdv_next_dist_theme_themes_default_index0 from "antdv-next/dist/theme/themes/default/index";
11
+ import * as _$antdv_next_dist_theme_interface_index0 from "antdv-next/dist/theme/interface/index";
12
+ import { AliasToken, CSSInterpolation } from "antdv-next/dist/theme/interface/index";
13
+ import * as _$antdv_next_dist_theme_getDesignToken0 from "antdv-next/dist/theme/getDesignToken";
14
+
15
+ //#region src/useStyle/index.d.ts
16
+ /**
17
+ * 把一个颜色设置一下透明度
18
+ * @example (#fff, 0.5) => rgba(255, 255, 255, 0.5)
19
+ * @param baseColor {string}
20
+ * @param alpha {number} 0-1
21
+ * @returns rgba {string}
22
+ */
23
+ declare function setAlpha(baseColor: string, alpha: number): string;
24
+ /**
25
+ * 把一个颜色修改一些明度
26
+ * @example (#000, 50) => #808080
27
+ * @param baseColor {string}
28
+ * @param brightness {number} 0-100
29
+ * @returns hexColor {string}
30
+ */
31
+ declare function lighten(baseColor: string, brightness: number): string;
32
+ type GenerateStyle<ComponentToken extends object = GlobalToken, ReturnType = CSSInterpolation> = (token: ComponentToken, ...rest: any[]) => ReturnType;
33
+ declare const proTheme: {
34
+ defaultSeed: _$antdv_next_dist_theme_internal0.SeedToken;
35
+ useToken: () => {
36
+ theme: _$vue.Ref<_$_antdv_next_cssinjs0.Theme<_$antdv_next_dist_theme_internal0.SeedToken, AliasToken>, _$_antdv_next_cssinjs0.Theme<_$antdv_next_dist_theme_internal0.SeedToken, AliasToken>>;
37
+ token: _$vue.Ref<GlobalToken, GlobalToken>;
38
+ hashId: _$vue.Ref<string, string>;
39
+ };
40
+ defaultAlgorithm: typeof _$antdv_next_dist_theme_themes_default_index0.default;
41
+ darkAlgorithm: _$_antdv_next_cssinjs0.DerivativeFunc<_$antdv_next_dist_theme_internal0.SeedToken, _$antdv_next_dist_theme_interface_index0.MapToken>;
42
+ compactAlgorithm: _$_antdv_next_cssinjs0.DerivativeFunc<_$antdv_next_dist_theme_internal0.SeedToken, _$antdv_next_dist_theme_interface_index0.MapToken>;
43
+ getDesignToken: typeof _$antdv_next_dist_theme_getDesignToken0.default;
44
+ defaultConfig: {
45
+ token: _$antdv_next_dist_theme_internal0.SeedToken;
46
+ override: {
47
+ override: _$antdv_next_dist_theme_internal0.SeedToken;
48
+ };
49
+ hashed: boolean;
50
+ };
51
+ } | {
52
+ useToken: () => {
53
+ theme: _$vue.ComputedRef<Theme<any, any>>;
54
+ token: _$vue.ComputedRef<GlobalToken>;
55
+ hashId: _$vue.ComputedRef<string>;
56
+ };
57
+ token: {
58
+ theme: _$vue.ComputedRef<Theme<any, any>>;
59
+ token: _$vue.ComputedRef<GlobalToken>;
60
+ hashId: _$vue.ComputedRef<string>;
61
+ };
62
+ emptyTheme: Theme<any, any>;
63
+ hashCode: typeof hashCode;
64
+ defaultToken: GlobalToken;
65
+ };
66
+ declare const useToken: (() => {
67
+ theme: _$vue.ComputedRef<Theme<any, any>>;
68
+ token: _$vue.ComputedRef<GlobalToken>;
69
+ hashId: _$vue.ComputedRef<string>;
70
+ }) | (() => {
71
+ theme: _$vue.Ref<_$_antdv_next_cssinjs0.Theme<_$antdv_next_dist_theme_internal0.SeedToken, AliasToken>, _$_antdv_next_cssinjs0.Theme<_$antdv_next_dist_theme_internal0.SeedToken, AliasToken>>;
72
+ token: _$vue.Ref<GlobalToken, GlobalToken>;
73
+ hashId: _$vue.Ref<string, string>;
74
+ });
75
+ type ProAliasToken = GlobalToken & ProTokenType & {
76
+ themeId: number;
77
+ /**
78
+ * pro 的 className
79
+ * @type {string}
80
+ * @example .ant-pro
81
+ */
82
+ proComponentsCls: string;
83
+ /**
84
+ * antd 的 className
85
+ * @type {string}
86
+ * @example .ant
87
+ */
88
+ antCls: string;
89
+ /**
90
+ * antd 的 iconCls
91
+ * @type {string}
92
+ * @example .anticon
93
+ */
94
+ iconCls?: string;
95
+ };
96
+ type ProAliasCssVarToken = GlobalToken & ProFlattenTokenType & {
97
+ componentCls: string;
98
+ themeId: number;
99
+ /**
100
+ * pro 的 className
101
+ * @type {string}
102
+ * @example .ant-pro
103
+ */
104
+ proComponentsCls: string;
105
+ /**
106
+ * antd 的 className
107
+ * @type {string}
108
+ * @example .ant
109
+ */
110
+ antCls: string;
111
+ /**
112
+ * antd 的 iconCls
113
+ * @type {string}
114
+ * @example .anticon
115
+ */
116
+ iconCls?: string;
117
+ calc: ReturnType<typeof genCalc>;
118
+ min: ReturnType<typeof genMaxMin>['min'];
119
+ max: ReturnType<typeof genMaxMin>['max'];
120
+ } & {
121
+ [key: string]: any;
122
+ };
123
+ declare function resetComponent(token: ProAliasToken): CSSObject;
124
+ declare function operationUnit(token: ProAliasToken): CSSObject;
125
+ declare const useStyle: (component: string | [string, string], styleFn: (token: ProAliasCssVarToken, info: StyleInfo & {
126
+ proComponentsCls: string;
127
+ }) => CSSInterpolation, getDefaultToken?: (token: AliasToken) => TokenMap, options?: {
128
+ /**
129
+ * Component tokens that do not need unit.
130
+ */
131
+ unitless?: Record<string, boolean>;
132
+ /**
133
+ * Only use component style in client side. Ignore in SSR.
134
+ */
135
+ clientOnly?: boolean;
136
+ /**
137
+ * Set order of component style.
138
+ * @default -999
139
+ */
140
+ order?: number;
141
+ /**
142
+ * Whether generate styles
143
+ * @default true
144
+ */
145
+ injectStyle?: boolean;
146
+ }) => (prefixCls: Ref<string>, rootCls?: Ref<string | undefined>) => readonly [Ref<string, string>, _$vue.ComputedRef<string | undefined>], genComponentStyleHook: (componentName: string | [string, string], styleFn: (token: ProAliasCssVarToken, info: StyleInfo & {
147
+ proComponentsCls: string;
148
+ }) => CSSInterpolation, getDefaultToken: ((token: AliasToken) => TokenMap) | undefined, options?: {
149
+ deprecatedTokens?: any[];
150
+ /**
151
+ * Only use component style in client side. Ignore in SSR.
152
+ */
153
+ clientOnly?: boolean;
154
+ /**
155
+ * Set order of component style. Default is -999.
156
+ */
157
+ order?: number;
158
+ injectStyle?: boolean;
159
+ unitless?: Record<string, boolean>;
160
+ }) => (prefixCls: Ref<string>) => Ref<string, string>;
161
+ //#endregion
162
+ export { GenerateStyle, ProAliasCssVarToken, ProAliasToken, genComponentStyleHook, lighten, operationUnit, proTheme, resetComponent, setAlpha, useStyle, useToken };
@@ -0,0 +1,254 @@
1
+ import { useProCacheToken, useProConfig } from "../context.js";
2
+ import token_default from "./token.js";
3
+ import { computed } from "vue";
4
+ import { genCalc, mergeToken, statisticToken, token2CSSVar, useCSSVarRegister } from "@antdv-next/cssinjs";
5
+ import { theme } from "antdv-next";
6
+ import { useConfig } from "antdv-next/config-provider/context";
7
+ import useLocalToken, { unitless } from "antdv-next/dist/theme/useToken";
8
+ import { FastColor } from "@ant-design/fast-color";
9
+ import useUniqueMemo from "@antdv-next/cssinjs/dist/cssinjs-utils/_util/hooks/useUniqueMemo";
10
+ import useDefaultCSP from "@antdv-next/cssinjs/dist/cssinjs-utils/hooks/useCSP";
11
+ import getComponentToken from "@antdv-next/cssinjs/dist/cssinjs-utils/util/getComponentToken";
12
+ import getCompVarPrefix from "@antdv-next/cssinjs/dist/cssinjs-utils/util/getCompVarPrefix";
13
+ import getDefaultComponentToken from "@antdv-next/cssinjs/dist/cssinjs-utils/util/getDefaultComponentToken";
14
+ import genMaxMin from "@antdv-next/cssinjs/dist/cssinjs-utils/util/maxmin";
15
+ import useStyleRegister from "@antdv-next/cssinjs/dist/hooks/useStyleRegister";
16
+ //#region src/useStyle/index.ts
17
+ /**
18
+ * 把一个颜色设置一下透明度
19
+ * @example (#fff, 0.5) => rgba(255, 255, 255, 0.5)
20
+ * @param baseColor {string}
21
+ * @param alpha {number} 0-1
22
+ * @returns rgba {string}
23
+ */
24
+ function setAlpha(baseColor, alpha) {
25
+ return new FastColor(baseColor).setA(alpha).toRgbString();
26
+ }
27
+ /**
28
+ * 把一个颜色修改一些明度
29
+ * @example (#000, 50) => #808080
30
+ * @param baseColor {string}
31
+ * @param brightness {number} 0-100
32
+ * @returns hexColor {string}
33
+ */
34
+ function lighten(baseColor, brightness) {
35
+ return new FastColor(baseColor).lighten(brightness).toHexString();
36
+ }
37
+ function genTheme() {
38
+ if (typeof theme === "undefined" || !theme) return token_default;
39
+ return theme;
40
+ }
41
+ const proTheme = genTheme();
42
+ const useToken = proTheme.useToken;
43
+ function resetComponent(token) {
44
+ return {
45
+ boxSizing: "border-box",
46
+ margin: 0,
47
+ padding: 0,
48
+ color: token.colorText,
49
+ fontSize: token.fontSize,
50
+ lineHeight: token.lineHeight,
51
+ listStyle: "none",
52
+ "*, *::before, *::after": { boxSizing: "border-box" }
53
+ };
54
+ }
55
+ function operationUnit(token) {
56
+ return {
57
+ color: token.colorLink,
58
+ outline: "none",
59
+ cursor: "pointer",
60
+ transition: `color ${token.motionDurationSlow}`,
61
+ "&:focus, &:hover": { color: token.colorLinkHover },
62
+ "&:active": { color: token.colorLinkActive }
63
+ };
64
+ }
65
+ function hashString(input) {
66
+ let hash = 5381;
67
+ for (let i = 0; i < input.length; i += 1) hash = hash * 33 ^ input.charCodeAt(i);
68
+ return (hash >>> 0).toString(36);
69
+ }
70
+ function genStyleUtils(config) {
71
+ const { useCSP = useDefaultCSP, useToken: useAntdToken, usePrefix, getCompUnitless } = config;
72
+ function genStyleHooks(component, styleFn, getDefaultToken, options) {
73
+ const componentName = Array.isArray(component) ? component[0] : component;
74
+ function prefixToken(key) {
75
+ return `${String(componentName)}${key.slice(0, 1).toUpperCase()}${key.slice(1)}`;
76
+ }
77
+ const originUnitless = options?.unitless || {};
78
+ const compUnitless = {
79
+ ...typeof getCompUnitless === "function" ? getCompUnitless() : {},
80
+ [prefixToken("zIndexPopup")]: true
81
+ };
82
+ Object.keys(originUnitless).forEach((key) => {
83
+ compUnitless[prefixToken(key)] = originUnitless[key];
84
+ });
85
+ const mergedOptions = {
86
+ ...options,
87
+ unitless: compUnitless,
88
+ prefixToken
89
+ };
90
+ const useStyle = genComponentStyleHook(component, styleFn, getDefaultToken, mergedOptions);
91
+ const useCSSVar = genCSSVarRegister(componentName, getDefaultToken, mergedOptions);
92
+ return (prefixCls, rootCls = prefixCls) => {
93
+ return [useStyle(prefixCls), useCSSVar(rootCls)];
94
+ };
95
+ }
96
+ function genCSSVarRegister(component, getDefaultToken, options) {
97
+ const { unitless: compUnitless, prefixToken, ignore } = options;
98
+ return (rootCls) => {
99
+ const { cssVar, hashId, realToken } = useAntdToken();
100
+ const csp = useCSP();
101
+ useCSSVarRegister(computed(() => {
102
+ const _cssVar = cssVar.value;
103
+ return {
104
+ path: [component],
105
+ prefix: _cssVar?.prefix,
106
+ key: _cssVar.key,
107
+ unitless: compUnitless,
108
+ ignore,
109
+ hashId: hashId?.value,
110
+ nonce: () => csp.value.nonce,
111
+ token: realToken?.value,
112
+ scope: rootCls.value
113
+ };
114
+ }), () => {
115
+ const defaultToken = getDefaultComponentToken(component, realToken.value, getDefaultToken);
116
+ const componentToken = getComponentToken(component, realToken.value, defaultToken, { deprecatedTokens: options?.deprecatedTokens });
117
+ if (defaultToken) Object.keys(defaultToken).forEach((key) => {
118
+ componentToken[prefixToken(key)] = componentToken[key];
119
+ delete componentToken[key];
120
+ });
121
+ return componentToken;
122
+ });
123
+ return computed(() => cssVar?.value?.key);
124
+ };
125
+ }
126
+ function genComponentStyleHook(componentName, styleFn, getDefaultToken, options = {}) {
127
+ const cells = Array.isArray(componentName) ? componentName : [componentName, componentName];
128
+ const [component] = cells;
129
+ const styleRegisterKey = `${cells.join("-")}-${hashString(styleFn.toString())}`;
130
+ const mergedLayer = config.layer || { name: "antd-pro" };
131
+ return (prefixCls) => {
132
+ const { theme, hashId, token, realToken, cssVar, zeroRuntime } = useAntdToken();
133
+ if (computed(() => {
134
+ return zeroRuntime?.value;
135
+ }).value) return hashId;
136
+ const prefix = usePrefix();
137
+ const csp = useCSP();
138
+ const type = "css";
139
+ const calc = computed(() => useUniqueMemo(() => {
140
+ const unitlessCssVar = /* @__PURE__ */ new Set();
141
+ Object.keys(options.unitless || {}).forEach((key) => {
142
+ unitlessCssVar.add(key);
143
+ unitlessCssVar.add(token2CSSVar(key, cssVar?.value?.prefix));
144
+ unitlessCssVar.add(token2CSSVar(key, getCompVarPrefix(component, cssVar?.value?.prefix)));
145
+ });
146
+ return genCalc(type, unitlessCssVar);
147
+ }, [
148
+ type,
149
+ component,
150
+ cssVar?.value?.prefix
151
+ ]));
152
+ const { max, min } = genMaxMin(type);
153
+ const sharedConfig = computed(() => {
154
+ return {
155
+ theme: theme?.value,
156
+ token: token?.value,
157
+ hashId: hashId?.value,
158
+ nonce: () => csp.value.nonce,
159
+ clientOnly: options.clientOnly,
160
+ layer: mergedLayer,
161
+ order: options.order || -999
162
+ };
163
+ });
164
+ const getMergedToken = () => {
165
+ const { token: proxyToken, flush } = statisticToken(token.value);
166
+ const tokenForCalc = realToken?.value || proxyToken;
167
+ const defaultComponentToken = getDefaultComponentToken(component, tokenForCalc, getDefaultToken);
168
+ const componentToken = getComponentToken(component, tokenForCalc, defaultComponentToken, { deprecatedTokens: options.deprecatedTokens });
169
+ if (defaultComponentToken && typeof defaultComponentToken === "object") Object.keys(defaultComponentToken).forEach((key) => {
170
+ defaultComponentToken[key] = `var(${token2CSSVar(key, getCompVarPrefix(component, cssVar?.value?.prefix))})`;
171
+ });
172
+ return {
173
+ componentToken,
174
+ flush,
175
+ mergedToken: mergeToken(proxyToken, {
176
+ componentCls: `.${prefixCls.value}`,
177
+ prefixCls: prefixCls.value,
178
+ proComponentsCls: `.${prefix.value.rootPrefixCls}-pro`,
179
+ iconCls: `.${prefix.value.iconPrefixCls}`,
180
+ antCls: `.${prefix.value.rootPrefixCls}`,
181
+ calc: calc.value,
182
+ max,
183
+ min
184
+ }, defaultComponentToken)
185
+ };
186
+ };
187
+ useStyleRegister(computed(() => {
188
+ return {
189
+ ...sharedConfig.value,
190
+ path: [
191
+ styleRegisterKey,
192
+ prefixCls.value,
193
+ prefix.value.iconPrefixCls
194
+ ]
195
+ };
196
+ }), () => {
197
+ if (options.injectStyle === false) return [];
198
+ const { componentToken, flush, mergedToken } = getMergedToken();
199
+ const styleInterpolation = styleFn(mergedToken, {
200
+ hashId: hashId.value,
201
+ prefixCls: prefixCls.value,
202
+ rootPrefixCls: prefix.value.rootPrefixCls,
203
+ iconPrefixCls: prefix.value.iconPrefixCls,
204
+ proComponentsCls: `${prefix.value.rootPrefixCls}-pro`
205
+ });
206
+ flush(component, componentToken);
207
+ return styleInterpolation;
208
+ });
209
+ return hashId;
210
+ };
211
+ }
212
+ return {
213
+ genStyleHooks,
214
+ genComponentStyleHook
215
+ };
216
+ }
217
+ const { genStyleHooks: useStyle, genComponentStyleHook } = genStyleUtils({
218
+ usePrefix: () => {
219
+ const configCtx = useConfig();
220
+ return computed(() => {
221
+ const { getPrefixCls, iconPrefixCls } = configCtx.value;
222
+ return {
223
+ rootPrefixCls: getPrefixCls(),
224
+ iconPrefixCls
225
+ };
226
+ });
227
+ },
228
+ useToken() {
229
+ const proProvide = useProConfig();
230
+ const { realToken: proRealToken, token: proToken } = useProCacheToken();
231
+ const [theme, localToken, localHashId, localRealToken, , zeroRuntime] = useLocalToken();
232
+ return {
233
+ theme,
234
+ realToken: computed(() => proRealToken?.value || localRealToken.value),
235
+ hashId: computed(() => {
236
+ if (proProvide.value.hashed === false) return "";
237
+ return proProvide.value.hashId ?? localHashId.value ?? "";
238
+ }),
239
+ token: computed(() => proToken?.value || localToken.value),
240
+ cssVar: computed(() => ({
241
+ prefix: "ant",
242
+ key: "css-var-pro"
243
+ })),
244
+ zeroRuntime
245
+ };
246
+ },
247
+ useCSP: () => {
248
+ const configCtx = useConfig();
249
+ return computed(() => configCtx.value?.csp ?? {});
250
+ },
251
+ getCompUnitless: () => unitless
252
+ });
253
+ //#endregion
254
+ export { genComponentStyleHook, lighten, operationUnit, proTheme, resetComponent, setAlpha, useStyle, useToken };
@@ -0,0 +1,35 @@
1
+ import * as _$vue from "vue";
2
+ import * as _$_antdv_next_cssinjs0 from "@antdv-next/cssinjs";
3
+ import { GlobalToken } from "antdv-next";
4
+
5
+ //#region src/useStyle/token.d.ts
6
+ declare const defaultToken: GlobalToken;
7
+ declare function hashCode(str: string, seed?: number): number;
8
+ declare const emptyTheme: _$_antdv_next_cssinjs0.Theme<any, any>;
9
+ declare const token: {
10
+ theme: _$vue.ComputedRef<_$_antdv_next_cssinjs0.Theme<any, any>>;
11
+ token: _$vue.ComputedRef<GlobalToken>;
12
+ hashId: _$vue.ComputedRef<string>;
13
+ };
14
+ declare const useToken: () => {
15
+ theme: _$vue.ComputedRef<_$_antdv_next_cssinjs0.Theme<any, any>>;
16
+ token: _$vue.ComputedRef<GlobalToken>;
17
+ hashId: _$vue.ComputedRef<string>;
18
+ };
19
+ declare const _default: {
20
+ useToken: () => {
21
+ theme: _$vue.ComputedRef<_$_antdv_next_cssinjs0.Theme<any, any>>;
22
+ token: _$vue.ComputedRef<GlobalToken>;
23
+ hashId: _$vue.ComputedRef<string>;
24
+ };
25
+ token: {
26
+ theme: _$vue.ComputedRef<_$_antdv_next_cssinjs0.Theme<any, any>>;
27
+ token: _$vue.ComputedRef<GlobalToken>;
28
+ hashId: _$vue.ComputedRef<string>;
29
+ };
30
+ emptyTheme: _$_antdv_next_cssinjs0.Theme<any, any>;
31
+ hashCode: typeof hashCode;
32
+ defaultToken: GlobalToken;
33
+ };
34
+ //#endregion
35
+ export { _default as default, defaultToken, emptyTheme, hashCode, token, useToken };