Data display
MaskedValue
A secret value shown as dots. Reveal can ask first (confirm); the app reads the value and writes its audit log in onReveal. confirm.action sets the confirm button text (default “Show”). open and onOpenChange control the dialog, for example to open it from a row menu; they work only with confirm. After a reveal the value has Copy and Hide. Give each record its own key, so a shown value does not stay when the record changes.
import { MaskedValue, type MaskedValueProps } from "@percentsa/ui";Examples
Hidden
Code
export function MaskedValueExample() {
const t = useT();
return (
<MaskedValue
label={t("Password", "كلمة المرور")}
canReveal
confirm={{ title: t("Show the password?", "عرض كلمة المرور؟"), description: t("The reveal is recorded.", "يُسجَّل الإظهار.") }}
onReveal={() => new Promise((r) => setTimeout(() => r("p4ss-example-only"), 600))}
/>
);
}Hidden
Code
export function MaskedValueOpenExample() {
const t = useT();
const [open, setOpen] = useState(false);
return (
<Inline gap={3}>
<MaskedValue
label={t("Password", "كلمة المرور")}
canReveal
open={open}
onOpenChange={setOpen}
confirm={{ title: t("Show the password?", "عرض كلمة المرور؟"), action: t("Show the password", "اعرض كلمة المرور") }}
onReveal={async () => "p4ss-example-only"}
/>
<DropdownMenu
align="end"
trigger={<Button size="sm" variant="ghost" iconOnly aria-label={t("Row actions", "إجراءات الصف")}><Ellipsis aria-hidden /></Button>}
items={[{ label: t("Reveal Password", "إظهار كلمة المرور"), onSelect: () => setOpen(true) }]}
/>
</Inline>
);
}