@uvalib/web-components 1.2.0 → 1.3.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 +87 -0
- package/README.md +808 -46
- package/dist/analytics.d.ts +10 -0
- package/dist/analytics.js +9 -0
- package/dist/analytics.js.map +1 -0
- package/dist/base/UvalibElement.js +8 -5
- package/dist/base/UvalibElement.js.map +1 -1
- package/dist/base/analytics-state.d.ts +7 -0
- package/dist/base/analytics-state.js.map +1 -1
- package/dist/base/light-dom-styles.d.ts +13 -0
- package/dist/base/light-dom-styles.js +26 -0
- package/dist/base/light-dom-styles.js.map +1 -1
- package/dist/base/search-tracker.d.ts +57 -0
- package/dist/base/search-tracker.js +51 -0
- package/dist/base/search-tracker.js.map +1 -0
- package/dist/base.css +286 -14
- package/dist/base.d.ts +2 -0
- package/dist/base.js +1 -0
- package/dist/base.js.map +1 -1
- package/dist/components/site-analytics/SiteAnalytics.d.ts +20 -1
- package/dist/components/site-analytics/SiteAnalytics.js +93 -12
- package/dist/components/site-analytics/SiteAnalytics.js.map +1 -1
- package/dist/components/site-page/SitePage.d.ts +23 -0
- package/dist/components/site-page/SitePage.js +77 -0
- package/dist/components/site-page/SitePage.js.map +1 -1
- package/dist/components/uvalib-back-to-top/UvalibBackToTop.d.ts +58 -0
- package/dist/components/uvalib-back-to-top/UvalibBackToTop.js +250 -0
- package/dist/components/uvalib-back-to-top/UvalibBackToTop.js.map +1 -0
- package/dist/components/uvalib-back-to-top/uvalib-back-to-top.d.ts +1 -0
- package/dist/components/uvalib-back-to-top/uvalib-back-to-top.js +4 -0
- package/dist/components/uvalib-back-to-top/uvalib-back-to-top.js.map +1 -0
- package/dist/components/uvalib-breadcrumbs/UvalibBreadcrumbs.d.ts +14 -0
- package/dist/components/uvalib-breadcrumbs/UvalibBreadcrumbs.js +56 -4
- package/dist/components/uvalib-breadcrumbs/UvalibBreadcrumbs.js.map +1 -1
- package/dist/components/uvalib-chip-group/UvalibChipGroup.d.ts +25 -3
- package/dist/components/uvalib-chip-group/UvalibChipGroup.js +80 -10
- package/dist/components/uvalib-chip-group/UvalibChipGroup.js.map +1 -1
- package/dist/components/uvalib-combobox/UvalibCombobox.d.ts +212 -0
- package/dist/components/uvalib-combobox/UvalibCombobox.js +1088 -0
- package/dist/components/uvalib-combobox/UvalibCombobox.js.map +1 -0
- package/dist/components/uvalib-combobox/uvalib-combobox.d.ts +1 -0
- package/dist/components/uvalib-combobox/uvalib-combobox.js +4 -0
- package/dist/components/uvalib-combobox/uvalib-combobox.js.map +1 -0
- package/dist/components/uvalib-contents/UvalibContents.d.ts +53 -0
- package/dist/components/uvalib-contents/UvalibContents.js +202 -3
- package/dist/components/uvalib-contents/UvalibContents.js.map +1 -1
- package/dist/components/uvalib-date-histogram/UvalibDateHistogram.d.ts +56 -17
- package/dist/components/uvalib-date-histogram/UvalibDateHistogram.js +285 -81
- package/dist/components/uvalib-date-histogram/UvalibDateHistogram.js.map +1 -1
- package/dist/components/uvalib-date-range/UvalibDateRange.d.ts +6 -0
- package/dist/components/uvalib-date-range/UvalibDateRange.js +23 -0
- package/dist/components/uvalib-date-range/UvalibDateRange.js.map +1 -1
- package/dist/components/uvalib-filter-drawer/UvalibFilterDrawer.d.ts +113 -0
- package/dist/components/uvalib-filter-drawer/UvalibFilterDrawer.js +589 -0
- package/dist/components/uvalib-filter-drawer/UvalibFilterDrawer.js.map +1 -0
- package/dist/components/uvalib-filter-drawer/uvalib-filter-drawer.d.ts +1 -0
- package/dist/components/uvalib-filter-drawer/uvalib-filter-drawer.js +4 -0
- package/dist/components/uvalib-filter-drawer/uvalib-filter-drawer.js.map +1 -0
- package/dist/components/uvalib-image-regions/UvalibImageRegions.d.ts +130 -0
- package/dist/components/uvalib-image-regions/UvalibImageRegions.js +658 -0
- package/dist/components/uvalib-image-regions/UvalibImageRegions.js.map +1 -0
- package/dist/components/uvalib-image-regions/regions.d.ts +57 -0
- package/dist/components/uvalib-image-regions/regions.js +117 -0
- package/dist/components/uvalib-image-regions/regions.js.map +1 -0
- package/dist/components/uvalib-image-regions/uvalib-image-regions.d.ts +1 -0
- package/dist/components/uvalib-image-regions/uvalib-image-regions.js +4 -0
- package/dist/components/uvalib-image-regions/uvalib-image-regions.js.map +1 -0
- package/dist/components/uvalib-lightbox/UvalibLightbox.d.ts +40 -0
- package/dist/components/uvalib-lightbox/UvalibLightbox.js +144 -16
- package/dist/components/uvalib-lightbox/UvalibLightbox.js.map +1 -1
- package/dist/components/uvalib-map/UvalibMap.d.ts +182 -0
- package/dist/components/uvalib-map/UvalibMap.js +1001 -0
- package/dist/components/uvalib-map/UvalibMap.js.map +1 -0
- package/dist/components/uvalib-map/uvalib-map.d.ts +1 -0
- package/dist/components/uvalib-map/uvalib-map.js +4 -0
- package/dist/components/uvalib-map/uvalib-map.js.map +1 -0
- package/dist/components/uvalib-metadata/UvalibMetadata.d.ts +39 -2
- package/dist/components/uvalib-metadata/UvalibMetadata.js +214 -8
- package/dist/components/uvalib-metadata/UvalibMetadata.js.map +1 -1
- package/dist/components/uvalib-pager/UvalibPager.d.ts +22 -3
- package/dist/components/uvalib-pager/UvalibPager.js +42 -4
- package/dist/components/uvalib-pager/UvalibPager.js.map +1 -1
- package/dist/custom-elements.json +9253 -3253
- package/dist/index.d.ts +8 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/pagefind.css +4 -0
- package/dist/styles/base.js +119 -0
- package/dist/styles/base.js.map +1 -1
- package/dist/styles/color-scheme.js +5 -0
- package/dist/styles/color-scheme.js.map +1 -1
- package/dist/styles/controls.js +6 -0
- package/dist/styles/controls.js.map +1 -1
- package/dist/styles/hidden.d.ts +2 -0
- package/dist/styles/hidden.js +51 -0
- package/dist/styles/hidden.js.map +1 -0
- package/dist/styles/message.d.ts +1 -0
- package/dist/styles/message.js +82 -0
- package/dist/styles/message.js.map +1 -0
- package/dist/styles/pagefind.js +4 -0
- package/dist/styles/pagefind.js.map +1 -1
- package/dist/styles/result-list.d.ts +1 -0
- package/dist/styles/result-list.js +111 -0
- package/dist/styles/result-list.js.map +1 -0
- package/dist/styles/results.js +0 -15
- package/dist/styles/results.js.map +1 -1
- package/dist/testing/index.d.ts +110 -0
- package/dist/testing/index.js +100 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/testing/lighthouse-rules.d.ts +10 -0
- package/dist/testing/lighthouse-rules.js +44 -0
- package/dist/testing/lighthouse-rules.js.map +1 -0
- package/dist/tokens.css +5 -0
- package/dist-cdn/analytics.js +32 -0
- package/dist-cdn/analytics.js.map +1 -0
- package/dist-cdn/base.css +286 -14
- package/dist-cdn/bento-box.js +3 -3
- package/dist-cdn/chunks/{SiteAnalytics-Cm-FyhYS.js → SiteAnalytics-B9gu5aGO.js} +59 -30
- package/dist-cdn/chunks/SiteAnalytics-B9gu5aGO.js.map +1 -0
- package/dist-cdn/chunks/{UvalibElement-BnI-eRRR.js → UvalibElement-pGONDAwB.js} +108 -101
- package/dist-cdn/chunks/UvalibElement-pGONDAwB.js.map +1 -0
- package/dist-cdn/chunks/{accessible-GqhVn5_H.js → accessible-DJv7YOtS.js} +2 -2
- package/dist-cdn/chunks/{accessible-GqhVn5_H.js.map → accessible-DJv7YOtS.js.map} +1 -1
- package/dist-cdn/chunks/analytics-state-Ce8DKe4F.js.map +1 -1
- package/dist-cdn/chunks/{base-p5pk0vb2.js → base-BI8h0Gf3.js} +121 -2
- package/dist-cdn/chunks/base-BI8h0Gf3.js.map +1 -0
- package/dist-cdn/chunks/{library-weekly-hours-COE7Vv6V.js → library-weekly-hours-CrV3TlP5.js} +3 -3
- package/dist-cdn/chunks/{library-weekly-hours-COE7Vv6V.js.map → library-weekly-hours-CrV3TlP5.js.map} +1 -1
- package/dist-cdn/chunks/regions-B8ExwUGP.js +86 -0
- package/dist-cdn/chunks/regions-B8ExwUGP.js.map +1 -0
- package/dist-cdn/chunks/{repeat-CIFUYkyh.js → repeat-m5Zd_QeP.js} +2 -2
- package/dist-cdn/chunks/{repeat-CIFUYkyh.js.map → repeat-m5Zd_QeP.js.map} +1 -1
- package/dist-cdn/chunks/{site-header-BlOYvQg1.js → site-header-DYRMpdBj.js} +9 -4
- package/dist-cdn/chunks/{site-header-BlOYvQg1.js.map → site-header-DYRMpdBj.js.map} +1 -1
- package/dist-cdn/chunks/{site-main-nav-AaxZ9rQf.js → site-main-nav-DURrQMal.js} +3 -3
- package/dist-cdn/chunks/{site-main-nav-AaxZ9rQf.js.map → site-main-nav-DURrQMal.js.map} +1 -1
- package/dist-cdn/chunks/{static-html-1mTAG6nS.js → static-html-C1rhtCHu.js} +2 -2
- package/dist-cdn/chunks/{static-html-1mTAG6nS.js.map → static-html-C1rhtCHu.js.map} +1 -1
- package/dist-cdn/custom-elements.json +9253 -3253
- package/dist-cdn/events-section.js +3 -3
- package/dist-cdn/library-hours-setup.js +2 -2
- package/dist-cdn/library-weekly-hours.js +1 -1
- package/dist-cdn/manifest.json +10 -2
- package/dist-cdn/pagefind.css +4 -0
- package/dist-cdn/site-alerts.js +4 -4
- package/dist-cdn/site-analytics.js +2 -2
- package/dist-cdn/site-footer.js +2 -2
- package/dist-cdn/site-header.js +1 -1
- package/dist-cdn/site-hours-section.js +4 -4
- package/dist-cdn/site-main-nav.js +1 -1
- package/dist-cdn/site-page.js +56 -11
- package/dist-cdn/site-page.js.map +1 -1
- package/dist-cdn/site-style.js +2 -2
- package/dist-cdn/skills/uvalib-web-components/SKILL.md +98 -13
- package/dist-cdn/skills/uvalib-web-components/reference/accessibility-testing.md +34 -2
- package/dist-cdn/skills/uvalib-web-components/reference/components.md +300 -13
- package/dist-cdn/skills/uvalib-web-components/reference/snippets.md +1 -1
- package/dist-cdn/tokens.css +5 -0
- package/dist-cdn/uvalib-analytics.js +2 -2
- package/dist-cdn/uvalib-back-to-top.js +156 -0
- package/dist-cdn/uvalib-back-to-top.js.map +1 -0
- package/dist-cdn/uvalib-breadcrumbs.js +31 -11
- package/dist-cdn/uvalib-breadcrumbs.js.map +1 -1
- package/dist-cdn/uvalib-card-grid.js +1 -1
- package/dist-cdn/uvalib-card.js +3 -3
- package/dist-cdn/uvalib-chip-group.js +53 -14
- package/dist-cdn/uvalib-chip-group.js.map +1 -1
- package/dist-cdn/uvalib-combobox.js +667 -0
- package/dist-cdn/uvalib-combobox.js.map +1 -0
- package/dist-cdn/uvalib-contents.js +100 -22
- package/dist-cdn/uvalib-contents.js.map +1 -1
- package/dist-cdn/uvalib-date-histogram.js +237 -127
- package/dist-cdn/uvalib-date-histogram.js.map +1 -1
- package/dist-cdn/uvalib-date-range.js +14 -2
- package/dist-cdn/uvalib-date-range.js.map +1 -1
- package/dist-cdn/uvalib-filter-drawer.js +355 -0
- package/dist-cdn/uvalib-filter-drawer.js.map +1 -0
- package/dist-cdn/uvalib-filter.js +3 -3
- package/dist-cdn/uvalib-image-regions.js +447 -0
- package/dist-cdn/uvalib-image-regions.js.map +1 -0
- package/dist-cdn/uvalib-lightbox.js +144 -55
- package/dist-cdn/uvalib-lightbox.js.map +1 -1
- package/dist-cdn/uvalib-map.js +471 -0
- package/dist-cdn/uvalib-map.js.map +1 -0
- package/dist-cdn/uvalib-metadata.js +150 -24
- package/dist-cdn/uvalib-metadata.js.map +1 -1
- package/dist-cdn/uvalib-pager.js +29 -17
- package/dist-cdn/uvalib-pager.js.map +1 -1
- package/dist-cdn/uvalib-photo-grid.js +2 -2
- package/dist-cdn/uvalib-results-count.js +2 -2
- package/dist-cdn/uvalib-tabs.js +2 -2
- package/dist-cdn/uvalib-tag-list.js +2 -2
- package/package.json +43 -1
- package/skills/uvalib-web-components/SKILL.md +98 -13
- package/skills/uvalib-web-components/reference/accessibility-testing.md +34 -2
- package/skills/uvalib-web-components/reference/components.md +300 -13
- package/skills/uvalib-web-components/reference/snippets.md +1 -1
- package/dist-cdn/chunks/SiteAnalytics-Cm-FyhYS.js.map +0 -1
- package/dist-cdn/chunks/UvalibElement-BnI-eRRR.js.map +0 -1
- package/dist-cdn/chunks/base-p5pk0vb2.js.map +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
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-
|
|
2
|
-
import { t as l } from "./chunks/repeat-
|
|
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-pGONDAwB.js";
|
|
2
|
+
import { t as l } from "./chunks/repeat-m5Zd_QeP.js";
|
|
3
3
|
import { a as u } from "./chunks/analytics-DTTihuBD.js";
|
|
4
4
|
import { t as d } from "./chunks/source-children-BHsDwCvL.js";
|
|
5
|
-
import { t as f } from "./chunks/accessible-
|
|
5
|
+
import { t as f } from "./chunks/accessible-DJv7YOtS.js";
|
|
6
6
|
// src/components/uvalib-date-histogram/UvalibDateHistogram.ts
|
|
7
7
|
var p = "uvalib-date-histogram", m = [
|
|
8
8
|
"January",
|
|
@@ -40,9 +40,19 @@ function b(e) {
|
|
|
40
40
|
let i = Number(t);
|
|
41
41
|
return Number.isInteger(i) && i >= 1 && i <= 12 ? i : 0;
|
|
42
42
|
}
|
|
43
|
-
|
|
43
|
+
var x = /^(\d{3}0)s$/, S = (e) => `${String(Math.floor(e / 10) * 10).padStart(4, "0")}s`;
|
|
44
|
+
function C(e) {
|
|
45
|
+
let t = Number(e.slice(0, 4));
|
|
46
|
+
return `${e.slice(0, 4)}/${String(t + 9).padStart(4, "0")}`;
|
|
47
|
+
}
|
|
48
|
+
var w = 3, T = 30;
|
|
49
|
+
function E(e) {
|
|
44
50
|
let t = e.replace(/\s+/g, " ").trim();
|
|
45
51
|
if (!t) return null;
|
|
52
|
+
if (x.test(t)) return {
|
|
53
|
+
key: t,
|
|
54
|
+
kind: "decade"
|
|
55
|
+
};
|
|
46
56
|
if (_.test(t)) return {
|
|
47
57
|
key: (v(t), t),
|
|
48
58
|
kind: "odd"
|
|
@@ -75,44 +85,55 @@ function x(e) {
|
|
|
75
85
|
kind: "odd"
|
|
76
86
|
};
|
|
77
87
|
}
|
|
78
|
-
function
|
|
88
|
+
function D(e) {
|
|
79
89
|
if (v(e)) return {
|
|
80
90
|
from: e,
|
|
81
91
|
to: e
|
|
82
92
|
};
|
|
83
93
|
let t = /^(\d{4})-(\d{2})$/.exec(e);
|
|
84
|
-
|
|
94
|
+
if (t && Number(t[2]) >= 1 && Number(t[2]) <= 12) return {
|
|
85
95
|
from: `${e}-01`,
|
|
86
96
|
to: y(Number(t[1]), Number(t[2]))
|
|
87
|
-
}
|
|
97
|
+
};
|
|
98
|
+
if (/^\d{4}$/.test(e)) return {
|
|
88
99
|
from: `${e}-01-01`,
|
|
89
100
|
to: `${e}-12-31`
|
|
90
|
-
}
|
|
101
|
+
};
|
|
102
|
+
let n = x.exec(e);
|
|
103
|
+
if (n) {
|
|
104
|
+
let e = String(Number(n[1]) + 9).padStart(4, "0");
|
|
105
|
+
return {
|
|
106
|
+
from: `${n[1]}-01-01`,
|
|
107
|
+
to: `${e}-12-31`
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
return null;
|
|
91
111
|
}
|
|
92
|
-
function
|
|
112
|
+
function O(e) {
|
|
93
113
|
return e.trim().split(/\s*(?:\.\.|\/|\u2013|\u2014)\s*/).filter(Boolean);
|
|
94
114
|
}
|
|
95
|
-
function
|
|
115
|
+
function k(e) {
|
|
96
116
|
let t = e.trim();
|
|
97
117
|
if (!t) return null;
|
|
98
|
-
let n =
|
|
99
|
-
if (n.length >= 2 && n.every((e) =>
|
|
100
|
-
let e = n.map((e) =>
|
|
118
|
+
let n = O(t);
|
|
119
|
+
if (n.length >= 2 && n.every((e) => D(e) !== null)) {
|
|
120
|
+
let e = n.map((e) => D(e));
|
|
101
121
|
return {
|
|
102
122
|
from: e.reduce((e, t) => t.from < e ? t.from : e, e[0].from),
|
|
103
123
|
to: e.reduce((e, t) => t.to > e ? t.to : e, e[0].to)
|
|
104
124
|
};
|
|
105
125
|
}
|
|
106
|
-
return
|
|
126
|
+
return D(t) ?? {
|
|
107
127
|
from: t,
|
|
108
128
|
to: t
|
|
109
129
|
};
|
|
110
130
|
}
|
|
111
|
-
|
|
131
|
+
var A = (e) => Math.floor(e / 50) * 50;
|
|
132
|
+
function j(e, t) {
|
|
112
133
|
let n = /^(\d{4})/.exec(e.trim()), r = /^(\d{4})/.exec(t.trim());
|
|
113
134
|
return !n || !r ? null : Math.abs(Number(r[1]) - Number(n[1])) + 1;
|
|
114
135
|
}
|
|
115
|
-
function
|
|
136
|
+
function M(e, t, n) {
|
|
116
137
|
if (!v(e) || !v(t)) return "";
|
|
117
138
|
let [r, i] = e <= t ? [e, t] : [t, e];
|
|
118
139
|
if (n === "year") {
|
|
@@ -122,38 +143,62 @@ function E(e, t, n) {
|
|
|
122
143
|
let a = r.slice(0, 7), o = i.slice(0, 7);
|
|
123
144
|
return a === o ? a : `${a}/${o}`;
|
|
124
145
|
}
|
|
125
|
-
function
|
|
146
|
+
function N(e, t) {
|
|
126
147
|
let n = t.trim() || "items";
|
|
127
148
|
return e === 1 && /[^s]s$/i.test(n) && !/ies$/i.test(n) ? n.slice(0, -1) : n;
|
|
128
149
|
}
|
|
129
|
-
function
|
|
130
|
-
let r = t.toLocaleString("en-US"), i =
|
|
150
|
+
function P(e, t, n) {
|
|
151
|
+
let r = t.toLocaleString("en-US"), i = N(t, n), a = /^(\d{4})-(\d{2})$/.exec(e);
|
|
131
152
|
if (a) return `${m[Number(a[2]) - 1]} ${a[1]}: ${r} ${i}`;
|
|
132
153
|
let o = /^(\d{4})-(\d{2})-(\d{2})$/.exec(e);
|
|
133
154
|
return o && v(e) ? `${Number(o[3])} ${m[Number(o[2]) - 1]} ${o[1]}: ${r} ${i}` : `${e}: ${r} ${i}`;
|
|
134
155
|
}
|
|
135
|
-
function
|
|
156
|
+
function F(e, t, n) {
|
|
136
157
|
e.set(t, (e.get(t) ?? 0) + n);
|
|
137
158
|
}
|
|
138
|
-
function
|
|
139
|
-
let
|
|
140
|
-
for (let
|
|
141
|
-
if (!
|
|
142
|
-
let e = typeof
|
|
159
|
+
function I(e) {
|
|
160
|
+
let t = [];
|
|
161
|
+
for (let n of e) {
|
|
162
|
+
if (!n || typeof n.date != "string") continue;
|
|
163
|
+
let e = typeof n.count == "number" ? n.count : Number(n.count);
|
|
143
164
|
if (!Number.isFinite(e) || e < 0) continue;
|
|
144
|
-
let
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
165
|
+
let r = E(n.date);
|
|
166
|
+
r && t.push({
|
|
167
|
+
...r,
|
|
168
|
+
count: e
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
return t;
|
|
172
|
+
}
|
|
173
|
+
function L(e, t) {
|
|
174
|
+
let n = I(e).filter((e) => e.kind !== "odd");
|
|
175
|
+
if (!n.length) return t != null && t > T ? "decade" : "year";
|
|
176
|
+
let r = n.map((e) => Number(e.key.slice(0, 4))), i = Math.max(...r) - Math.min(...r) + 1;
|
|
177
|
+
return n.every((e) => e.kind === "month") && i <= w ? "month" : n.some((e) => e.kind === "decade") ? "decade" : i <= T ? "year" : "decade";
|
|
178
|
+
}
|
|
179
|
+
function R(e, t) {
|
|
180
|
+
let n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map();
|
|
181
|
+
for (let i of I(e)) {
|
|
182
|
+
let { count: e } = i;
|
|
183
|
+
if (i.kind === "odd" || t === "month" && i.kind === "year" || t !== "decade" && i.kind === "decade") {
|
|
184
|
+
F(r, i.key, e);
|
|
148
185
|
continue;
|
|
149
186
|
}
|
|
150
|
-
let
|
|
151
|
-
n.set(
|
|
187
|
+
let a = t === "year" ? i.key.slice(0, 4) : t === "decade" ? S(Number(i.key.slice(0, 4))) : i.key;
|
|
188
|
+
n.set(a, (n.get(a) ?? 0) + e);
|
|
152
189
|
}
|
|
153
190
|
let i = [], a = [...n.keys()].sort();
|
|
154
191
|
if (a.length) {
|
|
155
192
|
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
|
|
193
|
+
for (let a = e; a <= r; a += t === "decade" ? 10 : 1) if (t === "decade") {
|
|
194
|
+
let e = S(a);
|
|
195
|
+
i.push({
|
|
196
|
+
key: e,
|
|
197
|
+
count: n.get(e) ?? 0,
|
|
198
|
+
year: a,
|
|
199
|
+
month: 0
|
|
200
|
+
});
|
|
201
|
+
} else if (t === "year") {
|
|
157
202
|
let e = String(a);
|
|
158
203
|
i.push({
|
|
159
204
|
key: e,
|
|
@@ -181,10 +226,10 @@ function A(e, t) {
|
|
|
181
226
|
max: o
|
|
182
227
|
};
|
|
183
228
|
}
|
|
184
|
-
function
|
|
229
|
+
function z(e, t, n) {
|
|
185
230
|
return e <= 0 || t <= 0 ? 0 : n ? Math.log1p(e) / Math.log1p(t) * 100 : e / t * 100;
|
|
186
231
|
}
|
|
187
|
-
function
|
|
232
|
+
function B(e) {
|
|
188
233
|
if (e == null) return null;
|
|
189
234
|
let t = e.replace(/,/g, "").trim();
|
|
190
235
|
if (!t) return null;
|
|
@@ -192,11 +237,11 @@ function M(e) {
|
|
|
192
237
|
let n = Number(t);
|
|
193
238
|
return Number.isFinite(n) && n >= 0 ? n : null;
|
|
194
239
|
}
|
|
195
|
-
function
|
|
240
|
+
function V(e, t) {
|
|
196
241
|
let n = [...e.cells];
|
|
197
|
-
return n.some((e) => e.tagName === "TH") || e.parentElement?.tagName === "THEAD" ? !0 :
|
|
242
|
+
return n.some((e) => e.tagName === "TH") || e.parentElement?.tagName === "THEAD" ? !0 : B(n[t]?.textContent) == null;
|
|
198
243
|
}
|
|
199
|
-
function
|
|
244
|
+
function H(e) {
|
|
200
245
|
let t = [...e.rows];
|
|
201
246
|
if (!t.length) return [];
|
|
202
247
|
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 = [];
|
|
@@ -205,7 +250,7 @@ function P(e) {
|
|
|
205
250
|
let t = [...e.cells], n = (t[0]?.textContent ?? "").trim();
|
|
206
251
|
/^\d{4}$/.test(n) && r.forEach((e, r) => {
|
|
207
252
|
if (!e) return;
|
|
208
|
-
let i =
|
|
253
|
+
let i = B(t[r]?.textContent);
|
|
209
254
|
i != null && a.push({
|
|
210
255
|
date: `${n}-${String(e).padStart(2, "0")}`,
|
|
211
256
|
count: i
|
|
@@ -216,9 +261,9 @@ function P(e) {
|
|
|
216
261
|
}
|
|
217
262
|
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
263
|
s < 0 && (s = 0), c < 0 && (c = +(s === 0));
|
|
219
|
-
let l =
|
|
264
|
+
let l = V(t[0], c) ? t.slice(1) : t;
|
|
220
265
|
for (let e of l) {
|
|
221
|
-
let t = [...e.cells], n = (t[s]?.textContent ?? "").replace(/\s+/g, " ").trim(), r =
|
|
266
|
+
let t = [...e.cells], n = (t[s]?.textContent ?? "").replace(/\s+/g, " ").trim(), r = B(t[c]?.textContent);
|
|
222
267
|
n && r != null && a.push({
|
|
223
268
|
date: n,
|
|
224
269
|
count: r
|
|
@@ -226,10 +271,10 @@ function P(e) {
|
|
|
226
271
|
}
|
|
227
272
|
return a;
|
|
228
273
|
}
|
|
229
|
-
var
|
|
274
|
+
var U = (e) => `
|
|
230
275
|
${e} { display: block; max-width: 100%; min-width: 0; box-sizing: border-box; }
|
|
231
276
|
${e} .scroller { overflow-x: auto; max-width: 100%; overscroll-behavior-x: contain; }
|
|
232
|
-
${e} .by-month .scroller { scroll-padding-inline-start: 4rem; }
|
|
277
|
+
${e} :is(.by-month, .by-decade) .scroller { scroll-padding-inline-start: 4rem; }
|
|
233
278
|
${e} .year {
|
|
234
279
|
display: grid;
|
|
235
280
|
grid-template-columns: 3.5rem minmax(0, 1fr);
|
|
@@ -254,6 +299,10 @@ var F = (e) => `
|
|
|
254
299
|
block-size: var(--uvalib-date-histogram-bar-size, 8rem);
|
|
255
300
|
min-inline-size: calc(12 * 1.5rem + 11 * 2px);
|
|
256
301
|
}
|
|
302
|
+
${e} .by-decade .bars {
|
|
303
|
+
grid-template-columns: repeat(5, minmax(1.5rem, 1fr));
|
|
304
|
+
min-inline-size: calc(5 * 1.5rem + 4 * 2px);
|
|
305
|
+
}
|
|
257
306
|
${e} .bar {
|
|
258
307
|
position: relative;
|
|
259
308
|
box-sizing: border-box;
|
|
@@ -401,27 +450,27 @@ var F = (e) => `
|
|
|
401
450
|
outline-offset: 2px;
|
|
402
451
|
}
|
|
403
452
|
}
|
|
404
|
-
`,
|
|
405
|
-
function
|
|
453
|
+
`, W = o(U(":host"));
|
|
454
|
+
function G(e) {
|
|
406
455
|
return n`<caption>${e}</caption>`;
|
|
407
456
|
}
|
|
408
|
-
var
|
|
457
|
+
var K = class extends c {
|
|
409
458
|
static {
|
|
410
459
|
this.styles = [
|
|
411
460
|
f,
|
|
412
|
-
|
|
461
|
+
W,
|
|
413
462
|
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
463
|
];
|
|
415
464
|
}
|
|
416
465
|
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 = (
|
|
418
|
-
this.
|
|
466
|
+
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 = () => {
|
|
467
|
+
this.pullPartner();
|
|
419
468
|
}, new d(this, () => this.lightDom, (e) => this.readTable(e));
|
|
420
469
|
}
|
|
421
470
|
createRenderRoot() {
|
|
422
471
|
let e = super.createRenderRoot();
|
|
423
472
|
if (e instanceof ShadowRoot && this.noStyle) {
|
|
424
|
-
let t =
|
|
473
|
+
let t = W.styleSheet;
|
|
425
474
|
t && (e.adoptedStyleSheets = [t]);
|
|
426
475
|
}
|
|
427
476
|
return e;
|
|
@@ -429,20 +478,25 @@ var R = class extends c {
|
|
|
429
478
|
connectedCallback() {
|
|
430
479
|
if (super.connectedCallback(), this.lightDom && this.noStyle) {
|
|
431
480
|
let e = this.getRootNode();
|
|
432
|
-
s(`${this.localName}::structure`, o(
|
|
481
|
+
s(`${this.localName}::structure`, o(U(this.localName)), {
|
|
433
482
|
root: e instanceof ShadowRoot || e instanceof Document ? e : void 0,
|
|
434
483
|
scope: !1
|
|
435
484
|
});
|
|
436
485
|
}
|
|
437
|
-
this.bindPartner(), this.measureOverflow(), customElements.get("uvalib-date-range") || customElements.whenDefined("uvalib-date-range").then(() => {
|
|
438
|
-
this.isConnected &&
|
|
486
|
+
this.bindPartner(), this.hasUpdated && (this.seen = !0, this.syncOnBind()), this.measureOverflow(), customElements.get("uvalib-date-range") || customElements.whenDefined("uvalib-date-range").then(() => {
|
|
487
|
+
this.isConnected && (this.bindPartner(), this.syncOnBind());
|
|
439
488
|
});
|
|
440
489
|
}
|
|
441
490
|
disconnectedCallback() {
|
|
442
|
-
super.disconnectedCallback(), this.
|
|
491
|
+
super.disconnectedCallback(), this.unlisten(this.partner), 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
492
|
}
|
|
444
493
|
willUpdate(e) {
|
|
445
|
-
!this.warnedGrain && e.has("granularity") &&
|
|
494
|
+
!this.warnedGrain && e.has("granularity") && ![
|
|
495
|
+
"year",
|
|
496
|
+
"month",
|
|
497
|
+
"decade",
|
|
498
|
+
"auto"
|
|
499
|
+
].includes(this.granularity) && (this.warnedGrain = !0, console.warn(`<${p}>: granularity must be "month", "year", "decade" or "auto"; using "month".`)), e.has("selected") && !this.choosing && (this.activeKey = ""), this.choosing = !1;
|
|
446
500
|
}
|
|
447
501
|
updated(e) {
|
|
448
502
|
let t = this.echo;
|
|
@@ -450,10 +504,20 @@ var R = class extends c {
|
|
|
450
504
|
let n = this.partner;
|
|
451
505
|
this.bindPartner();
|
|
452
506
|
let r = this.partner != null && this.partner !== n;
|
|
453
|
-
!this.seen || e.has("rangeFor") || r ? (this.seen = !0,
|
|
507
|
+
!this.seen || e.has("rangeFor") || r ? (this.seen = !0, (!t || this.selected) && this.syncOnBind()) : e.has("selected") && !t && this.pushPartner();
|
|
508
|
+
let i = this.grain;
|
|
509
|
+
this.drawnGrain && i !== this.drawnGrain && this.partner && this.pullPartner(), this.drawnGrain = i, this.watchForPartner(), this.measureOverflow();
|
|
454
510
|
}
|
|
455
511
|
get grain() {
|
|
456
|
-
|
|
512
|
+
let e = this.granularity;
|
|
513
|
+
return e === "year" || e === "decade" ? e : e === "auto" ? L(this.data, this.partnerSpan()) : "month";
|
|
514
|
+
}
|
|
515
|
+
get stripGrain() {
|
|
516
|
+
return this.granularity === "decade" || this.granularity === "auto" && this.grain === "decade" ? "decade" : "year";
|
|
517
|
+
}
|
|
518
|
+
partnerSpan() {
|
|
519
|
+
let e = this.partner ?? this.findPartner();
|
|
520
|
+
return e ? j(e.min || e.getAttribute("min") || "", e.max || e.getAttribute("max") || "") : null;
|
|
457
521
|
}
|
|
458
522
|
get strip() {
|
|
459
523
|
return this.variant === "strip";
|
|
@@ -468,7 +532,7 @@ var R = class extends c {
|
|
|
468
532
|
return this.items.length ? this.items : this.tableItems;
|
|
469
533
|
}
|
|
470
534
|
readTable(e) {
|
|
471
|
-
let t = e.filter((e) => e instanceof HTMLTableElement), n = t.flatMap((e) =>
|
|
535
|
+
let t = e.filter((e) => e instanceof HTMLTableElement), n = t.flatMap((e) => H(e)), r = JSON.stringify(n), i = t.length > 0;
|
|
472
536
|
(r !== this.tableKey || i !== this.authorTable) && (this.tableKey = r, this.tableItems = n, this.authorTable = i, this.hasUpdated && this.requestUpdate());
|
|
473
537
|
}
|
|
474
538
|
findPartner() {
|
|
@@ -479,7 +543,16 @@ var R = class extends c {
|
|
|
479
543
|
}
|
|
480
544
|
bindPartner() {
|
|
481
545
|
let e = this.findPartner();
|
|
482
|
-
e !== this.partner && (this.partner?.
|
|
546
|
+
e !== this.partner && (this.unlisten(this.partner), this.partner = e, e?.addEventListener("uvalib-date-range-value", this.onPartner), e?.addEventListener("date-range-change", this.onPartner));
|
|
547
|
+
}
|
|
548
|
+
unlisten(e) {
|
|
549
|
+
e?.removeEventListener("uvalib-date-range-value", this.onPartner), e?.removeEventListener("date-range-change", this.onPartner);
|
|
550
|
+
}
|
|
551
|
+
syncOnBind() {
|
|
552
|
+
let e = this.partner;
|
|
553
|
+
if (!e) return;
|
|
554
|
+
let t = this.partnerRange(), n = !!t && this.lastSeenEl === e && this.lastSeen != null && t.join("/") !== this.lastSeen;
|
|
555
|
+
this.lastSeenEl = e, !this.selected || n || t && !this.isFullSpan(t[0], t[1]) ? this.pullPartner() : this.pushPartner();
|
|
483
556
|
}
|
|
484
557
|
watchForPartner() {
|
|
485
558
|
if (!this.isConnected || !this.rangeFor.trim() || this.partner) {
|
|
@@ -489,7 +562,7 @@ var R = class extends c {
|
|
|
489
562
|
if (this.partnerObserver) return;
|
|
490
563
|
let e = this.getRootNode();
|
|
491
564
|
(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.
|
|
565
|
+
this.isConnected && !this.partner && (this.bindPartner(), this.partner && (this.partnerObserver?.disconnect(), this.partnerObserver = void 0, this.syncOnBind(), this.requestUpdate()));
|
|
493
566
|
}), this.partnerObserver.observe(e, {
|
|
494
567
|
childList: !0,
|
|
495
568
|
subtree: !0
|
|
@@ -506,26 +579,35 @@ var R = class extends c {
|
|
|
506
579
|
let n = this.partnerEnds();
|
|
507
580
|
return !n?.min || !n.max ? !1 : e === n.min && t === n.max;
|
|
508
581
|
}
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
582
|
+
partnerRange() {
|
|
583
|
+
let e = this.partner, t = this.partnerEnds();
|
|
584
|
+
if (!e || !t) return null;
|
|
585
|
+
let n = Array.isArray(e.value) ? e.value : [], r = v(t.min) && v(t.max) && t.min <= t.max, i = (e) => r ? e < t.min ? t.min : e > t.max ? t.max : e : e, a = v(n[0]) ? i(n[0]) : r ? t.min : "", o = v(n[1]) ? i(n[1]) : r ? t.max : "";
|
|
586
|
+
return !a || !o ? null : a <= o ? [a, o] : [o, o];
|
|
587
|
+
}
|
|
588
|
+
pullPartner() {
|
|
589
|
+
let e = this.partnerRange();
|
|
590
|
+
if (!e) return;
|
|
591
|
+
this.lastSeen = e.join("/");
|
|
592
|
+
let [t, n] = e;
|
|
512
593
|
if (this.isFullSpan(t, n)) {
|
|
513
594
|
this.selected &&= (this.echo = !0, "");
|
|
514
595
|
return;
|
|
515
596
|
}
|
|
516
|
-
let r =
|
|
517
|
-
r && r
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
this.applyPartnerValue(this.partner?.value);
|
|
597
|
+
let r = this.selected ? k(this.selected) : null, i = this.partnerEnds(), a = (e) => i && v(i.min) && v(i.max) ? e < i.min ? i.min : e > i.max ? i.max : e : e;
|
|
598
|
+
if (r && a(r.from) === t && a(r.to) === n) return;
|
|
599
|
+
let o = M(t, n, this.grain === "month" ? "month" : "year");
|
|
600
|
+
o && o !== this.selected && (this.echo = !0, this.selected = o);
|
|
521
601
|
}
|
|
522
|
-
pushPartner() {
|
|
523
|
-
let
|
|
524
|
-
if (!
|
|
525
|
-
let
|
|
526
|
-
if (
|
|
527
|
-
let
|
|
528
|
-
Array.isArray(
|
|
602
|
+
pushPartner(e = !1) {
|
|
603
|
+
let t = this.partner;
|
|
604
|
+
if (!t) return;
|
|
605
|
+
let n = this.selected ? k(this.selected) : null, r = null;
|
|
606
|
+
if (n && v(n.from) && v(n.to) ? r = [n.from, n.to] : !this.selected && v(t.min) && v(t.max) && (r = [t.min, t.max]), !r) return;
|
|
607
|
+
let i = t.value;
|
|
608
|
+
if (Array.isArray(i) && i[0] === r[0] && i[1] === r[1]) return;
|
|
609
|
+
let a = this.partnerRange();
|
|
610
|
+
!e && a && this.selected && !this.isFullSpan(a[0], a[1]) && M(a[0], a[1], this.grain === "month" ? "month" : "year") === this.selected.trim() ? this.lastSeen = a.join("/") : (t.value = r, this.lastSeen = r.join("/"));
|
|
529
611
|
}
|
|
530
612
|
emit(e, t) {
|
|
531
613
|
if (this.dispatchEvent(new CustomEvent("select", {
|
|
@@ -546,19 +628,19 @@ var R = class extends c {
|
|
|
546
628
|
}
|
|
547
629
|
choose(e) {
|
|
548
630
|
this.activeKey = e;
|
|
549
|
-
let t = this.selected.trim(), n =
|
|
550
|
-
if (t === e) {
|
|
631
|
+
let t = this.selected.trim(), n = D(e), r = this.grain === "decade" && x.test(e) ? C(e) : e;
|
|
632
|
+
if (t === e || t === r) {
|
|
551
633
|
let e = this.partner?.value;
|
|
552
634
|
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);
|
|
635
|
+
this.pushPartner(!0), this.emit(n.from, n.to);
|
|
554
636
|
return;
|
|
555
637
|
}
|
|
556
638
|
this.choosing = !0, this.selected = "", this.emit("", "");
|
|
557
639
|
return;
|
|
558
640
|
}
|
|
559
|
-
this.choosing = !0, this.selected =
|
|
560
|
-
let
|
|
561
|
-
this.emit(
|
|
641
|
+
this.choosing = !0, this.selected = r;
|
|
642
|
+
let i = k(r);
|
|
643
|
+
this.emit(i?.from ?? e, i?.to ?? e);
|
|
562
644
|
}
|
|
563
645
|
onBarClick(e) {
|
|
564
646
|
let t = e.currentTarget.dataset.date ?? "";
|
|
@@ -567,32 +649,32 @@ var R = class extends c {
|
|
|
567
649
|
onBarKeydown(e) {
|
|
568
650
|
let t = this.flatKeys(), n = t.indexOf(e.currentTarget.dataset.date ?? "");
|
|
569
651
|
if (n < 0) return;
|
|
570
|
-
let r = this.grain === "month" ? 12 : 1, i = -1;
|
|
652
|
+
let r = this.grain, i = r === "month" ? 12 : 1, a = (e) => r === "decade" ? t.indexOf(S(Number(t[n].slice(0, 4)) + e * 50)) : n + e * i, o = -1;
|
|
571
653
|
switch (e.key) {
|
|
572
654
|
case "ArrowRight":
|
|
573
|
-
|
|
655
|
+
o = n + 1;
|
|
574
656
|
break;
|
|
575
657
|
case "ArrowLeft":
|
|
576
|
-
|
|
658
|
+
o = n - 1;
|
|
577
659
|
break;
|
|
578
660
|
case "ArrowDown":
|
|
579
|
-
|
|
661
|
+
o = a(1);
|
|
580
662
|
break;
|
|
581
663
|
case "ArrowUp":
|
|
582
|
-
|
|
664
|
+
o = a(-1);
|
|
583
665
|
break;
|
|
584
666
|
case "Home":
|
|
585
|
-
|
|
667
|
+
o = 0;
|
|
586
668
|
break;
|
|
587
669
|
case "End":
|
|
588
|
-
|
|
670
|
+
o = t.length - 1;
|
|
589
671
|
break;
|
|
590
672
|
default: return;
|
|
591
673
|
}
|
|
592
|
-
e.preventDefault(),
|
|
674
|
+
e.preventDefault(), o < 0 || o >= t.length || o === n || (this.activeKey = t[o], this.updateComplete.then(() => this.focusBar(this.activeKey)));
|
|
593
675
|
}
|
|
594
676
|
flatKeys() {
|
|
595
|
-
return
|
|
677
|
+
return R(this.data, this.grain).bars.map((e) => e.key);
|
|
596
678
|
}
|
|
597
679
|
focusBar(e) {
|
|
598
680
|
let t = this.renderRoot.querySelector(`button.bar[data-date="${CSS.escape(e)}"]`);
|
|
@@ -616,12 +698,15 @@ var R = class extends c {
|
|
|
616
698
|
selectionHighlights() {
|
|
617
699
|
let e = this.selected.trim();
|
|
618
700
|
if (!e) return !1;
|
|
619
|
-
let t =
|
|
620
|
-
|
|
701
|
+
let t = O(e);
|
|
702
|
+
if (t.length >= 2 && t.every((e) => D(e) !== null)) return !0;
|
|
703
|
+
if (t.length !== 1) return !1;
|
|
704
|
+
let n = this.grain;
|
|
705
|
+
return n === "decade" ? /^\d{4}$/.test(e) || x.test(e) : n === "year" ? /^\d{4}$/.test(e) : /^\d{4}-\d{2}$/.test(e);
|
|
621
706
|
}
|
|
622
707
|
overlaps(e, t) {
|
|
623
708
|
if (!t || !v(t.from) || !v(t.to)) return !1;
|
|
624
|
-
let n =
|
|
709
|
+
let n = D(e);
|
|
625
710
|
return n ? n.from <= t.to && n.to >= t.from : !1;
|
|
626
711
|
}
|
|
627
712
|
pressed(e, t) {
|
|
@@ -630,50 +715,69 @@ var R = class extends c {
|
|
|
630
715
|
chipOn(e, t) {
|
|
631
716
|
if (this.selected.trim() === e) return !0;
|
|
632
717
|
if (!v(e)) return !1;
|
|
633
|
-
let n =
|
|
634
|
-
return n.length < 2 || n.some((e) =>
|
|
718
|
+
let n = O(this.selected.trim());
|
|
719
|
+
return n.length < 2 || n.some((e) => D(e) === null) ? !1 : this.overlaps(e, t);
|
|
635
720
|
}
|
|
636
721
|
focusKey(e) {
|
|
637
722
|
let t = e.map((e) => e.key);
|
|
638
723
|
if (this.activeKey && t.includes(this.activeKey)) return this.activeKey;
|
|
639
|
-
let n =
|
|
724
|
+
let n = k(this.selected);
|
|
640
725
|
return e.find((e) => this.pressed(e.key, n))?.key ?? t[0] ?? "";
|
|
641
726
|
}
|
|
642
|
-
barTemplate(e, t, r) {
|
|
643
|
-
let
|
|
727
|
+
barTemplate(e, t, r, i, o = 0) {
|
|
728
|
+
let s = z(e.count, i, this.log), c = this.pressed(e.key, r);
|
|
644
729
|
return n`
|
|
645
730
|
<button
|
|
646
731
|
type="button"
|
|
647
732
|
class="bar ${e.count ? "" : "is-empty"}"
|
|
648
733
|
part="bar"
|
|
734
|
+
style=${o ? `grid-column-start: ${o}` : a}
|
|
649
735
|
data-date=${e.key}
|
|
650
736
|
tabindex=${e.key === t ? "0" : "-1"}
|
|
651
|
-
aria-pressed=${
|
|
652
|
-
aria-label=${
|
|
737
|
+
aria-pressed=${c ? "true" : "false"}
|
|
738
|
+
aria-label=${P(e.key, e.count, this.unit)}
|
|
653
739
|
@click=${this.onBarClick}
|
|
654
740
|
@keydown=${this.onBarKeydown}
|
|
655
741
|
>
|
|
656
|
-
<span class="fill" aria-hidden="true" style="height: ${
|
|
742
|
+
<span class="fill" aria-hidden="true" style="height: ${s}%"></span>
|
|
657
743
|
</button>
|
|
658
744
|
`;
|
|
659
745
|
}
|
|
660
746
|
renderBars(e, t) {
|
|
661
|
-
let r = this.focusKey(e.bars);
|
|
662
|
-
if (
|
|
747
|
+
let r = this.focusKey(e.bars), i = this.grain;
|
|
748
|
+
if (i === "decade") {
|
|
749
|
+
let i = [...new Set(e.bars.map((e) => A(e.year)))];
|
|
750
|
+
return n`
|
|
751
|
+
<div class="scroller" role="group" aria-label=${this.labelText}>
|
|
752
|
+
${i.map((i) => {
|
|
753
|
+
let a = e.bars.filter((e) => A(e.year) === i), o = (a[0].year - i) / 10 + 1;
|
|
754
|
+
return n`
|
|
755
|
+
<div class="year">
|
|
756
|
+
<span class="year-label" aria-hidden="true">${i}</span>
|
|
757
|
+
<div class="bars" role="group" aria-label=${`${i} to ${i + 49}`}>
|
|
758
|
+
${l(a, (e) => e.key, (n, i) => this.barTemplate(n, r, t, e.max, i === 0 ? o : 0))}
|
|
759
|
+
</div>
|
|
760
|
+
</div>
|
|
761
|
+
`;
|
|
762
|
+
})}
|
|
763
|
+
</div>
|
|
764
|
+
`;
|
|
765
|
+
}
|
|
766
|
+
if (i === "year") return n`
|
|
663
767
|
<div class="scroller" role="group" aria-label=${this.labelText}>
|
|
664
768
|
<div class="bars">
|
|
665
|
-
${l(e.bars, (e) => e.key, (
|
|
769
|
+
${l(e.bars, (e) => e.key, (n) => this.barTemplate(n, r, t, e.max))}
|
|
666
770
|
</div>
|
|
667
771
|
</div>
|
|
668
772
|
`;
|
|
669
|
-
let
|
|
773
|
+
let a = [...new Set(e.bars.map((e) => e.year))];
|
|
670
774
|
return n`
|
|
671
775
|
<div class="scroller" role="group" aria-label=${this.labelText}>
|
|
672
|
-
${
|
|
776
|
+
${a.map((i) => n`
|
|
673
777
|
<div class="year">
|
|
674
778
|
<span class="year-label" id=${`${this.uid}-${i}`}>${i}</span>
|
|
675
779
|
<div class="bars" role="group" aria-labelledby=${`${this.uid}-${i}`}>
|
|
676
|
-
${l(e.bars.filter((e) => e.year === i), (e) => e.key, (
|
|
780
|
+
${l(e.bars.filter((e) => e.year === i), (e) => e.key, (n) => this.barTemplate(n, r, t, e.max))}
|
|
677
781
|
</div>
|
|
678
782
|
</div>
|
|
679
783
|
`)}
|
|
@@ -684,7 +788,7 @@ var R = class extends c {
|
|
|
684
788
|
return e.length ? n`
|
|
685
789
|
<div class="outliers" role="group" aria-label="Other dates">
|
|
686
790
|
${e.map((e) => {
|
|
687
|
-
let r =
|
|
791
|
+
let r = P(e.key, e.count, this.unit), i = this.chipOn(e.key, t);
|
|
688
792
|
return n`
|
|
689
793
|
<button
|
|
690
794
|
type="button"
|
|
@@ -706,7 +810,7 @@ var R = class extends c {
|
|
|
706
810
|
let r = [...new Set(e.bars.map((e) => e.year))];
|
|
707
811
|
return n`
|
|
708
812
|
<table part="table">
|
|
709
|
-
${
|
|
813
|
+
${G(t)}
|
|
710
814
|
<thead>
|
|
711
815
|
<tr>
|
|
712
816
|
<th scope="col">Year</th>
|
|
@@ -732,10 +836,14 @@ var R = class extends c {
|
|
|
732
836
|
}
|
|
733
837
|
return n`
|
|
734
838
|
<table part="table">
|
|
735
|
-
${
|
|
839
|
+
${G(t)}
|
|
736
840
|
<thead>
|
|
737
841
|
<tr>
|
|
738
|
-
<th scope="col">${
|
|
842
|
+
<th scope="col">${{
|
|
843
|
+
year: "Year",
|
|
844
|
+
decade: "Decade",
|
|
845
|
+
month: "Date"
|
|
846
|
+
}[this.grain]}</th>
|
|
739
847
|
<th scope="col">Count</th>
|
|
740
848
|
</tr>
|
|
741
849
|
</thead>
|
|
@@ -759,7 +867,7 @@ var R = class extends c {
|
|
|
759
867
|
oddsTable(e) {
|
|
760
868
|
return e.odds.length ? n`
|
|
761
869
|
<table part="table">
|
|
762
|
-
${
|
|
870
|
+
${G("Other dates")}
|
|
763
871
|
<thead>
|
|
764
872
|
<tr>
|
|
765
873
|
<th scope="col">Date</th>
|
|
@@ -797,26 +905,28 @@ var R = class extends c {
|
|
|
797
905
|
}
|
|
798
906
|
reserveStyle() {
|
|
799
907
|
let e = "var(--uvalib-date-histogram-bar-size, 8rem)";
|
|
800
|
-
return this.grain === "year" ? `min-block-size: ${e}` : `min-block-size: calc(${this.
|
|
801
|
-
}
|
|
802
|
-
|
|
803
|
-
let e = A(this.data,
|
|
804
|
-
if (
|
|
805
|
-
let
|
|
806
|
-
if (!
|
|
807
|
-
let
|
|
808
|
-
|
|
908
|
+
return this.grain === "year" ? `min-block-size: ${e}` : `min-block-size: calc(${this.reservedRows()} * (${e} + 0.5rem))`;
|
|
909
|
+
}
|
|
910
|
+
reservedRows() {
|
|
911
|
+
let e = this.grain, t = (t) => e === "decade" ? A(t) : t, n = R(this.data, e);
|
|
912
|
+
if (n.bars.length) return new Set(n.bars.map((e) => t(e.year))).size;
|
|
913
|
+
let r = this.partner ?? this.findPartner();
|
|
914
|
+
if (!r) return 1;
|
|
915
|
+
let i = /^(\d{4})/.exec((r.min || r.getAttribute("min") || "").trim()), a = /^(\d{4})/.exec((r.max || r.getAttribute("max") || "").trim());
|
|
916
|
+
if (!i || !a) return 1;
|
|
917
|
+
let [o, s] = [Number(i[1]), Number(a[1])].sort((e, t) => e - t);
|
|
918
|
+
return e === "decade" ? (t(s) - t(o)) / 50 + 1 : s - o + 1;
|
|
809
919
|
}
|
|
810
920
|
renderStrip(e) {
|
|
811
|
-
let t = e.bars, r = t.reduce((e, t) => e + t.count, 0), i =
|
|
921
|
+
let t = e.bars, r = t.reduce((e, t) => e + t.count, 0), i = k(this.selected), a = t.length === 0 ? "" : t.length === 1 ? t[0].key : `${t[0].key} to ${t[t.length - 1].key}`, o = t.length ? `${this.labelText}: ${a}, ${r.toLocaleString("en-US")} ${N(r, this.unit)}` : `${this.labelText}: no dates`;
|
|
812
922
|
if (i && t.some((e) => this.pressed(e.key, i))) {
|
|
813
|
-
let e = t.filter((e) => this.pressed(e.key, i)), n = e[0].
|
|
923
|
+
let e = t.filter((e) => this.pressed(e.key, i)), n = e[0].key, r = e[e.length - 1].key;
|
|
814
924
|
o += n === r ? `. Selected ${n}.` : `. Selected ${n} to ${r}.`;
|
|
815
925
|
}
|
|
816
926
|
return n`
|
|
817
927
|
<div class="strip" part="chart" role="img" aria-label=${o}>
|
|
818
928
|
${t.map((t) => {
|
|
819
|
-
let r =
|
|
929
|
+
let r = z(t.count, e.max, this.log), a = this.pressed(t.key, i);
|
|
820
930
|
return n`<span
|
|
821
931
|
class="strip-bar ${t.count ? "" : "is-empty"} ${a ? "is-selected" : ""}"
|
|
822
932
|
part="bar"
|
|
@@ -827,9 +937,9 @@ var R = class extends c {
|
|
|
827
937
|
`;
|
|
828
938
|
}
|
|
829
939
|
render() {
|
|
830
|
-
let e =
|
|
940
|
+
let e = R(this.data, this.strip ? this.stripGrain : this.grain);
|
|
831
941
|
if (this.strip) return this.renderStrip(e);
|
|
832
|
-
let t =
|
|
942
|
+
let t = k(this.selected), r = `by-${this.grain}`;
|
|
833
943
|
return n`
|
|
834
944
|
<div class="chart ${r}" part="chart">
|
|
835
945
|
<p class="scroll-hint" ?hidden=${!this.overflowing}>Scroll sideways to see more.</p>
|
|
@@ -842,9 +952,9 @@ var R = class extends c {
|
|
|
842
952
|
}
|
|
843
953
|
};
|
|
844
954
|
// src/components/uvalib-date-histogram/uvalib-date-histogram.ts
|
|
845
|
-
i([e({ type: Array })],
|
|
955
|
+
i([e({ type: Array })], K.prototype, "items", void 0), i([e({ type: String })], K.prototype, "granularity", void 0), i([e({ type: String })], K.prototype, "scale", void 0), i([e({ type: String })], K.prototype, "selected", void 0), i([e({
|
|
846
956
|
type: String,
|
|
847
957
|
attribute: "range-for"
|
|
848
|
-
})],
|
|
958
|
+
})], K.prototype, "rangeFor", void 0), i([e({ type: String })], K.prototype, "variant", void 0), i([e({ type: String })], K.prototype, "unit", void 0), i([e({ type: String })], K.prototype, "label", void 0), i([t()], K.prototype, "tableItems", void 0), i([t()], K.prototype, "authorTable", void 0), i([t()], K.prototype, "overflowing", void 0), i([t()], K.prototype, "activeKey", void 0), r("uvalib-date-histogram", K);
|
|
849
959
|
|
|
850
960
|
//# sourceMappingURL=uvalib-date-histogram.js.map
|