@open-formulieren/formio-builder
Version:
An opinionated Formio webform builder for Open Forms
34 lines (33 loc) • 900 B
JavaScript
import { COMPONENT_PLACEHOLDER_TYPE as s } from "./components/designer/types.js";
import { getRegistryEntry as m } from "./registry/index.js";
import { hasOwnProperty as p } from "./types/index.js";
function* i(o, n = "") {
for (const [e, t] of o.entries()) {
const f = [n, p(t, "key") ? t.key : ""].filter(Boolean).join(".");
if (yield {
index: e,
component: t,
dataPath: f,
collection: o
}, l(t)) continue;
const {
getComponentSlots: c
} = m(t.type);
if (c)
for (const r of c(t))
yield* i(r.collection, r.useReferenceInComponentDataPath ? [n, r.reference].filter(Boolean).join(".") : n);
}
}
const d = (o, n) => {
for (const {
component: e
} of i(o))
if (!l(e) && e.key === n)
return e;
return null;
}, l = (o) => o.type === s;
export {
d as findComponent,
l as isPlaceholder,
i as iterComponents
};