@helsenorge/designsystem-react 15.7.1 → 16.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (230) hide show
  1. package/lib/Button.js +2 -2
  2. package/lib/Button.js.map +1 -1
  3. package/lib/CHANGELOG.md +2657 -996
  4. package/lib/Close.js +1 -1
  5. package/lib/Close.js.map +1 -1
  6. package/lib/Drawer.js +2 -4
  7. package/lib/Drawer.js.map +1 -1
  8. package/lib/DrawerNavigation.js +1 -0
  9. package/lib/DrawerNavigation.js.map +1 -1
  10. package/lib/Duolist.js +5 -1
  11. package/lib/Duolist.js.map +1 -1
  12. package/lib/ElementHeader.js.map +1 -1
  13. package/lib/FilterLinkList.js +1 -1
  14. package/lib/FilterLinkList.js.map +1 -1
  15. package/lib/FormGroup.js +3 -3
  16. package/lib/FormGroup.js.map +1 -1
  17. package/lib/HelpDetails.js +1 -1
  18. package/lib/HelpTriggerIcon.js +2 -2
  19. package/lib/HelpTriggerIcon.js.map +1 -1
  20. package/lib/HelpTriggerStandalone.js +1 -1
  21. package/lib/HelpTriggerStandalone.js.map +1 -1
  22. package/lib/LazyIcon.js +1 -0
  23. package/lib/LazyIcon.js.map +1 -1
  24. package/lib/LazyIllustration.js +2 -0
  25. package/lib/LazyIllustration.js.map +1 -1
  26. package/lib/LinkList.js +10 -10
  27. package/lib/LinkList.js.map +1 -1
  28. package/lib/ListEditMode.js +1 -1
  29. package/lib/ListEditMode.js.map +1 -1
  30. package/lib/PopOver.js +2 -2
  31. package/lib/PopOver.js.map +1 -1
  32. package/lib/Radio.js +65 -55
  33. package/lib/Radio.js.map +1 -1
  34. package/lib/Radio2.js +74 -0
  35. package/lib/Radio2.js.map +1 -0
  36. package/lib/RadioMarker.js +2 -2
  37. package/lib/RadioMarker.js.map +1 -1
  38. package/lib/TabList.js +5 -5
  39. package/lib/TabList.js.map +1 -1
  40. package/lib/Toggle.js +2 -2
  41. package/lib/Toggle.js.map +1 -1
  42. package/lib/VisualRadio.js +1 -1
  43. package/lib/VisualRadio.js.map +1 -1
  44. package/lib/components/AnchorLink/styles.module.scss +3 -4
  45. package/lib/components/ArticleTeaser/styles.module.scss +12 -12
  46. package/lib/components/Button/Button.d.ts +1 -1
  47. package/lib/components/Button/styles.module.scss +111 -60
  48. package/lib/components/Button/styles.module.scss.d.ts +1 -1
  49. package/lib/components/Checkbox/CheckboxMarker/styles.module.scss +6 -6
  50. package/lib/components/Chip/styles.module.scss +2 -3
  51. package/lib/components/Close/styles.module.scss +2 -3
  52. package/lib/components/DictionaryTrigger/index.js +26 -1
  53. package/lib/{DictionaryTrigger.js.map → components/DictionaryTrigger/index.js.map} +1 -1
  54. package/lib/components/DictionaryTrigger/styles.module.scss +6 -8
  55. package/lib/components/Drawer/Drawer.d.ts +0 -4
  56. package/lib/components/Drawer/DrawerBackButton.module.scss +1 -2
  57. package/lib/components/Drawer/styles.module.scss +6 -3
  58. package/lib/components/Dropdown/SingleSelect/styles.module.scss +0 -2
  59. package/lib/components/Dropdown/index.js +9 -17
  60. package/lib/components/Dropdown/index.js.map +1 -1
  61. package/lib/components/Dropdown/styles.module.scss +12 -14
  62. package/lib/components/Duolist/Duolist.d.ts +14 -2
  63. package/lib/components/Duolist/styles.module.scss +32 -8
  64. package/lib/components/Duolist/styles.module.scss.d.ts +3 -0
  65. package/lib/components/ElementHeader/ElementHeader.d.ts +1 -1
  66. package/lib/components/ElementHeader/styles.module.scss +1 -1
  67. package/lib/components/EmptyState/styles.module.scss +1 -2
  68. package/lib/components/ErrorWrapper/styles.module.scss +3 -3
  69. package/lib/components/Expander/styles.module.scss +0 -2
  70. package/lib/components/Expander/styles.module.scss.d.ts +1 -1
  71. package/lib/components/ExpanderList/index.js +20 -19
  72. package/lib/components/ExpanderList/index.js.map +1 -1
  73. package/lib/components/ExpanderList/styles.module.scss +10 -11
  74. package/lib/components/FavoriteButton/index.js +3 -3
  75. package/lib/components/FavoriteButton/index.js.map +1 -1
  76. package/lib/components/FavoriteButton/styles.module.scss +0 -1
  77. package/lib/components/Filter/FilterButton/styles.module.scss +5 -6
  78. package/lib/components/Filter/FilterButtonAndChipsWrapper/styles.module.scss +0 -1
  79. package/lib/components/Filter/FilterDrawer/styles.module.scss +0 -1
  80. package/lib/components/Filter/FilterLinkList/FilterLinkList.module.scss +5 -6
  81. package/lib/components/Filter/FilterOverviewSearch/styles.module.scss +1 -4
  82. package/lib/components/Filter/FilterSearch/styles.module.scss +14 -15
  83. package/lib/components/Filter/FilterSort/styles.module.scss +1 -2
  84. package/lib/components/Filter/FilterStateWrapper/styles.module.scss +0 -2
  85. package/lib/components/Filter/LoaderSpinner/styles.module.scss +2 -4
  86. package/lib/components/FormFieldTag/styles.module.scss +0 -1
  87. package/lib/components/FormGroup/styles.module.scss +0 -1
  88. package/lib/components/HelpBubble/styles.module.scss +0 -1
  89. package/lib/components/HelpDetails/styles.module.scss +2 -4
  90. package/lib/components/HelpDrawer/styles.module.scss +1 -2
  91. package/lib/components/HelpPanel/HelpPanel.d.ts +2 -2
  92. package/lib/components/HelpPanel/index.js +1 -17
  93. package/lib/components/HelpPanel/index.js.map +1 -1
  94. package/lib/components/HelpPanel/styles.module.scss +2 -22
  95. package/lib/components/HelpPanel/styles.module.scss.d.ts +0 -4
  96. package/lib/components/HelpTeaser/styles.module.scss +7 -9
  97. package/lib/components/HelpTriggerIcon/HelpTriggerIcon.d.ts +2 -2
  98. package/lib/components/HelpTriggerIcon/styles.module.scss +20 -22
  99. package/lib/components/HelpTriggerIcon/styles.module.scss.d.ts +1 -1
  100. package/lib/components/HelpTriggerInline/styles.module.scss +3 -5
  101. package/lib/components/HelpTriggerStandalone/styles.module.scss +3 -5
  102. package/lib/components/HighlightPanel/styles.module.scss +2 -3
  103. package/lib/components/Icons/AdditionalIconInformation.d.ts +4 -0
  104. package/lib/components/Icons/AdditionalIconInformation.js +14 -10
  105. package/lib/components/Icons/AdditionalIconInformation.js.map +1 -1
  106. package/lib/components/Icons/HealthcarePersonnelSecurity.js +4 -4
  107. package/lib/components/Icons/HealthcarePersonnelSecurity.js.map +1 -1
  108. package/lib/components/Icons/HistoryDocument.js +6 -7
  109. package/lib/components/Icons/HistoryDocument.js.map +1 -1
  110. package/lib/components/Icons/IconNames.d.ts +1 -1
  111. package/lib/components/Icons/IconNames.js +1 -0
  112. package/lib/components/Icons/IconNames.js.map +1 -1
  113. package/lib/components/Icons/YesNo.d.ts +3 -0
  114. package/lib/components/Icons/YesNo.js +53 -0
  115. package/lib/components/Icons/YesNo.js.map +1 -0
  116. package/lib/components/Illustrations/IllustrationNames.d.ts +1 -1
  117. package/lib/components/Illustrations/IllustrationNames.js +2 -0
  118. package/lib/components/Illustrations/IllustrationNames.js.map +1 -1
  119. package/lib/components/Illustrations/MoveAway.d.ts +11 -0
  120. package/lib/components/Illustrations/MoveAway.js +18 -0
  121. package/lib/components/Illustrations/MoveAway.js.map +1 -0
  122. package/lib/components/Illustrations/MoveAwayMedium.d.ts +3 -0
  123. package/lib/components/Illustrations/MoveAwayMedium.js +114 -0
  124. package/lib/components/Illustrations/MoveAwayMedium.js.map +1 -0
  125. package/lib/components/InfoTeaser/styles.module.scss +6 -8
  126. package/lib/components/Label/styles.module.scss +1 -1
  127. package/lib/components/LinkList/LinkList.d.ts +1 -1
  128. package/lib/components/LinkList/styles.module.scss +9 -11
  129. package/lib/components/LinkList/styles.module.scss.d.ts +1 -1
  130. package/lib/components/ListEditMode/styles.module.scss +5 -7
  131. package/lib/components/Loader/Loader.d.ts +1 -1
  132. package/lib/components/Loader/index.js +4 -4
  133. package/lib/components/Loader/index.js.map +1 -1
  134. package/lib/components/Loader/styles.module.scss +7 -7
  135. package/lib/components/Loader/styles.module.scss.d.ts +3 -3
  136. package/lib/components/Modal/constants.d.ts +1 -1
  137. package/lib/components/Modal/index.js +2 -2
  138. package/lib/components/Modal/index.js.map +1 -1
  139. package/lib/components/Modal/styles.module.scss +14 -19
  140. package/lib/components/Modal/styles.module.scss.d.ts +2 -3
  141. package/lib/components/Panel/index.js +1 -1
  142. package/lib/components/Panel/index.js.map +1 -1
  143. package/lib/components/Panel/styles.module.scss +15 -16
  144. package/lib/components/Panel/styles.module.scss.d.ts +1 -1
  145. package/lib/components/PopMenu/index.js +7 -4
  146. package/lib/components/PopMenu/index.js.map +1 -1
  147. package/lib/components/PopOver/styles.module.scss +1 -3
  148. package/lib/components/Progressbar/Progressbar.d.ts +1 -1
  149. package/lib/components/Progressbar/constants.d.ts +1 -1
  150. package/lib/components/Progressbar/index.js +4 -4
  151. package/lib/components/Progressbar/index.js.map +1 -1
  152. package/lib/components/Radio/Radio.d.ts +28 -0
  153. package/lib/components/Radio/index.d.ts +3 -0
  154. package/lib/components/Radio/index.js +7 -0
  155. package/lib/components/Radio/index.js.map +1 -0
  156. package/lib/components/{RadioButton → Radio}/styles.module.scss +8 -9
  157. package/lib/components/Radio/styles.module.scss.d.ts +26 -0
  158. package/lib/components/ServiceMessage/styles.module.scss +20 -22
  159. package/lib/components/Slider/styles.module.scss +1 -2
  160. package/lib/components/StatusDot/styles.module.scss +4 -5
  161. package/lib/components/StickyNote/index.js +2 -2
  162. package/lib/components/StickyNote/index.js.map +1 -1
  163. package/lib/components/StickyNote/styles.module.scss +9 -10
  164. package/lib/components/Tabs/TabList/styles.module.scss +20 -18
  165. package/lib/components/Tabs/TabPanel/styles.module.scss +2 -3
  166. package/lib/components/Tabs/styles.module.scss +0 -1
  167. package/lib/components/Tag/styles.module.scss +0 -1
  168. package/lib/components/Tile/styles.module.scss +5 -7
  169. package/lib/components/Toast/styles.module.scss +0 -1
  170. package/lib/components/Toggle/styles.module.scss +9 -10
  171. package/lib/components/Validation/index.js +2 -2
  172. package/lib/components/Validation/index.js.map +1 -1
  173. package/lib/components/VisualCheckboxCloud/Checkbox/styles.module.scss +0 -2
  174. package/lib/components/VisualCheckboxCloud/styles.module.scss +0 -1
  175. package/lib/components/VisualCheckboxGroup/VisualCheckbox/styles.module.scss +0 -2
  176. package/lib/components/VisualCheckboxGroup/styles.module.scss +0 -1
  177. package/lib/components/VisualContentgroupWithImage/styles.module.scss +0 -1
  178. package/lib/components/VisualRadioCloud/Radio/index.js +1 -1
  179. package/lib/components/VisualRadioCloud/Radio/styles.module.scss +0 -2
  180. package/lib/components/VisualRadioCloud/index.js +1 -1
  181. package/lib/components/VisualRadioCloud/styles.module.scss +0 -1
  182. package/lib/components/VisualRadioGroup/VisualRadio/styles.module.scss +0 -2
  183. package/lib/components/VisualRadioGroup/styles.module.scss +0 -1
  184. package/lib/constants.d.ts +2 -3
  185. package/lib/constants.js +2 -3
  186. package/lib/constants.js.map +1 -1
  187. package/lib/floating-ui.react.js +1 -458
  188. package/lib/floating-ui.react.js.map +1 -1
  189. package/lib/hooks/useDismissablePopover.d.ts +20 -0
  190. package/lib/hooks/useDismissablePopover.js +66 -0
  191. package/lib/hooks/useDismissablePopover.js.map +1 -0
  192. package/lib/hooks/useOutsideEvent.d.ts +3 -0
  193. package/lib/hooks/useOutsideEvent.js +24 -3
  194. package/lib/hooks/useOutsideEvent.js.map +1 -1
  195. package/lib/hooks/useReturnFocusOnClose.d.ts +7 -0
  196. package/lib/hooks/useReturnFocusOnClose.js +22 -0
  197. package/lib/hooks/useReturnFocusOnClose.js.map +1 -0
  198. package/lib/index.d.ts +2 -0
  199. package/lib/index.js +3 -1
  200. package/lib/scss/_visual-form.scss +47 -47
  201. package/lib/scss/helsenorge.scss +1 -0
  202. package/lib/scss/supernova/styles/colors.css +177 -122
  203. package/lib/scss/supernova/styles/typography.css +58 -51
  204. package/lib/scss/supernova-legacy/index.css +2 -0
  205. package/lib/scss/supernova-legacy/styles/legacy-colors.css +111 -0
  206. package/lib/utils/formSpacing.js +3 -3
  207. package/lib/utils/formSpacing.js.map +1 -1
  208. package/package.json +8 -14
  209. package/scss/_visual-form.scss +47 -47
  210. package/scss/helsenorge.scss +1 -0
  211. package/scss/supernova/styles/colors.css +177 -122
  212. package/scss/supernova/styles/typography.css +58 -51
  213. package/scss/supernova-legacy/index.css +2 -0
  214. package/scss/supernova-legacy/styles/legacy-colors.css +111 -0
  215. package/lib/DictionaryTrigger.js +0 -27
  216. package/lib/RadioButton.js +0 -84
  217. package/lib/RadioButton.js.map +0 -1
  218. package/lib/components/HelpTooltip/HelpTooltip.d.ts +0 -12
  219. package/lib/components/HelpTooltip/index.d.ts +0 -3
  220. package/lib/components/HelpTooltip/index.js +0 -48
  221. package/lib/components/HelpTooltip/index.js.map +0 -1
  222. package/lib/components/RadioButton/RadioButton.d.ts +0 -28
  223. package/lib/components/RadioButton/index.d.ts +0 -3
  224. package/lib/components/RadioButton/index.js +0 -7
  225. package/lib/components/RadioButton/index.js.map +0 -1
  226. package/lib/components/RadioButton/styles.module.scss.d.ts +0 -26
  227. package/lib/designsystem-react.css +0 -273
  228. /package/lib/components/{RadioButton → Radio}/RadioMarker/RadioMarker.d.ts +0 -0
  229. /package/lib/components/{RadioButton → Radio}/RadioMarker/styles.module.scss +0 -0
  230. /package/lib/components/{RadioButton → Radio}/RadioMarker/styles.module.scss.d.ts +0 -0
