@navikt/ds-react 7.33.0 → 7.33.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 (57) hide show
  1. package/cjs/form/combobox/FilteredOptions/FilteredOptions.js +0 -1
  2. package/cjs/form/combobox/FilteredOptions/FilteredOptions.js.map +1 -1
  3. package/cjs/overlays/action-menu/ActionMenu.js +2 -5
  4. package/cjs/overlays/action-menu/ActionMenu.js.map +1 -1
  5. package/cjs/overlays/dismissablelayer/DismissableLayer.d.ts +3 -30
  6. package/cjs/overlays/dismissablelayer/DismissableLayer.js +141 -134
  7. package/cjs/overlays/dismissablelayer/DismissableLayer.js.map +1 -1
  8. package/cjs/overlays/dismissablelayer/util/sort-layers.d.ts +18 -0
  9. package/cjs/overlays/dismissablelayer/util/sort-layers.js +51 -0
  10. package/cjs/overlays/dismissablelayer/util/sort-layers.js.map +1 -0
  11. package/cjs/overlays/floating-menu/Menu.d.ts +5 -7
  12. package/cjs/overlays/floating-menu/Menu.js +7 -15
  13. package/cjs/overlays/floating-menu/Menu.js.map +1 -1
  14. package/cjs/popover/Popover.js +0 -1
  15. package/cjs/popover/Popover.js.map +1 -1
  16. package/cjs/portal/Portal.d.ts +1 -3
  17. package/cjs/portal/Portal.js +49 -17
  18. package/cjs/portal/Portal.js.map +1 -1
  19. package/cjs/tooltip/Tooltip.js +23 -22
  20. package/cjs/tooltip/Tooltip.js.map +1 -1
  21. package/cjs/util/focus-boundary/FocusBoundary.d.ts +19 -10
  22. package/cjs/util/focus-boundary/FocusBoundary.js +107 -63
  23. package/cjs/util/focus-boundary/FocusBoundary.js.map +1 -1
  24. package/esm/form/combobox/FilteredOptions/FilteredOptions.js +0 -1
  25. package/esm/form/combobox/FilteredOptions/FilteredOptions.js.map +1 -1
  26. package/esm/overlays/action-menu/ActionMenu.js +2 -5
  27. package/esm/overlays/action-menu/ActionMenu.js.map +1 -1
  28. package/esm/overlays/dismissablelayer/DismissableLayer.d.ts +3 -30
  29. package/esm/overlays/dismissablelayer/DismissableLayer.js +140 -132
  30. package/esm/overlays/dismissablelayer/DismissableLayer.js.map +1 -1
  31. package/esm/overlays/dismissablelayer/util/sort-layers.d.ts +18 -0
  32. package/esm/overlays/dismissablelayer/util/sort-layers.js +49 -0
  33. package/esm/overlays/dismissablelayer/util/sort-layers.js.map +1 -0
  34. package/esm/overlays/floating-menu/Menu.d.ts +5 -7
  35. package/esm/overlays/floating-menu/Menu.js +7 -15
  36. package/esm/overlays/floating-menu/Menu.js.map +1 -1
  37. package/esm/popover/Popover.js +0 -1
  38. package/esm/popover/Popover.js.map +1 -1
  39. package/esm/portal/Portal.d.ts +1 -3
  40. package/esm/portal/Portal.js +50 -18
  41. package/esm/portal/Portal.js.map +1 -1
  42. package/esm/tooltip/Tooltip.js +23 -22
  43. package/esm/tooltip/Tooltip.js.map +1 -1
  44. package/esm/util/focus-boundary/FocusBoundary.d.ts +19 -10
  45. package/esm/util/focus-boundary/FocusBoundary.js +108 -64
  46. package/esm/util/focus-boundary/FocusBoundary.js.map +1 -1
  47. package/package.json +3 -3
  48. package/src/form/combobox/FilteredOptions/FilteredOptions.tsx +0 -1
  49. package/src/overlays/action-menu/ActionMenu.tsx +2 -4
  50. package/src/overlays/dismissablelayer/DismissableLayer.tsx +219 -194
  51. package/src/overlays/dismissablelayer/util/sort-layers.test.ts +128 -0
  52. package/src/overlays/dismissablelayer/util/sort-layers.ts +61 -0
  53. package/src/overlays/floating-menu/Menu.tsx +11 -21
  54. package/src/popover/Popover.tsx +0 -1
  55. package/src/portal/Portal.tsx +89 -31
  56. package/src/tooltip/Tooltip.tsx +4 -4
  57. package/src/util/focus-boundary/FocusBoundary.tsx +164 -93
@@ -9,120 +9,74 @@ var __rest = (this && this.__rest) || function (s, e) {
9
9
  }
10
10
  return t;
11
11
  };
12
- import React, { forwardRef, useEffect, useRef, useState, } from "react";
12
+ import React, { forwardRef, useContext, useEffect, useState } from "react";
13
13
  import { Slot } from "../../slot/Slot.js";
14
+ import { omit } from "../../util/index.js";
15
+ import { composeEventHandlers } from "../../util/composeEventHandlers.js";
14
16
  import { useMergeRefs } from "../../util/hooks/index.js";
