UNPKG

@react-form-builder/core

Version:

React JSON Schema Form Builder to create complex, validated, reusable forms with no deep React knowledge required

208 lines (207 loc) 5.14 kB
function u(t) { return typeof t > "u"; } function m(t) { return t === null; } function a(t) { return typeof t == "number"; } function w(t) { return typeof t == "boolean"; } function j(t) { return t instanceof Date; } function i(t) { return t !== null && typeof t == "object"; } function I(t) { return m(t) || u(t) ? !0 : typeof t == "string" || Array.isArray(t) ? t.length === 0 : t instanceof Map || t instanceof Set ? t.size === 0 : i(t) ? Object.keys(t).length === 0 : !1; } function O(t) { if (!t) return ["", ""]; try { if (typeof Intl < "u" && Intl.Segmenter) { const n = new Intl.Segmenter(void 0, { granularity: "grapheme" }).segment(t)[Symbol.iterator]().next(); if (!n.done) { const s = String(n.value.segment); return [s, t.slice(s.length)]; } return ["", ""]; } } catch { } const e = [...t]; return [e[0] ?? "", e.slice(1).join("")]; } function l(t) { if (!t) return ""; const [e, r] = O(t); return e.toUpperCase() + r; } function d(t) { const e = String(t ?? ""); if (!e) return []; const r = e.replace(new RegExp("(\\p{Ll})(\\p{Lu})", "gu"), "$1 $2"); try { if (typeof Intl < "u" && Intl.Segmenter) { const o = new Intl.Segmenter(void 0, { granularity: "word" }), n = []; for (const s of o.segment(r)) { const c = s, p = String(c.segment); (c.isWordLike ?? /[\p{L}\p{N}]/u.test(p)) && n.push(p); } return n; } } catch { } return r.split(/[^\p{L}\p{N}]+/u).filter(Boolean); } function L(t) { const e = d(t); if (e.length === 0) return ""; const r = e[0].toLowerCase(), o = e.slice(1).map((n) => l(n.toLowerCase())); return [r, ...o].join(""); } function b(t) { return l(t); } function C(t) { const e = d(t); return e.length === 0 ? "" : e.map((r) => l(r.toLowerCase())).join(" "); } function D(t) { return (t || "").toUpperCase(); } function h(t = "") { return `${t}${++h.counter}`; } h.counter = 0; function A(t, ...e) { for (const r of e) { if (!i(t) || !i(r)) { Object.assign(t, r); continue; } for (const o of Object.keys(r)) { const n = r[o], s = t[o]; i(n) && i(s) ? A(s, n) : t[o] = n; } } return t; } function E(t, e = 0) { let r; return (...n) => { u(r) || clearTimeout(r), r = setTimeout(() => t(...n), e); }; } function y(t, e) { if (t === e) return !0; if (t == null || e == null) return !1; if (t instanceof Date && e instanceof Date) return t.getTime() === e.getTime(); if (Array.isArray(t) && Array.isArray(e)) { if (t.length !== e.length) return !1; for (let r = 0; r < t.length; r++) if (!y(t[r], e[r])) return !1; return !0; } if (typeof t == "object" && typeof e == "object") { const r = Object.keys(t), o = Object.keys(e); if (r.length !== o.length) return !1; for (const n of r) if (!Object.prototype.hasOwnProperty.call(e, n) || !y(t[n], e[n])) return !1; return !0; } return !1; } function g(t, e, r) { if (r) { if (Array.isArray(t) && Array.isArray(e)) { if (t.length !== e.length) return !1; for (let o = 0; o < t.length; o++) { const n = r(t[o], e[o], o); if (!u(n)) { if (!n) return !1; continue; } if (!g(t[o], e[o], r)) return !1; } return !0; } if (i(t) && i(e)) { const o = /* @__PURE__ */ new Set([...Object.keys(t), ...Object.keys(e)]); for (const n of o) { const s = r(t[n], e[n], n); if (!u(s)) { if (!s) return !1; continue; } if (!g(t[n], e[n], r)) return !1; } return !0; } } return y(t, e); } function f(t, e = /* @__PURE__ */ new WeakMap()) { if (t === null || typeof t != "object") return t; if (e.has(t)) return e.get(t); if (j(t)) return new Date(t.getTime()); if (t instanceof RegExp) { const n = new RegExp(t.source, t.flags); return n.lastIndex = t.lastIndex, n; } if (t instanceof Map) { const n = /* @__PURE__ */ new Map(); return e.set(t, n), t.forEach((s, c) => { n.set(f(c, e), f(s, e)); }), n; } if (t instanceof Set) { const n = /* @__PURE__ */ new Set(); return e.set(t, n), t.forEach((s) => n.add(f(s, e))), n; } if (ArrayBuffer.isView(t)) return new t.constructor(t); if (t instanceof ArrayBuffer) return t.slice(0); if (Array.isArray(t)) { const n = []; e.set(t, n); for (const s of t) n.push(f(s, e)); return n; } const r = Object.getPrototypeOf(t), o = Object.create(r); e.set(t, o); for (const n of Reflect.ownKeys(t)) { const s = Object.getOwnPropertyDescriptor(t, n); s && ("value" in s && (s.value = f(t[n], e)), Object.defineProperty(o, n, s)); } return o; } export { L as camelCase, f as cloneDeep, E as debounce, w as isBoolean, j as isDate, I as isEmpty, y as isEqual, g as isEqualWith, m as isNull, a as isNumber, i as isObject, u as isUndefined, A as merge, C as startCase, D as toUpper, h as uniqueId, b as upperFirst }; //# sourceMappingURL=tools.js.map