@react-spectrum/toast 3.0.0 → 3.0.2
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/Toast.main.js +2 -2
- package/dist/Toast.mjs +2 -2
- package/dist/Toast.module.js +2 -2
- package/dist/ToastContainer.main.js +1 -1
- package/dist/ToastContainer.main.js.map +1 -1
- package/dist/ToastContainer.mjs +1 -1
- package/dist/ToastContainer.module.js +1 -1
- package/dist/ToastContainer.module.js.map +1 -1
- package/dist/Toaster.main.js +2 -2
- package/dist/Toaster.main.js.map +1 -1
- package/dist/Toaster.mjs +3 -3
- package/dist/Toaster.module.js +3 -3
- package/dist/Toaster.module.js.map +1 -1
- package/dist/{vars.84eec607.css → toast.62356566.css} +1 -1
- package/dist/{vars.84eec607.css.map → toast.62356566.css.map} +1 -1
- package/dist/{toastContainer.6706a095.css → toast.69f125e3.css} +1 -1
- package/dist/{toastContainer.6706a095.css.map → toast.69f125e3.css.map} +1 -1
- package/package.json +12 -12
- package/src/ToastContainer.tsx +1 -1
- package/src/Toaster.tsx +2 -2
package/dist/Toast.main.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var $1e709ec471c88b75$exports = require("./intlStrings.main.js");
|
|
2
|
-
require("./
|
|
2
|
+
require("./toast.62356566.css");
|
|
3
3
|
var $b6e6aa676f8f9e47$exports = require("./toast_vars_css.main.js");
|
|
4
|
-
require("./
|
|
4
|
+
require("./toast.69f125e3.css");
|
|
5
5
|
var $e20782d0579ed886$exports = require("./toastContainer_css.main.js");
|
|
6
6
|
var $8Jify$spectrumiconsuiAlertMedium = require("@spectrum-icons/ui/AlertMedium");
|
|
7
7
|
var $8Jify$reactspectrumbutton = require("@react-spectrum/button");
|
package/dist/Toast.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import $iu2Jc$intlStringsmodulejs from "./intlStrings.mjs";
|
|
2
|
-
import "./
|
|
2
|
+
import "./toast.62356566.css";
|
|
3
3
|
import $iu2Jc$toast_vars_cssmodulejs from "./toast_vars_css.mjs";
|
|
4
|
-
import "./
|
|
4
|
+
import "./toast.69f125e3.css";
|
|
5
5
|
import $iu2Jc$toastContainer_cssmodulejs from "./toastContainer_css.mjs";
|
|
6
6
|
import $iu2Jc$spectrumiconsuiAlertMedium from "@spectrum-icons/ui/AlertMedium";
|
|
7
7
|
import {Button as $iu2Jc$Button, ClearButton as $iu2Jc$ClearButton} from "@react-spectrum/button";
|
package/dist/Toast.module.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import $iu2Jc$intlStringsmodulejs from "./intlStrings.module.js";
|
|
2
|
-
import "./
|
|
2
|
+
import "./toast.62356566.css";
|
|
3
3
|
import $iu2Jc$toast_vars_cssmodulejs from "./toast_vars_css.module.js";
|
|
4
|
-
import "./
|
|
4
|
+
import "./toast.69f125e3.css";
|
|
5
5
|
import $iu2Jc$toastContainer_cssmodulejs from "./toastContainer_css.module.js";
|
|
6
6
|
import $iu2Jc$spectrumiconsuiAlertMedium from "@spectrum-icons/ui/AlertMedium";
|
|
7
7
|
import {Button as $iu2Jc$Button, ClearButton as $iu2Jc$ClearButton} from "@react-spectrum/button";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
var $6c5bd1047ecc310e$exports = require("./Toast.main.js");
|
|
2
|
-
require("./
|
|
2
|
+
require("./toast.69f125e3.css");
|
|
3
3
|
var $e20782d0579ed886$exports = require("./toastContainer_css.main.js");
|
|
4
4
|
var $5b9f2c86c1b1395c$exports = require("./Toaster.main.js");
|
|
5
5
|
var $5IVGU$reactspectrumutils = require("@react-spectrum/utils");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;AA+BD,SAAS,2CAAqB,EAAc;IAC1C,IAAI,yBAAyB,UAC3B,SAAS,mBAAmB,CAAC;QAC3B,CAAA,GAAA,yBAAQ,EAAE;IACZ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AAU,QAAQ,OAAO,IAAI,CAAC,QAAQ,QAAQ,GAAG,KAAK,GAAG,CAAC,QAAQ,OAAO,EAAE,QAAQ;IACvF,IAAI,QAAQ;IACZ,IAAI,MAAM,MAAM,GAAG,CAAC,OAAO;iBAAC;QAAS,SAAS,QAAQ,OAAO;IAAA;IAC7D,OAAO,IAAM,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 {flushSync} from 'react-dom';\nimport React, {ReactElement, useEffect, useMemo, 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 type ToastPlacement = 'top' | 'top end' | 'bottom' | 'bottom end';\n\nexport interface SpectrumToastContainerProps extends AriaToastRegionProps {\n placement?: ToastPlacement\n}\n\nexport interface SpectrumToastOptions extends ToastOptions, 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\nfunction wrapInViewTransition(fn: () => void): void {\n if ('startViewTransition' in document) {\n document.startViewTransition(() => {\n flushSync(fn);\n }).ready.catch(() => {});\n } else {\n fn();\n }\n}\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 wrapUpdate: wrapInViewTransition\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 // 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 let {placement, isCentered} = useMemo(() => {\n let placements = (props.placement ?? 'bottom').split(' ');\n let placement = placements[placements.length - 1];\n let isCentered = placements.length === 1;\n return {placement, isCentered};\n }, [props.placement]);\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.map((toast, index) => {\n let shouldFade = isCentered && index !== 0;\n return (\n <li\n key={toast.key}\n className={classNames(toastContainerStyles, 'spectrum-ToastContainer-listitem')}\n style={{\n viewTransitionName: toast.key,\n viewTransitionClass: classNames(\n toastContainerStyles,\n 'toast',\n placement,\n {'fadeOnly': shouldFade}\n )\n }}>\n <Toast\n toast={toast}\n state={state} />\n </li>\n );\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"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;AA+BD,SAAS,2CAAqB,EAAc;IAC1C,IAAI,yBAAyB,UAC3B,SAAS,mBAAmB,CAAC;QAC3B,CAAA,GAAA,yBAAQ,EAAE;IACZ,GAAG,KAAK,CAAC,KAAK,CAAC,KAAO;SAEtB;AAEJ;AAEA,uFAAuF;AACvF,IAAI,yCAA0D;AAC9D,SAAS;IACP,IAAI,CAAC,wCACH,yCAAmB,IAAI,CAAA,GAAA,mCAAS,EAAE;QAChC,kBAAkB;QAClB,YAAY;IACd;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,q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BAA6B,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 {flushSync} from 'react-dom';\nimport React, {ReactElement, useEffect, useMemo, 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 type ToastPlacement = 'top' | 'top end' | 'bottom' | 'bottom end';\n\nexport interface SpectrumToastContainerProps extends AriaToastRegionProps {\n placement?: ToastPlacement\n}\n\nexport interface SpectrumToastOptions extends ToastOptions, 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\nfunction wrapInViewTransition(fn: () => void): void {\n if ('startViewTransition' in document) {\n document.startViewTransition(() => {\n flushSync(fn);\n }).ready.catch(() => {});\n } else {\n fn();\n }\n}\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 wrapUpdate: wrapInViewTransition\n });\n }\n\n return globalToastQueue;\n}\n\n// For testing. Not exported from the package index.\nexport function clearToastQueue(): void {\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 // 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 let {placement, isCentered} = useMemo(() => {\n let placements = (props.placement ?? 'bottom').split(' ');\n let placement = placements[placements.length - 1];\n let isCentered = placements.length === 1;\n return {placement, isCentered};\n }, [props.placement]);\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.map((toast, index) => {\n let shouldFade = isCentered && index !== 0;\n return (\n <li\n key={toast.key}\n className={classNames(toastContainerStyles, 'spectrum-ToastContainer-listitem')}\n style={{\n viewTransitionName: toast.key,\n viewTransitionClass: classNames(\n toastContainerStyles,\n 'toast',\n placement,\n {'fadeOnly': shouldFade}\n )\n }}>\n <Toast\n toast={toast}\n state={state} />\n </li>\n );\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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {Toast as $7e7a2952509f3a56$export$8d8dc7d5f743331b} from "./Toast.mjs";
|
|
2
|
-
import "./
|
|
2
|
+
import "./toast.69f125e3.css";
|
|
3
3
|
import $5lmgI$toastContainer_cssmodulejs from "./toastContainer_css.mjs";
|
|
4
4
|
import {Toaster as $e46feef4e4c28a4b$export$fb98e3a2a4cd92d7} from "./Toaster.mjs";
|
|
5
5
|
import {classNames as $5lmgI$classNames} from "@react-spectrum/utils";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {Toast as $7e7a2952509f3a56$export$8d8dc7d5f743331b} from "./Toast.module.js";
|
|
2
|
-
import "./
|
|
2
|
+
import "./toast.69f125e3.css";
|
|
3
3
|
import $5lmgI$toastContainer_cssmodulejs from "./toastContainer_css.module.js";
|
|
4
4
|
import {Toaster as $e46feef4e4c28a4b$export$fb98e3a2a4cd92d7} from "./Toaster.module.js";
|
|
5
5
|
import {classNames as $5lmgI$classNames} from "@react-spectrum/utils";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;AA+BD,SAAS,2CAAqB,EAAc;IAC1C,IAAI,yBAAyB,UAC3B,SAAS,mBAAmB,CAAC;QAC3B,CAAA,GAAA,gBAAQ,EAAE;IACZ,GAAG,KAAK,CAAC,KAAK,CAAC,KAAO;SAEtB;AAEJ;AAEA,uFAAuF;AACvF,IAAI,yCAA0D;AAC9D,SAAS;IACP,IAAI,CAAC,wCACH,yCAAmB,IAAI,CAAA,GAAA,iBAAS,EAAE;QAChC,kBAAkB;QAClB,YAAY;IACd;IAGF,OAAO;AACT;AAGO,SAAS;IACd,yCAAmB;AACrB;A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AAM,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 {flushSync} from 'react-dom';\nimport React, {ReactElement, useEffect, useMemo, 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 type ToastPlacement = 'top' | 'top end' | 'bottom' | 'bottom end';\n\nexport interface SpectrumToastContainerProps extends AriaToastRegionProps {\n placement?: ToastPlacement\n}\n\nexport interface SpectrumToastOptions extends ToastOptions, 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\nfunction wrapInViewTransition(fn: () => void): void {\n if ('startViewTransition' in document) {\n document.startViewTransition(() => {\n flushSync(fn);\n }).ready.catch(() => {});\n } else {\n fn();\n }\n}\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 wrapUpdate: wrapInViewTransition\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 // 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 let {placement, isCentered} = useMemo(() => {\n let placements = (props.placement ?? 'bottom').split(' ');\n let placement = placements[placements.length - 1];\n let isCentered = placements.length === 1;\n return {placement, isCentered};\n }, [props.placement]);\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.map((toast, index) => {\n let shouldFade = isCentered && index !== 0;\n return (\n <li\n key={toast.key}\n className={classNames(toastContainerStyles, 'spectrum-ToastContainer-listitem')}\n style={{\n viewTransitionName: toast.key,\n viewTransitionClass: classNames(\n toastContainerStyles,\n 'toast',\n placement,\n {'fadeOnly': shouldFade}\n )\n }}>\n <Toast\n toast={toast}\n state={state} />\n </li>\n );\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"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;AA+BD,SAAS,2CAAqB,EAAc;IAC1C,IAAI,yBAAyB,UAC3B,SAAS,mBAAmB,CAAC;QAC3B,CAAA,GAAA,gBAAQ,EAAE;IACZ,GAAG,KAAK,CAAC,KAAK,CAAC,KAAO;SAEtB;AAEJ;AAEA,uFAAuF;AACvF,IAAI,yCAA0D;AAC9D,SAAS;IACP,IAAI,CAAC,wCACH,yCAAmB,IAAI,CAAA,GAAA,iBAAS,EAAE;QAChC,kBAAkB;QAClB,YAAY;IACd;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,2BAAmB,EAAE,iCAAW,+CAAyB;AAClE;AAMO,SAAS,0CAAe,KAAkC;IAC/D,+CAA+C;IAC/C,2CAA2C;IAC3C,gEAAgE;IAChE,sCAAsC;IACtC,IAAI,MAAM,CAAA,GAAA,aAAK,EAAE;IAGjB,CAA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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 {flushSync} from 'react-dom';\nimport React, {ReactElement, useEffect, useMemo, 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 type ToastPlacement = 'top' | 'top end' | 'bottom' | 'bottom end';\n\nexport interface SpectrumToastContainerProps extends AriaToastRegionProps {\n placement?: ToastPlacement\n}\n\nexport interface SpectrumToastOptions extends ToastOptions, 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\nfunction wrapInViewTransition(fn: () => void): void {\n if ('startViewTransition' in document) {\n document.startViewTransition(() => {\n flushSync(fn);\n }).ready.catch(() => {});\n } else {\n fn();\n }\n}\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 wrapUpdate: wrapInViewTransition\n });\n }\n\n return globalToastQueue;\n}\n\n// For testing. Not exported from the package index.\nexport function clearToastQueue(): void {\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 // 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 let {placement, isCentered} = useMemo(() => {\n let placements = (props.placement ?? 'bottom').split(' ');\n let placement = placements[placements.length - 1];\n let isCentered = placements.length === 1;\n return {placement, isCentered};\n }, [props.placement]);\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.map((toast, index) => {\n let shouldFade = isCentered && index !== 0;\n return (\n <li\n key={toast.key}\n className={classNames(toastContainerStyles, 'spectrum-ToastContainer-listitem')}\n style={{\n viewTransitionName: toast.key,\n viewTransitionClass: classNames(\n toastContainerStyles,\n 'toast',\n placement,\n {'fadeOnly': shouldFade}\n )\n }}>\n <Toast\n toast={toast}\n state={state} />\n </li>\n );\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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require("./
|
|
1
|
+
require("./toast.69f125e3.css");
|
|
2
2
|
var $e20782d0579ed886$exports = require("./toastContainer_css.main.js");
|
|
3
3
|
var $acAHv$reactariatoast = require("@react-aria/toast");
|
|
4
4
|
var $acAHv$reactspectrumutils = require("@react-spectrum/utils");
|
|
@@ -44,7 +44,7 @@ function $5b9f2c86c1b1395c$export$fb98e3a2a4cd92d7(props) {
|
|
|
44
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
|
-
let { getContainer: getContainer } = (0, $acAHv$reactariaoverlays.
|
|
47
|
+
let { getContainer: getContainer } = (0, $acAHv$reactariaoverlays.useUNSAFE_PortalContext)();
|
|
48
48
|
let [position, placement] = (0, $acAHv$react.useMemo)(()=>{
|
|
49
49
|
var _props_placement;
|
|
50
50
|
let [pos = 'bottom', place = 'center'] = ((_props_placement = props.placement) === null || _props_placement === void 0 ? void 0 : _props_placement.split(' ')) || [];
|
package/dist/Toaster.main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;AAoBM,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,
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;AAoBM,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,gDAAsB;IAE3C,IAAI,CAAC,UAAU,UAAU,GAAG,CAAA,GAAA,oBAAM,EAAE;YACO;QAAzC,IAAI,CAAC,MAAM,QAAQ,EAAE,QAAQ,QAAQ,CAAC,GAAG,EAAA,mBAAA,MAAM,SAAS,cAAf,uCAAA,iBAAiB,KAAK,CAAC,SAAQ,EAAE;QAC1E,OAAO;YAAC;YAAK;SAAM;IACrB,GAAG;QAAC,MAAM,SAAS;KAAC;IAEpB,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,iBAAe;QACf,kBAAgB;QAChB,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, useMemo, useRef} from 'react';\nimport ReactDOM from 'react-dom';\nimport toastContainerStyles from './toastContainer.css';\nimport type {ToastPlacement} from './ToastContainer';\nimport {ToastState} from '@react-stately/toast';\nimport {useUNSAFE_PortalContext} from '@react-aria/overlays';\n\ninterface ToastContainerProps extends AriaToastRegionProps {\n children: ReactNode,\n state: ToastState<unknown>,\n placement?: ToastPlacement\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} = useUNSAFE_PortalContext();\n\n let [position, placement] = useMemo(() => {\n let [pos = 'bottom', place = 'center'] = props.placement?.split(' ') || [];\n return [pos, place];\n }, [props.placement]);\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={position}\n data-placement={placement}\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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "./
|
|
1
|
+
import "./toast.69f125e3.css";
|
|
2
2
|
import $7Pdp8$toastContainer_cssmodulejs from "./toastContainer_css.mjs";
|
|
3
3
|
import {useToastRegion as $7Pdp8$useToastRegion} from "@react-aria/toast";
|
|
4
4
|
import {classNames as $7Pdp8$classNames} from "@react-spectrum/utils";
|
|
@@ -7,7 +7,7 @@ import {mergeProps as $7Pdp8$mergeProps} from "@react-aria/utils";
|
|
|
7
7
|
import {Provider as $7Pdp8$Provider} from "@react-spectrum/provider";
|
|
8
8
|
import $7Pdp8$react, {createContext as $7Pdp8$createContext, useRef as $7Pdp8$useRef, useMemo as $7Pdp8$useMemo} from "react";
|
|
9
9
|
import $7Pdp8$reactdom from "react-dom";
|
|
10
|
-
import {
|
|
10
|
+
import {useUNSAFE_PortalContext as $7Pdp8$useUNSAFE_PortalContext} from "@react-aria/overlays";
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
function $parcel$interopDefault(a) {
|
|
@@ -38,7 +38,7 @@ function $e46feef4e4c28a4b$export$fb98e3a2a4cd92d7(props) {
|
|
|
38
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
|
-
let { getContainer: getContainer } = (0, $7Pdp8$
|
|
41
|
+
let { getContainer: getContainer } = (0, $7Pdp8$useUNSAFE_PortalContext)();
|
|
42
42
|
let [position, placement] = (0, $7Pdp8$useMemo)(()=>{
|
|
43
43
|
var _props_placement;
|
|
44
44
|
let [pos = 'bottom', place = 'center'] = ((_props_placement = props.placement) === null || _props_placement === void 0 ? void 0 : _props_placement.split(' ')) || [];
|
package/dist/Toaster.module.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "./
|
|
1
|
+
import "./toast.69f125e3.css";
|
|
2
2
|
import $7Pdp8$toastContainer_cssmodulejs from "./toastContainer_css.module.js";
|
|
3
3
|
import {useToastRegion as $7Pdp8$useToastRegion} from "@react-aria/toast";
|
|
4
4
|
import {classNames as $7Pdp8$classNames} from "@react-spectrum/utils";
|
|
@@ -7,7 +7,7 @@ import {mergeProps as $7Pdp8$mergeProps} from "@react-aria/utils";
|
|
|
7
7
|
import {Provider as $7Pdp8$Provider} from "@react-spectrum/provider";
|
|
8
8
|
import $7Pdp8$react, {createContext as $7Pdp8$createContext, useRef as $7Pdp8$useRef, useMemo as $7Pdp8$useMemo} from "react";
|
|
9
9
|
import $7Pdp8$reactdom from "react-dom";
|
|
10
|
-
import {
|
|
10
|
+
import {useUNSAFE_PortalContext as $7Pdp8$useUNSAFE_PortalContext} from "@react-aria/overlays";
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
function $parcel$interopDefault(a) {
|
|
@@ -38,7 +38,7 @@ function $e46feef4e4c28a4b$export$fb98e3a2a4cd92d7(props) {
|
|
|
38
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
|
-
let { getContainer: getContainer } = (0, $7Pdp8$
|
|
41
|
+
let { getContainer: getContainer } = (0, $7Pdp8$useUNSAFE_PortalContext)();
|
|
42
42
|
let [position, placement] = (0, $7Pdp8$useMemo)(()=>{
|
|
43
43
|
var _props_placement;
|
|
44
44
|
let [pos = 'bottom', place = 'center'] = ((_props_placement = props.placement) === null || _props_placement === void 0 ? void 0 : _props_placement.split(' ')) || [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;AAoBM,MAAM,0DAAiB,CAAA,GAAA,oBAAY,EAAE;AAErC,SAAS,0C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AAe;QACf,kBAAgB;QAChB,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, useMemo, useRef} from 'react';\nimport ReactDOM from 'react-dom';\nimport toastContainerStyles from './toastContainer.css';\nimport type {ToastPlacement} from './ToastContainer';\nimport {ToastState} from '@react-stately/toast';\nimport {useUNSAFE_PortalContext} from '@react-aria/overlays';\n\ninterface ToastContainerProps extends AriaToastRegionProps {\n children: ReactNode,\n state: ToastState<unknown>,\n placement?: ToastPlacement\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} = useUNSAFE_PortalContext();\n\n let [position, placement] = useMemo(() => {\n let [pos = 'bottom', place = 'center'] = props.placement?.split(' ') || [];\n return [pos, place];\n }, [props.placement]);\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={position}\n data-placement={placement}\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":"AAwBA;;;;;;;;;;;;;;;AAkBA;;;;;;;;;AAUA;;;;;;;;;AASA;;;;;;;;;AAUI;;;;AAOJ;;;;;;;;;;AAwBA;;;;;AAKA;;;;AAIA;;;;AAIA;;;;AAIA;;;;AAIA;;;;AAIA;;;;AAIA;EACE","sources":["packages/@adobe/spectrum-css-temp/components/toast/vars.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 './index.css';\n@import './skin.css';\n"],"names":[],"version":3,"file":"
|
|
1
|
+
{"mappings":"AAwBA;;;;;;;;;;;;;;;AAkBA;;;;;;;;;AAUA;;;;;;;;;AASA;;;;;;;;;AAUI;;;;AAOJ;;;;;;;;;;AAwBA;;;;;AAKA;;;;AAIA;;;;AAIA;;;;AAIA;;;;AAIA;;;;AAIA;;;;AAIA;EACE","sources":["packages/@adobe/spectrum-css-temp/components/toast/vars.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 './index.css';\n@import './skin.css';\n"],"names":[],"version":3,"file":"toast.62356566.css.map"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"AAYA;;;;;;;;AAOE;;;;;;;;;;;AAqBE;;;;;AAQF;;;;AAKE;;;;;AAOJ;EACE;;;;EAIE;;;;;AAMJ;;;;;;;;;;;;;;;AAiBE;;;;;AAKA;;;;;;AAMA;;;;;;AAMA;;;;;AAIE;;;;AAAA;;;;AAKF;;;;AAIA;;;;;AAIE;;;;AAAA;;;;AAMJ;;;;;;;;AASE;;;;AAKF;;;;;;;;;AASA;;;;;AAKA;;;;;;;AAOA;;;;;;;AAOA;;;;;;AAMA;;;;AAIA;;;;;AAKA;;;;;AAKA;;;;;AAKA;;;;;AAKA;;;;AAIA;;;;AAIA","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 }\n\n &[data-position=bottom] {\n bottom: 0;\n flex-direction: column-reverse;\n --slide-from: translateY(100%);\n }\n\n &[data-placement=start] {\n align-items: flex-start;\n --slide-from: translateX(-100%);\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=end] {\n align-items: flex-end;\n --slide-from: translateX(100%);\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 .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: 0;\n padding-inline-start: 0;\n}\n\n.spectrum-ToastContainer-listitem {\n display: inline-block;\n view-transition-class: toast;\n}\n\n@keyframes slide-in {\n from {\n translate: var(--slideX) var(--slideY);\n opacity: 0;\n }\n}\n\n@keyframes slide-out {\n to {\n translate: var(--slideX) var(--slideY);\n opacity: 0;\n }\n}\n\n@keyframes fade-out {\n to {\n opacity: 0;\n }\n}\n\n::view-transition-group(.toast) {\n animation-duration: 300ms;\n}\n\n::view-transition-group(.toast.bottom) {\n --slideX: 0;\n --slideY: calc(100% + 12px);\n}\n\n::view-transition-group(.toast.top) {\n --slideX: 0;\n --slideY: calc(-100% - 12px);\n}\n\n::view-transition-group(.toast.start) {\n --slideX: calc(-100% - 12px);\n --slideY: 0;\n}\n\n::view-transition-group(.toast.end) {\n --slideX: calc(100% + 12px);\n --slideY: 0;\n}\n\n::view-transition-new(.toast):only-child {\n animation-name: slide-in;\n}\n\n::view-transition-old(.toast):only-child {\n animation-name: slide-out;\n}\n\n::view-transition-old(.toast.fadeOnly):only-child {\n animation-name: fade-out;\n}\n"],"names":[],"version":3,"file":"
|
|
1
|
+
{"mappings":"AAYA;;;;;;;;AAOE;;;;;;;;;;;AAqBE;;;;;AAQF;;;;AAKE;;;;;AAOJ;EACE;;;;EAIE;;;;;AAMJ;;;;;;;;;;;;;;;AAiBE;;;;;AAKA;;;;;;AAMA;;;;;;AAMA;;;;;AAIE;;;;AAAA;;;;AAKF;;;;AAIA;;;;;AAIE;;;;AAAA;;;;AAMJ;;;;;;;;AASE;;;;AAKF;;;;;;;;;AASA;;;;;AAKA;;;;;;;AAOA;;;;;;;AAOA;;;;;;AAMA;;;;AAIA;;;;;AAKA;;;;;AAKA;;;;;AAKA;;;;;AAKA;;;;AAIA;;;;AAIA","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 }\n\n &[data-position=bottom] {\n bottom: 0;\n flex-direction: column-reverse;\n --slide-from: translateY(100%);\n }\n\n &[data-placement=start] {\n align-items: flex-start;\n --slide-from: translateX(-100%);\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=end] {\n align-items: flex-end;\n --slide-from: translateX(100%);\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 .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: 0;\n padding-inline-start: 0;\n}\n\n.spectrum-ToastContainer-listitem {\n display: inline-block;\n view-transition-class: toast;\n}\n\n@keyframes slide-in {\n from {\n translate: var(--slideX) var(--slideY);\n opacity: 0;\n }\n}\n\n@keyframes slide-out {\n to {\n translate: var(--slideX) var(--slideY);\n opacity: 0;\n }\n}\n\n@keyframes fade-out {\n to {\n opacity: 0;\n }\n}\n\n::view-transition-group(.toast) {\n animation-duration: 300ms;\n}\n\n::view-transition-group(.toast.bottom) {\n --slideX: 0;\n --slideY: calc(100% + 12px);\n}\n\n::view-transition-group(.toast.top) {\n --slideX: 0;\n --slideY: calc(-100% - 12px);\n}\n\n::view-transition-group(.toast.start) {\n --slideX: calc(-100% - 12px);\n --slideY: 0;\n}\n\n::view-transition-group(.toast.end) {\n --slideX: calc(100% + 12px);\n --slideY: 0;\n}\n\n::view-transition-new(.toast):only-child {\n animation-name: slide-in;\n}\n\n::view-transition-old(.toast):only-child {\n animation-name: slide-out;\n}\n\n::view-transition-old(.toast.fadeOnly):only-child {\n animation-name: fade-out;\n}\n"],"names":[],"version":3,"file":"toast.69f125e3.css.map"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-spectrum/toast",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.2",
|
|
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.20.
|
|
40
|
-
"@react-aria/i18n": "^3.12.
|
|
41
|
-
"@react-aria/overlays": "^3.
|
|
42
|
-
"@react-aria/toast": "^3.0.
|
|
43
|
-
"@react-aria/utils": "^3.28.
|
|
44
|
-
"@react-spectrum/button": "^3.16.
|
|
45
|
-
"@react-spectrum/utils": "^3.12.
|
|
46
|
-
"@react-stately/toast": "^3.
|
|
47
|
-
"@react-types/shared": "^3.
|
|
48
|
-
"@spectrum-icons/ui": "^3.6.
|
|
39
|
+
"@react-aria/focus": "^3.20.2",
|
|
40
|
+
"@react-aria/i18n": "^3.12.8",
|
|
41
|
+
"@react-aria/overlays": "^3.27.0",
|
|
42
|
+
"@react-aria/toast": "^3.0.2",
|
|
43
|
+
"@react-aria/utils": "^3.28.2",
|
|
44
|
+
"@react-spectrum/button": "^3.16.13",
|
|
45
|
+
"@react-spectrum/utils": "^3.12.4",
|
|
46
|
+
"@react-stately/toast": "^3.1.0",
|
|
47
|
+
"@react-types/shared": "^3.29.0",
|
|
48
|
+
"@spectrum-icons/ui": "^3.6.15",
|
|
49
49
|
"@swc/helpers": "^0.5.0",
|
|
50
50
|
"use-sync-external-store": "^1.4.0"
|
|
51
51
|
},
|
|
@@ -62,5 +62,5 @@
|
|
|
62
62
|
"publishConfig": {
|
|
63
63
|
"access": "public"
|
|
64
64
|
},
|
|
65
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "9b66d270572f482948afee95622a85cdf68ed408"
|
|
66
66
|
}
|
package/src/ToastContainer.tsx
CHANGED
package/src/Toaster.tsx
CHANGED
|
@@ -20,7 +20,7 @@ import ReactDOM from 'react-dom';
|
|
|
20
20
|
import toastContainerStyles from './toastContainer.css';
|
|
21
21
|
import type {ToastPlacement} from './ToastContainer';
|
|
22
22
|
import {ToastState} from '@react-stately/toast';
|
|
23
|
-
import {
|
|
23
|
+
import {useUNSAFE_PortalContext} from '@react-aria/overlays';
|
|
24
24
|
|
|
25
25
|
interface ToastContainerProps extends AriaToastRegionProps {
|
|
26
26
|
children: ReactNode,
|
|
@@ -39,7 +39,7 @@ export function Toaster(props: ToastContainerProps): ReactElement {
|
|
|
39
39
|
let ref = useRef(null);
|
|
40
40
|
let {regionProps} = useToastRegion(props, state, ref);
|
|
41
41
|
let {focusProps, isFocusVisible} = useFocusRing();
|
|
42
|
-
let {getContainer} =
|
|
42
|
+
let {getContainer} = useUNSAFE_PortalContext();
|
|
43
43
|
|
|
44
44
|
let [position, placement] = useMemo(() => {
|
|
45
45
|
let [pos = 'bottom', place = 'center'] = props.placement?.split(' ') || [];
|