15
- import { createDescendantContext } from "../../util/hooks/descendants/useDescendant.js";
16
17
  import { ownerDocument } from "../../util/owner.js";
18
+ import { getSortedLayers } from "./util/sort-layers.js";
17
19
  import { useEscapeKeydown } from "./util/useEscapeKeydown.js";
18
20
  import { useFocusOutside } from "./util/useFocusOutside.js";
19
21
  import { usePointerDownOutside } from "./util/usePointerDownOutside.js";
20
- export const [DismissableDescendantsProvider, useDismissableDescendantsContext, useDismissableDescendants, useDismissableDescendant,] = createDescendantContext();
21
- /**
22
- * Number of layers with `disableOutsidePointerEvents` set to `true` currently enabled.
23
- */
24
- let bodyLockCount = 0;
22
+ const DismissableLayer = forwardRef((_a, forwardedRef) => {
23
+ var { enabled = true } = _a, restProps = __rest(_a, ["enabled"]);
24
+ if (!enabled) {
25
+ const Component = restProps.asChild ? Slot : "div";
26
+ return (React.createElement(Component, Object.assign({}, omit(restProps, [
27
+ "asChild",
28
+ "disableOutsidePointerEvents",
29
+ "onDismiss",
30
+ "onEscapeKeyDown",
31
+ "onFocusOutside",
32
+ "onInteractOutside",
33
+ "onPointerDownOutside",
34
+ "safeZone",
35
+ ]), { ref: forwardedRef })));
36
+ }
37
+ return React.createElement(DismissableLayerInternal, Object.assign({}, restProps, { ref: forwardedRef }));
38
+ });
39
+ const BranchedLayerContext = React.createContext(null);
40
+ /* ------------------------ DismissableLayerInternal ------------------------ */
41
+ const CONTEXT_UPDATE_EVENT = "dismissableLayer.update";
25
42
  let originalBodyPointerEvents;
