@mpxjs/webpack-plugin 2.8.25-alpha.13 → 2.8.25-alpha.15
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.
|
@@ -61,9 +61,9 @@ function createTouch (context, hasLongTap, __mpxTapInfo) {
|
|
|
61
61
|
})
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
function processOriginEvent (listeners) {
|
|
64
|
+
function processOriginEvent (listeners, context, _input) {
|
|
65
65
|
// 给event添加_originEvent属性
|
|
66
|
-
const ignoreEvents = ['onTap', 'onFocus', 'onChange', 'onBlur', 'onConfirm']
|
|
66
|
+
const ignoreEvents = ['onTap', 'onFocus', 'onChange', 'onBlur', 'onConfirm', 'onInput']
|
|
67
67
|
Object.keys(listeners).forEach((key) => {
|
|
68
68
|
if (!ignoreEvents.includes(key)) {
|
|
69
69
|
const listener = listeners[key]
|
|
@@ -75,14 +75,32 @@ function processOriginEvent (listeners) {
|
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
})
|
|
78
|
+
|
|
79
|
+
// 处理input输入框事件
|
|
80
|
+
if (listeners.onInput && _input) {
|
|
81
|
+
delete listeners.onInput
|
|
82
|
+
listeners.onInput = function (e) {
|
|
83
|
+
let _type
|
|
84
|
+
const { state } = e || {}
|
|
85
|
+
if (state === 1) {
|
|
86
|
+
_type = 'focus'
|
|
87
|
+
} else if (state === 2) {
|
|
88
|
+
_type = 'focus'
|
|
89
|
+
} else if (state === 3) {
|
|
90
|
+
_type = 'blur'
|
|
91
|
+
} else {
|
|
92
|
+
_type = 'confirm'
|
|
93
|
+
}
|
|
94
|
+
context.$emit(_type, { ...e, detail: e })
|
|
95
|
+
}
|
|
96
|
+
}
|
|
78
97
|
}
|
|
79
98
|
|
|
80
|
-
function processModel (listeners, context) {
|
|
99
|
+
function processModel (listeners, context, _input = false) {
|
|
81
100
|
// 该函数只有wx:model的情况下才调用,而且默认e.detail.value有值
|
|
82
101
|
// 该函数必须在产生merge前执行
|
|
83
102
|
// todo 此处对于$attrs的访问会导致父组件更新时子组件必然更新,暂时用短路效应避免影响,待优化
|
|
84
103
|
// todo 访问$listeners也会导致上述现象,但是为了事件代理还必须访问$listeners,待后续思考处理
|
|
85
|
-
|
|
86
104
|
const modelEvent = context.$attrs.mpxModelEvent
|
|
87
105
|
const modelEventId = context.$attrs.mpxModelEventId
|
|
88
106
|
if (modelEvent && modelEventId) {
|
|
@@ -278,11 +296,13 @@ export default function getInnerListeners (context, options = {}) {
|
|
|
278
296
|
mergeBefore = {},
|
|
279
297
|
mergeAfter = {},
|
|
280
298
|
defaultListeners = [],
|
|
281
|
-
ignoredListeners = []
|
|
299
|
+
ignoredListeners = [],
|
|
300
|
+
_input = false
|
|
282
301
|
} = options
|
|
283
302
|
const __mpxTapInfo = {}
|
|
284
303
|
// 从attrs里面拿到以on开头的所有绑定的事件
|
|
285
304
|
const listeners = Object.assign({}, getListeners(context))
|
|
305
|
+
|
|
286
306
|
defaultListeners.forEach((key) => {
|
|
287
307
|
if (!listeners[key]) listeners[key] = noop
|
|
288
308
|
})
|
|
@@ -302,8 +322,8 @@ export default function getInnerListeners (context, options = {}) {
|
|
|
302
322
|
mergeAfterOptions.force = mergeAfter.force
|
|
303
323
|
mergeAfter = mergeAfter.listeners
|
|
304
324
|
}
|
|
305
|
-
processOriginEvent(listeners)
|
|
306
|
-
processModel(listeners, context)
|
|
325
|
+
processOriginEvent(listeners, context, _input)
|
|
326
|
+
processModel(listeners, context, _input)
|
|
307
327
|
processTouchAndLtap(listeners, context, __mpxTapInfo)
|
|
308
328
|
mergeListeners(listeners, mergeBefore, mergeBeforeOptions, context, __mpxTapInfo)
|
|
309
329
|
mergeListeners(listeners, mergeAfter, mergeAfterOptions, context, __mpxTapInfo)
|
|
@@ -37,15 +37,76 @@ export default {
|
|
|
37
37
|
type: Number,
|
|
38
38
|
default: -1,
|
|
39
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
|
+
}
|
|
40
52
|
},
|
|
41
53
|
computed: {
|
|
42
54
|
originRef() {
|
|
43
55
|
return this.$refs["mpx-input"]
|
|
44
|
-
}
|
|
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
|
+
},
|
|
45
105
|
},
|
|
46
106
|
watch: {
|
|
47
|
-
value: function(newVal, oldVal) {
|
|
48
|
-
|
|
107
|
+
value: function (newVal, oldVal) {
|
|
108
|
+
console.log(newVal)
|
|
109
|
+
if (this.originRef && newVal !== this.originRef.value) {
|
|
49
110
|
this.originRef.value = newVal;
|
|
50
111
|
}
|
|
51
112
|
}
|
|
@@ -62,6 +123,9 @@ export default {
|
|
|
62
123
|
case "number":
|
|
63
124
|
inputType = "number";
|
|
64
125
|
break;
|
|
126
|
+
case "tel":
|
|
127
|
+
inputType = "tel";
|
|
128
|
+
break;
|
|
65
129
|
default:
|
|
66
130
|
inputType = "text";
|
|
67
131
|
}
|
|
@@ -69,13 +133,15 @@ export default {
|
|
|
69
133
|
|
|
70
134
|
const data = {
|
|
71
135
|
class: "mpx-input",
|
|
72
|
-
|
|
136
|
+
focused: this.focus,
|
|
73
137
|
ref: "mpx-input",
|
|
74
138
|
placeholder: this.placeholder,
|
|
75
|
-
maxLength: this.
|
|
139
|
+
maxLength: this.maxlength,
|
|
76
140
|
type: inputType,
|
|
77
141
|
disabled: this.disabled,
|
|
78
|
-
|
|
142
|
+
style: this.computedStyle,
|
|
143
|
+
returnKeyType: this.confirmType,
|
|
144
|
+
...getInnerListeners(this, { _input: true }),
|
|
79
145
|
};
|
|
80
146
|
return h("input", data, []);
|
|
81
147
|
},
|
|
@@ -31,6 +31,14 @@ export default {
|
|
|
31
31
|
type: Number,
|
|
32
32
|
default: -1,
|
|
33
33
|
},
|
|
34
|
+
placeholderStyle: {
|
|
35
|
+
type: String,
|
|
36
|
+
default: '',
|
|
37
|
+
},
|
|
38
|
+
confirmType: {
|
|
39
|
+
type: String,
|
|
40
|
+
default: 'return',
|
|
41
|
+
}
|
|
34
42
|
},
|
|
35
43
|
computed: {
|
|
36
44
|
originRef() {
|
|
@@ -50,9 +58,11 @@ export default {
|
|
|
50
58
|
class: "mpx-textarea",
|
|
51
59
|
ref: "mpx-textarea",
|
|
52
60
|
focus: this.focus,
|
|
61
|
+
value: this.value,
|
|
53
62
|
placeholder: this.placeholder,
|
|
54
|
-
maxLength: this.
|
|
63
|
+
maxLength: this.maxlength,
|
|
55
64
|
disabled: this.disabled,
|
|
65
|
+
returnKeyType: this.confirmType,
|
|
56
66
|
...getInnerListeners(this),
|
|
57
67
|
};
|
|
58
68
|
return h("textarea", data);
|
|
@@ -4,7 +4,8 @@ const coreVersion = require('@mpxjs/core/package.json').version
|
|
|
4
4
|
const packageName = require('../../package.json').name
|
|
5
5
|
const packageVersion = require('../../package.json').version
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
// skip check prerelease version
|
|
8
|
+
if (!/-\w+$/.test(packageVersion) && packageVersion.slice(0, 3) !== coreVersion.slice(0, 3)) {
|
|
8
9
|
const corePath = require.resolve('@mpxjs/core')
|
|
9
10
|
const packagePath = require.resolve('../../package.json')
|
|
10
11
|
throw new Error(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mpxjs/webpack-plugin",
|
|
3
|
-
"version": "2.8.25-alpha.
|
|
3
|
+
"version": "2.8.25-alpha.15",
|
|
4
4
|
"description": "mpx compile core",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mpx"
|
|
@@ -85,5 +85,5 @@
|
|
|
85
85
|
"engines": {
|
|
86
86
|
"node": ">=14.14.0"
|
|
87
87
|
},
|
|
88
|
-
"gitHead": "
|
|
88
|
+
"gitHead": "76f3ab2ed024078afc89c48e9e009426ba866156"
|
|
89
89
|
}
|