@danxbot/ui 7.4.2 → 7.5.0
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 +8822 -8653
- package/dist/index.js.map +1 -1
- package/dist/pure.js +112 -100
- package/dist/pure.js.map +1 -1
- package/dist/types/components/InlineEdit.d.ts +6 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/lib/reads/index.d.ts +2 -1
- package/dist/types/lib/reads/optimistic.d.ts +68 -0
- package/dist/types/lib/reads/slots.d.ts +30 -0
- package/dist/types/lib/records/store.d.ts +74 -1
- package/dist/types/lib/values/email.d.ts +6 -0
- package/dist/types/lib/values/phone.d.ts +39 -11
- 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,7 +36,7 @@ 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
|
}
|
|
@@ -57,7 +57,7 @@ const U = "—";
|
|
|
57
57
|
function S(t, n = 2) {
|
|
58
58
|
return String(t).padStart(n, "0");
|
|
59
59
|
}
|
|
60
|
-
function
|
|
60
|
+
function X(t) {
|
|
61
61
|
if (t == null || t === "") return U;
|
|
62
62
|
let n;
|
|
63
63
|
try {
|
|
@@ -67,23 +67,23 @@ 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 > d(e, r) ? null :
|
|
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
|
-
function
|
|
86
|
+
function w(t) {
|
|
87
87
|
let n = D.get(t);
|
|
88
88
|
return n || (n = new Intl.DateTimeFormat("en-US", {
|
|
89
89
|
timeZone: t,
|
|
@@ -100,8 +100,8 @@ function B(t) {
|
|
|
100
100
|
}), D.set(t, n)), n;
|
|
101
101
|
}
|
|
102
102
|
function N(t, n) {
|
|
103
|
-
const e =
|
|
104
|
-
let r = 0, o = 1, i = 1,
|
|
103
|
+
const e = w(t).formatToParts(new Date(n));
|
|
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,46 +114,46 @@ function N(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
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
139
|
function O(t, n) {
|
|
140
|
-
const e =
|
|
141
|
-
for (const
|
|
142
|
-
const
|
|
143
|
-
I(N(t,
|
|
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
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
159
|
function p(t, n = 2) {
|
|
@@ -167,77 +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 = N(r, e), i = (o.hour + 11) % 12 + 1,
|
|
175
|
-
return `${p(o.month)}/${p(o.day)}/${o.year}, ${i}:${p(o.minute)} ${
|
|
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
|
-
const
|
|
178
|
-
function
|
|
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 nt(t, n = {}) {
|
|
179
179
|
const e = t.trim();
|
|
180
180
|
if (e === "") return null;
|
|
181
|
-
if (
|
|
181
|
+
if (P.test(e)) {
|
|
182
182
|
const f = e.replace(/(\.\d{3})\d+/, "$1"), l = Date.parse(f);
|
|
183
183
|
return Number.isNaN(l) ? null : new Date(l).toISOString();
|
|
184
184
|
}
|
|
185
|
-
const r =
|
|
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 > d(
|
|
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
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
|
|
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) ?
|
|
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
|
-
function
|
|
228
|
-
|
|
229
|
-
return n.length === 11 && n.startsWith("1") && (n = n.slice(1)), n.slice(0, 10);
|
|
227
|
+
function st(t) {
|
|
228
|
+
return t.replace(/\D/g, "");
|
|
230
229
|
}
|
|
231
|
-
function
|
|
232
|
-
|
|
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;
|
|
233
234
|
}
|
|
234
|
-
const
|
|
235
|
-
function
|
|
236
|
-
if (t == null || !Number.isFinite(t)) return
|
|
235
|
+
const Z = "—";
|
|
236
|
+
function ut(t, n = {}) {
|
|
237
|
+
if (t == null || !Number.isFinite(t)) return Z;
|
|
237
238
|
const { decimals: e } = n, r = e === void 0 ? { maximumFractionDigits: 6 } : { minimumFractionDigits: e, maximumFractionDigits: e };
|
|
238
239
|
return new Intl.NumberFormat("en-US", r).format(t);
|
|
239
240
|
}
|
|
240
|
-
function
|
|
241
|
+
function ct(t) {
|
|
241
242
|
const n = t.trim();
|
|
242
243
|
if (n === "") return null;
|
|
243
244
|
const e = n.replace(/,/g, "");
|
|
@@ -245,41 +246,52 @@ function it(t) {
|
|
|
245
246
|
const r = Number(e);
|
|
246
247
|
return Number.isFinite(r) ? r : null;
|
|
247
248
|
}
|
|
248
|
-
function
|
|
249
|
+
function at(t, n = {}) {
|
|
249
250
|
const { trueLabel: e = "Yes", falseLabel: r = "No", unknownLabel: o = "Unknown" } = n;
|
|
250
251
|
return t === !0 ? e : t === !1 ? r : o;
|
|
251
252
|
}
|
|
252
|
-
const
|
|
253
|
-
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) {
|
|
254
255
|
const n = t.trim().toLowerCase();
|
|
255
|
-
return
|
|
256
|
+
return V.has(n) ? !0 : j.has(n) ? !1 : null;
|
|
256
257
|
}
|
|
257
|
-
const
|
|
258
|
-
function
|
|
258
|
+
const J = /^([^\s@]+)@([^\s@]+)$/;
|
|
259
|
+
function z(t) {
|
|
260
|
+
return t.split(".").some((n) => n.length === 0);
|
|
261
|
+
}
|
|
262
|
+
function ft(t) {
|
|
259
263
|
const n = t.trim();
|
|
260
|
-
|
|
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]);
|
|
261
276
|
}
|
|
262
|
-
function
|
|
277
|
+
function lt(t) {
|
|
263
278
|
const n = t.trim();
|
|
264
279
|
if (n === "") return !0;
|
|
265
280
|
if (/\s/.test(n)) return !1;
|
|
281
|
+
const e = G.test(n) ? n : `https://${n}`;
|
|
266
282
|
try {
|
|
267
|
-
const
|
|
268
|
-
return
|
|
269
|
-
} catch {
|
|
270
|
-
}
|
|
271
|
-
try {
|
|
272
|
-
return new URL(`https://${n}`).hostname.includes(".");
|
|
283
|
+
const r = new URL(e);
|
|
284
|
+
return r.protocol !== "http:" && r.protocol !== "https:" ? !1 : K(r.hostname);
|
|
273
285
|
} catch {
|
|
274
286
|
return !1;
|
|
275
287
|
}
|
|
276
288
|
}
|
|
277
|
-
function
|
|
289
|
+
function dt(t, n) {
|
|
278
290
|
if (!Number.isFinite(t) || !Number.isFinite(n) || n <= 0 || t <= 0) return null;
|
|
279
291
|
const e = Math.round(Math.min(t, n) / n * 5);
|
|
280
292
|
return Math.max(1, Math.min(5, e));
|
|
281
293
|
}
|
|
282
|
-
const
|
|
294
|
+
const ht = {
|
|
283
295
|
1: "Just a guess",
|
|
284
296
|
2: "Somewhat unsure",
|
|
285
297
|
3: "Fairly confident",
|
|
@@ -287,26 +299,26 @@ const ft = {
|
|
|
287
299
|
5: "Highly confident"
|
|
288
300
|
};
|
|
289
301
|
export {
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
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
|
|
311
323
|
};
|
|
312
324
|
//# sourceMappingURL=pure.js.map
|