UNPKG

@sheerid/jslib-nightly

Version:

SheerID JavaScript Library

105 lines (103 loc) 3.15 kB
/** * VERSION: 2.230.0-alpha.0 * BUILD_TIMESTAMP: 1778694684677 * BUILD_DATE: Wed May 13 2026 17:51:24 GMT+0000 (Coordinated Universal Time) * BUILD_COMMIT: 7af1c105d5485ac4ed1190c56d492bb4590667a9 */ import { i as h, j as p, F as w, l as m, h as f, w as x, g as I, R as F, x as E, p as c, y as V, z as j, o as T, A as k } from "../sheerid.js"; import { F as z } from "./FormFieldInputSelect-o7QZaYhS.js"; const B = ({ value: o, isErrored: n, options: u, onChange: r, onKeyDown: y, intl: C, placeholder: i = "", isRequired: d = !0, suppressPlaceholder: M = !1, disabled: t = !1 }) => /* @__PURE__ */ p.jsx( z, { fieldId: "country", options: u, onChange: (l) => r(l), onKeyDown: y, placeholder: i || C.formatHTMLMessage({ id: "countryPlaceholder", defaultMessage: "Country" }), value: u.find((l) => l.value === (o && o.value)), isRequired: d, label: /* @__PURE__ */ p.jsx(w, { id: "country", defaultMessage: "Country" }), errorMessage: n && /* @__PURE__ */ p.jsx(w, { id: "errorId.invalidCountry", defaultMessage: "Invalid country" }), showPlaceholderAndHideLabel: !!i, suppressPlaceholder: M, disabled: t } ), H = h(B), R = ({ verificationService: o, viewModelDraftDecorator: n = void 0, intl: u, viewModel: r = void 0, nextFocusField: y = void 0, disabled: C = !1 }) => { r && m.warn("viewModel prop is deprecated, use verificationService.viewModel instead"), y && m.warn("nextFocusField prop is deprecated"); const i = f(() => r.localeChoice.value, "en-US"), d = x( o.programTheme, u, i ), { fieldValidationErrors: M } = o, t = d.length > 1, g = I("country")?.hidden, l = (e) => { const s = c( o.viewModel, (a) => { a.countryChoice = e || void 0, a.country = e ? e.value : void 0, n && n(a, e), a.organization && (a.organization = k.organization); } ); o.updateViewModel(s); }; return F.useEffect(() => { const e = d.some((s) => s.value === "US"); if (!t && !e) { const s = o.viewModel.fieldsToSkipValidation ? [...o.viewModel.fieldsToSkipValidation, "country"] : ["country", "address1", "postalCode", "state", "city"]; o.updateViewModel( E( o.viewModel, "fieldsToSkipValidation", s ) ); } }, [t]), F.useEffect(() => { const e = c( o.fieldValidationErrors, (s) => { s.country && (s.country = V( "country", o.viewModel.countryChoice, o.formValidationOptions )), "postalCode" in o.viewModel && o.viewModel.postalCode && (s.postalCode = V( "postalCode", o.viewModel.postalCode, o.formValidationOptions )); } ); j(e, o); }, [o.viewModel.countryChoice]), !t || g ? null : /* @__PURE__ */ p.jsx( H, { isRequired: !0, options: d, value: o.viewModel.countryChoice, isErrored: !!M.country, disabled: C, onChange: async (e) => { const s = e ? e.value : void 0; l(e), T("country", s, o); } } ); }, O = h(R); export { O as C };