UNPKG

@blossom-carousel/react

Version:

A native-scroll-first carousel component for React.

26 lines (25 loc) 785 B
import { jsx as f } from "react/jsx-runtime"; import { Blossom as a } from "@blossom-carousel/core"; import { forwardRef as i, useRef as t, useEffect as p, useImperativeHandle as d } from "react"; const v = i(({ children: n, as: l = "div", repeat: s = !1, ...u }, m) => { const c = l, r = t(null), o = t(null); return p(() => { if (!r.current) return; const e = a(r.current, { repeat: s }); return o.current = e, e.init(), () => { e.destroy(); }; }, [s]), d( m, () => ({ prev: (e) => o.current?.prev(e), next: (e) => o.current?.next(e), element: r.current }), [] ), /* @__PURE__ */ f(c, { ref: r, "blossom-carousel": "true", ...u, children: n }); }); v.displayName = "BlossomCarousel"; export { v as BlossomCarousel };