@wow-two-beta/fe 0.0.48 → 0.0.50
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/feedback/FeedbackBus.d.ts +154 -29
- package/dist/feedback/FeedbackBus.js +264 -27
- package/dist/feedback/FeedbackBus.js.map +1 -1
- package/dist/feedback/index.d.ts +1 -1
- package/dist/feedback/index.js +3 -1
- package/dist/foundation/dom/enums/ElementTag.d.ts +2 -0
- package/dist/foundation/dom/enums/ElementTag.js +3 -1
- package/dist/foundation/dom/enums/ElementTag.js.map +1 -1
- package/dist/index.js +325 -312
- package/dist/index.js.map +1 -1
- package/dist/presentation/display/index.js +105 -102
- package/dist/presentation/display/index.js.map +1 -1
- package/dist/presentation/display/notificationCenterGroup/NotificationCenterButton.vue.d.ts +18 -0
- package/dist/presentation/display/notificationCenterGroup/NotificationCenterButton.vue.js +120 -0
- package/dist/presentation/display/notificationCenterGroup/NotificationCenterButton.vue.js.map +1 -0
- package/dist/presentation/display/notificationCenterGroup/NotificationCenterButton2.vue.js +5 -0
- package/dist/presentation/display/notificationCenterGroup/NotificationCenterButton2.vue.js.map +1 -0
- package/dist/presentation/display/notificationCenterGroup/NotificationCenterGroup.vue.d.ts +11 -6
- package/dist/presentation/display/notificationCenterGroup/NotificationCenterGroup.vue.js +255 -61
- package/dist/presentation/display/notificationCenterGroup/NotificationCenterGroup.vue.js.map +1 -1
- package/dist/presentation/display/notificationCenterGroup/{NotificationItem.vue.d.ts → NotificationCenterGroupItem.vue.d.ts} +13 -12
- package/dist/presentation/display/notificationCenterGroup/{NotificationItem.vue.js → NotificationCenterGroupItem.vue.js} +81 -58
- package/dist/presentation/display/notificationCenterGroup/NotificationCenterGroupItem.vue.js.map +1 -0
- package/dist/presentation/display/notificationCenterGroup/NotificationCenterGroupItem2.vue.js +5 -0
- package/dist/presentation/display/notificationCenterGroup/NotificationCenterGroupItem2.vue.js.map +1 -0
- package/dist/presentation/display/notificationCenterGroup/index.d.ts +6 -1
- package/dist/presentation/feedback/feedbackToastHost/FeedbackToastHost.vue.d.ts +1 -9
- package/dist/presentation/feedback/feedbackToastHost/FeedbackToastHost.vue.js +165 -20
- package/dist/presentation/feedback/feedbackToastHost/FeedbackToastHost.vue.js.map +1 -1
- package/dist/presentation/feedback/feedbackToastHost/RemindLaterButton.vue.d.ts +7 -0
- package/dist/presentation/feedback/feedbackToastHost/RemindLaterButton.vue.js +56 -0
- package/dist/presentation/feedback/feedbackToastHost/RemindLaterButton.vue.js.map +1 -0
- package/dist/presentation/feedback/feedbackToastHost/RemindLaterButton2.vue.js +5 -0
- package/dist/presentation/feedback/feedbackToastHost/RemindLaterButton2.vue.js.map +1 -0
- package/dist/presentation/feedback/index.js +9 -1
- package/dist/presentation/feedback/index.js.map +1 -1
- package/dist/presentation/feedback/toast/Toast.vue.d.ts +34 -8
- package/dist/presentation/feedback/toast/Toast.vue.js +290 -85
- package/dist/presentation/feedback/toast/Toast.vue.js.map +1 -1
- package/dist/presentation/feedback/toast/ToastContent.vue.d.ts +25 -0
- package/dist/presentation/feedback/toast/ToastContent.vue.js +78 -0
- package/dist/presentation/feedback/toast/ToastContent.vue.js.map +1 -0
- package/dist/presentation/feedback/toast/ToastContent2.vue.js +5 -0
- package/dist/presentation/feedback/toast/ToastContent2.vue.js.map +1 -0
- package/dist/presentation/feedback/toast/ToastRunningProgress.vue.d.ts +15 -0
- package/dist/presentation/feedback/toast/ToastRunningProgress.vue.js +88 -0
- package/dist/presentation/feedback/toast/ToastRunningProgress.vue.js.map +1 -0
- package/dist/presentation/feedback/toast/ToastRunningProgress2.vue.js +5 -0
- package/dist/presentation/feedback/toast/ToastRunningProgress2.vue.js.map +1 -0
- package/dist/presentation/feedback/toast/ToastSurface.d.ts +8 -0
- package/dist/presentation/feedback/toast/ToastSurface.js +10 -0
- package/dist/presentation/feedback/toast/ToastSurface.js.map +1 -0
- package/dist/presentation/feedback/toast/index.d.ts +1 -0
- package/dist/presentation/feedback/toastHost/ToastContent.d.ts +3 -0
- package/dist/presentation/feedback/toastHost/ToastEntry.d.ts +12 -0
- package/dist/presentation/feedback/toastHost/ToastFocusExtensions.d.ts +2 -0
- package/dist/presentation/feedback/toastHost/ToastFocusExtensions.js +11 -0
- package/dist/presentation/feedback/toastHost/ToastFocusExtensions.js.map +1 -0
- package/dist/presentation/feedback/toastHost/ToastGroup.d.ts +8 -0
- package/dist/presentation/feedback/toastHost/ToastGroupLatest.d.ts +10 -0
- package/dist/presentation/feedback/toastHost/ToastHost.vue.d.ts +55 -110
- package/dist/presentation/feedback/toastHost/ToastHost.vue.js +394 -399
- package/dist/presentation/feedback/toastHost/ToastHost.vue.js.map +1 -1
- package/dist/presentation/feedback/toastHost/ToastHost2.vue.js +4 -5
- package/dist/presentation/feedback/toastHost/ToastHostStore.d.ts +37 -0
- package/dist/presentation/feedback/toastHost/ToastHostStore.js +98 -0
- package/dist/presentation/feedback/toastHost/ToastHostStore.js.map +1 -0
- package/dist/presentation/feedback/toastHost/ToastHostStyles.d.ts +34 -0
- package/dist/presentation/feedback/toastHost/ToastHostStyles.js +44 -0
- package/dist/presentation/feedback/toastHost/ToastHostStyles.js.map +1 -0
- package/dist/presentation/feedback/toastHost/ToastNode.d.ts +3 -0
- package/dist/presentation/feedback/toastHost/ToastOptions.d.ts +72 -0
- package/dist/presentation/feedback/toastHost/ToastProgress.vue.d.ts +11 -0
- package/dist/presentation/feedback/toastHost/ToastProgress.vue.js +44 -0
- package/dist/presentation/feedback/toastHost/ToastProgress.vue.js.map +1 -0
- package/dist/presentation/feedback/toastHost/ToastProgress2.vue.js +5 -0
- package/dist/presentation/feedback/toastHost/ToastProgress2.vue.js.map +1 -0
- package/dist/presentation/feedback/toastHost/ToastPromiseOptions.d.ts +12 -0
- package/dist/presentation/feedback/toastHost/ToastRing.vue.d.ts +14 -0
- package/dist/presentation/feedback/toastHost/ToastRing.vue.js +65 -0
- package/dist/presentation/feedback/toastHost/ToastRing.vue.js.map +1 -0
- package/dist/presentation/feedback/toastHost/ToastRing2.vue.js +5 -0
- package/dist/presentation/feedback/toastHost/ToastRing2.vue.js.map +1 -0
- package/dist/presentation/feedback/toastHost/ToastSeconds.vue.d.ts +9 -0
- package/dist/presentation/feedback/toastHost/ToastSeconds.vue.js +56 -0
- package/dist/presentation/feedback/toastHost/ToastSeconds.vue.js.map +1 -0
- package/dist/presentation/feedback/toastHost/ToastSeconds2.vue.js +5 -0
- package/dist/presentation/feedback/toastHost/ToastSeconds2.vue.js.map +1 -0
- package/dist/presentation/feedback/toastHost/ToastSeverity.d.ts +3 -0
- package/dist/presentation/feedback/toastHost/UseResolvedToasts.d.ts +27 -0
- package/dist/presentation/feedback/toastHost/UseResolvedToasts.js +34 -0
- package/dist/presentation/feedback/toastHost/UseResolvedToasts.js.map +1 -0
- package/dist/presentation/feedback/toastHost/UseToastAnnouncer.d.ts +14 -0
- package/dist/presentation/feedback/toastHost/UseToastAnnouncer.js +106 -0
- package/dist/presentation/feedback/toastHost/UseToastAnnouncer.js.map +1 -0
- package/dist/presentation/feedback/toastHost/UseToastCapacity.d.ts +34 -0
- package/dist/presentation/feedback/toastHost/UseToastCapacity.js +128 -0
- package/dist/presentation/feedback/toastHost/UseToastCapacity.js.map +1 -0
- package/dist/presentation/feedback/toastHost/UseToastClock.d.ts +44 -0
- package/dist/presentation/feedback/toastHost/UseToastClock.js +134 -0
- package/dist/presentation/feedback/toastHost/UseToastClock.js.map +1 -0
- package/dist/presentation/feedback/toastHost/UseToastCountdown.d.ts +26 -0
- package/dist/presentation/feedback/toastHost/UseToastCountdown.js +23 -0
- package/dist/presentation/feedback/toastHost/UseToastCountdown.js.map +1 -0
- package/dist/presentation/feedback/toastHost/UseToastEntries.d.ts +4 -0
- package/dist/presentation/feedback/toastHost/UseToastEntries.js +17 -0
- package/dist/presentation/feedback/toastHost/UseToastEntries.js.map +1 -0
- package/dist/presentation/feedback/toastHost/UseToastExits.d.ts +11 -0
- package/dist/presentation/feedback/toastHost/UseToastExits.js +52 -0
- package/dist/presentation/feedback/toastHost/UseToastExits.js.map +1 -0
- package/dist/presentation/feedback/toastHost/UseToastGroupMotion.d.ts +43 -0
- package/dist/presentation/feedback/toastHost/UseToastGroupMotion.js +173 -0
- package/dist/presentation/feedback/toastHost/UseToastGroupMotion.js.map +1 -0
- package/dist/presentation/feedback/toastHost/UseToastHost.d.ts +10 -0
- package/dist/presentation/feedback/toastHost/UseToastHost.js +14 -0
- package/dist/presentation/feedback/toastHost/UseToastHost.js.map +1 -0
- package/dist/presentation/feedback/toastHost/UseToastHotkey.d.ts +20 -0
- package/dist/presentation/feedback/toastHost/UseToastHotkey.js +66 -0
- package/dist/presentation/feedback/toastHost/UseToastHotkey.js.map +1 -0
- package/dist/presentation/feedback/toastHost/UseToastPins.d.ts +26 -0
- package/dist/presentation/feedback/toastHost/UseToastPins.js +35 -0
- package/dist/presentation/feedback/toastHost/UseToastPins.js.map +1 -0
- package/dist/presentation/feedback/toastHost/UseToastStackMotion.d.ts +27 -0
- package/dist/presentation/feedback/toastHost/UseToastStackMotion.js +96 -0
- package/dist/presentation/feedback/toastHost/UseToastStackMotion.js.map +1 -0
- package/dist/presentation/feedback/toastHost/UseToastSwipe.d.ts +19 -0
- package/dist/presentation/feedback/toastHost/UseToastSwipe.js +173 -0
- package/dist/presentation/feedback/toastHost/UseToastSwipe.js.map +1 -0
- package/dist/presentation/feedback/toastHost/index.d.ts +8 -1
- package/dist/presentation/feedback/toastHost/index.js +7 -1
- package/dist/presentation/feedback/toastHost/index.js.map +1 -1
- package/dist/presentation/feedback/toastHost/styles.css +14 -2
- package/dist/presentation/layout/grid/Grid.variants.d.ts +7 -0
- package/dist/presentation/layout/grid/Grid.variants.js +4 -0
- package/dist/presentation/layout/grid/Grid.variants.js.map +1 -1
- package/dist/presentation/layout/grid/Grid.vue.d.ts +5 -0
- package/dist/presentation/layout/grid/Grid.vue.js +16 -4
- package/dist/presentation/layout/grid/Grid.vue.js.map +1 -1
- package/dist/presentation/layout/grid/index.d.ts +1 -1
- package/dist/presentation/layout/index.js +3 -1
- package/dist/presentation/layout/navbar/Navbar.vue.js.map +1 -1
- package/dist/presentation/overlays/popover/PopoverContent.vue.js +4 -4
- package/dist/presentation/overlays/popover/PopoverContent.vue.js.map +1 -1
- package/dist/presentation/overlays/tooltip/Tooltip.vue.js +52 -63
- package/dist/presentation/overlays/tooltip/Tooltip.vue.js.map +1 -1
- package/package.json +1 -1
- package/dist/presentation/display/notificationCenterGroup/NotificationItem.vue.js.map +0 -1
- package/dist/presentation/display/notificationCenterGroup/NotificationItem2.vue.js +0 -5
- package/dist/presentation/display/notificationCenterGroup/NotificationItem2.vue.js.map +0 -1
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Severity } from '../../../foundation/styles';
|
|
2
|
+
import { ToastCountdownProps } from './UseToastCountdown';
|
|
3
|
+
/** Defines props for the countdown ring. */
|
|
4
|
+
export interface ToastRingProps extends ToastCountdownProps {
|
|
5
|
+
/** The close-button variant, drawing a thin ring around it with a dim arc for the elapsed time. */
|
|
6
|
+
readonly isAroundClose?: boolean;
|
|
7
|
+
}
|
|
8
|
+
declare const _default: import('vue').DefineComponent<ToastRingProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<ToastRingProps> & Readonly<{}>, {
|
|
9
|
+
readonly severity: Severity;
|
|
10
|
+
readonly isPaused: boolean;
|
|
11
|
+
readonly elapsed: number;
|
|
12
|
+
readonly isAroundClose: boolean;
|
|
13
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
14
|
+
export default _default;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { defineComponent, useTemplateRef, openBlock, createElementBlock, normalizeClass, unref, createElementVNode } from "vue";
|
|
2
|
+
import { cn } from "../../../foundation/styles/Cn.js";
|
|
3
|
+
import { Severity } from "../../../foundation/styles/enums/Severity.js";
|
|
4
|
+
import { useToastCountdown } from "./UseToastCountdown.js";
|
|
5
|
+
const _hoisted_1 = ["stroke-width", "stroke-opacity"];
|
|
6
|
+
const _hoisted_2 = ["stroke-width", "stroke-opacity"];
|
|
7
|
+
const RingClasses = {
|
|
8
|
+
[Severity.Neutral]: "stroke-primary",
|
|
9
|
+
[Severity.Info]: "stroke-info",
|
|
10
|
+
[Severity.Success]: "stroke-success",
|
|
11
|
+
[Severity.Warning]: "stroke-warning",
|
|
12
|
+
[Severity.Danger]: "stroke-destructive"
|
|
13
|
+
};
|
|
14
|
+
const RingRadius = 6;
|
|
15
|
+
const RingCircumference = 2 * Math.PI * RingRadius;
|
|
16
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
17
|
+
...{ name: "ToastRing" },
|
|
18
|
+
__name: "ToastRing",
|
|
19
|
+
props: {
|
|
20
|
+
isAroundClose: { type: Boolean, default: false },
|
|
21
|
+
duration: {},
|
|
22
|
+
elapsed: { default: 0 },
|
|
23
|
+
isPaused: { type: Boolean, default: false },
|
|
24
|
+
severity: { default: Severity.Neutral }
|
|
25
|
+
},
|
|
26
|
+
setup(__props) {
|
|
27
|
+
const props = __props;
|
|
28
|
+
const arc = useTemplateRef("arc");
|
|
29
|
+
useToastCountdown(() => arc.value, [{ strokeDashoffset: "0" }, { strokeDashoffset: `${RingCircumference}` }], props);
|
|
30
|
+
return (_ctx, _cache) => {
|
|
31
|
+
return openBlock(), createElementBlock("svg", {
|
|
32
|
+
"aria-hidden": "true",
|
|
33
|
+
viewBox: "0 0 16 16",
|
|
34
|
+
class: normalizeClass(unref(cn)("-rotate-90 motion-reduce:hidden", props.isAroundClose ? "size-full" : "size-4"))
|
|
35
|
+
}, [
|
|
36
|
+
createElementVNode("circle", {
|
|
37
|
+
cx: "8",
|
|
38
|
+
cy: "8",
|
|
39
|
+
r: RingRadius,
|
|
40
|
+
fill: "none",
|
|
41
|
+
"stroke-width": props.isAroundClose ? 1 : 2,
|
|
42
|
+
"stroke-opacity": props.isAroundClose ? 0.22 : 1,
|
|
43
|
+
class: normalizeClass(props.isAroundClose ? "stroke-muted-foreground" : "stroke-border")
|
|
44
|
+
}, null, 10, _hoisted_1),
|
|
45
|
+
createElementVNode("circle", {
|
|
46
|
+
ref_key: "arc",
|
|
47
|
+
ref: arc,
|
|
48
|
+
cx: "8",
|
|
49
|
+
cy: "8",
|
|
50
|
+
r: RingRadius,
|
|
51
|
+
fill: "none",
|
|
52
|
+
"stroke-width": props.isAroundClose ? 1 : 2,
|
|
53
|
+
"stroke-opacity": props.isAroundClose ? 0.85 : 1,
|
|
54
|
+
"stroke-linecap": "round",
|
|
55
|
+
"stroke-dasharray": RingCircumference,
|
|
56
|
+
class: normalizeClass(props.isAroundClose ? "stroke-muted-foreground" : RingClasses[props.severity])
|
|
57
|
+
}, null, 10, _hoisted_2)
|
|
58
|
+
], 2);
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
export {
|
|
63
|
+
_sfc_main as default
|
|
64
|
+
};
|
|
65
|
+
//# sourceMappingURL=ToastRing.vue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ToastRing.vue.js","sources":["../../../../src/presentation/feedback/toastHost/ToastRing.vue"],"sourcesContent":["<script lang=\"ts\">\nimport { cn, Severity } from '../../../foundation/styles';\nimport { useToastCountdown, type ToastCountdownProps } from './UseToastCountdown';\n\n/** Defines props for the countdown ring. */\nexport interface ToastRingProps extends ToastCountdownProps {\n /** The close-button variant, drawing a thin ring around it with a dim arc for the elapsed time. */\n readonly isAroundClose?: boolean;\n}\n\n/** @internal The countdown-ring stroke per severity — the bar's tones, drawn as an arc. */\nconst RingClasses: Record<Severity, string> = {\n [Severity.Neutral]: 'stroke-primary',\n [Severity.Info]: 'stroke-info',\n [Severity.Success]: 'stroke-success',\n [Severity.Warning]: 'stroke-warning',\n [Severity.Danger]: 'stroke-destructive',\n};\n\n/** @internal The ring's radius in the 16×16 view box. */\nconst RingRadius = 6;\n\n/** @internal The ring's circumference, which is the dash the countdown drains. */\nconst RingCircumference = 2 * Math.PI * RingRadius;\n</script>\n\n<script setup lang=\"ts\">\nimport { useTemplateRef } from 'vue';\n\n/** Renders the countdown ring — an arc draining clockwise from twelve o'clock. */\ndefineOptions({ name: 'ToastRing' });\n\nconst props = withDefaults(defineProps<ToastRingProps>(), {\n elapsed: 0,\n isPaused: false,\n severity: Severity.Neutral,\n isAroundClose: false,\n});\n\nconst arc = useTemplateRef<SVGCircleElement>('arc');\nuseToastCountdown(() => arc.value, [{ strokeDashoffset: '0' }, { strokeDashoffset: `${RingCircumference}` }], props);\n</script>\n\n<template>\n <svg\n aria-hidden=\"true\"\n viewBox=\"0 0 16 16\"\n :class=\"cn('-rotate-90 motion-reduce:hidden', props.isAroundClose ? 'size-full' : 'size-4')\"\n >\n <circle\n cx=\"8\"\n cy=\"8\"\n :r=\"RingRadius\"\n fill=\"none\"\n :stroke-width=\"props.isAroundClose ? 1 : 2\"\n :stroke-opacity=\"props.isAroundClose ? 0.22 : 1\"\n :class=\"props.isAroundClose ? 'stroke-muted-foreground' : 'stroke-border'\"\n />\n <circle\n ref=\"arc\"\n cx=\"8\"\n cy=\"8\"\n :r=\"RingRadius\"\n fill=\"none\"\n :stroke-width=\"props.isAroundClose ? 1 : 2\"\n :stroke-opacity=\"props.isAroundClose ? 0.85 : 1\"\n stroke-linecap=\"round\"\n :stroke-dasharray=\"RingCircumference\"\n :class=\"props.isAroundClose ? 'stroke-muted-foreground' : RingClasses[props.severity]\"\n />\n </svg>\n</template>\n"],"names":["_createElementBlock","_normalizeClass","_unref","_createElementVNode"],"mappings":";;;;;;AAWA,MAAM,cAAwC;AAAA,EAC5C,CAAC,SAAS,OAAO,GAAG;AAAA,EACpB,CAAC,SAAS,IAAI,GAAG;AAAA,EACjB,CAAC,SAAS,OAAO,GAAG;AAAA,EACpB,CAAC,SAAS,OAAO,GAAG;AAAA,EACpB,CAAC,SAAS,MAAM,GAAG;AACrB;AAGA,MAAM,aAAa;AAGnB,MAAM,oBAAoB,IAAI,KAAK,KAAK;;;;;;;;;;;;AASxC,UAAM,QAAQ;AAOd,UAAM,MAAM,eAAiC,KAAK;AAClD,sBAAkB,MAAM,IAAI,OAAO,CAAC,EAAE,kBAAkB,IAAA,GAAO,EAAE,kBAAkB,GAAG,iBAAiB,GAAA,CAAI,GAAG,KAAK;;0BAIjHA,mBA0BM,OAAA;AAAA,QAzBJ,eAAY;AAAA,QACZ,SAAQ;AAAA,QACP,OAAKC,eAAEC,MAAA,EAAA,EAAE,mCAAoC,MAAM,gBAAa,cAAA,QAAA,CAAA;AAAA,MAAA;QAEjEC,mBAQE,UAAA;AAAA,UAPA,IAAG;AAAA,UACH,IAAG;AAAA,UACF,GAAG;AAAA,UACJ,MAAK;AAAA,UACJ,gBAAc,MAAM,gBAAa,IAAA;AAAA,UACjC,kBAAgB,MAAM,gBAAa,OAAA;AAAA,UACnC,OAAKF,eAAE,MAAM,gBAAa,4BAAA,eAAA;AAAA,QAAA;QAE7BE,mBAWE,UAAA;AAAA,mBAVI;AAAA,UAAJ,KAAI;AAAA,UACJ,IAAG;AAAA,UACH,IAAG;AAAA,UACF,GAAG;AAAA,UACJ,MAAK;AAAA,UACJ,gBAAc,MAAM,gBAAa,IAAA;AAAA,UACjC,kBAAgB,MAAM,gBAAa,OAAA;AAAA,UACpC,kBAAe;AAAA,UACd,oBAAkB;AAAA,UAClB,OAAKF,eAAE,MAAM,4CAA4C,YAAY,MAAM,QAAQ,CAAA;AAAA,QAAA;;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ToastRing2.vue.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ToastCountdownProps } from './UseToastCountdown';
|
|
2
|
+
/** Defines props for the seconds display. */
|
|
3
|
+
export interface ToastSecondsProps extends ToastCountdownProps {
|
|
4
|
+
}
|
|
5
|
+
declare const _default: import('vue').DefineComponent<ToastSecondsProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<ToastSecondsProps> & Readonly<{}>, {
|
|
6
|
+
readonly isPaused: boolean;
|
|
7
|
+
readonly elapsed: number;
|
|
8
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
9
|
+
export default _default;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { defineComponent, ref, onMounted, watch, onUnmounted, openBlock, createElementBlock, toDisplayString } from "vue";
|
|
2
|
+
const _hoisted_1 = {
|
|
3
|
+
"aria-hidden": "true",
|
|
4
|
+
class: "text-xs tabular-nums text-muted-foreground"
|
|
5
|
+
};
|
|
6
|
+
const SecondsTickMs = 250;
|
|
7
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
8
|
+
...{ name: "ToastSeconds" },
|
|
9
|
+
__name: "ToastSeconds",
|
|
10
|
+
props: {
|
|
11
|
+
duration: {},
|
|
12
|
+
elapsed: { default: 0 },
|
|
13
|
+
isPaused: { type: Boolean, default: false },
|
|
14
|
+
severity: {}
|
|
15
|
+
},
|
|
16
|
+
setup(__props) {
|
|
17
|
+
const props = __props;
|
|
18
|
+
const left = ref(Math.max(0, props.duration - props.elapsed));
|
|
19
|
+
let lastTick = 0;
|
|
20
|
+
let handle;
|
|
21
|
+
onMounted(() => {
|
|
22
|
+
if (!props.isPaused) start();
|
|
23
|
+
});
|
|
24
|
+
watch(
|
|
25
|
+
() => props.isPaused,
|
|
26
|
+
(isPaused) => isPaused ? stop() : start()
|
|
27
|
+
);
|
|
28
|
+
onUnmounted(() => {
|
|
29
|
+
if (handle !== void 0) window.clearInterval(handle);
|
|
30
|
+
handle = void 0;
|
|
31
|
+
});
|
|
32
|
+
function tick() {
|
|
33
|
+
const now = Date.now();
|
|
34
|
+
left.value = Math.max(0, left.value - (now - lastTick));
|
|
35
|
+
lastTick = now;
|
|
36
|
+
}
|
|
37
|
+
function start() {
|
|
38
|
+
if (handle !== void 0) return;
|
|
39
|
+
lastTick = Date.now();
|
|
40
|
+
handle = window.setInterval(tick, SecondsTickMs);
|
|
41
|
+
}
|
|
42
|
+
function stop() {
|
|
43
|
+
if (handle === void 0) return;
|
|
44
|
+
tick();
|
|
45
|
+
window.clearInterval(handle);
|
|
46
|
+
handle = void 0;
|
|
47
|
+
}
|
|
48
|
+
return (_ctx, _cache) => {
|
|
49
|
+
return openBlock(), createElementBlock("span", _hoisted_1, toDisplayString(Math.ceil(left.value / 1e3)) + "s", 1);
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
export {
|
|
54
|
+
_sfc_main as default
|
|
55
|
+
};
|
|
56
|
+
//# sourceMappingURL=ToastSeconds.vue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ToastSeconds.vue.js","sources":["../../../../src/presentation/feedback/toastHost/ToastSeconds.vue"],"sourcesContent":["<script lang=\"ts\">\nimport type { ToastCountdownProps } from './UseToastCountdown';\n\n/** Defines props for the seconds display. */\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\nexport interface ToastSecondsProps extends ToastCountdownProps {}\n\n/** @internal How often the display re-reads its clock (ms); a quarter second keeps a whole-second flip on time. */\nconst SecondsTickMs = 250;\n</script>\n\n<script setup lang=\"ts\">\nimport { onMounted, onUnmounted, ref, watch } from 'vue';\n\n/** Renders the whole seconds left, rounded up so it reads `1s` until the toast goes. */\ndefineOptions({ name: 'ToastSeconds' });\n\nconst props = withDefaults(defineProps<ToastSecondsProps>(), { elapsed: 0, isPaused: false });\n\nconst left = ref(Math.max(0, props.duration - props.elapsed));\nlet lastTick = 0;\nlet handle: number | undefined;\n\nonMounted(() => {\n if (!props.isPaused) start();\n});\nwatch(\n () => props.isPaused,\n (isPaused) => (isPaused ? stop() : start()),\n);\nonUnmounted(() => {\n if (handle !== undefined) window.clearInterval(handle);\n handle = undefined;\n});\n\n/** Takes the time since the last tick off the seconds left. */\nfunction tick(): void {\n const now = Date.now();\n left.value = Math.max(0, left.value - (now - lastTick));\n lastTick = now;\n}\n\n/** Starts the interval; a running one is left alone. */\nfunction start(): void {\n if (handle !== undefined) return;\n lastTick = Date.now();\n handle = window.setInterval(tick, SecondsTickMs);\n}\n\n/** Banks the time spent so far and stops the interval. */\nfunction stop(): void {\n if (handle === undefined) return;\n tick();\n window.clearInterval(handle);\n handle = undefined;\n}\n</script>\n\n<template>\n <span aria-hidden=\"true\" class=\"text-xs tabular-nums text-muted-foreground\">{{ Math.ceil(left / 1000) }}s</span>\n</template>\n"],"names":["_createElementBlock","_toDisplayString"],"mappings":";;;;;AAQA,MAAM,gBAAgB;;;;;;;;;;;AAStB,UAAM,QAAQ;AAEd,UAAM,OAAO,IAAI,KAAK,IAAI,GAAG,MAAM,WAAW,MAAM,OAAO,CAAC;AAC5D,QAAI,WAAW;AACf,QAAI;AAEJ,cAAU,MAAM;AACd,UAAI,CAAC,MAAM,SAAU,OAAA;AAAA,IACvB,CAAC;AACD;AAAA,MACE,MAAM,MAAM;AAAA,MACZ,CAAC,aAAc,WAAW,KAAA,IAAS,MAAA;AAAA,IAAM;AAE3C,gBAAY,MAAM;AAChB,UAAI,WAAW,OAAW,QAAO,cAAc,MAAM;AACrD,eAAS;AAAA,IACX,CAAC;AAGD,aAAS,OAAa;AACpB,YAAM,MAAM,KAAK,IAAA;AACjB,WAAK,QAAQ,KAAK,IAAI,GAAG,KAAK,SAAS,MAAM,SAAS;AACtD,iBAAW;AAAA,IACb;AAGA,aAAS,QAAc;AACrB,UAAI,WAAW,OAAW;AAC1B,iBAAW,KAAK,IAAA;AAChB,eAAS,OAAO,YAAY,MAAM,aAAa;AAAA,IACjD;AAGA,aAAS,OAAa;AACpB,UAAI,WAAW,OAAW;AAC1B,WAAA;AACA,aAAO,cAAc,MAAM;AAC3B,eAAS;AAAA,IACX;;0BAIEA,mBAAgH,QAAhH,YAAgHC,gBAAjC,KAAK,KAAK,KAAA,QAAI,GAAA,CAAA,IAAW,KAAC,CAAA;AAAA;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ToastSeconds2.vue.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ComputedRef, Ref } from 'vue';
|
|
2
|
+
import { NoticePriority } from '../../../feedback';
|
|
3
|
+
import { ToastEntry } from './ToastEntry';
|
|
4
|
+
import { ToastSeverity } from './ToastSeverity';
|
|
5
|
+
/** The per-severity expiry a `ToastHost` starts from, in ms. */
|
|
6
|
+
export declare const DefaultToastDurations: Readonly<Partial<Record<ToastSeverity, number>>>;
|
|
7
|
+
/** The display lifetimes for low, normal, high and urgent notices, in milliseconds. */
|
|
8
|
+
export declare const DefaultToastPriorityDurations: Readonly<Record<NoticePriority, number>>;
|
|
9
|
+
/** Represents a live toast with the lifetime its host resolved for it. */
|
|
10
|
+
export interface VisibleToast extends ToastEntry {
|
|
11
|
+
/** The lifetime in ms the host resolved; `Infinity` while the toast runs or never expires. */
|
|
12
|
+
resolvedDuration: number;
|
|
13
|
+
}
|
|
14
|
+
/** Defines the host settings a toast's lifetime resolves from. */
|
|
15
|
+
export interface ToastDurationSettings {
|
|
16
|
+
/** The auto-dismiss delay in ms for a severity missing from `durations`. */
|
|
17
|
+
readonly defaultDuration: number;
|
|
18
|
+
/** The auto-dismiss delay in ms per severity. */
|
|
19
|
+
readonly durations: Readonly<Partial<Record<ToastSeverity, number>>>;
|
|
20
|
+
/** The display lifetime in ms per priority; when set, unclassified toasts count as Normal. */
|
|
21
|
+
readonly priorityDurations?: Readonly<Partial<Record<NoticePriority, number>>>;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Manages each toast's resolved lifetime — none while it runs, else its deadline, its own `duration`, the
|
|
25
|
+
* priority table, the severity table, then `defaultDuration` — in priority, then delivery, order.
|
|
26
|
+
*/
|
|
27
|
+
export declare function useResolvedToasts(entries: Readonly<Ref<ReadonlyArray<ToastEntry>>>, settings: ToastDurationSettings): ComputedRef<ReadonlyArray<VisibleToast>>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { computed } from "vue";
|
|
2
|
+
import { NoticePriority } from "../../../feedback/FeedbackBus.js";
|
|
3
|
+
import { Severity } from "../../../foundation/styles/enums/Severity.js";
|
|
4
|
+
import { isRunning, hasDeadline, compareOrder } from "./ToastHostStore.js";
|
|
5
|
+
const DefaultToastDurations = Object.freeze({
|
|
6
|
+
[Severity.Danger]: 8e3
|
|
7
|
+
});
|
|
8
|
+
const DefaultToastPriorityDurations = Object.freeze({
|
|
9
|
+
[NoticePriority.Low]: 4e3,
|
|
10
|
+
[NoticePriority.Normal]: 6e3,
|
|
11
|
+
[NoticePriority.High]: 1e4,
|
|
12
|
+
[NoticePriority.Urgent]: 1e4
|
|
13
|
+
});
|
|
14
|
+
function useResolvedToasts(entries, settings) {
|
|
15
|
+
return computed(
|
|
16
|
+
() => entries.value.map((t) => {
|
|
17
|
+
const priority = t.priority ?? (settings.priorityDurations ? NoticePriority.Normal : void 0);
|
|
18
|
+
const priorityDuration = priority === void 0 ? void 0 : (settings.priorityDurations ?? DefaultToastPriorityDurations)[priority];
|
|
19
|
+
let resolvedDuration;
|
|
20
|
+
if (isRunning(t)) resolvedDuration = Infinity;
|
|
21
|
+
else if (hasDeadline(t)) resolvedDuration = Math.max(0, t.expiresAtMs - t.createdAtMs);
|
|
22
|
+
else {
|
|
23
|
+
resolvedDuration = t.duration ?? priorityDuration ?? settings.durations[t.severity ?? Severity.Neutral] ?? settings.defaultDuration;
|
|
24
|
+
}
|
|
25
|
+
return { ...t, resolvedDuration };
|
|
26
|
+
}).sort(compareOrder)
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
export {
|
|
30
|
+
DefaultToastDurations,
|
|
31
|
+
DefaultToastPriorityDurations,
|
|
32
|
+
useResolvedToasts
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=UseResolvedToasts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UseResolvedToasts.js","sources":["../../../../src/presentation/feedback/toastHost/UseResolvedToasts.ts"],"sourcesContent":["import { computed, type ComputedRef, type Ref } from 'vue';\n\nimport { NoticePriority } from '../../../feedback';\nimport { Severity } from '../../../foundation/styles';\nimport type { ToastEntry } from './ToastEntry';\nimport { compareOrder, hasDeadline, isRunning } from './ToastHostStore';\nimport type { ToastSeverity } from './ToastSeverity';\n\n/** The per-severity expiry a `ToastHost` starts from, in ms. */\nexport const DefaultToastDurations: Readonly<Partial<Record<ToastSeverity, number>>> = Object.freeze({\n [Severity.Danger]: 8000,\n});\n\n/** The display lifetimes for low, normal, high and urgent notices, in milliseconds. */\nexport const DefaultToastPriorityDurations: Readonly<Record<NoticePriority, number>> = Object.freeze({\n [NoticePriority.Low]: 4000,\n [NoticePriority.Normal]: 6000,\n [NoticePriority.High]: 10000,\n [NoticePriority.Urgent]: 10000,\n});\n\n/** Represents a live toast with the lifetime its host resolved for it. */\nexport interface VisibleToast extends ToastEntry {\n /** The lifetime in ms the host resolved; `Infinity` while the toast runs or never expires. */\n resolvedDuration: number;\n}\n\n/** Defines the host settings a toast's lifetime resolves from. */\nexport interface ToastDurationSettings {\n /** The auto-dismiss delay in ms for a severity missing from `durations`. */\n readonly defaultDuration: number;\n\n /** The auto-dismiss delay in ms per severity. */\n readonly durations: Readonly<Partial<Record<ToastSeverity, number>>>;\n\n /** The display lifetime in ms per priority; when set, unclassified toasts count as Normal. */\n readonly priorityDurations?: Readonly<Partial<Record<NoticePriority, number>>>;\n}\n\n/**\n * Manages each toast's resolved lifetime — none while it runs, else its deadline, its own `duration`, the\n * priority table, the severity table, then `defaultDuration` — in priority, then delivery, order.\n */\nexport function useResolvedToasts(\n entries: Readonly<Ref<ReadonlyArray<ToastEntry>>>,\n settings: ToastDurationSettings,\n): ComputedRef<ReadonlyArray<VisibleToast>> {\n return computed(() =>\n entries.value\n .map((t) => {\n const priority = t.priority ?? (settings.priorityDurations ? NoticePriority.Normal : undefined);\n const priorityDuration =\n priority === undefined ? undefined : (settings.priorityDurations ?? DefaultToastPriorityDurations)[priority];\n let resolvedDuration: number;\n if (isRunning(t)) resolvedDuration = Infinity;\n else if (hasDeadline(t)) resolvedDuration = Math.max(0, t.expiresAtMs - t.createdAtMs);\n else {\n resolvedDuration =\n t.duration ??\n priorityDuration ??\n settings.durations[t.severity ?? Severity.Neutral] ??\n settings.defaultDuration;\n }\n return { ...t, resolvedDuration };\n })\n .sort(compareOrder),\n );\n}\n"],"names":[],"mappings":";;;;AASO,MAAM,wBAA0E,OAAO,OAAO;AAAA,EACnG,CAAC,SAAS,MAAM,GAAG;AACrB,CAAC;AAGM,MAAM,gCAA0E,OAAO,OAAO;AAAA,EACnG,CAAC,eAAe,GAAG,GAAG;AAAA,EACtB,CAAC,eAAe,MAAM,GAAG;AAAA,EACzB,CAAC,eAAe,IAAI,GAAG;AAAA,EACvB,CAAC,eAAe,MAAM,GAAG;AAC3B,CAAC;AAwBM,SAAS,kBACd,SACA,UAC0C;AAC1C,SAAO;AAAA,IAAS,MACd,QAAQ,MACL,IAAI,CAAC,MAAM;AACV,YAAM,WAAW,EAAE,aAAa,SAAS,oBAAoB,eAAe,SAAS;AACrF,YAAM,mBACJ,aAAa,SAAY,UAAa,SAAS,qBAAqB,+BAA+B,QAAQ;AAC7G,UAAI;AACJ,UAAI,UAAU,CAAC,EAAG,oBAAmB;AAAA,eAC5B,YAAY,CAAC,EAAG,oBAAmB,KAAK,IAAI,GAAG,EAAE,cAAc,EAAE,WAAW;AAAA,WAChF;AACH,2BACE,EAAE,YACF,oBACA,SAAS,UAAU,EAAE,YAAY,SAAS,OAAO,KACjD,SAAS;AAAA,MACb;AACA,aAAO,EAAE,GAAG,GAAG,iBAAA;AAAA,IACjB,CAAC,EACA,KAAK,YAAY;AAAA,EAAA;AAExB;"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Ref } from 'vue';
|
|
2
|
+
import { LocaleContextValue } from '../../../foundation/i18n';
|
|
3
|
+
import { VisibleToast } from './UseResolvedToasts';
|
|
4
|
+
/**
|
|
5
|
+
* Manages the host's two live regions. A new toast, an in-place change of its title, description or severity, a
|
|
6
|
+
* group's growth and a finished operation each queue the toast's plain text; a progress update alone queues
|
|
7
|
+
* nothing. A danger or urgent toast speaks in the assertive region, the rest in the polite one. Changes within
|
|
8
|
+
* 120 ms read as one message, and more than three arrivals as a count plus the most important one. Each message
|
|
9
|
+
* clears its region first, so the same text read twice is heard twice.
|
|
10
|
+
*/
|
|
11
|
+
export declare function useToastAnnouncer(cards: Readonly<Ref<ReadonlyArray<VisibleToast>>>, locale: Pick<LocaleContextValue, 't'>): {
|
|
12
|
+
polite: import('vue').ShallowRef<string, string>;
|
|
13
|
+
assertive: import('vue').ShallowRef<string, string>;
|
|
14
|
+
};
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { shallowRef, watch, onScopeDispose } from "vue";
|
|
2
|
+
import { NoticePriority } from "../../../feedback/FeedbackBus.js";
|
|
3
|
+
import { Severity } from "../../../foundation/styles/enums/Severity.js";
|
|
4
|
+
import { isRunning, compareOrder } from "./ToastHostStore.js";
|
|
5
|
+
const BatchMs = 120;
|
|
6
|
+
const ListedArrivals = 3;
|
|
7
|
+
function textOf(node) {
|
|
8
|
+
return typeof node === "string" ? node.trim() : "";
|
|
9
|
+
}
|
|
10
|
+
function joinSentences(parts) {
|
|
11
|
+
return parts.filter((part) => part.length > 0).reduce((text, part) => !text ? part : /[.!?…:]$/u.test(text) ? `${text} ${part}` : `${text}. ${part}`, "");
|
|
12
|
+
}
|
|
13
|
+
function isUrgent(toast) {
|
|
14
|
+
return toast.severity === Severity.Danger || toast.group?.latest.severity === Severity.Danger || toast.priority === NoticePriority.Urgent;
|
|
15
|
+
}
|
|
16
|
+
function afterNextFrame(callback) {
|
|
17
|
+
if (typeof window.requestAnimationFrame !== "function") {
|
|
18
|
+
const handle2 = window.setTimeout(callback, 16);
|
|
19
|
+
return () => window.clearTimeout(handle2);
|
|
20
|
+
}
|
|
21
|
+
let handle = window.requestAnimationFrame(() => {
|
|
22
|
+
handle = window.requestAnimationFrame(callback);
|
|
23
|
+
});
|
|
24
|
+
return () => window.cancelAnimationFrame(handle);
|
|
25
|
+
}
|
|
26
|
+
function useToastAnnouncer(cards, locale) {
|
|
27
|
+
const polite = shallowRef("");
|
|
28
|
+
const assertive = shallowRef("");
|
|
29
|
+
let pending = [];
|
|
30
|
+
let batch;
|
|
31
|
+
const frames = /* @__PURE__ */ new Map();
|
|
32
|
+
function speak(region, message) {
|
|
33
|
+
frames.get(region)?.();
|
|
34
|
+
region.value = "";
|
|
35
|
+
frames.set(
|
|
36
|
+
region,
|
|
37
|
+
afterNextFrame(() => {
|
|
38
|
+
frames.delete(region);
|
|
39
|
+
region.value = message;
|
|
40
|
+
})
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
function flush() {
|
|
44
|
+
batch = void 0;
|
|
45
|
+
const live = new Set(cards.value.map((card) => card.id));
|
|
46
|
+
const queued = pending.filter((entry) => live.has(entry.toast.id));
|
|
47
|
+
pending = [];
|
|
48
|
+
if (queued.length === 0) return;
|
|
49
|
+
const arrivals = queued.filter((entry) => entry.arrival);
|
|
50
|
+
let parts = queued.map((entry) => entry.text);
|
|
51
|
+
if (arrivals.length > ListedArrivals) {
|
|
52
|
+
const [first] = [...arrivals].sort((a, b) => compareOrder(a.toast, b.toast));
|
|
53
|
+
parts = [
|
|
54
|
+
locale.t("ToastHost.manyArrivals", { count: arrivals.length }, "{count} new notifications"),
|
|
55
|
+
first?.text ?? "",
|
|
56
|
+
...queued.filter((entry) => !entry.arrival).map((entry) => entry.text)
|
|
57
|
+
];
|
|
58
|
+
}
|
|
59
|
+
speak(queued.some((entry) => entry.assertive) ? assertive : polite, joinSentences(parts));
|
|
60
|
+
}
|
|
61
|
+
function enqueue(toast, text, arrival) {
|
|
62
|
+
if (!text) return;
|
|
63
|
+
const earlier = pending.findIndex((entry2) => entry2.toast.id === toast.id);
|
|
64
|
+
const entry = { toast, text, assertive: isUrgent(toast), arrival: arrival || pending[earlier]?.arrival === true };
|
|
65
|
+
if (earlier >= 0) pending[earlier] = entry;
|
|
66
|
+
else pending.push(entry);
|
|
67
|
+
batch ??= window.setTimeout(flush, BatchMs);
|
|
68
|
+
}
|
|
69
|
+
function copyOf(toast) {
|
|
70
|
+
return joinSentences([textOf(toast.title), textOf(toast.description)]);
|
|
71
|
+
}
|
|
72
|
+
function growthOf(toast) {
|
|
73
|
+
const title = textOf(toast.title);
|
|
74
|
+
const count = toast.group.count;
|
|
75
|
+
const head = title ? locale.t("ToastHost.groupGrowth", { title, count }, "{title}: {count} notifications") : locale.t("ToastHost.groupCount", { count }, "{count} notifications");
|
|
76
|
+
return joinSentences([head, textOf(toast.group.latest.title)]);
|
|
77
|
+
}
|
|
78
|
+
watch(cards, (next, previous) => {
|
|
79
|
+
const earlier = new Map(previous.map((card) => [card.id, card]));
|
|
80
|
+
for (const card of next) {
|
|
81
|
+
const prior = earlier.get(card.id);
|
|
82
|
+
if (!prior) {
|
|
83
|
+
enqueue(card, copyOf(card), true);
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
if (prior.nonce === card.nonce) continue;
|
|
87
|
+
if (card.group && card.group.count > (prior.group?.count ?? 1)) {
|
|
88
|
+
enqueue(card, growthOf({ ...card, group: card.group }), false);
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
if (card.group && prior.group && card.group.count < prior.group.count) continue;
|
|
92
|
+
const changed = textOf(prior.title) !== textOf(card.title) || textOf(prior.description) !== textOf(card.description) || prior.severity !== card.severity || isRunning(prior) && !isRunning(card);
|
|
93
|
+
if (changed) enqueue(card, copyOf(card), false);
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
onScopeDispose(() => {
|
|
97
|
+
if (batch !== void 0) window.clearTimeout(batch);
|
|
98
|
+
for (const cancel of frames.values()) cancel();
|
|
99
|
+
frames.clear();
|
|
100
|
+
});
|
|
101
|
+
return { polite, assertive };
|
|
102
|
+
}
|
|
103
|
+
export {
|
|
104
|
+
useToastAnnouncer
|
|
105
|
+
};
|
|
106
|
+
//# sourceMappingURL=UseToastAnnouncer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UseToastAnnouncer.js","sources":["../../../../src/presentation/feedback/toastHost/UseToastAnnouncer.ts"],"sourcesContent":["import { onScopeDispose, shallowRef, watch, type Ref } from 'vue';\n\nimport { NoticePriority } from '../../../feedback';\nimport type { LocaleContextValue } from '../../../foundation/i18n';\nimport { Severity } from '../../../foundation/styles';\nimport { compareOrder, isRunning } from './ToastHostStore';\nimport type { ToastNode } from './ToastNode';\nimport type { VisibleToast } from './UseResolvedToasts';\n\n/** @internal Arrivals this close together read as one message (ms). */\nconst BatchMs = 120;\n\n/** @internal More arrivals than this in one batch read as a count plus the most important one. */\nconst ListedArrivals = 3;\n\n/** @internal One queued announcement — the toast, its plain text and the region it speaks in. */\ninterface Announcement {\n readonly toast: VisibleToast;\n readonly text: string;\n readonly assertive: boolean;\n readonly arrival: boolean;\n}\n\nfunction textOf(node: ToastNode | undefined): string {\n return typeof node === 'string' ? node.trim() : '';\n}\n\n/** Joins phrases as sentences, adding a full stop only where a phrase has no closing mark of its own. */\nfunction joinSentences(parts: ReadonlyArray<string>): string {\n return parts\n .filter((part) => part.length > 0)\n .reduce((text, part) => (!text ? part : /[.!?…:]$/u.test(text) ? `${text} ${part}` : `${text}. ${part}`), '');\n}\n\n/** Whether a toast interrupts: a danger severity or an urgent priority. */\nfunction isUrgent(toast: VisibleToast): boolean {\n return (\n toast.severity === Severity.Danger ||\n toast.group?.latest.severity === Severity.Danger ||\n toast.priority === NoticePriority.Urgent\n );\n}\n\n/** Calls back after the next rendered frame, so a cleared region is seen empty before it fills again. */\nfunction afterNextFrame(callback: () => void): () => void {\n if (typeof window.requestAnimationFrame !== 'function') {\n const handle = window.setTimeout(callback, 16);\n return () => window.clearTimeout(handle);\n }\n let handle = window.requestAnimationFrame(() => {\n handle = window.requestAnimationFrame(callback);\n });\n return () => window.cancelAnimationFrame(handle);\n}\n\n/**\n * Manages the host's two live regions. A new toast, an in-place change of its title, description or severity, a\n * group's growth and a finished operation each queue the toast's plain text; a progress update alone queues\n * nothing. A danger or urgent toast speaks in the assertive region, the rest in the polite one. Changes within\n * 120 ms read as one message, and more than three arrivals as a count plus the most important one. Each message\n * clears its region first, so the same text read twice is heard twice.\n */\nexport function useToastAnnouncer(\n cards: Readonly<Ref<ReadonlyArray<VisibleToast>>>,\n locale: Pick<LocaleContextValue, 't'>,\n) {\n const polite = shallowRef('');\n const assertive = shallowRef('');\n let pending: Array<Announcement> = [];\n let batch: number | undefined;\n const frames = new Map<Ref<string>, () => void>();\n\n function speak(region: Ref<string>, message: string): void {\n frames.get(region)?.();\n region.value = '';\n frames.set(\n region,\n afterNextFrame(() => {\n frames.delete(region);\n region.value = message;\n }),\n );\n }\n\n function flush(): void {\n batch = undefined;\n const live = new Set(cards.value.map((card) => card.id));\n const queued = pending.filter((entry) => live.has(entry.toast.id));\n pending = [];\n if (queued.length === 0) return;\n const arrivals = queued.filter((entry) => entry.arrival);\n let parts = queued.map((entry) => entry.text);\n if (arrivals.length > ListedArrivals) {\n const [first] = [...arrivals].sort((a, b) => compareOrder(a.toast, b.toast));\n parts = [\n locale.t('ToastHost.manyArrivals', { count: arrivals.length }, '{count} new notifications'),\n first?.text ?? '',\n ...queued.filter((entry) => !entry.arrival).map((entry) => entry.text),\n ];\n }\n speak(queued.some((entry) => entry.assertive) ? assertive : polite, joinSentences(parts));\n }\n\n function enqueue(toast: VisibleToast, text: string, arrival: boolean): void {\n if (!text) return;\n // A toast that changes again inside the batch is read once, as it is now.\n const earlier = pending.findIndex((entry) => entry.toast.id === toast.id);\n const entry = { toast, text, assertive: isUrgent(toast), arrival: arrival || pending[earlier]?.arrival === true };\n if (earlier >= 0) pending[earlier] = entry;\n else pending.push(entry);\n batch ??= window.setTimeout(flush, BatchMs);\n }\n\n function copyOf(toast: VisibleToast): string {\n return joinSentences([textOf(toast.title), textOf(toast.description)]);\n }\n\n function growthOf(toast: VisibleToast & { group: NonNullable<VisibleToast['group']> }): string {\n const title = textOf(toast.title);\n const count = toast.group.count;\n const head = title\n ? locale.t('ToastHost.groupGrowth', { title, count }, '{title}: {count} notifications')\n : locale.t('ToastHost.groupCount', { count }, '{count} notifications');\n return joinSentences([head, textOf(toast.group.latest.title)]);\n }\n\n watch(cards, (next, previous) => {\n const earlier = new Map(previous.map((card) => [card.id, card]));\n for (const card of next) {\n const prior = earlier.get(card.id);\n if (!prior) {\n enqueue(card, copyOf(card), true);\n continue;\n }\n if (prior.nonce === card.nonce) continue;\n if (card.group && card.group.count > (prior.group?.count ?? 1)) {\n enqueue(card, growthOf({ ...card, group: card.group }), false);\n continue;\n }\n // A member leaving its group is the reader's own doing, or a quiet expiry.\n if (card.group && prior.group && card.group.count < prior.group.count) continue;\n const changed =\n textOf(prior.title) !== textOf(card.title) ||\n textOf(prior.description) !== textOf(card.description) ||\n prior.severity !== card.severity ||\n (isRunning(prior) && !isRunning(card));\n if (changed) enqueue(card, copyOf(card), false);\n }\n });\n\n onScopeDispose(() => {\n if (batch !== undefined) window.clearTimeout(batch);\n for (const cancel of frames.values()) cancel();\n frames.clear();\n });\n\n return { polite, assertive };\n}\n"],"names":["handle","entry"],"mappings":";;;;AAUA,MAAM,UAAU;AAGhB,MAAM,iBAAiB;AAUvB,SAAS,OAAO,MAAqC;AACnD,SAAO,OAAO,SAAS,WAAW,KAAK,SAAS;AAClD;AAGA,SAAS,cAAc,OAAsC;AAC3D,SAAO,MACJ,OAAO,CAAC,SAAS,KAAK,SAAS,CAAC,EAChC,OAAO,CAAC,MAAM,SAAU,CAAC,OAAO,OAAO,YAAY,KAAK,IAAI,IAAI,GAAG,IAAI,IAAI,IAAI,KAAK,GAAG,IAAI,KAAK,IAAI,IAAK,EAAE;AAChH;AAGA,SAAS,SAAS,OAA8B;AAC9C,SAC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K,IAAI,IAAI,CAAC,CAAC;AAC/D,eAAW,QAAQ,MAAM;AACvB,YAAM,QAAQ,QAAQ,IAAI,KAAK,EAAE;AACjC,UAAI,CAAC,OAAO;AACV,gBAAQ,MAAM,OAAO,IAAI,GAAG,IAAI;AAChC;AAAA,MACF;AACA,UAAI,MAAM,UAAU,KAAK,MAAO;AAChC,UAAI,KAAK,SAAS,KAAK,MAAM,SAAS,MAAM,OAAO,SAAS,IAAI;AAC9D,gBAAQ,MAAM,SAAS,EAAE,GAAG,MAAM,OAAO,KAAK,OAAO,GAAG,KAAK;AAC7D;AAAA,MACF;AAEA,UAAI,KAAK,SAAS,MAAM,SAAS,KAAK,MAAM,QAAQ,MAAM,MAAM,MAAO;AACvE,YAAM,UACJ,OAAO,MAAM,KAAK,MAAM,OAAO,KAAK,KAAK,KACzC,OAAO,MAAM,WAAW,MAAM,OAAO,KAAK,WAAW,KACrD,MAAM,aAAa,KAAK,YACvB,UAAU,KAAK,KAAK,CAAC,UAAU,IAAI;AACtC,UAAI,QAAS,SAAQ,MAAM,OAAO,IAAI,GAAG,KAAK;AAAA,IAChD;AAAA,EACF,CAAC;AAED,iBAAe,MAAM;AACnB,QAAI,UAAU,OAAW,QAAO,aAAa,KAAK;AAClD,eAAW,UAAU,OAAO,OAAA,EAAU,QAAA;AACtC,WAAO,MAAA;AAAA,EACT,CAAC;AAED,SAAO,EAAE,QAAQ,UAAA;AACnB;"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Ref } from 'vue';
|
|
2
|
+
import { ToastOptions } from './ToastOptions';
|
|
3
|
+
import { VisibleToast } from './UseResolvedToasts';
|
|
4
|
+
/** Defines the elements and lists a host's capacity is measured from. */
|
|
5
|
+
export interface ToastCapacitySources {
|
|
6
|
+
readonly stack: Readonly<Ref<HTMLElement | null>>;
|
|
7
|
+
readonly overflowButton: () => HTMLElement | null | undefined;
|
|
8
|
+
/** Every live toast, in delivery order. */
|
|
9
|
+
readonly cards: Readonly<Ref<ReadonlyArray<VisibleToast>>>;
|
|
10
|
+
/** The order the collapsed window fills in. */
|
|
11
|
+
readonly ordered: Readonly<Ref<ReadonlyArray<VisibleToast>>>;
|
|
12
|
+
}
|
|
13
|
+
/** Defines the host settings capacity reads. */
|
|
14
|
+
export interface ToastCapacitySettings {
|
|
15
|
+
/** The maximum number of cards shown at rest. */
|
|
16
|
+
readonly max: number;
|
|
17
|
+
/** The space between cards, in px. */
|
|
18
|
+
readonly gap: number;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Manages the collapsed stack's fit to `max` and to the available height, measured from full cards, and the
|
|
22
|
+
* expanded overflow list that shows every card in compact rows.
|
|
23
|
+
*/
|
|
24
|
+
export declare function useToastCapacity(sources: ToastCapacitySources, settings: ToastCapacitySettings): {
|
|
25
|
+
overflowOpen: Ref<boolean, boolean>;
|
|
26
|
+
needsScroll: Ref<boolean, boolean>;
|
|
27
|
+
overflowCount: import('vue').ComputedRef<number>;
|
|
28
|
+
visible: import('vue').ComputedRef<readonly VisibleToast[]>;
|
|
29
|
+
copyOf: (toast: ToastOptions) => Pick<ToastOptions, "title" | "description">;
|
|
30
|
+
measureCapacity: () => void;
|
|
31
|
+
toggleOverflow: () => Promise<void>;
|
|
32
|
+
onEscape: (event: KeyboardEvent) => void;
|
|
33
|
+
reset: () => void;
|
|
34
|
+
};
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { ref, computed, watch, nextTick } from "vue";
|
|
2
|
+
import { compareOrder } from "./ToastHostStore.js";
|
|
3
|
+
const OverflowButtonHeight = 36;
|
|
4
|
+
const TouchOverflowButtonHeight = 44;
|
|
5
|
+
function useToastCapacity(sources, settings) {
|
|
6
|
+
const { stack, overflowButton, cards, ordered } = sources;
|
|
7
|
+
const overflowOpen = ref(false);
|
|
8
|
+
const fitCount = ref(Infinity);
|
|
9
|
+
const needsScroll = ref(false);
|
|
10
|
+
const collapsed = computed(() => ordered.value.slice(0, Math.min(settings.max, fitCount.value)));
|
|
11
|
+
const overflowCount = computed(() => settings.max > 0 ? cards.value.length - collapsed.value.length : 0);
|
|
12
|
+
const visible = computed(() => overflowOpen.value ? cards.value : [...collapsed.value].sort(compareOrder));
|
|
13
|
+
function copyOf(toast) {
|
|
14
|
+
return overflowOpen.value && toast.compact || toast;
|
|
15
|
+
}
|
|
16
|
+
const measuredHeights = /* @__PURE__ */ new Map();
|
|
17
|
+
let sizeObserver;
|
|
18
|
+
let observedCards = /* @__PURE__ */ new Set();
|
|
19
|
+
let measuredWidth = 0;
|
|
20
|
+
function measureCapacity() {
|
|
21
|
+
const host = stack.value;
|
|
22
|
+
if (!host) return;
|
|
23
|
+
const minButtonHeight = window.matchMedia?.("(pointer: coarse)").matches ? TouchOverflowButtonHeight : OverflowButtonHeight;
|
|
24
|
+
const buttonHeight = Math.max(overflowButton()?.offsetHeight ?? 0, minButtonHeight);
|
|
25
|
+
host.style.setProperty("--toast-overflow-control-height", `${buttonHeight}px`);
|
|
26
|
+
if (overflowOpen.value) return;
|
|
27
|
+
if (host.clientWidth !== measuredWidth) {
|
|
28
|
+
measuredWidth = host.clientWidth;
|
|
29
|
+
measuredHeights.clear();
|
|
30
|
+
}
|
|
31
|
+
const nextObserved = /* @__PURE__ */ new Set();
|
|
32
|
+
const active = new Map(cards.value.map((card) => [card.id, card.nonce]));
|
|
33
|
+
for (const node of host.children) {
|
|
34
|
+
if (!(node instanceof HTMLElement) || !node.dataset.toastId || node.hasAttribute("data-toast-exiting")) continue;
|
|
35
|
+
const id = node.dataset.toastId;
|
|
36
|
+
const nonce = active.get(id);
|
|
37
|
+
if (nonce === void 0) continue;
|
|
38
|
+
nextObserved.add(node);
|
|
39
|
+
if (!observedCards.has(node)) sizeObserver?.observe(node);
|
|
40
|
+
measuredHeights.set(id, { nonce, height: node.offsetHeight });
|
|
41
|
+
}
|
|
42
|
+
for (const node of observedCards) if (!nextObserved.has(node)) sizeObserver?.unobserve(node);
|
|
43
|
+
observedCards = nextObserved;
|
|
44
|
+
for (const id of measuredHeights.keys()) if (!active.has(id)) measuredHeights.delete(id);
|
|
45
|
+
const room = Number.parseFloat(getComputedStyle(host).maxHeight);
|
|
46
|
+
if (!Number.isFinite(room) || settings.max <= 0) return;
|
|
47
|
+
const heights = ordered.value.slice(0, settings.max).map((card) => {
|
|
48
|
+
const measured = measuredHeights.get(card.id);
|
|
49
|
+
return (measured?.nonce === card.nonce ? measured.height : 0) + settings.gap;
|
|
50
|
+
});
|
|
51
|
+
const total = heights.reduce((sum, height) => sum + height, 0) - settings.gap;
|
|
52
|
+
const needsOverflow = ordered.value.length > settings.max || total > room;
|
|
53
|
+
const budget = needsOverflow ? room - buttonHeight : room + settings.gap;
|
|
54
|
+
let used = 0;
|
|
55
|
+
let fit = 0;
|
|
56
|
+
for (const height of heights) {
|
|
57
|
+
if (used + height > budget) break;
|
|
58
|
+
used += height;
|
|
59
|
+
fit += 1;
|
|
60
|
+
}
|
|
61
|
+
needsScroll.value = fit === 0 && heights.length > 0;
|
|
62
|
+
fitCount.value = Math.max(1, fit);
|
|
63
|
+
}
|
|
64
|
+
watch(
|
|
65
|
+
stack,
|
|
66
|
+
(host, _old, onCleanup) => {
|
|
67
|
+
if (!host) return;
|
|
68
|
+
if (typeof ResizeObserver !== "undefined") {
|
|
69
|
+
sizeObserver = new ResizeObserver(measureCapacity);
|
|
70
|
+
sizeObserver.observe(host);
|
|
71
|
+
}
|
|
72
|
+
window.addEventListener("resize", measureCapacity);
|
|
73
|
+
measureCapacity();
|
|
74
|
+
onCleanup(() => {
|
|
75
|
+
sizeObserver?.disconnect();
|
|
76
|
+
sizeObserver = void 0;
|
|
77
|
+
observedCards.clear();
|
|
78
|
+
measuredHeights.clear();
|
|
79
|
+
window.removeEventListener("resize", measureCapacity);
|
|
80
|
+
});
|
|
81
|
+
},
|
|
82
|
+
{ flush: "post" }
|
|
83
|
+
);
|
|
84
|
+
watch(visible, measureCapacity, { flush: "post" });
|
|
85
|
+
async function toggleOverflow() {
|
|
86
|
+
const show = !overflowOpen.value;
|
|
87
|
+
const shown = new Set(collapsed.value.map((card) => card.id));
|
|
88
|
+
const next = show ? cards.value.find((card) => !shown.has(card.id)) : void 0;
|
|
89
|
+
overflowOpen.value = show;
|
|
90
|
+
await nextTick();
|
|
91
|
+
const host = stack.value;
|
|
92
|
+
if (!host) return;
|
|
93
|
+
if (next) {
|
|
94
|
+
const card = host.querySelector(`[data-toast-id="${next.id}"]`);
|
|
95
|
+
card?.focus({ preventScroll: true });
|
|
96
|
+
card?.scrollIntoView?.({ block: "nearest" });
|
|
97
|
+
} else {
|
|
98
|
+
host.scrollTop = 0;
|
|
99
|
+
const target = overflowButton() ?? host.querySelector("[data-toast-id]:not([data-toast-exiting])");
|
|
100
|
+
target?.focus({ preventScroll: true });
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
function onEscape(event) {
|
|
104
|
+
if (!overflowOpen.value) return;
|
|
105
|
+
event.stopPropagation();
|
|
106
|
+
void toggleOverflow();
|
|
107
|
+
}
|
|
108
|
+
function reset() {
|
|
109
|
+
overflowOpen.value = false;
|
|
110
|
+
fitCount.value = Infinity;
|
|
111
|
+
needsScroll.value = false;
|
|
112
|
+
}
|
|
113
|
+
return {
|
|
114
|
+
overflowOpen,
|
|
115
|
+
needsScroll,
|
|
116
|
+
overflowCount,
|
|
117
|
+
visible,
|
|
118
|
+
copyOf,
|
|
119
|
+
measureCapacity,
|
|
120
|
+
toggleOverflow,
|
|
121
|
+
onEscape,
|
|
122
|
+
reset
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
export {
|
|
126
|
+
useToastCapacity
|
|
127
|
+
};
|
|
128
|
+
//# sourceMappingURL=UseToastCapacity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UseToastCapacity.js","sources":["../../../../src/presentation/feedback/toastHost/UseToastCapacity.ts"],"sourcesContent":["import { computed, nextTick, ref, watch, type Ref } from 'vue';\n\nimport { compareOrder } from './ToastHostStore';\nimport type { ToastOptions } from './ToastOptions';\nimport type { VisibleToast } from './UseResolvedToasts';\n\n/** @internal The least height the overflow button is measured at (px). */\nconst OverflowButtonHeight = 36;\n\n/** @internal The least height the overflow button is measured at on a coarse pointer (px). */\nconst TouchOverflowButtonHeight = 44;\n\n/** Defines the elements and lists a host's capacity is measured from. */\nexport interface ToastCapacitySources {\n readonly stack: Readonly<Ref<HTMLElement | null>>;\n readonly overflowButton: () => HTMLElement | null | undefined;\n /** Every live toast, in delivery order. */\n readonly cards: Readonly<Ref<ReadonlyArray<VisibleToast>>>;\n /** The order the collapsed window fills in. */\n readonly ordered: Readonly<Ref<ReadonlyArray<VisibleToast>>>;\n}\n\n/** Defines the host settings capacity reads. */\nexport interface ToastCapacitySettings {\n /** The maximum number of cards shown at rest. */\n readonly max: number;\n\n /** The space between cards, in px. */\n readonly gap: number;\n}\n\n/**\n * Manages the collapsed stack's fit to `max` and to the available height, measured from full cards, and the\n * expanded overflow list that shows every card in compact rows.\n */\nexport function useToastCapacity(sources: ToastCapacitySources, settings: ToastCapacitySettings) {\n const { stack, overflowButton, cards, ordered } = sources;\n const overflowOpen = ref(false);\n const fitCount = ref(Infinity);\n const needsScroll = ref(false);\n\n const collapsed = computed(() => ordered.value.slice(0, Math.min(settings.max, fitCount.value)));\n const overflowCount = computed(() => (settings.max > 0 ? cards.value.length - collapsed.value.length : 0));\n const visible = computed(() => (overflowOpen.value ? cards.value : [...collapsed.value].sort(compareOrder)));\n\n /** The copy a card shows — its `compact` copy in the overflow list, when it has one. */\n function copyOf(toast: ToastOptions): Pick<ToastOptions, 'title' | 'description'> {\n return (overflowOpen.value && toast.compact) || toast;\n }\n\n const measuredHeights = new Map<string, { nonce: number; height: number }>();\n let sizeObserver: ResizeObserver | undefined;\n let observedCards = new Set<HTMLElement>();\n let measuredWidth = 0;\n\n function measureCapacity(): void {\n const host = stack.value;\n if (!host) return;\n // `matchMedia` is missing from some test DOMs (jsdom); without it the pointer counts as fine.\n const minButtonHeight = window.matchMedia?.('(pointer: coarse)').matches\n ? TouchOverflowButtonHeight\n : OverflowButtonHeight;\n const buttonHeight = Math.max(overflowButton()?.offsetHeight ?? 0, minButtonHeight);\n host.style.setProperty('--toast-overflow-control-height', `${buttonHeight}px`);\n // The collapsed capacity is measured from full cards. Compact rows can yield a different fit.\n if (overflowOpen.value) return;\n // A different viewport width can rewrap even the cards currently outside the collapsed window.\n if (host.clientWidth !== measuredWidth) {\n measuredWidth = host.clientWidth;\n measuredHeights.clear();\n }\n const nextObserved = new Set<HTMLElement>();\n const active = new Map(cards.value.map((card) => [card.id, card.nonce]));\n for (const node of host.children) {\n if (!(node instanceof HTMLElement) || !node.dataset.toastId || node.hasAttribute('data-toast-exiting')) continue;\n const id = node.dataset.toastId;\n const nonce = active.get(id);\n if (nonce === undefined) continue;\n nextObserved.add(node);\n if (!observedCards.has(node)) sizeObserver?.observe(node);\n measuredHeights.set(id, { nonce, height: node.offsetHeight });\n }\n for (const node of observedCards) if (!nextObserved.has(node)) sizeObserver?.unobserve(node);\n observedCards = nextObserved;\n for (const id of measuredHeights.keys()) if (!active.has(id)) measuredHeights.delete(id);\n\n const room = Number.parseFloat(getComputedStyle(host).maxHeight);\n if (!Number.isFinite(room) || settings.max <= 0) return;\n const heights = ordered.value.slice(0, settings.max).map((card) => {\n const measured = measuredHeights.get(card.id);\n return (measured?.nonce === card.nonce ? measured.height : 0) + settings.gap;\n });\n const total = heights.reduce((sum, height) => sum + height, 0) - settings.gap;\n const needsOverflow = ordered.value.length > settings.max || total > room;\n const budget = needsOverflow ? room - buttonHeight : room + settings.gap;\n let used = 0;\n let fit = 0;\n for (const height of heights) {\n if (used + height > budget) break;\n used += height;\n fit += 1;\n }\n needsScroll.value = fit === 0 && heights.length > 0;\n fitCount.value = Math.max(1, fit);\n }\n\n watch(\n stack,\n (host, _old, onCleanup) => {\n if (!host) return;\n if (typeof ResizeObserver !== 'undefined') {\n sizeObserver = new ResizeObserver(measureCapacity);\n sizeObserver.observe(host);\n }\n window.addEventListener('resize', measureCapacity);\n measureCapacity();\n onCleanup(() => {\n sizeObserver?.disconnect();\n sizeObserver = undefined;\n observedCards.clear();\n measuredHeights.clear();\n window.removeEventListener('resize', measureCapacity);\n });\n },\n { flush: 'post' },\n );\n\n // The stack renders inside `Portal`'s slot, so the host's own `onUpdated` never sees a list change; an updated\n // card keeping its size gets its new nonce measured here.\n watch(visible, measureCapacity, { flush: 'post' });\n\n /** Opens the overflow list on the first hidden card, or closes it and returns focus to its button. */\n async function toggleOverflow(): Promise<void> {\n const show = !overflowOpen.value;\n const shown = new Set(collapsed.value.map((card) => card.id));\n const next = show ? cards.value.find((card) => !shown.has(card.id)) : undefined;\n overflowOpen.value = show;\n await nextTick();\n const host = stack.value;\n if (!host) return;\n if (next) {\n const card = host.querySelector<HTMLElement>(`[data-toast-id=\"${next.id}\"]`);\n card?.focus({ preventScroll: true });\n card?.scrollIntoView?.({ block: 'nearest' });\n } else {\n host.scrollTop = 0;\n const target = overflowButton() ?? host.querySelector<HTMLElement>('[data-toast-id]:not([data-toast-exiting])');\n target?.focus({ preventScroll: true });\n }\n }\n\n function onEscape(event: KeyboardEvent): void {\n if (!overflowOpen.value) return;\n event.stopPropagation();\n void toggleOverflow();\n }\n\n /** Returns to the collapsed, unmeasured state once the stack is gone. */\n function reset(): void {\n overflowOpen.value = false;\n fitCount.value = Infinity;\n needsScroll.value = false;\n }\n\n return {\n overflowOpen,\n needsScroll,\n overflowCount,\n visible,\n copyOf,\n measureCapacity,\n toggleOverflow,\n onEscape,\n reset,\n };\n}\n"],"names":[],"mappings":";;AAOA,MAAM,uBAAuB;AAG7B,MAAM,4BAA4B;AAyB3B,SAAS,iBAAiB,SAA+B,UAAiC;AAC/F,QAAM,EAAE,OAAO,gBAAgB,OAAO,YAAY;AAClD,QAAM,eAAe,IAAI,KAAK;AAC9B,QAAM,WAAW,IAAI,QAAQ;AAC7B,QAAM,cAAc,IAAI,KAAK;AAE7B,QAAM,YAAY,SAAS,MAAM,QAAQ,MAAM,MAA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