@uvalib/web-components 1.1.1 → 1.2.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/CHANGELOG.md +53 -0
- package/README.md +515 -47
- package/dist/base/url-param.d.ts +23 -0
- package/dist/base/url-param.js +49 -0
- package/dist/base/url-param.js.map +1 -0
- package/dist/base.css +289 -1
- package/dist/components/uvalib-card/UvalibCard.d.ts +19 -5
- package/dist/components/uvalib-card/UvalibCard.js +112 -9
- package/dist/components/uvalib-card/UvalibCard.js.map +1 -1
- package/dist/components/uvalib-chip-group/UvalibChipGroup.d.ts +156 -0
- package/dist/components/uvalib-chip-group/UvalibChipGroup.js +747 -0
- package/dist/components/uvalib-chip-group/UvalibChipGroup.js.map +1 -0
- package/dist/components/uvalib-chip-group/uvalib-chip-group.d.ts +1 -0
- package/dist/components/uvalib-chip-group/uvalib-chip-group.js +4 -0
- package/dist/components/uvalib-chip-group/uvalib-chip-group.js.map +1 -0
- package/dist/components/uvalib-date-histogram/UvalibDateHistogram.d.ts +148 -0
- package/dist/components/uvalib-date-histogram/UvalibDateHistogram.js +1248 -0
- package/dist/components/uvalib-date-histogram/UvalibDateHistogram.js.map +1 -0
- package/dist/components/uvalib-date-histogram/uvalib-date-histogram.d.ts +1 -0
- package/dist/components/uvalib-date-histogram/uvalib-date-histogram.js +4 -0
- package/dist/components/uvalib-date-histogram/uvalib-date-histogram.js.map +1 -0
- package/dist/components/uvalib-lightbox/UvalibLightbox.js +8 -1
- package/dist/components/uvalib-lightbox/UvalibLightbox.js.map +1 -1
- package/dist/components/uvalib-lightbox/media.d.ts +1 -18
- package/dist/components/uvalib-lightbox/media.js +1 -42
- package/dist/components/uvalib-lightbox/media.js.map +1 -1
- package/dist/components/uvalib-pager/UvalibPager.d.ts +58 -4
- package/dist/components/uvalib-pager/UvalibPager.js +232 -8
- package/dist/components/uvalib-pager/UvalibPager.js.map +1 -1
- package/dist/components/uvalib-photo-grid/UvalibPhotoGrid.d.ts +27 -1
- package/dist/components/uvalib-photo-grid/UvalibPhotoGrid.js +192 -26
- package/dist/components/uvalib-photo-grid/UvalibPhotoGrid.js.map +1 -1
- package/dist/components/uvalib-results-count/UvalibResultsCount.d.ts +62 -0
- package/dist/components/uvalib-results-count/UvalibResultsCount.js +208 -0
- package/dist/components/uvalib-results-count/UvalibResultsCount.js.map +1 -0
- package/dist/components/uvalib-results-count/uvalib-results-count.d.ts +1 -0
- package/dist/components/uvalib-results-count/uvalib-results-count.js +4 -0
- package/dist/components/uvalib-results-count/uvalib-results-count.js.map +1 -0
- package/dist/components/uvalib-tabs/UvalibTabs.d.ts +127 -0
- package/dist/components/uvalib-tabs/UvalibTabs.js +821 -0
- package/dist/components/uvalib-tabs/UvalibTabs.js.map +1 -0
- package/dist/components/uvalib-tabs/uvalib-tabs.d.ts +1 -0
- package/dist/components/uvalib-tabs/uvalib-tabs.js +4 -0
- package/dist/components/uvalib-tabs/uvalib-tabs.js.map +1 -0
- package/dist/components/uvalib-tag-list/UvalibTagList.d.ts +89 -0
- package/dist/components/uvalib-tag-list/UvalibTagList.js +411 -0
- package/dist/components/uvalib-tag-list/UvalibTagList.js.map +1 -0
- package/dist/components/uvalib-tag-list/uvalib-tag-list.d.ts +1 -0
- package/dist/components/uvalib-tag-list/uvalib-tag-list.js +4 -0
- package/dist/components/uvalib-tag-list/uvalib-tag-list.js.map +1 -0
- package/dist/custom-elements.json +7140 -2630
- package/dist/index.d.ts +8 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/styles/base.js +35 -1
- package/dist/styles/base.js.map +1 -1
- package/dist/styles/color-scheme.js +4 -0
- package/dist/styles/color-scheme.js.map +1 -1
- package/dist/styles/controls.js +2 -0
- package/dist/styles/controls.js.map +1 -1
- package/dist/styles/results.d.ts +1 -0
- package/dist/styles/results.js +257 -0
- package/dist/styles/results.js.map +1 -0
- package/dist/tokens.css +4 -0
- package/dist-cdn/base.css +289 -1
- package/dist-cdn/chunks/{base-CAFQWnZG.js → base-p5pk0vb2.js} +36 -2
- package/dist-cdn/chunks/{base-CAFQWnZG.js.map → base-p5pk0vb2.js.map} +1 -1
- package/dist-cdn/chunks/inline-copy-BANQSMIR.js +69 -0
- package/dist-cdn/chunks/inline-copy-BANQSMIR.js.map +1 -0
- package/dist-cdn/chunks/{site-header-C9V7Wuw2.js → site-header-BlOYvQg1.js} +5 -1
- package/dist-cdn/chunks/site-header-BlOYvQg1.js.map +1 -0
- package/dist-cdn/chunks/source-children-BHsDwCvL.js +53 -0
- package/dist-cdn/chunks/source-children-BHsDwCvL.js.map +1 -0
- package/dist-cdn/chunks/url-param-C1sk_F1d.js +28 -0
- package/dist-cdn/chunks/url-param-C1sk_F1d.js.map +1 -0
- package/dist-cdn/custom-elements.json +7140 -2630
- package/dist-cdn/manifest.json +7 -2
- package/dist-cdn/site-header.js +1 -1
- package/dist-cdn/site-page.js +2 -2
- package/dist-cdn/site-style.js +1 -1
- package/dist-cdn/skills/uvalib-web-components/SKILL.md +179 -19
- package/dist-cdn/skills/uvalib-web-components/reference/components.md +220 -6
- package/dist-cdn/tokens.css +4 -0
- package/dist-cdn/uvalib-card.js +94 -20
- package/dist-cdn/uvalib-card.js.map +1 -1
- package/dist-cdn/uvalib-chip-group.js +496 -0
- package/dist-cdn/uvalib-chip-group.js.map +1 -0
- package/dist-cdn/uvalib-contents.js +2 -1
- package/dist-cdn/uvalib-contents.js.map +1 -1
- package/dist-cdn/uvalib-date-histogram.js +850 -0
- package/dist-cdn/uvalib-date-histogram.js.map +1 -0
- package/dist-cdn/uvalib-lightbox.js +26 -48
- package/dist-cdn/uvalib-lightbox.js.map +1 -1
- package/dist-cdn/uvalib-metadata.js +2 -1
- package/dist-cdn/uvalib-metadata.js.map +1 -1
- package/dist-cdn/uvalib-pager.js +141 -7
- package/dist-cdn/uvalib-pager.js.map +1 -1
- package/dist-cdn/uvalib-photo-grid.js +121 -19
- package/dist-cdn/uvalib-photo-grid.js.map +1 -1
- package/dist-cdn/uvalib-results-count.js +101 -0
- package/dist-cdn/uvalib-results-count.js.map +1 -0
- package/dist-cdn/uvalib-tabs.js +436 -0
- package/dist-cdn/uvalib-tabs.js.map +1 -0
- package/dist-cdn/uvalib-tag-list.js +267 -0
- package/dist-cdn/uvalib-tag-list.js.map +1 -0
- package/package.json +24 -3
- package/skills/uvalib-web-components/SKILL.md +179 -19
- package/skills/uvalib-web-components/reference/components.md +220 -6
- package/dist-cdn/chunks/site-header-C9V7Wuw2.js.map +0 -1
- package/dist-cdn/chunks/source-children-RuAec527.js +0 -119
- package/dist-cdn/chunks/source-children-RuAec527.js.map +0 -1
|
@@ -0,0 +1,850 @@
|
|
|
1
|
+
import { a as e, i as t, l as n, m as r, n as i, o as a, p as o, r as s, t as c } from "./chunks/UvalibElement-BnI-eRRR.js";
|
|
2
|
+
import { t as l } from "./chunks/repeat-CIFUYkyh.js";
|
|
3
|
+
import { a as u } from "./chunks/analytics-DTTihuBD.js";
|
|
4
|
+
import { t as d } from "./chunks/source-children-BHsDwCvL.js";
|
|
5
|
+
import { t as f } from "./chunks/accessible-GqhVn5_H.js";
|
|
6
|
+
// src/components/uvalib-date-histogram/UvalibDateHistogram.ts
|
|
7
|
+
var p = "uvalib-date-histogram", m = [
|
|
8
|
+
"January",
|
|
9
|
+
"February",
|
|
10
|
+
"March",
|
|
11
|
+
"April",
|
|
12
|
+
"May",
|
|
13
|
+
"June",
|
|
14
|
+
"July",
|
|
15
|
+
"August",
|
|
16
|
+
"September",
|
|
17
|
+
"October",
|
|
18
|
+
"November",
|
|
19
|
+
"December"
|
|
20
|
+
], h = m.map((e) => e.slice(0, 3)), g = 0, _ = /^(\d{4})-(\d{2})-(\d{2})$/;
|
|
21
|
+
function v(e) {
|
|
22
|
+
let t = typeof e == "string" ? _.exec(e) : null;
|
|
23
|
+
if (!t) return !1;
|
|
24
|
+
let [n, r, i] = [
|
|
25
|
+
Number(t[1]),
|
|
26
|
+
Number(t[2]),
|
|
27
|
+
Number(t[3])
|
|
28
|
+
], a = new Date(Date.UTC(n, r - 1, i));
|
|
29
|
+
return a.setUTCFullYear(n), a.getUTCFullYear() === n && a.getUTCMonth() === r - 1 && a.getUTCDate() === i;
|
|
30
|
+
}
|
|
31
|
+
function y(e, t) {
|
|
32
|
+
let n = new Date(Date.UTC(e, t, 0)).getUTCDate();
|
|
33
|
+
return `${String(e).padStart(4, "0")}-${String(t).padStart(2, "0")}-${String(n).padStart(2, "0")}`;
|
|
34
|
+
}
|
|
35
|
+
function b(e) {
|
|
36
|
+
let t = e.toLowerCase(), n = m.findIndex((e) => e.toLowerCase() === t);
|
|
37
|
+
if (n >= 0) return n + 1;
|
|
38
|
+
let r = h.findIndex((e) => e.toLowerCase() === t);
|
|
39
|
+
if (r >= 0) return r + 1;
|
|
40
|
+
let i = Number(t);
|
|
41
|
+
return Number.isInteger(i) && i >= 1 && i <= 12 ? i : 0;
|
|
42
|
+
}
|
|
43
|
+
function x(e) {
|
|
44
|
+
let t = e.replace(/\s+/g, " ").trim();
|
|
45
|
+
if (!t) return null;
|
|
46
|
+
if (_.test(t)) return {
|
|
47
|
+
key: (v(t), t),
|
|
48
|
+
kind: "odd"
|
|
49
|
+
};
|
|
50
|
+
let n = /^(\d{4})-(\d{2})$/.exec(t);
|
|
51
|
+
if (n) {
|
|
52
|
+
let e = Number(n[2]);
|
|
53
|
+
return e >= 1 && e <= 12 ? {
|
|
54
|
+
key: `${n[1]}-${n[2]}`,
|
|
55
|
+
kind: "month"
|
|
56
|
+
} : {
|
|
57
|
+
key: t,
|
|
58
|
+
kind: "odd"
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
if (/^\d{4}$/.test(t)) return {
|
|
62
|
+
key: t,
|
|
63
|
+
kind: "year"
|
|
64
|
+
};
|
|
65
|
+
let r = /^([A-Za-z]+)\s+(\d{4})$/.exec(t) ?? /^(\d{4})\s+([A-Za-z]+)$/.exec(t);
|
|
66
|
+
if (r) {
|
|
67
|
+
let e = /^\d{4}$/.test(r[1]) ? r[1] : r[2], t = b(e === r[1] ? r[2] : r[1]);
|
|
68
|
+
if (t) return {
|
|
69
|
+
key: `${e}-${String(t).padStart(2, "0")}`,
|
|
70
|
+
kind: "month"
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
return {
|
|
74
|
+
key: t,
|
|
75
|
+
kind: "odd"
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
function S(e) {
|
|
79
|
+
if (v(e)) return {
|
|
80
|
+
from: e,
|
|
81
|
+
to: e
|
|
82
|
+
};
|
|
83
|
+
let t = /^(\d{4})-(\d{2})$/.exec(e);
|
|
84
|
+
return t && Number(t[2]) >= 1 && Number(t[2]) <= 12 ? {
|
|
85
|
+
from: `${e}-01`,
|
|
86
|
+
to: y(Number(t[1]), Number(t[2]))
|
|
87
|
+
} : /^\d{4}$/.test(e) ? {
|
|
88
|
+
from: `${e}-01-01`,
|
|
89
|
+
to: `${e}-12-31`
|
|
90
|
+
} : null;
|
|
91
|
+
}
|
|
92
|
+
function C(e) {
|
|
93
|
+
return e.trim().split(/\s*(?:\.\.|\/|\u2013|\u2014)\s*/).filter(Boolean);
|
|
94
|
+
}
|
|
95
|
+
function w(e) {
|
|
96
|
+
let t = e.trim();
|
|
97
|
+
if (!t) return null;
|
|
98
|
+
let n = C(t);
|
|
99
|
+
if (n.length >= 2 && n.every((e) => S(e) !== null)) {
|
|
100
|
+
let e = n.map((e) => S(e));
|
|
101
|
+
return {
|
|
102
|
+
from: e.reduce((e, t) => t.from < e ? t.from : e, e[0].from),
|
|
103
|
+
to: e.reduce((e, t) => t.to > e ? t.to : e, e[0].to)
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
return S(t) ?? {
|
|
107
|
+
from: t,
|
|
108
|
+
to: t
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
function T(e, t) {
|
|
112
|
+
let n = /^(\d{4})/.exec(e.trim()), r = /^(\d{4})/.exec(t.trim());
|
|
113
|
+
return !n || !r ? null : Math.abs(Number(r[1]) - Number(n[1])) + 1;
|
|
114
|
+
}
|
|
115
|
+
function E(e, t, n) {
|
|
116
|
+
if (!v(e) || !v(t)) return "";
|
|
117
|
+
let [r, i] = e <= t ? [e, t] : [t, e];
|
|
118
|
+
if (n === "year") {
|
|
119
|
+
let e = r.slice(0, 4), t = i.slice(0, 4);
|
|
120
|
+
return e === t ? e : `${e}/${t}`;
|
|
121
|
+
}
|
|
122
|
+
let a = r.slice(0, 7), o = i.slice(0, 7);
|
|
123
|
+
return a === o ? a : `${a}/${o}`;
|
|
124
|
+
}
|
|
125
|
+
function D(e, t) {
|
|
126
|
+
let n = t.trim() || "items";
|
|
127
|
+
return e === 1 && /[^s]s$/i.test(n) && !/ies$/i.test(n) ? n.slice(0, -1) : n;
|
|
128
|
+
}
|
|
129
|
+
function O(e, t, n) {
|
|
130
|
+
let r = t.toLocaleString("en-US"), i = D(t, n), a = /^(\d{4})-(\d{2})$/.exec(e);
|
|
131
|
+
if (a) return `${m[Number(a[2]) - 1]} ${a[1]}: ${r} ${i}`;
|
|
132
|
+
let o = /^(\d{4})-(\d{2})-(\d{2})$/.exec(e);
|
|
133
|
+
return o && v(e) ? `${Number(o[3])} ${m[Number(o[2]) - 1]} ${o[1]}: ${r} ${i}` : `${e}: ${r} ${i}`;
|
|
134
|
+
}
|
|
135
|
+
function k(e, t, n) {
|
|
136
|
+
e.set(t, (e.get(t) ?? 0) + n);
|
|
137
|
+
}
|
|
138
|
+
function A(e, t) {
|
|
139
|
+
let n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map();
|
|
140
|
+
for (let i of e) {
|
|
141
|
+
if (!i || typeof i.date != "string") continue;
|
|
142
|
+
let e = typeof i.count == "number" ? i.count : Number(i.count);
|
|
143
|
+
if (!Number.isFinite(e) || e < 0) continue;
|
|
144
|
+
let a = x(i.date);
|
|
145
|
+
if (!a) continue;
|
|
146
|
+
if (a.kind === "odd" || t === "month" && a.kind === "year") {
|
|
147
|
+
k(r, a.key, e);
|
|
148
|
+
continue;
|
|
149
|
+
}
|
|
150
|
+
let o = t === "year" ? a.key.slice(0, 4) : a.key;
|
|
151
|
+
n.set(o, (n.get(o) ?? 0) + e);
|
|
152
|
+
}
|
|
153
|
+
let i = [], a = [...n.keys()].sort();
|
|
154
|
+
if (a.length) {
|
|
155
|
+
let e = Number(a[0].slice(0, 4)), r = Number(a[a.length - 1].slice(0, 4));
|
|
156
|
+
for (let a = e; a <= r; a++) if (t === "year") {
|
|
157
|
+
let e = String(a);
|
|
158
|
+
i.push({
|
|
159
|
+
key: e,
|
|
160
|
+
count: n.get(e) ?? 0,
|
|
161
|
+
year: a,
|
|
162
|
+
month: 0
|
|
163
|
+
});
|
|
164
|
+
} else for (let e = 1; e <= 12; e++) {
|
|
165
|
+
let t = `${a}-${String(e).padStart(2, "0")}`;
|
|
166
|
+
i.push({
|
|
167
|
+
key: t,
|
|
168
|
+
count: n.get(t) ?? 0,
|
|
169
|
+
year: a,
|
|
170
|
+
month: e
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
let o = i.reduce((e, t) => t.count > e ? t.count : e, 0);
|
|
175
|
+
return {
|
|
176
|
+
bars: i,
|
|
177
|
+
odds: [...r.entries()].map(([e, t]) => ({
|
|
178
|
+
key: e,
|
|
179
|
+
count: t
|
|
180
|
+
})),
|
|
181
|
+
max: o
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
function j(e, t, n) {
|
|
185
|
+
return e <= 0 || t <= 0 ? 0 : n ? Math.log1p(e) / Math.log1p(t) * 100 : e / t * 100;
|
|
186
|
+
}
|
|
187
|
+
function M(e) {
|
|
188
|
+
if (e == null) return null;
|
|
189
|
+
let t = e.replace(/,/g, "").trim();
|
|
190
|
+
if (!t) return null;
|
|
191
|
+
if (t === "—" || t === "-" || t === "–") return 0;
|
|
192
|
+
let n = Number(t);
|
|
193
|
+
return Number.isFinite(n) && n >= 0 ? n : null;
|
|
194
|
+
}
|
|
195
|
+
function N(e, t) {
|
|
196
|
+
let n = [...e.cells];
|
|
197
|
+
return n.some((e) => e.tagName === "TH") || e.parentElement?.tagName === "THEAD" ? !0 : M(n[t]?.textContent) == null;
|
|
198
|
+
}
|
|
199
|
+
function P(e) {
|
|
200
|
+
let t = [...e.rows];
|
|
201
|
+
if (!t.length) return [];
|
|
202
|
+
let n = [...t[0].cells].map((e) => (e.textContent ?? "").replace(/\s+/g, " ").trim()), r = n.map((e) => b(e)), i = n.length >= 3 && r.filter((e) => e > 0).length >= 2, a = [];
|
|
203
|
+
if (i) {
|
|
204
|
+
for (let e of t.slice(1)) {
|
|
205
|
+
let t = [...e.cells], n = (t[0]?.textContent ?? "").trim();
|
|
206
|
+
/^\d{4}$/.test(n) && r.forEach((e, r) => {
|
|
207
|
+
if (!e) return;
|
|
208
|
+
let i = M(t[r]?.textContent);
|
|
209
|
+
i != null && a.push({
|
|
210
|
+
date: `${n}-${String(e).padStart(2, "0")}`,
|
|
211
|
+
count: i
|
|
212
|
+
});
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
return a;
|
|
216
|
+
}
|
|
217
|
+
let o = n.map((e) => e.toLowerCase()), s = o.findIndex((e) => /date|month|year/.test(e)), c = o.findIndex((e) => /count|photo|total|number|item/.test(e));
|
|
218
|
+
s < 0 && (s = 0), c < 0 && (c = +(s === 0));
|
|
219
|
+
let l = N(t[0], c) ? t.slice(1) : t;
|
|
220
|
+
for (let e of l) {
|
|
221
|
+
let t = [...e.cells], n = (t[s]?.textContent ?? "").replace(/\s+/g, " ").trim(), r = M(t[c]?.textContent);
|
|
222
|
+
n && r != null && a.push({
|
|
223
|
+
date: n,
|
|
224
|
+
count: r
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
return a;
|
|
228
|
+
}
|
|
229
|
+
var F = (e) => `
|
|
230
|
+
${e} { display: block; max-width: 100%; min-width: 0; box-sizing: border-box; }
|
|
231
|
+
${e} .scroller { overflow-x: auto; max-width: 100%; overscroll-behavior-x: contain; }
|
|
232
|
+
${e} .by-month .scroller { scroll-padding-inline-start: 4rem; }
|
|
233
|
+
${e} .year {
|
|
234
|
+
display: grid;
|
|
235
|
+
grid-template-columns: 3.5rem minmax(0, 1fr);
|
|
236
|
+
column-gap: 0.5rem;
|
|
237
|
+
align-items: end;
|
|
238
|
+
margin: 0 0 0.5rem;
|
|
239
|
+
}
|
|
240
|
+
${e} .year-label {
|
|
241
|
+
position: sticky;
|
|
242
|
+
inset-inline-start: 0;
|
|
243
|
+
z-index: 1;
|
|
244
|
+
text-align: end;
|
|
245
|
+
font-weight: 600;
|
|
246
|
+
font-variant-numeric: tabular-nums;
|
|
247
|
+
background: var(--uva-color-surface, #fff);
|
|
248
|
+
color: var(--uva-color-text, #2b2b2b);
|
|
249
|
+
}
|
|
250
|
+
${e} .bars {
|
|
251
|
+
display: grid;
|
|
252
|
+
grid-template-columns: repeat(12, minmax(1.5rem, 1fr));
|
|
253
|
+
gap: 2px;
|
|
254
|
+
block-size: var(--uvalib-date-histogram-bar-size, 8rem);
|
|
255
|
+
min-inline-size: calc(12 * 1.5rem + 11 * 2px);
|
|
256
|
+
}
|
|
257
|
+
${e} .bar {
|
|
258
|
+
position: relative;
|
|
259
|
+
box-sizing: border-box;
|
|
260
|
+
display: flex;
|
|
261
|
+
flex-direction: column;
|
|
262
|
+
justify-content: flex-end;
|
|
263
|
+
align-items: stretch;
|
|
264
|
+
min-inline-size: 1.5rem;
|
|
265
|
+
min-block-size: 1.5rem;
|
|
266
|
+
height: 100%;
|
|
267
|
+
margin: 0;
|
|
268
|
+
padding: 0;
|
|
269
|
+
border: 1px solid var(--uva-color-control-border, #808080);
|
|
270
|
+
background: var(--uva-color-track, #e5e7eb);
|
|
271
|
+
font: inherit;
|
|
272
|
+
color: inherit;
|
|
273
|
+
cursor: pointer;
|
|
274
|
+
}
|
|
275
|
+
${e} .bar::after {
|
|
276
|
+
content: '';
|
|
277
|
+
position: absolute;
|
|
278
|
+
inset: 0;
|
|
279
|
+
z-index: 1;
|
|
280
|
+
pointer-events: none;
|
|
281
|
+
}
|
|
282
|
+
${e} .fill {
|
|
283
|
+
display: block;
|
|
284
|
+
width: 100%;
|
|
285
|
+
min-height: 0;
|
|
286
|
+
background: var(--uva-color-accent-bg, var(--uva-brand-blue, #232d4b));
|
|
287
|
+
border: 1px solid var(--uva-color-text, #2b2b2b);
|
|
288
|
+
box-sizing: border-box;
|
|
289
|
+
}
|
|
290
|
+
${e} .bar.is-empty .fill { background: transparent; border-color: transparent; }
|
|
291
|
+
${e} .bar[aria-pressed='true']::after {
|
|
292
|
+
box-shadow: inset 0 0 0 3px var(--uva-color-text, #2b2b2b);
|
|
293
|
+
background-image: repeating-linear-gradient(
|
|
294
|
+
-45deg,
|
|
295
|
+
transparent,
|
|
296
|
+
transparent 3px,
|
|
297
|
+
var(--uva-color-on-accent, #fff) 3px,
|
|
298
|
+
var(--uva-color-on-accent, #fff) 4px
|
|
299
|
+
);
|
|
300
|
+
}
|
|
301
|
+
${e} .by-year .bars {
|
|
302
|
+
display: flex;
|
|
303
|
+
flex-wrap: wrap;
|
|
304
|
+
align-items: flex-end;
|
|
305
|
+
align-content: flex-end;
|
|
306
|
+
min-inline-size: 0;
|
|
307
|
+
block-size: auto;
|
|
308
|
+
min-block-size: var(--uvalib-date-histogram-bar-size, 8rem);
|
|
309
|
+
}
|
|
310
|
+
${e} .by-year .bar {
|
|
311
|
+
flex: 1 1 1.5rem;
|
|
312
|
+
max-inline-size: 3rem;
|
|
313
|
+
height: auto;
|
|
314
|
+
block-size: var(--uvalib-date-histogram-bar-size, 8rem);
|
|
315
|
+
}
|
|
316
|
+
${e} .strip {
|
|
317
|
+
display: flex;
|
|
318
|
+
align-items: flex-end;
|
|
319
|
+
gap: 2px;
|
|
320
|
+
block-size: var(--uvalib-date-histogram-strip-size, 1.5rem);
|
|
321
|
+
max-width: 100%;
|
|
322
|
+
}
|
|
323
|
+
${e} .strip-bar {
|
|
324
|
+
flex: 1 1 0;
|
|
325
|
+
min-inline-size: 0;
|
|
326
|
+
box-sizing: border-box;
|
|
327
|
+
background: var(--uva-color-accent-bg, var(--uva-brand-blue, #232d4b));
|
|
328
|
+
border: 1px solid var(--uva-color-text, #2b2b2b);
|
|
329
|
+
}
|
|
330
|
+
${e} .strip-bar.is-empty { background: transparent; }
|
|
331
|
+
${e} .strip-bar.is-selected {
|
|
332
|
+
box-shadow: inset 0 0 0 2px var(--uva-color-text, #2b2b2b);
|
|
333
|
+
background-image: repeating-linear-gradient(
|
|
334
|
+
-45deg,
|
|
335
|
+
transparent,
|
|
336
|
+
transparent 2px,
|
|
337
|
+
var(--uva-color-on-accent, #fff) 2px,
|
|
338
|
+
var(--uva-color-on-accent, #fff) 3px
|
|
339
|
+
);
|
|
340
|
+
}
|
|
341
|
+
${e} .outliers { display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0.5rem 0; }
|
|
342
|
+
${e} .chip {
|
|
343
|
+
box-sizing: border-box;
|
|
344
|
+
min-block-size: 1.5rem;
|
|
345
|
+
min-inline-size: 1.5rem;
|
|
346
|
+
margin: 0;
|
|
347
|
+
padding: 0.15rem 0.6rem;
|
|
348
|
+
border: 1px solid var(--uva-color-control-border, #808080);
|
|
349
|
+
border-radius: 999px;
|
|
350
|
+
background: var(--uva-color-surface-raised, #fff);
|
|
351
|
+
color: var(--uva-color-text, #2b2b2b);
|
|
352
|
+
font: inherit;
|
|
353
|
+
cursor: pointer;
|
|
354
|
+
}
|
|
355
|
+
${e} .chip[aria-pressed='true'] {
|
|
356
|
+
box-shadow: inset 0 0 0 2px var(--uva-color-text, #2b2b2b);
|
|
357
|
+
font-weight: 700;
|
|
358
|
+
}
|
|
359
|
+
${e} .scroll-hint {
|
|
360
|
+
margin: 0 0 0.35rem;
|
|
361
|
+
font-size: 0.875rem;
|
|
362
|
+
color: var(--uva-color-text-muted, #4b5563);
|
|
363
|
+
}
|
|
364
|
+
${e} .plot { min-block-size: var(--uvalib-date-histogram-bar-size, 8rem); }
|
|
365
|
+
${e} .empty { margin: 0; color: var(--uva-color-text-muted, #4b5563); }
|
|
366
|
+
${e} .table-wrap { overflow-x: auto; max-width: 100%; }
|
|
367
|
+
${e} table { border-collapse: collapse; }
|
|
368
|
+
${e} th, ${e} td {
|
|
369
|
+
border: 1px solid var(--uva-color-control-border, #808080);
|
|
370
|
+
padding: 0.2rem 0.4rem;
|
|
371
|
+
text-align: end;
|
|
372
|
+
color: var(--uva-color-text, #2b2b2b);
|
|
373
|
+
}
|
|
374
|
+
${e} th[scope='row'], ${e} caption { text-align: start; }
|
|
375
|
+
${e} caption { font-weight: 600; }
|
|
376
|
+
${e} .visually-hidden {
|
|
377
|
+
position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
|
|
378
|
+
overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
|
|
379
|
+
}
|
|
380
|
+
${e} :is(button, summary, [tabindex]):focus-visible {
|
|
381
|
+
outline: 3px solid var(--uva-color-focus, var(--uva-brand-orange, #e57200));
|
|
382
|
+
outline-offset: 2px;
|
|
383
|
+
}
|
|
384
|
+
${e}[hidden], ${e} [hidden] { display: none !important; }
|
|
385
|
+
${((t) => e === ":host" ? `:host(${t})` : `${e}${t}`)("[variant='strip']")} .chart { min-block-size: var(--uvalib-date-histogram-strip-size, 1.5rem); }
|
|
386
|
+
@media (forced-colors: active) {
|
|
387
|
+
${e} .bar, ${e} .strip-bar, ${e} .fill, ${e} .chip, ${e} th, ${e} td {
|
|
388
|
+
forced-color-adjust: none;
|
|
389
|
+
border: 1px solid ButtonText;
|
|
390
|
+
background: Canvas;
|
|
391
|
+
color: ButtonText;
|
|
392
|
+
}
|
|
393
|
+
${e} .fill, ${e} .strip-bar { background: ButtonText; }
|
|
394
|
+
${e} .bar.is-empty .fill, ${e} .strip-bar.is-empty { background: transparent; }
|
|
395
|
+
${e} .bar[aria-pressed='true'], ${e} .chip[aria-pressed='true'], ${e} .strip-bar.is-selected {
|
|
396
|
+
outline: 3px solid Highlight;
|
|
397
|
+
outline-offset: -4px;
|
|
398
|
+
}
|
|
399
|
+
${e} :is(.bar, .chip, summary, [tabindex]):focus-visible {
|
|
400
|
+
outline: 3px solid Highlight;
|
|
401
|
+
outline-offset: 2px;
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
`, I = o(F(":host"));
|
|
405
|
+
function L(e) {
|
|
406
|
+
return n`<caption>${e}</caption>`;
|
|
407
|
+
}
|
|
408
|
+
var R = class extends c {
|
|
409
|
+
static {
|
|
410
|
+
this.styles = [
|
|
411
|
+
f,
|
|
412
|
+
I,
|
|
413
|
+
o("\n :host { font-family: var(--uva-font-family, inherit); }\n .year-label { background: var(--uva-color-surface, #fff); color: var(--uva-color-text, #2b2b2b); }\n .bar {\n border-color: var(--uva-color-control-border, #808080);\n background: var(--uva-color-track, #e5e7eb);\n }\n .fill {\n background: var(--uva-color-accent-bg, var(--uva-brand-blue, #232d4b));\n border-color: var(--uva-color-text, #2b2b2b);\n transition: height 0.2s ease;\n }\n .bar[aria-pressed='true']::after {\n box-shadow: inset 0 0 0 3px var(--uva-color-text, #2b2b2b);\n background-image: repeating-linear-gradient(\n -45deg,\n transparent,\n transparent 3px,\n var(--uva-color-on-accent, #fff) 3px,\n var(--uva-color-on-accent, #fff) 4px\n );\n }\n .strip-bar { background: var(--uva-color-accent-bg, var(--uva-brand-blue, #232d4b)); border-color: var(--uva-color-text, #2b2b2b); }\n .strip-bar.is-selected {\n box-shadow: inset 0 0 0 2px var(--uva-color-text, #2b2b2b);\n background-image: repeating-linear-gradient(-45deg, transparent, transparent 2px, var(--uva-color-on-accent, #fff) 2px, var(--uva-color-on-accent, #fff) 3px);\n }\n .chip {\n background: var(--uva-color-surface-raised, #fff);\n color: var(--uva-color-text, #2b2b2b);\n border-color: var(--uva-color-control-border, #808080);\n }\n .chip[aria-pressed='true'] { box-shadow: inset 0 0 0 2px var(--uva-color-text, #2b2b2b); }\n .scroll-hint { color: var(--uva-color-text-muted, #4b5563); }\n .empty { margin: 0; color: var(--uva-color-text-muted, #4b5563); }\n th, td { border-color: var(--uva-color-control-border, #808080); color: var(--uva-color-text, #2b2b2b); }\n caption { color: var(--uva-color-text, #2b2b2b); }\n @media (prefers-reduced-motion: reduce) {\n .fill { transition: none; }\n }\n ")
|
|
414
|
+
];
|
|
415
|
+
}
|
|
416
|
+
constructor() {
|
|
417
|
+
super(), this.items = [], this.granularity = "month", this.scale = "linear", this.selected = "", this.rangeFor = "", this.variant = "", this.unit = "items", this.label = "Dates", this.tableItems = [], this.authorTable = !1, this.overflowing = !1, this.activeKey = "", this.uid = `uvalib-date-histogram-${++g}`, this.tableKey = "", this.warnedGrain = !1, this.partner = null, this.echo = !1, this.seen = !1, this.choosing = !1, this.onPartner = (e) => {
|
|
418
|
+
this.applyPartnerValue(e.detail?.value);
|
|
419
|
+
}, new d(this, () => this.lightDom, (e) => this.readTable(e));
|
|
420
|
+
}
|
|
421
|
+
createRenderRoot() {
|
|
422
|
+
let e = super.createRenderRoot();
|
|
423
|
+
if (e instanceof ShadowRoot && this.noStyle) {
|
|
424
|
+
let t = I.styleSheet;
|
|
425
|
+
t && (e.adoptedStyleSheets = [t]);
|
|
426
|
+
}
|
|
427
|
+
return e;
|
|
428
|
+
}
|
|
429
|
+
connectedCallback() {
|
|
430
|
+
if (super.connectedCallback(), this.lightDom && this.noStyle) {
|
|
431
|
+
let e = this.getRootNode();
|
|
432
|
+
s(`${this.localName}::structure`, o(F(this.localName)), {
|
|
433
|
+
root: e instanceof ShadowRoot || e instanceof Document ? e : void 0,
|
|
434
|
+
scope: !1
|
|
435
|
+
});
|
|
436
|
+
}
|
|
437
|
+
this.bindPartner(), this.measureOverflow(), customElements.get("uvalib-date-range") || customElements.whenDefined("uvalib-date-range").then(() => {
|
|
438
|
+
this.isConnected && !this.selected && (this.bindPartner(), this.pullPartner());
|
|
439
|
+
});
|
|
440
|
+
}
|
|
441
|
+
disconnectedCallback() {
|
|
442
|
+
super.disconnectedCallback(), this.partner?.removeEventListener("date-range-change", this.onPartner), this.partner = null, this.ro?.disconnect(), this.ro = void 0, this.observed = void 0, this.partnerObserver?.disconnect(), this.partnerObserver = void 0, this.seen = !1;
|
|
443
|
+
}
|
|
444
|
+
willUpdate(e) {
|
|
445
|
+
!this.warnedGrain && e.has("granularity") && this.granularity !== "year" && this.granularity !== "month" && (this.warnedGrain = !0, console.warn(`<${p}>: granularity must be "year" or "month"; using "month".`)), e.has("selected") && !this.choosing && (this.activeKey = ""), this.choosing = !1;
|
|
446
|
+
}
|
|
447
|
+
updated(e) {
|
|
448
|
+
let t = this.echo;
|
|
449
|
+
this.echo = !1;
|
|
450
|
+
let n = this.partner;
|
|
451
|
+
this.bindPartner();
|
|
452
|
+
let r = this.partner != null && this.partner !== n;
|
|
453
|
+
!this.seen || e.has("rangeFor") || r ? (this.seen = !0, this.selected ? this.pushPartner() : t || this.pullPartner()) : e.has("selected") && !t && this.pushPartner(), this.watchForPartner(), this.measureOverflow();
|
|
454
|
+
}
|
|
455
|
+
get grain() {
|
|
456
|
+
return this.granularity === "year" ? "year" : "month";
|
|
457
|
+
}
|
|
458
|
+
get strip() {
|
|
459
|
+
return this.variant === "strip";
|
|
460
|
+
}
|
|
461
|
+
get log() {
|
|
462
|
+
return this.scale === "log";
|
|
463
|
+
}
|
|
464
|
+
get labelText() {
|
|
465
|
+
return this.label.trim() || "Dates";
|
|
466
|
+
}
|
|
467
|
+
get data() {
|
|
468
|
+
return this.items.length ? this.items : this.tableItems;
|
|
469
|
+
}
|
|
470
|
+
readTable(e) {
|
|
471
|
+
let t = e.filter((e) => e instanceof HTMLTableElement), n = t.flatMap((e) => P(e)), r = JSON.stringify(n), i = t.length > 0;
|
|
472
|
+
(r !== this.tableKey || i !== this.authorTable) && (this.tableKey = r, this.tableItems = n, this.authorTable = i, this.hasUpdated && this.requestUpdate());
|
|
473
|
+
}
|
|
474
|
+
findPartner() {
|
|
475
|
+
let e = this.rangeFor.trim();
|
|
476
|
+
if (!e) return null;
|
|
477
|
+
let t = this.getRootNode(), n = (t instanceof Document || t instanceof ShadowRoot ? t.getElementById(e) : null) ?? this.ownerDocument.getElementById(e);
|
|
478
|
+
return !n || n.localName !== "uvalib-date-range" ? null : n;
|
|
479
|
+
}
|
|
480
|
+
bindPartner() {
|
|
481
|
+
let e = this.findPartner();
|
|
482
|
+
e !== this.partner && (this.partner?.removeEventListener("date-range-change", this.onPartner), this.partner = e, e?.addEventListener("date-range-change", this.onPartner));
|
|
483
|
+
}
|
|
484
|
+
watchForPartner() {
|
|
485
|
+
if (!this.isConnected || !this.rangeFor.trim() || this.partner) {
|
|
486
|
+
this.partnerObserver?.disconnect(), this.partnerObserver = void 0;
|
|
487
|
+
return;
|
|
488
|
+
}
|
|
489
|
+
if (this.partnerObserver) return;
|
|
490
|
+
let e = this.getRootNode();
|
|
491
|
+
(e instanceof Document || e instanceof ShadowRoot) && (this.partnerObserver = new MutationObserver(() => {
|
|
492
|
+
this.isConnected && !this.partner && (this.bindPartner(), this.partner && (this.partnerObserver?.disconnect(), this.partnerObserver = void 0, this.selected ? this.pushPartner() : this.pullPartner(), this.requestUpdate()));
|
|
493
|
+
}), this.partnerObserver.observe(e, {
|
|
494
|
+
childList: !0,
|
|
495
|
+
subtree: !0
|
|
496
|
+
}));
|
|
497
|
+
}
|
|
498
|
+
partnerEnds() {
|
|
499
|
+
let e = this.partner;
|
|
500
|
+
return e ? {
|
|
501
|
+
min: e.min || e.getAttribute("min") || "",
|
|
502
|
+
max: e.max || e.getAttribute("max") || ""
|
|
503
|
+
} : null;
|
|
504
|
+
}
|
|
505
|
+
isFullSpan(e, t) {
|
|
506
|
+
let n = this.partnerEnds();
|
|
507
|
+
return !n?.min || !n.max ? !1 : e === n.min && t === n.max;
|
|
508
|
+
}
|
|
509
|
+
applyPartnerValue(e) {
|
|
510
|
+
if (!Array.isArray(e) || e.length < 2) return;
|
|
511
|
+
let t = e[0] ?? "", n = e[1] ?? "";
|
|
512
|
+
if (this.isFullSpan(t, n)) {
|
|
513
|
+
this.selected &&= (this.echo = !0, "");
|
|
514
|
+
return;
|
|
515
|
+
}
|
|
516
|
+
let r = E(t, n, this.grain);
|
|
517
|
+
r && r !== this.selected && (this.echo = !0, this.selected = r);
|
|
518
|
+
}
|
|
519
|
+
pullPartner() {
|
|
520
|
+
this.applyPartnerValue(this.partner?.value);
|
|
521
|
+
}
|
|
522
|
+
pushPartner() {
|
|
523
|
+
let e = this.partner;
|
|
524
|
+
if (!e) return;
|
|
525
|
+
let t = this.selected ? w(this.selected) : null, n = null;
|
|
526
|
+
if (t && v(t.from) && v(t.to) ? n = [t.from, t.to] : !this.selected && v(e.min) && v(e.max) && (n = [e.min, e.max]), !n) return;
|
|
527
|
+
let r = e.value;
|
|
528
|
+
Array.isArray(r) && r[0] === n[0] && r[1] === n[1] || (e.value = n);
|
|
529
|
+
}
|
|
530
|
+
emit(e, t) {
|
|
531
|
+
if (this.dispatchEvent(new CustomEvent("select", {
|
|
532
|
+
detail: {
|
|
533
|
+
from: e,
|
|
534
|
+
to: t
|
|
535
|
+
},
|
|
536
|
+
bubbles: !0,
|
|
537
|
+
composed: !0
|
|
538
|
+
})), e && t) {
|
|
539
|
+
let n = v(e) && v(t) ? `${e}\u2013${t}` : "other";
|
|
540
|
+
u(this, [
|
|
541
|
+
p,
|
|
542
|
+
"select",
|
|
543
|
+
n
|
|
544
|
+
]);
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
choose(e) {
|
|
548
|
+
this.activeKey = e;
|
|
549
|
+
let t = this.selected.trim(), n = S(e);
|
|
550
|
+
if (t === e) {
|
|
551
|
+
let e = this.partner?.value;
|
|
552
|
+
if (n && Array.isArray(e) && e.length >= 2 && (e[0] !== n.from || e[1] !== n.to) && n) {
|
|
553
|
+
this.pushPartner(), this.emit(n.from, n.to);
|
|
554
|
+
return;
|
|
555
|
+
}
|
|
556
|
+
this.choosing = !0, this.selected = "", this.emit("", "");
|
|
557
|
+
return;
|
|
558
|
+
}
|
|
559
|
+
this.choosing = !0, this.selected = e;
|
|
560
|
+
let r = w(e);
|
|
561
|
+
this.emit(r?.from ?? e, r?.to ?? e);
|
|
562
|
+
}
|
|
563
|
+
onBarClick(e) {
|
|
564
|
+
let t = e.currentTarget.dataset.date ?? "";
|
|
565
|
+
t && this.choose(t);
|
|
566
|
+
}
|
|
567
|
+
onBarKeydown(e) {
|
|
568
|
+
let t = this.flatKeys(), n = t.indexOf(e.currentTarget.dataset.date ?? "");
|
|
569
|
+
if (n < 0) return;
|
|
570
|
+
let r = this.grain === "month" ? 12 : 1, i = -1;
|
|
571
|
+
switch (e.key) {
|
|
572
|
+
case "ArrowRight":
|
|
573
|
+
i = n + 1;
|
|
574
|
+
break;
|
|
575
|
+
case "ArrowLeft":
|
|
576
|
+
i = n - 1;
|
|
577
|
+
break;
|
|
578
|
+
case "ArrowDown":
|
|
579
|
+
i = n + r;
|
|
580
|
+
break;
|
|
581
|
+
case "ArrowUp":
|
|
582
|
+
i = n - r;
|
|
583
|
+
break;
|
|
584
|
+
case "Home":
|
|
585
|
+
i = 0;
|
|
586
|
+
break;
|
|
587
|
+
case "End":
|
|
588
|
+
i = t.length - 1;
|
|
589
|
+
break;
|
|
590
|
+
default: return;
|
|
591
|
+
}
|
|
592
|
+
e.preventDefault(), i < 0 || i >= t.length || i === n || (this.activeKey = t[i], this.updateComplete.then(() => this.focusBar(this.activeKey)));
|
|
593
|
+
}
|
|
594
|
+
flatKeys() {
|
|
595
|
+
return A(this.data, this.grain).bars.map((e) => e.key);
|
|
596
|
+
}
|
|
597
|
+
focusBar(e) {
|
|
598
|
+
let t = this.renderRoot.querySelector(`button.bar[data-date="${CSS.escape(e)}"]`);
|
|
599
|
+
if (!t) return;
|
|
600
|
+
t.focus();
|
|
601
|
+
let n = t.closest(".scroller");
|
|
602
|
+
if (!n) return;
|
|
603
|
+
let r = t.getBoundingClientRect(), i = n.getBoundingClientRect(), a = t.closest(".year")?.querySelector(".year-label")?.getBoundingClientRect().right, o = a == null ? i.left : a + 5;
|
|
604
|
+
r.right > i.right ? n.scrollLeft += r.right - i.right : r.left < o && (n.scrollLeft -= o - r.left);
|
|
605
|
+
}
|
|
606
|
+
measureOverflow() {
|
|
607
|
+
let e = this.renderRoot.querySelector(".scroller");
|
|
608
|
+
if (!(e instanceof HTMLElement)) {
|
|
609
|
+
this.overflowing &&= !1;
|
|
610
|
+
return;
|
|
611
|
+
}
|
|
612
|
+
typeof ResizeObserver < "u" && (this.ro ??= new ResizeObserver(() => this.measureOverflow()), this.observed !== e && (this.ro.disconnect(), this.ro.observe(e), this.observed = e));
|
|
613
|
+
let t = e.scrollWidth > e.clientWidth + 1;
|
|
614
|
+
t !== this.overflowing && (this.overflowing = t);
|
|
615
|
+
}
|
|
616
|
+
selectionHighlights() {
|
|
617
|
+
let e = this.selected.trim();
|
|
618
|
+
if (!e) return !1;
|
|
619
|
+
let t = C(e);
|
|
620
|
+
return t.length >= 2 && t.every((e) => S(e) !== null) ? !0 : t.length === 1 ? this.grain === "year" ? /^\d{4}$/.test(e) : /^\d{4}-\d{2}$/.test(e) : !1;
|
|
621
|
+
}
|
|
622
|
+
overlaps(e, t) {
|
|
623
|
+
if (!t || !v(t.from) || !v(t.to)) return !1;
|
|
624
|
+
let n = S(e);
|
|
625
|
+
return n ? n.from <= t.to && n.to >= t.from : !1;
|
|
626
|
+
}
|
|
627
|
+
pressed(e, t) {
|
|
628
|
+
return this.selected.trim() === e ? !0 : this.selectionHighlights() ? this.overlaps(e, t) : !1;
|
|
629
|
+
}
|
|
630
|
+
chipOn(e, t) {
|
|
631
|
+
if (this.selected.trim() === e) return !0;
|
|
632
|
+
if (!v(e)) return !1;
|
|
633
|
+
let n = C(this.selected.trim());
|
|
634
|
+
return n.length < 2 || n.some((e) => S(e) === null) ? !1 : this.overlaps(e, t);
|
|
635
|
+
}
|
|
636
|
+
focusKey(e) {
|
|
637
|
+
let t = e.map((e) => e.key);
|
|
638
|
+
if (this.activeKey && t.includes(this.activeKey)) return this.activeKey;
|
|
639
|
+
let n = w(this.selected);
|
|
640
|
+
return e.find((e) => this.pressed(e.key, n))?.key ?? t[0] ?? "";
|
|
641
|
+
}
|
|
642
|
+
barTemplate(e, t, r) {
|
|
643
|
+
let i = j(e.count, A(this.data, this.grain).max, this.log), a = this.pressed(e.key, r);
|
|
644
|
+
return n`
|
|
645
|
+
<button
|
|
646
|
+
type="button"
|
|
647
|
+
class="bar ${e.count ? "" : "is-empty"}"
|
|
648
|
+
part="bar"
|
|
649
|
+
data-date=${e.key}
|
|
650
|
+
tabindex=${e.key === t ? "0" : "-1"}
|
|
651
|
+
aria-pressed=${a ? "true" : "false"}
|
|
652
|
+
aria-label=${O(e.key, e.count, this.unit)}
|
|
653
|
+
@click=${this.onBarClick}
|
|
654
|
+
@keydown=${this.onBarKeydown}
|
|
655
|
+
>
|
|
656
|
+
<span class="fill" aria-hidden="true" style="height: ${i}%"></span>
|
|
657
|
+
</button>
|
|
658
|
+
`;
|
|
659
|
+
}
|
|
660
|
+
renderBars(e, t) {
|
|
661
|
+
let r = this.focusKey(e.bars);
|
|
662
|
+
if (this.grain === "year") return n`
|
|
663
|
+
<div class="scroller" role="group" aria-label=${this.labelText}>
|
|
664
|
+
<div class="bars">
|
|
665
|
+
${l(e.bars, (e) => e.key, (e) => this.barTemplate(e, r, t))}
|
|
666
|
+
</div>
|
|
667
|
+
</div>
|
|
668
|
+
`;
|
|
669
|
+
let i = [...new Set(e.bars.map((e) => e.year))];
|
|
670
|
+
return n`
|
|
671
|
+
<div class="scroller" role="group" aria-label=${this.labelText}>
|
|
672
|
+
${i.map((i) => n`
|
|
673
|
+
<div class="year">
|
|
674
|
+
<span class="year-label" id=${`${this.uid}-${i}`}>${i}</span>
|
|
675
|
+
<div class="bars" role="group" aria-labelledby=${`${this.uid}-${i}`}>
|
|
676
|
+
${l(e.bars.filter((e) => e.year === i), (e) => e.key, (e) => this.barTemplate(e, r, t))}
|
|
677
|
+
</div>
|
|
678
|
+
</div>
|
|
679
|
+
`)}
|
|
680
|
+
</div>
|
|
681
|
+
`;
|
|
682
|
+
}
|
|
683
|
+
renderOdds(e, t) {
|
|
684
|
+
return e.length ? n`
|
|
685
|
+
<div class="outliers" role="group" aria-label="Other dates">
|
|
686
|
+
${e.map((e) => {
|
|
687
|
+
let r = O(e.key, e.count, this.unit), i = this.chipOn(e.key, t);
|
|
688
|
+
return n`
|
|
689
|
+
<button
|
|
690
|
+
type="button"
|
|
691
|
+
class="chip"
|
|
692
|
+
data-date=${e.key}
|
|
693
|
+
aria-pressed=${i ? "true" : "false"}
|
|
694
|
+
@click=${this.onBarClick}
|
|
695
|
+
>
|
|
696
|
+
${r}
|
|
697
|
+
</button>
|
|
698
|
+
`;
|
|
699
|
+
})}
|
|
700
|
+
</div>
|
|
701
|
+
` : a;
|
|
702
|
+
}
|
|
703
|
+
generatedTable(e) {
|
|
704
|
+
let t = this.labelText;
|
|
705
|
+
if (this.grain === "month" && e.bars.length) {
|
|
706
|
+
let r = [...new Set(e.bars.map((e) => e.year))];
|
|
707
|
+
return n`
|
|
708
|
+
<table part="table">
|
|
709
|
+
${L(t)}
|
|
710
|
+
<thead>
|
|
711
|
+
<tr>
|
|
712
|
+
<th scope="col">Year</th>
|
|
713
|
+
${h.map((e) => n`<th scope="col">${e}</th>`)}
|
|
714
|
+
<th scope="col">Total</th>
|
|
715
|
+
</tr>
|
|
716
|
+
</thead>
|
|
717
|
+
<tbody>
|
|
718
|
+
${r.map((t) => {
|
|
719
|
+
let r = e.bars.filter((e) => e.year === t), i = r.reduce((e, t) => e + t.count, 0);
|
|
720
|
+
return n`
|
|
721
|
+
<tr>
|
|
722
|
+
<th scope="row">${t}</th>
|
|
723
|
+
${r.map((e) => n`<td>${e.count.toLocaleString("en-US")}</td>`)}
|
|
724
|
+
<td>${i.toLocaleString("en-US")}</td>
|
|
725
|
+
</tr>
|
|
726
|
+
`;
|
|
727
|
+
})}
|
|
728
|
+
</tbody>
|
|
729
|
+
</table>
|
|
730
|
+
${this.oddsTable(e)}
|
|
731
|
+
`;
|
|
732
|
+
}
|
|
733
|
+
return n`
|
|
734
|
+
<table part="table">
|
|
735
|
+
${L(t)}
|
|
736
|
+
<thead>
|
|
737
|
+
<tr>
|
|
738
|
+
<th scope="col">${this.grain === "year" ? "Year" : "Date"}</th>
|
|
739
|
+
<th scope="col">Count</th>
|
|
740
|
+
</tr>
|
|
741
|
+
</thead>
|
|
742
|
+
<tbody>
|
|
743
|
+
${e.bars.map((e) => n`
|
|
744
|
+
<tr>
|
|
745
|
+
<th scope="row">${e.key}</th>
|
|
746
|
+
<td>${e.count.toLocaleString("en-US")}</td>
|
|
747
|
+
</tr>
|
|
748
|
+
`)}
|
|
749
|
+
${e.odds.map((e) => n`
|
|
750
|
+
<tr>
|
|
751
|
+
<th scope="row">${e.key}</th>
|
|
752
|
+
<td>${e.count.toLocaleString("en-US")}</td>
|
|
753
|
+
</tr>
|
|
754
|
+
`)}
|
|
755
|
+
</tbody>
|
|
756
|
+
</table>
|
|
757
|
+
`;
|
|
758
|
+
}
|
|
759
|
+
oddsTable(e) {
|
|
760
|
+
return e.odds.length ? n`
|
|
761
|
+
<table part="table">
|
|
762
|
+
${L("Other dates")}
|
|
763
|
+
<thead>
|
|
764
|
+
<tr>
|
|
765
|
+
<th scope="col">Date</th>
|
|
766
|
+
<th scope="col">Count</th>
|
|
767
|
+
</tr>
|
|
768
|
+
</thead>
|
|
769
|
+
<tbody>
|
|
770
|
+
${e.odds.map((e) => n`
|
|
771
|
+
<tr>
|
|
772
|
+
<th scope="row">${e.key}</th>
|
|
773
|
+
<td>${e.count.toLocaleString("en-US")}</td>
|
|
774
|
+
</tr>
|
|
775
|
+
`)}
|
|
776
|
+
</tbody>
|
|
777
|
+
</table>
|
|
778
|
+
` : a;
|
|
779
|
+
}
|
|
780
|
+
renderDisclosure(e) {
|
|
781
|
+
if (!this.authorTable && !e.bars.length && !e.odds.length) return a;
|
|
782
|
+
let t = this.lightDom || !this.authorTable || this.items.length > 0;
|
|
783
|
+
return n`
|
|
784
|
+
<details class="as-table">
|
|
785
|
+
<summary>Show as table</summary>
|
|
786
|
+
<div
|
|
787
|
+
class="table-wrap"
|
|
788
|
+
role="region"
|
|
789
|
+
tabindex="0"
|
|
790
|
+
aria-label="${this.labelText} as a table"
|
|
791
|
+
>
|
|
792
|
+
${t ? this.generatedTable(e) : a}
|
|
793
|
+
${t || this.lightDom ? a : n`<slot></slot>`}
|
|
794
|
+
</div>
|
|
795
|
+
</details>
|
|
796
|
+
`;
|
|
797
|
+
}
|
|
798
|
+
reserveStyle() {
|
|
799
|
+
let e = "var(--uvalib-date-histogram-bar-size, 8rem)";
|
|
800
|
+
return this.grain === "year" ? `min-block-size: ${e}` : `min-block-size: calc(${this.reservedYears()} * (${e} + 0.5rem))`;
|
|
801
|
+
}
|
|
802
|
+
reservedYears() {
|
|
803
|
+
let e = A(this.data, this.grain);
|
|
804
|
+
if (e.bars.length) return new Set(e.bars.map((e) => e.year)).size;
|
|
805
|
+
let t = this.partner ?? this.findPartner();
|
|
806
|
+
if (!t) return 1;
|
|
807
|
+
let n = T(t.min || t.getAttribute("min") || "", t.max || t.getAttribute("max") || "");
|
|
808
|
+
return n && n > 0 ? n : 1;
|
|
809
|
+
}
|
|
810
|
+
renderStrip(e) {
|
|
811
|
+
let t = e.bars, r = t.reduce((e, t) => e + t.count, 0), i = w(this.selected), a = t.length === 0 ? "" : t[0].year === t[t.length - 1].year ? String(t[0].year) : `${t[0].year} to ${t[t.length - 1].year}`, o = t.length ? `${this.labelText}: ${a}, ${r.toLocaleString("en-US")} ${D(r, this.unit)}` : `${this.labelText}: no dates`;
|
|
812
|
+
if (i && t.some((e) => this.pressed(e.key, i))) {
|
|
813
|
+
let e = t.filter((e) => this.pressed(e.key, i)), n = e[0].year, r = e[e.length - 1].year;
|
|
814
|
+
o += n === r ? `. Selected ${n}.` : `. Selected ${n} to ${r}.`;
|
|
815
|
+
}
|
|
816
|
+
return n`
|
|
817
|
+
<div class="strip" part="chart" role="img" aria-label=${o}>
|
|
818
|
+
${t.map((t) => {
|
|
819
|
+
let r = j(t.count, e.max, this.log), a = this.pressed(t.key, i);
|
|
820
|
+
return n`<span
|
|
821
|
+
class="strip-bar ${t.count ? "" : "is-empty"} ${a ? "is-selected" : ""}"
|
|
822
|
+
part="bar"
|
|
823
|
+
style="height: ${r}%"
|
|
824
|
+
></span>`;
|
|
825
|
+
})}
|
|
826
|
+
</div>
|
|
827
|
+
`;
|
|
828
|
+
}
|
|
829
|
+
render() {
|
|
830
|
+
let e = A(this.data, this.strip ? "year" : this.grain);
|
|
831
|
+
if (this.strip) return this.renderStrip(e);
|
|
832
|
+
let t = w(this.selected), r = this.grain === "year" ? "by-year" : "by-month";
|
|
833
|
+
return n`
|
|
834
|
+
<div class="chart ${r}" part="chart">
|
|
835
|
+
<p class="scroll-hint" ?hidden=${!this.overflowing}>Scroll sideways to see more.</p>
|
|
836
|
+
<div class="plot" style=${this.reserveStyle()}>
|
|
837
|
+
${e.bars.length ? this.renderBars(e, t) : n`<p class="empty">No dates to show.</p>`}
|
|
838
|
+
</div>
|
|
839
|
+
</div>
|
|
840
|
+
${this.renderOdds(e.odds, t)} ${this.renderDisclosure(e)}
|
|
841
|
+
`;
|
|
842
|
+
}
|
|
843
|
+
};
|
|
844
|
+
// src/components/uvalib-date-histogram/uvalib-date-histogram.ts
|
|
845
|
+
i([e({ type: Array })], R.prototype, "items", void 0), i([e({ type: String })], R.prototype, "granularity", void 0), i([e({ type: String })], R.prototype, "scale", void 0), i([e({ type: String })], R.prototype, "selected", void 0), i([e({
|
|
846
|
+
type: String,
|
|
847
|
+
attribute: "range-for"
|
|
848
|
+
})], R.prototype, "rangeFor", void 0), i([e({ type: String })], R.prototype, "variant", void 0), i([e({ type: String })], R.prototype, "unit", void 0), i([e({ type: String })], R.prototype, "label", void 0), i([t()], R.prototype, "tableItems", void 0), i([t()], R.prototype, "authorTable", void 0), i([t()], R.prototype, "overflowing", void 0), i([t()], R.prototype, "activeKey", void 0), r("uvalib-date-histogram", R);
|
|
849
|
+
|
|
850
|
+
//# sourceMappingURL=uvalib-date-histogram.js.map
|