@raulaguila/maat-ui 0.8.0 → 0.8.1
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/form-field.js +2 -2
- package/package.json +1 -1
- package/styles.css +51 -13
package/dist/form-field.js
CHANGED
|
@@ -11,10 +11,10 @@ export function FormField({ id, label, description, error, children, className,
|
|
|
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
|
+
...(floating ? { id, placeholder: children.props.placeholder || " " } : {}),
|
|
15
15
|
"aria-invalid": error ? true : children.props["aria-invalid"],
|
|
16
16
|
"aria-describedby": note ? [children.props["aria-describedby"], noteId].filter(Boolean).join(" ") : children.props["aria-describedby"],
|
|
17
17
|
}) : children;
|
|
18
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 })] });
|
|
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, _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 })] });
|
|
20
20
|
}
|
package/package.json
CHANGED
package/styles.css
CHANGED
|
@@ -431,30 +431,68 @@ html[data-density="compact"] {
|
|
|
431
431
|
[data-ui-app-header] { height: 56px; padding-inline: 0; margin-bottom: 8px; }
|
|
432
432
|
}
|
|
433
433
|
|
|
434
|
-
/* The
|
|
435
|
-
|
|
436
|
-
[data-ui-floating-control]
|
|
437
|
-
|
|
434
|
+
/* The label sizes the middle grid track. Its top edge opens without painting
|
|
435
|
+
over the surface, including on translucent inputs and native autofill. */
|
|
436
|
+
[data-ui-floating-control] {
|
|
437
|
+
--field-line: var(--input);
|
|
438
|
+
--field-stroke: 1px;
|
|
439
|
+
display: grid;
|
|
440
|
+
grid-template-columns: .5rem fit-content(calc(100% - 3.5rem)) minmax(0, 1fr);
|
|
441
|
+
position: relative;
|
|
442
|
+
min-width: 0;
|
|
443
|
+
}
|
|
444
|
+
[data-ui-floating-control] > * { grid-row: 1 }
|
|
445
|
+
[data-ui-floating-input] { grid-column: 1 / -1; min-width: 0 }
|
|
446
|
+
[data-ui-floating-control] [data-ui-floating-input] input {
|
|
447
|
+
border-color: transparent;
|
|
448
|
+
box-shadow: none;
|
|
449
|
+
}
|
|
450
|
+
[data-ui-floating-control]::before, [data-ui-floating-control]::after, [data-ui-floating-edge] {
|
|
451
|
+
grid-row: 1;
|
|
438
452
|
z-index: 1;
|
|
439
|
-
|
|
453
|
+
pointer-events: none;
|
|
454
|
+
border: var(--field-stroke) solid var(--field-line);
|
|
455
|
+
}
|
|
456
|
+
[data-ui-floating-control]::before, [data-ui-floating-control]::after { content: "" }
|
|
457
|
+
[data-ui-floating-control]::before {
|
|
458
|
+
grid-column: 1;
|
|
459
|
+
border-inline-end: 0;
|
|
460
|
+
border-start-start-radius: .5rem;
|
|
461
|
+
border-end-start-radius: .5rem;
|
|
462
|
+
}
|
|
463
|
+
[data-ui-floating-control]::after {
|
|
464
|
+
grid-column: 3;
|
|
465
|
+
border-inline-start: 0;
|
|
466
|
+
border-start-end-radius: .5rem;
|
|
467
|
+
border-end-end-radius: .5rem;
|
|
468
|
+
}
|
|
469
|
+
[data-ui-floating-edge] { grid-column: 2; border-inline: 0; border-top-color: transparent }
|
|
470
|
+
[data-ui-floating-control] > label {
|
|
471
|
+
position: relative;
|
|
472
|
+
grid-column: 2;
|
|
473
|
+
align-self: start;
|
|
474
|
+
z-index: 2;
|
|
440
475
|
top: 0;
|
|
441
476
|
transform: translateY(-50%);
|
|
442
477
|
padding-inline: .25rem;
|
|
443
|
-
max-width: calc(100% - 3.5rem);
|
|
444
|
-
background: var(--floating-label-surface, var(--card));
|
|
445
478
|
color: var(--muted-foreground);
|
|
446
479
|
font-size: .75rem;
|
|
447
480
|
line-height: 1rem;
|
|
448
481
|
}
|
|
449
|
-
[data-ui-floating-control]:not(:focus-within):has(input:placeholder-shown):not(:has(input:is(:autofill, :-webkit-autofill)))
|
|
450
|
-
top: 50%;
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
cursor: text;
|
|
482
|
+
[data-ui-floating-control]:not(:focus-within):has(input:placeholder-shown):not(:has(input:is(:autofill, :-webkit-autofill))) {
|
|
483
|
+
& > label { top: 50%; font-size: 1rem; cursor: text }
|
|
484
|
+
& > [data-ui-floating-edge] { border-top-color: var(--field-line) }
|
|
485
|
+
& input::placeholder { color: transparent }
|
|
454
486
|
}
|
|
487
|
+
[data-ui-floating-control]:focus-within { --field-line: var(--ring); --field-stroke: 2px }
|
|
455
488
|
[data-ui-floating-control]:focus-within > label { color: var(--primary) }
|
|
489
|
+
[data-ui-floating-control]:has(input[aria-invalid=true]) { --field-line: var(--destructive) }
|
|
456
490
|
[data-ui-floating-control]:has(input[aria-invalid=true]) > label { color: var(--destructive) }
|
|
457
|
-
|
|
491
|
+
@media (forced-colors: active) {
|
|
492
|
+
[data-ui-floating-control] { --field-line: ButtonText }
|
|
493
|
+
[data-ui-floating-control]:focus-within { --field-line: Highlight }
|
|
494
|
+
[data-ui-floating-edge] { forced-color-adjust: none }
|
|
495
|
+
}
|
|
458
496
|
@media (prefers-reduced-motion: no-preference) {
|
|
459
497
|
[data-ui-floating-control] > label { transition: top 140ms ease-out, font-size 140ms ease-out }
|
|
460
498
|
}
|