@mpxjs/webpack-plugin 2.9.69 → 2.9.70

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 (111) hide show
  1. package/lib/parser.js +1 -1
  2. package/lib/platform/json/wx/index.js +21 -8
  3. package/lib/platform/style/wx/index.js +51 -54
  4. package/lib/platform/template/wx/component-config/fix-component-name.js +15 -12
  5. package/lib/platform/template/wx/component-config/index.js +1 -1
  6. package/lib/platform/template/wx/component-config/input.js +1 -1
  7. package/lib/platform/template/wx/component-config/rich-text.js +8 -0
  8. package/lib/platform/template/wx/component-config/swiper.js +1 -1
  9. package/lib/platform/template/wx/component-config/textarea.js +1 -1
  10. package/lib/platform/template/wx/component-config/unsupported.js +1 -1
  11. package/lib/react/processTemplate.js +3 -0
  12. package/lib/runtime/components/react/context.ts +4 -0
  13. package/lib/runtime/components/react/dist/context.js +1 -0
  14. package/lib/runtime/components/react/dist/event.config.js +24 -24
  15. package/lib/runtime/components/react/dist/getInnerListeners.js +183 -166
  16. package/lib/runtime/components/react/dist/mpx-button.jsx +35 -42
  17. package/lib/runtime/components/react/dist/mpx-canvas/html.js +2 -4
  18. package/lib/runtime/components/react/dist/mpx-canvas/index.jsx +35 -13
  19. package/lib/runtime/components/react/dist/mpx-checkbox-group.jsx +13 -19
  20. package/lib/runtime/components/react/dist/mpx-checkbox.jsx +29 -38
  21. package/lib/runtime/components/react/dist/mpx-form.jsx +16 -19
  22. package/lib/runtime/components/react/dist/mpx-icon.jsx +8 -16
  23. package/lib/runtime/components/react/dist/mpx-image.jsx +291 -0
  24. package/lib/runtime/components/react/dist/mpx-input.jsx +54 -27
  25. package/lib/runtime/components/react/dist/mpx-label.jsx +15 -22
  26. package/lib/runtime/components/react/dist/mpx-movable-area.jsx +13 -16
  27. package/lib/runtime/components/react/dist/mpx-movable-view.jsx +13 -13
  28. package/lib/runtime/components/react/dist/mpx-navigator.jsx +2 -4
  29. package/lib/runtime/components/react/dist/mpx-picker/date.jsx +6 -2
  30. package/lib/runtime/components/react/dist/mpx-picker/index.jsx +5 -3
  31. package/lib/runtime/components/react/dist/mpx-picker/multiSelector.jsx +6 -2
  32. package/lib/runtime/components/react/dist/mpx-picker/region.jsx +6 -2
  33. package/lib/runtime/components/react/dist/mpx-picker/selector.jsx +6 -2
  34. package/lib/runtime/components/react/dist/mpx-picker/time.jsx +10 -15
  35. package/lib/runtime/components/react/dist/mpx-picker-view-column.jsx +3 -1
  36. package/lib/runtime/components/react/dist/mpx-picker-view.jsx +5 -3
  37. package/lib/runtime/components/react/dist/mpx-radio-group.jsx +11 -19
  38. package/lib/runtime/components/react/dist/mpx-radio.jsx +27 -42
  39. package/lib/runtime/components/react/dist/mpx-rich-text/html.js +39 -0
  40. package/lib/runtime/components/react/dist/mpx-rich-text/index.jsx +63 -0
  41. package/lib/runtime/components/react/dist/mpx-root-portal.jsx +6 -4
  42. package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +47 -41
  43. package/lib/runtime/components/react/dist/mpx-simple-text.jsx +11 -0
  44. package/lib/runtime/components/react/dist/mpx-swiper/carouse.jsx +4 -2
  45. package/lib/runtime/components/react/dist/mpx-swiper-item.jsx +4 -2
  46. package/lib/runtime/components/react/dist/mpx-switch.jsx +20 -10
  47. package/lib/runtime/components/react/dist/mpx-text.jsx +11 -10
  48. package/lib/runtime/components/react/dist/mpx-textarea.jsx +8 -3
  49. package/lib/runtime/components/react/dist/mpx-view.jsx +34 -46
  50. package/lib/runtime/components/react/dist/mpx-web-view.jsx +105 -42
  51. package/lib/runtime/components/react/dist/useAnimationHooks.js +35 -10
  52. package/lib/runtime/components/react/dist/utils.jsx +107 -82
  53. package/lib/runtime/components/react/event.config.ts +25 -26
  54. package/lib/runtime/components/react/getInnerListeners.ts +238 -188
  55. package/lib/runtime/components/react/mpx-button.tsx +64 -50
  56. package/lib/runtime/components/react/mpx-canvas/html.ts +2 -4
  57. package/lib/runtime/components/react/mpx-canvas/index.tsx +46 -48
  58. package/lib/runtime/components/react/mpx-checkbox-group.tsx +28 -25
  59. package/lib/runtime/components/react/mpx-checkbox.tsx +48 -49
  60. package/lib/runtime/components/react/mpx-form.tsx +25 -28
  61. package/lib/runtime/components/react/mpx-icon.tsx +12 -17
  62. package/lib/runtime/components/react/mpx-image.tsx +436 -0
  63. package/lib/runtime/components/react/mpx-input.tsx +77 -57
  64. package/lib/runtime/components/react/mpx-label.tsx +26 -27
  65. package/lib/runtime/components/react/mpx-movable-area.tsx +18 -23
  66. package/lib/runtime/components/react/mpx-movable-view.tsx +21 -25
  67. package/lib/runtime/components/react/mpx-navigator.tsx +2 -8
  68. package/lib/runtime/components/react/mpx-picker/date.tsx +5 -2
  69. package/lib/runtime/components/react/mpx-picker/index.tsx +3 -2
  70. package/lib/runtime/components/react/mpx-picker/multiSelector.tsx +5 -2
  71. package/lib/runtime/components/react/mpx-picker/region.tsx +5 -2
  72. package/lib/runtime/components/react/mpx-picker/selector.tsx +5 -2
  73. package/lib/runtime/components/react/mpx-picker/time.tsx +10 -15
  74. package/lib/runtime/components/react/mpx-picker/type.ts +48 -43
  75. package/lib/runtime/components/react/mpx-picker-view-column.tsx +4 -1
  76. package/lib/runtime/components/react/mpx-picker-view.tsx +7 -1
  77. package/lib/runtime/components/react/mpx-radio-group.tsx +24 -27
  78. package/lib/runtime/components/react/mpx-radio.tsx +45 -54
  79. package/lib/runtime/components/react/mpx-rich-text/html.ts +40 -0
  80. package/lib/runtime/components/react/mpx-rich-text/index.tsx +121 -0
  81. package/lib/runtime/components/react/mpx-root-portal.tsx +3 -5
  82. package/lib/runtime/components/react/mpx-scroll-view.tsx +72 -71
  83. package/lib/runtime/components/react/mpx-simple-text.tsx +18 -0
  84. package/lib/runtime/components/react/mpx-swiper/carouse.tsx +4 -2
  85. package/lib/runtime/components/react/mpx-swiper-item.tsx +3 -2
  86. package/lib/runtime/components/react/mpx-switch.tsx +29 -23
  87. package/lib/runtime/components/react/mpx-text.tsx +14 -18
  88. package/lib/runtime/components/react/mpx-textarea.tsx +11 -10
  89. package/lib/runtime/components/react/mpx-view.tsx +55 -65
  90. package/lib/runtime/components/react/mpx-web-view.tsx +108 -63
  91. package/lib/runtime/components/react/types/global.d.ts +3 -17
  92. package/lib/runtime/components/react/useAnimationHooks.ts +36 -12
  93. package/lib/runtime/components/react/utils.tsx +113 -82
  94. package/lib/runtime/components/web/getInnerListeners.js +6 -6
  95. package/lib/runtime/components/web/mpx-movable-view.vue +334 -344
  96. package/lib/runtime/components/web/mpx-picker-view-column.vue +75 -75
  97. package/lib/runtime/components/web/mpx-picker.vue +382 -385
  98. package/lib/runtime/components/web/mpx-web-view.vue +175 -161
  99. package/lib/runtime/optionProcessor.js +7 -38
  100. package/lib/runtime/utils.js +2 -0
  101. package/lib/style-compiler/plugins/scope-id.js +30 -2
  102. package/lib/template-compiler/bind-this.js +7 -2
  103. package/lib/template-compiler/compiler.js +77 -46
  104. package/lib/template-compiler/gen-node-react.js +2 -2
  105. package/lib/utils/pre-process-json.js +9 -5
  106. package/package.json +5 -4
  107. package/lib/runtime/components/react/dist/mpx-image/index.jsx +0 -226
  108. package/lib/runtime/components/react/dist/mpx-image/svg.jsx +0 -7
  109. package/lib/runtime/components/react/mpx-image/index.tsx +0 -345
  110. package/lib/runtime/components/react/mpx-image/svg.tsx +0 -22
  111. package/lib/runtime/components/web/event.js +0 -105