@@ -601,9 +601,6 @@ function isAndroid() {
601
601
  const re = /android/i;
602
602
  return re.test(getPlatform()) || re.test(getUserAgent());
603
603
  }
604
- function isMac() {
605
- return getPlatform().toLowerCase().startsWith("mac") && !navigator.maxTouchPoints;
606
- }
607
604
  function isJSDOM() {
608
605
  return getUserAgent().includes("jsdom/");
609
606
  }
@@ -653,14 +650,6 @@ function isTypeableCombobox(element) {
653
650
  if (!element) return false;
654
651
  return element.getAttribute("role") === "combobox" && isTypeableElement(element);
655
652
  }
656
- function matchesFocusVisible(element) {
657
- if (!element || isJSDOM()) return true;
658
- try {
659
- return element.matches(":focus-visible");
660
- } catch (_e) {
661
- return true;
662
- }
663
- }
664
653
  function getFloatingFocusElement(floatingElement) {
665
654
  if (!floatingElement) return null;
666
655
  return floatingElement.hasAttribute(FOCUSABLE_ATTRIBUTE$1) ? floatingElement : floatingElement.querySelector("[data-floating-ui-focusable]") || floatingElement;
@@ -2283,357 +2272,6 @@ function clearTimeoutIfSet(timeoutRef) {
2283
2272
  timeoutRef.current = -1;
2284
2273
  }
2285
2274
  }
