@seekalfred/primitives 0.6.0 → 0.7.1
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/README.md +19 -11
- package/dist/activity-heatmap/activity-heatmap.d.ts +92 -0
- package/dist/activity-heatmap/activity-heatmap.js +699 -0
- package/dist/activity-heatmap/activity-heatmap.js.map +1 -0
- package/dist/activity-heatmap/index.d.ts +2 -0
- package/dist/activity-heatmap/index.js +2 -0
- package/dist/alert/alert.d.ts +5 -1
- package/dist/alert/alert.js +68 -7
- package/dist/alert/alert.js.map +1 -1
- package/dist/alert-dialog/alert-dialog.d.ts +45 -18
- package/dist/alert-dialog/alert-dialog.js +128 -9
- package/dist/alert-dialog/alert-dialog.js.map +1 -1
- package/dist/alert-dialog/index.d.ts +2 -2
- package/dist/alert-dialog/index.js +2 -2
- package/dist/animated-counter/animated-counter.d.ts +38 -0
- package/dist/animated-counter/animated-counter.js +230 -0
- package/dist/animated-counter/animated-counter.js.map +1 -0
- package/dist/animated-counter/index.d.ts +2 -0
- package/dist/animated-counter/index.js +2 -0
- package/dist/announcement-bar/announcement-bar.d.ts +67 -0
- package/dist/announcement-bar/announcement-bar.js +364 -0
- package/dist/announcement-bar/announcement-bar.js.map +1 -0
- package/dist/announcement-bar/index.d.ts +2 -0
- package/dist/announcement-bar/index.js +2 -0
- package/dist/badge/badge.d.ts +1 -1
- package/dist/bar-chart/bar-chart.d.ts +51 -0
- package/dist/bar-chart/bar-chart.js +565 -0
- package/dist/bar-chart/bar-chart.js.map +1 -0
- package/dist/bar-chart/index.d.ts +2 -0
- package/dist/bar-chart/index.js +2 -0
- package/dist/breadcrumb/breadcrumb.d.ts +2 -2
- package/dist/breadcrumb/breadcrumb.js +12 -3
- package/dist/breadcrumb/breadcrumb.js.map +1 -1
- package/dist/brush-chart/brush-chart.d.ts +64 -0
- package/dist/brush-chart/brush-chart.js +1056 -0
- package/dist/brush-chart/brush-chart.js.map +1 -0
- package/dist/brush-chart/index.d.ts +2 -0
- package/dist/brush-chart/index.js +2 -0
- package/dist/button/button.d.ts +2 -2
- package/dist/button/button.js +31 -21
- package/dist/button/button.js.map +1 -1
- package/dist/button-group/button-group.js +3 -4
- package/dist/button-group/button-group.js.map +1 -1
- package/dist/card/card.js +1 -1
- package/dist/card/card.js.map +1 -1
- package/dist/card-stack/card-stack.d.ts +54 -0
- package/dist/card-stack/card-stack.js +492 -0
- package/dist/card-stack/card-stack.js.map +1 -0
- package/dist/card-stack/index.d.ts +2 -0
- package/dist/card-stack/index.js +2 -0
- package/dist/carousel/carousel.d.ts +56 -0
- package/dist/carousel/carousel.js +389 -0
- package/dist/carousel/carousel.js.map +1 -0
- package/dist/carousel/index.d.ts +2 -0
- package/dist/carousel/index.js +2 -0
- package/dist/checkbox/checkbox.js +4 -4
- package/dist/checkbox/checkbox.js.map +1 -1
- package/dist/chip-group/chip-group.d.ts +37 -0
- package/dist/chip-group/chip-group.js +148 -0
- package/dist/chip-group/chip-group.js.map +1 -0
- package/dist/chip-group/index.d.ts +2 -0
- package/dist/chip-group/index.js +2 -0
- package/dist/countdown/countdown.d.ts +45 -0
- package/dist/countdown/countdown.js +298 -0
- package/dist/countdown/countdown.js.map +1 -0
- package/dist/countdown/index.d.ts +2 -0
- package/dist/countdown/index.js +2 -0
- package/dist/date-picker/picker-parts.js +1 -1
- package/dist/date-picker/picker-parts.js.map +1 -1
- package/dist/dialog/dialog.js +1 -1
- package/dist/dialog/dialog.js.map +1 -1
- package/dist/donut-chart/donut-chart.d.ts +64 -0
- package/dist/donut-chart/donut-chart.js +576 -0
- package/dist/donut-chart/donut-chart.js.map +1 -0
- package/dist/donut-chart/index.d.ts +2 -0
- package/dist/donut-chart/index.js +2 -0
- package/dist/empty-state/empty-state.d.ts +21 -10
- package/dist/empty-state/empty-state.js +32 -26
- package/dist/empty-state/empty-state.js.map +1 -1
- package/dist/empty-state/index.d.ts +2 -2
- package/dist/empty-state/index.js +2 -2
- package/dist/file-drop-zone/file-drop-zone.js +1 -1
- package/dist/file-drop-zone/file-drop-zone.js.map +1 -1
- package/dist/filter-bar/filter-bar.d.ts +47 -26
- package/dist/filter-bar/filter-bar.js +272 -156
- package/dist/filter-bar/filter-bar.js.map +1 -1
- package/dist/gauge/gauge.d.ts +45 -0
- package/dist/gauge/gauge.js +219 -0
- package/dist/gauge/gauge.js.map +1 -0
- package/dist/gauge/index.d.ts +2 -0
- package/dist/gauge/index.js +2 -0
- package/dist/in-view-title/in-view-title.d.ts +33 -0
- package/dist/in-view-title/in-view-title.js +119 -0
- package/dist/in-view-title/in-view-title.js.map +1 -0
- package/dist/in-view-title/index.d.ts +2 -0
- package/dist/in-view-title/index.js +2 -0
- package/dist/index.d.ts +49 -6
- package/dist/index.js +48 -8
- package/dist/lib/cn.js +11 -1
- package/dist/lib/cn.js.map +1 -1
- package/dist/lib/field-message.js +28 -10
- package/dist/lib/field-message.js.map +1 -1
- package/dist/lib/field-surface.js +9 -8
- package/dist/lib/field-surface.js.map +1 -1
- package/dist/lib/flag-emoji.js +50 -0
- package/dist/lib/flag-emoji.js.map +1 -0
- package/dist/lib/flip.js +11 -3
- package/dist/lib/flip.js.map +1 -1
- package/dist/lib/menu-highlight.js +64 -0
- package/dist/lib/menu-highlight.js.map +1 -0
- package/dist/lib/motion.js +9 -2
- package/dist/lib/motion.js.map +1 -1
- package/dist/lib/rolling-value.js +1 -1
- package/dist/lib/rolling-value.js.map +1 -1
- package/dist/lib/spring-tween.js +500 -0
- package/dist/lib/spring-tween.js.map +1 -0
- package/dist/lib/swap-text.js +3 -1
- package/dist/lib/swap-text.js.map +1 -1
- package/dist/line-chart/index.d.ts +2 -0
- package/dist/line-chart/index.js +2 -0
- package/dist/line-chart/line-chart.d.ts +76 -0
- package/dist/line-chart/line-chart.js +611 -0
- package/dist/line-chart/line-chart.js.map +1 -0
- package/dist/mention-input/index.d.ts +2 -0
- package/dist/mention-input/index.js +2 -0
- package/dist/mention-input/mention-input.d.ts +98 -0
- package/dist/mention-input/mention-input.js +576 -0
- package/dist/mention-input/mention-input.js.map +1 -0
- package/dist/menu/menu.d.ts +2 -0
- package/dist/menu/menu.js +23 -12
- package/dist/menu/menu.js.map +1 -1
- package/dist/money-input/index.d.ts +2 -0
- package/dist/money-input/index.js +2 -0
- package/dist/money-input/money-input.d.ts +65 -0
- package/dist/money-input/money-input.js +607 -0
- package/dist/money-input/money-input.js.map +1 -0
- package/dist/morph-select/index.d.ts +2 -0
- package/dist/morph-select/index.js +2 -0
- package/dist/morph-select/morph-select.d.ts +71 -0
- package/dist/morph-select/morph-select.js +693 -0
- package/dist/morph-select/morph-select.js.map +1 -0
- package/dist/multi-select/index.d.ts +2 -0
- package/dist/multi-select/index.js +2 -0
- package/dist/multi-select/multi-select.d.ts +36 -0
- package/dist/multi-select/multi-select.js +152 -0
- package/dist/multi-select/multi-select.js.map +1 -0
- package/dist/number-field/index.d.ts +2 -0
- package/dist/number-field/index.js +2 -0
- package/dist/number-field/number-field.d.ts +42 -0
- package/dist/number-field/number-field.js +199 -0
- package/dist/number-field/number-field.js.map +1 -0
- package/dist/onboarding-checklist/index.d.ts +2 -0
- package/dist/onboarding-checklist/index.js +2 -0
- package/dist/onboarding-checklist/onboarding-checklist.d.ts +55 -0
- package/dist/onboarding-checklist/onboarding-checklist.js +577 -0
- package/dist/onboarding-checklist/onboarding-checklist.js.map +1 -0
- package/dist/password-field/password-field.js +2 -2
- package/dist/password-field/password-field.js.map +1 -1
- package/dist/phone-input/index.d.ts +3 -0
- package/dist/phone-input/index.js +3 -0
- package/dist/phone-input/phone-countries.d.ts +29 -0
- package/dist/phone-input/phone-countries.js +170 -0
- package/dist/phone-input/phone-countries.js.map +1 -0
- package/dist/phone-input/phone-input.d.ts +66 -0
- package/dist/phone-input/phone-input.js +440 -0
- package/dist/phone-input/phone-input.js.map +1 -0
- package/dist/popover/popover.d.ts +12 -0
- package/dist/popover/popover.js +31 -7
- package/dist/popover/popover.js.map +1 -1
- package/dist/progress/progress.js +1 -1
- package/dist/radio-group/radio-group.js +1 -1
- package/dist/radio-group/radio-group.js.map +1 -1
- package/dist/reactions/index.d.ts +2 -0
- package/dist/reactions/index.js +2 -0
- package/dist/reactions/reactions.d.ts +50 -0
- package/dist/reactions/reactions.js +315 -0
- package/dist/reactions/reactions.js.map +1 -0
- package/dist/rich-text-editor/index.d.ts +3 -0
- package/dist/rich-text-editor/index.js +2 -0
- package/dist/rich-text-editor/rich-text-editor.d.ts +70 -0
- package/dist/rich-text-editor/rich-text-editor.js +909 -0
- package/dist/rich-text-editor/rich-text-editor.js.map +1 -0
- package/dist/rich-text-editor/rich-text-engine.d.ts +16 -0
- package/dist/rich-text-editor/rich-text-engine.js +366 -0
- package/dist/rich-text-editor/rich-text-engine.js.map +1 -0
- package/dist/rich-text-editor/rich-text-html.js +174 -0
- package/dist/rich-text-editor/rich-text-html.js.map +1 -0
- package/dist/rich-text-editor/rich-text-icons.js +43 -0
- package/dist/rich-text-editor/rich-text-icons.js.map +1 -0
- package/dist/ridgeline/index.d.ts +2 -0
- package/dist/ridgeline/index.js +2 -0
- package/dist/ridgeline/ridgeline.d.ts +55 -0
- package/dist/ridgeline/ridgeline.js +701 -0
- package/dist/ridgeline/ridgeline.js.map +1 -0
- package/dist/scroll-area/index.d.ts +2 -2
- package/dist/scroll-area/index.js +2 -2
- package/dist/scroll-area/scroll-area.d.ts +68 -31
- package/dist/scroll-area/scroll-area.js +208 -59
- package/dist/scroll-area/scroll-area.js.map +1 -1
- package/dist/scrub-input/evaluate.d.ts +14 -0
- package/dist/scrub-input/evaluate.js +72 -0
- package/dist/scrub-input/evaluate.js.map +1 -0
- package/dist/scrub-input/index.d.ts +3 -0
- package/dist/scrub-input/index.js +3 -0
- package/dist/scrub-input/scrub-input.d.ts +74 -0
- package/dist/scrub-input/scrub-input.js +486 -0
- package/dist/scrub-input/scrub-input.js.map +1 -0
- package/dist/search-field/search-field.d.ts +2 -1
- package/dist/search-field/search-field.js +4 -4
- package/dist/search-field/search-field.js.map +1 -1
- package/dist/select/select.d.ts +3 -1
- package/dist/select/select.js +20 -8
- package/dist/select/select.js.map +1 -1
- package/dist/separator/separator.d.ts +1 -1
- package/dist/sheet/sheet.js +2 -1
- package/dist/sheet/sheet.js.map +1 -1
- package/dist/shortcut-recorder/index.d.ts +3 -0
- package/dist/shortcut-recorder/index.js +3 -0
- package/dist/shortcut-recorder/shortcut-model.d.ts +27 -0
- package/dist/shortcut-recorder/shortcut-model.js +206 -0
- package/dist/shortcut-recorder/shortcut-model.js.map +1 -0
- package/dist/shortcut-recorder/shortcut-recorder.d.ts +93 -0
- package/dist/shortcut-recorder/shortcut-recorder.js +489 -0
- package/dist/shortcut-recorder/shortcut-recorder.js.map +1 -0
- package/dist/slider/index.d.ts +2 -2
- package/dist/slider/slider.d.ts +46 -14
- package/dist/slider/slider.js +151 -67
- package/dist/slider/slider.js.map +1 -1
- package/dist/slope-chart/index.d.ts +2 -0
- package/dist/slope-chart/index.js +2 -0
- package/dist/slope-chart/slope-chart.d.ts +54 -0
- package/dist/slope-chart/slope-chart.js +568 -0
- package/dist/slope-chart/slope-chart.js.map +1 -0
- package/dist/sparkline/index.d.ts +2 -0
- package/dist/sparkline/index.js +2 -0
- package/dist/sparkline/sparkline.d.ts +46 -0
- package/dist/sparkline/sparkline.js +390 -0
- package/dist/sparkline/sparkline.js.map +1 -0
- package/dist/split-bar/index.d.ts +2 -0
- package/dist/split-bar/index.js +2 -0
- package/dist/split-bar/split-bar.d.ts +62 -0
- package/dist/split-bar/split-bar.js +513 -0
- package/dist/split-bar/split-bar.js.map +1 -0
- package/dist/split-button/split-button.d.ts +1 -1
- package/dist/split-button/split-button.js +12 -11
- package/dist/split-button/split-button.js.map +1 -1
- package/dist/stat-card/index.d.ts +2 -2
- package/dist/stat-card/index.js +2 -2
- package/dist/stat-card/stat-card.d.ts +24 -4
- package/dist/stat-card/stat-card.js +114 -17
- package/dist/stat-card/stat-card.js.map +1 -1
- package/dist/stepper/index.d.ts +2 -0
- package/dist/stepper/index.js +2 -0
- package/dist/stepper/stepper.d.ts +51 -0
- package/dist/stepper/stepper.js +215 -0
- package/dist/stepper/stepper.js.map +1 -0
- package/dist/streamgraph/index.d.ts +2 -0
- package/dist/streamgraph/index.js +2 -0
- package/dist/streamgraph/streamgraph.d.ts +70 -0
- package/dist/streamgraph/streamgraph.js +613 -0
- package/dist/streamgraph/streamgraph.js.map +1 -0
- package/dist/styles.css +1 -1
- package/dist/swipe-actions/index.d.ts +2 -0
- package/dist/swipe-actions/index.js +2 -0
- package/dist/swipe-actions/swipe-actions.d.ts +67 -0
- package/dist/swipe-actions/swipe-actions.js +552 -0
- package/dist/swipe-actions/swipe-actions.js.map +1 -0
- package/dist/switch/switch.js +2 -2
- package/dist/switch/switch.js.map +1 -1
- package/dist/table/index.d.ts +2 -2
- package/dist/table/index.js +2 -2
- package/dist/table/table.d.ts +56 -4
- package/dist/table/table.js +340 -165
- package/dist/table/table.js.map +1 -1
- package/dist/tabs/tabs.js +2 -2
- package/dist/tabs/tabs.js.map +1 -1
- package/dist/tag-input/index.d.ts +2 -0
- package/dist/tag-input/index.js +2 -0
- package/dist/tag-input/tag-input.d.ts +40 -0
- package/dist/tag-input/tag-input.js +269 -0
- package/dist/tag-input/tag-input.js.map +1 -0
- package/dist/text-morph/index.d.ts +2 -0
- package/dist/text-morph/index.js +2 -0
- package/dist/text-morph/text-morph.d.ts +23 -0
- package/dist/text-morph/text-morph.js +21 -0
- package/dist/text-morph/text-morph.js.map +1 -0
- package/dist/text-reveal/index.d.ts +2 -0
- package/dist/text-reveal/index.js +2 -0
- package/dist/text-reveal/text-reveal.d.ts +27 -0
- package/dist/text-reveal/text-reveal.js +51 -0
- package/dist/text-reveal/text-reveal.js.map +1 -0
- package/dist/text-shimmer/index.d.ts +2 -0
- package/dist/text-shimmer/index.js +2 -0
- package/dist/text-shimmer/text-shimmer.d.ts +29 -0
- package/dist/text-shimmer/text-shimmer.js +29 -0
- package/dist/text-shimmer/text-shimmer.js.map +1 -0
- package/dist/time-picker/time-picker.js +2 -2
- package/dist/time-picker/time-picker.js.map +1 -1
- package/dist/toast/index.d.ts +2 -2
- package/dist/toast/index.js +2 -2
- package/dist/toast/toast.d.ts +6 -0
- package/dist/toast/toast.js +82 -40
- package/dist/toast/toast.js.map +1 -1
- package/dist/tooltip/tooltip.d.ts +9 -2
- package/dist/tooltip/tooltip.js +7 -7
- package/dist/tooltip/tooltip.js.map +1 -1
- package/dist/treemap/index.d.ts +2 -0
- package/dist/treemap/index.js +2 -0
- package/dist/treemap/treemap.d.ts +53 -0
- package/dist/treemap/treemap.js +699 -0
- package/dist/treemap/treemap.js.map +1 -0
- package/dist/usage-meter/index.d.ts +2 -0
- package/dist/usage-meter/index.js +2 -0
- package/dist/usage-meter/usage-meter.d.ts +50 -0
- package/dist/usage-meter/usage-meter.js +440 -0
- package/dist/usage-meter/usage-meter.js.map +1 -0
- package/dist/waffle-chart/index.d.ts +2 -0
- package/dist/waffle-chart/index.js +2 -0
- package/dist/waffle-chart/waffle-chart.d.ts +57 -0
- package/dist/waffle-chart/waffle-chart.js +426 -0
- package/dist/waffle-chart/waffle-chart.js.map +1 -0
- package/package.json +165 -3
|
@@ -0,0 +1,699 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn } from "../lib/cn.js";
|
|
3
|
+
import { mergeRefs } from "../lib/merge-refs.js";
|
|
4
|
+
import { prefersReducedMotion, useIsomorphicLayoutEffect } from "../lib/motion.js";
|
|
5
|
+
import { useCountTo } from "../lib/count-to.js";
|
|
6
|
+
import { SwapText } from "../lib/swap-text.js";
|
|
7
|
+
import { Tab as Tab$1, TabList as TabList$1, Tabs as Tabs$1 } from "../tabs/tabs.js";
|
|
8
|
+
import { forwardRef, useEffect, useId, useMemo, useRef, useState } from "react";
|
|
9
|
+
import { TabPanel } from "react-aria-components";
|
|
10
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
11
|
+
//#region src/activity-heatmap/activity-heatmap.tsx
|
|
12
|
+
const DAY = 864e5;
|
|
13
|
+
const LEVELS = [
|
|
14
|
+
0,
|
|
15
|
+
1,
|
|
16
|
+
2,
|
|
17
|
+
3,
|
|
18
|
+
4
|
|
19
|
+
];
|
|
20
|
+
/** Total wave travel in ms, kept under the system's stagger budget however many weeks the range spans. */
|
|
21
|
+
const WAVE = 420;
|
|
22
|
+
const toUtc = (iso) => Date.parse(`${iso}T00:00:00Z`);
|
|
23
|
+
const toIso = (time) => new Date(time).toISOString().slice(0, 10);
|
|
24
|
+
const CONTRIBUTIONS = {
|
|
25
|
+
one: "contribution",
|
|
26
|
+
other: "contributions"
|
|
27
|
+
};
|
|
28
|
+
const noun = (count, unit) => count === 1 ? unit.one : unit.other;
|
|
29
|
+
const clamp = (value, low, high) => Math.min(high, Math.max(low, value));
|
|
30
|
+
function buildModel(days, weekStartsOn, thresholds, locale) {
|
|
31
|
+
const dates = days.map((day) => toUtc(day.date)).filter(Number.isFinite);
|
|
32
|
+
const start = dates.length ? Math.min(...dates) : toUtc("2025-01-01");
|
|
33
|
+
const length = dates.length ? Math.round((Math.max(...dates) - start) / DAY) + 1 : 0;
|
|
34
|
+
const counts = new Array(length).fill(0);
|
|
35
|
+
for (const day of days) {
|
|
36
|
+
const index = Math.round((toUtc(day.date) - start) / DAY);
|
|
37
|
+
if (index >= 0 && index < length) counts[index] += Math.max(0, day.count);
|
|
38
|
+
}
|
|
39
|
+
const max = counts.reduce((a, b) => Math.max(a, b), 0);
|
|
40
|
+
const bounds = thresholds ?? [
|
|
41
|
+
Math.max(1, Math.ceil(max * .25)),
|
|
42
|
+
Math.max(2, Math.ceil(max * .5)),
|
|
43
|
+
Math.max(3, Math.ceil(max * .75))
|
|
44
|
+
];
|
|
45
|
+
const levels = counts.map((count) => count <= 0 ? 0 : count <= bounds[0] ? 1 : count <= bounds[1] ? 2 : count <= bounds[2] ? 3 : 4);
|
|
46
|
+
const lead = (new Date(start).getUTCDay() - weekStartsOn + 7) % 7;
|
|
47
|
+
const weeks = Math.ceil((lead + length) / 7);
|
|
48
|
+
const monthName = new Intl.DateTimeFormat(locale, {
|
|
49
|
+
month: "short",
|
|
50
|
+
timeZone: "UTC"
|
|
51
|
+
});
|
|
52
|
+
const months = [];
|
|
53
|
+
for (let index = 0; index < length; index++) {
|
|
54
|
+
const date = new Date(start + index * DAY);
|
|
55
|
+
if (index === 0 || date.getUTCDate() === 1) months.push({
|
|
56
|
+
month: date.getUTCFullYear() * 12 + date.getUTCMonth(),
|
|
57
|
+
col: Math.floor((lead + index) / 7),
|
|
58
|
+
label: monthName.format(date)
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
if (months.length > 1 && months[1].col - months[0].col < 3) months.shift();
|
|
62
|
+
const perLevel = [
|
|
63
|
+
0,
|
|
64
|
+
0,
|
|
65
|
+
0,
|
|
66
|
+
0,
|
|
67
|
+
0
|
|
68
|
+
];
|
|
69
|
+
for (const level of levels) perLevel[level]++;
|
|
70
|
+
return {
|
|
71
|
+
start,
|
|
72
|
+
length,
|
|
73
|
+
lead,
|
|
74
|
+
weeks,
|
|
75
|
+
total: counts.reduce((a, b) => a + b, 0),
|
|
76
|
+
counts,
|
|
77
|
+
levels,
|
|
78
|
+
thresholds: bounds,
|
|
79
|
+
months,
|
|
80
|
+
perLevel
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
/** The total counts to each new number on the smooth spring. */
|
|
84
|
+
function Total({ value, format }) {
|
|
85
|
+
return /* @__PURE__ */ jsx(Fragment$1, { children: format.format(useCountTo(value)) });
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* The year switch is a set of tabs, and a tab names the panel it controls: the grid is that panel. Both wrappers add no box of
|
|
89
|
+
* their own (`contents`), and with no `periods` they are not there at all.
|
|
90
|
+
*/
|
|
91
|
+
function PeriodShell({ periods, period, onPeriodChange, children }) {
|
|
92
|
+
if (!periods?.length) return /* @__PURE__ */ jsx(Fragment$1, { children });
|
|
93
|
+
return /* @__PURE__ */ jsx(Tabs$1, {
|
|
94
|
+
selectedKey: period,
|
|
95
|
+
onSelectionChange: (key) => onPeriodChange?.(String(key)),
|
|
96
|
+
className: "contents",
|
|
97
|
+
children
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
function PeriodPanel({ periods, period, children }) {
|
|
101
|
+
if (!periods?.length) return /* @__PURE__ */ jsx(Fragment$1, { children });
|
|
102
|
+
return /* @__PURE__ */ jsx(TabPanel, {
|
|
103
|
+
id: period,
|
|
104
|
+
className: "contents",
|
|
105
|
+
children
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
const ActivityHeatmap = forwardRef(function ActivityHeatmap({ days, label, period, unit: unitProp = CONTRIBUTIONS, thresholds, weekStartsOn = 0, selectedDate, defaultSelectedDate = null, onSelectDate, actions, periods, onPeriodChange, periodsLabel = "Period", describeDay, detailHint = "Hover or select a day for details.", framed = true, emptyLabel = "No activity yet", locale = "en-US", className }, ref) {
|
|
109
|
+
const id = useId();
|
|
110
|
+
const unit = useMemo(() => ({
|
|
111
|
+
one: unitProp.one,
|
|
112
|
+
other: unitProp.other
|
|
113
|
+
}), [unitProp.one, unitProp.other]);
|
|
114
|
+
const root = useRef(null);
|
|
115
|
+
const refs = useMemo(() => mergeRefs(ref, root), [ref]);
|
|
116
|
+
const plot = useRef(null);
|
|
117
|
+
const grid = useRef(null);
|
|
118
|
+
const scroller = useRef(null);
|
|
119
|
+
const ring = useRef(null);
|
|
120
|
+
const tipNode = useRef(null);
|
|
121
|
+
const tipBody = useRef(null);
|
|
122
|
+
const measure = useRef(null);
|
|
123
|
+
const model = useMemo(() => buildModel(days, weekStartsOn, thresholds, locale), [
|
|
124
|
+
days,
|
|
125
|
+
weekStartsOn,
|
|
126
|
+
thresholds,
|
|
127
|
+
locale
|
|
128
|
+
]);
|
|
129
|
+
const formats = useMemo(() => ({
|
|
130
|
+
long: new Intl.DateTimeFormat(locale, {
|
|
131
|
+
weekday: "long",
|
|
132
|
+
month: "long",
|
|
133
|
+
day: "numeric",
|
|
134
|
+
year: "numeric",
|
|
135
|
+
timeZone: "UTC"
|
|
136
|
+
}),
|
|
137
|
+
short: new Intl.DateTimeFormat(locale, {
|
|
138
|
+
weekday: "short",
|
|
139
|
+
month: "short",
|
|
140
|
+
day: "numeric",
|
|
141
|
+
year: "numeric",
|
|
142
|
+
timeZone: "UTC"
|
|
143
|
+
}),
|
|
144
|
+
day: new Intl.DateTimeFormat(locale, {
|
|
145
|
+
weekday: "long",
|
|
146
|
+
month: "long",
|
|
147
|
+
day: "numeric",
|
|
148
|
+
timeZone: "UTC"
|
|
149
|
+
}),
|
|
150
|
+
weekday: new Intl.DateTimeFormat(locale, {
|
|
151
|
+
weekday: "short",
|
|
152
|
+
timeZone: "UTC"
|
|
153
|
+
}),
|
|
154
|
+
number: new Intl.NumberFormat(locale)
|
|
155
|
+
}), [locale]);
|
|
156
|
+
const [range, setRange] = useState({
|
|
157
|
+
start: model.start,
|
|
158
|
+
direction: 1
|
|
159
|
+
});
|
|
160
|
+
if (range.start !== model.start) setRange({
|
|
161
|
+
start: model.start,
|
|
162
|
+
direction: model.start > range.start ? 1 : -1
|
|
163
|
+
});
|
|
164
|
+
const [reveal, setReveal] = useState("hidden");
|
|
165
|
+
useEffect(() => {
|
|
166
|
+
const node = plot.current;
|
|
167
|
+
if (reveal !== "hidden" || !node) return;
|
|
168
|
+
if (prefersReducedMotion() || typeof IntersectionObserver === "undefined") {
|
|
169
|
+
const frame = requestAnimationFrame(() => setReveal("done"));
|
|
170
|
+
return () => cancelAnimationFrame(frame);
|
|
171
|
+
}
|
|
172
|
+
let frame = 0;
|
|
173
|
+
const observer = new IntersectionObserver(([entry]) => {
|
|
174
|
+
if (!entry?.isIntersecting) return;
|
|
175
|
+
observer.disconnect();
|
|
176
|
+
frame = requestAnimationFrame(() => setReveal("revealing"));
|
|
177
|
+
}, { threshold: .35 });
|
|
178
|
+
observer.observe(node);
|
|
179
|
+
return () => {
|
|
180
|
+
observer.disconnect();
|
|
181
|
+
cancelAnimationFrame(frame);
|
|
182
|
+
};
|
|
183
|
+
}, [reveal]);
|
|
184
|
+
useEffect(() => {
|
|
185
|
+
if (reveal !== "revealing") return;
|
|
186
|
+
const timer = window.setTimeout(() => setReveal("done"), 1120);
|
|
187
|
+
return () => window.clearTimeout(timer);
|
|
188
|
+
}, [reveal]);
|
|
189
|
+
const [ownSelected, setOwnSelected] = useState(defaultSelectedDate);
|
|
190
|
+
const selected = selectedDate !== void 0 ? selectedDate : ownSelected;
|
|
191
|
+
const selectedIndex = selected ? Math.round((toUtc(selected) - model.start) / DAY) : -1;
|
|
192
|
+
const hasSelection = selectedIndex >= 0 && selectedIndex < model.length;
|
|
193
|
+
const select = (index) => {
|
|
194
|
+
const date = toIso(model.start + index * DAY);
|
|
195
|
+
if (selectedDate === void 0) setOwnSelected(date);
|
|
196
|
+
onSelectDate?.(date);
|
|
197
|
+
};
|
|
198
|
+
const [focusIndex, setFocusIndex] = useState(null);
|
|
199
|
+
const tabIndexDay = focusIndex !== null && focusIndex < model.length ? focusIndex : hasSelection ? selectedIndex : model.length - 1;
|
|
200
|
+
const [preview, setPreview] = useState(null);
|
|
201
|
+
const [pinned, setPinned] = useState(null);
|
|
202
|
+
const [legendFocus, setLegendFocus] = useState(0);
|
|
203
|
+
const previewTimer = useRef(0);
|
|
204
|
+
const highlight = preview ?? pinned;
|
|
205
|
+
const previewLevel = (level) => {
|
|
206
|
+
window.clearTimeout(previewTimer.current);
|
|
207
|
+
if (level !== null) setPreview(level);
|
|
208
|
+
else previewTimer.current = window.setTimeout(() => setPreview(null), 90);
|
|
209
|
+
};
|
|
210
|
+
useEffect(() => () => window.clearTimeout(previewTimer.current), []);
|
|
211
|
+
const [tip, setTip] = useState(null);
|
|
212
|
+
const [open, setOpen] = useState(false);
|
|
213
|
+
const [change, setChange] = useState(1);
|
|
214
|
+
const [session, setSession] = useState(0);
|
|
215
|
+
const [active, setActive] = useState(null);
|
|
216
|
+
const openRef = useRef(false);
|
|
217
|
+
const hideTimer = useRef(0);
|
|
218
|
+
useEffect(() => () => window.clearTimeout(hideTimer.current), []);
|
|
219
|
+
const tipFor = (index) => {
|
|
220
|
+
const count = model.counts[index];
|
|
221
|
+
const date = new Date(model.start + index * DAY);
|
|
222
|
+
return {
|
|
223
|
+
index,
|
|
224
|
+
key: `day-${toIso(date.getTime())}`,
|
|
225
|
+
primary: count ? `${formats.number.format(count)} ${noun(count, unit)}` : `No ${unit.other}`,
|
|
226
|
+
secondary: formats.short.format(date),
|
|
227
|
+
value: count
|
|
228
|
+
};
|
|
229
|
+
};
|
|
230
|
+
const [a, b, c] = model.thresholds;
|
|
231
|
+
const ranges = [
|
|
232
|
+
`no ${unit.other}`,
|
|
233
|
+
a === 1 ? `1 ${unit.one}` : `1 to ${a} ${unit.other}`,
|
|
234
|
+
`${a + 1} to ${b} ${unit.other}`,
|
|
235
|
+
`${b + 1} to ${c} ${unit.other}`,
|
|
236
|
+
`${c + 1} or more ${unit.other}`
|
|
237
|
+
];
|
|
238
|
+
const shortRanges = [
|
|
239
|
+
`no ${unit.other}`,
|
|
240
|
+
a === 1 ? `1 ${unit.one}` : `1–${a} ${unit.other}`,
|
|
241
|
+
`${a + 1}–${b} ${unit.other}`,
|
|
242
|
+
`${b + 1}–${c} ${unit.other}`,
|
|
243
|
+
`${c + 1}+ ${unit.other}`
|
|
244
|
+
];
|
|
245
|
+
const dayCount = highlight === null ? "" : `${formats.number.format(model.perLevel[highlight])} ${model.perLevel[highlight] === 1 ? "day" : "days"}`;
|
|
246
|
+
const caption = highlight === null ? "" : `${dayCount} with ${shortRanges[highlight]}`;
|
|
247
|
+
const show = (index) => {
|
|
248
|
+
window.clearTimeout(hideTimer.current);
|
|
249
|
+
const next = tipFor(index);
|
|
250
|
+
if (!openRef.current) setSession((current) => current + 1);
|
|
251
|
+
setChange(tip && openRef.current ? Math.sign(next.value - tip.value) || 1 : 1);
|
|
252
|
+
setTip(next);
|
|
253
|
+
setOpen(true);
|
|
254
|
+
setActive(index);
|
|
255
|
+
};
|
|
256
|
+
const hideSoon = (delay = 110) => {
|
|
257
|
+
window.clearTimeout(hideTimer.current);
|
|
258
|
+
hideTimer.current = window.setTimeout(() => {
|
|
259
|
+
setOpen(false);
|
|
260
|
+
setActive(null);
|
|
261
|
+
}, delay);
|
|
262
|
+
};
|
|
263
|
+
useIsomorphicLayoutEffect(() => {
|
|
264
|
+
const node = root.current;
|
|
265
|
+
const bubble = tipNode.current;
|
|
266
|
+
const body = tipBody.current;
|
|
267
|
+
const sizer = measure.current;
|
|
268
|
+
if (!tip || !node || !bubble || !body || !sizer) return;
|
|
269
|
+
const place = (glide) => {
|
|
270
|
+
const cell = grid.current?.querySelector(`[data-index="${tip.index}"]`);
|
|
271
|
+
if (!cell) return;
|
|
272
|
+
const box = node.getBoundingClientRect();
|
|
273
|
+
const at = cell.getBoundingClientRect();
|
|
274
|
+
const width = Math.ceil(sizer.getBoundingClientRect().width);
|
|
275
|
+
const half = width / 2 + 13;
|
|
276
|
+
const x = clamp(at.left - box.left - node.clientLeft + at.width / 2, half + 2, node.clientWidth - half - 2);
|
|
277
|
+
bubble.toggleAttribute("data-glide", glide);
|
|
278
|
+
bubble.style.translate = `${x}px ${at.top - box.top - node.clientTop}px`;
|
|
279
|
+
body.toggleAttribute("data-glide", glide);
|
|
280
|
+
body.style.width = `${width}px`;
|
|
281
|
+
};
|
|
282
|
+
place(open && openRef.current && !prefersReducedMotion());
|
|
283
|
+
openRef.current = open;
|
|
284
|
+
if (!open) return;
|
|
285
|
+
const follow = () => place(false);
|
|
286
|
+
const frame = scroller.current;
|
|
287
|
+
frame?.addEventListener("scroll", follow, { passive: true });
|
|
288
|
+
return () => frame?.removeEventListener("scroll", follow);
|
|
289
|
+
}, [tip, open]);
|
|
290
|
+
const indexOf = (element) => {
|
|
291
|
+
const cell = element?.closest("[data-index]");
|
|
292
|
+
return cell && grid.current?.contains(cell) ? {
|
|
293
|
+
cell,
|
|
294
|
+
index: Number(cell.dataset.index)
|
|
295
|
+
} : null;
|
|
296
|
+
};
|
|
297
|
+
const focusDay = (index) => grid.current?.querySelector(`[data-index="${index}"]`)?.focus();
|
|
298
|
+
const onGridPointerOver = (event) => {
|
|
299
|
+
const hit = indexOf(event.target);
|
|
300
|
+
if (hit) show(hit.index);
|
|
301
|
+
};
|
|
302
|
+
const onGridPointerLeave = (event) => {
|
|
303
|
+
const focused = indexOf(document.activeElement);
|
|
304
|
+
if (focused?.cell.matches(":focus-visible")) show(focused.index);
|
|
305
|
+
else hideSoon(event.pointerType === "touch" ? 2400 : 110);
|
|
306
|
+
};
|
|
307
|
+
const onGridFocus = (event) => {
|
|
308
|
+
const hit = indexOf(event.target);
|
|
309
|
+
if (!hit) return;
|
|
310
|
+
setFocusIndex(hit.index);
|
|
311
|
+
show(hit.index);
|
|
312
|
+
};
|
|
313
|
+
const onGridBlur = (event) => {
|
|
314
|
+
if (!grid.current?.contains(event.relatedTarget)) hideSoon(0);
|
|
315
|
+
};
|
|
316
|
+
const onGridKeyDown = (event) => {
|
|
317
|
+
const hit = indexOf(event.target);
|
|
318
|
+
if (!hit) return;
|
|
319
|
+
const moves = {
|
|
320
|
+
ArrowUp: hit.index - 1,
|
|
321
|
+
ArrowDown: hit.index + 1,
|
|
322
|
+
ArrowLeft: hit.index - 7,
|
|
323
|
+
ArrowRight: hit.index + 7,
|
|
324
|
+
Home: 0,
|
|
325
|
+
End: model.length - 1
|
|
326
|
+
};
|
|
327
|
+
if (event.key in moves) {
|
|
328
|
+
event.preventDefault();
|
|
329
|
+
focusDay(clamp(moves[event.key], 0, model.length - 1));
|
|
330
|
+
} else if (event.key === "Enter" || event.key === " ") {
|
|
331
|
+
event.preventDefault();
|
|
332
|
+
select(hit.index);
|
|
333
|
+
} else if (event.key === "Escape" && open) {
|
|
334
|
+
event.preventDefault();
|
|
335
|
+
setOpen(false);
|
|
336
|
+
}
|
|
337
|
+
};
|
|
338
|
+
const onLegendKeyDown = (event) => {
|
|
339
|
+
if (event.key === "Escape") {
|
|
340
|
+
previewLevel(null);
|
|
341
|
+
return;
|
|
342
|
+
}
|
|
343
|
+
const moves = {
|
|
344
|
+
ArrowLeft: legendFocus - 1,
|
|
345
|
+
ArrowRight: legendFocus + 1,
|
|
346
|
+
Home: 0,
|
|
347
|
+
End: 4
|
|
348
|
+
};
|
|
349
|
+
if (!(event.key in moves)) return;
|
|
350
|
+
event.preventDefault();
|
|
351
|
+
const next = clamp(moves[event.key], 0, 4);
|
|
352
|
+
root.current?.querySelector(`[data-level-key="${next}"]`)?.focus();
|
|
353
|
+
};
|
|
354
|
+
const ringShown = hasSelection && reveal !== "hidden";
|
|
355
|
+
const ringWasShown = useRef(ringShown);
|
|
356
|
+
useIsomorphicLayoutEffect(() => {
|
|
357
|
+
const node = ring.current;
|
|
358
|
+
if (node && ringShown && !ringWasShown.current) {
|
|
359
|
+
node.style.transitionProperty = "opacity";
|
|
360
|
+
node.offsetWidth;
|
|
361
|
+
node.style.transitionProperty = "";
|
|
362
|
+
}
|
|
363
|
+
ringWasShown.current = ringShown;
|
|
364
|
+
}, [ringShown]);
|
|
365
|
+
const maxDiagonal = Math.max(1, model.weeks - 1 + 6);
|
|
366
|
+
const step = Math.min(12, WAVE / maxDiagonal);
|
|
367
|
+
const cells = useMemo(() => Array.from({ length: 7 }, (_, row) => /* @__PURE__ */ jsx("div", {
|
|
368
|
+
role: "row",
|
|
369
|
+
"aria-hidden": Array.from({ length: model.weeks }, (_, col) => col * 7 + row - model.lead).some((index) => index >= 0 && index < model.length) ? void 0 : true,
|
|
370
|
+
className: "activity-heatmap-row",
|
|
371
|
+
children: Array.from({ length: model.weeks }, (_, col) => {
|
|
372
|
+
const index = col * 7 + row - model.lead;
|
|
373
|
+
const inRange = index >= 0 && index < model.length;
|
|
374
|
+
const wave = {
|
|
375
|
+
"--wave": `${Math.round((col + row) * step)}ms`,
|
|
376
|
+
"--wave-back": `${Math.round((maxDiagonal - col - row) * step)}ms`
|
|
377
|
+
};
|
|
378
|
+
if (!inRange) return /* @__PURE__ */ jsx("span", {
|
|
379
|
+
className: "activity-heatmap-cell",
|
|
380
|
+
"data-empty": "",
|
|
381
|
+
style: wave,
|
|
382
|
+
"aria-hidden": "true"
|
|
383
|
+
}, col);
|
|
384
|
+
const count = model.counts[index];
|
|
385
|
+
const date = new Date(model.start + index * DAY);
|
|
386
|
+
return /* @__PURE__ */ jsx("span", {
|
|
387
|
+
role: "gridcell",
|
|
388
|
+
className: "activity-heatmap-cell",
|
|
389
|
+
style: wave,
|
|
390
|
+
"data-index": index,
|
|
391
|
+
"data-level": model.levels[index],
|
|
392
|
+
tabIndex: index === tabIndexDay ? 0 : -1,
|
|
393
|
+
"aria-selected": index === selectedIndex,
|
|
394
|
+
"aria-label": `${count ? formats.number.format(count) : "No"} ${noun(count, unit)}, ${formats.long.format(date)}`,
|
|
395
|
+
onClick: () => select(index)
|
|
396
|
+
}, col);
|
|
397
|
+
})
|
|
398
|
+
}, row)), [
|
|
399
|
+
model,
|
|
400
|
+
step,
|
|
401
|
+
maxDiagonal,
|
|
402
|
+
tabIndexDay,
|
|
403
|
+
selectedIndex,
|
|
404
|
+
formats,
|
|
405
|
+
unit,
|
|
406
|
+
onSelectDate,
|
|
407
|
+
selectedDate
|
|
408
|
+
]);
|
|
409
|
+
const weekdayLabels = useMemo(() => Array.from({ length: 7 }, (_, row) => {
|
|
410
|
+
const weekday = (row + weekStartsOn) % 7;
|
|
411
|
+
return weekday % 2 === 1 ? formats.weekday.format(/* @__PURE__ */ new Date((3 + weekday) * DAY)) : "";
|
|
412
|
+
}), [formats, weekStartsOn]);
|
|
413
|
+
const detailIndex = active !== null && active < model.length ? active : hasSelection ? selectedIndex : null;
|
|
414
|
+
const spansYears = model.length > 0 && new Date(model.start).getUTCFullYear() !== new Date(model.start + (model.length - 1) * DAY).getUTCFullYear();
|
|
415
|
+
let detailText = detailHint;
|
|
416
|
+
if (describeDay !== null && detailIndex !== null) {
|
|
417
|
+
const at = new Date(model.start + detailIndex * DAY);
|
|
418
|
+
const count = model.counts[detailIndex];
|
|
419
|
+
const dayLabel = spansYears ? formats.long.format(at) : formats.day.format(at);
|
|
420
|
+
detailText = describeDay ? describeDay({
|
|
421
|
+
date: toIso(at.getTime()),
|
|
422
|
+
count,
|
|
423
|
+
label: dayLabel,
|
|
424
|
+
unit
|
|
425
|
+
}) : `${dayLabel}: ${count ? `${formats.number.format(count)} ${noun(count, unit)}` : `no ${unit.other}`}.`;
|
|
426
|
+
}
|
|
427
|
+
const selectedCol = hasSelection ? Math.floor((selectedIndex + model.lead) / 7) : 0;
|
|
428
|
+
const selectedRow = hasSelection ? (selectedIndex + model.lead) % 7 : 0;
|
|
429
|
+
const summary = `${formats.number.format(model.total)} ${noun(model.total, unit)} in ${period}`;
|
|
430
|
+
const header = unit.other.charAt(0).toUpperCase() + unit.other.slice(1);
|
|
431
|
+
return /* @__PURE__ */ jsx("div", {
|
|
432
|
+
ref: refs,
|
|
433
|
+
"data-slot": "activity-heatmap",
|
|
434
|
+
"data-framed": framed || void 0,
|
|
435
|
+
className: cn("activity-heatmap", className),
|
|
436
|
+
children: /* @__PURE__ */ jsxs(PeriodShell, {
|
|
437
|
+
periods,
|
|
438
|
+
period,
|
|
439
|
+
onPeriodChange,
|
|
440
|
+
children: [
|
|
441
|
+
/* @__PURE__ */ jsxs("div", {
|
|
442
|
+
className: "flex min-w-0 flex-wrap items-center justify-between gap-x-4 gap-y-3",
|
|
443
|
+
children: [/* @__PURE__ */ jsxs("p", {
|
|
444
|
+
className: "m-0 flex min-w-0 flex-wrap items-baseline gap-x-1 text-sm tabular-nums text-text-secondary",
|
|
445
|
+
children: [
|
|
446
|
+
/* @__PURE__ */ jsxs("span", {
|
|
447
|
+
"aria-hidden": "true",
|
|
448
|
+
className: "whitespace-nowrap font-medium text-foreground",
|
|
449
|
+
children: [
|
|
450
|
+
/* @__PURE__ */ jsx(Total, {
|
|
451
|
+
value: model.total,
|
|
452
|
+
format: formats.number
|
|
453
|
+
}),
|
|
454
|
+
" ",
|
|
455
|
+
noun(model.total, unit)
|
|
456
|
+
]
|
|
457
|
+
}),
|
|
458
|
+
/* @__PURE__ */ jsxs("span", {
|
|
459
|
+
"aria-hidden": "true",
|
|
460
|
+
className: "whitespace-nowrap",
|
|
461
|
+
children: [
|
|
462
|
+
"in",
|
|
463
|
+
" ",
|
|
464
|
+
/* @__PURE__ */ jsx(SwapText, {
|
|
465
|
+
swapKey: period,
|
|
466
|
+
className: "inline-flex",
|
|
467
|
+
children: period
|
|
468
|
+
})
|
|
469
|
+
]
|
|
470
|
+
}),
|
|
471
|
+
/* @__PURE__ */ jsx("span", {
|
|
472
|
+
className: "sr-only",
|
|
473
|
+
role: "status",
|
|
474
|
+
children: summary
|
|
475
|
+
})
|
|
476
|
+
]
|
|
477
|
+
}), actions || periods?.length ? /* @__PURE__ */ jsxs("div", {
|
|
478
|
+
className: "flex flex-none items-center gap-3",
|
|
479
|
+
children: [actions, periods?.length ? /* @__PURE__ */ jsx(TabList$1, {
|
|
480
|
+
"aria-label": periodsLabel,
|
|
481
|
+
children: periods.map((item) => /* @__PURE__ */ jsx(Tab$1, {
|
|
482
|
+
id: item,
|
|
483
|
+
children: item
|
|
484
|
+
}, item))
|
|
485
|
+
}) : null]
|
|
486
|
+
}) : null]
|
|
487
|
+
}),
|
|
488
|
+
model.length === 0 ? /* @__PURE__ */ jsx("p", {
|
|
489
|
+
className: "m-0 text-sm text-muted-foreground",
|
|
490
|
+
children: emptyLabel
|
|
491
|
+
}) : null,
|
|
492
|
+
/* @__PURE__ */ jsx(PeriodPanel, {
|
|
493
|
+
periods,
|
|
494
|
+
period,
|
|
495
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
496
|
+
className: "activity-heatmap-body",
|
|
497
|
+
hidden: model.length === 0,
|
|
498
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
499
|
+
className: "activity-heatmap-weekdays",
|
|
500
|
+
"aria-hidden": "true",
|
|
501
|
+
children: weekdayLabels.map((text, row) => /* @__PURE__ */ jsx("span", {
|
|
502
|
+
className: "activity-heatmap-weekday",
|
|
503
|
+
children: text
|
|
504
|
+
}, row))
|
|
505
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
506
|
+
ref: scroller,
|
|
507
|
+
className: "activity-heatmap-scroller",
|
|
508
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
509
|
+
className: "activity-heatmap-canvas",
|
|
510
|
+
style: { "--weeks": model.weeks },
|
|
511
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
512
|
+
className: "activity-heatmap-months",
|
|
513
|
+
"aria-hidden": "true",
|
|
514
|
+
children: model.months.map((month, order) => /* @__PURE__ */ jsx("span", {
|
|
515
|
+
className: "activity-heatmap-month",
|
|
516
|
+
style: { "--col": month.col },
|
|
517
|
+
children: month.label
|
|
518
|
+
}, `${month.month % 12}-${model.months.findIndex((item) => item.month % 12 === month.month % 12) === order ? 0 : 1}`))
|
|
519
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
520
|
+
ref: plot,
|
|
521
|
+
className: "relative",
|
|
522
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
523
|
+
ref: grid,
|
|
524
|
+
role: "grid",
|
|
525
|
+
"aria-label": label,
|
|
526
|
+
"aria-readonly": "true",
|
|
527
|
+
"aria-describedby": `${id}-legend`,
|
|
528
|
+
className: "activity-heatmap-grid",
|
|
529
|
+
"data-reveal": reveal,
|
|
530
|
+
"data-direction": range.direction < 0 ? "back" : void 0,
|
|
531
|
+
"data-highlight": highlight ?? void 0,
|
|
532
|
+
onPointerOver: onGridPointerOver,
|
|
533
|
+
onPointerLeave: onGridPointerLeave,
|
|
534
|
+
onFocus: onGridFocus,
|
|
535
|
+
onBlur: onGridBlur,
|
|
536
|
+
onKeyDown: onGridKeyDown,
|
|
537
|
+
children: cells
|
|
538
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
539
|
+
ref: ring,
|
|
540
|
+
"aria-hidden": "true",
|
|
541
|
+
"data-shown": ringShown || void 0,
|
|
542
|
+
className: "activity-heatmap-ring",
|
|
543
|
+
style: {
|
|
544
|
+
"--col": selectedCol,
|
|
545
|
+
"--row": selectedRow
|
|
546
|
+
}
|
|
547
|
+
})]
|
|
548
|
+
})]
|
|
549
|
+
})
|
|
550
|
+
})]
|
|
551
|
+
})
|
|
552
|
+
}),
|
|
553
|
+
/* @__PURE__ */ jsxs("div", {
|
|
554
|
+
className: "flex min-w-0 items-center justify-between gap-3 text-xs text-text-secondary",
|
|
555
|
+
children: [
|
|
556
|
+
/* @__PURE__ */ jsxs("span", {
|
|
557
|
+
id: `${id}-legend`,
|
|
558
|
+
className: "sr-only",
|
|
559
|
+
children: [
|
|
560
|
+
"Darker squares mean more ",
|
|
561
|
+
unit.other,
|
|
562
|
+
". Levels: ",
|
|
563
|
+
ranges.join(", "),
|
|
564
|
+
"."
|
|
565
|
+
]
|
|
566
|
+
}),
|
|
567
|
+
/* @__PURE__ */ jsxs("span", {
|
|
568
|
+
"aria-live": "polite",
|
|
569
|
+
className: "activity-heatmap-caption",
|
|
570
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
571
|
+
"aria-hidden": "true",
|
|
572
|
+
children: /* @__PURE__ */ jsxs(SwapText, {
|
|
573
|
+
swapKey: caption,
|
|
574
|
+
className: "block",
|
|
575
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
576
|
+
className: "activity-heatmap-caption-long",
|
|
577
|
+
children: caption
|
|
578
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
579
|
+
className: "activity-heatmap-caption-short",
|
|
580
|
+
children: dayCount
|
|
581
|
+
})]
|
|
582
|
+
})
|
|
583
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
584
|
+
className: "sr-only",
|
|
585
|
+
children: caption
|
|
586
|
+
})]
|
|
587
|
+
}),
|
|
588
|
+
/* @__PURE__ */ jsxs("span", {
|
|
589
|
+
className: "flex flex-none items-center gap-2",
|
|
590
|
+
children: [
|
|
591
|
+
/* @__PURE__ */ jsx("span", {
|
|
592
|
+
"aria-hidden": "true",
|
|
593
|
+
className: "leading-none",
|
|
594
|
+
children: "Less"
|
|
595
|
+
}),
|
|
596
|
+
/* @__PURE__ */ jsx("div", {
|
|
597
|
+
role: "group",
|
|
598
|
+
"aria-label": "Highlight days by level",
|
|
599
|
+
onKeyDown: onLegendKeyDown,
|
|
600
|
+
className: "flex",
|
|
601
|
+
children: LEVELS.map((level) => /* @__PURE__ */ jsx("button", {
|
|
602
|
+
type: "button",
|
|
603
|
+
className: "activity-heatmap-swatch",
|
|
604
|
+
"data-level-key": level,
|
|
605
|
+
"data-level": level,
|
|
606
|
+
tabIndex: level === legendFocus ? 0 : -1,
|
|
607
|
+
"aria-pressed": pinned === level,
|
|
608
|
+
"aria-label": `Highlight days with ${ranges[level]}`,
|
|
609
|
+
onClick: () => setPinned((current) => current === level ? null : level),
|
|
610
|
+
onPointerEnter: () => previewLevel(level),
|
|
611
|
+
onPointerLeave: () => previewLevel(null),
|
|
612
|
+
onFocus: () => {
|
|
613
|
+
setLegendFocus(level);
|
|
614
|
+
previewLevel(level);
|
|
615
|
+
},
|
|
616
|
+
onBlur: () => previewLevel(null)
|
|
617
|
+
}, level))
|
|
618
|
+
}),
|
|
619
|
+
/* @__PURE__ */ jsx("span", {
|
|
620
|
+
"aria-hidden": "true",
|
|
621
|
+
className: "leading-none",
|
|
622
|
+
children: "More"
|
|
623
|
+
})
|
|
624
|
+
]
|
|
625
|
+
})
|
|
626
|
+
]
|
|
627
|
+
}),
|
|
628
|
+
describeDay !== null && model.length > 0 ? /* @__PURE__ */ jsx("p", {
|
|
629
|
+
className: "activity-heatmap-detail",
|
|
630
|
+
children: /* @__PURE__ */ jsx(SwapText, {
|
|
631
|
+
swapKey: detailText,
|
|
632
|
+
className: "block",
|
|
633
|
+
children: detailText
|
|
634
|
+
})
|
|
635
|
+
}) : null,
|
|
636
|
+
/* @__PURE__ */ jsx("div", {
|
|
637
|
+
ref: tipNode,
|
|
638
|
+
"aria-hidden": "true",
|
|
639
|
+
"data-open": open && tip ? "" : void 0,
|
|
640
|
+
className: "activity-heatmap-tip",
|
|
641
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
642
|
+
className: "activity-heatmap-bubble",
|
|
643
|
+
children: /* @__PURE__ */ jsxs("span", {
|
|
644
|
+
ref: tipBody,
|
|
645
|
+
className: "activity-heatmap-tip-body",
|
|
646
|
+
children: [/* @__PURE__ */ jsxs("span", {
|
|
647
|
+
ref: measure,
|
|
648
|
+
className: "activity-heatmap-tip-lines absolute start-0 top-0 invisible",
|
|
649
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
650
|
+
className: "activity-heatmap-tip-primary",
|
|
651
|
+
children: tip?.primary
|
|
652
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
653
|
+
className: "activity-heatmap-tip-secondary",
|
|
654
|
+
children: tip?.secondary
|
|
655
|
+
})]
|
|
656
|
+
}), /* @__PURE__ */ jsx(SwapText, {
|
|
657
|
+
swapKey: tip?.key ?? "",
|
|
658
|
+
dir: change,
|
|
659
|
+
className: "block",
|
|
660
|
+
children: /* @__PURE__ */ jsxs("span", {
|
|
661
|
+
className: "activity-heatmap-tip-lines",
|
|
662
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
663
|
+
className: "activity-heatmap-tip-primary",
|
|
664
|
+
children: tip?.primary
|
|
665
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
666
|
+
className: "activity-heatmap-tip-secondary",
|
|
667
|
+
children: tip?.secondary
|
|
668
|
+
})]
|
|
669
|
+
})
|
|
670
|
+
}, session)]
|
|
671
|
+
})
|
|
672
|
+
})
|
|
673
|
+
}),
|
|
674
|
+
/* @__PURE__ */ jsx("div", {
|
|
675
|
+
className: "sr-only",
|
|
676
|
+
hidden: model.length === 0,
|
|
677
|
+
children: /* @__PURE__ */ jsxs("table", { children: [
|
|
678
|
+
/* @__PURE__ */ jsx("caption", { children: label }),
|
|
679
|
+
/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { children: [/* @__PURE__ */ jsx("th", {
|
|
680
|
+
scope: "col",
|
|
681
|
+
children: "Date"
|
|
682
|
+
}), /* @__PURE__ */ jsx("th", {
|
|
683
|
+
scope: "col",
|
|
684
|
+
children: header
|
|
685
|
+
})] }) }),
|
|
686
|
+
/* @__PURE__ */ jsx("tbody", { children: model.counts.map((count, index) => /* @__PURE__ */ jsxs("tr", { children: [/* @__PURE__ */ jsx("th", {
|
|
687
|
+
scope: "row",
|
|
688
|
+
children: formats.long.format(new Date(model.start + index * DAY))
|
|
689
|
+
}), /* @__PURE__ */ jsx("td", { children: formats.number.format(count) })] }, index)) })
|
|
690
|
+
] })
|
|
691
|
+
})
|
|
692
|
+
]
|
|
693
|
+
})
|
|
694
|
+
});
|
|
695
|
+
});
|
|
696
|
+
//#endregion
|
|
697
|
+
export { ActivityHeatmap };
|
|
698
|
+
|
|
699
|
+
//# sourceMappingURL=activity-heatmap.js.map
|