@mpxjs/webpack-plugin 2.9.59 → 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.
Files changed (115) hide show
  1. package/lib/index.js +1 -3
  2. package/lib/platform/style/wx/index.js +344 -270
  3. package/lib/platform/template/wx/component-config/checkbox-group.js +8 -0
  4. package/lib/platform/template/wx/component-config/checkbox.js +8 -0
  5. package/lib/platform/template/wx/component-config/cover-image.js +15 -0
  6. package/lib/platform/template/wx/component-config/cover-view.js +9 -0
  7. package/lib/platform/template/wx/component-config/form.js +13 -1
  8. package/lib/platform/template/wx/component-config/icon.js +8 -0
  9. package/lib/platform/template/wx/component-config/index.js +5 -1
  10. package/lib/platform/template/wx/component-config/label.js +15 -0
  11. package/lib/platform/template/wx/component-config/movable-area.js +18 -1
  12. package/lib/platform/template/wx/component-config/movable-view.js +18 -1
  13. package/lib/platform/template/wx/component-config/navigator.js +8 -0
  14. package/lib/platform/template/wx/component-config/picker-view-column.js +8 -0
  15. package/lib/platform/template/wx/component-config/picker-view.js +18 -2
  16. package/lib/platform/template/wx/component-config/picker.js +14 -1
  17. package/lib/platform/template/wx/component-config/radio-group.js +8 -0
  18. package/lib/platform/template/wx/component-config/radio.js +8 -0
  19. package/lib/platform/template/wx/component-config/root-portal.js +15 -0
  20. package/lib/platform/template/wx/component-config/switch.js +8 -0
  21. package/lib/platform/template/wx/component-config/unsupported.js +1 -3
  22. package/lib/react/processScript.js +2 -0
  23. package/lib/react/processStyles.js +1 -0
  24. package/lib/react/processTemplate.js +2 -3
  25. package/lib/react/style-helper.js +12 -7
  26. package/lib/runtime/components/react/context.ts +40 -0
  27. package/lib/runtime/components/react/dist/context.js +8 -0
  28. package/lib/runtime/components/react/dist/getInnerListeners.js +34 -12
  29. package/lib/runtime/components/react/dist/mpx-button.jsx +88 -88
  30. package/lib/runtime/components/react/dist/mpx-checkbox-group.jsx +82 -0
  31. package/lib/runtime/components/react/dist/mpx-checkbox.jsx +139 -0
  32. package/lib/runtime/components/react/dist/mpx-form.jsx +61 -0
  33. package/lib/runtime/components/react/dist/mpx-icon.jsx +48 -0
  34. package/lib/runtime/components/react/dist/mpx-image/index.jsx +39 -43
  35. package/lib/runtime/components/react/dist/mpx-image/svg.jsx +3 -2
  36. package/lib/runtime/components/react/dist/mpx-input.jsx +63 -37
  37. package/lib/runtime/components/react/dist/mpx-label.jsx +55 -0
  38. package/lib/runtime/components/react/dist/mpx-movable-area.jsx +41 -0
  39. package/lib/runtime/components/react/dist/mpx-movable-view.jsx +346 -0
  40. package/lib/runtime/components/react/dist/mpx-navigator.jsx +35 -0
  41. package/lib/runtime/components/react/dist/mpx-picker/date.jsx +69 -0
  42. package/lib/runtime/components/react/dist/mpx-picker/index.jsx +138 -0
  43. package/lib/runtime/components/react/dist/mpx-picker/multiSelector.jsx +142 -0
  44. package/lib/runtime/components/react/dist/mpx-picker/region.jsx +94 -0
  45. package/lib/runtime/components/react/dist/mpx-picker/regionData.js +6099 -0
  46. package/lib/runtime/components/react/dist/mpx-picker/selector.jsx +76 -0
  47. package/lib/runtime/components/react/dist/mpx-picker/time.jsx +244 -0
  48. package/lib/runtime/components/react/dist/mpx-picker/type.js +1 -0
  49. package/lib/runtime/components/react/dist/mpx-picker-view-column.jsx +107 -0
  50. package/lib/runtime/components/react/dist/mpx-picker-view.jsx +162 -0
  51. package/lib/runtime/components/react/dist/mpx-radio-group.jsx +80 -0
  52. package/lib/runtime/components/react/dist/mpx-radio.jsx +154 -0
  53. package/lib/runtime/components/react/dist/mpx-root-portal.jsx +15 -0
  54. package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +93 -70
  55. package/lib/runtime/components/react/dist/mpx-swiper/carouse.jsx +281 -157
  56. package/lib/runtime/components/react/dist/mpx-swiper/index.jsx +21 -11
  57. package/lib/runtime/components/react/dist/mpx-swiper-item.jsx +19 -11
  58. package/lib/runtime/components/react/dist/mpx-switch.jsx +79 -0
  59. package/lib/runtime/components/react/dist/mpx-text.jsx +21 -49
  60. package/lib/runtime/components/react/dist/mpx-textarea.jsx +2 -2
  61. package/lib/runtime/components/react/dist/mpx-view.jsx +451 -146
  62. package/lib/runtime/components/react/dist/mpx-web-view.jsx +17 -20
  63. package/lib/runtime/components/react/dist/parser.js +218 -0
  64. package/lib/runtime/components/react/dist/types/common.js +1 -0
  65. package/lib/runtime/components/react/dist/useNodesRef.js +3 -8
  66. package/lib/runtime/components/react/dist/utils.jsx +433 -0
  67. package/lib/runtime/components/react/getInnerListeners.ts +43 -21
  68. package/lib/runtime/components/react/mpx-button.tsx +129 -119
  69. package/lib/runtime/components/react/mpx-checkbox-group.tsx +152 -0
  70. package/lib/runtime/components/react/mpx-checkbox.tsx +234 -0
  71. package/lib/runtime/components/react/mpx-form.tsx +117 -0
  72. package/lib/runtime/components/react/mpx-icon.tsx +106 -0
  73. package/lib/runtime/components/react/mpx-image/index.tsx +62 -68
  74. package/lib/runtime/components/react/mpx-image/svg.tsx +7 -5
  75. package/lib/runtime/components/react/mpx-input.tsx +90 -42
  76. package/lib/runtime/components/react/mpx-label.tsx +110 -0
  77. package/lib/runtime/components/react/mpx-movable-area.tsx +81 -0
  78. package/lib/runtime/components/react/mpx-movable-view.tsx +424 -0
  79. package/lib/runtime/components/react/mpx-navigator.tsx +67 -0
  80. package/lib/runtime/components/react/mpx-picker/date.tsx +82 -0
  81. package/lib/runtime/components/react/mpx-picker/index.tsx +155 -0
  82. package/lib/runtime/components/react/mpx-picker/multiSelector.tsx +156 -0
  83. package/lib/runtime/components/react/mpx-picker/region.tsx +107 -0
  84. package/lib/runtime/components/react/mpx-picker/regionData.ts +6101 -0
  85. package/lib/runtime/components/react/mpx-picker/selector.tsx +91 -0
  86. package/lib/runtime/components/react/mpx-picker/time.tsx +270 -0
  87. package/lib/runtime/components/react/mpx-picker/type.ts +107 -0
  88. package/lib/runtime/components/react/mpx-picker-view-column.tsx +156 -0
  89. package/lib/runtime/components/react/mpx-picker-view.tsx +220 -0
  90. package/lib/runtime/components/react/mpx-radio-group.tsx +150 -0
  91. package/lib/runtime/components/react/mpx-radio.tsx +230 -0
  92. package/lib/runtime/components/react/mpx-root-portal.tsx +27 -0
  93. package/lib/runtime/components/react/mpx-scroll-view.tsx +184 -130
  94. package/lib/runtime/components/react/mpx-swiper/carouse.tsx +308 -183
  95. package/lib/runtime/components/react/mpx-swiper/index.tsx +27 -19
  96. package/lib/runtime/components/react/mpx-swiper/type.ts +23 -5
  97. package/lib/runtime/components/react/mpx-swiper-item.tsx +49 -14
  98. package/lib/runtime/components/react/mpx-switch.tsx +148 -0
  99. package/lib/runtime/components/react/mpx-text.tsx +53 -77
  100. package/lib/runtime/components/react/mpx-textarea.tsx +3 -3
  101. package/lib/runtime/components/react/mpx-view.tsx +576 -195
  102. package/lib/runtime/components/react/mpx-web-view.tsx +34 -39
  103. package/lib/runtime/components/react/parser.ts +245 -0
  104. package/lib/runtime/components/react/types/common.ts +12 -0
  105. package/lib/runtime/components/react/types/getInnerListeners.ts +2 -1
  106. package/lib/runtime/components/react/types/global.d.ts +17 -1
  107. package/lib/runtime/components/react/useNodesRef.ts +4 -10
  108. package/lib/runtime/components/react/utils.tsx +505 -0
  109. package/lib/runtime/optionProcessor.js +19 -17
  110. package/lib/template-compiler/compiler.js +84 -61
  111. package/lib/template-compiler/gen-node-react.js +7 -9
  112. package/lib/web/processStyles.js +2 -5
  113. package/package.json +8 -3
  114. package/lib/runtime/components/react/dist/utils.js +0 -80
  115. package/lib/runtime/components/react/utils.ts +0 -92
