UNPKG

@easykit/design

Version:

Easy kit design components

369 lines (368 loc) 13.6 kB
import st from "react-dom"; import { createRoot as it } from "react-dom/client"; import { clsx as ut } from "clsx"; import { twMerge as at } from "tailwind-merge"; var ot = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}; function ct(o) { return o && o.__esModule && Object.prototype.hasOwnProperty.call(o, "default") ? o.default : o; } var Q = { exports: {} }; (function(o, h) { (function(a, y) { o.exports = y(); })(ot, function() { var a = 1e3, y = 6e4, L = 36e5, F = "millisecond", T = "second", C = "minute", Y = "hour", _ = "day", N = "week", M = "month", z = "quarter", D = "year", j = "date", B = "Invalid Date", tt = /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/, et = /\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g, nt = { name: "en", weekdays: "Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"), months: "January_February_March_April_May_June_July_August_September_October_November_December".split("_"), ordinal: function(s) { var n = ["th", "st", "nd", "rd"], t = s % 100; return "[" + s + (n[(t - 20) % 10] || n[t] || n[0]) + "]"; } }, P = function(s, n, t) { var r = String(s); return !r || r.length >= n ? s : "" + Array(n + 1 - r.length).join(t) + s; }, rt = { s: P, z: function(s) { var n = -s.utcOffset(), t = Math.abs(n), r = Math.floor(t / 60), e = t % 60; return (n <= 0 ? "+" : "-") + P(r, 2, "0") + ":" + P(e, 2, "0"); }, m: function s(n, t) { if (n.date() < t.date()) return -s(t, n); var r = 12 * (t.year() - n.year()) + (t.month() - n.month()), e = n.clone().add(r, M), i = t - e < 0, u = n.clone().add(r + (i ? -1 : 1), M); return +(-(r + (t - e) / (i ? e - u : u - e)) || 0); }, a: function(s) { return s < 0 ? Math.ceil(s) || 0 : Math.floor(s); }, p: function(s) { return { M, y: D, w: N, d: _, D: j, h: Y, m: C, s: T, ms: F, Q: z }[s] || String(s || "").toLowerCase().replace(/s$/, ""); }, u: function(s) { return s === void 0; } }, R = "en", O = {}; O[R] = nt; var J = "$isDayjsObject", V = function(s) { return s instanceof A || !(!s || !s[J]); }, I = function s(n, t, r) { var e; if (!n) return R; if (typeof n == "string") { var i = n.toLowerCase(); O[i] && (e = i), t && (O[i] = t, e = i); var u = n.split("-"); if (!e && u.length > 1) return s(u[0]); } else { var f = n.name; O[f] = n, e = f; } return !r && e && (R = e), e || !r && R; }, l = function(s, n) { if (V(s)) return s.clone(); var t = typeof n == "object" ? n : {}; return t.date = s, t.args = arguments, new A(t); }, c = rt; c.l = I, c.i = V, c.w = function(s, n) { return l(s, { locale: n.$L, utc: n.$u, x: n.$x, $offset: n.$offset }); }; var A = function() { function s(t) { this.$L = I(t.locale, null, !0), this.parse(t), this.$x = this.$x || t.x || {}, this[J] = !0; } var n = s.prototype; return n.parse = function(t) { this.$d = function(r) { var e = r.date, i = r.utc; if (e === null) return /* @__PURE__ */ new Date(NaN); if (c.u(e)) return /* @__PURE__ */ new Date(); if (e instanceof Date) return new Date(e); if (typeof e == "string" && !/Z$/i.test(e)) { var u = e.match(tt); if (u) { var f = u[2] - 1 || 0, d = (u[7] || "0").substring(0, 3); return i ? new Date(Date.UTC(u[1], f, u[3] || 1, u[4] || 0, u[5] || 0, u[6] || 0, d)) : new Date(u[1], f, u[3] || 1, u[4] || 0, u[5] || 0, u[6] || 0, d); } } return new Date(e); }(t), this.init(); }, n.init = function() { var t = this.$d; this.$y = t.getFullYear(), this.$M = t.getMonth(), this.$D = t.getDate(), this.$W = t.getDay(), this.$H = t.getHours(), this.$m = t.getMinutes(), this.$s = t.getSeconds(), this.$ms = t.getMilliseconds(); }, n.$utils = function() { return c; }, n.isValid = function() { return this.$d.toString() !== B; }, n.isSame = function(t, r) { var e = l(t); return this.startOf(r) <= e && e <= this.endOf(r); }, n.isAfter = function(t, r) { return l(t) < this.startOf(r); }, n.isBefore = function(t, r) { return this.endOf(r) < l(t); }, n.$g = function(t, r, e) { return c.u(t) ? this[r] : this.set(e, t); }, n.unix = function() { return Math.floor(this.valueOf() / 1e3); }, n.valueOf = function() { return this.$d.getTime(); }, n.startOf = function(t, r) { var e = this, i = !!c.u(r) || r, u = c.p(t), f = function(w, p) { var S = c.w(e.$u ? Date.UTC(e.$y, p, w) : new Date(e.$y, p, w), e); return i ? S : S.endOf(_); }, d = function(w, p) { return c.w(e.toDate()[w].apply(e.toDate("s"), (i ? [0, 0, 0, 0] : [23, 59, 59, 999]).slice(p)), e); }, $ = this.$W, m = this.$M, g = this.$D, k = "set" + (this.$u ? "UTC" : ""); switch (u) { case D: return i ? f(1, 0) : f(31, 11); case M: return i ? f(1, m) : f(0, m + 1); case N: var b = this.$locale().weekStart || 0, H = ($ < b ? $ + 7 : $) - b; return f(i ? g - H : g + (6 - H), m); case _: case j: return d(k + "Hours", 0); case Y: return d(k + "Minutes", 1); case C: return d(k + "Seconds", 2); case T: return d(k + "Milliseconds", 3); default: return this.clone(); } }, n.endOf = function(t) { return this.startOf(t, !1); }, n.$set = function(t, r) { var e, i = c.p(t), u = "set" + (this.$u ? "UTC" : ""), f = (e = {}, e[_] = u + "Date", e[j] = u + "Date", e[M] = u + "Month", e[D] = u + "FullYear", e[Y] = u + "Hours", e[C] = u + "Minutes", e[T] = u + "Seconds", e[F] = u + "Milliseconds", e)[i], d = i === _ ? this.$D + (r - this.$W) : r; if (i === M || i === D) { var $ = this.clone().set(j, 1); $.$d[f](d), $.init(), this.$d = $.set(j, Math.min(this.$D, $.daysInMonth())).$d; } else f && this.$d[f](d); return this.init(), this; }, n.set = function(t, r) { return this.clone().$set(t, r); }, n.get = function(t) { return this[c.p(t)](); }, n.add = function(t, r) { var e, i = this; t = Number(t); var u = c.p(r), f = function(m) { var g = l(i); return c.w(g.date(g.date() + Math.round(m * t)), i); }; if (u === M) return this.set(M, this.$M + t); if (u === D) return this.set(D, this.$y + t); if (u === _) return f(1); if (u === N) return f(7); var d = (e = {}, e[C] = y, e[Y] = L, e[T] = a, e)[u] || 1, $ = this.$d.getTime() + t * d; return c.w($, this); }, n.subtract = function(t, r) { return this.add(-1 * t, r); }, n.format = function(t) { var r = this, e = this.$locale(); if (!this.isValid()) return e.invalidDate || B; var i = t || "YYYY-MM-DDTHH:mm:ssZ", u = c.z(this), f = this.$H, d = this.$m, $ = this.$M, m = e.weekdays, g = e.months, k = e.meridiem, b = function(p, S, E, x) { return p && (p[S] || p(r, i)) || E[S].slice(0, x); }, H = function(p) { return c.s(f % 12 || 12, p, "0"); }, w = k || function(p, S, E) { var x = p < 12 ? "AM" : "PM"; return E ? x.toLowerCase() : x; }; return i.replace(et, function(p, S) { return S || function(E) { switch (E) { case "YY": return String(r.$y).slice(-2); case "YYYY": return c.s(r.$y, 4, "0"); case "M": return $ + 1; case "MM": return c.s($ + 1, 2, "0"); case "MMM": return b(e.monthsShort, $, g, 3); case "MMMM": return b(g, $); case "D": return r.$D; case "DD": return c.s(r.$D, 2, "0"); case "d": return String(r.$W); case "dd": return b(e.weekdaysMin, r.$W, m, 2); case "ddd": return b(e.weekdaysShort, r.$W, m, 3); case "dddd": return m[r.$W]; case "H": return String(f); case "HH": return c.s(f, 2, "0"); case "h": return H(1); case "hh": return H(2); case "a": return w(f, d, !0); case "A": return w(f, d, !1); case "m": return String(d); case "mm": return c.s(d, 2, "0"); case "s": return String(r.$s); case "ss": return c.s(r.$s, 2, "0"); case "SSS": return c.s(r.$ms, 3, "0"); case "Z": return u; } return null; }(p) || u.replace(":", ""); }); }, n.utcOffset = function() { return 15 * -Math.round(this.$d.getTimezoneOffset() / 15); }, n.diff = function(t, r, e) { var i, u = this, f = c.p(r), d = l(t), $ = (d.utcOffset() - this.utcOffset()) * y, m = this - d, g = function() { return c.m(u, d); }; switch (f) { case D: i = g() / 12; break; case M: i = g(); break; case z: i = g() / 3; break; case N: i = (m - $) / 6048e5; break; case _: i = (m - $) / 864e5; break; case Y: i = m / L; break; case C: i = m / y; break; case T: i = m / a; break; default: i = m; } return e ? i : c.a(i); }, n.daysInMonth = function() { return this.endOf(M).$D; }, n.$locale = function() { return O[this.$L]; }, n.locale = function(t, r) { if (!t) return this.$L; var e = this.clone(), i = I(t, r, !0); return i && (e.$L = i), e; }, n.clone = function() { return c.w(this.$d, this); }, n.toDate = function() { return new Date(this.valueOf()); }, n.toJSON = function() { return this.isValid() ? this.toISOString() : null; }, n.toISOString = function() { return this.$d.toISOString(); }, n.toString = function() { return this.$d.toUTCString(); }, s; }(), K = A.prototype; return l.prototype = K, [["$ms", F], ["$s", T], ["$m", C], ["$H", Y], ["$W", _], ["$M", M], ["$y", D], ["$D", j]].forEach(function(s) { K[s[1]] = function(n) { return this.$g(n, s[0], s[1]); }; }), l.extend = function(s, n) { return s.$i || (s(n, A, l), s.$i = !0), l; }, l.locale = I, l.isDayjs = V, l.unix = function(s) { return l(1e3 * s); }, l.en = O[R], l.Ls = O, l.p = {}, l; }); })(Q); var ft = Q.exports; const dt = /* @__PURE__ */ ct(ft), ht = (o, h = "YYYY-MM-DD HH:mm:ss") => { if (!o) return "--"; const a = dt(o); return a.isValid() ? a.format(h) : "--"; }, lt = (o) => o === 0 ? o : o || "--", Ot = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, defaultValue: lt, time: ht }, Symbol.toStringTag, { value: "Module" })), $t = Object.prototype.toString; function mt(o) { return $t.call(o) === "[object Object]"; } const yt = it, Z = "__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED", v = st; let U; var q; const pt = Number((q = v.version) == null ? void 0 : q.split(".")[0]) > 17; var G; const gt = Number((G = v.version) == null ? void 0 : G.split(".")[0]) > 18, W = (o) => { mt(v[Z]) && (v[Z].usingClientEntryPoint = o); }; let X; try { X = v.createRoot; } catch { } gt ? U = (o, h) => { W(!0); const a = yt(h); return W(!1), a.render(o), a._unmount = () => { setTimeout(() => { var y; (y = a == null ? void 0 : a.unmount) == null || y.call(a); }); }, a; } : pt ? U = (o, h) => { W(!0); const a = X(h); return W(!1), a.render(o), a._unmount = () => { setTimeout(() => { var y; (y = a == null ? void 0 : a.unmount) == null || y.call(a); }); }, a; } : U = (o, h) => (v.render(o, h), { render: (a) => { v.render(a, h); }, _unmount() { v.unmountComponentAtNode(h); } }); const bt = U; function wt(...o) { return at(ut(o)); } function Mt(o) { let h = 0; if (o.length === 0) return h.toString(); for (let a = 0; a < o.length; a++) { const y = o.charCodeAt(a); h = (h << 5) - h + y, h &= h; } return Math.abs(h).toString(16).padStart(8, "0"); } function Tt(o) { const h = o.map((a) => { const y = a.accessorKey ? String(a.accessorKey) : "", L = a.id || ""; return y || L; }).filter((a) => a).sort().join(","); return Mt(h); } export { Ot as B, ct as a, ot as b, wt as c, lt as d, Tt as g, mt as i, Mt as m, bt as r, ht as t };