@react-aria/toast 3.0.0-beta.1 → 3.0.0-beta.11
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/ar-AE.main.js +7 -0
- package/dist/ar-AE.main.js.map +1 -0
- package/dist/ar-AE.mjs +9 -0
- package/dist/ar-AE.module.js +9 -0
- package/dist/ar-AE.module.js.map +1 -0
- package/dist/bg-BG.main.js +7 -0
- package/dist/bg-BG.main.js.map +1 -0
- package/dist/bg-BG.mjs +9 -0
- package/dist/bg-BG.module.js +9 -0
- package/dist/bg-BG.module.js.map +1 -0
- package/dist/cs-CZ.main.js +7 -0
- package/dist/cs-CZ.main.js.map +1 -0
- package/dist/cs-CZ.mjs +9 -0
- package/dist/cs-CZ.module.js +9 -0
- package/dist/cs-CZ.module.js.map +1 -0
- package/dist/da-DK.main.js +7 -0
- package/dist/da-DK.main.js.map +1 -0
- package/dist/da-DK.mjs +9 -0
- package/dist/da-DK.module.js +9 -0
- package/dist/da-DK.module.js.map +1 -0
- package/dist/de-DE.main.js +7 -0
- package/dist/de-DE.main.js.map +1 -0
- package/dist/de-DE.mjs +9 -0
- package/dist/de-DE.module.js +9 -0
- package/dist/de-DE.module.js.map +1 -0
- package/dist/el-GR.main.js +7 -0
- package/dist/el-GR.main.js.map +1 -0
- package/dist/el-GR.mjs +9 -0
- package/dist/el-GR.module.js +9 -0
- package/dist/el-GR.module.js.map +1 -0
- package/dist/en-US.main.js +7 -0
- package/dist/en-US.main.js.map +1 -0
- package/dist/en-US.mjs +9 -0
- package/dist/en-US.module.js +9 -0
- package/dist/en-US.module.js.map +1 -0
- package/dist/es-ES.main.js +7 -0
- package/dist/es-ES.main.js.map +1 -0
- package/dist/es-ES.mjs +9 -0
- package/dist/es-ES.module.js +9 -0
- package/dist/es-ES.module.js.map +1 -0
- package/dist/et-EE.main.js +7 -0
- package/dist/et-EE.main.js.map +1 -0
- package/dist/et-EE.mjs +9 -0
- package/dist/et-EE.module.js +9 -0
- package/dist/et-EE.module.js.map +1 -0
- package/dist/fi-FI.main.js +7 -0
- package/dist/fi-FI.main.js.map +1 -0
- package/dist/fi-FI.mjs +9 -0
- package/dist/fi-FI.module.js +9 -0
- package/dist/fi-FI.module.js.map +1 -0
- package/dist/fr-FR.main.js +7 -0
- package/dist/fr-FR.main.js.map +1 -0
- package/dist/fr-FR.mjs +9 -0
- package/dist/fr-FR.module.js +9 -0
- package/dist/fr-FR.module.js.map +1 -0
- package/dist/he-IL.main.js +7 -0
- package/dist/he-IL.main.js.map +1 -0
- package/dist/he-IL.mjs +9 -0
- package/dist/he-IL.module.js +9 -0
- package/dist/he-IL.module.js.map +1 -0
- package/dist/hr-HR.main.js +7 -0
- package/dist/hr-HR.main.js.map +1 -0
- package/dist/hr-HR.mjs +9 -0
- package/dist/hr-HR.module.js +9 -0
- package/dist/hr-HR.module.js.map +1 -0
- package/dist/hu-HU.main.js +7 -0
- package/dist/hu-HU.main.js.map +1 -0
- package/dist/hu-HU.mjs +9 -0
- package/dist/hu-HU.module.js +9 -0
- package/dist/hu-HU.module.js.map +1 -0
- package/dist/import.mjs +3 -414
- package/dist/intlStrings.main.js +108 -0
- package/dist/intlStrings.main.js.map +1 -0
- package/dist/intlStrings.mjs +110 -0
- package/dist/intlStrings.module.js +110 -0
- package/dist/intlStrings.module.js.map +1 -0
- package/dist/it-IT.main.js +7 -0
- package/dist/it-IT.main.js.map +1 -0
- package/dist/it-IT.mjs +9 -0
- package/dist/it-IT.module.js +9 -0
- package/dist/it-IT.module.js.map +1 -0
- package/dist/ja-JP.main.js +7 -0
- package/dist/ja-JP.main.js.map +1 -0
- package/dist/ja-JP.mjs +9 -0
- package/dist/ja-JP.module.js +9 -0
- package/dist/ja-JP.module.js.map +1 -0
- package/dist/ko-KR.main.js +7 -0
- package/dist/ko-KR.main.js.map +1 -0
- package/dist/ko-KR.mjs +9 -0
- package/dist/ko-KR.module.js +9 -0
- package/dist/ko-KR.module.js.map +1 -0
- package/dist/lt-LT.main.js +7 -0
- package/dist/lt-LT.main.js.map +1 -0
- package/dist/lt-LT.mjs +9 -0
- package/dist/lt-LT.module.js +9 -0
- package/dist/lt-LT.module.js.map +1 -0
- package/dist/lv-LV.main.js +7 -0
- package/dist/lv-LV.main.js.map +1 -0
- package/dist/lv-LV.mjs +9 -0
- package/dist/lv-LV.module.js +9 -0
- package/dist/lv-LV.module.js.map +1 -0
- package/dist/main.js +6 -416
- package/dist/main.js.map +1 -1
- package/dist/module.js +3 -414
- package/dist/module.js.map +1 -1
- package/dist/nb-NO.main.js +7 -0
- package/dist/nb-NO.main.js.map +1 -0
- package/dist/nb-NO.mjs +9 -0
- package/dist/nb-NO.module.js +9 -0
- package/dist/nb-NO.module.js.map +1 -0
- package/dist/nl-NL.main.js +7 -0
- package/dist/nl-NL.main.js.map +1 -0
- package/dist/nl-NL.mjs +9 -0
- package/dist/nl-NL.module.js +9 -0
- package/dist/nl-NL.module.js.map +1 -0
- package/dist/pl-PL.main.js +7 -0
- package/dist/pl-PL.main.js.map +1 -0
- package/dist/pl-PL.mjs +9 -0
- package/dist/pl-PL.module.js +9 -0
- package/dist/pl-PL.module.js.map +1 -0
- package/dist/pt-BR.main.js +7 -0
- package/dist/pt-BR.main.js.map +1 -0
- package/dist/pt-BR.mjs +9 -0
- package/dist/pt-BR.module.js +9 -0
- package/dist/pt-BR.module.js.map +1 -0
- package/dist/pt-PT.main.js +7 -0
- package/dist/pt-PT.main.js.map +1 -0
- package/dist/pt-PT.mjs +9 -0
- package/dist/pt-PT.module.js +9 -0
- package/dist/pt-PT.module.js.map +1 -0
- package/dist/ro-RO.main.js +7 -0
- package/dist/ro-RO.main.js.map +1 -0
- package/dist/ro-RO.mjs +9 -0
- package/dist/ro-RO.module.js +9 -0
- package/dist/ro-RO.module.js.map +1 -0
- package/dist/ru-RU.main.js +7 -0
- package/dist/ru-RU.main.js.map +1 -0
- package/dist/ru-RU.mjs +9 -0
- package/dist/ru-RU.module.js +9 -0
- package/dist/ru-RU.module.js.map +1 -0
- package/dist/sk-SK.main.js +7 -0
- package/dist/sk-SK.main.js.map +1 -0
- package/dist/sk-SK.mjs +9 -0
- package/dist/sk-SK.module.js +9 -0
- package/dist/sk-SK.module.js.map +1 -0
- package/dist/sl-SI.main.js +7 -0
- package/dist/sl-SI.main.js.map +1 -0
- package/dist/sl-SI.mjs +9 -0
- package/dist/sl-SI.module.js +9 -0
- package/dist/sl-SI.module.js.map +1 -0
- package/dist/sr-SP.main.js +7 -0
- package/dist/sr-SP.main.js.map +1 -0
- package/dist/sr-SP.mjs +9 -0
- package/dist/sr-SP.module.js +9 -0
- package/dist/sr-SP.module.js.map +1 -0
- package/dist/sv-SE.main.js +7 -0
- package/dist/sv-SE.main.js.map +1 -0
- package/dist/sv-SE.mjs +9 -0
- package/dist/sv-SE.module.js +9 -0
- package/dist/sv-SE.module.js.map +1 -0
- package/dist/tr-TR.main.js +7 -0
- package/dist/tr-TR.main.js.map +1 -0
- package/dist/tr-TR.mjs +9 -0
- package/dist/tr-TR.module.js +9 -0
- package/dist/tr-TR.module.js.map +1 -0
- package/dist/uk-UA.main.js +7 -0
- package/dist/uk-UA.main.js.map +1 -0
- package/dist/uk-UA.mjs +9 -0
- package/dist/uk-UA.module.js +9 -0
- package/dist/uk-UA.module.js.map +1 -0
- package/dist/useToast.main.js +92 -0
- package/dist/useToast.main.js.map +1 -0
- package/dist/useToast.mjs +87 -0
- package/dist/useToast.module.js +87 -0
- package/dist/useToast.module.js.map +1 -0
- package/dist/useToastRegion.main.js +73 -0
- package/dist/useToastRegion.main.js.map +1 -0
- package/dist/useToastRegion.mjs +68 -0
- package/dist/useToastRegion.module.js +68 -0
- package/dist/useToastRegion.module.js.map +1 -0
- package/dist/zh-CN.main.js +7 -0
- package/dist/zh-CN.main.js.map +1 -0
- package/dist/zh-CN.mjs +9 -0
- package/dist/zh-CN.module.js +9 -0
- package/dist/zh-CN.module.js.map +1 -0
- package/dist/zh-TW.main.js +7 -0
- package/dist/zh-TW.main.js.map +1 -0
- package/dist/zh-TW.mjs +9 -0
- package/dist/zh-TW.module.js +9 -0
- package/dist/zh-TW.module.js.map +1 -0
- package/package.json +10 -10
- package/src/useToast.ts +1 -1
- package/src/useToastRegion.ts +1 -1
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
var $f49b2d6c91681304$exports = require("./intlStrings.main.js");
|
|
2
|
+
var $eO7VF$reactariautils = require("@react-aria/utils");
|
|
3
|
+
var $eO7VF$reactariainteractions = require("@react-aria/interactions");
|
|
4
|
+
var $eO7VF$react = require("react");
|
|
5
|
+
var $eO7VF$reactarialandmark = require("@react-aria/landmark");
|
|
6
|
+
var $eO7VF$reactariai18n = require("@react-aria/i18n");
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
function $parcel$interopDefault(a) {
|
|
10
|
+
return a && a.__esModule ? a.default : a;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function $parcel$export(e, n, v, s) {
|
|
14
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
$parcel$export(module.exports, "useToastRegion", () => $eda7c6204a682dd4$export$b8cbbb20a51697de);
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
function $eda7c6204a682dd4$export$b8cbbb20a51697de(props, state, ref) {
|
|
25
|
+
let stringFormatter = (0, $eO7VF$reactariai18n.useLocalizedStringFormatter)((0, ($parcel$interopDefault($f49b2d6c91681304$exports))), "@react-aria/toast");
|
|
26
|
+
let { landmarkProps: landmarkProps } = (0, $eO7VF$reactarialandmark.useLandmark)({
|
|
27
|
+
role: "region",
|
|
28
|
+
"aria-label": props["aria-label"] || stringFormatter.format("notifications")
|
|
29
|
+
}, ref);
|
|
30
|
+
let { hoverProps: hoverProps } = (0, $eO7VF$reactariainteractions.useHover)({
|
|
31
|
+
onHoverStart: state.pauseAll,
|
|
32
|
+
onHoverEnd: state.resumeAll
|
|
33
|
+
});
|
|
34
|
+
let lastFocused = (0, $eO7VF$react.useRef)(null);
|
|
35
|
+
let { focusWithinProps: focusWithinProps } = (0, $eO7VF$reactariainteractions.useFocusWithin)({
|
|
36
|
+
onFocusWithin: (e)=>{
|
|
37
|
+
state.pauseAll();
|
|
38
|
+
lastFocused.current = e.relatedTarget;
|
|
39
|
+
},
|
|
40
|
+
onBlurWithin: ()=>{
|
|
41
|
+
state.resumeAll();
|
|
42
|
+
lastFocused.current = null;
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
// When the region unmounts, restore focus to the last element that had focus
|
|
46
|
+
// before the user moved focus into the region.
|
|
47
|
+
// TODO: handle when the element has unmounted like FocusScope does?
|
|
48
|
+
// eslint-disable-next-line arrow-body-style
|
|
49
|
+
(0, $eO7VF$react.useEffect)(()=>{
|
|
50
|
+
return ()=>{
|
|
51
|
+
if (lastFocused.current && document.body.contains(lastFocused.current)) {
|
|
52
|
+
if ((0, $eO7VF$reactariainteractions.getInteractionModality)() === "pointer") (0, $eO7VF$reactariautils.focusWithoutScrolling)(lastFocused.current);
|
|
53
|
+
else lastFocused.current.focus();
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
}, [
|
|
57
|
+
ref
|
|
58
|
+
]);
|
|
59
|
+
return {
|
|
60
|
+
regionProps: (0, $eO7VF$reactariautils.mergeProps)(landmarkProps, hoverProps, focusWithinProps, {
|
|
61
|
+
tabIndex: -1,
|
|
62
|
+
// Mark the toast region as a "top layer", so that it:
|
|
63
|
+
// - is not aria-hidden when opening an overlay
|
|
64
|
+
// - allows focus even outside a containing focus scope
|
|
65
|
+
// - doesn’t dismiss overlays when clicking on it, even though it is outside
|
|
66
|
+
// @ts-ignore
|
|
67
|
+
"data-react-aria-top-layer": true
|
|
68
|
+
})
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
//# sourceMappingURL=useToastRegion.main.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA2BO,SAAS,0CAAkB,KAA2B,EAAE,KAAoB,EAAE,GAA2B;IAC9G,IAAI,kBAAkB,CAAA,GAAA,gDAA0B,EAAE,CAAA,GAAA,mDAAW,GAAG;IAChE,IAAI,iBAAC,aAAa,EAAC,GAAG,CAAA,GAAA,oCAAU,EAAE;QAChC,MAAM;QACN,cAAc,KAAK,CAAC,aAAa,IAAI,gBAAgB,MAAM,CAAC;IAC9D,GAAG;IAEH,IAAI,cAAC,UAAU,EAAC,GAAG,CAAA,GAAA,qCAAO,EAAE;QAC1B,cAAc,MAAM,QAAQ;QAC5B,YAAY,MAAM,SAAS;IAC7B;IAEA,IAAI,cAAc,CAAA,GAAA,mBAAK,EAAE;IACzB,IAAI,oBAAC,gBAAgB,EAAC,GAAG,CAAA,GAAA,2CAAa,EAAE;QACtC,eAAe,CAAC;YACd,MAAM,QAAQ;YACd,YAAY,OAAO,GAAG,EAAE,aAAa;QACvC;QACA,cAAc;YACZ,MAAM,SAAS;YACf,YAAY,OAAO,GAAG;QACxB;IACF;IAEA,6EAA6E;IAC7E,+CAA+C;IAC/C,oEAAoE;IACpE,4CAA4C;IAC5C,CAAA,GAAA,sBAAQ,EAAE;QACR,OAAO;YACL,IAAI,YAAY,OAAO,IAAI,SAAS,IAAI,CAAC,QAAQ,CAAC,YAAY,OAAO;gBACnE,IAAI,CAAA,GAAA,mDAAqB,QAAQ,WAC/B,CAAA,GAAA,2CAAoB,EAAE,YAAY,OAAO;qBAEzC,YAAY,OAAO,CAAC,KAAK;;QAG/B;IACF,GAAG;QAAC;KAAI;IAER,OAAO;QACL,aAAa,CAAA,GAAA,gCAAS,EAAE,eAAe,YAAY,kBAAkB;YACnE,UAAU;YACV,sDAAsD;YACtD,iDAAiD;YACjD,yDAAyD;YACzD,8EAA8E;YAC9E,aAAa;YACb,6BAA6B;QAC/B;IACF;AACF","sources":["packages/@react-aria/toast/src/useToastRegion.ts"],"sourcesContent":["import {AriaLabelingProps, DOMAttributes} from '@react-types/shared';\nimport {focusWithoutScrolling, mergeProps} from '@react-aria/utils';\nimport {getInteractionModality, useFocusWithin, useHover} from '@react-aria/interactions';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport {RefObject, useEffect, useRef} from 'react';\nimport {ToastState} from '@react-stately/toast';\nimport {useLandmark} from '@react-aria/landmark';\nimport {useLocalizedStringFormatter} from '@react-aria/i18n';\n\nexport interface AriaToastRegionProps extends AriaLabelingProps {\n /**\n * An accessibility label for the toast region.\n * @default \"Notifications\"\n */\n 'aria-label'?: string\n}\n\nexport interface ToastRegionAria {\n /** Props for the landmark region element. */\n regionProps: DOMAttributes\n}\n\n/**\n * Provides the behavior and accessibility implementation for a toast region containing one or more toasts.\n * Toasts display brief, temporary notifications of actions, errors, or other events in an application.\n */\nexport function useToastRegion<T>(props: AriaToastRegionProps, state: ToastState<T>, ref: RefObject<HTMLElement>): ToastRegionAria {\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/toast');\n let {landmarkProps} = useLandmark({\n role: 'region',\n 'aria-label': props['aria-label'] || stringFormatter.format('notifications')\n }, ref);\n\n let {hoverProps} = useHover({\n onHoverStart: state.pauseAll,\n onHoverEnd: state.resumeAll\n });\n\n let lastFocused = useRef(null);\n let {focusWithinProps} = useFocusWithin({\n onFocusWithin: (e) => {\n state.pauseAll();\n lastFocused.current = e.relatedTarget;\n },\n onBlurWithin: () => {\n state.resumeAll();\n lastFocused.current = null;\n }\n });\n\n // When the region unmounts, restore focus to the last element that had focus\n // before the user moved focus into the region.\n // TODO: handle when the element has unmounted like FocusScope does?\n // eslint-disable-next-line arrow-body-style\n useEffect(() => {\n return () => {\n if (lastFocused.current && document.body.contains(lastFocused.current)) {\n if (getInteractionModality() === 'pointer') {\n focusWithoutScrolling(lastFocused.current);\n } else {\n lastFocused.current.focus();\n }\n }\n };\n }, [ref]);\n\n return {\n regionProps: mergeProps(landmarkProps, hoverProps, focusWithinProps, {\n tabIndex: -1,\n // Mark the toast region as a \"top layer\", so that it:\n // - is not aria-hidden when opening an overlay\n // - allows focus even outside a containing focus scope\n // - doesn’t dismiss overlays when clicking on it, even though it is outside\n // @ts-ignore\n 'data-react-aria-top-layer': true\n })\n };\n}\n"],"names":[],"version":3,"file":"useToastRegion.main.js.map"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import $ckyCP$intlStringsmodulejs from "./intlStrings.mjs";
|
|
2
|
+
import {focusWithoutScrolling as $ckyCP$focusWithoutScrolling, mergeProps as $ckyCP$mergeProps} from "@react-aria/utils";
|
|
3
|
+
import {useHover as $ckyCP$useHover, useFocusWithin as $ckyCP$useFocusWithin, getInteractionModality as $ckyCP$getInteractionModality} from "@react-aria/interactions";
|
|
4
|
+
import {useRef as $ckyCP$useRef, useEffect as $ckyCP$useEffect} from "react";
|
|
5
|
+
import {useLandmark as $ckyCP$useLandmark} from "@react-aria/landmark";
|
|
6
|
+
import {useLocalizedStringFormatter as $ckyCP$useLocalizedStringFormatter} from "@react-aria/i18n";
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
function $parcel$interopDefault(a) {
|
|
10
|
+
return a && a.__esModule ? a.default : a;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
function $6cc546b19ee7130a$export$b8cbbb20a51697de(props, state, ref) {
|
|
19
|
+
let stringFormatter = (0, $ckyCP$useLocalizedStringFormatter)((0, ($parcel$interopDefault($ckyCP$intlStringsmodulejs))), "@react-aria/toast");
|
|
20
|
+
let { landmarkProps: landmarkProps } = (0, $ckyCP$useLandmark)({
|
|
21
|
+
role: "region",
|
|
22
|
+
"aria-label": props["aria-label"] || stringFormatter.format("notifications")
|
|
23
|
+
}, ref);
|
|
24
|
+
let { hoverProps: hoverProps } = (0, $ckyCP$useHover)({
|
|
25
|
+
onHoverStart: state.pauseAll,
|
|
26
|
+
onHoverEnd: state.resumeAll
|
|
27
|
+
});
|
|
28
|
+
let lastFocused = (0, $ckyCP$useRef)(null);
|
|
29
|
+
let { focusWithinProps: focusWithinProps } = (0, $ckyCP$useFocusWithin)({
|
|
30
|
+
onFocusWithin: (e)=>{
|
|
31
|
+
state.pauseAll();
|
|
32
|
+
lastFocused.current = e.relatedTarget;
|
|
33
|
+
},
|
|
34
|
+
onBlurWithin: ()=>{
|
|
35
|
+
state.resumeAll();
|
|
36
|
+
lastFocused.current = null;
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
// When the region unmounts, restore focus to the last element that had focus
|
|
40
|
+
// before the user moved focus into the region.
|
|
41
|
+
// TODO: handle when the element has unmounted like FocusScope does?
|
|
42
|
+
// eslint-disable-next-line arrow-body-style
|
|
43
|
+
(0, $ckyCP$useEffect)(()=>{
|
|
44
|
+
return ()=>{
|
|
45
|
+
if (lastFocused.current && document.body.contains(lastFocused.current)) {
|
|
46
|
+
if ((0, $ckyCP$getInteractionModality)() === "pointer") (0, $ckyCP$focusWithoutScrolling)(lastFocused.current);
|
|
47
|
+
else lastFocused.current.focus();
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
}, [
|
|
51
|
+
ref
|
|
52
|
+
]);
|
|
53
|
+
return {
|
|
54
|
+
regionProps: (0, $ckyCP$mergeProps)(landmarkProps, hoverProps, focusWithinProps, {
|
|
55
|
+
tabIndex: -1,
|
|
56
|
+
// Mark the toast region as a "top layer", so that it:
|
|
57
|
+
// - is not aria-hidden when opening an overlay
|
|
58
|
+
// - allows focus even outside a containing focus scope
|
|
59
|
+
// - doesn’t dismiss overlays when clicking on it, even though it is outside
|
|
60
|
+
// @ts-ignore
|
|
61
|
+
"data-react-aria-top-layer": true
|
|
62
|
+
})
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
export {$6cc546b19ee7130a$export$b8cbbb20a51697de as useToastRegion};
|
|
68
|
+
//# sourceMappingURL=useToastRegion.mjs.map
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import $ckyCP$intlStringsmodulejs from "./intlStrings.module.js";
|
|
2
|
+
import {focusWithoutScrolling as $ckyCP$focusWithoutScrolling, mergeProps as $ckyCP$mergeProps} from "@react-aria/utils";
|
|
3
|
+
import {useHover as $ckyCP$useHover, useFocusWithin as $ckyCP$useFocusWithin, getInteractionModality as $ckyCP$getInteractionModality} from "@react-aria/interactions";
|
|
4
|
+
import {useRef as $ckyCP$useRef, useEffect as $ckyCP$useEffect} from "react";
|
|
5
|
+
import {useLandmark as $ckyCP$useLandmark} from "@react-aria/landmark";
|
|
6
|
+
import {useLocalizedStringFormatter as $ckyCP$useLocalizedStringFormatter} from "@react-aria/i18n";
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
function $parcel$interopDefault(a) {
|
|
10
|
+
return a && a.__esModule ? a.default : a;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
function $6cc546b19ee7130a$export$b8cbbb20a51697de(props, state, ref) {
|
|
19
|
+
let stringFormatter = (0, $ckyCP$useLocalizedStringFormatter)((0, ($parcel$interopDefault($ckyCP$intlStringsmodulejs))), "@react-aria/toast");
|
|
20
|
+
let { landmarkProps: landmarkProps } = (0, $ckyCP$useLandmark)({
|
|
21
|
+
role: "region",
|
|
22
|
+
"aria-label": props["aria-label"] || stringFormatter.format("notifications")
|
|
23
|
+
}, ref);
|
|
24
|
+
let { hoverProps: hoverProps } = (0, $ckyCP$useHover)({
|
|
25
|
+
onHoverStart: state.pauseAll,
|
|
26
|
+
onHoverEnd: state.resumeAll
|
|
27
|
+
});
|
|
28
|
+
let lastFocused = (0, $ckyCP$useRef)(null);
|
|
29
|
+
let { focusWithinProps: focusWithinProps } = (0, $ckyCP$useFocusWithin)({
|
|
30
|
+
onFocusWithin: (e)=>{
|
|
31
|
+
state.pauseAll();
|
|
32
|
+
lastFocused.current = e.relatedTarget;
|
|
33
|
+
},
|
|
34
|
+
onBlurWithin: ()=>{
|
|
35
|
+
state.resumeAll();
|
|
36
|
+
lastFocused.current = null;
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
// When the region unmounts, restore focus to the last element that had focus
|
|
40
|
+
// before the user moved focus into the region.
|
|
41
|
+
// TODO: handle when the element has unmounted like FocusScope does?
|
|
42
|
+
// eslint-disable-next-line arrow-body-style
|
|
43
|
+
(0, $ckyCP$useEffect)(()=>{
|
|
44
|
+
return ()=>{
|
|
45
|
+
if (lastFocused.current && document.body.contains(lastFocused.current)) {
|
|
46
|
+
if ((0, $ckyCP$getInteractionModality)() === "pointer") (0, $ckyCP$focusWithoutScrolling)(lastFocused.current);
|
|
47
|
+
else lastFocused.current.focus();
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
}, [
|
|
51
|
+
ref
|
|
52
|
+
]);
|
|
53
|
+
return {
|
|
54
|
+
regionProps: (0, $ckyCP$mergeProps)(landmarkProps, hoverProps, focusWithinProps, {
|
|
55
|
+
tabIndex: -1,
|
|
56
|
+
// Mark the toast region as a "top layer", so that it:
|
|
57
|
+
// - is not aria-hidden when opening an overlay
|
|
58
|
+
// - allows focus even outside a containing focus scope
|
|
59
|
+
// - doesn’t dismiss overlays when clicking on it, even though it is outside
|
|
60
|
+
// @ts-ignore
|
|
61
|
+
"data-react-aria-top-layer": true
|
|
62
|
+
})
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
export {$6cc546b19ee7130a$export$b8cbbb20a51697de as useToastRegion};
|
|
68
|
+
//# sourceMappingURL=useToastRegion.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;AA2BO,SAAS,0CAAkB,KAA2B,EAAE,KAAoB,EAAE,GAA2B;IAC9G,IAAI,kBAAkB,CAAA,GAAA,kCAA0B,EAAE,CAAA,GAAA,oDAAW,GAAG;IAChE,IAAI,iBAAC,aAAa,EAAC,GAAG,CAAA,GAAA,kBAAU,EAAE;QAChC,MAAM;QACN,cAAc,KAAK,CAAC,aAAa,IAAI,gBAAgB,MAAM,CAAC;IAC9D,GAAG;IAEH,IAAI,cAAC,UAAU,EAAC,GAAG,CAAA,GAAA,eAAO,EAAE;QAC1B,cAAc,MAAM,QAAQ;QAC5B,YAAY,MAAM,SAAS;IAC7B;IAEA,IAAI,cAAc,CAAA,GAAA,aAAK,EAAE;IACzB,IAAI,oBAAC,gBAAgB,EAAC,GAAG,CAAA,GAAA,qBAAa,EAAE;QACtC,eAAe,CAAC;YACd,MAAM,QAAQ;YACd,YAAY,OAAO,GAAG,EAAE,aAAa;QACvC;QACA,cAAc;YACZ,MAAM,SAAS;YACf,YAAY,OAAO,GAAG;QACxB;IACF;IAEA,6EAA6E;IAC7E,+CAA+C;IAC/C,oEAAoE;IACpE,4CAA4C;IAC5C,CAAA,GAAA,gBAAQ,EAAE;QACR,OAAO;YACL,IAAI,YAAY,OAAO,IAAI,SAAS,IAAI,CAAC,QAAQ,CAAC,YAAY,OAAO;gBACnE,IAAI,CAAA,GAAA,6BAAqB,QAAQ,WAC/B,CAAA,GAAA,4BAAoB,EAAE,YAAY,OAAO;qBAEzC,YAAY,OAAO,CAAC,KAAK;;QAG/B;IACF,GAAG;QAAC;KAAI;IAER,OAAO;QACL,aAAa,CAAA,GAAA,iBAAS,EAAE,eAAe,YAAY,kBAAkB;YACnE,UAAU;YACV,sDAAsD;YACtD,iDAAiD;YACjD,yDAAyD;YACzD,8EAA8E;YAC9E,aAAa;YACb,6BAA6B;QAC/B;IACF;AACF","sources":["packages/@react-aria/toast/src/useToastRegion.ts"],"sourcesContent":["import {AriaLabelingProps, DOMAttributes} from '@react-types/shared';\nimport {focusWithoutScrolling, mergeProps} from '@react-aria/utils';\nimport {getInteractionModality, useFocusWithin, useHover} from '@react-aria/interactions';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport {RefObject, useEffect, useRef} from 'react';\nimport {ToastState} from '@react-stately/toast';\nimport {useLandmark} from '@react-aria/landmark';\nimport {useLocalizedStringFormatter} from '@react-aria/i18n';\n\nexport interface AriaToastRegionProps extends AriaLabelingProps {\n /**\n * An accessibility label for the toast region.\n * @default \"Notifications\"\n */\n 'aria-label'?: string\n}\n\nexport interface ToastRegionAria {\n /** Props for the landmark region element. */\n regionProps: DOMAttributes\n}\n\n/**\n * Provides the behavior and accessibility implementation for a toast region containing one or more toasts.\n * Toasts display brief, temporary notifications of actions, errors, or other events in an application.\n */\nexport function useToastRegion<T>(props: AriaToastRegionProps, state: ToastState<T>, ref: RefObject<HTMLElement>): ToastRegionAria {\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/toast');\n let {landmarkProps} = useLandmark({\n role: 'region',\n 'aria-label': props['aria-label'] || stringFormatter.format('notifications')\n }, ref);\n\n let {hoverProps} = useHover({\n onHoverStart: state.pauseAll,\n onHoverEnd: state.resumeAll\n });\n\n let lastFocused = useRef(null);\n let {focusWithinProps} = useFocusWithin({\n onFocusWithin: (e) => {\n state.pauseAll();\n lastFocused.current = e.relatedTarget;\n },\n onBlurWithin: () => {\n state.resumeAll();\n lastFocused.current = null;\n }\n });\n\n // When the region unmounts, restore focus to the last element that had focus\n // before the user moved focus into the region.\n // TODO: handle when the element has unmounted like FocusScope does?\n // eslint-disable-next-line arrow-body-style\n useEffect(() => {\n return () => {\n if (lastFocused.current && document.body.contains(lastFocused.current)) {\n if (getInteractionModality() === 'pointer') {\n focusWithoutScrolling(lastFocused.current);\n } else {\n lastFocused.current.focus();\n }\n }\n };\n }, [ref]);\n\n return {\n regionProps: mergeProps(landmarkProps, hoverProps, focusWithinProps, {\n tabIndex: -1,\n // Mark the toast region as a \"top layer\", so that it:\n // - is not aria-hidden when opening an overlay\n // - allows focus even outside a containing focus scope\n // - doesn’t dismiss overlays when clicking on it, even though it is outside\n // @ts-ignore\n 'data-react-aria-top-layer': true\n })\n };\n}\n"],"names":[],"version":3,"file":"useToastRegion.module.js.map"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":"AAAA,iBAAiB;IAAG,SAAS,CAAC,gBAAE,CAAC;IAC/B,iBAAiB,CAAC,gBAAE,CAAC;AACvB","sources":["packages/@react-aria/toast/intl/zh-CN.json"],"sourcesContent":["{\n \"close\": \"关闭\",\n \"notifications\": \"通知\"\n}\n"],"names":[],"version":3,"file":"zh-CN.main.js.map"}
|
package/dist/zh-CN.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";AAAA,4BAAiB;IAAG,SAAS,CAAC,gBAAE,CAAC;IAC/B,iBAAiB,CAAC,gBAAE,CAAC;AACvB","sources":["packages/@react-aria/toast/intl/zh-CN.json"],"sourcesContent":["{\n \"close\": \"关闭\",\n \"notifications\": \"通知\"\n}\n"],"names":[],"version":3,"file":"zh-CN.module.js.map"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":"AAAA,iBAAiB;IAAG,SAAS,CAAC,gBAAE,CAAC;IAC/B,iBAAiB,CAAC,gBAAE,CAAC;AACvB","sources":["packages/@react-aria/toast/intl/zh-TW.json"],"sourcesContent":["{\n \"close\": \"關閉\",\n \"notifications\": \"通知\"\n}\n"],"names":[],"version":3,"file":"zh-TW.main.js.map"}
|
package/dist/zh-TW.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";AAAA,4BAAiB;IAAG,SAAS,CAAC,gBAAE,CAAC;IAC/B,iBAAiB,CAAC,gBAAE,CAAC;AACvB","sources":["packages/@react-aria/toast/intl/zh-TW.json"],"sourcesContent":["{\n \"close\": \"關閉\",\n \"notifications\": \"通知\"\n}\n"],"names":[],"version":3,"file":"zh-TW.module.js.map"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-aria/toast",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.11",
|
|
4
4
|
"description": "Spectrum UI components in React",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -22,14 +22,14 @@
|
|
|
22
22
|
"url": "https://github.com/adobe/react-spectrum"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@react-aria/i18n": "^3.
|
|
26
|
-
"@react-aria/interactions": "^3.
|
|
27
|
-
"@react-aria/landmark": "3.0.0-beta.
|
|
28
|
-
"@react-aria/utils": "^3.
|
|
29
|
-
"@react-stately/toast": "3.0.0-beta.
|
|
30
|
-
"@react-types/button": "^3.
|
|
31
|
-
"@react-types/shared": "^3.
|
|
32
|
-
"@swc/helpers": "^0.
|
|
25
|
+
"@react-aria/i18n": "^3.11.0",
|
|
26
|
+
"@react-aria/interactions": "^3.21.2",
|
|
27
|
+
"@react-aria/landmark": "3.0.0-beta.11",
|
|
28
|
+
"@react-aria/utils": "^3.24.0",
|
|
29
|
+
"@react-stately/toast": "3.0.0-beta.3",
|
|
30
|
+
"@react-types/button": "^3.9.3",
|
|
31
|
+
"@react-types/shared": "^3.23.0",
|
|
32
|
+
"@swc/helpers": "^0.5.0"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0"
|
|
@@ -37,5 +37,5 @@
|
|
|
37
37
|
"publishConfig": {
|
|
38
38
|
"access": "public"
|
|
39
39
|
},
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "f645f29edc1322153fd60af4640cbcab1d992dbd"
|
|
41
41
|
}
|
package/src/useToast.ts
CHANGED
|
@@ -85,7 +85,7 @@ export function useToast<T>(props: AriaToastProps<T>, state: ToastState<T>, ref:
|
|
|
85
85
|
|
|
86
86
|
let titleId = useId();
|
|
87
87
|
let descriptionId = useSlotId();
|
|
88
|
-
let stringFormatter = useLocalizedStringFormatter(intlMessages);
|
|
88
|
+
let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/toast');
|
|
89
89
|
|
|
90
90
|
return {
|
|
91
91
|
toastProps: {
|
package/src/useToastRegion.ts
CHANGED
|
@@ -26,7 +26,7 @@ export interface ToastRegionAria {
|
|
|
26
26
|
* Toasts display brief, temporary notifications of actions, errors, or other events in an application.
|
|
27
27
|
*/
|
|
28
28
|
export function useToastRegion<T>(props: AriaToastRegionProps, state: ToastState<T>, ref: RefObject<HTMLElement>): ToastRegionAria {
|
|
29
|
-
let stringFormatter = useLocalizedStringFormatter(intlMessages);
|
|
29
|
+
let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/toast');
|
|
30
30
|
let {landmarkProps} = useLandmark({
|
|
31
31
|
role: 'region',
|
|
32
32
|
'aria-label': props['aria-label'] || stringFormatter.format('notifications')
|