@@ -6,6 +6,14 @@ module.exports = function () {
6
6
  web (tag, { el }) {
7
7
  el.isBuiltIn = true
8
8
  return 'mpx-checkbox-group'
9
+ },
10
+ ios (tag, { el }) {
11
+ el.isBuiltIn = true
12
+ return 'mpx-checkbox-group'
13
+ },
14
+ android (tag, { el }) {
15
+ el.isBuiltIn = true
16
+ return 'mpx-checkbox-group'
9
17
  }
10
18
  }
11
19
  }
@@ -7,6 +7,14 @@ module.exports = function () {
7
7
  el.isBuiltIn = true
8
8
  return 'mpx-checkbox'
9
9
  },
10
+ ios (tag, { el }) {
11
+ el.isBuiltIn = true
12
+ return 'mpx-checkbox'
13
+ },
14
+ android (tag, { el }) {
15
+ el.isBuiltIn = true
16
+ return 'mpx-checkbox'
17
+ },
10
18
  event: [
11
19
  {
12
20
  test: 'tap',
@@ -2,6 +2,8 @@ const TAG_NAME = 'cover-image'
2
2
 
3
3
  module.exports = function ({ print }) {
4
4
  const aliEventLog = print({ platform: 'ali', tag: TAG_NAME, isError: false, type: 'event' })
5
+ const iosPropLog = print({ platform: 'ios', tag: TAG_NAME, isError: false })
6
+ const androidPropLog = print({ platform: 'android', tag: TAG_NAME, isError: false })
5
7
  return {
6
8
  test: TAG_NAME,
7
9
  web (tag, { el }) {
@@ -11,12 +13,25 @@ module.exports = function ({ print }) {
11
13
  tt () {
12
14
  return 'image'
13
15
  },
16
+ ios (tag, { el }) {
17
+ el.isBuiltIn = true
18
+ return 'mpx-image'
19
+ },
20
+ android (tag, { el }) {
21
+ el.isBuiltIn = true
22
+ return 'mpx-image'
23
+ },
14
24
  props: [
15
25
  {
16
26
  test: 'use-built-in',
17
27
  web (prop, { el }) {
18
28
  el.isBuiltIn = true
19
29
  }
30
+ },
31
+ {
32
+ test: /^(referrer-policy)$/,
33
+ ios: iosPropLog,
34
+ android: androidPropLog
20
35
  }
21
36
  ],
22
37
  event: [
@@ -4,6 +4,7 @@ module.exports = function ({ print }) {
4
4
  const aliPropLog = print({ platform: 'ali', tag: TAG_NAME, isError: false })
5
5
  const baiduValueLogError = print({ platform: 'baidu', tag: TAG_NAME, isError: true, type: 'value' })
6
6
  const webPropLog = print({ platform: 'web', tag: TAG_NAME, isError: false })
7
+
7
8
  return {
8
9
  test: TAG_NAME,
9
10
  web (tag, { el }) {
@@ -19,6 +20,14 @@ module.exports = function ({ print }) {
19
20
  tt () {
20
21
  return 'view'
21
22
  },
23
+ ios (tag, { el }) {
24
+ el.isBuiltIn = true
25
+ return 'mpx-view'
26
+ },
27
+ android (tag, { el }) {
28
+ el.isBuiltIn = true
29
+ return 'mpx-view'
30
+ },
22
31
  props: [
23
32
  {
24
33
  test: 'scroll-top',
@@ -7,6 +7,8 @@ module.exports = function ({ print }) {
7
7
  const jdPropLog = print({ platform: 'jd', tag: TAG_NAME, isError: false })
8
8
  const webPropLog = print({ platform: 'web', tag: TAG_NAME, isError: false })
9
9
  const qaPropLog = print({ platform: 'qa', tag: TAG_NAME, isError: false })
10
+ const iosPropLog = print({ platform: 'ios', tag: TAG_NAME, isError: false })
11
+ const androidPropLog = print({ platform: 'android', tag: TAG_NAME, isError: false })
10
12
 
11
13
  return {
12
14
  test: TAG_NAME,
@@ -15,6 +17,14 @@ module.exports = function ({ print }) {
15
17
  el.isBuiltIn = true
16
18
  return 'mpx-form'
17
19
  },
20
+ ios (tag, { el }) {
21
+ el.isBuiltIn = true
22
+ return 'mpx-form'
23
+ },
24
+ android (tag, { el }) {
25
+ el.isBuiltIn = true
26
+ return 'mpx-form'
27
+ },
18
28
  props: [
19
29
  {
20
30
  test: /^(report-submit-timeout)$/,
@@ -26,7 +36,9 @@ module.exports = function ({ print }) {
26
36
  {
27
37
  test: /^(report-submit|report-submit-timeout)$/,
28
38
  web: webPropLog,
29
- qa: qaPropLog
39
+ qa: qaPropLog,
40
+ ios: iosPropLog,
41
+ android: androidPropLog
30
42
  }
31
43
  ]
32
44
  }
@@ -6,6 +6,14 @@ module.exports = function () {
6
6
  web (tag, { el }) {
7
7
  el.isBuiltIn = true
8
8
  return 'mpx-icon'
9
+ },
10
+ ios (tag, { el }) {
11
+ el.isBuiltIn = true
12
+ return 'mpx-icon'
13
+ },
14
+ android (tag, { el }) {
15
+ el.isBuiltIn = true
16
+ return 'mpx-icon'
9
17
  }
10
18
  }
11
19
  }
@@ -37,9 +37,11 @@ const unsupported = require('./unsupported')
37
37
  const video = require('./video')
38
38
  const view = require('./view')
39
39
  const webView = require('./web-view')
40
+ const label = require('./label')
40
41
  const wxs = require('./wxs')
41
42
  const component = require('./component')
42
43
  const fixComponentName = require('./fix-component-name')
44
+ const rootPortal = require('./root-portal')
43
45
 
44
46
  module.exports = function getComponentConfigs ({ warn, error }) {
45
47
  /**
@@ -121,6 +123,8 @@ module.exports = function getComponentConfigs ({ warn, error }) {
121
123
  livePlayer({ print }),
122
124
  livePusher({ print }),
123
125
  hyphenTagName({ print }),
124
- component()
126
+ label({ print }),
127
+ component(),
128
+ rootPortal({ print })
125
129
  ]
126
130
  }
@@ -0,0 +1,15 @@
1
+ const TAG_NAME = 'label'
2
+
3
+ module.exports = function () {
4
+ return {
5
+ test: TAG_NAME,
6
+ ios (tag, { el }) {
7
+ el.isBuiltIn = true
8
+ return 'mpx-label'
9
+ },
10
+ android (tag, { el }) {
11
+ el.isBuiltIn = true
12
+ return 'mpx-label'
13
+ }
14
+ }
15
+ }
@@ -1,11 +1,28 @@
1
1
  const TAG_NAME = 'movable-area'
2
2
 
3
3
  module.exports = function ({ print }) {
4
+ const androidPropLog = print({ platform: 'android', tag: TAG_NAME, isError: false })
5
+ const iosPropLog = print({ platform: 'ios', tag: TAG_NAME, isError: false })
4
6
  return {
5
7
  test: TAG_NAME,
6
8
  web (tag, { el }) {
7
9
  el.isBuiltIn = true
8
10
  return 'mpx-movable-area'
9
- }
11
+ },
12
+ android (tag, { el }) {
13
+ el.isBuiltIn = true
14
+ return 'mpx-movable-area'
15
+ },
16
+ ios (tag, { el }) {
17
+ el.isBuiltIn = true
18
+ return 'mpx-movable-area'
19
+ },
20
+ props: [
21
+ {
22
+ test: /^(scale-area)$/,
23
+ ios: iosPropLog,
24
+ android: androidPropLog
25
+ }
26
+ ]
10
27
  }
11
28
  }
@@ -3,16 +3,33 @@ const TAG_NAME = 'movable-view'
3
3
  module.exports = function ({ print }) {
4
4
  const aliEventLog = print({ platform: 'ali', tag: TAG_NAME, isError: false, type: 'event' })
5
5
  const qaPropLog = print({ platform: 'qa', tag: TAG_NAME, isError: false })
6
+ const androidPropLog = print({ platform: 'android', tag: TAG_NAME, isError: false })
7
+ const iosPropLog = print({ platform: 'ios', tag: TAG_NAME, isError: false })
6
8
  return {
7
9
  test: TAG_NAME,
8
10
  web (tag, { el }) {
9
11
  el.isBuiltIn = true
10
12
  return 'mpx-movable-view'
11
13
  },
14
+ android (tag, { el }) {
15
+ el.isBuiltIn = true
16
+ return 'mpx-movable-view'
17
+ },
18
+ ios (tag, { el }) {
19
+ el.isBuiltIn = true
20
+ return 'mpx-movable-view'
21
+ },
12
22
  props: [
13
23
  {
14
24
  test: /^(out-of-bounds)$/,
15
- ali: qaPropLog
25
+ ali: qaPropLog,
26
+ ios: iosPropLog,
27
+ android: androidPropLog
28
+ },
29
+ {
30
+ test: /^(inertia|damping|animation)$/,
31
+ ios: iosPropLog,
32
+ android: androidPropLog
16
33
  }
17
34
  ],
18
35
  event: [
@@ -28,6 +28,14 @@ module.exports = function ({ print }) {
28
28
  el.isBuiltIn = true
29
29
  return 'mpx-navigator'
30
30
  },
31
+ ios (tag, { el }) {
32
+ el.isBuiltIn = true
33
+ return 'mpx-navigator'
34
+ },
35
+ android (tag, { el }) {
36
+ el.isBuiltIn = true
37
+ return 'mpx-navigator'
38
+ },
31
39
  props: [
32
40
  {
33
41
  test: /^(target|delta|app-id|path|extra-data|version|hover-stop-propagation)$/,
@@ -6,6 +6,14 @@ module.exports = function () {
6
6
  web (tag, { el }) {
7
7
  el.isBuiltIn = true
8
8
  return 'mpx-picker-view-column'
9
+ },
10
+ ios (tag, { el }) {
11
+ el.isBuiltIn = true
12
+ return 'mpx-picker-view-column'
13
+ },
14
+ android (tag, { el }) {
15
+ el.isBuiltIn = true
16
+ return 'mpx-picker-view-column'
9
17
  }
10
18
  }
11
19
  }
@@ -6,6 +6,10 @@ module.exports = function ({ print }) {
6
6
  const ttPropLog = print({ platform: 'bytedance', tag: TAG_NAME, isError: false })
7
7
  const ttEventLog = print({ platform: 'bytedance', tag: TAG_NAME, isError: false, type: 'event' })
8
8
  const jdEventLog = print({ platform: 'jd', tag: TAG_NAME, isError: false, type: 'event' })
9
+ const iosPropLog = print({ platform: 'ios', tag: TAG_NAME, isError: false })
10
+ const iosEventLog = print({ platform: 'ios', tag: TAG_NAME, isError: false, type: 'event' })
11
+ const androidPropLog = print({ platform: 'android', tag: TAG_NAME, isError: false })
12
+ const androidEventLog = print({ platform: 'android', tag: TAG_NAME, isError: false, type: 'event' })
9
13
 
10
14
  return {
11
15
  test: TAG_NAME,
@@ -13,10 +17,20 @@ module.exports = function ({ print }) {
13
17
  el.isBuiltIn = true
14
18
  return 'mpx-picker-view'
15
19
  },
20
+ ios (tag, { el }) {
21
+ el.isBuiltIn = true
22
+ return 'mpx-picker-view'
23
+ },
24
+ android (tag, { el }) {
25
+ el.isBuiltIn = true
26
+ return 'mpx-picker-view'
27
+ },
16
28
  props: [
17
29
  {
18
30
  test: /^(indicator-class|mask-class)$/,
19
- tt: ttPropLog
31
+ tt: ttPropLog,
32
+ ios: iosPropLog,
33
+ android: androidPropLog
20
34
  }
21
35
  ],
22
36
  event: [
@@ -25,7 +39,9 @@ module.exports = function ({ print }) {
25
39
  ali: aliEventLog,
26
40
  swan: baiduEventLog,
27
41
  tt: ttEventLog,
28
- jd: jdEventLog
42
+ jd: jdEventLog,
43
+ ios: iosEventLog,
44
+ android: androidEventLog
29
45
  }
30
46
  ]
31
47
  }
@@ -8,12 +8,23 @@ 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
+
11
14
  return {
12
15
  test: TAG_NAME,
13
16
  web (tag, { el }) {
14
17
  el.isBuiltIn = true
15
18
  return 'mpx-picker'
16
19
  },
20
+ ios (tag, { el }) {
21
+ el.isBuiltIn = true
22
+ return 'mpx-picker'
23
+ },
24
+ android (tag, { el }) {
25
+ el.isBuiltIn = true
26
+ return 'mpx-picker'
27
+ },
17
28
  props: [
18
29
  {
19
30
  test: 'mode',
@@ -30,7 +41,9 @@ module.exports = function ({ print }) {
30
41
  swan: baiduPropLog,
31
42
  ali: aliPropLog,
32
43
  jd: jdPropLog,
33
- qa: qaPropLog
44
+ qa: qaPropLog,
45
+ ios: iosPropLog,
46
+ android: androidPropLog
34
47
  }
35
48
  ],
36
49
  event: [
@@ -6,6 +6,14 @@ module.exports = function () {
6
6
  web (tag, { el }) {
7
7
  el.isBuiltIn = true
8
8
  return 'mpx-radio-group'
9
+ },
10
+ ios (tag, { el }) {
11
+ el.isBuiltIn = true
12
+ return 'mpx-radio-group'
13
+ },
14
+ android (tag, { el }) {
15
+ el.isBuiltIn = true
16
+ return 'mpx-radio-group'
9
17
  }
10
18
  }
11
19
  }
@@ -7,6 +7,14 @@ module.exports = function () {
7
7
  el.isBuiltIn = true
8
8
  return 'mpx-radio'
9
9
  },
10
+ ios (tag, { el }) {
11
+ el.isBuiltIn = true
12
+ return 'mpx-radio'
13
+ },
14
+ android (tag, { el }) {
15
+ el.isBuiltIn = true
16
+ return 'mpx-radio'
17
+ },
10
18
  event: [
11
19
  {
12
20
  test: 'tap',
@@ -0,0 +1,15 @@
1
+ const TAG_NAME = 'root-portal'
2
+
3
+ module.exports = function ({ print }) {
4
+ return {
5
+ test: TAG_NAME,
6
+ ios (tag, { el }) {
7
+ el.isBuiltIn = true
8
+ return 'mpx-root-portal'
9
+ },
10
+ android (tag, { el }) {
11
+ el.isBuiltIn = true
12
+ return 'mpx-root-portal'
13
+ }
14
+ }
15
+ }
@@ -10,6 +10,14 @@ module.exports = function ({ print }) {
10
10
  el.isBuiltIn = true
11
11
  return 'mpx-switch'
12
12
  },
13
+ ios (tag, { el }) {
14
+ el.isBuiltIn = true
15
+ return 'mpx-switch'
16
+ },
17
+ android (tag, { el }) {
18
+ el.isBuiltIn = true
19
+ return 'mpx-switch'
20
+ },
13
21
  props: [
14
22
  {
15
23
  test: /^type$/,
@@ -11,9 +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 = ['movable-view', 'movable-area', 'open-data', 'official-account', 'editor', 'functional-page-navigator', 'live-player', 'live-pusher', 'ad', 'cover-image',
15
- 'checkbox', 'checkbox-group', 'radio', 'radio-group', 'switch', 'movable-area', 'movable-view', 'icon', 'progress', 'rich-text', 'form', 'label', 'picker', 'picker-view', 'picker-view-column', 'slider',
16
- 'audio', 'camera', 'video', 'canvas', 'cover-image', 'cover-view', 'match-media', 'page-container', 'root-portal', 'editor', 'keyboard-accessory', 'navigator', 'map']
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', 'canvas', 'match-media', 'page-container', 'editor', 'keyboard-accessory', 'map']
17
15
 
18
16
  /**
19
17
  * @param {function(object): function} print
@@ -28,12 +28,14 @@ import { NavigationContainer, createNavigationContainerRef, StackActions } from
28
28
  import { createNativeStackNavigator } from '@react-navigation/native-stack'
29
29
  import { Provider } from '@ant-design/react-native'
30
30
  import { SafeAreaProvider, useSafeAreaInsets } from 'react-native-safe-area-context'
31
+ import { GestureHandlerRootView } from 'react-native-gesture-handler'
31
32
 
32
33
  global.__navigationHelper = {
33
34
  NavigationContainer: NavigationContainer,
34
35
  createNavigationContainerRef: createNavigationContainerRef,
35
36
  createNativeStackNavigator: createNativeStackNavigator,
36
37
  StackActions: StackActions,
38
+ GestureHandlerRootView: GestureHandlerRootView,
37
39
  Provider: Provider,
38
40
  SafeAreaProvider: SafeAreaProvider,
39
41
  useSafeAreaInsets: useSafeAreaInsets
@@ -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, rootProps) {
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 rpxRegExp = /^\s*(-?\d+(\.\d+)?)rpx\s*$/
6
- const pxRegExp = /^\s*(-?\d+(\.\d+)?)(px)?\s*$/
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 = pxRegExp.exec(value))) {
20
+ if ((matched = numberRegExp.exec(value))) {
19
21
  value = matched[1]
20
22
  needStringify = false
21
- } else if ((matched = rpxRegExp.exec(value))) {
22
- value = `this.__rpx(${matched[1]})`
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 => {
@@ -0,0 +1,40 @@
1
+ import { createContext, Dispatch, MutableRefObject, SetStateAction } from 'react'
2
+ import { NativeSyntheticEvent } from 'react-native'
3
+
4
+ export type LabelContextValue = MutableRefObject<{
5
+ triggerChange: (evt: NativeSyntheticEvent<TouchEvent>) => void
6
+ }>
7
+
8
+ export interface GroupValue {
9
+ [key: string]: { checked: boolean; setValue: Dispatch<SetStateAction<boolean>> }
10
+ }
11
+
12
+ export interface GroupContextValue {
13
+ groupValue: GroupValue
14
+ notifyChange: (evt: NativeSyntheticEvent<TouchEvent>) => void
15
+ }
16
+
17
+ export interface FormFieldValue {
18
+ getValue: () => any
19
+ resetValue: ({ newVal, type }: { newVal?: any; type?: string }) => void
20
+ }
21
+
22
+ export interface FormContextValue {
23
+ formValuesMap: Map<string, FormFieldValue>
24
+ submit: () => void
25
+ reset: () => void
26
+ }
27
+
28
+ export const MovableAreaContext = createContext({ width: 0, height: 0 })
29
+
30
+ export const FormContext = createContext<FormContextValue | null>(null)
31
+
32
+ export const CheckboxGroupContext = createContext<GroupContextValue | null>(null)
33
+
34
+ export const RadioGroupContext = createContext<GroupContextValue | null>(null)
35
+
36
+ export const LabelContext = createContext<LabelContextValue | null>(null)
37
+
38
+ export const PickerContext = createContext(null)
39
+
40
+ export const VarContext = createContext({})
@@ -0,0 +1,8 @@
1
+ import { createContext } from 'react';
2
+ export const MovableAreaContext = createContext({ width: 0, height: 0 });
3
+ export const FormContext = createContext(null);
4
+ export const CheckboxGroupContext = createContext(null);
5
+ export const RadioGroupContext = createContext(null);
6
+ export const LabelContext = createContext(null);
7
+ export const PickerContext = createContext(null);
8
+ export const VarContext = createContext({});
@@ -65,10 +65,13 @@ export const getCustomEvent = (type = '', oe = {}, { detail = {}, layoutRef }, p
65
65
  dataset: getDataSet(props),
66
66
  offsetLeft: layoutRef?.current?.offsetLeft || 0,
67
67
  offsetTop: layoutRef?.current?.offsetTop || 0
68
- }
68
+ },
69
+ persist: oe.persist,
70
+ stopPropagation: oe.stopPropagation,
71
+ preventDefault: oe.preventDefault
69
72
  };
70
73
  };
71
- const useInnerProps = (props = {}, additionalProps = {}, removeProps = [], rawConfig) => {
74
+ const useInnerProps = (props = {}, additionalProps = {}, userRemoveProps = [], rawConfig) => {
72
75
  const ref = useRef({
73
76
  startTimer: {
74
77
  bubble: null,
@@ -87,7 +90,18 @@ const useInnerProps = (props = {}, additionalProps = {}, removeProps = [], rawCo
87
90
  });
88
91
  const propsRef = useRef({});
89
92
  const eventConfig = {};
90
- const config = rawConfig || {};
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
+ ];
91
105
  propsRef.current = { ...props, ...additionalProps };
92
106
  for (const key in eventConfigMap) {
93
107
  if (propsRef.current[key]) {
@@ -108,6 +122,17 @@ const useInnerProps = (props = {}, additionalProps = {}, removeProps = [], rawCo
108
122
  }
109
123
  });
110
124
  }
125
+ function checkIsNeedPress(e, type) {
126
+ const tapDetailInfo = ref.current.mpxPressInfo.detail || { x: 0, y: 0 };
127
+ const nativeEvent = e.nativeEvent;
128
+ const currentPageX = nativeEvent.changedTouches[0].pageX;
129
+ const currentPageY = nativeEvent.changedTouches[0].pageY;
130
+ if (Math.abs(currentPageX - tapDetailInfo.x) > 1 || Math.abs(currentPageY - tapDetailInfo.y) > 1) {
131
+ ref.current.needPress[type] = false;
132
+ ref.current.startTimer[type] && clearTimeout(ref.current.startTimer[type]);
133
+ ref.current.startTimer[type] = null;
134
+ }
135
+ }
111
136
  function handleTouchstart(e, type) {
112
137
  e.persist();
113
138
  const bubbleTouchEvent = ['catchtouchstart', 'bindtouchstart'];
@@ -135,19 +160,13 @@ const useInnerProps = (props = {}, additionalProps = {}, removeProps = [], rawCo
135
160
  function handleTouchmove(e, type) {
136
161
  const bubbleTouchEvent = ['catchtouchmove', 'bindtouchmove'];
137
162
  const captureTouchEvent = ['capture-catchtouchmove', 'capture-bindtouchmove'];
138
- const tapDetailInfo = ref.current.mpxPressInfo.detail || { x: 0, y: 0 };
139
- const nativeEvent = e.nativeEvent;
140
- const currentPageX = nativeEvent.changedTouches[0].pageX;
141
- const currentPageY = nativeEvent.changedTouches[0].pageY;
142
163
  const currentTouchEvent = type === 'bubble' ? bubbleTouchEvent : captureTouchEvent;
143
- if (Math.abs(currentPageX - tapDetailInfo.x) > 1 || Math.abs(currentPageY - tapDetailInfo.y) > 1) {
144
- ref.current.needPress[type] = false;
145
- ref.current.startTimer[type] && clearTimeout(ref.current.startTimer[type]);
146
- ref.current.startTimer[type] = null;
147
- }
148
164
  handleEmitEvent(currentTouchEvent, 'touchmove', e);
165
+ checkIsNeedPress(e, type);
149
166
  }
150
167
  function handleTouchend(e, type) {
168
+ // move event may not be triggered
169
+ checkIsNeedPress(e, type);
151
170
  const bubbleTouchEvent = ['catchtouchend', 'bindtouchend'];
152
171
  const bubbleTapEvent = ['catchtap', 'bindtap'];
153
172
  const captureTouchEvent = ['capture-catchtouchend', 'capture-bindtouchend'];
@@ -158,6 +177,9 @@ const useInnerProps = (props = {}, additionalProps = {}, removeProps = [], rawCo
158
177
  ref.current.startTimer[type] = null;
159
178
  handleEmitEvent(currentTouchEvent, 'touchend', e);
160
179
  if (ref.current.needPress[type]) {
180
+ if (type === 'bubble' && config.disableTap) {
181
+ return;
182
+ }
161
183
  handleEmitEvent(currentTapEvent, 'tap', e);
162
184
  }
163
185
  }