@uvalib/web-components 1.1.1 → 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 +140 -0
- package/README.md +1310 -80
- 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/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 +562 -2
- 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-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 +178 -0
- package/dist/components/uvalib-chip-group/UvalibChipGroup.js +817 -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-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 +187 -0
- package/dist/components/uvalib-date-histogram/UvalibDateHistogram.js +1452 -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-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 +152 -17
- 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-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 +77 -4
- package/dist/components/uvalib-pager/UvalibPager.js +270 -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 +14007 -3497
- package/dist/index.d.ts +16 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -1
- package/dist/pagefind.css +4 -0
- package/dist/styles/base.js +154 -1
- package/dist/styles/base.js.map +1 -1
- package/dist/styles/color-scheme.js +9 -0
- package/dist/styles/color-scheme.js.map +1 -1
- package/dist/styles/controls.js +8 -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.d.ts +1 -0
- package/dist/styles/results.js +242 -0
- package/dist/styles/results.js.map +1 -0
- 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 +9 -0
- package/dist-cdn/analytics.js +32 -0
- package/dist-cdn/analytics.js.map +1 -0
- package/dist-cdn/base.css +562 -2
- 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-BI8h0Gf3.js +281 -0
- package/dist-cdn/chunks/base-BI8h0Gf3.js.map +1 -0
- 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/{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-C9V7Wuw2.js → site-header-DYRMpdBj.js} +13 -4
- package/dist-cdn/chunks/site-header-DYRMpdBj.js.map +1 -0
- 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/source-children-BHsDwCvL.js +53 -0
- package/dist-cdn/chunks/source-children-BHsDwCvL.js.map +1 -0
- 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/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 +14007 -3497
- 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 +15 -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 +269 -24
- package/dist-cdn/skills/uvalib-web-components/reference/accessibility-testing.md +34 -2
- package/dist-cdn/skills/uvalib-web-components/reference/components.md +514 -13
- package/dist-cdn/skills/uvalib-web-components/reference/snippets.md +1 -1
- package/dist-cdn/tokens.css +9 -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 +97 -23
- package/dist-cdn/uvalib-card.js.map +1 -1
- package/dist-cdn/uvalib-chip-group.js +535 -0
- package/dist-cdn/uvalib-chip-group.js.map +1 -0
- package/dist-cdn/uvalib-combobox.js +667 -0
- package/dist-cdn/uvalib-combobox.js.map +1 -0
- package/dist-cdn/uvalib-contents.js +102 -23
- package/dist-cdn/uvalib-contents.js.map +1 -1
- package/dist-cdn/uvalib-date-histogram.js +960 -0
- package/dist-cdn/uvalib-date-histogram.js.map +1 -0
- 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 +145 -78
- 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 +152 -25
- package/dist-cdn/uvalib-metadata.js.map +1 -1
- package/dist-cdn/uvalib-pager.js +164 -18
- package/dist-cdn/uvalib-pager.js.map +1 -1
- package/dist-cdn/uvalib-photo-grid.js +123 -21
- 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 +66 -3
- package/skills/uvalib-web-components/SKILL.md +269 -24
- package/skills/uvalib-web-components/reference/accessibility-testing.md +34 -2
- package/skills/uvalib-web-components/reference/components.md +514 -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-CAFQWnZG.js +0 -128
- package/dist-cdn/chunks/base-CAFQWnZG.js.map +0 -1
- 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,960 @@
|
|
|
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
|
+
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-DJv7YOtS.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
|
+
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) {
|
|
50
|
+
let t = e.replace(/\s+/g, " ").trim();
|
|
51
|
+
if (!t) return null;
|
|
52
|
+
if (x.test(t)) return {
|
|
53
|
+
key: t,
|
|
54
|
+
kind: "decade"
|
|
55
|
+
};
|
|
56
|
+
if (_.test(t)) return {
|
|
57
|
+
key: (v(t), t),
|
|
58
|
+
kind: "odd"
|
|
59
|
+
};
|
|
60
|
+
let n = /^(\d{4})-(\d{2})$/.exec(t);
|
|
61
|
+
if (n) {
|
|
62
|
+
let e = Number(n[2]);
|
|
63
|
+
return e >= 1 && e <= 12 ? {
|
|
64
|
+
key: `${n[1]}-${n[2]}`,
|
|
65
|
+
kind: "month"
|
|
66
|
+
} : {
|
|
67
|
+
key: t,
|
|
68
|
+
kind: "odd"
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
if (/^\d{4}$/.test(t)) return {
|
|
72
|
+
key: t,
|
|
73
|
+
kind: "year"
|
|
74
|
+
};
|
|
75
|
+
let r = /^([A-Za-z]+)\s+(\d{4})$/.exec(t) ?? /^(\d{4})\s+([A-Za-z]+)$/.exec(t);
|
|
76
|
+
if (r) {
|
|
77
|
+
let e = /^\d{4}$/.test(r[1]) ? r[1] : r[2], t = b(e === r[1] ? r[2] : r[1]);
|
|
78
|
+
if (t) return {
|
|
79
|
+
key: `${e}-${String(t).padStart(2, "0")}`,
|
|
80
|
+
kind: "month"
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
return {
|
|
84
|
+
key: t,
|
|
85
|
+
kind: "odd"
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
function D(e) {
|
|
89
|
+
if (v(e)) return {
|
|
90
|
+
from: e,
|
|
91
|
+
to: e
|
|
92
|
+
};
|
|
93
|
+
let t = /^(\d{4})-(\d{2})$/.exec(e);
|
|
94
|
+
if (t && Number(t[2]) >= 1 && Number(t[2]) <= 12) return {
|
|
95
|
+
from: `${e}-01`,
|
|
96
|
+
to: y(Number(t[1]), Number(t[2]))
|
|
97
|
+
};
|
|
98
|
+
if (/^\d{4}$/.test(e)) return {
|
|
99
|
+
from: `${e}-01-01`,
|
|
100
|
+
to: `${e}-12-31`
|
|
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;
|
|
111
|
+
}
|
|
112
|
+
function O(e) {
|
|
113
|
+
return e.trim().split(/\s*(?:\.\.|\/|\u2013|\u2014)\s*/).filter(Boolean);
|
|
114
|
+
}
|
|
115
|
+
function k(e) {
|
|
116
|
+
let t = e.trim();
|
|
117
|
+
if (!t) return null;
|
|
118
|
+
let n = O(t);
|
|
119
|
+
if (n.length >= 2 && n.every((e) => D(e) !== null)) {
|
|
120
|
+
let e = n.map((e) => D(e));
|
|
121
|
+
return {
|
|
122
|
+
from: e.reduce((e, t) => t.from < e ? t.from : e, e[0].from),
|
|
123
|
+
to: e.reduce((e, t) => t.to > e ? t.to : e, e[0].to)
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
return D(t) ?? {
|
|
127
|
+
from: t,
|
|
128
|
+
to: t
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
var A = (e) => Math.floor(e / 50) * 50;
|
|
132
|
+
function j(e, t) {
|
|
133
|
+
let n = /^(\d{4})/.exec(e.trim()), r = /^(\d{4})/.exec(t.trim());
|
|
134
|
+
return !n || !r ? null : Math.abs(Number(r[1]) - Number(n[1])) + 1;
|
|
135
|
+
}
|
|
136
|
+
function M(e, t, n) {
|
|
137
|
+
if (!v(e) || !v(t)) return "";
|
|
138
|
+
let [r, i] = e <= t ? [e, t] : [t, e];
|
|
139
|
+
if (n === "year") {
|
|
140
|
+
let e = r.slice(0, 4), t = i.slice(0, 4);
|
|
141
|
+
return e === t ? e : `${e}/${t}`;
|
|
142
|
+
}
|
|
143
|
+
let a = r.slice(0, 7), o = i.slice(0, 7);
|
|
144
|
+
return a === o ? a : `${a}/${o}`;
|
|
145
|
+
}
|
|
146
|
+
function N(e, t) {
|
|
147
|
+
let n = t.trim() || "items";
|
|
148
|
+
return e === 1 && /[^s]s$/i.test(n) && !/ies$/i.test(n) ? n.slice(0, -1) : n;
|
|
149
|
+
}
|
|
150
|
+
function P(e, t, n) {
|
|
151
|
+
let r = t.toLocaleString("en-US"), i = N(t, n), a = /^(\d{4})-(\d{2})$/.exec(e);
|
|
152
|
+
if (a) return `${m[Number(a[2]) - 1]} ${a[1]}: ${r} ${i}`;
|
|
153
|
+
let o = /^(\d{4})-(\d{2})-(\d{2})$/.exec(e);
|
|
154
|
+
return o && v(e) ? `${Number(o[3])} ${m[Number(o[2]) - 1]} ${o[1]}: ${r} ${i}` : `${e}: ${r} ${i}`;
|
|
155
|
+
}
|
|
156
|
+
function F(e, t, n) {
|
|
157
|
+
e.set(t, (e.get(t) ?? 0) + n);
|
|
158
|
+
}
|
|
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);
|
|
164
|
+
if (!Number.isFinite(e) || e < 0) continue;
|
|
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);
|
|
185
|
+
continue;
|
|
186
|
+
}
|
|
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);
|
|
189
|
+
}
|
|
190
|
+
let i = [], a = [...n.keys()].sort();
|
|
191
|
+
if (a.length) {
|
|
192
|
+
let e = Number(a[0].slice(0, 4)), r = Number(a[a.length - 1].slice(0, 4));
|
|
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") {
|
|
202
|
+
let e = String(a);
|
|
203
|
+
i.push({
|
|
204
|
+
key: e,
|
|
205
|
+
count: n.get(e) ?? 0,
|
|
206
|
+
year: a,
|
|
207
|
+
month: 0
|
|
208
|
+
});
|
|
209
|
+
} else for (let e = 1; e <= 12; e++) {
|
|
210
|
+
let t = `${a}-${String(e).padStart(2, "0")}`;
|
|
211
|
+
i.push({
|
|
212
|
+
key: t,
|
|
213
|
+
count: n.get(t) ?? 0,
|
|
214
|
+
year: a,
|
|
215
|
+
month: e
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
let o = i.reduce((e, t) => t.count > e ? t.count : e, 0);
|
|
220
|
+
return {
|
|
221
|
+
bars: i,
|
|
222
|
+
odds: [...r.entries()].map(([e, t]) => ({
|
|
223
|
+
key: e,
|
|
224
|
+
count: t
|
|
225
|
+
})),
|
|
226
|
+
max: o
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
function z(e, t, n) {
|
|
230
|
+
return e <= 0 || t <= 0 ? 0 : n ? Math.log1p(e) / Math.log1p(t) * 100 : e / t * 100;
|
|
231
|
+
}
|
|
232
|
+
function B(e) {
|
|
233
|
+
if (e == null) return null;
|
|
234
|
+
let t = e.replace(/,/g, "").trim();
|
|
235
|
+
if (!t) return null;
|
|
236
|
+
if (t === "—" || t === "-" || t === "–") return 0;
|
|
237
|
+
let n = Number(t);
|
|
238
|
+
return Number.isFinite(n) && n >= 0 ? n : null;
|
|
239
|
+
}
|
|
240
|
+
function V(e, t) {
|
|
241
|
+
let n = [...e.cells];
|
|
242
|
+
return n.some((e) => e.tagName === "TH") || e.parentElement?.tagName === "THEAD" ? !0 : B(n[t]?.textContent) == null;
|
|
243
|
+
}
|
|
244
|
+
function H(e) {
|
|
245
|
+
let t = [...e.rows];
|
|
246
|
+
if (!t.length) return [];
|
|
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 = [];
|
|
248
|
+
if (i) {
|
|
249
|
+
for (let e of t.slice(1)) {
|
|
250
|
+
let t = [...e.cells], n = (t[0]?.textContent ?? "").trim();
|
|
251
|
+
/^\d{4}$/.test(n) && r.forEach((e, r) => {
|
|
252
|
+
if (!e) return;
|
|
253
|
+
let i = B(t[r]?.textContent);
|
|
254
|
+
i != null && a.push({
|
|
255
|
+
date: `${n}-${String(e).padStart(2, "0")}`,
|
|
256
|
+
count: i
|
|
257
|
+
});
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
return a;
|
|
261
|
+
}
|
|
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));
|
|
263
|
+
s < 0 && (s = 0), c < 0 && (c = +(s === 0));
|
|
264
|
+
let l = V(t[0], c) ? t.slice(1) : t;
|
|
265
|
+
for (let e of l) {
|
|
266
|
+
let t = [...e.cells], n = (t[s]?.textContent ?? "").replace(/\s+/g, " ").trim(), r = B(t[c]?.textContent);
|
|
267
|
+
n && r != null && a.push({
|
|
268
|
+
date: n,
|
|
269
|
+
count: r
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
return a;
|
|
273
|
+
}
|
|
274
|
+
var U = (e) => `
|
|
275
|
+
${e} { display: block; max-width: 100%; min-width: 0; box-sizing: border-box; }
|
|
276
|
+
${e} .scroller { overflow-x: auto; max-width: 100%; overscroll-behavior-x: contain; }
|
|
277
|
+
${e} :is(.by-month, .by-decade) .scroller { scroll-padding-inline-start: 4rem; }
|
|
278
|
+
${e} .year {
|
|
279
|
+
display: grid;
|
|
280
|
+
grid-template-columns: 3.5rem minmax(0, 1fr);
|
|
281
|
+
column-gap: 0.5rem;
|
|
282
|
+
align-items: end;
|
|
283
|
+
margin: 0 0 0.5rem;
|
|
284
|
+
}
|
|
285
|
+
${e} .year-label {
|
|
286
|
+
position: sticky;
|
|
287
|
+
inset-inline-start: 0;
|
|
288
|
+
z-index: 1;
|
|
289
|
+
text-align: end;
|
|
290
|
+
font-weight: 600;
|
|
291
|
+
font-variant-numeric: tabular-nums;
|
|
292
|
+
background: var(--uva-color-surface, #fff);
|
|
293
|
+
color: var(--uva-color-text, #2b2b2b);
|
|
294
|
+
}
|
|
295
|
+
${e} .bars {
|
|
296
|
+
display: grid;
|
|
297
|
+
grid-template-columns: repeat(12, minmax(1.5rem, 1fr));
|
|
298
|
+
gap: 2px;
|
|
299
|
+
block-size: var(--uvalib-date-histogram-bar-size, 8rem);
|
|
300
|
+
min-inline-size: calc(12 * 1.5rem + 11 * 2px);
|
|
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
|
+
}
|
|
306
|
+
${e} .bar {
|
|
307
|
+
position: relative;
|
|
308
|
+
box-sizing: border-box;
|
|
309
|
+
display: flex;
|
|
310
|
+
flex-direction: column;
|
|
311
|
+
justify-content: flex-end;
|
|
312
|
+
align-items: stretch;
|
|
313
|
+
min-inline-size: 1.5rem;
|
|
314
|
+
min-block-size: 1.5rem;
|
|
315
|
+
height: 100%;
|
|
316
|
+
margin: 0;
|
|
317
|
+
padding: 0;
|
|
318
|
+
border: 1px solid var(--uva-color-control-border, #808080);
|
|
319
|
+
background: var(--uva-color-track, #e5e7eb);
|
|
320
|
+
font: inherit;
|
|
321
|
+
color: inherit;
|
|
322
|
+
cursor: pointer;
|
|
323
|
+
}
|
|
324
|
+
${e} .bar::after {
|
|
325
|
+
content: '';
|
|
326
|
+
position: absolute;
|
|
327
|
+
inset: 0;
|
|
328
|
+
z-index: 1;
|
|
329
|
+
pointer-events: none;
|
|
330
|
+
}
|
|
331
|
+
${e} .fill {
|
|
332
|
+
display: block;
|
|
333
|
+
width: 100%;
|
|
334
|
+
min-height: 0;
|
|
335
|
+
background: var(--uva-color-accent-bg, var(--uva-brand-blue, #232d4b));
|
|
336
|
+
border: 1px solid var(--uva-color-text, #2b2b2b);
|
|
337
|
+
box-sizing: border-box;
|
|
338
|
+
}
|
|
339
|
+
${e} .bar.is-empty .fill { background: transparent; border-color: transparent; }
|
|
340
|
+
${e} .bar[aria-pressed='true']::after {
|
|
341
|
+
box-shadow: inset 0 0 0 3px var(--uva-color-text, #2b2b2b);
|
|
342
|
+
background-image: repeating-linear-gradient(
|
|
343
|
+
-45deg,
|
|
344
|
+
transparent,
|
|
345
|
+
transparent 3px,
|
|
346
|
+
var(--uva-color-on-accent, #fff) 3px,
|
|
347
|
+
var(--uva-color-on-accent, #fff) 4px
|
|
348
|
+
);
|
|
349
|
+
}
|
|
350
|
+
${e} .by-year .bars {
|
|
351
|
+
display: flex;
|
|
352
|
+
flex-wrap: wrap;
|
|
353
|
+
align-items: flex-end;
|
|
354
|
+
align-content: flex-end;
|
|
355
|
+
min-inline-size: 0;
|
|
356
|
+
block-size: auto;
|
|
357
|
+
min-block-size: var(--uvalib-date-histogram-bar-size, 8rem);
|
|
358
|
+
}
|
|
359
|
+
${e} .by-year .bar {
|
|
360
|
+
flex: 1 1 1.5rem;
|
|
361
|
+
max-inline-size: 3rem;
|
|
362
|
+
height: auto;
|
|
363
|
+
block-size: var(--uvalib-date-histogram-bar-size, 8rem);
|
|
364
|
+
}
|
|
365
|
+
${e} .strip {
|
|
366
|
+
display: flex;
|
|
367
|
+
align-items: flex-end;
|
|
368
|
+
gap: 2px;
|
|
369
|
+
block-size: var(--uvalib-date-histogram-strip-size, 1.5rem);
|
|
370
|
+
max-width: 100%;
|
|
371
|
+
}
|
|
372
|
+
${e} .strip-bar {
|
|
373
|
+
flex: 1 1 0;
|
|
374
|
+
min-inline-size: 0;
|
|
375
|
+
box-sizing: border-box;
|
|
376
|
+
background: var(--uva-color-accent-bg, var(--uva-brand-blue, #232d4b));
|
|
377
|
+
border: 1px solid var(--uva-color-text, #2b2b2b);
|
|
378
|
+
}
|
|
379
|
+
${e} .strip-bar.is-empty { background: transparent; }
|
|
380
|
+
${e} .strip-bar.is-selected {
|
|
381
|
+
box-shadow: inset 0 0 0 2px var(--uva-color-text, #2b2b2b);
|
|
382
|
+
background-image: repeating-linear-gradient(
|
|
383
|
+
-45deg,
|
|
384
|
+
transparent,
|
|
385
|
+
transparent 2px,
|
|
386
|
+
var(--uva-color-on-accent, #fff) 2px,
|
|
387
|
+
var(--uva-color-on-accent, #fff) 3px
|
|
388
|
+
);
|
|
389
|
+
}
|
|
390
|
+
${e} .outliers { display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0.5rem 0; }
|
|
391
|
+
${e} .chip {
|
|
392
|
+
box-sizing: border-box;
|
|
393
|
+
min-block-size: 1.5rem;
|
|
394
|
+
min-inline-size: 1.5rem;
|
|
395
|
+
margin: 0;
|
|
396
|
+
padding: 0.15rem 0.6rem;
|
|
397
|
+
border: 1px solid var(--uva-color-control-border, #808080);
|
|
398
|
+
border-radius: 999px;
|
|
399
|
+
background: var(--uva-color-surface-raised, #fff);
|
|
400
|
+
color: var(--uva-color-text, #2b2b2b);
|
|
401
|
+
font: inherit;
|
|
402
|
+
cursor: pointer;
|
|
403
|
+
}
|
|
404
|
+
${e} .chip[aria-pressed='true'] {
|
|
405
|
+
box-shadow: inset 0 0 0 2px var(--uva-color-text, #2b2b2b);
|
|
406
|
+
font-weight: 700;
|
|
407
|
+
}
|
|
408
|
+
${e} .scroll-hint {
|
|
409
|
+
margin: 0 0 0.35rem;
|
|
410
|
+
font-size: 0.875rem;
|
|
411
|
+
color: var(--uva-color-text-muted, #4b5563);
|
|
412
|
+
}
|
|
413
|
+
${e} .plot { min-block-size: var(--uvalib-date-histogram-bar-size, 8rem); }
|
|
414
|
+
${e} .empty { margin: 0; color: var(--uva-color-text-muted, #4b5563); }
|
|
415
|
+
${e} .table-wrap { overflow-x: auto; max-width: 100%; }
|
|
416
|
+
${e} table { border-collapse: collapse; }
|
|
417
|
+
${e} th, ${e} td {
|
|
418
|
+
border: 1px solid var(--uva-color-control-border, #808080);
|
|
419
|
+
padding: 0.2rem 0.4rem;
|
|
420
|
+
text-align: end;
|
|
421
|
+
color: var(--uva-color-text, #2b2b2b);
|
|
422
|
+
}
|
|
423
|
+
${e} th[scope='row'], ${e} caption { text-align: start; }
|
|
424
|
+
${e} caption { font-weight: 600; }
|
|
425
|
+
${e} .visually-hidden {
|
|
426
|
+
position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
|
|
427
|
+
overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
|
|
428
|
+
}
|
|
429
|
+
${e} :is(button, summary, [tabindex]):focus-visible {
|
|
430
|
+
outline: 3px solid var(--uva-color-focus, var(--uva-brand-orange, #e57200));
|
|
431
|
+
outline-offset: 2px;
|
|
432
|
+
}
|
|
433
|
+
${e}[hidden], ${e} [hidden] { display: none !important; }
|
|
434
|
+
${((t) => e === ":host" ? `:host(${t})` : `${e}${t}`)("[variant='strip']")} .chart { min-block-size: var(--uvalib-date-histogram-strip-size, 1.5rem); }
|
|
435
|
+
@media (forced-colors: active) {
|
|
436
|
+
${e} .bar, ${e} .strip-bar, ${e} .fill, ${e} .chip, ${e} th, ${e} td {
|
|
437
|
+
forced-color-adjust: none;
|
|
438
|
+
border: 1px solid ButtonText;
|
|
439
|
+
background: Canvas;
|
|
440
|
+
color: ButtonText;
|
|
441
|
+
}
|
|
442
|
+
${e} .fill, ${e} .strip-bar { background: ButtonText; }
|
|
443
|
+
${e} .bar.is-empty .fill, ${e} .strip-bar.is-empty { background: transparent; }
|
|
444
|
+
${e} .bar[aria-pressed='true'], ${e} .chip[aria-pressed='true'], ${e} .strip-bar.is-selected {
|
|
445
|
+
outline: 3px solid Highlight;
|
|
446
|
+
outline-offset: -4px;
|
|
447
|
+
}
|
|
448
|
+
${e} :is(.bar, .chip, summary, [tabindex]):focus-visible {
|
|
449
|
+
outline: 3px solid Highlight;
|
|
450
|
+
outline-offset: 2px;
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
`, W = o(U(":host"));
|
|
454
|
+
function G(e) {
|
|
455
|
+
return n`<caption>${e}</caption>`;
|
|
456
|
+
}
|
|
457
|
+
var K = class extends c {
|
|
458
|
+
static {
|
|
459
|
+
this.styles = [
|
|
460
|
+
f,
|
|
461
|
+
W,
|
|
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 ")
|
|
463
|
+
];
|
|
464
|
+
}
|
|
465
|
+
constructor() {
|
|
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();
|
|
468
|
+
}, new d(this, () => this.lightDom, (e) => this.readTable(e));
|
|
469
|
+
}
|
|
470
|
+
createRenderRoot() {
|
|
471
|
+
let e = super.createRenderRoot();
|
|
472
|
+
if (e instanceof ShadowRoot && this.noStyle) {
|
|
473
|
+
let t = W.styleSheet;
|
|
474
|
+
t && (e.adoptedStyleSheets = [t]);
|
|
475
|
+
}
|
|
476
|
+
return e;
|
|
477
|
+
}
|
|
478
|
+
connectedCallback() {
|
|
479
|
+
if (super.connectedCallback(), this.lightDom && this.noStyle) {
|
|
480
|
+
let e = this.getRootNode();
|
|
481
|
+
s(`${this.localName}::structure`, o(U(this.localName)), {
|
|
482
|
+
root: e instanceof ShadowRoot || e instanceof Document ? e : void 0,
|
|
483
|
+
scope: !1
|
|
484
|
+
});
|
|
485
|
+
}
|
|
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());
|
|
488
|
+
});
|
|
489
|
+
}
|
|
490
|
+
disconnectedCallback() {
|
|
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;
|
|
492
|
+
}
|
|
493
|
+
willUpdate(e) {
|
|
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;
|
|
500
|
+
}
|
|
501
|
+
updated(e) {
|
|
502
|
+
let t = this.echo;
|
|
503
|
+
this.echo = !1;
|
|
504
|
+
let n = this.partner;
|
|
505
|
+
this.bindPartner();
|
|
506
|
+
let r = this.partner != null && this.partner !== n;
|
|
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();
|
|
510
|
+
}
|
|
511
|
+
get grain() {
|
|
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;
|
|
521
|
+
}
|
|
522
|
+
get strip() {
|
|
523
|
+
return this.variant === "strip";
|
|
524
|
+
}
|
|
525
|
+
get log() {
|
|
526
|
+
return this.scale === "log";
|
|
527
|
+
}
|
|
528
|
+
get labelText() {
|
|
529
|
+
return this.label.trim() || "Dates";
|
|
530
|
+
}
|
|
531
|
+
get data() {
|
|
532
|
+
return this.items.length ? this.items : this.tableItems;
|
|
533
|
+
}
|
|
534
|
+
readTable(e) {
|
|
535
|
+
let t = e.filter((e) => e instanceof HTMLTableElement), n = t.flatMap((e) => H(e)), r = JSON.stringify(n), i = t.length > 0;
|
|
536
|
+
(r !== this.tableKey || i !== this.authorTable) && (this.tableKey = r, this.tableItems = n, this.authorTable = i, this.hasUpdated && this.requestUpdate());
|
|
537
|
+
}
|
|
538
|
+
findPartner() {
|
|
539
|
+
let e = this.rangeFor.trim();
|
|
540
|
+
if (!e) return null;
|
|
541
|
+
let t = this.getRootNode(), n = (t instanceof Document || t instanceof ShadowRoot ? t.getElementById(e) : null) ?? this.ownerDocument.getElementById(e);
|
|
542
|
+
return !n || n.localName !== "uvalib-date-range" ? null : n;
|
|
543
|
+
}
|
|
544
|
+
bindPartner() {
|
|
545
|
+
let e = this.findPartner();
|
|
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();
|
|
556
|
+
}
|
|
557
|
+
watchForPartner() {
|
|
558
|
+
if (!this.isConnected || !this.rangeFor.trim() || this.partner) {
|
|
559
|
+
this.partnerObserver?.disconnect(), this.partnerObserver = void 0;
|
|
560
|
+
return;
|
|
561
|
+
}
|
|
562
|
+
if (this.partnerObserver) return;
|
|
563
|
+
let e = this.getRootNode();
|
|
564
|
+
(e instanceof Document || e instanceof ShadowRoot) && (this.partnerObserver = new MutationObserver(() => {
|
|
565
|
+
this.isConnected && !this.partner && (this.bindPartner(), this.partner && (this.partnerObserver?.disconnect(), this.partnerObserver = void 0, this.syncOnBind(), this.requestUpdate()));
|
|
566
|
+
}), this.partnerObserver.observe(e, {
|
|
567
|
+
childList: !0,
|
|
568
|
+
subtree: !0
|
|
569
|
+
}));
|
|
570
|
+
}
|
|
571
|
+
partnerEnds() {
|
|
572
|
+
let e = this.partner;
|
|
573
|
+
return e ? {
|
|
574
|
+
min: e.min || e.getAttribute("min") || "",
|
|
575
|
+
max: e.max || e.getAttribute("max") || ""
|
|
576
|
+
} : null;
|
|
577
|
+
}
|
|
578
|
+
isFullSpan(e, t) {
|
|
579
|
+
let n = this.partnerEnds();
|
|
580
|
+
return !n?.min || !n.max ? !1 : e === n.min && t === n.max;
|
|
581
|
+
}
|
|
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;
|
|
593
|
+
if (this.isFullSpan(t, n)) {
|
|
594
|
+
this.selected &&= (this.echo = !0, "");
|
|
595
|
+
return;
|
|
596
|
+
}
|
|
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);
|
|
601
|
+
}
|
|
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("/"));
|
|
611
|
+
}
|
|
612
|
+
emit(e, t) {
|
|
613
|
+
if (this.dispatchEvent(new CustomEvent("select", {
|
|
614
|
+
detail: {
|
|
615
|
+
from: e,
|
|
616
|
+
to: t
|
|
617
|
+
},
|
|
618
|
+
bubbles: !0,
|
|
619
|
+
composed: !0
|
|
620
|
+
})), e && t) {
|
|
621
|
+
let n = v(e) && v(t) ? `${e}\u2013${t}` : "other";
|
|
622
|
+
u(this, [
|
|
623
|
+
p,
|
|
624
|
+
"select",
|
|
625
|
+
n
|
|
626
|
+
]);
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
choose(e) {
|
|
630
|
+
this.activeKey = 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) {
|
|
633
|
+
let e = this.partner?.value;
|
|
634
|
+
if (n && Array.isArray(e) && e.length >= 2 && (e[0] !== n.from || e[1] !== n.to) && n) {
|
|
635
|
+
this.pushPartner(!0), this.emit(n.from, n.to);
|
|
636
|
+
return;
|
|
637
|
+
}
|
|
638
|
+
this.choosing = !0, this.selected = "", this.emit("", "");
|
|
639
|
+
return;
|
|
640
|
+
}
|
|
641
|
+
this.choosing = !0, this.selected = r;
|
|
642
|
+
let i = k(r);
|
|
643
|
+
this.emit(i?.from ?? e, i?.to ?? e);
|
|
644
|
+
}
|
|
645
|
+
onBarClick(e) {
|
|
646
|
+
let t = e.currentTarget.dataset.date ?? "";
|
|
647
|
+
t && this.choose(t);
|
|
648
|
+
}
|
|
649
|
+
onBarKeydown(e) {
|
|
650
|
+
let t = this.flatKeys(), n = t.indexOf(e.currentTarget.dataset.date ?? "");
|
|
651
|
+
if (n < 0) return;
|
|
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;
|
|
653
|
+
switch (e.key) {
|
|
654
|
+
case "ArrowRight":
|
|
655
|
+
o = n + 1;
|
|
656
|
+
break;
|
|
657
|
+
case "ArrowLeft":
|
|
658
|
+
o = n - 1;
|
|
659
|
+
break;
|
|
660
|
+
case "ArrowDown":
|
|
661
|
+
o = a(1);
|
|
662
|
+
break;
|
|
663
|
+
case "ArrowUp":
|
|
664
|
+
o = a(-1);
|
|
665
|
+
break;
|
|
666
|
+
case "Home":
|
|
667
|
+
o = 0;
|
|
668
|
+
break;
|
|
669
|
+
case "End":
|
|
670
|
+
o = t.length - 1;
|
|
671
|
+
break;
|
|
672
|
+
default: return;
|
|
673
|
+
}
|
|
674
|
+
e.preventDefault(), o < 0 || o >= t.length || o === n || (this.activeKey = t[o], this.updateComplete.then(() => this.focusBar(this.activeKey)));
|
|
675
|
+
}
|
|
676
|
+
flatKeys() {
|
|
677
|
+
return R(this.data, this.grain).bars.map((e) => e.key);
|
|
678
|
+
}
|
|
679
|
+
focusBar(e) {
|
|
680
|
+
let t = this.renderRoot.querySelector(`button.bar[data-date="${CSS.escape(e)}"]`);
|
|
681
|
+
if (!t) return;
|
|
682
|
+
t.focus();
|
|
683
|
+
let n = t.closest(".scroller");
|
|
684
|
+
if (!n) return;
|
|
685
|
+
let r = t.getBoundingClientRect(), i = n.getBoundingClientRect(), a = t.closest(".year")?.querySelector(".year-label")?.getBoundingClientRect().right, o = a == null ? i.left : a + 5;
|
|
686
|
+
r.right > i.right ? n.scrollLeft += r.right - i.right : r.left < o && (n.scrollLeft -= o - r.left);
|
|
687
|
+
}
|
|
688
|
+
measureOverflow() {
|
|
689
|
+
let e = this.renderRoot.querySelector(".scroller");
|
|
690
|
+
if (!(e instanceof HTMLElement)) {
|
|
691
|
+
this.overflowing &&= !1;
|
|
692
|
+
return;
|
|
693
|
+
}
|
|
694
|
+
typeof ResizeObserver < "u" && (this.ro ??= new ResizeObserver(() => this.measureOverflow()), this.observed !== e && (this.ro.disconnect(), this.ro.observe(e), this.observed = e));
|
|
695
|
+
let t = e.scrollWidth > e.clientWidth + 1;
|
|
696
|
+
t !== this.overflowing && (this.overflowing = t);
|
|
697
|
+
}
|
|
698
|
+
selectionHighlights() {
|
|
699
|
+
let e = this.selected.trim();
|
|
700
|
+
if (!e) return !1;
|
|
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);
|
|
706
|
+
}
|
|
707
|
+
overlaps(e, t) {
|
|
708
|
+
if (!t || !v(t.from) || !v(t.to)) return !1;
|
|
709
|
+
let n = D(e);
|
|
710
|
+
return n ? n.from <= t.to && n.to >= t.from : !1;
|
|
711
|
+
}
|
|
712
|
+
pressed(e, t) {
|
|
713
|
+
return this.selected.trim() === e ? !0 : this.selectionHighlights() ? this.overlaps(e, t) : !1;
|
|
714
|
+
}
|
|
715
|
+
chipOn(e, t) {
|
|
716
|
+
if (this.selected.trim() === e) return !0;
|
|
717
|
+
if (!v(e)) return !1;
|
|
718
|
+
let n = O(this.selected.trim());
|
|
719
|
+
return n.length < 2 || n.some((e) => D(e) === null) ? !1 : this.overlaps(e, t);
|
|
720
|
+
}
|
|
721
|
+
focusKey(e) {
|
|
722
|
+
let t = e.map((e) => e.key);
|
|
723
|
+
if (this.activeKey && t.includes(this.activeKey)) return this.activeKey;
|
|
724
|
+
let n = k(this.selected);
|
|
725
|
+
return e.find((e) => this.pressed(e.key, n))?.key ?? t[0] ?? "";
|
|
726
|
+
}
|
|
727
|
+
barTemplate(e, t, r, i, o = 0) {
|
|
728
|
+
let s = z(e.count, i, this.log), c = this.pressed(e.key, r);
|
|
729
|
+
return n`
|
|
730
|
+
<button
|
|
731
|
+
type="button"
|
|
732
|
+
class="bar ${e.count ? "" : "is-empty"}"
|
|
733
|
+
part="bar"
|
|
734
|
+
style=${o ? `grid-column-start: ${o}` : a}
|
|
735
|
+
data-date=${e.key}
|
|
736
|
+
tabindex=${e.key === t ? "0" : "-1"}
|
|
737
|
+
aria-pressed=${c ? "true" : "false"}
|
|
738
|
+
aria-label=${P(e.key, e.count, this.unit)}
|
|
739
|
+
@click=${this.onBarClick}
|
|
740
|
+
@keydown=${this.onBarKeydown}
|
|
741
|
+
>
|
|
742
|
+
<span class="fill" aria-hidden="true" style="height: ${s}%"></span>
|
|
743
|
+
</button>
|
|
744
|
+
`;
|
|
745
|
+
}
|
|
746
|
+
renderBars(e, t) {
|
|
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`
|
|
767
|
+
<div class="scroller" role="group" aria-label=${this.labelText}>
|
|
768
|
+
<div class="bars">
|
|
769
|
+
${l(e.bars, (e) => e.key, (n) => this.barTemplate(n, r, t, e.max))}
|
|
770
|
+
</div>
|
|
771
|
+
</div>
|
|
772
|
+
`;
|
|
773
|
+
let a = [...new Set(e.bars.map((e) => e.year))];
|
|
774
|
+
return n`
|
|
775
|
+
<div class="scroller" role="group" aria-label=${this.labelText}>
|
|
776
|
+
${a.map((i) => n`
|
|
777
|
+
<div class="year">
|
|
778
|
+
<span class="year-label" id=${`${this.uid}-${i}`}>${i}</span>
|
|
779
|
+
<div class="bars" role="group" aria-labelledby=${`${this.uid}-${i}`}>
|
|
780
|
+
${l(e.bars.filter((e) => e.year === i), (e) => e.key, (n) => this.barTemplate(n, r, t, e.max))}
|
|
781
|
+
</div>
|
|
782
|
+
</div>
|
|
783
|
+
`)}
|
|
784
|
+
</div>
|
|
785
|
+
`;
|
|
786
|
+
}
|
|
787
|
+
renderOdds(e, t) {
|
|
788
|
+
return e.length ? n`
|
|
789
|
+
<div class="outliers" role="group" aria-label="Other dates">
|
|
790
|
+
${e.map((e) => {
|
|
791
|
+
let r = P(e.key, e.count, this.unit), i = this.chipOn(e.key, t);
|
|
792
|
+
return n`
|
|
793
|
+
<button
|
|
794
|
+
type="button"
|
|
795
|
+
class="chip"
|
|
796
|
+
data-date=${e.key}
|
|
797
|
+
aria-pressed=${i ? "true" : "false"}
|
|
798
|
+
@click=${this.onBarClick}
|
|
799
|
+
>
|
|
800
|
+
${r}
|
|
801
|
+
</button>
|
|
802
|
+
`;
|
|
803
|
+
})}
|
|
804
|
+
</div>
|
|
805
|
+
` : a;
|
|
806
|
+
}
|
|
807
|
+
generatedTable(e) {
|
|
808
|
+
let t = this.labelText;
|
|
809
|
+
if (this.grain === "month" && e.bars.length) {
|
|
810
|
+
let r = [...new Set(e.bars.map((e) => e.year))];
|
|
811
|
+
return n`
|
|
812
|
+
<table part="table">
|
|
813
|
+
${G(t)}
|
|
814
|
+
<thead>
|
|
815
|
+
<tr>
|
|
816
|
+
<th scope="col">Year</th>
|
|
817
|
+
${h.map((e) => n`<th scope="col">${e}</th>`)}
|
|
818
|
+
<th scope="col">Total</th>
|
|
819
|
+
</tr>
|
|
820
|
+
</thead>
|
|
821
|
+
<tbody>
|
|
822
|
+
${r.map((t) => {
|
|
823
|
+
let r = e.bars.filter((e) => e.year === t), i = r.reduce((e, t) => e + t.count, 0);
|
|
824
|
+
return n`
|
|
825
|
+
<tr>
|
|
826
|
+
<th scope="row">${t}</th>
|
|
827
|
+
${r.map((e) => n`<td>${e.count.toLocaleString("en-US")}</td>`)}
|
|
828
|
+
<td>${i.toLocaleString("en-US")}</td>
|
|
829
|
+
</tr>
|
|
830
|
+
`;
|
|
831
|
+
})}
|
|
832
|
+
</tbody>
|
|
833
|
+
</table>
|
|
834
|
+
${this.oddsTable(e)}
|
|
835
|
+
`;
|
|
836
|
+
}
|
|
837
|
+
return n`
|
|
838
|
+
<table part="table">
|
|
839
|
+
${G(t)}
|
|
840
|
+
<thead>
|
|
841
|
+
<tr>
|
|
842
|
+
<th scope="col">${{
|
|
843
|
+
year: "Year",
|
|
844
|
+
decade: "Decade",
|
|
845
|
+
month: "Date"
|
|
846
|
+
}[this.grain]}</th>
|
|
847
|
+
<th scope="col">Count</th>
|
|
848
|
+
</tr>
|
|
849
|
+
</thead>
|
|
850
|
+
<tbody>
|
|
851
|
+
${e.bars.map((e) => n`
|
|
852
|
+
<tr>
|
|
853
|
+
<th scope="row">${e.key}</th>
|
|
854
|
+
<td>${e.count.toLocaleString("en-US")}</td>
|
|
855
|
+
</tr>
|
|
856
|
+
`)}
|
|
857
|
+
${e.odds.map((e) => n`
|
|
858
|
+
<tr>
|
|
859
|
+
<th scope="row">${e.key}</th>
|
|
860
|
+
<td>${e.count.toLocaleString("en-US")}</td>
|
|
861
|
+
</tr>
|
|
862
|
+
`)}
|
|
863
|
+
</tbody>
|
|
864
|
+
</table>
|
|
865
|
+
`;
|
|
866
|
+
}
|
|
867
|
+
oddsTable(e) {
|
|
868
|
+
return e.odds.length ? n`
|
|
869
|
+
<table part="table">
|
|
870
|
+
${G("Other dates")}
|
|
871
|
+
<thead>
|
|
872
|
+
<tr>
|
|
873
|
+
<th scope="col">Date</th>
|
|
874
|
+
<th scope="col">Count</th>
|
|
875
|
+
</tr>
|
|
876
|
+
</thead>
|
|
877
|
+
<tbody>
|
|
878
|
+
${e.odds.map((e) => n`
|
|
879
|
+
<tr>
|
|
880
|
+
<th scope="row">${e.key}</th>
|
|
881
|
+
<td>${e.count.toLocaleString("en-US")}</td>
|
|
882
|
+
</tr>
|
|
883
|
+
`)}
|
|
884
|
+
</tbody>
|
|
885
|
+
</table>
|
|
886
|
+
` : a;
|
|
887
|
+
}
|
|
888
|
+
renderDisclosure(e) {
|
|
889
|
+
if (!this.authorTable && !e.bars.length && !e.odds.length) return a;
|
|
890
|
+
let t = this.lightDom || !this.authorTable || this.items.length > 0;
|
|
891
|
+
return n`
|
|
892
|
+
<details class="as-table">
|
|
893
|
+
<summary>Show as table</summary>
|
|
894
|
+
<div
|
|
895
|
+
class="table-wrap"
|
|
896
|
+
role="region"
|
|
897
|
+
tabindex="0"
|
|
898
|
+
aria-label="${this.labelText} as a table"
|
|
899
|
+
>
|
|
900
|
+
${t ? this.generatedTable(e) : a}
|
|
901
|
+
${t || this.lightDom ? a : n`<slot></slot>`}
|
|
902
|
+
</div>
|
|
903
|
+
</details>
|
|
904
|
+
`;
|
|
905
|
+
}
|
|
906
|
+
reserveStyle() {
|
|
907
|
+
let e = "var(--uvalib-date-histogram-bar-size, 8rem)";
|
|
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;
|
|
919
|
+
}
|
|
920
|
+
renderStrip(e) {
|
|
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`;
|
|
922
|
+
if (i && t.some((e) => this.pressed(e.key, i))) {
|
|
923
|
+
let e = t.filter((e) => this.pressed(e.key, i)), n = e[0].key, r = e[e.length - 1].key;
|
|
924
|
+
o += n === r ? `. Selected ${n}.` : `. Selected ${n} to ${r}.`;
|
|
925
|
+
}
|
|
926
|
+
return n`
|
|
927
|
+
<div class="strip" part="chart" role="img" aria-label=${o}>
|
|
928
|
+
${t.map((t) => {
|
|
929
|
+
let r = z(t.count, e.max, this.log), a = this.pressed(t.key, i);
|
|
930
|
+
return n`<span
|
|
931
|
+
class="strip-bar ${t.count ? "" : "is-empty"} ${a ? "is-selected" : ""}"
|
|
932
|
+
part="bar"
|
|
933
|
+
style="height: ${r}%"
|
|
934
|
+
></span>`;
|
|
935
|
+
})}
|
|
936
|
+
</div>
|
|
937
|
+
`;
|
|
938
|
+
}
|
|
939
|
+
render() {
|
|
940
|
+
let e = R(this.data, this.strip ? this.stripGrain : this.grain);
|
|
941
|
+
if (this.strip) return this.renderStrip(e);
|
|
942
|
+
let t = k(this.selected), r = `by-${this.grain}`;
|
|
943
|
+
return n`
|
|
944
|
+
<div class="chart ${r}" part="chart">
|
|
945
|
+
<p class="scroll-hint" ?hidden=${!this.overflowing}>Scroll sideways to see more.</p>
|
|
946
|
+
<div class="plot" style=${this.reserveStyle()}>
|
|
947
|
+
${e.bars.length ? this.renderBars(e, t) : n`<p class="empty">No dates to show.</p>`}
|
|
948
|
+
</div>
|
|
949
|
+
</div>
|
|
950
|
+
${this.renderOdds(e.odds, t)} ${this.renderDisclosure(e)}
|
|
951
|
+
`;
|
|
952
|
+
}
|
|
953
|
+
};
|
|
954
|
+
// src/components/uvalib-date-histogram/uvalib-date-histogram.ts
|
|
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({
|
|
956
|
+
type: String,
|
|
957
|
+
attribute: "range-for"
|
|
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);
|
|
959
|
+
|
|
960
|
+
//# sourceMappingURL=uvalib-date-histogram.js.map
|