2286
- var safePolygonIdentifier = /*#__PURE__*/ createAttribute("safe-polygon");
2287
- function getDelay(value, prop, pointerType) {
2288
- if (pointerType && !isMouseLikePointerType(pointerType)) return 0;
2289
- if (typeof value === "number") return value;
2290
- if (typeof value === "function") {
2291
- const result = value();
2292
- if (typeof result === "number") return result;
2293
- return result == null ? void 0 : result[prop];
2294
- }
2295
- return value == null ? void 0 : value[prop];
2296
- }
2297
- function getRestMs(value) {
2298
- if (typeof value === "function") return value();
2299
- return value;
2300
- }
2301
- /**
2302
- * Opens the floating element while hovering over the reference element, like
2303
- * CSS `:hover`.
2304
- * @see https://floating-ui.com/docs/useHover
2305
- */
2306
- function useHover(context, props) {
2307
- if (props === void 0) props = {};
2308
- const { open, onOpenChange, dataRef, events, elements } = context;
2309
- const { enabled = true, delay = 0, handleClose = null, mouseOnly = false, restMs = 0, move = true } = props;
2310
- const tree = useFloatingTree();
2311
- const parentId = useFloatingParentNodeId();
2312
- const handleCloseRef = useLatestRef$1(handleClose);
2313
- const delayRef = useLatestRef$1(delay);
2314
- const openRef = useLatestRef$1(open);
2315
- const restMsRef = useLatestRef$1(restMs);
2316
- const pointerTypeRef = React$1.useRef();
2317
- const timeoutRef = React$1.useRef(-1);
2318
- const handlerRef = React$1.useRef();
2319
- const restTimeoutRef = React$1.useRef(-1);
2320
- const blockMouseMoveRef = React$1.useRef(true);
2321
- const performedPointerEventsMutationRef = React$1.useRef(false);
2322
- const unbindMouseMoveRef = React$1.useRef(() => {});
2323
- const restTimeoutPendingRef = React$1.useRef(false);
2324
- const isHoverOpen = useEffectEvent(() => {
2325
- var _dataRef$current$open;
2326
- const type = (_dataRef$current$open = dataRef.current.openEvent) == null ? void 0 : _dataRef$current$open.type;
2327
- return (type == null ? void 0 : type.includes("mouse")) && type !== "mousedown";
2328
- });
2329
- React$1.useEffect(() => {
2330
- if (!enabled) return;
2331
- function onOpenChange(_ref) {
2332
- let { open } = _ref;
2333
- if (!open) {
2334
- clearTimeoutIfSet(timeoutRef);
2335
- clearTimeoutIfSet(restTimeoutRef);
2336
- blockMouseMoveRef.current = true;
2337
- restTimeoutPendingRef.current = false;
2338
- }
2339
- }
2340
- events.on("openchange", onOpenChange);
2341
- return () => {
2342
- events.off("openchange", onOpenChange);
2343
- };
2344
- }, [enabled, events]);
2345
- React$1.useEffect(() => {
2346
- if (!enabled) return;
2347
- if (!handleCloseRef.current) return;
2348
- if (!open) return;
2349
- function onLeave(event) {
2350
- if (isHoverOpen()) onOpenChange(false, event, "hover");
2351
- }
2352
- const html = getDocument$1(elements.floating).documentElement;
2353
- html.addEventListener("mouseleave", onLeave);
2354
- return () => {
2355
- html.removeEventListener("mouseleave", onLeave);
2356
- };
2357
- }, [
2358
- elements.floating,
2359
- open,
2360
- onOpenChange,
2361
- enabled,
2362
- handleCloseRef,
2363
- isHoverOpen
2364
- ]);
2365
- const closeWithDelay = React$1.useCallback(function(event, runElseBranch, reason) {
2366
- if (runElseBranch === void 0) runElseBranch = true;
2367
- if (reason === void 0) reason = "hover";
2368
- const closeDelay = getDelay(delayRef.current, "close", pointerTypeRef.current);
2369
- if (closeDelay && !handlerRef.current) {
2370
- clearTimeoutIfSet(timeoutRef);
2371
- timeoutRef.current = window.setTimeout(() => onOpenChange(false, event, reason), closeDelay);
2372
- } else if (runElseBranch) {
2373
- clearTimeoutIfSet(timeoutRef);
2374
- onOpenChange(false, event, reason);
2375
- }
2376
- }, [delayRef, onOpenChange]);
2377
- const cleanupMouseMoveHandler = useEffectEvent(() => {
2378
- unbindMouseMoveRef.current();
2379
- handlerRef.current = void 0;
2380
- });
2381
- const clearPointerEvents = useEffectEvent(() => {
2382
- if (performedPointerEventsMutationRef.current) {
2383
- const body = getDocument$1(elements.floating).body;
2384
- body.style.pointerEvents = "";
2385
- body.removeAttribute(safePolygonIdentifier);
2386
- performedPointerEventsMutationRef.current = false;
2387
- }
2388
- });
2389
- const isClickLikeOpenEvent = useEffectEvent(() => {
2390
- return dataRef.current.openEvent ? ["click", "mousedown"].includes(dataRef.current.openEvent.type) : false;
2391
- });
2392
- React$1.useEffect(() => {
2393
- if (!enabled) return;
2394
- function onReferenceMouseEnter(event) {
2395
- clearTimeoutIfSet(timeoutRef);
2396
- blockMouseMoveRef.current = false;
2397
- if (mouseOnly && !isMouseLikePointerType(pointerTypeRef.current) || getRestMs(restMsRef.current) > 0 && !getDelay(delayRef.current, "open")) return;
2398
- const openDelay = getDelay(delayRef.current, "open", pointerTypeRef.current);
2399
- if (openDelay) timeoutRef.current = window.setTimeout(() => {
2400
- if (!openRef.current) onOpenChange(true, event, "hover");
2401
- }, openDelay);
2402
- else if (!open) onOpenChange(true, event, "hover");
2403
- }
2404
- function onReferenceMouseLeave(event) {
2405
- if (isClickLikeOpenEvent()) {
2406
- clearPointerEvents();
2407
- return;
2408
- }
2409
- unbindMouseMoveRef.current();
2410
- const doc = getDocument$1(elements.floating);
2411
- clearTimeoutIfSet(restTimeoutRef);
2412
- restTimeoutPendingRef.current = false;
2413
- if (handleCloseRef.current && dataRef.current.floatingContext) {
2414
- if (!open) clearTimeoutIfSet(timeoutRef);
2415
- handlerRef.current = handleCloseRef.current({
2416
- ...dataRef.current.floatingContext,
2417
- tree,
2418
- x: event.clientX,
2419
- y: event.clientY,
2420
- onClose() {
2421
- clearPointerEvents();
2422
- cleanupMouseMoveHandler();
2423
- if (!isClickLikeOpenEvent()) closeWithDelay(event, true, "safe-polygon");
2424
- }
2425
- });
2426
- const handler = handlerRef.current;
2427
- doc.addEventListener("mousemove", handler);
2428
- unbindMouseMoveRef.current = () => {
2429
- doc.removeEventListener("mousemove", handler);
2430
- };
2431
- return;
2432
- }
2433
- if (pointerTypeRef.current === "touch" ? !contains(elements.floating, event.relatedTarget) : true) closeWithDelay(event);
2434
- }
2435
- function onScrollMouseLeave(event) {
2436
- if (isClickLikeOpenEvent()) return;
2437
- if (!dataRef.current.floatingContext) return;
2438
- handleCloseRef.current == null || handleCloseRef.current({
2439
- ...dataRef.current.floatingContext,
2440
- tree,
2441
- x: event.clientX,
2442
- y: event.clientY,
2443
- onClose() {
2444
- clearPointerEvents();
2445
- cleanupMouseMoveHandler();
2446
- if (!isClickLikeOpenEvent()) closeWithDelay(event);
2447
- }
2448
- })(event);
2449
- }
2450
- function onFloatingMouseEnter() {
2451
- clearTimeoutIfSet(timeoutRef);
2452
- }
2453
- function onFloatingMouseLeave(event) {
2454
- if (!isClickLikeOpenEvent()) closeWithDelay(event, false);
2455
- }
2456
- if (isElement(elements.domReference)) {
2457
- const reference = elements.domReference;
2458
- const floating = elements.floating;
2459
- if (open) reference.addEventListener("mouseleave", onScrollMouseLeave);
2460
- if (move) reference.addEventListener("mousemove", onReferenceMouseEnter, { once: true });
2461
- reference.addEventListener("mouseenter", onReferenceMouseEnter);
2462
- reference.addEventListener("mouseleave", onReferenceMouseLeave);
2463
- if (floating) {
2464
- floating.addEventListener("mouseleave", onScrollMouseLeave);
2465
- floating.addEventListener("mouseenter", onFloatingMouseEnter);
2466
- floating.addEventListener("mouseleave", onFloatingMouseLeave);
2467
- }
2468
- return () => {
2469
- if (open) reference.removeEventListener("mouseleave", onScrollMouseLeave);
2470
- if (move) reference.removeEventListener("mousemove", onReferenceMouseEnter);
2471
- reference.removeEventListener("mouseenter", onReferenceMouseEnter);
2472
- reference.removeEventListener("mouseleave", onReferenceMouseLeave);
2473
- if (floating) {
2474
- floating.removeEventListener("mouseleave", onScrollMouseLeave);
2475
- floating.removeEventListener("mouseenter", onFloatingMouseEnter);
2476
- floating.removeEventListener("mouseleave", onFloatingMouseLeave);
2477
- }
2478
- };
2479
- }
2480
- }, [
2481
- elements,
2482
- enabled,
2483
- context,
2484
- mouseOnly,
2485
- move,
2486
- closeWithDelay,
2487
- cleanupMouseMoveHandler,
2488
- clearPointerEvents,
2489
- onOpenChange,
2490
- open,
2491
- openRef,
2492
- tree,
2493
- delayRef,
2494
- handleCloseRef,
2495
- dataRef,
2496
- isClickLikeOpenEvent,
2497
- restMsRef
2498
- ]);
2499
- index$1(() => {
2500
- var _handleCloseRef$curre;
2501
- if (!enabled) return;
2502
- if (open && (_handleCloseRef$curre = handleCloseRef.current) != null && (_handleCloseRef$curre = _handleCloseRef$curre.__options) != null && _handleCloseRef$curre.blockPointerEvents && isHoverOpen()) {
2503
- performedPointerEventsMutationRef.current = true;
2504
- const floatingEl = elements.floating;
2505
- if (isElement(elements.domReference) && floatingEl) {
2506
- var _tree$nodesRef$curren;
2507
- const body = getDocument$1(elements.floating).body;
2508
- body.setAttribute(safePolygonIdentifier, "");
2509
- const ref = elements.domReference;
2510
- const parentFloating = tree == null || (_tree$nodesRef$curren = tree.nodesRef.current.find((node) => node.id === parentId)) == null || (_tree$nodesRef$curren = _tree$nodesRef$curren.context) == null ? void 0 : _tree$nodesRef$curren.elements.floating;
2511
- if (parentFloating) parentFloating.style.pointerEvents = "";
2512
- body.style.pointerEvents = "none";
2513
- ref.style.pointerEvents = "auto";
2514
- floatingEl.style.pointerEvents = "auto";
2515
- return () => {
2516
- body.style.pointerEvents = "";
2517
- ref.style.pointerEvents = "";
2518
- floatingEl.style.pointerEvents = "";
2519
- };
2520
- }
2521
- }
2522
- }, [
2523
- enabled,
2524
- open,
2525
- parentId,
2526
- elements,
2527
- tree,
2528
- handleCloseRef,
2529
- isHoverOpen
2530
- ]);
2531
- index$1(() => {
2532
- if (!open) {
2533
- pointerTypeRef.current = void 0;
2534
- restTimeoutPendingRef.current = false;
2535
- cleanupMouseMoveHandler();
2536
- clearPointerEvents();
2537
- }
2538
- }, [
2539
- open,
2540
- cleanupMouseMoveHandler,
2541
- clearPointerEvents
2542
- ]);
2543
- React$1.useEffect(() => {
2544
- return () => {
2545
- cleanupMouseMoveHandler();
2546
- clearTimeoutIfSet(timeoutRef);
2547
- clearTimeoutIfSet(restTimeoutRef);
2548
- clearPointerEvents();
2549
- };
2550
- }, [
2551
- enabled,
2552
- elements.domReference,
2553
- cleanupMouseMoveHandler,
2554
- clearPointerEvents
2555
- ]);
2556
- const reference = React$1.useMemo(() => {
2557
- function setPointerRef(event) {
2558
- pointerTypeRef.current = event.pointerType;
2559
- }
2560
- return {
2561
- onPointerDown: setPointerRef,
2562
- onPointerEnter: setPointerRef,
2563
- onMouseMove(event) {
2564
- const { nativeEvent } = event;
2565
- function handleMouseMove() {
2566
- if (!blockMouseMoveRef.current && !openRef.current) onOpenChange(true, nativeEvent, "hover");
2567
- }
2568
- if (mouseOnly && !isMouseLikePointerType(pointerTypeRef.current)) return;
2569
- if (open || getRestMs(restMsRef.current) === 0) return;
2570
- if (restTimeoutPendingRef.current && event.movementX ** 2 + event.movementY ** 2 < 2) return;
2571
- clearTimeoutIfSet(restTimeoutRef);
2572
- if (pointerTypeRef.current === "touch") handleMouseMove();
2573
- else {
2574
- restTimeoutPendingRef.current = true;
2575
- restTimeoutRef.current = window.setTimeout(handleMouseMove, getRestMs(restMsRef.current));
2576
- }
2577
- }
2578
- };
2579
- }, [
2580
- mouseOnly,
2581
- onOpenChange,
2582
- open,
2583
- openRef,
2584
- restMsRef
2585
- ]);
2586
- return React$1.useMemo(() => enabled ? { reference } : {}, [enabled, reference]);
2587
- }
2588
- var NOOP = () => {};
2589
- var FloatingDelayGroupContext = /*#__PURE__*/ React$1.createContext({
2590
- delay: 0,
2591
- initialDelay: 0,
2592
- timeoutMs: 0,
2593
- currentId: null,
2594
- setCurrentId: NOOP,
2595
- setState: NOOP,
2596
- isInstantPhase: false
2597
- });
2598
- /**
2599
- * Provides context for a group of floating elements that should share a
2600
- * `delay`.
2601
- * @see https://floating-ui.com/docs/FloatingDelayGroup
2602
- */
2603
- function FloatingDelayGroup(props) {
2604
- const { children, delay, timeoutMs = 0 } = props;
2605
- const [state, setState] = React$1.useReducer((prev, next) => ({
2606
- ...prev,
2607
- ...next
2608
- }), {
2609
- delay,
2610
- timeoutMs,
2611
- initialDelay: delay,
2612
- currentId: null,
2613
- isInstantPhase: false
2614
- });
2615
- const initialCurrentIdRef = React$1.useRef(null);
2616
- const setCurrentId = React$1.useCallback((currentId) => {
2617
- setState({ currentId });
2618
- }, []);
2619
- index$1(() => {
2620
- if (state.currentId) {
2621
- if (initialCurrentIdRef.current === null) initialCurrentIdRef.current = state.currentId;
2622
- else if (!state.isInstantPhase) setState({ isInstantPhase: true });
2623
- } else {
2624
- if (state.isInstantPhase) setState({ isInstantPhase: false });
2625
- initialCurrentIdRef.current = null;
2626
- }
2627
- }, [state.currentId, state.isInstantPhase]);
2628
- return /*#__PURE__*/ jsx(FloatingDelayGroupContext.Provider, {
2629
- value: React$1.useMemo(() => ({
2630
- ...state,
2631
- setState,
2632
- setCurrentId
2633
- }), [state, setCurrentId]),
2634
- children
2635
- });
2636
- }
2637
2275
  var rafId = 0;
