@surdeddd/bottom-sheet 0.2.0 → 0.4.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 +51 -21
- package/dist/{BottomSheetEngine-CIT9Htti.d.cts → BottomSheetEngine-BJrH7qY3.d.cts} +105 -3
- package/dist/{BottomSheetEngine-Df9MwBbm.d.ts → BottomSheetEngine-L05jGZvU.d.ts} +105 -3
- package/dist/element.cjs +1170 -196
- package/dist/element.d.cts +29 -5
- package/dist/element.d.ts +29 -5
- package/dist/element.iife.global.js +2 -2
- package/dist/element.js +1170 -196
- package/dist/index.cjs +1051 -220
- package/dist/index.d.cts +18 -3
- package/dist/index.d.ts +18 -3
- package/dist/index.js +1049 -221
- package/dist/integrations/formik.d.cts +1 -1
- package/dist/integrations/formik.d.ts +1 -1
- package/dist/integrations/react-hook-form.d.cts +1 -1
- package/dist/integrations/react-hook-form.d.ts +1 -1
- package/dist/overlay.cjs +181 -37
- package/dist/overlay.d.cts +13 -0
- package/dist/overlay.d.ts +13 -0
- package/dist/overlay.js +181 -37
- package/dist/preact.d.cts +1 -1
- package/dist/preact.d.ts +1 -1
- package/dist/qwik.cjs +966 -195
- package/dist/qwik.d.cts +4 -2
- package/dist/qwik.d.ts +4 -2
- package/dist/qwik.js +967 -196
- package/dist/react.cjs +1242 -272
- package/dist/react.d.cts +47 -5
- package/dist/react.d.ts +47 -5
- package/dist/react.js +1242 -272
- package/dist/solid.cjs +992 -236
- package/dist/solid.d.cts +299 -4
- package/dist/solid.d.ts +299 -4
- package/dist/solid.js +993 -237
- package/dist/solid.source.jsx +3476 -0
- package/dist/styles.css +67 -66
- package/dist/svelte-core.cjs +3415 -0
- package/dist/svelte-core.js +3413 -0
- package/dist/svelte-src/BottomSheet.svelte +308 -0
- package/dist/svelte-src/index.js +2 -0
- package/dist/svelte.cjs +1034 -207
- package/dist/svelte.d.cts +121 -0
- package/dist/svelte.d.ts +28 -3
- package/dist/svelte.js +1035 -208
- package/dist/vue.cjs +1191 -205
- package/dist/vue.d.cts +127 -0
- package/dist/vue.d.ts +57 -4
- package/dist/vue.js +1192 -206
- package/package.json +105 -45
package/README.md
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
> Universal, headless bottom-sheet engine. **One core, eight adapters, GPU-accelerated, fully tested.**
|
|
4
4
|
|
|
5
|
-

|
|
6
|
+

|
|
7
7
|

|
|
8
8
|

