@adyen/adyen-platform-experience-web
Version:

38 lines (37 loc) • 1.56 kB
JavaScript
import { jsx as o } from "../../../external/.pnpm/preact@10.28.2/node_modules/preact/jsx-runtime/dist/jsxRuntime.module.js";
import { useMemo as m } from "../../../external/.pnpm/preact@10.28.2/node_modules/preact/hooks/dist/hooks.module.js";
import { useWizardFormContext as d } from "../../../hooks/form/wizard/WizardFormContext.js";
import c from "./FormField.js";
import { CalendarInput as F } from "../FormFields/CalendarInput/CalendarInput.js";
import { VisibleField as g } from "./VisibleField.js";
import { FieldError as h } from "../FormFields/FieldError/FieldError.js";
import { Controller as C } from "../../../hooks/form/Controller.js";
function O({ clearable: u, fieldName: r, label: p, isReadOnly: i }) {
const { control: a, fieldsConfig: n } = d(), s = m(() => n[r]?.required, [n, r]), l = m(() => i ?? n[r]?.readOnly, [n, r, i]);
return /* @__PURE__ */ o(g, { name: r, children: /* @__PURE__ */ o(c, { label: p, optional: !s, children: /* @__PURE__ */ o(
C,
{
name: r,
control: a,
rules: {
required: s
},
render: ({ field: t, fieldState: e }) => /* @__PURE__ */ o("div", { children: [
/* @__PURE__ */ o(
F,
{
value: t.value,
onInput: t.onInput,
isInvalid: !!e.error && e.isTouched,
clearable: u,
isReadOnly: l
}
),
e.error?.message && /* @__PURE__ */ o(h, { errorMessage: e.error?.message, withTopMargin: !0 })
] })
}
) }) });
}
export {
O as FormCalendarInput
};