@fluentui/react-utilities 9.12.0 → 9.13.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.
- package/CHANGELOG.json +24 -1
- package/CHANGELOG.md +15 -2
- package/dist/index.d.ts +4 -0
- package/lib/hooks/useOnClickOutside.js +14 -15
- package/lib/hooks/useOnClickOutside.js.map +1 -1
- package/lib-commonjs/hooks/useOnClickOutside.js +14 -15
- package/lib-commonjs/hooks/useOnClickOutside.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.json
CHANGED
@@ -2,7 +2,30 @@
|
|
2
2
|
"name": "@fluentui/react-utilities",
|
3
3
|
"entries": [
|
4
4
|
{
|
5
|
-
"date": "
|
5
|
+
"date": "Tue, 29 Aug 2023 12:53:36 GMT",
|
6
|
+
"tag": "@fluentui/react-utilities_v9.13.0",
|
7
|
+
"version": "9.13.0",
|
8
|
+
"comments": {
|
9
|
+
"minor": [
|
10
|
+
{
|
11
|
+
"author": "olfedias@microsoft.com",
|
12
|
+
"package": "@fluentui/react-utilities",
|
13
|
+
"commit": "2147e3d60a21ff7ded34b27a19f3d5313533e910",
|
14
|
+
"comment": "feat: add disabledFocusOnIframe for useOnClickOutside()"
|
15
|
+
}
|
16
|
+
],
|
17
|
+
"patch": [
|
18
|
+
{
|
19
|
+
"author": "yuanboxue@microsoft.com",
|
20
|
+
"package": "@fluentui/react-utilities",
|
21
|
+
"commit": "17f08ac2e61d5f569067e78832096a54c3966d0b",
|
22
|
+
"comment": "fix: `useOnClickOutside` should invoke callback on clicking scrollbar"
|
23
|
+
}
|
24
|
+
]
|
25
|
+
}
|
26
|
+
},
|
27
|
+
{
|
28
|
+
"date": "Thu, 24 Aug 2023 10:26:34 GMT",
|
6
29
|
"tag": "@fluentui/react-utilities_v9.12.0",
|
7
30
|
"version": "9.12.0",
|
8
31
|
"comments": {
|
package/CHANGELOG.md
CHANGED
@@ -1,12 +1,25 @@
|
|
1
1
|
# Change Log - @fluentui/react-utilities
|
2
2
|
|
3
|
-
This log was last generated on
|
3
|
+
This log was last generated on Tue, 29 Aug 2023 12:53:36 GMT and should not be manually modified.
|
4
4
|
|
5
5
|
<!-- Start content -->
|
6
6
|
|
7
|
+
## [9.13.0](https://github.com/microsoft/fluentui/tree/@fluentui/react-utilities_v9.13.0)
|
8
|
+
|
9
|
+
Tue, 29 Aug 2023 12:53:36 GMT
|
10
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-utilities_v9.12.0..@fluentui/react-utilities_v9.13.0)
|
11
|
+
|
12
|
+
### Minor changes
|
13
|
+
|
14
|
+
- feat: add disabledFocusOnIframe for useOnClickOutside() ([PR #28881](https://github.com/microsoft/fluentui/pull/28881) by olfedias@microsoft.com)
|
15
|
+
|
16
|
+
### Patches
|
17
|
+
|
18
|
+
- fix: `useOnClickOutside` should invoke callback on clicking scrollbar ([PR #28965](https://github.com/microsoft/fluentui/pull/28965) by yuanboxue@microsoft.com)
|
19
|
+
|
7
20
|
## [9.12.0](https://github.com/microsoft/fluentui/tree/@fluentui/react-utilities_v9.12.0)
|
8
21
|
|
9
|
-
Thu, 24 Aug 2023 10:
|
22
|
+
Thu, 24 Aug 2023 10:26:34 GMT
|
10
23
|
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-utilities_v9.11.2..@fluentui/react-utilities_v9.12.0)
|
11
24
|
|
12
25
|
### Minor changes
|
package/dist/index.d.ts
CHANGED
@@ -824,6 +824,10 @@ export declare type UseOnClickOrScrollOutsideOptions = {
|
|
824
824
|
* Disables event listeners
|
825
825
|
*/
|
826
826
|
disabled?: boolean;
|
827
|
+
/**
|
828
|
+
* Disables custom focus event listeners for iframes
|
829
|
+
*/
|
830
|
+
disabledFocusOnIframe?: boolean;
|
827
831
|
/**
|
828
832
|
* Called if the click is outside the element refs
|
829
833
|
*/
|
@@ -1,16 +1,22 @@
|
|
1
1
|
import * as React from 'react';
|
2
2
|
import { useEventCallback } from './useEventCallback';
|
3
|
+
const DEFAULT_CONTAINS = (parent, child)=>{
|
4
|
+
return !!(parent === null || parent === void 0 ? void 0 : parent.contains(child));
|
5
|
+
};
|
3
6
|
/**
|
4
7
|
* @internal
|
5
8
|
* Utility to perform checks where a click/touch event was made outside a component
|
6
9
|
*/ export const useOnClickOutside = (options)=>{
|
7
|
-
const { refs , callback , element , disabled , contains
|
10
|
+
const { refs , callback , element , disabled , disabledFocusOnIframe , contains =DEFAULT_CONTAINS } = options;
|
8
11
|
const timeoutId = React.useRef(undefined);
|
9
|
-
useIFrameFocus(
|
10
|
-
|
11
|
-
|
12
|
-
|
12
|
+
useIFrameFocus({
|
13
|
+
element,
|
14
|
+
disabled: disabledFocusOnIframe || disabled,
|
15
|
+
callback,
|
16
|
+
refs,
|
17
|
+
contains
|
13
18
|
});
|
19
|
+
const isMouseDownInsideRef = React.useRef(false);
|
14
20
|
const listener = useEventCallback((ev)=>{
|
15
21
|
if (isMouseDownInsideRef.current) {
|
16
22
|
isMouseDownInsideRef.current = false;
|
@@ -45,18 +51,16 @@ import { useEventCallback } from './useEventCallback';
|
|
45
51
|
listener(event);
|
46
52
|
};
|
47
53
|
// use capture phase because React can update DOM before the event bubbles to the document
|
48
|
-
element === null || element === void 0 ? void 0 : element.addEventListener('click', conditionalHandler, true);
|
49
54
|
element === null || element === void 0 ? void 0 : element.addEventListener('touchstart', conditionalHandler, true);
|
50
|
-
element === null || element === void 0 ? void 0 : element.addEventListener('
|
55
|
+
element === null || element === void 0 ? void 0 : element.addEventListener('mouseup', conditionalHandler, true);
|
51
56
|
element === null || element === void 0 ? void 0 : element.addEventListener('mousedown', handleMouseDown, true);
|
52
57
|
// Garbage collect this event after it's no longer useful to avoid memory leaks
|
53
58
|
timeoutId.current = window.setTimeout(()=>{
|
54
59
|
currentEvent = undefined;
|
55
60
|
}, 1);
|
56
61
|
return ()=>{
|
57
|
-
element === null || element === void 0 ? void 0 : element.removeEventListener('click', conditionalHandler, true);
|
58
62
|
element === null || element === void 0 ? void 0 : element.removeEventListener('touchstart', conditionalHandler, true);
|
59
|
-
element === null || element === void 0 ? void 0 : element.removeEventListener('
|
63
|
+
element === null || element === void 0 ? void 0 : element.removeEventListener('mouseup', conditionalHandler, true);
|
60
64
|
element === null || element === void 0 ? void 0 : element.removeEventListener('mousedown', handleMouseDown, true);
|
61
65
|
clearTimeout(timeoutId.current);
|
62
66
|
currentEvent = undefined;
|
@@ -92,14 +96,9 @@ const FUI_FRAME_EVENT = 'fuiframefocus';
|
|
92
96
|
* Polls the value of `document.activeElement`. If it is an iframe, then dispatch
|
93
97
|
* a custom DOM event. When the custom event is received call the provided callback
|
94
98
|
*/ const useIFrameFocus = (options)=>{
|
95
|
-
const { disabled , element: targetDocument , callback , contains
|
96
|
-
return !!(parent === null || parent === void 0 ? void 0 : parent.contains(child));
|
97
|
-
} , pollDuration =1000 , refs } = options;
|
99
|
+
const { disabled , element: targetDocument , callback , contains =DEFAULT_CONTAINS , pollDuration =1000 , refs } = options;
|
98
100
|
const timeoutRef = React.useRef();
|
99
101
|
const listener = useEventCallback((e)=>{
|
100
|
-
const contains = containsProp || ((parent, child)=>{
|
101
|
-
return !!(parent === null || parent === void 0 ? void 0 : parent.contains(child));
|
102
|
-
});
|
103
102
|
const isOutside = refs.every((ref)=>!contains(ref.current || null, e.target));
|
104
103
|
if (isOutside && !disabled) {
|
105
104
|
callback(e);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["useOnClickOutside.ts"],"sourcesContent":["import * as React from 'react';\nimport { useEventCallback } from './useEventCallback';\n\n/**\n * @internal\n */\nexport type UseOnClickOrScrollOutsideOptions = {\n /**\n * The element to listen for the click event\n */\n element: Document | undefined;\n /**\n * Refs to elements that check if the click is outside\n */\n refs: React.MutableRefObject<HTMLElement | undefined | null>[];\n\n /**\n * By default uses element.contains, but custom contain function can be provided\n *\n * @param parent - provided parent element\n * @param child - event target element\n */\n contains?(parent: HTMLElement | null, child: HTMLElement): boolean;\n\n /**\n * Disables event listeners\n */\n disabled?: boolean;\n\n /**\n * Called if the click is outside the element refs\n */\n callback: (ev: MouseEvent | TouchEvent) => void;\n};\n\n/**\n * @internal\n * Utility to perform checks where a click/touch event was made outside a component\n */\nexport const useOnClickOutside = (options: UseOnClickOrScrollOutsideOptions) => {\n const { refs, callback, element, disabled, contains: containsProp } = options;\n const timeoutId = React.useRef<number | undefined>(undefined);\n useIFrameFocus(options);\n\n const isMouseDownInsideRef = React.useRef(false);\n\n const contains: UseOnClickOrScrollOutsideOptions['contains'] =\n containsProp || ((parent, child) => !!parent?.contains(child));\n\n const listener = useEventCallback((ev: MouseEvent | TouchEvent) => {\n if (isMouseDownInsideRef.current) {\n isMouseDownInsideRef.current = false;\n return;\n }\n\n const target = ev.composedPath()[0] as HTMLElement;\n const isOutside = refs.every(ref => !contains(ref.current || null, target));\n\n if (isOutside && !disabled) {\n callback(ev);\n }\n });\n\n const handleMouseDown = useEventCallback((ev: MouseEvent) => {\n // Selecting text from inside to outside will rigger click event.\n // In this case click event target is outside but mouse down event target is inside.\n // And this click event should be considered as inside click.\n isMouseDownInsideRef.current = refs.some(ref => contains(ref.current || null, ev.target as HTMLElement));\n });\n\n React.useEffect(() => {\n if (disabled) {\n return;\n }\n\n // Store the current event to avoid triggering handlers immediately\n // Note this depends on a deprecated but extremely well supported quirk of the web platform\n // https://github.com/facebook/react/issues/20074\n let currentEvent = getWindowEvent(window);\n\n const conditionalHandler = (event: MouseEvent | TouchEvent) => {\n // Skip if this event is the same as the one running when we added the handlers\n if (event === currentEvent) {\n currentEvent = undefined;\n return;\n }\n\n listener(event);\n };\n\n // use capture phase because React can update DOM before the event bubbles to the document\n element?.addEventListener('click', conditionalHandler, true);\n element?.addEventListener('touchstart', conditionalHandler, true);\n element?.addEventListener('contextmenu', conditionalHandler, true);\n element?.addEventListener('mousedown', handleMouseDown, true);\n\n // Garbage collect this event after it's no longer useful to avoid memory leaks\n timeoutId.current = window.setTimeout(() => {\n currentEvent = undefined;\n }, 1);\n\n return () => {\n element?.removeEventListener('click', conditionalHandler, true);\n element?.removeEventListener('touchstart', conditionalHandler, true);\n element?.removeEventListener('contextmenu', conditionalHandler, true);\n element?.removeEventListener('mousedown', handleMouseDown, true);\n\n clearTimeout(timeoutId.current);\n currentEvent = undefined;\n };\n }, [listener, element, disabled, handleMouseDown]);\n};\n\nconst getWindowEvent = (target: Node | Window): Event | undefined => {\n if (target) {\n if (typeof (target as Window).window === 'object' && (target as Window).window === target) {\n // eslint-disable-next-line deprecation/deprecation\n return target.event;\n }\n\n // eslint-disable-next-line deprecation/deprecation\n return (target as Node).ownerDocument?.defaultView?.event ?? undefined;\n }\n\n return undefined;\n};\n\nconst FUI_FRAME_EVENT = 'fuiframefocus';\n\ninterface UseIFrameFocusOptions extends UseOnClickOrScrollOutsideOptions {\n /**\n * Millisecond duration to poll\n */\n pollDuration?: number;\n}\n\n/**\n * Since click events do not propagate past iframes, we use focus to detect if a\n * click has happened inside an iframe, since the only ways of focusing inside an\n * iframe are:\n * - clicking inside\n * - tabbing inside\n *\n * Polls the value of `document.activeElement`. If it is an iframe, then dispatch\n * a custom DOM event. When the custom event is received call the provided callback\n */\nconst useIFrameFocus = (options: UseIFrameFocusOptions) => {\n const {\n disabled,\n element: targetDocument,\n callback,\n contains: containsProp = (parent, child) => !!parent?.contains(child),\n pollDuration = 1000,\n refs,\n } = options;\n const timeoutRef = React.useRef<number>();\n\n const listener = useEventCallback((e: Event) => {\n const contains = containsProp || ((parent, child) => !!parent?.contains(child));\n\n const isOutside = refs.every(ref => !contains(ref.current || null, e.target as HTMLElement));\n if (isOutside && !disabled) {\n callback(e as MouseEvent);\n }\n });\n\n // Adds listener to the custom iframe focus event\n React.useEffect(() => {\n if (disabled) {\n return;\n }\n\n targetDocument?.addEventListener(FUI_FRAME_EVENT, listener, true);\n\n return () => {\n targetDocument?.removeEventListener(FUI_FRAME_EVENT, listener, true);\n };\n }, [targetDocument, disabled, listener]);\n\n // Starts polling for the active element\n React.useEffect(() => {\n if (disabled) {\n return;\n }\n\n timeoutRef.current = targetDocument?.defaultView?.setInterval(() => {\n const activeElement = targetDocument?.activeElement;\n\n if (activeElement?.tagName === 'IFRAME' || activeElement?.tagName === 'WEBVIEW') {\n const event = new CustomEvent(FUI_FRAME_EVENT, { bubbles: true });\n activeElement.dispatchEvent(event);\n }\n }, pollDuration);\n\n return () => {\n targetDocument?.defaultView?.clearTimeout(timeoutRef.current);\n };\n }, [targetDocument, disabled, pollDuration]);\n};\n"],"names":["React","useEventCallback","useOnClickOutside","options","refs","callback","element","disabled","contains","containsProp","timeoutId","useRef","undefined","useIFrameFocus","isMouseDownInsideRef","parent","child","listener","ev","current","target","composedPath","isOutside","every","ref","handleMouseDown","some","useEffect","currentEvent","getWindowEvent","window","conditionalHandler","event","addEventListener","setTimeout","removeEventListener","clearTimeout","ownerDocument","defaultView","FUI_FRAME_EVENT","targetDocument","pollDuration","timeoutRef","e","setInterval","activeElement","tagName","CustomEvent","bubbles","dispatchEvent"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,gBAAgB,QAAQ,qBAAqB;AAkCtD;;;CAGC,GACD,OAAO,MAAMC,oBAAoB,CAACC,UAA8C;IAC9E,MAAM,EAAEC,KAAI,EAAEC,SAAQ,EAAEC,QAAO,EAAEC,SAAQ,EAAEC,UAAUC,aAAY,EAAE,GAAGN;IACtE,MAAMO,YAAYV,MAAMW,MAAM,CAAqBC;IACnDC,eAAeV;IAEf,MAAMW,uBAAuBd,MAAMW,MAAM,CAAC,KAAK;IAE/C,MAAMH,WACJC,gBAAiB,CAAA,CAACM,QAAQC;QAAU,OAAA,CAAC,EAACD,mBAAAA,oBAAAA,KAAAA,IAAAA,OAAQP,QAAQ,CAACQ;KAAK;IAE9D,MAAMC,WAAWhB,iBAAiB,CAACiB,KAAgC;QACjE,IAAIJ,qBAAqBK,OAAO,EAAE;YAChCL,qBAAqBK,OAAO,GAAG,KAAK;YACpC;QACF,CAAC;QAED,MAAMC,SAASF,GAAGG,YAAY,EAAE,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A,eAAgBF,WAAW,cAA3BE,yCAAAA,KAAAA,IAAAA,4BAA6BJ,aAAaM,WAAWvB,OAAO;QAC9D;IACF,GAAG;QAACqB;QAAgBjC;QAAUkC;KAAa;AAC7C"}
|
1
|
+
{"version":3,"sources":["useOnClickOutside.ts"],"sourcesContent":["import * as React from 'react';\nimport { useEventCallback } from './useEventCallback';\n\n/**\n * @internal\n */\nexport type UseOnClickOrScrollOutsideOptions = {\n /**\n * The element to listen for the click event\n */\n element: Document | undefined;\n /**\n * Refs to elements that check if the click is outside\n */\n refs: React.MutableRefObject<HTMLElement | undefined | null>[];\n\n /**\n * By default uses element.contains, but custom contain function can be provided\n *\n * @param parent - provided parent element\n * @param child - event target element\n */\n contains?(parent: HTMLElement | null, child: HTMLElement): boolean;\n\n /**\n * Disables event listeners\n */\n disabled?: boolean;\n\n /**\n * Disables custom focus event listeners for iframes\n */\n disabledFocusOnIframe?: boolean;\n\n /**\n * Called if the click is outside the element refs\n */\n callback: (ev: MouseEvent | TouchEvent) => void;\n};\n\nconst DEFAULT_CONTAINS: UseOnClickOrScrollOutsideOptions['contains'] = (parent, child) => !!parent?.contains(child);\n\n/**\n * @internal\n * Utility to perform checks where a click/touch event was made outside a component\n */\nexport const useOnClickOutside = (options: UseOnClickOrScrollOutsideOptions) => {\n const { refs, callback, element, disabled, disabledFocusOnIframe, contains = DEFAULT_CONTAINS } = options;\n const timeoutId = React.useRef<number | undefined>(undefined);\n\n useIFrameFocus({ element, disabled: disabledFocusOnIframe || disabled, callback, refs, contains });\n\n const isMouseDownInsideRef = React.useRef(false);\n const listener = useEventCallback((ev: MouseEvent | TouchEvent) => {\n if (isMouseDownInsideRef.current) {\n isMouseDownInsideRef.current = false;\n return;\n }\n\n const target = ev.composedPath()[0] as HTMLElement;\n const isOutside = refs.every(ref => !contains(ref.current || null, target));\n\n if (isOutside && !disabled) {\n callback(ev);\n }\n });\n\n const handleMouseDown = useEventCallback((ev: MouseEvent) => {\n // Selecting text from inside to outside will rigger click event.\n // In this case click event target is outside but mouse down event target is inside.\n // And this click event should be considered as inside click.\n isMouseDownInsideRef.current = refs.some(ref => contains(ref.current || null, ev.target as HTMLElement));\n });\n\n React.useEffect(() => {\n if (disabled) {\n return;\n }\n\n // Store the current event to avoid triggering handlers immediately\n // Note this depends on a deprecated but extremely well supported quirk of the web platform\n // https://github.com/facebook/react/issues/20074\n let currentEvent = getWindowEvent(window);\n\n const conditionalHandler = (event: MouseEvent | TouchEvent) => {\n // Skip if this event is the same as the one running when we added the handlers\n if (event === currentEvent) {\n currentEvent = undefined;\n return;\n }\n\n listener(event);\n };\n\n // use capture phase because React can update DOM before the event bubbles to the document\n element?.addEventListener('touchstart', conditionalHandler, true);\n element?.addEventListener('mouseup', conditionalHandler, true);\n element?.addEventListener('mousedown', handleMouseDown, true);\n\n // Garbage collect this event after it's no longer useful to avoid memory leaks\n timeoutId.current = window.setTimeout(() => {\n currentEvent = undefined;\n }, 1);\n\n return () => {\n element?.removeEventListener('touchstart', conditionalHandler, true);\n element?.removeEventListener('mouseup', conditionalHandler, true);\n element?.removeEventListener('mousedown', handleMouseDown, true);\n\n clearTimeout(timeoutId.current);\n currentEvent = undefined;\n };\n }, [listener, element, disabled, handleMouseDown]);\n};\n\nconst getWindowEvent = (target: Node | Window): Event | undefined => {\n if (target) {\n if (typeof (target as Window).window === 'object' && (target as Window).window === target) {\n // eslint-disable-next-line deprecation/deprecation\n return target.event;\n }\n\n // eslint-disable-next-line deprecation/deprecation\n return (target as Node).ownerDocument?.defaultView?.event ?? undefined;\n }\n\n return undefined;\n};\n\nconst FUI_FRAME_EVENT = 'fuiframefocus';\n\ninterface UseIFrameFocusOptions\n extends Pick<UseOnClickOrScrollOutsideOptions, 'disabled' | 'element' | 'callback' | 'contains' | 'refs'> {\n /**\n * Millisecond duration to poll\n */\n pollDuration?: number;\n}\n\n/**\n * Since click events do not propagate past iframes, we use focus to detect if a\n * click has happened inside an iframe, since the only ways of focusing inside an\n * iframe are:\n * - clicking inside\n * - tabbing inside\n *\n * Polls the value of `document.activeElement`. If it is an iframe, then dispatch\n * a custom DOM event. When the custom event is received call the provided callback\n */\nconst useIFrameFocus = (options: UseIFrameFocusOptions) => {\n const {\n disabled,\n element: targetDocument,\n callback,\n contains = DEFAULT_CONTAINS,\n pollDuration = 1000,\n refs,\n } = options;\n const timeoutRef = React.useRef<number>();\n\n const listener = useEventCallback((e: Event) => {\n const isOutside = refs.every(ref => !contains(ref.current || null, e.target as HTMLElement));\n\n if (isOutside && !disabled) {\n callback(e as MouseEvent);\n }\n });\n\n // Adds listener to the custom iframe focus event\n React.useEffect(() => {\n if (disabled) {\n return;\n }\n\n targetDocument?.addEventListener(FUI_FRAME_EVENT, listener, true);\n\n return () => {\n targetDocument?.removeEventListener(FUI_FRAME_EVENT, listener, true);\n };\n }, [targetDocument, disabled, listener]);\n\n // Starts polling for the active element\n React.useEffect(() => {\n if (disabled) {\n return;\n }\n\n timeoutRef.current = targetDocument?.defaultView?.setInterval(() => {\n const activeElement = targetDocument?.activeElement;\n\n if (activeElement?.tagName === 'IFRAME' || activeElement?.tagName === 'WEBVIEW') {\n const event = new CustomEvent(FUI_FRAME_EVENT, { bubbles: true });\n activeElement.dispatchEvent(event);\n }\n }, pollDuration);\n\n return () => {\n targetDocument?.defaultView?.clearTimeout(timeoutRef.current);\n };\n }, [targetDocument, disabled, pollDuration]);\n};\n"],"names":["React","useEventCallback","DEFAULT_CONTAINS","parent","child","contains","useOnClickOutside","options","refs","callback","element","disabled","disabledFocusOnIframe","timeoutId","useRef","undefined","useIFrameFocus","isMouseDownInsideRef","listener","ev","current","target","composedPath","isOutside","every","ref","handleMouseDown","some","useEffect","currentEvent","getWindowEvent","window","conditionalHandler","event","addEventListener","setTimeout","removeEventListener","clearTimeout","ownerDocument","defaultView","FUI_FRAME_EVENT","targetDocument","pollDuration","timeoutRef","e","setInterval","activeElement","tagName","CustomEvent","bubbles","dispatchEvent"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SA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,IAAAA,cAAeC,OAAO,AAAD,MAAM,WAAW;gBAC/E,MAAMd,QAAQ,IAAIe,YAAYR,iBAAiB;oBAAES,SAAS,IAAI;gBAAC;gBAC/DH,cAAcI,aAAa,CAACjB;YAC9B,CAAC;QACH,GAAGS;QAEH,OAAO,IAAM;gBACXD;YAAAA,2BAAAA,4BAAAA,KAAAA,IAAAA,CAAAA,8BAAAA,eAAgBF,WAAW,cAA3BE,yCAAAA,KAAAA,IAAAA,4BAA6BJ,aAAaM,WAAWvB,OAAO;QAC9D;IACF,GAAG;QAACqB;QAAgB9B;QAAU+B;KAAa;AAC7C"}
|
@@ -9,14 +9,20 @@ Object.defineProperty(exports, "useOnClickOutside", {
|
|
9
9
|
const _interopRequireWildcard = require("@swc/helpers/lib/_interop_require_wildcard.js").default;
|
10
10
|
const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
|
11
11
|
const _useEventCallback = require("./useEventCallback");
|
12
|
+
const DEFAULT_CONTAINS = (parent, child)=>{
|
13
|
+
return !!(parent === null || parent === void 0 ? void 0 : parent.contains(child));
|
14
|
+
};
|
12
15
|
const useOnClickOutside = (options)=>{
|
13
|
-
const { refs , callback , element , disabled , contains
|
16
|
+
const { refs , callback , element , disabled , disabledFocusOnIframe , contains =DEFAULT_CONTAINS } = options;
|
14
17
|
const timeoutId = _react.useRef(undefined);
|
15
|
-
useIFrameFocus(
|
16
|
-
|
17
|
-
|
18
|
-
|
18
|
+
useIFrameFocus({
|
19
|
+
element,
|
20
|
+
disabled: disabledFocusOnIframe || disabled,
|
21
|
+
callback,
|
22
|
+
refs,
|
23
|
+
contains
|
19
24
|
});
|
25
|
+
const isMouseDownInsideRef = _react.useRef(false);
|
20
26
|
const listener = (0, _useEventCallback.useEventCallback)((ev)=>{
|
21
27
|
if (isMouseDownInsideRef.current) {
|
22
28
|
isMouseDownInsideRef.current = false;
|
@@ -51,18 +57,16 @@ const useOnClickOutside = (options)=>{
|
|
51
57
|
listener(event);
|
52
58
|
};
|
53
59
|
// use capture phase because React can update DOM before the event bubbles to the document
|
54
|
-
element === null || element === void 0 ? void 0 : element.addEventListener('click', conditionalHandler, true);
|
55
60
|
element === null || element === void 0 ? void 0 : element.addEventListener('touchstart', conditionalHandler, true);
|
56
|
-
element === null || element === void 0 ? void 0 : element.addEventListener('
|
61
|
+
element === null || element === void 0 ? void 0 : element.addEventListener('mouseup', conditionalHandler, true);
|
57
62
|
element === null || element === void 0 ? void 0 : element.addEventListener('mousedown', handleMouseDown, true);
|
58
63
|
// Garbage collect this event after it's no longer useful to avoid memory leaks
|
59
64
|
timeoutId.current = window.setTimeout(()=>{
|
60
65
|
currentEvent = undefined;
|
61
66
|
}, 1);
|
62
67
|
return ()=>{
|
63
|
-
element === null || element === void 0 ? void 0 : element.removeEventListener('click', conditionalHandler, true);
|
64
68
|
element === null || element === void 0 ? void 0 : element.removeEventListener('touchstart', conditionalHandler, true);
|
65
|
-
element === null || element === void 0 ? void 0 : element.removeEventListener('
|
69
|
+
element === null || element === void 0 ? void 0 : element.removeEventListener('mouseup', conditionalHandler, true);
|
66
70
|
element === null || element === void 0 ? void 0 : element.removeEventListener('mousedown', handleMouseDown, true);
|
67
71
|
clearTimeout(timeoutId.current);
|
68
72
|
currentEvent = undefined;
|
@@ -98,14 +102,9 @@ const FUI_FRAME_EVENT = 'fuiframefocus';
|
|
98
102
|
* Polls the value of `document.activeElement`. If it is an iframe, then dispatch
|
99
103
|
* a custom DOM event. When the custom event is received call the provided callback
|
100
104
|
*/ const useIFrameFocus = (options)=>{
|
101
|
-
const { disabled , element: targetDocument , callback , contains
|
102
|
-
return !!(parent === null || parent === void 0 ? void 0 : parent.contains(child));
|
103
|
-
} , pollDuration =1000 , refs } = options;
|
105
|
+
const { disabled , element: targetDocument , callback , contains =DEFAULT_CONTAINS , pollDuration =1000 , refs } = options;
|
104
106
|
const timeoutRef = _react.useRef();
|
105
107
|
const listener = (0, _useEventCallback.useEventCallback)((e)=>{
|
106
|
-
const contains = containsProp || ((parent, child)=>{
|
107
|
-
return !!(parent === null || parent === void 0 ? void 0 : parent.contains(child));
|
108
|
-
});
|
109
108
|
const isOutside = refs.every((ref)=>!contains(ref.current || null, e.target));
|
110
109
|
if (isOutside && !disabled) {
|
111
110
|
callback(e);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["useOnClickOutside.js"],"sourcesContent":["import * as React from 'react';\nimport { useEventCallback } from './useEventCallback';\n/**\n * @internal\n * Utility to perform checks where a click/touch event was made outside a component\n */ export const useOnClickOutside = (options)=>{\n const { refs , callback , element , disabled , contains: containsProp } = options;\n const timeoutId = React.useRef(undefined);\n useIFrameFocus(options);\n const isMouseDownInsideRef = React.useRef(false);\n const contains = containsProp || ((parent, child)=>{\n return !!(parent === null || parent === void 0 ? void 0 : parent.contains(child));\n });\n const listener = useEventCallback((ev)=>{\n if (isMouseDownInsideRef.current) {\n isMouseDownInsideRef.current = false;\n return;\n }\n const target = ev.composedPath()[0];\n const isOutside = refs.every((ref)=>!contains(ref.current || null, target));\n if (isOutside && !disabled) {\n callback(ev);\n }\n });\n const handleMouseDown = useEventCallback((ev)=>{\n // Selecting text from inside to outside will rigger click event.\n // In this case click event target is outside but mouse down event target is inside.\n // And this click event should be considered as inside click.\n isMouseDownInsideRef.current = refs.some((ref)=>contains(ref.current || null, ev.target));\n });\n React.useEffect(()=>{\n if (disabled) {\n return;\n }\n // Store the current event to avoid triggering handlers immediately\n // Note this depends on a deprecated but extremely well supported quirk of the web platform\n // https://github.com/facebook/react/issues/20074\n let currentEvent = getWindowEvent(window);\n const conditionalHandler = (event)=>{\n // Skip if this event is the same as the one running when we added the handlers\n if (event === currentEvent) {\n currentEvent = undefined;\n return;\n }\n listener(event);\n };\n // use capture phase because React can update DOM before the event bubbles to the document\n element === null || element === void 0 ? void 0 : element.addEventListener('click', conditionalHandler, true);\n element === null || element === void 0 ? void 0 : element.addEventListener('touchstart', conditionalHandler, true);\n element === null || element === void 0 ? void 0 : element.addEventListener('contextmenu', conditionalHandler, true);\n element === null || element === void 0 ? void 0 : element.addEventListener('mousedown', handleMouseDown, true);\n // Garbage collect this event after it's no longer useful to avoid memory leaks\n timeoutId.current = window.setTimeout(()=>{\n currentEvent = undefined;\n }, 1);\n return ()=>{\n element === null || element === void 0 ? void 0 : element.removeEventListener('click', conditionalHandler, true);\n element === null || element === void 0 ? void 0 : element.removeEventListener('touchstart', conditionalHandler, true);\n element === null || element === void 0 ? void 0 : element.removeEventListener('contextmenu', conditionalHandler, true);\n element === null || element === void 0 ? void 0 : element.removeEventListener('mousedown', handleMouseDown, true);\n clearTimeout(timeoutId.current);\n currentEvent = undefined;\n };\n }, [\n listener,\n element,\n disabled,\n handleMouseDown\n ]);\n};\nconst getWindowEvent = (target)=>{\n if (target) {\n var _target_ownerDocument, _target_ownerDocument_defaultView;\n if (typeof target.window === 'object' && target.window === target) {\n // eslint-disable-next-line deprecation/deprecation\n return target.event;\n }\n var _target_ownerDocument_defaultView_event;\n // eslint-disable-next-line deprecation/deprecation\n return (_target_ownerDocument_defaultView_event = (_target_ownerDocument = target.ownerDocument) === null || _target_ownerDocument === void 0 ? void 0 : (_target_ownerDocument_defaultView = _target_ownerDocument.defaultView) === null || _target_ownerDocument_defaultView === void 0 ? void 0 : _target_ownerDocument_defaultView.event) !== null && _target_ownerDocument_defaultView_event !== void 0 ? _target_ownerDocument_defaultView_event : undefined;\n }\n return undefined;\n};\nconst FUI_FRAME_EVENT = 'fuiframefocus';\n/**\n * Since click events do not propagate past iframes, we use focus to detect if a\n * click has happened inside an iframe, since the only ways of focusing inside an\n * iframe are:\n * - clicking inside\n * - tabbing inside\n *\n * Polls the value of `document.activeElement`. If it is an iframe, then dispatch\n * a custom DOM event. When the custom event is received call the provided callback\n */ const useIFrameFocus = (options)=>{\n const { disabled , element: targetDocument , callback , contains: containsProp = (parent, child)=>{\n return !!(parent === null || parent === void 0 ? void 0 : parent.contains(child));\n } , pollDuration =1000 , refs } = options;\n const timeoutRef = React.useRef();\n const listener = useEventCallback((e)=>{\n const contains = containsProp || ((parent, child)=>{\n return !!(parent === null || parent === void 0 ? void 0 : parent.contains(child));\n });\n const isOutside = refs.every((ref)=>!contains(ref.current || null, e.target));\n if (isOutside && !disabled) {\n callback(e);\n }\n });\n // Adds listener to the custom iframe focus event\n React.useEffect(()=>{\n if (disabled) {\n return;\n }\n targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.addEventListener(FUI_FRAME_EVENT, listener, true);\n return ()=>{\n targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.removeEventListener(FUI_FRAME_EVENT, listener, true);\n };\n }, [\n targetDocument,\n disabled,\n listener\n ]);\n // Starts polling for the active element\n React.useEffect(()=>{\n var _targetDocument_defaultView;\n if (disabled) {\n return;\n }\n timeoutRef.current = targetDocument === null || targetDocument === void 0 ? void 0 : (_targetDocument_defaultView = targetDocument.defaultView) === null || _targetDocument_defaultView === void 0 ? void 0 : _targetDocument_defaultView.setInterval(()=>{\n const activeElement = targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.activeElement;\n if ((activeElement === null || activeElement === void 0 ? void 0 : activeElement.tagName) === 'IFRAME' || (activeElement === null || activeElement === void 0 ? void 0 : activeElement.tagName) === 'WEBVIEW') {\n const event = new CustomEvent(FUI_FRAME_EVENT, {\n bubbles: true\n });\n activeElement.dispatchEvent(event);\n }\n }, pollDuration);\n return ()=>{\n var _targetDocument_defaultView;\n targetDocument === null || targetDocument === void 0 ? void 0 : (_targetDocument_defaultView = targetDocument.defaultView) === null || _targetDocument_defaultView === void 0 ? void 0 : _targetDocument_defaultView.clearTimeout(timeoutRef.current);\n };\n }, [\n targetDocument,\n disabled,\n pollDuration\n ]);\n};\n"],"names":["useOnClickOutside","options","refs","callback","element","disabled","contains","containsProp","timeoutId","React","useRef","undefined","useIFrameFocus","isMouseDownInsideRef","parent","child","listener","useEventCallback","ev","current","target","composedPath","isOutside","every","ref","handleMouseDown","some","useEffect","currentEvent","getWindowEvent","window","conditionalHandler","event","addEventListener","setTimeout","removeEventListener","clearTimeout","_target_ownerDocument","_target_ownerDocument_defaultView","_target_ownerDocument_defaultView_event","ownerDocument","defaultView","FUI_FRAME_EVENT","targetDocument","pollDuration","timeoutRef","e","_targetDocument_defaultView","setInterval","activeElement","tagName","CustomEvent","bubbles","dispatchEvent"],"mappings":";;;;+BAKiBA;;aAAAA;;;6DALM;kCACU;AAItB,MAAMA,oBAAoB,CAACC,UAAU;IAC5C,MAAM,EAAEC,KAAI,EAAGC,SAAQ,EAAGC,QAAO,EAAGC,SAAQ,EAAGC,UAAUC,aAAY,EAAG,GAAGN;IAC3E,MAAMO,YAAYC,OAAMC,MAAM,CAACC;IAC/BC,eAAeX;IACf,MAAMY,uBAAuBJ,OAAMC,MAAM,CAAC,KAAK;IAC/C,MAAMJ,WAAWC,gBAAiB,CAAA,CAACO,QAAQC,QAAQ;QAC/C,OAAO,CAAC,CAAED,CAAAA,WAAW,IAAI,IAAIA,WAAW,KAAK,IAAI,KAAK,IAAIA,OAAOR,QAAQ,CAACS,MAAM,AAAD;IACnF,CAAA;IACA,MAAMC,WAAWC,IAAAA,kCAAgB,EAAC,CAACC,KAAK;QACpC,IAAIL,qBAAqBM,OAAO,EAAE;YAC9BN,qBAAqBM,OAAO,GAAG,KAAK;YACpC;QACJ,CAAC;QACD,MAAMC,SAASF,GAAGG,YAAY,EAAE,CAAC,EAAE;QACnC,MAAMC,YAAYpB,KAAKqB,KAAK,CAAC,CAACC,MAAM,CAAClB,SAASkB,IAAIL,OAAO,IAAI,IAAI,EAAEC;QACnE,IAAIE,aAAa,CAACjB,UAAU;YACxBF,SAASe;QACb,CAAC;IACL;IACA,MAAMO,kBAAkBR,IAAAA,kCAAgB,EAAC,CAACC,KAAK;QAC3C,iEAAiE;QACjE,oFAAoF;QACpF,6DAA6D;QAC7DL,qBAAqBM,OAAO,GAAGjB,KAAKwB,IAAI,CAAC,CAACF,MAAMlB,SAASkB,IAAIL,OAAO,IAAI,IAAI,EAAED,GAAGE,MAAM;IAC3F;IACA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AK,IAAI,KAAK,IAAIA,cAAcC,OAAO,AAAD,MAAO,WAAW;gBAC3M,MAAMlB,QAAQ,IAAImB,YAAYT,iBAAiB;oBAC3CU,SAAS,IAAI;gBACjB;gBACAH,cAAcI,aAAa,CAACrB;YAChC,CAAC;QACL,GAAGY,aAAa;QAChB,OAAO,IAAI;YACP,IAAIG;YACJJ,mBAAmB,IAAI,IAAIA,mBAAmB,KAAK,IAAI,KAAK,IAAI,AAACI,CAAAA,8BAA8BJ,eAAeF,WAAW,AAAD,MAAO,IAAI,IAAIM,gCAAgC,KAAK,IAAI,KAAK,IAAIA,4BAA4BX,YAAY,CAACS,WAAW1B,OAAO,CAAC;QACzP;IACJ,GAAG;QACCwB;QACAtC;QACAuC;KACH;AACL"}
|
1
|
+
{"version":3,"sources":["useOnClickOutside.js"],"sourcesContent":["import * as React from 'react';\nimport { useEventCallback } from './useEventCallback';\nconst DEFAULT_CONTAINS = (parent, child)=>{\n return !!(parent === null || parent === void 0 ? void 0 : parent.contains(child));\n};\n/**\n * @internal\n * Utility to perform checks where a click/touch event was made outside a component\n */ export const useOnClickOutside = (options)=>{\n const { refs , callback , element , disabled , disabledFocusOnIframe , contains =DEFAULT_CONTAINS } = options;\n const timeoutId = React.useRef(undefined);\n useIFrameFocus({\n element,\n disabled: disabledFocusOnIframe || disabled,\n callback,\n refs,\n contains\n });\n const isMouseDownInsideRef = React.useRef(false);\n const listener = useEventCallback((ev)=>{\n if (isMouseDownInsideRef.current) {\n isMouseDownInsideRef.current = false;\n return;\n }\n const target = ev.composedPath()[0];\n const isOutside = refs.every((ref)=>!contains(ref.current || null, target));\n if (isOutside && !disabled) {\n callback(ev);\n }\n });\n const handleMouseDown = useEventCallback((ev)=>{\n // Selecting text from inside to outside will rigger click event.\n // In this case click event target is outside but mouse down event target is inside.\n // And this click event should be considered as inside click.\n isMouseDownInsideRef.current = refs.some((ref)=>contains(ref.current || null, ev.target));\n });\n React.useEffect(()=>{\n if (disabled) {\n return;\n }\n // Store the current event to avoid triggering handlers immediately\n // Note this depends on a deprecated but extremely well supported quirk of the web platform\n // https://github.com/facebook/react/issues/20074\n let currentEvent = getWindowEvent(window);\n const conditionalHandler = (event)=>{\n // Skip if this event is the same as the one running when we added the handlers\n if (event === currentEvent) {\n currentEvent = undefined;\n return;\n }\n listener(event);\n };\n // use capture phase because React can update DOM before the event bubbles to the document\n element === null || element === void 0 ? void 0 : element.addEventListener('touchstart', conditionalHandler, true);\n element === null || element === void 0 ? void 0 : element.addEventListener('mouseup', conditionalHandler, true);\n element === null || element === void 0 ? void 0 : element.addEventListener('mousedown', handleMouseDown, true);\n // Garbage collect this event after it's no longer useful to avoid memory leaks\n timeoutId.current = window.setTimeout(()=>{\n currentEvent = undefined;\n }, 1);\n return ()=>{\n element === null || element === void 0 ? void 0 : element.removeEventListener('touchstart', conditionalHandler, true);\n element === null || element === void 0 ? void 0 : element.removeEventListener('mouseup', conditionalHandler, true);\n element === null || element === void 0 ? void 0 : element.removeEventListener('mousedown', handleMouseDown, true);\n clearTimeout(timeoutId.current);\n currentEvent = undefined;\n };\n }, [\n listener,\n element,\n disabled,\n handleMouseDown\n ]);\n};\nconst getWindowEvent = (target)=>{\n if (target) {\n var _target_ownerDocument, _target_ownerDocument_defaultView;\n if (typeof target.window === 'object' && target.window === target) {\n // eslint-disable-next-line deprecation/deprecation\n return target.event;\n }\n var _target_ownerDocument_defaultView_event;\n // eslint-disable-next-line deprecation/deprecation\n return (_target_ownerDocument_defaultView_event = (_target_ownerDocument = target.ownerDocument) === null || _target_ownerDocument === void 0 ? void 0 : (_target_ownerDocument_defaultView = _target_ownerDocument.defaultView) === null || _target_ownerDocument_defaultView === void 0 ? void 0 : _target_ownerDocument_defaultView.event) !== null && _target_ownerDocument_defaultView_event !== void 0 ? _target_ownerDocument_defaultView_event : undefined;\n }\n return undefined;\n};\nconst FUI_FRAME_EVENT = 'fuiframefocus';\n/**\n * Since click events do not propagate past iframes, we use focus to detect if a\n * click has happened inside an iframe, since the only ways of focusing inside an\n * iframe are:\n * - clicking inside\n * - tabbing inside\n *\n * Polls the value of `document.activeElement`. If it is an iframe, then dispatch\n * a custom DOM event. When the custom event is received call the provided callback\n */ const useIFrameFocus = (options)=>{\n const { disabled , element: targetDocument , callback , contains =DEFAULT_CONTAINS , pollDuration =1000 , refs } = options;\n const timeoutRef = React.useRef();\n const listener = useEventCallback((e)=>{\n const isOutside = refs.every((ref)=>!contains(ref.current || null, e.target));\n if (isOutside && !disabled) {\n callback(e);\n }\n });\n // Adds listener to the custom iframe focus event\n React.useEffect(()=>{\n if (disabled) {\n return;\n }\n targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.addEventListener(FUI_FRAME_EVENT, listener, true);\n return ()=>{\n targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.removeEventListener(FUI_FRAME_EVENT, listener, true);\n };\n }, [\n targetDocument,\n disabled,\n listener\n ]);\n // Starts polling for the active element\n React.useEffect(()=>{\n var _targetDocument_defaultView;\n if (disabled) {\n return;\n }\n timeoutRef.current = targetDocument === null || targetDocument === void 0 ? void 0 : (_targetDocument_defaultView = targetDocument.defaultView) === null || _targetDocument_defaultView === void 0 ? void 0 : _targetDocument_defaultView.setInterval(()=>{\n const activeElement = targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.activeElement;\n if ((activeElement === null || activeElement === void 0 ? void 0 : activeElement.tagName) === 'IFRAME' || (activeElement === null || activeElement === void 0 ? void 0 : activeElement.tagName) === 'WEBVIEW') {\n const event = new CustomEvent(FUI_FRAME_EVENT, {\n bubbles: true\n });\n activeElement.dispatchEvent(event);\n }\n }, pollDuration);\n return ()=>{\n var _targetDocument_defaultView;\n targetDocument === null || targetDocument === void 0 ? void 0 : (_targetDocument_defaultView = targetDocument.defaultView) === null || _targetDocument_defaultView === void 0 ? void 0 : _targetDocument_defaultView.clearTimeout(timeoutRef.current);\n };\n }, [\n targetDocument,\n disabled,\n pollDuration\n ]);\n};\n"],"names":["useOnClickOutside","DEFAULT_CONTAINS","parent","child","contains","options","refs","callback","element","disabled","disabledFocusOnIframe","timeoutId","React","useRef","undefined","useIFrameFocus","isMouseDownInsideRef","listener","useEventCallback","ev","current","target","composedPath","isOutside","every","ref","handleMouseDown","some","useEffect","currentEvent","getWindowEvent","window","conditionalHandler","event","addEventListener","setTimeout","removeEventListener","clearTimeout","_target_ownerDocument","_target_ownerDocument_defaultView","_target_ownerDocument_defaultView_event","ownerDocument","defaultView","FUI_FRAME_EVENT","targetDocument","pollDuration","timeoutRef","e","_targetDocument_defaultView","setInterval","activeElement","tagName","CustomEvent","bubbles","dispatchEvent"],"mappings":";;;;+BAQiBA;;aAAAA;;;6DARM;kCACU;AACjC,MAAMC,mBAAmB,CAACC,QAAQC,QAAQ;IACtC,OAAO,CAAC,CAAED,CAAAA,WAAW,IAAI,IAAIA,WAAW,KAAK,IAAI,KAAK,IAAIA,OAAOE,QAAQ,CAACD,MAAM,AAAD;AACnF;AAIW,MAAMH,oBAAoB,CAACK,UAAU;IAC5C,MAAM,EAAEC,KAAI,EAAGC,SAAQ,EAAGC,QAAO,EAAGC,SAAQ,EAAGC,sBAAqB,EAAGN,UAAUH,iBAAgB,EAAG,GAAGI;IACvG,MAAMM,YAAYC,OAAMC,MAAM,CAACC;IAC/BC,eAAe;QACXP;QACAC,UAAUC,yBAAyBD;QACnCF;QACAD;QACAF;IACJ;IACA,MAAMY,uBAAuBJ,OAAMC,MAAM,CAAC,KAAK;IAC/C,MAAMI,WAAWC,IAAAA,kCAAgB,EAAC,CAACC,KAAK;QACpC,IAAIH,qBAAqBI,OAAO,EAAE;YAC9BJ,qBAAqBI,OAAO,GAAG,KAAK;YACpC;QACJ,CAAC;QACD,MAAMC,SAASF,GAAGG,YAAY,EAAE,CAAC,EAAE;QACnC,MAAMC,YAAYjB,KAAKkB,KAAK,CAAC,CAACC,MAAM,CAACrB,SAASqB,IAAIL,OAAO,IAAI,IAAI,EAAEC;QACnE,IAAIE,aAAa,CAACd,UAAU;YACxBF,SAASY;QACb,CA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