@mpxjs/webpack-plugin 2.9.67 → 2.9.70-alpha.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.
Files changed (161) hide show
  1. package/README.md +1 -1
  2. package/lib/config.js +14 -0
  3. package/lib/dependencies/AddEntryDependency.js +24 -0
  4. package/lib/dependencies/ResolveDependency.js +5 -0
  5. package/lib/index.js +51 -15
  6. package/lib/json-compiler/helper.js +3 -3
  7. package/lib/loader.js +53 -0
  8. package/lib/platform/template/wx/component-config/button.js +14 -2
  9. package/lib/platform/template/wx/component-config/canvas.js +8 -0
  10. package/lib/platform/template/wx/component-config/image.js +4 -0
  11. package/lib/platform/template/wx/component-config/input.js +5 -1
  12. package/lib/platform/template/wx/component-config/rich-text.js +4 -0
  13. package/lib/platform/template/wx/component-config/scroll-view.js +4 -0
  14. package/lib/platform/template/wx/component-config/swiper.js +1 -1
  15. package/lib/platform/template/wx/component-config/switch.js +4 -0
  16. package/lib/platform/template/wx/component-config/text.js +4 -0
  17. package/lib/platform/template/wx/component-config/textarea.js +6 -1
  18. package/lib/platform/template/wx/component-config/unsupported.js +1 -1
  19. package/lib/platform/template/wx/component-config/view.js +4 -0
  20. package/lib/platform/template/wx/index.js +127 -1
  21. package/lib/react/processStyles.js +14 -4
  22. package/lib/react/processTemplate.js +3 -0
  23. package/lib/resolve-loader.js +4 -1
  24. package/lib/resolver/AddModePlugin.js +8 -8
  25. package/lib/runtime/components/react/context.ts +6 -0
  26. package/lib/runtime/components/react/dist/context.js +2 -0
  27. package/lib/runtime/components/react/dist/event.config.js +24 -24
  28. package/lib/runtime/components/react/dist/getInnerListeners.js +183 -174
  29. package/lib/runtime/components/react/dist/mpx-button.jsx +77 -49
  30. package/lib/runtime/components/react/dist/mpx-canvas/Bus.js +60 -0
  31. package/lib/runtime/components/react/dist/mpx-canvas/CanvasGradient.js +15 -0
  32. package/lib/runtime/components/react/dist/mpx-canvas/CanvasRenderingContext2D.js +84 -0
  33. package/lib/runtime/components/react/dist/mpx-canvas/Image.js +87 -0
  34. package/lib/runtime/components/react/dist/mpx-canvas/ImageData.js +15 -0
  35. package/lib/runtime/components/react/dist/mpx-canvas/constructorsRegistry.js +28 -0
  36. package/lib/runtime/components/react/dist/mpx-canvas/html.js +343 -0
  37. package/lib/runtime/components/react/dist/mpx-canvas/index.jsx +232 -0
  38. package/lib/runtime/components/react/dist/mpx-canvas/utils.jsx +89 -0
  39. package/lib/runtime/components/react/dist/mpx-checkbox-group.jsx +13 -19
  40. package/lib/runtime/components/react/dist/mpx-checkbox.jsx +29 -38
  41. package/lib/runtime/components/react/dist/mpx-form.jsx +16 -19
  42. package/lib/runtime/components/react/dist/mpx-icon.jsx +8 -16
  43. package/lib/runtime/components/react/dist/mpx-image.jsx +291 -0
  44. package/lib/runtime/components/react/dist/mpx-input.jsx +54 -27
  45. package/lib/runtime/components/react/dist/mpx-label.jsx +15 -22
  46. package/lib/runtime/components/react/dist/mpx-movable-area.jsx +13 -16
  47. package/lib/runtime/components/react/dist/mpx-movable-view.jsx +13 -13
  48. package/lib/runtime/components/react/dist/mpx-navigator.jsx +2 -4
  49. package/lib/runtime/components/react/dist/mpx-picker/date.jsx +6 -2
  50. package/lib/runtime/components/react/dist/mpx-picker/index.jsx +5 -3
  51. package/lib/runtime/components/react/dist/mpx-picker/multiSelector.jsx +6 -2
  52. package/lib/runtime/components/react/dist/mpx-picker/region.jsx +6 -2
  53. package/lib/runtime/components/react/dist/mpx-picker/selector.jsx +6 -2
  54. package/lib/runtime/components/react/dist/mpx-picker/time.jsx +10 -15
  55. package/lib/runtime/components/react/dist/mpx-picker-view-column-item.jsx +39 -0
  56. package/lib/runtime/components/react/dist/mpx-picker-view-column.jsx +160 -88
  57. package/lib/runtime/components/react/dist/mpx-picker-view.jsx +80 -121
  58. package/lib/runtime/components/react/dist/mpx-radio-group.jsx +11 -19
  59. package/lib/runtime/components/react/dist/mpx-radio.jsx +27 -42
  60. package/lib/runtime/components/react/dist/mpx-rich-text/html.js +39 -0
  61. package/lib/runtime/components/react/dist/mpx-rich-text/index.jsx +63 -0
  62. package/lib/runtime/components/react/dist/mpx-root-portal.jsx +6 -4
  63. package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +47 -41
  64. package/lib/runtime/components/react/dist/mpx-simple-text.jsx +11 -0
  65. package/lib/runtime/components/react/dist/mpx-swiper-item.jsx +4 -2
  66. package/lib/runtime/components/react/dist/mpx-swiper.jsx +606 -0
  67. package/lib/runtime/components/react/dist/mpx-switch.jsx +20 -10
  68. package/lib/runtime/components/react/dist/mpx-text.jsx +11 -10
  69. package/lib/runtime/components/react/dist/mpx-textarea.jsx +8 -3
  70. package/lib/runtime/components/react/dist/mpx-view.jsx +65 -61
  71. package/lib/runtime/components/react/dist/mpx-web-view.jsx +112 -35
  72. package/lib/runtime/components/react/dist/pickerFaces.js +81 -0
  73. package/lib/runtime/components/react/dist/pickerVIewContext.js +9 -0
  74. package/lib/runtime/components/react/dist/pickerViewMask.jsx +18 -0
  75. package/lib/runtime/components/react/dist/pickerViewOverlay.jsx +23 -0
  76. package/lib/runtime/components/react/dist/useAnimationHooks.js +35 -9
  77. package/lib/runtime/components/react/dist/utils.jsx +70 -23
  78. package/lib/runtime/components/react/getInnerListeners.ts +36 -43
  79. package/lib/runtime/components/react/mpx-button.tsx +95 -43
  80. package/lib/runtime/components/react/mpx-canvas/Bus.ts +70 -0
  81. package/lib/runtime/components/react/mpx-canvas/CanvasGradient.ts +18 -0
  82. package/lib/runtime/components/react/mpx-canvas/CanvasRenderingContext2D.ts +87 -0
  83. package/lib/runtime/components/react/mpx-canvas/Image.ts +102 -0
  84. package/lib/runtime/components/react/mpx-canvas/ImageData.ts +23 -0
  85. package/lib/runtime/components/react/mpx-canvas/constructorsRegistry.ts +38 -0
  86. package/lib/runtime/components/react/mpx-canvas/html.ts +343 -0
  87. package/lib/runtime/components/react/mpx-canvas/index.tsx +302 -0
  88. package/lib/runtime/components/react/mpx-canvas/utils.tsx +150 -0
  89. package/lib/runtime/components/react/mpx-checkbox-group.tsx +13 -12
  90. package/lib/runtime/components/react/mpx-checkbox.tsx +28 -28
  91. package/lib/runtime/components/react/mpx-form.tsx +10 -8
  92. package/lib/runtime/components/react/mpx-icon.tsx +10 -15
  93. package/lib/runtime/components/react/mpx-image.tsx +396 -0
  94. package/lib/runtime/components/react/mpx-input.tsx +61 -33
  95. package/lib/runtime/components/react/mpx-label.tsx +14 -13
  96. package/lib/runtime/components/react/mpx-movable-area.tsx +8 -7
  97. package/lib/runtime/components/react/mpx-movable-view.tsx +1 -1
  98. package/lib/runtime/components/react/mpx-picker/date.tsx +5 -2
  99. package/lib/runtime/components/react/mpx-picker/index.tsx +3 -2
  100. package/lib/runtime/components/react/mpx-picker/multiSelector.tsx +5 -2
  101. package/lib/runtime/components/react/mpx-picker/region.tsx +5 -2
  102. package/lib/runtime/components/react/mpx-picker/selector.tsx +5 -2
  103. package/lib/runtime/components/react/mpx-picker/time.tsx +10 -15
  104. package/lib/runtime/components/react/mpx-picker/type.ts +48 -43
  105. package/lib/runtime/components/react/mpx-picker-view-column.tsx +236 -104
  106. package/lib/runtime/components/react/mpx-picker-view.tsx +132 -122
  107. package/lib/runtime/components/react/mpx-radio-group.tsx +11 -12
  108. package/lib/runtime/components/react/mpx-radio.tsx +26 -29
  109. package/lib/runtime/components/react/mpx-scroll-view.tsx +32 -30
  110. package/lib/runtime/components/react/mpx-simple-text.tsx +18 -0
  111. package/lib/runtime/components/react/mpx-swiper/carouse.tsx +4 -2
  112. package/lib/runtime/components/react/mpx-swiper-item.tsx +3 -2
  113. package/lib/runtime/components/react/mpx-switch.tsx +10 -8
  114. package/lib/runtime/components/react/mpx-text.tsx +6 -2
  115. package/lib/runtime/components/react/mpx-view.tsx +81 -59
  116. package/lib/runtime/components/react/mpx-web-view.tsx +46 -19
  117. package/lib/runtime/components/react/pickerFaces.ts +104 -0
  118. package/lib/runtime/components/react/pickerOverlay.tsx +32 -0
  119. package/lib/runtime/components/react/types/common.ts +2 -0
  120. package/lib/runtime/components/react/types/global.d.ts +3 -16
  121. package/lib/runtime/components/react/utils.tsx +98 -27
  122. package/lib/runtime/components/tenon/getInnerListeners.js +334 -0
  123. package/lib/runtime/components/tenon/tenon-button.vue +309 -0
  124. package/lib/runtime/components/tenon/tenon-image.vue +66 -0
  125. package/lib/runtime/components/tenon/tenon-input.vue +171 -0
  126. package/lib/runtime/components/tenon/tenon-rich-text.vue +26 -0
  127. package/lib/runtime/components/tenon/tenon-scroll-view.vue +127 -0
  128. package/lib/runtime/components/tenon/tenon-switch.vue +96 -0
  129. package/lib/runtime/components/tenon/tenon-text.vue +70 -0
  130. package/lib/runtime/components/tenon/tenon-textarea.vue +86 -0
  131. package/lib/runtime/components/tenon/tenon-view.vue +93 -0
  132. package/lib/runtime/components/web/getInnerListeners.js +6 -6
  133. package/lib/runtime/components/web/mpx-movable-view.vue +334 -344
  134. package/lib/runtime/components/web/mpx-picker-view-column.vue +75 -75
  135. package/lib/runtime/components/web/mpx-picker.vue +382 -385
  136. package/lib/runtime/components/web/mpx-web-view.vue +162 -162
  137. package/lib/runtime/optionProcessor.js +7 -16
  138. package/lib/runtime/optionProcessor.tenon.js +84 -0
  139. package/lib/runtime/utils.js +2 -0
  140. package/lib/style-compiler/index.js +1 -1
  141. package/lib/style-compiler/plugins/hm.js +20 -0
  142. package/lib/template-compiler/bind-this.js +7 -2
  143. package/lib/template-compiler/compiler.js +70 -42
  144. package/lib/template-compiler/gen-node-react.js +3 -3
  145. package/lib/tenon/index.js +117 -0
  146. package/lib/tenon/processJSON.js +352 -0
  147. package/lib/tenon/processScript.js +203 -0
  148. package/lib/tenon/processStyles.js +21 -0
  149. package/lib/tenon/processTemplate.js +126 -0
  150. package/lib/tenon/script-helper.js +223 -0
  151. package/lib/utils/env.js +6 -1
  152. package/lib/utils/get-relative-path.js +25 -0
  153. package/package.json +9 -4
  154. package/LICENSE +0 -433
  155. package/lib/runtime/components/react/dist/mpx-image/index.jsx +0 -226
  156. package/lib/runtime/components/react/dist/mpx-image/svg.jsx +0 -7
  157. package/lib/runtime/components/react/dist/mpx-swiper/carouse.jsx +0 -478
  158. package/lib/runtime/components/react/dist/mpx-swiper/index.jsx +0 -68
  159. package/lib/runtime/components/react/dist/mpx-swiper/type.js +0 -1
  160. package/lib/runtime/components/react/mpx-image/index.tsx +0 -345
  161. package/lib/runtime/components/react/mpx-image/svg.tsx +0 -22
