@bouko/react 2.0.0 → 2.0.2
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.
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useState, useEffect } from "react";
|
|
4
|
+
import { AnimatePresence, motion } from "framer-motion";
|
|
5
|
+
import { cn } from "@bouko/style";
|
|
6
|
+
export function Carousel({ container, items, style }) {
|
|
7
|
+
const [index, setIndex] = useState(0);
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
const interval = setInterval(() => {
|
|
10
|
+
setIndex((prev) => (prev + 1) % items.length);
|
|
11
|
+
}, 3000);
|
|
12
|
+
return () => clearInterval(interval);
|
|
13
|
+
}, []);
|
|
14
|
+
return (_jsx("div", { className: cn("flex items-center", container), children: _jsx(AnimatePresence, { mode: "wait", children: _jsx(motion.div, { transition: { duration: 0.5 }, initial: { opacity: 0, y: 5 }, animate: { opacity: 1, y: 0 }, exit: { opacity: 0, y: -5 }, layout: true, children: _jsx("div", { className: cn("w-full h-full", style), children: items[index] }) }, index) }) }));
|
|
15
|
+
}
|
package/dist/components/index.js
CHANGED
package/dist/core/functions.d.ts
CHANGED
package/dist/core/functions.js
CHANGED
|
@@ -13,6 +13,21 @@ export const getFileData = (files) => Promise.all(files.map((file) => {
|
|
|
13
13
|
reader.readAsDataURL(file);
|
|
14
14
|
});
|
|
15
15
|
}));
|
|
16
|
+
export const getAudioDuration = (file) => {
|
|
17
|
+
return new Promise((resolve, reject) => {
|
|
18
|
+
const url = URL.createObjectURL(file);
|
|
19
|
+
const audio = new Audio(url);
|
|
20
|
+
audio.addEventListener("loadedmetadata", () => {
|
|
21
|
+
const durationMs = audio.duration * 1000;
|
|
22
|
+
URL.revokeObjectURL(url);
|
|
23
|
+
resolve(durationMs);
|
|
24
|
+
});
|
|
25
|
+
audio.addEventListener("error", (e) => {
|
|
26
|
+
URL.revokeObjectURL(url);
|
|
27
|
+
reject(new Error("Failed to load audio metadata"));
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
};
|
|
16
31
|
export const getEnv = (key) => {
|
|
17
32
|
const value = process.env[key];
|
|
18
33
|
if (!value)
|