@sdxc/ui 2026.11.18 → 2026.11.26
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 +133 -1
- 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/slider.js +7 -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/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/package.json +21 -2
|
@@ -0,0 +1,301 @@
|
|
|
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 { when } from "@sdxc/u/state";
|
|
5
|
+
import { Popover } from "../components/popover.js";
|
|
6
|
+
import { layoutSpanItems } from "./utils/time-grid-layout.js";
|
|
7
|
+
/** Milliseconds in a day, for walking the grid's dates. */
|
|
8
|
+
const DAY_MS = 86_400_000;
|
|
9
|
+
/** Container the view names, so its cells switch to dots when the view is narrow. */
|
|
10
|
+
const MONTH_CONTAINER = "ui-month-view";
|
|
11
|
+
/** Below this width each day shows dots rather than titles. */
|
|
12
|
+
const NARROW = `@container ${MONTH_CONTAINER} (width < 36rem)`;
|
|
13
|
+
/** How many entries a day shows before "+N more" when `max` is unset. */
|
|
14
|
+
const DEFAULT_MAX = 3;
|
|
15
|
+
/** A `YYYY-MM-DD` date as its UTC instant. */
|
|
16
|
+
function instantOf(date) {
|
|
17
|
+
return Date.parse(`${date}T00:00:00Z`);
|
|
18
|
+
}
|
|
19
|
+
/** A UTC instant as its `YYYY-MM-DD` date. */
|
|
20
|
+
function dateOf(instant) {
|
|
21
|
+
return new Date(instant).toISOString().slice(0, 10);
|
|
22
|
+
}
|
|
23
|
+
/** Every date the month's grid shows: whole weeks from the one holding the 1st to the last's. */
|
|
24
|
+
function gridWeeks(month, weekStartsOn) {
|
|
25
|
+
let first = instantOf(`${month}-01`);
|
|
26
|
+
let year = Number(month.slice(0, 4));
|
|
27
|
+
let index = Number(month.slice(5, 7));
|
|
28
|
+
let last = Date.UTC(year, index, 0);
|
|
29
|
+
let start = first - ((new Date(first).getUTCDay() - weekStartsOn + 7) % 7) * DAY_MS;
|
|
30
|
+
let weeks = [];
|
|
31
|
+
for (let cursor = start; cursor <= last; cursor += 7 * DAY_MS) {
|
|
32
|
+
weeks.push(Array.from({ length: 7 }, (_, day) => dateOf(cursor + day * DAY_MS)));
|
|
33
|
+
}
|
|
34
|
+
return weeks;
|
|
35
|
+
}
|
|
36
|
+
/** Whether an event draws as a bar rather than a dotted line. */
|
|
37
|
+
function isBar(event) {
|
|
38
|
+
return event.allDay === true || (event.end !== undefined && event.end > event.start);
|
|
39
|
+
}
|
|
40
|
+
/** The face of an entry: a popover button, a link, or plain text. */
|
|
41
|
+
function Entry(handle) {
|
|
42
|
+
return () => {
|
|
43
|
+
let { id, event, bar, label } = handle.props;
|
|
44
|
+
let popoverId = event.popover === undefined ? undefined : `${id}-popover`;
|
|
45
|
+
let style = `--ui-month-view-color: ${event.color ?? "var(--ui-brand-bg-solid)"}`;
|
|
46
|
+
let past = event.past ? "" : undefined;
|
|
47
|
+
let content = bar ? (_jsx("span", { mix: [
|
|
48
|
+
raw({
|
|
49
|
+
overflow: "hidden",
|
|
50
|
+
textOverflow: "ellipsis",
|
|
51
|
+
whiteSpace: "nowrap",
|
|
52
|
+
fontWeight: "600",
|
|
53
|
+
}),
|
|
54
|
+
], children: event.title })) : (_jsxs(_Fragment, { children: [_jsx("span", { "aria-hidden": "true", mix: [
|
|
55
|
+
raw({
|
|
56
|
+
flex: "none",
|
|
57
|
+
inlineSize: "0.4375rem",
|
|
58
|
+
blockSize: "0.4375rem",
|
|
59
|
+
borderRadius: "999px",
|
|
60
|
+
backgroundColor: "var(--ui-month-view-color)",
|
|
61
|
+
}),
|
|
62
|
+
] }), event.time === undefined ? null : (_jsx("span", { mix: [
|
|
63
|
+
raw({ flex: "none", color: "var(--ui-neutral-fg-muted)" }),
|
|
64
|
+
when(NARROW, raw({ display: "none" })),
|
|
65
|
+
], children: event.time })), _jsx("span", { mix: [
|
|
66
|
+
raw({
|
|
67
|
+
overflow: "hidden",
|
|
68
|
+
textOverflow: "ellipsis",
|
|
69
|
+
whiteSpace: "nowrap",
|
|
70
|
+
fontWeight: "500",
|
|
71
|
+
}),
|
|
72
|
+
when(NARROW, visuallyHidden()),
|
|
73
|
+
], children: event.title })] }));
|
|
74
|
+
let mix = [
|
|
75
|
+
raw({
|
|
76
|
+
all: "unset",
|
|
77
|
+
boxSizing: "border-box",
|
|
78
|
+
display: "flex",
|
|
79
|
+
alignItems: "center",
|
|
80
|
+
gap: "0.3125rem",
|
|
81
|
+
inlineSize: "100%",
|
|
82
|
+
minInlineSize: "0",
|
|
83
|
+
blockSize: "1.375rem",
|
|
84
|
+
paddingInline: "0.375rem",
|
|
85
|
+
borderRadius: "0.3125rem",
|
|
86
|
+
fontSize: "0.75rem",
|
|
87
|
+
lineHeight: "1rem",
|
|
88
|
+
cursor: "pointer",
|
|
89
|
+
color: "var(--ui-neutral-fg-emphasis)",
|
|
90
|
+
"&:hover": { backgroundColor: "var(--ui-neutral-bg-tint)" },
|
|
91
|
+
"&:focus-visible": { boxShadow: "0 0 0 2px var(--ui-brand-ring)" },
|
|
92
|
+
"&[data-past]": { opacity: "0.62" },
|
|
93
|
+
}),
|
|
94
|
+
bar
|
|
95
|
+
? raw({
|
|
96
|
+
backgroundColor: "color-mix(in oklch, var(--ui-month-view-color) 16%, var(--ui-bg, Canvas))",
|
|
97
|
+
color: "color-mix(in oklch, var(--ui-month-view-color) 45%, var(--ui-neutral-fg-emphasis, CanvasText))",
|
|
98
|
+
boxShadow: "inset 3px 0 0 var(--ui-month-view-color)",
|
|
99
|
+
"&:hover": {
|
|
100
|
+
backgroundColor: "color-mix(in oklch, var(--ui-month-view-color) 24%, var(--ui-bg, Canvas))",
|
|
101
|
+
},
|
|
102
|
+
})
|
|
103
|
+
: when(NARROW, raw({ inlineSize: "auto", paddingInline: "0.125rem" })),
|
|
104
|
+
];
|
|
105
|
+
if (popoverId !== undefined)
|
|
106
|
+
return (_jsxs(_Fragment, { children: [_jsx("button", { type: "button", popovertarget: popoverId, "aria-label": label, style: style, "data-past": past, "data-slot": "month-view-entry", mix: mix, children: content }), _jsx(Popover, { id: popoverId, placement: "right-start", children: event.popover })] }));
|
|
107
|
+
if (event.href !== undefined)
|
|
108
|
+
return (_jsx("a", { href: event.href, "aria-label": label, style: style, "data-past": past, "data-slot": "month-view-entry", mix: mix, children: content }));
|
|
109
|
+
return (_jsx("span", { "aria-label": label, role: "img", style: style, "data-past": past, "data-slot": "month-view-entry", mix: mix, children: content }));
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Renders the month: a header of weekday names over one grid per week. Bars take the week's top
|
|
114
|
+
* rows, stacked so none overlap, and each day lists its timed events under them until `max`,
|
|
115
|
+
* where a "+N more" link to the day takes over.
|
|
116
|
+
*
|
|
117
|
+
* @example
|
|
118
|
+
* <MonthView id="nov" month="2026-11" today="2026-11-18" labels={{ more: "+{count} more", count: "{count} events" }}
|
|
119
|
+
* events={[{ id: "e1", start: "2026-11-18", time: "9 AM", title: "Standup" }]} />
|
|
120
|
+
*/
|
|
121
|
+
export function MonthView(handle) {
|
|
122
|
+
return () => {
|
|
123
|
+
let { id, month, events, today, selected, weekStartsOn = 0, dayHref, max = DEFAULT_MAX, locale = "en", labels, mix, ...rest } = handle.props;
|
|
124
|
+
let weeks = gridWeeks(month, weekStartsOn);
|
|
125
|
+
let weekdayShort = new Intl.DateTimeFormat(locale, { weekday: "short", timeZone: "UTC" });
|
|
126
|
+
let weekdayNarrow = new Intl.DateTimeFormat(locale, { weekday: "narrow", timeZone: "UTC" });
|
|
127
|
+
let fullDay = new Intl.DateTimeFormat(locale, { dateStyle: "full", timeZone: "UTC" });
|
|
128
|
+
let monthName = new Intl.DateTimeFormat(locale, { month: "short", timeZone: "UTC" });
|
|
129
|
+
let time = new Intl.DateTimeFormat(locale, { dateStyle: "medium", timeZone: "UTC" });
|
|
130
|
+
return (_jsxs("div", { ...rest, id: id, "data-slot": "month-view", mix: mergeMix([
|
|
131
|
+
raw({
|
|
132
|
+
container: `${MONTH_CONTAINER} / inline-size`,
|
|
133
|
+
display: "flex",
|
|
134
|
+
flexDirection: "column",
|
|
135
|
+
minInlineSize: "0",
|
|
136
|
+
minBlockSize: "0",
|
|
137
|
+
fontVariantNumeric: "tabular-nums",
|
|
138
|
+
}),
|
|
139
|
+
], mix), children: [_jsx("div", { "aria-hidden": "true", mix: [
|
|
140
|
+
raw({
|
|
141
|
+
display: "grid",
|
|
142
|
+
gridTemplateColumns: "repeat(7, minmax(0, 1fr))",
|
|
143
|
+
borderBlockEnd: "1px solid var(--ui-neutral-border)",
|
|
144
|
+
}),
|
|
145
|
+
], children: (weeks[0] ?? []).map((date) => (_jsxs("span", { mix: [
|
|
146
|
+
raw({
|
|
147
|
+
paddingBlock: "0.375rem",
|
|
148
|
+
fontSize: "0.6875rem",
|
|
149
|
+
fontWeight: "600",
|
|
150
|
+
letterSpacing: "0.05em",
|
|
151
|
+
textTransform: "uppercase",
|
|
152
|
+
textAlign: "center",
|
|
153
|
+
color: "var(--ui-neutral-fg-muted)",
|
|
154
|
+
}),
|
|
155
|
+
], children: [_jsx("span", { mix: [when(NARROW, raw({ display: "none" }))], children: weekdayShort.format(new Date(instantOf(date))) }), _jsx("span", { mix: [raw({ display: "none" }), when(NARROW, raw({ display: "inline" }))], children: weekdayNarrow.format(new Date(instantOf(date))) })] }))) }), _jsx("ol", { "data-slot": "month-view-weeks", mix: [
|
|
156
|
+
raw({
|
|
157
|
+
flex: "1 1 auto",
|
|
158
|
+
display: "grid",
|
|
159
|
+
gridAutoRows: "minmax(6.5rem, 1fr)",
|
|
160
|
+
margin: "0",
|
|
161
|
+
padding: "0",
|
|
162
|
+
listStyle: "none",
|
|
163
|
+
}),
|
|
164
|
+
when(NARROW, raw({ gridAutoRows: "minmax(3.25rem, 1fr)" })),
|
|
165
|
+
], children: weeks.map((week) => {
|
|
166
|
+
let weekStart = week[0];
|
|
167
|
+
let weekEnd = week[6];
|
|
168
|
+
let bars = events
|
|
169
|
+
.filter((event) => isBar(event) && event.start <= weekEnd && (event.end ?? event.start) >= weekStart)
|
|
170
|
+
.map((event) => ({
|
|
171
|
+
event,
|
|
172
|
+
first: Math.max(0, week.indexOf(event.start)),
|
|
173
|
+
last: week.includes(event.end ?? event.start)
|
|
174
|
+
? week.indexOf(event.end ?? event.start)
|
|
175
|
+
: 6,
|
|
176
|
+
}))
|
|
177
|
+
.map((entry) => ({
|
|
178
|
+
...entry,
|
|
179
|
+
first: entry.event.start < weekStart ? 0 : entry.first,
|
|
180
|
+
}));
|
|
181
|
+
let lane = layoutSpanItems(bars.map((entry) => ({ id: entry.event.id, first: entry.first, last: entry.last })));
|
|
182
|
+
let shownRows = Math.min(lane.count, max);
|
|
183
|
+
return (_jsxs("li", { "data-slot": "month-view-week", mix: [
|
|
184
|
+
raw({
|
|
185
|
+
position: "relative",
|
|
186
|
+
display: "grid",
|
|
187
|
+
gridTemplateColumns: "repeat(7, minmax(0, 1fr))",
|
|
188
|
+
gridTemplateRows: shownRows === 0 ? "auto 1fr" : `auto repeat(${shownRows}, auto) 1fr`,
|
|
189
|
+
alignContent: "start",
|
|
190
|
+
rowGap: "0.125rem",
|
|
191
|
+
paddingBlockEnd: "0.25rem",
|
|
192
|
+
borderBlockEnd: "1px solid var(--ui-neutral-border)",
|
|
193
|
+
minBlockSize: "0",
|
|
194
|
+
}),
|
|
195
|
+
], children: [week.map((date, column) => {
|
|
196
|
+
let outside = !date.startsWith(month);
|
|
197
|
+
let isToday = date === today;
|
|
198
|
+
let dayBars = bars.filter((entry) => column >= entry.first && column <= entry.last);
|
|
199
|
+
let hiddenBars = dayBars.filter((entry) => (lane.rows.get(entry.event.id) ?? 0) >= shownRows);
|
|
200
|
+
let timed = events
|
|
201
|
+
.filter((event) => !isBar(event) && event.start === date)
|
|
202
|
+
.sort((a, b) => (a.time ?? "").localeCompare(b.time ?? ""));
|
|
203
|
+
let room = Math.max(0, max - Math.min(dayBars.length, shownRows));
|
|
204
|
+
let visible = timed.length + hiddenBars.length > room
|
|
205
|
+
? timed.slice(0, Math.max(0, room - 1))
|
|
206
|
+
: timed;
|
|
207
|
+
let more = timed.length - visible.length + hiddenBars.length;
|
|
208
|
+
let total = dayBars.length + timed.length;
|
|
209
|
+
let first = new Date(instantOf(date)).getUTCDate() === 1;
|
|
210
|
+
let number = new Date(instantOf(date)).getUTCDate();
|
|
211
|
+
return (_jsxs(_Fragment, { children: [_jsx("span", { "data-slot": "month-view-day", "data-date": date, "data-outside": outside ? "" : undefined, "data-today": isToday ? "" : undefined, "data-selected": date === selected ? "" : undefined, mix: [
|
|
212
|
+
raw({
|
|
213
|
+
gridColumn: `${column + 1}`,
|
|
214
|
+
gridRow: "1 / -1",
|
|
215
|
+
borderInlineStart: column === 0 ? "none" : "1px solid var(--ui-neutral-border)",
|
|
216
|
+
"&[data-outside]": {
|
|
217
|
+
backgroundColor: "color-mix(in oklch, var(--ui-neutral-bg-tint) 60%, transparent)",
|
|
218
|
+
},
|
|
219
|
+
"&[data-selected]": {
|
|
220
|
+
backgroundColor: "color-mix(in oklch, var(--ui-brand-bg-solid) 7%, transparent)",
|
|
221
|
+
},
|
|
222
|
+
}),
|
|
223
|
+
] }), _jsxs("a", { href: dayHref?.(date), "aria-current": isToday ? "date" : undefined, "data-slot": "month-view-number", mix: [
|
|
224
|
+
raw({
|
|
225
|
+
gridColumn: `${column + 1}`,
|
|
226
|
+
gridRow: "1",
|
|
227
|
+
position: "relative",
|
|
228
|
+
justifySelf: "start",
|
|
229
|
+
display: "inline-flex",
|
|
230
|
+
alignItems: "center",
|
|
231
|
+
justifyContent: "center",
|
|
232
|
+
minInlineSize: "1.625rem",
|
|
233
|
+
blockSize: "1.625rem",
|
|
234
|
+
margin: "0.25rem",
|
|
235
|
+
paddingInline: "0.3125rem",
|
|
236
|
+
boxSizing: "border-box",
|
|
237
|
+
borderRadius: "999px",
|
|
238
|
+
fontSize: "0.75rem",
|
|
239
|
+
fontWeight: "600",
|
|
240
|
+
color: "var(--ui-neutral-fg-emphasis)",
|
|
241
|
+
textDecoration: "none",
|
|
242
|
+
outline: "none",
|
|
243
|
+
"[data-outside] + &": { color: "var(--ui-neutral-fg-muted)" },
|
|
244
|
+
"&[href]:hover": { backgroundColor: "var(--ui-neutral-bg-tint)" },
|
|
245
|
+
"&[aria-current='date']": {
|
|
246
|
+
backgroundColor: "var(--ui-brand-bg-solid)",
|
|
247
|
+
color: "var(--ui-brand-fg-on-solid, white)",
|
|
248
|
+
},
|
|
249
|
+
"&:focus-visible": { boxShadow: "0 0 0 2px var(--ui-brand-ring)" },
|
|
250
|
+
}),
|
|
251
|
+
when(NARROW, raw({ justifySelf: "center", fontSize: "0.6875rem" })),
|
|
252
|
+
], children: [_jsx("span", { "aria-hidden": "true", children: first
|
|
253
|
+
? `${monthName.format(new Date(instantOf(date)))} ${number}`
|
|
254
|
+
: number }), _jsxs("span", { mix: [visuallyHidden()], children: [fullDay.format(new Date(instantOf(date))), total > 0 ? `, ${labels.count.replace("{count}", String(total))}` : ""] })] }), _jsxs("div", { "data-slot": "month-view-entries", mix: [
|
|
255
|
+
raw({
|
|
256
|
+
gridColumn: `${column + 1}`,
|
|
257
|
+
gridRow: `${shownRows + 2}`,
|
|
258
|
+
display: "flex",
|
|
259
|
+
flexDirection: "column",
|
|
260
|
+
gap: "0.125rem",
|
|
261
|
+
minInlineSize: "0",
|
|
262
|
+
paddingInline: "0.25rem",
|
|
263
|
+
}),
|
|
264
|
+
when(NARROW, raw({
|
|
265
|
+
flexDirection: "row",
|
|
266
|
+
flexWrap: "wrap",
|
|
267
|
+
justifyContent: "center",
|
|
268
|
+
gap: "0",
|
|
269
|
+
})),
|
|
270
|
+
], children: [visible.map((event) => (_jsx(Entry, { id: `${id}-${event.id}`, event: event, bar: false, label: [event.time, event.title].filter(Boolean).join(" ") }))), more > 0 ? (_jsx("a", { href: dayHref?.(date), "data-slot": "month-view-more", mix: [
|
|
271
|
+
raw({
|
|
272
|
+
alignSelf: "start",
|
|
273
|
+
paddingInline: "0.375rem",
|
|
274
|
+
fontSize: "0.75rem",
|
|
275
|
+
fontWeight: "600",
|
|
276
|
+
color: "var(--ui-neutral-fg-muted)",
|
|
277
|
+
textDecoration: "none",
|
|
278
|
+
borderRadius: "0.3125rem",
|
|
279
|
+
"&:hover": {
|
|
280
|
+
color: "var(--ui-neutral-fg-emphasis)",
|
|
281
|
+
backgroundColor: "var(--ui-neutral-bg-tint)",
|
|
282
|
+
},
|
|
283
|
+
}),
|
|
284
|
+
when(NARROW, raw({ fontSize: "0.625rem", paddingInline: "0.125rem" })),
|
|
285
|
+
], children: labels.more.replace("{count}", String(more)) })) : null] })] }));
|
|
286
|
+
}), bars
|
|
287
|
+
.filter((entry) => (lane.rows.get(entry.event.id) ?? 0) < shownRows)
|
|
288
|
+
.map((entry) => (_jsx("div", { "data-slot": "month-view-bar", "data-id": entry.event.id, "data-past": entry.event.past ? "" : undefined, style: `--ui-month-view-color: ${entry.event.color ?? "var(--ui-brand-bg-solid)"}`, mix: [
|
|
289
|
+
raw({
|
|
290
|
+
gridColumn: `${entry.first + 1} / ${entry.last + 2}`,
|
|
291
|
+
gridRow: `${(lane.rows.get(entry.event.id) ?? 0) + 2}`,
|
|
292
|
+
position: "relative",
|
|
293
|
+
minInlineSize: "0",
|
|
294
|
+
paddingInline: "0.25rem",
|
|
295
|
+
"&[data-past]": { opacity: "0.62" },
|
|
296
|
+
}),
|
|
297
|
+
when(NARROW, raw({ paddingInline: "0.0625rem", "& span": { fontSize: "0.625rem" } })),
|
|
298
|
+
], children: _jsx(Entry, { id: `${id}-${entry.event.id}-${weekStart}`, event: entry.event, bar: true, label: `${entry.event.title}, ${time.format(new Date(instantOf(entry.event.start)))} – ${time.format(new Date(instantOf(entry.event.end ?? entry.event.start)))}` }) })))] }));
|
|
299
|
+
}) })] }));
|
|
300
|
+
};
|
|
301
|
+
}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A calendar's time grid: one column per day under a header of dates and a lane of all-day and
|
|
3
|
+
* multi-day spans, hours down the side in one or more time zones, timed events placed by their
|
|
4
|
+
* minutes with overlapping ones side by side, and a line at the present minute.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
import type { EntryComponent, Handle, Props as TagProps, RemixNode } from "remix/component";
|
|
10
|
+
/** Prop types for {@link TimeGrid}. */
|
|
11
|
+
export declare namespace TimeGrid {
|
|
12
|
+
/** Every string the grid shows or announces; `{…}` marks where a value goes. */
|
|
13
|
+
interface Labels {
|
|
14
|
+
/** The all-day lane's name, such as "All day". */
|
|
15
|
+
allDay: string;
|
|
16
|
+
/** The present-minute line's name, such as "Now". */
|
|
17
|
+
now: string;
|
|
18
|
+
/** What a move announces, such as "{title} moved to {time}". */
|
|
19
|
+
moved: string;
|
|
20
|
+
/** What a resize announces, such as "{title} now ends at {time}". */
|
|
21
|
+
resized: string;
|
|
22
|
+
}
|
|
23
|
+
/** One day column. */
|
|
24
|
+
interface Day {
|
|
25
|
+
/** The day, as `YYYY-MM-DD`. */
|
|
26
|
+
date: string;
|
|
27
|
+
/** The day's own view, which its header links to. */
|
|
28
|
+
href?: string;
|
|
29
|
+
/** Tints the column, such as a weekend or a holiday. */
|
|
30
|
+
muted?: boolean;
|
|
31
|
+
}
|
|
32
|
+
/** One column of hour labels: the viewer's zone first, then any second zone. */
|
|
33
|
+
interface Zone {
|
|
34
|
+
/** The zone's short name over its column, such as "EST". */
|
|
35
|
+
label: string;
|
|
36
|
+
/** The label beside each hour of the grid's days, 24 of them, such as "9 AM". */
|
|
37
|
+
hours: string[];
|
|
38
|
+
}
|
|
39
|
+
/** A timed event, or the part of one that falls on a single day. */
|
|
40
|
+
interface Event {
|
|
41
|
+
/** Unique on the grid; a move posts it. */
|
|
42
|
+
id: string;
|
|
43
|
+
/** The day it falls on, as `YYYY-MM-DD`. */
|
|
44
|
+
date: string;
|
|
45
|
+
/** Minutes from the day's start. */
|
|
46
|
+
start: number;
|
|
47
|
+
/** Minutes from the day's start; up to 1440. */
|
|
48
|
+
end: number;
|
|
49
|
+
title: string;
|
|
50
|
+
/** Its times as the reader reads them, such as "9:00 – 10:30 AM". */
|
|
51
|
+
time?: string;
|
|
52
|
+
/** A line under the title, such as the place. */
|
|
53
|
+
detail?: RemixNode;
|
|
54
|
+
/** Any CSS colour; the block tints itself from it. */
|
|
55
|
+
color?: string;
|
|
56
|
+
/** Opens in a popover anchored to the block; without it, `href` makes the block a link. */
|
|
57
|
+
popover?: RemixNode;
|
|
58
|
+
href?: string;
|
|
59
|
+
/** Lets a drag or the keyboard move and resize it. */
|
|
60
|
+
editable?: boolean;
|
|
61
|
+
/** Draws it hatched, for an invitation not yet answered. */
|
|
62
|
+
tentative?: boolean;
|
|
63
|
+
/** Dims it, for an event already over. */
|
|
64
|
+
past?: boolean;
|
|
65
|
+
}
|
|
66
|
+
/** An all-day or multi-day event in the top lane. */
|
|
67
|
+
interface Span {
|
|
68
|
+
id: string;
|
|
69
|
+
/** Its first day, as `YYYY-MM-DD`; it may start before the grid's first day. */
|
|
70
|
+
start: string;
|
|
71
|
+
/** Its last day, inclusive, as `YYYY-MM-DD`. */
|
|
72
|
+
end: string;
|
|
73
|
+
title: string;
|
|
74
|
+
color?: string;
|
|
75
|
+
popover?: RemixNode;
|
|
76
|
+
href?: string;
|
|
77
|
+
}
|
|
78
|
+
/** A form a drag or a key press posts: where, into which frame, with which fields. */
|
|
79
|
+
interface Form {
|
|
80
|
+
action: string;
|
|
81
|
+
/** `get` for a create that opens a form rather than saving. @default "post" */
|
|
82
|
+
method?: "get" | "post";
|
|
83
|
+
/** The named frame the answer loads into. */
|
|
84
|
+
target?: string;
|
|
85
|
+
/** Hidden fields sent with every submission, such as the page to return to. */
|
|
86
|
+
fields?: Record<string, string>;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* What dragging and the keyboard can change. Each submission adds `date` (`YYYY-MM-DD`),
|
|
90
|
+
* `start` and `end` (minutes from the day's start), and a move or resize adds `id`.
|
|
91
|
+
*/
|
|
92
|
+
interface Edit {
|
|
93
|
+
/** Posted when a drag across empty time ends. */
|
|
94
|
+
create?: Form;
|
|
95
|
+
/** Posted when an editable event is dragged, resized, or moved by key. */
|
|
96
|
+
move?: Form;
|
|
97
|
+
/** The minutes every change snaps to. @default 15 */
|
|
98
|
+
step?: number;
|
|
99
|
+
}
|
|
100
|
+
/** Props accepted by {@link TimeGrid}. */
|
|
101
|
+
interface Props extends Omit<TagProps<"div">, "children"> {
|
|
102
|
+
/** The grid's accessible name, such as "Week of November 16". */
|
|
103
|
+
label: string;
|
|
104
|
+
/** Unique on the page; prefixes every event's popover id. */
|
|
105
|
+
id: string;
|
|
106
|
+
days: Day[];
|
|
107
|
+
events: Event[];
|
|
108
|
+
spans?: Span[];
|
|
109
|
+
/** The viewer's zone, then any second zone, as columns of hour labels. */
|
|
110
|
+
zones: Zone[];
|
|
111
|
+
/** Today, as `YYYY-MM-DD`; its header is marked. */
|
|
112
|
+
today?: string;
|
|
113
|
+
/**
|
|
114
|
+
* The present: the day, its minute, and the instant it was read, so the line moves on as
|
|
115
|
+
* time passes and a cached page still draws it where the clock is.
|
|
116
|
+
*/
|
|
117
|
+
now?: {
|
|
118
|
+
date: string;
|
|
119
|
+
minute: number;
|
|
120
|
+
at: number;
|
|
121
|
+
};
|
|
122
|
+
/** The minutes outside it are shaded, such as `{ start: 540, end: 1080 }`. */
|
|
123
|
+
workday?: {
|
|
124
|
+
start: number;
|
|
125
|
+
end: number;
|
|
126
|
+
};
|
|
127
|
+
/** The minute the grid opens scrolled to. @default 480 */
|
|
128
|
+
scrollTo?: number;
|
|
129
|
+
/** Formats the day headers and the times a change announces. @default "en" */
|
|
130
|
+
locale?: string;
|
|
131
|
+
edit?: Edit;
|
|
132
|
+
/**
|
|
133
|
+
* The previous and next ranges' addresses, which a horizontal swipe on a touch screen
|
|
134
|
+
* follows; keep visible arrows beside the grid, since a swipe has no affordance.
|
|
135
|
+
*/
|
|
136
|
+
pages?: {
|
|
137
|
+
previous: string;
|
|
138
|
+
next: string;
|
|
139
|
+
};
|
|
140
|
+
labels: Labels;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Client island: an invisible marker carrying the grid's opening scroll, its moving now line
|
|
145
|
+
* and, when the grid can be edited, its drags and keyboard moves. Loads from
|
|
146
|
+
* `@sdxc/ui/schedule/time-grid#TimeGridBehavior`.
|
|
147
|
+
*/
|
|
148
|
+
export declare const TimeGridBehavior: EntryComponent<TimeGridBehaviorProps>;
|
|
149
|
+
/**
|
|
150
|
+
* Props {@link TimeGridBehavior} serializes into the page, which is why they are a `type`:
|
|
151
|
+
* `SerializableProps` rejects an interface.
|
|
152
|
+
*/
|
|
153
|
+
export type TimeGridBehaviorProps = {
|
|
154
|
+
/** What a keyboard move announces. */
|
|
155
|
+
moved: string;
|
|
156
|
+
/** What a keyboard resize announces. */
|
|
157
|
+
resized: string;
|
|
158
|
+
};
|
|
159
|
+
/**
|
|
160
|
+
* Renders the grid: a header of day links over the all-day lane, then one scroller holding the
|
|
161
|
+
* hour labels and the day columns. Each event is placed from its minutes, side by side with
|
|
162
|
+
* those it overlaps; an editable one also takes a resize edge, and the forms `edit` names.
|
|
163
|
+
*
|
|
164
|
+
* @example
|
|
165
|
+
* <TimeGrid id="week" label="Week of November 16" days={days} zones={zones} labels={labels}
|
|
166
|
+
* events={[{ id: "e1", date: "2026-11-18", start: 540, end: 600, title: "Standup" }]} />
|
|
167
|
+
*/
|
|
168
|
+
export declare function TimeGrid(handle: Handle<TimeGrid.Props>): () => import("remix/component").RemixElement;
|