@danxbot/ui 7.4.1 → 7.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +9587 -9470
- package/dist/index.js.map +1 -1
- package/dist/pure.js +132 -89
- package/dist/pure.js.map +1 -1
- package/dist/types/components/InlineEdit.d.ts +29 -1
- package/dist/types/components/PhoneField.d.ts +17 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/lib/values/email.d.ts +12 -0
- package/dist/types/lib/values/index.d.ts +3 -1
- package/dist/types/lib/values/phone.d.ts +45 -0
- package/dist/types/lib/values/url.d.ts +6 -0
- package/dist/types/pure.d.ts +1 -1
- package/package.json +1 -1
package/dist/pure.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function
|
|
1
|
+
function q(t) {
|
|
2
2
|
if (!Number.isFinite(t) || t < 0) return "";
|
|
3
3
|
if (t < 1024) return `${t} B`;
|
|
4
4
|
const n = ["KB", "MB", "GB", "TB"];
|
|
@@ -7,10 +7,10 @@ function J(t) {
|
|
|
7
7
|
e /= 1024, r += 1;
|
|
8
8
|
return `${e < 10 ? e.toFixed(1) : Math.round(e)} ${n[r]}`;
|
|
9
9
|
}
|
|
10
|
-
function
|
|
11
|
-
return
|
|
10
|
+
function Q(t) {
|
|
11
|
+
return E(t);
|
|
12
12
|
}
|
|
13
|
-
function
|
|
13
|
+
function E(t) {
|
|
14
14
|
if (t == null || !Number.isFinite(t)) return "—";
|
|
15
15
|
const n = t < 0 ? "-" : "", e = Math.abs(t), r = [
|
|
16
16
|
[1e12, "T"],
|
|
@@ -22,7 +22,7 @@ function M(t) {
|
|
|
22
22
|
if (e >= o) return `${n}${Number((e / o).toFixed(1))}${i}`;
|
|
23
23
|
return `${n}${Math.round(e)}`;
|
|
24
24
|
}
|
|
25
|
-
class
|
|
25
|
+
class b extends Error {
|
|
26
26
|
constructor(n, e, r) {
|
|
27
27
|
super(
|
|
28
28
|
r === "gap" ? `${y(n)} does not exist in ${e} — the clock skipped it.` : `${y(n)} happens twice in ${e}.`
|
|
@@ -36,11 +36,11 @@ function y(t) {
|
|
|
36
36
|
const n = (e, r = 2) => String(e).padStart(r, "0");
|
|
37
37
|
return `${n(t.year, 4)}-${n(t.month)}-${n(t.day)}T${n(t.hour)}:${n(t.minute)}:${n(t.second)}.${n(t.millisecond, 3)}`;
|
|
38
38
|
}
|
|
39
|
-
function
|
|
39
|
+
function M(t) {
|
|
40
40
|
const n = (e, r = 2) => String(e).padStart(r, "0");
|
|
41
41
|
return `${n(t.year, 4)}-${n(t.month)}-${n(t.day)}`;
|
|
42
42
|
}
|
|
43
|
-
function
|
|
43
|
+
function d(t, n) {
|
|
44
44
|
const e = /* @__PURE__ */ new Date(0);
|
|
45
45
|
return e.setUTCFullYear(t, n, 0), e.getUTCDate();
|
|
46
46
|
}
|
|
@@ -49,16 +49,16 @@ function A(t) {
|
|
|
49
49
|
if (!n) throw new Error(`not an ISO date: ${JSON.stringify(t)} — expected YYYY-MM-DD`);
|
|
50
50
|
const e = Number(n[1]), r = Number(n[2]), o = Number(n[3]);
|
|
51
51
|
if (r < 1 || r > 12) throw new Error(`month out of range in ${t}`);
|
|
52
|
-
if (o < 1 || o >
|
|
53
|
-
throw new Error(`${t} is not a real date — ${e}-${r} has ${
|
|
52
|
+
if (o < 1 || o > d(e, r))
|
|
53
|
+
throw new Error(`${t} is not a real date — ${e}-${r} has ${d(e, r)} days`);
|
|
54
54
|
return { year: e, month: r, day: o };
|
|
55
55
|
}
|
|
56
|
-
const
|
|
56
|
+
const U = "—";
|
|
57
57
|
function S(t, n = 2) {
|
|
58
58
|
return String(t).padStart(n, "0");
|
|
59
59
|
}
|
|
60
|
-
function
|
|
61
|
-
if (t == null || t === "") return
|
|
60
|
+
function X(t) {
|
|
61
|
+
if (t == null || t === "") return U;
|
|
62
62
|
let n;
|
|
63
63
|
try {
|
|
64
64
|
n = A(t);
|
|
@@ -67,20 +67,20 @@ function K(t) {
|
|
|
67
67
|
}
|
|
68
68
|
return `${S(n.month)}/${S(n.day)}/${n.year}`;
|
|
69
69
|
}
|
|
70
|
-
const
|
|
71
|
-
function
|
|
70
|
+
const x = /^(\d{1,2})\/(\d{1,2})\/(\d{4})$/, B = /^(\d{4})-(\d{1,2})-(\d{1,2})$/;
|
|
71
|
+
function v(t) {
|
|
72
72
|
const n = t.trim();
|
|
73
73
|
if (n === "") return null;
|
|
74
74
|
let e, r, o;
|
|
75
|
-
const i =
|
|
75
|
+
const i = B.exec(n);
|
|
76
76
|
if (i)
|
|
77
77
|
e = Number(i[1]), r = Number(i[2]), o = Number(i[3]);
|
|
78
78
|
else {
|
|
79
|
-
const
|
|
80
|
-
if (!
|
|
81
|
-
r = Number(
|
|
79
|
+
const s = x.exec(n);
|
|
80
|
+
if (!s) return null;
|
|
81
|
+
r = Number(s[1]), o = Number(s[2]), e = Number(s[3]);
|
|
82
82
|
}
|
|
83
|
-
return r < 1 || r > 12 || o < 1 || o >
|
|
83
|
+
return r < 1 || r > 12 || o < 1 || o > d(e, r) ? null : M({ year: e, month: r, day: o });
|
|
84
84
|
}
|
|
85
85
|
const h = 36e5, D = /* @__PURE__ */ new Map();
|
|
86
86
|
function w(t) {
|
|
@@ -99,9 +99,9 @@ function w(t) {
|
|
|
99
99
|
hourCycle: "h23"
|
|
100
100
|
}), D.set(t, n)), n;
|
|
101
101
|
}
|
|
102
|
-
function
|
|
102
|
+
function N(t, n) {
|
|
103
103
|
const e = w(t).formatToParts(new Date(n));
|
|
104
|
-
let r = 0, o = 1, i = 1,
|
|
104
|
+
let r = 0, o = 1, i = 1, s = 0, u = 0, c = 0;
|
|
105
105
|
for (const m of e)
|
|
106
106
|
switch (m.type) {
|
|
107
107
|
case "year":
|
|
@@ -114,49 +114,49 @@ function p(t, n) {
|
|
|
114
114
|
i = Number(m.value);
|
|
115
115
|
break;
|
|
116
116
|
case "hour":
|
|
117
|
-
|
|
117
|
+
s = Number(m.value);
|
|
118
118
|
break;
|
|
119
119
|
case "minute":
|
|
120
|
-
|
|
120
|
+
u = Number(m.value);
|
|
121
121
|
break;
|
|
122
122
|
case "second":
|
|
123
123
|
c = Number(m.value);
|
|
124
124
|
break;
|
|
125
125
|
}
|
|
126
126
|
const a = (n % 1e3 + 1e3) % 1e3;
|
|
127
|
-
return { year: r, month: o, day: i, hour:
|
|
127
|
+
return { year: r, month: o, day: i, hour: s, minute: u, second: c, millisecond: a };
|
|
128
128
|
}
|
|
129
|
-
function
|
|
129
|
+
function g(t) {
|
|
130
130
|
const n = /* @__PURE__ */ new Date(0);
|
|
131
131
|
return n.setUTCFullYear(t.year, t.month - 1, t.day), n.setUTCHours(t.hour, t.minute, t.second, t.millisecond), n.getTime();
|
|
132
132
|
}
|
|
133
133
|
function $(t, n) {
|
|
134
|
-
return
|
|
134
|
+
return g(N(t, n)) - n;
|
|
135
135
|
}
|
|
136
|
-
function
|
|
136
|
+
function I(t, n) {
|
|
137
137
|
return t.year === n.year && t.month === n.month && t.day === n.day && t.hour === n.hour && t.minute === n.minute && t.second === n.second && t.millisecond === n.millisecond;
|
|
138
138
|
}
|
|
139
|
-
function
|
|
140
|
-
const e =
|
|
141
|
-
for (const
|
|
142
|
-
const
|
|
143
|
-
|
|
139
|
+
function O(t, n) {
|
|
140
|
+
const e = g(n), r = $(t, e - 24 * h), o = $(t, e + 24 * h), i = [];
|
|
141
|
+
for (const s of r === o ? [r] : [r, o]) {
|
|
142
|
+
const u = e - s;
|
|
143
|
+
I(N(t, u), n) && i.push(u);
|
|
144
144
|
}
|
|
145
|
-
return i.sort((
|
|
145
|
+
return i.sort((s, u) => s - u), i.filter((s, u) => u === 0 || s !== i[u - 1]);
|
|
146
146
|
}
|
|
147
147
|
function k(t, n, e = "compatible") {
|
|
148
|
-
const r =
|
|
148
|
+
const r = O(t, n);
|
|
149
149
|
if (r.length === 1) return r[0];
|
|
150
150
|
if (r.length > 1) {
|
|
151
|
-
if (e === "reject") throw new
|
|
151
|
+
if (e === "reject") throw new b(n, t, "overlap");
|
|
152
152
|
return e === "later" ? r[r.length - 1] : r[0];
|
|
153
153
|
}
|
|
154
|
-
if (e === "reject") throw new
|
|
155
|
-
const o =
|
|
156
|
-
return e === "earlier" ? Math.min(c, a) :
|
|
154
|
+
if (e === "reject") throw new b(n, t, "gap");
|
|
155
|
+
const o = g(n), i = $(t, o - 24 * h), s = $(t, o + 24 * h), u = s - i, c = o - i, a = o - s;
|
|
156
|
+
return e === "earlier" ? Math.min(c, a) : u > 0 ? Math.max(c, a) : Math.min(c, a);
|
|
157
157
|
}
|
|
158
158
|
const C = "—";
|
|
159
|
-
function
|
|
159
|
+
function p(t, n = 2) {
|
|
160
160
|
return String(t).padStart(n, "0");
|
|
161
161
|
}
|
|
162
162
|
function T() {
|
|
@@ -167,70 +167,78 @@ function L(t) {
|
|
|
167
167
|
const n = t.replace(/(\.\d{3})\d+/, "$1"), e = Date.parse(n);
|
|
168
168
|
return Number.isNaN(e) ? null : e;
|
|
169
169
|
}
|
|
170
|
-
function
|
|
170
|
+
function tt(t, n = {}) {
|
|
171
171
|
if (t == null || t === "") return C;
|
|
172
172
|
const e = L(t);
|
|
173
173
|
if (e === null) return String(t);
|
|
174
|
-
const r = n.zone ?? T(), o =
|
|
175
|
-
return `${
|
|
174
|
+
const r = n.zone ?? T(), o = N(r, e), i = (o.hour + 11) % 12 + 1, s = o.hour < 12 ? "AM" : "PM";
|
|
175
|
+
return `${p(o.month)}/${p(o.day)}/${o.year}, ${i}:${p(o.minute)} ${s}`;
|
|
176
176
|
}
|
|
177
177
|
const _ = /^(\d{1,2})\/(\d{1,2})\/(\d{4})(?:,?\s+(\d{1,2}):(\d{2})(?::(\d{2}))?\s*([AaPp][Mm]))?$/, P = /^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}(:\d{2}(\.\d+)?)?\s*(Z|[+-]\d{2}:?\d{2})$/;
|
|
178
|
-
function
|
|
178
|
+
function nt(t, n = {}) {
|
|
179
179
|
const e = t.trim();
|
|
180
180
|
if (e === "") return null;
|
|
181
181
|
if (P.test(e)) {
|
|
182
|
-
const f = e.replace(/(\.\d{3})\d+/, "$1"),
|
|
183
|
-
return Number.isNaN(
|
|
182
|
+
const f = e.replace(/(\.\d{3})\d+/, "$1"), l = Date.parse(f);
|
|
183
|
+
return Number.isNaN(l) ? null : new Date(l).toISOString();
|
|
184
184
|
}
|
|
185
185
|
const r = _.exec(e);
|
|
186
186
|
if (!r) return null;
|
|
187
|
-
const o = Number(r[1]), i = Number(r[2]),
|
|
188
|
-
if (o < 1 || o > 12 || i < 1 || i >
|
|
189
|
-
let
|
|
187
|
+
const o = Number(r[1]), i = Number(r[2]), s = Number(r[3]);
|
|
188
|
+
if (o < 1 || o > 12 || i < 1 || i > d(s, o)) return null;
|
|
189
|
+
let u = 0, c = 0, a = 0;
|
|
190
190
|
if (r[4] !== void 0) {
|
|
191
191
|
const f = Number(r[4]);
|
|
192
192
|
c = Number(r[5]), a = r[6] !== void 0 ? Number(r[6]) : 0;
|
|
193
|
-
const
|
|
193
|
+
const l = r[7].toUpperCase();
|
|
194
194
|
if (f < 1 || f > 12 || c > 59 || a > 59) return null;
|
|
195
|
-
|
|
195
|
+
u = l === "AM" ? f === 12 ? 0 : f : f === 12 ? 12 : f + 12;
|
|
196
196
|
}
|
|
197
|
-
const m = { year:
|
|
197
|
+
const m = { year: s, month: o, day: i, hour: u, minute: c, second: a, millisecond: 0 }, F = n.zone ?? T();
|
|
198
198
|
return new Date(k(F, m)).toISOString();
|
|
199
199
|
}
|
|
200
|
-
const R = "—",
|
|
200
|
+
const R = "—", H = new Intl.NumberFormat("en-US", {
|
|
201
201
|
style: "currency",
|
|
202
202
|
currency: "USD",
|
|
203
203
|
minimumFractionDigits: 2,
|
|
204
204
|
maximumFractionDigits: 2
|
|
205
205
|
});
|
|
206
|
-
function
|
|
207
|
-
return t == null || !Number.isFinite(t) ? R :
|
|
206
|
+
function et(t) {
|
|
207
|
+
return t == null || !Number.isFinite(t) ? R : H.format(t);
|
|
208
208
|
}
|
|
209
|
-
function
|
|
209
|
+
function rt(t) {
|
|
210
210
|
const n = t.trim();
|
|
211
211
|
if (n === "") return null;
|
|
212
212
|
const e = /^\((.*)\)$/.exec(n), r = e !== null, i = (e ? e[1] : n).replace(/[$,\s]/g, "");
|
|
213
213
|
if (!/^-?\d+(\.\d+)?$/.test(i)) return null;
|
|
214
|
-
const
|
|
215
|
-
return Number.isFinite(
|
|
214
|
+
const s = Number(i);
|
|
215
|
+
return Number.isFinite(s) ? r ? -Math.abs(s) : s : null;
|
|
216
216
|
}
|
|
217
|
-
const
|
|
218
|
-
function
|
|
219
|
-
if (t == null || t === "") return
|
|
217
|
+
const Y = "—";
|
|
218
|
+
function ot(t) {
|
|
219
|
+
if (t == null || t === "") return Y;
|
|
220
220
|
const n = t.replace(/\D/g, "");
|
|
221
|
-
return n.length !== 10 ? t :
|
|
221
|
+
return n.length !== 10 ? t : W(n);
|
|
222
222
|
}
|
|
223
|
-
function
|
|
223
|
+
function it(t) {
|
|
224
224
|
const n = t.replace(/\D/g, "");
|
|
225
225
|
return n.length === 11 && n.startsWith("1") ? n.slice(1) : n.length === 10 ? n : null;
|
|
226
226
|
}
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
227
|
+
function st(t) {
|
|
228
|
+
return t.replace(/\D/g, "");
|
|
229
|
+
}
|
|
230
|
+
function W(t) {
|
|
231
|
+
if (t.length === 0) return "";
|
|
232
|
+
const n = t.slice(0, 10), e = t.slice(10), r = n.length < 4 ? `(${n}` : n.length < 7 ? `(${n.slice(0, 3)}) ${n.slice(3)}` : `(${n.slice(0, 3)}) ${n.slice(3, 6)}-${n.slice(6)}`;
|
|
233
|
+
return e ? `${r} ${e}` : r;
|
|
234
|
+
}
|
|
235
|
+
const Z = "—";
|
|
236
|
+
function ut(t, n = {}) {
|
|
237
|
+
if (t == null || !Number.isFinite(t)) return Z;
|
|
230
238
|
const { decimals: e } = n, r = e === void 0 ? { maximumFractionDigits: 6 } : { minimumFractionDigits: e, maximumFractionDigits: e };
|
|
231
239
|
return new Intl.NumberFormat("en-US", r).format(t);
|
|
232
240
|
}
|
|
233
|
-
function
|
|
241
|
+
function ct(t) {
|
|
234
242
|
const n = t.trim();
|
|
235
243
|
if (n === "") return null;
|
|
236
244
|
const e = n.replace(/,/g, "");
|
|
@@ -238,21 +246,52 @@ function et(t) {
|
|
|
238
246
|
const r = Number(e);
|
|
239
247
|
return Number.isFinite(r) ? r : null;
|
|
240
248
|
}
|
|
241
|
-
function
|
|
249
|
+
function at(t, n = {}) {
|
|
242
250
|
const { trueLabel: e = "Yes", falseLabel: r = "No", unknownLabel: o = "Unknown" } = n;
|
|
243
251
|
return t === !0 ? e : t === !1 ? r : o;
|
|
244
252
|
}
|
|
245
|
-
const
|
|
246
|
-
function
|
|
253
|
+
const V = /* @__PURE__ */ new Set(["yes", "y", "true", "t", "1"]), j = /* @__PURE__ */ new Set(["no", "n", "false", "f", "0"]);
|
|
254
|
+
function mt(t) {
|
|
247
255
|
const n = t.trim().toLowerCase();
|
|
248
|
-
return
|
|
256
|
+
return V.has(n) ? !0 : j.has(n) ? !1 : null;
|
|
257
|
+
}
|
|
258
|
+
const J = /^([^\s@]+)@([^\s@]+)$/;
|
|
259
|
+
function z(t) {
|
|
260
|
+
return t.split(".").some((n) => n.length === 0);
|
|
261
|
+
}
|
|
262
|
+
function ft(t) {
|
|
263
|
+
const n = t.trim();
|
|
264
|
+
if (n === "") return !0;
|
|
265
|
+
if (/[.,]$/.test(n)) return !1;
|
|
266
|
+
const e = J.exec(n);
|
|
267
|
+
if (!e) return !1;
|
|
268
|
+
const r = e[2], o = r.split(".");
|
|
269
|
+
return o.length < 2 || z(r) ? !1 : /^[a-z]{2,}$/i.test(o[o.length - 1]);
|
|
270
|
+
}
|
|
271
|
+
const G = /^https?:\/\//i;
|
|
272
|
+
function K(t) {
|
|
273
|
+
if (t === "localhost") return !0;
|
|
274
|
+
const n = t.split(".");
|
|
275
|
+
return n.length < 2 || n.some((e) => e.length === 0) ? !1 : /^[a-z]{2,}$/i.test(n[n.length - 1]);
|
|
276
|
+
}
|
|
277
|
+
function lt(t) {
|
|
278
|
+
const n = t.trim();
|
|
279
|
+
if (n === "") return !0;
|
|
280
|
+
if (/\s/.test(n)) return !1;
|
|
281
|
+
const e = G.test(n) ? n : `https://${n}`;
|
|
282
|
+
try {
|
|
283
|
+
const r = new URL(e);
|
|
284
|
+
return r.protocol !== "http:" && r.protocol !== "https:" ? !1 : K(r.hostname);
|
|
285
|
+
} catch {
|
|
286
|
+
return !1;
|
|
287
|
+
}
|
|
249
288
|
}
|
|
250
|
-
function
|
|
289
|
+
function dt(t, n) {
|
|
251
290
|
if (!Number.isFinite(t) || !Number.isFinite(n) || n <= 0 || t <= 0) return null;
|
|
252
291
|
const e = Math.round(Math.min(t, n) / n * 5);
|
|
253
292
|
return Math.max(1, Math.min(5, e));
|
|
254
293
|
}
|
|
255
|
-
const
|
|
294
|
+
const ht = {
|
|
256
295
|
1: "Just a guess",
|
|
257
296
|
2: "Somewhat unsure",
|
|
258
297
|
3: "Fairly confident",
|
|
@@ -260,22 +299,26 @@ const ut = {
|
|
|
260
299
|
5: "Highly confident"
|
|
261
300
|
};
|
|
262
301
|
export {
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
302
|
+
ht as CONFIDENCE_LEVEL_LABELS,
|
|
303
|
+
dt as confidenceLevel,
|
|
304
|
+
st as digitsOfPhoneInProgress,
|
|
305
|
+
at as formatBoolean,
|
|
306
|
+
q as formatBytes,
|
|
307
|
+
E as formatCompactNumber,
|
|
308
|
+
et as formatCurrency,
|
|
309
|
+
X as formatDate,
|
|
310
|
+
tt as formatDateTime,
|
|
311
|
+
ut as formatNumber,
|
|
312
|
+
ot as formatPhone,
|
|
313
|
+
W as formatPhonePartial,
|
|
314
|
+
Q as formatTokens,
|
|
315
|
+
ft as isValidEmail,
|
|
316
|
+
lt as isValidUrl,
|
|
317
|
+
mt as parseBoolean,
|
|
318
|
+
rt as parseCurrency,
|
|
319
|
+
v as parseDate,
|
|
320
|
+
nt as parseDateTime,
|
|
321
|
+
ct as parseNumber,
|
|
322
|
+
it as parsePhone
|
|
280
323
|
};
|
|
281
324
|
//# sourceMappingURL=pure.js.map
|