@kingsoft-ai/design 0.1.18 → 0.2.6
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/dist/index.cjs +3150 -2478
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +7211 -7849
- package/dist/index.mjs.map +1 -1
- package/dist/style.css +1 -1
- package/dist/types/DesignThemeProvider.d.ts +25 -20
- package/dist/types/button/Button.d.ts +4 -19
- package/dist/types/button/Button.style.d.ts +4 -35
- package/dist/types/button/IconButton.d.ts +4 -5
- package/dist/types/button/IconButton.style.d.ts +4 -7
- package/dist/types/button/styled-tokens.d.ts +582 -0
- package/dist/types/button/tokens.d.ts +1 -1
- package/dist/types/button/tokens.types.d.ts +190 -0
- package/dist/types/card/Card.d.ts +0 -6
- package/dist/types/card/Card.style.d.ts +4 -7
- package/dist/types/card/styled-tokens.d.ts +130 -0
- package/dist/types/card/tokens.d.ts +1 -1
- package/dist/types/card/tokens.types.d.ts +48 -0
- package/dist/types/checkbox/Checkbox.d.ts +0 -7
- package/dist/types/checkbox/Checkbox.style.d.ts +29 -7
- package/dist/types/checkbox/CheckboxButton.d.ts +0 -16
- package/dist/types/checkbox/CheckboxButton.style.d.ts +24 -12
- package/dist/types/checkbox/styled-tokens.d.ts +122 -0
- package/dist/types/checkbox/tokens.d.ts +1 -1
- package/dist/types/checkbox/tokens.types.d.ts +39 -0
- package/dist/types/collapse/Collapse.d.ts +2 -34
- package/dist/types/collapse/Collapse.style.d.ts +4 -43
- package/dist/types/collapse/styled-tokens.d.ts +77 -0
- package/dist/types/collapse/tokens.d.ts +1 -1
- package/dist/types/collapse/tokens.types.d.ts +28 -0
- package/dist/types/context/ThemeContext.d.ts +24 -0
- package/dist/types/context/index.d.ts +2 -0
- package/dist/types/floatButton/FloatButton.d.ts +0 -21
- package/dist/types/floatButton/FloatButton.style.d.ts +0 -31
- package/dist/types/floatButton/styled-tokens.d.ts +127 -0
- package/dist/types/floatButton/tokens.d.ts +1 -1
- package/dist/types/floatButton/tokens.types.d.ts +66 -0
- package/dist/types/index.d.ts +5 -4
- package/dist/types/input/Input.d.ts +4 -22
- package/dist/types/input/Input.style.d.ts +4 -48
- package/dist/types/input/styled-tokens.d.ts +147 -0
- package/dist/types/input/tokens.d.ts +1 -1
- package/dist/types/input/tokens.types.d.ts +46 -0
- package/dist/types/link/Link.d.ts +4 -0
- package/dist/types/link/Link.style.d.ts +4 -10
- package/dist/types/link/styled-tokens.d.ts +107 -0
- package/dist/types/link/tokens.d.ts +1 -1
- package/dist/types/link/tokens.types.d.ts +39 -0
- package/dist/types/menu/Menu.d.ts +0 -25
- package/dist/types/menu/Menu.style.d.ts +4 -43
- package/dist/types/menu/MenuItem.d.ts +0 -6
- package/dist/types/menu/styled-tokens.d.ts +217 -0
- package/dist/types/menu/tokens.d.ts +1 -1
- package/dist/types/menu/tokens.types.d.ts +79 -0
- package/dist/types/modal/Modal.d.ts +0 -8
- package/dist/types/modal/Modal.style.d.ts +4 -11
- package/dist/types/modal/styled-tokens.d.ts +370 -0
- package/dist/types/modal/tokens.d.ts +1 -1
- package/dist/types/modal/tokens.types.d.ts +107 -0
- package/dist/types/numberInput/NumberInput.d.ts +2 -22
- package/dist/types/numberInput/NumberInput.style.d.ts +4 -7
- package/dist/types/numberInput/styled-tokens.d.ts +192 -0
- package/dist/types/numberInput/tokens.d.ts +1 -1
- package/dist/types/numberInput/tokens.types.d.ts +65 -0
- package/dist/types/progress/Progress.d.ts +4 -27
- package/dist/types/progress/Progress.style.d.ts +4 -43
- package/dist/types/progress/styled-tokens.d.ts +137 -0
- package/dist/types/progress/tokens.d.ts +3 -0
- package/dist/types/progress/tokens.types.d.ts +52 -0
- package/dist/types/radio/Radio.d.ts +4 -0
- package/dist/types/radio/Radio.style.d.ts +9 -28
- package/dist/types/radio/styled-tokens.d.ts +122 -0
- package/dist/types/radio/tokens.d.ts +1 -1
- package/dist/types/radio/tokens.types.d.ts +41 -0
- package/dist/types/select/Select.style.d.ts +4 -7
- package/dist/types/select/styled-tokens.d.ts +237 -0
- package/dist/types/select/tokens.d.ts +1 -1
- package/dist/types/select/tokens.types.d.ts +72 -0
- package/dist/types/skeleton/Skeleton.style.d.ts +0 -25
- package/dist/types/skeleton/styled-tokens.d.ts +82 -0
- package/dist/types/skeleton/tokens.d.ts +1 -1
- package/dist/types/skeleton/tokens.types.d.ts +31 -0
- package/dist/types/slider/Slider.d.ts +74 -0
- package/dist/types/slider/Slider.style.d.ts +125 -0
- package/dist/types/slider/__tests__/Slider.test.d.ts +13 -0
- package/dist/types/slider/index.d.ts +2 -0
- package/dist/types/slider/styled-tokens.d.ts +252 -0
- package/dist/types/slider/tokens.d.ts +3 -0
- package/dist/types/slider/tokens.types.d.ts +121 -0
- package/dist/types/stepper/Stepper.d.ts +3 -0
- package/dist/types/stepper/Stepper.style.d.ts +4 -7
- package/dist/types/stepper/styled-tokens.d.ts +157 -0
- package/dist/types/stepper/tokens.d.ts +1 -1
- package/dist/types/stepper/tokens.types.d.ts +68 -0
- package/dist/types/switch/Switch.d.ts +4 -35
- package/dist/types/switch/Switch.style.d.ts +4 -56
- package/dist/types/switch/styled-tokens.d.ts +132 -0
- package/dist/types/switch/tokens.d.ts +1 -1
- package/dist/types/switch/tokens.types.d.ts +45 -0
- package/dist/types/table/Table.d.ts +2 -0
- package/dist/types/table/Table.style.d.ts +4 -7
- package/dist/types/table/styled-tokens.d.ts +182 -0
- package/dist/types/table/tokens.d.ts +3 -0
- package/dist/types/table/tokens.types.d.ts +43 -0
- package/dist/types/tag/Tag.d.ts +4 -36
- package/dist/types/tag/Tag.style.d.ts +5 -41
- package/dist/types/tag/styled-tokens.d.ts +140 -0
- package/dist/types/tag/tokens.d.ts +1 -1
- package/dist/types/tag/tokens.types.d.ts +76 -0
- package/dist/types/theme.d.ts +1 -2
- package/dist/types/tooltip/Tooltip.d.ts +0 -18
- package/dist/types/tooltip/Tooltip.style.d.ts +0 -19
- package/dist/types/tooltip/styled-tokens.d.ts +72 -0
- package/dist/types/tooltip/tokens.d.ts +1 -1
- package/dist/types/tooltip/tokens.types.d.ts +21 -0
- package/dist/types/transfer/Transfer.d.ts +0 -20
- package/dist/types/transfer/Transfer.style.d.ts +0 -10
- package/dist/types/transfer/styled-tokens.d.ts +252 -0
- package/dist/types/transfer/tokens.d.ts +1 -1
- package/dist/types/transfer/tokens.types.d.ts +79 -0
- package/dist/types/types/index.d.ts +64 -4
- package/dist/types/upload/Upload.d.ts +2 -21
- package/dist/types/upload/Upload.style.d.ts +4 -64
- package/dist/types/upload/styled-tokens.d.ts +227 -0
- package/dist/types/upload/tokens.d.ts +3 -0
- package/dist/types/upload/tokens.types.d.ts +66 -0
- package/dist/types/utils/index.d.ts +4 -0
- package/dist/types/utils/styled-token.d.ts +117 -0
- package/package.json +14 -13
- package/dist/styles.css +0 -1
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Upload Styled Tokens
|
|
3
|
+
*
|
|
4
|
+
* 将 Upload 的 JS tokens 与 CSS 变量映射,实现:
|
|
5
|
+
* - 有 ThemeProvider 时:使用 JS token 值(可被用户自定义)
|
|
6
|
+
* - 无 ThemeProvider 时:fallback 到 CSS 变量(基础样式)
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Upload 组件的 Styled Tokens
|
|
10
|
+
*/
|
|
11
|
+
export declare const $upload: {
|
|
12
|
+
readonly dropzoneBorderRadius: (props: {
|
|
13
|
+
theme?: import("@kingsoft-ai/theme").Theme & {
|
|
14
|
+
_useCSSVariables?: boolean;
|
|
15
|
+
};
|
|
16
|
+
}) => string;
|
|
17
|
+
readonly dropzonePadding: (props: {
|
|
18
|
+
theme?: import("@kingsoft-ai/theme").Theme & {
|
|
19
|
+
_useCSSVariables?: boolean;
|
|
20
|
+
};
|
|
21
|
+
}) => string;
|
|
22
|
+
readonly dropzoneGap: (props: {
|
|
23
|
+
theme?: import("@kingsoft-ai/theme").Theme & {
|
|
24
|
+
_useCSSVariables?: boolean;
|
|
25
|
+
};
|
|
26
|
+
}) => string;
|
|
27
|
+
readonly dropzoneBorder: (props: {
|
|
28
|
+
theme?: import("@kingsoft-ai/theme").Theme & {
|
|
29
|
+
_useCSSVariables?: boolean;
|
|
30
|
+
};
|
|
31
|
+
}) => string;
|
|
32
|
+
readonly dropzoneBorderActive: (props: {
|
|
33
|
+
theme?: import("@kingsoft-ai/theme").Theme & {
|
|
34
|
+
_useCSSVariables?: boolean;
|
|
35
|
+
};
|
|
36
|
+
}) => string;
|
|
37
|
+
readonly dropzoneBg: (props: {
|
|
38
|
+
theme?: import("@kingsoft-ai/theme").Theme & {
|
|
39
|
+
_useCSSVariables?: boolean;
|
|
40
|
+
};
|
|
41
|
+
}) => string;
|
|
42
|
+
readonly dropzoneBgActive: (props: {
|
|
43
|
+
theme?: import("@kingsoft-ai/theme").Theme & {
|
|
44
|
+
_useCSSVariables?: boolean;
|
|
45
|
+
};
|
|
46
|
+
}) => string;
|
|
47
|
+
readonly dropzoneBgDisabled: (props: {
|
|
48
|
+
theme?: import("@kingsoft-ai/theme").Theme & {
|
|
49
|
+
_useCSSVariables?: boolean;
|
|
50
|
+
};
|
|
51
|
+
}) => string;
|
|
52
|
+
readonly iconSize: (props: {
|
|
53
|
+
theme?: import("@kingsoft-ai/theme").Theme & {
|
|
54
|
+
_useCSSVariables?: boolean;
|
|
55
|
+
};
|
|
56
|
+
}) => string;
|
|
57
|
+
readonly iconFillPrimary: (props: {
|
|
58
|
+
theme?: import("@kingsoft-ai/theme").Theme & {
|
|
59
|
+
_useCSSVariables?: boolean;
|
|
60
|
+
};
|
|
61
|
+
}) => string;
|
|
62
|
+
readonly iconFillSecondary: (props: {
|
|
63
|
+
theme?: import("@kingsoft-ai/theme").Theme & {
|
|
64
|
+
_useCSSVariables?: boolean;
|
|
65
|
+
};
|
|
66
|
+
}) => string;
|
|
67
|
+
readonly mainTextFontSize: (props: {
|
|
68
|
+
theme?: import("@kingsoft-ai/theme").Theme & {
|
|
69
|
+
_useCSSVariables?: boolean;
|
|
70
|
+
};
|
|
71
|
+
}) => string;
|
|
72
|
+
readonly mainTextLineHeight: (props: {
|
|
73
|
+
theme?: import("@kingsoft-ai/theme").Theme & {
|
|
74
|
+
_useCSSVariables?: boolean;
|
|
75
|
+
};
|
|
76
|
+
}) => string;
|
|
77
|
+
readonly mainTextColor: (props: {
|
|
78
|
+
theme?: import("@kingsoft-ai/theme").Theme & {
|
|
79
|
+
_useCSSVariables?: boolean;
|
|
80
|
+
};
|
|
81
|
+
}) => string;
|
|
82
|
+
readonly secondaryTextFontSize: (props: {
|
|
83
|
+
theme?: import("@kingsoft-ai/theme").Theme & {
|
|
84
|
+
_useCSSVariables?: boolean;
|
|
85
|
+
};
|
|
86
|
+
}) => string;
|
|
87
|
+
readonly secondaryTextLineHeight: (props: {
|
|
88
|
+
theme?: import("@kingsoft-ai/theme").Theme & {
|
|
89
|
+
_useCSSVariables?: boolean;
|
|
90
|
+
};
|
|
91
|
+
}) => string;
|
|
92
|
+
readonly secondaryTextColor: (props: {
|
|
93
|
+
theme?: import("@kingsoft-ai/theme").Theme & {
|
|
94
|
+
_useCSSVariables?: boolean;
|
|
95
|
+
};
|
|
96
|
+
}) => string;
|
|
97
|
+
readonly linkColor: (props: {
|
|
98
|
+
theme?: import("@kingsoft-ai/theme").Theme & {
|
|
99
|
+
_useCSSVariables?: boolean;
|
|
100
|
+
};
|
|
101
|
+
}) => string;
|
|
102
|
+
readonly fileItemPadding: (props: {
|
|
103
|
+
theme?: import("@kingsoft-ai/theme").Theme & {
|
|
104
|
+
_useCSSVariables?: boolean;
|
|
105
|
+
};
|
|
106
|
+
}) => string;
|
|
107
|
+
readonly fileItemBorderRadius: (props: {
|
|
108
|
+
theme?: import("@kingsoft-ai/theme").Theme & {
|
|
109
|
+
_useCSSVariables?: boolean;
|
|
110
|
+
};
|
|
111
|
+
}) => string;
|
|
112
|
+
readonly fileItemBg: (props: {
|
|
113
|
+
theme?: import("@kingsoft-ai/theme").Theme & {
|
|
114
|
+
_useCSSVariables?: boolean;
|
|
115
|
+
};
|
|
116
|
+
}) => string;
|
|
117
|
+
readonly fileItemBgHover: (props: {
|
|
118
|
+
theme?: import("@kingsoft-ai/theme").Theme & {
|
|
119
|
+
_useCSSVariables?: boolean;
|
|
120
|
+
};
|
|
121
|
+
}) => string;
|
|
122
|
+
readonly fileItemBgSuccess: (props: {
|
|
123
|
+
theme?: import("@kingsoft-ai/theme").Theme & {
|
|
124
|
+
_useCSSVariables?: boolean;
|
|
125
|
+
};
|
|
126
|
+
}) => string;
|
|
127
|
+
readonly fileItemBgError: (props: {
|
|
128
|
+
theme?: import("@kingsoft-ai/theme").Theme & {
|
|
129
|
+
_useCSSVariables?: boolean;
|
|
130
|
+
};
|
|
131
|
+
}) => string;
|
|
132
|
+
readonly fileIconSize: (props: {
|
|
133
|
+
theme?: import("@kingsoft-ai/theme").Theme & {
|
|
134
|
+
_useCSSVariables?: boolean;
|
|
135
|
+
};
|
|
136
|
+
}) => string;
|
|
137
|
+
readonly fileNameFontSize: (props: {
|
|
138
|
+
theme?: import("@kingsoft-ai/theme").Theme & {
|
|
139
|
+
_useCSSVariables?: boolean;
|
|
140
|
+
};
|
|
141
|
+
}) => string;
|
|
142
|
+
readonly fileNameColor: (props: {
|
|
143
|
+
theme?: import("@kingsoft-ai/theme").Theme & {
|
|
144
|
+
_useCSSVariables?: boolean;
|
|
145
|
+
};
|
|
146
|
+
}) => string;
|
|
147
|
+
readonly fileNameColorError: (props: {
|
|
148
|
+
theme?: import("@kingsoft-ai/theme").Theme & {
|
|
149
|
+
_useCSSVariables?: boolean;
|
|
150
|
+
};
|
|
151
|
+
}) => string;
|
|
152
|
+
readonly fileInfoFontSize: (props: {
|
|
153
|
+
theme?: import("@kingsoft-ai/theme").Theme & {
|
|
154
|
+
_useCSSVariables?: boolean;
|
|
155
|
+
};
|
|
156
|
+
}) => string;
|
|
157
|
+
readonly fileInfoColor: (props: {
|
|
158
|
+
theme?: import("@kingsoft-ai/theme").Theme & {
|
|
159
|
+
_useCSSVariables?: boolean;
|
|
160
|
+
};
|
|
161
|
+
}) => string;
|
|
162
|
+
readonly fileInfoColorSuccess: (props: {
|
|
163
|
+
theme?: import("@kingsoft-ai/theme").Theme & {
|
|
164
|
+
_useCSSVariables?: boolean;
|
|
165
|
+
};
|
|
166
|
+
}) => string;
|
|
167
|
+
readonly fileInfoColorError: (props: {
|
|
168
|
+
theme?: import("@kingsoft-ai/theme").Theme & {
|
|
169
|
+
_useCSSVariables?: boolean;
|
|
170
|
+
};
|
|
171
|
+
}) => string;
|
|
172
|
+
readonly actionColor: (props: {
|
|
173
|
+
theme?: import("@kingsoft-ai/theme").Theme & {
|
|
174
|
+
_useCSSVariables?: boolean;
|
|
175
|
+
};
|
|
176
|
+
}) => string;
|
|
177
|
+
readonly actionColorHover: (props: {
|
|
178
|
+
theme?: import("@kingsoft-ai/theme").Theme & {
|
|
179
|
+
_useCSSVariables?: boolean;
|
|
180
|
+
};
|
|
181
|
+
}) => string;
|
|
182
|
+
readonly progressBg: (props: {
|
|
183
|
+
theme?: import("@kingsoft-ai/theme").Theme & {
|
|
184
|
+
_useCSSVariables?: boolean;
|
|
185
|
+
};
|
|
186
|
+
}) => string;
|
|
187
|
+
readonly progressBarBg: (props: {
|
|
188
|
+
theme?: import("@kingsoft-ai/theme").Theme & {
|
|
189
|
+
_useCSSVariables?: boolean;
|
|
190
|
+
};
|
|
191
|
+
}) => string;
|
|
192
|
+
readonly progressHeight: (props: {
|
|
193
|
+
theme?: import("@kingsoft-ai/theme").Theme & {
|
|
194
|
+
_useCSSVariables?: boolean;
|
|
195
|
+
};
|
|
196
|
+
}) => string;
|
|
197
|
+
readonly progressBorderRadius: (props: {
|
|
198
|
+
theme?: import("@kingsoft-ai/theme").Theme & {
|
|
199
|
+
_useCSSVariables?: boolean;
|
|
200
|
+
};
|
|
201
|
+
}) => string;
|
|
202
|
+
readonly progressTextFontSize: (props: {
|
|
203
|
+
theme?: import("@kingsoft-ai/theme").Theme & {
|
|
204
|
+
_useCSSVariables?: boolean;
|
|
205
|
+
};
|
|
206
|
+
}) => string;
|
|
207
|
+
readonly progressTextColor: (props: {
|
|
208
|
+
theme?: import("@kingsoft-ai/theme").Theme & {
|
|
209
|
+
_useCSSVariables?: boolean;
|
|
210
|
+
};
|
|
211
|
+
}) => string;
|
|
212
|
+
readonly disabledOpacity: (props: {
|
|
213
|
+
theme?: import("@kingsoft-ai/theme").Theme & {
|
|
214
|
+
_useCSSVariables?: boolean;
|
|
215
|
+
};
|
|
216
|
+
}) => string;
|
|
217
|
+
readonly transition: (props: {
|
|
218
|
+
theme?: import("@kingsoft-ai/theme").Theme & {
|
|
219
|
+
_useCSSVariables?: boolean;
|
|
220
|
+
};
|
|
221
|
+
}) => string;
|
|
222
|
+
readonly focusRing: (props: {
|
|
223
|
+
theme?: import("@kingsoft-ai/theme").Theme & {
|
|
224
|
+
_useCSSVariables?: boolean;
|
|
225
|
+
};
|
|
226
|
+
}) => string;
|
|
227
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Upload 组件 Token 类型定义
|
|
3
|
+
*/
|
|
4
|
+
export interface UploadTokens {
|
|
5
|
+
dropzone: {
|
|
6
|
+
borderRadius: string;
|
|
7
|
+
padding: string;
|
|
8
|
+
gap: string;
|
|
9
|
+
border: string;
|
|
10
|
+
borderActive: string;
|
|
11
|
+
bg: string;
|
|
12
|
+
bgActive: string;
|
|
13
|
+
bgDisabled: string;
|
|
14
|
+
};
|
|
15
|
+
icon: {
|
|
16
|
+
size: string;
|
|
17
|
+
fillPrimary: string;
|
|
18
|
+
fillSecondary: string;
|
|
19
|
+
};
|
|
20
|
+
mainText: {
|
|
21
|
+
fontSize: string;
|
|
22
|
+
lineHeight: string;
|
|
23
|
+
color: string;
|
|
24
|
+
};
|
|
25
|
+
secondaryText: {
|
|
26
|
+
fontSize: string;
|
|
27
|
+
lineHeight: string;
|
|
28
|
+
color: string;
|
|
29
|
+
};
|
|
30
|
+
linkColor: string;
|
|
31
|
+
fileItem: {
|
|
32
|
+
padding: string;
|
|
33
|
+
borderRadius: string;
|
|
34
|
+
bg: string;
|
|
35
|
+
bgHover: string;
|
|
36
|
+
bgSuccess: string;
|
|
37
|
+
bgError: string;
|
|
38
|
+
};
|
|
39
|
+
fileIconSize: string;
|
|
40
|
+
fileName: {
|
|
41
|
+
fontSize: string;
|
|
42
|
+
color: string;
|
|
43
|
+
colorError: string;
|
|
44
|
+
};
|
|
45
|
+
fileInfo: {
|
|
46
|
+
fontSize: string;
|
|
47
|
+
color: string;
|
|
48
|
+
colorSuccess: string;
|
|
49
|
+
colorError: string;
|
|
50
|
+
};
|
|
51
|
+
action: {
|
|
52
|
+
color: string;
|
|
53
|
+
colorHover: string;
|
|
54
|
+
};
|
|
55
|
+
progress: {
|
|
56
|
+
bg: string;
|
|
57
|
+
barBg: string;
|
|
58
|
+
height: string;
|
|
59
|
+
borderRadius: string;
|
|
60
|
+
textFontSize: string;
|
|
61
|
+
textColor: string;
|
|
62
|
+
};
|
|
63
|
+
disabledOpacity: number;
|
|
64
|
+
transition: string;
|
|
65
|
+
focusRing: string;
|
|
66
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Styled Token System
|
|
3
|
+
*
|
|
4
|
+
* 一套优雅的 Design Token 解析系统,支持两种样式解析策略:
|
|
5
|
+
*
|
|
6
|
+
* 1. **CSS 变量方案**(默认)
|
|
7
|
+
* - 无 Provider 或只传 mode 时使用
|
|
8
|
+
* - 样式通过 CSS 变量解析,支持在元素上直接覆盖
|
|
9
|
+
* - light/dark 切换通过 data-theme 属性实现
|
|
10
|
+
*
|
|
11
|
+
* 2. **JS Token 方案**
|
|
12
|
+
* - 传 theme prop 时使用
|
|
13
|
+
* - 样式通过 JavaScript 对象解析
|
|
14
|
+
* - 支持完整的主题自定义能力
|
|
15
|
+
*
|
|
16
|
+
* ## 检测逻辑
|
|
17
|
+
*
|
|
18
|
+
* | theme 状态 | _useCSSVariables | 结果 |
|
|
19
|
+
* |------------------------------|------------------|------------|
|
|
20
|
+
* | undefined | - | CSS 变量 |
|
|
21
|
+
* | 存在,_useCSSVariables=true | true | CSS 变量 |
|
|
22
|
+
* | 存在,_useCSSVariables=false | false | JS Token |
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```tsx
|
|
26
|
+
* // 定义组件的 styled tokens
|
|
27
|
+
* export const $card = createStyledTokens({
|
|
28
|
+
* bg: ['components.card.container.background.default', '--ksd-card-bg'],
|
|
29
|
+
* radius: ['components.card.container.radius', '--ksd-card-radius'],
|
|
30
|
+
* });
|
|
31
|
+
*
|
|
32
|
+
* // 在 styled-components 中使用
|
|
33
|
+
* const Container = styled.div`
|
|
34
|
+
* background: ${$card.bg};
|
|
35
|
+
* border-radius: ${$card.radius};
|
|
36
|
+
* `;
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
import type { AppTheme } from '@kingsoft-ai/theme';
|
|
40
|
+
/**
|
|
41
|
+
* 带有样式策略标记的 Theme 类型
|
|
42
|
+
* - _useCSSVariables: true → 使用 CSS 变量
|
|
43
|
+
* - _useCSSVariables: false → 使用 JS Token
|
|
44
|
+
*/
|
|
45
|
+
type ThemeWithFlag = AppTheme & {
|
|
46
|
+
_useCSSVariables?: boolean;
|
|
47
|
+
};
|
|
48
|
+
type ThemeProps = {
|
|
49
|
+
theme?: ThemeWithFlag;
|
|
50
|
+
};
|
|
51
|
+
type StyledTokenFn = (props: ThemeProps) => string;
|
|
52
|
+
/**
|
|
53
|
+
* 创建单个 styled token 函数
|
|
54
|
+
*
|
|
55
|
+
* @param themePath - Theme 对象中的路径
|
|
56
|
+
* @param cssVar - CSS 变量名(作为 fallback)
|
|
57
|
+
* @returns 可在 styled-components 中使用的函数
|
|
58
|
+
*/
|
|
59
|
+
export declare const token: (themePath: string, cssVar: string) => StyledTokenFn;
|
|
60
|
+
/**
|
|
61
|
+
* Token 定义:[themePath, cssVar]
|
|
62
|
+
*/
|
|
63
|
+
type TokenDef = readonly [themePath: string, cssVar: string];
|
|
64
|
+
/**
|
|
65
|
+
* Token 映射配置
|
|
66
|
+
*/
|
|
67
|
+
type TokenMap = Record<string, TokenDef>;
|
|
68
|
+
/**
|
|
69
|
+
* 将 TokenMap 转换为 StyledTokens 对象
|
|
70
|
+
*/
|
|
71
|
+
type StyledTokens<T extends TokenMap> = {
|
|
72
|
+
readonly [K in keyof T]: StyledTokenFn;
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* 批量创建 styled tokens
|
|
76
|
+
*
|
|
77
|
+
* 将 token 定义映射为可在 styled-components 中直接使用的函数集合。
|
|
78
|
+
* 每个函数会优先使用 JS theme 值,fallback 到 CSS 变量。
|
|
79
|
+
*
|
|
80
|
+
* @param tokenMap - Token 定义映射 { name: [themePath, cssVar] }
|
|
81
|
+
* @returns Styled tokens 对象
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```tsx
|
|
85
|
+
* const $button = createStyledTokens({
|
|
86
|
+
* bg: ['components.button.background', '--ksd-btn-bg'],
|
|
87
|
+
* color: ['components.button.color', '--ksd-btn-color'],
|
|
88
|
+
* });
|
|
89
|
+
*
|
|
90
|
+
* const Button = styled.button`
|
|
91
|
+
* background: ${$button.bg};
|
|
92
|
+
* color: ${$button.color};
|
|
93
|
+
* `;
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
export declare const createStyledTokens: <T extends TokenMap>(tokenMap: T) => StyledTokens<T>;
|
|
97
|
+
/**
|
|
98
|
+
* 条件 token:根据条件选择不同的 token 值
|
|
99
|
+
*
|
|
100
|
+
* @example
|
|
101
|
+
* ```tsx
|
|
102
|
+
* const Container = styled.div<{ variant: 'filled' | 'outlined' }>`
|
|
103
|
+
* background: ${({ variant }) =>
|
|
104
|
+
* tokenWhen(variant === 'filled',
|
|
105
|
+
* ['components.card.bg.filled', '--ksd-card-bg-filled'],
|
|
106
|
+
* ['components.card.bg.outlined', '--ksd-card-bg-outlined']
|
|
107
|
+
* )};
|
|
108
|
+
* `;
|
|
109
|
+
* ```
|
|
110
|
+
*/
|
|
111
|
+
export declare const tokenWhen: (condition: boolean, whenTrue: TokenDef, whenFalse: TokenDef) => StyledTokenFn;
|
|
112
|
+
/**
|
|
113
|
+
* 直接从 theme 获取值(不带 CSS fallback)
|
|
114
|
+
* 用于需要在 JS 中进行计算的场景
|
|
115
|
+
*/
|
|
116
|
+
export declare const themeValue: <T = string>(themePath: string, fallback: T) => ((props: ThemeProps) => T);
|
|
117
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kingsoft-ai/design",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -23,24 +23,24 @@
|
|
|
23
23
|
"access": "public"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@emotion/react": "^11.13.3",
|
|
27
|
-
"@emotion/styled": "^11.13.3",
|
|
28
|
-
"@react-aria/tooltip": "^3.9.0",
|
|
29
|
-
"@react-stately/collections": "^3.12.8",
|
|
30
|
-
"@react-stately/list": "^3.13.1",
|
|
31
|
-
"@react-stately/select": "^3.8.0",
|
|
32
|
-
"@react-stately/tooltip": "^3.5.9",
|
|
33
|
-
"@react-types/overlays": "^3.9.2",
|
|
34
|
-
"@react-types/shared": "^3.32.1",
|
|
35
|
-
"@react-types/tooltip": "^3.5.0",
|
|
36
26
|
"deepmerge": "^4.3.1",
|
|
37
27
|
"@kingsoft-ai/icons": "^0.1.6",
|
|
38
|
-
"@kingsoft-ai/theme": "^0.
|
|
28
|
+
"@kingsoft-ai/theme": "^0.2.3"
|
|
39
29
|
},
|
|
40
30
|
"peerDependencies": {
|
|
31
|
+
"@emotion/react": ">=11",
|
|
32
|
+
"@emotion/styled": ">=11",
|
|
41
33
|
"react": ">=18",
|
|
42
34
|
"react-aria": ">=3",
|
|
43
|
-
"react-dom": ">=18"
|
|
35
|
+
"react-dom": ">=18",
|
|
36
|
+
"@react-aria/tooltip": ">=3",
|
|
37
|
+
"@react-stately/collections": ">=3",
|
|
38
|
+
"@react-stately/list": ">=3",
|
|
39
|
+
"@react-stately/select": ">=3",
|
|
40
|
+
"@react-stately/tooltip": ">=3",
|
|
41
|
+
"@react-types/overlays": ">=3",
|
|
42
|
+
"@react-types/shared": ">=3",
|
|
43
|
+
"@react-types/tooltip": ">=3"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@emotion/react": "^11.13.3",
|
|
@@ -50,6 +50,7 @@
|
|
|
50
50
|
"@react-aria/interactions": "^3.25.6",
|
|
51
51
|
"@react-aria/utils": "^3.26.0",
|
|
52
52
|
"@react-stately/toggle": "^3.9.0",
|
|
53
|
+
"@react-stately/slider": "^3.6.0",
|
|
53
54
|
"@react-types/checkbox": "^3.9.0",
|
|
54
55
|
"@testing-library/jest-dom": "^6.6.3",
|
|
55
56
|
"@testing-library/react": "^16.1.0",
|