@danxbot/ui 7.4.1 → 7.4.2

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/pure.js CHANGED
@@ -40,7 +40,7 @@ function E(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 l(t, n) {
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 > l(e, r))
53
- throw new Error(`${t} is not a real date — ${e}-${r} has ${l(e, r)} days`);
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 x = "—";
56
+ const U = "—";
57
57
  function S(t, n = 2) {
58
58
  return String(t).padStart(n, "0");
59
59
  }
60
60
  function K(t) {
61
- if (t == null || t === "") return x;
61
+ if (t == null || t === "") return U;
62
62
  let n;
63
63
  try {
64
64
  n = A(t);
@@ -67,23 +67,23 @@ function K(t) {
67
67
  }
68
68
  return `${S(n.month)}/${S(n.day)}/${n.year}`;
69
69
  }
70
- const B = /^(\d{1,2})\/(\d{1,2})\/(\d{4})$/, U = /^(\d{4})-(\d{1,2})-(\d{1,2})$/;
71
- function V(t) {
70
+ const w = /^(\d{1,2})\/(\d{1,2})\/(\d{4})$/, x = /^(\d{4})-(\d{1,2})-(\d{1,2})$/;
71
+ function q(t) {
72
72
  const n = t.trim();
73
73
  if (n === "") return null;
74
74
  let e, r, o;
75
- const i = U.exec(n);
75
+ const i = x.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 u = B.exec(n);
79
+ const u = w.exec(n);
80
80
  if (!u) return null;
81
81
  r = Number(u[1]), o = Number(u[2]), e = Number(u[3]);
82
82
  }
83
- return r < 1 || r > 12 || o < 1 || o > l(e, r) ? null : E({ year: e, month: r, day: o });
83
+ return r < 1 || r > 12 || o < 1 || o > d(e, r) ? null : E({ year: e, month: r, day: o });
84
84
  }
85
85
  const h = 36e5, D = /* @__PURE__ */ new Map();
86
- function w(t) {
86
+ function B(t) {
87
87
  let n = D.get(t);
88
88
  return n || (n = new Intl.DateTimeFormat("en-US", {
89
89
  timeZone: t,
@@ -99,8 +99,8 @@ function w(t) {
99
99
  hourCycle: "h23"
100
100
  }), D.set(t, n)), n;
101
101
  }
102
- function p(t, n) {
103
- const e = w(t).formatToParts(new Date(n));
102
+ function N(t, n) {
103
+ const e = B(t).formatToParts(new Date(n));
104
104
  let r = 0, o = 1, i = 1, u = 0, s = 0, c = 0;
105
105
  for (const m of e)
106
106
  switch (m.type) {
@@ -131,21 +131,21 @@ function b(t) {
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 b(p(t, n)) - n;
134
+ return b(N(t, n)) - n;
135
135
  }
136
- function O(t, n) {
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 I(t, n) {
139
+ function O(t, n) {
140
140
  const e = b(n), r = $(t, e - 24 * h), o = $(t, e + 24 * h), i = [];
141
141
  for (const u of r === o ? [r] : [r, o]) {
142
142
  const s = e - u;
143
- O(p(t, s), n) && i.push(s);
143
+ I(N(t, s), n) && i.push(s);
144
144
  }
145
145
  return i.sort((u, s) => u - s), i.filter((u, s) => s === 0 || u !== i[s - 1]);
146
146
  }
147
147
  function k(t, n, e = "compatible") {
148
- const r = I(t, n);
148
+ const r = O(t, n);
149
149
  if (r.length === 1) return r[0];
150
150
  if (r.length > 1) {
151
151
  if (e === "reject") throw new g(n, t, "overlap");
@@ -156,7 +156,7 @@ function k(t, n, e = "compatible") {
156
156
  return e === "earlier" ? Math.min(c, a) : s > 0 ? Math.max(c, a) : Math.min(c, a);
157
157
  }
158
158
  const C = "—";
159
- function N(t, n = 2) {
159
+ function p(t, n = 2) {
160
160
  return String(t).padStart(n, "0");
161
161
  }
162
162
  function T() {
@@ -167,46 +167,46 @@ 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 q(t, n = {}) {
170
+ function Q(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 = p(r, e), i = (o.hour + 11) % 12 + 1, u = o.hour < 12 ? "AM" : "PM";
175
- return `${N(o.month)}/${N(o.day)}/${o.year}, ${i}:${N(o.minute)} ${u}`;
174
+ const r = n.zone ?? T(), o = N(r, e), i = (o.hour + 11) % 12 + 1, u = o.hour < 12 ? "AM" : "PM";
175
+ return `${p(o.month)}/${p(o.day)}/${o.year}, ${i}:${p(o.minute)} ${u}`;
176
176
  }
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 Q(t, n = {}) {
177
+ const P = /^(\d{1,2})\/(\d{1,2})\/(\d{4})(?:,?\s+(\d{1,2}):(\d{2})(?::(\d{2}))?\s*([AaPp][Mm]))?$/, R = /^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}(:\d{2}(\.\d+)?)?\s*(Z|[+-]\d{2}:?\d{2})$/;
178
+ function X(t, n = {}) {
179
179
  const e = t.trim();
180
180
  if (e === "") return null;
181
- if (P.test(e)) {
182
- const f = e.replace(/(\.\d{3})\d+/, "$1"), d = Date.parse(f);
183
- return Number.isNaN(d) ? null : new Date(d).toISOString();
181
+ if (R.test(e)) {
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
- const r = _.exec(e);
185
+ const r = P.exec(e);
186
186
  if (!r) return null;
187
187
  const o = Number(r[1]), i = Number(r[2]), u = Number(r[3]);
188
- if (o < 1 || o > 12 || i < 1 || i > l(u, o)) return null;
188
+ if (o < 1 || o > 12 || i < 1 || i > d(u, o)) return null;
189
189
  let s = 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 d = r[7].toUpperCase();
193
+ const l = r[7].toUpperCase();
194
194
  if (f < 1 || f > 12 || c > 59 || a > 59) return null;
195
- s = d === "AM" ? f === 12 ? 0 : f : f === 12 ? 12 : f + 12;
195
+ s = l === "AM" ? f === 12 ? 0 : f : f === 12 ? 12 : f + 12;
196
196
  }
197
197
  const m = { year: u, month: o, day: i, hour: s, minute: c, second: a, millisecond: 0 }, F = n.zone ?? T();
198
198
  return new Date(k(F, m)).toISOString();
199
199
  }
200
- const R = "—", Y = new Intl.NumberFormat("en-US", {
200
+ const _ = "—", Y = 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 X(t) {
207
- return t == null || !Number.isFinite(t) ? R : Y.format(t);
208
- }
209
206
  function z(t) {
207
+ return t == null || !Number.isFinite(t) ? _ : Y.format(t);
208
+ }
209
+ function v(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, "");
@@ -214,23 +214,30 @@ function z(t) {
214
214
  const u = Number(i);
215
215
  return Number.isFinite(u) ? r ? -Math.abs(u) : u : null;
216
216
  }
217
- const H = "—";
218
- function v(t) {
219
- if (t == null || t === "") return H;
217
+ const W = "—";
218
+ function tt(t) {
219
+ if (t == null || t === "") return W;
220
220
  const n = t.replace(/\D/g, "");
221
221
  return n.length !== 10 ? t : `(${n.slice(0, 3)}) ${n.slice(3, 6)}-${n.slice(6)}`;
222
222
  }
223
- function tt(t) {
223
+ function nt(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
- const W = "—";
228
- function nt(t, n = {}) {
229
- if (t == null || !Number.isFinite(t)) return W;
227
+ function et(t) {
228
+ let n = t.replace(/\D/g, "");
229
+ return n.length === 11 && n.startsWith("1") && (n = n.slice(1)), n.slice(0, 10);
230
+ }
231
+ function rt(t) {
232
+ return t.length === 0 ? "" : t.length < 4 ? `(${t}` : t.length < 7 ? `(${t.slice(0, 3)}) ${t.slice(3)}` : `(${t.slice(0, 3)}) ${t.slice(3, 6)}-${t.slice(6)}`;
233
+ }
234
+ const H = "—";
235
+ function ot(t, n = {}) {
236
+ if (t == null || !Number.isFinite(t)) return H;
230
237
  const { decimals: e } = n, r = e === void 0 ? { maximumFractionDigits: 6 } : { minimumFractionDigits: e, maximumFractionDigits: e };
231
238
  return new Intl.NumberFormat("en-US", r).format(t);
232
239
  }
233
- function et(t) {
240
+ function it(t) {
234
241
  const n = t.trim();
235
242
  if (n === "") return null;
236
243
  const e = n.replace(/,/g, "");
@@ -238,21 +245,41 @@ function et(t) {
238
245
  const r = Number(e);
239
246
  return Number.isFinite(r) ? r : null;
240
247
  }
241
- function rt(t, n = {}) {
248
+ function ut(t, n = {}) {
242
249
  const { trueLabel: e = "Yes", falseLabel: r = "No", unknownLabel: o = "Unknown" } = n;
243
250
  return t === !0 ? e : t === !1 ? r : o;
244
251
  }
245
- const Z = /* @__PURE__ */ new Set(["yes", "y", "true", "t", "1"]), j = /* @__PURE__ */ new Set(["no", "n", "false", "f", "0"]);
246
- function ot(t) {
252
+ const Z = /* @__PURE__ */ new Set(["yes", "y", "true", "t", "1"]), V = /* @__PURE__ */ new Set(["no", "n", "false", "f", "0"]);
253
+ function st(t) {
247
254
  const n = t.trim().toLowerCase();
248
- return Z.has(n) ? !0 : j.has(n) ? !1 : null;
255
+ return Z.has(n) ? !0 : V.has(n) ? !1 : null;
256
+ }
257
+ const j = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
258
+ function ct(t) {
259
+ const n = t.trim();
260
+ return n === "" ? !0 : j.test(n);
261
+ }
262
+ function at(t) {
263
+ const n = t.trim();
264
+ if (n === "") return !0;
265
+ if (/\s/.test(n)) return !1;
266
+ try {
267
+ const e = new URL(n);
268
+ return e.hostname.includes(".") || e.hostname === "localhost";
269
+ } catch {
270
+ }
271
+ try {
272
+ return new URL(`https://${n}`).hostname.includes(".");
273
+ } catch {
274
+ return !1;
275
+ }
249
276
  }
250
- function it(t, n) {
277
+ function mt(t, n) {
251
278
  if (!Number.isFinite(t) || !Number.isFinite(n) || n <= 0 || t <= 0) return null;
252
279
  const e = Math.round(Math.min(t, n) / n * 5);
253
280
  return Math.max(1, Math.min(5, e));
254
281
  }
255
- const ut = {
282
+ const ft = {
256
283
  1: "Just a guess",
257
284
  2: "Somewhat unsure",
258
285
  3: "Fairly confident",
@@ -260,22 +287,26 @@ const ut = {
260
287
  5: "Highly confident"
261
288
  };
262
289
  export {
263
- ut as CONFIDENCE_LEVEL_LABELS,
264
- it as confidenceLevel,
265
- rt as formatBoolean,
290
+ ft as CONFIDENCE_LEVEL_LABELS,
291
+ mt as confidenceLevel,
292
+ et as digitsOfPhoneInProgress,
293
+ ut as formatBoolean,
266
294
  J as formatBytes,
267
295
  M as formatCompactNumber,
268
- X as formatCurrency,
296
+ z as formatCurrency,
269
297
  K as formatDate,
270
- q as formatDateTime,
271
- nt as formatNumber,
272
- v as formatPhone,
298
+ Q as formatDateTime,
299
+ ot as formatNumber,
300
+ tt as formatPhone,
301
+ rt as formatPhonePartial,
273
302
  G as formatTokens,
274
- ot as parseBoolean,
275
- z as parseCurrency,
276
- V as parseDate,
277
- Q as parseDateTime,
278
- et as parseNumber,
279
- tt as parsePhone
303
+ ct as isValidEmail,
304
+ at as isValidUrl,
305
+ st as parseBoolean,
306
+ v as parseCurrency,
307
+ q as parseDate,
308
+ X as parseDateTime,
309
+ it as parseNumber,
310
+ nt as parsePhone
280
311
  };
281
312
  //# sourceMappingURL=pure.js.map