@ramathibodi/nuxt-commons 4.0.23 → 4.0.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/module.json +1 -1
- package/dist/module.mjs +1 -1
- package/dist/runtime/calendar/mapping.d.ts +20 -0
- package/dist/runtime/calendar/mapping.js +51 -0
- package/dist/runtime/components/Calendar.d.vue.ts +109 -0
- package/dist/runtime/components/Calendar.vue +116 -0
- package/dist/runtime/components/Calendar.vue.d.ts +109 -0
- package/dist/runtime/components/form/DateTime.d.vue.ts +1 -1
- package/dist/runtime/components/form/DateTime.vue.d.ts +1 -1
- package/dist/runtime/types/calendar.d.ts +25 -0
- package/package.json +3 -9
- package/dist/runtime/labs/Calendar.d.vue.ts +0 -35
- package/dist/runtime/labs/Calendar.vue +0 -71
- package/dist/runtime/labs/Calendar.vue.d.ts +0 -35
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -36,7 +36,7 @@ const module$1 = defineNuxtModule({
|
|
|
36
36
|
src: resolver.resolve("runtime/plugins/default"),
|
|
37
37
|
mode: "client"
|
|
38
38
|
});
|
|
39
|
-
const typeFiles = ["modules", "alert", "menu", "graphqlOperation", "api", "formDialog", "dialogManager", "permission", "clientConfig", "bridge"];
|
|
39
|
+
const typeFiles = ["modules", "alert", "menu", "graphqlOperation", "api", "formDialog", "dialogManager", "permission", "clientConfig", "bridge", "calendar"];
|
|
40
40
|
for (const file of typeFiles) {
|
|
41
41
|
addTypeTemplate({
|
|
42
42
|
src: resolver.resolve(`runtime/types/${file}.d.ts`),
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { CalendarEvent, CalendarToolbar, CalendarView } from '../types/calendar.js';
|
|
2
|
+
export declare function toFcView(view: CalendarView): string;
|
|
3
|
+
export declare function fromFcView(fcView: string): CalendarView;
|
|
4
|
+
export declare function toFcToolbar(toolbar: CalendarToolbar | false): {
|
|
5
|
+
left: string;
|
|
6
|
+
center: string;
|
|
7
|
+
right: string;
|
|
8
|
+
} | false;
|
|
9
|
+
export declare function toFcEvent(event: CalendarEvent): Record<string, unknown>;
|
|
10
|
+
/** A plain CalendarEvent from FullCalendar's EventApi, so no library object reaches a consumer. */
|
|
11
|
+
export declare function toCalendarEvent(event: {
|
|
12
|
+
id: string;
|
|
13
|
+
title: string;
|
|
14
|
+
start: Date | null;
|
|
15
|
+
end: Date | null;
|
|
16
|
+
allDay: boolean;
|
|
17
|
+
color?: string;
|
|
18
|
+
display?: string;
|
|
19
|
+
extendedProps?: Record<string, any>;
|
|
20
|
+
}): CalendarEvent;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
const VIEW_TO_FC = {
|
|
2
|
+
month: "dayGridMonth",
|
|
3
|
+
week: "timeGridWeek",
|
|
4
|
+
day: "timeGridDay",
|
|
5
|
+
list: "listWeek"
|
|
6
|
+
};
|
|
7
|
+
export function toFcView(view) {
|
|
8
|
+
return VIEW_TO_FC[view] ?? VIEW_TO_FC.week;
|
|
9
|
+
}
|
|
10
|
+
export function fromFcView(fcView) {
|
|
11
|
+
const hit = Object.keys(VIEW_TO_FC).find((key) => VIEW_TO_FC[key] === fcView);
|
|
12
|
+
return hit ?? "week";
|
|
13
|
+
}
|
|
14
|
+
const NAV = /* @__PURE__ */ new Set(["prev", "next"]);
|
|
15
|
+
const VIEWS = /* @__PURE__ */ new Set(["month", "week", "day", "list"]);
|
|
16
|
+
function toFcToken(token) {
|
|
17
|
+
return VIEWS.has(token) ? toFcView(token) : token;
|
|
18
|
+
}
|
|
19
|
+
function toFcSection(tokens = []) {
|
|
20
|
+
let out = "";
|
|
21
|
+
tokens.forEach((token, index) => {
|
|
22
|
+
const previous = tokens[index - 1];
|
|
23
|
+
const sameGroup = previous !== void 0 && (NAV.has(previous) && NAV.has(token) || VIEWS.has(previous) && VIEWS.has(token));
|
|
24
|
+
out += (index === 0 ? "" : sameGroup ? "," : " ") + toFcToken(token);
|
|
25
|
+
});
|
|
26
|
+
return out;
|
|
27
|
+
}
|
|
28
|
+
export function toFcToolbar(toolbar) {
|
|
29
|
+
if (toolbar === false) return false;
|
|
30
|
+
return { left: toFcSection(toolbar.left), center: toFcSection(toolbar.center), right: toFcSection(toolbar.right) };
|
|
31
|
+
}
|
|
32
|
+
export function toFcEvent(event) {
|
|
33
|
+
const out = {};
|
|
34
|
+
for (const [key, value] of Object.entries(event)) {
|
|
35
|
+
if (value === null || value === void 0) continue;
|
|
36
|
+
out[key] = key === "id" ? String(value) : value;
|
|
37
|
+
}
|
|
38
|
+
return out;
|
|
39
|
+
}
|
|
40
|
+
export function toCalendarEvent(event) {
|
|
41
|
+
return {
|
|
42
|
+
id: event.id || null,
|
|
43
|
+
title: event.title,
|
|
44
|
+
start: event.start,
|
|
45
|
+
end: event.end,
|
|
46
|
+
allDay: event.allDay,
|
|
47
|
+
color: event.color || null,
|
|
48
|
+
display: event.display === "background" ? "background" : "auto",
|
|
49
|
+
extendedProps: { ...event.extendedProps ?? {} }
|
|
50
|
+
};
|
|
51
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import '@fullcalendar/vue3/skeleton.css';
|
|
2
|
+
import '@fullcalendar/vue3/themes/classic/theme.css';
|
|
3
|
+
import '@fullcalendar/vue3/themes/classic/palette.css';
|
|
4
|
+
import type { CalendarEvent, CalendarRange, CalendarToolbar, CalendarView } from '../types/calendar.js';
|
|
5
|
+
interface Props {
|
|
6
|
+
/** Array mode: redraws whenever the array changes. */
|
|
7
|
+
events?: CalendarEvent[];
|
|
8
|
+
/**
|
|
9
|
+
* Loader mode: called for every visible-range change. Wins over `events`.
|
|
10
|
+
* The loader is read at fetch time, not captured when passed, so replacing this prop on every
|
|
11
|
+
* render does not by itself trigger a refetch; call `refetch()` when its inputs change.
|
|
12
|
+
*/
|
|
13
|
+
fetchEvents?: (range: CalendarRange) => Promise<CalendarEvent[]>;
|
|
14
|
+
view?: CalendarView;
|
|
15
|
+
date?: Date | string;
|
|
16
|
+
locale?: 'th' | 'en';
|
|
17
|
+
timeZone?: string;
|
|
18
|
+
toolbar?: CalendarToolbar | false;
|
|
19
|
+
height?: number | string;
|
|
20
|
+
slotMinTime?: string;
|
|
21
|
+
slotMaxTime?: string;
|
|
22
|
+
selectable?: boolean;
|
|
23
|
+
/** Last resort, FullCalendar-specific and unstable: merged over everything else. */
|
|
24
|
+
options?: Record<string, unknown>;
|
|
25
|
+
}
|
|
26
|
+
declare var __VLS_10: {
|
|
27
|
+
event: CalendarEvent;
|
|
28
|
+
timeText: any;
|
|
29
|
+
};
|
|
30
|
+
type __VLS_Slots = {} & {
|
|
31
|
+
event?: (props: typeof __VLS_10) => any;
|
|
32
|
+
};
|
|
33
|
+
declare const __VLS_base: import("vue").DefineComponent<Props, {
|
|
34
|
+
currentView: Readonly<import("vue").Ref<CalendarView, CalendarView>>;
|
|
35
|
+
currentRange: Readonly<import("vue").Ref<{
|
|
36
|
+
readonly start: Date;
|
|
37
|
+
readonly end: Date;
|
|
38
|
+
} | null, {
|
|
39
|
+
readonly start: Date;
|
|
40
|
+
readonly end: Date;
|
|
41
|
+
} | null>>;
|
|
42
|
+
title: Readonly<import("vue").Ref<string, string>>;
|
|
43
|
+
refetch: () => void | undefined;
|
|
44
|
+
gotoDate: (date: Date | string) => void | undefined;
|
|
45
|
+
changeView: (view: CalendarView) => void | undefined;
|
|
46
|
+
today: () => void | undefined;
|
|
47
|
+
prev: () => void | undefined;
|
|
48
|
+
next: () => void | undefined;
|
|
49
|
+
scrollToTime: (time: string) => void | undefined;
|
|
50
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
51
|
+
loading: (value: boolean) => any;
|
|
52
|
+
select: (value: {
|
|
53
|
+
start: Date;
|
|
54
|
+
end: Date;
|
|
55
|
+
allDay: boolean;
|
|
56
|
+
}) => any;
|
|
57
|
+
"event-click": (event: CalendarEvent) => any;
|
|
58
|
+
"date-click": (value: {
|
|
59
|
+
date: Date;
|
|
60
|
+
allDay: boolean;
|
|
61
|
+
}) => any;
|
|
62
|
+
"dates-set": (value: {
|
|
63
|
+
start: Date;
|
|
64
|
+
end: Date;
|
|
65
|
+
view: CalendarView;
|
|
66
|
+
}) => any;
|
|
67
|
+
"update:view": (value: CalendarView) => any;
|
|
68
|
+
"update:date": (value: Date) => any;
|
|
69
|
+
}, string, import("vue").PublicProps, Readonly<Props> & Readonly<{
|
|
70
|
+
onLoading?: ((value: boolean) => any) | undefined;
|
|
71
|
+
onSelect?: ((value: {
|
|
72
|
+
start: Date;
|
|
73
|
+
end: Date;
|
|
74
|
+
allDay: boolean;
|
|
75
|
+
}) => any) | undefined;
|
|
76
|
+
"onEvent-click"?: ((event: CalendarEvent) => any) | undefined;
|
|
77
|
+
"onDate-click"?: ((value: {
|
|
78
|
+
date: Date;
|
|
79
|
+
allDay: boolean;
|
|
80
|
+
}) => any) | undefined;
|
|
81
|
+
"onDates-set"?: ((value: {
|
|
82
|
+
start: Date;
|
|
83
|
+
end: Date;
|
|
84
|
+
view: CalendarView;
|
|
85
|
+
}) => any) | undefined;
|
|
86
|
+
"onUpdate:view"?: ((value: CalendarView) => any) | undefined;
|
|
87
|
+
"onUpdate:date"?: ((value: Date) => any) | undefined;
|
|
88
|
+
}>, {
|
|
89
|
+
height: number | string;
|
|
90
|
+
options: Record<string, unknown>;
|
|
91
|
+
view: CalendarView;
|
|
92
|
+
events: CalendarEvent[];
|
|
93
|
+
fetchEvents: (range: CalendarRange) => Promise<CalendarEvent[]>;
|
|
94
|
+
date: Date | string;
|
|
95
|
+
locale: "th" | "en";
|
|
96
|
+
timeZone: string;
|
|
97
|
+
toolbar: CalendarToolbar | false;
|
|
98
|
+
slotMinTime: string;
|
|
99
|
+
slotMaxTime: string;
|
|
100
|
+
selectable: boolean;
|
|
101
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
102
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
103
|
+
declare const _default: typeof __VLS_export;
|
|
104
|
+
export default _default;
|
|
105
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
106
|
+
new (): {
|
|
107
|
+
$slots: S;
|
|
108
|
+
};
|
|
109
|
+
};
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import FullCalendar from "@fullcalendar/vue3";
|
|
3
|
+
import dayGridPlugin from "@fullcalendar/vue3/daygrid";
|
|
4
|
+
import timeGridPlugin from "@fullcalendar/vue3/timegrid";
|
|
5
|
+
import listPlugin from "@fullcalendar/vue3/list";
|
|
6
|
+
import interactionPlugin from "@fullcalendar/vue3/interaction";
|
|
7
|
+
import classicThemePlugin from "@fullcalendar/vue3/themes/classic";
|
|
8
|
+
import thLocale from "@fullcalendar/vue3/locales/th";
|
|
9
|
+
import "@fullcalendar/vue3/skeleton.css";
|
|
10
|
+
import "@fullcalendar/vue3/themes/classic/theme.css";
|
|
11
|
+
import "@fullcalendar/vue3/themes/classic/palette.css";
|
|
12
|
+
import { computed, readonly, ref, useSlots, watch } from "vue";
|
|
13
|
+
import { fromFcView, toCalendarEvent, toFcEvent, toFcToolbar, toFcView } from "../calendar/mapping";
|
|
14
|
+
const props = defineProps({
|
|
15
|
+
events: { type: Array, required: false, default: void 0 },
|
|
16
|
+
fetchEvents: { type: Function, required: false, default: void 0 },
|
|
17
|
+
view: { type: String, required: false, default: "week" },
|
|
18
|
+
date: { type: [Date, String], required: false, default: void 0 },
|
|
19
|
+
locale: { type: String, required: false, default: "th" },
|
|
20
|
+
timeZone: { type: String, required: false, default: "local" },
|
|
21
|
+
toolbar: { type: [Object, Boolean], required: false, default: () => ({ left: ["today", "prev", "next"], center: ["title"], right: ["month", "week", "day", "list"] }) },
|
|
22
|
+
height: { type: [Number, String], required: false, default: "auto" },
|
|
23
|
+
slotMinTime: { type: String, required: false, default: "07:00" },
|
|
24
|
+
slotMaxTime: { type: String, required: false, default: "20:00" },
|
|
25
|
+
selectable: { type: Boolean, required: false, default: false },
|
|
26
|
+
options: { type: Object, required: false, default: void 0 }
|
|
27
|
+
});
|
|
28
|
+
const emit = defineEmits(["event-click", "date-click", "select", "dates-set", "loading", "update:view", "update:date"]);
|
|
29
|
+
const slots = useSlots();
|
|
30
|
+
const fc = ref();
|
|
31
|
+
const api = () => fc.value?.getApi?.();
|
|
32
|
+
const currentView = ref(props.view);
|
|
33
|
+
const currentRange = ref(null);
|
|
34
|
+
const title = ref("");
|
|
35
|
+
function loadEvents(info) {
|
|
36
|
+
const loader = props.fetchEvents;
|
|
37
|
+
if (!loader) return Promise.resolve([]);
|
|
38
|
+
return loader({ start: info.start, end: info.end }).then((list) => (list ?? []).map(toFcEvent));
|
|
39
|
+
}
|
|
40
|
+
const hasLoader = computed(() => !!props.fetchEvents);
|
|
41
|
+
const eventSource = computed(() => {
|
|
42
|
+
if (hasLoader.value) return loadEvents;
|
|
43
|
+
return (props.events ?? []).map(toFcEvent);
|
|
44
|
+
});
|
|
45
|
+
const calendarOptions = computed(() => ({
|
|
46
|
+
plugins: [classicThemePlugin, dayGridPlugin, timeGridPlugin, listPlugin, interactionPlugin],
|
|
47
|
+
initialView: toFcView(props.view),
|
|
48
|
+
initialDate: props.date,
|
|
49
|
+
locale: props.locale === "th" ? thLocale : "en",
|
|
50
|
+
timeZone: props.timeZone,
|
|
51
|
+
headerToolbar: toFcToolbar(props.toolbar),
|
|
52
|
+
height: props.height,
|
|
53
|
+
slotMinTime: props.slotMinTime,
|
|
54
|
+
slotMaxTime: props.slotMaxTime,
|
|
55
|
+
selectable: props.selectable,
|
|
56
|
+
nowIndicator: true,
|
|
57
|
+
dayMaxEvents: true,
|
|
58
|
+
events: eventSource.value,
|
|
59
|
+
eventClick: (info) => emit("event-click", toCalendarEvent(info.event)),
|
|
60
|
+
dateClick: (info) => emit("date-click", { date: info.date, allDay: info.allDay }),
|
|
61
|
+
select: (info) => emit("select", { start: info.start, end: info.end, allDay: info.allDay }),
|
|
62
|
+
loading: (isLoading) => emit("loading", isLoading),
|
|
63
|
+
datesSet: (info) => {
|
|
64
|
+
const view = fromFcView(info.view.type);
|
|
65
|
+
currentRange.value = { start: info.start, end: info.end };
|
|
66
|
+
title.value = info.view.title;
|
|
67
|
+
if (view !== currentView.value) {
|
|
68
|
+
currentView.value = view;
|
|
69
|
+
emit("update:view", view);
|
|
70
|
+
}
|
|
71
|
+
emit("update:date", info.view.currentStart);
|
|
72
|
+
emit("dates-set", { start: info.start, end: info.end, view });
|
|
73
|
+
},
|
|
74
|
+
...props.options ?? {}
|
|
75
|
+
}));
|
|
76
|
+
watch(() => props.view, (view) => {
|
|
77
|
+
if (view && view !== currentView.value) api()?.changeView(toFcView(view));
|
|
78
|
+
});
|
|
79
|
+
watch(() => props.date, (date) => {
|
|
80
|
+
if (!date) return;
|
|
81
|
+
const target = date instanceof Date ? date : new Date(date);
|
|
82
|
+
const range = currentRange.value;
|
|
83
|
+
const withinRange = range !== null && target >= range.start && target < range.end;
|
|
84
|
+
if (!withinRange) api()?.gotoDate(date);
|
|
85
|
+
});
|
|
86
|
+
defineExpose({
|
|
87
|
+
currentView: readonly(currentView),
|
|
88
|
+
currentRange: readonly(currentRange),
|
|
89
|
+
title: readonly(title),
|
|
90
|
+
refetch: () => api()?.refetchEvents(),
|
|
91
|
+
gotoDate: (date) => api()?.gotoDate(date),
|
|
92
|
+
changeView: (view) => api()?.changeView(toFcView(view)),
|
|
93
|
+
today: () => api()?.today(),
|
|
94
|
+
prev: () => api()?.prev(),
|
|
95
|
+
next: () => api()?.next(),
|
|
96
|
+
scrollToTime: (time) => api()?.scrollToTime(time)
|
|
97
|
+
});
|
|
98
|
+
</script>
|
|
99
|
+
|
|
100
|
+
<template>
|
|
101
|
+
<FullCalendar
|
|
102
|
+
ref="fc"
|
|
103
|
+
:options="calendarOptions"
|
|
104
|
+
>
|
|
105
|
+
<template
|
|
106
|
+
v-if="slots.event"
|
|
107
|
+
#eventContent="arg"
|
|
108
|
+
>
|
|
109
|
+
<slot
|
|
110
|
+
name="event"
|
|
111
|
+
:event="toCalendarEvent(arg.event)"
|
|
112
|
+
:time-text="arg.timeText"
|
|
113
|
+
/>
|
|
114
|
+
</template>
|
|
115
|
+
</FullCalendar>
|
|
116
|
+
</template>
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import '@fullcalendar/vue3/skeleton.css';
|
|
2
|
+
import '@fullcalendar/vue3/themes/classic/theme.css';
|
|
3
|
+
import '@fullcalendar/vue3/themes/classic/palette.css';
|
|
4
|
+
import type { CalendarEvent, CalendarRange, CalendarToolbar, CalendarView } from '../types/calendar.js';
|
|
5
|
+
interface Props {
|
|
6
|
+
/** Array mode: redraws whenever the array changes. */
|
|
7
|
+
events?: CalendarEvent[];
|
|
8
|
+
/**
|
|
9
|
+
* Loader mode: called for every visible-range change. Wins over `events`.
|
|
10
|
+
* The loader is read at fetch time, not captured when passed, so replacing this prop on every
|
|
11
|
+
* render does not by itself trigger a refetch; call `refetch()` when its inputs change.
|
|
12
|
+
*/
|
|
13
|
+
fetchEvents?: (range: CalendarRange) => Promise<CalendarEvent[]>;
|
|
14
|
+
view?: CalendarView;
|
|
15
|
+
date?: Date | string;
|
|
16
|
+
locale?: 'th' | 'en';
|
|
17
|
+
timeZone?: string;
|
|
18
|
+
toolbar?: CalendarToolbar | false;
|
|
19
|
+
height?: number | string;
|
|
20
|
+
slotMinTime?: string;
|
|
21
|
+
slotMaxTime?: string;
|
|
22
|
+
selectable?: boolean;
|
|
23
|
+
/** Last resort, FullCalendar-specific and unstable: merged over everything else. */
|
|
24
|
+
options?: Record<string, unknown>;
|
|
25
|
+
}
|
|
26
|
+
declare var __VLS_10: {
|
|
27
|
+
event: CalendarEvent;
|
|
28
|
+
timeText: any;
|
|
29
|
+
};
|
|
30
|
+
type __VLS_Slots = {} & {
|
|
31
|
+
event?: (props: typeof __VLS_10) => any;
|
|
32
|
+
};
|
|
33
|
+
declare const __VLS_base: import("vue").DefineComponent<Props, {
|
|
34
|
+
currentView: Readonly<import("vue").Ref<CalendarView, CalendarView>>;
|
|
35
|
+
currentRange: Readonly<import("vue").Ref<{
|
|
36
|
+
readonly start: Date;
|
|
37
|
+
readonly end: Date;
|
|
38
|
+
} | null, {
|
|
39
|
+
readonly start: Date;
|
|
40
|
+
readonly end: Date;
|
|
41
|
+
} | null>>;
|
|
42
|
+
title: Readonly<import("vue").Ref<string, string>>;
|
|
43
|
+
refetch: () => void | undefined;
|
|
44
|
+
gotoDate: (date: Date | string) => void | undefined;
|
|
45
|
+
changeView: (view: CalendarView) => void | undefined;
|
|
46
|
+
today: () => void | undefined;
|
|
47
|
+
prev: () => void | undefined;
|
|
48
|
+
next: () => void | undefined;
|
|
49
|
+
scrollToTime: (time: string) => void | undefined;
|
|
50
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
51
|
+
loading: (value: boolean) => any;
|
|
52
|
+
select: (value: {
|
|
53
|
+
start: Date;
|
|
54
|
+
end: Date;
|
|
55
|
+
allDay: boolean;
|
|
56
|
+
}) => any;
|
|
57
|
+
"event-click": (event: CalendarEvent) => any;
|
|
58
|
+
"date-click": (value: {
|
|
59
|
+
date: Date;
|
|
60
|
+
allDay: boolean;
|
|
61
|
+
}) => any;
|
|
62
|
+
"dates-set": (value: {
|
|
63
|
+
start: Date;
|
|
64
|
+
end: Date;
|
|
65
|
+
view: CalendarView;
|
|
66
|
+
}) => any;
|
|
67
|
+
"update:view": (value: CalendarView) => any;
|
|
68
|
+
"update:date": (value: Date) => any;
|
|
69
|
+
}, string, import("vue").PublicProps, Readonly<Props> & Readonly<{
|
|
70
|
+
onLoading?: ((value: boolean) => any) | undefined;
|
|
71
|
+
onSelect?: ((value: {
|
|
72
|
+
start: Date;
|
|
73
|
+
end: Date;
|
|
74
|
+
allDay: boolean;
|
|
75
|
+
}) => any) | undefined;
|
|
76
|
+
"onEvent-click"?: ((event: CalendarEvent) => any) | undefined;
|
|
77
|
+
"onDate-click"?: ((value: {
|
|
78
|
+
date: Date;
|
|
79
|
+
allDay: boolean;
|
|
80
|
+
}) => any) | undefined;
|
|
81
|
+
"onDates-set"?: ((value: {
|
|
82
|
+
start: Date;
|
|
83
|
+
end: Date;
|
|
84
|
+
view: CalendarView;
|
|
85
|
+
}) => any) | undefined;
|
|
86
|
+
"onUpdate:view"?: ((value: CalendarView) => any) | undefined;
|
|
87
|
+
"onUpdate:date"?: ((value: Date) => any) | undefined;
|
|
88
|
+
}>, {
|
|
89
|
+
height: number | string;
|
|
90
|
+
options: Record<string, unknown>;
|
|
91
|
+
view: CalendarView;
|
|
92
|
+
events: CalendarEvent[];
|
|
93
|
+
fetchEvents: (range: CalendarRange) => Promise<CalendarEvent[]>;
|
|
94
|
+
date: Date | string;
|
|
95
|
+
locale: "th" | "en";
|
|
96
|
+
timeZone: string;
|
|
97
|
+
toolbar: CalendarToolbar | false;
|
|
98
|
+
slotMinTime: string;
|
|
99
|
+
slotMaxTime: string;
|
|
100
|
+
selectable: boolean;
|
|
101
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
102
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
103
|
+
declare const _default: typeof __VLS_export;
|
|
104
|
+
export default _default;
|
|
105
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
106
|
+
new (): {
|
|
107
|
+
$slots: S;
|
|
108
|
+
};
|
|
109
|
+
};
|
|
@@ -22,9 +22,9 @@ declare const __VLS_export: import("vue").DefineComponent<Props, {}, {}, {}, {},
|
|
|
22
22
|
}, string, import("vue").PublicProps, Readonly<Props> & Readonly<{
|
|
23
23
|
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
24
24
|
}>, {
|
|
25
|
-
readonly: boolean;
|
|
26
25
|
locale: "TH" | "EN";
|
|
27
26
|
format: dateFormat | string;
|
|
27
|
+
readonly: boolean;
|
|
28
28
|
dense: boolean;
|
|
29
29
|
pickerOnly: boolean;
|
|
30
30
|
defaultDate: boolean | string;
|
|
@@ -22,9 +22,9 @@ declare const __VLS_export: import("vue").DefineComponent<Props, {}, {}, {}, {},
|
|
|
22
22
|
}, string, import("vue").PublicProps, Readonly<Props> & Readonly<{
|
|
23
23
|
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
24
24
|
}>, {
|
|
25
|
-
readonly: boolean;
|
|
26
25
|
locale: "TH" | "EN";
|
|
27
26
|
format: dateFormat | string;
|
|
27
|
+
readonly: boolean;
|
|
28
28
|
dense: boolean;
|
|
29
29
|
pickerOnly: boolean;
|
|
30
30
|
defaultDate: boolean | string;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export type CalendarView = 'month' | 'week' | 'day' | 'list'
|
|
2
|
+
export type CalendarToolbarToken = 'today' | 'prev' | 'next' | 'title' | CalendarView
|
|
3
|
+
|
|
4
|
+
export interface CalendarEvent {
|
|
5
|
+
id?: string | number | null
|
|
6
|
+
title?: string | null
|
|
7
|
+
/** ISO string with offset, or a Date. */
|
|
8
|
+
start: string | Date
|
|
9
|
+
end?: string | Date | null
|
|
10
|
+
allDay?: boolean | null
|
|
11
|
+
color?: string | null
|
|
12
|
+
display?: 'auto' | 'background' | null
|
|
13
|
+
// `any`, not `unknown`, is deliberate: consumers (e.g. his-ui) read into this without a guard,
|
|
14
|
+
// such as `event.extendedProps.patient.name`, and `unknown` fails that under vue-tsc.
|
|
15
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
16
|
+
extendedProps?: Record<string, any> | null
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface CalendarRange { start: Date, end: Date }
|
|
20
|
+
|
|
21
|
+
export interface CalendarToolbar {
|
|
22
|
+
left?: CalendarToolbarToken[]
|
|
23
|
+
center?: CalendarToolbarToken[]
|
|
24
|
+
right?: CalendarToolbarToken[]
|
|
25
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ramathibodi/nuxt-commons",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.24",
|
|
4
4
|
"description": "Ramathibodi Nuxt modules for common components",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -27,7 +27,6 @@
|
|
|
27
27
|
},
|
|
28
28
|
"./components/*": "./dist/runtime/components/*.vue",
|
|
29
29
|
"./components/*/*": "./dist/runtime/components/*/*.vue",
|
|
30
|
-
"./lab/*": "./dist/runtime/labs/*.vue",
|
|
31
30
|
"./lab/*/*": "./dist/runtime/labs/*/*.vue"
|
|
32
31
|
},
|
|
33
32
|
"main": "./dist/module.mjs",
|
|
@@ -73,13 +72,7 @@
|
|
|
73
72
|
"@codemirror/lang-vue": "^0.1.3",
|
|
74
73
|
"@codemirror/theme-one-dark": "^6.1.3",
|
|
75
74
|
"@fortawesome/fontawesome-free": "^6.7.2",
|
|
76
|
-
"@fullcalendar/
|
|
77
|
-
"@fullcalendar/daygrid": "^6.1.20",
|
|
78
|
-
"@fullcalendar/interaction": "^6.1.20",
|
|
79
|
-
"@fullcalendar/list": "^6.1.20",
|
|
80
|
-
"@fullcalendar/multimonth": "^6.1.20",
|
|
81
|
-
"@fullcalendar/timegrid": "^6.1.20",
|
|
82
|
-
"@fullcalendar/vue3": "^6.1.20",
|
|
75
|
+
"@fullcalendar/vue3": "^7.1.0",
|
|
83
76
|
"@graphql-codegen/add": "^5.0.3",
|
|
84
77
|
"@graphql-codegen/cli": "^6.1.3",
|
|
85
78
|
"@graphql-codegen/plugin-helpers": "^6.1.1",
|
|
@@ -108,6 +101,7 @@
|
|
|
108
101
|
"pdf-vue3": "^1.0.12",
|
|
109
102
|
"prettier": "3.3.2",
|
|
110
103
|
"print-js": "^1.6.0",
|
|
104
|
+
"temporal-polyfill": "^1.0.5",
|
|
111
105
|
"tesseract.js": "^6.0.1",
|
|
112
106
|
"uid": "^2.0.2",
|
|
113
107
|
"vue": "^3.5.30",
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
type Event = {
|
|
2
|
-
id: string | undefined;
|
|
3
|
-
title: string;
|
|
4
|
-
start: string;
|
|
5
|
-
end: string;
|
|
6
|
-
color: string;
|
|
7
|
-
detail?: string;
|
|
8
|
-
props: Record<string, any> | any[];
|
|
9
|
-
};
|
|
10
|
-
interface CalendarProps {
|
|
11
|
-
modelValue: Event[];
|
|
12
|
-
locale?: 'th' | 'en';
|
|
13
|
-
toolBarLeft?: string;
|
|
14
|
-
toolBarCenter?: string;
|
|
15
|
-
toolBarRight?: string;
|
|
16
|
-
height?: string | number;
|
|
17
|
-
selectViewDay?: string;
|
|
18
|
-
mode: 'dayGridMonth' | 'timeGridDay';
|
|
19
|
-
}
|
|
20
|
-
declare const __VLS_export: import("vue").DefineComponent<CalendarProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
21
|
-
dialog: (...args: any[]) => void;
|
|
22
|
-
select: (...args: any[]) => void;
|
|
23
|
-
}, string, import("vue").PublicProps, Readonly<CalendarProps> & Readonly<{
|
|
24
|
-
onDialog?: ((...args: any[]) => any) | undefined;
|
|
25
|
-
onSelect?: ((...args: any[]) => any) | undefined;
|
|
26
|
-
}>, {
|
|
27
|
-
height: string | number;
|
|
28
|
-
mode: "dayGridMonth" | "timeGridDay";
|
|
29
|
-
locale: "th" | "en";
|
|
30
|
-
toolBarLeft: string;
|
|
31
|
-
toolBarCenter: string;
|
|
32
|
-
toolBarRight: string;
|
|
33
|
-
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
34
|
-
declare const _default: typeof __VLS_export;
|
|
35
|
-
export default _default;
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
<script setup>
|
|
2
|
-
import FullCalendar from "@fullcalendar/vue3";
|
|
3
|
-
import dayGridPlugin from "@fullcalendar/daygrid";
|
|
4
|
-
import timeGridPlugin from "@fullcalendar/timegrid";
|
|
5
|
-
import listPlugin from "@fullcalendar/list";
|
|
6
|
-
import interactionPlugin from "@fullcalendar/interaction";
|
|
7
|
-
import { ref, computed } from "vue";
|
|
8
|
-
import {} from "@fullcalendar/core";
|
|
9
|
-
const props = defineProps({
|
|
10
|
-
modelValue: { type: Array, required: true },
|
|
11
|
-
locale: { type: String, required: false, default: "th" },
|
|
12
|
-
toolBarLeft: { type: String, required: false, default: "today prev,next" },
|
|
13
|
-
toolBarCenter: { type: String, required: false, default: "title" },
|
|
14
|
-
toolBarRight: { type: String, required: false, default: "timeGridDay,timeGridWeek,dayGridMonth" },
|
|
15
|
-
height: { type: [String, Number], required: false, default: 1200 },
|
|
16
|
-
selectViewDay: { type: String, required: false },
|
|
17
|
-
mode: { type: String, required: true, default: "dayGridMonth" }
|
|
18
|
-
});
|
|
19
|
-
const emit = defineEmits(["select", "dialog"]);
|
|
20
|
-
const buttonText = computed(() => {
|
|
21
|
-
return {
|
|
22
|
-
today: props.locale === "th" ? "\u0E27\u0E31\u0E19\u0E19\u0E35\u0E49" : "today",
|
|
23
|
-
month: props.locale === "th" ? "\u0E40\u0E14\u0E37\u0E2D\u0E19" : "month",
|
|
24
|
-
week: props.locale === "th" ? "\u0E2A\u0E31\u0E1B\u0E14\u0E32\u0E2B\u0E4C" : "week",
|
|
25
|
-
day: props.locale === "th" ? "\u0E27\u0E31\u0E19" : "day",
|
|
26
|
-
list: props.locale === "th" ? "\u0E23\u0E32\u0E22\u0E01\u0E32\u0E23" : "list",
|
|
27
|
-
year: props.locale === "th" ? "\u0E1B\u0E35" : "year"
|
|
28
|
-
};
|
|
29
|
-
});
|
|
30
|
-
const calendarRef = ref();
|
|
31
|
-
const dateViewDay = ref({ date: "", props: {} });
|
|
32
|
-
const handleDateClick = (info) => {
|
|
33
|
-
emit("select", info.event);
|
|
34
|
-
};
|
|
35
|
-
const handleEventClick = (info) => {
|
|
36
|
-
emit("dialog", true);
|
|
37
|
-
emit("select", info.event);
|
|
38
|
-
};
|
|
39
|
-
const eventContentDay = (arg) => {
|
|
40
|
-
const list = document.createElement("div");
|
|
41
|
-
list.innerHTML = document.getElementById(arg.event.id.toString())?.innerHTML || "";
|
|
42
|
-
return { domNodes: [list] };
|
|
43
|
-
};
|
|
44
|
-
const calendarOptions = ref({
|
|
45
|
-
plugins: [dayGridPlugin, timeGridPlugin, listPlugin, interactionPlugin],
|
|
46
|
-
initialView: props.mode,
|
|
47
|
-
locale: props.locale,
|
|
48
|
-
dayMaxEvents: true,
|
|
49
|
-
timeZone: "UTC",
|
|
50
|
-
headerToolbar: {
|
|
51
|
-
left: props.toolBarLeft,
|
|
52
|
-
center: props.toolBarCenter,
|
|
53
|
-
right: props.toolBarRight
|
|
54
|
-
},
|
|
55
|
-
buttonText: buttonText.value,
|
|
56
|
-
events: props.modelValue,
|
|
57
|
-
initialDate: props.selectViewDay,
|
|
58
|
-
dateClick: handleDateClick,
|
|
59
|
-
eventClick: handleEventClick,
|
|
60
|
-
nowIndicator: true,
|
|
61
|
-
height: props.height,
|
|
62
|
-
eventColor: "#378006"
|
|
63
|
-
});
|
|
64
|
-
</script>
|
|
65
|
-
|
|
66
|
-
<template>
|
|
67
|
-
<FullCalendar
|
|
68
|
-
ref="calendarRef"
|
|
69
|
-
:options="calendarOptions"
|
|
70
|
-
/>
|
|
71
|
-
</template>
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
type Event = {
|
|
2
|
-
id: string | undefined;
|
|
3
|
-
title: string;
|
|
4
|
-
start: string;
|
|
5
|
-
end: string;
|
|
6
|
-
color: string;
|
|
7
|
-
detail?: string;
|
|
8
|
-
props: Record<string, any> | any[];
|
|
9
|
-
};
|
|
10
|
-
interface CalendarProps {
|
|
11
|
-
modelValue: Event[];
|
|
12
|
-
locale?: 'th' | 'en';
|
|
13
|
-
toolBarLeft?: string;
|
|
14
|
-
toolBarCenter?: string;
|
|
15
|
-
toolBarRight?: string;
|
|
16
|
-
height?: string | number;
|
|
17
|
-
selectViewDay?: string;
|
|
18
|
-
mode: 'dayGridMonth' | 'timeGridDay';
|
|
19
|
-
}
|
|
20
|
-
declare const __VLS_export: import("vue").DefineComponent<CalendarProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
21
|
-
dialog: (...args: any[]) => void;
|
|
22
|
-
select: (...args: any[]) => void;
|
|
23
|
-
}, string, import("vue").PublicProps, Readonly<CalendarProps> & Readonly<{
|
|
24
|
-
onDialog?: ((...args: any[]) => any) | undefined;
|
|
25
|
-
onSelect?: ((...args: any[]) => any) | undefined;
|
|
26
|
-
}>, {
|
|
27
|
-
height: string | number;
|
|
28
|
-
mode: "dayGridMonth" | "timeGridDay";
|
|
29
|
-
locale: "th" | "en";
|
|
30
|
-
toolBarLeft: string;
|
|
31
|
-
toolBarCenter: string;
|
|
32
|
-
toolBarRight: string;
|
|
33
|
-
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
34
|
-
declare const _default: typeof __VLS_export;
|
|
35
|
-
export default _default;
|