@surdeddd/bottom-sheet 0.1.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/LICENSE +21 -0
- package/README.md +377 -0
- package/dist/BottomSheetEngine-CvSVbo6c.d.cts +704 -0
- package/dist/BottomSheetEngine-DbO8rW_3.d.ts +704 -0
- package/dist/element.cjs +3442 -0
- package/dist/element.d.cts +88 -0
- package/dist/element.d.ts +88 -0
- package/dist/element.iife.global.js +3 -0
- package/dist/element.js +3442 -0
- package/dist/index.cjs +3693 -0
- package/dist/index.d.cts +184 -0
- package/dist/index.d.ts +184 -0
- package/dist/index.js +3669 -0
- package/dist/integrations/formik.cjs +27 -0
- package/dist/integrations/formik.d.cts +27 -0
- package/dist/integrations/formik.d.ts +27 -0
- package/dist/integrations/formik.js +25 -0
- package/dist/integrations/react-hook-form.cjs +28 -0
- package/dist/integrations/react-hook-form.d.cts +30 -0
- package/dist/integrations/react-hook-form.d.ts +30 -0
- package/dist/integrations/react-hook-form.js +26 -0
- package/dist/overlay.cjs +1058 -0
- package/dist/overlay.d.cts +282 -0
- package/dist/overlay.d.ts +282 -0
- package/dist/overlay.js +1053 -0
- package/dist/preact.cjs +2 -0
- package/dist/preact.d.cts +5 -0
- package/dist/preact.d.ts +5 -0
- package/dist/preact.js +2 -0
- package/dist/qwik.cjs +3046 -0
- package/dist/qwik.d.cts +55 -0
- package/dist/qwik.d.ts +55 -0
- package/dist/qwik.js +3044 -0
- package/dist/react.cjs +4162 -0
- package/dist/react.d.cts +301 -0
- package/dist/react.d.ts +301 -0
- package/dist/react.js +4156 -0
- package/dist/solid.cjs +3063 -0
- package/dist/solid.d.cts +66 -0
- package/dist/solid.d.ts +66 -0
- package/dist/solid.js +3061 -0
- package/dist/styles.css +508 -0
- package/dist/svelte.cjs +3200 -0
- package/dist/svelte.d.ts +89 -0
- package/dist/svelte.js +3177 -0
- package/dist/themes/ios.css +24 -0
- package/dist/themes/material.css +24 -0
- package/dist/themes/vercel.css +24 -0
- package/dist/transform-Brkf-wzo.d.cts +4 -0
- package/dist/transform-Brkf-wzo.d.ts +4 -0
- package/dist/vue.cjs +3361 -0
- package/dist/vue.d.ts +68 -0
- package/dist/vue.js +3358 -0
- package/package.json +288 -0
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
import { T as TransformAxis } from './transform-Brkf-wzo.cjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Slide-up panel without gestures. CSS-transition-driven, single-state.
|
|
5
|
+
* Distinct from `BottomSheetEngine`, which is gesture-driven and multi-snap.
|
|
6
|
+
*
|
|
7
|
+
* Shares scroll-lock / focus-trap / sheet-stack / inert-siblings / transform
|
|
8
|
+
* primitives with the engine so z-indices orchestrate automatically when
|
|
9
|
+
* sheets and overlays mix and feature behaviour stays consistent.
|
|
10
|
+
*/
|
|
11
|
+
type OverlayEdge = TransformAxis;
|
|
12
|
+
type OverlayAnimation = "slide" | "fade" | "scale";
|
|
13
|
+
type OverlayCloseReason = "escape" | "backdrop" | "swipe" | "back" | "programmatic" | "outside-pointer";
|
|
14
|
+
type SwipeToCloseConfig = {
|
|
15
|
+
enabled?: boolean;
|
|
16
|
+
threshold?: number;
|
|
17
|
+
velocityThreshold?: number;
|
|
18
|
+
};
|
|
19
|
+
type OverlayMountTarget = HTMLElement | "body" | "parent";
|
|
20
|
+
/**
|
|
21
|
+
* Named overlay archetypes — bundle the common animation + dim + gesture
|
|
22
|
+
* combinations so consumers can opt into a "mode" without restating every
|
|
23
|
+
* field. Applied BEFORE individual options at construction, and as the
|
|
24
|
+
* first step of `setOverlay()` so individual overrides win.
|
|
25
|
+
*/
|
|
26
|
+
type OverlayPreset = "sheet" | "dialog" | "sidebar" | "toast";
|
|
27
|
+
type OverlayPresetConfig = {
|
|
28
|
+
enterAnimation: OverlayAnimation;
|
|
29
|
+
exitAnimation: OverlayAnimation;
|
|
30
|
+
backdropOpacity: number;
|
|
31
|
+
backdropFilter?: string;
|
|
32
|
+
swipeToClose: boolean | SwipeToCloseConfig;
|
|
33
|
+
};
|
|
34
|
+
declare const OVERLAY_PRESETS: Readonly<Record<OverlayPreset, Readonly<OverlayPresetConfig>>>;
|
|
35
|
+
/**
|
|
36
|
+
* Batch payload for `setOverlay()`. `null` on `backdropFilter` clears it
|
|
37
|
+
* (distinct from `undefined` which means "leave as-is" in the diff). Apply
|
|
38
|
+
* order: preset first, then individual overrides — single DOM-write phase
|
|
39
|
+
* if the overlay is currently open.
|
|
40
|
+
*/
|
|
41
|
+
type OverlayUpdate = {
|
|
42
|
+
backdropOpacity?: number;
|
|
43
|
+
backdropFilter?: string | null;
|
|
44
|
+
swipeToClose?: boolean | SwipeToCloseConfig;
|
|
45
|
+
enterAnimation?: OverlayAnimation;
|
|
46
|
+
exitAnimation?: OverlayAnimation;
|
|
47
|
+
preset?: OverlayPreset;
|
|
48
|
+
/**
|
|
49
|
+
* Runtime children swap. `null` clears the panel's contents. A function is
|
|
50
|
+
* called once to lazy-resolve dynamic content. Applied LAST in the batch so
|
|
51
|
+
* style mutations finish before the DOM swap.
|
|
52
|
+
*/
|
|
53
|
+
children?: HTMLElement | DocumentFragment | (() => HTMLElement | DocumentFragment) | null;
|
|
54
|
+
};
|
|
55
|
+
type OverlayOptions = {
|
|
56
|
+
/** The panel element — gets transform/opacity inline writes. */
|
|
57
|
+
element: HTMLElement;
|
|
58
|
+
/** Optional dimmed backdrop element. */
|
|
59
|
+
backdrop?: HTMLElement;
|
|
60
|
+
/** Edge the panel slides in from. Default: "bottom". */
|
|
61
|
+
edge?: OverlayEdge;
|
|
62
|
+
/** Open immediately on construction. Default: false. */
|
|
63
|
+
initialOpen?: boolean;
|
|
64
|
+
/** Listen for Escape key. Default: true. */
|
|
65
|
+
closeOnEscape?: boolean;
|
|
66
|
+
/** Tap on backdrop closes. Default: true. */
|
|
67
|
+
closeOnBackdrop?: boolean;
|
|
68
|
+
/** Trap Tab focus inside the panel. Default: true. */
|
|
69
|
+
focusTrap?: boolean;
|
|
70
|
+
/** Selector or HTMLElement focused on open. */
|
|
71
|
+
initialFocus?: string | HTMLElement;
|
|
72
|
+
/**
|
|
73
|
+
* Element to focus after close. By default the focus trap restores
|
|
74
|
+
* whatever was focused before open. Pass an element or a getter for
|
|
75
|
+
* explicit control (e.g. focus a status banner instead of the trigger).
|
|
76
|
+
*/
|
|
77
|
+
returnFocus?: HTMLElement | (() => HTMLElement | null);
|
|
78
|
+
/** Lock body scroll while open. Default: true. */
|
|
79
|
+
lockBodyScroll?: boolean;
|
|
80
|
+
/** Mark page siblings `inert` while open (full a11y modal). Default: false. */
|
|
81
|
+
inertSiblings?: boolean;
|
|
82
|
+
/** Push history state so Android back closes the overlay. Default: false. */
|
|
83
|
+
closeOnBack?: boolean;
|
|
84
|
+
/** Animation duration in ms. Default: 320. */
|
|
85
|
+
duration?: number;
|
|
86
|
+
/** CSS easing for the slide-in. Default matches monitoring's bezier. */
|
|
87
|
+
enterEasing?: string;
|
|
88
|
+
/** CSS easing for the slide-out. Default: ease-in. */
|
|
89
|
+
exitEasing?: string;
|
|
90
|
+
/**
|
|
91
|
+
* Peak backdrop opacity when open. Useful when `backdropFilter` blur
|
|
92
|
+
* already darkens enough and the dim should be light (e.g. 0.3).
|
|
93
|
+
* Default: 1.
|
|
94
|
+
*/
|
|
95
|
+
backdropOpacity?: number;
|
|
96
|
+
/**
|
|
97
|
+
* CSS `backdrop-filter` value applied to the backdrop while open
|
|
98
|
+
* (e.g. `"blur(8px)"`, `"blur(12px) saturate(140%)"`). Cleared on close.
|
|
99
|
+
*/
|
|
100
|
+
backdropFilter?: string;
|
|
101
|
+
/**
|
|
102
|
+
* Allow drag-to-dismiss along the entry edge — pointer-driven. The panel
|
|
103
|
+
* follows the finger past the closed-edge axis and dismisses if the user
|
|
104
|
+
* crosses 30% of the panel size or releases with > 0.5 px/ms velocity.
|
|
105
|
+
*
|
|
106
|
+
* Pass a config object to tune thresholds:
|
|
107
|
+
* `{ enabled: true, threshold: 0.5, velocityThreshold: 1.0 }`.
|
|
108
|
+
* Default: false (CSS-only transition).
|
|
109
|
+
*/
|
|
110
|
+
swipeToClose?: boolean | SwipeToCloseConfig;
|
|
111
|
+
/**
|
|
112
|
+
* Entry animation. `"slide"` (default) translates from the edge.
|
|
113
|
+
* `"fade"` is opacity-only (no transform). `"scale"` fades + scales
|
|
114
|
+
* from 0.94 — best for centred dialogs.
|
|
115
|
+
*/
|
|
116
|
+
enterAnimation?: OverlayAnimation;
|
|
117
|
+
/** Exit animation. Defaults to `enterAnimation`. */
|
|
118
|
+
exitAnimation?: OverlayAnimation;
|
|
119
|
+
/**
|
|
120
|
+
* Move `element` to a different container on first open. `'parent'`
|
|
121
|
+
* (default) leaves it in place. `'body'` appends to `document.body`.
|
|
122
|
+
* Pass an explicit `HTMLElement` for any other portal target.
|
|
123
|
+
*
|
|
124
|
+
* Restored to its original parent on `destroy()`. Move is deferred to
|
|
125
|
+
* first `open()` so SSR / pre-mount construction doesn't crash.
|
|
126
|
+
*/
|
|
127
|
+
mountTo?: OverlayMountTarget;
|
|
128
|
+
/**
|
|
129
|
+
* `peek` keeps part of the panel visible when closed instead of
|
|
130
|
+
* translating fully off-screen. Number is treated as pixels; strings
|
|
131
|
+
* accept any CSS length (`"10dvh"`, `"clamp(40px, 8vh, 80px)"`).
|
|
132
|
+
* Only honoured when `edge: 'bottom'` — warns and falls back otherwise.
|
|
133
|
+
*/
|
|
134
|
+
peek?: number | string;
|
|
135
|
+
/**
|
|
136
|
+
* Close when a pointerdown lands outside `element` AND outside `backdrop`.
|
|
137
|
+
* Distinct from `closeOnBackdrop` — this fires even when no backdrop is
|
|
138
|
+
* mounted. Single document-level listener, removed on close.
|
|
139
|
+
*/
|
|
140
|
+
closeOnOutsidePointer?: boolean;
|
|
141
|
+
/**
|
|
142
|
+
* Named archetype — bundles `enterAnimation`/`exitAnimation`/
|
|
143
|
+
* `backdropOpacity`/`backdropFilter`/`swipeToClose` defaults. Applied
|
|
144
|
+
* BEFORE the individual options on this object, so any explicit field
|
|
145
|
+
* still wins over the preset's default.
|
|
146
|
+
*/
|
|
147
|
+
preset?: OverlayPreset;
|
|
148
|
+
/** Lifecycle callbacks. */
|
|
149
|
+
onOpen?: () => void;
|
|
150
|
+
onClose?: () => void;
|
|
151
|
+
};
|
|
152
|
+
type OverlayState = {
|
|
153
|
+
isOpen: boolean;
|
|
154
|
+
isAnimating: boolean;
|
|
155
|
+
};
|
|
156
|
+
type OverlayEventMap = {
|
|
157
|
+
open: void;
|
|
158
|
+
close: {
|
|
159
|
+
reason: OverlayCloseReason;
|
|
160
|
+
};
|
|
161
|
+
"before-open": void;
|
|
162
|
+
"before-close": void;
|
|
163
|
+
};
|
|
164
|
+
type Listener<K extends keyof OverlayEventMap> = (payload: OverlayEventMap[K]) => void;
|
|
165
|
+
declare class OverlayEngine {
|
|
166
|
+
private id;
|
|
167
|
+
private element;
|
|
168
|
+
private backdrop?;
|
|
169
|
+
private edge;
|
|
170
|
+
private closeOnEscape;
|
|
171
|
+
private closeOnBackdropEnabled;
|
|
172
|
+
private focusTrapEnabled;
|
|
173
|
+
private initialFocus?;
|
|
174
|
+
private bodyScrollLockEnabled;
|
|
175
|
+
private inertSiblingsEnabled;
|
|
176
|
+
private closeOnBackEnabled;
|
|
177
|
+
private duration;
|
|
178
|
+
private enterEasing;
|
|
179
|
+
private exitEasing;
|
|
180
|
+
private backdropOpacity;
|
|
181
|
+
private backdropFilter?;
|
|
182
|
+
private swipeToCloseEnabled;
|
|
183
|
+
private swipeThreshold;
|
|
184
|
+
private swipeVelocityThreshold;
|
|
185
|
+
private enterAnimation;
|
|
186
|
+
private exitAnimation;
|
|
187
|
+
private mountTarget?;
|
|
188
|
+
private originalParent;
|
|
189
|
+
private originalNextSibling;
|
|
190
|
+
private mounted;
|
|
191
|
+
private peekRaw?;
|
|
192
|
+
private peekPx?;
|
|
193
|
+
private closeOnOutsidePointerEnabled;
|
|
194
|
+
private detachOutsidePointer;
|
|
195
|
+
private detachSwipe;
|
|
196
|
+
private onOpenCb?;
|
|
197
|
+
private onCloseCb?;
|
|
198
|
+
private isOpen_;
|
|
199
|
+
private isAnimating_;
|
|
200
|
+
private destroyed;
|
|
201
|
+
private hasInjectedChildren;
|
|
202
|
+
private cycleNonce;
|
|
203
|
+
private bus;
|
|
204
|
+
private detachEscape;
|
|
205
|
+
private detachBackdrop;
|
|
206
|
+
private detachHardwareBack;
|
|
207
|
+
private releaseStackEntry;
|
|
208
|
+
private lifecycle;
|
|
209
|
+
constructor(opts: OverlayOptions);
|
|
210
|
+
get state(): OverlayState;
|
|
211
|
+
on<K extends keyof OverlayEventMap>(event: K, fn: Listener<K>): () => void;
|
|
212
|
+
open(): Promise<void>;
|
|
213
|
+
close(reason?: OverlayCloseReason): Promise<void>;
|
|
214
|
+
toggle(): Promise<void>;
|
|
215
|
+
destroy(): void;
|
|
216
|
+
/**
|
|
217
|
+
* Runtime visual setter — opacity is applied immediately when open so a
|
|
218
|
+
* live-controls panel can preview the change without re-opening. When
|
|
219
|
+
* closed we only stash the field; next open() picks it up so we don't
|
|
220
|
+
* mutate hidden DOM (avoids paint thrash on detached panels).
|
|
221
|
+
*/
|
|
222
|
+
setBackdropOpacity(opacity: number): void;
|
|
223
|
+
/**
|
|
224
|
+
* Runtime visual setter for `backdrop-filter`. `undefined` clears the
|
|
225
|
+
* filter (mirrors the close() behaviour). Defers to next open() when the
|
|
226
|
+
* overlay is currently closed.
|
|
227
|
+
*/
|
|
228
|
+
setBackdropFilter(filter: string | undefined): void;
|
|
229
|
+
/**
|
|
230
|
+
* Toggle / reconfigure swipe-to-close at runtime. Re-resolves the flat
|
|
231
|
+
* threshold fields, then installs or tears down the pointer listener so
|
|
232
|
+
* the change applies to the CURRENT open cycle. Idempotent: safe to call
|
|
233
|
+
* with the same config repeatedly.
|
|
234
|
+
*/
|
|
235
|
+
setSwipeToClose(config: boolean | SwipeToCloseConfig): void;
|
|
236
|
+
/** Animation setters only stage the field — applied on next open/close. */
|
|
237
|
+
setEnterAnimation(animation: OverlayAnimation): void;
|
|
238
|
+
setExitAnimation(animation: OverlayAnimation): void;
|
|
239
|
+
/** Updates the field used at next close() — no immediate side effect. */
|
|
240
|
+
setReturnFocus(target: HTMLElement | (() => HTMLElement | null) | undefined): void;
|
|
241
|
+
/**
|
|
242
|
+
* Batch update — preset first, then individual overrides. Applied as a
|
|
243
|
+
* single DOM-write phase when open so live-controls don't trigger
|
|
244
|
+
* cascading reflows. Safe to call when closed (defers to next open).
|
|
245
|
+
*/
|
|
246
|
+
setOverlay(opts: OverlayUpdate): void;
|
|
247
|
+
/**
|
|
248
|
+
* Runtime children injection — replace the panel's contents without
|
|
249
|
+
* unmounting the engine. `replaceChildren()` is a single atomic DOM op,
|
|
250
|
+
* so callers can swap content rapidly without intermediate flicker.
|
|
251
|
+
* Function form is resolved exactly ONCE per call (cheap lazy content).
|
|
252
|
+
*/
|
|
253
|
+
setOverlayChildren(children: HTMLElement | DocumentFragment | (() => HTMLElement | DocumentFragment)): void;
|
|
254
|
+
/**
|
|
255
|
+
* Clear injected children. No-op when nothing was injected so consumers
|
|
256
|
+
* who never used setOverlayChildren can call this defensively without
|
|
257
|
+
* paying for a DOM mutation.
|
|
258
|
+
*/
|
|
259
|
+
clearOverlayChildren(): void;
|
|
260
|
+
private assignSwipeFromConfig;
|
|
261
|
+
private emit;
|
|
262
|
+
private resolvePeekPx;
|
|
263
|
+
private maybeMount;
|
|
264
|
+
private restoreMount;
|
|
265
|
+
private applyClosedStyles;
|
|
266
|
+
private awaitTransition;
|
|
267
|
+
private installInteractiveListeners;
|
|
268
|
+
private releaseInteractiveListeners;
|
|
269
|
+
/**
|
|
270
|
+
* Light pointer-driven dismiss. Tracks finger along the edge axis, follows
|
|
271
|
+
* with translate, dismisses if past `swipeThreshold` (fraction of panel
|
|
272
|
+
* size) or release velocity exceeds `swipeVelocityThreshold` (px/ms).
|
|
273
|
+
* Pure CSS-transform during drag — no rAF or physics required since the
|
|
274
|
+
* panel only moves one direction.
|
|
275
|
+
*/
|
|
276
|
+
private installSwipeToClose;
|
|
277
|
+
private registerInStack;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
declare const createOverlay: (opts: OverlayOptions) => OverlayEngine;
|
|
281
|
+
|
|
282
|
+
export { OVERLAY_PRESETS, OverlayEngine as Overlay, type OverlayAnimation, type OverlayCloseReason, type OverlayEdge, OverlayEngine, type OverlayEventMap, type OverlayMountTarget, type OverlayOptions, type OverlayPreset, type OverlayState, type OverlayUpdate, type SwipeToCloseConfig, createOverlay };
|
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
import { T as TransformAxis } from './transform-Brkf-wzo.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Slide-up panel without gestures. CSS-transition-driven, single-state.
|
|
5
|
+
* Distinct from `BottomSheetEngine`, which is gesture-driven and multi-snap.
|
|
6
|
+
*
|
|
7
|
+
* Shares scroll-lock / focus-trap / sheet-stack / inert-siblings / transform
|
|
8
|
+
* primitives with the engine so z-indices orchestrate automatically when
|
|
9
|
+
* sheets and overlays mix and feature behaviour stays consistent.
|
|
10
|
+
*/
|
|
11
|
+
type OverlayEdge = TransformAxis;
|
|
12
|
+
type OverlayAnimation = "slide" | "fade" | "scale";
|
|
13
|
+
type OverlayCloseReason = "escape" | "backdrop" | "swipe" | "back" | "programmatic" | "outside-pointer";
|
|
14
|
+
type SwipeToCloseConfig = {
|
|
15
|
+
enabled?: boolean;
|
|
16
|
+
threshold?: number;
|
|
17
|
+
velocityThreshold?: number;
|
|
18
|
+
};
|
|
19
|
+
type OverlayMountTarget = HTMLElement | "body" | "parent";
|
|
20
|
+
/**
|
|
21
|
+
* Named overlay archetypes — bundle the common animation + dim + gesture
|
|
22
|
+
* combinations so consumers can opt into a "mode" without restating every
|
|
23
|
+
* field. Applied BEFORE individual options at construction, and as the
|
|
24
|
+
* first step of `setOverlay()` so individual overrides win.
|
|
25
|
+
*/
|
|
26
|
+
type OverlayPreset = "sheet" | "dialog" | "sidebar" | "toast";
|
|
27
|
+
type OverlayPresetConfig = {
|
|
28
|
+
enterAnimation: OverlayAnimation;
|
|
29
|
+
exitAnimation: OverlayAnimation;
|
|
30
|
+
backdropOpacity: number;
|
|
31
|
+
backdropFilter?: string;
|
|
32
|
+
swipeToClose: boolean | SwipeToCloseConfig;
|
|
33
|
+
};
|
|
34
|
+
declare const OVERLAY_PRESETS: Readonly<Record<OverlayPreset, Readonly<OverlayPresetConfig>>>;
|
|
35
|
+
/**
|
|
36
|
+
* Batch payload for `setOverlay()`. `null` on `backdropFilter` clears it
|
|
37
|
+
* (distinct from `undefined` which means "leave as-is" in the diff). Apply
|
|
38
|
+
* order: preset first, then individual overrides — single DOM-write phase
|
|
39
|
+
* if the overlay is currently open.
|
|
40
|
+
*/
|
|
41
|
+
type OverlayUpdate = {
|
|
42
|
+
backdropOpacity?: number;
|
|
43
|
+
backdropFilter?: string | null;
|
|
44
|
+
swipeToClose?: boolean | SwipeToCloseConfig;
|
|
45
|
+
enterAnimation?: OverlayAnimation;
|
|
46
|
+
exitAnimation?: OverlayAnimation;
|
|
47
|
+
preset?: OverlayPreset;
|
|
48
|
+
/**
|
|
49
|
+
* Runtime children swap. `null` clears the panel's contents. A function is
|
|
50
|
+
* called once to lazy-resolve dynamic content. Applied LAST in the batch so
|
|
51
|
+
* style mutations finish before the DOM swap.
|
|
52
|
+
*/
|
|
53
|
+
children?: HTMLElement | DocumentFragment | (() => HTMLElement | DocumentFragment) | null;
|
|
54
|
+
};
|
|
55
|
+
type OverlayOptions = {
|
|
56
|
+
/** The panel element — gets transform/opacity inline writes. */
|
|
57
|
+
element: HTMLElement;
|
|
58
|
+
/** Optional dimmed backdrop element. */
|
|
59
|
+
backdrop?: HTMLElement;
|
|
60
|
+
/** Edge the panel slides in from. Default: "bottom". */
|
|
61
|
+
edge?: OverlayEdge;
|
|
62
|
+
/** Open immediately on construction. Default: false. */
|
|
63
|
+
initialOpen?: boolean;
|
|
64
|
+
/** Listen for Escape key. Default: true. */
|
|
65
|
+
closeOnEscape?: boolean;
|
|
66
|
+
/** Tap on backdrop closes. Default: true. */
|
|
67
|
+
closeOnBackdrop?: boolean;
|
|
68
|
+
/** Trap Tab focus inside the panel. Default: true. */
|
|
69
|
+
focusTrap?: boolean;
|
|
70
|
+
/** Selector or HTMLElement focused on open. */
|
|
71
|
+
initialFocus?: string | HTMLElement;
|
|
72
|
+
/**
|
|
73
|
+
* Element to focus after close. By default the focus trap restores
|
|
74
|
+
* whatever was focused before open. Pass an element or a getter for
|
|
75
|
+
* explicit control (e.g. focus a status banner instead of the trigger).
|
|
76
|
+
*/
|
|
77
|
+
returnFocus?: HTMLElement | (() => HTMLElement | null);
|
|
78
|
+
/** Lock body scroll while open. Default: true. */
|
|
79
|
+
lockBodyScroll?: boolean;
|
|
80
|
+
/** Mark page siblings `inert` while open (full a11y modal). Default: false. */
|
|
81
|
+
inertSiblings?: boolean;
|
|
82
|
+
/** Push history state so Android back closes the overlay. Default: false. */
|
|
83
|
+
closeOnBack?: boolean;
|
|
84
|
+
/** Animation duration in ms. Default: 320. */
|
|
85
|
+
duration?: number;
|
|
86
|
+
/** CSS easing for the slide-in. Default matches monitoring's bezier. */
|
|
87
|
+
enterEasing?: string;
|
|
88
|
+
/** CSS easing for the slide-out. Default: ease-in. */
|
|
89
|
+
exitEasing?: string;
|
|
90
|
+
/**
|
|
91
|
+
* Peak backdrop opacity when open. Useful when `backdropFilter` blur
|
|
92
|
+
* already darkens enough and the dim should be light (e.g. 0.3).
|
|
93
|
+
* Default: 1.
|
|
94
|
+
*/
|
|
95
|
+
backdropOpacity?: number;
|
|
96
|
+
/**
|
|
97
|
+
* CSS `backdrop-filter` value applied to the backdrop while open
|
|
98
|
+
* (e.g. `"blur(8px)"`, `"blur(12px) saturate(140%)"`). Cleared on close.
|
|
99
|
+
*/
|
|
100
|
+
backdropFilter?: string;
|
|
101
|
+
/**
|
|
102
|
+
* Allow drag-to-dismiss along the entry edge — pointer-driven. The panel
|
|
103
|
+
* follows the finger past the closed-edge axis and dismisses if the user
|
|
104
|
+
* crosses 30% of the panel size or releases with > 0.5 px/ms velocity.
|
|
105
|
+
*
|
|
106
|
+
* Pass a config object to tune thresholds:
|
|
107
|
+
* `{ enabled: true, threshold: 0.5, velocityThreshold: 1.0 }`.
|
|
108
|
+
* Default: false (CSS-only transition).
|
|
109
|
+
*/
|
|
110
|
+
swipeToClose?: boolean | SwipeToCloseConfig;
|
|
111
|
+
/**
|
|
112
|
+
* Entry animation. `"slide"` (default) translates from the edge.
|
|
113
|
+
* `"fade"` is opacity-only (no transform). `"scale"` fades + scales
|
|
114
|
+
* from 0.94 — best for centred dialogs.
|
|
115
|
+
*/
|
|
116
|
+
enterAnimation?: OverlayAnimation;
|
|
117
|
+
/** Exit animation. Defaults to `enterAnimation`. */
|
|
118
|
+
exitAnimation?: OverlayAnimation;
|
|
119
|
+
/**
|
|
120
|
+
* Move `element` to a different container on first open. `'parent'`
|
|
121
|
+
* (default) leaves it in place. `'body'` appends to `document.body`.
|
|
122
|
+
* Pass an explicit `HTMLElement` for any other portal target.
|
|
123
|
+
*
|
|
124
|
+
* Restored to its original parent on `destroy()`. Move is deferred to
|
|
125
|
+
* first `open()` so SSR / pre-mount construction doesn't crash.
|
|
126
|
+
*/
|
|
127
|
+
mountTo?: OverlayMountTarget;
|
|
128
|
+
/**
|
|
129
|
+
* `peek` keeps part of the panel visible when closed instead of
|
|
130
|
+
* translating fully off-screen. Number is treated as pixels; strings
|
|
131
|
+
* accept any CSS length (`"10dvh"`, `"clamp(40px, 8vh, 80px)"`).
|
|
132
|
+
* Only honoured when `edge: 'bottom'` — warns and falls back otherwise.
|
|
133
|
+
*/
|
|
134
|
+
peek?: number | string;
|
|
135
|
+
/**
|
|
136
|
+
* Close when a pointerdown lands outside `element` AND outside `backdrop`.
|
|
137
|
+
* Distinct from `closeOnBackdrop` — this fires even when no backdrop is
|
|
138
|
+
* mounted. Single document-level listener, removed on close.
|
|
139
|
+
*/
|
|
140
|
+
closeOnOutsidePointer?: boolean;
|
|
141
|
+
/**
|
|
142
|
+
* Named archetype — bundles `enterAnimation`/`exitAnimation`/
|
|
143
|
+
* `backdropOpacity`/`backdropFilter`/`swipeToClose` defaults. Applied
|
|
144
|
+
* BEFORE the individual options on this object, so any explicit field
|
|
145
|
+
* still wins over the preset's default.
|
|
146
|
+
*/
|
|
147
|
+
preset?: OverlayPreset;
|
|
148
|
+
/** Lifecycle callbacks. */
|
|
149
|
+
onOpen?: () => void;
|
|
150
|
+
onClose?: () => void;
|
|
151
|
+
};
|
|
152
|
+
type OverlayState = {
|
|
153
|
+
isOpen: boolean;
|
|
154
|
+
isAnimating: boolean;
|
|
155
|
+
};
|
|
156
|
+
type OverlayEventMap = {
|
|
157
|
+
open: void;
|
|
158
|
+
close: {
|
|
159
|
+
reason: OverlayCloseReason;
|
|
160
|
+
};
|
|
161
|
+
"before-open": void;
|
|
162
|
+
"before-close": void;
|
|
163
|
+
};
|
|
164
|
+
type Listener<K extends keyof OverlayEventMap> = (payload: OverlayEventMap[K]) => void;
|
|
165
|
+
declare class OverlayEngine {
|
|
166
|
+
private id;
|
|
167
|
+
private element;
|
|
168
|
+
private backdrop?;
|
|
169
|
+
private edge;
|
|
170
|
+
private closeOnEscape;
|
|
171
|
+
private closeOnBackdropEnabled;
|
|
172
|
+
private focusTrapEnabled;
|
|
173
|
+
private initialFocus?;
|
|
174
|
+
private bodyScrollLockEnabled;
|
|
175
|
+
private inertSiblingsEnabled;
|
|
176
|
+
private closeOnBackEnabled;
|
|
177
|
+
private duration;
|
|
178
|
+
private enterEasing;
|
|
179
|
+
private exitEasing;
|
|
180
|
+
private backdropOpacity;
|
|
181
|
+
private backdropFilter?;
|
|
182
|
+
private swipeToCloseEnabled;
|
|
183
|
+
private swipeThreshold;
|
|
184
|
+
private swipeVelocityThreshold;
|
|
185
|
+
private enterAnimation;
|
|
186
|
+
private exitAnimation;
|
|
187
|
+
private mountTarget?;
|
|
188
|
+
private originalParent;
|
|
189
|
+
private originalNextSibling;
|
|
190
|
+
private mounted;
|
|
191
|
+
private peekRaw?;
|
|
192
|
+
private peekPx?;
|
|
193
|
+
private closeOnOutsidePointerEnabled;
|
|
194
|
+
private detachOutsidePointer;
|
|
195
|
+
private detachSwipe;
|
|
196
|
+
private onOpenCb?;
|
|
197
|
+
private onCloseCb?;
|
|
198
|
+
private isOpen_;
|
|
199
|
+
private isAnimating_;
|
|
200
|
+
private destroyed;
|
|
201
|
+
private hasInjectedChildren;
|
|
202
|
+
private cycleNonce;
|
|
203
|
+
private bus;
|
|
204
|
+
private detachEscape;
|
|
205
|
+
private detachBackdrop;
|
|
206
|
+
private detachHardwareBack;
|
|
207
|
+
private releaseStackEntry;
|
|
208
|
+
private lifecycle;
|
|
209
|
+
constructor(opts: OverlayOptions);
|
|
210
|
+
get state(): OverlayState;
|
|
211
|
+
on<K extends keyof OverlayEventMap>(event: K, fn: Listener<K>): () => void;
|
|
212
|
+
open(): Promise<void>;
|
|
213
|
+
close(reason?: OverlayCloseReason): Promise<void>;
|
|
214
|
+
toggle(): Promise<void>;
|
|
215
|
+
destroy(): void;
|
|
216
|
+
/**
|
|
217
|
+
* Runtime visual setter — opacity is applied immediately when open so a
|
|
218
|
+
* live-controls panel can preview the change without re-opening. When
|
|
219
|
+
* closed we only stash the field; next open() picks it up so we don't
|
|
220
|
+
* mutate hidden DOM (avoids paint thrash on detached panels).
|
|
221
|
+
*/
|
|
222
|
+
setBackdropOpacity(opacity: number): void;
|
|
223
|
+
/**
|
|
224
|
+
* Runtime visual setter for `backdrop-filter`. `undefined` clears the
|
|
225
|
+
* filter (mirrors the close() behaviour). Defers to next open() when the
|
|
226
|
+
* overlay is currently closed.
|
|
227
|
+
*/
|
|
228
|
+
setBackdropFilter(filter: string | undefined): void;
|
|
229
|
+
/**
|
|
230
|
+
* Toggle / reconfigure swipe-to-close at runtime. Re-resolves the flat
|
|
231
|
+
* threshold fields, then installs or tears down the pointer listener so
|
|
232
|
+
* the change applies to the CURRENT open cycle. Idempotent: safe to call
|
|
233
|
+
* with the same config repeatedly.
|
|
234
|
+
*/
|
|
235
|
+
setSwipeToClose(config: boolean | SwipeToCloseConfig): void;
|
|
236
|
+
/** Animation setters only stage the field — applied on next open/close. */
|
|
237
|
+
setEnterAnimation(animation: OverlayAnimation): void;
|
|
238
|
+
setExitAnimation(animation: OverlayAnimation): void;
|
|
239
|
+
/** Updates the field used at next close() — no immediate side effect. */
|
|
240
|
+
setReturnFocus(target: HTMLElement | (() => HTMLElement | null) | undefined): void;
|
|
241
|
+
/**
|
|
242
|
+
* Batch update — preset first, then individual overrides. Applied as a
|
|
243
|
+
* single DOM-write phase when open so live-controls don't trigger
|
|
244
|
+
* cascading reflows. Safe to call when closed (defers to next open).
|
|
245
|
+
*/
|
|
246
|
+
setOverlay(opts: OverlayUpdate): void;
|
|
247
|
+
/**
|
|
248
|
+
* Runtime children injection — replace the panel's contents without
|
|
249
|
+
* unmounting the engine. `replaceChildren()` is a single atomic DOM op,
|
|
250
|
+
* so callers can swap content rapidly without intermediate flicker.
|
|
251
|
+
* Function form is resolved exactly ONCE per call (cheap lazy content).
|
|
252
|
+
*/
|
|
253
|
+
setOverlayChildren(children: HTMLElement | DocumentFragment | (() => HTMLElement | DocumentFragment)): void;
|
|
254
|
+
/**
|
|
255
|
+
* Clear injected children. No-op when nothing was injected so consumers
|
|
256
|
+
* who never used setOverlayChildren can call this defensively without
|
|
257
|
+
* paying for a DOM mutation.
|
|
258
|
+
*/
|
|
259
|
+
clearOverlayChildren(): void;
|
|
260
|
+
private assignSwipeFromConfig;
|
|
261
|
+
private emit;
|
|
262
|
+
private resolvePeekPx;
|
|
263
|
+
private maybeMount;
|
|
264
|
+
private restoreMount;
|
|
265
|
+
private applyClosedStyles;
|
|
266
|
+
private awaitTransition;
|
|
267
|
+
private installInteractiveListeners;
|
|
268
|
+
private releaseInteractiveListeners;
|
|
269
|
+
/**
|
|
270
|
+
* Light pointer-driven dismiss. Tracks finger along the edge axis, follows
|
|
271
|
+
* with translate, dismisses if past `swipeThreshold` (fraction of panel
|
|
272
|
+
* size) or release velocity exceeds `swipeVelocityThreshold` (px/ms).
|
|
273
|
+
* Pure CSS-transform during drag — no rAF or physics required since the
|
|
274
|
+
* panel only moves one direction.
|
|
275
|
+
*/
|
|
276
|
+
private installSwipeToClose;
|
|
277
|
+
private registerInStack;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
declare const createOverlay: (opts: OverlayOptions) => OverlayEngine;
|
|
281
|
+
|
|
282
|
+
export { OVERLAY_PRESETS, OverlayEngine as Overlay, type OverlayAnimation, type OverlayCloseReason, type OverlayEdge, OverlayEngine, type OverlayEventMap, type OverlayMountTarget, type OverlayOptions, type OverlayPreset, type OverlayState, type OverlayUpdate, type SwipeToCloseConfig, createOverlay };
|