@fluentui/react-utilities 9.12.0 → 9.13.1

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.
Files changed (162) hide show
  1. package/CHANGELOG.json +63 -1
  2. package/CHANGELOG.md +28 -2
  3. package/dist/index.d.ts +4 -0
  4. package/lib/compose/assertSlots.js +8 -3
  5. package/lib/compose/assertSlots.js.map +1 -1
  6. package/lib/compose/getSlots.js +1 -1
  7. package/lib/compose/getSlots.js.map +1 -1
  8. package/lib/compose/getSlotsNext.js +1 -1
  9. package/lib/compose/getSlotsNext.js.map +1 -1
  10. package/lib/compose/isResolvedShorthand.js.map +1 -1
  11. package/lib/compose/isSlot.js +2 -1
  12. package/lib/compose/isSlot.js.map +1 -1
  13. package/lib/compose/resolveShorthand.js +2 -1
  14. package/lib/compose/resolveShorthand.js.map +1 -1
  15. package/lib/compose/slot.js +7 -7
  16. package/lib/compose/slot.js.map +1 -1
  17. package/lib/events/mouseTouchHelpers.js.map +1 -1
  18. package/lib/hooks/useAnimationFrame.js +10 -1
  19. package/lib/hooks/useAnimationFrame.js.map +1 -1
  20. package/lib/hooks/useBrowserTimer.js.map +1 -1
  21. package/lib/hooks/useControllableState.js +5 -8
  22. package/lib/hooks/useControllableState.js.map +1 -1
  23. package/lib/hooks/useEventCallback.js.map +1 -1
  24. package/lib/hooks/useFirstMount.js.map +1 -1
  25. package/lib/hooks/useForceUpdate.js.map +1 -1
  26. package/lib/hooks/useId.js.map +1 -1
  27. package/lib/hooks/useMergedRefs.js.map +1 -1
  28. package/lib/hooks/useOnClickOutside.js +34 -29
  29. package/lib/hooks/useOnClickOutside.js.map +1 -1
  30. package/lib/hooks/useOnScrollOutside.js +9 -6
  31. package/lib/hooks/useOnScrollOutside.js.map +1 -1
  32. package/lib/hooks/usePrevious.js.map +1 -1
  33. package/lib/hooks/useScrollbarWidth.js +1 -1
  34. package/lib/hooks/useScrollbarWidth.js.map +1 -1
  35. package/lib/hooks/useTimeout.js.map +1 -1
  36. package/lib/selection/useSelection.js +2 -2
  37. package/lib/selection/useSelection.js.map +1 -1
  38. package/lib/ssr/SSRContext.js +5 -7
  39. package/lib/ssr/SSRContext.js.map +1 -1
  40. package/lib/ssr/canUseDOM.js.map +1 -1
  41. package/lib/trigger/applyTriggerPropsToChildren.js.map +1 -1
  42. package/lib/trigger/getTriggerChild.js.map +1 -1
  43. package/lib/trigger/isFluentTrigger.js.map +1 -1
  44. package/lib/utils/createSetFromIterable.js.map +1 -1
  45. package/lib/utils/getNativeElementProps.js +1 -1
  46. package/lib/utils/getNativeElementProps.js.map +1 -1
  47. package/lib/utils/getRTLSafeKey.js.map +1 -1
  48. package/lib/utils/getReactCallbackName.js +2 -4
  49. package/lib/utils/getReactCallbackName.js.map +1 -1
  50. package/lib/utils/isHTMLElement.js +2 -2
  51. package/lib/utils/isHTMLElement.js.map +1 -1
  52. package/lib/utils/isInteractiveHTMLElement.js +1 -1
  53. package/lib/utils/isInteractiveHTMLElement.js.map +1 -1
  54. package/lib/utils/mergeCallbacks.js +3 -2
  55. package/lib/utils/mergeCallbacks.js.map +1 -1
  56. package/lib/utils/omit.js.map +1 -1
  57. package/lib/utils/priorityQueue.js.map +1 -1
  58. package/lib/utils/properties.js +2 -1
  59. package/lib/utils/properties.js.map +1 -1
  60. package/lib-commonjs/compose/assertSlots.js +13 -6
  61. package/lib-commonjs/compose/assertSlots.js.map +1 -1
  62. package/lib-commonjs/compose/constants.js +6 -2
  63. package/lib-commonjs/compose/constants.js.map +1 -1
  64. package/lib-commonjs/compose/getSlots.js +6 -4
  65. package/lib-commonjs/compose/getSlots.js.map +1 -1
  66. package/lib-commonjs/compose/getSlotsNext.js +6 -4
  67. package/lib-commonjs/compose/getSlotsNext.js.map +1 -1
  68. package/lib-commonjs/compose/index.js +14 -12
  69. package/lib-commonjs/compose/index.js.map +1 -1
  70. package/lib-commonjs/compose/isResolvedShorthand.js +3 -1
  71. package/lib-commonjs/compose/isResolvedShorthand.js.map +1 -1
  72. package/lib-commonjs/compose/isSlot.js +5 -2
  73. package/lib-commonjs/compose/isSlot.js.map +1 -1
  74. package/lib-commonjs/compose/resolveShorthand.js +7 -4
  75. package/lib-commonjs/compose/resolveShorthand.js.map +1 -1
  76. package/lib-commonjs/compose/slot.js +18 -12
  77. package/lib-commonjs/compose/slot.js.map +1 -1
  78. package/lib-commonjs/compose/types.js +2 -2
  79. package/lib-commonjs/compose/types.js.map +1 -1
  80. package/lib-commonjs/events/index.js +2 -2
  81. package/lib-commonjs/events/index.js.map +1 -1
  82. package/lib-commonjs/events/mouseTouchHelpers.js +11 -5
  83. package/lib-commonjs/events/mouseTouchHelpers.js.map +1 -1
  84. package/lib-commonjs/hooks/index.js +14 -14
  85. package/lib-commonjs/hooks/index.js.map +1 -1
  86. package/lib-commonjs/hooks/useAnimationFrame.js +13 -2
  87. package/lib-commonjs/hooks/useAnimationFrame.js.map +1 -1
  88. package/lib-commonjs/hooks/useBrowserTimer.js +5 -3
  89. package/lib-commonjs/hooks/useBrowserTimer.js.map +1 -1
  90. package/lib-commonjs/hooks/useControllableState.js +10 -11
  91. package/lib-commonjs/hooks/useControllableState.js.map +1 -1
  92. package/lib-commonjs/hooks/useEventCallback.js +5 -3
  93. package/lib-commonjs/hooks/useEventCallback.js.map +1 -1
  94. package/lib-commonjs/hooks/useFirstMount.js +5 -3
  95. package/lib-commonjs/hooks/useFirstMount.js.map +1 -1
  96. package/lib-commonjs/hooks/useForceUpdate.js +3 -1
  97. package/lib-commonjs/hooks/useForceUpdate.js.map +1 -1
  98. package/lib-commonjs/hooks/useId.js +11 -5
  99. package/lib-commonjs/hooks/useId.js.map +1 -1
  100. package/lib-commonjs/hooks/useIsomorphicLayoutEffect.js +5 -3
  101. package/lib-commonjs/hooks/useIsomorphicLayoutEffect.js.map +1 -1
  102. package/lib-commonjs/hooks/useMergedRefs.js +5 -3
  103. package/lib-commonjs/hooks/useMergedRefs.js.map +1 -1
  104. package/lib-commonjs/hooks/useOnClickOutside.js +38 -32
  105. package/lib-commonjs/hooks/useOnClickOutside.js.map +1 -1
  106. package/lib-commonjs/hooks/useOnScrollOutside.js +14 -9
  107. package/lib-commonjs/hooks/useOnScrollOutside.js.map +1 -1
  108. package/lib-commonjs/hooks/usePrevious.js +5 -3
  109. package/lib-commonjs/hooks/usePrevious.js.map +1 -1
  110. package/lib-commonjs/hooks/useScrollbarWidth.js +6 -4
  111. package/lib-commonjs/hooks/useScrollbarWidth.js.map +1 -1
  112. package/lib-commonjs/hooks/useTimeout.js +3 -1
  113. package/lib-commonjs/hooks/useTimeout.js.map +1 -1
  114. package/lib-commonjs/index.js +129 -43
  115. package/lib-commonjs/index.js.map +1 -1
  116. package/lib-commonjs/selection/index.js +3 -3
  117. package/lib-commonjs/selection/index.js.map +1 -1
  118. package/lib-commonjs/selection/types.js +2 -2
  119. package/lib-commonjs/selection/types.js.map +1 -1
  120. package/lib-commonjs/selection/useSelection.js +7 -5
  121. package/lib-commonjs/selection/useSelection.js.map +1 -1
  122. package/lib-commonjs/ssr/SSRContext.js +22 -14
  123. package/lib-commonjs/ssr/SSRContext.js.map +1 -1
  124. package/lib-commonjs/ssr/canUseDOM.js +3 -1
  125. package/lib-commonjs/ssr/canUseDOM.js.map +1 -1
  126. package/lib-commonjs/ssr/index.js +3 -3
  127. package/lib-commonjs/ssr/index.js.map +1 -1
  128. package/lib-commonjs/trigger/applyTriggerPropsToChildren.js +5 -3
  129. package/lib-commonjs/trigger/applyTriggerPropsToChildren.js.map +1 -1
  130. package/lib-commonjs/trigger/getTriggerChild.js +5 -3
  131. package/lib-commonjs/trigger/getTriggerChild.js.map +1 -1
  132. package/lib-commonjs/trigger/index.js +5 -5
  133. package/lib-commonjs/trigger/index.js.map +1 -1
  134. package/lib-commonjs/trigger/isFluentTrigger.js +5 -3
  135. package/lib-commonjs/trigger/isFluentTrigger.js.map +1 -1
  136. package/lib-commonjs/trigger/types.js +2 -2
  137. package/lib-commonjs/trigger/types.js.map +1 -1
  138. package/lib-commonjs/utils/clamp.js +3 -1
  139. package/lib-commonjs/utils/clamp.js.map +1 -1
  140. package/lib-commonjs/utils/createSetFromIterable.js +3 -1
  141. package/lib-commonjs/utils/createSetFromIterable.js.map +1 -1
  142. package/lib-commonjs/utils/getNativeElementProps.js +9 -5
  143. package/lib-commonjs/utils/getNativeElementProps.js.map +1 -1
  144. package/lib-commonjs/utils/getRTLSafeKey.js +3 -1
  145. package/lib-commonjs/utils/getRTLSafeKey.js.map +1 -1
  146. package/lib-commonjs/utils/getReactCallbackName.js +7 -7
  147. package/lib-commonjs/utils/getReactCallbackName.js.map +1 -1
  148. package/lib-commonjs/utils/index.js +10 -10
  149. package/lib-commonjs/utils/index.js.map +1 -1
  150. package/lib-commonjs/utils/isHTMLElement.js +5 -3
  151. package/lib-commonjs/utils/isHTMLElement.js.map +1 -1
  152. package/lib-commonjs/utils/isInteractiveHTMLElement.js +4 -2
  153. package/lib-commonjs/utils/isInteractiveHTMLElement.js.map +1 -1
  154. package/lib-commonjs/utils/mergeCallbacks.js +6 -3
  155. package/lib-commonjs/utils/mergeCallbacks.js.map +1 -1
  156. package/lib-commonjs/utils/omit.js +3 -1
  157. package/lib-commonjs/utils/omit.js.map +1 -1
  158. package/lib-commonjs/utils/priorityQueue.js +3 -1
  159. package/lib-commonjs/utils/priorityQueue.js.map +1 -1
  160. package/lib-commonjs/utils/properties.js +89 -30
  161. package/lib-commonjs/utils/properties.js.map +1 -1
  162. package/package.json +5 -5