|
|
9
9
|
|
|
@@ -47,7 +47,7 @@ stacking — and the exact same engine behind every adapter.
|
|
|
47
47
|
| WCAG 2.1 AA keyboard slider | partial | — | **✓** |
|
|
48
48
|
| Multi-sheet stacking | — | — | **✓** |
|
|
49
49
|
| Sheet-manager registry (typed) | — | — | **✓** |
|
|
50
|
-
| Tests (unit + e2e) | partial | partial | **
|
|
50
|
+
| Tests (unit + e2e) | partial | partial | **392 + 164** |
|
|
51
51
|
|
|
52
52
|
## Install
|
|
53
53
|
|
|
@@ -170,7 +170,7 @@ Drop-in usage from a static HTML page. The IIFE bundle registers
|
|
|
170
170
|
rel="stylesheet"
|
|
171
171
|
href="https://unpkg.com/@surdeddd/bottom-sheet/dist/styles.css"
|
|
172
172
|
/>
|
|
173
|
-
<script src="https://unpkg.com/@surdeddd/bottom-sheet/dist/element.iife.js"></script>
|
|
173
|
+
<script src="https://unpkg.com/@surdeddd/bottom-sheet/dist/element.iife.global.js"></script>
|
|
174
174
|
<bottom-sheet
|
|
175
175
|
snap-points='[{"id":"min","size":96},{"id":"full","size":"85%"}]'
|
|
176
176
|
initial="min"
|
|
@@ -217,23 +217,53 @@ type SnapPoint =
|
|
|
217
217
|
|
|
218
218
|
### Engine options
|
|
219
219
|
|
|
220
|
-
| Option | Default | What it does
|
|
221
|
-
| ---------------- | ------------- |
|
|
222
|
-
| `snapPoints` | required | Ordered list of `{ id, size }`
|
|
223
|
-
| `allowed` | all ids | Subset the sheet may settle on right now
|
|
224
|
-
| `initial` | first allowed | Snap id to start at
|
|
225
|
-
| `mode` | `"bottom"` | `bottom
|
|
226
|
-
| `animation` | `"spring"` | `spring
|
|
227
|
-
| `spring` | snappy | `{ stiffness, damping, mass }`
|
|
228
|
-
| `flickVelocity` | `0.65 px/ms` | Mobile flick threshold
|
|
229
|
-
| `dragThreshold` | `18 px` | Below this, drag snaps back
|
|
230
|
-
| `rubberBand` | `true` | iOS-style soft over-drag
|
|
231
|
-
| `backdropRange` | `[0, 1]` | Progress range over which backdrop fades
|
|
232
|
-
| `focusTrap` | `false` | Trap Tab focus inside the sheet when open
|
|
233
|
-
| `closeOnEscape` | `true` | Listen for Escape and close
|
|
234
|
-
| `closeOnBack` | `false` | Intercept Android back button (history.popstate)
|
|
235
|
-
| `lockBodyScroll` | `true` | iOS-safe body lock (`position: fixed`)
|
|
236
|
-
| `
|
|
220
|
+
| Option | Default | What it does |
|
|
221
|
+
| ---------------- | ------------- | ---------------------------------------------------------------------- |
|
|
222
|
+
| `snapPoints` | required | Ordered list of `{ id, size }` |
|
|
223
|
+
| `allowed` | all ids | Subset the sheet may settle on right now |
|
|
224
|
+
| `initial` | first allowed | Snap id to start at |
|
|
225
|
+
| `mode` | `"bottom"` | `bottom`, `top`, `left`, `right` |
|
|
226
|
+
| `animation` | `"spring"` | `spring`, `tween`, `ios-spring`, `material-bounce`, `linear`, `snappy` |
|
|
227
|
+
| `spring` | snappy | `{ stiffness, damping, mass }` |
|
|
228
|
+
| `flickVelocity` | `0.65 px/ms` | Mobile flick threshold |
|
|
229
|
+
| `dragThreshold` | `18 px` | Below this, drag snaps back |
|
|
230
|
+
| `rubberBand` | `true` | iOS-style soft over-drag |
|
|
231
|
+
| `backdropRange` | `[0, 1]` | Progress range over which backdrop fades |
|
|
232
|
+
| `focusTrap` | `false` | Trap Tab focus inside the sheet when open |
|
|
233
|
+
| `closeOnEscape` | `true` | Listen for Escape and close |
|
|
234
|
+
| `closeOnBack` | `false` | Intercept Android back button (history.popstate) |
|
|
235
|
+
| `lockBodyScroll` | `true` | iOS-safe body lock (`position: fixed`) |
|
|
236
|
+
| `stackEffect` | `false` | iOS card-stack: back sheets scale down per depth |
|
|
237
|
+
| `inertSiblings` | `false` | Mark page siblings `inert` while open (full modal) |
|
|
238
|
+
|
|
239
|
+
### Anchored elements, docked bars & scrim stages
|
|
240
|
+
|
|
241
|
+
Pin UI around the sheet — it rides the motion on the compositor (zero JS per
|
|
242
|
+
frame) and shows/hides per state with configurable animations:
|
|
243
|
+
|
|
244
|
+
```ts
|
|
245
|
+
engine.addAnchor({
|
|
246
|
+
element: closeBtn,
|
|
247
|
+
position: 'sheet-top-right', // rides the sheet edge; 9 screen positions too
|
|
248
|
+
showOn: ['half', 'full'], // snap ids or a predicate
|
|
249
|
+
animation: 'pop', // fade | scale | slide | pop | custom keyframes
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
engine.addAnchor({
|
|
253
|
+
element: tabBar,
|
|
254
|
+
position: 'dock-bottom', // full-width bar; the sheet slides under it
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
engine.setScrimStages({
|
|
258
|
+
stages: [
|
|
259
|
+
{ for: 'peek', element: teaser },
|
|
260
|
+
{ forRange: [0.5, 1], element: expanded },
|
|
261
|
+
],
|
|
262
|
+
animation: 'fade',
|
|
263
|
+
});
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
[Full anchors & stages docs →](docs/anchors.md)
|
|
237
267
|
|
|
238
268
|
### Events
|
|
239
269
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { T as TransformAxis } from './transform-jVfAikE9.cjs';
|
|
2
2
|
|
|
3
|
-
type SnapPoint = number | `${number}%` | "fit" | "full" | (string & {});
|
|
3
|
+
type SnapPoint = number | `${number}%` | "fit" | "content" | "full" | (string & {});
|
|
4
4
|
type SnapPointDef<Id extends string = string> = {
|
|
5
5
|
id: Id;
|
|
6
6
|
size: SnapPoint;
|
|
@@ -43,9 +43,14 @@ type SheetEventMap = {
|
|
|
43
43
|
cancel: () => void;
|
|
44
44
|
previousId: string;
|
|
45
45
|
};
|
|
46
|
+
"before-close": {
|
|
47
|
+
reason: "programmatic" | "backdrop" | "escape" | "back";
|
|
48
|
+
cancel: () => void;
|
|
49
|
+
};
|
|
46
50
|
snap: {
|
|
47
51
|
id: string;
|
|
48
52
|
size: number;
|
|
53
|
+
progress: number;
|
|
49
54
|
};
|
|
50
55
|
progress: {
|
|
51
56
|
value: number;
|
|
@@ -66,7 +71,12 @@ type SheetEventMap = {
|
|
|
66
71
|
open: {
|
|
67
72
|
id: string;
|
|
68
73
|
};
|
|
74
|
+
opened: {
|
|
75
|
+
id: string;
|
|
76
|
+
};
|
|
77
|
+
closed: undefined;
|
|
69
78
|
};
|
|
79
|
+
type CloseReason = "programmatic" | "backdrop" | "escape" | "back";
|
|
70
80
|
type EngineOptions = {
|
|
71
81
|
element: HTMLElement;
|
|
72
82
|
handle?: HTMLElement;
|
|
@@ -105,10 +115,18 @@ type EngineOptions = {
|
|
|
105
115
|
closeOnBack?: boolean;
|
|
106
116
|
routedTo?: string;
|
|
107
117
|
inertSiblings?: boolean;
|
|
118
|
+
persistent?: boolean;
|
|
119
|
+
disableClose?: boolean;
|
|
120
|
+
disableDrag?: boolean;
|
|
121
|
+
closeOnRouteChange?: boolean;
|
|
122
|
+
radius?: string | number;
|
|
123
|
+
maxHeight?: string | number;
|
|
124
|
+
returnFocusTo?: HTMLElement | string | (() => HTMLElement | null);
|
|
108
125
|
persistKey?: string;
|
|
109
126
|
autoCollapseAfter?: number;
|
|
110
127
|
linkedSheets?: BottomSheetEngineLike[];
|
|
111
128
|
viewTransitions?: boolean;
|
|
129
|
+
stackEffect?: boolean;
|
|
112
130
|
};
|
|
113
131
|
|
|
114
132
|
type BottomSheetEngineLike = BottomSheetEngine;
|
|
@@ -127,6 +145,60 @@ type EngineState = {
|
|
|
127
145
|
progress: number;
|
|
128
146
|
};
|
|
129
147
|
|
|
148
|
+
type AnchorAnimationPreset = "fade" | "scale" | "slide" | "pop" | "none";
|
|
149
|
+
type AnchorAnimationSpec = AnchorAnimationPreset | {
|
|
150
|
+
preset?: AnchorAnimationPreset;
|
|
151
|
+
enter?: Keyframe[];
|
|
152
|
+
exit?: Keyframe[];
|
|
153
|
+
duration?: number;
|
|
154
|
+
easing?: string;
|
|
155
|
+
respectReducedMotion?: boolean;
|
|
156
|
+
};
|
|
157
|
+
type AnchorTransitionHandle = {
|
|
158
|
+
finished: Promise<void>;
|
|
159
|
+
cancel: () => void;
|
|
160
|
+
};
|
|
161
|
+
declare function runAnchorTransition(el: HTMLElement, spec: AnchorAnimationSpec | undefined, phase: "enter" | "exit"): AnchorTransitionHandle;
|
|
162
|
+
|
|
163
|
+
type AnchorState = {
|
|
164
|
+
activeId: string;
|
|
165
|
+
size: number;
|
|
166
|
+
progress: number;
|
|
167
|
+
};
|
|
168
|
+
type AnchorPosition = ScrimOverlayPosition | "dock-bottom" | "dock-top";
|
|
169
|
+
type AnchorOptions = {
|
|
170
|
+
element: HTMLElement;
|
|
171
|
+
position?: AnchorPosition;
|
|
172
|
+
inset?: string;
|
|
173
|
+
showOn?: string[] | ((state: AnchorState) => boolean);
|
|
174
|
+
fadeRange?: [number, number];
|
|
175
|
+
interactive?: boolean;
|
|
176
|
+
animation?: AnchorAnimationSpec;
|
|
177
|
+
};
|
|
178
|
+
type AnchorHandle = {
|
|
179
|
+
wrapper: HTMLElement;
|
|
180
|
+
detach: () => void;
|
|
181
|
+
syncZ: (z: number) => void;
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
type ScrimStageDef = {
|
|
185
|
+
id?: string;
|
|
186
|
+
for?: string | string[];
|
|
187
|
+
forRange?: [number, number];
|
|
188
|
+
element: HTMLElement;
|
|
189
|
+
position?: ScrimOverlayPosition;
|
|
190
|
+
inset?: string;
|
|
191
|
+
interactive?: boolean;
|
|
192
|
+
animation?: AnchorAnimationSpec;
|
|
193
|
+
};
|
|
194
|
+
type ScrimStagesOptions = {
|
|
195
|
+
stages: ScrimStageDef[];
|
|
196
|
+
position?: ScrimOverlayPosition;
|
|
197
|
+
inset?: string;
|
|
198
|
+
interactive?: boolean;
|
|
199
|
+
animation?: AnchorAnimationSpec;
|
|
200
|
+
};
|
|
201
|
+
|
|
130
202
|
type Listener<K extends keyof SheetEventMap> = (payload: SheetEventMap[K]) => void;
|
|
131
203
|
declare class BottomSheetEngine {
|
|
132
204
|
private id;
|
|
@@ -146,6 +218,11 @@ declare class BottomSheetEngine {
|
|
|
146
218
|
private lifecycle;
|
|
147
219
|
private closeOnBack;
|
|
148
220
|
private routedTo;
|
|
221
|
+
private persistent;
|
|
222
|
+
private disableCloseFlag;
|
|
223
|
+
private disableDragFlag;
|
|
224
|
+
private closeOnRouteChange;
|
|
225
|
+
private maxHeightCap;
|
|
149
226
|
private snapPointsRaw;
|
|
150
227
|
private snaps;
|
|
151
228
|
private activeId;
|
|
@@ -158,6 +235,7 @@ declare class BottomSheetEngine {
|
|
|
158
235
|
private sizeWriteSentinel;
|
|
159
236
|
private progressWriteSentinel;
|
|
160
237
|
private isTopSheet;
|
|
238
|
+
private opening;
|
|
161
239
|
private progressPayload;
|
|
162
240
|
private dragContextBuf;
|
|
163
241
|
private bus;
|
|
@@ -165,6 +243,12 @@ declare class BottomSheetEngine {
|
|
|
165
243
|
private linkedSheets;
|
|
166
244
|
private scrollCache;
|
|
167
245
|
private teardowns;
|
|
246
|
+
private anchors;
|
|
247
|
+
private anchorHost;
|
|
248
|
+
private stackZ;
|
|
249
|
+
private detachScrimStages;
|
|
250
|
+
private stackEffectEnabled;
|
|
251
|
+
private stackEffectPrimed;
|
|
168
252
|
private transformTemplate;
|
|
169
253
|
constructor(opts: EngineOptions);
|
|
170
254
|
get state(): EngineState;
|
|
@@ -181,7 +265,15 @@ declare class BottomSheetEngine {
|
|
|
181
265
|
signal?: AbortSignal;
|
|
182
266
|
}): Promise<void>;
|
|
183
267
|
open(id?: string): Promise<void>;
|
|
184
|
-
close(): Promise<void>;
|
|
268
|
+
close(reason?: CloseReason): Promise<void>;
|
|
269
|
+
canDismiss(): boolean;
|
|
270
|
+
isTop(): boolean;
|
|
271
|
+
depth(): number;
|
|
272
|
+
expand(): Promise<void>;
|
|
273
|
+
collapse(): Promise<void>;
|
|
274
|
+
setRadius(r: string | number): void;
|
|
275
|
+
setMaxHeight(h: string | number): void;
|
|
276
|
+
private clampToMaxHeight;
|
|
185
277
|
setAllowed(ids: string[], snap?: string): void;
|
|
186
278
|
setBackdropRange(range: [number, number]): void;
|
|
187
279
|
setScreenRange(range: [number, number]): void;
|
|
@@ -193,19 +285,28 @@ declare class BottomSheetEngine {
|
|
|
193
285
|
setScrimTapToClose(enabled: boolean): void;
|
|
194
286
|
setScrimEnabled(enabled: boolean): void;
|
|
195
287
|
setScrimOverlay(opts: ScrimOverlayOptions): () => void;
|
|
288
|
+
addAnchor(opts: AnchorOptions): () => void;
|
|
289
|
+
setScrimStages(opts: ScrimStagesOptions | null): () => void;
|
|
196
290
|
getScrimState(): {
|
|
197
291
|
mode: "full" | "above-sheet" | "off";
|
|
198
292
|
enabled: boolean;
|
|
199
293
|
};
|
|
200
294
|
setSnapPoints(points: EngineOptions["snapPoints"], allowed?: string[]): void;
|
|
295
|
+
recompute(): void;
|
|
296
|
+
private measureFitSize;
|
|
297
|
+
private installFitObserver;
|
|
201
298
|
destroy(): void;
|
|
202
299
|
private emit;
|
|
203
300
|
private newCycle;
|
|
204
301
|
private emitBeforeSnap;
|
|
302
|
+
private emitBeforeClose;
|
|
303
|
+
private applyAutoAriaLabelledBy;
|
|
205
304
|
private recomputeSnaps;
|
|
206
305
|
private getAllowedRange;
|
|
306
|
+
private allowedIdsBySize;
|
|
207
307
|
private updateAriaSlider;
|
|
208
308
|
private registerInStack;
|
|
309
|
+
private applyStackDepth;
|
|
209
310
|
private attach;
|
|
210
311
|
private attachFeatures;
|
|
211
312
|
private settleAfterDrag;
|
|
@@ -213,7 +314,8 @@ declare class BottomSheetEngine {
|
|
|
213
314
|
private applySize;
|
|
214
315
|
private computeProgress;
|
|
215
316
|
private handleOpen;
|
|
317
|
+
private resyncAfterResize;
|
|
216
318
|
private handleClose;
|
|
217
319
|
}
|
|
218
320
|
|
|
219
|
-
export { BottomSheetEngine as B, type EngineState as E, type Plugin as P, type
|
|
321
|
+
export { type AnchorOptions as A, BottomSheetEngine as B, type CloseReason as C, type EngineState as E, type Plugin as P, type ScrimStagesOptions as S, type TeardownScope as T, type SnapPointDef as a, type SheetMode as b, type EngineOptions as c, type SnapPoint as d, type SheetEventMap as e, type ScrimOverlayPosition as f, type AnchorAnimationPreset as g, type AnchorAnimationSpec as h, type AnchorHandle as i, type AnchorPosition as j, type AnchorState as k, SCRIM_PRESETS as l, type ScrimOverlayOptions as m, type ScrimPreset as n, type ScrimPresetConfig as o, type ScrimStageDef as p, type ScrimUpdate as q, type SnapId as r, runAnchorTransition as s };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { T as TransformAxis } from './transform-jVfAikE9.js';
|
|
2
2
|
|
|
3
|
-
type SnapPoint = number | `${number}%` | "fit" | "full" | (string & {});
|
|
3
|
+
type SnapPoint = number | `${number}%` | "fit" | "content" | "full" | (string & {});
|
|
4
4
|
type SnapPointDef<Id extends string = string> = {
|
|
5
5
|
id: Id;
|
|
6
6
|
size: SnapPoint;
|
|
@@ -43,9 +43,14 @@ type SheetEventMap = {
|
|
|
43
43
|
cancel: () => void;
|
|
44
44
|
previousId: string;
|
|
45
45
|
};
|
|
46
|
+
"before-close": {
|
|
47
|
+
reason: "programmatic" | "backdrop" | "escape" | "back";
|
|
48
|
+
cancel: () => void;
|
|
49
|
+
};
|
|
46
50
|
snap: {
|
|
47
51
|
id: string;
|
|
48
52
|
size: number;
|
|
53
|
+
progress: number;
|
|
49
54
|
};
|
|
50
55
|
progress: {
|
|
51
56
|
value: number;
|
|
@@ -66,7 +71,12 @@ type SheetEventMap = {
|
|
|
66
71
|
open: {
|
|
67
72
|
id: string;
|
|
68
73
|
};
|
|
74
|
+
opened: {
|
|
75
|
+
id: string;
|
|
76
|
+
};
|
|
77
|
+
closed: undefined;
|
|
69
78
|
};
|
|
79
|
+
type CloseReason = "programmatic" | "backdrop" | "escape" | "back";
|
|
70
80
|
type EngineOptions = {
|
|
71
81
|
element: HTMLElement;
|
|
72
82
|
handle?: HTMLElement;
|
|
@@ -105,10 +115,18 @@ type EngineOptions = {
|
|
|
105
115
|
closeOnBack?: boolean;
|
|
106
116
|
routedTo?: string;
|
|
107
117
|
inertSiblings?: boolean;
|
|
118
|
+
persistent?: boolean;
|
|
119
|
+
disableClose?: boolean;
|
|
120
|
+
disableDrag?: boolean;
|
|
121
|
+
closeOnRouteChange?: boolean;
|
|
122
|
+
radius?: string | number;
|
|
123
|
+
maxHeight?: string | number;
|
|
124
|
+
returnFocusTo?: HTMLElement | string | (() => HTMLElement | null);
|
|
108
125
|
persistKey?: string;
|
|
109
126
|
autoCollapseAfter?: number;
|
|
110
127
|
linkedSheets?: BottomSheetEngineLike[];
|
|
111
128
|
viewTransitions?: boolean;
|
|
129
|
+
stackEffect?: boolean;
|
|
112
130
|
};
|
|
113
131
|
|
|
114
132
|
type BottomSheetEngineLike = BottomSheetEngine;
|
|
@@ -127,6 +145,60 @@ type EngineState = {
|
|
|
127
145
|
progress: number;
|
|
128
146
|
};
|
|
129
147
|
|
|
148
|
+
type AnchorAnimationPreset = "fade" | "scale" | "slide" | "pop" | "none";
|
|
149
|
+
type AnchorAnimationSpec = AnchorAnimationPreset | {
|
|
150
|
+
preset?: AnchorAnimationPreset;
|
|
151
|
+
enter?: Keyframe[];
|
|
152
|
+
exit?: Keyframe[];
|
|
153
|
+
duration?: number;
|
|
154
|
+
easing?: string;
|
|
155
|
+
respectReducedMotion?: boolean;
|
|
156
|
+
};
|
|
157
|
+
type AnchorTransitionHandle = {
|
|
158
|
+
finished: Promise<void>;
|
|
159
|
+
cancel: () => void;
|
|
160
|
+
};
|
|
161
|
+
declare function runAnchorTransition(el: HTMLElement, spec: AnchorAnimationSpec | undefined, phase: "enter" | "exit"): AnchorTransitionHandle;
|
|
162
|
+
|
|
163
|
+
type AnchorState = {
|
|
164
|
+
activeId: string;
|
|
165
|
+
size: number;
|
|
166
|
+
progress: number;
|
|
167
|
+
};
|
|
168
|
+
type AnchorPosition = ScrimOverlayPosition | "dock-bottom" | "dock-top";
|
|
169
|
+
type AnchorOptions = {
|
|
170
|
+
element: HTMLElement;
|
|
171
|
+
position?: AnchorPosition;
|
|
172
|
+
inset?: string;
|
|
173
|
+
showOn?: string[] | ((state: AnchorState) => boolean);
|
|
174
|
+
fadeRange?: [number, number];
|
|
175
|
+
interactive?: boolean;
|
|
176
|
+
animation?: AnchorAnimationSpec;
|
|
177
|
+
};
|
|
178
|
+
type AnchorHandle = {
|
|
179
|
+
wrapper: HTMLElement;
|
|
180
|
+
detach: () => void;
|
|
181
|
+
syncZ: (z: number) => void;
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
type ScrimStageDef = {
|
|
185
|
+
id?: string;
|
|
186
|
+
for?: string | string[];
|
|
187
|
+
forRange?: [number, number];
|
|
188
|
+
element: HTMLElement;
|
|
189
|
+
position?: ScrimOverlayPosition;
|
|
190
|
+
inset?: string;
|
|
191
|
+
interactive?: boolean;
|
|
192
|
+
animation?: AnchorAnimationSpec;
|
|
193
|
+
};
|
|
194
|
+
type ScrimStagesOptions = {
|
|
195
|
+
stages: ScrimStageDef[];
|
|
196
|
+
position?: ScrimOverlayPosition;
|
|
197
|
+
inset?: string;
|
|
198
|
+
interactive?: boolean;
|
|
199
|
+
animation?: AnchorAnimationSpec;
|
|
200
|
+
};
|
|
201
|
+
|
|
130
202
|
type Listener<K extends keyof SheetEventMap> = (payload: SheetEventMap[K]) => void;
|
|
131
203
|
declare class BottomSheetEngine {
|
|
132
204
|
private id;
|
|
@@ -146,6 +218,11 @@ declare class BottomSheetEngine {
|
|
|
146
218
|
private lifecycle;
|
|
147
219
|
private closeOnBack;
|
|
148
220
|
private routedTo;
|
|
221
|
+
private persistent;
|
|
222
|
+
private disableCloseFlag;
|
|
223
|
+
private disableDragFlag;
|
|
224
|
+
private closeOnRouteChange;
|
|
225
|
+
private maxHeightCap;
|
|
149
226
|
private snapPointsRaw;
|
|
150
227
|
private snaps;
|
|
151
228
|
private activeId;
|
|
@@ -158,6 +235,7 @@ declare class BottomSheetEngine {
|
|
|
158
235
|
private sizeWriteSentinel;
|
|
159
236
|
private progressWriteSentinel;
|
|
160
237
|
private isTopSheet;
|
|
238
|
+
private opening;
|
|
161
239
|
private progressPayload;
|
|
162
240
|
private dragContextBuf;
|
|
163
241
|
private bus;
|
|
@@ -165,6 +243,12 @@ declare class BottomSheetEngine {
|
|
|
165
243
|
private linkedSheets;
|
|
166
244
|
private scrollCache;
|
|
167
245
|
private teardowns;
|
|
246
|
+
private anchors;
|
|
247
|
+
private anchorHost;
|
|
248
|
+
private stackZ;
|
|
249
|
+
private detachScrimStages;
|
|
250
|
+
private stackEffectEnabled;
|
|
251
|
+
private stackEffectPrimed;
|
|
168
252
|
private transformTemplate;
|
|
169
253
|
constructor(opts: EngineOptions);
|
|
170
254
|
get state(): EngineState;
|
|
@@ -181,7 +265,15 @@ declare class BottomSheetEngine {
|
|
|
181
265
|
signal?: AbortSignal;
|
|
182
266
|
}): Promise<void>;
|
|
183
267
|
open(id?: string): Promise<void>;
|
|
184
|
-
close(): Promise<void>;
|
|
268
|
+
close(reason?: CloseReason): Promise<void>;
|
|
269
|
+
canDismiss(): boolean;
|
|
270
|
+
isTop(): boolean;
|
|
271
|
+
depth(): number;
|
|
272
|
+
expand(): Promise<void>;
|
|
273
|
+
collapse(): Promise<void>;
|
|
274
|
+
setRadius(r: string | number): void;
|
|
275
|
+
setMaxHeight(h: string | number): void;
|
|
276
|
+
private clampToMaxHeight;
|
|
185
277
|
setAllowed(ids: string[], snap?: string): void;
|
|
186
278
|
setBackdropRange(range: [number, number]): void;
|
|
187
279
|
setScreenRange(range: [number, number]): void;
|
|
@@ -193,19 +285,28 @@ declare class BottomSheetEngine {
|
|
|
193
285
|
setScrimTapToClose(enabled: boolean): void;
|
|
194
286
|
setScrimEnabled(enabled: boolean): void;
|
|
195
287
|
setScrimOverlay(opts: ScrimOverlayOptions): () => void;
|
|
288
|
+
addAnchor(opts: AnchorOptions): () => void;
|
|
289
|
+
setScrimStages(opts: ScrimStagesOptions | null): () => void;
|
|
196
290
|
getScrimState(): {
|
|
197
291
|
mode: "full" | "above-sheet" | "off";
|
|
198
292
|
enabled: boolean;
|
|
199
293
|
};
|
|
200
294
|
setSnapPoints(points: EngineOptions["snapPoints"], allowed?: string[]): void;
|
|
295
|
+
recompute(): void;
|
|
296
|
+
private measureFitSize;
|
|
297
|
+
private installFitObserver;
|
|
201
298
|
destroy(): void;
|
|
202
299
|
private emit;
|
|
203
300
|
private newCycle;
|
|
204
301
|
private emitBeforeSnap;
|
|
302
|
+
private emitBeforeClose;
|
|
303
|
+
private applyAutoAriaLabelledBy;
|
|
205
304
|
private recomputeSnaps;
|
|
206
305
|
private getAllowedRange;
|
|
306
|
+
private allowedIdsBySize;
|
|
207
307
|
private updateAriaSlider;
|
|
208
308
|
private registerInStack;
|
|
309
|
+
private applyStackDepth;
|
|
209
310
|
private attach;
|
|
210
311
|
private attachFeatures;
|
|
211
312
|
private settleAfterDrag;
|
|
@@ -213,7 +314,8 @@ declare class BottomSheetEngine {
|
|
|
213
314
|
private applySize;
|
|
214
315
|
private computeProgress;
|
|
215
316
|
private handleOpen;
|
|
317
|
+
private resyncAfterResize;
|
|
216
318
|
private handleClose;
|
|
217
319
|
}
|
|
218
320
|
|
|
219
|
-
export { BottomSheetEngine as B, type EngineState as E, type Plugin as P, type
|
|
321
|
+
export { type AnchorOptions as A, BottomSheetEngine as B, type CloseReason as C, type EngineState as E, type Plugin as P, type ScrimStagesOptions as S, type TeardownScope as T, type SnapPointDef as a, type SheetMode as b, type EngineOptions as c, type SnapPoint as d, type SheetEventMap as e, type ScrimOverlayPosition as f, type AnchorAnimationPreset as g, type AnchorAnimationSpec as h, type AnchorHandle as i, type AnchorPosition as j, type AnchorState as k, SCRIM_PRESETS as l, type ScrimOverlayOptions as m, type ScrimPreset as n, type ScrimPresetConfig as o, type ScrimStageDef as p, type ScrimUpdate as q, type SnapId as r, runAnchorTransition as s };
|