@react-spectrum/toast 3.0.0-beta.16 → 3.0.0-beta.17
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/ToastContainer.main.js +3 -4
- package/dist/ToastContainer.main.js.map +1 -1
- package/dist/ToastContainer.mjs +3 -4
- package/dist/ToastContainer.module.js +3 -4
- package/dist/ToastContainer.module.js.map +1 -1
- package/dist/Toaster.main.js +1 -1
- package/dist/Toaster.main.js.map +1 -1
- package/dist/Toaster.mjs +1 -1
- package/dist/Toaster.module.js +1 -1
- package/dist/Toaster.module.js.map +1 -1
- package/dist/toastContainer_css.main.js.map +1 -1
- package/dist/toastContainer_css.module.js.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +14 -14
- package/src/ToastContainer.tsx +5 -5
- package/src/Toaster.tsx +1 -1
|
@@ -69,8 +69,7 @@ function $56cdf77f3be52eaf$export$f2815235e76a62b9(props) {
|
|
|
69
69
|
// Only the first one will actually render.
|
|
70
70
|
// We use a ref to do this, since it will have a stable identity
|
|
71
71
|
// over the lifetime of the component.
|
|
72
|
-
let ref = (0, $5IVGU$react.useRef)(
|
|
73
|
-
// eslint-disable-next-line arrow-body-style
|
|
72
|
+
let ref = (0, $5IVGU$react.useRef)(null);
|
|
74
73
|
(0, $5IVGU$react.useEffect)(()=>{
|
|
75
74
|
$56cdf77f3be52eaf$var$toastProviders.add(ref);
|
|
76
75
|
$56cdf77f3be52eaf$var$triggerSubscriptions();
|
|
@@ -115,7 +114,7 @@ function $56cdf77f3be52eaf$var$addToast(children, variant, options = {}) {
|
|
|
115
114
|
}
|
|
116
115
|
});
|
|
117
116
|
let shouldContinue = window.dispatchEvent(event);
|
|
118
|
-
if (!shouldContinue) return;
|
|
117
|
+
if (!shouldContinue) return ()=>{};
|
|
119
118
|
}
|
|
120
119
|
let value = {
|
|
121
120
|
children: children,
|
|
@@ -128,7 +127,7 @@ function $56cdf77f3be52eaf$var$addToast(children, variant, options = {}) {
|
|
|
128
127
|
// Minimum time of 5s from https://spectrum.adobe.com/page/toast/#Auto-dismissible
|
|
129
128
|
// Actionable toasts cannot be auto dismissed. That would fail WCAG SC 2.2.1.
|
|
130
129
|
// It is debatable whether non-actionable toasts would also fail.
|
|
131
|
-
let timeout = options.timeout && !options.onAction ? Math.max(options.timeout, 5000) :
|
|
130
|
+
let timeout = options.timeout && !options.onAction ? Math.max(options.timeout, 5000) : undefined;
|
|
132
131
|
let queue = $56cdf77f3be52eaf$var$getGlobalToastQueue();
|
|
133
132
|
let key = queue.add(value, {
|
|
134
133
|
timeout: timeout,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;AA0BD,uFAAuF;AACvF,IAAI,yCAA0D;AAC9D,SAAS;IACP,IAAI,CAAC,wCACH,yCAAmB,IAAI,CAAA,GAAA,mCAAS,EAAE;QAChC,kBAAkB;QAClB,kBAAkB;IACpB;IAGF,OAAO;AACT;AAGO,SAAS;IACd,yCAAmB;AACrB;AAEA,IAAI,uCAAiB,IAAI;AACzB,IAAI,sCAAgB,IAAI;AACxB,SAAS,gCAAU,EAAc;IAC/B,oCAAc,GAAG,CAAC;IAClB,OAAO,IAAM,oCAAc,MAAM,CAAC;AACpC;AAEA,SAAS;IACP,KAAK,IAAI,MAAM,oCACb;AAEJ;AAEA,SAAS;IACP,OAAO,qCAAe,MAAM,GAAG,IAAI,GAAG,KAAK;AAC7C;AAEA,SAAS;IACP,OAAO,CAAA,GAAA,2DAAmB,EAAE,iCAAW,+CAAyB;AAClE;AAMO,SAAS,0CAAe,KAAkC;IAC/D,+CAA+C;IAC/C,2CAA2C;IAC3C,gEAAgE;IAChE,sCAAsC;IACtC,IAAI,MAAM,CAAA,GAAA,mBAAK,EAAE;
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;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6BAA6B,GAC7B,UAAS,QAAgB,EAAE,UAAgC,CAAC,CAAC;QAC3D,OAAO,+BAAS,UAAU,YAAY;IACxC;IACA,mCAAmC,GACnC,MAAK,QAAgB,EAAE,UAAgC,CAAC,CAAC;QACvD,OAAO,+BAAS,UAAU,QAAQ;IACpC;AACF","sources":["packages/@react-spectrum/toast/src/ToastContainer.tsx"],"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 {AriaToastRegionProps} from '@react-aria/toast';\nimport {classNames} from '@react-spectrum/utils';\nimport {DOMProps} from '@react-types/shared';\nimport {filterDOMProps} from '@react-aria/utils';\nimport React, {ReactElement, useEffect, useRef} from 'react';\nimport {SpectrumToastValue, Toast} from './Toast';\nimport toastContainerStyles from './toastContainer.css';\nimport {Toaster} from './Toaster';\nimport {ToastOptions, ToastQueue, useToastQueue} from '@react-stately/toast';\nimport {useSyncExternalStore} from 'use-sync-external-store/shim/index.js';\n\nexport interface SpectrumToastContainerProps extends AriaToastRegionProps {}\n\nexport interface SpectrumToastOptions extends Omit<ToastOptions, 'priority'>, DOMProps {\n /** A label for the action button within the toast. */\n actionLabel?: string,\n /** Handler that is called when the action button is pressed. */\n onAction?: () => void,\n /** Whether the toast should automatically close when an action is performed. */\n shouldCloseOnAction?: boolean\n}\n\ntype CloseFunction = () => void;\n\n// There is a single global toast queue instance for the whole app, initialized lazily.\nlet globalToastQueue: ToastQueue<SpectrumToastValue> | null = null;\nfunction getGlobalToastQueue() {\n if (!globalToastQueue) {\n globalToastQueue = new ToastQueue({\n maxVisibleToasts: Infinity,\n hasExitAnimation: true\n });\n }\n\n return globalToastQueue;\n}\n\n// For testing. Not exported from the package index.\nexport function clearToastQueue() {\n globalToastQueue = null;\n}\n\nlet toastProviders = new Set();\nlet subscriptions = new Set<() => void>();\nfunction subscribe(fn: () => void) {\n subscriptions.add(fn);\n return () => subscriptions.delete(fn);\n}\n\nfunction triggerSubscriptions() {\n for (let fn of subscriptions) {\n fn();\n }\n}\n\nfunction getActiveToastContainer() {\n return toastProviders.values().next().value;\n}\n\nfunction useActiveToastContainer() {\n return useSyncExternalStore(subscribe, getActiveToastContainer, getActiveToastContainer);\n}\n\n/**\n * A ToastContainer renders the queued toasts in an application. It should be placed\n * at the root of the app.\n */\nexport function ToastContainer(props: SpectrumToastContainerProps): ReactElement | null {\n // Track all toast provider instances in a set.\n // Only the first one will actually render.\n // We use a ref to do this, since it will have a stable identity\n // over the lifetime of the component.\n let ref = useRef(null);\n\n\n useEffect(() => {\n toastProviders.add(ref);\n triggerSubscriptions();\n\n return () => {\n // When this toast provider unmounts, reset all animations so that\n // when the new toast provider renders, it is seamless.\n for (let toast of getGlobalToastQueue().visibleToasts) {\n toast.animation = null;\n }\n\n // Remove this toast provider, and call subscriptions.\n // This will cause all other instances to re-render,\n // and the first one to become the new active toast provider.\n toastProviders.delete(ref);\n triggerSubscriptions();\n };\n }, []);\n\n // Only render if this is the active toast provider instance, and there are visible toasts.\n let activeToastContainer = useActiveToastContainer();\n let state = useToastQueue(getGlobalToastQueue());\n\n if (ref === activeToastContainer && state.visibleToasts.length > 0) {\n return (\n <Toaster state={state} {...props}>\n <ol className={classNames(toastContainerStyles, 'spectrum-ToastContainer-list')}>\n {state.visibleToasts.slice().reverse().map((toast) => (\n <li\n key={toast.key}\n className={classNames(toastContainerStyles, 'spectrum-ToastContainer-listitem')}>\n <Toast\n toast={toast}\n state={state} />\n </li>\n ))}\n </ol>\n </Toaster>\n );\n }\n\n return null;\n}\n\nfunction addToast(children: string, variant: SpectrumToastValue['variant'], options: SpectrumToastOptions = {}) {\n // Dispatch a custom event so that toasts can be intercepted and re-targeted, e.g. when inside an iframe.\n if (typeof CustomEvent !== 'undefined' && typeof window !== 'undefined') {\n let event = new CustomEvent('react-spectrum-toast', {\n cancelable: true,\n bubbles: true,\n detail: {\n children,\n variant,\n options\n }\n });\n\n let shouldContinue = window.dispatchEvent(event);\n if (!shouldContinue) {\n return () => {};\n }\n }\n\n let value = {\n children,\n variant,\n actionLabel: options.actionLabel,\n onAction: options.onAction,\n shouldCloseOnAction: options.shouldCloseOnAction,\n ...filterDOMProps(options)\n };\n\n // Minimum time of 5s from https://spectrum.adobe.com/page/toast/#Auto-dismissible\n // Actionable toasts cannot be auto dismissed. That would fail WCAG SC 2.2.1.\n // It is debatable whether non-actionable toasts would also fail.\n let timeout = options.timeout && !options.onAction ? Math.max(options.timeout, 5000) : undefined;\n let queue = getGlobalToastQueue();\n let key = queue.add(value, {timeout, onClose: options.onClose});\n return () => queue.close(key);\n}\n\nconst SpectrumToastQueue = {\n /** Queues a neutral toast. */\n neutral(children: string, options: SpectrumToastOptions = {}): CloseFunction {\n return addToast(children, 'neutral', options);\n },\n /** Queues a positive toast. */\n positive(children: string, options: SpectrumToastOptions = {}): CloseFunction {\n return addToast(children, 'positive', options);\n },\n /** Queues a negative toast. */\n negative(children: string, options: SpectrumToastOptions = {}): CloseFunction {\n return addToast(children, 'negative', options);\n },\n /** Queues an informational toast. */\n info(children: string, options: SpectrumToastOptions = {}): CloseFunction {\n return addToast(children, 'info', options);\n }\n};\n\nexport {SpectrumToastQueue as ToastQueue};\n"],"names":[],"version":3,"file":"ToastContainer.main.js.map"}
|
package/dist/ToastContainer.mjs
CHANGED
|
@@ -62,8 +62,7 @@ function $02c59b34bd70955a$export$f2815235e76a62b9(props) {
|
|
|
62
62
|
// Only the first one will actually render.
|
|
63
63
|
// We use a ref to do this, since it will have a stable identity
|
|
64
64
|
// over the lifetime of the component.
|
|
65
|
-
let ref = (0, $5lmgI$useRef)(
|
|
66
|
-
// eslint-disable-next-line arrow-body-style
|
|
65
|
+
let ref = (0, $5lmgI$useRef)(null);
|
|
67
66
|
(0, $5lmgI$useEffect)(()=>{
|
|
68
67
|
$02c59b34bd70955a$var$toastProviders.add(ref);
|
|
69
68
|
$02c59b34bd70955a$var$triggerSubscriptions();
|
|
@@ -108,7 +107,7 @@ function $02c59b34bd70955a$var$addToast(children, variant, options = {}) {
|
|
|
108
107
|
}
|
|
109
108
|
});
|
|
110
109
|
let shouldContinue = window.dispatchEvent(event);
|
|
111
|
-
if (!shouldContinue) return;
|
|
110
|
+
if (!shouldContinue) return ()=>{};
|
|
112
111
|
}
|
|
113
112
|
let value = {
|
|
114
113
|
children: children,
|
|
@@ -121,7 +120,7 @@ function $02c59b34bd70955a$var$addToast(children, variant, options = {}) {
|
|
|
121
120
|
// Minimum time of 5s from https://spectrum.adobe.com/page/toast/#Auto-dismissible
|
|
122
121
|
// Actionable toasts cannot be auto dismissed. That would fail WCAG SC 2.2.1.
|
|
123
122
|
// It is debatable whether non-actionable toasts would also fail.
|
|
124
|
-
let timeout = options.timeout && !options.onAction ? Math.max(options.timeout, 5000) :
|
|
123
|
+
let timeout = options.timeout && !options.onAction ? Math.max(options.timeout, 5000) : undefined;
|
|
125
124
|
let queue = $02c59b34bd70955a$var$getGlobalToastQueue();
|
|
126
125
|
let key = queue.add(value, {
|
|
127
126
|
timeout: timeout,
|
|
@@ -62,8 +62,7 @@ function $02c59b34bd70955a$export$f2815235e76a62b9(props) {
|
|
|
62
62
|
// Only the first one will actually render.
|
|
63
63
|
// We use a ref to do this, since it will have a stable identity
|
|
64
64
|
// over the lifetime of the component.
|
|
65
|
-
let ref = (0, $5lmgI$useRef)(
|
|
66
|
-
// eslint-disable-next-line arrow-body-style
|
|
65
|
+
let ref = (0, $5lmgI$useRef)(null);
|
|
67
66
|
(0, $5lmgI$useEffect)(()=>{
|
|
68
67
|
$02c59b34bd70955a$var$toastProviders.add(ref);
|
|
69
68
|
$02c59b34bd70955a$var$triggerSubscriptions();
|
|
@@ -108,7 +107,7 @@ function $02c59b34bd70955a$var$addToast(children, variant, options = {}) {
|
|
|
108
107
|
}
|
|
109
108
|
});
|
|
110
109
|
let shouldContinue = window.dispatchEvent(event);
|
|
111
|
-
if (!shouldContinue) return;
|
|
110
|
+
if (!shouldContinue) return ()=>{};
|
|
112
111
|
}
|
|
113
112
|
let value = {
|
|
114
113
|
children: children,
|
|
@@ -121,7 +120,7 @@ function $02c59b34bd70955a$var$addToast(children, variant, options = {}) {
|
|
|
121
120
|
// Minimum time of 5s from https://spectrum.adobe.com/page/toast/#Auto-dismissible
|
|
122
121
|
// Actionable toasts cannot be auto dismissed. That would fail WCAG SC 2.2.1.
|
|
123
122
|
// It is debatable whether non-actionable toasts would also fail.
|
|
124
|
-
let timeout = options.timeout && !options.onAction ? Math.max(options.timeout, 5000) :
|
|
123
|
+
let timeout = options.timeout && !options.onAction ? Math.max(options.timeout, 5000) : undefined;
|
|
125
124
|
let queue = $02c59b34bd70955a$var$getGlobalToastQueue();
|
|
126
125
|
let key = queue.add(value, {
|
|
127
126
|
timeout: timeout,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;AA0BD,uFAAuF;AACvF,IAAI,yCAA0D;AAC9D,SAAS;IACP,IAAI,CAAC,wCACH,yCAAmB,IAAI,CAAA,GAAA,iBAAS,EAAE;QAChC,kBAAkB;QAClB,kBAAkB;IACpB;IAGF,OAAO;AACT;AAGO,SAAS;IACd,yCAAmB;AACrB;AAEA,IAAI,uCAAiB,IAAI;AACzB,IAAI,sCAAgB,IAAI;AACxB,SAAS,gCAAU,EAAc;IAC/B,oCAAc,GAAG,CAAC;IAClB,OAAO,IAAM,oCAAc,MAAM,CAAC;AACpC;AAEA,SAAS;IACP,KAAK,IAAI,MAAM,oCACb;AAEJ;AAEA,SAAS;IACP,OAAO,qCAAe,MAAM,GAAG,IAAI,GAAG,KAAK;AAC7C;AAEA,SAAS;IACP,O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MAAM,KAAK,CAAC;AAC3B;AAEA,MAAM,4CAAqB;IACzB,4BAA4B,GAC5B,SAAQ,QAAgB,EAAE,UAAgC,CAAC,CAAC;QAC1D,OAAO,+BAAS,UAAU,WAAW;IACvC;IACA,6BAA6B,GAC7B,UAAS,QAAgB,EAAE,UAAgC,CAAC,CAAC;QAC3D,OAAO,+BAAS,UAAU,YAAY;IACxC;IACA,6BAA6B,GAC7B,UAAS,QAAgB,EAAE,UAAgC,CAAC,CAAC;QAC3D,OAAO,+BAAS,UAAU,YAAY;IACxC;IACA,mCAAmC,GACnC,MAAK,QAAgB,EAAE,UAAgC,CAAC,CAAC;QACvD,OAAO,+BAAS,UAAU,QAAQ;IACpC;AACF","sources":["packages/@react-spectrum/toast/src/ToastContainer.tsx"],"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 {AriaToastRegionProps} from '@react-aria/toast';\nimport {classNames} from '@react-spectrum/utils';\nimport {DOMProps} from '@react-types/shared';\nimport {filterDOMProps} from '@react-aria/utils';\nimport React, {ReactElement, useEffect, useRef} from 'react';\nimport {SpectrumToastValue, Toast} from './Toast';\nimport toastContainerStyles from './toastContainer.css';\nimport {Toaster} from './Toaster';\nimport {ToastOptions, ToastQueue, useToastQueue} from '@react-stately/toast';\nimport {useSyncExternalStore} from 'use-sync-external-store/shim/index.js';\n\nexport interface SpectrumToastContainerProps extends AriaToastRegionProps {}\n\nexport interface SpectrumToastOptions extends Omit<ToastOptions, 'priority'>, DOMProps {\n /** A label for the action button within the toast. */\n actionLabel?: string,\n /** Handler that is called when the action button is pressed. */\n onAction?: () => void,\n /** Whether the toast should automatically close when an action is performed. */\n shouldCloseOnAction?: boolean\n}\n\ntype CloseFunction = () => void;\n\n// There is a single global toast queue instance for the whole app, initialized lazily.\nlet globalToastQueue: ToastQueue<SpectrumToastValue> | null = null;\nfunction getGlobalToastQueue() {\n if (!globalToastQueue) {\n globalToastQueue = new ToastQueue({\n maxVisibleToasts: Infinity,\n hasExitAnimation: true\n });\n }\n\n return globalToastQueue;\n}\n\n// For testing. Not exported from the package index.\nexport function clearToastQueue() {\n globalToastQueue = null;\n}\n\nlet toastProviders = new Set();\nlet subscriptions = new Set<() => void>();\nfunction subscribe(fn: () => void) {\n subscriptions.add(fn);\n return () => subscriptions.delete(fn);\n}\n\nfunction triggerSubscriptions() {\n for (let fn of subscriptions) {\n fn();\n }\n}\n\nfunction getActiveToastContainer() {\n return toastProviders.values().next().value;\n}\n\nfunction useActiveToastContainer() {\n return useSyncExternalStore(subscribe, getActiveToastContainer, getActiveToastContainer);\n}\n\n/**\n * A ToastContainer renders the queued toasts in an application. It should be placed\n * at the root of the app.\n */\nexport function ToastContainer(props: SpectrumToastContainerProps): ReactElement | null {\n // Track all toast provider instances in a set.\n // Only the first one will actually render.\n // We use a ref to do this, since it will have a stable identity\n // over the lifetime of the component.\n let ref = useRef(null);\n\n\n useEffect(() => {\n toastProviders.add(ref);\n triggerSubscriptions();\n\n return () => {\n // When this toast provider unmounts, reset all animations so that\n // when the new toast provider renders, it is seamless.\n for (let toast of getGlobalToastQueue().visibleToasts) {\n toast.animation = null;\n }\n\n // Remove this toast provider, and call subscriptions.\n // This will cause all other instances to re-render,\n // and the first one to become the new active toast provider.\n toastProviders.delete(ref);\n triggerSubscriptions();\n };\n }, []);\n\n // Only render if this is the active toast provider instance, and there are visible toasts.\n let activeToastContainer = useActiveToastContainer();\n let state = useToastQueue(getGlobalToastQueue());\n\n if (ref === activeToastContainer && state.visibleToasts.length > 0) {\n return (\n <Toaster state={state} {...props}>\n <ol className={classNames(toastContainerStyles, 'spectrum-ToastContainer-list')}>\n {state.visibleToasts.slice().reverse().map((toast) => (\n <li\n key={toast.key}\n className={classNames(toastContainerStyles, 'spectrum-ToastContainer-listitem')}>\n <Toast\n toast={toast}\n state={state} />\n </li>\n ))}\n </ol>\n </Toaster>\n );\n }\n\n return null;\n}\n\nfunction addToast(children: string, variant: SpectrumToastValue['variant'], options: SpectrumToastOptions = {}) {\n // Dispatch a custom event so that toasts can be intercepted and re-targeted, e.g. when inside an iframe.\n if (typeof CustomEvent !== 'undefined' && typeof window !== 'undefined') {\n let event = new CustomEvent('react-spectrum-toast', {\n cancelable: true,\n bubbles: true,\n detail: {\n children,\n variant,\n options\n }\n });\n\n let shouldContinue = window.dispatchEvent(event);\n if (!shouldContinue) {\n return () => {};\n }\n }\n\n let value = {\n children,\n variant,\n actionLabel: options.actionLabel,\n onAction: options.onAction,\n shouldCloseOnAction: options.shouldCloseOnAction,\n ...filterDOMProps(options)\n };\n\n // Minimum time of 5s from https://spectrum.adobe.com/page/toast/#Auto-dismissible\n // Actionable toasts cannot be auto dismissed. That would fail WCAG SC 2.2.1.\n // It is debatable whether non-actionable toasts would also fail.\n let timeout = options.timeout && !options.onAction ? Math.max(options.timeout, 5000) : undefined;\n let queue = getGlobalToastQueue();\n let key = queue.add(value, {timeout, onClose: options.onClose});\n return () => queue.close(key);\n}\n\nconst SpectrumToastQueue = {\n /** Queues a neutral toast. */\n neutral(children: string, options: SpectrumToastOptions = {}): CloseFunction {\n return addToast(children, 'neutral', options);\n },\n /** Queues a positive toast. */\n positive(children: string, options: SpectrumToastOptions = {}): CloseFunction {\n return addToast(children, 'positive', options);\n },\n /** Queues a negative toast. */\n negative(children: string, options: SpectrumToastOptions = {}): CloseFunction {\n return addToast(children, 'negative', options);\n },\n /** Queues an informational toast. */\n info(children: string, options: SpectrumToastOptions = {}): CloseFunction {\n return addToast(children, 'info', options);\n }\n};\n\nexport {SpectrumToastQueue as ToastQueue};\n"],"names":[],"version":3,"file":"ToastContainer.module.js.map"}
|
package/dist/Toaster.main.js
CHANGED
|
@@ -41,7 +41,7 @@ $parcel$export(module.exports, "Toaster", () => $5b9f2c86c1b1395c$export$fb98e3a
|
|
|
41
41
|
const $5b9f2c86c1b1395c$export$9194c0aa0cd7a9ff = /*#__PURE__*/ (0, $acAHv$react.createContext)(false);
|
|
42
42
|
function $5b9f2c86c1b1395c$export$fb98e3a2a4cd92d7(props) {
|
|
43
43
|
let { children: children, state: state } = props;
|
|
44
|
-
let ref = (0, $acAHv$react.useRef)(
|
|
44
|
+
let ref = (0, $acAHv$react.useRef)(null);
|
|
45
45
|
let { regionProps: regionProps } = (0, $acAHv$reactariatoast.useToastRegion)(props, state, ref);
|
|
46
46
|
let { focusProps: focusProps, isFocusVisible: isFocusVisible } = (0, $acAHv$reactariafocus.useFocusRing)();
|
|
47
47
|
let { getContainer: getContainer } = (0, $acAHv$reactariaoverlays.useUNSTABLE_PortalContext)();
|
package/dist/Toaster.main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;AAkBM,MAAM,0DAAiB,CAAA,GAAA,0BAAY,EAAE;AAErC,SAAS,0CAAQ,KAA0B;IAChD,IAAI,YACF,QAAQ,SACR,KAAK,EACN,GAAG;IAEJ,IAAI,MAAM,CAAA,GAAA,mBAAK,EAAE;IACjB,IAAI,eAAC,WAAW,EAAC,GAAG,CAAA,GAAA,oCAAa,EAAE,OAAO,OAAO;IACjD,IAAI,cAAC,UAAU,kBAAE,cAAc,EAAC,GAAG,CAAA,GAAA,kCAAW;IAC9C,IAAI,gBAAC,YAAY,EAAC,GAAG,CAAA,GAAA,kDAAwB;IAE7C,IAAI,yBACF,0DAAC,CAAA,GAAA,qCAAO;QAAE,cAAc;YAAC,YAAY;QAAa;qBAChD,0DAAC,CAAA,GAAA,gCAAS,uBACR,0DAAC,0CAAe,QAAQ;QAAC,OAAO;qBAC9B,0DAAC;QACE,GAAG,CAAA,GAAA,gCAAS,EAAE,aAAa,WAAW;QACvC,KAAK;QACL,iBAAc;QACd,kBAAe;QACf,WAAW,CAAA,GAAA,oCAAS,EAClB,CAAA,GAAA,mDAAmB,GACnB,iCACA;YAAC,cAAc;QAAc;OAE9B;QAO4B;IAAvC,qBAAO,CAAA,GAAA,yCAAO,EAAE,YAAY,CAAC,UAAU,CAAA,gBAAA,yBAAA,mCAAA,4BAAA,2BAAA,gBAAoB,SAAS,IAAI;AAC1E","sources":["packages/@react-spectrum/toast/src/Toaster.tsx"],"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 {AriaToastRegionProps, useToastRegion} from '@react-aria/toast';\nimport {classNames} from '@react-spectrum/utils';\nimport {FocusScope, useFocusRing} from '@react-aria/focus';\nimport {mergeProps} from '@react-aria/utils';\nimport {Provider} from '@react-spectrum/provider';\nimport React, {createContext, ReactElement, ReactNode, useRef} from 'react';\nimport ReactDOM from 'react-dom';\nimport toastContainerStyles from './toastContainer.css';\nimport {ToastState} from '@react-stately/toast';\nimport {useUNSTABLE_PortalContext} from '@react-aria/overlays';\n\ninterface ToastContainerProps extends AriaToastRegionProps {\n children: ReactNode,\n state: ToastState<unknown>\n}\n\nexport const ToasterContext = createContext(false);\n\nexport function Toaster(props: ToastContainerProps): ReactElement {\n let {\n children,\n state\n } = props;\n\n let ref = useRef(
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;AAkBM,MAAM,0DAAiB,CAAA,GAAA,0BAAY,EAAE;AAErC,SAAS,0CAAQ,KAA0B;IAChD,IAAI,YACF,QAAQ,SACR,KAAK,EACN,GAAG;IAEJ,IAAI,MAAM,CAAA,GAAA,mBAAK,EAAE;IACjB,IAAI,eAAC,WAAW,EAAC,GAAG,CAAA,GAAA,oCAAa,EAAE,OAAO,OAAO;IACjD,IAAI,cAAC,UAAU,kBAAE,cAAc,EAAC,GAAG,CAAA,GAAA,kCAAW;IAC9C,IAAI,gBAAC,YAAY,EAAC,GAAG,CAAA,GAAA,kDAAwB;IAE7C,IAAI,yBACF,0DAAC,CAAA,GAAA,qCAAO;QAAE,cAAc;YAAC,YAAY;QAAa;qBAChD,0DAAC,CAAA,GAAA,gCAAS,uBACR,0DAAC,0CAAe,QAAQ;QAAC,OAAO;qBAC9B,0DAAC;QACE,GAAG,CAAA,GAAA,gCAAS,EAAE,aAAa,WAAW;QACvC,KAAK;QACL,iBAAc;QACd,kBAAe;QACf,WAAW,CAAA,GAAA,oCAAS,EAClB,CAAA,GAAA,mDAAmB,GACnB,iCACA;YAAC,cAAc;QAAc;OAE9B;QAO4B;IAAvC,qBAAO,CAAA,GAAA,yCAAO,EAAE,YAAY,CAAC,UAAU,CAAA,gBAAA,yBAAA,mCAAA,4BAAA,2BAAA,gBAAoB,SAAS,IAAI;AAC1E","sources":["packages/@react-spectrum/toast/src/Toaster.tsx"],"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 {AriaToastRegionProps, useToastRegion} from '@react-aria/toast';\nimport {classNames} from '@react-spectrum/utils';\nimport {FocusScope, useFocusRing} from '@react-aria/focus';\nimport {mergeProps} from '@react-aria/utils';\nimport {Provider} from '@react-spectrum/provider';\nimport React, {createContext, ReactElement, ReactNode, useRef} from 'react';\nimport ReactDOM from 'react-dom';\nimport toastContainerStyles from './toastContainer.css';\nimport {ToastState} from '@react-stately/toast';\nimport {useUNSTABLE_PortalContext} from '@react-aria/overlays';\n\ninterface ToastContainerProps extends AriaToastRegionProps {\n children: ReactNode,\n state: ToastState<unknown>\n}\n\nexport const ToasterContext = createContext(false);\n\nexport function Toaster(props: ToastContainerProps): ReactElement {\n let {\n children,\n state\n } = props;\n\n let ref = useRef(null);\n let {regionProps} = useToastRegion(props, state, ref);\n let {focusProps, isFocusVisible} = useFocusRing();\n let {getContainer} = useUNSTABLE_PortalContext();\n\n let contents = (\n <Provider UNSAFE_style={{background: 'transparent'}}>\n <FocusScope>\n <ToasterContext.Provider value={isFocusVisible}>\n <div\n {...mergeProps(regionProps, focusProps)}\n ref={ref}\n data-position=\"bottom\"\n data-placement=\"center\"\n className={classNames(\n toastContainerStyles,\n 'react-spectrum-ToastContainer',\n {'focus-ring': isFocusVisible}\n )}>\n {children}\n </div>\n </ToasterContext.Provider>\n </FocusScope>\n </Provider>\n );\n\n return ReactDOM.createPortal(contents, getContainer?.() ?? document.body);\n}\n"],"names":[],"version":3,"file":"Toaster.main.js.map"}
|
package/dist/Toaster.mjs
CHANGED
|
@@ -35,7 +35,7 @@ function $parcel$interopDefault(a) {
|
|
|
35
35
|
const $e46feef4e4c28a4b$export$9194c0aa0cd7a9ff = /*#__PURE__*/ (0, $7Pdp8$createContext)(false);
|
|
36
36
|
function $e46feef4e4c28a4b$export$fb98e3a2a4cd92d7(props) {
|
|
37
37
|
let { children: children, state: state } = props;
|
|
38
|
-
let ref = (0, $7Pdp8$useRef)(
|
|
38
|
+
let ref = (0, $7Pdp8$useRef)(null);
|
|
39
39
|
let { regionProps: regionProps } = (0, $7Pdp8$useToastRegion)(props, state, ref);
|
|
40
40
|
let { focusProps: focusProps, isFocusVisible: isFocusVisible } = (0, $7Pdp8$useFocusRing)();
|
|
41
41
|
let { getContainer: getContainer } = (0, $7Pdp8$useUNSTABLE_PortalContext)();
|
package/dist/Toaster.module.js
CHANGED
|
@@ -35,7 +35,7 @@ function $parcel$interopDefault(a) {
|
|
|
35
35
|
const $e46feef4e4c28a4b$export$9194c0aa0cd7a9ff = /*#__PURE__*/ (0, $7Pdp8$createContext)(false);
|
|
36
36
|
function $e46feef4e4c28a4b$export$fb98e3a2a4cd92d7(props) {
|
|
37
37
|
let { children: children, state: state } = props;
|
|
38
|
-
let ref = (0, $7Pdp8$useRef)(
|
|
38
|
+
let ref = (0, $7Pdp8$useRef)(null);
|
|
39
39
|
let { regionProps: regionProps } = (0, $7Pdp8$useToastRegion)(props, state, ref);
|
|
40
40
|
let { focusProps: focusProps, isFocusVisible: isFocusVisible } = (0, $7Pdp8$useFocusRing)();
|
|
41
41
|
let { getContainer: getContainer } = (0, $7Pdp8$useUNSTABLE_PortalContext)();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;AAkBM,MAAM,0DAAiB,CAAA,GAAA,oBAAY,EAAE;AAErC,SAAS,0CAAQ,KAA0B;IAChD,IAAI,YACF,QAAQ,SACR,KAAK,EACN,GAAG;IAEJ,IAAI,MAAM,CAAA,GAAA,aAAK,EAAE;IACjB,IAAI,eAAC,WAAW,EAAC,GAAG,CAAA,GAAA,qBAAa,EAAE,OAAO,OAAO;IACjD,IAAI,cAAC,UAAU,kBAAE,cAAc,EAAC,GAAG,CAAA,GAAA,mBAAW;IAC9C,IAAI,gBAAC,YAAY,EAAC,GAAG,CAAA,GAAA,gCAAwB;IAE7C,IAAI,yBACF,gCAAC,CAAA,GAAA,eAAO;QAAE,cAAc;YAAC,YAAY;QAAa;qBAChD,gCAAC,CAAA,GAAA,iBAAS,uBACR,gCAAC,0CAAe,QAAQ;QAAC,OAAO;qBAC9B,gCAAC;QACE,GAAG,CAAA,GAAA,iBAAS,EAAE,aAAa,WAAW;QACvC,KAAK;QACL,iBAAc;QACd,kBAAe;QACf,WAAW,CAAA,GAAA,iBAAS,EAClB,CAAA,GAAA,2DAAmB,GACnB,iCACA;YAAC,cAAc;QAAc;OAE9B;QAO4B;IAAvC,qBAAO,CAAA,GAAA,eAAO,EAAE,YAAY,CAAC,UAAU,CAAA,gBAAA,yBAAA,mCAAA,4BAAA,2BAAA,gBAAoB,SAAS,IAAI;AAC1E","sources":["packages/@react-spectrum/toast/src/Toaster.tsx"],"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 {AriaToastRegionProps, useToastRegion} from '@react-aria/toast';\nimport {classNames} from '@react-spectrum/utils';\nimport {FocusScope, useFocusRing} from '@react-aria/focus';\nimport {mergeProps} from '@react-aria/utils';\nimport {Provider} from '@react-spectrum/provider';\nimport React, {createContext, ReactElement, ReactNode, useRef} from 'react';\nimport ReactDOM from 'react-dom';\nimport toastContainerStyles from './toastContainer.css';\nimport {ToastState} from '@react-stately/toast';\nimport {useUNSTABLE_PortalContext} from '@react-aria/overlays';\n\ninterface ToastContainerProps extends AriaToastRegionProps {\n children: ReactNode,\n state: ToastState<unknown>\n}\n\nexport const ToasterContext = createContext(false);\n\nexport function Toaster(props: ToastContainerProps): ReactElement {\n let {\n children,\n state\n } = props;\n\n let ref = useRef(
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;AAkBM,MAAM,0DAAiB,CAAA,GAAA,oBAAY,EAAE;AAErC,SAAS,0CAAQ,KAA0B;IAChD,IAAI,YACF,QAAQ,SACR,KAAK,EACN,GAAG;IAEJ,IAAI,MAAM,CAAA,GAAA,aAAK,EAAE;IACjB,IAAI,eAAC,WAAW,EAAC,GAAG,CAAA,GAAA,qBAAa,EAAE,OAAO,OAAO;IACjD,IAAI,cAAC,UAAU,kBAAE,cAAc,EAAC,GAAG,CAAA,GAAA,mBAAW;IAC9C,IAAI,gBAAC,YAAY,EAAC,GAAG,CAAA,GAAA,gCAAwB;IAE7C,IAAI,yBACF,gCAAC,CAAA,GAAA,eAAO;QAAE,cAAc;YAAC,YAAY;QAAa;qBAChD,gCAAC,CAAA,GAAA,iBAAS,uBACR,gCAAC,0CAAe,QAAQ;QAAC,OAAO;qBAC9B,gCAAC;QACE,GAAG,CAAA,GAAA,iBAAS,EAAE,aAAa,WAAW;QACvC,KAAK;QACL,iBAAc;QACd,kBAAe;QACf,WAAW,CAAA,GAAA,iBAAS,EAClB,CAAA,GAAA,2DAAmB,GACnB,iCACA;YAAC,cAAc;QAAc;OAE9B;QAO4B;IAAvC,qBAAO,CAAA,GAAA,eAAO,EAAE,YAAY,CAAC,UAAU,CAAA,gBAAA,yBAAA,mCAAA,4BAAA,2BAAA,gBAAoB,SAAS,IAAI;AAC1E","sources":["packages/@react-spectrum/toast/src/Toaster.tsx"],"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 {AriaToastRegionProps, useToastRegion} from '@react-aria/toast';\nimport {classNames} from '@react-spectrum/utils';\nimport {FocusScope, useFocusRing} from '@react-aria/focus';\nimport {mergeProps} from '@react-aria/utils';\nimport {Provider} from '@react-spectrum/provider';\nimport React, {createContext, ReactElement, ReactNode, useRef} from 'react';\nimport ReactDOM from 'react-dom';\nimport toastContainerStyles from './toastContainer.css';\nimport {ToastState} from '@react-stately/toast';\nimport {useUNSTABLE_PortalContext} from '@react-aria/overlays';\n\ninterface ToastContainerProps extends AriaToastRegionProps {\n children: ReactNode,\n state: ToastState<unknown>\n}\n\nexport const ToasterContext = createContext(false);\n\nexport function Toaster(props: ToastContainerProps): ReactElement {\n let {\n children,\n state\n } = props;\n\n let ref = useRef(null);\n let {regionProps} = useToastRegion(props, state, ref);\n let {focusProps, isFocusVisible} = useFocusRing();\n let {getContainer} = useUNSTABLE_PortalContext();\n\n let contents = (\n <Provider UNSAFE_style={{background: 'transparent'}}>\n <FocusScope>\n <ToasterContext.Provider value={isFocusVisible}>\n <div\n {...mergeProps(regionProps, focusProps)}\n ref={ref}\n data-position=\"bottom\"\n data-placement=\"center\"\n className={classNames(\n toastContainerStyles,\n 'react-spectrum-ToastContainer',\n {'focus-ring': isFocusVisible}\n )}>\n {children}\n </div>\n </ToasterContext.Provider>\n </FocusScope>\n </Provider>\n );\n\n return ReactDOM.createPortal(contents, getContainer?.() ?? document.body);\n}\n"],"names":[],"version":3,"file":"Toaster.module.js.map"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;AAAA,IAAA;AAEA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AAEA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AAZA,4CAA6B,CAAC,eAAe,CAAC;AAC9C;AACA,4CAA+B,CAAC,iBAAiB,CAAC;AAClD,4CAA4C,CAAC,8BAA8B,CAAC;AAC5E,4CAAuC,CAAC,0BAA0B,EAAE,
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;AAAA,IAAA;AAEA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AAEA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AAZA,4CAA6B,CAAC,eAAe,CAAC;AAC9C;AACA,4CAA+B,CAAC,iBAAiB,CAAC;AAClD,4CAA4C,CAAC,8BAA8B,CAAC;AAC5E,4CAAuC,CAAC,0BAA0B,EAAE,2CAA2C;AAC/G,4CAAkD,CAAC,qCAAqC,EAAE,2CAAsC;AAChI,4CAA6B,CAAC,eAAe,CAAC;AAC9C;AACA,4CAA8C,CAAC,gCAAgC,CAAC;AAChF,4CAAmC,CAAC,sBAAsB,EAAE,2CAAsC;AAClG,4CAAkD,CAAC,oCAAoC,CAAC;AACxF,4CAAiD,CAAC,mCAAmC,CAAC;AACtF,4CAAqD,CAAC,uCAAuC,CAAC","sources":["packages/@react-spectrum/toast/src/toastContainer.css"],"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\n@import \"../../../@adobe/spectrum-css-temp/components/commons/focus-ring.css\";\n\n.react-spectrum-ToastContainer {\n composes: spectrum-FocusRing;\n --spectrum-focus-ring-border-radius: var(--spectrum-toast-border-radius);\n --spectrum-focus-ring-gap: var(--spectrum-alias-focus-ring-gap);\n --spectrum-focus-ring-size: var(--spectrum-alias-focus-ring-size);\n\n position: fixed;\n inset-inline-start: 0;\n inset-inline-end: 0;\n z-index: 100050; /* above modals */\n display: flex;\n pointer-events: none;\n outline: none;\n /* keep focus ring inside the viewport */\n margin-block-end: 8px;\n margin-inline: 8px;\n\n .spectrum-Toast {\n margin: 8px;\n pointer-events: all;\n }\n\n &[data-position=top] {\n top: 0;\n flex-direction: column;\n --slide-from: translateY(-100%);\n --slide-to: translateY(0);\n }\n\n &[data-position=bottom] {\n bottom: 0;\n flex-direction: column-reverse;\n --slide-from: translateY(100%);\n --slide-to: translateY(0);\n }\n\n &[data-placement=left] {\n align-items: flex-start;\n --slide-from: translateX(-100%);\n --slide-to: translateX(0);\n\n &:dir(rtl) {\n --slide-from: translateX(100%);\n }\n }\n\n &[data-placement=center] {\n align-items: center;\n }\n\n &[data-placement=right] {\n align-items: flex-end;\n --slide-from: translateX(100%);\n --slide-to: translateX(0);\n\n &:dir(rtl) {\n --slide-from: translateX(-100%);\n }\n }\n}\n\n.spectrum-Toast {\n composes: spectrum-FocusRing;\n --spectrum-focus-ring-border-radius: var(--spectrum-toast-border-radius);\n --spectrum-focus-ring-gap: var(--spectrum-alias-focus-ring-gap);\n --spectrum-focus-ring-size: var(--spectrum-alias-focus-ring-size);\n\n position: relative;\n outline: none;\n\n &[data-animation=entering] {\n animation: slide-in 300ms;\n }\n\n &[data-animation=exiting] {\n animation: fade-out 300ms forwards;\n }\n\n .spectrum-Toast-contentWrapper {\n display: inline-flex;\n }\n}\n\n.spectrum-ToastContainer-list {\n display: inherit;\n flex-direction: inherit;\n align-items: inherit;\n list-style-type: none;\n margin-block-start: 0;\n margin-block-end: 0;\n margin-inline-start: 0;\n margin-inline-end: 0;\n padding-inline-start: 0;\n}\n\n.spectrum-ToastContainer-listitem {\n display: inline-block;\n}\n\n@keyframes slide-in {\n from {\n transform: var(--slide-from);\n }\n\n to {\n transform: var(--slide-to);\n }\n}\n\n@keyframes fade-out {\n from {\n opacity: 1;\n }\n\n to {\n opacity: 0;\n }\n}\n"],"names":[],"version":3,"file":"toastContainer_css.main.js.map"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;AAAA,IAAA;AAEA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AAEA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AAZA,4CAA6B,CAAC,eAAe,CAAC;AAC9C;AACA,4CAA+B,CAAC,iBAAiB,CAAC;AAClD,4CAA4C,CAAC,8BAA8B,CAAC;AAC5E,4CAAuC,CAAC,0BAA0B,EAAE,
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;AAAA,IAAA;AAEA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AAEA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AAZA,4CAA6B,CAAC,eAAe,CAAC;AAC9C;AACA,4CAA+B,CAAC,iBAAiB,CAAC;AAClD,4CAA4C,CAAC,8BAA8B,CAAC;AAC5E,4CAAuC,CAAC,0BAA0B,EAAE,2CAA2C;AAC/G,4CAAkD,CAAC,qCAAqC,EAAE,2CAAsC;AAChI,4CAA6B,CAAC,eAAe,CAAC;AAC9C;AACA,4CAA8C,CAAC,gCAAgC,CAAC;AAChF,4CAAmC,CAAC,sBAAsB,EAAE,2CAAsC;AAClG,4CAAkD,CAAC,oCAAoC,CAAC;AACxF,4CAAiD,CAAC,mCAAmC,CAAC;AACtF,4CAAqD,CAAC,uCAAuC,CAAC","sources":["packages/@react-spectrum/toast/src/toastContainer.css"],"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\n@import \"../../../@adobe/spectrum-css-temp/components/commons/focus-ring.css\";\n\n.react-spectrum-ToastContainer {\n composes: spectrum-FocusRing;\n --spectrum-focus-ring-border-radius: var(--spectrum-toast-border-radius);\n --spectrum-focus-ring-gap: var(--spectrum-alias-focus-ring-gap);\n --spectrum-focus-ring-size: var(--spectrum-alias-focus-ring-size);\n\n position: fixed;\n inset-inline-start: 0;\n inset-inline-end: 0;\n z-index: 100050; /* above modals */\n display: flex;\n pointer-events: none;\n outline: none;\n /* keep focus ring inside the viewport */\n margin-block-end: 8px;\n margin-inline: 8px;\n\n .spectrum-Toast {\n margin: 8px;\n pointer-events: all;\n }\n\n &[data-position=top] {\n top: 0;\n flex-direction: column;\n --slide-from: translateY(-100%);\n --slide-to: translateY(0);\n }\n\n &[data-position=bottom] {\n bottom: 0;\n flex-direction: column-reverse;\n --slide-from: translateY(100%);\n --slide-to: translateY(0);\n }\n\n &[data-placement=left] {\n align-items: flex-start;\n --slide-from: translateX(-100%);\n --slide-to: translateX(0);\n\n &:dir(rtl) {\n --slide-from: translateX(100%);\n }\n }\n\n &[data-placement=center] {\n align-items: center;\n }\n\n &[data-placement=right] {\n align-items: flex-end;\n --slide-from: translateX(100%);\n --slide-to: translateX(0);\n\n &:dir(rtl) {\n --slide-from: translateX(-100%);\n }\n }\n}\n\n.spectrum-Toast {\n composes: spectrum-FocusRing;\n --spectrum-focus-ring-border-radius: var(--spectrum-toast-border-radius);\n --spectrum-focus-ring-gap: var(--spectrum-alias-focus-ring-gap);\n --spectrum-focus-ring-size: var(--spectrum-alias-focus-ring-size);\n\n position: relative;\n outline: none;\n\n &[data-animation=entering] {\n animation: slide-in 300ms;\n }\n\n &[data-animation=exiting] {\n animation: fade-out 300ms forwards;\n }\n\n .spectrum-Toast-contentWrapper {\n display: inline-flex;\n }\n}\n\n.spectrum-ToastContainer-list {\n display: inherit;\n flex-direction: inherit;\n align-items: inherit;\n list-style-type: none;\n margin-block-start: 0;\n margin-block-end: 0;\n margin-inline-start: 0;\n margin-inline-end: 0;\n padding-inline-start: 0;\n}\n\n.spectrum-ToastContainer-listitem {\n display: inline-block;\n}\n\n@keyframes slide-in {\n from {\n transform: var(--slide-from);\n }\n\n to {\n transform: var(--slide-to);\n }\n}\n\n@keyframes fade-out {\n from {\n opacity: 1;\n }\n\n to {\n opacity: 0;\n }\n}\n"],"names":[],"version":3,"file":"toastContainer_css.module.js.map"}
|
package/dist/types.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ type CloseFunction = () => void;
|
|
|
17
17
|
* A ToastContainer renders the queued toasts in an application. It should be placed
|
|
18
18
|
* at the root of the app.
|
|
19
19
|
*/
|
|
20
|
-
export function ToastContainer(props: SpectrumToastContainerProps): ReactElement;
|
|
20
|
+
export function ToastContainer(props: SpectrumToastContainerProps): ReactElement | null;
|
|
21
21
|
export const ToastQueue: {
|
|
22
22
|
/** Queues a neutral toast. */
|
|
23
23
|
neutral(children: string, options?: SpectrumToastOptions): CloseFunction;
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;AEuBA,4CAA6C,SAAQ,oBAAoB;CAAG;AAE5E,qCAAsC,SAAQ,IAAI,CAAC,YAAY,EAAE,UAAU,CAAC,EAAE,QAAQ;IACpF,sDAAsD;IACtD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gEAAgE;IAChE,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,gFAAgF;IAChF,mBAAmB,CAAC,EAAE,OAAO,CAAA;CAC9B;AAED,qBAAqB,MAAM,IAAI,CAAC;AAyChC;;;GAGG;AACH,+BAA+B,KAAK,EAAE,2BAA2B,GAAG,YAAY,
|
|
1
|
+
{"mappings":";;;;AEuBA,4CAA6C,SAAQ,oBAAoB;CAAG;AAE5E,qCAAsC,SAAQ,IAAI,CAAC,YAAY,EAAE,UAAU,CAAC,EAAE,QAAQ;IACpF,sDAAsD;IACtD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gEAAgE;IAChE,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,gFAAgF;IAChF,mBAAmB,CAAC,EAAE,OAAO,CAAA;CAC9B;AAED,qBAAqB,MAAM,IAAI,CAAC;AAyChC;;;GAGG;AACH,+BAA+B,KAAK,EAAE,2BAA2B,GAAG,YAAY,GAAG,IAAI,CAkDtF;AAuCD,OAAA,MAAM;IACJ,8BAA8B;sBACZ,MAAM,YAAW,oBAAoB,GAAQ,aAAa;IAG5E,+BAA+B;uBACZ,MAAM,YAAW,oBAAoB,GAAQ,aAAa;IAG7E,+BAA+B;uBACZ,MAAM,YAAW,oBAAoB,GAAQ,aAAa;IAG7E,qCAAqC;mBACtB,MAAM,YAAW,oBAAoB,GAAQ,aAAa;CAG1E,CAAC","sources":["packages/@react-spectrum/toast/src/packages/@react-spectrum/toast/src/Toast.tsx","packages/@react-spectrum/toast/src/packages/@react-spectrum/toast/src/Toaster.tsx","packages/@react-spectrum/toast/src/packages/@react-spectrum/toast/src/ToastContainer.tsx","packages/@react-spectrum/toast/src/packages/@react-spectrum/toast/src/index.ts","packages/@react-spectrum/toast/src/index.ts"],"sourcesContent":[null,null,null,null,"/*\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\n/// <reference types=\"css-module-types\" />\n\nexport {ToastContainer, ToastQueue} from './ToastContainer';\n\nexport type {SpectrumToastOptions, SpectrumToastContainerProps} from './ToastContainer';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-spectrum/toast",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.17",
|
|
4
4
|
"description": "Spectrum UI components in React",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -36,16 +36,16 @@
|
|
|
36
36
|
"url": "https://github.com/adobe/react-spectrum"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@react-aria/focus": "^3.
|
|
40
|
-
"@react-aria/i18n": "^3.12.
|
|
41
|
-
"@react-aria/overlays": "^3.
|
|
42
|
-
"@react-aria/toast": "3.0.0-beta.
|
|
43
|
-
"@react-aria/utils": "^3.
|
|
44
|
-
"@react-spectrum/button": "^3.16.
|
|
45
|
-
"@react-spectrum/utils": "^3.
|
|
46
|
-
"@react-stately/toast": "3.0.0-beta.
|
|
47
|
-
"@react-types/shared": "^3.
|
|
48
|
-
"@spectrum-icons/ui": "^3.6.
|
|
39
|
+
"@react-aria/focus": "^3.19.0",
|
|
40
|
+
"@react-aria/i18n": "^3.12.4",
|
|
41
|
+
"@react-aria/overlays": "^3.24.0",
|
|
42
|
+
"@react-aria/toast": "3.0.0-beta.18",
|
|
43
|
+
"@react-aria/utils": "^3.26.0",
|
|
44
|
+
"@react-spectrum/button": "^3.16.9",
|
|
45
|
+
"@react-spectrum/utils": "^3.12.0",
|
|
46
|
+
"@react-stately/toast": "3.0.0-beta.7",
|
|
47
|
+
"@react-types/shared": "^3.26.0",
|
|
48
|
+
"@spectrum-icons/ui": "^3.6.11",
|
|
49
49
|
"@swc/helpers": "^0.5.0",
|
|
50
50
|
"use-sync-external-store": "^1.2.0"
|
|
51
51
|
},
|
|
@@ -56,11 +56,11 @@
|
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
58
58
|
"@react-spectrum/provider": "^3.0.0",
|
|
59
|
-
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0",
|
|
60
|
-
"react-dom": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0"
|
|
59
|
+
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1",
|
|
60
|
+
"react-dom": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1"
|
|
61
61
|
},
|
|
62
62
|
"publishConfig": {
|
|
63
63
|
"access": "public"
|
|
64
64
|
},
|
|
65
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "71f0ef23053f9e03ee7e97df736e8b083e006849"
|
|
66
66
|
}
|
package/src/ToastContainer.tsx
CHANGED
|
@@ -77,14 +77,14 @@ function useActiveToastContainer() {
|
|
|
77
77
|
* A ToastContainer renders the queued toasts in an application. It should be placed
|
|
78
78
|
* at the root of the app.
|
|
79
79
|
*/
|
|
80
|
-
export function ToastContainer(props: SpectrumToastContainerProps): ReactElement {
|
|
80
|
+
export function ToastContainer(props: SpectrumToastContainerProps): ReactElement | null {
|
|
81
81
|
// Track all toast provider instances in a set.
|
|
82
82
|
// Only the first one will actually render.
|
|
83
83
|
// We use a ref to do this, since it will have a stable identity
|
|
84
84
|
// over the lifetime of the component.
|
|
85
|
-
let ref = useRef(
|
|
85
|
+
let ref = useRef(null);
|
|
86
|
+
|
|
86
87
|
|
|
87
|
-
// eslint-disable-next-line arrow-body-style
|
|
88
88
|
useEffect(() => {
|
|
89
89
|
toastProviders.add(ref);
|
|
90
90
|
triggerSubscriptions();
|
|
@@ -144,7 +144,7 @@ function addToast(children: string, variant: SpectrumToastValue['variant'], opti
|
|
|
144
144
|
|
|
145
145
|
let shouldContinue = window.dispatchEvent(event);
|
|
146
146
|
if (!shouldContinue) {
|
|
147
|
-
return;
|
|
147
|
+
return () => {};
|
|
148
148
|
}
|
|
149
149
|
}
|
|
150
150
|
|
|
@@ -160,7 +160,7 @@ function addToast(children: string, variant: SpectrumToastValue['variant'], opti
|
|
|
160
160
|
// Minimum time of 5s from https://spectrum.adobe.com/page/toast/#Auto-dismissible
|
|
161
161
|
// Actionable toasts cannot be auto dismissed. That would fail WCAG SC 2.2.1.
|
|
162
162
|
// It is debatable whether non-actionable toasts would also fail.
|
|
163
|
-
let timeout = options.timeout && !options.onAction ? Math.max(options.timeout, 5000) :
|
|
163
|
+
let timeout = options.timeout && !options.onAction ? Math.max(options.timeout, 5000) : undefined;
|
|
164
164
|
let queue = getGlobalToastQueue();
|
|
165
165
|
let key = queue.add(value, {timeout, onClose: options.onClose});
|
|
166
166
|
return () => queue.close(key);
|
package/src/Toaster.tsx
CHANGED
|
@@ -34,7 +34,7 @@ export function Toaster(props: ToastContainerProps): ReactElement {
|
|
|
34
34
|
state
|
|
35
35
|
} = props;
|
|
36
36
|
|
|
37
|
-
let ref = useRef(
|
|
37
|
+
let ref = useRef(null);
|
|
38
38
|
let {regionProps} = useToastRegion(props, state, ref);
|
|
39
39
|
let {focusProps, isFocusVisible} = useFocusRing();
|
|
40
40
|
let {getContainer} = useUNSTABLE_PortalContext();
|