@raulaguila/maat-ui 0.7.0 → 0.8.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.7.0
10
+ pnpm add --save-exact @raulaguila/maat-ui@0.8.0
11
11
  ```
12
12
 
13
13
  Inclua o `package.json` e o `pnpm-lock.yaml` no mesmo commit.
@@ -68,6 +68,7 @@ Os textos vêm de `FamilyUIProvider`; as props de rótulo, quando existem, têm
68
68
  - `useDebounced`, `useDiscardChanges` e `useHashToken` (`/hooks`): valor depois de parar de mudar; proteção de alterações não salvas (fechar aba sempre; com `onOpenChange` devolve `requestClose` e `discardDialog` para diálogos, sem ele confirma cliques em links); token de `#token=` (ou `?token=` antigo) retirado da barra de endereço. `const { token, setToken, read } = useHashToken()`
69
69
  - `formatDateTime`, `relativeTime`, `formatBytes` e `formatDuration` (`/format`): funções puras com Intl; `relativeTime` usa semanas e diz "agora" abaixo de um minuto, `formatDateTime(d, locale, { long: true })` mostra segundos e fuso (auditoria). `relativeTime(iso, locale)`
70
70
  - `Button` com `loading`: spinner antes do rótulo, desabilitado e `aria-busy`. `<Button loading={salvando}>Salvar</Button>`
71
+ - `FormField floating` posiciona o rótulo de um `Input` ou `PasswordInput` na borda ao focar ou preencher, inclusive com autofill. Use um único controle com o `autoComplete` apropriado.
71
72
  - `FormField` com `error`: substitui a descrição, `role="alert"`, e marca o controle com `aria-invalid` e `aria-describedby`. `<FormField id="email" label="E-mail" error={erro}><Input id="email" /></FormField>`
72
73
  - `PasswordStrength` e `passwordScore` (`/password-strength`): medidor de quatro barras (0 a 4). `<PasswordStrength password={senha} />`
73
74
  - `SessionsTable` (`/sessions-table`, requer sonner, fora da entrada raiz): dispositivo, IP, último acesso relativo (absoluto no `title`), "Este dispositivo", "Encerrar" por linha (toast em falha) e "Encerrar as outras" com confirmação. `<SessionsTable items={s} onRevoke={encerrar} onRevokeOthers={encerrarOutras} />`
@@ -3,7 +3,7 @@ import { type ComponentProps, type ReactNode } from "react";
3
3
  export declare function FormFieldGrid({ className, columns, ...props }: ComponentProps<"div"> & {
4
4
  columns?: 2 | 3;
5
5
  }): import("react").JSX.Element;
