@allxsmith/bestax-bulma 5.27.8 → 5.29.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 (103) hide show
  1. package/dist/bestax.css +1 -1
  2. package/dist/bestax.css.map +1 -1
  3. package/dist/esm/components/Dialog.js +8 -4
  4. package/dist/esm/components/Dialog.js.map +1 -1
  5. package/dist/esm/components/HoverCard.js +127 -0
  6. package/dist/esm/components/HoverCard.js.map +1 -0
  7. package/dist/esm/components/Modal.js +19 -11
  8. package/dist/esm/components/Modal.js.map +1 -1
  9. package/dist/esm/components/Popover.js.map +1 -1
  10. package/dist/esm/components/Sidebar.js +12 -3
  11. package/dist/esm/components/Sidebar.js.map +1 -1
  12. package/dist/esm/components/Toast.js +5 -3
  13. package/dist/esm/components/Toast.js.map +1 -1
  14. package/dist/esm/elements/Notification.js +3 -1
  15. package/dist/esm/elements/Notification.js.map +1 -1
  16. package/dist/esm/form/DateInput.js.map +1 -1
  17. package/dist/esm/form/DateInputBase.js.map +1 -1
  18. package/dist/esm/form/DateRangeInputBase.js.map +1 -1
  19. package/dist/esm/form/DateTimeInput.js.map +1 -1
  20. package/dist/esm/form/DateTimeInputBase.js.map +1 -1
  21. package/dist/esm/form/Field.js.map +1 -1
  22. package/dist/esm/form/File.js.map +1 -1
  23. package/dist/esm/form/Input.js.map +1 -1
  24. package/dist/esm/form/Numberinput.js.map +1 -1
  25. package/dist/esm/form/Select.js.map +1 -1
  26. package/dist/esm/form/Slider.js.map +1 -1
  27. package/dist/esm/form/Taginput.js.map +1 -1
  28. package/dist/esm/form/TextArea.js.map +1 -1
  29. package/dist/esm/form/TimeInput.js.map +1 -1
  30. package/dist/esm/form/TimeInputBase.js.map +1 -1
  31. package/dist/esm/form/_pickerInternals/PickerPopover.js +3 -1
  32. package/dist/esm/form/_pickerInternals/PickerPopover.js.map +1 -1
  33. package/dist/esm/helpers/Config.js +5 -2
  34. package/dist/esm/helpers/Config.js.map +1 -1
  35. package/dist/esm/helpers/portal.js +30 -5
  36. package/dist/esm/helpers/portal.js.map +1 -1
  37. package/dist/esm/helpers/useFocusTrap.js +2 -1
  38. package/dist/esm/helpers/useFocusTrap.js.map +1 -1
  39. package/dist/esm/helpers/useHoverOpen.js +390 -0
  40. package/dist/esm/helpers/useHoverOpen.js.map +1 -0
  41. package/dist/extras.css +1 -1
  42. package/dist/extras.css.map +1 -1
  43. package/dist/index.cjs +574 -27
  44. package/dist/index.cjs.map +1 -1
  45. package/dist/index.esm.js +1 -0
  46. package/dist/index.esm.js.map +1 -1
  47. package/dist/types/components/HoverCard.d.ts +138 -0
  48. package/dist/types/components/Modal.d.ts +2 -1
  49. package/dist/types/components/Popover.d.ts +8 -7
  50. package/dist/types/form/DateInput.d.ts +1 -1
  51. package/dist/types/form/DateInputBase.d.ts +4 -1
  52. package/dist/types/form/DateRangeInputBase.d.ts +4 -1
  53. package/dist/types/form/DateTimeInput.d.ts +1 -1
  54. package/dist/types/form/DateTimeInputBase.d.ts +4 -1
  55. package/dist/types/form/Field.d.ts +1 -1
  56. package/dist/types/form/File.d.ts +1 -1
  57. package/dist/types/form/Input.d.ts +1 -1
  58. package/dist/types/form/Numberinput.d.ts +1 -1
  59. package/dist/types/form/Select.d.ts +1 -1
  60. package/dist/types/form/Slider.d.ts +1 -1
  61. package/dist/types/form/Taginput.d.ts +1 -1
  62. package/dist/types/form/TextArea.d.ts +1 -1
  63. package/dist/types/form/TimeInput.d.ts +1 -1
  64. package/dist/types/form/TimeInputBase.d.ts +2 -1
  65. package/dist/types/helpers/Config.d.ts +34 -3
  66. package/dist/types/helpers/portal.d.ts +27 -5
  67. package/dist/types/helpers/useFocusTrap.d.ts +9 -0
  68. package/dist/types/helpers/useHoverOpen.d.ts +98 -0
  69. package/dist/types/index.d.ts +1 -0
  70. package/dist/types-cjs/components/HoverCard.d.ts +138 -0
  71. package/dist/types-cjs/components/Modal.d.ts +2 -1
  72. package/dist/types-cjs/components/Popover.d.ts +8 -7
  73. package/dist/types-cjs/form/DateInput.d.ts +1 -1
  74. package/dist/types-cjs/form/DateInputBase.d.ts +4 -1
  75. package/dist/types-cjs/form/DateRangeInputBase.d.ts +4 -1
  76. package/dist/types-cjs/form/DateTimeInput.d.ts +1 -1
  77. package/dist/types-cjs/form/DateTimeInputBase.d.ts +4 -1
  78. package/dist/types-cjs/form/Field.d.ts +1 -1
  79. package/dist/types-cjs/form/File.d.ts +1 -1
  80. package/dist/types-cjs/form/Input.d.ts +1 -1
  81. package/dist/types-cjs/form/Numberinput.d.ts +1 -1
  82. package/dist/types-cjs/form/Select.d.ts +1 -1
  83. package/dist/types-cjs/form/Slider.d.ts +1 -1
  84. package/dist/types-cjs/form/Taginput.d.ts +1 -1
  85. package/dist/types-cjs/form/TextArea.d.ts +1 -1
  86. package/dist/types-cjs/form/TimeInput.d.ts +1 -1
  87. package/dist/types-cjs/form/TimeInputBase.d.ts +2 -1
  88. package/dist/types-cjs/helpers/Config.d.ts +34 -3
  89. package/dist/types-cjs/helpers/portal.d.ts +27 -5
  90. package/dist/types-cjs/helpers/useFocusTrap.d.ts +9 -0
  91. package/dist/types-cjs/helpers/useHoverOpen.d.ts +98 -0
  92. package/dist/types-cjs/index.d.ts +1 -0
  93. package/dist/versions/bestax-no-dark-mode.css +1 -1
  94. package/dist/versions/bestax-no-dark-mode.css.map +1 -1
  95. package/dist/versions/bestax-no-helpers-prefixed.css +1 -1
  96. package/dist/versions/bestax-no-helpers-prefixed.css.map +1 -1
  97. package/dist/versions/bestax-no-helpers.css +1 -1
  98. package/dist/versions/bestax-no-helpers.css.map +1 -1
  99. package/dist/versions/bestax-prefixed.css +1 -1
  100. package/dist/versions/bestax-prefixed.css.map +1 -1
  101. package/package.json +2 -2
  102. package/src/scss/components/_hovercard.scss +118 -0
  103. package/src/scss/components/_index.scss +1 -0
@@ -2,6 +2,7 @@
2
2
  import { jsx, Fragment } from 'react/jsx-runtime';
3
3
  import { createPortal } from 'react-dom';
4
4
  import { useIsHydrated } from './useIsHydrated.js';
5
+ import { useConfig } from './Config.js';
5
6
 
