@bouko/react 2.6.5 → 2.6.7
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/colors/core.d.ts +10 -10
- package/dist/colors/core.js +25 -25
- package/dist/colors/index.d.ts +26 -26
- package/dist/colors/index.js +43 -43
- package/dist/colors/types.d.ts +11 -11
- package/dist/colors/types.js +7 -7
- package/dist/components/animate/configs.d.ts +136 -136
- package/dist/components/animate/configs.js +62 -62
- package/dist/components/animate/index.d.ts +54 -54
- package/dist/components/animate/index.js +33 -33
- package/dist/components/attachment.d.ts +2 -2
- package/dist/components/attachment.js +18 -18
- package/dist/components/audio/timestamp.d.ts +12 -0
- package/dist/components/audio/timestamp.js +9 -0
- package/dist/components/button/icon.d.ts +10 -10
- package/dist/components/button/icon.js +19 -19
- package/dist/components/button/normal.d.ts +11 -11
- package/dist/components/button/normal.js +39 -39
- package/dist/components/carousel/index.d.ts +11 -11
- package/dist/components/carousel/index.js +19 -19
- package/dist/components/checkbox.d.ts +8 -8
- package/dist/components/checkbox.js +13 -13
- package/dist/components/dropdown/normal.d.ts +10 -10
- package/dist/components/dropdown/normal.js +19 -19
- package/dist/components/fade-carousel.d.ts +4 -4
- package/dist/components/fade-carousel.js +14 -14
- package/dist/components/field.d.ts +10 -10
- package/dist/components/field.js +10 -10
- package/dist/components/form/functions.d.ts +1 -1
- package/dist/components/form/functions.js +28 -28
- package/dist/components/form/types.d.ts +38 -38
- package/dist/components/form/types.js +1 -1
- package/dist/components/heading/normal.d.ts +29 -29
- package/dist/components/heading/normal.js +22 -22
- package/dist/components/heading/page.d.ts +25 -25
- package/dist/components/heading/page.js +23 -23
- package/dist/components/index.d.ts +14 -14
- package/dist/components/index.js +14 -14
- package/dist/components/input.d.ts +37 -37
- package/dist/components/input.js +40 -40
- package/dist/components/layout/absolute.d.ts +9 -9
- package/dist/components/layout/absolute.js +9 -9
- package/dist/components/layout/fade.d.ts +7 -7
- package/dist/components/layout/fade.js +15 -15
- package/dist/components/layout/flex.d.ts +16 -16
- package/dist/components/layout/flex.js +42 -42
- package/dist/components/layout/separator.d.ts +3 -3
- package/dist/components/layout/separator.js +5 -5
- package/dist/components/list/index.d.ts +2 -2
- package/dist/components/list/index.js +2 -2
- package/dist/components/list/item.d.ts +9 -9
- package/dist/components/list/item.js +7 -7
- package/dist/components/list/variants/bullet.d.ts +9 -9
- package/dist/components/list/variants/bullet.js +16 -16
- package/dist/components/list/variants/number.d.ts +10 -10
- package/dist/components/list/variants/number.js +18 -18
- package/dist/components/multiple-choice.d.ts +2 -2
- package/dist/components/multiple-choice.js +12 -12
- package/dist/components/search-bar.d.ts +13 -14
- package/dist/components/search-bar.js +22 -22
- package/dist/components/select.d.ts +6 -6
- package/dist/components/select.js +24 -24
- package/dist/components/text/badge.d.ts +17 -16
- package/dist/components/text/badge.js +35 -28
- package/dist/components/textarea.d.ts +7 -7
- package/dist/components/textarea.js +11 -11
- package/dist/components/upload/file.d.ts +8 -8
- package/dist/components/upload/file.js +23 -23
- package/dist/components/waveform/index.d.ts +8 -8
- package/dist/components/waveform/index.js +11 -11
- package/dist/components/waveform/patterns.d.ts +1 -1
- package/dist/components/waveform/patterns.js +27 -27
- package/dist/core/classes.js +1 -1
- package/dist/core/format.d.ts +3 -3
- package/dist/core/format.js +34 -34
- package/dist/core/functions.d.ts +10 -13
- package/dist/core/functions.js +76 -79
- package/dist/core/types.d.ts +15 -15
- package/dist/core/types.js +2 -2
- package/dist/core/variants.d.ts +5 -5
- package/dist/core/variants.js +6 -6
- package/dist/format/index.d.ts +2 -2
- package/dist/format/index.js +33 -33
- package/dist/hooks/audio/sound.d.ts +1 -1
- package/dist/hooks/audio/sound.js +6 -6
- package/dist/hooks/clock/interval.d.ts +8 -8
- package/dist/hooks/clock/interval.js +25 -25
- package/dist/hooks/element/container.d.ts +4 -5
- package/dist/hooks/element/container.js +7 -7
- package/dist/hooks/element/index.d.ts +4 -5
- package/dist/hooks/element/index.js +9 -9
- package/dist/hooks/element/resize.d.ts +1 -1
- package/dist/hooks/element/resize.js +12 -12
- package/dist/hooks/index.d.ts +5 -5
- package/dist/hooks/index.js +5 -5
- package/dist/index.d.ts +14 -14
- package/dist/index.js +14 -14
- package/package.json +5 -2
|
@@ -1,54 +1,54 @@
|
|
|
1
|
-
import type { ReactNode } from "react";
|
|
2
|
-
export
|
|
3
|
-
variants?: VariantConfig[];
|
|
4
|
-
direction?: "horizontal" | "vertical";
|
|
5
|
-
interval?: number;
|
|
6
|
-
duration?: number;
|
|
7
|
-
style?: string;
|
|
8
|
-
layout?: boolean;
|
|
9
|
-
children?: ReactNode;
|
|
10
|
-
};
|
|
11
|
-
export declare function Animation({ variants, style, direction, interval, duration, ...props }: Props): import("react/jsx-runtime").JSX.Element;
|
|
12
|
-
|
|
13
|
-
initial?: Record<string, number>;
|
|
14
|
-
animate?: Record<string, number>;
|
|
15
|
-
exit?: Record<string, number>;
|
|
16
|
-
};
|
|
17
|
-
/**
|
|
18
|
-
* Merges multiple variant configs into one.
|
|
19
|
-
*/
|
|
20
|
-
export declare function mergeVariants(...variants: VariantConfig[]): VariantConfig;
|
|
21
|
-
export declare const opacity: (x?: number) => {
|
|
22
|
-
initial: {
|
|
23
|
-
opacity: number;
|
|
24
|
-
};
|
|
25
|
-
animate: {
|
|
26
|
-
opacity: number;
|
|
27
|
-
};
|
|
28
|
-
exit: {
|
|
29
|
-
opacity: number;
|
|
30
|
-
};
|
|
31
|
-
};
|
|
32
|
-
export declare const slideX: (x?: number) => {
|
|
33
|
-
initial: {
|
|
34
|
-
x: number;
|
|
35
|
-
};
|
|
36
|
-
animate: {
|
|
37
|
-
x: number;
|
|
38
|
-
};
|
|
39
|
-
exit: {
|
|
40
|
-
x: number;
|
|
41
|
-
};
|
|
42
|
-
};
|
|
43
|
-
export declare const slideY: (y?: number) => {
|
|
44
|
-
initial: {
|
|
45
|
-
y: number;
|
|
46
|
-
};
|
|
47
|
-
animate: {
|
|
48
|
-
y: number;
|
|
49
|
-
};
|
|
50
|
-
exit: {
|
|
51
|
-
y: number;
|
|
52
|
-
};
|
|
53
|
-
};
|
|
54
|
-
export { AnimatePresence } from "framer-motion";
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
export type Props = {
|
|
3
|
+
variants?: VariantConfig[];
|
|
4
|
+
direction?: "horizontal" | "vertical";
|
|
5
|
+
interval?: number;
|
|
6
|
+
duration?: number;
|
|
7
|
+
style?: string;
|
|
8
|
+
layout?: boolean;
|
|
9
|
+
children?: ReactNode;
|
|
10
|
+
};
|
|
11
|
+
export declare function Animation({ variants, style, direction, interval, duration, ...props }: Props): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
type VariantConfig = {
|
|
13
|
+
initial?: Record<string, number>;
|
|
14
|
+
animate?: Record<string, number>;
|
|
15
|
+
exit?: Record<string, number>;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Merges multiple variant configs into one.
|
|
19
|
+
*/
|
|
20
|
+
export declare function mergeVariants(...variants: VariantConfig[]): VariantConfig;
|
|
21
|
+
export declare const opacity: (x?: number) => {
|
|
22
|
+
initial: {
|
|
23
|
+
opacity: number;
|
|
24
|
+
};
|
|
25
|
+
animate: {
|
|
26
|
+
opacity: number;
|
|
27
|
+
};
|
|
28
|
+
exit: {
|
|
29
|
+
opacity: number;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
export declare const slideX: (x?: number) => {
|
|
33
|
+
initial: {
|
|
34
|
+
x: number;
|
|
35
|
+
};
|
|
36
|
+
animate: {
|
|
37
|
+
x: number;
|
|
38
|
+
};
|
|
39
|
+
exit: {
|
|
40
|
+
x: number;
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
export declare const slideY: (y?: number) => {
|
|
44
|
+
initial: {
|
|
45
|
+
y: number;
|
|
46
|
+
};
|
|
47
|
+
animate: {
|
|
48
|
+
y: number;
|
|
49
|
+
};
|
|
50
|
+
exit: {
|
|
51
|
+
y: number;
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
export { AnimatePresence } from "framer-motion";
|
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import { motion } from "framer-motion";
|
|
4
|
-
import { cn } from "@bouko/style";
|
|
5
|
-
export function Animation({ variants = [opacity()], style, direction = "horizontal", interval = 3000, duration = 0.3, ...props }) {
|
|
6
|
-
return (_jsx(motion.div, { className: cn("w-full", style), transition: { duration: duration }, ...mergeVariants(...variants), ...props }
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Merges multiple variant configs into one.
|
|
10
|
-
*/
|
|
11
|
-
export function mergeVariants(...variants) {
|
|
12
|
-
return variants.reduce((acc, v) => ({
|
|
13
|
-
initial: { ...acc.initial, ...v.initial },
|
|
14
|
-
animate: { ...acc.animate, ...v.animate },
|
|
15
|
-
exit: { ...acc.exit, ...v.exit },
|
|
16
|
-
}), { initial: {}, animate: {}, exit: {} });
|
|
17
|
-
}
|
|
18
|
-
export const opacity = (x = 1) => ({
|
|
19
|
-
initial: { opacity: 0 },
|
|
20
|
-
animate: { opacity: x },
|
|
21
|
-
exit: { opacity: 0 }
|
|
22
|
-
});
|
|
23
|
-
export const slideX = (x = 5) => ({
|
|
24
|
-
initial: { x: x },
|
|
25
|
-
animate: { x: 0 },
|
|
26
|
-
exit: { x: -x }
|
|
27
|
-
});
|
|
28
|
-
export const slideY = (y = 5) => ({
|
|
29
|
-
initial: { y: y },
|
|
30
|
-
animate: { y: 0 },
|
|
31
|
-
exit: { y: -y }
|
|
32
|
-
});
|
|
33
|
-
export { AnimatePresence } from "framer-motion";
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { motion } from "framer-motion";
|
|
4
|
+
import { cn } from "@bouko/style";
|
|
5
|
+
export function Animation({ variants = [opacity()], style, direction = "horizontal", interval = 3000, duration = 0.3, ...props }) {
|
|
6
|
+
return (_jsx(motion.div, { className: cn("w-full", style), transition: { duration: duration }, ...mergeVariants(...variants), ...props }));
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Merges multiple variant configs into one.
|
|
10
|
+
*/
|
|
11
|
+
export function mergeVariants(...variants) {
|
|
12
|
+
return variants.reduce((acc, v) => ({
|
|
13
|
+
initial: { ...acc.initial, ...v.initial },
|
|
14
|
+
animate: { ...acc.animate, ...v.animate },
|
|
15
|
+
exit: { ...acc.exit, ...v.exit },
|
|
16
|
+
}), { initial: {}, animate: {}, exit: {} });
|
|
17
|
+
}
|
|
18
|
+
export const opacity = (x = 1) => ({
|
|
19
|
+
initial: { opacity: 0 },
|
|
20
|
+
animate: { opacity: x },
|
|
21
|
+
exit: { opacity: 0 }
|
|
22
|
+
});
|
|
23
|
+
export const slideX = (x = 5) => ({
|
|
24
|
+
initial: { x: x },
|
|
25
|
+
animate: { x: 0 },
|
|
26
|
+
exit: { x: -x }
|
|
27
|
+
});
|
|
28
|
+
export const slideY = (y = 5) => ({
|
|
29
|
+
initial: { y: y },
|
|
30
|
+
animate: { y: 0 },
|
|
31
|
+
exit: { y: -y }
|
|
32
|
+
});
|
|
33
|
+
export { AnimatePresence } from "framer-motion";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { type Field } from "./form/types";
|
|
2
|
-
export default function Attachment({ id, style, label, value, update, required, note }: Field<File[], File[]>): import("react/jsx-runtime").JSX.Element;
|
|
1
|
+
import { type Field } from "./form/types";
|
|
2
|
+
export default function Attachment({ id, style, label, value, update, required, note }: Field<File[], File[]>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { useRef } from "react";
|
|
3
|
-
import PaperClip from "../assets/icons/paperclip.svg";
|
|
4
|
-
import { cn } from "@bouko/style";
|
|
5
|
-
export default function Attachment({ id, style, label, value, update, required = true, note }) {
|
|
6
|
-
const ref = useRef(null);
|
|
7
|
-
const handleFileChange = (e) => {
|
|
8
|
-
if (e.target.files && id)
|
|
9
|
-
update(Array.from(e.target.files));
|
|
10
|
-
};
|
|
11
|
-
return (_jsxs("div", { className: cn(styles.container, style), children: [label && _jsxs("span", { className: styles.label, children: [label, " ", !required ? _jsx("span", { className: "italic text-slate-400", children: "(optional)" }
|
|
12
|
-
}
|
|
13
|
-
const styles = {
|
|
14
|
-
container: "flex flex-col gap-2 w-full shrink-0 overflow-hidden",
|
|
15
|
-
label: "text-xs text-slate-600",
|
|
16
|
-
input: "px-3 py-2 bg-slate-200/50 border border-slate-300 outline-blue-500 rounded text-sm",
|
|
17
|
-
note: "mt-1 text-xs text-slate-500"
|
|
18
|
-
};
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useRef } from "react";
|
|
3
|
+
import PaperClip from "../assets/icons/paperclip.svg";
|
|
4
|
+
import { cn } from "@bouko/style";
|
|
5
|
+
export default function Attachment({ id, style, label, value, update, required = true, note }) {
|
|
6
|
+
const ref = useRef(null);
|
|
7
|
+
const handleFileChange = (e) => {
|
|
8
|
+
if (e.target.files && id)
|
|
9
|
+
update(Array.from(e.target.files));
|
|
10
|
+
};
|
|
11
|
+
return (_jsxs("div", { className: cn(styles.container, style), children: [label && _jsxs("span", { className: styles.label, children: [label, " ", !required ? _jsx("span", { className: "italic text-slate-400", children: "(optional)" }) : ""] }), _jsxs("div", { onClick: () => ref.current?.click(), className: "flex flex-col justify-center items-center py-3 gap-1 w-full cursor-pointer duration-200 hover:bg-slate-200/40 rounded border-2 border-slate-300 border-dashed", children: [!value || value.length === 0 && (_jsxs(_Fragment, { children: [_jsxs("span", { className: "flex gap-2 items-center font-semibold text-sm", children: [_jsx(PaperClip, {}), "Drag and drop files, paste screenshots, or"] }), _jsx("span", { className: "text-xs text-slate-500", children: "browse" }), _jsx("input", { type: "file", className: "hidden", onChange: handleFileChange, multiple: true, ref: ref })] })), value && value.length > 0 && value.map((x, i) => (_jsx("span", { className: "text-xs text-slate-500", children: x.name }, i)))] }), note && _jsx("span", { className: styles.note, children: note })] }));
|
|
12
|
+
}
|
|
13
|
+
const styles = {
|
|
14
|
+
container: "flex flex-col gap-2 w-full shrink-0 overflow-hidden",
|
|
15
|
+
label: "text-xs text-slate-600",
|
|
16
|
+
input: "px-3 py-2 bg-slate-200/50 border border-slate-300 outline-blue-500 rounded text-sm",
|
|
17
|
+
note: "mt-1 text-xs text-slate-500"
|
|
18
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
type Props = {
|
|
2
|
+
ms?: number;
|
|
3
|
+
sec?: number;
|
|
4
|
+
size?: "sm" | "md";
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Audio timestamp component.
|
|
8
|
+
*
|
|
9
|
+
* @param {number} x - The time to display (ms).
|
|
10
|
+
**/
|
|
11
|
+
export declare const Timestamp: ({ ms, sec, ...props }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Badge } from "../text/badge";
|
|
3
|
+
import { mmSS } from "@bouko/ts";
|
|
4
|
+
/**
|
|
5
|
+
* Audio timestamp component.
|
|
6
|
+
*
|
|
7
|
+
* @param {number} x - The time to display (ms).
|
|
8
|
+
**/
|
|
9
|
+
export const Timestamp = ({ ms, sec, ...props }) => (_jsx(Badge, { style: "font-mono", color: "--color-background-dark", ...props, children: mmSS(ms ? ms : sec ? sec * 1000 : 0) }));
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { ReactNode } from "react";
|
|
2
|
-
import type { Clickable } from "../../core/types";
|
|
3
|
-
|
|
4
|
-
style?: string;
|
|
5
|
-
color?: string;
|
|
6
|
-
icon: ReactNode;
|
|
7
|
-
disabled?: boolean;
|
|
8
|
-
};
|
|
9
|
-
export default function IconButton({ style, color, icon, action, disabled }: Props): import("react/jsx-runtime").JSX.Element;
|
|
10
|
-
export {};
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import type { Clickable } from "../../core/types";
|
|
3
|
+
type Props = Clickable & {
|
|
4
|
+
style?: string;
|
|
5
|
+
color?: string;
|
|
6
|
+
icon: ReactNode;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
};
|
|
9
|
+
export default function IconButton({ style, color, icon, action, disabled }: Props): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { cn, opacitize } from "@bouko/style";
|
|
3
|
-
export default function IconButton({ style, color = "--color-accent", icon, action, disabled = false }) {
|
|
4
|
-
return (_jsx("button", { className: cn("flex hover:brightness-115 disabled:!cursor-not-allowed", style), style: styles(color), onClick: action, disabled: !action || disabled, children: icon }
|
|
5
|
-
}
|
|
6
|
-
const styles = (color) => ({
|
|
7
|
-
justifyContent: "center",
|
|
8
|
-
itemsCenter: "center",
|
|
9
|
-
padding: "0.5rem",
|
|
10
|
-
background: opacitize(color, 60),
|
|
11
|
-
border: `1px solid var(${color})`,
|
|
12
|
-
borderRadius: "100%",
|
|
13
|
-
outline: "none",
|
|
14
|
-
fontSize: "0.75rem",
|
|
15
|
-
fontWeight: "600",
|
|
16
|
-
color: opacitize("--color-primary", 80),
|
|
17
|
-
transitionDuration: "200ms",
|
|
18
|
-
cursor: "pointer"
|
|
19
|
-
});
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { cn, opacitize } from "@bouko/style";
|
|
3
|
+
export default function IconButton({ style, color = "--color-accent", icon, action, disabled = false }) {
|
|
4
|
+
return (_jsx("button", { className: cn("flex hover:brightness-115 disabled:!cursor-not-allowed", style), style: styles(color), onClick: action, disabled: !action || disabled, children: icon }));
|
|
5
|
+
}
|
|
6
|
+
const styles = (color) => ({
|
|
7
|
+
justifyContent: "center",
|
|
8
|
+
itemsCenter: "center",
|
|
9
|
+
padding: "0.5rem",
|
|
10
|
+
background: opacitize(color, 60),
|
|
11
|
+
border: `1px solid var(${color})`,
|
|
12
|
+
borderRadius: "100%",
|
|
13
|
+
outline: "none",
|
|
14
|
+
fontSize: "0.75rem",
|
|
15
|
+
fontWeight: "600",
|
|
16
|
+
color: opacitize("--color-primary", 80),
|
|
17
|
+
transitionDuration: "200ms",
|
|
18
|
+
cursor: "pointer"
|
|
19
|
+
});
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { ReactNode } from "react";
|
|
2
|
-
import type { Component } from "../../core/types";
|
|
3
|
-
export
|
|
4
|
-
variant?: "primary" | "outline" | "ghost" | "secondary";
|
|
5
|
-
size?: "xs" | "sm" | "md" | "lg";
|
|
6
|
-
icon?: ReactNode;
|
|
7
|
-
action?: () => void;
|
|
8
|
-
disabled?: boolean;
|
|
9
|
-
};
|
|
10
|
-
export declare function Button({ size, variant, style, icon, action, disabled, children }: ButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
11
|
-
export default Button;
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
import type { Component } from "../../core/types";
|
|
3
|
+
export type ButtonProps = Component & {
|
|
4
|
+
variant?: "primary" | "outline" | "ghost" | "secondary";
|
|
5
|
+
size?: "xs" | "sm" | "md" | "lg";
|
|
6
|
+
icon?: ReactNode;
|
|
7
|
+
action?: () => void;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
};
|
|
10
|
+
export declare function Button({ size, variant, style, icon, action, disabled, children }: ButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export default Button;
|
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { useState } from "react";
|
|
4
|
-
import { cn, tv } from "@bouko/style";
|
|
5
|
-
import Spinner from "../../assets/icons/spinner.svg";
|
|
6
|
-
export function Button({ size, variant, style, icon, action, disabled, children }) {
|
|
7
|
-
const [isLoading, setLoading] = useState(false);
|
|
8
|
-
const submit = async () => {
|
|
9
|
-
setLoading(true);
|
|
10
|
-
try {
|
|
11
|
-
await action?.();
|
|
12
|
-
}
|
|
13
|
-
catch { }
|
|
14
|
-
setLoading(false);
|
|
15
|
-
};
|
|
16
|
-
return (_jsxs("button", { className: cn(styles({ variant, size }), variant === "ghost" && "p-0", style), onClick: submit, disabled: disabled || isLoading, children: [icon && isLoading
|
|
17
|
-
? _jsx(Spinner, { className: "animate-spin" }
|
|
18
|
-
: icon, children] }
|
|
19
|
-
}
|
|
20
|
-
const styles = tv({
|
|
21
|
-
base: "flex justify-center items-center gap-2 bg-accent border border-accent-darker rounded font-semibold text-background-light duration-200 cursor-pointer disabled:cursor-not-allowed hover:brightness-110",
|
|
22
|
-
defaultVariants: { size: "md" },
|
|
23
|
-
variants: {
|
|
24
|
-
variant: {
|
|
25
|
-
primary: "bg-primary border-primary-dark",
|
|
26
|
-
outline: "bg-transparent border-accent hover:border-accent-dark text-primary",
|
|
27
|
-
ghost: "bg-transparent border-transparent text-accent hover:brightness-110",
|
|
28
|
-
secondary: "bg-background-dark dark:bg-background-light border-border-dark dark:border-border-light text-background-darker dark:text-primary"
|
|
29
|
-
},
|
|
30
|
-
size: {
|
|
31
|
-
xs: "px-3 py-1 text-xs",
|
|
32
|
-
circle: "px-2 py-2 text-xs rounded-full",
|
|
33
|
-
sm: "px-3 py-2 text-xs sm:text-sm",
|
|
34
|
-
md: "px-4 py-2",
|
|
35
|
-
lg: "px-5 py-3 text-lg"
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
export default Button;
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
import { cn, tv } from "@bouko/style";
|
|
5
|
+
import Spinner from "../../assets/icons/spinner.svg";
|
|
6
|
+
export function Button({ size, variant, style, icon, action, disabled, children }) {
|
|
7
|
+
const [isLoading, setLoading] = useState(false);
|
|
8
|
+
const submit = async () => {
|
|
9
|
+
setLoading(true);
|
|
10
|
+
try {
|
|
11
|
+
await action?.();
|
|
12
|
+
}
|
|
13
|
+
catch { }
|
|
14
|
+
setLoading(false);
|
|
15
|
+
};
|
|
16
|
+
return (_jsxs("button", { className: cn(styles({ variant, size }), variant === "ghost" && "p-0", style), onClick: submit, disabled: disabled || isLoading, children: [icon && isLoading
|
|
17
|
+
? _jsx(Spinner, { className: "animate-spin" })
|
|
18
|
+
: icon, children] }));
|
|
19
|
+
}
|
|
20
|
+
const styles = tv({
|
|
21
|
+
base: "flex justify-center items-center gap-2 bg-accent border border-accent-darker rounded font-semibold text-background-light duration-200 cursor-pointer disabled:cursor-not-allowed hover:brightness-110",
|
|
22
|
+
defaultVariants: { size: "md" },
|
|
23
|
+
variants: {
|
|
24
|
+
variant: {
|
|
25
|
+
primary: "bg-primary border-primary-dark",
|
|
26
|
+
outline: "bg-transparent border-accent hover:border-accent-dark text-primary",
|
|
27
|
+
ghost: "bg-transparent border-transparent text-accent hover:brightness-110",
|
|
28
|
+
secondary: "bg-background-dark dark:bg-background-light border-border-dark dark:border-border-light text-background-darker dark:text-primary"
|
|
29
|
+
},
|
|
30
|
+
size: {
|
|
31
|
+
xs: "px-3 py-1 text-xs",
|
|
32
|
+
circle: "px-2 py-2 text-xs rounded-full",
|
|
33
|
+
sm: "px-3 py-2 text-xs sm:text-sm",
|
|
34
|
+
md: "px-4 py-2",
|
|
35
|
+
lg: "px-5 py-3 text-lg"
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
export default Button;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { ReactNode } from "react";
|
|
2
|
-
export
|
|
3
|
-
container?: string;
|
|
4
|
-
items: T[];
|
|
5
|
-
direction?: "horizontal" | "vertical";
|
|
6
|
-
interval?: number;
|
|
7
|
-
duration?: number;
|
|
8
|
-
autoplay?: boolean;
|
|
9
|
-
style?: string;
|
|
10
|
-
};
|
|
11
|
-
export declare function Carousel({ container, style, items, direction, autoplay, interval, ...props }: CarouselProps): import("react/jsx-runtime").JSX.Element;
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
export type CarouselProps<T = ReactNode> = {
|
|
3
|
+
container?: string;
|
|
4
|
+
items: T[];
|
|
5
|
+
direction?: "horizontal" | "vertical";
|
|
6
|
+
interval?: number;
|
|
7
|
+
duration?: number;
|
|
8
|
+
autoplay?: boolean;
|
|
9
|
+
style?: string;
|
|
10
|
+
};
|
|
11
|
+
export declare function Carousel({ container, style, items, direction, autoplay, interval, ...props }: CarouselProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import { AnimatePresence } from "framer-motion";
|
|
4
|
-
import { Animation } from "../animate";
|
|
5
|
-
import { useState, useEffect } from "react";
|
|
6
|
-
import { opacity, slideX, slideY } from "../animate";
|
|
7
|
-
import { cn } from "@bouko/style";
|
|
8
|
-
export function Carousel({ container, style, items, direction = "horizontal", autoplay = true, interval = 3000, ...props }) {
|
|
9
|
-
const [index, setIndex] = useState(0);
|
|
10
|
-
useEffect(() => {
|
|
11
|
-
if (items.length === 0 || !autoplay)
|
|
12
|
-
return;
|
|
13
|
-
const intervalTracker = setInterval(() => {
|
|
14
|
-
setIndex((prev) => (prev + 1) % items.length);
|
|
15
|
-
}, interval);
|
|
16
|
-
return () => clearInterval(intervalTracker);
|
|
17
|
-
}, [items.length, interval, autoplay]);
|
|
18
|
-
return (_jsx("div", { className: cn("flex items-center", container), children: _jsx(AnimatePresence, { mode: "wait", children: _jsx(Animation, { style: cn("w-full", style), variants: [opacity(), direction === "horizontal" ? slideX() : slideY()], children: items[index], ...props }, index) }
|
|
19
|
-
}
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { AnimatePresence } from "framer-motion";
|
|
4
|
+
import { Animation } from "../animate";
|
|
5
|
+
import { useState, useEffect } from "react";
|
|
6
|
+
import { opacity, slideX, slideY } from "../animate";
|
|
7
|
+
import { cn } from "@bouko/style";
|
|
8
|
+
export function Carousel({ container, style, items, direction = "horizontal", autoplay = true, interval = 3000, ...props }) {
|
|
9
|
+
const [index, setIndex] = useState(0);
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
if (items.length === 0 || !autoplay)
|
|
12
|
+
return;
|
|
13
|
+
const intervalTracker = setInterval(() => {
|
|
14
|
+
setIndex((prev) => (prev + 1) % items.length);
|
|
15
|
+
}, interval);
|
|
16
|
+
return () => clearInterval(intervalTracker);
|
|
17
|
+
}, [items.length, interval, autoplay]);
|
|
18
|
+
return (_jsx("div", { className: cn("flex items-center", container), children: _jsx(AnimatePresence, { mode: "wait", children: _jsx(Animation, { style: cn("w-full", style), variants: [opacity(), direction === "horizontal" ? slideX() : slideY()], children: items[index], ...props }, index) }) }));
|
|
19
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
style?: string;
|
|
3
|
-
label: string;
|
|
4
|
-
value: boolean;
|
|
5
|
-
update: (x: boolean) => void;
|
|
6
|
-
};
|
|
7
|
-
export default function Checkbox({ style, label, value, update }: Props): import("react/jsx-runtime").JSX.Element;
|
|
8
|
-
export {};
|
|
1
|
+
type Props = {
|
|
2
|
+
style?: string;
|
|
3
|
+
label: string;
|
|
4
|
+
value: boolean;
|
|
5
|
+
update: (x: boolean) => void;
|
|
6
|
+
};
|
|
7
|
+
export default function Checkbox({ style, label, value, update }: Props): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export {};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import Check from "../assets/icons/check.svg";
|
|
3
|
-
import { cn } from "@bouko/style";
|
|
4
|
-
export default function Checkbox({ style, label, value, update }) {
|
|
5
|
-
const isChecked = !!value;
|
|
6
|
-
return (_jsxs("div", { className: cn(styles.container, style), children: [_jsx("div", { className: cn(styles.box, isChecked && "bg-accent"), onClick: () => update(!isChecked), children: isChecked && _jsx(Check, { className: styles.check }
|
|
7
|
-
}
|
|
8
|
-
const styles = {
|
|
9
|
-
container: "flex gap-3 items-center",
|
|
10
|
-
box: "flex justify-center items-center size-4 min-w-4 hover:bg-accent border rounded border-border-light duration-200 cursor-pointer",
|
|
11
|
-
check: "size-2 text-background",
|
|
12
|
-
label: "text-xs text-primary-dark"
|
|
13
|
-
};
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import Check from "../assets/icons/check.svg";
|
|
3
|
+
import { cn } from "@bouko/style";
|
|
4
|
+
export default function Checkbox({ style, label, value, update }) {
|
|
5
|
+
const isChecked = !!value;
|
|
6
|
+
return (_jsxs("div", { className: cn(styles.container, style), children: [_jsx("div", { className: cn(styles.box, isChecked && "bg-accent"), onClick: () => update(!isChecked), children: isChecked && _jsx(Check, { className: styles.check }) }), _jsx("span", { className: styles.label, children: label })] }));
|
|
7
|
+
}
|
|
8
|
+
const styles = {
|
|
9
|
+
container: "flex gap-3 items-center",
|
|
10
|
+
box: "flex justify-center items-center size-4 min-w-4 hover:bg-accent border rounded border-border-light duration-200 cursor-pointer",
|
|
11
|
+
check: "size-2 text-background",
|
|
12
|
+
label: "text-xs text-primary-dark"
|
|
13
|
+
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { ReactNode } from "react";
|
|
2
|
-
|
|
3
|
-
label: ReactNode;
|
|
4
|
-
action: () => void;
|
|
5
|
-
};
|
|
6
|
-
export default function Dropdown({ options, children }: {
|
|
7
|
-
options: Option[];
|
|
8
|
-
children: ReactNode;
|
|
9
|
-
}): import("react/jsx-runtime").JSX.Element;
|
|
10
|
-
export {};
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
type Option = {
|
|
3
|
+
label: ReactNode;
|
|
4
|
+
action: () => void;
|
|
5
|
+
};
|
|
6
|
+
export default function Dropdown({ options, children }: {
|
|
7
|
+
options: Option[];
|
|
8
|
+
children: ReactNode;
|
|
9
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { useState } from "react";
|
|
4
|
-
import { AnimatePresence, motion } from "framer-motion";
|
|
5
|
-
export default function Dropdown({ options, children }) {
|
|
6
|
-
const [isOpen, setOpen] = useState(false);
|
|
7
|
-
const boom = (action) => {
|
|
8
|
-
action();
|
|
9
|
-
setOpen(false);
|
|
10
|
-
};
|
|
11
|
-
return (_jsxs("div", { className: styles.container, children: [_jsx("div", { onClick: () => setOpen(true), children: children }
|
|
12
|
-
}
|
|
13
|
-
const styles = {
|
|
14
|
-
container: "relative shrink-0",
|
|
15
|
-
subcontainer: "flex flex-col gap-1 w-full",
|
|
16
|
-
label: "text-xs text-slate-600",
|
|
17
|
-
trigger: "flex justify-between items-center px-3 py-2 bg-slate-200/50 hover:bg-slate-200/80 border border-slate-300 outline-blue-500 rounded text-sm duration-200 cursor-pointer",
|
|
18
|
-
dropdown: "absolute mt-2 z-50 flex flex-col items-end justify-end gap-1 w-full bg-slate-950 rounded border border-border-dark p-3 pr-4 text-sm max-h-46 overflow-y-auto"
|
|
19
|
-
};
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
import { AnimatePresence, motion } from "framer-motion";
|
|
5
|
+
export default function Dropdown({ options, children }) {
|
|
6
|
+
const [isOpen, setOpen] = useState(false);
|
|
7
|
+
const boom = (action) => {
|
|
8
|
+
action();
|
|
9
|
+
setOpen(false);
|
|
10
|
+
};
|
|
11
|
+
return (_jsxs("div", { className: styles.container, children: [_jsx("div", { onClick: () => setOpen(true), children: children }), _jsx(AnimatePresence, { children: isOpen && (_jsx(motion.div, { className: styles.dropdown, initial: { opacity: 0 }, animate: { opacity: 1 }, exit: { opacity: 0 }, children: options.map(({ label, action }, i) => (_jsx("div", { className: "cursor-pointer duration-200 hover:brightness-115", onClick: () => boom(action), children: label }, i))) }, "dropdown")) })] }));
|
|
12
|
+
}
|
|
13
|
+
const styles = {
|
|
14
|
+
container: "relative shrink-0",
|
|
15
|
+
subcontainer: "flex flex-col gap-1 w-full",
|
|
16
|
+
label: "text-xs text-slate-600",
|
|
17
|
+
trigger: "flex justify-between items-center px-3 py-2 bg-slate-200/50 hover:bg-slate-200/80 border border-slate-300 outline-blue-500 rounded text-sm duration-200 cursor-pointer",
|
|
18
|
+
dropdown: "absolute mt-2 z-50 flex flex-col items-end justify-end gap-1 w-full bg-slate-950 rounded border border-border-dark p-3 pr-4 text-sm max-h-46 overflow-y-auto"
|
|
19
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ReactNode } from "react";
|
|
2
|
-
export default function FadeCarousel({ items }: {
|
|
3
|
-
items: ReactNode[];
|
|
4
|
-
}): import("react/jsx-runtime").JSX.Element;
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
export default function FadeCarousel({ items }: {
|
|
3
|
+
items: ReactNode[];
|
|
4
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,14 +1,14 @@
|
|
|
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
|
-
export default function FadeCarousel({ items }) {
|
|
6
|
-
const [index, setIndex] = useState(0);
|
|
7
|
-
useEffect(() => {
|
|
8
|
-
const interval = setInterval(() => {
|
|
9
|
-
setIndex((prev) => (prev + 1) % items.length);
|
|
10
|
-
}, 2000);
|
|
11
|
-
return () => clearInterval(interval);
|
|
12
|
-
}, []);
|
|
13
|
-
return (_jsx(AnimatePresence, { mode: "wait", children: _jsx(motion.div, { className: "absolute", transition: { duration: 0.5 }, initial: { opacity: 0, y: 5 }, animate: { opacity: 1, y: 0 }, exit: { opacity: 0, y: -5 }, children: items[index] }, index) }
|
|
14
|
-
}
|
|
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
|
+
export default function FadeCarousel({ items }) {
|
|
6
|
+
const [index, setIndex] = useState(0);
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
const interval = setInterval(() => {
|
|
9
|
+
setIndex((prev) => (prev + 1) % items.length);
|
|
10
|
+
}, 2000);
|
|
11
|
+
return () => clearInterval(interval);
|
|
12
|
+
}, []);
|
|
13
|
+
return (_jsx(AnimatePresence, { mode: "wait", children: _jsx(motion.div, { className: "absolute", transition: { duration: 0.5 }, initial: { opacity: 0, y: 5 }, animate: { opacity: 1, y: 0 }, exit: { opacity: 0, y: -5 }, children: items[index] }, index) }));
|
|
14
|
+
}
|