|
27 | 27 | @keydown.enter="handleEnter" |
28 | 28 | @keydown.tab="handleTab" |
29 | 29 | @focus="handleFocus" |
| 30 | + @blur="handleBlur" |
30 | 31 | /> |
31 | 32 | <span class="dp__input_icon" v-if="$slots['input-icon'] && !hideInputIcon" @click="stopPropagation" |
32 | 33 | ><slot name="input-icon" |
|
57 | 58 | import { CalendarIcon, CancelIcon } from './Icons'; |
58 | 59 | import { isValidDate, parseFreeInput } from '../utils/date-utils'; |
59 | 60 |
|
60 | | - const emit = defineEmits(['clear', 'open', 'update:inputValue', 'setInputDate', 'close']); |
| 61 | + const emit = defineEmits(['clear', 'open', 'update:inputValue', 'setInputDate', 'close', 'selectDate']); |
61 | 62 |
|
62 | 63 | const props = defineProps({ |
63 | 64 | inputValue: { type: String as PropType<string>, default: '' }, |
|
73 | 74 | textInput: { type: Boolean as PropType<boolean>, default: false }, |
74 | 75 | textInputOptions: { type: Object as PropType<ITextInputOptions>, default: () => null }, |
75 | 76 | isMenuOpen: { type: Boolean as PropType<boolean>, default: false }, |
| 77 | + autoApply: { type: Boolean as PropType<boolean>, default: false }, |
76 | 78 | pattern: { type: String as PropType<string>, default: '' }, |
77 | 79 | }); |
78 | 80 | const parsedDate = ref(); |
|
147 | 149 | } |
148 | 150 | }; |
149 | 151 |
|
| 152 | + const handleBlur = (): void => { |
| 153 | + if (props.autoApply && props.textInput && parsedDate.value) { |
| 154 | + emit('setInputDate', parsedDate.value); |
| 155 | + emit('selectDate'); |
| 156 | + parsedDate.value = null; |
| 157 | + } |
| 158 | + }; |
| 159 | +
|
150 | 160 | const stopPropagation = (e: Event) => { |
151 | 161 | e.stopImmediatePropagation(); |
152 | 162 | }; |
|
0 commit comments