UNPKG

react-aria-components

Version:

A library of styleable components built using React Aria

178 lines (162 loc) • 8.17 kB
var $b856e6788a7ea5bf$exports = require("./Button.main.js"); var $c5ccf687772c0422$exports = require("./utils.main.js"); var $a8a589c28affdc40$exports = require("./Text.main.js"); var $coXVq$reactaria = require("react-aria"); var $coXVq$reactdom = require("react-dom"); var $coXVq$reactstately = require("react-stately"); var $coXVq$react = require("react"); var $coXVq$reactariassr = require("@react-aria/ssr"); var $coXVq$reactariautils = require("@react-aria/utils"); var $coXVq$reactariaoverlays = require("@react-aria/overlays"); function $parcel$interopDefault(a) { return a && a.__esModule ? a.default : a; } function $parcel$export(e, n, v, s) { Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true}); } $parcel$export(module.exports, "ToastStateContext", () => $4e3fafb90a1b5a5f$export$e9e2a1fc7373c1e1); $parcel$export(module.exports, "ToastRegion", () => $4e3fafb90a1b5a5f$export$2cbf5519fbeaa538); $parcel$export(module.exports, "ToastList", () => $4e3fafb90a1b5a5f$export$c20d626a86a69756); $parcel$export(module.exports, "Toast", () => $4e3fafb90a1b5a5f$export$8d8dc7d5f743331b); $parcel$export(module.exports, "ToastContent", () => $4e3fafb90a1b5a5f$export$b134a6cc89b08851); /* * Copyright 2025 Adobe. All rights reserved. * This file is licensed to you under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. You may obtain a copy * of the License at http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software distributed under * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS * OF ANY KIND, either express or implied. See the License for the specific language * governing permissions and limitations under the License. */ const $4e3fafb90a1b5a5f$export$e9e2a1fc7373c1e1 = /*#__PURE__*/ (0, $coXVq$react.createContext)(null); const $4e3fafb90a1b5a5f$export$2cbf5519fbeaa538 = /*#__PURE__*/ (0, $coXVq$react.forwardRef)(function ToastRegion(props, ref) { let isSSR = (0, $coXVq$reactariassr.useIsSSR)(); let state = (0, $coXVq$reactstately.useToastQueue)(props.queue); let objectRef = (0, $coXVq$reactariautils.useObjectRef)(ref); let { regionProps: regionProps } = (0, $coXVq$reactaria.useToastRegion)(props, state, objectRef); let { focusProps: focusProps, isFocused: isFocused, isFocusVisible: isFocusVisible } = (0, $coXVq$reactaria.useFocusRing)(); let { hoverProps: hoverProps, isHovered: isHovered } = (0, $coXVq$reactaria.useHover)({}); let renderProps = (0, $c5ccf687772c0422$exports.useRenderProps)({ ...props, children: undefined, defaultClassName: 'react-aria-ToastRegion', values: { visibleToasts: state.visibleToasts, isHovered: isHovered, isFocused: isFocused, isFocusVisible: isFocusVisible } }); let { direction: direction } = (0, $coXVq$reactaria.useLocale)(); let portalContainer; let { getContainer: getContainer } = (0, $coXVq$reactariaoverlays.useUNSAFE_PortalContext)(); if (!isSSR) { portalContainer = document.body; if (getContainer) portalContainer = getContainer(); } let region = /*#__PURE__*/ (0, ($parcel$interopDefault($coXVq$react))).createElement($4e3fafb90a1b5a5f$export$e9e2a1fc7373c1e1.Provider, { value: state }, /*#__PURE__*/ (0, ($parcel$interopDefault($coXVq$react))).createElement("div", { ...renderProps, ...(0, $coXVq$reactaria.mergeProps)(regionProps, focusProps, hoverProps), dir: direction, ref: objectRef, "data-hovered": isHovered || undefined, "data-focused": isFocused || undefined, "data-focus-visible": isFocusVisible || undefined }, typeof props.children === 'function' ? /*#__PURE__*/ (0, ($parcel$interopDefault($coXVq$react))).createElement($4e3fafb90a1b5a5f$export$c20d626a86a69756, { ...props, className: undefined, style: { display: 'contents' } }, props.children) : props.children)); return state.visibleToasts.length > 0 && portalContainer ? /*#__PURE__*/ (0, $coXVq$reactdom.createPortal)(region, portalContainer) : null; }); const $4e3fafb90a1b5a5f$export$c20d626a86a69756 = /*#__PURE__*/ (0, $coXVq$react.forwardRef)(function ToastList(props, ref) { let state = (0, $coXVq$react.useContext)($4e3fafb90a1b5a5f$export$e9e2a1fc7373c1e1); let { hoverProps: hoverProps, isHovered: isHovered } = (0, $coXVq$reactaria.useHover)({}); let renderProps = (0, $c5ccf687772c0422$exports.useRenderProps)({ ...props, children: undefined, defaultClassName: 'react-aria-ToastList', values: { visibleToasts: state.visibleToasts, isFocused: false, isFocusVisible: false, isHovered: isHovered } }); return /*#__PURE__*/ (0, ($parcel$interopDefault($coXVq$react))).createElement("ol", { ...hoverProps, ...renderProps, ref: ref }, state.visibleToasts.map((toast)=>/*#__PURE__*/ (0, ($parcel$interopDefault($coXVq$react))).createElement("li", { key: toast.key, style: { display: 'contents' } }, props.children({ toast: toast })))); }); const $4e3fafb90a1b5a5f$export$8d8dc7d5f743331b = /*#__PURE__*/ (0, $coXVq$react.forwardRef)(function Toast(props, ref) { let state = (0, $coXVq$react.useContext)($4e3fafb90a1b5a5f$export$e9e2a1fc7373c1e1); let objectRef = (0, $coXVq$reactariautils.useObjectRef)(ref); let { toastProps: toastProps, contentProps: contentProps, titleProps: titleProps, descriptionProps: descriptionProps, closeButtonProps: closeButtonProps } = (0, $coXVq$reactaria.useToast)(props, state, objectRef); let { focusProps: focusProps, isFocused: isFocused, isFocusVisible: isFocusVisible } = (0, $coXVq$reactaria.useFocusRing)(); let renderProps = (0, $c5ccf687772c0422$exports.useRenderProps)({ ...props, defaultClassName: 'react-aria-Toast', values: { toast: props.toast, isFocused: isFocused, isFocusVisible: isFocusVisible } }); return /*#__PURE__*/ (0, ($parcel$interopDefault($coXVq$react))).createElement("div", { ...renderProps, ...(0, $coXVq$reactaria.mergeProps)(toastProps, focusProps), ref: objectRef, "data-focused": isFocused || undefined, "data-focus-visible": isFocusVisible || undefined }, /*#__PURE__*/ (0, ($parcel$interopDefault($coXVq$react))).createElement((0, $c5ccf687772c0422$exports.Provider), { values: [ [ $4e3fafb90a1b5a5f$export$3a0d85872d9f73f2, contentProps ], [ (0, $a8a589c28affdc40$exports.TextContext), { slots: { [(0, $c5ccf687772c0422$exports.DEFAULT_SLOT)]: {}, title: titleProps, description: descriptionProps } } ], [ (0, $b856e6788a7ea5bf$exports.ButtonContext), { slots: { [(0, $c5ccf687772c0422$exports.DEFAULT_SLOT)]: {}, close: closeButtonProps } } ] ] }, renderProps.children)); }); const $4e3fafb90a1b5a5f$export$3a0d85872d9f73f2 = /*#__PURE__*/ (0, $coXVq$react.createContext)({}); const $4e3fafb90a1b5a5f$export$b134a6cc89b08851 = /*#__PURE__*/ (0, $coXVq$react.forwardRef)(function ToastContent(props, ref) { [props, ref] = (0, $c5ccf687772c0422$exports.useContextProps)(props, ref, $4e3fafb90a1b5a5f$export$3a0d85872d9f73f2); return /*#__PURE__*/ (0, ($parcel$interopDefault($coXVq$react))).createElement("div", { className: "react-aria-ToastContent", ...props, ref: ref }, props.children); }); //# sourceMappingURL=Toast.main.js.map