@surdeddd/bottom-sheet 0.21.1 → 0.22.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 +32 -0
- package/dist/{BottomSheetCore-CK_mq14p.d.ts → BottomSheetCore-9i-Uh6T3.d.ts} +4 -1
- package/dist/{BottomSheetCore-BHv6LPmS.d.cts → BottomSheetCore-CQStdVy2.d.cts} +4 -1
- package/dist/{BottomSheetEngine-mmFzIK1Z.d.cts → BottomSheetEngine-CsQWHLNb.d.cts} +1 -1
- package/dist/{BottomSheetEngine-wLn6Q2kA.d.ts → BottomSheetEngine-Dn6h-7gF.d.ts} +1 -1
- package/dist/core.cjs +25 -7
- package/dist/core.d.cts +2 -2
- package/dist/core.d.ts +2 -2
- package/dist/core.js +25 -7
- package/dist/debug.d.cts +1 -1
- package/dist/debug.d.ts +1 -1
- package/dist/default-features-C3cilcW9.d.ts +11 -0
- package/dist/default-features-DkG9aho0.d.cts +11 -0
- package/dist/element.cjs +106 -15
- package/dist/element.d.cts +2 -2
- package/dist/element.d.ts +2 -2
- package/dist/element.iife.global.js +2 -2
- package/dist/element.js +106 -15
- package/dist/features.cjs +65 -1
- package/dist/features.d.cts +5 -10
- package/dist/features.d.ts +5 -10
- package/dist/features.js +65 -2
- package/dist/{index-juAyT76E.d.cts → index-CVGC5B5D.d.cts} +1 -1
- package/dist/{index-CWKv1Xy4.d.ts → index-CnsJQZp2.d.ts} +1 -1
- package/dist/index.cjs +89 -8
- package/dist/index.d.cts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.js +89 -8
- 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/preact.d.cts +2 -2
- package/dist/preact.d.ts +2 -2
- package/dist/qwik-lib/index.qwik.cjs +84 -6
- package/dist/qwik-lib/index.qwik.mjs +84 -6
- package/dist/qwik.cjs +90 -8
- package/dist/qwik.d.cts +3 -2
- package/dist/qwik.d.ts +3 -2
- package/dist/qwik.js +90 -8
- package/dist/react.cjs +89 -8
- package/dist/react.d.cts +3 -3
- package/dist/react.d.ts +3 -3
- package/dist/react.js +89 -8
- package/dist/solid.cjs +90 -8
- package/dist/solid.d.cts +4 -0
- package/dist/solid.d.ts +4 -0
- package/dist/solid.js +90 -8
- package/dist/solid.source.jsx +90 -8
- package/dist/styles.css +11 -0
- package/dist/svelte-core.cjs +89 -8
- package/dist/svelte-core.js +89 -8
- package/dist/svelte-src/BottomSheet.svelte +3 -0
- package/dist/svelte.cjs +90 -8
- package/dist/svelte.d.cts +1 -0
- package/dist/svelte.d.ts +1 -0
- package/dist/svelte.js +90 -8
- package/dist/vue.cjs +93 -8
- package/dist/vue.js +93 -8
- package/dist/webgl.d.cts +1 -1
- package/dist/webgl.d.ts +1 -1
- package/package.json +9 -9
package/dist/index.d.cts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export { B as BottomSheetEngine } from './BottomSheetEngine-
|
|
2
|
-
import {
|
|
3
|
-
export {
|
|
4
|
-
export { autoCollapseFeature, contentSwipeFeature, defaultEngineFeatures, persistFeature, routeFeature, visualViewportFeature } from './features.cjs';
|
|
5
|
-
export { R as ResolvedSnap, r as resolveSnapList } from './index-
|
|
1
|
+
export { B as BottomSheetEngine } from './BottomSheetEngine-CsQWHLNb.cjs';
|
|
2
|
+
import { h as SnapPoint, f as SheetMode, g as EngineOptions, P as PhysicalSheetMode, j as ScrimOverlayPosition } from './BottomSheetCore-CQStdVy2.cjs';
|
|
3
|
+
export { k as AnchorAnimationPreset, l as AnchorAnimationSpec, m as AnchorHandle, A as AnchorOptions, n as AnchorPosition, o as AnchorState, B as BottomSheetCore, C as CloseReason, E as EngineFeature, a as EngineFeatureContext, b as EngineFeatureOptions, c as EngineFeatureStage, d as EngineState, L as LogicalSheetMode, p as Plugin, q as SCRIM_PRESETS, r as ScrimOverlayOptions, s as ScrimPreset, t as ScrimPresetConfig, u as ScrimStageDef, i as ScrimStagesOptions, v as ScrimUpdate, S as SheetEventMap, w as SnapId, e as SnapPointDef, T as TeardownScope, x as runAnchorTransition } from './BottomSheetCore-CQStdVy2.cjs';
|
|
4
|
+
export { a as autoCollapseFeature, c as contentSwipeFeature, d as defaultEngineFeatures, p as persistFeature, r as routeFeature, v as visualViewportFeature } from './default-features-DkG9aho0.cjs';
|
|
5
|
+
export { R as ResolvedSnap, r as resolveSnapList } from './index-CVGC5B5D.cjs';
|
|
6
6
|
import './transform-jVfAikE9.cjs';
|
|
7
7
|
|
|
8
8
|
declare const resolveSnap: (point: SnapPoint | string, mode: SheetMode, measureFit?: () => number) => number;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export { B as BottomSheetEngine } from './BottomSheetEngine-
|
|
2
|
-
import {
|
|
3
|
-
export {
|
|
4
|
-
export { autoCollapseFeature, contentSwipeFeature, defaultEngineFeatures, persistFeature, routeFeature, visualViewportFeature } from './features.js';
|
|
5
|
-
export { R as ResolvedSnap, r as resolveSnapList } from './index-
|
|
1
|
+
export { B as BottomSheetEngine } from './BottomSheetEngine-Dn6h-7gF.js';
|
|
2
|
+
import { h as SnapPoint, f as SheetMode, g as EngineOptions, P as PhysicalSheetMode, j as ScrimOverlayPosition } from './BottomSheetCore-9i-Uh6T3.js';
|
|
3
|
+
export { k as AnchorAnimationPreset, l as AnchorAnimationSpec, m as AnchorHandle, A as AnchorOptions, n as AnchorPosition, o as AnchorState, B as BottomSheetCore, C as CloseReason, E as EngineFeature, a as EngineFeatureContext, b as EngineFeatureOptions, c as EngineFeatureStage, d as EngineState, L as LogicalSheetMode, p as Plugin, q as SCRIM_PRESETS, r as ScrimOverlayOptions, s as ScrimPreset, t as ScrimPresetConfig, u as ScrimStageDef, i as ScrimStagesOptions, v as ScrimUpdate, S as SheetEventMap, w as SnapId, e as SnapPointDef, T as TeardownScope, x as runAnchorTransition } from './BottomSheetCore-9i-Uh6T3.js';
|
|
4
|
+
export { a as autoCollapseFeature, c as contentSwipeFeature, d as defaultEngineFeatures, p as persistFeature, r as routeFeature, v as visualViewportFeature } from './default-features-C3cilcW9.js';
|
|
5
|
+
export { R as ResolvedSnap, r as resolveSnapList } from './index-CnsJQZp2.js';
|
|
6
6
|
import './transform-jVfAikE9.js';
|
|
7
7
|
|
|
8
8
|
declare const resolveSnap: (point: SnapPoint | string, mode: SheetMode, measureFit?: () => number) => number;
|
package/dist/index.js
CHANGED
|
@@ -373,14 +373,26 @@ function notifyLinkedSheets(sheets, self) {
|
|
|
373
373
|
}
|
|
374
374
|
}
|
|
375
375
|
|
|
376
|
+
// src/core/primitives/hot-path-thresholds.ts
|
|
377
|
+
var SIZE_WRITE_EPSILON = 0.5;
|
|
378
|
+
var OPACITY_WRITE_EPSILON = 5e-3;
|
|
379
|
+
var POINTER_EVENTS_OPACITY_THRESHOLD = 0.05;
|
|
380
|
+
var RANGE_DIVISION_EPSILON = 1e-4;
|
|
381
|
+
|
|
376
382
|
// src/core/features/resize-observer.ts
|
|
377
383
|
function installResizeObserver(deps) {
|
|
378
384
|
if (typeof window === "undefined") {
|
|
379
385
|
return () => {
|
|
380
386
|
};
|
|
381
387
|
}
|
|
388
|
+
const seatFor = () => {
|
|
389
|
+
const snap = deps.resolveActiveSnap();
|
|
390
|
+
const max = deps.getMaxAxisSize();
|
|
391
|
+
return { target: snap ? Math.min(snap.size, max) : null, max };
|
|
392
|
+
};
|
|
382
393
|
const onResize = () => {
|
|
383
394
|
if (deps.isDestroyed()) return;
|
|
395
|
+
const before = seatFor();
|
|
384
396
|
deps.recomputeSnaps();
|
|
385
397
|
const mode = deps.getMode();
|
|
386
398
|
const isVerticalAxis = mode === "bottom" || mode === "top";
|
|
@@ -389,6 +401,10 @@ function installResizeObserver(deps) {
|
|
|
389
401
|
if (viewportSize2 > 0 && viewportSize2 < max) {
|
|
390
402
|
deps.setMaxAxisSize(viewportSize2);
|
|
391
403
|
}
|
|
404
|
+
const after = seatFor();
|
|
405
|
+
if (before.target !== null && after.target !== null && Math.abs(after.target - before.target) < SIZE_WRITE_EPSILON && Math.abs(after.max - before.max) < SIZE_WRITE_EPSILON) {
|
|
406
|
+
return;
|
|
407
|
+
}
|
|
392
408
|
const wasAnimating = deps.isAnimating?.() ?? false;
|
|
393
409
|
deps.cancelInFlight();
|
|
394
410
|
deps.newCycle();
|
|
@@ -657,12 +673,6 @@ var SCRIM_PRESETS = Object.freeze({
|
|
|
657
673
|
}
|
|
658
674
|
});
|
|
659
675
|
|
|
660
|
-
// src/core/primitives/hot-path-thresholds.ts
|
|
661
|
-
var SIZE_WRITE_EPSILON = 0.5;
|
|
662
|
-
var OPACITY_WRITE_EPSILON = 5e-3;
|
|
663
|
-
var POINTER_EVENTS_OPACITY_THRESHOLD = 0.05;
|
|
664
|
-
var RANGE_DIVISION_EPSILON = 1e-4;
|
|
665
|
-
|
|
666
676
|
// src/core/primitives/opacity-dedup.ts
|
|
667
677
|
var WriteSentinel = class {
|
|
668
678
|
constructor() {
|
|
@@ -2592,6 +2602,7 @@ var BottomSheetCore = class {
|
|
|
2592
2602
|
__publicField(this, "lifecycle");
|
|
2593
2603
|
__publicField(this, "closeOnBack");
|
|
2594
2604
|
__publicField(this, "routedTo");
|
|
2605
|
+
__publicField(this, "fitContentToSnap");
|
|
2595
2606
|
__publicField(this, "persistent");
|
|
2596
2607
|
__publicField(this, "disableCloseFlag");
|
|
2597
2608
|
__publicField(this, "disableDragFlag");
|
|
@@ -2705,6 +2716,7 @@ var BottomSheetCore = class {
|
|
|
2705
2716
|
);
|
|
2706
2717
|
this.closeOnBack = resolved.closeOnBack;
|
|
2707
2718
|
this.routedTo = opts.routedTo;
|
|
2719
|
+
this.fitContentToSnap = opts.fitContentToSnap === true;
|
|
2708
2720
|
this.persistent = resolved.persistent;
|
|
2709
2721
|
this.disableCloseFlag = resolved.disableClose;
|
|
2710
2722
|
this.disableDragFlag = resolved.disableDrag;
|
|
@@ -2806,7 +2818,8 @@ var BottomSheetCore = class {
|
|
|
2806
2818
|
closeOnBack: this.closeOnBack,
|
|
2807
2819
|
closeOnRouteChange: this.closeOnRouteChange,
|
|
2808
2820
|
persistKey: this.persistKey,
|
|
2809
|
-
autoCollapseAfter
|
|
2821
|
+
autoCollapseAfter,
|
|
2822
|
+
fitContentToSnap: this.fitContentToSnap
|
|
2810
2823
|
},
|
|
2811
2824
|
isDestroyed: () => this.destroyed,
|
|
2812
2825
|
isDragging: () => this.isDraggingAny(),
|
|
@@ -2858,6 +2871,11 @@ var BottomSheetCore = class {
|
|
|
2858
2871
|
"[BottomSheet] closeOnBack/routedTo/closeOnRouteChange need routeFeature() \u2014 option ignored"
|
|
2859
2872
|
);
|
|
2860
2873
|
}
|
|
2874
|
+
if (this.fitContentToSnap && !names.has("content-fit")) {
|
|
2875
|
+
devWarn(
|
|
2876
|
+
"[BottomSheet] fitContentToSnap needs contentFitFeature() \u2014 option ignored"
|
|
2877
|
+
);
|
|
2878
|
+
}
|
|
2861
2879
|
if (this.persistKey && !names.has("persist")) {
|
|
2862
2880
|
devWarn(
|
|
2863
2881
|
"[BottomSheet] persistKey needs persistFeature() \u2014 snaps will not be saved"
|
|
@@ -4215,6 +4233,68 @@ function visualViewportFeature() {
|
|
|
4215
4233
|
};
|
|
4216
4234
|
}
|
|
4217
4235
|
|
|
4236
|
+
// src/core/features/content-fit.ts
|
|
4237
|
+
var INSET_VAR = "--bs-content-inset";
|
|
4238
|
+
var FIT_ATTR = "data-bs-fit-content";
|
|
4239
|
+
function contentFitFeature() {
|
|
4240
|
+
return {
|
|
4241
|
+
name: "content-fit",
|
|
4242
|
+
install: (ctx) => {
|
|
4243
|
+
const scroller = ctx.scrollContainer;
|
|
4244
|
+
if (!ctx.options.fitContentToSnap || !scroller || typeof window === "undefined") {
|
|
4245
|
+
return;
|
|
4246
|
+
}
|
|
4247
|
+
const sheet = ctx.element;
|
|
4248
|
+
let inset = 0;
|
|
4249
|
+
let unpaddedMax = -1;
|
|
4250
|
+
let top = 0;
|
|
4251
|
+
const hiddenAt = (size) => sheet.dataset.mode === "bottom" ? Math.max(0, ctx.getMaxAxisSize() - size) : 0;
|
|
4252
|
+
const follow = (size) => {
|
|
4253
|
+
if (unpaddedMax < 0) {
|
|
4254
|
+
unpaddedMax = scroller.scrollHeight - scroller.clientHeight - inset;
|
|
4255
|
+
top = scroller.scrollTop;
|
|
4256
|
+
}
|
|
4257
|
+
const limit = Math.max(0, unpaddedMax + hiddenAt(size));
|
|
4258
|
+
if (top > limit) {
|
|
4259
|
+
if (scroller.scrollTop > limit) scroller.scrollTop = limit;
|
|
4260
|
+
top = limit;
|
|
4261
|
+
}
|
|
4262
|
+
};
|
|
4263
|
+
const settle = () => {
|
|
4264
|
+
if (ctx.isDestroyed()) return;
|
|
4265
|
+
const size = ctx.getSize();
|
|
4266
|
+
unpaddedMax = -1;
|
|
4267
|
+
follow(size);
|
|
4268
|
+
inset = hiddenAt(size);
|
|
4269
|
+
sheet.style.setProperty(INSET_VAR, `${inset}px`);
|
|
4270
|
+
unpaddedMax = -1;
|
|
4271
|
+
};
|
|
4272
|
+
const moving = () => ctx.isAnimating() || ctx.isDragging();
|
|
4273
|
+
const whenIdle = () => {
|
|
4274
|
+
if (!moving()) settle();
|
|
4275
|
+
};
|
|
4276
|
+
sheet.setAttribute(FIT_ATTR, "");
|
|
4277
|
+
settle();
|
|
4278
|
+
const offProgress = ctx.on(
|
|
4279
|
+
"progress",
|
|
4280
|
+
(p) => moving() ? follow(p.size) : settle()
|
|
4281
|
+
);
|
|
4282
|
+
const offSnap = ctx.on("snap", settle);
|
|
4283
|
+
const observer = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(whenIdle);
|
|
4284
|
+
observer?.observe(document.documentElement);
|
|
4285
|
+
window.addEventListener("orientationchange", whenIdle);
|
|
4286
|
+
return () => {
|
|
4287
|
+
offProgress();
|
|
4288
|
+
offSnap();
|
|
4289
|
+
observer?.disconnect();
|
|
4290
|
+
window.removeEventListener("orientationchange", whenIdle);
|
|
4291
|
+
sheet.removeAttribute(FIT_ATTR);
|
|
4292
|
+
sheet.style.removeProperty(INSET_VAR);
|
|
4293
|
+
};
|
|
4294
|
+
}
|
|
4295
|
+
};
|
|
4296
|
+
}
|
|
4297
|
+
|
|
4218
4298
|
// src/core/default-features.ts
|
|
4219
4299
|
function defaultEngineFeatures() {
|
|
4220
4300
|
return [
|
|
@@ -4222,7 +4302,8 @@ function defaultEngineFeatures() {
|
|
|
4222
4302
|
visualViewportFeature(),
|
|
4223
4303
|
persistFeature(),
|
|
4224
4304
|
autoCollapseFeature(),
|
|
4225
|
-
routeFeature()
|
|
4305
|
+
routeFeature(),
|
|
4306
|
+
contentFitFeature()
|
|
4226
4307
|
];
|
|
4227
4308
|
}
|
|
4228
4309
|
|
package/dist/preact.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { BottomSheet, BottomSheetFromConfig, BottomSheetFromConfigProps, BottomSheetHandle, BottomSheetProps, HeaderProp, Overlay, OverlayHandle, OverlayProps, SheetConfig, UseBottomSheetRefs, UseBottomSheetReturn, UseOverlayReturn, useBottomSheet, useOverlay } from './react.cjs';
|
|
2
|
-
export {
|
|
2
|
+
export { d as EngineState, f as SheetMode, h as SnapPoint, e as SnapPointDef } from './BottomSheetCore-CQStdVy2.cjs';
|
|
3
3
|
export { OverlayEdge, OverlayOptions, OverlayState } from './overlay.cjs';
|
|
4
4
|
import 'react';
|
|
5
|
-
import './BottomSheetEngine-
|
|
5
|
+
import './BottomSheetEngine-CsQWHLNb.cjs';
|
|
6
6
|
import './teleport-7uYNiEAT.cjs';
|
|
7
7
|
import './transform-jVfAikE9.cjs';
|
package/dist/preact.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { BottomSheet, BottomSheetFromConfig, BottomSheetFromConfigProps, BottomSheetHandle, BottomSheetProps, HeaderProp, Overlay, OverlayHandle, OverlayProps, SheetConfig, UseBottomSheetRefs, UseBottomSheetReturn, UseOverlayReturn, useBottomSheet, useOverlay } from './react.js';
|
|
2
|
-
export {
|
|
2
|
+
export { d as EngineState, f as SheetMode, h as SnapPoint, e as SnapPointDef } from './BottomSheetCore-9i-Uh6T3.js';
|
|
3
3
|
export { OverlayEdge, OverlayOptions, OverlayState } from './overlay.js';
|
|
4
4
|
import 'react';
|
|
5
|
-
import './BottomSheetEngine-
|
|
5
|
+
import './BottomSheetEngine-Dn6h-7gF.js';
|
|
6
6
|
import './teleport-7uYNiEAT.js';
|
|
7
7
|
import './transform-jVfAikE9.js';
|
|
@@ -359,13 +359,26 @@ function notifyLinkedSheets(sheets, self) {
|
|
|
359
359
|
}
|
|
360
360
|
}
|
|
361
361
|
}
|
|
362
|
+
const SIZE_WRITE_EPSILON = 0.5;
|
|
363
|
+
const OPACITY_WRITE_EPSILON = 5e-3;
|
|
364
|
+
const POINTER_EVENTS_OPACITY_THRESHOLD = 0.05;
|
|
365
|
+
const RANGE_DIVISION_EPSILON = 1e-4;
|
|
362
366
|
function installResizeObserver(deps) {
|
|
363
367
|
if (typeof window === "undefined") {
|
|
364
368
|
return () => {
|
|
365
369
|
};
|
|
366
370
|
}
|
|
371
|
+
const seatFor = () => {
|
|
372
|
+
const snap = deps.resolveActiveSnap();
|
|
373
|
+
const max = deps.getMaxAxisSize();
|
|
374
|
+
return {
|
|
375
|
+
target: snap ? Math.min(snap.size, max) : null,
|
|
376
|
+
max
|
|
377
|
+
};
|
|
378
|
+
};
|
|
367
379
|
const onResize = () => {
|
|
368
380
|
if (deps.isDestroyed()) return;
|
|
381
|
+
const before = seatFor();
|
|
369
382
|
deps.recomputeSnaps();
|
|
370
383
|
const mode = deps.getMode();
|
|
371
384
|
const isVerticalAxis = mode === "bottom" || mode === "top";
|
|
@@ -374,6 +387,10 @@ function installResizeObserver(deps) {
|
|
|
374
387
|
if (viewportSize2 > 0 && viewportSize2 < max) {
|
|
375
388
|
deps.setMaxAxisSize(viewportSize2);
|
|
376
389
|
}
|
|
390
|
+
const after = seatFor();
|
|
391
|
+
if (before.target !== null && after.target !== null && Math.abs(after.target - before.target) < SIZE_WRITE_EPSILON && Math.abs(after.max - before.max) < SIZE_WRITE_EPSILON) {
|
|
392
|
+
return;
|
|
393
|
+
}
|
|
377
394
|
const wasAnimating = deps.isAnimating?.() ?? false;
|
|
378
395
|
deps.cancelInFlight();
|
|
379
396
|
deps.newCycle();
|
|
@@ -635,10 +652,6 @@ const SCRIM_PRESETS = Object.freeze({
|
|
|
635
652
|
interactive: false
|
|
636
653
|
}
|
|
637
654
|
});
|
|
638
|
-
const SIZE_WRITE_EPSILON = 0.5;
|
|
639
|
-
const OPACITY_WRITE_EPSILON = 5e-3;
|
|
640
|
-
const POINTER_EVENTS_OPACITY_THRESHOLD = 0.05;
|
|
641
|
-
const RANGE_DIVISION_EPSILON = 1e-4;
|
|
642
655
|
class WriteSentinel {
|
|
643
656
|
constructor() {
|
|
644
657
|
__publicField(this, "last", -1);
|
|
@@ -2638,6 +2651,7 @@ class BottomSheetCore {
|
|
|
2638
2651
|
__publicField(this, "lifecycle");
|
|
2639
2652
|
__publicField(this, "closeOnBack");
|
|
2640
2653
|
__publicField(this, "routedTo");
|
|
2654
|
+
__publicField(this, "fitContentToSnap");
|
|
2641
2655
|
__publicField(this, "persistent");
|
|
2642
2656
|
__publicField(this, "disableCloseFlag");
|
|
2643
2657
|
__publicField(this, "disableDragFlag");
|
|
@@ -2743,6 +2757,7 @@ class BottomSheetCore {
|
|
|
2743
2757
|
}, resolved.lifecycle);
|
|
2744
2758
|
this.closeOnBack = resolved.closeOnBack;
|
|
2745
2759
|
this.routedTo = opts.routedTo;
|
|
2760
|
+
this.fitContentToSnap = opts.fitContentToSnap === true;
|
|
2746
2761
|
this.persistent = resolved.persistent;
|
|
2747
2762
|
this.disableCloseFlag = resolved.disableClose;
|
|
2748
2763
|
this.disableDragFlag = resolved.disableDrag;
|
|
@@ -2834,7 +2849,8 @@ class BottomSheetCore {
|
|
|
2834
2849
|
closeOnBack: this.closeOnBack,
|
|
2835
2850
|
closeOnRouteChange: this.closeOnRouteChange,
|
|
2836
2851
|
persistKey: this.persistKey,
|
|
2837
|
-
autoCollapseAfter
|
|
2852
|
+
autoCollapseAfter,
|
|
2853
|
+
fitContentToSnap: this.fitContentToSnap
|
|
2838
2854
|
},
|
|
2839
2855
|
isDestroyed: () => this.destroyed,
|
|
2840
2856
|
isDragging: () => this.isDraggingAny(),
|
|
@@ -2884,6 +2900,9 @@ class BottomSheetCore {
|
|
|
2884
2900
|
if ((this.closeOnBack || this.routedTo !== void 0 || this.closeOnRouteChange) && !names.has("route")) {
|
|
2885
2901
|
devWarn("[BottomSheet] closeOnBack/routedTo/closeOnRouteChange need routeFeature() — option ignored");
|
|
2886
2902
|
}
|
|
2903
|
+
if (this.fitContentToSnap && !names.has("content-fit")) {
|
|
2904
|
+
devWarn("[BottomSheet] fitContentToSnap needs contentFitFeature() — option ignored");
|
|
2905
|
+
}
|
|
2887
2906
|
if (this.persistKey && !names.has("persist")) {
|
|
2888
2907
|
devWarn("[BottomSheet] persistKey needs persistFeature() — snaps will not be saved");
|
|
2889
2908
|
}
|
|
@@ -4208,13 +4227,71 @@ function visualViewportFeature() {
|
|
|
4208
4227
|
}
|
|
4209
4228
|
};
|
|
4210
4229
|
}
|
|
4230
|
+
const INSET_VAR = "--bs-content-inset";
|
|
4231
|
+
const FIT_ATTR = "data-bs-fit-content";
|
|
4232
|
+
function contentFitFeature() {
|
|
4233
|
+
return {
|
|
4234
|
+
name: "content-fit",
|
|
4235
|
+
install: (ctx) => {
|
|
4236
|
+
const scroller = ctx.scrollContainer;
|
|
4237
|
+
if (!ctx.options.fitContentToSnap || !scroller || typeof window === "undefined") {
|
|
4238
|
+
return;
|
|
4239
|
+
}
|
|
4240
|
+
const sheet = ctx.element;
|
|
4241
|
+
let inset = 0;
|
|
4242
|
+
let unpaddedMax = -1;
|
|
4243
|
+
let top = 0;
|
|
4244
|
+
const hiddenAt = (size) => sheet.dataset.mode === "bottom" ? Math.max(0, ctx.getMaxAxisSize() - size) : 0;
|
|
4245
|
+
const follow = (size) => {
|
|
4246
|
+
if (unpaddedMax < 0) {
|
|
4247
|
+
unpaddedMax = scroller.scrollHeight - scroller.clientHeight - inset;
|
|
4248
|
+
top = scroller.scrollTop;
|
|
4249
|
+
}
|
|
4250
|
+
const limit = Math.max(0, unpaddedMax + hiddenAt(size));
|
|
4251
|
+
if (top > limit) {
|
|
4252
|
+
if (scroller.scrollTop > limit) scroller.scrollTop = limit;
|
|
4253
|
+
top = limit;
|
|
4254
|
+
}
|
|
4255
|
+
};
|
|
4256
|
+
const settle = () => {
|
|
4257
|
+
if (ctx.isDestroyed()) return;
|
|
4258
|
+
const size = ctx.getSize();
|
|
4259
|
+
unpaddedMax = -1;
|
|
4260
|
+
follow(size);
|
|
4261
|
+
inset = hiddenAt(size);
|
|
4262
|
+
sheet.style.setProperty(INSET_VAR, `${inset}px`);
|
|
4263
|
+
unpaddedMax = -1;
|
|
4264
|
+
};
|
|
4265
|
+
const moving = () => ctx.isAnimating() || ctx.isDragging();
|
|
4266
|
+
const whenIdle = () => {
|
|
4267
|
+
if (!moving()) settle();
|
|
4268
|
+
};
|
|
4269
|
+
sheet.setAttribute(FIT_ATTR, "");
|
|
4270
|
+
settle();
|
|
4271
|
+
const offProgress = ctx.on("progress", (p) => moving() ? follow(p.size) : settle());
|
|
4272
|
+
const offSnap = ctx.on("snap", settle);
|
|
4273
|
+
const observer = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(whenIdle);
|
|
4274
|
+
observer?.observe(document.documentElement);
|
|
4275
|
+
window.addEventListener("orientationchange", whenIdle);
|
|
4276
|
+
return () => {
|
|
4277
|
+
offProgress();
|
|
4278
|
+
offSnap();
|
|
4279
|
+
observer?.disconnect();
|
|
4280
|
+
window.removeEventListener("orientationchange", whenIdle);
|
|
4281
|
+
sheet.removeAttribute(FIT_ATTR);
|
|
4282
|
+
sheet.style.removeProperty(INSET_VAR);
|
|
4283
|
+
};
|
|
4284
|
+
}
|
|
4285
|
+
};
|
|
4286
|
+
}
|
|
4211
4287
|
function defaultEngineFeatures() {
|
|
4212
4288
|
return [
|
|
4213
4289
|
contentSwipeFeature(),
|
|
4214
4290
|
visualViewportFeature(),
|
|
4215
4291
|
persistFeature(),
|
|
4216
4292
|
autoCollapseFeature(),
|
|
4217
|
-
routeFeature()
|
|
4293
|
+
routeFeature(),
|
|
4294
|
+
contentFitFeature()
|
|
4218
4295
|
];
|
|
4219
4296
|
}
|
|
4220
4297
|
class BottomSheetEngine extends BottomSheetCore {
|
|
@@ -4311,6 +4388,7 @@ const BottomSheet = qwik.component$((props) => {
|
|
|
4311
4388
|
disableDrag: props.disableDrag,
|
|
4312
4389
|
dragFrom: props.dragFrom,
|
|
4313
4390
|
dragFromContent: props.dragFromContent,
|
|
4391
|
+
fitContentToSnap: props.fitContentToSnap,
|
|
4314
4392
|
closeOnRouteChange: props.closeOnRouteChange,
|
|
4315
4393
|
stackEffect: props.stackEffect,
|
|
4316
4394
|
returnFocusTo: props.returnFocusTo,
|
|
@@ -357,13 +357,26 @@ function notifyLinkedSheets(sheets, self) {
|
|
|
357
357
|
}
|
|
358
358
|
}
|
|
359
359
|
}
|
|
360
|
+
const SIZE_WRITE_EPSILON = 0.5;
|
|
361
|
+
const OPACITY_WRITE_EPSILON = 5e-3;
|
|
362
|
+
const POINTER_EVENTS_OPACITY_THRESHOLD = 0.05;
|
|
363
|
+
const RANGE_DIVISION_EPSILON = 1e-4;
|
|
360
364
|
function installResizeObserver(deps) {
|
|
361
365
|
if (typeof window === "undefined") {
|
|
362
366
|
return () => {
|
|
363
367
|
};
|
|
364
368
|
}
|
|
369
|
+
const seatFor = () => {
|
|
370
|
+
const snap = deps.resolveActiveSnap();
|
|
371
|
+
const max = deps.getMaxAxisSize();
|
|
372
|
+
return {
|
|
373
|
+
target: snap ? Math.min(snap.size, max) : null,
|
|
374
|
+
max
|
|
375
|
+
};
|
|
376
|
+
};
|
|
365
377
|
const onResize = () => {
|
|
366
378
|
if (deps.isDestroyed()) return;
|
|
379
|
+
const before = seatFor();
|
|
367
380
|
deps.recomputeSnaps();
|
|
368
381
|
const mode = deps.getMode();
|
|
369
382
|
const isVerticalAxis = mode === "bottom" || mode === "top";
|
|
@@ -372,6 +385,10 @@ function installResizeObserver(deps) {
|
|
|
372
385
|
if (viewportSize2 > 0 && viewportSize2 < max) {
|
|
373
386
|
deps.setMaxAxisSize(viewportSize2);
|
|
374
387
|
}
|
|
388
|
+
const after = seatFor();
|
|
389
|
+
if (before.target !== null && after.target !== null && Math.abs(after.target - before.target) < SIZE_WRITE_EPSILON && Math.abs(after.max - before.max) < SIZE_WRITE_EPSILON) {
|
|
390
|
+
return;
|
|
391
|
+
}
|
|
375
392
|
const wasAnimating = deps.isAnimating?.() ?? false;
|
|
376
393
|
deps.cancelInFlight();
|
|
377
394
|
deps.newCycle();
|
|
@@ -633,10 +650,6 @@ const SCRIM_PRESETS = Object.freeze({
|
|
|
633
650
|
interactive: false
|
|
634
651
|
}
|
|
635
652
|
});
|
|
636
|
-
const SIZE_WRITE_EPSILON = 0.5;
|
|
637
|
-
const OPACITY_WRITE_EPSILON = 5e-3;
|
|
638
|
-
const POINTER_EVENTS_OPACITY_THRESHOLD = 0.05;
|
|
639
|
-
const RANGE_DIVISION_EPSILON = 1e-4;
|
|
640
653
|
class WriteSentinel {
|
|
641
654
|
constructor() {
|
|
642
655
|
__publicField(this, "last", -1);
|
|
@@ -2636,6 +2649,7 @@ class BottomSheetCore {
|
|
|
2636
2649
|
__publicField(this, "lifecycle");
|
|
2637
2650
|
__publicField(this, "closeOnBack");
|
|
2638
2651
|
__publicField(this, "routedTo");
|
|
2652
|
+
__publicField(this, "fitContentToSnap");
|
|
2639
2653
|
__publicField(this, "persistent");
|
|
2640
2654
|
__publicField(this, "disableCloseFlag");
|
|
2641
2655
|
__publicField(this, "disableDragFlag");
|
|
@@ -2741,6 +2755,7 @@ class BottomSheetCore {
|
|
|
2741
2755
|
}, resolved.lifecycle);
|
|
2742
2756
|
this.closeOnBack = resolved.closeOnBack;
|
|
2743
2757
|
this.routedTo = opts.routedTo;
|
|
2758
|
+
this.fitContentToSnap = opts.fitContentToSnap === true;
|
|
2744
2759
|
this.persistent = resolved.persistent;
|
|
2745
2760
|
this.disableCloseFlag = resolved.disableClose;
|
|
2746
2761
|
this.disableDragFlag = resolved.disableDrag;
|
|
@@ -2832,7 +2847,8 @@ class BottomSheetCore {
|
|
|
2832
2847
|
closeOnBack: this.closeOnBack,
|
|
2833
2848
|
closeOnRouteChange: this.closeOnRouteChange,
|
|
2834
2849
|
persistKey: this.persistKey,
|
|
2835
|
-
autoCollapseAfter
|
|
2850
|
+
autoCollapseAfter,
|
|
2851
|
+
fitContentToSnap: this.fitContentToSnap
|
|
2836
2852
|
},
|
|
2837
2853
|
isDestroyed: () => this.destroyed,
|
|
2838
2854
|
isDragging: () => this.isDraggingAny(),
|
|
@@ -2882,6 +2898,9 @@ class BottomSheetCore {
|
|
|
2882
2898
|
if ((this.closeOnBack || this.routedTo !== void 0 || this.closeOnRouteChange) && !names.has("route")) {
|
|
2883
2899
|
devWarn("[BottomSheet] closeOnBack/routedTo/closeOnRouteChange need routeFeature() — option ignored");
|
|
2884
2900
|
}
|
|
2901
|
+
if (this.fitContentToSnap && !names.has("content-fit")) {
|
|
2902
|
+
devWarn("[BottomSheet] fitContentToSnap needs contentFitFeature() — option ignored");
|
|
2903
|
+
}
|
|
2885
2904
|
if (this.persistKey && !names.has("persist")) {
|
|
2886
2905
|
devWarn("[BottomSheet] persistKey needs persistFeature() — snaps will not be saved");
|
|
2887
2906
|
}
|
|
@@ -4206,13 +4225,71 @@ function visualViewportFeature() {
|
|
|
4206
4225
|
}
|
|
4207
4226
|
};
|
|
4208
4227
|
}
|
|
4228
|
+
const INSET_VAR = "--bs-content-inset";
|
|
4229
|
+
const FIT_ATTR = "data-bs-fit-content";
|
|
4230
|
+
function contentFitFeature() {
|
|
4231
|
+
return {
|
|
4232
|
+
name: "content-fit",
|
|
4233
|
+
install: (ctx) => {
|
|
4234
|
+
const scroller = ctx.scrollContainer;
|
|
4235
|
+
if (!ctx.options.fitContentToSnap || !scroller || typeof window === "undefined") {
|
|
4236
|
+
return;
|
|
4237
|
+
}
|
|
4238
|
+
const sheet = ctx.element;
|
|
4239
|
+
let inset = 0;
|
|
4240
|
+
let unpaddedMax = -1;
|
|
4241
|
+
let top = 0;
|
|
4242
|
+
const hiddenAt = (size) => sheet.dataset.mode === "bottom" ? Math.max(0, ctx.getMaxAxisSize() - size) : 0;
|
|
4243
|
+
const follow = (size) => {
|
|
4244
|
+
if (unpaddedMax < 0) {
|
|
4245
|
+
unpaddedMax = scroller.scrollHeight - scroller.clientHeight - inset;
|
|
4246
|
+
top = scroller.scrollTop;
|
|
4247
|
+
}
|
|
4248
|
+
const limit = Math.max(0, unpaddedMax + hiddenAt(size));
|
|
4249
|
+
if (top > limit) {
|
|
4250
|
+
if (scroller.scrollTop > limit) scroller.scrollTop = limit;
|
|
4251
|
+
top = limit;
|
|
4252
|
+
}
|
|
4253
|
+
};
|
|
4254
|
+
const settle = () => {
|
|
4255
|
+
if (ctx.isDestroyed()) return;
|
|
4256
|
+
const size = ctx.getSize();
|
|
4257
|
+
unpaddedMax = -1;
|
|
4258
|
+
follow(size);
|
|
4259
|
+
inset = hiddenAt(size);
|
|
4260
|
+
sheet.style.setProperty(INSET_VAR, `${inset}px`);
|
|
4261
|
+
unpaddedMax = -1;
|
|
4262
|
+
};
|
|
4263
|
+
const moving = () => ctx.isAnimating() || ctx.isDragging();
|
|
4264
|
+
const whenIdle = () => {
|
|
4265
|
+
if (!moving()) settle();
|
|
4266
|
+
};
|
|
4267
|
+
sheet.setAttribute(FIT_ATTR, "");
|
|
4268
|
+
settle();
|
|
4269
|
+
const offProgress = ctx.on("progress", (p) => moving() ? follow(p.size) : settle());
|
|
4270
|
+
const offSnap = ctx.on("snap", settle);
|
|
4271
|
+
const observer = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(whenIdle);
|
|
4272
|
+
observer?.observe(document.documentElement);
|
|
4273
|
+
window.addEventListener("orientationchange", whenIdle);
|
|
4274
|
+
return () => {
|
|
4275
|
+
offProgress();
|
|
4276
|
+
offSnap();
|
|
4277
|
+
observer?.disconnect();
|
|
4278
|
+
window.removeEventListener("orientationchange", whenIdle);
|
|
4279
|
+
sheet.removeAttribute(FIT_ATTR);
|
|
4280
|
+
sheet.style.removeProperty(INSET_VAR);
|
|
4281
|
+
};
|
|
4282
|
+
}
|
|
4283
|
+
};
|
|
4284
|
+
}
|
|
4209
4285
|
function defaultEngineFeatures() {
|
|
4210
4286
|
return [
|
|
4211
4287
|
contentSwipeFeature(),
|
|
4212
4288
|
visualViewportFeature(),
|
|
4213
4289
|
persistFeature(),
|
|
4214
4290
|
autoCollapseFeature(),
|
|
4215
|
-
routeFeature()
|
|
4291
|
+
routeFeature(),
|
|
4292
|
+
contentFitFeature()
|
|
4216
4293
|
];
|
|
4217
4294
|
}
|
|
4218
4295
|
class BottomSheetEngine extends BottomSheetCore {
|
|
@@ -4309,6 +4386,7 @@ const BottomSheet = component$((props) => {
|
|
|
4309
4386
|
disableDrag: props.disableDrag,
|
|
4310
4387
|
dragFrom: props.dragFrom,
|
|
4311
4388
|
dragFromContent: props.dragFromContent,
|
|
4389
|
+
fitContentToSnap: props.fitContentToSnap,
|
|
4312
4390
|
closeOnRouteChange: props.closeOnRouteChange,
|
|
4313
4391
|
stackEffect: props.stackEffect,
|
|
4314
4392
|
returnFocusTo: props.returnFocusTo,
|