26
- const DismissableLayer = forwardRef((props, ref) => {
27
- const context = useDismissableDescendantsContext(false);
28
- /**
29
- * To correctly handle nested DismissableLayer,
30
- * we only initialize the `Descendants`-API for the root layer to aboid resetting context
31
- */
32
- return context ? (React.createElement(DismissableLayerNode, Object.assign({ ref: ref }, props))) : (React.createElement(DismissableRoot, null,
33
- React.createElement(DismissableLayerNode, Object.assign({ ref: ref }, props))));
43
+ const DismissableLayerContext = React.createContext({
44
+ layers: new Set(),
45
+ branchedLayers: new Map(),
46
+ layersWithOutsidePointerEventsDisabled: new Set(),
34
47
  });
35
- /**
36
- * DismissableRoot
37
- *
38
- * Used to initialize the `Descendants`-API at the root layer.
39
- * All subsequent layers will use the same context.
40
- */
41
- const DismissableRoot = ({ children }) => {
42
- const descendants = useDismissableDescendants();
43
- return (React.createElement(DismissableDescendantsProvider, { value: descendants }, children));
44
- };
45
- const DismissableLayerNode = forwardRef((_a, ref) => {
46
- var { children, asChild, onEscapeKeyDown, onPointerDownOutside, onFocusOutside, onInteractOutside, onDismiss, safeZone, disableOutsidePointerEvents = false, enabled = true } = _a, rest = __rest(_a, ["children", "asChild", "onEscapeKeyDown", "onPointerDownOutside", "onFocusOutside", "onInteractOutside", "onDismiss", "safeZone", "disableOutsidePointerEvents", "enabled"]);
47
- const [, setForce] = useState({});
48
- const { register, index, descendants } = useDismissableDescendant({
49
- disableOutsidePointerEvents,
50
- disabled: !enabled,
51
- forceUpdate: () => setForce({}),
52
- });
53
- /**
54
- * `node` will be set to the ref of the component or nested component
55
- * Ex: If
56
- * ```
57
- * <DismissableLayer asChild>
58
- * <Popover />
59
- * </DismissableLayer>
60
- * ```
61
- * `node` will in this case be the Popover-element.
62
- * We use State her and not ref since we want to trigger a rerender when the node changes.
63
- */
64
- const [node, setNode] = useState(null);
65
- const mergedRefs = useMergeRefs(setNode, register, ref);
48
+ const DismissableLayerInternal = forwardRef((_a, forwardedRef) => {
49
+ var { children, disableOutsidePointerEvents, onDismiss, onInteractOutside, onEscapeKeyDown, onFocusOutside, onPointerDownOutside, safeZone, asChild } = _a, restProps = __rest(_a, ["children", "disableOutsidePointerEvents", "onDismiss", "onInteractOutside", "onEscapeKeyDown", "onFocusOutside", "onPointerDownOutside", "safeZone", "asChild"]);
50
+ const context = useContext(DismissableLayerContext);
51
+ const [, forceRerender] = useState({});
52
+ const [node, setNode] = React.useState(null);
53
+ const mergedRefs = useMergeRefs(forwardedRef, setNode);
66
54
  const ownerDoc = ownerDocument(node);
67
- const hasInteractedOutsideRef = useRef(false);
68
- const hasPointerDownOutsideRef = useRef(false);
69
- const pointerState = (() => {
70
- let lastIndex = -1;
71
- const descendantNodes = descendants.enabledValues();
72
- descendantNodes.forEach((obj, _index) => {
73
- if (obj.disableOutsidePointerEvents) {
74
- lastIndex = _index;
75
- }
76
- });
77
- return {
78
- /**
79
- * Makes sure we stop events at the highest layer with pointer events disabled.
80
- * If not checked, we risk closing every layer when clicking outside the layer.
81
- */
82
- isPointerEventsEnabled: index >= lastIndex,
83
- /**
84
- * If we find a node with `disableOutsidePointerEvents` we want to disable pointer events on the body.
85
- */
86
- isBodyPointerEventsDisabled: bodyLockCount > 0,
87
- pointerStyle: (index >= lastIndex && bodyLockCount > 0
88
- ? "auto"
89
- : undefined),
90
- };
91
- })();
55
+ /* Layer handling */
56
+ const layers = getSortedLayers(context.layers, context.branchedLayers);
57
+ const highestLayerWithOutsidePointerEventsDisabledIndex = findHighestLayerIndex(layers, context.layersWithOutsidePointerEventsDisabled);
58
+ const index = node ? layers.indexOf(node) : -1;
59
+ const isBodyPointerEventsDisabled = context.layersWithOutsidePointerEventsDisabled.size > 0;
60
+ const shouldEnablePointerEvents = highestLayerWithOutsidePointerEventsDisabledIndex === -1 ||
61
+ index >= highestLayerWithOutsidePointerEventsDisabledIndex;
92
62
  /**
93
- * We want to prevent the Layer from closing when the trigger, anchor element, or its child elements are interacted with.
94
- *
95
- * To achieve this, we check if the event target is the trigger, anchor or a child. If it is, we prevent default event behavior.
96
- *
97
- * The `pointerDownOutside` and `focusOutside` handlers already check if the event target is within the DismissableLayer (`node`).
98
- * However, since we don't add a `tabIndex` to the Popover/Tooltip, the `focusOutside` handler doesn't correctly handle focus events.
99
- * Therefore, we also need to check that neither the trigger (`anchor`) nor the DismissableLayer (`dismissable`) are the event targets.
63
+ * We want to prevent the Layer from closing when the trigger/anchor element or its child elements are interacted with.
64
+ * To achieve this, we check if the event target is the trigger/anchor or a child. If it is, we prevent default event behavior.
100
65
  */
101
66
  function handleOutsideEvent(event) {
102
- var _a, _b;
103
- if ((!(safeZone === null || safeZone === void 0 ? void 0 : safeZone.anchor) && !(safeZone === null || safeZone === void 0 ? void 0 : safeZone.dismissable)) || !enabled) {
67
+ if (!(safeZone === null || safeZone === void 0 ? void 0 : safeZone.anchor)) {
104
68
  return;
105
69
  }
70
+ let hasPointerDownOutside = false;
106
71
  if (!event.defaultPrevented) {
107
- hasInteractedOutsideRef.current = true;
108
72
  if (event.detail.originalEvent.type === "pointerdown") {
109
- hasPointerDownOutsideRef.current = true;
73
+ hasPointerDownOutside = true;
110
74
  }
111
75
  }
112
76
  const target = event.target;
113
- /**
114
- * pointerdown-events works as expected, but focus-events does not.
115
- * For focus-event we need to also check `safeZone.dismissable` (the Popover/Tooltip itself) since it does not have a tabIndex.
116
- */
117
- if (event.detail.originalEvent.type === "pointerdown") {
118
- const targetIsTrigger = ((_a = safeZone === null || safeZone === void 0 ? void 0 : safeZone.anchor) === null || _a === void 0 ? void 0 : _a.contains(target)) || target === (safeZone === null || safeZone === void 0 ? void 0 : safeZone.anchor);
119
- targetIsTrigger && event.preventDefault();
120
- }
121
- else {
122
- const targetIsNotTrigger = target instanceof HTMLElement &&
123
- ![safeZone === null || safeZone === void 0 ? void 0 : safeZone.anchor, safeZone === null || safeZone === void 0 ? void 0 : safeZone.dismissable].some((element) => element === null || element === void 0 ? void 0 : element.contains(target)) &&
124
- !target.contains((_b = safeZone === null || safeZone === void 0 ? void 0 : safeZone.dismissable) !== null && _b !== void 0 ? _b : null);
125
- !targetIsNotTrigger && event.preventDefault();
77
+ const targetIsAnchor = safeZone.anchor.contains(target) || target === safeZone.anchor;
78
+ if (targetIsAnchor) {
79
+ event.preventDefault();
126
80
  }
127
81
  /**
128
82
  * In Safari, if the trigger element is inside a container with tabIndex={0}, a click on the trigger
@@ -133,18 +87,16 @@ const DismissableLayerNode = forwardRef((_a, ref) => {
133
87
  * 'pointerdownoutside' event is sufficient to indicate interaction outside the DismissableLayer.
134
88
  */
135
89
  if (event.detail.originalEvent.type === "focusin" &&
136
- hasPointerDownOutsideRef.current) {
90
+ hasPointerDownOutside) {
137
91
  event.preventDefault();
138
92
  }
139
- hasPointerDownOutsideRef.current = false;
140
- hasInteractedOutsideRef.current = false;
141
93
  }
142
94
  const pointerDownOutside = usePointerDownOutside((event) => {
143
- if (!pointerState.isPointerEventsEnabled || !enabled) {
95
+ if (!shouldEnablePointerEvents) {
144
96
  return;
145
97
  }
146
98
  /**
147
- * We call these before letting `handleOutsideEvent` do its checks to give consumer a chance to preventDefault based certain cases.
99
+ * We call these before letting `handleOutsideEvent` do its checks to give consumer a chance to preventDefault.
148
100
  */
149
101
  onPointerDownOutside === null || onPointerDownOutside === void 0 ? void 0 : onPointerDownOutside(event);
150
102
  onInteractOutside === null || onInteractOutside === void 0 ? void 0 : onInteractOutside(event);
@@ -152,19 +104,13 @@ const DismissableLayerNode = forwardRef((_a, ref) => {
152
104
  * Add safeZone to prevent closing when interacting with trigger/anchor or its children.
153
105
  */
154
106
  safeZone && handleOutsideEvent(event);
155
- /**
156
- * Both `onPointerDownOutside` and `onInteractOutside` are able to preventDefault the event, thus stopping call for `onDismiss`.
157
- */
158
107
  if (!event.defaultPrevented && onDismiss) {
159
108
  onDismiss();
160
109
  }
161
110
  }, ownerDoc);
162
111
  const focusOutside = useFocusOutside((event) => {
163
- if (!enabled) {
164
- return;
165
- }
166
112
  /**
167
- * We call these before letting `handleOutsideEvent` do its checks to give consumer a chance to preventDefault based certain cases.
113
+ * We call these before letting `handleOutsideEvent` do its checks to give consumer a chance to preventDefault.
168
114
  */
169
115
  onFocusOutside === null || onFocusOutside === void 0 ? void 0 : onFocusOutside(event);
170
116
  onInteractOutside === null || onInteractOutside === void 0 ? void 0 : onInteractOutside(event);
@@ -172,24 +118,16 @@ const DismissableLayerNode = forwardRef((_a, ref) => {
172
118
  * Add safeZone to prevent closing when interacting with trigger/anchor or its children.
173
119
  */
174
120
  safeZone && handleOutsideEvent(event);
175
- /**
176
- * Both `onFocusOutside` and `onInteractOutside` are able to preventDefault the event, thus stopping call for `onDismiss`.
177
- */
178
121
  if (!event.defaultPrevented && onDismiss) {
179
122
  onDismiss();
180
123
  }
181
124
  }, ownerDoc);
182
125
  useEscapeKeydown((event) => {
183
- if (!enabled) {
184
- return;
185
- }
186
126
  /**
187
127
  * The deepest nested element will always be last in the descendants list.
188
128
  * This allows us to only close the highest layer when pressing escape.
189
- *
190
- * In some cases a layer might still exist, but be disabled. We want to ignore these layers.
191
129
  */
192
- const isHighestLayer = index === descendants.enabledCount() - 1;
130
+ const isHighestLayer = index === context.layers.size - 1;
193
131
  if (!isHighestLayer) {
194
132
  return;
195
133
  }
@@ -207,34 +145,104 @@ const DismissableLayerNode = forwardRef((_a, ref) => {
207
145
  }
208
146
  }, ownerDoc);
209
147
  /**
210
- * If `disableOutsidePointerEvents` is true,
211
- * we want to disable pointer events on the body when the first layer is opened.
148
+ * Handles registering `layers` and `layersWithOutsidePointerEventsDisabled`.
212
149
  */
213
- // biome-ignore lint/correctness/useExhaustiveDependencies: Every time the descendants change, we want to update the body pointer events since we might have added or removed a layer.
214
150
  useEffect(() => {
215
- if (!node || !enabled || !disableOutsidePointerEvents)
151
+ if (!node) {
216
152
  return;
217
- if (bodyLockCount === 0) {
218
- originalBodyPointerEvents = ownerDoc.body.style.pointerEvents;
219
- ownerDoc.body.style.pointerEvents = "none";
220
153
  }
221
- bodyLockCount++;
154
+ if (disableOutsidePointerEvents) {
155
+ if (context.layersWithOutsidePointerEventsDisabled.size === 0) {
156
+ originalBodyPointerEvents = ownerDoc.body.style.pointerEvents;
157
+ ownerDoc.body.style.pointerEvents = "none";
158
+ }
159
+ context.layersWithOutsidePointerEventsDisabled.add(node);
160
+ }
161
+ context.layers.add(node);
162
+ dispatchUpdate();
222
163
  return () => {
223
- if (bodyLockCount === 1) {
164
+ if (disableOutsidePointerEvents &&
165
+ context.layersWithOutsidePointerEventsDisabled.size === 1) {
224
166
  ownerDoc.body.style.pointerEvents = originalBodyPointerEvents;
225
167
  }
226
- bodyLockCount--;
227
168
  };
228
- }, [node, ownerDoc, disableOutsidePointerEvents, descendants, enabled]);
169
+ }, [node, disableOutsidePointerEvents, context, ownerDoc]);
170
+ /**
171
+ * We purposefully prevent combining this effect with the `disableOutsidePointerEvents` effect
172
+ * because a change to `disableOutsidePointerEvents` would remove this layer from the stack
173
+ * and add it to the end again so the layering order wouldn't be creation order.
174
+ * We only want them to be removed from context stacks when unmounted.
175
+ */
176
+ useEffect(() => {
177
+ return () => {
178
+ if (!node) {
179
+ return;
180
+ }
181
+ context.layers.delete(node);
182
+ context.layersWithOutsidePointerEventsDisabled.delete(node);
183
+ dispatchUpdate();
184
+ };
185
+ }, [node, context]);
186
+ const parentBranchedLayer = useContext(BranchedLayerContext);
187
+ /**
188
+ * Handles registering and unregistering branched (nested) layers.
189
+ * When this layer has a parent, we register it as a child of the parent.
190
+ */
191
+ useEffect(() => {
192
+ if (!node || !parentBranchedLayer || node === parentBranchedLayer) {
193
+ return;
194
+ }
195
+ if (!context.branchedLayers.has(parentBranchedLayer)) {
196
+ context.branchedLayers.set(parentBranchedLayer, new Set());
197
+ }
198
+ const branchedChildren = context.branchedLayers.get(parentBranchedLayer);
199
+ branchedChildren.add(node);
200
+ dispatchUpdate();
201
+ return () => {
202
+ // Remove this node from the parent's children
203
+ branchedChildren.delete(node);
204
+ // If the parent has no more children, remove the parent from branchedLayers
205
+ if (branchedChildren.size === 0) {
206
+ context.branchedLayers.delete(parentBranchedLayer);
207
+ }
208
+ dispatchUpdate();
209
+ };
210
+ }, [node, parentBranchedLayer, context]);
229
211
  /**
230
- * To make sure pointerEvents are enabled for all parents and siblings when the layer is removed from the DOM
212
+ * Synchronizes layer state across all mounted `DismissableLayer` instances.
213
+ * All layers re-render on every context change to recalculate their position and pointer-events.
231
214
  */
232
- // biome-ignore lint/correctness/useExhaustiveDependencies: We explicitly want to run this on unmount, including every time the node updates to make sure we don't lock the application behind pointer-events: none.
233
215
  useEffect(() => {
234
- return () => descendants.values().forEach((x) => x.forceUpdate());
235
- }, [descendants, node]);
216
+ const handleUpdate = () => forceRerender({});
217
+ document.addEventListener(CONTEXT_UPDATE_EVENT, handleUpdate);
218
+ return () => document.removeEventListener(CONTEXT_UPDATE_EVENT, handleUpdate);
219
+ }, []);
236
220
  const Comp = asChild ? Slot : "div";
237
- return (React.createElement(Comp, Object.assign({ ref: mergedRefs }, rest, { onFocusCapture: focusOutside.onFocusCapture, onBlurCapture: focusOutside.onBlurCapture, onPointerDownCapture: pointerDownOutside.onPointerDownCapture, style: Object.assign({ pointerEvents: pointerState.pointerStyle }, rest.style) }), children));
221
+ return (React.createElement(BranchedLayerContext.Provider, { value: node },
222
+ React.createElement(Comp, Object.assign({}, restProps, { ref: mergedRefs, style: Object.assign({ pointerEvents: isBodyPointerEventsDisabled
223
+ ? shouldEnablePointerEvents
224
+ ? "auto"
225
+ : "none"
226
+ : undefined }, restProps.style), onFocusCapture: composeEventHandlers(restProps.onFocusCapture, focusOutside.onFocusCapture), onBlurCapture: composeEventHandlers(restProps.onBlurCapture, focusOutside.onBlurCapture), onPointerDownCapture: composeEventHandlers(restProps.onPointerDownCapture, pointerDownOutside.onPointerDownCapture) }), children)));
238
227
  });
228
+ /**
229
+ * Dispatches a custom event to inform all `DismissableLayer` components to update.
230
+ */
231
+ function dispatchUpdate() {
232
+ const event = new CustomEvent(CONTEXT_UPDATE_EVENT);
233
+ document.dispatchEvent(event);
234
+ }
235
+ /**
236
+ * Returns the index of the last layer that is found in the given subset.
237
+ * Returns -1 if no layers are found.
238
+ */
239
+ function findHighestLayerIndex(orderedLayers, layersWithOutsidePointerEventsDisabled) {
240
+ for (let i = orderedLayers.length - 1; i >= 0; i -= 1) {
241
+ if (layersWithOutsidePointerEventsDisabled.has(orderedLayers[i])) {
242
+ return i;
243
+ }
244
+ }
245
+ return -1;
246
+ }
239
247
  export { DismissableLayer };
240
248
  //# sourceMappingURL=DismissableLayer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"DismissableLayer.js","sourceRoot":"","sources":["../../../src/overlays/dismissablelayer/DismissableLayer.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,EAEZ,UAAU,EACV,SAAS,EACT,MAAM,EACN,QAAQ,GACT,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,uBAAuB,EAAE,MAAM,4CAA4C,CAAC;AACrF,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAMjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAsDrE,MAAM,CAAC,MAAM,CACX,8BAA8B,EAC9B,gCAAgC,EAChC,yBAAyB,EACzB,wBAAwB,EACzB,GAAG,uBAAuB,EAGxB,CAAC;AAEJ;;GAEG;AACH,IAAI,aAAa,GAAG,CAAC,CAAC;AACtB,IAAI,yBAAiC,CAAC;AAEtC,MAAM,gBAAgB,GAAG,UAAU,CACjC,CAAC,KAA4B,EAAE,GAAG,EAAE,EAAE;IACpC,MAAM,OAAO,GAAG,gCAAgC,CAAC,KAAK,CAAC,CAAC;IAExD;;;OAGG;IACH,OAAO,OAAO,CAAC,CAAC,CAAC,CACf,oBAAC,oBAAoB,kBAAC,GAAG,EAAE,GAAG,IAAM,KAAK,EAAI,CAC9C,CAAC,CAAC,CAAC,CACF,oBAAC,eAAe;QACd,oBAAC,oBAAoB,kBAAC,GAAG,EAAE,GAAG,IAAM,KAAK,EAAI,CAC7B,CACnB,CAAC;AACJ,CAAC,CACF,CAAC;AAEF;;;;;GAKG;A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OAAO,EAAE,gBAAgB,EAA8B,CAAC"}
1
+ {"version":3,"file":"DismissableLayer.js","sourceRoot":"","sources":["../../../src/overlays/dismissablelayer/DismissableLayer.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC3E,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAClC,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AACvE,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAMjD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAmDrE,MAAM,gBAAgB,GAAG,UAAU,CACjC,CAAC,EAAuD,EAAE,YAAY,EAAE,EAAE;QAAzE,EAAE,OAAO,GAAG,IAAI,OAAuC,EAAlC,SAAS,cAA9B,WAAgC,CAAF;IAC7B,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,SAAS,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC;QACnD,OAAO,CACL,oBAAC,SAAS,oBACJ,IAAI,CAAC,SAAS,EAAE;YAClB,SAAS;YACT,6BAA6B;YAC7B,WAAW;YACX,iBAAiB;YACjB,gBAAgB;YAChB,mBAAmB;YACnB,sBAAsB;YACtB,UAAU;SACX,CAAC,IACF,GAAG,EAAE,YAAY,IACjB,CACH,CAAC;IACJ,CAAC;IAED,OAAO,oBAA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SAAS,IACb,GAAG,EAAE,UAAU,EACf,KAAK,kBACH,aAAa,EAAE,2BAA2B;oBACxC,CAAC,CAAC,yBAAyB;wBACzB,CAAC,CAAC,MAAM;wBACR,CAAC,CAAC,MAAM;oBACV,CAAC,CAAC,SAAS,IACV,SAAS,CAAC,KAAK,GAEpB,cAAc,EAAE,oBAAoB,CAClC,SAAS,CAAC,cAAc,EACxB,YAAY,CAAC,cAAc,CAC5B,EACD,aAAa,EAAE,oBAAoB,CACjC,SAAS,CAAC,aAAa,EACvB,YAAY,CAAC,aAAa,CAC3B,EACD,oBAAoB,EAAE,oBAAoB,CACxC,SAAS,CAAC,oBAAoB,EAC9B,kBAAkB,CAAC,oBAAoB,CACxC,KAEA,QAAQ,CACJ,CACuB,CACjC,CAAC;AACJ,CAAC,CACF,CAAC;AAEF;;GAEG;AACH,SAAS,cAAc;IACrB,MAAM,KAAK,GAAG,IAAI,WAAW,CAAC,oBAAoB,CAAC,CAAC;IACpD,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;AAChC,CAAC;AAED;;;GAGG;AACH,SAAS,qBAAqB,CAC5B,aAAwC,EACxC,sCAAoE;IAEpE,KAAK,IAAI,CAAC,GAAG,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;QACtD,IAAI,sCAAsC,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YACjE,OAAO,CAAC,CAAC;QACX,CAAC;IACH,CAAC;IAED,OAAO,CAAC,CAAC,CAAC;AACZ,CAAC;AAED,OAAO,EAAE,gBAAgB,EAA8B,CAAC"}
@@ -0,0 +1,18 @@
1
+ type DismissableLayerElement = HTMLDivElement;
2
+ /**
3
+ * Returns an array of layers sorted such that parents appear before their children.
4
+ *
5
+ * **Why**:
6
+ * - mount order for parent-child relationships is unstable due to portals
7
+ * - event handling relies on parents being before children in the array
8
+ *
9
+ * This function ensures that for any parent-child relationship, the parent layer
10
+ * will always appear before its child layer in the returned array,
11
+ * resulting in consistent behavior.
12
+ *
13
+ * @param layers - A set of DismissableLayerElements to be sorted.
14
+ * @param branchedLayers - A map where each key is a parent layer and its value is a set of child layers.
15
+ * @returns An array of DismissableLayerElements sorted by parent-child relationships.
16
+ */
17
+ declare function getSortedLayers(layers: Set<DismissableLayerElement>, branchedLayers: Map<DismissableLayerElement, Set<DismissableLayerElement>>): DismissableLayerElement[];
18
+ export { getSortedLayers };
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Returns an array of layers sorted such that parents appear before their children.
3
+ *
4
+ * **Why**:
5
+ * - mount order for parent-child relationships is unstable due to portals
6
+ * - event handling relies on parents being before children in the array
7
+ *
8
+ * This function ensures that for any parent-child relationship, the parent layer
9
+ * will always appear before its child layer in the returned array,
10
+ * resulting in consistent behavior.
11
+ *
12
+ * @param layers - A set of DismissableLayerElements to be sorted.
13
+ * @param branchedLayers - A map where each key is a parent layer and its value is a set of child layers.
14
+ * @returns An array of DismissableLayerElements sorted by parent-child relationships.
15
+ */
16
+ function getSortedLayers(layers, branchedLayers) {
17
+ const sorted = [];
18
+ const visited = new Set();
19
+ const parentMap = new Map();
20
+ branchedLayers.forEach((children, parent) => {
21
+ children.forEach((child) => {
22
+ if (child !== parent) {
23
+ parentMap.set(child, parent);
24
+ }
25
+ });
26
+ });
27
+ const walk = (layer) => {
28
+ if (visited.has(layer)) {
29
+ return;
30
+ }
31
+ const parent = parentMap.get(layer);
32
+ if (parent && !visited.has(parent)) {
33
+ walk(parent);
34
+ if (visited.has(layer)) {
35
+ return;
36
+ }
37
+ }
38
+ visited.add(layer);
39
+ sorted.push(layer);
40
+ const children = branchedLayers.get(layer);
41
+ if (children) {
42
+ children.forEach(walk);
43
+ }
44
+ };
45
+ layers.forEach(walk);
46
+ return sorted;
47
+ }
48
+ export { getSortedLayers };
49
+ //# sourceMappingURL=sort-layers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":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AC;IACH,CAAC,CAAC;IAEF,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAErB,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,OAAO,EAAE,eAAe,EAAE,CAAC"}
@@ -35,16 +35,12 @@ declare const MenuContent: React.ForwardRefExoticComponent<MenuContentInternalTy
35
35
  type FocusScopeProps = React.ComponentPropsWithoutRef<typeof FocusBoundary>;
36
36
  type DismissableLayerProps = React.ComponentPropsWithoutRef<typeof DismissableLayer>;
37
37
  type MenuContentInternalPrivateProps = {
38
- onOpenAutoFocus?: FocusScopeProps["onMountAutoFocus"];
38
+ initialFocus?: FocusScopeProps["initialFocus"];
39
39
  onDismiss?: DismissableLayerProps["onDismiss"];
40
40
  disableOutsidePointerEvents?: DismissableLayerProps["disableOutsidePointerEvents"];
41
41
  };
42
42
  interface MenuContentInternalProps extends MenuContentInternalPrivateProps, Omit<React.ComponentPropsWithoutRef<typeof Floating.Content>, "dir" | "onPlaced"> {
43
- /**
44
- * Event handler called when auto-focusing after close.
45
- * Can be prevented.
46
- */
47
- onCloseAutoFocus?: FocusScopeProps["onUnmountAutoFocus"];
43
+ returnFocus?: FocusScopeProps["returnFocus"];
48
44
  onEntryFocus?: RovingFocusProps["onEntryFocus"];
49
45
  onEscapeKeyDown?: DismissableLayerProps["onEscapeKeyDown"];
50
46
  onPointerDownOutside?: DismissableLayerProps["onPointerDownOutside"];
@@ -68,7 +64,9 @@ type PortalProps = React.ComponentPropsWithoutRef<typeof Portal>;
68
64
  type MenuPortalProps = PortalProps & {
69
65
  children: React.ReactElement;
70
66
  };
71
- declare const MenuPortal: React.ForwardRefExoticComponent<MenuPortalProps & React.RefAttributes<HTMLDivElement>>;
67
+ declare const MenuPortal: React.ForwardRefExoticComponent<Omit<import("../../portal/index.js").PortalProps & React.RefAttributes<HTMLDivElement>, "ref"> & {
68
+ children: React.ReactElement;
69
+ } & React.RefAttributes<HTMLDivElement>>;
72
70
  interface MenuRadioGroupProps extends MenuGroupProps {
73
71
  value?: string;
74
72
  onValueChange?: (value: string) => void;
@@ -103,19 +103,13 @@ const MenuRootContentModal = forwardRef((props, ref) => {
103
103
  onFocusOutside: composeEventHandlers(props.onFocusOutside, (event) => event.preventDefault(), { checkForDefaultPrevented: false }), onDismiss: () => context.onOpenChange(false) })));
104
104
  });
105
105
  const MenuContentInternal = forwardRef((_a, forwardedRef) => {
106
- var { onOpenAutoFocus, onCloseAutoFocus, disableOutsidePointerEvents, onEntryFocus, onEscapeKeyDown, onPointerDownOutside, onFocusOutside, onInteractOutside, onDismiss, safeZone } = _a, rest = __rest(_a, ["onOpenAutoFocus", "onCloseAutoFocus", "disableOutsidePointerEvents", "onEntryFocus", "onEscapeKeyDown", "onPointerDownOutside", "onFocusOutside", "onInteractOutside", "onDismiss", "safeZone"]);
106
+ var { initialFocus, returnFocus, disableOutsidePointerEvents, onEntryFocus, onEscapeKeyDown, onPointerDownOutside, onFocusOutside, onInteractOutside, onDismiss, safeZone } = _a, rest = __rest(_a, ["initialFocus", "returnFocus", "disableOutsidePointerEvents", "onEntryFocus", "onEscapeKeyDown", "onPointerDownOutside", "onFocusOutside", "onInteractOutside", "onDismiss", "safeZone"]);
107
107
  const descendants = useMenuDescendantsContext();
108
108
  const context = useMenuContext();
109
109
  const rootContext = useMenuRootContext();
110
110
  const contentRef = useRef(null);
111
111
  const composedRefs = useMergeRefs(forwardedRef, contentRef, context.onContentChange);
112
- return (React.createElement(FocusBoundary, { onMountAutoFocus: composeEventHandlers(onOpenAutoFocus, (event) => {
113
- var _a;
114
- // when opening, explicitly focus the content area only and leave
115
- // `onEntryFocus` in control of focusing first item
116
- event.preventDefault();
117
- (_a = contentRef.current) === null || _a === void 0 ? void 0 : _a.focus({ preventScroll: true });
118
- }), onUnmountAutoFocus: onCloseAutoFocus,
112
+ return (React.createElement(FocusBoundary, { initialFocus: initialFocus !== null && initialFocus !== void 0 ? initialFocus : contentRef, returnFocus: returnFocus,
119
113
  /* Focus trapping is handled in `Floating.Content: onKeyDown */
120
114
  trapped: false, loop: false },
121
115
  React.createElement(DismissableLayer, { asChild: true, disableOutsidePointerEvents: disableOutsidePointerEvents, onEscapeKeyDown: onEscapeKeyDown, onPointerDownOutside: onPointerDownOutside, onFocusOutside: onFocusOutside, onInteractOutside: onInteractOutside, onDismiss: onDismiss, safeZone: safeZone },
@@ -257,7 +251,7 @@ const MenuPortal = forwardRef(({ children, rootElement }, ref) => {
257
251
  if (!context.open) {
258
252
  return null;
259
253
  }
260
- return (React.createElement(Portal, { asChild: true, rootElement: rootElement, ref: ref }, children));
254
+ return (React.createElement(Portal, { rootElement: rootElement, ref: ref }, children));
261
255
  });
262
256
  /* -------------------------------------------------------------------------- */
263
257
  /* Menu Radio */
@@ -375,16 +369,14 @@ const MenuSubContent = forwardRef((props, forwardedRef) => {
375
369
  const ref = useRef(null);
376
370
  const composedRefs = useMergeRefs(forwardedRef, ref);
377
371
  return (React.createElement(MenuDescendantsProvider, { value: descendants },
378
- React.createElement(MenuContentInternal, Object.assign({ id: subContext.contentId, "aria-labelledby": subContext.triggerId }, props, { ref: composedRefs, align: "start", side: "right", disableOutsidePointerEvents: false, onOpenAutoFocus: (event) => {
379
- var _a;
380
- // when opening a submenu, focus content for keyboard users only
372
+ React.createElement(MenuContentInternal, Object.assign({ id: subContext.contentId, "aria-labelledby": subContext.triggerId }, props, { ref: composedRefs, align: "start", side: "right", disableOutsidePointerEvents: false, initialFocus: () => {
381
373
  if (rootContext.isUsingKeyboardRef.current) {
382
- (_a = ref.current) === null || _a === void 0 ? void 0 : _a.focus();
374
+ return ref.current;
383
375
  }
384
- event.preventDefault();
376
+ return false;
385
377
  },
386
378
  /* Since we manually focus Subtrigger, we prevent use of auto-focus */
387
- onCloseAutoFocus: (event) => event.preventDefault(), onEscapeKeyDown: composeEventHandlers(props.onEscapeKeyDown, (event) => {
379
+ returnFocus: false, onEscapeKeyDown: composeEventHandlers(props.onEscapeKeyDown, (event) => {
388
380
  rootContext.onClose();
389
381
  // Ensure pressing escape in submenu doesn't escape full screen mode
390
382
  event.preventDefault();