6
7
  /**
7
8
  * Resolves a portal target: an `HTMLElement` is used directly, a non-empty
@@ -27,7 +28,26 @@ function resolvePortalContainer(container) {
27
28
  return container;
28
29
  }
29
30
  /**
30
- * Renders its children into another part of the page, `document.body` unless `container` says otherwise, so floating content escapes an ancestor's `overflow`, `transform` or stacking context.
31
+ * Where a component's portal goes, as a function to call when the portal is
32
+ * created: the target the component was given, else the `portalContainer` a
33
+ * `ConfigProvider` sets, else `document.body`, each read as
34
+ * `resolvePortalContainer` reads it. A component that portals resolves its
35
+ * target through this, so the provider's default reaches it.
36
+ *
37
+ * The hook only reads context, so it is safe to call on the server, ahead of
38
+ * any early return. The function it returns reads the DOM, so call it only
39
+ * where the portal is created, which the server never reaches.
40
+ *
41
+ * @function usePortalContainer
42
+ * @returns A function that takes the component's own target, if any, and
43
+ * returns the DOM node to portal into.
44
+ */
45
+ function usePortalContainer() {
46
+ const { portalContainer } = useConfig();
47
+ return container => resolvePortalContainer(container || portalContainer);
48
+ }
49
+ /**
50
+ * Renders its children into another part of the page, `document.body` unless `container` or a `ConfigProvider` says otherwise, so floating content escapes an ancestor's `overflow`, `transform` or stacking context.
31
51
  *
32
52
  * React's server renderer can't render a portal, so `Portal` renders nothing
33
53
  * on the server and during hydration, and mounts its children in the commit
@@ -38,8 +58,12 @@ function resolvePortalContainer(container) {
38
58
  * portaled children, and their React events bubble through the React tree.
39
59
  * CSS inheritance follows the DOM instead: a scoped (non-`isRoot`) `Theme`
40
60
  * sets its variables on a wrapper element the portaled content has left, so
41
- * that content sees the page-level theme. Point `container` at an element
42
- * inside the themed area to keep it.
61
+ * that content sees the page-level theme, and styles scoped to a shadow root
62
+ * don't reach `document.body` at all. To keep them, portal into an element
63
+ * inside the themed area or the shadow root: pass it as `container`, or as
64
+ * the `portalContainer` of a `ConfigProvider` around that area. The second
65
+ * also reaches what the library's components portal, such as Popover's
66
+ * `appendToBody` panel or a `Modal` with `portal`.
43
67
  *
44
68
  * Tab order and focus follow the DOM too. Content portaled from inside a
45
69
  * focus trap is no longer inside the trapped element, so the trap neither
@@ -65,12 +89,13 @@ function resolvePortalContainer(container) {
65
89
  */
66
90
  function Portal({ children, container, disabled = false }) {
67
91
  const hydrated = useIsHydrated();
92
+ const resolveContainer = usePortalContainer();
68
93
  if (disabled)
69
94
  return jsx(Fragment, { children: children });
70
95
  if (!hydrated)
71
96
  return null;
72
- return createPortal(children, resolvePortalContainer(container));
97
+ return createPortal(children, resolveContainer(container));
73
98
  }
74
99
 
75
- export { Portal, resolvePortalContainer };
100
+ export { Portal, resolvePortalContainer, usePortalContainer };
76
101
  //# sourceMappingURL=portal.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"portal.js","sources":["../../../src/helpers/portal.tsx"],"sourcesContent":["import React from 'react';\nimport { createPortal } from 'react-dom';\nimport { useIsHydrated } from './useIsHydrated';\n\n/**\n * Resolves a portal target: an `HTMLElement` is used directly, a non-empty\n * `string` is treated as a `document.querySelector` selector (falling back to\n * `document.body` when it matches nothing), and any falsy value — `undefined`\n * or the empty string — resolves to `document.body`.\n *\n * The empty string is deliberately treated as \"no target\" rather than passed\n * through: `document.querySelector('')` throws a `SyntaxError`, and callers\n * building a selector from state can easily hand us `''`.\n *\n * @function resolvePortalContainer\n * @param container - The requested portal target, if any.\n * @returns The resolved DOM node to portal into.\n */\nexport function resolvePortalContainer(\n container?: string | HTMLElement\n): HTMLElement {\n if (!container) {\n return document.body;\n }\n if (typeof container === 'string') {\n return (\n (document.querySelector(container) as HTMLElement | null) ?? document.body\n );\n }\n return container;\n}\n\n/**\n * Props for the Portal component.\n */\nexport interface PortalProps {\n /** Content to render into the container. */\n children?: React.ReactNode;\n /**\n * Where the content goes: an element, or a `document.querySelector`\n * selector. Omitted, empty, or a selector that matches nothing, it goes to\n * `document.body`. A selector is looked up again on each render, so the\n * content follows the target when it changes. Moving to another target\n * remounts the children and resets their state, which includes a selector\n * that only starts matching after the content has shown in `document.body`.\n * Render the target first, or pass the element once you have it.\n */\n container?: string | HTMLElement;\n /**\n * Render the children in place instead, on the server as well as the\n * client. Lets a component that portals only sometimes keep a single code\n * path.\n * @defaultValue false\n */\n disabled?: boolean;\n}\n\n/**\n * Renders its children into another part of the page, `document.body` unless `container` says otherwise, so floating content escapes an ancestor's `overflow`, `transform` or stacking context.\n *\n * React's server renderer can't render a portal, so `Portal` renders nothing\n * on the server and during hydration, and mounts its children in the commit\n * that follows. The first client render then matches the server markup. In an app\n * without server rendering it portals on the first render.\n *\n * React context, such as `ConfigProvider`'s class prefix, reaches the\n * portaled children, and their React events bubble through the React tree.\n * CSS inheritance follows the DOM instead: a scoped (non-`isRoot`) `Theme`\n * sets its variables on a wrapper element the portaled content has left, so\n * that content sees the page-level theme. Point `container` at an element\n * inside the themed area to keep it.\n *\n * Tab order and focus follow the DOM too. Content portaled from inside a\n * focus trap is no longer inside the trapped element, so the trap neither\n * reaches it nor holds focus there: render nested overlays inside the\n * trapped element, or give them a trap of their own. To trap portaled\n * content, put `useFocusTrap`'s ref on the element inside the `Portal`.\n *\n * @function\n * @param {PortalProps} props - Props for the Portal component.\n * @returns The portal, the children in place when `disabled`, or nothing\n * before hydration.\n *\n * @example\n * <Portal>\n * <div className=\"box\">Rendered at the end of document.body</div>\n * </Portal>\n *\n * @example\n * // Into a dedicated overlay root\n * <Portal container=\"#overlays\">\n * <CommandPalette />\n * </Portal>\n */\nexport function Portal({ children, container, disabled = false }: PortalProps) {\n const hydrated = useIsHydrated();\n if (disabled) return <>{children}</>;\n if (!hydrated) return null;\n return createPortal(children, resolvePortalContainer(container));\n}\n"],"names":["_jsx","_Fragment"],"mappings":";;;;;AAIA;;;;;;;;;;;;;AAaG;AACG,SAAU,sBAAsB,CACpC,SAAgC,EAAA;IAEhC,IAAI,CAAC,SAAS,EAAE;QACd,OAAO,QAAQ,CAAC,IAAI;IACtB;AACA,IAAA,IAAI,OAAO,SAAS,KAAK,QAAQ,EAAE;AACjC,QAAA,QACG,QAAQ,CAAC,aAAa,CAAC,SAAS,CAAwB,IAAI,QAAQ,CAAC,IAAI;IAE9E;AACA,IAAA,OAAO,SAAS;AAClB;AA2BA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCG;AACG,SAAU,MAAM,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,GAAG,KAAK,EAAe,EAAA;AAC3E,IAAA,MAAM,QAAQ,GAAG,aAAa,EAAE;AAChC,IAAA,IAAI,QAAQ;QAAE,OAAOA,GAAA,CAAAC,QAAA,EAAA,EAAA,QAAA,EAAG,QAAQ,EAAA,CAAI;AACpC,IAAA,IAAI,CAAC,QAAQ;AAAE,QAAA,OAAO,IAAI;IAC1B,OAAO,YAAY,CAAC,QAAQ,EAAE,sBAAsB,CAAC,SAAS,CAAC,CAAC;AAClE;;"}
