@fluentui/react-utilities 9.18.10 → 9.18.12
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 +23 -2
- package/dist/index.d.ts +3 -7
- package/lib/compose/assertSlots.js.map +1 -1
- package/lib/compose/constants.js.map +1 -1
- package/lib/compose/deprecated/getSlots.js.map +1 -1
- package/lib/compose/deprecated/getSlotsNext.js.map +1 -1
- package/lib/compose/deprecated/resolveShorthand.js.map +1 -1
- package/lib/compose/getIntrinsicElementProps.js.map +1 -1
- package/lib/compose/index.js.map +1 -1
- package/lib/compose/isResolvedShorthand.js.map +1 -1
- package/lib/compose/isSlot.js.map +1 -1
- package/lib/compose/slot.js.map +1 -1
- package/lib/compose/types.js.map +1 -1
- package/lib/events/index.js.map +1 -1
- package/lib/events/mouseTouchHelpers.js.map +1 -1
- package/lib/hooks/index.js.map +1 -1
- package/lib/hooks/useAnimationFrame.js.map +1 -1
- package/lib/hooks/useBrowserTimer.js.map +1 -1
- package/lib/hooks/useControllableState.js +2 -0
- package/lib/hooks/useControllableState.js.map +1 -1
- package/lib/hooks/useEventCallback.js.map +1 -1
- package/lib/hooks/useFirstMount.js.map +1 -1
- package/lib/hooks/useForceUpdate.js.map +1 -1
- package/lib/hooks/useId.js +1 -0
- package/lib/hooks/useId.js.map +1 -1
- package/lib/hooks/useIsomorphicLayoutEffect.js.map +1 -1
- package/lib/hooks/useMergedRefs.js +1 -0
- package/lib/hooks/useMergedRefs.js.map +1 -1
- package/lib/hooks/useOnClickOutside.js.map +1 -1
- package/lib/hooks/useOnScrollOutside.js.map +1 -1
- package/lib/hooks/usePrevious.js.map +1 -1
- package/lib/hooks/useScrollbarWidth.js.map +1 -1
- package/lib/hooks/useTimeout.js.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/selection/index.js.map +1 -1
- package/lib/selection/types.js.map +1 -1
- package/lib/selection/useSelection.js +1 -0
- package/lib/selection/useSelection.js.map +1 -1
- package/lib/ssr/SSRContext.js.map +1 -1
- package/lib/ssr/canUseDOM.js.map +1 -1
- package/lib/ssr/index.js.map +1 -1
- package/lib/trigger/applyTriggerPropsToChildren.js.map +1 -1
- package/lib/trigger/getTriggerChild.js.map +1 -1
- package/lib/trigger/index.js.map +1 -1
- package/lib/trigger/isFluentTrigger.js.map +1 -1
- package/lib/trigger/types.js.map +1 -1
- package/lib/utils/clamp.js.map +1 -1
- package/lib/utils/createSetFromIterable.js.map +1 -1
- package/lib/utils/getNativeElementProps.js.map +1 -1
- package/lib/utils/getRTLSafeKey.js.map +1 -1
- package/lib/utils/getReactCallbackName.js.map +1 -1
- package/lib/utils/index.js.map +1 -1
- package/lib/utils/isHTMLElement.js.map +1 -1
- package/lib/utils/isInteractiveHTMLElement.js.map +1 -1
- package/lib/utils/mergeCallbacks.js.map +1 -1
- package/lib/utils/omit.js.map +1 -1
- package/lib/utils/priorityQueue.js.map +1 -1
- package/lib/utils/properties.js.map +1 -1
- package/lib/utils/types.js +4 -1
- package/lib/utils/types.js.map +1 -1
- package/lib/virtualParent/elementContains.js.map +1 -1
- package/lib/virtualParent/getParent.js.map +1 -1
- package/lib/virtualParent/index.js.map +1 -1
- package/lib/virtualParent/isVirtualElement.js.map +1 -1
- package/lib/virtualParent/setVirtualParent.js.map +1 -1
- package/lib/virtualParent/types.js.map +1 -1
- package/lib-commonjs/compose/assertSlots.js.map +1 -1
- package/lib-commonjs/compose/constants.js +3 -3
- package/lib-commonjs/compose/constants.js.map +1 -1
- package/lib-commonjs/compose/deprecated/getSlots.js.map +1 -1
- package/lib-commonjs/compose/deprecated/getSlotsNext.js.map +1 -1
- package/lib-commonjs/compose/deprecated/resolveShorthand.js.map +1 -1
- package/lib-commonjs/compose/getIntrinsicElementProps.js.map +1 -1
- package/lib-commonjs/compose/index.js.map +1 -1
- package/lib-commonjs/compose/isResolvedShorthand.js.map +1 -1
- package/lib-commonjs/compose/isSlot.js.map +1 -1
- package/lib-commonjs/compose/slot.js.map +1 -1
- package/lib-commonjs/compose/types.js.map +1 -1
- package/lib-commonjs/events/index.js.map +1 -1
- package/lib-commonjs/events/mouseTouchHelpers.js +4 -4
- package/lib-commonjs/events/mouseTouchHelpers.js.map +1 -1
- package/lib-commonjs/hooks/index.js.map +1 -1
- package/lib-commonjs/hooks/useAnimationFrame.js.map +1 -1
- package/lib-commonjs/hooks/useBrowserTimer.js.map +1 -1
- package/lib-commonjs/hooks/useControllableState.js +2 -0
- package/lib-commonjs/hooks/useControllableState.js.map +1 -1
- package/lib-commonjs/hooks/useEventCallback.js.map +1 -1
- package/lib-commonjs/hooks/useFirstMount.js.map +1 -1
- package/lib-commonjs/hooks/useForceUpdate.js.map +1 -1
- package/lib-commonjs/hooks/useId.js +1 -0
- package/lib-commonjs/hooks/useId.js.map +1 -1
- package/lib-commonjs/hooks/useIsomorphicLayoutEffect.js.map +1 -1
- package/lib-commonjs/hooks/useMergedRefs.js +1 -0
- package/lib-commonjs/hooks/useMergedRefs.js.map +1 -1
- package/lib-commonjs/hooks/useOnClickOutside.js.map +1 -1
- package/lib-commonjs/hooks/useOnScrollOutside.js.map +1 -1
- package/lib-commonjs/hooks/usePrevious.js.map +1 -1
- package/lib-commonjs/hooks/useScrollbarWidth.js.map +1 -1
- package/lib-commonjs/hooks/useTimeout.js.map +1 -1
- package/lib-commonjs/index.js +81 -81
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/selection/index.js.map +1 -1
- package/lib-commonjs/selection/types.js.map +1 -1
- package/lib-commonjs/selection/useSelection.js +1 -0
- package/lib-commonjs/selection/useSelection.js.map +1 -1
- package/lib-commonjs/ssr/SSRContext.js +6 -6
- package/lib-commonjs/ssr/SSRContext.js.map +1 -1
- package/lib-commonjs/ssr/canUseDOM.js.map +1 -1
- package/lib-commonjs/ssr/index.js.map +1 -1
- package/lib-commonjs/trigger/applyTriggerPropsToChildren.js.map +1 -1
- package/lib-commonjs/trigger/getTriggerChild.js.map +1 -1
- package/lib-commonjs/trigger/index.js.map +1 -1
- package/lib-commonjs/trigger/isFluentTrigger.js.map +1 -1
- package/lib-commonjs/trigger/types.js.map +1 -1
- package/lib-commonjs/utils/clamp.js.map +1 -1
- package/lib-commonjs/utils/createSetFromIterable.js.map +1 -1
- package/lib-commonjs/utils/getNativeElementProps.js.map +1 -1
- package/lib-commonjs/utils/getRTLSafeKey.js.map +1 -1
- package/lib-commonjs/utils/getReactCallbackName.js.map +1 -1
- package/lib-commonjs/utils/index.js.map +1 -1
- package/lib-commonjs/utils/isHTMLElement.js.map +1 -1
- package/lib-commonjs/utils/isInteractiveHTMLElement.js.map +1 -1
- package/lib-commonjs/utils/mergeCallbacks.js.map +1 -1
- package/lib-commonjs/utils/omit.js.map +1 -1
- package/lib-commonjs/utils/priorityQueue.js.map +1 -1
- package/lib-commonjs/utils/properties.js +52 -52
- package/lib-commonjs/utils/properties.js.map +1 -1
- package/lib-commonjs/utils/types.js +4 -1
- package/lib-commonjs/utils/types.js.map +1 -1
- package/lib-commonjs/virtualParent/elementContains.js.map +1 -1
- package/lib-commonjs/virtualParent/getParent.js.map +1 -1
- package/lib-commonjs/virtualParent/index.js.map +1 -1
- package/lib-commonjs/virtualParent/isVirtualElement.js.map +1 -1
- package/lib-commonjs/virtualParent/setVirtualParent.js.map +1 -1
- package/lib-commonjs/virtualParent/types.js.map +1 -1
- package/package.json +2 -2
@@ -1 +1 @@
|
|
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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AQA,mBAAmB,KAAK,IAAI,KAAK,IAAI,AAAC4C,CAAAA,8BAA8B5C,eAAeG,WAAW,AAAD,MAAO,QAAQyC,gCAAgC,KAAK,IAAI,KAAK,IAAIA,4BAA4BC,WAAW,CAAC;YAClP,MAAMC,gBAAgB9C,mBAAmB,QAAQA,mBAAmB,KAAK,IAAI,KAAK,IAAIA,eAAe8C,aAAa;YAClH,IAAI,AAACA,CAAAA,kBAAkB,QAAQA,kBAAkB,KAAK,IAAI,KAAK,IAAIA,cAAcC,OAAO,AAAD,MAAO,YAAY,AAACD,CAAAA,kBAAkB,QAAQA,kBAAkB,KAAK,IAAI,KAAK,IAAIA,cAAcC,OAAO,AAAD,MAAO,WAAW;gBAC3M,MAAMjB,QAAQ,IAAIkB,YAAYR,iBAAiB;oBAC3CS,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"}
|
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":["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","setInterval","activeElement","tagName","CustomEvent","bubbles","dispatchEvent"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BA+CaA;;;eAAAA;;;;iEA/CU;kCACU;qCACe;AAuChD,MAAMC,mBAAiE,CAACC,QAAQC,QAAU,CAAC,CAACD,CAAAA,WAAAA,QAAAA,WAAAA,KAAAA,IAAAA,KAAAA,IAAAA,OAAQE,QAAQ,CAACD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;IAEvC,wCAAwC;IACxCL,OAAMgB,SAAS,CAAC;YAKO1B;QAJrB,IAAIO,UAAU;YACZ;QACF;QAEAmC,WAAWxB,OAAO,GAAGlB,mBAAAA,QAAAA,mBAAAA,KAAAA,IAAAA,KAAAA,IAAAA,CAAAA,8BAAAA,eAAgBG,WAAW,AAAXA,MAAW,QAA3BH,gCAAAA,KAAAA,IAAAA,KAAAA,IAAAA,4BAA6B4C,WAAW,CAAC;YAC5D,MAAMC,gBAAgB7C,mBAAAA,QAAAA,mBAAAA,KAAAA,IAAAA,KAAAA,IAAAA,eAAgB6C,aAAa;YAEnD,IAAIA,CAAAA,kBAAAA,QAAAA,kBAAAA,KAAAA,IAAAA,KAAAA,IAAAA,cAAeC,OAAO,AAAPA,MAAY,YAAYD,CAAAA,kBAAAA,QAAAA,kBAAAA,KAAAA,IAAAA,KAAAA,IAAAA,cAAeC,OAAO,AAAPA,MAAY,WAAW;gBAC/E,MAAMhB,QAAQ,IAAIiB,YAAYP,iBAAiB;oBAAEQ,SAAS;gBAAK;gBAC/DH,cAAcI,aAAa,CAACnB;YAC9B;QACF,GAAGW;QAEH,OAAO;gBACLzC;YAAAA,mBAAAA,QAAAA,mBAAAA,KAAAA,IAAAA,KAAAA,IAAAA,CAAAA,8BAAAA,eAAgBG,WAAW,AAAXA,MAAW,QAA3BH,gCAAAA,KAAAA,IAAAA,KAAAA,IAAAA,4BAA6BkC,YAAY,CAACQ,WAAWxB,OAAO;QAC9D;IACF,GAAG;QAAClB;QAAgBO;QAAUkC;KAAa;AAC7C"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["useOnScrollOutside.
|
1
|
+
{"version":3,"sources":["useOnScrollOutside.ts"],"sourcesContent":["import * as React from 'react';\nimport { useEventCallback } from './useEventCallback';\nimport type { UseOnClickOrScrollOutsideOptions } from './useOnClickOutside';\n\n/**\n * @internal\n * Utility to perform checks where a click/touch event was made outside a component\n */\nexport const useOnScrollOutside = (options: UseOnClickOrScrollOutsideOptions) => {\n const { refs, callback, element, disabled, contains: containsProp } = 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 element?.addEventListener('wheel', listener);\n element?.addEventListener('touchmove', listener);\n\n return () => {\n element?.removeEventListener('wheel', listener);\n element?.removeEventListener('touchmove', listener);\n };\n }, [listener, element, disabled]);\n};\n"],"names":["useOnScrollOutside","options","refs","callback","element","disabled","contains","containsProp","listener","useEventCallback","ev","parent","child","target","composedPath","isOutside","every","ref","current","React","useEffect","addEventListener","removeEventListener"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAQaA;;;eAAAA;;;;iEARU;kCACU;AAO1B,MAAMA,qBAAqB,CAACC;IACjC,MAAM,EAAEC,IAAI,EAAEC,QAAQ,EAAEC,OAAO,EAAEC,QAAQ,EAAEC,UAAUC,YAAY,EAAE,GAAGN;IAEtE,MAAMO,WAAWC,IAAAA,kCAAAA,EAAiB,CAACC;QACjC,MAAMJ,WACJC,gBAAiB,CAAA,CAACI,QAAQC,QAAU,CAAC,CAACD,CAAAA,WAAAA,QAAAA,WAAAA,KAAAA,IAAAA,KAAAA,IAAAA,OAAQL,QAAQ,CAACM,MAAAA,CAAAA;QAEzD,MAAMC,SAASH,GAAGI,YAAY,EAAE,CAAC,EAAE;QACnC,MAAMC,YAAYb,KAAKc,KAAK,CAACC,CAAAA,MAAO,CAACX,SAASW,IAAIC,OAAO,IAAI,MAAML;QAEnE,IAAIE,aAAa,CAACV,UAAU;YAC1BF,SAASO;QACX;IACF;IAEAS,OAAMC,SAAS,CAAC;QACd,IAAIf,UAAU;YACZ;QACF;QAEAD,YAAAA,QAAAA,YAAAA,KAAAA,IAAAA,KAAAA,IAAAA,QAASiB,gBAAgB,CAAC,SAASb;QACnCJ,YAAAA,QAAAA,YAAAA,KAAAA,IAAAA,KAAAA,IAAAA,QAASiB,gBAAgB,CAAC,aAAab;QAEvC,OAAO;YACLJ,YAAAA,QAAAA,YAAAA,KAAAA,IAAAA,KAAAA,IAAAA,QAASkB,mBAAmB,CAAC,SAASd;YACtCJ,YAAAA,QAAAA,YAAAA,KAAAA,IAAAA,KAAAA,IAAAA,QAASkB,mBAAmB,CAAC,aAAad;QAC5C;IACF,GAAG;QAACA;QAAUJ;QAASC;KAAS;AAClC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["usePrevious.
|
1
|
+
{"version":3,"sources":["usePrevious.ts"],"sourcesContent":["import * as React from 'react';\n\n/**\n * @internal\n */\nexport const usePrevious = <ValueType = unknown>(value: ValueType) => {\n const ref = React.useRef<ValueType | null>(null);\n React.useEffect(() => {\n ref.current = value;\n }, [value]);\n return ref.current;\n};\n"],"names":["usePrevious","value","ref","React","useRef","useEffect","current"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAKaA;;;eAAAA;;;;iEALU;AAKhB,MAAMA,cAAc,CAAsBC;IAC/C,MAAMC,MAAMC,OAAMC,MAAM,CAAmB;IAC3CD,OAAME,SAAS,CAAC;QACdH,IAAII,OAAO,GAAGL;IAChB,GAAG;QAACA;KAAM;IACV,OAAOC,IAAII,OAAO;AACpB"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["useScrollbarWidth.
|
1
|
+
{"version":3,"sources":["useScrollbarWidth.ts"],"sourcesContent":["import * as React from 'react';\n\nconst cache = new WeakMap<Document, number>();\n\ninterface UseScrollbarWidthOptions {\n /**\n * Reference document to measure the scrollbar width\n */\n targetDocument: Document | null | undefined;\n\n /**\n * Does not use the cache and recalculates the scrollbar width\n */\n force?: boolean;\n}\n\n/**\n * @returns The width in pixels of the scrollbar in the user agent\n */\nexport function useScrollbarWidth(options: UseScrollbarWidthOptions) {\n const { targetDocument, force } = options;\n return React.useMemo(() => {\n if (!targetDocument) {\n return 0;\n }\n\n if (!force && cache.has(targetDocument)) {\n return cache.get(targetDocument);\n }\n\n const outer = targetDocument.createElement('div');\n outer.style.visibility = 'hidden';\n outer.style.overflow = 'scroll';\n\n const inner = targetDocument.createElement('div');\n outer.appendChild(inner);\n\n targetDocument.body.appendChild(outer);\n const scrollbarWidth = outer.offsetWidth - inner.offsetWidth;\n outer.remove();\n cache.set(targetDocument, scrollbarWidth);\n return scrollbarWidth;\n }, [targetDocument, force]);\n}\n"],"names":["useScrollbarWidth","cache","WeakMap","options","targetDocument","force","React","useMemo","has","get","outer","createElement","style","visibility","overflow","inner","appendChild","body","scrollbarWidth","offsetWidth","remove","set"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAmBgBA;;;eAAAA;;;;iEAnBO;AAEvB,MAAMC,QAAQ,IAAIC;AAiBX,SAASF,kBAAkBG,OAAiC;IACjE,MAAM,EAAEC,cAAc,EAAEC,KAAK,EAAE,GAAGF;IAClC,OAAOG,OAAMC,OAAO,CAAC;QACnB,IAAI,CAACH,gBAAgB;YACnB,OAAO;QACT;QAEA,IAAI,CAACC,SAASJ,MAAMO,GAAG,CAACJ,iBAAiB;YACvC,OAAOH,MAAMQ,GAAG,CAACL;QACnB;QAEA,MAAMM,QAAQN,eAAeO,aAAa,CAAC;QAC3CD,MAAME,KAAK,CAACC,UAAU,GAAG;QACzBH,MAAME,KAAK,CAACE,QAAQ,GAAG;QAEvB,MAAMC,QAAQX,eAAeO,aAAa,CAAC;QAC3CD,MAAMM,WAAW,CAACD;QAElBX,eAAea,IAAI,CAACD,WAAW,CAACN;QAChC,MAAMQ,iBAAiBR,MAAMS,WAAW,GAAGJ,MAAMI,WAAW;QAC5DT,MAAMU,MAAM;QACZnB,MAAMoB,GAAG,CAACjB,gBAAgBc;QAC1B,OAAOA;IACT,GAAG;QAACd;QAAgBC;KAAM;AAC5B"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["useTimeout.
|
1
|
+
{"version":3,"sources":["useTimeout.ts"],"sourcesContent":["import { useBrowserTimer } from './useBrowserTimer';\nimport { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';\n\nconst setTimeoutNoop = (_callback: Function) => -1;\nconst clearTimeoutNoop = (_handle: number) => undefined;\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 const { targetDocument } = useFluent();\n const win = targetDocument?.defaultView;\n\n const setTimerFn = win ? win.setTimeout : setTimeoutNoop;\n const clearTimerFn = win ? win.clearTimeout : clearTimeoutNoop;\n\n return useBrowserTimer(setTimerFn, clearTimerFn);\n}\n"],"names":["useTimeout","setTimeoutNoop","_callback","clearTimeoutNoop","_handle","undefined","targetDocument","useFluent","win","defaultView","setTimerFn","setTimeout","clearTimerFn","clearTimeout","useBrowserTimer"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAcgBA;;;eAAAA;;;iCAdgB;qCACgB;AAEhD,MAAMC,iBAAiB,CAACC,YAAwB,CAAC;AACjD,MAAMC,mBAAmB,CAACC,UAAoBC;AAUvC,SAASL;IACd,MAAM,EAAEM,cAAc,EAAE,GAAGC,IAAAA,uCAAAA;IAC3B,MAAMC,MAAMF,mBAAAA,QAAAA,mBAAAA,KAAAA,IAAAA,KAAAA,IAAAA,eAAgBG,WAAW;IAEvC,MAAMC,aAAaF,MAAMA,IAAIG,UAAU,GAAGV;IAC1C,MAAMW,eAAeJ,MAAMA,IAAIK,YAAY,GAAGV;IAE9C,OAAOW,IAAAA,gCAAAA,EAAgBJ,YAAYE;AACrC"}
|
package/lib-commonjs/index.js
CHANGED
@@ -9,11 +9,53 @@ function _export(target, all) {
|
|
9
9
|
});
|
10
10
|
}
|
11
11
|
_export(exports, {
|
12
|
-
|
13
|
-
return
|
12
|
+
IdPrefixProvider: function() {
|
13
|
+
return _index1.IdPrefixProvider;
|
14
14
|
},
|
15
|
-
|
16
|
-
return _index.
|
15
|
+
SLOT_ELEMENT_TYPE_SYMBOL: function() {
|
16
|
+
return _index.SLOT_ELEMENT_TYPE_SYMBOL;
|
17
|
+
},
|
18
|
+
SLOT_RENDER_FUNCTION_SYMBOL: function() {
|
19
|
+
return _index.SLOT_RENDER_FUNCTION_SYMBOL;
|
20
|
+
},
|
21
|
+
SSRProvider: function() {
|
22
|
+
return _index2.SSRProvider;
|
23
|
+
},
|
24
|
+
applyTriggerPropsToChildren: function() {
|
25
|
+
return _index4.applyTriggerPropsToChildren;
|
26
|
+
},
|
27
|
+
assertSlots: function() {
|
28
|
+
return _index.assertSlots;
|
29
|
+
},
|
30
|
+
canUseDOM: function() {
|
31
|
+
return _index2.canUseDOM;
|
32
|
+
},
|
33
|
+
clamp: function() {
|
34
|
+
return _index3.clamp;
|
35
|
+
},
|
36
|
+
createPriorityQueue: function() {
|
37
|
+
return _index3.createPriorityQueue;
|
38
|
+
},
|
39
|
+
elementContains: function() {
|
40
|
+
return _index7.elementContains;
|
41
|
+
},
|
42
|
+
getEventClientCoords: function() {
|
43
|
+
return _index5.getEventClientCoords;
|
44
|
+
},
|
45
|
+
getIntrinsicElementProps: function() {
|
46
|
+
return _index.getIntrinsicElementProps;
|
47
|
+
},
|
48
|
+
getNativeElementProps: function() {
|
49
|
+
return _index3.getNativeElementProps;
|
50
|
+
},
|
51
|
+
getParent: function() {
|
52
|
+
return _index7.getParent;
|
53
|
+
},
|
54
|
+
getPartitionedNativeProps: function() {
|
55
|
+
return _index3.getPartitionedNativeProps;
|
56
|
+
},
|
57
|
+
getRTLSafeKey: function() {
|
58
|
+
return _index3.getRTLSafeKey;
|
17
59
|
},
|
18
60
|
getSlots: function() {
|
19
61
|
return _index.getSlots;
|
@@ -21,30 +63,48 @@ _export(exports, {
|
|
21
63
|
getSlotsNext: function() {
|
22
64
|
return _index.getSlotsNext;
|
23
65
|
},
|
24
|
-
|
25
|
-
return
|
66
|
+
getTriggerChild: function() {
|
67
|
+
return _index4.getTriggerChild;
|
26
68
|
},
|
27
|
-
|
28
|
-
return
|
69
|
+
isFluentTrigger: function() {
|
70
|
+
return _index4.isFluentTrigger;
|
71
|
+
},
|
72
|
+
isHTMLElement: function() {
|
73
|
+
return _index3.isHTMLElement;
|
74
|
+
},
|
75
|
+
isInteractiveHTMLElement: function() {
|
76
|
+
return _index3.isInteractiveHTMLElement;
|
77
|
+
},
|
78
|
+
isMouseEvent: function() {
|
79
|
+
return _index5.isMouseEvent;
|
29
80
|
},
|
30
81
|
isResolvedShorthand: function() {
|
31
82
|
return _index.isResolvedShorthand;
|
32
83
|
},
|
33
|
-
|
34
|
-
return _index.
|
84
|
+
isSlot: function() {
|
85
|
+
return _index.isSlot;
|
35
86
|
},
|
36
|
-
|
37
|
-
return
|
87
|
+
isTouchEvent: function() {
|
88
|
+
return _index5.isTouchEvent;
|
38
89
|
},
|
39
|
-
|
40
|
-
return
|
90
|
+
mergeCallbacks: function() {
|
91
|
+
return _index3.mergeCallbacks;
|
41
92
|
},
|
42
|
-
|
43
|
-
return
|
93
|
+
omit: function() {
|
94
|
+
return _index3.omit;
|
44
95
|
},
|
45
96
|
resetIdsForTests: function() {
|
46
97
|
return _index1.resetIdsForTests;
|
47
98
|
},
|
99
|
+
resolveShorthand: function() {
|
100
|
+
return _index.resolveShorthand;
|
101
|
+
},
|
102
|
+
setVirtualParent: function() {
|
103
|
+
return _index7.setVirtualParent;
|
104
|
+
},
|
105
|
+
slot: function() {
|
106
|
+
return _index.slot;
|
107
|
+
},
|
48
108
|
useAnimationFrame: function() {
|
49
109
|
return _index1.useAnimationFrame;
|
50
110
|
},
|
@@ -63,6 +123,9 @@ _export(exports, {
|
|
63
123
|
useId: function() {
|
64
124
|
return _index1.useId;
|
65
125
|
},
|
126
|
+
useIsSSR: function() {
|
127
|
+
return _index2.useIsSSR;
|
128
|
+
},
|
66
129
|
useIsomorphicLayoutEffect: function() {
|
67
130
|
return _index1.useIsomorphicLayoutEffect;
|
68
131
|
},
|
@@ -81,74 +144,11 @@ _export(exports, {
|
|
81
144
|
useScrollbarWidth: function() {
|
82
145
|
return _index1.useScrollbarWidth;
|
83
146
|
},
|
84
|
-
useTimeout: function() {
|
85
|
-
return _index1.useTimeout;
|
86
|
-
},
|
87
|
-
canUseDOM: function() {
|
88
|
-
return _index2.canUseDOM;
|
89
|
-
},
|
90
|
-
useIsSSR: function() {
|
91
|
-
return _index2.useIsSSR;
|
92
|
-
},
|
93
|
-
SSRProvider: function() {
|
94
|
-
return _index2.SSRProvider;
|
95
|
-
},
|
96
|
-
clamp: function() {
|
97
|
-
return _index3.clamp;
|
98
|
-
},
|
99
|
-
getNativeElementProps: function() {
|
100
|
-
return _index3.getNativeElementProps;
|
101
|
-
},
|
102
|
-
getPartitionedNativeProps: function() {
|
103
|
-
return _index3.getPartitionedNativeProps;
|
104
|
-
},
|
105
|
-
getRTLSafeKey: function() {
|
106
|
-
return _index3.getRTLSafeKey;
|
107
|
-
},
|
108
|
-
mergeCallbacks: function() {
|
109
|
-
return _index3.mergeCallbacks;
|
110
|
-
},
|
111
|
-
isHTMLElement: function() {
|
112
|
-
return _index3.isHTMLElement;
|
113
|
-
},
|
114
|
-
isInteractiveHTMLElement: function() {
|
115
|
-
return _index3.isInteractiveHTMLElement;
|
116
|
-
},
|
117
|
-
omit: function() {
|
118
|
-
return _index3.omit;
|
119
|
-
},
|
120
|
-
createPriorityQueue: function() {
|
121
|
-
return _index3.createPriorityQueue;
|
122
|
-
},
|
123
|
-
applyTriggerPropsToChildren: function() {
|
124
|
-
return _index4.applyTriggerPropsToChildren;
|
125
|
-
},
|
126
|
-
getTriggerChild: function() {
|
127
|
-
return _index4.getTriggerChild;
|
128
|
-
},
|
129
|
-
isFluentTrigger: function() {
|
130
|
-
return _index4.isFluentTrigger;
|
131
|
-
},
|
132
|
-
isTouchEvent: function() {
|
133
|
-
return _index5.isTouchEvent;
|
134
|
-
},
|
135
|
-
isMouseEvent: function() {
|
136
|
-
return _index5.isMouseEvent;
|
137
|
-
},
|
138
|
-
getEventClientCoords: function() {
|
139
|
-
return _index5.getEventClientCoords;
|
140
|
-
},
|
141
147
|
useSelection: function() {
|
142
148
|
return _index6.useSelection;
|
143
149
|
},
|
144
|
-
|
145
|
-
return
|
146
|
-
},
|
147
|
-
setVirtualParent: function() {
|
148
|
-
return _index7.setVirtualParent;
|
149
|
-
},
|
150
|
-
getParent: function() {
|
151
|
-
return _index7.getParent;
|
150
|
+
useTimeout: function() {
|
151
|
+
return _index1.useTimeout;
|
152
152
|
}
|
153
153
|
});
|
154
154
|
const _index = require("./compose/index");
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["index.
|
1
|
+
{"version":3,"sources":["index.ts"],"sourcesContent":["export {\n slot,\n isSlot,\n // eslint-disable-next-line deprecation/deprecation\n getSlots,\n // eslint-disable-next-line deprecation/deprecation\n getSlotsNext,\n assertSlots,\n // eslint-disable-next-line deprecation/deprecation\n resolveShorthand,\n isResolvedShorthand,\n getIntrinsicElementProps,\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 // eslint-disable-next-line deprecation/deprecation\n ResolveShorthandFunction,\n // eslint-disable-next-line deprecation/deprecation\n ResolveShorthandOptions,\n Slot,\n // eslint-disable-next-line deprecation/deprecation\n Slots,\n SlotClassNames,\n SlotPropsRecord,\n SlotRenderFunction,\n SlotShorthandValue,\n UnknownSlotProps,\n SlotComponentType,\n SlotOptions,\n InferredElementRefType,\n EventData,\n EventHandler,\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 // eslint-disable-next-line deprecation/deprecation\n getNativeElementProps,\n getPartitionedNativeProps,\n getRTLSafeKey,\n mergeCallbacks,\n isHTMLElement,\n isInteractiveHTMLElement,\n omit,\n createPriorityQueue,\n} from './utils/index';\n\nexport type { DistributiveOmit, UnionToIntersection } from './utils/types';\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\nexport { elementContains, setVirtualParent, getParent } from './virtualParent/index';\n"],"names":["IdPrefixProvider","SLOT_ELEMENT_TYPE_SYMBOL","SLOT_RENDER_FUNCTION_SYMBOL","SSRProvider","applyTriggerPropsToChildren","assertSlots","canUseDOM","clamp","createPriorityQueue","elementContains","getEventClientCoords","getIntrinsicElementProps","getNativeElementProps","getParent","getPartitionedNativeProps","getRTLSafeKey","getSlots","getSlotsNext","getTriggerChild","isFluentTrigger","isHTMLElement","isInteractiveHTMLElement","isMouseEvent","isResolvedShorthand","isSlot","isTouchEvent","mergeCallbacks","omit","resetIdsForTests","resolveShorthand","setVirtualParent","slot","useAnimationFrame","useControllableState","useEventCallback","useFirstMount","useForceUpdate","useId","useIsSSR","useIsomorphicLayoutEffect","useMergedRefs","useOnClickOutside","useOnScrollOutside","usePrevious","useScrollbarWidth","useSelection","useTimeout"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;;;;;;;;IAwCEA,gBAAgB;eAAhBA,wBAAgB;;IA5BhBC,wBAAwB;eAAxBA,+BAAwB;;IACxBC,2BAA2B;eAA3BA,kCAA2B;;IA6CCC,WAAW;eAAXA,mBAAW;;IAmBhCC,2BAA2B;eAA3BA,mCAA2B;;IAtElCC,WAAW;eAAXA,kBAAW;;IAmDJC,SAAS;eAATA,iBAAS;;IAGhBC,KAAK;eAALA,aAAK;;IASLC,mBAAmB;eAAnBA,2BAAmB;;IA2BZC,eAAe;eAAfA,uBAAe;;IAZaC,oBAAoB;eAApBA,4BAAoB;;IA1EvDC,wBAAwB;eAAxBA,+BAAwB;;IAoDxBC,qBAAqB;eAArBA,6BAAqB;;IAkCqBC,SAAS;eAATA,iBAAS;;IAjCnDC,yBAAyB;eAAzBA,iCAAyB;;IACzBC,aAAa;eAAbA,qBAAa;;IA7DbC,QAAQ;eAARA,eAAQ;;IAERC,YAAY;eAAZA,mBAAY;;IAuEwBC,eAAe;eAAfA,uBAAe;;IAAEC,eAAe;eAAfA,uBAAe;;IAVpEC,aAAa;eAAbA,qBAAa;;IACbC,wBAAwB;eAAxBA,gCAAwB;;IAiBHC,YAAY;eAAZA,oBAAY;;IA3EjCC,mBAAmB;eAAnBA,0BAAmB;;IARnBC,MAAM;eAANA,aAAM;;IAmFCC,YAAY;eAAZA,oBAAY;;IAnBnBC,cAAc;eAAdA,sBAAc;;IAGdC,IAAI;eAAJA,YAAI;;IA5BJC,gBAAgB;eAAhBA,wBAAgB;;IAhChBC,gBAAgB;eAAhBA,uBAAgB;;IAwFQC,gBAAgB;eAAhBA,wBAAgB;;IAhGxCC,IAAI;eAAJA,WAAI;;IAyCJC,iBAAiB;eAAjBA,yBAAiB;;IACjBC,oBAAoB;eAApBA,4BAAoB;;IACpBC,gBAAgB;eAAhBA,wBAAgB;;IAChBC,aAAa;eAAbA,qBAAa;;IACbC,cAAc;eAAdA,sBAAc;;IACdC,KAAK;eAALA,aAAK;;IAWaC,QAAQ;eAARA,gBAAQ;;IAV1BC,yBAAyB;eAAzBA,iCAAyB;;IACzBC,aAAa;eAAbA,qBAAa;;IACbC,iBAAiB;eAAjBA,yBAAiB;;IACjBC,kBAAkB;eAAlBA,0BAAkB;;IAClBC,WAAW;eAAXA,mBAAW;;IACXC,iBAAiB;eAAjBA,yBAAiB;;IA0CVC,YAAY;eAAZA,oBAAY;;IAzCnBC,UAAU;eAAVA,kBAAU;;;uBAxCL;wBAyCA;wBAG0C;wBAa1C;wBAMuE;wBAQb;wBAUpC;wBAEgC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["index.
|
1
|
+
{"version":3,"sources":["index.ts"],"sourcesContent":["export * from './types';\nexport * from './useSelection';\n"],"names":[],"rangeMappings":";;;;;;","mappings":";;;;;uBAAc;uBACA"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["types.
|
1
|
+
{"version":3,"sources":["types.ts"],"sourcesContent":["import * as React from 'react';\n\nexport type SelectionMode = 'single' | 'multiselect';\n\nexport interface SelectionMethods {\n toggleItem(event: React.SyntheticEvent, id: SelectionItemId): void;\n selectItem(event: React.SyntheticEvent, id: SelectionItemId): void;\n deselectItem(event: React.SyntheticEvent, id: SelectionItemId): void;\n clearItems(event: React.SyntheticEvent): void;\n isSelected(id: SelectionItemId): boolean;\n toggleAllItems(event: React.SyntheticEvent, itemIds: SelectionItemId[]): void;\n}\n\nexport type SelectionItemId = string | number;\n\nexport type OnSelectionChangeCallback = (event: React.SyntheticEvent, selectedItems: Set<SelectionItemId>) => void;\n\nexport type OnSelectionChangeData = {\n selectedItems: Set<SelectionItemId>;\n};\n\nexport type SelectionHookParams = {\n selectionMode: SelectionMode;\n /**\n * Used in uncontrolled mode to set initial selected items on mount\n */\n defaultSelectedItems?: Iterable<SelectionItemId>;\n /**\n * Used to control selected items\n */\n selectedItems?: Iterable<SelectionItemId>;\n /**\n * Called when selection changes\n */\n onSelectionChange?(event: React.SyntheticEvent, data: OnSelectionChangeData): void;\n};\n"],"names":[],"rangeMappings":";;;;;","mappings":";;;;;iEAAuB"}
|
@@ -103,6 +103,7 @@ function useMultipleSelection(params) {
|
|
103
103
|
];
|
104
104
|
}
|
105
105
|
function useSelection(params) {
|
106
|
+
'use no memo';
|
106
107
|
if (params.selectionMode === 'multiselect') {
|
107
108
|
// selectionMode is a static value, so we can safely ignore rules-of-hooks
|
108
109
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["useSelection.
|
1
|
+
{"version":3,"sources":["useSelection.ts"],"sourcesContent":["import * as React from 'react';\nimport { SelectionHookParams, SelectionItemId, SelectionMethods } from './types';\nimport { useControllableState } from '../hooks/useControllableState';\nimport { createSetFromIterable } from '../utils/createSetFromIterable';\n\nfunction useSelectionState(params: Omit<SelectionHookParams, 'selectionMode'>) {\n const [selected, setSelected] = useControllableState<Set<SelectionItemId>>({\n initialState: new Set(),\n defaultState: React.useMemo(\n () => params.defaultSelectedItems && createSetFromIterable(params.defaultSelectedItems),\n [params.defaultSelectedItems],\n ),\n state: React.useMemo(\n () => params.selectedItems && createSetFromIterable(params.selectedItems),\n [params.selectedItems],\n ),\n });\n const changeSelection = (event: React.SyntheticEvent, nextSelectedItems: Set<SelectionItemId>) => {\n params.onSelectionChange?.(event, { selectedItems: nextSelectedItems });\n setSelected(nextSelectedItems);\n };\n return [selected, changeSelection] as const;\n}\n\nfunction useSingleSelection(params: Omit<SelectionHookParams, 'selectionMode'>) {\n const [selected, changeSelection] = useSelectionState(params);\n const methods: SelectionMethods = {\n deselectItem: event => changeSelection(event, new Set()),\n selectItem: (event, itemId) => changeSelection(event, new Set([itemId])),\n toggleAllItems: () => {\n if (process.env.NODE_ENV !== 'production') {\n throw new Error('[react-utilities]: `toggleAllItems` should not be used in single selection mode');\n }\n },\n toggleItem: (event, itemId) => changeSelection(event, new Set([itemId])),\n clearItems: event => changeSelection(event, new Set()),\n isSelected: itemId => selected.has(itemId) ?? false,\n };\n return [selected, methods] as const;\n}\n\nfunction useMultipleSelection(params: Omit<SelectionHookParams, 'selectionMode'>) {\n const [selected, changeSelection] = useSelectionState(params);\n const methods: SelectionMethods = {\n toggleItem: (event, itemId) => {\n const nextSelectedItems = new Set(selected);\n if (selected.has(itemId)) {\n nextSelectedItems.delete(itemId);\n } else {\n nextSelectedItems.add(itemId);\n }\n changeSelection(event, nextSelectedItems);\n },\n selectItem: (event, itemId) => {\n const nextSelectedItems = new Set(selected);\n nextSelectedItems.add(itemId);\n changeSelection(event, nextSelectedItems);\n },\n deselectItem: (event, itemId) => {\n const nextSelectedItems = new Set(selected);\n nextSelectedItems.delete(itemId);\n changeSelection(event, nextSelectedItems);\n },\n clearItems: event => {\n changeSelection(event, new Set());\n },\n isSelected: itemId => selected.has(itemId),\n toggleAllItems: (event, itemIds) => {\n const allItemsSelected = itemIds.every(itemId => selected.has(itemId));\n const nextSelectedItems = new Set(selected);\n if (allItemsSelected) {\n nextSelectedItems.clear();\n } else {\n itemIds.forEach(itemId => nextSelectedItems.add(itemId));\n }\n changeSelection(event, nextSelectedItems);\n },\n };\n return [selected, methods] as const;\n}\n\nexport function useSelection(params: SelectionHookParams) {\n 'use no memo';\n\n if (params.selectionMode === 'multiselect') {\n // selectionMode is a static value, so we can safely ignore rules-of-hooks\n // eslint-disable-next-line react-hooks/rules-of-hooks\n return useMultipleSelection(params);\n }\n // selectionMode is a static value, so we can safely ignore rules-of-hooks\n // eslint-disable-next-line react-hooks/rules-of-hooks\n return useSingleSelection(params);\n}\n"],"names":["useSelection","useSelectionState","params","selected","setSelected","useControllableState","initialState","Set","defaultState","React","useMemo","defaultSelectedItems","createSetFromIterable","state","selectedItems","changeSelection","event","nextSelectedItems","onSelectionChange","useSingleSelection","methods","deselectItem","selectItem","itemId","toggleAllItems","process","env","NODE_ENV","Error","toggleItem","clearItems","isSelected","has","useMultipleSelection","delete","add","itemIds","allItemsSelected","every","clear","forEach","selectionMode"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAiFgBA;;;eAAAA;;;;iEAjFO;sCAEc;uCACC;AAEtC,SAASC,kBAAkBC,MAAkD;IAC3E,MAAM,CAACC,UAAUC,YAAY,GAAGC,IAAAA,0CAAAA,EAA2C;QACzEC,cAAc,IAAIC;QAClBC,cAAcC,OAAMC,OAAO,CACzB,IAAMR,OAAOS,oBAAoB,IAAIC,IAAAA,4CAAAA,EAAsBV,OAAOS,oBAAoB,GACtF;YAACT,OAAOS,oBAAoB;SAAC;QAE/BE,OAAOJ,OAAMC,OAAO,CAClB,IAAMR,OAAOY,aAAa,IAAIF,IAAAA,4CAAAA,EAAsBV,OAAOY,aAAa,GACxE;YAACZ,OAAOY,aAAa;SAAC;IAE1B;IACA,MAAMC,kBAAkB,CAACC,OAA6BC;YACpDf;QAAAA,CAAAA,4BAAAA,OAAOgB,iBAAiB,AAAjBA,MAAiB,QAAxBhB,8BAAAA,KAAAA,IAAAA,KAAAA,IAAAA,0BAAAA,IAAAA,CAAAA,QAA2Bc,OAAO;YAAEF,eAAeG;QAAkB;QACrEb,YAAYa;IACd;IACA,OAAO;QAACd;QAAUY;KAAgB;AACpC;AAEA,SAASI,mBAAmBjB,MAAkD;IAC5E,MAAM,CAACC,UAAUY,gBAAgB,GAAG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,GAAG,CAACT;QACnCC,gBAAgB,CAACR,OAAOoB;YACtB,MAAMC,mBAAmBD,QAAQE,KAAK,CAACf,CAAAA,SAAUpB,SAAS6B,GAAG,CAACT;YAC9D,MAAMN,oBAAoB,IAAIV,IAAIJ;YAClC,IAAIkC,kBAAkB;gBACpBpB,kBAAkBsB,KAAK;YACzB,OAAO;gBACLH,QAAQI,OAAO,CAACjB,CAAAA,SAAUN,kBAAkBkB,GAAG,CAACZ;YAClD;YACAR,gBAAgBC,OAAOC;QACzB;IACF;IACA,OAAO;QAACd;QAAUiB;KAAQ;AAC5B;AAEO,SAASpB,aAAaE,MAA2B;IACtD;IAEA,IAAIA,OAAOuC,aAAa,KAAK,eAAe;QAC1C,0EAA0E;QAC1E,sDAAsD;QACtD,OAAOR,qBAAqB/B;IAC9B;IACA,0EAA0E;IAC1E,sDAAsD;IACtD,OAAOiB,mBAAmBjB;AAC5B"}
|
@@ -9,20 +9,20 @@ function _export(target, all) {
|
|
9
9
|
});
|
10
10
|
}
|
11
11
|
_export(exports, {
|
12
|
-
defaultSSRContextValue: function() {
|
13
|
-
return defaultSSRContextValue;
|
14
|
-
},
|
15
12
|
SSRContext: function() {
|
16
13
|
return SSRContext;
|
17
14
|
},
|
18
|
-
useSSRContext: function() {
|
19
|
-
return useSSRContext;
|
20
|
-
},
|
21
15
|
SSRProvider: function() {
|
22
16
|
return SSRProvider;
|
23
17
|
},
|
18
|
+
defaultSSRContextValue: function() {
|
19
|
+
return defaultSSRContextValue;
|
20
|
+
},
|
24
21
|
useIsSSR: function() {
|
25
22
|
return useIsSSR;
|
23
|
+
},
|
24
|
+
useSSRContext: function() {
|
25
|
+
return useSSRContext;
|
26
26
|
}
|
27
27
|
});
|
28
28
|
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["SSRContext.
|
1
|
+
{"version":3,"sources":["SSRContext.tsx"],"sourcesContent":["import * as React from 'react';\nimport { canUseDOM } from './canUseDOM';\n\n/**\n * To support SSR, the auto incrementing id counter is stored in a context. This allows it to be reset on every request\n * to ensure the client and server are consistent.\n *\n * @internal\n */\nexport type SSRContextValue = {\n current: number;\n};\n\n/**\n * Default context value to use in case there is no SSRProvider. This is fine for client-only apps.\n *\n * @internal\n */\nexport const defaultSSRContextValue: SSRContextValue = {\n current: 0,\n};\n\nexport const SSRContext = React.createContext<SSRContextValue | undefined>(undefined) as React.Context<SSRContextValue>;\n\n/**\n * @internal\n */\nexport function useSSRContext(): SSRContextValue {\n return React.useContext(SSRContext) ?? defaultSSRContextValue;\n}\n\n/**\n * When using SSR with Fluent UI, applications must be wrapped in an SSRProvider. This ensures that auto generated ids\n * are consistent between the client and server.\n *\n * @public\n */\nexport const SSRProvider: React.FC<{ children: React.ReactNode }> = props => {\n const [value] = React.useState<SSRContextValue>(() => ({ current: 0 }));\n\n return <SSRContext.Provider value={value}>{props.children}</SSRContext.Provider>;\n};\n\n/**\n * Returns whether the component is currently being server side rendered or hydrated on the client. Can be used to delay\n * browser-specific rendering until after hydration. May cause re-renders on a client when is used within SSRProvider.\n */\nexport function useIsSSR(): boolean {\n const isInSSRContext = useSSRContext() !== defaultSSRContextValue;\n const [isSSR, setIsSSR] = React.useState(isInSSRContext);\n\n // If we are rendering in a non-DOM environment, and there's no SSRProvider, provide a warning to hint to the\n // developer to add one.\n if (process.env.NODE_ENV !== 'production') {\n if (!isInSSRContext && !canUseDOM()) {\n // eslint-disable-next-line no-console\n console.error(/** #__DE-INDENT__ */ `\n @fluentui/react-components [${useIsSSR.name}]:\n When server rendering, you must wrap your application in an <SSRProvider> to ensure consistent ids are generated between the client and server.\n\n\n Check documentation at https://aka.ms/fluentui-ssr.\n `);\n }\n }\n\n // If on the client, and the component was initially server rendered, then schedule a layout effect to update the\n // component after hydration.\n if (canUseDOM() && isInSSRContext) {\n // This if statement technically breaks the rules of hooks, but is safe because the condition never changes after\n // mounting.\n // eslint-disable-next-line\n React.useLayoutEffect(() => {\n setIsSSR(false);\n }, []);\n }\n\n return isSSR;\n}\n"],"names":["SSRContext","SSRProvider","defaultSSRContextValue","useIsSSR","useSSRContext","current","React","createContext","undefined","useContext","props","value","useState","createElement","Provider","children","isInSSRContext","isSSR","setIsSSR","process","env","NODE_ENV","canUseDOM","console","error","name","useLayoutEffect"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;;;;;;;;IAsBaA,UAAAA;eAAAA;;IAeAC,WAAAA;eAAAA;;IAnBAC,sBAAAA;eAAAA;;IA6BGC,QAAAA;eAAAA;;IApBAC,aAAAA;eAAAA;;;;iEA3BO;2BACG;AAiBnB,MAAMF,yBAA0C;IACrDG,SAAS;AACX;AAEO,MAAML,aAAAA,WAAAA,GAAaM,OAAMC,aAAa,CAA8BC;AAKpE,SAASJ;QACPE;IAAP,OAAOA,CAAAA,oBAAAA,OAAMG,UAAU,CAACT,WAAAA,MAAAA,QAAjBM,sBAAAA,KAAAA,IAAAA,oBAAgCJ;AACzC;AAQO,MAAMD,cAAuDS,CAAAA;IAClE,MAAM,CAACC,MAAM,GAAGL,OAAMM,QAAQ,CAAkB,IAAO,CAAA;YAAEP,SAAS;QAAE,CAAA;IAEpE,OAAA,WAAA,GAAOC,OAAAO,aAAA,CAACb,WAAWc,QAAQ,EAAA;QAACH,OAAOA;OAAQD,MAAMK,QAAQ;AAC3D;AAMO,SAASZ;IACd,MAAMa,iBAAiBZ,oBAAoBF;IAC3C,MAAM,CAACe,OAAOC,SAAS,GAAGZ,OAAMM,QAAQ,CAACI;IAEzC,6GAA6G;IAC7G,wBAAwB;IACxB,IAAIG,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;QACzC,IAAI,CAACL,kBAAkB,CAACM,IAAAA,oBAAAA,KAAa;YACnC,sCAAsC;YACtCC,QAAQC,KAAK,CAAuB,CAAC,4BACP,EAAErB,SAASsB,IAAI,CAAC;;;;mDAK9C,CAAC;QACH;IACF;IAEA,iHAAiH;IACjH,6BAA6B;IAC7B,IAAIH,IAAAA,oBAAAA,OAAeN,gBAAgB;QACjC,iHAAiH;QACjH,YAAY;QACZ,2BAA2B;QAC3BV,OAAMoB,eAAe,CAAC;YACpBR,SAAS;QACX,GAAG,EAAE;IACP;IAEA,OAAOD;AACT"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["canUseDOM.
|
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"],"rangeMappings":";;;;;;;;;;;;;;","mappings":"AAAA;;CAEC;;;;+BACeA;;;eAAAA;;;AAAT,SAASA;IACd,OAEE,OAAOC,WAAW,eAAe,CAAC,CAAEA,CAAAA,OAAOC,QAAQ,IAAID,OAAOC,QAAQ,CAACC,aAAa,AAAbA;AAE3E"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["index.
|
1
|
+
{"version":3,"sources":["index.ts"],"sourcesContent":["export * from './canUseDOM';\nexport * from './SSRContext';\n"],"names":[],"rangeMappings":";;;;;;","mappings":";;;;;uBAAc;uBACA"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["applyTriggerPropsToChildren.
|
1
|
+
{"version":3,"sources":["applyTriggerPropsToChildren.ts"],"sourcesContent":["import * as React from 'react';\nimport { isFluentTrigger } from './isFluentTrigger';\nimport type { TriggerProps } from './types';\n\n/**\n * @internal\n * resolve the trigger props to the children, either by calling the render function, or cloning with the new props.\n */\nexport function applyTriggerPropsToChildren<TriggerChildProps>(\n children: TriggerProps<TriggerChildProps>['children'],\n triggerChildProps: TriggerChildProps,\n): React.ReactElement | null {\n if (typeof children === 'function') {\n return children(triggerChildProps);\n } else if (children) {\n return cloneTriggerTree(children, triggerChildProps);\n }\n\n // Components in React should return either JSX elements or \"null\", otherwise React will throw:\n // Nothing was returned from render.\n // This usually means a return statement is missing. Or, to render nothing, return null.\n return children || null;\n}\n\n/**\n * Clones a React element tree, and applies the given props to the first grandchild that is not\n * a FluentTriggerComponent or React Fragment (the same element returned by {@link getTriggerChild}).\n */\nfunction cloneTriggerTree<TriggerChildProps>(\n child: React.ReactNode,\n triggerProps: TriggerChildProps,\n): React.ReactElement {\n if (!React.isValidElement(child) || child.type === React.Fragment) {\n throw new Error(\n 'A trigger element must be a single element for this component. ' +\n \"Please ensure that you're not using React Fragments.\",\n );\n }\n\n if (isFluentTrigger(child)) {\n const grandchild = cloneTriggerTree(child.props.children, triggerProps);\n return React.cloneElement(child, undefined, grandchild);\n } else {\n return React.cloneElement(child, triggerProps as TriggerChildProps & React.Attributes);\n }\n}\n"],"names":["applyTriggerPropsToChildren","children","triggerChildProps","cloneTriggerTree","child","triggerProps","React","isValidElement","type","Fragment","Error","isFluentTrigger","grandchild","props","cloneElement","undefined"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";;;;+BAQgBA;;;eAAAA;;;;iEARO;iCACS;AAOzB,SAASA,4BACdC,QAAqD,EACrDC,iBAAoC;IAEpC,IAAI,OAAOD,aAAa,YAAY;QAClC,OAAOA,SAASC;IAClB,OAAO,IAAID,UAAU;QACnB,OAAOE,iBAAiBF,UAAUC;IACpC;IAEA,+FAA+F;IAC/F,sCAAsC;IACtC,0FAA0F;IAC1F,OAAOD,YAAY;AACrB;AAEA;;;CAGC,GACD,SAASE,iBACPC,KAAsB,EACtBC,YAA+B;IAE/B,IAAI,eAACC,OAAMC,cAAc,CAACH,UAAUA,MAAMI,IAAI,KAAKF,OAAMG,QAAQ,EAAE;QACjE,MAAM,IAAIC,MACR,oEACE;IAEN;IAEA,IAAIC,IAAAA,gCAAAA,EAAgBP,QAAQ;QAC1B,MAAMQ,aAAaT,iBAAiBC,MAAMS,KAAK,CAACZ,QAAQ,EAAEI;QAC1D,qBAAOC,OAAMQ,YAAY,CAACV,OAAOW,WAAWH;IAC9C,OAAO;QACL,qBAAON,OAAMQ,YAAY,CAACV,OAAOC;IACnC;AACF"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["getTriggerChild.
|
1
|
+
{"version":3,"sources":["getTriggerChild.ts"],"sourcesContent":["import * as React from 'react';\nimport { isFluentTrigger } from './isFluentTrigger';\nimport type { TriggerProps } from './types';\n\n/**\n * @internal\n * Gets the trigger element of a FluentTriggerComponent (such as Tooltip or MenuTrigger).\n *\n * In the case where the immediate child is itself a FluentTriggerComponent and/or React Fragment,\n * it returns the first descendant that is _not_ a FluentTriggerComponent or Fragment.\n * This allows multiple triggers to be stacked, and still apply their props to the actual trigger element.\n *\n * For example, the following returns `<div id=\"child\" />`:\n * ```jsx\n * getTriggerChild(\n * <Tooltip>\n * <MenuTrigger>\n * <div id=\"child\" />\n * </MenuTrigger>\n * </Tooltip>\n * );\n * ```\n *\n * In the case where the immediate child is not a valid element,\n * null is returned\n */\nexport function getTriggerChild<TriggerChildProps>(\n children: TriggerProps<TriggerChildProps>['children'],\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n): (React.ReactElement<Partial<TriggerChildProps>> & { ref?: React.Ref<any> }) | null {\n if (!React.isValidElement<TriggerChildProps>(children)) {\n return null;\n }\n return isFluentTrigger(children)\n ? getTriggerChild(\n // FIXME: This casting should be unnecessary as isFluentTrigger is a guard type method,\n // but for some reason it's failing on build\n (children.props as TriggerProps).children,\n )\n : children;\n}\n"],"names":["getTriggerChild","children","React","isValidElement","isFluentTrigger","props"],"rangeMappings":";;;;;;;;;;;;;;;;;;;","mappings":";;;;+BA0BgBA;;;eAAAA;;;;iEA1BO;iCACS;AAyBzB,SAASA,gBACdC,QAAqD;IAGrD,IAAI,eAACC,OAAMC,cAAc,CAAoBF,WAAW;QACtD,OAAO;IACT;IACA,OAAOG,IAAAA,gCAAAA,EAAgBH,YACnBD,gBAEE,4CAA4C;IAC3CC,SAASI,KAAK,CAAkBJ,QAAQ,IAE3CA;AACN"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["index.
|
1
|
+
{"version":3,"sources":["index.ts"],"sourcesContent":["export * from './applyTriggerPropsToChildren';\nexport * from './getTriggerChild';\nexport * from './isFluentTrigger';\nexport * from './types';\n"],"names":[],"rangeMappings":";;;;;;;;","mappings":";;;;;uBAAc;uBACA;uBACA;uBACA"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["isFluentTrigger.
|
1
|
+
{"version":3,"sources":["isFluentTrigger.ts"],"sourcesContent":["import * as React from 'react';\nimport type { FluentTriggerComponent, TriggerProps } from './types';\n\n/**\n * @internal\n * Checks if a given element is a FluentUI trigger (e.g. `MenuTrigger` or `Tooltip`).\n * See the {@link FluentTriggerComponent} type for more info.\n */\nexport function isFluentTrigger(element: React.ReactElement): element is React.ReactElement<TriggerProps> {\n return Boolean((element.type as FluentTriggerComponent).isFluentTriggerComponent);\n}\n"],"names":["isFluentTrigger","element","Boolean","type","isFluentTriggerComponent"],"rangeMappings":";;;;;;;;;;;;;;","mappings":";;;;+BAQgBA;;;eAAAA;;;;iEARO;AAQhB,SAASA,gBAAgBC,OAA2B;IACzD,OAAOC,QAAQD,QAASE,IAAI,CAA4BC,wBAAwB;AAClF"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["types.
|
1
|
+
{"version":3,"sources":["types.ts"],"sourcesContent":["import * as React from 'react';\n\n/**\n * @internal\n * Allows a component to be tagged as a FluentUI trigger component.\n *\n * Triggers are special-case components: they attach event listeners and other props on their child,\n * and use them to trigger another component to show. Examples include `MenuTrigger` and `Tooltip`.\n *\n * A component can be tagged as a trigger as follows:\n * ```ts\n * const MyComponent: React.FC<MyComponentProps> & FluentTriggerComponent = ...;\n *\n * MyComponent.isFluentTriggerComponent = true; // MUST also set this to true\n * ```\n */\nexport type FluentTriggerComponent = {\n isFluentTriggerComponent?: boolean;\n};\n\n/**\n * A trigger may have a children that could be either:\n * 1. A single element\n * 2. A render function that will receive properties and must return a valid element or null\n * 3. null or undefined\n */\nexport type TriggerProps<TriggerChildProps = unknown> = {\n children?: React.ReactElement | ((props: TriggerChildProps) => React.ReactElement | null) | null;\n};\n"],"names":[],"rangeMappings":";;;;;","mappings":";;;;;iEAAuB"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["clamp.
|
1
|
+
{"version":3,"sources":["clamp.ts"],"sourcesContent":["/**\n * @internal\n * Clamps `value` to a number between the min and max.\n *\n * @param value - the value to be clamped\n * @param min - the lowest valid value\n * @param max - the highest valid value\n */\nexport const clamp = (value: number, min: number, max: number): number => Math.max(min, Math.min(max, value || 0));\n"],"names":["clamp","value","min","max","Math"],"rangeMappings":";;;;;;;;;;;;;;;;;","mappings":"AAAA;;;;;;;CAOC;;;;+BACYA;;;eAAAA;;;AAAN,MAAMA,QAAQ,CAACC,OAAeC,KAAaC,MAAwBC,KAAKD,GAAG,CAACD,KAAKE,KAAKF,GAAG,CAACC,KAAKF,SAAS"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["createSetFromIterable.
|
1
|
+
{"version":3,"sources":["createSetFromIterable.ts"],"sourcesContent":["/**\n * Creates a set from a given iterable, in case the iterable is a set itself, returns the given set instead.\n */\nexport function createSetFromIterable<V>(iterable: Iterable<V>): Set<V> {\n return iterable instanceof Set ? iterable : new Set(iterable);\n}\n"],"names":["createSetFromIterable","iterable","Set"],"rangeMappings":";;;;;;;;;;;;;;","mappings":"AAAA;;CAEC;;;;+BACeA;;;eAAAA;;;AAAT,SAASA,sBAAyBC,QAAqB;IAC5D,OAAOA,oBAAoBC,MAAMD,WAAW,IAAIC,IAAID;AACtD"}
|