@sdxc/ui 2026.11.18 → 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.
Files changed (233) hide show
  1. package/README.md +133 -1
  2. package/dist/app/index.d.ts +1 -0
  3. package/dist/app/index.js +1 -0
  4. package/dist/app/mixins/command-palette.js +10 -2
  5. package/dist/app/mixins/log-viewer.js +17 -14
  6. package/dist/app/mixins/route-dialog.d.ts +17 -0
  7. package/dist/app/mixins/route-dialog.js +53 -0
  8. package/dist/app/optimistic-toggle.js +6 -0
  9. package/dist/app/route-dialog.d.ts +38 -0
  10. package/dist/app/route-dialog.js +49 -0
  11. package/dist/audio/equalizer.d.ts +24 -0
  12. package/dist/audio/equalizer.js +57 -0
  13. package/dist/audio/index.d.ts +16 -0
  14. package/dist/audio/index.js +16 -0
  15. package/dist/audio/media-tile.d.ts +38 -0
  16. package/dist/audio/media-tile.js +98 -0
  17. package/dist/audio/player-bar.d.ts +108 -0
  18. package/dist/audio/player-bar.js +338 -0
  19. package/dist/audio/queue-list.d.ts +56 -0
  20. package/dist/audio/queue-list.js +102 -0
  21. package/dist/audio/track-list.d.ts +91 -0
  22. package/dist/audio/track-list.js +226 -0
  23. package/dist/audio/utils/media-session.d.ts +44 -0
  24. package/dist/audio/utils/media-session.js +87 -0
  25. package/dist/audio/utils/play-queue.d.ts +98 -0
  26. package/dist/audio/utils/play-queue.js +149 -0
  27. package/dist/audio/utils/track-time.d.ts +28 -0
  28. package/dist/audio/utils/track-time.js +36 -0
  29. package/dist/chat/composer-format.d.ts +35 -0
  30. package/dist/chat/composer-format.js +84 -0
  31. package/dist/chat/index.d.ts +6 -0
  32. package/dist/chat/index.js +6 -0
  33. package/dist/chat/mention-menu.d.ts +43 -0
  34. package/dist/chat/mention-menu.js +70 -0
  35. package/dist/chat/message-group.d.ts +92 -0
  36. package/dist/chat/message-group.js +222 -0
  37. package/dist/chat/mixins/composer-format.d.ts +28 -0
  38. package/dist/chat/mixins/composer-format.js +80 -0
  39. package/dist/chat/mixins/composer-send.d.ts +2 -2
  40. package/dist/chat/mixins/composer-send.js +4 -2
  41. package/dist/chat/mixins/mention-menu.d.ts +41 -0
  42. package/dist/chat/mixins/mention-menu.js +213 -0
  43. package/dist/chat/mixins/reaction-sync.d.ts +47 -0
  44. package/dist/chat/mixins/reaction-sync.js +172 -0
  45. package/dist/chat/reaction-bar.d.ts +70 -0
  46. package/dist/chat/reaction-bar.js +108 -0
  47. package/dist/chat/typing-indicator.d.ts +42 -0
  48. package/dist/chat/typing-indicator.js +68 -0
  49. package/dist/chat/utils/composer-text.d.ts +38 -0
  50. package/dist/chat/utils/composer-text.js +86 -0
  51. package/dist/chat/utils/markdown-format.d.ts +30 -0
  52. package/dist/chat/utils/markdown-format.js +158 -0
  53. package/dist/chat/utils/mention-query.d.ts +55 -0
  54. package/dist/chat/utils/mention-query.js +60 -0
  55. package/dist/commerce/cart-drawer.d.ts +69 -0
  56. package/dist/commerce/cart-drawer.js +163 -0
  57. package/dist/commerce/cart-line.d.ts +32 -0
  58. package/dist/commerce/cart-line.js +43 -0
  59. package/dist/commerce/checkout-layout.d.ts +32 -0
  60. package/dist/commerce/checkout-layout.js +51 -0
  61. package/dist/commerce/facet-filters.d.ts +121 -0
  62. package/dist/commerce/facet-filters.js +318 -0
  63. package/dist/commerce/fulfilment-note.d.ts +28 -0
  64. package/dist/commerce/fulfilment-note.js +26 -0
  65. package/dist/commerce/index.d.ts +27 -0
  66. package/dist/commerce/index.js +27 -0
  67. package/dist/commerce/item-options-dialog.d.ts +67 -0
  68. package/dist/commerce/item-options-dialog.js +150 -0
  69. package/dist/commerce/menu-item-card.d.ts +37 -0
  70. package/dist/commerce/menu-item-card.js +96 -0
  71. package/dist/commerce/option-group.d.ts +62 -0
  72. package/dist/commerce/option-group.js +121 -0
  73. package/dist/commerce/order-summary.d.ts +42 -0
  74. package/dist/commerce/order-summary.js +76 -0
  75. package/dist/commerce/order-tracker.d.ts +80 -0
  76. package/dist/commerce/order-tracker.js +178 -0
  77. package/dist/commerce/price.d.ts +52 -0
  78. package/dist/commerce/price.js +108 -0
  79. package/dist/commerce/product-card.d.ts +53 -0
  80. package/dist/commerce/product-card.js +127 -0
  81. package/dist/commerce/product-gallery.d.ts +70 -0
  82. package/dist/commerce/product-gallery.js +186 -0
  83. package/dist/commerce/promo-code.d.ts +56 -0
  84. package/dist/commerce/promo-code.js +101 -0
  85. package/dist/commerce/quantity-stepper.d.ts +42 -0
  86. package/dist/commerce/quantity-stepper.js +53 -0
  87. package/dist/commerce/question-list.d.ts +53 -0
  88. package/dist/commerce/question-list.js +92 -0
  89. package/dist/commerce/shipping-estimate.d.ts +53 -0
  90. package/dist/commerce/shipping-estimate.js +39 -0
  91. package/dist/commerce/sort-select.d.ts +38 -0
  92. package/dist/commerce/sort-select.js +38 -0
  93. package/dist/commerce/variant-picker.d.ts +75 -0
  94. package/dist/commerce/variant-picker.js +135 -0
  95. package/dist/components/amount.d.ts +46 -0
  96. package/dist/components/amount.js +34 -0
  97. package/dist/components/autocomplete.d.ts +82 -0
  98. package/dist/components/autocomplete.js +114 -0
  99. package/dist/components/carousel.d.ts +31 -1
  100. package/dist/components/carousel.js +66 -3
  101. package/dist/components/index.d.ts +11 -0
  102. package/dist/components/index.js +11 -0
  103. package/dist/components/letterbox.d.ts +47 -0
  104. package/dist/components/letterbox.js +56 -0
  105. package/dist/components/lightbox.d.ts +88 -0
  106. package/dist/components/lightbox.js +224 -0
  107. package/dist/components/media-grid.d.ts +53 -0
  108. package/dist/components/media-grid.js +89 -0
  109. package/dist/components/range-months.d.ts +100 -0
  110. package/dist/components/range-months.js +274 -0
  111. package/dist/components/rating-input.d.ts +33 -0
  112. package/dist/components/rating-input.js +63 -0
  113. package/dist/components/rating.d.ts +38 -0
  114. package/dist/components/rating.js +66 -0
  115. package/dist/components/review-card.d.ts +39 -0
  116. package/dist/components/review-card.js +59 -0
  117. package/dist/components/section-bar.d.ts +57 -0
  118. package/dist/components/section-bar.js +140 -0
  119. package/dist/components/step-indicator.d.ts +46 -0
  120. package/dist/components/step-indicator.js +96 -0
  121. package/dist/finance/index.d.ts +10 -0
  122. package/dist/finance/index.js +10 -0
  123. package/dist/finance/ledger.d.ts +60 -0
  124. package/dist/finance/ledger.js +93 -0
  125. package/dist/finance/payment-card.d.ts +49 -0
  126. package/dist/finance/payment-card.js +115 -0
  127. package/dist/map/engine.d.ts +49 -0
  128. package/dist/map/engine.js +591 -0
  129. package/dist/map/index.d.ts +12 -0
  130. package/dist/map/index.js +12 -0
  131. package/dist/map/map-canvas.d.ts +101 -0
  132. package/dist/map/map-canvas.js +275 -0
  133. package/dist/map/map.d.ts +217 -0
  134. package/dist/map/map.js +598 -0
  135. package/dist/map/mixins/map-link.d.ts +30 -0
  136. package/dist/map/mixins/map-link.js +116 -0
  137. package/dist/map/utils/basemap.d.ts +88 -0
  138. package/dist/map/utils/basemap.js +84 -0
  139. package/dist/map/utils/cluster.d.ts +43 -0
  140. package/dist/map/utils/cluster.js +80 -0
  141. package/dist/map/utils/mercator.d.ts +66 -0
  142. package/dist/map/utils/mercator.js +92 -0
  143. package/dist/map/utils/stage.d.ts +24 -0
  144. package/dist/map/utils/stage.js +49 -0
  145. package/dist/mixins/autocomplete.d.ts +28 -0
  146. package/dist/mixins/autocomplete.js +283 -0
  147. package/dist/mixins/carousel-controls.d.ts +14 -3
  148. package/dist/mixins/carousel-controls.js +89 -30
  149. package/dist/mixins/index.d.ts +2 -0
  150. package/dist/mixins/index.js +2 -0
  151. package/dist/mixins/lightbox-controls.d.ts +34 -0
  152. package/dist/mixins/lightbox-controls.js +176 -0
  153. package/dist/schedule/agenda.d.ts +63 -0
  154. package/dist/schedule/agenda.js +221 -0
  155. package/dist/schedule/day-strip.d.ts +50 -0
  156. package/dist/schedule/day-strip.js +136 -0
  157. package/dist/schedule/free-busy.d.ts +96 -0
  158. package/dist/schedule/free-busy.js +285 -0
  159. package/dist/schedule/index.d.ts +15 -0
  160. package/dist/schedule/index.js +15 -0
  161. package/dist/schedule/mixins/day-strip-scroll.d.ts +16 -0
  162. package/dist/schedule/mixins/day-strip-scroll.js +40 -0
  163. package/dist/schedule/mixins/time-grid-drag.d.ts +24 -0
  164. package/dist/schedule/mixins/time-grid-drag.js +532 -0
  165. package/dist/schedule/month-view.d.ts +68 -0
  166. package/dist/schedule/month-view.js +301 -0
  167. package/dist/schedule/time-grid.d.ts +168 -0
  168. package/dist/schedule/time-grid.js +417 -0
  169. package/dist/schedule/utils/time-grid-layout.d.ts +50 -0
  170. package/dist/schedule/utils/time-grid-layout.js +93 -0
  171. package/dist/schedule/year-view.d.ts +46 -0
  172. package/dist/schedule/year-view.js +142 -0
  173. package/dist/styles/index.d.ts +1 -0
  174. package/dist/styles/index.js +1 -0
  175. package/dist/styles/typewriter-text.d.ts +20 -0
  176. package/dist/styles/typewriter-text.js +23 -0
  177. package/dist/test/map.d.ts +18 -0
  178. package/dist/test/map.js +96 -0
  179. package/dist/test/reels.d.ts +30 -0
  180. package/dist/test/reels.js +41 -0
  181. package/dist/test/stories.d.ts +31 -0
  182. package/dist/test/stories.js +66 -0
  183. package/dist/travel/boarding-pass.d.ts +107 -0
  184. package/dist/travel/boarding-pass.js +293 -0
  185. package/dist/travel/car-offer.d.ts +70 -0
  186. package/dist/travel/car-offer.js +127 -0
  187. package/dist/travel/fare-calendar.d.ts +85 -0
  188. package/dist/travel/fare-calendar.js +233 -0
  189. package/dist/travel/fare-options.d.ts +84 -0
  190. package/dist/travel/fare-options.js +142 -0
  191. package/dist/travel/flight-itinerary.d.ts +84 -0
  192. package/dist/travel/flight-itinerary.js +112 -0
  193. package/dist/travel/flight-option.d.ts +58 -0
  194. package/dist/travel/flight-option.js +111 -0
  195. package/dist/travel/flight-segment.d.ts +105 -0
  196. package/dist/travel/flight-segment.js +174 -0
  197. package/dist/travel/index.d.ts +20 -0
  198. package/dist/travel/index.js +20 -0
  199. package/dist/travel/package-savings.d.ts +74 -0
  200. package/dist/travel/package-savings.js +128 -0
  201. package/dist/travel/price-breakdown.d.ts +66 -0
  202. package/dist/travel/price-breakdown.js +102 -0
  203. package/dist/travel/rating-breakdown.d.ts +81 -0
  204. package/dist/travel/rating-breakdown.js +132 -0
  205. package/dist/travel/seat-map.d.ts +108 -0
  206. package/dist/travel/seat-map.js +371 -0
  207. package/dist/travel/trip-timeline.d.ts +84 -0
  208. package/dist/travel/trip-timeline.js +212 -0
  209. package/dist/utils/gamepad-presses.d.ts +21 -0
  210. package/dist/utils/gamepad-presses.js +28 -0
  211. package/dist/utils/index.d.ts +5 -0
  212. package/dist/utils/index.js +5 -0
  213. package/dist/utils/move-focus.d.ts +20 -0
  214. package/dist/utils/move-focus.js +28 -0
  215. package/dist/utils/range-months.d.ts +54 -0
  216. package/dist/utils/range-months.js +98 -0
  217. package/dist/utils/swipe-direction.d.ts +23 -0
  218. package/dist/utils/swipe-direction.js +27 -0
  219. package/dist/utils/typewriter.d.ts +49 -0
  220. package/dist/utils/typewriter.js +171 -0
  221. package/dist/video/index.d.ts +6 -2
  222. package/dist/video/index.js +6 -2
  223. package/dist/video/mixins/reel-feed-sync.d.ts +41 -0
  224. package/dist/video/mixins/reel-feed-sync.js +430 -0
  225. package/dist/video/mixins/story-viewer-sync.d.ts +31 -0
  226. package/dist/video/mixins/story-viewer-sync.js +391 -0
  227. package/dist/video/reel-feed.d.ts +95 -0
  228. package/dist/video/reel-feed.js +124 -0
  229. package/dist/video/story-ring.d.ts +32 -0
  230. package/dist/video/story-ring.js +42 -0
  231. package/dist/video/story-viewer.d.ts +85 -0
  232. package/dist/video/story-viewer.js +250 -0
  233. package/package.json +21 -2