1
+ {"version":3,"file":"portal.js","sources":["../../../src/helpers/portal.tsx"],"sourcesContent":["import React from 'react';\nimport { createPortal } from 'react-dom';\nimport { useIsHydrated } from './useIsHydrated';\nimport { useConfig } from './Config';\n\n/**\n * Resolves a portal target: an `HTMLElement` is used directly, a non-empty\n * `string` is treated as a `document.querySelector` selector (falling back to\n * `document.body` when it matches nothing), and any falsy value — `undefined`\n * or the empty string — resolves to `document.body`.\n *\n * The empty string is deliberately treated as \"no target\" rather than passed\n * through: `document.querySelector('')` throws a `SyntaxError`, and callers\n * building a selector from state can easily hand us `''`.\n *\n * @function resolvePortalContainer\n * @param container - The requested portal target, if any.\n * @returns The resolved DOM node to portal into.\n */\nexport function resolvePortalContainer(\n container?: string | HTMLElement\n): HTMLElement {\n if (!container) {\n return document.body;\n }\n if (typeof container === 'string') {\n return (\n (document.querySelector(container) as HTMLElement | null) ?? document.body\n );\n }\n return container;\n}\n\n/**\n * Where a component's portal goes, as a function to call when the portal is\n * created: the target the component was given, else the `portalContainer` a\n * `ConfigProvider` sets, else `document.body`, each read as\n * `resolvePortalContainer` reads it. A component that portals resolves its\n * target through this, so the provider's default reaches it.\n *\n * The hook only reads context, so it is safe to call on the server, ahead of\n * any early return. The function it returns reads the DOM, so call it only\n * where the portal is created, which the server never reaches.\n *\n * @function usePortalContainer\n * @returns A function that takes the component's own target, if any, and\n * returns the DOM node to portal into.\n */\nexport function usePortalContainer(): (\n container?: string | HTMLElement\n) => HTMLElement {\n const { portalContainer } = useConfig();\n return container => resolvePortalContainer(container || portalContainer);\n}\n\n/**\n * Props for the Portal component.\n */\nexport interface PortalProps {\n /** Content to render into the container. */\n children?: React.ReactNode;\n /**\n * Where the content goes: an element, or a `document.querySelector`\n * selector. Omitted or empty, it goes to the `portalContainer` a\n * `ConfigProvider` sets, and to `document.body` when none is set. A\n * selector that matches nothing means `document.body` too. A selector is\n * looked up again on each render, so the\n * content follows the target when it changes. Moving to another target\n * remounts the children and resets their state, which includes a selector\n * that only starts matching after the content has shown in `document.body`.\n * Render the target first, or pass the element once you have it.\n */\n container?: string | HTMLElement;\n /**\n * Render the children in place instead, on the server as well as the\n * client. Lets a component that portals only sometimes keep a single code\n * path.\n * @defaultValue false\n */\n disabled?: boolean;\n}\n\n/**\n * Renders its children into another part of the page, `document.body` unless `container` or a `ConfigProvider` says otherwise, so floating content escapes an ancestor's `overflow`, `transform` or stacking context.\n *\n * React's server renderer can't render a portal, so `Portal` renders nothing\n * on the server and during hydration, and mounts its children in the commit\n * that follows. The first client render then matches the server markup. In an app\n * without server rendering it portals on the first render.\n *\n * React context, such as `ConfigProvider`'s class prefix, reaches the\n * portaled children, and their React events bubble through the React tree.\n * CSS inheritance follows the DOM instead: a scoped (non-`isRoot`) `Theme`\n * sets its variables on a wrapper element the portaled content has left, so\n * that content sees the page-level theme, and styles scoped to a shadow root\n * don't reach `document.body` at all. To keep them, portal into an element\n * inside the themed area or the shadow root: pass it as `container`, or as\n * the `portalContainer` of a `ConfigProvider` around that area. The second\n * also reaches what the library's components portal, such as Popover's\n * `appendToBody` panel or a `Modal` with `portal`.\n *\n * Tab order and focus follow the DOM too. Content portaled from inside a\n * focus trap is no longer inside the trapped element, so the trap neither\n * reaches it nor holds focus there: render nested overlays inside the\n * trapped element, or give them a trap of their own. To trap portaled\n * content, put `useFocusTrap`'s ref on the element inside the `Portal`.\n *\n * @function\n * @param {PortalProps} props - Props for the Portal component.\n * @returns The portal, the children in place when `disabled`, or nothing\n * before hydration.\n *\n * @example\n * <Portal>\n * <div className=\"box\">Rendered at the end of document.body</div>\n * </Portal>\n *\n * @example\n * // Into a dedicated overlay root\n * <Portal container=\"#overlays\">\n * <CommandPalette />\n * </Portal>\n */\nexport function Portal({ children, container, disabled = false }: PortalProps) {\n const hydrated = useIsHydrated();\n const resolveContainer = usePortalContainer();\n if (disabled) return <>{children}</>;\n if (!hydrated) return null;\n return createPortal(children, resolveContainer(container));\n}\n"],"names":["_jsx","_Fragment"],"mappings":";;;;;;AAKA;;;;;;;;;;;;;AAaG;AACG,SAAU,sBAAsB,CACpC,SAAgC,EAAA;IAEhC,IAAI,CAAC,SAAS,EAAE;QACd,OAAO,QAAQ,CAAC,IAAI;IACtB;AACA,IAAA,IAAI,OAAO,SAAS,KAAK,QAAQ,EAAE;AACjC,QAAA,QACG,QAAQ,CAAC,aAAa,CAAC,SAAS,CAAwB,IAAI,QAAQ,CAAC,IAAI;IAE9E;AACA,IAAA,OAAO,SAAS;AAClB;AAEA;;;;;;;;;;;;;;AAcG;SACa,kBAAkB,GAAA;AAGhC,IAAA,MAAM,EAAE,eAAe,EAAE,GAAG,SAAS,EAAE;IACvC,OAAO,SAAS,IAAI,sBAAsB,CAAC,SAAS,IAAI,eAAe,CAAC;AAC1E;AA6BA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCG;AACG,SAAU,MAAM,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,GAAG,KAAK,EAAe,EAAA;AAC3E,IAAA,MAAM,QAAQ,GAAG,aAAa,EAAE;AAChC,IAAA,MAAM,gBAAgB,GAAG,kBAAkB,EAAE;AAC7C,IAAA,IAAI,QAAQ;QAAE,OAAOA,GAAA,CAAAC,QAAA,EAAA,EAAA,QAAA,EAAG,QAAQ,EAAA,CAAI;AACpC,IAAA,IAAI,CAAC,QAAQ;AAAE,QAAA,OAAO,IAAI;IAC1B,OAAO,YAAY,CAAC,QAAQ,EAAE,gBAAgB,CAAC,SAAS,CAAC,CAAC;AAC5D;;"}
@@ -36,6 +36,7 @@ const isDetailsSummary = (el) => el.parentElement?.localName === 'details' &&
36
36
  * can read `-1` for an editable region or an `<embed>` that Tab still visits,
37
37
  * and `0` for a `<video>` without controls that it doesn't. So a valid
38
38
  * `tabindex` attribute decides, and otherwise the element's kind does.
39
+ * Internal like `firstTabStop`: `src/index.ts` names what it takes from here.
39
40
  */
40
41
  function isTabbableKind(el) {
41
42
  const tabindex = el.getAttribute('tabindex');
@@ -466,5 +467,5 @@ function useFocusTrap(containerRef, options = {}) {
466
467
  });
467
468
  }
468
469
 