@@ -1 +1 @@
1
- {"version":3,"sources":["useOnClickOutside.js"],"sourcesContent":["import * as React from 'react';\nimport { useEventCallback } from './useEventCallback';\n/**\n * @internal\n * Utility to perform checks where a click/touch event was made outside a component\n */ export const useOnClickOutside = (options)=>{\n const { refs , callback , element , disabled , contains: containsProp } = options;\n const timeoutId = React.useRef(undefined);\n useIFrameFocus(options);\n const isMouseDownInsideRef = React.useRef(false);\n const contains = containsProp || ((parent, child)=>{\n return !!(parent === null || parent === void 0 ? void 0 : parent.contains(child));\n });\n const listener = useEventCallback((ev)=>{\n if (isMouseDownInsideRef.current) {\n isMouseDownInsideRef.current = false;\n return;\n }\n const target = ev.composedPath()[0];\n const isOutside = refs.every((ref)=>!contains(ref.current || null, target));\n if (isOutside && !disabled) {\n callback(ev);\n }\n });\n const handleMouseDown = useEventCallback((ev)=>{\n // Selecting text from inside to outside will rigger click event.\n // In this case click event target is outside but mouse down event target is inside.\n // And this click event should be considered as inside click.\n isMouseDownInsideRef.current = refs.some((ref)=>contains(ref.current || null, ev.target));\n });\n React.useEffect(()=>{\n if (disabled) {\n return;\n }\n // Store the current event to avoid triggering handlers immediately\n // Note this depends on a deprecated but extremely well supported quirk of the web platform\n // https://github.com/facebook/react/issues/20074\n let currentEvent = getWindowEvent(window);\n const conditionalHandler = (event)=>{\n // Skip if this event is the same as the one running when we added the handlers\n if (event === currentEvent) {\n currentEvent = undefined;\n return;\n }\n listener(event);\n };\n // use capture phase because React can update DOM before the event bubbles to the document\n element === null || element === void 0 ? void 0 : element.addEventListener('click', conditionalHandler, true);\n element === null || element === void 0 ? void 0 : element.addEventListener('touchstart', conditionalHandler, true);\n element === null || element === void 0 ? void 0 : element.addEventListener('contextmenu', conditionalHandler, true);\n element === null || element === void 0 ? void 0 : element.addEventListener('mousedown', handleMouseDown, true);\n // Garbage collect this event after it's no longer useful to avoid memory leaks\n timeoutId.current = window.setTimeout(()=>{\n currentEvent = undefined;\n }, 1);\n return ()=>{\n element === null || element === void 0 ? void 0 : element.removeEventListener('click', conditionalHandler, true);\n element === null || element === void 0 ? void 0 : element.removeEventListener('touchstart', conditionalHandler, true);\n element === null || element === void 0 ? void 0 : element.removeEventListener('contextmenu', conditionalHandler, true);\n element === null || element === void 0 ? void 0 : element.removeEventListener('mousedown', handleMouseDown, true);\n clearTimeout(timeoutId.current);\n currentEvent = undefined;\n };\n }, [\n listener,\n element,\n disabled,\n handleMouseDown\n ]);\n};\nconst getWindowEvent = (target)=>{\n if (target) {\n var _target_ownerDocument, _target_ownerDocument_defaultView;\n if (typeof target.window === 'object' && target.window === target) {\n // eslint-disable-next-line deprecation/deprecation\n return target.event;\n }\n var _target_ownerDocument_defaultView_event;\n // eslint-disable-next-line deprecation/deprecation\n return (_target_ownerDocument_defaultView_event = (_target_ownerDocument = target.ownerDocument) === null || _target_ownerDocument === void 0 ? void 0 : (_target_ownerDocument_defaultView = _target_ownerDocument.defaultView) === null || _target_ownerDocument_defaultView === void 0 ? void 0 : _target_ownerDocument_defaultView.event) !== null && _target_ownerDocument_defaultView_event !== void 0 ? _target_ownerDocument_defaultView_event : undefined;\n }\n return undefined;\n};\nconst FUI_FRAME_EVENT = 'fuiframefocus';\n/**\n * Since click events do not propagate past iframes, we use focus to detect if a\n * click has happened inside an iframe, since the only ways of focusing inside an\n * iframe are:\n * - clicking inside\n * - tabbing inside\n *\n * Polls the value of `document.activeElement`. If it is an iframe, then dispatch\n * a custom DOM event. When the custom event is received call the provided callback\n */ const useIFrameFocus = (options)=>{\n const { disabled , element: targetDocument , callback , contains: containsProp = (parent, child)=>{\n return !!(parent === null || parent === void 0 ? void 0 : parent.contains(child));\n } , pollDuration =1000 , refs } = options;\n const timeoutRef = React.useRef();\n const listener = useEventCallback((e)=>{\n const contains = containsProp || ((parent, child)=>{\n return !!(parent === null || parent === void 0 ? void 0 : parent.contains(child));\n });\n const isOutside = refs.every((ref)=>!contains(ref.current || null, e.target));\n if (isOutside && !disabled) {\n callback(e);\n }\n });\n // Adds listener to the custom iframe focus event\n React.useEffect(()=>{\n if (disabled) {\n return;\n }\n targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.addEventListener(FUI_FRAME_EVENT, listener, true);\n return ()=>{\n targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.removeEventListener(FUI_FRAME_EVENT, listener, true);\n };\n }, [\n targetDocument,\n disabled,\n listener\n ]);\n // Starts polling for the active element\n React.useEffect(()=>{\n var _targetDocument_defaultView;\n if (disabled) {\n return;\n }\n timeoutRef.current = targetDocument === null || targetDocument === void 0 ? void 0 : (_targetDocument_defaultView = targetDocument.defaultView) === null || _targetDocument_defaultView === void 0 ? void 0 : _targetDocument_defaultView.setInterval(()=>{\n const activeElement = targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.activeElement;\n if ((activeElement === null || activeElement === void 0 ? void 0 : activeElement.tagName) === 'IFRAME' || (activeElement === null || activeElement === void 0 ? void 0 : activeElement.tagName) === 'WEBVIEW') {\n const event = new CustomEvent(FUI_FRAME_EVENT, {\n bubbles: true\n });\n activeElement.dispatchEvent(event);\n }\n }, pollDuration);\n return ()=>{\n var _targetDocument_defaultView;\n targetDocument === null || targetDocument === void 0 ? void 0 : (_targetDocument_defaultView = targetDocument.defaultView) === null || _targetDocument_defaultView === void 0 ? void 0 : _targetDocument_defaultView.clearTimeout(timeoutRef.current);\n };\n }, [\n targetDocument,\n disabled,\n pollDuration\n ]);\n};\n"],"names":["useOnClickOutside","options","refs","callback","element","disabled","contains","containsProp","timeoutId","React","useRef","undefined","useIFrameFocus","isMouseDownInsideRef","parent","child","listener","useEventCallback","ev","current","target","composedPath","isOutside","every","ref","handleMouseDown","some","useEffect","currentEvent","getWindowEvent","window","conditionalHandler","event","addEventListener","setTimeout","removeEventListener","clearTimeout","_target_ownerDocument","_target_ownerDocument_defaultView","_target_ownerDocument_defaultView_event","ownerDocument","defaultView","FUI_FRAME_EVENT","targetDocument","pollDuration","timeoutRef","e","_targetDocument_defaultView","setInterval","activeElement","tagName","CustomEvent","bubbles","dispatchEvent"],"mappings":";;;;+BAKiBA;;aAAAA;;;6DALM;kCACU;AAItB,MAAMA,oBAAoB,CAACC,UAAU;IAC5C,MAAM,EAAEC,KAAI,EAAGC,SAAQ,EAAGC,QAAO,EAAGC,SAAQ,EAAGC,UAAUC,aAAY,EAAG,GAAGN;IAC3E,MAAMO,YAAYC,OAAMC,MAAM,CAACC;IAC/BC,eAAeX;IACf,MAAMY,uBAAuBJ,OAAMC,MAAM,CAAC,KAAK;IAC/C,MAAMJ,WAAWC,gBAAiB,CA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.js"],"sourcesContent":["import * as React from 'react';\nimport { useEventCallback } from './useEventCallback';\nconst DEFAULT_CONTAINS = (parent, child)=>{\n var _parent;\n return !!((_parent = parent) === null || _parent === void 0 ? void 0 : _parent.contains(child));\n};\n/**\n * @internal\n * Utility to perform checks where a click/touch event was made outside a component\n */ export const useOnClickOutside = (options)=>{\n const { refs, callback, element, disabled, disabledFocusOnIframe, contains = DEFAULT_CONTAINS } = options;\n const timeoutId = React.useRef(undefined);\n useIFrameFocus({\n element,\n disabled: disabledFocusOnIframe || disabled,\n callback,\n refs,\n contains\n });\n const isMouseDownInsideRef = React.useRef(false);\n const listener = useEventCallback((ev)=>{\n if (isMouseDownInsideRef.current) {\n isMouseDownInsideRef.current = false;\n return;\n }\n const target = ev.composedPath()[0];\n const isOutside = refs.every((ref)=>!contains(ref.current || null, target));\n if (isOutside && !disabled) {\n callback(ev);\n }\n });\n const handleMouseDown = useEventCallback((ev)=>{\n // Selecting text from inside to outside will rigger click event.\n // In this case click event target is outside but mouse down event target is inside.\n // And this click event should be considered as inside click.\n isMouseDownInsideRef.current = refs.some((ref)=>contains(ref.current || null, ev.target));\n });\n React.useEffect(()=>{\n var // use capture phase because React can update DOM before the event bubbles to the document\n _element, _element1, _element2;\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 (_element = element) === null || _element === void 0 ? void 0 : _element.addEventListener('touchstart', conditionalHandler, true);\n (_element1 = element) === null || _element1 === void 0 ? void 0 : _element1.addEventListener('mouseup', conditionalHandler, true);\n (_element2 = element) === null || _element2 === void 0 ? void 0 : _element2.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 var _element, _element1, _element2;\n (_element = element) === null || _element === void 0 ? void 0 : _element.removeEventListener('touchstart', conditionalHandler, true);\n (_element1 = element) === null || _element1 === void 0 ? void 0 : _element1.removeEventListener('mouseup', conditionalHandler, true);\n (_element2 = element) === null || _element2 === void 0 ? void 0 : _element2.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 var _targetDocument;\n if (disabled) {\n return;\n }\n (_targetDocument = targetDocument) === null || _targetDocument === void 0 ? void 0 : _targetDocument.addEventListener(FUI_FRAME_EVENT, listener, true);\n return ()=>{\n var _targetDocument;\n (_targetDocument = 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, _targetDocument;\n if (disabled) {\n return;\n }\n timeoutRef.current = (_targetDocument = targetDocument) === null || _targetDocument === void 0 ? void 0 : (_targetDocument_defaultView = _targetDocument.defaultView) === null || _targetDocument_defaultView === void 0 ? void 0 : _targetDocument_defaultView.setInterval(()=>{\n var _targetDocument, _activeElement, _activeElement1;\n const activeElement = (_targetDocument = targetDocument) === null || _targetDocument === void 0 ? void 0 : _targetDocument.activeElement;\n if (((_activeElement = activeElement) === null || _activeElement === void 0 ? void 0 : _activeElement.tagName) === 'IFRAME' || ((_activeElement1 = activeElement) === null || _activeElement1 === void 0 ? void 0 : _activeElement1.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, _targetDocument;\n (_targetDocument = 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","_parent","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","_element","_element1","_element2","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","_targetDocument_defaultView","setInterval","_activeElement","_activeElement1","activeElement","tagName","CustomEvent","bubbles","dispatchEvent"],"mappings":";;;;+BASiBA;;;eAAAA;;;;iEATM;kCACU;AACjC,MAAMC,mBAAmB,CAACC,QAAQC;IAC9B,IAAIC;IACJ,OAAO,CAAC,CAAE,CAAA,AAACA,CAAAA,UAAUF,MAAK,MAAO,QAAQE,YAAY,KAAK,IAAI,KAAK,IAAIA,QAAQC,QAAQ,CAACF,MAAK;AACjG;AAIW,MAAMH,oBAAoB,CAACM;IAClC,MAAM,EAAEC,IAAI,EAAEC,QAAQ,EAAEC,OAAO,EAAEC,QAAQ,EAAEC,qBAAqB,EAAEN,WAAWJ,gBAAgB,EAAE,GAAGK;IAClG,MAAMM,YAAYC,OAAMC,MAAM,CAACC;IAC/BC,eAAe;QACXP;QACAC,UAAUC,yBAAyBD;QACnCF;QACAD;QACAF;IACJ;IACA,MAAMY,uBAAuBJ,OAAMC,MAAM,CAAC;IAC1C,MAAMI,WAAWC,IAAAA,kCAAgB,EAAC,CAACC;QAC/B,IAAIH,qBAAqBI,OAAO,EAAE;YAC9BJ,qBAAqBI,OAAO,GAAG;YAC/B;QACJ;QACA,MAAMC,SAASF,GAAGG,YAAY,EAAE,CAAC,EAAE;QACnC,MAAMC,YAAYjB,KAAKkB,KAAK,CAAC,CAACC,MAAM,CAACrB,SAASqB,IAAIL,OAAO,IAAI,MAAMC;QACnE,IAAIE,aAAa,CAACd,UAAU;YACxBF,SAASY;QACb;IACJ;IACA,MAAMO,kBAAkBR,IAAAA,kCAAgB,EAAC,CAACC;QACtC,iEAAiE;QACjE,oFAAoF;QACpF,6DAA6D;QAC7DH,qBAAqBI,OAAO,GAAGd,KAAKqB,IAAI,CAAC,CAACF,MAAMrB,SAASqB,IAAIL,OAAO,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B;QACAtC;QACAuC;KACH;AACL"}
@@ -4,16 +4,19 @@ Object.defineProperty(exports, "__esModule", {
4
4
  });
