@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.
Files changed (234) 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/slider.js +7 -0
  120. package/dist/components/step-indicator.d.ts +46 -0
  121. package/dist/components/step-indicator.js +96 -0
  122. package/dist/finance/index.d.ts +10 -0
  123. package/dist/finance/index.js +10 -0
  124. package/dist/finance/ledger.d.ts +60 -0
  125. package/dist/finance/ledger.js +93 -0
  126. package/dist/finance/payment-card.d.ts +49 -0
  127. package/dist/finance/payment-card.js +115 -0
  128. package/dist/map/engine.d.ts +49 -0
  129. package/dist/map/engine.js +591 -0
  130. package/dist/map/index.d.ts +12 -0
  131. package/dist/map/index.js +12 -0
  132. package/dist/map/map-canvas.d.ts +101 -0
  133. package/dist/map/map-canvas.js +275 -0
  134. package/dist/map/map.d.ts +217 -0
  135. package/dist/map/map.js +598 -0
  136. package/dist/map/mixins/map-link.d.ts +30 -0
  137. package/dist/map/mixins/map-link.js +116 -0
  138. package/dist/map/utils/basemap.d.ts +88 -0
  139. package/dist/map/utils/basemap.js +84 -0
  140. package/dist/map/utils/cluster.d.ts +43 -0
  141. package/dist/map/utils/cluster.js +80 -0
  142. package/dist/map/utils/mercator.d.ts +66 -0
  143. package/dist/map/utils/mercator.js +92 -0
  144. package/dist/map/utils/stage.d.ts +24 -0
  145. package/dist/map/utils/stage.js +49 -0
  146. package/dist/mixins/autocomplete.d.ts +28 -0
  147. package/dist/mixins/autocomplete.js +283 -0
  148. package/dist/mixins/carousel-controls.d.ts +14 -3
  149. package/dist/mixins/carousel-controls.js +89 -30
  150. package/dist/mixins/index.d.ts +2 -0
  151. package/dist/mixins/index.js +2 -0
  152. package/dist/mixins/lightbox-controls.d.ts +34 -0
  153. package/dist/mixins/lightbox-controls.js +176 -0
  154. package/dist/schedule/agenda.d.ts +63 -0
  155. package/dist/schedule/agenda.js +221 -0
  156. package/dist/schedule/day-strip.d.ts +50 -0
  157. package/dist/schedule/day-strip.js +136 -0
  158. package/dist/schedule/free-busy.d.ts +96 -0
  159. package/dist/schedule/free-busy.js +285 -0
  160. package/dist/schedule/index.d.ts +15 -0
  161. package/dist/schedule/index.js +15 -0
  162. package/dist/schedule/mixins/day-strip-scroll.d.ts +16 -0
  163. package/dist/schedule/mixins/day-strip-scroll.js +40 -0
  164. package/dist/schedule/mixins/time-grid-drag.d.ts +24 -0
  165. package/dist/schedule/mixins/time-grid-drag.js +532 -0
  166. package/dist/schedule/month-view.d.ts +68 -0
  167. package/dist/schedule/month-view.js +301 -0
  168. package/dist/schedule/time-grid.d.ts +168 -0
  169. package/dist/schedule/time-grid.js +417 -0
  170. package/dist/schedule/utils/time-grid-layout.d.ts +50 -0
  171. package/dist/schedule/utils/time-grid-layout.js +93 -0
  172. package/dist/schedule/year-view.d.ts +46 -0
  173. package/dist/schedule/year-view.js +142 -0
  174. package/dist/styles/index.d.ts +1 -0
  175. package/dist/styles/index.js +1 -0
  176. package/dist/styles/typewriter-text.d.ts +20 -0
  177. package/dist/styles/typewriter-text.js +23 -0
  178. package/dist/test/map.d.ts +18 -0
  179. package/dist/test/map.js +96 -0
  180. package/dist/test/reels.d.ts +30 -0
  181. package/dist/test/reels.js +41 -0
  182. package/dist/test/stories.d.ts +31 -0
  183. package/dist/test/stories.js +66 -0
  184. package/dist/travel/boarding-pass.d.ts +107 -0
  185. package/dist/travel/boarding-pass.js +293 -0
  186. package/dist/travel/car-offer.d.ts +70 -0
  187. package/dist/travel/car-offer.js +127 -0
  188. package/dist/travel/fare-calendar.d.ts +85 -0
  189. package/dist/travel/fare-calendar.js +233 -0
  190. package/dist/travel/fare-options.d.ts +84 -0
  191. package/dist/travel/fare-options.js +142 -0
  192. package/dist/travel/flight-itinerary.d.ts +84 -0
  193. package/dist/travel/flight-itinerary.js +112 -0
  194. package/dist/travel/flight-option.d.ts +58 -0
  195. package/dist/travel/flight-option.js +111 -0
  196. package/dist/travel/flight-segment.d.ts +105 -0
  197. package/dist/travel/flight-segment.js +174 -0
  198. package/dist/travel/index.d.ts +20 -0
  199. package/dist/travel/index.js +20 -0
  200. package/dist/travel/package-savings.d.ts +74 -0
  201. package/dist/travel/package-savings.js +128 -0
  202. package/dist/travel/price-breakdown.d.ts +66 -0
  203. package/dist/travel/price-breakdown.js +102 -0
  204. package/dist/travel/rating-breakdown.d.ts +81 -0
  205. package/dist/travel/rating-breakdown.js +132 -0
  206. package/dist/travel/seat-map.d.ts +108 -0
  207. package/dist/travel/seat-map.js +371 -0
  208. package/dist/travel/trip-timeline.d.ts +84 -0
  209. package/dist/travel/trip-timeline.js +212 -0
  210. package/dist/utils/gamepad-presses.d.ts +21 -0
  211. package/dist/utils/gamepad-presses.js +28 -0
  212. package/dist/utils/index.d.ts +5 -0
  213. package/dist/utils/index.js +5 -0
  214. package/dist/utils/move-focus.d.ts +20 -0
  215. package/dist/utils/move-focus.js +28 -0
  216. package/dist/utils/range-months.d.ts +54 -0
  217. package/dist/utils/range-months.js +98 -0
  218. package/dist/utils/swipe-direction.d.ts +23 -0
  219. package/dist/utils/swipe-direction.js +27 -0
  220. package/dist/utils/typewriter.d.ts +49 -0
  221. package/dist/utils/typewriter.js +171 -0
  222. package/dist/video/index.d.ts +6 -2
  223. package/dist/video/index.js +6 -2
  224. package/dist/video/mixins/reel-feed-sync.d.ts +41 -0
  225. package/dist/video/mixins/reel-feed-sync.js +430 -0
  226. package/dist/video/mixins/story-viewer-sync.d.ts +31 -0
  227. package/dist/video/mixins/story-viewer-sync.js +391 -0
  228. package/dist/video/reel-feed.d.ts +95 -0
  229. package/dist/video/reel-feed.js +124 -0
  230. package/dist/video/story-ring.d.ts +32 -0
  231. package/dist/video/story-ring.js +42 -0
  232. package/dist/video/story-viewer.d.ts +85 -0
  233. package/dist/video/story-viewer.js +250 -0
  234. package/package.json +21 -2
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Why JS: advancing when a segment's time runs out, pausing while a finger holds, closing on a
3
+ * downward swipe and moving between people without loading a page all need live input and
4
+ * timing that HTML cannot express.
5
+ * No-JS baseline: each tap zone is a link to the previous or next segment's own address, the
6
+ * progress bar fills once, and the close link leaves.
7
+ *
8
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
9
+ * @copyright Sergio Xalambrí 2026
10
+ */
11
+ import type { MixinFactory } from "remix/component";
12
+ /** Set on the group on screen, whose current segment's bar runs. */
13
+ export declare const STORY_ACTIVE = "data-story-active";
14
+ /** Set on the viewer while its story is paused, by a held finger, a key or the pause button. */
15
+ export declare const STORY_PAUSED = "data-story-paused";
16
+ /** Set on the viewer once its island runs. */
17
+ export declare const STORY_READY = "data-story-ready";
18
+ /** Dispatched, bubbling, from the viewer whenever another segment comes on screen. */
19
+ export declare const STORY_CHANGE_EVENT = "ui:story-change";
20
+ /** What {@link STORY_CHANGE_EVENT} carries. */
21
+ export interface StoryChangeDetail {
22
+ /** The address of the segment now on screen. */
23
+ href: string;
24
+ }
25
+ /**
26
+ * Runs the viewer it sits in: plays the open group's current segment and moves on when its bar
27
+ * fills, steps on taps and arrow keys, pauses for a hold, the space bar or the pause button,
28
+ * moves between groups by horizontal snap, and closes on a downward swipe or Escape. Typing in
29
+ * a field inside it, such as a reply, holds the story still until the field loses focus.
30
+ */
31
+ export declare const storyViewerSync: MixinFactory<HTMLElement>;
@@ -0,0 +1,391 @@
1
+ /**
2
+ * Why JS: advancing when a segment's time runs out, pausing while a finger holds, closing on a
3
+ * downward swipe and moving between people without loading a page all need live input and
4
+ * timing that HTML cannot express.
5
+ * No-JS baseline: each tap zone is a link to the previous or next segment's own address, the
6
+ * progress bar fills once, and the close link leaves.
7
+ *
8
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
9
+ * @copyright Sergio Xalambrí 2026
10
+ */
11
+ import { createMixin } from "remix/component";
12
+ /** Set on the group on screen, whose current segment's bar runs. */
13
+ export const STORY_ACTIVE = "data-story-active";
14
+ /** Set on the viewer while its story is paused, by a held finger, a key or the pause button. */
15
+ export const STORY_PAUSED = "data-story-paused";
16
+ /** Set on the viewer once its island runs. */
17
+ export const STORY_READY = "data-story-ready";
18
+ /** Dispatched, bubbling, from the viewer whenever another segment comes on screen. */
19
+ export const STORY_CHANGE_EVENT = "ui:story-change";
20
+ /** How long a press must last to count as a hold that pauses rather than a tap. */
21
+ const HOLD_MS = 220;
22
+ /** How far a finger must pull the story down for the release to close it. */
23
+ const CLOSE_DISTANCE = 110;
24
+ /** How far a pointer may wander before a press stops counting as a tap. */
25
+ const SLOP = 10;
26
+ /**
27
+ * Runs the viewer it sits in: plays the open group's current segment and moves on when its bar
28
+ * fills, steps on taps and arrow keys, pauses for a hold, the space bar or the pause button,
29
+ * moves between groups by horizontal snap, and closes on a downward swipe or Escape. Typing in
30
+ * a field inside it, such as a reply, holds the story still until the field loses focus.
31
+ */
32
+ export const storyViewerSync = createMixin((handle) => {
33
+ let controller;
34
+ handle.addEventListener("insert", (event) => {
35
+ controller?.abort();
36
+ let viewer = event.node.closest("[data-slot=story-viewer]");
37
+ let track = viewer?.querySelector("[data-slot=story-viewer-track]");
38
+ if (!viewer || !track)
39
+ return;
40
+ controller = new AbortController();
41
+ wireViewer(viewer, track, controller.signal);
42
+ });
43
+ handle.addEventListener("remove", () => {
44
+ controller?.abort();
45
+ controller = undefined;
46
+ });
47
+ });
48
+ /** The groups in viewer order. */
49
+ function groupsOf(track) {
50
+ return [...track.querySelectorAll(":scope > [data-slot=story-viewer-group]")];
51
+ }
52
+ /** A group's segments in order. */
53
+ function segmentsOf(group) {
54
+ return [...group.querySelectorAll("[data-slot=story-viewer-segment]")];
55
+ }
56
+ /** A group's progress bars, one per segment. */
57
+ function barsOf(group) {
58
+ return [...group.querySelectorAll("[data-slot=story-viewer-bar]")];
59
+ }
60
+ /** The index of a group's current segment. */
61
+ function currentOf(group) {
62
+ return Math.max(0, segmentsOf(group).findIndex((segment) => segment.hasAttribute("data-current")));
63
+ }
64
+ /**
65
+ * Wires one viewer until `signal` aborts.
66
+ *
67
+ * @param viewer The viewer's root.
68
+ * @param track The horizontal scroller holding one group per screen.
69
+ * @param signal Ends the wiring.
70
+ */
71
+ function wireViewer(viewer, track, signal) {
72
+ let groups = groupsOf(track);
73
+ let active = Math.max(0, groups.findIndex((group) => group.hasAttribute(STORY_ACTIVE)));
74
+ let close = viewer.querySelector("[data-story-close]");
75
+ let pauseButton = viewer.querySelector("[data-story-pause]");
76
+ let manualPause = false;
77
+ let press = null;
78
+ let holdTimer;
79
+ let swallowClick = false;
80
+ let closing = false;
81
+ let fullScreen = getComputedStyle(viewer).position === "fixed";
82
+ /** Pauses or resumes the bar and any video, keeping the pause button's state in step. */
83
+ function setPaused(paused) {
84
+ viewer.toggleAttribute(STORY_PAUSED, paused);
85
+ pauseButton?.setAttribute("aria-pressed", paused ? "true" : "false");
86
+ syncVideos();
87
+ }
88
+ /** Plays the video of the segment on screen and pauses every other. */
89
+ function syncVideos() {
90
+ let paused = viewer.hasAttribute(STORY_PAUSED);
91
+ groups.forEach((group, index) => {
92
+ let current = currentOf(group);
93
+ segmentsOf(group).forEach((segment, position) => {
94
+ let video = segment.querySelector("video");
95
+ if (video === null)
96
+ return;
97
+ if (index === active && position === current && !paused) {
98
+ video.muted = true;
99
+ video.play().catch(() => undefined);
100
+ }
101
+ else {
102
+ video.pause();
103
+ if (position !== current)
104
+ video.currentTime = 0;
105
+ }
106
+ });
107
+ });
108
+ }
109
+ /** Shows segment `index` of `group`, filling the bars before it and restarting its own. */
110
+ function show(group, index) {
111
+ let segments = segmentsOf(group);
112
+ let bars = barsOf(group);
113
+ segments.forEach((segment, position) => {
114
+ segment.toggleAttribute("data-current", position === index);
115
+ });
116
+ bars.forEach((bar, position) => {
117
+ bar.toggleAttribute("data-done", position < index);
118
+ bar.removeAttribute("data-current");
119
+ });
120
+ let bar = bars[index];
121
+ if (bar !== undefined) {
122
+ void bar.offsetWidth;
123
+ bar.setAttribute("data-current", "");
124
+ }
125
+ syncZones(group);
126
+ syncVideos();
127
+ let href = segments[index]?.dataset.href;
128
+ if (href === undefined || groups[active] !== group)
129
+ return;
130
+ let url = new URL(href, location.href);
131
+ if (`${url.pathname}${url.search}` !== `${location.pathname}${location.search}`) {
132
+ history.replaceState(history.state, "", href);
133
+ }
134
+ viewer.dispatchEvent(new CustomEvent(STORY_CHANGE_EVENT, { bubbles: true, detail: { href } }));
135
+ }
136
+ /** Points a group's tap zones at the segments around its current one, for a middle-click or no script. */
137
+ function syncZones(group) {
138
+ let index = currentOf(group);
139
+ let position = groups.indexOf(group);
140
+ let segments = segmentsOf(group);
141
+ let previous = segments[index - 1]?.dataset.href ??
142
+ (groups[position - 1] && segmentsOf(groups[position - 1]).at(-1)?.dataset.href) ??
143
+ close?.getAttribute("href");
144
+ let next = segments[index + 1]?.dataset.href ??
145
+ (groups[position + 1] && segmentsOf(groups[position + 1])[0]?.dataset.href) ??
146
+ close?.getAttribute("href");
147
+ let zones = group.querySelectorAll("[data-story-zone]");
148
+ for (let zone of zones) {
149
+ let href = zone.dataset.storyZone === "next" ? next : previous;
150
+ if (href)
151
+ zone.setAttribute("href", href);
152
+ }
153
+ }
154
+ /** Makes the group at `index` the one on screen and runs its current segment. */
155
+ function activate(index) {
156
+ active = index;
157
+ groups.forEach((group, position) => group.toggleAttribute(STORY_ACTIVE, position === index));
158
+ let group = groups[index];
159
+ if (group !== undefined)
160
+ show(group, currentOf(group));
161
+ }
162
+ /** Scrolls the track to the group at `index`, or closes past either end. */
163
+ function goToGroup(index, segment) {
164
+ let group = groups[index];
165
+ if (group === undefined) {
166
+ leave();
167
+ return;
168
+ }
169
+ let segments = segmentsOf(group);
170
+ if (segment === "first")
171
+ show(group, 0);
172
+ if (segment === "last")
173
+ show(group, segments.length - 1);
174
+ track.scrollTo({ left: group.offsetLeft, behavior: scrollBehavior() });
175
+ activate(index);
176
+ }
177
+ /** Moves one segment forward, into the next group after the last. */
178
+ function next() {
179
+ let group = groups[active];
180
+ if (group === undefined)
181
+ return;
182
+ let index = currentOf(group);
183
+ if (index < segmentsOf(group).length - 1)
184
+ show(group, index + 1);
185
+ else
186
+ goToGroup(active + 1, "first");
187
+ }
188
+ /** Moves one segment back, into the previous group before the first. */
189
+ function previous() {
190
+ let group = groups[active];
191
+ if (group === undefined)
192
+ return;
193
+ let index = currentOf(group);
194
+ if (index > 0)
195
+ show(group, index - 1);
196
+ else if (active > 0)
197
+ goToGroup(active - 1, "last");
198
+ else
199
+ show(group, 0);
200
+ }
201
+ /** Leaves the viewer through its close link, so the app's own navigation takes it. */
202
+ function leave() {
203
+ if (closing)
204
+ return;
205
+ closing = true;
206
+ close?.click();
207
+ }
208
+ /** Runs a tap zone's step in place, unless the press was a hold or a swipe. */
209
+ function onClick(event) {
210
+ let zone = event.target instanceof Element
211
+ ? event.target.closest("[data-story-zone]")
212
+ : null;
213
+ if (zone === null || event.button !== 0 || event.metaKey || event.ctrlKey || event.shiftKey)
214
+ return;
215
+ event.preventDefault();
216
+ if (swallowClick) {
217
+ swallowClick = false;
218
+ return;
219
+ }
220
+ if (zone.dataset.storyZone === "next")
221
+ next();
222
+ else
223
+ previous();
224
+ }
225
+ /** Starts timing a press for a hold, and tracking it for a swipe down. */
226
+ function onPointerDown(event) {
227
+ if (!event.isPrimary || event.button !== 0)
228
+ return;
229
+ let card = event.target instanceof Element
230
+ ? event.target.closest("[data-slot=story-viewer-card]")
231
+ : null;
232
+ if (card === null || event.target.closest("[data-story-control]"))
233
+ return;
234
+ press = {
235
+ x: event.clientX,
236
+ y: event.clientY,
237
+ id: event.pointerId,
238
+ held: false,
239
+ dragging: false,
240
+ };
241
+ swallowClick = false;
242
+ clearTimeout(holdTimer);
243
+ holdTimer = setTimeout(() => {
244
+ if (press === null || press.dragging)
245
+ return;
246
+ press.held = true;
247
+ setPaused(true);
248
+ }, HOLD_MS);
249
+ }
250
+ /** Follows a downward drag with the card, so the visitor sees the story letting go. */
251
+ function onPointerMove(event) {
252
+ if (press === null || event.pointerId !== press.id)
253
+ return;
254
+ let dx = event.clientX - press.x;
255
+ let dy = event.clientY - press.y;
256
+ if (!press.dragging && dy > SLOP && dy > Math.abs(dx)) {
257
+ press.dragging = true;
258
+ clearTimeout(holdTimer);
259
+ viewer.setAttribute("data-story-dragging", "");
260
+ setPaused(true);
261
+ }
262
+ if (!press.dragging)
263
+ return;
264
+ let pull = Math.max(0, dy);
265
+ viewer.style.setProperty("--ui-story-pull", `${pull}px`);
266
+ viewer.style.setProperty("--ui-story-fade", String(Math.max(0.35, 1 - pull / 600)));
267
+ }
268
+ /** Ends a press: a long enough pull closes, a hold resumes, and either swallows the tap. */
269
+ function onPointerUp(event) {
270
+ if (press === null || event.pointerId !== press.id)
271
+ return;
272
+ clearTimeout(holdTimer);
273
+ let { dragging, held, y } = press;
274
+ press = null;
275
+ if (dragging) {
276
+ swallowClick = true;
277
+ viewer.removeAttribute("data-story-dragging");
278
+ if (event.type === "pointerup" && event.clientY - y >= CLOSE_DISTANCE) {
279
+ leave();
280
+ return;
281
+ }
282
+ viewer.style.removeProperty("--ui-story-pull");
283
+ viewer.style.removeProperty("--ui-story-fade");
284
+ setPaused(manualPause);
285
+ return;
286
+ }
287
+ if (held) {
288
+ swallowClick = true;
289
+ setPaused(manualPause);
290
+ }
291
+ }
292
+ /**
293
+ * Steps, pauses and closes from the keyboard, unless the visitor is typing a reply; a viewer
294
+ * shown inside a box on a longer page answers only keys pressed inside it.
295
+ */
296
+ function onKey(event) {
297
+ if (event.defaultPrevented || event.altKey || event.ctrlKey || event.metaKey)
298
+ return;
299
+ let typing = event.target instanceof Element &&
300
+ event.target.closest("input, textarea, select, [contenteditable]");
301
+ if (typing || !(fullScreen || (event.target instanceof Node && viewer.contains(event.target))))
302
+ return;
303
+ let rtl = getComputedStyle(viewer).direction === "rtl";
304
+ if (event.key === "Escape")
305
+ leave();
306
+ else if (event.key === (rtl ? "ArrowLeft" : "ArrowRight"))
307
+ next();
308
+ else if (event.key === (rtl ? "ArrowRight" : "ArrowLeft"))
309
+ previous();
310
+ else if (event.key === " " || event.key === "k") {
311
+ if (event.target instanceof HTMLButtonElement || event.target instanceof HTMLAnchorElement) {
312
+ if (event.key === " ")
313
+ return;
314
+ }
315
+ manualPause = !viewer.hasAttribute(STORY_PAUSED);
316
+ setPaused(manualPause);
317
+ }
318
+ else
319
+ return;
320
+ event.preventDefault();
321
+ }
322
+ /** Moves on once the bar of the segment on screen fills. */
323
+ function onAnimationEnd(event) {
324
+ let bar = event.target instanceof HTMLElement
325
+ ? event.target.closest("[data-slot=story-viewer-bar]")
326
+ : null;
327
+ if (bar === null || !bar.hasAttribute("data-current"))
328
+ return;
329
+ let group = bar.closest("[data-slot=story-viewer-group]");
330
+ if (group === null || groups.indexOf(group) !== active)
331
+ return;
332
+ next();
333
+ }
334
+ let observer = new IntersectionObserver((entries) => {
335
+ for (let entry of entries) {
336
+ if (!entry.isIntersecting || entry.intersectionRatio < 0.6)
337
+ continue;
338
+ let index = groups.indexOf(entry.target);
339
+ if (index !== -1 && index !== active)
340
+ activate(index);
341
+ }
342
+ }, { root: track, threshold: [0.6] });
343
+ let start = groups[active];
344
+ if (start !== undefined && Math.abs(track.scrollLeft - start.offsetLeft) > 1) {
345
+ track.scrollTo({ left: start.offsetLeft, behavior: "instant" });
346
+ }
347
+ for (let group of groups)
348
+ syncZones(group);
349
+ syncVideos();
350
+ for (let group of groups)
351
+ observer.observe(group);
352
+ viewer.setAttribute(STORY_READY, "");
353
+ if (fullScreen && !viewer.contains(document.activeElement))
354
+ viewer.focus({ preventScroll: true });
355
+ viewer.addEventListener("click", onClick, { signal });
356
+ viewer.addEventListener("pointerdown", onPointerDown, { signal });
357
+ viewer.addEventListener("pointermove", onPointerMove, { signal });
358
+ viewer.addEventListener("pointerup", onPointerUp, { signal });
359
+ viewer.addEventListener("pointercancel", onPointerUp, { signal });
360
+ viewer.addEventListener("animationend", onAnimationEnd, { signal });
361
+ viewer.addEventListener("contextmenu", (event) => press?.held && event.preventDefault(), {
362
+ signal,
363
+ });
364
+ viewer.addEventListener("focusin", (event) => {
365
+ if (event.target instanceof Element && event.target.matches("input, textarea"))
366
+ setPaused(true);
367
+ }, { signal });
368
+ viewer.addEventListener("focusout", (event) => {
369
+ if (event.target instanceof Element && event.target.matches("input, textarea"))
370
+ setPaused(manualPause);
371
+ }, { signal });
372
+ pauseButton?.addEventListener("click", () => {
373
+ manualPause = !viewer.hasAttribute(STORY_PAUSED);
374
+ setPaused(manualPause);
375
+ }, { signal });
376
+ document.addEventListener("keydown", onKey, { signal });
377
+ document.addEventListener("visibilitychange", () => setPaused(document.hidden || manualPause), {
378
+ signal,
379
+ });
380
+ signal.addEventListener("abort", () => {
381
+ observer.disconnect();
382
+ clearTimeout(holdTimer);
383
+ viewer.removeAttribute(STORY_READY);
384
+ for (let video of viewer.querySelectorAll("video"))
385
+ video.pause();
386
+ });
387
+ }
388
+ /** Smooth moves, or instant ones for a visitor who asked for reduced motion. */
389
+ function scrollBehavior() {
390
+ return matchMedia("(prefers-reduced-motion: reduce)").matches ? "instant" : "smooth";
391
+ }
@@ -0,0 +1,95 @@
1
+ /**
2
+ * A full-height vertical feed of short videos, one per screen, the way a reels or shorts tab
3
+ * reads: native scroll snap moves it under the thumb, and its island loads only the reels
4
+ * around the one on screen, plays that one, and steps one reel per key or wheel flick.
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
+ export { REEL_CHANGE_EVENT, reelPreload } from "./mixins/reel-feed-sync.js";
11
+ export type { ReelChangeDetail } from "./mixins/reel-feed-sync.js";
12
+ /** Prop types for {@link ReelFeed} and its parts. */
13
+ export declare namespace ReelFeed {
14
+ /** Every native `<section>` attribute, plus the feed's name and options. */
15
+ interface Props extends TagProps<"section"> {
16
+ /** The feed's accessible name, such as "Reels". */
17
+ label: string;
18
+ /**
19
+ * Puts each reel's `href` in the address bar as it comes on screen, in place, so the
20
+ * address always shares the reel being watched.
21
+ */
22
+ followAddress?: boolean;
23
+ /**
24
+ * Moves on to the next reel when the one on screen reaches its end, the way a reels tab
25
+ * plays through; the last reel loops. Without it every reel loops until the visitor swipes.
26
+ */
27
+ autoAdvance?: boolean;
28
+ /**
29
+ * Runs on from the last reel to the first, by swipe, key, wheel, step control or
30
+ * `autoAdvance`, so the feed never ends; the island adds a copy of the first reel to do it.
31
+ */
32
+ loop?: boolean;
33
+ /**
34
+ * The frame the next reel's page is prefetched into, such as `main`, so moving to it with
35
+ * a link renders without waiting; the document hint is prefetched either way.
36
+ */
37
+ prefetchTarget?: string;
38
+ /** {@link ReelFeed.Item} elements in feed order. */
39
+ children: RemixNode;
40
+ /**
41
+ * Controls beside the scroller, such as up and down arrows: an element marked
42
+ * `data-reel-step="1"` or `"-1"` steps the feed, so a link to the next reel moves it in place;
43
+ * the island keeps its link on the neighbouring reel and marks it `aria-disabled` at an end.
44
+ */
45
+ controls?: RemixNode;
46
+ }
47
+ /** One video source, in the order the browser should try them. */
48
+ interface Source {
49
+ src: string;
50
+ type: string;
51
+ }
52
+ /** Every native `<article>` attribute, plus the reel's video and what sits over it. */
53
+ interface ItemProps extends Omit<TagProps<"article">, "children"> {
54
+ /** The reel's own address, which the feed follows and prefetches. */
55
+ href: string;
56
+ /** The reel's accessible name, such as "Reel by Mara Quint". */
57
+ label: string;
58
+ /**
59
+ * The reel's index minus the index of the reel the page opens on: `0` marks that reel,
60
+ * which the scroller starts at and which autoplays, and the distance sets its `preload`.
61
+ */
62
+ offset: number;
63
+ sources: Source[];
64
+ /** Plays the video only this many seconds before looping, for a clip longer than the reel. */
65
+ loopAt?: number;
66
+ /** Drawn behind the video, for a transparent clip or while it loads. */
67
+ backdrop?: RemixNode;
68
+ /** The stage's play button names: it reads `pause` while playing, pressed once paused. */
69
+ labels: {
70
+ pause: string;
71
+ };
72
+ /** What sits over the video: the author, the caption, the action column. */
73
+ children?: RemixNode;
74
+ }
75
+ }
76
+ /**
77
+ * Renders the feed: a labelled `feed` scroller that snaps one reel per screen, and the island
78
+ * that runs it. It keeps scrolling and snapping without script; the reel at `offset` 0 is
79
+ * where the scroller starts and the one that autoplays.
80
+ *
81
+ * @example
82
+ * <ReelFeed label="Reels" followAddress prefetchTarget="main">
83
+ * {reels.map((reel, index) => <ReelFeed.Item href={reel.href} label={reel.label}
84
+ * offset={index - current} sources={reel.sources} labels={{ pause: "Pause" }} />)}
85
+ * </ReelFeed>
86
+ */
87
+ export declare function ReelFeed(handle: Handle<ReelFeed.Props>): () => import("remix/component").RemixElement;
88
+ export declare namespace ReelFeed {
89
+ var Item: (handle: Handle<ReelFeed.ItemProps>) => () => import("remix/component").RemixElement;
90
+ }
91
+ /**
92
+ * The island inside every {@link ReelFeed}: a hidden marker that runs the feed. It loads from
93
+ * `@sdxc/ui/video/reel-feed`, which the browser entry maps to an import.
94
+ */
95
+ export declare const ReelFeedSync: EntryComponent<Record<never, never>>;
@@ -0,0 +1,124 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "remix/component/jsx-runtime";
2
+ import { PlayIcon } from "@sdxc/icons";
3
+ import { mergeMix, raw } from "@sdxc/u/general";
4
+ import { motionReduce } from "@sdxc/u/responsive";
5
+ import { when } from "@sdxc/u/state";
6
+ import { clientEntry } from "remix/component";
7
+ import { REEL_ACTIVE, REEL_PAUSED, reelFeedSync, reelPreload } from "./mixins/reel-feed-sync.js";
8
+ export { REEL_CHANGE_EVENT, reelPreload } from "./mixins/reel-feed-sync.js";
9
+ /**
10
+ * A one-pixel transparent GIF as the poster, so the drawn backdrop shows through until the
11
+ * first frame instead of the browser's grey placeholder.
12
+ */
13
+ const CLEAR_POSTER = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";
14
+ /** The feed's height, a screen by default, which a page shortens by its own bars. */
15
+ const HEIGHT = "var(--ui-reel-feed-height, 100dvh)";
16
+ /**
17
+ * Renders the feed: a labelled `feed` scroller that snaps one reel per screen, and the island
18
+ * that runs it. It keeps scrolling and snapping without script; the reel at `offset` 0 is
19
+ * where the scroller starts and the one that autoplays.
20
+ *
21
+ * @example
22
+ * <ReelFeed label="Reels" followAddress prefetchTarget="main">
23
+ * {reels.map((reel, index) => <ReelFeed.Item href={reel.href} label={reel.label}
24
+ * offset={index - current} sources={reel.sources} labels={{ pause: "Pause" }} />)}
25
+ * </ReelFeed>
26
+ */
27
+ export function ReelFeed(handle) {
28
+ return () => {
29
+ let { autoAdvance, children, controls, followAddress, label, loop, mix, prefetchTarget, ...rest } = handle.props;
30
+ return (_jsxs("section", { ...rest, "aria-label": label, "data-slot": "reel-feed", "data-follow-address": followAddress ? "" : undefined, "data-auto-advance": autoAdvance ? "" : undefined, "data-loop": loop ? "" : undefined, "data-prefetch-target": prefetchTarget, mix: mergeMix([raw({ position: "relative", blockSize: HEIGHT, minInlineSize: "0" })], mix), children: [_jsx("div", { role: "feed", "aria-label": label, "data-slot": "reel-feed-scroller", mix: [
31
+ raw({
32
+ blockSize: "100%",
33
+ overflowX: "hidden",
34
+ overflowY: "auto",
35
+ overscrollBehavior: "contain",
36
+ scrollSnapType: "y mandatory",
37
+ scrollbarWidth: "none",
38
+ outline: "none",
39
+ "&::-webkit-scrollbar": { display: "none" },
40
+ }),
41
+ when("&:focus-visible", raw({ boxShadow: "inset 0 0 0 2px var(--ui-brand-ring)" })),
42
+ ], children: children }), controls, _jsx(ReelFeedSync, {})] }));
43
+ };
44
+ }
45
+ /**
46
+ * One reel: a screen-high snap point holding a stage as tall as the feed and at most 9:16
47
+ * wide, with the backdrop, the video, a full-stage play button and the overlay over it, and
48
+ * a progress line along its foot.
49
+ */
50
+ ReelFeed.Item = function ReelFeedItem(handle) {
51
+ return () => {
52
+ let { backdrop, children, href, label, labels, loopAt, mix, offset, sources, ...rest } = handle.props;
53
+ let current = offset === 0;
54
+ return (_jsxs("article", { ...rest, "aria-label": label, "data-slot": "reel-feed-item", "data-href": href, [REEL_ACTIVE]: current ? "" : undefined, mix: mergeMix([
55
+ raw({
56
+ position: "relative",
57
+ blockSize: "100%",
58
+ containerType: "size",
59
+ scrollSnapAlign: "start",
60
+ scrollSnapStop: "always",
61
+ display: "grid",
62
+ placeItems: "center",
63
+ overflow: "hidden",
64
+ }),
65
+ raw(current ? { scrollInitialTarget: "nearest" } : {}),
66
+ ], mix), children: [_jsxs("div", { "data-slot": "reel-feed-stage", mix: [
67
+ raw({
68
+ position: "relative",
69
+ blockSize: "100%",
70
+ inlineSize: "min(100cqi, 56.25cqb)",
71
+ overflow: "hidden",
72
+ backgroundColor: "oklch(0.16 0.01 280)",
73
+ borderRadius: "var(--ui-reel-feed-radius, 0)",
74
+ isolation: "isolate",
75
+ }),
76
+ ], children: [backdrop === undefined ? null : (_jsx("div", { "aria-hidden": "true", "data-slot": "reel-feed-backdrop", mix: [layer()], children: backdrop })), _jsx("video", { "data-reel-video": "", "data-loop-at": loopAt === undefined ? undefined : String(loopAt), preload: reelPreload(offset), poster: CLEAR_POSTER, autoplay: current, muted: true, loop: true, playsinline: true, "aria-hidden": "true", mix: [layer(), raw({ objectFit: "cover" })], children: sources.map((source) => (_jsx("source", { src: source.src, type: source.type }))) }), _jsx("button", { type: "button", "data-reel-toggle": "", "aria-label": labels.pause, "aria-pressed": "false", mix: [
77
+ layer(),
78
+ raw({
79
+ display: "grid",
80
+ placeItems: "center",
81
+ padding: "0",
82
+ border: "0",
83
+ background: "transparent",
84
+ color: "oklch(0.99 0 0)",
85
+ cursor: "pointer",
86
+ "& > svg": {
87
+ inlineSize: "4rem",
88
+ blockSize: "4rem",
89
+ padding: "1rem",
90
+ borderRadius: "999px",
91
+ backgroundColor: "rgb(0 0 0 / 0.45)",
92
+ opacity: "0",
93
+ transform: "scale(0.85)",
94
+ transition: "opacity 160ms ease, transform 160ms ease",
95
+ },
96
+ }),
97
+ when(`[${REEL_PAUSED}] > [data-slot=reel-feed-stage] > & > svg`, raw({ opacity: "1", transform: "scale(1)" })),
98
+ when("&:focus-visible", raw({ outline: "2px solid var(--ui-brand-ring)", outlineOffset: "-4px" })),
99
+ motionReduce(raw({ "& > svg": { transition: "none" } })),
100
+ ], children: _jsx(PlayIcon, { "aria-hidden": "true", fill: "currentColor" }) }), children === undefined ? null : (_jsx("div", { "data-slot": "reel-feed-overlay", mix: [layer(), raw({ pointerEvents: "none", "& > *": { pointerEvents: "auto" } })], children: children })), _jsx("span", { "aria-hidden": "true", "data-slot": "reel-feed-progress", mix: [
101
+ raw({
102
+ position: "absolute",
103
+ insetInline: "0",
104
+ insetBlockEnd: "0",
105
+ blockSize: "2px",
106
+ backgroundColor: "rgb(255 255 255 / 0.85)",
107
+ transformOrigin: "left",
108
+ transform: "scaleX(var(--ui-reel-progress, 0))",
109
+ pointerEvents: "none",
110
+ }),
111
+ ] })] }), offset === 1 ? _jsx("link", { rel: "prefetch", href: href, "data-reel-next": "" }) : null] }));
112
+ };
113
+ };
114
+ /** A layer filling the stage, stacked in source order. */
115
+ function layer() {
116
+ return raw({ position: "absolute", inset: "0", inlineSize: "100%", blockSize: "100%" });
117
+ }
118
+ /**
119
+ * The island inside every {@link ReelFeed}: a hidden marker that runs the feed. It loads from
120
+ * `@sdxc/ui/video/reel-feed`, which the browser entry maps to an import.
121
+ */
122
+ export const ReelFeedSync = clientEntry("@sdxc/ui/video/reel-feed#ReelFeedSync", function ReelFeedSync() {
123
+ return () => _jsx("span", { hidden: true, mix: [reelFeedSync()] });
124
+ });
@@ -0,0 +1,32 @@
1
+ /**
2
+ * A picture in a ring that says whether there is a story to watch: a bright ring for one not
3
+ * yet seen, a thin quiet one once it has been, and a gap between ring and picture so it reads
4
+ * at any size. A row of them is a story tray, and a profile's highlights.
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 StoryRing}. */
11
+ export declare namespace StoryRing {
12
+ /** Every native `<span>` attribute, plus the picture and its state. */
13
+ interface Props extends Omit<TagProps<"span">, "children"> {
14
+ /** The picture inside the ring: an avatar, a drawn cover. */
15
+ children: RemixNode;
16
+ /** Whether every story behind it has been seen, which quiets the ring. Default: `false`. */
17
+ seen?: boolean;
18
+ /**
19
+ * The ring's outer size in rem, or a CSS length, such as a custom property a page
20
+ * changes with its width. Default: `4`.
21
+ */
22
+ size?: number | string;
23
+ }
24
+ }
25
+ /**
26
+ * Renders the ring around its picture, its size set on the element itself so every ring shares
27
+ * one set of rules and the seen state always wins. The unseen ring paints `--ui-story-ring`, the brand's
28
+ * solid colour unless a page names a gradient; the seen ring paints the quiet border colour.
29
+ *
30
+ * @example <StoryRing seen={person.seen}><Avatar src={person.photo} alt="" /></StoryRing>
31
+ */
32
+ export declare function StoryRing(handle: Handle<StoryRing.Props>): () => import("remix/component").RemixElement;