UNPKG

@payfit/unity-components

Version:

54 lines (53 loc) • 1.94 kB
import { useFieldContext as e } from "../../hooks/form-context.js"; import { FormField as t } from "../form-field/FormField.js"; import { FormFeedbackText as n } from "../form-field/parts/FormFeedbackText.js"; import { FormHelperText as r } from "../form-field/parts/FormHelperText.js"; import { FormLabel as i } from "../form-field/parts/FormLabel.js"; import { PasswordFieldDetails as a } from "./parts/PasswordFieldDetails.js"; import { PasswordInput as o } from "./parts/PasswordInput.js"; import { forwardRef as s } from "react"; import { jsx as c, jsxs as l } from "react/jsx-runtime"; import { useTranslation as u } from "react-i18next"; //#region src/modules/tanstack-form/components/password-field/PasswordField.tsx function d({ label: s, helperText: d, rulesTitle: f, rules: p, contextualLink: m, isRequired: h, requiredVariant: g, isLoading: _, isDisabled: v, isReadOnly: y, showCapsLockWarning: b, autoComplete: x, onBlur: S, onFocus: C, onChange: w, onClearButtonPress: T, ...E }, D) { let { t: O } = u("unity"), k = e(), A = k.state.meta.isTouched && !k.state.meta.isValid, j = p && p.length > 0, M = O((e) => e.unity.component.passwordField.rulesTitle); return /* @__PURE__ */ l(t, { children: [ /* @__PURE__ */ c(i, { requiredVariant: g, isRequired: h, children: s }), d && /* @__PURE__ */ c(r, { children: d }), /* @__PURE__ */ c(o, { ...E, ref: D, value: k.state.value, onChange: (e) => { k.handleChange(e.target.value), w?.(e); }, onBlur: (e) => { k.handleBlur(), S?.(e); }, onFocus: C, isLoading: _, isDisabled: v, isReadOnly: y, isInvalid: A, showCapsLockWarning: b, autoComplete: x, onClearButtonPress: () => { k.setValue(""), T?.(); } }), /* @__PURE__ */ c(n, {}), j && /* @__PURE__ */ c(a, { title: f ?? M, rules: p }), m ] }); } var f = s(d); f.displayName = "PasswordField"; //#endregion export { f as PasswordField };