nuxt-ui-elements-pro 0.1.4 → 0.1.6

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.
Files changed (39) hide show
  1. package/dist/module.json +1 -1
  2. package/dist/module.mjs +50 -15
  3. package/dist/runtime/components/EventCalendar.d.vue.ts +48 -42
  4. package/dist/runtime/components/EventCalendar.vue +116 -606
  5. package/dist/runtime/components/EventCalendar.vue.d.ts +48 -42
  6. package/dist/runtime/components/EventCalendarHeader.d.vue.ts +26 -0
  7. package/dist/runtime/components/EventCalendarHeader.vue +48 -0
  8. package/dist/runtime/components/EventCalendarHeader.vue.d.ts +26 -0
  9. package/dist/runtime/components/EventCalendarListView.d.vue.ts +25 -0
  10. package/dist/runtime/components/EventCalendarListView.vue +95 -0
  11. package/dist/runtime/components/EventCalendarListView.vue.d.ts +25 -0
  12. package/dist/runtime/components/EventCalendarMonthView.d.vue.ts +34 -0
  13. package/dist/runtime/components/EventCalendarMonthView.vue +336 -0
  14. package/dist/runtime/components/EventCalendarMonthView.vue.d.ts +34 -0
  15. package/dist/runtime/components/EventCalendarTimeGrid.d.vue.ts +31 -0
  16. package/dist/runtime/components/EventCalendarTimeGrid.vue +306 -0
  17. package/dist/runtime/components/EventCalendarTimeGrid.vue.d.ts +31 -0
  18. package/dist/runtime/composables/useEventCalendar.d.ts +52 -0
  19. package/dist/runtime/composables/useEventCalendar.js +362 -0
  20. package/dist/runtime/composables/useEventCalendarContext.d.ts +8 -0
  21. package/dist/runtime/composables/useEventCalendarContext.js +11 -0
  22. package/dist/runtime/composables/useEventCalendarDragDrop.d.ts +1 -1
  23. package/dist/runtime/composables/useEventCalendarDragDrop.js +11 -9
  24. package/dist/runtime/composables/useEventCalendarKeyboard.d.ts +20 -0
  25. package/dist/runtime/composables/useEventCalendarKeyboard.js +128 -0
  26. package/dist/runtime/composables/useEventCalendarResize.d.ts +31 -0
  27. package/dist/runtime/composables/useEventCalendarResize.js +87 -0
  28. package/dist/runtime/composables/useEventCalendarSelect.d.ts +21 -0
  29. package/dist/runtime/composables/useEventCalendarSelect.js +119 -0
  30. package/dist/runtime/index.d.ts +2 -0
  31. package/dist/runtime/index.js +1 -0
  32. package/dist/runtime/types/event-calendar.d.ts +169 -0
  33. package/dist/runtime/types/index.d.ts +4 -0
  34. package/dist/runtime/types/index.js +4 -0
  35. package/dist/runtime/utils/event-calendar.d.ts +22 -1
  36. package/dist/runtime/utils/event-calendar.js +199 -1
  37. package/dist/runtime/utils/recurrence.d.ts +30 -0
  38. package/dist/runtime/utils/recurrence.js +150 -0
  39. package/package.json +15 -6
@@ -1,22 +1,29 @@
1
1
  import type { CalendarDate, DateValue } from "@internationalized/date";
2
2
  import type { AppConfig } from "@nuxt/schema";
3
- import theme from "#build/ui-elements-pro/event-calendar";
4
3
  import type { ComponentConfig } from "nuxt-ui-elements";
5
- import type { CalendarEvent, CalendarDay, MonthViewOptions, WeekViewOptions, DayViewOptions, EventDropPayload } from "../types/event-calendar.js";
4
+ import type { CalendarEvent, CalendarView, MonthViewOptions, WeekViewOptions, DayViewOptions, EventDropPayload, EventResizePayload, SelectPayload, EventCalendarContext } from "../types/event-calendar.js";
5
+ import { type Component } from "vue";
6
+ import theme from "#build/ui-elements-pro/event-calendar";
6
7
  type EventCalendar = ComponentConfig<typeof theme, AppConfig, "eventCalendar">;
