UNPKG

@mitcsutt/kiln-forms

Version:

Kiln forms: typed React forms on TanStack Form, in component or JSON schema mode, rendered through kiln-ui

54 lines (53 loc) • 1.32 kB
//#region src/schema/core/unsafeProps.ts var e = /^[a-z][a-zA-Z0-9]*$/, t = new Set([ "dangerouslySetInnerHTML", "ref", "key", "style", "className", "children", "srcDoc", "form", "action", "formAction", "formMethod", "formEncType", "formTarget", "formNoValidate", "validators", "listeners", "node", "scopeNames", "pattern" ].map((e) => e.toLowerCase())), n = /^on/i, r = /* @__PURE__ */ new Set([ "href", "src", "srcset", "xlinkhref", "data", "poster", "cite", "background", "ping" ]), i = /* @__PURE__ */ new Set([ "submit", "reset", "button", "image", "file", "hidden" ]), a = /^(?:javascript|vbscript|data):/i; function o(e) { return e.replace(/[\u0000- ]/g, ""); } function s(s, c, l = !1) { if (!e.test(s)) return `Prop "${s}" is not a camelCase prop name`; let u = s.toLowerCase(); if (t.has(u)) return `Prop "${s}" is not allowed in a schema`; if (n.test(s)) return `Event handler prop "${s}" is not allowed in a schema`; if (r.has(u) && typeof c == "string" && a.test(o(c))) return `Prop "${s}" may not use a javascript:, vbscript: or data: URL`; if (l && u === "type" && typeof c == "string" && i.has(c.trim().toLowerCase())) return `Field type "${c}" is not allowed in a schema`; } //#endregion export { s as unsafePropReason }; //# sourceMappingURL=unsafeProps.js.map