@react-spectrum/provider 3.10.13 → 3.11.0

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.
Files changed (47) hide show
  1. package/dist/import.mjs +4 -2
  2. package/dist/main.js +6 -4
  3. package/dist/main.js.map +1 -1
  4. package/dist/module.js +4 -2
  5. package/dist/module.js.map +1 -1
  6. package/dist/types/src/index.d.ts +3 -0
  7. package/package.json +13 -31
  8. package/src/index.ts +4 -3
  9. package/dist/Provider.main.js +0 -179
  10. package/dist/Provider.main.js.map +0 -1
  11. package/dist/Provider.mjs +0 -172
  12. package/dist/Provider.module.js +0 -172
  13. package/dist/Provider.module.js.map +0 -1
  14. package/dist/context.main.js +0 -28
  15. package/dist/context.main.js.map +0 -1
  16. package/dist/context.mjs +0 -19
  17. package/dist/context.module.js +0 -19
  18. package/dist/context.module.js.map +0 -1
  19. package/dist/mediaQueries.main.js +0 -41
  20. package/dist/mediaQueries.main.js.map +0 -1
  21. package/dist/mediaQueries.mjs +0 -35
  22. package/dist/mediaQueries.module.js +0 -35
  23. package/dist/mediaQueries.module.js.map +0 -1
  24. package/dist/package.main.js +0 -4
  25. package/dist/package.main.js.map +0 -1
  26. package/dist/package.mjs +0 -6
  27. package/dist/package.module.js +0 -6
  28. package/dist/package.module.js.map +0 -1
  29. package/dist/page_vars_css.main.js +0 -26
  30. package/dist/page_vars_css.main.js.map +0 -1
  31. package/dist/page_vars_css.mjs +0 -28
  32. package/dist/page_vars_css.module.js +0 -28
  33. package/dist/page_vars_css.module.js.map +0 -1
  34. package/dist/provider.bd9c6608.css +0 -85
  35. package/dist/provider.bd9c6608.css.map +0 -1
  36. package/dist/provider.c642b855.css +0 -96
  37. package/dist/provider.c642b855.css.map +0 -1
  38. package/dist/types.d.ts +0 -19
  39. package/dist/types.d.ts.map +0 -1
  40. package/dist/typography_index_css.main.js +0 -32
  41. package/dist/typography_index_css.main.js.map +0 -1
  42. package/dist/typography_index_css.mjs +0 -34
  43. package/dist/typography_index_css.module.js +0 -34
  44. package/dist/typography_index_css.module.js.map +0 -1
  45. package/src/Provider.tsx +0 -219
  46. package/src/context.ts +0 -19
  47. package/src/mediaQueries.ts +0 -60
package/dist/import.mjs CHANGED
@@ -1,4 +1,5 @@
1
- import {Provider as $7167f8da3cce35e4$export$2881499e37b75b9a, useProvider as $7167f8da3cce35e4$export$693cdb10cec23617, useProviderProps as $7167f8da3cce35e4$export$521c373ccc32c300} from "./Provider.mjs";
1
+ import {Provider as $b505528386d8498b$re_export$Provider, useProvider as $b505528386d8498b$re_export$useProvider} from "@adobe/react-spectrum/Provider";
2
+ import {useProviderProps as $b505528386d8498b$re_export$useProviderProps} from "@adobe/react-spectrum/private/provider/Provider";
2
3
 
