@cloudbase/cals 0.4.2 → 0.4.5

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 CHANGED
@@ -18,7 +18,7 @@ CALS 规范主要分为三部分 :
18
18
 
19
19
  ## 应用
20
20
 
21
- CALS 扩展自[通用组件语言规范](https://cls.pages.woa.com/),目前主要应用于云开发低码平台,目前定义了 basic 和 platform 两套规范(platform 继承自 basic):
21
+ CALS 扩展自[通用组件语言规范](https://cls.pages.woa.com/),目前主要应用于微搭低代码平台,目前定义了 basic 和 platform 两套规范(platform 继承自 basic):
22
22
 
23
23
  | 类型 | 层级 | 定义 |
24
24
  | -------------- | ---- | ------------------------------------------ |
@@ -1,2 +1,12 @@
1
+ import { Properties } from 'csstype';
1
2
  export declare function removeInvalidStyleFormValue(styleForm?: any): any;
3
+ export declare function processCommonStyle2CSSProperties(commonStyle?: any, options?: {
4
+ toRem: boolean;
5
+ ignoreSelf?: boolean;
6
+ addPXUnit?: boolean;
7
+ toRpx?: boolean;
8
+ }): Properties<string | number>;
9
+ export declare function processCSSProperties2Rem(style?: Properties<string | number>, options?: {
10
+ looseError: boolean;
11
+ }): Properties<string | number>;
2
12
  //# sourceMappingURL=style.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"style.d.ts","sourceRoot":"","sources":["../../../../src/parser/cals/utils/style.ts"],"names":[],"mappings":"AAEA,wBAAgB,2BAA2B,CAAC,SAAS,GAAE,GAA2B,GAAG,GAAG,CAUvF"}
1
+ {"version":3,"file":"style.d.ts","sourceRoot":"","sources":["../../../../src/parser/cals/utils/style.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAKrC,wBAAgB,2BAA2B,CAAC,SAAS,GAAE,GAA2B,GAAG,GAAG,CAUvF;AA0ID,wBAAgB,gCAAgC,CAC9C,WAAW,GAAE,GAA2B,EACxC,OAAO,GAAE;IACP,KAAK,EAAE,OAAO,CAAC;IACf,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,KAAK,CAAC,EAAE,OAAO,CAAC;CACoD,GACrE,UAAU,CAAC,MAAM,GAAG,MAAM,CAAC,CAmN7B;AASD,wBAAgB,wBAAwB,CACtC,KAAK,GAAE,UAAU,CAAC,MAAM,GAAG,MAAM,CAAM,EACvC,OAAO;;CAAwB,GAC9B,UAAU,CAAC,MAAM,GAAG,MAAM,CAAC,CAE7B"}
@@ -1,7 +1,21 @@
1
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
+ };
2
13
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.removeInvalidStyleFormValue = void 0;
14
+ exports.processCSSProperties2Rem = exports.processCommonStyle2CSSProperties = exports.removeInvalidStyleFormValue = void 0;
4
15
  const common_1 = require("./common");
16
+ const lodash_1 = require("lodash");
17
+ const CSSProperty_1 = require("../../../utils/CSSProperty");
18
+ const DISTANCE_KEY_LIST = ['top', 'right', 'bottom', 'left'];
5
19
  function removeInvalidStyleFormValue(styleForm = {}) {
6
20
  return Object.keys(styleForm).reduce((result, key) => {
7
21
  const propStyleFormData = styleForm[key];
@@ -28,3 +42,275 @@ function setStyleValue(object, key, value) {
28
42
  }
29
43
  object[(0, common_1.camelcase)(key)] = value;
30
44
  }
45
+ function _handleStyleNumValue(styleVal, addPXUnit) {
46
+ if (addPXUnit) {
47
+ // 该分支实际没有使用?
48
+ // styleValue = '0.2' 时处理有问题
49
+ const value = `${styleVal}`;
50
+ if (value.search(/^\d+$/) >= 0) {
51
+ return `${value}px`;
52
+ }
53
+ }
54
+ return styleVal;
55
+ }
56
+ function setDistanceStyle(style, distance, attr, addPXUnit) {
57
+ const attributeKey = (0, common_1.camelcase)(`${attr}`);
58
+ if (Object.keys(distance).length === 4) {
59
+ if ((0, lodash_1.uniq)((0, lodash_1.map)(distance, (val) => val)).length === 1) {
60
+ // 4个值全相等的情况
61
+ setStyleValue(style, attributeKey, _handleStyleNumValue(distance.top, addPXUnit));
62
+ }
63
+ else if (distance.top === distance.bottom && distance.left === distance.right) {
64
+ // 俩俩相等的情况
65
+ setStyleValue(style, attributeKey, `${_handleStyleNumValue(distance.top, addPXUnit)} ${_handleStyleNumValue(distance.right, addPXUnit)}`);
66
+ }
67
+ else if (distance.left === distance.right) {
68
+ setStyleValue(style, attributeKey, `${_handleStyleNumValue(distance.top, addPXUnit)} ${_handleStyleNumValue(distance.right, addPXUnit)} ${_handleStyleNumValue(distance.bottom, addPXUnit)}`);
69
+ }
70
+ else {
71
+ setStyleValue(style, attributeKey, `${_handleStyleNumValue(distance.top, addPXUnit)} ${_handleStyleNumValue(distance.right, addPXUnit)} ${_handleStyleNumValue(distance.bottom, addPXUnit)} ${_handleStyleNumValue(distance.left, addPXUnit)}`);
72
+ }
73
+ }
74
+ else {
75
+ DISTANCE_KEY_LIST.forEach((key) => {
76
+ if (distance[key] !== undefined)
77
+ setStyleValue(style, (0, common_1.camelcase)(`${attr}_${key}`), _handleStyleNumValue(distance[key], addPXUnit));
78
+ });
79
+ }
80
+ }
81
+ function translateStyleByHandler(style = {}, handler, options = { looseError: false }) {
82
+ return Object.keys(style).reduce((result, key) => {
83
+ const value = style[key];
84
+ if (CSSProperty_1.isUnitlessNumber[key]) {
85
+ setStyleValue(result, key, value);
86
+ }
87
+ else if (value !== undefined && value !== null) {
88
+ try {
89
+ setStyleValue(result, key, handler(value));
90
+ }
91
+ catch (e) {
92
+ if (options.looseError) {
93
+ console.warn('translate style error, key:value', key, value);
94
+ }
95
+ else {
96
+ throw e;
97
+ }
98
+ }
99
+ }
100
+ return result;
101
+ }, {});
102
+ }
103
+ function calPxToREM(px) {
104
+ if (Number.isNaN(px / 28))
105
+ return px.toString();
106
+ if (+px === 0) {
107
+ return '0';
108
+ }
109
+ return `${(px / 28).toFixed(4)}rem`;
110
+ }
111
+ function toREM(cssLen) {
112
+ if (typeof cssLen === 'string') {
113
+ const cssLenArr = cssLen.split(' ');
114
+ return cssLenArr
115
+ .map((attr) => {
116
+ const matchResult = attr.match(/^(-?\d+)(px)?$/);
117
+ if (matchResult === null || matchResult === void 0 ? void 0 : matchResult[1]) {
118
+ return calPxToREM(+matchResult[1]);
119
+ }
120
+ return attr;
121
+ })
122
+ .join(' ');
123
+ }
124
+ else if (typeof cssLen === 'number') {
125
+ return calPxToREM(cssLen);
126
+ }
127
+ else {
128
+ throw new Error('cssLen type error');
129
+ }
130
+ }
131
+ function toRPX(cssLen) {
132
+ if (typeof cssLen === 'string') {
133
+ const cssLenArr = cssLen.split(' ');
134
+ return cssLenArr
135
+ .map((attr) => {
136
+ const matchResult = attr.match(/^(-?\d+)(px)?$/);
137
+ if (matchResult === null || matchResult === void 0 ? void 0 : matchResult[1]) {
138
+ return `${+matchResult[1]}rpx`;
139
+ }
140
+ return attr;
141
+ })
142
+ .join(' ');
143
+ }
144
+ return `${cssLen}rpx`;
145
+ }
146
+ // Convert WeApps common style to css styles(React.CSSProperties)
147
+ function processCommonStyle2CSSProperties(commonStyle = {}, options = { toRem: true, ignoreSelf: false, addPXUnit: false, toRpx: false }) {
148
+ const { size,
149
+ // transform,
150
+ text, border, background, margin, padding, zIndex, position, display, flexConfig, custom, self, } = commonStyle;
151
+ const style = {};
152
+ if (size) {
153
+ setStyleValue(style, 'width', _handleStyleNumValue(size.width, !!options.addPXUnit));
154
+ setStyleValue(style, 'height', _handleStyleNumValue(size.height, !!options.addPXUnit));
155
+ }
156
+ // if (transform) {
157
+ // const { rotate, opacity, scale, radius } = transform
158
+ // if ((rotate && rotate !== 0) || (scale && scale !== 1)) {
159
+ // style.transform = `${rotate ? `rotate(${rotate}deg) ` : ''}${scale ? `scale(${scale})` : ''}`
160
+ // }
161
+ // setStyleValue(style, 'opacity', opacity)
162
+ // setStyleValue(style, 'borderRadius', radius)
163
+ // }
164
+ if (margin) {
165
+ setDistanceStyle(style, margin, 'margin', !!options.addPXUnit);
166
+ }
167
+ if (padding) {
168
+ setDistanceStyle(style, padding, 'padding', !!options.addPXUnit);
169
+ }
170
+ if (display) {
171
+ setStyleValue(style, 'display', display);
172
+ }
173
+ if (display === 'flex' && flexConfig) {
174
+ if (flexConfig.justifyContent)
175
+ setStyleValue(style, 'justifyContent', flexConfig.justifyContent);
176
+ if (flexConfig.alignItems)
177
+ setStyleValue(style, 'alignItems', flexConfig.alignItems);
178
+ if (flexConfig.flexWrap && flexConfig.flexDirection) {
179
+ setStyleValue(style, 'flexFlow', `${flexConfig.flexDirection} ${flexConfig.flexWrap}`);
180
+ }
181
+ else {
182
+ if (flexConfig.flexWrap)
183
+ setStyleValue(style, 'flexWrap', flexConfig.flexWrap);
184
+ if (flexConfig.flexDirection)
185
+ setStyleValue(style, 'flexDirection', flexConfig.flexDirection);
186
+ }
187
+ }
188
+ if (typeof zIndex === 'number' || `${zIndex}`.search(/^\d+$/) === 0) {
189
+ style.zIndex = zIndex;
190
+ }
191
+ if (text) {
192
+ setStyleValue(style, 'color', text.color);
193
+ setStyleValue(style, 'fontSize', _handleStyleNumValue(text.fontSize, !!options.addPXUnit));
194
+ setStyleValue(style, 'lineHeight', text.lineHeight);
195
+ setStyleValue(style, 'textAlign', text.textAlign);
196
+ setStyleValue(style, 'fontWeight', text.weight);
197
+ if (text.opacity !== undefined) {
198
+ setStyleValue(style, 'opacity', text.opacity / 100);
199
+ }
200
+ }
201
+ if (border) {
202
+ const { type, color, width, radius, radiusInfo } = border;
203
+ if (width !== undefined) {
204
+ if (type && type !== 'none') {
205
+ setStyleValue(style, 'border', `${_handleStyleNumValue(width, !!options.addPXUnit)} ${type} ${color || ''}`);
206
+ }
207
+ else {
208
+ setStyleValue(style, 'borderWidth', _handleStyleNumValue(width, !!options.addPXUnit));
209
+ if (color)
210
+ setStyleValue(style, 'borderColor', color);
211
+ }
212
+ }
213
+ if (radius !== undefined) {
214
+ setStyleValue(style, 'borderRadius', _handleStyleNumValue(radius, !!options.addPXUnit));
215
+ }
216
+ if (radiusInfo && !(0, common_1.isEmptyObj)(radiusInfo)) {
217
+ if (Object.keys(radiusInfo).length === 4) {
218
+ if ((0, lodash_1.uniq)((0, lodash_1.map)(radiusInfo, (val) => val)).length === 1) {
219
+ // 4个值全相等的情况
220
+ setStyleValue(style, 'borderRadius', _handleStyleNumValue(radiusInfo.topLeft, !!options.addPXUnit));
221
+ }
222
+ else if (radiusInfo.topLeft === radiusInfo.bottomRight && radiusInfo.topRight === radiusInfo.bottomLeft) {
223
+ // 俩俩相等的情况
224
+ setStyleValue(style, 'borderRadius', `${_handleStyleNumValue(radiusInfo.topLeft, !!options.addPXUnit)} ${_handleStyleNumValue(radiusInfo.topRight, !!options.addPXUnit)}`);
225
+ }
226
+ else if (radiusInfo.topRight === radiusInfo.bottomLeft) {
227
+ setStyleValue(style, 'borderRadius', `${_handleStyleNumValue(radiusInfo.topLeft, !!options.addPXUnit)} ${_handleStyleNumValue(radiusInfo.topRight, !!options.addPXUnit)} ${_handleStyleNumValue(radiusInfo.bottomRight, !!options.addPXUnit)}`);
228
+ }
229
+ else {
230
+ setStyleValue(style, 'borderRadius', `${_handleStyleNumValue(radiusInfo.topLeft, !!options.addPXUnit)} ${_handleStyleNumValue(radiusInfo.topRight, !!options.addPXUnit)} ${_handleStyleNumValue(radiusInfo.bottomRight, !!options.addPXUnit)} ${_handleStyleNumValue(radiusInfo.bottomLeft, !!options.addPXUnit)}`);
231
+ }
232
+ }
233
+ else {
234
+ setStyleValue(style, 'borderTopLeftRadius', _handleStyleNumValue(radiusInfo.topLeft, !!options.addPXUnit));
235
+ setStyleValue(style, 'borderTopRightRadius', _handleStyleNumValue(radiusInfo.topRight, !!options.addPXUnit));
236
+ setStyleValue(style, 'borderBottomRightRadius', _handleStyleNumValue(radiusInfo.bottomRight, !!options.addPXUnit));
237
+ setStyleValue(style, 'borderBottomLeftRadius', _handleStyleNumValue(radiusInfo.bottomLeft, !!options.addPXUnit));
238
+ }
239
+ }
240
+ if (type === 'none') {
241
+ setStyleValue(style, 'border', `none`);
242
+ }
243
+ }
244
+ if (background) {
245
+ const { bgType, color, image, size, repeat, position, positionObj } = background;
246
+ if (bgType === 'color') {
247
+ setStyleValue(style, 'background', color);
248
+ }
249
+ else if (bgType === 'image') {
250
+ // 如 radial-gradient(crimson, skyblue);
251
+ if (image != null) {
252
+ if (image.search(/[()]/) >= 0) {
253
+ style.background = image;
254
+ }
255
+ else {
256
+ style.background = `url(${image})`;
257
+ }
258
+ }
259
+ if (repeat)
260
+ style.background += ` ${repeat}`;
261
+ if (size) {
262
+ setStyleValue(style, 'backgroundSize', _handleStyleNumValue(size, !!options.addPXUnit));
263
+ }
264
+ setStyleValue(style, 'backgroundPosition', position);
265
+ if (positionObj && !(0, common_1.isEmptyObj)(positionObj)) {
266
+ style.background += ` ${_handleStyleNumValue(positionObj.left, !!options.addPXUnit)} ${_handleStyleNumValue(positionObj.top, !!options.addPXUnit)}`;
267
+ }
268
+ }
269
+ // FIXME: 这里兼容原有应用的数据,后面应去掉
270
+ if (bgType === undefined) {
271
+ setStyleValue(style, 'backgroundColor', color);
272
+ if (image != null) {
273
+ style.backgroundImage = `url(${image})`;
274
+ setStyleValue(style, 'backgroundRepeat', repeat);
275
+ setStyleValue(style, 'backgroundSize', _handleStyleNumValue(size, !!options.addPXUnit));
276
+ setStyleValue(style, 'backgroundPosition', position);
277
+ }
278
+ }
279
+ }
280
+ if (position) {
281
+ setStyleValue(style, 'position', position.position);
282
+ if (position.left !== undefined) {
283
+ setStyleValue(style, 'left', _handleStyleNumValue(position.left, !!options.addPXUnit));
284
+ }
285
+ if (position.right !== undefined) {
286
+ setStyleValue(style, 'right', _handleStyleNumValue(position.right, !!options.addPXUnit));
287
+ }
288
+ if (position.top !== undefined) {
289
+ setStyleValue(style, 'top', _handleStyleNumValue(position.top, !!options.addPXUnit));
290
+ }
291
+ if (position.bottom !== undefined) {
292
+ setStyleValue(style, 'bottom', _handleStyleNumValue(position.bottom, !!options.addPXUnit));
293
+ }
294
+ }
295
+ if (custom && custom.length > 0) {
296
+ custom.map((item) => {
297
+ setStyleValue(style, item.key, item.value);
298
+ });
299
+ }
300
+ if (self && !options.ignoreSelf) {
301
+ const _a = self, { cssFloat } = _a, restSelf = __rest(_a, ["cssFloat"]);
302
+ Object.assign(style, restSelf, { float: cssFloat });
303
+ }
304
+ if (options.toRpx) {
305
+ return translateStyleToRpx(style);
306
+ }
307
+ return options.toRem ? processCSSProperties2Rem(style) : style;
308
+ }
309
+ exports.processCommonStyle2CSSProperties = processCommonStyle2CSSProperties;
310
+ function translateStyleToRpx(style = {}, options = { looseError: false }) {
311
+ return translateStyleByHandler(style, toRPX, options);
312
+ }
313
+ function processCSSProperties2Rem(style = {}, options = { looseError: false }) {
314
+ return translateStyleByHandler(style, toREM, options);
315
+ }
316
+ exports.processCSSProperties2Rem = processCSSProperties2Rem;
@@ -1,7 +1,8 @@
1
1
  export * from './cals/index';
2
2
  export { upgrageToVersion2 } from './cals/utils/version';
3
3
  export { processComponentModule } from './cals/utils/spinoff';
4
- export { calsToCode, codeToCals, ICodeItem, checkForConflicts, autoResolveConflicts, } from './cals/utils/code';
4
+ export { calsToCode, codeToCals, ICodeItem, checkForConflicts, autoResolveConflicts } from './cals/utils/code';
5
5
  export { parseComponentCals } from './cals/utils/block';
6
6
  export { ActionType, IDataBind, PropBindType } from './expression/index';
7
+ export { processCommonStyle2CSSProperties, processCSSProperties2Rem } from './cals/utils/style';
7
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/parser/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EACL,UAAU,EACV,UAAU,EACV,SAAS,EACT,iBAAiB,EACjB,oBAAoB,GACrB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/parser/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAC/G,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACzE,OAAO,EAAE,gCAAgC,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC"}
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.PropBindType = exports.ActionType = exports.parseComponentCals = exports.autoResolveConflicts = exports.checkForConflicts = exports.codeToCals = exports.calsToCode = exports.processComponentModule = exports.upgrageToVersion2 = void 0;
17
+ exports.processCSSProperties2Rem = exports.processCommonStyle2CSSProperties = exports.PropBindType = exports.ActionType = exports.parseComponentCals = exports.autoResolveConflicts = exports.checkForConflicts = exports.codeToCals = exports.calsToCode = exports.processComponentModule = exports.upgrageToVersion2 = void 0;
18
18
  __exportStar(require("./cals/index"), exports);
19
19
  var version_1 = require("./cals/utils/version");
20
20
  Object.defineProperty(exports, "upgrageToVersion2", { enumerable: true, get: function () { return version_1.upgrageToVersion2; } });
@@ -30,3 +30,6 @@ Object.defineProperty(exports, "parseComponentCals", { enumerable: true, get: fu
30
30
  var index_1 = require("./expression/index");
31
31
  Object.defineProperty(exports, "ActionType", { enumerable: true, get: function () { return index_1.ActionType; } });
32
32
  Object.defineProperty(exports, "PropBindType", { enumerable: true, get: function () { return index_1.PropBindType; } });
33
+ var style_1 = require("./cals/utils/style");
34
+ Object.defineProperty(exports, "processCommonStyle2CSSProperties", { enumerable: true, get: function () { return style_1.processCommonStyle2CSSProperties; } });
35
+ Object.defineProperty(exports, "processCSSProperties2Rem", { enumerable: true, get: function () { return style_1.processCSSProperties2Rem; } });
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Copyright (c) Facebook, Inc. and its affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ /**
8
+ * 来源:packages/react-dom/src/shared/CSSProperty.js
9
+ * react-dom 内部实现用于判断是否补齐 number 类型数据的 px 单位
10
+ */
11
+ /**
12
+ * CSS properties which accept numbers but are not in units of "px".
13
+ */
14
+ export declare const isUnitlessNumber: {
15
+ animationIterationCount: boolean;
16
+ aspectRatio: boolean;
17
+ borderImage: boolean;
18
+ borderImageOutset: boolean;
19
+ borderImageSlice: boolean;
20
+ borderImageWidth: boolean;
21
+ boxFlex: boolean;
22
+ boxFlexGroup: boolean;
23
+ boxOrdinalGroup: boolean;
24
+ columnCount: boolean;
25
+ columns: boolean;
26
+ flex: boolean;
27
+ flexGrow: boolean;
28
+ flexPositive: boolean;
29
+ flexShrink: boolean;
30
+ flexNegative: boolean;
31
+ flexOrder: boolean;
32
+ gridArea: boolean;
33
+ gridRow: boolean;
34
+ gridRowEnd: boolean;
35
+ gridRowSpan: boolean;
36
+ gridRowStart: boolean;
37
+ gridColumn: boolean;
38
+ gridColumnEnd: boolean;
39
+ gridColumnSpan: boolean;
40
+ gridColumnStart: boolean;
41
+ fontWeight: boolean;
42
+ lineClamp: boolean;
43
+ /**
44
+ * TODO:
45
+ * 历史原因,存量大量的是当做默认补充 px 单位来做的,导致没法一下子兼容,需要刷新设计态数据
46
+ */
47
+ opacity: boolean;
48
+ order: boolean;
49
+ orphans: boolean;
50
+ tabSize: boolean;
51
+ widows: boolean;
52
+ zIndex: boolean;
53
+ zoom: boolean;
54
+ fillOpacity: boolean;
55
+ floodOpacity: boolean;
56
+ stopOpacity: boolean;
57
+ strokeDasharray: boolean;
58
+ strokeDashoffset: boolean;
59
+ strokeMiterlimit: boolean;
60
+ strokeOpacity: boolean;
61
+ strokeWidth: boolean;
62
+ };
63
+ //# sourceMappingURL=CSSProperty.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CSSProperty.d.ts","sourceRoot":"","sources":["../../src/utils/CSSProperty.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;GAGG;AAEH;;GAEG;AAEH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA6B3B;;;OAGG;;;;;;;;;;;;;;;;CAmBJ,CAAC"}
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) Facebook, Inc. and its affiliates.
4
+ *
5
+ * This source code is licensed under the MIT license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.isUnitlessNumber = void 0;
10
+ /**
11
+ * 来源:packages/react-dom/src/shared/CSSProperty.js
12
+ * react-dom 内部实现用于判断是否补齐 number 类型数据的 px 单位
13
+ */
14
+ /**
15
+ * CSS properties which accept numbers but are not in units of "px".
16
+ */
17
+ exports.isUnitlessNumber = {
18
+ animationIterationCount: true,
19
+ aspectRatio: true,
20
+ borderImage: true,
21
+ borderImageOutset: true,
22
+ borderImageSlice: true,
23
+ borderImageWidth: true,
24
+ boxFlex: true,
25
+ boxFlexGroup: true,
26
+ boxOrdinalGroup: true,
27
+ columnCount: true,
28
+ columns: true,
29
+ flex: true,
30
+ flexGrow: true,
31
+ flexPositive: true,
32
+ flexShrink: true,
33
+ flexNegative: true,
34
+ flexOrder: true,
35
+ gridArea: true,
36
+ gridRow: true,
37
+ gridRowEnd: true,
38
+ gridRowSpan: true,
39
+ gridRowStart: true,
40
+ gridColumn: true,
41
+ gridColumnEnd: true,
42
+ gridColumnSpan: true,
43
+ gridColumnStart: true,
44
+ fontWeight: true,
45
+ lineClamp: true,
46
+ /**
47
+ * TODO:
48
+ * 历史原因,存量大量的是当做默认补充 px 单位来做的,导致没法一下子兼容,需要刷新设计态数据
49
+ */
50
+ // lineHeight: true,
51
+ opacity: true,
52
+ order: true,
53
+ orphans: true,
54
+ tabSize: true,
55
+ widows: true,
56
+ zIndex: true,
57
+ zoom: true,
58
+ // SVG-related properties
59
+ fillOpacity: true,
60
+ floodOpacity: true,
61
+ stopOpacity: true,
62
+ strokeDasharray: true,
63
+ strokeDashoffset: true,
64
+ strokeMiterlimit: true,
65
+ strokeOpacity: true,
66
+ strokeWidth: true,
67
+ };
68
+ /**
69
+ * @param {string} prefix vendor-specific prefix, eg: Webkit
70
+ * @param {string} key style name, eg: transitionDuration
71
+ * @return {string} style name prefixed with `prefix`, properly camelCased, eg:
72
+ * WebkitTransitionDuration
73
+ */
74
+ function prefixKey(prefix, key) {
75
+ return prefix + key.charAt(0).toUpperCase() + key.substring(1);
76
+ }
77
+ /**
78
+ * Support style names that may come passed in prefixed by adding permutations
79
+ * of vendor prefixes.
80
+ */
81
+ const prefixes = ['Webkit', 'ms', 'Moz', 'O'];
82
+ // Using Object.keys here, or else the vanilla for-in loop makes IE8 go into an
83
+ // infinite loop, because it iterates over the newly added props too.
84
+ Object.keys(exports.isUnitlessNumber).forEach(function (prop) {
85
+ prefixes.forEach(function (prefix) {
86
+ exports.isUnitlessNumber[prefixKey(prefix, prop)] = exports.isUnitlessNumber[prop];
87
+ });
88
+ });
@@ -1,4 +1,5 @@
1
1
  export * from '../parser';
2
2
  export * from '../types/index';
3
3
  export * from './constant';
4
+ export { isUnitlessNumber } from './CSSProperty';
4
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC"}
@@ -14,6 +14,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.isUnitlessNumber = void 0;
17
18
  __exportStar(require("../parser"), exports);
18
19
  __exportStar(require("../types/index"), exports);
19
20
  __exportStar(require("./constant"), exports);
21
+ var CSSProperty_1 = require("./CSSProperty");
22
+ Object.defineProperty(exports, "isUnitlessNumber", { enumerable: true, get: function () { return CSSProperty_1.isUnitlessNumber; } });
package/package.json CHANGED
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "name": "@cloudbase/cals",
3
- "version": "0.4.2",
3
+ "version": "0.4.5",
4
4
  "description": "Common application specifications",
5
5
  "main": "lib/utils/index.js",
6
+ "source": "src/utils/index.ts",
6
7
  "typedocMain": "src/types/index.ts",
7
8
  "files": [
8
9
  "lib"
@@ -30,6 +31,7 @@
30
31
  "@types/jest": "^27.4.0",
31
32
  "@types/lodash": "^4.14.168",
32
33
  "@types/node": "^14.14.6",
34
+ "@types/react": "^18.0.17",
33
35
  "ajv": "^8.8.2",
34
36
  "csstype": "^3.0.11",
35
37
  "jest": "^27.1.0",