@svar-ui/svelte-calendar 2.6.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/Demo.svelte +7 -0
- package/dist/Demo.svelte.d.ts +26 -0
- package/dist/components/AddEventButton.svelte +12 -0
- package/dist/components/AddEventButton.svelte.d.ts +18 -0
- package/dist/components/Calendar.svelte +110 -0
- package/dist/components/Calendar.svelte.d.ts +153 -0
- package/dist/components/CalendarPanel.svelte +147 -0
- package/dist/components/CalendarPanel.svelte.d.ts +18 -0
- package/dist/components/ContextMenu.svelte +87 -0
- package/dist/components/ContextMenu.svelte.d.ts +17 -0
- package/dist/components/DateLabel.svelte +13 -0
- package/dist/components/DateLabel.svelte.d.ts +18 -0
- package/dist/components/DateNav.svelte +31 -0
- package/dist/components/DateNav.svelte.d.ts +18 -0
- package/dist/components/DateTimePicker.svelte +30 -0
- package/dist/components/DateTimePicker.svelte.d.ts +8 -0
- package/dist/components/Editor.svelte +123 -0
- package/dist/components/Editor.svelte.d.ts +10 -0
- package/dist/components/Layout.svelte +76 -0
- package/dist/components/Layout.svelte.d.ts +21 -0
- package/dist/components/MenuButton.svelte +9 -0
- package/dist/components/MenuButton.svelte.d.ts +18 -0
- package/dist/components/Navigation.svelte +59 -0
- package/dist/components/Navigation.svelte.d.ts +12 -0
- package/dist/components/Render/BarSection.svelte +89 -0
- package/dist/components/Render/BarSection.svelte.d.ts +13 -0
- package/dist/components/Render/BoxSection.svelte +94 -0
- package/dist/components/Render/BoxSection.svelte.d.ts +15 -0
- package/dist/components/Render/Grid.svelte +16 -0
- package/dist/components/Render/Grid.svelte.d.ts +14 -0
- package/dist/components/Render/GridCells.svelte +98 -0
- package/dist/components/Render/GridCells.svelte.d.ts +14 -0
- package/dist/components/Render/GridLines.svelte +45 -0
- package/dist/components/Render/GridLines.svelte.d.ts +10 -0
- package/dist/components/Render/GridSection.svelte +348 -0
- package/dist/components/Render/GridSection.svelte.d.ts +16 -0
- package/dist/components/Render/Headers.svelte +86 -0
- package/dist/components/Render/Headers.svelte.d.ts +8 -0
- package/dist/components/Render/ListSection.svelte +110 -0
- package/dist/components/Render/ListSection.svelte.d.ts +8 -0
- package/dist/components/Render/NowLine.svelte +68 -0
- package/dist/components/Render/NowLine.svelte.d.ts +8 -0
- package/dist/components/Render/ScrollableSection.svelte +207 -0
- package/dist/components/Render/ScrollableSection.svelte.d.ts +14 -0
- package/dist/components/Render/SectionContent.svelte +83 -0
- package/dist/components/Render/SectionContent.svelte.d.ts +17 -0
- package/dist/components/Render/Sections.svelte +340 -0
- package/dist/components/Render/Sections.svelte.d.ts +14 -0
- package/dist/components/Render/YearSection.svelte +265 -0
- package/dist/components/Render/YearSection.svelte.d.ts +9 -0
- package/dist/components/Render/useEventOverlay.svelte.d.ts +21 -0
- package/dist/components/Render/useEventOverlay.svelte.js +60 -0
- package/dist/components/TodayButton.svelte +11 -0
- package/dist/components/TodayButton.svelte.d.ts +18 -0
- package/dist/components/editorItems.d.ts +15 -0
- package/dist/components/editorItems.js +20 -0
- package/dist/components/types.d.ts +29 -0
- package/dist/components/types.js +1 -0
- package/dist/directives/clickdate.d.ts +8 -0
- package/dist/directives/clickdate.js +45 -0
- package/dist/directives/clickevent.d.ts +15 -0
- package/dist/directives/clickevent.js +54 -0
- package/dist/directives/drag.d.ts +19 -0
- package/dist/directives/drag.js +494 -0
- package/dist/directives/dragresize.d.ts +10 -0
- package/dist/directives/dragresize.js +58 -0
- package/dist/directives/resize.d.ts +5 -0
- package/dist/directives/resize.js +11 -0
- package/dist/dom.d.ts +1 -0
- package/dist/dom.js +12 -0
- package/dist/env.d.ts +9 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +12 -0
- package/dist/init.d.ts +1 -0
- package/dist/init.js +5 -0
- package/dist/themes/Willow.svelte +16 -0
- package/dist/themes/Willow.svelte.d.ts +7 -0
- package/dist/themes/WillowDark.svelte +16 -0
- package/dist/themes/WillowDark.svelte.d.ts +7 -0
- package/license.txt +21 -0
- package/package.json +60 -0
- package/readme.md +107 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<script lang="ts">import { getContext } from "svelte";
|
|
2
|
+
import { Button } from "@svar-ui/svelte-core";
|
|
3
|
+
const store = getContext("calendar-api");
|
|
4
|
+
const _ = getContext("wx-i18n").getGroup("eventCalendar");
|
|
5
|
+
function today() {
|
|
6
|
+
store.exec("navigate-time", { direction: "now" });
|
|
7
|
+
}
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<Button onclick={today}>{_("Today")}</Button>
|
|
11
|
+
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
2
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
3
|
+
$$bindings?: Bindings;
|
|
4
|
+
} & Exports;
|
|
5
|
+
(internal: unknown, props: {
|
|
6
|
+
$$events?: Events;
|
|
7
|
+
$$slots?: Slots;
|
|
8
|
+
}): Exports & {
|
|
9
|
+
$set?: any;
|
|
10
|
+
$on?: any;
|
|
11
|
+
};
|
|
12
|
+
z_$$bindings?: Bindings;
|
|
13
|
+
}
|
|
14
|
+
declare const TodayButton: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
|
|
15
|
+
[evt: string]: CustomEvent<any>;
|
|
16
|
+
}, {}, {}, string>;
|
|
17
|
+
type TodayButton = InstanceType<typeof TodayButton>;
|
|
18
|
+
export default TodayButton;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare function getEditorItems(): ({
|
|
2
|
+
comp: string;
|
|
3
|
+
key: string;
|
|
4
|
+
label: string;
|
|
5
|
+
time?: undefined;
|
|
6
|
+
config?: undefined;
|
|
7
|
+
} | {
|
|
8
|
+
comp: string;
|
|
9
|
+
key: string;
|
|
10
|
+
label: string;
|
|
11
|
+
time: boolean;
|
|
12
|
+
config: {
|
|
13
|
+
buttons: boolean;
|
|
14
|
+
};
|
|
15
|
+
})[];
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export function getEditorItems() {
|
|
2
|
+
return [
|
|
3
|
+
{ comp: "text", key: "text", label: "Text" },
|
|
4
|
+
{
|
|
5
|
+
comp: "date-time-picker",
|
|
6
|
+
key: "start",
|
|
7
|
+
label: "Start date",
|
|
8
|
+
time: true,
|
|
9
|
+
config: { buttons: false },
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
comp: "date-time-picker",
|
|
13
|
+
key: "end",
|
|
14
|
+
label: "End date",
|
|
15
|
+
time: true,
|
|
16
|
+
config: { buttons: false },
|
|
17
|
+
},
|
|
18
|
+
{ comp: "checkbox", key: "allDay", label: "All day" },
|
|
19
|
+
];
|
|
20
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { EventBus } from "@svar-ui/lib-state";
|
|
2
|
+
import type { Brandmark, CalendarStore, FormatFactory, StoreActions } from "@svar-ui/calendar-store";
|
|
3
|
+
export type ViewOption = {
|
|
4
|
+
id: string;
|
|
5
|
+
label: string;
|
|
6
|
+
};
|
|
7
|
+
type CalendarEventBus = EventBus<StoreActions, keyof StoreActions>;
|
|
8
|
+
type CalendarApi = {
|
|
9
|
+
getState: CalendarStore["getState"];
|
|
10
|
+
getReactiveState: CalendarStore["getReactive"];
|
|
11
|
+
exec: CalendarEventBus["exec"];
|
|
12
|
+
fmt: FormatFactory;
|
|
13
|
+
getEvent: CalendarStore["getEvent"];
|
|
14
|
+
};
|
|
15
|
+
export type CalendarContextApi = CalendarApi & {
|
|
16
|
+
getBrandmark: () => Brandmark | null;
|
|
17
|
+
};
|
|
18
|
+
export type CalendarInstanceApi = CalendarApi & {
|
|
19
|
+
getStores: () => {
|
|
20
|
+
data: CalendarStore;
|
|
21
|
+
};
|
|
22
|
+
setNext: (handler: any) => any;
|
|
23
|
+
intercept: CalendarEventBus["intercept"];
|
|
24
|
+
on: CalendarEventBus["on"];
|
|
25
|
+
detach: CalendarEventBus["detach"];
|
|
26
|
+
getEvents: CalendarStore["getEvents"];
|
|
27
|
+
getEvent: CalendarStore["getEvent"];
|
|
28
|
+
};
|
|
29
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { StoreActions } from "@svar-ui/calendar-store";
|
|
2
|
+
export interface ClickDateOptions {
|
|
3
|
+
exec: (action: keyof StoreActions, data: any) => unknown;
|
|
4
|
+
}
|
|
5
|
+
export declare function clickdate(node: HTMLElement, options: ClickDateOptions): {
|
|
6
|
+
update(newOpts: ClickDateOptions): void;
|
|
7
|
+
destroy(): void;
|
|
8
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
const CLICK_THRESHOLD = 3;
|
|
2
|
+
export function clickdate(node, options) {
|
|
3
|
+
let opts = options;
|
|
4
|
+
let startX = 0;
|
|
5
|
+
let startY = 0;
|
|
6
|
+
let target = null;
|
|
7
|
+
function handleMouseDown(e) {
|
|
8
|
+
if (e.button !== 0)
|
|
9
|
+
return;
|
|
10
|
+
startX = e.clientX;
|
|
11
|
+
startY = e.clientY;
|
|
12
|
+
target = e.target;
|
|
13
|
+
}
|
|
14
|
+
function handleMouseUp(e) {
|
|
15
|
+
if (!target)
|
|
16
|
+
return;
|
|
17
|
+
const dx = Math.abs(e.clientX - startX);
|
|
18
|
+
const dy = Math.abs(e.clientY - startY);
|
|
19
|
+
if (dx > CLICK_THRESHOLD || dy > CLICK_THRESHOLD) {
|
|
20
|
+
target = null;
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
const el = target.closest("[data-date]");
|
|
24
|
+
target = null;
|
|
25
|
+
if (!el)
|
|
26
|
+
return;
|
|
27
|
+
const raw = el.getAttribute("data-date");
|
|
28
|
+
if (!raw)
|
|
29
|
+
return;
|
|
30
|
+
const [y, m, d] = raw.split("-").map(Number);
|
|
31
|
+
const date = new Date(y, m - 1, d);
|
|
32
|
+
opts.exec("navigate-to", { date, view: "day" });
|
|
33
|
+
}
|
|
34
|
+
node.addEventListener("mousedown", handleMouseDown);
|
|
35
|
+
node.addEventListener("mouseup", handleMouseUp);
|
|
36
|
+
return {
|
|
37
|
+
update(newOpts) {
|
|
38
|
+
opts = newOpts;
|
|
39
|
+
},
|
|
40
|
+
destroy() {
|
|
41
|
+
node.removeEventListener("mousedown", handleMouseDown);
|
|
42
|
+
node.removeEventListener("mouseup", handleMouseUp);
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { CalendarEvent, StoreActions } from "@svar-ui/calendar-store";
|
|
2
|
+
export interface EventPopupInfo {
|
|
3
|
+
eventId: string | number;
|
|
4
|
+
element: HTMLElement;
|
|
5
|
+
}
|
|
6
|
+
export type ExecFn = (action: keyof StoreActions, data: any) => unknown;
|
|
7
|
+
export interface ClickEventOptions {
|
|
8
|
+
exec: ExecFn;
|
|
9
|
+
onEventPopup?: ((info: EventPopupInfo | null) => void) | null;
|
|
10
|
+
getEvent: (id: string | number) => CalendarEvent | undefined;
|
|
11
|
+
}
|
|
12
|
+
export declare function clickevent(node: HTMLElement, options: ClickEventOptions): {
|
|
13
|
+
update(newOpts: ClickEventOptions): void;
|
|
14
|
+
destroy(): void;
|
|
15
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { getID, locate } from "@svar-ui/lib-dom";
|
|
2
|
+
const CLICK_THRESHOLD = 3;
|
|
3
|
+
export function clickevent(node, options) {
|
|
4
|
+
let opts = options;
|
|
5
|
+
let startX = 0;
|
|
6
|
+
let startY = 0;
|
|
7
|
+
let target = null;
|
|
8
|
+
function handleMouseDown(e) {
|
|
9
|
+
if (e.button !== 0)
|
|
10
|
+
return;
|
|
11
|
+
startX = e.clientX;
|
|
12
|
+
startY = e.clientY;
|
|
13
|
+
target = e.target;
|
|
14
|
+
}
|
|
15
|
+
function handleMouseUp(e) {
|
|
16
|
+
if (!target)
|
|
17
|
+
return;
|
|
18
|
+
const dx = Math.abs(e.clientX - startX);
|
|
19
|
+
const dy = Math.abs(e.clientY - startY);
|
|
20
|
+
if (dx > CLICK_THRESHOLD || dy > CLICK_THRESHOLD) {
|
|
21
|
+
target = null;
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
const node = locate(target);
|
|
25
|
+
const event = node ? opts.getEvent(getID(node)) : null;
|
|
26
|
+
target = null;
|
|
27
|
+
if (opts.onEventPopup) {
|
|
28
|
+
if (!event) {
|
|
29
|
+
opts.onEventPopup(null);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
opts.onEventPopup({
|
|
33
|
+
eventId: event.id,
|
|
34
|
+
element: node,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
if (!event)
|
|
39
|
+
return;
|
|
40
|
+
opts.exec("select-event", { id: event.id });
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
node.addEventListener("mousedown", handleMouseDown);
|
|
44
|
+
node.addEventListener("mouseup", handleMouseUp);
|
|
45
|
+
return {
|
|
46
|
+
update(newOpts) {
|
|
47
|
+
opts = newOpts;
|
|
48
|
+
},
|
|
49
|
+
destroy() {
|
|
50
|
+
node.removeEventListener("mousedown", handleMouseDown);
|
|
51
|
+
node.removeEventListener("mouseup", handleMouseUp);
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { CalendarEvent, EventID, ScaleUnit, SectionMode, StoreActions, ViewModel } from "@svar-ui/calendar-store";
|
|
2
|
+
export interface DragOptions {
|
|
3
|
+
mode: SectionMode;
|
|
4
|
+
dx: number;
|
|
5
|
+
dy: number;
|
|
6
|
+
xHeaders: ScaleUnit[][] | null;
|
|
7
|
+
yHeaders: ScaleUnit[][] | null;
|
|
8
|
+
sectionName: string;
|
|
9
|
+
model: ViewModel;
|
|
10
|
+
exec: (action: keyof StoreActions, data: any) => unknown;
|
|
11
|
+
move: boolean;
|
|
12
|
+
getEvent: (id: EventID) => CalendarEvent | undefined;
|
|
13
|
+
clipDrag: boolean;
|
|
14
|
+
create: boolean;
|
|
15
|
+
}
|
|
16
|
+
export declare function drag(node: HTMLElement, options: DragOptions): {
|
|
17
|
+
update(newOpts: DragOptions): void;
|
|
18
|
+
destroy(): void;
|
|
19
|
+
};
|