@mpxjs/webpack-plugin 2.9.62 → 2.9.64
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/lib/index.js +1 -3
- package/lib/platform/style/wx/index.js +67 -53
- package/lib/react/processStyles.js +1 -0
- package/lib/react/processTemplate.js +2 -3
- package/lib/react/style-helper.js +12 -7
- package/lib/runtime/components/react/context.ts +9 -7
- package/lib/runtime/components/react/dist/context.js +1 -0
- package/lib/runtime/components/react/dist/getInnerListeners.js +12 -1
- package/lib/runtime/components/react/dist/mpx-button.jsx +52 -74
- package/lib/runtime/components/react/dist/mpx-checkbox-group.jsx +19 -18
- package/lib/runtime/components/react/dist/mpx-checkbox.jsx +28 -41
- package/lib/runtime/components/react/dist/mpx-form.jsx +16 -14
- package/lib/runtime/components/react/dist/mpx-icon.jsx +14 -17
- package/lib/runtime/components/react/dist/mpx-image/index.jsx +34 -33
- package/lib/runtime/components/react/dist/mpx-image/svg.jsx +3 -1
- package/lib/runtime/components/react/dist/mpx-input.jsx +35 -31
- package/lib/runtime/components/react/dist/mpx-label.jsx +29 -37
- package/lib/runtime/components/react/dist/mpx-movable-area.jsx +13 -18
- package/lib/runtime/components/react/dist/mpx-movable-view.jsx +8 -8
- package/lib/runtime/components/react/dist/mpx-picker/index.jsx +9 -9
- package/lib/runtime/components/react/dist/mpx-picker/multiSelector.jsx +7 -4
- package/lib/runtime/components/react/dist/mpx-picker/region.jsx +11 -7
- package/lib/runtime/components/react/dist/mpx-picker/selector.jsx +1 -1
- package/lib/runtime/components/react/dist/mpx-picker/time.jsx +18 -18
- package/lib/runtime/components/react/dist/mpx-picker-view-column.jsx +102 -10
- package/lib/runtime/components/react/dist/mpx-picker-view.jsx +147 -53
- package/lib/runtime/components/react/dist/mpx-radio-group.jsx +19 -18
- package/lib/runtime/components/react/dist/mpx-radio.jsx +28 -43
- package/lib/runtime/components/react/dist/mpx-root-portal.jsx +8 -4
- package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +33 -26
- package/lib/runtime/components/react/dist/mpx-swiper/carouse.jsx +139 -74
- package/lib/runtime/components/react/dist/mpx-swiper/index.jsx +14 -6
- package/lib/runtime/components/react/dist/mpx-swiper-item.jsx +19 -11
- package/lib/runtime/components/react/dist/mpx-switch.jsx +17 -14
- package/lib/runtime/components/react/dist/mpx-text.jsx +19 -35
- package/lib/runtime/components/react/dist/mpx-textarea.jsx +1 -1
- package/lib/runtime/components/react/dist/mpx-view.jsx +284 -209
- package/lib/runtime/components/react/dist/mpx-web-view.jsx +8 -5
- package/lib/runtime/components/react/dist/parser.js +218 -0
- package/lib/runtime/components/react/dist/utils.jsx +433 -0
- package/lib/runtime/components/react/getInnerListeners.ts +18 -8
- package/lib/runtime/components/react/mpx-button.tsx +81 -91
- package/lib/runtime/components/react/mpx-checkbox-group.tsx +48 -43
- package/lib/runtime/components/react/mpx-checkbox.tsx +52 -63
- package/lib/runtime/components/react/mpx-form.tsx +49 -21
- package/lib/runtime/components/react/mpx-icon.tsx +30 -27
- package/lib/runtime/components/react/mpx-image/index.tsx +52 -46
- package/lib/runtime/components/react/mpx-image/svg.tsx +5 -3
- package/lib/runtime/components/react/mpx-input.tsx +58 -38
- package/lib/runtime/components/react/mpx-label.tsx +54 -59
- package/lib/runtime/components/react/mpx-movable-area.tsx +38 -24
- package/lib/runtime/components/react/mpx-movable-view.tsx +27 -28
- package/lib/runtime/components/react/mpx-navigator.tsx +2 -2
- package/lib/runtime/components/react/mpx-picker/date.tsx +2 -3
- package/lib/runtime/components/react/mpx-picker/index.tsx +10 -10
- package/lib/runtime/components/react/mpx-picker/multiSelector.tsx +15 -12
- package/lib/runtime/components/react/mpx-picker/region.tsx +21 -18
- package/lib/runtime/components/react/mpx-picker/selector.tsx +5 -6
- package/lib/runtime/components/react/mpx-picker/time.tsx +25 -29
- package/lib/runtime/components/react/mpx-picker/type.ts +1 -1
- package/lib/runtime/components/react/mpx-picker-view-column.tsx +148 -20
- package/lib/runtime/components/react/mpx-picker-view.tsx +179 -63
- package/lib/runtime/components/react/mpx-radio-group.tsx +50 -47
- package/lib/runtime/components/react/mpx-radio.tsx +56 -72
- package/lib/runtime/components/react/mpx-root-portal.tsx +10 -8
- package/lib/runtime/components/react/mpx-scroll-view.tsx +133 -103
- package/lib/runtime/components/react/mpx-swiper/carouse.tsx +174 -96
- package/lib/runtime/components/react/mpx-swiper/index.tsx +18 -9
- package/lib/runtime/components/react/mpx-swiper/type.ts +16 -5
- package/lib/runtime/components/react/mpx-swiper-item.tsx +46 -13
- package/lib/runtime/components/react/mpx-switch.tsx +44 -23
- package/lib/runtime/components/react/mpx-text.tsx +37 -45
- package/lib/runtime/components/react/mpx-textarea.tsx +1 -1
- package/lib/runtime/components/react/mpx-view.tsx +388 -240
- package/lib/runtime/components/react/mpx-web-view.tsx +19 -20
- package/lib/runtime/components/react/parser.ts +245 -0
- package/lib/runtime/components/react/types/common.ts +4 -4
- package/lib/runtime/components/react/types/global.d.ts +14 -2
- package/lib/runtime/components/react/useNodesRef.ts +1 -2
- package/lib/runtime/components/react/utils.tsx +505 -0
- package/lib/template-compiler/compiler.js +28 -20
- package/lib/template-compiler/gen-node-react.js +1 -3
- package/lib/web/processStyles.js +2 -5
- package/package.json +6 -4
- package/lib/runtime/components/react/dist/utils.js +0 -148
- package/lib/runtime/components/react/utils.ts +0 -170
package/lib/index.js
CHANGED
|
@@ -1812,7 +1812,6 @@ try {
|
|
|
1812
1812
|
}
|
|
1813
1813
|
|
|
1814
1814
|
if (isWeb(mpx.mode)) {
|
|
1815
|
-
const mpxStyleOptions = queryObj.mpxStyleOptions
|
|
1816
1815
|
const firstLoader = loaders[0] ? toPosix(loaders[0].loader) : ''
|
|
1817
1816
|
const isPitcherRequest = firstLoader.includes('node_modules/vue-loader/lib/loaders/pitcher')
|
|
1818
1817
|
let cssLoaderIndex = -1
|
|
@@ -1837,8 +1836,7 @@ try {
|
|
|
1837
1836
|
}
|
|
1838
1837
|
if (loaderIndex > -1) {
|
|
1839
1838
|
loaders.splice(loaderIndex + 1, 0, {
|
|
1840
|
-
loader: styleCompilerPath
|
|
1841
|
-
options: (mpxStyleOptions && JSON.parse(mpxStyleOptions)) || {}
|
|
1839
|
+
loader: styleCompilerPath
|
|
1842
1840
|
})
|
|
1843
1841
|
}
|
|
1844
1842
|
}
|
|
@@ -9,16 +9,20 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
9
9
|
// React Native android 不支持的 CSS property
|
|
10
10
|
android: /^(text-decoration-style|text-decoration-color|shadow-offset|shadow-opacity|shadow-radius)$/
|
|
11
11
|
}
|
|
12
|
+
// var(xx)
|
|
13
|
+
const cssVariableExp = /var\(/
|
|
14
|
+
// calc(xx)
|
|
15
|
+
const calcExp = /calc\(/
|
|
12
16
|
// 不支持的属性提示
|
|
13
|
-
const unsupportedPropError = ({ prop, mode }) => {
|
|
14
|
-
|
|
17
|
+
const unsupportedPropError = ({ prop, value, selector }, { mode }, isError = true) => {
|
|
18
|
+
const tips = isError ? error : warn
|
|
19
|
+
tips(`Property [${prop}] on ${selector} is not supported in ${mode} environment!`)
|
|
15
20
|
}
|
|
16
21
|
// prop 校验
|
|
17
|
-
const verifyProps = ({ prop, value }, { mode }, isError = true) => {
|
|
22
|
+
const verifyProps = ({ prop, value, selector }, { mode }, isError = true) => {
|
|
18
23
|
prop = prop.trim()
|
|
19
|
-
const tips = isError ? error : warn
|
|
20
24
|
if (unsupportedPropExp.test(prop) || unsupportedPropMode[mode].test(prop)) {
|
|
21
|
-
|
|
25
|
+
unsupportedPropError({ prop, value, selector }, { mode }, isError)
|
|
22
26
|
return false
|
|
23
27
|
}
|
|
24
28
|
return true
|
|
@@ -82,27 +86,36 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
82
86
|
}
|
|
83
87
|
}
|
|
84
88
|
// 属性值校验
|
|
85
|
-
const verifyValues = ({ prop, value }, isError = true) => {
|
|
89
|
+
const verifyValues = ({ prop, value, selector }, isError = true) => {
|
|
86
90
|
prop = prop.trim()
|
|
87
91
|
value = value.trim()
|
|
88
|
-
const
|
|
92
|
+
const tips = isError ? error : warn
|
|
93
|
+
if (cssVariableExp.test(value) || calcExp.test(value)) return true
|
|
89
94
|
const namedColor = ['transparent', 'aliceblue', 'antiquewhite', 'aqua', 'aquamarine', 'azure', 'beige', 'bisque', 'black', 'blanchedalmond', 'blue', 'blueviolet', 'brown', 'burlywood', 'cadetblue', 'chartreuse', 'chocolate', 'coral', 'cornflowerblue', 'cornsilk', 'crimson', 'cyan', 'darkblue', 'darkcyan', 'darkgoldenrod', 'darkgray', 'darkgreen', 'darkgrey', 'darkkhaki', 'darkmagenta', 'darkolivegreen', 'darkorange', 'darkorchid', 'darkred', 'darksalmon', 'darkseagreen', 'darkslateblue', 'darkslategrey', 'darkturquoise', 'darkviolet', 'deeppink', 'deepskyblue', 'dimgray', 'dimgrey', 'dodgerblue', 'firebrick', 'floralwhite', 'forestgreen', 'fuchsia', 'gainsboro', 'ghostwhite', 'gold', 'goldenrod', 'gray', 'green', 'greenyellow', 'grey', 'honeydew', 'hotpink', 'indianred', 'indigo', 'ivory', 'khaki', 'lavender', 'lavenderblush', 'lawngreen', 'lemonchiffon', 'lightblue', 'lightcoral', 'lightcyan', 'lightgoldenrodyellow', 'lightgray', 'lightgreen', 'lightgrey', 'lightpink', 'lightsalmon', 'lightseagreen', 'lightskyblue', 'lightslategrey', 'lightsteelblue', 'lightyellow', 'lime', 'limegreen', 'linen', 'magenta', 'maroon', 'mediumaquamarine', 'mediumblue', 'mediumorchid', 'mediumpurple', 'mediumseagreen', 'mediumslateblue', 'mediumspringgreen', 'mediumturquoise', 'mediumvioletred', 'midnightblue', 'mintcream', 'mistyrose', 'moccasin', 'navajowhite', 'navy', 'oldlace', 'olive', 'olivedrab', 'orange', 'orangered', 'orchid', 'palegoldenrod', 'palegreen', 'paleturquoise', 'palevioletred', 'papayawhip', 'peachpuff', 'peru', 'pink', 'plum', 'powderblue', 'purple', 'rebeccapurple', 'red', 'rosybrown', 'royalblue', 'saddlebrown', 'salmon', 'sandybrown', 'seagreen', 'seashell', 'sienna', 'silver', 'skyblue', 'slateblue', 'slategray', 'snow', 'springgreen', 'steelblue', 'tan', 'teal', 'thistle', 'tomato', 'turquoise', 'violet', 'wheat', 'white', 'whitesmoke', 'yellow', 'yellowgreen']
|
|
90
95
|
const valueExp = {
|
|
91
|
-
number: /^(-?\d+(\.\d+)?)(rpx|px
|
|
96
|
+
number: /^((-?\d+(\.\d+)?)(rpx|px|%|vw|vh)?|hairlineWidth)$/,
|
|
92
97
|
color: new RegExp(('^(' + namedColor.join('|') + ')$') + '|(^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$)|^(rgb|rgba|hsl|hsla|hwb)\\(.+\\)$')
|
|
93
98
|
}
|
|
94
|
-
const
|
|
99
|
+
const type = getValueType(prop)
|
|
100
|
+
const tipsType = (type) => {
|
|
101
|
+
const info = {
|
|
102
|
+
[ValueType.number]: '2rpx,10%,30rpx',
|
|
103
|
+
[ValueType.color]: 'rgb,rgba,hsl,hsla,hwb,named color,#000000',
|
|
104
|
+
[ValueType.enum]: `${SUPPORTED_PROP_VAL_ARR[prop]?.join(',')}`
|
|
105
|
+
}
|
|
106
|
+
tips(`Value of ${prop} in ${selector} should be ${type}, eg ${info[type]}, received [${value}], please check again!`)
|
|
107
|
+
}
|
|
95
108
|
switch (type) {
|
|
96
109
|
case ValueType.number: {
|
|
97
110
|
if (!valueExp.number.test(value)) {
|
|
98
|
-
|
|
111
|
+
tipsType(type)
|
|
99
112
|
return false
|
|
100
113
|
}
|
|
101
114
|
return true
|
|
102
115
|
}
|
|
103
116
|
case ValueType.color: {
|
|
104
117
|
if (!valueExp.color.test(value)) {
|
|
105
|
-
|
|
118
|
+
tipsType(type)
|
|
106
119
|
return false
|
|
107
120
|
}
|
|
108
121
|
return true
|
|
@@ -111,7 +124,7 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
111
124
|
const isIn = SUPPORTED_PROP_VAL_ARR[prop].includes(value)
|
|
112
125
|
const isType = Object.keys(valueExp).some(item => valueExp[item].test(value) && SUPPORTED_PROP_VAL_ARR[prop].includes(ValueType[item]))
|
|
113
126
|
if (!isIn && !isType) {
|
|
114
|
-
|
|
127
|
+
tipsType(type)
|
|
115
128
|
return false
|
|
116
129
|
}
|
|
117
130
|
return true
|
|
@@ -120,8 +133,8 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
120
133
|
return true
|
|
121
134
|
}
|
|
122
135
|
// prop & value 校验:过滤的不合法的属性和属性值
|
|
123
|
-
const verification = ({ prop, value }, { mode }) => {
|
|
124
|
-
return verifyProps({ prop, value }, { mode }) && verifyValues({ prop, value }) && ({ prop, value })
|
|
136
|
+
const verification = ({ prop, value, selector }, { mode }) => {
|
|
137
|
+
return verifyProps({ prop, value, selector }, { mode }) && verifyValues({ prop, value, selector }) && ({ prop, value })
|
|
125
138
|
}
|
|
126
139
|
|
|
127
140
|
// 简写转换规则
|
|
@@ -148,7 +161,7 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
148
161
|
'flex-flow': ['flexDirection', 'flexWrap'],
|
|
149
162
|
'border-radius': ['borderTopLeftRadius', 'borderTopRightRadius', 'borderBottomRightRadius', 'borderBottomLeftRadius']
|
|
150
163
|
}
|
|
151
|
-
const formatAbbreviation = ({ prop, value }, { mode }) => {
|
|
164
|
+
const formatAbbreviation = ({ prop, value, selector }, { mode }) => {
|
|
152
165
|
const original = `${prop}:${value}`
|
|
153
166
|
const props = AbbreviationMap[prop]
|
|
154
167
|
const values = value.trim().split(/\s(?![^()]*\))/)
|
|
@@ -159,12 +172,12 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
159
172
|
while (idx < values.length) {
|
|
160
173
|
const prop = props[propsIdx]
|
|
161
174
|
if (!prop) {
|
|
162
|
-
error(`
|
|
175
|
+
error(`Value of [${original}] in ${selector} has not enough props to assign, please check again!`)
|
|
163
176
|
break
|
|
164
177
|
}
|
|
165
178
|
const value = values[idx]
|
|
166
179
|
const newProp = hump2dash(prop.replace(/\..+/, ''))
|
|
167
|
-
if (!verifyProps({ prop: newProp, value }, { mode }, diff === 0)) {
|
|
180
|
+
if (!verifyProps({ prop: newProp, value, selector }, { mode }, diff === 0)) {
|
|
168
181
|
// 有 ios or android 不支持的 prop,跳过 prop
|
|
169
182
|
if (diff === 0) {
|
|
170
183
|
propsIdx++
|
|
@@ -172,7 +185,7 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
172
185
|
} else {
|
|
173
186
|
propsIdx++
|
|
174
187
|
}
|
|
175
|
-
} else if (!verifyValues({ prop: newProp, value }, diff === 0)) {
|
|
188
|
+
} else if (!verifyValues({ prop: newProp, value, selector }, diff === 0)) {
|
|
176
189
|
// 值不合法 跳过 value
|
|
177
190
|
if (diff === 0) {
|
|
178
191
|
propsIdx++
|
|
@@ -212,7 +225,7 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
212
225
|
}
|
|
213
226
|
|
|
214
227
|
// margin padding
|
|
215
|
-
const formatMargins = ({ prop, value }) => {
|
|
228
|
+
const formatMargins = ({ prop, value, selector }) => {
|
|
216
229
|
const values = value.trim().split(/\s(?![^()]*\))/)
|
|
217
230
|
// format
|
|
218
231
|
let suffix = []
|
|
@@ -231,7 +244,7 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
231
244
|
return values.map((value, index) => {
|
|
232
245
|
const newProp = `${prop}${suffix[index] || ''}`
|
|
233
246
|
// validate
|
|
234
|
-
verifyValues({ prop: hump2dash(newProp), value }, false)
|
|
247
|
+
verifyValues({ prop: hump2dash(newProp), value, selector }, false)
|
|
235
248
|
return {
|
|
236
249
|
prop: newProp,
|
|
237
250
|
value: value
|
|
@@ -240,8 +253,8 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
240
253
|
}
|
|
241
254
|
|
|
242
255
|
// line-height
|
|
243
|
-
const formatLineHeight = ({ prop, value }) => {
|
|
244
|
-
return verifyValues({ prop, value }) && ({
|
|
256
|
+
const formatLineHeight = ({ prop, value, selector }) => {
|
|
257
|
+
return verifyValues({ prop, value, selector }) && ({
|
|
245
258
|
prop,
|
|
246
259
|
value: /^\s*-?\d+(\.\d+)?\s*$/.test(value) ? `${Math.round(value * 100)}%` : value
|
|
247
260
|
})
|
|
@@ -250,7 +263,7 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
250
263
|
// background 相关属性的转换 Todo
|
|
251
264
|
// 仅支持以下属性,不支持其他背景相关的属性
|
|
252
265
|
// /^((?!(-color)).)*background((?!(-color)).)*$/ 包含background且不包含background-color
|
|
253
|
-
const checkBackgroundImage = ({ prop, value }, { mode }) => {
|
|
266
|
+
const checkBackgroundImage = ({ prop, value, selector }, { mode }) => {
|
|
254
267
|
const bgPropMap = {
|
|
255
268
|
image: 'background-image',
|
|
256
269
|
color: 'background-color',
|
|
@@ -260,17 +273,18 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
260
273
|
all: 'background'
|
|
261
274
|
}
|
|
262
275
|
const urlExp = /url\(["']?(.*?)["']?\)/
|
|
276
|
+
const linerExp = /linear-gradient\(["']?(.*?)["']?\)/
|
|
263
277
|
switch (prop) {
|
|
264
278
|
case bgPropMap.image: {
|
|
265
279
|
// background-image 仅支持背景图
|
|
266
280
|
const imgUrl = value.match(urlExp)?.[0]
|
|
267
|
-
|
|
268
|
-
error(`<linear-gradient()> is not supported in React Native ${mode} environment!`)
|
|
269
|
-
}
|
|
281
|
+
const linerVal = value.match(linerExp)?.[0]
|
|
270
282
|
if (imgUrl) {
|
|
271
283
|
return { prop, value: imgUrl }
|
|
284
|
+
} else if (linerVal) {
|
|
285
|
+
return { prop, value: linerVal }
|
|
272
286
|
} else {
|
|
273
|
-
error(`
|
|
287
|
+
error(`Value of ${prop} in ${selector} selector only support value <url()> or <linear-gradient()>, received ${value}, please check again!`)
|
|
274
288
|
return false
|
|
275
289
|
}
|
|
276
290
|
}
|
|
@@ -280,12 +294,12 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
280
294
|
// 支持一个值:这个值指定图片的宽度,图片的高度隐式的为 auto
|
|
281
295
|
// 支持两个值:第一个值指定图片的宽度,第二个值指定图片的高度
|
|
282
296
|
if (value.includes(',')) { // commas are not allowed in values
|
|
283
|
-
error(`
|
|
297
|
+
error(`Value of [${bgPropMap.size}] in ${selector} does not support commas, received [${value}], please check again!`)
|
|
284
298
|
return false
|
|
285
299
|
}
|
|
286
300
|
const values = []
|
|
287
301
|
value.trim().split(/\s(?![^()]*\))/).forEach(item => {
|
|
288
|
-
if (verifyValues({ prop, value: item })) {
|
|
302
|
+
if (verifyValues({ prop, value: item, selector })) {
|
|
289
303
|
// 支持 number 值 / container cover auto 枚举
|
|
290
304
|
values.push(item)
|
|
291
305
|
}
|
|
@@ -296,14 +310,13 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
296
310
|
case bgPropMap.position: {
|
|
297
311
|
const values = []
|
|
298
312
|
value.trim().split(/\s(?![^()]*\))/).forEach(item => {
|
|
299
|
-
if (verifyValues({ prop, value: item })) {
|
|
313
|
+
if (verifyValues({ prop, value: item, selector })) {
|
|
300
314
|
// 支持 number 值 / 枚举, center与50%等价
|
|
301
315
|
values.push(item === 'center' ? '50%' : item)
|
|
302
316
|
} else {
|
|
303
|
-
error(`
|
|
317
|
+
error(`Value of [${bgPropMap.size}] in ${selector} does not support commas, received [${value}], please check again!`)
|
|
304
318
|
}
|
|
305
319
|
})
|
|
306
|
-
|
|
307
320
|
return { prop, value: values }
|
|
308
321
|
}
|
|
309
322
|
case bgPropMap.all: {
|
|
@@ -312,28 +325,29 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
312
325
|
const values = value.trim().split(/\s(?![^()]*\))/)
|
|
313
326
|
values.forEach(item => {
|
|
314
327
|
const url = item.match(urlExp)?.[0]
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
} else if (url) {
|
|
328
|
+
const linerVal = item.match(linerExp)?.[0]
|
|
329
|
+
if (url) {
|
|
318
330
|
bgMap.push({ prop: bgPropMap.image, value: url })
|
|
331
|
+
} else if (linerVal) {
|
|
332
|
+
bgMap.push({ prop: bgPropMap.image, value: linerVal })
|
|
319
333
|
} else if (verifyValues({ prop: bgPropMap.color, value: item }, false)) {
|
|
320
334
|
bgMap.push({ prop: bgPropMap.color, value: item })
|
|
321
|
-
} else if (verifyValues({ prop: bgPropMap.repeat, value: item }, false)) {
|
|
335
|
+
} else if (verifyValues({ prop: bgPropMap.repeat, value: item, selector }, false)) {
|
|
322
336
|
bgMap.push({ prop: bgPropMap.repeat, value: item })
|
|
323
337
|
}
|
|
324
338
|
})
|
|
325
339
|
return bgMap.length ? bgMap : false
|
|
326
340
|
}
|
|
327
341
|
}
|
|
328
|
-
unsupportedPropError({ prop, mode })
|
|
342
|
+
unsupportedPropError({ prop, value, selector }, { mode })
|
|
329
343
|
return false
|
|
330
344
|
}
|
|
331
345
|
|
|
332
346
|
// border-radius 缩写转换
|
|
333
|
-
const getBorderRadius = ({ prop, value }, { mode }) => {
|
|
347
|
+
const getBorderRadius = ({ prop, value, selector }, { mode }) => {
|
|
334
348
|
const values = value.trim().split(/\s(?![^()]*\))/)
|
|
335
349
|
if (values.length === 1) {
|
|
336
|
-
verifyValues({ prop, value }, false)
|
|
350
|
+
verifyValues({ prop, value, selector }, false)
|
|
337
351
|
return { prop, value }
|
|
338
352
|
} else {
|
|
339
353
|
if (values.length === 2) {
|
|
@@ -346,7 +360,7 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
346
360
|
}
|
|
347
361
|
|
|
348
362
|
// transform 转换
|
|
349
|
-
const formatTransform = ({ prop, value }, { mode }) => {
|
|
363
|
+
const formatTransform = ({ prop, value, selector }, { mode }) => {
|
|
350
364
|
if (Array.isArray(value)) return { prop, value }
|
|
351
365
|
const values = value.trim().split(/\s(?![^()]*\))/)
|
|
352
366
|
const transform = []
|
|
@@ -387,7 +401,7 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
387
401
|
const xyz = ['X', 'Y', 'Z']
|
|
388
402
|
transform.push(...vals.map((v, index) => {
|
|
389
403
|
if (key !== 'rotate' && index > 1) {
|
|
390
|
-
unsupportedPropError({ prop: `${key}Z`, mode })
|
|
404
|
+
unsupportedPropError({ prop: `${key}Z`, value, selector }, { mode })
|
|
391
405
|
}
|
|
392
406
|
return { [`${key}${xyz[index] || ''}`]: v.trim() }
|
|
393
407
|
}))
|
|
@@ -397,11 +411,11 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
397
411
|
case 'scaleZ':
|
|
398
412
|
default:
|
|
399
413
|
// 不支持的属性处理
|
|
400
|
-
unsupportedPropError({ prop
|
|
414
|
+
unsupportedPropError({ prop, value, selector }, { mode })
|
|
401
415
|
break
|
|
402
416
|
}
|
|
403
417
|
} else {
|
|
404
|
-
error(`Property [${prop}] is invalid, please check
|
|
418
|
+
error(`Property [${prop}] is invalid in ${selector}, received [${value}], please check again!`)
|
|
405
419
|
}
|
|
406
420
|
})
|
|
407
421
|
return {
|
|
@@ -414,19 +428,19 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
414
428
|
return !isNaN(+value)
|
|
415
429
|
}
|
|
416
430
|
|
|
417
|
-
const getIntegersFlex = ({ prop, value }) => {
|
|
431
|
+
const getIntegersFlex = ({ prop, value, selector }) => {
|
|
418
432
|
if (isNumber(value) && value >= 0) {
|
|
419
433
|
return { prop, value }
|
|
420
434
|
} else {
|
|
421
|
-
error(`
|
|
435
|
+
error(`Value of [${prop}] in ${selector} accepts any floating point value >= 0, received [${value}], please check again!`)
|
|
422
436
|
return false
|
|
423
437
|
}
|
|
424
438
|
}
|
|
425
439
|
|
|
426
|
-
const formatFlex = ({ prop, value
|
|
440
|
+
const formatFlex = ({ prop, value, selector }) => {
|
|
427
441
|
let values = value.trim().split(/\s(?![^()]*\))/)
|
|
428
442
|
if (values.length > 3) {
|
|
429
|
-
error(
|
|
443
|
+
error(`Value of [flex] in ${selector} supports up to three values, received [${value}], please check again!`)
|
|
430
444
|
values = values.splice(0, 3)
|
|
431
445
|
}
|
|
432
446
|
const cssMap = []
|
|
@@ -441,7 +455,7 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
441
455
|
// value=initial 则 flexShrink=1,其他场景都是0
|
|
442
456
|
cssMap.push(...[{ prop: 'flexGrow', value: 0 }, { prop: 'flexShrink', value: +(values[0] === 'initial') }])
|
|
443
457
|
} else {
|
|
444
|
-
error(
|
|
458
|
+
error(`Value of [${prop}] in ${selector} is invalid, When setting the value of flex to none or initial, only one value is supported.`)
|
|
445
459
|
}
|
|
446
460
|
return cssMap
|
|
447
461
|
}
|
|
@@ -481,25 +495,25 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
481
495
|
return cssMap
|
|
482
496
|
}
|
|
483
497
|
|
|
484
|
-
const formatFontFamily = ({ prop, value }) => {
|
|
498
|
+
const formatFontFamily = ({ prop, value, selector }) => {
|
|
485
499
|
// 去掉引号 取逗号分隔后的第一个
|
|
486
500
|
const newVal = value.replace(/"|'/g, '').trim()
|
|
487
501
|
const values = newVal.split(',').filter(i => i)
|
|
488
502
|
if (!newVal || !values.length) {
|
|
489
|
-
error(`
|
|
503
|
+
error(`Value of [${prop}] is invalid in ${selector}, received [${value}], please check again!`)
|
|
490
504
|
return false
|
|
491
505
|
} else if (values.length > 1) {
|
|
492
|
-
warn(`
|
|
506
|
+
warn(`Value of [${prop}] only supports one in ${selector}, received [${value}], and the first one is used by default.`)
|
|
493
507
|
}
|
|
494
508
|
return { prop, value: values[0].trim() }
|
|
495
509
|
}
|
|
496
510
|
|
|
497
|
-
const formatBoxShadow = ({ prop, value }, { mode }) => {
|
|
511
|
+
const formatBoxShadow = ({ prop, value, selector }, { mode }) => {
|
|
498
512
|
value = value.trim()
|
|
499
513
|
if (value === 'none') {
|
|
500
514
|
return false
|
|
501
515
|
}
|
|
502
|
-
const cssMap = formatAbbreviation({ prop, value }, { mode })
|
|
516
|
+
const cssMap = formatAbbreviation({ prop, value, selector }, { mode })
|
|
503
517
|
if (mode === 'android') return cssMap
|
|
504
518
|
// ios 阴影需要额外设置 shadowOpacity=1
|
|
505
519
|
cssMap.push({
|
|
@@ -31,6 +31,7 @@ module.exports = function (styles, {
|
|
|
31
31
|
scoped,
|
|
32
32
|
extract: false
|
|
33
33
|
}
|
|
34
|
+
// todo 建立新的request在内部导出classMap,便于样式模块复用
|
|
34
35
|
loaderContext.importModule(JSON.parse(getRequestString('styles', style, extraOptions, i))).then((result) => {
|
|
35
36
|
if (Array.isArray(result)) {
|
|
36
37
|
result = result.map((item) => {
|
|
@@ -113,13 +113,12 @@ module.exports = function (template, {
|
|
|
113
113
|
try {
|
|
114
114
|
const ignoreMap = Object.assign({
|
|
115
115
|
createElement: true,
|
|
116
|
-
getComponent: true
|
|
117
|
-
rootProps: true
|
|
116
|
+
getComponent: true
|
|
118
117
|
}, meta.wxsModuleMap)
|
|
119
118
|
const bindResult = bindThis.transform(rawCode, {
|
|
120
119
|
ignoreMap
|
|
121
120
|
})
|
|
122
|
-
output += `global.currentInject.render = function (createElement, getComponent
|
|
121
|
+
output += `global.currentInject.render = function (createElement, getComponent) {
|
|
123
122
|
return ${bindResult.code}
|
|
124
123
|
};\n`
|
|
125
124
|
} catch (e) {
|
|
@@ -2,8 +2,10 @@ const postcss = require('postcss')
|
|
|
2
2
|
const selectorParser = require('postcss-selector-parser')
|
|
3
3
|
const getRulesRunner = require('../platform/index')
|
|
4
4
|
const dash2hump = require('../utils/hump-dash').dash2hump
|
|
5
|
-
const
|
|
6
|
-
const
|
|
5
|
+
const unitRegExp = /^\s*(-?\d+(?:\.\d+)?)(rpx|vw|vh)\s*$/
|
|
6
|
+
const numberRegExp = /^\s*(-?\d+(\.\d+)?)(px)?\s*$/
|
|
7
|
+
const hairlineRegExp = /^\s*hairlineWidth\s*$/
|
|
8
|
+
const varRegExp = /^--/
|
|
7
9
|
const cssPrefixExp = /^-(webkit|moz|ms|o)-/
|
|
8
10
|
function getClassMap ({ content, filename, mode, srcMode, warn, error }) {
|
|
9
11
|
const classMap = {}
|
|
@@ -15,11 +17,14 @@ function getClassMap ({ content, filename, mode, srcMode, warn, error }) {
|
|
|
15
17
|
function formatValue (value) {
|
|
16
18
|
let matched
|
|
17
19
|
let needStringify = true
|
|
18
|
-
if ((matched =
|
|
20
|
+
if ((matched = numberRegExp.exec(value))) {
|
|
19
21
|
value = matched[1]
|
|
20
22
|
needStringify = false
|
|
21
|
-
} else if ((matched =
|
|
22
|
-
value = `
|
|
23
|
+
} else if ((matched = unitRegExp.exec(value))) {
|
|
24
|
+
value = `global.__unit.${matched[2]}(${matched[1]})`
|
|
25
|
+
needStringify = false
|
|
26
|
+
} else if (hairlineRegExp.test(value)) {
|
|
27
|
+
value = 'global.__hairlineWidth'
|
|
23
28
|
needStringify = false
|
|
24
29
|
}
|
|
25
30
|
return needStringify ? JSON.stringify(value) : value
|
|
@@ -38,13 +43,13 @@ function getClassMap ({ content, filename, mode, srcMode, warn, error }) {
|
|
|
38
43
|
const classMapValue = {}
|
|
39
44
|
rule.walkDecls(({ prop, value }) => {
|
|
40
45
|
if (cssPrefixExp.test(prop) || cssPrefixExp.test(value)) return
|
|
41
|
-
let newData = rulesRunner({ prop, value })
|
|
46
|
+
let newData = rulesRunner({ prop, value, selector: rule.selector })
|
|
42
47
|
if (!newData) return
|
|
43
48
|
if (!Array.isArray(newData)) {
|
|
44
49
|
newData = [newData]
|
|
45
50
|
}
|
|
46
51
|
newData.forEach(item => {
|
|
47
|
-
prop = dash2hump(item.prop)
|
|
52
|
+
prop = varRegExp.test(item.prop) ? item.prop : dash2hump(item.prop)
|
|
48
53
|
value = item.value
|
|
49
54
|
if (Array.isArray(value)) {
|
|
50
55
|
value = value.map(val => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createContext, Dispatch, MutableRefObject, SetStateAction } from 'react'
|
|
1
|
+
import { createContext, Dispatch, MutableRefObject, SetStateAction } from 'react'
|
|
2
2
|
import { NativeSyntheticEvent } from 'react-native'
|
|
3
3
|
|
|
4
4
|
export type LabelContextValue = MutableRefObject<{
|
|
@@ -15,14 +15,14 @@ export interface GroupContextValue {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
export interface FormFieldValue {
|
|
18
|
-
getValue: () => any
|
|
19
|
-
resetValue: ({ newVal, type }: { newVal?: any; type?: string }) => void
|
|
18
|
+
getValue: () => any
|
|
19
|
+
resetValue: ({ newVal, type }: { newVal?: any; type?: string }) => void
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
export interface FormContextValue {
|
|
23
|
-
formValuesMap: Map<string, FormFieldValue
|
|
24
|
-
submit: () => void
|
|
25
|
-
reset: () => void
|
|
23
|
+
formValuesMap: Map<string, FormFieldValue>
|
|
24
|
+
submit: () => void
|
|
25
|
+
reset: () => void
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
export const MovableAreaContext = createContext({ width: 0, height: 0 })
|
|
@@ -35,4 +35,6 @@ export const RadioGroupContext = createContext<GroupContextValue | null>(null)
|
|
|
35
35
|
|
|
36
36
|
export const LabelContext = createContext<LabelContextValue | null>(null)
|
|
37
37
|
|
|
38
|
-
export const PickerContext = createContext(null)
|
|
38
|
+
export const PickerContext = createContext(null)
|
|
39
|
+
|
|
40
|
+
export const VarContext = createContext({})
|
|
@@ -71,7 +71,7 @@ export const getCustomEvent = (type = '', oe = {}, { detail = {}, layoutRef }, p
|
|
|
71
71
|
preventDefault: oe.preventDefault
|
|
72
72
|
};
|
|
73
73
|
};
|
|
74
|
-
const useInnerProps = (props = {}, additionalProps = {},
|
|
74
|
+
const useInnerProps = (props = {}, additionalProps = {}, userRemoveProps = [], rawConfig) => {
|
|
75
75
|
const ref = useRef({
|
|
76
76
|
startTimer: {
|
|
77
77
|
bubble: null,
|
|
@@ -91,6 +91,17 @@ const useInnerProps = (props = {}, additionalProps = {}, removeProps = [], rawCo
|
|
|
91
91
|
const propsRef = useRef({});
|
|
92
92
|
const eventConfig = {};
|
|
93
93
|
const config = rawConfig || { layoutRef: { current: {} }, disableTouch: false, disableTap: false };
|
|
94
|
+
const removeProps = [
|
|
95
|
+
'children',
|
|
96
|
+
'enable-background',
|
|
97
|
+
'enable-offset',
|
|
98
|
+
'enable-var',
|
|
99
|
+
'external-var-context',
|
|
100
|
+
'parent-font-size',
|
|
101
|
+
'parent-width',
|
|
102
|
+
'parent-height',
|
|
103
|
+
...userRemoveProps
|
|
104
|
+
];
|
|
94
105
|
propsRef.current = { ...props, ...additionalProps };
|
|
95
106
|
for (const key in eventConfigMap) {
|
|
96
107
|
if (propsRef.current[key]) {
|