@oceanbase/codemod 0.4.16 → 1.0.0-alpha.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/README.md +19 -8
- package/bin/upgrade-list.json +8 -5
- package/package.json +3 -3
- package/transforms/__testfixtures__/less-to-token/antd-v4-less-to-token.input.less +2 -0
- package/transforms/__testfixtures__/less-to-token/antd-v4-less-to-token.output.less +2 -0
- package/transforms/__testfixtures__/less-to-token/case-insensitive.input.less +2 -0
- package/transforms/__testfixtures__/less-to-token/case-insensitive.output.less +2 -0
- package/transforms/__testfixtures__/less-to-token/mixin.input.less +3 -0
- package/transforms/__testfixtures__/less-to-token/mixin.output.less +3 -0
- package/transforms/__testfixtures__/less-to-token/obui-less-to-token.input.less +2 -0
- package/transforms/__testfixtures__/less-to-token/obui-less-to-token.output.less +2 -0
- package/transforms/__testfixtures__/less-to-token/obui-less-token-to-token.input.less +1 -0
- package/transforms/__testfixtures__/less-to-token/obui-less-token-to-token.output.less +1 -0
- package/transforms/__testfixtures__/style-to-token/anonymous-function.input.js +13 -0
- package/transforms/__testfixtures__/style-to-token/anonymous-function.output.js +14 -0
- package/transforms/__testfixtures__/style-to-token/antd-style.input.js +3 -0
- package/transforms/__testfixtures__/style-to-token/antd-style.output.js +3 -0
- package/transforms/__testfixtures__/style-to-token/block-statement.input.js +4 -0
- package/transforms/__testfixtures__/style-to-token/block-statement.output.js +4 -0
- package/transforms/__testfixtures__/style-to-token/class-component.input.js +2 -2
- package/transforms/__testfixtures__/style-to-token/class-component.output.js +2 -2
- package/transforms/__testfixtures__/style-to-token/existed-useToken.input.js +2 -2
- package/transforms/__testfixtures__/style-to-token/existed-useToken.output.js +2 -2
- package/transforms/__testfixtures__/style-to-token/function-component.input.js +4 -4
- package/transforms/__testfixtures__/style-to-token/function-component.output.js +4 -4
- package/transforms/__testfixtures__/style-to-token/function.input.js +6 -6
- package/transforms/__testfixtures__/style-to-token/function.output.js +7 -7
- package/transforms/__testfixtures__/style-to-token/hooks.input.js +4 -4
- package/transforms/__testfixtures__/style-to-token/hooks.output.js +4 -4
- package/transforms/__testfixtures__/style-to-token/nested-block-statement.input.js +3 -3
- package/transforms/__testfixtures__/style-to-token/nested-block-statement.output.js +3 -3
- package/transforms/__testfixtures__/style-to-token/single-function.input.js +5 -0
- package/transforms/__testfixtures__/style-to-token/single-function.output.js +7 -0
- package/transforms/__testfixtures__/style-to-token/top-identifier.input.js +1 -0
- package/transforms/__testfixtures__/style-to-token/top-identifier.output.js +1 -0
- package/transforms/__tests__/style-to-token.test.ts +2 -0
- package/transforms/less-to-token.js +16 -6
- package/transforms/style-to-token.js +392 -121
- package/transforms/utils/index.js +8 -0
- package/transforms/utils/token.js +39 -0
|
@@ -35,6 +35,7 @@ const TOKEN_MAP = {
|
|
|
35
35
|
'#1677ff': 'colorInfo',
|
|
36
36
|
'#1890ff': 'colorInfo',
|
|
37
37
|
'#40a9ff': 'colorInfo',
|
|
38
|
+
'#006aff': 'colorInfo',
|
|
38
39
|
'#f7f9fb': 'colorInfoBg',
|
|
39
40
|
'#e6f7ff': 'colorInfoBgHover',
|
|
40
41
|
'#f3f9ff': 'colorInfoBgHover',
|
|
@@ -57,6 +58,7 @@ const TOKEN_MAP = {
|
|
|
57
58
|
'#f0f2f5': 'colorBgLayout',
|
|
58
59
|
'#fafafa': 'colorBgLayout',
|
|
59
60
|
'#f7f8fc': 'colorBgLayout',
|
|
61
|
+
'#f3f6fc': 'colorBgLayout',
|
|
60
62
|
'rgb(250,250,250)': 'colorBgLayout',
|
|
61
63
|
'#ffffff': 'colorBgContainer',
|
|
62
64
|
'#fff': 'colorBgContainer',
|
|
@@ -158,9 +160,46 @@ function tokenParse(value) {
|
|
|
158
160
|
};
|
|
159
161
|
}
|
|
160
162
|
|
|
163
|
+
// 基于属性名和数值的 token 映射
|
|
164
|
+
const PROPERTY_TOKEN_MAP = {
|
|
165
|
+
fontSize: {
|
|
166
|
+
11: 'fontSizeSM',
|
|
167
|
+
12: 'fontSizeSM',
|
|
168
|
+
13: 'fontSize',
|
|
169
|
+
14: 'fontSize',
|
|
170
|
+
15: 'fontSizeLG',
|
|
171
|
+
16: 'fontSizeLG',
|
|
172
|
+
},
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
function propertyTokenParse(propertyName, value) {
|
|
176
|
+
// 基于属性名和数值的 token 解析
|
|
177
|
+
const propertyMap = PROPERTY_TOKEN_MAP[propertyName];
|
|
178
|
+
if (!propertyMap) {
|
|
179
|
+
return null;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
const stringValue = String(value);
|
|
183
|
+
// 提取数值部分(去掉单位)
|
|
184
|
+
const numericValue = stringValue.replace(/[^\d.]/g, '');
|
|
185
|
+
const token = propertyMap[numericValue];
|
|
186
|
+
if (!token) {
|
|
187
|
+
return null;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
return {
|
|
191
|
+
key: stringValue,
|
|
192
|
+
token,
|
|
193
|
+
formattedValue: stringValue,
|
|
194
|
+
propertyName,
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
|
|
161
198
|
module.exports = {
|
|
162
199
|
TOKEN_MAP,
|
|
163
200
|
TOKEN_MAP_KEYS,
|
|
164
201
|
tokenParse,
|
|
202
|
+
PROPERTY_TOKEN_MAP,
|
|
203
|
+
propertyTokenParse,
|
|
165
204
|
isLower,
|
|
166
205
|
};
|