@@ -0,0 +1,309 @@
1
+ <script>
2
+ import { h } from "@hummer/tenon-vue";
3
+ import getInnerListeners from "./getInnerListeners";
4
+
5
+ // 获取当前小程序样式版本配置
6
+ const styleVersion = global.__style || "";
7
+ const sizeClassMap = {
8
+ default: "",
9
+ mini: "mpx-button-size-mini",
10
+ };
11
+ const typeClassMap = {
12
+ primary: "mpx-button-type-primary",
13
+ warn: "mpx-button-type-warn",
14
+ };
15
+ const plainClassMap = {
16
+ false: "",
17
+ true: "mpx-button-plain",
18
+ };
19
+ const disabledClassMap = {
20
+ false: "",
21
+ true: "mpx-button-disabled",
22
+ };
23
+ const clickDisabledClassMap = {
24
+ false: "",
25
+ true: "mpx-button-click-disabled",
26
+ };
27
+ export default (function(){
28
+ return {
29
+ name: "mpx-button",
30
+ data() {
31
+ return {
32
+ hover: false,
33
+ };
34
+ },
35
+ props: {
36
+ name: String,
37
+ size: {
38
+ type: String,
39
+ default: "default",
40
+ },
41
+ type: {
42
+ type: String,
43
+ default: "default",
44
+ },
45
+ plain: Boolean,
46
+ disabled: Boolean,
47
+ loading: Boolean,
48
+ formType: String,
49
+ hoverClass: {
50
+ type: String,
51
+ default: "button-hover",
52
+ },
53
+ hoverStopPropagation: {
54
+ type: Boolean,
55
+ default: false,
56
+ },
57
+ hoverStartTime: {
58
+ type: Number,
59
+ default: 20,
60
+ },
61
+ hoverStayTime: {
62
+ type: Number,
63
+ default: 70,
64
+ },
65
+ },
66
+ computed: {
67
+ originRef() {
68
+ return this.$refs["mpx-button"]
69
+ },
70
+ className() {
71
+ if (this.hoverClass && this.hoverClass !== "none" && this.hover) {
72
+ return this.hoverClass;
73
+ }
74
+ return "";
75
+ },
76
+ classNameList() {
77
+ let classArr = [];
78
+ if (this.hoverClass && this.hoverClass !== "none" && this.hover) {
79
+ classArr.push(this.hoverClass);
80
+ }
81
+ if (styleVersion === "v2") {
82
+ classArr.push(`${sizeClassMap[this.size]}${styleVersion}`);
83
+ classArr.push(`${typeClassMap[this.type]}${styleVersion}`);
84
+ classArr.push(`mpx-button-version${styleVersion}`);
85
+ } else {
86
+ classArr.push(sizeClassMap[this.size]);
87
+ classArr.push(typeClassMap[this.type]);
88
+ classArr.push(`mpx-button-version`);
89
+ }
90
+ classArr.push(plainClassMap[this.plain]);
91
+ classArr.push(disabledClassMap["" + !!this.disabled]);
92
+ // 禁用click
93
+ classArr.push(clickDisabledClassMap["" + !!this.disabled]);
94
+ return classArr;
95
+ },
96
+ },
97
+ render() {
98
+ let mergeAfter;
99
+ if (this.hoverClass && this.hoverClass !== "none") {
100
+ mergeAfter = {
101
+ listeners: {
102
+ onTouchstart: this.handleTouchstart,
103
+ onTouchend: this.handleTouchend,
104
+ },
105
+ force: true,
106
+ };
107
+ }
108
+ const domProps = {
109
+ disabled: this.disabled,
110
+ plain: this.plain,
111
+ type: this.type,
112
+ };
113
+ const data = {
114
+ class: ["mpx-button", ...this.classNameList],
115
+ ref: "mpx-button",
116
+ ...domProps,
117
+ ...getInnerListeners(this, {
118
+ mergeAfter,
119
+ // 由于当前机制下tap事件只有存在tap监听才会触发,为了确保该组件能够触发tap,传递一个包含tap的defaultListeners用于模拟存在tap监听
120
+ defaultListeners: ["onTap"],
121
+ }),
122
+ };
123
+
124
+ let text = "";
125
+ const nodes = this.$slots.default();
126
+ nodes.forEach((item) => {
127
+ if (item.shapeFlag === 8 && item.children) {
128
+ text += item.children;
129
+ }
130
+ });
131
+ return h("button", data, text);
132
+ },
133
+ methods: {
134
+ handleTouchstart(e) {
135
+ if (e.__hoverStopPropagation) {
136
+ return;
137
+ }
138
+ e.__hoverStopPropagation = this.hoverStopPropagation;
139
+ clearTimeout(this.startTimer);
140
+ this.startTimer = setTimeout(() => {
141
+ this.hover = true;
142
+ }, this.hoverStartTime);
143
+ },
144
+ handleTouchend() {
145
+ clearTimeout(this.endTimer);
146
+ this.endTimer = setTimeout(() => {
147
+ this.hover = false;
148
+ }, this.hoverStayTime);
149
+ },
150
+ },
151
+ }
152
+ })()
153
+ </script>
154
+
155
+
156
+
157
+ <style lang="stylus" scoped>
158
+ .mpx-button-versionv2
159
+ width: 184px
160
+ line-height 1.41176471
161
+ font-weight: 700;
162
+ padding-top 8px
163
+ padding-bottom 8px
164
+ .mpx-button-version
165
+ width: 100%
166
+ line-height 2.55555556
167
+ cursor: pointer
168
+ &:after
169
+ border 1px solid rgba(0,0,0,.2)
170
+
171
+ .mpx-button
172
+ padding-left: 14px
173
+ padding-right: 14px
174
+ border none
175
+ outline: none
176
+ position relative
177
+ display block
178
+ margin-left auto
179
+ margin-right auto
180
+ margin-bottom 10px
181
+ box-sizing border-box
182
+ font-size 18px
183
+ text-align center
184
+ text-decoration none
185
+ border-radius 5px
186
+ -webkit-tap-highlight-color transparent
187
+ overflow hidden
188
+ color #000
189
+ background-color #f8f8f8
190
+ &:after
191
+ content " "
192
+ width 200%
193
+ height 200%
194
+ position absolute
195
+ top 0
196
+ left 0
197
+ -webkit-transform scale(.5)
198
+ transform scale(.5)
199
+ -webkit-transform-origin 0 0
200
+ transform-origin 0 0
201
+ box-sizing border-box
202
+ border-radius 10px
203
+
204
+ &.button-hover
205
+ background-color #dedede
206
+
207
+ /* 默认版本 size=mini style */
208
+ &.mpx-button-size-mini
209
+ display inline-block
210
+ line-height 2.3
211
+ font-size 13px
212
+ padding 0 1.34em
213
+ width auto
214
+ /* v2 size=mini style */
215
+ &.mpx-button-size-miniv2
216
+ width auto
217
+ padding 0 0.75em
218
+ line-height 2
219
+ font-size 16px
220
+ display inline-block
221
+ &.mpx-button-plain
222
+ color #353535
223
+ border 1px solid #353535
224
+ background-color transparent
225
+ &.mpx-button-plain.button-hover
226
+ background-color rgba(0, 0, 0, 0)
227
+ color #828282
228
+ border 1px solid #828282
229
+
230
+ /* 默认版本 type=primary style */
231
+ &.mpx-button-type-primary
232
+ background-color #1aad19
233
+ color #fff
234
+ &.mpx-button-type-primary.mpx-button-plain
235
+ color #1aad19
236
+ border-color #1aad19
237
+ background-color #fff
238
+ /* v2 type=primary style */
239
+ &.mpx-button-type-primaryv2
240
+ background-color #07c160
241
+ color #fff
242
+ &.mpx-button-type-primaryv2.button-hover
243
+ color #fff
244
+ background-color #06ad56
245
+ &.mpx-button-type-primaryv2.mpx-button-plain
246
+ color #06ae56
247
+ border-color #179c16
248
+ background-color #fff
249
+ &.mpx-button-type-primaryv2.button-hover.mpx-button-plain
250
+ color #06ae56
251
+ background-color rgba(0, 0, 0, .1)
252
+
253
+ /* 默认版本 type=warn style */
254
+ &.mpx-button-type-warn
255
+ color #fff
256
+ background-color #e64340
257
+ &.mpx-button-type-warn.mpx-button-plain
258
+ color #e64340
259
+ background-color transparent
260
+ border 1px solid #e64340
261
+ /* v2 type=warn style */
262
+ &.mpx-button-type-warnv2
263
+ color #fa5151
264
+ background-color #f2f2f2
265
+ &.mpx-button-type-warnv2.button-hover
266
+ background-color #d9d9d9
267
+ &.mpx-button-type-warnv2.mpx-button-plain
268
+ color #fa5151
269
+ background-color #fff
270
+ border 1px solid #e64340
271
+ &.mpx-button-type-warnv2.button-hover.mpx-button-plain
272
+ color: #f58c8d
273
+ border 1px solid #f58a8b
274
+ background-color #fff
275
+
276
+ &.mpx-button-disabled
277
+ color rgba(0, 0, 0, 0.18) !important
278
+ background-color #fafafa !important
279
+ border 1px solid rgba(0, 0, 0, .2) !important
280
+ &.mpx-button-click-disabled
281
+ pointer-events none
282
+ &.mpx-button-loading
283
+ &.mpx-button-type-warn
284
+ color rgba(255,255,255,.6)
285
+ background-color #ce3c39
286
+ &.mpx-button-type-warnv2
287
+ background-color #d9d9d9
288
+ color #fa5151
289
+ &.mpx-button-type-primary
290
+ color: rgba(255,255,255,.6);
291
+ background-color: #179b16;
292
+ &:before
293
+ content: " "
294
+ display: inline-block
295
+ width: 18px
296
+ height: 18px
297
+ vertical-align: middle
298
+ -webkit-animation: mpxButton 1s steps(12,end) infinite
299
+ animation: mpxButton 1s steps(12,end) infinite
300
+ background transparent url('data:image/svg+xml;base64,PHN2ZyBjbGFzcz0iciIgd2lkdGg9JzEyMHB4JyBoZWlnaHQ9JzEyMHB4JyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxMDAgMTAwIj4KICAgIDxyZWN0IHg9IjAiIHk9IjAiIHdpZHRoPSIxMDAiIGhlaWdodD0iMTAwIiBmaWxsPSJub25lIiBjbGFzcz0iYmsiPjwvcmVjdD4KICAgIDxyZWN0IHg9JzQ2LjUnIHk9JzQwJyB3aWR0aD0nNycgaGVpZ2h0PScyMCcgcng9JzUnIHJ5PSc1JyBmaWxsPScjRTlFOUU5JwogICAgICAgICAgdHJhbnNmb3JtPSdyb3RhdGUoMCA1MCA1MCkgdHJhbnNsYXRlKDAgLTMwKSc+CiAgICA8L3JlY3Q+CiAgICA8cmVjdCB4PSc0Ni41JyB5PSc0MCcgd2lkdGg9JzcnIGhlaWdodD0nMjAnIHJ4PSc1JyByeT0nNScgZmlsbD0nIzk4OTY5NycKICAgICAgICAgIHRyYW5zZm9ybT0ncm90YXRlKDMwIDUwIDUwKSB0cmFuc2xhdGUoMCAtMzApJz4KICAgICAgICAgICAgICAgICByZXBlYXRDb3VudD0naW5kZWZpbml0ZScvPgogICAgPC9yZWN0PgogICAgPHJlY3QgeD0nNDYuNScgeT0nNDAnIHdpZHRoPSc3JyBoZWlnaHQ9JzIwJyByeD0nNScgcnk9JzUnIGZpbGw9JyM5Qjk5OUEnCiAgICAgICAgICB0cmFuc2Zvcm09J3JvdGF0ZSg2MCA1MCA1MCkgdHJhbnNsYXRlKDAgLTMwKSc+CiAgICAgICAgICAgICAgICAgcmVwZWF0Q291bnQ9J2luZGVmaW5pdGUnLz4KICAgIDwvcmVjdD4KICAgIDxyZWN0IHg9JzQ2LjUnIHk9JzQwJyB3aWR0aD0nNycgaGVpZ2h0PScyMCcgcng9JzUnIHJ5PSc1JyBmaWxsPScjQTNBMUEyJwogICAgICAgICAgdHJhbnNmb3JtPSdyb3RhdGUoOTAgNTAgNTApIHRyYW5zbGF0ZSgwIC0zMCknPgogICAgPC9yZWN0PgogICAgPHJlY3QgeD0nNDYuNScgeT0nNDAnIHdpZHRoPSc3JyBoZWlnaHQ9JzIwJyByeD0nNScgcnk9JzUnIGZpbGw9JyNBQkE5QUEnCiAgICAgICAgICB0cmFuc2Zvcm09J3JvdGF0ZSgxMjAgNTAgNTApIHRyYW5zbGF0ZSgwIC0zMCknPgogICAgPC9yZWN0PgogICAgPHJlY3QgeD0nNDYuNScgeT0nNDAnIHdpZHRoPSc3JyBoZWlnaHQ9JzIwJyByeD0nNScgcnk9JzUnIGZpbGw9JyNCMkIyQjInCiAgICAgICAgICB0cmFuc2Zvcm09J3JvdGF0ZSgxNTAgNTAgNTApIHRyYW5zbGF0ZSgwIC0zMCknPgogICAgPC9yZWN0PgogICAgPHJlY3QgeD0nNDYuNScgeT0nNDAnIHdpZHRoPSc3JyBoZWlnaHQ9JzIwJyByeD0nNScgcnk9JzUnIGZpbGw9JyNCQUI4QjknCiAgICAgICAgICB0cmFuc2Zvcm09J3JvdGF0ZSgxODAgNTAgNTApIHRyYW5zbGF0ZSgwIC0zMCknPgogICAgPC9yZWN0PgogICAgPHJlY3QgeD0nNDYuNScgeT0nNDAnIHdpZHRoPSc3JyBoZWlnaHQ9JzIwJyByeD0nNScgcnk9JzUnIGZpbGw9JyNDMkMwQzEnCiAgICAgICAgICB0cmFuc2Zvcm09J3JvdGF0ZSgyMTAgNTAgNTApIHRyYW5zbGF0ZSgwIC0zMCknPgogICAgPC9yZWN0PgogICAgPHJlY3QgeD0nNDYuNScgeT0nNDAnIHdpZHRoPSc3JyBoZWlnaHQ9JzIwJyByeD0nNScgcnk9JzUnIGZpbGw9JyNDQkNCQ0InCiAgICAgICAgICB0cmFuc2Zvcm09J3JvdGF0ZSgyNDAgNTAgNTApIHRyYW5zbGF0ZSgwIC0zMCknPgogICAgPC9yZWN0PgogICAgPHJlY3QgeD0nNDYuNScgeT0nNDAnIHdpZHRoPSc3JyBoZWlnaHQ9JzIwJyByeD0nNScgcnk9JzUnIGZpbGw9JyNEMkQyRDInCiAgICAgICAgICB0cmFuc2Zvcm09J3JvdGF0ZSgyNzAgNTAgNTApIHRyYW5zbGF0ZSgwIC0zMCknPgogICAgPC9yZWN0PgogICAgPHJlY3QgeD0nNDYuNScgeT0nNDAnIHdpZHRoPSc3JyBoZWlnaHQ9JzIwJyByeD0nNScgcnk9JzUnIGZpbGw9JyNEQURBREEnCiAgICAgICAgICB0cmFuc2Zvcm09J3JvdGF0ZSgzMDAgNTAgNTApIHRyYW5zbGF0ZSgwIC0zMCknPgogICAgPC9yZWN0PgogICAgPHJlY3QgeD0nNDYuNScgeT0nNDAnIHdpZHRoPSc3JyBoZWlnaHQ9JzIwJyByeD0nNScgcnk9JzUnIGZpbGw9JyNFMkUyRTInCiAgICAgICAgICB0cmFuc2Zvcm09J3JvdGF0ZSgzMzAgNTAgNTApIHRyYW5zbGF0ZSgwIC0zMCknPgogICAgPC9yZWN0Pgo8L3N2Zz4=') no-repeat
301
+ background-size: 100%
302
+ margin -0.2em 0.34em 0 0
303
+
304
+ @keyframes mpxButton
305
+ 0%
306
+ transform: rotate3d(0, 0, 1, 0deg)
307
+ 100%
308
+ transform: rotate3d(0, 0, 1, 360deg)
309
+ </style>
@@ -0,0 +1,66 @@
1
+ <script>
2
+ import { h } from "@hummer/tenon-vue";
3
+ import getInnerListeners from "./getInnerListeners";
4
+
5
+ export default {
6
+ name: "mpx-image",
7
+ props: {
8
+ src: {
9
+ type: String,
10
+ },
11
+ mode: {
12
+ type: String,
13
+ default: "scaleToFill",
14
+ },
15
+ lazyLoad: {
16
+ type: Boolean,
17
+ default: false,
18
+ },
19
+ showMenuByLongpress: {
20
+ type: Boolean,
21
+ default: false,
22
+ },
23
+ },
24
+ render() {
25
+ let resize = "";
26
+ switch (this.mode) {
27
+ case "scaleToFill":
28
+ resize = "stretch";
29
+ break;
30
+ case "aspectFit":
31
+ resize = "contain";
32
+ break;
33
+ case "aspectFill":
34
+ resize = "cover";
35
+ break;
36
+ default:
37
+ resize = "stretch";
38
+ }
39
+ return h("image", {
40
+ class: "mpx-image",
41
+ ref: "mpx-image",
42
+ src: this.src,
43
+ resize,
44
+ ...getInnerListeners(this)
45
+ });
46
+ },
47
+ computed: {
48
+ originRef() {
49
+ return this.$refs["mpx-image"]
50
+ }
51
+ },
52
+ data() {
53
+ return {};
54
+ },
55
+ pageConfig: {
56
+ canScroll: false,
57
+ },
58
+ methods: {
59
+ },
60
+ };
61
+ </script>
62
+ <style lang="stylus" scoped>
63
+ .mpx-image
64
+ width 300px
65
+ height 225px
66
+ </style>
@@ -0,0 +1,171 @@
1
+ <script>
2
+ import { h } from "@hummer/tenon-vue";
3
+ import getInnerListeners from "./getInnerListeners";
4
+ export default {
5
+ name: "mpx-input",
6
+ props: {
7
+ name: String,
8
+ value: {
9
+ type: String,
10
+ default: "",
11
+ },
12
+ type: {
13
+ type: String,
14
+ default: "text",
15
+ },
16
+ password: Boolean,
17
+ placeholder: String,
18
+ disabled: Boolean,
19
+ maxlength: {
20
+ type: Number,
21
+ default: 140,
22
+ },
23
+ autoFocus: Boolean,
24
+ focus: {
25
+ type: Boolean,
26
+ default: false,
27
+ },
28
+ cursor: {
29
+ type: Number,
30
+ default: -1,
31
+ },
32
+ selectionStart: {
33
+ type: Number,
34
+ default: -1,
35
+ },
36
+ selectionEnd: {
37
+ type: Number,
38
+ default: -1,
39
+ },
40
+ style: {
41
+ type: String,
42
+ default: '',
43
+ },
44
+ placeholderStyle: {
45
+ type: String,
46
+ default: '',
47
+ },
48
+ confirmType: {
49
+ type: String,
50
+ default: 'done',
51
+ }
52
+ },
53
+ computed: {
54
+ originRef() {
55
+ return this.$refs["mpx-input"]
56
+ },
57
+ computedStyle() {
58
+ let _inputWrapStyleObj = {
59
+ "font-size": "33hm",
60
+ height: "80hm",
61
+ "line-height": "80hm",
62
+ color: "#000000",
63
+ border: "1hm solid #999999",
64
+ "border-radius": "8hm",
65
+ "text-align": "left",
66
+ "background-color": "#ffffff"
67
+ };
68
+
69
+ if (typeof this.style !== 'string') {
70
+ console.warn('Runtime warning: PROPS style must be string')
71
+ }
72
+
73
+ let _styleObj = {};
74
+
75
+ if (typeof this.style === 'string') {
76
+ let _style = this.style;
77
+
78
+ if (_style[_style.length - 1] !== ";") {
79
+ _style += ";";
80
+ }
81
+
82
+ _style.split(";").map(item => {
83
+ if (item) {
84
+ let itemArray = item.split(":");
85
+ _styleObj[itemArray[0]] = itemArray[1];
86
+ }
87
+ });
88
+ }
89
+
90
+ //HACK: tenon会存在读到this.style为封装标签的样式 @曹恩泽
91
+ if (typeof this.style === 'object') {
92
+ _styleObj = Object.assign({}, _styleObj, this.style)
93
+ }
94
+
95
+ let styleObj = Object.assign({}, _inputWrapStyleObj, _styleObj);
96
+ let style = Object.keys(styleObj)
97
+ .map(k => `${k}:${styleObj[k]}`)
98
+ .join(";");
99
+
100
+ //Tenon变更placeholderColor
101
+ const regex = /color/i
102
+ style += this.placeholderStyle.replace(regex, 'placeholderColor');
103
+ return style;
104
+ },
105
+ },
106
+ watch: {
107
+ value: function (newVal, oldVal) {
108
+ console.log(newVal)
109
+ if (this.originRef && newVal !== this.originRef.value) {
110
+ this.originRef.value = newVal;
111
+ }
112
+ }
113
+ },
114
+ render() {
115
+ let inputType = "";
116
+ if (this.password) {
117
+ inputType = "password";
118
+ } else {
119
+ switch (this.type) {
120
+ case "text":
121
+ inputType = "default";
122
+ break;
123
+ case "number":
124
+ inputType = "number";
125
+ break;
126
+ case "tel":
127
+ inputType = "tel";
128
+ break;
129
+ default:
130
+ inputType = "text";
131
+ }
132
+ }
133
+
134
+ const data = {
135
+ class: "mpx-input",
136
+ focused: this.focus,
137
+ ref: "mpx-input",
138
+ placeholder: this.placeholder,
139
+ maxLength: this.maxlength,
140
+ type: inputType,
141
+ disabled: this.disabled,
142
+ style: this.computedStyle,
143
+ returnKeyType: this.confirmType,
144
+ value: this.value,
145
+ ...getInnerListeners(this, { _input: true }),
146
+ };
147
+ return h("input", data, []);
148
+ },
149
+ data() {
150
+ return {};
151
+ },
152
+ pageConfig: {
153
+ canScroll: false,
154
+ },
155
+ methods: {},
156
+ };
157
+ </script>
158
+ <style lang="stylus" scoped>
159
+ .mpx-input
160
+ cursor auto
161
+ width 100%
162
+ padding 0
163
+ border 0
164
+ font inherit
165
+ display block
166
+ text-overflow clip
167
+ overflow hidden
168
+ white-space nowrap
169
+ font-family UICTFontTextStyleBody
170
+
171
+ </style>
@@ -0,0 +1,26 @@
1
+ <script>
2
+ import getInnerListeners from './getInnerListeners'
3
+ import { h } from '@hummer/tenon-vue'
4
+ export default {
5
+ name: 'mpx-rich-text',
6
+ props: {
7
+ richText: {
8
+ type: Object,
9
+ value: {}
10
+ }
11
+ },
12
+ computed: {
13
+ originRef() {
14
+ return this.$refs["mpx-richtext"]
15
+ }
16
+ },
17
+ render () {
18
+ const data = {
19
+ richText: this.richText,
20
+ ref: "mpx-richtext",
21
+ ...getInnerListeners(this)
22
+ }
23
+ return h('text', data)
24
+ }
25
+ }
26
+ </script>
@@ -0,0 +1,127 @@
1
+ <script>
2
+ import getInnerListeners from "./getInnerListeners";
3
+ import { processSize } from '../../utils';
4
+ import { h } from "@hummer/tenon-vue";
5
+ export default {
6
+ name: "mpx-scroll-view",
7
+ props: {
8
+ // 允许横向滚动
9
+ scrollX: Boolean,
10
+ // 允许纵向滚动
11
+ scrollY: Boolean,
12
+ // 滚动方向-默认竖向滚动
13
+ scrollDirection: {
14
+ type: String,
15
+ default: "vertical",
16
+ },
17
+ // 距顶部/左边多远时,触发 scrolltoupper 事件
18
+ upperThreshold: {
19
+ type: [Number, String],
20
+ default: 50,
21
+ },
22
+ // 距底部/右边多远时,触发 scrolltolower 事件
23
+ lowerThreshold: {
24
+ type: [Number, String],
25
+ default: 50,
26
+ },
27
+ // 设置竖向滚动条位置
28
+ scrollTop: {
29
+ type: [Number, String],
30
+ default: 0,
31
+ },
32
+ // 设置横向滚动条位置
33
+ scrollLeft: {
34
+ type: [Number, String],
35
+ default: 0,
36
+ },
37
+ scrollOptions: Object,
38
+ // 更新refresh
39
+ updateRefresh: {
40
+ type: Boolean,
41
+ default: true,
42
+ },
43
+ // 值应为某子元素id(id不能以数字开头)。设置哪个方向可滚动,则在哪个方向滚动到该元素
44
+ scrollIntoView: String,
45
+ // 在设置滚动条位置时使用动画过渡
46
+ scrollWithAnimation: Boolean,
47
+ // 启用 flexbox 布局。开启后,当前节点声明了 display: flex 就会成为 flex container,并作用于其孩子节点。
48
+ enableFlex: Boolean,
49
+ // 启用 scroll-view 增强特性,启用后可通过 ScrollViewContext 操作 scroll-view
50
+ enhanced: Boolean,
51
+ // 开启自定义下拉刷新
52
+ refresherEnabled: Boolean,
53
+ // 设置当前下拉刷新状态,true 表示下拉刷新已经被触发,false 表示下拉刷新未被触发
54
+ refresherTriggered: Boolean,
55
+ // 设置自定义下拉刷新阈值
56
+ refresherThreshold: {
57
+ type: Number,
58
+ default: 45,
59
+ },
60
+ // 设置自定义下拉刷新默认样式,支持设置 black | white | none, none 表示不使用默认样式
61
+ refresherDefaultStyle: {
62
+ type: String,
63
+ default: "black",
64
+ },
65
+ // 设置自定义下拉刷新区域背景颜色
66
+ refresherBackground: {
67
+ type: String,
68
+ default: "",
69
+ },
70
+ },
71
+ data() {
72
+ return {};
73
+ },
74
+ computed: {
75
+ originRef() {
76
+ return this.$refs["scroll"]
77
+ },
78
+ _scrollTop() {
79
+ // return 1
80
+ return processSize(this.scrollTop);
81
+ },
82
+ _scrollLeft() {
83
+ // return 1
84
+ return processSize(this.scrollLeft);
85
+ },
86
+ },
87
+ mounted() {
88
+ if (this.scrollTop) {
89
+ setTimeout(() => {
90
+ this.$refs.scroll && this.$refs.scroll.scrollTo(0, this._scrollTop);
91
+ }, 100);
92
+
93
+ }
94
+ if (this.scrollLeft) {
95
+ setTimeout(() => {
96
+ this.$refs.scroll && this.$refs.scroll.scrollTo(this._scrollLeft, 0);
97
+ }, 100);
98
+ }
99
+ },
100
+ watch: {
101
+ _scrollTop(val) {
102
+ console.log('触发')
103
+ this.$refs.scroll && this.$refs.scroll.scrollTo(0, val);
104
+ },
105
+ _scrollLeft(val) {
106
+ this.$refs.scroll && this.$refs.scroll.scrollTo(val, 0);
107
+ },
108
+ },
109
+ methods: {},
110
+ render() {
111
+ let scrollDirection = this.scrollDirection;
112
+ if (!this.scrollY && this.scrollX) {
113
+ scrollDirection = "horizontal";
114
+ }
115
+ return h(
116
+ "scroller",
117
+ {
118
+ ref: "scroll",
119
+ scrollDirection,
120
+ showScrollBar: false,
121
+ ...getInnerListeners(this, {})
122
+ },
123
+ this.$slots.default()
124
+ );
125
+ },
126
+ };
127
+ </script>