469
- export { firstTabStop, useFocusTrap };
470
+ export { firstTabStop, isTabbableKind, useFocusTrap };
470
471
  //# sourceMappingURL=useFocusTrap.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useFocusTrap.js","sources":["../../../src/helpers/useFocusTrap.ts"],"sourcesContent":["import { useEffect, useRef, useState } from 'react';\nimport type { RefObject } from 'react';\nimport { useIsHydrated } from './useIsHydrated';\nimport { getDeepestActiveElement } from './shadowDom';\n\n/**\n * Whether `el` is editable while its parent is not, which makes it an editing\n * host: the one tab stop an editable region gets. `contenteditable=\"false\"`\n * turns editing off, and a missing or unknown value inherits the parent's.\n */\nfunction isEditingHost(el: Element): boolean {\n const editable = (node: Element): boolean | null => {\n const value = node.getAttribute('contenteditable')?.toLowerCase();\n if (value === undefined) return null;\n if (value === '' || value === 'true' || value === 'plaintext-only') {\n return true;\n }\n return value === 'false' ? false : null;\n };\n if (editable(el) !== true) return false;\n for (let node = el.parentElement; node; node = node.parentElement) {\n const state = editable(node);\n if (state !== null) return !state;\n }\n return true;\n}\n\n/** Whether `el` is the summary of its `<details>`: the first one, not a stray. */\nconst isDetailsSummary = (el: Element): boolean =>\n el.parentElement?.localName === 'details' &&\n Array.from(el.parentElement.children).find(\n child => child.localName === 'summary'\n ) === el;\n\n/**\n * Whether the browser puts `el` in the tab order, before anything that hides\n * or disables it. The `tabIndex` property can't answer this on its own: it\n * can read `-1` for an editable region or an `<embed>` that Tab still visits,\n * and `0` for a `<video>` without controls that it doesn't. So a valid\n * `tabindex` attribute decides, and otherwise the element's kind does.\n */\nfunction isTabbableKind(el: Element): boolean {\n const tabindex = el.getAttribute('tabindex');\n if (tabindex !== null && /^\\s*[+-]?\\d/.test(tabindex)) {\n return (el as HTMLElement).tabIndex >= 0;\n }\n switch (el.localName) {\n case 'a':\n case 'area':\n return el.hasAttribute('href');\n case 'input':\n return (el as HTMLInputElement).type !== 'hidden';\n case 'button':\n case 'select':\n case 'textarea':\n case 'iframe':\n case 'embed':\n case 'object':\n return true;\n case 'audio':\n case 'video':\n return el.hasAttribute('controls');\n case 'summary':\n return isDetailsSummary(el);\n default:\n return isEditingHost(el);\n }\n}\n\n/**\n * The node's parent in the flattened tree, the one the browser renders and\n * tabs through: the slot it is assigned to, else its parent, else the host of\n * the shadow root it tops, and nothing above the document. A closed shadow\n * root hides its slots (`assignedSlot` reads `null` under one), so a child of\n * its host goes straight to the host, whether a slot takes it or not.\n */\nconst flatParent = (node: Node): Node | null =>\n (node as Element).assignedSlot ??\n node.parentElement ??\n (node.parentNode as ShadowRoot | null)?.host ??\n null;\n\n/**\n * The element's children in the flattened tree, in the order they render: a\n * host's shadow root content, a slot's assigned elements (or its fallback\n * content when nothing is assigned), anything else's own children. A host\n * whose shadow root is closed has no root to read, so its own children stand\n * in, including any that no slot takes and that aren't rendered.\n */\nfunction flatChildren(el: Element): Element[] {\n if (el.shadowRoot) return Array.from(el.shadowRoot.children);\n if (el.localName === 'slot') {\n const assigned = (el as HTMLSlotElement).assignedNodes();\n if (assigned.length > 0) {\n return assigned.filter(\n (node): node is Element => node.nodeType === Node.ELEMENT_NODE\n );\n }\n }\n return Array.from(el.children);\n}\n\nconst isShown = (el: Element): boolean =>\n !el.hasAttribute('inert') && getComputedStyle(el).display !== 'none';\n\nconst isVisible = (el: Element): boolean => {\n const { visibility } = getComputedStyle(el);\n return visibility !== 'hidden' && visibility !== 'collapse';\n};\n\n/**\n * Whether nothing from `el` up to `top` hides it: `inert`, `display: none`\n * (not inherited, so each element is checked) or a closed `<details>` it\n * isn't the summary of. `top` itself isn't checked, and `null` walks to the\n * top of the page.\n */\nfunction isShownUpTo(el: Element, top: Node | null): boolean {\n let below: Element | null = null;\n for (\n let node: Element | null = el;\n node && node !== top;\n node = flatParent(node) as Element | null\n ) {\n if (!isShown(node)) return false;\n if (\n below &&\n node.localName === 'details' &&\n !node.hasAttribute('open') &&\n !isDetailsSummary(below)\n ) {\n return false;\n }\n below = node;\n }\n return true;\n}\n\n/**\n * The images that use the image map `area` belongs to. An image names its\n * map with `usemap=\"#…\"`, matching the map's `name` or `id`.\n */\nfunction imagesUsingMapOf(area: Element): Element[] {\n const map = area.closest('map');\n if (!map) return [];\n const names = [map.getAttribute('name'), map.id].filter(name => name);\n return Array.from(\n (area.getRootNode() as ParentNode).querySelectorAll('img[usemap]')\n ).filter(img => {\n const ref = img.getAttribute('usemap') as string;\n return ref.startsWith('#') && names.includes(ref.slice(1));\n });\n}\n\n/**\n * Whether an image map area is shown. An area has no box of its own: the\n * HTML rendering rules give it `display: none`, though a browser may not\n * report that. So it counts where an image using its map is shown, as long\n * as nothing makes it inert.\n */\nfunction isAreaShown(area: Element, container: Element): boolean {\n for (\n let node: Element | null = area;\n node && node !== container;\n node = flatParent(node) as Element | null\n ) {\n if (node.hasAttribute('inert')) return false;\n }\n return imagesUsingMapOf(area).some(\n img => isShownUpTo(img, null) && isVisible(img)\n );\n}\n\n/**\n * Whether Tab can land on `el`, one of the kinds it visits. A disabled control\n * (including one inside a disabled `<fieldset>`), an inert subtree and\n * anything not rendered are skipped. `visibility` is inherited, so the\n * element's own computed value covers its ancestors.\n */\nfunction isRenderedAndEnabled(el: Element, container: Element): boolean {\n if (el.matches(':disabled')) return false;\n if (el.localName === 'area') return isAreaShown(el, container);\n return isShownUpTo(el, container) && isVisible(el);\n}\n\n/** A radio button with a name, which shares one tab stop with its group. */\nconst isGroupedRadio = (el: Element): el is HTMLInputElement =>\n el.localName === 'input' &&\n (el as HTMLInputElement).type === 'radio' &&\n (el as HTMLInputElement).name !== '';\n\n/** Whether two radio buttons are in one group: same name, form owner and tree. */\nconst sameGroup = (a: HTMLInputElement, b: Element): b is HTMLInputElement =>\n isGroupedRadio(b) &&\n b.name === a.name &&\n b.form === a.form &&\n b.getRootNode() === a.getRootNode();\n\n/**\n * The checked button of `radio`'s group. The group isn't bounded by the trap,\n * so this looks through the radio's whole tree.\n */\nconst checkedInGroup = (radio: HTMLInputElement): Element | undefined =>\n Array.from(\n (radio.getRootNode() as ParentNode).querySelectorAll('input:checked')\n ).find(el => sameGroup(radio, el));\n\n/** The flattened-tree ancestors of `node` below the container, outermost first, then `node`. */\nfunction flatChain(node: Node, container: Node): Node[] {\n const chain: Node[] = [];\n for (let n: Node | null = node; n && n !== container; n = flatParent(n)) {\n chain.unshift(n);\n }\n return chain;\n}\n\n/**\n * Whether `node` is inside the container in the flattened tree: in it, in a\n * shadow root it holds, or slotted into it. A child of a closed-root host\n * counts as inside wherever the host is, as its slot can't be seen.\n */\nfunction inside(container: Node, node: Node): boolean {\n for (let n: Node | null = node; n; n = flatParent(n)) {\n if (n === container) return true;\n }\n return false;\n}\n\n/**\n * `true` when Tab reaches `b` after `a`, which is their order in the\n * flattened tree: a shadow host comes before its shadow root's content, and\n * slotted content comes where its slot is. A closed root's slots can't be\n * seen, so its host's children keep their place in the light DOM. Two\n * flattened-tree siblings are always in one DOM tree, so their document\n * position decides between them.\n */\nfunction follows(container: Element, a: Node, b: Node): boolean {\n const chainA = flatChain(a, container);\n const chainB = flatChain(b, container);\n for (let i = 0; i < Math.max(chainA.length, chainB.length); i++) {\n const [x, y] = [chainA[i], chainB[i]];\n if (x === y) continue;\n if (!x) return true;\n if (!y) return false;\n return Boolean(\n x.compareDocumentPosition(y) & Node.DOCUMENT_POSITION_FOLLOWING\n );\n }\n return false;\n}\n\n/**\n * Every element of a tabbable kind under `el` in the flattened tree, depth\n * first, which is the order Tab visits them. Under a host whose shadow root\n * is closed, that takes in the host's own children instead, rendered or not.\n */\nfunction collectCandidates(\n el: Element,\n out: HTMLElement[] = []\n): HTMLElement[] {\n for (const child of flatChildren(el)) {\n if (isTabbableKind(child)) out.push(child as HTMLElement);\n collectCandidates(child, out);\n }\n return out;\n}\n\ninterface TabStops {\n first: HTMLElement;\n last: HTMLElement;\n /** The stop that stands for `node`: its group's stop for a radio button. */\n stopFor(node: Element): Element;\n}\n\n/**\n * The first and last tab stops inside `container`, or `null` when there are\n * none. Only the ends matter for wrapping, so the style checks run from each\n * end until they find a stop rather than over every candidate.\n *\n * A radio group is one stop, the way the browser treats it: its checked\n * button, or its first when none is checked. Counting every button would make\n * the group's last one an end, and Tab from the checked one would leave. The\n * group goes by name, form owner and tree, not by the trap, so a checked\n * button outside the container that Tab can land on leaves the group no stop\n * inside. One that Tab can't land on leaves the group as if none were checked.\n */\nfunction findTabStops(container: HTMLElement): TabStops | null {\n const candidates = collectCandidates(container);\n const checked = new Map<Element, boolean>();\n const usable = (el: Element): boolean => {\n let ok = checked.get(el);\n if (ok === undefined) {\n ok = isRenderedAndEnabled(el, container);\n checked.set(el, ok);\n }\n return ok;\n };\n // Resolved once per group, filed under each of its buttons, since finding\n // the checked one scans the radio's whole tree.\n const groupStops = new Map<Element, HTMLElement | undefined>();\n const groupStop = (radio: HTMLInputElement): HTMLElement | undefined => {\n if (groupStops.has(radio)) return groupStops.get(radio);\n const group = candidates.filter(el => sameGroup(radio, el));\n const on = checkedInGroup(radio);\n const stop =\n on && isTabbableKind(on) && usable(on)\n ? group.find(el => el === on)\n : group.find(usable);\n for (const el of [radio, ...group]) groupStops.set(el, stop);\n return stop;\n };\n const isStop = (el: HTMLElement): boolean =>\n usable(el) && (!isGroupedRadio(el) || groupStop(el) === el);\n\n const first = candidates.find(isStop);\n if (!first) return null;\n let last = first;\n for (let i = candidates.length - 1; candidates[i] !== first; i--) {\n if (isStop(candidates[i])) {\n last = candidates[i];\n break;\n }\n }\n return {\n first,\n last,\n stopFor: node => (isGroupedRadio(node) && groupStop(node)) || node,\n };\n}\n\n/**\n * The first tab stop inside `container`, found the way the trap finds it, or\n * `null` when there is none. For a component that moves focus into a panel\n * without trapping it there. `src/index.ts` names its exports from this\n * module, so this one stays internal.\n */\nexport function firstTabStop(container: HTMLElement): HTMLElement | null {\n return findTabStops(container)?.first ?? null;\n}\n\n/**\n * The element that has focus in the container's own document (an iframe's,\n * when it renders into one), inside open shadow roots too. Focus inside a\n * closed one reads as its host, which the comparisons above place like any\n * other element. Browsers fall back to <body> when nothing has\n * focus. jsdom, where consumers run their tests, reports nothing once focus\n * was inside a shadow root that was removed, so this falls back for it.\n */\nconst focusedElement = (doc: Document): Element =>\n getDeepestActiveElement(doc) ?? doc.body;\n\n/**\n * Options for `useFocusTrap`.\n */\nexport interface UseFocusTrapOptions {\n /**\n * Whether the trap is on. Turning it on moves focus into the container;\n * turning it off (or unmounting) releases Tab and restores focus.\n * @defaultValue true\n */\n active?: boolean;\n /**\n * The element inside the container to focus when the trap turns on. It has\n * to be one that can take focus, so a heading needs `tabIndex={-1}`. When\n * focusing it doesn't put focus inside the container (the ref is empty, or\n * its element is outside, disabled, hidden or can't take focus), focus goes\n * to the first tab stop inside the container, and to the container itself\n * when there is none.\n */\n initialFocusRef?: RefObject<HTMLElement | null>;\n /**\n * Where focus goes when the trap turns off. `true` returns it to the element\n * that had focus when the trap turned on; a ref sends it to that element\n * instead; `false` leaves it alone. Focus is only moved while the trap still\n * holds it, so a click that already put focus somewhere else outside the\n * container keeps it there.\n *\n * `true` reads focus after the container's content has mounted, so content\n * that focuses itself as it mounts (an `autoFocus` input) hides the element\n * that opened it. And some browsers don't focus a button when it is\n * clicked. For a panel opened from a button, pass the button's ref.\n * @defaultValue true\n */\n restoreFocus?: boolean | RefObject<HTMLElement | null>;\n}\n\n/**\n * Keeps keyboard focus inside a container while it is active: focus moves in\n * when the trap turns on, Tab and Shift+Tab wrap between the first and last\n * tab stops, and focus goes back where it came from when the trap turns off.\n *\n * Tab stops are what the browser's Tab visits, in document order: links,\n * form controls, frames, media with controls, a `<details>` summary, editable\n * regions, anything with `tabIndex={0}`, and the content of open shadow\n * roots. Hidden, disabled, inert and `tabIndex={-1}` elements are skipped,\n * and a radio group counts once. Give the container `tabIndex={-1}` so it can\n * hold focus itself when nothing inside can. The trap listens on the\n * container, so a trap nested inside another handles Tab first and the outer\n * one stands aside.\n *\n * The trap is about Tab. If a Tab it let through still takes focus out (a\n * browser can leave out a stop the page has, such as links when its settings\n * say to), it sends focus back to the other end. A pointer or a script moving\n * focus out is left alone, because pulling focus back from a click is modal\n * behaviour, and a modal also has to block the page behind it, which `Modal`\n * does. Content the container renders through a portal lives elsewhere in\n * the DOM, so it is outside the trap: render nested overlays inside the\n * container, or give them a trap of their own. To trap content a `Portal`\n * renders, pass a ref to the element inside the `Portal` as `containerRef`.\n *\n * The trap looks at `containerRef` again each time the component calling it\n * renders. A container that mounts after the trap turns on, such as a panel\n * waiting for a `Portal` target held in state, has it attach once that\n * component renders with the container in the DOM. When the container leaves\n * or is replaced, the trap lets go of it as it would turning off, handing\n * focus back, and attaches to the next one.\n * A child that mounts the container in a render of its own (from its own\n * state, or as a `Suspense` boundary resolves) goes unseen until the\n * component calling the hook renders again. The trap waits for hydration, so\n * that component renders again when the page hydrates, and portaled content,\n * which first appears then, is found.\n *\n * @function useFocusTrap\n * @param containerRef - Ref to the element focus stays inside.\n * @param options - When the trap is on, and where focus starts and ends.\n *\n * @example\n * const panelRef = useRef<HTMLDivElement>(null);\n * useFocusTrap(panelRef, { active: isOpen });\n * return isOpen ? (\n * <div ref={panelRef} role=\"dialog\" aria-label=\"Filters\" tabIndex={-1}>\n * …\n * </div>\n * ) : null;\n */\nexport function useFocusTrap(\n containerRef: RefObject<HTMLElement | null>,\n options: UseFocusTrapOptions = {}\n): void {\n const { active = true, initialFocusRef, restoreFocus = true } = options;\n // Portaled content has no server-rendered counterpart, so a portaled\n // container only exists from the commit after hydration.\n const hydrated = useIsHydrated();\n // The container the trap is attached to, or `null` while it has none.\n const heldRef = useRef<HTMLElement | null>(null);\n // Bumped to run the trap again when the container in the ref changes.\n const [refChanges, setRefChanges] = useState(0);\n\n useEffect(() => {\n heldRef.current = null;\n if (!active || !hydrated) return undefined;\n const container = containerRef.current;\n if (!container) return undefined;\n heldRef.current = container;\n const doc = container.ownerDocument;\n\n const opener = focusedElement(doc) as HTMLElement;\n\n // `initialFocusRef` counts only when focusing it puts focus inside. Focus\n // put outside would stay out, as Tab there never reaches the container's\n // listener, and focusing something that can't take focus (a heading\n // without `tabIndex`, a disabled control) leaves focus where it was.\n const initial = initialFocusRef?.current;\n const inTrap = initial && inside(container, initial) ? initial : null;\n inTrap?.focus();\n if (!inTrap || !inside(container, focusedElement(doc))) {\n (findTabStops(container)?.first ?? container).focus();\n }\n\n // Where focus goes if a Tab the trap let the browser handle takes it out,\n // held until that Tab has finished moving focus.\n let wrapTo: HTMLElement | null = null;\n let wrapTimer: ReturnType<typeof setTimeout> | undefined;\n\n const handleKeyDown = (e: KeyboardEvent) => {\n // A trap nested inside this one has already wrapped focus.\n if (e.key !== 'Tab' || e.defaultPrevented) return;\n const stops = findTabStops(container);\n if (!stops) {\n e.preventDefault();\n container.focus();\n return;\n }\n const current = stops.stopFor(focusedElement(doc));\n // Wrap whenever the browser has no stop left in that direction inside\n // the container. Comparing positions rather than testing `=== first`\n // also covers focus resting on the container or on an element outside\n // the tab order, which the browser would otherwise walk straight out of.\n if (\n e.shiftKey\n ? !follows(container, stops.first, current)\n : !follows(container, current, stops.last)\n ) {\n e.preventDefault();\n (e.shiftKey ? stops.last : stops.first).focus();\n return;\n }\n wrapTo = e.shiftKey ? stops.last : stops.first;\n clearTimeout(wrapTimer);\n wrapTimer = setTimeout(() => {\n wrapTo = null;\n });\n };\n\n // The browser moves focus as soon as the keydown is over, so focus that\n // lands outside while `wrapTo` is set got there by that Tab.\n const handleFocusIn = (e: FocusEvent) => {\n if (!wrapTo || inside(container, e.composedPath()[0] as Node)) return;\n const target = wrapTo;\n wrapTo = null;\n target.focus();\n };\n\n container.addEventListener('keydown', handleKeyDown);\n doc.addEventListener('focusin', handleFocusIn, true);\n return () => {\n container.removeEventListener('keydown', handleKeyDown);\n doc.removeEventListener('focusin', handleFocusIn, true);\n clearTimeout(wrapTimer);\n let target = restoreFocus ? opener : null;\n // `null` is an object too, and a caller without types can pass it.\n if (restoreFocus && typeof restoreFocus === 'object') {\n // Read now rather than when the trap turned on: a trigger that\n // re-mounted in between has a new node.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n target = restoreFocus.current;\n }\n // Hand focus back only while the trap still holds it: inside the\n // container, or dropped to <body> because the container left the page.\n const now = focusedElement(doc);\n if (target && (now === doc.body || inside(container, now))) {\n target.focus();\n }\n };\n }, [\n active,\n hydrated,\n containerRef,\n initialFocusRef,\n restoreFocus,\n refChanges,\n ]);\n\n // Nothing says when a ref is set, so after every render, a ref that no\n // longer matches what the trap holds (a container that mounted, left or was\n // replaced) runs it again. Effects run in order, so whenever the effect\n // above ran in this commit, it read the ref just before this does, and a\n // mismatch means the ref changed in a render it didn't run for. The render\n // a bump asks for runs it, so the two match and the trap settles. An empty\n // ref matches a trap holding nothing, so a container that never mounts\n // costs no render.\n // eslint-disable-next-line react-hooks/exhaustive-deps -- after every render on purpose\n useEffect(() => {\n if (active && hydrated && containerRef.current !== heldRef.current) {\n setRefChanges(n => n + 1);\n }\n });\n}\n"],"names":[],"mappings":";;;;;AAKA;;;;AAIG;AACH,SAAS,aAAa,CAAC,EAAW,EAAA;AAChC,IAAA,MAAM,QAAQ,GAAG,CAAC,IAAa,KAAoB;QACjD,MAAM,KAAK,GAAG,IA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UAAU;AACX,KAAA,CAAC;;;;;;;;;;IAWF,SAAS,CAAC,MAAK;AACb,QAAA,IAAI,MAAM,IAAI,QAAQ,IAAI,YAAY,CAAC,OAAO,KAAK,OAAO,CAAC,OAAO,EAAE;YAClE,aAAa,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC3B;AACF,IAAA,CAAC,CAAC;AACJ;;"}
