@navikt/ds-react 6.7.0 → 6.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (211) hide show
  1. package/cjs/chat/Chat.d.ts +2 -1
  2. package/cjs/chat/Chat.js +2 -1
  3. package/cjs/chat/Chat.js.map +1 -1
  4. package/cjs/date/datepicker/parts/DropdownCaption.js +1 -1
  5. package/cjs/date/datepicker/parts/DropdownCaption.js.map +1 -1
  6. package/cjs/date/monthpicker/MonthCaption.js +1 -1
  7. package/cjs/date/utils/labels.d.ts +2 -2
  8. package/cjs/form/ReadOnlyIcon.d.ts +2 -2
  9. package/cjs/form/combobox/Combobox.js +7 -22
  10. package/cjs/form/combobox/Combobox.js.map +1 -1
  11. package/cjs/form/combobox/ComboboxProvider.js +2 -2
  12. package/cjs/form/combobox/ComboboxProvider.js.map +1 -1
  13. package/cjs/form/combobox/ComboboxWrapper.d.ts +1 -2
  14. package/cjs/form/combobox/ComboboxWrapper.js +4 -2
  15. package/cjs/form/combobox/ComboboxWrapper.js.map +1 -1
  16. package/cjs/form/combobox/FilteredOptions/FilteredOptions.js +4 -4
  17. package/cjs/form/combobox/FilteredOptions/FilteredOptions.js.map +1 -1
  18. package/cjs/form/combobox/FilteredOptions/filteredOptionsContext.d.ts +4 -4
  19. package/cjs/form/combobox/FilteredOptions/filteredOptionsContext.js +13 -15
  20. package/cjs/form/combobox/FilteredOptions/filteredOptionsContext.js.map +1 -1
  21. package/cjs/form/combobox/Input/{inputContext.d.ts → Input.context.d.ts} +7 -5
  22. package/cjs/form/combobox/Input/{inputContext.js → Input.context.js} +22 -22
  23. package/cjs/form/combobox/Input/Input.context.js.map +1 -0
  24. package/cjs/form/combobox/Input/Input.js +2 -2
  25. package/cjs/form/combobox/Input/Input.js.map +1 -1
  26. package/cjs/form/combobox/Input/InputController.d.ts +3 -0
  27. package/cjs/form/combobox/Input/InputController.js +70 -0
  28. package/cjs/form/combobox/Input/InputController.js.map +1 -0
  29. package/cjs/form/combobox/{ToggleListButton.js → Input/ToggleListButton.js} +1 -1
  30. package/cjs/form/combobox/Input/ToggleListButton.js.map +1 -0
  31. package/cjs/form/combobox/SelectedOptions/SelectedOptions.js +2 -2
  32. package/cjs/form/combobox/SelectedOptions/SelectedOptions.js.map +1 -1
  33. package/cjs/form/combobox/SelectedOptions/selectedOptionsContext.d.ts +4 -4
  34. package/cjs/form/combobox/SelectedOptions/selectedOptionsContext.js +7 -13
  35. package/cjs/form/combobox/SelectedOptions/selectedOptionsContext.js.map +1 -1
  36. package/cjs/form/combobox/customOptionsContext.d.ts +4 -4
  37. package/cjs/form/combobox/customOptionsContext.js +10 -13
  38. package/cjs/form/combobox/customOptionsContext.js.map +1 -1
  39. package/cjs/form/combobox/types.d.ts +1 -1
  40. package/cjs/help-text/HelpTextIcon.d.ts +1 -1
  41. package/cjs/overlay/dismiss/DismissableLayer.d.ts +70 -0
  42. package/cjs/overlay/dismiss/DismissableLayer.js +253 -0
  43. package/cjs/overlay/dismiss/DismissableLayer.js.map +1 -0
  44. package/cjs/overlay/dismiss/util/dispatchCustomEvent.d.ts +50 -0
  45. package/cjs/overlay/dismiss/util/dispatchCustomEvent.js +65 -0
  46. package/cjs/overlay/dismiss/util/dispatchCustomEvent.js.map +1 -0
  47. package/cjs/overlay/dismiss/util/useEscapeKeydown.d.ts +1 -0
  48. package/cjs/overlay/dismiss/util/useEscapeKeydown.js +19 -0
  49. package/cjs/overlay/dismiss/util/useEscapeKeydown.js.map +1 -0
  50. package/cjs/overlay/dismiss/util/useFocusOutside.d.ts +8 -0
  51. package/cjs/overlay/dismiss/util/useFocusOutside.js +42 -0
  52. package/cjs/overlay/dismiss/util/useFocusOutside.js.map +1 -0
  53. package/cjs/overlay/dismiss/util/usePointerDownOutside.d.ts +10 -0
  54. package/cjs/overlay/dismiss/util/usePointerDownOutside.js +84 -0
  55. package/cjs/overlay/dismiss/util/usePointerDownOutside.js.map +1 -0
  56. package/cjs/overlays/floating/Floating.d.ts +53 -0
  57. package/cjs/overlays/floating/Floating.js +215 -0
  58. package/cjs/overlays/floating/Floating.js.map +1 -0
  59. package/cjs/overlays/floating/Floating.utils.d.ts +18 -0
  60. package/cjs/overlays/floating/Floating.utils.js +52 -0
  61. package/cjs/overlays/floating/Floating.utils.js.map +1 -0
  62. package/cjs/popover/Popover.js +13 -28
  63. package/cjs/popover/Popover.js.map +1 -1
  64. package/cjs/progress-bar/ProgressBar.d.ts +20 -8
  65. package/cjs/progress-bar/ProgressBar.js +19 -9
  66. package/cjs/progress-bar/ProgressBar.js.map +1 -1
  67. package/cjs/tabs/Tabs.context.d.ts +7 -3
  68. package/cjs/tabs/Tabs.context.js +1 -0
  69. package/cjs/tabs/Tabs.context.js.map +1 -1
  70. package/cjs/timeline/AxisLabels.d.ts +1 -1
  71. package/cjs/toggle-group/ToggleGroup.context.d.ts +7 -3
  72. package/cjs/toggle-group/ToggleGroup.context.js +1 -0
  73. package/cjs/toggle-group/ToggleGroup.context.js.map +1 -1
  74. package/cjs/util/hooks/descendants/useDescendant.d.ts +2 -2
  75. package/cjs/util/hooks/descendants/useDescendant.js +49 -52
  76. package/cjs/util/hooks/descendants/useDescendant.js.map +1 -1
  77. package/cjs/util/types/AsChild.d.ts +14 -0
  78. package/cjs/util/types/AsChild.js +3 -0
  79. package/cjs/util/types/AsChild.js.map +1 -0
  80. package/esm/chat/Chat.d.ts +2 -1
  81. package/esm/chat/Chat.js +1 -0
  82. package/esm/chat/Chat.js.map +1 -1
  83. package/esm/date/datepicker/parts/DropdownCaption.js +1 -1
  84. package/esm/date/datepicker/parts/DropdownCaption.js.map +1 -1
  85. package/esm/date/monthpicker/MonthCaption.js +1 -1
  86. package/esm/date/utils/labels.d.ts +2 -2
  87. package/esm/form/ReadOnlyIcon.d.ts +2 -2
  88. package/esm/form/combobox/Combobox.js +8 -23
  89. package/esm/form/combobox/Combobox.js.map +1 -1
  90. package/esm/form/combobox/ComboboxProvider.js +1 -1
  91. package/esm/form/combobox/ComboboxProvider.js.map +1 -1
  92. package/esm/form/combobox/ComboboxWrapper.d.ts +1 -2
  93. package/esm/form/combobox/ComboboxWrapper.js +4 -2
  94. package/esm/form/combobox/ComboboxWrapper.js.map +1 -1
  95. package/esm/form/combobox/FilteredOptions/FilteredOptions.js +3 -3
  96. package/esm/form/combobox/FilteredOptions/FilteredOptions.js.map +1 -1
  97. package/esm/form/combobox/FilteredOptions/filteredOptionsContext.d.ts +4 -4
  98. package/esm/form/combobox/FilteredOptions/filteredOptionsContext.js +15 -16
  99. package/esm/form/combobox/FilteredOptions/filteredOptionsContext.js.map +1 -1
  100. package/esm/form/combobox/Input/{inputContext.d.ts → Input.context.d.ts} +7 -5
  101. package/esm/form/combobox/Input/{inputContext.js → Input.context.js} +22 -21
  102. package/esm/form/combobox/Input/Input.context.js.map +1 -0
  103. package/esm/form/combobox/Input/Input.js +1 -1
  104. package/esm/form/combobox/Input/Input.js.map +1 -1
  105. package/esm/form/combobox/Input/InputController.d.ts +3 -0
  106. package/esm/form/combobox/Input/InputController.js +41 -0
  107. package/esm/form/combobox/Input/InputController.js.map +1 -0
  108. package/esm/form/combobox/{ToggleListButton.js → Input/ToggleListButton.js} +1 -1
  109. package/esm/form/combobox/Input/ToggleListButton.js.map +1 -0
  110. package/esm/form/combobox/SelectedOptions/SelectedOptions.js +1 -1
  111. package/esm/form/combobox/SelectedOptions/SelectedOptions.js.map +1 -1
  112. package/esm/form/combobox/SelectedOptions/selectedOptionsContext.d.ts +4 -4
  113. package/esm/form/combobox/SelectedOptions/selectedOptionsContext.js +9 -14
  114. package/esm/form/combobox/SelectedOptions/selectedOptionsContext.js.map +1 -1
  115. package/esm/form/combobox/customOptionsContext.d.ts +4 -4
  116. package/esm/form/combobox/customOptionsContext.js +10 -12
  117. package/esm/form/combobox/customOptionsContext.js.map +1 -1
  118. package/esm/form/combobox/types.d.ts +1 -1
  119. package/esm/help-text/HelpTextIcon.d.ts +1 -1
  120. package/esm/overlay/dismiss/DismissableLayer.d.ts +70 -0
  121. package/esm/overlay/dismiss/DismissableLayer.js +226 -0
  122. package/esm/overlay/dismiss/DismissableLayer.js.map +1 -0
  123. package/esm/overlay/dismiss/util/dispatchCustomEvent.d.ts +50 -0
  124. package/esm/overlay/dismiss/util/dispatchCustomEvent.js +58 -0
  125. package/esm/overlay/dismiss/util/dispatchCustomEvent.js.map +1 -0
  126. package/esm/overlay/dismiss/util/useEscapeKeydown.d.ts +1 -0
  127. package/esm/overlay/dismiss/util/useEscapeKeydown.js +15 -0
  128. package/esm/overlay/dismiss/util/useEscapeKeydown.js.map +1 -0
  129. package/esm/overlay/dismiss/util/useFocusOutside.d.ts +8 -0
  130. package/esm/overlay/dismiss/util/useFocusOutside.js +38 -0
  131. package/esm/overlay/dismiss/util/useFocusOutside.js.map +1 -0
  132. package/esm/overlay/dismiss/util/usePointerDownOutside.d.ts +10 -0
  133. package/esm/overlay/dismiss/util/usePointerDownOutside.js +80 -0
  134. package/esm/overlay/dismiss/util/usePointerDownOutside.js.map +1 -0
  135. package/esm/overlays/floating/Floating.d.ts +53 -0
  136. package/esm/overlays/floating/Floating.js +188 -0
  137. package/esm/overlays/floating/Floating.js.map +1 -0
  138. package/esm/overlays/floating/Floating.utils.d.ts +18 -0
  139. package/esm/overlays/floating/Floating.utils.js +48 -0
  140. package/esm/overlays/floating/Floating.utils.js.map +1 -0
  141. package/esm/popover/Popover.js +16 -31
  142. package/esm/popover/Popover.js.map +1 -1
  143. package/esm/progress-bar/ProgressBar.d.ts +20 -8
  144. package/esm/progress-bar/ProgressBar.js +20 -10
  145. package/esm/progress-bar/ProgressBar.js.map +1 -1
  146. package/esm/tabs/Tabs.context.d.ts +7 -3
  147. package/esm/tabs/Tabs.context.js +1 -0
  148. package/esm/tabs/Tabs.context.js.map +1 -1
  149. package/esm/timeline/AxisLabels.d.ts +1 -1
  150. package/esm/toggle-group/ToggleGroup.context.d.ts +7 -3
  151. package/esm/toggle-group/ToggleGroup.context.js +1 -0
  152. package/esm/toggle-group/ToggleGroup.context.js.map +1 -1
  153. package/esm/util/hooks/descendants/useDescendant.d.ts +2 -2
  154. package/esm/util/hooks/descendants/useDescendant.js +49 -52
  155. package/esm/util/hooks/descendants/useDescendant.js.map +1 -1
  156. package/esm/util/types/AsChild.d.ts +14 -0
  157. package/esm/util/types/AsChild.js +2 -0
  158. package/esm/util/types/AsChild.js.map +1 -0
  159. package/package.json +6 -5
  160. package/src/chat/Chat.tsx +2 -1
  161. package/src/date/datepicker/parts/DropdownCaption.tsx +5 -1
  162. package/src/date/monthpicker/MonthCaption.tsx +1 -1
  163. package/src/form/combobox/Combobox.tsx +6 -76
  164. package/src/form/combobox/ComboboxProvider.tsx +1 -1
  165. package/src/form/combobox/ComboboxWrapper.tsx +4 -3
  166. package/src/form/combobox/FilteredOptions/FilteredOptions.tsx +3 -3
  167. package/src/form/combobox/FilteredOptions/filteredOptionsContext.tsx +19 -29
  168. package/src/form/combobox/Input/{inputContext.tsx → Input.context.tsx} +30 -33
  169. package/src/form/combobox/Input/Input.tsx +1 -1
  170. package/src/form/combobox/Input/InputController.tsx +102 -0
  171. package/src/form/combobox/{ToggleListButton.tsx → Input/ToggleListButton.tsx} +1 -1
  172. package/src/form/combobox/SelectedOptions/SelectedOptions.tsx +1 -1
  173. package/src/form/combobox/SelectedOptions/selectedOptionsContext.tsx +12 -26
  174. package/src/form/combobox/{combobox-utils.test.ts → __tests__/combobox-utils.test.ts} +1 -1
  175. package/src/form/combobox/{combobox.test.tsx → __tests__/combobox.test.tsx} +2 -3
  176. package/src/form/combobox/customOptionsContext.tsx +14 -18
  177. package/src/form/combobox/types.ts +3 -1
  178. package/src/overlay/README.md +5 -0
  179. package/src/overlay/dismiss/DismissableLayer.tsx +368 -0
  180. package/src/overlay/dismiss/util/dispatchCustomEvent.ts +77 -0
  181. package/src/overlay/dismiss/util/useEscapeKeydown.ts +21 -0
  182. package/src/overlay/dismiss/util/useFocusOutside.ts +52 -0
  183. package/src/overlay/dismiss/util/usePointerDownOutside.ts +95 -0
  184. package/src/overlays/floating/Floating.tsx +399 -0
  185. package/src/overlays/floating/Floating.utils.ts +63 -0
  186. package/src/popover/Popover.tsx +38 -70
  187. package/src/progress-bar/ProgressBar.tsx +45 -20
  188. package/src/tabs/Tabs.context.ts +2 -0
  189. package/src/toggle-group/ToggleGroup.context.ts +1 -0
  190. package/src/util/hooks/descendants/useDescendant.tsx +55 -68
  191. package/src/util/types/AsChild.ts +15 -0
  192. package/cjs/form/combobox/ClearButton.d.ts +0 -7
  193. package/cjs/form/combobox/ClearButton.js +0 -28
  194. package/cjs/form/combobox/ClearButton.js.map +0 -1
  195. package/cjs/form/combobox/FilteredOptions/CheckIcon.d.ts +0 -3
  196. package/cjs/form/combobox/FilteredOptions/CheckIcon.js +0 -12
  197. package/cjs/form/combobox/FilteredOptions/CheckIcon.js.map +0 -1
  198. package/cjs/form/combobox/Input/inputContext.js.map +0 -1
  199. package/cjs/form/combobox/ToggleListButton.js.map +0 -1
  200. package/esm/form/combobox/ClearButton.d.ts +0 -7
  201. package/esm/form/combobox/ClearButton.js +0 -21
  202. package/esm/form/combobox/ClearButton.js.map +0 -1
  203. package/esm/form/combobox/FilteredOptions/CheckIcon.d.ts +0 -3
  204. package/esm/form/combobox/FilteredOptions/CheckIcon.js +0 -7
  205. package/esm/form/combobox/FilteredOptions/CheckIcon.js.map +0 -1
  206. package/esm/form/combobox/Input/inputContext.js.map +0 -1
  207. package/esm/form/combobox/ToggleListButton.js.map +0 -1
  208. package/src/form/combobox/ClearButton.tsx +0 -29
  209. package/src/form/combobox/FilteredOptions/CheckIcon.tsx +0 -23
  210. /package/cjs/form/combobox/{ToggleListButton.d.ts → Input/ToggleListButton.d.ts} +0 -0
  211. /package/esm/form/combobox/{ToggleListButton.d.ts → Input/ToggleListButton.d.ts} +0 -0
