@dtcode/ui 0.1.0 → 0.2.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/button.d.ts CHANGED
@@ -1,9 +1,10 @@
1
1
  export type ButtonVariant = "primary" | "secondary" | "accent" | "ghost" | "danger";
2
2
  export type ButtonSize = "sm" | "md" | "lg";
3
- export declare function buttonClasses({ variant, size, block, className, }?: {
3
+ export declare function buttonClasses({ variant, size, block, loading, className, }?: {
4
4
  variant?: ButtonVariant;
5
5
  size?: ButtonSize;
6
6
  block?: boolean;
7
+ loading?: boolean;
7
8
  className?: string;
8
9
  }): string;
9
10
  export type ButtonProps = React.ComponentProps<"button"> & {
@@ -14,6 +15,8 @@ export type ButtonProps = React.ComponentProps<"button"> & {
14
15
  /** Material Symbol exibido depois do texto. */
15
16
  iconRight?: string;
16
17
  loading?: boolean;
18
+ /** Texto anunciado por leitores de tela durante o carregamento. */
19
+ loadingLabel?: string;
17
20
  block?: boolean;
18
21
  };
19
- export declare function Button({ variant, size, icon, iconRight, loading, block, className, children, disabled, type, ...props }: ButtonProps): import("react").JSX.Element;
22
+ export declare function Button({ variant, size, icon, iconRight, loading, loadingLabel, block, className, children, disabled, type, ...props }: ButtonProps): import("react").JSX.Element;
package/dist/button.js CHANGED
@@ -5,8 +5,10 @@ import { Loader } from "./loader.js";
5
5
  const base = "group/btn inline-flex items-center justify-center gap-2 whitespace-nowrap border border-transparent font-semibold " +
6
6
  "transition-[translate,scale,box-shadow,background-color,color,opacity] duration-150 ease-brand " +
7
7
  "hover:-translate-y-px active:translate-y-0 active:scale-[.97] " +
8
- "disabled:pointer-events-none disabled:opacity-45 disabled:shadow-none " +
9
8
  "focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus";
9
+ const disabledCls = "disabled:pointer-events-none disabled:opacity-45 disabled:shadow-none";
10
+ // Carregando (como no login): mantém a cor do botão, sem esmaecer como desabilitado, e só bloqueia o clique.
11
+ const loadingCls = "pointer-events-none cursor-progress";
10
12
  const variants = {
11
13
  primary: "bg-action text-on-action shadow-2 hover:bg-action-hover hover:shadow-3",
12
14
  secondary: "bg-surface text-fg border-border-strong shadow-1 hover:bg-surface-subtle",
@@ -21,9 +23,11 @@ const sizes = {
21
23
  lg: "h-13 px-6 text-[17px] font-bold rounded-lg",
22
24
  };
23
25
  const iconSize = { sm: 16, md: 18, lg: 20 };
24
- export function buttonClasses({ variant = "primary", size = "md", block, className, } = {}) {
25
- return cn(base, variants[variant], sizes[size], block && "w-full", className);
26
+ export function buttonClasses({ variant = "primary", size = "md", block, loading, className, } = {}) {
27
+ return cn(base, variants[variant], sizes[size], loading ? loadingCls : disabledCls, block && "w-full", className);
26
28
  }
27
- export function Button({ variant, size = "md", icon, iconRight, loading, block, className, children, disabled, type = "button", ...props }) {
28
- return (_jsxs("button", { type: type, className: buttonClasses({ variant, size, block, className }), disabled: disabled || loading, "aria-busy": loading || undefined, ...props, children: [loading ? _jsx(Loader, { size: "sm" }) : icon && _jsx(Icon, { name: icon, size: iconSize[size] }), children, iconRight && !loading && (_jsx(Icon, { name: iconRight, size: iconSize[size], className: "transition-[translate] duration-200 ease-brand group-hover/btn:translate-x-0.5" }))] }));
29
+ export function Button({ variant, size = "md", icon, iconRight, loading, loadingLabel, block, className, children, disabled, type = "button", ...props }) {
30
+ return (_jsxs("button", { type: type, className: buttonClasses({ variant, size, block, loading, className }), disabled: disabled || loading, "aria-busy": loading || undefined, ...props, children: [loading ? (
31
+ // No accent o fundo já é o gradiente da marca: os losangos ficam na cor do texto para aparecer.
32
+ _jsx(Loader, { size: "sm", label: loadingLabel, className: variant === "accent" ? "[&_i]:bg-current [&_i]:bg-none" : undefined })) : (icon && _jsx(Icon, { name: icon, size: iconSize[size] })), children, iconRight && !loading && (_jsx(Icon, { name: iconRight, size: iconSize[size], className: "transition-[translate] duration-200 ease-brand group-hover/btn:translate-x-0.5" }))] }));
29
33
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dtcode/ui",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Componentes React e tokens do Design System dtcode (Tailwind CSS v4).",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {