@react-spectrum/provider 3.9.5 → 3.9.6
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 +181 -0
- package/dist/Provider.main.js.map +1 -0
- package/dist/Provider.mjs +174 -0
- package/dist/Provider.module.js +174 -0
- package/dist/Provider.module.js.map +1 -0
- package/dist/context.main.js +28 -0
- package/dist/context.main.js.map +1 -0
- package/dist/context.mjs +19 -0
- package/dist/context.module.js +19 -0
- package/dist/context.module.js.map +1 -0
- package/dist/import.mjs +1 -263
- package/dist/main.js +4 -262
- package/dist/main.js.map +1 -1
- package/dist/mediaQueries.main.js +41 -0
- package/dist/mediaQueries.main.js.map +1 -0
- package/dist/mediaQueries.mjs +35 -0
- package/dist/mediaQueries.module.js +35 -0
- package/dist/mediaQueries.module.js.map +1 -0
- package/dist/module.js +1 -263
- package/dist/module.js.map +1 -1
- package/dist/package.main.js +4 -0
- package/dist/package.main.js.map +1 -0
- package/dist/package.mjs +6 -0
- package/dist/package.module.js +6 -0
- package/dist/package.module.js.map +1 -0
- package/dist/page_vars_css.main.js +26 -0
- package/dist/page_vars_css.main.js.map +1 -0
- package/dist/page_vars_css.mjs +28 -0
- package/dist/page_vars_css.module.js +28 -0
- package/dist/page_vars_css.module.js.map +1 -0
- package/dist/types.d.ts +2 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/{main.css → typography.eea3ebfe.css} +13 -99
- package/dist/typography.eea3ebfe.css.map +1 -0
- package/dist/typography_index_css.main.js +32 -0
- package/dist/typography_index_css.main.js.map +1 -0
- package/dist/typography_index_css.mjs +34 -0
- package/dist/typography_index_css.module.js +34 -0
- package/dist/typography_index_css.module.js.map +1 -0
- package/dist/vars.3c44f451.css +85 -0
- package/dist/vars.3c44f451.css.map +1 -0
- package/package.json +8 -8
- package/dist/main.css.map +0 -1
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
var $a5b4f4e252b5a021$exports = require("./context.main.js");
|
|
2
|
+
require("./vars.3c44f451.css");
|
|
3
|
+
var $22365f0f5f2dcdd5$exports = require("./page_vars_css.main.js");
|
|
4
|
+
require("./typography.eea3ebfe.css");
|
|
5
|
+
var $19fbfce217006b12$exports = require("./typography_index_css.main.js");
|
|
6
|
+
var $a6e2b5f4621e4690$exports = require("./mediaQueries.main.js");
|
|
7
|
+
var $4db360e38265184f$exports = require("./package.main.js");
|
|
8
|
+
var $dbjUM$reactspectrumutils = require("@react-spectrum/utils");
|
|
9
|
+
var $dbjUM$clsx = require("clsx");
|
|
10
|
+
var $dbjUM$reactariautils = require("@react-aria/utils");
|
|
11
|
+
var $dbjUM$reactariai18n = require("@react-aria/i18n");
|
|
12
|
+
var $dbjUM$reactariaoverlays = require("@react-aria/overlays");
|
|
13
|
+
var $dbjUM$react = require("react");
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
function $parcel$interopDefault(a) {
|
|
17
|
+
return a && a.__esModule ? a.default : a;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function $parcel$export(e, n, v, s) {
|
|
21
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
$parcel$export(module.exports, "useProvider", () => $96cabdf5b0aed55b$export$693cdb10cec23617);
|
|
25
|
+
$parcel$export(module.exports, "Provider", () => $96cabdf5b0aed55b$export$2881499e37b75b9a);
|
|
26
|
+
$parcel$export(module.exports, "useProviderProps", () => $96cabdf5b0aed55b$export$521c373ccc32c300);
|
|
27
|
+
/*
|
|
28
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
29
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
30
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
31
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
32
|
+
*
|
|
33
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
34
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
35
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
36
|
+
* governing permissions and limitations under the License.
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
const $96cabdf5b0aed55b$var$DEFAULT_BREAKPOINTS = {
|
|
49
|
+
S: 640,
|
|
50
|
+
M: 768,
|
|
51
|
+
L: 1024,
|
|
52
|
+
XL: 1280,
|
|
53
|
+
XXL: 1536
|
|
54
|
+
};
|
|
55
|
+
function $96cabdf5b0aed55b$var$Provider(props, ref) {
|
|
56
|
+
let prevContext = $96cabdf5b0aed55b$export$693cdb10cec23617();
|
|
57
|
+
let prevColorScheme = prevContext && prevContext.colorScheme;
|
|
58
|
+
let prevBreakpoints = prevContext && prevContext.breakpoints;
|
|
59
|
+
let { theme: theme = prevContext && prevContext.theme, defaultColorScheme: defaultColorScheme } = props;
|
|
60
|
+
if (!theme) throw new Error("theme not found, the parent provider must have a theme provided");
|
|
61
|
+
// Hooks must always be called.
|
|
62
|
+
let autoColorScheme = (0, $a6e2b5f4621e4690$exports.useColorScheme)(theme, defaultColorScheme);
|
|
63
|
+
let autoScale = (0, $a6e2b5f4621e4690$exports.useScale)(theme);
|
|
64
|
+
let { locale: prevLocale } = (0, $dbjUM$reactariai18n.useLocale)();
|
|
65
|
+
// if the new theme doesn't support the prevColorScheme, we must resort to the auto
|
|
66
|
+
let usePrevColorScheme = !!theme[prevColorScheme];
|
|
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 : null, 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
|
+
// select only the props with values so undefined props don't overwrite prevContext values
|
|
70
|
+
let currentProps = {
|
|
71
|
+
version: $4db360e38265184f$exports.version,
|
|
72
|
+
theme: theme,
|
|
73
|
+
breakpoints: breakpoints,
|
|
74
|
+
colorScheme: colorScheme,
|
|
75
|
+
scale: scale,
|
|
76
|
+
isQuiet: isQuiet,
|
|
77
|
+
isEmphasized: isEmphasized,
|
|
78
|
+
isDisabled: isDisabled,
|
|
79
|
+
isRequired: isRequired,
|
|
80
|
+
isReadOnly: isReadOnly,
|
|
81
|
+
validationState: validationState
|
|
82
|
+
};
|
|
83
|
+
let matchedBreakpoints = (0, $dbjUM$reactspectrumutils.useMatchedBreakpoints)(breakpoints);
|
|
84
|
+
let filteredProps = {};
|
|
85
|
+
Object.entries(currentProps).forEach(([key, value])=>value !== undefined && (filteredProps[key] = value));
|
|
86
|
+
// Merge options with parent provider
|
|
87
|
+
let context = Object.assign({}, prevContext, filteredProps);
|
|
88
|
+
// Only wrap in a DOM node if the theme, colorScheme, or scale changed
|
|
89
|
+
let contents = children;
|
|
90
|
+
let domProps = (0, $dbjUM$reactariautils.filterDOMProps)(otherProps);
|
|
91
|
+
let { styleProps: styleProps } = (0, $dbjUM$reactspectrumutils.useStyleProps)(otherProps, undefined, {
|
|
92
|
+
matchedBreakpoints: matchedBreakpoints
|
|
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, {
|
|
95
|
+
...props,
|
|
96
|
+
UNSAFE_style: {
|
|
97
|
+
isolation: !prevContext ? "isolate" : undefined,
|
|
98
|
+
...styleProps.style
|
|
99
|
+
},
|
|
100
|
+
ref: ref
|
|
101
|
+
}, contents);
|
|
102
|
+
if (router) contents = /*#__PURE__*/ (0, ($parcel$interopDefault($dbjUM$react))).createElement((0, $dbjUM$reactariautils.RouterProvider), router, contents);
|
|
103
|
+
return /*#__PURE__*/ (0, ($parcel$interopDefault($dbjUM$react))).createElement((0, $a5b4f4e252b5a021$exports.Context).Provider, {
|
|
104
|
+
value: context
|
|
105
|
+
}, /*#__PURE__*/ (0, ($parcel$interopDefault($dbjUM$react))).createElement((0, $dbjUM$reactariai18n.I18nProvider), {
|
|
106
|
+
locale: locale
|
|
107
|
+
}, /*#__PURE__*/ (0, ($parcel$interopDefault($dbjUM$react))).createElement((0, $dbjUM$reactspectrumutils.BreakpointProvider), {
|
|
108
|
+
matchedBreakpoints: matchedBreakpoints
|
|
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);
|
|
116
|
+
const $96cabdf5b0aed55b$var$ProviderWrapper = /*#__PURE__*/ (0, ($parcel$interopDefault($dbjUM$react))).forwardRef(function ProviderWrapper(props, ref) {
|
|
117
|
+
let { children: children, ...otherProps } = props;
|
|
118
|
+
let { locale: locale, direction: direction } = (0, $dbjUM$reactariai18n.useLocale)();
|
|
119
|
+
let { theme: theme, colorScheme: colorScheme, scale: scale } = $96cabdf5b0aed55b$export$693cdb10cec23617();
|
|
120
|
+
let { modalProviderProps: modalProviderProps } = (0, $dbjUM$reactariaoverlays.useModalProvider)();
|
|
121
|
+
let { styleProps: styleProps } = (0, $dbjUM$reactspectrumutils.useStyleProps)(otherProps);
|
|
122
|
+
let domRef = (0, $dbjUM$reactspectrumutils.useDOMRef)(ref);
|
|
123
|
+
let themeKey = Object.keys(theme[colorScheme])[0];
|
|
124
|
+
let scaleKey = Object.keys(theme[scale])[0];
|
|
125
|
+
let className = (0, ($parcel$interopDefault($dbjUM$clsx)))(styleProps.className, (0, ($parcel$interopDefault($22365f0f5f2dcdd5$exports)))["spectrum"], (0, ($parcel$interopDefault($19fbfce217006b12$exports)))["spectrum"], Object.values(theme[colorScheme]), Object.values(theme[scale]), theme.global ? Object.values(theme.global) : null, {
|
|
126
|
+
"react-spectrum-provider": (0, $dbjUM$reactspectrumutils.shouldKeepSpectrumClassNames),
|
|
127
|
+
spectrum: (0, $dbjUM$reactspectrumutils.shouldKeepSpectrumClassNames),
|
|
128
|
+
[themeKey]: (0, $dbjUM$reactspectrumutils.shouldKeepSpectrumClassNames),
|
|
129
|
+
[scaleKey]: (0, $dbjUM$reactspectrumutils.shouldKeepSpectrumClassNames)
|
|
130
|
+
});
|
|
131
|
+
var _props_colorScheme, _ref;
|
|
132
|
+
let style = {
|
|
133
|
+
...styleProps.style,
|
|
134
|
+
// This ensures that browser native UI like scrollbars are rendered in the right color scheme.
|
|
135
|
+
// See https://web.dev/color-scheme/.
|
|
136
|
+
colorScheme: (_ref = (_props_colorScheme = props.colorScheme) !== null && _props_colorScheme !== void 0 ? _props_colorScheme : colorScheme) !== null && _ref !== void 0 ? _ref : Object.keys(theme).filter((k)=>k === "light" || k === "dark").join(" ")
|
|
137
|
+
};
|
|
138
|
+
let hasWarned = (0, $dbjUM$react.useRef)(false);
|
|
139
|
+
(0, $dbjUM$react.useEffect)(()=>{
|
|
140
|
+
if (direction && domRef.current) {
|
|
141
|
+
let closestDir = domRef.current.parentElement.closest("[dir]");
|
|
142
|
+
let dir = closestDir && closestDir.getAttribute("dir");
|
|
143
|
+
if (dir && dir !== direction && !hasWarned.current) {
|
|
144
|
+
console.warn(`Language directions cannot be nested. ${direction} inside ${dir}.`);
|
|
145
|
+
hasWarned.current = true;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}, [
|
|
149
|
+
direction,
|
|
150
|
+
domRef,
|
|
151
|
+
hasWarned
|
|
152
|
+
]);
|
|
153
|
+
return /*#__PURE__*/ (0, ($parcel$interopDefault($dbjUM$react))).createElement("div", {
|
|
154
|
+
...(0, $dbjUM$reactariautils.filterDOMProps)(otherProps),
|
|
155
|
+
...styleProps,
|
|
156
|
+
...modalProviderProps,
|
|
157
|
+
className: className,
|
|
158
|
+
style: style,
|
|
159
|
+
lang: locale,
|
|
160
|
+
dir: direction,
|
|
161
|
+
ref: domRef
|
|
162
|
+
}, children);
|
|
163
|
+
});
|
|
164
|
+
function $96cabdf5b0aed55b$export$693cdb10cec23617() {
|
|
165
|
+
return (0, $dbjUM$react.useContext)((0, $a5b4f4e252b5a021$exports.Context));
|
|
166
|
+
}
|
|
167
|
+
function $96cabdf5b0aed55b$export$521c373ccc32c300(props) {
|
|
168
|
+
let context = $96cabdf5b0aed55b$export$693cdb10cec23617();
|
|
169
|
+
if (!context) return props;
|
|
170
|
+
return Object.assign({}, {
|
|
171
|
+
isQuiet: context.isQuiet,
|
|
172
|
+
isEmphasized: context.isEmphasized,
|
|
173
|
+
isDisabled: context.isDisabled,
|
|
174
|
+
isRequired: context.isRequired,
|
|
175
|
+
isReadOnly: context.isReadOnly,
|
|
176
|
+
validationState: context.validationState
|
|
177
|
+
}, props);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
//# sourceMappingURL=Provider.main.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;AAuBD,MAAM,4CAAsB;IAAC,GAAG;IAAK,GAAG;IAAK,GAAG;IAAM,IAAI;IAAM,KA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F;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"}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import {Context as $a8430f637b4ccbce$export$841858b892ce1f4c} from "./context.mjs";
|
|
2
|
+
import "./vars.3c44f451.css";
|
|
3
|
+
import $dyW1v$page_vars_cssmodulejs from "./page_vars_css.mjs";
|
|
4
|
+
import "./typography.eea3ebfe.css";
|
|
5
|
+
import $dyW1v$typography_index_cssmodulejs from "./typography_index_css.mjs";
|
|
6
|
+
import {useColorScheme as $d8453c5ae7fac713$export$6343629ee1b29116, useScale as $d8453c5ae7fac713$export$a8d2043b2d807f4d} from "./mediaQueries.mjs";
|
|
7
|
+
import $dyW1v$packagemodulejs from "./package.mjs";
|
|
8
|
+
import {useMatchedBreakpoints as $dyW1v$useMatchedBreakpoints, useStyleProps as $dyW1v$useStyleProps, BreakpointProvider as $dyW1v$BreakpointProvider, useDOMRef as $dyW1v$useDOMRef, shouldKeepSpectrumClassNames as $dyW1v$shouldKeepSpectrumClassNames} from "@react-spectrum/utils";
|
|
9
|
+
import $dyW1v$clsx from "clsx";
|
|
10
|
+
import {filterDOMProps as $dyW1v$filterDOMProps, RouterProvider as $dyW1v$RouterProvider} from "@react-aria/utils";
|
|
11
|
+
import {useLocale as $dyW1v$useLocale, I18nProvider as $dyW1v$I18nProvider} from "@react-aria/i18n";
|
|
12
|
+
import {ModalProvider as $dyW1v$ModalProvider, useModalProvider as $dyW1v$useModalProvider} from "@react-aria/overlays";
|
|
13
|
+
import $dyW1v$react, {useRef as $dyW1v$useRef, useEffect as $dyW1v$useEffect, useContext as $dyW1v$useContext} from "react";
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
function $parcel$interopDefault(a) {
|
|
17
|
+
return a && a.__esModule ? a.default : a;
|
|
18
|
+
}
|
|
19
|
+
/*
|
|
20
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
21
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
22
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
23
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
24
|
+
*
|
|
25
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
26
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
27
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
28
|
+
* governing permissions and limitations under the License.
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
const $7167f8da3cce35e4$var$DEFAULT_BREAKPOINTS = {
|
|
41
|
+
S: 640,
|
|
42
|
+
M: 768,
|
|
43
|
+
L: 1024,
|
|
44
|
+
XL: 1280,
|
|
45
|
+
XXL: 1536
|
|
46
|
+
};
|
|
47
|
+
function $7167f8da3cce35e4$var$Provider(props, ref) {
|
|
48
|
+
let prevContext = $7167f8da3cce35e4$export$693cdb10cec23617();
|
|
49
|
+
let prevColorScheme = prevContext && prevContext.colorScheme;
|
|
50
|
+
let prevBreakpoints = prevContext && prevContext.breakpoints;
|
|
51
|
+
let { theme: theme = prevContext && prevContext.theme, defaultColorScheme: defaultColorScheme } = props;
|
|
52
|
+
if (!theme) throw new Error("theme not found, the parent provider must have a theme provided");
|
|
53
|
+
// Hooks must always be called.
|
|
54
|
+
let autoColorScheme = (0, $d8453c5ae7fac713$export$6343629ee1b29116)(theme, defaultColorScheme);
|
|
55
|
+
let autoScale = (0, $d8453c5ae7fac713$export$a8d2043b2d807f4d)(theme);
|
|
56
|
+
let { locale: prevLocale } = (0, $dyW1v$useLocale)();
|
|
57
|
+
// if the new theme doesn't support the prevColorScheme, we must resort to the auto
|
|
58
|
+
let usePrevColorScheme = !!theme[prevColorScheme];
|
|
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 : null, 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
|
+
// select only the props with values so undefined props don't overwrite prevContext values
|
|
62
|
+
let currentProps = {
|
|
63
|
+
version: $dyW1v$packagemodulejs.version,
|
|
64
|
+
theme: theme,
|
|
65
|
+
breakpoints: breakpoints,
|
|
66
|
+
colorScheme: colorScheme,
|
|
67
|
+
scale: scale,
|
|
68
|
+
isQuiet: isQuiet,
|
|
69
|
+
isEmphasized: isEmphasized,
|
|
70
|
+
isDisabled: isDisabled,
|
|
71
|
+
isRequired: isRequired,
|
|
72
|
+
isReadOnly: isReadOnly,
|
|
73
|
+
validationState: validationState
|
|
74
|
+
};
|
|
75
|
+
let matchedBreakpoints = (0, $dyW1v$useMatchedBreakpoints)(breakpoints);
|
|
76
|
+
let filteredProps = {};
|
|
77
|
+
Object.entries(currentProps).forEach(([key, value])=>value !== undefined && (filteredProps[key] = value));
|
|
78
|
+
// Merge options with parent provider
|
|
79
|
+
let context = Object.assign({}, prevContext, filteredProps);
|
|
80
|
+
// Only wrap in a DOM node if the theme, colorScheme, or scale changed
|
|
81
|
+
let contents = children;
|
|
82
|
+
let domProps = (0, $dyW1v$filterDOMProps)(otherProps);
|
|
83
|
+
let { styleProps: styleProps } = (0, $dyW1v$useStyleProps)(otherProps, undefined, {
|
|
84
|
+
matchedBreakpoints: matchedBreakpoints
|
|
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, {
|
|
87
|
+
...props,
|
|
88
|
+
UNSAFE_style: {
|
|
89
|
+
isolation: !prevContext ? "isolate" : undefined,
|
|
90
|
+
...styleProps.style
|
|
91
|
+
},
|
|
92
|
+
ref: ref
|
|
93
|
+
}, contents);
|
|
94
|
+
if (router) contents = /*#__PURE__*/ (0, $dyW1v$react).createElement((0, $dyW1v$RouterProvider), router, contents);
|
|
95
|
+
return /*#__PURE__*/ (0, $dyW1v$react).createElement((0, $a8430f637b4ccbce$export$841858b892ce1f4c).Provider, {
|
|
96
|
+
value: context
|
|
97
|
+
}, /*#__PURE__*/ (0, $dyW1v$react).createElement((0, $dyW1v$I18nProvider), {
|
|
98
|
+
locale: locale
|
|
99
|
+
}, /*#__PURE__*/ (0, $dyW1v$react).createElement((0, $dyW1v$BreakpointProvider), {
|
|
100
|
+
matchedBreakpoints: matchedBreakpoints
|
|
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);
|
|
108
|
+
const $7167f8da3cce35e4$var$ProviderWrapper = /*#__PURE__*/ (0, $dyW1v$react).forwardRef(function ProviderWrapper(props, ref) {
|
|
109
|
+
let { children: children, ...otherProps } = props;
|
|
110
|
+
let { locale: locale, direction: direction } = (0, $dyW1v$useLocale)();
|
|
111
|
+
let { theme: theme, colorScheme: colorScheme, scale: scale } = $7167f8da3cce35e4$export$693cdb10cec23617();
|
|
112
|
+
let { modalProviderProps: modalProviderProps } = (0, $dyW1v$useModalProvider)();
|
|
113
|
+
let { styleProps: styleProps } = (0, $dyW1v$useStyleProps)(otherProps);
|
|
114
|
+
let domRef = (0, $dyW1v$useDOMRef)(ref);
|
|
115
|
+
let themeKey = Object.keys(theme[colorScheme])[0];
|
|
116
|
+
let scaleKey = Object.keys(theme[scale])[0];
|
|
117
|
+
let className = (0, $dyW1v$clsx)(styleProps.className, (0, ($parcel$interopDefault($dyW1v$page_vars_cssmodulejs)))["spectrum"], (0, ($parcel$interopDefault($dyW1v$typography_index_cssmodulejs)))["spectrum"], Object.values(theme[colorScheme]), Object.values(theme[scale]), theme.global ? Object.values(theme.global) : null, {
|
|
118
|
+
"react-spectrum-provider": (0, $dyW1v$shouldKeepSpectrumClassNames),
|
|
119
|
+
spectrum: (0, $dyW1v$shouldKeepSpectrumClassNames),
|
|
120
|
+
[themeKey]: (0, $dyW1v$shouldKeepSpectrumClassNames),
|
|
121
|
+
[scaleKey]: (0, $dyW1v$shouldKeepSpectrumClassNames)
|
|
122
|
+
});
|
|
123
|
+
var _props_colorScheme, _ref;
|
|
124
|
+
let style = {
|
|
125
|
+
...styleProps.style,
|
|
126
|
+
// This ensures that browser native UI like scrollbars are rendered in the right color scheme.
|
|
127
|
+
// See https://web.dev/color-scheme/.
|
|
128
|
+
colorScheme: (_ref = (_props_colorScheme = props.colorScheme) !== null && _props_colorScheme !== void 0 ? _props_colorScheme : colorScheme) !== null && _ref !== void 0 ? _ref : Object.keys(theme).filter((k)=>k === "light" || k === "dark").join(" ")
|
|
129
|
+
};
|
|
130
|
+
let hasWarned = (0, $dyW1v$useRef)(false);
|
|
131
|
+
(0, $dyW1v$useEffect)(()=>{
|
|
132
|
+
if (direction && domRef.current) {
|
|
133
|
+
let closestDir = domRef.current.parentElement.closest("[dir]");
|
|
134
|
+
let dir = closestDir && closestDir.getAttribute("dir");
|
|
135
|
+
if (dir && dir !== direction && !hasWarned.current) {
|
|
136
|
+
console.warn(`Language directions cannot be nested. ${direction} inside ${dir}.`);
|
|
137
|
+
hasWarned.current = true;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}, [
|
|
141
|
+
direction,
|
|
142
|
+
domRef,
|
|
143
|
+
hasWarned
|
|
144
|
+
]);
|
|
145
|
+
return /*#__PURE__*/ (0, $dyW1v$react).createElement("div", {
|
|
146
|
+
...(0, $dyW1v$filterDOMProps)(otherProps),
|
|
147
|
+
...styleProps,
|
|
148
|
+
...modalProviderProps,
|
|
149
|
+
className: className,
|
|
150
|
+
style: style,
|
|
151
|
+
lang: locale,
|
|
152
|
+
dir: direction,
|
|
153
|
+
ref: domRef
|
|
154
|
+
}, children);
|
|
155
|
+
});
|
|
156
|
+
function $7167f8da3cce35e4$export$693cdb10cec23617() {
|
|
157
|
+
return (0, $dyW1v$useContext)((0, $a8430f637b4ccbce$export$841858b892ce1f4c));
|
|
158
|
+
}
|
|
159
|
+
function $7167f8da3cce35e4$export$521c373ccc32c300(props) {
|
|
160
|
+
let context = $7167f8da3cce35e4$export$693cdb10cec23617();
|
|
161
|
+
if (!context) return props;
|
|
162
|
+
return Object.assign({}, {
|
|
163
|
+
isQuiet: context.isQuiet,
|
|
164
|
+
isEmphasized: context.isEmphasized,
|
|
165
|
+
isDisabled: context.isDisabled,
|
|
166
|
+
isRequired: context.isRequired,
|
|
167
|
+
isReadOnly: context.isReadOnly,
|
|
168
|
+
validationState: context.validationState
|
|
169
|
+
}, props);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
export {$7167f8da3cce35e4$export$693cdb10cec23617 as useProvider, $7167f8da3cce35e4$export$2881499e37b75b9a as Provider, $7167f8da3cce35e4$export$521c373ccc32c300 as useProviderProps};
|
|
174
|
+
//# sourceMappingURL=Provider.mjs.map
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import {Context as $a8430f637b4ccbce$export$841858b892ce1f4c} from "./context.module.js";
|
|
2
|
+
import "./vars.3c44f451.css";
|
|
3
|
+
import $dyW1v$page_vars_cssmodulejs from "./page_vars_css.module.js";
|
|
4
|
+
import "./typography.eea3ebfe.css";
|
|
5
|
+
import $dyW1v$typography_index_cssmodulejs from "./typography_index_css.module.js";
|
|
6
|
+
import {useColorScheme as $d8453c5ae7fac713$export$6343629ee1b29116, useScale as $d8453c5ae7fac713$export$a8d2043b2d807f4d} from "./mediaQueries.module.js";
|
|
7
|
+
import $dyW1v$packagemodulejs from "./package.module.js";
|
|
8
|
+
import {useMatchedBreakpoints as $dyW1v$useMatchedBreakpoints, useStyleProps as $dyW1v$useStyleProps, BreakpointProvider as $dyW1v$BreakpointProvider, useDOMRef as $dyW1v$useDOMRef, shouldKeepSpectrumClassNames as $dyW1v$shouldKeepSpectrumClassNames} from "@react-spectrum/utils";
|
|
9
|
+
import $dyW1v$clsx from "clsx";
|
|
10
|
+
import {filterDOMProps as $dyW1v$filterDOMProps, RouterProvider as $dyW1v$RouterProvider} from "@react-aria/utils";
|
|
11
|
+
import {useLocale as $dyW1v$useLocale, I18nProvider as $dyW1v$I18nProvider} from "@react-aria/i18n";
|
|
12
|
+
import {ModalProvider as $dyW1v$ModalProvider, useModalProvider as $dyW1v$useModalProvider} from "@react-aria/overlays";
|
|
13
|
+
import $dyW1v$react, {useRef as $dyW1v$useRef, useEffect as $dyW1v$useEffect, useContext as $dyW1v$useContext} from "react";
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
function $parcel$interopDefault(a) {
|
|
17
|
+
return a && a.__esModule ? a.default : a;
|
|
18
|
+
}
|
|
19
|
+
/*
|
|
20
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
21
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
22
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
23
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
24
|
+
*
|
|
25
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
26
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
27
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
28
|
+
* governing permissions and limitations under the License.
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
const $7167f8da3cce35e4$var$DEFAULT_BREAKPOINTS = {
|
|
41
|
+
S: 640,
|
|
42
|
+
M: 768,
|
|
43
|
+
L: 1024,
|
|
44
|
+
XL: 1280,
|
|
45
|
+
XXL: 1536
|
|
46
|
+
};
|
|
47
|
+
function $7167f8da3cce35e4$var$Provider(props, ref) {
|
|
48
|
+
let prevContext = $7167f8da3cce35e4$export$693cdb10cec23617();
|
|
49
|
+
let prevColorScheme = prevContext && prevContext.colorScheme;
|
|
50
|
+
let prevBreakpoints = prevContext && prevContext.breakpoints;
|
|
51
|
+
let { theme: theme = prevContext && prevContext.theme, defaultColorScheme: defaultColorScheme } = props;
|
|
52
|
+
if (!theme) throw new Error("theme not found, the parent provider must have a theme provided");
|
|
53
|
+
// Hooks must always be called.
|
|
54
|
+
let autoColorScheme = (0, $d8453c5ae7fac713$export$6343629ee1b29116)(theme, defaultColorScheme);
|
|
55
|
+
let autoScale = (0, $d8453c5ae7fac713$export$a8d2043b2d807f4d)(theme);
|
|
56
|
+
let { locale: prevLocale } = (0, $dyW1v$useLocale)();
|
|
57
|
+
// if the new theme doesn't support the prevColorScheme, we must resort to the auto
|
|
58
|
+
let usePrevColorScheme = !!theme[prevColorScheme];
|
|
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 : null, 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
|
+
// select only the props with values so undefined props don't overwrite prevContext values
|
|
62
|
+
let currentProps = {
|
|
63
|
+
version: $dyW1v$packagemodulejs.version,
|
|
64
|
+
theme: theme,
|
|
65
|
+
breakpoints: breakpoints,
|
|
66
|
+
colorScheme: colorScheme,
|
|
67
|
+
scale: scale,
|
|
68
|
+
isQuiet: isQuiet,
|
|
69
|
+
isEmphasized: isEmphasized,
|
|
70
|
+
isDisabled: isDisabled,
|
|
71
|
+
isRequired: isRequired,
|
|
72
|
+
isReadOnly: isReadOnly,
|
|
73
|
+
validationState: validationState
|
|
74
|
+
};
|
|
75
|
+
let matchedBreakpoints = (0, $dyW1v$useMatchedBreakpoints)(breakpoints);
|
|
76
|
+
let filteredProps = {};
|
|
77
|
+
Object.entries(currentProps).forEach(([key, value])=>value !== undefined && (filteredProps[key] = value));
|
|
78
|
+
// Merge options with parent provider
|
|
79
|
+
let context = Object.assign({}, prevContext, filteredProps);
|
|
80
|
+
// Only wrap in a DOM node if the theme, colorScheme, or scale changed
|
|
81
|
+
let contents = children;
|
|
82
|
+
let domProps = (0, $dyW1v$filterDOMProps)(otherProps);
|
|
83
|
+
let { styleProps: styleProps } = (0, $dyW1v$useStyleProps)(otherProps, undefined, {
|
|
84
|
+
matchedBreakpoints: matchedBreakpoints
|
|
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, {
|
|
87
|
+
...props,
|
|
88
|
+
UNSAFE_style: {
|
|
89
|
+
isolation: !prevContext ? "isolate" : undefined,
|
|
90
|
+
...styleProps.style
|
|
91
|
+
},
|
|
92
|
+
ref: ref
|
|
93
|
+
}, contents);
|
|
94
|
+
if (router) contents = /*#__PURE__*/ (0, $dyW1v$react).createElement((0, $dyW1v$RouterProvider), router, contents);
|
|
95
|
+
return /*#__PURE__*/ (0, $dyW1v$react).createElement((0, $a8430f637b4ccbce$export$841858b892ce1f4c).Provider, {
|
|
96
|
+
value: context
|
|
97
|
+
}, /*#__PURE__*/ (0, $dyW1v$react).createElement((0, $dyW1v$I18nProvider), {
|
|
98
|
+
locale: locale
|
|
99
|
+
}, /*#__PURE__*/ (0, $dyW1v$react).createElement((0, $dyW1v$BreakpointProvider), {
|
|
100
|
+
matchedBreakpoints: matchedBreakpoints
|
|
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);
|
|
108
|
+
const $7167f8da3cce35e4$var$ProviderWrapper = /*#__PURE__*/ (0, $dyW1v$react).forwardRef(function ProviderWrapper(props, ref) {
|
|
109
|
+
let { children: children, ...otherProps } = props;
|
|
110
|
+
let { locale: locale, direction: direction } = (0, $dyW1v$useLocale)();
|
|
111
|
+
let { theme: theme, colorScheme: colorScheme, scale: scale } = $7167f8da3cce35e4$export$693cdb10cec23617();
|
|
112
|
+
let { modalProviderProps: modalProviderProps } = (0, $dyW1v$useModalProvider)();
|
|
113
|
+
let { styleProps: styleProps } = (0, $dyW1v$useStyleProps)(otherProps);
|
|
114
|
+
let domRef = (0, $dyW1v$useDOMRef)(ref);
|
|
115
|
+
let themeKey = Object.keys(theme[colorScheme])[0];
|
|
116
|
+
let scaleKey = Object.keys(theme[scale])[0];
|
|
117
|
+
let className = (0, $dyW1v$clsx)(styleProps.className, (0, ($parcel$interopDefault($dyW1v$page_vars_cssmodulejs)))["spectrum"], (0, ($parcel$interopDefault($dyW1v$typography_index_cssmodulejs)))["spectrum"], Object.values(theme[colorScheme]), Object.values(theme[scale]), theme.global ? Object.values(theme.global) : null, {
|
|
118
|
+
"react-spectrum-provider": (0, $dyW1v$shouldKeepSpectrumClassNames),
|
|
119
|
+
spectrum: (0, $dyW1v$shouldKeepSpectrumClassNames),
|
|
120
|
+
[themeKey]: (0, $dyW1v$shouldKeepSpectrumClassNames),
|
|
121
|
+
[scaleKey]: (0, $dyW1v$shouldKeepSpectrumClassNames)
|
|
122
|
+
});
|
|
123
|
+
var _props_colorScheme, _ref;
|
|
124
|
+
let style = {
|
|
125
|
+
...styleProps.style,
|
|
126
|
+
// This ensures that browser native UI like scrollbars are rendered in the right color scheme.
|
|
127
|
+
// See https://web.dev/color-scheme/.
|
|
128
|
+
colorScheme: (_ref = (_props_colorScheme = props.colorScheme) !== null && _props_colorScheme !== void 0 ? _props_colorScheme : colorScheme) !== null && _ref !== void 0 ? _ref : Object.keys(theme).filter((k)=>k === "light" || k === "dark").join(" ")
|
|
129
|
+
};
|
|
130
|
+
let hasWarned = (0, $dyW1v$useRef)(false);
|
|
131
|
+
(0, $dyW1v$useEffect)(()=>{
|
|
132
|
+
if (direction && domRef.current) {
|
|
133
|
+
let closestDir = domRef.current.parentElement.closest("[dir]");
|
|
134
|
+
let dir = closestDir && closestDir.getAttribute("dir");
|
|
135
|
+
if (dir && dir !== direction && !hasWarned.current) {
|
|
136
|
+
console.warn(`Language directions cannot be nested. ${direction} inside ${dir}.`);
|
|
137
|
+
hasWarned.current = true;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}, [
|
|
141
|
+
direction,
|
|
142
|
+
domRef,
|
|
143
|
+
hasWarned
|
|
144
|
+
]);
|
|
145
|
+
return /*#__PURE__*/ (0, $dyW1v$react).createElement("div", {
|
|
146
|
+
...(0, $dyW1v$filterDOMProps)(otherProps),
|
|
147
|
+
...styleProps,
|
|
148
|
+
...modalProviderProps,
|
|
149
|
+
className: className,
|
|
150
|
+
style: style,
|
|
151
|
+
lang: locale,
|
|
152
|
+
dir: direction,
|
|
153
|
+
ref: domRef
|
|
154
|
+
}, children);
|
|
155
|
+
});
|
|
156
|
+
function $7167f8da3cce35e4$export$693cdb10cec23617() {
|
|
157
|
+
return (0, $dyW1v$useContext)((0, $a8430f637b4ccbce$export$841858b892ce1f4c));
|
|
158
|
+
}
|
|
159
|
+
function $7167f8da3cce35e4$export$521c373ccc32c300(props) {
|
|
160
|
+
let context = $7167f8da3cce35e4$export$693cdb10cec23617();
|
|
161
|
+
if (!context) return props;
|
|
162
|
+
return Object.assign({}, {
|
|
163
|
+
isQuiet: context.isQuiet,
|
|
164
|
+
isEmphasized: context.isEmphasized,
|
|
165
|
+
isDisabled: context.isDisabled,
|
|
166
|
+
isRequired: context.isRequired,
|
|
167
|
+
isReadOnly: context.isReadOnly,
|
|
168
|
+
validationState: context.validationState
|
|
169
|
+
}, props);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
export {$7167f8da3cce35e4$export$693cdb10cec23617 as useProvider, $7167f8da3cce35e4$export$2881499e37b75b9a as Provider, $7167f8da3cce35e4$export$521c373ccc32c300 as useProviderProps};
|
|
174
|
+
//# sourceMappingURL=Provider.module.js.map
|
|
@@ -0,0 +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,yCAAa,EAAE,OAAO;IAC5C,IAAI,YAAY,CAAA,GAAA,yCAAO,EAAE;IACzB,IAAI,EAAC,QAAQ,UAAU,EAAC,GAAG,CAAA,GAAA,gBAAQ;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,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oC,OAAO,IAAI,CAAC,OAAO,MAAM,CAAC,CAAA,IAAK,MAAM,WAAW,MAAM,QAAQ,IAAI,CAAC;IACtH;IAEA,IAAI,YAAY,CAAA,GAAA,aAAK,EAAE;IACvB,CAAA,GAAA,gBAAQ,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,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"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
var $3n4Xf$react = require("react");
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
function $parcel$interopDefault(a) {
|
|
5
|
+
return a && a.__esModule ? a.default : a;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
function $parcel$export(e, n, v, s) {
|
|
9
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
$parcel$export(module.exports, "Context", () => $a5b4f4e252b5a021$export$841858b892ce1f4c);
|
|
13
|
+
/*
|
|
14
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
15
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
16
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
17
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
18
|
+
*
|
|
19
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
20
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
21
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
22
|
+
* governing permissions and limitations under the License.
|
|
23
|
+
*/
|
|
24
|
+
const $a5b4f4e252b5a021$export$841858b892ce1f4c = (0, ($parcel$interopDefault($3n4Xf$react))).createContext(null);
|
|
25
|
+
$a5b4f4e252b5a021$export$841858b892ce1f4c.displayName = "ProviderContext";
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
//# sourceMappingURL=context.main.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;AAOM,MAAM,4CAAU,CAAA,GAAA,sCAAI,EAAE,aAAa,CAAyB;AACnE,0CAAQ,WAAW,GAAG","sources":["packages/@react-spectrum/provider/src/context.ts"],"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 {ProviderContext} from '@react-types/provider';\nimport React from 'react';\n\n// Context is placed in a separate file to avoid fast refresh issue where the old provider context values\n// are immediately replaced with the null default. Stopgap solution until we fix this in parcel.\nexport const Context = React.createContext<ProviderContext | null>(null);\nContext.displayName = 'ProviderContext';\n"],"names":[],"version":3,"file":"context.main.js.map"}
|
package/dist/context.mjs
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import $hscZN$react from "react";
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
5
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
7
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
*
|
|
9
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
10
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
11
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
12
|
+
* governing permissions and limitations under the License.
|
|
13
|
+
*/
|
|
14
|
+
const $a8430f637b4ccbce$export$841858b892ce1f4c = (0, $hscZN$react).createContext(null);
|
|
15
|
+
$a8430f637b4ccbce$export$841858b892ce1f4c.displayName = "ProviderContext";
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
export {$a8430f637b4ccbce$export$841858b892ce1f4c as Context};
|
|
19
|
+
//# sourceMappingURL=context.mjs.map
|