UNPKG

@open-formulieren/formio-builder

Version:

An opinionated Formio webform builder for Open Forms

56 lines (55 loc) 1.42 kB
import { jsx as r, jsxs as s, Fragment as x } from "react/jsx-runtime"; import F from "clsx"; import { useFormikContext as h, Field as v } from "formik"; import { useContext as C } from "react"; import { RenderContext as D } from "../../context.js"; import { useValidationErrors as E, ErrorList as g } from "../../utils/errors.js"; import j from "./component.js"; import y from "./description.js"; import { withMultiple as I } from "./multiple.js"; const M = ({ name: t, label: d, required: l = !1, tooltip: n = "", description: o = "", ...p }) => { const { getFieldProps: m } = h(), { bareInput: a } = C(D), { errors: f, hasErrors: c } = E(t), e = `editform-${t}`, { value: u } = m(t), i = /* @__PURE__ */ r( v, { name: t, id: e, as: "input", type: "date", className: F("form-control", { "is-invalid": c }), "data-testid": `input-${t}`, pattern: "\\d{4}-\\d{2}-\\d{2}", value: u ?? "", ...p } ); return a ? /* @__PURE__ */ s(x, { children: [ i, /* @__PURE__ */ r(g, { errors: f }) ] }) : /* @__PURE__ */ s(j, { type: "date", field: t, required: l, htmlId: e, label: d, tooltip: n, children: [ /* @__PURE__ */ r("div", { children: i }), o && /* @__PURE__ */ r(y, { text: o }) ] }); }, q = I(M, ""); export { M as DateField, q as DateFieldMultiple, q as default };