5
5
  Object.defineProperty(exports, "useOnScrollOutside", {
6
6
  enumerable: true,
7
- get: ()=>useOnScrollOutside
7
+ get: function() {
8
+ return useOnScrollOutside;
9
+ }
8
10
  });
9
- const _interopRequireWildcard = require("@swc/helpers/lib/_interop_require_wildcard.js").default;
10
- const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
11
+ const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
12
+ const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
11
13
  const _useEventCallback = require("./useEventCallback");
12
14
  const useOnScrollOutside = (options)=>{
13
- const { refs , callback , element , disabled , contains: containsProp } = options;
15
+ const { refs, callback, element, disabled, contains: containsProp } = options;
14
16
  const listener = (0, _useEventCallback.useEventCallback)((ev)=>{
15
17
  const contains = containsProp || ((parent, child)=>{
16
- return !!(parent === null || parent === void 0 ? void 0 : parent.contains(child));
18
+ var _parent;
19
+ return !!((_parent = parent) === null || _parent === void 0 ? void 0 : _parent.contains(child));
17
20
  });
18
21
  const target = ev.composedPath()[0];
19
22
  const isOutside = refs.every((ref)=>!contains(ref.current || null, target));
@@ -22,14 +25,16 @@ const useOnScrollOutside = (options)=>{
22
25
  }
23
26
  });
24
27
  _react.useEffect(()=>{
28
+ var _element, _element1;
25
29
  if (disabled) {
26
30
  return;
27
31
  }
28
- element === null || element === void 0 ? void 0 : element.addEventListener('wheel', listener);
29
- element === null || element === void 0 ? void 0 : element.addEventListener('touchmove', listener);
32
+ (_element = element) === null || _element === void 0 ? void 0 : _element.addEventListener('wheel', listener);
33
+ (_element1 = element) === null || _element1 === void 0 ? void 0 : _element1.addEventListener('touchmove', listener);
30
34
  return ()=>{
31
- element === null || element === void 0 ? void 0 : element.removeEventListener('wheel', listener);
32
- element === null || element === void 0 ? void 0 : element.removeEventListener('touchmove', listener);
35
+ var _element, _element1;
36
+ (_element = element) === null || _element === void 0 ? void 0 : _element.removeEventListener('wheel', listener);
37
+ (_element1 = element) === null || _element1 === void 0 ? void 0 : _element1.removeEventListener('touchmove', listener);
33
38
  };
34
39
  }, [
35
40
  listener,
@@ -1 +1 @@
1
- {"version":3,"sources":["useOnScrollOutside.js"],"sourcesContent":["import * as React from 'react';\nimport { useEventCallback } from './useEventCallback';\n/**\n * @internal\n * Utility to perform checks where a click/touch event was made outside a component\n */ export const useOnScrollOutside = (options)=>{\n const { refs , callback , element , disabled , contains: containsProp } = options;\n const listener = useEventCallback((ev)=>{\n const contains = containsProp || ((parent, child)=>{\n return !!(parent === null || parent === void 0 ? void 0 : parent.contains(child));\n });\n const target = ev.composedPath()[0];\n const isOutside = refs.every((ref)=>!contains(ref.current || null, target));\n if (isOutside && !disabled) {\n callback(ev);\n }\n });\n React.useEffect(()=>{\n if (disabled) {\n return;\n }\n element === null || element === void 0 ? void 0 : element.addEventListener('wheel', listener);\n element === null || element === void 0 ? void 0 : element.addEventListener('touchmove', listener);\n return ()=>{\n element === null || element === void 0 ? void 0 : element.removeEventListener('wheel', listener);\n element === null || element === void 0 ? void 0 : element.removeEventListener('touchmove', listener);\n };\n }, [\n listener,\n element,\n disabled\n ]);\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"],"mappings":";;;;+BAKiBA;;aAAAA;;;6DALM;kCACU;AAItB,MAAMA,qBAAqB,CAACC,UAAU;IAC7C,MAAM,EAAEC,KAAI,EAAGC,SAAQ,EAAGC,QAAO,EAAGC,SAAQ,EAAGC,UAAUC,aAAY,EAAG,GAAGN;IAC3E,MAAMO,WAAWC,IAAAA,kCAAgB,EAAC,CAACC,KAAK;QACpC,MAAMJ,WAAWC,gBAAiB,CAAA,CAACI,QAAQC,QAAQ;YAC/C,OAAO,CAAC,CAAED,CAAAA,WAAW,IAAI,IAAIA,WAAW,KAAK,IAAI,KAAK,IAAIA,OAAOL,QAAQ,CAACM,MAAM,AAAD;QACnF,CAAA;QACA,MAAMC,SAASH,GAAGI,YAAY,EAAE,CAAC,EAAE;QACnC,MAAMC,YAAYb,KAAKc,KAAK,CAAC,CAACC,MAAM,CAACX,SAASW,IAAIC,OAAO,IAAI,IAAI,EAAEL;QACnE,IAAIE,aAAa,CAACV,UAAU;YACxBF,SAASO;QACb,CAAC;IACL;IACAS,OAAMC,SAAS,CAAC,IAAI;QAChB,IAAIf,UAAU;YACV;QACJ,CAAC;QACDD,YAAY,IAAI,IAAIA,YAAY,KAAK,IAAI,KAAK,IAAIA,QAAQiB,gBAAgB,CAAC,SAASb,SAAS;QAC7FJ,YAAY,IAAI,IAAIA,YAAY,KAAK,IAAI,KAAK,IAAIA,QAAQiB,gBAAgB,CAAC,aAAab,SAAS;QACjG,OAAO,IAAI;YACPJ,YAAY,IAAI,IAAIA,YAAY,KAAK,IAAI,KAAK,IAAIA,QAAQkB,mBAAmB,CAAC,SAASd,SAAS;YAChGJ,YAAY,IAAI,IAAIA,YAAY,KAAK,IAAI,KAAK,IAAIA,QAAQkB,mBAAmB,CAAC,aAAad,SAAS;QACxG;IACJ,GAAG;QACCA;QACAJ;QACAC;KACH;AACL"}
1
+ {"version":3,"sources":["useOnScrollOutside.js"],"sourcesContent":["import * as React from 'react';\nimport { useEventCallback } from './useEventCallback';\n/**\n * @internal\n * Utility to perform checks where a click/touch event was made outside a component\n */ export const useOnScrollOutside = (options)=>{\n const { refs, callback, element, disabled, contains: containsProp } = options;\n const listener = useEventCallback((ev)=>{\n const contains = containsProp || ((parent, child)=>{\n var _parent;\n return !!((_parent = parent) === null || _parent === void 0 ? void 0 : _parent.contains(child));\n });\n const target = ev.composedPath()[0];\n const isOutside = refs.every((ref)=>!contains(ref.current || null, target));\n if (isOutside && !disabled) {\n callback(ev);\n }\n });\n React.useEffect(()=>{\n var _element, _element1;\n if (disabled) {\n return;\n }\n (_element = element) === null || _element === void 0 ? void 0 : _element.addEventListener('wheel', listener);\n (_element1 = element) === null || _element1 === void 0 ? void 0 : _element1.addEventListener('touchmove', listener);\n return ()=>{\n var _element, _element1;\n (_element = element) === null || _element === void 0 ? void 0 : _element.removeEventListener('wheel', listener);\n (_element1 = element) === null || _element1 === void 0 ? void 0 : _element1.removeEventListener('touchmove', listener);\n };\n }, [\n listener,\n element,\n disabled\n ]);\n};\n"],"names":["useOnScrollOutside","options","refs","callback","element","disabled","contains","containsProp","listener","useEventCallback","ev","parent","child","_parent","target","composedPath","isOutside","every","ref","current","React","useEffect","_element","_element1","addEventListener","removeEventListener"],"mappings":";;;;+BAKiBA;;;eAAAA;;;;iEALM;kCACU;AAItB,MAAMA,qBAAqB,CAACC;IACnC,MAAM,EAAEC,IAAI,EAAEC,QAAQ,EAAEC,OAAO,EAAEC,QAAQ,EAAEC,UAAUC,YAAY,EAAE,GAAGN;IACtE,MAAMO,WAAWC,IAAAA,kCAAgB,EAAC,CAACC;QAC/B,MAAMJ,WAAWC,gBAAiB,CAAA,CAACI,QAAQC;YACvC,IAAIC;YACJ,OAAO,CAAC,CAAE,CAAA,AAACA,CAAAA,UAAUF,MAAK,MAAO,QAAQE,YAAY,KAAK,IAAI,KAAK,IAAIA,QAAQP,QAAQ,CAACM,MAAK;QACjG,CAAA;QACA,MAAME,SAASJ,GAAGK,YAAY,EAAE,CAAC,EAAE;QACnC,MAAMC,YAAYd,KAAKe,KAAK,CAAC,CAACC,MAAM,CAACZ,SAASY,IAAIC,OAAO,IAAI,MAAML;QACnE,IAAIE,aAAa,CAACX,UAAU;YACxBF,SAASO;QACb;IACJ;IACAU,OAAMC,SAAS,CAAC;QACZ,IAAIC,UAAUC;QACd,IAAIlB,UAAU;YACV;QACJ;QACCiB,CAAAA,WAAWlB,OAAM,MAAO,QAAQkB,aAAa,KAAK,IAAI,KAAK,IAAIA,SAASE,gBAAgB,CAAC,SAAShB;QAClGe,CAAAA,YAAYnB,OAAM,MAAO,QAAQmB,cAAc,KAAK,IAAI,KAAK,IAAIA,UAAUC,gBAAgB,CAAC,aAAahB;QAC1G,OAAO;YACH,IAAIc,UAAUC;YACbD,CAAAA,WAAWlB,OAAM,MAAO,QAAQkB,aAAa,KAAK,IAAI,KAAK,IAAIA,SAASG,mBAAmB,CAAC,SAASjB;YACrGe,CAAAA,YAAYnB,OAAM,MAAO,QAAQmB,cAAc,KAAK,IAAI,KAAK,IAAIA,UAAUE,mBAAmB,CAAC,aAAajB;QACjH;IACJ,GAAG;QACCA;QACAJ;QACAC;KACH;AACL"}
@@ -4,10 +4,12 @@ Object.defineProperty(exports, "__esModule", {
4
4
  });
5
5
  Object.defineProperty(exports, "usePrevious", {
6
6
  enumerable: true,
7
- get: ()=>usePrevious
7
+ get: function() {
8
+ return usePrevious;
9
+ }
8
10
  });
9
- const _interopRequireWildcard = require("@swc/helpers/lib/_interop_require_wildcard.js").default;
10
- const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
11
+ const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
12
+ const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
11
13
  const usePrevious = (value)=>{
12
14
  const ref = _react.useRef(null);
13
15
  _react.useEffect(()=>{
@@ -1 +1 @@
1
- {"version":3,"sources":["usePrevious.js"],"sourcesContent":["import * as React from 'react';\n/**\n * @internal\n */ export const usePrevious = (value)=>{\n const ref = React.useRef(null);\n React.useEffect(()=>{\n ref.current = value;\n }, [\n value\n ]);\n return ref.current;\n};\n"],"names":["usePrevious","value","ref","React","useRef","useEffect","current"],"mappings":";;;;+BAGiBA;;aAAAA;;;6DAHM;AAGZ,MAAMA,cAAc,CAACC,QAAQ;IACpC,MAAMC,MAAMC,OAAMC,MAAM,CAAC,IAAI;IAC7BD,OAAME,SAAS,CAAC,IAAI;QAChBH,IAAII,OAAO,GAAGL;IAClB,GAAG;QACCA;KACH;IACD,OAAOC,IAAII,OAAO;AACtB"}
1
+ {"version":3,"sources":["usePrevious.js"],"sourcesContent":["import * as React from 'react';\n/**\n * @internal\n */ export const usePrevious = (value)=>{\n const ref = React.useRef(null);\n React.useEffect(()=>{\n ref.current = value;\n }, [\n value\n ]);\n return ref.current;\n};\n"],"names":["usePrevious","value","ref","React","useRef","useEffect","current"],"mappings":";;;;+BAGiBA;;;eAAAA;;;;iEAHM;AAGZ,MAAMA,cAAc,CAACC;IAC5B,MAAMC,MAAMC,OAAMC,MAAM,CAAC;IACzBD,OAAME,SAAS,CAAC;QACZH,IAAII,OAAO,GAAGL;IAClB,GAAG;QACCA;KACH;IACD,OAAOC,IAAII,OAAO;AACtB"}
@@ -4,13 +4,15 @@ Object.defineProperty(exports, "__esModule", {
4
4
  });
5
5
  Object.defineProperty(exports, "useScrollbarWidth", {
6
6
  enumerable: true,
7
- get: ()=>useScrollbarWidth
7
+ get: function() {
8
+ return useScrollbarWidth;
9
+ }
8
10
  });
9
- const _interopRequireWildcard = require("@swc/helpers/lib/_interop_require_wildcard.js").default;
10
- const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
11
+ const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
12
+ const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
11
13
  const cache = new WeakMap();
12
14
  function useScrollbarWidth(options) {
13
- const { targetDocument , force } = options;
15
+ const { targetDocument, force } = options;
14
16
  return _react.useMemo(()=>{
15
17
  if (!targetDocument) {
16
18
  return 0;
@@ -1 +1 @@
1
- {"version":3,"sources":["useScrollbarWidth.js"],"sourcesContent":["import * as React from 'react';\nconst cache = new WeakMap();\n/**\n * @returns The width in pixels of the scrollbar in the user agent\n */ export function useScrollbarWidth(options) {\n const { targetDocument , force } = options;\n return React.useMemo(()=>{\n if (!targetDocument) {\n return 0;\n }\n if (!force && cache.has(targetDocument)) {\n return cache.get(targetDocument);\n }\n const outer = targetDocument.createElement('div');\n outer.style.visibility = 'hidden';\n outer.style.overflow = 'scroll';\n const inner = targetDocument.createElement('div');\n outer.appendChild(inner);\n targetDocument.body.appendChild(outer);\n const scrollbarWidth = outer.offsetWidth - inner.offsetWidth;\n outer.remove();\n cache.set(targetDocument, scrollbarWidth);\n return scrollbarWidth;\n }, [\n targetDocument,\n force\n ]);\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"],"mappings":";;;;+BAIoBA;;aAAAA;;;6DAJG;AACvB,MAAMC,QAAQ,IAAIC;AAGP,SAASF,kBAAkBG,OAAO,EAAE;IAC3C,MAAM,EAAEC,eAAc,EAAGC,MAAK,EAAG,GAAGF;IACpC,OAAOG,OAAMC,OAAO,CAAC,IAAI;QACrB,IAAI,CAACH,gBAAgB;YACjB,OAAO;QACX,CAAC;QACD,IAAI,CAACC,SAASJ,MAAMO,GAAG,CAACJ,iBAAiB;YACrC,OAAOH,MAAMQ,GAAG,CAACL;QACrB,CAAC;QACD,MAAMM,QAAQN,eAAeO,aAAa,CAAC;QAC3CD,MAAME,KAAK,CAACC,UAAU,GAAG;QACzBH,MAAME,KAAK,CAACE,QAAQ,GAAG;QACvB,MAAMC,QAAQX,eAAeO,aAAa,CAAC;QAC3CD,MAAMM,WAAW,CAACD;QAClBX,eAAea,IAAI,CAACD,WAAW,CAACN;QAChC,MAAMQ,iBAAiBR,MAAMS,WAAW,GAAGJ,MAAMI,WAAW;QAC5DT,MAAMU,MAAM;QACZnB,MAAMoB,GAAG,CAACjB,gBAAgBc;QAC1B,OAAOA;IACX,GAAG;QACCd;QACAC;KACH;AACL"}
1
+ {"version":3,"sources":["useScrollbarWidth.js"],"sourcesContent":["import * as React from 'react';\nconst cache = new WeakMap();\n/**\n * @returns The width in pixels of the scrollbar in the user agent\n */ export function useScrollbarWidth(options) {\n const { targetDocument, force } = options;\n return React.useMemo(()=>{\n if (!targetDocument) {\n return 0;\n }\n if (!force && cache.has(targetDocument)) {\n return cache.get(targetDocument);\n }\n const outer = targetDocument.createElement('div');\n outer.style.visibility = 'hidden';\n outer.style.overflow = 'scroll';\n const inner = targetDocument.createElement('div');\n outer.appendChild(inner);\n targetDocument.body.appendChild(outer);\n const scrollbarWidth = outer.offsetWidth - inner.offsetWidth;\n outer.remove();\n cache.set(targetDocument, scrollbarWidth);\n return scrollbarWidth;\n }, [\n targetDocument,\n force\n ]);\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"],"mappings":";;;;+BAIoBA;;;eAAAA;;;;iEAJG;AACvB,MAAMC,QAAQ,IAAIC;AAGP,SAASF,kBAAkBG,OAAO;IACzC,MAAM,EAAEC,cAAc,EAAEC,KAAK,EAAE,GAAGF;IAClC,OAAOG,OAAMC,OAAO,CAAC;QACjB,IAAI,CAACH,gBAAgB;YACjB,OAAO;QACX;QACA,IAAI,CAACC,SAASJ,MAAMO,GAAG,CAACJ,iBAAiB;YACrC,OAAOH,MAAMQ,GAAG,CAACL;QACrB;QACA,MAAMM,QAAQN,eAAeO,aAAa,CAAC;QAC3CD,MAAME,KAAK,CAACC,UAAU,GAAG;QACzBH,MAAME,KAAK,CAACE,QAAQ,GAAG;QACvB,MAAMC,QAAQX,eAAeO,aAAa,CAAC;QAC3CD,MAAMM,WAAW,CAACD;QAClBX,eAAea,IAAI,CAACD,WAAW,CAACN;QAChC,MAAMQ,iBAAiBR,MAAMS,WAAW,GAAGJ,MAAMI,WAAW;QAC5DT,MAAMU,MAAM;QACZnB,MAAMoB,GAAG,CAACjB,gBAAgBc;QAC1B,OAAOA;IACX,GAAG;QACCd;QACAC;KACH;AACL"}
@@ -4,7 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  });
5
5
  Object.defineProperty(exports, "useTimeout", {
6
6
  enumerable: true,
7
- get: ()=>useTimeout
7
+ get: function() {
8
+ return useTimeout;
9
+ }
8
10
  });
9
11
  const _useBrowserTimer = require("./useBrowserTimer");
10
12
  function useTimeout() {
@@ -1 +1 @@
1
- {"version":3,"sources":["useTimeout.js"],"sourcesContent":["import { useBrowserTimer } from './useBrowserTimer';\n/**\n * @internal\n * Helper to manage a browser timeout.\n * Ensures that the timeout isn't set multiple times at once and is cleaned up\n * when the component is unloaded.\n *\n * @returns A pair of [setTimeout, clearTimeout] that are stable between renders.\n */ export function useTimeout() {\n // TODO: figure it out a way to not call global.setTimeout and instead infer window from some context\n return useBrowserTimer(setTimeout, clearTimeout);\n}\n"],"names":["useTimeout","useBrowserTimer","setTimeout","clearTimeout"],"mappings":";;;;+BAQoBA;;aAAAA;;iCARY;AAQrB,SAASA,aAAa;IAC7B,qGAAqG;IACrG,OAAOC,IAAAA,gCAAe,EAACC,YAAYC;AACvC"}
1
+ {"version":3,"sources":["useTimeout.js"],"sourcesContent":["import { useBrowserTimer } from './useBrowserTimer';\n/**\n * @internal\n * Helper to manage a browser timeout.\n * Ensures that the timeout isn't set multiple times at once and is cleaned up\n * when the component is unloaded.\n *\n * @returns A pair of [setTimeout, clearTimeout] that are stable between renders.\n */ export function useTimeout() {\n // TODO: figure it out a way to not call global.setTimeout and instead infer window from some context\n return useBrowserTimer(setTimeout, clearTimeout);\n}\n"],"names":["useTimeout","useBrowserTimer","setTimeout","clearTimeout"],"mappings":";;;;+BAQoBA;;;eAAAA;;;iCARY;AAQrB,SAASA;IAChB,qGAAqG;IACrG,OAAOC,IAAAA,gCAAe,EAACC,YAAYC;AACvC"}
@@ -9,49 +9,135 @@ function _export(target, all) {
9
9
  });
10
10
  }
11
11
  _export(exports, {
12
- slot: ()=>_index.slot,
13
- isSlot: ()=>_index.isSlot,
14
- getSlots: ()=>_index.getSlots,
15
- getSlotsNext: ()=>_index.getSlotsNext,
16
- assertSlots: ()=>_index.assertSlots,
17
- resolveShorthand: ()=>_index.resolveShorthand,
18
- isResolvedShorthand: ()=>_index.isResolvedShorthand,
19
- SLOT_ELEMENT_TYPE_SYMBOL: ()=>_index.SLOT_ELEMENT_TYPE_SYMBOL,
20
- SLOT_RENDER_FUNCTION_SYMBOL: ()=>_index.SLOT_RENDER_FUNCTION_SYMBOL,
21
- IdPrefixProvider: ()=>_index1.IdPrefixProvider,
22
- resetIdsForTests: ()=>_index1.resetIdsForTests,
23
- useAnimationFrame: ()=>_index1.useAnimationFrame,
24
- useControllableState: ()=>_index1.useControllableState,
25
- useEventCallback: ()=>_index1.useEventCallback,
26
- useFirstMount: ()=>_index1.useFirstMount,
27
- useForceUpdate: ()=>_index1.useForceUpdate,
28
- useId: ()=>_index1.useId,
29
- useIsomorphicLayoutEffect: ()=>_index1.useIsomorphicLayoutEffect,
30
- useMergedRefs: ()=>_index1.useMergedRefs,
31
- useOnClickOutside: ()=>_index1.useOnClickOutside,
32
- useOnScrollOutside: ()=>_index1.useOnScrollOutside,
33
- usePrevious: ()=>_index1.usePrevious,
34
- useScrollbarWidth: ()=>_index1.useScrollbarWidth,
35
- useTimeout: ()=>_index1.useTimeout,
36
- canUseDOM: ()=>_index2.canUseDOM,
37
- useIsSSR: ()=>_index2.useIsSSR,
38
- SSRProvider: ()=>_index2.SSRProvider,
39
- clamp: ()=>_index3.clamp,
40
- getNativeElementProps: ()=>_index3.getNativeElementProps,
41
- getPartitionedNativeProps: ()=>_index3.getPartitionedNativeProps,
42
- getRTLSafeKey: ()=>_index3.getRTLSafeKey,
43
- mergeCallbacks: ()=>_index3.mergeCallbacks,
44
- isHTMLElement: ()=>_index3.isHTMLElement,
45
- isInteractiveHTMLElement: ()=>_index3.isInteractiveHTMLElement,
46
- omit: ()=>_index3.omit,
47
- createPriorityQueue: ()=>_index3.createPriorityQueue,
48
- applyTriggerPropsToChildren: ()=>_index4.applyTriggerPropsToChildren,
49
- getTriggerChild: ()=>_index4.getTriggerChild,
50
- isFluentTrigger: ()=>_index4.isFluentTrigger,
51
- isTouchEvent: ()=>_index5.isTouchEvent,
52
- isMouseEvent: ()=>_index5.isMouseEvent,
53
- getEventClientCoords: ()=>_index5.getEventClientCoords,
54
- useSelection: ()=>_index6.useSelection
12
+ slot: function() {
13
+ return _index.slot;
14
+ },
15
+ isSlot: function() {
16
+ return _index.isSlot;
17
+ },
18
+ getSlots: function() {
19
+ return _index.getSlots;
20
+ },
21
+ getSlotsNext: function() {
22
+ return _index.getSlotsNext;
23
+ },
24
+ assertSlots: function() {
25
+ return _index.assertSlots;
26
+ },
27
+ resolveShorthand: function() {
28
+ return _index.resolveShorthand;
29
+ },
30
+ isResolvedShorthand: function() {
31
+ return _index.isResolvedShorthand;
32
+ },
33
+ SLOT_ELEMENT_TYPE_SYMBOL: function() {
34
+ return _index.SLOT_ELEMENT_TYPE_SYMBOL;
35
+ },
36
+ SLOT_RENDER_FUNCTION_SYMBOL: function() {
37
+ return _index.SLOT_RENDER_FUNCTION_SYMBOL;
38
+ },
39
+ IdPrefixProvider: function() {
40
+ return _index1.IdPrefixProvider;
41
+ },
42
+ resetIdsForTests: function() {
43
+ return _index1.resetIdsForTests;
44
+ },
45
+ useAnimationFrame: function() {
46
+ return _index1.useAnimationFrame;
47
+ },
48
+ useControllableState: function() {
49
+ return _index1.useControllableState;
50
+ },
51
+ useEventCallback: function() {
52
+ return _index1.useEventCallback;
53
+ },
54
+ useFirstMount: function() {
55
+ return _index1.useFirstMount;
56
+ },
57
+ useForceUpdate: function() {
58
+ return _index1.useForceUpdate;
59
+ },
60
+ useId: function() {
61
+ return _index1.useId;
62
+ },
63
+ useIsomorphicLayoutEffect: function() {
64
+ return _index1.useIsomorphicLayoutEffect;
65
+ },
66
+ useMergedRefs: function() {
67
+ return _index1.useMergedRefs;
68
+ },
69
+ useOnClickOutside: function() {
70
+ return _index1.useOnClickOutside;
71
+ },
72
+ useOnScrollOutside: function() {
73
+ return _index1.useOnScrollOutside;
74
+ },
75
+ usePrevious: function() {
76
+ return _index1.usePrevious;
77
+ },
78
+ useScrollbarWidth: function() {
79
+ return _index1.useScrollbarWidth;
80
+ },
81
+ useTimeout: function() {
82
+ return _index1.useTimeout;
83
+ },
84
+ canUseDOM: function() {
85
+ return _index2.canUseDOM;
86
+ },
87
+ useIsSSR: function() {
88
+ return _index2.useIsSSR;
89
+ },
90
+ SSRProvider: function() {
91
+ return _index2.SSRProvider;
92
+ },
93
+ clamp: function() {
94
+ return _index3.clamp;
95
+ },
96
+ getNativeElementProps: function() {
97
+ return _index3.getNativeElementProps;
98
+ },
99
+ getPartitionedNativeProps: function() {
100
+ return _index3.getPartitionedNativeProps;
101
+ },
102
+ getRTLSafeKey: function() {
103
+ return _index3.getRTLSafeKey;
104
+ },
105
+ mergeCallbacks: function() {
106
+ return _index3.mergeCallbacks;
107
+ },
108
+ isHTMLElement: function() {
109
+ return _index3.isHTMLElement;
110
+ },
111
+ isInteractiveHTMLElement: function() {
112
+ return _index3.isInteractiveHTMLElement;
113
+ },
114
+ omit: function() {
115
+ return _index3.omit;
116
+ },
117
+ createPriorityQueue: function() {
118
+ return _index3.createPriorityQueue;
119
+ },
120
+ applyTriggerPropsToChildren: function() {
121
+ return _index4.applyTriggerPropsToChildren;
122
+ },
123
+ getTriggerChild: function() {
124
+ return _index4.getTriggerChild;
125
+ },
126
+ isFluentTrigger: function() {
127
+ return _index4.isFluentTrigger;
128
+ },
129
+ isTouchEvent: function() {
130
+ return _index5.isTouchEvent;
131
+ },
132
+ isMouseEvent: function() {
133
+ return _index5.isMouseEvent;
134
+ },
135
+ getEventClientCoords: function() {
136
+ return _index5.getEventClientCoords;
137
+ },
138
+ useSelection: function() {
139
+ return _index6.useSelection;
140
+ }
55
141
  });
56
142
  const _index = require("./compose/index");
57
143
  const _index1 = require("./hooks/index");
@@ -1 +1 @@
1
- {"version":3,"sources":["index.js"],"sourcesContent":["export { slot, isSlot, getSlots, getSlotsNext, assertSlots, resolveShorthand, isResolvedShorthand, SLOT_ELEMENT_TYPE_SYMBOL, SLOT_RENDER_FUNCTION_SYMBOL } from './compose/index';\nexport { IdPrefixProvider, resetIdsForTests, useAnimationFrame, useControllableState, useEventCallback, useFirstMount, useForceUpdate, useId, useIsomorphicLayoutEffect, useMergedRefs, useOnClickOutside, useOnScrollOutside, usePrevious, useScrollbarWidth, useTimeout } from './hooks/index';\nexport { canUseDOM, useIsSSR, SSRProvider } from './ssr/index';\nexport { clamp, getNativeElementProps, getPartitionedNativeProps, getRTLSafeKey, mergeCallbacks, isHTMLElement, isInteractiveHTMLElement, omit, createPriorityQueue } from './utils/index';\nexport { applyTriggerPropsToChildren, getTriggerChild, isFluentTrigger } from './trigger/index';\nexport { isTouchEvent, isMouseEvent, getEventClientCoords } from './events/index';\nexport { useSelection } from './selection/index';\n"],"names":["slot","isSlot","getSlots","getSlotsNext","assertSlots","resolveShorthand","isResolvedShorthand","SLOT_ELEMENT_TYPE_SYMBOL","SLOT_RENDER_FUNCTION_SYMBOL","IdPrefixProvider","resetIdsForTests","useAnimationFrame","useControllableState","useEventCallback","useFirstMount","useForceUpdate","useId","useIsomorphicLayoutEffect","useMergedRefs","useOnClickOutside","useOnScrollOutside","usePrevious","useScrollbarWidth","useTimeout","canUseDOM","useIsSSR","SSRProvider","clamp","getNativeElementProps","getPartitionedNativeProps","getRTLSafeKey","mergeCallbacks","isHTMLElement","isInteractiveHTMLElement","omit","createPriorityQueue","applyTriggerPropsToChildren","getTriggerChild","isFluentTrigger","isTouchEvent","isMouseEvent","getEventClientCoords","useSelection"],"mappings":";;;;;;;;;;;IAASA,IAAI,MAAJA,WAAI;IAAEC,MAAM,MAANA,aAAM;IAAEC,QAAQ,MAARA,eAAQ;IAAEC,YAAY,MAAZA,mBAAY;IAAEC,WAAW,MAAXA,kBAAW;IAAEC,gBAAgB,MAAhBA,uBAAgB;IAAEC,mBAAmB,MAAnBA,0BAAmB;IAAEC,wBAAwB,MAAxBA,+BAAwB;IAAEC,2BAA2B,MAA3BA,kCAA2B;IAC/IC,gBAAgB,MAAhBA,wBAAgB;IAAEC,gBAAgB,MAAhBA,wBAAgB;IAAEC,iBAAiB,MAAjBA,yBAAiB;IAAEC,oBAAoB,MAApBA,4BAAoB;IAAEC,gBAAgB,MAAhBA,wBAAgB;IAAEC,aAAa,MAAbA,qBAAa;IAAEC,cAAc,MAAdA,sBAAc;IAAEC,KAAK,MAALA,aAAK;IAAEC,yBAAyB,MAAzBA,iCAAyB;IAAEC,aAAa,MAAbA,qBAAa;IAAEC,iBAAiB,MAAjBA,yBAAiB;IAAEC,kBAAkB,MAAlBA,0BAAkB;IAAEC,WAAW,MAAXA,mBAAW;IAAEC,iBAAiB,MAAjBA,yBAAiB;IAAEC,UAAU,MAAVA,kBAAU;IAChQC,SAAS,MAATA,iBAAS;IAAEC,QAAQ,MAARA,gBAAQ;IAAEC,WAAW,MAAXA,mBAAW;IAChCC,KAAK,MAALA,aAAK;IAAEC,qBAAqB,MAArBA,6BAAqB;IAAEC,yBAAyB,MAAzBA,iCAAyB;IAAEC,aAAa,MAAbA,qBAAa;IAAEC,cAAc,MAAdA,sBAAc;IAAEC,aAAa,MAAbA,qBAAa;IAAEC,wBAAwB,MAAxBA,gCAAwB;IAAEC,IAAI,MAAJA,YAAI;IAAEC,mBAAmB,MAAnBA,2BAAmB;IAC1JC,2BAA2B,MAA3BA,mCAA2B;IAAEC,eAAe,MAAfA,uBAAe;IAAEC,eAAe,MAAfA,uBAAe;IAC7DC,YAAY,MAAZA,oBAAY;IAAEC,YAAY,MAAZA,oBAAY;IAAEC,oBAAoB,MAApBA,4BAAoB;IAChDC,YAAY,MAAZA,oBAAY;;uBAN2I;wBACiH;wBAChO;wBAC0H;wBAC7F;wBACb;wBACpC"}
1
+ {"version":3,"sources":["index.js"],"sourcesContent":["export { slot, isSlot, getSlots, getSlotsNext, assertSlots, resolveShorthand, isResolvedShorthand, SLOT_ELEMENT_TYPE_SYMBOL, SLOT_RENDER_FUNCTION_SYMBOL } from './compose/index';\nexport { IdPrefixProvider, resetIdsForTests, useAnimationFrame, useControllableState, useEventCallback, useFirstMount, useForceUpdate, useId, useIsomorphicLayoutEffect, useMergedRefs, useOnClickOutside, useOnScrollOutside, usePrevious, useScrollbarWidth, useTimeout } from './hooks/index';\nexport { canUseDOM, useIsSSR, SSRProvider } from './ssr/index';\nexport { clamp, getNativeElementProps, getPartitionedNativeProps, getRTLSafeKey, mergeCallbacks, isHTMLElement, isInteractiveHTMLElement, omit, createPriorityQueue } from './utils/index';\nexport { applyTriggerPropsToChildren, getTriggerChild, isFluentTrigger } from './trigger/index';\nexport { isTouchEvent, isMouseEvent, getEventClientCoords } from './events/index';\nexport { useSelection } from './selection/index';\n"],"names":["slot","isSlot","getSlots","getSlotsNext","assertSlots","resolveShorthand","isResolvedShorthand","SLOT_ELEMENT_TYPE_SYMBOL","SLOT_RENDER_FUNCTION_SYMBOL","IdPrefixProvider","resetIdsForTests","useAnimationFrame","useControllableState","useEventCallback","useFirstMount","useForceUpdate","useId","useIsomorphicLayoutEffect","useMergedRefs","useOnClickOutside","useOnScrollOutside","usePrevious","useScrollbarWidth","useTimeout","canUseDOM","useIsSSR","SSRProvider","clamp","getNativeElementProps","getPartitionedNativeProps","getRTLSafeKey","mergeCallbacks","isHTMLElement","isInteractiveHTMLElement","omit","createPriorityQueue","applyTriggerPropsToChildren","getTriggerChild","isFluentTrigger","isTouchEvent","isMouseEvent","getEventClientCoords","useSelection"],"mappings":";;;;;;;;;;;IAASA,IAAI;eAAJA,WAAI;;IAAEC,MAAM;eAANA,aAAM;;IAAEC,QAAQ;eAARA,eAAQ;;IAAEC,YAAY;eAAZA,mBAAY;;IAAEC,WAAW;eAAXA,kBAAW;;IAAEC,gBAAgB;eAAhBA,uBAAgB;;IAAEC,mBAAmB;eAAnBA,0BAAmB;;IAAEC,wBAAwB;eAAxBA,+BAAwB;;IAAEC,2BAA2B;eAA3BA,kCAA2B;;IAC/IC,gBAAgB;eAAhBA,wBAAgB;;IAAEC,gBAAgB;eAAhBA,wBAAgB;;IAAEC,iBAAiB;eAAjBA,yBAAiB;;IAAEC,oBAAoB;eAApBA,4BAAoB;;IAAEC,gBAAgB;eAAhBA,wBAAgB;;IAAEC,aAAa;eAAbA,qBAAa;;IAAEC,cAAc;eAAdA,sBAAc;;IAAEC,KAAK;eAALA,aAAK;;IAAEC,yBAAyB;eAAzBA,iCAAyB;;IAAEC,aAAa;eAAbA,qBAAa;;IAAEC,iBAAiB;eAAjBA,yBAAiB;;IAAEC,kBAAkB;eAAlBA,0BAAkB;;IAAEC,WAAW;eAAXA,mBAAW;;IAAEC,iBAAiB;eAAjBA,yBAAiB;;IAAEC,UAAU;eAAVA,kBAAU;;IAChQC,SAAS;eAATA,iBAAS;;IAAEC,QAAQ;eAARA,gBAAQ;;IAAEC,WAAW;eAAXA,mBAAW;;IAChCC,KAAK;eAALA,aAAK;;IAAEC,qBAAqB;eAArBA,6BAAqB;;IAAEC,yBAAyB;eAAzBA,iCAAyB;;IAAEC,aAAa;eAAbA,qBAAa;;IAAEC,cAAc;eAAdA,sBAAc;;IAAEC,aAAa;eAAbA,qBAAa;;IAAEC,wBAAwB;eAAxBA,gCAAwB;;IAAEC,IAAI;eAAJA,YAAI;;IAAEC,mBAAmB;eAAnBA,2BAAmB;;IAC1JC,2BAA2B;eAA3BA,mCAA2B;;IAAEC,eAAe;eAAfA,uBAAe;;IAAEC,eAAe;eAAfA,uBAAe;;IAC7DC,YAAY;eAAZA,oBAAY;;IAAEC,YAAY;eAAZA,oBAAY;;IAAEC,oBAAoB;eAApBA,4BAAoB;;IAChDC,YAAY;eAAZA,oBAAY;;;uBAN2I;wBACiH;wBAChO;wBAC0H;wBAC7F;wBACb;wBACpC"}
@@ -2,6 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- const _exportStar = require("@swc/helpers/lib/_export_star.js").default;
6
- _exportStar(require("./types"), exports);
7
- _exportStar(require("./useSelection"), exports);
5
+ const _export_star = require("@swc/helpers/_/_export_star");
6
+ _export_star._(require("./types"), exports);
7
+ _export_star._(require("./useSelection"), exports);
@@ -1 +1 @@
1
- {"version":3,"sources":["index.js"],"sourcesContent":["export * from './types';\nexport * from './useSelection';\n"],"names":[],"mappings":";;;;;oBAAc;oBACA"}
1
+ {"version":3,"sources":["index.js"],"sourcesContent":["export * from './types';\nexport * from './useSelection';\n"],"names":[],"mappings":";;;;;uBAAc;uBACA"}
@@ -2,5 +2,5 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- const _interopRequireWildcard = require("@swc/helpers/lib/_interop_require_wildcard.js").default;
6
- const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
5
+ const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
6
+ const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
@@ -1 +1 @@
1
- {"version":3,"sources":["types.js"],"sourcesContent":["import * as React from 'react';\n"],"names":[],"mappings":";;;;;6DAAuB"}
1
+ {"version":3,"sources":["types.js"],"sourcesContent":["import * as React from 'react';\n"],"names":[],"mappings":";;;;;iEAAuB"}
@@ -4,10 +4,12 @@ Object.defineProperty(exports, "__esModule", {
4
4
  });
5
5
  Object.defineProperty(exports, "useSelection", {
6
6
  enumerable: true,
7
- get: ()=>useSelection
7
+ get: function() {
8
+ return useSelection;
9
+ }
8
10
  });
9
- const _interopRequireWildcard = require("@swc/helpers/lib/_interop_require_wildcard.js").default;
10
- const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
11
+ const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
12
+ const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
11
13
  const _useControllableState = require("../hooks/useControllableState");
12
14
  const _createSetFromIterable = require("../utils/createSetFromIterable");
13
15
  function useSelectionState(params) {
@@ -21,8 +23,8 @@ function useSelectionState(params) {
21
23
  ])
22
24
  });
23
25
  const changeSelection = (event, nextSelectedItems)=>{
24
- var _params_onSelectionChange;
25
- (_params_onSelectionChange = params.onSelectionChange) === null || _params_onSelectionChange === void 0 ? void 0 : _params_onSelectionChange.call(params, event, {
26
+ var _params_onSelectionChange, _params;
27
+ (_params_onSelectionChange = (_params = params).onSelectionChange) === null || _params_onSelectionChange === void 0 ? void 0 : _params_onSelectionChange.call(_params, event, {
26
28
  selectedItems: nextSelectedItems
27
29
  });
28
30
  setSelected(nextSelectedItems);
@@ -1 +1 @@
1
- {"version":3,"sources":["useSelection.js"],"sourcesContent":["import * as React from 'react';\nimport { useControllableState } from '../hooks/useControllableState';\nimport { createSetFromIterable } from '../utils/createSetFromIterable';\nfunction useSelectionState(params) {\n const [selected, setSelected] = useControllableState({\n initialState: new Set(),\n defaultState: React.useMemo(()=>params.defaultSelectedItems && createSetFromIterable(params.defaultSelectedItems), [\n params.defaultSelectedItems\n ]),\n state: React.useMemo(()=>params.selectedItems && createSetFromIterable(params.selectedItems), [\n params.selectedItems\n ])\n });\n const changeSelection = (event, nextSelectedItems)=>{\n var _params_onSelectionChange;\n (_params_onSelectionChange = params.onSelectionChange) === null || _params_onSelectionChange === void 0 ? void 0 : _params_onSelectionChange.call(params, event, {\n selectedItems: nextSelectedItems\n });\n setSelected(nextSelectedItems);\n };\n return [\n selected,\n changeSelection\n ];\n}\nfunction useSingleSelection(params) {\n const [selected, changeSelection] = useSelectionState(params);\n var _selected_has;\n const methods = {\n deselectItem: (event)=>changeSelection(event, new Set()),\n selectItem: (event, itemId)=>changeSelection(event, new Set([\n itemId\n ])),\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([\n itemId\n ])),\n clearItems: (event)=>changeSelection(event, new Set()),\n isSelected: (itemId)=>(_selected_has = selected.has(itemId)) !== null && _selected_has !== void 0 ? _selected_has : false\n };\n return [\n selected,\n methods\n ];\n}\nfunction useMultipleSelection(params) {\n const [selected, changeSelection] = useSelectionState(params);\n const methods = {\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 [\n selected,\n methods\n ];\n}\nexport function useSelection(params) {\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","_params_onSelectionChange","onSelectionChange","call","useSingleSelection","_selected_has","methods","deselectItem","selectItem","itemId","toggleAllItems","process","env","NODE_ENV","Error","toggleItem","clearItems","isSelected","has","useMultipleSelection","delete","add","itemIds","allItemsSelected","every","clear","forEach","selectionMode"],"mappings":";;;;+BA2FgBA;;aAAAA;;;6DA3FO;sCACc;uCACC;AACtC,SAASC,kBAAkBC,MAAM,EAAE;IAC/B,MAAM,CAACC,UAAUC,YAAY,GAAGC,IAAAA,0CAAoB,EAAC;QACjDC,cAAc,IAAIC;QAClBC,cAAcC,OAAMC,OAAO,CAAC,IAAIR,OAAOS,oBAAoB,IAAIC,IAAAA,4CAAqB,EAACV,OAAOS,oB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,CAAChB,OAAOU,SAAS;YACzB,MAAMT,oBAAoB,IAAIV,IAAIJ;YAClC,IAAIA,SAASgC,GAAG,CAACT,SAAS;gBACtBT,kBAAkBoB,MAAM,CAACX;YAC7B,OAAO;gBACHT,kBAAkBqB,GAAG,CAACZ;YAC1B,CAAC;YACDX,gBAAgBC,OAAOC;QAC3B;QACAQ,YAAY,CAACT,OAAOU,SAAS;YACzB,MAAMT,oBAAoB,IAAIV,IAAIJ;YAClCc,kBAAkBqB,GAAG,CAACZ;YACtBX,gBAAgBC,OAAOC;QAC3B;QACAO,cAAc,CAACR,OAAOU,SAAS;YAC3B,MAAMT,oBAAoB,IAAIV,IAAIJ;YAClCc,kBAAkBoB,MAAM,CAACX;YACzBX,gBAAgBC,OAAOC;QAC3B;QACAgB,YAAY,CAACjB,QAAQ;YACjBD,gBAAgBC,OAAO,IAAIT;QAC/B;QACA2B,YAAY,CAACR,SAASvB,SAASgC,GAAG,CAACT;QACnCC,gBAAgB,CAACX,OAAOuB,UAAU;YAC9B,MAAMC,mBAAmBD,QAAQE,KAAK,CAAC,CAACf,SAASvB,SAASgC,GAAG,CAACT;YAC9D,MAAMT,oBAAoB,IAAIV,IAAIJ;YAClC,IAAIqC,kBAAkB;gBAClBvB,kBAAkByB,KAAK;YAC3B,OAAO;gBACHH,QAAQI,OAAO,CAAC,CAACjB,SAAST,kBAAkBqB,GAAG,CAACZ;YACpD,CAAC;YACDX,gBAAgBC,OAAOC;QAC3B;IACJ;IACA,OAAO;QACHd;QACAoB;KACH;AACL;AACO,SAASvB,aAAaE,MAAM,EAAE;IACjC,IAAIA,OAAO0C,aAAa,KAAK,eAAe;QACxC,0EAA0E;QAC1E,sDAAsD;QACtD,OAAOR,qBAAqBlC;IAChC,CAAC;IACD,0EAA0E;IAC1E,sDAAsD;IACtD,OAAOmB,mBAAmBnB;AAC9B"}
1
+ {"version":3,"sources":["useSelection.js"],"sourcesContent":["import * as React from 'react';\nimport { useControllableState } from '../hooks/useControllableState';\nimport { createSetFromIterable } from '../utils/createSetFromIterable';\nfunction useSelectionState(params) {\n const [selected, setSelected] = useControllableState({\n initialState: new Set(),\n defaultState: React.useMemo(()=>params.defaultSelectedItems && createSetFromIterable(params.defaultSelectedItems), [\n params.defaultSelectedItems\n ]),\n state: React.useMemo(()=>params.selectedItems && createSetFromIterable(params.selectedItems), [\n params.selectedItems\n ])\n });\n const changeSelection = (event, nextSelectedItems)=>{\n var _params_onSelectionChange, _params;\n (_params_onSelectionChange = (_params = params).onSelectionChange) === null || _params_onSelectionChange === void 0 ? void 0 : _params_onSelectionChange.call(_params, event, {\n selectedItems: nextSelectedItems\n });\n setSelected(nextSelectedItems);\n };\n return [\n selected,\n changeSelection\n ];\n}\nfunction useSingleSelection(params) {\n const [selected, changeSelection] = useSelectionState(params);\n var _selected_has;\n const methods = {\n deselectItem: (event)=>changeSelection(event, new Set()),\n selectItem: (event, itemId)=>changeSelection(event, new Set([\n itemId\n ])),\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([\n itemId\n ])),\n clearItems: (event)=>changeSelection(event, new Set()),\n isSelected: (itemId)=>(_selected_has = selected.has(itemId)) !== null && _selected_has !== void 0 ? _selected_has : false\n };\n return [\n selected,\n methods\n ];\n}\nfunction useMultipleSelection(params) {\n const [selected, changeSelection] = useSelectionState(params);\n const methods = {\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 [\n selected,\n methods\n ];\n}\nexport function useSelection(params) {\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","_params_onSelectionChange","_params","onSelectionChange","call","useSingleSelection","_selected_has","methods","deselectItem","selectItem","itemId","toggleAllItems","process","env","NODE_ENV","Error","toggleItem","clearItems","isSelected","has","useMultipleSelection","delete","add","itemIds","allItemsSelected","every","clear","forEach","selectionMode"],"mappings":";;;;+BA2FgBA;;;eAAAA;;;;iEA3FO;sCACc;uCACC;AACtC,SAASC,kBAAkBC,MAAM;IAC7B,MAAM,CAACC,UAAUC,YAAY,GAAGC,IAAAA,0CAAoB,EAAC;QACjDC,cAAc,IAAIC;QAClBC,cAAcC,OAAMC,OAAO,CAAC,IAAIR,OAAOS,oBAAoB,IAAIC,IAAAA,4CAAqB,EAACV,OAAOS,oBAAoB,GAAG;YAC/GT,OAAOS,oBAAoB;SAC9B;QACDE,OAAOJ,OAAMC,OAAO,CAAC,IAAIR,OAAOY,aAAa,IAAIF,IAAAA,4CAAqB,EAACV,OAAOY,aAAa,GAAG;YAC1FZ,OAAOY,aAAa;SACvB;IACL;IACA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ACAS,YAAY,CAACV,OAAOW;YAChB,MAAMV,oBAAoB,IAAIV,IAAIJ;YAClCc,kBAAkBsB,GAAG,CAACZ;YACtBZ,gBAAgBC,OAAOC;QAC3B;QACAQ,cAAc,CAACT,OAAOW;YAClB,MAAMV,oBAAoB,IAAIV,IAAIJ;YAClCc,kBAAkBqB,MAAM,CAACX;YACzBZ,gBAAgBC,OAAOC;QAC3B;QACAiB,YAAY,CAAClB;YACTD,gBAAgBC,OAAO,IAAIT;QAC/B;QACA4B,YAAY,CAACR,SAASxB,SAASiC,GAAG,CAACT;QACnCC,gBAAgB,CAACZ,OAAOwB;YACpB,MAAMC,mBAAmBD,QAAQE,KAAK,CAAC,CAACf,SAASxB,SAASiC,GAAG,CAACT;YAC9D,MAAMV,oBAAoB,IAAIV,IAAIJ;YAClC,IAAIsC,kBAAkB;gBAClBxB,kBAAkB0B,KAAK;YAC3B,OAAO;gBACHH,QAAQI,OAAO,CAAC,CAACjB,SAASV,kBAAkBsB,GAAG,CAACZ;YACpD;YACAZ,gBAAgBC,OAAOC;QAC3B;IACJ;IACA,OAAO;QACHd;QACAqB;KACH;AACL;AACO,SAASxB,aAAaE,MAAM;IAC/B,IAAIA,OAAO2C,aAAa,KAAK,eAAe;QACxC,0EAA0E;QAC1E,sDAAsD;QACtD,OAAOR,qBAAqBnC;IAChC;IACA,0EAA0E;IAC1E,sDAAsD;IACtD,OAAOoB,mBAAmBpB;AAC9B"}
@@ -9,14 +9,24 @@ function _export(target, all) {
9
9
  });
10
10
  }
11
11
  _export(exports, {
12
- defaultSSRContextValue: ()=>defaultSSRContextValue,
13
- SSRContext: ()=>SSRContext,
14
- useSSRContext: ()=>useSSRContext,
15
- SSRProvider: ()=>SSRProvider,
16
- useIsSSR: ()=>useIsSSR
12
+ defaultSSRContextValue: function() {
13
+ return defaultSSRContextValue;
14
+ },
15
+ SSRContext: function() {
16
+ return SSRContext;
17
+ },
18
+ useSSRContext: function() {
19
+ return useSSRContext;
20
+ },
21
+ SSRProvider: function() {
22
+ return SSRProvider;
23
+ },
24
+ useIsSSR: function() {
25
+ return useIsSSR;
26
+ }
17
27
  });
18
- const _interopRequireWildcard = require("@swc/helpers/lib/_interop_require_wildcard.js").default;
19
- const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
28
+ const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
29
+ const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
20
30
  const _canUseDOM = require("./canUseDOM");
21
31
  const defaultSSRContextValue = {
22
32
  current: 0
@@ -42,13 +52,11 @@ function useIsSSR() {
42
52
  if (process.env.NODE_ENV !== 'production') {
43
53
  if (!isInSSRContext && !(0, _canUseDOM.canUseDOM)()) {
44
54
  // eslint-disable-next-line no-console
45
- console.error([
46
- '@fluentui/react-components: ',
47
- 'When server rendering, you must wrap your application in an <SSRProvider> to ensure consistent ids are ' + 'generated between the client and server.',
48
- '\n',
49
- '\n',
50
- 'Check documentation at https://aka.ms/fluentui-ssr'
51
- ].join(''));
55
+ console.error(`@fluentui/react-components [${useIsSSR.name}]:
56
+ When server rendering, you must wrap your application in an <SSRProvider> to ensure consistent ids are generated between the client and server.
57
+
58
+
59
+ Check documentation at https://aka.ms/fluentui-ssr.`);
52
60
  }
53
61
  }
54
62
  // If on the client, and the component was initially server rendered, then schedule a layout effect to update the
@@ -1 +1 @@
1
- {"version":3,"sources":["SSRContext.js"],"sourcesContent":["import * as React from 'react';\nimport { canUseDOM } from './canUseDOM';\n/**\n * Default context value to use in case there is no SSRProvider. This is fine for client-only apps.\n *\n * @internal\n */ export const defaultSSRContextValue = {\n current: 0\n};\nexport const SSRContext = /*#__PURE__*/ React.createContext(undefined);\n/**\n * @internal\n */ export function useSSRContext() {\n var _React_useContext;\n return (_React_useContext = React.useContext(SSRContext)) !== null && _React_useContext !== void 0 ? _React_useContext : defaultSSRContextValue;\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 */ export const SSRProvider = (props)=>{\n const [value] = React.useState(()=>({\n current: 0\n }));\n return /*#__PURE__*/ React.createElement(SSRContext.Provider, {\n value: value\n }, props.children);\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 */ export function useIsSSR() {\n const isInSSRContext = useSSRContext() !== defaultSSRContextValue;\n const [isSSR, setIsSSR] = React.useState(isInSSRContext);\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([\n '@fluentui/react-components: ',\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 '\\n',\n 'Check documentation at https://aka.ms/fluentui-ssr'\n ].join(''));\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 return isSSR;\n}\n"],"names":["defaultSSRContextValue","SSRContext","useSSRContext","SSRProvider","useIsSSR","current","React","createContext","undefined","_React_useContext","useContext","props","value","useState","createElement","Provider","children","isInSSRContext","isSSR","setIsSSR","process","env","NODE_ENV","canUseDOM","console","error","join","useLayoutEffect"],"mappings":";;;;;;;;;;;IAMiBA,sBAAsB,MAAtBA;IAGJC,UAAU,MAAVA;IAGOC,aAAa,MAAbA;IASHC,WAAW,MAAXA;IAWGC,QAAQ,MAARA;;;6DAhCG;2BACG;AAKf,MAAMJ,yBAAyB;IACtCK,SAAS;AACb;AACO,MAAMJ,aAAa,WAAW,GAAGK,OAAMC,aAAa,CAACC;AAGjD,SAASN,gBAAgB;IAChC,IAAIO;IACJ,OAAO,AAACA,CAAAA,oBAAoBH,OAAMI,UAAU,CAACT,WAAU,MAAO,IAAI,IAAIQ,sBAAsB,KAAK,IAAIA,oBAAoBT,sBAAsB;AACnJ;AAMW,MAAMG,cAAc,CAACQ,QAAQ;IACpC,MAAM,CAACC,MAAM,GAAGN,OAAMO,QAAQ,CAAC,IAAK,CAAA;YAC5BR,SAAS;QACb,CAAA;IACJ,OAAO,WAAW,GAAGC,OAAMQ,aAAa,CAACb,WAAWc,QAAQ,EAAE;QAC1DH,OAAOA;IACX,GAAGD,MAAMK,QAAQ;AACrB;AAIW,SAASZ,WAAW;IAC3B,MAAMa,iBAAiBf,oBAAoBF;IAC3C,MAAM,CAACkB,OAAOC,SAAS,GAAGb,OAAMO,QAAQ,CAACI;IACzC,6GAA6G;IAC7G,wBAAwB;IACxB,IAAIG,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;QACvC,IAAI,CAACL,kBAAkB,CAACM,IAAAA,oBAAS,KAAI;YACjC,sCAAsC;YACtCC,QAAQC,KAAK,CAAC;gBACV;gBACA,4GAA4G;gBAC5G;gBACA;gBACA;aACH,CAACC,IAAI,CAAC;QACX,CAAC;IACL,CAAC;IACD,iHAAiH;IACjH,6BAA6B;IAC7B,IAAIH,IAAAA,oBAAS,OAAMN,gBAAgB;QAC/B,iHAAiH;QACjH,YAAY;QACZ,2BAA2B;QAC3BX,OAAMqB,eAAe,CAAC,IAAI;YACtBR,SAAS,KAAK;QAClB,GAAG,EAAE;IACT,CAAC;IACD,OAAOD;AACX"}
1
+ {"version":3,"sources":["SSRContext.js"],"sourcesContent":["import * as React from 'react';\nimport { canUseDOM } from './canUseDOM';\n/**\n * Default context value to use in case there is no SSRProvider. This is fine for client-only apps.\n *\n * @internal\n */ export const defaultSSRContextValue = {\n current: 0\n};\nexport const SSRContext = /*#__PURE__*/ React.createContext(undefined);\n/**\n * @internal\n */ export function useSSRContext() {\n var _React_useContext;\n return (_React_useContext = React.useContext(SSRContext)) !== null && _React_useContext !== void 0 ? _React_useContext : defaultSSRContextValue;\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 */ export const SSRProvider = (props)=>{\n const [value] = React.useState(()=>({\n current: 0\n }));\n return /*#__PURE__*/ React.createElement(SSRContext.Provider, {\n value: value\n }, props.children);\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 */ export function useIsSSR() {\n const isInSSRContext = useSSRContext() !== defaultSSRContextValue;\n const [isSSR, setIsSSR] = React.useState(isInSSRContext);\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(`@fluentui/react-components [${useIsSSR.name}]:\nWhen server rendering, you must wrap your application in an <SSRProvider> to ensure consistent ids are generated between the client and server.\n\n\nCheck documentation at https://aka.ms/fluentui-ssr.`);\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 return isSSR;\n}\n"],"names":["defaultSSRContextValue","SSRContext","useSSRContext","SSRProvider","useIsSSR","current","React","createContext","undefined","_React_useContext","useContext","props","value","useState","createElement","Provider","children","isInSSRContext","isSSR","setIsSSR","process","env","NODE_ENV","canUseDOM","console","error","name","useLayoutEffect"],"mappings":";;;;;;;;;;;IAMiBA,sBAAsB;eAAtBA;;IAGJC,UAAU;eAAVA;;IAGOC,aAAa;eAAbA;;IASHC,WAAW;eAAXA;;IAWGC,QAAQ;eAARA;;;;iEAhCG;2BACG;AAKf,MAAMJ,yBAAyB;IACtCK,SAAS;AACb;AACO,MAAMJ,aAAa,WAAW,GAAGK,OAAMC,aAAa,CAACC;AAGjD,SAASN;IAChB,IAAIO;IACJ,OAAO,AAACA,CAAAA,oBAAoBH,OAAMI,UAAU,CAACT,WAAU,MAAO,QAAQQ,sBAAsB,KAAK,IAAIA,oBAAoBT;AAC7H;AAMW,MAAMG,cAAc,CAACQ;IAC5B,MAAM,CAACC,MAAM,GAAGN,OAAMO,QAAQ,CAAC,IAAK,CAAA;YAC5BR,SAAS;QACb,CAAA;IACJ,OAAO,WAAW,GAAGC,OAAMQ,aAAa,CAACb,WAAWc,QAAQ,EAAE;QAC1DH,OAAOA;IACX,GAAGD,MAAMK,QAAQ;AACrB;AAIW,SAASZ;IAChB,MAAMa,iBAAiBf,oBAAoBF;IAC3C,MAAM,CAACkB,OAAOC,SAAS,GAAGb,OAAMO,QAAQ,CAACI;IACzC,6GAA6G;IAC7G,wBAAwB;IACxB,IAAIG,QAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;QACvC,IAAI,CAACL,kBAAkB,CAACM,IAAAA,oBAAS,KAAI;YACjC,sCAAsC;YACtCC,QAAQC,KAAK,CAAC,CAAC,4BAA4B,EAAErB,SAASsB,IAAI,CAAC;;;;mDAIpB,CAAC;QAC5C;IACJ;IACA,iHAAiH;IACjH,6BAA6B;IAC7B,IAAIH,IAAAA,oBAAS,OAAMN,gBAAgB;QAC/B,iHAAiH;QACjH,YAAY;QACZ,2BAA2B;QAC3BX,OAAMqB,eAAe,CAAC;YAClBR,SAAS;QACb,GAAG,EAAE;IACT;IACA,OAAOD;AACX"}
@@ -6,7 +6,9 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  Object.defineProperty(exports, "canUseDOM", {
8
8
  enumerable: true,
9
- get: ()=>canUseDOM
9
+ get: function() {
10
+ return canUseDOM;
11
+ }
10
12
  });
11
13
  function canUseDOM() {
12
14
  return typeof window !== 'undefined' && !!(window.document && // eslint-disable-next-line deprecation/deprecation
@@ -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 && // eslint-disable-next-line deprecation/deprecation\n window.document.createElement);\n}\n"],"names":["canUseDOM","window","document","createElement"],"mappings":"AAAA;;CAEC;;;;+BAAmBA;;aAAAA;;AAAT,SAASA,YAAY;IAC5B,OAAO,OAAOC,WAAW,eAAe,CAAC,CAAEA,CAAAA,OAAOC,QAAQ,IAAI,mDAAmD;IACjHD,OAAOC,QAAQ,CAACC,aAAa,AAAD;AAChC"}
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 && // eslint-disable-next-line deprecation/deprecation\n window.document.createElement);\n}\n"],"names":["canUseDOM","window","document","createElement"],"mappings":"AAAA;;CAEC;;;;+BAAmBA;;;eAAAA;;;AAAT,SAASA;IAChB,OAAO,OAAOC,WAAW,eAAe,CAAC,CAAEA,CAAAA,OAAOC,QAAQ,IAAI,mDAAmD;IACjHD,OAAOC,QAAQ,CAACC,aAAa,AAAD;AAChC"}