@hanzogui/dismissable 3.0.2 → 7.0.0
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/package.json +12 -12
- package/src/Dismissable.tsx +3 -3
- package/types/Dismissable.d.ts +2 -2
- package/dist/cjs/Dismissable.cjs +0 -287
- package/dist/cjs/Dismissable.native.js +0 -65
- package/dist/cjs/Dismissable.native.js.map +0 -1
- package/dist/cjs/DismissableProps.cjs +0 -16
- package/dist/cjs/DismissableProps.native.js +0 -19
- package/dist/cjs/DismissableProps.native.js.map +0 -1
- package/dist/cjs/index.cjs +0 -18
- package/dist/cjs/index.native.js +0 -21
- package/dist/cjs/index.native.js.map +0 -1
- package/dist/esm/Dismissable.mjs +0 -246
- 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.js +0 -2
- package/dist/esm/index.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 -246
- package/dist/jsx/Dismissable.mjs.map +0 -1
- package/dist/jsx/Dismissable.native.js +0 -65
- 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 -19
- 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 -21
- package/dist/jsx/index.native.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hanzogui/dismissable",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"files": [
|
|
6
6
|
"src",
|
|
@@ -28,20 +28,20 @@
|
|
|
28
28
|
"access": "public"
|
|
29
29
|
},
|
|
30
30
|
"scripts": {
|
|
31
|
-
"build": "
|
|
32
|
-
"watch": "
|
|
33
|
-
"clean": "
|
|
34
|
-
"clean:build": "
|
|
31
|
+
"build": "hanzogui-build",
|
|
32
|
+
"watch": "hanzogui-build --watch",
|
|
33
|
+
"clean": "hanzogui-build clean",
|
|
34
|
+
"clean:build": "hanzogui-build clean:build"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@hanzogui/compose-refs": "
|
|
38
|
-
"@hanzogui/core": "
|
|
39
|
-
"@hanzogui/helpers": "
|
|
40
|
-
"@hanzogui/use-escape-keydown": "
|
|
41
|
-
"@hanzogui/use-event": "
|
|
37
|
+
"@hanzogui/compose-refs": "^7.0.0",
|
|
38
|
+
"@hanzogui/core": "^7.0.0",
|
|
39
|
+
"@hanzogui/helpers": "^7.0.0",
|
|
40
|
+
"@hanzogui/use-escape-keydown": "^7.0.0",
|
|
41
|
+
"@hanzogui/use-event": "^7.0.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@hanzogui/build": "
|
|
44
|
+
"@hanzogui/build": "^7.0.0",
|
|
45
45
|
"react": ">=19",
|
|
46
46
|
"react-dom": "*"
|
|
47
47
|
},
|
|
@@ -50,4 +50,4 @@
|
|
|
50
50
|
"react-dom": "*"
|
|
51
51
|
},
|
|
52
52
|
"module:jsx": "dist/jsx"
|
|
53
|
-
}
|
|
53
|
+
}
|
package/src/Dismissable.tsx
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// https://github.com/radix-ui/primitives/blob/cfd8dcba5fa6a0e751486af418d05a7b88a7f541/packages/react/dismissable-layer/src/DismissableLayer.tsx#L324
|
|
3
3
|
|
|
4
4
|
import { useComposedRefs } from '@hanzogui/compose-refs'
|
|
5
|
-
import { Slot,
|
|
5
|
+
import { Slot, HanzoguiElement, View, composeEventHandlers } from '@hanzogui/core'
|
|
6
6
|
import { useEscapeKeydown } from '@hanzogui/use-escape-keydown'
|
|
7
7
|
import { useEvent } from '@hanzogui/use-event'
|
|
8
8
|
import * as React from 'react'
|
|
@@ -339,11 +339,11 @@ Dismissable.displayName = DISMISSABLE_LAYER_NAME
|
|
|
339
339
|
|
|
340
340
|
const BRANCH_NAME = 'DismissableBranch'
|
|
341
341
|
|
|
342
|
-
const DismissableBranch = React.forwardRef<
|
|
342
|
+
const DismissableBranch = React.forwardRef<HanzoguiElement, DismissableBranchProps>(
|
|
343
343
|
(props, forwardedRef) => {
|
|
344
344
|
const { branches: branchesProp, ...rest } = props
|
|
345
345
|
const context = React.useContext(DismissableContext)
|
|
346
|
-
const ref = React.useRef<
|
|
346
|
+
const ref = React.useRef<HanzoguiElement>(null)
|
|
347
347
|
const composedRefs = useComposedRefs(forwardedRef, ref)
|
|
348
348
|
|
|
349
349
|
React.useEffect(() => {
|
package/types/Dismissable.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { HanzoguiElement } from '@hanzogui/core';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import type { DismissableBranchProps, DismissableProps } from './DismissableProps';
|
|
4
4
|
export declare function dispatchDiscreteCustomEvent<E extends CustomEvent>(target: E['target'], event: E): void;
|
|
@@ -30,7 +30,7 @@ export declare function useDismissableLayersAbove(ref: React.RefObject<HTMLEleme
|
|
|
30
30
|
declare const Dismissable: React.ForwardRefExoticComponent<DismissableProps & {
|
|
31
31
|
asChild?: boolean;
|
|
32
32
|
} & React.RefAttributes<HTMLElement>>;
|
|
33
|
-
declare const DismissableBranch: React.ForwardRefExoticComponent<DismissableBranchProps & React.RefAttributes<
|
|
33
|
+
declare const DismissableBranch: React.ForwardRefExoticComponent<DismissableBranchProps & React.RefAttributes<HanzoguiElement>>;
|
|
34
34
|
export type PointerDownOutsideEvent = CustomEvent<{
|
|
35
35
|
originalEvent: PointerEvent;
|
|
36
36
|
}>;
|
package/dist/cjs/Dismissable.cjs
DELETED
|
@@ -1,287 +0,0 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf,
|
|
6
|
-
__hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all) __defProp(target, name, {
|
|
9
|
-
get: all[name],
|
|
10
|
-
enumerable: !0
|
|
11
|
-
});
|
|
12
|
-
},
|
|
13
|
-
__copyProps = (to, from, except, desc) => {
|
|
14
|
-
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
|
15
|
-
get: () => from[key],
|
|
16
|
-
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", {
|
|
26
|
-
value: mod,
|
|
27
|
-
enumerable: !0
|
|
28
|
-
}) : target, mod)),
|
|
29
|
-
__toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
30
|
-
value: !0
|
|
31
|
-
}), mod);
|
|
32
|
-
var Dismissable_exports = {};
|
|
33
|
-
__export(Dismissable_exports, {
|
|
34
|
-
Dismissable: () => Dismissable,
|
|
35
|
-
DismissableBranch: () => DismissableBranch,
|
|
36
|
-
debugDismissableLayers: () => debugDismissableLayers,
|
|
37
|
-
dispatchDiscreteCustomEvent: () => dispatchDiscreteCustomEvent,
|
|
38
|
-
getDismissableLayerCount: () => getDismissableLayerCount,
|
|
39
|
-
useDismissableLayersAbove: () => useDismissableLayersAbove,
|
|
40
|
-
useHasDismissableLayers: () => useHasDismissableLayers,
|
|
41
|
-
useIsInsideDismissable: () => useIsInsideDismissable
|
|
42
|
-
});
|
|
43
|
-
module.exports = __toCommonJS(Dismissable_exports);
|
|
44
|
-
var import_gui_compose_refs = require("@hanzogui/compose-refs"),
|
|
45
|
-
import_gui_core = require("@hanzogui/core"),
|
|
46
|
-
import_gui_use_escape_keydown = require("@hanzogui/use-escape-keydown"),
|
|
47
|
-
import_gui_use_event = require("@hanzogui/use-event"),
|
|
48
|
-
React = __toESM(require("react"), 1),
|
|
49
|
-
ReactDOM = __toESM(require("react-dom"), 1),
|
|
50
|
-
import_jsx_runtime = require("react/jsx-runtime");
|
|
51
|
-
function dispatchDiscreteCustomEvent(target, event) {
|
|
52
|
-
target && ReactDOM.flushSync(() => target.dispatchEvent(event));
|
|
53
|
-
}
|
|
54
|
-
const DISMISSABLE_LAYER_NAME = "Dismissable",
|
|
55
|
-
CONTEXT_UPDATE = "dismissable.update",
|
|
56
|
-
POINTER_DOWN_OUTSIDE = "dismissable.pointerDownOutside",
|
|
57
|
-
FOCUS_OUTSIDE = "dismissable.focusOutside";
|
|
58
|
-
let originalBodyPointerEvents;
|
|
59
|
-
const globalLayers = /* @__PURE__ */new Set(),
|
|
60
|
-
layerChangeListeners = /* @__PURE__ */new Set();
|
|
61
|
-
let layersWithPointerEventsDisabledCount = 0;
|
|
62
|
-
function notifyLayerChange() {
|
|
63
|
-
for (const listener of layerChangeListeners) listener();
|
|
64
|
-
}
|
|
65
|
-
function getDismissableLayerCount() {
|
|
66
|
-
return globalLayers.size;
|
|
67
|
-
}
|
|
68
|
-
function debugDismissableLayers() {
|
|
69
|
-
const layers = Array.from(globalLayers);
|
|
70
|
-
return console.log("[Dismissable] Active layers:", layers.length, layers), layers;
|
|
71
|
-
}
|
|
72
|
-
function useHasDismissableLayers() {
|
|
73
|
-
const [count, setCount] = React.useState(() => globalLayers.size);
|
|
74
|
-
return React.useEffect(() => {
|
|
75
|
-
setCount(globalLayers.size);
|
|
76
|
-
const update = () => setCount(globalLayers.size);
|
|
77
|
-
return layerChangeListeners.add(update), () => {
|
|
78
|
-
layerChangeListeners.delete(update);
|
|
79
|
-
};
|
|
80
|
-
}, []), count > 0;
|
|
81
|
-
}
|
|
82
|
-
const DismissableContext = React.createContext({
|
|
83
|
-
layers: /* @__PURE__ */new Set(),
|
|
84
|
-
layersWithOutsidePointerEventsDisabled: /* @__PURE__ */new Set(),
|
|
85
|
-
branches: /* @__PURE__ */new Set()
|
|
86
|
-
});
|
|
87
|
-
function useIsInsideDismissable(ref) {
|
|
88
|
-
const context = React.useContext(DismissableContext),
|
|
89
|
-
[isInside, setIsInside] = React.useState(!1);
|
|
90
|
-
return React.useEffect(() => {
|
|
91
|
-
const check = () => {
|
|
92
|
-
const el = ref.current;
|
|
93
|
-
if (!el) {
|
|
94
|
-
setIsInside(!1);
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
for (const layer of context.layers) if (layer.contains(el)) {
|
|
98
|
-
setIsInside(!0);
|
|
99
|
-
return;
|
|
100
|
-
}
|
|
101
|
-
setIsInside(!1);
|
|
102
|
-
};
|
|
103
|
-
return check(), document.addEventListener(CONTEXT_UPDATE, check), () => document.removeEventListener(CONTEXT_UPDATE, check);
|
|
104
|
-
}, [context.layers, ref]), isInside;
|
|
105
|
-
}
|
|
106
|
-
function useDismissableLayersAbove(ref) {
|
|
107
|
-
const context = React.useContext(DismissableContext),
|
|
108
|
-
[count, setCount] = React.useState(0);
|
|
109
|
-
return React.useEffect(() => {
|
|
110
|
-
const check = () => {
|
|
111
|
-
const el = ref.current;
|
|
112
|
-
if (!el) {
|
|
113
|
-
setCount(0);
|
|
114
|
-
return;
|
|
115
|
-
}
|
|
116
|
-
let above = 0;
|
|
117
|
-
for (const layer of context.layers) layer.contains(el) && above++;
|
|
118
|
-
setCount(above);
|
|
119
|
-
};
|
|
120
|
-
return check(), document.addEventListener(CONTEXT_UPDATE, check), () => document.removeEventListener(CONTEXT_UPDATE, check);
|
|
121
|
-
}, [context.layers, ref]), count;
|
|
122
|
-
}
|
|
123
|
-
const Dismissable = React.forwardRef((props, forwardedRef) => {
|
|
124
|
-
const {
|
|
125
|
-
disableOutsidePointerEvents = !1,
|
|
126
|
-
forceUnmount,
|
|
127
|
-
onEscapeKeyDown,
|
|
128
|
-
onPointerDownOutside,
|
|
129
|
-
onFocusOutside,
|
|
130
|
-
onInteractOutside,
|
|
131
|
-
onDismiss,
|
|
132
|
-
asChild,
|
|
133
|
-
children,
|
|
134
|
-
branches: branchesProp,
|
|
135
|
-
...layerProps
|
|
136
|
-
} = props,
|
|
137
|
-
Comp = asChild ? import_gui_core.Slot : import_gui_core.View,
|
|
138
|
-
context = React.useContext(DismissableContext),
|
|
139
|
-
[node, setNode] = React.useState(null),
|
|
140
|
-
[, force] = React.useState({}),
|
|
141
|
-
composedRefs = (0, import_gui_compose_refs.useComposedRefs)(forwardedRef, node2 => setNode(node2)),
|
|
142
|
-
layers = Array.from(context.layers),
|
|
143
|
-
[highestLayerWithOutsidePointerEventsDisabled] = [...context.layersWithOutsidePointerEventsDisabled].slice(-1),
|
|
144
|
-
highestLayerWithOutsidePointerEventsDisabledIndex = layers.indexOf(highestLayerWithOutsidePointerEventsDisabled),
|
|
145
|
-
index = node ? layers.indexOf(node) : -1,
|
|
146
|
-
isBodyPointerEventsDisabled = context.layersWithOutsidePointerEventsDisabled.size > 0,
|
|
147
|
-
isPointerEventsEnabled = index >= highestLayerWithOutsidePointerEventsDisabledIndex,
|
|
148
|
-
pointerDownOutside = usePointerDownOutside(event => {
|
|
149
|
-
const target = event.target,
|
|
150
|
-
isPointerDownOnBranch = [...(branchesProp || context.branches)].some(branch => branch.contains(target));
|
|
151
|
-
!isPointerEventsEnabled || isPointerDownOnBranch || (onPointerDownOutside?.(event), onInteractOutside?.(event), event.defaultPrevented || onDismiss?.());
|
|
152
|
-
}),
|
|
153
|
-
focusOutside = useFocusOutside(event => {
|
|
154
|
-
const target = event.target;
|
|
155
|
-
[...(branchesProp || context.branches)].some(branch => branch.contains(target)) || (onFocusOutside?.(event), onInteractOutside?.(event), event.defaultPrevented || onDismiss?.());
|
|
156
|
-
}),
|
|
157
|
-
forceUnmountRef = React.useRef(forceUnmount);
|
|
158
|
-
return React.useEffect(() => {
|
|
159
|
-
forceUnmountRef.current = forceUnmount;
|
|
160
|
-
}, [forceUnmount]), (0, import_gui_use_escape_keydown.useEscapeKeydown)(event => {
|
|
161
|
-
if (forceUnmountRef.current) return;
|
|
162
|
-
const currentLayers = Array.from(context.layers);
|
|
163
|
-
(node ? currentLayers.indexOf(node) : -1) === currentLayers.length - 1 && (onEscapeKeyDown?.(event), !event.defaultPrevented && onDismiss && (event.preventDefault(), onDismiss()));
|
|
164
|
-
}), React.useEffect(() => {
|
|
165
|
-
if (node && !forceUnmount) return disableOutsidePointerEvents && (context.layersWithOutsidePointerEventsDisabled.size === 0 && (originalBodyPointerEvents = document.body.style.pointerEvents, document.body.style.pointerEvents = "none"), context.layersWithOutsidePointerEventsDisabled.add(node), layersWithPointerEventsDisabledCount++), context.layers.add(node), globalLayers.add(node), (disableOutsidePointerEvents || layersWithPointerEventsDisabledCount > 0) && dispatchUpdate(), notifyLayerChange(), () => {
|
|
166
|
-
disableOutsidePointerEvents && context.layersWithOutsidePointerEventsDisabled.size === 1 && (document.body.style.pointerEvents = originalBodyPointerEvents);
|
|
167
|
-
};
|
|
168
|
-
}, [node, disableOutsidePointerEvents, forceUnmount, context]), React.useEffect(() => {
|
|
169
|
-
if (!forceUnmount) return () => {
|
|
170
|
-
if (!node) return;
|
|
171
|
-
const hadPointerEventsDisabled = context.layersWithOutsidePointerEventsDisabled.has(node);
|
|
172
|
-
context.layers.delete(node), context.layersWithOutsidePointerEventsDisabled.delete(node), globalLayers.delete(node), layersWithPointerEventsDisabledCount > 0 && dispatchUpdate(), notifyLayerChange(), hadPointerEventsDisabled && layersWithPointerEventsDisabledCount--;
|
|
173
|
-
};
|
|
174
|
-
}, [node, context, forceUnmount]), React.useEffect(() => {
|
|
175
|
-
const handleUpdate = () => {
|
|
176
|
-
layersWithPointerEventsDisabledCount > 0 && force({});
|
|
177
|
-
};
|
|
178
|
-
return document.addEventListener(CONTEXT_UPDATE, handleUpdate), () => document.removeEventListener(CONTEXT_UPDATE, handleUpdate);
|
|
179
|
-
}, []), /* @__PURE__ */(0, import_jsx_runtime.jsx)(Comp, {
|
|
180
|
-
...layerProps,
|
|
181
|
-
ref: composedRefs,
|
|
182
|
-
...(!asChild && {
|
|
183
|
-
display: "contents"
|
|
184
|
-
}),
|
|
185
|
-
pointerEvents: isBodyPointerEventsDisabled ? isPointerEventsEnabled ? "auto" : "none" : void 0,
|
|
186
|
-
onFocusCapture: (0, import_gui_core.composeEventHandlers)(props.onFocusCapture, focusOutside.onFocusCapture),
|
|
187
|
-
onBlurCapture: (0, import_gui_core.composeEventHandlers)(props.onBlurCapture, focusOutside.onBlurCapture),
|
|
188
|
-
onPointerDownCapture: (0, import_gui_core.composeEventHandlers)(props.onPointerDownCapture, pointerDownOutside.onPointerDownCapture),
|
|
189
|
-
children
|
|
190
|
-
});
|
|
191
|
-
});
|
|
192
|
-
Dismissable.displayName = DISMISSABLE_LAYER_NAME;
|
|
193
|
-
const BRANCH_NAME = "DismissableBranch",
|
|
194
|
-
DismissableBranch = React.forwardRef((props, forwardedRef) => {
|
|
195
|
-
const {
|
|
196
|
-
branches: branchesProp,
|
|
197
|
-
...rest
|
|
198
|
-
} = props,
|
|
199
|
-
context = React.useContext(DismissableContext),
|
|
200
|
-
ref = React.useRef(null),
|
|
201
|
-
composedRefs = (0, import_gui_compose_refs.useComposedRefs)(forwardedRef, ref);
|
|
202
|
-
return React.useEffect(() => {
|
|
203
|
-
const node = ref.current;
|
|
204
|
-
if (!(node instanceof HTMLElement)) return;
|
|
205
|
-
const branches = branchesProp || context.branches;
|
|
206
|
-
if (node && branches) return branches.add(node), () => {
|
|
207
|
-
branches.delete(node);
|
|
208
|
-
};
|
|
209
|
-
}, [branchesProp, context.branches]), /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_gui_core.View, {
|
|
210
|
-
asChild: "except-style",
|
|
211
|
-
...rest,
|
|
212
|
-
ref: composedRefs
|
|
213
|
-
});
|
|
214
|
-
});
|
|
215
|
-
DismissableBranch.displayName = BRANCH_NAME;
|
|
216
|
-
function usePointerDownOutside(onPointerDownOutside) {
|
|
217
|
-
const handlePointerDownOutside = (0, import_gui_use_event.useEvent)(onPointerDownOutside),
|
|
218
|
-
isPointerInsideReactTreeRef = React.useRef(!1),
|
|
219
|
-
handleClickRef = React.useRef(() => {});
|
|
220
|
-
return React.useEffect(() => {
|
|
221
|
-
const handlePointerDown = event => {
|
|
222
|
-
if (event.target && !isPointerInsideReactTreeRef.current) {
|
|
223
|
-
let handleAndDispatchPointerDownOutsideEvent = function () {
|
|
224
|
-
handleAndDispatchCustomEvent(POINTER_DOWN_OUTSIDE, handlePointerDownOutside, eventDetail, {
|
|
225
|
-
discrete: !0
|
|
226
|
-
});
|
|
227
|
-
};
|
|
228
|
-
const eventDetail = {
|
|
229
|
-
originalEvent: event
|
|
230
|
-
};
|
|
231
|
-
event.pointerType === "touch" ? (document.removeEventListener("click", handleClickRef.current), handleClickRef.current = handleAndDispatchPointerDownOutsideEvent, document.addEventListener("click", handleClickRef.current, {
|
|
232
|
-
once: !0
|
|
233
|
-
})) : handleAndDispatchPointerDownOutsideEvent();
|
|
234
|
-
}
|
|
235
|
-
isPointerInsideReactTreeRef.current = !1;
|
|
236
|
-
},
|
|
237
|
-
timerId = setTimeout(() => {
|
|
238
|
-
document.addEventListener("pointerdown", handlePointerDown);
|
|
239
|
-
}, 0);
|
|
240
|
-
return () => {
|
|
241
|
-
window.clearTimeout(timerId), document.removeEventListener("pointerdown", handlePointerDown), document.removeEventListener("click", handleClickRef.current);
|
|
242
|
-
};
|
|
243
|
-
}, [handlePointerDownOutside]), {
|
|
244
|
-
// ensures we check React component tree (not just DOM tree)
|
|
245
|
-
onPointerDownCapture: () => {
|
|
246
|
-
isPointerInsideReactTreeRef.current = !0;
|
|
247
|
-
}
|
|
248
|
-
};
|
|
249
|
-
}
|
|
250
|
-
function useFocusOutside(onFocusOutside) {
|
|
251
|
-
const handleFocusOutside = (0, import_gui_use_event.useEvent)(onFocusOutside),
|
|
252
|
-
isFocusInsideReactTreeRef = React.useRef(!1);
|
|
253
|
-
return React.useEffect(() => {
|
|
254
|
-
const handleFocus = event => {
|
|
255
|
-
event.target && !isFocusInsideReactTreeRef.current && handleAndDispatchCustomEvent(FOCUS_OUTSIDE, handleFocusOutside, {
|
|
256
|
-
originalEvent: event
|
|
257
|
-
}, {
|
|
258
|
-
discrete: !1
|
|
259
|
-
});
|
|
260
|
-
};
|
|
261
|
-
return document.addEventListener("focusin", handleFocus), () => document.removeEventListener("focusin", handleFocus);
|
|
262
|
-
}, [handleFocusOutside]), {
|
|
263
|
-
onFocusCapture: () => {
|
|
264
|
-
isFocusInsideReactTreeRef.current = !0;
|
|
265
|
-
},
|
|
266
|
-
onBlurCapture: () => {
|
|
267
|
-
isFocusInsideReactTreeRef.current = !1;
|
|
268
|
-
}
|
|
269
|
-
};
|
|
270
|
-
}
|
|
271
|
-
function dispatchUpdate() {
|
|
272
|
-
const event = new CustomEvent(CONTEXT_UPDATE);
|
|
273
|
-
document.dispatchEvent(event);
|
|
274
|
-
}
|
|
275
|
-
function handleAndDispatchCustomEvent(name, handler, detail, {
|
|
276
|
-
discrete
|
|
277
|
-
}) {
|
|
278
|
-
const target = detail.originalEvent.target,
|
|
279
|
-
event = new CustomEvent(name, {
|
|
280
|
-
bubbles: !1,
|
|
281
|
-
cancelable: !0,
|
|
282
|
-
detail
|
|
283
|
-
});
|
|
284
|
-
handler && target.addEventListener(name, handler, {
|
|
285
|
-
once: !0
|
|
286
|
-
}), discrete ? dispatchDiscreteCustomEvent(target, event) : target.dispatchEvent(event);
|
|
287
|
-
}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
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
|
-
__hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
-
var __export = (target, all) => {
|
|
10
|
-
for (var name in all) __defProp(target, name, {
|
|
11
|
-
get: all[name],
|
|
12
|
-
enumerable: !0
|
|
13
|
-
});
|
|
14
|
-
},
|
|
15
|
-
__copyProps = (to, from, except, desc) => {
|
|
16
|
-
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
|
17
|
-
get: () => from[key],
|
|
18
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
-
});
|
|
20
|
-
return to;
|
|
21
|
-
};
|
|
22
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
23
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
24
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
25
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
26
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
27
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
28
|
-
value: mod,
|
|
29
|
-
enumerable: !0
|
|
30
|
-
}) : target, mod)),
|
|
31
|
-
__toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
32
|
-
value: !0
|
|
33
|
-
}), mod);
|
|
34
|
-
var Dismissable_native_exports = {};
|
|
35
|
-
__export(Dismissable_native_exports, {
|
|
36
|
-
Dismissable: () => Dismissable,
|
|
37
|
-
DismissableBranch: () => DismissableBranch,
|
|
38
|
-
dispatchDiscreteCustomEvent: () => dispatchDiscreteCustomEvent,
|
|
39
|
-
getDismissableLayerCount: () => getDismissableLayerCount,
|
|
40
|
-
useDismissableLayersAbove: () => useDismissableLayersAbove,
|
|
41
|
-
useHasDismissableLayers: () => useHasDismissableLayers,
|
|
42
|
-
useIsInsideDismissable: () => useIsInsideDismissable
|
|
43
|
-
});
|
|
44
|
-
module.exports = __toCommonJS(Dismissable_native_exports);
|
|
45
|
-
var import_react = __toESM(require("react"), 1);
|
|
46
|
-
function dispatchDiscreteCustomEvent(_target, _event) {}
|
|
47
|
-
function getDismissableLayerCount() {
|
|
48
|
-
return 0;
|
|
49
|
-
}
|
|
50
|
-
function useHasDismissableLayers() {
|
|
51
|
-
return !1;
|
|
52
|
-
}
|
|
53
|
-
function useIsInsideDismissable(_ref) {
|
|
54
|
-
return !1;
|
|
55
|
-
}
|
|
56
|
-
function useDismissableLayersAbove(_ref) {
|
|
57
|
-
return 0;
|
|
58
|
-
}
|
|
59
|
-
var Dismissable = /* @__PURE__ */import_react.default.forwardRef(function (props, _ref) {
|
|
60
|
-
return props.children;
|
|
61
|
-
}),
|
|
62
|
-
DismissableBranch = /* @__PURE__ */import_react.default.forwardRef(function (props, _ref) {
|
|
63
|
-
return props.children;
|
|
64
|
-
});
|
|
65
|
-
//# sourceMappingURL=Dismissable.native.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["Dismissable_native_exports","__export","Dismissable","DismissableBranch","dispatchDiscreteCustomEvent","getDismissableLayerCount","useDismissableLayersAbove","useHasDismissableLayers","useIsInsideDismissable","module","exports","__toCommonJS","import_react","__toESM","require","_target","_event","_ref","default","forwardRef","props","children"],"sources":["../../src/Dismissable.native.tsx"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,0BAAA;AAAAC,QAAA,CAAAD,0BAAA;EAAAE,WAAA,EAAAA,CAAA,KAAAA,WAAA;EAAAC,iBAAA,EAAAA,CAAA,KAAAA,iBAAA;EAAAC,2BAAA,EAAAA,CAAA,KAAAA,2BAAA;EAAAC,wBAAA,EAAAA,CAAA,KAAAA,wBAAA;EAAAC,yBAAA,EAAAA,CAAA,KAAAA,yBAAA;EAAAC,uBAAA,EAAAA,CAAA,KAAAA,uBAAA;EAAAC,sBAAA,EAAAA,CAAA,KAAAA;AAAA;AAAAC,MAAA,CAAAC,OAAA,GAAAC,YAAA,CAAAX,0BAAA;AAAA,IAAAY,YAAA,GAAkBC,OAAA,CAAAC,OAAA;AAEX,SAASV,4BAA4BW,OAAA,EAASC,MAAA,EAAQ,CAAC;AACvD,SAASX,yBAAA,EAA2B;EACvC,OAAO;AACX;AACO,SAASE,wBAAA,EAA0B;EACtC,OAAO;AACX;AACO,SAASC,uBAAuBS,IAAA,EAAM;EACzC,OAAO;AACX;AACO,SAASX,0BAA0BW,IAAA,EAAM;EAC5C,OAAO;AACX;AACO,IAAIf,WAAA,GAA4B,eAAAU,YAAA,CAAAM,OAAA,CAAMC,UAAA,CAAW,UAASC,KAAA,EAAOH,IAAA,EAAM;IAC1E,OAAOG,KAAA,CAAMC,QAAA;EACjB,CAAC;EACUlB,iBAAA,GAAkC,eAAAS,YAAA,CAAAM,OAAA,CAAMC,UAAA,CAAW,UAASC,KAAA,EAAOH,IAAA,EAAM;IAChF,OAAOG,KAAA,CAAMC,QAAA;EACjB,CAAC","ignoreList":[]}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __copyProps = (to, from, except, desc) => {
|
|
6
|
-
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
|
7
|
-
get: () => from[key],
|
|
8
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
9
|
-
});
|
|
10
|
-
return to;
|
|
11
|
-
};
|
|
12
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
13
|
-
value: !0
|
|
14
|
-
}), mod);
|
|
15
|
-
var DismissableProps_exports = {};
|
|
16
|
-
module.exports = __toCommonJS(DismissableProps_exports);
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __copyProps = (to, from, except, desc) => {
|
|
8
|
-
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
|
9
|
-
get: () => from[key],
|
|
10
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
11
|
-
});
|
|
12
|
-
return to;
|
|
13
|
-
};
|
|
14
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
15
|
-
value: !0
|
|
16
|
-
}), mod);
|
|
17
|
-
var DismissableProps_exports = {};
|
|
18
|
-
module.exports = __toCommonJS(DismissableProps_exports);
|
|
19
|
-
//# sourceMappingURL=DismissableProps.native.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["__defProp","Object","defineProperty","__getOwnPropDesc","getOwnPropertyDescriptor","__getOwnPropNames","getOwnPropertyNames","__hasOwnProp","prototype","hasOwnProperty","__copyProps","to","from","except","desc","key","call","get","enumerable","__toCommonJS","mod","value","DismissableProps_exports","module","exports"],"sources":["DismissableProps.native.js"],"sourcesContent":["\"use strict\";\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from == \"object\" || typeof from == \"function\")\n for (let key of __getOwnPropNames(from))\n !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n return to;\n};\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: !0 }), mod);\nvar DismissableProps_exports = {};\nmodule.exports = __toCommonJS(DismissableProps_exports);\n//# sourceMappingURL=DismissableProps.js.map\n"],"mappings":"AAAA,YAAY;;AACZ,IAAIA,SAAS,GAAGC,MAAM,CAACC,cAAc;AACrC,IAAIC,gBAAgB,GAAGF,MAAM,CAACG,wBAAwB;AACtD,IAAIC,iBAAiB,GAAGJ,MAAM,CAACK,mBAAmB;AAClD,IAAIC,YAAY,GAAGN,MAAM,CAACO,SAAS,CAACC,cAAc;AAClD,IAAIC,WAAW,GAAGA,CAACC,EAAE,EAAEC,IAAI,EAAEC,MAAM,EAAEC,IAAI,KAAK;EAC5C,IAAIF,IAAI,IAAI,OAAOA,IAAI,IAAI,QAAQ,IAAI,OAAOA,IAAI,IAAI,UAAU,EAC9D,KAAK,IAAIG,GAAG,IAAIV,iBAAiB,CAACO,IAAI,CAAC,EACrC,CAACL,YAAY,CAACS,IAAI,CAACL,EAAE,EAAEI,GAAG,CAAC,IAAIA,GAAG,KAAKF,MAAM,IAAIb,SAAS,CAACW,EAAE,EAAEI,GAAG,EAAE;IAAEE,GAAG,EAAEA,CAAA,KAAML,IAAI,CAACG,GAAG,CAAC;IAAEG,UAAU,EAAE,EAAEJ,IAAI,GAAGX,gBAAgB,CAACS,IAAI,EAAEG,GAAG,CAAC,CAAC,IAAID,IAAI,CAACI;EAAW,CAAC,CAAC;EACvK,OAAOP,EAAE;AACX,CAAC;AACD,IAAIQ,YAAY,GAAIC,GAAG,IAAKV,WAAW,CAACV,SAAS,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE;EAAEqB,KAAK,EAAE,CAAC;AAAE,CAAC,CAAC,EAAED,GAAG,CAAC;AACxF,IAAIE,wBAAwB,GAAG,CAAC,CAAC;AACjCC,MAAM,CAACC,OAAO,GAAGL,YAAY,CAACG,wBAAwB,CAAC","ignoreList":[]}
|
package/dist/cjs/index.cjs
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __copyProps = (to, from, except, desc) => {
|
|
6
|
-
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
|
7
|
-
get: () => from[key],
|
|
8
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
9
|
-
});
|
|
10
|
-
return to;
|
|
11
|
-
},
|
|
12
|
-
__reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
13
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
14
|
-
value: !0
|
|
15
|
-
}), mod);
|
|
16
|
-
var index_exports = {};
|
|
17
|
-
module.exports = __toCommonJS(index_exports);
|
|
18
|
-
__reExport(index_exports, require("./Dismissable.cjs"), module.exports);
|
package/dist/cjs/index.native.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __copyProps = (to, from, except, desc) => {
|
|
8
|
-
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
|
9
|
-
get: () => from[key],
|
|
10
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
11
|
-
});
|
|
12
|
-
return to;
|
|
13
|
-
},
|
|
14
|
-
__reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
16
|
-
value: !0
|
|
17
|
-
}), mod);
|
|
18
|
-
var index_exports = {};
|
|
19
|
-
module.exports = __toCommonJS(index_exports);
|
|
20
|
-
__reExport(index_exports, require("./Dismissable"), module.exports);
|
|
21
|
-
//# sourceMappingURL=index.native.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["__defProp","Object","defineProperty","__getOwnPropDesc","getOwnPropertyDescriptor","__getOwnPropNames","getOwnPropertyNames","__hasOwnProp","prototype","hasOwnProperty","__copyProps","to","from","except","desc","key","call","get","enumerable","__reExport","target","mod","secondTarget","__toCommonJS","value","index_exports","module","exports","require"],"sources":["index.native.js"],"sourcesContent":["\"use strict\";\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from == \"object\" || typeof from == \"function\")\n for (let key of __getOwnPropNames(from))\n !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n return to;\n}, __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, \"default\"), secondTarget && __copyProps(secondTarget, mod, \"default\"));\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: !0 }), mod);\nvar index_exports = {};\nmodule.exports = __toCommonJS(index_exports);\n__reExport(index_exports, require(\"./Dismissable\"), module.exports);\n//# sourceMappingURL=index.js.map\n"],"mappings":"AAAA,YAAY;;AACZ,IAAIA,SAAS,GAAGC,MAAM,CAACC,cAAc;AACrC,IAAIC,gBAAgB,GAAGF,MAAM,CAACG,wBAAwB;AACtD,IAAIC,iBAAiB,GAAGJ,MAAM,CAACK,mBAAmB;AAClD,IAAIC,YAAY,GAAGN,MAAM,CAACO,SAAS,CAACC,cAAc;AAClD,IAAIC,WAAW,GAAGA,CAACC,EAAE,EAAEC,IAAI,EAAEC,MAAM,EAAEC,IAAI,KAAK;IAC5C,IAAIF,IAAI,IAAI,OAAOA,IAAI,IAAI,QAAQ,IAAI,OAAOA,IAAI,IAAI,UAAU,EAC9D,KAAK,IAAIG,GAAG,IAAIV,iBAAiB,CAACO,IAAI,CAAC,EACrC,CAACL,YAAY,CAACS,IAAI,CAACL,EAAE,EAAEI,GAAG,CAAC,IAAIA,GAAG,KAAKF,MAAM,IAAIb,SAAS,CAACW,EAAE,EAAEI,GAAG,EAAE;MAAEE,GAAG,EAAEA,CAAA,KAAML,IAAI,CAACG,GAAG,CAAC;MAAEG,UAAU,EAAE,EAAEJ,IAAI,GAAGX,gBAAgB,CAACS,IAAI,EAAEG,GAAG,CAAC,CAAC,IAAID,IAAI,CAACI;IAAW,CAAC,CAAC;IACvK,OAAOP,EAAE;EACX,CAAC;EAAEQ,UAAU,GAAGA,CAACC,MAAM,EAAEC,GAAG,EAAEC,YAAY,MAAMZ,WAAW,CAACU,MAAM,EAAEC,GAAG,EAAE,SAAS,CAAC,EAAEC,YAAY,IAAIZ,WAAW,CAACY,YAAY,EAAED,GAAG,EAAE,SAAS,CAAC,CAAC;AAC/I,IAAIE,YAAY,GAAIF,GAAG,IAAKX,WAAW,CAACV,SAAS,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE;EAAEwB,KAAK,EAAE,CAAC;AAAE,CAAC,CAAC,EAAEH,GAAG,CAAC;AACxF,IAAII,aAAa,GAAG,CAAC,CAAC;AACtBC,MAAM,CAACC,OAAO,GAAGJ,YAAY,CAACE,aAAa,CAAC;AAC5CN,UAAU,CAACM,aAAa,EAAEG,OAAO,CAAC,eAAe,CAAC,EAAEF,MAAM,CAACC,OAAO,CAAC","ignoreList":[]}
|