@burdenoff/microfe-calendar 2026.1123.2 → 2026.1124.1
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/AgendaView.js.map +1 -1
- package/dist/generated/wspace-operations.d.ts +596 -0
- package/dist/generated/wspace-operations.js +190 -85
- package/dist/generated/wspace-operations.js.map +1 -1
- package/dist/translations/en.d.ts +292 -0
- package/dist/v2/CalendarPageV2.js +87 -14
- package/dist/v2/CalendarPageV2.js.map +1 -1
- package/dist/v2/colors.d.ts +23 -0
- package/dist/v2/colors.js +92 -0
- package/dist/v2/colors.js.map +1 -0
- package/dist/v2/data/enums.d.ts +6 -0
- package/dist/v2/data/enums.js +10 -0
- package/dist/v2/data/enums.js.map +1 -0
- package/dist/v2/data/errors.d.ts +4 -0
- package/dist/v2/data/errors.js +17 -0
- package/dist/v2/data/errors.js.map +1 -0
- package/dist/v2/data/invalidation.js +19 -0
- package/dist/v2/data/invalidation.js.map +1 -0
- package/dist/v2/data/normalize.js +181 -16
- package/dist/v2/data/normalize.js.map +1 -1
- package/dist/v2/data/serialWrites.d.ts +17 -0
- package/dist/v2/data/serialWrites.js +21 -0
- package/dist/v2/data/serialWrites.js.map +1 -0
- package/dist/v2/data/useCalendarsV2.d.ts +10 -1
- package/dist/v2/data/useCalendarsV2.js +68 -16
- package/dist/v2/data/useCalendarsV2.js.map +1 -1
- package/dist/v2/data/useEventActions.d.ts +49 -0
- package/dist/v2/data/useEventActions.js +399 -0
- package/dist/v2/data/useEventActions.js.map +1 -0
- package/dist/v2/data/useEventForPeek.d.ts +17 -0
- package/dist/v2/data/useEventForPeek.js +29 -0
- package/dist/v2/data/useEventForPeek.js.map +1 -0
- package/dist/v2/data/useEventSearchV2.d.ts +15 -0
- package/dist/v2/data/useEventSearchV2.js +80 -0
- package/dist/v2/data/useEventSearchV2.js.map +1 -0
- package/dist/v2/data/useEventsInRangeV2.js +78 -0
- package/dist/v2/data/useEventsInRangeV2.js.map +1 -0
- package/dist/v2/data/useFreeBusy.d.ts +5 -0
- package/dist/v2/data/useFreeBusy.js +83 -0
- package/dist/v2/data/useFreeBusy.js.map +1 -0
- package/dist/v2/data/useKeyedLoad.js +47 -0
- package/dist/v2/data/useKeyedLoad.js.map +1 -0
- package/dist/v2/data/useRoomsV2.d.ts +28 -0
- package/dist/v2/data/useRoomsV2.js +45 -0
- package/dist/v2/data/useRoomsV2.js.map +1 -0
- package/dist/v2/day/DayPanel.d.ts +6 -0
- package/dist/v2/day/DayPanel.js +215 -0
- package/dist/v2/day/DayPanel.js.map +1 -0
- package/dist/v2/day/daySummary.d.ts +37 -0
- package/dist/v2/day/daySummary.js +37 -0
- package/dist/v2/day/daySummary.js.map +1 -0
- package/dist/v2/dialogs/CalendarDialogsV2.d.ts +1 -0
- package/dist/v2/dialogs/CalendarDialogsV2.js +17 -0
- package/dist/v2/dialogs/CalendarDialogsV2.js.map +1 -0
- package/dist/v2/dialogs/ShortcutsDialog.d.ts +4 -0
- package/dist/v2/dialogs/ShortcutsDialog.js +42 -0
- package/dist/v2/dialogs/ShortcutsDialog.js.map +1 -0
- package/dist/v2/events/eventLook.d.ts +46 -0
- package/dist/v2/events/eventLook.js +35 -0
- package/dist/v2/events/eventLook.js.map +1 -0
- package/dist/v2/events/eventModel.d.ts +92 -0
- package/dist/v2/events/eventModel.js +116 -0
- package/dist/v2/events/eventModel.js.map +1 -0
- package/dist/v2/events/localChanges.d.ts +4 -0
- package/dist/v2/events/localChanges.js +23 -0
- package/dist/v2/events/localChanges.js.map +1 -0
- package/dist/v2/format.d.ts +67 -0
- package/dist/v2/format.js +112 -0
- package/dist/v2/format.js.map +1 -0
- package/dist/v2/grid/AllDayRow.d.ts +20 -0
- package/dist/v2/grid/AllDayRow.js +94 -0
- package/dist/v2/grid/AllDayRow.js.map +1 -0
- package/dist/v2/grid/EventBlock.d.ts +21 -0
- package/dist/v2/grid/EventBlock.js +112 -0
- package/dist/v2/grid/EventBlock.js.map +1 -0
- package/dist/v2/grid/GridParts.d.ts +40 -0
- package/dist/v2/grid/GridParts.js +204 -0
- package/dist/v2/grid/GridParts.js.map +1 -0
- package/dist/v2/grid/QuickCreate.d.ts +1 -0
- package/dist/v2/grid/QuickCreate.js +175 -0
- package/dist/v2/grid/QuickCreate.js.map +1 -0
- package/dist/v2/grid/TimeGrid.d.ts +1 -0
- package/dist/v2/grid/TimeGrid.js +179 -0
- package/dist/v2/grid/TimeGrid.js.map +1 -0
- package/dist/v2/grid/geometry.d.ts +72 -0
- package/dist/v2/grid/geometry.js +85 -0
- package/dist/v2/grid/geometry.js.map +1 -0
- package/dist/v2/grid/layout.d.ts +24 -0
- package/dist/v2/grid/layout.js +77 -0
- package/dist/v2/grid/layout.js.map +1 -0
- package/dist/v2/grid/useGridDrag.d.ts +42 -0
- package/dist/v2/grid/useGridDrag.js +181 -0
- package/dist/v2/grid/useGridDrag.js.map +1 -0
- package/dist/v2/grid/useSlotCursor.d.ts +32 -0
- package/dist/v2/grid/useSlotCursor.js +57 -0
- package/dist/v2/grid/useSlotCursor.js.map +1 -0
- package/dist/v2/grid/workingHours.d.ts +21 -0
- package/dist/v2/grid/workingHours.js +101 -0
- package/dist/v2/grid/workingHours.js.map +1 -0
- package/dist/v2/hooks/useAvailableHeight.d.ts +2 -0
- package/dist/v2/hooks/useAvailableHeight.js +25 -0
- package/dist/v2/hooks/useAvailableHeight.js.map +1 -0
- package/dist/v2/hooks/useCalendarShortcuts.d.ts +9 -0
- package/dist/v2/hooks/useCalendarShortcuts.js +60 -0
- package/dist/v2/hooks/useCalendarShortcuts.js.map +1 -0
- package/dist/v2/hooks/useDebouncedValue.d.ts +1 -0
- package/dist/v2/hooks/useDebouncedValue.js +12 -0
- package/dist/v2/hooks/useDebouncedValue.js.map +1 -0
- package/dist/v2/hooks/useMediaQuery.d.ts +5 -0
- package/dist/v2/hooks/useMediaQuery.js +17 -0
- package/dist/v2/hooks/useMediaQuery.js.map +1 -0
- package/dist/v2/hooks/useNow.d.ts +2 -0
- package/dist/v2/hooks/useNow.js +31 -0
- package/dist/v2/hooks/useNow.js.map +1 -0
- package/dist/v2/limits.d.ts +6 -0
- package/dist/v2/limits.js +5 -0
- package/dist/v2/limits.js.map +1 -0
- package/dist/v2/list/EventListRow.d.ts +10 -0
- package/dist/v2/list/EventListRow.js +109 -0
- package/dist/v2/list/EventListRow.js.map +1 -0
- package/dist/v2/list/ListViewV2.d.ts +12 -0
- package/dist/v2/list/ListViewV2.js +90 -0
- package/dist/v2/list/ListViewV2.js.map +1 -0
- package/dist/v2/month/MonthView.d.ts +1 -0
- package/dist/v2/month/MonthView.js +324 -0
- package/dist/v2/month/MonthView.js.map +1 -0
- package/dist/v2/month/monthLayout.d.ts +39 -0
- package/dist/v2/month/monthLayout.js +29 -0
- package/dist/v2/month/monthLayout.js.map +1 -0
- package/dist/v2/page/CalendarChrome.d.ts +2 -0
- package/dist/v2/page/CalendarChrome.js +295 -0
- package/dist/v2/page/CalendarChrome.js.map +1 -0
- package/dist/v2/page/CalendarPageContext.d.ts +92 -0
- package/dist/v2/page/CalendarPageContext.js +11 -0
- package/dist/v2/page/CalendarPageContext.js.map +1 -0
- package/dist/v2/page/pageHelpers.d.ts +19 -0
- package/dist/v2/page/pageHelpers.js +39 -0
- package/dist/v2/page/pageHelpers.js.map +1 -0
- package/dist/v2/page/useCalendarPageModel.d.ts +2 -0
- package/dist/v2/page/useCalendarPageModel.js +198 -0
- package/dist/v2/page/useCalendarPageModel.js.map +1 -0
- package/dist/v2/page/viewState.d.ts +70 -0
- package/dist/v2/page/viewState.js +47 -0
- package/dist/v2/page/viewState.js.map +1 -0
- package/dist/v2/peek/EventPeek.d.ts +2 -0
- package/dist/v2/peek/EventPeek.js +92 -0
- package/dist/v2/peek/EventPeek.js.map +1 -0
- package/dist/v2/peek/PeekEvent.d.ts +4 -0
- package/dist/v2/peek/PeekEvent.js +443 -0
- package/dist/v2/peek/PeekEvent.js.map +1 -0
- package/dist/v2/peek/PeekParts.d.ts +14 -0
- package/dist/v2/peek/PeekParts.js +75 -0
- package/dist/v2/peek/PeekParts.js.map +1 -0
- package/dist/v2/prefs/calendarPrefs.d.ts +2 -2
- package/dist/v2/prefs/calendarPrefs.js +35 -34
- package/dist/v2/prefs/calendarPrefs.js.map +1 -1
- package/dist/v2/rail/CalendarRail.d.ts +3 -0
- package/dist/v2/rail/CalendarRail.js +284 -0
- package/dist/v2/rail/CalendarRail.js.map +1 -0
- package/dist/v2/rail/railStatus.d.ts +54 -0
- package/dist/v2/rail/railStatus.js +84 -0
- package/dist/v2/rail/railStatus.js.map +1 -0
- package/dist/v2/rail/syncWords.d.ts +10 -0
- package/dist/v2/rail/syncWords.js +75 -0
- package/dist/v2/rail/syncWords.js.map +1 -0
- package/dist/v2/rail/useMonthEventDates.d.ts +4 -0
- package/dist/v2/rail/useMonthEventDates.js +30 -0
- package/dist/v2/rail/useMonthEventDates.js.map +1 -0
- package/dist/v2/routes.js +4 -1
- package/dist/v2/routes.js.map +1 -1
- package/dist/v2/search/SearchResults.d.ts +1 -0
- package/dist/v2/search/SearchResults.js +88 -0
- package/dist/v2/search/SearchResults.js.map +1 -0
- package/dist/v2/search/searchModel.d.ts +20 -0
- package/dist/v2/search/searchModel.js +22 -0
- package/dist/v2/search/searchModel.js.map +1 -0
- package/dist/v2/state/calendarV2Store.d.ts +4 -1
- package/dist/v2/state/calendarV2Store.js +3 -1
- package/dist/v2/state/calendarV2Store.js.map +1 -1
- package/dist/v2/state/useCalendarV2Navigation.d.ts +1 -0
- package/dist/v2/state/useCalendarV2Navigation.js +4 -1
- package/dist/v2/state/useCalendarV2Navigation.js.map +1 -1
- package/dist/v2/states/CalendarStates.d.ts +18 -0
- package/dist/v2/states/CalendarStates.js +122 -0
- package/dist/v2/states/CalendarStates.js.map +1 -0
- package/dist/v2/styles.d.ts +32 -0
- package/dist/v2/styles.js +10 -0
- package/dist/v2/styles.js.map +1 -0
- package/dist/v2/time/calendarTime.js +121 -35
- package/dist/v2/time/calendarTime.js.map +1 -1
- package/dist/v2/types.d.ts +22 -2
- package/package.json +1 -1
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import { calendarHueStyle as e } from "../colors.js";
|
|
2
|
+
import { formatDay as t, formatDuration as n, formatMinuteRange as r, formatMinutes as i } from "../format.js";
|
|
3
|
+
import { useCalendarPage as a } from "../page/CalendarPageContext.js";
|
|
4
|
+
import { FOCUS_RING as o } from "../styles.js";
|
|
5
|
+
import { isWeekendDay as s } from "../time/calendarTime.js";
|
|
6
|
+
import { EventBlock as c } from "./EventBlock.js";
|
|
7
|
+
import { minuteOffset as l } from "./geometry.js";
|
|
8
|
+
import { offHours as u } from "./workingHours.js";
|
|
9
|
+
import { CalendarPlus as d, Plus as f } from "lucide-react";
|
|
10
|
+
import { Fragment as p, jsx as m, jsxs as h } from "react/jsx-runtime";
|
|
11
|
+
import { Button as g, EmptyState as _, formatTimeZoneOffset as v } from "@burdenoff/fe-libs/ui";
|
|
12
|
+
import { cn as y } from "@burdenoff/fe-libs/utils";
|
|
13
|
+
// src/v2/grid/GridParts.tsx
|
|
14
|
+
var b = Array.from({ length: 24 }, (e, t) => t);
|
|
15
|
+
function x({ columnsStyle: e }) {
|
|
16
|
+
let t = a(), { tr: n, format: r, timeZone: i, compact: s, days: c, today: l, nav: u } = t, d = v(i, t.now, r.locale), f = n("calendar.v2.timeZoneButton", "Time zone: {{zone}}", { zone: i });
|
|
17
|
+
return /* @__PURE__ */ h("div", {
|
|
18
|
+
className: "grid border-b border-border-subtle",
|
|
19
|
+
style: e,
|
|
20
|
+
children: [/* @__PURE__ */ m("div", {
|
|
21
|
+
className: "flex items-end justify-end pe-1 pb-1.5",
|
|
22
|
+
children: /* @__PURE__ */ m("button", {
|
|
23
|
+
type: "button",
|
|
24
|
+
onClick: () => u.openDialog("settings"),
|
|
25
|
+
title: f,
|
|
26
|
+
"aria-label": f,
|
|
27
|
+
className: y("rounded px-[3px] py-0.5 text-[10px] whitespace-nowrap tabular-nums text-text-muted hover:bg-bg-sunken hover:text-text-primary", o),
|
|
28
|
+
children: s ? d.replace(/^[^+−-]*/, "") : d
|
|
29
|
+
})
|
|
30
|
+
}), c.map((e) => /* @__PURE__ */ m(S, {
|
|
31
|
+
day: e,
|
|
32
|
+
isToday: e === l
|
|
33
|
+
}, e))]
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
function S({ day: e, isToday: n }) {
|
|
37
|
+
let { tr: r, format: i, compact: c, nav: l } = a(), u = s(e), d = n ? "today" : u ? "weekend" : "day";
|
|
38
|
+
return /* @__PURE__ */ h("button", {
|
|
39
|
+
type: "button",
|
|
40
|
+
onClick: () => l.goTo({
|
|
41
|
+
view: "day",
|
|
42
|
+
date: e
|
|
43
|
+
}),
|
|
44
|
+
"aria-current": n ? "date" : void 0,
|
|
45
|
+
"aria-label": r("calendar.v2.openDay", "{{day}}. Open the day", { day: t(e, i, "full") }),
|
|
46
|
+
className: y("flex min-w-0 items-center justify-center gap-1.5 border-s border-border-subtle px-0.5 py-[7px] hover:bg-bg-sunken", c && "flex-col gap-px py-[5px]", o),
|
|
47
|
+
children: [/* @__PURE__ */ m("span", {
|
|
48
|
+
className: y("text-[11px] font-semibold uppercase tracking-[0.06em]", d === "today" && "text-action-primary-bg", d === "weekend" && "text-text-muted", d === "day" && "text-text-secondary"),
|
|
49
|
+
children: t(e, i, "weekday")
|
|
50
|
+
}), /* @__PURE__ */ m("span", {
|
|
51
|
+
className: y("grid h-[30px] min-w-[30px] place-items-center rounded-full px-1 text-lg font-semibold tabular-nums", c && "h-7 min-w-7 text-base", d === "today" && "bg-action-primary-bg text-action-primary-text", d === "weekend" && "text-text-muted", d === "day" && "text-text-primary"),
|
|
52
|
+
children: t(e, i, "dayNumber")
|
|
53
|
+
})]
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
function C({ hourHeight: e }) {
|
|
57
|
+
let { format: t, days: n, today: r, nowMinute: o } = a(), s = n.includes(r);
|
|
58
|
+
return /* @__PURE__ */ h("div", {
|
|
59
|
+
className: "relative",
|
|
60
|
+
"aria-hidden": "true",
|
|
61
|
+
children: [b.map((n) => n === 0 || s && Math.abs(n * 60 - o) < 13 ? null : /* @__PURE__ */ m("span", {
|
|
62
|
+
className: "absolute end-[7px] -translate-y-1/2 text-[11px] leading-none whitespace-nowrap tabular-nums text-text-muted",
|
|
63
|
+
style: { top: n * e },
|
|
64
|
+
children: i(n * 60, t)
|
|
65
|
+
}, n)), s ? /* @__PURE__ */ m("span", {
|
|
66
|
+
className: "absolute end-[3px] z-[4] -translate-y-1/2 rounded-full bg-action-primary-bg px-[5px] py-[3px] text-[10.5px] leading-none font-bold whitespace-nowrap tabular-nums text-action-primary-text",
|
|
67
|
+
style: { top: l(o, e) },
|
|
68
|
+
children: i(o, t)
|
|
69
|
+
}) : null]
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
function w({ day: e, hourHeight: t }) {
|
|
73
|
+
let { workingHoursOn: n } = a(), r = n(e);
|
|
74
|
+
return r === void 0 ? null : /* @__PURE__ */ m(p, { children: u(r).map((e) => /* @__PURE__ */ m("div", {
|
|
75
|
+
className: "pointer-events-none absolute inset-x-0 bg-bg-sunken/70",
|
|
76
|
+
style: {
|
|
77
|
+
top: l(e.start, t),
|
|
78
|
+
height: l(e.end - e.start, t)
|
|
79
|
+
}
|
|
80
|
+
}, e.start)) });
|
|
81
|
+
}
|
|
82
|
+
function T({ isToday: e, hourHeight: t }) {
|
|
83
|
+
let { nowMinute: n } = a();
|
|
84
|
+
return /* @__PURE__ */ m("div", {
|
|
85
|
+
"aria-hidden": "true",
|
|
86
|
+
className: y("pointer-events-none absolute inset-x-0", e ? "-start-px z-[5] -mt-px h-0.5 bg-action-primary-bg before:absolute before:-start-[5px] before:-top-1 before:size-2.5 before:rounded-full before:bg-action-primary-bg" : "z-[2] h-px bg-[color-mix(in_oklab,var(--color-action-primary-bg)_40%,transparent)]"),
|
|
87
|
+
style: { top: l(n, t) }
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
function E({ day: i, placed: o, hourHeight: s, selectedId: u, onOpen: d, onKeyDown: f, consumeClick: p, ghost: g, quick: _, cursorMinute: v }) {
|
|
91
|
+
let b = a(), { tr: x, format: S, compact: C, today: E, days: O } = b, k = i === E, A = {
|
|
92
|
+
backgroundImage: "linear-gradient(to bottom, var(--color-border-subtle) 1px, transparent 1px), linear-gradient(to bottom, color-mix(in oklab, var(--color-border-subtle) 45%, transparent) 1px, transparent 1px)",
|
|
93
|
+
backgroundSize: `100% ${s}px, 100% ${s}px`,
|
|
94
|
+
backgroundPosition: `0 0, 0 ${s / 2}px`
|
|
95
|
+
};
|
|
96
|
+
return /* @__PURE__ */ h("div", {
|
|
97
|
+
"data-grid-day": i,
|
|
98
|
+
role: "group",
|
|
99
|
+
"aria-label": x("calendar.v2.dayColumn", "{{day}}: {{count}} events", {
|
|
100
|
+
day: t(i, S, "full"),
|
|
101
|
+
count: o.length
|
|
102
|
+
}),
|
|
103
|
+
className: y("relative border-s border-border-subtle", k && "bg-accent-soft/30"),
|
|
104
|
+
style: A,
|
|
105
|
+
children: [
|
|
106
|
+
/* @__PURE__ */ m(w, {
|
|
107
|
+
day: i,
|
|
108
|
+
hourHeight: s
|
|
109
|
+
}),
|
|
110
|
+
o.map((e) => {
|
|
111
|
+
let t = b.lookOf(e.event);
|
|
112
|
+
return /* @__PURE__ */ m(c, {
|
|
113
|
+
placed: e,
|
|
114
|
+
hourHeight: s,
|
|
115
|
+
look: t,
|
|
116
|
+
hue: b.hueOf(e.event.calendarId),
|
|
117
|
+
label: b.labelOf(e.event),
|
|
118
|
+
format: S,
|
|
119
|
+
selected: u === e.event.id,
|
|
120
|
+
resizable: t.movable && !C && !e.continuesAfter,
|
|
121
|
+
onOpen: d,
|
|
122
|
+
onKeyDown: f,
|
|
123
|
+
consumeClick: p
|
|
124
|
+
}, `${e.event.id}|${e.date}`);
|
|
125
|
+
}),
|
|
126
|
+
O.includes(E) ? /* @__PURE__ */ m(T, {
|
|
127
|
+
isToday: k,
|
|
128
|
+
hourHeight: s
|
|
129
|
+
}) : null,
|
|
130
|
+
g ? /* @__PURE__ */ m(D, {
|
|
131
|
+
start: g.start,
|
|
132
|
+
end: g.end,
|
|
133
|
+
hourHeight: s,
|
|
134
|
+
hueStyle: g.event ? e(b.hueOf(g.event.calendarId)) : void 0,
|
|
135
|
+
label: g.event ? `${g.event.title} · ${r(g.start, g.end, S)}` : `${r(g.start, g.end, S)} · ${n(g.end - g.start, b.durationWords)}`
|
|
136
|
+
}) : null,
|
|
137
|
+
_ ? /* @__PURE__ */ m(D, {
|
|
138
|
+
start: _.start,
|
|
139
|
+
end: _.end,
|
|
140
|
+
hourHeight: s,
|
|
141
|
+
label: r(_.start, _.end, S),
|
|
142
|
+
quickAnchor: !0
|
|
143
|
+
}) : null,
|
|
144
|
+
v === null ? null : /* @__PURE__ */ m("div", {
|
|
145
|
+
"aria-hidden": "true",
|
|
146
|
+
className: "pointer-events-none absolute inset-x-0.5 z-[8] rounded-md border-2 border-[var(--color-focus-ring)] bg-accent-soft/40 px-1.5 text-[11px] font-semibold text-text-primary",
|
|
147
|
+
style: {
|
|
148
|
+
top: l(v, s),
|
|
149
|
+
height: l(30, s) - 2
|
|
150
|
+
},
|
|
151
|
+
children: r(v, v + 30, S)
|
|
152
|
+
})
|
|
153
|
+
]
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
function D({ start: e, end: t, hourHeight: n, label: r, hueStyle: i, quickAnchor: a = !1 }) {
|
|
157
|
+
return /* @__PURE__ */ m("div", {
|
|
158
|
+
"aria-hidden": "true",
|
|
159
|
+
"data-quick-ghost": a || void 0,
|
|
160
|
+
className: y("pointer-events-none absolute inset-x-0.5 z-[9] overflow-hidden rounded-md border border-dashed px-1.5 py-0.5 text-[11px] font-semibold text-text-primary", i ? "border-[var(--cal-hue)] bg-[color-mix(in_oklab,var(--cal-hue)_22%,var(--color-bg-surface))]" : "border-action-primary-bg bg-accent-soft/70"),
|
|
161
|
+
style: {
|
|
162
|
+
...i,
|
|
163
|
+
top: l(e, n),
|
|
164
|
+
height: Math.max(18, l(t - e, n) - 2)
|
|
165
|
+
},
|
|
166
|
+
children: r
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
function O() {
|
|
170
|
+
let e = a(), { tr: t, compact: n } = e, r = e.days.includes(e.today) ? e.today : e.days[0] ?? e.today;
|
|
171
|
+
return /* @__PURE__ */ m("div", {
|
|
172
|
+
className: "pointer-events-none absolute inset-0 z-30 grid place-items-center p-4",
|
|
173
|
+
children: /* @__PURE__ */ m("div", {
|
|
174
|
+
className: "pointer-events-auto w-full max-w-sm rounded-card border border-border-default bg-bg-elevated shadow-elevation-3",
|
|
175
|
+
children: /* @__PURE__ */ m(_, {
|
|
176
|
+
compact: !0,
|
|
177
|
+
size: "panel",
|
|
178
|
+
kind: "first-use",
|
|
179
|
+
illustration: "calendar",
|
|
180
|
+
title: t("calendar.v2.emptyDays", "Nothing on these days"),
|
|
181
|
+
description: n ? t("calendar.v2.emptyDaysPhone", "Add an event, or bring in a team, holiday or other calendar.") : t("calendar.v2.emptyDaysDesktop", "Click and drag on the grid to add an event, or bring in a team, holiday or other calendar."),
|
|
182
|
+
action: /* @__PURE__ */ h(g, {
|
|
183
|
+
type: "button",
|
|
184
|
+
onClick: () => e.openEventDialog({
|
|
185
|
+
date: r,
|
|
186
|
+
start: e.workingHoursOn(r)?.start ?? 540,
|
|
187
|
+
end: (e.workingHoursOn(r)?.start ?? 540) + e.prefs.defaultDuration,
|
|
188
|
+
allDay: !1
|
|
189
|
+
}),
|
|
190
|
+
children: [/* @__PURE__ */ m(f, { "aria-hidden": "true" }), t("calendar.v2.newEvent", "New event")]
|
|
191
|
+
}),
|
|
192
|
+
secondaryAction: /* @__PURE__ */ h(g, {
|
|
193
|
+
type: "button",
|
|
194
|
+
variant: "outline",
|
|
195
|
+
onClick: () => e.nav.openDialog("share"),
|
|
196
|
+
children: [/* @__PURE__ */ m(d, { "aria-hidden": "true" }), t("calendar.v2.addCalendar", "Add a calendar")]
|
|
197
|
+
})
|
|
198
|
+
})
|
|
199
|
+
})
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
export { E as DayColumn, x as DayHeaderRow, O as GridEmpty, D as GridGhost, C as HourGutter };
|
|
203
|
+
|
|
204
|
+
//# sourceMappingURL=GridParts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GridParts.js","names":["_Fragment","HOURS","hour","DayHeaderRow","page","useCalendarPage","offsetLabel","formatTimeZoneOffset","timeZone","format","zoneLabel","tr","columnsStyle","nav","cn","FOCUS_RING","compact","days","DayHeader","day","today","weekend","isWeekendDay","tone","isToday","formatDay","HourGutter","showsToday","nowMinute","hourHeight","formatMinutes","minuteOffset","OffHours","hours","workingHoursOn","Fragment","offHours","stretch","NowLine","DayColumn","lineStyle","placed","look","piece","EventBlock","selectedId","ghost","GridGhost","calendarHueStyle","formatMinuteRange","formatDuration","quick","cursorMinute","quickAnchor","hueStyle","start","end","label","GridEmpty","EmptyState","Button","Plus","CalendarPlus"],"sources":["../../../src/v2/grid/GridParts.tsx"],"sourcesContent":["/**\n * The time grid's parts (BOFF-15698 A1): the row of days, the hours down the side with the now\n * time, a day's column (working hours unshaded, its events, the now line, a drag's ghost, the\n * quick create's slot and the keyboard cursor), and the \"nothing on these days\" card.\n */\nimport type { CSSProperties, KeyboardEvent } from 'react';\nimport { CalendarPlus, Plus } from 'lucide-react';\nimport { Button, EmptyState, formatTimeZoneOffset, type DateValue } from '@burdenoff/fe-libs/ui';\nimport { cn } from '@burdenoff/fe-libs/utils';\nimport { calendarHueStyle } from '../colors';\nimport { formatDay, formatDuration, formatMinuteRange, formatMinutes } from '../format';\nimport { useCalendarPage, type QuickDraft } from '../page/CalendarPageContext';\nimport { FOCUS_RING } from '../styles';\nimport { isWeekendDay } from '../time/calendarTime';\nimport type { CalendarEventV2, PlacedSegment } from '../types';\nimport { EventBlock } from './EventBlock';\nimport { CURSOR_STEP, minuteOffset } from './geometry';\nimport type { DragGhost } from './useGridDrag';\nimport { offHours } from './workingHours';\n\nconst HOURS = Array.from({ length: 24 }, (_, hour) => hour);\n\n/** The time zone (it opens Calendar settings) and the shown days (each opens its Day view). */\nexport function DayHeaderRow({ columnsStyle }: { columnsStyle: CSSProperties }) {\n const page = useCalendarPage();\n const { tr, format, timeZone, compact, days, today, nav } = page;\n const offsetLabel = formatTimeZoneOffset(timeZone, page.now, format.locale);\n const zoneLabel = tr('calendar.v2.timeZoneButton', 'Time zone: {{zone}}', { zone: timeZone });\n return (\n <div className=\"grid border-b border-border-subtle\" style={columnsStyle}>\n <div className=\"flex items-end justify-end pe-1 pb-1.5\">\n <button\n type=\"button\"\n onClick={() => nav.openDialog('settings')}\n title={zoneLabel}\n aria-label={zoneLabel}\n className={cn(\n 'rounded px-[3px] py-0.5 text-[10px] whitespace-nowrap tabular-nums text-text-muted hover:bg-bg-sunken hover:text-text-primary',\n FOCUS_RING\n )}\n >\n {compact ? offsetLabel.replace(/^[^+−-]*/, '') : offsetLabel}\n </button>\n </div>\n {days.map((day) => (\n <DayHeader key={day} day={day} isToday={day === today} />\n ))}\n </div>\n );\n}\n\nfunction DayHeader({ day, isToday }: { day: DateValue; isToday: boolean }) {\n const { tr, format, compact, nav } = useCalendarPage();\n const weekend = isWeekendDay(day);\n const tone = isToday ? 'today' : weekend ? 'weekend' : 'day';\n return (\n <button\n type=\"button\"\n onClick={() => nav.goTo({ view: 'day', date: day })}\n aria-current={isToday ? 'date' : undefined}\n aria-label={tr('calendar.v2.openDay', '{{day}}. Open the day', {\n day: formatDay(day, format, 'full'),\n })}\n className={cn(\n 'flex min-w-0 items-center justify-center gap-1.5 border-s border-border-subtle px-0.5 py-[7px] hover:bg-bg-sunken',\n compact && 'flex-col gap-px py-[5px]',\n FOCUS_RING\n )}\n >\n <span\n className={cn(\n 'text-[11px] font-semibold uppercase tracking-[0.06em]',\n tone === 'today' && 'text-action-primary-bg',\n tone === 'weekend' && 'text-text-muted',\n tone === 'day' && 'text-text-secondary'\n )}\n >\n {formatDay(day, format, 'weekday')}\n </span>\n <span\n className={cn(\n 'grid h-[30px] min-w-[30px] place-items-center rounded-full px-1 text-lg font-semibold tabular-nums',\n compact && 'h-7 min-w-7 text-base',\n tone === 'today' && 'bg-action-primary-bg text-action-primary-text',\n tone === 'weekend' && 'text-text-muted',\n tone === 'day' && 'text-text-primary'\n )}\n >\n {formatDay(day, format, 'dayNumber')}\n </span>\n </button>\n );\n}\n\n/** The hours down the side, and the time now beside the now line (when today is shown). */\nexport function HourGutter({ hourHeight }: { hourHeight: number }) {\n const { format, days, today, nowMinute } = useCalendarPage();\n const showsToday = days.includes(today);\n return (\n <div className=\"relative\" aria-hidden=\"true\">\n {HOURS.map((hour) =>\n hour === 0 || (showsToday && Math.abs(hour * 60 - nowMinute) < 13) ? null : (\n <span\n key={hour}\n className=\"absolute end-[7px] -translate-y-1/2 text-[11px] leading-none whitespace-nowrap tabular-nums text-text-muted\"\n style={{ top: hour * hourHeight }}\n >\n {formatMinutes(hour * 60, format)}\n </span>\n )\n )}\n {showsToday ? (\n <span\n className=\"absolute end-[3px] z-[4] -translate-y-1/2 rounded-full bg-action-primary-bg px-[5px] py-[3px] text-[10.5px] leading-none font-bold whitespace-nowrap tabular-nums text-action-primary-text\"\n style={{ top: minuteOffset(nowMinute, hourHeight) }}\n >\n {formatMinutes(nowMinute, format)}\n </span>\n ) : null}\n </div>\n );\n}\n\n/** The hours outside the working day, shaded (a day off is shaded whole). */\nfunction OffHours({ day, hourHeight }: { day: DateValue; hourHeight: number }) {\n const { workingHoursOn } = useCalendarPage();\n const hours = workingHoursOn(day);\n // Not known (free/busy hasn't answered, or failed): no shading rather than a guess.\n if (hours === undefined) return null;\n return (\n <>\n {offHours(hours).map((stretch) => (\n <div\n key={stretch.start}\n className=\"pointer-events-none absolute inset-x-0 bg-bg-sunken/70\"\n style={{\n top: minuteOffset(stretch.start, hourHeight),\n height: minuteOffset(stretch.end - stretch.start, hourHeight),\n }}\n />\n ))}\n </>\n );\n}\n\n/** Now: a line with a dot across today, faint across the other shown days. */\nfunction NowLine({ isToday, hourHeight }: { isToday: boolean; hourHeight: number }) {\n const { nowMinute } = useCalendarPage();\n return (\n <div\n aria-hidden=\"true\"\n className={cn(\n 'pointer-events-none absolute inset-x-0',\n isToday\n ? '-start-px z-[5] -mt-px h-0.5 bg-action-primary-bg before:absolute before:-start-[5px] before:-top-1 before:size-2.5 before:rounded-full before:bg-action-primary-bg'\n : 'z-[2] h-px bg-[color-mix(in_oklab,var(--color-action-primary-bg)_40%,transparent)]'\n )}\n style={{ top: minuteOffset(nowMinute, hourHeight) }}\n />\n );\n}\n\nexport interface DayColumnProps {\n day: DateValue;\n placed: readonly PlacedSegment<CalendarEventV2>[];\n hourHeight: number;\n selectedId: string | null;\n onOpen: (event: CalendarEventV2, element: HTMLElement) => void;\n onKeyDown: (event: KeyboardEvent<HTMLButtonElement>, calendarEvent: CalendarEventV2) => void;\n consumeClick: () => boolean;\n /** A drag's preview in this column. */\n ghost: DragGhost | null;\n /** The quick create's slot in this column. */\n quick: QuickDraft | null;\n /** The keyboard cursor's minute in this column. */\n cursorMinute: number | null;\n}\n\n/** One day of the grid: its working hours, events, the now line and what's being made. */\nexport function DayColumn({\n day,\n placed,\n hourHeight,\n selectedId,\n onOpen,\n onKeyDown,\n consumeClick,\n ghost,\n quick,\n cursorMinute,\n}: DayColumnProps) {\n const page = useCalendarPage();\n const { tr, format, compact, today, days } = page;\n const isToday = day === today;\n const lineStyle: CSSProperties = {\n backgroundImage:\n 'linear-gradient(to bottom, var(--color-border-subtle) 1px, transparent 1px), linear-gradient(to bottom, color-mix(in oklab, var(--color-border-subtle) 45%, transparent) 1px, transparent 1px)',\n backgroundSize: `100% ${hourHeight}px, 100% ${hourHeight}px`,\n backgroundPosition: `0 0, 0 ${hourHeight / 2}px`,\n };\n return (\n <div\n data-grid-day={day}\n role=\"group\"\n aria-label={tr('calendar.v2.dayColumn', '{{day}}: {{count}} events', {\n day: formatDay(day, format, 'full'),\n count: placed.length,\n })}\n className={cn('relative border-s border-border-subtle', isToday && 'bg-accent-soft/30')}\n style={lineStyle}\n >\n <OffHours day={day} hourHeight={hourHeight} />\n {placed.map((piece) => {\n const look = page.lookOf(piece.event);\n return (\n <EventBlock\n key={`${piece.event.id}|${piece.date}`}\n placed={piece}\n hourHeight={hourHeight}\n look={look}\n hue={page.hueOf(piece.event.calendarId)}\n label={page.labelOf(piece.event)}\n format={format}\n selected={selectedId === piece.event.id}\n resizable={look.movable && !compact && !piece.continuesAfter}\n onOpen={onOpen}\n onKeyDown={onKeyDown}\n consumeClick={consumeClick}\n />\n );\n })}\n {days.includes(today) ? <NowLine isToday={isToday} hourHeight={hourHeight} /> : null}\n {ghost ? (\n <GridGhost\n start={ghost.start}\n end={ghost.end}\n hourHeight={hourHeight}\n hueStyle={ghost.event ? calendarHueStyle(page.hueOf(ghost.event.calendarId)) : undefined}\n label={\n ghost.event\n ? `${ghost.event.title} · ${formatMinuteRange(ghost.start, ghost.end, format)}`\n : `${formatMinuteRange(ghost.start, ghost.end, format)} · ${formatDuration(ghost.end - ghost.start, page.durationWords)}`\n }\n />\n ) : null}\n {quick ? (\n <GridGhost\n start={quick.start}\n end={quick.end}\n hourHeight={hourHeight}\n label={formatMinuteRange(quick.start, quick.end, format)}\n quickAnchor\n />\n ) : null}\n {cursorMinute !== null ? (\n <div\n aria-hidden=\"true\"\n className=\"pointer-events-none absolute inset-x-0.5 z-[8] rounded-md border-2 border-[var(--color-focus-ring)] bg-accent-soft/40 px-1.5 text-[11px] font-semibold text-text-primary\"\n style={{\n top: minuteOffset(cursorMinute, hourHeight),\n height: minuteOffset(CURSOR_STEP, hourHeight) - 2,\n }}\n >\n {formatMinuteRange(cursorMinute, cursorMinute + CURSOR_STEP, format)}\n </div>\n ) : null}\n </div>\n );\n}\n\nexport function GridGhost({\n start,\n end,\n hourHeight,\n label,\n hueStyle,\n quickAnchor = false,\n}: {\n start: number;\n end: number;\n hourHeight: number;\n label: string;\n hueStyle?: CSSProperties;\n quickAnchor?: boolean;\n}) {\n return (\n <div\n aria-hidden=\"true\"\n data-quick-ghost={quickAnchor || undefined}\n className={cn(\n 'pointer-events-none absolute inset-x-0.5 z-[9] overflow-hidden rounded-md border border-dashed px-1.5 py-0.5 text-[11px] font-semibold text-text-primary',\n hueStyle\n ? 'border-[var(--cal-hue)] bg-[color-mix(in_oklab,var(--cal-hue)_22%,var(--color-bg-surface))]'\n : 'border-action-primary-bg bg-accent-soft/70'\n )}\n style={{\n ...hueStyle,\n top: minuteOffset(start, hourHeight),\n height: Math.max(18, minuteOffset(end - start, hourHeight) - 2),\n }}\n >\n {label}\n </div>\n );\n}\n\n/** Nothing on the shown days: a card over the grid, which stays usable around it. */\nexport function GridEmpty() {\n const page = useCalendarPage();\n const { tr, compact } = page;\n const day = page.days.includes(page.today) ? page.today : (page.days[0] ?? page.today);\n return (\n <div className=\"pointer-events-none absolute inset-0 z-30 grid place-items-center p-4\">\n <div className=\"pointer-events-auto w-full max-w-sm rounded-card border border-border-default bg-bg-elevated shadow-elevation-3\">\n <EmptyState\n compact\n size=\"panel\"\n kind=\"first-use\"\n illustration=\"calendar\"\n title={tr('calendar.v2.emptyDays', 'Nothing on these days')}\n description={\n compact\n ? tr(\n 'calendar.v2.emptyDaysPhone',\n 'Add an event, or bring in a team, holiday or other calendar.'\n )\n : tr(\n 'calendar.v2.emptyDaysDesktop',\n 'Click and drag on the grid to add an event, or bring in a team, holiday or other calendar.'\n )\n }\n action={\n <Button\n type=\"button\"\n onClick={() =>\n page.openEventDialog({\n date: day,\n start: page.workingHoursOn(day)?.start ?? 9 * 60,\n end: (page.workingHoursOn(day)?.start ?? 9 * 60) + page.prefs.defaultDuration,\n allDay: false,\n })\n }\n >\n <Plus aria-hidden=\"true\" />\n {tr('calendar.v2.newEvent', 'New event')}\n </Button>\n }\n secondaryAction={\n <Button type=\"button\" variant=\"outline\" onClick={() => page.nav.openDialog('share')}>\n <CalendarPlus a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CAC1B,IAAMtD,IAAOC,EAAgB,GACvB,EAAE,OAAI,eAAYD,GAClBe,IAAMf,EAAK,KAAK,SAASA,EAAK,KAAK,IAAIA,EAAK,QAASA,EAAK,KAAK,MAAMA,EAAK;CAChF,OACE,kBAAC,OAAD;EAAK,WAAU;EACb,UAAA,kBAAC,OAAD;GAAK,WAAU;GACb,UAAA,kBAACuD,GAAD;IACE,SAAA;IACA,MAAK;IACL,MAAK;IACL,cAAa;IACb,OAAOhD,EAAG,yBAAyB,uBAAuB;IAC1D,aACEK,IACIL,EACE,8BACA,8DACF,IACAA,EACE,gCACA,4FACF;IAEN,QACE,kBAACiD,GAAD;KACE,MAAK;KACL,eACExD,EAAK,gBAAgB;MACnB,MAAMe;MACN,OAAOf,EAAK,eAAee,CAAG,CAAC,EAAE,SAAS;MAC1C,MAAMf,EAAK,eAAee,CAAG,CAAC,EAAE,SAAS,OAAUf,EAAK,MAAM;MAC9D,QAAQ;KACV,CAAC;KARL,UAAA,CAWE,kBAACyD,GAAD,EAAM,eAAY,OAAQ,CAAA,GACzBlD,EAAG,wBAAwB,WAAW,CACjC;;IAEV,iBACE,kBAACiD,GAAD;KAAQ,MAAK;KAAS,SAAQ;KAAU,eAAexD,EAAK,IAAI,WAAW,OAAO;KAAlF,UAAA,CACE,kBAAC0D,GAAD,EAAc,eAAY,OAAQ,CAAA,GACjCnD,EAAG,2BAA2B,gBAAgB,CACzC;;GAEX,CAAA;EACE,CAAA;CACF,CAAA;AAET"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function QuickCreateHost(): import('react').JSX.Element | null;
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { calendarHueStyle as e } from "../colors.js";
|
|
2
|
+
import { formatDay as t, formatDuration as n, formatMinuteRange as r } from "../format.js";
|
|
3
|
+
import { useCalendarPage as i } from "../page/CalendarPageContext.js";
|
|
4
|
+
import { zonedTimeToInstant as a } from "../time/calendarTime.js";
|
|
5
|
+
import { FOCUS_RING as o, ICON_BUTTON as s } from "../styles.js";
|
|
6
|
+
import { useMemo as c, useState as l } from "react";
|
|
7
|
+
import { Check as u, ChevronDown as d, Clock3 as f, X as p } from "lucide-react";
|
|
8
|
+
import { jsx as m, jsxs as h } from "react/jsx-runtime";
|
|
9
|
+
import { Button as g, DropdownMenu as _, DropdownMenuContent as v, DropdownMenuRadioGroup as y, DropdownMenuRadioItem as b, DropdownMenuTrigger as x, Input as S, Popover as C, PopoverAnchor as w, PopoverContent as T } from "@burdenoff/fe-libs/ui";
|
|
10
|
+
import { cn as E } from "@burdenoff/fe-libs/utils";
|
|
11
|
+
// src/v2/grid/QuickCreate.tsx
|
|
12
|
+
function D() {
|
|
13
|
+
let e = i(), t = e.quickDraft;
|
|
14
|
+
return !t || e.compact ? null : /* @__PURE__ */ m(O, { draft: t }, `${t.date}|${t.start}|${t.end}`);
|
|
15
|
+
}
|
|
16
|
+
function O({ draft: D }) {
|
|
17
|
+
let O = i(), { tr: k, format: A } = O, [j, M] = l(""), [N, P] = l(O.defaultCalendarId), [F, I] = l(!1), L = O.writableCalendars.find((e) => e.id === N) ?? null, R = c(() => ({ current: { getBoundingClientRect: () => {
|
|
18
|
+
let e = document.querySelector("[data-quick-ghost]") ?? (D.anchor?.isConnected ? D.anchor : null);
|
|
19
|
+
return e ? e.getBoundingClientRect() : new DOMRect(window.innerWidth / 2, 160, 0, 0);
|
|
20
|
+
} } }), [D.anchor]), z = D.allDay ? k("calendar.v2.allDayLower", "all day") : `${r(D.start, D.end, A)} (${n(D.end - D.start, O.durationWords)})`, B = async (e) => {
|
|
21
|
+
if (e?.preventDefault(), !L || F) return;
|
|
22
|
+
I(!0);
|
|
23
|
+
let t = !1;
|
|
24
|
+
try {
|
|
25
|
+
t = await O.actions.quickCreate({
|
|
26
|
+
calendarId: L.id,
|
|
27
|
+
title: j.trim() || k("calendar.v2.newEventTitle", "New event"),
|
|
28
|
+
start: a(D.date, D.allDay ? 0 : D.start, O.timeZone),
|
|
29
|
+
end: a(D.date, D.allDay ? 1440 : D.end, O.timeZone),
|
|
30
|
+
allDay: D.allDay
|
|
31
|
+
});
|
|
32
|
+
} finally {
|
|
33
|
+
I(!1);
|
|
34
|
+
}
|
|
35
|
+
t && O.closeQuickCreate();
|
|
36
|
+
};
|
|
37
|
+
return /* @__PURE__ */ h(C, {
|
|
38
|
+
open: !0,
|
|
39
|
+
onOpenChange: (e) => e ? void 0 : O.closeQuickCreate(),
|
|
40
|
+
children: [/* @__PURE__ */ m(w, { virtualRef: R }), /* @__PURE__ */ m(T, {
|
|
41
|
+
side: "right",
|
|
42
|
+
align: "start",
|
|
43
|
+
sideOffset: 8,
|
|
44
|
+
collisionPadding: 12,
|
|
45
|
+
className: "w-[340px] p-0",
|
|
46
|
+
"aria-labelledby": "calendar-quick-create-title",
|
|
47
|
+
onOpenAutoFocus: (e) => {
|
|
48
|
+
e.preventDefault(), document.getElementById("calendar-quick-create-input")?.focus();
|
|
49
|
+
},
|
|
50
|
+
children: /* @__PURE__ */ h("form", {
|
|
51
|
+
onSubmit: (e) => void B(e),
|
|
52
|
+
className: "flex flex-col gap-3 p-4",
|
|
53
|
+
children: [
|
|
54
|
+
/* @__PURE__ */ h("div", {
|
|
55
|
+
className: "flex items-center gap-2",
|
|
56
|
+
children: [/* @__PURE__ */ m("h3", {
|
|
57
|
+
id: "calendar-quick-create-title",
|
|
58
|
+
className: "flex-1 text-base font-bold text-text-primary",
|
|
59
|
+
children: k("calendar.v2.newEvent", "New event")
|
|
60
|
+
}), /* @__PURE__ */ m("button", {
|
|
61
|
+
type: "button",
|
|
62
|
+
className: s,
|
|
63
|
+
"aria-label": k("calendar.v2.close", "Close"),
|
|
64
|
+
onClick: O.closeQuickCreate,
|
|
65
|
+
children: /* @__PURE__ */ m(p, { "aria-hidden": "true" })
|
|
66
|
+
})]
|
|
67
|
+
}),
|
|
68
|
+
/* @__PURE__ */ m("label", {
|
|
69
|
+
className: "sr-only",
|
|
70
|
+
htmlFor: "calendar-quick-create-input",
|
|
71
|
+
children: k("calendar.v2.eventTitle", "Title")
|
|
72
|
+
}),
|
|
73
|
+
/* @__PURE__ */ m(S, {
|
|
74
|
+
id: "calendar-quick-create-input",
|
|
75
|
+
autoComplete: "off",
|
|
76
|
+
maxLength: 200,
|
|
77
|
+
placeholder: k("calendar.v2.addTitle", "Add a title"),
|
|
78
|
+
value: j,
|
|
79
|
+
onChange: (e) => M(e.target.value),
|
|
80
|
+
className: "h-11 text-base"
|
|
81
|
+
}),
|
|
82
|
+
/* @__PURE__ */ h("p", {
|
|
83
|
+
className: "flex items-center gap-2 text-sm text-text-primary",
|
|
84
|
+
children: [/* @__PURE__ */ m(f, {
|
|
85
|
+
className: "size-3.5 shrink-0 text-text-muted",
|
|
86
|
+
"aria-hidden": "true"
|
|
87
|
+
}), /* @__PURE__ */ h("span", { children: [
|
|
88
|
+
/* @__PURE__ */ m("b", {
|
|
89
|
+
className: "font-semibold",
|
|
90
|
+
children: t(D.date, A, "mid")
|
|
91
|
+
}),
|
|
92
|
+
" · ",
|
|
93
|
+
/* @__PURE__ */ m("span", {
|
|
94
|
+
className: "text-text-secondary",
|
|
95
|
+
children: z
|
|
96
|
+
})
|
|
97
|
+
] })]
|
|
98
|
+
}),
|
|
99
|
+
O.writableCalendars.length > 0 ? /* @__PURE__ */ h(_, { children: [/* @__PURE__ */ m(x, {
|
|
100
|
+
asChild: !0,
|
|
101
|
+
children: /* @__PURE__ */ h("button", {
|
|
102
|
+
type: "button",
|
|
103
|
+
"aria-label": k("calendar.v2.pickCalendar", "Calendar: {{name}}", { name: L?.name ?? "" }),
|
|
104
|
+
className: E("flex h-10 w-full items-center gap-2 rounded-input border border-border-default bg-bg-surface px-3 text-start text-sm text-text-primary hover:border-border-strong", o),
|
|
105
|
+
children: [
|
|
106
|
+
L ? /* @__PURE__ */ m("span", {
|
|
107
|
+
"aria-hidden": "true",
|
|
108
|
+
className: "size-2.5 shrink-0 rounded-[3px] bg-[var(--cal-hue)]",
|
|
109
|
+
style: e(O.hueOf(L.id))
|
|
110
|
+
}) : null,
|
|
111
|
+
/* @__PURE__ */ m("span", {
|
|
112
|
+
className: "min-w-0 flex-1 truncate",
|
|
113
|
+
children: L?.name
|
|
114
|
+
}),
|
|
115
|
+
/* @__PURE__ */ m(d, {
|
|
116
|
+
className: "size-4 text-text-muted",
|
|
117
|
+
"aria-hidden": "true"
|
|
118
|
+
})
|
|
119
|
+
]
|
|
120
|
+
})
|
|
121
|
+
}), /* @__PURE__ */ m(v, {
|
|
122
|
+
align: "start",
|
|
123
|
+
className: "w-[var(--radix-dropdown-menu-trigger-width)]",
|
|
124
|
+
children: /* @__PURE__ */ m(y, {
|
|
125
|
+
value: N ?? "",
|
|
126
|
+
onValueChange: P,
|
|
127
|
+
children: O.writableCalendars.map((t) => /* @__PURE__ */ h(b, {
|
|
128
|
+
value: t.id,
|
|
129
|
+
className: "gap-2",
|
|
130
|
+
children: [/* @__PURE__ */ m("span", {
|
|
131
|
+
"aria-hidden": "true",
|
|
132
|
+
className: "size-2.5 shrink-0 rounded-[3px] bg-[var(--cal-hue)]",
|
|
133
|
+
style: e(O.hueOf(t.id))
|
|
134
|
+
}), /* @__PURE__ */ m("span", {
|
|
135
|
+
className: "truncate",
|
|
136
|
+
children: t.name
|
|
137
|
+
})]
|
|
138
|
+
}, t.id))
|
|
139
|
+
})
|
|
140
|
+
})] }) : /* @__PURE__ */ m("p", {
|
|
141
|
+
className: "text-sm text-text-secondary",
|
|
142
|
+
children: k("calendar.v2.noWritableCalendar", "You don’t have a calendar you can add events to.")
|
|
143
|
+
}),
|
|
144
|
+
/* @__PURE__ */ h("div", {
|
|
145
|
+
className: "flex items-center gap-2",
|
|
146
|
+
children: [
|
|
147
|
+
/* @__PURE__ */ m(g, {
|
|
148
|
+
type: "button",
|
|
149
|
+
variant: "ghost",
|
|
150
|
+
onClick: () => O.openEventDialog({
|
|
151
|
+
date: D.date,
|
|
152
|
+
start: D.start,
|
|
153
|
+
end: D.end,
|
|
154
|
+
allDay: D.allDay,
|
|
155
|
+
calendarId: L?.id,
|
|
156
|
+
title: j.trim() || void 0
|
|
157
|
+
}),
|
|
158
|
+
children: k("calendar.v2.moreOptions", "More options")
|
|
159
|
+
}),
|
|
160
|
+
/* @__PURE__ */ m("span", { className: "flex-1" }),
|
|
161
|
+
/* @__PURE__ */ h(g, {
|
|
162
|
+
type: "submit",
|
|
163
|
+
disabled: !L || F,
|
|
164
|
+
children: [/* @__PURE__ */ m(u, { "aria-hidden": "true" }), k("calendar.v2.save", "Save")]
|
|
165
|
+
})
|
|
166
|
+
]
|
|
167
|
+
})
|
|
168
|
+
]
|
|
169
|
+
})
|
|
170
|
+
})]
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
export { D as QuickCreateHost };
|
|
174
|
+
|
|
175
|
+
//# sourceMappingURL=QuickCreate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"QuickCreate.js","names":["QuickCreateHost","page","useCalendarPage","draft","QuickCreate","title","setTitle","useState","calendarId","setCalendarId","saving","setSaving","calendar","item","anchor","useMemo","element","when","tr","formatMinuteRange","format","formatDuration","save","event","done","zonedTimeToInstant","Popover","open","PopoverAnchor","PopoverContent","focusEvent","ICON_BUTTON","X","Input","Clock3","formatDay","DropdownMenu","DropdownMenuTrigger","cn","FOCUS_RING","calendarHueStyle","ChevronDown","DropdownMenuContent","DropdownMenuRadioGroup","DropdownMenuRadioItem","Button","Check"],"sources":["../../../src/v2/grid/QuickCreate.tsx"],"sourcesContent":["/**\n * Quick create (BOFF-15698 A1): after a click or a click-drag on free time (or a free gap in the\n * Day panel, or a day in Month), a small popover: a title, when, and which calendar. Save adds\n * the event (Undo in the toast); More options opens the full event dialog with what was typed.\n * Desktop only: phones open the event dialog straight away.\n */\nimport { useMemo, useState, type FormEvent } from 'react';\nimport { Check, ChevronDown, Clock3, X } from 'lucide-react';\nimport {\n Button,\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuRadioGroup,\n DropdownMenuRadioItem,\n DropdownMenuTrigger,\n Input,\n Popover,\n PopoverAnchor,\n PopoverContent,\n} from '@burdenoff/fe-libs/ui';\nimport { cn } from '@burdenoff/fe-libs/utils';\nimport { calendarHueStyle } from '../colors';\nimport { formatDay, formatDuration, formatMinuteRange } from '../format';\nimport { useCalendarPage, type QuickDraft } from '../page/CalendarPageContext';\nimport { zonedTimeToInstant } from '../time/calendarTime';\nimport { FOCUS_RING, ICON_BUTTON } from '../styles';\n\nexport function QuickCreateHost() {\n const page = useCalendarPage();\n const draft = page.quickDraft;\n if (!draft || page.compact) return null;\n return <QuickCreate key={`${draft.date}|${draft.start}|${draft.end}`} draft={draft} />;\n}\n\nfunction QuickCreate({ draft }: { draft: QuickDraft }) {\n const page = useCalendarPage();\n const { tr, format } = page;\n const [title, setTitle] = useState('');\n const [calendarId, setCalendarId] = useState(page.defaultCalendarId);\n const [saving, setSaving] = useState(false);\n const calendar = page.writableCalendars.find((item) => item.id === calendarId) ?? null;\n const anchor = useMemo(\n () => ({\n current: {\n getBoundingClientRect: () => {\n const ghost = document.querySelector('[data-quick-ghost]');\n const element = ghost ?? (draft.anchor?.isConnected ? draft.anchor : null);\n return element\n ? element.getBoundingClientRect()\n : new DOMRect(window.innerWidth / 2, 160, 0, 0);\n },\n },\n }),\n [draft.anchor]\n );\n\n const when = draft.allDay\n ? tr('calendar.v2.allDayLower', 'all day')\n : `${formatMinuteRange(draft.start, draft.end, format)} (${formatDuration(draft.end - draft.start, page.durationWords)})`;\n\n const save = async (event?: FormEvent) => {\n event?.preventDefault();\n if (!calendar || saving) return;\n setSaving(true);\n let done = false;\n try {\n done = await page.actions.quickCreate({\n calendarId: calendar.id,\n title: title.trim() || tr('calendar.v2.newEventTitle', 'New event'),\n start: zonedTimeToInstant(draft.date, draft.allDay ? 0 : draft.start, page.timeZone),\n end: zonedTimeToInstant(draft.date, draft.allDay ? 1440 : draft.end, page.timeZone),\n allDay: draft.allDay,\n });\n } finally {\n setSaving(false);\n }\n if (done) page.closeQuickCreate();\n };\n\n return (\n <Popover open onOpenChange={(open) => (open ? undefined : page.closeQuickCreate())}>\n <PopoverAnchor virtualRef={anchor} />\n <PopoverContent\n side=\"right\"\n align=\"start\"\n sideOffset={8}\n collisionPadding={12}\n className=\"w-[340px] p-0\"\n aria-labelledby=\"calendar-quick-create-title\"\n onOpenAutoFocus={(focusEvent) => {\n focusEvent.preventDefault();\n document.getElementById('calendar-quick-create-input')?.focus();\n }}\n >\n <form onSubmit={(event) => void save(event)} className=\"flex flex-col gap-3 p-4\">\n <div className=\"flex items-center gap-2\">\n <h3\n id=\"calendar-quick-create-title\"\n className=\"flex-1 text-base font-bold text-text-primary\"\n >\n {tr('calendar.v2.newEvent', 'New event')}\n </h3>\n <button\n type=\"button\"\n className={ICON_BUTTON}\n aria-label={tr('calendar.v2.close', 'Close')}\n onClick={page.closeQuickCreate}\n >\n <X aria-hidden=\"true\" />\n </button>\n </div>\n <label className=\"sr-only\" htmlFor=\"calendar-quick-create-input\">\n {tr('calendar.v2.eventTitle', 'Title')}\n </label>\n <Input\n id=\"calendar-quick-create-input\"\n autoComplete=\"off\"\n maxLength={200}\n placeholder={tr('calendar.v2.addTitle', 'Add a title')}\n value={title}\n onChange={(event) => setTitle(event.target.value)}\n className=\"h-11 text-base\"\n />\n <p className=\"flex items-center gap-2 text-sm text-text-primary\">\n <Clock3 className=\"size-3.5 shrink-0 text-text-muted\" aria-hidden=\"true\" />\n <span>\n <b className=\"font-semibold\">{formatDay(draft.date, format, 'mid')}</b>\n {' · '}\n <span className=\"text-text-secondary\">{when}</span>\n </span>\n </p>\n {page.writableCalendars.length > 0 ? (\n <DropdownMenu>\n <DropdownMenuTrigger asChild>\n <button\n type=\"button\"\n aria-label={tr('calendar.v2.pickCalendar', 'Calendar: {{name}}', {\n name: calendar?.name ?? '',\n })}\n className={cn(\n 'flex h-10 w-full items-center gap-2 rounded-input border border-border-default bg-bg-surface px-3 text-start text-sm text-text-primary hover:border-border-strong',\n FOCUS_RING\n )}\n >\n {calendar ? (\n <span\n aria-hidden=\"true\"\n className=\"size-2.5 shrink-0 rounded-[3px] bg-[var(--cal-hue)]\"\n style={calendarHueStyle(page.hueOf(calendar.id))}\n />\n ) : null}\n <span className=\"min-w-0 flex-1 truncate\">{calendar?.name}</span>\n <ChevronDown className=\"size-4 text-text-muted\" aria-hidden=\"true\" />\n </button>\n </DropdownMenuTrigger>\n <DropdownMenuContent\n align=\"start\"\n className=\"w-[var(--radix-dropdown-menu-trigger-width)]\"\n >\n <DropdownMenuRadioGroup value={calendarId ?? ''} onValueChange={setCalendarId}>\n {page.writableCalendars.map((item) => (\n <DropdownMenuRadioItem key={item.id} value={item.id} className=\"gap-2\">\n <span\n aria-hidden=\"true\"\n className=\"size-2.5 shrink-0 rounded-[3px] bg-[var(--cal-hue)]\"\n style={calendarHueStyle(page.hueOf(item.id))}\n />\n <span className=\"truncate\">{item.name}</span>\n </DropdownMenuRadioItem>\n ))}\n </DropdownMenuRadioGroup>\n </DropdownMenuContent>\n </DropdownMenu>\n ) : (\n <p className=\"text-sm text-text-secondary\">\n {tr(\n 'calendar.v2.noWritableCalendar',\n 'You don’t have a calendar you can add events to.'\n )}\n </p>\n )}\n <div className=\"flex items-center gap-2\">\n <Button\n type=\"button\"\n variant=\"ghost\"\n onClick={() =>\n page.openEventDialog({\n date: draft.date,\n start: draft.start,\n end: draft.end,\n allDay: draft.allDay,\n calendarId: calendar?.id,\n title: title.trim() || undefined,\n })\n }\n >\n {tr('calendar.v2.moreOptions', 'More options')}\n </Button>\n <span className=\"flex-1\" />\n <Button type=\"submit\" disabled={!calendar || saving}>\n <Check aria-hidden=\"true\" />\n {tr('calendar.v2.save', 'Save')}\n </Button>\n </div>\n </form>\n </PopoverContent>\n </Popover>\n );\n}\n"],"mappings":";;;;;;;;;;;AA2BA,SAAgBA,IAAkB;CAChC,IAAMC,IAAOC,EAAgB,GACvBC,IAAQF,EAAK;CAEnB,OADI,CAACE,KAASF,EAAK,UAAgB,OAC5B,kBAACG,GAA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QACL,SAAQ;QACR,eACE5C,EAAK,gBAAgB;SACnB,MAAME,EAAM;SACZ,OAAOA,EAAM;SACb,KAAKA,EAAM;SACX,QAAQA,EAAM;SACd,YAAYS,GAAU;SACtB,OAAOP,EAAM,KAAK,KAAK,KAAA;QACzB,CAAC;QAGF,UAAAa,EAAG,2BAA2B,cAAc;OACvC,CAAA;OACR,kBAAC,QAAD,EAAM,WAAU,SAAU,CAAA;OAC1B,kBAAC2B,GAAD;QAAQ,MAAK;QAAS,UAAU,CAACjC,KAAYF;QAA7C,UAAA,CACE,kBAACoC,GAAD,EAAO,eAAY,OAAQ,CAAA,GAC1B5B,EAAG,oBAAoB,MAAM,CACxB;;MACL;;IACD;;EACQ,CAAA,CACT;;AAEb"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function TimeGrid(): import('react').JSX.Element;
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { allDayItems as e, timedSegmentsByDay as t } from "../events/eventModel.js";
|
|
2
|
+
import { formatDay as n } from "../format.js";
|
|
3
|
+
import { useCalendarPage as r } from "../page/CalendarPageContext.js";
|
|
4
|
+
import { MINUTES_PER_DAY as i } from "../time/calendarTime.js";
|
|
5
|
+
import { VIEW_PANEL as a } from "../styles.js";
|
|
6
|
+
import { AllDayRow as o } from "./AllDayRow.js";
|
|
7
|
+
import { HOUR_HEIGHT as s, minBlockMinutes as ee, openingScrollTop as c, planKeyboardMove as l, sameTimes as u } from "./geometry.js";
|
|
8
|
+
import { DayColumn as d, DayHeaderRow as f, GridEmpty as p, HourGutter as te } from "./GridParts.js";
|
|
9
|
+
import { allDayLanes as ne, layoutDay as re } from "./layout.js";
|
|
10
|
+
import { useGridDrag as m } from "./useGridDrag.js";
|
|
11
|
+
import { useSlotCursor as h } from "./useSlotCursor.js";
|
|
12
|
+
import { useCallback as g, useLayoutEffect as _, useMemo as v, useRef as y, useState as ie } from "react";
|
|
13
|
+
import { jsx as b, jsxs as x } from "react/jsx-runtime";
|
|
14
|
+
import { cn as ae } from "@burdenoff/fe-libs/utils";
|
|
15
|
+
// src/v2/grid/TimeGrid.tsx
|
|
16
|
+
var S = {
|
|
17
|
+
regular: 58,
|
|
18
|
+
compact: 44
|
|
19
|
+
}, C = (e) => e.id;
|
|
20
|
+
function w() {
|
|
21
|
+
let w = r(), { tr: oe, format: T, timeZone: E, compact: D, days: O, today: k, nowMinute: se, nav: A, prefs: j, events: M } = w, N = D ? s.compact : s.regular, P = D ? S.compact : S.regular, F = y(null), I = y(null), L = y(null), R = O[0] ?? A.date, z = O[O.length - 1] ?? A.date, B = O.includes(k), V = `${A.view}|${R}|${O.length}|${N}`, H = y(null);
|
|
22
|
+
_(() => {
|
|
23
|
+
let e = F.current;
|
|
24
|
+
if (!e) return;
|
|
25
|
+
let t = () => {
|
|
26
|
+
H.current === V || e.scrollHeight <= e.clientHeight || (e.scrollTop = c(N), H.current = V);
|
|
27
|
+
};
|
|
28
|
+
if (t(), typeof ResizeObserver != "function") return;
|
|
29
|
+
let n = new ResizeObserver(t);
|
|
30
|
+
return n.observe(e), () => n.disconnect();
|
|
31
|
+
}, [V, N]);
|
|
32
|
+
let U = v(() => t(M, O, E), [
|
|
33
|
+
O,
|
|
34
|
+
M,
|
|
35
|
+
E
|
|
36
|
+
]), W = v(() => {
|
|
37
|
+
let e = ee(N);
|
|
38
|
+
return new Map(O.map((t) => [t, re(U.get(t) ?? [], e, C)]));
|
|
39
|
+
}, [
|
|
40
|
+
O,
|
|
41
|
+
N,
|
|
42
|
+
U
|
|
43
|
+
]), [G, ce] = ie(!1), K = v(() => ne(e(M, R, z, E), O, G ? Infinity : 3, C), [
|
|
44
|
+
G,
|
|
45
|
+
O,
|
|
46
|
+
M,
|
|
47
|
+
R,
|
|
48
|
+
z,
|
|
49
|
+
E
|
|
50
|
+
]), le = v(() => new Map(M.map((e) => [e.id, e])), [M]), ue = g((e, t, n) => {
|
|
51
|
+
w.actions.changeTimes(e, t, n);
|
|
52
|
+
}, [w.actions]), q = m({
|
|
53
|
+
containerRef: I,
|
|
54
|
+
hourHeight: N,
|
|
55
|
+
timeZone: E,
|
|
56
|
+
disabled: D,
|
|
57
|
+
defaultDuration: j.defaultDuration,
|
|
58
|
+
eventById: (e) => le.get(e),
|
|
59
|
+
canMove: (e) => w.lookOf(e).movable,
|
|
60
|
+
onCreate: (e) => {
|
|
61
|
+
w.closePeek(), w.openQuickCreate({
|
|
62
|
+
...e,
|
|
63
|
+
allDay: !1,
|
|
64
|
+
anchor: null
|
|
65
|
+
});
|
|
66
|
+
},
|
|
67
|
+
onChange: ue
|
|
68
|
+
}), de = (e, t) => {
|
|
69
|
+
let n = Math.min(i, t + j.defaultDuration);
|
|
70
|
+
D ? w.openEventDialog({
|
|
71
|
+
date: e,
|
|
72
|
+
start: t,
|
|
73
|
+
end: n,
|
|
74
|
+
allDay: !1
|
|
75
|
+
}) : (w.closePeek(), w.openQuickCreate({
|
|
76
|
+
date: e,
|
|
77
|
+
start: t,
|
|
78
|
+
end: n,
|
|
79
|
+
allDay: !1,
|
|
80
|
+
anchor: null
|
|
81
|
+
}));
|
|
82
|
+
}, J = h({
|
|
83
|
+
scrollRef: F,
|
|
84
|
+
headerRef: L,
|
|
85
|
+
hourHeight: N,
|
|
86
|
+
days: O,
|
|
87
|
+
format: T,
|
|
88
|
+
workingHoursOn: w.workingHoursOn,
|
|
89
|
+
start: () => B ? {
|
|
90
|
+
date: k,
|
|
91
|
+
minute: Math.min(i - 30, Math.ceil(se / 30) * 30)
|
|
92
|
+
} : {
|
|
93
|
+
date: R,
|
|
94
|
+
minute: w.workingHoursOn(R)?.start ?? 540
|
|
95
|
+
},
|
|
96
|
+
onCreate: (e) => de(e.date, e.minute)
|
|
97
|
+
}), Y = (e, t) => {
|
|
98
|
+
let n = w.lookOf(t), r = e.key;
|
|
99
|
+
if ((r === "Delete" || r === "Backspace") && n.editable) {
|
|
100
|
+
e.preventDefault(), w.actions.remove(t);
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
if (r !== "ArrowUp" && r !== "ArrowDown" && r !== "ArrowLeft" && r !== "ArrowRight") return;
|
|
104
|
+
if (e.preventDefault(), e.shiftKey) {
|
|
105
|
+
if (!n.movable) return;
|
|
106
|
+
let e = {
|
|
107
|
+
start: t.start,
|
|
108
|
+
end: t.end
|
|
109
|
+
}, i = l(e, r, E);
|
|
110
|
+
if (u(e, i)) return;
|
|
111
|
+
w.actions.changeTimes(t, i, "move"), requestAnimationFrame(() => F.current?.querySelector(`[data-event-id="${CSS.escape(t.id)}"]`)?.focus());
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
let i = [...F.current?.querySelectorAll("[data-event-id]") ?? []], a = i.indexOf(e.currentTarget);
|
|
115
|
+
(r === "ArrowDown" || r === "ArrowRight" ? i[a + 1] : i[a - 1])?.focus();
|
|
116
|
+
}, X = A.eventId, Z = (e, t) => {
|
|
117
|
+
!D && X === e.id ? w.closePeek() : w.openPeek(e, t);
|
|
118
|
+
}, Q = w.quickDraft && O.includes(w.quickDraft.date) && !w.quickDraft.allDay ? w.quickDraft : null, fe = w.state.kind === "ready" && w.state.empty && K.bars.length === 0, $ = { gridTemplateColumns: `${P}px repeat(${O.length}, minmax(0, 1fr))` }, pe = A.view === "day" ? n(R, T, "full") : `${n(R, T, "short")} – ${n(z, T, "short")}`;
|
|
119
|
+
return /* @__PURE__ */ x("section", {
|
|
120
|
+
className: a,
|
|
121
|
+
"aria-label": pe,
|
|
122
|
+
"data-testid": "time-grid",
|
|
123
|
+
children: [
|
|
124
|
+
/* @__PURE__ */ x("div", {
|
|
125
|
+
ref: F,
|
|
126
|
+
tabIndex: 0,
|
|
127
|
+
role: "group",
|
|
128
|
+
"aria-label": oe("calendar.v2.gridLabel", "Time grid. Arrow keys pick a time, Enter adds an event, Tab moves through events."),
|
|
129
|
+
onFocus: J.onFocus,
|
|
130
|
+
onBlur: J.onBlur,
|
|
131
|
+
onKeyDown: J.onKeyDown,
|
|
132
|
+
className: ae("relative min-h-0 flex-1 overflow-auto overscroll-contain [overflow-anchor:none] focus-visible:outline-none", q.dragging && "cursor-grabbing select-none"),
|
|
133
|
+
children: [/* @__PURE__ */ x("div", {
|
|
134
|
+
ref: L,
|
|
135
|
+
className: "sticky top-0 z-20 bg-bg-surface",
|
|
136
|
+
children: [/* @__PURE__ */ b(f, { columnsStyle: $ }), /* @__PURE__ */ b(o, {
|
|
137
|
+
days: O,
|
|
138
|
+
lanes: K,
|
|
139
|
+
expanded: G,
|
|
140
|
+
onToggle: () => ce((e) => !e),
|
|
141
|
+
gutter: P,
|
|
142
|
+
selectedId: X,
|
|
143
|
+
onOpen: Z,
|
|
144
|
+
onKeyDown: Y
|
|
145
|
+
})]
|
|
146
|
+
}), /* @__PURE__ */ x("div", {
|
|
147
|
+
ref: I,
|
|
148
|
+
className: "relative grid",
|
|
149
|
+
style: {
|
|
150
|
+
...$,
|
|
151
|
+
height: 24 * N
|
|
152
|
+
},
|
|
153
|
+
...q.handlers,
|
|
154
|
+
children: [/* @__PURE__ */ b(te, { hourHeight: N }), O.map((e) => /* @__PURE__ */ b(d, {
|
|
155
|
+
day: e,
|
|
156
|
+
placed: W.get(e) ?? [],
|
|
157
|
+
hourHeight: N,
|
|
158
|
+
selectedId: X,
|
|
159
|
+
onOpen: Z,
|
|
160
|
+
onKeyDown: Y,
|
|
161
|
+
consumeClick: q.consumeClick,
|
|
162
|
+
ghost: q.ghost && q.ghost.date === e ? q.ghost : null,
|
|
163
|
+
quick: Q && Q.date === e && !q.ghost ? Q : null,
|
|
164
|
+
cursorMinute: J.cursor && J.cursor.date === e ? J.cursor.minute : null
|
|
165
|
+
}, e))]
|
|
166
|
+
})]
|
|
167
|
+
}),
|
|
168
|
+
/* @__PURE__ */ b("p", {
|
|
169
|
+
className: "sr-only",
|
|
170
|
+
"aria-live": "polite",
|
|
171
|
+
children: J.announcement
|
|
172
|
+
}),
|
|
173
|
+
fe ? /* @__PURE__ */ b(p, {}) : null
|
|
174
|
+
]
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
export { w as TimeGrid };
|
|
178
|
+
|
|
179
|
+
//# sourceMappingURL=TimeGrid.js.map
|