@nordwerk/scroll-carousel 0.1.3 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,9 +1,392 @@
1
- import {
2
- attach,
3
- getCarousel
4
- } from "./shared/chunk-HPGJKTV5.js";
5
- import "./shared/chunk-3THCBXDW.js";
6
- export {
7
- attach,
8
- getCarousel
1
+ import { a as snapPositions, i as pageOf, n as clamp, o as visibleRange, r as closest, t as buildPages } from "./shared/math-DhvRXjtu.js";
2
+ //#region src/index.ts
3
+ const LABELS = {
4
+ page: (n, count) => `Page ${n} of ${count}`,
5
+ status: (first, last, count) => first === last ? `Item ${first} of ${count}` : `Items ${first} to ${last} of ${count}`
9
6
  };
7
+ const px = (value) => parseFloat(value) || 0;
8
+ /** A computed length-percentage in px; percentages of scroll-padding refer to the scrollport. */
9
+ const lengthIn = (value, whole) => value.trim().endsWith("%") ? px(value) * whole / 100 : px(value);
10
+ const instances = /* @__PURE__ */ new WeakMap();
11
+ /** The carousel attached to `root`, if any. */
12
+ const getCarousel = (root) => instances.get(root);
13
+ /** Attach to server-rendered markup. Attaching twice returns the same carousel. */
14
+ function attach(root, options = {}) {
15
+ const existing = instances.get(root);
16
+ if (existing) return existing;
17
+ const track = root.querySelector("[data-sc-track]");
18
+ const part = (name) => options[name] || root.querySelector(`[data-sc-${name}]`);
19
+ const prevButton = part("prev");
20
+ const nextButton = part("next");
21
+ const dots = part("dots");
22
+ const status = part("status");
23
+ const labels = {
24
+ ...LABELS,
25
+ ...options.labels
26
+ };
27
+ const rewind = options.rewind === true ? "fade" : options.rewind || false;
28
+ const motion = matchMedia("(prefers-reduced-motion: reduce)");
29
+ const tabIndex = track.getAttribute("tabindex");
30
+ const listeners = new AbortController();
31
+ const listen = (target, type, handler, opts) => target?.addEventListener(type, handler, {
32
+ signal: listeners.signal,
33
+ ...opts
34
+ });
35
+ const hooks = {
36
+ control: [],
37
+ settle: [],
38
+ measure: []
39
+ };
40
+ const run = (name) => hooks[name].forEach((handler) => handler());
41
+ let slides = [...track.children];
42
+ const marked = slides.findIndex((slide) => slide.hasAttribute("data-sc-initial"));
43
+ let anchor = Math.max(0, options.initial ?? marked);
44
+ const anchorSlide = slides[anchor];
45
+ let needsInitial = anchor > 0;
46
+ let geo = {
47
+ starts: [],
48
+ sizes: [],
49
+ port: 0,
50
+ padStart: 0,
51
+ padEnd: 0,
52
+ max: 0,
53
+ align: "start"
54
+ };
55
+ let snaps = [];
56
+ let pages = [];
57
+ let snap = "mandatory";
58
+ let rtl = false;
59
+ let pos = 0;
60
+ let target = -1;
61
+ let scrolling = false;
62
+ let touching = false;
63
+ let busy = false;
64
+ let quiet = false;
65
+ let state;
66
+ let settled;
67
+ let frame = 0;
68
+ let measureFrame = 0;
69
+ let settleTimer = 0;
70
+ let fadeTimer = 0;
71
+ const readPos = () => Math.abs(track.scrollLeft);
72
+ const positions = () => pages.map((page) => page.pos);
73
+ const moveTo = (position, behavior) => track.scrollTo({
74
+ left: rtl ? -position : position,
75
+ behavior
76
+ });
77
+ function measure() {
78
+ slides = [...track.children];
79
+ const style = getComputedStyle(track);
80
+ rtl = style.direction == "rtl";
81
+ const configured = String(options.group ?? style.getPropertyValue("--sc-group")).trim();
82
+ const group = configured == "page" ? "page" : Math.max(1, parseInt(configured) || 1);
83
+ if (!track.hasAttribute("data-sc-dragging")) {
84
+ const type = style.scrollSnapType;
85
+ snap = type == "none" ? "none" : type.includes("mandatory") ? "mandatory" : "proximity";
86
+ }
87
+ const box = track.getBoundingClientRect();
88
+ const edge = rtl ? box.right - px(style.borderRightWidth) : box.left + px(style.borderLeftWidth);
89
+ const offset = readPos();
90
+ const port = track.clientWidth;
91
+ geo = {
92
+ starts: [],
93
+ sizes: [],
94
+ port,
95
+ padStart: lengthIn(style.scrollPaddingInlineStart, port),
96
+ padEnd: lengthIn(style.scrollPaddingInlineEnd, port),
97
+ max: Math.max(0, track.scrollWidth - port),
98
+ align: style.getPropertyValue("--sc-align").trim() || "start"
99
+ };
100
+ for (const slide of slides) {
101
+ const rect = slide.getBoundingClientRect();
102
+ geo.starts.push((rtl ? edge - rect.right : rect.left - edge) + offset);
103
+ geo.sizes.push(rect.width);
104
+ }
105
+ snaps = snapPositions(geo);
106
+ if (anchorSlide?.parentNode == track) anchor = slides.indexOf(anchorSlide);
107
+ anchor = Math.max(0, Math.min(anchor, slides.length - 1));
108
+ pages = buildPages(geo, snaps, group, anchor);
109
+ if (target >= pages.length) target = -1;
110
+ const firsts = new Set(pages.map((page) => page.first));
111
+ slides.forEach((slide, i) => slide.toggleAttribute("data-sc-snap-off", group != 1 && !firsts.has(i)));
112
+ if (dots) {
113
+ while (dots.children.length > pages.length) dots.lastElementChild.remove();
114
+ while (dots.children.length < pages.length) {
115
+ const dot = document.createElement("button");
116
+ dot.type = "button";
117
+ dot.className = "sc-dot";
118
+ dots.append(dot);
119
+ }
120
+ [...dots.children].forEach((dot, i) => dot.setAttribute("aria-label", labels.page(i + 1, pages.length)));
121
+ }
122
+ if (needsInitial && port && pages.length) {
123
+ needsInitial = false;
124
+ const initial = pages[pageOf(pages, anchor)].pos;
125
+ if (Math.abs(readPos() - initial) > 1) moveTo(initial, "instant");
126
+ }
127
+ pos = readPos();
128
+ run("measure");
129
+ }
130
+ function update(isSettled, silent) {
131
+ const moving = target >= 0;
132
+ const here = moving ? pages[target].pos : pos;
133
+ const page = moving ? target : closest(positions(), pos);
134
+ state = {
135
+ index: moving ? pages[target].first : closest(snaps, pos),
136
+ page,
137
+ pageCount: pages.length,
138
+ isBeginning: here <= 2,
139
+ isEnd: here >= geo.max - 2,
140
+ overflow: geo.max > 2
141
+ };
142
+ for (const [name, on] of [
143
+ ["overflow", state.overflow],
144
+ ["start", state.isBeginning],
145
+ ["end", state.isEnd]
146
+ ]) root.toggleAttribute("data-sc-" + name, on);
147
+ if (tabIndex == "0") track.tabIndex = state.overflow ? 0 : -1;
148
+ prevButton?.setAttribute("aria-disabled", String(state.isBeginning && !rewind));
149
+ nextButton?.setAttribute("aria-disabled", String(state.isEnd && !rewind));
150
+ if (dots) [...dots.children].forEach((dot, i) => i == page ? dot.setAttribute("aria-current", "true") : dot.removeAttribute("aria-current"));
151
+ if (!isSettled) return;
152
+ if (settled && [
153
+ "index",
154
+ "page",
155
+ "pageCount"
156
+ ].every((key) => settled[key] == state[key])) return;
157
+ const first = !settled;
158
+ settled = state;
159
+ if (first) return;
160
+ root.dispatchEvent(new CustomEvent("sc:change", { detail: { ...state } }));
161
+ options.onChange?.({ ...state });
162
+ if (status && !silent && !quiet) {
163
+ const [from, to] = visibleRange(pos, geo);
164
+ if (from >= 0) status.textContent = labels.status(from + 1, to + 1, slides.length, slides);
165
+ }
166
+ quiet = false;
167
+ }
168
+ function armSettle() {
169
+ clearTimeout(settleTimer);
170
+ settleTimer = setTimeout(settle, "onscrollend" in window ? 400 : 120);
171
+ }
172
+ function settle() {
173
+ clearTimeout(settleTimer);
174
+ if (touching || busy) return;
175
+ scrolling = false;
176
+ target = -1;
177
+ pos = readPos();
178
+ run("settle");
179
+ update(true);
180
+ }
181
+ function cancelFade() {
182
+ clearTimeout(fadeTimer);
183
+ track.removeAttribute("data-sc-fading");
184
+ }
185
+ function scrollToPos(position, how) {
186
+ cancelFade();
187
+ if (Math.abs(readPos() - position) < 1) return settle();
188
+ if (how == "fade" && !motion.matches) {
189
+ track.setAttribute("data-sc-fading", "");
190
+ fadeTimer = setTimeout(() => {
191
+ moveTo(position, "instant");
192
+ track.removeAttribute("data-sc-fading");
193
+ }, 160);
194
+ return;
195
+ }
196
+ moveTo(position, how == "instant" || motion.matches ? "instant" : "smooth");
197
+ armSettle();
198
+ }
199
+ function toPage(page, how) {
200
+ if (!pages[page]) return;
201
+ target = page;
202
+ update();
203
+ scrollToPos(pages[page].pos, how);
204
+ }
205
+ function step(direction, wrap, silent) {
206
+ if (pages.length < 2) return;
207
+ if (silent) quiet = true;
208
+ const from = target >= 0 ? pages[target].pos : readPos();
209
+ let next = -1;
210
+ pages.forEach((page, i) => {
211
+ if (direction > 0 ? next < 0 && page.pos > from + 2 : page.pos < from - 2) next = i;
212
+ });
213
+ if (next >= 0) toPage(next);
214
+ else if (wrap) toPage(direction > 0 ? 0 : pages.length - 1, rewind == "fade" ? "fade" : void 0);
215
+ }
216
+ /** The user acted through a control: stop autoplay and let the move be announced. */
217
+ function takeControl() {
218
+ quiet = false;
219
+ run("control");
220
+ }
221
+ function grab() {
222
+ takeControl();
223
+ cancelFade();
224
+ target = -1;
225
+ }
226
+ const click = (button, direction) => listen(button, "click", () => {
227
+ if (button.getAttribute("aria-disabled") == "true") return;
228
+ takeControl();
229
+ step(direction, !!rewind);
230
+ });
231
+ click(prevButton, -1);
232
+ click(nextButton, 1);
233
+ listen(dots, "click", (event) => {
234
+ const dot = event.target.closest(".sc-dot");
235
+ if (!dot) return;
236
+ takeControl();
237
+ toPage([...dots.children].indexOf(dot));
238
+ });
239
+ listen(track, "keydown", (event) => {
240
+ if (event.target != track || event.altKey || event.ctrlKey || event.metaKey || event.shiftKey) return;
241
+ const key = event.key;
242
+ const forward = rtl ? "ArrowLeft" : "ArrowRight";
243
+ if (![
244
+ forward,
245
+ rtl ? "ArrowRight" : "ArrowLeft",
246
+ "Home",
247
+ "End"
248
+ ].includes(key)) return;
249
+ event.preventDefault();
250
+ takeControl();
251
+ if (key == "Home") toPage(0);
252
+ else if (key == "End") toPage(pages.length - 1);
253
+ else step(key == forward ? 1 : -1, false);
254
+ });
255
+ listen(track, "scroll", () => {
256
+ scrolling = true;
257
+ frame ||= requestAnimationFrame(() => {
258
+ frame = 0;
259
+ pos = readPos();
260
+ update();
261
+ });
262
+ armSettle();
263
+ }, { passive: true });
264
+ listen(track, "scrollend", settle);
265
+ listen(track, "touchstart", () => {
266
+ touching = true;
267
+ grab();
268
+ }, { passive: true });
269
+ for (const type of ["touchend", "touchcancel"]) listen(track, type, () => {
270
+ touching = false;
271
+ armSettle();
272
+ }, { passive: true });
273
+ listen(track, "wheel", (event) => {
274
+ if (Math.abs(event.deltaX) > Math.abs(event.deltaY)) grab();
275
+ }, { passive: true });
276
+ const resizes = new ResizeObserver(() => {
277
+ measureFrame ||= requestAnimationFrame(() => {
278
+ measureFrame = 0;
279
+ measure();
280
+ update(!scrolling, true);
281
+ });
282
+ });
283
+ const observeSlides = () => {
284
+ resizes.disconnect();
285
+ for (const element of [track, ...slides]) resizes.observe(element);
286
+ };
287
+ const mutations = new MutationObserver(() => {
288
+ const keep = !scrolling && target < 0 && !busy ? slides[state.index] : void 0;
289
+ const seen = keep ? geo.starts[state.index] - pos : 0;
290
+ measure();
291
+ if (keep?.parentNode == track) {
292
+ const wanted = clamp(geo.starts[slides.indexOf(keep)] - seen, 0, geo.max);
293
+ if (Math.abs(readPos() - wanted) > 1) {
294
+ moveTo(wanted, "instant");
295
+ pos = readPos();
296
+ }
297
+ }
298
+ observeSlides();
299
+ update(!scrolling, true);
300
+ });
301
+ const context = {
302
+ root,
303
+ track,
304
+ listen,
305
+ layout: () => ({
306
+ pages,
307
+ max: geo.max,
308
+ rtl,
309
+ snap,
310
+ state
311
+ }),
312
+ toPage,
313
+ scrollTo: scrollToPos,
314
+ step,
315
+ grab,
316
+ hold: (on) => busy = on,
317
+ on: (event, handler) => hooks[event].push(handler)
318
+ };
319
+ const api = {
320
+ root,
321
+ track,
322
+ get slides() {
323
+ return slides;
324
+ },
325
+ get state() {
326
+ return { ...state };
327
+ },
328
+ next() {
329
+ takeControl();
330
+ step(1, !!rewind);
331
+ },
332
+ prev() {
333
+ takeControl();
334
+ step(-1, !!rewind);
335
+ },
336
+ slideTo(index, { instant } = {}) {
337
+ takeControl();
338
+ toPage(pageOf(pages, clamp(index, 0, slides.length - 1)), instant ? "instant" : void 0);
339
+ },
340
+ goToPage(page, { instant } = {}) {
341
+ takeControl();
342
+ toPage(clamp(page, 0, pages.length - 1), instant ? "instant" : void 0);
343
+ },
344
+ update() {
345
+ measure();
346
+ update(!scrolling, true);
347
+ },
348
+ destroy() {
349
+ listeners.abort();
350
+ resizes.disconnect();
351
+ mutations.disconnect();
352
+ cancelAnimationFrame(frame);
353
+ cancelAnimationFrame(measureFrame);
354
+ clearTimeout(settleTimer);
355
+ cancelFade();
356
+ cleanups.forEach((cleanup) => cleanup?.());
357
+ for (const name of [
358
+ "ready",
359
+ "overflow",
360
+ "start",
361
+ "end"
362
+ ]) root.removeAttribute(`data-sc-${name}`);
363
+ for (const slide of track.children) slide.removeAttribute("data-sc-snap-off");
364
+ if (tabIndex != null) track.setAttribute("tabindex", tabIndex);
365
+ prevButton?.removeAttribute("aria-disabled");
366
+ nextButton?.removeAttribute("aria-disabled");
367
+ dots?.replaceChildren();
368
+ instances.delete(root);
369
+ }
370
+ };
371
+ for (const key of [
372
+ "index",
373
+ "page",
374
+ "pageCount",
375
+ "isBeginning",
376
+ "isEnd"
377
+ ]) Object.defineProperty(api, key, { get: () => state[key] });
378
+ measure();
379
+ update(true, true);
380
+ observeSlides();
381
+ mutations.observe(track, { childList: true });
382
+ const cleanups = (options.plugins || []).map((plugin) => {
383
+ const { destroy, ...extra } = plugin(context) || {};
384
+ Object.assign(api, extra);
385
+ return destroy;
386
+ });
387
+ instances.set(root, api);
388
+ root.setAttribute("data-sc-ready", "");
389
+ return api;
390
+ }
391
+ //#endregion
392
+ export { attach, getCarousel };
package/dist/markup.d.ts CHANGED
@@ -1,51 +1,2 @@
1
- /**
2
- * A value, or values by minimum container width in px, e.g. { 0: 2, 600: 3, 900: 4 }.
3
- * Widths are container widths: the carousel root is the query container.
4
- */
5
- export type Responsive<T> = T | Record<number, T>;
6
- export interface LayoutProps {
7
- /** Slides per view; fractions show part of the next slide. */
8
- perView?: Responsive<number>;
9
- /** A fixed slide size such as '18rem', or 'auto' for the content width. Wins over perView. */
10
- slideSize?: Responsive<string>;
11
- /** Numbers are px. */
12
- gap?: Responsive<number | string>;
13
- offsetBefore?: Responsive<number | string>;
14
- offsetAfter?: Responsive<number | string>;
15
- snap?: Responsive<'mandatory' | 'proximity' | 'none'>;
16
- align?: Responsive<'start' | 'center'>;
17
- /** Pad both ends so the first and last slide can reach the centre. Needs perView. */
18
- centered?: boolean;
19
- /** Slides per step of next and previous. */
20
- group?: Responsive<number | 'page'>;
21
- /** false hides arrows, dots and the play button, e.g. for free mode on small containers. */
22
- controls?: Responsive<boolean>;
23
- }
24
- /** Custom properties for the root's style attribute: plain values and the 0 breakpoint. */
25
- export declare function baseVars(props: LayoutProps): Record<string, string>;
26
- /** The same as a CSS declaration string, for templating languages. */
27
- export declare const baseStyle: (props: LayoutProps) => string;
28
- /**
29
- * Container-query rules for responsive values, scoped to [data-sc-id="id"]. Empty when nothing
30
- * is responsive. Render it in a <style> element inside the root.
31
- */
32
- export declare function responsiveCss(id: string, props: LayoutProps): string;
33
- /**
34
- * Inline script to render immediately after a carousel that opens on a later slide. It sets the
35
- * start position before the first paint, so a deferred or module script finds it in place.
36
- * Start alignment only. It expects the root as its previous sibling.
37
- */
38
- export declare const PRE_POSITION: string;
39
- /**
40
- * Label templates such as 'Slide {n} of {count}' turned into label functions. `statusSingle`
41
- * is used when only one slide is visible, e.g. 'Item {first} of {count}' next to a `status` of
42
- * 'Items {first} to {last} of {count}'.
43
- */
44
- export declare function templateLabels(templates?: {
45
- page?: string;
46
- status?: string;
47
- statusSingle?: string;
48
- }): {
49
- page?: ((n: number, count: number) => string) | undefined;
50
- status?: ((first: number, last: number, count: number) => string) | undefined;
51
- };
1
+ import { a as baseVars, i as baseStyle, n as PRE_POSITION, o as responsiveCss, r as Responsive, s as templateLabels, t as LayoutProps } from "./shared/markup-CM54igQ_.js";
2
+ export { LayoutProps, PRE_POSITION, Responsive, baseStyle, baseVars, responsiveCss, templateLabels };
package/dist/markup.js CHANGED
@@ -1,14 +1,80 @@
1
- import {
2
- PRE_POSITION,
3
- baseStyle,
4
- baseVars,
5
- responsiveCss,
6
- templateLabels
7
- } from "./shared/chunk-QHWWA243.js";
8
- export {
9
- PRE_POSITION,
10
- baseStyle,
11
- baseVars,
12
- responsiveCss,
13
- templateLabels
1
+ //#region src/markup.ts
2
+ const PROPERTIES = {
3
+ perView: "per-view",
4
+ slideSize: "slide-size",
5
+ gap: "gap",
6
+ offsetBefore: "offset-before",
7
+ offsetAfter: "offset-after",
8
+ snap: "snap",
9
+ align: "align",
10
+ group: "group",
11
+ controls: "controls"
14
12
  };
13
+ const LENGTHS = /* @__PURE__ */ new Set([
14
+ "gap",
15
+ "offsetBefore",
16
+ "offsetAfter"
17
+ ]);
18
+ function value(key, raw) {
19
+ if (key == "controls") return raw ? "initial" : "none";
20
+ return typeof raw == "number" && LENGTHS.has(key) ? `${raw}px` : String(raw).replace(/[<>]/g, "");
21
+ }
22
+ const isResponsive = (raw) => typeof raw == "object" && raw != null;
23
+ /** Custom properties for the root's style attribute: plain values and the 0 breakpoint. */
24
+ function baseVars(props) {
25
+ const vars = {};
26
+ for (const [key, name] of Object.entries(PROPERTIES)) {
27
+ const raw = props[key];
28
+ const base = isResponsive(raw) ? raw[0] : raw;
29
+ if (base !== void 0 && !(key == "controls" && base)) vars[`--sc-${name}`] = value(key, base);
30
+ }
31
+ if (props.centered) vars["--sc-centered"] = "1";
32
+ return vars;
33
+ }
34
+ /** The same as a CSS declaration string, for templating languages. */
35
+ const baseStyle = (props) => Object.entries(baseVars(props)).map(([name, val]) => `${name}:${val}`).join(";");
36
+ /**
37
+ * Container-query rules for responsive values, scoped to [data-sc-id="id"]. Empty when nothing
38
+ * is responsive. Render it in a <style> element inside the root.
39
+ */
40
+ function responsiveCss(id, props) {
41
+ const rules = /* @__PURE__ */ new Map();
42
+ for (const [key, name] of Object.entries(PROPERTIES)) {
43
+ const raw = props[key];
44
+ if (!isResponsive(raw)) continue;
45
+ for (const [width, val] of Object.entries(raw)) {
46
+ if (+width <= 0) continue;
47
+ if (!rules.has(+width)) rules.set(+width, []);
48
+ rules.get(+width).push(`--sc-${name}:${value(key, val)}`);
49
+ }
50
+ }
51
+ return [...rules].sort(([a], [b]) => a - b).map(([width, decls]) => `@container sc (min-width:${width}px){[data-sc-id="${id}"]>*{${decls.join(";")}}}`).join("");
52
+ }
53
+ /**
54
+ * Inline script to render immediately after a carousel that opens on a later slide. It sets the
55
+ * start position before the first paint, so a deferred or module script finds it in place.
56
+ * Start alignment only. It expects the root as its previous sibling.
57
+ */
58
+ const PRE_POSITION = "(function(r){var t=r.querySelector('[data-sc-track]'),s=t&&t.querySelector('[data-sc-initial]'),f=t&&t.firstElementChild;if(!s||s==f)return;var a=s.getBoundingClientRect(),b=f.getBoundingClientRect();t.scrollLeft=getComputedStyle(t).direction=='rtl'?a.right-b.right:a.left-b.left})(document.currentScript.previousElementSibling)";
59
+ /**
60
+ * Label templates such as 'Slide {n} of {count}' turned into label functions. `statusSingle`
61
+ * is used when only one slide is visible, e.g. 'Item {first} of {count}' next to a `status` of
62
+ * 'Items {first} to {last} of {count}'.
63
+ */
64
+ function templateLabels(templates = {}) {
65
+ const fill = (template, values) => template.replace(/\{(\w+)\}/g, (match, name) => name in values ? String(values[name]) : match);
66
+ const status = templates.status || templates.statusSingle;
67
+ return {
68
+ ...templates.page && { page: (n, count) => fill(templates.page, {
69
+ n,
70
+ count
71
+ }) },
72
+ ...status && { status: (first, last, count) => fill(first == last && templates.statusSingle ? templates.statusSingle : status, {
73
+ first,
74
+ last,
75
+ count
76
+ }) }
77
+ };
78
+ }
79
+ //#endregion
80
+ export { PRE_POSITION, baseStyle, baseVars, responsiveCss, templateLabels };
package/dist/preact.d.ts CHANGED
@@ -1,9 +1,12 @@
1
- export type { CarouselProps } from './adapter.js';
2
- export type { Carousel as CarouselApi, CarouselOptions, CarouselState } from './index.js';
3
- export declare const Carousel: (props: import("./adapter.ts").CarouselProps) => any, useCarousel: (options?: import("./index.ts").CarouselOptions) => {
4
- ref: {
5
- current: HTMLElement | null;
6
- };
7
- carousel: import("./index.ts").Carousel | null;
8
- state: import("./index.ts").CarouselState | null;
1
+ import { n as CarouselOptions, r as CarouselState, t as Carousel$1 } from "./shared/index-D1Np3wzP.js";
2
+ import { t as CarouselProps } from "./shared/adapter-D4APPfnz.js";
3
+ //#region src/preact.d.ts
4
+ export declare const Carousel: (props: CarouselProps) => any, useCarousel: (options?: CarouselOptions) => {
5
+ ref: {
6
+ current: HTMLElement | null;
7
+ };
8
+ carousel: Carousel$1 | null;
9
+ state: CarouselState | null;
9
10
  };
11
+ //#endregion
12
+ export type { Carousel$1 as CarouselApi, CarouselOptions, CarouselProps, CarouselState };
package/dist/preact.js CHANGED
@@ -1,24 +1,16 @@
1
- import {
2
- createAdapter
3
- } from "./shared/chunk-I3QEUR7L.js";
4
- import "./shared/chunk-HPGJKTV5.js";
5
- import "./shared/chunk-3THCBXDW.js";
6
- import "./shared/chunk-QHWWA243.js";
7
-
8
- // src/preact.ts
1
+ import { t as createAdapter } from "./shared/adapter-DhmQTrqX.js";
9
2
  import { Fragment, createElement, toChildArray } from "preact";
10
3
  import { useEffect, useId, useLayoutEffect, useRef, useState } from "preact/hooks";
11
- var { Carousel, useCarousel } = createAdapter({
12
- createElement,
13
- Fragment,
14
- useState,
15
- useRef,
16
- useEffect,
17
- useLayoutEffect,
18
- useId,
19
- toChildArray
4
+ //#region src/preact.ts
5
+ const { Carousel, useCarousel } = createAdapter({
6
+ createElement,
7
+ Fragment,
8
+ useState,
9
+ useRef,
10
+ useEffect,
11
+ useLayoutEffect,
12
+ useId,
13
+ toChildArray
20
14
  });
21
- export {
22
- Carousel,
23
- useCarousel
24
- };
15
+ //#endregion
16
+ export { Carousel, useCarousel };
package/dist/react.d.ts CHANGED
@@ -1,9 +1,12 @@
1
- export type { CarouselProps } from './adapter.js';
2
- export type { Carousel as CarouselApi, CarouselOptions, CarouselState } from './index.js';
3
- export declare const Carousel: (props: import("./adapter.ts").CarouselProps) => any, useCarousel: (options?: import("./index.ts").CarouselOptions) => {
4
- ref: {
5
- current: HTMLElement | null;
6
- };
7
- carousel: import("./index.ts").Carousel | null;
8
- state: import("./index.ts").CarouselState | null;
1
+ import { n as CarouselOptions, r as CarouselState, t as Carousel$1 } from "./shared/index-D1Np3wzP.js";
2
+ import { t as CarouselProps } from "./shared/adapter-D4APPfnz.js";
3
+ //#region src/react.d.ts
4
+ export declare const Carousel: (props: CarouselProps) => any, useCarousel: (options?: CarouselOptions) => {
5
+ ref: {
6
+ current: HTMLElement | null;
7
+ };
8
+ carousel: Carousel$1 | null;
9
+ state: CarouselState | null;
9
10
  };
11
+ //#endregion
12
+ export type { Carousel$1 as CarouselApi, CarouselOptions, CarouselProps, CarouselState };
package/dist/react.js CHANGED
@@ -1,24 +1,16 @@
1
- 'use client';
2
- import {
3
- createAdapter
4
- } from "./shared/chunk-I3QEUR7L.js";
5
- import "./shared/chunk-HPGJKTV5.js";
6
- import "./shared/chunk-3THCBXDW.js";
7
- import "./shared/chunk-QHWWA243.js";
8
-
9
- // src/react.ts
1
+ "use client";
2
+ import { t as createAdapter } from "./shared/adapter-DhmQTrqX.js";
10
3
  import { Children, Fragment, createElement, useEffect, useId, useLayoutEffect, useRef, useState } from "react";
11
- var { Carousel, useCarousel } = createAdapter({
12
- createElement,
13
- Fragment,
14
- useState,
15
- useRef,
16
- useEffect,
17
- useLayoutEffect,
18
- useId,
19
- toChildArray: Children.toArray
4
+ //#region src/react.ts
5
+ const { Carousel, useCarousel } = createAdapter({
6
+ createElement,
7
+ Fragment,
8
+ useState,
9
+ useRef,
10
+ useEffect,
11
+ useLayoutEffect,
12
+ useId,
13
+ toChildArray: Children.toArray
20
14
  });
21
- export {
22
- Carousel,
23
- useCarousel
24
- };
15
+ //#endregion
16
+ export { Carousel, useCarousel };