@react-spectrum/s2
Version:
Spectrum 2 UI components in React
91 lines (80 loc) • 4.21 kB
JavaScript
require("./Provider.css");
var $55e0379377484943$exports = require("./Fonts.cjs");
var $308b180f49d82d28$exports = require("../icons/runtime.cjs");
var $jc3A8$reactjsxruntime = require("react/jsx-runtime");
var $jc3A8$react = require("react");
var $jc3A8$reactariautils = require("@react-aria/utils");
var $jc3A8$reactariacomponents = require("react-aria-components");
function $parcel$export(e, n, v, s) {
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
}
$parcel$export(module.exports, "ColorSchemeContext", () => $914a06b3a1c679bc$export$374e0245597d19a3);
$parcel$export(module.exports, "Provider", () => $914a06b3a1c679bc$export$2881499e37b75b9a);
/*
* 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 $914a06b3a1c679bc$export$374e0245597d19a3 = /*#__PURE__*/ (0, $jc3A8$react.createContext)(null);
function $914a06b3a1c679bc$export$2881499e37b75b9a(props) {
let result = /*#__PURE__*/ (0, $jc3A8$reactjsxruntime.jsx)($914a06b3a1c679bc$var$ProviderInner, {
...props
});
let parentColorScheme = (0, $jc3A8$react.useContext)($914a06b3a1c679bc$export$374e0245597d19a3);
let colorScheme = props.colorScheme || parentColorScheme;
result = /*#__PURE__*/ (0, $jc3A8$reactjsxruntime.jsx)($914a06b3a1c679bc$export$374e0245597d19a3.Provider, {
value: colorScheme,
children: result
});
if (props.locale) result = /*#__PURE__*/ (0, $jc3A8$reactjsxruntime.jsx)((0, $jc3A8$reactariacomponents.I18nProvider), {
locale: props.locale,
children: result
});
if (props.router) result = /*#__PURE__*/ (0, $jc3A8$reactjsxruntime.jsx)((0, $jc3A8$reactariacomponents.RouterProvider), {
...props.router,
children: result
});
return result;
}
undefined;
let $914a06b3a1c679bc$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 $914a06b3a1c679bc$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, $jc3A8$reactariacomponents.useLocale)();
return /*#__PURE__*/ (0, $jc3A8$reactjsxruntime.jsxs)(Element, {
...(0, $jc3A8$reactariautils.filterDOMProps)(props),
lang: locale,
dir: direction,
style: UNSAFE_style,
className: UNSAFE_className + (0, $308b180f49d82d28$exports.mergeStyles)(styles, $914a06b3a1c679bc$var$providerStyles({
background: background,
colorScheme: colorScheme
})),
children: [
/*#__PURE__*/ (0, $jc3A8$reactjsxruntime.jsx)((0, $55e0379377484943$exports.Fonts), {}),
children
]
});
}
//# sourceMappingURL=Provider.cjs.map