@surdeddd/bottom-sheet 0.1.0 → 0.2.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/README.md +6 -0
- package/dist/BottomSheetEngine-CIT9Htti.d.cts +219 -0
- package/dist/BottomSheetEngine-Df9MwBbm.d.ts +219 -0
- package/dist/element.cjs +95 -440
- package/dist/element.d.cts +3 -56
- package/dist/element.d.ts +3 -56
- package/dist/element.iife.global.js +2 -2
- package/dist/element.js +95 -440
- package/dist/index.cjs +84 -494
- package/dist/index.d.cts +3 -84
- package/dist/index.d.ts +3 -84
- package/dist/index.js +84 -494
- package/dist/integrations/formik.d.cts +2 -8
- package/dist/integrations/formik.d.ts +2 -8
- package/dist/integrations/react-hook-form.d.cts +2 -11
- package/dist/integrations/react-hook-form.d.ts +2 -11
- package/dist/overlay.cjs +0 -87
- package/dist/overlay.d.cts +1 -137
- package/dist/overlay.d.ts +1 -137
- package/dist/overlay.js +0 -87
- package/dist/preact.d.cts +2 -2
- package/dist/preact.d.ts +2 -2
- package/dist/preact.js +0 -1
- package/dist/qwik.cjs +87 -439
- package/dist/qwik.d.cts +3 -24
- package/dist/qwik.d.ts +3 -24
- package/dist/qwik.js +87 -439
- package/dist/react.cjs +91 -496
- package/dist/react.d.cts +16 -158
- package/dist/react.d.ts +16 -158
- package/dist/react.js +91 -496
- package/dist/solid.cjs +87 -439
- package/dist/solid.d.cts +4 -31
- package/dist/solid.d.ts +4 -31
- package/dist/solid.js +87 -439
- package/dist/styles.css +27 -102
- package/dist/svelte.cjs +139 -462
- package/dist/svelte.d.ts +9 -2
- package/dist/svelte.js +139 -462
- package/dist/themes/ios.css +0 -3
- package/dist/themes/material.css +0 -3
- package/dist/themes/vercel.css +0 -3
- package/dist/{transform-Brkf-wzo.d.cts → transform-jVfAikE9.d.cts} +0 -1
- package/dist/{transform-Brkf-wzo.d.ts → transform-jVfAikE9.d.ts} +0 -1
- package/dist/vue.cjs +104 -446
- package/dist/vue.d.ts +7 -1
- package/dist/vue.js +105 -447
- package/package.json +3 -3
- package/dist/BottomSheetEngine-CvSVbo6c.d.cts +0 -704
- package/dist/BottomSheetEngine-DbO8rW_3.d.ts +0 -704
package/dist/overlay.d.ts
CHANGED
|
@@ -1,13 +1,5 @@
|
|
|
1
|
-
import { T as TransformAxis } from './transform-
|
|
1
|
+
import { T as TransformAxis } from './transform-jVfAikE9.js';
|
|
2
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
3
|
type OverlayEdge = TransformAxis;
|
|
12
4
|
type OverlayAnimation = "slide" | "fade" | "scale";
|
|
13
5
|
type OverlayCloseReason = "escape" | "backdrop" | "swipe" | "back" | "programmatic" | "outside-pointer";
|
|
@@ -17,12 +9,6 @@ type SwipeToCloseConfig = {
|
|
|
17
9
|
velocityThreshold?: number;
|
|
18
10
|
};
|
|
19
11
|
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
12
|
type OverlayPreset = "sheet" | "dialog" | "sidebar" | "toast";
|
|
27
13
|
type OverlayPresetConfig = {
|
|
28
14
|
enterAnimation: OverlayAnimation;
|
|
@@ -32,12 +18,6 @@ type OverlayPresetConfig = {
|
|
|
32
18
|
swipeToClose: boolean | SwipeToCloseConfig;
|
|
33
19
|
};
|
|
34
20
|
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
21
|
type OverlayUpdate = {
|
|
42
22
|
backdropOpacity?: number;
|
|
43
23
|
backdropFilter?: string | null;
|
|
@@ -45,107 +25,33 @@ type OverlayUpdate = {
|
|
|
45
25
|
enterAnimation?: OverlayAnimation;
|
|
46
26
|
exitAnimation?: OverlayAnimation;
|
|
47
27
|
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
28
|
children?: HTMLElement | DocumentFragment | (() => HTMLElement | DocumentFragment) | null;
|
|
54
29
|
};
|
|
55
30
|
type OverlayOptions = {
|
|
56
|
-
/** The panel element — gets transform/opacity inline writes. */
|
|
57
31
|
element: HTMLElement;
|
|
58
|
-
/** Optional dimmed backdrop element. */
|
|
59
32
|
backdrop?: HTMLElement;
|
|
60
|
-
/** Edge the panel slides in from. Default: "bottom". */
|
|
61
33
|
edge?: OverlayEdge;
|
|
62
|
-
/** Open immediately on construction. Default: false. */
|
|
63
34
|
initialOpen?: boolean;
|
|
64
|
-
/** Listen for Escape key. Default: true. */
|
|
65
35
|
closeOnEscape?: boolean;
|
|
66
|
-
/** Tap on backdrop closes. Default: true. */
|
|
67
36
|
closeOnBackdrop?: boolean;
|
|
68
|
-
/** Trap Tab focus inside the panel. Default: true. */
|
|
69
37
|
focusTrap?: boolean;
|
|
70
|
-
/** Selector or HTMLElement focused on open. */
|
|
71
38
|
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
39
|
returnFocus?: HTMLElement | (() => HTMLElement | null);
|
|
78
|
-
/** Lock body scroll while open. Default: true. */
|
|
79
40
|
lockBodyScroll?: boolean;
|
|
80
|
-
/** Mark page siblings `inert` while open (full a11y modal). Default: false. */
|
|
81
41
|
inertSiblings?: boolean;
|
|
82
|
-
/** Push history state so Android back closes the overlay. Default: false. */
|
|
83
42
|
closeOnBack?: boolean;
|
|
84
|
-
/** Animation duration in ms. Default: 320. */
|
|
85
43
|
duration?: number;
|
|
86
|
-
/** CSS easing for the slide-in. Default matches monitoring's bezier. */
|
|
87
44
|
enterEasing?: string;
|
|
88
|
-
/** CSS easing for the slide-out. Default: ease-in. */
|
|
89
45
|
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
46
|
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
47
|
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
48
|
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
49
|
enterAnimation?: OverlayAnimation;
|
|
117
|
-
/** Exit animation. Defaults to `enterAnimation`. */
|
|
118
50
|
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
51
|
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
52
|
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
53
|
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
54
|
preset?: OverlayPreset;
|
|
148
|
-
/** Lifecycle callbacks. */
|
|
149
55
|
onOpen?: () => void;
|
|
150
56
|
onClose?: () => void;
|
|
151
57
|
};
|
|
@@ -213,49 +119,14 @@ declare class OverlayEngine {
|
|
|
213
119
|
close(reason?: OverlayCloseReason): Promise<void>;
|
|
214
120
|
toggle(): Promise<void>;
|
|
215
121
|
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
122
|
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
123
|
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
124
|
setSwipeToClose(config: boolean | SwipeToCloseConfig): void;
|
|
236
|
-
/** Animation setters only stage the field — applied on next open/close. */
|
|
237
125
|
setEnterAnimation(animation: OverlayAnimation): void;
|
|
238
126
|
setExitAnimation(animation: OverlayAnimation): void;
|
|
239
|
-
/** Updates the field used at next close() — no immediate side effect. */
|
|
240
127
|
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
128
|
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
129
|
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
130
|
clearOverlayChildren(): void;
|
|
260
131
|
private assignSwipeFromConfig;
|
|
261
132
|
private emit;
|
|
@@ -266,13 +137,6 @@ declare class OverlayEngine {
|
|
|
266
137
|
private awaitTransition;
|
|
267
138
|
private installInteractiveListeners;
|
|
268
139
|
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
140
|
private installSwipeToClose;
|
|
277
141
|
private registerInStack;
|
|
278
142
|
}
|
package/dist/overlay.js
CHANGED
|
@@ -280,12 +280,8 @@ var LifecycleController = class {
|
|
|
280
280
|
__publicField(this, "inertSiblings");
|
|
281
281
|
__publicField(this, "shouldApplyInertSiblings");
|
|
282
282
|
__publicField(this, "returnFocus");
|
|
283
|
-
/** Toggle-state teardowns — fire on close, NOT in destroy-only stack. */
|
|
284
283
|
__publicField(this, "releaseFocusTrap", null);
|
|
285
284
|
__publicField(this, "releaseScrollLock", null);
|
|
286
|
-
/** True between install() and release(). Guards release()/destroy() from
|
|
287
|
-
* re-running side effects (notably `returnFocus.focus()`) on already-
|
|
288
|
-
* released or never-installed instances. */
|
|
289
285
|
__publicField(this, "installed", false);
|
|
290
286
|
__publicField(this, "destroyed", false);
|
|
291
287
|
this.element = deps.element;
|
|
@@ -299,14 +295,6 @@ var LifecycleController = class {
|
|
|
299
295
|
this.returnFocus = opts.returnFocus;
|
|
300
296
|
this.inertSiblings = createInertSiblings(() => this.element);
|
|
301
297
|
}
|
|
302
|
-
/**
|
|
303
|
-
* Run the open-time install steps. Idempotent: each step checks its
|
|
304
|
-
* existing teardown ref so a re-open during a half-cancelled close
|
|
305
|
-
* doesn't double-install. Sets `installed=true` BEFORE the first side
|
|
306
|
-
* effect so a partial throw (detached / shadow-DOM target) leaves the
|
|
307
|
-
* caller's `release()` rollback path armed to undo whatever did succeed.
|
|
308
|
-
* No-op when destroyed.
|
|
309
|
-
*/
|
|
310
298
|
install() {
|
|
311
299
|
if (this.destroyed) return;
|
|
312
300
|
this.installed = true;
|
|
@@ -323,22 +311,10 @@ var LifecycleController = class {
|
|
|
323
311
|
this.inertSiblings.apply();
|
|
324
312
|
}
|
|
325
313
|
}
|
|
326
|
-
/**
|
|
327
|
-
* Update the post-release focus target. Overlay re-binds this when the
|
|
328
|
-
* consumer changes `returnFocus` after construction; the new value applies
|
|
329
|
-
* on the next `release()`. No-op when destroyed.
|
|
330
|
-
*/
|
|
331
314
|
setReturnFocus(target) {
|
|
332
315
|
if (this.destroyed) return;
|
|
333
316
|
this.returnFocus = target;
|
|
334
317
|
}
|
|
335
|
-
/**
|
|
336
|
-
* Release all install-time teardowns. Short-circuits when not installed,
|
|
337
|
-
* so `close() → destroy()` (each routing through here) only restores
|
|
338
|
-
* focus once. The `installed` guard lets `inertSiblings.remove()` and
|
|
339
|
-
* the focus-trap/scroll-lock teardown nullings stay simple — they were
|
|
340
|
-
* already idempotent, but `returnFocus.focus()` was firing on every call.
|
|
341
|
-
*/
|
|
342
318
|
release() {
|
|
343
319
|
if (!this.installed) return;
|
|
344
320
|
this.installed = false;
|
|
@@ -352,12 +328,6 @@ var LifecycleController = class {
|
|
|
352
328
|
target?.focus?.();
|
|
353
329
|
}
|
|
354
330
|
}
|
|
355
|
-
/**
|
|
356
|
-
* Final teardown — releases any still-installed listeners and seals the
|
|
357
|
-
* controller. After destroy(), install() is a no-op and setReturnFocus()
|
|
358
|
-
* is rejected, so post-destroy mutations can't queue up a stale focus
|
|
359
|
-
* restore.
|
|
360
|
-
*/
|
|
361
331
|
destroy() {
|
|
362
332
|
this.release();
|
|
363
333
|
this.destroyed = true;
|
|
@@ -429,8 +399,6 @@ var OverlayEngine = class {
|
|
|
429
399
|
__publicField(this, "exitEasing");
|
|
430
400
|
__publicField(this, "backdropOpacity");
|
|
431
401
|
__publicField(this, "backdropFilter");
|
|
432
|
-
// Definite-assignment: written via assignSwipeFromConfig in the
|
|
433
|
-
// constructor — TS can't follow the helper, mark the assertion explicit.
|
|
434
402
|
__publicField(this, "swipeToCloseEnabled");
|
|
435
403
|
__publicField(this, "swipeThreshold");
|
|
436
404
|
__publicField(this, "swipeVelocityThreshold");
|
|
@@ -450,13 +418,7 @@ var OverlayEngine = class {
|
|
|
450
418
|
__publicField(this, "isOpen_", false);
|
|
451
419
|
__publicField(this, "isAnimating_", false);
|
|
452
420
|
__publicField(this, "destroyed", false);
|
|
453
|
-
// Tracks whether setOverlayChildren ever populated the panel — lets
|
|
454
|
-
// clearOverlayChildren skip the DOM mutation when nothing was injected
|
|
455
|
-
// (so the field also acts as a zero-allocation feature flag).
|
|
456
421
|
__publicField(this, "hasInjectedChildren", false);
|
|
457
|
-
// Bumped on every open/close. awaitTransition captures it and ignores
|
|
458
|
-
// transitionend/timeout fired by older cycles — prevents cross-cycle
|
|
459
|
-
// listener bleed during rapid toggling.
|
|
460
422
|
__publicField(this, "cycleNonce", 0);
|
|
461
423
|
__publicField(this, "bus", createEventBus());
|
|
462
424
|
__publicField(this, "detachEscape", null);
|
|
@@ -509,9 +471,6 @@ var OverlayEngine = class {
|
|
|
509
471
|
closeOnEscape: this.closeOnEscape,
|
|
510
472
|
lockBodyScroll: this.bodyScrollLockEnabled,
|
|
511
473
|
inertSiblings: this.inertSiblingsEnabled,
|
|
512
|
-
// Overlay-specific guard: only paint body siblings inert when the
|
|
513
|
-
// overlay element is actually a body descendant. Detached / shadow-
|
|
514
|
-
// DOM / portal overlays would otherwise lock unrelated trees.
|
|
515
474
|
shouldApplyInertSiblings: () => {
|
|
516
475
|
const bodyChildren = Array.from(document.body.children);
|
|
517
476
|
return bodyChildren.some(
|
|
@@ -665,12 +624,6 @@ var OverlayEngine = class {
|
|
|
665
624
|
this.releaseStackEntry = null;
|
|
666
625
|
this.restoreMount();
|
|
667
626
|
}
|
|
668
|
-
/**
|
|
669
|
-
* Runtime visual setter — opacity is applied immediately when open so a
|
|
670
|
-
* live-controls panel can preview the change without re-opening. When
|
|
671
|
-
* closed we only stash the field; next open() picks it up so we don't
|
|
672
|
-
* mutate hidden DOM (avoids paint thrash on detached panels).
|
|
673
|
-
*/
|
|
674
627
|
setBackdropOpacity(opacity) {
|
|
675
628
|
if (this.destroyed) return;
|
|
676
629
|
this.backdropOpacity = opacity;
|
|
@@ -678,11 +631,6 @@ var OverlayEngine = class {
|
|
|
678
631
|
this.backdrop.style.opacity = String(opacity);
|
|
679
632
|
}
|
|
680
633
|
}
|
|
681
|
-
/**
|
|
682
|
-
* Runtime visual setter for `backdrop-filter`. `undefined` clears the
|
|
683
|
-
* filter (mirrors the close() behaviour). Defers to next open() when the
|
|
684
|
-
* overlay is currently closed.
|
|
685
|
-
*/
|
|
686
634
|
setBackdropFilter(filter) {
|
|
687
635
|
if (this.destroyed) return;
|
|
688
636
|
this.backdropFilter = filter;
|
|
@@ -696,12 +644,6 @@ var OverlayEngine = class {
|
|
|
696
644
|
style.webkitBackdropFilter = "";
|
|
697
645
|
}
|
|
698
646
|
}
|
|
699
|
-
/**
|
|
700
|
-
* Toggle / reconfigure swipe-to-close at runtime. Re-resolves the flat
|
|
701
|
-
* threshold fields, then installs or tears down the pointer listener so
|
|
702
|
-
* the change applies to the CURRENT open cycle. Idempotent: safe to call
|
|
703
|
-
* with the same config repeatedly.
|
|
704
|
-
*/
|
|
705
647
|
setSwipeToClose(config) {
|
|
706
648
|
if (this.destroyed) return;
|
|
707
649
|
const wasEnabled = this.swipeToCloseEnabled;
|
|
@@ -714,7 +656,6 @@ var OverlayEngine = class {
|
|
|
714
656
|
this.detachSwipe = null;
|
|
715
657
|
}
|
|
716
658
|
}
|
|
717
|
-
/** Animation setters only stage the field — applied on next open/close. */
|
|
718
659
|
setEnterAnimation(animation) {
|
|
719
660
|
if (this.destroyed) return;
|
|
720
661
|
this.enterAnimation = animation;
|
|
@@ -723,23 +664,15 @@ var OverlayEngine = class {
|
|
|
723
664
|
if (this.destroyed) return;
|
|
724
665
|
this.exitAnimation = animation;
|
|
725
666
|
}
|
|
726
|
-
/** Updates the field used at next close() — no immediate side effect. */
|
|
727
667
|
setReturnFocus(target) {
|
|
728
668
|
if (this.destroyed) return;
|
|
729
669
|
this.lifecycle.setReturnFocus(target);
|
|
730
670
|
}
|
|
731
|
-
/**
|
|
732
|
-
* Batch update — preset first, then individual overrides. Applied as a
|
|
733
|
-
* single DOM-write phase when open so live-controls don't trigger
|
|
734
|
-
* cascading reflows. Safe to call when closed (defers to next open).
|
|
735
|
-
*/
|
|
736
671
|
setOverlay(opts) {
|
|
737
672
|
if (this.destroyed) return;
|
|
738
673
|
const preset = opts.preset ? OVERLAY_PRESETS[opts.preset] : void 0;
|
|
739
674
|
const merged = preset ? {
|
|
740
675
|
backdropOpacity: preset.backdropOpacity,
|
|
741
|
-
// Preset's `undefined` filter means "no filter" — surface as null
|
|
742
|
-
// so the merged step clears the field instead of inheriting old.
|
|
743
676
|
backdropFilter: preset.backdropFilter === void 0 ? null : preset.backdropFilter,
|
|
744
677
|
swipeToClose: preset.swipeToClose,
|
|
745
678
|
enterAnimation: preset.enterAnimation,
|
|
@@ -798,30 +731,17 @@ var OverlayEngine = class {
|
|
|
798
731
|
}
|
|
799
732
|
}
|
|
800
733
|
}
|
|
801
|
-
/**
|
|
802
|
-
* Runtime children injection — replace the panel's contents without
|
|
803
|
-
* unmounting the engine. `replaceChildren()` is a single atomic DOM op,
|
|
804
|
-
* so callers can swap content rapidly without intermediate flicker.
|
|
805
|
-
* Function form is resolved exactly ONCE per call (cheap lazy content).
|
|
806
|
-
*/
|
|
807
734
|
setOverlayChildren(children) {
|
|
808
735
|
if (this.destroyed) return;
|
|
809
736
|
const node = typeof children === "function" ? children() : children;
|
|
810
737
|
this.element.replaceChildren(node);
|
|
811
738
|
this.hasInjectedChildren = true;
|
|
812
739
|
}
|
|
813
|
-
/**
|
|
814
|
-
* Clear injected children. No-op when nothing was injected so consumers
|
|
815
|
-
* who never used setOverlayChildren can call this defensively without
|
|
816
|
-
* paying for a DOM mutation.
|
|
817
|
-
*/
|
|
818
740
|
clearOverlayChildren() {
|
|
819
741
|
if (this.destroyed || !this.hasInjectedChildren) return;
|
|
820
742
|
this.element.replaceChildren();
|
|
821
743
|
this.hasInjectedChildren = false;
|
|
822
744
|
}
|
|
823
|
-
// Shared swipe-config normalizer — used by constructor, setSwipeToClose,
|
|
824
|
-
// and setOverlay so the union/object shape is decoded in exactly one place.
|
|
825
745
|
assignSwipeFromConfig(swipe) {
|
|
826
746
|
if (typeof swipe === "object" && swipe !== null) {
|
|
827
747
|
this.swipeToCloseEnabled = swipe.enabled ?? true;
|
|
@@ -965,13 +885,6 @@ var OverlayEngine = class {
|
|
|
965
885
|
this.detachOutsidePointer = null;
|
|
966
886
|
this.lifecycle.release();
|
|
967
887
|
}
|
|
968
|
-
/**
|
|
969
|
-
* Light pointer-driven dismiss. Tracks finger along the edge axis, follows
|
|
970
|
-
* with translate, dismisses if past `swipeThreshold` (fraction of panel
|
|
971
|
-
* size) or release velocity exceeds `swipeVelocityThreshold` (px/ms).
|
|
972
|
-
* Pure CSS-transform during drag — no rAF or physics required since the
|
|
973
|
-
* panel only moves one direction.
|
|
974
|
-
*/
|
|
975
888
|
installSwipeToClose() {
|
|
976
889
|
const el = this.element;
|
|
977
890
|
const edge = this.edge;
|
package/dist/preact.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { BottomSheet, BottomSheetFromConfig, BottomSheetFromConfigProps, BottomSheetHandle, BottomSheetProps, HeaderProp, Overlay, OverlayHandle, OverlayProps, SheetConfig, UseBottomSheetRefs, UseBottomSheetReturn, UseOverlayReturn, useBottomSheet, useOverlay } from './react.cjs';
|
|
2
|
-
export { E as EngineState, a as SheetMode, c as SnapPoint, S as SnapPointDef } from './BottomSheetEngine-
|
|
2
|
+
export { E as EngineState, a as SheetMode, c as SnapPoint, S as SnapPointDef } from './BottomSheetEngine-CIT9Htti.cjs';
|
|
3
3
|
export { OverlayEdge, OverlayOptions, OverlayState } from './overlay.cjs';
|
|
4
4
|
import 'react';
|
|
5
|
-
import './transform-
|
|
5
|
+
import './transform-jVfAikE9.cjs';
|
package/dist/preact.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { BottomSheet, BottomSheetFromConfig, BottomSheetFromConfigProps, BottomSheetHandle, BottomSheetProps, HeaderProp, Overlay, OverlayHandle, OverlayProps, SheetConfig, UseBottomSheetRefs, UseBottomSheetReturn, UseOverlayReturn, useBottomSheet, useOverlay } from './react.js';
|
|
2
|
-
export { E as EngineState, a as SheetMode, c as SnapPoint, S as SnapPointDef } from './BottomSheetEngine-
|
|
2
|
+
export { E as EngineState, a as SheetMode, c as SnapPoint, S as SnapPointDef } from './BottomSheetEngine-Df9MwBbm.js';
|
|
3
3
|
export { OverlayEdge, OverlayOptions, OverlayState } from './overlay.js';
|
|
4
4
|
import 'react';
|
|
5
|
-
import './transform-
|
|
5
|
+
import './transform-jVfAikE9.js';
|
package/dist/preact.js
CHANGED