@bouko/react 2.4.8 → 2.5.0
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/components/button/normal.d.ts +2 -3
- package/dist/components/layout/fade.d.ts +2 -2
- package/dist/components/layout/fade.js +2 -1
- package/dist/components/layout/flex.d.ts +3 -3
- package/dist/components/layout/flex.js +4 -4
- package/dist/components/search-bar.d.ts +6 -4
- package/dist/components/search-bar.js +21 -7
- package/dist/components/waveform/index.d.ts +8 -0
- package/dist/components/waveform/index.js +11 -0
- package/dist/components/waveform/patterns.d.ts +1 -0
- package/dist/components/waveform/patterns.js +27 -0
- package/dist/core/types.d.ts +3 -4
- package/package.json +4 -1
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { ReactNode } from "react";
|
|
2
|
-
|
|
2
|
+
import { Component } from "../../core/types";
|
|
3
|
+
export declare type ButtonProps = Component & {
|
|
3
4
|
variant?: "primary" | "outline" | "ghost";
|
|
4
5
|
size?: "xs" | "sm" | "md" | "lg";
|
|
5
|
-
style?: string;
|
|
6
6
|
icon?: ReactNode;
|
|
7
7
|
action?: () => void;
|
|
8
8
|
disabled?: boolean;
|
|
9
|
-
children: ReactNode;
|
|
10
9
|
};
|
|
11
10
|
export declare function Button({ size, variant, style, icon, action, disabled, children }: ButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
12
11
|
export default Button;
|
|
@@ -2,5 +2,5 @@ import { Component } from "../../core/types";
|
|
|
2
2
|
declare type Props = Component & {
|
|
3
3
|
gradient?: string;
|
|
4
4
|
};
|
|
5
|
-
export
|
|
6
|
-
export
|
|
5
|
+
export declare function FadeBox({ style, gradient, children }: Props): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export default FadeBox;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { cn, tv } from "@bouko/style";
|
|
3
|
-
export
|
|
3
|
+
export function FadeBox({ style, gradient, children }) {
|
|
4
4
|
const direction = "left";
|
|
5
5
|
return (_jsxs("div", { className: cn("relative", style), children: [children, _jsx("div", { className: cn(styles({ direction }), gradient) }, void 0)] }, void 0));
|
|
6
6
|
}
|
|
@@ -12,3 +12,4 @@ const styles = tv({
|
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
});
|
|
15
|
+
export default FadeBox;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Component } from "../../core/types";
|
|
1
|
+
import type { Component } from "../../core/types";
|
|
2
2
|
declare type Props = Component & {
|
|
3
3
|
center?: boolean;
|
|
4
4
|
centerX?: boolean;
|
|
@@ -11,6 +11,6 @@ declare type Props = Component & {
|
|
|
11
11
|
* @param {ReactNode} children - Child elements to render inside the row.
|
|
12
12
|
* @param {Props} opts - Variant options for styling.
|
|
13
13
|
**/
|
|
14
|
-
export declare
|
|
15
|
-
export declare
|
|
14
|
+
export declare function RowBox({ style, children, ...opts }: Props): import("react/jsx-runtime").JSX.Element | null;
|
|
15
|
+
export declare function ColumnBox({ style, children, ...opts }: Props): import("react/jsx-runtime").JSX.Element | null;
|
|
16
16
|
export {};
|
|
@@ -7,16 +7,16 @@ import { cn, tv } from "@bouko/style";
|
|
|
7
7
|
* @param {ReactNode} children - Child elements to render inside the row.
|
|
8
8
|
* @param {Props} opts - Variant options for styling.
|
|
9
9
|
**/
|
|
10
|
-
export
|
|
10
|
+
export function RowBox({ style, children, ...opts }) {
|
|
11
11
|
if (!children)
|
|
12
12
|
return null;
|
|
13
13
|
return (_jsx("div", { className: cn(row(opts), style), children: children }, void 0));
|
|
14
|
-
}
|
|
15
|
-
export
|
|
14
|
+
}
|
|
15
|
+
export function ColumnBox({ style, children, ...opts }) {
|
|
16
16
|
if (!children)
|
|
17
17
|
return null;
|
|
18
18
|
return (_jsx("div", { className: cn(column(opts), style), children: children }, void 0));
|
|
19
|
-
}
|
|
19
|
+
}
|
|
20
20
|
/**
|
|
21
21
|
* Styling variants for flex options.
|
|
22
22
|
*
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
declare type Props<T> = {
|
|
2
3
|
style?: Styles;
|
|
3
4
|
placeholder?: string;
|
|
4
|
-
|
|
5
|
+
trigger?: React.ReactNode;
|
|
6
|
+
submit: (query: string) => Promise<T>;
|
|
5
7
|
};
|
|
6
8
|
declare type Styles = {
|
|
7
9
|
container?: string;
|
|
8
10
|
input?: string;
|
|
9
|
-
trigger
|
|
11
|
+
trigger?: string;
|
|
10
12
|
};
|
|
11
|
-
export declare function SearchBar({ style, placeholder,
|
|
13
|
+
export declare function SearchBar<T>({ style, placeholder, trigger, submit }: Props<T>): import("react/jsx-runtime").JSX.Element;
|
|
12
14
|
export {};
|
|
@@ -1,14 +1,28 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useState } from "react";
|
|
4
|
-
import { cn } from "@bouko/style";
|
|
5
|
-
import AnglesRight from "../assets/icons/angles-right.svg";
|
|
6
4
|
import { RowBox } from "./layout/flex";
|
|
5
|
+
import { FadeBox } from "./layout/fade";
|
|
7
6
|
import { Button } from "./button/normal";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
import { Input } from "@bouko/form";
|
|
8
|
+
import { mergeStyles } from "@bouko/style";
|
|
9
|
+
import { toast } from "@bouko/notify";
|
|
10
|
+
export function SearchBar({ style = {}, placeholder, trigger, submit }) {
|
|
11
|
+
const [query, setQuery] = useState("");
|
|
12
|
+
const styles = mergeStyles(base, style);
|
|
13
|
+
const search = async () => {
|
|
14
|
+
if (query === "")
|
|
15
|
+
return;
|
|
16
|
+
try {
|
|
17
|
+
await submit(query);
|
|
18
|
+
}
|
|
19
|
+
catch (err) {
|
|
20
|
+
toast.error(err.message);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
return (_jsxs(RowBox, { style: styles.container, children: [_jsx(FadeBox, { style: "grow", gradient: "from-slate-950", children: _jsx(Input, { variant: "ghost", style: styles.input, placeholder: placeholder, value: query, update: setQuery, onEnter: search }, void 0) }, void 0), trigger && (_jsx(Button, { variant: "ghost", style: style?.trigger, action: search, children: trigger }, void 0))] }, void 0));
|
|
11
24
|
}
|
|
12
|
-
const
|
|
13
|
-
container: "items-center gap-
|
|
25
|
+
const base = {
|
|
26
|
+
container: "items-center gap-5 w-xl max-w-full pl-5 pr-4 py-3 bg-slate-950 border border-border rounded-md",
|
|
27
|
+
input: "text-lg tracking-wide"
|
|
14
28
|
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type GenericPlugin } from "wavesurfer.js/dist/base-plugin";
|
|
2
|
+
declare type Props = {
|
|
3
|
+
file: File;
|
|
4
|
+
height: number;
|
|
5
|
+
plugins: GenericPlugin[];
|
|
6
|
+
};
|
|
7
|
+
export default function Waveform({ file, height, plugins }: Props): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useMemo } from "react";
|
|
4
|
+
import { squiggly } from "./patterns";
|
|
5
|
+
import { default as Player } from "@wavesurfer/react";
|
|
6
|
+
export default function Waveform({ file, height, plugins }) {
|
|
7
|
+
const url = useMemo(() => URL.createObjectURL(file), [file]);
|
|
8
|
+
const plugins2 = useMemo(() => plugins, [plugins]);
|
|
9
|
+
const waves = useMemo(() => squiggly, []);
|
|
10
|
+
return (_jsx(Player, { height: height, url: url, waveColor: "#1c1d23", progressColor: "#0085e4", cursorWidth: 2, renderFunction: waves, plugins: plugins2 }, void 0));
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function squiggly(channels: (Float32Array | number[])[], ctx: CanvasRenderingContext2D): void;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export function squiggly(channels, ctx) {
|
|
2
|
+
const { width, height } = ctx.canvas;
|
|
3
|
+
const scale = channels[0].length / width;
|
|
4
|
+
const step = 12;
|
|
5
|
+
ctx.translate(0, height / 2);
|
|
6
|
+
ctx.strokeStyle = ctx.fillStyle;
|
|
7
|
+
ctx.lineWidth = 3;
|
|
8
|
+
ctx.beginPath();
|
|
9
|
+
for (let i = 0; i < width; i += step * 2) {
|
|
10
|
+
const index = Math.floor(i * scale);
|
|
11
|
+
const value = Math.abs(channels[0][index]);
|
|
12
|
+
let x = i;
|
|
13
|
+
let y = value * height;
|
|
14
|
+
ctx.moveTo(x, 0);
|
|
15
|
+
ctx.lineTo(x, y);
|
|
16
|
+
ctx.arc(x + step / 2, y, step / 2, Math.PI, 0, true);
|
|
17
|
+
ctx.lineTo(x + step, 0);
|
|
18
|
+
x = x + step;
|
|
19
|
+
y = -y;
|
|
20
|
+
ctx.moveTo(x, 0);
|
|
21
|
+
ctx.lineTo(x, y);
|
|
22
|
+
ctx.arc(x + step / 2, y, step / 2, Math.PI, 0, false);
|
|
23
|
+
ctx.lineTo(x + step, 0);
|
|
24
|
+
}
|
|
25
|
+
ctx.stroke();
|
|
26
|
+
ctx.closePath();
|
|
27
|
+
}
|
package/dist/core/types.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { ReactNode } from "react";
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
2
|
/**
|
|
3
3
|
* Common props for React components.
|
|
4
4
|
*
|
|
5
|
-
* @property
|
|
6
|
-
* @property
|
|
7
|
-
* @property action - Executes on click
|
|
5
|
+
* @property `Component` - Component with Tailwind style(s) and children.
|
|
6
|
+
* @property `Clickable` - Component that executes a callback when clicked.
|
|
8
7
|
**/
|
|
9
8
|
export declare type Component = {
|
|
10
9
|
style?: string;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
|
|
3
3
|
"name": "@bouko/react",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.5.0",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
7
7
|
"license": "MIT",
|
|
@@ -21,13 +21,16 @@
|
|
|
21
21
|
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@bouko/audio": "^0.1.0",
|
|
24
|
+
"@bouko/form": "^0.5.7",
|
|
24
25
|
"@bouko/style": "^0.1.7",
|
|
26
|
+
"@wavesurfer/react": "^1.0.11",
|
|
25
27
|
"clsx": "^2.1.1",
|
|
26
28
|
"file-type": "^21.0.0",
|
|
27
29
|
"framer-motion": "^12.23.6",
|
|
28
30
|
"ms": "^2.1.3",
|
|
29
31
|
"tailwind-merge": "^3.3.1",
|
|
30
32
|
"tailwind-variants": "^1.0.0",
|
|
33
|
+
"wavesurfer.js": "^7.10.1",
|
|
31
34
|
"zod": "^4.0.13"
|
|
32
35
|
},
|
|
33
36
|
|