@tamagui/dismissable 1.14.1 → 1.14.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/cjs/Dismissable.js +285 -1
- package/dist/cjs/Dismissable.js.map +2 -2
- package/dist/cjs/Dismissable.native.js +38 -1
- package/dist/cjs/Dismissable.native.js.map +2 -2
- package/dist/cjs/DismissableProps.js +16 -1
- package/dist/cjs/DismissableProps.js.map +2 -2
- package/dist/cjs/index.js +18 -1
- package/dist/cjs/index.js.map +2 -2
- package/dist/esm/Dismissable.js +249 -1
- package/dist/esm/Dismissable.js.map +2 -2
- package/dist/esm/Dismissable.mjs +249 -1
- package/dist/esm/Dismissable.mjs.map +2 -2
- package/dist/esm/Dismissable.native.js +13 -1
- package/dist/esm/Dismissable.native.js.map +2 -2
- package/dist/esm/Dismissable.native.mjs +13 -1
- package/dist/esm/Dismissable.native.mjs.map +2 -2
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/index.mjs.map +1 -1
- package/dist/jsx/Dismissable.js +245 -1
- package/dist/jsx/Dismissable.js.map +2 -2
- package/dist/jsx/Dismissable.mjs +245 -1
- package/dist/jsx/Dismissable.mjs.map +2 -2
- package/dist/jsx/Dismissable.native.js +13 -1
- package/dist/jsx/Dismissable.native.js.map +2 -2
- package/dist/jsx/Dismissable.native.mjs +13 -1
- package/dist/jsx/Dismissable.native.mjs.map +2 -2
- package/dist/jsx/index.js +1 -1
- package/dist/jsx/index.js.map +1 -1
- package/dist/jsx/index.mjs +1 -1
- package/dist/jsx/index.mjs.map +1 -1
- package/package.json +5 -5
package/dist/cjs/Dismissable.js
CHANGED
|
@@ -1,2 +1,286 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var Dismissable_exports = {};
|
|
30
|
+
__export(Dismissable_exports, {
|
|
31
|
+
Dismissable: () => Dismissable,
|
|
32
|
+
DismissableBranch: () => DismissableBranch,
|
|
33
|
+
dispatchDiscreteCustomEvent: () => dispatchDiscreteCustomEvent
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(Dismissable_exports);
|
|
36
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
37
|
+
var import_react_use_escape_keydown = require("@radix-ui/react-use-escape-keydown");
|
|
38
|
+
var import_compose_refs = require("@tamagui/compose-refs");
|
|
39
|
+
var import_core = require("@tamagui/core");
|
|
40
|
+
var import_use_event = require("@tamagui/use-event");
|
|
41
|
+
var React = __toESM(require("react"));
|
|
42
|
+
var ReactDOM = __toESM(require("react-dom"));
|
|
43
|
+
function dispatchDiscreteCustomEvent(target, event) {
|
|
44
|
+
if (target)
|
|
45
|
+
ReactDOM.flushSync(() => target.dispatchEvent(event));
|
|
46
|
+
}
|
|
47
|
+
const DISMISSABLE_LAYER_NAME = "Dismissable";
|
|
48
|
+
const CONTEXT_UPDATE = "dismissable.update";
|
|
49
|
+
const POINTER_DOWN_OUTSIDE = "dismissable.pointerDownOutside";
|
|
50
|
+
const FOCUS_OUTSIDE = "dismissable.focusOutside";
|
|
51
|
+
let originalBodyPointerEvents;
|
|
52
|
+
const DismissableContext = React.createContext({
|
|
53
|
+
layers: /* @__PURE__ */ new Set(),
|
|
54
|
+
layersWithOutsidePointerEventsDisabled: /* @__PURE__ */ new Set(),
|
|
55
|
+
branches: /* @__PURE__ */ new Set()
|
|
56
|
+
});
|
|
57
|
+
const Dismissable = React.forwardRef(
|
|
58
|
+
(props, forwardedRef) => {
|
|
59
|
+
const {
|
|
60
|
+
disableOutsidePointerEvents = false,
|
|
61
|
+
forceUnmount,
|
|
62
|
+
onEscapeKeyDown,
|
|
63
|
+
onPointerDownOutside,
|
|
64
|
+
onFocusOutside,
|
|
65
|
+
onInteractOutside,
|
|
66
|
+
onDismiss,
|
|
67
|
+
...layerProps
|
|
68
|
+
} = props;
|
|
69
|
+
const context = React.useContext(DismissableContext);
|
|
70
|
+
const [node, setNode] = React.useState(null);
|
|
71
|
+
const [, force] = React.useState({});
|
|
72
|
+
const composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, (node2) => setNode(node2));
|
|
73
|
+
const layers = Array.from(context.layers);
|
|
74
|
+
const [highestLayerWithOutsidePointerEventsDisabled] = [
|
|
75
|
+
...context.layersWithOutsidePointerEventsDisabled
|
|
76
|
+
].slice(-1);
|
|
77
|
+
const highestLayerWithOutsidePointerEventsDisabledIndex = layers.indexOf(
|
|
78
|
+
highestLayerWithOutsidePointerEventsDisabled
|
|
79
|
+
);
|
|
80
|
+
const index = node ? layers.indexOf(node) : -1;
|
|
81
|
+
const isBodyPointerEventsDisabled = context.layersWithOutsidePointerEventsDisabled.size > 0;
|
|
82
|
+
const isPointerEventsEnabled = index >= highestLayerWithOutsidePointerEventsDisabledIndex;
|
|
83
|
+
const pointerDownOutside = usePointerDownOutside((event) => {
|
|
84
|
+
const target = event.target;
|
|
85
|
+
const isPointerDownOnBranch = [...context.branches].some(
|
|
86
|
+
(branch) => branch.contains(target)
|
|
87
|
+
);
|
|
88
|
+
if (!isPointerEventsEnabled || isPointerDownOnBranch)
|
|
89
|
+
return;
|
|
90
|
+
onPointerDownOutside == null ? void 0 : onPointerDownOutside(event);
|
|
91
|
+
onInteractOutside == null ? void 0 : onInteractOutside(event);
|
|
92
|
+
if (!event.defaultPrevented)
|
|
93
|
+
onDismiss == null ? void 0 : onDismiss();
|
|
94
|
+
});
|
|
95
|
+
const focusOutside = useFocusOutside((event) => {
|
|
96
|
+
const target = event.target;
|
|
97
|
+
const isFocusInBranch = [...context.branches].some(
|
|
98
|
+
(branch) => branch.contains(target)
|
|
99
|
+
);
|
|
100
|
+
if (isFocusInBranch)
|
|
101
|
+
return;
|
|
102
|
+
onFocusOutside == null ? void 0 : onFocusOutside(event);
|
|
103
|
+
onInteractOutside == null ? void 0 : onInteractOutside(event);
|
|
104
|
+
if (!event.defaultPrevented)
|
|
105
|
+
onDismiss == null ? void 0 : onDismiss();
|
|
106
|
+
});
|
|
107
|
+
(0, import_react_use_escape_keydown.useEscapeKeydown)((event) => {
|
|
108
|
+
const isHighestLayer = index === context.layers.size - 1;
|
|
109
|
+
if (!isHighestLayer)
|
|
110
|
+
return;
|
|
111
|
+
onEscapeKeyDown == null ? void 0 : onEscapeKeyDown(event);
|
|
112
|
+
if (!event.defaultPrevented && onDismiss) {
|
|
113
|
+
event.preventDefault();
|
|
114
|
+
onDismiss();
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
React.useEffect(() => {
|
|
118
|
+
if (!node)
|
|
119
|
+
return;
|
|
120
|
+
if (disableOutsidePointerEvents) {
|
|
121
|
+
if (context.layersWithOutsidePointerEventsDisabled.size === 0) {
|
|
122
|
+
originalBodyPointerEvents = document.body.style.pointerEvents;
|
|
123
|
+
document.body.style.pointerEvents = "none";
|
|
124
|
+
}
|
|
125
|
+
context.layersWithOutsidePointerEventsDisabled.add(node);
|
|
126
|
+
}
|
|
127
|
+
context.layers.add(node);
|
|
128
|
+
dispatchUpdate();
|
|
129
|
+
return () => {
|
|
130
|
+
if (disableOutsidePointerEvents && context.layersWithOutsidePointerEventsDisabled.size === 1) {
|
|
131
|
+
document.body.style.pointerEvents = originalBodyPointerEvents;
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
}, [node, disableOutsidePointerEvents, context]);
|
|
135
|
+
React.useEffect(() => {
|
|
136
|
+
if (forceUnmount)
|
|
137
|
+
return;
|
|
138
|
+
return () => {
|
|
139
|
+
if (!node)
|
|
140
|
+
return;
|
|
141
|
+
context.layers.delete(node);
|
|
142
|
+
context.layersWithOutsidePointerEventsDisabled.delete(node);
|
|
143
|
+
dispatchUpdate();
|
|
144
|
+
};
|
|
145
|
+
}, [node, context, forceUnmount]);
|
|
146
|
+
React.useEffect(() => {
|
|
147
|
+
const handleUpdate = () => {
|
|
148
|
+
force({});
|
|
149
|
+
};
|
|
150
|
+
document.addEventListener(CONTEXT_UPDATE, handleUpdate);
|
|
151
|
+
return () => document.removeEventListener(CONTEXT_UPDATE, handleUpdate);
|
|
152
|
+
}, []);
|
|
153
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
154
|
+
"div",
|
|
155
|
+
{
|
|
156
|
+
...layerProps,
|
|
157
|
+
ref: composedRefs,
|
|
158
|
+
style: {
|
|
159
|
+
display: "contents",
|
|
160
|
+
pointerEvents: isBodyPointerEventsDisabled ? isPointerEventsEnabled ? "auto" : "none" : void 0,
|
|
161
|
+
// @ts-ignore
|
|
162
|
+
...props.style
|
|
163
|
+
},
|
|
164
|
+
onFocusCapture: (0, import_core.composeEventHandlers)(
|
|
165
|
+
// @ts-ignore
|
|
166
|
+
props.onFocusCapture,
|
|
167
|
+
focusOutside.onFocusCapture
|
|
168
|
+
),
|
|
169
|
+
onBlurCapture: (0, import_core.composeEventHandlers)(
|
|
170
|
+
// @ts-ignore
|
|
171
|
+
props.onBlurCapture,
|
|
172
|
+
focusOutside.onBlurCapture
|
|
173
|
+
),
|
|
174
|
+
onPointerDownCapture: (0, import_core.composeEventHandlers)(
|
|
175
|
+
// @ts-ignore
|
|
176
|
+
props.onPointerDownCapture,
|
|
177
|
+
pointerDownOutside.onPointerDownCapture
|
|
178
|
+
)
|
|
179
|
+
}
|
|
180
|
+
);
|
|
181
|
+
}
|
|
182
|
+
);
|
|
183
|
+
Dismissable.displayName = DISMISSABLE_LAYER_NAME;
|
|
184
|
+
const BRANCH_NAME = "DismissableBranch";
|
|
185
|
+
const DismissableBranch = React.forwardRef(
|
|
186
|
+
(props, forwardedRef) => {
|
|
187
|
+
const context = React.useContext(DismissableContext);
|
|
188
|
+
const ref = React.useRef(null);
|
|
189
|
+
const composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, ref);
|
|
190
|
+
React.useEffect(() => {
|
|
191
|
+
const node = ref.current;
|
|
192
|
+
if (node) {
|
|
193
|
+
context.branches.add(node);
|
|
194
|
+
return () => {
|
|
195
|
+
context.branches.delete(node);
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
}, [context.branches]);
|
|
199
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: { display: "contents" }, ...props, ref: composedRefs });
|
|
200
|
+
}
|
|
201
|
+
);
|
|
202
|
+
DismissableBranch.displayName = BRANCH_NAME;
|
|
203
|
+
function usePointerDownOutside(onPointerDownOutside) {
|
|
204
|
+
const handlePointerDownOutside = (0, import_use_event.useEvent)(onPointerDownOutside);
|
|
205
|
+
const isPointerInsideReactTreeRef = React.useRef(false);
|
|
206
|
+
const handleClickRef = React.useRef(() => {
|
|
207
|
+
});
|
|
208
|
+
React.useEffect(() => {
|
|
209
|
+
const handlePointerDown = (event) => {
|
|
210
|
+
if (event.target && !isPointerInsideReactTreeRef.current) {
|
|
211
|
+
let handleAndDispatchPointerDownOutsideEvent2 = function() {
|
|
212
|
+
handleAndDispatchCustomEvent(
|
|
213
|
+
POINTER_DOWN_OUTSIDE,
|
|
214
|
+
handlePointerDownOutside,
|
|
215
|
+
eventDetail,
|
|
216
|
+
{ discrete: true }
|
|
217
|
+
);
|
|
218
|
+
};
|
|
219
|
+
var handleAndDispatchPointerDownOutsideEvent = handleAndDispatchPointerDownOutsideEvent2;
|
|
220
|
+
const eventDetail = { originalEvent: event };
|
|
221
|
+
if (event.pointerType === "touch") {
|
|
222
|
+
document.removeEventListener("click", handleClickRef.current);
|
|
223
|
+
handleClickRef.current = handleAndDispatchPointerDownOutsideEvent2;
|
|
224
|
+
document.addEventListener("click", handleClickRef.current, { once: true });
|
|
225
|
+
} else {
|
|
226
|
+
handleAndDispatchPointerDownOutsideEvent2();
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
isPointerInsideReactTreeRef.current = false;
|
|
230
|
+
};
|
|
231
|
+
const timerId = setTimeout(() => {
|
|
232
|
+
document.addEventListener("pointerdown", handlePointerDown);
|
|
233
|
+
}, 0);
|
|
234
|
+
return () => {
|
|
235
|
+
window.clearTimeout(timerId);
|
|
236
|
+
document.removeEventListener("pointerdown", handlePointerDown);
|
|
237
|
+
document.removeEventListener("click", handleClickRef.current);
|
|
238
|
+
};
|
|
239
|
+
}, [handlePointerDownOutside]);
|
|
240
|
+
return {
|
|
241
|
+
// ensures we check React component tree (not just DOM tree)
|
|
242
|
+
onPointerDownCapture: () => isPointerInsideReactTreeRef.current = true
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
function useFocusOutside(onFocusOutside) {
|
|
246
|
+
const handleFocusOutside = (0, import_use_event.useEvent)(onFocusOutside);
|
|
247
|
+
const isFocusInsideReactTreeRef = React.useRef(false);
|
|
248
|
+
React.useEffect(() => {
|
|
249
|
+
const handleFocus = (event) => {
|
|
250
|
+
if (event.target && !isFocusInsideReactTreeRef.current) {
|
|
251
|
+
const eventDetail = { originalEvent: event };
|
|
252
|
+
handleAndDispatchCustomEvent(FOCUS_OUTSIDE, handleFocusOutside, eventDetail, {
|
|
253
|
+
discrete: false
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
};
|
|
257
|
+
document.addEventListener("focusin", handleFocus);
|
|
258
|
+
return () => document.removeEventListener("focusin", handleFocus);
|
|
259
|
+
}, [handleFocusOutside]);
|
|
260
|
+
return {
|
|
261
|
+
onFocusCapture: () => isFocusInsideReactTreeRef.current = true,
|
|
262
|
+
onBlurCapture: () => isFocusInsideReactTreeRef.current = false
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
function dispatchUpdate() {
|
|
266
|
+
const event = new CustomEvent(CONTEXT_UPDATE);
|
|
267
|
+
document.dispatchEvent(event);
|
|
268
|
+
}
|
|
269
|
+
function handleAndDispatchCustomEvent(name, handler, detail, { discrete }) {
|
|
270
|
+
const target = detail.originalEvent.target;
|
|
271
|
+
const event = new CustomEvent(name, { bubbles: false, cancelable: true, detail });
|
|
272
|
+
if (handler)
|
|
273
|
+
target.addEventListener(name, handler, { once: true });
|
|
274
|
+
if (discrete) {
|
|
275
|
+
dispatchDiscreteCustomEvent(target, event);
|
|
276
|
+
} else {
|
|
277
|
+
target.dispatchEvent(event);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
281
|
+
0 && (module.exports = {
|
|
282
|
+
Dismissable,
|
|
283
|
+
DismissableBranch,
|
|
284
|
+
dispatchDiscreteCustomEvent
|
|
285
|
+
});
|
|
2
286
|
//# sourceMappingURL=Dismissable.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Dismissable.tsx"],
|
|
4
4
|
"sourcesContent": ["// forked from radix-ui\n// https://github.com/radix-ui/primitives/blob/cfd8dcba5fa6a0e751486af418d05a7b88a7f541/packages/react/dismissable-layer/src/DismissableLayer.tsx#L324\n\nimport { useEscapeKeydown } from '@radix-ui/react-use-escape-keydown'\nimport { useComposedRefs } from '@tamagui/compose-refs'\nimport { composeEventHandlers } from '@tamagui/core'\nimport { useEvent } from '@tamagui/use-event'\nimport * as React from 'react'\nimport * as ReactDOM from 'react-dom'\n\nimport { DismissableBranchProps, DismissableProps } from './DismissableProps'\n\nexport function dispatchDiscreteCustomEvent<E extends CustomEvent>(\n target: E['target'],\n event: E\n) {\n if (target) ReactDOM.flushSync(() => target.dispatchEvent(event))\n}\n\n/* -------------------------------------------------------------------------------------------------\n * Dismissable\n * -----------------------------------------------------------------------------------------------*/\n\nconst DISMISSABLE_LAYER_NAME = 'Dismissable'\nconst CONTEXT_UPDATE = 'dismissable.update'\nconst POINTER_DOWN_OUTSIDE = 'dismissable.pointerDownOutside'\nconst FOCUS_OUTSIDE = 'dismissable.focusOutside'\n\nlet originalBodyPointerEvents: string\n\nconst DismissableContext = React.createContext({\n layers: new Set<HTMLDivElement>(),\n layersWithOutsidePointerEventsDisabled: new Set<HTMLDivElement>(),\n branches: new Set<HTMLDivElement>(),\n})\n\nconst Dismissable = React.forwardRef<HTMLDivElement, DismissableProps>(\n (props, forwardedRef) => {\n const {\n disableOutsidePointerEvents = false,\n forceUnmount,\n onEscapeKeyDown,\n onPointerDownOutside,\n onFocusOutside,\n onInteractOutside,\n onDismiss,\n ...layerProps\n } = props\n const context = React.useContext(DismissableContext)\n const [node, setNode] = React.useState<HTMLDivElement | null>(null)\n const [, force] = React.useState({})\n const composedRefs = useComposedRefs(forwardedRef, (node) => setNode(node))\n const layers = Array.from(context.layers)\n\n const [highestLayerWithOutsidePointerEventsDisabled] = [\n ...context.layersWithOutsidePointerEventsDisabled,\n ].slice(-1)\n const highestLayerWithOutsidePointerEventsDisabledIndex = layers.indexOf(\n highestLayerWithOutsidePointerEventsDisabled\n )\n\n const index = node ? layers.indexOf(node) : -1\n const isBodyPointerEventsDisabled =\n context.layersWithOutsidePointerEventsDisabled.size > 0\n const isPointerEventsEnabled =\n index >= highestLayerWithOutsidePointerEventsDisabledIndex\n\n const pointerDownOutside = usePointerDownOutside((event) => {\n const target = event.target as HTMLDivElement\n const isPointerDownOnBranch = [...context.branches].some((branch) =>\n branch.contains(target)\n )\n if (!isPointerEventsEnabled || isPointerDownOnBranch) return\n onPointerDownOutside?.(event)\n onInteractOutside?.(event)\n if (!event.defaultPrevented) onDismiss?.()\n })\n\n const focusOutside = useFocusOutside((event) => {\n const target = event.target as HTMLDivElement\n const isFocusInBranch = [...context.branches].some((branch) =>\n branch.contains(target)\n )\n if (isFocusInBranch) return\n onFocusOutside?.(event)\n onInteractOutside?.(event)\n if (!event.defaultPrevented) onDismiss?.()\n })\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 })\n\n React.useEffect(() => {\n if (!node) return\n if (disableOutsidePointerEvents) {\n if (context.layersWithOutsidePointerEventsDisabled.size === 0) {\n originalBodyPointerEvents = document.body.style.pointerEvents\n document.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 document.body.style.pointerEvents = originalBodyPointerEvents\n }\n }\n }, [node, 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 if (forceUnmount) return\n return () => {\n if (!node) return\n context.layers.delete(node)\n context.layersWithOutsidePointerEventsDisabled.delete(node)\n dispatchUpdate()\n }\n }, [node, context, forceUnmount])\n\n React.useEffect(() => {\n const handleUpdate = () => {\n force({})\n }\n document.addEventListener(CONTEXT_UPDATE, handleUpdate)\n return () => document.removeEventListener(CONTEXT_UPDATE, handleUpdate)\n }, [])\n\n return (\n <div\n {...layerProps}\n // @ts-ignore\n ref={composedRefs}\n style={{\n display: 'contents',\n pointerEvents: isBodyPointerEventsDisabled\n ? isPointerEventsEnabled\n ? 'auto'\n : 'none'\n : undefined,\n // @ts-ignore\n ...props.style,\n }}\n onFocusCapture={composeEventHandlers(\n // @ts-ignore\n props.onFocusCapture,\n focusOutside.onFocusCapture\n )}\n onBlurCapture={composeEventHandlers(\n // @ts-ignore\n props.onBlurCapture,\n focusOutside.onBlurCapture\n )}\n // @ts-ignore\n onPointerDownCapture={composeEventHandlers(\n // @ts-ignore\n props.onPointerDownCapture,\n pointerDownOutside.onPointerDownCapture\n )}\n />\n )\n }\n)\n\nDismissable.displayName = DISMISSABLE_LAYER_NAME\n\n/* -------------------------------------------------------------------------------------------------\n * DismissableBranch\n * -----------------------------------------------------------------------------------------------*/\n\nconst BRANCH_NAME = 'DismissableBranch'\n\nconst DismissableBranch = React.forwardRef<HTMLDivElement, DismissableBranchProps>(\n (props, forwardedRef) => {\n const context = React.useContext(DismissableContext)\n const ref = React.useRef<HTMLDivElement>(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 <div style={{ display: 'contents' }} {...props} ref={composedRefs} />\n }\n)\n\nDismissableBranch.displayName = BRANCH_NAME\n\n/* -----------------------------------------------------------------------------------------------*/\n\nexport type PointerDownOutsideEvent = CustomEvent<{ originalEvent: PointerEvent }>\nexport type 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) {\n const handlePointerDownOutside = useEvent(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 document.removeEventListener('click', handleClickRef.current)\n handleClickRef.current = handleAndDispatchPointerDownOutsideEvent\n document.addEventListener('click', handleClickRef.current, { once: true })\n } else {\n handleAndDispatchPointerDownOutsideEvent()\n }\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 = setTimeout(() => {\n document.addEventListener('pointerdown', handlePointerDown)\n }, 0)\n return () => {\n window.clearTimeout(timerId)\n document.removeEventListener('pointerdown', handlePointerDown)\n document.removeEventListener('click', handleClickRef.current)\n }\n }, [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(onFocusOutside?: (event: FocusOutsideEvent) => void) {\n const handleFocusOutside = useEvent(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 document.addEventListener('focusin', handleFocus)\n return () => document.removeEventListener('focusin', handleFocus)\n }, [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\nexport { Dismissable, DismissableBranch }\n\nex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BAAgB,gBAAqD;AAC5E,QAAM,yBAAqB,2BAAS,cAAc;AAClD,QAAM,4BAA4B,MAAM,OAAO,KAAK;AAEpD,QAAM,UAAU,MAAM;AACpB,UAAM,cAAc,CAAC,UAAsB;AACzC,UAAI,MAAM,UAAU,CAAC,0BAA0B,SAAS;AACtD,cAAM,cAAc,EAAE,eAAe,MAAM;AAC3C,qCAA6B,eAAe,oBAAoB,aAAa;AAAA,UAC3E,UAAU;AAAA,QACZ,CAAC;AAAA,MACH;AAAA,IACF;AACA,aAAS,iBAAiB,WAAW,WAAW;AAChD,WAAO,MAAM,SAAS,oBAAoB,WAAW,WAAW;AAAA,EAClE,GAAG,CAAC,kBAAkB,CAAC;AAEvB,SAAO;AAAA,IACL,gBAAgB,MAAO,0BAA0B,UAAU;AAAA,IAC3D,eAAe,MAAO,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;AAAS,WAAO,iBAAiB,MAAM,SAA0B,EAAE,MAAM,KAAK,CAAC;AAEnF,MAAI,UAAU;AACZ,gCAA4B,QAAQ,KAAK;AAAA,EAC3C,OAAO;AACL,WAAO,cAAc,KAAK;AAAA,EAC5B;AACF;",
|
|
6
|
+
"names": ["node", "handleAndDispatchPointerDownOutsideEvent"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,39 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var Dismissable_native_exports = {};
|
|
20
|
+
__export(Dismissable_native_exports, {
|
|
21
|
+
Dismissable: () => Dismissable,
|
|
22
|
+
DismissableBranch: () => DismissableBranch
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(Dismissable_native_exports);
|
|
25
|
+
var import_react = require("react");
|
|
26
|
+
const Dismissable = (0, import_react.forwardRef)((props, _ref) => {
|
|
27
|
+
return props.children;
|
|
28
|
+
});
|
|
29
|
+
const DismissableBranch = (0, import_react.forwardRef)(
|
|
30
|
+
(props, _ref) => {
|
|
31
|
+
return props.children;
|
|
32
|
+
}
|
|
33
|
+
);
|
|
34
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
35
|
+
0 && (module.exports = {
|
|
36
|
+
Dismissable,
|
|
37
|
+
DismissableBranch
|
|
38
|
+
});
|
|
2
39
|
//# sourceMappingURL=Dismissable.native.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/Dismissable.native.tsx"],
|
|
4
4
|
"sourcesContent": ["import { forwardRef } from 'react'\n\nimport { DismissableBranchProps, DismissableProps } from './DismissableProps'\n\nexport const Dismissable = forwardRef((props: DismissableProps, _ref) => {\n return props.children as any\n})\n\nexport const DismissableBranch = forwardRef(\n (props: DismissableBranchProps, _ref) => {\n return props.children as any\n },\n)\n"],
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": [
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA2B;AAIpB,MAAM,kBAAc,yBAAW,CAAC,OAAyB,SAAS;AACvE,SAAO,MAAM;AACf,CAAC;AAEM,MAAM,wBAAoB;AAAA,EAC/B,CAAC,OAA+B,SAAS;AACvC,WAAO,MAAM;AAAA,EACf;AACF;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
|
@@ -1,2 +1,17 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var DismissableProps_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(DismissableProps_exports);
|
|
2
17
|
//# sourceMappingURL=DismissableProps.js.map
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/DismissableProps.tsx"],
|
|
4
4
|
"sourcesContent": ["import React from 'react'\n\nimport { FocusOutsideEvent, PointerDownOutsideEvent } from './Dismissable'\n\nexport interface DismissableProps {\n /**\n * When `true`, hover/focus/click interactions will be disabled on elements outside\n * the `Dismissable`. Users will need to click twice on outside elements to\n * interact with them: once to close the `Dismissable`, 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 `Dismissable`.\n * Can be prevented.\n */\n onPointerDownOutside?: (event: PointerDownOutsideEvent) => void\n /**\n * Event handler called when the focus moves outside of the `Dismissable`.\n * Can be prevented.\n */\n onFocusOutside?: (event: FocusOutsideEvent) => void\n /**\n * Event handler called when an interaction happens outside the `Dismissable`.\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 `Dismissable` should be dismissed\n */\n onDismiss?: () => void\n\n /**\n * When using animations on exit, may want to simualte force unmount early\n */\n forceUnmount?: boolean\n\n children?: React.ReactNode\n}\n\nexport interface DismissableBranchProps {\n children?: React.ReactNode\n}\n"],
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": [
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;AAAA;AAAA;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,2 +1,19 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
+
var src_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(src_exports);
|
|
18
|
+
__reExport(src_exports, require("./Dismissable"), module.exports);
|
|
2
19
|
//# sourceMappingURL=index.js.map
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/index.tsx"],
|
|
4
4
|
"sourcesContent": ["export * from './Dismissable'\n"],
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": [
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,wBAAc,0BAAd;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|