@sdxc/ui 2026.11.17 → 2026.11.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +139 -2
- package/dist/app/index.d.ts +1 -0
- package/dist/app/index.js +1 -0
- package/dist/app/mixins/command-palette.js +10 -2
- package/dist/app/mixins/log-viewer.js +17 -14
- package/dist/app/mixins/route-dialog.d.ts +17 -0
- package/dist/app/mixins/route-dialog.js +53 -0
- package/dist/app/optimistic-toggle.js +6 -0
- package/dist/app/route-dialog.d.ts +38 -0
- package/dist/app/route-dialog.js +49 -0
- package/dist/audio/equalizer.d.ts +24 -0
- package/dist/audio/equalizer.js +57 -0
- package/dist/audio/index.d.ts +16 -0
- package/dist/audio/index.js +16 -0
- package/dist/audio/media-tile.d.ts +38 -0
- package/dist/audio/media-tile.js +98 -0
- package/dist/audio/player-bar.d.ts +108 -0
- package/dist/audio/player-bar.js +338 -0
- package/dist/audio/queue-list.d.ts +56 -0
- package/dist/audio/queue-list.js +102 -0
- package/dist/audio/track-list.d.ts +91 -0
- package/dist/audio/track-list.js +226 -0
- package/dist/audio/utils/media-session.d.ts +44 -0
- package/dist/audio/utils/media-session.js +87 -0
- package/dist/audio/utils/play-queue.d.ts +98 -0
- package/dist/audio/utils/play-queue.js +149 -0
- package/dist/audio/utils/track-time.d.ts +28 -0
- package/dist/audio/utils/track-time.js +36 -0
- package/dist/chat/composer-format.d.ts +35 -0
- package/dist/chat/composer-format.js +84 -0
- package/dist/chat/index.d.ts +6 -0
- package/dist/chat/index.js +6 -0
- package/dist/chat/mention-menu.d.ts +43 -0
- package/dist/chat/mention-menu.js +70 -0
- package/dist/chat/message-group.d.ts +92 -0
- package/dist/chat/message-group.js +222 -0
- package/dist/chat/mixins/composer-format.d.ts +28 -0
- package/dist/chat/mixins/composer-format.js +80 -0
- package/dist/chat/mixins/composer-send.d.ts +2 -2
- package/dist/chat/mixins/composer-send.js +4 -2
- package/dist/chat/mixins/mention-menu.d.ts +41 -0
- package/dist/chat/mixins/mention-menu.js +213 -0
- package/dist/chat/mixins/reaction-sync.d.ts +47 -0
- package/dist/chat/mixins/reaction-sync.js +172 -0
- package/dist/chat/reaction-bar.d.ts +70 -0
- package/dist/chat/reaction-bar.js +108 -0
- package/dist/chat/typing-indicator.d.ts +42 -0
- package/dist/chat/typing-indicator.js +68 -0
- package/dist/chat/utils/composer-text.d.ts +38 -0
- package/dist/chat/utils/composer-text.js +86 -0
- package/dist/chat/utils/markdown-format.d.ts +30 -0
- package/dist/chat/utils/markdown-format.js +158 -0
- package/dist/chat/utils/mention-query.d.ts +55 -0
- package/dist/chat/utils/mention-query.js +60 -0
- package/dist/commerce/cart-drawer.d.ts +69 -0
- package/dist/commerce/cart-drawer.js +163 -0
- package/dist/commerce/cart-line.d.ts +32 -0
- package/dist/commerce/cart-line.js +43 -0
- package/dist/commerce/checkout-layout.d.ts +32 -0
- package/dist/commerce/checkout-layout.js +51 -0
- package/dist/commerce/facet-filters.d.ts +121 -0
- package/dist/commerce/facet-filters.js +318 -0
- package/dist/commerce/fulfilment-note.d.ts +28 -0
- package/dist/commerce/fulfilment-note.js +26 -0
- package/dist/commerce/index.d.ts +27 -0
- package/dist/commerce/index.js +27 -0
- package/dist/commerce/item-options-dialog.d.ts +67 -0
- package/dist/commerce/item-options-dialog.js +150 -0
- package/dist/commerce/menu-item-card.d.ts +37 -0
- package/dist/commerce/menu-item-card.js +96 -0
- package/dist/commerce/option-group.d.ts +62 -0
- package/dist/commerce/option-group.js +121 -0
- package/dist/commerce/order-summary.d.ts +42 -0
- package/dist/commerce/order-summary.js +76 -0
- package/dist/commerce/order-tracker.d.ts +80 -0
- package/dist/commerce/order-tracker.js +178 -0
- package/dist/commerce/price.d.ts +52 -0
- package/dist/commerce/price.js +108 -0
- package/dist/commerce/product-card.d.ts +53 -0
- package/dist/commerce/product-card.js +127 -0
- package/dist/commerce/product-gallery.d.ts +70 -0
- package/dist/commerce/product-gallery.js +186 -0
- package/dist/commerce/promo-code.d.ts +56 -0
- package/dist/commerce/promo-code.js +101 -0
- package/dist/commerce/quantity-stepper.d.ts +42 -0
- package/dist/commerce/quantity-stepper.js +53 -0
- package/dist/commerce/question-list.d.ts +53 -0
- package/dist/commerce/question-list.js +92 -0
- package/dist/commerce/shipping-estimate.d.ts +53 -0
- package/dist/commerce/shipping-estimate.js +39 -0
- package/dist/commerce/sort-select.d.ts +38 -0
- package/dist/commerce/sort-select.js +38 -0
- package/dist/commerce/variant-picker.d.ts +75 -0
- package/dist/commerce/variant-picker.js +135 -0
- package/dist/components/amount.d.ts +46 -0
- package/dist/components/amount.js +34 -0
- package/dist/components/autocomplete.d.ts +82 -0
- package/dist/components/autocomplete.js +114 -0
- package/dist/components/carousel.d.ts +31 -1
- package/dist/components/carousel.js +66 -3
- package/dist/components/index.d.ts +11 -0
- package/dist/components/index.js +11 -0
- package/dist/components/letterbox.d.ts +47 -0
- package/dist/components/letterbox.js +56 -0
- package/dist/components/lightbox.d.ts +88 -0
- package/dist/components/lightbox.js +224 -0
- package/dist/components/media-grid.d.ts +53 -0
- package/dist/components/media-grid.js +89 -0
- package/dist/components/range-months.d.ts +100 -0
- package/dist/components/range-months.js +274 -0
- package/dist/components/rating-input.d.ts +33 -0
- package/dist/components/rating-input.js +63 -0
- package/dist/components/rating.d.ts +38 -0
- package/dist/components/rating.js +66 -0
- package/dist/components/review-card.d.ts +39 -0
- package/dist/components/review-card.js +59 -0
- package/dist/components/section-bar.d.ts +57 -0
- package/dist/components/section-bar.js +140 -0
- package/dist/components/step-indicator.d.ts +46 -0
- package/dist/components/step-indicator.js +96 -0
- package/dist/finance/index.d.ts +10 -0
- package/dist/finance/index.js +10 -0
- package/dist/finance/ledger.d.ts +60 -0
- package/dist/finance/ledger.js +93 -0
- package/dist/finance/payment-card.d.ts +49 -0
- package/dist/finance/payment-card.js +115 -0
- package/dist/map/engine.d.ts +49 -0
- package/dist/map/engine.js +591 -0
- package/dist/map/index.d.ts +12 -0
- package/dist/map/index.js +12 -0
- package/dist/map/map-canvas.d.ts +101 -0
- package/dist/map/map-canvas.js +275 -0
- package/dist/map/map.d.ts +217 -0
- package/dist/map/map.js +598 -0
- package/dist/map/mixins/map-link.d.ts +30 -0
- package/dist/map/mixins/map-link.js +116 -0
- package/dist/map/utils/basemap.d.ts +88 -0
- package/dist/map/utils/basemap.js +84 -0
- package/dist/map/utils/cluster.d.ts +43 -0
- package/dist/map/utils/cluster.js +80 -0
- package/dist/map/utils/mercator.d.ts +66 -0
- package/dist/map/utils/mercator.js +92 -0
- package/dist/map/utils/stage.d.ts +24 -0
- package/dist/map/utils/stage.js +49 -0
- package/dist/mixins/autocomplete.d.ts +28 -0
- package/dist/mixins/autocomplete.js +283 -0
- package/dist/mixins/carousel-controls.d.ts +14 -3
- package/dist/mixins/carousel-controls.js +89 -30
- package/dist/mixins/index.d.ts +2 -0
- package/dist/mixins/index.js +2 -0
- package/dist/mixins/lightbox-controls.d.ts +34 -0
- package/dist/mixins/lightbox-controls.js +176 -0
- package/dist/schedule/agenda.d.ts +63 -0
- package/dist/schedule/agenda.js +221 -0
- package/dist/schedule/day-strip.d.ts +50 -0
- package/dist/schedule/day-strip.js +136 -0
- package/dist/schedule/free-busy.d.ts +96 -0
- package/dist/schedule/free-busy.js +285 -0
- package/dist/schedule/index.d.ts +15 -0
- package/dist/schedule/index.js +15 -0
- package/dist/schedule/mixins/day-strip-scroll.d.ts +16 -0
- package/dist/schedule/mixins/day-strip-scroll.js +40 -0
- package/dist/schedule/mixins/time-grid-drag.d.ts +24 -0
- package/dist/schedule/mixins/time-grid-drag.js +532 -0
- package/dist/schedule/month-view.d.ts +68 -0
- package/dist/schedule/month-view.js +301 -0
- package/dist/schedule/time-grid.d.ts +168 -0
- package/dist/schedule/time-grid.js +417 -0
- package/dist/schedule/utils/time-grid-layout.d.ts +50 -0
- package/dist/schedule/utils/time-grid-layout.js +93 -0
- package/dist/schedule/year-view.d.ts +46 -0
- package/dist/schedule/year-view.js +142 -0
- package/dist/styles/index.d.ts +1 -0
- package/dist/styles/index.js +1 -0
- package/dist/styles/typewriter-text.d.ts +20 -0
- package/dist/styles/typewriter-text.js +23 -0
- package/dist/test/map.d.ts +18 -0
- package/dist/test/map.js +96 -0
- package/dist/test/reels.d.ts +30 -0
- package/dist/test/reels.js +41 -0
- package/dist/test/stories.d.ts +31 -0
- package/dist/test/stories.js +66 -0
- package/dist/travel/boarding-pass.d.ts +107 -0
- package/dist/travel/boarding-pass.js +293 -0
- package/dist/travel/car-offer.d.ts +70 -0
- package/dist/travel/car-offer.js +127 -0
- package/dist/travel/fare-calendar.d.ts +85 -0
- package/dist/travel/fare-calendar.js +233 -0
- package/dist/travel/fare-options.d.ts +84 -0
- package/dist/travel/fare-options.js +142 -0
- package/dist/travel/flight-itinerary.d.ts +84 -0
- package/dist/travel/flight-itinerary.js +112 -0
- package/dist/travel/flight-option.d.ts +58 -0
- package/dist/travel/flight-option.js +111 -0
- package/dist/travel/flight-segment.d.ts +105 -0
- package/dist/travel/flight-segment.js +174 -0
- package/dist/travel/index.d.ts +20 -0
- package/dist/travel/index.js +20 -0
- package/dist/travel/package-savings.d.ts +74 -0
- package/dist/travel/package-savings.js +128 -0
- package/dist/travel/price-breakdown.d.ts +66 -0
- package/dist/travel/price-breakdown.js +102 -0
- package/dist/travel/rating-breakdown.d.ts +81 -0
- package/dist/travel/rating-breakdown.js +132 -0
- package/dist/travel/seat-map.d.ts +108 -0
- package/dist/travel/seat-map.js +371 -0
- package/dist/travel/trip-timeline.d.ts +84 -0
- package/dist/travel/trip-timeline.js +212 -0
- package/dist/utils/gamepad-presses.d.ts +21 -0
- package/dist/utils/gamepad-presses.js +28 -0
- package/dist/utils/index.d.ts +5 -0
- package/dist/utils/index.js +5 -0
- package/dist/utils/move-focus.d.ts +20 -0
- package/dist/utils/move-focus.js +28 -0
- package/dist/utils/range-months.d.ts +54 -0
- package/dist/utils/range-months.js +98 -0
- package/dist/utils/swipe-direction.d.ts +23 -0
- package/dist/utils/swipe-direction.js +27 -0
- package/dist/utils/typewriter.d.ts +49 -0
- package/dist/utils/typewriter.js +171 -0
- package/dist/video/index.d.ts +6 -2
- package/dist/video/index.js +6 -2
- package/dist/video/mixins/reel-feed-sync.d.ts +41 -0
- package/dist/video/mixins/reel-feed-sync.js +430 -0
- package/dist/video/mixins/story-viewer-sync.d.ts +31 -0
- package/dist/video/mixins/story-viewer-sync.js +391 -0
- package/dist/video/mixins/video-player-sync.js +138 -5
- package/dist/video/reel-feed.d.ts +95 -0
- package/dist/video/reel-feed.js +124 -0
- package/dist/video/story-ring.d.ts +32 -0
- package/dist/video/story-ring.js +42 -0
- package/dist/video/story-viewer.d.ts +85 -0
- package/dist/video/story-viewer.js +250 -0
- package/dist/video/video-card.d.ts +3 -1
- package/dist/video/video-card.js +15 -5
- package/dist/video/video-player.d.ts +33 -0
- package/dist/video/video-player.js +226 -20
- package/package.json +21 -2
|
@@ -0,0 +1,417 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "remix/component/jsx-runtime";
|
|
2
|
+
import { visuallyHidden } from "@sdxc/u/a11y";
|
|
3
|
+
import { mergeMix, raw } from "@sdxc/u/general";
|
|
4
|
+
import { motionReduce } from "@sdxc/u/responsive";
|
|
5
|
+
import { when } from "@sdxc/u/state";
|
|
6
|
+
import { clientEntry } from "remix/component";
|
|
7
|
+
import { Popover } from "../components/popover.js";
|
|
8
|
+
import { timeGridDrag } from "./mixins/time-grid-drag.js";
|
|
9
|
+
import { layoutSpanItems, layoutTimedItems } from "./utils/time-grid-layout.js";
|
|
10
|
+
/** One hour's height, which every offset and length multiplies. */
|
|
11
|
+
const HOUR = "var(--ui-time-grid-hour, 3rem)";
|
|
12
|
+
/** The width of one time zone's column of hour labels. */
|
|
13
|
+
const GUTTER = "var(--ui-time-grid-gutter, 3.5rem)";
|
|
14
|
+
/**
|
|
15
|
+
* An event block too short for its title and time on two lines: the time joins the title on one
|
|
16
|
+
* line, which every block keeps fully readable however short.
|
|
17
|
+
*/
|
|
18
|
+
const ONE_LINE = "@container ui-time-grid-event (height < 2.5rem)";
|
|
19
|
+
/** An event block too short for a third line, which drops its detail (a place or a note). */
|
|
20
|
+
const TWO_LINES = "@container ui-time-grid-event (height < 3.5rem)";
|
|
21
|
+
/** Minutes in a day, the column's full height. */
|
|
22
|
+
const DAY_MINUTES = 1440;
|
|
23
|
+
/** The snap every drag and keyboard move rounds to when `edit.step` is unset. */
|
|
24
|
+
const DEFAULT_STEP = 15;
|
|
25
|
+
/**
|
|
26
|
+
* Client island: an invisible marker carrying the grid's opening scroll, its moving now line
|
|
27
|
+
* and, when the grid can be edited, its drags and keyboard moves. Loads from
|
|
28
|
+
* `@sdxc/ui/schedule/time-grid#TimeGridBehavior`.
|
|
29
|
+
*/
|
|
30
|
+
export const TimeGridBehavior = clientEntry("@sdxc/ui/schedule/time-grid#TimeGridBehavior", function TimeGridBehavior(handle) {
|
|
31
|
+
return () => (_jsx("span", { hidden: true, "data-slot": "time-grid-behavior", mix: [timeGridDrag({ moved: handle.props.moved, resized: handle.props.resized })] }));
|
|
32
|
+
});
|
|
33
|
+
/** Days between two `YYYY-MM-DD` dates, read as UTC so no zone shifts a day. */
|
|
34
|
+
function daysBetween(from, to) {
|
|
35
|
+
return Math.round((Date.parse(`${to}T00:00:00Z`) - Date.parse(`${from}T00:00:00Z`)) / 86_400_000);
|
|
36
|
+
}
|
|
37
|
+
/** A length in minutes as a CSS length on the grid's hour scale. */
|
|
38
|
+
function minutes(value) {
|
|
39
|
+
return `calc(${HOUR} * ${value / 60})`;
|
|
40
|
+
}
|
|
41
|
+
/** The colour token an event or span tints itself from. */
|
|
42
|
+
function tint(color) {
|
|
43
|
+
return `--ui-time-grid-color: ${color ?? "var(--ui-brand-bg-solid)"}`;
|
|
44
|
+
}
|
|
45
|
+
/** An event's or span's look: a soft fill of its colour, an edge of it, and readable ink. */
|
|
46
|
+
const BLOCK = raw({
|
|
47
|
+
boxSizing: "border-box",
|
|
48
|
+
borderRadius: "0.375rem",
|
|
49
|
+
backgroundColor: "color-mix(in oklch, var(--ui-time-grid-color) 20%, var(--ui-bg, Canvas))",
|
|
50
|
+
color: "color-mix(in oklch, var(--ui-time-grid-color) 55%, var(--ui-neutral-fg-emphasis, CanvasText))",
|
|
51
|
+
boxShadow: "inset 3px 0 0 var(--ui-time-grid-color), 0 0 0 1px var(--ui-bg, Canvas)",
|
|
52
|
+
"&[data-tentative]": {
|
|
53
|
+
backgroundImage: "repeating-linear-gradient(135deg, transparent 0 5px, color-mix(in oklch, var(--ui-time-grid-color) 14%, transparent) 5px 10px)",
|
|
54
|
+
backgroundColor: "var(--ui-bg, Canvas)",
|
|
55
|
+
},
|
|
56
|
+
"&[data-past]": { opacity: "0.62" },
|
|
57
|
+
});
|
|
58
|
+
/** The clickable face of an event or span: the button opening its popover, or its link. */
|
|
59
|
+
function Trigger(handle) {
|
|
60
|
+
return () => {
|
|
61
|
+
let { id, popoverId, href, label, children } = handle.props;
|
|
62
|
+
let mix = [
|
|
63
|
+
raw({
|
|
64
|
+
all: "unset",
|
|
65
|
+
boxSizing: "border-box",
|
|
66
|
+
display: "flex",
|
|
67
|
+
flexDirection: "column",
|
|
68
|
+
gap: "0.0625rem",
|
|
69
|
+
inlineSize: "100%",
|
|
70
|
+
blockSize: "100%",
|
|
71
|
+
paddingBlock: "0.1875rem",
|
|
72
|
+
paddingInline: "0.5rem 0.375rem",
|
|
73
|
+
overflow: "hidden",
|
|
74
|
+
cursor: "pointer",
|
|
75
|
+
borderRadius: "inherit",
|
|
76
|
+
fontSize: "0.75rem",
|
|
77
|
+
lineHeight: "1rem",
|
|
78
|
+
textAlign: "start",
|
|
79
|
+
color: "inherit",
|
|
80
|
+
textDecoration: "none",
|
|
81
|
+
"&:focus-visible": { boxShadow: "0 0 0 2px var(--ui-brand-ring)" },
|
|
82
|
+
}),
|
|
83
|
+
];
|
|
84
|
+
if (popoverId !== undefined)
|
|
85
|
+
return (_jsx("button", { type: "button", id: id, popovertarget: popoverId, "aria-label": label, "data-slot": "time-grid-trigger", mix: mix, children: children }));
|
|
86
|
+
if (href !== undefined)
|
|
87
|
+
return (_jsx("a", { id: id, href: href, "aria-label": label, "data-slot": "time-grid-trigger", mix: mix, children: children }));
|
|
88
|
+
return (_jsx("span", { id: id, "aria-label": label, role: "img", "data-slot": "time-grid-trigger", mix: mix, children: children }));
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Renders the grid: a header of day links over the all-day lane, then one scroller holding the
|
|
93
|
+
* hour labels and the day columns. Each event is placed from its minutes, side by side with
|
|
94
|
+
* those it overlaps; an editable one also takes a resize edge, and the forms `edit` names.
|
|
95
|
+
*
|
|
96
|
+
* @example
|
|
97
|
+
* <TimeGrid id="week" label="Week of November 16" days={days} zones={zones} labels={labels}
|
|
98
|
+
* events={[{ id: "e1", date: "2026-11-18", start: 540, end: 600, title: "Standup" }]} />
|
|
99
|
+
*/
|
|
100
|
+
export function TimeGrid(handle) {
|
|
101
|
+
return () => {
|
|
102
|
+
let { id, label, days, events, spans = [], zones, today, now, workday, scrollTo = 480, locale = "en", edit, pages, labels, mix, ...rest } = handle.props;
|
|
103
|
+
let step = edit?.step ?? DEFAULT_STEP;
|
|
104
|
+
let columns = `repeat(${zones.length}, ${GUTTER}) repeat(${days.length}, minmax(0, 1fr))`;
|
|
105
|
+
let weekday = new Intl.DateTimeFormat(locale, { weekday: "short", timeZone: "UTC" });
|
|
106
|
+
let dayNumber = new Intl.DateTimeFormat(locale, { day: "numeric", timeZone: "UTC" });
|
|
107
|
+
let fullDay = new Intl.DateTimeFormat(locale, { dateStyle: "full", timeZone: "UTC" });
|
|
108
|
+
let first = days[0]?.date ?? "";
|
|
109
|
+
let visibleSpans = spans
|
|
110
|
+
.map((span) => ({
|
|
111
|
+
span,
|
|
112
|
+
first: Math.max(0, daysBetween(first, span.start)),
|
|
113
|
+
last: Math.min(days.length - 1, daysBetween(first, span.end)),
|
|
114
|
+
}))
|
|
115
|
+
.filter((entry) => entry.first <= entry.last && entry.last >= 0);
|
|
116
|
+
let lane = layoutSpanItems(visibleSpans.map((entry) => ({ id: entry.span.id, first: entry.first, last: entry.last })));
|
|
117
|
+
return (_jsxs("div", { ...rest, id: id, role: "group", "aria-label": label, "data-slot": "time-grid", "data-locale": locale, "data-step": step, "data-scroll-to": scrollTo, style: `--ui-time-grid-columns: ${columns}`, mix: mergeMix([
|
|
118
|
+
raw({
|
|
119
|
+
display: "flex",
|
|
120
|
+
flexDirection: "column",
|
|
121
|
+
minInlineSize: "0",
|
|
122
|
+
minBlockSize: "0",
|
|
123
|
+
fontVariantNumeric: "tabular-nums",
|
|
124
|
+
"&[data-dragging]": { userSelect: "none", cursor: "grabbing" },
|
|
125
|
+
}),
|
|
126
|
+
], mix), children: [_jsxs("div", { "data-slot": "time-grid-head", mix: [
|
|
127
|
+
raw({
|
|
128
|
+
display: "grid",
|
|
129
|
+
gridTemplateColumns: "var(--ui-time-grid-columns)",
|
|
130
|
+
overflow: "hidden",
|
|
131
|
+
scrollbarGutter: "stable",
|
|
132
|
+
borderBlockEnd: "1px solid var(--ui-neutral-border)",
|
|
133
|
+
flexShrink: "0",
|
|
134
|
+
}),
|
|
135
|
+
], children: [zones.map((zone, index) => (_jsx("span", { "data-slot": "time-grid-zone", mix: [
|
|
136
|
+
raw({
|
|
137
|
+
gridRow: "1",
|
|
138
|
+
gridColumn: `${index + 1}`,
|
|
139
|
+
alignSelf: "end",
|
|
140
|
+
paddingInlineEnd: "0.5rem",
|
|
141
|
+
paddingBlockEnd: "0.25rem",
|
|
142
|
+
fontSize: "0.625rem",
|
|
143
|
+
fontWeight: "600",
|
|
144
|
+
letterSpacing: "0.04em",
|
|
145
|
+
textAlign: "end",
|
|
146
|
+
color: "var(--ui-neutral-fg-muted)",
|
|
147
|
+
}),
|
|
148
|
+
], children: zone.label }))), days.map((day, index) => {
|
|
149
|
+
let instant = new Date(`${day.date}T00:00:00Z`);
|
|
150
|
+
let isToday = day.date === today;
|
|
151
|
+
let content = (_jsxs(_Fragment, { children: [_jsx("span", { "aria-hidden": "true", mix: [
|
|
152
|
+
raw({
|
|
153
|
+
fontSize: "0.6875rem",
|
|
154
|
+
fontWeight: "600",
|
|
155
|
+
letterSpacing: "0.05em",
|
|
156
|
+
textTransform: "uppercase",
|
|
157
|
+
color: "var(--ui-neutral-fg-muted)",
|
|
158
|
+
}),
|
|
159
|
+
when("[data-today] > &", raw({ color: "var(--ui-brand-fg)" })),
|
|
160
|
+
], children: weekday.format(instant) }), _jsx("span", { "aria-hidden": "true", mix: [
|
|
161
|
+
raw({
|
|
162
|
+
display: "grid",
|
|
163
|
+
placeItems: "center",
|
|
164
|
+
minInlineSize: "2rem",
|
|
165
|
+
blockSize: "2rem",
|
|
166
|
+
paddingInline: "0.25rem",
|
|
167
|
+
boxSizing: "border-box",
|
|
168
|
+
borderRadius: "999px",
|
|
169
|
+
fontSize: "1.125rem",
|
|
170
|
+
fontWeight: "600",
|
|
171
|
+
color: "var(--ui-neutral-fg-emphasis)",
|
|
172
|
+
}),
|
|
173
|
+
when("[data-today] > &", raw({
|
|
174
|
+
backgroundColor: "var(--ui-brand-bg-solid)",
|
|
175
|
+
color: "var(--ui-brand-fg-on-solid, white)",
|
|
176
|
+
})),
|
|
177
|
+
], children: dayNumber.format(instant) }), _jsx("span", { mix: [visuallyHidden()], children: fullDay.format(instant) })] }));
|
|
178
|
+
let headMix = [
|
|
179
|
+
raw({
|
|
180
|
+
gridRow: "1",
|
|
181
|
+
gridColumn: `${zones.length + index + 1}`,
|
|
182
|
+
display: "flex",
|
|
183
|
+
flexDirection: "column",
|
|
184
|
+
alignItems: "center",
|
|
185
|
+
gap: "0.125rem",
|
|
186
|
+
paddingBlock: "0.375rem",
|
|
187
|
+
borderRadius: "0.5rem",
|
|
188
|
+
color: "inherit",
|
|
189
|
+
textDecoration: "none",
|
|
190
|
+
outline: "none",
|
|
191
|
+
}),
|
|
192
|
+
when("&[href]:hover", raw({ backgroundColor: "var(--ui-neutral-bg-tint)" })),
|
|
193
|
+
when("&:focus-visible", raw({ boxShadow: "inset 0 0 0 2px var(--ui-brand-ring)" })),
|
|
194
|
+
];
|
|
195
|
+
return day.href === undefined ? (_jsx("span", { "data-slot": "time-grid-day", "data-today": isToday ? "" : undefined, "aria-current": isToday ? "date" : undefined, mix: headMix, children: content })) : (_jsx("a", { href: day.href, "data-slot": "time-grid-day", "data-today": isToday ? "" : undefined, "aria-current": isToday ? "date" : undefined, mix: headMix, children: content }));
|
|
196
|
+
}), _jsx("span", { "data-slot": "time-grid-lane-label", mix: [
|
|
197
|
+
raw({
|
|
198
|
+
gridRow: `2 / span ${Math.max(1, lane.count)}`,
|
|
199
|
+
gridColumn: `1 / span ${zones.length}`,
|
|
200
|
+
alignSelf: "start",
|
|
201
|
+
paddingInlineEnd: "0.5rem",
|
|
202
|
+
paddingBlock: "0.3125rem",
|
|
203
|
+
fontSize: "0.625rem",
|
|
204
|
+
fontWeight: "500",
|
|
205
|
+
textAlign: "end",
|
|
206
|
+
color: "var(--ui-neutral-fg-muted)",
|
|
207
|
+
}),
|
|
208
|
+
], children: labels.allDay }), _jsx("span", { "aria-hidden": "true", mix: [
|
|
209
|
+
raw({
|
|
210
|
+
gridRow: `2 / span ${Math.max(1, lane.count)}`,
|
|
211
|
+
gridColumn: `${zones.length + 1} / -1`,
|
|
212
|
+
minBlockSize: "1.625rem",
|
|
213
|
+
paddingBlockEnd: "0.25rem",
|
|
214
|
+
}),
|
|
215
|
+
] }), visibleSpans.map(({ span, first: from, last }) => {
|
|
216
|
+
let popoverId = span.popover === undefined ? undefined : `${id}-span-${span.id}-popover`;
|
|
217
|
+
let row = (lane.rows.get(span.id) ?? 0) + 2;
|
|
218
|
+
return (_jsxs("div", { "data-slot": "time-grid-span", "data-id": span.id, "data-continues-before": daysBetween(first, span.start) < 0 ? "" : undefined, style: tint(span.color), mix: [
|
|
219
|
+
BLOCK,
|
|
220
|
+
raw({
|
|
221
|
+
gridRow: `${row}`,
|
|
222
|
+
gridColumn: `${zones.length + from + 1} / ${zones.length + last + 2}`,
|
|
223
|
+
marginInline: "0.125rem",
|
|
224
|
+
marginBlockEnd: "0.125rem",
|
|
225
|
+
blockSize: "1.375rem",
|
|
226
|
+
"&[data-continues-before]": {
|
|
227
|
+
borderStartStartRadius: "0",
|
|
228
|
+
borderEndStartRadius: "0",
|
|
229
|
+
},
|
|
230
|
+
}),
|
|
231
|
+
], children: [_jsx(Trigger, { id: `${id}-span-${span.id}`, popoverId: popoverId, href: span.href, label: span.title, children: _jsx("span", { mix: [
|
|
232
|
+
raw({
|
|
233
|
+
fontWeight: "600",
|
|
234
|
+
whiteSpace: "nowrap",
|
|
235
|
+
overflow: "hidden",
|
|
236
|
+
textOverflow: "ellipsis",
|
|
237
|
+
}),
|
|
238
|
+
], children: span.title }) }), popoverId === undefined ? null : (_jsx(Popover, { id: popoverId, placement: "bottom-start", children: span.popover }))] }));
|
|
239
|
+
})] }), _jsx("div", { "data-slot": "time-grid-body", mix: [
|
|
240
|
+
raw({
|
|
241
|
+
position: "relative",
|
|
242
|
+
flex: "1 1 auto",
|
|
243
|
+
minBlockSize: "0",
|
|
244
|
+
overflowY: "auto",
|
|
245
|
+
overflowX: "hidden",
|
|
246
|
+
overscrollBehavior: "contain",
|
|
247
|
+
scrollbarGutter: "stable",
|
|
248
|
+
touchAction: "pan-y pinch-zoom",
|
|
249
|
+
}),
|
|
250
|
+
], children: _jsxs("div", { "data-slot": "time-grid-canvas", mix: [
|
|
251
|
+
raw({
|
|
252
|
+
position: "relative",
|
|
253
|
+
display: "grid",
|
|
254
|
+
gridTemplateColumns: "var(--ui-time-grid-columns)",
|
|
255
|
+
blockSize: `calc(${HOUR} * 24)`,
|
|
256
|
+
paddingBlockStart: "0.5rem",
|
|
257
|
+
boxSizing: "content-box",
|
|
258
|
+
}),
|
|
259
|
+
], children: [zones.map((zone, index) => (_jsx("div", { "aria-hidden": "true", "data-slot": "time-grid-hours", mix: [
|
|
260
|
+
raw({
|
|
261
|
+
position: "relative",
|
|
262
|
+
gridColumn: `${index + 1}`,
|
|
263
|
+
gridRow: "1",
|
|
264
|
+
color: "var(--ui-neutral-fg-muted)",
|
|
265
|
+
}),
|
|
266
|
+
when("&:not(:first-child)", raw({ opacity: "0.72" })),
|
|
267
|
+
], children: zone.hours.map((hour, at) => at === 0 ? null : (_jsx("span", { style: `top: ${minutes(at * 60)}`, mix: [
|
|
268
|
+
raw({
|
|
269
|
+
position: "absolute",
|
|
270
|
+
insetInlineEnd: "0.5rem",
|
|
271
|
+
transform: "translateY(-50%)",
|
|
272
|
+
fontSize: "0.6875rem",
|
|
273
|
+
lineHeight: "1",
|
|
274
|
+
whiteSpace: "nowrap",
|
|
275
|
+
}),
|
|
276
|
+
], children: hour }))) }))), days.map((day, index) => {
|
|
277
|
+
let dayEvents = events.filter((event) => event.date === day.date);
|
|
278
|
+
let placements = layoutTimedItems(dayEvents);
|
|
279
|
+
let nowHere = now !== undefined && now.date === day.date ? now : undefined;
|
|
280
|
+
return (_jsxs("section", { "aria-label": fullDay.format(new Date(`${day.date}T00:00:00Z`)), "data-slot": "time-grid-column", "data-date": day.date, "data-muted": day.muted ? "" : undefined, style: workday === undefined
|
|
281
|
+
? undefined
|
|
282
|
+
: `--ui-time-grid-work-start: ${minutes(workday.start)}; --ui-time-grid-work-end: ${minutes(workday.end)}`, mix: [
|
|
283
|
+
raw({
|
|
284
|
+
position: "relative",
|
|
285
|
+
gridColumn: `${zones.length + index + 1}`,
|
|
286
|
+
gridRow: "1",
|
|
287
|
+
borderInlineStart: "1px solid var(--ui-neutral-border)",
|
|
288
|
+
backgroundImage: `repeating-linear-gradient(to bottom, var(--ui-neutral-border) 0 1px, transparent 1px ${HOUR})`,
|
|
289
|
+
"&[data-muted]": {
|
|
290
|
+
backgroundColor: "color-mix(in oklch, var(--ui-neutral-bg-tint) 55%, transparent)",
|
|
291
|
+
},
|
|
292
|
+
"--ui-time-grid-off-hours": "color-mix(in oklch, var(--ui-color-neutral-950, black) 6%, transparent)",
|
|
293
|
+
"&[style*='work-start']::before": {
|
|
294
|
+
content: "''",
|
|
295
|
+
position: "absolute",
|
|
296
|
+
inset: "0",
|
|
297
|
+
pointerEvents: "none",
|
|
298
|
+
background: "linear-gradient(to bottom, var(--ui-time-grid-off-hours) var(--ui-time-grid-work-start), transparent var(--ui-time-grid-work-start) var(--ui-time-grid-work-end), var(--ui-time-grid-off-hours) var(--ui-time-grid-work-end))",
|
|
299
|
+
},
|
|
300
|
+
}),
|
|
301
|
+
], children: [dayEvents.map((event) => (_jsx(EventBlock, { id: id, event: event, place: placements.get(event.id) ?? { column: 0, columns: 1, span: 1 }, movable: edit?.move !== undefined }))), nowHere === undefined ? null : (_jsx("div", { role: "img", "aria-label": labels.now, "data-slot": "time-grid-now", "data-minute": nowHere.minute, "data-at": nowHere.at, style: `top: ${minutes(nowHere.minute)}`, mix: [
|
|
302
|
+
raw({
|
|
303
|
+
position: "absolute",
|
|
304
|
+
insetInline: "0",
|
|
305
|
+
zIndex: "4",
|
|
306
|
+
blockSize: "2px",
|
|
307
|
+
marginBlockStart: "-1px",
|
|
308
|
+
pointerEvents: "none",
|
|
309
|
+
backgroundColor: "var(--ui-time-grid-now, var(--ui-danger-bg-solid, crimson))",
|
|
310
|
+
"&::before": {
|
|
311
|
+
content: "''",
|
|
312
|
+
position: "absolute",
|
|
313
|
+
insetInlineStart: "-0.3125rem",
|
|
314
|
+
insetBlockStart: "-0.25rem",
|
|
315
|
+
inlineSize: "0.625rem",
|
|
316
|
+
blockSize: "0.625rem",
|
|
317
|
+
borderRadius: "999px",
|
|
318
|
+
backgroundColor: "inherit",
|
|
319
|
+
},
|
|
320
|
+
}),
|
|
321
|
+
] }))] }));
|
|
322
|
+
})] }) }), pages === undefined ? null : (_jsxs(_Fragment, { children: [_jsx("a", { hidden: true, href: pages.previous, "data-slot": "time-grid-previous", tabIndex: -1 }), _jsx("a", { hidden: true, href: pages.next, "data-slot": "time-grid-next", tabIndex: -1 })] })), edit?.create ? _jsx(EditForm, { kind: "create", form: edit.create }) : null, edit?.move ? _jsx(EditForm, { kind: "move", form: edit.move }) : null, _jsx("span", { role: "status", "aria-live": "polite", "data-slot": "time-grid-status", mix: [visuallyHidden()] }), _jsx(TimeGridBehavior, { moved: labels.moved, resized: labels.resized })] }));
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
/** One timed event on its day column, placed from its minutes and its overlap columns. */
|
|
326
|
+
function EventBlock(handle) {
|
|
327
|
+
return () => {
|
|
328
|
+
let { id, event, place, movable } = handle.props;
|
|
329
|
+
let popoverId = event.popover === undefined ? undefined : `${id}-event-${event.id}-popover`;
|
|
330
|
+
let left = (place.column / place.columns) * 100;
|
|
331
|
+
let width = (place.span / place.columns) * 100;
|
|
332
|
+
return (_jsxs("div", { "data-slot": "time-grid-event", "data-id": event.id, "data-start": event.start, "data-end": event.end, "data-title": event.title, "data-editable": event.editable && movable ? "" : undefined, "data-tentative": event.tentative ? "" : undefined, "data-past": event.past ? "" : undefined, style: `${tint(event.color)}; top: ${minutes(event.start)}; height: max(1.25rem, ${minutes(Math.min(DAY_MINUTES, event.end) - event.start)}); left: calc(${left}% + 1px); width: calc(${width}% - 3px)`, mix: [
|
|
333
|
+
BLOCK,
|
|
334
|
+
raw({
|
|
335
|
+
position: "absolute",
|
|
336
|
+
zIndex: "1",
|
|
337
|
+
container: "ui-time-grid-event / size",
|
|
338
|
+
transition: "box-shadow 120ms, opacity 120ms",
|
|
339
|
+
"&:hover": {
|
|
340
|
+
backgroundColor: "color-mix(in oklch, var(--ui-time-grid-color) 28%, var(--ui-bg, Canvas))",
|
|
341
|
+
},
|
|
342
|
+
"&[data-editable]": { touchAction: "pan-y" },
|
|
343
|
+
"&[data-dragging]": {
|
|
344
|
+
opacity: "0.35",
|
|
345
|
+
},
|
|
346
|
+
"&[data-preview]": {
|
|
347
|
+
zIndex: "3",
|
|
348
|
+
opacity: "1",
|
|
349
|
+
boxShadow: "inset 3px 0 0 var(--ui-time-grid-color), 0 8px 24px -8px color-mix(in oklch, var(--ui-time-grid-color) 50%, transparent)",
|
|
350
|
+
},
|
|
351
|
+
"&:has(:popover-open)": { zIndex: "2" },
|
|
352
|
+
}),
|
|
353
|
+
motionReduce(raw({ transition: "none" })),
|
|
354
|
+
], children: [_jsxs(Trigger, { id: `${id}-event-${event.id}`, popoverId: popoverId, href: event.href, label: [event.title, event.time].filter(Boolean).join(", "), children: [_jsxs("span", { "aria-hidden": "true", "data-slot": "time-grid-title", mix: [
|
|
355
|
+
raw({
|
|
356
|
+
flexShrink: "0",
|
|
357
|
+
fontWeight: "600",
|
|
358
|
+
overflow: "hidden",
|
|
359
|
+
textOverflow: "ellipsis",
|
|
360
|
+
[ONE_LINE]: { whiteSpace: "nowrap" },
|
|
361
|
+
}),
|
|
362
|
+
], children: [event.title, event.time === undefined ? null : (_jsx("span", { mix: [
|
|
363
|
+
raw({
|
|
364
|
+
display: "none",
|
|
365
|
+
fontWeight: "400",
|
|
366
|
+
opacity: "0.8",
|
|
367
|
+
[ONE_LINE]: { display: "inline" },
|
|
368
|
+
}),
|
|
369
|
+
], children: `, ${event.time}` }))] }), event.time === undefined ? null : (_jsx("span", { "aria-hidden": "true", "data-slot": "time-grid-time", mix: [
|
|
370
|
+
raw({
|
|
371
|
+
flexShrink: "0",
|
|
372
|
+
opacity: "0.8",
|
|
373
|
+
whiteSpace: "nowrap",
|
|
374
|
+
[ONE_LINE]: { display: "none" },
|
|
375
|
+
}),
|
|
376
|
+
], children: event.time })), event.detail === undefined ? null : (_jsx("span", { "aria-hidden": "true", mix: [
|
|
377
|
+
raw({
|
|
378
|
+
flexShrink: "0",
|
|
379
|
+
opacity: "0.8",
|
|
380
|
+
whiteSpace: "nowrap",
|
|
381
|
+
overflow: "hidden",
|
|
382
|
+
textOverflow: "ellipsis",
|
|
383
|
+
[TWO_LINES]: { display: "none" },
|
|
384
|
+
}),
|
|
385
|
+
], children: event.detail }))] }), event.editable && movable ? (_jsx("span", { "aria-hidden": "true", "data-slot": "time-grid-resize", mix: [
|
|
386
|
+
raw({
|
|
387
|
+
position: "absolute",
|
|
388
|
+
insetInline: "0.25rem",
|
|
389
|
+
insetBlockEnd: "0",
|
|
390
|
+
blockSize: "0.5rem",
|
|
391
|
+
cursor: "ns-resize",
|
|
392
|
+
touchAction: "none",
|
|
393
|
+
"&::after": {
|
|
394
|
+
content: "''",
|
|
395
|
+
position: "absolute",
|
|
396
|
+
insetInlineStart: "50%",
|
|
397
|
+
insetBlockEnd: "0.125rem",
|
|
398
|
+
inlineSize: "1rem",
|
|
399
|
+
blockSize: "0.1875rem",
|
|
400
|
+
marginInlineStart: "-0.5rem",
|
|
401
|
+
borderRadius: "999px",
|
|
402
|
+
backgroundColor: "currentColor",
|
|
403
|
+
opacity: "0",
|
|
404
|
+
transition: "opacity 120ms",
|
|
405
|
+
},
|
|
406
|
+
"[data-slot='time-grid-event']:hover > &::after": { opacity: "0.45" },
|
|
407
|
+
}),
|
|
408
|
+
] })) : null, popoverId === undefined ? null : (_jsx(Popover, { id: popoverId, placement: "right-start", children: event.popover }))] }));
|
|
409
|
+
};
|
|
410
|
+
}
|
|
411
|
+
/** A hidden form a drag fills in and submits, carrying the consumer's own fields. */
|
|
412
|
+
function EditForm(handle) {
|
|
413
|
+
return () => {
|
|
414
|
+
let { kind, form } = handle.props;
|
|
415
|
+
return (_jsx("form", { hidden: true, method: form.method ?? "post", action: form.action, "data-time-grid-form": kind, "data-rmx-target": form.target, children: Object.entries(form.fields ?? {}).map(([name, value]) => (_jsx("input", { type: "hidden", name: name, value: value }))) }));
|
|
416
|
+
};
|
|
417
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lays a day's timed events out side by side and a range's all-day spans out in rows, the two
|
|
3
|
+
* placements a calendar's time grid needs. Events that overlap share their cluster's width in
|
|
4
|
+
* columns, and an event widens into the columns to its right that are free for its whole length.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
/** A timed event as the layout reads it: minutes from the day's start. */
|
|
10
|
+
export interface TimedItem {
|
|
11
|
+
id: string;
|
|
12
|
+
start: number;
|
|
13
|
+
end: number;
|
|
14
|
+
}
|
|
15
|
+
/** Where an event sits within its overlap cluster. */
|
|
16
|
+
export interface TimedPlacement {
|
|
17
|
+
/** Its column, from 0. */
|
|
18
|
+
column: number;
|
|
19
|
+
/** How many columns its cluster splits into. */
|
|
20
|
+
columns: number;
|
|
21
|
+
/** How many columns it spans, from its own rightwards. */
|
|
22
|
+
span: number;
|
|
23
|
+
}
|
|
24
|
+
/** An all-day span as the layout reads it: indexes of its first and last visible day. */
|
|
25
|
+
export interface SpanItem {
|
|
26
|
+
id: string;
|
|
27
|
+
first: number;
|
|
28
|
+
last: number;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Places a day's events: events whose times chain together by overlap form a cluster split into
|
|
32
|
+
* as many columns as it needs at its busiest, each event in the first column free at its start
|
|
33
|
+
* (earlier starts first, longer events first on a tie), then widened rightwards while free.
|
|
34
|
+
*
|
|
35
|
+
* @param items The day's events, in any order.
|
|
36
|
+
* @returns Each event's placement, keyed by its id.
|
|
37
|
+
* @example layoutTimedItems([{ id: "a", start: 540, end: 600 }, { id: "b", start: 570, end: 630 }]) // a column 0 of 2, b column 1 of 2
|
|
38
|
+
*/
|
|
39
|
+
export declare function layoutTimedItems(items: TimedItem[]): Map<string, TimedPlacement>;
|
|
40
|
+
/**
|
|
41
|
+
* Stacks all-day spans into rows: longer spans first so they claim the top rows, then each in
|
|
42
|
+
* the first row that is free across all of its days.
|
|
43
|
+
*
|
|
44
|
+
* @param items The spans, clipped to the visible days.
|
|
45
|
+
* @returns Each span's row from 0, keyed by its id, and how many rows the lane needs.
|
|
46
|
+
*/
|
|
47
|
+
export declare function layoutSpanItems(items: SpanItem[]): {
|
|
48
|
+
rows: Map<string, number>;
|
|
49
|
+
count: number;
|
|
50
|
+
};
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lays a day's timed events out side by side and a range's all-day spans out in rows, the two
|
|
3
|
+
* placements a calendar's time grid needs. Events that overlap share their cluster's width in
|
|
4
|
+
* columns, and an event widens into the columns to its right that are free for its whole length.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
/** The shortest length an event takes up on the grid, the height of one line of its title. */
|
|
10
|
+
const MIN_BLOCK_MINUTES = 30;
|
|
11
|
+
/**
|
|
12
|
+
* The end a placement compares against: a short event still blocks the half hour its block is
|
|
13
|
+
* drawn over, so a 15-minute standup sits beside the event right after it instead of under it.
|
|
14
|
+
*/
|
|
15
|
+
function blockingEnd(item) {
|
|
16
|
+
return Math.max(item.end, item.start + MIN_BLOCK_MINUTES);
|
|
17
|
+
}
|
|
18
|
+
/** Whether two events share any minute. */
|
|
19
|
+
function overlaps(a, b) {
|
|
20
|
+
return a.start < blockingEnd(b) && b.start < blockingEnd(a);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Places a day's events: events whose times chain together by overlap form a cluster split into
|
|
24
|
+
* as many columns as it needs at its busiest, each event in the first column free at its start
|
|
25
|
+
* (earlier starts first, longer events first on a tie), then widened rightwards while free.
|
|
26
|
+
*
|
|
27
|
+
* @param items The day's events, in any order.
|
|
28
|
+
* @returns Each event's placement, keyed by its id.
|
|
29
|
+
* @example layoutTimedItems([{ id: "a", start: 540, end: 600 }, { id: "b", start: 570, end: 630 }]) // a column 0 of 2, b column 1 of 2
|
|
30
|
+
*/
|
|
31
|
+
export function layoutTimedItems(items) {
|
|
32
|
+
let sorted = items
|
|
33
|
+
.slice()
|
|
34
|
+
.sort((a, b) => a.start - b.start || blockingEnd(b) - blockingEnd(a) || a.id.localeCompare(b.id));
|
|
35
|
+
let placements = new Map();
|
|
36
|
+
let cluster = [];
|
|
37
|
+
let columnEnds = [];
|
|
38
|
+
let clusterEnd = -Infinity;
|
|
39
|
+
/** Fixes the finished cluster's column count and each event's span. */
|
|
40
|
+
function close() {
|
|
41
|
+
let columns = columnEnds.length;
|
|
42
|
+
for (let entry of cluster) {
|
|
43
|
+
let span = 1;
|
|
44
|
+
while (entry.column + span < columns &&
|
|
45
|
+
!cluster.some((other) => other.column === entry.column + span && overlaps(other.item, entry.item))) {
|
|
46
|
+
span += 1;
|
|
47
|
+
}
|
|
48
|
+
placements.set(entry.item.id, { column: entry.column, columns, span });
|
|
49
|
+
}
|
|
50
|
+
cluster = [];
|
|
51
|
+
columnEnds = [];
|
|
52
|
+
}
|
|
53
|
+
for (let item of sorted) {
|
|
54
|
+
if (item.start >= clusterEnd)
|
|
55
|
+
close();
|
|
56
|
+
let column = columnEnds.findIndex((end) => end <= item.start);
|
|
57
|
+
if (column === -1) {
|
|
58
|
+
column = columnEnds.length;
|
|
59
|
+
columnEnds.push(blockingEnd(item));
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
columnEnds[column] = blockingEnd(item);
|
|
63
|
+
}
|
|
64
|
+
cluster.push({ item, column });
|
|
65
|
+
clusterEnd = Math.max(clusterEnd, blockingEnd(item));
|
|
66
|
+
}
|
|
67
|
+
close();
|
|
68
|
+
return placements;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Stacks all-day spans into rows: longer spans first so they claim the top rows, then each in
|
|
72
|
+
* the first row that is free across all of its days.
|
|
73
|
+
*
|
|
74
|
+
* @param items The spans, clipped to the visible days.
|
|
75
|
+
* @returns Each span's row from 0, keyed by its id, and how many rows the lane needs.
|
|
76
|
+
*/
|
|
77
|
+
export function layoutSpanItems(items) {
|
|
78
|
+
let sorted = items
|
|
79
|
+
.slice()
|
|
80
|
+
.sort((a, b) => a.first - b.first || b.last - b.first - (a.last - a.first) || a.id.localeCompare(b.id));
|
|
81
|
+
let taken = [];
|
|
82
|
+
let rows = new Map();
|
|
83
|
+
for (let item of sorted) {
|
|
84
|
+
let row = taken.findIndex((ranges) => ranges.every(([first, last]) => item.last < first || item.first > last));
|
|
85
|
+
if (row === -1) {
|
|
86
|
+
row = taken.length;
|
|
87
|
+
taken.push([]);
|
|
88
|
+
}
|
|
89
|
+
taken[row].push([item.first, item.last]);
|
|
90
|
+
rows.set(item.id, row);
|
|
91
|
+
}
|
|
92
|
+
return { rows, count: taken.length };
|
|
93
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A calendar's year: twelve small months in a grid that reflows from four columns to one, each
|
|
3
|
+
* day a link with a dot whose weight follows how busy the day is, today ringed and the chosen day
|
|
4
|
+
* filled, so a year reads at a glance and any day is one tap away.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
import type { Handle, Props as TagProps } from "remix/component";
|
|
10
|
+
/** Prop types for {@link YearView}. */
|
|
11
|
+
export declare namespace YearView {
|
|
12
|
+
/** Every string the view announces; `{…}` marks where a value goes. */
|
|
13
|
+
interface Labels {
|
|
14
|
+
/** A day's count for a screen reader, such as "{count} events". */
|
|
15
|
+
count: string;
|
|
16
|
+
}
|
|
17
|
+
/** Props accepted by {@link YearView}. */
|
|
18
|
+
interface Props extends Omit<TagProps<"div">, "children"> {
|
|
19
|
+
year: number;
|
|
20
|
+
/** Events per day, keyed `YYYY-MM-DD`; a day missing from it is free. */
|
|
21
|
+
counts?: Record<string, number>;
|
|
22
|
+
/** Today, as `YYYY-MM-DD`, ringed. */
|
|
23
|
+
today?: string;
|
|
24
|
+
/** The chosen day, as `YYYY-MM-DD`, filled. */
|
|
25
|
+
selected?: string;
|
|
26
|
+
/** Where a day leads, such as its day view. */
|
|
27
|
+
dayHref: (date: string) => string;
|
|
28
|
+
/** Where a month's name leads, such as its month view; plain text without it. */
|
|
29
|
+
monthHref?: (month: string) => string;
|
|
30
|
+
/** 0 for Sunday, 1 for Monday. @default 0 */
|
|
31
|
+
weekStartsOn?: 0 | 1;
|
|
32
|
+
/** @default "en" */
|
|
33
|
+
locale?: string;
|
|
34
|
+
labels: Labels;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Renders the year: a heading per month (a link when `monthHref` is set) over its weekday
|
|
39
|
+
* initials and day links. Dots grow and darken with a day's count, so busy stretches show as
|
|
40
|
+
* texture across the year.
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* <YearView year={2026} today="2026-11-18" counts={{ "2026-11-18": 4 }} dayHref={(date) => `/day/${date}`}
|
|
44
|
+
* labels={{ count: "{count} events" }} />
|
|
45
|
+
*/
|
|
46
|
+
export declare function YearView(handle: Handle<YearView.Props>): () => import("remix/component").RemixElement;
|