UNPKG

@payfit/unity-components

Version:

57 lines (56 loc) 2.06 kB
import { useFieldContext as e } from "../../hooks/tanstack-form-context.js"; import { TanstackFormFeedbackText as t } from "../form-field/parts/TanstackFormFeedbackText.js"; import { TanstackFormField as n } from "../form-field/TanstackFormField.js"; import { TanstackFormHelperText as r } from "../form-field/parts/TanstackFormHelperText.js"; import { TanstackFormLabel as i } from "../form-field/parts/TanstackFormLabel.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 { useIntl as u } from "react-intl"; //#region src/components/password-field/TanstackPasswordField.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 O = u(), k = e(), A = k.state.meta.isTouched && !k.state.meta.isValid, j = p && p.length > 0, M = O.formatMessage({ id: "unity:component:password-field:rules-title", defaultMessage: "Your password must have:" }); return /* @__PURE__ */ l(n, { 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(t, {}), j && /* @__PURE__ */ c(a, { title: f ?? M, rules: p }), m ] }); } var f = s(d); f.displayName = "TanstackPasswordField"; //#endregion export { f as TanstackPasswordField };