@fluentui/react-utilities 0.0.0-nightly-20230316-0427.1 → 0.0.0-nightly-20230317-1454.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 (161) hide show
  1. package/.swcrc +39 -0
  2. package/CHANGELOG.json +20 -5
  3. package/CHANGELOG.md +14 -5
  4. package/dist/index.d.ts +16 -4
  5. package/lib/compose/getSlots.js +6 -7
  6. package/lib/compose/getSlots.js.map +1 -1
  7. package/lib/compose/index.js +4 -4
  8. package/lib/compose/index.js.map +1 -1
  9. package/lib/compose/isResolvedShorthand.js +2 -2
  10. package/lib/compose/isResolvedShorthand.js.map +1 -1
  11. package/lib/compose/resolveShorthand.js +3 -3
  12. package/lib/compose/resolveShorthand.js.map +1 -1
  13. package/lib/compose/types.js +1 -1
  14. package/lib/compose/types.js.map +1 -1
  15. package/lib/events/index.js +1 -1
  16. package/lib/events/index.js.map +1 -1
  17. package/lib/events/mouseTouchHelpers.js +5 -4
  18. package/lib/events/mouseTouchHelpers.js.map +1 -1
  19. package/lib/hooks/index.js +12 -12
  20. package/lib/hooks/index.js.map +1 -1
  21. package/lib/hooks/useControllableState.js +7 -7
  22. package/lib/hooks/useControllableState.js.map +1 -1
  23. package/lib/hooks/useEventCallback.js +3 -3
  24. package/lib/hooks/useEventCallback.js.map +1 -1
  25. package/lib/hooks/useFirstMount.js +1 -1
  26. package/lib/hooks/useFirstMount.js.map +1 -1
  27. package/lib/hooks/useForceUpdate.js +1 -1
  28. package/lib/hooks/useForceUpdate.js.map +1 -1
  29. package/lib/hooks/useId.js +6 -6
  30. package/lib/hooks/useId.js.map +1 -1
  31. package/lib/hooks/useIsomorphicLayoutEffect.js +3 -4
  32. package/lib/hooks/useIsomorphicLayoutEffect.js.map +1 -1
  33. package/lib/hooks/useMergedRefs.js +2 -2
  34. package/lib/hooks/useMergedRefs.js.map +1 -1
  35. package/lib/hooks/useOnClickOutside.js +20 -23
  36. package/lib/hooks/useOnClickOutside.js.map +1 -1
  37. package/lib/hooks/useOnScrollOutside.js +7 -7
  38. package/lib/hooks/useOnScrollOutside.js.map +1 -1
  39. package/lib/hooks/usePrevious.js +1 -1
  40. package/lib/hooks/usePrevious.js.map +1 -1
  41. package/lib/hooks/useScrollbarWidth.js +5 -5
  42. package/lib/hooks/useScrollbarWidth.js.map +1 -1
  43. package/lib/hooks/useTimeout.js +1 -1
  44. package/lib/hooks/useTimeout.js.map +1 -1
  45. package/lib/index.js +6 -6
  46. package/lib/index.js.map +1 -1
  47. package/lib/ssr/SSRContext.js +5 -6
  48. package/lib/ssr/SSRContext.js.map +1 -1
  49. package/lib/ssr/canUseDOM.js +2 -3
  50. package/lib/ssr/canUseDOM.js.map +1 -1
  51. package/lib/ssr/index.js +2 -2
  52. package/lib/ssr/index.js.map +1 -1
  53. package/lib/trigger/applyTriggerPropsToChildren.js +4 -4
  54. package/lib/trigger/applyTriggerPropsToChildren.js.map +1 -1
  55. package/lib/trigger/getTriggerChild.js +2 -2
  56. package/lib/trigger/getTriggerChild.js.map +1 -1
  57. package/lib/trigger/index.js +4 -4
  58. package/lib/trigger/index.js.map +1 -1
  59. package/lib/trigger/isFluentTrigger.js +1 -0
  60. package/lib/trigger/isFluentTrigger.js.map +1 -1
  61. package/lib/trigger/types.js +1 -1
  62. package/lib/trigger/types.js.map +1 -1
  63. package/lib/utils/clamp.js +1 -2
  64. package/lib/utils/clamp.js.map +1 -1
  65. package/lib/utils/getNativeElementProps.js +4 -4
  66. package/lib/utils/getNativeElementProps.js.map +1 -1
  67. package/lib/utils/getRTLSafeKey.js +6 -7
  68. package/lib/utils/getRTLSafeKey.js.map +1 -1
  69. package/lib/utils/getReactCallbackName.js +3 -2
  70. package/lib/utils/getReactCallbackName.js.map +1 -1
  71. package/lib/utils/index.js +8 -8
  72. package/lib/utils/index.js.map +1 -1
  73. package/lib/utils/isHTMLElement.js +10 -7
  74. package/lib/utils/isHTMLElement.js.map +1 -1
  75. package/lib/utils/isInteractiveHTMLElement.js +5 -5
  76. package/lib/utils/isInteractiveHTMLElement.js.map +1 -1
  77. package/lib/utils/mergeCallbacks.js +3 -4
  78. package/lib/utils/mergeCallbacks.js.map +1 -1
  79. package/lib/utils/omit.js +1 -2
  80. package/lib/utils/omit.js.map +1 -1
  81. package/lib/utils/properties.js +28 -55
  82. package/lib/utils/properties.js.map +1 -1
  83. package/lib-commonjs/compose/getSlots.js +47 -55
  84. package/lib-commonjs/compose/getSlots.js.map +1 -1
  85. package/lib-commonjs/compose/index.js +8 -7
  86. package/lib-commonjs/compose/index.js.map +1 -1
  87. package/lib-commonjs/compose/isResolvedShorthand.js +9 -37
  88. package/lib-commonjs/compose/isResolvedShorthand.js.map +1 -1
  89. package/lib-commonjs/compose/resolveShorthand.js +25 -32
  90. package/lib-commonjs/compose/resolveShorthand.js.map +1 -1
  91. package/lib-commonjs/compose/types.js +5 -2
  92. package/lib-commonjs/compose/types.js.map +1 -1
  93. package/lib-commonjs/events/index.js +5 -4
  94. package/lib-commonjs/events/index.js.map +1 -1
  95. package/lib-commonjs/events/mouseTouchHelpers.js +40 -37
  96. package/lib-commonjs/events/mouseTouchHelpers.js.map +1 -1
  97. package/lib-commonjs/hooks/index.js +16 -15
  98. package/lib-commonjs/hooks/index.js.map +1 -1
  99. package/lib-commonjs/hooks/useControllableState.js +63 -64
  100. package/lib-commonjs/hooks/useControllableState.js.map +1 -1
  101. package/lib-commonjs/hooks/useEventCallback.js +25 -31
  102. package/lib-commonjs/hooks/useEventCallback.js.map +1 -1
  103. package/lib-commonjs/hooks/useFirstMount.js +15 -23
  104. package/lib-commonjs/hooks/useFirstMount.js.map +1 -1
  105. package/lib-commonjs/hooks/useForceUpdate.js +9 -11
  106. package/lib-commonjs/hooks/useForceUpdate.js.map +1 -1
  107. package/lib-commonjs/hooks/useId.js +48 -47
  108. package/lib-commonjs/hooks/useId.js.map +1 -1
  109. package/lib-commonjs/hooks/useIsomorphicLayoutEffect.js +10 -16
  110. package/lib-commonjs/hooks/useIsomorphicLayoutEffect.js.map +1 -1
  111. package/lib-commonjs/hooks/useMergedRefs.js +25 -27
  112. package/lib-commonjs/hooks/useMergedRefs.js.map +1 -1
  113. package/lib-commonjs/hooks/useOnClickOutside.js +109 -115
  114. package/lib-commonjs/hooks/useOnClickOutside.js.map +1 -1
  115. package/lib-commonjs/hooks/useOnScrollOutside.js +33 -36
  116. package/lib-commonjs/hooks/useOnScrollOutside.js.map +1 -1
  117. package/lib-commonjs/hooks/usePrevious.js +17 -15
  118. package/lib-commonjs/hooks/usePrevious.js.map +1 -1
  119. package/lib-commonjs/hooks/useScrollbarWidth.js +32 -32
  120. package/lib-commonjs/hooks/useScrollbarWidth.js.map +1 -1
  121. package/lib-commonjs/hooks/useTimeout.js +30 -30
  122. package/lib-commonjs/hooks/useTimeout.js.map +1 -1
  123. package/lib-commonjs/index.js +52 -214
  124. package/lib-commonjs/index.js.map +1 -1
  125. package/lib-commonjs/ssr/SSRContext.js +56 -59
  126. package/lib-commonjs/ssr/SSRContext.js.map +1 -1
  127. package/lib-commonjs/ssr/canUseDOM.js +12 -12
  128. package/lib-commonjs/ssr/canUseDOM.js.map +1 -1
  129. package/lib-commonjs/ssr/index.js +6 -5
  130. package/lib-commonjs/ssr/index.js.map +1 -1
  131. package/lib-commonjs/trigger/applyTriggerPropsToChildren.js +29 -31
  132. package/lib-commonjs/trigger/applyTriggerPropsToChildren.js.map +1 -1
  133. package/lib-commonjs/trigger/getTriggerChild.js +16 -36
  134. package/lib-commonjs/trigger/getTriggerChild.js.map +1 -1
  135. package/lib-commonjs/trigger/index.js +8 -7
  136. package/lib-commonjs/trigger/index.js.map +1 -1
  137. package/lib-commonjs/trigger/isFluentTrigger.js +10 -11
  138. package/lib-commonjs/trigger/isFluentTrigger.js.map +1 -1
  139. package/lib-commonjs/trigger/types.js +5 -2
  140. package/lib-commonjs/trigger/types.js.map +1 -1
  141. package/lib-commonjs/utils/clamp.js +10 -9
  142. package/lib-commonjs/utils/clamp.js.map +1 -1
  143. package/lib-commonjs/utils/getNativeElementProps.js +54 -61
  144. package/lib-commonjs/utils/getNativeElementProps.js.map +1 -1
  145. package/lib-commonjs/utils/getRTLSafeKey.js +22 -21
  146. package/lib-commonjs/utils/getRTLSafeKey.js.map +1 -1
  147. package/lib-commonjs/utils/getReactCallbackName.js +24 -24
  148. package/lib-commonjs/utils/getReactCallbackName.js.map +1 -1
  149. package/lib-commonjs/utils/index.js +12 -11
  150. package/lib-commonjs/utils/index.js.map +1 -1
  151. package/lib-commonjs/utils/isHTMLElement.js +20 -15
  152. package/lib-commonjs/utils/isHTMLElement.js.map +1 -1
  153. package/lib-commonjs/utils/isInteractiveHTMLElement.js +20 -24
  154. package/lib-commonjs/utils/isInteractiveHTMLElement.js.map +1 -1
  155. package/lib-commonjs/utils/mergeCallbacks.js +14 -13
  156. package/lib-commonjs/utils/mergeCallbacks.js.map +1 -1
  157. package/lib-commonjs/utils/omit.js +18 -17
  158. package/lib-commonjs/utils/omit.js.map +1 -1
  159. package/lib-commonjs/utils/properties.js +327 -223
  160. package/lib-commonjs/utils/properties.js.map +1 -1
  161. package/package.json +4 -4
