@dolphinweex/weex-vue-render 0.2.63 → 0.2.65
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 +95 -34
- 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
|
});
|
|
@@ -5506,25 +5538,16 @@ function setPlaceholderColor (inputVm, placeholderColor) {
|
|
|
5506
5538
|
if (!placeholderColor) {
|
|
5507
5539
|
return
|
|
5508
5540
|
}
|
|
5509
|
-
var vendors = [
|
|
5510
|
-
'::-webkit-input-placeholder',
|
|
5511
|
-
':-moz-placeholder',
|
|
5512
|
-
'::-moz-placeholder',
|
|
5513
|
-
':-ms-input-placeholder',
|
|
5514
|
-
':placeholder-shown'
|
|
5515
|
-
];
|
|
5516
5541
|
var id = inputVm._id;
|
|
5517
5542
|
appendCss$1(
|
|
5518
|
-
|
|
5519
|
-
return ("#" + ID_PREFIX_INPUT + id + (vendors[idx]) + "{color:" + placeholderColor + ";}")
|
|
5520
|
-
}).join(''),
|
|
5543
|
+
("#" + ID_PREFIX_INPUT + id + "::placeholder{color:" + placeholderColor + ";opacity:1;}"),
|
|
5521
5544
|
("" + ID_PREFIX_PLACEHOLDER_COLOR + id),
|
|
5522
5545
|
true);
|
|
5523
5546
|
}
|
|
5524
5547
|
|
|
5525
5548
|
function processStyle (vm) {
|
|
5526
5549
|
var styles = getComponentInlineStyle(vm);
|
|
5527
|
-
var phColor = styles.placeholderColor || styles['placeholder-color'];
|
|
5550
|
+
var phColor = styles.placeholderColor || styles['placeholder-color'] || vm.placeholderColor;
|
|
5528
5551
|
if (phColor) {
|
|
5529
5552
|
setPlaceholderColor(vm, phColor);
|
|
5530
5553
|
}
|
|
@@ -5559,7 +5582,8 @@ function getInput (weex) {
|
|
|
5559
5582
|
default: false
|
|
5560
5583
|
},
|
|
5561
5584
|
maxlength: [String, Number],
|
|
5562
|
-
returnKeyType: String
|
|
5585
|
+
returnKeyType: String,
|
|
5586
|
+
placeholderColor: String
|
|
5563
5587
|
},
|
|
5564
5588
|
|
|
5565
5589
|
mounted: function mounted () {
|
|
@@ -5574,6 +5598,9 @@ function getInput (weex) {
|
|
|
5574
5598
|
this.focus(val)
|
|
5575
5599
|
}
|
|
5576
5600
|
},
|
|
5601
|
+
placeholderColor: function placeholderColor(val) {
|
|
5602
|
+
setPlaceholderColor(this, val)
|
|
5603
|
+
}
|
|
5577
5604
|
},
|
|
5578
5605
|
|
|
5579
5606
|
render: function render (createElement) {
|
|
@@ -5581,12 +5608,18 @@ function getInput (weex) {
|
|
|
5581
5608
|
this._id = idCount++;
|
|
5582
5609
|
}
|
|
5583
5610
|
var events = extend(mapFormEvents(this));
|
|
5611
|
+
var isNumberType = this.type === 'number';
|
|
5612
|
+
var isEditingAsText = !!this._editingNumberAsText;
|
|
5613
|
+
var inputTypeAttr = isNumberType && isEditingAsText ? 'text' : this.type;
|
|
5614
|
+
var displayValue = isNumberType && isEditingAsText && this._editingDisplayValue !== undefined
|
|
5615
|
+
? this._editingDisplayValue
|
|
5616
|
+
: this.value;
|
|
5584
5617
|
return createElement('html:input', {
|
|
5585
5618
|
attrs: {
|
|
5586
5619
|
'weex-type': 'input',
|
|
5587
5620
|
id: ("" + ID_PREFIX_INPUT + (this._id)),
|
|
5588
|
-
type:
|
|
5589
|
-
value:
|
|
5621
|
+
type: inputTypeAttr,
|
|
5622
|
+
value: displayValue,
|
|
5590
5623
|
disabled: (this.disabled !== 'false' && this.disabled !== false),
|
|
5591
5624
|
autofocus: (this.autofocus !== 'false' && this.autofocus !== false),
|
|
5592
5625
|
placeholder: this.placeholder,
|
|
@@ -5594,7 +5627,7 @@ function getInput (weex) {
|
|
|
5594
5627
|
'returnKeyType': this.returnKeyType
|
|
5595
5628
|
},
|
|
5596
5629
|
domProps: {
|
|
5597
|
-
value:
|
|
5630
|
+
value: displayValue
|
|
5598
5631
|
},
|
|
5599
5632
|
on: this.createKeyboardEvent(events),
|
|
5600
5633
|
staticClass: 'weex-input weex-el',
|
|
@@ -5647,6 +5680,15 @@ function getImage(weex) {
|
|
|
5647
5680
|
},
|
|
5648
5681
|
methods: {
|
|
5649
5682
|
loadImage: function loadImage() {
|
|
5683
|
+
// 检查src是否有效
|
|
5684
|
+
if (!this.src || this.src === 'undefined' || this.src === '') {
|
|
5685
|
+
this.$emit("error", {
|
|
5686
|
+
success: false,
|
|
5687
|
+
message: 'Invalid image source'
|
|
5688
|
+
});
|
|
5689
|
+
return;
|
|
5690
|
+
}
|
|
5691
|
+
|
|
5650
5692
|
const img = new Image();
|
|
5651
5693
|
img.src = this.src;
|
|
5652
5694
|
img.onload = (event) => {
|
|
@@ -5663,6 +5705,7 @@ function getImage(weex) {
|
|
|
5663
5705
|
// 触发error事件并传递参数
|
|
5664
5706
|
this.$emit("error", {
|
|
5665
5707
|
success: false,
|
|
5708
|
+
message: 'Failed to load image: ' + this.src
|
|
5666
5709
|
});
|
|
5667
5710
|
};
|
|
5668
5711
|
},
|
|
@@ -5720,9 +5763,9 @@ function getImage(weex) {
|
|
|
5720
5763
|
}
|
|
5721
5764
|
let processedAppendStr = appendStr;
|
|
5722
5765
|
|
|
5723
|
-
|
|
5724
|
-
|
|
5725
|
-
|
|
5766
|
+
if (/^[a-zA-Z]/i.test(appendStr) && appendStr.includes("/")) {
|
|
5767
|
+
return path + appendStr; // 直接返回绝对路径
|
|
5768
|
+
}
|
|
5726
5769
|
if (processedAppendStr.startsWith("/")) {
|
|
5727
5770
|
return path + appendStr;
|
|
5728
5771
|
}
|
|
@@ -5756,9 +5799,18 @@ function getImage(weex) {
|
|
|
5756
5799
|
return path + processedAppendStr;
|
|
5757
5800
|
},
|
|
5758
5801
|
checkTrim(url) {
|
|
5759
|
-
|
|
5760
|
-
|
|
5761
|
-
|
|
5802
|
+
try{
|
|
5803
|
+
// 检查URL是否有效
|
|
5804
|
+
if (!url || url === 'undefined') {
|
|
5805
|
+
return '';
|
|
5806
|
+
}
|
|
5807
|
+
if (url.includes(' ')) {
|
|
5808
|
+
const parts = url.replace(/\s/g, match => encodeURIComponent(match));
|
|
5809
|
+
return parts
|
|
5810
|
+
}
|
|
5811
|
+
}catch(e){
|
|
5812
|
+
// 静默处理错误,返回空字符串
|
|
5813
|
+
return '';
|
|
5762
5814
|
}
|
|
5763
5815
|
return url
|
|
5764
5816
|
},
|
|
@@ -6623,6 +6675,14 @@ function getScroller (weex) {
|
|
|
6623
6675
|
staticClass: 'weex-scroller-inner weex-ct'
|
|
6624
6676
|
}, cellsWithScopeIds)
|
|
6625
6677
|
]
|
|
6678
|
+
},
|
|
6679
|
+
_handleScrollWrapper: function _handleScrollWrapper (event) {
|
|
6680
|
+
weex.isWebScrolling = true
|
|
6681
|
+
if (this._restorePointerEventsTimer) { clearTimeout(this._restorePointerEventsTimer); }
|
|
6682
|
+
this._restorePointerEventsTimer = setTimeout(function () {
|
|
6683
|
+
weex.isWebScrolling = false
|
|
6684
|
+
}, 120);
|
|
6685
|
+
return this.handleScroll(event)
|
|
6626
6686
|
}
|
|
6627
6687
|
},
|
|
6628
6688
|
|
|
@@ -6645,7 +6705,7 @@ function getScroller (weex) {
|
|
|
6645
6705
|
ref: 'wrapper',
|
|
6646
6706
|
attrs: { 'weex-type': 'scroller' },
|
|
6647
6707
|
on: {
|
|
6648
|
-
scroll: this.
|
|
6708
|
+
scroll: this._handleScrollWrapper,
|
|
6649
6709
|
touchstart: this.handleTouchStart,
|
|
6650
6710
|
touchmove: this.handleTouchMove.bind(this),
|
|
6651
6711
|
touchend: this.handleTouchEnd
|
|
@@ -7907,6 +7967,7 @@ var slideMixin = {
|
|
|
7907
7967
|
var rect = wrapper.getBoundingClientRect();
|
|
7908
7968
|
this._wrapperWidth = rect.width;
|
|
7909
7969
|
this._wrapperHeight = rect.height;
|
|
7970
|
+
this.maxHeight = react.height;
|
|
7910
7971
|
}
|
|
7911
7972
|
},
|
|
7912
7973
|
|
package/package.json
CHANGED