@radix-ui/react-dismissable-layer 1.1.0-rc.2 → 1.1.0-rc.3

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.
package/dist/index.js CHANGED
@@ -1,246 +1,253 @@
1
1
  "use strict";
2
2
  "use client";
3
- (() => {
4
- var __create = Object.create;
5
- var __defProp = Object.defineProperty;
6
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7
- var __getOwnPropNames = Object.getOwnPropertyNames;
8
- var __getProtoOf = Object.getPrototypeOf;
9
- var __hasOwnProp = Object.prototype.hasOwnProperty;
10
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
11
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
12
- }) : x)(function(x) {
13
- if (typeof require !== "undefined") return require.apply(this, arguments);
14
- throw Error('Dynamic require of "' + x + '" is not supported');
15
- });
16
- var __copyProps = (to, from, except, desc) => {
17
- if (from && typeof from === "object" || typeof from === "function") {
18
- for (let key of __getOwnPropNames(from))
19
- if (!__hasOwnProp.call(to, key) && key !== except)
20
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
21
- }
22
- return to;
23
- };
24
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
25
- // If the importer is in node compatibility mode or this is not an ESM
26
- // file that has been converted to a CommonJS file using a Babel-
27
- // compatible transform (i.e. "__esModule" has not been set), then set
28
- // "default" to the CommonJS "module.exports" for node compatibility.
29
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
30
- mod
31
- ));
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __export = (target, all) => {
10
+ for (var name in all)
11
+ __defProp(target, name, { get: all[name], enumerable: true });
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from))
16
+ if (!__hasOwnProp.call(to, key) && key !== except)
17
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
+ }
19
+ return to;
20
+ };
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
+ // If the importer is in node compatibility mode or this is not an ESM
23
+ // file that has been converted to a CommonJS file using a Babel-
24
+ // compatible transform (i.e. "__esModule" has not been set), then set
25
+ // "default" to the CommonJS "module.exports" for node compatibility.
26
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
+ mod
28
+ ));
29
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
32
30
 
