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