Skip to content

Commit

Permalink
Fix input value types
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanreyes committed Jan 31, 2023
1 parent c717a79 commit 363bed4
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/use/datePicker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ const contextKey = '__vc_date_picker_context__';
export type DateModes = 'date' | 'datetime' | 'time';

export type ValueTarget = 'none' | 'start' | 'end' | 'both';
export type InputValueTarget = 'start' | 'end';

export interface UpdateOptions {
config: any;
Expand Down Expand Up @@ -237,7 +238,7 @@ export function createDatePicker(
});

const inputEvents = computed(() => {
const events = (<ValueTarget[]>['start', 'end']).map(target => ({
const events = (['start', 'end'] as const).map(target => ({
input: onInputInput(target),
change: onInputChange(target),
keyup: onInputKeyup,
Expand Down Expand Up @@ -542,7 +543,7 @@ export function createDatePicker(

function onInputUpdate(
inputValue: string,
target: ValueTarget,
target: InputValueTarget,
opts: Partial<UpdateOptions>,
) {
inputValues.value.splice(target === 'start' ? 0 : 1, 1, inputValue);
Expand All @@ -565,7 +566,7 @@ export function createDatePicker(
});
}

function onInputInput(target: ValueTarget) {
function onInputInput(target: InputValueTarget) {
return (e: InputEvent) => {
if (!props.updateOnInput) return;
onInputUpdate((<HTMLInputElement>e.currentTarget).value, target, {
Expand All @@ -576,7 +577,7 @@ export function createDatePicker(
};
}

function onInputChange(target: ValueTarget) {
function onInputChange(target: InputValueTarget) {
return (e: InputEvent) => {
onInputUpdate((<HTMLInputElement>e.currentTarget).value, target, {
formatInput: true,
Expand Down

0 comments on commit 363bed4

Please sign in to comment.