Skip to content

Commit

Permalink
Merge pull request #12 from joffreyBerrier/fix/add-component-name
Browse files Browse the repository at this point in the history
fix(global): add component name
  • Loading branch information
joffreyBerrier authored Apr 8, 2022
2 parents 5a39ce0 + 128bc09 commit 85c7e05
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 14 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vue-calendar-3",
"version": "1.1.0",
"version": "1.1.1",
"repository": "https://github.com/joffreyBerrier/vue-datepicker",
"funding": "https://github.com/sponsors/joffreyBerrier",
"license": "MIT",
Expand Down
6 changes: 6 additions & 0 deletions src/components/BaseIcon.vue
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
<script lang="ts">
export default {
name: "BaseIcon",
};
</script>

<script setup lang="ts">
import { computed, ref } from "vue";
import type { Ref, ComputedRef } from "vue";
Expand Down
25 changes: 20 additions & 5 deletions src/components/Calendar.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
<script lang="ts">
export default {
name: "VueCalendar",
};
</script>

<script setup lang="ts">
import { computed, ref } from "vue";
import { computed, ref, onBeforeMount, onUnmounted } from "vue";
import type { ComputedRef, PropType, Ref } from "vue";
import { format } from "fecha";
Expand Down Expand Up @@ -129,7 +135,16 @@ const countOfMonth = getMonthDiff(props.startDate, props.endDate) + 11;
const multipleMonths = useCreateMultipleMonths(props.startDate, countOfMonth);
months.value.push(...multipleMonths);
const { calendarRef, openCalendar, showCalendar } = useToggleCalendar(props);
const { addClickOusideListener, calendarRef, openCalendar, showCalendar } =
useToggleCalendar(props);
onBeforeMount(() => {
if (!props.showYear) addClickOusideListener();
});
onUnmounted(() => {
if (!props.showYear) removeClickOusideListener();
});
// Create array of disabledDates for each types of period
const saturdayWeeklyPeriods = computed(() => {
Expand Down Expand Up @@ -448,7 +463,7 @@ const getBookingType = (day: Day): string | null => {

<template>
<div ref="calendarRef" class="calendar">
<calendar-input
<CalendarInput
v-if="showInputCalendar"
:placeholder="placeholder"
:check-in="checkIn"
Expand Down Expand Up @@ -479,7 +494,7 @@ const getBookingType = (day: Day): string | null => {
v-if="showCalendar"
:class="['calendar_wrapper', { 'calendar_wrapper--year': showYear }]"
>
<calendar-header
<CalendarHeader
v-if="!showYear"
:active-index="activeIndex"
:months="months"
Expand All @@ -490,7 +505,7 @@ const getBookingType = (day: Day): string | null => {
<div v-for="month in slicedMonths" :key="month.monthKey">
<span v-if="showYear" class="font-bold">{{ month.monthName }}</span>

<calendar-days />
<CalendarDays />

<div class="calendar_wrapper_content-days">
<div
Expand Down
6 changes: 6 additions & 0 deletions src/components/CalendarDays.vue
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
<script lang="ts">
export default {
name: "CalendarDays",
};
</script>

<script setup lang="ts">
import { ref } from "vue";
import type { Ref } from "vue";
Expand Down
6 changes: 6 additions & 0 deletions src/components/CalendarHeader.vue
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
<script lang="ts">
export default {
name: "CalendarHeader",
};
</script>

<script setup lang="ts">
import { computed } from "vue";
import type { ComputedRef, PropType } from "vue";
Expand Down
6 changes: 6 additions & 0 deletions src/components/CalendarInput.vue
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
<script lang="ts">
export default {
name: "CalendarInput",
};
</script>

<script setup lang="ts">
import type { PropType } from "vue";
import type { Placeholder } from "~/types";
Expand Down
10 changes: 2 additions & 8 deletions src/components/compose/useToggleCalendar.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ref, watch, onBeforeMount, onUnmounted } from "vue";
import { ref, watch } from "vue";

export const useToggleCalendar = (props) => {
const showCalendar = ref(props.showYear);
Expand Down Expand Up @@ -39,14 +39,8 @@ export const useToggleCalendar = (props) => {
}
);

onBeforeMount(() => {
if (!props.showYear) addClickOusideListener();
});
onUnmounted(() => {
if (!props.showYear) removeClickOusideListener();
});

return {
addClickOusideListener,
calendarRef,
openCalendar,
showCalendar,
Expand Down
1 change: 1 addition & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@ export default defineConfig({
alias: {
"~": fileURLToPath(new URL("./src", import.meta.url)),
},
// preserveSymlinks: true,
},
});

0 comments on commit 85c7e05

Please sign in to comment.