@zazz-ui/core 0.13.1 → 0.14.1

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 (88) hide show
  1. package/CHANGELOG.md +93 -0
  2. package/README.md +5 -9
  3. package/dist/sri.json +35 -31
  4. package/dist/zazz.css +1 -1
  5. package/dist/zazz.js +1 -1
  6. package/editor/zazz.css-data.json +173 -3
  7. package/editor/zazz.html-data.json +138 -0
  8. package/editor/zazz.language-data.json +313 -125
  9. package/editor/zazz.lint-data.json +1501 -1383
  10. package/package.json +1 -5
  11. package/src/base/_defaults.css +1 -1
  12. package/src/base/_reset.css +16 -2
  13. package/src/base/_variables.css +43 -31
  14. package/src/base/carousel-scroll.d.ts +161 -0
  15. package/src/base/carousel-scroll.d.ts.map +1 -0
  16. package/src/base/carousel-scroll.js +1035 -0
  17. package/src/base/carousel-scroll.ts +1227 -0
  18. package/src/base/carousel.d.ts +34 -0
  19. package/src/base/carousel.d.ts.map +1 -0
  20. package/src/base/carousel.js +279 -0
  21. package/src/base/carousel.ts +292 -0
  22. package/src/base/dialog-lifecycle.js +1 -1
  23. package/src/base/dialog-lifecycle.ts +1 -1
  24. package/src/base/gesture.d.ts +201 -0
  25. package/src/base/gesture.d.ts.map +1 -0
  26. package/src/base/gesture.js +317 -0
  27. package/src/base/gesture.ts +494 -0
  28. package/src/base/kit-styling.d.ts.map +1 -1
  29. package/src/base/kit-styling.js +182 -162
  30. package/src/base/kit-styling.ts +182 -162
  31. package/src/base/navigation.d.ts +12 -1
  32. package/src/base/navigation.d.ts.map +1 -1
  33. package/src/base/navigation.js +65 -1
  34. package/src/base/navigation.ts +66 -1
  35. package/src/base/utils.d.ts +1 -1
  36. package/src/base/utils.js +2 -2
  37. package/src/base/utils.ts +2 -2
  38. package/src/globals.d.ts +7 -30
  39. package/src/head.d.ts.map +1 -1
  40. package/src/head.js +1 -25
  41. package/src/head.ts +1 -25
  42. package/src/index.css +1 -0
  43. package/src/index.d.ts +6 -5
  44. package/src/index.d.ts.map +1 -1
  45. package/src/index.js +6 -5
  46. package/src/index.ts +6 -5
  47. package/src/manifest.d.ts +1 -1
  48. package/src/manifest.d.ts.map +1 -1
  49. package/src/manifest.js +25 -13
  50. package/src/manifest.ts +26 -14
  51. package/src/primitives/button/button.css +1 -1
  52. package/src/primitives/carousel/carousel.css +103 -20
  53. package/src/primitives/carousel/carousel.d.ts +4 -32
  54. package/src/primitives/carousel/carousel.d.ts.map +1 -1
  55. package/src/primitives/carousel/carousel.js +39 -14
  56. package/src/primitives/carousel/carousel.ts +21 -25
  57. package/src/primitives/dialog/dialog.css +14 -8
  58. package/src/primitives/drawer/drawer-indent.html +27 -0
  59. package/src/primitives/drawer/drawer-nested.html +72 -0
  60. package/src/primitives/drawer/drawer-responsive-dialog.html +44 -0
  61. package/src/primitives/drawer/drawer-snap.html +26 -0
  62. package/src/primitives/drawer/drawer.css +528 -0
  63. package/src/primitives/drawer/drawer.d.ts +24 -0
  64. package/src/primitives/drawer/drawer.d.ts.map +1 -0
  65. package/src/primitives/drawer/drawer.html +42 -0
  66. package/src/primitives/drawer/drawer.js +765 -0
  67. package/src/primitives/drawer/drawer.ts +823 -0
  68. package/src/primitives/fields/fields.css +4 -2
  69. package/src/primitives/input/input.css +1 -1
  70. package/src/primitives/input-group/input-group.css +5 -5
  71. package/src/primitives/lightbox/lightbox.css +2 -2
  72. package/src/primitives/lightbox/lightbox.d.ts.map +1 -1
  73. package/src/primitives/lightbox/lightbox.js +9 -8
  74. package/src/primitives/lightbox/lightbox.ts +9 -8
  75. package/src/primitives/password-group/password-group.css +5 -5
  76. package/src/primitives/radio/radio.css +15 -10
  77. package/src/primitives/slider/slider.css +2 -2
  78. package/src/primitives/switch/switch.css +6 -6
  79. package/src/primitives/tabs/tabs.css +10 -10
  80. package/src/primitives/toaster/toaster.css +29 -1
  81. package/src/primitives/toaster/toaster.d.ts.map +1 -1
  82. package/src/primitives/toaster/toaster.js +117 -9
  83. package/src/primitives/toaster/toaster.ts +136 -9
  84. package/src/primitives/tooltip/tooltip.css +93 -10
  85. package/src/base/embla.d.ts +0 -90
  86. package/src/base/embla.d.ts.map +0 -1
  87. package/src/base/embla.js +0 -878
  88. package/src/base/embla.ts +0 -1066
