@raulaguila/maat-ui 0.9.0 → 0.10.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 +2 -0
- package/dist/form-field.d.ts +1 -1
- package/dist/form-field.js +2 -2
- package/dist/textarea.js +1 -1
- package/package.json +1 -1
- package/styles.css +23 -0
package/README.md
CHANGED
|
@@ -197,3 +197,5 @@ Valem para endpoints, tabelas e jobs novos. Os contratos v1 existentes continuam
|
|
|
197
197
|
|
|
198
198
|
|
|
199
199
|
Nos formulários, use `<FormField floating="select" label="Idioma">` diretamente ao redor do `SelectTrigger`, do `DropdownSelectTrigger`, do `SearchableChoice` ou do `select` nativo de escolha única. O campo associa o rótulo ao controle e mantém a ajuda e o erro acessíveis. No seletor nativo, `<option value="">Selecione</option>` representa o estado vazio. Para exibir uma escolha explícita como “Nenhum” mesmo quando seu valor é a string vazia, marque essa opção com `data-value-label`.
|
|
200
|
+
|
|
201
|
+
Para textos de várias linhas com rótulo curto, use `<FormField floating="textarea" label="Observações"><Textarea rows={3} /></FormField>`. O rótulo vazio começa na primeira linha. Mantenha perguntas longas acima do controle. A altura máxima padrão é o menor valor entre 16 rem e 35% da altura visível da tela, com rolagem interna.
|
package/dist/form-field.d.ts
CHANGED
package/dist/form-field.js
CHANGED
|
@@ -14,10 +14,10 @@ export function FormField({ id: providedId, label, description, error, children,
|
|
|
14
14
|
// The single control gets the state and the note's id; a group of controls sets its own.
|
|
15
15
|
const control = isValidElement(children) ? cloneElement(children, {
|
|
16
16
|
...(floating ? { id } : {}),
|
|
17
|
-
...(floating
|
|
17
|
+
...(floating && floating !== "select" ? { placeholder: children.props.placeholder || " " } : {}),
|
|
18
18
|
"aria-invalid": error ? true : children.props["aria-invalid"],
|
|
19
19
|
"aria-describedby": note ? [children.props["aria-describedby"], noteId].filter(Boolean).join(" ") : children.props["aria-describedby"],
|
|
20
20
|
}) : children;
|
|
21
21
|
const fieldLabel = _jsx(Label, { htmlFor: id, className: cn(!floating && "self-end pb-2", labelClassName), children: label });
|
|
22
|
-
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": floating === "
|
|
22
|
+
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": typeof floating === "string" ? floating : "", children: [fieldLabel, _jsx("div", { "data-ui-floating-input": true, children: control }), _jsx("span", { "data-ui-floating-edge": true, "aria-hidden": "true" })] }) : _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 })] });
|
|
23
23
|
}
|
package/dist/textarea.js
CHANGED
|
@@ -2,6 +2,6 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { cn } from "./cn.js";
|
|
3
3
|
/** Multi-line twin of Input: same border, fill, focus and invalid states. */
|
|
4
4
|
function Textarea({ className, ...props }) {
|
|
5
|
-
return (_jsx("textarea", { "data-slot": "textarea", className: cn("w-full min-w-0 rounded-lg border border-input bg-card px-2.5 py-2 text-base transition-colors outline-none placeholder:text-muted-foreground/70 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-[color-mix(in_oklab,var(--input-fill)_30%,transparent)] dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40", className), ...props }));
|
|
5
|
+
return (_jsx("textarea", { "data-slot": "textarea", className: cn("block w-full min-w-0 max-h-(--textarea-max-height) resize-y overflow-y-auto rounded-lg border border-input bg-card px-2.5 py-2 text-base transition-colors outline-none placeholder:text-muted-foreground/70 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-[color-mix(in_oklab,var(--input-fill)_30%,transparent)] dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40", className), ...props }));
|
|
6
6
|
}
|
|
7
7
|
export { Textarea };
|
package/package.json
CHANGED
package/styles.css
CHANGED
|
@@ -114,6 +114,7 @@
|
|
|
114
114
|
--space-list: 0.75rem;
|
|
115
115
|
--space-card: 1.25rem;
|
|
116
116
|
--space-row: 0.5rem;
|
|
117
|
+
--textarea-max-height: min(16rem, 35dvh);
|
|
117
118
|
--control-h: 2rem;
|
|
118
119
|
--control-h-sm: 1.75rem;
|
|
119
120
|
--control-h-lg: 2.25rem;
|
|
@@ -484,6 +485,28 @@ html[data-density="compact"] {
|
|
|
484
485
|
& > [data-ui-floating-edge] { border-top-color: var(--field-line) }
|
|
485
486
|
& input::placeholder { color: transparent }
|
|
486
487
|
}
|
|
488
|
+
[data-ui-floating-control="textarea"] {
|
|
489
|
+
& [data-ui-floating-input] textarea {
|
|
490
|
+
display: block;
|
|
491
|
+
width: 100%;
|
|
492
|
+
max-height: var(--textarea-max-height);
|
|
493
|
+
overflow-y: auto;
|
|
494
|
+
border-color: transparent;
|
|
495
|
+
box-shadow: none;
|
|
496
|
+
}
|
|
497
|
+
&:not(:focus-within):has(textarea:placeholder-shown) {
|
|
498
|
+
& > label {
|
|
499
|
+
top: .5625rem;
|
|
500
|
+
transform: none;
|
|
501
|
+
line-height: 1.25rem;
|
|
502
|
+
font-size: .875rem;
|
|
503
|
+
cursor: text;
|
|
504
|
+
}
|
|
505
|
+
& > [data-ui-floating-edge] { border-top-color: var(--field-line) }
|
|
506
|
+
& textarea::placeholder { color: transparent }
|
|
507
|
+
}
|
|
508
|
+
&:has(textarea:disabled) > label { opacity: .65 }
|
|
509
|
+
}
|
|
487
510
|
[data-ui-floating-control="select"] {
|
|
488
511
|
& [data-ui-floating-input] :is(select, button[aria-haspopup]) {
|
|
489
512
|
width: 100%;
|