@@ -0,0 +1,50 @@
1
+ type CustomFocusEvent = CustomEvent<{
2
+ originalEvent: FocusEvent;
3
+ }>;
4
+ type CustomPointerDownEvent = CustomEvent<{
5
+ originalEvent: PointerEvent;
6
+ }>;
7
+ export { CustomFocusEvent, CustomPointerDownEvent };
8
+ export declare const CUSTOM_EVENTS: {
9
+ FOCUS_OUTSIDE: string;
10
+ POINTER_DOWN_OUTSIDE: string;
11
+ };
12
+ /**
13
+ * Use of `discrete` flushes custom event dispatch. This is to mimic the behavior React has for `discrete` events.
14
+ * https://github.com/facebook/react/blob/a8a4742f1c54493df00da648a3f9d26e3db9c8b5/packages/react-dom/src/events/ReactDOMEventListener.js#L318
15
+ *
16
+ * React batches *all* event handlers since version 18, this introduces certain considerations when using custom event types.
17
+ *
18
+ * Internally, React prioritises events in the following order:
19
+ * - discrete
20
+ * - continuous
21
+ * - default
22
+ *
23
+ * `discrete` is an important distinction as updates within these events are applied immediately.
24
+ * React however, is not able to infer the priority of custom event types due to how they are detected internally.
25
+ * Because of this, it's possible for updates from custom events to be unexpectedly batched when
26
+ * dispatched by another `discrete` event.
27
+ *
28
+ * In order to ensure that updates from custom events are applied predictably, we need to manually flush the batch.
29
+ * This utility should be used when dispatching a custom event from within another `discrete` event, this utility
30
+ * is not nessesary when dispatching known event types, or if dispatching a custom type inside a non-discrete event.
31
+ * For example:
32
+ *
33
+ * dispatching a known click 👎
34
+ * target.dispatchEvent(new Event(‘click’))
35
+ *
36
+ * dispatching a custom type within a non-discrete event 👎
37
+ * onScroll={(event) => event.target.dispatchEvent(new CustomEvent(‘customType’))}
38
+ *
39
+ * dispatching a custom type within a `discrete` event 👍
40
+ * onPointerDown={(event) => dispatchDiscreteCustomEvent(event.target, new CustomEvent(‘customType’))}
41
+ *
42
+ * Note: though React classifies `focus`, `focusin` and `focusout` events as `discrete`, it's not recommended to use
43
+ * this utility with them. This is because it's possible for those handlers to be called implicitly during render
44
+ * e.g. when focus is within a component as it is unmounted, or when managing focus on mount.
45
+ */
46
+ export declare function dispatchCustomEvent<E extends CustomEvent, OriginalEvent extends Event>(name: string, handler: ((event: E) => void) | undefined, detail: {
47
+ originalEvent: OriginalEvent;
48
+ } & (E extends CustomEvent<infer D> ? D : never), { discrete }?: {
49
+ discrete: boolean;
50
+ }): void;
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.dispatchCustomEvent = exports.CUSTOM_EVENTS = void 0;
7
+ const react_dom_1 = __importDefault(require("react-dom"));
8
+ exports.CUSTOM_EVENTS = {
9
+ FOCUS_OUTSIDE: "AKSEL_FOCUS_OUTSIDE",
10
+ POINTER_DOWN_OUTSIDE: "AKSEL_POINTER_DOWN_OUTSIDE",
11
+ };
12
+ /**
13
+ * Use of `discrete` flushes custom event dispatch. This is to mimic the behavior React has for `discrete` events.
14
+ * https://github.com/facebook/react/blob/a8a4742f1c54493df00da648a3f9d26e3db9c8b5/packages/react-dom/src/events/ReactDOMEventListener.js#L318
15
+ *
16
+ * React batches *all* event handlers since version 18, this introduces certain considerations when using custom event types.
17
+ *
18
+ * Internally, React prioritises events in the following order:
19
+ * - discrete
20
+ * - continuous
21
+ * - default
22
+ *
23
+ * `discrete` is an important distinction as updates within these events are applied immediately.
24
+ * React however, is not able to infer the priority of custom event types due to how they are detected internally.
25
+ * Because of this, it's possible for updates from custom events to be unexpectedly batched when
26
+ * dispatched by another `discrete` event.
27
+ *
28
+ * In order to ensure that updates from custom events are applied predictably, we need to manually flush the batch.
29
+ * This utility should be used when dispatching a custom event from within another `discrete` event, this utility
30
+ * is not nessesary when dispatching known event types, or if dispatching a custom type inside a non-discrete event.
31
+ * For example:
32
+ *
33
+ * dispatching a known click 👎
34
+ * target.dispatchEvent(new Event(‘click’))
35
+ *
36
+ * dispatching a custom type within a non-discrete event 👎
37
+ * onScroll={(event) => event.target.dispatchEvent(new CustomEvent(‘customType’))}
38
+ *
39
+ * dispatching a custom type within a `discrete` event 👍
40
+ * onPointerDown={(event) => dispatchDiscreteCustomEvent(event.target, new CustomEvent(‘customType’))}
41
+ *
42
+ * Note: though React classifies `focus`, `focusin` and `focusout` events as `discrete`, it's not recommended to use
43
+ * this utility with them. This is because it's possible for those handlers to be called implicitly during render
44
+ * e.g. when focus is within a component as it is unmounted, or when managing focus on mount.
45
+ */
46
+ function dispatchCustomEvent(name, handler, detail, { discrete } = { discrete: false }) {
47
+ if (!handler) {
48
+ return;
49
+ }
50
+ const target = detail.originalEvent.target;
51
+ const event = new CustomEvent(name, {
52
+ bubbles: false,
53
+ cancelable: true,
54
+ detail,
55
+ });
56
+ target.addEventListener(name, handler, { once: true });
57
+ if (discrete && target) {
58
+ react_dom_1.default.flushSync(() => target.dispatchEvent(event));
59
+ }
60
+ else {
61
+ target.dispatchEvent(event);
62
+ }
63
+ }
64
+ exports.dispatchCustomEvent = dispatchCustomEvent;
65
+ //# sourceMappingURL=dispatchCustomEvent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dispatchCustomEvent.js","sourceRoot":"","sources":["../../../../src/overlay/dismiss/util/dispatchCustomEvent.ts"],"names":[],"mappings":";;;;;;AAAA,0DAAiC;AASpB,QAAA,aAAa,GAAG;IAC3B,aAAa,EAAE,qBAAqB;IACpC,oBAAoB,EAAE,4BAA4B;CACnD,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,SAAgB,mBAAmB,CAIjC,IAAY,EACZ,OAAyC,EACzC,MAEU,EACV,EAAE,QAAQ,KAA4B,EAAE,QAAQ,EAAE,KAAK,EAAE;IAEzD,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO;IACT,CAAC;IACD,MAAM,MAAM,GAAG,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC;IAC3C,MAAM,KAAK,GAAG,IAAI,WAAW,CAAC,IAAI,EAAE;QAClC,OAAO,EAAE,KAAK;QACd,UAAU,EAAE,IAAI;QAChB,MAAM;KACP,CAAC,CAAC;IAEH,MAAM,CAAC,gBAAgB,CAAC,IAAI,EAAE,OAAwB,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IAExE,IAAI,QAAQ,IAAI,MAAM,EAAE,CAAC;QACvB,mBAAQ,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC;IACxD,CAAC;SAAM,CAAC;QACN,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IAC9B,CAAC;AACH,CAAC;AA5BD,kDA4BC"}
@@ -0,0 +1 @@
1
+ export declare function useEscapeKeydown(callback?: (event: KeyboardEvent) => void, ownerDocument?: Document): void;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useEscapeKeydown = void 0;
4
+ const react_1 = require("react");
5
+ const hooks_1 = require("../../../util/hooks");
6
+ function useEscapeKeydown(callback, ownerDocument = globalThis === null || globalThis === void 0 ? void 0 : globalThis.document) {
7
+ const onEscapeKeyDown = (0, hooks_1.useCallbackRef)(callback);
8
+ (0, react_1.useEffect)(() => {
9
+ const handleKeyDown = (event) => {
10
+ if (event.key === "Escape") {
11
+ onEscapeKeyDown(event);
12
+ }
13
+ };
14
+ ownerDocument.addEventListener("keydown", handleKeyDown, true);
15
+ return () => ownerDocument.removeEventListener("keydown", handleKeyDown, true);
16
+ }, [onEscapeKeyDown, ownerDocument]);
17
+ }
18
+ exports.useEscapeKeydown = useEscapeKeydown;
19
+ //# sourceMappingURL=useEscapeKeydown.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useEscapeKeydown.js","sourceRoot":"","sources":["../../../../src/overlay/dismiss/util/useEscapeKeydown.ts"],"names":[],"mappings":";;;AAAA,iCAAkC;AAClC,+CAAqD;AAErD,SAAgB,gBAAgB,CAC9B,QAAyC,EACzC,gBAA0B,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,QAAQ;IAE9C,MAAM,eAAe,GAAG,IAAA,sBAAc,EAAC,QAAQ,CAAC,CAAC;IAEjD,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,MAAM,aAAa,GAAG,CAAC,KAAoB,EAAE,EAAE;YAC7C,IAAI,KAAK,CAAC,GAAG,KAAK,QAAQ,EAAE,CAAC;gBAC3B,eAAe,CAAC,KAAK,CAAC,CAAC;YACzB,CAAC;QACH,CAAC,CAAC;QAEF,aAAa,CAAC,gBAAgB,CAAC,SAAS,EAAE,aAAa,EAAE,IAAI,CAAC,CAAC;QAC/D,OAAO,GAAG,EAAE,CACV,aAAa,CAAC,mBAAmB,CAAC,SAAS,EAAE,aAAa,EAAE,IAAI,CAAC,CAAC;IACtE,CAAC,EAAE,CAAC,eAAe,EAAE,aAAa,CAAC,CAAC,CAAC;AACvC,CAAC;AAjBD,4CAiBC"}
@@ -0,0 +1,8 @@
1
+ import { CustomFocusEvent } from "./dispatchCustomEvent";
2
+ /**
3
+ * Tracks focus outside a React subtree. Returns props for the subtree root.
4
+ */
5
+ export declare function useFocusOutside(callback?: (event: CustomFocusEvent) => void, ownerDocument?: Document): {
6
+ onFocusCapture: () => boolean;
7
+ onBlurCapture: () => boolean;
8
+ };
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useFocusOutside = void 0;
4
+ const react_1 = require("react");
5
+ const hooks_1 = require("../../../util/hooks");
6
+ const dispatchCustomEvent_1 = require("./dispatchCustomEvent");
7
+ /**
8
+ * Tracks focus outside a React subtree. Returns props for the subtree root.
9
+ */
10
+ function useFocusOutside(callback, ownerDocument = globalThis === null || globalThis === void 0 ? void 0 : globalThis.document) {
11
+ const handleFocusOutside = (0, hooks_1.useCallbackRef)(callback);
12
+ const isFocusInsideReactTreeRef = (0, react_1.useRef)(false);
13
+ (0, react_1.useEffect)(() => {
14
+ const handleFocus = (event) => {
15
+ if (event.target && !isFocusInsideReactTreeRef.current) {
16
+ const eventDetail = { originalEvent: event };
17
+ /**
18
+ * The `DismisableLayer`-API is based on the ability to stop events from propagating and in the end calling `onDismiss`
19
+ * if `useFocusOutside`-callback runs `event.preventDefault()`.
20
+ *
21
+ * Because of the `focusin`-event not being cancelable,
22
+ * we need to use a custom event to ensure that the event is cancelable.
23
+ * https://developer.mozilla.org/en-US/docs/Web/API/Element/focusin_event
24
+ * > The focusin event is not cancelable.
25
+ */
26
+ (0, dispatchCustomEvent_1.dispatchCustomEvent)(dispatchCustomEvent_1.CUSTOM_EVENTS.FOCUS_OUTSIDE, handleFocusOutside, eventDetail);
27
+ }
28
+ };
29
+ ownerDocument.addEventListener("focusin", handleFocus);
30
+ return () => ownerDocument.removeEventListener("focusin", handleFocus);
31
+ }, [ownerDocument, handleFocusOutside]);
32
+ /**
33
+ * By directly setting isFocusInsideReactTreeRef on focus-events at the root of the "dismissable" element,
34
+ * we can eliminate the need for DOM traversal to verify if the focused element is within the react tree.
35
+ */
36
+ return {
37
+ onFocusCapture: () => (isFocusInsideReactTreeRef.current = true),
38
+ onBlurCapture: () => (isFocusInsideReactTreeRef.current = false),
39
+ };
40
+ }
41
+ exports.useFocusOutside = useFocusOutside;
42
+ //# sourceMappingURL=useFocusOutside.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useFocusOutside.js","sourceRoot":"","sources":["../../../../src/overlay/dismiss/util/useFocusOutside.ts"],"names":[],"mappings":";;;AAAA,iCAA0C;AAC1C,+CAAqD;AACrD,+DAI+B;AAE/B;;GAEG;AACH,SAAgB,eAAe,CAC7B,QAA4C,EAC5C,gBAA0B,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,QAAQ;IAE9C,MAAM,kBAAkB,GAAG,IAAA,sBAAc,EAAC,QAAQ,CAAkB,CAAC;IACrE,MAAM,yBAAyB,GAAG,IAAA,cAAM,EAAC,KAAK,CAAC,CAAC;IAEhD,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,MAAM,WAAW,GAAG,CAAC,KAAiB,EAAE,EAAE;YACxC,IAAI,KAAK,CAAC,MAAM,IAAI,CAAC,yBAAyB,CAAC,OAAO,EAAE,CAAC;gBACvD,MAAM,WAAW,GAAG,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC;gBAE7C;;;;;;;;mBAQG;gBACH,IAAA,yCAAmB,EACjB,mCAAa,CAAC,aAAa,EAC3B,kBAAkB,EAClB,WAAW,CACZ,CAAC;YACJ,CAAC;QACH,CAAC,CAAC;QACF,aAAa,CAAC,gBAAgB,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;QACvD,OAAO,GAAG,EAAE,CAAC,aAAa,CAAC,mBAAmB,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;IACzE,CAAC,EAAE,CAAC,aAAa,EAAE,kBAAkB,CAAC,CAAC,CAAC;IAExC;;;OAGG;IACH,OAAO;QACL,cAAc,EAAE,GAAG,EAAE,CAAC,CAAC,yBAAyB,CAAC,OAAO,GAAG,IAAI,CAAC;QAChE,aAAa,EAAE,GAAG,EAAE,CAAC,CAAC,yBAAyB,CAAC,OAAO,GAAG,KAAK,CAAC;KACjE,CAAC;AACJ,CAAC;AAxCD,0CAwCC"}
@@ -0,0 +1,10 @@
1
+ import { CustomPointerDownEvent } from "./dispatchCustomEvent";
2
+ /**
3
+ * Listens for `pointerdown` outside a react subtree. We use `pointerdown` rather than `pointerup`
4
+ * to mimic layer dismissing behaviour present in OS.
5
+ * Returns props to pass to the node we want to check for outside events.
6
+ * By checking `isPointerInsideReactTreeRef` we can determine if the event happened outside the subtree of the node, saving some element-comparisons.
7
+ */
8
+ export declare function usePointerDownOutside(callback?: (event: CustomPointerDownEvent) => void, ownerDocument?: Document): {
9
+ onPointerDownCapture: () => boolean;
10
+ };
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.usePointerDownOutside = void 0;
4
+ const react_1 = require("react");
5
+ const hooks_1 = require("../../../util/hooks");
6
+ const dispatchCustomEvent_1 = require("./dispatchCustomEvent");
7
+ /**
8
+ * Listens for `pointerdown` outside a react subtree. We use `pointerdown` rather than `pointerup`
9
+ * to mimic layer dismissing behaviour present in OS.
10
+ * Returns props to pass to the node we want to check for outside events.
11
+ * By checking `isPointerInsideReactTreeRef` we can determine if the event happened outside the subtree of the node, saving some element-comparisons.
12
+ */
13
+ function usePointerDownOutside(callback, ownerDocument = globalThis === null || globalThis === void 0 ? void 0 : globalThis.document) {
14
+ const handlePointerDownOutside = (0, hooks_1.useCallbackRef)(callback);
15
+ const isPointerInsideReactTreeRef = (0, react_1.useRef)(false);
16
+ const handleClickRef = (0, react_1.useRef)(() => { });
17
+ (0, react_1.useEffect)(() => {
18
+ const handlePointerDown = (event) => {
19
+ /**
20
+ * The `DismisableLayer`-API is based on the ability to stop events from propagating and in the end calling `onDismiss`
21
+ * if `usePointerDownOutside` runs `event.preventDefault()`.
22
+ *
23
+ * Altrough `pointerdown` is already a cancelable event,
24
+ * to to make sure the batching of events works corretly with `focusIn` in `useFocusOutside`,
25
+ * we still use a custom event like in `useFocusOutside`.
26
+ *
27
+ * Since pointer-events are `discrete` events in React: https://github.com/facebook/react/blob/a8a4742f1c54493df00da648a3f9d26e3db9c8b5/packages/react-dom/src/events/ReactDOMEventListener.js#L318
28
+ * we need to to use flushSync to ensure that the event is dispatched before the next event is raised.
29
+ */
30
+ function dispatchPointerEvent() {
31
+ (0, dispatchCustomEvent_1.dispatchCustomEvent)(dispatchCustomEvent_1.CUSTOM_EVENTS.POINTER_DOWN_OUTSIDE, handlePointerDownOutside, { originalEvent: event }, { discrete: true });
32
+ }
33
+ if (event.target && !isPointerInsideReactTreeRef.current) {
34
+ /**
35
+ * On touch devices, we delay reactivating pointer-events to account for the browser's delay in executing events after touch ends.
36
+ * This also handles cancellations when no click event is raised due to scrolling or long-pressing.
37
+ * We continuously remove the previous listener as we can't be sure it was raised and cleaned up.
38
+ */
39
+ if (event.pointerType === "touch") {
40
+ ownerDocument.removeEventListener("click", handleClickRef.current);
41
+ handleClickRef.current = dispatchPointerEvent;
42
+ ownerDocument.addEventListener("click", handleClickRef.current, {
43
+ once: true,
44
+ });
45
+ }
46
+ else {
47
+ dispatchPointerEvent();
48
+ }
49
+ }
50
+ else {
51
+ // We need to remove the event listener in case the outside click has been canceled.
52
+ ownerDocument.removeEventListener("click", handleClickRef.current);
53
+ }
54
+ isPointerInsideReactTreeRef.current = false;
55
+ };
56
+ /**
57
+ * If this hook executes in a component that mounts via a `pointerdown` event, the event
58
+ * would bubble up to the document and trigger a `pointerDownOutside` event. We avoid
59
+ * this by delaying the event listener registration on the document.
60
+ * This is not React specific, but rather how the DOM works, ie:
61
+ * ```
62
+ * button.addEventListener('pointerdown', () => {
63
+ * console.log('I will log');
64
+ * document.addEventListener('pointerdown', () => {
65
+ * console.log('I will also log');
66
+ * })
67
+ * });
68
+ */
69
+ const timerId = window.setTimeout(() => {
70
+ ownerDocument.addEventListener("pointerdown", handlePointerDown);
71
+ }, 0);
72
+ return () => {
73
+ window.clearTimeout(timerId);
74
+ ownerDocument.removeEventListener("pointerdown", handlePointerDown);
75
+ ownerDocument.removeEventListener("click", handleClickRef.current);
76
+ };
77
+ }, [ownerDocument, handlePointerDownOutside]);
78
+ return {
79
+ // ensures we check React component tree (not just DOM tree)
80
+ onPointerDownCapture: () => (isPointerInsideReactTreeRef.current = true),
81
+ };
82
+ }
83
+ exports.usePointerDownOutside = usePointerDownOutside;
84
+ //# sourceMappingURL=usePointerDownOutside.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usePointerDownOutside.js","sourceRoot":"","sources":["../../../../src/overlay/dismiss/util/usePointerDownOutside.ts"],"names":[],"mappings":";;;AAAA,iCAA0C;AAC1C,+CAAqD;AACrD,+DAI+B;AAE/B;;;;;GAKG;AACH,SAAgB,qBAAqB,CACnC,QAAkD,EAClD,gBAA0B,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,QAAQ;IAE9C,MAAM,wBAAwB,GAAG,IAAA,sBAAc,EAAC,QAAQ,CAAkB,CAAC;IAC3E,MAAM,2BAA2B,GAAG,IAAA,cAAM,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AAG,EAAE;YACV,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;YAC7B,aAAa,CAAC,mBAAmB,CAAC,aAAa,EAAE,iBAAiB,CAAC,CAAC;YACpE,aAAa,CAAC,mBAAmB,CAAC,OAAO,EAAE,cAAc,CAAC,OAAO,CAAC,CAAC;QACrE,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,aAAa,EAAE,wBAAwB,CAAC,CAAC,CAAC;IAE9C,OAAO;QACL,4DAA4D;QAC5D,oBAAoB,EAAE,GAAG,EAAE,CAAC,CAAC,2BAA2B,CAAC,OAAO,GAAG,IAAI,CAAC;KACzE,CAAC;AACJ,CAAC;AAhFD,sDAgFC"}
@@ -0,0 +1,53 @@
1
+ import React, { HTMLAttributes } from "react";
2
+ import { AsChildProps } from "../../util/types";
3
+ import { type Align, type Measurable, type Side } from "./Floating.utils";
4
+ /**
5
+ * Floating Root
6
+ */
7
+ type FloatingContextValue = {
8
+ anchor: Measurable | null;
9
+ onAnchorChange: (anchor: Measurable | null) => void;
10
+ };
11
+ export declare const FloatingProvider: React.ForwardRefExoticComponent<FloatingContextValue & {
12
+ children: React.ReactNode;
13
+ } & React.RefAttributes<unknown>>, useFloatingContext: <S extends boolean = true>(strict?: S) => S extends true ? FloatingContextValue : FloatingContextValue | undefined;
14
+ interface FloatingProps {
15
+ children: React.ReactNode;
16
+ }
17
+ interface FloatingComponent extends React.FC<FloatingProps> {
18
+ Anchor: typeof FloatingAnchor;
19
+ Content: typeof FloatingContent;
20
+ }
21
+ declare const Floating: FloatingComponent;
22
+ /**
23
+ * Floating Anchor
24
+ */
25
+ type FloatingAnchorProps = HTMLAttributes<HTMLDivElement> & AsChildProps & {
26
+ virtualRef?: React.RefObject<Measurable>;
27
+ };
28
+ /**
29
+ * `FloatingAnchor` provides an anchor for a Floating instance.
30
+ * Allows anchoring to non-DOM nodes like a cursor position when used with `virtualRef`.
31
+ */
32
+ declare const FloatingAnchor: React.ForwardRefExoticComponent<FloatingAnchorProps & React.RefAttributes<HTMLDivElement>>;
33
+ type Boundary = Element | null;
34
+ interface FloatingContentProps extends HTMLAttributes<HTMLDivElement> {
35
+ side?: Side;
36
+ sideOffset?: number;
37
+ align?: Align;
38
+ alignOffset?: number;
39
+ avoidCollisions?: boolean;
40
+ collisionBoundary?: Boundary | Boundary[];
41
+ collisionPadding?: number | Partial<Record<Side, number>>;
42
+ hideWhenDetached?: boolean;
43
+ updatePositionStrategy?: "optimized" | "always";
44
+ onPlaced?: () => void;
45
+ arrow?: {
46
+ className?: string;
47
+ padding?: number;
48
+ width: number;
49
+ height: number;
50
+ };
51
+ }
52
+ declare const FloatingContent: React.ForwardRefExoticComponent<FloatingContentProps & React.RefAttributes<HTMLDivElement>>;
53
+ export { Floating };
@@ -0,0 +1,215 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __rest = (this && this.__rest) || function (s, e) {
26
+ var t = {};
27
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
28
+ t[p] = s[p];
29
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
30
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
31
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
32
+ t[p[i]] = s[p[i]];
33
+ }
34
+ return t;
35
+ };
36
+ var _a;
37
+ Object.defineProperty(exports, "__esModule", { value: true });
38
+ exports.Floating = exports.useFloatingContext = exports.FloatingProvider = void 0;
39
+ const react_dom_1 = require("@floating-ui/react-dom");
40
+ const react_1 = __importStar(require("react"));
41
+ const Slot_1 = require("../../util/Slot");
42
+ const create_context_1 = require("../../util/create-context");
43
+ const hooks_1 = require("../../util/hooks");
44
+ const Floating_utils_1 = require("./Floating.utils");
45
+ _a = (0, create_context_1.createContext)({
46
+ name: "FloatingContext",
47
+ hookName: "useFloating",
48
+ providerName: "FloatingProvider",
49
+ }), exports.FloatingProvider = _a[0], exports.useFloatingContext = _a[1];
50
+ const Floating = ({ children }) => {
51
+ const [anchor, setAnchor] = (0, react_1.useState)(null);
52
+ return (react_1.default.createElement(exports.FloatingProvider, { anchor: anchor, onAnchorChange: setAnchor }, children));
53
+ };
54
+ exports.Floating = Floating;
55
+ /**
56
+ * `FloatingAnchor` provides an anchor for a Floating instance.
57
+ * Allows anchoring to non-DOM nodes like a cursor position when used with `virtualRef`.
58
+ */
59
+ const FloatingAnchor = (0, react_1.forwardRef)((_a, forwardedRef) => {
60
+ var { virtualRef, asChild } = _a, rest = __rest(_a, ["virtualRef", "asChild"]);
61
+ const context = (0, exports.useFloatingContext)();
62
+ const ref = (0, react_1.useRef)(null);
63
+ const mergedRef = (0, hooks_1.useMergeRefs)(forwardedRef, ref);
64
+ (0, react_1.useEffect)(() => {
65
+ // Allows anchoring the floating to non-DOM nodes like a cursor position.
66
+ // We replace `anchorRef` with a virtual ref in such cases.
67
+ context.onAnchorChange((virtualRef === null || virtualRef === void 0 ? void 0 : virtualRef.current) || ref.current);
68
+ });
69
+ const Comp = asChild ? Slot_1.Slot : "div";
70
+ return virtualRef ? null : react_1.default.createElement(Comp, Object.assign({ ref: mergedRef }, rest));
71
+ });
72
+ /**
73
+ * Floating Arrow
74
+ */
75
+ const OPPOSITE_SIDE = {
76
+ top: "bottom",
77
+ right: "left",
78
+ bottom: "top",
79
+ left: "right",
80
+ };
81
+ const FloatingArrow = ({ width, height, className }) => {
82
+ const context = useFloatingContentContext();
83
+ const side = OPPOSITE_SIDE[context.placedSide];
84
+ return (react_1.default.createElement("span", { ref: context.onArrowChange, style: {
85
+ position: "absolute",
86
+ left: context.arrowX,
87
+ top: context.arrowY,
88
+ [side]: 0,
89
+ transformOrigin: {
90
+ top: "",
91
+ right: "0 0",
92
+ bottom: "center 0",
93
+ left: "100% 0",
94
+ }[context.placedSide],
95
+ transform: {
96
+ top: "translateY(100%)",
97
+ right: "translateY(50%) rotate(90deg) translateX(-50%)",
98
+ bottom: `rotate(180deg)`,
99
+ left: "translateY(50%) rotate(-90deg) translateX(50%)",
100
+ }[context.placedSide],
101
+ visibility: context.hideArrow ? "hidden" : undefined,
102
+ }, "aria-hidden": true },
103
+ react_1.default.createElement("svg", { className: className, width: width, height: height, viewBox: "0 0 30 10", preserveAspectRatio: "none", style: { display: "block" } },
104
+ react_1.default.createElement("polygon", { points: "0,0 30,0 15,10" }))));
105
+ };
106
+ const [FloatingContentProvider, useFloatingContentContext] = (0, create_context_1.createContext)({
107
+ name: "FloatingContentContext",
108
+ hookName: "useFloatingContentContext",
109
+ providerName: "FloatingContentProvider",
110
+ });
111
+ const FloatingContent = (0, react_1.forwardRef)((_a, forwardedRef) => {
112
+ var _b, _c, _d, _e, _f, _g;
113
+ var { children, side = "bottom", sideOffset = 0, align = "center", alignOffset = 0, avoidCollisions = true, collisionBoundary = [], collisionPadding: collisionPaddingProp = 0, hideWhenDetached = false, updatePositionStrategy = "optimized", onPlaced, arrow: _arrow } = _a, contentProps = __rest(_a, ["children", "side", "sideOffset", "align", "alignOffset", "avoidCollisions", "collisionBoundary", "collisionPadding", "hideWhenDetached", "updatePositionStrategy", "onPlaced", "arrow"]);
114
+ const context = (0, exports.useFloatingContext)();
115
+ const [content, setContent] = (0, react_1.useState)(null);
116
+ const mergeRefs = (0, hooks_1.useMergeRefs)(forwardedRef, setContent);
117
+ const arrowDefaults = Object.assign({ padding: 5, width: 0, height: 0 }, _arrow);
118
+ const [arrow, setArrow] = (0, react_1.useState)(null);
119
+ const arrowWidth = arrowDefaults.width;
120
+ const arrowHeight = arrowDefaults.height;
121
+ const desiredPlacement = (side +
122
+ (align !== "center" ? "-" + align : ""));
123
+ const collisionPadding = typeof collisionPaddingProp === "number"
124
+ ? collisionPaddingProp
125
+ : Object.assign({ top: 0, right: 0, bottom: 0, left: 0 }, collisionPaddingProp);
126
+ const boundary = Array.isArray(collisionBoundary)
127
+ ? collisionBoundary
128
+ : [collisionBoundary];
129
+ const hasExplicitBoundaries = boundary.length > 0;
130
+ /**
131
+ * .filter(x => x !== null) does not narrow the type of the array enough.
132
+ */
133
+ function isNotNull(value) {
134
+ return value !== null;
135
+ }
136
+ const detectOverflowOptions = {
137
+ padding: collisionPadding,
138
+ boundary: boundary.filter(isNotNull),
139
+ // with `strategy: 'fixed'`, this is the only way to get it to respect boundaries
140
+ altBoundary: hasExplicitBoundaries,
141
+ };
142
+ const { refs, floatingStyles, placement, isPositioned, middlewareData } = (0, react_dom_1.useFloating)({
143
+ // default to `fixed` strategy so users don't have to pick and we also avoid focus scroll issues
144
+ strategy: "fixed",
145
+ placement: desiredPlacement,
146
+ whileElementsMounted: (...args) => {
147
+ const cleanup = (0, react_dom_1.autoUpdate)(...args, {
148
+ animationFrame: updatePositionStrategy === "always",
149
+ });
150
+ return cleanup;
151
+ },
152
+ elements: {
153
+ reference: context.anchor,
154
+ },
155
+ middleware: [
156
+ (0, react_dom_1.offset)({
157
+ mainAxis: sideOffset + arrowHeight,
158
+ alignmentAxis: alignOffset,
159
+ }),
160
+ avoidCollisions &&
161
+ (0, react_dom_1.shift)(Object.assign({ mainAxis: true, crossAxis: false, limiter: (0, react_dom_1.limitShift)() }, detectOverflowOptions)),
162
+ avoidCollisions && (0, react_dom_1.flip)(Object.assign({}, detectOverflowOptions)),
163
+ (0, react_dom_1.size)(Object.assign(Object.assign({}, detectOverflowOptions), { apply: ({ elements, rects, availableWidth, availableHeight }) => {
164
+ const { width: anchorWidth, height: anchorHeight } = rects.reference;
165
+ const contentStyle = elements.floating.style;
166
+ /**
167
+ * Allows styling and animations based on the available space.
168
+ */
169
+ contentStyle.setProperty("--ac-floating-available-width", `${availableWidth}px`);
170
+ contentStyle.setProperty("--ac-floating-available-height", `${availableHeight}px`);
171
+ contentStyle.setProperty("--ac-floating-anchor-width", `${anchorWidth}px`);
172
+ contentStyle.setProperty("--ac-floating-anchor-height", `${anchorHeight}px`);
173
+ } })),
174
+ arrow &&
175
+ (0, react_dom_1.arrow)({ element: arrow, padding: arrowDefaults.padding }),
176
+ (0, Floating_utils_1.transformOrigin)({ arrowWidth, arrowHeight }),
177
+ hideWhenDetached &&
178
+ (0, react_dom_1.hide)(Object.assign({ strategy: "referenceHidden" }, detectOverflowOptions)),
179
+ ],
180
+ });
181
+ const [placedSide, placedAlign] = (0, Floating_utils_1.getSideAndAlignFromPlacement)(placement);
182
+ const handlePlaced = (0, hooks_1.useCallbackRef)(onPlaced);
183
+ (0, hooks_1.useClientLayoutEffect)(() => {
184
+ isPositioned && (handlePlaced === null || handlePlaced === void 0 ? void 0 : handlePlaced());
185
+ }, [isPositioned, handlePlaced]);
186
+ const arrowX = (_b = middlewareData.arrow) === null || _b === void 0 ? void 0 : _b.x;
187
+ const arrowY = (_c = middlewareData.arrow) === null || _c === void 0 ? void 0 : _c.y;
188
+ const cannotCenterArrow = ((_d = middlewareData.arrow) === null || _d === void 0 ? void 0 : _d.centerOffset) !== 0;
189
+ const [contentZIndex, setContentZIndex] = (0, react_1.useState)();
190
+ (0, hooks_1.useClientLayoutEffect)(() => {
191
+ if (content)
192
+ setContentZIndex(window.getComputedStyle(content).zIndex);
193
+ }, [content]);
194
+ return (react_1.default.createElement("div", { ref: refs.setFloating, "data-aksel-floating-content-wrapper": "", style: Object.assign(Object.assign({}, floatingStyles), { transform: isPositioned
195
+ ? floatingStyles.transform
196
+ : "translate(0, -200%)", minWidth: "max-content", zIndex: contentZIndex, ["--ac-floating-transform-origin"]: [
197
+ (_e = middlewareData.transformOrigin) === null || _e === void 0 ? void 0 : _e.x,
198
+ (_f = middlewareData.transformOrigin) === null || _f === void 0 ? void 0 : _f.y,
199
+ ].join(" ") }),
200
+ // Floating UI uses the `dir` attribute on the reference/floating node for logical alignment.
201
+ // This attribute is necessary for both portalled and inline calculations.
202
+ dir: "ltr" },
203
+ react_1.default.createElement(FloatingContentProvider, { placedSide: placedSide, onArrowChange: setArrow, arrowX: arrowX, arrowY: arrowY, hideArrow: cannotCenterArrow },
204
+ react_1.default.createElement("div", Object.assign({ ref: mergeRefs, "data-side": placedSide, "data-align": placedAlign }, contentProps, { style: Object.assign(Object.assign({}, contentProps.style), {
205
+ // if the FloatingContent hasn't been placed yet (not all measurements done)
206
+ // we prevent animations so that users's animation don't kick in too early referring wrong sides
207
+ animation: !isPositioned ? "none" : undefined,
208
+ // hide the content if using the hide middleware and should be hidden
209
+ opacity: ((_g = middlewareData.hide) === null || _g === void 0 ? void 0 : _g.referenceHidden) ? 0 : undefined }) }),
210
+ children,
211
+ (_arrow === null || _arrow === void 0 ? void 0 : _arrow.height) && (_arrow === null || _arrow === void 0 ? void 0 : _arrow.width) && (react_1.default.createElement(FloatingArrow, { width: _arrow.width, height: _arrow.height, className: _arrow.className }))))));
212
+ });
213
+ Floating.Anchor = FloatingAnchor;
214
+ Floating.Content = FloatingContent;
215
+ //# sourceMappingURL=Floating.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Floating.js","sourceRoot":"","sources":["../../../src/overlays/floating/Floating.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;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uB,IACtB,UAAU,EAAE,UAAU,EACtB,aAAa,EAAE,QAAQ,EACvB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,iBAAiB;YAE5B,qDACE,GAAG,EAAE,SAAS,eACH,UAAU,gBACT,WAAW,IACnB,YAAY,IAChB,KAAK,kCACA,YAAY,CAAC,KAAK;oBACrB,4EAA4E;oBAC5E,gGAAgG;oBAChG,SAAS,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS;oBAC7C,qEAAqE;oBACrE,OAAO,EAAE,CAAA,MAAA,cAAc,CAAC,IAAI,0CAAE,eAAe,EAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS;gBAG9D,QAAQ;gBACR,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,MAAM,MAAI,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,KAAK,CAAA,IAAI,CAClC,8BAAC,aAAa,IACZ,KAAK,EAAE,MAAM,CAAC,KAAK,EACnB,MAAM,EAAE,MAAM,CAAC,MAAM,EACrB,SAAS,EAAE,MAAM,CAAC,SAAS,GAC3B,CACH,CACG,CACkB,CACtB,CACP,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,QAAQ,CAAC,MAAM,GAAG,cAAc,CAAC;AACjC,QAAQ,CAAC,OAAO,GAAG,eAAe,CAAC"}
@@ -0,0 +1,18 @@
1
+ import type { Middleware, Placement } from "@floating-ui/react-dom";
2
+ declare const SIDE_OPTIONS: readonly ["top", "right", "bottom", "left"];
3
+ declare const ALIGN_OPTIONS: readonly ["start", "center", "end"];
4
+ type Side = (typeof SIDE_OPTIONS)[number];
5
+ type Align = (typeof ALIGN_OPTIONS)[number];
6
+ type Measurable = {
7
+ getBoundingClientRect(): DOMRect;
8
+ };
9
+ /**
10
+ * `transformOrigin` is a custom middleware for floating-ui that calculates the transform origin of the floating-element.
11
+ */
12
+ declare function transformOrigin(options: {
13
+ arrowWidth: number;
14
+ arrowHeight: number;
15
+ }): Middleware;
16
+ declare function getSideAndAlignFromPlacement(placement: Placement): readonly ["left" | "right" | "bottom" | "top", "center" | "start" | "end"];
17
+ export { getSideAndAlignFromPlacement, transformOrigin };
18
+ export type { Side, Align, Measurable };