@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,283 @@
1
+ /**
2
+ * Turns a server-rendered `Autocomplete` into an ARIA combobox: the native `<datalist>` gives
3
+ * way to a styled listbox that filters as the reader types, walks with the arrows and picks on
4
+ * Enter or a press. Without script the field keeps its datalist and submits the typed text.
5
+ *
6
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
7
+ * @copyright Sergio Xalambrí 2026
8
+ */
9
+ import { createMixin } from "remix/component";
10
+ import { chooseOption, chosenOption } from "./active-descendant-keys.js";
11
+ /** Name of the bubbling event a pick dispatches on the field, carrying {@link AutocompleteSelectDetail}. */
12
+ export const AUTOCOMPLETE_SELECT_EVENT = "autocomplete-select";
13
+ /** Gap, in pixels, between the field and the list under it, and between the list and the viewport. */
14
+ const GAP = 6;
15
+ /** Height, in pixels, below which the list opens above the field when there is more room there. */
16
+ const MIN_LIST_HEIGHT = 200;
17
+ /** Widest a list grows past a narrow field, in pixels, before the viewport caps it. */
18
+ const MIN_LIST_WIDTH = 256;
19
+ /** Collects the parts under `root`, or `null` when its markup is incomplete. */
20
+ function partsOf(root) {
21
+ let input = root.querySelector("[data-autocomplete-input]");
22
+ let popup = root.querySelector("[data-autocomplete-popup]");
23
+ let listbox = root.querySelector("[data-autocomplete-listbox]");
24
+ if (!input || !popup || !listbox)
25
+ return null;
26
+ return {
27
+ root,
28
+ input,
29
+ popup,
30
+ listbox,
31
+ options: Array.from(listbox.querySelectorAll("[data-autocomplete-option]")),
32
+ heading: root.querySelector("[data-autocomplete-heading]"),
33
+ empty: root.querySelector("[data-autocomplete-empty]"),
34
+ hidden: root.querySelector("[data-autocomplete-value]"),
35
+ };
36
+ }
37
+ /**
38
+ * Writes `text` into `target`, wrapping its first case-insensitive occurrence of `query` in a
39
+ * `<mark>`, so the reader sees why each option matched.
40
+ */
41
+ function highlight(target, text, query) {
42
+ if (!target)
43
+ return;
44
+ let at = query ? text.toLowerCase().indexOf(query) : -1;
45
+ if (at < 0) {
46
+ target.replaceChildren(text);
47
+ return;
48
+ }
49
+ let mark = target.ownerDocument.createElement("mark");
50
+ mark.textContent = text.slice(at, at + query.length);
51
+ target.replaceChildren(text.slice(0, at), mark, text.slice(at + query.length));
52
+ }
53
+ /**
54
+ * Shows the options whose label or description holds the typed text, ignoring case, and gives
55
+ * every other one up as an option, so the arrows only walk what is on screen. The heading
56
+ * shows while the field is empty, and the empty message while nothing matches.
57
+ */
58
+ function filter(parts) {
59
+ let query = parts.input.value.trim().toLowerCase();
60
+ let shown = 0;
61
+ for (let option of parts.options) {
62
+ let label = option.dataset.label ?? "";
63
+ let description = option.dataset.description ?? "";
64
+ let match = query === "" ||
65
+ label.toLowerCase().includes(query) ||
66
+ description.toLowerCase().includes(query);
67
+ option.hidden = !match;
68
+ option.setAttribute("role", match ? "option" : "presentation");
69
+ if (match)
70
+ shown += 1;
71
+ highlight(option.querySelector("[data-autocomplete-label]"), label, query);
72
+ highlight(option.querySelector("[data-autocomplete-description]"), description, query);
73
+ }
74
+ if (parts.heading)
75
+ parts.heading.hidden = query !== "";
76
+ if (parts.empty)
77
+ parts.empty.hidden = shown > 0;
78
+ chooseOption(parts.input, -1);
79
+ }
80
+ /**
81
+ * Places the list under the field in viewport coordinates, as wide as the field and never
82
+ * past the viewport's edges, flipping above it when the room below is short and above is not.
83
+ */
84
+ function place(parts) {
85
+ let view = parts.input.ownerDocument.documentElement;
86
+ let rect = parts.input.getBoundingClientRect();
87
+ let viewWidth = view.clientWidth;
88
+ let viewHeight = view.clientHeight;
89
+ let width = Math.min(Math.max(rect.width, MIN_LIST_WIDTH), viewWidth - GAP * 2);
90
+ let left = Math.max(GAP, Math.min(rect.left, viewWidth - width - GAP));
91
+ let below = viewHeight - rect.bottom - GAP * 2;
92
+ let above = rect.top - GAP * 2;
93
+ let flip = below < MIN_LIST_HEIGHT && above > below;
94
+ let style = parts.popup.style;
95
+ style.setProperty("left", `${left}px`);
96
+ style.setProperty("inline-size", `${width}px`);
97
+ style.setProperty("max-block-size", `${Math.max(flip ? above : below, 0)}px`);
98
+ if (flip) {
99
+ style.removeProperty("top");
100
+ style.setProperty("bottom", `${viewHeight - rect.top + GAP}px`);
101
+ }
102
+ else {
103
+ style.removeProperty("bottom");
104
+ style.setProperty("top", `${rect.bottom + GAP}px`);
105
+ }
106
+ }
107
+ /** Whether the list is showing. */
108
+ function isOpen(parts) {
109
+ return parts.popup.matches(":popover-open");
110
+ }
111
+ /** Shows the list under the field. */
112
+ function open(parts) {
113
+ if (parts.input.disabled || parts.input.readOnly)
114
+ return;
115
+ if (!isOpen(parts))
116
+ parts.popup.showPopover();
117
+ place(parts);
118
+ parts.input.setAttribute("aria-expanded", "true");
119
+ }
120
+ /** Hides the list and drops the active option. */
121
+ function close(parts) {
122
+ if (isOpen(parts))
123
+ parts.popup.hidePopover();
124
+ parts.input.setAttribute("aria-expanded", "false");
125
+ chooseOption(parts.input, -1);
126
+ }
127
+ /** The options the typed text left showing, in document order. */
128
+ function shownOptions(parts) {
129
+ return parts.options.filter((option) => !option.hidden);
130
+ }
131
+ /**
132
+ * Fills the field with `option`'s label and its value into the hidden field, closes the list,
133
+ * and tells the page as a native pick would: a bubbling `change`, then
134
+ * {@link AUTOCOMPLETE_SELECT_EVENT} with the value and label.
135
+ */
136
+ function pick(parts, option) {
137
+ let label = option.dataset.label ?? "";
138
+ let value = option.dataset.value ?? "";
139
+ parts.input.value = label;
140
+ if (parts.hidden)
141
+ parts.hidden.value = value;
142
+ parts.root.dataset.picked = label;
143
+ close(parts);
144
+ filter(parts);
145
+ parts.input.dispatchEvent(new Event("change", { bubbles: true }));
146
+ parts.input.dispatchEvent(new CustomEvent(AUTOCOMPLETE_SELECT_EVENT, {
147
+ bubbles: true,
148
+ detail: { value, label },
149
+ }));
150
+ }
151
+ /**
152
+ * Moves the active option by `step` through the showing options, wrapping at both ends, and
153
+ * opens the list first when it is closed.
154
+ */
155
+ function move(parts, step) {
156
+ open(parts);
157
+ let rows = shownOptions(parts);
158
+ if (rows.length === 0)
159
+ return;
160
+ let current = chosenOption(parts.input);
161
+ let next = current + step;
162
+ if (current < 0 && step < 0)
163
+ next = rows.length - 1;
164
+ if (next >= rows.length)
165
+ next = 0;
166
+ if (next < 0)
167
+ next = rows.length - 1;
168
+ chooseOption(parts.input, next);
169
+ }
170
+ /** Answers the field's keys: arrows walk, Enter picks without submitting, Escape closes then clears. */
171
+ function onKeyDown(parts, event) {
172
+ if (event.defaultPrevented || event.isComposing)
173
+ return;
174
+ if (event.key === "ArrowDown") {
175
+ event.preventDefault();
176
+ if (event.altKey)
177
+ open(parts);
178
+ else
179
+ move(parts, 1);
180
+ }
181
+ else if (event.key === "ArrowUp") {
182
+ event.preventDefault();
183
+ move(parts, -1);
184
+ }
185
+ else if (event.key === "Enter") {
186
+ let row = shownOptions(parts)[chosenOption(parts.input)];
187
+ if (!isOpen(parts) || !row)
188
+ return;
189
+ event.preventDefault();
190
+ pick(parts, row);
191
+ }
192
+ else if (event.key === "Escape") {
193
+ if (isOpen(parts)) {
194
+ event.preventDefault();
195
+ close(parts);
196
+ }
197
+ else if (parts.input.value !== "") {
198
+ event.preventDefault();
199
+ parts.input.value = "";
200
+ edited(parts);
201
+ }
202
+ }
203
+ else if (event.key === "Tab")
204
+ close(parts);
205
+ }
206
+ /** Refilters after the text changed, and forgets a picked value once the text no longer reads as it. */
207
+ function edited(parts) {
208
+ if (parts.input.value !== parts.root.dataset.picked) {
209
+ if (parts.hidden)
210
+ parts.hidden.value = "";
211
+ delete parts.root.dataset.picked;
212
+ }
213
+ filter(parts);
214
+ }
215
+ /**
216
+ * Wires every listener for one autocomplete, removed through `signal`. A press inside the list
217
+ * keeps focus in the field, so the field's blur alone closes the list on a click elsewhere or
218
+ * on Tab; scroll and resize keep an open list under its field.
219
+ */
220
+ function enhance(parts, signal) {
221
+ let { input, popup, root } = parts;
222
+ let options = { signal };
223
+ input.removeAttribute("list");
224
+ input.setAttribute("role", "combobox");
225
+ input.setAttribute("aria-autocomplete", "list");
226
+ input.setAttribute("aria-expanded", "false");
227
+ input.setAttribute("aria-controls", parts.listbox.id);
228
+ root.dataset.enhanced = "";
229
+ filter(parts);
230
+ input.addEventListener("focus", () => open(parts), options);
231
+ input.addEventListener("click", () => open(parts), options);
232
+ input.addEventListener("input", () => {
233
+ edited(parts);
234
+ open(parts);
235
+ }, options);
236
+ input.addEventListener("keydown", (event) => onKeyDown(parts, event), options);
237
+ input.addEventListener("blur", () => close(parts), options);
238
+ popup.addEventListener("pointerdown", (event) => event.preventDefault(), options);
239
+ popup.addEventListener("pointermove", (event) => {
240
+ let row = event.target instanceof Element ? event.target.closest("[role='option']") : null;
241
+ if (!(row instanceof HTMLElement))
242
+ return;
243
+ let index = shownOptions(parts).indexOf(row);
244
+ if (index >= 0 && index !== chosenOption(input))
245
+ chooseOption(input, index);
246
+ }, options);
247
+ popup.addEventListener("click", (event) => {
248
+ let row = event.target instanceof Element ? event.target.closest("[role='option']") : null;
249
+ if (row instanceof HTMLElement)
250
+ pick(parts, row);
251
+ }, options);
252
+ let view = input.ownerDocument.defaultView;
253
+ /** Keeps an open list under its field as the page scrolls or resizes. */
254
+ function reposition() {
255
+ if (isOpen(parts))
256
+ place(parts);
257
+ }
258
+ view?.addEventListener("resize", reposition, options);
259
+ view?.addEventListener("scroll", reposition, { signal, capture: true, passive: true });
260
+ }
261
+ /**
262
+ * Enhances the `[data-slot="autocomplete"]` around the host into a combobox over its styled
263
+ * list, and undoes nothing on removal beyond dropping its listeners. Mount it on a hidden
264
+ * element inside the autocomplete, which is how the island that carries it renders.
265
+ *
266
+ * @example <span hidden mix={autocomplete()} />
267
+ */
268
+ export const autocomplete = createMixin((handle) => {
269
+ let controller;
270
+ handle.addEventListener("insert", (event) => {
271
+ controller?.abort();
272
+ let root = event.node.closest('[data-slot="autocomplete"]');
273
+ let parts = root ? partsOf(root) : null;
274
+ if (!parts)
275
+ return;
276
+ controller = new AbortController();
277
+ enhance(parts, controller.signal);
278
+ });
279
+ handle.addEventListener("remove", () => {
280
+ controller?.abort();
281
+ controller = undefined;
282
+ });
283
+ });
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * Handles the `--ui-prev`, `--ui-next`, and `--ui-goto` commands a Carousel's
3
- * invoker buttons dispatch at its viewport, turning each into an
4
- * `Element.scrollBy()` call, and keeps every matching invoker's `disabled`
5
- * state in sync with whichever scroll edge the viewport currently sits at.
3
+ * invoker buttons dispatch at its viewport, turning each into a scroll, and keeps
4
+ * every matching invoker's `disabled` state, the current dot and any `n / N` count
5
+ * in step with the slide in view.
6
6
  *
