@raulaguila/maat-ui 0.2.2 → 0.3.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/README.md CHANGED
@@ -7,7 +7,7 @@ O pacote **@raulaguila/maat-ui** é a biblioteca de componentes da família Maat
7
7
  O pacote público requer React 19, React DOM 19 e Tailwind CSS 4. Escolha a versão em cada frontend:
8
8
 
9
9
  ```sh
10
- pnpm add --save-exact @raulaguila/maat-ui@0.2.2
10
+ pnpm add --save-exact @raulaguila/maat-ui@0.3.0
11
11
  ```
12
12
 
13
13
  Inclua o `package.json` e o `pnpm-lock.yaml` no mesmo commit.
@@ -38,6 +38,8 @@ Para localizar controles, envolva a aplicação em `FamilyUIProvider` com `label
38
38
 
39
39
  ## Componentes
40
40
 
41
+ `PasswordInput` oferece visibilidade da senha e informa o estado de Caps Lock. `ConfirmDialog` aguarda ações assíncronas, mantém o foco inicial em Cancelar para ações destrutivas e aceita `formatError` para mensagens do produto. `EmptyState` aceita ação opcional e variante compacta. `QueryErrorState` mostra uma mensagem de erro e oferece nova tentativa quando recebe `onRetry`. As aplicações fornecem traduções por `FamilyUIProvider` e decidem quando a operação pode ser repetida.
42
+
41
43
  O Seshat é a referência de apresentação. Quando o Thoth precisa de um controle adicional, ele usa os mesmos tokens, fontes e estados. Entre as extensões estão o seletor pesquisável, os grupos de campos, o painel recolhível e os gráficos. `IconAction` implementa o botão de ícone com nome acessível e tooltip. `PageTabs` mantém as abas endereçáveis pelo fragmento da URL.
42
44
 
43
45
  Os módulos opcionais `@raulaguila/maat-ui/chart` (Recharts) e `@raulaguila/maat-ui/sonner` (Sonner e next-themes) têm entradas próprias. Instale os respectivos peers no produto que os utiliza.
@@ -0,0 +1,14 @@
1
+ /** Explicit, translated feedback for partial batches; API errors stay sanitized. */
2
+ export declare class ConfirmationError extends Error {
3
+ }
4
+ export declare function ConfirmDialog({ open, onOpenChange, title, description, confirmLabel, cancelLabel, destructive, onConfirm, formatError, }: {
5
+ open: boolean;
6
+ onOpenChange: (o: boolean) => void;
7
+ title: string;
8
+ description?: string;
9
+ confirmLabel?: string;
10
+ cancelLabel?: string;
11
+ destructive?: boolean;
12
+ onConfirm: () => void | Promise<void>;
13
+ formatError?: (error: unknown) => string;
14
+ }): import("react").JSX.Element;
@@ -0,0 +1,44 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useRef, useState } from "react";
4
+ import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, } from "./dialog.js";
5
+ import { Loader2 } from "lucide-react";
6
+ import { Button } from "./button.js";
7
+ import { useFamilyLabels } from "./labels.js";
8
+ /** Explicit, translated feedback for partial batches; API errors stay sanitized. */
9
+ export class ConfirmationError extends Error {
10
+ }
11
+ export function ConfirmDialog({ open, onOpenChange, title, description, confirmLabel, cancelLabel, destructive, onConfirm, formatError, }) {
12
+ const labels = useFamilyLabels();
13
+ const cancelButton = useRef(null);
14
+ const inFlight = useRef(false);
15
+ const [pending, setPending] = useState(false);
16
+ const [error, setError] = useState(null);
17
+ const cancel = cancelLabel ?? labels.cancel ?? "Cancelar";
18
+ const confirm = confirmLabel ?? labels.confirm ?? "Confirmar";
19
+ const changeOpen = (next) => {
20
+ if (inFlight.current)
21
+ return;
22
+ setError(null);
23
+ onOpenChange(next);
24
+ };
25
+ const submit = async () => {
26
+ if (inFlight.current)
27
+ return;
28
+ inFlight.current = true;
29
+ setPending(true);
30
+ setError(null);
31
+ try {
32
+ await onConfirm();
33
+ onOpenChange(false);
34
+ }
35
+ catch (e) {
36
+ setError(e instanceof ConfirmationError ? e.message : formatError?.(e) ?? labels.confirmFailed ?? "Não foi possível concluir a ação.");
37
+ }
38
+ finally {
39
+ inFlight.current = false;
40
+ setPending(false);
41
+ }
42
+ };
43
+ return (_jsx(Dialog, { open: open, onOpenChange: changeOpen, children: _jsxs(DialogContent, { initialFocus: destructive ? cancelButton : undefined, className: "sm:max-w-sm", "aria-busy": pending, showCloseButton: !pending, children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { children: title }), description && _jsx(DialogDescription, { children: description })] }), error && _jsx("div", { role: "alert", className: "rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive", children: error }), _jsxs(DialogFooter, { children: [_jsx(Button, { ref: cancelButton, variant: "ghost", disabled: pending, onClick: () => changeOpen(false), children: cancel }), _jsxs(Button, { variant: destructive ? "destructive" : "default", disabled: pending, onClick: () => void submit(), children: [pending && _jsx(Loader2, { "aria-hidden": true, className: "size-4 animate-spin" }), pending ? (labels.confirming ?? "Aguarde…") : confirm] })] })] }) }));
44
+ }
@@ -0,0 +1,11 @@
1
+ import type { LucideIcon } from "lucide-react";
2
+ /** Canonical empty list: icon + title + one sentence + optional CTA. compact is
3
+ * the one-line form for a list inside a form section. */
4
+ export declare function EmptyState({ icon: Icon, title, description, action, compact, className, }: {
5
+ icon?: LucideIcon;
6
+ title: string;
7
+ description?: string;
8
+ action?: React.ReactNode;
9
+ compact?: boolean;
10
+ className?: string;
11
+ }): import("react").JSX.Element;
@@ -0,0 +1,10 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { cn } from "./cn.js";
3
+ /** Canonical empty list: icon + title + one sentence + optional CTA. compact is
4
+ * the one-line form for a list inside a form section. */
5
+ export function EmptyState({ icon: Icon, title, description, action, compact = false, className, }) {
6
+ if (compact) {
7
+ return _jsx("p", { role: "status", className: cn("rounded-md border border-dashed px-3 py-4 text-center text-sm text-muted-foreground", className), children: title });
8
+ }
9
+ return (_jsxs("div", { role: "status", className: cn("flex flex-col items-center justify-center rounded-xl border border-dashed px-6 py-14 text-center", className), children: [Icon && (_jsx("div", { className: "mb-4 flex size-12 items-center justify-center rounded-lg bg-muted text-muted-foreground", children: _jsx(Icon, { className: "size-5" }) })), _jsx("p", { className: "font-medium", children: title }), description && (_jsx("p", { className: "mt-1 max-w-sm text-sm text-muted-foreground", children: description })), action && _jsx("div", { className: "mt-4", children: action })] }));
10
+ }
package/dist/index.d.ts CHANGED
@@ -25,3 +25,7 @@ export * from "./collapsible.js";
25
25
  export * from "./form-field.js";
26
26
  export * from "./dropdown-select.js";
27
27
  export * from "./searchable-choice.js";
28
+ export * from "./password-input.js";
29
+ export * from "./confirm-dialog.js";
30
+ export * from "./empty-state.js";
31
+ export * from "./query-error-state.js";
package/dist/index.js CHANGED
@@ -25,3 +25,7 @@ export * from "./collapsible.js";
25
25
  export * from "./form-field.js";
26
26
  export * from "./dropdown-select.js";
27
27
  export * from "./searchable-choice.js";
28
+ export * from "./password-input.js";
29
+ export * from "./confirm-dialog.js";
30
+ export * from "./empty-state.js";
31
+ export * from "./query-error-state.js";
package/dist/labels.d.ts CHANGED
@@ -6,6 +6,15 @@ export interface FamilyLabels {
6
6
  previous: string;
7
7
  next: string;
8
8
  noChoices?: string;
9
+ hidePassword?: string;
10
+ showPassword?: string;
11
+ cancel?: string;
12
+ confirm?: string;
13
+ confirming?: string;
14
+ confirmFailed?: string;
15
+ errorTitle?: string;
16
+ errorDescription?: string;
17
+ retry?: string;
9
18
  }
10
19
  export declare function FamilyUIProvider({ labels, children }: {
11
20
  labels: FamilyLabels;
@@ -0,0 +1,5 @@
1
+ import * as React from "react";
2
+ import { Input } from "./input.js";
3
+ export declare function PasswordInput({ className, onCapsLock, onKeyUp, ...props }: React.ComponentProps<typeof Input> & {
4
+ onCapsLock?: (on: boolean) => void;
5
+ }): React.JSX.Element;
@@ -0,0 +1,18 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import * as React from "react";
4
+ import { Eye, EyeOff } from "lucide-react";
5
+ import { Input } from "./input.js";
6
+ import { cn } from "./cn.js";
7
+ import { useFamilyLabels } from "./labels.js";
8
+ // Password field with a show/hide toggle and optional Caps Lock callback.
9
+ // `type`/`className` are applied after the forwarded props so a caller can't
10
+ // override the toggle; onKeyUp is chained so capslock + caller handlers both run.
11
+ export function PasswordInput({ className, onCapsLock, onKeyUp, ...props }) {
12
+ const { hidePassword = "Ocultar senha", showPassword = "Mostrar senha" } = useFamilyLabels();
13
+ const [show, setShow] = React.useState(false);
14
+ return (_jsxs("div", { className: "relative min-w-0", children: [_jsx(Input, { ...props, type: show ? "text" : "password", className: cn("pr-12", className), onKeyUp: (e) => {
15
+ onKeyUp?.(e);
16
+ onCapsLock?.(e.getModifierState?.("CapsLock") ?? false);
17
+ } }), _jsx("button", { type: "button", "aria-pressed": show, "aria-label": show ? hidePassword : showPassword, onClick: () => setShow((s) => !s), className: "absolute right-0 top-1/2 flex size-[var(--control-h)] -translate-y-1/2 items-center justify-center rounded-md text-muted-foreground transition-colors hover:text-foreground", children: show ? _jsx(EyeOff, { className: "size-4" }) : _jsx(Eye, { className: "size-4" }) })] }));
18
+ }
@@ -0,0 +1,6 @@
1
+ export declare function QueryErrorState({ title, description, onRetry, className, }: {
2
+ title?: string;
3
+ description?: string;
4
+ onRetry?: () => void;
5
+ className?: string;
6
+ }): import("react").JSX.Element;
@@ -0,0 +1,10 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { AlertTriangle } from "lucide-react";
4
+ import { Button } from "./button.js";
5
+ import { cn } from "./cn.js";
6
+ import { useFamilyLabels } from "./labels.js";
7
+ export function QueryErrorState({ title, description, onRetry, className, }) {
8
+ const labels = useFamilyLabels();
9
+ return (_jsxs("div", { role: "alert", className: cn("flex flex-col items-center justify-center rounded-xl border border-dashed border-destructive/30 px-6 py-14 text-center", className), children: [_jsx("div", { className: "mb-4 flex size-12 items-center justify-center rounded-lg bg-destructive/10 text-destructive", children: _jsx(AlertTriangle, { className: "size-5" }) }), _jsx("p", { className: "font-medium", children: title ?? labels.errorTitle ?? "Algo deu errado" }), description !== "" && (_jsx("p", { className: "mt-1 max-w-sm text-sm text-muted-foreground", children: description ?? labels.errorDescription ?? "Os dados não puderam ser carregados." })), onRetry && (_jsx(Button, { className: "mt-4", variant: "outline", onClick: onRetry, children: labels.retry ?? "Tentar de novo" }))] }));
10
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@raulaguila/maat-ui",
3
- "version": "0.2.2",
3
+ "version": "0.3.0",
4
4
  "publishConfig": { "registry": "https://registry.npmjs.org", "access": "public" },
5
5
  "repository": { "type": "git", "url": "git+https://github.com/raulaguila/maat-ui.git" },
6
6
  "description": "Maat UI — componentes React e estilos de Seshat, Thoth e Khnum",
@@ -17,6 +17,22 @@
17
17
  "import": "./dist/index.js"
18
18
  },
19
19
  "./styles.css": "./styles.css",
20
+ "./password-input": {
21
+ "types": "./dist/password-input.d.ts",
22
+ "import": "./dist/password-input.js"
23
+ },
24
+ "./confirm-dialog": {
25
+ "types": "./dist/confirm-dialog.d.ts",
26
+ "import": "./dist/confirm-dialog.js"
27
+ },
28
+ "./empty-state": {
29
+ "types": "./dist/empty-state.d.ts",
30
+ "import": "./dist/empty-state.js"
31
+ },
32
+ "./query-error-state": {
33
+ "types": "./dist/query-error-state.d.ts",
34
+ "import": "./dist/query-error-state.js"
35
+ },
20
36
  "./avatar": {
21
37
  "types": "./dist/avatar.d.ts",
22
38
  "import": "./dist/avatar.js"