@open-formulieren/formio-builder
Version:
An opinionated Formio webform builder for Open Forms
43 lines (42 loc) • 1.28 kB
JavaScript
import { jsx as l } from "react/jsx-runtime";
import { useFormikContext as d, useField as g } from "formik";
import { useContext as b } from "react";
import { useIntl as v, FormattedMessage as y } from "react-intl";
import { usePrevious as P, useAsync as h } from "react-use";
import x from "../../formio/select.js";
import { BuilderContext as A } from "../../../context.js";
function C(t) {
return t !== void 0;
}
const z = () => {
const t = "prefill.attribute", u = v(), {
values: a,
setFieldValue: i
} = d(), [{
value: n
}] = g("prefill.attribute"), {
getPrefillAttributes: f
} = b(A), {
plugin: e
} = a.prefill, o = P(e), {
value: r,
loading: p,
error: s
} = h(async () => e ? (n && o && e !== o && i(t, ""), await f(e)) : (i(t, ""), []), [e]);
if (s)
throw s;
const m = u.formatMessage({
id: "vzhWgR",
defaultMessage: [{
type: 0,
value: "Specify the attribute holding the pre-fill data."
}]
}), c = C(r) ? r : [];
return /* @__PURE__ */ l(x, { name: t, label: /* @__PURE__ */ l(y, { id: "sgmcmf", defaultMessage: [{
type: 0,
value: "Plugin attribute"
}] }), tooltip: m, isLoading: p, isClearable: !0, options: c, valueProperty: "id", emptyValue: "" });
};
export {
z as default
};