Skip to content

Commit 84fe80b

Browse files
committed
fix: text-input formats prop type, proper format and pattern value, format value on focus (fixes #1181)
1 parent 6a1cf60 commit 84fe80b

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

src/VueDatePicker/VueDatePicker.vue

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
@close="closeMenu"
1313
@focus="handleInputFocus"
1414
@blur="handleBlur"
15-
@real-blur="isInputFocused = false"
15+
@real-blur="setState('isInputFocused', false)"
1616
>
1717
<template v-for="(slot, i) in inputSlots" #[slot]="args" :key="i">
1818
<slot :name="slot" v-bind="args" />
@@ -127,7 +127,6 @@
127127
const pickerWrapperRef = useTemplateRef('picker-wrapper');
128128
const menuArrowRef = useTemplateRef('menu-arrow');
129129
130-
const isInputFocused = ref(false);
131130
const shouldFocusNext = ref(false);
132131
const shiftKeyActive = ref(false);
133132
const collapse = ref(false);
@@ -397,7 +396,7 @@
397396
398397
const handleInputFocus = () => {
399398
if (textInput.value.enabled) {
400-
isInputFocused.value = true;
399+
setState('isInputFocused', true);
401400
formatInputValue();
402401
}
403402
@@ -406,7 +405,7 @@
406405
407406
const handleBlur = () => {
408407
if (textInput.value.enabled) {
409-
isInputFocused.value = false;
408+
setState('isInputFocused', false);
410409
parseExternalModelValue(rootProps.modelValue);
411410
if (shouldFocusNext.value) {
412411
const el = findNextFocusableElement(pickerWrapperRef.value!, shiftKeyActive.value);

src/VueDatePicker/composables/useDefaults.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,9 @@ export const useDefaults = (props: RootPropsWithDefaults) => {
135135
if (typeof props.textInput === 'object') {
136136
return {
137137
...defaultTextInputOptions,
138-
format: formats.value.input,
139-
pattern: formats.value.input,
140138
...props.textInput,
139+
format: typeof props.textInput.format === 'string' ? props.textInput.format : formats.value.input,
140+
pattern: props.textInput.format ?? formats.value.input,
141141
enabled: true,
142142
};
143143
}

src/VueDatePicker/types/configs.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ export interface TextInputConfig {
120120
rangeSeparator: string;
121121
selectOnFocus: boolean;
122122
escClose: boolean;
123-
format: string;
123+
format: string | string[] | ((value: string) => Date | null);
124124
maskFormat: string;
125125
}
126126

0 commit comments

Comments
 (0)