@react-spectrum/provider 3.10.14 → 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
@@ -1,60 +0,0 @@
1
- /*
2
- * Copyright 2020 Adobe. All rights reserved.
3
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
- * you may not use this file except in compliance with the License. You may obtain a copy
5
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
- *
7
- * Unless required by applicable law or agreed to in writing, software distributed under
8
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
- * OF ANY KIND, either express or implied. See the License for the specific language
10
- * governing permissions and limitations under the License.
11
- */
12
-
13
- import {ColorScheme, Scale, Theme} from '@react-types/provider';
14
- import {useMediaQuery} from '@react-spectrum/utils';
15
-
16
- export function useColorScheme(theme: Theme, defaultColorScheme: ColorScheme): ColorScheme {
17
- let matchesDark = useMediaQuery('(prefers-color-scheme: dark)');
18
- let matchesLight = useMediaQuery('(prefers-color-scheme: light)');
19
-
20
- // importance OS > default > omitted
21
-
22
- if (theme.dark && matchesDark) {
23
- return 'dark';
24
- }
25
-
26
- if (theme.light && matchesLight) {
27
- return 'light';
28
- }
29
-
30
- if (theme.dark && defaultColorScheme === 'dark') {
31
- return 'dark';
32
- }
33
-
34
- if (theme.light && defaultColorScheme === 'light') {
35
- return 'light';
36
- }
37
-
38
- if (!theme.dark) {
39
- return 'light';
40
- }
41
-
42
- if (!theme.light) {
43
- return 'dark';
44
- }
45
-
46
- return 'light';
47
- }
48
-
49
- export function useScale(theme: Theme): Scale {
50
- let matchesFine = useMediaQuery('(any-pointer: fine)');
51
- if (matchesFine && theme.medium) {
52
- return 'medium';
53
- }
54
-
55
- if (theme.large) {
56
- return 'large';
57
- }
58
-
59
- return 'medium';
60
- }