@epoch32/visage 1.3.2 → 1.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{index-vbsc8z8h.js → index-9700cg44.js} +20 -2
- package/dist/index.js +1 -1
- package/dist/ui/index.js +1 -1
- package/package.json +1 -1
- package/src/ui/overlay.ts +23 -3
|
@@ -575,7 +575,7 @@ function useDismiss2(element, options) {
|
|
|
575
575
|
}
|
|
576
576
|
};
|
|
577
577
|
if (typeof document !== "undefined") {
|
|
578
|
-
const
|
|
578
|
+
const unbindPointer = onClickOutside2(() => {
|
|
579
579
|
const el = element();
|
|
580
580
|
const rawIgnores = typeof options.outsideIgnore === "function" ? options.outsideIgnore() : options.outsideIgnore;
|
|
581
581
|
const ignores = Array.isArray(rawIgnores) ? rawIgnores : rawIgnores ? [rawIgnores] : [];
|
|
@@ -592,7 +592,25 @@ function useDismiss2(element, options) {
|
|
|
592
592
|
options.onDismiss();
|
|
593
593
|
}
|
|
594
594
|
});
|
|
595
|
-
|
|
595
|
+
const onGlobalKeyDown = (e) => {
|
|
596
|
+
if (!isEnabled() || e.defaultPrevented)
|
|
597
|
+
return;
|
|
598
|
+
if (e.key === "Escape" && (options.escapeKey ?? true)) {
|
|
599
|
+
if (options.onEscapeKeyDown) {
|
|
600
|
+
options.onEscapeKeyDown(e);
|
|
601
|
+
}
|
|
602
|
+
if (!e.defaultPrevented) {
|
|
603
|
+
options.onDismiss();
|
|
604
|
+
e.stopPropagation();
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
};
|
|
608
|
+
const targetWindow = typeof window !== "undefined" ? window : document;
|
|
609
|
+
targetWindow.addEventListener("keydown", onGlobalKeyDown);
|
|
610
|
+
onCleanup2(() => {
|
|
611
|
+
unbindPointer();
|
|
612
|
+
targetWindow.removeEventListener("keydown", onGlobalKeyDown);
|
|
613
|
+
});
|
|
596
614
|
}
|
|
597
615
|
return {
|
|
598
616
|
handleKeyDown,
|
package/dist/index.js
CHANGED
package/dist/ui/index.js
CHANGED
package/package.json
CHANGED
package/src/ui/overlay.ts
CHANGED
|
@@ -97,9 +97,9 @@ export function useDismiss(
|
|
|
97
97
|
}
|
|
98
98
|
};
|
|
99
99
|
|
|
100
|
-
// Setup outside pointer listener
|
|
100
|
+
// Setup outside pointer listener and global escape key listener
|
|
101
101
|
if (typeof document !== "undefined") {
|
|
102
|
-
const
|
|
102
|
+
const unbindPointer = onClickOutside(
|
|
103
103
|
() => {
|
|
104
104
|
const el = element();
|
|
105
105
|
const rawIgnores =
|
|
@@ -120,7 +120,27 @@ export function useDismiss(
|
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
122
|
);
|
|
123
|
-
|
|
123
|
+
|
|
124
|
+
const onGlobalKeyDown = (e: KeyboardEvent) => {
|
|
125
|
+
if (!isEnabled() || e.defaultPrevented) return;
|
|
126
|
+
if (e.key === "Escape" && (options.escapeKey ?? true)) {
|
|
127
|
+
if (options.onEscapeKeyDown) {
|
|
128
|
+
options.onEscapeKeyDown(e);
|
|
129
|
+
}
|
|
130
|
+
if (!e.defaultPrevented) {
|
|
131
|
+
options.onDismiss();
|
|
132
|
+
e.stopPropagation();
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
const targetWindow = typeof window !== "undefined" ? window : document;
|
|
138
|
+
targetWindow.addEventListener("keydown", onGlobalKeyDown as any);
|
|
139
|
+
|
|
140
|
+
onCleanup(() => {
|
|
141
|
+
unbindPointer();
|
|
142
|
+
targetWindow.removeEventListener("keydown", onGlobalKeyDown as any);
|
|
143
|
+
});
|
|
124
144
|
}
|
|
125
145
|
|
|
126
146
|
return {
|