@vuesax-alpha/nightly
Version:
A Component Library for Vue 3
29 lines (26 loc) • 743 B
JavaScript
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