6
- export declare function FormField({ id, label, description, error, children, className, labelClassName }: {
6
+ export declare function FormField({ id, label, description, error, children, className, labelClassName, floating }: {
7
7
  id: string;
8
8
  label: ReactNode;
9
9
  description?: ReactNode;
@@ -12,4 +12,6 @@ export declare function FormField({ id, label, description, error, children, cla
12
12
  children: ReactNode;
13
13
  className?: string;
14
14
  labelClassName?: string;
15
+ /** Float the label on the border of a single text or password input. */
16
+ floating?: boolean;
15
17
  }): import("react").JSX.Element;
@@ -1,4 +1,4 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import { cloneElement, isValidElement } from "react";
3
3
  import { Label } from "./label.js";
4
4
  import { cn } from "./cn.js";
@@ -6,13 +6,15 @@ import { cn } from "./cn.js";
6
6
  export function FormFieldGrid({ className, columns = 2, ...props }) {
7
7
  return _jsx("div", { "data-slot": "form-field-grid", className: cn("grid min-w-0 grid-cols-1 gap-x-4 gap-y-4 sm:gap-y-0 sm:*:data-[slot=form-field]:row-span-3 sm:*:data-[slot=form-field]:grid-rows-subgrid", columns === 3 ? "sm:grid-cols-3" : "sm:grid-cols-2", className), ...props });
8
8
  }
9
- export function FormField({ id, label, description, error, children, className, labelClassName }) {
9
+ export function FormField({ id, label, description, error, children, className, labelClassName, floating = false }) {
10
10
  const note = error || description;
11
11
  const noteId = `${id}-note`;
12
12
  // The single control gets the state and the note's id; a group of controls sets its own.
13
13
  const control = isValidElement(children) ? cloneElement(children, {
14
+ ...(floating ? { id, placeholder: " " } : {}),
14
15
  "aria-invalid": error ? true : children.props["aria-invalid"],
15
16
  "aria-describedby": note ? [children.props["aria-describedby"], noteId].filter(Boolean).join(" ") : children.props["aria-describedby"],
16
17
  }) : children;
17
- return _jsxs("div", { "data-slot": "form-field", className: cn("grid min-w-0 grid-rows-[auto_auto_1fr] content-start gap-0", className), children: [_jsx(Label, { htmlFor: id, className: cn("self-end pb-2", labelClassName), children: label }), _jsx("div", { "data-slot": "form-control", className: "min-w-0 self-start *:data-[slot=select-trigger]:w-full *:data-[slot=dropdown-select-trigger]:w-full", children: control }), _jsx("div", { id: noteId, "data-slot": "form-description", role: error ? "alert" : undefined, className: cn("min-w-0 space-y-2 text-xs", error ? "text-destructive" : "text-muted-foreground", note && "pt-2"), "aria-hidden": note ? undefined : true, children: note })] });
18
+ const fieldLabel = _jsx(Label, { htmlFor: id, className: cn(!floating && "self-end pb-2", labelClassName), children: label });
19
+ return _jsxs("div", { "data-slot": "form-field", className: cn("grid min-w-0 grid-rows-[auto_auto_1fr] content-start gap-0", className), children: [floating ? _jsxs("div", { "data-ui-floating-control": true, children: [fieldLabel, control] }) : _jsxs(_Fragment, { children: [fieldLabel, _jsx("div", { "data-slot": "form-control", className: "min-w-0 self-start *:data-[slot=select-trigger]:w-full *:data-[slot=dropdown-select-trigger]:w-full", children: control })] }), _jsx("div", { id: noteId, "data-slot": "form-description", role: error ? "alert" : undefined, className: cn("min-w-0 space-y-2 text-xs", error ? "text-destructive" : "text-muted-foreground", note && "pt-2"), "aria-hidden": note ? undefined : true, children: note })] });
18
20
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@raulaguila/maat-ui",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org",
6
6
  "access": "public"
package/styles.css CHANGED
@@ -431,6 +431,33 @@ html[data-density="compact"] {
431
431
  [data-ui-app-header] { height: 56px; padding-inline: 0; margin-bottom: 8px; }
432
432
  }
433
433
 
434
+ /* The native input state also covers values restored before hydration. */
435
+ [data-ui-floating-control] { position: relative; min-width: 0 }
436
+ [data-ui-floating-control] > label {
437
+ position: absolute;
438
+ z-index: 1;
439
+ inset-inline-start: .5rem;
440
+ top: 0;
441
+ transform: translateY(-50%);
442
+ padding-inline: .25rem;
443
+ max-width: calc(100% - 3.5rem);
444
+ background: var(--floating-label-surface, var(--card));
445
+ color: var(--muted-foreground);
446
+ font-size: .75rem;
447
+ line-height: 1rem;
448
+ }
449
+ [data-ui-floating-control]:not(:focus-within):has(input:placeholder-shown):not(:has(input:is(:autofill, :-webkit-autofill))) > label {
450
+ top: 50%;
451
+ background: transparent;
452
+ font-size: 1rem;
453
+ cursor: text;
454
+ }
455
+ [data-ui-floating-control]:focus-within > label { color: var(--primary) }
456
+ [data-ui-floating-control]:has(input[aria-invalid=true]) > label { color: var(--destructive) }
457
+ .dark [data-ui-auth-card] { --floating-label-surface: var(--background) }
458
+ @media (prefers-reduced-motion: no-preference) {
459
+ [data-ui-floating-control] > label { transition: top 140ms ease-out, font-size 140ms ease-out }
460
+ }
434
461
  /* Sign-in, sign-up and recovery screens (AuthLayout, AuthCard). */
435
462
  [data-ui-auth-layout] {
436
463
  display: flex;