@react-spectrum/provider 3.9.12 → 3.10.1
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/Provider.main.js +14 -16
- package/dist/Provider.main.js.map +1 -1
- package/dist/Provider.mjs +15 -17
- package/dist/Provider.module.js +15 -17
- package/dist/Provider.module.js.map +1 -1
- package/dist/package.main.js +1 -1
- package/dist/package.main.js.map +1 -1
- package/dist/package.mjs +1 -1
- package/dist/package.module.js +1 -1
- package/dist/package.module.js.map +1 -1
- package/dist/page_vars_css.main.js.map +1 -1
- package/dist/page_vars_css.module.js.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/typography_index_css.main.js.map +1 -1
- package/dist/typography_index_css.module.js.map +1 -1
- package/package.json +10 -10
- package/src/Provider.tsx +27 -23
package/dist/Provider.main.js
CHANGED
|
@@ -21,8 +21,8 @@ function $parcel$export(e, n, v, s) {
|
|
|
21
21
|
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
$parcel$export(module.exports, "useProvider", () => $96cabdf5b0aed55b$export$693cdb10cec23617);
|
|
25
24
|
$parcel$export(module.exports, "Provider", () => $96cabdf5b0aed55b$export$2881499e37b75b9a);
|
|
25
|
+
$parcel$export(module.exports, "useProvider", () => $96cabdf5b0aed55b$export$693cdb10cec23617);
|
|
26
26
|
$parcel$export(module.exports, "useProviderProps", () => $96cabdf5b0aed55b$export$521c373ccc32c300);
|
|
27
27
|
/*
|
|
28
28
|
* Copyright 2020 Adobe. All rights reserved.
|
|
@@ -52,20 +52,20 @@ const $96cabdf5b0aed55b$var$DEFAULT_BREAKPOINTS = {
|
|
|
52
52
|
XL: 1280,
|
|
53
53
|
XXL: 1536
|
|
54
54
|
};
|
|
55
|
-
|
|
56
|
-
let prevContext = $
|
|
55
|
+
const $96cabdf5b0aed55b$export$2881499e37b75b9a = /*#__PURE__*/ (0, ($parcel$interopDefault($dbjUM$react))).forwardRef(function Provider(props, ref) {
|
|
56
|
+
let prevContext = (0, $dbjUM$react.useContext)((0, $a5b4f4e252b5a021$exports.Context));
|
|
57
57
|
let prevColorScheme = prevContext && prevContext.colorScheme;
|
|
58
58
|
let prevBreakpoints = prevContext && prevContext.breakpoints;
|
|
59
59
|
let { theme: theme = prevContext && prevContext.theme, defaultColorScheme: defaultColorScheme } = props;
|
|
60
60
|
if (!theme) throw new Error('theme not found, the parent provider must have a theme provided');
|
|
61
61
|
// Hooks must always be called.
|
|
62
|
-
let autoColorScheme = (0, $a6e2b5f4621e4690$exports.useColorScheme)(theme, defaultColorScheme);
|
|
62
|
+
let autoColorScheme = (0, $a6e2b5f4621e4690$exports.useColorScheme)(theme, defaultColorScheme || 'light');
|
|
63
63
|
let autoScale = (0, $a6e2b5f4621e4690$exports.useScale)(theme);
|
|
64
64
|
let { locale: prevLocale } = (0, $dbjUM$reactariai18n.useLocale)();
|
|
65
65
|
// if the new theme doesn't support the prevColorScheme, we must resort to the auto
|
|
66
|
-
let usePrevColorScheme = !!theme[prevColorScheme];
|
|
66
|
+
let usePrevColorScheme = prevColorScheme ? !!theme[prevColorScheme] : false;
|
|
67
67
|
// importance of color scheme props > parent > auto:(OS > default > omitted)
|
|
68
|
-
let { colorScheme: colorScheme = usePrevColorScheme ? prevColorScheme : autoColorScheme, scale: scale = prevContext ? prevContext.scale : autoScale, locale: locale = prevContext ? prevLocale :
|
|
68
|
+
let { colorScheme: colorScheme = usePrevColorScheme ? prevColorScheme : autoColorScheme, scale: scale = prevContext ? prevContext.scale : autoScale, locale: locale = prevContext ? prevLocale : undefined, breakpoints: breakpoints = prevContext ? prevBreakpoints : $96cabdf5b0aed55b$var$DEFAULT_BREAKPOINTS, children: children, isQuiet: isQuiet, isEmphasized: isEmphasized, isDisabled: isDisabled, isRequired: isRequired, isReadOnly: isReadOnly, validationState: validationState, router: router, ...otherProps } = props;
|
|
69
69
|
// select only the props with values so undefined props don't overwrite prevContext values
|
|
70
70
|
let currentProps = {
|
|
71
71
|
version: $4db360e38265184f$exports.version,
|
|
@@ -91,7 +91,7 @@ function $96cabdf5b0aed55b$var$Provider(props, ref) {
|
|
|
91
91
|
let { styleProps: styleProps } = (0, $dbjUM$reactspectrumutils.useStyleProps)(otherProps, undefined, {
|
|
92
92
|
matchedBreakpoints: matchedBreakpoints
|
|
93
93
|
});
|
|
94
|
-
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__*/ (0, ($parcel$interopDefault($dbjUM$react))).createElement($96cabdf5b0aed55b$var$ProviderWrapper, {
|
|
94
|
+
if (!prevContext || props.locale || theme !== prevContext.theme || colorScheme !== prevContext.colorScheme || scale !== prevContext.scale || Object.keys(domProps).length > 0 || otherProps.UNSAFE_className || styleProps.style && Object.keys(styleProps.style).length > 0) contents = /*#__PURE__*/ (0, ($parcel$interopDefault($dbjUM$react))).createElement($96cabdf5b0aed55b$var$ProviderWrapper, {
|
|
95
95
|
...props,
|
|
96
96
|
UNSAFE_style: {
|
|
97
97
|
isolation: !prevContext ? 'isolate' : undefined,
|
|
@@ -107,12 +107,7 @@ function $96cabdf5b0aed55b$var$Provider(props, ref) {
|
|
|
107
107
|
}, /*#__PURE__*/ (0, ($parcel$interopDefault($dbjUM$react))).createElement((0, $dbjUM$reactspectrumutils.BreakpointProvider), {
|
|
108
108
|
matchedBreakpoints: matchedBreakpoints
|
|
109
109
|
}, /*#__PURE__*/ (0, ($parcel$interopDefault($dbjUM$react))).createElement((0, $dbjUM$reactariaoverlays.ModalProvider), null, contents))));
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* Provider is the container for all React Spectrum applications.
|
|
113
|
-
* It defines the theme, locale, and other application level settings,
|
|
114
|
-
* and can also be used to provide common properties to a group of components.
|
|
115
|
-
*/ let $96cabdf5b0aed55b$export$2881499e37b75b9a = /*#__PURE__*/ (0, ($parcel$interopDefault($dbjUM$react))).forwardRef($96cabdf5b0aed55b$var$Provider);
|
|
110
|
+
});
|
|
116
111
|
const $96cabdf5b0aed55b$var$ProviderWrapper = /*#__PURE__*/ (0, ($parcel$interopDefault($dbjUM$react))).forwardRef(function ProviderWrapper(props, ref) {
|
|
117
112
|
let { children: children, ...otherProps } = props;
|
|
118
113
|
let { locale: locale, direction: direction } = (0, $dbjUM$reactariai18n.useLocale)();
|
|
@@ -138,7 +133,8 @@ const $96cabdf5b0aed55b$var$ProviderWrapper = /*#__PURE__*/ (0, ($parcel$interop
|
|
|
138
133
|
let hasWarned = (0, $dbjUM$react.useRef)(false);
|
|
139
134
|
(0, $dbjUM$react.useEffect)(()=>{
|
|
140
135
|
if (direction && domRef.current) {
|
|
141
|
-
|
|
136
|
+
var _domRef_current_parentElement, _domRef_current;
|
|
137
|
+
let closestDir = (_domRef_current = domRef.current) === null || _domRef_current === void 0 ? void 0 : (_domRef_current_parentElement = _domRef_current.parentElement) === null || _domRef_current_parentElement === void 0 ? void 0 : _domRef_current_parentElement.closest('[dir]');
|
|
142
138
|
let dir = closestDir && closestDir.getAttribute('dir');
|
|
143
139
|
if (dir && dir !== direction && !hasWarned.current) {
|
|
144
140
|
console.warn(`Language directions cannot be nested. ${direction} inside ${dir}.`);
|
|
@@ -162,10 +158,12 @@ const $96cabdf5b0aed55b$var$ProviderWrapper = /*#__PURE__*/ (0, ($parcel$interop
|
|
|
162
158
|
}, children);
|
|
163
159
|
});
|
|
164
160
|
function $96cabdf5b0aed55b$export$693cdb10cec23617() {
|
|
165
|
-
|
|
161
|
+
let context = (0, $dbjUM$react.useContext)((0, $a5b4f4e252b5a021$exports.Context));
|
|
162
|
+
if (!context) throw new Error("No root provider found, please make sure your app is wrapped within a <Provider>. Alternatively, this issue may be caused by duplicate packages, see https://github.com/adobe/react-spectrum/wiki/Frequently-Asked-Questions-(FAQs)#why-are-there-errors-after-upgrading-a-react-spectrum-package for more information.");
|
|
163
|
+
return context;
|
|
166
164
|
}
|
|
167
165
|
function $96cabdf5b0aed55b$export$521c373ccc32c300(props) {
|
|
168
|
-
let context = $
|
|
166
|
+
let context = (0, $dbjUM$react.useContext)((0, $a5b4f4e252b5a021$exports.Context));
|
|
169
167
|
if (!context) return props;
|
|
170
168
|
return Object.assign({}, {
|
|
171
169
|
isQuiet: context.isQuiet,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;AAuBD,MAAM,4CAAsB;IAAC,GAAG;IAAK,GAAG;IAAK,GAAG;IAAM,IAAI;IAAM,KAAK;AAAI;AAEzE,SAAS,+BAAS,KAAoB,EAAE,GAA2B;IACjE,IAAI,cAAc;IAClB,IAAI,kBAAkB,eAAe,YAAY,WAAW;IAC5D,IAAI,kBAAkB,eAAe,YAAY,WAAW;IAC5D,IAAI,SACF,QAAQ,eAAe,YAAY,KAAK,sBACxC,kBAAkB,EACnB,GAAG;IACJ,IAAI,CAAC,OACH,MAAM,IAAI,MAAM;IAElB,+BAA+B;IAC/B,IAAI,kBAAkB,CAAA,GAAA,wCAAa,EAAE,OAAO;IAC5C,IAAI,YAAY,CAAA,GAAA,kCAAO,EAAE;IACzB,IAAI,EAAC,QAAQ,UAAU,EAAC,GAAG,CAAA,GAAA,8BAAQ;IACnC,mFAAmF;IACnF,IAAI,qBAAqB,CAAC,CAAC,KAAK,CAAC,gBAAgB;IAEjD,4EAA4E;IAC5E,IAAI,eACF,cAAc,qBAAqB,kBAAkB,wBACrD,QAAQ,cAAc,YAAY,KAAK,GAAG,mBAC1C,SAAS,cAAc,aAAa,mBACpC,cAAc,cAAc,kBAAkB,qDAC9C,QAAQ,WACR,OAAO,gBACP,YAAY,cACZ,UAAU,cACV,UAAU,cACV,UAAU,mBACV,eAAe,UACf,MAAM,EACN,GAAG,YACJ,GAAG;IAEJ,0FA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AM,CAAC,CAAA,IAAK,MAAM,WAAW,MAAM,QAAQ,IAAI,CAAC;IACtH;IAEA,IAAI,YAAY,CAAA,GAAA,mBAAK,EAAE;IACvB,CAAA,GAAA,sBAAQ,EAAE;QACR,IAAI,aAAa,OAAO,OAAO,EAAE;YAC/B,IAAI,aAAa,OAAO,OAAO,CAAC,aAAa,CAAC,OAAO,CAAC;YACtD,IAAI,MAAM,cAAc,WAAW,YAAY,CAAC;YAChD,IAAI,OAAO,QAAQ,aAAa,CAAC,UAAU,OAAO,EAAE;gBAClD,QAAQ,IAAI,CAAC,CAAC,sCAAsC,EAAE,UAAU,QAAQ,EAAE,IAAI,CAAC,CAAC;gBAChF,UAAU,OAAO,GAAG;YACtB;QACF;IACF,GAAG;QAAC;QAAW;QAAQ;KAAU;IAGjC,qBACE,0DAAC;QACE,GAAG,CAAA,GAAA,oCAAa,EAAE,WAAW;QAC7B,GAAG,UAAU;QACb,GAAG,kBAAkB;QACtB,WAAW;QACX,OAAO;QACP,MAAM;QACN,KAAK;QACL,KAAK;OACJ;AAGP;AAMO,SAAS;IACd,OAAO,CAAA,GAAA,uBAAS,EAAE,CAAA,GAAA,iCAAM;AAC1B;AAEO,SAAS,0CAAoB,KAAQ;IAC1C,IAAI,UAAU;IACd,IAAI,CAAC,SACH,OAAO;IAET,OAAO,OAAO,MAAM,CAAC,CAAC,GAAG;QACvB,SAAS,QAAQ,OAAO;QACxB,cAAc,QAAQ,YAAY;QAClC,YAAY,QAAQ,UAAU;QAC9B,YAAY,QAAQ,UAAU;QAC9B,YAAY,QAAQ,UAAU;QAC9B,iBAAiB,QAAQ,eAAe;IAC1C,GAAG;AACL","sources":["packages/@react-spectrum/provider/src/Provider.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 {\n BreakpointProvider,\n shouldKeepSpectrumClassNames,\n useDOMRef,\n useMatchedBreakpoints,\n useStyleProps\n} from '@react-spectrum/utils';\nimport clsx from 'clsx';\nimport {Context} from './context';\nimport {DOMRef} from '@react-types/shared';\nimport {filterDOMProps, RouterProvider} from '@react-aria/utils';\nimport {I18nProvider, useLocale} from '@react-aria/i18n';\nimport {ModalProvider, useModalProvider} from '@react-aria/overlays';\nimport {ProviderContext, ProviderProps} from '@react-types/provider';\nimport React, {useContext, useEffect, useRef} from 'react';\nimport styles from '@adobe/spectrum-css-temp/components/page/vars.css';\nimport typographyStyles from '@adobe/spectrum-css-temp/components/typography/index.css';\nimport {useColorScheme, useScale} from './mediaQueries';\n// @ts-ignore\nimport {version} from '../package.json';\n\nconst DEFAULT_BREAKPOINTS = {S: 640, M: 768, L: 1024, XL: 1280, XXL: 1536};\n\nfunction Provider(props: ProviderProps, ref: DOMRef<HTMLDivElement>) {\n let prevContext = useProvider();\n let prevColorScheme = prevContext && prevContext.colorScheme;\n let prevBreakpoints = prevContext && prevContext.breakpoints;\n let {\n theme = prevContext && prevContext.theme,\n defaultColorScheme\n } = props;\n if (!theme) {\n throw new Error('theme not found, the parent provider must have a theme provided');\n }\n // Hooks must always be called.\n let autoColorScheme = useColorScheme(theme, defaultColorScheme);\n let autoScale = useScale(theme);\n let {locale: prevLocale} = useLocale();\n // if the new theme doesn't support the prevColorScheme, we must resort to the auto\n let usePrevColorScheme = !!theme[prevColorScheme];\n\n // importance of color scheme props > parent > auto:(OS > default > omitted)\n let {\n colorScheme = usePrevColorScheme ? prevColorScheme : autoColorScheme,\n scale = prevContext ? prevContext.scale : autoScale,\n locale = prevContext ? prevLocale : null,\n breakpoints = prevContext ? prevBreakpoints : DEFAULT_BREAKPOINTS,\n children,\n isQuiet,\n isEmphasized,\n isDisabled,\n isRequired,\n isReadOnly,\n validationState,\n router,\n ...otherProps\n } = props;\n\n // select only the props with values so undefined props don't overwrite prevContext values\n let currentProps = {\n version,\n theme,\n breakpoints,\n colorScheme,\n scale,\n isQuiet,\n isEmphasized,\n isDisabled,\n isRequired,\n isReadOnly,\n validationState\n };\n\n let matchedBreakpoints = useMatchedBreakpoints(breakpoints);\n let filteredProps = {};\n Object.entries(currentProps).forEach(([key, value]) => value !== undefined && (filteredProps[key] = value));\n\n // Merge options with parent provider\n let context = Object.assign({}, prevContext, filteredProps);\n\n // Only wrap in a DOM node if the theme, colorScheme, or scale changed\n let contents = children;\n let domProps = filterDOMProps(otherProps);\n let {styleProps} = useStyleProps(otherProps, undefined, {matchedBreakpoints});\n 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) {\n contents = (\n <ProviderWrapper {...props} UNSAFE_style={{isolation: !prevContext ? 'isolate' : undefined, ...styleProps.style}} ref={ref}>\n {contents}\n </ProviderWrapper>\n );\n }\n\n if (router) {\n contents = <RouterProvider {...router}>{contents}</RouterProvider>;\n }\n\n return (\n <Context.Provider value={context}>\n <I18nProvider locale={locale}>\n <BreakpointProvider matchedBreakpoints={matchedBreakpoints}>\n <ModalProvider>\n {contents}\n </ModalProvider>\n </BreakpointProvider>\n </I18nProvider>\n </Context.Provider>\n );\n}\n\n/**\n * Provider is the container for all React Spectrum applications.\n * It defines the theme, locale, and other application level settings,\n * and can also be used to provide common properties to a group of components.\n */\nlet _Provider = React.forwardRef(Provider);\nexport {_Provider as Provider};\n\nconst ProviderWrapper = React.forwardRef(function ProviderWrapper(props: ProviderProps, ref: DOMRef<HTMLDivElement>) {\n let {\n children,\n ...otherProps\n } = props;\n let {locale, direction} = useLocale();\n let {theme, colorScheme, scale} = useProvider();\n let {modalProviderProps} = useModalProvider();\n let {styleProps} = useStyleProps(otherProps);\n let domRef = useDOMRef(ref);\n\n let themeKey = Object.keys(theme[colorScheme])[0];\n let scaleKey = Object.keys(theme[scale])[0];\n\n let className = clsx(\n styleProps.className,\n styles['spectrum'],\n typographyStyles['spectrum'],\n Object.values(theme[colorScheme]),\n Object.values(theme[scale]),\n theme.global ? Object.values(theme.global) : null,\n {\n 'react-spectrum-provider': shouldKeepSpectrumClassNames,\n spectrum: shouldKeepSpectrumClassNames,\n [themeKey]: shouldKeepSpectrumClassNames,\n [scaleKey]: shouldKeepSpectrumClassNames\n }\n );\n\n let style = {\n ...styleProps.style,\n // This ensures that browser native UI like scrollbars are rendered in the right color scheme.\n // See https://web.dev/color-scheme/.\n colorScheme: props.colorScheme ?? colorScheme ?? Object.keys(theme).filter(k => k === 'light' || k === 'dark').join(' ')\n };\n\n let hasWarned = useRef(false);\n useEffect(() => {\n if (direction && domRef.current) {\n let closestDir = domRef.current.parentElement.closest('[dir]');\n let dir = closestDir && closestDir.getAttribute('dir');\n if (dir && dir !== direction && !hasWarned.current) {\n console.warn(`Language directions cannot be nested. ${direction} inside ${dir}.`);\n hasWarned.current = true;\n }\n }\n }, [direction, domRef, hasWarned]);\n\n\n return (\n <div\n {...filterDOMProps(otherProps)}\n {...styleProps}\n {...modalProviderProps}\n className={className}\n style={style}\n lang={locale}\n dir={direction}\n ref={domRef}>\n {children}\n </div>\n );\n});\n\n/**\n * Returns the various settings and styles applied by the nearest parent Provider.\n * Properties explicitly set by the nearest parent Provider override those provided by preceeding Providers.\n */\nexport function useProvider(): ProviderContext {\n return useContext(Context);\n}\n\nexport function useProviderProps<T>(props: T) : T {\n let context = useProvider();\n if (!context) {\n return props;\n }\n return Object.assign({}, {\n isQuiet: context.isQuiet,\n isEmphasized: context.isEmphasized,\n isDisabled: context.isDisabled,\n isRequired: context.isRequired,\n isReadOnly: context.isReadOnly,\n validationState: context.validationState\n }, props);\n}\n"],"names":[],"version":3,"file":"Provider.main.js.map"}
|
|
1
|
+
{"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A,gCAAA,gBAAgB,aAAa,cAA7B,oDAAA,8BAA+B,OAAO,CAAC;YACxD,IAAI,MAAM,cAAc,WAAW,YAAY,CAAC;YAChD,IAAI,OAAO,QAAQ,aAAa,CAAC,UAAU,OAAO,EAAE;gBAClD,QAAQ,IAAI,CAAC,CAAC,sCAAsC,EAAE,UAAU,QAAQ,EAAE,IAAI,CAAC,CAAC;gBAChF,UAAU,OAAO,GAAG;YACtB;QACF;IACF,GAAG;QAAC;QAAW;QAAQ;KAAU;IAGjC,qBACE,0DAAC;QACE,GAAG,CAAA,GAAA,oCAAa,EAAE,WAAW;QAC7B,GAAG,UAAU;QACb,GAAG,kBAAkB;QACtB,WAAW;QACX,OAAO;QACP,MAAM;QACN,KAAK;QACL,KAAK;OACJ;AAGP;AAMO,SAAS;IACd,IAAI,UAAU,CAAA,GAAA,uBAAS,EAAE,CAAA,GAAA,iCAAM;IAC/B,IAAI,CAAC,SACH,MAAM,IAAI,MACR;IAIJ,OAAO;AACT;AAEO,SAAS,0CAAoB,KAAQ;IAC1C,IAAI,UAAU,CAAA,GAAA,uBAAS,EAAE,CAAA,GAAA,iCAAM;IAC/B,IAAI,CAAC,SACH,OAAO;IAET,OAAO,OAAO,MAAM,CAAC,CAAC,GAAG;QACvB,SAAS,QAAQ,OAAO;QACxB,cAAc,QAAQ,YAAY;QAClC,YAAY,QAAQ,UAAU;QAC9B,YAAY,QAAQ,UAAU;QAC9B,YAAY,QAAQ,UAAU;QAC9B,iBAAiB,QAAQ,eAAe;IAC1C,GAAG;AACL","sources":["packages/@react-spectrum/provider/src/Provider.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 {\n BreakpointProvider,\n shouldKeepSpectrumClassNames,\n useDOMRef,\n useMatchedBreakpoints,\n useStyleProps\n} from '@react-spectrum/utils';\nimport clsx from 'clsx';\nimport {Context} from './context';\nimport {DOMRef} from '@react-types/shared';\nimport {filterDOMProps, RouterProvider} from '@react-aria/utils';\nimport {I18nProvider, useLocale} from '@react-aria/i18n';\nimport {ModalProvider, useModalProvider} from '@react-aria/overlays';\nimport {ProviderContext, ProviderProps} from '@react-types/provider';\nimport React, {useContext, useEffect, useRef} from 'react';\nimport styles from '@adobe/spectrum-css-temp/components/page/vars.css';\nimport typographyStyles from '@adobe/spectrum-css-temp/components/typography/index.css';\nimport {useColorScheme, useScale} from './mediaQueries';\n// @ts-ignore\nimport {version} from '../package.json';\n\nconst DEFAULT_BREAKPOINTS = {S: 640, M: 768, L: 1024, XL: 1280, XXL: 1536};\n\n/**\n * Provider is the container for all React Spectrum applications.\n * It defines the theme, locale, and other application level settings,\n * and can also be used to provide common properties to a group of components.\n */\nexport const Provider = React.forwardRef(function Provider(props: ProviderProps, ref: DOMRef<HTMLDivElement>) {\n let prevContext = useContext(Context);\n let prevColorScheme = prevContext && prevContext.colorScheme;\n let prevBreakpoints = prevContext && prevContext.breakpoints;\n let {\n theme = prevContext && prevContext.theme,\n defaultColorScheme\n } = props;\n if (!theme) {\n throw new Error('theme not found, the parent provider must have a theme provided');\n }\n // Hooks must always be called.\n let autoColorScheme = useColorScheme(theme, defaultColorScheme || 'light');\n let autoScale = useScale(theme);\n let {locale: prevLocale} = useLocale();\n // if the new theme doesn't support the prevColorScheme, we must resort to the auto\n let usePrevColorScheme = prevColorScheme ? !!theme[prevColorScheme] : false;\n\n // importance of color scheme props > parent > auto:(OS > default > omitted)\n let {\n colorScheme = usePrevColorScheme ? prevColorScheme : autoColorScheme,\n scale = prevContext ? prevContext.scale : autoScale,\n locale = prevContext ? prevLocale : undefined,\n breakpoints = prevContext ? prevBreakpoints : DEFAULT_BREAKPOINTS,\n children,\n isQuiet,\n isEmphasized,\n isDisabled,\n isRequired,\n isReadOnly,\n validationState,\n router,\n ...otherProps\n } = props;\n\n // select only the props with values so undefined props don't overwrite prevContext values\n let currentProps = {\n version,\n theme,\n breakpoints,\n colorScheme,\n scale,\n isQuiet,\n isEmphasized,\n isDisabled,\n isRequired,\n isReadOnly,\n validationState\n };\n\n let matchedBreakpoints = useMatchedBreakpoints(breakpoints!);\n let filteredProps = {};\n Object.entries(currentProps).forEach(([key, value]) => value !== undefined && (filteredProps[key] = value));\n\n // Merge options with parent provider\n let context = Object.assign({}, prevContext, filteredProps);\n\n // Only wrap in a DOM node if the theme, colorScheme, or scale changed\n let contents = children;\n let domProps = filterDOMProps(otherProps);\n let {styleProps} = useStyleProps(otherProps, undefined, {matchedBreakpoints});\n if (!prevContext || props.locale || theme !== prevContext.theme || colorScheme !== prevContext.colorScheme || scale !== prevContext.scale || Object.keys(domProps).length > 0 || otherProps.UNSAFE_className || (styleProps.style && Object.keys(styleProps.style).length > 0)) {\n contents = (\n <ProviderWrapper {...props} UNSAFE_style={{isolation: !prevContext ? 'isolate' : undefined, ...styleProps.style}} ref={ref}>\n {contents}\n </ProviderWrapper>\n );\n }\n\n if (router) {\n contents = <RouterProvider {...router}>{contents}</RouterProvider>;\n }\n\n return (\n <Context.Provider value={context}>\n <I18nProvider locale={locale}>\n <BreakpointProvider matchedBreakpoints={matchedBreakpoints}>\n <ModalProvider>\n {contents}\n </ModalProvider>\n </BreakpointProvider>\n </I18nProvider>\n </Context.Provider>\n );\n});\n\nconst ProviderWrapper = React.forwardRef(function ProviderWrapper(props: ProviderProps, ref: DOMRef<HTMLDivElement>) {\n let {\n children,\n ...otherProps\n } = props;\n let {locale, direction} = useLocale();\n let {theme, colorScheme, scale} = useProvider();\n let {modalProviderProps} = useModalProvider();\n let {styleProps} = useStyleProps(otherProps);\n let domRef = useDOMRef(ref);\n\n let themeKey = Object.keys(theme[colorScheme]!)[0];\n let scaleKey = Object.keys(theme[scale]!)[0];\n\n let className = clsx(\n styleProps.className,\n styles['spectrum'],\n typographyStyles['spectrum'],\n Object.values(theme[colorScheme]!),\n Object.values(theme[scale]!),\n theme.global ? Object.values(theme.global) : null,\n {\n 'react-spectrum-provider': shouldKeepSpectrumClassNames,\n spectrum: shouldKeepSpectrumClassNames,\n [themeKey]: shouldKeepSpectrumClassNames,\n [scaleKey]: shouldKeepSpectrumClassNames\n }\n );\n\n let style = {\n ...styleProps.style,\n // This ensures that browser native UI like scrollbars are rendered in the right color scheme.\n // See https://web.dev/color-scheme/.\n colorScheme: props.colorScheme ?? colorScheme ?? Object.keys(theme).filter(k => k === 'light' || k === 'dark').join(' ')\n };\n\n let hasWarned = useRef(false);\n useEffect(() => {\n if (direction && domRef.current) {\n let closestDir = domRef.current?.parentElement?.closest('[dir]');\n let dir = closestDir && closestDir.getAttribute('dir');\n if (dir && dir !== direction && !hasWarned.current) {\n console.warn(`Language directions cannot be nested. ${direction} inside ${dir}.`);\n hasWarned.current = true;\n }\n }\n }, [direction, domRef, hasWarned]);\n\n\n return (\n <div\n {...filterDOMProps(otherProps)}\n {...styleProps}\n {...modalProviderProps}\n className={className}\n style={style}\n lang={locale}\n dir={direction}\n ref={domRef}>\n {children}\n </div>\n );\n});\n\n/**\n * Returns the various settings and styles applied by the nearest parent Provider.\n * Properties explicitly set by the nearest parent Provider override those provided by preceeding Providers.\n */\nexport function useProvider(): ProviderContext {\n let context = useContext(Context);\n if (!context) {\n throw new Error(\n 'No root provider found, please make sure your app is wrapped within a <Provider>. ' +\n 'Alternatively, this issue may be caused by duplicate packages, see https://github.com/adobe/react-spectrum/wiki/Frequently-Asked-Questions-(FAQs)#why-are-there-errors-after-upgrading-a-react-spectrum-package for more information.'\n );\n }\n return context;\n}\n\nexport function useProviderProps<T>(props: T) : T {\n let context = useContext(Context);\n if (!context) {\n return props;\n }\n return Object.assign({}, {\n isQuiet: context.isQuiet,\n isEmphasized: context.isEmphasized,\n isDisabled: context.isDisabled,\n isRequired: context.isRequired,\n isReadOnly: context.isReadOnly,\n validationState: context.validationState\n }, props);\n}\n"],"names":[],"version":3,"file":"Provider.main.js.map"}
|
package/dist/Provider.mjs
CHANGED
|
@@ -10,7 +10,7 @@ import $dyW1v$clsx from "clsx";
|
|
|
10
10
|
import {filterDOMProps as $dyW1v$filterDOMProps, RouterProvider as $dyW1v$RouterProvider} from "@react-aria/utils";
|
|
11
11
|
import {useLocale as $dyW1v$useLocale, I18nProvider as $dyW1v$I18nProvider} from "@react-aria/i18n";
|
|
12
12
|
import {ModalProvider as $dyW1v$ModalProvider, useModalProvider as $dyW1v$useModalProvider} from "@react-aria/overlays";
|
|
13
|
-
import $dyW1v$react, {
|
|
13
|
+
import $dyW1v$react, {useContext as $dyW1v$useContext, useRef as $dyW1v$useRef, useEffect as $dyW1v$useEffect} from "react";
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
function $parcel$interopDefault(a) {
|
|
@@ -44,20 +44,20 @@ const $7167f8da3cce35e4$var$DEFAULT_BREAKPOINTS = {
|
|
|
44
44
|
XL: 1280,
|
|
45
45
|
XXL: 1536
|
|
46
46
|
};
|
|
47
|
-
|
|
48
|
-
let prevContext = $
|
|
47
|
+
const $7167f8da3cce35e4$export$2881499e37b75b9a = /*#__PURE__*/ (0, $dyW1v$react).forwardRef(function Provider(props, ref) {
|
|
48
|
+
let prevContext = (0, $dyW1v$useContext)((0, $a8430f637b4ccbce$export$841858b892ce1f4c));
|
|
49
49
|
let prevColorScheme = prevContext && prevContext.colorScheme;
|
|
50
50
|
let prevBreakpoints = prevContext && prevContext.breakpoints;
|
|
51
51
|
let { theme: theme = prevContext && prevContext.theme, defaultColorScheme: defaultColorScheme } = props;
|
|
52
52
|
if (!theme) throw new Error('theme not found, the parent provider must have a theme provided');
|
|
53
53
|
// Hooks must always be called.
|
|
54
|
-
let autoColorScheme = (0, $d8453c5ae7fac713$export$6343629ee1b29116)(theme, defaultColorScheme);
|
|
54
|
+
let autoColorScheme = (0, $d8453c5ae7fac713$export$6343629ee1b29116)(theme, defaultColorScheme || 'light');
|
|
55
55
|
let autoScale = (0, $d8453c5ae7fac713$export$a8d2043b2d807f4d)(theme);
|
|
56
56
|
let { locale: prevLocale } = (0, $dyW1v$useLocale)();
|
|
57
57
|
// if the new theme doesn't support the prevColorScheme, we must resort to the auto
|
|
58
|
-
let usePrevColorScheme = !!theme[prevColorScheme];
|
|
58
|
+
let usePrevColorScheme = prevColorScheme ? !!theme[prevColorScheme] : false;
|
|
59
59
|
// importance of color scheme props > parent > auto:(OS > default > omitted)
|
|
60
|
-
let { colorScheme: colorScheme = usePrevColorScheme ? prevColorScheme : autoColorScheme, scale: scale = prevContext ? prevContext.scale : autoScale, locale: locale = prevContext ? prevLocale :
|
|
60
|
+
let { colorScheme: colorScheme = usePrevColorScheme ? prevColorScheme : autoColorScheme, scale: scale = prevContext ? prevContext.scale : autoScale, locale: locale = prevContext ? prevLocale : undefined, breakpoints: breakpoints = prevContext ? prevBreakpoints : $7167f8da3cce35e4$var$DEFAULT_BREAKPOINTS, children: children, isQuiet: isQuiet, isEmphasized: isEmphasized, isDisabled: isDisabled, isRequired: isRequired, isReadOnly: isReadOnly, validationState: validationState, router: router, ...otherProps } = props;
|
|
61
61
|
// select only the props with values so undefined props don't overwrite prevContext values
|
|
62
62
|
let currentProps = {
|
|
63
63
|
version: $dyW1v$packagemodulejs.version,
|
|
@@ -83,7 +83,7 @@ function $7167f8da3cce35e4$var$Provider(props, ref) {
|
|
|
83
83
|
let { styleProps: styleProps } = (0, $dyW1v$useStyleProps)(otherProps, undefined, {
|
|
84
84
|
matchedBreakpoints: matchedBreakpoints
|
|
85
85
|
});
|
|
86
|
-
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__*/ (0, $dyW1v$react).createElement($7167f8da3cce35e4$var$ProviderWrapper, {
|
|
86
|
+
if (!prevContext || props.locale || theme !== prevContext.theme || colorScheme !== prevContext.colorScheme || scale !== prevContext.scale || Object.keys(domProps).length > 0 || otherProps.UNSAFE_className || styleProps.style && Object.keys(styleProps.style).length > 0) contents = /*#__PURE__*/ (0, $dyW1v$react).createElement($7167f8da3cce35e4$var$ProviderWrapper, {
|
|
87
87
|
...props,
|
|
88
88
|
UNSAFE_style: {
|
|
89
89
|
isolation: !prevContext ? 'isolate' : undefined,
|
|
@@ -99,12 +99,7 @@ function $7167f8da3cce35e4$var$Provider(props, ref) {
|
|
|
99
99
|
}, /*#__PURE__*/ (0, $dyW1v$react).createElement((0, $dyW1v$BreakpointProvider), {
|
|
100
100
|
matchedBreakpoints: matchedBreakpoints
|
|
101
101
|
}, /*#__PURE__*/ (0, $dyW1v$react).createElement((0, $dyW1v$ModalProvider), null, contents))));
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* Provider is the container for all React Spectrum applications.
|
|
105
|
-
* It defines the theme, locale, and other application level settings,
|
|
106
|
-
* and can also be used to provide common properties to a group of components.
|
|
107
|
-
*/ let $7167f8da3cce35e4$export$2881499e37b75b9a = /*#__PURE__*/ (0, $dyW1v$react).forwardRef($7167f8da3cce35e4$var$Provider);
|
|
102
|
+
});
|
|
108
103
|
const $7167f8da3cce35e4$var$ProviderWrapper = /*#__PURE__*/ (0, $dyW1v$react).forwardRef(function ProviderWrapper(props, ref) {
|
|
109
104
|
let { children: children, ...otherProps } = props;
|
|
110
105
|
let { locale: locale, direction: direction } = (0, $dyW1v$useLocale)();
|
|
@@ -130,7 +125,8 @@ const $7167f8da3cce35e4$var$ProviderWrapper = /*#__PURE__*/ (0, $dyW1v$react).fo
|
|
|
130
125
|
let hasWarned = (0, $dyW1v$useRef)(false);
|
|
131
126
|
(0, $dyW1v$useEffect)(()=>{
|
|
132
127
|
if (direction && domRef.current) {
|
|
133
|
-
|
|
128
|
+
var _domRef_current_parentElement, _domRef_current;
|
|
129
|
+
let closestDir = (_domRef_current = domRef.current) === null || _domRef_current === void 0 ? void 0 : (_domRef_current_parentElement = _domRef_current.parentElement) === null || _domRef_current_parentElement === void 0 ? void 0 : _domRef_current_parentElement.closest('[dir]');
|
|
134
130
|
let dir = closestDir && closestDir.getAttribute('dir');
|
|
135
131
|
if (dir && dir !== direction && !hasWarned.current) {
|
|
136
132
|
console.warn(`Language directions cannot be nested. ${direction} inside ${dir}.`);
|
|
@@ -154,10 +150,12 @@ const $7167f8da3cce35e4$var$ProviderWrapper = /*#__PURE__*/ (0, $dyW1v$react).fo
|
|
|
154
150
|
}, children);
|
|
155
151
|
});
|
|
156
152
|
function $7167f8da3cce35e4$export$693cdb10cec23617() {
|
|
157
|
-
|
|
153
|
+
let context = (0, $dyW1v$useContext)((0, $a8430f637b4ccbce$export$841858b892ce1f4c));
|
|
154
|
+
if (!context) throw new Error("No root provider found, please make sure your app is wrapped within a <Provider>. Alternatively, this issue may be caused by duplicate packages, see https://github.com/adobe/react-spectrum/wiki/Frequently-Asked-Questions-(FAQs)#why-are-there-errors-after-upgrading-a-react-spectrum-package for more information.");
|
|
155
|
+
return context;
|
|
158
156
|
}
|
|
159
157
|
function $7167f8da3cce35e4$export$521c373ccc32c300(props) {
|
|
160
|
-
let context = $
|
|
158
|
+
let context = (0, $dyW1v$useContext)((0, $a8430f637b4ccbce$export$841858b892ce1f4c));
|
|
161
159
|
if (!context) return props;
|
|
162
160
|
return Object.assign({}, {
|
|
163
161
|
isQuiet: context.isQuiet,
|
|
@@ -170,5 +168,5 @@ function $7167f8da3cce35e4$export$521c373ccc32c300(props) {
|
|
|
170
168
|
}
|
|
171
169
|
|
|
172
170
|
|
|
173
|
-
export {$7167f8da3cce35e4$export$
|
|
171
|
+
export {$7167f8da3cce35e4$export$2881499e37b75b9a as Provider, $7167f8da3cce35e4$export$693cdb10cec23617 as useProvider, $7167f8da3cce35e4$export$521c373ccc32c300 as useProviderProps};
|
|
174
172
|
//# sourceMappingURL=Provider.module.js.map
|
package/dist/Provider.module.js
CHANGED
|
@@ -10,7 +10,7 @@ import $dyW1v$clsx from "clsx";
|
|
|
10
10
|
import {filterDOMProps as $dyW1v$filterDOMProps, RouterProvider as $dyW1v$RouterProvider} from "@react-aria/utils";
|
|
11
11
|
import {useLocale as $dyW1v$useLocale, I18nProvider as $dyW1v$I18nProvider} from "@react-aria/i18n";
|
|
12
12
|
import {ModalProvider as $dyW1v$ModalProvider, useModalProvider as $dyW1v$useModalProvider} from "@react-aria/overlays";
|
|
13
|
-
import $dyW1v$react, {
|
|
13
|
+
import $dyW1v$react, {useContext as $dyW1v$useContext, useRef as $dyW1v$useRef, useEffect as $dyW1v$useEffect} from "react";
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
function $parcel$interopDefault(a) {
|
|
@@ -44,20 +44,20 @@ const $7167f8da3cce35e4$var$DEFAULT_BREAKPOINTS = {
|
|
|
44
44
|
XL: 1280,
|
|
45
45
|
XXL: 1536
|
|
46
46
|
};
|
|
47
|
-
|
|
48
|
-
let prevContext = $
|
|
47
|
+
const $7167f8da3cce35e4$export$2881499e37b75b9a = /*#__PURE__*/ (0, $dyW1v$react).forwardRef(function Provider(props, ref) {
|
|
48
|
+
let prevContext = (0, $dyW1v$useContext)((0, $a8430f637b4ccbce$export$841858b892ce1f4c));
|
|
49
49
|
let prevColorScheme = prevContext && prevContext.colorScheme;
|
|
50
50
|
let prevBreakpoints = prevContext && prevContext.breakpoints;
|
|
51
51
|
let { theme: theme = prevContext && prevContext.theme, defaultColorScheme: defaultColorScheme } = props;
|
|
52
52
|
if (!theme) throw new Error('theme not found, the parent provider must have a theme provided');
|
|
53
53
|
// Hooks must always be called.
|
|
54
|
-
let autoColorScheme = (0, $d8453c5ae7fac713$export$6343629ee1b29116)(theme, defaultColorScheme);
|
|
54
|
+
let autoColorScheme = (0, $d8453c5ae7fac713$export$6343629ee1b29116)(theme, defaultColorScheme || 'light');
|
|
55
55
|
let autoScale = (0, $d8453c5ae7fac713$export$a8d2043b2d807f4d)(theme);
|
|
56
56
|
let { locale: prevLocale } = (0, $dyW1v$useLocale)();
|
|
57
57
|
// if the new theme doesn't support the prevColorScheme, we must resort to the auto
|
|
58
|
-
let usePrevColorScheme = !!theme[prevColorScheme];
|
|
58
|
+
let usePrevColorScheme = prevColorScheme ? !!theme[prevColorScheme] : false;
|
|
59
59
|
// importance of color scheme props > parent > auto:(OS > default > omitted)
|
|
60
|
-
let { colorScheme: colorScheme = usePrevColorScheme ? prevColorScheme : autoColorScheme, scale: scale = prevContext ? prevContext.scale : autoScale, locale: locale = prevContext ? prevLocale :
|
|
60
|
+
let { colorScheme: colorScheme = usePrevColorScheme ? prevColorScheme : autoColorScheme, scale: scale = prevContext ? prevContext.scale : autoScale, locale: locale = prevContext ? prevLocale : undefined, breakpoints: breakpoints = prevContext ? prevBreakpoints : $7167f8da3cce35e4$var$DEFAULT_BREAKPOINTS, children: children, isQuiet: isQuiet, isEmphasized: isEmphasized, isDisabled: isDisabled, isRequired: isRequired, isReadOnly: isReadOnly, validationState: validationState, router: router, ...otherProps } = props;
|
|
61
61
|
// select only the props with values so undefined props don't overwrite prevContext values
|
|
62
62
|
let currentProps = {
|
|
63
63
|
version: $dyW1v$packagemodulejs.version,
|
|
@@ -83,7 +83,7 @@ function $7167f8da3cce35e4$var$Provider(props, ref) {
|
|
|
83
83
|
let { styleProps: styleProps } = (0, $dyW1v$useStyleProps)(otherProps, undefined, {
|
|
84
84
|
matchedBreakpoints: matchedBreakpoints
|
|
85
85
|
});
|
|
86
|
-
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__*/ (0, $dyW1v$react).createElement($7167f8da3cce35e4$var$ProviderWrapper, {
|
|
86
|
+
if (!prevContext || props.locale || theme !== prevContext.theme || colorScheme !== prevContext.colorScheme || scale !== prevContext.scale || Object.keys(domProps).length > 0 || otherProps.UNSAFE_className || styleProps.style && Object.keys(styleProps.style).length > 0) contents = /*#__PURE__*/ (0, $dyW1v$react).createElement($7167f8da3cce35e4$var$ProviderWrapper, {
|
|
87
87
|
...props,
|
|
88
88
|
UNSAFE_style: {
|
|
89
89
|
isolation: !prevContext ? 'isolate' : undefined,
|
|
@@ -99,12 +99,7 @@ function $7167f8da3cce35e4$var$Provider(props, ref) {
|
|
|
99
99
|
}, /*#__PURE__*/ (0, $dyW1v$react).createElement((0, $dyW1v$BreakpointProvider), {
|
|
100
100
|
matchedBreakpoints: matchedBreakpoints
|
|
101
101
|
}, /*#__PURE__*/ (0, $dyW1v$react).createElement((0, $dyW1v$ModalProvider), null, contents))));
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* Provider is the container for all React Spectrum applications.
|
|
105
|
-
* It defines the theme, locale, and other application level settings,
|
|
106
|
-
* and can also be used to provide common properties to a group of components.
|
|
107
|
-
*/ let $7167f8da3cce35e4$export$2881499e37b75b9a = /*#__PURE__*/ (0, $dyW1v$react).forwardRef($7167f8da3cce35e4$var$Provider);
|
|
102
|
+
});
|
|
108
103
|
const $7167f8da3cce35e4$var$ProviderWrapper = /*#__PURE__*/ (0, $dyW1v$react).forwardRef(function ProviderWrapper(props, ref) {
|
|
109
104
|
let { children: children, ...otherProps } = props;
|
|
110
105
|
let { locale: locale, direction: direction } = (0, $dyW1v$useLocale)();
|
|
@@ -130,7 +125,8 @@ const $7167f8da3cce35e4$var$ProviderWrapper = /*#__PURE__*/ (0, $dyW1v$react).fo
|
|
|
130
125
|
let hasWarned = (0, $dyW1v$useRef)(false);
|
|
131
126
|
(0, $dyW1v$useEffect)(()=>{
|
|
132
127
|
if (direction && domRef.current) {
|
|
133
|
-
|
|
128
|
+
var _domRef_current_parentElement, _domRef_current;
|
|
129
|
+
let closestDir = (_domRef_current = domRef.current) === null || _domRef_current === void 0 ? void 0 : (_domRef_current_parentElement = _domRef_current.parentElement) === null || _domRef_current_parentElement === void 0 ? void 0 : _domRef_current_parentElement.closest('[dir]');
|
|
134
130
|
let dir = closestDir && closestDir.getAttribute('dir');
|
|
135
131
|
if (dir && dir !== direction && !hasWarned.current) {
|
|
136
132
|
console.warn(`Language directions cannot be nested. ${direction} inside ${dir}.`);
|
|
@@ -154,10 +150,12 @@ const $7167f8da3cce35e4$var$ProviderWrapper = /*#__PURE__*/ (0, $dyW1v$react).fo
|
|
|
154
150
|
}, children);
|
|
155
151
|
});
|
|
156
152
|
function $7167f8da3cce35e4$export$693cdb10cec23617() {
|
|
157
|
-
|
|
153
|
+
let context = (0, $dyW1v$useContext)((0, $a8430f637b4ccbce$export$841858b892ce1f4c));
|
|
154
|
+
if (!context) throw new Error("No root provider found, please make sure your app is wrapped within a <Provider>. Alternatively, this issue may be caused by duplicate packages, see https://github.com/adobe/react-spectrum/wiki/Frequently-Asked-Questions-(FAQs)#why-are-there-errors-after-upgrading-a-react-spectrum-package for more information.");
|
|
155
|
+
return context;
|
|
158
156
|
}
|
|
159
157
|
function $7167f8da3cce35e4$export$521c373ccc32c300(props) {
|
|
160
|
-
let context = $
|
|
158
|
+
let context = (0, $dyW1v$useContext)((0, $a8430f637b4ccbce$export$841858b892ce1f4c));
|
|
161
159
|
if (!context) return props;
|
|
162
160
|
return Object.assign({}, {
|
|
163
161
|
isQuiet: context.isQuiet,
|
|
@@ -170,5 +168,5 @@ function $7167f8da3cce35e4$export$521c373ccc32c300(props) {
|
|
|
170
168
|
}
|
|
171
169
|
|
|
172
170
|
|
|
173
|
-
export {$7167f8da3cce35e4$export$
|
|
171
|
+
export {$7167f8da3cce35e4$export$2881499e37b75b9a as Provider, $7167f8da3cce35e4$export$693cdb10cec23617 as useProvider, $7167f8da3cce35e4$export$521c373ccc32c300 as useProviderProps};
|
|
174
172
|
//# sourceMappingURL=Provider.module.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;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EAAE,UAAU,QAAQ,EAAE,IAAI,CAAC,CAAC;gBAChF,UAAU,OAAO,GAAG;YACtB;QACF;IACF,GAAG;QAAC;QAAW;QAAQ;KAAU;IAGjC,qBACE,gCAAC;QACE,GAAG,CAAA,GAAA,qBAAa,EAAE,WAAW;QAC7B,GAAG,UAAU;QACb,GAAG,kBAAkB;QACtB,WAAW;QACX,OAAO;QACP,MAAM;QACN,KAAK;QACL,KAAK;OACJ;AAGP;AAMO,SAAS;IACd,OAAO,CAAA,GAAA,iBAAS,EAAE,CAAA,GAAA,yCAAM;AAC1B;AAEO,SAAS,0CAAoB,KAAQ;IAC1C,IAAI,UAAU;IACd,IAAI,CAAC,SACH,OAAO;IAET,OAAO,OAAO,MAAM,CAAC,CAAC,GAAG;QACvB,SAAS,QAAQ,OAAO;QACxB,cAAc,QAAQ,YAAY;QAClC,YAAY,QAAQ,UAAU;QAC9B,YAAY,QAAQ,UAAU;QAC9B,YAAY,QAAQ,UAAU;QAC9B,iBAAiB,QAAQ,eAAe;IAC1C,GAAG;AACL","sources":["packages/@react-spectrum/provider/src/Provider.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 {\n BreakpointProvider,\n shouldKeepSpectrumClassNames,\n useDOMRef,\n useMatchedBreakpoints,\n useStyleProps\n} from '@react-spectrum/utils';\nimport clsx from 'clsx';\nimport {Context} from './context';\nimport {DOMRef} from '@react-types/shared';\nimport {filterDOMProps, RouterProvider} from '@react-aria/utils';\nimport {I18nProvider, useLocale} from '@react-aria/i18n';\nimport {ModalProvider, useModalProvider} from '@react-aria/overlays';\nimport {ProviderContext, ProviderProps} from '@react-types/provider';\nimport React, {useContext, useEffect, useRef} from 'react';\nimport styles from '@adobe/spectrum-css-temp/components/page/vars.css';\nimport typographyStyles from '@adobe/spectrum-css-temp/components/typography/index.css';\nimport {useColorScheme, useScale} from './mediaQueries';\n// @ts-ignore\nimport {version} from '../package.json';\n\nconst DEFAULT_BREAKPOINTS = {S: 640, M: 768, L: 1024, XL: 1280, XXL: 1536};\n\nfunction Provider(props: ProviderProps, ref: DOMRef<HTMLDivElement>) {\n let prevContext = useProvider();\n let prevColorScheme = prevContext && prevContext.colorScheme;\n let prevBreakpoints = prevContext && prevContext.breakpoints;\n let {\n theme = prevContext && prevContext.theme,\n defaultColorScheme\n } = props;\n if (!theme) {\n throw new Error('theme not found, the parent provider must have a theme provided');\n }\n // Hooks must always be called.\n let autoColorScheme = useColorScheme(theme, defaultColorScheme);\n let autoScale = useScale(theme);\n let {locale: prevLocale} = useLocale();\n // if the new theme doesn't support the prevColorScheme, we must resort to the auto\n let usePrevColorScheme = !!theme[prevColorScheme];\n\n // importance of color scheme props > parent > auto:(OS > default > omitted)\n let {\n colorScheme = usePrevColorScheme ? prevColorScheme : autoColorScheme,\n scale = prevContext ? prevContext.scale : autoScale,\n locale = prevContext ? prevLocale : null,\n breakpoints = prevContext ? prevBreakpoints : DEFAULT_BREAKPOINTS,\n children,\n isQuiet,\n isEmphasized,\n isDisabled,\n isRequired,\n isReadOnly,\n validationState,\n router,\n ...otherProps\n } = props;\n\n // select only the props with values so undefined props don't overwrite prevContext values\n let currentProps = {\n version,\n theme,\n breakpoints,\n colorScheme,\n scale,\n isQuiet,\n isEmphasized,\n isDisabled,\n isRequired,\n isReadOnly,\n validationState\n };\n\n let matchedBreakpoints = useMatchedBreakpoints(breakpoints);\n let filteredProps = {};\n Object.entries(currentProps).forEach(([key, value]) => value !== undefined && (filteredProps[key] = value));\n\n // Merge options with parent provider\n let context = Object.assign({}, prevContext, filteredProps);\n\n // Only wrap in a DOM node if the theme, colorScheme, or scale changed\n let contents = children;\n let domProps = filterDOMProps(otherProps);\n let {styleProps} = useStyleProps(otherProps, undefined, {matchedBreakpoints});\n 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) {\n contents = (\n <ProviderWrapper {...props} UNSAFE_style={{isolation: !prevContext ? 'isolate' : undefined, ...styleProps.style}} ref={ref}>\n {contents}\n </ProviderWrapper>\n );\n }\n\n if (router) {\n contents = <RouterProvider {...router}>{contents}</RouterProvider>;\n }\n\n return (\n <Context.Provider value={context}>\n <I18nProvider locale={locale}>\n <BreakpointProvider matchedBreakpoints={matchedBreakpoints}>\n <ModalProvider>\n {contents}\n </ModalProvider>\n </BreakpointProvider>\n </I18nProvider>\n </Context.Provider>\n );\n}\n\n/**\n * Provider is the container for all React Spectrum applications.\n * It defines the theme, locale, and other application level settings,\n * and can also be used to provide common properties to a group of components.\n */\nlet _Provider = React.forwardRef(Provider);\nexport {_Provider as Provider};\n\nconst ProviderWrapper = React.forwardRef(function ProviderWrapper(props: ProviderProps, ref: DOMRef<HTMLDivElement>) {\n let {\n children,\n ...otherProps\n } = props;\n let {locale, direction} = useLocale();\n let {theme, colorScheme, scale} = useProvider();\n let {modalProviderProps} = useModalProvider();\n let {styleProps} = useStyleProps(otherProps);\n let domRef = useDOMRef(ref);\n\n let themeKey = Object.keys(theme[colorScheme])[0];\n let scaleKey = Object.keys(theme[scale])[0];\n\n let className = clsx(\n styleProps.className,\n styles['spectrum'],\n typographyStyles['spectrum'],\n Object.values(theme[colorScheme]),\n Object.values(theme[scale]),\n theme.global ? Object.values(theme.global) : null,\n {\n 'react-spectrum-provider': shouldKeepSpectrumClassNames,\n spectrum: shouldKeepSpectrumClassNames,\n [themeKey]: shouldKeepSpectrumClassNames,\n [scaleKey]: shouldKeepSpectrumClassNames\n }\n );\n\n let style = {\n ...styleProps.style,\n // This ensures that browser native UI like scrollbars are rendered in the right color scheme.\n // See https://web.dev/color-scheme/.\n colorScheme: props.colorScheme ?? colorScheme ?? Object.keys(theme).filter(k => k === 'light' || k === 'dark').join(' ')\n };\n\n let hasWarned = useRef(false);\n useEffect(() => {\n if (direction && domRef.current) {\n let closestDir = domRef.current.parentElement.closest('[dir]');\n let dir = closestDir && closestDir.getAttribute('dir');\n if (dir && dir !== direction && !hasWarned.current) {\n console.warn(`Language directions cannot be nested. ${direction} inside ${dir}.`);\n hasWarned.current = true;\n }\n }\n }, [direction, domRef, hasWarned]);\n\n\n return (\n <div\n {...filterDOMProps(otherProps)}\n {...styleProps}\n {...modalProviderProps}\n className={className}\n style={style}\n lang={locale}\n dir={direction}\n ref={domRef}>\n {children}\n </div>\n );\n});\n\n/**\n * Returns the various settings and styles applied by the nearest parent Provider.\n * Properties explicitly set by the nearest parent Provider override those provided by preceeding Providers.\n */\nexport function useProvider(): ProviderContext {\n return useContext(Context);\n}\n\nexport function useProviderProps<T>(props: T) : T {\n let context = useProvider();\n if (!context) {\n return props;\n }\n return Object.assign({}, {\n isQuiet: context.isQuiet,\n isEmphasized: context.isEmphasized,\n isDisabled: context.isDisabled,\n isRequired: context.isRequired,\n isReadOnly: context.isReadOnly,\n validationState: context.validationState\n }, props);\n}\n"],"names":[],"version":3,"file":"Provider.module.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;AAuBD,MAAM,4CAAsB;IAAC,GAAG;IAAK,GAAG;IAAK,GAAG;IAAM,IAAI;IAAM,KAAK;AAAI;AAOlE,MAAM,0DAAW,CAAA,GAAA,YAAI,EAAE,UAAU,CAAC,SAAS,SAAS,KAAoB,EAAE,GAA2B;IAC1G,IAAI,cAAc,CAAA,GAAA,iBAAS,EAAE,CAAA,GAAA,yCAAM;IACnC,IAAI,kBAAkB,eAAe,YAAY,WAAW;IAC5D,IAAI,kBAAkB,eAAe,YAAY,W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AAU;QACb,GAAG,kBAAkB;QACtB,WAAW;QACX,OAAO;QACP,MAAM;QACN,KAAK;QACL,KAAK;OACJ;AAGP;AAMO,SAAS;IACd,IAAI,UAAU,CAAA,GAAA,iBAAS,EAAE,CAAA,GAAA,yCAAM;IAC/B,IAAI,CAAC,SACH,MAAM,IAAI,MACR;IAIJ,OAAO;AACT;AAEO,SAAS,0CAAoB,KAAQ;IAC1C,IAAI,UAAU,CAAA,GAAA,iBAAS,EAAE,CAAA,GAAA,yCAAM;IAC/B,IAAI,CAAC,SACH,OAAO;IAET,OAAO,OAAO,MAAM,CAAC,CAAC,GAAG;QACvB,SAAS,QAAQ,OAAO;QACxB,cAAc,QAAQ,YAAY;QAClC,YAAY,QAAQ,UAAU;QAC9B,YAAY,QAAQ,UAAU;QAC9B,YAAY,QAAQ,UAAU;QAC9B,iBAAiB,QAAQ,eAAe;IAC1C,GAAG;AACL","sources":["packages/@react-spectrum/provider/src/Provider.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 {\n BreakpointProvider,\n shouldKeepSpectrumClassNames,\n useDOMRef,\n useMatchedBreakpoints,\n useStyleProps\n} from '@react-spectrum/utils';\nimport clsx from 'clsx';\nimport {Context} from './context';\nimport {DOMRef} from '@react-types/shared';\nimport {filterDOMProps, RouterProvider} from '@react-aria/utils';\nimport {I18nProvider, useLocale} from '@react-aria/i18n';\nimport {ModalProvider, useModalProvider} from '@react-aria/overlays';\nimport {ProviderContext, ProviderProps} from '@react-types/provider';\nimport React, {useContext, useEffect, useRef} from 'react';\nimport styles from '@adobe/spectrum-css-temp/components/page/vars.css';\nimport typographyStyles from '@adobe/spectrum-css-temp/components/typography/index.css';\nimport {useColorScheme, useScale} from './mediaQueries';\n// @ts-ignore\nimport {version} from '../package.json';\n\nconst DEFAULT_BREAKPOINTS = {S: 640, M: 768, L: 1024, XL: 1280, XXL: 1536};\n\n/**\n * Provider is the container for all React Spectrum applications.\n * It defines the theme, locale, and other application level settings,\n * and can also be used to provide common properties to a group of components.\n */\nexport const Provider = React.forwardRef(function Provider(props: ProviderProps, ref: DOMRef<HTMLDivElement>) {\n let prevContext = useContext(Context);\n let prevColorScheme = prevContext && prevContext.colorScheme;\n let prevBreakpoints = prevContext && prevContext.breakpoints;\n let {\n theme = prevContext && prevContext.theme,\n defaultColorScheme\n } = props;\n if (!theme) {\n throw new Error('theme not found, the parent provider must have a theme provided');\n }\n // Hooks must always be called.\n let autoColorScheme = useColorScheme(theme, defaultColorScheme || 'light');\n let autoScale = useScale(theme);\n let {locale: prevLocale} = useLocale();\n // if the new theme doesn't support the prevColorScheme, we must resort to the auto\n let usePrevColorScheme = prevColorScheme ? !!theme[prevColorScheme] : false;\n\n // importance of color scheme props > parent > auto:(OS > default > omitted)\n let {\n colorScheme = usePrevColorScheme ? prevColorScheme : autoColorScheme,\n scale = prevContext ? prevContext.scale : autoScale,\n locale = prevContext ? prevLocale : undefined,\n breakpoints = prevContext ? prevBreakpoints : DEFAULT_BREAKPOINTS,\n children,\n isQuiet,\n isEmphasized,\n isDisabled,\n isRequired,\n isReadOnly,\n validationState,\n router,\n ...otherProps\n } = props;\n\n // select only the props with values so undefined props don't overwrite prevContext values\n let currentProps = {\n version,\n theme,\n breakpoints,\n colorScheme,\n scale,\n isQuiet,\n isEmphasized,\n isDisabled,\n isRequired,\n isReadOnly,\n validationState\n };\n\n let matchedBreakpoints = useMatchedBreakpoints(breakpoints!);\n let filteredProps = {};\n Object.entries(currentProps).forEach(([key, value]) => value !== undefined && (filteredProps[key] = value));\n\n // Merge options with parent provider\n let context = Object.assign({}, prevContext, filteredProps);\n\n // Only wrap in a DOM node if the theme, colorScheme, or scale changed\n let contents = children;\n let domProps = filterDOMProps(otherProps);\n let {styleProps} = useStyleProps(otherProps, undefined, {matchedBreakpoints});\n if (!prevContext || props.locale || theme !== prevContext.theme || colorScheme !== prevContext.colorScheme || scale !== prevContext.scale || Object.keys(domProps).length > 0 || otherProps.UNSAFE_className || (styleProps.style && Object.keys(styleProps.style).length > 0)) {\n contents = (\n <ProviderWrapper {...props} UNSAFE_style={{isolation: !prevContext ? 'isolate' : undefined, ...styleProps.style}} ref={ref}>\n {contents}\n </ProviderWrapper>\n );\n }\n\n if (router) {\n contents = <RouterProvider {...router}>{contents}</RouterProvider>;\n }\n\n return (\n <Context.Provider value={context}>\n <I18nProvider locale={locale}>\n <BreakpointProvider matchedBreakpoints={matchedBreakpoints}>\n <ModalProvider>\n {contents}\n </ModalProvider>\n </BreakpointProvider>\n </I18nProvider>\n </Context.Provider>\n );\n});\n\nconst ProviderWrapper = React.forwardRef(function ProviderWrapper(props: ProviderProps, ref: DOMRef<HTMLDivElement>) {\n let {\n children,\n ...otherProps\n } = props;\n let {locale, direction} = useLocale();\n let {theme, colorScheme, scale} = useProvider();\n let {modalProviderProps} = useModalProvider();\n let {styleProps} = useStyleProps(otherProps);\n let domRef = useDOMRef(ref);\n\n let themeKey = Object.keys(theme[colorScheme]!)[0];\n let scaleKey = Object.keys(theme[scale]!)[0];\n\n let className = clsx(\n styleProps.className,\n styles['spectrum'],\n typographyStyles['spectrum'],\n Object.values(theme[colorScheme]!),\n Object.values(theme[scale]!),\n theme.global ? Object.values(theme.global) : null,\n {\n 'react-spectrum-provider': shouldKeepSpectrumClassNames,\n spectrum: shouldKeepSpectrumClassNames,\n [themeKey]: shouldKeepSpectrumClassNames,\n [scaleKey]: shouldKeepSpectrumClassNames\n }\n );\n\n let style = {\n ...styleProps.style,\n // This ensures that browser native UI like scrollbars are rendered in the right color scheme.\n // See https://web.dev/color-scheme/.\n colorScheme: props.colorScheme ?? colorScheme ?? Object.keys(theme).filter(k => k === 'light' || k === 'dark').join(' ')\n };\n\n let hasWarned = useRef(false);\n useEffect(() => {\n if (direction && domRef.current) {\n let closestDir = domRef.current?.parentElement?.closest('[dir]');\n let dir = closestDir && closestDir.getAttribute('dir');\n if (dir && dir !== direction && !hasWarned.current) {\n console.warn(`Language directions cannot be nested. ${direction} inside ${dir}.`);\n hasWarned.current = true;\n }\n }\n }, [direction, domRef, hasWarned]);\n\n\n return (\n <div\n {...filterDOMProps(otherProps)}\n {...styleProps}\n {...modalProviderProps}\n className={className}\n style={style}\n lang={locale}\n dir={direction}\n ref={domRef}>\n {children}\n </div>\n );\n});\n\n/**\n * Returns the various settings and styles applied by the nearest parent Provider.\n * Properties explicitly set by the nearest parent Provider override those provided by preceeding Providers.\n */\nexport function useProvider(): ProviderContext {\n let context = useContext(Context);\n if (!context) {\n throw new Error(\n 'No root provider found, please make sure your app is wrapped within a <Provider>. ' +\n 'Alternatively, this issue may be caused by duplicate packages, see https://github.com/adobe/react-spectrum/wiki/Frequently-Asked-Questions-(FAQs)#why-are-there-errors-after-upgrading-a-react-spectrum-package for more information.'\n );\n }\n return context;\n}\n\nexport function useProviderProps<T>(props: T) : T {\n let context = useContext(Context);\n if (!context) {\n return props;\n }\n return Object.assign({}, {\n isQuiet: context.isQuiet,\n isEmphasized: context.isEmphasized,\n isDisabled: context.isDisabled,\n isRequired: context.isRequired,\n isReadOnly: context.isReadOnly,\n validationState: context.validationState\n }, props);\n}\n"],"names":[],"version":3,"file":"Provider.module.js.map"}
|
package/dist/package.main.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
module.exports = JSON.parse("{\"name\":\"@react-spectrum/provider\",\"version\":\"3.
|
|
1
|
+
module.exports = JSON.parse("{\"name\":\"@react-spectrum/provider\",\"version\":\"3.10.1\",\"description\":\"Spectrum UI components in React\",\"license\":\"Apache-2.0\",\"main\":\"dist/main.js\",\"module\":\"dist/module.js\",\"exports\":{\"types\":\"./dist/types.d.ts\",\"import\":\"./dist/import.mjs\",\"require\":\"./dist/main.js\"},\"types\":\"dist/types.d.ts\",\"source\":\"src/index.ts\",\"files\":[\"dist\",\"src\"],\"sideEffects\":[\"*.css\"],\"targets\":{\"main\":{\"includeNodeModules\":[\"@adobe/spectrum-css-temp\"]},\"module\":{\"includeNodeModules\":[\"@adobe/spectrum-css-temp\"]}},\"repository\":{\"type\":\"git\",\"url\":\"https://github.com/adobe/react-spectrum\"},\"dependencies\":{\"@react-aria/i18n\":\"^3.12.5\",\"@react-aria/overlays\":\"^3.25.0\",\"@react-aria/utils\":\"^3.27.0\",\"@react-spectrum/utils\":\"^3.12.1\",\"@react-types/provider\":\"^3.8.6\",\"@react-types/shared\":\"^3.27.0\",\"@swc/helpers\":\"^0.5.0\",\"clsx\":\"^2.0.0\"},\"devDependencies\":{\"@adobe/spectrum-css-temp\":\"3.0.0-alpha.1\"},\"peerDependencies\":{\"react\":\"^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1\",\"react-dom\":\"^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1\"},\"publishConfig\":{\"access\":\"public\"}}");
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
//# sourceMappingURL=package.main.js.map
|
package/dist/package.main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"AAAA,iBAAiB,KAAK,KAAK,CAAC","sources":["packages/@react-spectrum/provider/package.json"],"sourcesContent":["{\n \"name\": \"@react-spectrum/provider\",\n \"version\": \"3.
|
|
1
|
+
{"mappings":"AAAA,iBAAiB,KAAK,KAAK,CAAC","sources":["packages/@react-spectrum/provider/package.json"],"sourcesContent":["{\n \"name\": \"@react-spectrum/provider\",\n \"version\": \"3.10.1\",\n \"description\": \"Spectrum UI components in React\",\n \"license\": \"Apache-2.0\",\n \"main\": \"dist/main.js\",\n \"module\": \"dist/module.js\",\n \"exports\": {\n \"types\": \"./dist/types.d.ts\",\n \"import\": \"./dist/import.mjs\",\n \"require\": \"./dist/main.js\"\n },\n \"types\": \"dist/types.d.ts\",\n \"source\": \"src/index.ts\",\n \"files\": [\n \"dist\",\n \"src\"\n ],\n \"sideEffects\": [\n \"*.css\"\n ],\n \"targets\": {\n \"main\": {\n \"includeNodeModules\": [\n \"@adobe/spectrum-css-temp\"\n ]\n },\n \"module\": {\n \"includeNodeModules\": [\n \"@adobe/spectrum-css-temp\"\n ]\n }\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/adobe/react-spectrum\"\n },\n \"dependencies\": {\n \"@react-aria/i18n\": \"^3.12.5\",\n \"@react-aria/overlays\": \"^3.25.0\",\n \"@react-aria/utils\": \"^3.27.0\",\n \"@react-spectrum/utils\": \"^3.12.1\",\n \"@react-types/provider\": \"^3.8.6\",\n \"@react-types/shared\": \"^3.27.0\",\n \"@swc/helpers\": \"^0.5.0\",\n \"clsx\": \"^2.0.0\"\n },\n \"devDependencies\": {\n \"@adobe/spectrum-css-temp\": \"3.0.0-alpha.1\"\n },\n \"peerDependencies\": {\n \"react\": \"^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1\",\n \"react-dom\": \"^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1\"\n },\n \"publishConfig\": {\n \"access\": \"public\"\n }\n}\n"],"names":[],"version":3,"file":"package.main.js.map"}
|
package/dist/package.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
var $7b22e09dddddd7da$exports = {};
|
|
2
|
-
$7b22e09dddddd7da$exports = JSON.parse("{\"name\":\"@react-spectrum/provider\",\"version\":\"3.
|
|
2
|
+
$7b22e09dddddd7da$exports = JSON.parse("{\"name\":\"@react-spectrum/provider\",\"version\":\"3.10.1\",\"description\":\"Spectrum UI components in React\",\"license\":\"Apache-2.0\",\"main\":\"dist/main.js\",\"module\":\"dist/module.js\",\"exports\":{\"types\":\"./dist/types.d.ts\",\"import\":\"./dist/import.mjs\",\"require\":\"./dist/main.js\"},\"types\":\"dist/types.d.ts\",\"source\":\"src/index.ts\",\"files\":[\"dist\",\"src\"],\"sideEffects\":[\"*.css\"],\"targets\":{\"main\":{\"includeNodeModules\":[\"@adobe/spectrum-css-temp\"]},\"module\":{\"includeNodeModules\":[\"@adobe/spectrum-css-temp\"]}},\"repository\":{\"type\":\"git\",\"url\":\"https://github.com/adobe/react-spectrum\"},\"dependencies\":{\"@react-aria/i18n\":\"^3.12.5\",\"@react-aria/overlays\":\"^3.25.0\",\"@react-aria/utils\":\"^3.27.0\",\"@react-spectrum/utils\":\"^3.12.1\",\"@react-types/provider\":\"^3.8.6\",\"@react-types/shared\":\"^3.27.0\",\"@swc/helpers\":\"^0.5.0\",\"clsx\":\"^2.0.0\"},\"devDependencies\":{\"@adobe/spectrum-css-temp\":\"3.0.0-alpha.1\"},\"peerDependencies\":{\"react\":\"^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1\",\"react-dom\":\"^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1\"},\"publishConfig\":{\"access\":\"public\"}}");
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
export {$7b22e09dddddd7da$exports as default};
|
package/dist/package.module.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
var $7b22e09dddddd7da$exports = {};
|
|
2
|
-
$7b22e09dddddd7da$exports = JSON.parse("{\"name\":\"@react-spectrum/provider\",\"version\":\"3.
|
|
2
|
+
$7b22e09dddddd7da$exports = JSON.parse("{\"name\":\"@react-spectrum/provider\",\"version\":\"3.10.1\",\"description\":\"Spectrum UI components in React\",\"license\":\"Apache-2.0\",\"main\":\"dist/main.js\",\"module\":\"dist/module.js\",\"exports\":{\"types\":\"./dist/types.d.ts\",\"import\":\"./dist/import.mjs\",\"require\":\"./dist/main.js\"},\"types\":\"dist/types.d.ts\",\"source\":\"src/index.ts\",\"files\":[\"dist\",\"src\"],\"sideEffects\":[\"*.css\"],\"targets\":{\"main\":{\"includeNodeModules\":[\"@adobe/spectrum-css-temp\"]},\"module\":{\"includeNodeModules\":[\"@adobe/spectrum-css-temp\"]}},\"repository\":{\"type\":\"git\",\"url\":\"https://github.com/adobe/react-spectrum\"},\"dependencies\":{\"@react-aria/i18n\":\"^3.12.5\",\"@react-aria/overlays\":\"^3.25.0\",\"@react-aria/utils\":\"^3.27.0\",\"@react-spectrum/utils\":\"^3.12.1\",\"@react-types/provider\":\"^3.8.6\",\"@react-types/shared\":\"^3.27.0\",\"@swc/helpers\":\"^0.5.0\",\"clsx\":\"^2.0.0\"},\"devDependencies\":{\"@adobe/spectrum-css-temp\":\"3.0.0-alpha.1\"},\"peerDependencies\":{\"react\":\"^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1\",\"react-dom\":\"^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1\"},\"publishConfig\":{\"access\":\"public\"}}");
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
export {$7b22e09dddddd7da$exports as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";AAAA,4BAAiB,KAAK,KAAK,CAAC","sources":["packages/@react-spectrum/provider/package.json"],"sourcesContent":["{\n \"name\": \"@react-spectrum/provider\",\n \"version\": \"3.
|
|
1
|
+
{"mappings":";AAAA,4BAAiB,KAAK,KAAK,CAAC","sources":["packages/@react-spectrum/provider/package.json"],"sourcesContent":["{\n \"name\": \"@react-spectrum/provider\",\n \"version\": \"3.10.1\",\n \"description\": \"Spectrum UI components in React\",\n \"license\": \"Apache-2.0\",\n \"main\": \"dist/main.js\",\n \"module\": \"dist/module.js\",\n \"exports\": {\n \"types\": \"./dist/types.d.ts\",\n \"import\": \"./dist/import.mjs\",\n \"require\": \"./dist/main.js\"\n },\n \"types\": \"dist/types.d.ts\",\n \"source\": \"src/index.ts\",\n \"files\": [\n \"dist\",\n \"src\"\n ],\n \"sideEffects\": [\n \"*.css\"\n ],\n \"targets\": {\n \"main\": {\n \"includeNodeModules\": [\n \"@adobe/spectrum-css-temp\"\n ]\n },\n \"module\": {\n \"includeNodeModules\": [\n \"@adobe/spectrum-css-temp\"\n ]\n }\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/adobe/react-spectrum\"\n },\n \"dependencies\": {\n \"@react-aria/i18n\": \"^3.12.5\",\n \"@react-aria/overlays\": \"^3.25.0\",\n \"@react-aria/utils\": \"^3.27.0\",\n \"@react-spectrum/utils\": \"^3.12.1\",\n \"@react-types/provider\": \"^3.8.6\",\n \"@react-types/shared\": \"^3.27.0\",\n \"@swc/helpers\": \"^0.5.0\",\n \"clsx\": \"^2.0.0\"\n },\n \"devDependencies\": {\n \"@adobe/spectrum-css-temp\": \"3.0.0-alpha.1\"\n },\n \"peerDependencies\": {\n \"react\": \"^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1\",\n \"react-dom\": \"^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1\"\n },\n \"publishConfig\": {\n \"access\": \"public\"\n }\n}\n"],"names":[],"version":3,"file":"package.module.js.map"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;AAAA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AALA,4CAA+B,CAAC,iBAAiB,CAAC;AAClD,4CAAmC,CAAC,qBAAqB,CAAC;AAC1D,4CAA6B,CAAC,eAAe,CAAC;AAC9C,4CAA4C,CAAC,8BAA8B,CAAC;AAC5E,4CAAuC,CAAC,0BAA0B,EAAE,
|
|
1
|
+
{"mappings":";;;;;;;;;;;AAAA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AALA,4CAA+B,CAAC,iBAAiB,CAAC;AAClD,4CAAmC,CAAC,qBAAqB,CAAC;AAC1D,4CAA6B,CAAC,eAAe,CAAC;AAC9C,4CAA4C,CAAC,8BAA8B,CAAC;AAC5E,4CAAuC,CAAC,0BAA0B,EAAE,2CAA2C;AAC/G,4CAA8C,CAAC,gCAAgC,CAAC","sources":["packages/@adobe/spectrum-css-temp/components/page/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":"page_vars_css.main.js.map"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;AAAA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AALA,4CAA+B,CAAC,iBAAiB,CAAC;AAClD,4CAAmC,CAAC,qBAAqB,CAAC;AAC1D,4CAA6B,CAAC,eAAe,CAAC;AAC9C,4CAA4C,CAAC,8BAA8B,CAAC;AAC5E,4CAAuC,CAAC,0BAA0B,EAAE,
|
|
1
|
+
{"mappings":";;;;;;;;;;;;AAAA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AALA,4CAA+B,CAAC,iBAAiB,CAAC;AAClD,4CAAmC,CAAC,qBAAqB,CAAC;AAC1D,4CAA6B,CAAC,eAAe,CAAC;AAC9C,4CAA4C,CAAC,8BAA8B,CAAC;AAC5E,4CAAuC,CAAC,0BAA0B,EAAE,2CAA2C;AAC/G,4CAA8C,CAAC,gCAAgC,CAAC","sources":["packages/@adobe/spectrum-css-temp/components/page/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":"page_vars_css.module.js.map"}
|
package/dist/types.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { DOMRefValue } from "@react-types/shared";
|
|
|
6
6
|
* It defines the theme, locale, and other application level settings,
|
|
7
7
|
* and can also be used to provide common properties to a group of components.
|
|
8
8
|
*/
|
|
9
|
-
export
|
|
9
|
+
export const Provider: React.ForwardRefExoticComponent<ProviderProps & React.RefAttributes<DOMRefValue<HTMLDivElement>>>;
|
|
10
10
|
/**
|
|
11
11
|
* Returns the various settings and styles applied by the nearest parent Provider.
|
|
12
12
|
* Properties explicitly set by the nearest parent Provider override those provided by preceeding Providers.
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;
|
|
1
|
+
{"mappings":";;;AEmCA;;;;GAIG;AACH,OAAO,MAAM,2GAoFX,CAAC;AAkEH;;;GAGG;AACH,+BAA+B,eAAe,CAS7C;AAED,iCAAiC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAI,CAAC,CAahD;AC3MD,YAAY,EAAC,eAAe,EAAC,MAAM,uBAAuB,CAAC;AAC3D,YAAY,EAAC,aAAa,EAAC,MAAM,uBAAuB,CAAC","sources":["packages/@react-spectrum/provider/src/packages/@react-spectrum/provider/src/context.ts","packages/@react-spectrum/provider/src/packages/@react-spectrum/provider/src/mediaQueries.ts","packages/@react-spectrum/provider/src/packages/@react-spectrum/provider/src/Provider.tsx","packages/@react-spectrum/provider/src/packages/@react-spectrum/provider/src/index.ts","packages/@react-spectrum/provider/src/index.ts"],"sourcesContent":[null,null,null,null,"/*\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/// <reference types=\"css-module-types\" />\n\nexport {Provider, useProvider, useProviderProps} from './Provider';\nexport type {ProviderContext} from '@react-types/provider';\nexport type {ProviderProps} from '@react-types/provider';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;AAAA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AAPA,4CAA+B,CAAC,iBAAiB,CAAC;AAClD,4CAAmC,CAAC,qBAAqB,CAAC;AAC1D,4CAA6B,CAAC,gBAAgB,EAAE,
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;AAAA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AAPA,4CAA+B,CAAC,iBAAiB,CAAC;AAClD,4CAAmC,CAAC,qBAAqB,CAAC;AAC1D,4CAA6B,CAAC,gBAAgB,EAAE,2CAAkC;AAClF,4CAAkC,CAAC,oBAAoB,CAAC;AACxD,4CAA0C,CAAC,4BAA4B,CAAC;AACxE,4CAA4C,CAAC,8BAA8B,CAAC;AAC5E,4CAAuC,CAAC,0BAA0B,EAAE,2CAA2C;AAC/G,4CAA8C,CAAC,gCAAgC,CAAC","sources":["packages/@adobe/spectrum-css-temp/components/typography/index.css"],"sourcesContent":["/*\nCopyright 2019 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\n@import '../commons/index.css';\n@import 'font.css';\n\n/*@mixin typography .spectrum-Body1 {}\n@mixin typography .spectrum-Body2 {}\n@mixin typography .spectrum-Body3 {}\n@mixin typography .spectrum-Body4 {}\n@mixin typography .spectrum-Body5 {}\n@mixin typography .spectrum-Heading1 {}\n@mixin typography .spectrum-Heading2 {}\n@mixin typography .spectrum-Heading3 {}\n@mixin typography .spectrum-Heading4 {}\n@mixin typography .spectrum-Heading5 {}\n@mixin typography .spectrum-Heading6 {}\n@mixin typography .spectrum-Subheading {}\n@mixin typography .spectrum-Detail {}\n@mixin typography .spectrum-Heading1--quiet, heading-quiet-1 {}\n@mixin typography .spectrum-Heading2--quiet, heading-quiet-2 {}\n@mixin typography .spectrum-Heading1--strong, heading-strong-1 {}\n@mixin typography .spectrum-Heading2--strong, heading-strong-2 {}\n@mixin typography .spectrum-Heading1--display, display-1 {}\n@mixin typography .spectrum-Heading2--display, display-2 {}\n@mixin typography .spectrum-Heading1--display.spectrum-Heading1--strong, display-strong-1 {}\n@mixin typography .spectrum-Heading2--display.spectrum-Heading2--strong, display-strong-2 {}\n@mixin typography .spectrum-Heading1--display.spectrum-Heading1--quiet, display-quiet-1 {}\n@mixin typography .spectrum-Heading2--display.spectrum-Heading2--quiet, display-quiet-2 {}\n\n.spectrum-Typography {\n @mixin typographyMargins .spectrum-Body1 {}\n @mixin typographyMargins .spectrum-Body2 {}\n @mixin typographyMargins .spectrum-Body3 {}\n @mixin typographyMargins .spectrum-Body4 {}\n @mixin typographyMargins .spectrum-Body5 {}\n @mixin typographyMargins .spectrum-Heading1 {}\n @mixin typographyMargins .spectrum-Heading2 {}\n @mixin typographyMargins .spectrum-Heading3 {}\n @mixin typographyMargins .spectrum-Heading4 {}\n @mixin typographyMargins .spectrum-Heading5 {}\n @mixin typographyMargins .spectrum-Heading6 {}\n @mixin typographyMargins .spectrum-Subheading {}\n @mixin typographyMargins .spectrum-Detail {}\n @mixin typographyMargins .spectrum-Heading1--quiet, heading-quiet-1 {}\n @mixin typographyMargins .spectrum-Heading2--quiet, heading-quiet-2 {}\n @mixin typographyMargins .spectrum-Heading1--strong, heading-strong-1 {}\n @mixin typographyMargins .spectrum-Heading2--strong, heading-strong-2 {}\n @mixin typographyMargins .spectrum-Heading1--display, display-1 {}\n @mixin typographyMargins .spectrum-Heading2--display, display-2 {}\n @mixin typographyMargins .spectrum-Heading1--display.spectrum-Heading1--strong, display-strong-1 {}\n @mixin typographyMargins .spectrum-Heading2--display.spectrum-Heading2--strong, display-strong-2 {}\n @mixin typographyMargins .spectrum-Heading1--display.spectrum-Heading1--quiet, display-quiet-1 {}\n @mixin typographyMargins .spectrum-Heading2--display.spectrum-Heading2--quiet, display-quiet-2 {}\n}\n\n.spectrum-Article {\n font-family: var(--spectrum-body-article-1-text-font-family);\n @mixin typography .spectrum-Body1, body-article-1 {}\n @mixin typography .spectrum-Body2, body-article-2 {}\n @mixin typography .spectrum-Body3, body-article-3 {}\n @mixin typography .spectrum-Body4, body-article-4 {}\n @mixin typography .spectrum-Body5, body-article-5 {}\n @mixin typography .spectrum-Heading1, heading-article-1 {}\n @mixin typography .spectrum-Heading2, heading-article-2 {}\n @mixin typography .spectrum-Heading3, heading-article-3 {}\n @mixin typography .spectrum-Heading4, heading-article-4 {}\n @mixin typography .spectrum-Heading5, heading-article-5 {}\n @mixin typography .spectrum-Heading6, heading-article-6 {}\n @mixin typography .spectrum-Subheading, subheading-article {}\n @mixin typography .spectrum-Detail, detail-article {}\n @mixin typography .spectrum-Heading1--quiet, heading-quiet-article-1 {}\n @mixin typography .spectrum-Heading2--quiet, heading-quiet-article-2 {}\n @mixin typography .spectrum-Heading1--display, display-article-1 {}\n @mixin typography .spectrum-Heading2--display, display-article-2 {}\n @mixin typography .spectrum-Heading1--display.spectrum-Heading1--quiet, display-quiet-article-1 {}\n @mixin typography .spectrum-Heading2--display.spectrum-Heading2--quiet, display-quiet-article-2 {}\n}\n.spectrum {\n &:lang(ja),\n &:lang(ko),\n &:lang(zh) {\n @mixin typography .spectrum-Body1, body-han-1 {}\n @mixin typography .spectrum-Body2, body-han-2 {}\n @mixin typography .spectrum-Body3, body-han-3 {}\n @mixin typography .spectrum-Body4, body-han-4 {}\n @mixin typography .spectrum-Body5, body-han-5 {}\n @mixin typography .spectrum-Heading1, heading-han-1 {}\n @mixin typography .spectrum-Heading2, heading-han-2 {}\n @mixin typography .spectrum-Heading3, heading-han-3 {}\n @mixin typography .spectrum-Heading4, heading-han-4 {}\n @mixin typography .spectrum-Heading5, heading-han-5 {}\n @mixin typography .spectrum-Heading6, heading-han-6 {}\n @mixin typography .spectrum-Subheading, subheading-han {}\n @mixin typography .spectrum-Detail, detail-han {}\n @mixin typography .spectrum-Heading1--quiet, heading-quiet-han-1 {}\n @mixin typography .spectrum-Heading2--quiet, heading-quiet-han-2 {}\n @mixin typography .spectrum-Heading1--strong, heading-strong-han-1 {}\n @mixin typography .spectrum-Heading2--strong, heading-strong-han-2 {}\n @mixin typography .spectrum-Heading1--display, display-han-1 {}\n @mixin typography .spectrum-Heading2--display, display-han-2 {}\n @mixin typography .spectrum-Heading1--display.spectrum-Heading1--strong, display-strong-han-1 {}\n @mixin typography .spectrum-Heading2--display.spectrum-Heading2--strong, display-strong-han-2 {}\n @mixin typography .spectrum-Heading1--display.spectrum-Heading1--quiet, display-quiet-han-1 {}\n @mixin typography .spectrum-Heading2--display.spectrum-Heading2--quiet, display-quiet-han-2 {}\n }\n}\n@mixin typography .spectrum-Code1, body-code-1, true {\n font-family: var(--spectrum-body-code-1-text-font-family);\n}\n@mixin typography .spectrum-Code2, body-code-2, true {\n font-family: var(--spectrum-body-code-2-text-font-family);\n}\n@mixin typography .spectrum-Code3, body-code-3, true {\n font-family: var(--spectrum-body-code-3-text-font-family);\n}\n@mixin typography .spectrum-Code4, body-code-4, true {\n font-family: var(--spectrum-body-code-4-text-font-family);\n}\n@mixin typography .spectrum-Code5, body-code-5, true {\n font-family: var(--spectrum-body-code-5-text-font-family);\n}*/\n\n/*\n The &.spectrum makes it so users can do <div class=\"spectrum spectrum--large\"> and still get the right font sizes\n Without this, they would have to do <div class=\"spectrum--large\"><div class=\"spectrum\">, which makes no sense\n*/\n.spectrum,\n.spectrum-Body,\n.spectrum,\n.spectrum-Body {\n font-size: var(--spectrum-body-4-text-size);\n font-weight: var(--spectrum-body-4-text-font-weight);\n line-height: var(--spectrum-body-4-text-line-height);\n font-style: var(--spectrum-body-4-text-font-style);\n}\n\n.spectrum-Body--italic {\n font-style: var(--spectrum-body-4-emphasis-text-font-style);\n}\n\n/*\n.spectrum-Body--large {\n @extend .spectrum-Body2;\n}\n\n.spectrum-Body--small {\n @extend .spectrum-Body5;\n}\n\n.spectrum-Body--secondary {\n @extend .spectrum-Body4;\n}\n\n.spectrum-Heading--display {\n @extend .spectrum-Heading2--display.spectrum-Heading2--quiet;\n}\n\n.spectrum-Heading--pageTitle {\n @extend .spectrum-Heading2--quiet;\n}\n\n.spectrum-Heading--subtitle1 {\n @extend .spectrum-Heading4;\n}\n\n.spectrum-Heading--subtitle2 {\n @extend .spectrum-Heading6;\n}\n\n.spectrum-Heading--subtitle3 {\n @extend .spectrum-Subheading;\n}*/\n"],"names":[],"version":3,"file":"typography_index_css.main.js.map"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;AAAA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AAPA,4CAA+B,CAAC,iBAAiB,CAAC;AAClD,4CAAmC,CAAC,qBAAqB,CAAC;AAC1D,4CAA6B,CAAC,gBAAgB,EAAE,
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;AAAA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AACA,IAAA;AAPA,4CAA+B,CAAC,iBAAiB,CAAC;AAClD,4CAAmC,CAAC,qBAAqB,CAAC;AAC1D,4CAA6B,CAAC,gBAAgB,EAAE,2CAAkC;AAClF,4CAAkC,CAAC,oBAAoB,CAAC;AACxD,4CAA0C,CAAC,4BAA4B,CAAC;AACxE,4CAA4C,CAAC,8BAA8B,CAAC;AAC5E,4CAAuC,CAAC,0BAA0B,EAAE,2CAA2C;AAC/G,4CAA8C,CAAC,gCAAgC,CAAC","sources":["packages/@adobe/spectrum-css-temp/components/typography/index.css"],"sourcesContent":["/*\nCopyright 2019 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\n@import '../commons/index.css';\n@import 'font.css';\n\n/*@mixin typography .spectrum-Body1 {}\n@mixin typography .spectrum-Body2 {}\n@mixin typography .spectrum-Body3 {}\n@mixin typography .spectrum-Body4 {}\n@mixin typography .spectrum-Body5 {}\n@mixin typography .spectrum-Heading1 {}\n@mixin typography .spectrum-Heading2 {}\n@mixin typography .spectrum-Heading3 {}\n@mixin typography .spectrum-Heading4 {}\n@mixin typography .spectrum-Heading5 {}\n@mixin typography .spectrum-Heading6 {}\n@mixin typography .spectrum-Subheading {}\n@mixin typography .spectrum-Detail {}\n@mixin typography .spectrum-Heading1--quiet, heading-quiet-1 {}\n@mixin typography .spectrum-Heading2--quiet, heading-quiet-2 {}\n@mixin typography .spectrum-Heading1--strong, heading-strong-1 {}\n@mixin typography .spectrum-Heading2--strong, heading-strong-2 {}\n@mixin typography .spectrum-Heading1--display, display-1 {}\n@mixin typography .spectrum-Heading2--display, display-2 {}\n@mixin typography .spectrum-Heading1--display.spectrum-Heading1--strong, display-strong-1 {}\n@mixin typography .spectrum-Heading2--display.spectrum-Heading2--strong, display-strong-2 {}\n@mixin typography .spectrum-Heading1--display.spectrum-Heading1--quiet, display-quiet-1 {}\n@mixin typography .spectrum-Heading2--display.spectrum-Heading2--quiet, display-quiet-2 {}\n\n.spectrum-Typography {\n @mixin typographyMargins .spectrum-Body1 {}\n @mixin typographyMargins .spectrum-Body2 {}\n @mixin typographyMargins .spectrum-Body3 {}\n @mixin typographyMargins .spectrum-Body4 {}\n @mixin typographyMargins .spectrum-Body5 {}\n @mixin typographyMargins .spectrum-Heading1 {}\n @mixin typographyMargins .spectrum-Heading2 {}\n @mixin typographyMargins .spectrum-Heading3 {}\n @mixin typographyMargins .spectrum-Heading4 {}\n @mixin typographyMargins .spectrum-Heading5 {}\n @mixin typographyMargins .spectrum-Heading6 {}\n @mixin typographyMargins .spectrum-Subheading {}\n @mixin typographyMargins .spectrum-Detail {}\n @mixin typographyMargins .spectrum-Heading1--quiet, heading-quiet-1 {}\n @mixin typographyMargins .spectrum-Heading2--quiet, heading-quiet-2 {}\n @mixin typographyMargins .spectrum-Heading1--strong, heading-strong-1 {}\n @mixin typographyMargins .spectrum-Heading2--strong, heading-strong-2 {}\n @mixin typographyMargins .spectrum-Heading1--display, display-1 {}\n @mixin typographyMargins .spectrum-Heading2--display, display-2 {}\n @mixin typographyMargins .spectrum-Heading1--display.spectrum-Heading1--strong, display-strong-1 {}\n @mixin typographyMargins .spectrum-Heading2--display.spectrum-Heading2--strong, display-strong-2 {}\n @mixin typographyMargins .spectrum-Heading1--display.spectrum-Heading1--quiet, display-quiet-1 {}\n @mixin typographyMargins .spectrum-Heading2--display.spectrum-Heading2--quiet, display-quiet-2 {}\n}\n\n.spectrum-Article {\n font-family: var(--spectrum-body-article-1-text-font-family);\n @mixin typography .spectrum-Body1, body-article-1 {}\n @mixin typography .spectrum-Body2, body-article-2 {}\n @mixin typography .spectrum-Body3, body-article-3 {}\n @mixin typography .spectrum-Body4, body-article-4 {}\n @mixin typography .spectrum-Body5, body-article-5 {}\n @mixin typography .spectrum-Heading1, heading-article-1 {}\n @mixin typography .spectrum-Heading2, heading-article-2 {}\n @mixin typography .spectrum-Heading3, heading-article-3 {}\n @mixin typography .spectrum-Heading4, heading-article-4 {}\n @mixin typography .spectrum-Heading5, heading-article-5 {}\n @mixin typography .spectrum-Heading6, heading-article-6 {}\n @mixin typography .spectrum-Subheading, subheading-article {}\n @mixin typography .spectrum-Detail, detail-article {}\n @mixin typography .spectrum-Heading1--quiet, heading-quiet-article-1 {}\n @mixin typography .spectrum-Heading2--quiet, heading-quiet-article-2 {}\n @mixin typography .spectrum-Heading1--display, display-article-1 {}\n @mixin typography .spectrum-Heading2--display, display-article-2 {}\n @mixin typography .spectrum-Heading1--display.spectrum-Heading1--quiet, display-quiet-article-1 {}\n @mixin typography .spectrum-Heading2--display.spectrum-Heading2--quiet, display-quiet-article-2 {}\n}\n.spectrum {\n &:lang(ja),\n &:lang(ko),\n &:lang(zh) {\n @mixin typography .spectrum-Body1, body-han-1 {}\n @mixin typography .spectrum-Body2, body-han-2 {}\n @mixin typography .spectrum-Body3, body-han-3 {}\n @mixin typography .spectrum-Body4, body-han-4 {}\n @mixin typography .spectrum-Body5, body-han-5 {}\n @mixin typography .spectrum-Heading1, heading-han-1 {}\n @mixin typography .spectrum-Heading2, heading-han-2 {}\n @mixin typography .spectrum-Heading3, heading-han-3 {}\n @mixin typography .spectrum-Heading4, heading-han-4 {}\n @mixin typography .spectrum-Heading5, heading-han-5 {}\n @mixin typography .spectrum-Heading6, heading-han-6 {}\n @mixin typography .spectrum-Subheading, subheading-han {}\n @mixin typography .spectrum-Detail, detail-han {}\n @mixin typography .spectrum-Heading1--quiet, heading-quiet-han-1 {}\n @mixin typography .spectrum-Heading2--quiet, heading-quiet-han-2 {}\n @mixin typography .spectrum-Heading1--strong, heading-strong-han-1 {}\n @mixin typography .spectrum-Heading2--strong, heading-strong-han-2 {}\n @mixin typography .spectrum-Heading1--display, display-han-1 {}\n @mixin typography .spectrum-Heading2--display, display-han-2 {}\n @mixin typography .spectrum-Heading1--display.spectrum-Heading1--strong, display-strong-han-1 {}\n @mixin typography .spectrum-Heading2--display.spectrum-Heading2--strong, display-strong-han-2 {}\n @mixin typography .spectrum-Heading1--display.spectrum-Heading1--quiet, display-quiet-han-1 {}\n @mixin typography .spectrum-Heading2--display.spectrum-Heading2--quiet, display-quiet-han-2 {}\n }\n}\n@mixin typography .spectrum-Code1, body-code-1, true {\n font-family: var(--spectrum-body-code-1-text-font-family);\n}\n@mixin typography .spectrum-Code2, body-code-2, true {\n font-family: var(--spectrum-body-code-2-text-font-family);\n}\n@mixin typography .spectrum-Code3, body-code-3, true {\n font-family: var(--spectrum-body-code-3-text-font-family);\n}\n@mixin typography .spectrum-Code4, body-code-4, true {\n font-family: var(--spectrum-body-code-4-text-font-family);\n}\n@mixin typography .spectrum-Code5, body-code-5, true {\n font-family: var(--spectrum-body-code-5-text-font-family);\n}*/\n\n/*\n The &.spectrum makes it so users can do <div class=\"spectrum spectrum--large\"> and still get the right font sizes\n Without this, they would have to do <div class=\"spectrum--large\"><div class=\"spectrum\">, which makes no sense\n*/\n.spectrum,\n.spectrum-Body,\n.spectrum,\n.spectrum-Body {\n font-size: var(--spectrum-body-4-text-size);\n font-weight: var(--spectrum-body-4-text-font-weight);\n line-height: var(--spectrum-body-4-text-line-height);\n font-style: var(--spectrum-body-4-text-font-style);\n}\n\n.spectrum-Body--italic {\n font-style: var(--spectrum-body-4-emphasis-text-font-style);\n}\n\n/*\n.spectrum-Body--large {\n @extend .spectrum-Body2;\n}\n\n.spectrum-Body--small {\n @extend .spectrum-Body5;\n}\n\n.spectrum-Body--secondary {\n @extend .spectrum-Body4;\n}\n\n.spectrum-Heading--display {\n @extend .spectrum-Heading2--display.spectrum-Heading2--quiet;\n}\n\n.spectrum-Heading--pageTitle {\n @extend .spectrum-Heading2--quiet;\n}\n\n.spectrum-Heading--subtitle1 {\n @extend .spectrum-Heading4;\n}\n\n.spectrum-Heading--subtitle2 {\n @extend .spectrum-Heading6;\n}\n\n.spectrum-Heading--subtitle3 {\n @extend .spectrum-Subheading;\n}*/\n"],"names":[],"version":3,"file":"typography_index_css.module.js.map"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-spectrum/provider",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.10.1",
|
|
4
4
|
"description": "Spectrum UI components in React",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -36,12 +36,12 @@
|
|
|
36
36
|
"url": "https://github.com/adobe/react-spectrum"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@react-aria/i18n": "^3.12.
|
|
40
|
-
"@react-aria/overlays": "^3.
|
|
41
|
-
"@react-aria/utils": "^3.
|
|
42
|
-
"@react-spectrum/utils": "^3.
|
|
43
|
-
"@react-types/provider": "^3.8.
|
|
44
|
-
"@react-types/shared": "^3.
|
|
39
|
+
"@react-aria/i18n": "^3.12.5",
|
|
40
|
+
"@react-aria/overlays": "^3.25.0",
|
|
41
|
+
"@react-aria/utils": "^3.27.0",
|
|
42
|
+
"@react-spectrum/utils": "^3.12.1",
|
|
43
|
+
"@react-types/provider": "^3.8.6",
|
|
44
|
+
"@react-types/shared": "^3.27.0",
|
|
45
45
|
"@swc/helpers": "^0.5.0",
|
|
46
46
|
"clsx": "^2.0.0"
|
|
47
47
|
},
|
|
@@ -49,11 +49,11 @@
|
|
|
49
49
|
"@adobe/spectrum-css-temp": "3.0.0-alpha.1"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
52
|
-
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0",
|
|
53
|
-
"react-dom": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0"
|
|
52
|
+
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1",
|
|
53
|
+
"react-dom": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1"
|
|
54
54
|
},
|
|
55
55
|
"publishConfig": {
|
|
56
56
|
"access": "public"
|
|
57
57
|
},
|
|
58
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "09e7f44bebdc9d89122926b2b439a0a38a2814ea"
|
|
59
59
|
}
|
package/src/Provider.tsx
CHANGED
|
@@ -33,8 +33,13 @@ import {version} from '../package.json';
|
|
|
33
33
|
|
|
34
34
|
const DEFAULT_BREAKPOINTS = {S: 640, M: 768, L: 1024, XL: 1280, XXL: 1536};
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
/**
|
|
37
|
+
* Provider is the container for all React Spectrum applications.
|
|
38
|
+
* It defines the theme, locale, and other application level settings,
|
|
39
|
+
* and can also be used to provide common properties to a group of components.
|
|
40
|
+
*/
|
|
41
|
+
export const Provider = React.forwardRef(function Provider(props: ProviderProps, ref: DOMRef<HTMLDivElement>) {
|
|
42
|
+
let prevContext = useContext(Context);
|
|
38
43
|
let prevColorScheme = prevContext && prevContext.colorScheme;
|
|
39
44
|
let prevBreakpoints = prevContext && prevContext.breakpoints;
|
|
40
45
|
let {
|
|
@@ -45,17 +50,17 @@ function Provider(props: ProviderProps, ref: DOMRef<HTMLDivElement>) {
|
|
|
45
50
|
throw new Error('theme not found, the parent provider must have a theme provided');
|
|
46
51
|
}
|
|
47
52
|
// Hooks must always be called.
|
|
48
|
-
let autoColorScheme = useColorScheme(theme, defaultColorScheme);
|
|
53
|
+
let autoColorScheme = useColorScheme(theme, defaultColorScheme || 'light');
|
|
49
54
|
let autoScale = useScale(theme);
|
|
50
55
|
let {locale: prevLocale} = useLocale();
|
|
51
56
|
// if the new theme doesn't support the prevColorScheme, we must resort to the auto
|
|
52
|
-
let usePrevColorScheme = !!theme[prevColorScheme];
|
|
57
|
+
let usePrevColorScheme = prevColorScheme ? !!theme[prevColorScheme] : false;
|
|
53
58
|
|
|
54
59
|
// importance of color scheme props > parent > auto:(OS > default > omitted)
|
|
55
60
|
let {
|
|
56
61
|
colorScheme = usePrevColorScheme ? prevColorScheme : autoColorScheme,
|
|
57
62
|
scale = prevContext ? prevContext.scale : autoScale,
|
|
58
|
-
locale = prevContext ? prevLocale :
|
|
63
|
+
locale = prevContext ? prevLocale : undefined,
|
|
59
64
|
breakpoints = prevContext ? prevBreakpoints : DEFAULT_BREAKPOINTS,
|
|
60
65
|
children,
|
|
61
66
|
isQuiet,
|
|
@@ -83,7 +88,7 @@ function Provider(props: ProviderProps, ref: DOMRef<HTMLDivElement>) {
|
|
|
83
88
|
validationState
|
|
84
89
|
};
|
|
85
90
|
|
|
86
|
-
let matchedBreakpoints = useMatchedBreakpoints(breakpoints);
|
|
91
|
+
let matchedBreakpoints = useMatchedBreakpoints(breakpoints!);
|
|
87
92
|
let filteredProps = {};
|
|
88
93
|
Object.entries(currentProps).forEach(([key, value]) => value !== undefined && (filteredProps[key] = value));
|
|
89
94
|
|
|
@@ -94,7 +99,7 @@ function Provider(props: ProviderProps, ref: DOMRef<HTMLDivElement>) {
|
|
|
94
99
|
let contents = children;
|
|
95
100
|
let domProps = filterDOMProps(otherProps);
|
|
96
101
|
let {styleProps} = useStyleProps(otherProps, undefined, {matchedBreakpoints});
|
|
97
|
-
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) {
|
|
102
|
+
if (!prevContext || props.locale || theme !== prevContext.theme || colorScheme !== prevContext.colorScheme || scale !== prevContext.scale || Object.keys(domProps).length > 0 || otherProps.UNSAFE_className || (styleProps.style && Object.keys(styleProps.style).length > 0)) {
|
|
98
103
|
contents = (
|
|
99
104
|
<ProviderWrapper {...props} UNSAFE_style={{isolation: !prevContext ? 'isolate' : undefined, ...styleProps.style}} ref={ref}>
|
|
100
105
|
{contents}
|
|
@@ -117,15 +122,7 @@ function Provider(props: ProviderProps, ref: DOMRef<HTMLDivElement>) {
|
|
|
117
122
|
</I18nProvider>
|
|
118
123
|
</Context.Provider>
|
|
119
124
|
);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* Provider is the container for all React Spectrum applications.
|
|
124
|
-
* It defines the theme, locale, and other application level settings,
|
|
125
|
-
* and can also be used to provide common properties to a group of components.
|
|
126
|
-
*/
|
|
127
|
-
let _Provider = React.forwardRef(Provider);
|
|
128
|
-
export {_Provider as Provider};
|
|
125
|
+
});
|
|
129
126
|
|
|
130
127
|
const ProviderWrapper = React.forwardRef(function ProviderWrapper(props: ProviderProps, ref: DOMRef<HTMLDivElement>) {
|
|
131
128
|
let {
|
|
@@ -138,15 +135,15 @@ const ProviderWrapper = React.forwardRef(function ProviderWrapper(props: Provide
|
|
|
138
135
|
let {styleProps} = useStyleProps(otherProps);
|
|
139
136
|
let domRef = useDOMRef(ref);
|
|
140
137
|
|
|
141
|
-
let themeKey = Object.keys(theme[colorScheme])[0];
|
|
142
|
-
let scaleKey = Object.keys(theme[scale])[0];
|
|
138
|
+
let themeKey = Object.keys(theme[colorScheme]!)[0];
|
|
139
|
+
let scaleKey = Object.keys(theme[scale]!)[0];
|
|
143
140
|
|
|
144
141
|
let className = clsx(
|
|
145
142
|
styleProps.className,
|
|
146
143
|
styles['spectrum'],
|
|
147
144
|
typographyStyles['spectrum'],
|
|
148
|
-
Object.values(theme[colorScheme]),
|
|
149
|
-
Object.values(theme[scale]),
|
|
145
|
+
Object.values(theme[colorScheme]!),
|
|
146
|
+
Object.values(theme[scale]!),
|
|
150
147
|
theme.global ? Object.values(theme.global) : null,
|
|
151
148
|
{
|
|
152
149
|
'react-spectrum-provider': shouldKeepSpectrumClassNames,
|
|
@@ -166,7 +163,7 @@ const ProviderWrapper = React.forwardRef(function ProviderWrapper(props: Provide
|
|
|
166
163
|
let hasWarned = useRef(false);
|
|
167
164
|
useEffect(() => {
|
|
168
165
|
if (direction && domRef.current) {
|
|
169
|
-
let closestDir = domRef.current
|
|
166
|
+
let closestDir = domRef.current?.parentElement?.closest('[dir]');
|
|
170
167
|
let dir = closestDir && closestDir.getAttribute('dir');
|
|
171
168
|
if (dir && dir !== direction && !hasWarned.current) {
|
|
172
169
|
console.warn(`Language directions cannot be nested. ${direction} inside ${dir}.`);
|
|
@@ -196,11 +193,18 @@ const ProviderWrapper = React.forwardRef(function ProviderWrapper(props: Provide
|
|
|
196
193
|
* Properties explicitly set by the nearest parent Provider override those provided by preceeding Providers.
|
|
197
194
|
*/
|
|
198
195
|
export function useProvider(): ProviderContext {
|
|
199
|
-
|
|
196
|
+
let context = useContext(Context);
|
|
197
|
+
if (!context) {
|
|
198
|
+
throw new Error(
|
|
199
|
+
'No root provider found, please make sure your app is wrapped within a <Provider>. ' +
|
|
200
|
+
'Alternatively, this issue may be caused by duplicate packages, see https://github.com/adobe/react-spectrum/wiki/Frequently-Asked-Questions-(FAQs)#why-are-there-errors-after-upgrading-a-react-spectrum-package for more information.'
|
|
201
|
+
);
|
|
202
|
+
}
|
|
203
|
+
return context;
|
|
200
204
|
}
|
|
201
205
|
|
|
202
206
|
export function useProviderProps<T>(props: T) : T {
|
|
203
|
-
let context =
|
|
207
|
+
let context = useContext(Context);
|
|
204
208
|
if (!context) {
|
|
205
209
|
return props;
|
|
206
210
|
}
|