/** * @file input 输入框组件 * @author fuqiangqiang@baidu.com */ import {classCreator} from '../core/util'; import './style/index.less'; import BaseInput from './Base'; import Icon from '../icon'; import type {TInputPassword} from './InputPassword'; import type {TInputSearch} from './InputSearch'; import type {TTextarea} from './Textarea'; import type {TGroup} from './Group'; const prefixCls = classCreator('input')(); export default class Input extends BaseInput { static components = { 's-icon': Icon } static Search: TInputSearch static TextArea: TTextarea static Group: TGroup static Password: TInputPassword inited() { this.data.set('value', this.data.get('value') || this.data.get('defaultValue') || ''); this.data.set('hasAddonBefore', this.data.get('addonBefore') || !!this.sourceSlots.named.addonBefore); this.data.set('hasAddonAfter', this.data.get('addonAfter') || !!this.sourceSlots.named.addonAfter); this.data.set('hasPrefix', this.data.get('prefix') || !!this.sourceSlots.named.prefix); this.data.set('hasSuffix', this.data.get('suffix') || !!this.sourceSlots.named.suffix); } handleIconClear() { this.fire('change', ''); this.data.set('value', ''); this.focus(); } handleMouseDown(e: MouseEvent) { // Do not trigger onBlur when clear input e.preventDefault(); } static template = /* html */ ` ${BaseInput.template} ${BaseInput.template} ` };