@dolphinweex/weex-vue-render 0.2.64 → 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 +70 -28
- 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',
|
|
@@ -6642,6 +6675,14 @@ function getScroller (weex) {
|
|
|
6642
6675
|
staticClass: 'weex-scroller-inner weex-ct'
|
|
6643
6676
|
}, cellsWithScopeIds)
|
|
6644
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)
|
|
6645
6686
|
}
|
|
6646
6687
|
},
|
|
6647
6688
|
|
|
@@ -6664,7 +6705,7 @@ function getScroller (weex) {
|
|
|
6664
6705
|
ref: 'wrapper',
|
|
6665
6706
|
attrs: { 'weex-type': 'scroller' },
|
|
6666
6707
|
on: {
|
|
6667
|
-
scroll: this.
|
|
6708
|
+
scroll: this._handleScrollWrapper,
|
|
6668
6709
|
touchstart: this.handleTouchStart,
|
|
6669
6710
|
touchmove: this.handleTouchMove.bind(this),
|
|
6670
6711
|
touchend: this.handleTouchEnd
|
|
@@ -7926,6 +7967,7 @@ var slideMixin = {
|
|
|
7926
7967
|
var rect = wrapper.getBoundingClientRect();
|
|
7927
7968
|
this._wrapperWidth = rect.width;
|
|
7928
7969
|
this._wrapperHeight = rect.height;
|
|
7970
|
+
this.maxHeight = react.height;
|
|
7929
7971
|
}
|
|
7930
7972
|
},
|
|
7931
7973
|
|
package/package.json
CHANGED