@danxbot/ui 5.2.0 → 6.0.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 +11269 -11057
- package/dist/index.js.map +1 -1
- package/dist/pure.js +163 -150
- package/dist/pure.js.map +1 -1
- package/dist/types/components/InlineEdit.d.ts +46 -115
- package/dist/types/components/MarkdownEditor.d.ts +22 -2
- package/dist/types/components/Progress.d.ts +24 -0
- package/dist/types/components/ReadMore.d.ts +76 -0
- package/dist/types/components/provenance/ProvenanceDetail.d.ts +9 -0
- package/dist/types/index.d.ts +3 -2
- package/dist/types/lib/format.d.ts +27 -7
- package/dist/types/pure.d.ts +1 -1
- package/package.json +2 -2
- /package/dist/types/{components/code-editor/state.d.ts → lib/use-controllable.d.ts} +0 -0
package/dist/pure.js
CHANGED
|
@@ -1,79 +1,91 @@
|
|
|
1
|
-
function
|
|
1
|
+
function G(t) {
|
|
2
2
|
if (!Number.isFinite(t) || t < 0) return "";
|
|
3
3
|
if (t < 1024) return `${t} B`;
|
|
4
|
-
const
|
|
5
|
-
let
|
|
6
|
-
for (;
|
|
7
|
-
|
|
8
|
-
return `${
|
|
4
|
+
const n = ["KB", "MB", "GB", "TB"];
|
|
5
|
+
let e = t / 1024, r = 0;
|
|
6
|
+
for (; e >= 1024 && r < n.length - 1; )
|
|
7
|
+
e /= 1024, r += 1;
|
|
8
|
+
return `${e < 10 ? e.toFixed(1) : Math.round(e)} ${n[r]}`;
|
|
9
9
|
}
|
|
10
|
-
function
|
|
11
|
-
return
|
|
10
|
+
function J(t) {
|
|
11
|
+
return M(t);
|
|
12
12
|
}
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
function M(t) {
|
|
14
|
+
if (t == null || !Number.isFinite(t)) return "—";
|
|
15
|
+
const n = t < 0 ? "-" : "", e = Math.abs(t), r = [
|
|
16
|
+
[1e12, "T"],
|
|
17
|
+
[1e9, "B"],
|
|
18
|
+
[1e6, "M"],
|
|
19
|
+
[1e3, "k"]
|
|
20
|
+
];
|
|
21
|
+
for (const [o, i] of r)
|
|
22
|
+
if (e >= o) return `${n}${Number((e / o).toFixed(1))}${i}`;
|
|
23
|
+
return `${n}${Math.round(e)}`;
|
|
24
|
+
}
|
|
25
|
+
class g extends Error {
|
|
26
|
+
constructor(n, e, r) {
|
|
15
27
|
super(
|
|
16
|
-
r === "gap" ? `${y(
|
|
17
|
-
), this.wall =
|
|
28
|
+
r === "gap" ? `${y(n)} does not exist in ${e} — the clock skipped it.` : `${y(n)} happens twice in ${e}.`
|
|
29
|
+
), this.wall = n, this.zone = e, this.kind = r, this.name = "AmbiguousTimeError";
|
|
18
30
|
}
|
|
19
31
|
wall;
|
|
20
32
|
zone;
|
|
21
33
|
kind;
|
|
22
34
|
}
|
|
23
35
|
function y(t) {
|
|
24
|
-
const
|
|
25
|
-
return `${
|
|
36
|
+
const n = (e, r = 2) => String(e).padStart(r, "0");
|
|
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)}`;
|
|
26
38
|
}
|
|
27
|
-
function
|
|
28
|
-
const
|
|
29
|
-
return `${
|
|
39
|
+
function A(t) {
|
|
40
|
+
const n = (e, r = 2) => String(e).padStart(r, "0");
|
|
41
|
+
return `${n(t.year, 4)}-${n(t.month)}-${n(t.day)}`;
|
|
30
42
|
}
|
|
31
|
-
function l(t,
|
|
32
|
-
const
|
|
33
|
-
return
|
|
43
|
+
function l(t, n) {
|
|
44
|
+
const e = /* @__PURE__ */ new Date(0);
|
|
45
|
+
return e.setUTCFullYear(t, n, 0), e.getUTCDate();
|
|
34
46
|
}
|
|
35
|
-
function
|
|
36
|
-
const
|
|
37
|
-
if (!
|
|
38
|
-
const
|
|
47
|
+
function U(t) {
|
|
48
|
+
const n = /^(\d{4})-(\d{2})-(\d{2})$/.exec(t);
|
|
49
|
+
if (!n) throw new Error(`not an ISO date: ${JSON.stringify(t)} — expected YYYY-MM-DD`);
|
|
50
|
+
const e = Number(n[1]), r = Number(n[2]), o = Number(n[3]);
|
|
39
51
|
if (r < 1 || r > 12) throw new Error(`month out of range in ${t}`);
|
|
40
|
-
if (o < 1 || o > l(
|
|
41
|
-
throw new Error(`${t} is not a real date — ${
|
|
42
|
-
return { year:
|
|
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`);
|
|
54
|
+
return { year: e, month: r, day: o };
|
|
43
55
|
}
|
|
44
|
-
const
|
|
45
|
-
function S(t,
|
|
46
|
-
return String(t).padStart(
|
|
56
|
+
const x = "—";
|
|
57
|
+
function S(t, n = 2) {
|
|
58
|
+
return String(t).padStart(n, "0");
|
|
47
59
|
}
|
|
48
|
-
function
|
|
49
|
-
if (t == null || t === "") return
|
|
50
|
-
let
|
|
60
|
+
function K(t) {
|
|
61
|
+
if (t == null || t === "") return x;
|
|
62
|
+
let n;
|
|
51
63
|
try {
|
|
52
|
-
|
|
64
|
+
n = U(t);
|
|
53
65
|
} catch {
|
|
54
66
|
return t;
|
|
55
67
|
}
|
|
56
|
-
return `${S(
|
|
68
|
+
return `${S(n.month)}/${S(n.day)}/${n.year}`;
|
|
57
69
|
}
|
|
58
|
-
const
|
|
59
|
-
function
|
|
60
|
-
const
|
|
61
|
-
if (
|
|
62
|
-
let
|
|
63
|
-
const
|
|
64
|
-
if (
|
|
65
|
-
|
|
70
|
+
const B = /^(\d{1,2})\/(\d{1,2})\/(\d{4})$/, E = /^(\d{4})-(\d{1,2})-(\d{1,2})$/;
|
|
71
|
+
function q(t) {
|
|
72
|
+
const n = t.trim();
|
|
73
|
+
if (n === "") return null;
|
|
74
|
+
let e, r, o;
|
|
75
|
+
const i = E.exec(n);
|
|
76
|
+
if (i)
|
|
77
|
+
e = Number(i[1]), r = Number(i[2]), o = Number(i[3]);
|
|
66
78
|
else {
|
|
67
|
-
const
|
|
68
|
-
if (!
|
|
69
|
-
r = Number(
|
|
79
|
+
const s = B.exec(n);
|
|
80
|
+
if (!s) return null;
|
|
81
|
+
r = Number(s[1]), o = Number(s[2]), e = Number(s[3]);
|
|
70
82
|
}
|
|
71
|
-
return r < 1 || r > 12 || o < 1 || o > l(
|
|
83
|
+
return r < 1 || r > 12 || o < 1 || o > l(e, r) ? null : A({ year: e, month: r, day: o });
|
|
72
84
|
}
|
|
73
|
-
const h = 36e5,
|
|
74
|
-
function
|
|
75
|
-
let
|
|
76
|
-
return
|
|
85
|
+
const h = 36e5, T = /* @__PURE__ */ new Map();
|
|
86
|
+
function w(t) {
|
|
87
|
+
let n = T.get(t);
|
|
88
|
+
return n || (n = new Intl.DateTimeFormat("en-US", {
|
|
77
89
|
timeZone: t,
|
|
78
90
|
year: "numeric",
|
|
79
91
|
month: "2-digit",
|
|
@@ -85,12 +97,12 @@ function B(t) {
|
|
|
85
97
|
midnight as hour "24" under `hour12: false`, which parses as a valid
|
|
86
98
|
number and silently lands the reading on the wrong day. */
|
|
87
99
|
hourCycle: "h23"
|
|
88
|
-
}),
|
|
100
|
+
}), T.set(t, n)), n;
|
|
89
101
|
}
|
|
90
|
-
function N(t,
|
|
91
|
-
const
|
|
92
|
-
let r = 0, o = 1,
|
|
93
|
-
for (const m of
|
|
102
|
+
function N(t, n) {
|
|
103
|
+
const e = w(t).formatToParts(new Date(n));
|
|
104
|
+
let r = 0, o = 1, i = 1, s = 0, u = 0, c = 0;
|
|
105
|
+
for (const m of e)
|
|
94
106
|
switch (m.type) {
|
|
95
107
|
case "year":
|
|
96
108
|
r = Number(m.value);
|
|
@@ -99,156 +111,157 @@ function N(t, e) {
|
|
|
99
111
|
o = Number(m.value);
|
|
100
112
|
break;
|
|
101
113
|
case "day":
|
|
102
|
-
|
|
114
|
+
i = Number(m.value);
|
|
103
115
|
break;
|
|
104
116
|
case "hour":
|
|
105
|
-
|
|
117
|
+
s = Number(m.value);
|
|
106
118
|
break;
|
|
107
119
|
case "minute":
|
|
108
|
-
|
|
120
|
+
u = Number(m.value);
|
|
109
121
|
break;
|
|
110
122
|
case "second":
|
|
111
123
|
c = Number(m.value);
|
|
112
124
|
break;
|
|
113
125
|
}
|
|
114
|
-
const a = (
|
|
115
|
-
return { year: r, month: o, day:
|
|
126
|
+
const a = (n % 1e3 + 1e3) % 1e3;
|
|
127
|
+
return { year: r, month: o, day: i, hour: s, minute: u, second: c, millisecond: a };
|
|
116
128
|
}
|
|
117
|
-
function
|
|
118
|
-
const
|
|
119
|
-
return
|
|
129
|
+
function b(t) {
|
|
130
|
+
const n = /* @__PURE__ */ new Date(0);
|
|
131
|
+
return n.setUTCFullYear(t.year, t.month - 1, t.day), n.setUTCHours(t.hour, t.minute, t.second, t.millisecond), n.getTime();
|
|
120
132
|
}
|
|
121
|
-
function $(t,
|
|
122
|
-
return
|
|
133
|
+
function $(t, n) {
|
|
134
|
+
return b(N(t, n)) - n;
|
|
123
135
|
}
|
|
124
|
-
function
|
|
125
|
-
return t.year ===
|
|
136
|
+
function O(t, n) {
|
|
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;
|
|
126
138
|
}
|
|
127
|
-
function
|
|
128
|
-
const
|
|
129
|
-
for (const
|
|
130
|
-
const
|
|
131
|
-
|
|
139
|
+
function I(t, n) {
|
|
140
|
+
const e = b(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
|
+
O(N(t, u), n) && i.push(u);
|
|
132
144
|
}
|
|
133
|
-
return
|
|
145
|
+
return i.sort((s, u) => s - u), i.filter((s, u) => u === 0 || s !== i[u - 1]);
|
|
134
146
|
}
|
|
135
|
-
function
|
|
136
|
-
const r =
|
|
147
|
+
function k(t, n, e = "compatible") {
|
|
148
|
+
const r = I(t, n);
|
|
137
149
|
if (r.length === 1) return r[0];
|
|
138
150
|
if (r.length > 1) {
|
|
139
|
-
if (
|
|
140
|
-
return
|
|
151
|
+
if (e === "reject") throw new g(n, t, "overlap");
|
|
152
|
+
return e === "later" ? r[r.length - 1] : r[0];
|
|
141
153
|
}
|
|
142
|
-
if (
|
|
143
|
-
const o =
|
|
144
|
-
return
|
|
154
|
+
if (e === "reject") throw new g(n, t, "gap");
|
|
155
|
+
const o = b(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);
|
|
145
157
|
}
|
|
146
158
|
const C = "—";
|
|
147
|
-
function p(t,
|
|
148
|
-
return String(t).padStart(
|
|
159
|
+
function p(t, n = 2) {
|
|
160
|
+
return String(t).padStart(n, "0");
|
|
149
161
|
}
|
|
150
|
-
function
|
|
162
|
+
function D() {
|
|
151
163
|
return Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
152
164
|
}
|
|
153
|
-
function
|
|
165
|
+
function P(t) {
|
|
154
166
|
if (typeof t == "number") return Number.isFinite(t) ? t : null;
|
|
155
|
-
const
|
|
156
|
-
return Number.isNaN(
|
|
167
|
+
const n = t.replace(/(\.\d{3})\d+/, "$1"), e = Date.parse(n);
|
|
168
|
+
return Number.isNaN(e) ? null : e;
|
|
157
169
|
}
|
|
158
|
-
function
|
|
170
|
+
function Q(t, n = {}) {
|
|
159
171
|
if (t == null || t === "") return C;
|
|
160
|
-
const
|
|
161
|
-
if (
|
|
162
|
-
const r =
|
|
163
|
-
return `${p(o.month)}/${p(o.day)}/${o.year}, ${
|
|
172
|
+
const e = P(t);
|
|
173
|
+
if (e === null) return String(t);
|
|
174
|
+
const r = n.zone ?? D(), 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}`;
|
|
164
176
|
}
|
|
165
|
-
const
|
|
166
|
-
function
|
|
167
|
-
const
|
|
168
|
-
if (
|
|
169
|
-
if (Y.test(
|
|
170
|
-
const f =
|
|
177
|
+
const R = /^(\d{1,2})\/(\d{1,2})\/(\d{4})(?:,?\s+(\d{1,2}):(\d{2})(?::(\d{2}))?\s*([AaPp][Mm]))?$/, Y = /^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}(:\d{2}(\.\d+)?)?\s*(Z|[+-]\d{2}:?\d{2})$/;
|
|
178
|
+
function V(t, n = {}) {
|
|
179
|
+
const e = t.trim();
|
|
180
|
+
if (e === "") return null;
|
|
181
|
+
if (Y.test(e)) {
|
|
182
|
+
const f = e.replace(/(\.\d{3})\d+/, "$1"), d = Date.parse(f);
|
|
171
183
|
return Number.isNaN(d) ? null : new Date(d).toISOString();
|
|
172
184
|
}
|
|
173
|
-
const r =
|
|
185
|
+
const r = R.exec(e);
|
|
174
186
|
if (!r) return null;
|
|
175
|
-
const o = Number(r[1]),
|
|
176
|
-
if (o < 1 || o > 12 ||
|
|
177
|
-
let
|
|
187
|
+
const o = Number(r[1]), i = Number(r[2]), s = Number(r[3]);
|
|
188
|
+
if (o < 1 || o > 12 || i < 1 || i > l(s, o)) return null;
|
|
189
|
+
let u = 0, c = 0, a = 0;
|
|
178
190
|
if (r[4] !== void 0) {
|
|
179
191
|
const f = Number(r[4]);
|
|
180
192
|
c = Number(r[5]), a = r[6] !== void 0 ? Number(r[6]) : 0;
|
|
181
193
|
const d = r[7].toUpperCase();
|
|
182
194
|
if (f < 1 || f > 12 || c > 59 || a > 59) return null;
|
|
183
|
-
|
|
195
|
+
u = d === "AM" ? f === 12 ? 0 : f : f === 12 ? 12 : f + 12;
|
|
184
196
|
}
|
|
185
|
-
const m = { year:
|
|
186
|
-
return new Date(
|
|
197
|
+
const m = { year: s, month: o, day: i, hour: u, minute: c, second: a, millisecond: 0 }, F = n.zone ?? D();
|
|
198
|
+
return new Date(k(F, m)).toISOString();
|
|
187
199
|
}
|
|
188
|
-
const _ = "—",
|
|
200
|
+
const _ = "—", L = new Intl.NumberFormat("en-US", {
|
|
189
201
|
style: "currency",
|
|
190
202
|
currency: "USD",
|
|
191
203
|
minimumFractionDigits: 2,
|
|
192
204
|
maximumFractionDigits: 2
|
|
193
205
|
});
|
|
194
|
-
function V(t) {
|
|
195
|
-
return t == null || !Number.isFinite(t) ? _ : R.format(t);
|
|
196
|
-
}
|
|
197
206
|
function X(t) {
|
|
198
|
-
|
|
199
|
-
if (e === "") return null;
|
|
200
|
-
const n = /^\((.*)\)$/.exec(e), r = n !== null, u = (n ? n[1] : e).replace(/[$,\s]/g, "");
|
|
201
|
-
if (!/^-?\d+(\.\d+)?$/.test(u)) return null;
|
|
202
|
-
const i = Number(u);
|
|
203
|
-
return Number.isFinite(i) ? r ? -Math.abs(i) : i : null;
|
|
207
|
+
return t == null || !Number.isFinite(t) ? _ : L.format(t);
|
|
204
208
|
}
|
|
205
|
-
const L = "—";
|
|
206
209
|
function z(t) {
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
+
const n = t.trim();
|
|
211
|
+
if (n === "") return null;
|
|
212
|
+
const e = /^\((.*)\)$/.exec(n), r = e !== null, i = (e ? e[1] : n).replace(/[$,\s]/g, "");
|
|
213
|
+
if (!/^-?\d+(\.\d+)?$/.test(i)) return null;
|
|
214
|
+
const s = Number(i);
|
|
215
|
+
return Number.isFinite(s) ? r ? -Math.abs(s) : s : null;
|
|
210
216
|
}
|
|
217
|
+
const W = "—";
|
|
211
218
|
function v(t) {
|
|
212
|
-
|
|
213
|
-
|
|
219
|
+
if (t == null || t === "") return W;
|
|
220
|
+
const n = t.replace(/\D/g, "");
|
|
221
|
+
return n.length !== 10 ? t : `(${n.slice(0, 3)}) ${n.slice(3, 6)}-${n.slice(6)}`;
|
|
214
222
|
}
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
223
|
+
function tt(t) {
|
|
224
|
+
const n = t.replace(/\D/g, "");
|
|
225
|
+
return n.length === 11 && n.startsWith("1") ? n.slice(1) : n.length === 10 ? n : null;
|
|
226
|
+
}
|
|
227
|
+
const Z = "—";
|
|
228
|
+
function nt(t, n = {}) {
|
|
229
|
+
if (t == null || !Number.isFinite(t)) return Z;
|
|
230
|
+
const { decimals: e } = n, r = e === void 0 ? { maximumFractionDigits: 6 } : { minimumFractionDigits: e, maximumFractionDigits: e };
|
|
219
231
|
return new Intl.NumberFormat("en-US", r).format(t);
|
|
220
232
|
}
|
|
221
233
|
function et(t) {
|
|
222
|
-
const
|
|
223
|
-
if (
|
|
224
|
-
const
|
|
225
|
-
if (!/^-?\d+(\.\d+)?$/.test(
|
|
226
|
-
const r = Number(
|
|
234
|
+
const n = t.trim();
|
|
235
|
+
if (n === "") return null;
|
|
236
|
+
const e = n.replace(/,/g, "");
|
|
237
|
+
if (!/^-?\d+(\.\d+)?$/.test(e)) return null;
|
|
238
|
+
const r = Number(e);
|
|
227
239
|
return Number.isFinite(r) ? r : null;
|
|
228
240
|
}
|
|
229
|
-
function
|
|
230
|
-
const { trueLabel:
|
|
231
|
-
return t === !0 ?
|
|
241
|
+
function rt(t, n = {}) {
|
|
242
|
+
const { trueLabel: e = "Yes", falseLabel: r = "No", unknownLabel: o = "Unknown" } = n;
|
|
243
|
+
return t === !0 ? e : t === !1 ? r : o;
|
|
232
244
|
}
|
|
233
|
-
const
|
|
234
|
-
function
|
|
235
|
-
const
|
|
236
|
-
return
|
|
245
|
+
const H = /* @__PURE__ */ new Set(["yes", "y", "true", "t", "1"]), j = /* @__PURE__ */ new Set(["no", "n", "false", "f", "0"]);
|
|
246
|
+
function ot(t) {
|
|
247
|
+
const n = t.trim().toLowerCase();
|
|
248
|
+
return H.has(n) ? !0 : j.has(n) ? !1 : null;
|
|
237
249
|
}
|
|
238
250
|
export {
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
+
rt as formatBoolean,
|
|
252
|
+
G as formatBytes,
|
|
253
|
+
M as formatCompactNumber,
|
|
254
|
+
X as formatCurrency,
|
|
255
|
+
K as formatDate,
|
|
256
|
+
Q as formatDateTime,
|
|
257
|
+
nt as formatNumber,
|
|
258
|
+
v as formatPhone,
|
|
259
|
+
J as formatTokens,
|
|
260
|
+
ot as parseBoolean,
|
|
261
|
+
z as parseCurrency,
|
|
262
|
+
q as parseDate,
|
|
263
|
+
V as parseDateTime,
|
|
251
264
|
et as parseNumber,
|
|
252
|
-
|
|
265
|
+
tt as parsePhone
|
|
253
266
|
};
|
|
254
267
|
//# sourceMappingURL=pure.js.map
|