-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
626 additions
and
206 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<script setup lang="ts"> | ||
interface Props { | ||
value: Array<string | undefined> | undefined | ||
} | ||
const props = defineProps<Props>() | ||
interface Emits { | ||
(event: 'update:value', value: Array<string | undefined> | undefined): void | ||
} | ||
const emit = defineEmits<Emits>() | ||
const decode = (value: string | null | undefined): Date | null => { | ||
if (value === null || value === undefined || value === '') { | ||
return null | ||
} | ||
return new Date(value) | ||
} | ||
const encode = (value: Date | null | undefined): string => { | ||
if (value === null || value === undefined) { | ||
return '' | ||
} | ||
return value.toISOString() | ||
} | ||
const addDay = (date: Date | null): Date | null => { | ||
if (date === null) { | ||
return null | ||
} | ||
return new Date(date.getTime() + 24 * 60 * 60 * 1000) | ||
} | ||
const subDay = (date: Date | null): Date | null => { | ||
if (date === null) { | ||
return null | ||
} | ||
return new Date(date.getTime() - 24 * 60 * 60 * 1000) | ||
} | ||
// We use the addDay/subDay to make sure end-dates selected on the calendar are | ||
// included in the range for search. Otherwise, the filter will exclude the last day, | ||
// since the Calendar component selects the first millisecond of the date given. | ||
const model = computed<Array<Date | null>>({ | ||
get: () => props.value | ||
? [ | ||
decode(props.value[0]), | ||
subDay(decode(props.value[1])), | ||
] | ||
: [new Date(), new Date()], | ||
set: (value: Array<Date | null>) => { | ||
emit('update:value', [ | ||
encode(value[0]), | ||
encode(addDay(value[1])), | ||
]) | ||
}, | ||
}) | ||
</script> | ||
|
||
<template> | ||
<PVCalendar | ||
v-model="model" | ||
inline | ||
selection-mode="range" | ||
:manual-input="false" | ||
/> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<template> | ||
<div | ||
class="standard-full-width" | ||
> | ||
<slot /> | ||
</div> | ||
</template> | ||
|
||
<style lang="scss"> | ||
.standard-full-width { | ||
width: calc(100vw - 1rem); | ||
margin: 0 calc(50% - 50vw + .5rem); | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
} | ||
.standard-full-width > * { | ||
width: 100%; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.