@react-spectrum/s2
Version:
Spectrum 2 UI components in React
85 lines (76 loc) • 4.07 kB
JavaScript
import "./Provider.css";
import {Fonts as $f333e78089fdffab$export$20f257fc407da7a3} from "./Fonts.mjs";
import {mergeStyles as $feb886035e0d4633$export$e618dc39ac9ad607} from "../icons/runtime.mjs";
import {jsx as $5cZPy$jsx, jsxs as $5cZPy$jsxs} from "react/jsx-runtime";
import {createContext as $5cZPy$createContext, useContext as $5cZPy$useContext} from "react";
import {filterDOMProps as $5cZPy$filterDOMProps} from "@react-aria/utils";
import {I18nProvider as $5cZPy$I18nProvider, RouterProvider as $5cZPy$RouterProvider, useLocale as $5cZPy$useLocale} from "react-aria-components";
/*
* Copyright 2024 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 $9affbfa4e13b9582$export$374e0245597d19a3 = /*#__PURE__*/ (0, $5cZPy$createContext)(null);
function $9affbfa4e13b9582$export$2881499e37b75b9a(props) {
let result = /*#__PURE__*/ (0, $5cZPy$jsx)($9affbfa4e13b9582$var$ProviderInner, {
...props
});
let parentColorScheme = (0, $5cZPy$useContext)($9affbfa4e13b9582$export$374e0245597d19a3);
let colorScheme = props.colorScheme || parentColorScheme;
result = /*#__PURE__*/ (0, $5cZPy$jsx)($9affbfa4e13b9582$export$374e0245597d19a3.Provider, {
value: colorScheme,
children: result
});
if (props.locale) result = /*#__PURE__*/ (0, $5cZPy$jsx)((0, $5cZPy$I18nProvider), {
locale: props.locale,
children: result
});
if (props.router) result = /*#__PURE__*/ (0, $5cZPy$jsx)((0, $5cZPy$RouterProvider), {
...props.router,
children: result
});
return result;
}
undefined;
let $9affbfa4e13b9582$var$providerStyles = function anonymous(props) {
let rules = " ";
if (props.colorScheme === "dark") rules += ' _pa1';
else if (props.colorScheme === "light") rules += ' _pb1';
else if (props.colorScheme === "light dark") rules += ' _pc1';
else rules += ' _pN79Hzc1';
if (props.background === "layer-2") rules += ' -Ovbhqd-g_g1';
else if (props.background === "layer-1") rules += ' -Ovbhqd-gqlRAZb1';
else if (props.background === "base") rules += ' -Ovbhqd-gX1';
if (props.background === "layer-2") rules += ' gEzkoQe1';
else if (props.background === "layer-1") rules += ' gEzkoQe1';
else if (props.background === "base") rules += ' gEzkoQe1';
rules += ' _Bb1';
return rules;
};
function $9affbfa4e13b9582$var$ProviderInner(props) {
let { elementType: Element = 'div', UNSAFE_style: UNSAFE_style, UNSAFE_className: UNSAFE_className = '', styles: styles, children: children, background: // Set a default background if the provider is rendered as the root <html> element.
background = Element === 'html' ? 'base' : undefined, colorScheme: colorScheme } = props;
let { locale: locale, direction: direction } = (0, $5cZPy$useLocale)();
return /*#__PURE__*/ (0, $5cZPy$jsxs)(Element, {
...(0, $5cZPy$filterDOMProps)(props),
lang: locale,
dir: direction,
style: UNSAFE_style,
className: UNSAFE_className + (0, $feb886035e0d4633$export$e618dc39ac9ad607)(styles, $9affbfa4e13b9582$var$providerStyles({
background: background,
colorScheme: colorScheme
})),
children: [
/*#__PURE__*/ (0, $5cZPy$jsx)((0, $f333e78089fdffab$export$20f257fc407da7a3), {}),
children
]
});
}
export {$9affbfa4e13b9582$export$374e0245597d19a3 as ColorSchemeContext, $9affbfa4e13b9582$export$2881499e37b75b9a as Provider};
//# sourceMappingURL=Provider.mjs.map