antd-mini
Version:
antd-mini 是支付宝小程序 UI 组件库,遵循 Ant Design 规范。
47 lines (46 loc) • 1.35 kB
JavaScript
import mixinValue from '../../mixins/value';
import { Component, triggerEvent } from '../../_util/simply';
import { InputBlurDefaultProps } from './props';
Component(InputBlurDefaultProps, {
onChange: function (e) {
var value = e.detail.value;
if (this.isControlled()) {
this.update(value, {}, true);
}
triggerEvent(this, 'change', value, e);
},
onFocus: function (e) {
var value = e.detail.value;
this.focus = true;
triggerEvent(this, 'focus', value, e);
},
onBlur: function (e) {
var value = e.detail.value;
this.focus = false;
if (this.isControlled()) {
this.update(this.props.value);
}
triggerEvent(this, 'blur', value, e);
},
onConfirm: function (e) {
var value = e.detail.value;
triggerEvent(this, 'confirm', value, e);
},
}, undefined, [
mixinValue({
scopeKey: 'state',
transformValue: function (value, extra, updateWithoutFocusCheck) {
if (value === null || (!updateWithoutFocusCheck && this.focus)) {
return {
needUpdate: false,
};
}
return {
needUpdate: true,
value: value,
};
},
}),
], {
focus: false,
});