@mpxjs/webpack-plugin 2.10.24-test.1 → 2.11.0
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/LICENSE +433 -0
- package/lib/index.js +4 -1
- package/lib/platform/style/wx/index.js +44 -38
- package/lib/platform/template/wx/component-config/picker.js +0 -6
- package/lib/resolver/AddEnvPlugin.js +1 -1
- package/lib/resolver/AddModePlugin.js +1 -1
- package/lib/resolver/ExtendComponentsPlugin.js +68 -0
- package/lib/runtime/components/extends/section-list.mpx +14 -0
- package/lib/runtime/components/react/dist/mpx-button.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-button.jsx +2 -2
- package/lib/runtime/components/react/dist/mpx-camera.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-camera.jsx +36 -4
- package/lib/runtime/components/react/dist/mpx-canvas/index.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/index.jsx +1 -2
- package/lib/runtime/components/react/dist/mpx-checkbox-group.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-checkbox-group.jsx +2 -2
- package/lib/runtime/components/react/dist/mpx-checkbox.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-checkbox.jsx +2 -2
- package/lib/runtime/components/react/dist/mpx-form.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-form.jsx +2 -2
- package/lib/runtime/components/react/dist/mpx-icon/index.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-icon/index.jsx +2 -2
- package/lib/runtime/components/react/dist/mpx-image.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-image.jsx +2 -2
- package/lib/runtime/components/react/dist/mpx-inline-text.jsx +13 -4
- package/lib/runtime/components/react/dist/mpx-input.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-input.jsx +16 -8
- package/lib/runtime/components/react/dist/mpx-label.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-label.jsx +2 -2
- package/lib/runtime/components/react/dist/mpx-movable-area.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-movable-area.jsx +2 -2
- package/lib/runtime/components/react/dist/mpx-movable-view.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-movable-view.jsx +2 -2
- package/lib/runtime/components/react/dist/mpx-nav.jsx +1 -1
- package/lib/runtime/components/react/dist/mpx-picker/index.jsx +72 -23
- package/lib/runtime/components/react/dist/mpx-picker/multiSelector.jsx +2 -2
- package/lib/runtime/components/react/dist/mpx-picker/type.d.ts +4 -0
- package/lib/runtime/components/react/dist/mpx-picker-view/index.jsx +6 -8
- package/lib/runtime/components/react/dist/mpx-picker-view/pickerVIewContext.d.ts +0 -2
- package/lib/runtime/components/react/dist/mpx-picker-view/pickerVIewContext.js +0 -5
- package/lib/runtime/components/react/dist/mpx-picker-view-column/index.d.ts +1 -0
- package/lib/runtime/components/react/dist/mpx-picker-view-column/index.jsx +34 -14
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItem.d.ts +0 -2
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItem.jsx +4 -5
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItemLite.d.ts +0 -2
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItemLite.jsx +3 -5
- package/lib/runtime/components/react/dist/mpx-popup/index.d.ts +5 -4
- package/lib/runtime/components/react/dist/mpx-popup/index.jsx +2 -2
- package/lib/runtime/components/react/dist/mpx-popup/popupBase.jsx +3 -2
- package/lib/runtime/components/react/dist/mpx-progress.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-progress.jsx +1 -2
- package/lib/runtime/components/react/dist/mpx-radio-group.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-radio-group.jsx +2 -2
- package/lib/runtime/components/react/dist/mpx-radio.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-radio.jsx +2 -2
- package/lib/runtime/components/react/dist/mpx-rich-text/index.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-rich-text/index.jsx +1 -2
- package/lib/runtime/components/react/dist/mpx-scroll-view.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +2 -2
- package/lib/runtime/components/react/dist/mpx-section-list.d.ts +51 -0
- package/lib/runtime/components/react/dist/mpx-section-list.jsx +376 -0
- package/lib/runtime/components/react/dist/mpx-simple-text.jsx +27 -14
- package/lib/runtime/components/react/dist/mpx-simple-view.d.ts +1 -0
- package/lib/runtime/components/react/dist/mpx-slider.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-slider.jsx +1 -2
- package/lib/runtime/components/react/dist/mpx-sticky-header.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-sticky-header.jsx +2 -2
- package/lib/runtime/components/react/dist/mpx-sticky-section.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-sticky-section.jsx +2 -2
- package/lib/runtime/components/react/dist/mpx-swiper-item.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-swiper.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-swiper.jsx +1 -2
- package/lib/runtime/components/react/dist/mpx-switch.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-switch.jsx +1 -2
- package/lib/runtime/components/react/dist/mpx-text.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-text.jsx +22 -8
- package/lib/runtime/components/react/dist/mpx-video.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-video.jsx +1 -2
- package/lib/runtime/components/react/dist/mpx-view.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-view.jsx +1 -2
- package/lib/runtime/components/react/dist/mpx-web-view.d.ts +2 -1
- package/lib/runtime/components/react/dist/utils.d.ts +6 -9
- package/lib/runtime/components/react/dist/utils.jsx +70 -84
- package/lib/runtime/components/react/mpx-button.tsx +1 -3
- package/lib/runtime/components/react/mpx-camera.tsx +40 -5
- package/lib/runtime/components/react/mpx-canvas/index.tsx +5 -5
- package/lib/runtime/components/react/mpx-checkbox-group.tsx +1 -3
- package/lib/runtime/components/react/mpx-checkbox.tsx +1 -3
- package/lib/runtime/components/react/mpx-form.tsx +1 -3
- package/lib/runtime/components/react/mpx-icon/index.tsx +1 -3
- package/lib/runtime/components/react/mpx-image.tsx +2 -5
- package/lib/runtime/components/react/mpx-inline-text.tsx +13 -4
- package/lib/runtime/components/react/mpx-input.tsx +19 -10
- package/lib/runtime/components/react/mpx-label.tsx +1 -3
- package/lib/runtime/components/react/mpx-movable-area.tsx +2 -3
- package/lib/runtime/components/react/mpx-movable-view.tsx +1 -3
- package/lib/runtime/components/react/mpx-nav.tsx +1 -1
- package/lib/runtime/components/react/mpx-picker/index.tsx +100 -29
- package/lib/runtime/components/react/mpx-picker/multiSelector.tsx +3 -3
- package/lib/runtime/components/react/mpx-picker/selector.tsx +1 -1
- package/lib/runtime/components/react/mpx-picker/type.ts +4 -0
- package/lib/runtime/components/react/mpx-picker-view/index.tsx +12 -17
- package/lib/runtime/components/react/mpx-picker-view/pickerVIewContext.ts +0 -9
- package/lib/runtime/components/react/mpx-picker-view-column/index.tsx +44 -21
- package/lib/runtime/components/react/mpx-picker-view-column/pickerViewColumnItem.tsx +1 -9
- package/lib/runtime/components/react/mpx-picker-view-column/pickerViewColumnItemLite.tsx +0 -9
- package/lib/runtime/components/react/mpx-popup/index.tsx +7 -3
- package/lib/runtime/components/react/mpx-popup/popupBase.tsx +3 -2
- package/lib/runtime/components/react/mpx-progress.tsx +0 -3
- package/lib/runtime/components/react/mpx-radio-group.tsx +1 -3
- package/lib/runtime/components/react/mpx-radio.tsx +1 -3
- package/lib/runtime/components/react/mpx-rich-text/index.tsx +0 -3
- package/lib/runtime/components/react/mpx-scroll-view.tsx +1 -3
- package/lib/runtime/components/react/mpx-section-list.tsx +557 -0
- package/lib/runtime/components/react/mpx-simple-text.tsx +26 -13
- package/lib/runtime/components/react/mpx-slider.tsx +0 -3
- package/lib/runtime/components/react/mpx-sticky-header.tsx +1 -3
- package/lib/runtime/components/react/mpx-sticky-section.tsx +1 -3
- package/lib/runtime/components/react/mpx-swiper-item.tsx +0 -1
- package/lib/runtime/components/react/mpx-swiper.tsx +0 -3
- package/lib/runtime/components/react/mpx-switch.tsx +0 -3
- package/lib/runtime/components/react/mpx-text.tsx +21 -9
- package/lib/runtime/components/react/mpx-video.tsx +0 -3
- package/lib/runtime/components/react/mpx-view.tsx +0 -3
- package/lib/runtime/components/react/mpx-web-view.tsx +4 -3
- package/lib/runtime/components/react/utils.tsx +82 -88
- package/lib/template-compiler/compiler.js +6 -0
- package/package.json +5 -5
|
@@ -9,9 +9,9 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
9
9
|
// React Native ios 不支持的 CSS property
|
|
10
10
|
ios: /^(vertical-align)$/,
|
|
11
11
|
// React Native android 不支持的 CSS property
|
|
12
|
-
android: /^(text-decoration-
|
|
12
|
+
android: /^(text-decoration-color|shadow-offset|shadow-opacity|shadow-radius)$/,
|
|
13
13
|
// TODO: rnoh 文档暂未找到 css 属性支持说明,暂时同步 android,同时需要注意此处校验是否有缺失,类似 will-change 之类属性
|
|
14
|
-
harmony: /^(text-decoration-
|
|
14
|
+
harmony: /^(text-decoration-color|shadow-offset|shadow-opacity|shadow-radius)$/
|
|
15
15
|
}
|
|
16
16
|
const isNum = (v) => !isNaN(+v)
|
|
17
17
|
// var(xx)
|
|
@@ -31,11 +31,12 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
31
31
|
|
|
32
32
|
// 不支持的属性提示
|
|
33
33
|
const unsupportedPropError = ({ prop, value, selector }, { mode }, isError = true) => {
|
|
34
|
+
if (isError === silentVerify) return
|
|
34
35
|
const tips = isError ? error : warn
|
|
35
36
|
tips(`Property [${prop}] on ${selector} is not supported in ${mode} environment!`)
|
|
36
37
|
}
|
|
37
38
|
// prop 校验
|
|
38
|
-
const verifyProps = ({ prop, value, selector }, { mode
|
|
39
|
+
const verifyProps = ({ prop, value, selector }, { mode, isError = true }) => {
|
|
39
40
|
prop = prop.trim()
|
|
40
41
|
if (unsupportedPropExp.test(prop) || unsupportedPropMode[mode].test(prop)) {
|
|
41
42
|
unsupportedPropError({ prop, value, selector }, { mode }, isError)
|
|
@@ -87,6 +88,11 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
87
88
|
'background-repeat': ['no-repeat'],
|
|
88
89
|
width: ['auto', ValueType.length],
|
|
89
90
|
height: ['auto', ValueType.length],
|
|
91
|
+
left: ['auto', ValueType.length],
|
|
92
|
+
right: ['auto', ValueType.length],
|
|
93
|
+
top: ['auto', ValueType.length],
|
|
94
|
+
bottom: ['auto', ValueType.length],
|
|
95
|
+
inset: ['auto', ValueType.length],
|
|
90
96
|
'flex-basis': ['auto', ValueType.length],
|
|
91
97
|
margin: ['auto', ValueType.length],
|
|
92
98
|
'margin-top': ['auto', ValueType.length],
|
|
@@ -98,12 +104,16 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
98
104
|
// outline-style 走 enum 校验;与 border-style 对齐,不支持 double / groove / ridge
|
|
99
105
|
'outline-style': ['solid', 'dotted', 'dashed', 'none']
|
|
100
106
|
}
|
|
107
|
+
const getSupportedPropValArr = (prop, mode) => {
|
|
108
|
+
if ((mode === 'android' || mode === 'harmony') && prop === 'text-decoration-style') return ['solid']
|
|
109
|
+
return SUPPORTED_PROP_VAL_ARR[prop]
|
|
110
|
+
}
|
|
101
111
|
// 获取值类型
|
|
102
112
|
const getValueType = (prop) => {
|
|
103
113
|
const propValueTypeRules = [
|
|
104
114
|
// 重要!!优先判断是不是枚举类型
|
|
105
115
|
[ValueType.enum, new RegExp('^(' + Object.keys(SUPPORTED_PROP_VAL_ARR).join('|') + ')$')],
|
|
106
|
-
[ValueType.length, /^(
|
|
116
|
+
[ValueType.length, /^(gap|(.+-(width|height|left|right|top|bottom|radius|spacing|size|gap|offset)))$/],
|
|
107
117
|
[ValueType.integer, /^((opacity|flex-grow|flex-shrink|z-index)|(.+-(index|opacity)))$/],
|
|
108
118
|
[ValueType.color, /^(color|(.+-color))$/]
|
|
109
119
|
]
|
|
@@ -111,6 +121,7 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
111
121
|
if (rule[1].test(prop)) return rule[0]
|
|
112
122
|
}
|
|
113
123
|
}
|
|
124
|
+
const getDashProp = (prop) => hump2dash(prop.replace(/\..+/, ''))
|
|
114
125
|
|
|
115
126
|
// 从 CSS 变量中提取 fallback 值进行验证
|
|
116
127
|
// 返回值:fallback 值 | null(没有 fallback)| undefined(循环引用)
|
|
@@ -135,7 +146,7 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
135
146
|
// 返回值:
|
|
136
147
|
// - 通过:返回 true
|
|
137
148
|
// - 失败:返回 false
|
|
138
|
-
const verifyValues = ({ prop, value, selector }, isError = true) => {
|
|
149
|
+
const verifyValues = ({ prop, value, selector }, { isError = true, mode } = {}) => {
|
|
139
150
|
prop = prop.trim()
|
|
140
151
|
const rawValue = value.trim()
|
|
141
152
|
const tips = isError === silentVerify ? () => { } : isError ? error : warn
|
|
@@ -165,9 +176,10 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
165
176
|
// calc() / env() 跳过值校验,但保留 rawValue 输出
|
|
166
177
|
if (calcExp.test(valueForVerify) || envExp.test(valueForVerify)) return true
|
|
167
178
|
const type = getValueType(prop)
|
|
179
|
+
const supportedPropValArr = getSupportedPropValArr(prop, mode)
|
|
168
180
|
const tipsType = (type) => {
|
|
169
181
|
const example = type === ValueType.enum
|
|
170
|
-
?
|
|
182
|
+
? supportedPropValArr?.join(',')
|
|
171
183
|
: valueTypeExample[type]
|
|
172
184
|
tips(`Value of ${prop} in ${selector} should be ${type}${example ? `, eg ${example}` : ''}, received [${rawValue}], please check again!`)
|
|
173
185
|
}
|
|
@@ -199,14 +211,14 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
199
211
|
// 输出仍保留 raw value,运行时由 RN `processFontVariant` 自行 `split(' ')` 归一为数组。
|
|
200
212
|
if (prop === 'font-variant') {
|
|
201
213
|
const tokens = parseValues(valueForVerify)
|
|
202
|
-
if (!tokens.length || !tokens.every(t =>
|
|
214
|
+
if (!tokens.length || !tokens.every(t => supportedPropValArr.includes(t))) {
|
|
203
215
|
tipsType(type)
|
|
204
216
|
return false
|
|
205
217
|
}
|
|
206
218
|
return true
|
|
207
219
|
}
|
|
208
|
-
const isIn =
|
|
209
|
-
const isType = Object.keys(valueExp).some(item =>
|
|
220
|
+
const isIn = supportedPropValArr.includes(valueForVerify)
|
|
221
|
+
const isType = Object.keys(valueExp).some(item => supportedPropValArr.includes(ValueType[item]) && valueExp[item].test(valueForVerify))
|
|
210
222
|
if (!isIn && !isType) {
|
|
211
223
|
tipsType(type)
|
|
212
224
|
return false
|
|
@@ -218,7 +230,7 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
218
230
|
}
|
|
219
231
|
// prop & value 校验:过滤的不合法的属性和属性值
|
|
220
232
|
const verification = ({ prop, value, selector }, { mode }) => {
|
|
221
|
-
return verifyProps({ prop, value, selector }, { mode }) && verifyValues({ prop, value, selector }) && ({ prop, value })
|
|
233
|
+
return verifyProps({ prop, value, selector }, { mode }) && verifyValues({ prop, value, selector }, { mode }) && ({ prop, value })
|
|
222
234
|
}
|
|
223
235
|
|
|
224
236
|
// 简写转换规则
|
|
@@ -327,9 +339,9 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
327
339
|
const getVerifiedProp = (props, value, selector, mode, used) => {
|
|
328
340
|
return props.find(prop => {
|
|
329
341
|
if (used[prop]) return false
|
|
330
|
-
const newProp =
|
|
331
|
-
return verifyValues({ prop: newProp, value, selector }, silentVerify) &&
|
|
332
|
-
verifyProps({ prop: newProp, value, selector }, { mode }
|
|
342
|
+
const newProp = getDashProp(prop)
|
|
343
|
+
return verifyValues({ prop: newProp, value, selector }, { mode, isError: silentVerify }) &&
|
|
344
|
+
verifyProps({ prop: newProp, value, selector }, { mode, isError: silentVerify })
|
|
333
345
|
})
|
|
334
346
|
}
|
|
335
347
|
|
|
@@ -348,7 +360,7 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
348
360
|
return { prop, value: values[0] }
|
|
349
361
|
}
|
|
350
362
|
values.forEach(value => {
|
|
351
|
-
if (prop === 'text-decoration' && verifyValues({ prop: 'text-decoration-line', value, selector }, silentVerify)) {
|
|
363
|
+
if (prop === 'text-decoration' && verifyValues({ prop: 'text-decoration-line', value, selector }, { isError: silentVerify, mode })) {
|
|
352
364
|
switch (value) {
|
|
353
365
|
case 'underline':
|
|
354
366
|
hasUnderline = true
|
|
@@ -364,7 +376,7 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
364
376
|
}
|
|
365
377
|
const matchedProp = getVerifiedProp(props, value, selector, mode, used)
|
|
366
378
|
if (!matchedProp) {
|
|
367
|
-
warn(`Value of [${original}] in ${selector}
|
|
379
|
+
warn(`Value of [${original}] in ${selector} contains unsupported value [${value}], please check again!`)
|
|
368
380
|
return
|
|
369
381
|
}
|
|
370
382
|
used[matchedProp] = true
|
|
@@ -412,8 +424,8 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
412
424
|
break
|
|
413
425
|
}
|
|
414
426
|
const value = values[idx]
|
|
415
|
-
const newProp =
|
|
416
|
-
if (!verifyProps({ prop: newProp, value, selector }, { mode
|
|
427
|
+
const newProp = getDashProp(prop)
|
|
428
|
+
if (!verifyProps({ prop: newProp, value, selector }, { mode, isError: diff === 0 })) {
|
|
417
429
|
// 有 ios or android 不支持的 prop,跳过 prop
|
|
418
430
|
if (diff === 0) {
|
|
419
431
|
propsIdx++
|
|
@@ -421,7 +433,7 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
421
433
|
} else {
|
|
422
434
|
propsIdx++
|
|
423
435
|
}
|
|
424
|
-
} else if (!verifyValues({ prop: newProp, value, selector }, diff === 0)) {
|
|
436
|
+
} else if (!verifyValues({ prop: newProp, value, selector }, { isError: diff === 0, mode })) {
|
|
425
437
|
// 值不合法 跳过 value
|
|
426
438
|
if (diff === 0) {
|
|
427
439
|
propsIdx++
|
|
@@ -440,20 +452,14 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
440
452
|
return cssMap
|
|
441
453
|
}
|
|
442
454
|
|
|
443
|
-
// 单值直接返回(RN 原生支持单值 DimensionValue)的属性:margin / padding / border-* 四值简写
|
|
444
|
-
// 不含 gap / inset:
|
|
445
|
-
// - inset:RN inset 长属性非稳定,单值透传会留下不可靠的 inset key,必须展开到 top/right/bottom/left
|
|
446
|
-
// - gap:RN gap / rowGap / columnGap 只接受 number;单值串虽然后续 style-helper formatValue 也会处理,
|
|
447
|
-
// 但展开到 rowGap / columnGap 与运行时 runtimeForceExpandCompositeMap 行为保持对齐,更可读
|
|
448
|
-
const compositeSingleValuePassthrough = (prop) => prop !== 'gap' && prop !== 'inset'
|
|
449
|
-
|
|
450
455
|
const formatCompositeVal = ({ prop, value, selector }, { mode }) => {
|
|
451
456
|
// 槽位数由 AbbreviationMap[prop].length 决定(gap=2,inset/margin/padding/border-*=4)
|
|
452
457
|
const count = AbbreviationMap[prop].length
|
|
453
458
|
const values = parseValues(value).splice(0, count)
|
|
454
|
-
// 单值短路:margin / padding 等 RN
|
|
455
|
-
|
|
456
|
-
|
|
459
|
+
// 单值短路:margin / padding / inset / border-* 等 RN 原生支持单值 DimensionValue,原样透传;
|
|
460
|
+
// gap 单值仍需展开(RN gap / rowGap / columnGap 只接受 number,展开后与运行时 runtimeForceExpandCompositeMap 对齐)
|
|
461
|
+
if (values.length === 1 && prop !== 'gap') {
|
|
462
|
+
verifyValues({ prop, value, selector }, { isError: false })
|
|
457
463
|
return { prop, value }
|
|
458
464
|
}
|
|
459
465
|
if (count === 2) {
|
|
@@ -461,7 +467,7 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
461
467
|
if (values.length === 1) values.push(values[0])
|
|
462
468
|
} else {
|
|
463
469
|
switch (values.length) {
|
|
464
|
-
case 1
|
|
470
|
+
// case 1 已被上面单值短路兜走(margin / padding / inset / border-* 四值简写均原样透传单值)
|
|
465
471
|
case 2: values.push(...values); break
|
|
466
472
|
case 3: values.push(values[1]); break
|
|
467
473
|
}
|
|
@@ -569,12 +575,12 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
569
575
|
let isSize = false
|
|
570
576
|
const pushPositionOrSize = (item) => {
|
|
571
577
|
if (isSize) {
|
|
572
|
-
if (verifyValues({ prop: bgPropMap.size, value: item, selector }, silentVerify)) {
|
|
578
|
+
if (verifyValues({ prop: bgPropMap.size, value: item, selector }, { isError: silentVerify, mode })) {
|
|
573
579
|
sizeValues.push(item)
|
|
574
580
|
} else {
|
|
575
581
|
warn(`Value of [${bgPropMap.all}:${value}] in ${selector} does not support background-size token [${item}], please check again!`)
|
|
576
582
|
}
|
|
577
|
-
} else if (verifyValues({ prop: bgPropMap.position, value: item, selector }, silentVerify)) {
|
|
583
|
+
} else if (verifyValues({ prop: bgPropMap.position, value: item, selector }, { isError: silentVerify, mode })) {
|
|
578
584
|
positionValues.push(item)
|
|
579
585
|
} else {
|
|
580
586
|
warn(`Value of [${bgPropMap.all}:${value}] in ${selector} does not support background-position token [${item}], please check again!`)
|
|
@@ -593,7 +599,7 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
593
599
|
})
|
|
594
600
|
return true
|
|
595
601
|
}
|
|
596
|
-
if (isSize || verifyValues({ prop: bgPropMap.position, value: item, selector }, silentVerify)) {
|
|
602
|
+
if (isSize || verifyValues({ prop: bgPropMap.position, value: item, selector }, { isError: silentVerify, mode })) {
|
|
597
603
|
pushPositionOrSize(item)
|
|
598
604
|
return true
|
|
599
605
|
}
|
|
@@ -607,9 +613,9 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
607
613
|
bgMap.push({ prop: bgPropMap.image, value: url })
|
|
608
614
|
} else if (linerVal) {
|
|
609
615
|
bgMap.push({ prop: bgPropMap.image, value: linerVal })
|
|
610
|
-
} else if (verifyValues({ prop: bgPropMap.color, value: item, selector }, silentVerify)) {
|
|
616
|
+
} else if (verifyValues({ prop: bgPropMap.color, value: item, selector }, { isError: silentVerify, mode })) {
|
|
611
617
|
bgMap.push({ prop: bgPropMap.color, value: item })
|
|
612
|
-
} else if (verifyValues({ prop: bgPropMap.repeat, value: item, selector }, silentVerify)) {
|
|
618
|
+
} else if (verifyValues({ prop: bgPropMap.repeat, value: item, selector }, { isError: silentVerify, mode })) {
|
|
613
619
|
bgMap.push({ prop: bgPropMap.repeat, value: item })
|
|
614
620
|
} else if (!handlePositionSize(item)) {
|
|
615
621
|
// 既不是 url / linear-gradient / color / repeat / position-size,也不是合法 position 起头的 token
|
|
@@ -876,8 +882,8 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
876
882
|
tokens.splice(i + 1, 1)
|
|
877
883
|
}
|
|
878
884
|
const [sizePart, lhPart] = parseValues(t, '/')
|
|
879
|
-
if (verifyValues({ prop: 'font-weight', value: sizePart, selector }, silentVerify)) continue
|
|
880
|
-
if (verifyValues({ prop: 'font-size', value: sizePart, selector }, silentVerify)) {
|
|
885
|
+
if (verifyValues({ prop: 'font-weight', value: sizePart, selector }, { isError: silentVerify, mode })) continue
|
|
886
|
+
if (verifyValues({ prop: 'font-size', value: sizePart, selector }, { isError: silentVerify, mode })) {
|
|
881
887
|
sizeIdx = i
|
|
882
888
|
cssMap.push({ prop: 'fontSize', value: sizePart })
|
|
883
889
|
if (lhPart) lineHeight = lhPart
|
|
@@ -893,13 +899,13 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
893
899
|
for (let i = 0; i < sizeIdx; i++) {
|
|
894
900
|
const t = tokens[i]
|
|
895
901
|
if (t === 'normal') continue // 默认值跳过
|
|
896
|
-
if (verifyValues({ prop: 'font-style', value: t, selector }, silentVerify)) {
|
|
902
|
+
if (verifyValues({ prop: 'font-style', value: t, selector }, { isError: silentVerify, mode })) {
|
|
897
903
|
cssMap.push({ prop: 'fontStyle', value: t })
|
|
898
904
|
} else if (t === 'small-caps') {
|
|
899
905
|
// CSS font 简写的 variant 槽位仅 <font-variant-css2>(normal | small-caps);
|
|
900
906
|
// 字符串透传,RN processFontVariant 会 split 归一为数组,与 font-variant 长属性同口径
|
|
901
907
|
cssMap.push({ prop: 'fontVariant', value: t })
|
|
902
|
-
} else if (verifyValues({ prop: 'font-weight', value: t, selector }, silentVerify)) {
|
|
908
|
+
} else if (verifyValues({ prop: 'font-weight', value: t, selector }, { isError: silentVerify, mode })) {
|
|
903
909
|
cssMap.push({ prop: 'fontWeight', value: t })
|
|
904
910
|
} else {
|
|
905
911
|
// font-stretch / 数字型 font-variant-numeric / system 关键字等 → 非必填槽位,warn 并忽略该 token、保留其余
|
|
@@ -8,9 +8,6 @@ module.exports = function ({ print }) {
|
|
|
8
8
|
const ttPropLog = print({ platform: 'bytedance', tag: TAG_NAME, isError: false })
|
|
9
9
|
const baiduPropLog = print({ platform: 'baidu', tag: TAG_NAME, isError: false })
|
|
10
10
|
const qaPropLog = print({ platform: 'qa', tag: TAG_NAME, isError: false })
|
|
11
|
-
const iosPropLog = print({ platform: 'ios', tag: TAG_NAME, isError: false })
|
|
12
|
-
const androidPropLog = print({ platform: 'android', tag: TAG_NAME, isError: false })
|
|
13
|
-
const harmonyPropLog = print({ platform: 'harmony', tag: TAG_NAME, isError: false })
|
|
14
11
|
const ksPropLog = print({ platform: 'ks', tag: TAG_NAME, isError: false })
|
|
15
12
|
|
|
16
13
|
return {
|
|
@@ -48,9 +45,6 @@ module.exports = function ({ print }) {
|
|
|
48
45
|
ali: aliPropLog,
|
|
49
46
|
jd: jdPropLog,
|
|
50
47
|
qa: qaPropLog,
|
|
51
|
-
ios: iosPropLog,
|
|
52
|
-
android: androidPropLog,
|
|
53
|
-
harmony: harmonyPropLog,
|
|
54
48
|
ks: ksPropLog
|
|
55
49
|
}
|
|
56
50
|
],
|
|
@@ -19,7 +19,7 @@ module.exports = class AddEnvPlugin {
|
|
|
19
19
|
const envPattern = new RegExp(`\\.${env}(\\.|$)`)
|
|
20
20
|
|
|
21
21
|
resolver.getHook(this.source).tapAsync('AddEnvPlugin', (request, resolveContext, callback) => {
|
|
22
|
-
if (request.env) {
|
|
22
|
+
if (request.__mpxResolvedExtendComponent || request.env) {
|
|
23
23
|
return callback()
|
|
24
24
|
}
|
|
25
25
|
const obj = {
|
|
@@ -21,7 +21,7 @@ module.exports = class AddModePlugin {
|
|
|
21
21
|
const defaultModePattern = new RegExp(`\\.${defaultMode}(\\.|$)`)
|
|
22
22
|
|
|
23
23
|
resolver.getHook(this.source).tapAsync('AddModePlugin', (request, resolveContext, callback) => {
|
|
24
|
-
if (request.mode || request.env) {
|
|
24
|
+
if (request.__mpxResolvedExtendComponent || request.mode || request.env) {
|
|
25
25
|
return callback()
|
|
26
26
|
}
|
|
27
27
|
const obj = {
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
const path = require('path')
|
|
2
|
+
const toPosix = require('../utils/to-posix')
|
|
3
|
+
const EXTEND_COMPONENT_PATH_REGEXP = /@mpxjs\/webpack-plugin\/lib\/runtime\/components\/extends\/[^/]+$/
|
|
4
|
+
const RN_COMPONENTS_DIST_PATH = 'lib/runtime/components/react/dist'
|
|
5
|
+
const EXTEND_COMPONENTS = {
|
|
6
|
+
'section-list': {
|
|
7
|
+
ios: `${RN_COMPONENTS_DIST_PATH}/mpx-section-list.jsx`,
|
|
8
|
+
android: `${RN_COMPONENTS_DIST_PATH}/mpx-section-list.jsx`,
|
|
9
|
+
harmony: `${RN_COMPONENTS_DIST_PATH}/mpx-section-list.jsx`
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* 扩展组件路径解析插件
|
|
15
|
+
* 将 @mpxjs/webpack-plugin/lib/runtime/components/extends/[component-name] 格式的路径
|
|
16
|
+
* 解析为对应平台的实际组件路径
|
|
17
|
+
*/
|
|
18
|
+
module.exports = class ExtendComponentsPlugin {
|
|
19
|
+
constructor (source, mode, target) {
|
|
20
|
+
this.source = source
|
|
21
|
+
this.target = target
|
|
22
|
+
this.mode = mode
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
apply (resolver) {
|
|
26
|
+
const target = resolver.ensureHook(this.target)
|
|
27
|
+
const mode = this.mode
|
|
28
|
+
|
|
29
|
+
resolver.getHook(this.source).tapAsync('ExtendComponentsPlugin', (request, resolveContext, callback) => {
|
|
30
|
+
if (request.__mpxResolvedExtendComponent) return callback()
|
|
31
|
+
|
|
32
|
+
const componentName = getComponentName(request)
|
|
33
|
+
if (!componentName) {
|
|
34
|
+
return callback()
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// 检查组件是否在配置中
|
|
38
|
+
const componentTargetMap = EXTEND_COMPONENTS[componentName]
|
|
39
|
+
const targetSubPath = componentTargetMap && componentTargetMap[mode]
|
|
40
|
+
if (!targetSubPath) {
|
|
41
|
+
return callback(new Error(`Extended component "${componentName}" cannot be used on the ${mode} platform.`))
|
|
42
|
+
}
|
|
43
|
+
const targetPath = path.join(request.descriptionFileRoot, targetSubPath)
|
|
44
|
+
const targetRelativePath = `./${targetSubPath}`
|
|
45
|
+
|
|
46
|
+
const redirectRequest = Object.assign({}, request, {
|
|
47
|
+
path: targetPath,
|
|
48
|
+
relativePath: targetRelativePath,
|
|
49
|
+
__mpxResolvedExtendComponent: true
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
resolver.doResolve(
|
|
53
|
+
target,
|
|
54
|
+
redirectRequest,
|
|
55
|
+
`resolve extend component: ${componentName} to ${targetPath}`,
|
|
56
|
+
resolveContext,
|
|
57
|
+
callback
|
|
58
|
+
)
|
|
59
|
+
})
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function getComponentName (request) {
|
|
64
|
+
if (!request.path) return
|
|
65
|
+
const requestPath = toPosix(request.path)
|
|
66
|
+
if (!EXTEND_COMPONENT_PATH_REGEXP.test(requestPath)) return
|
|
67
|
+
return path.basename(requestPath, path.extname(requestPath))
|
|
68
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Placeholder for @mpxjs/webpack-plugin/lib/runtime/components/extends/section-list.
|
|
3
|
+
ExtendComponentsPlugin should always redirect requests away from this file at
|
|
4
|
+
build time. Reaching this module means the plugin failed to redirect — most
|
|
5
|
+
likely because section-list is not supported on the current platform, or
|
|
6
|
+
ExtendComponentsPlugin is not registered on the resolver.
|
|
7
|
+
-->
|
|
8
|
+
<template></template>
|
|
9
|
+
|
|
10
|
+
<script>
|
|
11
|
+
import { error } from '@mpxjs/utils'
|
|
12
|
+
error('section-list extend placeholder reached at runtime, ExtendComponentsPlugin redirect failed. See build log for the original error.')
|
|
13
|
+
export default {}
|
|
14
|
+
</script>
|
|
@@ -56,7 +56,6 @@ export interface ButtonProps {
|
|
|
56
56
|
'enable-offset'?: boolean;
|
|
57
57
|
'enable-var'?: boolean;
|
|
58
58
|
'enable-text-pass-through'?: boolean;
|
|
59
|
-
'parent-font-size'?: number;
|
|
60
59
|
'parent-width'?: number;
|
|
61
60
|
'parent-height'?: number;
|
|
62
61
|
style?: ViewStyle & TextStyle & Record<string, any>;
|
|
@@ -130,7 +130,7 @@ const Loading = ({ alone = false }) => {
|
|
|
130
130
|
};
|
|
131
131
|
const Button = forwardRef((buttonProps, ref) => {
|
|
132
132
|
const { textProps, innerProps: props = {} } = splitProps(buttonProps);
|
|
133
|
-
const { size = 'default', type = 'default', plain = false, disabled = false, loading = false, 'hover-class': hoverClass, 'hover-style': hoverStyle = {}, 'hover-start-time': hoverStartTime = 20, 'hover-stay-time': hoverStayTime = 70, 'open-type': openType, 'form-type': formType, 'enable-var': enableVar, 'enable-text-pass-through': enableTextPassThrough, 'parent-
|
|
133
|
+
const { size = 'default', type = 'default', plain = false, disabled = false, loading = false, 'hover-class': hoverClass, 'hover-style': hoverStyle = {}, 'hover-start-time': hoverStartTime = 20, 'hover-stay-time': hoverStayTime = 70, 'open-type': openType, 'form-type': formType, 'enable-var': enableVar, 'enable-text-pass-through': enableTextPassThrough, 'parent-width': parentWidth, 'parent-height': parentHeight, style = {}, children, bindgetuserinfo, bindtap } = props;
|
|
134
134
|
const { pageId } = useContext(RouteContext) || {};
|
|
135
135
|
const formContext = useContext(FormContext);
|
|
136
136
|
const enableHover = hoverClass !== 'none';
|
|
@@ -175,7 +175,7 @@ const Button = forwardRef((buttonProps, ref) => {
|
|
|
175
175
|
if (hasOwn(styleObj, 'padding')) {
|
|
176
176
|
delete defaultStyle.paddingHorizontal;
|
|
177
177
|
}
|
|
178
|
-
const { hasPositionFixed, hasSelfPercent, normalStyle, hasVarDec, varContextRef, setWidth, setHeight } = useTransformStyle(styleObj, { enableVar,
|
|
178
|
+
const { hasPositionFixed, hasSelfPercent, normalStyle, hasVarDec, varContextRef, setWidth, setHeight } = useTransformStyle(styleObj, { enableVar, parentWidth, parentHeight, defaultStyle });
|
|
179
179
|
const nodeRef = useRef(null);
|
|
180
180
|
useNodesRef(props, ref, nodeRef, { style: normalStyle });
|
|
181
181
|
const { layoutRef, layoutStyle, layoutProps } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef });
|
|
@@ -12,14 +12,24 @@ const qualityValue = {
|
|
|
12
12
|
original: 100
|
|
13
13
|
};
|
|
14
14
|
let RecordRes = null;
|
|
15
|
+
const cameraPermissionCacheMap = new Map();
|
|
16
|
+
function getCameraPermissionCache(pageId) {
|
|
17
|
+
if (pageId == null)
|
|
18
|
+
return;
|
|
19
|
+
let cache = cameraPermissionCacheMap.get(pageId);
|
|
20
|
+
if (!cache) {
|
|
21
|
+
cache = {};
|
|
22
|
+
cameraPermissionCacheMap.set(pageId, cache);
|
|
23
|
+
}
|
|
24
|
+
return cache;
|
|
25
|
+
}
|
|
15
26
|
const _camera = forwardRef((props, ref) => {
|
|
16
27
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
17
28
|
const cameraRef = useRef(null);
|
|
18
|
-
const { mode = 'normal', resolution = 'medium', 'device-position': devicePosition = 'back', flash = 'auto', 'frame-size': frameSize = 'medium', bindinitdone, bindstop, bindscancode, 'parent-
|
|
29
|
+
const { mode = 'normal', resolution = 'medium', 'device-position': devicePosition = 'back', flash = 'auto', 'frame-size': frameSize = 'medium', bindinitdone, bindstop, bindscancode, 'parent-width': parentWidth, 'parent-height': parentHeight, 'enable-var': enableVar, style = {} } = props;
|
|
19
30
|
const styleObj = extendObject({}, style);
|
|
20
31
|
const { normalStyle, hasSelfPercent, setWidth, setHeight } = useTransformStyle(styleObj, {
|
|
21
32
|
enableVar,
|
|
22
|
-
parentFontSize,
|
|
23
33
|
parentWidth,
|
|
24
34
|
parentHeight
|
|
25
35
|
});
|
|
@@ -209,14 +219,36 @@ const _camera = forwardRef((props, ref) => {
|
|
|
209
219
|
try {
|
|
210
220
|
const cameraPermission = global?.__mpx?.config?.rnConfig?.cameraPermission;
|
|
211
221
|
if (typeof cameraPermission === 'function') {
|
|
212
|
-
const
|
|
213
|
-
|
|
222
|
+
const permissionCache = getCameraPermissionCache(pageId);
|
|
223
|
+
if (permissionCache && hasOwn(permissionCache, 'result')) {
|
|
224
|
+
setHasPermission(permissionCache.result === true);
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
let permissionResult;
|
|
228
|
+
if (permissionCache) {
|
|
229
|
+
if (!permissionCache.promise) {
|
|
230
|
+
permissionCache.promise = cameraPermission();
|
|
231
|
+
}
|
|
232
|
+
permissionResult = await permissionCache.promise;
|
|
233
|
+
}
|
|
234
|
+
else {
|
|
235
|
+
permissionResult = await cameraPermission();
|
|
236
|
+
}
|
|
237
|
+
const granted = permissionResult === true;
|
|
238
|
+
if (permissionCache) {
|
|
239
|
+
permissionCache.result = granted;
|
|
240
|
+
}
|
|
241
|
+
setHasPermission(granted);
|
|
214
242
|
}
|
|
215
243
|
else {
|
|
216
244
|
setHasPermission(true);
|
|
217
245
|
}
|
|
218
246
|
}
|
|
219
247
|
catch (error) {
|
|
248
|
+
const permissionCache = getCameraPermissionCache(pageId);
|
|
249
|
+
if (permissionCache) {
|
|
250
|
+
permissionCache.result = false;
|
|
251
|
+
}
|
|
220
252
|
setHasPermission(false);
|
|
221
253
|
}
|
|
222
254
|
};
|
|
@@ -17,7 +17,6 @@ interface CanvasProps {
|
|
|
17
17
|
style?: Record<string, any>;
|
|
18
18
|
originWhitelist?: Array<string>;
|
|
19
19
|
'enable-var'?: boolean;
|
|
20
|
-
'parent-font-size'?: number;
|
|
21
20
|
'parent-width'?: number;
|
|
22
21
|
'parent-height'?: number;
|
|
23
22
|
bindtouchstart?: (event: NativeSyntheticEvent<TouchEvent>) => void;
|
|
@@ -39,12 +39,11 @@ const stylesheet = StyleSheet.create({
|
|
|
39
39
|
}
|
|
40
40
|
});
|
|
41
41
|
const _Canvas = forwardRef((props = {}, ref) => {
|
|
42
|
-
const { style = {}, originWhitelist = ['*'], 'enable-var': enableVar, 'parent-
|
|
42
|
+
const { style = {}, originWhitelist = ['*'], 'enable-var': enableVar, 'parent-width': parentWidth, 'parent-height': parentHeight } = props;
|
|
43
43
|
const [isLoaded, setIsLoaded] = useState(false);
|
|
44
44
|
const nodeRef = useRef(null);
|
|
45
45
|
const { normalStyle, hasSelfPercent, hasPositionFixed, setWidth, setHeight } = useTransformStyle(extendObject({}, style, stylesheet.container), {
|
|
46
46
|
enableVar,
|
|
47
|
-
parentFontSize,
|
|
48
47
|
parentWidth,
|
|
49
48
|
parentHeight
|
|
50
49
|
});
|
|
@@ -12,7 +12,7 @@ import Portal from './mpx-portal';
|
|
|
12
12
|
const CheckboxGroup = forwardRef((props, ref) => {
|
|
13
13
|
const propsRef = useRef({});
|
|
14
14
|
propsRef.current = props;
|
|
15
|
-
const { style = {}, 'enable-var': enableVar, 'parent-
|
|
15
|
+
const { style = {}, 'enable-var': enableVar, 'parent-width': parentWidth, 'parent-height': parentHeight } = props;
|
|
16
16
|
const formContext = useContext(FormContext);
|
|
17
17
|
let formValuesMap;
|
|
18
18
|
if (formContext) {
|
|
@@ -23,7 +23,7 @@ const CheckboxGroup = forwardRef((props, ref) => {
|
|
|
23
23
|
flexDirection: 'row',
|
|
24
24
|
flexWrap: 'wrap'
|
|
25
25
|
};
|
|
26
|
-
const { hasPositionFixed, hasSelfPercent, normalStyle, hasVarDec, varContextRef, setWidth, setHeight } = useTransformStyle(style, { enableVar,
|
|
26
|
+
const { hasPositionFixed, hasSelfPercent, normalStyle, hasVarDec, varContextRef, setWidth, setHeight } = useTransformStyle(style, { enableVar, parentWidth, parentHeight, defaultStyle });
|
|
27
27
|
const nodeRef = useRef(null);
|
|
28
28
|
useNodesRef(props, ref, nodeRef, { style: normalStyle });
|
|
29
29
|
const { layoutRef, layoutStyle, layoutProps } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef });
|
|
@@ -19,7 +19,6 @@ export interface CheckboxProps extends Selection {
|
|
|
19
19
|
'enable-offset'?: boolean;
|
|
20
20
|
'enable-var'?: boolean;
|
|
21
21
|
'enable-text-pass-through'?: boolean;
|
|
22
|
-
'parent-font-size'?: number;
|
|
23
22
|
'parent-width'?: number;
|
|
24
23
|
'parent-height'?: number;
|
|
25
24
|
children?: ReactNode;
|
|
@@ -41,7 +41,7 @@ const styles = StyleSheet.create({
|
|
|
41
41
|
});
|
|
42
42
|
const Checkbox = forwardRef((checkboxProps, ref) => {
|
|
43
43
|
const { textProps, innerProps: props = {} } = splitProps(checkboxProps);
|
|
44
|
-
const { value = '', disabled = false, checked = false, color = '#09BB07', style = {}, 'enable-var': enableVar, 'enable-text-pass-through': enableTextPassThrough, 'parent-
|
|
44
|
+
const { value = '', disabled = false, checked = false, color = '#09BB07', style = {}, 'enable-var': enableVar, 'enable-text-pass-through': enableTextPassThrough, 'parent-width': parentWidth, 'parent-height': parentHeight, bindtap, _onChange } = props;
|
|
45
45
|
const [isChecked, setIsChecked] = useState(!!checked);
|
|
46
46
|
const groupContext = useContext(CheckboxGroupContext);
|
|
47
47
|
let groupValue;
|
|
@@ -63,7 +63,7 @@ const Checkbox = forwardRef((checkboxProps, ref) => {
|
|
|
63
63
|
bindtap && bindtap(getCustomEvent('tap', evt, { layoutRef }, props));
|
|
64
64
|
onChange(evt);
|
|
65
65
|
};
|
|
66
|
-
const { hasPositionFixed, hasSelfPercent, normalStyle, hasVarDec, varContextRef, setWidth, setHeight } = useTransformStyle(style, { enableVar,
|
|
66
|
+
const { hasPositionFixed, hasSelfPercent, normalStyle, hasVarDec, varContextRef, setWidth, setHeight } = useTransformStyle(style, { enableVar, parentWidth, parentHeight, defaultStyle: styles.container });
|
|
67
67
|
const nodeRef = useRef(null);
|
|
68
68
|
useNodesRef(props, ref, nodeRef, {
|
|
69
69
|
style: normalStyle,
|
|
@@ -12,8 +12,8 @@ import { FormContext } from './context';
|
|
|
12
12
|
import { useTransformStyle, splitProps, splitStyle, useLayout, wrapChildren, extendObject, useTextPassThrough } from './utils';
|
|
13
13
|
const _Form = forwardRef((fromProps, ref) => {
|
|
14
14
|
const { textProps, innerProps: props = {} } = splitProps(fromProps);
|
|
15
|
-
const { style, 'enable-var': enableVar, 'enable-text-pass-through': enableTextPassThrough, 'parent-
|
|
16
|
-
const { hasSelfPercent, normalStyle, hasVarDec, varContextRef, setWidth, setHeight } = useTransformStyle(style, { enableVar,
|
|
15
|
+
const { style, 'enable-var': enableVar, 'enable-text-pass-through': enableTextPassThrough, 'parent-width': parentWidth, 'parent-height': parentHeight } = props;
|
|
16
|
+
const { hasSelfPercent, normalStyle, hasVarDec, varContextRef, setWidth, setHeight } = useTransformStyle(style, { enableVar, parentWidth, parentHeight });
|
|
17
17
|
const { textStyle, innerStyle = {} } = splitStyle(normalStyle);
|
|
18
18
|
const textPassThrough = useTextPassThrough(textStyle, textProps, { enableTextPassThrough });
|
|
19
19
|
const formRef = useRef(null);
|
|
@@ -30,11 +30,11 @@ const IconTypeMap = new Map([
|
|
|
30
30
|
['clear', Clear]
|
|
31
31
|
]);
|
|
32
32
|
const Icon = forwardRef((props, ref) => {
|
|
33
|
-
const { type, size = 23, color, style = {}, 'enable-var': enableVar, 'parent-
|
|
33
|
+
const { type, size = 23, color, style = {}, 'enable-var': enableVar, 'parent-width': parentWidth, 'parent-height': parentHeight } = props;
|
|
34
34
|
const source = IconTypeMap.get(type);
|
|
35
35
|
const defaultStyle = { width: ~~size, height: ~~size };
|
|
36
36
|
const styleObj = extendObject({}, defaultStyle, style);
|
|
37
|
-
const { hasPositionFixed, hasSelfPercent, normalStyle, setWidth, setHeight } = useTransformStyle(styleObj, { enableVar,
|
|
37
|
+
const { hasPositionFixed, hasSelfPercent, normalStyle, setWidth, setHeight } = useTransformStyle(styleObj, { enableVar, parentWidth, parentHeight });
|
|
38
38
|
const nodeRef = useRef(null);
|
|
39
39
|
useNodesRef(props, ref, nodeRef, { style: normalStyle });
|
|
40
40
|
const { layoutRef, layoutStyle, layoutProps } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef });
|