@cloudbase/cals 1.0.49 → 1.0.50

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 (87) hide show
  1. package/lib/parser/cals/utils/template.js +3 -3
  2. package/package.json +3 -3
  3. package/lib/parser/cals/utils/block/index.js +0 -151
  4. package/lib/parser/cals/utils/code/index.js +0 -393
  5. package/lib/parser/cals/utils/common.js +0 -268
  6. package/lib/parser/cals/utils/getUsedResources.d.ts +0 -10
  7. package/lib/parser/cals/utils/getUsedResources.d.ts.map +0 -1
  8. package/lib/parser/cals/utils/getUsedResources.js +0 -128
  9. package/lib/parser/cals/utils/runtime.js +0 -268
  10. package/lib/parser/cals/utils/style.js +0 -472
  11. package/lib/parser/cals/utils/version/common.js +0 -385
  12. package/lib/parser/cals/utils/version/config.d.ts +0 -16
  13. package/lib/parser/cals/utils/version/config.d.ts.map +0 -1
  14. package/lib/parser/cals/utils/version/config.js +0 -244
  15. package/lib/parser/cals/utils/version/index.js +0 -96
  16. package/lib/parser/cals/utils/version/parses.js +0 -581
  17. package/lib/parser/cals/utils/version/utils.d.ts +0 -14
  18. package/lib/parser/cals/utils/version/utils.d.ts.map +0 -1
  19. package/lib/parser/cals/utils/version/utils.js +0 -148
  20. package/lib/parser/expression/index.d.ts +0 -123
  21. package/lib/parser/expression/index.d.ts.map +0 -1
  22. package/lib/parser/expression/index.js +0 -301
  23. package/lib/parser/plugins/postcss-rpx2clac.d.ts +0 -18
  24. package/lib/parser/plugins/postcss-rpx2clac.d.ts.map +0 -1
  25. package/lib/parser/plugins/postcss-rpx2clac.js +0 -68
  26. package/lib/types/basic/app.d.ts +0 -73
  27. package/lib/types/basic/app.d.ts.map +0 -1
  28. package/lib/types/basic/app.js +0 -2
  29. package/lib/types/basic/common.d.ts +0 -93
  30. package/lib/types/basic/common.d.ts.map +0 -1
  31. package/lib/types/basic/common.js +0 -2
  32. package/lib/types/basic/component.d.ts +0 -211
  33. package/lib/types/basic/component.d.ts.map +0 -1
  34. package/lib/types/basic/component.js +0 -2
  35. package/lib/types/basic/datasource.d.ts +0 -50
  36. package/lib/types/basic/datasource.d.ts.map +0 -1
  37. package/lib/types/basic/datasource.js +0 -2
  38. package/lib/types/index.js +0 -42
  39. package/lib/types/lcds.js +0 -25
  40. package/lib/types/platform/app.js +0 -11
  41. package/lib/types/platform/common.d.ts +0 -181
  42. package/lib/types/platform/common.d.ts.map +0 -1
  43. package/lib/types/platform/common.js +0 -87
  44. package/lib/types/platform/component.d.ts +0 -139
  45. package/lib/types/platform/component.d.ts.map +0 -1
  46. package/lib/types/platform/component.js +0 -11
  47. package/lib/types/platform/datasource.d.ts +0 -467
  48. package/lib/types/platform/datasource.d.ts.map +0 -1
  49. package/lib/types/platform/datasource.js +0 -2
  50. package/lib/types/platform/eventFlow.d.ts +0 -20
  51. package/lib/types/platform/eventFlow.d.ts.map +0 -1
  52. package/lib/types/platform/eventFlow.js +0 -2
  53. package/lib/types/platform/query.d.ts +0 -67
  54. package/lib/types/platform/query.d.ts.map +0 -1
  55. package/lib/types/platform/query.js +0 -2
  56. package/lib/types/platform/theme.js +0 -2
  57. package/lib/types/platform/widget/form.d.ts +0 -5
  58. package/lib/types/platform/widget/form.d.ts.map +0 -1
  59. package/lib/types/platform/widget/form.js +0 -5
  60. package/lib/types/platform/widget/meta.d.ts +0 -60
  61. package/lib/types/platform/widget/meta.d.ts.map +0 -1
  62. package/lib/types/platform/widget/meta.js +0 -6
  63. package/lib/utils/CSSProperty.d.ts +0 -64
  64. package/lib/utils/CSSProperty.d.ts.map +0 -1
  65. package/lib/utils/CSSProperty.js +0 -89
  66. package/lib/utils/build.d.ts +0 -2
  67. package/lib/utils/build.d.ts.map +0 -1
  68. package/lib/utils/build.js +0 -75
  69. package/lib/utils/dts/auto-generated.d.ts +0 -2
  70. package/lib/utils/dts/auto-generated.d.ts.map +0 -1
  71. package/lib/utils/dts/auto-generated.js +0 -1796
  72. package/lib/utils/dts/build.d.ts +0 -2
  73. package/lib/utils/dts/build.d.ts.map +0 -1
  74. package/lib/utils/dts/build.js +0 -136
  75. package/lib/utils/dts/index.js +0 -1008
  76. package/lib/utils/index.js +0 -27
  77. package/lib/utils/version/common.d.ts +0 -3
  78. package/lib/utils/version/common.d.ts.map +0 -1
  79. package/lib/utils/version/common.js +0 -27
  80. package/lib/utils/version/featureChecker.js +0 -35
  81. package/lib/utils/version/migrations/version4.js +0 -199
  82. package/lib/utils/version-migrations/common.d.ts +0 -5
  83. package/lib/utils/version-migrations/common.d.ts.map +0 -1
  84. package/lib/utils/version-migrations/common.js +0 -29
  85. package/lib/utils/version-migrations/version4.d.ts +0 -3
  86. package/lib/utils/version-migrations/version4.d.ts.map +0 -1
  87. package/lib/utils/version-migrations/version4.js +0 -199
