@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,30 @@
|
|
|
1
|
+
<script lang="ts">import { DatePicker, TimePicker } from "@svar-ui/svelte-core";
|
|
2
|
+
let { value, id, time, onchange, ...restProps } = $props();
|
|
3
|
+
</script>
|
|
4
|
+
|
|
5
|
+
<div class="wx-event-calendar-date_field">
|
|
6
|
+
<div class="wx-event-calendar-input_wrapper">
|
|
7
|
+
<DatePicker {id} {value} {onchange} {...restProps} buttons={false} />
|
|
8
|
+
</div>
|
|
9
|
+
{#if time}
|
|
10
|
+
<TimePicker {id} {value} {onchange} />
|
|
11
|
+
{/if}
|
|
12
|
+
</div>
|
|
13
|
+
|
|
14
|
+
<style>
|
|
15
|
+
.wx-event-calendar-date_field {
|
|
16
|
+
display: flex;
|
|
17
|
+
}
|
|
18
|
+
.wx-event-calendar-date_field .wx-event-calendar-input_wrapper {
|
|
19
|
+
flex-grow: 2;
|
|
20
|
+
}
|
|
21
|
+
.wx-event-calendar-date_field :global(.timepicker) {
|
|
22
|
+
width: unset !important;
|
|
23
|
+
}
|
|
24
|
+
.wx-event-calendar-input_wrapper {
|
|
25
|
+
margin-right: 10px;
|
|
26
|
+
}
|
|
27
|
+
:global(.wx-event-calendar-editor-controls > .btn:not(:last-child)) {
|
|
28
|
+
margin-right: 5px;
|
|
29
|
+
}
|
|
30
|
+
</style>
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
<script lang="ts">import { getContext, setContext } from "svelte";
|
|
2
|
+
import { Editor as EditorBase, registerEditorItem } from "@svar-ui/svelte-editor";
|
|
3
|
+
import { locale } from "@svar-ui/lib-dom";
|
|
4
|
+
import { en } from "@svar-ui/calendar-locales";
|
|
5
|
+
import { en as coreEn } from "@svar-ui/core-locales";
|
|
6
|
+
import DateTimePicker from "./DateTimePicker.svelte";
|
|
7
|
+
import { getEditorItems } from "./editorItems.js";
|
|
8
|
+
registerEditorItem("date-time-picker", DateTimePicker);
|
|
9
|
+
let { api, values, items = getEditorItems(), placement = "sidebar", layout = "default", focus = true, css = "", topBar, autoSave = true, onchange, onsave, onaction, ...editorProps } = $props();
|
|
10
|
+
// svelte-ignore state_referenced_locally
|
|
11
|
+
void values;
|
|
12
|
+
// svelte-ignore state_referenced_locally
|
|
13
|
+
const { editorData } = api.getReactiveState();
|
|
14
|
+
let l = getContext("wx-i18n");
|
|
15
|
+
if (!l) {
|
|
16
|
+
l = locale({
|
|
17
|
+
...en,
|
|
18
|
+
...coreEn
|
|
19
|
+
});
|
|
20
|
+
setContext("wx-i18n", l);
|
|
21
|
+
}
|
|
22
|
+
const _ = l.getGroup("eventCalendar");
|
|
23
|
+
function translate(value) {
|
|
24
|
+
return typeof value === "string" ? _(value) : value;
|
|
25
|
+
}
|
|
26
|
+
function applyLocale(list) {
|
|
27
|
+
return list.map((item) => {
|
|
28
|
+
const next = { ...item };
|
|
29
|
+
next.label = translate(next.label);
|
|
30
|
+
return next;
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
let generation = $state(1);
|
|
34
|
+
const allDay = $derived(generation > 0 ? $editorData?.allDay : false);
|
|
35
|
+
const cItems = $derived(applyLocale(items));
|
|
36
|
+
const defaultTopBar = { items: [
|
|
37
|
+
{
|
|
38
|
+
comp: "icon",
|
|
39
|
+
icon: "wxi-close",
|
|
40
|
+
id: "close"
|
|
41
|
+
},
|
|
42
|
+
{ comp: "spacer" },
|
|
43
|
+
{
|
|
44
|
+
comp: "button",
|
|
45
|
+
id: "delete",
|
|
46
|
+
text: _("Delete"),
|
|
47
|
+
type: "primary danger",
|
|
48
|
+
onclick: handleDelete
|
|
49
|
+
}
|
|
50
|
+
] };
|
|
51
|
+
const editorTopBar = $derived(topBar === undefined ? defaultTopBar : topBar);
|
|
52
|
+
const editorCss = $derived([
|
|
53
|
+
"wx-editor-calendar",
|
|
54
|
+
allDay ? "wx-editor-all-day" : "",
|
|
55
|
+
css
|
|
56
|
+
].filter(Boolean).join(" "));
|
|
57
|
+
function handleSave(ev) {
|
|
58
|
+
onsave?.(ev);
|
|
59
|
+
const data = $editorData;
|
|
60
|
+
if (!data) return;
|
|
61
|
+
api.exec("update-event", {
|
|
62
|
+
id: data.id,
|
|
63
|
+
event: { ...ev.values }
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
function sameDay(a, b) {
|
|
67
|
+
return a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth() && a.getDate() === b.getDate();
|
|
68
|
+
}
|
|
69
|
+
function handleChange(ev) {
|
|
70
|
+
const { key, value, update } = ev;
|
|
71
|
+
const prev = $editorData;
|
|
72
|
+
generation++;
|
|
73
|
+
if (prev && key === "start" && !update.allDay) {
|
|
74
|
+
const oldStart = prev.start;
|
|
75
|
+
const oldEnd = prev.end;
|
|
76
|
+
if (oldStart instanceof Date && oldEnd instanceof Date && sameDay(oldStart, oldEnd) && value instanceof Date) {
|
|
77
|
+
const newEnd = new Date(oldEnd);
|
|
78
|
+
newEnd.setFullYear(value.getFullYear(), value.getMonth(), value.getDate());
|
|
79
|
+
update.end = newEnd;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
onchange?.(ev);
|
|
83
|
+
}
|
|
84
|
+
function handleDelete() {
|
|
85
|
+
const data = $editorData;
|
|
86
|
+
if (!data) return;
|
|
87
|
+
api.exec("delete-event", { id: data.id });
|
|
88
|
+
api.exec("select-event", { id: null });
|
|
89
|
+
}
|
|
90
|
+
function handleAction(ev) {
|
|
91
|
+
onaction?.(ev);
|
|
92
|
+
const { item } = ev;
|
|
93
|
+
if (item.id === "close" && !!item.comp) {
|
|
94
|
+
api.exec("select-event", { id: null });
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
</script>
|
|
98
|
+
|
|
99
|
+
{#if $editorData}
|
|
100
|
+
<EditorBase
|
|
101
|
+
{...editorProps}
|
|
102
|
+
{focus}
|
|
103
|
+
items={cItems}
|
|
104
|
+
topBar={editorTopBar}
|
|
105
|
+
{autoSave}
|
|
106
|
+
onchange={handleChange}
|
|
107
|
+
onaction={handleAction}
|
|
108
|
+
onsave={handleSave}
|
|
109
|
+
{placement}
|
|
110
|
+
{layout}
|
|
111
|
+
values={$editorData}
|
|
112
|
+
css={editorCss}
|
|
113
|
+
/>
|
|
114
|
+
{/if}
|
|
115
|
+
|
|
116
|
+
<style>
|
|
117
|
+
:global(.wx-sidearea .wx-editor-calendar) {
|
|
118
|
+
width: 450px;
|
|
119
|
+
}
|
|
120
|
+
:global(.wx-editor-calendar.wx-editor-all-day .wx-timepicker) {
|
|
121
|
+
visibility: hidden;
|
|
122
|
+
}
|
|
123
|
+
</style>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type ComponentProps } from "svelte";
|
|
2
|
+
import { Editor as EditorBase } from "@svar-ui/svelte-editor";
|
|
3
|
+
type BaseEditorProps = ComponentProps<typeof EditorBase>;
|
|
4
|
+
type EditorProps = Omit<BaseEditorProps, "values"> & {
|
|
5
|
+
api: any;
|
|
6
|
+
values?: never;
|
|
7
|
+
};
|
|
8
|
+
declare const Editor: import("svelte").Component<EditorProps, {}, "">;
|
|
9
|
+
type Editor = ReturnType<typeof Editor>;
|
|
10
|
+
export default Editor;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
<script lang="ts">import { getContext } from "svelte";
|
|
2
|
+
import Navigation from "./Navigation.svelte";
|
|
3
|
+
import Sections from "./Render/Sections.svelte";
|
|
4
|
+
import ScrollableSection from "./Render/ScrollableSection.svelte";
|
|
5
|
+
const _ = getContext("wx-i18n").getGroup("eventCalendar");
|
|
6
|
+
const { store, views, toolbar, cellCss, eventCss, eventContent, children, tooltip, eventPopup, brandmark, readonly = false } = $props();
|
|
7
|
+
// svelte-ignore state_referenced_locally
|
|
8
|
+
const { viewData, currentView, _view } = store.getReactiveState();
|
|
9
|
+
const renderMode = $derived($_view?.render);
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
{#snippet viewContent()}
|
|
13
|
+
{#if renderMode === "scrollable"}
|
|
14
|
+
<ScrollableSection data={$viewData} {cellCss} {eventCss} {eventContent} view={$currentView} {tooltip} {eventPopup} {readonly} />
|
|
15
|
+
{:else}
|
|
16
|
+
<Sections data={$viewData} {cellCss} {eventCss} {eventContent} view={$currentView} {tooltip} {eventPopup} {readonly} />
|
|
17
|
+
{/if}
|
|
18
|
+
{/snippet}
|
|
19
|
+
|
|
20
|
+
<div class="wx-calendar" role="region" aria-label={_("Calendar")}>
|
|
21
|
+
{#if toolbar !== null}
|
|
22
|
+
<Navigation {views} toolbar={toolbar} {readonly} />
|
|
23
|
+
{/if}
|
|
24
|
+
{#if children}
|
|
25
|
+
<div class="wx-calendar-content">
|
|
26
|
+
<div class="wx-calendar-sidebar" role="complementary" aria-label={_("Calendar sidebar")}>
|
|
27
|
+
{@render children()}
|
|
28
|
+
</div>
|
|
29
|
+
<div class="wx-calendar-main">
|
|
30
|
+
{@render viewContent()}
|
|
31
|
+
{#if brandmark}
|
|
32
|
+
<a style={brandmark.style} href={brandmark.link} target="_blank">
|
|
33
|
+
{brandmark.text}
|
|
34
|
+
</a>
|
|
35
|
+
{/if}
|
|
36
|
+
</div>
|
|
37
|
+
</div>
|
|
38
|
+
{:else}
|
|
39
|
+
<div class="wx-calendar-main wx-calendar-main--full">
|
|
40
|
+
{@render viewContent()}
|
|
41
|
+
{#if brandmark}
|
|
42
|
+
<a style={brandmark.style} href={brandmark.link} target="_blank">
|
|
43
|
+
{brandmark.text}
|
|
44
|
+
</a>
|
|
45
|
+
{/if}
|
|
46
|
+
</div>
|
|
47
|
+
{/if}
|
|
48
|
+
</div>
|
|
49
|
+
|
|
50
|
+
<style>
|
|
51
|
+
.wx-calendar {
|
|
52
|
+
display: flex;
|
|
53
|
+
flex-direction: column;
|
|
54
|
+
height: 100%;
|
|
55
|
+
}
|
|
56
|
+
.wx-calendar-content {
|
|
57
|
+
display: flex;
|
|
58
|
+
flex: 1;
|
|
59
|
+
min-height: 0;
|
|
60
|
+
}
|
|
61
|
+
.wx-calendar-sidebar {
|
|
62
|
+
flex-shrink: 0;
|
|
63
|
+
border-right: var(--wx-border);
|
|
64
|
+
}
|
|
65
|
+
.wx-calendar-main {
|
|
66
|
+
flex: 1;
|
|
67
|
+
min-width: 0;
|
|
68
|
+
min-height: 0;
|
|
69
|
+
position: relative;
|
|
70
|
+
display: flex;
|
|
71
|
+
flex-direction: column;
|
|
72
|
+
}
|
|
73
|
+
.wx-calendar-main--full {
|
|
74
|
+
min-height: 0;
|
|
75
|
+
}
|
|
76
|
+
</style>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Snippet } from "svelte";
|
|
2
|
+
import type { ToolbarItem, Brandmark, CellCss, EventCss } from "@svar-ui/calendar-store";
|
|
3
|
+
type $$ComponentProps = {
|
|
4
|
+
store: any;
|
|
5
|
+
views: any;
|
|
6
|
+
toolbar?: {
|
|
7
|
+
items?: ToolbarItem[];
|
|
8
|
+
css?: string;
|
|
9
|
+
} | null;
|
|
10
|
+
cellCss?: CellCss;
|
|
11
|
+
eventCss?: EventCss;
|
|
12
|
+
eventContent?: any;
|
|
13
|
+
children?: Snippet;
|
|
14
|
+
tooltip?: any;
|
|
15
|
+
eventPopup?: any;
|
|
16
|
+
brandmark?: Brandmark;
|
|
17
|
+
readonly?: boolean;
|
|
18
|
+
};
|
|
19
|
+
declare const Layout: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
20
|
+
type Layout = ReturnType<typeof Layout>;
|
|
21
|
+
export default Layout;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<script lang="ts">import { getContext } from "svelte";
|
|
2
|
+
import { Button } from "@svar-ui/svelte-core";
|
|
3
|
+
const store = getContext("calendar-api");
|
|
4
|
+
function menuClick() {
|
|
5
|
+
store.exec("action", { id: "menu-button" });
|
|
6
|
+
}
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
<Button icon="wxi-menu" onclick={menuClick} /*ariaLabel={_("Menu")}*/ />
|
|
@@ -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 MenuButton: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
|
|
15
|
+
[evt: string]: CustomEvent<any>;
|
|
16
|
+
}, {}, {}, string>;
|
|
17
|
+
type MenuButton = InstanceType<typeof MenuButton>;
|
|
18
|
+
export default MenuButton;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
<script lang="ts">import { getContext } from "svelte";
|
|
2
|
+
import { Toolbar, registerToolbarItem } from "@svar-ui/svelte-toolbar";
|
|
3
|
+
import { RichSelect, Segmented } from "@svar-ui/svelte-core";
|
|
4
|
+
import { getToolbarItems } from "@svar-ui/calendar-store";
|
|
5
|
+
import DateNav from "./DateNav.svelte";
|
|
6
|
+
import TodayButton from "./TodayButton.svelte";
|
|
7
|
+
import DateLabel from "./DateLabel.svelte";
|
|
8
|
+
import MenuButton from "./MenuButton.svelte";
|
|
9
|
+
import AddEventButton from "./AddEventButton.svelte";
|
|
10
|
+
registerToolbarItem("richselect", RichSelect);
|
|
11
|
+
registerToolbarItem("segmented", Segmented);
|
|
12
|
+
registerToolbarItem("dateNav", DateNav);
|
|
13
|
+
registerToolbarItem("todayButton", TodayButton);
|
|
14
|
+
registerToolbarItem("dateLabel", DateLabel);
|
|
15
|
+
registerToolbarItem("menuButton", MenuButton);
|
|
16
|
+
registerToolbarItem("addEventButton", AddEventButton);
|
|
17
|
+
const store = getContext("calendar-api");
|
|
18
|
+
const { views, toolbar = { items: getToolbarItems() }, readonly = false } = $props();
|
|
19
|
+
const { currentView } = store.getReactiveState();
|
|
20
|
+
const _ = getContext("wx-i18n").getGroup("eventCalendar");
|
|
21
|
+
const items = $derived.by(() => {
|
|
22
|
+
const base = toolbar?.items;
|
|
23
|
+
const viewOptions = views.map((v) => ({
|
|
24
|
+
id: v.id,
|
|
25
|
+
label: _(v.label || v.id.charAt(0).toUpperCase() + v.id.slice(1))
|
|
26
|
+
}));
|
|
27
|
+
const res = [...base ?? []].map((item) => {
|
|
28
|
+
if (item.id === "modes") {
|
|
29
|
+
if (viewOptions.length > 1) {
|
|
30
|
+
return {
|
|
31
|
+
...item,
|
|
32
|
+
value: $currentView,
|
|
33
|
+
options: viewOptions
|
|
34
|
+
};
|
|
35
|
+
} else {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
if (readonly && item.comp === "addEventButton") return null;
|
|
40
|
+
return item;
|
|
41
|
+
}).filter(Boolean);
|
|
42
|
+
return res;
|
|
43
|
+
});
|
|
44
|
+
const onchange = ({ item, value }) => {
|
|
45
|
+
if (item.id === "modes") {
|
|
46
|
+
store.exec("navigate-to", { view: value });
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
</script>
|
|
50
|
+
|
|
51
|
+
<div class="wx-navigation" role="navigation" aria-label={_("Calendar controls")}>
|
|
52
|
+
<Toolbar {items} {onchange} css={toolbar?.css}></Toolbar>
|
|
53
|
+
</div>
|
|
54
|
+
|
|
55
|
+
<style>
|
|
56
|
+
.wx-navigation {
|
|
57
|
+
border-bottom: var(--wx-border);
|
|
58
|
+
}
|
|
59
|
+
</style>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ToolbarItem } from "@svar-ui/calendar-store";
|
|
2
|
+
type $$ComponentProps = {
|
|
3
|
+
views: any;
|
|
4
|
+
toolbar?: {
|
|
5
|
+
items?: ToolbarItem[];
|
|
6
|
+
css?: string;
|
|
7
|
+
};
|
|
8
|
+
readonly?: boolean;
|
|
9
|
+
};
|
|
10
|
+
declare const Navigation: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
11
|
+
type Navigation = ReturnType<typeof Navigation>;
|
|
12
|
+
export default Navigation;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
<script lang="ts">import { setID } from "@svar-ui/lib-dom";
|
|
2
|
+
const { primitives, dx, dy, eventCss, eventContent, view, section } = $props();
|
|
3
|
+
const laneHeight = 28;
|
|
4
|
+
const gap = 2;
|
|
5
|
+
function style(p) {
|
|
6
|
+
const left = dx * p.x + gap;
|
|
7
|
+
const width = dx * p.width - gap * 2;
|
|
8
|
+
const lane = p.lane ?? 0;
|
|
9
|
+
const lanes = p.totalLanes ?? 1;
|
|
10
|
+
const groupTop = dy * p.y;
|
|
11
|
+
const groupHeight = dy * p.height;
|
|
12
|
+
const rowLaneHeight = Math.min(laneHeight, groupHeight / lanes);
|
|
13
|
+
const top = groupTop + lane * rowLaneHeight + gap;
|
|
14
|
+
const height = rowLaneHeight - gap * 2;
|
|
15
|
+
return `left:${left}px;top:${top}px;width:${width}px;height:${height}px`;
|
|
16
|
+
}
|
|
17
|
+
function css(p) {
|
|
18
|
+
const base = p.event.css || "";
|
|
19
|
+
const dynamic = eventCss ? eventCss({
|
|
20
|
+
event: p.event,
|
|
21
|
+
view,
|
|
22
|
+
section,
|
|
23
|
+
mode: "bars"
|
|
24
|
+
}) : "";
|
|
25
|
+
return base + (dynamic ? " " + dynamic : "");
|
|
26
|
+
}
|
|
27
|
+
</script>
|
|
28
|
+
|
|
29
|
+
<div class="wx-bar-section">
|
|
30
|
+
{#each primitives as p (p.id)}
|
|
31
|
+
<div
|
|
32
|
+
class="wx-bar-event {css(p)}"
|
|
33
|
+
class:wx-bar-single-day={p.isMultiDay}
|
|
34
|
+
style={style(p)}
|
|
35
|
+
data-id={setID(p.id)}
|
|
36
|
+
>
|
|
37
|
+
{#if eventContent}
|
|
38
|
+
{@const EventContentCmp = eventContent}
|
|
39
|
+
<EventContentCmp event={p.event} mode="bars" />
|
|
40
|
+
{:else}
|
|
41
|
+
<span class="wx-bar-title">
|
|
42
|
+
{p.event.text || " "}
|
|
43
|
+
</span>
|
|
44
|
+
{/if}
|
|
45
|
+
</div>
|
|
46
|
+
{/each}
|
|
47
|
+
</div>
|
|
48
|
+
|
|
49
|
+
<style>
|
|
50
|
+
.wx-bar-section {
|
|
51
|
+
position: relative;
|
|
52
|
+
width: 100%;
|
|
53
|
+
height: 100%;
|
|
54
|
+
}
|
|
55
|
+
.wx-bar-event {
|
|
56
|
+
position: absolute;
|
|
57
|
+
background-color: var(--wx-color-primary);
|
|
58
|
+
color: var(--wx-color-primary-font);
|
|
59
|
+
border-radius: var(--wx-border-radius);
|
|
60
|
+
overflow: hidden;
|
|
61
|
+
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
|
|
62
|
+
cursor: pointer;
|
|
63
|
+
display: flex;
|
|
64
|
+
align-items: center;
|
|
65
|
+
}
|
|
66
|
+
.wx-bar-event:hover {
|
|
67
|
+
opacity: 0.9;
|
|
68
|
+
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.25);
|
|
69
|
+
}
|
|
70
|
+
.wx-bar-single-day {
|
|
71
|
+
background-color: transparent;
|
|
72
|
+
color: var(--wx-color-font);
|
|
73
|
+
box-shadow: none;
|
|
74
|
+
border-radius: 0;
|
|
75
|
+
}
|
|
76
|
+
.wx-bar-single-day:hover {
|
|
77
|
+
background-color: var(--wx-color-secondary-hover);
|
|
78
|
+
box-shadow: none;
|
|
79
|
+
opacity: 1;
|
|
80
|
+
}
|
|
81
|
+
.wx-bar-title {
|
|
82
|
+
padding: 0 8px;
|
|
83
|
+
white-space: nowrap;
|
|
84
|
+
overflow: hidden;
|
|
85
|
+
text-overflow: ellipsis;
|
|
86
|
+
font-size: var(--wx-font-size-sm);
|
|
87
|
+
line-height: 1.2;
|
|
88
|
+
}
|
|
89
|
+
</style>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Primitive, EventCss } from "@svar-ui/calendar-store";
|
|
2
|
+
type $$ComponentProps = {
|
|
3
|
+
primitives: Primitive[];
|
|
4
|
+
dx: number;
|
|
5
|
+
dy: number;
|
|
6
|
+
eventCss?: EventCss;
|
|
7
|
+
eventContent?: any;
|
|
8
|
+
view: string;
|
|
9
|
+
section: string;
|
|
10
|
+
};
|
|
11
|
+
declare const BarSection: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
12
|
+
type BarSection = ReturnType<typeof BarSection>;
|
|
13
|
+
export default BarSection;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
<script lang="ts">import { setID } from "@svar-ui/lib-dom";
|
|
2
|
+
const { primitives, dx, dy, layoutMode = "split", eventCss, eventContent, view, section } = $props();
|
|
3
|
+
const gap = 2;
|
|
4
|
+
const overlap = 20;
|
|
5
|
+
function style(p) {
|
|
6
|
+
const top = dy * p.y;
|
|
7
|
+
const height = dy * p.height - 1;
|
|
8
|
+
if (layoutMode === "overlap") {
|
|
9
|
+
const slot = p.slot ?? 0;
|
|
10
|
+
const laneOffset = slot * overlap;
|
|
11
|
+
const left = dx * p.x + gap + laneOffset;
|
|
12
|
+
const width = Math.max(0, dx * p.width - gap * 2 - laneOffset);
|
|
13
|
+
return `left:${left}px;top:${top}px;width:${width}px;height:${height}px;z-index:${slot}`;
|
|
14
|
+
}
|
|
15
|
+
const slotWidth = p.width / (p.maxConcurrency ?? 1);
|
|
16
|
+
const left = dx * (p.x + (p.slot ?? 0) * slotWidth) + gap;
|
|
17
|
+
const width = dx * slotWidth - gap * 2;
|
|
18
|
+
return `left:${left}px;top:${top}px;width:${width}px;height:${height}px`;
|
|
19
|
+
}
|
|
20
|
+
function formatTime(d) {
|
|
21
|
+
return d.toLocaleTimeString([], {
|
|
22
|
+
hour: "2-digit",
|
|
23
|
+
minute: "2-digit"
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
function css(p) {
|
|
27
|
+
const base = p.event.css || "";
|
|
28
|
+
const dynamic = eventCss ? eventCss({
|
|
29
|
+
event: p.event,
|
|
30
|
+
view,
|
|
31
|
+
section,
|
|
32
|
+
mode: "boxes"
|
|
33
|
+
}) : "";
|
|
34
|
+
return base + (dynamic ? " " + dynamic : "");
|
|
35
|
+
}
|
|
36
|
+
</script>
|
|
37
|
+
|
|
38
|
+
<div class="wx-box-section">
|
|
39
|
+
{#each primitives as p (p.id)}
|
|
40
|
+
<div
|
|
41
|
+
class="wx-box-event {css(p)}"
|
|
42
|
+
style={style(p)}
|
|
43
|
+
data-id={setID(p.id)}
|
|
44
|
+
>
|
|
45
|
+
{#if eventContent}
|
|
46
|
+
{@const EventContentCmp = eventContent}
|
|
47
|
+
<EventContentCmp event={p.event} mode="boxes" />
|
|
48
|
+
{:else}
|
|
49
|
+
<div class="wx-box-time">
|
|
50
|
+
{formatTime(p.event.start)} – {formatTime(p.event.end)}
|
|
51
|
+
</div>
|
|
52
|
+
<div class="wx-box-title">
|
|
53
|
+
{p.event.text || ""}
|
|
54
|
+
</div>
|
|
55
|
+
{/if}
|
|
56
|
+
</div>
|
|
57
|
+
{/each}
|
|
58
|
+
</div>
|
|
59
|
+
|
|
60
|
+
<style>
|
|
61
|
+
.wx-box-section {
|
|
62
|
+
position: relative;
|
|
63
|
+
width: 100%;
|
|
64
|
+
height: 100%;
|
|
65
|
+
}
|
|
66
|
+
.wx-box-event {
|
|
67
|
+
position: absolute;
|
|
68
|
+
background-color: var(--wx-color-primary);
|
|
69
|
+
color: var(--wx-color-primary-font);
|
|
70
|
+
border-radius: var(--wx-border-radius);
|
|
71
|
+
padding: 4px 8px;
|
|
72
|
+
overflow: hidden;
|
|
73
|
+
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
|
|
74
|
+
font-size: var(--wx-font-size-sm);
|
|
75
|
+
line-height: 1.3;
|
|
76
|
+
cursor: pointer;
|
|
77
|
+
z-index: 1;
|
|
78
|
+
}
|
|
79
|
+
.wx-box-event:hover {
|
|
80
|
+
opacity: 0.9;
|
|
81
|
+
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
|
|
82
|
+
}
|
|
83
|
+
.wx-box-time {
|
|
84
|
+
font-weight: var(--wx-font-weight-md);
|
|
85
|
+
font-size: 12px;
|
|
86
|
+
margin-bottom: 2px;
|
|
87
|
+
white-space: nowrap;
|
|
88
|
+
overflow: hidden;
|
|
89
|
+
text-overflow: ellipsis;
|
|
90
|
+
}
|
|
91
|
+
.wx-box-title {
|
|
92
|
+
overflow: hidden;
|
|
93
|
+
}
|
|
94
|
+
</style>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Primitive, EventCss } from "@svar-ui/calendar-store";
|
|
2
|
+
type BoxLayoutMode = "split" | "overlap";
|
|
3
|
+
type $$ComponentProps = {
|
|
4
|
+
primitives: Primitive[];
|
|
5
|
+
dx: number;
|
|
6
|
+
dy: number;
|
|
7
|
+
layoutMode?: BoxLayoutMode;
|
|
8
|
+
eventCss?: EventCss;
|
|
9
|
+
eventContent?: any;
|
|
10
|
+
view: string;
|
|
11
|
+
section: string;
|
|
12
|
+
};
|
|
13
|
+
declare const BoxSection: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
14
|
+
type BoxSection = ReturnType<typeof BoxSection>;
|
|
15
|
+
export default BoxSection;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<script lang="ts">import GridLines from "./GridLines.svelte";
|
|
2
|
+
import GridCells from "./GridCells.svelte";
|
|
3
|
+
const { xHeaders, yHeaders, dx, dy, cellCss, view, section, mode } = $props();
|
|
4
|
+
function hasWeekend(headers) {
|
|
5
|
+
if (!headers) return false;
|
|
6
|
+
const last = headers[headers.length - 1];
|
|
7
|
+
for (const u of last) if (u.weekend) return true;
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
{#if cellCss || hasWeekend(xHeaders)}
|
|
13
|
+
<GridCells {xHeaders} {yHeaders} {dx} {dy} {cellCss} {view} {section} {mode} />
|
|
14
|
+
{:else}
|
|
15
|
+
<GridLines {xHeaders} {yHeaders} {dx} {dy} />
|
|
16
|
+
{/if}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { CellCss, ScaleUnit, SectionMode } from "@svar-ui/calendar-store";
|
|
2
|
+
type $$ComponentProps = {
|
|
3
|
+
xHeaders: ScaleUnit[][] | null;
|
|
4
|
+
yHeaders: ScaleUnit[][] | null;
|
|
5
|
+
dx: number;
|
|
6
|
+
dy: number;
|
|
7
|
+
cellCss?: CellCss;
|
|
8
|
+
view: string;
|
|
9
|
+
section: string;
|
|
10
|
+
mode: SectionMode;
|
|
11
|
+
};
|
|
12
|
+
declare const Grid: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
13
|
+
type Grid = ReturnType<typeof Grid>;
|
|
14
|
+
export default Grid;
|