@surdeddd/bottom-sheet 0.21.0 → 0.21.2
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 +9 -0
- package/dist/{BottomSheetCore-CK8Rh1He.d.cts → BottomSheetCore-BHv6LPmS.d.cts} +1 -1
- package/dist/{BottomSheetCore-CIijwtdi.d.ts → BottomSheetCore-CK_mq14p.d.ts} +1 -1
- package/dist/{BottomSheetEngine-hLSAxzla.d.cts → BottomSheetEngine-mmFzIK1Z.d.cts} +1 -1
- package/dist/{BottomSheetEngine-CZglPsTF.d.ts → BottomSheetEngine-wLn6Q2kA.d.ts} +1 -1
- package/dist/core.cjs +31 -21
- package/dist/core.d.cts +2 -2
- package/dist/core.d.ts +2 -2
- package/dist/core.js +31 -21
- package/dist/debug.d.cts +1 -1
- package/dist/debug.d.ts +1 -1
- package/dist/element.cjs +37 -26
- 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 +37 -26
- package/dist/features.d.cts +2 -2
- package/dist/features.d.ts +2 -2
- package/dist/{index-BqLHKOeM.d.ts → index-CWKv1Xy4.d.ts} +1 -1
- package/dist/{index-BEX-NHRJ.d.cts → index-juAyT76E.d.cts} +1 -1
- package/dist/index.cjs +31 -21
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +31 -21
- 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 +29 -19
- package/dist/qwik-lib/index.qwik.mjs +29 -19
- package/dist/qwik.cjs +31 -21
- package/dist/qwik.d.cts +2 -2
- package/dist/qwik.d.ts +2 -2
- package/dist/qwik.js +31 -21
- package/dist/react.cjs +31 -21
- package/dist/react.d.cts +3 -3
- package/dist/react.d.ts +3 -3
- package/dist/react.js +31 -21
- package/dist/solid.cjs +31 -21
- package/dist/solid.d.cts +1 -1
- package/dist/solid.d.ts +1 -1
- package/dist/solid.js +31 -21
- package/dist/solid.source.jsx +31 -21
- package/dist/svelte-core.cjs +31 -21
- package/dist/svelte-core.js +31 -21
- package/dist/svelte.cjs +31 -21
- package/dist/svelte.js +31 -21
- package/dist/vue.cjs +31 -21
- package/dist/vue.js +31 -21
- package/dist/webgl.d.cts +1 -1
- package/dist/webgl.d.ts +1 -1
- package/package.json +2 -2
package/dist/element.js
CHANGED
|
@@ -431,14 +431,31 @@ var init_linked_sheets = __esm({
|
|
|
431
431
|
}
|
|
432
432
|
});
|
|
433
433
|
|
|
434
|
+
// src/core/primitives/hot-path-thresholds.ts
|
|
435
|
+
var SIZE_WRITE_EPSILON, OPACITY_WRITE_EPSILON, POINTER_EVENTS_OPACITY_THRESHOLD, RANGE_DIVISION_EPSILON;
|
|
436
|
+
var init_hot_path_thresholds = __esm({
|
|
437
|
+
"src/core/primitives/hot-path-thresholds.ts"() {
|
|
438
|
+
SIZE_WRITE_EPSILON = 0.5;
|
|
439
|
+
OPACITY_WRITE_EPSILON = 5e-3;
|
|
440
|
+
POINTER_EVENTS_OPACITY_THRESHOLD = 0.05;
|
|
441
|
+
RANGE_DIVISION_EPSILON = 1e-4;
|
|
442
|
+
}
|
|
443
|
+
});
|
|
444
|
+
|
|
434
445
|
// src/core/features/resize-observer.ts
|
|
435
446
|
function installResizeObserver(deps) {
|
|
436
447
|
if (typeof window === "undefined") {
|
|
437
448
|
return () => {
|
|
438
449
|
};
|
|
439
450
|
}
|
|
451
|
+
const seatFor = () => {
|
|
452
|
+
const snap = deps.resolveActiveSnap();
|
|
453
|
+
const max = deps.getMaxAxisSize();
|
|
454
|
+
return { target: snap ? Math.min(snap.size, max) : null, max };
|
|
455
|
+
};
|
|
440
456
|
const onResize = () => {
|
|
441
457
|
if (deps.isDestroyed()) return;
|
|
458
|
+
const before = seatFor();
|
|
442
459
|
deps.recomputeSnaps();
|
|
443
460
|
const mode = deps.getMode();
|
|
444
461
|
const isVerticalAxis = mode === "bottom" || mode === "top";
|
|
@@ -447,6 +464,10 @@ function installResizeObserver(deps) {
|
|
|
447
464
|
if (viewportSize2 > 0 && viewportSize2 < max) {
|
|
448
465
|
deps.setMaxAxisSize(viewportSize2);
|
|
449
466
|
}
|
|
467
|
+
const after = seatFor();
|
|
468
|
+
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) {
|
|
469
|
+
return;
|
|
470
|
+
}
|
|
450
471
|
const wasAnimating = deps.isAnimating?.() ?? false;
|
|
451
472
|
deps.cancelInFlight();
|
|
452
473
|
deps.newCycle();
|
|
@@ -481,6 +502,7 @@ function installResizeObserver(deps) {
|
|
|
481
502
|
}
|
|
482
503
|
var init_resize_observer = __esm({
|
|
483
504
|
"src/core/features/resize-observer.ts"() {
|
|
505
|
+
init_hot_path_thresholds();
|
|
484
506
|
}
|
|
485
507
|
});
|
|
486
508
|
|
|
@@ -745,17 +767,6 @@ var init_types = __esm({
|
|
|
745
767
|
}
|
|
746
768
|
});
|
|
747
769
|
|
|
748
|
-
// src/core/primitives/hot-path-thresholds.ts
|
|
749
|
-
var SIZE_WRITE_EPSILON, OPACITY_WRITE_EPSILON, POINTER_EVENTS_OPACITY_THRESHOLD, RANGE_DIVISION_EPSILON;
|
|
750
|
-
var init_hot_path_thresholds = __esm({
|
|
751
|
-
"src/core/primitives/hot-path-thresholds.ts"() {
|
|
752
|
-
SIZE_WRITE_EPSILON = 0.5;
|
|
753
|
-
OPACITY_WRITE_EPSILON = 5e-3;
|
|
754
|
-
POINTER_EVENTS_OPACITY_THRESHOLD = 0.05;
|
|
755
|
-
RANGE_DIVISION_EPSILON = 1e-4;
|
|
756
|
-
}
|
|
757
|
-
});
|
|
758
|
-
|
|
759
770
|
// src/core/primitives/opacity-dedup.ts
|
|
760
771
|
var WriteSentinel;
|
|
761
772
|
var init_opacity_dedup = __esm({
|
|
@@ -883,7 +894,6 @@ var init_scrim_controller = __esm({
|
|
|
883
894
|
__publicField(this, "backdrop");
|
|
884
895
|
__publicField(this, "mode");
|
|
885
896
|
__publicField(this, "isDestroyed");
|
|
886
|
-
__publicField(this, "isTopSheet");
|
|
887
897
|
__publicField(this, "getAllowedIds");
|
|
888
898
|
__publicField(this, "getResolvedSnaps");
|
|
889
899
|
__publicField(this, "snapToFn");
|
|
@@ -905,7 +915,6 @@ var init_scrim_controller = __esm({
|
|
|
905
915
|
this.backdrop = deps.backdrop;
|
|
906
916
|
this.mode = deps.mode;
|
|
907
917
|
this.isDestroyed = deps.isDestroyed;
|
|
908
|
-
this.isTopSheet = deps.isTopSheet;
|
|
909
918
|
this.getAllowedIds = deps.getAllowedIds;
|
|
910
919
|
this.getResolvedSnaps = deps.getResolvedSnaps;
|
|
911
920
|
this.snapToFn = deps.snapTo;
|
|
@@ -950,8 +959,10 @@ var init_scrim_controller = __esm({
|
|
|
950
959
|
if (this.backdrop) {
|
|
951
960
|
const [s, e] = this.backdropRange;
|
|
952
961
|
const range = Math.max(e - s, RANGE_DIVISION_EPSILON);
|
|
953
|
-
const
|
|
954
|
-
|
|
962
|
+
const backdropOpacity = Math.min(
|
|
963
|
+
Math.max((progress - s) / range, 0),
|
|
964
|
+
1
|
|
965
|
+
);
|
|
955
966
|
if (this.backdropOpacitySentinel.shouldWrite(
|
|
956
967
|
backdropOpacity,
|
|
957
968
|
OPACITY_WRITE_EPSILON
|
|
@@ -2893,6 +2904,7 @@ var init_BottomSheetCore = __esm({
|
|
|
2893
2904
|
__publicField(this, "progressWriteSentinel", new WriteSentinel());
|
|
2894
2905
|
__publicField(this, "isTopSheet", true);
|
|
2895
2906
|
__publicField(this, "opening", false);
|
|
2907
|
+
__publicField(this, "promotedForOpen", false);
|
|
2896
2908
|
__publicField(this, "allowOvershoot", false);
|
|
2897
2909
|
__publicField(this, "progressPayload", {
|
|
2898
2910
|
value: 0,
|
|
@@ -2949,7 +2961,6 @@ var init_BottomSheetCore = __esm({
|
|
|
2949
2961
|
screenComponent: this.screenComponent,
|
|
2950
2962
|
backdrop: this.backdrop,
|
|
2951
2963
|
isDestroyed: () => this.destroyed,
|
|
2952
|
-
isTopSheet: () => this.isTopSheet,
|
|
2953
2964
|
getAllowedIds: () => this.snaps.getAllowedIds().slice(),
|
|
2954
2965
|
getResolvedSnaps: () => this.snaps.getResolvedSnaps().slice(),
|
|
2955
2966
|
snapTo: (id) => {
|
|
@@ -3219,13 +3230,14 @@ var init_BottomSheetCore = __esm({
|
|
|
3219
3230
|
if (!_skipBeforeSnap && this.emitBeforeSnap(target, this.activeId)) {
|
|
3220
3231
|
return;
|
|
3221
3232
|
}
|
|
3233
|
+
const resumingOpen = this.opening;
|
|
3222
3234
|
const signal = this.newCycle();
|
|
3223
3235
|
const onExternalAbort = () => {
|
|
3224
3236
|
this.animation.cancel();
|
|
3225
3237
|
this.newCycle();
|
|
3226
3238
|
};
|
|
3227
3239
|
externalSignal?.addEventListener("abort", onExternalAbort, { once: true });
|
|
3228
|
-
const wasClosed = this.size === 0;
|
|
3240
|
+
const wasClosed = this.size === 0 || resumingOpen;
|
|
3229
3241
|
const previousId = this.activeId;
|
|
3230
3242
|
const previousSize = this.size;
|
|
3231
3243
|
this.scrollCache.cache(previousId, previousSize, target.size);
|
|
@@ -3234,7 +3246,10 @@ var init_BottomSheetCore = __esm({
|
|
|
3234
3246
|
const opensToRest = id === "closed" || rawTargetSize === 0;
|
|
3235
3247
|
if (wasClosed && !opensToRest) {
|
|
3236
3248
|
this.opening = true;
|
|
3237
|
-
|
|
3249
|
+
if (!resumingOpen) {
|
|
3250
|
+
this.promotedForOpen = true;
|
|
3251
|
+
sheetStack.promote(this.id);
|
|
3252
|
+
}
|
|
3238
3253
|
}
|
|
3239
3254
|
if (this.animation.viewTransitionsAvailable) {
|
|
3240
3255
|
this.currentViewTransition?.skipTransition?.();
|
|
@@ -3675,19 +3690,12 @@ var init_BottomSheetCore = __esm({
|
|
|
3675
3690
|
for (const anchor of this.anchors) anchor.syncZ(z + 1);
|
|
3676
3691
|
},
|
|
3677
3692
|
setIsTop: (isTop) => {
|
|
3678
|
-
if (this.isTopSheet === isTop) return;
|
|
3679
3693
|
this.isTopSheet = isTop;
|
|
3680
|
-
this.repaintScrim();
|
|
3681
3694
|
},
|
|
3682
3695
|
isOpen: () => this.size > 0 || this.opening,
|
|
3683
3696
|
setDepth: (depth) => this.applyStackDepth(depth)
|
|
3684
3697
|
}));
|
|
3685
3698
|
}
|
|
3686
|
-
repaintScrim() {
|
|
3687
|
-
if (this.destroyed) return;
|
|
3688
|
-
this.scrim.invalidateOpacityCache();
|
|
3689
|
-
this.scrim.applyOpacity(this.computeProgress(this.size), true);
|
|
3690
|
-
}
|
|
3691
3699
|
applyStackDepth(depth) {
|
|
3692
3700
|
if (!this.stackEffectEnabled) return;
|
|
3693
3701
|
this.element.setAttribute("data-stack-depth", String(depth));
|
|
@@ -3932,6 +3940,7 @@ var init_BottomSheetCore = __esm({
|
|
|
3932
3940
|
this.activeId = target.id;
|
|
3933
3941
|
if (previousSnapSize === 0 && target.size > 0) {
|
|
3934
3942
|
this.opening = true;
|
|
3943
|
+
this.promotedForOpen = true;
|
|
3935
3944
|
sheetStack.promote(this.id);
|
|
3936
3945
|
}
|
|
3937
3946
|
const settleCap = this.snaps.getMaxAxisSize();
|
|
@@ -4013,7 +4022,8 @@ var init_BottomSheetCore = __esm({
|
|
|
4013
4022
|
return Math.min(Math.max((size - min) / (reachableMax - min), 0), 1);
|
|
4014
4023
|
}
|
|
4015
4024
|
handleOpen() {
|
|
4016
|
-
|
|
4025
|
+
if (this.promotedForOpen) this.promotedForOpen = false;
|
|
4026
|
+
else sheetStack.promote(this.id);
|
|
4017
4027
|
try {
|
|
4018
4028
|
this.lifecycle.install();
|
|
4019
4029
|
} catch (err) {
|
|
@@ -4045,6 +4055,7 @@ var init_BottomSheetCore = __esm({
|
|
|
4045
4055
|
}
|
|
4046
4056
|
handleClose() {
|
|
4047
4057
|
this.opening = false;
|
|
4058
|
+
this.promotedForOpen = false;
|
|
4048
4059
|
this.lifecycle.release();
|
|
4049
4060
|
sheetStack.update();
|
|
4050
4061
|
}
|
package/dist/features.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { f as EngineFeature } from './BottomSheetCore-
|
|
2
|
-
export { m as EngineFeatureContext, n as EngineFeatureOptions, o as EngineFeatureStage } from './BottomSheetCore-
|
|
1
|
+
import { f as EngineFeature } from './BottomSheetCore-BHv6LPmS.cjs';
|
|
2
|
+
export { m as EngineFeatureContext, n as EngineFeatureOptions, o as EngineFeatureStage } from './BottomSheetCore-BHv6LPmS.cjs';
|
|
3
3
|
import './transform-jVfAikE9.cjs';
|
|
4
4
|
|
|
5
5
|
declare function routeFeature(): EngineFeature;
|
package/dist/features.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { f as EngineFeature } from './BottomSheetCore-
|
|
2
|
-
export { m as EngineFeatureContext, n as EngineFeatureOptions, o as EngineFeatureStage } from './BottomSheetCore-
|
|
1
|
+
import { f as EngineFeature } from './BottomSheetCore-CK_mq14p.js';
|
|
2
|
+
export { m as EngineFeatureContext, n as EngineFeatureOptions, o as EngineFeatureStage } from './BottomSheetCore-CK_mq14p.js';
|
|
3
3
|
import './transform-jVfAikE9.js';
|
|
4
4
|
|
|
5
5
|
declare function routeFeature(): EngineFeature;
|
package/dist/index.cjs
CHANGED
|
@@ -375,14 +375,26 @@ function notifyLinkedSheets(sheets, self) {
|
|
|
375
375
|
}
|
|
376
376
|
}
|
|
377
377
|
|
|
378
|
+
// src/core/primitives/hot-path-thresholds.ts
|
|
379
|
+
var SIZE_WRITE_EPSILON = 0.5;
|
|
380
|
+
var OPACITY_WRITE_EPSILON = 5e-3;
|
|
381
|
+
var POINTER_EVENTS_OPACITY_THRESHOLD = 0.05;
|
|
382
|
+
var RANGE_DIVISION_EPSILON = 1e-4;
|
|
383
|
+
|
|
378
384
|
// src/core/features/resize-observer.ts
|
|
379
385
|
function installResizeObserver(deps) {
|
|
380
386
|
if (typeof window === "undefined") {
|
|
381
387
|
return () => {
|
|
382
388
|
};
|
|
383
389
|
}
|
|
390
|
+
const seatFor = () => {
|
|
391
|
+
const snap = deps.resolveActiveSnap();
|
|
392
|
+
const max = deps.getMaxAxisSize();
|
|
393
|
+
return { target: snap ? Math.min(snap.size, max) : null, max };
|
|
394
|
+
};
|
|
384
395
|
const onResize = () => {
|
|
385
396
|
if (deps.isDestroyed()) return;
|
|
397
|
+
const before = seatFor();
|
|
386
398
|
deps.recomputeSnaps();
|
|
387
399
|
const mode = deps.getMode();
|
|
388
400
|
const isVerticalAxis = mode === "bottom" || mode === "top";
|
|
@@ -391,6 +403,10 @@ function installResizeObserver(deps) {
|
|
|
391
403
|
if (viewportSize2 > 0 && viewportSize2 < max) {
|
|
392
404
|
deps.setMaxAxisSize(viewportSize2);
|
|
393
405
|
}
|
|
406
|
+
const after = seatFor();
|
|
407
|
+
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) {
|
|
408
|
+
return;
|
|
409
|
+
}
|
|
394
410
|
const wasAnimating = deps.isAnimating?.() ?? false;
|
|
395
411
|
deps.cancelInFlight();
|
|
396
412
|
deps.newCycle();
|
|
@@ -659,12 +675,6 @@ var SCRIM_PRESETS = Object.freeze({
|
|
|
659
675
|
}
|
|
660
676
|
});
|
|
661
677
|
|
|
662
|
-
// src/core/primitives/hot-path-thresholds.ts
|
|
663
|
-
var SIZE_WRITE_EPSILON = 0.5;
|
|
664
|
-
var OPACITY_WRITE_EPSILON = 5e-3;
|
|
665
|
-
var POINTER_EVENTS_OPACITY_THRESHOLD = 0.05;
|
|
666
|
-
var RANGE_DIVISION_EPSILON = 1e-4;
|
|
667
|
-
|
|
668
678
|
// src/core/primitives/opacity-dedup.ts
|
|
669
679
|
var WriteSentinel = class {
|
|
670
680
|
constructor() {
|
|
@@ -774,7 +784,6 @@ var ScrimController = class {
|
|
|
774
784
|
__publicField(this, "backdrop");
|
|
775
785
|
__publicField(this, "mode");
|
|
776
786
|
__publicField(this, "isDestroyed");
|
|
777
|
-
__publicField(this, "isTopSheet");
|
|
778
787
|
__publicField(this, "getAllowedIds");
|
|
779
788
|
__publicField(this, "getResolvedSnaps");
|
|
780
789
|
__publicField(this, "snapToFn");
|
|
@@ -796,7 +805,6 @@ var ScrimController = class {
|
|
|
796
805
|
this.backdrop = deps.backdrop;
|
|
797
806
|
this.mode = deps.mode;
|
|
798
807
|
this.isDestroyed = deps.isDestroyed;
|
|
799
|
-
this.isTopSheet = deps.isTopSheet;
|
|
800
808
|
this.getAllowedIds = deps.getAllowedIds;
|
|
801
809
|
this.getResolvedSnaps = deps.getResolvedSnaps;
|
|
802
810
|
this.snapToFn = deps.snapTo;
|
|
@@ -841,8 +849,10 @@ var ScrimController = class {
|
|
|
841
849
|
if (this.backdrop) {
|
|
842
850
|
const [s, e] = this.backdropRange;
|
|
843
851
|
const range = Math.max(e - s, RANGE_DIVISION_EPSILON);
|
|
844
|
-
const
|
|
845
|
-
|
|
852
|
+
const backdropOpacity = Math.min(
|
|
853
|
+
Math.max((progress - s) / range, 0),
|
|
854
|
+
1
|
|
855
|
+
);
|
|
846
856
|
if (this.backdropOpacitySentinel.shouldWrite(
|
|
847
857
|
backdropOpacity,
|
|
848
858
|
OPACITY_WRITE_EPSILON
|
|
@@ -2617,6 +2627,7 @@ var BottomSheetCore = class {
|
|
|
2617
2627
|
__publicField(this, "progressWriteSentinel", new WriteSentinel());
|
|
2618
2628
|
__publicField(this, "isTopSheet", true);
|
|
2619
2629
|
__publicField(this, "opening", false);
|
|
2630
|
+
__publicField(this, "promotedForOpen", false);
|
|
2620
2631
|
__publicField(this, "allowOvershoot", false);
|
|
2621
2632
|
__publicField(this, "progressPayload", {
|
|
2622
2633
|
value: 0,
|
|
@@ -2673,7 +2684,6 @@ var BottomSheetCore = class {
|
|
|
2673
2684
|
screenComponent: this.screenComponent,
|
|
2674
2685
|
backdrop: this.backdrop,
|
|
2675
2686
|
isDestroyed: () => this.destroyed,
|
|
2676
|
-
isTopSheet: () => this.isTopSheet,
|
|
2677
2687
|
getAllowedIds: () => this.snaps.getAllowedIds().slice(),
|
|
2678
2688
|
getResolvedSnaps: () => this.snaps.getResolvedSnaps().slice(),
|
|
2679
2689
|
snapTo: (id) => {
|
|
@@ -2943,13 +2953,14 @@ var BottomSheetCore = class {
|
|
|
2943
2953
|
if (!_skipBeforeSnap && this.emitBeforeSnap(target, this.activeId)) {
|
|
2944
2954
|
return;
|
|
2945
2955
|
}
|
|
2956
|
+
const resumingOpen = this.opening;
|
|
2946
2957
|
const signal = this.newCycle();
|
|
2947
2958
|
const onExternalAbort = () => {
|
|
2948
2959
|
this.animation.cancel();
|
|
2949
2960
|
this.newCycle();
|
|
2950
2961
|
};
|
|
2951
2962
|
externalSignal?.addEventListener("abort", onExternalAbort, { once: true });
|
|
2952
|
-
const wasClosed = this.size === 0;
|
|
2963
|
+
const wasClosed = this.size === 0 || resumingOpen;
|
|
2953
2964
|
const previousId = this.activeId;
|
|
2954
2965
|
const previousSize = this.size;
|
|
2955
2966
|
this.scrollCache.cache(previousId, previousSize, target.size);
|
|
@@ -2958,7 +2969,10 @@ var BottomSheetCore = class {
|
|
|
2958
2969
|
const opensToRest = id === "closed" || rawTargetSize === 0;
|
|
2959
2970
|
if (wasClosed && !opensToRest) {
|
|
2960
2971
|
this.opening = true;
|
|
2961
|
-
|
|
2972
|
+
if (!resumingOpen) {
|
|
2973
|
+
this.promotedForOpen = true;
|
|
2974
|
+
sheetStack.promote(this.id);
|
|
2975
|
+
}
|
|
2962
2976
|
}
|
|
2963
2977
|
if (this.animation.viewTransitionsAvailable) {
|
|
2964
2978
|
this.currentViewTransition?.skipTransition?.();
|
|
@@ -3399,19 +3413,12 @@ var BottomSheetCore = class {
|
|
|
3399
3413
|
for (const anchor of this.anchors) anchor.syncZ(z + 1);
|
|
3400
3414
|
},
|
|
3401
3415
|
setIsTop: (isTop) => {
|
|
3402
|
-
if (this.isTopSheet === isTop) return;
|
|
3403
3416
|
this.isTopSheet = isTop;
|
|
3404
|
-
this.repaintScrim();
|
|
3405
3417
|
},
|
|
3406
3418
|
isOpen: () => this.size > 0 || this.opening,
|
|
3407
3419
|
setDepth: (depth) => this.applyStackDepth(depth)
|
|
3408
3420
|
}));
|
|
3409
3421
|
}
|
|
3410
|
-
repaintScrim() {
|
|
3411
|
-
if (this.destroyed) return;
|
|
3412
|
-
this.scrim.invalidateOpacityCache();
|
|
3413
|
-
this.scrim.applyOpacity(this.computeProgress(this.size), true);
|
|
3414
|
-
}
|
|
3415
3422
|
applyStackDepth(depth) {
|
|
3416
3423
|
if (!this.stackEffectEnabled) return;
|
|
3417
3424
|
this.element.setAttribute("data-stack-depth", String(depth));
|
|
@@ -3656,6 +3663,7 @@ var BottomSheetCore = class {
|
|
|
3656
3663
|
this.activeId = target.id;
|
|
3657
3664
|
if (previousSnapSize === 0 && target.size > 0) {
|
|
3658
3665
|
this.opening = true;
|
|
3666
|
+
this.promotedForOpen = true;
|
|
3659
3667
|
sheetStack.promote(this.id);
|
|
3660
3668
|
}
|
|
3661
3669
|
const settleCap = this.snaps.getMaxAxisSize();
|
|
@@ -3737,7 +3745,8 @@ var BottomSheetCore = class {
|
|
|
3737
3745
|
return Math.min(Math.max((size - min) / (reachableMax - min), 0), 1);
|
|
3738
3746
|
}
|
|
3739
3747
|
handleOpen() {
|
|
3740
|
-
|
|
3748
|
+
if (this.promotedForOpen) this.promotedForOpen = false;
|
|
3749
|
+
else sheetStack.promote(this.id);
|
|
3741
3750
|
try {
|
|
3742
3751
|
this.lifecycle.install();
|
|
3743
3752
|
} catch (err) {
|
|
@@ -3769,6 +3778,7 @@ var BottomSheetCore = class {
|
|
|
3769
3778
|
}
|
|
3770
3779
|
handleClose() {
|
|
3771
3780
|
this.opening = false;
|
|
3781
|
+
this.promotedForOpen = false;
|
|
3772
3782
|
this.lifecycle.release();
|
|
3773
3783
|
sheetStack.update();
|
|
3774
3784
|
}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export { B as BottomSheetEngine } from './BottomSheetEngine-
|
|
2
|
-
import { d as SnapPoint, b as SheetMode, c as EngineOptions, P as PhysicalSheetMode, g as ScrimOverlayPosition } from './BottomSheetCore-
|
|
3
|
-
export { h as AnchorAnimationPreset, i as AnchorAnimationSpec, j as AnchorHandle, A as AnchorOptions, k as AnchorPosition, l as AnchorState, B as BottomSheetCore, C as CloseReason, f as EngineFeature, m as EngineFeatureContext, n as EngineFeatureOptions, o as EngineFeatureStage, E as EngineState, L as LogicalSheetMode, p as Plugin, q as SCRIM_PRESETS, r as ScrimOverlayOptions, s as ScrimPreset, t as ScrimPresetConfig, u as ScrimStageDef, e as ScrimStagesOptions, v as ScrimUpdate, S as SheetEventMap, w as SnapId, a as SnapPointDef, T as TeardownScope, x as runAnchorTransition } from './BottomSheetCore-
|
|
1
|
+
export { B as BottomSheetEngine } from './BottomSheetEngine-mmFzIK1Z.cjs';
|
|
2
|
+
import { d as SnapPoint, b as SheetMode, c as EngineOptions, P as PhysicalSheetMode, g as ScrimOverlayPosition } from './BottomSheetCore-BHv6LPmS.cjs';
|
|
3
|
+
export { h as AnchorAnimationPreset, i as AnchorAnimationSpec, j as AnchorHandle, A as AnchorOptions, k as AnchorPosition, l as AnchorState, B as BottomSheetCore, C as CloseReason, f as EngineFeature, m as EngineFeatureContext, n as EngineFeatureOptions, o as EngineFeatureStage, E as EngineState, L as LogicalSheetMode, p as Plugin, q as SCRIM_PRESETS, r as ScrimOverlayOptions, s as ScrimPreset, t as ScrimPresetConfig, u as ScrimStageDef, e as ScrimStagesOptions, v as ScrimUpdate, S as SheetEventMap, w as SnapId, a as SnapPointDef, T as TeardownScope, x as runAnchorTransition } from './BottomSheetCore-BHv6LPmS.cjs';
|
|
4
4
|
export { autoCollapseFeature, contentSwipeFeature, defaultEngineFeatures, persistFeature, routeFeature, visualViewportFeature } from './features.cjs';
|
|
5
|
-
export { R as ResolvedSnap, r as resolveSnapList } from './index-
|
|
5
|
+
export { R as ResolvedSnap, r as resolveSnapList } from './index-juAyT76E.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 { d as SnapPoint, b as SheetMode, c as EngineOptions, P as PhysicalSheetMode, g as ScrimOverlayPosition } from './BottomSheetCore-
|
|
3
|
-
export { h as AnchorAnimationPreset, i as AnchorAnimationSpec, j as AnchorHandle, A as AnchorOptions, k as AnchorPosition, l as AnchorState, B as BottomSheetCore, C as CloseReason, f as EngineFeature, m as EngineFeatureContext, n as EngineFeatureOptions, o as EngineFeatureStage, E as EngineState, L as LogicalSheetMode, p as Plugin, q as SCRIM_PRESETS, r as ScrimOverlayOptions, s as ScrimPreset, t as ScrimPresetConfig, u as ScrimStageDef, e as ScrimStagesOptions, v as ScrimUpdate, S as SheetEventMap, w as SnapId, a as SnapPointDef, T as TeardownScope, x as runAnchorTransition } from './BottomSheetCore-
|
|
1
|
+
export { B as BottomSheetEngine } from './BottomSheetEngine-wLn6Q2kA.js';
|
|
2
|
+
import { d as SnapPoint, b as SheetMode, c as EngineOptions, P as PhysicalSheetMode, g as ScrimOverlayPosition } from './BottomSheetCore-CK_mq14p.js';
|
|
3
|
+
export { h as AnchorAnimationPreset, i as AnchorAnimationSpec, j as AnchorHandle, A as AnchorOptions, k as AnchorPosition, l as AnchorState, B as BottomSheetCore, C as CloseReason, f as EngineFeature, m as EngineFeatureContext, n as EngineFeatureOptions, o as EngineFeatureStage, E as EngineState, L as LogicalSheetMode, p as Plugin, q as SCRIM_PRESETS, r as ScrimOverlayOptions, s as ScrimPreset, t as ScrimPresetConfig, u as ScrimStageDef, e as ScrimStagesOptions, v as ScrimUpdate, S as SheetEventMap, w as SnapId, a as SnapPointDef, T as TeardownScope, x as runAnchorTransition } from './BottomSheetCore-CK_mq14p.js';
|
|
4
4
|
export { autoCollapseFeature, contentSwipeFeature, defaultEngineFeatures, persistFeature, routeFeature, visualViewportFeature } from './features.js';
|
|
5
|
-
export { R as ResolvedSnap, r as resolveSnapList } from './index-
|
|
5
|
+
export { R as ResolvedSnap, r as resolveSnapList } from './index-CWKv1Xy4.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() {
|
|
@@ -772,7 +782,6 @@ var ScrimController = class {
|
|
|
772
782
|
__publicField(this, "backdrop");
|
|
773
783
|
__publicField(this, "mode");
|
|
774
784
|
__publicField(this, "isDestroyed");
|
|
775
|
-
__publicField(this, "isTopSheet");
|
|
776
785
|
__publicField(this, "getAllowedIds");
|
|
777
786
|
__publicField(this, "getResolvedSnaps");
|
|
778
787
|
__publicField(this, "snapToFn");
|
|
@@ -794,7 +803,6 @@ var ScrimController = class {
|
|
|
794
803
|
this.backdrop = deps.backdrop;
|
|
795
804
|
this.mode = deps.mode;
|
|
796
805
|
this.isDestroyed = deps.isDestroyed;
|
|
797
|
-
this.isTopSheet = deps.isTopSheet;
|
|
798
806
|
this.getAllowedIds = deps.getAllowedIds;
|
|
799
807
|
this.getResolvedSnaps = deps.getResolvedSnaps;
|
|
800
808
|
this.snapToFn = deps.snapTo;
|
|
@@ -839,8 +847,10 @@ var ScrimController = class {
|
|
|
839
847
|
if (this.backdrop) {
|
|
840
848
|
const [s, e] = this.backdropRange;
|
|
841
849
|
const range = Math.max(e - s, RANGE_DIVISION_EPSILON);
|
|
842
|
-
const
|
|
843
|
-
|
|
850
|
+
const backdropOpacity = Math.min(
|
|
851
|
+
Math.max((progress - s) / range, 0),
|
|
852
|
+
1
|
|
853
|
+
);
|
|
844
854
|
if (this.backdropOpacitySentinel.shouldWrite(
|
|
845
855
|
backdropOpacity,
|
|
846
856
|
OPACITY_WRITE_EPSILON
|
|
@@ -2615,6 +2625,7 @@ var BottomSheetCore = class {
|
|
|
2615
2625
|
__publicField(this, "progressWriteSentinel", new WriteSentinel());
|
|
2616
2626
|
__publicField(this, "isTopSheet", true);
|
|
2617
2627
|
__publicField(this, "opening", false);
|
|
2628
|
+
__publicField(this, "promotedForOpen", false);
|
|
2618
2629
|
__publicField(this, "allowOvershoot", false);
|
|
2619
2630
|
__publicField(this, "progressPayload", {
|
|
2620
2631
|
value: 0,
|
|
@@ -2671,7 +2682,6 @@ var BottomSheetCore = class {
|
|
|
2671
2682
|
screenComponent: this.screenComponent,
|
|
2672
2683
|
backdrop: this.backdrop,
|
|
2673
2684
|
isDestroyed: () => this.destroyed,
|
|
2674
|
-
isTopSheet: () => this.isTopSheet,
|
|
2675
2685
|
getAllowedIds: () => this.snaps.getAllowedIds().slice(),
|
|
2676
2686
|
getResolvedSnaps: () => this.snaps.getResolvedSnaps().slice(),
|
|
2677
2687
|
snapTo: (id) => {
|
|
@@ -2941,13 +2951,14 @@ var BottomSheetCore = class {
|
|
|
2941
2951
|
if (!_skipBeforeSnap && this.emitBeforeSnap(target, this.activeId)) {
|
|
2942
2952
|
return;
|
|
2943
2953
|
}
|
|
2954
|
+
const resumingOpen = this.opening;
|
|
2944
2955
|
const signal = this.newCycle();
|
|
2945
2956
|
const onExternalAbort = () => {
|
|
2946
2957
|
this.animation.cancel();
|
|
2947
2958
|
this.newCycle();
|
|
2948
2959
|
};
|
|
2949
2960
|
externalSignal?.addEventListener("abort", onExternalAbort, { once: true });
|
|
2950
|
-
const wasClosed = this.size === 0;
|
|
2961
|
+
const wasClosed = this.size === 0 || resumingOpen;
|
|
2951
2962
|
const previousId = this.activeId;
|
|
2952
2963
|
const previousSize = this.size;
|
|
2953
2964
|
this.scrollCache.cache(previousId, previousSize, target.size);
|
|
@@ -2956,7 +2967,10 @@ var BottomSheetCore = class {
|
|
|
2956
2967
|
const opensToRest = id === "closed" || rawTargetSize === 0;
|
|
2957
2968
|
if (wasClosed && !opensToRest) {
|
|
2958
2969
|
this.opening = true;
|
|
2959
|
-
|
|
2970
|
+
if (!resumingOpen) {
|
|
2971
|
+
this.promotedForOpen = true;
|
|
2972
|
+
sheetStack.promote(this.id);
|
|
2973
|
+
}
|
|
2960
2974
|
}
|
|
2961
2975
|
if (this.animation.viewTransitionsAvailable) {
|
|
2962
2976
|
this.currentViewTransition?.skipTransition?.();
|
|
@@ -3397,19 +3411,12 @@ var BottomSheetCore = class {
|
|
|
3397
3411
|
for (const anchor of this.anchors) anchor.syncZ(z + 1);
|
|
3398
3412
|
},
|
|
3399
3413
|
setIsTop: (isTop) => {
|
|
3400
|
-
if (this.isTopSheet === isTop) return;
|
|
3401
3414
|
this.isTopSheet = isTop;
|
|
3402
|
-
this.repaintScrim();
|
|
3403
3415
|
},
|
|
3404
3416
|
isOpen: () => this.size > 0 || this.opening,
|
|
3405
3417
|
setDepth: (depth) => this.applyStackDepth(depth)
|
|
3406
3418
|
}));
|
|
3407
3419
|
}
|
|
3408
|
-
repaintScrim() {
|
|
3409
|
-
if (this.destroyed) return;
|
|
3410
|
-
this.scrim.invalidateOpacityCache();
|
|
3411
|
-
this.scrim.applyOpacity(this.computeProgress(this.size), true);
|
|
3412
|
-
}
|
|
3413
3420
|
applyStackDepth(depth) {
|
|
3414
3421
|
if (!this.stackEffectEnabled) return;
|
|
3415
3422
|
this.element.setAttribute("data-stack-depth", String(depth));
|
|
@@ -3654,6 +3661,7 @@ var BottomSheetCore = class {
|
|
|
3654
3661
|
this.activeId = target.id;
|
|
3655
3662
|
if (previousSnapSize === 0 && target.size > 0) {
|
|
3656
3663
|
this.opening = true;
|
|
3664
|
+
this.promotedForOpen = true;
|
|
3657
3665
|
sheetStack.promote(this.id);
|
|
3658
3666
|
}
|
|
3659
3667
|
const settleCap = this.snaps.getMaxAxisSize();
|
|
@@ -3735,7 +3743,8 @@ var BottomSheetCore = class {
|
|
|
3735
3743
|
return Math.min(Math.max((size - min) / (reachableMax - min), 0), 1);
|
|
3736
3744
|
}
|
|
3737
3745
|
handleOpen() {
|
|
3738
|
-
|
|
3746
|
+
if (this.promotedForOpen) this.promotedForOpen = false;
|
|
3747
|
+
else sheetStack.promote(this.id);
|
|
3739
3748
|
try {
|
|
3740
3749
|
this.lifecycle.install();
|
|
3741
3750
|
} catch (err) {
|
|
@@ -3767,6 +3776,7 @@ var BottomSheetCore = class {
|
|
|
3767
3776
|
}
|
|
3768
3777
|
handleClose() {
|
|
3769
3778
|
this.opening = false;
|
|
3779
|
+
this.promotedForOpen = false;
|
|
3770
3780
|
this.lifecycle.release();
|
|
3771
3781
|
sheetStack.update();
|
|
3772
3782
|
}
|
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 { E as EngineState, b as SheetMode, d as SnapPoint, a as SnapPointDef } from './BottomSheetCore-
|
|
2
|
+
export { E as EngineState, b as SheetMode, d as SnapPoint, a as SnapPointDef } from './BottomSheetCore-BHv6LPmS.cjs';
|
|
3
3
|
export { OverlayEdge, OverlayOptions, OverlayState } from './overlay.cjs';
|
|
4
4
|
import 'react';
|
|
5
|
-
import './BottomSheetEngine-
|
|
5
|
+
import './BottomSheetEngine-mmFzIK1Z.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 { E as EngineState, b as SheetMode, d as SnapPoint, a as SnapPointDef } from './BottomSheetCore-
|
|
2
|
+
export { E as EngineState, b as SheetMode, d as SnapPoint, a as SnapPointDef } from './BottomSheetCore-CK_mq14p.js';
|
|
3
3
|
export { OverlayEdge, OverlayOptions, OverlayState } from './overlay.js';
|
|
4
4
|
import 'react';
|
|
5
|
-
import './BottomSheetEngine-
|
|
5
|
+
import './BottomSheetEngine-wLn6Q2kA.js';
|
|
6
6
|
import './teleport-7uYNiEAT.js';
|
|
7
7
|
import './transform-jVfAikE9.js';
|