@primer/react 38.1.0-rc.a72ba106c → 38.1.0-rc.d71b584fb
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/CHANGELOG.md +1 -1
- package/dist/ActionList/Item.d.ts.map +1 -1
- package/dist/ActionList/Item.js +3 -1
- package/dist/hooks/{useMediaUnsafeSSR.d.ts → useMedia.d.ts} +6 -9
- package/dist/hooks/useMedia.d.ts.map +1 -0
- package/dist/hooks/{useMediaUnsafeSSR.js → useMedia.js} +2 -2
- package/dist/hooks/useResponsiveValue.d.ts +0 -2
- package/dist/hooks/useResponsiveValue.d.ts.map +1 -1
- package/dist/hooks/useResponsiveValue.js +5 -9
- package/package.json +2 -2
- package/dist/hooks/useMediaUnsafeSSR.d.ts.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
- [#7063](https://github.com/primer/react/pull/7063) [`247c66a`](https://github.com/primer/react/commit/247c66a3c297afba73c6e9e3842cc15ff8a845c1) Thanks [@francinelucca](https://github.com/francinelucca)! - Feat: popover implement click outside
|
|
10
10
|
|
|
11
|
-
- [#
|
|
11
|
+
- [#7109](https://github.com/primer/react/pull/7109) [`34e7108`](https://github.com/primer/react/commit/34e71089ea7668d7b0ab4572f125d13b998e8754) Thanks [@adierkens](https://github.com/adierkens)! - Add support to ActionList for 'tablist' and 'tab' roles
|
|
12
12
|
|
|
13
13
|
### Patch Changes
|
|
14
14
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Item.d.ts","sourceRoot":"","sources":["../../src/ActionList/Item.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAmBzB,KAAK,sBAAsB,GAAG;IAC5B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;CAC3B,CAAA;AAED,eAAO,MAAM,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC,sBAAsB,CAEpD,CAAA;
|
|
1
|
+
{"version":3,"file":"Item.d.ts","sourceRoot":"","sources":["../../src/ActionList/Item.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAmBzB,KAAK,sBAAsB,GAAG;IAC5B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;CAC3B,CAAA;AAED,eAAO,MAAM,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC,sBAAsB,CAEpD,CAAA;AAySD,QAAA,MAAM,IAAI,IAjRa,EAAE,SAAS,KAAK,CAAC,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoRjD,CAAA;AAEF,OAAO,EAAC,IAAI,EAAC,CAAA"}
|
package/dist/ActionList/Item.js
CHANGED
|
@@ -118,6 +118,8 @@ const UnwrappedItem = ({
|
|
|
118
118
|
if (selectionVariant === 'single') inferredItemRole = 'menuitemradio';else if (selectionVariant === 'multiple') inferredItemRole = 'menuitemcheckbox';else inferredItemRole = 'menuitem';
|
|
119
119
|
} else if (listRole === 'listbox') {
|
|
120
120
|
if (selectionVariant !== undefined && !role) inferredItemRole = 'option';
|
|
121
|
+
} else if (listRole === 'tablist') {
|
|
122
|
+
inferredItemRole = 'tab';
|
|
121
123
|
}
|
|
122
124
|
const itemRole = role || inferredItemRole;
|
|
123
125
|
if (slots.trailingAction) {
|
|
@@ -129,7 +131,7 @@ const UnwrappedItem = ({
|
|
|
129
131
|
if (itemRole === 'menuitemradio' || itemRole === 'menuitemcheckbox') inferredSelectionAttribute = 'aria-checked';else if (itemRole === 'option') inferredSelectionAttribute = 'aria-selected';
|
|
130
132
|
const itemSelectionAttribute = selectionAttribute || inferredSelectionAttribute;
|
|
131
133
|
// Ensures ActionList.Item retains list item semantics if a valid ARIA role is applied, or if item is inactive
|
|
132
|
-
const listItemSemantics =
|
|
134
|
+
const listItemSemantics = itemRole === 'option' || itemRole === 'menuitem' || itemRole === 'menuitemradio' || itemRole === 'menuitemcheckbox' || itemRole === 'tab';
|
|
133
135
|
const listRoleTypes = ['listbox', 'menu', 'list'];
|
|
134
136
|
const listSemantics = listRole && listRoleTypes.includes(listRole) || inactive || listItemSemantics;
|
|
135
137
|
const buttonSemantics = !listSemantics && !_PrivateItemWrapper;
|
|
@@ -1,21 +1,18 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
/**
|
|
3
|
-
* `
|
|
3
|
+
* `useMedia` will use the given `mediaQueryString` with `matchMedia` to
|
|
4
4
|
* determine if the document matches the media query string.
|
|
5
5
|
*
|
|
6
|
-
* If `MatchMedia` is used as an ancestor, `
|
|
6
|
+
* If `MatchMedia` is used as an ancestor, `useMedia` will instead use the
|
|
7
7
|
* value of the media query string, if available
|
|
8
8
|
*
|
|
9
|
-
* Warning: If rendering on the server, and no `defaultState` is provided,
|
|
10
|
-
* this could cause a hydration mismatch between server and client.
|
|
11
|
-
*
|
|
12
9
|
* @example
|
|
13
10
|
* function Example() {
|
|
14
|
-
* const coarsePointer =
|
|
11
|
+
* const coarsePointer = useMedia('(pointer: coarse)');
|
|
15
12
|
* // ...
|
|
16
13
|
* }
|
|
17
14
|
*/
|
|
18
|
-
export declare function
|
|
15
|
+
export declare function useMedia(mediaQueryString: string, defaultState?: boolean): boolean;
|
|
19
16
|
type MediaQueryFeatures = {
|
|
20
17
|
[key: string]: boolean | undefined;
|
|
21
18
|
};
|
|
@@ -25,7 +22,7 @@ type MatchMediaProps = {
|
|
|
25
22
|
};
|
|
26
23
|
/**
|
|
27
24
|
* Use `MatchMedia` to emulate media conditions by passing in feature
|
|
28
|
-
* queries to the `features` prop. If a component uses `
|
|
25
|
+
* queries to the `features` prop. If a component uses `useMedia` with the
|
|
29
26
|
* feature passed in to `MatchMedia` it will force its value to match what is
|
|
30
27
|
* provided to `MatchMedia`
|
|
31
28
|
*
|
|
@@ -39,4 +36,4 @@ type MatchMediaProps = {
|
|
|
39
36
|
*/
|
|
40
37
|
export declare function MatchMedia({ children, features }: MatchMediaProps): React.JSX.Element;
|
|
41
38
|
export {};
|
|
42
|
-
//# sourceMappingURL=
|
|
39
|
+
//# sourceMappingURL=useMedia.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useMedia.d.ts","sourceRoot":"","sources":["../../src/hooks/useMedia.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAuD,MAAM,OAAO,CAAA;AAI3E;;;;;;;;;;;;GAYG;AACH,wBAAgB,QAAQ,CAAC,gBAAgB,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,OAAO,WAoExE;AAED,KAAK,kBAAkB,GAAG;IACxB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAAA;CACnC,CAAA;AAOD,KAAK,eAAe,GAAG;IACrB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,QAAQ,CAAC,EAAE,kBAAkB,CAAA;CAC9B,CAAA;AAID;;;;;;;;;;;;;GAaG;AACH,wBAAgB,UAAU,CAAC,EAAC,QAAQ,EAAE,QAA0B,EAAC,EAAE,eAAe,qBAGjF"}
|
|
@@ -2,7 +2,7 @@ import { c } from 'react-compiler-runtime';
|
|
|
2
2
|
import React, { useContext, createContext, useEffect } from 'react';
|
|
3
3
|
import 'react/jsx-runtime';
|
|
4
4
|
|
|
5
|
-
function
|
|
5
|
+
function useMedia(mediaQueryString, defaultState) {
|
|
6
6
|
const $ = c(12);
|
|
7
7
|
const features = useContext(MatchMediaContext);
|
|
8
8
|
let t0;
|
|
@@ -83,4 +83,4 @@ function useMediaUnsafeSSR(mediaQueryString, defaultState) {
|
|
|
83
83
|
// unavailable through devtools
|
|
84
84
|
const MatchMediaContext = /*#__PURE__*/createContext({});
|
|
85
85
|
|
|
86
|
-
export {
|
|
86
|
+
export { useMedia };
|
|
@@ -23,8 +23,6 @@ export declare function isResponsiveValue(value: any): value is ResponsiveValue<
|
|
|
23
23
|
* Resolves responsive values based on the current viewport width.
|
|
24
24
|
* For example, if the current viewport width is narrow (less than 768px), the value of `{regular: 'foo', narrow: 'bar'}` will resolve to `'bar'`.
|
|
25
25
|
*
|
|
26
|
-
* Warning: This hook is not fully SSR compatible as it relies on `useMediaUnsafeSSR` without a `defaultState`. Using `getResponsiveAttributes` is preferred to avoid hydration mismatches.
|
|
27
|
-
*
|
|
28
26
|
* @example
|
|
29
27
|
* const value = useResponsiveValue({regular: 'foo', narrow: 'bar'})
|
|
30
28
|
* console.log(value) // 'bar'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useResponsiveValue.d.ts","sourceRoot":"","sources":["../../src/hooks/useResponsiveValue.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useResponsiveValue.d.ts","sourceRoot":"","sources":["../../src/hooks/useResponsiveValue.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,cAAc;;;;CAI1B,CAAA;AAED,MAAM,MAAM,eAAe,CAAC,QAAQ,EAAE,OAAO,GAAG,QAAQ,EAAE,KAAK,GAAG,QAAQ,IAAI;IAC5E,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,OAAO,CAAC,EAAE,QAAQ,CAAA;IAClB,IAAI,CAAC,EAAE,KAAK,CAAA;CACb,CAAA;AAED;;;;GAIG;AACH,MAAM,MAAM,sBAAsB,CAAC,CAAC,IAChC,CAAC,CAAC,SAAS,eAAe,CAAC,MAAM,QAAQ,EAAE,MAAM,OAAO,EAAE,MAAM,KAAK,CAAC,GAAG,QAAQ,GAAG,OAAO,GAAG,KAAK,GAAG,KAAK,CAAC,GAE5G,OAAO,CAAC,CAAC,EAAE,eAAe,CAAC,GAAG,CAAC,CAAC,CAAA;AAEpC;;;GAGG;AAEH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,eAAe,CAAC,GAAG,CAAC,CAE3E;AAED;;;;;;;GAOG;AAEH,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,GAAG,sBAAsB,CAAC,CAAC,CAAC,GAAG,CAAC,CA0B7F"}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { canUseDOM } from '../utils/environment.js';
|
|
3
|
-
import { warning } from '../utils/warning.js';
|
|
1
|
+
import { useMedia } from './useMedia.js';
|
|
4
2
|
|
|
5
3
|
// This file contains utilities for working with responsive values.
|
|
6
4
|
|
|
@@ -35,17 +33,15 @@ function isResponsiveValue(value) {
|
|
|
35
33
|
* Resolves responsive values based on the current viewport width.
|
|
36
34
|
* For example, if the current viewport width is narrow (less than 768px), the value of `{regular: 'foo', narrow: 'bar'}` will resolve to `'bar'`.
|
|
37
35
|
*
|
|
38
|
-
* Warning: This hook is not fully SSR compatible as it relies on `useMediaUnsafeSSR` without a `defaultState`. Using `getResponsiveAttributes` is preferred to avoid hydration mismatches.
|
|
39
|
-
*
|
|
40
36
|
* @example
|
|
41
37
|
* const value = useResponsiveValue({regular: 'foo', narrow: 'bar'})
|
|
42
38
|
* console.log(value) // 'bar'
|
|
43
39
|
*/
|
|
40
|
+
// TODO: Improve SSR support
|
|
44
41
|
function useResponsiveValue(value, fallback) {
|
|
45
|
-
const isNarrowViewport =
|
|
46
|
-
const isRegularViewport =
|
|
47
|
-
const isWideViewport =
|
|
48
|
-
process.env.NODE_ENV !== "production" ? warning(!canUseDOM, "`useResponsiveValue` is not fully SSR compatible as it relies on `useMediaUnsafeSSR` without a `defaultState`. Using `getResponsiveAttributes` is preferred to avoid hydration mismatches.") : void 0;
|
|
42
|
+
const isNarrowViewport = useMedia(viewportRanges.narrow, false);
|
|
43
|
+
const isRegularViewport = useMedia(viewportRanges.regular, false);
|
|
44
|
+
const isWideViewport = useMedia(viewportRanges.wide, false);
|
|
49
45
|
if (isResponsiveValue(value)) {
|
|
50
46
|
const responsiveValue = value;
|
|
51
47
|
if (isNarrowViewport && "narrow" in responsiveValue) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@primer/react",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "38.1.0-rc.
|
|
4
|
+
"version": "38.1.0-rc.d71b584fb",
|
|
5
5
|
"description": "An implementation of GitHub's Primer Design System using React",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"module": "./dist/index.js",
|
|
@@ -164,7 +164,7 @@
|
|
|
164
164
|
"micromark-extension-frontmatter": "2.0.0",
|
|
165
165
|
"micromark-extension-mdxjs": "3.0.0",
|
|
166
166
|
"postcss-preset-primer": "^0.0.0",
|
|
167
|
-
"publint": "^0.3.
|
|
167
|
+
"publint": "^0.3.15",
|
|
168
168
|
"react": "18.3.1",
|
|
169
169
|
"react-dom": "18.3.1",
|
|
170
170
|
"react-is": "18.3.1",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useMediaUnsafeSSR.d.ts","sourceRoot":"","sources":["../../src/hooks/useMediaUnsafeSSR.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAuD,MAAM,OAAO,CAAA;AAI3E;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,iBAAiB,CAAC,gBAAgB,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,OAAO,WAoEjF;AAED,KAAK,kBAAkB,GAAG;IACxB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAAA;CACnC,CAAA;AAOD,KAAK,eAAe,GAAG;IACrB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,QAAQ,CAAC,EAAE,kBAAkB,CAAA;CAC9B,CAAA;AAID;;;;;;;;;;;;;GAaG;AACH,wBAAgB,UAAU,CAAC,EAAC,QAAQ,EAAE,QAA0B,EAAC,EAAE,eAAe,qBAGjF"}
|