|
|
|
@ -2,6 +2,7 @@
|
|
|
|
|
import dayjs from 'dayjs' |
|
|
|
|
|
|
|
|
|
interface Props { |
|
|
|
|
size?: 'medium' | 'large' | 'small' |
|
|
|
|
selectedDate?: dayjs.Dayjs | null |
|
|
|
|
isDisabled?: boolean |
|
|
|
|
pageDate?: dayjs.Dayjs |
|
|
|
@ -16,6 +17,7 @@ interface Props {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const props = withDefaults(defineProps<Props>(), { |
|
|
|
|
size: 'large', |
|
|
|
|
selectedDate: null, |
|
|
|
|
isDisabled: false, |
|
|
|
|
isMondayFirst: true, |
|
|
|
@ -135,7 +137,13 @@ const paginate = (action: 'next' | 'prev') => {
|
|
|
|
|
</script> |
|
|
|
|
|
|
|
|
|
<template> |
|
|
|
|
<div class="px-4 pt-3 pb-4 flex flex-col gap-4"> |
|
|
|
|
<div |
|
|
|
|
:class="{ |
|
|
|
|
'gap-1': size === 'small', |
|
|
|
|
'gap-4': size === 'medium' || size === 'large', |
|
|
|
|
}" |
|
|
|
|
class="flex flex-col" |
|
|
|
|
> |
|
|
|
|
<div |
|
|
|
|
:class="{ |
|
|
|
|
'justify-center': disablePagination, |
|
|
|
@ -144,7 +152,7 @@ const paginate = (action: 'next' | 'prev') => {
|
|
|
|
|
class="flex items-center" |
|
|
|
|
> |
|
|
|
|
<NcTooltip> |
|
|
|
|
<NcButton v-if="!disablePagination" size="small" type="secondary" @click="paginate('prev')"> |
|
|
|
|
<NcButton v-if="!disablePagination" size="medium" type="secondary" @click="paginate('prev')"> |
|
|
|
|
<component :is="iconMap.doubleLeftArrow" class="h-4 w-4" /> |
|
|
|
|
</NcButton> |
|
|
|
|
<template #title> |
|
|
|
@ -152,9 +160,16 @@ const paginate = (action: 'next' | 'prev') => {
|
|
|
|
|
</template> |
|
|
|
|
</NcTooltip> |
|
|
|
|
|
|
|
|
|
<span class="font-bold text-gray-700">{{ currentMonthYear }}</span> |
|
|
|
|
<span |
|
|
|
|
:class="{ |
|
|
|
|
'text-xs': size === 'small', |
|
|
|
|
'text-sm': size === 'medium', |
|
|
|
|
}" |
|
|
|
|
class="font-bold text-gray-700" |
|
|
|
|
>{{ currentMonthYear }}</span |
|
|
|
|
> |
|
|
|
|
<NcTooltip> |
|
|
|
|
<NcButton v-if="!disablePagination" size="small" type="secondary" @click="paginate('next')"> |
|
|
|
|
<NcButton v-if="!disablePagination" size="medium" type="secondary" @click="paginate('next')"> |
|
|
|
|
<component :is="iconMap.doubleRightArrow" class="h-4 w-4" /> |
|
|
|
|
</NcButton> |
|
|
|
|
<template #title> |
|
|
|
@ -162,13 +177,41 @@ const paginate = (action: 'next' | 'prev') => {
|
|
|
|
|
</template> |
|
|
|
|
</NcTooltip> |
|
|
|
|
</div> |
|
|
|
|
<div class="border-1 border-gray-200 rounded-y-xl max-w-[320px]"> |
|
|
|
|
<div class="flex flex-row bg-gray-100 gap-2 rounded-t-xl justify-between px-2"> |
|
|
|
|
<span v-for="(day, index) in days" :key="index" class="h-9 flex items-center justify-center w-9 text-gray-500">{{ |
|
|
|
|
day |
|
|
|
|
}}</span> |
|
|
|
|
<div |
|
|
|
|
:class="{ |
|
|
|
|
'rounded-lg': size === 'small', |
|
|
|
|
'rounded-y-xl': size !== 'small', |
|
|
|
|
}" |
|
|
|
|
class="border-1 border-gray-200 max-w-[320px]" |
|
|
|
|
> |
|
|
|
|
<div |
|
|
|
|
:class="{ |
|
|
|
|
'gap-1 px-1': size === 'medium', |
|
|
|
|
'gap-2 px-2': size === 'large', |
|
|
|
|
'px-2 py-1 !rounded-t-lg': size === 'small', |
|
|
|
|
'rounded-t-xl': size !== 'small', |
|
|
|
|
}" |
|
|
|
|
class="flex flex-row bg-gray-100 justify-between" |
|
|
|
|
> |
|
|
|
|
<span |
|
|
|
|
v-for="(day, index) in days" |
|
|
|
|
:key="index" |
|
|
|
|
:class="{ |
|
|
|
|
'w-9 h-9': size === 'large', |
|
|
|
|
'w-8 h-8': size === 'medium', |
|
|
|
|
'text-[10px]': size === 'small', |
|
|
|
|
}" |
|
|
|
|
class="flex items-center uppercase justify-center text-gray-500" |
|
|
|
|
>{{ day[0] }}</span |
|
|
|
|
> |
|
|
|
|
</div> |
|
|
|
|
<div class="grid grid-cols-7 gap-2 p-2"> |
|
|
|
|
<div |
|
|
|
|
:class="{ |
|
|
|
|
'gap-2 p-2': size === 'large', |
|
|
|
|
'gap-1 p-1': size === 'medium', |
|
|
|
|
}" |
|
|
|
|
class="grid grid-cols-7" |
|
|
|
|
> |
|
|
|
|
<span |
|
|
|
|
v-for="(date, index) in dates" |
|
|
|
|
:key="index" |
|
|
|
@ -177,16 +220,31 @@ const paginate = (action: 'next' | 'prev') => {
|
|
|
|
|
'bg-brand-50 border-1 !border-brand-500': isSelectedDate(date) && !isWeekPicker && isDayInPagedMonth(date), |
|
|
|
|
'hover:(border-1 border-gray-200 bg-gray-100)': !isSelectedDate(date) && !isWeekPicker, |
|
|
|
|
'nc-selected-week z-1': isDateInSelectedWeek(date) && isWeekPicker, |
|
|
|
|
'border-none': isWeekPicker, |
|
|
|
|
'border-transparent': !isWeekPicker, |
|
|
|
|
'text-gray-400': !isDateInCurrentMonth(date), |
|
|
|
|
'nc-selected-week-start': isSameDate(date, selectedWeek?.start), |
|
|
|
|
'nc-selected-week-end': isSameDate(date, selectedWeek?.end), |
|
|
|
|
'rounded-md bg-brand-50 nc-calendar-today text-brand-500': isSameDate(date, dayjs()) && isDateInCurrentMonth(date), |
|
|
|
|
'h-9 w-9': size === 'large', |
|
|
|
|
'h-8 w-8': size === 'medium', |
|
|
|
|
'h-6 w-6 text-[10px]': size === 'small', |
|
|
|
|
}" |
|
|
|
|
class="h-9 w-9 px-1 py-2 relative font-medium flex items-center cursor-pointer justify-center" |
|
|
|
|
class="px-1 py-1 relative border-1 font-large flex items-center cursor-pointer justify-center" |
|
|
|
|
data-testid="nc-calendar-date" |
|
|
|
|
@click="handleSelectDate(date)" |
|
|
|
|
> |
|
|
|
|
<span v-if="isActiveDate(date)" class="absolute z-2 h-1.5 w-1.5 rounded-full bg-brand-500 top-1 right-1"></span> |
|
|
|
|
<span |
|
|
|
|
v-if="isActiveDate(date)" |
|
|
|
|
:class="{ |
|
|
|
|
'h-1.5 w-1.5': size === 'large', |
|
|
|
|
'h-1 w-1': size === 'medium', |
|
|
|
|
'h-0.75 w-0.75': size === 'small', |
|
|
|
|
'top-1 right-1': size !== 'small', |
|
|
|
|
'top-0.5 right-0.5': size === 'small', |
|
|
|
|
}" |
|
|
|
|
class="absolute z-2 rounded-full bg-brand-500" |
|
|
|
|
></span> |
|
|
|
|
<span class="z-2"> |
|
|
|
|
{{ date.get('date') }} |
|
|
|
|
</span> |
|
|
|
|