@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,212 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "remix/component/jsx-runtime";
|
|
2
|
+
import { BedDoubleIcon, CarIcon, PlaneIcon, StickyNoteIcon, TicketIcon } from "@sdxc/icons";
|
|
3
|
+
import { visuallyHidden } from "@sdxc/u/a11y";
|
|
4
|
+
import { bg, fg } from "@sdxc/u/color";
|
|
5
|
+
import { rounded } from "@sdxc/u/effects";
|
|
6
|
+
import { listStyle, pseudoContent, raw, mergeMix } from "@sdxc/u/general";
|
|
7
|
+
import { container, flex, gap, grid, inlineFlex, items, justify, relative, vstack, } from "@sdxc/u/layout";
|
|
8
|
+
import { at } from "@sdxc/u/responsive";
|
|
9
|
+
import { bs, is, m, minIs, p } from "@sdxc/u/size";
|
|
10
|
+
import { after, data, when } from "@sdxc/u/state";
|
|
11
|
+
import { leading, tabularNums, text, weight } from "@sdxc/u/typography";
|
|
12
|
+
import { readAmbientLevel, resolveHeadingLevel, TAG_BY_LEVEL, } from "../components/heading-scope.js";
|
|
13
|
+
/** Container the timeline names, so items lay out by the timeline's width. */
|
|
14
|
+
const CONTAINER_NAME = "ui-trip-timeline";
|
|
15
|
+
/** Timeline width from which an item's time takes a column before the rail. */
|
|
16
|
+
const TIME_COLUMN_WIDTH = "30rem";
|
|
17
|
+
/** The side of the round marker each item's icon sits in; the rail runs through its middle. */
|
|
18
|
+
const MARKER = "var(--ui-trip-timeline-marker, 2rem)";
|
|
19
|
+
/** Space between items, which the rail spans to reach the next marker. */
|
|
20
|
+
const ITEM_GAP = "1.25rem";
|
|
21
|
+
/** Heading level a day takes where nothing sets one. */
|
|
22
|
+
const DEFAULT_LEVEL = 3;
|
|
23
|
+
/**
|
|
24
|
+
* The glyph for an item of each kind.
|
|
25
|
+
*
|
|
26
|
+
* @param kind What the item is.
|
|
27
|
+
* @returns A 16px icon for the kind.
|
|
28
|
+
*/
|
|
29
|
+
function kindIcon(kind) {
|
|
30
|
+
if (kind === "flight")
|
|
31
|
+
return _jsx(PlaneIcon, { size: 16 });
|
|
32
|
+
if (kind === "stay")
|
|
33
|
+
return _jsx(BedDoubleIcon, { size: 16 });
|
|
34
|
+
if (kind === "car")
|
|
35
|
+
return _jsx(CarIcon, { size: 16 });
|
|
36
|
+
if (kind === "activity")
|
|
37
|
+
return _jsx(TicketIcon, { size: 16 });
|
|
38
|
+
return _jsx(StickyNoteIcon, { size: 16 });
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Renders the trip as an `<ol>` of days. Under 30rem each item's time sits over its title; wider,
|
|
42
|
+
* times take a column before the rail so a day reads down like a schedule.
|
|
43
|
+
*
|
|
44
|
+
* @param handle Runtime handle carrying the list's props and sharing kind words and level.
|
|
45
|
+
* @returns The render function producing the timeline's markup.
|
|
46
|
+
* @example
|
|
47
|
+
* <TripTimeline aria-label="Trip to Vellis" kindLabels={{ flight: "Flight", stay: "Stay" }}>
|
|
48
|
+
* <TripTimeline.Day heading="Fri 14 Mar" date="2026-03-14" detail="Day 1">
|
|
49
|
+
* <TripTimeline.Item kind="flight" time="08:40" title="LW 214 Merrow → Vellis" status={<Badge>Confirmed</Badge>} />
|
|
50
|
+
* <TripTimeline.Item kind="stay" time="15:00" title="Check in at Hotel Saltmarsh" />
|
|
51
|
+
* </TripTimeline.Day>
|
|
52
|
+
* </TripTimeline>
|
|
53
|
+
*/
|
|
54
|
+
export function TripTimeline(handle) {
|
|
55
|
+
return () => {
|
|
56
|
+
let { kindLabels, level, children, mix, ...rest } = handle.props;
|
|
57
|
+
handle.context.set({ kindLabels, level });
|
|
58
|
+
return (_jsx("ol", { "data-slot": "trip-timeline", ...rest, mix: mergeMix([
|
|
59
|
+
container(CONTAINER_NAME, "inline-size"),
|
|
60
|
+
m(0),
|
|
61
|
+
p(0),
|
|
62
|
+
listStyle("none"),
|
|
63
|
+
vstack({ gap: 6 }),
|
|
64
|
+
minIs(0),
|
|
65
|
+
text("sm"),
|
|
66
|
+
], mix), children: children }));
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Renders one day: a heading at the ambient level (its date in a `<time>`) with muted detail
|
|
71
|
+
* beside it, then the day's items in their own ordered list on one rail.
|
|
72
|
+
*
|
|
73
|
+
* @param handle Runtime handle carrying the day's props.
|
|
74
|
+
* @returns The render function producing the day's list item.
|
|
75
|
+
* @example
|
|
76
|
+
* <TripTimeline.Day heading="Sat 15 Mar" date="2026-03-15" detail="Day 2 · Vellis">…</TripTimeline.Day>
|
|
77
|
+
*/
|
|
78
|
+
TripTimeline.Day = function TripTimelineDay(handle) {
|
|
79
|
+
return () => {
|
|
80
|
+
let { heading, date, detail, children, mix, ...rest } = handle.props;
|
|
81
|
+
let { level } = handle.context.get(TripTimeline);
|
|
82
|
+
let Heading = TAG_BY_LEVEL[resolveHeadingLevel(handle, level ?? readAmbientLevel(handle) ?? DEFAULT_LEVEL)];
|
|
83
|
+
return (_jsxs("li", { "data-slot": "trip-timeline-day", ...rest, mix: mergeMix([vstack({ gap: 3 }), minIs(0)], mix), children: [_jsxs("div", { mix: [
|
|
84
|
+
flex(),
|
|
85
|
+
items("baseline"),
|
|
86
|
+
raw({ flexWrap: "wrap", columnGap: "0.5rem" }),
|
|
87
|
+
p(0),
|
|
88
|
+
raw({ paddingBlockEnd: "0.5rem" }),
|
|
89
|
+
raw({ borderBlockEnd: "1px solid var(--ui-neutral-border)" }),
|
|
90
|
+
], children: [_jsx(Heading, { "data-slot": "trip-timeline-day-heading", mix: [m(0), text("base"), weight("semibold"), fg("neutral.emphasis")], children: date === undefined ? heading : _jsx("time", { dateTime: date, children: heading }) }), detail === undefined ? null : (_jsx("span", { "data-slot": "trip-timeline-day-detail", mix: [text("xs"), fg("neutral.muted")], children: detail }))] }), _jsx("ol", { "data-slot": "trip-timeline-items", mix: [m(0), p(0), listStyle("none"), vstack({ gap: 0 }), raw({ rowGap: ITEM_GAP })], children: children })] }));
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* Renders one booked item: a round marker with the kind's icon on the rail, which runs on to the
|
|
95
|
+
* next item's marker, then the time, the title with its status, detail lines and actions. The
|
|
96
|
+
* marker takes the kind's tone, and the kind's words from `kindLabels` lead the title.
|
|
97
|
+
*
|
|
98
|
+
* @param handle Runtime handle carrying the item's props.
|
|
99
|
+
* @returns The render function producing the item's list item.
|
|
100
|
+
* @example
|
|
101
|
+
* <TripTimeline.Item kind="car" time="11:30" title="Pick up at Tallow Rent" details={["Terminal 1, level 0", "Ref. TR-58213"]}
|
|
102
|
+
* actions={<a href="/trip.ics">Add to calendar</a>} />
|
|
103
|
+
*/
|
|
104
|
+
TripTimeline.Item = function TripTimelineItem(handle) {
|
|
105
|
+
return () => {
|
|
106
|
+
let { kind, icon, time, dateTime, title, details, status, actions, children, mix, ...rest } = handle.props;
|
|
107
|
+
let { kindLabels } = handle.context.get(TripTimeline);
|
|
108
|
+
let kindLabel = kindLabels?.[kind];
|
|
109
|
+
return (_jsxs("li", { "data-slot": "trip-timeline-item", "data-kind": kind, ...rest, mix: mergeMix([
|
|
110
|
+
grid(),
|
|
111
|
+
raw({
|
|
112
|
+
gridTemplateColumns: `${MARKER} minmax(0, 1fr)`,
|
|
113
|
+
gridTemplateAreas: '"marker time" "marker body"',
|
|
114
|
+
columnGap: "0.75rem",
|
|
115
|
+
alignItems: "start",
|
|
116
|
+
}),
|
|
117
|
+
when("&:last-child > [data-slot=trip-timeline-marker]::after", raw({ display: "none" })),
|
|
118
|
+
when("&:not(:has([data-slot=trip-timeline-time]))", raw({ gridTemplateAreas: '"marker body"' })),
|
|
119
|
+
at(TIME_COLUMN_WIDTH, CONTAINER_NAME, raw({
|
|
120
|
+
gridTemplateColumns: `5.5rem ${MARKER} minmax(0, 1fr)`,
|
|
121
|
+
gridTemplateAreas: '"time marker body"',
|
|
122
|
+
})),
|
|
123
|
+
], mix), children: [_jsx("span", { "data-slot": "trip-timeline-marker", mix: [
|
|
124
|
+
relative(),
|
|
125
|
+
raw({ gridArea: "marker", alignSelf: "stretch" }),
|
|
126
|
+
after([
|
|
127
|
+
pseudoContent('""'),
|
|
128
|
+
raw({
|
|
129
|
+
position: "absolute",
|
|
130
|
+
insetBlockStart: `calc(${MARKER} + 0.25rem)`,
|
|
131
|
+
insetBlockEnd: `calc(-1 * ${ITEM_GAP} + 0.25rem)`,
|
|
132
|
+
insetInlineStart: "calc(50% - 1px)",
|
|
133
|
+
inlineSize: "2px",
|
|
134
|
+
borderRadius: "1px",
|
|
135
|
+
}),
|
|
136
|
+
bg("neutral.border"),
|
|
137
|
+
]),
|
|
138
|
+
], children: _jsx("span", { "data-slot": "trip-timeline-icon", "aria-hidden": "true", mix: [
|
|
139
|
+
inlineFlex(),
|
|
140
|
+
items("center"),
|
|
141
|
+
justify("center"),
|
|
142
|
+
is(MARKER),
|
|
143
|
+
bs(MARKER),
|
|
144
|
+
rounded("full"),
|
|
145
|
+
bg("neutral.tint"),
|
|
146
|
+
fg("neutral.muted"),
|
|
147
|
+
raw({ boxShadow: "inset 0 0 0 1px var(--ui-neutral-border)" }),
|
|
148
|
+
data("kind", "flight", [
|
|
149
|
+
bg("brand.tint"),
|
|
150
|
+
fg("brand"),
|
|
151
|
+
raw({ boxShadow: "inset 0 0 0 1px var(--ui-brand-border)" }),
|
|
152
|
+
]),
|
|
153
|
+
data("kind", "stay", [
|
|
154
|
+
bg("success.tint"),
|
|
155
|
+
fg("success"),
|
|
156
|
+
raw({ boxShadow: "inset 0 0 0 1px var(--ui-success-border)" }),
|
|
157
|
+
]),
|
|
158
|
+
data("kind", "car", [
|
|
159
|
+
bg("warning.tint"),
|
|
160
|
+
fg("warning.emphasis"),
|
|
161
|
+
raw({ boxShadow: "inset 0 0 0 1px var(--ui-warning-border)" }),
|
|
162
|
+
]),
|
|
163
|
+
data("kind", "activity", [
|
|
164
|
+
bg("danger.tint"),
|
|
165
|
+
fg("danger"),
|
|
166
|
+
raw({ boxShadow: "inset 0 0 0 1px var(--ui-danger-border)" }),
|
|
167
|
+
]),
|
|
168
|
+
when("& > svg", raw({ inlineSize: "1rem", blockSize: "1rem" })),
|
|
169
|
+
], "data-kind": kind, children: icon ?? kindIcon(kind) }) }), time === undefined ? null : (_jsx("span", { "data-slot": "trip-timeline-time", mix: [
|
|
170
|
+
raw({ gridArea: "time" }),
|
|
171
|
+
text("xs"),
|
|
172
|
+
weight("medium"),
|
|
173
|
+
fg("neutral.muted"),
|
|
174
|
+
tabularNums(),
|
|
175
|
+
at(TIME_COLUMN_WIDTH, CONTAINER_NAME, [
|
|
176
|
+
text("sm"),
|
|
177
|
+
raw({ textAlign: "end", lineHeight: MARKER }),
|
|
178
|
+
]),
|
|
179
|
+
], children: dateTime === undefined ? time : _jsx("time", { dateTime: dateTime, children: time }) })), _jsxs("div", { "data-slot": "trip-timeline-body", mix: [
|
|
180
|
+
raw({ gridArea: "body" }),
|
|
181
|
+
vstack({ gap: 1.5 }),
|
|
182
|
+
minIs(0),
|
|
183
|
+
at(TIME_COLUMN_WIDTH, CONTAINER_NAME, raw({ paddingBlockStart: "0.3125rem" })),
|
|
184
|
+
], children: [_jsxs("div", { mix: [
|
|
185
|
+
flex(),
|
|
186
|
+
items("start"),
|
|
187
|
+
raw({ flexWrap: "wrap", justifyContent: "space-between" }),
|
|
188
|
+
gap(2),
|
|
189
|
+
], children: [_jsxs("p", { "data-slot": "trip-timeline-title", mix: [
|
|
190
|
+
m(0),
|
|
191
|
+
minIs(0),
|
|
192
|
+
weight("semibold"),
|
|
193
|
+
leading(1.35),
|
|
194
|
+
fg("neutral.emphasis"),
|
|
195
|
+
raw({ flex: "1 1 12rem" }),
|
|
196
|
+
], children: [kindLabel === undefined ? null : (_jsx("span", { mix: [visuallyHidden()], children: `${kindLabel}: ` })), title] }), status === undefined ? null : (_jsx("span", { "data-slot": "trip-timeline-status", mix: [inlineFlex(), raw({ flexShrink: 0 })], children: status }))] }), details === undefined || details.length === 0 ? null : (_jsx("ul", { "data-slot": "trip-timeline-details", mix: [
|
|
197
|
+
m(0),
|
|
198
|
+
p(0),
|
|
199
|
+
listStyle("none"),
|
|
200
|
+
vstack({ gap: 0.5 }),
|
|
201
|
+
text("xs"),
|
|
202
|
+
fg("neutral.muted"),
|
|
203
|
+
leading(1.45),
|
|
204
|
+
], children: details.map((line) => (_jsx("li", { mix: [raw({ overflowWrap: "anywhere" })], children: line }))) })), children, actions === undefined ? null : (_jsx("div", { "data-slot": "trip-timeline-actions", mix: [
|
|
205
|
+
flex(),
|
|
206
|
+
raw({ flexWrap: "wrap" }),
|
|
207
|
+
gap(3),
|
|
208
|
+
text("xs"),
|
|
209
|
+
raw({ marginBlockStart: "0.25rem" }),
|
|
210
|
+
], children: actions }))] })] }));
|
|
211
|
+
};
|
|
212
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reads a gamepad's buttons as presses: polled once per frame, a held button would act on every
|
|
3
|
+
* frame, so comparing two polls reports each button once, on the frame it goes down, the way a
|
|
4
|
+
* key press reports once.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* The buttons pressed since the previous poll.
|
|
11
|
+
*
|
|
12
|
+
* @param previous - Which buttons were down at the previous poll, by index; empty on the first.
|
|
13
|
+
* @param current - Which buttons are down now, by index.
|
|
14
|
+
* @returns The index of every button that went down, ascending; with the browser's standard
|
|
15
|
+
* mapping, `0` is the bottom face button and `12`–`15` the D-pad (up, down, left, right).
|
|
16
|
+
* @example
|
|
17
|
+
* let down = pad.buttons.map((button) => button.pressed);
|
|
18
|
+
* for (let index of gamepadPresses(last, down)) act(index);
|
|
19
|
+
* last = down;
|
|
20
|
+
*/
|
|
21
|
+
export declare function gamepadPresses(previous: readonly boolean[], current: readonly boolean[]): number[];
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reads a gamepad's buttons as presses: polled once per frame, a held button would act on every
|
|
3
|
+
* frame, so comparing two polls reports each button once, on the frame it goes down, the way a
|
|
4
|
+
* key press reports once.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* The buttons pressed since the previous poll.
|
|
11
|
+
*
|
|
12
|
+
* @param previous - Which buttons were down at the previous poll, by index; empty on the first.
|
|
13
|
+
* @param current - Which buttons are down now, by index.
|
|
14
|
+
* @returns The index of every button that went down, ascending; with the browser's standard
|
|
15
|
+
* mapping, `0` is the bottom face button and `12`–`15` the D-pad (up, down, left, right).
|
|
16
|
+
* @example
|
|
17
|
+
* let down = pad.buttons.map((button) => button.pressed);
|
|
18
|
+
* for (let index of gamepadPresses(last, down)) act(index);
|
|
19
|
+
* last = down;
|
|
20
|
+
*/
|
|
21
|
+
export function gamepadPresses(previous, current) {
|
|
22
|
+
let pressed = [];
|
|
23
|
+
for (let index = 0; index < current.length; index++) {
|
|
24
|
+
if (current[index] === true && previous[index] !== true)
|
|
25
|
+
pressed.push(index);
|
|
26
|
+
}
|
|
27
|
+
return pressed;
|
|
28
|
+
}
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ export * from "./eyebrow.js";
|
|
|
17
17
|
export * from "./field-parts.js";
|
|
18
18
|
export * from "./file-icon.js";
|
|
19
19
|
export * from "./full-turn-radians.js";
|
|
20
|
+
export * from "./gamepad-presses.js";
|
|
20
21
|
export * from "./geometry.js";
|
|
21
22
|
export * from "./glyph-edges.js";
|
|
22
23
|
export * from "./has-accessible-text.js";
|
|
@@ -25,13 +26,17 @@ export * from "./key-combo.js";
|
|
|
25
26
|
export * from "./keyboard-nav.js";
|
|
26
27
|
export * from "./link-prefetch.js";
|
|
27
28
|
export * from "./merge-style.js";
|
|
29
|
+
export * from "./move-focus.js";
|
|
28
30
|
export * from "./paired-range-inputs.js";
|
|
29
31
|
export * from "./placement.js";
|
|
30
32
|
export * from "./prefers-reduced-motion.js";
|
|
33
|
+
export * from "./range-months.js";
|
|
31
34
|
export * from "./resolve-field-wiring.js";
|
|
32
35
|
export * from "./resolve-fill-percent.js";
|
|
33
36
|
export * from "./round-precision.js";
|
|
34
37
|
export * from "./semantic-color.js";
|
|
38
|
+
export * from "./swipe-direction.js";
|
|
39
|
+
export * from "./typewriter.js";
|
|
35
40
|
export * from "./warn-if-no-accessible-name.js";
|
|
36
41
|
export * from "./write-cookie.js";
|
|
37
42
|
export * from "./relative-time.js";
|
package/dist/utils/index.js
CHANGED
|
@@ -17,6 +17,7 @@ export * from "./eyebrow.js";
|
|
|
17
17
|
export * from "./field-parts.js";
|
|
18
18
|
export * from "./file-icon.js";
|
|
19
19
|
export * from "./full-turn-radians.js";
|
|
20
|
+
export * from "./gamepad-presses.js";
|
|
20
21
|
export * from "./geometry.js";
|
|
21
22
|
export * from "./glyph-edges.js";
|
|
22
23
|
export * from "./has-accessible-text.js";
|
|
@@ -25,13 +26,17 @@ export * from "./key-combo.js";
|
|
|
25
26
|
export * from "./keyboard-nav.js";
|
|
26
27
|
export * from "./link-prefetch.js";
|
|
27
28
|
export * from "./merge-style.js";
|
|
29
|
+
export * from "./move-focus.js";
|
|
28
30
|
export * from "./paired-range-inputs.js";
|
|
29
31
|
export * from "./placement.js";
|
|
30
32
|
export * from "./prefers-reduced-motion.js";
|
|
33
|
+
export * from "./range-months.js";
|
|
31
34
|
export * from "./resolve-field-wiring.js";
|
|
32
35
|
export * from "./resolve-fill-percent.js";
|
|
33
36
|
export * from "./round-precision.js";
|
|
34
37
|
export * from "./semantic-color.js";
|
|
38
|
+
export * from "./swipe-direction.js";
|
|
39
|
+
export * from "./typewriter.js";
|
|
35
40
|
export * from "./warn-if-no-accessible-name.js";
|
|
36
41
|
export * from "./write-cookie.js";
|
|
37
42
|
export * from "./relative-time.js";
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Moves focus one control forward or back inside a container, wrapping at either end, for input
|
|
3
|
+
* that has no Tab key: a gamepad's D-pad, a TV remote, a pair of arrow buttons. Only controls
|
|
4
|
+
* a person can see and use take part, so a hidden or disabled one is passed over.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
/** Controls {@link moveFocus} visits, in document order. */
|
|
10
|
+
export declare const MOVE_FOCUS_SELECTOR = "button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), a[href], [tabindex]:not([tabindex=\"-1\"])";
|
|
11
|
+
/**
|
|
12
|
+
* Focuses the next or previous visible control inside `root`, wrapping around. With focus
|
|
13
|
+
* outside `root`, the first control takes it whichever way `step` points.
|
|
14
|
+
*
|
|
15
|
+
* @param root - The container to move through, such as a page region or an open dialog.
|
|
16
|
+
* @param step - `1` for the next control, `-1` for the previous one.
|
|
17
|
+
* @returns The control that took focus, or `null` when `root` has none.
|
|
18
|
+
* @example moveFocus(dialog ?? main, button === 13 ? 1 : -1);
|
|
19
|
+
*/
|
|
20
|
+
export declare function moveFocus(root: Element, step: 1 | -1): HTMLElement | null;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Moves focus one control forward or back inside a container, wrapping at either end, for input
|
|
3
|
+
* that has no Tab key: a gamepad's D-pad, a TV remote, a pair of arrow buttons. Only controls
|
|
4
|
+
* a person can see and use take part, so a hidden or disabled one is passed over.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
/** Controls {@link moveFocus} visits, in document order. */
|
|
10
|
+
export const MOVE_FOCUS_SELECTOR = 'button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), a[href], [tabindex]:not([tabindex="-1"])';
|
|
11
|
+
/**
|
|
12
|
+
* Focuses the next or previous visible control inside `root`, wrapping around. With focus
|
|
13
|
+
* outside `root`, the first control takes it whichever way `step` points.
|
|
14
|
+
*
|
|
15
|
+
* @param root - The container to move through, such as a page region or an open dialog.
|
|
16
|
+
* @param step - `1` for the next control, `-1` for the previous one.
|
|
17
|
+
* @returns The control that took focus, or `null` when `root` has none.
|
|
18
|
+
* @example moveFocus(dialog ?? main, button === 13 ? 1 : -1);
|
|
19
|
+
*/
|
|
20
|
+
export function moveFocus(root, step) {
|
|
21
|
+
let controls = [...root.querySelectorAll(MOVE_FOCUS_SELECTOR)].filter((control) => control.getClientRects().length > 0);
|
|
22
|
+
if (controls.length === 0)
|
|
23
|
+
return null;
|
|
24
|
+
let index = controls.indexOf(document.activeElement);
|
|
25
|
+
let next = index === -1 ? controls[0] : controls[(index + step + controls.length) % controls.length];
|
|
26
|
+
next?.focus();
|
|
27
|
+
return next ?? null;
|
|
28
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Day-key arithmetic and selection rules behind a link-driven range calendar. Every day is a
|
|
3
|
+
* `YYYY-MM-DD` string counted in UTC, so the server and the browser lay out identical weeks and
|
|
4
|
+
* two keys compare in date order as plain strings.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
/** The selection a calendar draws: its two ends, `YYYY-MM-DD`, and whether it picks one day. */
|
|
10
|
+
export interface DaySelection {
|
|
11
|
+
start?: string;
|
|
12
|
+
end?: string;
|
|
13
|
+
single: boolean;
|
|
14
|
+
}
|
|
15
|
+
/** Where a day sits in a drawn selection. */
|
|
16
|
+
export type RangePosition = "start" | "middle" | "end" | "only";
|
|
17
|
+
/**
|
|
18
|
+
* The selection a click on `date` makes: single mode picks the day; otherwise a missing start
|
|
19
|
+
* or a finished range restarts at the day, and a pending start takes a later day as its end and
|
|
20
|
+
* an earlier or equal one as its replacement.
|
|
21
|
+
*
|
|
22
|
+
* @example nextSelection("2026-03-14", { start: "2026-03-10", single: false }); // { start: "2026-03-10", end: "2026-03-14" }
|
|
23
|
+
*/
|
|
24
|
+
export declare function nextSelection(date: string, selection: DaySelection): {
|
|
25
|
+
start: string;
|
|
26
|
+
end?: string;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Where `date` sits in a selection: `"only"` for a lone picked day or a start still waiting for
|
|
30
|
+
* its end, `"start"`/`"middle"`/`"end"` along a finished range, `undefined` outside it.
|
|
31
|
+
*/
|
|
32
|
+
export declare function rangePosition(date: string, selection: DaySelection): RangePosition | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* The first day after `start`, up to `last`, that `isUnavailable` reports: a pending range ends
|
|
35
|
+
* before it, so no range spans a day already taken.
|
|
36
|
+
*
|
|
37
|
+
* @returns The blocking day, or `undefined` when every day through `last` is free.
|
|
38
|
+
*/
|
|
39
|
+
export declare function firstUnavailableAfter(start: string, last: string, isUnavailable: ((date: string) => boolean) | undefined): string | undefined;
|
|
40
|
+
/** Midnight UTC of a `YYYY-MM-DD` day, or of the first day of a `YYYY-MM` month. */
|
|
41
|
+
export declare function dayTime(date: string): number;
|
|
42
|
+
/** Formats a UTC instant as its `YYYY-MM-DD` day. */
|
|
43
|
+
export declare function toDayKey(time: number): string;
|
|
44
|
+
/** The day `count` days after a `YYYY-MM-DD` day, counted in UTC so no offset shifts it. */
|
|
45
|
+
export declare function addDays(date: string, count: number): string;
|
|
46
|
+
/** The `YYYY-MM` month `delta` months after `month`, rolling over year ends. */
|
|
47
|
+
export declare function shiftMonth(month: string, delta: number): string;
|
|
48
|
+
/** The UTC instant of the `index`th weekday column of a week opening on `weekStartsOn`. */
|
|
49
|
+
export declare function weekdayTime(weekStartsOn: number, index: number): number;
|
|
50
|
+
/**
|
|
51
|
+
* The weeks of a `YYYY-MM` month, each seven entries long from `weekStartsOn` (0 is Sunday): a
|
|
52
|
+
* day key for each day of the month and `null` for the columns that belong to its neighbours.
|
|
53
|
+
*/
|
|
54
|
+
export declare function monthWeeks(month: string, weekStartsOn: number): Array<Array<string | null>>;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Day-key arithmetic and selection rules behind a link-driven range calendar. Every day is a
|
|
3
|
+
* `YYYY-MM-DD` string counted in UTC, so the server and the browser lay out identical weeks and
|
|
4
|
+
* two keys compare in date order as plain strings.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
/** Milliseconds in one UTC day, the step every day key advances by. */
|
|
10
|
+
const DAY_MS = 86_400_000;
|
|
11
|
+
/** A Sunday, the reference week weekday names are formatted from. */
|
|
12
|
+
const REFERENCE_SUNDAY = Date.UTC(2023, 0, 1);
|
|
13
|
+
/**
|
|
14
|
+
* The selection a click on `date` makes: single mode picks the day; otherwise a missing start
|
|
15
|
+
* or a finished range restarts at the day, and a pending start takes a later day as its end and
|
|
16
|
+
* an earlier or equal one as its replacement.
|
|
17
|
+
*
|
|
18
|
+
* @example nextSelection("2026-03-14", { start: "2026-03-10", single: false }); // { start: "2026-03-10", end: "2026-03-14" }
|
|
19
|
+
*/
|
|
20
|
+
export function nextSelection(date, selection) {
|
|
21
|
+
let { start, end, single } = selection;
|
|
22
|
+
if (single || start === undefined || end !== undefined || date <= start)
|
|
23
|
+
return { start: date };
|
|
24
|
+
return { start, end: date };
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Where `date` sits in a selection: `"only"` for a lone picked day or a start still waiting for
|
|
28
|
+
* its end, `"start"`/`"middle"`/`"end"` along a finished range, `undefined` outside it.
|
|
29
|
+
*/
|
|
30
|
+
export function rangePosition(date, selection) {
|
|
31
|
+
let { start, single } = selection;
|
|
32
|
+
let end = single ? undefined : selection.end;
|
|
33
|
+
if (start === undefined)
|
|
34
|
+
return undefined;
|
|
35
|
+
if (end === undefined || start === end)
|
|
36
|
+
return date === start ? "only" : undefined;
|
|
37
|
+
if (date === start)
|
|
38
|
+
return "start";
|
|
39
|
+
if (date === end)
|
|
40
|
+
return "end";
|
|
41
|
+
if (date > start && date < end)
|
|
42
|
+
return "middle";
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* The first day after `start`, up to `last`, that `isUnavailable` reports: a pending range ends
|
|
47
|
+
* before it, so no range spans a day already taken.
|
|
48
|
+
*
|
|
49
|
+
* @returns The blocking day, or `undefined` when every day through `last` is free.
|
|
50
|
+
*/
|
|
51
|
+
export function firstUnavailableAfter(start, last, isUnavailable) {
|
|
52
|
+
if (isUnavailable === undefined)
|
|
53
|
+
return undefined;
|
|
54
|
+
for (let date = addDays(start, 1); date <= last; date = addDays(date, 1)) {
|
|
55
|
+
if (isUnavailable(date))
|
|
56
|
+
return date;
|
|
57
|
+
}
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
60
|
+
/** Midnight UTC of a `YYYY-MM-DD` day, or of the first day of a `YYYY-MM` month. */
|
|
61
|
+
export function dayTime(date) {
|
|
62
|
+
let day = date.length > 7 ? Number(date.slice(8, 10)) : 1;
|
|
63
|
+
return Date.UTC(Number(date.slice(0, 4)), Number(date.slice(5, 7)) - 1, day);
|
|
64
|
+
}
|
|
65
|
+
/** Formats a UTC instant as its `YYYY-MM-DD` day. */
|
|
66
|
+
export function toDayKey(time) {
|
|
67
|
+
return new Date(time).toISOString().slice(0, 10);
|
|
68
|
+
}
|
|
69
|
+
/** The day `count` days after a `YYYY-MM-DD` day, counted in UTC so no offset shifts it. */
|
|
70
|
+
export function addDays(date, count) {
|
|
71
|
+
return toDayKey(dayTime(date) + count * DAY_MS);
|
|
72
|
+
}
|
|
73
|
+
/** The `YYYY-MM` month `delta` months after `month`, rolling over year ends. */
|
|
74
|
+
export function shiftMonth(month, delta) {
|
|
75
|
+
return toDayKey(Date.UTC(Number(month.slice(0, 4)), Number(month.slice(5, 7)) - 1 + delta, 1)).slice(0, 7);
|
|
76
|
+
}
|
|
77
|
+
/** The UTC instant of the `index`th weekday column of a week opening on `weekStartsOn`. */
|
|
78
|
+
export function weekdayTime(weekStartsOn, index) {
|
|
79
|
+
return REFERENCE_SUNDAY + ((((weekStartsOn + index) % 7) + 7) % 7) * DAY_MS;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* The weeks of a `YYYY-MM` month, each seven entries long from `weekStartsOn` (0 is Sunday): a
|
|
83
|
+
* day key for each day of the month and `null` for the columns that belong to its neighbours.
|
|
84
|
+
*/
|
|
85
|
+
export function monthWeeks(month, weekStartsOn) {
|
|
86
|
+
let first = dayTime(month);
|
|
87
|
+
let offset = (((new Date(first).getUTCDay() - weekStartsOn) % 7) + 7) % 7;
|
|
88
|
+
let length = new Date(Date.UTC(Number(month.slice(0, 4)), Number(month.slice(5, 7)), 0)).getUTCDate();
|
|
89
|
+
let cells = Array.from({ length: offset }, () => null);
|
|
90
|
+
for (let day = 0; day < length; day++)
|
|
91
|
+
cells.push(toDayKey(first + day * DAY_MS));
|
|
92
|
+
while (cells.length % 7 !== 0)
|
|
93
|
+
cells.push(null);
|
|
94
|
+
let weeks = [];
|
|
95
|
+
for (let index = 0; index < cells.length; index += 7)
|
|
96
|
+
weeks.push(cells.slice(index, index + 7));
|
|
97
|
+
return weeks;
|
|
98
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reads a pointer's travel between `pointerdown` and `pointerup` as a swipe or a tap, so one
|
|
3
|
+
* surface can take both: a carousel advancing on a swipe, a reader paging on one, while a tap
|
|
4
|
+
* still clicks through.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
/** Pixels a pointer travels before a press counts as a swipe; shorter travel is a tap. */
|
|
10
|
+
export declare const SWIPE_DISTANCE = 48;
|
|
11
|
+
/** Where a swipe went, along its main axis. */
|
|
12
|
+
export type SwipeDirection = "up" | "down" | "left" | "right";
|
|
13
|
+
/**
|
|
14
|
+
* The direction of a swipe, taken from whichever axis travelled further; a tie reads as
|
|
15
|
+
* vertical.
|
|
16
|
+
*
|
|
17
|
+
* @param dx - Horizontal travel in pixels, positive to the right.
|
|
18
|
+
* @param dy - Vertical travel in pixels, positive downward.
|
|
19
|
+
* @param threshold - Travel below which the press is a tap.
|
|
20
|
+
* @returns The swipe's direction, or `null` for a tap.
|
|
21
|
+
* @example swipeDirection(event.clientX - start.x, event.clientY - start.y); // "down"
|
|
22
|
+
*/
|
|
23
|
+
export declare function swipeDirection(dx: number, dy: number, threshold?: number): SwipeDirection | null;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reads a pointer's travel between `pointerdown` and `pointerup` as a swipe or a tap, so one
|
|
3
|
+
* surface can take both: a carousel advancing on a swipe, a reader paging on one, while a tap
|
|
4
|
+
* still clicks through.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
/** Pixels a pointer travels before a press counts as a swipe; shorter travel is a tap. */
|
|
10
|
+
export const SWIPE_DISTANCE = 48;
|
|
11
|
+
/**
|
|
12
|
+
* The direction of a swipe, taken from whichever axis travelled further; a tie reads as
|
|
13
|
+
* vertical.
|
|
14
|
+
*
|
|
15
|
+
* @param dx - Horizontal travel in pixels, positive to the right.
|
|
16
|
+
* @param dy - Vertical travel in pixels, positive downward.
|
|
17
|
+
* @param threshold - Travel below which the press is a tap.
|
|
18
|
+
* @returns The swipe's direction, or `null` for a tap.
|
|
19
|
+
* @example swipeDirection(event.clientX - start.x, event.clientY - start.y); // "down"
|
|
20
|
+
*/
|
|
21
|
+
export function swipeDirection(dx, dy, threshold = SWIPE_DISTANCE) {
|
|
22
|
+
if (Math.max(Math.abs(dx), Math.abs(dy)) < threshold)
|
|
23
|
+
return null;
|
|
24
|
+
if (Math.abs(dy) >= Math.abs(dx))
|
|
25
|
+
return dy > 0 ? "down" : "up";
|
|
26
|
+
return dx > 0 ? "right" : "left";
|
|
27
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reveals rendered text character by character without touching its DOM: the unrevealed rest
|
|
3
|
+
* is a range in the `ui-typewriter` CSS highlight, which `typewriterText()` paints transparent,
|
|
4
|
+
* so the text keeps its final layout and a screen reader gets all of it at once.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
/** The CSS highlight holding every typewriter's unrevealed text. */
|
|
10
|
+
export declare const TYPEWRITER_HIGHLIGHT = "ui-typewriter";
|
|
11
|
+
/** Marks an element where typing holds; its value is the hold in milliseconds. */
|
|
12
|
+
export declare const TYPEWRITER_PAUSE_ATTRIBUTE = "data-typewriter-pause";
|
|
13
|
+
/** Multiplies the typing speed of the text inside an element; `0.5` types at half speed. */
|
|
14
|
+
export declare const TYPEWRITER_SPEED_ATTRIBUTE = "data-typewriter-speed";
|
|
15
|
+
/**
|
|
16
|
+
* Types out the text of one element. Construct it once the element is in the document, which
|
|
17
|
+
* hides the text, call `start()` to type, and `dispose()` when the element leaves. Paint the
|
|
18
|
+
* host with `typewriterText()` from `@sdxc/ui/styles` so the hidden text stays invisible.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* let writer = new Typewriter(paragraph);
|
|
22
|
+
* writer.start(40);
|
|
23
|
+
* await writer.done;
|
|
24
|
+
*/
|
|
25
|
+
export declare class Typewriter {
|
|
26
|
+
#private;
|
|
27
|
+
/** Settles once the whole text is visible, typed out or finished early. */
|
|
28
|
+
readonly done: Promise<void>;
|
|
29
|
+
/**
|
|
30
|
+
* Hides the whole text, ready to type.
|
|
31
|
+
*
|
|
32
|
+
* @param root - The element whose text is typed.
|
|
33
|
+
*/
|
|
34
|
+
constructor(root: Element);
|
|
35
|
+
/** How many characters are visible. */
|
|
36
|
+
get shown(): number;
|
|
37
|
+
/** True once the text is fully visible. */
|
|
38
|
+
get finished(): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Starts typing.
|
|
41
|
+
*
|
|
42
|
+
* @param charactersPerSecond - The base typing speed; `0` or less shows the text at once.
|
|
43
|
+
*/
|
|
44
|
+
start(charactersPerSecond: number): void;
|
|
45
|
+
/** Shows the rest of the text at once, as a click during typing usually asks. */
|
|
46
|
+
finish(): void;
|
|
47
|
+
/** Stops typing and releases the highlight range, leaving `done` unsettled. */
|
|
48
|
+
dispose(): void;
|
|
49
|
+
}
|