nuxt-ui-elements-pro 0.1.0
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/README.md +1 -0
- package/dist/module.d.mts +14 -0
- package/dist/module.json +9 -0
- package/dist/module.mjs +178 -0
- package/dist/runtime/components/EventCalendar.d.vue.ts +97 -0
- package/dist/runtime/components/EventCalendar.vue +646 -0
- package/dist/runtime/components/EventCalendar.vue.d.ts +97 -0
- package/dist/runtime/composables/useEventCalendarDragDrop.d.ts +24 -0
- package/dist/runtime/composables/useEventCalendarDragDrop.js +116 -0
- package/dist/runtime/index.css +1 -0
- package/dist/runtime/index.d.ts +1 -0
- package/dist/runtime/index.js +1 -0
- package/dist/runtime/types/event-calendar.d.ts +92 -0
- package/dist/runtime/types/event-calendar.js +0 -0
- package/dist/runtime/types/index.d.ts +2 -0
- package/dist/runtime/types/index.js +2 -0
- package/dist/runtime/utils/event-calendar.d.ts +16 -0
- package/dist/runtime/utils/event-calendar.js +67 -0
- package/dist/runtime/utils/tv.d.ts +1 -0
- package/dist/runtime/utils/tv.js +2 -0
- package/dist/types.d.mts +5 -0
- package/package.json +68 -0
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
test
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
|
+
export * from '../dist/runtime/types/index.js';
|
|
3
|
+
|
|
4
|
+
interface ModuleOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Prefix for component names
|
|
7
|
+
* @default 'UE'
|
|
8
|
+
*/
|
|
9
|
+
prefix?: string;
|
|
10
|
+
}
|
|
11
|
+
declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
|
|
12
|
+
|
|
13
|
+
export { _default as default };
|
|
14
|
+
export type { ModuleOptions };
|
package/dist/module.json
ADDED
package/dist/module.mjs
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import { addTemplate, defineNuxtModule, createResolver, addImportsDir, addComponentsDir } from '@nuxt/kit';
|
|
2
|
+
import { kebabCase } from 'scule';
|
|
3
|
+
|
|
4
|
+
const eventCalendar = (options) => ({
|
|
5
|
+
slots: {
|
|
6
|
+
// Shared
|
|
7
|
+
root: "w-full border border-default rounded-lg bg-default",
|
|
8
|
+
header: "flex items-center justify-between px-4 py-3 border-b border-default",
|
|
9
|
+
headerTitle: "text-lg font-semibold text-highlighted",
|
|
10
|
+
headerActions: "flex items-center gap-1",
|
|
11
|
+
viewSwitcher: "flex items-center gap-0.5 bg-elevated rounded-lg p-0.5",
|
|
12
|
+
// Month view
|
|
13
|
+
weekdayRow: "grid grid-cols-7 border-b border-default",
|
|
14
|
+
weekdayCell: "py-2 text-center text-xs font-medium text-muted uppercase tracking-wider",
|
|
15
|
+
monthBody: "grid grid-cols-7",
|
|
16
|
+
dayCell: "min-h-24 border-b border-r border-default p-1 last-of-type:border-r-0 hover:bg-elevated/50 cursor-pointer",
|
|
17
|
+
dayCellOutside: "bg-muted/20",
|
|
18
|
+
dayNumber: "text-xs font-medium p-1 leading-none",
|
|
19
|
+
dayNumberToday: "inline-flex items-center justify-center size-6 rounded-full text-inverted font-semibold",
|
|
20
|
+
dayNumberOutside: "text-muted",
|
|
21
|
+
eventList: "space-y-1 mt-1",
|
|
22
|
+
eventChip: [
|
|
23
|
+
"text-xs px-1.5 py-1 rounded truncate cursor-pointer mb-0.5",
|
|
24
|
+
"border-l-2 text-[var(--event-color)] border-[var(--event-color)]"
|
|
25
|
+
],
|
|
26
|
+
eventTime: "font-medium mr-1",
|
|
27
|
+
moreEvents: "text-xs text-muted px-1.5 py-0.5 cursor-pointer hover:text-highlighted block w-full",
|
|
28
|
+
expandedOverlay: "absolute -m-1.5 min-h-[calc(100%+12px)] bg-default border border-default rounded-lg p-1.5 shadow-xl z-20 animate-expand-overlay",
|
|
29
|
+
// Week/Day view
|
|
30
|
+
columnHeaders: "flex border-b border-default",
|
|
31
|
+
timeGutterSpacer: "w-16 shrink-0 border-r border-default",
|
|
32
|
+
dayColumnHeader: "flex-1 bg-default py-2 text-center border-r border-default last:border-r-0",
|
|
33
|
+
dayColumnHeaderLabel: "text-xs font-medium text-muted uppercase",
|
|
34
|
+
dayColumnHeaderNumber: "text-lg font-semibold text-highlighted",
|
|
35
|
+
dayColumnHeaderToday: "inline-flex items-center justify-center size-8 rounded-full text-inverted font-semibold",
|
|
36
|
+
allDayRow: "flex border-b border-default min-h-8",
|
|
37
|
+
allDayLabel: "w-16 shrink-0 border-r border-default flex items-center justify-end pr-2 text-[10px] text-muted",
|
|
38
|
+
allDayCell: "flex-1 border-r border-default last:border-r-0 p-0.5 flex flex-wrap gap-0.5",
|
|
39
|
+
timeGrid: "relative flex items-start flex-1 overflow-auto h-[600px]",
|
|
40
|
+
timeGutter: "sticky left-0 z-10 w-16 shrink-0 bg-default border-r border-default",
|
|
41
|
+
timeGutterSlot: "relative border-b border-default/50",
|
|
42
|
+
timeLabel: "absolute top-0 right-0 px-2 mr-2 text-[10px] text-muted -translate-y-1/2 bg-default",
|
|
43
|
+
dayColumn: "flex-1 relative border-r border-default last:border-r-0",
|
|
44
|
+
timeSlotRow: "border-b border-default/50 transition-colors",
|
|
45
|
+
timeEvent: [
|
|
46
|
+
"absolute rounded px-1.5 py-0.5 text-xs cursor-pointer overflow-hidden",
|
|
47
|
+
"border-l-2 text-[var(--event-color)] border-[var(--event-color)]"
|
|
48
|
+
],
|
|
49
|
+
timeEventTitle: "font-medium truncate",
|
|
50
|
+
timeEventTime: "opacity-70 text-[10px]",
|
|
51
|
+
// Drag state
|
|
52
|
+
dropTarget: "ring-2 ring-dashed ring-offset-1",
|
|
53
|
+
dragSnapSlot: ""
|
|
54
|
+
},
|
|
55
|
+
variants: {
|
|
56
|
+
color: {
|
|
57
|
+
...Object.fromEntries((options.theme.colors || []).map((color) => [color, ""])),
|
|
58
|
+
neutral: ""
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
compoundVariants: [
|
|
62
|
+
...(options.theme.colors || []).map((color) => ({
|
|
63
|
+
color,
|
|
64
|
+
class: {
|
|
65
|
+
dayNumberToday: `bg-${color}`,
|
|
66
|
+
dayColumnHeaderToday: `bg-${color}`,
|
|
67
|
+
dropTarget: `ring-${color}`,
|
|
68
|
+
dragSnapSlot: `bg-${color}/10 ring-1 ring-inset ring-${color}/30`
|
|
69
|
+
}
|
|
70
|
+
})),
|
|
71
|
+
{
|
|
72
|
+
color: "neutral",
|
|
73
|
+
class: {
|
|
74
|
+
dayNumberToday: "bg-inverted",
|
|
75
|
+
dayColumnHeaderToday: "bg-inverted",
|
|
76
|
+
dropTarget: "ring-inverted",
|
|
77
|
+
dragSnapSlot: "bg-inverted/10 ring-1 ring-inset ring-inverted/30"
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
],
|
|
81
|
+
defaultVariants: {
|
|
82
|
+
color: "primary"
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
const theme = {
|
|
87
|
+
__proto__: null,
|
|
88
|
+
eventCalendar: eventCalendar
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
function addTemplates(options, _nuxt) {
|
|
92
|
+
const templates = [];
|
|
93
|
+
function writeThemeTemplate(themeModules) {
|
|
94
|
+
for (const component in themeModules) {
|
|
95
|
+
templates.push({
|
|
96
|
+
filename: `ui-elements-pro/${kebabCase(component)}.ts`,
|
|
97
|
+
write: true,
|
|
98
|
+
getContents: () => {
|
|
99
|
+
const template = themeModules[component];
|
|
100
|
+
const result = typeof template === "function" ? template(options) : template;
|
|
101
|
+
const variants = Object.entries(result.variants || {}).filter(([_, values]) => {
|
|
102
|
+
const keys = Object.keys(values);
|
|
103
|
+
return keys.some((key) => key !== "true" && key !== "false");
|
|
104
|
+
}).map(([key]) => key);
|
|
105
|
+
let json = JSON.stringify(result, null, 2);
|
|
106
|
+
for (const variant of variants) {
|
|
107
|
+
json = json.replace(new RegExp(`("${variant}": "[^"]+")`, "g"), `$1 as typeof ${variant}[number]`);
|
|
108
|
+
json = json.replace(new RegExp(`("${variant}": \\[\\s*)((?:"[^"]+",?\\s*)+)(\\])`, "g"), (_, before, match, after) => {
|
|
109
|
+
const replaced = match.replace(/("[^"]+")/g, `$1 as typeof ${variant}[number]`);
|
|
110
|
+
return `${before}${replaced}${after}`;
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
const variantDeclarations = variants.filter((variant) => json.includes(`as typeof ${variant}`)).map((variant) => {
|
|
114
|
+
const keys = Object.keys(result.variants[variant]);
|
|
115
|
+
return `const ${variant} = ${JSON.stringify(keys, null, 2)} as const`;
|
|
116
|
+
});
|
|
117
|
+
return [...variantDeclarations, `export default ${json}`].join("\n\n");
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
writeThemeTemplate(theme);
|
|
123
|
+
templates.push({
|
|
124
|
+
filename: "ui-elements-pro.css",
|
|
125
|
+
write: true,
|
|
126
|
+
getContents: () => {
|
|
127
|
+
return `@source "./ui-elements-pro";
|
|
128
|
+
|
|
129
|
+
@keyframes expand-overlay {
|
|
130
|
+
from {
|
|
131
|
+
margin: -1px;
|
|
132
|
+
min-height: calc(100% + 2px);
|
|
133
|
+
box-shadow: none;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
.animate-expand-overlay {
|
|
138
|
+
animation: expand-overlay 200ms ease-out both;
|
|
139
|
+
}
|
|
140
|
+
`;
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
templates.forEach((template) => addTemplate(template));
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
const module$1 = defineNuxtModule({
|
|
147
|
+
meta: {
|
|
148
|
+
name: "nuxt-ui-elements-pro",
|
|
149
|
+
configKey: "uiElementsPro"
|
|
150
|
+
},
|
|
151
|
+
defaults: {
|
|
152
|
+
prefix: "UE"
|
|
153
|
+
},
|
|
154
|
+
moduleDependencies: {
|
|
155
|
+
"nuxt-ui-elements": {}
|
|
156
|
+
},
|
|
157
|
+
setup(options, nuxt) {
|
|
158
|
+
const resolver = createResolver(import.meta.url);
|
|
159
|
+
const uiOptions = nuxt.options.ui;
|
|
160
|
+
const themeColors = uiOptions?.theme?.colors || ["primary", "secondary", "success", "info", "warning", "error"];
|
|
161
|
+
const optionsWithTheme = {
|
|
162
|
+
...options,
|
|
163
|
+
theme: {
|
|
164
|
+
colors: themeColors
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
addTemplates(optionsWithTheme);
|
|
168
|
+
nuxt.options.css.push(resolver.resolve("./runtime/index.css"));
|
|
169
|
+
addImportsDir(resolver.resolve("./runtime/composables"));
|
|
170
|
+
nuxt.options.alias["#ui-elements-pro"] = resolver.resolve("./runtime");
|
|
171
|
+
addComponentsDir({
|
|
172
|
+
path: resolver.resolve("./runtime/components"),
|
|
173
|
+
prefix: options.prefix
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
export { module$1 as default };
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import type { CalendarDate, DateValue } from "@internationalized/date";
|
|
2
|
+
import type { AppConfig } from "@nuxt/schema";
|
|
3
|
+
import theme from "#build/ui-elements-pro/event-calendar";
|
|
4
|
+
import type { ComponentConfig } from "nuxt-ui-elements";
|
|
5
|
+
import type { CalendarEvent, CalendarDay, MonthViewOptions, WeekViewOptions, DayViewOptions, EventDropPayload } from "../types/event-calendar.js";
|
|
6
|
+
type EventCalendar = ComponentConfig<typeof theme, AppConfig, "eventCalendar">;
|
|
7
|
+
export interface EventCalendarProps {
|
|
8
|
+
/** Array of events to display */
|
|
9
|
+
events?: CalendarEvent[];
|
|
10
|
+
/** Currently displayed date. Controls which month/week/day is shown. Supports v-model. */
|
|
11
|
+
modelValue?: Date | string | DateValue;
|
|
12
|
+
/** Calendar view mode @defaultValue 'month' */
|
|
13
|
+
view?: "month" | "week" | "day";
|
|
14
|
+
/** Locale for day/month names @defaultValue 'en-US' */
|
|
15
|
+
locale?: string;
|
|
16
|
+
/** Day the week starts on @defaultValue 0 */
|
|
17
|
+
weekStartsOn?: 0 | 1;
|
|
18
|
+
/** Enable drag-and-drop globally @defaultValue true */
|
|
19
|
+
editable?: boolean;
|
|
20
|
+
/** Theme color for calendar chrome @defaultValue 'primary' */
|
|
21
|
+
color?: EventCalendar["variants"]["color"];
|
|
22
|
+
/** Month view options */
|
|
23
|
+
monthOptions?: MonthViewOptions;
|
|
24
|
+
/** Week view options */
|
|
25
|
+
weekOptions?: WeekViewOptions;
|
|
26
|
+
/** Day view options */
|
|
27
|
+
dayOptions?: DayViewOptions;
|
|
28
|
+
/** Slot class overrides */
|
|
29
|
+
ui?: EventCalendar["slots"];
|
|
30
|
+
}
|
|
31
|
+
export interface EventCalendarEmits {
|
|
32
|
+
/** Fires when the displayed date changes */
|
|
33
|
+
"update:modelValue": [value: CalendarDate];
|
|
34
|
+
/** Fires when the view changes */
|
|
35
|
+
"update:view": [value: "month" | "week" | "day"];
|
|
36
|
+
/** Fires when a date cell is clicked */
|
|
37
|
+
dateClick: [date: CalendarDate];
|
|
38
|
+
/** Fires when an event is clicked */
|
|
39
|
+
eventClick: [event: CalendarEvent];
|
|
40
|
+
/** Fires after drag-and-drop */
|
|
41
|
+
eventDrop: [payload: EventDropPayload];
|
|
42
|
+
}
|
|
43
|
+
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;
|
|
77
|
+
}
|
|
78
|
+
declare const _default: typeof __VLS_export;
|
|
79
|
+
export default _default;
|
|
80
|
+
declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<EventCalendarProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
81
|
+
"update:modelValue": (value: CalendarDate) => any;
|
|
82
|
+
"update:view": (value: "day" | "week" | "month") => any;
|
|
83
|
+
dateClick: (date: CalendarDate) => any;
|
|
84
|
+
eventClick: (event: CalendarEvent) => any;
|
|
85
|
+
eventDrop: (payload: EventDropPayload) => any;
|
|
86
|
+
}, string, import("vue").PublicProps, Readonly<EventCalendarProps> & Readonly<{
|
|
87
|
+
"onUpdate:modelValue"?: ((value: CalendarDate) => any) | undefined;
|
|
88
|
+
"onUpdate:view"?: ((value: "day" | "week" | "month") => any) | undefined;
|
|
89
|
+
onDateClick?: ((date: CalendarDate) => any) | undefined;
|
|
90
|
+
onEventClick?: ((event: CalendarEvent) => any) | undefined;
|
|
91
|
+
onEventDrop?: ((payload: EventDropPayload) => any) | undefined;
|
|
92
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, EventCalendarSlots>;
|
|
93
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
94
|
+
new (): {
|
|
95
|
+
$slots: S;
|
|
96
|
+
};
|
|
97
|
+
};
|