@t007/utils 0.0.30 → 0.0.31
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/{chunk-YDARUYLO.js → chunk-LBDWVTYF.js} +8 -7
- package/dist/hooks/react.cjs +9 -8
- package/dist/hooks/react.d.cts +1 -1
- package/dist/hooks/react.d.ts +1 -1
- package/dist/hooks/react.js +2 -2
- package/dist/hooks/vanilla.cjs +8 -7
- package/dist/hooks/vanilla.d.cts +1 -1
- package/dist/hooks/vanilla.d.ts +1 -1
- package/dist/hooks/vanilla.js +1 -1
- package/dist/{ripple-CVQx46Xq.d.cts → ripple-C5MfEErC.d.cts} +6 -4
- package/dist/{ripple-CVQx46Xq.d.ts → ripple-C5MfEErC.d.ts} +6 -4
- package/package.json +1 -1
|
@@ -8,16 +8,17 @@ import {
|
|
|
8
8
|
|
|
9
9
|
// src/ts/hooks/vanilla/outsideClick.ts
|
|
10
10
|
import { NIL, NOOP } from "sia-reactor";
|
|
11
|
-
function initOutsideClick(el, { enabled = false,
|
|
11
|
+
function initOutsideClick(el, { enabled = false, onOutside = NOOP, outOnClick = true, outOnEscape = true, outOnFocusOut = false, allowBounds = false, allowInputs = false, root = window, scoped = true, capture = true } = NIL) {
|
|
12
12
|
const stacks = t007._outsiders_stacks ??= /* @__PURE__ */ new WeakMap(), existing = (t007._outsiders ??= /* @__PURE__ */ new WeakMap()).get(el);
|
|
13
13
|
if (!enabled || existing) return existing ? existing : void 0;
|
|
14
14
|
scoped = scoped && root instanceof HTMLElement, root = scoped ? root : root === document ? document : window;
|
|
15
|
-
const stack = stacks.get(root) ?? [], onScopedOut = (e, t, p = e.touches?.[0] || e, rect = el.getBoundingClientRect()) => {
|
|
16
|
-
if (stack.at(-1) !== el || p.clientX >= rect.left && p.clientX <= rect.right && p.clientY >= rect.top && p.clientY <= rect.bottom) return false;
|
|
17
|
-
return (!scoped ? true : root.contains(t)) &&
|
|
18
|
-
}, handleClick = ((e) => outOnClick && !(allowInputs && isInteractive(e.target)) && onScopedOut(e, e.target)), handleEscape = ((e) => outOnEscape && e.key === "Escape" && !e.ctrlKey && !e.shiftKey && !e.altKey && !e.metaKey && stack.at(-1) === el &&
|
|
15
|
+
const stack = stacks.get(root) ?? [], onScopedOut = (e, t, p = e.touches?.[0] || e, rect = allowBounds ? el.getBoundingClientRect() : null) => {
|
|
16
|
+
if (stack.at(-1) !== el || (allowBounds ? p.clientX >= rect.left && p.clientX <= rect.right && p.clientY >= rect.top && p.clientY <= rect.bottom : el.contains(t))) return false;
|
|
17
|
+
return (!scoped ? true : root.contains(t)) && onOutside(e);
|
|
18
|
+
}, handleClick = ((e) => outOnClick && !(allowInputs && isInteractive(e.target)) && onScopedOut(e, e.target)), handleEscape = ((e) => outOnEscape && e.key === "Escape" && !e.ctrlKey && !e.shiftKey && !e.altKey && !e.metaKey && stack.at(-1) === el && onOutside(e)), handleFocusOut = (e) => outOnFocusOut && !el.contains(e.relatedTarget) && onScopedOut(e, e.relatedTarget);
|
|
19
19
|
root.addEventListener("mousedown", handleClick, capture), root.addEventListener("touchstart", handleClick, { passive: true, capture });
|
|
20
|
-
root.addEventListener("keydown", handleEscape, capture)
|
|
20
|
+
root.addEventListener("keydown", handleEscape, capture);
|
|
21
|
+
el.addEventListener("focusout", handleFocusOut, capture);
|
|
21
22
|
if (!stack.includes(el)) stack.push(el), stacks.set(root, stack);
|
|
22
23
|
const destroy = () => {
|
|
23
24
|
root.removeEventListener("mousedown", handleClick, capture), root.removeEventListener("touchstart", handleClick, capture);
|
|
@@ -52,7 +53,7 @@ function initFocusTrap(el, { enabled = false, initialSelector = "[data-autofocus
|
|
|
52
53
|
first.addEventListener("focus", (e) => el.contains(e.relatedTarget) ? edgeFocus(true) : resetFocus(), capture), el.prepend(first);
|
|
53
54
|
last.addEventListener("focus", (e) => el.contains(e.relatedTarget) ? edgeFocus() : resetFocus(-1), capture), el.append(last);
|
|
54
55
|
root.addEventListener("focusin", handleFocusIn, capture);
|
|
55
|
-
if (!el.
|
|
56
|
+
if (initial || !el.contains(focused)) !initial ? setTimeout(resetFocus) : setTimeout(() => (initial.classList.add(ringClassName), initial.focus(), initial.addEventListener("blur", handleInitialBlur, capture)));
|
|
56
57
|
if (!stack.includes(el)) stack.push(el), stacks.set(root, stack);
|
|
57
58
|
const destroy = () => {
|
|
58
59
|
focused?.isConnected && focused.focus(), first.remove(), last.remove();
|
package/dist/hooks/react.cjs
CHANGED
|
@@ -125,16 +125,17 @@ var import_react2 = require("react");
|
|
|
125
125
|
|
|
126
126
|
// src/ts/hooks/vanilla/outsideClick.ts
|
|
127
127
|
var import_sia_reactor2 = require("sia-reactor");
|
|
128
|
-
function initOutsideClick(el, { enabled = false,
|
|
128
|
+
function initOutsideClick(el, { enabled = false, onOutside = import_sia_reactor2.NOOP, outOnClick = true, outOnEscape = true, outOnFocusOut = false, allowBounds = false, allowInputs = false, root = window, scoped = true, capture = true } = import_sia_reactor2.NIL) {
|
|
129
129
|
const stacks = t007._outsiders_stacks ??= /* @__PURE__ */ new WeakMap(), existing = (t007._outsiders ??= /* @__PURE__ */ new WeakMap()).get(el);
|
|
130
130
|
if (!enabled || existing) return existing ? existing : void 0;
|
|
131
131
|
scoped = scoped && root instanceof HTMLElement, root = scoped ? root : root === document ? document : window;
|
|
132
|
-
const stack = stacks.get(root) ?? [], onScopedOut = (e, t, p = e.touches?.[0] || e, rect = el.getBoundingClientRect()) => {
|
|
133
|
-
if (stack.at(-1) !== el || p.clientX >= rect.left && p.clientX <= rect.right && p.clientY >= rect.top && p.clientY <= rect.bottom) return false;
|
|
134
|
-
return (!scoped ? true : root.contains(t)) &&
|
|
135
|
-
}, handleClick = ((e) => outOnClick && !(allowInputs && isInteractive(e.target)) && onScopedOut(e, e.target)), handleEscape = ((e) => outOnEscape && e.key === "Escape" && !e.ctrlKey && !e.shiftKey && !e.altKey && !e.metaKey && stack.at(-1) === el &&
|
|
132
|
+
const stack = stacks.get(root) ?? [], onScopedOut = (e, t, p = e.touches?.[0] || e, rect = allowBounds ? el.getBoundingClientRect() : null) => {
|
|
133
|
+
if (stack.at(-1) !== el || (allowBounds ? p.clientX >= rect.left && p.clientX <= rect.right && p.clientY >= rect.top && p.clientY <= rect.bottom : el.contains(t))) return false;
|
|
134
|
+
return (!scoped ? true : root.contains(t)) && onOutside(e);
|
|
135
|
+
}, handleClick = ((e) => outOnClick && !(allowInputs && isInteractive(e.target)) && onScopedOut(e, e.target)), handleEscape = ((e) => outOnEscape && e.key === "Escape" && !e.ctrlKey && !e.shiftKey && !e.altKey && !e.metaKey && stack.at(-1) === el && onOutside(e)), handleFocusOut = (e) => outOnFocusOut && !el.contains(e.relatedTarget) && onScopedOut(e, e.relatedTarget);
|
|
136
136
|
root.addEventListener("mousedown", handleClick, capture), root.addEventListener("touchstart", handleClick, { passive: true, capture });
|
|
137
|
-
root.addEventListener("keydown", handleEscape, capture)
|
|
137
|
+
root.addEventListener("keydown", handleEscape, capture);
|
|
138
|
+
el.addEventListener("focusout", handleFocusOut, capture);
|
|
138
139
|
if (!stack.includes(el)) stack.push(el), stacks.set(root, stack);
|
|
139
140
|
const destroy = () => {
|
|
140
141
|
root.removeEventListener("mousedown", handleClick, capture), root.removeEventListener("touchstart", handleClick, capture);
|
|
@@ -148,7 +149,7 @@ function initOutsideClick(el, { enabled = false, onOutsideClick = import_sia_rea
|
|
|
148
149
|
// src/ts/hooks/react/useOutsideClick.ts
|
|
149
150
|
var import_sia_reactor3 = require("sia-reactor");
|
|
150
151
|
function useOutsideClick(ref, config = import_sia_reactor3.NIL) {
|
|
151
|
-
(0, import_react2.useEffect)(() => ref.current ? initOutsideClick(ref.current, config) : void 0, [ref, config.enabled, config.
|
|
152
|
+
(0, import_react2.useEffect)(() => ref.current ? initOutsideClick(ref.current, config) : void 0, [ref, config.enabled, config.onOutside, config.outOnEscape, config.outOnClick, config.outOnFocusOut, config.allowBounds, config.allowInputs, config.root, config.scoped, config.capture]);
|
|
152
153
|
}
|
|
153
154
|
|
|
154
155
|
// src/ts/hooks/react/useArrowNavigation/index.ts
|
|
@@ -399,7 +400,7 @@ function initFocusTrap(el, { enabled = false, initialSelector = "[data-autofocus
|
|
|
399
400
|
first.addEventListener("focus", (e) => el.contains(e.relatedTarget) ? edgeFocus(true) : resetFocus(), capture), el.prepend(first);
|
|
400
401
|
last.addEventListener("focus", (e) => el.contains(e.relatedTarget) ? edgeFocus() : resetFocus(-1), capture), el.append(last);
|
|
401
402
|
root.addEventListener("focusin", handleFocusIn, capture);
|
|
402
|
-
if (!el.
|
|
403
|
+
if (initial || !el.contains(focused)) !initial ? setTimeout(resetFocus) : setTimeout(() => (initial.classList.add(ringClassName), initial.focus(), initial.addEventListener("blur", handleInitialBlur, capture)));
|
|
403
404
|
if (!stack.includes(el)) stack.push(el), stacks.set(root, stack);
|
|
404
405
|
const destroy = () => {
|
|
405
406
|
focused?.isConnected && focused.focus(), first.remove(), last.remove();
|
package/dist/hooks/react.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { RefObject } from 'react';
|
|
2
2
|
import { a as ScrollAssistConfig, C as Config, K as KeyEvent } from '../scrollAssist-y9wFmYgt.cjs';
|
|
3
|
-
import { O as OutsideClickConfig, F as FocusTrapConfig, R as RippleConfig } from '../ripple-
|
|
3
|
+
import { O as OutsideClickConfig, F as FocusTrapConfig, R as RippleConfig } from '../ripple-C5MfEErC.cjs';
|
|
4
4
|
export { H as HighlightOptions, u as useHighlight } from '../useHighlight-DMpDCILK.cjs';
|
|
5
5
|
|
|
6
6
|
/** Configuration options for the `useScrollAssist` hook. */
|
package/dist/hooks/react.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { RefObject } from 'react';
|
|
2
2
|
import { a as ScrollAssistConfig, C as Config, K as KeyEvent } from '../scrollAssist-y9wFmYgt.js';
|
|
3
|
-
import { O as OutsideClickConfig, F as FocusTrapConfig, R as RippleConfig } from '../ripple-
|
|
3
|
+
import { O as OutsideClickConfig, F as FocusTrapConfig, R as RippleConfig } from '../ripple-C5MfEErC.js';
|
|
4
4
|
export { H as HighlightOptions, u as useHighlight } from '../useHighlight-DMpDCILK.js';
|
|
5
5
|
|
|
6
6
|
/** Configuration options for the `useScrollAssist` hook. */
|
package/dist/hooks/react.js
CHANGED
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
initFocusTrap,
|
|
12
12
|
initOutsideClick,
|
|
13
13
|
rippleHandler
|
|
14
|
-
} from "../chunk-
|
|
14
|
+
} from "../chunk-LBDWVTYF.js";
|
|
15
15
|
import {
|
|
16
16
|
INTERACTIVE_SELECTOR,
|
|
17
17
|
getActiveEl
|
|
@@ -101,7 +101,7 @@ function useScrollAssist(ref, { enabled = true, pxPerSecond = 80, assistClassNam
|
|
|
101
101
|
import { useEffect as useEffect2 } from "react";
|
|
102
102
|
import { NIL as NIL2 } from "sia-reactor";
|
|
103
103
|
function useOutsideClick(ref, config = NIL2) {
|
|
104
|
-
useEffect2(() => ref.current ? initOutsideClick(ref.current, config) : void 0, [ref, config.enabled, config.
|
|
104
|
+
useEffect2(() => ref.current ? initOutsideClick(ref.current, config) : void 0, [ref, config.enabled, config.onOutside, config.outOnEscape, config.outOnClick, config.outOnFocusOut, config.allowBounds, config.allowInputs, config.root, config.scoped, config.capture]);
|
|
105
105
|
}
|
|
106
106
|
|
|
107
107
|
// src/ts/hooks/react/useArrowNavigation/index.ts
|
package/dist/hooks/vanilla.cjs
CHANGED
|
@@ -136,16 +136,17 @@ function initVScrollerator({ baseSpeed = 3, maxSpeed = 10, stepDelay = 2e3, base
|
|
|
136
136
|
|
|
137
137
|
// src/ts/hooks/vanilla/outsideClick.ts
|
|
138
138
|
var import_sia_reactor3 = require("sia-reactor");
|
|
139
|
-
function initOutsideClick(el, { enabled = false,
|
|
139
|
+
function initOutsideClick(el, { enabled = false, onOutside = import_sia_reactor3.NOOP, outOnClick = true, outOnEscape = true, outOnFocusOut = false, allowBounds = false, allowInputs = false, root = window, scoped = true, capture = true } = import_sia_reactor3.NIL) {
|
|
140
140
|
const stacks = t007._outsiders_stacks ??= /* @__PURE__ */ new WeakMap(), existing = (t007._outsiders ??= /* @__PURE__ */ new WeakMap()).get(el);
|
|
141
141
|
if (!enabled || existing) return existing ? existing : void 0;
|
|
142
142
|
scoped = scoped && root instanceof HTMLElement, root = scoped ? root : root === document ? document : window;
|
|
143
|
-
const stack = stacks.get(root) ?? [], onScopedOut = (e, t, p = e.touches?.[0] || e, rect = el.getBoundingClientRect()) => {
|
|
144
|
-
if (stack.at(-1) !== el || p.clientX >= rect.left && p.clientX <= rect.right && p.clientY >= rect.top && p.clientY <= rect.bottom) return false;
|
|
145
|
-
return (!scoped ? true : root.contains(t)) &&
|
|
146
|
-
}, handleClick = ((e) => outOnClick && !(allowInputs && isInteractive(e.target)) && onScopedOut(e, e.target)), handleEscape = ((e) => outOnEscape && e.key === "Escape" && !e.ctrlKey && !e.shiftKey && !e.altKey && !e.metaKey && stack.at(-1) === el &&
|
|
143
|
+
const stack = stacks.get(root) ?? [], onScopedOut = (e, t, p = e.touches?.[0] || e, rect = allowBounds ? el.getBoundingClientRect() : null) => {
|
|
144
|
+
if (stack.at(-1) !== el || (allowBounds ? p.clientX >= rect.left && p.clientX <= rect.right && p.clientY >= rect.top && p.clientY <= rect.bottom : el.contains(t))) return false;
|
|
145
|
+
return (!scoped ? true : root.contains(t)) && onOutside(e);
|
|
146
|
+
}, handleClick = ((e) => outOnClick && !(allowInputs && isInteractive(e.target)) && onScopedOut(e, e.target)), handleEscape = ((e) => outOnEscape && e.key === "Escape" && !e.ctrlKey && !e.shiftKey && !e.altKey && !e.metaKey && stack.at(-1) === el && onOutside(e)), handleFocusOut = (e) => outOnFocusOut && !el.contains(e.relatedTarget) && onScopedOut(e, e.relatedTarget);
|
|
147
147
|
root.addEventListener("mousedown", handleClick, capture), root.addEventListener("touchstart", handleClick, { passive: true, capture });
|
|
148
|
-
root.addEventListener("keydown", handleEscape, capture)
|
|
148
|
+
root.addEventListener("keydown", handleEscape, capture);
|
|
149
|
+
el.addEventListener("focusout", handleFocusOut, capture);
|
|
149
150
|
if (!stack.includes(el)) stack.push(el), stacks.set(root, stack);
|
|
150
151
|
const destroy = () => {
|
|
151
152
|
root.removeEventListener("mousedown", handleClick, capture), root.removeEventListener("touchstart", handleClick, capture);
|
|
@@ -180,7 +181,7 @@ function initFocusTrap(el, { enabled = false, initialSelector = "[data-autofocus
|
|
|
180
181
|
first.addEventListener("focus", (e) => el.contains(e.relatedTarget) ? edgeFocus(true) : resetFocus(), capture), el.prepend(first);
|
|
181
182
|
last.addEventListener("focus", (e) => el.contains(e.relatedTarget) ? edgeFocus() : resetFocus(-1), capture), el.append(last);
|
|
182
183
|
root.addEventListener("focusin", handleFocusIn, capture);
|
|
183
|
-
if (!el.
|
|
184
|
+
if (initial || !el.contains(focused)) !initial ? setTimeout(resetFocus) : setTimeout(() => (initial.classList.add(ringClassName), initial.focus(), initial.addEventListener("blur", handleInitialBlur, capture)));
|
|
184
185
|
if (!stack.includes(el)) stack.push(el), stacks.set(root, stack);
|
|
185
186
|
const destroy = () => {
|
|
186
187
|
focused?.isConnected && focused.focus(), first.remove(), last.remove();
|
package/dist/hooks/vanilla.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { a as ScrollAssistConfig, S as ScrollAssistHandle, b as ScrollDir, i as initScrollAssist, r as removeScrollAssist } from '../scrollAssist-y9wFmYgt.cjs';
|
|
2
|
-
export { F as FocusTrapConfig, O as OutsideClickConfig, R as RippleConfig, i as initFocusTrap, a as initOutsideClick, r as removeFocusTrap, b as removeOutsideClick, c as rippleHandler } from '../ripple-
|
|
2
|
+
export { F as FocusTrapConfig, O as OutsideClickConfig, R as RippleConfig, i as initFocusTrap, a as initOutsideClick, r as removeFocusTrap, b as removeOutsideClick, c as rippleHandler } from '../ripple-C5MfEErC.cjs';
|
|
3
3
|
export { A as ArrowNavigationHandle, i as initArrowNavigation, r as removeArrowNavigation } from '../arrowNavigation-DK8mqVOk.cjs';
|
|
4
4
|
|
|
5
5
|
/** Configuration for the vertical edge-scrolling helper. */
|
package/dist/hooks/vanilla.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { a as ScrollAssistConfig, S as ScrollAssistHandle, b as ScrollDir, i as initScrollAssist, r as removeScrollAssist } from '../scrollAssist-y9wFmYgt.js';
|
|
2
|
-
export { F as FocusTrapConfig, O as OutsideClickConfig, R as RippleConfig, i as initFocusTrap, a as initOutsideClick, r as removeFocusTrap, b as removeOutsideClick, c as rippleHandler } from '../ripple-
|
|
2
|
+
export { F as FocusTrapConfig, O as OutsideClickConfig, R as RippleConfig, i as initFocusTrap, a as initOutsideClick, r as removeFocusTrap, b as removeOutsideClick, c as rippleHandler } from '../ripple-C5MfEErC.js';
|
|
3
3
|
export { A as ArrowNavigationHandle, i as initArrowNavigation, r as removeArrowNavigation } from '../arrowNavigation-VenvPI4H.js';
|
|
4
4
|
|
|
5
5
|
/** Configuration for the vertical edge-scrolling helper. */
|
package/dist/hooks/vanilla.js
CHANGED
|
@@ -2,13 +2,15 @@ interface OutsideClickConfig {
|
|
|
2
2
|
/** Enables or disables outside-click handling. Defaults to `false`. */
|
|
3
3
|
enabled?: boolean;
|
|
4
4
|
/** Callback invoked when an outside interaction is detected. Defaults to `()=>{}`. */
|
|
5
|
-
|
|
5
|
+
onOutside?: (e: MouseEvent | TouchEvent | KeyboardEvent | FocusEvent) => void;
|
|
6
6
|
/** Whether pointer/touch outside interactions should trigger callback. Defaults to `true`. */
|
|
7
7
|
outOnClick?: boolean;
|
|
8
8
|
/** Whether Escape key should trigger callback. Defaults to `true`. */
|
|
9
9
|
outOnEscape?: boolean;
|
|
10
10
|
/** Whether focus leaving the container should trigger callback. Defaults to `false`. */
|
|
11
11
|
outOnFocusOut?: boolean;
|
|
12
|
+
/** Allow only clicks inside `el` bounding client rectangle to be considered valid, otherwise uses `el.contains(target)`. Defaults to `false . */
|
|
13
|
+
allowBounds?: boolean;
|
|
12
14
|
/** Allow interactive elements including outsiders to bypass click callback. Defaults to `false`. */
|
|
13
15
|
allowInputs?: boolean;
|
|
14
16
|
/** Optional root used to scope focus listeners to an element instead of the window. Defaults to `window`. */
|
|
@@ -19,16 +21,16 @@ interface OutsideClickConfig {
|
|
|
19
21
|
capture?: boolean;
|
|
20
22
|
}
|
|
21
23
|
/** Hook to attach outside-click, escape, and optional focus-out handling to an element. */
|
|
22
|
-
declare function initOutsideClick(el: HTMLElement, { enabled,
|
|
24
|
+
declare function initOutsideClick(el: HTMLElement, { enabled, onOutside, outOnClick, outOnEscape, outOnFocusOut, allowBounds, allowInputs, root, scoped, capture }?: OutsideClickConfig): (() => void) | void;
|
|
23
25
|
/** Remove outside-click handling from an element. */
|
|
24
26
|
declare const removeOutsideClick: (el: HTMLElement) => void | undefined;
|
|
25
27
|
|
|
26
28
|
interface FocusTrapConfig {
|
|
27
29
|
/** Enables or disables the focus trap. Defaults to `false`. */
|
|
28
30
|
enabled?: boolean;
|
|
29
|
-
/** The preferred initial focus target selector within the element. Defaults to `[data-autofocus]`. */
|
|
31
|
+
/** The preferred initial focus target selector within the element, overrides whatever was focused. Try `autofocus` attribute if working with dialogs before this. Defaults to `[data-autofocus]`. */
|
|
30
32
|
initialSelector?: string;
|
|
31
|
-
/** The class name for the initial focus ring since programmatic focus is not always visible. Defaults to `"focus-outline"`. */
|
|
33
|
+
/** The class name for the initial focus ring since programmatic focus is not always visible, `autofocus` attribute in dialogs might work fine as an alternative. Defaults to `"focus-outline"`. */
|
|
32
34
|
ringClassName?: string;
|
|
33
35
|
/** Optional root used to scope focus listeners to an element instead of the window. Defaults to `window`. */
|
|
34
36
|
root?: HTMLElement | Document | Window;
|
|
@@ -2,13 +2,15 @@ interface OutsideClickConfig {
|
|
|
2
2
|
/** Enables or disables outside-click handling. Defaults to `false`. */
|
|
3
3
|
enabled?: boolean;
|
|
4
4
|
/** Callback invoked when an outside interaction is detected. Defaults to `()=>{}`. */
|
|
5
|
-
|
|
5
|
+
onOutside?: (e: MouseEvent | TouchEvent | KeyboardEvent | FocusEvent) => void;
|
|
6
6
|
/** Whether pointer/touch outside interactions should trigger callback. Defaults to `true`. */
|
|
7
7
|
outOnClick?: boolean;
|
|
8
8
|
/** Whether Escape key should trigger callback. Defaults to `true`. */
|
|
9
9
|
outOnEscape?: boolean;
|
|
10
10
|
/** Whether focus leaving the container should trigger callback. Defaults to `false`. */
|
|
11
11
|
outOnFocusOut?: boolean;
|
|
12
|
+
/** Allow only clicks inside `el` bounding client rectangle to be considered valid, otherwise uses `el.contains(target)`. Defaults to `false . */
|
|
13
|
+
allowBounds?: boolean;
|
|
12
14
|
/** Allow interactive elements including outsiders to bypass click callback. Defaults to `false`. */
|
|
13
15
|
allowInputs?: boolean;
|
|
14
16
|
/** Optional root used to scope focus listeners to an element instead of the window. Defaults to `window`. */
|
|
@@ -19,16 +21,16 @@ interface OutsideClickConfig {
|
|
|
19
21
|
capture?: boolean;
|
|
20
22
|
}
|
|
21
23
|
/** Hook to attach outside-click, escape, and optional focus-out handling to an element. */
|
|
22
|
-
declare function initOutsideClick(el: HTMLElement, { enabled,
|
|
24
|
+
declare function initOutsideClick(el: HTMLElement, { enabled, onOutside, outOnClick, outOnEscape, outOnFocusOut, allowBounds, allowInputs, root, scoped, capture }?: OutsideClickConfig): (() => void) | void;
|
|
23
25
|
/** Remove outside-click handling from an element. */
|
|
24
26
|
declare const removeOutsideClick: (el: HTMLElement) => void | undefined;
|
|
25
27
|
|
|
26
28
|
interface FocusTrapConfig {
|
|
27
29
|
/** Enables or disables the focus trap. Defaults to `false`. */
|
|
28
30
|
enabled?: boolean;
|
|
29
|
-
/** The preferred initial focus target selector within the element. Defaults to `[data-autofocus]`. */
|
|
31
|
+
/** The preferred initial focus target selector within the element, overrides whatever was focused. Try `autofocus` attribute if working with dialogs before this. Defaults to `[data-autofocus]`. */
|
|
30
32
|
initialSelector?: string;
|
|
31
|
-
/** The class name for the initial focus ring since programmatic focus is not always visible. Defaults to `"focus-outline"`. */
|
|
33
|
+
/** The class name for the initial focus ring since programmatic focus is not always visible, `autofocus` attribute in dialogs might work fine as an alternative. Defaults to `"focus-outline"`. */
|
|
32
34
|
ringClassName?: string;
|
|
33
35
|
/** Optional root used to scope focus listeners to an element instead of the window. Defaults to `window`. */
|
|
34
36
|
root?: HTMLElement | Document | Window;
|