@@ -1,472 +0,0 @@
1
- "use strict";
2
- var __rest = (this && this.__rest) || function (s, e) {
3
- var t = {};
4
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
- t[p] = s[p];
6
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
- t[p[i]] = s[p[i]];
10
- }
11
- return t;
12
- };
13
- var __importDefault = (this && this.__importDefault) || function (mod) {
14
- return (mod && mod.__esModule) ? mod : { "default": mod };
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.processCSSPropertiesUnit = exports.processCSSProperties2Rem = exports.processCommonStyle2CSSProperties = exports.removeInvalidStyleFormValue = void 0;
18
- const common_1 = require("./common");
19
- const map_1 = __importDefault(require("lodash/map"));
20
- const uniq_1 = __importDefault(require("lodash/uniq"));
21
- const utils_1 = require("../../../utils");
22
- const DISTANCE_KEY_LIST = ['top', 'right', 'bottom', 'left'];
23
- function removeInvalidStyleFormValue(styleForm = {}) {
24
- return Object.keys(styleForm).reduce((result, key) => {
25
- const propStyleFormData = styleForm[key];
26
- if ((0, common_1.isPlainObject)(propStyleFormData)) {
27
- setStyleValue(result, key, removeInvalidStyleFormValue(propStyleFormData));
28
- }
29
- else {
30
- setStyleValue(result, key, styleForm[key]);
31
- }
32
- return result;
33
- }, {});
34
- }
35
- exports.removeInvalidStyleFormValue = removeInvalidStyleFormValue;
36
- function setStyleValue(object, key, value) {
37
- if (value === undefined || value === null || value === '') {
38
- return;
39
- }
40
- // 特殊样式移除
41
- if (key === 'open') {
42
- return;
43
- }
44
- if ((0, common_1.isEmptyObj)(value)) {
45
- return;
46
- }
47
- if (key.startsWith('--')) {
48
- // css 自定义属性
49
- object[key] = value;
50
- }
51
- else {
52
- object[(0, common_1.camelcase)(key)] = value;
53
- }
54
- }
55
- function _handleStyleNumValue(styleVal, addPXUnit) {
56
- if (addPXUnit) {
57
- /**
58
- * 2022.12.13
59
- * 改分支未启用
60
- */
61
- const value = `${styleVal}`;
62
- if (/^-?(?:\d*\.)?\d+$/.test(value)) {
63
- return `${value}px`;
64
- }
65
- }
66
- return styleVal;
67
- }
68
- function setDistanceStyle(style, distance, attr, addPXUnit) {
69
- const attributeKey = (0, common_1.camelcase)(`${attr}`);
70
- if (Object.keys(distance).length === 4) {
71
- if ((0, uniq_1.default)((0, map_1.default)(distance, (val) => val)).length === 1) {
72
- // 4个值全相等的情况
73
- setStyleValue(style, attributeKey, _handleStyleNumValue(distance.top, addPXUnit));
74
- }
75
- else if (distance.top === distance.bottom && distance.left === distance.right) {
76
- // 俩俩相等的情况
77
- setStyleValue(style, attributeKey, `${_handleStyleNumValue(distance.top, addPXUnit)} ${_handleStyleNumValue(distance.right, addPXUnit)}`);
78
- }
79
- else if (distance.left === distance.right) {
80
- setStyleValue(style, attributeKey, `${_handleStyleNumValue(distance.top, addPXUnit)} ${_handleStyleNumValue(distance.right, addPXUnit)} ${_handleStyleNumValue(distance.bottom, addPXUnit)}`);
81
- }
82
- else {
83
- setStyleValue(style, attributeKey, `${_handleStyleNumValue(distance.top, addPXUnit)} ${_handleStyleNumValue(distance.right, addPXUnit)} ${_handleStyleNumValue(distance.bottom, addPXUnit)} ${_handleStyleNumValue(distance.left, addPXUnit)}`);
84
- }
85
- }
86
- else {
87
- DISTANCE_KEY_LIST.forEach((key) => {
88
- if (distance[key] !== undefined)
89
- setStyleValue(style, (0, common_1.camelcase)(`${attr}_${key}`), _handleStyleNumValue(distance[key], addPXUnit));
90
- });
91
- }
92
- }
93
- function translateStyleByHandler(style = {}, handler, options) {
94
- const { looseError = false, rpxCalcRoot } = options || {};
95
- return Object.keys(style).reduce((result, key) => {
96
- const value = style[key];
97
- if (utils_1.isUnitlessNumber[key]) {
98
- setStyleValue(result, key, value);
99
- }
100
- else if (value !== undefined && value !== null) {
101
- try {
102
- setStyleValue(result, key, handler(value, rpxCalcRoot));
103
- }
104
- catch (e) {
105
- if (looseError) {
106
- console.warn('translate style error, key:value', key, value);
107
- }
108
- else {
109
- throw e;
110
- }
111
- }
112
- }
113
- return result;
114
- }, {});
115
- }
116
- function toREM(cssLen, rpxCalcRoot = undefined) {
117
- if (typeof cssLen === 'string' || typeof cssLen === 'number') {
118
- const cssLenArr = `${cssLen}`.split(' ');
119
- return cssLenArr
120
- .map((attr) => {
121
- const matchResult = attr.match(/^(-?\d*\.?\d+)(r?px)?$/);
122
- if (matchResult === null || matchResult === void 0 ? void 0 : matchResult[1]) {
123
- const px = +matchResult[1];
124
- if (Number.isNaN(px / 1))
125
- return px.toString();
126
- if (px === 0) {
127
- return '0';
128
- }
129
- if ((matchResult === null || matchResult === void 0 ? void 0 : matchResult[2]) === 'rpx') {
130
- return rpxCalcRoot ? `calc(${px}px / ${rpxCalcRoot})` : attr;
131
- }
132
- return `${(px / 28).toFixed(4)}rem`;
133
- }
134
- return attr;
135
- })
136
- .join(' ');
137
- }
138
- else {
139
- throw new Error(`cssLen type error ${cssLen}`);
140
- }
141
- }
142
- function toRPX(cssLen, rpxCalcRoot = undefined) {
143
- const cssLenArr = `${cssLen}`.split(' ');
144
- return cssLenArr
145
- .map((attr) => {
146
- const matchResult = attr.match(/^(-?\d*\.?\d+)(px)?$/);
147
- if (matchResult === null || matchResult === void 0 ? void 0 : matchResult[1]) {
148
- const px = +matchResult[1];
149
- if (Number.isNaN(px / 1))
150
- return px.toString();
151
- if (px === 0) {
152
- return '0';
153
- }
154
- return rpxCalcRoot ? `calc(${px}px / ${rpxCalcRoot})` : `${px}rpx`;
155
- }
156
- return attr;
157
- })
158
- .join(' ');
159
- }
160
- function toPX(cssLen, rpxCalcRoot = undefined) {
161
- return `${cssLen}`
162
- .split(' ')
163
- .map((attr) => {
164
- const matchResult = attr.match(/^(-?\d*\.?\d+)(rpx)?$/);
165
- if (matchResult === null || matchResult === void 0 ? void 0 : matchResult[1]) {
166
- const px = +matchResult[1];
167
- if (Number.isNaN(px / 1))
168
- return px.toString();
169
- if (px === 0) {
170
- return '0';
171
- }
172
- if ((matchResult === null || matchResult === void 0 ? void 0 : matchResult[2]) === 'rpx') {
173
- return rpxCalcRoot ? `calc(${px}px / ${rpxCalcRoot})` : attr;
174
- }
175
- return `${+matchResult[1]}px`;
176
- }
177
- return attr;
178
- })
179
- .join(' ');
180
- }
181
- /**
182
- * Convert WeApps common style to css styles(React.CSSProperties)
183
- * toRem/toRpx/toRpx 三者互斥 @deprecated
184
- * 应使用 defaultUnit 来声明
185
- */
186
- function processCommonStyle2CSSProperties(commonStyle = {}, options = { toRem: true, ignoreSelf: false, addPXUnit: false, toRpx: false, rpxCalcRoot: undefined }) {
187
- const { size,
188
- // transform,
189
- text, border, background, margin, padding, zIndex, position, display, flexConfig, custom, self, boxShadow, } = commonStyle;
190
- const style = {};
191
- if (size) {
192
- setStyleValue(style, 'width', _handleStyleNumValue(size.width, !!options.addPXUnit));
193
- setStyleValue(style, 'height', _handleStyleNumValue(size.height, !!options.addPXUnit));
194
- }
195
- // if (transform) {
196
- // const { rotate, opacity, scale, radius } = transform
197
- // if ((rotate && rotate !== 0) || (scale && scale !== 1)) {
198
- // style.transform = `${rotate ? `rotate(${rotate}deg) ` : ''}${scale ? `scale(${scale})` : ''}`
199
- // }
200
- // setStyleValue(style, 'opacity', opacity)
201
- // setStyleValue(style, 'borderRadius', radius)
202
- // }
203
- if (margin) {
204
- setDistanceStyle(style, margin, 'margin', !!options.addPXUnit);
205
- }
206
- if (padding) {
207
- setDistanceStyle(style, padding, 'padding', !!options.addPXUnit);
208
- }
209
- if (display) {
210
- setStyleValue(style, 'display', display);
211
- }
212
- if (display === 'flex' && flexConfig) {
213
- if (flexConfig.justifyContent)
214
- setStyleValue(style, 'justifyContent', flexConfig.justifyContent);
215
- if (flexConfig.alignItems)
216
- setStyleValue(style, 'alignItems', flexConfig.alignItems);
217
- if (flexConfig.flexWrap && flexConfig.flexDirection) {
218
- setStyleValue(style, 'flexFlow', `${flexConfig.flexDirection} ${flexConfig.flexWrap}`);
219
- }
220
- else {
221
- if (flexConfig.flexWrap)
222
- setStyleValue(style, 'flexWrap', flexConfig.flexWrap);
223
- if (flexConfig.flexDirection)
224
- setStyleValue(style, 'flexDirection', flexConfig.flexDirection);
225
- }
226
- }
227
- if (typeof zIndex === 'number' || `${zIndex}`.search(/^\d+$/) === 0) {
228
- style.zIndex = zIndex;
229
- }
230
- if (text) {
231
- setStyleValue(style, 'color', text.color);
232
- setStyleValue(style, 'fontSize', _handleStyleNumValue(text.fontSize, !!options.addPXUnit));
233
- setStyleValue(style, 'lineHeight', text.lineHeight);
234
- setStyleValue(style, 'textAlign', text.textAlign);
235
- setStyleValue(style, 'fontWeight', text.weight);
236
- if (text.opacity !== undefined) {
237
- setStyleValue(style, 'opacity', text.opacity / 100);
238
- }
239
- }
240
- if (border) {
241
- const { type, color, width, radius, radiusInfo } = border;
242
- // width
243
- if (typeof width === 'string') {
244
- if (type && type !== 'none') {
245
- setStyleValue(style, 'border', `${_handleStyleNumValue(width, !!options.addPXUnit)} ${type} ${color || ''}`);
246
- }
247
- else {
248
- setStyleValue(style, 'borderWidth', _handleStyleNumValue(width, !!options.addPXUnit));
249
- if (color)
250
- setStyleValue(style, 'borderColor', color);
251
- }
252
- }
253
- else if (Object.prototype.toString.call(width) === '[object Object]' && Object.keys(width).length !== 0) {
254
- // https://developer.mozilla.org/zh-CN/docs/Web/CSS/border
255
- // 虽然border-width,、border-style和 border-color 简写属性接受最多 4 个参数来为不同的边设置宽度、风格和颜色,但 boder 属性只接受三个参数,分别是宽度、风格和颜色,所以这样会使得四条边的边框相同。
256
- const { top = '0', right = '0', bottom = '0', left = '0' } = width;
257
- setStyleValue(style, 'borderWidth', `${_handleStyleNumValue(top, !!options.addPXUnit) || '0'} ${_handleStyleNumValue(right, !!options.addPXUnit) || '0'} ${_handleStyleNumValue(bottom, !!options.addPXUnit) || '0'} ${_handleStyleNumValue(left, !!options.addPXUnit) || '0'}`);
258
- if (type) {
259
- setStyleValue(style, 'borderStyle', type);
260
- }
261
- if (color) {
262
- setStyleValue(style, 'borderColor', color);
263
- }
264
- }
265
- // border radius
266
- if (radius !== undefined) {
267
- setStyleValue(style, 'borderRadius', _handleStyleNumValue(radius, !!options.addPXUnit));
268
- }
269
- if (radiusInfo && !(0, common_1.isEmptyObj)(radiusInfo)) {
270
- let { topLeft, topRight, bottomRight, bottomLeft } = radiusInfo;
271
- if (Object.keys(radiusInfo).length === 4) {
272
- // 包含不为空的属性,将部分为空属性处理成 0
273
- if (Object.values(radiusInfo).some((corner) => !!corner)) {
274
- if (!topLeft) {
275
- topLeft = '0';
276
- }
277
- if (!topRight) {
278
- topRight = '0';
279
- }
280
- if (!bottomRight) {
281
- bottomRight = '0';
282
- }
283
- if (!bottomLeft) {
284
- bottomLeft = '0';
285
- }
286
- }
287
- if ((0, uniq_1.default)((0, map_1.default)(radiusInfo, (val) => val)).length === 1) {
288
- // 4个值全相等的情况
289
- setStyleValue(style, 'borderRadius', _handleStyleNumValue(topLeft, !!options.addPXUnit));
290
- }
291
- else if (topLeft === bottomRight && topRight === bottomLeft) {
292
- // 俩俩相等的情况
293
- setStyleValue(style, 'borderRadius', `${_handleStyleNumValue(topLeft, !!options.addPXUnit)} ${_handleStyleNumValue(topRight, !!options.addPXUnit)}`);
294
- }
295
- else if (topRight === bottomLeft) {
296
- setStyleValue(style, 'borderRadius', `${_handleStyleNumValue(topLeft, !!options.addPXUnit)} ${_handleStyleNumValue(topRight, !!options.addPXUnit)} ${_handleStyleNumValue(bottomRight, !!options.addPXUnit)}`);
297
- }
298
- else {
299
- setStyleValue(style, 'borderRadius', `${_handleStyleNumValue(topLeft, !!options.addPXUnit)} ${_handleStyleNumValue(topRight, !!options.addPXUnit)} ${_handleStyleNumValue(bottomRight, !!options.addPXUnit)} ${_handleStyleNumValue(bottomLeft, !!options.addPXUnit)}`);
300
- }
301
- }
302
- else {
303
- setStyleValue(style, 'borderTopLeftRadius', _handleStyleNumValue(topLeft, !!options.addPXUnit));
304
- setStyleValue(style, 'borderTopRightRadius', _handleStyleNumValue(topRight, !!options.addPXUnit));
305
- setStyleValue(style, 'borderBottomRightRadius', _handleStyleNumValue(bottomRight, !!options.addPXUnit));
306
- setStyleValue(style, 'borderBottomLeftRadius', _handleStyleNumValue(bottomLeft, !!options.addPXUnit));
307
- }
308
- }
309
- if (type === 'none') {
310
- setStyleValue(style, 'border', `none`);
311
- }
312
- }
313
- if (background) {
314
- const { bgType, color, image, size, repeat, position, positionObj } = background;
315
- if (bgType === 'none') {
316
- setStyleValue(style, 'background', 'none');
317
- }
318
- else if (bgType === 'color') {
319
- setStyleValue(style, 'background', color);
320
- }
321
- else if (bgType === 'image') {
322
- // 如 radial-gradient(crimson, skyblue);
323
- if (image != null) {
324
- if (image.search(/[()]/) >= 0) {
325
- style.background = image;
326
- }
327
- else {
328
- style.background = `url(${image})`;
329
- }
330
- }
331
- if (repeat)
332
- style.background += ` ${repeat}`;
333
- if (size) {
334
- setStyleValue(style, 'backgroundSize', _handleStyleNumValue(size, !!options.addPXUnit));
335
- }
336
- setStyleValue(style, 'backgroundPosition', position);
337
- if (positionObj && !(0, common_1.isEmptyObj)(positionObj)) {
338
- style.background += ` ${_handleStyleNumValue(positionObj.left, !!options.addPXUnit)} ${_handleStyleNumValue(positionObj.top, !!options.addPXUnit)}`;
339
- }
340
- }
341
- // FIXME: 这里兼容原有应用的数据,后面应去掉
342
- if (bgType === undefined) {
343
- setStyleValue(style, 'backgroundColor', color);
344
- if (image != null) {
345
- style.backgroundImage = `url(${image})`;
346
- setStyleValue(style, 'backgroundRepeat', repeat);
347
- setStyleValue(style, 'backgroundSize', _handleStyleNumValue(size, !!options.addPXUnit));
348
- setStyleValue(style, 'backgroundPosition', position);
349
- }
350
- }
351
- }
352
- if (position) {
353
- setStyleValue(style, 'position', position.position);
354
- if (position.left !== undefined) {
355
- setStyleValue(style, 'left', _handleStyleNumValue(position.left, !!options.addPXUnit));
356
- }
357
- if (position.right !== undefined) {
358
- setStyleValue(style, 'right', _handleStyleNumValue(position.right, !!options.addPXUnit));
359
- }
360
- if (position.top !== undefined) {
361
- setStyleValue(style, 'top', _handleStyleNumValue(position.top, !!options.addPXUnit));
362
- }
363
- if (position.bottom !== undefined) {
364
- setStyleValue(style, 'bottom', _handleStyleNumValue(position.bottom, !!options.addPXUnit));
365
- }
366
- }
367
- if (boxShadow) {
368
- let processedBoxShadow = boxShadow;
369
- if (Object.prototype.toString.call(boxShadow) === '[object Object]') {
370
- processedBoxShadow = [boxShadow];
371
- }
372
- let boxShadowStyleString = '';
373
- if (Array.isArray(processedBoxShadow)) {
374
- processedBoxShadow.forEach((boxShadowItem, index) => {
375
- let currentBoxShadowStyleString = '';
376
- const { keyWord, offsetX, offsetY, blurRadius, spreadRadius, color, global, inset } = boxShadowItem;
377
- // Keyword values
378
- if (keyWord === 'none') {
379
- currentBoxShadowStyleString = 'none';
380
- }
381
- else if (!!global) {
382
- currentBoxShadowStyleString = global;
383
- }
384
- else if (!!offsetX || !!offsetY) {
385
- // inset
386
- if (!!inset) {
387
- currentBoxShadowStyleString = 'inset ';
388
- }
389
- // offsetX
390
- currentBoxShadowStyleString += _handleStyleNumValue(!!offsetX ? offsetX : 0, !!options.addPXUnit);
391
- // offsetY
392
- currentBoxShadowStyleString += ` ${_handleStyleNumValue(!!offsetY ? offsetY : 0, !!options.addPXUnit)}`;
393
- // blur-radius 当 spread-radius 存在时,即使不存在 blur-radius,blur-radius 也要为 0
394
- if (!!blurRadius || !!spreadRadius) {
395
- currentBoxShadowStyleString += ` ${_handleStyleNumValue(!!blurRadius ? blurRadius : 0, !!options.addPXUnit)}`;
396
- }
397
- // spread-radius
398
- if (!!spreadRadius) {
399
- currentBoxShadowStyleString += ` ${_handleStyleNumValue(spreadRadius, !!options.addPXUnit)}`;
400
- }
401
- // color
402
- if (!!color) {
403
- currentBoxShadowStyleString += ` ${color}`;
404
- }
405
- }
406
- if (!!currentBoxShadowStyleString) {
407
- const splitLabel = !!boxShadowStyleString ? ' , ' : '';
408
- boxShadowStyleString += splitLabel + currentBoxShadowStyleString;
409
- }
410
- });
411
- }
412
- else if (typeof boxShadow === 'string') {
413
- boxShadowStyleString = boxShadow;
414
- }
415
- if (!!boxShadowStyleString) {
416
- setStyleValue(style, 'boxShadow', boxShadowStyleString);
417
- }
418
- }
419
- if (custom && custom.length > 0) {
420
- custom.map((item) => {
421
- setStyleValue(style, item.key, item.value);
422
- });
423
- }
424
- if (self && !options.ignoreSelf) {
425
- const _a = self, { cssFloat } = _a, restSelf = __rest(_a, ["cssFloat"]);
426
- Object.assign(style, restSelf);
427
- if (cssFloat) {
428
- Object.assign(style, { float: cssFloat });
429
- }
430
- }
431
- for (const key in style) {
432
- const value = style[key];
433
- if (Array.isArray(value)) {
434
- style[key] = value[value.length - 1];
435
- }
436
- }
437
- let { defaultUnit } = options;
438
- const translateStyleOptions = { rpxCalcRoot: options.rpxCalcRoot };
439
- if (!defaultUnit) {
440
- if (options.toRpx) {
441
- defaultUnit = 'rpx';
442
- }
443
- if (options.toRem) {
444
- defaultUnit = 'rem';
445
- }
446
- }
447
- if (defaultUnit) {
448
- return processCSSPropertiesUnit(style, defaultUnit, translateStyleOptions);
449
- }
450
- return style;
451
- }
452
- exports.processCommonStyle2CSSProperties = processCommonStyle2CSSProperties;
453
- /**
454
- * @deprecated
455
- */
456
- function processCSSProperties2Rem(style = {}, options) {
457
- return translateStyleByHandler(style, toREM, options);
458
- }
459
- exports.processCSSProperties2Rem = processCSSProperties2Rem;
460
- function processCSSPropertiesUnit(style = {}, type, options) {
461
- const handerMap = {
462
- px: toPX,
463
- rem: toREM,
464
- rpx: toRPX,
465
- };
466
- const handler = handerMap[type] ||
467
- function (cssLen, _) {
468
- return cssLen;
469
- };
470
- return translateStyleByHandler(style, handler, options);
471
- }
472
- exports.processCSSPropertiesUnit = processCSSPropertiesUnit;