@fluentui/react-utilities 9.11.2 → 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 +47 -1
- package/CHANGELOG.md +28 -2
- package/dist/index.d.ts +17 -3
- package/lib/hooks/index.js +1 -0
- package/lib/hooks/index.js.map +1 -1
- package/lib/hooks/useAnimationFrame.js +12 -0
- package/lib/hooks/useAnimationFrame.js.map +1 -0
- package/lib/hooks/useBrowserTimer.js +45 -0
- package/lib/hooks/useBrowserTimer.js.map +1 -0
- package/lib/hooks/useOnClickOutside.js +29 -16
- package/lib/hooks/useOnClickOutside.js.map +1 -1
- package/lib/hooks/useTimeout.js +5 -24
- package/lib/hooks/useTimeout.js.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib-commonjs/hooks/index.js +1 -0
- package/lib-commonjs/hooks/index.js.map +1 -1
- package/lib-commonjs/hooks/useAnimationFrame.js +13 -0
- package/lib-commonjs/hooks/useAnimationFrame.js.map +1 -0
- package/lib-commonjs/hooks/useBrowserTimer.js +39 -0
- package/lib-commonjs/hooks/useBrowserTimer.js.map +1 -0
- package/lib-commonjs/hooks/useOnClickOutside.js +29 -16
- package/lib-commonjs/hooks/useOnClickOutside.js.map +1 -1
- package/lib-commonjs/hooks/useTimeout.js +3 -23
- package/lib-commonjs/hooks/useTimeout.js.map +1 -1
- package/lib-commonjs/index.js +1 -0
- package/lib-commonjs/index.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.json
CHANGED
@@ -2,7 +2,53 @@
|
|
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",
|
29
|
+
"tag": "@fluentui/react-utilities_v9.12.0",
|
30
|
+
"version": "9.12.0",
|
31
|
+
"comments": {
|
32
|
+
"patch": [
|
33
|
+
{
|
34
|
+
"author": "yuanboxue@microsoft.com",
|
35
|
+
"package": "@fluentui/react-utilities",
|
36
|
+
"commit": "192b74335ed4d99dbcbeeab5aa2075409e911e1a",
|
37
|
+
"comment": "fix: `useOnClickOutside` should consider text selection starting inside and finishing outside as an inside click"
|
38
|
+
}
|
39
|
+
],
|
40
|
+
"minor": [
|
41
|
+
{
|
42
|
+
"author": "marcosvmmoura@gmail.com",
|
43
|
+
"package": "@fluentui/react-utilities",
|
44
|
+
"commit": "148d5fa771ea9eb1f5a96f817782e76484070ec3",
|
45
|
+
"comment": "feat: create a new useAnimationFrame hook"
|
46
|
+
}
|
47
|
+
]
|
48
|
+
}
|
49
|
+
},
|
50
|
+
{
|
51
|
+
"date": "Wed, 23 Aug 2023 12:01:49 GMT",
|
6
52
|
"tag": "@fluentui/react-utilities_v9.11.2",
|
7
53
|
"version": "9.11.2",
|
8
54
|
"comments": {
|
package/CHANGELOG.md
CHANGED
@@ -1,12 +1,38 @@
|
|
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
|
+
|
20
|
+
## [9.12.0](https://github.com/microsoft/fluentui/tree/@fluentui/react-utilities_v9.12.0)
|
21
|
+
|
22
|
+
Thu, 24 Aug 2023 10:26:34 GMT
|
23
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-utilities_v9.11.2..@fluentui/react-utilities_v9.12.0)
|
24
|
+
|
25
|
+
### Minor changes
|
26
|
+
|
27
|
+
- feat: create a new useAnimationFrame hook ([PR #28948](https://github.com/microsoft/fluentui/pull/28948) by marcosvmmoura@gmail.com)
|
28
|
+
|
29
|
+
### Patches
|
30
|
+
|
31
|
+
- fix: `useOnClickOutside` should consider text selection starting inside and finishing outside as an inside click ([PR #28765](https://github.com/microsoft/fluentui/pull/28765) by yuanboxue@microsoft.com)
|
32
|
+
|
7
33
|
## [9.11.2](https://github.com/microsoft/fluentui/tree/@fluentui/react-utilities_v9.11.2)
|
8
34
|
|
9
|
-
Wed, 23 Aug 2023
|
35
|
+
Wed, 23 Aug 2023 12:01:49 GMT
|
10
36
|
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-utilities_v9.11.1..@fluentui/react-utilities_v9.11.2)
|
11
37
|
|
12
38
|
### Patches
|
package/dist/index.d.ts
CHANGED
@@ -684,6 +684,16 @@ export declare type UnknownSlotProps = Pick<React_2.HTMLAttributes<HTMLElement>,
|
|
684
684
|
as?: keyof JSX.IntrinsicElements;
|
685
685
|
};
|
686
686
|
|
687
|
+
/**
|
688
|
+
* @internal
|
689
|
+
* Helper to manage a browser requestAnimationFrame.
|
690
|
+
* Ensures that the requestAnimationFrame isn't set multiple times at once and is cleaned up
|
691
|
+
* when the component is unloaded.
|
692
|
+
*
|
693
|
+
* @returns A pair of [requestAnimationFrame, cancelAnimationFrame] that are stable between renders.
|
694
|
+
*/
|
695
|
+
export declare function useAnimationFrame(): readonly [(fn: () => void, delay?: number | undefined) => number, () => void];
|
696
|
+
|
687
697
|
/**
|
688
698
|
* @internal
|
689
699
|
*
|
@@ -814,6 +824,10 @@ export declare type UseOnClickOrScrollOutsideOptions = {
|
|
814
824
|
* Disables event listeners
|
815
825
|
*/
|
816
826
|
disabled?: boolean;
|
827
|
+
/**
|
828
|
+
* Disables custom focus event listeners for iframes
|
829
|
+
*/
|
830
|
+
disabledFocusOnIframe?: boolean;
|
817
831
|
/**
|
818
832
|
* Called if the click is outside the element refs
|
819
833
|
*/
|
@@ -858,12 +872,12 @@ export declare function useSelection(params: SelectionHookParams): readonly [Set
|
|
858
872
|
/**
|
859
873
|
* @internal
|
860
874
|
* Helper to manage a browser timeout.
|
861
|
-
* Ensures that the timeout isn't set multiple times at once
|
862
|
-
*
|
875
|
+
* Ensures that the timeout isn't set multiple times at once and is cleaned up
|
876
|
+
* when the component is unloaded.
|
863
877
|
*
|
864
878
|
* @returns A pair of [setTimeout, clearTimeout] that are stable between renders.
|
865
879
|
*/
|
866
|
-
export declare function useTimeout(): readonly [(fn: () => void, delay
|
880
|
+
export declare function useTimeout(): readonly [(fn: () => void, delay?: number | undefined) => number, () => void];
|
867
881
|
|
868
882
|
/**
|
869
883
|
* Helper type for {@link Slot}. Takes the props we want to support for a slot and adds the ability for `children`
|
package/lib/hooks/index.js
CHANGED
package/lib/hooks/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["index.ts"],"sourcesContent":["export * from './useControllableState';\nexport * from './useEventCallback';\nexport * from './useFirstMount';\nexport * from './useForceUpdate';\nexport * from './useId';\nexport * from './useIsomorphicLayoutEffect';\nexport * from './useMergedRefs';\nexport * from './useOnClickOutside';\nexport * from './useOnScrollOutside';\nexport * from './usePrevious';\nexport * from './useScrollbarWidth';\nexport * from './useTimeout';\n"],"names":[],"mappings":"AAAA,cAAc,yBAAyB;AACvC,cAAc,qBAAqB;AACnC,cAAc,kBAAkB;AAChC,cAAc,mBAAmB;AACjC,cAAc,UAAU;AACxB,cAAc,8BAA8B;AAC5C,cAAc,kBAAkB;AAChC,cAAc,sBAAsB;AACpC,cAAc,uBAAuB;AACrC,cAAc,gBAAgB;AAC9B,cAAc,sBAAsB;AACpC,cAAc,eAAe"}
|
1
|
+
{"version":3,"sources":["index.ts"],"sourcesContent":["export * from './useAnimationFrame';\nexport * from './useControllableState';\nexport * from './useEventCallback';\nexport * from './useFirstMount';\nexport * from './useForceUpdate';\nexport * from './useId';\nexport * from './useIsomorphicLayoutEffect';\nexport * from './useMergedRefs';\nexport * from './useOnClickOutside';\nexport * from './useOnScrollOutside';\nexport * from './usePrevious';\nexport * from './useScrollbarWidth';\nexport * from './useTimeout';\n"],"names":[],"mappings":"AAAA,cAAc,sBAAsB;AACpC,cAAc,yBAAyB;AACvC,cAAc,qBAAqB;AACnC,cAAc,kBAAkB;AAChC,cAAc,mBAAmB;AACjC,cAAc,UAAU;AACxB,cAAc,8BAA8B;AAC5C,cAAc,kBAAkB;AAChC,cAAc,sBAAsB;AACpC,cAAc,uBAAuB;AACrC,cAAc,gBAAgB;AAC9B,cAAc,sBAAsB;AACpC,cAAc,eAAe"}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import { useBrowserTimer } from './useBrowserTimer';
|
2
|
+
/**
|
3
|
+
* @internal
|
4
|
+
* Helper to manage a browser requestAnimationFrame.
|
5
|
+
* Ensures that the requestAnimationFrame isn't set multiple times at once and is cleaned up
|
6
|
+
* when the component is unloaded.
|
7
|
+
*
|
8
|
+
* @returns A pair of [requestAnimationFrame, cancelAnimationFrame] that are stable between renders.
|
9
|
+
*/ export function useAnimationFrame() {
|
10
|
+
// TODO: figure it out a way to not call global.requestAnimationFrame and instead infer window from some context
|
11
|
+
return useBrowserTimer(requestAnimationFrame, cancelAnimationFrame);
|
12
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["useAnimationFrame.ts"],"sourcesContent":["import { useBrowserTimer } from './useBrowserTimer';\n\n/**\n * @internal\n * Helper to manage a browser requestAnimationFrame.\n * Ensures that the requestAnimationFrame isn't set multiple times at once and is cleaned up\n * when the component is unloaded.\n *\n * @returns A pair of [requestAnimationFrame, cancelAnimationFrame] that are stable between renders.\n */\nexport function useAnimationFrame() {\n // TODO: figure it out a way to not call global.requestAnimationFrame and instead infer window from some context\n return useBrowserTimer(requestAnimationFrame, cancelAnimationFrame);\n}\n"],"names":["useBrowserTimer","useAnimationFrame","requestAnimationFrame","cancelAnimationFrame"],"mappings":"AAAA,SAASA,eAAe,QAAQ,oBAAoB;AAEpD;;;;;;;CAOC,GACD,OAAO,SAASC,oBAAoB;IAClC,gHAAgH;IAChH,OAAOD,gBAAgBE,uBAAuBC;AAChD,CAAC"}
|
@@ -0,0 +1,45 @@
|
|
1
|
+
import * as React from 'react';
|
2
|
+
/**
|
3
|
+
* @internal
|
4
|
+
* Helper to manage a browser timer.
|
5
|
+
* Ensures that the timer isn't set multiple times at once,
|
6
|
+
* and is cleaned up when the component is unloaded.
|
7
|
+
*
|
8
|
+
* @param setTimer - The timer setter function
|
9
|
+
* @param cancelTimer - The timer cancel function
|
10
|
+
* @returns A pair of [setTimer, cancelTimer] that are stable between renders.
|
11
|
+
*
|
12
|
+
* @example
|
13
|
+
* const [setTimer, cancelTimer] = useBrowserTimer(setTimeout, cancelTimeout);
|
14
|
+
*
|
15
|
+
* setTimer(() => console.log('Hello world!'), 1000);
|
16
|
+
* cancelTimer();
|
17
|
+
*/ export function useBrowserTimer(setTimer, cancelTimer) {
|
18
|
+
const id = React.useRef(undefined);
|
19
|
+
const set = React.useCallback((fn, delay)=>{
|
20
|
+
if (id.current !== undefined) {
|
21
|
+
cancelTimer(id.current);
|
22
|
+
}
|
23
|
+
id.current = setTimer(fn, delay);
|
24
|
+
return id.current;
|
25
|
+
}, [
|
26
|
+
cancelTimer,
|
27
|
+
setTimer
|
28
|
+
]);
|
29
|
+
const cancel = React.useCallback(()=>{
|
30
|
+
if (id.current !== undefined) {
|
31
|
+
cancelTimer(id.current);
|
32
|
+
id.current = undefined;
|
33
|
+
}
|
34
|
+
}, [
|
35
|
+
cancelTimer
|
36
|
+
]);
|
37
|
+
// Clean up the timeout when the component is unloaded
|
38
|
+
React.useEffect(()=>cancel, [
|
39
|
+
cancel
|
40
|
+
]);
|
41
|
+
return [
|
42
|
+
set,
|
43
|
+
cancel
|
44
|
+
];
|
45
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["useBrowserTimer.ts"],"sourcesContent":["import * as React from 'react';\n\ntype BrowserTimerSetter =\n | ((fn: () => void, duration?: number, ...args: Record<string, unknown>[]) => number)\n | ((fn: () => void) => number);\n\n/**\n * @internal\n * Helper to manage a browser timer.\n * Ensures that the timer isn't set multiple times at once,\n * and is cleaned up when the component is unloaded.\n *\n * @param setTimer - The timer setter function\n * @param cancelTimer - The timer cancel function\n * @returns A pair of [setTimer, cancelTimer] that are stable between renders.\n *\n * @example\n * const [setTimer, cancelTimer] = useBrowserTimer(setTimeout, cancelTimeout);\n *\n * setTimer(() => console.log('Hello world!'), 1000);\n * cancelTimer();\n */\nexport function useBrowserTimer(setTimer: BrowserTimerSetter, cancelTimer: (id: number) => void) {\n const id = React.useRef<number | undefined>(undefined);\n\n const set = React.useCallback(\n (fn: () => void, delay?: number) => {\n if (id.current !== undefined) {\n cancelTimer(id.current);\n }\n\n id.current = setTimer(fn, delay);\n return id.current;\n },\n [cancelTimer, setTimer],\n );\n\n const cancel = React.useCallback(() => {\n if (id.current !== undefined) {\n cancelTimer(id.current);\n id.current = undefined;\n }\n }, [cancelTimer]);\n\n // Clean up the timeout when the component is unloaded\n React.useEffect(() => cancel, [cancel]);\n\n return [set, cancel] as const;\n}\n"],"names":["React","useBrowserTimer","setTimer","cancelTimer","id","useRef","undefined","set","useCallback","fn","delay","current","cancel","useEffect"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAM/B;;;;;;;;;;;;;;;CAeC,GACD,OAAO,SAASC,gBAAgBC,QAA4B,EAAEC,WAAiC,EAAE;IAC/F,MAAMC,KAAKJ,MAAMK,MAAM,CAAqBC;IAE5C,MAAMC,MAAMP,MAAMQ,WAAW,CAC3B,CAACC,IAAgBC,QAAmB;QAClC,IAAIN,GAAGO,OAAO,KAAKL,WAAW;YAC5BH,YAAYC,GAAGO,OAAO;QACxB,CAAC;QAEDP,GAAGO,OAAO,GAAGT,SAASO,IAAIC;QAC1B,OAAON,GAAGO,OAAO;IACnB,GACA;QAACR;QAAaD;KAAS;IAGzB,MAAMU,SAASZ,MAAMQ,WAAW,CAAC,IAAM;QACrC,IAAIJ,GAAGO,OAAO,KAAKL,WAAW;YAC5BH,YAAYC,GAAGO,OAAO;YACtBP,GAAGO,OAAO,GAAGL;QACf,CAAC;IACH,GAAG;QAACH;KAAY;IAEhB,sDAAsD;IACtDH,MAAMa,SAAS,CAAC,IAAMD,QAAQ;QAACA;KAAO;IAEtC,OAAO;QAACL;QAAKK;KAAO;AACtB,CAAC"}
|
@@ -1,22 +1,39 @@
|
|
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(
|
12
|
+
useIFrameFocus({
|
13
|
+
element,
|
14
|
+
disabled: disabledFocusOnIframe || disabled,
|
15
|
+
callback,
|
16
|
+
refs,
|
17
|
+
contains
|
18
|
+
});
|
19
|
+
const isMouseDownInsideRef = React.useRef(false);
|
10
20
|
const listener = useEventCallback((ev)=>{
|
11
|
-
|
12
|
-
|
13
|
-
|
21
|
+
if (isMouseDownInsideRef.current) {
|
22
|
+
isMouseDownInsideRef.current = false;
|
23
|
+
return;
|
24
|
+
}
|
14
25
|
const target = ev.composedPath()[0];
|
15
26
|
const isOutside = refs.every((ref)=>!contains(ref.current || null, target));
|
16
27
|
if (isOutside && !disabled) {
|
17
28
|
callback(ev);
|
18
29
|
}
|
19
30
|
});
|
31
|
+
const handleMouseDown = useEventCallback((ev)=>{
|
32
|
+
// Selecting text from inside to outside will rigger click event.
|
33
|
+
// In this case click event target is outside but mouse down event target is inside.
|
34
|
+
// And this click event should be considered as inside click.
|
35
|
+
isMouseDownInsideRef.current = refs.some((ref)=>contains(ref.current || null, ev.target));
|
36
|
+
});
|
20
37
|
React.useEffect(()=>{
|
21
38
|
if (disabled) {
|
22
39
|
return;
|
@@ -34,24 +51,25 @@ import { useEventCallback } from './useEventCallback';
|
|
34
51
|
listener(event);
|
35
52
|
};
|
36
53
|
// use capture phase because React can update DOM before the event bubbles to the document
|
37
|
-
element === null || element === void 0 ? void 0 : element.addEventListener('click', conditionalHandler, true);
|
38
54
|
element === null || element === void 0 ? void 0 : element.addEventListener('touchstart', conditionalHandler, true);
|
39
|
-
element === null || element === void 0 ? void 0 : element.addEventListener('
|
55
|
+
element === null || element === void 0 ? void 0 : element.addEventListener('mouseup', conditionalHandler, true);
|
56
|
+
element === null || element === void 0 ? void 0 : element.addEventListener('mousedown', handleMouseDown, true);
|
40
57
|
// Garbage collect this event after it's no longer useful to avoid memory leaks
|
41
58
|
timeoutId.current = window.setTimeout(()=>{
|
42
59
|
currentEvent = undefined;
|
43
60
|
}, 1);
|
44
61
|
return ()=>{
|
45
|
-
element === null || element === void 0 ? void 0 : element.removeEventListener('click', conditionalHandler, true);
|
46
62
|
element === null || element === void 0 ? void 0 : element.removeEventListener('touchstart', conditionalHandler, true);
|
47
|
-
element === null || element === void 0 ? void 0 : element.removeEventListener('
|
63
|
+
element === null || element === void 0 ? void 0 : element.removeEventListener('mouseup', conditionalHandler, true);
|
64
|
+
element === null || element === void 0 ? void 0 : element.removeEventListener('mousedown', handleMouseDown, true);
|
48
65
|
clearTimeout(timeoutId.current);
|
49
66
|
currentEvent = undefined;
|
50
67
|
};
|
51
68
|
}, [
|
52
69
|
listener,
|
53
70
|
element,
|
54
|
-
disabled
|
71
|
+
disabled,
|
72
|
+
handleMouseDown
|
55
73
|
]);
|
56
74
|
};
|
57
75
|
const getWindowEvent = (target)=>{
|
@@ -78,14 +96,9 @@ const FUI_FRAME_EVENT = 'fuiframefocus';
|
|
78
96
|
* Polls the value of `document.activeElement`. If it is an iframe, then dispatch
|
79
97
|
* a custom DOM event. When the custom event is received call the provided callback
|
80
98
|
*/ const useIFrameFocus = (options)=>{
|
81
|
-
const { disabled , element: targetDocument , callback , contains
|
82
|
-
return !!(parent === null || parent === void 0 ? void 0 : parent.contains(child));
|
83
|
-
} , pollDuration =1000 , refs } = options;
|
99
|
+
const { disabled , element: targetDocument , callback , contains =DEFAULT_CONTAINS , pollDuration =1000 , refs } = options;
|
84
100
|
const timeoutRef = React.useRef();
|
85
101
|
const listener = useEventCallback((e)=>{
|
86
|
-
const contains = containsProp || ((parent, child)=>{
|
87
|
-
return !!(parent === null || parent === void 0 ? void 0 : parent.contains(child));
|
88
|
-
});
|
89
102
|
const isOutside = refs.every((ref)=>!contains(ref.current || null, e.target));
|
90
103
|
if (isOutside && !disabled) {
|
91
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 listener = useEventCallback((ev: MouseEvent | TouchEvent) => {\n const contains: UseOnClickOrScrollOutsideOptions['contains'] =\n containsProp || ((parent, child) => !!parent?.contains(child));\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 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\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\n clearTimeout(timeoutId.current);\n currentEvent = undefined;\n };\n }, [listener, element, disabled]);\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","listener","ev","parent","child","target","composedPath","isOutside","every","ref","current","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,WAAWb,iBAAiB,CAACc,KAAgC;QACjE,MAAMP,WACJC,gBAAiB,CAAA,CAACO,QAAQC;YAAU,OAAA,CAAC,EAACD,mBAAAA,oBAAAA,KAAAA,IAAAA,OAAQR,QAAQ,CAACS;SAAK;QAE9D,MAAMC,S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,iBAAiBtB,UAAU,IAAI;QAEhE,OAAO,IAAM;YACXuB,2BAAAA,4BAAAA,KAAAA,IAAAA,eAAgBL,mBAAmB,CAACI,iBAAiBtB,UAAU,IAAI;QACrE;IACF,GAAG;QAACuB;QAAgB9B;QAAUO;KAAS;IAEvC,wCAAwC;IACxCd,MAAMwB,SAAS,CAAC,IAAM;YAKCa;QAJrB,IAAI9B,UAAU;YACZ;QACF,CAAC;QAEDgC,WAAWhB,OAAO,GAAGc,2BAAAA,4BAAAA,KAAAA,IAAAA,CAAAA,8BAAAA,eAAgBF,WAAW,cAA3BE,yCAAAA,KAAAA,IAAAA,4BAA6BI,YAAY,IAAM;YAClE,MAAMC,gBAAgBL,2BAAAA,4BAAAA,KAAAA,IAAAA,eAAgBK,aAAa;YAEnD,IAAIA,CAAAA,0BAAAA,2BAAAA,KAAAA,IAAAA,cAAeC,OAAO,AAAD,MAAM,YAAYD,CAAAA,0BAAAA,2BAAAA,KAAAA,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,WAAWhB,OAAO;QAC9D;IACF,GAAG;QAACc;QAAgB9B;QAAU+B;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,SAASC,gBAAgB,QAAQ,qBAAqB;AAuCtD,MAAMC,mBAAiE,CAACC,QAAQC;IAAU,OAAA,CAAC,EAACD,mBAAAA,oBAAAA,KAAAA,IAAAA,OAAQE,QAAQ,CAACD;;AAE7G;;;CAGC,GACD,OAAO,MAAME,oBAAoB,CAACC,UAA8C;IAC9E,MAAM,EAAEC,KAAI,EAAEC,SAAQ,EAAEC,QAAO,EAAEC,SAAQ,EAAEC,sBAAqB,EAAEP,UAAWH,iBAAgB,EAAE,GAAGK;IAClG,MAAMM,YAAYb,MAAMc,MAAM,CAAqBC;IAEnDC,eAAe;QAAEN;QAASC,UAAU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/hooks/useTimeout.js
CHANGED
@@ -1,31 +1,12 @@
|
|
1
|
-
import
|
1
|
+
import { useBrowserTimer } from './useBrowserTimer';
|
2
2
|
/**
|
3
3
|
* @internal
|
4
4
|
* Helper to manage a browser timeout.
|
5
|
-
* Ensures that the timeout isn't set multiple times at once
|
6
|
-
*
|
5
|
+
* Ensures that the timeout isn't set multiple times at once and is cleaned up
|
6
|
+
* when the component is unloaded.
|
7
7
|
*
|
8
8
|
* @returns A pair of [setTimeout, clearTimeout] that are stable between renders.
|
9
9
|
*/ export function useTimeout() {
|
10
|
-
|
11
|
-
|
12
|
-
set: (fn, delay)=>{
|
13
|
-
timeout.clear();
|
14
|
-
timeout.id = setTimeout(fn, delay);
|
15
|
-
},
|
16
|
-
clear: ()=>{
|
17
|
-
if (timeout.id !== undefined) {
|
18
|
-
clearTimeout(timeout.id);
|
19
|
-
timeout.id = undefined;
|
20
|
-
}
|
21
|
-
}
|
22
|
-
}));
|
23
|
-
// Clean up the timeout when the component is unloaded
|
24
|
-
React.useEffect(()=>timeout.clear, [
|
25
|
-
timeout
|
26
|
-
]);
|
27
|
-
return [
|
28
|
-
timeout.set,
|
29
|
-
timeout.clear
|
30
|
-
];
|
10
|
+
// TODO: figure it out a way to not call global.setTimeout and instead infer window from some context
|
11
|
+
return useBrowserTimer(setTimeout, clearTimeout);
|
31
12
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["useTimeout.ts"],"sourcesContent":["import
|
1
|
+
{"version":3,"sources":["useTimeout.ts"],"sourcesContent":["import { useBrowserTimer } from './useBrowserTimer';\n\n/**\n * @internal\n * Helper to manage a browser timeout.\n * Ensures that the timeout isn't set multiple times at once and is cleaned up\n * when the component is unloaded.\n *\n * @returns A pair of [setTimeout, clearTimeout] that are stable between renders.\n */\nexport function useTimeout() {\n // TODO: figure it out a way to not call global.setTimeout and instead infer window from some context\n return useBrowserTimer(setTimeout, clearTimeout);\n}\n"],"names":["useBrowserTimer","useTimeout","setTimeout","clearTimeout"],"mappings":"AAAA,SAASA,eAAe,QAAQ,oBAAoB;AAEpD;;;;;;;CAOC,GACD,OAAO,SAASC,aAAa;IAC3B,qGAAqG;IACrG,OAAOD,gBAAgBE,YAAYC;AACrC,CAAC"}
|
package/lib/index.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
export { slot, isSlot, getSlots, getSlotsNext, assertSlots, resolveShorthand, isResolvedShorthand, SLOT_ELEMENT_TYPE_SYMBOL, SLOT_RENDER_FUNCTION_SYMBOL } from './compose/index';
|
2
|
-
export { IdPrefixProvider, resetIdsForTests, useControllableState, useEventCallback, useFirstMount, useForceUpdate, useId, useIsomorphicLayoutEffect, useMergedRefs, useOnClickOutside, useOnScrollOutside, usePrevious, useScrollbarWidth, useTimeout } from './hooks/index';
|
2
|
+
export { IdPrefixProvider, resetIdsForTests, useAnimationFrame, useControllableState, useEventCallback, useFirstMount, useForceUpdate, useId, useIsomorphicLayoutEffect, useMergedRefs, useOnClickOutside, useOnScrollOutside, usePrevious, useScrollbarWidth, useTimeout } from './hooks/index';
|
3
3
|
export { canUseDOM, useIsSSR, SSRProvider } from './ssr/index';
|
4
4
|
export { clamp, getNativeElementProps, getPartitionedNativeProps, getRTLSafeKey, mergeCallbacks, isHTMLElement, isInteractiveHTMLElement, omit, createPriorityQueue } from './utils/index';
|
5
5
|
export { applyTriggerPropsToChildren, getTriggerChild, isFluentTrigger } from './trigger/index';
|
package/lib/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["index.ts"],"sourcesContent":["export {\n slot,\n isSlot,\n getSlots,\n getSlotsNext,\n assertSlots,\n resolveShorthand,\n isResolvedShorthand,\n SLOT_ELEMENT_TYPE_SYMBOL,\n SLOT_RENDER_FUNCTION_SYMBOL,\n} from './compose/index';\nexport type {\n ExtractSlotProps,\n ComponentProps,\n ComponentState,\n ForwardRefComponent,\n ResolveShorthandFunction,\n ResolveShorthandOptions,\n Slot,\n Slots,\n SlotClassNames,\n SlotPropsRecord,\n SlotRenderFunction,\n SlotShorthandValue,\n UnknownSlotProps,\n SlotComponentType,\n SlotOptions,\n} from './compose/index';\n\nexport {\n IdPrefixProvider,\n resetIdsForTests,\n useControllableState,\n useEventCallback,\n useFirstMount,\n useForceUpdate,\n useId,\n useIsomorphicLayoutEffect,\n useMergedRefs,\n useOnClickOutside,\n useOnScrollOutside,\n usePrevious,\n useScrollbarWidth,\n useTimeout,\n} from './hooks/index';\nexport type { RefObjectFunction, UseControllableStateOptions, UseOnClickOrScrollOutsideOptions } from './hooks/index';\n\nexport { canUseDOM, useIsSSR, SSRProvider } from './ssr/index';\n\nexport {\n clamp,\n getNativeElementProps,\n getPartitionedNativeProps,\n getRTLSafeKey,\n mergeCallbacks,\n isHTMLElement,\n isInteractiveHTMLElement,\n omit,\n createPriorityQueue,\n} from './utils/index';\n\nexport type { PriorityQueue } from './utils/priorityQueue';\n\nexport { applyTriggerPropsToChildren, getTriggerChild, isFluentTrigger } from './trigger/index';\n\nexport type { FluentTriggerComponent, TriggerProps } from './trigger/index';\n\n/**\n * Event utils\n */\nexport type { NativeTouchOrMouseEvent, ReactTouchOrMouseEvent, TouchOrMouseEvent } from './events/index';\nexport { isTouchEvent, isMouseEvent, getEventClientCoords } from './events/index';\n\nexport type {\n SelectionMode,\n OnSelectionChangeCallback,\n OnSelectionChangeData,\n SelectionItemId,\n SelectionHookParams,\n SelectionMethods,\n} from './selection/index';\nexport { useSelection } from './selection/index';\n"],"names":["slot","isSlot","getSlots","getSlotsNext","assertSlots","resolveShorthand","isResolvedShorthand","SLOT_ELEMENT_TYPE_SYMBOL","SLOT_RENDER_FUNCTION_SYMBOL","IdPrefixProvider","resetIdsForTests","useControllableState","useEventCallback","useFirstMount","useForceUpdate","useId","useIsomorphicLayoutEffect","useMergedRefs","useOnClickOutside","useOnScrollOutside","usePrevious","useScrollbarWidth","useTimeout","canUseDOM","useIsSSR","SSRProvider","clamp","getNativeElementProps","getPartitionedNativeProps","getRTLSafeKey","mergeCallbacks","isHTMLElement","isInteractiveHTMLElement","omit","createPriorityQueue","applyTriggerPropsToChildren","getTriggerChild","isFluentTrigger","isTouchEvent","isMouseEvent","getEventClientCoords","useSelection"],"mappings":"AAAA,SACEA,IAAI,EACJC,MAAM,EACNC,QAAQ,EACRC,YAAY,EACZC,WAAW,EACXC,gBAAgB,EAChBC,mBAAmB,EACnBC,wBAAwB,EACxBC,2BAA2B,QACtB,kBAAkB;AAmBzB,SACEC,gBAAgB,EAChBC,gBAAgB,EAChBC,oBAAoB,EACpBC,gBAAgB,EAChBC,aAAa,EACbC,cAAc,EACdC,KAAK,EACLC,yBAAyB,EACzBC,aAAa,EACbC,iBAAiB,EACjBC,kBAAkB,EAClBC,WAAW,EACXC,iBAAiB,EACjBC,UAAU,QACL,gBAAgB;AAGvB,SAASC,SAAS,EAAEC,QAAQ,EAAEC,WAAW,QAAQ,cAAc;AAE/D,SACEC,KAAK,EACLC,qBAAqB,EACrBC,yBAAyB,EACzBC,aAAa,EACbC,cAAc,EACdC,aAAa,EACbC,wBAAwB,EACxBC,IAAI,EACJC,mBAAmB,QACd,gBAAgB;AAIvB,SAASC,2BAA2B,EAAEC,eAAe,EAAEC,eAAe,QAAQ,kBAAkB;AAQhG,SAASC,YAAY,EAAEC,YAAY,EAAEC,oBAAoB,QAAQ,iBAAiB;AAUlF,SAASC,YAAY,QAAQ,oBAAoB"}
|
1
|
+
{"version":3,"sources":["index.ts"],"sourcesContent":["export {\n slot,\n isSlot,\n getSlots,\n getSlotsNext,\n assertSlots,\n resolveShorthand,\n isResolvedShorthand,\n SLOT_ELEMENT_TYPE_SYMBOL,\n SLOT_RENDER_FUNCTION_SYMBOL,\n} from './compose/index';\nexport type {\n ExtractSlotProps,\n ComponentProps,\n ComponentState,\n ForwardRefComponent,\n ResolveShorthandFunction,\n ResolveShorthandOptions,\n Slot,\n Slots,\n SlotClassNames,\n SlotPropsRecord,\n SlotRenderFunction,\n SlotShorthandValue,\n UnknownSlotProps,\n SlotComponentType,\n SlotOptions,\n} from './compose/index';\n\nexport {\n IdPrefixProvider,\n resetIdsForTests,\n useAnimationFrame,\n useControllableState,\n useEventCallback,\n useFirstMount,\n useForceUpdate,\n useId,\n useIsomorphicLayoutEffect,\n useMergedRefs,\n useOnClickOutside,\n useOnScrollOutside,\n usePrevious,\n useScrollbarWidth,\n useTimeout,\n} from './hooks/index';\nexport type { RefObjectFunction, UseControllableStateOptions, UseOnClickOrScrollOutsideOptions } from './hooks/index';\n\nexport { canUseDOM, useIsSSR, SSRProvider } from './ssr/index';\n\nexport {\n clamp,\n getNativeElementProps,\n getPartitionedNativeProps,\n getRTLSafeKey,\n mergeCallbacks,\n isHTMLElement,\n isInteractiveHTMLElement,\n omit,\n createPriorityQueue,\n} from './utils/index';\n\nexport type { PriorityQueue } from './utils/priorityQueue';\n\nexport { applyTriggerPropsToChildren, getTriggerChild, isFluentTrigger } from './trigger/index';\n\nexport type { FluentTriggerComponent, TriggerProps } from './trigger/index';\n\n/**\n * Event utils\n */\nexport type { NativeTouchOrMouseEvent, ReactTouchOrMouseEvent, TouchOrMouseEvent } from './events/index';\nexport { isTouchEvent, isMouseEvent, getEventClientCoords } from './events/index';\n\nexport type {\n SelectionMode,\n OnSelectionChangeCallback,\n OnSelectionChangeData,\n SelectionItemId,\n SelectionHookParams,\n SelectionMethods,\n} from './selection/index';\nexport { useSelection } from './selection/index';\n"],"names":["slot","isSlot","getSlots","getSlotsNext","assertSlots","resolveShorthand","isResolvedShorthand","SLOT_ELEMENT_TYPE_SYMBOL","SLOT_RENDER_FUNCTION_SYMBOL","IdPrefixProvider","resetIdsForTests","useAnimationFrame","useControllableState","useEventCallback","useFirstMount","useForceUpdate","useId","useIsomorphicLayoutEffect","useMergedRefs","useOnClickOutside","useOnScrollOutside","usePrevious","useScrollbarWidth","useTimeout","canUseDOM","useIsSSR","SSRProvider","clamp","getNativeElementProps","getPartitionedNativeProps","getRTLSafeKey","mergeCallbacks","isHTMLElement","isInteractiveHTMLElement","omit","createPriorityQueue","applyTriggerPropsToChildren","getTriggerChild","isFluentTrigger","isTouchEvent","isMouseEvent","getEventClientCoords","useSelection"],"mappings":"AAAA,SACEA,IAAI,EACJC,MAAM,EACNC,QAAQ,EACRC,YAAY,EACZC,WAAW,EACXC,gBAAgB,EAChBC,mBAAmB,EACnBC,wBAAwB,EACxBC,2BAA2B,QACtB,kBAAkB;AAmBzB,SACEC,gBAAgB,EAChBC,gBAAgB,EAChBC,iBAAiB,EACjBC,oBAAoB,EACpBC,gBAAgB,EAChBC,aAAa,EACbC,cAAc,EACdC,KAAK,EACLC,yBAAyB,EACzBC,aAAa,EACbC,iBAAiB,EACjBC,kBAAkB,EAClBC,WAAW,EACXC,iBAAiB,EACjBC,UAAU,QACL,gBAAgB;AAGvB,SAASC,SAAS,EAAEC,QAAQ,EAAEC,WAAW,QAAQ,cAAc;AAE/D,SACEC,KAAK,EACLC,qBAAqB,EACrBC,yBAAyB,EACzBC,aAAa,EACbC,cAAc,EACdC,aAAa,EACbC,wBAAwB,EACxBC,IAAI,EACJC,mBAAmB,QACd,gBAAgB;AAIvB,SAASC,2BAA2B,EAAEC,eAAe,EAAEC,eAAe,QAAQ,kBAAkB;AAQhG,SAASC,YAAY,EAAEC,YAAY,EAAEC,oBAAoB,QAAQ,iBAAiB;AAUlF,SAASC,YAAY,QAAQ,oBAAoB"}
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
4
4
|
});
|
5
5
|
const _exportStar = require("@swc/helpers/lib/_export_star.js").default;
|
6
|
+
_exportStar(require("./useAnimationFrame"), exports);
|
6
7
|
_exportStar(require("./useControllableState"), exports);
|
7
8
|
_exportStar(require("./useEventCallback"), exports);
|
8
9
|
_exportStar(require("./useFirstMount"), exports);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["index.js"],"sourcesContent":["export * from './useControllableState';\nexport * from './useEventCallback';\nexport * from './useFirstMount';\nexport * from './useForceUpdate';\nexport * from './useId';\nexport * from './useIsomorphicLayoutEffect';\nexport * from './useMergedRefs';\nexport * from './useOnClickOutside';\nexport * from './useOnScrollOutside';\nexport * from './usePrevious';\nexport * from './useScrollbarWidth';\nexport * from './useTimeout';\n"],"names":[],"mappings":";;;;;oBAAc;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA"}
|
1
|
+
{"version":3,"sources":["index.js"],"sourcesContent":["export * from './useAnimationFrame';\nexport * from './useControllableState';\nexport * from './useEventCallback';\nexport * from './useFirstMount';\nexport * from './useForceUpdate';\nexport * from './useId';\nexport * from './useIsomorphicLayoutEffect';\nexport * from './useMergedRefs';\nexport * from './useOnClickOutside';\nexport * from './useOnScrollOutside';\nexport * from './usePrevious';\nexport * from './useScrollbarWidth';\nexport * from './useTimeout';\n"],"names":[],"mappings":";;;;;oBAAc;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA;oBACA"}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
3
|
+
value: true
|
4
|
+
});
|
5
|
+
Object.defineProperty(exports, "useAnimationFrame", {
|
6
|
+
enumerable: true,
|
7
|
+
get: ()=>useAnimationFrame
|
8
|
+
});
|
9
|
+
const _useBrowserTimer = require("./useBrowserTimer");
|
10
|
+
function useAnimationFrame() {
|
11
|
+
// TODO: figure it out a way to not call global.requestAnimationFrame and instead infer window from some context
|
12
|
+
return (0, _useBrowserTimer.useBrowserTimer)(requestAnimationFrame, cancelAnimationFrame);
|
13
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["useAnimationFrame.js"],"sourcesContent":["import { useBrowserTimer } from './useBrowserTimer';\n/**\n * @internal\n * Helper to manage a browser requestAnimationFrame.\n * Ensures that the requestAnimationFrame isn't set multiple times at once and is cleaned up\n * when the component is unloaded.\n *\n * @returns A pair of [requestAnimationFrame, cancelAnimationFrame] that are stable between renders.\n */ export function useAnimationFrame() {\n // TODO: figure it out a way to not call global.requestAnimationFrame and instead infer window from some context\n return useBrowserTimer(requestAnimationFrame, cancelAnimationFrame);\n}\n"],"names":["useAnimationFrame","useBrowserTimer","requestAnimationFrame","cancelAnimationFrame"],"mappings":";;;;+BAQoBA;;aAAAA;;iCARY;AAQrB,SAASA,oBAAoB;IACpC,gHAAgH;IAChH,OAAOC,IAAAA,gCAAe,EAACC,uBAAuBC;AAClD"}
|
@@ -0,0 +1,39 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
3
|
+
value: true
|
4
|
+
});
|
5
|
+
Object.defineProperty(exports, "useBrowserTimer", {
|
6
|
+
enumerable: true,
|
7
|
+
get: ()=>useBrowserTimer
|
8
|
+
});
|
9
|
+
const _interopRequireWildcard = require("@swc/helpers/lib/_interop_require_wildcard.js").default;
|
10
|
+
const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
|
11
|
+
function useBrowserTimer(setTimer, cancelTimer) {
|
12
|
+
const id = _react.useRef(undefined);
|
13
|
+
const set = _react.useCallback((fn, delay)=>{
|
14
|
+
if (id.current !== undefined) {
|
15
|
+
cancelTimer(id.current);
|
16
|
+
}
|
17
|
+
id.current = setTimer(fn, delay);
|
18
|
+
return id.current;
|
19
|
+
}, [
|
20
|
+
cancelTimer,
|
21
|
+
setTimer
|
22
|
+
]);
|
23
|
+
const cancel = _react.useCallback(()=>{
|
24
|
+
if (id.current !== undefined) {
|
25
|
+
cancelTimer(id.current);
|
26
|
+
id.current = undefined;
|
27
|
+
}
|
28
|
+
}, [
|
29
|
+
cancelTimer
|
30
|
+
]);
|
31
|
+
// Clean up the timeout when the component is unloaded
|
32
|
+
_react.useEffect(()=>cancel, [
|
33
|
+
cancel
|
34
|
+
]);
|
35
|
+
return [
|
36
|
+
set,
|
37
|
+
cancel
|
38
|
+
];
|
39
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["useBrowserTimer.js"],"sourcesContent":["import * as React from 'react';\n/**\n * @internal\n * Helper to manage a browser timer.\n * Ensures that the timer isn't set multiple times at once,\n * and is cleaned up when the component is unloaded.\n *\n * @param setTimer - The timer setter function\n * @param cancelTimer - The timer cancel function\n * @returns A pair of [setTimer, cancelTimer] that are stable between renders.\n *\n * @example\n * const [setTimer, cancelTimer] = useBrowserTimer(setTimeout, cancelTimeout);\n *\n * setTimer(() => console.log('Hello world!'), 1000);\n * cancelTimer();\n */ export function useBrowserTimer(setTimer, cancelTimer) {\n const id = React.useRef(undefined);\n const set = React.useCallback((fn, delay)=>{\n if (id.current !== undefined) {\n cancelTimer(id.current);\n }\n id.current = setTimer(fn, delay);\n return id.current;\n }, [\n cancelTimer,\n setTimer\n ]);\n const cancel = React.useCallback(()=>{\n if (id.current !== undefined) {\n cancelTimer(id.current);\n id.current = undefined;\n }\n }, [\n cancelTimer\n ]);\n // Clean up the timeout when the component is unloaded\n React.useEffect(()=>cancel, [\n cancel\n ]);\n return [\n set,\n cancel\n ];\n}\n"],"names":["useBrowserTimer","setTimer","cancelTimer","id","React","useRef","undefined","set","useCallback","fn","delay","current","cancel","useEffect"],"mappings":";;;;+BAgBoBA;;aAAAA;;;6DAhBG;AAgBZ,SAASA,gBAAgBC,QAAQ,EAAEC,WAAW,EAAE;IACvD,MAAMC,KAAKC,OAAMC,MAAM,CAACC;IACxB,MAAMC,MAAMH,OAAMI,WAAW,CAAC,CAACC,IAAIC,QAAQ;QACvC,IAAIP,GAAGQ,OAAO,KAAKL,WAAW;YAC1BJ,YAAYC,GAAGQ,OAAO;QAC1B,CAAC;QACDR,GAAGQ,OAAO,GAAGV,SAASQ,IAAIC;QAC1B,OAAOP,GAAGQ,OAAO;IACrB,GAAG;QACCT;QACAD;KACH;IACD,MAAMW,SAASR,OAAMI,WAAW,CAAC,IAAI;QACjC,IAAIL,GAAGQ,OAAO,KAAKL,WAAW;YAC1BJ,YAAYC,GAAGQ,OAAO;YACtBR,GAAGQ,OAAO,GAAGL;QACjB,CAAC;IACL,GAAG;QACCJ;KACH;IACD,sDAAsD;IACtDE,OAAMS,SAAS,CAAC,IAAID,QAAQ;QACxBA;KACH;IACD,OAAO;QACHL;QACAK;KACH;AACL"}
|
@@ -9,20 +9,37 @@ 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(
|
18
|
+
useIFrameFocus({
|
19
|
+
element,
|
20
|
+
disabled: disabledFocusOnIframe || disabled,
|
21
|
+
callback,
|
22
|
+
refs,
|
23
|
+
contains
|
24
|
+
});
|
25
|
+
const isMouseDownInsideRef = _react.useRef(false);
|
16
26
|
const listener = (0, _useEventCallback.useEventCallback)((ev)=>{
|
17
|
-
|
18
|
-
|
19
|
-
|
27
|
+
if (isMouseDownInsideRef.current) {
|
28
|
+
isMouseDownInsideRef.current = false;
|
29
|
+
return;
|
30
|
+
}
|
20
31
|
const target = ev.composedPath()[0];
|
21
32
|
const isOutside = refs.every((ref)=>!contains(ref.current || null, target));
|
22
33
|
if (isOutside && !disabled) {
|
23
34
|
callback(ev);
|
24
35
|
}
|
25
36
|
});
|
37
|
+
const handleMouseDown = (0, _useEventCallback.useEventCallback)((ev)=>{
|
38
|
+
// Selecting text from inside to outside will rigger click event.
|
39
|
+
// In this case click event target is outside but mouse down event target is inside.
|
40
|
+
// And this click event should be considered as inside click.
|
41
|
+
isMouseDownInsideRef.current = refs.some((ref)=>contains(ref.current || null, ev.target));
|
42
|
+
});
|
26
43
|
_react.useEffect(()=>{
|
27
44
|
if (disabled) {
|
28
45
|
return;
|
@@ -40,24 +57,25 @@ const useOnClickOutside = (options)=>{
|
|
40
57
|
listener(event);
|
41
58
|
};
|
42
59
|
// use capture phase because React can update DOM before the event bubbles to the document
|
43
|
-
element === null || element === void 0 ? void 0 : element.addEventListener('click', conditionalHandler, true);
|
44
60
|
element === null || element === void 0 ? void 0 : element.addEventListener('touchstart', conditionalHandler, true);
|
45
|
-
element === null || element === void 0 ? void 0 : element.addEventListener('
|
61
|
+
element === null || element === void 0 ? void 0 : element.addEventListener('mouseup', conditionalHandler, true);
|
62
|
+
element === null || element === void 0 ? void 0 : element.addEventListener('mousedown', handleMouseDown, true);
|
46
63
|
// Garbage collect this event after it's no longer useful to avoid memory leaks
|
47
64
|
timeoutId.current = window.setTimeout(()=>{
|
48
65
|
currentEvent = undefined;
|
49
66
|
}, 1);
|
50
67
|
return ()=>{
|
51
|
-
element === null || element === void 0 ? void 0 : element.removeEventListener('click', conditionalHandler, true);
|
52
68
|
element === null || element === void 0 ? void 0 : element.removeEventListener('touchstart', conditionalHandler, true);
|
53
|
-
element === null || element === void 0 ? void 0 : element.removeEventListener('
|
69
|
+
element === null || element === void 0 ? void 0 : element.removeEventListener('mouseup', conditionalHandler, true);
|
70
|
+
element === null || element === void 0 ? void 0 : element.removeEventListener('mousedown', handleMouseDown, true);
|
54
71
|
clearTimeout(timeoutId.current);
|
55
72
|
currentEvent = undefined;
|
56
73
|
};
|
57
74
|
}, [
|
58
75
|
listener,
|
59
76
|
element,
|
60
|
-
disabled
|
77
|
+
disabled,
|
78
|
+
handleMouseDown
|
61
79
|
]);
|
62
80
|
};
|
63
81
|
const getWindowEvent = (target)=>{
|
@@ -84,14 +102,9 @@ const FUI_FRAME_EVENT = 'fuiframefocus';
|
|
84
102
|
* Polls the value of `document.activeElement`. If it is an iframe, then dispatch
|
85
103
|
* a custom DOM event. When the custom event is received call the provided callback
|
86
104
|
*/ const useIFrameFocus = (options)=>{
|
87
|
-
const { disabled , element: targetDocument , callback , contains
|
88
|
-
return !!(parent === null || parent === void 0 ? void 0 : parent.contains(child));
|
89
|
-
} , pollDuration =1000 , refs } = options;
|
105
|
+
const { disabled , element: targetDocument , callback , contains =DEFAULT_CONTAINS , pollDuration =1000 , refs } = options;
|
90
106
|
const timeoutRef = _react.useRef();
|
91
107
|
const listener = (0, _useEventCallback.useEventCallback)((e)=>{
|
92
|
-
const contains = containsProp || ((parent, child)=>{
|
93
|
-
return !!(parent === null || parent === void 0 ? void 0 : parent.contains(child));
|
94
|
-
});
|
95
108
|
const isOutside = refs.every((ref)=>!contains(ref.current || null, e.target));
|
96
109
|
if (isOutside && !disabled) {
|
97
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 listener = useEventCallback((ev)=>{\n const contains = containsProp || ((parent, child)=>{\n return !!(parent === null || parent === void 0 ? void 0 : parent.contains(child));\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 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 // 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 clearTimeout(timeoutId.current);\n currentEvent = undefined;\n };\n }, [\n listener,\n element,\n disabled\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","listener","useEventCallback","ev","parent","child","target","composedPath","isOutside","every","ref","current","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,WAAWC,IAAAA,kCAAgB,EAAC,CAACC,KAAK;QACpC,MAAMT,WAAWC,gBAAiB,CAAA,CAACS,QAAQC,QAAQ;YAC/C,OAAO,CAAC,CAAED,CAAAA,WAAW,IAAI,IAAIA,WAAW,KAAK,IAAI,KAAK,IAAIA,OAAOV,QAAQ,CAACW,MAAM,AAAD;QACnF,CAAA;QACA,MAAMC,SAASH,GAAGI,YAAY,EAAE,CAAC,EAAE;QACnC,MAAMC,YAAYlB,KAAKmB,KAAK,CAAC,CAACC,MAAM,CAAChB,SAASgB,IAAIC,OAAO,IAAI,IAAI,EAAEL;QACnE,IAAIE,aAAa,CAACf,UAAU;YACxBF,SAASY;QACb,CAAC;IACL;IACAN,OAAMe,SAAS,CAAC,IAAI;QAChB,IAAInB,UAAU;YACV;QACJ,CAAC;QACD,mEAAmE;QACnE,2FAA2F;QAC3F,iDAAiD;QACjD,IAAIoB,eAAeC,eAAeC;QAClC,MAAMC,qBAAqB,CAACC,QAAQ;YAChC,+EAA+E;YAC/E,IAAIA,UAAUJ,cAAc;gBACxBA,eAAed;gBACf;YACJ,CAAC;YACDE,SAASgB;QACb;QACA,0FAA0F;QAC1FzB,YAAY,IAAI,IAAIA,YAAY,KAAK,IAAI,KAAK,IAAIA,QAAQ0B,gBAAgB,CAAC,SAASF,oBAAoB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UAAU,IAAI,CAAC;QACvI;IACJ,GAAG;QACC2B;QACAnC;QACAQ;KACH;IACD,wCAAwC;IACxCJ,OAAMe,SAAS,CAAC,IAAI;QAChB,IAAIoB;QACJ,IAAIvC,UAAU;YACV;QACJ,CAAC;QACDqC,WAAWnB,OAAO,GAAGiB,mBAAmB,IAAI,IAAIA,mBAAmB,KAAK,IAAI,KAAK,IAAI,AAACI,CAAAA,8BAA8BJ,eAAeF,WAAW,AAAD,MAAO,IAAI,IAAIM,gCAAgC,KAAK,IAAI,KAAK,IAAIA,4BAA4BC,WAAW,CAAC,IAAI;YACtP,MAAMC,gBAAgBN,mBAAmB,IAAI,IAAIA,mBAAmB,KAAK,IAAI,KAAK,IAAIA,eAAeM,aAAa;YAClH,IAAI,AAACA,CAAAA,kBAAkB,IAAI,IAAIA,kBAAkB,KAAK,IAAI,KAAK,IAAIA,cAAcC,OAAO,AAAD,MAAO,YAAY,AAACD,CAAAA,kBAAkB,IAAI,IAAIA,kBAAkB,KAAK,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,WAAWnB,OAAO,CAAC;QACzP;IACJ,GAAG;QACCiB;QACAnC;QACAoC;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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IAAI,KAAK,IAAIA,4BAA4BC,WAAW,CAAC,IAAI;YACtP,MAAMC,gBAAgBN,mBAAmB,IAAI,IAAIA,mBAAmB,KAAK,IAAI,KAAK,IAAIA,eAAeM,aAAa;YAClH,IAAI,AAACA,CAAAA,kBAAkB,IAAI,IAAIA,kBAAkB,KAAK,IAAI,KAAK,IAAIA,cAAcC,OAAO,AAAD,MAAO,YAAY,AAACD,CAAAA,kBAAkB,IAAI,IAAIA,kBAAkB,KAAK,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;QACAnC;QACAoC;KACH;AACL"}
|
@@ -6,28 +6,8 @@ Object.defineProperty(exports, "useTimeout", {
|
|
6
6
|
enumerable: true,
|
7
7
|
get: ()=>useTimeout
|
8
8
|
});
|
9
|
-
const
|
10
|
-
const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
|
9
|
+
const _useBrowserTimer = require("./useBrowserTimer");
|
11
10
|
function useTimeout() {
|
12
|
-
|
13
|
-
|
14
|
-
set: (fn, delay)=>{
|
15
|
-
timeout.clear();
|
16
|
-
timeout.id = setTimeout(fn, delay);
|
17
|
-
},
|
18
|
-
clear: ()=>{
|
19
|
-
if (timeout.id !== undefined) {
|
20
|
-
clearTimeout(timeout.id);
|
21
|
-
timeout.id = undefined;
|
22
|
-
}
|
23
|
-
}
|
24
|
-
}));
|
25
|
-
// Clean up the timeout when the component is unloaded
|
26
|
-
_react.useEffect(()=>timeout.clear, [
|
27
|
-
timeout
|
28
|
-
]);
|
29
|
-
return [
|
30
|
-
timeout.set,
|
31
|
-
timeout.clear
|
32
|
-
];
|
11
|
+
// TODO: figure it out a way to not call global.setTimeout and instead infer window from some context
|
12
|
+
return (0, _useBrowserTimer.useBrowserTimer)(setTimeout, clearTimeout);
|
33
13
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["useTimeout.js"],"sourcesContent":["import
|
1
|
+
{"version":3,"sources":["useTimeout.js"],"sourcesContent":["import { useBrowserTimer } from './useBrowserTimer';\n/**\n * @internal\n * Helper to manage a browser timeout.\n * Ensures that the timeout isn't set multiple times at once and is cleaned up\n * when the component is unloaded.\n *\n * @returns A pair of [setTimeout, clearTimeout] that are stable between renders.\n */ export function useTimeout() {\n // TODO: figure it out a way to not call global.setTimeout and instead infer window from some context\n return useBrowserTimer(setTimeout, clearTimeout);\n}\n"],"names":["useTimeout","useBrowserTimer","setTimeout","clearTimeout"],"mappings":";;;;+BAQoBA;;aAAAA;;iCARY;AAQrB,SAASA,aAAa;IAC7B,qGAAqG;IACrG,OAAOC,IAAAA,gCAAe,EAACC,YAAYC;AACvC"}
|
package/lib-commonjs/index.js
CHANGED
@@ -20,6 +20,7 @@ _export(exports, {
|
|
20
20
|
SLOT_RENDER_FUNCTION_SYMBOL: ()=>_index.SLOT_RENDER_FUNCTION_SYMBOL,
|
21
21
|
IdPrefixProvider: ()=>_index1.IdPrefixProvider,
|
22
22
|
resetIdsForTests: ()=>_index1.resetIdsForTests,
|
23
|
+
useAnimationFrame: ()=>_index1.useAnimationFrame,
|
23
24
|
useControllableState: ()=>_index1.useControllableState,
|
24
25
|
useEventCallback: ()=>_index1.useEventCallback,
|
25
26
|
useFirstMount: ()=>_index1.useFirstMount,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["index.js"],"sourcesContent":["export { slot, isSlot, getSlots, getSlotsNext, assertSlots, resolveShorthand, isResolvedShorthand, SLOT_ELEMENT_TYPE_SYMBOL, SLOT_RENDER_FUNCTION_SYMBOL } from './compose/index';\nexport { IdPrefixProvider, resetIdsForTests, useControllableState, useEventCallback, useFirstMount, useForceUpdate, useId, useIsomorphicLayoutEffect, useMergedRefs, useOnClickOutside, useOnScrollOutside, usePrevious, useScrollbarWidth, useTimeout } from './hooks/index';\nexport { canUseDOM, useIsSSR, SSRProvider } from './ssr/index';\nexport { clamp, getNativeElementProps, getPartitionedNativeProps, getRTLSafeKey, mergeCallbacks, isHTMLElement, isInteractiveHTMLElement, omit, createPriorityQueue } from './utils/index';\nexport { applyTriggerPropsToChildren, getTriggerChild, isFluentTrigger } from './trigger/index';\nexport { isTouchEvent, isMouseEvent, getEventClientCoords } from './events/index';\nexport { useSelection } from './selection/index';\n"],"names":["slot","isSlot","getSlots","getSlotsNext","assertSlots","resolveShorthand","isResolvedShorthand","SLOT_ELEMENT_TYPE_SYMBOL","SLOT_RENDER_FUNCTION_SYMBOL","IdPrefixProvider","resetIdsForTests","useControllableState","useEventCallback","useFirstMount","useForceUpdate","useId","useIsomorphicLayoutEffect","useMergedRefs","useOnClickOutside","useOnScrollOutside","usePrevious","useScrollbarWidth","useTimeout","canUseDOM","useIsSSR","SSRProvider","clamp","getNativeElementProps","getPartitionedNativeProps","getRTLSafeKey","mergeCallbacks","isHTMLElement","isInteractiveHTMLElement","omit","createPriorityQueue","applyTriggerPropsToChildren","getTriggerChild","isFluentTrigger","isTouchEvent","isMouseEvent","getEventClientCoords","useSelection"],"mappings":";;;;;;;;;;;IAASA,IAAI,MAAJA,WAAI;IAAEC,MAAM,MAANA,aAAM;IAAEC,QAAQ,MAARA,eAAQ;IAAEC,YAAY,MAAZA,mBAAY;IAAEC,WAAW,MAAXA,kBAAW;IAAEC,gBAAgB,MAAhBA,uBAAgB;IAAEC,mBAAmB,MAAnBA,0BAAmB;IAAEC,wBAAwB,MAAxBA,+BAAwB;IAAEC,2BAA2B,MAA3BA,kCAA2B;IAC/IC,gBAAgB,MAAhBA,wBAAgB;IAAEC,gBAAgB,MAAhBA,wBAAgB;IAAEC,oBAAoB,MAApBA,4BAAoB;IAAEC,gBAAgB,MAAhBA,wBAAgB;IAAEC,aAAa,MAAbA,qBAAa;IAAEC,cAAc,MAAdA,sBAAc;IAAEC,KAAK,MAALA,aAAK;IAAEC,yBAAyB,MAAzBA,iCAAyB;IAAEC,aAAa,MAAbA,qBAAa;IAAEC,iBAAiB,MAAjBA,yBAAiB;IAAEC,kBAAkB,MAAlBA,0BAAkB;IAAEC,WAAW,MAAXA,mBAAW;IAAEC,iBAAiB,MAAjBA,yBAAiB;IAAEC,UAAU,MAAVA,kBAAU;
|
1
|
+
{"version":3,"sources":["index.js"],"sourcesContent":["export { slot, isSlot, getSlots, getSlotsNext, assertSlots, resolveShorthand, isResolvedShorthand, SLOT_ELEMENT_TYPE_SYMBOL, SLOT_RENDER_FUNCTION_SYMBOL } from './compose/index';\nexport { IdPrefixProvider, resetIdsForTests, useAnimationFrame, useControllableState, useEventCallback, useFirstMount, useForceUpdate, useId, useIsomorphicLayoutEffect, useMergedRefs, useOnClickOutside, useOnScrollOutside, usePrevious, useScrollbarWidth, useTimeout } from './hooks/index';\nexport { canUseDOM, useIsSSR, SSRProvider } from './ssr/index';\nexport { clamp, getNativeElementProps, getPartitionedNativeProps, getRTLSafeKey, mergeCallbacks, isHTMLElement, isInteractiveHTMLElement, omit, createPriorityQueue } from './utils/index';\nexport { applyTriggerPropsToChildren, getTriggerChild, isFluentTrigger } from './trigger/index';\nexport { isTouchEvent, isMouseEvent, getEventClientCoords } from './events/index';\nexport { useSelection } from './selection/index';\n"],"names":["slot","isSlot","getSlots","getSlotsNext","assertSlots","resolveShorthand","isResolvedShorthand","SLOT_ELEMENT_TYPE_SYMBOL","SLOT_RENDER_FUNCTION_SYMBOL","IdPrefixProvider","resetIdsForTests","useAnimationFrame","useControllableState","useEventCallback","useFirstMount","useForceUpdate","useId","useIsomorphicLayoutEffect","useMergedRefs","useOnClickOutside","useOnScrollOutside","usePrevious","useScrollbarWidth","useTimeout","canUseDOM","useIsSSR","SSRProvider","clamp","getNativeElementProps","getPartitionedNativeProps","getRTLSafeKey","mergeCallbacks","isHTMLElement","isInteractiveHTMLElement","omit","createPriorityQueue","applyTriggerPropsToChildren","getTriggerChild","isFluentTrigger","isTouchEvent","isMouseEvent","getEventClientCoords","useSelection"],"mappings":";;;;;;;;;;;IAASA,IAAI,MAAJA,WAAI;IAAEC,MAAM,MAANA,aAAM;IAAEC,QAAQ,MAARA,eAAQ;IAAEC,YAAY,MAAZA,mBAAY;IAAEC,WAAW,MAAXA,kBAAW;IAAEC,gBAAgB,MAAhBA,uBAAgB;IAAEC,mBAAmB,MAAnBA,0BAAmB;IAAEC,wBAAwB,MAAxBA,+BAAwB;IAAEC,2BAA2B,MAA3BA,kCAA2B;IAC/IC,gBAAgB,MAAhBA,wBAAgB;IAAEC,gBAAgB,MAAhBA,wBAAgB;IAAEC,iBAAiB,MAAjBA,yBAAiB;IAAEC,oBAAoB,MAApBA,4BAAoB;IAAEC,gBAAgB,MAAhBA,wBAAgB;IAAEC,aAAa,MAAbA,qBAAa;IAAEC,cAAc,MAAdA,sBAAc;IAAEC,KAAK,MAALA,aAAK;IAAEC,yBAAyB,MAAzBA,iCAAyB;IAAEC,aAAa,MAAbA,qBAAa;IAAEC,iBAAiB,MAAjBA,yBAAiB;IAAEC,kBAAkB,MAAlBA,0BAAkB;IAAEC,WAAW,MAAXA,mBAAW;IAAEC,iBAAiB,MAAjBA,yBAAiB;IAAEC,UAAU,MAAVA,kBAAU;IAChQC,SAAS,MAATA,iBAAS;IAAEC,QAAQ,MAARA,gBAAQ;IAAEC,WAAW,MAAXA,mBAAW;IAChCC,KAAK,MAALA,aAAK;IAAEC,qBAAqB,MAArBA,6BAAqB;IAAEC,yBAAyB,MAAzBA,iCAAyB;IAAEC,aAAa,MAAbA,qBAAa;IAAEC,cAAc,MAAdA,sBAA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