package/lib/parser.js CHANGED
@@ -14,7 +14,7 @@ module.exports = (content, { filePath, needMap, mode, env }) => {
14
14
  output = compiler.parseComponent(content, {
15
15
  mode,
16
16
  filePath,
17
- pad: 'line',
17
+ // pad: 'line', // stylus编译遇到大量空行时会出现栈溢出,故注释掉
18
18
  env
19
19
  })
20
20
  if (needMap) {
@@ -156,7 +156,9 @@ module.exports = function getSpec ({ warn, error }) {
156
156
  },
157
157
  {
158
158
  test: 'usingComponents',
159
- web: fixComponentName('usingComponents')
159
+ web: fixComponentName('usingComponents'),
160
+ ios: fixComponentName('usingComponents'),
161
+ android: fixComponentName('usingComponents')
160
162
  },
161
163
  {
162
164
  test: 'usingComponents',
@@ -256,12 +258,21 @@ module.exports = function getSpec ({ warn, error }) {
256
258
  }
257
259
 
258
260
  const spec = {
259
- supportedModes: ['ali', 'swan', 'qq', 'tt', 'jd', 'qa', 'dd', 'web'],
260
- normalizeTest,
261
- page: [
262
- ...windowRules,
263
- ...componentRules
261
+ supportedModes: [
262
+ 'ali',
263
+ 'swan',
264
+ 'qq',
265
+ 'tt',
266
+ 'jd',
267
+ 'qa',
268
+ 'dd',
269
+ 'web',
270
+ 'ios',
271
+ 'android'
264
272
  ],
273
+
274
+ normalizeTest,
275
+ page: [...windowRules, ...componentRules],
265
276
  component: componentRules,
266
277
  window: windowRules,
267
278
  tabBar: {
@@ -297,7 +308,7 @@ module.exports = function getSpec ({ warn, error }) {
297
308
  ali (input) {
298
309
  const value = input.list
299
310
  delete input.list
300
- input.items = value.map(item => {
311
+ input.items = value.map((item) => {
301
312
  return runRules(spec.tabBar.list, item, {
302
313
  mode: 'ali',
303
314
  normalizeTest,
@@ -361,7 +372,9 @@ module.exports = function getSpec ({ warn, error }) {
361
372
  },
362
373
  {
363
374
  test: 'usingComponents',
364
- web: fixComponentName('usingComponents')
375
+ web: fixComponentName('usingComponents'),
376
+ ios: fixComponentName('usingComponents'),
377
+ android: fixComponentName('usingComponents')
365
378
  },
366
379
  {
367
380
  test: 'usingComponents',
@@ -373,11 +373,12 @@ module.exports = function getSpec ({ warn, error }) {
373
373
 
374
374
  // transform 转换
375
375
  const formatTransform = ({ prop, value, selector }, { mode }) => {
376
- if (Array.isArray(value)) return { prop, value }
376
+ // css var & 数组直接返回
377
+ if (Array.isArray(value) || cssVariableExp.test(value)) return { prop, value }
377
378
  const values = parseValues(value)
378
379
  const transform = []
379
380
  values.forEach(item => {
380
- const match = item.match(/([/\w]+)\(([^)]+)\)/)
381
+ const match = item.match(/([/\w]+)\((.+)\)/)
381
382
  if (match && match.length >= 3) {
382
383
  let key = match[1]
383
384
  const val = match[2]
@@ -398,7 +399,7 @@ module.exports = function getSpec ({ warn, error }) {
398
399
  break
399
400
  case 'matrix':
400
401
  case 'matrix3d':
401
- transform.push({ [key]: val.split(',').map(val => +val) })
402
+ transform.push({ [key]: parseValues(val, ',').map(val => +val) })
402
403
  break
403
404
  case 'translate':
404
405
  case 'scale':
@@ -406,23 +407,23 @@ module.exports = function getSpec ({ warn, error }) {
406
407
  case 'rotate3d': // x y z angle
407
408
  case 'translate3d': // x y 支持 z不支持
408
409
  case 'scale3d': // x y 支持 z不支持
409
- {
410
- // 2 个以上的值处理
411
- key = key.replace('3d', '')
412
- const vals = val.split(',', key === 'rotate' ? 4 : 3)
413
- // scale(.5) === scaleX(.5) scaleY(.5)
414
- if (vals.length === 1 && key === 'scale') {
415
- vals.push(vals[0])
416
- }
417
- const xyz = ['X', 'Y', 'Z']
418
- transform.push(...vals.map((v, index) => {
419
- if (key !== 'rotate' && index > 1) {
420
- unsupportedPropError({ prop: `${key}Z`, value, selector }, { mode })
421
- }
422
- return { [`${key}${xyz[index] || ''}`]: v.trim() }
423
- }))
424
- break
410
+ {
411
+ // 2 个以上的值处理
412
+ key = key.replace('3d', '')
413
+ const vals = parseValues(val, ',').splice(0, key === 'rotate' ? 4 : 3)
414
+ // scale(.5) === scaleX(.5) scaleY(.5)
415
+ if (vals.length === 1 && key === 'scale') {
416
+ vals.push(vals[0])
425
417
  }
418
+ const xyz = ['X', 'Y', 'Z']
419
+ transform.push(...vals.map((v, index) => {
420
+ if (key !== 'rotate' && index > 1) {
421
+ unsupportedPropError({ prop: `${key}Z`, value, selector }, { mode })
422
+ }
423
+ return { [`${key}${xyz[index] || ''}`]: v.trim() }
424
+ }))
425
+ break
426
+ }
426
427
  case 'translateZ':
427
428
  case 'scaleZ':
428
429
  default:
@@ -455,14 +456,17 @@ module.exports = function getSpec ({ warn, error }) {
455
456
 
456
457
  const formatFlex = ({ prop, value, selector }) => {
457
458
  let values = parseValues(value)
459
+ // 值大于3 去前三
458
460
  if (values.length > 3) {
459
- error(`Value of [flex] in ${selector} supports up to three values, received [${value}], please check again!`)
461
+ warn(`Value of [flex] in ${selector} supports up to three values, received [${value}], please check again!`)
460
462
  values = values.splice(0, 3)
461
463
  }
462
464
  const cssMap = []
463
- const lastOne = values[values.length - 1]
464
- const isAuto = lastOne === 'auto'
465
- // 枚举值 none initial
465
+ // 单个css var 直接设置 flex 属性
466
+ if (values.length === 1 && cssVariableExp.test(value)) {
467
+ return { prop, value }
468
+ }
469
+ // 包含枚举值 none initial
466
470
  if (values.includes('initial') || values.includes('none')) {
467
471
  // css flex: initial ===> flex: 0 1 ===> rn flex 0 1
468
472
  // css flex: none ===> css flex: 0 0 ===> rn flex 0 0
@@ -475,38 +479,31 @@ module.exports = function getSpec ({ warn, error }) {
475
479
  }
476
480
  return cssMap
477
481
  }
478
- // 最后一个值是flexBasis 的有效值(auto或者有单位百分比、px等)
479
- // flex 0 1 auto flex auto flex 1 auto flex 1 30px flex 1 10% flex 1 1 auto
480
- if (!isNumber(lastOne) || !cssVariableExp.test(value)) {
481
- // 添加 grow shrink
482
- // 在设置 flex basis 有效值的场景下,如果没有设置 grow shrink,则默认为1
483
- // 单值 flex: 1 1 <flex-basis>
484
- // 双值 flex: <flex-grow> 1 <flex-basis>
485
- // 三值 flex: <flex-grow> <flex-shrink> <flex-basis>
486
- for (let i = 0; i < 2; i++) {
487
- const item = getIntegersFlex({ prop: AbbreviationMap[prop][i], value: isNumber(values[i]) || cssVariableExp.test(value) ? values[i] : 1 })
482
+ // 只有1-2个值且最后的值是flexBasis 的有效值(auto或者有单位百分比、px等)
483
+ // 在设置 flex basis 有效值的场景下,如果没有设置 grow shrink,则默认为1
484
+ // 单值 flex: 1 1 <flex-basis>
485
+ // 双值 flex: <flex-grow> 1 <flex-basis>
486
+ // 三值 flex: <flex-grow> <flex-shrink> <flex-basis>
487
+ for (let i = 0; i < 3; i++) {
488
+ if (i < 2) {
489
+ // 添加 grow shrink
490
+ const isValid = isNumber(values[0]) || cssVariableExp.test(values[0])
491
+ // 兜底 1
492
+ const val = isValid ? values[0] : 1
493
+ const item = getIntegersFlex({ prop: AbbreviationMap[prop][i], value: val, selector })
488
494
  item && cssMap.push(item)
495
+ isValid && values.shift()
496
+ } else {
497
+ // 添加 flexBasis
498
+ // 有单位(百分比、px等) 的 value 赋值 flexBasis,auto 不处理,兜底 0
499
+ const val = values[0] || 0
500
+ if (val !== 'auto') {
501
+ cssMap.push({
502
+ prop: 'flexBasis',
503
+ value: val
504
+ })
505
+ }
489
506
  }
490
- if (!isAuto) {
491
- // 有单位(百分比、px等) 的 value 赋值 flexBasis,auto 不处理
492
- cssMap.push({
493
- prop: 'flexBasis',
494
- value: lastOne
495
- })
496
- }
497
- return cssMap
498
- }
499
- // 纯数值:value 按flex-grow flex-shrink flex-basis 顺序赋值
500
- // 兜底 shrink & basis
501
- if (values.length === 1) {
502
- values.push(...[1, 0])
503
- } else if (values.length === 2) {
504
- values.push(0)
505
- }
506
- // 循环赋值
507
- for (let i = 0; i < values.length; i++) {
508
- const item = getIntegersFlex({ prop: AbbreviationMap[prop][i], value: values[i] })
509
- item && cssMap.push(item)
510
507
  }
511
508
  return cssMap
512
509
  }
@@ -514,7 +511,7 @@ module.exports = function getSpec ({ warn, error }) {
514
511
  const formatFontFamily = ({ prop, value, selector }) => {
515
512
  // 去掉引号 取逗号分隔后的第一个
516
513
  const newVal = value.replace(/"|'/g, '').trim()
517
- const values = newVal.split(',').filter(i => i)
514
+ const values = parseValues(newVal, ',')
518
515
  if (!newVal || !values.length) {
519
516
  error(`Value of [${prop}] is invalid in ${selector}, received [${value}], please check again!`)
520
517
  return false
@@ -1,21 +1,24 @@
1
1
  const { isOriginTag, isBuildInTag } = require('../../../../utils/dom-tag-config')
2
2
 
3
3
  module.exports = function () {
4
+ const handleComponentTag = (el, data) => {
5
+ const newTag = `mpx-com-${el.tag}`
6
+ const usingComponents = data.usingComponents || []
7
+ // 当前组件名与原生tag或内建tag同名,对组件名进行转义
8
+ // json转义见:platform/json/wx/index.js fixComponentName
9
+ if (usingComponents.includes(newTag)) {
10
+ el.tag = newTag
11
+ }
12
+ return el
13
+ }
14
+
4
15
  return {
5
16
  waterfall: true,
6
17
  skipNormalize: true,
7
- supportedModes: ['web'],
18
+ supportedModes: ['web', 'ios', 'android'],
8
19
  test: (input) => isOriginTag(input) || isBuildInTag(input),
9
- // 输出web时对组件名进行转义避免与原生tag和内建tag冲突
10
- web (el, data) {
11
- const newTag = `mpx-com-${el.tag}`
12
- const usingComponents = data.usingComponents || []
13
- // 当前组件名与原生tag或内建tag同名,对组件名进行转义
14
- // json转义见:platform/json/wx/index.js fixComponentName
15
- if (usingComponents.includes(newTag)) {
16
- el.tag = newTag
17
- }
18
- return el
19
- }
20
+ web: handleComponentTag,
21
+ ios: handleComponentTag,
22
+ android: handleComponentTag
20
23
  }
21
24
  }
@@ -82,8 +82,8 @@ module.exports = function getComponentConfigs ({ warn, error }) {
82
82
 
83
83
  // 转换规则只需以微信为基准配置微信和支付宝的差异部分,比如微信和支付宝都支持但是写法不一致,或者微信支持而支付宝不支持的部分(抛出错误或警告)
84
84
  return [
85
- ...unsupported({ print }),
86
85
  fixComponentName({ print }),
86
+ ...unsupported({ print }),
87
87
  ad({ print }),
88
88
  view({ print }),
89
89
  scrollView({ print }),
@@ -92,7 +92,7 @@ module.exports = function ({ print }) {
92
92
  qa: qaPropLog
93
93
  },
94
94
  {
95
- test: /^(placeholder-style|placeholder-class|cursor-spacing|always-embed|adjust-position|hold-keyboard|safe-password-.+)$/,
95
+ test: /^(placeholder-style|placeholder-class|cursor-spacing|always-embed|hold-keyboard|safe-password-.+)$/,
96
96
  ios: iosPropLog,
97
97
  android: androidPropLog
98
98
  }
@@ -12,6 +12,14 @@ module.exports = function ({ print }) {
12
12
  el.isBuiltIn = true
13
13
  return 'mpx-rich-text'
14
14
  },
15
+ ios (tag, { el }) {
16
+ el.isBuiltIn = true
17
+ return 'mpx-rich-text'
18
+ },
19
+ android (tag, { el }) {
20
+ el.isBuiltIn = true
21
+ return 'mpx-rich-text'
22
+ },
15
23
  props: [
16
24
  {
17
25
  test: /^(space)$/,
@@ -31,7 +31,7 @@ module.exports = function ({ print }) {
31
31
  },
32
32
  props: [
33
33
  {
34
- test: /^(display-multiple-items|skip-hidden-item-layout|easing-function)$/,
34
+ test: /^(display-multiple-items|skip-hidden-item-layout)$/,
35
35
  ali: aliPropLog
36
36
  },
37
37
  {
@@ -78,7 +78,7 @@ module.exports = function ({ print }) {
78
78
  }
79
79
  },
80
80
  {
81
- test: /^(placeholder-style|placeholder-class|cursor-spacing|always-embed|adjust-position|hold-keyboard|disable-default-padding|adjust-keyboard-to|fixed|show-confirm-bar)$/,
81
+ test: /^(placeholder-style|placeholder-class|cursor-spacing|always-embed|hold-keyboard|disable-default-padding|adjust-keyboard-to|fixed|show-confirm-bar)$/,
82
82
  ios: iosPropLog,
83
83
  android: androidPropLog
84
84
  }
@@ -11,7 +11,7 @@ const JD_UNSUPPORTED_TAG_NAME_ARR = ['functional-page-navigator', 'live-pusher',
11
11
  // 快应用不支持的标签集合
12
12
  const QA_UNSUPPORTED_TAG_NAME_ARR = ['movable-view', 'movable-area', 'open-data', 'official-account', 'editor', 'functional-page-navigator', 'live-player', 'live-pusher', 'ad', 'cover-image']
13
13
  // RN不支持的标签集合
14
- const RN_UNSUPPORTED_TAG_NAME_ARR = ['open-data', 'official-account', 'editor', 'functional-page-navigator', 'live-player', 'live-pusher', 'ad', 'progress', 'rich-text', 'slider', 'audio', 'camera', 'video', 'match-media', 'page-container', 'editor', 'keyboard-accessory', 'map']
14
+ const RN_UNSUPPORTED_TAG_NAME_ARR = ['open-data', 'official-account', 'editor', 'functional-page-navigator', 'live-player', 'live-pusher', 'ad', 'progress', 'slider', 'audio', 'camera', 'video', 'match-media', 'page-container', 'editor', 'keyboard-accessory', 'map']
15
15
 
16
16
  /**
17
17
  * @param {function(object): function} print
@@ -119,6 +119,9 @@ module.exports = function (template, {
119
119
  }, meta.wxsModuleMap)
120
120
  const bindResult = bindThis.transform(rawCode, {
121
121
  ignoreMap
122
+ // customBindThis (path, t) {
123
+ // path.replaceWith(t.callExpression(t.identifier('getValue'), [t.stringLiteral(path.node.name)]))
124
+ // }
122
125
  })
123
126
  output += `global.currentInject.render = function (createElement, getComponent) {
124
127
  return ${bindResult.code}
@@ -5,6 +5,8 @@ export type LabelContextValue = MutableRefObject<{
5
5
  triggerChange: (evt: NativeSyntheticEvent<TouchEvent>) => void
6
6
  }>
7
7
 
8
+ export type KeyboardAvoidContextValue = (enabled: boolean) => void
9
+
8
10
  export interface GroupValue {
9
11
  [key: string]: { checked: boolean; setValue: Dispatch<SetStateAction<boolean>> }
10
12
  }
@@ -48,3 +50,5 @@ export const VarContext = createContext({})
48
50
  export const IntersectionObserverContext = createContext<IntersectionObserver | null>(null)
49
51
 
50
52
  export const RouteContext = createContext<number | null>(null)
53
+
54
+ export const KeyboardAvoidContext = createContext<KeyboardAvoidContextValue | null>(null)
@@ -8,3 +8,4 @@ export const PickerContext = createContext(null);
8
8
  export const VarContext = createContext({});
9
9
  export const IntersectionObserverContext = createContext(null);
10
10
  export const RouteContext = createContext(null);
11
+ export const KeyboardAvoidContext = createContext(null);
@@ -1,27 +1,27 @@
1
1
  const eventConfigMap = {
2
- bindtap: ['onTouchStart', 'onTouchMove', 'onTouchEnd'],
3
- bindlongpress: ['onTouchStart', 'onTouchMove', 'onTouchEnd', 'onTouchCancel'],
4
- bindtouchstart: ['onTouchStart'],
5
- bindtouchmove: ['onTouchMove'],
6
- bindtouchend: ['onTouchEnd'],
7
- bindtouchcancel: ['onTouchCancel'],
8
- catchtap: ['onTouchStart', 'onTouchMove', 'onTouchEnd'],
9
- catchlongpress: ['onTouchStart', 'onTouchMove', 'onTouchEnd', 'onTouchCancel'],
10
- catchtouchstart: ['onTouchStart'],
11
- catchtouchmove: ['onTouchMove'],
12
- catchtouchend: ['onTouchEnd'],
13
- catchtouchcancel: ['onTouchCancel'],
14
- 'capture-bindtap': ['onTouchStartCapture', 'onTouchMoveCapture', 'onTouchEndCapture'],
15
- 'capture-bindlongpress': ['onTouchStartCapture', 'onTouchMoveCapture', 'onTouchEndCapture', 'onTouchCancelCapture'],
16
- 'capture-bindtouchstart': ['onTouchStartCapture'],
17
- 'capture-bindtouchmove': ['onTouchMoveCapture'],
18
- 'capture-bindtouchend': ['onTouchEndCapture'],
19
- 'capture-bindtouchcancel': ['onTouchCancelCapture'],
20
- 'capture-catchtap': ['onTouchStartCapture', 'onTouchMoveCapture', 'onTouchEndCapture'],
21
- 'capture-catchlongpress': ['onTouchStartCapture', 'onTouchMoveCapture', 'onTouchEndCapture', 'onTouchCancelCapture'],
22
- 'capture-catchtouchstart': ['onTouchStartCapture'],
23
- 'capture-catchtouchmove': ['onTouchMoveCapture'],
24
- 'capture-catchtouchend': ['onTouchEndCapture'],
25
- 'capture-catchtouchcancel': ['onTouchCancelCapture']
2
+ bindtap: { bitFlag: '0', events: ['onTouchStart', 'onTouchMove', 'onTouchEnd'] },
3
+ bindlongpress: { bitFlag: '1', events: ['onTouchStart', 'onTouchMove', 'onTouchEnd', 'onTouchCancel'] },
4
+ bindtouchstart: { bitFlag: '2', events: ['onTouchStart'] },
5
+ bindtouchmove: { bitFlag: '3', events: ['onTouchMove'] },
6
+ bindtouchend: { bitFlag: '4', events: ['onTouchEnd'] },
7
+ bindtouchcancel: { bitFlag: '5', events: ['onTouchCancel'] },
8
+ catchtap: { bitFlag: '6', events: ['onTouchStart', 'onTouchMove', 'onTouchEnd'] },
9
+ catchlongpress: { bitFlag: '7', events: ['onTouchStart', 'onTouchMove', 'onTouchEnd', 'onTouchCancel'] },
10
+ catchtouchstart: { bitFlag: '8', events: ['onTouchStart'] },
11
+ catchtouchmove: { bitFlag: '9', events: ['onTouchMove'] },
12
+ catchtouchend: { bitFlag: 'a', events: ['onTouchEnd'] },
13
+ catchtouchcancel: { bitFlag: 'b', events: ['onTouchCancel'] },
14
+ 'capture-bindtap': { bitFlag: 'c', events: ['onTouchStartCapture', 'onTouchMoveCapture', 'onTouchEndCapture'] },
15
+ 'capture-bindlongpress': { bitFlag: 'd', events: ['onTouchStartCapture', 'onTouchMoveCapture', 'onTouchEndCapture', 'onTouchCancelCapture'] },
16
+ 'capture-bindtouchstart': { bitFlag: 'e', events: ['onTouchStartCapture'] },
17
+ 'capture-bindtouchmove': { bitFlag: 'f', events: ['onTouchMoveCapture'] },
18
+ 'capture-bindtouchend': { bitFlag: 'g', events: ['onTouchEndCapture'] },
19
+ 'capture-bindtouchcancel': { bitFlag: 'h', events: ['onTouchCancelCapture'] },
20
+ 'capture-catchtap': { bitFlag: 'i', events: ['onTouchStartCapture', 'onTouchMoveCapture', 'onTouchEndCapture'] },
21
+ 'capture-catchlongpress': { bitFlag: 'j', events: ['onTouchStartCapture', 'onTouchMoveCapture', 'onTouchEndCapture', 'onTouchCancelCapture'] },
22
+ 'capture-catchtouchstart': { bitFlag: 'k', events: ['onTouchStartCapture'] },
23
+ 'capture-catchtouchmove': { bitFlag: 'l', events: ['onTouchMoveCapture'] },
24
+ 'capture-catchtouchend': { bitFlag: 'm', events: ['onTouchEndCapture'] },
25
+ 'capture-catchtouchcancel': { bitFlag: 'n', events: ['onTouchCancelCapture'] }
26
26
  };
27
27
  export default eventConfigMap;