@fluentui/react-utilities 9.15.2 → 9.15.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -2
- package/lib/hooks/useOnClickOutside.js +8 -4
- package/lib/hooks/useOnClickOutside.js.map +1 -1
- package/lib/ssr/canUseDOM.js +2 -2
- package/lib/ssr/canUseDOM.js.map +1 -1
- package/lib-commonjs/hooks/useOnClickOutside.js +8 -4
- package/lib-commonjs/hooks/useOnClickOutside.js.map +1 -1
- package/lib-commonjs/ssr/canUseDOM.js +1 -2
- package/lib-commonjs/ssr/canUseDOM.js.map +1 -1
- package/package.json +2 -1
package/CHANGELOG.md
CHANGED
@@ -1,12 +1,22 @@
|
|
1
1
|
# Change Log - @fluentui/react-utilities
|
2
2
|
|
3
|
-
This log was last generated on Thu,
|
3
|
+
This log was last generated on Thu, 14 Dec 2023 09:51:37 GMT and should not be manually modified.
|
4
4
|
|
5
5
|
<!-- Start content -->
|
6
6
|
|
7
|
+
## [9.15.3](https://github.com/microsoft/fluentui/tree/@fluentui/react-utilities_v9.15.3)
|
8
|
+
|
9
|
+
Thu, 14 Dec 2023 09:51:37 GMT
|
10
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-utilities_v9.15.2..@fluentui/react-utilities_v9.15.3)
|
11
|
+
|
12
|
+
### Patches
|
13
|
+
|
14
|
+
- chore: disallow `window` and `document` access ([PR #29962](https://github.com/microsoft/fluentui/pull/29962) by seanmonahan@microsoft.com)
|
15
|
+
- Bump @fluentui/react-shared-contexts to v9.13.1 ([commit](https://github.com/microsoft/fluentui/commit/80a1b02be2fbbdde916ac87fbf760e442a2295c4) by beachball)
|
16
|
+
|
7
17
|
## [9.15.2](https://github.com/microsoft/fluentui/tree/@fluentui/react-utilities_v9.15.2)
|
8
18
|
|
9
|
-
Thu, 09 Nov 2023 17:
|
19
|
+
Thu, 09 Nov 2023 17:29:48 GMT
|
10
20
|
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-utilities_v9.15.1..@fluentui/react-utilities_v9.15.2)
|
11
21
|
|
12
22
|
### Patches
|
@@ -1,10 +1,13 @@
|
|
1
1
|
import * as React from 'react';
|
2
2
|
import { useEventCallback } from './useEventCallback';
|
3
|
+
import { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';
|
3
4
|
const DEFAULT_CONTAINS = (parent, child)=>!!(parent === null || parent === void 0 ? void 0 : parent.contains(child));
|
4
5
|
/**
|
5
6
|
* @internal
|
6
7
|
* Utility to perform checks where a click/touch event was made outside a component
|
7
8
|
*/ export const useOnClickOutside = (options)=>{
|
9
|
+
const { targetDocument } = useFluent();
|
10
|
+
const win = targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.defaultView;
|
8
11
|
const { refs, callback, element, disabled, disabledFocusOnIframe, contains = DEFAULT_CONTAINS } = options;
|
9
12
|
const timeoutId = React.useRef(undefined);
|
10
13
|
useIFrameFocus({
|
@@ -39,7 +42,7 @@ const DEFAULT_CONTAINS = (parent, child)=>!!(parent === null || parent === void
|
|
39
42
|
// Store the current event to avoid triggering handlers immediately
|
40
43
|
// Note this depends on a deprecated but extremely well supported quirk of the web platform
|
41
44
|
// https://github.com/facebook/react/issues/20074
|
42
|
-
let currentEvent = getWindowEvent(
|
45
|
+
let currentEvent = getWindowEvent(win);
|
43
46
|
const conditionalHandler = (event)=>{
|
44
47
|
// Skip if this event is the same as the one running when we added the handlers
|
45
48
|
if (event === currentEvent) {
|
@@ -54,7 +57,7 @@ const DEFAULT_CONTAINS = (parent, child)=>!!(parent === null || parent === void
|
|
54
57
|
element === null || element === void 0 ? void 0 : element.addEventListener('contextmenu', conditionalHandler, true);
|
55
58
|
element === null || element === void 0 ? void 0 : element.addEventListener('mousedown', handleMouseDown, true);
|
56
59
|
// Garbage collect this event after it's no longer useful to avoid memory leaks
|
57
|
-
timeoutId.current =
|
60
|
+
timeoutId.current = win === null || win === void 0 ? void 0 : win.setTimeout(()=>{
|
58
61
|
currentEvent = undefined;
|
59
62
|
}, 1);
|
60
63
|
return ()=>{
|
@@ -62,14 +65,15 @@ const DEFAULT_CONTAINS = (parent, child)=>!!(parent === null || parent === void
|
|
62
65
|
element === null || element === void 0 ? void 0 : element.removeEventListener('touchstart', conditionalHandler, true);
|
63
66
|
element === null || element === void 0 ? void 0 : element.removeEventListener('contextmenu', conditionalHandler, true);
|
64
67
|
element === null || element === void 0 ? void 0 : element.removeEventListener('mousedown', handleMouseDown, true);
|
65
|
-
clearTimeout(timeoutId.current);
|
68
|
+
win === null || win === void 0 ? void 0 : win.clearTimeout(timeoutId.current);
|
66
69
|
currentEvent = undefined;
|
67
70
|
};
|
68
71
|
}, [
|
69
72
|
listener,
|
70
73
|
element,
|
71
74
|
disabled,
|
72
|
-
handleMouseDown
|
75
|
+
handleMouseDown,
|
76
|
+
win
|
73
77
|
]);
|
74
78
|
};
|
75
79
|
const getWindowEvent = (target)=>{
|
@@ -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 * 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('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\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,QAAU,CAAC,EAACD,mBAAAA,6BAAAA,OAAQE,QAAQ,CAACD;AAE7G;;;CAGC,GACD,OAAO,MAAME,oBAAoB,CAACC;IAChC,MAAM,EAAEC,IAAI,EAAEC,QAAQ,EAAEC,OAAO,EAAEC,QAAQ,EAAEC,qBAAqB,EAAEP,WAAWH,gBAAgB,EAAE,GAAGK;IAClG,MAAMM,YAAYb,MAAMc,MAAM,CAAqBC;IAEnDC,eAAe;QAAEN;QAASC,UAAUC,yBAAyBD;QAAUF;QAAUD;QAAMH;IAAS;IAEhG,MAAMY,uBAAuBjB,MAAMc,MAAM,CAAC;IAC1C,MAAMI,WAAWjB,iBAAiB,CAACkB;QACjC,IAAIF,qBAAqBG,OAAO,EAAE;YAChCH,qBAAqBG,OAAO,GAAG;YAC/B;QACF;QAEA,MAAMC,SAASF,GAAGG,YAAY,EAAE,CAAC,EAAE;QACnC,MAAMC,YAAYf,KAAKgB,KAAK,CAACC,CAAAA,MAAO,CAACpB,SAASoB,IAAIL,OAAO,IAAI,MAAM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A,sCAAAA,8BAAAA,eAAgBF,WAAW,cAA3BE,kDAAAA,4BAA6BI,WAAW,CAAC;YAC5D,MAAMC,gBAAgBL,2BAAAA,qCAAAA,eAAgBK,aAAa;YAEnD,IAAIA,CAAAA,0BAAAA,oCAAAA,cAAeC,OAAO,MAAK,YAAYD,CAAAA,0BAAAA,oCAAAA,cAAeC,OAAO,MAAK,WAAW;gBAC/E,MAAMd,QAAQ,IAAIe,YAAYR,iBAAiB;oBAAES,SAAS;gBAAK;gBAC/DH,cAAcI,aAAa,CAACjB;YAC9B;QACF,GAAGS;QAEH,OAAO;gBACLD;YAAAA,2BAAAA,sCAAAA,8BAAAA,eAAgBF,WAAW,cAA3BE,kDAAAA,4BAA6BJ,YAAY,CAACM,WAAWvB,OAAO;QAC9D;IACF,GAAG;QAACqB;QAAgB9B;QAAU+B;KAAa;AAC7C"}
|
1
|
+
{"version":3,"sources":["useOnClickOutside.ts"],"sourcesContent":["import * as React from 'react';\nimport { useEventCallback } from './useEventCallback';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\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 { targetDocument } = useFluent();\n const win = targetDocument?.defaultView;\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(win);\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 = win?.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 win?.clearTimeout(timeoutId.current);\n currentEvent = undefined;\n };\n }, [listener, element, disabled, handleMouseDown, win]);\n};\n\nconst getWindowEvent = (target: Node | Window | null | undefined): 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","useFluent_unstable","useFluent","DEFAULT_CONTAINS","parent","child","contains","useOnClickOutside","options","targetDocument","win","defaultView","refs","callback","element","disabled","disabledFocusOnIframe","timeoutId","useRef","undefined","useIFrameFocus","isMouseDownInsideRef","listener","ev","current","target","composedPath","isOutside","every","ref","handleMouseDown","some","useEffect","currentEvent","getWindowEvent","conditionalHandler","event","addEventListener","setTimeout","removeEventListener","clearTimeout","window","ownerDocument","FUI_FRAME_EVENT","pollDuration","timeoutRef","e","setInterval","activeElement","tagName","CustomEvent","bubbles","dispatchEvent"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,gBAAgB,QAAQ,qBAAqB;AACtD,SAASC,sBAAsBC,SAAS,QAAQ,kCAAkC;AAuClF,MAAMC,mBAAiE,CAACC,QAAQC,QAAU,CAAC,EAACD,mBAAAA,6BAAAA,OAAQE,QAAQ,CAACD;AAE7G;;;CAGC,GACD,OAAO,MAAME,oBAAoB,CAACC;IAChC,MAAM,EAAEC,cAAc,EAAE,GAAGP;IAC3B,MAAMQ,MAAMD,2BAAAA,qCAAAA,eAAgBE,WAAW;IACvC,MAAM,EAAEC,IAAI,EAAEC,QAAQ,EAAEC,OAAO,EAAEC,QAAQ,EAAEC,qBAAqB,EAAEV,WAAWH,gBAAgB,EAAE,GAAGK;IAClG,MAAMS,YAAYlB,MAAMmB,MAAM,CAAqBC;IAEnDC,eAAe;QAAEN;QAASC,UAAUC,yBAAyBD;QAAUF;QAAUD;QAAMN;IAAS;IAEhG,MAAMe,uBAAuBtB,MAAMmB,MAAM,CAAC;IAC1C,MAAMI,WAAWtB,iBAAiB,CAACuB;QACjC,IAAIF,qBAAqBG,OAAO,EAAE;YA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,OAAO;YACLb,2BAAAA,qCAAAA,eAAgB8B,mBAAmB,CAACI,iBAAiBrB,UAAU;QACjE;IACF,GAAG;QAACb;QAAgBM;QAAUO;KAAS;IAEvC,wCAAwC;IACxCvB,MAAMiC,SAAS,CAAC;YAKOvB;QAJrB,IAAIM,UAAU;YACZ;QACF;QAEA8B,WAAWrB,OAAO,GAAGf,2BAAAA,sCAAAA,8BAAAA,eAAgBE,WAAW,cAA3BF,kDAAAA,4BAA6BsC,WAAW,CAAC;YAC5D,MAAMC,gBAAgBvC,2BAAAA,qCAAAA,eAAgBuC,aAAa;YAEnD,IAAIA,CAAAA,0BAAAA,oCAAAA,cAAeC,OAAO,MAAK,YAAYD,CAAAA,0BAAAA,oCAAAA,cAAeC,OAAO,MAAK,WAAW;gBAC/E,MAAMb,QAAQ,IAAIc,YAAYP,iBAAiB;oBAAEQ,SAAS;gBAAK;gBAC/DH,cAAcI,aAAa,CAAChB;YAC9B;QACF,GAAGQ;QAEH,OAAO;gBACLnC;YAAAA,2BAAAA,sCAAAA,8BAAAA,eAAgBE,WAAW,cAA3BF,kDAAAA,4BAA6B+B,YAAY,CAACK,WAAWrB,OAAO;QAC9D;IACF,GAAG;QAACf;QAAgBM;QAAU6B;KAAa;AAC7C"}
|
package/lib/ssr/canUseDOM.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
/**
|
2
2
|
* Verifies if an application can use DOM.
|
3
3
|
*/ export function canUseDOM() {
|
4
|
-
return
|
5
|
-
window.document.createElement);
|
4
|
+
return(// eslint-disable-next-line deprecation/deprecation, no-restricted-globals
|
5
|
+
typeof window !== 'undefined' && !!(window.document && window.document.createElement));
|
6
6
|
}
|
package/lib/ssr/canUseDOM.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["canUseDOM.ts"],"sourcesContent":["/**\n * Verifies if an application can use DOM.\n */\nexport function canUseDOM(): boolean {\n return (\n typeof window !== 'undefined'
|
1
|
+
{"version":3,"sources":["canUseDOM.ts"],"sourcesContent":["/**\n * Verifies if an application can use DOM.\n */\nexport function canUseDOM(): boolean {\n return (\n // eslint-disable-next-line deprecation/deprecation, no-restricted-globals\n typeof window !== 'undefined' && !!(window.document && window.document.createElement)\n );\n}\n"],"names":["canUseDOM","window","document","createElement"],"mappings":"AAAA;;CAEC,GACD,OAAO,SAASA;IACd,OACE,0EAA0E;IAC1E,OAAOC,WAAW,eAAe,CAAC,CAAEA,CAAAA,OAAOC,QAAQ,IAAID,OAAOC,QAAQ,CAACC,aAAa,AAAD;AAEvF"}
|
@@ -11,8 +11,11 @@ Object.defineProperty(exports, "useOnClickOutside", {
|
|
11
11
|
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
12
12
|
const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
|
13
13
|
const _useEventCallback = require("./useEventCallback");
|
14
|
+
const _reactsharedcontexts = require("@fluentui/react-shared-contexts");
|
14
15
|
const DEFAULT_CONTAINS = (parent, child)=>!!(parent === null || parent === void 0 ? void 0 : parent.contains(child));
|
15
16
|
const useOnClickOutside = (options)=>{
|
17
|
+
const { targetDocument } = (0, _reactsharedcontexts.useFluent_unstable)();
|
18
|
+
const win = targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.defaultView;
|
16
19
|
const { refs, callback, element, disabled, disabledFocusOnIframe, contains = DEFAULT_CONTAINS } = options;
|
17
20
|
const timeoutId = _react.useRef(undefined);
|
18
21
|
useIFrameFocus({
|
@@ -47,7 +50,7 @@ const useOnClickOutside = (options)=>{
|
|
47
50
|
// Store the current event to avoid triggering handlers immediately
|
48
51
|
// Note this depends on a deprecated but extremely well supported quirk of the web platform
|
49
52
|
// https://github.com/facebook/react/issues/20074
|
50
|
-
let currentEvent = getWindowEvent(
|
53
|
+
let currentEvent = getWindowEvent(win);
|
51
54
|
const conditionalHandler = (event)=>{
|
52
55
|
// Skip if this event is the same as the one running when we added the handlers
|
53
56
|
if (event === currentEvent) {
|
@@ -62,7 +65,7 @@ const useOnClickOutside = (options)=>{
|
|
62
65
|
element === null || element === void 0 ? void 0 : element.addEventListener('contextmenu', conditionalHandler, true);
|
63
66
|
element === null || element === void 0 ? void 0 : element.addEventListener('mousedown', handleMouseDown, true);
|
64
67
|
// Garbage collect this event after it's no longer useful to avoid memory leaks
|
65
|
-
timeoutId.current =
|
68
|
+
timeoutId.current = win === null || win === void 0 ? void 0 : win.setTimeout(()=>{
|
66
69
|
currentEvent = undefined;
|
67
70
|
}, 1);
|
68
71
|
return ()=>{
|
@@ -70,14 +73,15 @@ const useOnClickOutside = (options)=>{
|
|
70
73
|
element === null || element === void 0 ? void 0 : element.removeEventListener('touchstart', conditionalHandler, true);
|
71
74
|
element === null || element === void 0 ? void 0 : element.removeEventListener('contextmenu', conditionalHandler, true);
|
72
75
|
element === null || element === void 0 ? void 0 : element.removeEventListener('mousedown', handleMouseDown, true);
|
73
|
-
clearTimeout(timeoutId.current);
|
76
|
+
win === null || win === void 0 ? void 0 : win.clearTimeout(timeoutId.current);
|
74
77
|
currentEvent = undefined;
|
75
78
|
};
|
76
79
|
}, [
|
77
80
|
listener,
|
78
81
|
element,
|
79
82
|
disabled,
|
80
|
-
handleMouseDown
|
83
|
+
handleMouseDown,
|
84
|
+
win
|
81
85
|
]);
|
82
86
|
};
|
83
87
|
const getWindowEvent = (target)=>{
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["useOnClickOutside.js"],"sourcesContent":["import * as React from 'react';\nimport { useEventCallback } from './useEventCallback';\nconst DEFAULT_CONTAINS = (parent, child)=>!!(parent === null || parent === void 0 ? void 0 : parent.contains(child));\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('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_defaultView, _target_ownerDocument;\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_defaultView","_target_ownerDocument","_target_ownerDocument_defaultView_event","ownerDocument","defaultView","FUI_FRAME_EVENT","targetDocument","pollDuration","timeoutRef","e","_targetDocument_defaultView","setInterval","activeElement","tagName","CustomEvent","bubbles","dispatchEvent"],"mappings":";;;;+BAMiBA;;;eAAAA;;;;iEANM;kCACU;AACjC,MAAMC,mBAAmB,CAACC,QAAQC,QAAQ,CAAC,CAAED,CAAAA,WAAW,QAAQA,WAAW,KAAK,IAAI,KAAK,IAAIA,OAAOE,QAAQ,CAACD,MAAK;AAIvG,MAAMH,oBAAoB,CAACK;IAClC,MAAM,EAAEC,IAAI,EAAEC,QAAQ,EAAEC,OAAO,EAAEC,QAAQ,EAAEC,qBAAqB,EAAEN,WAAWH,gBAAgB,EAAE,GAAGI;IAClG,MAAMM,YAAYC,OAAMC,MAAM,CAACC;IAC/BC,eAAe;QACXP;QACAC,UAAUC,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MAAMlB,QAAQ,IAAImB,YAAYT,iBAAiB;oBAC3CU,SAAS;gBACb;gBACAH,cAAcI,aAAa,CAACrB;YAChC;QACJ,GAAGY;QACH,OAAO;YACH,IAAIG;YACJJ,mBAAmB,QAAQA,mBAAmB,KAAK,IAAI,KAAK,IAAI,AAACI,CAAAA,8BAA8BJ,eAAeF,WAAW,AAAD,MAAO,QAAQM,gCAAgC,KAAK,IAAI,KAAK,IAAIA,4BAA4BX,YAAY,CAACS,WAAW1B,OAAO;QACxP;IACJ,GAAG;QACCwB;QACAnC;QACAoC;KACH;AACL"}
|
1
|
+
{"version":3,"sources":["useOnClickOutside.js"],"sourcesContent":["import * as React from 'react';\nimport { useEventCallback } from './useEventCallback';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\nconst DEFAULT_CONTAINS = (parent, child)=>!!(parent === null || parent === void 0 ? void 0 : parent.contains(child));\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 { targetDocument } = useFluent();\n const win = targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.defaultView;\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(win);\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 = win === null || win === void 0 ? void 0 : win.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 win === null || win === void 0 ? void 0 : win.clearTimeout(timeoutId.current);\n currentEvent = undefined;\n };\n }, [\n listener,\n element,\n disabled,\n handleMouseDown,\n win\n ]);\n};\nconst getWindowEvent = (target)=>{\n if (target) {\n var _target_ownerDocument_defaultView, _target_ownerDocument;\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","targetDocument","useFluent","win","defaultView","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","conditionalHandler","event","addEventListener","setTimeout","removeEventListener","clearTimeout","_target_ownerDocument_defaultView","_target_ownerDocument","window","_target_ownerDocument_defaultView_event","ownerDocument","FUI_FRAME_EVENT","pollDuration","timeoutRef","e","_targetDocument_defaultView","setInterval","activeElement","tagName","CustomEvent","bubbles","dispatchEvent"],"mappings":";;;;+BAOiBA;;;eAAAA;;;;iEAPM;kCACU;qCACe;AAChD,MAAMC,mBAAmB,CAACC,QAAQC,QAAQ,CAAC,CAAED,CAAAA,WAAW,QAAQA,WAAW,KAAK,IAAI,KAAK,IAAIA,OAAOE,QAAQ,CAACD,MAAK;AAIvG,MAAMH,oBAAoB,CAACK;IAClC,MAAM,EAAEC,cAAc,EAAE,GAAGC,IAAAA,uCAAS;IACpC,MAAMC,MAAMF,mBAAmB,QAAQA,mBAAmB,KAAK,IAAI,KAAK,IAAIA,eAAeG,WAAW;IACtG,MAAM,EAAEC,IAAI,EAAEC,QAAQ,EAAEC,OAAO,EAAEC,QAAQ,EAAEC,qBAAqB,EAAEV,WAAWH,gBAAgB,EAAE,GAAGI;IAClG,MAAMU,YAAYC,OAAMC,MAAM,CAACC;IAC/BC,eAAe;QACXP;QACAC,UAAUC,yBAAyBD;QACnCF;QACAD;QACAN;IACJ;IACA,MAAMgB,uBAAuBJ,OAAMC,MAAM,CAAC;IAC1C,MAAMI,WAAWC,IAAAA,kCAAgB,EAAC,CAACC;QAC/B,IAAIH,qBAAqBI,OAAO,EAAE;YAC9B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3CS,SAAS;gBACb;gBACAH,cAAcI,aAAa,CAACpB;YAChC;QACJ,GAAGW;QACH,OAAO;YACH,IAAIG;YACJ5C,mBAAmB,QAAQA,mBAAmB,KAAK,IAAI,KAAK,IAAI,AAAC4C,CAAAA,8BAA8B5C,eAAeG,WAAW,AAAD,MAAO,QAAQyC,gCAAgC,KAAK,IAAI,KAAK,IAAIA,4BAA4BV,YAAY,CAACQ,WAAWxB,OAAO;QACxP;IACJ,GAAG;QACClB;QACAO;QACAkC;KACH;AACL"}
|
@@ -11,6 +11,5 @@ Object.defineProperty(exports, "canUseDOM", {
|
|
11
11
|
}
|
12
12
|
});
|
13
13
|
function canUseDOM() {
|
14
|
-
return typeof window !== 'undefined' && !!(window.document &&
|
15
|
-
window.document.createElement);
|
14
|
+
return typeof window !== 'undefined' && !!(window.document && window.document.createElement);
|
16
15
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["canUseDOM.js"],"sourcesContent":["/**\n * Verifies if an application can use DOM.\n */ export function canUseDOM() {\n return typeof window !== 'undefined' && !!(window.document &&
|
1
|
+
{"version":3,"sources":["canUseDOM.js"],"sourcesContent":["/**\n * Verifies if an application can use DOM.\n */ export function canUseDOM() {\n return(// eslint-disable-next-line deprecation/deprecation, no-restricted-globals\n typeof window !== 'undefined' && !!(window.document && window.document.createElement));\n}\n"],"names":["canUseDOM","window","document","createElement"],"mappings":"AAAA;;CAEC;;;;+BAAmBA;;;eAAAA;;;AAAT,SAASA;IAChB,OACA,OAAOC,WAAW,eAAe,CAAC,CAAEA,CAAAA,OAAOC,QAAQ,IAAID,OAAOC,QAAQ,CAACC,aAAa,AAAD;AACvF"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@fluentui/react-utilities",
|
3
|
-
"version": "9.15.
|
3
|
+
"version": "9.15.3",
|
4
4
|
"description": "A set of general React-specific utilities.",
|
5
5
|
"main": "lib-commonjs/index.js",
|
6
6
|
"module": "lib/index.js",
|
@@ -32,6 +32,7 @@
|
|
32
32
|
},
|
33
33
|
"dependencies": {
|
34
34
|
"@fluentui/keyboard-keys": "^9.0.7",
|
35
|
+
"@fluentui/react-shared-contexts": "^9.13.1",
|
35
36
|
"@swc/helpers": "^0.5.1"
|
36
37
|
},
|
37
38
|
"peerDependencies": {
|