@@ -1 +1 @@
1
- {"version":3,"names":["React","useFirstMount","isFirst","useRef","current"],"sources":["../../../../../../../../packages/react-components/react-utilities/src/hooks/useFirstMount.ts"],"sourcesContent":["import * as React from 'react';\n\n/**\n * @internal\n * Checks if components was mounted the first time.\n * Since concurrent mode will be released in the future this needs to be verified\n * Currently (React 17) will always render the initial mount once\n * https://codesandbox.io/s/heuristic-brook-s4w0q?file=/src/App.jsx\n * https://codesandbox.io/s/holy-grass-8nieu?file=/src/App.jsx\n *\n * @example\n * const isFirstMount = useFirstMount();\n */\nexport function useFirstMount(): boolean {\n const isFirst = React.useRef(true);\n\n if (isFirst.current) {\n isFirst.current = false;\n return true;\n }\n\n return isFirst.current;\n}\n"],"mappings":"AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAE9B;;;;;;;;;;;AAWA,OAAM,SAAUC,aAAaA,CAAA;EAC3B,MAAMC,OAAO,GAAGF,KAAK,CAACG,MAAM,CAAC,IAAI,CAAC;EAElC,IAAID,OAAO,CAACE,OAAO,EAAE;IACnBF,OAAO,CAACE,OAAO,GAAG,KAAK;IACvB,OAAO,IAAI;;EAGb,OAAOF,OAAO,CAACE,OAAO;AACxB"}
1
+ {"version":3,"names":["React","useFirstMount","isFirst","useRef","current"],"sources":["../../src/hooks/useFirstMount.ts"],"sourcesContent":["import * as React from 'react';\n\n/**\n * @internal\n * Checks if components was mounted the first time.\n * Since concurrent mode will be released in the future this needs to be verified\n * Currently (React 17) will always render the initial mount once\n * https://codesandbox.io/s/heuristic-brook-s4w0q?file=/src/App.jsx\n * https://codesandbox.io/s/holy-grass-8nieu?file=/src/App.jsx\n *\n * @example\n * const isFirstMount = useFirstMount();\n */\nexport function useFirstMount(): boolean {\n const isFirst = React.useRef(true);\n\n if (isFirst.current) {\n isFirst.current = false;\n return true;\n }\n\n return isFirst.current;\n}\n"],"mappings":"AAAA,YAAYA,KAAA,MAAW;AAEvB;;;;;;;;;;;AAWA,OAAO,SAASC,cAAA,EAAyB;EACvC,MAAMC,OAAA,GAAUF,KAAA,CAAMG,MAAM,CAAC,IAAI;EAEjC,IAAID,OAAA,CAAQE,OAAO,EAAE;IACnBF,OAAA,CAAQE,OAAO,GAAG,KAAK;IACvB,OAAO,IAAI;EACb;EAEA,OAAOF,OAAA,CAAQE,OAAO;AACxB"}
@@ -1,4 +1,4 @@
1
- import { useReducer } from 'react';
1
+ import { useReducer } from "react";
2
2
  /**
3
3
  * @internal
4
4
  * Forces a re-render, similar to `forceUpdate` in class components.
@@ -1 +1 @@
1
- {"version":3,"names":["useReducer","useForceUpdate","x"],"sources":["../../../../../../../../packages/react-components/react-utilities/src/hooks/useForceUpdate.ts"],"sourcesContent":["import { useReducer } from 'react';\n\n/**\n * @internal\n * Forces a re-render, similar to `forceUpdate` in class components.\n */\nexport function useForceUpdate() {\n return useReducer(x => x + 1, 0)[1];\n}\n"],"mappings":"AAAA,SAASA,UAAU,QAAQ,OAAO;AAElC;;;;AAIA,OAAM,SAAUC,cAAcA,CAAA;EAC5B,OAAOD,UAAU,CAACE,CAAC,IAAIA,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;AACrC"}
1
+ {"version":3,"names":["useReducer","useForceUpdate","x"],"sources":["../../src/hooks/useForceUpdate.ts"],"sourcesContent":["import { useReducer } from 'react';\n\n/**\n * @internal\n * Forces a re-render, similar to `forceUpdate` in class components.\n */\nexport function useForceUpdate() {\n return useReducer(x => x + 1, 0)[1];\n}\n"],"mappings":"AAAA,SAASA,UAAU,QAAQ;AAE3B;;;;AAIA,OAAO,SAASC,eAAA,EAAiB;EAC/B,OAAOD,UAAA,CAAWE,CAAA,IAAKA,CAAA,GAAI,GAAG,EAAE,CAAC,EAAE;AACrC"}
@@ -1,5 +1,5 @@
1
- import * as React from 'react';
2
- import { defaultSSRContextValue, useSSRContext } from '../ssr/index';
1
+ import * as React from "react";
2
+ import { defaultSSRContextValue, useSSRContext } from "../ssr/index";
3
3
  const IdPrefixContext = /*#__PURE__*/React.createContext(undefined);
4
4
  /**
5
5
  * Allows to define a prefix that will be used for all IDs generated by useId() hook. It's useful to avoid collisions
@@ -7,7 +7,7 @@ const IdPrefixContext = /*#__PURE__*/React.createContext(undefined);
7
7
  */
8
8
  export const IdPrefixProvider = IdPrefixContext.Provider;
9
9
  function useIdPrefix() {
10
- return React.useContext(IdPrefixContext) || '';
10
+ return React.useContext(IdPrefixContext) || "";
11
11
  }
12
12
  /**
13
13
  * Resets generated IDs, should be used only in tests.
@@ -23,16 +23,16 @@ export function resetIdsForTests() {
23
23
  * without conditioning the hook call
24
24
  * @returns The ID
25
25
  */
