@react-aria/toast 3.0.0-beta.10 → 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.mjs +1 -1
- package/dist/bg-BG.mjs +1 -1
- package/dist/cs-CZ.mjs +1 -1
- package/dist/da-DK.mjs +1 -1
- package/dist/de-DE.mjs +1 -1
- package/dist/el-GR.mjs +1 -1
- package/dist/en-US.mjs +1 -1
- package/dist/es-ES.mjs +1 -1
- package/dist/et-EE.mjs +1 -1
- package/dist/fi-FI.mjs +1 -1
- package/dist/fr-FR.mjs +1 -1
- package/dist/he-IL.mjs +1 -1
- package/dist/hr-HR.mjs +1 -1
- package/dist/hu-HU.mjs +1 -1
- package/dist/import.mjs +3 -245
- 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.mjs +1 -1
- package/dist/ja-JP.mjs +1 -1
- package/dist/ko-KR.mjs +1 -1
- package/dist/lt-LT.mjs +1 -1
- package/dist/lv-LV.mjs +1 -1
- package/dist/main.js +5 -247
- package/dist/main.js.map +1 -1
- package/dist/module.js +3 -245
- package/dist/module.js.map +1 -1
- package/dist/nb-NO.mjs +1 -1
- package/dist/nl-NL.mjs +1 -1
- package/dist/pl-PL.mjs +1 -1
- package/dist/pt-BR.mjs +1 -1
- package/dist/pt-PT.mjs +1 -1
- package/dist/ro-RO.mjs +1 -1
- package/dist/ru-RU.mjs +1 -1
- package/dist/sk-SK.mjs +1 -1
- package/dist/sl-SI.mjs +1 -1
- package/dist/sr-SP.mjs +1 -1
- package/dist/sv-SE.mjs +1 -1
- package/dist/tr-TR.mjs +1 -1
- package/dist/uk-UA.mjs +1 -1
- 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.mjs +1 -1
- package/dist/zh-TW.mjs +1 -1
- package/package.json +9 -9
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import $7WpW4$intlStringsmodulejs from "./intlStrings.module.js";
|
|
2
|
+
import {useEffect as $7WpW4$useEffect, useRef as $7WpW4$useRef} from "react";
|
|
3
|
+
import {useLayoutEffect as $7WpW4$useLayoutEffect, useId as $7WpW4$useId, useSlotId as $7WpW4$useSlotId} from "@react-aria/utils";
|
|
4
|
+
import {useLocalizedStringFormatter as $7WpW4$useLocalizedStringFormatter} from "@react-aria/i18n";
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
function $parcel$interopDefault(a) {
|
|
8
|
+
return a && a.__esModule ? a.default : a;
|
|
9
|
+
}
|
|
10
|
+
/*
|
|
11
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
12
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
13
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
14
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
15
|
+
*
|
|
16
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
17
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
18
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
19
|
+
* governing permissions and limitations under the License.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
function $d6542812f0669241$export$a407b657d3044108(props, state, ref) {
|
|
25
|
+
let { key: key, timer: timer, timeout: timeout, animation: animation } = props.toast;
|
|
26
|
+
(0, $7WpW4$useEffect)(()=>{
|
|
27
|
+
if (!timer) return;
|
|
28
|
+
timer.reset(timeout);
|
|
29
|
+
return ()=>{
|
|
30
|
+
timer.pause();
|
|
31
|
+
};
|
|
32
|
+
}, [
|
|
33
|
+
timer,
|
|
34
|
+
timeout
|
|
35
|
+
]);
|
|
36
|
+
// Restore focus to the toast container on unmount.
|
|
37
|
+
// If there are no more toasts, the container will be unmounted
|
|
38
|
+
// and will restore focus to wherever focus was before the user
|
|
39
|
+
// focused the toast region.
|
|
40
|
+
let focusOnUnmount = (0, $7WpW4$useRef)(null);
|
|
41
|
+
(0, $7WpW4$useLayoutEffect)(()=>{
|
|
42
|
+
let container = ref.current.closest("[role=region]");
|
|
43
|
+
return ()=>{
|
|
44
|
+
if (container && container.contains(document.activeElement)) // Focus must be delayed for focus ring to appear, but we can't wait
|
|
45
|
+
// until useEffect cleanup to check if focus was inside the container.
|
|
46
|
+
focusOnUnmount.current = container;
|
|
47
|
+
};
|
|
48
|
+
}, [
|
|
49
|
+
ref
|
|
50
|
+
]);
|
|
51
|
+
// eslint-disable-next-line
|
|
52
|
+
(0, $7WpW4$useEffect)(()=>{
|
|
53
|
+
return ()=>{
|
|
54
|
+
if (focusOnUnmount.current) focusOnUnmount.current.focus();
|
|
55
|
+
};
|
|
56
|
+
}, [
|
|
57
|
+
ref
|
|
58
|
+
]);
|
|
59
|
+
let titleId = (0, $7WpW4$useId)();
|
|
60
|
+
let descriptionId = (0, $7WpW4$useSlotId)();
|
|
61
|
+
let stringFormatter = (0, $7WpW4$useLocalizedStringFormatter)((0, ($parcel$interopDefault($7WpW4$intlStringsmodulejs))), "@react-aria/toast");
|
|
62
|
+
return {
|
|
63
|
+
toastProps: {
|
|
64
|
+
role: "alert",
|
|
65
|
+
"aria-label": props["aria-label"],
|
|
66
|
+
"aria-labelledby": props["aria-labelledby"] || titleId,
|
|
67
|
+
"aria-describedby": props["aria-describedby"] || descriptionId,
|
|
68
|
+
"aria-details": props["aria-details"],
|
|
69
|
+
// Hide toasts that are animating out so VoiceOver doesn't announce them.
|
|
70
|
+
"aria-hidden": animation === "exiting" ? "true" : undefined
|
|
71
|
+
},
|
|
72
|
+
titleProps: {
|
|
73
|
+
id: titleId
|
|
74
|
+
},
|
|
75
|
+
descriptionProps: {
|
|
76
|
+
id: descriptionId
|
|
77
|
+
},
|
|
78
|
+
closeButtonProps: {
|
|
79
|
+
"aria-label": stringFormatter.format("close"),
|
|
80
|
+
onPress: ()=>state.close(key)
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
export {$d6542812f0669241$export$a407b657d3044108 as useToast};
|
|
87
|
+
//# sourceMappingURL=useToast.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;AA+BM,SAAS,0CAAY,KAAwB,EAAE,KAAoB,EAAE,GAAgC;IAC1G,IAAI,OACF,GAAG,SACH,KAAK,WACL,OAAO,aACP,SAAS,EACV,GAAG,MAAM,KAAK;IAEf,CAAA,GAAA,gBAAQ,EAAE;QACR,IAAI,CAAC,OACH;QAGF,MAAM,KAAK,CAAC;QACZ,OAAO;YACL,MAAM,KAAK;QACb;IACF,GAAG;QAAC;QAAO;KAAQ;IAEnB,mDAAmD;IACnD,+DAA+D;IAC/D,+DAA+D;IAC/D,4BAA4B;IAC5B,IAAI,iBAAiB,CAAA,GAAA,aAAK,EAAE;IAC5B,CAAA,GAAA,sBAAc,EAAE;QACd,IAAI,YAAY,IAAI,OAAO,CAAC,OAAO,CAAC;QACpC,OAAO;YACL,IAAI,aAAa,UAAU,QAAQ,CAAC,SAAS,aAAa,GACxD,oEAAoE;YACpE,sEAAsE;YACtE,eAAe,OAAO,GAAG;QAE7B;IACF,GAAG;QAAC;KAAI;IAER,2BAA2B;IAC3B,CAAA,GAAA,gBAAQ,EAAE;QACR,OAAO;YACL,IAAI,eAAe,OAAO,EACxB,eAAe,OAAO,CAAC,KAAK;QAEhC;IACF,GAAG;QAAC;KAAI;IAER,IAAI,UAAU,CAAA,GAAA,YAAI;IAClB,IAAI,gBAAgB,CAAA,GAAA,gBAAQ;IAC5B,IAAI,kBAAkB,CAAA,GAAA,kCAA0B,EAAE,CAAA,GAAA,oDAAW,GAAG;IAEhE,OAAO;QACL,YAAY;YACV,MAAM;YACN,cAAc,KAAK,CAAC,aAAa;YACjC,mBAAmB,KAAK,CAAC,kBAAkB,IAAI;YAC/C,oBAAoB,KAAK,CAAC,mBAAmB,IAAI;YACjD,gBAAgB,KAAK,CAAC,eAAe;YACrC,yEAAyE;YACzE,eAAe,cAAc,YAAY,SAAS;QACpD;QACA,YAAY;YACV,IAAI;QACN;QACA,kBAAkB;YAChB,IAAI;QACN;QACA,kBAAkB;YAChB,cAAc,gBAAgB,MAAM,CAAC;YACrC,SAAS,IAAM,MAAM,KAAK,CAAC;QAC7B;IACF;AACF","sources":["packages/@react-aria/toast/src/useToast.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {AriaButtonProps} from '@react-types/button';\nimport {AriaLabelingProps, DOMAttributes, FocusableElement} from '@react-types/shared';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport {QueuedToast, ToastState} from '@react-stately/toast';\nimport {RefObject, useEffect, useRef} from 'react';\nimport {useId, useLayoutEffect, useSlotId} from '@react-aria/utils';\nimport {useLocalizedStringFormatter} from '@react-aria/i18n';\n\nexport interface AriaToastProps<T> extends AriaLabelingProps {\n /** The toast object. */\n toast: QueuedToast<T>\n}\n\nexport interface ToastAria {\n /** Props for the toast container element. */\n toastProps: DOMAttributes,\n /** Props for the toast title element. */\n titleProps: DOMAttributes,\n /** Props for the toast description element, if any. */\n descriptionProps: DOMAttributes,\n /** Props for the toast close button. */\n closeButtonProps: AriaButtonProps\n}\n\n/**\n * Provides the behavior and accessibility implementation for a toast component.\n * Toasts display brief, temporary notifications of actions, errors, or other events in an application.\n */\nexport function useToast<T>(props: AriaToastProps<T>, state: ToastState<T>, ref: RefObject<FocusableElement>): ToastAria {\n let {\n key,\n timer,\n timeout,\n animation\n } = props.toast;\n\n useEffect(() => {\n if (!timer) {\n return;\n }\n\n timer.reset(timeout);\n return () => {\n timer.pause();\n };\n }, [timer, timeout]);\n\n // Restore focus to the toast container on unmount.\n // If there are no more toasts, the container will be unmounted\n // and will restore focus to wherever focus was before the user\n // focused the toast region.\n let focusOnUnmount = useRef(null);\n useLayoutEffect(() => {\n let container = ref.current.closest('[role=region]') as HTMLElement;\n return () => {\n if (container && container.contains(document.activeElement)) {\n // Focus must be delayed for focus ring to appear, but we can't wait\n // until useEffect cleanup to check if focus was inside the container.\n focusOnUnmount.current = container;\n }\n };\n }, [ref]);\n\n // eslint-disable-next-line\n useEffect(() => {\n return () => {\n if (focusOnUnmount.current) {\n focusOnUnmount.current.focus();\n }\n };\n }, [ref]);\n\n let titleId = useId();\n let descriptionId = useSlotId();\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/toast');\n\n return {\n toastProps: {\n role: 'alert',\n 'aria-label': props['aria-label'],\n 'aria-labelledby': props['aria-labelledby'] || titleId,\n 'aria-describedby': props['aria-describedby'] || descriptionId,\n 'aria-details': props['aria-details'],\n // Hide toasts that are animating out so VoiceOver doesn't announce them.\n 'aria-hidden': animation === 'exiting' ? 'true' : undefined\n },\n titleProps: {\n id: titleId\n },\n descriptionProps: {\n id: descriptionId\n },\n closeButtonProps: {\n 'aria-label': stringFormatter.format('close'),\n onPress: () => state.close(key)\n }\n };\n}\n"],"names":[],"version":3,"file":"useToast.module.js.map"}
|
|
@@ -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"}
|
package/dist/zh-CN.mjs
CHANGED
package/dist/zh-TW.mjs
CHANGED
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,13 +22,13 @@
|
|
|
22
22
|
"url": "https://github.com/adobe/react-spectrum"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@react-aria/i18n": "^3.
|
|
26
|
-
"@react-aria/interactions": "^3.21.
|
|
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.9.
|
|
31
|
-
"@react-types/shared": "^3.
|
|
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
32
|
"@swc/helpers": "^0.5.0"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
@@ -37,5 +37,5 @@
|
|
|
37
37
|
"publishConfig": {
|
|
38
38
|
"access": "public"
|
|
39
39
|
},
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "f645f29edc1322153fd60af4640cbcab1d992dbd"
|
|
41
41
|
}
|