@cloudbase/framework-plugin-low-code 1.0.1 → 1.0.2-beta.2

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 (218) hide show
  1. package/package.json +4 -4
  2. package/template/src/datasources/index.js.tpl +0 -2
  3. package/lib/builder/config/common.d.ts +0 -2
  4. package/lib/builder/config/common.d.ts.map +0 -1
  5. package/lib/builder/config/common.js +0 -13
  6. package/lib/builder/config/index.d.ts +0 -3
  7. package/lib/builder/config/index.d.ts.map +0 -1
  8. package/lib/builder/config/index.js +0 -29
  9. package/lib/builder/config/mp.d.ts +0 -2
  10. package/lib/builder/config/mp.d.ts.map +0 -1
  11. package/lib/builder/config/mp.js +0 -13
  12. package/lib/builder/core/copy.d.ts +0 -5
  13. package/lib/builder/core/copy.d.ts.map +0 -1
  14. package/lib/builder/core/copy.js +0 -62
  15. package/lib/builder/core/generate.d.ts +0 -9
  16. package/lib/builder/core/generate.d.ts.map +0 -1
  17. package/lib/builder/core/generate.js +0 -128
  18. package/lib/builder/core/index.d.ts +0 -32
  19. package/lib/builder/core/index.d.ts.map +0 -1
  20. package/lib/builder/core/index.js +0 -149
  21. package/lib/builder/core/material.d.ts +0 -4
  22. package/lib/builder/core/material.d.ts.map +0 -1
  23. package/lib/builder/core/material.js +0 -80
  24. package/lib/builder/core/plugin.d.ts +0 -4
  25. package/lib/builder/core/plugin.d.ts.map +0 -1
  26. package/lib/builder/core/plugin.js +0 -30
  27. package/lib/builder/core/prepare.d.ts +0 -8
  28. package/lib/builder/core/prepare.d.ts.map +0 -1
  29. package/lib/builder/core/prepare.js +0 -108
  30. package/lib/builder/core/webpack.d.ts +0 -15
  31. package/lib/builder/core/webpack.d.ts.map +0 -1
  32. package/lib/builder/core/webpack.js +0 -58
  33. package/lib/builder/mp/BuildContext.d.ts +0 -13
  34. package/lib/builder/mp/BuildContext.d.ts.map +0 -1
  35. package/lib/builder/mp/BuildContext.js +0 -2
  36. package/lib/builder/mp/index.d.ts +0 -33
  37. package/lib/builder/mp/index.d.ts.map +0 -1
  38. package/lib/builder/mp/index.js +0 -453
  39. package/lib/builder/mp/lowcode.d.ts +0 -8
  40. package/lib/builder/mp/lowcode.d.ts.map +0 -1
  41. package/lib/builder/mp/lowcode.js +0 -58
  42. package/lib/builder/mp/materials.d.ts +0 -15
  43. package/lib/builder/mp/materials.d.ts.map +0 -1
  44. package/lib/builder/mp/materials.js +0 -338
  45. package/lib/builder/mp/mixMode.d.ts +0 -10
  46. package/lib/builder/mp/mixMode.d.ts.map +0 -1
  47. package/lib/builder/mp/mixMode.js +0 -215
  48. package/lib/builder/mp/mp_config.d.ts +0 -18
  49. package/lib/builder/mp/mp_config.d.ts.map +0 -1
  50. package/lib/builder/mp/mp_config.js +0 -206
  51. package/lib/builder/mp/util.d.ts +0 -20
  52. package/lib/builder/mp/util.d.ts.map +0 -1
  53. package/lib/builder/mp/util.js +0 -239
  54. package/lib/builder/mp/wxml.d.ts +0 -16
  55. package/lib/builder/mp/wxml.d.ts.map +0 -1
  56. package/lib/builder/mp/wxml.js +0 -310
  57. package/lib/builder/service/builder/copy.d.ts +0 -14
  58. package/lib/builder/service/builder/copy.d.ts.map +0 -1
  59. package/lib/builder/service/builder/copy.js +0 -185
  60. package/lib/builder/service/builder/generate.d.ts +0 -52
  61. package/lib/builder/service/builder/generate.d.ts.map +0 -1
  62. package/lib/builder/service/builder/generate.js +0 -800
  63. package/lib/builder/service/builder/index.d.ts +0 -16
  64. package/lib/builder/service/builder/index.d.ts.map +0 -1
  65. package/lib/builder/service/builder/index.js +0 -69
  66. package/lib/builder/service/builder/plugin.d.ts +0 -8
  67. package/lib/builder/service/builder/plugin.d.ts.map +0 -1
  68. package/lib/builder/service/builder/plugin.js +0 -149
  69. package/lib/builder/service/builder/webpack.d.ts +0 -91
  70. package/lib/builder/service/builder/webpack.d.ts.map +0 -1
  71. package/lib/builder/service/builder/webpack.js +0 -594
  72. package/lib/builder/types/common.d.ts +0 -12
  73. package/lib/builder/types/common.d.ts.map +0 -1
  74. package/lib/builder/types/common.js +0 -7
  75. package/lib/builder/util/common.d.ts +0 -36
  76. package/lib/builder/util/common.d.ts.map +0 -1
  77. package/lib/builder/util/common.js +0 -257
  78. package/lib/builder/util/console.d.ts +0 -2
  79. package/lib/builder/util/console.d.ts.map +0 -1
  80. package/lib/builder/util/console.js +0 -13
  81. package/lib/builder/util/generateFiles.d.ts +0 -6
  82. package/lib/builder/util/generateFiles.d.ts.map +0 -1
  83. package/lib/builder/util/generateFiles.js +0 -94
  84. package/lib/builder/util/index.d.ts +0 -2
  85. package/lib/builder/util/index.d.ts.map +0 -1
  86. package/lib/builder/util/index.js +0 -13
  87. package/lib/builder/util/junk.d.ts +0 -3
  88. package/lib/builder/util/junk.d.ts.map +0 -1
  89. package/lib/builder/util/junk.js +0 -25
  90. package/lib/builder/util/mp.d.ts +0 -5
  91. package/lib/builder/util/mp.d.ts.map +0 -1
  92. package/lib/builder/util/mp.js +0 -99
  93. package/lib/builder/util/name-mangler.d.ts +0 -3
  94. package/lib/builder/util/name-mangler.d.ts.map +0 -1
  95. package/lib/builder/util/name-mangler.js +0 -7
  96. package/lib/builder/util/net.d.ts +0 -3
  97. package/lib/builder/util/net.d.ts.map +0 -1
  98. package/lib/builder/util/net.js +0 -54
  99. package/lib/builder/util/process.d.ts +0 -9
  100. package/lib/builder/util/process.d.ts.map +0 -1
  101. package/lib/builder/util/process.js +0 -28
  102. package/lib/builder/util/style.d.ts +0 -2
  103. package/lib/builder/util/style.d.ts.map +0 -1
  104. package/lib/builder/util/style.js +0 -13
  105. package/lib/builder/util/weapp.d.ts +0 -2
  106. package/lib/builder/util/weapp.d.ts.map +0 -1
  107. package/lib/builder/util/weapp.js +0 -13
  108. package/lib/generator/config/common.d.ts +0 -6
  109. package/lib/generator/config/common.d.ts.map +0 -1
  110. package/lib/generator/config/common.js +0 -25
  111. package/lib/generator/config/index.d.ts +0 -18
  112. package/lib/generator/config/index.d.ts.map +0 -1
  113. package/lib/generator/config/index.js +0 -43
  114. package/lib/generator/config/mp.d.ts +0 -56
  115. package/lib/generator/config/mp.d.ts.map +0 -1
  116. package/lib/generator/config/mp.js +0 -104
  117. package/lib/generator/core/generate.d.ts +0 -59
  118. package/lib/generator/core/generate.d.ts.map +0 -1
  119. package/lib/generator/core/generate.js +0 -669
  120. package/lib/generator/core/index.d.ts +0 -25
  121. package/lib/generator/core/index.d.ts.map +0 -1
  122. package/lib/generator/core/index.js +0 -102
  123. package/lib/generator/core/material.d.ts +0 -14
  124. package/lib/generator/core/material.d.ts.map +0 -1
  125. package/lib/generator/core/material.js +0 -230
  126. package/lib/generator/template.d.ts +0 -3
  127. package/lib/generator/template.d.ts.map +0 -1
  128. package/lib/generator/template.js +0 -3
  129. package/lib/generator/types/common.d.ts +0 -69
  130. package/lib/generator/types/common.d.ts.map +0 -1
  131. package/lib/generator/types/common.js +0 -21
  132. package/lib/generator/util/common.d.ts +0 -36
  133. package/lib/generator/util/common.d.ts.map +0 -1
  134. package/lib/generator/util/common.js +0 -238
  135. package/lib/generator/util/console.d.ts +0 -3
  136. package/lib/generator/util/console.d.ts.map +0 -1
  137. package/lib/generator/util/console.js +0 -17
  138. package/lib/generator/util/index.d.ts +0 -2
  139. package/lib/generator/util/index.d.ts.map +0 -1
  140. package/lib/generator/util/index.js +0 -13
  141. package/lib/generator/util/name-mangler.d.ts +0 -17
  142. package/lib/generator/util/name-mangler.d.ts.map +0 -1
  143. package/lib/generator/util/name-mangler.js +0 -63
  144. package/lib/generator/util/postcss-rpx.d.ts +0 -11
  145. package/lib/generator/util/postcss-rpx.d.ts.map +0 -1
  146. package/lib/generator/util/postcss-rpx.js +0 -16
  147. package/lib/generator/util/style.d.ts +0 -6
  148. package/lib/generator/util/style.d.ts.map +0 -1
  149. package/lib/generator/util/style.js +0 -92
  150. package/lib/generator/util/weapp.d.ts +0 -5
  151. package/lib/generator/util/weapp.d.ts.map +0 -1
  152. package/lib/generator/util/weapp.js +0 -17
  153. package/lib/types.d.ts +0 -14
  154. package/lib/types.d.ts.map +0 -1
  155. package/lib/types.js +0 -19
  156. package/lib/weapps-core/config/index.d.ts +0 -2
  157. package/lib/weapps-core/config/index.d.ts.map +0 -1
  158. package/lib/weapps-core/config/index.js +0 -13
  159. package/lib/weapps-core/config/style.d.ts +0 -7
  160. package/lib/weapps-core/config/style.d.ts.map +0 -1
  161. package/lib/weapps-core/config/style.js +0 -70
  162. package/lib/weapps-core/index.d.ts +0 -6
  163. package/lib/weapps-core/index.d.ts.map +0 -1
  164. package/lib/weapps-core/index.js +0 -31
  165. package/lib/weapps-core/types/action.d.ts +0 -25
  166. package/lib/weapps-core/types/action.d.ts.map +0 -1
  167. package/lib/weapps-core/types/action.js +0 -28
  168. package/lib/weapps-core/types/app.d.ts +0 -141
  169. package/lib/weapps-core/types/app.d.ts.map +0 -1
  170. package/lib/weapps-core/types/app.js +0 -21
  171. package/lib/weapps-core/types/appbuild.d.ts +0 -63
  172. package/lib/weapps-core/types/appbuild.d.ts.map +0 -1
  173. package/lib/weapps-core/types/appbuild.js +0 -78
  174. package/lib/weapps-core/types/code_types.d.ts +0 -26
  175. package/lib/weapps-core/types/code_types.d.ts.map +0 -1
  176. package/lib/weapps-core/types/code_types.js +0 -2
  177. package/lib/weapps-core/types/git.d.ts +0 -7
  178. package/lib/weapps-core/types/git.d.ts.map +0 -1
  179. package/lib/weapps-core/types/git.js +0 -2
  180. package/lib/weapps-core/types/index.d.ts +0 -11
  181. package/lib/weapps-core/types/index.d.ts.map +0 -1
  182. package/lib/weapps-core/types/index.js +0 -22
  183. package/lib/weapps-core/types/lowcode.d.ts +0 -26
  184. package/lib/weapps-core/types/lowcode.d.ts.map +0 -1
  185. package/lib/weapps-core/types/lowcode.js +0 -25
  186. package/lib/weapps-core/types/material.d.ts +0 -90
  187. package/lib/weapps-core/types/material.d.ts.map +0 -1
  188. package/lib/weapps-core/types/material.js +0 -9
  189. package/lib/weapps-core/types/plugins.d.ts +0 -17
  190. package/lib/weapps-core/types/plugins.d.ts.map +0 -1
  191. package/lib/weapps-core/types/plugins.js +0 -2
  192. package/lib/weapps-core/types/style.d.ts +0 -93
  193. package/lib/weapps-core/types/style.d.ts.map +0 -1
  194. package/lib/weapps-core/types/style.js +0 -2
  195. package/lib/weapps-core/types/web.d.ts +0 -120
  196. package/lib/weapps-core/types/web.d.ts.map +0 -1
  197. package/lib/weapps-core/types/web.js +0 -2
  198. package/lib/weapps-core/utils/appbuild.d.ts +0 -6
  199. package/lib/weapps-core/utils/appbuild.d.ts.map +0 -1
  200. package/lib/weapps-core/utils/appbuild.js +0 -40
  201. package/lib/weapps-core/utils/common.d.ts +0 -16
  202. package/lib/weapps-core/utils/common.d.ts.map +0 -1
  203. package/lib/weapps-core/utils/common.js +0 -90
  204. package/lib/weapps-core/utils/file.d.ts +0 -12
  205. package/lib/weapps-core/utils/file.d.ts.map +0 -1
  206. package/lib/weapps-core/utils/file.js +0 -142
  207. package/lib/weapps-core/utils/formily.d.ts +0 -5
  208. package/lib/weapps-core/utils/formily.d.ts.map +0 -1
  209. package/lib/weapps-core/utils/formily.js +0 -407
  210. package/lib/weapps-core/utils/index.d.ts +0 -7
  211. package/lib/weapps-core/utils/index.d.ts.map +0 -1
  212. package/lib/weapps-core/utils/index.js +0 -18
  213. package/lib/weapps-core/utils/lowcdoe.d.ts +0 -4
  214. package/lib/weapps-core/utils/lowcdoe.d.ts.map +0 -1
  215. package/lib/weapps-core/utils/lowcdoe.js +0 -69
  216. package/lib/weapps-core/utils/style.d.ts +0 -17
  217. package/lib/weapps-core/utils/style.d.ts.map +0 -1
  218. package/lib/weapps-core/utils/style.js +0 -321
