@react-spectrum/provider
Advanced tools
Comparing version 3.0.0-rc.2 to 3.0.0-rc.3
338
dist/main.js
@@ -1,38 +0,40 @@ | ||
require("./main.css"); | ||
var { | ||
shouldKeepSpectrumClassNames, | ||
useDOMRef, | ||
useStyleProps, | ||
useMediaQuery | ||
} = require("@react-spectrum/utils"); | ||
var _babelRuntimeHelpersDefineProperty = $parcel$interopDefault(require("@babel/runtime/helpers/defineProperty")); | ||
var _react2 = require("react"); | ||
var _babelRuntimeHelpersExtends = $parcel$interopDefault(require("@babel/runtime/helpers/extends")); | ||
var _react = $parcel$interopDefault(_react2); | ||
var _babelRuntimeHelpersSlicedToArray = $parcel$interopDefault(require("@babel/runtime/helpers/slicedToArray")); | ||
var { | ||
useContext, | ||
useEffect, | ||
useRef | ||
} = _react2; | ||
var _babelRuntimeHelpersObjectWithoutProperties = $parcel$interopDefault(require("@babel/runtime/helpers/objectWithoutProperties")); | ||
var { | ||
ModalProvider, | ||
useModalProvider | ||
} = require("@react-aria/overlays"); | ||
var _classnames = $parcel$interopDefault(require("classnames")); | ||
var { | ||
I18nProvider, | ||
useLocale | ||
} = require("@react-aria/i18n"); | ||
var _temp = require("@react-spectrum/utils"); | ||
var { | ||
filterDOMProps | ||
} = require("@react-aria/utils"); | ||
var filterDOMProps = _temp.filterDOMProps; | ||
var shouldKeepSpectrumClassNames = _temp.shouldKeepSpectrumClassNames; | ||
var useDOMRef = _temp.useDOMRef; | ||
var useStyleProps = _temp.useStyleProps; | ||
var useMediaQuery = _temp.useMediaQuery; | ||
var _classnames = $parcel$interopDefault(require("classnames")); | ||
var _temp2 = require("@react-aria/i18n"); | ||
var _babelRuntimeHelpersObjectWithoutPropertiesLoose = $parcel$interopDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose")); | ||
var _Provider = _temp2.Provider; | ||
var useLocale = _temp2.useLocale; | ||
var _babelRuntimeHelpersExtends = $parcel$interopDefault(require("@babel/runtime/helpers/extends")); | ||
var _temp3 = require("@react-aria/overlays"); | ||
require("./main.css"); | ||
var ModalProvider = _temp3.ModalProvider; | ||
var useModalProvider = _temp3.useModalProvider; | ||
var _react2 = require("react"); | ||
var _react = $parcel$interopDefault(_react2); | ||
var useContext = _react2.useContext; | ||
var useEffect = _react2.useEffect; | ||
function $parcel$interopDefault(a) { | ||
@@ -42,74 +44,18 @@ return a && a.__esModule ? a.default : a; | ||
/* | ||
* Copyright 2020 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. | ||
*/ | ||
var $e7c39633e1d2f66ca15289152a0097a3$var$loadingTypekitIds = new Set(); | ||
function $e7c39633e1d2f66ca15289152a0097a3$export$default(typeKitId) { | ||
if (!typeKitId || $e7c39633e1d2f66ca15289152a0097a3$var$loadingTypekitIds.has(typeKitId)) { | ||
return; | ||
} | ||
$e7c39633e1d2f66ca15289152a0097a3$var$loadingTypekitIds.add(typeKitId); | ||
var config = { | ||
kitId: typeKitId, | ||
scriptTimeout: 3000 | ||
}; | ||
var h = document.getElementsByTagName('html')[0]; | ||
h.className += ' wf-loading'; | ||
var t = setTimeout(function () { | ||
h.className = h.className.replace(/(\s|^)wf-loading(\s|$)/g, ' '); | ||
h.className += ' wf-inactive'; | ||
}, config.scriptTimeout); | ||
var tk = document.createElement('script'); | ||
var d = false; | ||
tk.src = "https://use.typekit.net/".concat(config.kitId, ".js"); | ||
tk.type = 'text/javascript'; | ||
tk.async = 'true'; | ||
tk.onload = tk.onreadystatechange = function onload() { | ||
var a = this.readyState; | ||
if (d || a && a !== 'complete' && a !== 'loaded') { | ||
return; | ||
} | ||
d = true; | ||
clearTimeout(t); | ||
try { | ||
window.Typekit.load(config); | ||
} catch (b) { | ||
/* empty */ | ||
} | ||
}; | ||
var s = document.getElementsByTagName('script')[0]; | ||
s.parentNode.insertBefore(tk, s); | ||
} | ||
// ASSET: /Users/govett/dev/react-spectrum/node_modules/@adobe/spectrum-css-temp/components/page/vars.css | ||
var $d5f9f4756139967221378fd4aff16c6f$exports = {}; | ||
$d5f9f4756139967221378fd4aff16c6f$exports = { | ||
"spectrum": "_spectrum_a958b" | ||
// ASSET: /Users/govett/dev/react-spectrum-v3/node_modules/@adobe/spectrum-css-temp/components/page/vars.css | ||
var $bdf53da28d3991a48a6a4f1a69cf6748$exports = {}; | ||
$bdf53da28d3991a48a6a4f1a69cf6748$exports = { | ||
"spectrum": "_spectrum_d43d2" | ||
}; | ||
// ASSET: /Users/govett/dev/react-spectrum/node_modules/@adobe/spectrum-css-temp/components/typography/index.css | ||
var $e638952e1f26803e52602862731a048$exports = {}; | ||
$e638952e1f26803e52602862731a048$exports = { | ||
"spectrum": "_spectrum_5b535", | ||
"spectrum-Body": "_spectrum-Body_5b535", | ||
"spectrum-Body--italic": "_spectrum-Body--italic_5b535" | ||
// ASSET: /Users/govett/dev/react-spectrum-v3/node_modules/@adobe/spectrum-css-temp/components/typography/index.css | ||
var $a4b6d91f224137a9e1821db979545594$exports = {}; | ||
$a4b6d91f224137a9e1821db979545594$exports = { | ||
"spectrum": "_spectrum_60105", | ||
"spectrum-Body": "_spectrum-Body_60105", | ||
"spectrum-Body--italic": "_spectrum-Body--italic_60105" | ||
}; | ||
function $be94f3d41cacd2d62c91f022056e44$export$useColorScheme(theme, defaultColorScheme) { | ||
var matchesDark = useMediaQuery('(prefers-color-scheme: dark)'); | ||
var matchesLight = useMediaQuery('(prefers-color-scheme: light)'); // importance OS > default > omitted | ||
function $ae471163e3fb08c2a281b1d3e1120f94$export$useColorScheme(theme, defaultColorScheme) { | ||
let matchesDark = useMediaQuery('(prefers-color-scheme: dark)'); | ||
let matchesLight = useMediaQuery('(prefers-color-scheme: light)'); // importance OS > default > omitted | ||
@@ -143,4 +89,4 @@ if (theme.dark && matchesDark) { | ||
function $be94f3d41cacd2d62c91f022056e44$export$useScale(theme) { | ||
var matchesFine = useMediaQuery('(any-pointer: fine)'); | ||
function $ae471163e3fb08c2a281b1d3e1120f94$export$useScale(theme) { | ||
let matchesFine = useMediaQuery('(any-pointer: fine)'); | ||
@@ -158,75 +104,67 @@ if (matchesFine && theme.medium) { | ||
// ASSET: /Users/govett/dev/react-spectrum/packages/@react-spectrum/provider/package.json | ||
var $c7e412c4049f69be774b838570a0f$exports = {}; | ||
$c7e412c4049f69be774b838570a0f$exports = JSON.parse("{\"name\":\"@react-spectrum/provider\",\"version\":\"3.0.0-rc.1\",\"description\":\"Spectrum UI components in React\",\"license\":\"Apache-2.0\",\"main\":\"dist/main.js\",\"module\":\"dist/module.js\",\"types\":\"dist/types.d.ts\",\"source\":\"src/index.ts\",\"files\":[\"dist\"],\"sideEffects\":false,\"targets\":{\"main\":{\"includeNodeModules\":[\"@adobe/spectrum-css-temp\"]},\"module\":{\"includeNodeModules\":[\"@adobe/spectrum-css-temp\"]}},\"repository\":{\"type\":\"git\",\"url\":\"https://github.com/adobe-private/react-spectrum-v3\"},\"dependencies\":{\"@babel/runtime\":\"^7.6.2\",\"@react-aria/i18n\":\"^3.0.0-rc.1\",\"@react-aria/overlays\":\"^3.0.0-alpha.1\",\"@react-spectrum/utils\":\"^3.0.0-rc.1\",\"@react-types/provider\":\"^3.0.0-rc.1\",\"@react-types/shared\":\"^3.0.0-rc.1\",\"classnames\":\"^2.2.5\"},\"devDependencies\":{\"@adobe/spectrum-css-temp\":\"^3.0.0-alpha.1\"},\"peerDependencies\":{\"react\":\"^16.8.0\"},\"publishConfig\":{\"access\":\"public\"}}"); | ||
// ASSET: /Users/govett/dev/react-spectrum-v3/packages/@react-spectrum/provider/package.json | ||
var $cb3a8279d5bbe24ad5b01eee2a870ec3$exports = {}; | ||
$cb3a8279d5bbe24ad5b01eee2a870ec3$exports = JSON.parse("{\"name\":\"@react-spectrum/provider\",\"version\":\"3.0.0-rc.2\",\"description\":\"Spectrum UI components in React\",\"license\":\"Apache-2.0\",\"main\":\"dist/main.js\",\"module\":\"dist/module.js\",\"types\":\"dist/types.d.ts\",\"source\":\"src/index.ts\",\"files\":[\"dist\"],\"sideEffects\":false,\"targets\":{\"main\":{\"includeNodeModules\":[\"@adobe/spectrum-css-temp\"]},\"module\":{\"includeNodeModules\":[\"@adobe/spectrum-css-temp\"]}},\"repository\":{\"type\":\"git\",\"url\":\"https://github.com/adobe-private/react-spectrum-v3\"},\"dependencies\":{\"@babel/runtime\":\"^7.6.2\",\"@react-aria/i18n\":\"^3.0.0-rc.2\",\"@react-aria/overlays\":\"^3.0.0-alpha.1\",\"@react-aria/utils\":\"^3.0.0-rc.2\",\"@react-spectrum/utils\":\"^3.0.0-rc.2\",\"@react-types/provider\":\"^3.0.0-rc.2\",\"@react-types/shared\":\"^3.0.0-rc.2\",\"classnames\":\"^2.2.5\"},\"devDependencies\":{\"@adobe/spectrum-css-temp\":\"^3.0.0-alpha.1\"},\"peerDependencies\":{\"react\":\"^16.8.0\"},\"publishConfig\":{\"access\":\"public\"}}"); | ||
var $d05983693c80be83897ca3db02d07da7$var$Context = _react.createContext(null); | ||
const $f150a45acb1414cf0ebc786fd600e35$var$Context = _react.createContext(null); | ||
function $d05983693c80be83897ca3db02d07da7$var$Provider(props, ref) { | ||
var prevContext = useProvider(); | ||
var prevColorScheme = prevContext && prevContext.colorScheme; | ||
var _props$theme = props.theme, | ||
theme = _props$theme === void 0 ? prevContext && prevContext.theme : _props$theme, | ||
defaultColorScheme = props.defaultColorScheme; // Hooks must always be called. | ||
function $f150a45acb1414cf0ebc786fd600e35$var$Provider(props, ref) { | ||
let prevContext = useProvider(); | ||
let prevColorScheme = prevContext && prevContext.colorScheme; | ||
let { | ||
theme = prevContext && prevContext.theme, | ||
defaultColorScheme | ||
} = props; // Hooks must always be called. | ||
var autoColorScheme = $be94f3d41cacd2d62c91f022056e44$export$useColorScheme(theme, defaultColorScheme); | ||
var autoScale = $be94f3d41cacd2d62c91f022056e44$export$useScale(theme); | ||
let autoColorScheme = $ae471163e3fb08c2a281b1d3e1120f94$export$useColorScheme(theme, defaultColorScheme); | ||
let autoScale = $ae471163e3fb08c2a281b1d3e1120f94$export$useScale(theme); | ||
let { | ||
locale: prevLocale | ||
} = useLocale(); // if the new theme doesn't support the prevColorScheme, we must resort to the auto | ||
var _useLocale = useLocale(), | ||
prevLocale = _useLocale.locale; // if the new theme doesn't support the prevColorScheme, we must resort to the auto | ||
let usePrevColorScheme = !!theme[prevColorScheme]; // importance of color scheme props > parent > auto:(OS > default > omitted) | ||
let { | ||
colorScheme = usePrevColorScheme ? prevColorScheme : autoColorScheme, | ||
scale = prevContext ? prevContext.scale : autoScale, | ||
locale = prevContext ? prevLocale : null, | ||
children, | ||
isQuiet, | ||
isEmphasized, | ||
isDisabled, | ||
isRequired, | ||
isReadOnly, | ||
validationState | ||
} = props, | ||
otherProps = _babelRuntimeHelpersObjectWithoutPropertiesLoose(props, ["colorScheme", "scale", "locale", "children", "isQuiet", "isEmphasized", "isDisabled", "isRequired", "isReadOnly", "validationState"]); // select only the props with values so undefined props don't overwrite prevContext values | ||
var usePrevColorScheme = !!theme[prevColorScheme]; // importance of color scheme props > parent > auto:(OS > default > omitted) | ||
var _props$colorScheme = props.colorScheme, | ||
colorScheme = _props$colorScheme === void 0 ? usePrevColorScheme ? prevColorScheme : autoColorScheme : _props$colorScheme, | ||
_props$scale = props.scale, | ||
scale = _props$scale === void 0 ? prevContext ? prevContext.scale : autoScale : _props$scale, | ||
typekitId = props.typekitId, | ||
_props$locale = props.locale, | ||
locale = _props$locale === void 0 ? prevContext ? prevLocale : null : _props$locale, | ||
children = props.children, | ||
isQuiet = props.isQuiet, | ||
isEmphasized = props.isEmphasized, | ||
isDisabled = props.isDisabled, | ||
isRequired = props.isRequired, | ||
isReadOnly = props.isReadOnly, | ||
validationState = props.validationState, | ||
otherProps = _babelRuntimeHelpersObjectWithoutProperties(props, ["colorScheme", "scale", "typekitId", "locale", "children", "isQuiet", "isEmphasized", "isDisabled", "isRequired", "isReadOnly", "validationState"]); // select only the props with values so undefined props don't overwrite prevContext values | ||
var currentProps = { | ||
version: $c7e412c4049f69be774b838570a0f$exports.version, | ||
theme: theme, | ||
colorScheme: colorScheme, | ||
scale: scale, | ||
isQuiet: isQuiet, | ||
isEmphasized: isEmphasized, | ||
isDisabled: isDisabled, | ||
isRequired: isRequired, | ||
isReadOnly: isReadOnly, | ||
validationState: validationState | ||
let currentProps = { | ||
version: $cb3a8279d5bbe24ad5b01eee2a870ec3$exports.version, | ||
theme, | ||
colorScheme, | ||
scale, | ||
isQuiet, | ||
isEmphasized, | ||
isDisabled, | ||
isRequired, | ||
isReadOnly, | ||
validationState | ||
}; | ||
var filteredProps = {}; | ||
Object.entries(currentProps).forEach(function (_ref) { | ||
var _ref2 = _babelRuntimeHelpersSlicedToArray(_ref, 2), | ||
key = _ref2[0], | ||
value = _ref2[1]; | ||
let filteredProps = {}; | ||
Object.entries(currentProps).forEach((_ref) => { | ||
let [key, value] = _ref; | ||
return value !== undefined && (filteredProps[key] = value); | ||
}); // Merge options with parent provider | ||
var context = Object.assign({}, prevContext, filteredProps); | ||
useEffect(function () { | ||
$e7c39633e1d2f66ca15289152a0097a3$export$default(typekitId); | ||
}, [typekitId]); // Only wrap in a DOM node if the theme, colorScheme, or scale changed | ||
let context = Object.assign({}, prevContext, filteredProps); // Only wrap in a DOM node if the theme, colorScheme, or scale changed | ||
var contents = children; | ||
var domProps = filterDOMProps(otherProps); | ||
let contents = children; | ||
let domProps = filterDOMProps(otherProps); | ||
let { | ||
styleProps | ||
} = useStyleProps(otherProps); | ||
var _useStyleProps = useStyleProps(otherProps), | ||
styleProps = _useStyleProps.styleProps; | ||
if (!prevContext || props.locale || theme !== prevContext.theme || colorScheme !== prevContext.colorScheme || scale !== prevContext.scale || Object.keys(domProps).length > 0 || otherProps.UNSAFE_className || Object.keys(styleProps.style).length > 0) { | ||
contents = /*#__PURE__*/_react.createElement($d05983693c80be83897ca3db02d07da7$var$ProviderWrapper, _babelRuntimeHelpersExtends({}, props, { | ||
contents = /*#__PURE__*/_react.createElement($f150a45acb1414cf0ebc786fd600e35$var$ProviderWrapper, _babelRuntimeHelpersExtends({}, props, { | ||
ref: ref | ||
@@ -236,5 +174,5 @@ }), contents); | ||
return (/*#__PURE__*/_react.createElement($d05983693c80be83897ca3db02d07da7$var$Context.Provider, { | ||
return (/*#__PURE__*/_react.createElement($f150a45acb1414cf0ebc786fd600e35$var$Context.Provider, { | ||
value: context | ||
}, /*#__PURE__*/_react.createElement(_Provider, { | ||
}, /*#__PURE__*/_react.createElement(I18nProvider, { | ||
locale: locale | ||
@@ -252,40 +190,63 @@ }, /*#__PURE__*/_react.createElement(ModalProvider, null, contents))) | ||
var Provider = _react.forwardRef($d05983693c80be83897ca3db02d07da7$var$Provider); | ||
let Provider = _react.forwardRef($f150a45acb1414cf0ebc786fd600e35$var$Provider); | ||
exports.Provider = Provider; | ||
var $d5f9f4756139967221378fd4aff16c6f$$interop$default = $parcel$interopDefault($d5f9f4756139967221378fd4aff16c6f$exports); | ||
var $e638952e1f26803e52602862731a048$$interop$default = $parcel$interopDefault($e638952e1f26803e52602862731a048$exports); | ||
var $bdf53da28d3991a48a6a4f1a69cf6748$$interop$default = $parcel$interopDefault($bdf53da28d3991a48a6a4f1a69cf6748$exports); | ||
var $a4b6d91f224137a9e1821db979545594$$interop$default = $parcel$interopDefault($a4b6d91f224137a9e1821db979545594$exports); | ||
var $d05983693c80be83897ca3db02d07da7$var$ProviderWrapper = _react.forwardRef(function ProviderWrapper(props, ref) { | ||
var _classNames; | ||
const $f150a45acb1414cf0ebc786fd600e35$var$ProviderWrapper = _react.forwardRef(function ProviderWrapper(props, ref) { | ||
var _props$colorScheme; | ||
var children = props.children, | ||
otherProps = _babelRuntimeHelpersObjectWithoutProperties(props, ["children"]); | ||
let { | ||
children | ||
} = props, | ||
otherProps = _babelRuntimeHelpersObjectWithoutPropertiesLoose(props, ["children"]); | ||
var _useLocale2 = useLocale(), | ||
locale = _useLocale2.locale, | ||
direction = _useLocale2.direction; | ||
let { | ||
locale, | ||
direction | ||
} = useLocale(); | ||
let { | ||
theme, | ||
colorScheme, | ||
scale | ||
} = useProvider(); | ||
let { | ||
modalProviderProps | ||
} = useModalProvider(); | ||
let { | ||
styleProps | ||
} = useStyleProps(otherProps); | ||
let domRef = useDOMRef(ref); | ||
let themeKey = Object.keys(theme[colorScheme])[0]; | ||
let scaleKey = Object.keys(theme[scale])[0]; | ||
var _useProvider = useProvider(), | ||
theme = _useProvider.theme, | ||
colorScheme = _useProvider.colorScheme, | ||
scale = _useProvider.scale; | ||
let className = _classnames(styleProps.className, $bdf53da28d3991a48a6a4f1a69cf6748$$interop$default['spectrum'], $a4b6d91f224137a9e1821db979545594$$interop$default['spectrum'], theme[colorScheme][themeKey], theme[scale][scaleKey], theme.global ? Object.values(theme.global) : null, { | ||
'react-spectrum-provider': shouldKeepSpectrumClassNames, | ||
spectrum: shouldKeepSpectrumClassNames, | ||
[themeKey]: shouldKeepSpectrumClassNames, | ||
[scaleKey]: shouldKeepSpectrumClassNames | ||
}); | ||
var _useModalProvider = useModalProvider(), | ||
modalProviderProps = _useModalProvider.modalProviderProps; | ||
let style = _babelRuntimeHelpersExtends({}, styleProps.style, { | ||
// This ensures that browser native UI like scrollbars are rendered in the right color scheme. | ||
// See https://web.dev/color-scheme/. | ||
colorScheme: (_props$colorScheme = props.colorScheme) != null ? _props$colorScheme : Object.keys(theme).filter(k => k === 'light' || k === 'dark').join(' ') | ||
}); | ||
var _useStyleProps2 = useStyleProps(otherProps), | ||
styleProps = _useStyleProps2.styleProps; | ||
let hasWarned = useRef(false); | ||
useEffect(() => { | ||
if (locale && domRef.current) { | ||
let closestLang = domRef.current.parentElement.closest('[lang]'); | ||
let lang = closestLang && closestLang.getAttribute('lang'); | ||
var domRef = useDOMRef(ref); | ||
var themeKey = Object.keys(theme[colorScheme])[0]; | ||
var scaleKey = Object.keys(theme[scale])[0]; | ||
var className = _classnames(styleProps.className, $d5f9f4756139967221378fd4aff16c6f$$interop$default['spectrum'], $e638952e1f26803e52602862731a048$$interop$default['spectrum'], theme[colorScheme][themeKey], theme[scale][scaleKey], theme.global ? Object.values(theme.global) : null, (_classNames = { | ||
'react-spectrum-provider': shouldKeepSpectrumClassNames, | ||
spectrum: shouldKeepSpectrumClassNames | ||
}, _babelRuntimeHelpersDefineProperty(_classNames, themeKey, shouldKeepSpectrumClassNames), _babelRuntimeHelpersDefineProperty(_classNames, scaleKey, shouldKeepSpectrumClassNames), _classNames)); | ||
if (lang && lang !== locale && !hasWarned.current) { | ||
console.warn("Locales cannot be nested. " + locale + " inside " + lang + "."); | ||
hasWarned.current = true; | ||
} | ||
} | ||
}, [locale, domRef, hasWarned]); | ||
return (/*#__PURE__*/_react.createElement("div", _babelRuntimeHelpersExtends({}, filterDOMProps(otherProps), styleProps, modalProviderProps, { | ||
className: className, | ||
style: style, | ||
lang: locale, | ||
@@ -299,3 +260,3 @@ dir: direction, | ||
function useProvider() { | ||
return useContext($d05983693c80be83897ca3db02d07da7$var$Context); | ||
return useContext($f150a45acb1414cf0ebc786fd600e35$var$Context); | ||
} | ||
@@ -306,3 +267,3 @@ | ||
function useProviderProps(props) { | ||
var context = useProvider(); | ||
let context = useProvider(); | ||
@@ -323,2 +284,3 @@ if (!context) { | ||
exports.useProviderProps = useProviderProps; | ||
exports.useProviderProps = useProviderProps; | ||
//# sourceMappingURL=main.js.map |
@@ -0,9 +1,10 @@ | ||
import { shouldKeepSpectrumClassNames, useDOMRef, useStyleProps, useMediaQuery } from "@react-spectrum/utils"; | ||
import _react, { useContext, useEffect, useRef } from "react"; | ||
import { ModalProvider, useModalProvider } from "@react-aria/overlays"; | ||
import { I18nProvider, useLocale } from "@react-aria/i18n"; | ||
import { filterDOMProps } from "@react-aria/utils"; | ||
import _classnames from "classnames"; | ||
import _babelRuntimeHelpersEsmObjectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose"; | ||
import _babelRuntimeHelpersEsmExtends from "@babel/runtime/helpers/esm/extends"; | ||
import "./main.css"; | ||
import _babelRuntimeHelpersEsmExtends from "@babel/runtime/helpers/esm/extends"; | ||
import _babelRuntimeHelpersEsmObjectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties"; | ||
import _classnames from "classnames"; | ||
import { filterDOMProps, shouldKeepSpectrumClassNames, useDOMRef, useStyleProps, useMediaQuery } from "@react-spectrum/utils"; | ||
import { Provider as _Provider, useLocale } from "@react-aria/i18n"; | ||
import { ModalProvider, useModalProvider } from "@react-aria/overlays"; | ||
import _react, { useContext, useEffect } from "react"; | ||
@@ -14,72 +15,16 @@ function $parcel$interopDefault(a) { | ||
/* | ||
* Copyright 2020 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 $f647e0178bdc42fc3d79fa5$var$loadingTypekitIds = new Set(); | ||
function $f647e0178bdc42fc3d79fa5$export$default(typeKitId) { | ||
if (!typeKitId || $f647e0178bdc42fc3d79fa5$var$loadingTypekitIds.has(typeKitId)) { | ||
return; | ||
} | ||
$f647e0178bdc42fc3d79fa5$var$loadingTypekitIds.add(typeKitId); | ||
const config = { | ||
kitId: typeKitId, | ||
scriptTimeout: 3000 | ||
}; | ||
const h = document.getElementsByTagName('html')[0]; | ||
h.className += ' wf-loading'; | ||
const t = setTimeout(() => { | ||
h.className = h.className.replace(/(\s|^)wf-loading(\s|$)/g, ' '); | ||
h.className += ' wf-inactive'; | ||
}, config.scriptTimeout); | ||
const tk = document.createElement('script'); | ||
let d = false; | ||
tk.src = "https://use.typekit.net/".concat(config.kitId, ".js"); | ||
tk.type = 'text/javascript'; | ||
tk.async = 'true'; | ||
tk.onload = tk.onreadystatechange = function onload() { | ||
const a = this.readyState; | ||
if (d || a && a !== 'complete' && a !== 'loaded') { | ||
return; | ||
} | ||
d = true; | ||
clearTimeout(t); | ||
try { | ||
window.Typekit.load(config); | ||
} catch (b) { | ||
/* empty */ | ||
} | ||
}; | ||
const s = document.getElementsByTagName('script')[0]; | ||
s.parentNode.insertBefore(tk, s); | ||
} | ||
// ASSET: /Users/govett/dev/react-spectrum/node_modules/@adobe/spectrum-css-temp/components/page/vars.css | ||
var $b5475d5dcfe4b4207518d367c05d169$exports = {}; | ||
$b5475d5dcfe4b4207518d367c05d169$exports = { | ||
"spectrum": "_spectrum_a958b" | ||
// ASSET: /Users/govett/dev/react-spectrum-v3/node_modules/@adobe/spectrum-css-temp/components/page/vars.css | ||
var $b25d8b701135d8d7a7615286f4137155$exports = {}; | ||
$b25d8b701135d8d7a7615286f4137155$exports = { | ||
"spectrum": "_spectrum_d43d2" | ||
}; | ||
// ASSET: /Users/govett/dev/react-spectrum/node_modules/@adobe/spectrum-css-temp/components/typography/index.css | ||
var $f8ee1619a9e3731fcce290f252aaea5$exports = {}; | ||
$f8ee1619a9e3731fcce290f252aaea5$exports = { | ||
"spectrum": "_spectrum_5b535", | ||
"spectrum-Body": "_spectrum-Body_5b535", | ||
"spectrum-Body--italic": "_spectrum-Body--italic_5b535" | ||
// ASSET: /Users/govett/dev/react-spectrum-v3/node_modules/@adobe/spectrum-css-temp/components/typography/index.css | ||
var $af89659787f3bb83d548267e89d8c4e$exports = {}; | ||
$af89659787f3bb83d548267e89d8c4e$exports = { | ||
"spectrum": "_spectrum_60105", | ||
"spectrum-Body": "_spectrum-Body_60105", | ||
"spectrum-Body--italic": "_spectrum-Body--italic_60105" | ||
}; | ||
function $b51ec1a3cedfd27d29c956b270e96b5f$export$useColorScheme(theme, defaultColorScheme) { | ||
function $c51f12b1e2e192b6909c7f3967b7e077$export$useColorScheme(theme, defaultColorScheme) { | ||
let matchesDark = useMediaQuery('(prefers-color-scheme: dark)'); | ||
@@ -115,3 +60,3 @@ let matchesLight = useMediaQuery('(prefers-color-scheme: light)'); // importance OS > default > omitted | ||
function $b51ec1a3cedfd27d29c956b270e96b5f$export$useScale(theme) { | ||
function $c51f12b1e2e192b6909c7f3967b7e077$export$useScale(theme) { | ||
let matchesFine = useMediaQuery('(any-pointer: fine)'); | ||
@@ -130,9 +75,9 @@ | ||
// ASSET: /Users/govett/dev/react-spectrum/packages/@react-spectrum/provider/package.json | ||
var $a306a8ce4e79e9eff01d3fa9fb0a$exports = {}; | ||
$a306a8ce4e79e9eff01d3fa9fb0a$exports = JSON.parse("{\"name\":\"@react-spectrum/provider\",\"version\":\"3.0.0-rc.1\",\"description\":\"Spectrum UI components in React\",\"license\":\"Apache-2.0\",\"main\":\"dist/main.js\",\"module\":\"dist/module.js\",\"types\":\"dist/types.d.ts\",\"source\":\"src/index.ts\",\"files\":[\"dist\"],\"sideEffects\":false,\"targets\":{\"main\":{\"includeNodeModules\":[\"@adobe/spectrum-css-temp\"]},\"module\":{\"includeNodeModules\":[\"@adobe/spectrum-css-temp\"]}},\"repository\":{\"type\":\"git\",\"url\":\"https://github.com/adobe-private/react-spectrum-v3\"},\"dependencies\":{\"@babel/runtime\":\"^7.6.2\",\"@react-aria/i18n\":\"^3.0.0-rc.1\",\"@react-aria/overlays\":\"^3.0.0-alpha.1\",\"@react-spectrum/utils\":\"^3.0.0-rc.1\",\"@react-types/provider\":\"^3.0.0-rc.1\",\"@react-types/shared\":\"^3.0.0-rc.1\",\"classnames\":\"^2.2.5\"},\"devDependencies\":{\"@adobe/spectrum-css-temp\":\"^3.0.0-alpha.1\"},\"peerDependencies\":{\"react\":\"^16.8.0\"},\"publishConfig\":{\"access\":\"public\"}}"); | ||
// ASSET: /Users/govett/dev/react-spectrum-v3/packages/@react-spectrum/provider/package.json | ||
var $e44261d82f8bb46fa32302e6282353ef$exports = {}; | ||
$e44261d82f8bb46fa32302e6282353ef$exports = JSON.parse("{\"name\":\"@react-spectrum/provider\",\"version\":\"3.0.0-rc.2\",\"description\":\"Spectrum UI components in React\",\"license\":\"Apache-2.0\",\"main\":\"dist/main.js\",\"module\":\"dist/module.js\",\"types\":\"dist/types.d.ts\",\"source\":\"src/index.ts\",\"files\":[\"dist\"],\"sideEffects\":false,\"targets\":{\"main\":{\"includeNodeModules\":[\"@adobe/spectrum-css-temp\"]},\"module\":{\"includeNodeModules\":[\"@adobe/spectrum-css-temp\"]}},\"repository\":{\"type\":\"git\",\"url\":\"https://github.com/adobe-private/react-spectrum-v3\"},\"dependencies\":{\"@babel/runtime\":\"^7.6.2\",\"@react-aria/i18n\":\"^3.0.0-rc.2\",\"@react-aria/overlays\":\"^3.0.0-alpha.1\",\"@react-aria/utils\":\"^3.0.0-rc.2\",\"@react-spectrum/utils\":\"^3.0.0-rc.2\",\"@react-types/provider\":\"^3.0.0-rc.2\",\"@react-types/shared\":\"^3.0.0-rc.2\",\"classnames\":\"^2.2.5\"},\"devDependencies\":{\"@adobe/spectrum-css-temp\":\"^3.0.0-alpha.1\"},\"peerDependencies\":{\"react\":\"^16.8.0\"},\"publishConfig\":{\"access\":\"public\"}}"); | ||
const $dd1bda183fdd07b54e8ea0f07d2319$var$Context = _react.createContext(null); | ||
const $bc3300334f45fd1ec62a173e70ad86$var$Context = _react.createContext(null); | ||
function $dd1bda183fdd07b54e8ea0f07d2319$var$Provider(props, ref) { | ||
function $bc3300334f45fd1ec62a173e70ad86$var$Provider(props, ref) { | ||
let prevContext = useProvider(); | ||
@@ -145,4 +90,4 @@ let prevColorScheme = prevContext && prevContext.colorScheme; | ||
let autoColorScheme = $b51ec1a3cedfd27d29c956b270e96b5f$export$useColorScheme(theme, defaultColorScheme); | ||
let autoScale = $b51ec1a3cedfd27d29c956b270e96b5f$export$useScale(theme); | ||
let autoColorScheme = $c51f12b1e2e192b6909c7f3967b7e077$export$useColorScheme(theme, defaultColorScheme); | ||
let autoScale = $c51f12b1e2e192b6909c7f3967b7e077$export$useScale(theme); | ||
let { | ||
@@ -157,3 +102,2 @@ locale: prevLocale | ||
scale = prevContext ? prevContext.scale : autoScale, | ||
typekitId, | ||
locale = prevContext ? prevLocale : null, | ||
@@ -168,7 +112,7 @@ children, | ||
} = props, | ||
otherProps = _babelRuntimeHelpersEsmObjectWithoutProperties(props, ["colorScheme", "scale", "typekitId", "locale", "children", "isQuiet", "isEmphasized", "isDisabled", "isRequired", "isReadOnly", "validationState"]); // select only the props with values so undefined props don't overwrite prevContext values | ||
otherProps = _babelRuntimeHelpersEsmObjectWithoutPropertiesLoose(props, ["colorScheme", "scale", "locale", "children", "isQuiet", "isEmphasized", "isDisabled", "isRequired", "isReadOnly", "validationState"]); // select only the props with values so undefined props don't overwrite prevContext values | ||
let currentProps = { | ||
version: $a306a8ce4e79e9eff01d3fa9fb0a$exports.version, | ||
version: $e44261d82f8bb46fa32302e6282353ef$exports.version, | ||
theme, | ||
@@ -185,8 +129,8 @@ colorScheme, | ||
let filteredProps = {}; | ||
Object.entries(currentProps).forEach(([key, value]) => value !== undefined && (filteredProps[key] = value)); // Merge options with parent provider | ||
Object.entries(currentProps).forEach((_ref) => { | ||
let [key, value] = _ref; | ||
return value !== undefined && (filteredProps[key] = value); | ||
}); // Merge options with parent provider | ||
let context = Object.assign({}, prevContext, filteredProps); | ||
useEffect(() => { | ||
$f647e0178bdc42fc3d79fa5$export$default(typekitId); | ||
}, [typekitId]); // Only wrap in a DOM node if the theme, colorScheme, or scale changed | ||
let context = Object.assign({}, prevContext, filteredProps); // Only wrap in a DOM node if the theme, colorScheme, or scale changed | ||
@@ -200,3 +144,3 @@ let contents = children; | ||
if (!prevContext || props.locale || theme !== prevContext.theme || colorScheme !== prevContext.colorScheme || scale !== prevContext.scale || Object.keys(domProps).length > 0 || otherProps.UNSAFE_className || Object.keys(styleProps.style).length > 0) { | ||
contents = /*#__PURE__*/_react.createElement($dd1bda183fdd07b54e8ea0f07d2319$var$ProviderWrapper, _babelRuntimeHelpersEsmExtends({}, props, { | ||
contents = /*#__PURE__*/_react.createElement($bc3300334f45fd1ec62a173e70ad86$var$ProviderWrapper, _babelRuntimeHelpersEsmExtends({}, props, { | ||
ref: ref | ||
@@ -206,5 +150,5 @@ }), contents); | ||
return (/*#__PURE__*/_react.createElement($dd1bda183fdd07b54e8ea0f07d2319$var$Context.Provider, { | ||
return (/*#__PURE__*/_react.createElement($bc3300334f45fd1ec62a173e70ad86$var$Context.Provider, { | ||
value: context | ||
}, /*#__PURE__*/_react.createElement(_Provider, { | ||
}, /*#__PURE__*/_react.createElement(I18nProvider, { | ||
locale: locale | ||
@@ -222,11 +166,13 @@ }, /*#__PURE__*/_react.createElement(ModalProvider, null, contents))) | ||
export let Provider = _react.forwardRef($dd1bda183fdd07b54e8ea0f07d2319$var$Provider); | ||
var $b5475d5dcfe4b4207518d367c05d169$$interop$default = $parcel$interopDefault($b5475d5dcfe4b4207518d367c05d169$exports); | ||
var $f8ee1619a9e3731fcce290f252aaea5$$interop$default = $parcel$interopDefault($f8ee1619a9e3731fcce290f252aaea5$exports); | ||
export let Provider = _react.forwardRef($bc3300334f45fd1ec62a173e70ad86$var$Provider); | ||
var $b25d8b701135d8d7a7615286f4137155$$interop$default = $parcel$interopDefault($b25d8b701135d8d7a7615286f4137155$exports); | ||
var $af89659787f3bb83d548267e89d8c4e$$interop$default = $parcel$interopDefault($af89659787f3bb83d548267e89d8c4e$exports); | ||
const $dd1bda183fdd07b54e8ea0f07d2319$var$ProviderWrapper = _react.forwardRef(function ProviderWrapper(props, ref) { | ||
const $bc3300334f45fd1ec62a173e70ad86$var$ProviderWrapper = _react.forwardRef(function ProviderWrapper(props, ref) { | ||
var _props$colorScheme; | ||
let { | ||
children | ||
} = props, | ||
otherProps = _babelRuntimeHelpersEsmObjectWithoutProperties(props, ["children"]); | ||
otherProps = _babelRuntimeHelpersEsmObjectWithoutPropertiesLoose(props, ["children"]); | ||
@@ -252,3 +198,3 @@ let { | ||
let className = _classnames(styleProps.className, $b5475d5dcfe4b4207518d367c05d169$$interop$default['spectrum'], $f8ee1619a9e3731fcce290f252aaea5$$interop$default['spectrum'], theme[colorScheme][themeKey], theme[scale][scaleKey], theme.global ? Object.values(theme.global) : null, { | ||
let className = _classnames(styleProps.className, $b25d8b701135d8d7a7615286f4137155$$interop$default['spectrum'], $af89659787f3bb83d548267e89d8c4e$$interop$default['spectrum'], theme[colorScheme][themeKey], theme[scale][scaleKey], theme.global ? Object.values(theme.global) : null, { | ||
'react-spectrum-provider': shouldKeepSpectrumClassNames, | ||
@@ -260,4 +206,23 @@ spectrum: shouldKeepSpectrumClassNames, | ||
let style = _babelRuntimeHelpersEsmExtends({}, styleProps.style, { | ||
// This ensures that browser native UI like scrollbars are rendered in the right color scheme. | ||
// See https://web.dev/color-scheme/. | ||
colorScheme: (_props$colorScheme = props.colorScheme) != null ? _props$colorScheme : Object.keys(theme).filter(k => k === 'light' || k === 'dark').join(' ') | ||
}); | ||
let hasWarned = useRef(false); | ||
useEffect(() => { | ||
if (locale && domRef.current) { | ||
let closestLang = domRef.current.parentElement.closest('[lang]'); | ||
let lang = closestLang && closestLang.getAttribute('lang'); | ||
if (lang && lang !== locale && !hasWarned.current) { | ||
console.warn("Locales cannot be nested. " + locale + " inside " + lang + "."); | ||
hasWarned.current = true; | ||
} | ||
} | ||
}, [locale, domRef, hasWarned]); | ||
return (/*#__PURE__*/_react.createElement("div", _babelRuntimeHelpersEsmExtends({}, filterDOMProps(otherProps), styleProps, modalProviderProps, { | ||
className: className, | ||
style: style, | ||
lang: locale, | ||
@@ -271,3 +236,3 @@ dir: direction, | ||
export function useProvider() { | ||
return useContext($dd1bda183fdd07b54e8ea0f07d2319$var$Context); | ||
return useContext($bc3300334f45fd1ec62a173e70ad86$var$Context); | ||
} | ||
@@ -289,2 +254,3 @@ export function useProviderProps(props) { | ||
}, props); | ||
} | ||
} | ||
//# sourceMappingURL=module.js.map |
{ | ||
"name": "@react-spectrum/provider", | ||
"version": "3.0.0-rc.2", | ||
"version": "3.0.0-rc.3", | ||
"description": "Spectrum UI components in React", | ||
@@ -32,7 +32,8 @@ "license": "Apache-2.0", | ||
"@babel/runtime": "^7.6.2", | ||
"@react-aria/i18n": "^3.0.0-rc.2", | ||
"@react-aria/overlays": "^3.0.0-alpha.1", | ||
"@react-spectrum/utils": "^3.0.0-rc.2", | ||
"@react-types/provider": "^3.0.0-rc.2", | ||
"@react-types/shared": "^3.0.0-rc.2", | ||
"@react-aria/i18n": "3.0.0-rc.3", | ||
"@react-aria/overlays": "3.0.0-rc.0", | ||
"@react-aria/utils": "3.0.0-rc.3", | ||
"@react-spectrum/utils": "3.0.0-rc.3", | ||
"@react-types/provider": "3.0.0-rc.3", | ||
"@react-types/shared": "3.0.0-rc.3", | ||
"classnames": "^2.2.5" | ||
@@ -49,3 +50,3 @@ }, | ||
}, | ||
"gitHead": "207e6ee9076905c96638a7f81a367758872e1410" | ||
"gitHead": "461d6321126ae9b4f1508aa912f7b36bf8a603f8" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
99046
11
9
1
80
492
+ Added@react-aria/utils@3.0.0-rc.3
+ Added@react-aria/i18n@3.0.0-rc.3(transitive)
+ Added@react-aria/interactions@3.0.0-rc.3(transitive)
+ Added@react-aria/overlays@3.0.0-rc.0(transitive)
+ Added@react-aria/utils@3.0.0-rc.3(transitive)
+ Added@react-aria/visually-hidden@3.0.0-rc.0(transitive)
+ Added@react-spectrum/utils@3.0.0-rc.3(transitive)
+ Added@react-stately/overlays@3.0.0-rc.0(transitive)
+ Added@react-stately/utils@3.0.0-rc.3(transitive)
+ Added@react-types/button@3.0.0-rc.3(transitive)
+ Added@react-types/overlays@3.0.0-rc.0(transitive)
+ Added@react-types/provider@3.0.0-rc.3(transitive)
+ Added@react-types/shared@3.0.0-rc.3(transitive)
+ Addeddom-helpers@3.4.0(transitive)
+ Addedintl-messageformat@2.2.0(transitive)
+ Addedintl-messageformat-parser@1.4.0(transitive)
+ Addedreact-dom@16.14.0(transitive)
+ Addedscheduler@0.19.1(transitive)
- Removed@formatjs/ecma402-abstract@2.2.4(transitive)
- Removed@formatjs/fast-memoize@2.2.3(transitive)
- Removed@formatjs/icu-messageformat-parser@2.9.4(transitive)
- Removed@formatjs/icu-skeleton-parser@1.8.8(transitive)
- Removed@formatjs/intl-localematcher@0.5.8(transitive)
- Removed@internationalized/date@3.6.0(transitive)
- Removed@internationalized/message@3.1.6(transitive)
- Removed@internationalized/number@3.6.0(transitive)
- Removed@internationalized/string@3.2.5(transitive)
- Removed@react-aria/focus@3.19.0(transitive)
- Removed@react-aria/i18n@3.12.4(transitive)
- Removed@react-aria/interactions@3.22.5(transitive)
- Removed@react-aria/overlays@3.24.0(transitive)
- Removed@react-aria/ssr@3.9.7(transitive)
- Removed@react-aria/utils@3.26.0(transitive)
- Removed@react-aria/visually-hidden@3.8.18(transitive)
- Removed@react-spectrum/utils@3.12.0(transitive)
- Removed@react-stately/overlays@3.6.12(transitive)
- Removed@react-stately/utils@3.10.5(transitive)
- Removed@react-types/button@3.10.1(transitive)
- Removed@react-types/overlays@3.8.11(transitive)
- Removed@react-types/provider@3.8.5(transitive)
- Removed@react-types/shared@3.26.0(transitive)
- Removed@swc/helpers@0.5.15(transitive)
- Removedclsx@2.1.1(transitive)
- Removedintl-messageformat@10.7.7(transitive)
- Removedreact@19.0.0-rc-fb9a90fa48-20240614(transitive)
- Removedreact-dom@19.0.0-rc-fb9a90fa48-20240614(transitive)
- Removedscheduler@0.25.0-rc-fb9a90fa48-20240614(transitive)
- Removedtslib@2.8.1(transitive)
Updated@react-aria/i18n@3.0.0-rc.3