@mitcsutt/kiln-forms
Version:
Kiln forms: typed React forms on TanStack Form, in component or JSON schema mode, rendered through kiln-ui
80 lines (79 loc) • 2.03 kB
JavaScript
import { isSchemaSwatch as e } from "./swatch.js";
import { unsafePropReason as t } from "./unsafeProps.js";
//#region src/schema/core/nodes.ts
function n(e) {
return "kind" in e;
}
function r(e) {
return !n(e) && "layout" in e && e.layout === "repeater";
}
function i(e) {
return !n(e) && "layout" in e && e.layout !== "repeater";
}
function a(e) {
return !n(e) && "content" in e;
}
function o(e) {
return !n(e) && "custom" in e;
}
function s(e) {
return r(e) ? e.item : i(e) ? e.children : [];
}
var c = [
"kind",
"name",
"id",
"when",
"whenAnimate",
"rules",
"warnRules",
"defaultValue",
"whenHidden",
"disabledWhen",
"readOnlyWhen",
"excludeWhen",
"requiredWhen",
"optionsFrom",
"resets",
"compute"
], l = [
"layout",
"id",
"when",
"whenAnimate",
"children",
"item",
"newItem",
"rules",
"whenHidden"
], u = [
"content",
"id",
"when",
"whenAnimate"
];
function d(e, n, r = !1) {
let i = {};
for (let [a, o] of Object.entries(e)) !n.includes(a) && t(a, o, r) === void 0 && (i[a] = o);
return i;
}
function f(t) {
return Array.isArray(t) ? t.map((t) => typeof t == "object" && t && "swatch" in t && !e(t.swatch) ? Object.fromEntries(Object.entries(t).filter(([e]) => e !== "swatch")) : t) : t;
}
function p(e) {
let t = d(e, c, !0);
return t.options !== void 0 && (t.options = f(t.options)), t;
}
function m(e) {
return d(e, l);
}
function h(e) {
return d(e, u);
}
function g(e) {
let t = {};
return e.when && (t.when = e.when), n(e) && (e.disabledWhen && (t.disabledWhen = e.disabledWhen), e.readOnlyWhen && (t.readOnlyWhen = e.readOnlyWhen), e.excludeWhen && (t.excludeWhen = e.excludeWhen), e.requiredWhen && (t.requiredWhen = e.requiredWhen)), t;
}
//#endregion
export { u as CONTENT_SCHEMA_KEYS, c as FIELD_SCHEMA_KEYS, l as LAYOUT_SCHEMA_KEYS, s as childNodes, h as contentNodeProps, p as fieldNodeProps, a as isContentNode, o as isCustomNode, n as isFieldNode, i as isLayoutNode, r as isRepeaterNode, m as layoutNodeProps, g as nodeConditions };
//# sourceMappingURL=nodes.js.map