@@ -0,0 +1,102 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "remix/component/jsx-runtime";
2
+ import { mergeMix, raw } from "@sdxc/u/general";
3
+ import { Equalizer } from "./equalizer.js";
4
+ import { formatTrackTime } from "./utils/track-time.js";
5
+ /** One headed group of queued tracks. */
6
+ function QueueListSection(handle) {
7
+ return () => {
8
+ let { children, empty, level = 3, mix, title, ...rest } = handle.props;
9
+ let Heading = `h${level}`;
10
+ let hasRows = Array.isArray(children) ? children.length > 0 : children != null;
11
+ return (_jsxs("section", { ...rest, "data-slot": "queue-list", mix: mergeMix([raw({ display: "grid", gap: "0.375rem", minInlineSize: "0" })], mix), children: [_jsx(Heading, { mix: [
12
+ raw({
13
+ margin: "0",
14
+ fontSize: "0.9375rem",
15
+ lineHeight: "1.375rem",
16
+ fontWeight: "700",
17
+ color: "var(--ui-neutral-fg-emphasis)",
18
+ }),
19
+ ], children: title }), hasRows ? (_jsx("ol", { mix: [raw({ display: "grid", margin: "0", padding: "0", listStyle: "none" })], children: children })) : (_jsx("p", { mix: [raw({ margin: "0", fontSize: "0.875rem", color: "var(--ui-neutral-fg-muted)" })], children: empty }))] }));
20
+ };
21
+ }
22
+ /** One queued track. */
23
+ function QueueListItem(handle) {
24
+ return () => {
25
+ let { action, art, current, duration, mix, subtitle, title, ...rest } = handle.props;
26
+ return (_jsxs("li", { ...rest, "data-slot": "queue-list-item", "aria-current": current ? "true" : undefined, mix: mergeMix([
27
+ raw({
28
+ position: "relative",
29
+ display: "flex",
30
+ alignItems: "center",
31
+ gap: "0.75rem",
32
+ padding: "0.375rem",
33
+ borderRadius: "var(--ui-radius-md, 0.375rem)",
34
+ minInlineSize: "0",
35
+ "&:hover, &:focus-within": { backgroundColor: "var(--ui-neutral-bg-tint-hover)" },
36
+ "& [data-slot=queue-list-action] > *": {
37
+ position: "absolute",
38
+ inset: "0",
39
+ margin: "0",
40
+ padding: "0",
41
+ border: "0",
42
+ borderRadius: "inherit",
43
+ background: "transparent",
44
+ cursor: "pointer",
45
+ },
46
+ "& [data-slot=queue-list-action] > :focus-visible": {
47
+ outline: "2px solid var(--ui-brand-ring)",
48
+ outlineOffset: "-2px",
49
+ },
50
+ "&[aria-current=true] [data-slot=queue-list-title]": { color: "var(--ui-brand-fg)" },
51
+ }),
52
+ ], mix), children: [art === undefined ? null : (_jsx("span", { mix: [
53
+ raw({
54
+ flex: "none",
55
+ inlineSize: "2.5rem",
56
+ blockSize: "2.5rem",
57
+ overflow: "clip",
58
+ borderRadius: "var(--ui-radius-sm, 0.25rem)",
59
+ backgroundColor: "var(--ui-neutral-bg-tint)",
60
+ "& > *": { display: "block", inlineSize: "100%", blockSize: "100%" },
61
+ }),
62
+ ], children: art })), _jsxs("span", { mix: [raw({ display: "grid", flex: "1", minInlineSize: "0" })], children: [_jsxs("span", { "data-slot": "queue-list-title", mix: [
63
+ raw({
64
+ display: "flex",
65
+ alignItems: "center",
66
+ gap: "0.375rem",
67
+ overflow: "hidden",
68
+ whiteSpace: "nowrap",
69
+ fontSize: "0.875rem",
70
+ lineHeight: "1.25rem",
71
+ fontWeight: "500",
72
+ color: "var(--ui-neutral-fg-emphasis)",
73
+ }),
74
+ ], children: [current ? _jsx(Equalizer, { mix: [raw({ flex: "none", fontSize: "0.75rem" })] }) : null, _jsx("span", { mix: [raw({ overflow: "hidden", textOverflow: "ellipsis" })], children: title })] }), subtitle === undefined ? null : (_jsx("span", { mix: [
75
+ raw({
76
+ overflow: "hidden",
77
+ textOverflow: "ellipsis",
78
+ whiteSpace: "nowrap",
79
+ fontSize: "0.75rem",
80
+ lineHeight: "1rem",
81
+ color: "var(--ui-neutral-fg-muted)",
82
+ }),
83
+ ], children: subtitle }))] }), duration === undefined ? null : (_jsx("span", { mix: [
84
+ raw({
85
+ flex: "none",
86
+ fontSize: "0.75rem",
87
+ fontVariantNumeric: "tabular-nums",
88
+ color: "var(--ui-neutral-fg-muted)",
89
+ }),
90
+ ], children: formatTrackTime(duration) })), action === undefined ? null : _jsx("span", { "data-slot": "queue-list-action", children: action })] }));
91
+ };
92
+ }
93
+ /**
94
+ * The queue's parts: {@link QueueList.Section} for a headed group, {@link QueueList.Item} for
95
+ * one track. A panel stacks a "Now playing" section with one item over a "Next up" section.
96
+ *
97
+ * @example
98
+ * <QueueList.Section title="Next up" empty="Nothing queued">
99
+ * <QueueList.Item title="Low Tide" subtitle="Lumen Harbor" duration={187} />
100
+ * </QueueList.Section>
101
+ */
102
+ export const QueueList = { Section: QueueListSection, Item: QueueListItem };
@@ -0,0 +1,91 @@
1
+ /**
2
+ * The track table of an album, a playlist or an artist's top songs: a number that turns into a
3
+ * play button under the pointer, the title with its artists, the album, when it was added and
4
+ * its length. The playing row carries `aria-current="true"` and shows an {@link Equalizer}.
5
+ *
6
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
7
+ * @copyright Sergio Xalambrí 2026
8
+ */
9
+ import type { Handle, Props as TagProps, RemixNode } from "remix/component";
10
+ /** Prop types for {@link TrackList} and its parts. */
11
+ export declare namespace TrackList {
12
+ /** The column headings and the marks' spoken names. */
13
+ interface Labels {
14
+ /** The number column's heading, such as "#". */
15
+ index: string;
16
+ title: string;
17
+ album: string;
18
+ added: string;
19
+ duration: string;
20
+ /** What a screen reader hears on the playing row's mark, such as "Now playing". */
21
+ playing: string;
22
+ }
23
+ /** Which optional columns the table shows; a playlist shows both, an album neither. */
24
+ interface Columns {
25
+ album?: boolean;
26
+ added?: boolean;
27
+ }
28
+ /** Every native `<table>` attribute, plus the headings and the rows. */
29
+ interface Props extends TagProps<"table"> {
30
+ labels: Labels;
31
+ /** @default { album: false, added: false } */
32
+ columns?: Columns;
33
+ /** Shows the heading row from the width where every column fits. @default true */
34
+ header?: boolean;
35
+ /** {@link TrackList.Row} elements in playing order. */
36
+ children: RemixNode;
37
+ }
38
+ /** Every native `<tr>` attribute, plus one track's cells. */
39
+ interface RowProps extends Omit<TagProps<"tr">, "title"> {
40
+ /** The track's place, shown in the number column. */
41
+ index: number;
42
+ title: string;
43
+ /** The artists, usually links to their pages, joined with commas by the caller. */
44
+ artists?: RemixNode;
45
+ /** A small square cover beside the title, for a list that mixes albums. */
46
+ art?: RemixNode;
47
+ /** The album, usually a link; shown when the table's `columns.album` is on. */
48
+ album?: RemixNode;
49
+ /** When the track was added, such as "3 days ago"; shown when `columns.added` is on. */
50
+ added?: RemixNode;
51
+ /** Length in seconds. */
52
+ duration: number;
53
+ /** Marks the "E" badge before the artists. */
54
+ explicit?: boolean;
55
+ /** The play control: a {@link TrackList.PlayButton}, inside a form when it posts. */
56
+ play: RemixNode;
57
+ /** Whether this row is the one playing, as the server knows it; a player keeps it current after. */
58
+ current?: boolean;
59
+ /** Controls at the row's end, such as a like button or a menu. */
60
+ trailing?: RemixNode;
61
+ }
62
+ /** Every native `<button>` attribute; `aria-label` names the track it plays. */
63
+ interface PlayButtonProps extends TagProps<"button"> {
64
+ "aria-label": string;
65
+ }
66
+ }
67
+ /**
68
+ * Renders the table. Its cells drop to number, title and length on a narrow container, and
69
+ * the whole row plays its track when pressed anywhere outside its own links and controls.
70
+ *
71
+ * @example
72
+ * <TrackList labels={labels} columns={{ album: true }}>
73
+ * <TrackList.Row index={1} title="Low Tide" duration={187} play={<TrackList.PlayButton aria-label="Play Low Tide" />} />
74
+ * </TrackList>
75
+ */
76
+ export declare function TrackList(handle: Handle<TrackList.Props>): () => import("remix/component").RemixElement;
77
+ export declare namespace TrackList {
78
+ var Row: typeof TrackListRow;
79
+ var PlayButton: typeof TrackListPlayButton;
80
+ }
81
+ /**
82
+ * One track. The album and added cells render only when the caller passes them, so the row
83
+ * matches the table's `columns`.
84
+ */
85
+ declare function TrackListRow(handle: Handle<TrackList.RowProps>): () => import("remix/component").RemixElement;
86
+ /**
87
+ * The play control in a row's number cell. It shows under the pointer and on keyboard focus,
88
+ * and its hit area covers the whole row, so a press anywhere on the row plays the track.
89
+ */
90
+ declare function TrackListPlayButton(handle: Handle<TrackList.PlayButtonProps>): () => import("remix/component").RemixElement;
91
+ export {};
@@ -0,0 +1,226 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "remix/component/jsx-runtime";
2
+ import { ClockIcon, PlayIcon } from "@sdxc/icons";
3
+ import { visuallyHidden } from "@sdxc/u/a11y";
4
+ import { mergeMix, raw } from "@sdxc/u/general";
5
+ import { Equalizer } from "./equalizer.js";
6
+ import { formatTrackTime } from "./utils/track-time.js";
7
+ /** The container the table's columns respond to, so it fits a side panel as well as a page. */
8
+ const CONTAINER = "ui-track-list";
9
+ /**
10
+ * Renders the table. Its cells drop to number, title and length on a narrow container, and
11
+ * the whole row plays its track when pressed anywhere outside its own links and controls.
12
+ *
13
+ * @example
14
+ * <TrackList labels={labels} columns={{ album: true }}>
15
+ * <TrackList.Row index={1} title="Low Tide" duration={187} play={<TrackList.PlayButton aria-label="Play Low Tide" />} />
16
+ * </TrackList>
17
+ */
18
+ export function TrackList(handle) {
19
+ return () => {
20
+ let { children, columns = {}, header = true, labels, mix, ...rest } = handle.props;
21
+ return (_jsx("div", { "data-slot": "track-list-frame", mix: [raw({ containerType: "inline-size", containerName: CONTAINER, minInlineSize: "0" })], children: _jsxs("table", { ...rest, "data-slot": "track-list", "data-album": columns.album ? "" : undefined, "data-added": columns.added ? "" : undefined, mix: mergeMix([tableStyles()], mix), children: [_jsxs("colgroup", { children: [_jsx("col", { "data-col": "index" }), _jsx("col", { "data-col": "title" }), columns.album ? _jsx("col", { "data-col": "album" }) : null, columns.added ? _jsx("col", { "data-col": "added" }) : null, _jsx("col", { "data-col": "duration" }), _jsx("col", { "data-col": "trailing" })] }), _jsx("thead", { "data-header": header ? "" : undefined, children: _jsxs("tr", { children: [_jsx("th", { scope: "col", "data-cell": "index", children: labels.index }), _jsx("th", { scope: "col", "data-cell": "title", children: labels.title }), columns.album ? (_jsx("th", { scope: "col", "data-cell": "album", children: labels.album })) : null, columns.added ? (_jsx("th", { scope: "col", "data-cell": "added", children: labels.added })) : null, _jsxs("th", { scope: "col", "data-cell": "duration", children: [_jsx(ClockIcon, { "aria-hidden": "true", size: 16 }), _jsx("span", { mix: [visuallyHidden()], children: labels.duration })] }), _jsx("th", { scope: "col", "data-cell": "trailing", children: _jsx("span", { mix: [visuallyHidden()], children: labels.title }) })] }) }), _jsx("tbody", { "data-playing-label": labels.playing, children: children })] }) }));
22
+ };
23
+ }
24
+ /**
25
+ * One track. The album and added cells render only when the caller passes them, so the row
26
+ * matches the table's `columns`.
27
+ */
28
+ function TrackListRow(handle) {
29
+ return () => {
30
+ let { added, album, art, artists, current, duration, explicit, index, play, title, trailing, ...rest } = handle.props;
31
+ return (_jsxs("tr", { ...rest, "data-slot": "track-list-row", "aria-current": current ? "true" : undefined, children: [_jsx("td", { "data-cell": "index", children: _jsxs("span", { "data-slot": "track-list-marker", children: [_jsx("span", { "data-slot": "track-list-index", children: index }), _jsx("span", { "data-slot": "track-list-playing", children: _jsx(Equalizer, {}) }), play] }) }), _jsx("td", { "data-cell": "title", children: _jsxs("span", { "data-slot": "track-list-heading", children: [art === undefined ? null : _jsx("span", { "data-slot": "track-list-art", children: art }), _jsxs("span", { "data-slot": "track-list-text", children: [_jsx("span", { "data-slot": "track-list-title", children: title }), artists === undefined && !explicit ? null : (_jsxs("span", { "data-slot": "track-list-artists", children: [explicit ? (_jsx("abbr", { "data-slot": "track-list-explicit", title: "Explicit", children: "E" })) : null, artists] }))] })] }) }), album === undefined ? null : _jsx("td", { "data-cell": "album", children: album }), added === undefined ? null : _jsx("td", { "data-cell": "added", children: added }), _jsx("td", { "data-cell": "duration", children: formatTrackTime(duration) }), _jsx("td", { "data-cell": "trailing", children: trailing })] }));
32
+ };
33
+ }
34
+ /**
35
+ * The play control in a row's number cell. It shows under the pointer and on keyboard focus,
36
+ * and its hit area covers the whole row, so a press anywhere on the row plays the track.
37
+ */
38
+ function TrackListPlayButton(handle) {
39
+ return () => {
40
+ let { children, type = "submit", ...rest } = handle.props;
41
+ return (_jsx("button", { ...rest, type: type, "data-slot": "track-list-play", children: children ?? _jsx(PlayIcon, { "aria-hidden": "true", size: 16, fill: "currentColor" }) }));
42
+ };
43
+ }
44
+ TrackList.Row = TrackListRow;
45
+ TrackList.PlayButton = TrackListPlayButton;
46
+ /** The table's look: quiet rows, a hover wash, the number cell's three states and the narrow form. */
47
+ function tableStyles() {
48
+ return raw({
49
+ inlineSize: "100%",
50
+ tableLayout: "fixed",
51
+ borderCollapse: "separate",
52
+ borderSpacing: "0",
53
+ fontSize: "0.875rem",
54
+ lineHeight: "1.25rem",
55
+ color: "var(--ui-neutral-fg-muted)",
56
+ fontVariantNumeric: "tabular-nums",
57
+ "& col[data-col=index]": { inlineSize: "3rem" },
58
+ "& col[data-col=album]": { inlineSize: "30%" },
59
+ "& col[data-col=added]": { inlineSize: "8.5rem" },
60
+ "& col[data-col=duration]": { inlineSize: "4.5rem" },
61
+ "& col[data-col=trailing]": { inlineSize: "3rem" },
62
+ "& th": {
63
+ paddingBlock: "0.5rem",
64
+ paddingInline: "0.5rem",
65
+ textAlign: "start",
66
+ fontSize: "0.75rem",
67
+ fontWeight: "500",
68
+ letterSpacing: "0.04em",
69
+ textTransform: "uppercase",
70
+ borderBlockEnd: "1px solid var(--ui-neutral-border)",
71
+ },
72
+ "& thead:not([data-header])": { display: "none" },
73
+ "& th[data-cell=index], & td[data-cell=index]": { textAlign: "center" },
74
+ "& th[data-cell=duration], & td[data-cell=duration]": { textAlign: "end" },
75
+ "& th[data-cell=duration] svg": { verticalAlign: "middle" },
76
+ "& tbody::before": { content: "''", display: "block", blockSize: "0.5rem" },
77
+ "& tr[data-slot=track-list-row]": { position: "relative" },
78
+ "& td": {
79
+ paddingInline: "0.5rem",
80
+ blockSize: "3.5rem",
81
+ overflow: "hidden",
82
+ textOverflow: "ellipsis",
83
+ whiteSpace: "nowrap",
84
+ },
85
+ "& td:first-child": {
86
+ borderStartStartRadius: "var(--ui-radius-md, 0.375rem)",
87
+ borderEndStartRadius: "var(--ui-radius-md, 0.375rem)",
88
+ },
89
+ "& td:last-child": {
90
+ borderStartEndRadius: "var(--ui-radius-md, 0.375rem)",
91
+ borderEndEndRadius: "var(--ui-radius-md, 0.375rem)",
92
+ },
93
+ "& tr[data-slot=track-list-row]:hover td, & tr[data-slot=track-list-row]:focus-within td": {
94
+ backgroundColor: "var(--ui-neutral-bg-tint-hover)",
95
+ },
96
+ "& td[data-cell=index]": {
97
+ display: "table-cell",
98
+ overflow: "visible",
99
+ fontSize: "0.9375rem",
100
+ },
101
+ "& [data-slot=track-list-marker]": {
102
+ display: "inline-grid",
103
+ placeItems: "center",
104
+ verticalAlign: "middle",
105
+ inlineSize: "1.75rem",
106
+ blockSize: "1.75rem",
107
+ },
108
+ "& [data-slot=track-list-marker] > *, & [data-slot=track-list-play]": { gridArea: "1 / 1" },
109
+ "& [data-slot=track-list-playing]": {
110
+ display: "none",
111
+ color: "var(--ui-brand-fg)",
112
+ fontSize: "0.875rem",
113
+ },
114
+ "& [data-slot=track-list-play]": {
115
+ display: "inline-grid",
116
+ placeItems: "center",
117
+ inlineSize: "1.75rem",
118
+ blockSize: "1.75rem",
119
+ padding: "0",
120
+ border: "0",
121
+ borderRadius: "999px",
122
+ color: "var(--ui-neutral-fg-emphasis)",
123
+ backgroundColor: "transparent",
124
+ cursor: "pointer",
125
+ opacity: "0",
126
+ },
127
+ "& [data-slot=track-list-play]::after": {
128
+ content: "''",
129
+ position: "absolute",
130
+ inset: "0",
131
+ },
132
+ "& [data-slot=track-list-play]:focus-visible": {
133
+ opacity: "1",
134
+ outline: "2px solid var(--ui-brand-ring)",
135
+ outlineOffset: "1px",
136
+ },
137
+ "& tr:hover [data-slot=track-list-play], & tr:focus-within [data-slot=track-list-play]": {
138
+ opacity: "1",
139
+ },
140
+ "& tr:hover [data-slot=track-list-index], & tr:focus-within [data-slot=track-list-index], & tr:hover [data-slot=track-list-playing], & tr:focus-within [data-slot=track-list-playing]": { visibility: "hidden" },
141
+ "& tr[aria-current=true] [data-slot=track-list-index]": { display: "none" },
142
+ "& tr[aria-current=true] [data-slot=track-list-playing]": { display: "inline-flex" },
143
+ "& [data-slot=track-list-playing] > *": { fontSize: "0.875rem" },
144
+ "& tr[aria-current=true] [data-slot=track-list-title]": { color: "var(--ui-brand-fg)" },
145
+ "& [data-slot=track-list-heading]": {
146
+ display: "flex",
147
+ alignItems: "center",
148
+ gap: "0.75rem",
149
+ minInlineSize: "0",
150
+ },
151
+ "& [data-slot=track-list-art]": {
152
+ flex: "none",
153
+ display: "block",
154
+ inlineSize: "2.5rem",
155
+ blockSize: "2.5rem",
156
+ overflow: "clip",
157
+ borderRadius: "var(--ui-radius-sm, 0.25rem)",
158
+ backgroundColor: "var(--ui-neutral-bg-tint)",
159
+ },
160
+ "& [data-slot=track-list-art] > *": {
161
+ display: "block",
162
+ inlineSize: "100%",
163
+ blockSize: "100%",
164
+ objectFit: "cover",
165
+ },
166
+ "& [data-slot=track-list-text]": { display: "grid", minInlineSize: "0" },
167
+ "& [data-slot=track-list-title]": {
168
+ overflow: "hidden",
169
+ textOverflow: "ellipsis",
170
+ fontSize: "0.9375rem",
171
+ lineHeight: "1.375rem",
172
+ fontWeight: "500",
173
+ color: "var(--ui-neutral-fg-emphasis)",
174
+ },
175
+ "& [data-slot=track-list-artists]": {
176
+ overflow: "hidden",
177
+ textOverflow: "ellipsis",
178
+ fontSize: "0.8125rem",
179
+ },
180
+ "& [data-slot=track-list-explicit]": {
181
+ display: "inline-grid",
182
+ placeItems: "center",
183
+ marginInlineEnd: "0.375rem",
184
+ inlineSize: "1rem",
185
+ blockSize: "1rem",
186
+ borderRadius: "0.1875rem",
187
+ fontSize: "0.625rem",
188
+ fontWeight: "700",
189
+ lineHeight: "1",
190
+ textDecoration: "none",
191
+ verticalAlign: "0.0625rem",
192
+ color: "var(--ui-neutral-bg-solid, Canvas)",
193
+ backgroundColor: "var(--ui-neutral-fg-muted)",
194
+ },
195
+ "& td a": {
196
+ position: "relative",
197
+ zIndex: "1",
198
+ color: "inherit",
199
+ textDecoration: "none",
200
+ },
201
+ "& td a:hover": { color: "var(--ui-neutral-fg-emphasis)", textDecoration: "underline" },
202
+ "& td a:focus-visible": {
203
+ outline: "2px solid var(--ui-brand-ring)",
204
+ outlineOffset: "2px",
205
+ borderRadius: "2px",
206
+ },
207
+ "& td[data-cell=trailing]": { textAlign: "end" },
208
+ "& td[data-cell=trailing] :is(a, button, input, select)": { position: "relative", zIndex: "1" },
209
+ [`@container ${CONTAINER} (max-width: 52rem)`]: {
210
+ "& col[data-col=added], & [data-cell=added]": { display: "none" },
211
+ },
212
+ [`@container ${CONTAINER} (max-width: 36rem)`]: {
213
+ "& thead": { display: "none" },
214
+ "& col[data-col=album], & [data-cell=album]": { display: "none" },
215
+ "& col[data-col=index]": { inlineSize: "2.25rem" },
216
+ "& col[data-col=duration]": { inlineSize: "3.25rem" },
217
+ "& col[data-col=trailing]": { inlineSize: "2.75rem" },
218
+ "& td": { paddingInline: "0.25rem" },
219
+ "& tr:hover [data-slot=track-list-index], & tr:focus-within [data-slot=track-list-index]": {
220
+ visibility: "visible",
221
+ },
222
+ "& tr:hover [data-slot=track-list-playing], & tr:focus-within [data-slot=track-list-playing]": { visibility: "visible" },
223
+ "& tr [data-slot=track-list-play]:not(:focus-visible)": { opacity: "0" },
224
+ },
225
+ });
226
+ }
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Hands a music player's state to the operating system through the Media Session API, so the
3
+ * media keys, the lock screen, a headset's buttons and the browser's own media hub show the
4
+ * track and drive the player. Browsers without the API are left alone.
5
+ *
6
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
7
+ * @copyright Sergio Xalambrí 2026
8
+ */
9
+ /** Types associated with {@link syncMediaSession}. */
10
+ export declare namespace MediaSessionSync {
11
+ /** What the system shows for the track playing. */
12
+ interface Track {
13
+ title: string;
14
+ artist: string;
15
+ album?: string;
16
+ /** Square pictures, largest last; a PNG or JPEG reaches every platform. */
17
+ artwork?: Array<{
18
+ src: string;
19
+ sizes?: string;
20
+ type?: string;
21
+ }>;
22
+ }
23
+ /** The player's commands the system may call; one left out disables its button. */
24
+ interface Actions {
25
+ play: () => void;
26
+ pause: () => void;
27
+ previous?: () => void;
28
+ next?: () => void;
29
+ /** Moves to an absolute time in seconds. */
30
+ seek?: (time: number) => void;
31
+ }
32
+ }
33
+ /**
34
+ * Publishes the track and the media's position, and routes the system's buttons to the
35
+ * player's commands. Call it when the track changes; position and play state follow the
36
+ * media's own events until `signal` aborts, which clears the handlers.
37
+ *
38
+ * @param media The `<audio>` or `<video>` element that plays.
39
+ * @param track What plays, or `null` to clear what the system shows.
40
+ * @param actions The player's commands.
41
+ * @param signal Ends the sync, such as when the player unmounts or the track changes.
42
+ * @example syncMediaSession(audio, { title: "Tidelight", artist: "Lumen Harbor" }, { play, pause, next }, controller.signal)
43
+ */
44
+ export declare function syncMediaSession(media: HTMLMediaElement, track: MediaSessionSync.Track | null, actions: MediaSessionSync.Actions, signal: AbortSignal): void;
@@ -0,0 +1,87 @@
1
+ /**
2
+ * Hands a music player's state to the operating system through the Media Session API, so the
3
+ * media keys, the lock screen, a headset's buttons and the browser's own media hub show the
4
+ * track and drive the player. Browsers without the API are left alone.
5
+ *
6
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
7
+ * @copyright Sergio Xalambrí 2026
8
+ */
9
+ /** How far the system's skip buttons move, in seconds, when it names no offset. */
10
+ const SKIP_SECONDS = 10;
11
+ /**
12
+ * Publishes the track and the media's position, and routes the system's buttons to the
13
+ * player's commands. Call it when the track changes; position and play state follow the
14
+ * media's own events until `signal` aborts, which clears the handlers.
15
+ *
16
+ * @param media The `<audio>` or `<video>` element that plays.
17
+ * @param track What plays, or `null` to clear what the system shows.
18
+ * @param actions The player's commands.
19
+ * @param signal Ends the sync, such as when the player unmounts or the track changes.
20
+ * @example syncMediaSession(audio, { title: "Tidelight", artist: "Lumen Harbor" }, { play, pause, next }, controller.signal)
21
+ */
22
+ export function syncMediaSession(media, track, actions, signal) {
23
+ if (typeof navigator === "undefined" || !("mediaSession" in navigator))
24
+ return;
25
+ let session = navigator.mediaSession;
26
+ session.metadata =
27
+ track === null || typeof MediaMetadata === "undefined"
28
+ ? null
29
+ : new MediaMetadata({
30
+ title: track.title,
31
+ artist: track.artist,
32
+ album: track.album ?? "",
33
+ artwork: track.artwork ?? [],
34
+ });
35
+ /** Sets a handler, skipping an action the browser does not know rather than throwing. */
36
+ let handle = (action, handler) => {
37
+ try {
38
+ session.setActionHandler(action, handler);
39
+ return true;
40
+ }
41
+ catch {
42
+ return false;
43
+ }
44
+ };
45
+ let seek = actions.seek;
46
+ handle("play", () => actions.play());
47
+ handle("pause", () => actions.pause());
48
+ handle("previoustrack", actions.previous ? () => actions.previous?.() : null);
49
+ handle("nexttrack", actions.next ? () => actions.next?.() : null);
50
+ handle("seekto", seek ? (details) => seek(details.seekTime ?? media.currentTime) : null);
51
+ handle("seekbackward", seek ? (details) => seek(media.currentTime - (details.seekOffset ?? SKIP_SECONDS)) : null);
52
+ handle("seekforward", seek ? (details) => seek(media.currentTime + (details.seekOffset ?? SKIP_SECONDS)) : null);
53
+ /** Reports where the media is, which the system draws as its own progress bar. */
54
+ let position = () => {
55
+ session.playbackState = media.paused ? "paused" : "playing";
56
+ if (!Number.isFinite(media.duration) || media.duration <= 0)
57
+ return false;
58
+ try {
59
+ session.setPositionState({
60
+ duration: media.duration,
61
+ position: Math.min(media.currentTime, media.duration),
62
+ playbackRate: media.playbackRate || 1,
63
+ });
64
+ return true;
65
+ }
66
+ catch {
67
+ return false;
68
+ }
69
+ };
70
+ position();
71
+ for (let type of ["play", "pause", "seeked", "loadedmetadata", "ratechange"]) {
72
+ media.addEventListener(type, position, { signal });
73
+ }
74
+ signal.addEventListener("abort", () => {
75
+ for (let action of [
76
+ "play",
77
+ "pause",
78
+ "previoustrack",
79
+ "nexttrack",
80
+ "seekto",
81
+ "seekbackward",
82
+ "seekforward",
83
+ ]) {
84
+ handle(action, null);
85
+ }
86
+ });
87
+ }
@@ -0,0 +1,98 @@
1
+ /**
2
+ * The play order of a music player as plain data: which track plays, what comes next with
3
+ * shuffle and repeat, and what Previous does. Every function returns a new queue, so a player
4
+ * keeps one value in state and a test checks each rule without media.
5
+ *
6
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
7
+ * @copyright Sergio Xalambrí 2026
8
+ */
9
+ /** Types associated with the play queue functions. */
10
+ export declare namespace PlayQueue {
11
+ /** `all` starts the list again after its last track; `one` plays the same track again. */
12
+ type Repeat = "off" | "all" | "one";
13
+ /** A queue over a list of tracks, which the player keeps beside it. */
14
+ interface State {
15
+ /** How many tracks the list holds. */
16
+ length: number;
17
+ /** The list's indexes in the order they play: the list's own, or a shuffle of it. */
18
+ order: number[];
19
+ /** Where in {@link order} the player is. */
20
+ position: number;
21
+ shuffle: boolean;
22
+ repeat: Repeat;
23
+ }
24
+ }
25
+ /** How far into a track, in seconds, Previous restarts it rather than going back one. */
26
+ export declare const RESTART_THRESHOLD = 3;
27
+ /**
28
+ * Starts a queue at one track of a list. With shuffle on, that track plays first and the rest
29
+ * follow in a random order.
30
+ *
31
+ * @param length How many tracks the list holds.
32
+ * @param start The index of the track to play first.
33
+ * @param options Shuffle, repeat and the random source a test pins.
34
+ * @example createPlayQueue(12, 3, { shuffle: true })
35
+ */
36
+ export declare function createPlayQueue(length: number, start: number, options?: {
37
+ shuffle?: boolean;
38
+ repeat?: PlayQueue.Repeat;
39
+ random?: () => number;
40
+ }): PlayQueue.State;
41
+ /**
42
+ * The list index of the track the queue is on, or `undefined` for an empty queue.
43
+ *
44
+ * @param queue The queue.
45
+ */
46
+ export declare function currentIndex(queue: PlayQueue.State): number | undefined;
47
+ /**
48
+ * Moves to the next track. When a track ends by itself (`ended`), repeat-one plays it again;
49
+ * pressing Next always moves on. Past the last track, repeat-all starts over and otherwise
50
+ * the queue ends.
51
+ *
52
+ * @param queue The queue.
53
+ * @param ended Whether the track finished playing, rather than the listener pressing Next.
54
+ * @returns The new queue, or `null` once nothing is left to play.
55
+ */
56
+ export declare function nextInQueue(queue: PlayQueue.State, ended?: boolean): PlayQueue.State | null;
57
+ /**
58
+ * What Previous does: restarts the track once it has played a few seconds, and otherwise goes
59
+ * back one, wrapping to the end under repeat-all and staying on the first track without it.
60
+ *
61
+ * @param queue The queue.
62
+ * @param time How far into the current track the player is, in seconds.
63
+ * @returns The new queue and whether the player should seek to the start of its track.
64
+ */
65
+ export declare function previousInQueue(queue: PlayQueue.State, time: number): {
66
+ queue: PlayQueue.State;
67
+ restart: boolean;
68
+ };
69
+ /**
70
+ * Turns shuffle on or off without interrupting the track playing: on, it stays first and the
71
+ * rest are shuffled after it; off, the list's own order resumes from it.
72
+ *
73
+ * @param queue The queue.
74
+ * @param random A source of numbers in [0, 1).
75
+ */
76
+ export declare function toggleShuffle(queue: PlayQueue.State, random?: () => number): PlayQueue.State;
77
+ /**
78
+ * Steps repeat from off to all to one and back to off, the order a player's one button cycles.
79
+ *
80
+ * @param queue The queue.
81
+ */
82
+ export declare function cycleRepeat(queue: PlayQueue.State): PlayQueue.State;
83
+ /**
84
+ * Jumps to a track that is already queued, such as a row picked in the queue panel.
85
+ *
86
+ * @param queue The queue.
87
+ * @param index The list index of the track.
88
+ * @returns The queue on that track; unchanged when the list has no such index.
89
+ */
90
+ export declare function jumpTo(queue: PlayQueue.State, index: number): PlayQueue.State;
91
+ /**
92
+ * The list indexes still to play after the current track, in order: under repeat-all the
93
+ * list's start follows its end, so "Next up" never reads empty while the music goes on.
94
+ *
95
+ * @param queue The queue.
96
+ * @param limit The most indexes to return.
97
+ */
98
+ export declare function upcoming(queue: PlayQueue.State, limit?: number): number[];