package/src/base/embla.ts DELETED
@@ -1,1066 +0,0 @@
1
- "use strict";
2
-
3
- /**
4
- * @fileoverview Embla Carousel initialization and controls.
5
- * @description Discovers carousel roots (`<ui-carousel>` or `[data-ui~="carousel"]`),
6
- * initializes Embla instances with optional plugins, and wires navigation,
7
- * keyboard, and dialog-open behaviors (subscribing to `zazz:dialog-open`
8
- * from base/dialog-lifecycle.ts; lightbox choreography lives in lightbox.ts).
9
- *
10
- * Structure: root is the element itself; parts are slots (`data-carousel-slot="<part>"`):
11
- * - root (`<ui-carousel>` | `[data-ui~="carousel"]`): Carousel container; holds all config attributes
12
- * - `carousel-viewport`: Visible window (required)
13
- * - `carousel-container`: Slides flex track
14
- * - `carousel-slide`: Individual slide
15
- * - `carousel-prev` / `carousel-next`: Navigation buttons (optional)
16
- * - `carousel-dots` / `carousel-dot`: Dot pagination container and template dot (optional)
17
- * - `carousel-thumbs`: Linked thumb carousel container (optional)
18
- *
19
- * thumb navigation (on `data-carousel-slot="thumbs"`):
20
- * - `data-carousel-thumbs-*`: thumb carousel options (defaults: containScroll keepSnaps, dragFree true)
21
- * - Syncs with the main carousel in the same root
22
- *
23
- * Lifecycle and dialog start index:
24
- * - `data-carousel-init`: Set by script when a carousel is initialized
25
- * - `data-carousel-start`: On a trigger; slide index to open to (pairs with commandfor)
26
- * - `data-carousel-start-index`: Set on root by script; consumed when dialog opens
27
- * - `data-carousel-keyboard`: Set to `"false"` to disable ArrowLeft/ArrowRight navigation
28
- *
29
- * Configuration (on the carousel root: `<ui-carousel>` or `[data-ui~="carousel"]`):
30
- * - `data-carousel-*`: Core Embla options
31
- * - `data-carousel-plugins`: Space-separated plugin slugs (`autoplay`, `auto-scroll`, `class-names`)
32
- * - `data-carousel-autoplay-*`: Autoplay plugin options (requires `autoplay` in plugins)
33
- * - `data-carousel-auto-scroll-*`: Auto scroll plugin options (requires `auto-scroll` in plugins)
34
- * - `data-carousel-class-names-*`: Class names plugin options (requires `class-names` in plugins)
35
- *
36
- * Built on Embla v9 (`9.0.0-rc04`). Core options pass straight through, so they
37
- * use Embla's v9 names (`data-carousel-start-snap`, `data-carousel-draggable`,
38
- * `data-carousel-drag-free="snap"`, …).
39
- *
40
- * Autoplay and Auto Scroll: the kit owns their interaction handling (it sets
41
- * Embla's `defaultInteraction: false`) and adds two kit-level options, read
42
- * from the plugin's own prefix (`data-carousel-autoplay-*`, `data-carousel-auto-scroll-*`):
43
- * - `…-play-on-init`: `"false"` leaves the plugin stopped until `play()` (default plays)
44
- * - `…-stop-on-interaction`: `"false"` holds the plugin during a drag or slide focus and
45
- * resumes it after; Prev/Next, the dots, the thumbs, and the arrow keys restart its
46
- * delay. By default (`true`) any of those stops it for good.
47
- * The kit also restarts a playing plugin after Embla's `reinit` (a resize or a
48
- * breakpoint change re-creates plugins, which Embla v9 leaves stopped).
49
- *
50
- * @see https://www.embla-carousel.com/api/options/
51
- * @see https://www.embla-carousel.com/plugins/autoplay/
52
- * @see https://www.embla-carousel.com/plugins/auto-scroll/
53
- * @see https://www.embla-carousel.com/plugins/class-names/
54
- *
55
- * @example
56
- * data-carousel-loop="true"
57
- *
58
- * @example
59
- * data-carousel-align="start"
60
- *
61
- * @example
62
- * data-carousel-plugins="autoplay" data-carousel-autoplay-delay="3000"
63
- *
64
- * @example
65
- * data-carousel-plugins="auto-scroll" data-carousel-auto-scroll-speed="2"
66
- *
67
- * @example
68
- * data-carousel-plugins="class-names" data-carousel-class-names-snapped="is-snapped"
69
- *
70
- * @example Barebones carousel (4 text slides; auto-inits on DOMContentLoaded):
71
- * <div data-ui="carousel">
72
- * <div data-carousel-slot="viewport">
73
- * <div data-carousel-slot="container">
74
- * <div data-carousel-slot="slide">Slide 1</div>
75
- * <div data-carousel-slot="slide">Slide 2</div>
76
- * <div data-carousel-slot="slide">Slide 3</div>
77
- * <div data-carousel-slot="slide">Slide 4</div>
78
- * </div>
79
- * </div>
80
- * <button type="button" data-carousel-slot="prev">Prev</button>
81
- * <button type="button" data-carousel-slot="next">Next</button>
82
- * </div>
83
- */
84
-
85
- import { Utils } from "./utils.ts";
86
- import { registerRefresh } from "./zazz-element.ts";
87
-
88
- // Bare specifiers resolve through the page's import map in browsers (pinned
89
- // jsDelivr URLs; see `head.ts`) and through node_modules in tests/bundlers.
90
- import EmblaCarousel from "embla-carousel";
91
- import type { EmblaCarouselType, EmblaOptionsType, EmblaPluginType } from "embla-carousel";
92
- import EmblaCarouselAutoplay from "embla-carousel-autoplay";
93
- import type { AutoplayOptionsType, AutoplayType } from "embla-carousel-autoplay";
94
- import EmblaCarouselAutoScroll from "embla-carousel-auto-scroll";
95
- import type { AutoScrollOptionsType, AutoScrollType } from "embla-carousel-auto-scroll";
96
- import EmblaCarouselClassNames from "embla-carousel-class-names";
97
- import type { ClassNamesOptionsType } from "embla-carousel-class-names";
98
-
99
- // --- Configuration reading ---
100
-
101
- /** Known Embla plugin slugs accepted by `data-carousel-plugins`. */
102
- type CarouselPluginSlug = "autoplay" | "auto-scroll" | "class-names";
103
-
104
- /**
105
- * @description Parses a space-separated `data-carousel-plugins` value into
106
- * plugin slug tokens. Empty / null / whitespace-only values yield `[]`.
107
- *
108
- * @param value - Raw attribute value (or `null` when absent).
109
- * @returns Plugin slug tokens in authoring order.
110
- */
111
- function parseCarouselPlugins(value: string | null): string[] {
112
- if (!value) return [];
113
- return value.trim().split(/\s+/).filter(Boolean);
114
- }
115
-
116
- /**
117
- * Map of plugin slug → Embla factory. Slugs match Embla package names
118
- * (`embla-carousel-auto-scroll`, etc.).
119
- */
120
- const PLUGIN_BY_SLUG: Record<CarouselPluginSlug, (node: Element) => EmblaPluginType> = {
121
- autoplay: (node) =>
122
- EmblaCarouselAutoplay(
123
- readAutoPluginOptions<AutoplayOptionsType>(node, "data-carousel-autoplay-"),
124
- ),
125
- "auto-scroll": (node) =>
126
- EmblaCarouselAutoScroll(
127
- readAutoPluginOptions<AutoScrollOptionsType>(node, "data-carousel-auto-scroll-"),
128
- ),
129
- "class-names": (node) =>
130
- EmblaCarouselClassNames(
131
- readCarouselOptions<ClassNamesOptionsType>(node, "data-carousel-class-names-"),
132
- ),
133
- };
134
-
135
- /**
136
- * @description Reads a node's prefixed `data-carousel-*` attributes as an
137
- * options object of the shape Embla (or one of its plugins) expects.
138
- *
139
- * Attributes are strings, so the single type assertion into Embla's option
140
- * types lives here (Embla validates its own options at runtime).
141
- *
142
- * @param node - Element carrying the configuration attributes.
143
- * @param prefix - Attribute prefix, e.g. `"data-carousel-autoplay-"`.
144
- * @returns The parsed attributes, typed as `T`.
145
- * @private
146
- */
147
- function readCarouselOptions<T>(node: Element, prefix: string): T {
148
- return Utils.parseDataAttributes(node, prefix) as T;
149
- }
150
-
151
- // --- Autoplay and Auto Scroll ---
152
-
153
- /** Kit-level options of the Autoplay and Auto Scroll plugins (not Embla's). */
154
- type AutoPluginKitOptions = { playOnInit?: boolean; stopOnInteraction?: boolean };
155
-
156
- /** The two plugins the kit drives: their `plugins()` key, attribute prefix, and interaction event. */
157
- const AUTO_PLUGINS = [
158
- {
159
- key: "autoplay",
160
- prefix: "data-carousel-autoplay-",
161
- interaction: "autoplay:interaction",
162
- },
163
- {
164
- key: "autoScroll",
165
- prefix: "data-carousel-auto-scroll-",
166
- interaction: "autoscroll:interaction",
167
- },
168
- ] as const;
169
-
170
- /**
171
- * @description Reads an Autoplay / Auto Scroll plugin's attributes as Embla
172
- * options: drops the kit-level `playOnInit` / `stopOnInteraction` and sets
173
- * `defaultInteraction: false`, so the plugin reports interactions
174
- * (`autoplay:interaction`) and `bindAutoPlugins` decides what they do.
175
- * @private
176
- */
177
- function readAutoPluginOptions<T>(node: Element, prefix: string): T {
178
- const options = Utils.parseDataAttributes(node, prefix);
179
- delete options.playOnInit;
180
- delete options.stopOnInteraction;
181
- return { ...options, defaultInteraction: false } as T;
182
- }
183
-
184
- /** Per-carousel manual-step handlers, one per driven plugin (see onManualNavigation). */
185
- const manualStepHandlers = new WeakMap<EmblaCarouselType, Array<() => void>>();
186
-
187
- /** Form fields Embla never starts a drag on (its DragHandler `focusNodes`). */
188
- const NON_DRAG_TARGETS = ["INPUT", "SELECT", "TEXTAREA"];
189
-
190
- /**
191
- * @description Whether a pointer down starts an Embla drag. Embla v9 emits
192
- * `pointerdown` before its own checks, then ignores a non-primary mouse button
193
- * or a press in a form field, and no `pointerup` follows; state set on such a
194
- * pointer down would never clear.
195
- * @private
196
- */
197
- function startsDrag(evt: Event): boolean {
198
- if (evt instanceof MouseEvent && evt.button !== 0) return false;
199
- return !(evt.target instanceof Element && NON_DRAG_TARGETS.includes(evt.target.nodeName));
200
- }
201
-
202
- /**
203
- * @description Drives the Autoplay and Auto Scroll plugins the way the kit
204
- * documents them, on top of Embla v9's bare plugins (which neither start on
205
- * their own nor survive a `reinit`):
206
- * - plays on init unless `…-play-on-init="false"`;
207
- * - a pointer down or slide focus stops the plugin; with
208
- * `…-stop-on-interaction="false"` it only holds it, and the pointer up or
209
- * focus leaving the slides resumes it;
210
- * - after a `reinit` (resize, breakpoint change, `reInit()`), which re-creates
211
- * the plugin stopped, resumes it if it was playing, or is still waiting to
212
- * play (no second snap yet, or the carousel was inactive at a breakpoint);
213
- * - registers the manual-step handler `onManualNavigation` runs.
214
- *
215
- * Takes the plugin instances themselves: `plugins()` is empty while the
216
- * carousel is inactive (`active: false` at the current breakpoint).
217
- * @private
218
- */
219
- function bindAutoPlugins(
220
- emblaApi: EmblaCarouselType,
221
- node: Element,
222
- plugins: readonly EmblaPluginType[],
223
- ): void {
224
- const handlers: Array<() => void> = [];
225
-
226
- for (const { key, prefix, interaction } of AUTO_PLUGINS) {
227
- const plugin = plugins.find((p) => p.name === key) as AutoplayType | AutoScrollType | undefined;
228
- if (!plugin) continue;
229
-
230
- const { playOnInit, stopOnInteraction } = readCarouselOptions<AutoPluginKitOptions>(
231
- node,
232
- prefix,
233
- );
234
- const holds = stopOnInteraction === false;
235
- // `pending`: should play as soon as it can. `held`: what paused it with
236
- // stop-on-interaction false (its end resumes it), or "" when nothing does.
237
- let pending = playOnInit !== false;
238
- let held: "" | "pointer" | "focus" = "";
239
- let wasPlaying = false;
240
-
241
- const playIfPending = () => {
242
- if (!pending || emblaApi.snapList().length <= 1) return;
243
- // An inactive carousel never inits its plugins, and play() before init throws.
244
- if (!emblaApi.internalEngine().options.active) return;
245
- plugin.play();
246
- // play() does nothing while the plugin itself is inactive; keep waiting then.
247
- pending = !plugin.isPlaying();
248
- };
249
-
250
- // Embla re-creates plugins on reinit by calling destroy() then init() on the
251
- // same object, and destroy() stops it; note whether it was playing first.
252
- const destroy = plugin.destroy;
253
- plugin.destroy = () => {
254
- wasPlaying = plugin.isPlaying();
255
- destroy();
256
- };
257
-
258
- emblaApi.on("reinit", () => {
259
- pending ||= wasPlaying;
260
- wasPlaying = false;
261
- // A reinit mid-drag drops the drag, so its pointer up never comes.
262
- if (held === "pointer") {
263
- held = "";
264
- pending = true;
265
- }
266
- if (!held) playIfPending();
267
- });
268
-
269
- emblaApi.on(interaction, (_api, { detail }) => {
270
- const { interaction: type, originalEvent } = detail;
271
- if (type === "pointerdown" || type === "slidefocus") {
272
- // A pointerdown's originalEvent is Embla's event model; its detail is the DOM event.
273
- const pointer = originalEvent instanceof Event ? null : originalEvent.detail;
274
- if (type === "pointerdown" && pointer && !startsDrag(pointer)) return;
275
- if (!plugin.isPlaying() && !held) return;
276
- held = holds ? (type === "pointerdown" ? "pointer" : "focus") : "";
277
- pending = false;
278
- plugin.stop();
279
- } else if (
280
- (type === "pointerup" && held === "pointer") ||
281
- (type === "slidefocusout" && held === "focus")
282
- ) {
283
- held = "";
284
- plugin.play();
285
- }
286
- });
287
-
288
- handlers.push(() => {
289
- pending = false;
290
- if (holds) plugin.reset();
291
- else plugin.stop();
292
- });
293
-
294
- playIfPending();
295
- }
296
-
297
- if (handlers.length) manualStepHandlers.set(emblaApi, handlers);
298
- }
299
-
300
- /**
301
- * @description The kit's own Embla plugin, placed first in the plugin list so
302
- * its `pointerdown` listener runs before any other plugin's, on init and
303
- * after every reinit (Embla re-registers plugins in list order):
304
- * - vetoes a drag when every slide already fits (one snap): Embla would still
305
- * rubber-band. Returning false cancels Embla's drag and the later listeners
306
- * (Class Names' pointer-down class, the plugins' interactions). Skipped when
307
- * the author set `data-carousel-draggable`.
308
- * - marks a drag as a `dragging` token on the viewport, and `data-ui-dragging`
309
- * on the document root for the page-wide grabbing cursor (a `body:has(…) *`
310
- * rule would restyle the whole page on every DOM insertion). Cleared on
311
- * pointer up and on destroy (a reinit mid-drag drops the pointer up).
312
- * @private
313
- */
314
- function KitDragPlugin(viewport: Element, vetoesDrag: boolean): EmblaPluginType {
315
- const root = viewport.ownerDocument.documentElement;
316
- let api: EmblaCarouselType | undefined;
317
-
318
- const setDragging = (on: boolean) => {
319
- setCarouselState(viewport, "dragging", on);
320
- root.toggleAttribute("data-ui-dragging", on);
321
- };
322
- const onPointerDown = (
323
- emblaApi: EmblaCarouselType,
324
- { detail }: { detail: Event },
325
- ): false | void => {
326
- if (vetoesDrag && !emblaApi.canGoToPrev() && !emblaApi.canGoToNext()) return false;
327
- if (startsDrag(detail)) setDragging(true);
328
- };
329
- const onPointerUp = () => setDragging(false);
330
-
331
- return {
332
- name: "zazzDrag",
333
- options: {},
334
- init(emblaApi) {
335
- api = emblaApi;
336
- emblaApi.on("pointerdown", onPointerDown).on("pointerup", onPointerUp);
337
- },
338
- destroy() {
339
- api?.off("pointerdown", onPointerDown).off("pointerup", onPointerUp);
340
- setDragging(false);
341
- },
342
- };
343
- }
344
-
345
- // --- Manual navigation ---
346
-
347
- /**
348
- * @description Treats a manual step (Prev/Next, a dot, a thumb, an arrow key) as
349
- * user interaction for the Autoplay and Auto Scroll plugins, which on their own
350
- * only count a pointer-down on the viewport. Without it the plugin's timer keeps
351
- * running, and a tick that lands just after a click moves a second slide.
352
- * `stop-on-interaction` (default true) stops the plugin; `false` restarts its delay.
353
- * This is the pattern Embla's own examples use for navigation buttons.
354
- * @private
355
- */
356
- function onManualNavigation(emblaApi: EmblaCarouselType): void {
357
- for (const handler of manualStepHandlers.get(emblaApi) ?? []) handler();
358
- }
359
-
360
- // --- Active-index sync ---
361
-
362
- /**
363
- * @description Adds or removes one token of an element's `data-carousel-state`
364
- * list, leaving the other tokens in place.
365
- * @private
366
- */
367
- function setCarouselState(node: Element, token: string, on: boolean): void {
368
- const tokens = (node.getAttribute("data-carousel-state") ?? "").split(/\s+/).filter(Boolean);
369
- const next = on ? [...new Set([...tokens, token])] : tokens.filter((t) => t !== token);
370
- if (next.length) node.setAttribute("data-carousel-state", next.join(" "));
371
- else node.removeAttribute("data-carousel-state");
372
- }
373
-
374
- /**
375
- * @description Mirrors Embla's view state onto the slides as `data-carousel-state`
376
- * tokens: `in-view` for slides inside the viewport and `snapped` for the slides
377
- * of the selected snap (what the ClassNames plugin exposes as classes).
378
- * @private
379
- */
380
- function bindSlideStates(emblaApi: EmblaCarouselType): void {
381
- const update = () => {
382
- const slides = emblaApi.slideNodes();
383
- const inView = new Set(emblaApi.slidesInView());
384
- const snapped = new Set(
385
- emblaApi.internalEngine().scrollSnapList.slidesBySnap[emblaApi.selectedSnap()] ?? [],
386
- );
387
- slides.forEach((slide, index) => {
388
- setCarouselState(slide, "in-view", inView.has(index));
389
- setCarouselState(slide, "snapped", snapped.has(index));
390
- });
391
- };
392
- emblaApi.on("reinit", update).on("select", update).on("slidesinview", update);
393
- update();
394
- }
395
-
396
- /**
397
- * @description Sets `data-carousel-state="active"` on the node at `selected` and clears it
398
- * from every other node: the shared "which one is current" marker used by
399
- * both dot pagination and thumb navigation.
400
- *
401
- * @param nodes - Candidate nodes, in slide order.
402
- * @param selected - The active index.
403
- * @param options - Set `ariaCurrent` to also toggle `aria-current` (thumbs only;
404
- * dot pagination is purely visual).
405
- * @private
406
- */
407
- function setActiveIndex(
408
- nodes: readonly HTMLElement[],
409
- selected: number,
410
- options: { ariaCurrent?: boolean } = {},
411
- ): void {
412
- nodes.forEach((node, idx) => {
413
- const active = idx === selected;
414
- setCarouselState(node, "active", active);
415
- if (!options.ariaCurrent) return;
416
- if (active) {
417
- node.setAttribute("aria-current", "true");
418
- } else {
419
- node.removeAttribute("aria-current");
420
- }
421
- });
422
- }
423
-
424
- // --- Dot navigation ---
425
-
426
- /**
427
- * @description Adds dot navigation buttons and click handlers for an Embla carousel.
428
- *
429
- * @param emblaApi - The Embla carousel API instance.
430
- * @param dotsNode - Container element for dot navigation.
431
- * @param signal - Aborts the dot click listeners on teardown.
432
- * @returns Cleanup function to remove dots.
433
- */
434
- const addDotBtnsAndClickHandlers = (
435
- emblaApi: EmblaCarouselType,
436
- dotsNode: Element,
437
- signal?: AbortSignal,
438
- ): (() => void) | undefined => {
439
- if (!dotsNode) return;
440
-
441
- const templateDot = dotsNode.querySelector('[data-carousel-slot~="dot"]');
442
- if (!templateDot) return;
443
-
444
- let dotNodes: HTMLElement[] = [];
445
-
446
- /**
447
- * @description Creates dot buttons for each slide and binds click handlers.
448
- *
449
- * @private
450
- */
451
- const addDotBtnsWithClickHandlers = () => {
452
- const snapCount = emblaApi.snapList().length;
453
-
454
- dotsNode.innerHTML = "";
455
-
456
- if (snapCount <= 1) {
457
- dotNodes = [];
458
- return;
459
- }
460
-
461
- dotNodes = [];
462
- for (let i = 0; i < snapCount; i++) {
463
- const dot = templateDot.cloneNode(true) as HTMLElement;
464
- dotNodes.push(dot);
465
- dotsNode.appendChild(dot);
466
-
467
- dot.addEventListener(
468
- "click",
469
- () => {
470
- onManualNavigation(emblaApi);
471
- emblaApi.goTo(i);
472
- },
473
- { signal },
474
- );
475
- }
476
- };
477
-
478
- /**
479
- * @description Updates the active state of dot buttons based on the current slide.
480
- *
481
- * @private
482
- */
483
- const toggleDotBtnsActive = () => {
484
- if (!dotNodes.length) return;
485
- setActiveIndex(dotNodes, emblaApi.selectedSnap());
486
- };
487
-
488
- emblaApi
489
- .on("reinit", addDotBtnsWithClickHandlers)
490
- .on("reinit", toggleDotBtnsActive)
491
- .on("select", toggleDotBtnsActive);
492
- addDotBtnsWithClickHandlers();
493
- toggleDotBtnsActive();
494
-
495
- return () => {
496
- dotsNode.innerHTML = "";
497
- };
498
- };
499
-
500
- // --- thumb navigation ---
501
-
502
- /**
503
- * @description Adds click handlers on thumb slides to scroll the main carousel.
504
- *
505
- * @param emblaApiMain - Main carousel API instance.
506
- * @param emblaApiThumb - thumb carousel API instance.
507
- * @param signal - Aborts the thumb click listeners on teardown.
508
- */
509
- const addThumbClickHandlers = (
510
- emblaApiMain: EmblaCarouselType,
511
- emblaApiThumb: EmblaCarouselType,
512
- signal?: AbortSignal,
513
- ) => {
514
- const slidesthumbs = emblaApiThumb.slideNodes();
515
-
516
- slidesthumbs.forEach((slideNode: HTMLElement, index: number) => {
517
- slideNode.addEventListener(
518
- "click",
519
- () => {
520
- onManualNavigation(emblaApiMain);
521
- emblaApiMain.goTo(index);
522
- },
523
- { signal },
524
- );
525
- });
526
- };
527
-
528
- /**
529
- * @description Keeps the thumb carousel and active state in sync with the main carousel.
530
- *
531
- * @param emblaApiMain - Main carousel API instance.
532
- * @param emblaApiThumb - thumb carousel API instance.
533
- */
534
- const addTogglethumbsActive = (
535
- emblaApiMain: EmblaCarouselType,
536
- emblaApiThumb: EmblaCarouselType,
537
- ) => {
538
- const slidesthumbs = emblaApiThumb.slideNodes();
539
-
540
- /**
541
- * @description Scrolls thumbs to the selected snap and toggles active classes.
542
- *
543
- * @private
544
- */
545
- const toggleThumbBtnsActive = () => {
546
- const selected = emblaApiMain.selectedSnap();
547
- emblaApiThumb.goTo(selected);
548
- setActiveIndex(slidesthumbs, selected, { ariaCurrent: true });
549
- };
550
-
551
- emblaApiMain.on("select", toggleThumbBtnsActive);
552
- toggleThumbBtnsActive();
553
- };
554
-
555
- // --- Drag-aware click suppression ---
556
-
557
- /**
558
- * Deadline (ms, `performance.now()`) until which invoker `command` events are
559
- * cancelled because a carousel drag just ended. Set by bindDragClickSuppression
560
- * for command-bearing slides (the lightbox stage) and enforced by
561
- * initCommandDragGuard. A bare `click` guard is not enough: the native /
562
- * polyfilled invoker opens the dialog from its own `command` dispatch.
563
- */
564
- let suppressCommandsUntil = 0;
565
-
566
- /**
567
- * @description Suppresses click activation immediately after a drag gesture.
568
- *
569
- * This prevents click-style actions (invoker commands, thumb navigation clicks)
570
- * from firing when the intent was dragging the carousel.
571
- *
572
- * @param root - Embla root/subtree to monitor.
573
- * @param emblaApi - Carousel instance tied to this root.
574
- * @param clickSelector - Click targets to suppress after dragging.
575
- * @param options - Per-carousel drag tolerance.
576
- * @param signal - Aborts the pointer/click listeners on teardown.
577
- */
578
- function bindDragClickSuppression(
579
- root: Element,
580
- emblaApi: EmblaCarouselType,
581
- clickSelector: string,
582
- options: { dragThresholdPx?: number } = {},
583
- signal?: AbortSignal,
584
- ): void {
585
- const DRAG_THRESHOLD_PX = options.dragThresholdPx ?? 6;
586
- const SUPPRESS_WINDOW_MS = 250;
587
- // Slides that open a dialog (command="show-modal") also need command suppression.
588
- const guardsCommands = clickSelector.includes("commandfor");
589
-
590
- let pointerDown = false;
591
- let moved = false;
592
- let startX = 0;
593
- let startY = 0;
594
- let lastX = 0;
595
- let lastY = 0;
596
- let snapAtDown = 0;
597
- let suppressUntil = 0;
598
-
599
- const pointerDistance = (): number => Math.hypot(lastX - startX, lastY - startY);
600
-
601
- root.addEventListener(
602
- "pointerdown",
603
- (e) => {
604
- if (!(e instanceof PointerEvent)) return;
605
- if (e.pointerType === "mouse" && e.button !== 0) return;
606
-
607
- pointerDown = true;
608
- moved = false;
609
- startX = e.clientX;
610
- startY = e.clientY;
611
- lastX = e.clientX;
612
- lastY = e.clientY;
613
- snapAtDown = emblaApi.selectedSnap();
614
- },
615
- { passive: true, signal },
616
- );
617
-
618
- root.addEventListener(
619
- "pointermove",
620
- (e) => {
621
- if (!pointerDown || !(e instanceof PointerEvent)) return;
622
- lastX = e.clientX;
623
- lastY = e.clientY;
624
- if (moved) return;
625
-
626
- if (pointerDistance() >= DRAG_THRESHOLD_PX) moved = true;
627
- },
628
- { passive: true, signal },
629
- );
630
-
631
- const finalizePointer = () => {
632
- if (pointerDown && moved) {
633
- suppressUntil = performance.now() + SUPPRESS_WINDOW_MS;
634
- if (guardsCommands) suppressCommandsUntil = suppressUntil;
635
- }
636
- pointerDown = false;
637
- moved = false;
638
- };
639
-
640
- root.addEventListener("pointerup", finalizePointer, { passive: true, signal });
641
- root.addEventListener("pointercancel", finalizePointer, { passive: true, signal });
642
- emblaApi.on("pointerup", finalizePointer);
643
-
644
- // Touch/trackpad drags can move with tiny deltas. Treat Embla scroll as drag intent,
645
- // but lightbox openers need extra tolerance so minor carousel settle does not block clicks.
646
- emblaApi.on("scroll", () => {
647
- if (!pointerDown) return;
648
-
649
- if (guardsCommands) {
650
- if (pointerDistance() >= DRAG_THRESHOLD_PX || emblaApi.selectedSnap() !== snapAtDown) {
651
- moved = true;
652
- }
653
- return;
654
- }
655
-
656
- moved = true;
657
- });
658
-
659
- root.addEventListener(
660
- "click",
661
- (e) => {
662
- if (performance.now() > suppressUntil) return;
663
-
664
- const target = e.target instanceof Element ? e.target.closest(clickSelector) : null;
665
- if (!target || !root.contains(target)) return;
666
-
667
- e.preventDefault();
668
- e.stopImmediatePropagation();
669
- },
670
- { capture: true, signal },
671
- );
672
- }
673
-
674
- let commandDragGuardBound = false;
675
-
676
- /**
677
- * @description Cancels invoker `command` events fired right after a carousel drag.
678
- *
679
- * Lightbox stage slides carry `command="show-modal"`, so a drag would both scroll
680
- * the carousel and open the dialog. The `command` event (native or polyfill) is
681
- * the single point that runs the built-in command, and it is cancelable, so we
682
- * preventDefault() it within the drag-suppress window. Bound once on `document` in
683
- * the capture phase; `command` does not bubble, but capture still reaches it.
684
- */
685
- function initCommandDragGuard(): void {
686
- if (commandDragGuardBound) return;
687
- commandDragGuardBound = true;
688
-
689
- document.addEventListener(
690
- "command",
691
- (e) => {
692
- if (e.cancelable && performance.now() <= suppressCommandsUntil) e.preventDefault();
693
- },
694
- true,
695
- );
696
- }
697
-
698
- // --- Carousel initialization ---
699
-
700
- /**
701
- * @description Initializes a single Embla carousel root.
702
- *
703
- * Configures the carousel from its `data-carousel-*` attributes, wires navigation
704
- * (prev/next, dots, thumbs), and stores the API on `root._emblaApi`. Idempotent:
705
- * skips roots that are already initialized or inside a closed dialog (no
706
- * measurable viewport until open).
707
- *
708
- * Called by `initEmblaCarousels()` for attribute-form (`[data-ui~="carousel"]`) markup and by
709
- * the `<ui-carousel>` web component on connect.
710
- *
711
- * @param emblaNode - The carousel root element.
712
- */
713
- function initEmblaRoot(emblaNode: Element): void {
714
- if (emblaNode.hasAttribute("data-carousel-init")) return;
715
-
716
- // Defer init inside closed dialogs: viewport has no measurable size until open
717
- if (emblaNode.closest("dialog:not([open])")) return;
718
-
719
- emblaNode.setAttribute("data-carousel-init", "");
720
-
721
- const emblathumbsNode = emblaNode.querySelector('[data-carousel-slot~="thumbs"]');
722
- const emblaViewportNode = emblathumbsNode
723
- ? emblaNode.querySelector(
724
- '[data-carousel-slot~="viewport"]:not([data-carousel-slot~="thumbs"] *)',
725
- )
726
- : emblaNode.querySelector('[data-carousel-slot~="viewport"]');
727
- const emblaPrevButtonNode = emblaNode.querySelector('[data-carousel-slot~="prev"]');
728
- const emblaNextButtonNode = emblaNode.querySelector('[data-carousel-slot~="next"]');
729
- const emblaDotsNode = emblaNode.querySelector('[data-carousel-slot~="dots"]');
730
-
731
- if (!emblaViewportNode) return;
732
-
733
- if (!emblaViewportNode.hasAttribute("tabindex")) {
734
- emblaViewportNode.setAttribute("tabindex", "0");
735
- }
736
-
737
- const apiOptions = readCarouselOptions<Record<string, unknown>>(emblaNode, "data-carousel-");
738
-
739
- // Keep kit-only / plugin keys out of core Embla options
740
- Object.keys(apiOptions).forEach(function (key) {
741
- if (
742
- key === "name" ||
743
- key === "keyboard" ||
744
- key === "plugins" ||
745
- key.startsWith("autoplay") ||
746
- key.startsWith("autoScroll") ||
747
- key.startsWith("classNames")
748
- ) {
749
- delete apiOptions[key];
750
- }
751
- });
752
-
753
- // Plugins load only when listed in data-carousel-plugins; option attrs alone
754
- // do not enable them. Unknown slugs are ignored.
755
- // The kit's drag plugin goes first (see KitDragPlugin).
756
- const plugins: EmblaPluginType[] = [
757
- KitDragPlugin(emblaViewportNode, !("draggable" in apiOptions)),
758
- ];
759
- for (const slug of parseCarouselPlugins(emblaNode.getAttribute("data-carousel-plugins"))) {
760
- const create = PLUGIN_BY_SLUG[slug as CarouselPluginSlug];
761
- if (!create) continue;
762
- plugins.push(create(emblaNode));
763
- }
764
-
765
- // The options come from untyped data attributes; Embla validates at runtime.
766
- const emblaApi = EmblaCarousel(
767
- emblaViewportNode as HTMLElement,
768
- apiOptions as EmblaOptionsType,
769
- plugins,
770
- );
771
- bindSlideStates(emblaApi);
772
- bindAutoPlugins(emblaApi, emblaNode, plugins);
773
-
774
- emblaNode._emblaApi = emblaApi;
775
-
776
- // One controller per root scopes every carousel listener below; the owner
777
- // (`<ui-carousel>` disconnectedCallback) aborts it on teardown so the DOM
778
- // listeners are removed alongside the destroyed Embla instance.
779
- const controller = new AbortController();
780
- const { signal } = controller;
781
- emblaNode._emblaController = controller;
782
-
783
- if (emblaPrevButtonNode) {
784
- emblaPrevButtonNode.addEventListener(
785
- "click",
786
- () => {
787
- onManualNavigation(emblaApi);
788
- emblaApi.goToPrev();
789
- },
790
- { signal },
791
- );
792
- }
793
-
794
- if (emblaNextButtonNode) {
795
- emblaNextButtonNode.addEventListener(
796
- "click",
797
- () => {
798
- onManualNavigation(emblaApi);
799
- emblaApi.goToNext();
800
- },
801
- { signal },
802
- );
803
- }
804
-
805
- if (emblaDotsNode) {
806
- addDotBtnsAndClickHandlers(emblaApi, emblaDotsNode, signal);
807
- }
808
-
809
- // Any command-bearing slide (e.g. a lightbox stage slide that opens the
810
- // dialog) needs its click suppressed when it was really a drag.
811
- if (emblaNode.querySelector('[data-carousel-slot~="slide"][commandfor]')) {
812
- bindDragClickSuppression(
813
- emblaNode,
814
- emblaApi,
815
- '[data-carousel-slot~="slide"][commandfor]',
816
- { dragThresholdPx: 14 },
817
- signal,
818
- );
819
- }
820
-
821
- if (emblathumbsNode) {
822
- const emblathumbsViewportNode = emblathumbsNode.querySelector(
823
- '[data-carousel-slot~="viewport"]',
824
- );
825
- if (emblathumbsViewportNode) {
826
- const thumbDefaults: EmblaOptionsType = { containScroll: "keepSnaps", dragFree: true };
827
- const thumbOptions = readCarouselOptions<EmblaOptionsType>(
828
- emblathumbsNode,
829
- "data-carousel-thumbs-",
830
- );
831
- const emblaApiThumb = EmblaCarousel(emblathumbsViewportNode as HTMLElement, {
832
- ...thumbDefaults,
833
- ...thumbOptions,
834
- });
835
-
836
- emblaNode._emblaApiThumb = emblaApiThumb;
837
- addThumbClickHandlers(emblaApi, emblaApiThumb, signal);
838
- addTogglethumbsActive(emblaApi, emblaApiThumb);
839
-
840
- bindDragClickSuppression(
841
- emblathumbsNode,
842
- emblaApiThumb,
843
- '[data-carousel-slot~="slide"]',
844
- {},
845
- signal,
846
- );
847
- }
848
- }
849
- }
850
-
851
- /**
852
- * @description Initializes all Embla carousels within a scope.
853
- *
854
- * Discovers carousel elements via `:is(ui-carousel, [data-ui~="carousel"])` and configures them
855
- * based on their data attributes. Roots managed by the `<ui-carousel>` web
856
- * component are skipped: they initialize themselves via `connectedCallback()`.
857
- *
858
- * @param scope - Root element to search within. Defaults to `document`.
859
- */
860
- function initEmblaCarousels(scope?: Document | Element): void {
861
- const root = scope || document;
862
- const emblaRoots = root.querySelectorAll(':is(ui-carousel, [data-ui~="carousel"])');
863
-
864
- emblaRoots.forEach(function (emblaNode) {
865
- // <ui-carousel> elements own their lifecycle (init on connect, destroy
866
- // on disconnect); double-initializing would leak a second Embla instance.
867
- if (emblaNode.closest("ui-carousel")) return;
868
-
869
- initEmblaRoot(emblaNode);
870
- });
871
- }
872
-
873
- // --- Dialog open subscription ---
874
-
875
- /**
876
- * @description Reacts to dialogs opening (via `zazz:dialog-open` from
877
- * base/dialog-lifecycle.ts) with the carousel-domain work:
878
- * initializes class-form roots that deferred while the dialog was
879
- * `display: none`, applies a stored `data-carousel-start-index`, and focuses
880
- * the viewport for keyboard navigation.
881
- *
882
- * Listens on `document`, so it runs after any dialog- or ancestor-level
883
- * subscriber (`<ui-carousel>` self-init, `<ui-lightbox>` choreography).
884
- */
885
- function initDialogOpenSubscription(): void {
886
- document.addEventListener("zazz:dialog-open", function (e) {
887
- if (!(e.target instanceof HTMLDialogElement)) return;
888
- const dialog = e.target;
889
- initEmblaCarousels(dialog);
890
-
891
- const roots = dialog.querySelectorAll(':is(ui-carousel, [data-ui~="carousel"])');
892
- roots.forEach(function (root) {
893
- const startIndex = root.getAttribute("data-carousel-start-index");
894
- if (startIndex != null && root._emblaApi) {
895
- root._emblaApi.goTo(Number(startIndex), true);
896
- root.removeAttribute("data-carousel-start-index");
897
- }
898
-
899
- const viewport = root.querySelector('[data-carousel-slot~="viewport"]');
900
- if (viewport instanceof HTMLElement) {
901
- viewport.focus({ preventScroll: true });
902
- }
903
- });
904
- });
905
- }
906
-
907
- // --- Keyboard navigation ---
908
-
909
- /**
910
- * @description Returns the active Embla root for keyboard navigation.
911
- *
912
- * Prefers a carousel inside an open dialog, then the carousel containing focus.
913
- * Respects `data-carousel-keyboard="false"`.
914
- *
915
- * @returns The active carousel root, or null when none applies.
916
- * @private
917
- */
918
- function getActiveEmblaRoot(): (Element & { _emblaApi: EmblaCarouselType }) | null {
919
- const openDialog = document.querySelector("dialog[open]");
920
- if (openDialog) {
921
- const dialogRoot = openDialog.querySelector(
922
- ':is(ui-carousel, [data-ui~="carousel"])[data-carousel-init]',
923
- );
924
- if (dialogRoot?._emblaApi && dialogRoot.getAttribute("data-carousel-keyboard") !== "false") {
925
- return dialogRoot as Element & { _emblaApi: EmblaCarouselType };
926
- }
927
- }
928
-
929
- const focusedRoot = document.activeElement?.closest(
930
- ':is(ui-carousel, [data-ui~="carousel"])[data-carousel-init]',
931
- );
932
- if (focusedRoot?._emblaApi && focusedRoot.getAttribute("data-carousel-keyboard") !== "false") {
933
- return focusedRoot as Element & { _emblaApi: EmblaCarouselType };
934
- }
935
-
936
- return null;
937
- }
938
-
939
- /**
940
- * @description Binds ArrowLeft/ArrowRight keyboard navigation for active carousels.
941
- *
942
- * Embla is headless: arrow keys are not built in. Opt out per carousel with
943
- * `data-carousel-keyboard="false"`.
944
- */
945
- const initEmblaKeyboardNav: InitEmblaKeyboardNavFn = function () {
946
- if (initEmblaKeyboardNav._bound) return;
947
- initEmblaKeyboardNav._bound = true;
948
-
949
- document.addEventListener("keydown", function (e) {
950
- if (e.key !== "ArrowLeft" && e.key !== "ArrowRight") return;
951
- if (e.defaultPrevented) return;
952
-
953
- const target = e.target;
954
- if (!(target instanceof HTMLElement)) return;
955
-
956
- if (
957
- target instanceof HTMLInputElement ||
958
- target instanceof HTMLTextAreaElement ||
959
- target instanceof HTMLSelectElement ||
960
- target.isContentEditable
961
- ) {
962
- return;
963
- }
964
-
965
- const root = getActiveEmblaRoot();
966
- if (!root) return;
967
-
968
- e.preventDefault();
969
- onManualNavigation(root._emblaApi);
970
- if (e.key === "ArrowLeft") root._emblaApi.goToPrev();
971
- else root._emblaApi.goToNext();
972
- });
973
- };
974
-
975
- /**
976
- * @namespace EmblaInit
977
- * @description Public API for Embla carousel initialization and helpers.
978
- *
979
- * @property init - Initializes all carousels within a scope.
980
- * @property initRoot - Initializes a single carousel root (used by `<ui-carousel>`).
981
- * @property addDotBtnsAndClickHandlers - Wires dot pagination.
982
- * @property addThumbClickHandlers - Wires thumb click handlers.
983
- * @property addTogglethumbsActive - Syncs thumb active state.
984
- */
985
- const EmblaInit = {
986
- init: initEmblaCarousels,
987
- initRoot: initEmblaRoot,
988
- addDotBtnsAndClickHandlers,
989
- addThumbClickHandlers,
990
- addTogglethumbsActive,
991
- };
992
-
993
- // --- Start index control ---
994
-
995
- /**
996
- * @description Stores or applies a start slide index from `[data-carousel-start]` triggers.
997
- *
998
- * Clicking an element with `data-carousel-start="N"` stores that index on the target
999
- * carousel (found via `commandfor` → dialog → `:is(ui-carousel, [data-ui~="carousel"])`). The dialog
1000
- * open observer scrolls to it on open.
1001
- */
1002
- function initEmblaStartLinks(): void {
1003
- document.addEventListener("click", function (e) {
1004
- if (!(e.target instanceof HTMLElement)) return;
1005
-
1006
- const trigger = e.target.closest(
1007
- "[data-carousel-start], [data-carousel-slot~='slide'][commandfor]",
1008
- );
1009
- if (!trigger) return;
1010
-
1011
- let index = trigger.getAttribute("data-carousel-start");
1012
- if (index == null && trigger.hasAttribute("commandfor")) {
1013
- const emblaRoot = trigger.closest(':is(ui-carousel, [data-ui~="carousel"])');
1014
- if (emblaRoot?._emblaApi) {
1015
- index = String(emblaRoot._emblaApi.selectedSnap());
1016
- }
1017
- }
1018
-
1019
- const dialogId = trigger.getAttribute("commandfor");
1020
- if (!dialogId) return;
1021
-
1022
- const dialog = document.getElementById(dialogId);
1023
- if (!dialog) return;
1024
-
1025
- const root = dialog.querySelector(':is(ui-carousel, [data-ui~="carousel"])');
1026
- if (!root) return;
1027
-
1028
- if (root._emblaApi) {
1029
- root._emblaApi.goTo(Number(index), true);
1030
- } else if (index != null) {
1031
- root.setAttribute("data-carousel-start-index", index);
1032
- }
1033
- });
1034
- }
1035
-
1036
- // Auto-initialize when DOM is ready (only in browser environment)
1037
- if (typeof window !== "undefined" && typeof document !== "undefined") {
1038
- // After an in-page navigation swap, initialize class-form carousels in the new content
1039
- // (<ui-carousel> elements ride the swap via their own lifecycle; init() skips
1040
- // already-initialized roots and closed dialogs).
1041
- registerRefresh((scope) => initEmblaCarousels(scope));
1042
-
1043
- if (document.readyState === "loading") {
1044
- document.addEventListener("DOMContentLoaded", function () {
1045
- initEmblaCarousels();
1046
- initDialogOpenSubscription();
1047
- initEmblaStartLinks();
1048
- initEmblaKeyboardNav();
1049
- initCommandDragGuard();
1050
- });
1051
- } else {
1052
- initEmblaCarousels();
1053
- initDialogOpenSubscription();
1054
- initEmblaStartLinks();
1055
- initEmblaKeyboardNav();
1056
- initCommandDragGuard();
1057
- }
1058
- }
1059
-
1060
- // Attach to window for the documented public API (`window.EmblaInit`), and export
1061
- // for module consumers (carousel.js / navigation.js import it via the index.js entry).
1062
- if (typeof window !== "undefined") {
1063
- window.EmblaInit = EmblaInit;
1064
- }
1065
-
1066
- export { EmblaInit, setActiveIndex, parseCarouselPlugins };