26
- export function useId(prefix = 'fui-', providedId) {
26
+ export function useId(prefix = "fui-", providedId) {
27
27
  const contextValue = useSSRContext();
28
28
  const idPrefix = useIdPrefix();
29
29
  // Checking if useId is available on React, if it is, we use it to generate the id. String concatenation is used to
30
30
  // prevent bundlers from complaining with older versions of React.
31
- const _useId = React['use' + 'Id'];
31
+ const _useId = React["use" + "Id"];
32
32
  if (_useId) {
33
33
  const generatedId = _useId();
34
34
  // eslint-disable-next-line react-hooks/rules-of-hooks
35
- const escapedId = React.useMemo(() => generatedId.replace(/:/g, ''), [generatedId]);
35
+ const escapedId = React.useMemo(() => generatedId.replace(/:/g, ""), [generatedId]);
36
36
  return providedId || `${idPrefix}${prefix}${escapedId}`;
37
37
  }
38
38
  // Hooks appear to be running conditionally, but they will always run in the same order since it's based on
@@ -1 +1 @@
1
- {"version":3,"names":["React","defaultSSRContextValue","useSSRContext","IdPrefixContext","createContext","undefined","IdPrefixProvider","Provider","useIdPrefix","useContext","resetIdsForTests","current","useId","prefix","providedId","contextValue","idPrefix","_useId","generatedId","escapedId","useMemo","replace"],"sources":["../../../../../../../../packages/react-components/react-utilities/src/hooks/useId.ts"],"sourcesContent":["import * as React from 'react';\nimport { defaultSSRContextValue, useSSRContext } from '../ssr/index';\n\nconst IdPrefixContext = React.createContext<string | undefined>(undefined);\n\n/**\n * Allows to define a prefix that will be used for all IDs generated by useId() hook. It's useful to avoid collisions\n * between different bundles.\n */\nexport const IdPrefixProvider = IdPrefixContext.Provider;\n\nfunction useIdPrefix(): string {\n return React.useContext(IdPrefixContext) || '';\n}\n\n/**\n * Resets generated IDs, should be used only in tests.\n */\nexport function resetIdsForTests(): void {\n defaultSSRContextValue.current = 0;\n}\n\n/**\n * Hook to generate a unique ID.\n *\n * @param prefix - Optional prefix for the ID. Defaults to 'fui-'.\n * @param providedId - Optional id provided by a parent component. Defaults to the provided value if present,\n * without conditioning the hook call\n * @returns The ID\n */\nexport function useId(prefix: string = 'fui-', providedId?: string): string {\n const contextValue = useSSRContext();\n const idPrefix = useIdPrefix();\n\n // Checking if useId is available on React, if it is, we use it to generate the id. String concatenation is used to\n // prevent bundlers from complaining with older versions of React.\n const _useId = (React as never)['use' + 'Id'] as (() => string) | undefined;\n\n if (_useId) {\n const generatedId = _useId();\n\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const escapedId = React.useMemo(() => generatedId.replace(/:/g, ''), [generatedId]);\n\n return providedId || `${idPrefix}${prefix}${escapedId}`;\n }\n\n // Hooks appear to be running conditionally, but they will always run in the same order since it's based on\n // the version of React being used. This is safe to ignore.\n // eslint-disable-next-line react-hooks/rules-of-hooks\n return React.useMemo(() => {\n if (providedId) {\n return providedId;\n }\n\n return `${idPrefix}${prefix}${++contextValue.current}`;\n }, [idPrefix, prefix, providedId, contextValue]);\n}\n"],"mappings":"AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,SAASC,sBAAsB,EAAEC,aAAa,QAAQ,cAAc;AAEpE,MAAMC,eAAe,gBAAGH,KAAK,CAACI,aAAa,CAAqBC,SAAS,CAAC;AAE1E;;;;AAIA,OAAO,MAAMC,gBAAgB,GAAGH,eAAe,CAACI,QAAQ;AAExD,SAASC,WAAWA,CAAA;EAClB,OAAOR,KAAK,CAACS,UAAU,CAACN,eAAe,CAAC,IAAI,EAAE;AAChD;AAEA;;;AAGA,OAAM,SAAUO,gBAAgBA,CAAA;EAC9BT,sBAAsB,CAACU,OAAO,GAAG,CAAC;AACpC;AAEA;;;;;;;;AAQA,OAAM,SAAUC,KAAKA,CAACC,MAAA,GAAiB,MAAM,EAAEC,UAAmB;EAChE,MAAMC,YAAY,GAAGb,aAAa,EAAE;EACpC,MAAMc,QAAQ,GAAGR,WAAW,EAAE;EAE9B;EACA;EACA,MAAMS,MAAM,GAAIjB,KAAe,CAAC,KAAK,GAAG,IAAI,CAA+B;EAE3E,IAAIiB,MAAM,EAAE;IACV,MAAMC,WAAW,GAAGD,MAAM,EAAE;IAE5B;IACA,MAAME,SAAS,GAAGnB,KAAK,CAACoB,OAAO,CAAC,MAAMF,WAAW,CAACG,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,EAAE,CAACH,WAAW,CAAC,CAAC;IAEnF,OAAOJ,UAAU,IAAI,GAAGE,QAAQ,GAAGH,MAAM,GAAGM,SAAS,EAAE;;EAGzD;EACA;EACA;EACA,OAAOnB,KAAK,CAACoB,OAAO,CAAC,MAAK;IACxB,IAAIN,UAAU,EAAE;MACd,OAAOA,UAAU;;IAGnB,OAAO,GAAGE,QAAQ,GAAGH,MAAM,GAAG,EAAEE,YAAY,CAACJ,OAAO,EAAE;EACxD,CAAC,EAAE,CAACK,QAAQ,EAAEH,MAAM,EAAEC,UAAU,EAAEC,YAAY,CAAC,CAAC;AAClD"}
1
+ {"version":3,"names":["React","defaultSSRContextValue","useSSRContext","IdPrefixContext","createContext","undefined","IdPrefixProvider","Provider","useIdPrefix","useContext","resetIdsForTests","current","useId","prefix","providedId","contextValue","idPrefix","_useId","generatedId","escapedId","useMemo","replace"],"sources":["../../src/hooks/useId.ts"],"sourcesContent":["import * as React from 'react';\nimport { defaultSSRContextValue, useSSRContext } from '../ssr/index';\n\nconst IdPrefixContext = React.createContext<string | undefined>(undefined);\n\n/**\n * Allows to define a prefix that will be used for all IDs generated by useId() hook. It's useful to avoid collisions\n * between different bundles.\n */\nexport const IdPrefixProvider = IdPrefixContext.Provider;\n\nfunction useIdPrefix(): string {\n return React.useContext(IdPrefixContext) || '';\n}\n\n/**\n * Resets generated IDs, should be used only in tests.\n */\nexport function resetIdsForTests(): void {\n defaultSSRContextValue.current = 0;\n}\n\n/**\n * Hook to generate a unique ID.\n *\n * @param prefix - Optional prefix for the ID. Defaults to 'fui-'.\n * @param providedId - Optional id provided by a parent component. Defaults to the provided value if present,\n * without conditioning the hook call\n * @returns The ID\n */\nexport function useId(prefix: string = 'fui-', providedId?: string): string {\n const contextValue = useSSRContext();\n const idPrefix = useIdPrefix();\n\n // Checking if useId is available on React, if it is, we use it to generate the id. String concatenation is used to\n // prevent bundlers from complaining with older versions of React.\n const _useId = (React as never)['use' + 'Id'] as (() => string) | undefined;\n\n if (_useId) {\n const generatedId = _useId();\n\n // eslint-disable-next-line react-hooks/rules-of-hooks\n const escapedId = React.useMemo(() => generatedId.replace(/:/g, ''), [generatedId]);\n\n return providedId || `${idPrefix}${prefix}${escapedId}`;\n }\n\n // Hooks appear to be running conditionally, but they will always run in the same order since it's based on\n // the version of React being used. This is safe to ignore.\n // eslint-disable-next-line react-hooks/rules-of-hooks\n return React.useMemo(() => {\n if (providedId) {\n return providedId;\n }\n\n return `${idPrefix}${prefix}${++contextValue.current}`;\n }, [idPrefix, prefix, providedId, contextValue]);\n}\n"],"mappings":"AAAA,YAAYA,KAAA,MAAW;AACvB,SAASC,sBAAsB,EAAEC,aAAa,QAAQ;AAEtD,MAAMC,eAAA,gBAAkBH,KAAA,CAAMI,aAAa,CAAqBC,SAAA;AAEhE;;;;AAIA,OAAO,MAAMC,gBAAA,GAAmBH,eAAA,CAAgBI,QAAQ;AAExD,SAASC,YAAA,EAAsB;EAC7B,OAAOR,KAAA,CAAMS,UAAU,CAACN,eAAA,KAAoB;AAC9C;AAEA;;;AAGA,OAAO,SAASO,iBAAA,EAAyB;EACvCT,sBAAA,CAAuBU,OAAO,GAAG;AACnC;AAEA;;;;;;;;AAQA,OAAO,SAASC,MAAMC,MAAA,GAAiB,MAAM,EAAEC,UAAmB,EAAU;EAC1E,MAAMC,YAAA,GAAeb,aAAA;EACrB,MAAMc,QAAA,GAAWR,WAAA;EAEjB;EACA;EACA,MAAMS,MAAA,GAASjB,KAAgB,CAAC,QAAQ,KAAK;EAE7C,IAAIiB,MAAA,EAAQ;IACV,MAAMC,WAAA,GAAcD,MAAA;IAEpB;IACA,MAAME,SAAA,GAAYnB,KAAA,CAAMoB,OAAO,CAAC,MAAMF,WAAA,CAAYG,OAAO,CAAC,MAAM,KAAK,CAACH,WAAA,CAAY;IAElF,OAAOJ,UAAA,IAAe,GAAEE,QAAS,GAAEH,MAAO,GAAEM,SAAU,EAAC;EACzD;EAEA;EACA;EACA;EACA,OAAOnB,KAAA,CAAMoB,OAAO,CAAC,MAAM;IACzB,IAAIN,UAAA,EAAY;MACd,OAAOA,UAAA;IACT;IAEA,OAAQ,GAAEE,QAAS,GAAEH,MAAO,GAAE,EAAEE,YAAA,CAAaJ,OAAQ,EAAC;EACxD,GAAG,CAACK,QAAA,EAAUH,MAAA,EAAQC,UAAA,EAAYC,YAAA,CAAa;AACjD"}
@@ -1,5 +1,5 @@
1
- import * as React from 'react';
2
- import { canUseDOM } from '../ssr/index';
1
+ import * as React from "react";
2
+ import { canUseDOM } from "../ssr/index";
3
3
  /**
4
4
  * React currently throws a warning when using useLayoutEffect on the server. To get around it, we can conditionally
5
5
  * useEffect on the server (no-op) and useLayoutEffect in the browser. We occasionally need useLayoutEffect to
@@ -8,7 +8,6 @@ import { canUseDOM } from '../ssr/index';
8
8
  *
9
9
  * https://gist.github.com/gaearon/e7d97cdf38a2907924ea12e4ebdf3c85
10
10
  * https://github.com/reduxjs/react-redux/blob/master/src/utils/useIsomorphicLayoutEffect.js
11
- */
12
- // eslint-disable-next-line no-restricted-properties
11
+ */ // eslint-disable-next-line no-restricted-properties
13
12
  export const useIsomorphicLayoutEffect = /*#__PURE__*/canUseDOM() ? React.useLayoutEffect : React.useEffect;
14
13
  //# sourceMappingURL=useIsomorphicLayoutEffect.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["React","canUseDOM","useIsomorphicLayoutEffect","useLayoutEffect","useEffect"],"sources":["../../../../../../../../packages/react-components/react-utilities/src/hooks/useIsomorphicLayoutEffect.ts"],"sourcesContent":["import * as React from 'react';\nimport { canUseDOM } from '../ssr/index';\n\n/**\n * React currently throws a warning when using useLayoutEffect on the server. To get around it, we can conditionally\n * useEffect on the server (no-op) and useLayoutEffect in the browser. We occasionally need useLayoutEffect to\n * ensure we don't get a render flash for certain operations, but we may also need affected components to render on\n * the server.\n *\n * https://gist.github.com/gaearon/e7d97cdf38a2907924ea12e4ebdf3c85\n * https://github.com/reduxjs/react-redux/blob/master/src/utils/useIsomorphicLayoutEffect.js\n */\n// eslint-disable-next-line no-restricted-properties\nexport const useIsomorphicLayoutEffect: typeof React.useEffect = canUseDOM() ? React.useLayoutEffect : React.useEffect;\n"],"mappings":"AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,SAASC,SAAS,QAAQ,cAAc;AAExC;;;;;;;;;AASA;AACA,OAAO,MAAMC,yBAAyB,GAA2B,aAAAD,SAAS,EAAE,GAAGD,KAAK,CAACG,eAAe,GAAGH,KAAK,CAACI,SAAS"}
1
+ {"version":3,"names":["React","canUseDOM","useIsomorphicLayoutEffect","useLayoutEffect","useEffect"],"sources":["../../src/hooks/useIsomorphicLayoutEffect.ts"],"sourcesContent":["import * as React from 'react';\nimport { canUseDOM } from '../ssr/index';\n\n/**\n * React currently throws a warning when using useLayoutEffect on the server. To get around it, we can conditionally\n * useEffect on the server (no-op) and useLayoutEffect in the browser. We occasionally need useLayoutEffect to\n * ensure we don't get a render flash for certain operations, but we may also need affected components to render on\n * the server.\n *\n * https://gist.github.com/gaearon/e7d97cdf38a2907924ea12e4ebdf3c85\n * https://github.com/reduxjs/react-redux/blob/master/src/utils/useIsomorphicLayoutEffect.js\n */\n// eslint-disable-next-line no-restricted-properties\nexport const useIsomorphicLayoutEffect: typeof React.useEffect = canUseDOM() ? React.useLayoutEffect : React.useEffect;\n"],"mappings":"AAAA,YAAYA,KAAA,MAAW;AACvB,SAASC,SAAS,QAAQ;AAE1B;;;;;;;;GAAA,CASA;AACA,OAAO,MAAMC,yBAAA,GAAoD,aAAAD,SAAA,KAAcD,KAAA,CAAMG,eAAe,GAAGH,KAAA,CAAMI,SAAS"}
@@ -1,4 +1,4 @@
1
- import * as React from 'react';
1
+ import * as React from "react";
2
2
  /**
3
3
  * React hook to merge multiple React refs (either MutableRefObjects or ref callbacks) into a single ref callback that
4
4
  * updates all provided refs
@@ -10,7 +10,7 @@ export function useMergedRefs(...refs) {
10
10
  // Update the "current" prop hanging on the function.
11
11
  mergedCallback.current = value;
12
12
  for (const ref of refs) {
13
- if (typeof ref === 'function') {
13
+ if (typeof ref === "function") {
14
14
  ref(value);
15
15
  } else if (ref) {
16
16
  // work around the immutability of the React.Ref type
@@ -1 +1 @@
1
- {"version":3,"names":["React","useMergedRefs","refs","mergedCallback","useCallback","value","current","ref"],"sources":["../../../../../../../../packages/react-components/react-utilities/src/hooks/useMergedRefs.ts"],"sourcesContent":["import * as React from 'react';\n\n/**\n * A Ref function which can be treated like a ref object in that it has an attached\n * current property, which will be updated as the ref is evaluated.\n */\nexport type RefObjectFunction<T> = React.RefObject<T> & ((value: T) => void);\n\n/**\n * React hook to merge multiple React refs (either MutableRefObjects or ref callbacks) into a single ref callback that\n * updates all provided refs\n * @param refs - Refs to collectively update with one ref value.\n * @returns A function with an attached \"current\" prop, so that it can be treated like a RefObject.\n */\nexport function useMergedRefs<T>(...refs: (React.Ref<T> | undefined)[]): RefObjectFunction<T> {\n const mergedCallback: RefObjectFunction<T> = React.useCallback(\n (value: T) => {\n // Update the \"current\" prop hanging on the function.\n (mergedCallback as unknown as React.MutableRefObject<T>).current = value;\n\n for (const ref of refs) {\n if (typeof ref === 'function') {\n ref(value);\n } else if (ref) {\n // work around the immutability of the React.Ref type\n (ref as unknown as React.MutableRefObject<T>).current = value;\n }\n }\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps -- already exhaustive\n [...refs],\n ) as unknown as RefObjectFunction<T>;\n\n return mergedCallback;\n}\n"],"mappings":"AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAQ9B;;;;;;AAMA,OAAM,SAAUC,aAAaA,CAAI,GAAGC,IAAkC;EACpE,MAAMC,cAAc,GAAyBH,KAAK,CAACI,WAAW,CAC3DC,KAAQ,IAAI;IACX;IACCF,cAAuD,CAACG,OAAO,GAAGD,KAAK;IAExE,KAAK,MAAME,GAAG,IAAIL,IAAI,EAAE;MACtB,IAAI,OAAOK,GAAG,KAAK,UAAU,EAAE;QAC7BA,GAAG,CAACF,KAAK,CAAC;OACX,MAAM,IAAIE,GAAG,EAAE;QACd;QACCA,GAA4C,CAACD,OAAO,GAAGD,KAAK;;;EAGnE,CAAC;EACD;EACA,CAAC,GAAGH,IAAI,CAAC,CACyB;EAEpC,OAAOC,cAAc;AACvB"}
1
+ {"version":3,"names":["React","useMergedRefs","refs","mergedCallback","useCallback","value","current","ref"],"sources":["../../src/hooks/useMergedRefs.ts"],"sourcesContent":["import * as React from 'react';\n\n/**\n * A Ref function which can be treated like a ref object in that it has an attached\n * current property, which will be updated as the ref is evaluated.\n */\nexport type RefObjectFunction<T> = React.RefObject<T> & ((value: T) => void);\n\n/**\n * React hook to merge multiple React refs (either MutableRefObjects or ref callbacks) into a single ref callback that\n * updates all provided refs\n * @param refs - Refs to collectively update with one ref value.\n * @returns A function with an attached \"current\" prop, so that it can be treated like a RefObject.\n */\nexport function useMergedRefs<T>(...refs: (React.Ref<T> | undefined)[]): RefObjectFunction<T> {\n const mergedCallback: RefObjectFunction<T> = React.useCallback(\n (value: T) => {\n // Update the \"current\" prop hanging on the function.\n (mergedCallback as unknown as React.MutableRefObject<T>).current = value;\n\n for (const ref of refs) {\n if (typeof ref === 'function') {\n ref(value);\n } else if (ref) {\n // work around the immutability of the React.Ref type\n (ref as unknown as React.MutableRefObject<T>).current = value;\n }\n }\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps -- already exhaustive\n [...refs],\n ) as unknown as RefObjectFunction<T>;\n\n return mergedCallback;\n}\n"],"mappings":"AAAA,YAAYA,KAAA,MAAW;AAQvB;;;;;;AAMA,OAAO,SAASC,cAAiB,GAAGC,IAAkC,EAAwB;EAC5F,MAAMC,cAAA,GAAuCH,KAAA,CAAMI,WAAW,CAC3DC,KAAA,IAAa;IACZ;IACCF,cAAA,CAAwDG,OAAO,GAAGD,KAAA;IAEnE,KAAK,MAAME,GAAA,IAAOL,IAAA,EAAM;MACtB,IAAI,OAAOK,GAAA,KAAQ,YAAY;QAC7BA,GAAA,CAAIF,KAAA;MACN,OAAO,IAAIE,GAAA,EAAK;QACd;QACCA,GAAA,CAA6CD,OAAO,GAAGD,KAAA;MAC1D;IACF;EACF;EACA;EACA,C,GAAIH,IAAA,CAAK;EAGX,OAAOC,cAAA;AACT"}
@@ -1,5 +1,5 @@
1
- import * as React from 'react';
2
- import { useEventCallback } from './useEventCallback';
1
+ import * as React from "react";
2
+ import { useEventCallback } from "./useEventCallback";
3
3
  /**
4
4
  * @internal
5
5
  * Utility to perform checks where a click/touch event was made outside a component
@@ -15,7 +15,7 @@ export const useOnClickOutside = options => {
15
15
  const timeoutId = React.useRef(undefined);
16
16
  useIFrameFocus(options);
17
17
  const listener = useEventCallback(ev => {
18
- const contains = containsProp || ((parent, child) => !!(parent === null || parent === void 0 ? void 0 : parent.contains(child)));
18
+ const contains = containsProp || ((parent, child) => !!parent?.contains(child));
19
19
  const isOutside = refs.every(ref => !contains(ref.current || null, ev.target));
20
20
  if (isOutside && !disabled) {
21
21
  callback(ev);
@@ -36,36 +36,35 @@ export const useOnClickOutside = options => {
36
36
  };
37
37
  if (!disabled) {
38
38
  // use capture phase because React can update DOM before the event bubbles to the document
39
- element === null || element === void 0 ? void 0 : element.addEventListener('click', conditionalHandler, true);
40
- element === null || element === void 0 ? void 0 : element.addEventListener('touchstart', conditionalHandler, true);
41
- element === null || element === void 0 ? void 0 : element.addEventListener('contextmenu', conditionalHandler, true);
39
+ element?.addEventListener("click", conditionalHandler, true);
40
+ element?.addEventListener("touchstart", conditionalHandler, true);
41
+ element?.addEventListener("contextmenu", conditionalHandler, true);
42
42
  }
43
43
  // Garbage collect this event after it's no longer useful to avoid memory leaks
44
44
  timeoutId.current = window.setTimeout(() => {
45
45
  currentEvent = undefined;
46
46
  }, 1);
47
47
  return () => {
48
- element === null || element === void 0 ? void 0 : element.removeEventListener('click', conditionalHandler, true);
49
- element === null || element === void 0 ? void 0 : element.removeEventListener('touchstart', conditionalHandler, true);
50
- element === null || element === void 0 ? void 0 : element.removeEventListener('contextmenu', conditionalHandler, true);
48
+ element?.removeEventListener("click", conditionalHandler, true);
49
+ element?.removeEventListener("touchstart", conditionalHandler, true);
50
+ element?.removeEventListener("contextmenu", conditionalHandler, true);
51
51
  clearTimeout(timeoutId.current);
52
52
  currentEvent = undefined;
53
53
  };
54
54
  }, [listener, element, disabled]);
55
55
  };
56
56
  const getWindowEvent = target => {
57
- var _a, _b, _c;
58
57
  if (target) {
59
- if (typeof target.window === 'object' && target.window === target) {
58
+ if (typeof target.window === "object" && target.window === target) {
60
59
  // eslint-disable-next-line deprecation/deprecation
61
60
  return target.event;
62
61
  }
63
62
  // eslint-disable-next-line deprecation/deprecation
64
- return (_c = (_b = (_a = target.ownerDocument) === null || _a === void 0 ? void 0 : _a.defaultView) === null || _b === void 0 ? void 0 : _b.event) !== null && _c !== void 0 ? _c : undefined;
63
+ return target.ownerDocument?.defaultView?.event ?? undefined;
65
64
  }
66
65
  return undefined;
67
66
  };
68
- const FUI_FRAME_EVENT = 'fuiframefocus';
67
+ const FUI_FRAME_EVENT = "fuiframefocus";
69
68
  /**
70
69
  * Since click events do not propagate past iframes, we use focus to detect if a
71
70
  * click has happened inside an iframe, since the only ways of focusing inside an
@@ -81,13 +80,13 @@ const useIFrameFocus = options => {
81
80
  disabled,
82
81
  element: targetDocument,
83
82
  callback,
84
- contains: containsProp = (parent, child) => !!(parent === null || parent === void 0 ? void 0 : parent.contains(child)),
83
+ contains: containsProp = (parent, child) => !!parent?.contains(child),
85
84
  pollDuration = 1000,
86
85
  refs
87
86
  } = options;
88
87
  const timeoutRef = React.useRef();
89
88
  const listener = useEventCallback(e => {
90
- const contains = containsProp || ((parent, child) => !!(parent === null || parent === void 0 ? void 0 : parent.contains(child)));
89
+ const contains = containsProp || ((parent, child) => !!parent?.contains(child));
91
90
  const isOutside = refs.every(ref => !contains(ref.current || null, e.target));
92
91
  if (isOutside && !disabled) {
93
92
  callback(e);
@@ -96,19 +95,18 @@ const useIFrameFocus = options => {
96
95
  // Adds listener to the custom iframe focus event
97
96
  React.useEffect(() => {
98
97
  if (!disabled) {
99
- targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.addEventListener(FUI_FRAME_EVENT, listener, true);
98
+ targetDocument?.addEventListener(FUI_FRAME_EVENT, listener, true);
100
99
  return () => {
101
- targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.removeEventListener(FUI_FRAME_EVENT, listener, true);
100
+ targetDocument?.removeEventListener(FUI_FRAME_EVENT, listener, true);
102
101
  };
103
102
  }
104
103
  }, [targetDocument, disabled, listener]);
105
104
  // Starts polling for the active element
106
105
  React.useEffect(() => {
107
- var _a;
108
106
  if (!disabled) {
109
- timeoutRef.current = (_a = targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.defaultView) === null || _a === void 0 ? void 0 : _a.setInterval(() => {
110
- const activeElement = targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.activeElement;
111
- if ((activeElement === null || activeElement === void 0 ? void 0 : activeElement.tagName) === 'IFRAME' || (activeElement === null || activeElement === void 0 ? void 0 : activeElement.tagName) === 'WEBVIEW') {
107
+ timeoutRef.current = targetDocument?.defaultView?.setInterval(() => {
108
+ const activeElement = targetDocument?.activeElement;
109
+ if (activeElement?.tagName === "IFRAME" || activeElement?.tagName === "WEBVIEW") {
112
110
  const event = new CustomEvent(FUI_FRAME_EVENT, {
113
111
  bubbles: true
114
112
  });
@@ -117,8 +115,7 @@ const useIFrameFocus = options => {
117
115
  }, pollDuration);
118
116
  }
119
117
  return () => {
120
- var _a;
121
- (_a = targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.defaultView) === null || _a === void 0 ? void 0 : _a.clearTimeout(timeoutRef.current);
118
+ targetDocument?.defaultView?.clearTimeout(timeoutRef.current);
122
119
  };
123
120
  }, [targetDocument, disabled, pollDuration]);
124
121
  };
@@ -1 +1 @@
1
- {"version":3,"names":["React","useEventCallback","useOnClickOutside","options","refs","callback","element","disabled","contains","containsProp","timeoutId","useRef","undefined","useIFrameFocus","listener","ev","parent","child","isOutside","every","ref","current","target","useEffect","currentEvent","getWindowEvent","window","conditionalHandler","event","addEventListener","setTimeout","removeEventListener","clearTimeout","_c","_b","_a","ownerDocument","defaultView","FUI_FRAME_EVENT","targetDocument","pollDuration","timeoutRef","e","setInterval","activeElement","tagName","CustomEvent","bubbles","dispatchEvent"],"sources":["../../../../../../../../packages/react-components/react-utilities/src/hooks/useOnClickOutside.ts"],"sourcesContent":["import * as React from 'react';\nimport { useEventCallback } from './useEventCallback';\n\n/**\n * @internal\n */\nexport type UseOnClickOrScrollOutsideOptions = {\n /**\n * The element to listen for the click event\n */\n element: Document | undefined;\n /**\n * Refs to elements that check if the click is outside\n */\n refs: React.MutableRefObject<HTMLElement | undefined | null>[];\n\n /**\n * By default uses element.contains, but custom contain function can be provided\n * @param parentRef - provided parent ref\n * @param child - event target element\n */\n contains?(parent: HTMLElement | null, child: HTMLElement): boolean;\n\n /**\n * Disables event listeners\n */\n disabled?: boolean;\n\n /**\n * Called if the click is outside the element refs\n */\n callback: (ev: MouseEvent | TouchEvent) => void;\n};\n\n/**\n * @internal\n * Utility to perform checks where a click/touch event was made outside a component\n */\nexport const useOnClickOutside = (options: UseOnClickOrScrollOutsideOptions) => {\n const { refs, callback, element, disabled, contains: containsProp } = options;\n const timeoutId = React.useRef<number | undefined>(undefined);\n useIFrameFocus(options);\n\n const listener = useEventCallback((ev: MouseEvent | TouchEvent) => {\n const contains: UseOnClickOrScrollOutsideOptions['contains'] =\n containsProp || ((parent, child) => !!parent?.contains(child));\n\n const isOutside = refs.every(ref => !contains(ref.current || null, ev.target as HTMLElement));\n if (isOutside && !disabled) {\n callback(ev);\n }\n });\n\n React.useEffect(() => {\n // Store the current event to avoid triggering handlers immediately\n // Note this depends on a deprecated but extremely well supported quirk of the web platform\n // https://github.com/facebook/react/issues/20074\n let currentEvent = getWindowEvent(window);\n\n const conditionalHandler = (event: MouseEvent | TouchEvent) => {\n // Skip if this event is the same as the one running when we added the handlers\n if (event === currentEvent) {\n currentEvent = undefined;\n return;\n }\n\n listener(event);\n };\n\n if (!disabled) {\n // use capture phase because React can update DOM before the event bubbles to the document\n element?.addEventListener('click', conditionalHandler, true);\n element?.addEventListener('touchstart', conditionalHandler, true);\n element?.addEventListener('contextmenu', conditionalHandler, true);\n }\n\n // Garbage collect this event after it's no longer useful to avoid memory leaks\n timeoutId.current = window.setTimeout(() => {\n currentEvent = undefined;\n }, 1);\n\n return () => {\n element?.removeEventListener('click', conditionalHandler, true);\n element?.removeEventListener('touchstart', conditionalHandler, true);\n element?.removeEventListener('contextmenu', conditionalHandler, true);\n\n clearTimeout(timeoutId.current);\n currentEvent = undefined;\n };\n }, [listener, element, disabled]);\n};\n\nconst getWindowEvent = (target: Node | Window): Event | undefined => {\n if (target) {\n if (typeof (target as Window).window === 'object' && (target as Window).window === target) {\n // eslint-disable-next-line deprecation/deprecation\n return target.event;\n }\n\n // eslint-disable-next-line deprecation/deprecation\n return (target as Node).ownerDocument?.defaultView?.event ?? undefined;\n }\n\n return undefined;\n};\n\nconst FUI_FRAME_EVENT = 'fuiframefocus';\n\ninterface UseIFrameFocusOptions extends UseOnClickOrScrollOutsideOptions {\n /**\n * Millisecond duration to poll\n */\n pollDuration?: number;\n}\n\n/**\n * Since click events do not propagate past iframes, we use focus to detect if a\n * click has happened inside an iframe, since the only ways of focusing inside an\n * iframe are:\n * - clicking inside\n * - tabbing inside\n *\n * Polls the value of `document.activeElement`. If it is an iframe, then dispatch\n * a custom DOM event. When the custom event is received call the provided callback\n */\nconst useIFrameFocus = (options: UseIFrameFocusOptions) => {\n const {\n disabled,\n element: targetDocument,\n callback,\n contains: containsProp = (parent, child) => !!parent?.contains(child),\n pollDuration = 1000,\n refs,\n } = options;\n const timeoutRef = React.useRef<number>();\n\n const listener = useEventCallback((e: Event) => {\n const contains = containsProp || ((parent, child) => !!parent?.contains(child));\n\n const isOutside = refs.every(ref => !contains(ref.current || null, e.target as HTMLElement));\n if (isOutside && !disabled) {\n callback(e as MouseEvent);\n }\n });\n\n // Adds listener to the custom iframe focus event\n React.useEffect(() => {\n if (!disabled) {\n targetDocument?.addEventListener(FUI_FRAME_EVENT, listener, true);\n return () => {\n targetDocument?.removeEventListener(FUI_FRAME_EVENT, listener, true);\n };\n }\n }, [targetDocument, disabled, listener]);\n\n // Starts polling for the active element\n React.useEffect(() => {\n if (!disabled) {\n timeoutRef.current = targetDocument?.defaultView?.setInterval(() => {\n const activeElement = targetDocument?.activeElement;\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"],"mappings":"AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,SAASC,gBAAgB,QAAQ,oBAAoB;AAiCrD;;;;AAIA,OAAO,MAAMC,iBAAiB,GAAIC,OAAyC,IAAI;EAC7E,MAAM;IAAEC,IAAI;IAAEC,QAAQ;IAAEC,OAAO;IAAEC,QAAQ;IAAEC,QAAQ,EAAEC;EAAY,CAAE,GAAGN,OAAO;EAC7E,MAAMO,SAAS,GAAGV,KAAK,CAACW,MAAM,CAAqBC,SAAS,CAAC;EAC7DC,cAAc,CAACV,OAAO,CAAC;EAEvB,MAAMW,QAAQ,GAAGb,gBAAgB,CAAEc,EAA2B,IAAI;IAChE,MAAMP,QAAQ,GACZC,YAAY,KAAK,CAACO,MAAM,EAAEC,KAAK,KAAK,CAAC,EAACD,MAAM,aAANA,MAAM,uBAANA,MAAM,CAAER,QAAQ,CAACS,KAAK,CAAC,EAAC;IAEhE,MAAMC,SAAS,GAAGd,IAAI,CAACe,KAAK,CAACC,GAAG,IAAI,CAACZ,QAAQ,CAACY,GAAG,CAACC,OAAO,IAAI,IAAI,EAAEN,EAAE,CAACO,MAAqB,CAAC,CAAC;IAC7F,IAAIJ,SAAS,IAAI,CAACX,QAAQ,EAAE;MAC1BF,QAAQ,CAACU,EAAE,CAAC;;EAEhB,CAAC,CAAC;EAEFf,KAAK,CAACuB,SAAS,CAAC,MAA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U,CAACpB,OAAO,CAAC;IAC/D,CAAC;EACH,CAAC,EAAE,CAACkB,cAAc,EAAEhC,QAAQ,EAAEiC,YAAY,CAAC,CAAC;AAC9C,CAAC"}
1
+ {"version":3,"names":["React","useEventCallback","useOnClickOutside","options","refs","callback","element","disabled","contains","containsProp","timeoutId","useRef","undefined","useIFrameFocus","listener","ev","parent","child","isOutside","every","ref","current","target","useEffect","currentEvent","getWindowEvent","window","conditionalHandler","event","addEventListener","setTimeout","removeEventListener","clearTimeout","ownerDocument","defaultView","FUI_FRAME_EVENT","targetDocument","pollDuration","timeoutRef","e","setInterval","activeElement","tagName","CustomEvent","bubbles","dispatchEvent"],"sources":["../../src/hooks/useOnClickOutside.ts"],"sourcesContent":["import * as React from 'react';\nimport { useEventCallback } from './useEventCallback';\n\n/**\n * @internal\n */\nexport type UseOnClickOrScrollOutsideOptions = {\n /**\n * The element to listen for the click event\n */\n element: Document | undefined;\n /**\n * Refs to elements that check if the click is outside\n */\n refs: React.MutableRefObject<HTMLElement | undefined | null>[];\n\n /**\n * By default uses element.contains, but custom contain function can be provided\n * @param parentRef - provided parent ref\n * @param child - event target element\n */\n contains?(parent: HTMLElement | null, child: HTMLElement): boolean;\n\n /**\n * Disables event listeners\n */\n disabled?: boolean;\n\n /**\n * Called if the click is outside the element refs\n */\n callback: (ev: MouseEvent | TouchEvent) => void;\n};\n\n/**\n * @internal\n * Utility to perform checks where a click/touch event was made outside a component\n */\nexport const useOnClickOutside = (options: UseOnClickOrScrollOutsideOptions) => {\n const { refs, callback, element, disabled, contains: containsProp } = options;\n const timeoutId = React.useRef<number | undefined>(undefined);\n useIFrameFocus(options);\n\n const listener = useEventCallback((ev: MouseEvent | TouchEvent) => {\n const contains: UseOnClickOrScrollOutsideOptions['contains'] =\n containsProp || ((parent, child) => !!parent?.contains(child));\n\n const isOutside = refs.every(ref => !contains(ref.current || null, ev.target as HTMLElement));\n if (isOutside && !disabled) {\n callback(ev);\n }\n });\n\n React.useEffect(() => {\n // Store the current event to avoid triggering handlers immediately\n // Note this depends on a deprecated but extremely well supported quirk of the web platform\n // https://github.com/facebook/react/issues/20074\n let currentEvent = getWindowEvent(window);\n\n const conditionalHandler = (event: MouseEvent | TouchEvent) => {\n // Skip if this event is the same as the one running when we added the handlers\n if (event === currentEvent) {\n currentEvent = undefined;\n return;\n }\n\n listener(event);\n };\n\n if (!disabled) {\n // use capture phase because React can update DOM before the event bubbles to the document\n element?.addEventListener('click', conditionalHandler, true);\n element?.addEventListener('touchstart', conditionalHandler, true);\n element?.addEventListener('contextmenu', conditionalHandler, true);\n }\n\n // Garbage collect this event after it's no longer useful to avoid memory leaks\n timeoutId.current = window.setTimeout(() => {\n currentEvent = undefined;\n }, 1);\n\n return () => {\n element?.removeEventListener('click', conditionalHandler, true);\n element?.removeEventListener('touchstart', conditionalHandler, true);\n element?.removeEventListener('contextmenu', conditionalHandler, true);\n\n clearTimeout(timeoutId.current);\n currentEvent = undefined;\n };\n }, [listener, element, disabled]);\n};\n\nconst getWindowEvent = (target: Node | Window): Event | undefined => {\n if (target) {\n if (typeof (target as Window).window === 'object' && (target as Window).window === target) {\n // eslint-disable-next-line deprecation/deprecation\n return target.event;\n }\n\n // eslint-disable-next-line deprecation/deprecation\n return (target as Node).ownerDocument?.defaultView?.event ?? undefined;\n }\n\n return undefined;\n};\n\nconst FUI_FRAME_EVENT = 'fuiframefocus';\n\ninterface UseIFrameFocusOptions extends UseOnClickOrScrollOutsideOptions {\n /**\n * Millisecond duration to poll\n */\n pollDuration?: number;\n}\n\n/**\n * Since click events do not propagate past iframes, we use focus to detect if a\n * click has happened inside an iframe, since the only ways of focusing inside an\n * iframe are:\n * - clicking inside\n * - tabbing inside\n *\n * Polls the value of `document.activeElement`. If it is an iframe, then dispatch\n * a custom DOM event. When the custom event is received call the provided callback\n */\nconst useIFrameFocus = (options: UseIFrameFocusOptions) => {\n const {\n disabled,\n element: targetDocument,\n callback,\n contains: containsProp = (parent, child) => !!parent?.contains(child),\n pollDuration = 1000,\n refs,\n } = options;\n const timeoutRef = React.useRef<number>();\n\n const listener = useEventCallback((e: Event) => {\n const contains = containsProp || ((parent, child) => !!parent?.contains(child));\n\n const isOutside = refs.every(ref => !contains(ref.current || null, e.target as HTMLElement));\n if (isOutside && !disabled) {\n callback(e as MouseEvent);\n }\n });\n\n // Adds listener to the custom iframe focus event\n React.useEffect(() => {\n if (!disabled) {\n targetDocument?.addEventListener(FUI_FRAME_EVENT, listener, true);\n return () => {\n targetDocument?.removeEventListener(FUI_FRAME_EVENT, listener, true);\n };\n }\n }, [targetDocument, disabled, listener]);\n\n // Starts polling for the active element\n React.useEffect(() => {\n if (!disabled) {\n timeoutRef.current = targetDocument?.defaultView?.setInterval(() => {\n const activeElement = targetDocument?.activeElement;\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"],"mappings":"AAAA,YAAYA,KAAA,MAAW;AACvB,SAASC,gBAAgB,QAAQ;AAiCjC;;;;AAIA,OAAO,MAAMC,iBAAA,GAAqBC,OAAA,IAA8C;EAC9E,MAAM;IAAEC,IAAA;IAAMC,QAAA;IAAUC,OAAA;IAASC,QAAA;IAAUC,QAAA,EAAUC;EAAY,CAAE,GAAGN,OAAA;EACtE,MAAMO,SAAA,GAAYV,KAAA,CAAMW,MAAM,CAAqBC,SAAA;EACnDC,cAAA,CAAeV,OAAA;EAEf,MAAMW,QAAA,GAAWb,gBAAA,CAAkBc,EAAA,IAAgC;IACjE,MAAMP,QAAA,GACJC,YAAA,KAAiB,CAACO,MAAA,EAAQC,KAAA,KAAU,CAAC,CAACD,MAAA,EAAQR,QAAA,CAASS,KAAA,CAAK;IAE9D,MAAMC,SAAA,GAAYd,IAAA,CAAKe,KAAK,CAACC,G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AAA,EAAgB7B,QAAA,EAAUO,QAAA,CAAS;EAEvC;EACAd,KAAA,CAAMuB,SAAS,CAAC,MAAM;IACpB,IAAI,CAAChB,QAAA,EAAU;MACb+B,UAAA,CAAWjB,OAAO,GAAGe,cAAA,EAAgBF,WAAA,EAAaM,WAAA,CAAY,MAAM;QAClE,MAAMC,aAAA,GAAgBL,cAAA,EAAgBK,aAAA;QACtC,IAAIA,aAAA,EAAeC,OAAA,KAAY,YAAYD,aAAA,EAAeC,OAAA,KAAY,WAAW;UAC/E,MAAMd,KAAA,GAAQ,IAAIe,WAAA,CAAYR,eAAA,EAAiB;YAAES,OAAA,EAAS;UAAK;UAC/DH,aAAA,CAAcI,aAAa,CAACjB,KAAA;QAC9B;MACF,GAAGS,YAAA;IACL;IACA,OAAO,MAAM;MACXD,cAAA,EAAgBF,WAAA,EAAaF,YAAA,CAAaM,UAAA,CAAWjB,OAAO;IAC9D;EACF,GAAG,CAACe,cAAA,EAAgB7B,QAAA,EAAU8B,YAAA,CAAa;AAC7C"}
@@ -1,5 +1,5 @@
1
- import * as React from 'react';
2
- import { useEventCallback } from './useEventCallback';
1
+ import * as React from "react";
2
+ import { useEventCallback } from "./useEventCallback";
3
3
  /**
4
4
  * @internal
5
5
  * Utility to perform checks where a click/touch event was made outside a component
@@ -13,7 +13,7 @@ export const useOnScrollOutside = options => {
13
13
  contains: containsProp
14
14
  } = options;
15
15
  const listener = useEventCallback(ev => {
16
- const contains = containsProp || ((parent, child) => !!(parent === null || parent === void 0 ? void 0 : parent.contains(child)));
16
+ const contains = containsProp || ((parent, child) => !!parent?.contains(child));
17
17
  const isOutside = refs.every(ref => !contains(ref.current || null, ev.target));
18
18
  if (isOutside && !disabled) {
19
19
  callback(ev);
@@ -21,12 +21,12 @@ export const useOnScrollOutside = options => {
21
21
  });
22
22
  React.useEffect(() => {
23
23
  if (!disabled) {
24
- element === null || element === void 0 ? void 0 : element.addEventListener('wheel', listener);
25
- element === null || element === void 0 ? void 0 : element.addEventListener('touchmove', listener);
24
+ element?.addEventListener("wheel", listener);
25
+ element?.addEventListener("touchmove", listener);
26
26
  }
27
27
  return () => {
28
- element === null || element === void 0 ? void 0 : element.removeEventListener('wheel', listener);
29
- element === null || element === void 0 ? void 0 : element.removeEventListener('touchmove', listener);
28
+ element?.removeEventListener("wheel", listener);
29
+ element?.removeEventListener("touchmove", listener);
30
30
  };
31
31
  }, [listener, element, disabled]);
32
32
  };
@@ -1 +1 @@
1
- {"version":3,"names":["React","useEventCallback","useOnScrollOutside","options","refs","callback","element","disabled","contains","containsProp","listener","ev","parent","child","isOutside","every","ref","current","target","useEffect","addEventListener","removeEventListener"],"sources":["../../../../../../../../packages/react-components/react-utilities/src/hooks/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 isOutside = refs.every(ref => !contains(ref.current || null, ev.target as HTMLElement));\n if (isOutside && !disabled) {\n callback(ev);\n }\n });\n\n React.useEffect(() => {\n if (!disabled) {\n element?.addEventListener('wheel', listener);\n element?.addEventListener('touchmove', listener);\n }\n\n return () => {\n element?.removeEventListener('wheel', listener);\n element?.removeEventListener('touchmove', listener);\n };\n }, [listener, element, disabled]);\n};\n"],"mappings":"AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,SAASC,gBAAgB,QAAQ,oBAAoB;AAGrD;;;;AAIA,OAAO,MAAMC,kBAAkB,GAAIC,OAAyC,IAAI;EAC9E,MAAM;IAAEC,IAAI;IAAEC,QAAQ;IAAEC,OAAO;IAAEC,QAAQ;IAAEC,QAAQ,EAAEC;EAAY,CAAE,GAAGN,OAAO;EAE7E,MAAMO,QAAQ,GAAGT,gBAAgB,CAAEU,EAA2B,IAAI;IAChE,MAAMH,QAAQ,GACZC,YAAY,KAAK,CAACG,MAAM,EAAEC,KAAK,KAAK,CAAC,EAACD,MAAM,aAANA,MAAM,uBAANA,MAAM,CAAEJ,QAAQ,CAACK,KAAK,CAAC,EAAC;IAEhE,MAAMC,SAAS,GAAGV,IAAI,CAACW,KAAK,CAACC,GAAG,IAAI,CAACR,QAAQ,CAACQ,GAAG,CAACC,OAAO,IAAI,IAAI,EAAEN,EAAE,CAACO,MAAqB,CAAC,CAAC;IAC7F,IAAIJ,SAAS,IAAI,CAACP,QAAQ,EAAE;MAC1BF,QAAQ,CAACM,EAAE,CAAC;;EAEhB,CAAC,CAAC;EAEFX,KAAK,CAACmB,SAAS,CAAC,MAAK;IACnB,IAAI,CAACZ,QAAQ,EAAE;MACbD,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEc,gBAAgB,CAAC,OAAO,EAAEV,QAAQ,CAAC;MAC5CJ,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEc,gBAAgB,CAAC,WAAW,EAAEV,QAAQ,CAAC;;IAGlD,OAAO,MAAK;MACVJ,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEe,mBAAmB,CAAC,OAAO,EAAEX,QAAQ,CAAC;MAC/CJ,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEe,mBAAmB,CAAC,WAAW,EAAEX,QAAQ,CAAC;IACrD,CAAC;EACH,CAAC,EAAE,CAACA,QAAQ,EAAEJ,OAAO,EAAEC,QAAQ,CAAC,CAAC;AACnC,CAAC"}
1
+ {"version":3,"names":["React","useEventCallback","useOnScrollOutside","options","refs","callback","element","disabled","contains","containsProp","listener","ev","parent","child","isOutside","every","ref","current","target","useEffect","addEventListener","removeEventListener"],"sources":["../../src/hooks/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 isOutside = refs.every(ref => !contains(ref.current || null, ev.target as HTMLElement));\n if (isOutside && !disabled) {\n callback(ev);\n }\n });\n\n React.useEffect(() => {\n if (!disabled) {\n element?.addEventListener('wheel', listener);\n element?.addEventListener('touchmove', listener);\n }\n\n return () => {\n element?.removeEventListener('wheel', listener);\n element?.removeEventListener('touchmove', listener);\n };\n }, [listener, element, disabled]);\n};\n"],"mappings":"AAAA,YAAYA,KAAA,MAAW;AACvB,SAASC,gBAAgB,QAAQ;AAGjC;;;;AAIA,OAAO,MAAMC,kBAAA,GAAsBC,OAAA,IAA8C;EAC/E,MAAM;IAAEC,IAAA;IAAMC,QAAA;IAAUC,OAAA;IAASC,QAAA;IAAUC,QAAA,EAAUC;EAAY,CAAE,GAAGN,OAAA;EAEtE,MAAMO,QAAA,GAAWT,gBAAA,CAAkBU,EAAA,IAAgC;IACjE,MAAMH,QAAA,GACJC,YAAA,KAAiB,CAACG,MAAA,EAAQC,KAAA,KAAU,CAAC,CAACD,MAAA,EAAQJ,QAAA,CAASK,KAAA,CAAK;IAE9D,MAAMC,SAAA,GAAYV,IAAA,CAAKW,KAAK,CAACC,GAAA,IAAO,CAACR,QAAA,CAASQ,GAAA,CAAIC,OAAO,IAAI,IAAI,EAAEN,EAAA,CAAGO,MAAM;IAC5E,IAAIJ,SAAA,IAAa,CAACP,QAAA,EAAU;MAC1BF,QAAA,CAASM,EAAA;IACX;EACF;EAEAX,KAAA,CAAMmB,SAAS,CAAC,MAAM;IACpB,IAAI,CAACZ,QAAA,EAAU;MACbD,OAAA,EAASc,gBAAA,CAAiB,SAASV,QAAA;MACnCJ,OAAA,EAASc,gBAAA,CAAiB,aAAaV,QAAA;IACzC;IAEA,OAAO,MAAM;MACXJ,OAAA,EAASe,mBAAA,CAAoB,SAASX,QAAA;MACtCJ,OAAA,EAASe,mBAAA,CAAoB,aAAaX,QAAA;IAC5C;EACF,GAAG,CAACA,QAAA,EAAUJ,OAAA,EAASC,QAAA,CAAS;AAClC"}
@@ -1,4 +1,4 @@
1
- import * as React from 'react';
1
+ import * as React from "react";
2
2
  /**
3
3
  * @internal
4
4
  */
@@ -1 +1 @@
1
- {"version":3,"names":["React","usePrevious","value","ref","useRef","useEffect","current"],"sources":["../../../../../../../../packages/react-components/react-utilities/src/hooks/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"],"mappings":"AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAE9B;;;AAGA,OAAO,MAAMC,WAAW,GAAyBC,KAAgB,IAAI;EACnE,MAAMC,GAAG,GAAGH,KAAK,CAACI,MAAM,CAAmB,IAAI,CAAC;EAChDJ,KAAK,CAACK,SAAS,CAAC,MAAK;IACnBF,GAAG,CAACG,OAAO,GAAGJ,KAAK;EACrB,CAAC,EAAE,CAACA,KAAK,CAAC,CAAC;EACX,OAAOC,GAAG,CAACG,OAAO;AACpB,CAAC"}
1
+ {"version":3,"names":["React","usePrevious","value","ref","useRef","useEffect","current"],"sources":["../../src/hooks/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"],"mappings":"AAAA,YAAYA,KAAA,MAAW;AAEvB;;;AAGA,OAAO,MAAMC,WAAA,GAAoCC,KAAA,IAAqB;EACpE,MAAMC,GAAA,GAAMH,KAAA,CAAMI,MAAM,CAAmB,IAAI;EAC/CJ,KAAA,CAAMK,SAAS,CAAC,MAAM;IACpBF,GAAA,CAAIG,OAAO,GAAGJ,KAAA;EAChB,GAAG,CAACA,KAAA,CAAM;EACV,OAAOC,GAAA,CAAIG,OAAO;AACpB"}
@@ -1,4 +1,4 @@
1
- import * as React from 'react';
1
+ import * as React from "react";
2
2
  const cache = /*#__PURE__*/new WeakMap();
3
3
  /**
4
4
  * @returns The width in pixels of the scrollbar in the user agent
@@ -15,10 +15,10 @@ export function useScrollbarWidth(options) {
15
15
  if (!force && cache.has(targetDocument)) {
16
16
  return cache.get(targetDocument);
17
17
  }
18
- const outer = targetDocument.createElement('div');
19
- outer.style.visibility = 'hidden';
20
- outer.style.overflow = 'scroll';
21
- const inner = targetDocument.createElement('div');
18
+ const outer = targetDocument.createElement("div");
19
+ outer.style.visibility = "hidden";
20
+ outer.style.overflow = "scroll";
21
+ const inner = targetDocument.createElement("div");
22
22
  outer.appendChild(inner);
23
23
  targetDocument.body.appendChild(outer);
24
24
  const scrollbarWidth = outer.offsetWidth - inner.offsetWidth;
@@ -1 +1 @@
1
- {"version":3,"names":["React","cache","WeakMap","useScrollbarWidth","options","targetDocument","force","useMemo","has","get","outer","createElement","style","visibility","overflow","inner","appendChild","body","scrollbarWidth","offsetWidth","remove","set"],"sources":["../../../../../../../../packages/react-components/react-utilities/src/hooks/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"],"mappings":"AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAE9B,MAAMC,KAAK,gBAAG,IAAIC,OAAO,EAAoB;AAc7C;;;AAGA,OAAM,SAAUC,iBAAiBA,CAACC,OAAiC;EACjE,MAAM;IAAEC,cAAc;IAAEC;EAAK,CAAE,GAAGF,OAAO;EACzC,OAAOJ,KAAK,CAACO,OAAO,CAAC,MAAK;IACxB,IAAI,CAACF,cAAc,EAAE;MACnB,OAAO,CAAC;;IAGV,IAAI,CAACC,KAAK,IAAIL,KAAK,CAACO,GAAG,CAACH,cAAc,CAAC,EAAE;MACvC,OAAOJ,KAAK,CAACQ,GAAG,CAACJ,cAAc,CAAC;;IAGlC,MAAMK,KAAK,GAAGL,cAAc,CAACM,aAAa,CAAC,KAAK,CAAC;IACjDD,KAAK,CAACE,KAAK,CAACC,UAAU,GAAG,QAAQ;IACjCH,KAAK,CAACE,KAAK,CAACE,QAAQ,GAAG,QAAQ;IAE/B,MAAMC,KAAK,GAAGV,cAAc,CAACM,aAAa,CAAC,KAAK,CAAC;IACjDD,KAAK,CAACM,WAAW,CAACD,KAAK,CAAC;IAExBV,cAAc,CAACY,IAAI,CAACD,WAAW,CAACN,KAAK,CAAC;IACtC,MAAMQ,cAAc,GAAGR,KAAK,CAACS,WAAW,GAAGJ,KAAK,CAACI,WAAW;IAC5DT,KAAK,CAACU,MAAM,EAAE;IACdnB,KAAK,CAACoB,GAAG,CAAChB,cAAc,EAAEa,cAAc,CAAC;IACzC,OAAOA,cAAc;EACvB,CAAC,EAAE,CAACb,cAAc,EAAEC,KAAK,CAAC,CAAC;AAC7B"}
1
+ {"version":3,"names":["React","cache","WeakMap","useScrollbarWidth","options","targetDocument","force","useMemo","has","get","outer","createElement","style","visibility","overflow","inner","appendChild","body","scrollbarWidth","offsetWidth","remove","set"],"sources":["../../src/hooks/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"],"mappings":"AAAA,YAAYA,KAAA,MAAW;AAEvB,MAAMC,KAAA,gBAAQ,IAAIC,OAAA;AAclB;;;AAGA,OAAO,SAASC,kBAAkBC,OAAiC,EAAE;EACnE,MAAM;IAAEC,cAAA;IAAgBC;EAAK,CAAE,GAAGF,OAAA;EAClC,OAAOJ,KAAA,CAAMO,OAAO,CAAC,MAAM;IACzB,IAAI,CAACF,cAAA,EAAgB;MACnB,OAAO;IACT;IAEA,IAAI,CAACC,KAAA,IAASL,KAAA,CAAMO,GAAG,CAACH,cAAA,GAAiB;MACvC,OAAOJ,KAAA,CAAMQ,GAAG,CAACJ,cAAA;IACnB;IAEA,MAAMK,KAAA,GAAQL,cAAA,CAAeM,aAAa,CAAC;IAC3CD,KAAA,CAAME,KAAK,CAACC,UAAU,GAAG;IACzBH,KAAA,CAAME,KAAK,CAACE,QAAQ,GAAG;IAEvB,MAAMC,KAAA,GAAQV,cAAA,CAAeM,aAAa,CAAC;IAC3CD,KAAA,CAAMM,WAAW,CAACD,KAAA;IAElBV,cAAA,CAAeY,IAAI,CAACD,WAAW,CAACN,KAAA;IAChC,MAAMQ,cAAA,GAAiBR,KAAA,CAAMS,WAAW,GAAGJ,KAAA,CAAMI,WAAW;IAC5DT,KAAA,CAAMU,MAAM;IACZnB,KAAA,CAAMoB,GAAG,CAAChB,cAAA,EAAgBa,cAAA;IAC1B,OAAOA,cAAA;EACT,GAAG,CAACb,cAAA,EAAgBC,KAAA,CAAM;AAC5B"}
@@ -1,4 +1,4 @@
1
- import * as React from 'react';
1
+ import * as React from "react";
2
2
  /**
3
3
  * @internal
4
4
  * Helper to manage a browser timeout.
@@ -1 +1 @@
1
- {"version":3,"names":["React","useTimeout","timeout","useState","id","undefined","set","fn","delay","clear","setTimeout","clearTimeout","useEffect"],"sources":["../../../../../../../../packages/react-components/react-utilities/src/hooks/useTimeout.ts"],"sourcesContent":["import * as React from 'react';\n\n/**\n * @internal\n * Helper to manage a browser timeout.\n * Ensures that the timeout isn't set multiple times at once,\n * and is cleaned up when the component is unloaded.\n *\n * @returns A pair of [setTimeout, clearTimeout] that are stable between renders.\n */\nexport function useTimeout() {\n const [timeout] = React.useState(() => ({\n id: undefined as ReturnType<typeof setTimeout> | undefined,\n set: (fn: () => void, delay: number) => {\n timeout.clear();\n timeout.id = setTimeout(fn, delay);\n },\n clear: () => {\n if (timeout.id !== undefined) {\n clearTimeout(timeout.id);\n timeout.id = undefined;\n }\n },\n }));\n\n // Clean up the timeout when the component is unloaded\n React.useEffect(() => timeout.clear, [timeout]);\n\n return [timeout.set, timeout.clear] as const;\n}\n"],"mappings":"AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAE9B;;;;;;;;AAQA,OAAM,SAAUC,UAAUA,CAAA;EACxB,MAAM,CAACC,OAAO,CAAC,GAAGF,KAAK,CAACG,QAAQ,CAAC,OAAO;IACtCC,EAAE,EAAEC,SAAsD;IAC1DC,GAAG,EAAEA,CAACC,EAAc,EAAEC,KAAa,KAAI;MACrCN,OAAO,CAACO,KAAK,EAAE;MACfP,OAAO,CAACE,EAAE,GAAGM,UAAU,CAACH,EAAE,EAAEC,KAAK,CAAC;IACpC,CAAC;IACDC,KAAK,EAAEA,CAAA,KAAK;MACV,IAAIP,OAAO,CAACE,EAAE,KAAKC,SAAS,EAAE;QAC5BM,YAAY,CAACT,OAAO,CAACE,EAAE,CAAC;QACxBF,OAAO,CAACE,EAAE,GAAGC,SAAS;;IAE1B;GACD,CAAC,CAAC;EAEH;EACAL,KAAK,CAACY,SAAS,CAAC,MAAMV,OAAO,CAACO,KAAK,EAAE,CAACP,OAAO,CAAC,CAAC;EAE/C,OAAO,CAACA,OAAO,CAACI,GAAG,EAAEJ,OAAO,CAACO,KAAK,CAAU;AAC9C"}
1
+ {"version":3,"names":["React","useTimeout","timeout","useState","id","undefined","set","fn","delay","clear","setTimeout","clearTimeout","useEffect"],"sources":["../../src/hooks/useTimeout.ts"],"sourcesContent":["import * as React from 'react';\n\n/**\n * @internal\n * Helper to manage a browser timeout.\n * Ensures that the timeout isn't set multiple times at once,\n * and is cleaned up when the component is unloaded.\n *\n * @returns A pair of [setTimeout, clearTimeout] that are stable between renders.\n */\nexport function useTimeout() {\n const [timeout] = React.useState(() => ({\n id: undefined as ReturnType<typeof setTimeout> | undefined,\n set: (fn: () => void, delay: number) => {\n timeout.clear();\n timeout.id = setTimeout(fn, delay);\n },\n clear: () => {\n if (timeout.id !== undefined) {\n clearTimeout(timeout.id);\n timeout.id = undefined;\n }\n },\n }));\n\n // Clean up the timeout when the component is unloaded\n React.useEffect(() => timeout.clear, [timeout]);\n\n return [timeout.set, timeout.clear] as const;\n}\n"],"mappings":"AAAA,YAAYA,KAAA,MAAW;AAEvB;;;;;;;;AAQA,OAAO,SAASC,WAAA,EAAa;EAC3B,MAAM,CAACC,OAAA,CAAQ,GAAGF,KAAA,CAAMG,QAAQ,CAAC,OAAO;IACtCC,EAAA,EAAIC,SAAA;IACJC,GAAA,EAAKA,CAACC,EAAA,EAAgBC,KAAA,KAAkB;MACtCN,OAAA,CAAQO,KAAK;MACbP,OAAA,CAAQE,EAAE,GAAGM,UAAA,CAAWH,EAAA,EAAIC,KAAA;IAC9B;IACAC,KAAA,EAAOA,CAAA,KAAM;MACX,IAAIP,OAAA,CAAQE,EAAE,KAAKC,SAAA,EAAW;QAC5BM,YAAA,CAAaT,OAAA,CAAQE,EAAE;QACvBF,OAAA,CAAQE,EAAE,GAAGC,SAAA;MACf;IACF;EACF;EAEA;EACAL,KAAA,CAAMY,SAAS,CAAC,MAAMV,OAAA,CAAQO,KAAK,EAAE,CAACP,OAAA,CAAQ;EAE9C,OAAO,CAACA,OAAA,CAAQI,GAAG,EAAEJ,OAAA,CAAQO,KAAK,CAAC;AACrC"}
package/lib/index.js CHANGED
@@ -1,7 +1,7 @@
1
- export { getSlots, resolveShorthand, isResolvedShorthand } from './compose/index';
2
- export { IdPrefixProvider, resetIdsForTests, useControllableState, useEventCallback, useFirstMount, useForceUpdate, useId, useIsomorphicLayoutEffect, useMergedRefs, useOnClickOutside, useOnScrollOutside, usePrevious, useScrollbarWidth, useTimeout } from './hooks/index';
3
- export { canUseDOM, useIsSSR, SSRProvider } from './ssr/index';
4
- export { clamp, getNativeElementProps, getPartitionedNativeProps, getRTLSafeKey, mergeCallbacks, isHTMLElement, isInteractiveHTMLElement, omit } from './utils/index';
5
- export { applyTriggerPropsToChildren, getTriggerChild, isFluentTrigger } from './trigger/index';
6
- export { isTouchEvent, isMouseEvent, getEventClientCoords } from './events/index';
1
+ export { getSlots, resolveShorthand, isResolvedShorthand } from "./compose/index";
2
+ export { IdPrefixProvider, resetIdsForTests, useControllableState, useEventCallback, useFirstMount, useForceUpdate, useId, useIsomorphicLayoutEffect, useMergedRefs, useOnClickOutside, useOnScrollOutside, usePrevious, useScrollbarWidth, useTimeout } from "./hooks/index";
3
+ export { canUseDOM, useIsSSR, SSRProvider } from "./ssr/index";
4
+ export { clamp, getNativeElementProps, getPartitionedNativeProps, getRTLSafeKey, mergeCallbacks, isHTMLElement, isInteractiveHTMLElement, omit } from "./utils/index";
5
+ export { applyTriggerPropsToChildren, getTriggerChild, isFluentTrigger } from "./trigger/index";
6
+ export { isTouchEvent, isMouseEvent, getEventClientCoords } from "./events/index";
7
7
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["getSlots","resolveShorthand","isResolvedShorthand","IdPrefixProvider","resetIdsForTests","useControllableState","useEventCallback","useFirstMount","useForceUpdate","useId","useIsomorphicLayoutEffect","useMergedRefs","useOnClickOutside","useOnScrollOutside","usePrevious","useScrollbarWidth","useTimeout","canUseDOM","useIsSSR","SSRProvider","clamp","getNativeElementProps","getPartitionedNativeProps","getRTLSafeKey","mergeCallbacks","isHTMLElement","isInteractiveHTMLElement","omit","applyTriggerPropsToChildren","getTriggerChild","isFluentTrigger","isTouchEvent","isMouseEvent","getEventClientCoords"],"sources":["../../../../../../../packages/react-components/react-utilities/src/index.ts"],"sourcesContent":["export { getSlots, resolveShorthand, isResolvedShorthand } from './compose/index';\nexport type {\n ExtractSlotProps,\n ComponentProps,\n ComponentState,\n ForwardRefComponent,\n ResolveShorthandFunction,\n ResolveShorthandOptions,\n Slot,\n Slots,\n SlotClassNames,\n SlotPropsRecord,\n SlotRenderFunction,\n SlotShorthandValue,\n} from './compose/index';\n\nexport {\n IdPrefixProvider,\n resetIdsForTests,\n useControllableState,\n useEventCallback,\n useFirstMount,\n useForceUpdate,\n useId,\n useIsomorphicLayoutEffect,\n useMergedRefs,\n useOnClickOutside,\n useOnScrollOutside,\n usePrevious,\n useScrollbarWidth,\n useTimeout,\n} from './hooks/index';\nexport type { RefObjectFunction, UseControllableStateOptions, UseOnClickOrScrollOutsideOptions } from './hooks/index';\n\nexport { canUseDOM, useIsSSR, SSRProvider } from './ssr/index';\n\nexport {\n clamp,\n getNativeElementProps,\n getPartitionedNativeProps,\n getRTLSafeKey,\n mergeCallbacks,\n isHTMLElement,\n isInteractiveHTMLElement,\n omit,\n} from './utils/index';\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"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,gBAAgB,EAAEC,mBAAmB,QAAQ,iBAAiB;AAgBjF,SACEC,gBAAgB,EAChBC,gBAAgB,EAChBC,oBAAoB,EACpBC,gBAAgB,EAChBC,aAAa,EACbC,cAAc,EACdC,KAAK,EACLC,yBAAyB,EACzBC,aAAa,EACbC,iBAAiB,EACjBC,kBAAkB,EAClBC,WAAW,EACXC,iBAAiB,EACjBC,UAAU,QACL,eAAe;AAGtB,SAASC,SAAS,EAAEC,QAAQ,EAAEC,WAAW,QAAQ,aAAa;AAE9D,SACEC,KAAK,EACLC,qBAAqB,EACrBC,yBAAyB,EACzBC,aAAa,EACbC,cAAc,EACdC,aAAa,EACbC,wBAAwB,EACxBC,IAAI,QACC,eAAe;AAEtB,SAASC,2BAA2B,EAAEC,eAAe,EAAEC,eAAe,QAAQ,iBAAiB;AAQ/F,SAASC,YAAY,EAAEC,YAAY,EAAEC,oBAAoB,QAAQ,gBAAgB"}
1
+ {"version":3,"names":["getSlots","resolveShorthand","isResolvedShorthand","IdPrefixProvider","resetIdsForTests","useControllableState","useEventCallback","useFirstMount","useForceUpdate","useId","useIsomorphicLayoutEffect","useMergedRefs","useOnClickOutside","useOnScrollOutside","usePrevious","useScrollbarWidth","useTimeout","canUseDOM","useIsSSR","SSRProvider","clamp","getNativeElementProps","getPartitionedNativeProps","getRTLSafeKey","mergeCallbacks","isHTMLElement","isInteractiveHTMLElement","omit","applyTriggerPropsToChildren","getTriggerChild","isFluentTrigger","isTouchEvent","isMouseEvent","getEventClientCoords"],"sources":["../src/index.ts"],"sourcesContent":["export { getSlots, resolveShorthand, isResolvedShorthand } from './compose/index';\nexport type {\n ExtractSlotProps,\n ComponentProps,\n ComponentState,\n ForwardRefComponent,\n ResolveShorthandFunction,\n ResolveShorthandOptions,\n Slot,\n Slots,\n SlotClassNames,\n SlotPropsRecord,\n SlotRenderFunction,\n SlotShorthandValue,\n} from './compose/index';\n\nexport {\n IdPrefixProvider,\n resetIdsForTests,\n useControllableState,\n useEventCallback,\n useFirstMount,\n useForceUpdate,\n useId,\n useIsomorphicLayoutEffect,\n useMergedRefs,\n useOnClickOutside,\n useOnScrollOutside,\n usePrevious,\n useScrollbarWidth,\n useTimeout,\n} from './hooks/index';\nexport type { RefObjectFunction, UseControllableStateOptions, UseOnClickOrScrollOutsideOptions } from './hooks/index';\n\nexport { canUseDOM, useIsSSR, SSRProvider } from './ssr/index';\n\nexport {\n clamp,\n getNativeElementProps,\n getPartitionedNativeProps,\n getRTLSafeKey,\n mergeCallbacks,\n isHTMLElement,\n isInteractiveHTMLElement,\n omit,\n} from './utils/index';\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"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,gBAAgB,EAAEC,mBAAmB,QAAQ;AAgBhE,SACEC,gBAAgB,EAChBC,gBAAgB,EAChBC,oBAAoB,EACpBC,gBAAgB,EAChBC,aAAa,EACbC,cAAc,EACdC,KAAK,EACLC,yBAAyB,EACzBC,aAAa,EACbC,iBAAiB,EACjBC,kBAAkB,EAClBC,WAAW,EACXC,iBAAiB,EACjBC,UAAU,QACL;AAGP,SAASC,SAAS,EAAEC,QAAQ,EAAEC,WAAW,QAAQ;AAEjD,SACEC,KAAK,EACLC,qBAAqB,EACrBC,yBAAyB,EACzBC,aAAa,EACbC,cAAc,EACdC,aAAa,EACbC,wBAAwB,EACxBC,IAAI,QACC;AAEP,SAASC,2BAA2B,EAAEC,eAAe,EAAEC,eAAe,QAAQ;AAQ9E,SAASC,YAAY,EAAEC,YAAY,EAAEC,oBAAoB,QAAQ"}
@@ -1,5 +1,5 @@
1
- import * as React from 'react';
2
- import { canUseDOM } from './canUseDOM';
1
+ import * as React from "react";
2
+ import { canUseDOM } from "./canUseDOM";
3
3
  /**
4
4
  * Default context value to use in case there is no SSRProvider. This is fine for client-only apps.
5
5
  *
@@ -13,8 +13,7 @@ export const SSRContext = /*#__PURE__*/React.createContext(undefined);
13
13
  * @internal
14
14
  */
15
15
  export function useSSRContext() {
16
- var _a;
17
- return (_a = React.useContext(SSRContext)) !== null && _a !== void 0 ? _a : defaultSSRContextValue;
16
+ return React.useContext(SSRContext) ?? defaultSSRContextValue;
18
17
  }
19
18
  /**
20
19
  * When using SSR with Fluent UI, applications must be wrapped in an SSRProvider. This ensures that auto generated ids
@@ -39,10 +38,10 @@ export function useIsSSR() {
39
38
  const [isSSR, setIsSSR] = React.useState(isInSSRContext);
40
39
  // If we are rendering in a non-DOM environment, and there's no SSRProvider, provide a warning to hint to the
41
40
  // developer to add one.
42
- if (process.env.NODE_ENV !== 'production') {
41
+ if (process.env.NODE_ENV !== "production") {
43
42
  if (!isInSSRContext && !canUseDOM()) {
44
43
  // eslint-disable-next-line no-console
45
- console.error(['@fluentui/react-components: ', 'When server rendering, you must wrap your application in an <SSRProvider> to ensure consistent ids are ' + 'generated between the client and server.', '\n', '\n', 'Check documentation at https://aka.ms/fluentui-ssr'].join(''));
44
+ console.error(["@fluentui/react-components: ", "When server rendering, you must wrap your application in an <SSRProvider> to ensure consistent ids are " + "generated between the client and server.", "\n", "\n", "Check documentation at https://aka.ms/fluentui-ssr"].join(""));
46
45
  }
47
46
  }
48
47
  // If on the client, and the component was initially server rendered, then schedule a layout effect to update the
@@ -1 +1 @@
1
- {"version":3,"names":["React","canUseDOM","defaultSSRContextValue","current","SSRContext","createContext","undefined","useSSRContext","_a","useContext","SSRProvider","props","value","useState","createElement","Provider","children","useIsSSR","isInSSRContext","isSSR","setIsSSR","process","env","NODE_ENV","console","error","join","useLayoutEffect"],"sources":["../../../../../../../../packages/react-components/react-utilities/src/ssr/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(\n [\n '@fluentui/react-components: ',\n 'When server rendering, you must wrap your application in an <SSRProvider> to ensure consistent ids are ' +\n 'generated between the client and server.',\n '\\n',\n '\\n',\n 'Check documentation at https://aka.ms/fluentui-ssr',\n ].join(''),\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"],"mappings":"AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,SAASC,SAAS,QAAQ,aAAa;AAYvC;;;;;AAKA,OAAO,MAAMC,sBAAsB,GAAoB;EACrDC,OAAO,EAAE;CACV;AAED,OAAO,MAAMC,UAAU,gBAAGJ,KAAK,CAACK,aAAa,CAA8BC,SAAS,CAAmC;AAEvH;;;AAGA,OAAM,SAAUC,aAAaA,CAAA;;EAC3B,OAAO,CAAAC,EAAA,GAAAR,KAAK,CAACS,UAAU,CAACL,UAAU,CAAC,cAAAI,EAAA,cAAAA,EAAA,GAAIN,sBAAsB;AAC/D;AAEA;;;;;;AAMA,OAAO,MAAMQ,WAAW,GAA4CC,KAAK,IAAG;EAC1E,MAAM,CAACC,KAAK,CAAC,GAAGZ,KAAK,CAACa,QAAQ,CAAkB,OAAO;IAAEV,OAAO,EAAE;EAAC,CAAE,CAAC,CAAC;EAEvE,oBAAOH,KAAA,CAAAc,aAAA,CAACV,UAAU,CAACW,QAAQ;IAACH,KAAK,EAAEA;EAAK,GAAGD,KAAK,CAACK,QAAQ,CAAuB;AAClF,CAAC;AAED;;;;AAIA,OAAM,SAAUC,QAAQA,CAAA;EACtB,MAAMC,cAAc,GAAGX,aAAa,EAAE,KAAKL,sBAAsB;EACjE,MAAM,CAACiB,KAAK,EAAEC,QAAQ,CAAC,GAAGpB,KAAK,CAACa,QAAQ,CAACK,cAAc,CAAC;EAExD;EACA;EACA,IAAIG,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,EAAE;IACzC,IAAI,CAACL,cAAc,IAAI,CAACjB,SAAS,EAAE,EAAE;MACnC;MACAuB,OAAO,CAACC,KAAK,CACX,CACE,8BAA8B,EAC9B,yGAAyG,GACvG,0CAA0C,EAC5C,IAAI,EACJ,IAAI,EACJ,oDAAoD,CACrD,CAACC,IAAI,CAAC,EAAE,CAAC,CACX;;;EAIL;EACA;EACA,IAAIzB,SAAS,EAAE,IAAIiB,cAAc,EAAE;IACjC;IACA;IACA;IACAlB,KAAK,CAAC2B,eAAe,CAAC,MAAK;MACzBP,QAAQ,CAAC,KAAK,CAAC;IACjB,CAAC,EAAE,EAAE,CAAC;;EAGR,OAAOD,KAAK;AACd"}
1
+ {"version":3,"names":["React","canUseDOM","defaultSSRContextValue","current","SSRContext","createContext","undefined","useSSRContext","useContext","SSRProvider","props","value","useState","createElement","Provider","children","useIsSSR","isInSSRContext","isSSR","setIsSSR","process","env","NODE_ENV","console","error","join","useLayoutEffect"],"sources":["../../src/ssr/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(\n [\n '@fluentui/react-components: ',\n 'When server rendering, you must wrap your application in an <SSRProvider> to ensure consistent ids are ' +\n 'generated between the client and server.',\n '\\n',\n '\\n',\n 'Check documentation at https://aka.ms/fluentui-ssr',\n ].join(''),\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"],"mappings":"AAAA,YAAYA,KAAA,MAAW;AACvB,SAASC,SAAS,QAAQ;AAY1B;;;;;AAKA,OAAO,MAAMC,sBAAA,GAA0C;EACrDC,OAAA,EAAS;AACX;AAEA,OAAO,MAAMC,UAAA,gBAAaJ,KAAA,CAAMK,aAAa,CAA8BC,SAAA;AAE3E;;;AAGA,OAAO,SAASC,cAAA,EAAiC;EAC/C,OAAOP,KAAA,CAAMQ,UAAU,CAACJ,UAAA,KAAeF,sBAAA;AACzC;AAEA;;;;;;AAMA,OAAO,MAAMO,WAAA,GAAuDC,KAAA,IAAS;EAC3E,MAAM,CAACC,KAAA,CAAM,GAAGX,KAAA,CAAMY,QAAQ,CAAkB,OAAO;IAAET,OAAA,EAAS;EAAE;EAEpE,oBAAOH,KAAA,CAAAa,aAAA,CAACT,UAAA,CAAWU,QAAQ;IAACH,KAAA,EAAOA;KAAQD,KAAA,CAAMK,QAAQ;AAC3D;AAEA;;;;AAIA,OAAO,SAASC,SAAA,EAAoB;EAClC,MAAMC,cAAA,GAAiBV,aAAA,OAAoBL,sBAAA;EAC3C,MAAM,CAACgB,KAAA,EAAOC,QAAA,CAAS,GAAGnB,KAAA,CAAMY,QAAQ,CAACK,cAAA;EAEzC;EACA;EACA,IAAIG,OAAA,CAAQC,GAAG,CAACC,QAAQ,KAAK,cAAc;IACzC,IAAI,CAACL,cAAA,IAAkB,CAAChB,SAAA,IAAa;MACnC;MACAsB,OAAA,CAAQC,KAAK,CACX,CACE,gCACA,4GACE,4CACF,MACA,MACA,qDACD,CAACC,IAAI,CAAC;IAEX;EACF;EAEA;EACA;EACA,IAAIxB,SAAA,MAAegB,cAAA,EAAgB;IACjC;IACA;IACA;IACAjB,KAAA,CAAM0B,eAAe,CAAC,MAAM;MAC1BP,QAAA,CAAS,KAAK;IAChB,GAAG,EAAE;EACP;EAEA,OAAOD,KAAA;AACT"}
@@ -1,8 +1,7 @@
1
1
  /**
2
2
  * Verifies if an application can use DOM.
3
- */
4
- export function canUseDOM() {
5
- return typeof window !== 'undefined' && !!(window.document &&
3
+ */export function canUseDOM() {
4
+ return typeof window !== "undefined" && !!(window.document &&
6
5
  // eslint-disable-next-line deprecation/deprecation
7
6
  window.document.createElement);
8
7
  }
@@ -1 +1 @@
1
- {"version":3,"names":["canUseDOM","window","document","createElement"],"sources":["../../../../../../../../packages/react-components/react-utilities/src/ssr/canUseDOM.ts"],"sourcesContent":["/**\n * Verifies if an application can use DOM.\n */\nexport function canUseDOM(): boolean {\n return (\n typeof window !== 'undefined' &&\n !!(\n window.document &&\n // eslint-disable-next-line deprecation/deprecation\n window.document.createElement\n )\n );\n}\n"],"mappings":"AAAA;;;AAGA,OAAM,SAAUA,SAASA,CAAA;EACvB,OACE,OAAOC,MAAM,KAAK,WAAW,IAC7B,CAAC,EACCA,MAAM,CAACC,QAAQ;EACf;EACAD,MAAM,CAACC,QAAQ,CAACC,aAAa,CAC9B;AAEL"}
1
+ {"version":3,"names":["canUseDOM","window","document","createElement"],"sources":["../../src/ssr/canUseDOM.ts"],"sourcesContent":["/**\n * Verifies if an application can use DOM.\n */\nexport function canUseDOM(): boolean {\n return (\n typeof window !== 'undefined' &&\n !!(\n window.document &&\n // eslint-disable-next-line deprecation/deprecation\n window.document.createElement\n )\n );\n}\n"],"mappings":"AAAA;;GAGA,OAAO,SAASA,UAAA,EAAqB;EACnC,OACE,OAAOC,MAAA,KAAW,eAClB,CAAC,EACCA,MAAA,CAAOC,QAAQ;EACf;EACAD,MAAA,CAAOC,QAAQ,CAACC,aAAa,CAAD;AAGlC"}
package/lib/ssr/index.js CHANGED
@@ -1,3 +1,3 @@
1
- export * from './canUseDOM';
2
- export * from './SSRContext';
1
+ export * from "./canUseDOM";
2
+ export * from "./SSRContext";
3
3
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../packages/react-components/react-utilities/src/ssr/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC","sourcesContent":["export * from './canUseDOM';\nexport * from './SSRContext';\n"]}
1
+ {"version":3,"names":[],"sources":["../../src/ssr/index.ts"],"sourcesContent":["export * from './canUseDOM';\nexport * from './SSRContext';\n"],"mappings":"AAAA,cAAc;AACd,cAAc"}