33
- // packages/react/dismissable-layer/src/DismissableLayer.tsx
34
- var React = __toESM(__require("react"));
35
- var import_primitive = __require("@radix-ui/primitive");
36
- var import_react_primitive = __require("@radix-ui/react-primitive");
37
- var import_react_compose_refs = __require("@radix-ui/react-compose-refs");
38
- var import_react_use_callback_ref = __require("@radix-ui/react-use-callback-ref");
39
- var import_react_use_escape_keydown = __require("@radix-ui/react-use-escape-keydown");
40
- var import_jsx_runtime = __require("react/jsx-runtime");
41
- var DISMISSABLE_LAYER_NAME = "DismissableLayer";
42
- var CONTEXT_UPDATE = "dismissableLayer.update";
43
- var POINTER_DOWN_OUTSIDE = "dismissableLayer.pointerDownOutside";
44
- var FOCUS_OUTSIDE = "dismissableLayer.focusOutside";
45
- var originalBodyPointerEvents;
46
- var DismissableLayerContext = React.createContext({
47
- layers: /* @__PURE__ */ new Set(),
48
- layersWithOutsidePointerEventsDisabled: /* @__PURE__ */ new Set(),
49
- branches: /* @__PURE__ */ new Set()
50
- });
51
- var DismissableLayer = React.forwardRef(
52
- (props, forwardedRef) => {
53
- const {
54
- disableOutsidePointerEvents = false,
55
- onEscapeKeyDown,
56
- onPointerDownOutside,
57
- onFocusOutside,
58
- onInteractOutside,
59
- onDismiss,
60
- ...layerProps
61
- } = props;
62
- const context = React.useContext(DismissableLayerContext);
63
- const [node, setNode] = React.useState(null);
64
- const ownerDocument = node?.ownerDocument ?? globalThis?.document;
65
- const [, force] = React.useState({});
66
- const composedRefs = (0, import_react_compose_refs.useComposedRefs)(forwardedRef, (node2) => setNode(node2));
67
- const layers = Array.from(context.layers);
68
- const [highestLayerWithOutsidePointerEventsDisabled] = [...context.layersWithOutsidePointerEventsDisabled].slice(-1);
69
- const highestLayerWithOutsidePointerEventsDisabledIndex = layers.indexOf(highestLayerWithOutsidePointerEventsDisabled);
70
- const index = node ? layers.indexOf(node) : -1;
71
- const isBodyPointerEventsDisabled = context.layersWithOutsidePointerEventsDisabled.size > 0;
72
- const isPointerEventsEnabled = index >= highestLayerWithOutsidePointerEventsDisabledIndex;
73
- const pointerDownOutside = usePointerDownOutside((event) => {
74
- const target = event.target;
75
- const isPointerDownOnBranch = [...context.branches].some((branch) => branch.contains(target));
76
- if (!isPointerEventsEnabled || isPointerDownOnBranch) return;
77
- onPointerDownOutside?.(event);
78
- onInteractOutside?.(event);
79
- if (!event.defaultPrevented) onDismiss?.();
80
- }, ownerDocument);
81
- const focusOutside = useFocusOutside((event) => {
82
- const target = event.target;
83
- const isFocusInBranch = [...context.branches].some((branch) => branch.contains(target));
84
- if (isFocusInBranch) return;
85
- onFocusOutside?.(event);
86
- onInteractOutside?.(event);
87
- if (!event.defaultPrevented) onDismiss?.();
88
- }, ownerDocument);
89
- (0, import_react_use_escape_keydown.useEscapeKeydown)((event) => {
90
- const isHighestLayer = index === context.layers.size - 1;
91
- if (!isHighestLayer) return;
92
- onEscapeKeyDown?.(event);
93
- if (!event.defaultPrevented && onDismiss) {
94
- event.preventDefault();
95
- onDismiss();
31
+ // packages/react/dismissable-layer/src/index.ts
32
+ var src_exports = {};
33
+ __export(src_exports, {
34
+ Branch: () => Branch,
35
+ DismissableLayer: () => DismissableLayer,
36
+ DismissableLayerBranch: () => DismissableLayerBranch,
37
+ Root: () => Root
38
+ });
39
+ module.exports = __toCommonJS(src_exports);
40
+
41
+ // packages/react/dismissable-layer/src/DismissableLayer.tsx
42
+ var React = __toESM(require("react"));
43
+ var import_primitive = require("@radix-ui/primitive");
44
+ var import_react_primitive = require("@radix-ui/react-primitive");
45
+ var import_react_compose_refs = require("@radix-ui/react-compose-refs");
46
+ var import_react_use_callback_ref = require("@radix-ui/react-use-callback-ref");
47
+ var import_react_use_escape_keydown = require("@radix-ui/react-use-escape-keydown");
48
+ var import_jsx_runtime = require("react/jsx-runtime");
49
+ var DISMISSABLE_LAYER_NAME = "DismissableLayer";
50
+ var CONTEXT_UPDATE = "dismissableLayer.update";
51
+ var POINTER_DOWN_OUTSIDE = "dismissableLayer.pointerDownOutside";
52
+ var FOCUS_OUTSIDE = "dismissableLayer.focusOutside";
53
+ var originalBodyPointerEvents;
54
+ var DismissableLayerContext = React.createContext({
55
+ layers: /* @__PURE__ */ new Set(),
56
+ layersWithOutsidePointerEventsDisabled: /* @__PURE__ */ new Set(),
57
+ branches: /* @__PURE__ */ new Set()
58
+ });
59
+ var DismissableLayer = React.forwardRef(
60
+ (props, forwardedRef) => {
61
+ const {
62
+ disableOutsidePointerEvents = false,
63
+ onEscapeKeyDown,
64
+ onPointerDownOutside,
65
+ onFocusOutside,
66
+ onInteractOutside,
67
+ onDismiss,
68
+ ...layerProps
69
+ } = props;
70
+ const context = React.useContext(DismissableLayerContext);
71
+ const [node, setNode] = React.useState(null);
72
+ const ownerDocument = node?.ownerDocument ?? globalThis?.document;
73
+ const [, force] = React.useState({});
74
+ const composedRefs = (0, import_react_compose_refs.useComposedRefs)(forwardedRef, (node2) => setNode(node2));
75
+ const layers = Array.from(context.layers);
76
+ const [highestLayerWithOutsidePointerEventsDisabled] = [...context.layersWithOutsidePointerEventsDisabled].slice(-1);
77
+ const highestLayerWithOutsidePointerEventsDisabledIndex = layers.indexOf(highestLayerWithOutsidePointerEventsDisabled);
78
+ const index = node ? layers.indexOf(node) : -1;
79
+ const isBodyPointerEventsDisabled = context.layersWithOutsidePointerEventsDisabled.size > 0;
80
+ const isPointerEventsEnabled = index >= highestLayerWithOutsidePointerEventsDisabledIndex;
81
+ const pointerDownOutside = usePointerDownOutside((event) => {
82
+ const target = event.target;
83
+ const isPointerDownOnBranch = [...context.branches].some((branch) => branch.contains(target));
84
+ if (!isPointerEventsEnabled || isPointerDownOnBranch) return;
85
+ onPointerDownOutside?.(event);
86
+ onInteractOutside?.(event);
87
+ if (!event.defaultPrevented) onDismiss?.();
88
+ }, ownerDocument);
89
+ const focusOutside = useFocusOutside((event) => {
90
+ const target = event.target;
91
+ const isFocusInBranch = [...context.branches].some((branch) => branch.contains(target));
92
+ if (isFocusInBranch) return;
93
+ onFocusOutside?.(event);
94
+ onInteractOutside?.(event);
95
+ if (!event.defaultPrevented) onDismiss?.();
96
+ }, ownerDocument);
97
+ (0, import_react_use_escape_keydown.useEscapeKeydown)((event) => {
98
+ const isHighestLayer = index === context.layers.size - 1;
99
+ if (!isHighestLayer) return;
100
+ onEscapeKeyDown?.(event);
101
+ if (!event.defaultPrevented && onDismiss) {
102
+ event.preventDefault();
103
+ onDismiss();
104
+ }
105
+ }, ownerDocument);
106
+ React.useEffect(() => {
107
+ if (!node) return;
108
+ if (disableOutsidePointerEvents) {
109
+ if (context.layersWithOutsidePointerEventsDisabled.size === 0) {
110
+ originalBodyPointerEvents = ownerDocument.body.style.pointerEvents;
111
+ ownerDocument.body.style.pointerEvents = "none";
96
112
  }
97
- }, ownerDocument);
98
- React.useEffect(() => {
99
- if (!node) return;
100
- if (disableOutsidePointerEvents) {
101
- if (context.layersWithOutsidePointerEventsDisabled.size === 0) {
102
- originalBodyPointerEvents = ownerDocument.body.style.pointerEvents;
103
- ownerDocument.body.style.pointerEvents = "none";
104
- }
105
- context.layersWithOutsidePointerEventsDisabled.add(node);
113
+ context.layersWithOutsidePointerEventsDisabled.add(node);
114
+ }
115
+ context.layers.add(node);
116
+ dispatchUpdate();
117
+ return () => {
118
+ if (disableOutsidePointerEvents && context.layersWithOutsidePointerEventsDisabled.size === 1) {
119
+ ownerDocument.body.style.pointerEvents = originalBodyPointerEvents;
106
120
  }
107
- context.layers.add(node);
121
+ };
122
+ }, [node, ownerDocument, disableOutsidePointerEvents, context]);
123
+ React.useEffect(() => {
124
+ return () => {
125
+ if (!node) return;
126
+ context.layers.delete(node);
127
+ context.layersWithOutsidePointerEventsDisabled.delete(node);
108
128
  dispatchUpdate();
109
- return () => {
110
- if (disableOutsidePointerEvents && context.layersWithOutsidePointerEventsDisabled.size === 1) {
111
- ownerDocument.body.style.pointerEvents = originalBodyPointerEvents;
112
- }
113
- };
114
- }, [node, ownerDocument, disableOutsidePointerEvents, context]);
115
- React.useEffect(() => {
116
- return () => {
117
- if (!node) return;
118
- context.layers.delete(node);
119
- context.layersWithOutsidePointerEventsDisabled.delete(node);
120
- dispatchUpdate();
121
- };
122
- }, [node, context]);
123
- React.useEffect(() => {
124
- const handleUpdate = () => force({});
125
- document.addEventListener(CONTEXT_UPDATE, handleUpdate);
126
- return () => document.removeEventListener(CONTEXT_UPDATE, handleUpdate);
127
- }, []);
128
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
129
- import_react_primitive.Primitive.div,
130
- {
131
- ...layerProps,
132
- ref: composedRefs,
133
- style: {
134
- pointerEvents: isBodyPointerEventsDisabled ? isPointerEventsEnabled ? "auto" : "none" : void 0,
135
- ...props.style
136
- },
137
- onFocusCapture: (0, import_primitive.composeEventHandlers)(props.onFocusCapture, focusOutside.onFocusCapture),
138
- onBlurCapture: (0, import_primitive.composeEventHandlers)(props.onBlurCapture, focusOutside.onBlurCapture),
139
- onPointerDownCapture: (0, import_primitive.composeEventHandlers)(
140
- props.onPointerDownCapture,
141
- pointerDownOutside.onPointerDownCapture
142
- )
143
- }
144
- );
145
- }
146
- );
147
- DismissableLayer.displayName = DISMISSABLE_LAYER_NAME;
148
- var BRANCH_NAME = "DismissableLayerBranch";
149
- var DismissableLayerBranch = React.forwardRef((props, forwardedRef) => {
150
- const context = React.useContext(DismissableLayerContext);
151
- const ref = React.useRef(null);
152
- const composedRefs = (0, import_react_compose_refs.useComposedRefs)(forwardedRef, ref);
129
+ };
130
+ }, [node, context]);
153
131
  React.useEffect(() => {
154
- const node = ref.current;
155
- if (node) {
156
- context.branches.add(node);
157
- return () => {
158
- context.branches.delete(node);
159
- };
132
+ const handleUpdate = () => force({});
133
+ document.addEventListener(CONTEXT_UPDATE, handleUpdate);
134
+ return () => document.removeEventListener(CONTEXT_UPDATE, handleUpdate);
135
+ }, []);
136
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
137
+ import_react_primitive.Primitive.div,
138
+ {
139
+ ...layerProps,
140
+ ref: composedRefs,
141
+ style: {
142
+ pointerEvents: isBodyPointerEventsDisabled ? isPointerEventsEnabled ? "auto" : "none" : void 0,
143
+ ...props.style
144
+ },
145
+ onFocusCapture: (0, import_primitive.composeEventHandlers)(props.onFocusCapture, focusOutside.onFocusCapture),
146
+ onBlurCapture: (0, import_primitive.composeEventHandlers)(props.onBlurCapture, focusOutside.onBlurCapture),
147
+ onPointerDownCapture: (0, import_primitive.composeEventHandlers)(
148
+ props.onPointerDownCapture,
149
+ pointerDownOutside.onPointerDownCapture
150
+ )
160
151
  }
161
- }, [context.branches]);
162
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_primitive.Primitive.div, { ...props, ref: composedRefs });
152
+ );
153
+ }
154
+ );
155
+ DismissableLayer.displayName = DISMISSABLE_LAYER_NAME;
156
+ var BRANCH_NAME = "DismissableLayerBranch";
157
+ var DismissableLayerBranch = React.forwardRef((props, forwardedRef) => {
158
+ const context = React.useContext(DismissableLayerContext);
159
+ const ref = React.useRef(null);
160
+ const composedRefs = (0, import_react_compose_refs.useComposedRefs)(forwardedRef, ref);
161
+ React.useEffect(() => {
162
+ const node = ref.current;
163
+ if (node) {
164
+ context.branches.add(node);
165
+ return () => {
166
+ context.branches.delete(node);
167
+ };
168
+ }
169
+ }, [context.branches]);
170
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_primitive.Primitive.div, { ...props, ref: composedRefs });
171
+ });
172
+ DismissableLayerBranch.displayName = BRANCH_NAME;
173
+ function usePointerDownOutside(onPointerDownOutside, ownerDocument = globalThis?.document) {
174
+ const handlePointerDownOutside = (0, import_react_use_callback_ref.useCallbackRef)(onPointerDownOutside);
175
+ const isPointerInsideReactTreeRef = React.useRef(false);
176
+ const handleClickRef = React.useRef(() => {
163
177
  });
164
- DismissableLayerBranch.displayName = BRANCH_NAME;
165
- function usePointerDownOutside(onPointerDownOutside, ownerDocument = globalThis?.document) {
166
- const handlePointerDownOutside = (0, import_react_use_callback_ref.useCallbackRef)(onPointerDownOutside);
167
- const isPointerInsideReactTreeRef = React.useRef(false);
168
- const handleClickRef = React.useRef(() => {
169
- });
170
- React.useEffect(() => {
171
- const handlePointerDown = (event) => {
172
- if (event.target && !isPointerInsideReactTreeRef.current) {
173
- let handleAndDispatchPointerDownOutsideEvent2 = function() {
174
- handleAndDispatchCustomEvent(
175
- POINTER_DOWN_OUTSIDE,
176
- handlePointerDownOutside,
177
- eventDetail,
178
- { discrete: true }
179
- );
180
- };
181
- var handleAndDispatchPointerDownOutsideEvent = handleAndDispatchPointerDownOutsideEvent2;
182
- const eventDetail = { originalEvent: event };
183
- if (event.pointerType === "touch") {
184
- ownerDocument.removeEventListener("click", handleClickRef.current);
185
- handleClickRef.current = handleAndDispatchPointerDownOutsideEvent2;
186
- ownerDocument.addEventListener("click", handleClickRef.current, { once: true });
187
- } else {
188
- handleAndDispatchPointerDownOutsideEvent2();
189
- }
190
- } else {
178
+ React.useEffect(() => {
179
+ const handlePointerDown = (event) => {
180
+ if (event.target && !isPointerInsideReactTreeRef.current) {
181
+ let handleAndDispatchPointerDownOutsideEvent2 = function() {
182
+ handleAndDispatchCustomEvent(
183
+ POINTER_DOWN_OUTSIDE,
184
+ handlePointerDownOutside,
185
+ eventDetail,
186
+ { discrete: true }
187
+ );
188
+ };
189
+ var handleAndDispatchPointerDownOutsideEvent = handleAndDispatchPointerDownOutsideEvent2;
190
+ const eventDetail = { originalEvent: event };
191
+ if (event.pointerType === "touch") {
191
192
  ownerDocument.removeEventListener("click", handleClickRef.current);
193
+ handleClickRef.current = handleAndDispatchPointerDownOutsideEvent2;
194
+ ownerDocument.addEventListener("click", handleClickRef.current, { once: true });
195
+ } else {
196
+ handleAndDispatchPointerDownOutsideEvent2();
192
197
  }
193
- isPointerInsideReactTreeRef.current = false;
194
- };
195
- const timerId = window.setTimeout(() => {
196
- ownerDocument.addEventListener("pointerdown", handlePointerDown);
197
- }, 0);
198
- return () => {
199
- window.clearTimeout(timerId);
200
- ownerDocument.removeEventListener("pointerdown", handlePointerDown);
198
+ } else {
201
199
  ownerDocument.removeEventListener("click", handleClickRef.current);
202
- };
203
- }, [ownerDocument, handlePointerDownOutside]);
204
- return {
205
- // ensures we check React component tree (not just DOM tree)
206
- onPointerDownCapture: () => isPointerInsideReactTreeRef.current = true
200
+ }
201
+ isPointerInsideReactTreeRef.current = false;
207
202
  };
208
- }
209
- function useFocusOutside(onFocusOutside, ownerDocument = globalThis?.document) {
210
- const handleFocusOutside = (0, import_react_use_callback_ref.useCallbackRef)(onFocusOutside);
211
- const isFocusInsideReactTreeRef = React.useRef(false);
212
- React.useEffect(() => {
213
- const handleFocus = (event) => {
214
- if (event.target && !isFocusInsideReactTreeRef.current) {
215
- const eventDetail = { originalEvent: event };
216
- handleAndDispatchCustomEvent(FOCUS_OUTSIDE, handleFocusOutside, eventDetail, {
217
- discrete: false
218
- });
219
- }
220
- };
221
- ownerDocument.addEventListener("focusin", handleFocus);
222
- return () => ownerDocument.removeEventListener("focusin", handleFocus);
223
- }, [ownerDocument, handleFocusOutside]);
224
- return {
225
- onFocusCapture: () => isFocusInsideReactTreeRef.current = true,
226
- onBlurCapture: () => isFocusInsideReactTreeRef.current = false
203
+ const timerId = window.setTimeout(() => {
204
+ ownerDocument.addEventListener("pointerdown", handlePointerDown);
205
+ }, 0);
206
+ return () => {
207
+ window.clearTimeout(timerId);
208
+ ownerDocument.removeEventListener("pointerdown", handlePointerDown);
209
+ ownerDocument.removeEventListener("click", handleClickRef.current);
227
210
  };
211
+ }, [ownerDocument, handlePointerDownOutside]);
212
+ return {
213
+ // ensures we check React component tree (not just DOM tree)
214
+ onPointerDownCapture: () => isPointerInsideReactTreeRef.current = true
215
+ };
216
+ }
217
+ function useFocusOutside(onFocusOutside, ownerDocument = globalThis?.document) {
218
+ const handleFocusOutside = (0, import_react_use_callback_ref.useCallbackRef)(onFocusOutside);
219
+ const isFocusInsideReactTreeRef = React.useRef(false);
220
+ React.useEffect(() => {
221
+ const handleFocus = (event) => {
222
+ if (event.target && !isFocusInsideReactTreeRef.current) {
223
+ const eventDetail = { originalEvent: event };
224
+ handleAndDispatchCustomEvent(FOCUS_OUTSIDE, handleFocusOutside, eventDetail, {
225
+ discrete: false
226
+ });
227
+ }
228
+ };
229
+ ownerDocument.addEventListener("focusin", handleFocus);
230
+ return () => ownerDocument.removeEventListener("focusin", handleFocus);
231
+ }, [ownerDocument, handleFocusOutside]);
232
+ return {
233
+ onFocusCapture: () => isFocusInsideReactTreeRef.current = true,
234
+ onBlurCapture: () => isFocusInsideReactTreeRef.current = false
235
+ };
236
+ }
237
+ function dispatchUpdate() {
238
+ const event = new CustomEvent(CONTEXT_UPDATE);
239
+ document.dispatchEvent(event);
240
+ }
241
+ function handleAndDispatchCustomEvent(name, handler, detail, { discrete }) {
242
+ const target = detail.originalEvent.target;
243
+ const event = new CustomEvent(name, { bubbles: false, cancelable: true, detail });
244
+ if (handler) target.addEventListener(name, handler, { once: true });
245
+ if (discrete) {
246
+ (0, import_react_primitive.dispatchDiscreteCustomEvent)(target, event);
247
+ } else {
248
+ target.dispatchEvent(event);
228
249
  }
229
- function dispatchUpdate() {
230
- const event = new CustomEvent(CONTEXT_UPDATE);
231
- document.dispatchEvent(event);
232
- }
233
- function handleAndDispatchCustomEvent(name, handler, detail, { discrete }) {
234
- const target = detail.originalEvent.target;
235
- const event = new CustomEvent(name, { bubbles: false, cancelable: true, detail });
236
- if (handler) target.addEventListener(name, handler, { once: true });
237
- if (discrete) {
238
- (0, import_react_primitive.dispatchDiscreteCustomEvent)(target, event);
239
- } else {
240
- target.dispatchEvent(event);
241
- }
242
- }
243
- var Root = DismissableLayer;
244
- var Branch = DismissableLayerBranch;
245
- })();
250
+ }
251
+ var Root = DismissableLayer;
252
+ var Branch = DismissableLayerBranch;
246
253
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../src/DismissableLayer.tsx"],
4
- "sourcesContent": ["import * as React from 'react';\nimport { composeEventHandlers } from '@radix-ui/primitive';\nimport { Primitive, dispatchDiscreteCustomEvent } from '@radix-ui/react-primitive';\nimport { useComposedRefs } from '@radix-ui/react-compose-refs';\nimport { useCallbackRef } from '@radix-ui/react-use-callback-ref';\nimport { useEscapeKeydown } from '@radix-ui/react-use-escape-keydown';\n\nimport type * as Radix from '@radix-ui/react-primitive';\n\n/* -------------------------------------------------------------------------------------------------\n * DismissableLayer\n * -----------------------------------------------------------------------------------------------*/\n\nconst DISMISSABLE_LAYER_NAME = 'DismissableLayer';\nconst CONTEXT_UPDATE = 'dismissableLayer.update';\nconst POINTER_DOWN_OUTSIDE = 'dismissableLayer.pointerDownOutside';\nconst FOCUS_OUTSIDE = 'dismissableLayer.focusOutside';\n\nlet originalBodyPointerEvents: string;\n\nconst DismissableLayerContext = React.createContext({\n layers: new Set<DismissableLayerElement>(),\n layersWithOutsidePointerEventsDisabled: new Set<DismissableLayerElement>(),\n branches: new Set<DismissableLayerBranchElement>(),\n});\n\ntype DismissableLayerElement = React.ElementRef<typeof Primitive.div>;\ntype PrimitiveDivProps = Radix.ComponentPropsWithoutRef<typeof Primitive.div>;\ninterface DismissableLayerProps extends PrimitiveDivProps {\n /**\n * When `true`, hover/focus/click interactions will be disabled on elements outside\n * the `DismissableLayer`. Users will need to click twice on outside elements to\n * interact with them: once to close the `DismissableLayer`, and again to trigger the element.\n */\n disableOutsidePointerEvents?: boolean;\n /**\n * Event handler called when the escape key is down.\n * Can be prevented.\n */\n onEscapeKeyDown?: (event: KeyboardEvent) => void;\n /**\n * Event handler called when the a `pointerdown` event happens outside of the `DismissableLayer`.\n * Can be prevented.\n */\n onPointerDownOutside?: (event: PointerDownOutsideEvent) => void;\n /**\n * Event handler called when the focus moves outside of the `DismissableLayer`.\n * Can be prevented.\n */\n onFocusOutside?: (event: FocusOutsideEvent) => void;\n /**\n * Event handler called when an interaction happens outside the `DismissableLayer`.\n * Specifically, when a `pointerdown` event happens outside or focus moves outside of it.\n * Can be prevented.\n */\n onInteractOutside?: (event: PointerDownOutsideEvent | FocusOutsideEvent) => void;\n /**\n * Handler called when the `DismissableLayer` should be dismissed\n */\n onDismiss?: () => void;\n}\n\nconst DismissableLayer = React.forwardRef<DismissableLayerElement, DismissableLayerProps>(\n (props, forwardedRef) => {\n const {\n disableOutsidePointerEvents = false,\n onEscapeKeyDown,\n onPointerDownOutside,\n onFocusOutside,\n onInteractOutside,\n onDismiss,\n ...layerProps\n } = props;\n const context = React.useContext(DismissableLayerContext);\n const [node, setNode] = React.useState<DismissableLayerElement | null>(null);\n const ownerDocument = node?.ownerDocument ?? globalThis?.document;\n const [, force] = React.useState({});\n const composedRefs = useComposedRefs(forwardedRef, (node) => setNode(node));\n const layers = Array.from(context.layers);\n const [highestLayerWithOutsidePointerEventsDisabled] = [...context.layersWithOutsidePointerEventsDisabled].slice(-1); // prettier-ignore\n const highestLayerWithOutsidePointerEventsDisabledIndex = layers.indexOf(highestLayerWithOutsidePointerEventsDisabled); // prettier-ignore\n const index = node ? layers.indexOf(node) : -1;\n const isBodyPointerEventsDisabled = context.layersWithOutsidePointerEventsDisabled.size > 0;\n const isPointerEventsEnabled = index >= highestLayerWithOutsidePointerEventsDisabledIndex;\n\n const pointerDownOutside = usePointerDownOutside((event) => {\n const target = event.target as HTMLElement;\n const isPointerDownOnBranch = [...context.branches].some((branch) => branch.contains(target));\n if (!isPointerEventsEnabled || isPointerDownOnBranch) return;\n onPointerDownOutside?.(event);\n onInteractOutside?.(event);\n if (!event.defaultPrevented) onDismiss?.();\n }, ownerDocument);\n\n const focusOutside = useFocusOutside((event) => {\n const target = event.target as HTMLElement;\n const isFocusInBranch = [...context.branches].some((branch) => branch.contains(target));\n if (isFocusInBranch) return;\n onFocusOutside?.(event);\n onInteractOutside?.(event);\n if (!event.defaultPrevented) onDismiss?.();\n }, ownerDocument);\n\n useEscapeKeydown((event) => {\n const isHighestLayer = index === context.layers.size - 1;\n if (!isHighestLayer) return;\n onEscapeKeyDown?.(event);\n if (!event.defaultPrevented && onDismiss) {\n event.preventDefault();\n onDismiss();\n }\n }, ownerDocument);\n\n React.useEffect(() => {\n if (!node) return;\n if (disableOutsidePointerEvents) {\n if (context.layersWithOutsidePointerEventsDisabled.size === 0) {\n originalBodyPointerEvents = ownerDocument.body.style.pointerEvents;\n ownerDocument.body.style.pointerEvents = 'none';\n }\n context.layersWithOutsidePointerEventsDisabled.add(node);\n }\n context.layers.add(node);\n dispatchUpdate();\n return () => {\n if (\n disableOutsidePointerEvents &&\n context.layersWithOutsidePointerEventsDisabled.size === 1\n ) {\n ownerDocument.body.style.pointerEvents = originalBodyPointerEvents;\n }\n };\n }, [node, ownerDocument, disableOutsidePointerEvents, context]);\n\n /**\n * We purposefully prevent combining this effect with the `disableOutsidePointerEvents` effect\n * because a change to `disableOutsidePointerEvents` would remove this layer from the stack\n * and add it to the end again so the layering order wouldn't be _creation order_.\n * We only want them to be removed from context stacks when unmounted.\n */\n React.useEffect(() => {\n return () => {\n if (!node) return;\n context.layers.delete(node);\n context.layersWithOutsidePointerEventsDisabled.delete(node);\n dispatchUpdate();\n };\n }, [node, context]);\n\n React.useEffect(() => {\n const handleUpdate = () => force({});\n document.addEventListener(CONTEXT_UPDATE, handleUpdate);\n return () => document.removeEventListener(CONTEXT_UPDATE, handleUpdate);\n }, []);\n\n return (\n <Primitive.div\n {...layerProps}\n ref={composedRefs}\n style={{\n pointerEvents: isBodyPointerEventsDisabled\n ? isPointerEventsEnabled\n ? 'auto'\n : 'none'\n : undefined,\n ...props.style,\n }}\n onFocusCapture={composeEventHandlers(props.onFocusCapture, focusOutside.onFocusCapture)}\n onBlurCapture={composeEventHandlers(props.onBlurCapture, focusOutside.onBlurCapture)}\n onPointerDownCapture={composeEventHandlers(\n props.onPointerDownCapture,\n pointerDownOutside.onPointerDownCapture\n )}\n />\n );\n }\n);\n\nDismissableLayer.displayName = DISMISSABLE_LAYER_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * DismissableLayerBranch\n * -----------------------------------------------------------------------------------------------*/\n\nconst BRANCH_NAME = 'DismissableLayerBranch';\n\ntype DismissableLayerBranchElement = React.ElementRef<typeof Primitive.div>;\ninterface DismissableLayerBranchProps extends PrimitiveDivProps {}\n\nconst DismissableLayerBranch = React.forwardRef<\n DismissableLayerBranchElement,\n DismissableLayerBranchProps\n>((props, forwardedRef) => {\n const context = React.useContext(DismissableLayerContext);\n const ref = React.useRef<DismissableLayerBranchElement>(null);\n const composedRefs = useComposedRefs(forwardedRef, ref);\n\n React.useEffect(() => {\n const node = ref.current;\n if (node) {\n context.branches.add(node);\n return () => {\n context.branches.delete(node);\n };\n }\n }, [context.branches]);\n\n return <Primitive.div {...props} ref={composedRefs} />;\n});\n\nDismissableLayerBranch.displayName = BRANCH_NAME;\n\n/* -----------------------------------------------------------------------------------------------*/\n\ntype PointerDownOutsideEvent = CustomEvent<{ originalEvent: PointerEvent }>;\ntype FocusOutsideEvent = CustomEvent<{ originalEvent: FocusEvent }>;\n\n/**\n * Listens for `pointerdown` outside a react subtree. We use `pointerdown` rather than `pointerup`\n * to mimic layer dismissing behaviour present in OS.\n * Returns props to pass to the node we want to check for outside events.\n */\nfunction usePointerDownOutside(\n onPointerDownOutside?: (event: PointerDownOutsideEvent) => void,\n ownerDocument: Document = globalThis?.document\n) {\n const handlePointerDownOutside = useCallbackRef(onPointerDownOutside) as EventListener;\n const isPointerInsideReactTreeRef = React.useRef(false);\n const handleClickRef = React.useRef(() => {});\n\n React.useEffect(() => {\n const handlePointerDown = (event: PointerEvent) => {\n if (event.target && !isPointerInsideReactTreeRef.current) {\n const eventDetail = { originalEvent: event };\n\n function handleAndDispatchPointerDownOutsideEvent() {\n handleAndDispatchCustomEvent(\n POINTER_DOWN_OUTSIDE,\n handlePointerDownOutside,\n eventDetail,\n { discrete: true }\n );\n }\n\n /**\n * On touch devices, we need to wait for a click event because browsers implement\n * a ~350ms delay between the time the user stops touching the display and when the\n * browser executres events. We need to ensure we don't reactivate pointer-events within\n * this timeframe otherwise the browser may execute events that should have been prevented.\n *\n * Additionally, this also lets us deal automatically with cancellations when a click event\n * isn't raised because the page was considered scrolled/drag-scrolled, long-pressed, etc.\n *\n * This is why we also continuously remove the previous listener, because we cannot be\n * certain that it was raised, and therefore cleaned-up.\n */\n if (event.pointerType === 'touch') {\n ownerDocument.removeEventListener('click', handleClickRef.current);\n handleClickRef.current = handleAndDispatchPointerDownOutsideEvent;\n ownerDocument.addEventListener('click', handleClickRef.current, { once: true });\n } else {\n handleAndDispatchPointerDownOutsideEvent();\n }\n } else {\n // We need to remove the event listener in case the outside click has been canceled.\n // See: https://github.com/radix-ui/primitives/issues/2171\n ownerDocument.removeEventListener('click', handleClickRef.current);\n }\n isPointerInsideReactTreeRef.current = false;\n };\n /**\n * if this hook executes in a component that mounts via a `pointerdown` event, the event\n * would bubble up to the document and trigger a `pointerDownOutside` event. We avoid\n * this by delaying the event listener registration on the document.\n * This is not React specific, but rather how the DOM works, ie:\n * ```\n * button.addEventListener('pointerdown', () => {\n * console.log('I will log');\n * document.addEventListener('pointerdown', () => {\n * console.log('I will also log');\n * })\n * });\n */\n const timerId = window.setTimeout(() => {\n ownerDocument.addEventListener('pointerdown', handlePointerDown);\n }, 0);\n return () => {\n window.clearTimeout(timerId);\n ownerDocument.removeEventListener('pointerdown', handlePointerDown);\n ownerDocument.removeEventListener('click', handleClickRef.current);\n };\n }, [ownerDocument, handlePointerDownOutside]);\n\n return {\n // ensures we check React component tree (not just DOM tree)\n onPointerDownCapture: () => (isPointerInsideReactTreeRef.current = true),\n };\n}\n\n/**\n * Listens for when focus happens outside a react subtree.\n * Returns props to pass to the root (node) of the subtree we want to check.\n */\nfunction useFocusOutside(\n onFocusOutside?: (event: FocusOutsideEvent) => void,\n ownerDocument: Document = globalThis?.document\n) {\n const handleFocusOutside = useCallbackRef(onFocusOutside) as EventListener;\n const isFocusInsideReactTreeRef = React.useRef(false);\n\n React.useEffect(() => {\n const handleFocus = (event: FocusEvent) => {\n if (event.target && !isFocusInsideReactTreeRef.current) {\n const eventDetail = { originalEvent: event };\n handleAndDispatchCustomEvent(FOCUS_OUTSIDE, handleFocusOutside, eventDetail, {\n discrete: false,\n });\n }\n };\n ownerDocument.addEventListener('focusin', handleFocus);\n return () => ownerDocument.removeEventListener('focusin', handleFocus);\n }, [ownerDocument, handleFocusOutside]);\n\n return {\n onFocusCapture: () => (isFocusInsideReactTreeRef.current = true),\n onBlurCapture: () => (isFocusInsideReactTreeRef.current = false),\n };\n}\n\nfunction dispatchUpdate() {\n const event = new CustomEvent(CONTEXT_UPDATE);\n document.dispatchEvent(event);\n}\n\nfunction handleAndDispatchCustomEvent<E extends CustomEvent, OriginalEvent extends Event>(\n name: string,\n handler: ((event: E) => void) | undefined,\n detail: { originalEvent: OriginalEvent } & (E extends CustomEvent<infer D> ? D : never),\n { discrete }: { discrete: boolean }\n) {\n const target = detail.originalEvent.target;\n const event = new CustomEvent(name, { bubbles: false, cancelable: true, detail });\n if (handler) target.addEventListener(name, handler as EventListener, { once: true });\n\n if (discrete) {\n dispatchDiscreteCustomEvent(target, event);\n } else {\n target.dispatchEvent(event);\n }\n}\n\nconst Root = DismissableLayer;\nconst Branch = DismissableLayerBranch;\n\nexport {\n DismissableLayer,\n DismissableLayerBranch,\n //\n Root,\n Branch,\n};\nexport type { DismissableLayerProps };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,cAAuB;AACvB,yBAAqC;AACrC,+BAAuD;AACvD,kCAAgC;AAChC,sCAA+B;AAC/B,wCAAiC;AAuJ3B;AA/IN,MAAM,yBAAyB;AAC/B,MAAM,iBAAiB;AACvB,MAAM,uBAAuB;AAC7B,MAAM,gBAAgB;AAEtB,MAAI;AAEJ,MAAM,0BAAgC,oBAAc;AAAA,IAClD,QAAQ,oBAAI,IAA6B;AAAA,IACzC,wCAAwC,oBAAI,IAA6B;AAAA,IACzE,UAAU,oBAAI,IAAmC;AAAA,EACnD,CAAC;AAsCD,MAAM,mBAAyB;AAAA,IAC7B,CAAC,OAAO,iBAAiB;AACvB,YAAM;AAAA,QACJ,8BAA8B;AAAA,QAC9B;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA,GAAG;AAAA,MACL,IAAI;AACJ,YAAM,UAAgB,iBAAW,uBAAuB;AACxD,YAAM,CAAC,MAAM,OAAO,IAAU,eAAyC,IAAI;AAC3E,YAAM,gBAAgB,MAAM,iBAAiB,YAAY;AACzD,YAAM,CAAC,EAAE,KAAK,IAAU,eAAS,CAAC,CAAC;AACnC,YAAM,mBAAe,2CAAgB,cAAc,CAACA,UAAS,QAAQA,KAAI,CAAC;AAC1E,YAAM,SAAS,MAAM,KAAK,QAAQ,MAAM;AACxC,YAAM,CAAC,4CAA4C,IAAI,CAAC,GAAG,QAAQ,sCAAsC,EAAE,MAAM,EAAE;AACnH,YAAM,oDAAoD,OAAO,QAAQ,4CAA4C;AACrH,YAAM,QAAQ,OAAO,OAAO,QAAQ,IAAI,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B,UAAU;AAAA,IACrE;AAAA,EACF;AAMA,WAAS,gBACP,gBACA,gBAA0B,YAAY,UACtC;AACA,UAAM,yBAAqB,8CAAe,cAAc;AACxD,UAAM,4BAAkC,aAAO,KAAK;AAEpD,IAAM,gBAAU,MAAM;AACpB,YAAM,cAAc,CAAC,UAAsB;AACzC,YAAI,MAAM,UAAU,CAAC,0BAA0B,SAAS;AACtD,gBAAM,cAAc,EAAE,eAAe,MAAM;AAC3C,uCAA6B,eAAe,oBAAoB,aAAa;AAAA,YAC3E,UAAU;AAAA,UACZ,CAAC;AAAA,QACH;AAAA,MACF;AACA,oBAAc,iBAAiB,WAAW,WAAW;AACrD,aAAO,MAAM,cAAc,oBAAoB,WAAW,WAAW;AAAA,IACvE,GAAG,CAAC,eAAe,kBAAkB,CAAC;AAEtC,WAAO;AAAA,MACL,gBAAgB,MAAO,0BAA0B,UAAU;AAAA,MAC3D,eAAe,MAAO,0BAA0B,UAAU;AAAA,IAC5D;AAAA,EACF;AAEA,WAAS,iBAAiB;AACxB,UAAM,QAAQ,IAAI,YAAY,cAAc;AAC5C,aAAS,cAAc,KAAK;AAAA,EAC9B;AAEA,WAAS,6BACP,MACA,SACA,QACA,EAAE,SAAS,GACX;AACA,UAAM,SAAS,OAAO,cAAc;AACpC,UAAM,QAAQ,IAAI,YAAY,MAAM,EAAE,SAAS,OAAO,YAAY,MAAM,OAAO,CAAC;AAChF,QAAI,QAAS,QAAO,iBAAiB,MAAM,SAA0B,EAAE,MAAM,KAAK,CAAC;AAEnF,QAAI,UAAU;AACZ,8DAA4B,QAAQ,KAAK;AAAA,IAC3C,OAAO;AACL,aAAO,cAAc,KAAK;AAAA,IAC5B;AAAA,EACF;AAEA,MAAM,OAAO;AACb,MAAM,SAAS;",
3
+ "sources": ["../src/index.ts", "../src/DismissableLayer.tsx"],
4
+ "sourcesContent": ["'use client';\nexport {\n DismissableLayer,\n DismissableLayerBranch,\n //\n Root,\n Branch,\n} from './DismissableLayer';\nexport type { DismissableLayerProps } from './DismissableLayer';\n", "import * as React from 'react';\nimport { composeEventHandlers } from '@radix-ui/primitive';\nimport { Primitive, dispatchDiscreteCustomEvent } from '@radix-ui/react-primitive';\nimport { useComposedRefs } from '@radix-ui/react-compose-refs';\nimport { useCallbackRef } from '@radix-ui/react-use-callback-ref';\nimport { useEscapeKeydown } from '@radix-ui/react-use-escape-keydown';\n\nimport type * as Radix from '@radix-ui/react-primitive';\n\n/* -------------------------------------------------------------------------------------------------\n * DismissableLayer\n * -----------------------------------------------------------------------------------------------*/\n\nconst DISMISSABLE_LAYER_NAME = 'DismissableLayer';\nconst CONTEXT_UPDATE = 'dismissableLayer.update';\nconst POINTER_DOWN_OUTSIDE = 'dismissableLayer.pointerDownOutside';\nconst FOCUS_OUTSIDE = 'dismissableLayer.focusOutside';\n\nlet originalBodyPointerEvents: string;\n\nconst DismissableLayerContext = React.createContext({\n layers: new Set<DismissableLayerElement>(),\n layersWithOutsidePointerEventsDisabled: new Set<DismissableLayerElement>(),\n branches: new Set<DismissableLayerBranchElement>(),\n});\n\ntype DismissableLayerElement = React.ElementRef<typeof Primitive.div>;\ntype PrimitiveDivProps = Radix.ComponentPropsWithoutRef<typeof Primitive.div>;\ninterface DismissableLayerProps extends PrimitiveDivProps {\n /**\n * When `true`, hover/focus/click interactions will be disabled on elements outside\n * the `DismissableLayer`. Users will need to click twice on outside elements to\n * interact with them: once to close the `DismissableLayer`, and again to trigger the element.\n */\n disableOutsidePointerEvents?: boolean;\n /**\n * Event handler called when the escape key is down.\n * Can be prevented.\n */\n onEscapeKeyDown?: (event: KeyboardEvent) => void;\n /**\n * Event handler called when the a `pointerdown` event happens outside of the `DismissableLayer`.\n * Can be prevented.\n */\n onPointerDownOutside?: (event: PointerDownOutsideEvent) => void;\n /**\n * Event handler called when the focus moves outside of the `DismissableLayer`.\n * Can be prevented.\n */\n onFocusOutside?: (event: FocusOutsideEvent) => void;\n /**\n * Event handler called when an interaction happens outside the `DismissableLayer`.\n * Specifically, when a `pointerdown` event happens outside or focus moves outside of it.\n * Can be prevented.\n */\n onInteractOutside?: (event: PointerDownOutsideEvent | FocusOutsideEvent) => void;\n /**\n * Handler called when the `DismissableLayer` should be dismissed\n */\n onDismiss?: () => void;\n}\n\nconst DismissableLayer = React.forwardRef<DismissableLayerElement, DismissableLayerProps>(\n (props, forwardedRef) => {\n const {\n disableOutsidePointerEvents = false,\n onEscapeKeyDown,\n onPointerDownOutside,\n onFocusOutside,\n onInteractOutside,\n onDismiss,\n ...layerProps\n } = props;\n const context = React.useContext(DismissableLayerContext);\n const [node, setNode] = React.useState<DismissableLayerElement | null>(null);\n const ownerDocument = node?.ownerDocument ?? globalThis?.document;\n const [, force] = React.useState({});\n const composedRefs = useComposedRefs(forwardedRef, (node) => setNode(node));\n const layers = Array.from(context.layers);\n const [highestLayerWithOutsidePointerEventsDisabled] = [...context.layersWithOutsidePointerEventsDisabled].slice(-1); // prettier-ignore\n const highestLayerWithOutsidePointerEventsDisabledIndex = layers.indexOf(highestLayerWithOutsidePointerEventsDisabled); // prettier-ignore\n const index = node ? layers.indexOf(node) : -1;\n const isBodyPointerEventsDisabled = context.layersWithOutsidePointerEventsDisabled.size > 0;\n const isPointerEventsEnabled = index >= highestLayerWithOutsidePointerEventsDisabledIndex;\n\n const pointerDownOutside = usePointerDownOutside((event) => {\n const target = event.target as HTMLElement;\n const isPointerDownOnBranch = [...context.branches].some((branch) => branch.contains(target));\n if (!isPointerEventsEnabled || isPointerDownOnBranch) return;\n onPointerDownOutside?.(event);\n onInteractOutside?.(event);\n if (!event.defaultPrevented) onDismiss?.();\n }, ownerDocument);\n\n const focusOutside = useFocusOutside((event) => {\n const target = event.target as HTMLElement;\n const isFocusInBranch = [...context.branches].some((branch) => branch.contains(target));\n if (isFocusInBranch) return;\n onFocusOutside?.(event);\n onInteractOutside?.(event);\n if (!event.defaultPrevented) onDismiss?.();\n }, ownerDocument);\n\n useEscapeKeydown((event) => {\n const isHighestLayer = index === context.layers.size - 1;\n if (!isHighestLayer) return;\n onEscapeKeyDown?.(event);\n if (!event.defaultPrevented && onDismiss) {\n event.preventDefault();\n onDismiss();\n }\n }, ownerDocument);\n\n React.useEffect(() => {\n if (!node) return;\n if (disableOutsidePointerEvents) {\n if (context.layersWithOutsidePointerEventsDisabled.size === 0) {\n originalBodyPointerEvents = ownerDocument.body.style.pointerEvents;\n ownerDocument.body.style.pointerEvents = 'none';\n }\n context.layersWithOutsidePointerEventsDisabled.add(node);\n }\n context.layers.add(node);\n dispatchUpdate();\n return () => {\n if (\n disableOutsidePointerEvents &&\n context.layersWithOutsidePointerEventsDisabled.size === 1\n ) {\n ownerDocument.body.style.pointerEvents = originalBodyPointerEvents;\n }\n };\n }, [node, ownerDocument, disableOutsidePointerEvents, context]);\n\n /**\n * We purposefully prevent combining this effect with the `disableOutsidePointerEvents` effect\n * because a change to `disableOutsidePointerEvents` would remove this layer from the stack\n * and add it to the end again so the layering order wouldn't be _creation order_.\n * We only want them to be removed from context stacks when unmounted.\n */\n React.useEffect(() => {\n return () => {\n if (!node) return;\n context.layers.delete(node);\n context.layersWithOutsidePointerEventsDisabled.delete(node);\n dispatchUpdate();\n };\n }, [node, context]);\n\n React.useEffect(() => {\n const handleUpdate = () => force({});\n document.addEventListener(CONTEXT_UPDATE, handleUpdate);\n return () => document.removeEventListener(CONTEXT_UPDATE, handleUpdate);\n }, []);\n\n return (\n <Primitive.div\n {...layerProps}\n ref={composedRefs}\n style={{\n pointerEvents: isBodyPointerEventsDisabled\n ? isPointerEventsEnabled\n ? 'auto'\n : 'none'\n : undefined,\n ...props.style,\n }}\n onFocusCapture={composeEventHandlers(props.onFocusCapture, focusOutside.onFocusCapture)}\n onBlurCapture={composeEventHandlers(props.onBlurCapture, focusOutside.onBlurCapture)}\n onPointerDownCapture={composeEventHandlers(\n props.onPointerDownCapture,\n pointerDownOutside.onPointerDownCapture\n )}\n />\n );\n }\n);\n\nDismissableLayer.displayName = DISMISSABLE_LAYER_NAME;\n\n/* -------------------------------------------------------------------------------------------------\n * DismissableLayerBranch\n * -----------------------------------------------------------------------------------------------*/\n\nconst BRANCH_NAME = 'DismissableLayerBranch';\n\ntype DismissableLayerBranchElement = React.ElementRef<typeof Primitive.div>;\ninterface DismissableLayerBranchProps extends PrimitiveDivProps {}\n\nconst DismissableLayerBranch = React.forwardRef<\n DismissableLayerBranchElement,\n DismissableLayerBranchProps\n>((props, forwardedRef) => {\n const context = React.useContext(DismissableLayerContext);\n const ref = React.useRef<DismissableLayerBranchElement>(null);\n const composedRefs = useComposedRefs(forwardedRef, ref);\n\n React.useEffect(() => {\n const node = ref.current;\n if (node) {\n context.branches.add(node);\n return () => {\n context.branches.delete(node);\n };\n }\n }, [context.branches]);\n\n return <Primitive.div {...props} ref={composedRefs} />;\n});\n\nDismissableLayerBranch.displayName = BRANCH_NAME;\n\n/* -----------------------------------------------------------------------------------------------*/\n\ntype PointerDownOutsideEvent = CustomEvent<{ originalEvent: PointerEvent }>;\ntype FocusOutsideEvent = CustomEvent<{ originalEvent: FocusEvent }>;\n\n/**\n * Listens for `pointerdown` outside a react subtree. We use `pointerdown` rather than `pointerup`\n * to mimic layer dismissing behaviour present in OS.\n * Returns props to pass to the node we want to check for outside events.\n */\nfunction usePointerDownOutside(\n onPointerDownOutside?: (event: PointerDownOutsideEvent) => void,\n ownerDocument: Document = globalThis?.document\n) {\n const handlePointerDownOutside = useCallbackRef(onPointerDownOutside) as EventListener;\n const isPointerInsideReactTreeRef = React.useRef(false);\n const handleClickRef = React.useRef(() => {});\n\n React.useEffect(() => {\n const handlePointerDown = (event: PointerEvent) => {\n if (event.target && !isPointerInsideReactTreeRef.current) {\n const eventDetail = { originalEvent: event };\n\n function handleAndDispatchPointerDownOutsideEvent() {\n handleAndDispatchCustomEvent(\n POINTER_DOWN_OUTSIDE,\n handlePointerDownOutside,\n eventDetail,\n { discrete: true }\n );\n }\n\n /**\n * On touch devices, we need to wait for a click event because browsers implement\n * a ~350ms delay between the time the user stops touching the display and when the\n * browser executres events. We need to ensure we don't reactivate pointer-events within\n * this timeframe otherwise the browser may execute events that should have been prevented.\n *\n * Additionally, this also lets us deal automatically with cancellations when a click event\n * isn't raised because the page was considered scrolled/drag-scrolled, long-pressed, etc.\n *\n * This is why we also continuously remove the previous listener, because we cannot be\n * certain that it was raised, and therefore cleaned-up.\n */\n if (event.pointerType === 'touch') {\n ownerDocument.removeEventListener('click', handleClickRef.current);\n handleClickRef.current = handleAndDispatchPointerDownOutsideEvent;\n ownerDocument.addEventListener('click', handleClickRef.current, { once: true });\n } else {\n handleAndDispatchPointerDownOutsideEvent();\n }\n } else {\n // We need to remove the event listener in case the outside click has been canceled.\n // See: https://github.com/radix-ui/primitives/issues/2171\n ownerDocument.removeEventListener('click', handleClickRef.current);\n }\n isPointerInsideReactTreeRef.current = false;\n };\n /**\n * if this hook executes in a component that mounts via a `pointerdown` event, the event\n * would bubble up to the document and trigger a `pointerDownOutside` event. We avoid\n * this by delaying the event listener registration on the document.\n * This is not React specific, but rather how the DOM works, ie:\n * ```\n * button.addEventListener('pointerdown', () => {\n * console.log('I will log');\n * document.addEventListener('pointerdown', () => {\n * console.log('I will also log');\n * })\n * });\n */\n const timerId = window.setTimeout(() => {\n ownerDocument.addEventListener('pointerdown', handlePointerDown);\n }, 0);\n return () => {\n window.clearTimeout(timerId);\n ownerDocument.removeEventListener('pointerdown', handlePointerDown);\n ownerDocument.removeEventListener('click', handleClickRef.current);\n };\n }, [ownerDocument, handlePointerDownOutside]);\n\n return {\n // ensures we check React component tree (not just DOM tree)\n onPointerDownCapture: () => (isPointerInsideReactTreeRef.current = true),\n };\n}\n\n/**\n * Listens for when focus happens outside a react subtree.\n * Returns props to pass to the root (node) of the subtree we want to check.\n */\nfunction useFocusOutside(\n onFocusOutside?: (event: FocusOutsideEvent) => void,\n ownerDocument: Document = globalThis?.document\n) {\n const handleFocusOutside = useCallbackRef(onFocusOutside) as EventListener;\n const isFocusInsideReactTreeRef = React.useRef(false);\n\n React.useEffect(() => {\n const handleFocus = (event: FocusEvent) => {\n if (event.target && !isFocusInsideReactTreeRef.current) {\n const eventDetail = { originalEvent: event };\n handleAndDispatchCustomEvent(FOCUS_OUTSIDE, handleFocusOutside, eventDetail, {\n discrete: false,\n });\n }\n };\n ownerDocument.addEventListener('focusin', handleFocus);\n return () => ownerDocument.removeEventListener('focusin', handleFocus);\n }, [ownerDocument, handleFocusOutside]);\n\n return {\n onFocusCapture: () => (isFocusInsideReactTreeRef.current = true),\n onBlurCapture: () => (isFocusInsideReactTreeRef.current = false),\n };\n}\n\nfunction dispatchUpdate() {\n const event = new CustomEvent(CONTEXT_UPDATE);\n document.dispatchEvent(event);\n}\n\nfunction handleAndDispatchCustomEvent<E extends CustomEvent, OriginalEvent extends Event>(\n name: string,\n handler: ((event: E) => void) | undefined,\n detail: { originalEvent: OriginalEvent } & (E extends CustomEvent<infer D> ? D : never),\n { discrete }: { discrete: boolean }\n) {\n const target = detail.originalEvent.target;\n const event = new CustomEvent(name, { bubbles: false, cancelable: true, detail });\n if (handler) target.addEventListener(name, handler as EventListener, { once: true });\n\n if (discrete) {\n dispatchDiscreteCustomEvent(target, event);\n } else {\n target.dispatchEvent(event);\n }\n}\n\nconst Root = DismissableLayer;\nconst Branch = DismissableLayerBranch;\n\nexport {\n DismissableLayer,\n DismissableLayerBranch,\n //\n Root,\n Branch,\n};\nexport type { DismissableLayerProps };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,YAAuB;AACvB,uBAAqC;AACrC,6BAAuD;AACvD,gCAAgC;AAChC,oCAA+B;AAC/B,sCAAiC;AAuJ3B;AA/IN,IAAM,yBAAyB;AAC/B,IAAM,iBAAiB;AACvB,IAAM,uBAAuB;AAC7B,IAAM,gBAAgB;AAEtB,IAAI;AAEJ,IAAM,0BAAgC,oBAAc;AAAA,EAClD,QAAQ,oBAAI,IAA6B;AAAA,EACzC,wCAAwC,oBAAI,IA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0BAA0B,UAAU;AAAA,EAC5D;AACF;AAEA,SAAS,iBAAiB;AACxB,QAAM,QAAQ,IAAI,YAAY,cAAc;AAC5C,WAAS,cAAc,KAAK;AAC9B;AAEA,SAAS,6BACP,MACA,SACA,QACA,EAAE,SAAS,GACX;AACA,QAAM,SAAS,OAAO,cAAc;AACpC,QAAM,QAAQ,IAAI,YAAY,MAAM,EAAE,SAAS,OAAO,YAAY,MAAM,OAAO,CAAC;AAChF,MAAI,QAAS,QAAO,iBAAiB,MAAM,SAA0B,EAAE,MAAM,KAAK,CAAC;AAEnF,MAAI,UAAU;AACZ,4DAA4B,QAAQ,KAAK;AAAA,EAC3C,OAAO;AACL,WAAO,cAAc,KAAK;AAAA,EAC5B;AACF;AAEA,IAAM,OAAO;AACb,IAAM,SAAS;",
6
6
  "names": ["node", "handleAndDispatchPointerDownOutsideEvent"]
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@radix-ui/react-dismissable-layer",
3
- "version": "1.1.0-rc.2",
3
+ "version": "1.1.0-rc.3",
4
4
  "license": "MIT",
5
5
  "exports": {
6
6
  ".": {
@@ -28,11 +28,11 @@
28
28
  "version": "yarn version"
29
29
  },
30
30
  "dependencies": {
31
- "@radix-ui/primitive": "1.1.0-rc.2",
32
- "@radix-ui/react-compose-refs": "1.1.0-rc.2",
33
- "@radix-ui/react-primitive": "1.1.0-rc.2",
34
- "@radix-ui/react-use-callback-ref": "1.1.0-rc.2",
35
- "@radix-ui/react-use-escape-keydown": "1.1.0-rc.2"
31
+ "@radix-ui/primitive": "1.1.0-rc.3",
32
+ "@radix-ui/react-compose-refs": "1.1.0-rc.3",
33
+ "@radix-ui/react-primitive": "1.1.0-rc.3",
34
+ "@radix-ui/react-use-callback-ref": "1.1.0-rc.3",
35
+ "@radix-ui/react-use-escape-keydown": "1.1.0-rc.3"
36
36
  },
37
37
  "devDependencies": {
38
38
  "react-remove-scroll": "2.5.7"