@primer/react 38.6.2 → 38.6.3-rc.42b944bf5
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.
Potentially problematic release.
This version of @primer/react might be problematic. Click here for more details.
- package/CHANGELOG.md +17 -0
- package/dist/Autocomplete/Autocomplete.d.ts +0 -3
- package/dist/Autocomplete/Autocomplete.d.ts.map +1 -1
- package/dist/Autocomplete/Autocomplete.js +69 -23
- package/dist/Autocomplete/AutocompleteContext.d.ts +23 -3
- package/dist/Autocomplete/AutocompleteContext.d.ts.map +1 -1
- package/dist/Autocomplete/AutocompleteContext.js +20 -1
- package/dist/Autocomplete/AutocompleteInput.d.ts.map +1 -1
- package/dist/Autocomplete/AutocompleteInput.js +8 -5
- package/dist/Autocomplete/AutocompleteMenu.d.ts.map +1 -1
- package/dist/Autocomplete/AutocompleteMenu.js +123 -121
- package/dist/internal/utils/hasInteractiveNodes.d.ts.map +1 -1
- package/dist/internal/utils/hasInteractiveNodes.js +22 -16
- package/package.json +8 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @primer/react
|
|
2
2
|
|
|
3
|
+
## 38.6.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#7354](https://github.com/primer/react/pull/7354) [`efbebdf`](https://github.com/primer/react/commit/efbebdf6589bf454ab78f17c83dc84ce88145e7b) Thanks [@llastflowers](https://github.com/llastflowers)! - update SelectPanel Multi Select Modal story
|
|
8
|
+
|
|
9
|
+
- [#7337](https://github.com/primer/react/pull/7337) [`de970d6`](https://github.com/primer/react/commit/de970d6682f4e9a3aa5e3c637e0245da2a7a9d84) Thanks [@mattcosta7](https://github.com/mattcosta7)! - perf(Autocomplete): Split context to reduce unnecessary re-renders
|
|
10
|
+
|
|
11
|
+
Split AutocompleteContext into separate contexts for static values, setters, and dynamic state.
|
|
12
|
+
Components now subscribe only to the context slices they need, reducing re-renders.
|
|
13
|
+
|
|
14
|
+
- [#7342](https://github.com/primer/react/pull/7342) [`a8b42b2`](https://github.com/primer/react/commit/a8b42b2e4cff9575eae8df897e64c1ca67ee180a) Thanks [@mattcosta7](https://github.com/mattcosta7)! - perf(hasInteractiveNodes): Optimize with combined selector and early attribute checks
|
|
15
|
+
|
|
16
|
+
- Use combined querySelectorAll selector instead of recursive traversal
|
|
17
|
+
- Check attribute-based states (disabled, hidden, inert) before getComputedStyle
|
|
18
|
+
- Only call getComputedStyle when CSS-based visibility check is needed
|
|
19
|
+
|
|
3
20
|
## 38.6.2
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
|
@@ -15,11 +15,8 @@ declare const _default: React.FC<React.PropsWithChildren<{
|
|
|
15
15
|
__SLOT__: symbol;
|
|
16
16
|
Context: React.Context<{
|
|
17
17
|
activeDescendantRef: React.MutableRefObject<HTMLElement | null>;
|
|
18
|
-
autocompleteSuggestion: string;
|
|
19
18
|
id: string;
|
|
20
19
|
inputRef: React.MutableRefObject<HTMLInputElement | null>;
|
|
21
|
-
inputValue: string;
|
|
22
|
-
isMenuDirectlyActivated: boolean;
|
|
23
20
|
scrollContainerRef: React.MutableRefObject<HTMLElement | null>;
|
|
24
21
|
selectedItemLength: number;
|
|
25
22
|
setAutocompleteSuggestion: (value: string) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Autocomplete.d.ts","sourceRoot":"","sources":["../../src/Autocomplete/Autocomplete.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,KAAK,EAAC,cAAc,EAAE,gBAAgB,EAAC,MAAM,gBAAgB,CAAA;AAGpE,OAAO,gBAAgB,MAAM,oBAAoB,CAAA;AACjD,OAAO,mBAAmB,MAAM,uBAAuB,CAAA;AA0CvD,QAAA,MAAM,YAAY,EAAE,gBAAgB,CAAC,KAAK,CAAC,iBAAiB,CAAC;IAAC,EAAE,CAAC,EAAE,MAAM,CAAA;CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"Autocomplete.d.ts","sourceRoot":"","sources":["../../src/Autocomplete/Autocomplete.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,KAAK,EAAC,cAAc,EAAE,gBAAgB,EAAC,MAAM,gBAAgB,CAAA;AAGpE,OAAO,gBAAgB,MAAM,oBAAoB,CAAA;AACjD,OAAO,mBAAmB,MAAM,uBAAuB,CAAA;AA0CvD,QAAA,MAAM,YAAY,EAAE,gBAAgB,CAAC,KAAK,CAAC,iBAAiB,CAAC;IAAC,EAAE,CAAC,EAAE,MAAM,CAAA;CAAC,CAAC,CA4E1E,CAAA;AAED,MAAM,MAAM,iBAAiB,GAAG,cAAc,CAAC,OAAO,YAAY,CAAC,CAAA;AACnE,YAAY,EAAC,sBAAsB,EAAC,MAAM,qBAAqB,CAAA;AAC/D,YAAY,EAAC,qBAAqB,EAAC,MAAM,oBAAoB,CAAA;AAC7D,YAAY,EAAC,wBAAwB,EAAC,MAAM,uBAAuB,CAAA;;SAjFA,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkFzE,wBAME"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { c } from 'react-compiler-runtime';
|
|
2
|
-
import { useRef, useReducer } from 'react';
|
|
3
|
-
import { AutocompleteContext } from './AutocompleteContext.js';
|
|
2
|
+
import { useRef, useReducer, useDeferredValue } from 'react';
|
|
3
|
+
import { AutocompleteContext, AutocompleteDeferredInputContext, AutocompleteInputContext } from './AutocompleteContext.js';
|
|
4
4
|
import AutocompleteInput from './AutocompleteInput.js';
|
|
5
5
|
import AutocompleteMenu from './AutocompleteMenu.js';
|
|
6
6
|
import AutocompleteOverlay from './AutocompleteOverlay.js';
|
|
@@ -50,7 +50,7 @@ const reducer = (state, action) => {
|
|
|
50
50
|
}
|
|
51
51
|
};
|
|
52
52
|
const Autocomplete = t0 => {
|
|
53
|
-
const $ = c(
|
|
53
|
+
const $ = c(24);
|
|
54
54
|
const {
|
|
55
55
|
children,
|
|
56
56
|
id: idProp
|
|
@@ -133,14 +133,11 @@ const Autocomplete = t0 => {
|
|
|
133
133
|
const setSelectedItemLength = t5;
|
|
134
134
|
const id = useId(idProp);
|
|
135
135
|
let t6;
|
|
136
|
-
if ($[5] !==
|
|
136
|
+
if ($[5] !== id || $[6] !== selectedItemLength || $[7] !== showMenu) {
|
|
137
137
|
t6 = {
|
|
138
138
|
activeDescendantRef,
|
|
139
|
-
autocompleteSuggestion,
|
|
140
139
|
id,
|
|
141
140
|
inputRef,
|
|
142
|
-
inputValue,
|
|
143
|
-
isMenuDirectlyActivated,
|
|
144
141
|
scrollContainerRef,
|
|
145
142
|
selectedItemLength,
|
|
146
143
|
setAutocompleteSuggestion,
|
|
@@ -150,29 +147,78 @@ const Autocomplete = t0 => {
|
|
|
150
147
|
setSelectedItemLength,
|
|
151
148
|
showMenu
|
|
152
149
|
};
|
|
153
|
-
$[5] =
|
|
154
|
-
$[6] =
|
|
155
|
-
$[7] =
|
|
156
|
-
$[8] =
|
|
157
|
-
$[9] = selectedItemLength;
|
|
158
|
-
$[10] = showMenu;
|
|
159
|
-
$[11] = t6;
|
|
150
|
+
$[5] = id;
|
|
151
|
+
$[6] = selectedItemLength;
|
|
152
|
+
$[7] = showMenu;
|
|
153
|
+
$[8] = t6;
|
|
160
154
|
} else {
|
|
161
|
-
t6 = $[
|
|
155
|
+
t6 = $[8];
|
|
162
156
|
}
|
|
157
|
+
const autocompleteContextValue = t6;
|
|
163
158
|
let t7;
|
|
164
|
-
if ($[
|
|
165
|
-
t7 =
|
|
166
|
-
|
|
159
|
+
if ($[9] !== autocompleteSuggestion || $[10] !== inputValue || $[11] !== isMenuDirectlyActivated) {
|
|
160
|
+
t7 = {
|
|
161
|
+
autocompleteSuggestion,
|
|
162
|
+
inputValue,
|
|
163
|
+
isMenuDirectlyActivated
|
|
164
|
+
};
|
|
165
|
+
$[9] = autocompleteSuggestion;
|
|
166
|
+
$[10] = inputValue;
|
|
167
|
+
$[11] = isMenuDirectlyActivated;
|
|
168
|
+
$[12] = t7;
|
|
169
|
+
} else {
|
|
170
|
+
t7 = $[12];
|
|
171
|
+
}
|
|
172
|
+
const autocompleteInputContextValue = t7;
|
|
173
|
+
const deferredInputValue = useDeferredValue(inputValue);
|
|
174
|
+
let t8;
|
|
175
|
+
if ($[13] !== deferredInputValue) {
|
|
176
|
+
t8 = {
|
|
177
|
+
deferredInputValue
|
|
178
|
+
};
|
|
179
|
+
$[13] = deferredInputValue;
|
|
180
|
+
$[14] = t8;
|
|
181
|
+
} else {
|
|
182
|
+
t8 = $[14];
|
|
183
|
+
}
|
|
184
|
+
const autocompleteDeferredInputContextValue = t8;
|
|
185
|
+
let t9;
|
|
186
|
+
if ($[15] !== autocompleteDeferredInputContextValue || $[16] !== children) {
|
|
187
|
+
t9 = /*#__PURE__*/jsx(AutocompleteDeferredInputContext.Provider, {
|
|
188
|
+
value: autocompleteDeferredInputContextValue,
|
|
167
189
|
children: children
|
|
168
190
|
});
|
|
169
|
-
$[
|
|
170
|
-
$[
|
|
171
|
-
$[
|
|
191
|
+
$[15] = autocompleteDeferredInputContextValue;
|
|
192
|
+
$[16] = children;
|
|
193
|
+
$[17] = t9;
|
|
194
|
+
} else {
|
|
195
|
+
t9 = $[17];
|
|
196
|
+
}
|
|
197
|
+
let t10;
|
|
198
|
+
if ($[18] !== autocompleteInputContextValue || $[19] !== t9) {
|
|
199
|
+
t10 = /*#__PURE__*/jsx(AutocompleteInputContext.Provider, {
|
|
200
|
+
value: autocompleteInputContextValue,
|
|
201
|
+
children: t9
|
|
202
|
+
});
|
|
203
|
+
$[18] = autocompleteInputContextValue;
|
|
204
|
+
$[19] = t9;
|
|
205
|
+
$[20] = t10;
|
|
206
|
+
} else {
|
|
207
|
+
t10 = $[20];
|
|
208
|
+
}
|
|
209
|
+
let t11;
|
|
210
|
+
if ($[21] !== autocompleteContextValue || $[22] !== t10) {
|
|
211
|
+
t11 = /*#__PURE__*/jsx(AutocompleteContext.Provider, {
|
|
212
|
+
value: autocompleteContextValue,
|
|
213
|
+
children: t10
|
|
214
|
+
});
|
|
215
|
+
$[21] = autocompleteContextValue;
|
|
216
|
+
$[22] = t10;
|
|
217
|
+
$[23] = t11;
|
|
172
218
|
} else {
|
|
173
|
-
|
|
219
|
+
t11 = $[23];
|
|
174
220
|
}
|
|
175
|
-
return
|
|
221
|
+
return t11;
|
|
176
222
|
};
|
|
177
223
|
var Autocomplete$1 = Object.assign(Autocomplete, {
|
|
178
224
|
__SLOT__: Symbol('Autocomplete'),
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base context containing refs, stable IDs, menu visibility state, and callbacks.
|
|
3
|
+
* This context changes when menu opens/closes or selection changes, but NOT on every keystroke.
|
|
4
|
+
* Consumers like AutocompleteOverlay that don't need input text should use only this context.
|
|
5
|
+
*/
|
|
1
6
|
export declare const AutocompleteContext: import("react").Context<{
|
|
2
7
|
activeDescendantRef: React.MutableRefObject<HTMLElement | null>;
|
|
3
|
-
autocompleteSuggestion: string;
|
|
4
8
|
id: string;
|
|
5
9
|
inputRef: React.MutableRefObject<HTMLInputElement | null>;
|
|
6
|
-
inputValue: string;
|
|
7
|
-
isMenuDirectlyActivated: boolean;
|
|
8
10
|
scrollContainerRef: React.MutableRefObject<HTMLElement | null>;
|
|
9
11
|
selectedItemLength: number;
|
|
10
12
|
setAutocompleteSuggestion: (value: string) => void;
|
|
@@ -14,4 +16,22 @@ export declare const AutocompleteContext: import("react").Context<{
|
|
|
14
16
|
setShowMenu: (value: boolean) => void;
|
|
15
17
|
showMenu: boolean;
|
|
16
18
|
} | null>;
|
|
19
|
+
/**
|
|
20
|
+
* Input-related state that changes on every keystroke.
|
|
21
|
+
* Only AutocompleteInput needs this for immediate text display and suggestion highlighting.
|
|
22
|
+
*/
|
|
23
|
+
export declare const AutocompleteInputContext: import("react").Context<{
|
|
24
|
+
autocompleteSuggestion: string;
|
|
25
|
+
inputValue: string;
|
|
26
|
+
isMenuDirectlyActivated: boolean;
|
|
27
|
+
} | null>;
|
|
28
|
+
/**
|
|
29
|
+
* Deferred input value for expensive operations like filtering.
|
|
30
|
+
* Uses React's useDeferredValue to allow typing to remain responsive while
|
|
31
|
+
* filtering large lists at lower priority.
|
|
32
|
+
* AutocompleteMenu uses this to avoid blocking keystrokes during filtering.
|
|
33
|
+
*/
|
|
34
|
+
export declare const AutocompleteDeferredInputContext: import("react").Context<{
|
|
35
|
+
deferredInputValue: string;
|
|
36
|
+
} | null>;
|
|
17
37
|
//# sourceMappingURL=AutocompleteContext.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AutocompleteContext.d.ts","sourceRoot":"","sources":["../../src/Autocomplete/AutocompleteContext.tsx"],"names":[],"mappings":"AAEA,eAAO,MAAM,mBAAmB;yBACT,KAAK,CAAC,gBAAgB,CAAC,WAAW,GAAG,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"AutocompleteContext.d.ts","sourceRoot":"","sources":["../../src/Autocomplete/AutocompleteContext.tsx"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,eAAO,MAAM,mBAAmB;yBACT,KAAK,CAAC,gBAAgB,CAAC,WAAW,GAAG,IAAI,CAAC;QAE3D,MAAM;cACA,KAAK,CAAC,gBAAgB,CAAC,gBAAgB,GAAG,IAAI,CAAC;wBACrC,KAAK,CAAC,gBAAgB,CAAC,WAAW,GAAG,IAAI,CAAC;wBAC1C,MAAM;+BACC,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI;mBACnC,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI;gCACV,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI;2BAC7B,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI;iBACjC,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI;cAC3B,OAAO;SACJ,CAAA;AAEf;;;GAGG;AACH,eAAO,MAAM,wBAAwB;4BACX,MAAM;gBAClB,MAAM;6BACO,OAAO;SACnB,CAAA;AAEf;;;;;GAKG;AACH,eAAO,MAAM,gCAAgC;wBACvB,MAAM;SACb,CAAA"}
|
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
import { createContext } from 'react';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Base context containing refs, stable IDs, menu visibility state, and callbacks.
|
|
5
|
+
* This context changes when menu opens/closes or selection changes, but NOT on every keystroke.
|
|
6
|
+
* Consumers like AutocompleteOverlay that don't need input text should use only this context.
|
|
7
|
+
*/
|
|
3
8
|
const AutocompleteContext = /*#__PURE__*/createContext(null);
|
|
4
9
|
|
|
5
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Input-related state that changes on every keystroke.
|
|
12
|
+
* Only AutocompleteInput needs this for immediate text display and suggestion highlighting.
|
|
13
|
+
*/
|
|
14
|
+
const AutocompleteInputContext = /*#__PURE__*/createContext(null);
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Deferred input value for expensive operations like filtering.
|
|
18
|
+
* Uses React's useDeferredValue to allow typing to remain responsive while
|
|
19
|
+
* filtering large lists at lower priority.
|
|
20
|
+
* AutocompleteMenu uses this to avoid blocking keystrokes during filtering.
|
|
21
|
+
*/
|
|
22
|
+
const AutocompleteDeferredInputContext = /*#__PURE__*/createContext(null);
|
|
23
|
+
|
|
24
|
+
export { AutocompleteContext, AutocompleteDeferredInputContext, AutocompleteInputContext };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AutocompleteInput.d.ts","sourceRoot":"","sources":["../../src/Autocomplete/AutocompleteInput.tsx"],"names":[],"mappings":"AACA,OAAO,KAAqD,MAAM,OAAO,CAAA;AACzE,OAAO,KAAK,EAAC,mBAAmB,IAAI,8BAA8B,EAAC,MAAM,sBAAsB,CAAA;AAE/F,OAAO,SAAS,MAAM,cAAc,CAAA;AAEpC,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,gBAAgB,CAAA;AAGlD,KAAK,8BAA8B,GAAG;IAEpC,EAAE,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,CAAA;IAEtD;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAA;CACtB,CAAA;AAID,QAAA,MAAM,iBAAiB,
|
|
1
|
+
{"version":3,"file":"AutocompleteInput.d.ts","sourceRoot":"","sources":["../../src/Autocomplete/AutocompleteInput.tsx"],"names":[],"mappings":"AACA,OAAO,KAAqD,MAAM,OAAO,CAAA;AACzE,OAAO,KAAK,EAAC,mBAAmB,IAAI,8BAA8B,EAAC,MAAM,sBAAsB,CAAA;AAE/F,OAAO,SAAS,MAAM,cAAc,CAAA;AAEpC,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,gBAAgB,CAAA;AAGlD,KAAK,8BAA8B,GAAG;IAEpC,EAAE,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,CAAA;IAEtD;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAA;CACtB,CAAA;AAID,QAAA,MAAM,iBAAiB,EAyJlB,8BAA8B,CAAC,OAAO,SAAS,EAAE,8BAA8B,CAAC,CAAA;AAIrF,MAAM,MAAM,sBAAsB,GAAG,cAAc,CAAC,OAAO,iBAAiB,CAAC,CAAA;AAC7E,eAAe,iBAAiB,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { useContext, useState, useCallback, useEffect } from 'react';
|
|
2
|
-
import { AutocompleteContext } from './AutocompleteContext.js';
|
|
2
|
+
import { AutocompleteContext, AutocompleteInputContext } from './AutocompleteContext.js';
|
|
3
3
|
import { useRefObjectAsForwardedRef } from '../hooks/useRefObjectAsForwardedRef.js';
|
|
4
4
|
import useSafeTimeout from '../hooks/useSafeTimeout.js';
|
|
5
5
|
import { jsx } from 'react/jsx-runtime';
|
|
@@ -19,20 +19,23 @@ const AutocompleteInput = /*#__PURE__*/React.forwardRef(({
|
|
|
19
19
|
...props
|
|
20
20
|
}, forwardedRef) => {
|
|
21
21
|
const autocompleteContext = useContext(AutocompleteContext);
|
|
22
|
-
|
|
22
|
+
const inputContext = useContext(AutocompleteInputContext);
|
|
23
|
+
if (autocompleteContext === null || inputContext === null) {
|
|
23
24
|
throw new Error('AutocompleteContext returned null values');
|
|
24
25
|
}
|
|
25
26
|
const {
|
|
26
27
|
activeDescendantRef,
|
|
27
|
-
autocompleteSuggestion = '',
|
|
28
28
|
id,
|
|
29
29
|
inputRef,
|
|
30
|
-
inputValue = '',
|
|
31
|
-
isMenuDirectlyActivated,
|
|
32
30
|
setInputValue,
|
|
33
31
|
setShowMenu,
|
|
34
32
|
showMenu
|
|
35
33
|
} = autocompleteContext;
|
|
34
|
+
const {
|
|
35
|
+
autocompleteSuggestion = '',
|
|
36
|
+
inputValue = '',
|
|
37
|
+
isMenuDirectlyActivated
|
|
38
|
+
} = inputContext;
|
|
36
39
|
useRefObjectAsForwardedRef(forwardedRef, inputRef);
|
|
37
40
|
const [highlightRemainingText, setHighlightRemainingText] = useState(true);
|
|
38
41
|
const {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AutocompleteMenu.d.ts","sourceRoot":"","sources":["../../src/Autocomplete/AutocompleteMenu.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAyD,MAAM,OAAO,CAAA;AAK7E,OAAO,KAAK,EAAC,mBAAmB,EAAC,MAAM,eAAe,CAAA;AAGtD,OAAO,KAAK,EAAC,cAAc,EAAE,YAAY,EAAW,MAAM,gBAAgB,CAAA;AAI1E,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,wBAAwB,CAAA;AAOrD,KAAK,gBAAgB,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,IAAI,CAAA;AAClD,MAAM,MAAM,oBAAoB,GAAG,YAAY,CAAC,mBAAmB,EAAE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AAqB,EAAE,KAAK,EAAE,6BAA6B,CAAC,CAAC,CAAC,qBAqRjG;kBArRQ,gBAAgB;;;;AAyRzB,MAAM,MAAM,qBAAqB,GAAG,cAAc,CAAC,OAAO,gBAAgB,CAAC,CAAA;AAC3E,eAAe,gBAAgB,CAAA"}
|
|
@@ -6,7 +6,7 @@ import { scrollIntoView } from '@primer/behaviors';
|
|
|
6
6
|
import { ActionList } from '../ActionList/index.js';
|
|
7
7
|
import { useFocusZone } from '../hooks/useFocusZone.js';
|
|
8
8
|
import { useId } from '../hooks/useId.js';
|
|
9
|
-
import { AutocompleteContext } from './AutocompleteContext.js';
|
|
9
|
+
import { AutocompleteContext, AutocompleteDeferredInputContext } from './AutocompleteContext.js';
|
|
10
10
|
import { PlusIcon } from '@primer/octicons-react';
|
|
11
11
|
import VisuallyHidden from '../_VisuallyHidden.js';
|
|
12
12
|
import { isElement } from 'react-is';
|
|
@@ -50,14 +50,14 @@ const debounceAnnouncement = debounce(announcement => {
|
|
|
50
50
|
function AutocompleteMenu(props) {
|
|
51
51
|
const $ = c(78);
|
|
52
52
|
const autocompleteContext = useContext(AutocompleteContext);
|
|
53
|
-
|
|
53
|
+
const deferredInputContext = useContext(AutocompleteDeferredInputContext);
|
|
54
|
+
if (autocompleteContext === null || deferredInputContext === null) {
|
|
54
55
|
throw new Error("AutocompleteContext returned null values");
|
|
55
56
|
}
|
|
56
57
|
const {
|
|
57
58
|
activeDescendantRef,
|
|
58
59
|
id,
|
|
59
60
|
inputRef,
|
|
60
|
-
inputValue: t0,
|
|
61
61
|
scrollContainerRef,
|
|
62
62
|
setAutocompleteSuggestion,
|
|
63
63
|
setShowMenu,
|
|
@@ -66,46 +66,48 @@ function AutocompleteMenu(props) {
|
|
|
66
66
|
setSelectedItemLength,
|
|
67
67
|
showMenu
|
|
68
68
|
} = autocompleteContext;
|
|
69
|
-
const
|
|
69
|
+
const {
|
|
70
|
+
deferredInputValue
|
|
71
|
+
} = deferredInputContext;
|
|
70
72
|
const {
|
|
71
73
|
items,
|
|
72
74
|
selectedItemIds,
|
|
73
75
|
sortOnCloseFn,
|
|
74
|
-
emptyStateText:
|
|
76
|
+
emptyStateText: t0,
|
|
75
77
|
addNewItem,
|
|
76
78
|
loading,
|
|
77
|
-
selectionVariant:
|
|
79
|
+
selectionVariant: t1,
|
|
78
80
|
filterFn,
|
|
79
81
|
"aria-labelledby": ariaLabelledBy,
|
|
80
82
|
onOpenChange,
|
|
81
83
|
onSelectedChange,
|
|
82
84
|
customScrollContainerRef
|
|
83
85
|
} = props;
|
|
84
|
-
const emptyStateText =
|
|
85
|
-
const selectionVariant =
|
|
86
|
+
const emptyStateText = t0 === undefined ? "No selectable options" : t0;
|
|
87
|
+
const selectionVariant = t1 === undefined ? "single" : t1;
|
|
86
88
|
const listContainerRef = useRef(null);
|
|
87
|
-
let
|
|
89
|
+
let t2;
|
|
88
90
|
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
89
|
-
|
|
90
|
-
$[0] =
|
|
91
|
+
t2 = [];
|
|
92
|
+
$[0] = t2;
|
|
91
93
|
} else {
|
|
92
|
-
|
|
94
|
+
t2 = $[0];
|
|
93
95
|
}
|
|
94
|
-
const allItemsToRenderRef = useRef(
|
|
96
|
+
const allItemsToRenderRef = useRef(t2);
|
|
95
97
|
const [highlightedItem, setHighlightedItem] = useState();
|
|
96
|
-
let
|
|
98
|
+
let t3;
|
|
97
99
|
if ($[1] !== items) {
|
|
98
|
-
|
|
100
|
+
t3 = items.map(_temp);
|
|
99
101
|
$[1] = items;
|
|
100
|
-
$[2] =
|
|
102
|
+
$[2] = t3;
|
|
101
103
|
} else {
|
|
102
|
-
|
|
104
|
+
t3 = $[2];
|
|
103
105
|
}
|
|
104
|
-
const [sortedItemIds, setSortedItemIds] = useState(
|
|
106
|
+
const [sortedItemIds, setSortedItemIds] = useState(t3);
|
|
105
107
|
const generatedUniqueId = useId(id);
|
|
106
|
-
let
|
|
108
|
+
let t4;
|
|
107
109
|
if ($[3] !== (highlightedItem === null || highlightedItem === void 0 ? void 0 : highlightedItem.id) || $[4] !== inputRef || $[5] !== items || $[6] !== onSelectedChange || $[7] !== selectedItemIds || $[8] !== selectionVariant || $[9] !== setAutocompleteSuggestion || $[10] !== setInputValue || $[11] !== setShowMenu) {
|
|
108
|
-
|
|
110
|
+
t4 = items.map(selectableItem => ({
|
|
109
111
|
...selectableItem,
|
|
110
112
|
role: "option",
|
|
111
113
|
id: selectableItem.id,
|
|
@@ -135,43 +137,43 @@ function AutocompleteMenu(props) {
|
|
|
135
137
|
$[9] = setAutocompleteSuggestion;
|
|
136
138
|
$[10] = setInputValue;
|
|
137
139
|
$[11] = setShowMenu;
|
|
138
|
-
$[12] =
|
|
140
|
+
$[12] = t4;
|
|
139
141
|
} else {
|
|
140
|
-
|
|
142
|
+
t4 = $[12];
|
|
141
143
|
}
|
|
142
|
-
const selectableItems =
|
|
143
|
-
let
|
|
144
|
+
const selectableItems = t4;
|
|
145
|
+
let t5;
|
|
144
146
|
if ($[13] !== sortedItemIds) {
|
|
145
|
-
|
|
147
|
+
t5 = sortedItemIds.reduce(_temp2, {});
|
|
146
148
|
$[13] = sortedItemIds;
|
|
147
|
-
$[14] =
|
|
149
|
+
$[14] = t5;
|
|
148
150
|
} else {
|
|
149
|
-
|
|
151
|
+
t5 = $[14];
|
|
150
152
|
}
|
|
151
|
-
const itemSortOrderData =
|
|
152
|
-
let
|
|
153
|
-
if ($[15] !==
|
|
154
|
-
let
|
|
153
|
+
const itemSortOrderData = t5;
|
|
154
|
+
let t6;
|
|
155
|
+
if ($[15] !== deferredInputValue || $[16] !== filterFn || $[17] !== itemSortOrderData || $[18] !== selectableItems) {
|
|
156
|
+
let t7;
|
|
155
157
|
if ($[20] !== itemSortOrderData) {
|
|
156
|
-
|
|
158
|
+
t7 = (a, b) => itemSortOrderData[a.id] - itemSortOrderData[b.id];
|
|
157
159
|
$[20] = itemSortOrderData;
|
|
158
|
-
$[21] =
|
|
160
|
+
$[21] = t7;
|
|
159
161
|
} else {
|
|
160
|
-
|
|
162
|
+
t7 = $[21];
|
|
161
163
|
}
|
|
162
|
-
|
|
163
|
-
$[15] =
|
|
164
|
-
$[16] =
|
|
164
|
+
t6 = selectableItems.filter(filterFn ? filterFn : getDefaultItemFilter(deferredInputValue)).sort(t7);
|
|
165
|
+
$[15] = deferredInputValue;
|
|
166
|
+
$[16] = filterFn;
|
|
165
167
|
$[17] = itemSortOrderData;
|
|
166
168
|
$[18] = selectableItems;
|
|
167
|
-
$[19] =
|
|
169
|
+
$[19] = t6;
|
|
168
170
|
} else {
|
|
169
|
-
|
|
171
|
+
t6 = $[19];
|
|
170
172
|
}
|
|
171
|
-
const sortedAndFilteredItemsToRender =
|
|
172
|
-
let
|
|
173
|
+
const sortedAndFilteredItemsToRender = t6;
|
|
174
|
+
let t7;
|
|
173
175
|
if ($[22] !== addNewItem || $[23] !== generatedUniqueId || $[24] !== (highlightedItem === null || highlightedItem === void 0 ? void 0 : highlightedItem.id) || $[25] !== selectedItemIds || $[26] !== selectionVariant || $[27] !== setAutocompleteSuggestion || $[28] !== setInputValue) {
|
|
174
|
-
|
|
176
|
+
t7 = addNewItem ? [{
|
|
175
177
|
...addNewItem,
|
|
176
178
|
role: "option",
|
|
177
179
|
key: addNewItem.id,
|
|
@@ -197,52 +199,52 @@ function AutocompleteMenu(props) {
|
|
|
197
199
|
$[26] = selectionVariant;
|
|
198
200
|
$[27] = setAutocompleteSuggestion;
|
|
199
201
|
$[28] = setInputValue;
|
|
200
|
-
$[29] =
|
|
202
|
+
$[29] = t7;
|
|
201
203
|
} else {
|
|
202
|
-
|
|
204
|
+
t7 = $[29];
|
|
203
205
|
}
|
|
204
|
-
let
|
|
205
|
-
if ($[30] !== sortedAndFilteredItemsToRender || $[31] !==
|
|
206
|
-
|
|
206
|
+
let t8;
|
|
207
|
+
if ($[30] !== sortedAndFilteredItemsToRender || $[31] !== t7) {
|
|
208
|
+
t8 = [...sortedAndFilteredItemsToRender, ...t7];
|
|
207
209
|
$[30] = sortedAndFilteredItemsToRender;
|
|
208
|
-
$[31] =
|
|
209
|
-
$[32] =
|
|
210
|
+
$[31] = t7;
|
|
211
|
+
$[32] = t8;
|
|
210
212
|
} else {
|
|
211
|
-
|
|
213
|
+
t8 = $[32];
|
|
212
214
|
}
|
|
213
|
-
const allItemsToRender =
|
|
214
|
-
let
|
|
215
|
+
const allItemsToRender = t8;
|
|
216
|
+
let t9;
|
|
215
217
|
if ($[33] !== allItemsToRender) {
|
|
216
|
-
|
|
218
|
+
t9 = () => {
|
|
217
219
|
allItemsToRenderRef.current = allItemsToRender;
|
|
218
220
|
};
|
|
219
221
|
$[33] = allItemsToRender;
|
|
220
|
-
$[34] =
|
|
222
|
+
$[34] = t9;
|
|
221
223
|
} else {
|
|
222
|
-
|
|
224
|
+
t9 = $[34];
|
|
223
225
|
}
|
|
224
|
-
React.useEffect(
|
|
226
|
+
React.useEffect(t9);
|
|
227
|
+
let t10;
|
|
225
228
|
let t11;
|
|
226
|
-
let t12;
|
|
227
229
|
if ($[35] !== allItemsToRender || $[36] !== emptyStateText) {
|
|
228
|
-
|
|
230
|
+
t10 = () => {
|
|
229
231
|
if (allItemsToRender.length === 0) {
|
|
230
232
|
debounceAnnouncement(emptyStateText);
|
|
231
233
|
}
|
|
232
234
|
};
|
|
233
|
-
|
|
235
|
+
t11 = [allItemsToRender, emptyStateText];
|
|
234
236
|
$[35] = allItemsToRender;
|
|
235
237
|
$[36] = emptyStateText;
|
|
236
|
-
$[37] =
|
|
237
|
-
$[38] =
|
|
238
|
+
$[37] = t10;
|
|
239
|
+
$[38] = t11;
|
|
238
240
|
} else {
|
|
239
|
-
|
|
240
|
-
|
|
241
|
+
t10 = $[37];
|
|
242
|
+
t11 = $[38];
|
|
241
243
|
}
|
|
242
|
-
React.useEffect(
|
|
243
|
-
let
|
|
244
|
+
React.useEffect(t10, t11);
|
|
245
|
+
let t12;
|
|
244
246
|
if ($[39] !== activeDescendantRef || $[40] !== customScrollContainerRef || $[41] !== scrollContainerRef || $[42] !== setIsMenuDirectlyActivated) {
|
|
245
|
-
|
|
247
|
+
t12 = (current, _previous, directlyActivated) => {
|
|
246
248
|
activeDescendantRef.current = current || null;
|
|
247
249
|
if (current) {
|
|
248
250
|
const selectedItem = allItemsToRenderRef.current.find(item_1 => {
|
|
@@ -264,61 +266,61 @@ function AutocompleteMenu(props) {
|
|
|
264
266
|
$[40] = customScrollContainerRef;
|
|
265
267
|
$[41] = scrollContainerRef;
|
|
266
268
|
$[42] = setIsMenuDirectlyActivated;
|
|
267
|
-
$[43] =
|
|
269
|
+
$[43] = t12;
|
|
268
270
|
} else {
|
|
269
|
-
|
|
271
|
+
t12 = $[43];
|
|
270
272
|
}
|
|
271
|
-
let
|
|
272
|
-
if ($[44] !== inputRef || $[45] !==
|
|
273
|
-
|
|
273
|
+
let t13;
|
|
274
|
+
if ($[44] !== inputRef || $[45] !== t12) {
|
|
275
|
+
t13 = {
|
|
274
276
|
containerRef: listContainerRef,
|
|
275
277
|
focusOutBehavior: "wrap",
|
|
276
278
|
focusableElementFilter: _temp4,
|
|
277
279
|
activeDescendantFocus: inputRef,
|
|
278
|
-
onActiveDescendantChanged:
|
|
280
|
+
onActiveDescendantChanged: t12
|
|
279
281
|
};
|
|
280
282
|
$[44] = inputRef;
|
|
281
|
-
$[45] =
|
|
282
|
-
$[46] =
|
|
283
|
+
$[45] = t12;
|
|
284
|
+
$[46] = t13;
|
|
283
285
|
} else {
|
|
284
|
-
|
|
286
|
+
t13 = $[46];
|
|
285
287
|
}
|
|
286
|
-
let
|
|
288
|
+
let t14;
|
|
287
289
|
if ($[47] !== loading) {
|
|
288
|
-
|
|
290
|
+
t14 = [loading];
|
|
289
291
|
$[47] = loading;
|
|
290
|
-
$[48] =
|
|
292
|
+
$[48] = t14;
|
|
291
293
|
} else {
|
|
292
|
-
|
|
294
|
+
t14 = $[48];
|
|
293
295
|
}
|
|
294
|
-
useFocusZone(
|
|
296
|
+
useFocusZone(t13, t14);
|
|
297
|
+
let t15;
|
|
295
298
|
let t16;
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
t16 = () => {
|
|
299
|
+
if ($[49] !== deferredInputValue || $[50] !== highlightedItem || $[51] !== selectedItemIds || $[52] !== setAutocompleteSuggestion) {
|
|
300
|
+
t15 = () => {
|
|
299
301
|
var _highlightedItem$text;
|
|
300
|
-
if (highlightedItem !== null && highlightedItem !== void 0 && (_highlightedItem$text = highlightedItem.text) !== null && _highlightedItem$text !== void 0 && _highlightedItem$text.startsWith(
|
|
302
|
+
if (highlightedItem !== null && highlightedItem !== void 0 && (_highlightedItem$text = highlightedItem.text) !== null && _highlightedItem$text !== void 0 && _highlightedItem$text.startsWith(deferredInputValue) && !selectedItemIds.includes(highlightedItem.id)) {
|
|
301
303
|
setAutocompleteSuggestion(highlightedItem.text);
|
|
302
304
|
} else {
|
|
303
305
|
setAutocompleteSuggestion("");
|
|
304
306
|
}
|
|
305
307
|
};
|
|
306
|
-
|
|
307
|
-
$[49] =
|
|
308
|
-
$[50] =
|
|
308
|
+
t16 = [highlightedItem, deferredInputValue, selectedItemIds, setAutocompleteSuggestion];
|
|
309
|
+
$[49] = deferredInputValue;
|
|
310
|
+
$[50] = highlightedItem;
|
|
309
311
|
$[51] = selectedItemIds;
|
|
310
312
|
$[52] = setAutocompleteSuggestion;
|
|
311
|
-
$[53] =
|
|
312
|
-
$[54] =
|
|
313
|
+
$[53] = t15;
|
|
314
|
+
$[54] = t16;
|
|
313
315
|
} else {
|
|
314
|
-
|
|
315
|
-
|
|
316
|
+
t15 = $[53];
|
|
317
|
+
t16 = $[54];
|
|
316
318
|
}
|
|
317
|
-
useEffect(
|
|
319
|
+
useEffect(t15, t16);
|
|
320
|
+
let t17;
|
|
318
321
|
let t18;
|
|
319
|
-
let t19;
|
|
320
322
|
if ($[55] !== onOpenChange || $[56] !== selectedItemIds || $[57] !== showMenu || $[58] !== sortOnCloseFn || $[59] !== sortedItemIds) {
|
|
321
|
-
|
|
323
|
+
t17 = () => {
|
|
322
324
|
const itemIdSortResult = [...sortedItemIds].sort(sortOnCloseFn ? sortOnCloseFn : getDefaultSortFn(itemId_0 => isItemSelected(itemId_0, selectedItemIds)));
|
|
323
325
|
const sortResultMatchesState = itemIdSortResult.length === sortedItemIds.length && itemIdSortResult.every((element_0, index) => element_0 === sortedItemIds[index]);
|
|
324
326
|
if (showMenu === false && !sortResultMatchesState) {
|
|
@@ -326,48 +328,48 @@ function AutocompleteMenu(props) {
|
|
|
326
328
|
}
|
|
327
329
|
onOpenChange && onOpenChange(Boolean(showMenu));
|
|
328
330
|
};
|
|
329
|
-
|
|
331
|
+
t18 = [showMenu, onOpenChange, selectedItemIds, sortOnCloseFn, sortedItemIds];
|
|
330
332
|
$[55] = onOpenChange;
|
|
331
333
|
$[56] = selectedItemIds;
|
|
332
334
|
$[57] = showMenu;
|
|
333
335
|
$[58] = sortOnCloseFn;
|
|
334
336
|
$[59] = sortedItemIds;
|
|
335
|
-
$[60] =
|
|
336
|
-
$[61] =
|
|
337
|
+
$[60] = t17;
|
|
338
|
+
$[61] = t18;
|
|
337
339
|
} else {
|
|
338
|
-
|
|
339
|
-
|
|
340
|
+
t17 = $[60];
|
|
341
|
+
t18 = $[61];
|
|
340
342
|
}
|
|
341
|
-
useEffect(
|
|
342
|
-
let
|
|
343
|
+
useEffect(t17, t18);
|
|
344
|
+
let t19;
|
|
343
345
|
if ($[62] !== selectedItemIds.length || $[63] !== setSelectedItemLength) {
|
|
344
|
-
|
|
346
|
+
t19 = () => {
|
|
345
347
|
if (selectedItemIds.length) {
|
|
346
348
|
setSelectedItemLength(selectedItemIds.length);
|
|
347
349
|
}
|
|
348
350
|
};
|
|
349
351
|
$[62] = selectedItemIds.length;
|
|
350
352
|
$[63] = setSelectedItemLength;
|
|
351
|
-
$[64] =
|
|
353
|
+
$[64] = t19;
|
|
352
354
|
} else {
|
|
353
|
-
|
|
355
|
+
t19 = $[64];
|
|
354
356
|
}
|
|
355
|
-
let
|
|
357
|
+
let t20;
|
|
356
358
|
if ($[65] !== selectedItemIds || $[66] !== setSelectedItemLength) {
|
|
357
|
-
|
|
359
|
+
t20 = [selectedItemIds, setSelectedItemLength];
|
|
358
360
|
$[65] = selectedItemIds;
|
|
359
361
|
$[66] = setSelectedItemLength;
|
|
360
|
-
$[67] =
|
|
362
|
+
$[67] = t20;
|
|
361
363
|
} else {
|
|
362
|
-
|
|
364
|
+
t20 = $[67];
|
|
363
365
|
}
|
|
364
|
-
useEffect(
|
|
366
|
+
useEffect(t19, t20);
|
|
365
367
|
if (selectionVariant === "single" && selectedItemIds.length > 1) {
|
|
366
368
|
throw new Error("Autocomplete: selectionVariant \"single\" cannot be used with multiple selected items");
|
|
367
369
|
}
|
|
368
|
-
let
|
|
370
|
+
let t21;
|
|
369
371
|
if ($[68] !== allItemsToRender || $[69] !== ariaLabelledBy || $[70] !== emptyStateText || $[71] !== id || $[72] !== loading || $[73] !== selectionVariant) {
|
|
370
|
-
|
|
372
|
+
t21 = loading ? /*#__PURE__*/jsx("div", {
|
|
371
373
|
className: classes.SpinnerWrapper,
|
|
372
374
|
children: /*#__PURE__*/jsx(Spinner, {})
|
|
373
375
|
}) : /*#__PURE__*/jsx("div", {
|
|
@@ -389,23 +391,23 @@ function AutocompleteMenu(props) {
|
|
|
389
391
|
$[71] = id;
|
|
390
392
|
$[72] = loading;
|
|
391
393
|
$[73] = selectionVariant;
|
|
392
|
-
$[74] =
|
|
394
|
+
$[74] = t21;
|
|
393
395
|
} else {
|
|
394
|
-
|
|
396
|
+
t21 = $[74];
|
|
395
397
|
}
|
|
396
|
-
let
|
|
397
|
-
if ($[75] !== showMenu || $[76] !==
|
|
398
|
-
|
|
398
|
+
let t22;
|
|
399
|
+
if ($[75] !== showMenu || $[76] !== t21) {
|
|
400
|
+
t22 = /*#__PURE__*/jsx(VisuallyHidden, {
|
|
399
401
|
isVisible: showMenu,
|
|
400
|
-
children:
|
|
402
|
+
children: t21
|
|
401
403
|
});
|
|
402
404
|
$[75] = showMenu;
|
|
403
|
-
$[76] =
|
|
404
|
-
$[77] =
|
|
405
|
+
$[76] = t21;
|
|
406
|
+
$[77] = t22;
|
|
405
407
|
} else {
|
|
406
|
-
|
|
408
|
+
t22 = $[77];
|
|
407
409
|
}
|
|
408
|
-
return
|
|
410
|
+
return t22;
|
|
409
411
|
}
|
|
410
412
|
function _temp5(item_2) {
|
|
411
413
|
const {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hasInteractiveNodes.d.ts","sourceRoot":"","sources":["../../../src/internal/utils/hasInteractiveNodes.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"hasInteractiveNodes.d.ts","sourceRoot":"","sources":["../../../src/internal/utils/hasInteractiveNodes.ts"],"names":[],"mappings":"AA2BA;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI,EAAE,WAAW,CAAC,EAAE,WAAW,EAAE,WAkBxF"}
|
|
@@ -7,6 +7,9 @@ const nonValidSelectors = {
|
|
|
7
7
|
const interactiveElementsSelectors = [`a[href]`, `button`, 'summary', 'select', 'input:not([type=hidden])', 'textarea', '[tabindex="0"]', `audio[controls]`, `video[controls]`, `[contenteditable]`];
|
|
8
8
|
const interactiveElements = interactiveElementsSelectors.map(selector => `${selector}:not(${Object.values(nonValidSelectors).join('):not(')})`);
|
|
9
9
|
|
|
10
|
+
// Combined selector for fast querySelector check
|
|
11
|
+
const interactiveSelector = interactiveElements.join(', ');
|
|
12
|
+
|
|
10
13
|
/**
|
|
11
14
|
* Finds interactive nodes within the passed node.
|
|
12
15
|
* If the node itself is interactive, or children within are, it will return true.
|
|
@@ -23,26 +26,29 @@ function hasInteractiveNodes(node, ignoreNodes) {
|
|
|
23
26
|
// If one does exist, we can abort early.
|
|
24
27
|
|
|
25
28
|
const nodesToIgnore = [node];
|
|
26
|
-
|
|
27
|
-
|
|
29
|
+
|
|
30
|
+
// Performance optimization: Use querySelectorAll with combined selector first
|
|
31
|
+
// This avoids recursive getComputedStyle calls for each node
|
|
32
|
+
const candidates = node.querySelectorAll(interactiveSelector);
|
|
33
|
+
for (const candidate of candidates) {
|
|
34
|
+
if (!nodesToIgnore.includes(candidate) && !isNonValidInteractiveNode(candidate)) {
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return false;
|
|
28
39
|
}
|
|
40
|
+
|
|
41
|
+
// Note: Only call getComputedStyle when CSS-based checks are insufficient
|
|
29
42
|
function isNonValidInteractiveNode(node) {
|
|
30
|
-
|
|
43
|
+
// Fast path: Check attribute-based states first (no style recalc needed)
|
|
31
44
|
const isNonInteractive = node.matches('[disabled], [hidden], [inert]');
|
|
45
|
+
if (isNonInteractive) return true;
|
|
46
|
+
|
|
47
|
+
// Only call getComputedStyle if attribute checks passed
|
|
48
|
+
// This is necessary for display:none and visibility:hidden which aren't detectable via attributes
|
|
49
|
+
const nodeStyle = getComputedStyle(node);
|
|
32
50
|
const isHiddenVisually = nodeStyle.display === 'none' || nodeStyle.visibility === 'hidden';
|
|
33
|
-
return
|
|
34
|
-
}
|
|
35
|
-
function findInteractiveChildNodes(node, ignoreNodes) {
|
|
36
|
-
if (!node) return;
|
|
37
|
-
const ignoreSelector = ignoreNodes.find(elem => elem === node);
|
|
38
|
-
const isNotValidNode = isNonValidInteractiveNode(node);
|
|
39
|
-
if (node.matches(interactiveElements.join(', ')) && !ignoreSelector && !isNotValidNode) {
|
|
40
|
-
return node;
|
|
41
|
-
}
|
|
42
|
-
for (const child of node.children) {
|
|
43
|
-
const interactiveNode = findInteractiveChildNodes(child, ignoreNodes);
|
|
44
|
-
if (interactiveNode) return true;
|
|
45
|
-
}
|
|
51
|
+
return isHiddenVisually;
|
|
46
52
|
}
|
|
47
53
|
|
|
48
54
|
export { hasInteractiveNodes };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@primer/react",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "38.6.
|
|
4
|
+
"version": "38.6.3-rc.42b944bf5",
|
|
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",
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
"@oddbird/popover-polyfill": "^0.5.2",
|
|
82
82
|
"@primer/behaviors": "^1.9.0",
|
|
83
83
|
"@primer/live-region-element": "^0.7.1",
|
|
84
|
-
"@primer/octicons-react": "^19.
|
|
84
|
+
"@primer/octicons-react": "^19.21.0",
|
|
85
85
|
"@primer/primitives": "10.x || 11.x",
|
|
86
86
|
"clsx": "^2.1.1",
|
|
87
87
|
"color2k": "^2.0.3",
|
|
@@ -114,11 +114,11 @@
|
|
|
114
114
|
"@rollup/plugin-node-resolve": "16.0.3",
|
|
115
115
|
"@rollup/plugin-typescript": "12.3.0",
|
|
116
116
|
"@rollup/plugin-virtual": "3.0.2",
|
|
117
|
-
"@storybook/addon-a11y": "^10.1.
|
|
118
|
-
"@storybook/addon-docs": "^10.1.
|
|
119
|
-
"@storybook/addon-links": "^10.1.
|
|
117
|
+
"@storybook/addon-a11y": "^10.1.10",
|
|
118
|
+
"@storybook/addon-docs": "^10.1.10",
|
|
119
|
+
"@storybook/addon-links": "^10.1.10",
|
|
120
120
|
"@storybook/icons": "^2.0.1",
|
|
121
|
-
"@storybook/react-vite": "^10.1.
|
|
121
|
+
"@storybook/react-vite": "^10.1.10",
|
|
122
122
|
"@testing-library/dom": "^10.4.0",
|
|
123
123
|
"@testing-library/jest-dom": "^6.4.5",
|
|
124
124
|
"@testing-library/react": "^16.3.0",
|
|
@@ -170,9 +170,9 @@
|
|
|
170
170
|
"react-is": "18.3.1",
|
|
171
171
|
"recast": "0.23.7",
|
|
172
172
|
"rimraf": "5.0.5",
|
|
173
|
-
"rollup": "4.
|
|
173
|
+
"rollup": "4.54.0",
|
|
174
174
|
"rollup-plugin-import-css": "^0.0.0",
|
|
175
|
-
"storybook": "^10.1.
|
|
175
|
+
"storybook": "^10.1.10",
|
|
176
176
|
"terser": "5.36.0",
|
|
177
177
|
"ts-toolbelt": "9.6.0",
|
|
178
178
|
"tsx": "4.20.3",
|