UNPKG

@vuesax-alpha/nightly

Version:
29 lines (26 loc) 743 B
import { getCurrentInstance, computed } from 'vue'; import '../../../../constants/index.mjs'; import { UPDATE_MODEL_EVENT } from '../../../../constants/event.mjs'; const useInputClearable = (props, { hovering, focused }) => { const { emit } = getCurrentInstance(); const clear = () => { if (props.disabled || props.loading) return; emit(UPDATE_MODEL_EVENT, ""); emit("change", ""); emit("clear"); emit("input", ""); }; const showClear = computed( () => props.clearable && !props.disabled && !props.loading && String(props.modelValue) && (focused.value || hovering.value) ); return { clear, showClear }; }; export { useInputClearable }; //# sourceMappingURL=use-input-clearable.mjs.map