2638
2276
  function enqueueFocus(el, options) {
2639
2277
  if (options === void 0) options = {};
@@ -3667,101 +3305,6 @@ function useFloating(_temp) {
3667
3305
  context
3668
3306
  ]);
3669
3307
  }
3670
- function isMacSafari() {
3671
- return isMac() && isSafari();
3672
- }
3673
- /**
3674
- * Opens the floating element while the reference element has focus, like CSS
3675
- * `:focus`.
3676
- * @see https://floating-ui.com/docs/useFocus
3677
- */
3678
- function useFocus(context, props) {
3679
- if (props === void 0) props = {};
3680
- const { open, onOpenChange, events, dataRef, elements } = context;
3681
- const { enabled = true, visibleOnly = true } = props;
3682
- const blockFocusRef = React$1.useRef(false);
3683
- const timeoutRef = React$1.useRef(-1);
3684
- const keyboardModalityRef = React$1.useRef(true);
3685
- React$1.useEffect(() => {
3686
- if (!enabled) return;
3687
- const win = getWindow(elements.domReference);
3688
- function onBlur() {
3689
- if (!open && isHTMLElement(elements.domReference) && elements.domReference === activeElement(getDocument$1(elements.domReference))) blockFocusRef.current = true;
3690
- }
3691
- function onKeyDown() {
3692
- keyboardModalityRef.current = true;
3693
- }
3694
- function onPointerDown() {
3695
- keyboardModalityRef.current = false;
3696
- }
3697
- win.addEventListener("blur", onBlur);
3698
- if (isMacSafari()) {
3699
- win.addEventListener("keydown", onKeyDown, true);
3700
- win.addEventListener("pointerdown", onPointerDown, true);
3701
- }
3702
- return () => {
3703
- win.removeEventListener("blur", onBlur);
3704
- if (isMacSafari()) {
3705
- win.removeEventListener("keydown", onKeyDown, true);
3706
- win.removeEventListener("pointerdown", onPointerDown, true);
3707
- }
3708
- };
3709
- }, [
3710
- elements.domReference,
3711
- open,
3712
- enabled
3713
- ]);
3714
- React$1.useEffect(() => {
3715
- if (!enabled) return;
3716
- function onOpenChange(_ref) {
3717
- let { reason } = _ref;
3718
- if (reason === "reference-press" || reason === "escape-key") blockFocusRef.current = true;
3719
- }
3720
- events.on("openchange", onOpenChange);
3721
- return () => {
3722
- events.off("openchange", onOpenChange);
3723
- };
3724
- }, [events, enabled]);
3725
- React$1.useEffect(() => {
3726
- return () => {
3727
- clearTimeoutIfSet(timeoutRef);
3728
- };
3729
- }, []);
3730
- const reference = React$1.useMemo(() => ({
3731
- onMouseLeave() {
3732
- blockFocusRef.current = false;
3733
- },
3734
- onFocus(event) {
3735
- if (blockFocusRef.current) return;
3736
- const target = getTarget(event.nativeEvent);
3737
- if (visibleOnly && isElement(target)) {
3738
- if (isMacSafari() && !event.relatedTarget) {
3739
- if (!keyboardModalityRef.current && !isTypeableElement(target)) return;
3740
- } else if (!matchesFocusVisible(target)) return;
3741
- }
3742
- onOpenChange(true, event.nativeEvent, "focus");
3743
- },
3744
- onBlur(event) {
3745
- blockFocusRef.current = false;
3746
- const relatedTarget = event.relatedTarget;
3747
- const nativeEvent = event.nativeEvent;
3748
- const movedToFocusGuard = isElement(relatedTarget) && relatedTarget.hasAttribute(createAttribute("focus-guard")) && relatedTarget.getAttribute("data-type") === "outside";
3749
- timeoutRef.current = window.setTimeout(() => {
3750
- var _dataRef$current$floa;
3751
- const activeEl = activeElement(elements.domReference ? elements.domReference.ownerDocument : document);
3752
- if (!relatedTarget && activeEl === elements.domReference) return;
3753
- if (contains((_dataRef$current$floa = dataRef.current.floatingContext) == null ? void 0 : _dataRef$current$floa.refs.floating.current, activeEl) || contains(elements.domReference, activeEl) || movedToFocusGuard) return;
3754
- onOpenChange(false, nativeEvent, "focus");
3755
- });
3756
- }
3757
- }), [
3758
- dataRef,
3759
- elements.domReference,
3760
- onOpenChange,
3761
- visibleOnly
3762
- ]);
3763
- return React$1.useMemo(() => enabled ? { reference } : {}, [enabled, reference]);
3764
- }
3765
3308
  function mergeProps(userProps, propsList, elementKey) {
3766
3309
  const map = /* @__PURE__ */ new Map();
3767
3310
  const isItem = elementKey === "item";
@@ -3827,6 +3370,6 @@ function useInteractions(propsList) {
3827
3370
  ]);
3828
3371
  }
3829
3372
  //#endregion
3830
- export { autoUpdate as _, useDismiss as a, useHover as c, arrow as d, flip as f, size as g, shift as h, useClick as i, useInteractions as l, offset as m, FloatingDelayGroup as n, useFloating as o, hide as p, FloatingFocusManager as r, useFocus as s, FloatingArrow as t, useMergeRefs as u };
3373
+ export { useFloating as a, arrow as c, offset as d, shift as f, useDismiss as i, flip as l, autoUpdate as m, FloatingFocusManager as n, useInteractions as o, size as p, useClick as r, useMergeRefs as s, FloatingArrow as t, hide as u };
3831
3374
 
3832
3375
  //# sourceMappingURL=floating-ui.react.js.map