@bouko/react 2.3.4 → 2.3.6

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,10 @@
1
+ import type { ReactNode } from "react";
2
+ export type ButtonProps = {
3
+ variant?: "primary" | "outline" | "ghost";
4
+ size?: "xs" | "sm" | "md" | "lg";
5
+ style?: string;
6
+ onClick?: () => void;
7
+ disabled?: boolean;
8
+ children: ReactNode;
9
+ };
10
+ export default function LoadButton({ size, variant, style, onClick, children, ...props }: ButtonProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,35 @@
1
+ "use state";
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 CheckCircle from "../../assets/icons/check-circle.svg";
6
+ import Spinner from "../../assets/icons/spinner.svg";
7
+ export default function LoadButton({ size, variant, style, onClick, children, ...props }) {
8
+ const [isLoading, setLoading] = useState(false);
9
+ const submit = async () => {
10
+ setLoading(true);
11
+ try {
12
+ await onClick?.();
13
+ }
14
+ catch { }
15
+ setLoading(false);
16
+ };
17
+ return (_jsxs("button", { className: cn(styles({ variant, size }), style), onClick: submit, ...props, children: [isLoading ? _jsx(Spinner, { className: "animate-spin" }) : _jsx(CheckCircle, {}), children] }));
18
+ }
19
+ const styles = tv({
20
+ base: "flex justify-center items-center gap-2 bg-accent hover:bg-accent-dark border border-accent-dark rounded font-semibold text-background-light duration-200 cursor-pointer disabled:cursor-not-allowed",
21
+ defaultVariants: { size: "md" },
22
+ variants: {
23
+ variant: {
24
+ primary: "bg-primary hover:bg-primary-dark border-primary-dark",
25
+ outline: "!bg-transparent border-accent hover:border-accent-dark text-primary",
26
+ ghost: "!bg-transparent border-transparent text-accent hover:text-accent-dark"
27
+ },
28
+ size: {
29
+ xs: "px-3 py-1 text-xs",
30
+ sm: "px-4 py-2 text-xs sm:text-sm",
31
+ md: "px-4 py-2",
32
+ lg: "px-5 py-3 text-lg"
33
+ }
34
+ }
35
+ });
@@ -35,3 +35,4 @@ export type OptionField<T> = Field<T> & {
35
35
  export type Form<T> = {
36
36
  data: T;
37
37
  };
38
+ export type FormSubmit<T> = (data: T, clear?: () => void) => Promise<void>;
@@ -3,6 +3,7 @@ export { default as FadeBox } from "./layout/fade";
3
3
  export { default as Heading } from "./heading/normal";
4
4
  export { default as PageHeading } from "./heading/page";
5
5
  export * from "./layout/flex";
6
+ export { default as LoadButton } from "./button/load";
6
7
  export { default as Badge } from "./text/badge";
7
8
  export { default as Dropdown } from "./dropdown/normal";
8
9
  export { default as FileUploader } from "./upload/file";
@@ -3,6 +3,7 @@ export { default as FadeBox } from "./layout/fade";
3
3
  export { default as Heading } from "./heading/normal";
4
4
  export { default as PageHeading } from "./heading/page";
5
5
  export * from "./layout/flex";
6
+ export { default as LoadButton } from "./button/load";
6
7
  export { default as Badge } from "./text/badge";
7
8
  export { default as Dropdown } from "./dropdown/normal";
8
9
  export { default as FileUploader } from "./upload/file";
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  "name": "@bouko/react",
4
4
 
5
- "version": "2.3.4",
5
+ "version": "2.3.6",
6
6
 
7
7
  "main": "./dist/index.js",
8
8