1
+ {"version":3,"file":"useFocusTrap.js","sources":["../../../src/helpers/useFocusTrap.ts"],"sourcesContent":["import { useEffect, useRef, useState } from 'react';\nimport type { RefObject } from 'react';\nimport { useIsHydrated } from './useIsHydrated';\nimport { getDeepestActiveElement } from './shadowDom';\n\n/**\n * Whether `el` is editable while its parent is not, which makes it an editing\n * host: the one tab stop an editable region gets. `contenteditable=\"false\"`\n * turns editing off, and a missing or unknown value inherits the parent's.\n */\nfunction isEditingHost(el: Element): boolean {\n const editable = (node: Element): boolean | null => {\n const value = node.getAttribute('contenteditable')?.toLowerCase();\n if (value === undefined) return null;\n if (value === '' || value === 'true' || value === 'plaintext-only') {\n return true;\n }\n return value === 'false' ? false : null;\n };\n if (editable(el) !== true) return false;\n for (let node = el.parentElement; node; node = node.parentElement) {\n const state = editable(node);\n if (state !== null) return !state;\n }\n return true;\n}\n\n/** Whether `el` is the summary of its `<details>`: the first one, not a stray. */\nconst isDetailsSummary = (el: Element): boolean =>\n el.parentElement?.localName === 'details' &&\n Array.from(el.parentElement.children).find(\n child => child.localName === 'summary'\n ) === el;\n\n/**\n * Whether the browser puts `el` in the tab order, before anything that hides\n * or disables it. The `tabIndex` property can't answer this on its own: it\n * can read `-1` for an editable region or an `<embed>` that Tab still visits,\n * and `0` for a `<video>` without controls that it doesn't. So a valid\n * `tabindex` attribute decides, and otherwise the element's kind does.\n * Internal like `firstTabStop`: `src/index.ts` names what it takes from here.\n */\nexport function isTabbableKind(el: Element): boolean {\n const tabindex = el.getAttribute('tabindex');\n if (tabindex !== null && /^\\s*[+-]?\\d/.test(tabindex)) {\n return (el as HTMLElement).tabIndex >= 0;\n }\n switch (el.localName) {\n case 'a':\n case 'area':\n return el.hasAttribute('href');\n case 'input':\n return (el as HTMLInputElement).type !== 'hidden';\n case 'button':\n case 'select':\n case 'textarea':\n case 'iframe':\n case 'embed':\n case 'object':\n return true;\n case 'audio':\n case 'video':\n return el.hasAttribute('controls');\n case 'summary':\n return isDetailsSummary(el);\n default:\n return isEditingHost(el);\n }\n}\n\n/**\n * The node's parent in the flattened tree, the one the browser renders and\n * tabs through: the slot it is assigned to, else its parent, else the host of\n * the shadow root it tops, and nothing above the document. A closed shadow\n * root hides its slots (`assignedSlot` reads `null` under one), so a child of\n * its host goes straight to the host, whether a slot takes it or not.\n */\nconst flatParent = (node: Node): Node | null =>\n (node as Element).assignedSlot ??\n node.parentElement ??\n (node.parentNode as ShadowRoot | null)?.host ??\n null;\n\n/**\n * The element's children in the flattened tree, in the order they render: a\n * host's shadow root content, a slot's assigned elements (or its fallback\n * content when nothing is assigned), anything else's own children. A host\n * whose shadow root is closed has no root to read, so its own children stand\n * in, including any that no slot takes and that aren't rendered.\n */\nfunction flatChildren(el: Element): Element[] {\n if (el.shadowRoot) return Array.from(el.shadowRoot.children);\n if (el.localName === 'slot') {\n const assigned = (el as HTMLSlotElement).assignedNodes();\n if (assigned.length > 0) {\n return assigned.filter(\n (node): node is Element => node.nodeType === Node.ELEMENT_NODE\n );\n }\n }\n return Array.from(el.children);\n}\n\nconst isShown = (el: Element): boolean =>\n !el.hasAttribute('inert') && getComputedStyle(el).display !== 'none';\n\nconst isVisible = (el: Element): boolean => {\n const { visibility } = getComputedStyle(el);\n return visibility !== 'hidden' && visibility !== 'collapse';\n};\n\n/**\n * Whether nothing from `el` up to `top` hides it: `inert`, `display: none`\n * (not inherited, so each element is checked) or a closed `<details>` it\n * isn't the summary of. `top` itself isn't checked, and `null` walks to the\n * top of the page.\n */\nfunction isShownUpTo(el: Element, top: Node | null): boolean {\n let below: Element | null = null;\n for (\n let node: Element | null = el;\n node && node !== top;\n node = flatParent(node) as Element | null\n ) {\n if (!isShown(node)) return false;\n if (\n below &&\n node.localName === 'details' &&\n !node.hasAttribute('open') &&\n !isDetailsSummary(below)\n ) {\n return false;\n }\n below = node;\n }\n return true;\n}\n\n/**\n * The images that use the image map `area` belongs to. An image names its\n * map with `usemap=\"#…\"`, matching the map's `name` or `id`.\n */\nfunction imagesUsingMapOf(area: Element): Element[] {\n const map = area.closest('map');\n if (!map) return [];\n const names = [map.getAttribute('name'), map.id].filter(name => name);\n return Array.from(\n (area.getRootNode() as ParentNode).querySelectorAll('img[usemap]')\n ).filter(img => {\n const ref = img.getAttribute('usemap') as string;\n return ref.startsWith('#') && names.includes(ref.slice(1));\n });\n}\n\n/**\n * Whether an image map area is shown. An area has no box of its own: the\n * HTML rendering rules give it `display: none`, though a browser may not\n * report that. So it counts where an image using its map is shown, as long\n * as nothing makes it inert.\n */\nfunction isAreaShown(area: Element, container: Element): boolean {\n for (\n let node: Element | null = area;\n node && node !== container;\n node = flatParent(node) as Element | null\n ) {\n if (node.hasAttribute('inert')) return false;\n }\n return imagesUsingMapOf(area).some(\n img => isShownUpTo(img, null) && isVisible(img)\n );\n}\n\n/**\n * Whether Tab can land on `el`, one of the kinds it visits. A disabled control\n * (including one inside a disabled `<fieldset>`), an inert subtree and\n * anything not rendered are skipped. `visibility` is inherited, so the\n * element's own computed value covers its ancestors.\n */\nfunction isRenderedAndEnabled(el: Element, container: Element): boolean {\n if (el.matches(':disabled')) return false;\n if (el.localName === 'area') return isAreaShown(el, container);\n return isShownUpTo(el, container) && isVisible(el);\n}\n\n/** A radio button with a name, which shares one tab stop with its group. */\nconst isGroupedRadio = (el: Element): el is HTMLInputElement =>\n el.localName === 'input' &&\n (el as HTMLInputElement).type === 'radio' &&\n (el as HTMLInputElement).name !== '';\n\n/** Whether two radio buttons are in one group: same name, form owner and tree. */\nconst sameGroup = (a: HTMLInputElement, b: Element): b is HTMLInputElement =>\n isGroupedRadio(b) &&\n b.name === a.name &&\n b.form === a.form &&\n b.getRootNode() === a.getRootNode();\n\n/**\n * The checked button of `radio`'s group. The group isn't bounded by the trap,\n * so this looks through the radio's whole tree.\n */\nconst checkedInGroup = (radio: HTMLInputElement): Element | undefined =>\n Array.from(\n (radio.getRootNode() as ParentNode).querySelectorAll('input:checked')\n ).find(el => sameGroup(radio, el));\n\n/** The flattened-tree ancestors of `node` below the container, outermost first, then `node`. */\nfunction flatChain(node: Node, container: Node): Node[] {\n const chain: Node[] = [];\n for (let n: Node | null = node; n && n !== container; n = flatParent(n)) {\n chain.unshift(n);\n }\n return chain;\n}\n\n/**\n * Whether `node` is inside the container in the flattened tree: in it, in a\n * shadow root it holds, or slotted into it. A child of a closed-root host\n * counts as inside wherever the host is, as its slot can't be seen.\n */\nfunction inside(container: Node, node: Node): boolean {\n for (let n: Node | null = node; n; n = flatParent(n)) {\n if (n === container) return true;\n }\n return false;\n}\n\n/**\n * `true` when Tab reaches `b` after `a`, which is their order in the\n * flattened tree: a shadow host comes before its shadow root's content, and\n * slotted content comes where its slot is. A closed root's slots can't be\n * seen, so its host's children keep their place in the light DOM. Two\n * flattened-tree siblings are always in one DOM tree, so their document\n * position decides between them.\n */\nfunction follows(container: Element, a: Node, b: Node): boolean {\n const chainA = flatChain(a, container);\n const chainB = flatChain(b, container);\n for (let i = 0; i < Math.max(chainA.length, chainB.length); i++) {\n const [x, y] = [chainA[i], chainB[i]];\n if (x === y) continue;\n if (!x) return true;\n if (!y) return false;\n return Boolean(\n x.compareDocumentPosition(y) & Node.DOCUMENT_POSITION_FOLLOWING\n );\n }\n return false;\n}\n\n/**\n * Every element of a tabbable kind under `el` in the flattened tree, depth\n * first, which is the order Tab visits them. Under a host whose shadow root\n * is closed, that takes in the host's own children instead, rendered or not.\n */\nfunction collectCandidates(\n el: Element,\n out: HTMLElement[] = []\n): HTMLElement[] {\n for (const child of flatChildren(el)) {\n if (isTabbableKind(child)) out.push(child as HTMLElement);\n collectCandidates(child, out);\n }\n return out;\n}\n\ninterface TabStops {\n first: HTMLElement;\n last: HTMLElement;\n /** The stop that stands for `node`: its group's stop for a radio button. */\n stopFor(node: Element): Element;\n}\n\n/**\n * The first and last tab stops inside `container`, or `null` when there are\n * none. Only the ends matter for wrapping, so the style checks run from each\n * end until they find a stop rather than over every candidate.\n *\n * A radio group is one stop, the way the browser treats it: its checked\n * button, or its first when none is checked. Counting every button would make\n * the group's last one an end, and Tab from the checked one would leave. The\n * group goes by name, form owner and tree, not by the trap, so a checked\n * button outside the container that Tab can land on leaves the group no stop\n * inside. One that Tab can't land on leaves the group as if none were checked.\n */\nfunction findTabStops(container: HTMLElement): TabStops | null {\n const candidates = collectCandidates(container);\n const checked = new Map<Element, boolean>();\n const usable = (el: Element): boolean => {\n let ok = checked.get(el);\n if (ok === undefined) {\n ok = isRenderedAndEnabled(el, container);\n checked.set(el, ok);\n }\n return ok;\n };\n // Resolved once per group, filed under each of its buttons, since finding\n // the checked one scans the radio's whole tree.\n const groupStops = new Map<Element, HTMLElement | undefined>();\n const groupStop = (radio: HTMLInputElement): HTMLElement | undefined => {\n if (groupStops.has(radio)) return groupStops.get(radio);\n const group = candidates.filter(el => sameGroup(radio, el));\n const on = checkedInGroup(radio);\n const stop =\n on && isTabbableKind(on) && usable(on)\n ? group.find(el => el === on)\n : group.find(usable);\n for (const el of [radio, ...group]) groupStops.set(el, stop);\n return stop;\n };\n const isStop = (el: HTMLElement): boolean =>\n usable(el) && (!isGroupedRadio(el) || groupStop(el) === el);\n\n const first = candidates.find(isStop);\n if (!first) return null;\n let last = first;\n for (let i = candidates.length - 1; candidates[i] !== first; i--) {\n if (isStop(candidates[i])) {\n last = candidates[i];\n break;\n }\n }\n return {\n first,\n last,\n stopFor: node => (isGroupedRadio(node) && groupStop(node)) || node,\n };\n}\n\n/**\n * The first tab stop inside `container`, found the way the trap finds it, or\n * `null` when there is none. For a component that moves focus into a panel\n * without trapping it there. `src/index.ts` names its exports from this\n * module, so this one stays internal.\n */\nexport function firstTabStop(container: HTMLElement): HTMLElement | null {\n return findTabStops(container)?.first ?? null;\n}\n\n/**\n * The element that has focus in the container's own document (an iframe's,\n * when it renders into one), inside open shadow roots too. Focus inside a\n * closed one reads as its host, which the comparisons above place like any\n * other element. Browsers fall back to <body> when nothing has\n * focus. jsdom, where consumers run their tests, reports nothing once focus\n * was inside a shadow root that was removed, so this falls back for it.\n */\nconst focusedElement = (doc: Document): Element =>\n getDeepestActiveElement(doc) ?? doc.body;\n\n/**\n * Options for `useFocusTrap`.\n */\nexport interface UseFocusTrapOptions {\n /**\n * Whether the trap is on. Turning it on moves focus into the container;\n * turning it off (or unmounting) releases Tab and restores focus.\n * @defaultValue true\n */\n active?: boolean;\n /**\n * The element inside the container to focus when the trap turns on. It has\n * to be one that can take focus, so a heading needs `tabIndex={-1}`. When\n * focusing it doesn't put focus inside the container (the ref is empty, or\n * its element is outside, disabled, hidden or can't take focus), focus goes\n * to the first tab stop inside the container, and to the container itself\n * when there is none.\n */\n initialFocusRef?: RefObject<HTMLElement | null>;\n /**\n * Where focus goes when the trap turns off. `true` returns it to the element\n * that had focus when the trap turned on; a ref sends it to that element\n * instead; `false` leaves it alone. Focus is only moved while the trap still\n * holds it, so a click that already put focus somewhere else outside the\n * container keeps it there.\n *\n * `true` reads focus after the container's content has mounted, so content\n * that focuses itself as it mounts (an `autoFocus` input) hides the element\n * that opened it. And some browsers don't focus a button when it is\n * clicked. For a panel opened from a button, pass the button's ref.\n * @defaultValue true\n */\n restoreFocus?: boolean | RefObject<HTMLElement | null>;\n}\n\n/**\n * Keeps keyboard focus inside a container while it is active: focus moves in\n * when the trap turns on, Tab and Shift+Tab wrap between the first and last\n * tab stops, and focus goes back where it came from when the trap turns off.\n *\n * Tab stops are what the browser's Tab visits, in document order: links,\n * form controls, frames, media with controls, a `<details>` summary, editable\n * regions, anything with `tabIndex={0}`, and the content of open shadow\n * roots. Hidden, disabled, inert and `tabIndex={-1}` elements are skipped,\n * and a radio group counts once. Give the container `tabIndex={-1}` so it can\n * hold focus itself when nothing inside can. The trap listens on the\n * container, so a trap nested inside another handles Tab first and the outer\n * one stands aside.\n *\n * The trap is about Tab. If a Tab it let through still takes focus out (a\n * browser can leave out a stop the page has, such as links when its settings\n * say to), it sends focus back to the other end. A pointer or a script moving\n * focus out is left alone, because pulling focus back from a click is modal\n * behaviour, and a modal also has to block the page behind it, which `Modal`\n * does. Content the container renders through a portal lives elsewhere in\n * the DOM, so it is outside the trap: render nested overlays inside the\n * container, or give them a trap of their own. To trap content a `Portal`\n * renders, pass a ref to the element inside the `Portal` as `containerRef`.\n *\n * The trap looks at `containerRef` again each time the component calling it\n * renders. A container that mounts after the trap turns on, such as a panel\n * waiting for a `Portal` target held in state, has it attach once that\n * component renders with the container in the DOM. When the container leaves\n * or is replaced, the trap lets go of it as it would turning off, handing\n * focus back, and attaches to the next one.\n * A child that mounts the container in a render of its own (from its own\n * state, or as a `Suspense` boundary resolves) goes unseen until the\n * component calling the hook renders again. The trap waits for hydration, so\n * that component renders again when the page hydrates, and portaled content,\n * which first appears then, is found.\n *\n * @function useFocusTrap\n * @param containerRef - Ref to the element focus stays inside.\n * @param options - When the trap is on, and where focus starts and ends.\n *\n * @example\n * const panelRef = useRef<HTMLDivElement>(null);\n * useFocusTrap(panelRef, { active: isOpen });\n * return isOpen ? (\n * <div ref={panelRef} role=\"dialog\" aria-label=\"Filters\" tabIndex={-1}>\n * …\n * </div>\n * ) : null;\n */\nexport function useFocusTrap(\n containerRef: RefObject<HTMLElement | null>,\n options: UseFocusTrapOptions = {}\n): void {\n const { active = true, initialFocusRef, restoreFocus = true } = options;\n // Portaled content has no server-rendered counterpart, so a portaled\n // container only exists from the commit after hydration.\n const hydrated = useIsHydrated();\n // The container the trap is attached to, or `null` while it has none.\n const heldRef = useRef<HTMLElement | null>(null);\n // Bumped to run the trap again when the container in the ref changes.\n const [refChanges, setRefChanges] = useState(0);\n\n useEffect(() => {\n heldRef.current = null;\n if (!active || !hydrated) return undefined;\n const container = containerRef.current;\n if (!container) return undefined;\n heldRef.current = container;\n const doc = container.ownerDocument;\n\n const opener = focusedElement(doc) as HTMLElement;\n\n // `initialFocusRef` counts only when focusing it puts focus inside. Focus\n // put outside would stay out, as Tab there never reaches the container's\n // listener, and focusing something that can't take focus (a heading\n // without `tabIndex`, a disabled control) leaves focus where it was.\n const initial = initialFocusRef?.current;\n const inTrap = initial && inside(container, initial) ? initial : null;\n inTrap?.focus();\n if (!inTrap || !inside(container, focusedElement(doc))) {\n (findTabStops(container)?.first ?? container).focus();\n }\n\n // Where focus goes if a Tab the trap let the browser handle takes it out,\n // held until that Tab has finished moving focus.\n let wrapTo: HTMLElement | null = null;\n let wrapTimer: ReturnType<typeof setTimeout> | undefined;\n\n const handleKeyDown = (e: KeyboardEvent) => {\n // A trap nested inside this one has already wrapped focus.\n if (e.key !== 'Tab' || e.defaultPrevented) return;\n const stops = findTabStops(container);\n if (!stops) {\n e.preventDefault();\n container.focus();\n return;\n }\n const current = stops.stopFor(focusedElement(doc));\n // Wrap whenever the browser has no stop left in that direction inside\n // the container. Comparing positions rather than testing `=== first`\n // also covers focus resting on the container or on an element outside\n // the tab order, which the browser would otherwise walk straight out of.\n if (\n e.shiftKey\n ? !follows(container, stops.first, current)\n : !follows(container, current, stops.last)\n ) {\n e.preventDefault();\n (e.shiftKey ? stops.last : stops.first).focus();\n return;\n }\n wrapTo = e.shiftKey ? stops.last : stops.first;\n clearTimeout(wrapTimer);\n wrapTimer = setTimeout(() => {\n wrapTo = null;\n });\n };\n\n // The browser moves focus as soon as the keydown is over, so focus that\n // lands outside while `wrapTo` is set got there by that Tab.\n const handleFocusIn = (e: FocusEvent) => {\n if (!wrapTo || inside(container, e.composedPath()[0] as Node)) return;\n const target = wrapTo;\n wrapTo = null;\n target.focus();\n };\n\n container.addEventListener('keydown', handleKeyDown);\n doc.addEventListener('focusin', handleFocusIn, true);\n return () => {\n container.removeEventListener('keydown', handleKeyDown);\n doc.removeEventListener('focusin', handleFocusIn, true);\n clearTimeout(wrapTimer);\n let target = restoreFocus ? opener : null;\n // `null` is an object too, and a caller without types can pass it.\n if (restoreFocus && typeof restoreFocus === 'object') {\n // Read now rather than when the trap turned on: a trigger that\n // re-mounted in between has a new node.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n target = restoreFocus.current;\n }\n // Hand focus back only while the trap still holds it: inside the\n // container, or dropped to <body> because the container left the page.\n const now = focusedElement(doc);\n if (target && (now === doc.body || inside(container, now))) {\n target.focus();\n }\n };\n }, [\n active,\n hydrated,\n containerRef,\n initialFocusRef,\n restoreFocus,\n refChanges,\n ]);\n\n // Nothing says when a ref is set, so after every render, a ref that no\n // longer matches what the trap holds (a container that mounted, left or was\n // replaced) runs it again. Effects run in order, so whenever the effect\n // above ran in this commit, it read the ref just before this does, and a\n // mismatch means the ref changed in a render it didn't run for. The render\n // a bump asks for runs it, so the two match and the trap settles. An empty\n // ref matches a trap holding nothing, so a container that never mounts\n // costs no render.\n // eslint-disable-next-line react-hooks/exhaustive-deps -- after every render on purpose\n useEffect(() => {\n if (active && hydrated && containerRef.current !== heldRef.current) {\n setRefChanges(n => n + 1);\n }\n });\n}\n"],"names":[],"mappings":";;;;;AAKA;;;;AAIG;AACH,SAAS,aAAa,CAAC,EAAW,EAAA;AAChC,IAAA,MAAM,QAAQ,GAAG,CAAC,IAAa,KAAoB;QACjD,MAAM,KAAK,GAAG,IAAI,CAAC,YAAY,CAAC,iBAAiB,CAAC,EAAE,WAAW,EAAE;QACjE,IAAI,KAAK,KAAK,SAAS;AAAE,YAAA,OAAO,IAAI;AACpC,QAAA,IAAI,KAAK,KAAK,EAAE,IAAI,KAAK,KAAK,MAAM,IAAI,KAAK,KAAK,gBAAgB,EAAE;AAClE,YAAA,OAAO,IAAI;QACb;QACA,OAAO,KAAK,KAAK,OAAO,GAAG,KAAK,GAAG,IAAI;AACzC,IAAA,CAAC;AACD,IAAA,IAAI,QAAQ,CAAC,EAAE,CAAC,KAAK,IAAI;AAAE,QAAA,OAAO,KAAK;AACvC,IAAA,KAAK,IAA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