3
4
  /*
4
5
  * Copyright 2020 Adobe. All rights reserved.
@@ -14,5 +15,6 @@ import {Provider as $7167f8da3cce35e4$export$2881499e37b75b9a, useProvider as $7
14
15
 
15
16
 
16
17
 
17
- export {$7167f8da3cce35e4$export$2881499e37b75b9a as Provider, $7167f8da3cce35e4$export$693cdb10cec23617 as useProvider, $7167f8da3cce35e4$export$521c373ccc32c300 as useProviderProps};
18
+
19
+ export {$b505528386d8498b$re_export$Provider as Provider, $b505528386d8498b$re_export$useProvider as useProvider, $b505528386d8498b$re_export$useProviderProps as useProviderProps};
18
20
  //# sourceMappingURL=module.js.map
package/dist/main.js CHANGED
@@ -1,13 +1,14 @@
1
- var $96cabdf5b0aed55b$exports = require("./Provider.main.js");
1
+ var $dt9kt$adobereactspectrumProvider = require("@adobe/react-spectrum/Provider");
2
+ var $dt9kt$adobereactspectrumprivateproviderProvider = require("@adobe/react-spectrum/private/provider/Provider");
2
3
 
3
4
 
4
5
  function $parcel$export(e, n, v, s) {
5
6
  Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
6
7
  }
7
8
 
8
- $parcel$export(module.exports, "Provider", () => $96cabdf5b0aed55b$exports.Provider);
9
- $parcel$export(module.exports, "useProvider", () => $96cabdf5b0aed55b$exports.useProvider);
10
- $parcel$export(module.exports, "useProviderProps", () => $96cabdf5b0aed55b$exports.useProviderProps);
9
+ $parcel$export(module.exports, "Provider", function () { return $dt9kt$adobereactspectrumProvider.Provider; });
10
+ $parcel$export(module.exports, "useProvider", function () { return $dt9kt$adobereactspectrumProvider.useProvider; });
11
+ $parcel$export(module.exports, "useProviderProps", function () { return $dt9kt$adobereactspectrumprivateproviderProvider.useProviderProps; });
11
12
  /*
12
13
  * Copyright 2020 Adobe. All rights reserved.
13
14
  * This file is licensed to you under the Apache License, Version 2.0 (the "License");
@@ -22,4 +23,5 @@ $parcel$export(module.exports, "useProviderProps", () => $96cabdf5b0aed55b$expor
22
23
 
23
24
 
24
25
 
26
+
25
27
  //# sourceMappingURL=main.js.map
package/dist/main.js.map CHANGED
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC,GAED,0CAA0C","sources":["packages/@react-spectrum/provider/src/index.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\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":"main.js.map"}
1
+ {"mappings":";;;;;;;;;;;AAAA;;;;;;;;;;CAUC,GAED,0CAA0C","sources":["packages/@react-spectrum/provider/src/index.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\n/// <reference types=\"css-module-types\" />\n\nexport {Provider, useProvider} from '@adobe/react-spectrum/Provider';\n\nexport {useProviderProps} from '@adobe/react-spectrum/private/provider/Provider';\nexport type {ProviderContext, ProviderProps, ColorScheme, Scale, Theme, Breakpoints, CSSModule} from '@adobe/react-spectrum/Provider';\n"],"names":[],"version":3,"file":"main.js.map"}
package/dist/module.js CHANGED
@@ -1,4 +1,5 @@
1
- import {Provider as $7167f8da3cce35e4$export$2881499e37b75b9a, useProvider as $7167f8da3cce35e4$export$693cdb10cec23617, useProviderProps as $7167f8da3cce35e4$export$521c373ccc32c300} from "./Provider.module.js";
1
+ import {Provider as $b505528386d8498b$re_export$Provider, useProvider as $b505528386d8498b$re_export$useProvider} from "@adobe/react-spectrum/Provider";
2
+ import {useProviderProps as $b505528386d8498b$re_export$useProviderProps} from "@adobe/react-spectrum/private/provider/Provider";
2
3
 
3
4
  /*
4
5
  * Copyright 2020 Adobe. All rights reserved.
@@ -14,5 +15,6 @@ import {Provider as $7167f8da3cce35e4$export$2881499e37b75b9a, useProvider as $7
14
15
 
15
16
 
16
17
 
17
- export {$7167f8da3cce35e4$export$2881499e37b75b9a as Provider, $7167f8da3cce35e4$export$693cdb10cec23617 as useProvider, $7167f8da3cce35e4$export$521c373ccc32c300 as useProviderProps};
18
+
19
+ export {$b505528386d8498b$re_export$Provider as Provider, $b505528386d8498b$re_export$useProvider as useProvider, $b505528386d8498b$re_export$useProviderProps as useProviderProps};
18
20
  //# sourceMappingURL=module.js.map
@@ -1 +1 @@
1
- {"mappings":";;AAAA;;;;;;;;;;CAUC,GAED,0CAA0C","sources":["packages/@react-spectrum/provider/src/index.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\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":"module.js.map"}
1
+ {"mappings":";;;AAAA;;;;;;;;;;CAUC,GAED,0CAA0C","sources":["packages/@react-spectrum/provider/src/index.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\n/// <reference types=\"css-module-types\" />\n\nexport {Provider, useProvider} from '@adobe/react-spectrum/Provider';\n\nexport {useProviderProps} from '@adobe/react-spectrum/private/provider/Provider';\nexport type {ProviderContext, ProviderProps, ColorScheme, Scale, Theme, Breakpoints, CSSModule} from '@adobe/react-spectrum/Provider';\n"],"names":[],"version":3,"file":"module.js.map"}
@@ -0,0 +1,3 @@
1
+ export { Provider, useProvider } from '@adobe/react-spectrum/Provider';
2
+ export { useProviderProps } from '@adobe/react-spectrum/private/provider/Provider';
3
+ export type { ProviderContext, ProviderProps, ColorScheme, Scale, Theme, Breakpoints, CSSModule } from '@adobe/react-spectrum/Provider';
package/package.json CHANGED
@@ -1,20 +1,20 @@
1
1
  {
2
2
  "name": "@react-spectrum/provider",
3
- "version": "3.10.13",
3
+ "version": "3.11.0",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/main.js",
7
7
  "module": "dist/module.js",
8
8
  "exports": {
9
- "source": "./src/index.ts",
10
- "types": [
11
- "./dist/types.d.ts",
12
- "./src/index.ts"
13
- ],
14
- "import": "./dist/import.mjs",
15
- "require": "./dist/main.js"
9
+ ".": {
10
+ "source": "./src/index.ts",
11
+ "types": "./dist/types/src/index.d.ts",
12
+ "import": "./dist/import.mjs",
13
+ "require": "./dist/main.js"
14
+ },
15
+ "./package.json": "./package.json"
16
16
  },
17
- "types": "dist/types.d.ts",
17
+ "types": "dist/types/src/index.d.ts",
18
18
  "source": "src/index.ts",
19
19
  "files": [
20
20
  "dist",
@@ -24,33 +24,15 @@
24
24
  "*.css"
25
25
  ],
26
26
  "targets": {
27
- "main": {
28
- "includeNodeModules": [
29
- "@adobe/spectrum-css-temp"
30
- ]
31
- },
32
- "module": {
33
- "includeNodeModules": [
34
- "@adobe/spectrum-css-temp"
35
- ]
36
- }
27
+ "types": false
37
28
  },
38
29
  "repository": {
39
30
  "type": "git",
40
31
  "url": "https://github.com/adobe/react-spectrum"
41
32
  },
42
33
  "dependencies": {
43
- "@react-aria/i18n": "^3.12.15",
44
- "@react-aria/overlays": "^3.31.1",
45
- "@react-aria/utils": "^3.33.0",
46
- "@react-spectrum/utils": "^3.12.11",
47
- "@react-types/provider": "^3.8.14",
48
- "@react-types/shared": "^3.33.0",
49
- "@swc/helpers": "^0.5.0",
50
- "clsx": "^2.0.0"
51
- },
52
- "devDependencies": {
53
- "@adobe/spectrum-css-temp": "3.0.0-alpha.1"
34
+ "@adobe/react-spectrum": "3.47.0",
35
+ "@swc/helpers": "^0.5.0"
54
36
  },
55
37
  "peerDependencies": {
56
38
  "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1",
@@ -59,5 +41,5 @@
59
41
  "publishConfig": {
60
42
  "access": "public"
61
43
  },
62
- "gitHead": "66e51757606b43a89ed02c574ca24517323a2ab9"
44
+ "gitHead": "a6999bdf494a2e9c0381a5881908328bdd22ddae"
63
45
  }
package/src/index.ts CHANGED
@@ -12,6 +12,7 @@
12
12
 
13
13
  /// <reference types="css-module-types" />
14
14
 
15
- export {Provider, useProvider, useProviderProps} from './Provider';
16
- export type {ProviderContext} from '@react-types/provider';
17
- export type {ProviderProps} from '@react-types/provider';
15
+ export {Provider, useProvider} from '@adobe/react-spectrum/Provider';
16
+
17
+ export {useProviderProps} from '@adobe/react-spectrum/private/provider/Provider';
18
+ export type {ProviderContext, ProviderProps, ColorScheme, Scale, Theme, Breakpoints, CSSModule} from '@adobe/react-spectrum/Provider';
@@ -1,179 +0,0 @@
1
- var $a5b4f4e252b5a021$exports = require("./context.main.js");
2
- require("./provider.bd9c6608.css");
3
- var $22365f0f5f2dcdd5$exports = require("./page_vars_css.main.js");
4
- require("./provider.c642b855.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, "Provider", () => $96cabdf5b0aed55b$export$2881499e37b75b9a);
25
- $parcel$export(module.exports, "useProvider", () => $96cabdf5b0aed55b$export$693cdb10cec23617);
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
- 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
- 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 || 'light');
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 = prevColorScheme ? !!theme[prevColorScheme] : false;
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 : 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
- // 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 || styleProps.style && 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
- const $96cabdf5b0aed55b$var$ProviderWrapper = /*#__PURE__*/ (0, ($parcel$interopDefault($dbjUM$react))).forwardRef(function ProviderWrapper(props, ref) {
112
- let { children: children, ...otherProps } = props;
113
- let { locale: locale, direction: direction } = (0, $dbjUM$reactariai18n.useLocale)();
114
- let { theme: theme, colorScheme: colorScheme, scale: scale } = $96cabdf5b0aed55b$export$693cdb10cec23617();
115
- let { modalProviderProps: modalProviderProps } = (0, $dbjUM$reactariaoverlays.useModalProvider)();
116
- let { styleProps: styleProps } = (0, $dbjUM$reactspectrumutils.useStyleProps)(otherProps);
117
- let domRef = (0, $dbjUM$reactspectrumutils.useDOMRef)(ref);
118
- let themeKey = Object.keys(theme[colorScheme])[0];
119
- let scaleKey = Object.keys(theme[scale])[0];
120
- 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, {
121
- 'react-spectrum-provider': (0, $dbjUM$reactspectrumutils.shouldKeepSpectrumClassNames),
122
- spectrum: (0, $dbjUM$reactspectrumutils.shouldKeepSpectrumClassNames),
123
- [themeKey]: (0, $dbjUM$reactspectrumutils.shouldKeepSpectrumClassNames),
124
- [scaleKey]: (0, $dbjUM$reactspectrumutils.shouldKeepSpectrumClassNames)
125
- });
126
- var _props_colorScheme, _ref;
127
- let style = {
128
- ...styleProps.style,
129
- // This ensures that browser native UI like scrollbars are rendered in the right color scheme.
130
- // See https://web.dev/color-scheme/.
131
- 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(' ')
132
- };
133
- let hasWarned = (0, $dbjUM$react.useRef)(false);
134
- (0, $dbjUM$react.useEffect)(()=>{
135
- if (direction && domRef.current) {
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]');
138
- let dir = closestDir && closestDir.getAttribute('dir');
139
- if (dir && dir !== direction && !hasWarned.current && process.env.NODE_ENV !== 'production') {
140
- console.warn(`Language directions cannot be nested. ${direction} inside ${dir}.`);
141
- hasWarned.current = true;
142
- }
143
- }
144
- }, [
145
- direction,
146
- domRef,
147
- hasWarned
148
- ]);
149
- return /*#__PURE__*/ (0, ($parcel$interopDefault($dbjUM$react))).createElement("div", {
150
- ...(0, $dbjUM$reactariautils.filterDOMProps)(otherProps),
151
- ...styleProps,
152
- ...modalProviderProps,
153
- className: className,
154
- style: style,
155
- lang: locale,
156
- dir: direction,
157
- ref: domRef
158
- }, children);
159
- });
160
- function $96cabdf5b0aed55b$export$693cdb10cec23617() {
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;
164
- }
165
- function $96cabdf5b0aed55b$export$521c373ccc32c300(props) {
166
- let context = (0, $dbjUM$react.useContext)((0, $a5b4f4e252b5a021$exports.Context));
167
- if (!context) return props;
168
- return Object.assign({}, {
169
- isQuiet: context.isQuiet,
170
- isEmphasized: context.isEmphasized,
171
- isDisabled: context.isDisabled,
172
- isRequired: context.isRequired,
173
- isReadOnly: context.isReadOnly,
174
- validationState: context.validationState
175
- }, props);
176
- }
177
-
178
-
179
- //# sourceMappingURL=Provider.main.js.map
@@ -1 +0,0 @@
1
- {"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;AAuBD,MAAM,4CAAsB;IAAC,GAAG;IAAK,GAAG;IAAK,GAAG;IAAM,IAAI;IAAM,KAAK;AAAI;AAOlE,MAAM,0DAAW,CAAA,GAAA,sCAAI,EAAE,UAAU,CAAC,SAAS,SAAS,KAAoB,EAAE,GAA2B;IAC1G,IAAI,cAAc,CAAA,GAAA,uBAAS,EAAE,CAAA,GAAA,iCAAM;IACnC,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,sBAAsB;IAClE,IAAI,YAAY,CAAA,GAAA,kCAAO,EAAE;IACzB,IAAI,EAAC,QAAQ,UAAU,EAAC,GAAG,CAAA,GAAA,8BAAQ;IACnC,mFAAmF;IACnF,IAAI,qBAAqB,kBAAkB,CAAC,CAAC,KAAK,CAAC,gBAAgB,GAAG;IAEtE,4EAA4E;IAC5E,IAAI,eACF,cAAc,qBAAqB,kBAAkB,wBACrD,QAAQ,cAAc,YA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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 && process.env.NODE_ENV !== 'production') {\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 DELETED
@@ -1,172 +0,0 @@
1
- import {Context as $a8430f637b4ccbce$export$841858b892ce1f4c} from "./context.mjs";
2
- import "./provider.bd9c6608.css";
3
- import $dyW1v$page_vars_cssmodulejs from "./page_vars_css.mjs";
4
- import "./provider.c642b855.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, {useContext as $dyW1v$useContext, useRef as $dyW1v$useRef, useEffect as $dyW1v$useEffect} 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
- const $7167f8da3cce35e4$export$2881499e37b75b9a = /*#__PURE__*/ (0, $dyW1v$react).forwardRef(function Provider(props, ref) {
48
- let prevContext = (0, $dyW1v$useContext)((0, $a8430f637b4ccbce$export$841858b892ce1f4c));
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 || 'light');
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 = prevColorScheme ? !!theme[prevColorScheme] : false;
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 : 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
- // 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 || styleProps.style && 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
- const $7167f8da3cce35e4$var$ProviderWrapper = /*#__PURE__*/ (0, $dyW1v$react).forwardRef(function ProviderWrapper(props, ref) {
104
- let { children: children, ...otherProps } = props;
105
- let { locale: locale, direction: direction } = (0, $dyW1v$useLocale)();
106
- let { theme: theme, colorScheme: colorScheme, scale: scale } = $7167f8da3cce35e4$export$693cdb10cec23617();
107
- let { modalProviderProps: modalProviderProps } = (0, $dyW1v$useModalProvider)();
108
- let { styleProps: styleProps } = (0, $dyW1v$useStyleProps)(otherProps);
109
- let domRef = (0, $dyW1v$useDOMRef)(ref);
110
- let themeKey = Object.keys(theme[colorScheme])[0];
111
- let scaleKey = Object.keys(theme[scale])[0];
112
- 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, {
113
- 'react-spectrum-provider': (0, $dyW1v$shouldKeepSpectrumClassNames),
114
- spectrum: (0, $dyW1v$shouldKeepSpectrumClassNames),
115
- [themeKey]: (0, $dyW1v$shouldKeepSpectrumClassNames),
116
- [scaleKey]: (0, $dyW1v$shouldKeepSpectrumClassNames)
117
- });
118
- var _props_colorScheme, _ref;
119
- let style = {
120
- ...styleProps.style,
121
- // This ensures that browser native UI like scrollbars are rendered in the right color scheme.
122
- // See https://web.dev/color-scheme/.
123
- 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(' ')
124
- };
125
- let hasWarned = (0, $dyW1v$useRef)(false);
126
- (0, $dyW1v$useEffect)(()=>{
127
- if (direction && domRef.current) {
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]');
130
- let dir = closestDir && closestDir.getAttribute('dir');
131
- if (dir && dir !== direction && !hasWarned.current && process.env.NODE_ENV !== 'production') {
132
- console.warn(`Language directions cannot be nested. ${direction} inside ${dir}.`);
133
- hasWarned.current = true;
134
- }
135
- }
136
- }, [
137
- direction,
138
- domRef,
139
- hasWarned
140
- ]);
141
- return /*#__PURE__*/ (0, $dyW1v$react).createElement("div", {
142
- ...(0, $dyW1v$filterDOMProps)(otherProps),
143
- ...styleProps,
144
- ...modalProviderProps,
145
- className: className,
146
- style: style,
147
- lang: locale,
148
- dir: direction,
149
- ref: domRef
150
- }, children);
151
- });
152
- function $7167f8da3cce35e4$export$693cdb10cec23617() {
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;
156
- }
157
- function $7167f8da3cce35e4$export$521c373ccc32c300(props) {
158
- let context = (0, $dyW1v$useContext)((0, $a8430f637b4ccbce$export$841858b892ce1f4c));
159
- if (!context) return props;
160
- return Object.assign({}, {
161
- isQuiet: context.isQuiet,
162
- isEmphasized: context.isEmphasized,
163
- isDisabled: context.isDisabled,
164
- isRequired: context.isRequired,
165
- isReadOnly: context.isReadOnly,
166
- validationState: context.validationState
167
- }, props);
168
- }
169
-
170
-
171
- export {$7167f8da3cce35e4$export$2881499e37b75b9a as Provider, $7167f8da3cce35e4$export$693cdb10cec23617 as useProvider, $7167f8da3cce35e4$export$521c373ccc32c300 as useProviderProps};
172
- //# sourceMappingURL=Provider.module.js.map