7
7
  * @author [Sergio Xalambrí](https://sergiodxa.com)
8
8
  * @copyright Sergio Xalambrí 2026
@@ -30,3 +30,14 @@ export declare const CAROUSEL_SLIDE_ATTRIBUTE = "data-carousel-slide";
30
30
  * <button commandfor="cart-carousel" command="--ui-goto" data-slide="1">Slide 2</button>
31
31
  */
32
32
  export declare const carouselControls: import("remix/component").MixinFactory<HTMLElement, [], import("remix/component").ElementProps>;
33
+ /** Set on a Carousel root once {@link carouselSync} runs it, for controls that need script. */
34
+ export declare const CAROUSEL_READY_ATTRIBUTE = "data-carousel-ready";
35
+ /**
36
+ * Runs the Carousel it sits in from a hidden host anywhere inside the carousel root, so a
37
+ * server-rendered carousel gets the same command handling, arrow and dot state and `n / N`
38
+ * counts as {@link carouselControls} without the page writing an island around its viewport.
39
+ * It marks the root with {@link CAROUSEL_READY_ATTRIBUTE} while it runs.
40
+ *
41
+ * @example <span hidden mix={[carouselSync()]} />
42
+ */
43
+ export declare const carouselSync: import("remix/component").MixinFactory<HTMLElement, [], import("remix/component").ElementProps>;
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * Handles the `--ui-prev`, `--ui-next`, and `--ui-goto` commands a Carousel's
3
- * invoker buttons dispatch at its viewport, turning each into an
4
- * `Element.scrollBy()` call, and keeps every matching invoker's `disabled`
5
- * state in sync with whichever scroll edge the viewport currently sits at.
3
+ * invoker buttons dispatch at its viewport, turning each into a scroll, and keeps
4
+ * every matching invoker's `disabled` state, the current dot and any `n / N` count
5
+ * in step with the slide in view.
6
6
  *
7
7
  * @author [Sergio Xalambrí](https://sergiodxa.com)
8
8
  * @copyright Sergio Xalambrí 2026
@@ -147,6 +147,46 @@ function syncGotoCurrent(node) {
147
147
  button.removeAttribute("aria-current");
148
148
  }
149
149
  }
150
+ /**
151
+ * Writes `n / N` into every count naming the viewport (`data-carousel-count-for`), so the
152
+ * position reads the same as the dots.
153
+ *
154
+ * @param node Carousel viewport whose scroll position is read.
155
+ */
156
+ function syncCount(node) {
157
+ if (node.id === "")
158
+ return;
159
+ let current = readCurrentSlideIndex(node);
160
+ if (current === null)
161
+ return;
162
+ let total = node.querySelectorAll(`[${CAROUSEL_SLIDE_ATTRIBUTE}]`).length;
163
+ for (let count of document.querySelectorAll(`[data-carousel-count-for="${CSS.escape(node.id)}"]`)) {
164
+ count.textContent = `${current + 1} / ${total}`;
165
+ }
166
+ }
167
+ /** Re-syncs everything that reports a viewport's position: arrows, dots and counts. */
168
+ function syncAll(node) {
169
+ syncInvokerDisabled(node);
170
+ syncGotoCurrent(node);
171
+ syncCount(node);
172
+ }
173
+ /** Runs one `--ui-prev`, `--ui-next` or `--ui-goto` command against a viewport. */
174
+ function runCommand(viewport, event) {
175
+ let commandEvent = asCommandEvent(event);
176
+ switch (commandEvent.command) {
177
+ case PREV_COMMAND:
178
+ scrollByPage(viewport, -1);
179
+ return;
180
+ case NEXT_COMMAND:
181
+ scrollByPage(viewport, 1);
182
+ return;
183
+ case GOTO_COMMAND: {
184
+ let index = readGotoSlideIndex(commandEvent.source);
185
+ if (index !== null)
186
+ scrollToSlide(viewport, index);
187
+ }
188
+ }
189
+ }
150
190
  /**
151
191
  * Parses a `--ui-goto` command's target slide index from its invoking
152
192
  * button's `data-slide` attribute.
@@ -231,38 +271,57 @@ function syncInvokerDisabled(node) {
231
271
  export const carouselControls = createMixin((handle) => {
232
272
  handle.addEventListener("insert", (event) => {
233
273
  let viewport = event.node;
234
- syncInvokerDisabled(viewport);
235
- syncGotoCurrent(viewport);
236
- let observer = new ResizeObserver(() => {
237
- syncInvokerDisabled(viewport);
238
- syncGotoCurrent(viewport);
239
- });
274
+ syncAll(viewport);
275
+ let observer = new ResizeObserver(() => syncAll(viewport));
240
276
  observer.observe(viewport);
241
277
  handle.signal.addEventListener("abort", () => observer.disconnect());
242
278
  });
243
279
  return () => createElement(handle.element, {
244
280
  mix: [
245
- on("command", (event) => {
246
- let commandEvent = asCommandEvent(event);
247
- let viewport = event.currentTarget;
248
- switch (commandEvent.command) {
249
- case PREV_COMMAND:
250
- scrollByPage(viewport, -1);
251
- return;
252
- case NEXT_COMMAND:
253
- scrollByPage(viewport, 1);
254
- return;
255
- case GOTO_COMMAND: {
256
- let index = readGotoSlideIndex(commandEvent.source);
257
- if (index !== null)
258
- scrollToSlide(viewport, index);
259
- }
260
- }
261
- }),
262
- on("scroll", (event) => {
263
- syncInvokerDisabled(event.currentTarget);
264
- syncGotoCurrent(event.currentTarget);
265
- }),
281
+ on("command", (event) => runCommand(event.currentTarget, event)),
282
+ on("scroll", (event) => syncAll(event.currentTarget)),
266
283
  ],
267
284
  });
268
285
  });
286
+ /** Set on a Carousel root once {@link carouselSync} runs it, for controls that need script. */
287
+ export const CAROUSEL_READY_ATTRIBUTE = "data-carousel-ready";
288
+ /**
289
+ * Runs the Carousel it sits in from a hidden host anywhere inside the carousel root, so a
290
+ * server-rendered carousel gets the same command handling, arrow and dot state and `n / N`
291
+ * counts as {@link carouselControls} without the page writing an island around its viewport.
292
+ * It marks the root with {@link CAROUSEL_READY_ATTRIBUTE} while it runs.
293
+ *
294
+ * @example <span hidden mix={[carouselSync()]} />
295
+ */
296
+ export const carouselSync = createMixin((handle) => {
297
+ let controller;
298
+ handle.addEventListener("insert", (event) => {
299
+ controller?.abort();
300
+ let root = event.node.closest("[data-slot=carousel]");
301
+ let viewport = root?.querySelector("[data-slot=viewport]");
302
+ if (!root || !viewport)
303
+ return;
304
+ let wired = new AbortController();
305
+ controller = wired;
306
+ let target = viewport;
307
+ target.addEventListener("command", (command) => runCommand(target, command), {
308
+ signal: wired.signal,
309
+ });
310
+ target.addEventListener("scroll", () => syncAll(target), {
311
+ passive: true,
312
+ signal: wired.signal,
313
+ });
314
+ let observer = new ResizeObserver(() => syncAll(target));
315
+ observer.observe(target);
316
+ root.setAttribute(CAROUSEL_READY_ATTRIBUTE, "");
317
+ syncAll(target);
318
+ wired.signal.addEventListener("abort", () => {
319
+ observer.disconnect();
320
+ root.removeAttribute(CAROUSEL_READY_ATTRIBUTE);
321
+ });
322
+ });
323
+ handle.addEventListener("remove", () => {
324
+ controller?.abort();
325
+ controller = undefined;
326
+ });
327
+ });
@@ -8,6 +8,7 @@
8
8
  */
9
9
  export * from "./active-descendant-keys.js";
10
10
  export * from "./aria-checked.js";
11
+ export * from "./autocomplete.js";
11
12
  export * from "./calendar-keys.js";
12
13
  export * from "./carousel-controls.js";
13
14
  export * from "./character-count.js";
@@ -27,6 +28,7 @@ export * from "./hotkey.js";
27
28
  export * from "./image-fallback.js";
28
29
  export * from "./invoker-fields.js";
29
30
  export * from "./keymap.js";
31
+ export * from "./lightbox-controls.js";
30
32
  export * from "./listbox-keys.js";
31
33
  export * from "./live-frame.js";
32
34
  export * from "./long-press.js";
@@ -8,6 +8,7 @@
8
8
  */
9
9
  export * from "./active-descendant-keys.js";
10
10
  export * from "./aria-checked.js";
11
+ export * from "./autocomplete.js";
11
12
  export * from "./calendar-keys.js";
12
13
  export * from "./carousel-controls.js";
13
14
  export * from "./character-count.js";
@@ -27,6 +28,7 @@ export * from "./hotkey.js";
27
28
  export * from "./image-fallback.js";
28
29
  export * from "./invoker-fields.js";
29
30
  export * from "./keymap.js";
31
+ export * from "./lightbox-controls.js";
30
32
  export * from "./listbox-keys.js";
31
33
  export * from "./live-frame.js";
32
34
  export * from "./long-press.js";
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Script layer for a Lightbox `<dialog>`: Left/Right arrow keys step through the photos, a
3
+ * trigger opens the viewer as a modal at the photo it names, the step links scroll in place,
4
+ * and the photo in view is marked current and announced as the track scrolls.
5
+ *
6
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
7
+ * @copyright Sergio Xalambrí 2026
8
+ */
9
+ import type { ElementProps, MixinFactory } from "remix/component";
10
+ /** Attribute on the scroll-snap track holding every slide. */
11
+ export declare const LIGHTBOX_TRACK_ATTRIBUTE = "data-lightbox-track";
12
+ /** Attribute on each slide, in photo order. */
13
+ export declare const LIGHTBOX_SLIDE_ATTRIBUTE = "data-lightbox-slide";
14
+ /** Attribute a trigger carries naming the zero-based photo it opens at. */
15
+ export declare const LIGHTBOX_INDEX_ATTRIBUTE = "data-lightbox-index";
16
+ /** Attribute a step link carries naming the zero-based photo it scrolls to. */
17
+ export declare const LIGHTBOX_STEP_ATTRIBUTE = "data-lightbox-to";
18
+ /** Attribute on the dialog naming the photo a server-opened viewer starts on. */
19
+ export declare const LIGHTBOX_INITIAL_ATTRIBUTE = "data-lightbox-initial";
20
+ /** Attribute on the polite live region that names the photo in view. */
21
+ export declare const LIGHTBOX_STATUS_ATTRIBUTE = "data-lightbox-status";
22
+ /** Attribute on each slide's counter and caption, read into the announcement. */
23
+ export declare const LIGHTBOX_ANNOUNCE_ATTRIBUTE = "data-lightbox-announce";
24
+ /**
25
+ * Attaches the viewer behavior to the `<dialog>` the host sits in, from insertion until
26
+ * removal. A dialog the server rendered open at a photo is upgraded to a modal there.
27
+ *
28
+ * @example
29
+ * <dialog id="photos">
30
+ * <span hidden mix={[lightboxControls()]} />
31
+ * <div data-lightbox-track>…</div>
32
+ * </dialog>
33
+ */
34
+ export declare const lightboxControls: MixinFactory<HTMLElement, [], ElementProps>;