@zovaris/sephiro 0.14.1 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{Chart-CDJ3a_FJ.js → Chart-C3wQzNKf.js} +41 -22
- package/dist/Chart-C3wQzNKf.js.map +1 -0
- package/dist/{Table-C-SStsKz.js → Table-Db4HQGlm.js} +35 -6
- package/dist/Table-Db4HQGlm.js.map +1 -0
- package/dist/Toast-CrL3aSID.js +383 -0
- package/dist/Toast-CrL3aSID.js.map +1 -0
- package/dist/activity-heatmap.d.ts +68 -0
- package/dist/activity-heatmap.d.ts.map +1 -0
- package/dist/activity-heatmap.js +239 -0
- package/dist/activity-heatmap.js.map +1 -0
- package/dist/alert-dialog.d.ts +25 -0
- package/dist/alert-dialog.d.ts.map +1 -0
- package/dist/alert-dialog.js +44 -0
- package/dist/alert-dialog.js.map +1 -0
- package/dist/budget-summary.d.ts +44 -0
- package/dist/budget-summary.d.ts.map +1 -0
- package/dist/budget-summary.js +137 -0
- package/dist/budget-summary.js.map +1 -0
- package/dist/carousel.js +8 -5
- package/dist/carousel.js.map +1 -1
- package/dist/change-timeline.d.ts +43 -0
- package/dist/change-timeline.d.ts.map +1 -0
- package/dist/change-timeline.js +395 -0
- package/dist/change-timeline.js.map +1 -0
- package/dist/chart.d.ts +3 -1
- package/dist/chart.d.ts.map +1 -1
- package/dist/chart.js +1 -1
- package/dist/chat-scroller.js +4 -0
- package/dist/chat-scroller.js.map +1 -1
- package/dist/checkbox-group.d.ts +28 -0
- package/dist/checkbox-group.d.ts.map +1 -0
- package/dist/checkbox-group.js +87 -0
- package/dist/checkbox-group.js.map +1 -0
- package/dist/combobox.js +1 -1
- package/dist/combobox.js.map +1 -1
- package/dist/components.css +8920 -3878
- package/dist/context-menu.js +1 -1
- package/dist/context-menu.js.map +1 -1
- package/dist/context-meter.d.ts +23 -0
- package/dist/context-meter.d.ts.map +1 -0
- package/dist/context-meter.js +65 -0
- package/dist/context-meter.js.map +1 -0
- package/dist/conversation-list.d.ts +25 -0
- package/dist/conversation-list.d.ts.map +1 -0
- package/dist/conversation-list.js +99 -0
- package/dist/conversation-list.js.map +1 -0
- package/dist/copy-button.d.ts +53 -0
- package/dist/copy-button.d.ts.map +1 -0
- package/dist/copy-button.js +102 -0
- package/dist/copy-button.js.map +1 -0
- package/dist/css/activity-heatmap.css +2 -0
- package/dist/css/alert-dialog.css +8 -0
- package/dist/css/attachment.css +5 -4
- package/dist/css/badge.css +1 -1
- package/dist/css/breadcrumb.css +5 -4
- package/dist/css/budget-summary.css +74 -0
- package/dist/css/button.css +1 -1
- package/dist/css/card.css +1 -1
- package/dist/css/carousel.css +17 -10
- package/dist/css/change-timeline.css +85 -0
- package/dist/css/chart.css +5 -4
- package/dist/css/chat-input.css +5 -4
- package/dist/css/checkbox-group.css +3 -0
- package/dist/css/checkbox.css +1 -1
- package/dist/css/combobox.css +1 -73
- package/dist/css/command-palette.css +10 -9
- package/dist/css/context-meter.css +2 -0
- package/dist/css/conversation-list.css +14 -0
- package/dist/css/copy-button.css +16 -0
- package/dist/css/date-field.css +69 -0
- package/dist/css/date-time-field.css +68 -0
- package/dist/css/decay-chart.css +12 -0
- package/dist/css/dialog.css +1 -1
- package/dist/css/donut-chart.css +12 -0
- package/dist/css/dot-matrix-chart.css +12 -0
- package/dist/css/drag-to-confirm.css +45 -0
- package/dist/css/drawer.css +1 -1
- package/dist/css/empty-state.css +4 -3
- package/dist/css/event-sparkline.css +74 -0
- package/dist/css/field.css +1 -1
- package/dist/css/follow-up-suggestions.css +1 -0
- package/dist/css/gauge.css +12 -0
- package/dist/css/hover-card.css +1 -1
- package/dist/css/icon-button.css +1 -1
- package/dist/css/image-preview.css +2 -0
- package/dist/css/link.css +14 -0
- package/dist/css/menu.css +1 -73
- package/dist/css/message-actions.css +20 -0
- package/dist/css/meter.css +10 -0
- package/dist/css/metric-card.css +77 -0
- package/dist/css/middle-truncate.css +20 -0
- package/dist/css/model-picker.css +44 -0
- package/dist/css/notice.css +1 -1
- package/dist/css/otp-input.css +1 -1
- package/dist/css/overflow-list.css +1 -73
- package/dist/css/pagination.css +1 -1
- package/dist/css/password-field.css +13 -0
- package/dist/css/plan-card.css +4 -3
- package/dist/css/popconfirm.css +44 -0
- package/dist/css/popover.css +1 -1
- package/dist/css/question-card.css +4 -3
- package/dist/css/radial-progress.css +1 -0
- package/dist/css/range-slider.css +1 -0
- package/dist/css/reasoning-steps.css +5 -4
- package/dist/css/run-matrix.css +13 -0
- package/dist/css/schedule-list.css +74 -0
- package/dist/css/score-band-chart.css +85 -0
- package/dist/css/search-field.css +13 -0
- package/dist/css/select.css +5 -4
- package/dist/css/shortcut-sheet.css +3 -0
- package/dist/css/sidebar.css +2 -4
- package/dist/css/slider.css +1 -1
- package/dist/css/sources-panel.css +2 -0
- package/dist/css/sparkline.css +74 -0
- package/dist/css/spinner.css +27 -1
- package/dist/css/split-button.css +45 -0
- package/dist/css/table.css +3 -1
- package/dist/css/tag-input.css +1 -0
- package/dist/css/task-list.css +5 -4
- package/dist/css/terminal.css +15 -0
- package/dist/css/theme-asterism.css +1 -1
- package/dist/css/theme-curie.css +1 -1
- package/dist/css/theme-dark.css +1 -1
- package/dist/css/theme-default.css +1 -1
- package/dist/css/theme-fizza.css +1 -1
- package/dist/css/theme-flexoki.css +1 -0
- package/dist/css/theme-light.css +1 -1
- package/dist/css/theme-pizarra.css +1 -0
- package/dist/css/theme-pulso.css +1 -1
- package/dist/css/theme-tinta.css +1 -0
- package/dist/css/time-field.css +1 -0
- package/dist/css/timeline.css +5 -4
- package/dist/css/toast.css +68 -1
- package/dist/css/tooltip.css +1 -1
- package/dist/css/tree-view.css +1 -0
- package/dist/css/virtual-list.css +1 -0
- package/dist/curve-9YxRv2_K.js +77 -0
- package/dist/curve-9YxRv2_K.js.map +1 -0
- package/dist/date-field.d.ts +21 -0
- package/dist/date-field.d.ts.map +1 -0
- package/dist/date-field.js +93 -0
- package/dist/date-field.js.map +1 -0
- package/dist/date-time-field.d.ts +27 -0
- package/dist/date-time-field.d.ts.map +1 -0
- package/dist/date-time-field.js +66 -0
- package/dist/date-time-field.js.map +1 -0
- package/dist/decay-chart.d.ts +108 -0
- package/dist/decay-chart.d.ts.map +1 -0
- package/dist/decay-chart.js +277 -0
- package/dist/decay-chart.js.map +1 -0
- package/dist/dialog.d.ts +5 -1
- package/dist/dialog.d.ts.map +1 -1
- package/dist/dialog.js +3 -3
- package/dist/dialog.js.map +1 -1
- package/dist/donut-chart.d.ts +26 -0
- package/dist/donut-chart.d.ts.map +1 -0
- package/dist/donut-chart.js +126 -0
- package/dist/donut-chart.js.map +1 -0
- package/dist/dot-matrix-chart.d.ts +42 -0
- package/dist/dot-matrix-chart.d.ts.map +1 -0
- package/dist/dot-matrix-chart.js +237 -0
- package/dist/dot-matrix-chart.js.map +1 -0
- package/dist/drag-to-confirm.d.ts +25 -0
- package/dist/drag-to-confirm.d.ts.map +1 -0
- package/dist/drag-to-confirm.js +203 -0
- package/dist/drag-to-confirm.js.map +1 -0
- package/dist/drawer.d.ts +3 -1
- package/dist/drawer.d.ts.map +1 -1
- package/dist/drawer.js +74 -2
- package/dist/drawer.js.map +1 -1
- package/dist/event-sparkline.d.ts +37 -0
- package/dist/event-sparkline.d.ts.map +1 -0
- package/dist/event-sparkline.js +159 -0
- package/dist/event-sparkline.js.map +1 -0
- package/dist/field.js +4 -4
- package/dist/field.js.map +1 -1
- package/dist/follow-up-suggestions.d.ts +19 -0
- package/dist/follow-up-suggestions.d.ts.map +1 -0
- package/dist/follow-up-suggestions.js +50 -0
- package/dist/follow-up-suggestions.js.map +1 -0
- package/dist/gauge.d.ts +34 -0
- package/dist/gauge.d.ts.map +1 -0
- package/dist/gauge.js +179 -0
- package/dist/gauge.js.map +1 -0
- package/dist/hover-card.js +1 -1
- package/dist/hover-card.js.map +1 -1
- package/dist/image-preview.d.ts +19 -0
- package/dist/image-preview.d.ts.map +1 -0
- package/dist/image-preview.js +52 -0
- package/dist/image-preview.js.map +1 -0
- package/dist/{index-D_6Yo51i.d.ts → index-CdTFUcZD.d.ts} +6 -2
- package/dist/index-CdTFUcZD.d.ts.map +1 -0
- package/dist/index-oeGST-S6.d.ts +91 -0
- package/dist/index-oeGST-S6.d.ts.map +1 -0
- package/dist/index.css +9140 -3845
- package/dist/index.d.ts +43 -3
- package/dist/index.js +44 -4
- package/dist/link.d.ts +15 -0
- package/dist/link.d.ts.map +1 -0
- package/dist/link.js +30 -0
- package/dist/link.js.map +1 -0
- package/dist/menu.js +1 -1
- package/dist/menu.js.map +1 -1
- package/dist/message-actions.d.ts +28 -0
- package/dist/message-actions.d.ts.map +1 -0
- package/dist/message-actions.js +115 -0
- package/dist/message-actions.js.map +1 -0
- package/dist/meter.d.ts +21 -0
- package/dist/meter.d.ts.map +1 -0
- package/dist/meter.js +42 -0
- package/dist/meter.js.map +1 -0
- package/dist/metric-card.d.ts +29 -0
- package/dist/metric-card.d.ts.map +1 -0
- package/dist/metric-card.js +68 -0
- package/dist/metric-card.js.map +1 -0
- package/dist/middle-truncate.d.ts +29 -0
- package/dist/middle-truncate.d.ts.map +1 -0
- package/dist/middle-truncate.js +52 -0
- package/dist/middle-truncate.js.map +1 -0
- package/dist/model-picker.d.ts +25 -0
- package/dist/model-picker.d.ts.map +1 -0
- package/dist/model-picker.js +101 -0
- package/dist/model-picker.js.map +1 -0
- package/dist/password-field.d.ts +18 -0
- package/dist/password-field.d.ts.map +1 -0
- package/dist/password-field.js +73 -0
- package/dist/password-field.js.map +1 -0
- package/dist/popconfirm.d.ts +22 -0
- package/dist/popconfirm.d.ts.map +1 -0
- package/dist/popconfirm.js +64 -0
- package/dist/popconfirm.js.map +1 -0
- package/dist/popover.js +1 -1
- package/dist/popover.js.map +1 -1
- package/dist/radial-progress.d.ts +13 -0
- package/dist/radial-progress.d.ts.map +1 -0
- package/dist/radial-progress.js +50 -0
- package/dist/radial-progress.js.map +1 -0
- package/dist/range-slider.d.ts +24 -0
- package/dist/range-slider.d.ts.map +1 -0
- package/dist/range-slider.js +84 -0
- package/dist/range-slider.js.map +1 -0
- package/dist/run-matrix.d.ts +32 -0
- package/dist/run-matrix.d.ts.map +1 -0
- package/dist/run-matrix.js +244 -0
- package/dist/run-matrix.js.map +1 -0
- package/dist/schedule-list.d.ts +29 -0
- package/dist/schedule-list.d.ts.map +1 -0
- package/dist/schedule-list.js +72 -0
- package/dist/schedule-list.js.map +1 -0
- package/dist/score-band-chart.d.ts +41 -0
- package/dist/score-band-chart.d.ts.map +1 -0
- package/dist/score-band-chart.js +159 -0
- package/dist/score-band-chart.js.map +1 -0
- package/dist/search-field.d.ts +20 -0
- package/dist/search-field.d.ts.map +1 -0
- package/dist/search-field.js +95 -0
- package/dist/search-field.js.map +1 -0
- package/dist/select.d.ts +4 -1
- package/dist/select.d.ts.map +1 -1
- package/dist/select.js +4 -2
- package/dist/select.js.map +1 -1
- package/dist/shortcut-sheet.d.ts +27 -0
- package/dist/shortcut-sheet.d.ts.map +1 -0
- package/dist/shortcut-sheet.js +43 -0
- package/dist/shortcut-sheet.js.map +1 -0
- package/dist/sources-panel.d.ts +14 -0
- package/dist/sources-panel.d.ts.map +1 -0
- package/dist/sources-panel.js +93 -0
- package/dist/sources-panel.js.map +1 -0
- package/dist/sparkline.d.ts +21 -0
- package/dist/sparkline.d.ts.map +1 -0
- package/dist/sparkline.js +64 -0
- package/dist/sparkline.js.map +1 -0
- package/dist/spinner.d.ts +2 -1
- package/dist/spinner.d.ts.map +1 -1
- package/dist/spinner.js +3 -3
- package/dist/spinner.js.map +1 -1
- package/dist/split-button.d.ts +27 -0
- package/dist/split-button.d.ts.map +1 -0
- package/dist/split-button.js +51 -0
- package/dist/split-button.js.map +1 -0
- package/dist/table.d.ts +1 -1
- package/dist/table.js +1 -1
- package/dist/tag-input.d.ts +17 -0
- package/dist/tag-input.d.ts.map +1 -0
- package/dist/tag-input.js +85 -0
- package/dist/tag-input.js.map +1 -0
- package/dist/terminal.d.ts +37 -0
- package/dist/terminal.d.ts.map +1 -0
- package/dist/terminal.js +86 -0
- package/dist/terminal.js.map +1 -0
- package/dist/themes.css +294 -47
- package/dist/time-field.d.ts +46 -0
- package/dist/time-field.d.ts.map +1 -0
- package/dist/time-field.js +227 -0
- package/dist/time-field.js.map +1 -0
- package/dist/toast.d.ts +2 -24
- package/dist/toast.js +2 -76
- package/dist/virtual-list.d.ts +17 -0
- package/dist/virtual-list.d.ts.map +1 -0
- package/dist/virtual-list.js +79 -0
- package/dist/virtual-list.js.map +1 -0
- package/package.json +161 -1
- package/dist/Chart-CDJ3a_FJ.js.map +0 -1
- package/dist/Table-C-SStsKz.js.map +0 -1
- package/dist/index-D_6Yo51i.d.ts.map +0 -1
- package/dist/toast.d.ts.map +0 -1
- package/dist/toast.js.map +0 -1
|
@@ -0,0 +1,383 @@
|
|
|
1
|
+
import { t as cn } from "./cn-M4U2-Tak.js";
|
|
2
|
+
import { t as node } from "./node-Dr67KnBr.js";
|
|
3
|
+
import { Spinner } from "./spinner.js";
|
|
4
|
+
import { useEffect, useLayoutEffect, useRef, useState, useSyncExternalStore } from "react";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { CheckCircleIcon, InfoIcon, WarningIcon, XCircleIcon, XIcon } from "@phosphor-icons/react";
|
|
7
|
+
import { createPortal } from "react-dom";
|
|
8
|
+
import { Toaster, toast } from "sonner";
|
|
9
|
+
const toastGlyphs = {
|
|
10
|
+
neutral: /* @__PURE__ */ jsx(InfoIcon, { size: 18 }),
|
|
11
|
+
info: /* @__PURE__ */ jsx(InfoIcon, { size: 18 }),
|
|
12
|
+
success: /* @__PURE__ */ jsx(CheckCircleIcon, { size: 18 }),
|
|
13
|
+
warning: /* @__PURE__ */ jsx(WarningIcon, { size: 18 }),
|
|
14
|
+
error: /* @__PURE__ */ jsx(XCircleIcon, { size: 18 }),
|
|
15
|
+
loading: /* @__PURE__ */ jsx(Spinner, { size: "md" })
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* A 14px ring that fills clockwise, sized like the other toast glyphs so it
|
|
19
|
+
* can stand in for the icon while work is in flight.
|
|
20
|
+
*/
|
|
21
|
+
function ToastProgress({ value }) {
|
|
22
|
+
const clamped = Math.min(1, Math.max(0, value));
|
|
23
|
+
const radius = 6.25;
|
|
24
|
+
const length = 2 * Math.PI * radius;
|
|
25
|
+
return /* @__PURE__ */ jsxs("svg", {
|
|
26
|
+
className: "sph-toast-progress",
|
|
27
|
+
width: 18,
|
|
28
|
+
height: 18,
|
|
29
|
+
viewBox: "0 0 18 18",
|
|
30
|
+
role: "progressbar",
|
|
31
|
+
"aria-valuemin": 0,
|
|
32
|
+
"aria-valuemax": 100,
|
|
33
|
+
"aria-valuenow": Math.round(clamped * 100),
|
|
34
|
+
children: [/* @__PURE__ */ jsx("circle", {
|
|
35
|
+
className: "sph-toast-progress__track",
|
|
36
|
+
cx: "9",
|
|
37
|
+
cy: "9",
|
|
38
|
+
r: radius
|
|
39
|
+
}), /* @__PURE__ */ jsx("circle", {
|
|
40
|
+
className: "sph-toast-progress__value",
|
|
41
|
+
cx: "9",
|
|
42
|
+
cy: "9",
|
|
43
|
+
r: radius,
|
|
44
|
+
strokeDasharray: length,
|
|
45
|
+
strokeDashoffset: length * (1 - clamped)
|
|
46
|
+
})]
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
//#endregion
|
|
50
|
+
//#region src/molecules/Toast/spring.tsx
|
|
51
|
+
const DEFAULT_DURATION = 5e3;
|
|
52
|
+
const EXIT_MS = 180;
|
|
53
|
+
/**
|
|
54
|
+
* One toast owns the screen, so a new call morphs the live record instead of
|
|
55
|
+
* adding a second card. A new call *replaces* the content: a field it does not
|
|
56
|
+
* send is gone, not inherited from whatever toast came before. Only `update`
|
|
57
|
+
* patches, keeping the fields it leaves out.
|
|
58
|
+
*/
|
|
59
|
+
function mergeSpringToast(current, patch, seq, mode = "replace") {
|
|
60
|
+
const previous = mode === "patch" ? current : null;
|
|
61
|
+
const tone = patch.tone ?? previous?.tone ?? "neutral";
|
|
62
|
+
const title = patch.title ?? previous?.title ?? "";
|
|
63
|
+
const description = patch.description !== void 0 ? patch.description : previous?.description;
|
|
64
|
+
const action = patch.action === null ? void 0 : patch.action ?? previous?.action;
|
|
65
|
+
const progress = patch.progress === null ? void 0 : patch.progress ?? previous?.progress;
|
|
66
|
+
const meta = patch.meta !== void 0 ? patch.meta : previous?.meta;
|
|
67
|
+
const duration = patch.duration ?? previous?.duration ?? DEFAULT_DURATION;
|
|
68
|
+
const repeat = current !== null && title === current.title && tone === current.tone && description === current.description && action === current.action && progress === current.progress;
|
|
69
|
+
return {
|
|
70
|
+
id: mode === "patch" ? current?.id ?? patch.id ?? `sph-spring-toast-${seq}` : patch.id ?? `sph-spring-toast-${seq}`,
|
|
71
|
+
title,
|
|
72
|
+
description,
|
|
73
|
+
tone,
|
|
74
|
+
action,
|
|
75
|
+
progress,
|
|
76
|
+
meta,
|
|
77
|
+
duration,
|
|
78
|
+
count: repeat ? current.count + 1 : 1,
|
|
79
|
+
seq
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
/** Errors, loading and toasts with an action wait for the reader. */
|
|
83
|
+
function springDuration(record) {
|
|
84
|
+
if (record.tone === "error" || record.tone === "loading" || record.action) return 0;
|
|
85
|
+
return record.duration;
|
|
86
|
+
}
|
|
87
|
+
let live = null;
|
|
88
|
+
let seq = 0;
|
|
89
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
90
|
+
const emit = () => {
|
|
91
|
+
for (const listener of listeners) listener();
|
|
92
|
+
};
|
|
93
|
+
const subscribe = (listener) => {
|
|
94
|
+
listeners.add(listener);
|
|
95
|
+
return () => {
|
|
96
|
+
listeners.delete(listener);
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
const snapshot = () => live;
|
|
100
|
+
const serverSnapshot = () => null;
|
|
101
|
+
function show(title, options = {}) {
|
|
102
|
+
seq += 1;
|
|
103
|
+
live = mergeSpringToast(live, {
|
|
104
|
+
...options,
|
|
105
|
+
title
|
|
106
|
+
}, seq, "replace");
|
|
107
|
+
emit();
|
|
108
|
+
return live.id;
|
|
109
|
+
}
|
|
110
|
+
const springToast = Object.assign(show, {
|
|
111
|
+
success: (title, options) => show(title, {
|
|
112
|
+
...options,
|
|
113
|
+
tone: "success"
|
|
114
|
+
}),
|
|
115
|
+
error: (title, options) => show(title, {
|
|
116
|
+
...options,
|
|
117
|
+
tone: "error"
|
|
118
|
+
}),
|
|
119
|
+
warning: (title, options) => show(title, {
|
|
120
|
+
...options,
|
|
121
|
+
tone: "warning"
|
|
122
|
+
}),
|
|
123
|
+
info: (title, options) => show(title, {
|
|
124
|
+
...options,
|
|
125
|
+
tone: "neutral"
|
|
126
|
+
}),
|
|
127
|
+
loading: (title, options) => show(title, {
|
|
128
|
+
...options,
|
|
129
|
+
tone: "loading"
|
|
130
|
+
}),
|
|
131
|
+
update(id, patch) {
|
|
132
|
+
if (!live || live.id !== id) return;
|
|
133
|
+
seq += 1;
|
|
134
|
+
live = mergeSpringToast(live, patch, seq, "patch");
|
|
135
|
+
emit();
|
|
136
|
+
},
|
|
137
|
+
dismiss(id) {
|
|
138
|
+
if (!live || id !== void 0 && live.id !== id) return;
|
|
139
|
+
live = null;
|
|
140
|
+
emit();
|
|
141
|
+
},
|
|
142
|
+
async promise(promise, messages) {
|
|
143
|
+
const id = show(messages.loading, { tone: "loading" });
|
|
144
|
+
try {
|
|
145
|
+
const value = await promise;
|
|
146
|
+
springToast.update(id, {
|
|
147
|
+
tone: "success",
|
|
148
|
+
title: typeof messages.success === "function" ? messages.success(value) : messages.success
|
|
149
|
+
});
|
|
150
|
+
return value;
|
|
151
|
+
} catch (error) {
|
|
152
|
+
springToast.update(id, {
|
|
153
|
+
tone: "error",
|
|
154
|
+
title: typeof messages.error === "function" ? messages.error(error) : messages.error
|
|
155
|
+
});
|
|
156
|
+
throw error;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
const icons = {
|
|
161
|
+
neutral: toastGlyphs.neutral,
|
|
162
|
+
success: toastGlyphs.success,
|
|
163
|
+
warning: toastGlyphs.warning,
|
|
164
|
+
error: toastGlyphs.error,
|
|
165
|
+
loading: toastGlyphs.loading
|
|
166
|
+
};
|
|
167
|
+
function SpringToaster({ position = "top-center", offset = 24, label = "Notifications", className }) {
|
|
168
|
+
const record = useSyncExternalStore(subscribe, snapshot, serverSnapshot);
|
|
169
|
+
const [portaled, setPortaled] = useState(false);
|
|
170
|
+
const [exiting, setExiting] = useState(null);
|
|
171
|
+
const [paused, setPaused] = useState(false);
|
|
172
|
+
const last = useRef(null);
|
|
173
|
+
const card = useRef(null);
|
|
174
|
+
const size = useRef(null);
|
|
175
|
+
useEffect(() => setPortaled(true), []);
|
|
176
|
+
useEffect(() => {
|
|
177
|
+
if (record) {
|
|
178
|
+
last.current = record;
|
|
179
|
+
setExiting(null);
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
const previous = last.current;
|
|
183
|
+
if (!previous) return;
|
|
184
|
+
setExiting(previous);
|
|
185
|
+
const timer = window.setTimeout(() => {
|
|
186
|
+
last.current = null;
|
|
187
|
+
setExiting(null);
|
|
188
|
+
}, EXIT_MS);
|
|
189
|
+
return () => window.clearTimeout(timer);
|
|
190
|
+
}, [record]);
|
|
191
|
+
const active = record ?? exiting;
|
|
192
|
+
const closing = record === null && exiting !== null;
|
|
193
|
+
useLayoutEffect(() => {
|
|
194
|
+
const element = card.current;
|
|
195
|
+
if (!element || closing) {
|
|
196
|
+
size.current = null;
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
element.style.width = "";
|
|
200
|
+
element.style.height = "";
|
|
201
|
+
const body = element.querySelector(".sph-spring-toast__body");
|
|
202
|
+
if (body) {
|
|
203
|
+
body.style.flex = "";
|
|
204
|
+
body.style.width = "";
|
|
205
|
+
}
|
|
206
|
+
const next = {
|
|
207
|
+
width: element.offsetWidth,
|
|
208
|
+
height: element.offsetHeight
|
|
209
|
+
};
|
|
210
|
+
const previous = size.current;
|
|
211
|
+
size.current = next;
|
|
212
|
+
if (!previous || Math.abs(previous.width - next.width) < 1 && Math.abs(previous.height - next.height) < 1) return;
|
|
213
|
+
if (body) {
|
|
214
|
+
body.style.flex = "none";
|
|
215
|
+
body.style.width = `${Math.ceil(body.getBoundingClientRect().width)}px`;
|
|
216
|
+
}
|
|
217
|
+
element.style.width = `${previous.width}px`;
|
|
218
|
+
element.style.height = `${previous.height}px`;
|
|
219
|
+
element.getBoundingClientRect();
|
|
220
|
+
element.style.width = `${next.width}px`;
|
|
221
|
+
element.style.height = `${next.height}px`;
|
|
222
|
+
const settle = window.setTimeout(() => {
|
|
223
|
+
element.style.width = "";
|
|
224
|
+
element.style.height = "";
|
|
225
|
+
if (body) {
|
|
226
|
+
body.style.flex = "";
|
|
227
|
+
body.style.width = "";
|
|
228
|
+
}
|
|
229
|
+
}, 520);
|
|
230
|
+
return () => window.clearTimeout(settle);
|
|
231
|
+
}, [
|
|
232
|
+
active?.seq,
|
|
233
|
+
active?.count,
|
|
234
|
+
closing
|
|
235
|
+
]);
|
|
236
|
+
useEffect(() => {
|
|
237
|
+
if (!record || paused) return;
|
|
238
|
+
const ms = springDuration(record);
|
|
239
|
+
if (!ms) return;
|
|
240
|
+
const timer = window.setTimeout(() => springToast.dismiss(record.id), ms);
|
|
241
|
+
return () => window.clearTimeout(timer);
|
|
242
|
+
}, [record, paused]);
|
|
243
|
+
useEffect(() => {
|
|
244
|
+
if (!record) return;
|
|
245
|
+
const onKeyDown = (event) => {
|
|
246
|
+
if (event.key === "Escape") springToast.dismiss();
|
|
247
|
+
};
|
|
248
|
+
document.addEventListener("keydown", onKeyDown);
|
|
249
|
+
return () => document.removeEventListener("keydown", onKeyDown);
|
|
250
|
+
}, [record]);
|
|
251
|
+
if (!portaled || !active) return null;
|
|
252
|
+
const action = active.action;
|
|
253
|
+
return createPortal(/* @__PURE__ */ jsx("section", {
|
|
254
|
+
className: cn("sph-spring-toast-region", className),
|
|
255
|
+
"data-position": position,
|
|
256
|
+
"aria-label": label,
|
|
257
|
+
style: {
|
|
258
|
+
top: position.startsWith("top") ? offset : void 0,
|
|
259
|
+
bottom: position.startsWith("bottom") ? offset : void 0
|
|
260
|
+
},
|
|
261
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
262
|
+
ref: card,
|
|
263
|
+
className: "sph-spring-toast",
|
|
264
|
+
"data-tone": active.tone,
|
|
265
|
+
"data-closing": closing || void 0,
|
|
266
|
+
role: active.tone === "error" ? "alert" : "status",
|
|
267
|
+
"aria-atomic": "true",
|
|
268
|
+
tabIndex: -1,
|
|
269
|
+
onPointerEnter: () => setPaused(true),
|
|
270
|
+
onPointerLeave: () => setPaused(false),
|
|
271
|
+
onFocus: () => setPaused(true),
|
|
272
|
+
onBlur: () => setPaused(false),
|
|
273
|
+
children: [
|
|
274
|
+
/* @__PURE__ */ jsx("span", {
|
|
275
|
+
className: "sph-spring-toast__icon",
|
|
276
|
+
"aria-hidden": "true",
|
|
277
|
+
children: active.progress !== void 0 ? /* @__PURE__ */ jsx(ToastProgress, { value: active.progress }) : /* @__PURE__ */ jsx("span", { children: node(icons[active.tone]) }, active.tone)
|
|
278
|
+
}),
|
|
279
|
+
/* @__PURE__ */ jsxs("span", {
|
|
280
|
+
className: "sph-spring-toast__body",
|
|
281
|
+
children: [/* @__PURE__ */ jsxs("span", {
|
|
282
|
+
className: "sph-spring-toast__title",
|
|
283
|
+
children: [node(active.title), active.count > 1 && /* @__PURE__ */ jsxs("span", {
|
|
284
|
+
className: "sph-spring-toast__count",
|
|
285
|
+
children: ["×", active.count]
|
|
286
|
+
})]
|
|
287
|
+
}), active.description !== void 0 && /* @__PURE__ */ jsx("span", {
|
|
288
|
+
className: "sph-spring-toast__description",
|
|
289
|
+
children: node(active.description)
|
|
290
|
+
})]
|
|
291
|
+
}, `${active.tone}:${String(active.title)}`),
|
|
292
|
+
action && /* @__PURE__ */ jsx("button", {
|
|
293
|
+
type: "button",
|
|
294
|
+
className: "sph-spring-toast__action",
|
|
295
|
+
onClick: () => {
|
|
296
|
+
const patch = action.onClick?.();
|
|
297
|
+
if (patch) springToast.update(active.id, patch);
|
|
298
|
+
else springToast.dismiss(active.id);
|
|
299
|
+
},
|
|
300
|
+
children: node(action.label)
|
|
301
|
+
}),
|
|
302
|
+
/* @__PURE__ */ jsx("button", {
|
|
303
|
+
type: "button",
|
|
304
|
+
className: "sph-spring-toast__close",
|
|
305
|
+
"aria-label": "Dismiss notification",
|
|
306
|
+
onClick: () => springToast.dismiss(active.id),
|
|
307
|
+
children: /* @__PURE__ */ jsx(XIcon, {
|
|
308
|
+
size: 12,
|
|
309
|
+
"aria-hidden": "true"
|
|
310
|
+
})
|
|
311
|
+
})
|
|
312
|
+
]
|
|
313
|
+
})
|
|
314
|
+
}), document.body);
|
|
315
|
+
}
|
|
316
|
+
//#endregion
|
|
317
|
+
//#region src/molecules/Toast/index.tsx
|
|
318
|
+
const wrap = (glyph) => /* @__PURE__ */ jsx("span", {
|
|
319
|
+
className: "sph-toast__status-icon",
|
|
320
|
+
children: node(glyph)
|
|
321
|
+
});
|
|
322
|
+
const toastIcons = {
|
|
323
|
+
success: wrap(toastGlyphs.success),
|
|
324
|
+
info: wrap(toastGlyphs.info),
|
|
325
|
+
warning: wrap(toastGlyphs.warning),
|
|
326
|
+
error: wrap(toastGlyphs.error),
|
|
327
|
+
loading: wrap(toastGlyphs.loading)
|
|
328
|
+
};
|
|
329
|
+
function Toast({ open = true, id, title, description, variant = "neutral", action, duration, closeButton = true, className }) {
|
|
330
|
+
useEffect(() => {
|
|
331
|
+
if (!open) return;
|
|
332
|
+
const options = {
|
|
333
|
+
id,
|
|
334
|
+
action,
|
|
335
|
+
closeButton,
|
|
336
|
+
description: node(description),
|
|
337
|
+
duration,
|
|
338
|
+
className: cn("sph-toast", className),
|
|
339
|
+
unstyled: true
|
|
340
|
+
};
|
|
341
|
+
const toastId = variant === "success" ? toast.success(node(title), options) : variant === "warning" ? toast.warning(node(title), options) : variant === "danger" ? toast.error(node(title), options) : toast(node(title), options);
|
|
342
|
+
return () => {
|
|
343
|
+
toast.dismiss(toastId);
|
|
344
|
+
};
|
|
345
|
+
}, [
|
|
346
|
+
open,
|
|
347
|
+
id,
|
|
348
|
+
action,
|
|
349
|
+
closeButton,
|
|
350
|
+
duration,
|
|
351
|
+
title,
|
|
352
|
+
description,
|
|
353
|
+
variant
|
|
354
|
+
]);
|
|
355
|
+
return null;
|
|
356
|
+
}
|
|
357
|
+
function ToastViewport({ label = "Notifications", className, toastOptions, theme = "system", position = "top-right", closeButton = true, expand = false, gap = 8, ...props }) {
|
|
358
|
+
const [portaled, setPortaled] = useState(false);
|
|
359
|
+
useEffect(() => setPortaled(true), []);
|
|
360
|
+
const toaster = /* @__PURE__ */ jsx(Toaster, {
|
|
361
|
+
...node(props),
|
|
362
|
+
theme,
|
|
363
|
+
position,
|
|
364
|
+
closeButton,
|
|
365
|
+
icons: toastIcons,
|
|
366
|
+
containerAriaLabel: label,
|
|
367
|
+
expand,
|
|
368
|
+
gap,
|
|
369
|
+
className: cn("sph-toast-viewport", className),
|
|
370
|
+
toastOptions: {
|
|
371
|
+
...toastOptions,
|
|
372
|
+
closeButton: toastOptions?.closeButton ?? closeButton,
|
|
373
|
+
closeButtonAriaLabel: toastOptions?.closeButtonAriaLabel ?? "Dismiss notification",
|
|
374
|
+
className: cn("sph-toast", toastOptions?.className),
|
|
375
|
+
unstyled: true
|
|
376
|
+
}
|
|
377
|
+
});
|
|
378
|
+
return portaled ? createPortal(toaster, document.body) : toaster;
|
|
379
|
+
}
|
|
380
|
+
//#endregion
|
|
381
|
+
export { springToast as a, SpringToaster as i, ToastViewport as n, ToastProgress as o, toast as r, Toast as t };
|
|
382
|
+
|
|
383
|
+
//# sourceMappingURL=Toast-CrL3aSID.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Toast-CrL3aSID.js","names":["SonnerToaster"],"sources":["../src/molecules/Toast/icons.tsx","../src/molecules/Toast/spring.tsx","../src/molecules/Toast/index.tsx"],"sourcesContent":["import {\n CheckCircleIcon,\n InfoIcon,\n WarningIcon,\n XCircleIcon,\n} from \"@phosphor-icons/react\";\nimport { Spinner } from \"@/atoms/Spinner/index.js\";\n\n/**\n * Every toast glyph sits in an 18px box. Phosphor pads its artwork, so an 18px\n * glyph draws a ~14px mark, the same as the 14px spinner and progress ring.\n */\nexport const TOAST_ICON_SIZE = 18;\n\nexport const toastGlyphs = {\n neutral: <InfoIcon size={TOAST_ICON_SIZE} />,\n info: <InfoIcon size={TOAST_ICON_SIZE} />,\n success: <CheckCircleIcon size={TOAST_ICON_SIZE} />,\n warning: <WarningIcon size={TOAST_ICON_SIZE} />,\n error: <XCircleIcon size={TOAST_ICON_SIZE} />,\n loading: <Spinner size=\"md\" />,\n};\n\nexport type ToastProgressProps = {\n /** 0 to 1. */\n value: number;\n};\n\n/**\n * A 14px ring that fills clockwise, sized like the other toast glyphs so it\n * can stand in for the icon while work is in flight.\n */\nexport function ToastProgress({ value }: ToastProgressProps) {\n const clamped = Math.min(1, Math.max(0, value));\n const radius = 6.25;\n const length = 2 * Math.PI * radius;\n return (\n <svg\n className=\"sph-toast-progress\"\n width={TOAST_ICON_SIZE}\n height={TOAST_ICON_SIZE}\n viewBox=\"0 0 18 18\"\n role=\"progressbar\"\n aria-valuemin={0}\n aria-valuemax={100}\n aria-valuenow={Math.round(clamped * 100)}\n >\n <circle className=\"sph-toast-progress__track\" cx=\"9\" cy=\"9\" r={radius} />\n <circle\n className=\"sph-toast-progress__value\"\n cx=\"9\"\n cy=\"9\"\n r={radius}\n strokeDasharray={length}\n strokeDashoffset={length * (1 - clamped)}\n />\n </svg>\n );\n}\n","import { XIcon } from \"@phosphor-icons/react\";\nimport { cn } from \"@/lib/cn.js\";\nimport { node, type Renderable } from \"@/lib/node.js\";\nimport {\n useEffect,\n useLayoutEffect,\n useRef,\n useState,\n useSyncExternalStore,\n} from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { ToastProgress, toastGlyphs } from \"./icons\";\n\nconst DEFAULT_DURATION = 5000;\nconst EXIT_MS = 180;\n\nexport type SpringToastPosition =\n | \"top-left\"\n | \"top-center\"\n | \"top-right\"\n | \"bottom-left\"\n | \"bottom-center\"\n | \"bottom-right\";\n\nexport type SpringToastTone =\n | \"neutral\"\n | \"success\"\n | \"warning\"\n | \"error\"\n | \"loading\";\n\nexport type SpringToastAction = {\n label: Renderable;\n /** Return a patch to morph the toast in place instead of closing it. */\n onClick?: () => SpringToastPatch | void;\n};\n\nexport type SpringToastPatch = {\n title?: Renderable;\n description?: Renderable;\n tone?: SpringToastTone;\n action?: SpringToastAction | null;\n progress?: number | null;\n meta?: Renderable;\n duration?: number;\n};\n\nexport type SpringToastOptions = SpringToastPatch & { id?: string };\n\nexport type SpringToastRecord = {\n id: string;\n title: Renderable;\n description?: Renderable;\n tone: SpringToastTone;\n action?: SpringToastAction;\n progress?: number;\n meta?: Renderable;\n duration: number;\n count: number;\n seq: number;\n};\n\n/**\n * One toast owns the screen, so a new call morphs the live record instead of\n * adding a second card. A new call *replaces* the content: a field it does not\n * send is gone, not inherited from whatever toast came before. Only `update`\n * patches, keeping the fields it leaves out.\n */\nexport function mergeSpringToast(\n current: SpringToastRecord | null,\n patch: SpringToastOptions,\n seq: number,\n mode: \"replace\" | \"patch\" = \"replace\",\n): SpringToastRecord {\n const previous = mode === \"patch\" ? current : null;\n const tone = patch.tone ?? previous?.tone ?? \"neutral\";\n const title = patch.title ?? previous?.title ?? \"\";\n const description =\n patch.description !== undefined ? patch.description : previous?.description;\n const action =\n patch.action === null ? undefined : (patch.action ?? previous?.action);\n const progress =\n patch.progress === null\n ? undefined\n : (patch.progress ?? previous?.progress);\n const meta = patch.meta !== undefined ? patch.meta : previous?.meta;\n const duration = patch.duration ?? previous?.duration ?? DEFAULT_DURATION;\n\n const repeat =\n current !== null &&\n title === current.title &&\n tone === current.tone &&\n description === current.description &&\n action === current.action &&\n progress === current.progress;\n\n return {\n // A new call owns a new id, so a delayed update from an older caller is\n // ignored instead of rewriting whatever toast is on screen by then. Only a\n // patch (or an explicit id) targets the card that is already live.\n id:\n mode === \"patch\"\n ? (current?.id ?? patch.id ?? `sph-spring-toast-${seq}`)\n : (patch.id ?? `sph-spring-toast-${seq}`),\n title,\n description,\n tone,\n action,\n progress,\n meta,\n duration,\n count: repeat ? current.count + 1 : 1,\n seq,\n };\n}\n\n/** Errors, loading and toasts with an action wait for the reader. */\nexport function springDuration(\n record: Pick<SpringToastRecord, \"tone\" | \"action\" | \"duration\">,\n): number {\n if (record.tone === \"error\" || record.tone === \"loading\" || record.action)\n return 0;\n return record.duration;\n}\n\nlet live: SpringToastRecord | null = null;\nlet seq = 0;\nconst listeners = new Set<() => void>();\nconst emit = () => {\n for (const listener of listeners) listener();\n};\nconst subscribe = (listener: () => void) => {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n};\nconst snapshot = () => live;\nconst serverSnapshot = () => null;\n\nfunction show(title: Renderable, options: SpringToastOptions = {}): string {\n seq += 1;\n live = mergeSpringToast(live, { ...options, title }, seq, \"replace\");\n emit();\n return live.id;\n}\n\nexport const springToast = Object.assign(show, {\n success: (title: Renderable, options?: SpringToastOptions) =>\n show(title, { ...options, tone: \"success\" }),\n error: (title: Renderable, options?: SpringToastOptions) =>\n show(title, { ...options, tone: \"error\" }),\n warning: (title: Renderable, options?: SpringToastOptions) =>\n show(title, { ...options, tone: \"warning\" }),\n info: (title: Renderable, options?: SpringToastOptions) =>\n show(title, { ...options, tone: \"neutral\" }),\n loading: (title: Renderable, options?: SpringToastOptions) =>\n show(title, { ...options, tone: \"loading\" }),\n update(id: string, patch: SpringToastPatch) {\n if (!live || live.id !== id) return;\n seq += 1;\n live = mergeSpringToast(live, patch, seq, \"patch\");\n emit();\n },\n dismiss(id?: string) {\n if (!live || (id !== undefined && live.id !== id)) return;\n live = null;\n emit();\n },\n async promise<T>(\n promise: Promise<T>,\n messages: {\n loading: Renderable;\n success: Renderable | ((value: T) => Renderable);\n error: Renderable | ((error: unknown) => Renderable);\n },\n ): Promise<T> {\n const id = show(messages.loading, { tone: \"loading\" });\n try {\n const value = await promise;\n springToast.update(id, {\n tone: \"success\",\n title:\n typeof messages.success === \"function\"\n ? messages.success(value)\n : messages.success,\n });\n return value;\n } catch (error) {\n springToast.update(id, {\n tone: \"error\",\n title:\n typeof messages.error === \"function\"\n ? messages.error(error)\n : messages.error,\n });\n throw error;\n }\n },\n});\n\nconst icons: Record<SpringToastTone, Renderable> = {\n neutral: toastGlyphs.neutral,\n success: toastGlyphs.success,\n warning: toastGlyphs.warning,\n error: toastGlyphs.error,\n loading: toastGlyphs.loading,\n};\n\nexport type SpringToasterProps = {\n position?: SpringToastPosition;\n /** Distance from the viewport edge; raise it to clear a sticky header. */\n offset?: number;\n label?: string;\n className?: string;\n};\n\nexport function SpringToaster({\n position = \"top-center\",\n offset = 24,\n label = \"Notifications\",\n className,\n}: SpringToasterProps) {\n const record = useSyncExternalStore(subscribe, snapshot, serverSnapshot);\n const [portaled, setPortaled] = useState(false);\n const [exiting, setExiting] = useState<SpringToastRecord | null>(null);\n const [paused, setPaused] = useState(false);\n const last = useRef<SpringToastRecord | null>(null);\n const card = useRef<HTMLDivElement>(null);\n const size = useRef<{ width: number; height: number } | null>(null);\n\n useEffect(() => setPortaled(true), []);\n\n // Keep the closed card on screen long enough to play its exit.\n useEffect(() => {\n if (record) {\n last.current = record;\n setExiting(null);\n return;\n }\n const previous = last.current;\n if (!previous) return;\n setExiting(previous);\n const timer = window.setTimeout(() => {\n last.current = null;\n setExiting(null);\n }, EXIT_MS);\n return () => window.clearTimeout(timer);\n }, [record]);\n\n const active = record ?? exiting;\n const closing = record === null && exiting !== null;\n\n // Morph the island between records: pin the old box, let the browser take\n // the new one as the transition target, then hand control back to auto so\n // the next change can measure again.\n useLayoutEffect(() => {\n const element = card.current;\n if (!element || closing) {\n size.current = null;\n return;\n }\n element.style.width = \"\";\n element.style.height = \"\";\n const body = element.querySelector<HTMLElement>(\".sph-spring-toast__body\");\n if (body) {\n body.style.flex = \"\";\n body.style.width = \"\";\n }\n const next = { width: element.offsetWidth, height: element.offsetHeight };\n const previous = size.current;\n size.current = next;\n if (\n !previous ||\n (Math.abs(previous.width - next.width) < 1 &&\n Math.abs(previous.height - next.height) < 1)\n )\n return;\n // Lock the content at its final layout so text does not reflow while the\n // island's box springs between sizes; the island clips it meanwhile.\n if (body) {\n body.style.flex = \"none\";\n body.style.width = `${Math.ceil(body.getBoundingClientRect().width)}px`;\n }\n element.style.width = `${previous.width}px`;\n element.style.height = `${previous.height}px`;\n element.getBoundingClientRect();\n element.style.width = `${next.width}px`;\n element.style.height = `${next.height}px`;\n const settle = window.setTimeout(() => {\n element.style.width = \"\";\n element.style.height = \"\";\n if (body) {\n body.style.flex = \"\";\n body.style.width = \"\";\n }\n }, 520);\n return () => window.clearTimeout(settle);\n }, [active?.seq, active?.count, closing]);\n\n useEffect(() => {\n if (!record || paused) return;\n const ms = springDuration(record);\n if (!ms) return;\n const timer = window.setTimeout(() => springToast.dismiss(record.id), ms);\n return () => window.clearTimeout(timer);\n }, [record, paused]);\n\n useEffect(() => {\n if (!record) return;\n const onKeyDown = (event: KeyboardEvent) => {\n if (event.key === \"Escape\") springToast.dismiss();\n };\n document.addEventListener(\"keydown\", onKeyDown);\n return () => document.removeEventListener(\"keydown\", onKeyDown);\n }, [record]);\n\n if (!portaled || !active) return null;\n\n const action = active.action;\n\n return createPortal(\n <section\n className={cn(\"sph-spring-toast-region\", className)}\n data-position={position}\n aria-label={label}\n style={{\n top: position.startsWith(\"top\") ? offset : undefined,\n bottom: position.startsWith(\"bottom\") ? offset : undefined,\n }}\n >\n <div\n ref={card}\n className=\"sph-spring-toast\"\n data-tone={active.tone}\n data-closing={closing || undefined}\n role={active.tone === \"error\" ? \"alert\" : \"status\"}\n aria-atomic=\"true\"\n tabIndex={-1}\n onPointerEnter={() => setPaused(true)}\n onPointerLeave={() => setPaused(false)}\n onFocus={() => setPaused(true)}\n onBlur={() => setPaused(false)}\n >\n <span className=\"sph-spring-toast__icon\" aria-hidden=\"true\">\n {active.progress !== undefined ? (\n <ToastProgress value={active.progress} />\n ) : (\n <span key={active.tone}>{node(icons[active.tone])}</span>\n )}\n </span>\n <span\n key={`${active.tone}:${String(active.title)}`}\n className=\"sph-spring-toast__body\"\n >\n <span className=\"sph-spring-toast__title\">\n {node(active.title)}\n {active.count > 1 && (\n <span className=\"sph-spring-toast__count\">×{active.count}</span>\n )}\n </span>\n {active.description !== undefined && (\n <span className=\"sph-spring-toast__description\">\n {node(active.description)}\n </span>\n )}\n </span>\n {action && (\n <button\n type=\"button\"\n className=\"sph-spring-toast__action\"\n onClick={() => {\n const patch = action.onClick?.();\n if (patch) springToast.update(active.id, patch);\n else springToast.dismiss(active.id);\n }}\n >\n {node(action.label)}\n </button>\n )}\n <button\n type=\"button\"\n className=\"sph-spring-toast__close\"\n aria-label=\"Dismiss notification\"\n onClick={() => springToast.dismiss(active.id)}\n >\n <XIcon size={12} aria-hidden=\"true\" />\n </button>\n </div>\n </section>,\n document.body,\n );\n}\n","import { cn } from \"@/lib/cn.js\";\nimport { useEffect, useState } from \"react\";\nimport { toastGlyphs } from \"./icons\";\nimport { createPortal } from \"react-dom\";\nimport {\n type ExternalToast,\n Toaster as SonnerToaster,\n type ToasterProps as SonnerToasterProps,\n toast,\n} from \"sonner\";\nimport { node, type Renderable } from \"@/lib/node.js\";\n\nexport type { ExternalToast } from \"sonner\";\nexport { toast };\nexport { ToastProgress, type ToastProgressProps } from \"./icons\";\nexport {\n SpringToaster,\n type SpringToasterProps,\n springToast,\n type SpringToastAction,\n type SpringToastOptions,\n type SpringToastPatch,\n type SpringToastPosition,\n type SpringToastRecord,\n type SpringToastTone,\n} from \"./spring\";\n\nconst wrap = (glyph: Renderable) => (\n <span className=\"sph-toast__status-icon\">{node(glyph)}</span>\n);\n\nconst toastIcons = {\n success: wrap(toastGlyphs.success),\n info: wrap(toastGlyphs.info),\n warning: wrap(toastGlyphs.warning),\n error: wrap(toastGlyphs.error),\n loading: wrap(toastGlyphs.loading),\n};\n\nexport type ToastProps = {\n open?: boolean;\n id?: string | number;\n title: Renderable;\n description?: Renderable;\n variant?: \"neutral\" | \"success\" | \"warning\" | \"danger\";\n action?: ExternalToast[\"action\"];\n duration?: number;\n closeButton?: boolean;\n className?: string;\n};\n\nexport function Toast({\n open = true,\n id,\n title,\n description,\n variant = \"neutral\",\n action,\n duration,\n closeButton = true,\n className,\n}: ToastProps) {\n useEffect(() => {\n if (!open) return;\n const options: ExternalToast = {\n id,\n action,\n closeButton,\n description: node(description),\n duration,\n className: cn(\"sph-toast\", className),\n unstyled: true,\n };\n const toastId =\n variant === \"success\"\n ? toast.success(node(title), options)\n : variant === \"warning\"\n ? toast.warning(node(title), options)\n : variant === \"danger\"\n ? toast.error(node(title), options)\n : toast(node(title), options);\n\n return () => {\n toast.dismiss(toastId);\n };\n }, [open, id, action, closeButton, duration, title, description, variant]);\n\n return null;\n}\n\nexport type ToastViewportProps = Omit<\n SonnerToasterProps,\n \"className\" | \"containerAriaLabel\" | \"icons\" | \"toastOptions\"\n> & {\n label?: string;\n className?: string;\n toastOptions?: SonnerToasterProps[\"toastOptions\"];\n};\n\nexport function ToastViewport({\n label = \"Notifications\",\n className,\n toastOptions,\n theme = \"system\",\n position = \"top-right\",\n closeButton = true,\n expand = false,\n gap = 8,\n ...props\n}: ToastViewportProps) {\n const [portaled, setPortaled] = useState(false);\n useEffect(() => setPortaled(true), []);\n\n const toaster = (\n <SonnerToaster\n {...node(props)}\n theme={theme}\n position={position}\n closeButton={closeButton}\n icons={toastIcons}\n containerAriaLabel={label}\n expand={expand}\n gap={gap}\n className={cn(\"sph-toast-viewport\", className)}\n toastOptions={{\n ...toastOptions,\n closeButton: toastOptions?.closeButton ?? closeButton,\n closeButtonAriaLabel:\n toastOptions?.closeButtonAriaLabel ?? \"Dismiss notification\",\n className: cn(\"sph-toast\", toastOptions?.className),\n unstyled: true,\n }}\n />\n );\n\n // Sonner mounts where it is rendered, so an ancestor with `isolation` or a\n // transform traps it in that stacking context and the toast paints under a\n // sticky header however high its z-index is. Portal it to the document.\n return portaled ? createPortal(toaster, document.body) : toaster;\n}\n"],"mappings":";;;;;;;;AAcA,MAAa,cAAc;CACzB,SAAS,oBAAC,UAAD,EAAU,MAAA,GAAwB,CAAA;CAC3C,MAAM,oBAAC,UAAD,EAAU,MAAA,GAAwB,CAAA;CACxC,SAAS,oBAAC,iBAAD,EAAiB,MAAA,GAAwB,CAAA;CAClD,SAAS,oBAAC,aAAD,EAAa,MAAA,GAAwB,CAAA;CAC9C,OAAO,oBAAC,aAAD,EAAa,MAAA,GAAwB,CAAA;CAC5C,SAAS,oBAAC,SAAD,EAAS,MAAK,KAAM,CAAA;AAC/B;;;;;AAWA,SAAgB,cAAc,EAAE,SAA6B;CAC3D,MAAM,UAAU,KAAK,IAAI,GAAG,KAAK,IAAI,GAAG,KAAK,CAAC;CAC9C,MAAM,SAAS;CACf,MAAM,SAAS,IAAI,KAAK,KAAK;CAC7B,OACE,qBAAC,OAAD;EACE,WAAU;EACV,OAAA;EACA,QAAA;EACA,SAAQ;EACR,MAAK;EACL,iBAAe;EACf,iBAAe;EACf,iBAAe,KAAK,MAAM,UAAU,GAAG;EARzC,UAAA,CAUE,oBAAC,UAAD;GAAQ,WAAU;GAA4B,IAAG;GAAI,IAAG;GAAI,GAAG;EAAS,CAAA,GACxE,oBAAC,UAAD;GACE,WAAU;GACV,IAAG;GACH,IAAG;GACH,GAAG;GACH,iBAAiB;GACjB,kBAAkB,UAAU,IAAI;EACjC,CAAA,CACE;;AAET;;;AC7CA,MAAM,mBAAmB;AACzB,MAAM,UAAU;;;;;;;AAsDhB,SAAgB,iBACd,SACA,OACA,KACA,OAA4B,WACT;CACnB,MAAM,WAAW,SAAS,UAAU,UAAU;CAC9C,MAAM,OAAO,MAAM,QAAQ,UAAU,QAAQ;CAC7C,MAAM,QAAQ,MAAM,SAAS,UAAU,SAAS;CAChD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E,cAAc,wBAAwB;GACxC,WAAW,GAAG,aAAa,cAAc,SAAS;GAClD,UAAU;EACZ;CACD,CAAA;CAMH,OAAO,WAAW,aAAa,SAAS,SAAS,IAAI,IAAI;AAC3D"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { HTMLAttributes } from "react";
|
|
2
|
+
//#region src/organisms/ActivityHeatmap/index.d.ts
|
|
3
|
+
export type HeatmapDay = {
|
|
4
|
+
/** Day as `YYYY-MM-DD`. */
|
|
5
|
+
date: string;
|
|
6
|
+
/** How many events that day holds. */
|
|
7
|
+
count: number;
|
|
8
|
+
};
|
|
9
|
+
export type HeatmapLevel = 0 | 1 | 2 | 3 | 4;
|
|
10
|
+
export type HeatmapCell = {
|
|
11
|
+
date: string;
|
|
12
|
+
count: number;
|
|
13
|
+
level: HeatmapLevel;
|
|
14
|
+
/** Days after the end of the range keep the grid square and stay out of reach. */
|
|
15
|
+
future: boolean;
|
|
16
|
+
};
|
|
17
|
+
export type HeatmapMonthLabel = {
|
|
18
|
+
label: string;
|
|
19
|
+
column: number;
|
|
20
|
+
span: number;
|
|
21
|
+
};
|
|
22
|
+
export type HeatmapModel = {
|
|
23
|
+
/** Seven weekday rows, oldest week first in each. */
|
|
24
|
+
rows: HeatmapCell[][];
|
|
25
|
+
weeks: number;
|
|
26
|
+
first: string;
|
|
27
|
+
last: string;
|
|
28
|
+
total: number;
|
|
29
|
+
max: number;
|
|
30
|
+
monthLabels: HeatmapMonthLabel[];
|
|
31
|
+
};
|
|
32
|
+
export declare function heatmapMs(iso: string): number;
|
|
33
|
+
export declare function heatmapIso(ms: number): string;
|
|
34
|
+
/** Shifts a `YYYY-MM-DD` day by a number of days. */
|
|
35
|
+
export declare function shiftDay(iso: string, delta: number): string;
|
|
36
|
+
/** Day of week as `0` Sunday through `6` Saturday. */
|
|
37
|
+
export declare function weekdayOf(iso: string): number;
|
|
38
|
+
/** Buckets a count into one of five steps; zero is its own step. */
|
|
39
|
+
export declare function levelFor(count: number, max: number): HeatmapLevel;
|
|
40
|
+
export declare function buildHeatmap(days: HeatmapDay[], options?: {
|
|
41
|
+
weeks?: number;
|
|
42
|
+
end?: string;
|
|
43
|
+
max?: number;
|
|
44
|
+
}): HeatmapModel;
|
|
45
|
+
export type ActivityHeatmapProps = Omit<HTMLAttributes<HTMLDivElement>, "children" | "onSelect"> & {
|
|
46
|
+
/** One entry per day that has activity; days without an entry read as zero. */
|
|
47
|
+
days: HeatmapDay[];
|
|
48
|
+
/** Columns of weeks to draw. Default 26. */
|
|
49
|
+
weeks?: number;
|
|
50
|
+
/** Last day of the range as `YYYY-MM-DD`. Defaults to the latest day given. */
|
|
51
|
+
end?: string;
|
|
52
|
+
/** Fixes the top of the scale so two heatmaps compare. Defaults to the data max. */
|
|
53
|
+
max?: number;
|
|
54
|
+
/** Accessible name of the grid. */
|
|
55
|
+
label?: string;
|
|
56
|
+
/** Shows the Less / More legend. Default true. */
|
|
57
|
+
legend?: boolean;
|
|
58
|
+
/** Called with the day when a cell is clicked or activated with Enter or Space. */
|
|
59
|
+
onSelect?: (day: HeatmapDay) => void;
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* A year of activity as a grid of days: weekdays down, weeks across. Intensity
|
|
63
|
+
* buckets the counts into four steps above zero, and the whole grid is one tab
|
|
64
|
+
* stop that the arrow keys walk day by day.
|
|
65
|
+
*/
|
|
66
|
+
export declare function ActivityHeatmap({ days, weeks, end, max, label, legend, onSelect, className, ...props }: ActivityHeatmapProps): import("react").JSX.Element;
|
|
67
|
+
//#endregion
|
|
68
|
+
//# sourceMappingURL=activity-heatmap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"activity-heatmap.d.ts","names":[],"sources":["../src/organisms/ActivityHeatmap/index.tsx"],"mappings":";;YAMY;;EAEV;;EAEA;;YAGU;YAEA;EACV;EACA;EACA,OAAO;;EAEP;;YAGU;EACV;EACA;EACA;;YAGU;;EAEV,MAAM;EACN;EACA;EACA;EACA;EACA;EACA,aAAa;;wBAqBC,UAAU;wBAKV,WAAW;;wBAKX,SAAS,aAAa;;wBAKtB,UAAU;;wBAKV,SAAS,eAAe,cAAc;wBAMtC,aACd,MAAM,cACN;EAAW;EAAgB;EAAc;IACxC;YAoES,uBAAuB,KACjC,eAAe;;EAIf,MAAM;;EAEN;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA,YAAY,KAAK;;;;;;;wBAQH,kBACd,MACA,OACA,KACA,KACA,OACA,QACA,UACA,cACG,SACF,uCAAoB,IAAA"}
|