@open-formulieren/formio-builder
Version:
An opinionated Formio webform builder for Open Forms
56 lines (55 loc) • 1.45 kB
JavaScript
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 T } from "../../utils/errors.js";
import g from "./component.js";
import j from "./description.js";
import { withMultiple as y } from "./multiple.js";
const I = ({
name: t,
label: d,
required: l = !1,
tooltip: m = "",
description: o = "",
...n
}) => {
const {
getFieldProps: p
} = h(), {
bareInput: a
} = C(D), {
errors: c,
hasErrors: f
} = E(t), e = `editform-${t}`, {
value: u
} = p(t), i = /* @__PURE__ */ r(
v,
{
name: t,
id: e,
as: "input",
type: "datetime-local",
className: F("form-control", {
"is-invalid": f
}),
"data-testid": `input-${t}`,
pattern: "\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}",
value: u ?? "",
...n
}
);
return a ? /* @__PURE__ */ s(x, { children: [
i,
/* @__PURE__ */ r(T, { errors: c })
] }) : /* @__PURE__ */ s(g, { type: "datetime", field: t, required: l, htmlId: e, label: d, tooltip: m, children: [
/* @__PURE__ */ r("div", { children: i }),
o && /* @__PURE__ */ r(j, { text: o })
] });
}, V = y(I, "");
export {
I as DateTimeField,
V as DateTimeFieldMultiple,
V as default
};