@raulaguila/maat-ui 0.2.2 → 0.4.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 +5 -1
- package/dist/confirm-dialog.d.ts +14 -0
- package/dist/confirm-dialog.js +44 -0
- package/dist/empty-state.d.ts +11 -0
- package/dist/empty-state.js +10 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/dist/labels.d.ts +9 -0
- package/dist/layout.d.ts +8 -0
- package/dist/layout.js +4 -0
- package/dist/password-input.d.ts +5 -0
- package/dist/password-input.js +18 -0
- package/dist/query-error-state.d.ts +6 -0
- package/dist/query-error-state.js +10 -0
- package/package.json +17 -1
- package/styles.css +46 -0
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.
|
|
10
|
+
pnpm add --save-exact @raulaguila/maat-ui@0.4.0
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
Inclua o `package.json` e o `pnpm-lock.yaml` no mesmo commit.
|
|
@@ -38,10 +38,14 @@ 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.
|
|
44
46
|
|
|
47
|
+
`ApplicationShell`, disponível em `@raulaguila/maat-ui/layout`, organiza a navegação lateral, o cabeçalho e a região principal rolável. Passe `sidebar` (incluindo o drawer), `header`, `skipLabel` traduzido e o conteúdo como filho. A biblioteca define margens, alturas e link de salto para o conteúdo nas três plataformas. O produto continua responsável por rotas, permissões e estado da navegação.
|
|
48
|
+
|
|
45
49
|
Botões, campos, seleção, checkbox, switch, badges, avatares, abas, cartões, tabelas, paginação, menus, diálogos, painéis, tooltips e skeletons compartilham tamanhos e estados. `Sidebar`, `SidebarBody` e `SidebarFooter` mantêm um centro rolável e o rodapé na base. A aplicação fornece a marca e os itens do menu. `ManagementGroup` e `ManagementRow` agrupam itens com um título acessível. Use o contêiner `family-management` e as áreas `family-open`, `family-roles`, `family-stats` e `family-actions` para reorganizar as linhas pela largura disponível.
|
|
46
50
|
|
|
47
51
|
## Desenvolver e distribuir
|
|
@@ -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;
|
package/dist/layout.d.ts
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
import { type ComponentProps, type ReactNode } from "react";
|
|
2
|
+
/** The product supplies its navigation and actions; Maat owns viewport geometry and landmarks. */
|
|
3
|
+
export declare function ApplicationShell({ sidebar, header, children, skipLabel, mainId }: {
|
|
4
|
+
sidebar: ReactNode;
|
|
5
|
+
header: ReactNode;
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
skipLabel: string;
|
|
8
|
+
mainId?: string;
|
|
9
|
+
}): import("react").JSX.Element;
|
|
2
10
|
export declare function PageHeader({ title, description, action, badge, }: {
|
|
3
11
|
title: string;
|
|
4
12
|
description?: React.ReactNode;
|
package/dist/layout.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useId } from "react";
|
|
3
3
|
import { cn } from "./cn.js";
|
|
4
|
+
/** The product supplies its navigation and actions; Maat owns viewport geometry and landmarks. */
|
|
5
|
+
export function ApplicationShell({ sidebar, header, children, skipLabel, mainId = "main-content" }) {
|
|
6
|
+
return (_jsxs("div", { "data-ui-app-shell": "", children: [_jsx("a", { href: `#${mainId}`, className: "sr-only focus:not-sr-only focus:fixed focus:left-4 focus:top-4 focus:z-[100] focus:rounded-md focus:bg-background focus:px-4 focus:py-2 focus:text-sm focus:font-medium focus:text-foreground focus:shadow-lg focus:outline-none focus:ring-2 focus:ring-ring", children: skipLabel }), sidebar, _jsxs("div", { "data-ui-app-column": "", children: [_jsx("header", { "data-ui-app-header": "", children: header }), _jsx("main", { "data-ui-app-content": "", id: mainId, tabIndex: -1, children: children })] })] }));
|
|
7
|
+
}
|
|
4
8
|
export function PageHeader({ title, description, action, badge, }) {
|
|
5
9
|
return (_jsx("div", { "data-ui-page-header": true, className: "px-[var(--space-page)] py-3 md:pb-5", children: _jsxs("div", { className: "flex w-full flex-col gap-[var(--space-row)] sm:flex-row sm:flex-wrap sm:items-start sm:justify-between", children: [_jsxs("div", { className: "min-w-0 max-w-full flex-1 wrap-anywhere sm:basis-64", children: [_jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [_jsx("h1", { className: "font-heading text-xl font-semibold tracking-tight md:text-2xl", children: title }), badge] }), description && _jsx("p", { className: "mt-1 max-w-[75ch] text-sm text-muted-foreground", children: description })] }), action && _jsx("div", { className: "flex max-w-full flex-wrap items-center gap-2 [&>*]:max-w-full [&>*]:flex-wrap", children: action })] }) }));
|
|
6
10
|
}
|
|
@@ -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,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.
|
|
3
|
+
"version": "0.4.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"
|
package/styles.css
CHANGED
|
@@ -384,3 +384,49 @@ html[data-density="compact"] {
|
|
|
384
384
|
@media (max-width: 767px), (pointer: coarse) {
|
|
385
385
|
.profile-content [role="tablist"] [role="tab"][aria-selected] { min-height: 44px; }
|
|
386
386
|
}
|
|
387
|
+
|
|
388
|
+
/* Application viewport shared by all three products. The main landmark owns scrolling. */
|
|
389
|
+
[data-ui-app-shell] {
|
|
390
|
+
display: flex;
|
|
391
|
+
width: 100%;
|
|
392
|
+
height: 100dvh;
|
|
393
|
+
min-width: 0;
|
|
394
|
+
overflow: hidden;
|
|
395
|
+
padding: 16px;
|
|
396
|
+
gap: 20px;
|
|
397
|
+
background: var(--background);
|
|
398
|
+
}
|
|
399
|
+
[data-ui-app-column] {
|
|
400
|
+
display: flex;
|
|
401
|
+
flex: 1;
|
|
402
|
+
flex-direction: column;
|
|
403
|
+
min-width: 0;
|
|
404
|
+
}
|
|
405
|
+
[data-ui-app-header] {
|
|
406
|
+
position: sticky;
|
|
407
|
+
top: 0;
|
|
408
|
+
z-index: 20;
|
|
409
|
+
display: flex;
|
|
410
|
+
align-items: center;
|
|
411
|
+
justify-content: space-between;
|
|
412
|
+
flex-shrink: 0;
|
|
413
|
+
height: 48px;
|
|
414
|
+
min-width: 0;
|
|
415
|
+
gap: 8px;
|
|
416
|
+
padding-inline: 4px;
|
|
417
|
+
margin-bottom: 12px;
|
|
418
|
+
background: var(--background);
|
|
419
|
+
}
|
|
420
|
+
[data-ui-app-content] {
|
|
421
|
+
position: relative;
|
|
422
|
+
flex: 1;
|
|
423
|
+
min-height: 0;
|
|
424
|
+
overflow: auto;
|
|
425
|
+
outline: none;
|
|
426
|
+
scrollbar-gutter: stable;
|
|
427
|
+
background: var(--content);
|
|
428
|
+
}
|
|
429
|
+
@media (max-width: 767px) {
|
|
430
|
+
[data-ui-app-shell] { gap: 0; }
|
|
431
|
+
[data-ui-app-header] { height: 56px; padding-inline: 0; margin-bottom: 8px; }
|
|
432
|
+
}
|