@surdeddd/bottom-sheet 0.23.1 → 0.23.3
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 +3 -3
- package/dist/{BottomSheetCore-9i-Uh6T3.d.ts → BottomSheetCore-COvILxmR.d.ts} +2 -0
- package/dist/{BottomSheetCore-CQStdVy2.d.cts → BottomSheetCore-CaJwHnxY.d.cts} +2 -0
- package/dist/{BottomSheetEngine-CsQWHLNb.d.cts → BottomSheetEngine-C_1aPJsU.d.cts} +1 -1
- package/dist/{BottomSheetEngine-Dn6h-7gF.d.ts → BottomSheetEngine-CsgCcCSO.d.ts} +1 -1
- package/dist/core.cjs +43 -13
- package/dist/core.d.cts +2 -2
- package/dist/core.d.ts +2 -2
- package/dist/core.js +43 -13
- package/dist/debug.d.cts +1 -1
- package/dist/debug.d.ts +1 -1
- package/dist/{default-features-C3cilcW9.d.ts → default-features-BJx7J0NH.d.ts} +1 -1
- package/dist/{default-features-DkG9aho0.d.cts → default-features-CTJb8Wdk.d.cts} +1 -1
- package/dist/element.cjs +103 -20
- 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 +103 -20
- package/dist/features.cjs +58 -3
- package/dist/features.d.cts +3 -3
- package/dist/features.d.ts +3 -3
- package/dist/features.js +58 -3
- package/dist/{index-CVGC5B5D.d.cts → index-BBrJJjy5.d.cts} +1 -1
- package/dist/{index-CnsJQZp2.d.ts → index-CXN7t3rr.d.ts} +1 -1
- package/dist/index.cjs +98 -16
- package/dist/index.d.cts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.js +98 -16
- 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 +89 -16
- package/dist/qwik-lib/index.qwik.mjs +89 -16
- package/dist/qwik.cjs +98 -16
- package/dist/qwik.d.cts +2 -2
- package/dist/qwik.d.ts +2 -2
- package/dist/qwik.js +98 -16
- package/dist/react.cjs +98 -16
- package/dist/react.d.cts +3 -3
- package/dist/react.d.ts +3 -3
- package/dist/react.js +98 -16
- package/dist/solid.cjs +98 -16
- package/dist/solid.d.cts +2 -0
- package/dist/solid.d.ts +2 -0
- package/dist/solid.js +98 -16
- package/dist/solid.source.jsx +98 -16
- package/dist/styles.css +8 -6
- package/dist/svelte-core.cjs +98 -16
- package/dist/svelte-core.js +98 -16
- package/dist/svelte.cjs +98 -16
- package/dist/svelte.js +98 -16
- package/dist/vue.cjs +98 -16
- package/dist/vue.js +98 -16
- package/dist/webgl.cjs +192 -42
- package/dist/webgl.d.cts +1 -1
- package/dist/webgl.d.ts +1 -1
- package/dist/webgl.js +192 -42
- package/package.json +12 -12
package/dist/react.cjs
CHANGED
|
@@ -90,6 +90,7 @@ function buildTransformTemplate(axis) {
|
|
|
90
90
|
return (offset) => `translate3d(${offset}px, 0, 0)`;
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
|
+
var offsetFromMatrix = (axis, m) => axis === "bottom" ? m.m42 : axis === "top" ? -m.m42 : axis === "left" ? -m.m41 : m.m41;
|
|
93
94
|
var CLOSED_TRANSFORM = {
|
|
94
95
|
bottom: "translate3d(0, 100%, 0)",
|
|
95
96
|
top: "translate3d(0, -100%, 0)",
|
|
@@ -1181,7 +1182,7 @@ var tween = ({
|
|
|
1181
1182
|
}
|
|
1182
1183
|
const step = (now) => {
|
|
1183
1184
|
if (cancelled) return;
|
|
1184
|
-
const elapsed = now - start;
|
|
1185
|
+
const elapsed = Math.max(0, now - start);
|
|
1185
1186
|
const t = Math.min(elapsed / duration, 1);
|
|
1186
1187
|
const value = from + (to - from) * easing(t);
|
|
1187
1188
|
onUpdate(value);
|
|
@@ -1234,8 +1235,8 @@ var runSpring = ({
|
|
|
1234
1235
|
resolveFn = resolve;
|
|
1235
1236
|
const step = (now) => {
|
|
1236
1237
|
if (cancelled) return;
|
|
1237
|
-
const dt = Math.min((now - lastTime) / 1e3, MAX_DT);
|
|
1238
|
-
lastTime = now;
|
|
1238
|
+
const dt = Math.min(Math.max(0, now - lastTime) / 1e3, MAX_DT);
|
|
1239
|
+
lastTime = Math.max(lastTime, now);
|
|
1239
1240
|
const steps = Math.max(1, Math.ceil(dt * 240));
|
|
1240
1241
|
const subDt = dt / steps;
|
|
1241
1242
|
let stepsLeft = steps;
|
|
@@ -1299,6 +1300,7 @@ function resolveAnimationPreset(animation) {
|
|
|
1299
1300
|
}
|
|
1300
1301
|
|
|
1301
1302
|
// src/core/animation/waapi-settle.ts
|
|
1303
|
+
var SETTLE_ANIMATION_ID = "bs-settle";
|
|
1302
1304
|
var SIM_HZ = 240;
|
|
1303
1305
|
var SAMPLE_STRIDE = 4;
|
|
1304
1306
|
var MAX_SIM_MS = 3e3;
|
|
@@ -1356,6 +1358,7 @@ var AnimationRunner = class {
|
|
|
1356
1358
|
__publicField(this, "isDragging");
|
|
1357
1359
|
__publicField(this, "applyAux");
|
|
1358
1360
|
__publicField(this, "getTransformFor");
|
|
1361
|
+
__publicField(this, "readShownSize");
|
|
1359
1362
|
__publicField(this, "settleWaapi");
|
|
1360
1363
|
__publicField(this, "currentWaapi", null);
|
|
1361
1364
|
__publicField(this, "animationKind");
|
|
@@ -1375,6 +1378,7 @@ var AnimationRunner = class {
|
|
|
1375
1378
|
this.isDragging = deps.isDragging;
|
|
1376
1379
|
this.applyAux = deps.applyAux;
|
|
1377
1380
|
this.getTransformFor = deps.getTransformFor;
|
|
1381
|
+
this.readShownSize = deps.readShownSize;
|
|
1378
1382
|
this.settleWaapi = opts.settleAnimation === "waapi";
|
|
1379
1383
|
const preset = resolveAnimationPreset(opts.animation);
|
|
1380
1384
|
this.animationKind = preset.kind;
|
|
@@ -1407,10 +1411,12 @@ var AnimationRunner = class {
|
|
|
1407
1411
|
const entry = this.currentWaapi;
|
|
1408
1412
|
this.currentWaapi = null;
|
|
1409
1413
|
entry.stop();
|
|
1414
|
+
const size = this.readShownSize?.() ?? entry.sizeNow();
|
|
1410
1415
|
try {
|
|
1411
1416
|
entry.anim.cancel();
|
|
1412
1417
|
} catch {
|
|
1413
1418
|
}
|
|
1419
|
+
this.applySizeFn(size);
|
|
1414
1420
|
}
|
|
1415
1421
|
cancel() {
|
|
1416
1422
|
this.currentTween?.cancel();
|
|
@@ -1420,6 +1426,7 @@ var AnimationRunner = class {
|
|
|
1420
1426
|
async animateTo(target, velocityPxPerMs) {
|
|
1421
1427
|
if (target === this.getSize()) {
|
|
1422
1428
|
if (!this.isAnimating && !this.isDragging()) {
|
|
1429
|
+
this.applySizeFn(target);
|
|
1423
1430
|
this.element.style.willChange = "";
|
|
1424
1431
|
}
|
|
1425
1432
|
return;
|
|
@@ -1456,6 +1463,7 @@ var AnimationRunner = class {
|
|
|
1456
1463
|
return;
|
|
1457
1464
|
}
|
|
1458
1465
|
}
|
|
1466
|
+
let current = false;
|
|
1459
1467
|
if (this.animationKind === "spring") {
|
|
1460
1468
|
const spring = runSpring({
|
|
1461
1469
|
from: this.getSize(),
|
|
@@ -1466,7 +1474,8 @@ var AnimationRunner = class {
|
|
|
1466
1474
|
});
|
|
1467
1475
|
this.currentSpring = spring;
|
|
1468
1476
|
await spring.promise;
|
|
1469
|
-
|
|
1477
|
+
current = this.currentSpring === spring;
|
|
1478
|
+
if (current) this.currentSpring = null;
|
|
1470
1479
|
} else {
|
|
1471
1480
|
const tw = tween({
|
|
1472
1481
|
from: this.getSize(),
|
|
@@ -1477,11 +1486,15 @@ var AnimationRunner = class {
|
|
|
1477
1486
|
});
|
|
1478
1487
|
this.currentTween = tw;
|
|
1479
1488
|
await tw.promise;
|
|
1480
|
-
|
|
1489
|
+
current = this.currentTween === tw;
|
|
1490
|
+
if (current) this.currentTween = null;
|
|
1481
1491
|
}
|
|
1482
1492
|
if (!this.isAnimating) {
|
|
1483
1493
|
this.getRootEl()?.removeAttribute("data-animating");
|
|
1484
|
-
if (!this.isDragging())
|
|
1494
|
+
if (!this.isDragging()) {
|
|
1495
|
+
if (current) this.applySizeFn(this.getSize());
|
|
1496
|
+
this.element.style.willChange = "";
|
|
1497
|
+
}
|
|
1485
1498
|
}
|
|
1486
1499
|
}
|
|
1487
1500
|
async runWaapiSettle(samples, target) {
|
|
@@ -1495,11 +1508,11 @@ var AnimationRunner = class {
|
|
|
1495
1508
|
easing: "linear",
|
|
1496
1509
|
fill: "forwards"
|
|
1497
1510
|
});
|
|
1511
|
+
anim.id = SETTLE_ANIMATION_ID;
|
|
1498
1512
|
let stopped = false;
|
|
1499
1513
|
let auxRaf = 0;
|
|
1500
1514
|
const lastIdx = samples.values.length - 1;
|
|
1501
|
-
const
|
|
1502
|
-
if (stopped) return;
|
|
1515
|
+
const sizeNow = () => {
|
|
1503
1516
|
const at = Math.min(
|
|
1504
1517
|
(Number(anim.currentTime) || 0) / samples.stepMs,
|
|
1505
1518
|
lastIdx
|
|
@@ -1507,7 +1520,11 @@ var AnimationRunner = class {
|
|
|
1507
1520
|
const idx = Math.floor(at);
|
|
1508
1521
|
const from = samples.values[idx];
|
|
1509
1522
|
const to = samples.values[Math.min(idx + 1, lastIdx)];
|
|
1510
|
-
|
|
1523
|
+
return from + (to - from) * (at - idx);
|
|
1524
|
+
};
|
|
1525
|
+
const auxTick = () => {
|
|
1526
|
+
if (stopped) return;
|
|
1527
|
+
applyAux(sizeNow());
|
|
1511
1528
|
auxRaf = requestAnimationFrame(auxTick);
|
|
1512
1529
|
};
|
|
1513
1530
|
auxRaf = requestAnimationFrame(auxTick);
|
|
@@ -1516,7 +1533,8 @@ var AnimationRunner = class {
|
|
|
1516
1533
|
stop: () => {
|
|
1517
1534
|
stopped = true;
|
|
1518
1535
|
cancelAnimationFrame(auxRaf);
|
|
1519
|
-
}
|
|
1536
|
+
},
|
|
1537
|
+
sizeNow
|
|
1520
1538
|
};
|
|
1521
1539
|
this.currentWaapi = entry;
|
|
1522
1540
|
try {
|
|
@@ -2619,6 +2637,7 @@ var BottomSheetCore = class {
|
|
|
2619
2637
|
__publicField(this, "closeOnBack");
|
|
2620
2638
|
__publicField(this, "routedTo");
|
|
2621
2639
|
__publicField(this, "fitContentToSnap");
|
|
2640
|
+
__publicField(this, "settleAnimation");
|
|
2622
2641
|
__publicField(this, "persistent");
|
|
2623
2642
|
__publicField(this, "disableCloseFlag");
|
|
2624
2643
|
__publicField(this, "disableDragFlag");
|
|
@@ -2723,6 +2742,11 @@ var BottomSheetCore = class {
|
|
|
2723
2742
|
const cap = this.snaps.getMaxAxisSize();
|
|
2724
2743
|
const shown = cap > 0 && !this.allowOvershoot ? Math.min(size, cap) : size;
|
|
2725
2744
|
return this.transformTemplate(cap - shown);
|
|
2745
|
+
},
|
|
2746
|
+
readShownSize: () => {
|
|
2747
|
+
const shown = getComputedStyle(this.element).transform;
|
|
2748
|
+
if (!shown || shown === "none") return void 0;
|
|
2749
|
+
return this.snaps.getMaxAxisSize() - offsetFromMatrix(this.mode, new DOMMatrix(shown));
|
|
2726
2750
|
}
|
|
2727
2751
|
},
|
|
2728
2752
|
resolved.animation
|
|
@@ -2737,6 +2761,7 @@ var BottomSheetCore = class {
|
|
|
2737
2761
|
this.closeOnBack = resolved.closeOnBack;
|
|
2738
2762
|
this.routedTo = opts.routedTo;
|
|
2739
2763
|
this.fitContentToSnap = opts.fitContentToSnap === true;
|
|
2764
|
+
this.settleAnimation = opts.settleAnimation;
|
|
2740
2765
|
this.persistent = resolved.persistent;
|
|
2741
2766
|
this.disableCloseFlag = resolved.disableClose;
|
|
2742
2767
|
this.disableDragFlag = resolved.disableDrag;
|
|
@@ -2839,7 +2864,8 @@ var BottomSheetCore = class {
|
|
|
2839
2864
|
closeOnRouteChange: this.closeOnRouteChange,
|
|
2840
2865
|
persistKey: this.persistKey,
|
|
2841
2866
|
autoCollapseAfter,
|
|
2842
|
-
fitContentToSnap: this.fitContentToSnap
|
|
2867
|
+
fitContentToSnap: this.fitContentToSnap,
|
|
2868
|
+
settleAnimation: this.settleAnimation
|
|
2843
2869
|
},
|
|
2844
2870
|
isDestroyed: () => this.destroyed,
|
|
2845
2871
|
isDragging: () => this.isDraggingAny(),
|
|
@@ -3731,7 +3757,11 @@ var BottomSheetCore = class {
|
|
|
3731
3757
|
const offset = cap - clamped;
|
|
3732
3758
|
const style = this.element.style;
|
|
3733
3759
|
if (!skipTransform) style.transform = this.transformTemplate(offset);
|
|
3734
|
-
|
|
3760
|
+
const sizeChanged = this.sizeWriteSentinel.shouldWrite(
|
|
3761
|
+
clamped,
|
|
3762
|
+
this.animation.isAnimating || this.isDraggingAny() ? SIZE_WRITE_EPSILON : 0
|
|
3763
|
+
);
|
|
3764
|
+
if (sizeChanged) {
|
|
3735
3765
|
style.setProperty("--bs-size", `${clamped}px`);
|
|
3736
3766
|
if (this.scrimParent) {
|
|
3737
3767
|
this.scrimParent.style.setProperty("--bs-size", `${clamped}px`);
|
|
@@ -3758,7 +3788,7 @@ var BottomSheetCore = class {
|
|
|
3758
3788
|
}
|
|
3759
3789
|
}
|
|
3760
3790
|
this.scrim.applyOpacity(progress, progressChanged);
|
|
3761
|
-
if (progressChanged && this.bus.listenerCount("progress") > 0) {
|
|
3791
|
+
if ((progressChanged || sizeChanged) && this.bus.listenerCount("progress") > 0) {
|
|
3762
3792
|
this.progressPayload.value = progress;
|
|
3763
3793
|
this.progressPayload.size = clamped;
|
|
3764
3794
|
this.emit("progress", this.progressPayload);
|
|
@@ -4255,7 +4285,6 @@ function visualViewportFeature() {
|
|
|
4255
4285
|
|
|
4256
4286
|
// src/core/features/content-fit.ts
|
|
4257
4287
|
var INSET_VAR = "--bs-content-inset";
|
|
4258
|
-
var SIZE_VAR = "--bs-size";
|
|
4259
4288
|
var CAP_VAR = "--bs-max-size";
|
|
4260
4289
|
var LIFT_VAR = "--bs-footer-lift-max";
|
|
4261
4290
|
var FIT_ATTR = "data-bs-fit-content";
|
|
@@ -4268,10 +4297,14 @@ function contentFitFeature() {
|
|
|
4268
4297
|
return;
|
|
4269
4298
|
}
|
|
4270
4299
|
const sheet = ctx.element;
|
|
4300
|
+
const waapi = ctx.options.settleAnimation === "waapi";
|
|
4271
4301
|
let inset = 0;
|
|
4272
4302
|
let unpaddedMax = -1;
|
|
4273
4303
|
let top = 0;
|
|
4274
4304
|
let resting = false;
|
|
4305
|
+
let liftMax = 0;
|
|
4306
|
+
let followed = null;
|
|
4307
|
+
let follower = null;
|
|
4275
4308
|
const put = (name, px) => sheet.style.setProperty(name, `${px}px`);
|
|
4276
4309
|
const hiddenAt = (size) => sheet.dataset.mode === "bottom" ? Math.max(0, ctx.getMaxAxisSize() - size) : 0;
|
|
4277
4310
|
const follow = (size) => {
|
|
@@ -4285,8 +4318,45 @@ function contentFitFeature() {
|
|
|
4285
4318
|
top = limit;
|
|
4286
4319
|
}
|
|
4287
4320
|
};
|
|
4321
|
+
const unfollow = () => {
|
|
4322
|
+
follower?.cancel();
|
|
4323
|
+
follower = null;
|
|
4324
|
+
followed = null;
|
|
4325
|
+
};
|
|
4326
|
+
const followSettle = () => {
|
|
4327
|
+
if (followed?.playState === "running") return;
|
|
4328
|
+
const settleAnim = sheet.getAnimations?.().find((a) => a.id === SETTLE_ANIMATION_ID);
|
|
4329
|
+
const footer = sheet.querySelector(".bs-footer");
|
|
4330
|
+
if (!settleAnim || !footer) return;
|
|
4331
|
+
const effect = settleAnim.effect;
|
|
4332
|
+
unfollow();
|
|
4333
|
+
const own = footer.animate(
|
|
4334
|
+
effect.getKeyframes().map((k) => ({
|
|
4335
|
+
offset: k.computedOffset,
|
|
4336
|
+
transform: `translateY(${-Math.min(
|
|
4337
|
+
Math.max(0, parseFloat(String(k.transform).split(",")[1]) || 0),
|
|
4338
|
+
liftMax
|
|
4339
|
+
)}px)`
|
|
4340
|
+
})),
|
|
4341
|
+
{
|
|
4342
|
+
duration: effect.getTiming().duration,
|
|
4343
|
+
easing: "linear",
|
|
4344
|
+
fill: "forwards"
|
|
4345
|
+
}
|
|
4346
|
+
);
|
|
4347
|
+
follower = own;
|
|
4348
|
+
followed = settleAnim;
|
|
4349
|
+
const done = () => {
|
|
4350
|
+
if (followed === settleAnim) unfollow();
|
|
4351
|
+
};
|
|
4352
|
+
settleAnim.ready.then(() => {
|
|
4353
|
+
if (follower === own) own.startTime = settleAnim.startTime;
|
|
4354
|
+
}, done);
|
|
4355
|
+
settleAnim.finished.then(done, done);
|
|
4356
|
+
};
|
|
4288
4357
|
const settle = () => {
|
|
4289
4358
|
if (ctx.isDestroyed()) return;
|
|
4359
|
+
unfollow();
|
|
4290
4360
|
const size = ctx.getSize();
|
|
4291
4361
|
if (!resting) {
|
|
4292
4362
|
unpaddedMax = -1;
|
|
@@ -4294,7 +4364,6 @@ function contentFitFeature() {
|
|
|
4294
4364
|
}
|
|
4295
4365
|
inset = hiddenAt(size);
|
|
4296
4366
|
put(INSET_VAR, inset);
|
|
4297
|
-
put(SIZE_VAR, size);
|
|
4298
4367
|
put(CAP_VAR, ctx.getMaxAxisSize());
|
|
4299
4368
|
if (!resting) {
|
|
4300
4369
|
resting = true;
|
|
@@ -4306,9 +4375,13 @@ function contentFitFeature() {
|
|
|
4306
4375
|
if (resting) {
|
|
4307
4376
|
resting = false;
|
|
4308
4377
|
sheet.setAttribute(FIT_ATTR, "moving");
|
|
4309
|
-
|
|
4378
|
+
liftMax = scroller.offsetHeight;
|
|
4379
|
+
put(LIFT_VAR, liftMax);
|
|
4310
4380
|
}
|
|
4311
4381
|
follow(size);
|
|
4382
|
+
if (waapi && ctx.isAnimating() && sheet.dataset.mode === "bottom") {
|
|
4383
|
+
followSettle();
|
|
4384
|
+
}
|
|
4312
4385
|
};
|
|
4313
4386
|
const moving = () => ctx.isAnimating() || ctx.isDragging();
|
|
4314
4387
|
const whenIdle = () => {
|
|
@@ -4320,12 +4393,21 @@ function contentFitFeature() {
|
|
|
4320
4393
|
(p) => moving() ? move(p.size) : settle()
|
|
4321
4394
|
);
|
|
4322
4395
|
const offSnap = ctx.on("snap", settle);
|
|
4396
|
+
const offDragStart = ctx.on("dragstart", () => move(ctx.getSize()));
|
|
4397
|
+
const offBeforeSnap = ctx.on("before-snap", () => {
|
|
4398
|
+
queueMicrotask(() => {
|
|
4399
|
+
if (!ctx.isDestroyed() && ctx.isAnimating()) move(ctx.getSize());
|
|
4400
|
+
});
|
|
4401
|
+
});
|
|
4323
4402
|
const observer = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(whenIdle);
|
|
4324
4403
|
observer?.observe(document.documentElement);
|
|
4325
4404
|
window.addEventListener("orientationchange", whenIdle);
|
|
4326
4405
|
return () => {
|
|
4406
|
+
unfollow();
|
|
4327
4407
|
offProgress();
|
|
4328
4408
|
offSnap();
|
|
4409
|
+
offDragStart();
|
|
4410
|
+
offBeforeSnap();
|
|
4329
4411
|
observer?.disconnect();
|
|
4330
4412
|
window.removeEventListener("orientationchange", whenIdle);
|
|
4331
4413
|
sheet.removeAttribute(FIT_ATTR);
|
package/dist/react.d.cts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { g as EngineOptions, d as EngineState, A as AnchorOptions, i as ScrimStagesOptions, u as ScrimStageDef, S as SheetEventMap, C as CloseReason, v as ScrimUpdate, r as ScrimOverlayOptions, e as SnapPointDef, f as SheetMode } from './BottomSheetCore-
|
|
2
|
-
export { h as SnapPoint } from './BottomSheetCore-
|
|
1
|
+
import { g as EngineOptions, d as EngineState, A as AnchorOptions, i as ScrimStagesOptions, u as ScrimStageDef, S as SheetEventMap, C as CloseReason, v as ScrimUpdate, r as ScrimOverlayOptions, e as SnapPointDef, f as SheetMode } from './BottomSheetCore-CaJwHnxY.cjs';
|
|
2
|
+
export { h as SnapPoint } from './BottomSheetCore-CaJwHnxY.cjs';
|
|
3
3
|
import { OverlayOptions, OverlayState, Overlay as OverlayEngine } from './overlay.cjs';
|
|
4
4
|
export { OverlayEdge } from './overlay.cjs';
|
|
5
5
|
import * as react from 'react';
|
|
6
6
|
import { CSSProperties, ReactNode } from 'react';
|
|
7
|
-
import { B as BottomSheetEngine } from './BottomSheetEngine-
|
|
7
|
+
import { B as BottomSheetEngine } from './BottomSheetEngine-C_1aPJsU.cjs';
|
|
8
8
|
import { T as TeleportTarget } from './teleport-7uYNiEAT.cjs';
|
|
9
9
|
import './transform-jVfAikE9.cjs';
|
|
10
10
|
|
package/dist/react.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { g as EngineOptions, d as EngineState, A as AnchorOptions, i as ScrimStagesOptions, u as ScrimStageDef, S as SheetEventMap, C as CloseReason, v as ScrimUpdate, r as ScrimOverlayOptions, e as SnapPointDef, f as SheetMode } from './BottomSheetCore-
|
|
2
|
-
export { h as SnapPoint } from './BottomSheetCore-
|
|
1
|
+
import { g as EngineOptions, d as EngineState, A as AnchorOptions, i as ScrimStagesOptions, u as ScrimStageDef, S as SheetEventMap, C as CloseReason, v as ScrimUpdate, r as ScrimOverlayOptions, e as SnapPointDef, f as SheetMode } from './BottomSheetCore-COvILxmR.js';
|
|
2
|
+
export { h as SnapPoint } from './BottomSheetCore-COvILxmR.js';
|
|
3
3
|
import { OverlayOptions, OverlayState, Overlay as OverlayEngine } from './overlay.js';
|
|
4
4
|
export { OverlayEdge } from './overlay.js';
|
|
5
5
|
import * as react from 'react';
|
|
6
6
|
import { CSSProperties, ReactNode } from 'react';
|
|
7
|
-
import { B as BottomSheetEngine } from './BottomSheetEngine-
|
|
7
|
+
import { B as BottomSheetEngine } from './BottomSheetEngine-CsgCcCSO.js';
|
|
8
8
|
import { T as TeleportTarget } from './teleport-7uYNiEAT.js';
|
|
9
9
|
import './transform-jVfAikE9.js';
|
|
10
10
|
|
package/dist/react.js
CHANGED
|
@@ -88,6 +88,7 @@ function buildTransformTemplate(axis) {
|
|
|
88
88
|
return (offset) => `translate3d(${offset}px, 0, 0)`;
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
|
+
var offsetFromMatrix = (axis, m) => axis === "bottom" ? m.m42 : axis === "top" ? -m.m42 : axis === "left" ? -m.m41 : m.m41;
|
|
91
92
|
var CLOSED_TRANSFORM = {
|
|
92
93
|
bottom: "translate3d(0, 100%, 0)",
|
|
93
94
|
top: "translate3d(0, -100%, 0)",
|
|
@@ -1179,7 +1180,7 @@ var tween = ({
|
|
|
1179
1180
|
}
|
|
1180
1181
|
const step = (now) => {
|
|
1181
1182
|
if (cancelled) return;
|
|
1182
|
-
const elapsed = now - start;
|
|
1183
|
+
const elapsed = Math.max(0, now - start);
|
|
1183
1184
|
const t = Math.min(elapsed / duration, 1);
|
|
1184
1185
|
const value = from + (to - from) * easing(t);
|
|
1185
1186
|
onUpdate(value);
|
|
@@ -1232,8 +1233,8 @@ var runSpring = ({
|
|
|
1232
1233
|
resolveFn = resolve;
|
|
1233
1234
|
const step = (now) => {
|
|
1234
1235
|
if (cancelled) return;
|
|
1235
|
-
const dt = Math.min((now - lastTime) / 1e3, MAX_DT);
|
|
1236
|
-
lastTime = now;
|
|
1236
|
+
const dt = Math.min(Math.max(0, now - lastTime) / 1e3, MAX_DT);
|
|
1237
|
+
lastTime = Math.max(lastTime, now);
|
|
1237
1238
|
const steps = Math.max(1, Math.ceil(dt * 240));
|
|
1238
1239
|
const subDt = dt / steps;
|
|
1239
1240
|
let stepsLeft = steps;
|
|
@@ -1297,6 +1298,7 @@ function resolveAnimationPreset(animation) {
|
|
|
1297
1298
|
}
|
|
1298
1299
|
|
|
1299
1300
|
// src/core/animation/waapi-settle.ts
|
|
1301
|
+
var SETTLE_ANIMATION_ID = "bs-settle";
|
|
1300
1302
|
var SIM_HZ = 240;
|
|
1301
1303
|
var SAMPLE_STRIDE = 4;
|
|
1302
1304
|
var MAX_SIM_MS = 3e3;
|
|
@@ -1354,6 +1356,7 @@ var AnimationRunner = class {
|
|
|
1354
1356
|
__publicField(this, "isDragging");
|
|
1355
1357
|
__publicField(this, "applyAux");
|
|
1356
1358
|
__publicField(this, "getTransformFor");
|
|
1359
|
+
__publicField(this, "readShownSize");
|
|
1357
1360
|
__publicField(this, "settleWaapi");
|
|
1358
1361
|
__publicField(this, "currentWaapi", null);
|
|
1359
1362
|
__publicField(this, "animationKind");
|
|
@@ -1373,6 +1376,7 @@ var AnimationRunner = class {
|
|
|
1373
1376
|
this.isDragging = deps.isDragging;
|
|
1374
1377
|
this.applyAux = deps.applyAux;
|
|
1375
1378
|
this.getTransformFor = deps.getTransformFor;
|
|
1379
|
+
this.readShownSize = deps.readShownSize;
|
|
1376
1380
|
this.settleWaapi = opts.settleAnimation === "waapi";
|
|
1377
1381
|
const preset = resolveAnimationPreset(opts.animation);
|
|
1378
1382
|
this.animationKind = preset.kind;
|
|
@@ -1405,10 +1409,12 @@ var AnimationRunner = class {
|
|
|
1405
1409
|
const entry = this.currentWaapi;
|
|
1406
1410
|
this.currentWaapi = null;
|
|
1407
1411
|
entry.stop();
|
|
1412
|
+
const size = this.readShownSize?.() ?? entry.sizeNow();
|
|
1408
1413
|
try {
|
|
1409
1414
|
entry.anim.cancel();
|
|
1410
1415
|
} catch {
|
|
1411
1416
|
}
|
|
1417
|
+
this.applySizeFn(size);
|
|
1412
1418
|
}
|
|
1413
1419
|
cancel() {
|
|
1414
1420
|
this.currentTween?.cancel();
|
|
@@ -1418,6 +1424,7 @@ var AnimationRunner = class {
|
|
|
1418
1424
|
async animateTo(target, velocityPxPerMs) {
|
|
1419
1425
|
if (target === this.getSize()) {
|
|
1420
1426
|
if (!this.isAnimating && !this.isDragging()) {
|
|
1427
|
+
this.applySizeFn(target);
|
|
1421
1428
|
this.element.style.willChange = "";
|
|
1422
1429
|
}
|
|
1423
1430
|
return;
|
|
@@ -1454,6 +1461,7 @@ var AnimationRunner = class {
|
|
|
1454
1461
|
return;
|
|
1455
1462
|
}
|
|
1456
1463
|
}
|
|
1464
|
+
let current = false;
|
|
1457
1465
|
if (this.animationKind === "spring") {
|
|
1458
1466
|
const spring = runSpring({
|
|
1459
1467
|
from: this.getSize(),
|
|
@@ -1464,7 +1472,8 @@ var AnimationRunner = class {
|
|
|
1464
1472
|
});
|
|
1465
1473
|
this.currentSpring = spring;
|
|
1466
1474
|
await spring.promise;
|
|
1467
|
-
|
|
1475
|
+
current = this.currentSpring === spring;
|
|
1476
|
+
if (current) this.currentSpring = null;
|
|
1468
1477
|
} else {
|
|
1469
1478
|
const tw = tween({
|
|
1470
1479
|
from: this.getSize(),
|
|
@@ -1475,11 +1484,15 @@ var AnimationRunner = class {
|
|
|
1475
1484
|
});
|
|
1476
1485
|
this.currentTween = tw;
|
|
1477
1486
|
await tw.promise;
|
|
1478
|
-
|
|
1487
|
+
current = this.currentTween === tw;
|
|
1488
|
+
if (current) this.currentTween = null;
|
|
1479
1489
|
}
|
|
1480
1490
|
if (!this.isAnimating) {
|
|
1481
1491
|
this.getRootEl()?.removeAttribute("data-animating");
|
|
1482
|
-
if (!this.isDragging())
|
|
1492
|
+
if (!this.isDragging()) {
|
|
1493
|
+
if (current) this.applySizeFn(this.getSize());
|
|
1494
|
+
this.element.style.willChange = "";
|
|
1495
|
+
}
|
|
1483
1496
|
}
|
|
1484
1497
|
}
|
|
1485
1498
|
async runWaapiSettle(samples, target) {
|
|
@@ -1493,11 +1506,11 @@ var AnimationRunner = class {
|
|
|
1493
1506
|
easing: "linear",
|
|
1494
1507
|
fill: "forwards"
|
|
1495
1508
|
});
|
|
1509
|
+
anim.id = SETTLE_ANIMATION_ID;
|
|
1496
1510
|
let stopped = false;
|
|
1497
1511
|
let auxRaf = 0;
|
|
1498
1512
|
const lastIdx = samples.values.length - 1;
|
|
1499
|
-
const
|
|
1500
|
-
if (stopped) return;
|
|
1513
|
+
const sizeNow = () => {
|
|
1501
1514
|
const at = Math.min(
|
|
1502
1515
|
(Number(anim.currentTime) || 0) / samples.stepMs,
|
|
1503
1516
|
lastIdx
|
|
@@ -1505,7 +1518,11 @@ var AnimationRunner = class {
|
|
|
1505
1518
|
const idx = Math.floor(at);
|
|
1506
1519
|
const from = samples.values[idx];
|
|
1507
1520
|
const to = samples.values[Math.min(idx + 1, lastIdx)];
|
|
1508
|
-
|
|
1521
|
+
return from + (to - from) * (at - idx);
|
|
1522
|
+
};
|
|
1523
|
+
const auxTick = () => {
|
|
1524
|
+
if (stopped) return;
|
|
1525
|
+
applyAux(sizeNow());
|
|
1509
1526
|
auxRaf = requestAnimationFrame(auxTick);
|
|
1510
1527
|
};
|
|
1511
1528
|
auxRaf = requestAnimationFrame(auxTick);
|
|
@@ -1514,7 +1531,8 @@ var AnimationRunner = class {
|
|
|
1514
1531
|
stop: () => {
|
|
1515
1532
|
stopped = true;
|
|
1516
1533
|
cancelAnimationFrame(auxRaf);
|
|
1517
|
-
}
|
|
1534
|
+
},
|
|
1535
|
+
sizeNow
|
|
1518
1536
|
};
|
|
1519
1537
|
this.currentWaapi = entry;
|
|
1520
1538
|
try {
|
|
@@ -2617,6 +2635,7 @@ var BottomSheetCore = class {
|
|
|
2617
2635
|
__publicField(this, "closeOnBack");
|
|
2618
2636
|
__publicField(this, "routedTo");
|
|
2619
2637
|
__publicField(this, "fitContentToSnap");
|
|
2638
|
+
__publicField(this, "settleAnimation");
|
|
2620
2639
|
__publicField(this, "persistent");
|
|
2621
2640
|
__publicField(this, "disableCloseFlag");
|
|
2622
2641
|
__publicField(this, "disableDragFlag");
|
|
@@ -2721,6 +2740,11 @@ var BottomSheetCore = class {
|
|
|
2721
2740
|
const cap = this.snaps.getMaxAxisSize();
|
|
2722
2741
|
const shown = cap > 0 && !this.allowOvershoot ? Math.min(size, cap) : size;
|
|
2723
2742
|
return this.transformTemplate(cap - shown);
|
|
2743
|
+
},
|
|
2744
|
+
readShownSize: () => {
|
|
2745
|
+
const shown = getComputedStyle(this.element).transform;
|
|
2746
|
+
if (!shown || shown === "none") return void 0;
|
|
2747
|
+
return this.snaps.getMaxAxisSize() - offsetFromMatrix(this.mode, new DOMMatrix(shown));
|
|
2724
2748
|
}
|
|
2725
2749
|
},
|
|
2726
2750
|
resolved.animation
|
|
@@ -2735,6 +2759,7 @@ var BottomSheetCore = class {
|
|
|
2735
2759
|
this.closeOnBack = resolved.closeOnBack;
|
|
2736
2760
|
this.routedTo = opts.routedTo;
|
|
2737
2761
|
this.fitContentToSnap = opts.fitContentToSnap === true;
|
|
2762
|
+
this.settleAnimation = opts.settleAnimation;
|
|
2738
2763
|
this.persistent = resolved.persistent;
|
|
2739
2764
|
this.disableCloseFlag = resolved.disableClose;
|
|
2740
2765
|
this.disableDragFlag = resolved.disableDrag;
|
|
@@ -2837,7 +2862,8 @@ var BottomSheetCore = class {
|
|
|
2837
2862
|
closeOnRouteChange: this.closeOnRouteChange,
|
|
2838
2863
|
persistKey: this.persistKey,
|
|
2839
2864
|
autoCollapseAfter,
|
|
2840
|
-
fitContentToSnap: this.fitContentToSnap
|
|
2865
|
+
fitContentToSnap: this.fitContentToSnap,
|
|
2866
|
+
settleAnimation: this.settleAnimation
|
|
2841
2867
|
},
|
|
2842
2868
|
isDestroyed: () => this.destroyed,
|
|
2843
2869
|
isDragging: () => this.isDraggingAny(),
|
|
@@ -3729,7 +3755,11 @@ var BottomSheetCore = class {
|
|
|
3729
3755
|
const offset = cap - clamped;
|
|
3730
3756
|
const style = this.element.style;
|
|
3731
3757
|
if (!skipTransform) style.transform = this.transformTemplate(offset);
|
|
3732
|
-
|
|
3758
|
+
const sizeChanged = this.sizeWriteSentinel.shouldWrite(
|
|
3759
|
+
clamped,
|
|
3760
|
+
this.animation.isAnimating || this.isDraggingAny() ? SIZE_WRITE_EPSILON : 0
|
|
3761
|
+
);
|
|
3762
|
+
if (sizeChanged) {
|
|
3733
3763
|
style.setProperty("--bs-size", `${clamped}px`);
|
|
3734
3764
|
if (this.scrimParent) {
|
|
3735
3765
|
this.scrimParent.style.setProperty("--bs-size", `${clamped}px`);
|
|
@@ -3756,7 +3786,7 @@ var BottomSheetCore = class {
|
|
|
3756
3786
|
}
|
|
3757
3787
|
}
|
|
3758
3788
|
this.scrim.applyOpacity(progress, progressChanged);
|
|
3759
|
-
if (progressChanged && this.bus.listenerCount("progress") > 0) {
|
|
3789
|
+
if ((progressChanged || sizeChanged) && this.bus.listenerCount("progress") > 0) {
|
|
3760
3790
|
this.progressPayload.value = progress;
|
|
3761
3791
|
this.progressPayload.size = clamped;
|
|
3762
3792
|
this.emit("progress", this.progressPayload);
|
|
@@ -4253,7 +4283,6 @@ function visualViewportFeature() {
|
|
|
4253
4283
|
|
|
4254
4284
|
// src/core/features/content-fit.ts
|
|
4255
4285
|
var INSET_VAR = "--bs-content-inset";
|
|
4256
|
-
var SIZE_VAR = "--bs-size";
|
|
4257
4286
|
var CAP_VAR = "--bs-max-size";
|
|
4258
4287
|
var LIFT_VAR = "--bs-footer-lift-max";
|
|
4259
4288
|
var FIT_ATTR = "data-bs-fit-content";
|
|
@@ -4266,10 +4295,14 @@ function contentFitFeature() {
|
|
|
4266
4295
|
return;
|
|
4267
4296
|
}
|
|
4268
4297
|
const sheet = ctx.element;
|
|
4298
|
+
const waapi = ctx.options.settleAnimation === "waapi";
|
|
4269
4299
|
let inset = 0;
|
|
4270
4300
|
let unpaddedMax = -1;
|
|
4271
4301
|
let top = 0;
|
|
4272
4302
|
let resting = false;
|
|
4303
|
+
let liftMax = 0;
|
|
4304
|
+
let followed = null;
|
|
4305
|
+
let follower = null;
|
|
4273
4306
|
const put = (name, px) => sheet.style.setProperty(name, `${px}px`);
|
|
4274
4307
|
const hiddenAt = (size) => sheet.dataset.mode === "bottom" ? Math.max(0, ctx.getMaxAxisSize() - size) : 0;
|
|
4275
4308
|
const follow = (size) => {
|
|
@@ -4283,8 +4316,45 @@ function contentFitFeature() {
|
|
|
4283
4316
|
top = limit;
|
|
4284
4317
|
}
|
|
4285
4318
|
};
|
|
4319
|
+
const unfollow = () => {
|
|
4320
|
+
follower?.cancel();
|
|
4321
|
+
follower = null;
|
|
4322
|
+
followed = null;
|
|
4323
|
+
};
|
|
4324
|
+
const followSettle = () => {
|
|
4325
|
+
if (followed?.playState === "running") return;
|
|
4326
|
+
const settleAnim = sheet.getAnimations?.().find((a) => a.id === SETTLE_ANIMATION_ID);
|
|
4327
|
+
const footer = sheet.querySelector(".bs-footer");
|
|
4328
|
+
if (!settleAnim || !footer) return;
|
|
4329
|
+
const effect = settleAnim.effect;
|
|
4330
|
+
unfollow();
|
|
4331
|
+
const own = footer.animate(
|
|
4332
|
+
effect.getKeyframes().map((k) => ({
|
|
4333
|
+
offset: k.computedOffset,
|
|
4334
|
+
transform: `translateY(${-Math.min(
|
|
4335
|
+
Math.max(0, parseFloat(String(k.transform).split(",")[1]) || 0),
|
|
4336
|
+
liftMax
|
|
4337
|
+
)}px)`
|
|
4338
|
+
})),
|
|
4339
|
+
{
|
|
4340
|
+
duration: effect.getTiming().duration,
|
|
4341
|
+
easing: "linear",
|
|
4342
|
+
fill: "forwards"
|
|
4343
|
+
}
|
|
4344
|
+
);
|
|
4345
|
+
follower = own;
|
|
4346
|
+
followed = settleAnim;
|
|
4347
|
+
const done = () => {
|
|
4348
|
+
if (followed === settleAnim) unfollow();
|
|
4349
|
+
};
|
|
4350
|
+
settleAnim.ready.then(() => {
|
|
4351
|
+
if (follower === own) own.startTime = settleAnim.startTime;
|
|
4352
|
+
}, done);
|
|
4353
|
+
settleAnim.finished.then(done, done);
|
|
4354
|
+
};
|
|
4286
4355
|
const settle = () => {
|
|
4287
4356
|
if (ctx.isDestroyed()) return;
|
|
4357
|
+
unfollow();
|
|
4288
4358
|
const size = ctx.getSize();
|
|
4289
4359
|
if (!resting) {
|
|
4290
4360
|
unpaddedMax = -1;
|
|
@@ -4292,7 +4362,6 @@ function contentFitFeature() {
|
|
|
4292
4362
|
}
|
|
4293
4363
|
inset = hiddenAt(size);
|
|
4294
4364
|
put(INSET_VAR, inset);
|
|
4295
|
-
put(SIZE_VAR, size);
|
|
4296
4365
|
put(CAP_VAR, ctx.getMaxAxisSize());
|
|
4297
4366
|
if (!resting) {
|
|
4298
4367
|
resting = true;
|
|
@@ -4304,9 +4373,13 @@ function contentFitFeature() {
|
|
|
4304
4373
|
if (resting) {
|
|
4305
4374
|
resting = false;
|
|
4306
4375
|
sheet.setAttribute(FIT_ATTR, "moving");
|
|
4307
|
-
|
|
4376
|
+
liftMax = scroller.offsetHeight;
|
|
4377
|
+
put(LIFT_VAR, liftMax);
|
|
4308
4378
|
}
|
|
4309
4379
|
follow(size);
|
|
4380
|
+
if (waapi && ctx.isAnimating() && sheet.dataset.mode === "bottom") {
|
|
4381
|
+
followSettle();
|
|
4382
|
+
}
|
|
4310
4383
|
};
|
|
4311
4384
|
const moving = () => ctx.isAnimating() || ctx.isDragging();
|
|
4312
4385
|
const whenIdle = () => {
|
|
@@ -4318,12 +4391,21 @@ function contentFitFeature() {
|
|
|
4318
4391
|
(p) => moving() ? move(p.size) : settle()
|
|
4319
4392
|
);
|
|
4320
4393
|
const offSnap = ctx.on("snap", settle);
|
|
4394
|
+
const offDragStart = ctx.on("dragstart", () => move(ctx.getSize()));
|
|
4395
|
+
const offBeforeSnap = ctx.on("before-snap", () => {
|
|
4396
|
+
queueMicrotask(() => {
|
|
4397
|
+
if (!ctx.isDestroyed() && ctx.isAnimating()) move(ctx.getSize());
|
|
4398
|
+
});
|
|
4399
|
+
});
|
|
4321
4400
|
const observer = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(whenIdle);
|
|
4322
4401
|
observer?.observe(document.documentElement);
|
|
4323
4402
|
window.addEventListener("orientationchange", whenIdle);
|
|
4324
4403
|
return () => {
|
|
4404
|
+
unfollow();
|
|
4325
4405
|
offProgress();
|
|
4326
4406
|
offSnap();
|
|
4407
|
+
offDragStart();
|
|
4408
|
+
offBeforeSnap();
|
|
4327
4409
|
observer?.disconnect();
|
|
4328
4410
|
window.removeEventListener("orientationchange", whenIdle);
|
|
4329
4411
|
sheet.removeAttribute(FIT_ATTR);
|