@@ -1,17 +0,0 @@
1
- import { CSSProperties, ICommonStyle } from '../types';
2
- export declare function toCssStyle(commonStyle?: ICommonStyle, options?: {
3
- toRem: boolean;
4
- ignoreSelf?: boolean;
5
- addPXUnit?: boolean;
6
- toRpx?: boolean;
7
- }): CSSProperties;
8
- export declare function removeInvalidStyleFormValue(styleForm?: ICommonStyle): ICommonStyle;
9
- export declare function translateStyleToRpx(style?: CSSProperties): CSSProperties;
10
- export declare function translateStyleToRem(style?: CSSProperties): CSSProperties;
11
- export declare function translateStyleByHandler(style: any, handler: (p: string) => string): {};
12
- export declare function toREM(cssLen: number | string): string;
13
- export declare function toRPX(cssLen: number | string): string;
14
- export declare function removeWrapperBadEffectStyle(commonStyle?: CSSProperties): CSSProperties;
15
- export declare function removeEffectTwiceStyle(commonStyle?: CSSProperties): CSSProperties;
16
- export declare function toCssText(style: CSSProperties, className?: string): string;
17
- //# sourceMappingURL=style.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"style.d.ts","sourceRoot":"","sources":["../../../src/weapps-core/utils/style.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAqBvD,wBAAgB,UAAU,CACxB,WAAW,GAAE,YAAiB,EAC9B,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,aAAa,CAwSf;AAED,wBAAgB,2BAA2B,CACzC,SAAS,GAAE,YAAiB,GAC3B,YAAY,CAcd;AAgED,wBAAgB,mBAAmB,CAAC,KAAK,GAAE,aAAkB,GAAG,aAAa,CAE5E;AAED,wBAAgB,mBAAmB,CAAC,KAAK,GAAE,aAAkB,GAAG,aAAa,CAE5E;AAED,wBAAgB,uBAAuB,CACrC,KAAK,KAAoB,EACzB,OAAO,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,MAW/B;AA0BD,wBAAgB,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAiBrD;AAED,wBAAgB,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAcrD;AAED,wBAAgB,2BAA2B,CACzC,WAAW,GAAE,aAAkB,GAC9B,aAAa,CAgBf;AAED,wBAAgB,sBAAsB,CACpC,WAAW,GAAE,aAAkB,GAC9B,aAAa,CAuBf;AAED,wBAAgB,SAAS,CACvB,KAAK,EAAE,aAAa,EACpB,SAAS,SAAqB,UAS/B"}
@@ -1,321 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.toCssText = exports.removeEffectTwiceStyle = exports.removeWrapperBadEffectStyle = exports.toRPX = exports.toREM = exports.translateStyleByHandler = exports.translateStyleToRem = exports.translateStyleToRpx = exports.removeInvalidStyleFormValue = exports.toCssStyle = void 0;
7
- const uniq_1 = __importDefault(require("lodash/uniq"));
8
- const map_1 = __importDefault(require("lodash/map"));
9
- const config_1 = require("../config");
10
- const common_1 = require("./common");
11
- function _handleStyleNumValue(styleVal, addPXUnit) {
12
- if (addPXUnit) {
13
- const value = `${styleVal}`;
14
- if (value.search(/^\d+$/) >= 0) {
15
- return value + 'px';
16
- }
17
- }
18
- return styleVal;
19
- }
20
- function toCssStyle(commonStyle = {}, options = { toRem: true, ignoreSelf: false, addPXUnit: false, toRpx: false }) {
21
- const { size, text, border, background, margin, padding, zIndex, position, display, flexConfig, custom, self, } = commonStyle;
22
- const style = {};
23
- if (size) {
24
- setStyleValue(style, 'width', _handleStyleNumValue(size.width, !!options.addPXUnit));
25
- setStyleValue(style, 'height', _handleStyleNumValue(size.height, !!options.addPXUnit));
26
- }
27
- if (margin) {
28
- setDistanceStyle(style, margin, 'margin', !!options.addPXUnit);
29
- }
30
- if (padding) {
31
- setDistanceStyle(style, padding, 'padding', !!options.addPXUnit);
32
- }
33
- if (display) {
34
- setStyleValue(style, 'display', display);
35
- }
36
- if (display === 'flex' && flexConfig) {
37
- if (flexConfig.justifyContent)
38
- setStyleValue(style, 'justifyContent', flexConfig.justifyContent);
39
- if (flexConfig.alignItems)
40
- setStyleValue(style, 'alignItems', flexConfig.alignItems);
41
- if (flexConfig.flexWrap && flexConfig.flexDirection) {
42
- setStyleValue(style, 'flexFlow', `${flexConfig.flexDirection} ${flexConfig.flexWrap}`);
43
- }
44
- else {
45
- if (flexConfig.flexWrap)
46
- setStyleValue(style, 'flexWrap', flexConfig.flexWrap);
47
- if (flexConfig.flexDirection)
48
- setStyleValue(style, 'flexDirection', flexConfig.flexDirection);
49
- }
50
- }
51
- if (typeof zIndex === 'number' || `${zIndex}`.search(/^\d+$/) === 0) {
52
- style.zIndex = zIndex;
53
- }
54
- if (text) {
55
- setStyleValue(style, 'color', text.color);
56
- setStyleValue(style, 'fontSize', _handleStyleNumValue(text.fontSize, !!options.addPXUnit));
57
- setStyleValue(style, 'lineHeight', text.lineHeight);
58
- setStyleValue(style, 'textAlign', text.textAlign);
59
- setStyleValue(style, 'fontWeight', text.weight);
60
- if (text.opacity) {
61
- setStyleValue(style, 'opacity', text.opacity / 100);
62
- }
63
- }
64
- if (border) {
65
- const { type, color, width, radius, radiusInfo } = border;
66
- if (width !== undefined) {
67
- if (type) {
68
- setStyleValue(style, 'border', `${_handleStyleNumValue(width, !!options.addPXUnit)} ${type} ${color || ''}`);
69
- }
70
- else {
71
- setStyleValue(style, 'borderWidth', _handleStyleNumValue(width, !!options.addPXUnit));
72
- if (color)
73
- setStyleValue(style, 'borderColor', color);
74
- }
75
- }
76
- if (radius !== undefined) {
77
- setStyleValue(style, 'borderRadius', _handleStyleNumValue(radius, !!options.addPXUnit));
78
- }
79
- if (radiusInfo && !(0, common_1.isEmptyObj)(radiusInfo)) {
80
- if (Object.keys(radiusInfo).length === 4) {
81
- if ((0, uniq_1.default)((0, map_1.default)(radiusInfo, (val) => val)).length === 1) {
82
- setStyleValue(style, 'borderRadius', _handleStyleNumValue(radiusInfo.topLeft, !!options.addPXUnit));
83
- }
84
- else if (radiusInfo.topLeft === radiusInfo.bottomRight &&
85
- radiusInfo.topRight === radiusInfo.bottomLeft) {
86
- setStyleValue(style, 'borderRadius', `${_handleStyleNumValue(radiusInfo.topLeft, !!options.addPXUnit)} ${_handleStyleNumValue(radiusInfo.topRight, !!options.addPXUnit)}`);
87
- }
88
- else if (radiusInfo.topRight === radiusInfo.bottomLeft) {
89
- setStyleValue(style, 'borderRadius', `${_handleStyleNumValue(radiusInfo.topLeft, !!options.addPXUnit)} ${_handleStyleNumValue(radiusInfo.topRight, !!options.addPXUnit)} ${_handleStyleNumValue(radiusInfo.bottomRight, !!options.addPXUnit)}`);
90
- }
91
- else {
92
- setStyleValue(style, 'borderRadius', `${_handleStyleNumValue(radiusInfo.topLeft, !!options.addPXUnit)} ${_handleStyleNumValue(radiusInfo.topRight, !!options.addPXUnit)} ${_handleStyleNumValue(radiusInfo.bottomRight, !!options.addPXUnit)} ${_handleStyleNumValue(radiusInfo.bottomLeft, !!options.addPXUnit)}`);
93
- }
94
- }
95
- else {
96
- setStyleValue(style, 'borderTopLeftRadius', _handleStyleNumValue(radiusInfo.topLeft, !!options.addPXUnit));
97
- setStyleValue(style, 'borderTopRightRadius', _handleStyleNumValue(radiusInfo.topRight, !!options.addPXUnit));
98
- setStyleValue(style, 'borderBottomRightRadius', _handleStyleNumValue(radiusInfo.bottomRight, !!options.addPXUnit));
99
- setStyleValue(style, 'borderBottomLeftRadius', _handleStyleNumValue(radiusInfo.bottomLeft, !!options.addPXUnit));
100
- }
101
- }
102
- }
103
- if (background) {
104
- const { bgType, color, image, size, repeat, position, positionObj } = background;
105
- if (bgType === 'color') {
106
- setStyleValue(style, 'background', color);
107
- }
108
- else if (bgType === 'image') {
109
- if (image != null) {
110
- if (image.search(/[()]/) >= 0) {
111
- style.background = image;
112
- }
113
- else {
114
- style.background = `url(${image})`;
115
- }
116
- }
117
- if (repeat)
118
- style.background += ` ${repeat}`;
119
- if (size) {
120
- setStyleValue(style, 'backgroundSize', _handleStyleNumValue(size, !!options.addPXUnit));
121
- }
122
- setStyleValue(style, 'backgroundPosition', position);
123
- if (positionObj && !(0, common_1.isEmptyObj)(positionObj)) {
124
- style.background += ` ${_handleStyleNumValue(positionObj.left, !!options.addPXUnit)} ${_handleStyleNumValue(positionObj.top, !!options.addPXUnit)}`;
125
- }
126
- }
127
- if (bgType === undefined) {
128
- setStyleValue(style, 'backgroundColor', color);
129
- if (image != null) {
130
- style.backgroundImage = `url(${image})`;
131
- setStyleValue(style, 'backgroundRepeat', repeat);
132
- setStyleValue(style, 'backgroundSize', _handleStyleNumValue(size, !!options.addPXUnit));
133
- setStyleValue(style, 'backgroundPosition', position);
134
- }
135
- }
136
- }
137
- if (position) {
138
- setStyleValue(style, 'position', position.position);
139
- if (position.left !== undefined) {
140
- setStyleValue(style, 'left', _handleStyleNumValue(position.left, !!options.addPXUnit));
141
- }
142
- if (position.right !== undefined) {
143
- setStyleValue(style, 'right', _handleStyleNumValue(position.right, !!options.addPXUnit));
144
- }
145
- if (position.top !== undefined) {
146
- setStyleValue(style, 'top', _handleStyleNumValue(position.top, !!options.addPXUnit));
147
- }
148
- if (position.bottom !== undefined) {
149
- setStyleValue(style, 'bottom', _handleStyleNumValue(position.bottom, !!options.addPXUnit));
150
- }
151
- }
152
- if (custom && custom.length > 0) {
153
- custom.map((item) => {
154
- setStyleValue(style, item.key, item.value);
155
- });
156
- }
157
- if (self && !options.ignoreSelf) {
158
- Object.assign(style, self);
159
- }
160
- if (options.toRpx) {
161
- return translateStyleToRpx(style);
162
- }
163
- return options.toRem ? translateStyleToRem(style) : style;
164
- }
165
- exports.toCssStyle = toCssStyle;
166
- function removeInvalidStyleFormValue(styleForm = {}) {
167
- return Object.keys(styleForm).reduce((result, key) => {
168
- const propStyleFormData = styleForm[key];
169
- if ((0, common_1.isPlainObject)(propStyleFormData)) {
170
- setStyleValue(result, key, removeInvalidStyleFormValue(propStyleFormData));
171
- }
172
- else {
173
- setStyleValue(result, key, styleForm[key]);
174
- }
175
- return result;
176
- }, {});
177
- }
178
- exports.removeInvalidStyleFormValue = removeInvalidStyleFormValue;
179
- function setDistanceStyle(style, distance, attr, addPXUnit) {
180
- if (Object.keys(distance).length === 4) {
181
- if ((0, uniq_1.default)((0, map_1.default)(distance, (val) => val)).length === 1) {
182
- setStyleValue(style, (0, common_1.camelcase)(`${attr}`), _handleStyleNumValue(distance.top, addPXUnit));
183
- }
184
- else if (distance.top === distance.bottom &&
185
- distance.left === distance.right) {
186
- setStyleValue(style, (0, common_1.camelcase)(`${attr}`), `${_handleStyleNumValue(distance.top, addPXUnit)} ${_handleStyleNumValue(distance.right, addPXUnit)}`);
187
- }
188
- else if (distance.left === distance.right) {
189
- setStyleValue(style, (0, common_1.camelcase)(`${attr}`), `${_handleStyleNumValue(distance.top, addPXUnit)} ${_handleStyleNumValue(distance.right, addPXUnit)} ${_handleStyleNumValue(distance.bottom, addPXUnit)}`);
190
- }
191
- else {
192
- setStyleValue(style, (0, common_1.camelcase)(`${attr}`), `${_handleStyleNumValue(distance.top, addPXUnit)} ${_handleStyleNumValue(distance.right, addPXUnit)} ${_handleStyleNumValue(distance.bottom, addPXUnit)} ${_handleStyleNumValue(distance.left, addPXUnit)}`);
193
- }
194
- }
195
- else {
196
- config_1.DISTANCE_KEY_LIST.forEach((key) => {
197
- if (distance[key] !== undefined)
198
- setStyleValue(style, (0, common_1.camelcase)(`${attr}_${key}`), _handleStyleNumValue(distance[key], addPXUnit));
199
- });
200
- }
201
- }
202
- function translateStyleToRpx(style = {}) {
203
- return translateStyleByHandler(style, toRPX);
204
- }
205
- exports.translateStyleToRpx = translateStyleToRpx;
206
- function translateStyleToRem(style = {}) {
207
- return translateStyleByHandler(style, toREM);
208
- }
209
- exports.translateStyleToRem = translateStyleToRem;
210
- function translateStyleByHandler(style = {}, handler) {
211
- return Object.keys(style).reduce((result, key) => {
212
- const value = style[key];
213
- if (config_1.PERCENTAGE_KEY_LIST.includes(key)) {
214
- setStyleValue(result, key, value);
215
- }
216
- else if (value !== undefined && value !== null) {
217
- setStyleValue(result, key, handler(value));
218
- }
219
- return result;
220
- }, {});
221
- }
222
- exports.translateStyleByHandler = translateStyleByHandler;
223
- function setStyleValue(object, key, value) {
224
- if (value === undefined || value === null || value === '') {
225
- return;
226
- }
227
- if (key === 'open') {
228
- return;
229
- }
230
- if ((0, common_1.isEmptyObj)(value)) {
231
- return;
232
- }
233
- object[(0, common_1.camelcase)(key)] = value;
234
- }
235
- function calPxToREM(px) {
236
- if (Number.isNaN(px / 28))
237
- return px.toString();
238
- if (+px === 0) {
239
- return '0';
240
- }
241
- return (px / 28).toFixed(4) + 'rem';
242
- }
243
- function toREM(cssLen) {
244
- if (typeof cssLen === 'string') {
245
- const cssLenArr = cssLen.split(' ');
246
- return cssLenArr
247
- .map((attr) => {
248
- const matchResult = attr.match(/^(-?\d+)(px)?$/);
249
- if (matchResult && matchResult[1]) {
250
- return calPxToREM(+matchResult[1]);
251
- }
252
- return attr;
253
- })
254
- .join(' ');
255
- }
256
- else if (typeof cssLen === 'number') {
257
- return calPxToREM(cssLen);
258
- }
259
- else {
260
- throw new Error('cssLen type error');
261
- }
262
- }
263
- exports.toREM = toREM;
264
- function toRPX(cssLen) {
265
- if (typeof cssLen === 'string') {
266
- const cssLenArr = cssLen.split(' ');
267
- return cssLenArr
268
- .map((attr) => {
269
- const matchResult = attr.match(/^(-?\d+)(px)?$/);
270
- if (matchResult && matchResult[1]) {
271
- return `${+matchResult[1]}rpx`;
272
- }
273
- return attr;
274
- })
275
- .join(' ');
276
- }
277
- return `${cssLen}rpx`;
278
- }
279
- exports.toRPX = toRPX;
280
- function removeWrapperBadEffectStyle(commonStyle = {}) {
281
- return Object.keys(commonStyle).reduce((result, key) => {
282
- const value = commonStyle[key];
283
- const camelcaseKey = (0, common_1.camelcase)(key);
284
- if (config_1.WRAPPER_REMOVE_STYLE_KEY_LIST.includes(camelcaseKey)) {
285
- return result;
286
- }
287
- if (key === 'display' && value === 'flex') {
288
- return result;
289
- }
290
- setStyleValue(result, camelcaseKey, value);
291
- return result;
292
- }, {});
293
- }
294
- exports.removeWrapperBadEffectStyle = removeWrapperBadEffectStyle;
295
- function removeEffectTwiceStyle(commonStyle = {}) {
296
- const style = {};
297
- Object.keys(commonStyle).map((key) => {
298
- const value = commonStyle[key];
299
- const camelcaseKey = (0, common_1.camelcase)(key);
300
- if (config_1.SELF_REMOVE_STYLE_KEY_LIST.includes(camelcaseKey)) {
301
- return false;
302
- }
303
- if (config_1.SELF_REMOVE_WITH_PERCENTAGE_KEY_LIST.includes(camelcaseKey) &&
304
- String(value).match(/.+%$/)) {
305
- return false;
306
- }
307
- setStyleValue(style, camelcaseKey, value);
308
- });
309
- return style;
310
- }
311
- exports.removeEffectTwiceStyle = removeEffectTwiceStyle;
312
- function toCssText(style, className = '.some-class-name') {
313
- const attrText = Object.keys(style)
314
- .map((key) => {
315
- const value = style[key];
316
- return `${(0, common_1.kebabCase)(key)}: ${value};`;
317
- })
318
- .join('\n');
319
- return `${className} { ${attrText} }\n`;
320
- }
321
- exports.toCssText = toCssText;