@dolphinweex/weex-vue-render 0.2.64 → 0.2.66
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.common.js +78 -30
- package/package.json +1 -1
package/dist/index.common.js
CHANGED
|
@@ -2918,22 +2918,54 @@ function dispatchNativeEvent (elm, type, data) {
|
|
|
2918
2918
|
function mapFormEvents (context) {
|
|
2919
2919
|
var eventMap = {};['input', 'change', 'focus', 'blur', 'return'].forEach(function (type) {
|
|
2920
2920
|
eventMap[type] = function (event) {
|
|
2921
|
-
if (context.$el) {
|
|
2922
|
-
|
|
2923
|
-
|
|
2924
|
-
|
|
2921
|
+
if (!context.$el) { return }
|
|
2922
|
+
var isNumberType = context.type === 'number';
|
|
2923
|
+
// 在 number 模式下,聚焦时改为 text,允许输入临时态(比如以 . 结尾)
|
|
2924
|
+
if (isNumberType && type === 'focus') {
|
|
2925
|
+
context._editingNumberAsText = true;
|
|
2926
|
+
try { context.$el.setAttribute('type', 'text'); } catch (e) {}
|
|
2927
|
+
}
|
|
2928
|
+
if (type === 'input') {
|
|
2929
|
+
var currentValue = context.$el.value == null ? '' : String(context.$el.value);
|
|
2930
|
+
if (isNumberType && context._editingNumberAsText) {
|
|
2931
|
+
var filtered = currentValue.replace(/[^\d.\-]/g, '');
|
|
2932
|
+
// 只保留第一个小数点
|
|
2933
|
+
var dotParts = filtered.split('.');
|
|
2934
|
+
if (dotParts.length > 2) {
|
|
2935
|
+
filtered = dotParts.shift() + '.' + dotParts.join('');
|
|
2925
2936
|
}
|
|
2926
|
-
context
|
|
2937
|
+
if (context.maxlength && String(filtered).length > context.maxlength) {
|
|
2938
|
+
filtered = String(filtered).slice(0, context.maxlength);
|
|
2939
|
+
}
|
|
2940
|
+
context.$el.value = filtered;
|
|
2941
|
+
context._editingDisplayValue = filtered;
|
|
2942
|
+
event.value = filtered;
|
|
2943
|
+
} else {
|
|
2944
|
+
var result = currentValue;
|
|
2945
|
+
if (context.maxlength && String(result).length > context.maxlength) {
|
|
2946
|
+
result = String(result).slice(0, context.maxlength);
|
|
2947
|
+
}
|
|
2948
|
+
context.$el.value = result;
|
|
2949
|
+
event.value = result;
|
|
2927
2950
|
}
|
|
2928
|
-
|
|
2929
|
-
|
|
2951
|
+
context.$emit('input', event);
|
|
2952
|
+
return;
|
|
2953
|
+
}
|
|
2954
|
+
|
|
2955
|
+
// blur/change/return 时,若类型为 number,则清理尾部点并切回 number 类型
|
|
2956
|
+
if (isNumberType && (type === 'blur' || type === 'change' || type === 'return')) {
|
|
2957
|
+
var val = context.$el.value == null ? '' : String(context.$el.value);
|
|
2958
|
+
if (val && val[val.length - 1] === '.') {
|
|
2959
|
+
val = val.slice(0, -1);
|
|
2930
2960
|
}
|
|
2931
|
-
context
|
|
2932
|
-
|
|
2933
|
-
// for the sake of v-model, a input event must be emitted.
|
|
2934
|
-
if (type === 'input') {
|
|
2935
|
-
context.$emit(type, event);
|
|
2961
|
+
if (context.maxlength && String(val).length > context.maxlength) {
|
|
2962
|
+
val = String(val).slice(0, context.maxlength);
|
|
2936
2963
|
}
|
|
2964
|
+
try { context.$el.setAttribute('type', 'number'); } catch (e) {}
|
|
2965
|
+
context._editingNumberAsText = false;
|
|
2966
|
+
context._editingDisplayValue = undefined;
|
|
2967
|
+
context.$el.value = val;
|
|
2968
|
+
event.value = val;
|
|
2937
2969
|
}
|
|
2938
2970
|
};
|
|
2939
2971
|
});
|
|
@@ -3867,13 +3899,19 @@ function px2rem (px, rootValue = 75) {
|
|
|
3867
3899
|
// fix: 适配鸿蒙wx单位
|
|
3868
3900
|
if (px.indexOf("--harmory") > -1) return px;
|
|
3869
3901
|
|
|
3870
|
-
return px.replace(/([+-]?\d+(?:\.\d*)?)([p|w]x)?/g, function ($0, $1, $2, offset, str) {
|
|
3902
|
+
return px.replace(/([+-]?\d+(?:\.\d*)?)([p|w]x|%)?/g, function ($0, $1, $2, offset, str) {
|
|
3871
3903
|
// 判断是否包含 scale 或 rotate,直接跳过
|
|
3872
3904
|
const filterKey = ['scale', 'rotate'];
|
|
3873
3905
|
if (filterKey.some(keyword => str.slice(0, offset).includes(keyword))) {
|
|
3874
3906
|
return $0; // 保留原字符串不替换
|
|
3875
3907
|
}
|
|
3876
|
-
if (ignoreSubKey.filter(k => str.slice(offset - k.length - 1, offset - 1) === k).length) return $1
|
|
3908
|
+
if (ignoreSubKey.filter(k => str.slice(offset - k.length - 1, offset - 1) === k).length) return $1
|
|
3909
|
+
|
|
3910
|
+
// 如果是百分比单位,直接返回原值不做转换
|
|
3911
|
+
if ($2 === '%') {
|
|
3912
|
+
return $0; // 保留原字符串 translateY(0%)
|
|
3913
|
+
}
|
|
3914
|
+
|
|
3877
3915
|
if ($2 === 'wx') { // 'wx' -> px
|
|
3878
3916
|
// return ($midea_harmony_native ? $midea_harmony_native.vp2px($1) : $1) + 'px'
|
|
3879
3917
|
// 适配鸿蒙wx
|
|
@@ -5506,25 +5544,16 @@ function setPlaceholderColor (inputVm, placeholderColor) {
|
|
|
5506
5544
|
if (!placeholderColor) {
|
|
5507
5545
|
return
|
|
5508
5546
|
}
|
|
5509
|
-
var vendors = [
|
|
5510
|
-
'::-webkit-input-placeholder',
|
|
5511
|
-
':-moz-placeholder',
|
|
5512
|
-
'::-moz-placeholder',
|
|
5513
|
-
':-ms-input-placeholder',
|
|
5514
|
-
':placeholder-shown'
|
|
5515
|
-
];
|
|
5516
5547
|
var id = inputVm._id;
|
|
5517
5548
|
appendCss$1(
|
|
5518
|
-
|
|
5519
|
-
return ("#" + ID_PREFIX_INPUT + id + (vendors[idx]) + "{color:" + placeholderColor + ";}")
|
|
5520
|
-
}).join(''),
|
|
5549
|
+
("#" + ID_PREFIX_INPUT + id + "::placeholder{color:" + placeholderColor + ";opacity:1;}"),
|
|
5521
5550
|
("" + ID_PREFIX_PLACEHOLDER_COLOR + id),
|
|
5522
5551
|
true);
|
|
5523
5552
|
}
|
|
5524
5553
|
|
|
5525
5554
|
function processStyle (vm) {
|
|
5526
5555
|
var styles = getComponentInlineStyle(vm);
|
|
5527
|
-
var phColor = styles.placeholderColor || styles['placeholder-color'];
|
|
5556
|
+
var phColor = styles.placeholderColor || styles['placeholder-color'] || vm.placeholderColor;
|
|
5528
5557
|
if (phColor) {
|
|
5529
5558
|
setPlaceholderColor(vm, phColor);
|
|
5530
5559
|
}
|
|
@@ -5559,7 +5588,8 @@ function getInput (weex) {
|
|
|
5559
5588
|
default: false
|
|
5560
5589
|
},
|
|
5561
5590
|
maxlength: [String, Number],
|
|
5562
|
-
returnKeyType: String
|
|
5591
|
+
returnKeyType: String,
|
|
5592
|
+
placeholderColor: String
|
|
5563
5593
|
},
|
|
5564
5594
|
|
|
5565
5595
|
mounted: function mounted () {
|
|
@@ -5574,6 +5604,9 @@ function getInput (weex) {
|
|
|
5574
5604
|
this.focus(val)
|
|
5575
5605
|
}
|
|
5576
5606
|
},
|
|
5607
|
+
placeholderColor: function placeholderColor(val) {
|
|
5608
|
+
setPlaceholderColor(this, val)
|
|
5609
|
+
}
|
|
5577
5610
|
},
|
|
5578
5611
|
|
|
5579
5612
|
render: function render (createElement) {
|
|
@@ -5581,12 +5614,18 @@ function getInput (weex) {
|
|
|
5581
5614
|
this._id = idCount++;
|
|
5582
5615
|
}
|
|
5583
5616
|
var events = extend(mapFormEvents(this));
|
|
5617
|
+
var isNumberType = this.type === 'number';
|
|
5618
|
+
var isEditingAsText = !!this._editingNumberAsText;
|
|
5619
|
+
var inputTypeAttr = isNumberType && isEditingAsText ? 'text' : this.type;
|
|
5620
|
+
var displayValue = isNumberType && isEditingAsText && this._editingDisplayValue !== undefined
|
|
5621
|
+
? this._editingDisplayValue
|
|
5622
|
+
: this.value;
|
|
5584
5623
|
return createElement('html:input', {
|
|
5585
5624
|
attrs: {
|
|
5586
5625
|
'weex-type': 'input',
|
|
5587
5626
|
id: ("" + ID_PREFIX_INPUT + (this._id)),
|
|
5588
|
-
type:
|
|
5589
|
-
value:
|
|
5627
|
+
type: inputTypeAttr,
|
|
5628
|
+
value: displayValue,
|
|
5590
5629
|
disabled: (this.disabled !== 'false' && this.disabled !== false),
|
|
5591
5630
|
autofocus: (this.autofocus !== 'false' && this.autofocus !== false),
|
|
5592
5631
|
placeholder: this.placeholder,
|
|
@@ -5594,7 +5633,7 @@ function getInput (weex) {
|
|
|
5594
5633
|
'returnKeyType': this.returnKeyType
|
|
5595
5634
|
},
|
|
5596
5635
|
domProps: {
|
|
5597
|
-
value:
|
|
5636
|
+
value: displayValue
|
|
5598
5637
|
},
|
|
5599
5638
|
on: this.createKeyboardEvent(events),
|
|
5600
5639
|
staticClass: 'weex-input weex-el',
|
|
@@ -6642,6 +6681,14 @@ function getScroller (weex) {
|
|
|
6642
6681
|
staticClass: 'weex-scroller-inner weex-ct'
|
|
6643
6682
|
}, cellsWithScopeIds)
|
|
6644
6683
|
]
|
|
6684
|
+
},
|
|
6685
|
+
_handleScrollWrapper: function _handleScrollWrapper (event) {
|
|
6686
|
+
weex.isWebScrolling = true
|
|
6687
|
+
if (this._restorePointerEventsTimer) { clearTimeout(this._restorePointerEventsTimer); }
|
|
6688
|
+
this._restorePointerEventsTimer = setTimeout(function () {
|
|
6689
|
+
weex.isWebScrolling = false
|
|
6690
|
+
}, 120);
|
|
6691
|
+
return this.handleScroll(event)
|
|
6645
6692
|
}
|
|
6646
6693
|
},
|
|
6647
6694
|
|
|
@@ -6664,7 +6711,7 @@ function getScroller (weex) {
|
|
|
6664
6711
|
ref: 'wrapper',
|
|
6665
6712
|
attrs: { 'weex-type': 'scroller' },
|
|
6666
6713
|
on: {
|
|
6667
|
-
scroll: this.
|
|
6714
|
+
scroll: this._handleScrollWrapper,
|
|
6668
6715
|
touchstart: this.handleTouchStart,
|
|
6669
6716
|
touchmove: this.handleTouchMove.bind(this),
|
|
6670
6717
|
touchend: this.handleTouchEnd
|
|
@@ -7926,6 +7973,7 @@ var slideMixin = {
|
|
|
7926
7973
|
var rect = wrapper.getBoundingClientRect();
|
|
7927
7974
|
this._wrapperWidth = rect.width;
|
|
7928
7975
|
this._wrapperHeight = rect.height;
|
|
7976
|
+
this.maxHeight = react.height;
|
|
7929
7977
|
}
|
|
7930
7978
|
},
|
|
7931
7979
|
|
package/package.json
CHANGED