UNPKG

@open-formulieren/formio-builder

Version:

An opinionated Formio webform builder for Open Forms

56 lines (55 loc) 1.41 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 E } from "../../context.js"; import { useValidationErrors as g, ErrorList as j } from "../../utils/errors.js"; import y from "./component.js"; import I from "./description.js"; import { withMultiple as M } from "./multiple.js"; const T = ({ name: t, label: m, required: l = !1, tooltip: n = "", description: o = "", ...p }) => { const { getFieldProps: d } = h(), { bareInput: f } = C(E), { errors: c, hasErrors: u } = g(t), i = `editform-${t}`, { value: a } = d(t), e = /* @__PURE__ */ r( v, { name: t, id: i, as: "input", type: "time", className: F("form-control", { "is-invalid": u }), "data-testid": `input-${t}`, pattern: "\\d{2}:\\d{2}", value: a ?? "", ...p } ); return f ? /* @__PURE__ */ s(x, { children: [ e, /* @__PURE__ */ r(j, { errors: c }) ] }) : /* @__PURE__ */ s(y, { type: "time", field: t, required: l, htmlId: i, label: m, tooltip: n, children: [ /* @__PURE__ */ r("div", { children: e }), o && /* @__PURE__ */ r(I, { text: o }) ] }); }, V = M(T, ""); export { T as TimeField, V as TimeFieldMultiple, V as default };