7
8
  export interface EventCalendarProps {
9
+ /** Rendered element type @defaultValue 'div' */
10
+ as?: string | Component;
8
11
  /** Array of events to display */
9
12
  events?: CalendarEvent[];
10
13
  /** Currently displayed date. Controls which month/week/day is shown. Supports v-model. */
11
14
  modelValue?: Date | string | DateValue;
12
15
  /** Calendar view mode @defaultValue 'month' */
13
- view?: "month" | "week" | "day";
16
+ view?: CalendarView;
14
17
  /** Locale for day/month names @defaultValue 'en-US' */
15
18
  locale?: string;
16
- /** Day the week starts on @defaultValue 0 */
17
- weekStartsOn?: 0 | 1;
19
+ /** Day the week starts on (0=Sun, 1=Mon, … 6=Sat) @defaultValue 0 */
20
+ weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6;
18
21
  /** Enable drag-and-drop globally @defaultValue true */
19
22
  editable?: boolean;
23
+ /** Show loading overlay @defaultValue false */
24
+ loading?: boolean;
25
+ /** Enable click/drag date range selection @defaultValue true */
26
+ selectable?: boolean;
20
27
  /** Theme color for calendar chrome @defaultValue 'primary' */
21
28
  color?: EventCalendar["variants"]["color"];
22
29
  /** Month view options */
@@ -32,64 +39,63 @@ export interface EventCalendarEmits {
32
39
  /** Fires when the displayed date changes */
33
40
  "update:modelValue": [value: CalendarDate];
34
41
  /** Fires when the view changes */
35
- "update:view": [value: "month" | "week" | "day"];
42
+ "update:view": [value: CalendarView];
36
43
  /** Fires when a date cell is clicked */
37
44
  dateClick: [date: CalendarDate];
38
45
  /** Fires when an event is clicked */
39
46
  eventClick: [event: CalendarEvent];
40
47
  /** Fires after drag-and-drop */
41
48
  eventDrop: [payload: EventDropPayload];
49
+ /** Fires after resize */
50
+ eventResize: [payload: EventResizePayload];
51
+ /** Fires when resize starts */
52
+ eventResizeStart: [payload: {
53
+ event: CalendarEvent;
54
+ }];
55
+ /** Fires when resize ends */
56
+ eventResizeEnd: [payload: {
57
+ event: CalendarEvent;
58
+ }];
59
+ /** Fires after a click or drag date range selection */
60
+ select: [payload: SelectPayload];
42
61
  }
43
62
  export interface EventCalendarSlots {
44
- header: (props: {
45
- title: string;
46
- prev: () => void;
47
- next: () => void;
48
- today: () => void;
49
- currentDate: CalendarDate;
50
- view: "month" | "week" | "day";
51
- setView: (v: "month" | "week" | "day") => void;
52
- }) => any;
53
- "day-header": (props: {
54
- day: string;
55
- index: number;
56
- }) => any;
57
- day: (props: {
58
- day: CalendarDay;
59
- }) => any;
60
- event: (props: {
61
- event: CalendarEvent;
62
- view: "month" | "week" | "day";
63
- }) => any;
64
- "more-events": (props: {
65
- events: CalendarEvent[];
66
- count: number;
67
- day: CalendarDay;
68
- }) => any;
69
- "time-label": (props: {
70
- hour: number;
71
- label: string;
72
- }) => any;
73
- "all-day": (props: {
74
- events: CalendarEvent[];
75
- date: CalendarDate;
76
- }) => any;
63
+ default: (props: EventCalendarContext) => any;
77
64
  }
78
65
  declare const _default: typeof __VLS_export;
79
66
  export default _default;
80
67
  declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<EventCalendarProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
68
+ select: (payload: SelectPayload) => any;
81
69
  "update:modelValue": (value: CalendarDate) => any;
82
- "update:view": (value: "day" | "month" | "week") => any;
70
+ "update:view": (value: CalendarView) => any;
83
71
  dateClick: (date: CalendarDate) => any;
84
72
  eventClick: (event: CalendarEvent) => any;
85
73
  eventDrop: (payload: EventDropPayload) => any;
74
+ eventResize: (payload: EventResizePayload) => any;
75
+ eventResizeStart: (payload: {
76
+ event: CalendarEvent;
77
+ }) => any;
78
+ eventResizeEnd: (payload: {
79
+ event: CalendarEvent;
80
+ }) => any;
86
81
  }, string, import("vue").PublicProps, Readonly<EventCalendarProps> & Readonly<{
82
+ onSelect?: ((payload: SelectPayload) => any) | undefined;
87
83
  "onUpdate:modelValue"?: ((value: CalendarDate) => any) | undefined;
88
- "onUpdate:view"?: ((value: "day" | "month" | "week") => any) | undefined;
84
+ "onUpdate:view"?: ((value: CalendarView) => any) | undefined;
89
85
  onDateClick?: ((date: CalendarDate) => any) | undefined;
90
86
  onEventClick?: ((event: CalendarEvent) => any) | undefined;
91
87
  onEventDrop?: ((payload: EventDropPayload) => any) | undefined;
92
- }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, EventCalendarSlots>;
88
+ onEventResize?: ((payload: EventResizePayload) => any) | undefined;
89
+ onEventResizeStart?: ((payload: {
90
+ event: CalendarEvent;
91
+ }) => any) | undefined;
92
+ onEventResizeEnd?: ((payload: {
93
+ event: CalendarEvent;
94
+ }) => any) | undefined;
95
+ }>, {
96
+ editable: boolean;
97
+ selectable: boolean;
98
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, EventCalendarSlots>;
93
99
  type __VLS_WithSlots<T, S> = T & {
94
100
  new (): {
95
101
  $slots: S;
@@ -0,0 +1,26 @@
1
+ import type { CalendarDate } from "@internationalized/date";
2
+ import type { CalendarView } from "../types/event-calendar.js";
3
+ import type { Component } from "vue";
4
+ export interface EventCalendarHeaderProps {
5
+ /** Rendered element type @defaultValue 'div' */
6
+ as?: string | Component;
7
+ }
8
+ export interface EventCalendarHeaderSlots {
9
+ default: (props: {
10
+ title: string;
11
+ prev: () => void;
12
+ next: () => void;
13
+ today: () => void;
14
+ currentDate: CalendarDate;
15
+ view: CalendarView;
16
+ setView: (v: CalendarView) => void;
17
+ }) => any;
18
+ }
19
+ declare const _default: typeof __VLS_export;
20
+ export default _default;
21
+ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<EventCalendarHeaderProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<EventCalendarHeaderProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, EventCalendarHeaderSlots>;
22
+ type __VLS_WithSlots<T, S> = T & {
23
+ new (): {
24
+ $slots: S;
25
+ };
26
+ };
@@ -0,0 +1,48 @@
1
+ <script>
2
+ import { Primitive } from "reka-ui";
3
+ import { useEventCalendarContext } from "../composables/useEventCalendarContext";
4
+ </script>
5
+
6
+ <script setup>
7
+ const props = defineProps({
8
+ as: { type: null, required: false }
9
+ });
10
+ defineSlots();
11
+ const ctx = useEventCalendarContext();
12
+ </script>
13
+
14
+ <template>
15
+ <Primitive :as="props.as ?? 'div'" data-slot="header" :class="ctx.ui.value.header({ class: ctx.propUi.value?.header })">
16
+ <slot
17
+ :title="ctx.headerTitle.value"
18
+ :prev="ctx.goToPrev"
19
+ :next="ctx.goToNext"
20
+ :today="ctx.goToToday"
21
+ :current-date="ctx.displayDate.value"
22
+ :view="ctx.view.value"
23
+ :set-view="ctx.setView">
24
+ <span data-slot="headerTitle" :class="ctx.ui.value.headerTitle({ class: ctx.propUi.value?.headerTitle })" aria-live="polite" aria-atomic="true">
25
+ {{ ctx.headerTitle.value }}
26
+ </span>
27
+
28
+ <div data-slot="headerActions" :class="ctx.ui.value.headerActions({ class: ctx.propUi.value?.headerActions })">
29
+ <div data-slot="viewSwitcher" role="group" aria-label="Calendar view" :class="ctx.ui.value.viewSwitcher({ class: ctx.propUi.value?.viewSwitcher })">
30
+ <UButton
31
+ v-for="v in ['month', 'week', 'day', 'list']"
32
+ :key="v"
33
+ :label="v"
34
+ size="xs"
35
+ :color="ctx.view.value === v ? ctx.color.value : 'neutral'"
36
+ :variant="ctx.view.value === v ? 'subtle' : 'ghost'"
37
+ :aria-pressed="ctx.view.value === v"
38
+ class="capitalize"
39
+ @click="ctx.setView(v)" />
40
+ </div>
41
+
42
+ <UButton icon="i-lucide-chevron-left" color="neutral" variant="ghost" size="xs" square :aria-label="`Previous ${ctx.view.value}`" @click="ctx.goToPrev" />
43
+ <UButton label="Today" color="neutral" variant="ghost" size="xs" aria-label="Go to today" @click="ctx.goToToday" />
44
+ <UButton icon="i-lucide-chevron-right" color="neutral" variant="ghost" size="xs" square :aria-label="`Next ${ctx.view.value}`" @click="ctx.goToNext" />
45
+ </div>
46
+ </slot>
47
+ </Primitive>
48
+ </template>
@@ -0,0 +1,26 @@
1
+ import type { CalendarDate } from "@internationalized/date";
2
+ import type { CalendarView } from "../types/event-calendar.js";
3
+ import type { Component } from "vue";
4
+ export interface EventCalendarHeaderProps {
5
+ /** Rendered element type @defaultValue 'div' */
6
+ as?: string | Component;
7
+ }
8
+ export interface EventCalendarHeaderSlots {
9
+ default: (props: {
10
+ title: string;
11
+ prev: () => void;
12
+ next: () => void;
13
+ today: () => void;
14
+ currentDate: CalendarDate;
15
+ view: CalendarView;
16
+ setView: (v: CalendarView) => void;
17
+ }) => any;
18
+ }
19
+ declare const _default: typeof __VLS_export;
20
+ export default _default;
21
+ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<EventCalendarHeaderProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<EventCalendarHeaderProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, EventCalendarHeaderSlots>;
22
+ type __VLS_WithSlots<T, S> = T & {
23
+ new (): {
24
+ $slots: S;
25
+ };
26
+ };
@@ -0,0 +1,25 @@
1
+ import type { CalendarEvent, CalendarView, CalendarDay } from "../types/event-calendar.js";
2
+ import type { Component } from "vue";
3
+ export interface EventCalendarListViewProps {
4
+ /** Rendered element type @defaultValue 'div' */
5
+ as?: string | Component;
6
+ }
7
+ export interface EventCalendarListViewSlots {
8
+ "date-header": (props: {
9
+ day: CalendarDay;
10
+ weekday: string;
11
+ dateLabel: string;
12
+ }) => any;
13
+ event: (props: {
14
+ event: CalendarEvent;
15
+ view: CalendarView;
16
+ }) => any;
17
+ }
18
+ declare const _default: typeof __VLS_export;
19
+ export default _default;
20
+ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<EventCalendarListViewProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<EventCalendarListViewProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, EventCalendarListViewSlots>;
21
+ type __VLS_WithSlots<T, S> = T & {
22
+ new (): {
23
+ $slots: S;
24
+ };
25
+ };
@@ -0,0 +1,95 @@
1
+ <script>
2
+ import { Primitive } from "reka-ui";
3
+ import { useEventCalendarContext } from "../composables/useEventCalendarContext";
4
+ </script>
5
+
6
+ <script setup>
7
+ import { computed } from "vue";
8
+ import { format } from "#std/date";
9
+ const props = defineProps({
10
+ as: { type: null, required: false }
11
+ });
12
+ defineSlots();
13
+ const ctx = useEventCalendarContext();
14
+ const daysWithEvents = computed(
15
+ () => ctx.listDays.value.filter((day) => day.events.length > 0)
16
+ );
17
+ function formatWeekday(day) {
18
+ return format(day.date, "dddd", ctx.locale.value);
19
+ }
20
+ function formatDateLabel(day) {
21
+ return format(day.date, "MMMM D, YYYY", ctx.locale.value);
22
+ }
23
+ </script>
24
+
25
+ <template>
26
+ <Primitive v-if="ctx.view.value === 'list'" :as="props.as ?? 'div'" data-slot="listView">
27
+ <div data-slot="listBody" :class="ctx.ui.value.listBody({ class: ctx.propUi.value?.listBody })">
28
+ <template v-if="daysWithEvents.length > 0">
29
+ <template v-for="day in daysWithEvents" :key="day.date.toString()">
30
+ <!-- Date header -->
31
+ <div
32
+ data-slot="listDateHeader"
33
+ :class="ctx.ui.value.listDateHeader({ class: ctx.propUi.value?.listDateHeader })">
34
+ <slot name="date-header" :day="day" :weekday="formatWeekday(day)" :date-label="formatDateLabel(day)">
35
+ <span
36
+ data-slot="listDateWeekday"
37
+ :class="ctx.ui.value.listDateWeekday({ class: ctx.propUi.value?.listDateWeekday })">
38
+ {{ formatWeekday(day) }}
39
+ </span>
40
+ <span
41
+ data-slot="listDateLabel"
42
+ :class="ctx.ui.value.listDateLabel({ class: ctx.propUi.value?.listDateLabel })">
43
+ {{ formatDateLabel(day) }}
44
+ </span>
45
+ </slot>
46
+ </div>
47
+
48
+ <!-- Event rows -->
49
+ <div
50
+ v-for="event in day.events"
51
+ :key="event.id"
52
+ data-slot="listEventRow"
53
+ role="button"
54
+ :aria-label="ctx.formatEventAriaLabel(event)"
55
+ tabindex="0"
56
+ :class="ctx.ui.value.listEventRow({ class: ctx.propUi.value?.listEventRow })"
57
+ @click="ctx.handleEventClick(event, $event)"
58
+ @keydown.enter.stop="ctx.handleEventClick(event, $event)"
59
+ @keydown.space.prevent.stop="ctx.handleEventClick(event, $event)">
60
+ <slot name="event" :event="event.original" :view="ctx.view.value">
61
+ <span
62
+ data-slot="listEventTime"
63
+ :class="ctx.ui.value.listEventTime({ class: ctx.propUi.value?.listEventTime })">
64
+ {{ event.allDay ? "all day" : ctx.formatTimeRange(event.start, event.end) }}
65
+ </span>
66
+ <span
67
+ data-slot="listEventDot"
68
+ :class="ctx.ui.value.listEventDot({ class: ctx.propUi.value?.listEventDot })"
69
+ :style="{ backgroundColor: `var(--ui-${event.color === 'neutral' ? 'bg-inverted' : event.color})` }" />
70
+ <span
71
+ data-slot="listEventTitle"
72
+ :class="ctx.ui.value.listEventTitle({ class: ctx.propUi.value?.listEventTitle })">
73
+ <UIcon
74
+ v-if="event.recurringEventId"
75
+ name="i-lucide-repeat"
76
+ data-slot="recurringIcon"
77
+ :class="ctx.ui.value.recurringIcon({ class: ctx.propUi.value?.recurringIcon })"
78
+ aria-hidden="true" />
79
+ {{ event.title }}
80
+ </span>
81
+ </slot>
82
+ </div>
83
+ </template>
84
+ </template>
85
+
86
+ <!-- Empty state -->
87
+ <div
88
+ v-else
89
+ data-slot="listEmpty"
90
+ :class="ctx.ui.value.listEmpty({ class: ctx.propUi.value?.listEmpty })">
91
+ No events this week
92
+ </div>
93
+ </div>
94
+ </Primitive>
95
+ </template>
@@ -0,0 +1,25 @@
1
+ import type { CalendarEvent, CalendarView, CalendarDay } from "../types/event-calendar.js";
2
+ import type { Component } from "vue";
3
+ export interface EventCalendarListViewProps {
4
+ /** Rendered element type @defaultValue 'div' */
5
+ as?: string | Component;
6
+ }
7
+ export interface EventCalendarListViewSlots {
8
+ "date-header": (props: {
9
+ day: CalendarDay;
10
+ weekday: string;
11
+ dateLabel: string;
12
+ }) => any;
13
+ event: (props: {
14
+ event: CalendarEvent;
15
+ view: CalendarView;
16
+ }) => any;
17
+ }
18
+ declare const _default: typeof __VLS_export;
19
+ export default _default;
20
+ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<EventCalendarListViewProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<EventCalendarListViewProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, EventCalendarListViewSlots>;
21
+ type __VLS_WithSlots<T, S> = T & {
22
+ new (): {
23
+ $slots: S;
24
+ };
25
+ };
@@ -0,0 +1,34 @@
1
+ import type { CalendarEvent, CalendarView, CalendarDay } from "../types/event-calendar.js";
2
+ import { type Component } from "vue";
3
+ export interface EventCalendarMonthViewProps {
4
+ /** Rendered element type @defaultValue 'div' */
5
+ as?: string | Component;
6
+ }
7
+ export interface EventCalendarMonthViewSlots {
8
+ "day-header": (props: {
9
+ day: string;
10
+ index: number;
11
+ }) => any;
12
+ day: (props: {
13
+ day: CalendarDay;
14
+ }) => any;
15
+ event: (props: {
16
+ event: CalendarEvent;
17
+ view: CalendarView;
18
+ }) => any;
19
+ "more-events": (props: {
20
+ events: CalendarEvent[];
21
+ count: number;
22
+ day: CalendarDay;
23
+ }) => any;
24
+ loading: () => any;
25
+ empty: () => any;
26
+ }
27
+ declare const _default: typeof __VLS_export;
28
+ export default _default;
29
+ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<EventCalendarMonthViewProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<EventCalendarMonthViewProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, EventCalendarMonthViewSlots>;
30
+ type __VLS_WithSlots<T, S> = T & {
31
+ new (): {
32
+ $slots: S;
33
+ };
34
+ };