@mitcsutt/kiln-forms
Version:
Kiln forms: typed React forms on TanStack Form, in component or JSON schema mode, rendered through kiln-ui
39 lines (38 loc) • 1.33 kB
JavaScript
import { useFieldContext as e } from "../../../kit/contexts.js";
import { useFieldPresentation as t } from "../FieldPresentation/FieldPresentation.js";
import { getFormRuntime as n } from "../../../runtime/formRuntime.js";
import { createContext as r, useContext as i } from "react";
import { Fragment as a, jsx as o } from "react/jsx-runtime";
import { DataList as s, ShowMore as c } from "@mitcsutt/kiln-ui";
//#region src/components/fields/FieldView/FieldView.tsx
var l = r(!1);
function u({ children: e, ...t }) {
return /* @__PURE__ */ o(s, {
...t,
children: /* @__PURE__ */ o(l.Provider, {
value: !0,
children: e
})
});
}
function d({ children: e }) {
return i(l) ? /* @__PURE__ */ o(l.Provider, {
value: !1,
children: e
}) : /* @__PURE__ */ o(a, { children: e });
}
function f({ label: r, children: a }) {
let u = e(), d = i(l), { viewLines: f } = t(), p = n(u.form).options.messages, m = a == null || a === "" ? p.notProvided : f === void 0 ? a : /* @__PURE__ */ o(c, {
lines: f,
moreLabel: p.showMore,
lessLabel: p.showLess,
children: a
}), h = /* @__PURE__ */ o(s.Item, {
label: r,
children: m
});
return d ? h : /* @__PURE__ */ o(s, { children: h });
}
//#endregion
export { f as FieldView, u as FieldViewList, d as FieldViewListBoundary };
//# sourceMappingURL=FieldView.js.map