@svar-ui/svelte-calendar 2.6.0 → 2.7.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/dist/components/Calendar.svelte +13 -4
- package/dist/components/Calendar.svelte.d.ts +50 -19
- package/dist/components/ContextMenu.svelte +13 -5
- package/dist/components/Editor.svelte +29 -34
- package/dist/components/EventDatesForm.svelte +121 -0
- package/dist/components/EventDatesForm.svelte.d.ts +15 -0
- package/dist/components/Layout.svelte +18 -5
- package/dist/components/Layout.svelte.d.ts +2 -0
- package/dist/components/Navigation.svelte +20 -12
- package/dist/components/Navigation.svelte.d.ts +1 -0
- package/dist/components/Render/BarSection.svelte +3 -0
- package/dist/components/Render/EventProjection.svelte +36 -0
- package/dist/components/Render/EventProjection.svelte.d.ts +9 -0
- package/dist/components/Render/GridSection.svelte +5 -2
- package/dist/components/Render/GridSection.svelte.d.ts +2 -1
- package/dist/components/Render/ScrollableSection.svelte +22 -3
- package/dist/components/Render/ScrollableSection.svelte.d.ts +1 -0
- package/dist/components/Render/SectionContent.svelte +1 -0
- package/dist/components/Render/Sections.svelte +46 -9
- package/dist/components/Render/Sections.svelte.d.ts +1 -0
- package/dist/components/Render/YearSection.svelte +8 -1
- package/dist/components/Render/resolveEventPosition.d.ts +5 -0
- package/dist/components/Render/resolveEventPosition.js +35 -0
- package/dist/components/pro_RecurringForm.svelte +346 -0
- package/dist/components/pro_RecurringForm.svelte.d.ts +15 -0
- package/dist/components/pro_rrule-form.d.ts +23 -0
- package/dist/components/pro_rrule-form.js +121 -0
- package/dist/components/{Render/useEventOverlay.svelte.d.ts → useEventOverlay.svelte.d.ts} +1 -1
- package/dist/components/{Render/useEventOverlay.svelte.js → useEventOverlay.svelte.js} +1 -1
- package/dist/context.tx +0 -0
- package/dist/defaults.d.ts +18 -0
- package/dist/defaults.js +15 -0
- package/dist/directives/clickevent.d.ts +1 -0
- package/dist/directives/clickevent.js +11 -8
- package/dist/directives/drag.js +11 -7
- package/dist/directives/dragresize.js +6 -3
- package/dist/helpers/pro_export.d.ts +5 -0
- package/dist/helpers/pro_export.js +22 -0
- package/dist/index.d.ts +5 -4
- package/dist/index.js +4 -2
- package/dist/pro_export/Calendar.svelte +30 -0
- package/dist/pro_export/Calendar.svelte.d.ts +16 -0
- package/dist/pro_export/Event.svelte +5 -0
- package/dist/pro_export/Event.svelte.d.ts +11 -0
- package/dist/pro_export.d.ts +3 -0
- package/dist/pro_export.js +15 -0
- package/dist/themes/Print.svelte +89 -0
- package/dist/themes/Print.svelte.d.ts +13 -0
- package/dist/themes/PrintBW.svelte +111 -0
- package/dist/themes/PrintBW.svelte.d.ts +13 -0
- package/dist/{components/types.d.ts → types.d.ts} +5 -0
- package/package.json +17 -17
- package/readme.md +2 -2
- package/dist/Demo.svelte +0 -7
- package/dist/Demo.svelte.d.ts +0 -26
- package/dist/components/editorItems.d.ts +0 -15
- package/dist/components/editorItems.js +0 -20
- package/dist/init.d.ts +0 -1
- package/dist/init.js +0 -5
- /package/dist/{components/types.js → types.js} +0 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export default ProRecurringForm;
|
|
2
|
+
type ProRecurringForm = {
|
|
3
|
+
$on?(type: string, callback: (e: any) => void): () => void;
|
|
4
|
+
$set?(props: Partial<$$ComponentProps>): void;
|
|
5
|
+
};
|
|
6
|
+
declare const ProRecurringForm: import("svelte").Component<{
|
|
7
|
+
value: any;
|
|
8
|
+
error: any;
|
|
9
|
+
onchange: any;
|
|
10
|
+
}, {}, "">;
|
|
11
|
+
type $$ComponentProps = {
|
|
12
|
+
value: any;
|
|
13
|
+
error: any;
|
|
14
|
+
onchange: any;
|
|
15
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { RecurrenceFrequency } from "@svar-ui/calendar-store";
|
|
2
|
+
export type Frequency = RecurrenceFrequency;
|
|
3
|
+
export type Weekday = "MO" | "TU" | "WE" | "TH" | "FR" | "SA" | "SU";
|
|
4
|
+
export type RecurrenceForm = {
|
|
5
|
+
type: "never" | "daily" | "weekly" | "monthly" | "yearly" | "workdays" | "custom";
|
|
6
|
+
freq: Frequency;
|
|
7
|
+
interval: number;
|
|
8
|
+
weekdays: Weekday[];
|
|
9
|
+
monthMode: "day" | "weekday";
|
|
10
|
+
ends: "never" | "count" | "until";
|
|
11
|
+
count: number;
|
|
12
|
+
until: Date | null;
|
|
13
|
+
};
|
|
14
|
+
export declare const WEEKDAYS: {
|
|
15
|
+
id: Weekday;
|
|
16
|
+
label: string;
|
|
17
|
+
}[];
|
|
18
|
+
export declare function weekdayOf(date: Date): Weekday;
|
|
19
|
+
export declare function weekdayName(day: Weekday): string;
|
|
20
|
+
export declare function nthOf(date: Date): number;
|
|
21
|
+
export declare function nthLabel(value: number): string;
|
|
22
|
+
export declare function parseRRule(rrule?: string, start?: Date): RecurrenceForm;
|
|
23
|
+
export declare function buildRRule(form: RecurrenceForm, start: Date): string;
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { parseRRule as parseRule, serializeRRule } from "@svar-ui/calendar-store";
|
|
2
|
+
export const WEEKDAYS = [
|
|
3
|
+
{ id: "MO", label: "Mon" },
|
|
4
|
+
{ id: "TU", label: "Tue" },
|
|
5
|
+
{ id: "WE", label: "Wed" },
|
|
6
|
+
{ id: "TH", label: "Thu" },
|
|
7
|
+
{ id: "FR", label: "Fri" },
|
|
8
|
+
{ id: "SA", label: "Sat" },
|
|
9
|
+
{ id: "SU", label: "Sun" },
|
|
10
|
+
];
|
|
11
|
+
const DAY_IDS = ["SU", "MO", "TU", "WE", "TH", "FR", "SA"];
|
|
12
|
+
const WORKDAYS = [1, 2, 3, 4, 5];
|
|
13
|
+
export function weekdayOf(date) {
|
|
14
|
+
return DAY_IDS[date.getDay()];
|
|
15
|
+
}
|
|
16
|
+
export function weekdayName(day) {
|
|
17
|
+
return WEEKDAYS.find(item => item.id === day)?.label ?? day;
|
|
18
|
+
}
|
|
19
|
+
export function nthOf(date) {
|
|
20
|
+
const nextWeek = new Date(date);
|
|
21
|
+
nextWeek.setDate(date.getDate() + 7);
|
|
22
|
+
return nextWeek.getMonth() !== date.getMonth()
|
|
23
|
+
? -1
|
|
24
|
+
: Math.ceil(date.getDate() / 7);
|
|
25
|
+
}
|
|
26
|
+
export function nthLabel(value) {
|
|
27
|
+
if (value === -1)
|
|
28
|
+
return "last";
|
|
29
|
+
if (value === 1)
|
|
30
|
+
return "first";
|
|
31
|
+
if (value === 2)
|
|
32
|
+
return "second";
|
|
33
|
+
if (value === 3)
|
|
34
|
+
return "third";
|
|
35
|
+
return "fourth";
|
|
36
|
+
}
|
|
37
|
+
function isWorkdays(byDay) {
|
|
38
|
+
if (byDay?.length !== WORKDAYS.length)
|
|
39
|
+
return false;
|
|
40
|
+
const sorted = [...byDay].sort((a, b) => a - b);
|
|
41
|
+
return WORKDAYS.every((day, i) => sorted[i] === day);
|
|
42
|
+
}
|
|
43
|
+
// which preset, if any, the rule is equivalent to for the current start date
|
|
44
|
+
function detectType(rule, start) {
|
|
45
|
+
if (rule.interval !== 1)
|
|
46
|
+
return "custom";
|
|
47
|
+
const onStartDay = rule.byMonthDay == null || rule.byMonthDay === start.getDate();
|
|
48
|
+
const days = rule.byDay ?? [];
|
|
49
|
+
if (rule.freq === "WEEKLY") {
|
|
50
|
+
if (isWorkdays(days))
|
|
51
|
+
return "workdays";
|
|
52
|
+
if (!days.length || (days.length === 1 && days[0] === start.getDay())) {
|
|
53
|
+
return "weekly";
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
else if (rule.freq === "MONTHLY") {
|
|
57
|
+
if (!days.length && onStartDay)
|
|
58
|
+
return "monthly";
|
|
59
|
+
}
|
|
60
|
+
else if (rule.freq === "YEARLY") {
|
|
61
|
+
const onStartMonth = !rule.byMonth?.length ||
|
|
62
|
+
(rule.byMonth.length === 1 && rule.byMonth[0] === start.getMonth() + 1);
|
|
63
|
+
if (!days.length && onStartDay && onStartMonth)
|
|
64
|
+
return "yearly";
|
|
65
|
+
}
|
|
66
|
+
else if (!days.length) {
|
|
67
|
+
return "daily";
|
|
68
|
+
}
|
|
69
|
+
return "custom";
|
|
70
|
+
}
|
|
71
|
+
export function parseRRule(rrule = "", start = new Date()) {
|
|
72
|
+
const rule = parseRule(rrule);
|
|
73
|
+
const weekdays = (rule?.byDay ?? []).map(day => DAY_IDS[day]);
|
|
74
|
+
return {
|
|
75
|
+
type: rule ? detectType(rule, start) : "never",
|
|
76
|
+
freq: rule?.freq ?? "DAILY",
|
|
77
|
+
interval: rule?.interval ?? 1,
|
|
78
|
+
weekdays: weekdays.length ? weekdays : [weekdayOf(start)],
|
|
79
|
+
monthMode: rule?.byDay?.length ? "weekday" : "day",
|
|
80
|
+
ends: rule?.count ? "count" : rule?.until ? "until" : "never",
|
|
81
|
+
count: Math.max(1, rule?.count ?? 10),
|
|
82
|
+
until: rule?.until ?? null,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
export function buildRRule(form, start) {
|
|
86
|
+
if (form.type === "never")
|
|
87
|
+
return "";
|
|
88
|
+
let rule;
|
|
89
|
+
if (form.type === "custom") {
|
|
90
|
+
rule = { freq: form.freq, interval: form.interval };
|
|
91
|
+
if (form.freq === "WEEKLY" && form.weekdays.length) {
|
|
92
|
+
rule.byDay = form.weekdays.map(day => DAY_IDS.indexOf(day));
|
|
93
|
+
}
|
|
94
|
+
if (form.freq === "MONTHLY" || form.freq === "YEARLY") {
|
|
95
|
+
if (form.freq === "YEARLY")
|
|
96
|
+
rule.byMonth = [start.getMonth() + 1];
|
|
97
|
+
if (form.monthMode === "weekday") {
|
|
98
|
+
rule.byDay = [start.getDay()];
|
|
99
|
+
rule.bySetPos = nthOf(start);
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
rule.byMonthDay = start.getDate();
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
else if (form.type === "workdays") {
|
|
107
|
+
rule = { freq: "WEEKLY", interval: 1, byDay: [...WORKDAYS] };
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
rule = { freq: form.type.toUpperCase(), interval: 1 };
|
|
111
|
+
}
|
|
112
|
+
if (form.ends === "count")
|
|
113
|
+
rule.count = form.count;
|
|
114
|
+
// the picker hands over a local day, and a date-only UNTIL keeps it that
|
|
115
|
+
// way - UTC parts would name the previous day in positive-offset zones
|
|
116
|
+
if (form.ends === "until" && form.until) {
|
|
117
|
+
rule.until = form.until;
|
|
118
|
+
rule.untilDateOnly = true;
|
|
119
|
+
}
|
|
120
|
+
return serializeRRule(rule);
|
|
121
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { EventPopupInfo } from "
|
|
1
|
+
import type { EventPopupInfo } from "../directives/clickevent.js";
|
|
2
2
|
import type { TPosition } from "@svar-ui/lib-dom";
|
|
3
3
|
import type { EventID } from "@svar-ui/calendar-store";
|
|
4
4
|
export declare function useEventOverlay(getEvent: (id: EventID) => any, getEventPopupAt: (element: HTMLElement) => TPosition): {
|
package/dist/context.tx
ADDED
|
File without changes
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare function getEditorItems(recurring?: boolean): ({
|
|
2
|
+
comp: string;
|
|
3
|
+
key: string;
|
|
4
|
+
label: string;
|
|
5
|
+
keys?: undefined;
|
|
6
|
+
validation?: undefined;
|
|
7
|
+
validationMessage?: undefined;
|
|
8
|
+
} | {
|
|
9
|
+
comp: string;
|
|
10
|
+
key: string;
|
|
11
|
+
keys: string[];
|
|
12
|
+
label: string;
|
|
13
|
+
validation: (value: {
|
|
14
|
+
start?: Date;
|
|
15
|
+
end?: Date;
|
|
16
|
+
}) => boolean;
|
|
17
|
+
validationMessage: string;
|
|
18
|
+
})[];
|
package/dist/defaults.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export function getEditorItems(recurring = false) {
|
|
2
|
+
return [
|
|
3
|
+
{ comp: "text", key: "text", label: "Text" },
|
|
4
|
+
{
|
|
5
|
+
comp: recurring ? "event-recurrence" : "event-dates",
|
|
6
|
+
key: "schedule",
|
|
7
|
+
keys: recurring
|
|
8
|
+
? ["start", "end", "allDay", "rrule"]
|
|
9
|
+
: ["start", "end", "allDay"],
|
|
10
|
+
label: "",
|
|
11
|
+
validation: (value) => !value.start || !value.end || value.end >= value.start,
|
|
12
|
+
validationMessage: "End date must be after the start date",
|
|
13
|
+
},
|
|
14
|
+
];
|
|
15
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { CalendarEvent, StoreActions } from "@svar-ui/calendar-store";
|
|
2
2
|
export interface EventPopupInfo {
|
|
3
3
|
eventId: string | number;
|
|
4
|
+
rawId: string | number;
|
|
4
5
|
element: HTMLElement;
|
|
5
6
|
}
|
|
6
7
|
export type ExecFn = (action: keyof StoreActions, data: any) => unknown;
|
|
@@ -12,6 +12,9 @@ export function clickevent(node, options) {
|
|
|
12
12
|
startY = e.clientY;
|
|
13
13
|
target = e.target;
|
|
14
14
|
}
|
|
15
|
+
function cancel() {
|
|
16
|
+
opts.onEventPopup?.(null);
|
|
17
|
+
}
|
|
15
18
|
function handleMouseUp(e) {
|
|
16
19
|
if (!target)
|
|
17
20
|
return;
|
|
@@ -22,22 +25,22 @@ export function clickevent(node, options) {
|
|
|
22
25
|
return;
|
|
23
26
|
}
|
|
24
27
|
const node = locate(target);
|
|
25
|
-
const event = node ? opts.getEvent(getID(node)) : null;
|
|
26
28
|
target = null;
|
|
29
|
+
if (!node)
|
|
30
|
+
return cancel();
|
|
31
|
+
const rawId = getID(node);
|
|
32
|
+
const event = opts.getEvent(rawId);
|
|
33
|
+
if (!event)
|
|
34
|
+
return cancel();
|
|
27
35
|
if (opts.onEventPopup) {
|
|
28
|
-
if (!event) {
|
|
29
|
-
opts.onEventPopup(null);
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
36
|
opts.onEventPopup({
|
|
33
37
|
eventId: event.id,
|
|
38
|
+
rawId,
|
|
34
39
|
element: node,
|
|
35
40
|
});
|
|
36
41
|
}
|
|
37
42
|
else {
|
|
38
|
-
|
|
39
|
-
return;
|
|
40
|
-
opts.exec("select-event", { id: event.id });
|
|
43
|
+
opts.exec("select-event", { id: event.id, rawId });
|
|
41
44
|
}
|
|
42
45
|
}
|
|
43
46
|
node.addEventListener("mousedown", handleMouseDown);
|
package/dist/directives/drag.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { decodeId } from "@svar-ui/calendar-store";
|
|
1
2
|
import { startResize } from "./dragresize.js";
|
|
2
3
|
import { getID } from "@svar-ui/lib-dom";
|
|
3
4
|
const MOVE_THRESHOLD = 3;
|
|
@@ -80,7 +81,7 @@ export function drag(node, options) {
|
|
|
80
81
|
const id = getID(moveEl);
|
|
81
82
|
moveEl = null;
|
|
82
83
|
movePending = false;
|
|
83
|
-
if (
|
|
84
|
+
if (id == null)
|
|
84
85
|
return;
|
|
85
86
|
startResize(node, el, e, id, {
|
|
86
87
|
dx: opts.dx,
|
|
@@ -199,8 +200,9 @@ export function drag(node, options) {
|
|
|
199
200
|
resetMove();
|
|
200
201
|
return;
|
|
201
202
|
}
|
|
202
|
-
const
|
|
203
|
-
const
|
|
203
|
+
const rawId = getID(moveEl);
|
|
204
|
+
const eventInfo = decodeId(rawId);
|
|
205
|
+
const original = opts.getEvent(eventInfo.id);
|
|
204
206
|
if (!original) {
|
|
205
207
|
resetMove();
|
|
206
208
|
return;
|
|
@@ -235,10 +237,11 @@ export function drag(node, options) {
|
|
|
235
237
|
: 0;
|
|
236
238
|
const newEnd = new Date(newStart.getTime() + duration);
|
|
237
239
|
const payload = {
|
|
238
|
-
id:
|
|
240
|
+
id: eventInfo.id,
|
|
241
|
+
rawId,
|
|
239
242
|
event: { start: newStart, end: newEnd },
|
|
240
243
|
};
|
|
241
|
-
opts.exec("
|
|
244
|
+
opts.exec("move-event", payload);
|
|
242
245
|
}
|
|
243
246
|
resetMove();
|
|
244
247
|
return;
|
|
@@ -269,10 +272,11 @@ export function drag(node, options) {
|
|
|
269
272
|
if (partial.start instanceof Date) {
|
|
270
273
|
partial.end = new Date(partial.start.getTime() + duration);
|
|
271
274
|
const payload = {
|
|
272
|
-
id:
|
|
275
|
+
id: eventInfo.id,
|
|
276
|
+
rawId,
|
|
273
277
|
event: partial,
|
|
274
278
|
};
|
|
275
|
-
opts.exec("
|
|
279
|
+
opts.exec("move-event", payload);
|
|
276
280
|
}
|
|
277
281
|
}
|
|
278
282
|
resetMove();
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { decodeId } from "@svar-ui/calendar-store";
|
|
1
2
|
const DRAG_THRESHOLD = 3;
|
|
2
3
|
export function startResize(node, dragEl, e, eventId, opts) {
|
|
3
4
|
const origStyle = dragEl.style.cssText;
|
|
@@ -30,7 +31,8 @@ export function startResize(node, dragEl, e, eventId, opts) {
|
|
|
30
31
|
return;
|
|
31
32
|
}
|
|
32
33
|
const finalBottom = origTop + (parseFloat(dragEl.style.height) || dragEl.offsetHeight);
|
|
33
|
-
const
|
|
34
|
+
const eventInfo = decodeId(eventId);
|
|
35
|
+
const original = opts.getEvent(eventInfo.id);
|
|
34
36
|
if (original) {
|
|
35
37
|
// x100: center of the element's column
|
|
36
38
|
const finalLeft = parseFloat(dragEl.style.left) || 0;
|
|
@@ -39,10 +41,11 @@ export function startResize(node, dragEl, e, eventId, opts) {
|
|
|
39
41
|
const endPartial = opts.model.toPositionEnd(opts.sectionName, x100, endY100, { end: original.end }, true);
|
|
40
42
|
if (endPartial.end instanceof Date) {
|
|
41
43
|
const payload = {
|
|
42
|
-
id:
|
|
44
|
+
id: eventInfo.id,
|
|
45
|
+
rawId: eventId,
|
|
43
46
|
event: { end: endPartial.end },
|
|
44
47
|
};
|
|
45
|
-
opts.exec("
|
|
48
|
+
opts.exec("move-event", payload);
|
|
46
49
|
}
|
|
47
50
|
}
|
|
48
51
|
reset();
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const EVENT_SELECTOR = ".wx-bar-event[data-id], .wx-box-event[data-id], .wx-list-event[data-id]";
|
|
2
|
+
const CELL_SELECTOR = "div.wx-grid-cell";
|
|
3
|
+
// Read rendered custom content and css from the live widget markup;
|
|
4
|
+
// position and size stay in style/wx-* classes and are excluded, as the
|
|
5
|
+
// export backend computes its own layout for its viewport
|
|
6
|
+
export function collectEventMaps(root) {
|
|
7
|
+
const content = {};
|
|
8
|
+
const css = {};
|
|
9
|
+
root.querySelectorAll(EVENT_SELECTOR).forEach(node => {
|
|
10
|
+
const el = node;
|
|
11
|
+
const id = el.dataset.id;
|
|
12
|
+
content[id] = el.innerHTML;
|
|
13
|
+
css[id] = el.getAttribute("class") || "";
|
|
14
|
+
});
|
|
15
|
+
return {
|
|
16
|
+
content,
|
|
17
|
+
css,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
export function collectCellCss(root) {
|
|
21
|
+
return Array.from(root.querySelectorAll(CELL_SELECTOR), node => node.getAttribute("class") || "");
|
|
22
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
declare const version: string;
|
|
1
2
|
import Calendar from "./components/Calendar.svelte";
|
|
2
3
|
import CalendarPanel from "./components/CalendarPanel.svelte";
|
|
3
4
|
import ContextMenu from "./components/ContextMenu.svelte";
|
|
@@ -5,10 +6,10 @@ import Editor from "./components/Editor.svelte";
|
|
|
5
6
|
import Willow from "./themes/Willow.svelte";
|
|
6
7
|
import WillowDark from "./themes/WillowDark.svelte";
|
|
7
8
|
export { getToolbarItems, getMenuOptions, registerCalendarView, WeekViewModel, DayViewModel, MonthViewModel, } from "@svar-ui/calendar-store";
|
|
8
|
-
export type { ToolbarItem, CalendarEvent, CellContext, EventContext, EventContentMode, CellCss, EventCss, } from "@svar-ui/calendar-store";
|
|
9
|
-
export type { CalendarContextApi, CalendarInstanceApi, ViewOption, } from "./
|
|
10
|
-
export { getEditorItems } from "./
|
|
9
|
+
export type { ToolbarItem, CalendarEvent, EditorData, CellContext, EventContext, EventContentMode, EventOverflowMode, SectionUI, CellCss, EventCss, } from "@svar-ui/calendar-store";
|
|
10
|
+
export type { CalendarContextApi, CalendarInstanceApi, CalendarPoint, ViewOption, } from "./types.js";
|
|
11
|
+
export { getEditorItems } from "./defaults.js";
|
|
11
12
|
export { registerEditorItem } from "@svar-ui/svelte-editor";
|
|
12
13
|
export { parseICal, serializeICal } from "@svar-ui/calendar-ical";
|
|
13
14
|
export { RestDataProvider } from "@svar-ui/calendar-provider";
|
|
14
|
-
export { Calendar, CalendarPanel, ContextMenu, Editor, Willow, WillowDark };
|
|
15
|
+
export { Calendar, CalendarPanel, ContextMenu, Editor, Willow, WillowDark, version, };
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import pkg from "../package.json" with { type: "json" };
|
|
2
|
+
const version = pkg.version;
|
|
1
3
|
import Calendar from "./components/Calendar.svelte";
|
|
2
4
|
import CalendarPanel from "./components/CalendarPanel.svelte";
|
|
3
5
|
import ContextMenu from "./components/ContextMenu.svelte";
|
|
@@ -5,8 +7,8 @@ import Editor from "./components/Editor.svelte";
|
|
|
5
7
|
import Willow from "./themes/Willow.svelte";
|
|
6
8
|
import WillowDark from "./themes/WillowDark.svelte";
|
|
7
9
|
export { getToolbarItems, getMenuOptions, registerCalendarView, WeekViewModel, DayViewModel, MonthViewModel, } from "@svar-ui/calendar-store";
|
|
8
|
-
export { getEditorItems } from "./
|
|
10
|
+
export { getEditorItems } from "./defaults.js";
|
|
9
11
|
export { registerEditorItem } from "@svar-ui/svelte-editor";
|
|
10
12
|
export { parseICal, serializeICal } from "@svar-ui/calendar-ical";
|
|
11
13
|
export { RestDataProvider } from "@svar-ui/calendar-provider";
|
|
12
|
-
export { Calendar, CalendarPanel, ContextMenu, Editor, Willow, WillowDark };
|
|
14
|
+
export { Calendar, CalendarPanel, ContextMenu, Editor, Willow, WillowDark, version, };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import Willow from "../themes/Willow.svelte";
|
|
3
|
+
import WillowDark from "../themes/WillowDark.svelte";
|
|
4
|
+
import Print from "../themes/Print.svelte";
|
|
5
|
+
import PrintBW from "../themes/PrintBW.svelte";
|
|
6
|
+
import Calendar from "../components/Calendar.svelte";
|
|
7
|
+
import Event from "./Event.svelte";
|
|
8
|
+
|
|
9
|
+
const { skin, config = {}, htmlMode } = $props();
|
|
10
|
+
const eventContent = $derived(htmlMode ? Event : undefined);
|
|
11
|
+
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
{#if skin === "willow-dark" || skin === "dark"}
|
|
15
|
+
<WillowDark>
|
|
16
|
+
<Calendar {...config} {eventContent} />
|
|
17
|
+
</WillowDark>
|
|
18
|
+
{:else if skin === "print"}
|
|
19
|
+
<Print>
|
|
20
|
+
<Calendar {...config} {eventContent} />
|
|
21
|
+
</Print>
|
|
22
|
+
{:else if skin === "bw"}
|
|
23
|
+
<PrintBW>
|
|
24
|
+
<Calendar {...config} {eventContent} />
|
|
25
|
+
</PrintBW>
|
|
26
|
+
{:else}
|
|
27
|
+
<Willow>
|
|
28
|
+
<Calendar {...config} {eventContent} />
|
|
29
|
+
</Willow>
|
|
30
|
+
{/if}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export default Calendar;
|
|
2
|
+
type Calendar = {
|
|
3
|
+
$on?(type: string, callback: (e: any) => void): () => void;
|
|
4
|
+
$set?(props: Partial<$$ComponentProps>): void;
|
|
5
|
+
};
|
|
6
|
+
declare const Calendar: import("svelte").Component<{
|
|
7
|
+
skin: any;
|
|
8
|
+
config?: Record<string, any>;
|
|
9
|
+
htmlMode: any;
|
|
10
|
+
}, {}, "">;
|
|
11
|
+
import Calendar from "../components/Calendar.svelte";
|
|
12
|
+
type $$ComponentProps = {
|
|
13
|
+
skin: any;
|
|
14
|
+
config?: Record<string, any>;
|
|
15
|
+
htmlMode: any;
|
|
16
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export default Event;
|
|
2
|
+
type Event = {
|
|
3
|
+
$on?(type: string, callback: (e: any) => void): () => void;
|
|
4
|
+
$set?(props: Partial<$$ComponentProps>): void;
|
|
5
|
+
};
|
|
6
|
+
declare const Event: import("svelte").Component<{
|
|
7
|
+
event: any;
|
|
8
|
+
}, {}, "">;
|
|
9
|
+
type $$ComponentProps = {
|
|
10
|
+
event: any;
|
|
11
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { mount } from "svelte";
|
|
2
|
+
import Export from "./pro_export/Calendar.svelte";
|
|
3
|
+
function init(target, config, skin, htmlMode) {
|
|
4
|
+
mount(Export, {
|
|
5
|
+
target: target
|
|
6
|
+
? document.querySelector(target)
|
|
7
|
+
: document.body,
|
|
8
|
+
props: {
|
|
9
|
+
config,
|
|
10
|
+
skin,
|
|
11
|
+
htmlMode,
|
|
12
|
+
},
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
export { init };
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import Willow from "./Willow.svelte";
|
|
3
|
+
let { fonts = true, children } = $props();
|
|
4
|
+
</script>
|
|
5
|
+
|
|
6
|
+
{#if children}
|
|
7
|
+
<Willow {fonts}>
|
|
8
|
+
<div class="wx-print-theme">
|
|
9
|
+
{@render children()}
|
|
10
|
+
</div>
|
|
11
|
+
</Willow>
|
|
12
|
+
{:else}
|
|
13
|
+
<Willow {fonts} />
|
|
14
|
+
{/if}
|
|
15
|
+
|
|
16
|
+
<style>
|
|
17
|
+
:global{
|
|
18
|
+
.wx-print-theme {
|
|
19
|
+
height: 100%;
|
|
20
|
+
width: 100%;
|
|
21
|
+
box-sizing: border-box;
|
|
22
|
+
|
|
23
|
+
/* surfaces - strip filled backgrounds, keep neutral page */
|
|
24
|
+
--wx-background: #ffffff;
|
|
25
|
+
--wx-background-alt: #ffffff;
|
|
26
|
+
--wx-background-hover: transparent;
|
|
27
|
+
--wx-color-primary: #1f6bd9;
|
|
28
|
+
--wx-color-primary-selected: transparent;
|
|
29
|
+
--wx-color-secondary-hover: transparent;
|
|
30
|
+
--wx-color-font-alt: #555d68;
|
|
31
|
+
--wx-icon-color: #555d68;
|
|
32
|
+
|
|
33
|
+
/* calendar surfaces */
|
|
34
|
+
--wx-calendar-grid-color: #b8bec8;
|
|
35
|
+
--wx-calendar-weekend-background: #ffffff;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.wx-print-theme .wx-calendar,
|
|
39
|
+
.wx-print-theme .wx-calendar-content,
|
|
40
|
+
.wx-print-theme .wx-calendar-main,
|
|
41
|
+
.wx-print-theme .wx-calendar-sidebar,
|
|
42
|
+
.wx-print-theme .wx-scroll-grid,
|
|
43
|
+
.wx-print-theme .wx-scroll-inner,
|
|
44
|
+
.wx-print-theme .wx-sections,
|
|
45
|
+
.wx-print-theme .wx-section {
|
|
46
|
+
background: #ffffff;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/* events - white body with a colored outline instead of a solid fill */
|
|
50
|
+
.wx-print-theme .wx-bar-event:not(.wx-bar-single-day),
|
|
51
|
+
.wx-print-theme .wx-box-event {
|
|
52
|
+
background-color: #ffffff;
|
|
53
|
+
color: var(--wx-color-font);
|
|
54
|
+
border: 2px solid var(--wx-color-primary);
|
|
55
|
+
box-shadow: none;
|
|
56
|
+
break-inside: avoid;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.wx-print-theme .wx-bar-event:hover,
|
|
60
|
+
.wx-print-theme .wx-box-event:hover {
|
|
61
|
+
box-shadow: none;
|
|
62
|
+
opacity: 1;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.wx-print-theme .wx-bar-single-day:hover {
|
|
66
|
+
background-color: transparent;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/* today marker - outline the day number instead of filling it */
|
|
70
|
+
.wx-print-theme .wx-month-day.wx-today .wx-day-num {
|
|
71
|
+
background: #ffffff;
|
|
72
|
+
color: var(--wx-color-primary);
|
|
73
|
+
border: 1px solid currentColor;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.wx-print-theme .wx-event-placeholder {
|
|
77
|
+
background: transparent;
|
|
78
|
+
border: 1px dashed var(--wx-color-primary);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.wx-print-theme .wx-list-event:hover {
|
|
82
|
+
background-color: transparent;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.wx-print-theme .wx-navigation button {
|
|
86
|
+
display: none;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
</style>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export default Print;
|
|
2
|
+
type Print = {
|
|
3
|
+
$on?(type: string, callback: (e: any) => void): () => void;
|
|
4
|
+
$set?(props: Partial<$$ComponentProps>): void;
|
|
5
|
+
};
|
|
6
|
+
declare const Print: import("svelte").Component<{
|
|
7
|
+
fonts?: boolean;
|
|
8
|
+
children: any;
|
|
9
|
+
}, {}, "">;
|
|
10
|
+
type $$ComponentProps = {
|
|
11
|
+
fonts?: boolean;
|
|
12
|
+
children: any;
|
|
13
|
+
};
|