@hanzogui/dismissable 8.3.0 → 8.3.2
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 +413 -0
- package/dist/cjs/Dismissable.js.map +1 -0
- package/dist/cjs/DismissableProps.js +3 -0
- package/dist/cjs/DismissableProps.js.map +1 -0
- package/dist/cjs/index.js +5 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/package.json +1 -0
- package/dist/esm/Dismissable.js +402 -0
- package/dist/esm/Dismissable.js.map +1 -0
- package/dist/esm/DismissableProps.js +2 -0
- package/dist/esm/DismissableProps.js.map +1 -0
- package/dist/esm/index.js +2 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/native/Dismissable.js +22 -0
- package/dist/native/Dismissable.js.map +1 -0
- package/dist/native/DismissableProps.js +2 -0
- package/dist/native/DismissableProps.js.map +1 -0
- package/dist/native/index.js +2 -0
- package/dist/native/index.js.map +1 -0
- package/package.json +19 -19
- package/src/Dismissable.native.tsx +1 -1
- package/src/Dismissable.tsx +1 -1
- package/src/DismissableProps.tsx +1 -1
- package/src/index.ts +1 -1
- package/types/Dismissable.d.ts +1 -1
- package/types/Dismissable.d.ts.map +1 -1
- package/types/Dismissable.native.d.ts +1 -1
- package/types/Dismissable.native.d.ts.map +1 -1
- package/types/DismissableProps.d.ts +1 -1
- package/types/DismissableProps.d.ts.map +1 -1
- package/types/index.d.ts +1 -1
- package/types/index.d.ts.map +1 -1
- package/dist/cjs/Dismissable.cjs +0 -383
- package/dist/cjs/Dismissable.native.js +0 -67
- package/dist/cjs/Dismissable.native.js.map +0 -1
- package/dist/cjs/DismissableProps.cjs +0 -18
- package/dist/cjs/DismissableProps.native.js +0 -21
- package/dist/cjs/DismissableProps.native.js.map +0 -1
- package/dist/cjs/index.cjs +0 -20
- package/dist/cjs/index.native.js +0 -23
- package/dist/cjs/index.native.js.map +0 -1
- package/dist/esm/Dismissable.mjs +0 -340
- package/dist/esm/Dismissable.mjs.map +0 -1
- package/dist/esm/Dismissable.native.js +0 -22
- package/dist/esm/Dismissable.native.js.map +0 -1
- package/dist/esm/DismissableProps.mjs +0 -2
- package/dist/esm/DismissableProps.mjs.map +0 -1
- package/dist/esm/DismissableProps.native.js +0 -2
- package/dist/esm/DismissableProps.native.js.map +0 -1
- package/dist/esm/index.mjs +0 -2
- package/dist/esm/index.mjs.map +0 -1
- package/dist/esm/index.native.js +0 -2
- package/dist/esm/index.native.js.map +0 -1
- package/dist/jsx/Dismissable.mjs +0 -340
- package/dist/jsx/Dismissable.mjs.map +0 -1
- package/dist/jsx/Dismissable.native.js +0 -67
- package/dist/jsx/Dismissable.native.js.map +0 -1
- package/dist/jsx/DismissableProps.mjs +0 -2
- package/dist/jsx/DismissableProps.mjs.map +0 -1
- package/dist/jsx/DismissableProps.native.js +0 -21
- package/dist/jsx/DismissableProps.native.js.map +0 -1
- package/dist/jsx/index.js +0 -2
- package/dist/jsx/index.js.map +0 -1
- package/dist/jsx/index.mjs +0 -2
- package/dist/jsx/index.mjs.map +0 -1
- package/dist/jsx/index.native.js +0 -23
- package/dist/jsx/index.native.js.map +0 -1
|
@@ -0,0 +1,413 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DismissableBranch = exports.Dismissable = void 0;
|
|
4
|
+
exports.dispatchDiscreteCustomEvent = dispatchDiscreteCustomEvent;
|
|
5
|
+
exports.getDismissableLayerCount = getDismissableLayerCount;
|
|
6
|
+
exports.debugDismissableLayers = debugDismissableLayers;
|
|
7
|
+
exports.useHasDismissableLayers = useHasDismissableLayers;
|
|
8
|
+
exports.useIsInsideDismissable = useIsInsideDismissable;
|
|
9
|
+
exports.useDismissableLayersAbove = useDismissableLayersAbove;
|
|
10
|
+
const tslib_1 = require("tslib");
|
|
11
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
12
|
+
// forked from radix-ui
|
|
13
|
+
// https://github.com/radix-ui/primitives/blob/cfd8dcba5fa6a0e751486af418d05a7b88a7f541/packages/react/dismissable-layer/src/DismissableLayer.tsx#L324
|
|
14
|
+
const compose_refs_1 = require("@hanzogui/compose-refs");
|
|
15
|
+
const core_1 = require("@hanzogui/core");
|
|
16
|
+
const use_escape_keydown_1 = require("@hanzogui/use-escape-keydown");
|
|
17
|
+
const use_event_1 = require("@hanzogui/use-event");
|
|
18
|
+
const React = tslib_1.__importStar(require("react"));
|
|
19
|
+
const ReactDOM = tslib_1.__importStar(require("react-dom"));
|
|
20
|
+
function dispatchDiscreteCustomEvent(target, event) {
|
|
21
|
+
if (target)
|
|
22
|
+
ReactDOM.flushSync(() => target.dispatchEvent(event));
|
|
23
|
+
}
|
|
24
|
+
/* -------------------------------------------------------------------------------------------------
|
|
25
|
+
* Dismissable
|
|
26
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
27
|
+
const DISMISSABLE_LAYER_NAME = 'Dismissable';
|
|
28
|
+
const CONTEXT_UPDATE = 'dismissable.update';
|
|
29
|
+
const POINTER_DOWN_OUTSIDE = 'dismissable.pointerDownOutside';
|
|
30
|
+
const FOCUS_OUTSIDE = 'dismissable.focusOutside';
|
|
31
|
+
let originalBodyPointerEvents;
|
|
32
|
+
// global layer tracking
|
|
33
|
+
const globalLayers = new Set();
|
|
34
|
+
const layerChangeListeners = new Set();
|
|
35
|
+
// track if any layer has disableOutsidePointerEvents - only then do we need position updates
|
|
36
|
+
let layersWithPointerEventsDisabledCount = 0;
|
|
37
|
+
function notifyLayerChange() {
|
|
38
|
+
for (const listener of layerChangeListeners) {
|
|
39
|
+
listener();
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* returns the number of active dismissable layers
|
|
44
|
+
* useful for non-React contexts (e.g. escape key handlers)
|
|
45
|
+
*/
|
|
46
|
+
function getDismissableLayerCount() {
|
|
47
|
+
return globalLayers.size;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* debug helper - logs what elements are registered as dismissable layers
|
|
51
|
+
*/
|
|
52
|
+
function debugDismissableLayers() {
|
|
53
|
+
const layers = Array.from(globalLayers);
|
|
54
|
+
console.log('[Dismissable] Active layers:', layers.length, layers);
|
|
55
|
+
return layers;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* hook that returns true when any dismissable layer is active
|
|
59
|
+
* re-renders when the state changes
|
|
60
|
+
* uses module-level globals, not React context, so works anywhere in tree
|
|
61
|
+
*/
|
|
62
|
+
function useHasDismissableLayers() {
|
|
63
|
+
const [count, setCount] = React.useState(() => globalLayers.size);
|
|
64
|
+
React.useEffect(() => {
|
|
65
|
+
setCount(globalLayers.size);
|
|
66
|
+
const update = () => setCount(globalLayers.size);
|
|
67
|
+
layerChangeListeners.add(update);
|
|
68
|
+
return () => {
|
|
69
|
+
layerChangeListeners.delete(update);
|
|
70
|
+
};
|
|
71
|
+
}, []);
|
|
72
|
+
return count > 0;
|
|
73
|
+
}
|
|
74
|
+
const DismissableContext = React.createContext({
|
|
75
|
+
layers: new Set(),
|
|
76
|
+
layersWithOutsidePointerEventsDisabled: new Set(),
|
|
77
|
+
branches: new Set(),
|
|
78
|
+
});
|
|
79
|
+
/**
|
|
80
|
+
* hook to check if a DOM element is inside an active dismissable layer
|
|
81
|
+
* useful for custom escape handling - if inside a dismissable, you may want to defer
|
|
82
|
+
*/
|
|
83
|
+
function useIsInsideDismissable(ref) {
|
|
84
|
+
const context = React.useContext(DismissableContext);
|
|
85
|
+
const [isInside, setIsInside] = React.useState(false);
|
|
86
|
+
React.useEffect(() => {
|
|
87
|
+
const check = () => {
|
|
88
|
+
const el = ref.current;
|
|
89
|
+
if (!el) {
|
|
90
|
+
setIsInside(false);
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
for (const layer of context.layers) {
|
|
94
|
+
if (layer.contains(el)) {
|
|
95
|
+
setIsInside(true);
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
setIsInside(false);
|
|
100
|
+
};
|
|
101
|
+
check();
|
|
102
|
+
document.addEventListener(CONTEXT_UPDATE, check);
|
|
103
|
+
return () => document.removeEventListener(CONTEXT_UPDATE, check);
|
|
104
|
+
}, [context.layers, ref]);
|
|
105
|
+
return isInside;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* hook to check if there are dismissable layers above a given element
|
|
109
|
+
* returns the count of layers that are ancestors of the element
|
|
110
|
+
*/
|
|
111
|
+
function useDismissableLayersAbove(ref) {
|
|
112
|
+
const context = React.useContext(DismissableContext);
|
|
113
|
+
const [count, setCount] = React.useState(0);
|
|
114
|
+
React.useEffect(() => {
|
|
115
|
+
const check = () => {
|
|
116
|
+
const el = ref.current;
|
|
117
|
+
if (!el) {
|
|
118
|
+
setCount(0);
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
let above = 0;
|
|
122
|
+
for (const layer of context.layers) {
|
|
123
|
+
if (layer.contains(el)) {
|
|
124
|
+
above++;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
setCount(above);
|
|
128
|
+
};
|
|
129
|
+
check();
|
|
130
|
+
document.addEventListener(CONTEXT_UPDATE, check);
|
|
131
|
+
return () => document.removeEventListener(CONTEXT_UPDATE, check);
|
|
132
|
+
}, [context.layers, ref]);
|
|
133
|
+
return count;
|
|
134
|
+
}
|
|
135
|
+
const Dismissable = React.forwardRef((props, forwardedRef) => {
|
|
136
|
+
const { disableOutsidePointerEvents = false, forceUnmount, onEscapeKeyDown, onPointerDownOutside, onFocusOutside, onInteractOutside, onDismiss, asChild, children, branches: branchesProp, ...layerProps } = props;
|
|
137
|
+
const Comp = asChild ? core_1.Slot : core_1.View;
|
|
138
|
+
const context = React.useContext(DismissableContext);
|
|
139
|
+
const [node, setNode] = React.useState(null);
|
|
140
|
+
const [, force] = React.useState({});
|
|
141
|
+
const composedRefs = (0, compose_refs_1.useComposedRefs)(forwardedRef, (node) => setNode(node));
|
|
142
|
+
const layers = Array.from(context.layers);
|
|
143
|
+
const [highestLayerWithOutsidePointerEventsDisabled] = [
|
|
144
|
+
...context.layersWithOutsidePointerEventsDisabled,
|
|
145
|
+
].slice(-1);
|
|
146
|
+
const highestLayerWithOutsidePointerEventsDisabledIndex = layers.indexOf(highestLayerWithOutsidePointerEventsDisabled);
|
|
147
|
+
const index = node ? layers.indexOf(node) : -1;
|
|
148
|
+
const isBodyPointerEventsDisabled = context.layersWithOutsidePointerEventsDisabled.size > 0;
|
|
149
|
+
const isPointerEventsEnabled = index >= highestLayerWithOutsidePointerEventsDisabledIndex;
|
|
150
|
+
const pointerDownOutside = usePointerDownOutside((event) => {
|
|
151
|
+
const target = event.target;
|
|
152
|
+
// check prop-based branches first (scoped to this dismissable), then global branches
|
|
153
|
+
const branches = branchesProp || context.branches;
|
|
154
|
+
const isPointerDownOnBranch = [...branches].some((branch) => branch.contains(target));
|
|
155
|
+
if (!isPointerEventsEnabled || isPointerDownOnBranch)
|
|
156
|
+
return;
|
|
157
|
+
onPointerDownOutside?.(event);
|
|
158
|
+
onInteractOutside?.(event);
|
|
159
|
+
if (!event.defaultPrevented)
|
|
160
|
+
onDismiss?.();
|
|
161
|
+
});
|
|
162
|
+
const focusOutside = useFocusOutside((event) => {
|
|
163
|
+
const target = event.target;
|
|
164
|
+
// check prop-based branches first (scoped to this dismissable), then global branches
|
|
165
|
+
const branches = branchesProp || context.branches;
|
|
166
|
+
const isFocusInBranch = [...branches].some((branch) => branch.contains(target));
|
|
167
|
+
if (isFocusInBranch)
|
|
168
|
+
return;
|
|
169
|
+
onFocusOutside?.(event);
|
|
170
|
+
onInteractOutside?.(event);
|
|
171
|
+
if (!event.defaultPrevented)
|
|
172
|
+
onDismiss?.();
|
|
173
|
+
});
|
|
174
|
+
// track forceUnmount in a ref so escape handler can check it
|
|
175
|
+
const forceUnmountRef = React.useRef(forceUnmount);
|
|
176
|
+
React.useEffect(() => {
|
|
177
|
+
forceUnmountRef.current = forceUnmount;
|
|
178
|
+
}, [forceUnmount]);
|
|
179
|
+
(0, use_escape_keydown_1.useEscapeKeydown)((event) => {
|
|
180
|
+
// skip if this layer is force-unmounted (e.g. dialog closed but still mounted)
|
|
181
|
+
if (forceUnmountRef.current)
|
|
182
|
+
return;
|
|
183
|
+
// Check layers at callback time, not render time, to avoid stale closures
|
|
184
|
+
const currentLayers = Array.from(context.layers);
|
|
185
|
+
const currentIndex = node ? currentLayers.indexOf(node) : -1;
|
|
186
|
+
const isHighestLayer = currentIndex === currentLayers.length - 1;
|
|
187
|
+
if (!isHighestLayer)
|
|
188
|
+
return;
|
|
189
|
+
onEscapeKeyDown?.(event);
|
|
190
|
+
if (!event.defaultPrevented && onDismiss) {
|
|
191
|
+
event.preventDefault();
|
|
192
|
+
onDismiss();
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
React.useEffect(() => {
|
|
196
|
+
if (!node)
|
|
197
|
+
return;
|
|
198
|
+
// don't add to layers when force-unmounted (dialog closed but still mounted)
|
|
199
|
+
if (forceUnmount)
|
|
200
|
+
return;
|
|
201
|
+
if (disableOutsidePointerEvents) {
|
|
202
|
+
if (context.layersWithOutsidePointerEventsDisabled.size === 0) {
|
|
203
|
+
originalBodyPointerEvents = document.body.style.pointerEvents;
|
|
204
|
+
document.body.style.pointerEvents = 'none';
|
|
205
|
+
}
|
|
206
|
+
context.layersWithOutsidePointerEventsDisabled.add(node);
|
|
207
|
+
layersWithPointerEventsDisabledCount++;
|
|
208
|
+
}
|
|
209
|
+
context.layers.add(node);
|
|
210
|
+
globalLayers.add(node);
|
|
211
|
+
// only dispatch position update when pointer-events tracking is active
|
|
212
|
+
if (disableOutsidePointerEvents || layersWithPointerEventsDisabledCount > 0) {
|
|
213
|
+
dispatchUpdate();
|
|
214
|
+
}
|
|
215
|
+
notifyLayerChange();
|
|
216
|
+
return () => {
|
|
217
|
+
if (disableOutsidePointerEvents) {
|
|
218
|
+
if (context.layersWithOutsidePointerEventsDisabled.size === 1) {
|
|
219
|
+
document.body.style.pointerEvents = originalBodyPointerEvents;
|
|
220
|
+
}
|
|
221
|
+
// decrement AFTER dispatch so other layers still re-render
|
|
222
|
+
}
|
|
223
|
+
};
|
|
224
|
+
}, [node, disableOutsidePointerEvents, forceUnmount, context]);
|
|
225
|
+
/**
|
|
226
|
+
* We purposefully prevent combining this effect with the `disableOutsidePointerEvents` effect
|
|
227
|
+
* because a change to `disableOutsidePointerEvents` would remove this layer from the stack
|
|
228
|
+
* and add it to the end again so the layering order wouldn't be _creation order_.
|
|
229
|
+
* We only want them to be removed from context stacks when unmounted.
|
|
230
|
+
*/
|
|
231
|
+
React.useEffect(() => {
|
|
232
|
+
if (forceUnmount)
|
|
233
|
+
return;
|
|
234
|
+
return () => {
|
|
235
|
+
if (!node)
|
|
236
|
+
return;
|
|
237
|
+
const hadPointerEventsDisabled = context.layersWithOutsidePointerEventsDisabled.has(node);
|
|
238
|
+
context.layers.delete(node);
|
|
239
|
+
context.layersWithOutsidePointerEventsDisabled.delete(node);
|
|
240
|
+
globalLayers.delete(node);
|
|
241
|
+
// only dispatch position update when pointer-events tracking is active
|
|
242
|
+
if (layersWithPointerEventsDisabledCount > 0) {
|
|
243
|
+
dispatchUpdate();
|
|
244
|
+
}
|
|
245
|
+
notifyLayerChange();
|
|
246
|
+
// decrement count AFTER dispatch so other layers see count > 0 and re-render
|
|
247
|
+
if (hadPointerEventsDisabled) {
|
|
248
|
+
layersWithPointerEventsDisabledCount--;
|
|
249
|
+
}
|
|
250
|
+
};
|
|
251
|
+
}, [node, context, forceUnmount]);
|
|
252
|
+
React.useEffect(() => {
|
|
253
|
+
const handleUpdate = () => {
|
|
254
|
+
// only force re-render if we need to track layer positions for pointer-events
|
|
255
|
+
// this avoids N^2 re-renders when multiple dismissables mount/unmount
|
|
256
|
+
if (layersWithPointerEventsDisabledCount > 0) {
|
|
257
|
+
force({});
|
|
258
|
+
}
|
|
259
|
+
};
|
|
260
|
+
document.addEventListener(CONTEXT_UPDATE, handleUpdate);
|
|
261
|
+
return () => document.removeEventListener(CONTEXT_UPDATE, handleUpdate);
|
|
262
|
+
}, []);
|
|
263
|
+
return ((0, jsx_runtime_1.jsx)(Comp, { ...layerProps,
|
|
264
|
+
// @ts-ignore
|
|
265
|
+
ref: composedRefs, ...(!asChild && {
|
|
266
|
+
display: 'contents',
|
|
267
|
+
}), pointerEvents: isBodyPointerEventsDisabled
|
|
268
|
+
? isPointerEventsEnabled
|
|
269
|
+
? 'auto'
|
|
270
|
+
: 'none'
|
|
271
|
+
: undefined, onFocusCapture: (0, core_1.composeEventHandlers)(props.onFocusCapture, focusOutside.onFocusCapture), onBlurCapture: (0, core_1.composeEventHandlers)(props.onBlurCapture, focusOutside.onBlurCapture), onPointerDownCapture: (0, core_1.composeEventHandlers)(props.onPointerDownCapture, pointerDownOutside.onPointerDownCapture), children: children }));
|
|
272
|
+
});
|
|
273
|
+
exports.Dismissable = Dismissable;
|
|
274
|
+
Dismissable.displayName = DISMISSABLE_LAYER_NAME;
|
|
275
|
+
/* -------------------------------------------------------------------------------------------------
|
|
276
|
+
* DismissableBranch
|
|
277
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
278
|
+
const BRANCH_NAME = 'DismissableBranch';
|
|
279
|
+
const DismissableBranch = React.forwardRef((props, forwardedRef) => {
|
|
280
|
+
const { branches: branchesProp, ...rest } = props;
|
|
281
|
+
const context = React.useContext(DismissableContext);
|
|
282
|
+
const ref = React.useRef(null);
|
|
283
|
+
const composedRefs = (0, compose_refs_1.useComposedRefs)(forwardedRef, ref);
|
|
284
|
+
React.useEffect(() => {
|
|
285
|
+
const node = ref.current;
|
|
286
|
+
if (!(node instanceof HTMLElement))
|
|
287
|
+
return;
|
|
288
|
+
// use prop-based branches if provided, otherwise fall back to global context
|
|
289
|
+
const branches = branchesProp || context.branches;
|
|
290
|
+
if (node && branches) {
|
|
291
|
+
branches.add(node);
|
|
292
|
+
return () => {
|
|
293
|
+
branches.delete(node);
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
}, [branchesProp, context.branches]);
|
|
297
|
+
return (0, jsx_runtime_1.jsx)(core_1.View, { asChild: "except-style", ...rest, ref: composedRefs });
|
|
298
|
+
});
|
|
299
|
+
exports.DismissableBranch = DismissableBranch;
|
|
300
|
+
DismissableBranch.displayName = BRANCH_NAME;
|
|
301
|
+
/**
|
|
302
|
+
* Listens for `pointerdown` outside a react subtree. We use `pointerdown` rather than `pointerup`
|
|
303
|
+
* to mimic layer dismissing behaviour present in OS.
|
|
304
|
+
* Returns props to pass to the node we want to check for outside events.
|
|
305
|
+
*/
|
|
306
|
+
function usePointerDownOutside(onPointerDownOutside) {
|
|
307
|
+
const handlePointerDownOutside = (0, use_event_1.useEvent)(onPointerDownOutside);
|
|
308
|
+
const isPointerInsideReactTreeRef = React.useRef(false);
|
|
309
|
+
const handleClickRef = React.useRef(() => { });
|
|
310
|
+
React.useEffect(() => {
|
|
311
|
+
const handlePointerDown = (event) => {
|
|
312
|
+
if (event.target && !isPointerInsideReactTreeRef.current) {
|
|
313
|
+
const eventDetail = { originalEvent: event };
|
|
314
|
+
function handleAndDispatchPointerDownOutsideEvent() {
|
|
315
|
+
handleAndDispatchCustomEvent(POINTER_DOWN_OUTSIDE, handlePointerDownOutside, eventDetail, { discrete: true });
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* On touch devices, we need to wait for a click event because browsers implement
|
|
319
|
+
* a ~350ms delay between the time the user stops touching the display and when the
|
|
320
|
+
* browser executres events. We need to ensure we don't reactivate pointer-events within
|
|
321
|
+
* this timeframe otherwise the browser may execute events that should have been prevented.
|
|
322
|
+
*
|
|
323
|
+
* Additionally, this also lets us deal automatically with cancellations when a click event
|
|
324
|
+
* isn't raised because the page was considered scrolled/drag-scrolled, long-pressed, etc.
|
|
325
|
+
*
|
|
326
|
+
* This is why we also continuously remove the previous listener, because we cannot be
|
|
327
|
+
* certain that it was raised, and therefore cleaned-up.
|
|
328
|
+
*/
|
|
329
|
+
if (event.pointerType === 'touch') {
|
|
330
|
+
document.removeEventListener('click', handleClickRef.current);
|
|
331
|
+
handleClickRef.current = handleAndDispatchPointerDownOutsideEvent;
|
|
332
|
+
document.addEventListener('click', handleClickRef.current, { once: true });
|
|
333
|
+
}
|
|
334
|
+
else {
|
|
335
|
+
handleAndDispatchPointerDownOutsideEvent();
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
isPointerInsideReactTreeRef.current = false;
|
|
339
|
+
};
|
|
340
|
+
/**
|
|
341
|
+
* if this hook executes in a component that mounts via a `pointerdown` event, the event
|
|
342
|
+
* would bubble up to the document and trigger a `pointerDownOutside` event. We avoid
|
|
343
|
+
* this by delaying the event listener registration on the document.
|
|
344
|
+
* This is not React specific, but rather how the DOM works, ie:
|
|
345
|
+
* ```
|
|
346
|
+
* button.addEventListener('pointerdown', () => {
|
|
347
|
+
* console.log('I will log');
|
|
348
|
+
* document.addEventListener('pointerdown', () => {
|
|
349
|
+
* console.log('I will also log');
|
|
350
|
+
* })
|
|
351
|
+
* });
|
|
352
|
+
*/
|
|
353
|
+
const timerId = setTimeout(() => {
|
|
354
|
+
document.addEventListener('pointerdown', handlePointerDown);
|
|
355
|
+
}, 0);
|
|
356
|
+
return () => {
|
|
357
|
+
window.clearTimeout(timerId);
|
|
358
|
+
document.removeEventListener('pointerdown', handlePointerDown);
|
|
359
|
+
document.removeEventListener('click', handleClickRef.current);
|
|
360
|
+
};
|
|
361
|
+
}, [handlePointerDownOutside]);
|
|
362
|
+
return {
|
|
363
|
+
// ensures we check React component tree (not just DOM tree)
|
|
364
|
+
onPointerDownCapture: () => {
|
|
365
|
+
isPointerInsideReactTreeRef.current = true;
|
|
366
|
+
},
|
|
367
|
+
};
|
|
368
|
+
}
|
|
369
|
+
/**
|
|
370
|
+
* Listens for when focus happens outside a react subtree.
|
|
371
|
+
* Returns props to pass to the root (node) of the subtree we want to check.
|
|
372
|
+
*/
|
|
373
|
+
function useFocusOutside(onFocusOutside) {
|
|
374
|
+
const handleFocusOutside = (0, use_event_1.useEvent)(onFocusOutside);
|
|
375
|
+
const isFocusInsideReactTreeRef = React.useRef(false);
|
|
376
|
+
React.useEffect(() => {
|
|
377
|
+
const handleFocus = (event) => {
|
|
378
|
+
if (event.target && !isFocusInsideReactTreeRef.current) {
|
|
379
|
+
const eventDetail = { originalEvent: event };
|
|
380
|
+
handleAndDispatchCustomEvent(FOCUS_OUTSIDE, handleFocusOutside, eventDetail, {
|
|
381
|
+
discrete: false,
|
|
382
|
+
});
|
|
383
|
+
}
|
|
384
|
+
};
|
|
385
|
+
document.addEventListener('focusin', handleFocus);
|
|
386
|
+
return () => document.removeEventListener('focusin', handleFocus);
|
|
387
|
+
}, [handleFocusOutside]);
|
|
388
|
+
return {
|
|
389
|
+
onFocusCapture: () => {
|
|
390
|
+
isFocusInsideReactTreeRef.current = true;
|
|
391
|
+
},
|
|
392
|
+
onBlurCapture: () => {
|
|
393
|
+
isFocusInsideReactTreeRef.current = false;
|
|
394
|
+
},
|
|
395
|
+
};
|
|
396
|
+
}
|
|
397
|
+
function dispatchUpdate() {
|
|
398
|
+
const event = new CustomEvent(CONTEXT_UPDATE);
|
|
399
|
+
document.dispatchEvent(event);
|
|
400
|
+
}
|
|
401
|
+
function handleAndDispatchCustomEvent(name, handler, detail, { discrete }) {
|
|
402
|
+
const target = detail.originalEvent.target;
|
|
403
|
+
const event = new CustomEvent(name, { bubbles: false, cancelable: true, detail });
|
|
404
|
+
if (handler)
|
|
405
|
+
target.addEventListener(name, handler, { once: true });
|
|
406
|
+
if (discrete) {
|
|
407
|
+
dispatchDiscreteCustomEvent(target, event);
|
|
408
|
+
}
|
|
409
|
+
else {
|
|
410
|
+
target.dispatchEvent(event);
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
//# sourceMappingURL=Dismissable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Dismissable.js","sourceRoot":"","sources":["../../src/Dismissable.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,uBAAu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,MAAM,KAAK,GAAG,IAAI,WAAW,CAAC,cAAc,CAAC,CAAA;IAC7C,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAA;AAC/B,CAAC;AAED,SAAS,4BAA4B,CACnC,IAAY,EACZ,OAAyC,EACzC,MAAuF,EACvF,EAAE,QAAQ,EAAyB;IAEnC,MAAM,MAAM,GAAG,MAAM,CAAC,aAAa,CAAC,MAAM,CAAA;IAC1C,MAAM,KAAK,GAAG,IAAI,WAAW,CAAC,IAAI,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAA;IACjF,IAAI,OAAO;QAAE,MAAM,CAAC,gBAAgB,CAAC,IAAI,EAAE,OAAwB,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAA;IAEpF,IAAI,QAAQ,EAAE,CAAC;QACb,2BAA2B,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA;IAC5C,CAAC;SAAM,CAAC;QACN,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,CAAA;IAC7B,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DismissableProps.js","sourceRoot":"","sources":["../../src/DismissableProps.tsx"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,2DAAiC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{ "type": "commonjs" }
|