@plainsheet/react 0.4.9 → 0.4.10
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.
|
@@ -222,31 +222,31 @@ const _t = (t, e, n) => {
|
|
|
222
222
|
function qt(t, e, n, o, r, i, a) {
|
|
223
223
|
if (!o.isDragging || !A(o.startY))
|
|
224
224
|
return;
|
|
225
|
-
const
|
|
226
|
-
if (
|
|
225
|
+
const l = e.getCoordinates(t).y, u = wt(o.startY, l), h = window.innerHeight, c = i.clientHeight, f = c - (o.containerStartTranslate.y + u);
|
|
226
|
+
if (f >= h)
|
|
227
227
|
return;
|
|
228
|
-
const
|
|
229
|
-
if (
|
|
228
|
+
const y = Et(o.startY, l);
|
|
229
|
+
if (y.isUp && !n.expandable && f >= c || n.preventClosing && f <= c)
|
|
230
230
|
return;
|
|
231
231
|
r.start(() => {
|
|
232
232
|
et(i, {
|
|
233
233
|
y: o.containerStartTranslate.y + u
|
|
234
234
|
});
|
|
235
235
|
}, 0);
|
|
236
|
-
const
|
|
237
|
-
if (
|
|
238
|
-
const
|
|
239
|
-
1 - tt(S /
|
|
236
|
+
const s = h - a, C = c - o.containerStartTranslate.y;
|
|
237
|
+
if (y.isUp) {
|
|
238
|
+
const v = s - C, S = s - f, E = gt(
|
|
239
|
+
1 - tt(S / v, 2),
|
|
240
240
|
{
|
|
241
241
|
min: 0,
|
|
242
242
|
max: 1
|
|
243
243
|
}
|
|
244
244
|
);
|
|
245
|
-
n.onDragMove(
|
|
246
|
-
} else if (
|
|
247
|
-
const
|
|
245
|
+
n.onDragMove(y, E);
|
|
246
|
+
} else if (y.isDown) {
|
|
247
|
+
const v = gt(
|
|
248
248
|
tt(
|
|
249
|
-
1 -
|
|
249
|
+
1 - f / C,
|
|
250
250
|
2
|
|
251
251
|
),
|
|
252
252
|
{
|
|
@@ -254,30 +254,30 @@ function qt(t, e, n, o, r, i, a) {
|
|
|
254
254
|
max: 1
|
|
255
255
|
}
|
|
256
256
|
);
|
|
257
|
-
n.onDragMove(
|
|
257
|
+
n.onDragMove(y, v);
|
|
258
258
|
}
|
|
259
259
|
}
|
|
260
|
-
const Vt = (t, e, n, o, r, i, a) => (
|
|
260
|
+
const Vt = (t, e, n, o, r, i, a) => (l) => {
|
|
261
261
|
if (!o.isDragging || (o.isDragging = !1, !A(o.startY)))
|
|
262
262
|
return;
|
|
263
263
|
n.onDragEnd();
|
|
264
|
-
const u = o.startY, h = t.getCoordinates(
|
|
265
|
-
if (
|
|
266
|
-
const
|
|
267
|
-
(
|
|
268
|
-
),
|
|
269
|
-
if (!n.expandable &&
|
|
264
|
+
const u = o.startY, h = t.getCoordinates(l).y, c = D(e).y, f = Et(u, h), y = window.innerHeight, s = e.clientHeight;
|
|
265
|
+
if (f.isUp) {
|
|
266
|
+
const C = [...n.snapPoints].sort(
|
|
267
|
+
(E, x) => E - x
|
|
268
|
+
), v = s + -c;
|
|
269
|
+
if (!n.expandable && v >= s)
|
|
270
270
|
return;
|
|
271
|
-
for (const
|
|
272
|
-
const x =
|
|
273
|
-
if (
|
|
274
|
-
const
|
|
275
|
-
|
|
271
|
+
for (const E of C) {
|
|
272
|
+
const x = E * window.innerHeight;
|
|
273
|
+
if (v <= x) {
|
|
274
|
+
const w = V(
|
|
275
|
+
v,
|
|
276
276
|
x
|
|
277
277
|
);
|
|
278
278
|
a.translateContainer({
|
|
279
|
-
startY:
|
|
280
|
-
endY:
|
|
279
|
+
startY: c,
|
|
280
|
+
endY: c - w,
|
|
281
281
|
animationFrame: r,
|
|
282
282
|
bottomSheetContainer: e
|
|
283
283
|
});
|
|
@@ -285,30 +285,30 @@ const Vt = (t, e, n, o, r, i, a) => (c) => {
|
|
|
285
285
|
}
|
|
286
286
|
}
|
|
287
287
|
const S = kt(
|
|
288
|
-
|
|
289
|
-
|
|
288
|
+
y,
|
|
289
|
+
s,
|
|
290
290
|
n.marginTop
|
|
291
291
|
);
|
|
292
292
|
a.translateContainer({
|
|
293
|
-
startY:
|
|
293
|
+
startY: c,
|
|
294
294
|
endY: S,
|
|
295
295
|
animationFrame: r,
|
|
296
296
|
bottomSheetContainer: e
|
|
297
297
|
});
|
|
298
|
-
} else if (
|
|
299
|
-
const
|
|
300
|
-
(
|
|
298
|
+
} else if (f.isDown) {
|
|
299
|
+
const C = [...n.snapPoints].sort(
|
|
300
|
+
(v, S) => S - v
|
|
301
301
|
);
|
|
302
|
-
for (const
|
|
303
|
-
const S =
|
|
304
|
-
if (
|
|
302
|
+
for (const v of C) {
|
|
303
|
+
const S = v * window.innerHeight, E = s + -c;
|
|
304
|
+
if (E >= S) {
|
|
305
305
|
const x = V(
|
|
306
|
-
|
|
306
|
+
E,
|
|
307
307
|
S
|
|
308
308
|
);
|
|
309
309
|
a.translateContainer({
|
|
310
|
-
startY:
|
|
311
|
-
endY:
|
|
310
|
+
startY: c,
|
|
311
|
+
endY: c + x,
|
|
312
312
|
animationFrame: r,
|
|
313
313
|
bottomSheetContainer: e
|
|
314
314
|
});
|
|
@@ -316,12 +316,12 @@ const Vt = (t, e, n, o, r, i, a) => (c) => {
|
|
|
316
316
|
}
|
|
317
317
|
}
|
|
318
318
|
if (n.preventClosing) {
|
|
319
|
-
const
|
|
320
|
-
if (
|
|
321
|
-
const S = V(
|
|
319
|
+
const v = s + -c;
|
|
320
|
+
if (v >= s) {
|
|
321
|
+
const S = V(v, s);
|
|
322
322
|
a.translateContainer({
|
|
323
|
-
startY:
|
|
324
|
-
endY:
|
|
323
|
+
startY: c,
|
|
324
|
+
endY: c + S,
|
|
325
325
|
animationFrame: r,
|
|
326
326
|
bottomSheetContainer: e
|
|
327
327
|
});
|
|
@@ -332,7 +332,7 @@ const Vt = (t, e, n, o, r, i, a) => (c) => {
|
|
|
332
332
|
}
|
|
333
333
|
};
|
|
334
334
|
var j = /* @__PURE__ */ ((t) => (t[t.All = -1] = "All", t[t.None = 0] = "None", t[t.Capture = 1] = "Capture", t[t.Target = 2] = "Target", t[t.Bubble = 3] = "Bubble", t))(j || {});
|
|
335
|
-
function
|
|
335
|
+
function vt(t) {
|
|
336
336
|
switch (t) {
|
|
337
337
|
case 0:
|
|
338
338
|
return 0;
|
|
@@ -374,7 +374,7 @@ class X {
|
|
|
374
374
|
e(i);
|
|
375
375
|
return;
|
|
376
376
|
}
|
|
377
|
-
|
|
377
|
+
vt(i.eventPhase) === n.eventPhase && e(i);
|
|
378
378
|
},
|
|
379
379
|
{
|
|
380
380
|
passive: !0
|
|
@@ -394,7 +394,7 @@ class X {
|
|
|
394
394
|
e(i);
|
|
395
395
|
return;
|
|
396
396
|
}
|
|
397
|
-
|
|
397
|
+
vt(i.eventPhase) === n.eventPhase && e(i);
|
|
398
398
|
},
|
|
399
399
|
{
|
|
400
400
|
passive: !0
|
|
@@ -515,7 +515,7 @@ function Qt(t) {
|
|
|
515
515
|
t.contentWrapperClass
|
|
516
516
|
]),
|
|
517
517
|
k.ContentWrapper
|
|
518
|
-
),
|
|
518
|
+
), l = M(
|
|
519
519
|
"div",
|
|
520
520
|
R([
|
|
521
521
|
k.Backdrop,
|
|
@@ -524,9 +524,9 @@ function Qt(t) {
|
|
|
524
524
|
]),
|
|
525
525
|
k.Backdrop
|
|
526
526
|
);
|
|
527
|
-
return t.backdropColor && (
|
|
527
|
+
return t.backdropColor && (l.style.backgroundColor = t.backdropColor), t.backDropTransition && (l.style.transition = t.backDropTransition), {
|
|
528
528
|
bottomSheetRoot: e,
|
|
529
|
-
bottomSheetBackdrop:
|
|
529
|
+
bottomSheetBackdrop: l,
|
|
530
530
|
bottomSheetContainer: n,
|
|
531
531
|
bottomSheetHandle: r,
|
|
532
532
|
bottomSheetHandleBar: i,
|
|
@@ -554,36 +554,29 @@ function te({
|
|
|
554
554
|
bottomSheetContainer: r,
|
|
555
555
|
bottomSheetHandle: i,
|
|
556
556
|
bottomSheetContainerGapFiller: a,
|
|
557
|
-
bottomSheetContentWrapper:
|
|
557
|
+
bottomSheetContentWrapper: l,
|
|
558
558
|
bottomSheetBackdrop: u
|
|
559
|
-
} = t, { animationFrame: h } = n,
|
|
560
|
-
|
|
561
|
-
),
|
|
559
|
+
} = t, { animationFrame: h } = n, c = new X(i), f = new X(
|
|
560
|
+
l
|
|
561
|
+
), y = new X(
|
|
562
562
|
a
|
|
563
|
-
)
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
if (!v.length)
|
|
567
|
-
return H;
|
|
568
|
-
const p = Array.from(v).map((d) => d instanceof HTMLElement ? new X(d) : null).filter((d) => !!d);
|
|
569
|
-
return [...H, ...p];
|
|
570
|
-
},
|
|
571
|
-
[]
|
|
572
|
-
), E = new X(
|
|
563
|
+
);
|
|
564
|
+
let s = [];
|
|
565
|
+
const C = new X(
|
|
573
566
|
window
|
|
574
|
-
),
|
|
575
|
-
|
|
567
|
+
), v = Xt(
|
|
568
|
+
C,
|
|
576
569
|
r,
|
|
577
570
|
e,
|
|
578
571
|
n.draggingState
|
|
579
572
|
), S = zt(
|
|
580
|
-
|
|
573
|
+
C,
|
|
581
574
|
r,
|
|
582
575
|
e,
|
|
583
576
|
n.draggingState,
|
|
584
577
|
h
|
|
585
|
-
),
|
|
586
|
-
|
|
578
|
+
), E = Vt(
|
|
579
|
+
C,
|
|
587
580
|
r,
|
|
588
581
|
e,
|
|
589
582
|
n.draggingState,
|
|
@@ -591,91 +584,102 @@ function te({
|
|
|
591
584
|
n.onClose,
|
|
592
585
|
n.bottomSheetState
|
|
593
586
|
);
|
|
594
|
-
function x(
|
|
595
|
-
|
|
587
|
+
function x(T) {
|
|
588
|
+
T.target instanceof Element && !o.contains(T.target) && n.onClose();
|
|
596
589
|
}
|
|
597
|
-
function T
|
|
590
|
+
function w(T) {
|
|
598
591
|
_t(
|
|
599
592
|
n.draggingState,
|
|
600
|
-
|
|
593
|
+
T.target,
|
|
601
594
|
t.bottomSheetContentWrapper
|
|
602
595
|
);
|
|
603
596
|
}
|
|
604
|
-
function Y(
|
|
605
|
-
const
|
|
606
|
-
|
|
607
|
-
onStart:
|
|
608
|
-
}), l.forEach((v) => {
|
|
609
|
-
v.addEventListeners({
|
|
610
|
-
onStart: T,
|
|
611
|
-
onStartOptions: {
|
|
612
|
-
eventPhase: j.Target
|
|
613
|
-
}
|
|
614
|
-
});
|
|
615
|
-
})), y.draggable && y.backgroundDraggable && (m.addEventListeners({
|
|
616
|
-
onStart: T,
|
|
597
|
+
function Y(T) {
|
|
598
|
+
const O = T ?? e;
|
|
599
|
+
O.draggable && O.backgroundDraggable && (f.addEventListeners({
|
|
600
|
+
onStart: w,
|
|
617
601
|
onStartOptions: {
|
|
618
602
|
eventPhase: j.Target
|
|
619
603
|
}
|
|
620
|
-
}),
|
|
621
|
-
onStart:
|
|
622
|
-
})),
|
|
623
|
-
onStart:
|
|
604
|
+
}), y.addEventListeners({
|
|
605
|
+
onStart: w
|
|
606
|
+
})), O.draggable && C.addEventListeners({
|
|
607
|
+
onStart: v,
|
|
624
608
|
onMove: S,
|
|
625
|
-
onEnd:
|
|
626
|
-
}),
|
|
627
|
-
|
|
628
|
-
}), i.addEventListener("keyup", (
|
|
629
|
-
if (
|
|
609
|
+
onEnd: E
|
|
610
|
+
}), O.draggable && window.document.addEventListener("keyup", (b) => {
|
|
611
|
+
b.key === "Escape" && n.onClose();
|
|
612
|
+
}), i.addEventListener("keyup", (b) => {
|
|
613
|
+
if (b.key === "ArrowUp") {
|
|
630
614
|
n.moveUp();
|
|
631
615
|
return;
|
|
632
616
|
}
|
|
633
|
-
if (
|
|
617
|
+
if (b.key === "ArrowDown") {
|
|
634
618
|
n.moveDown();
|
|
635
619
|
return;
|
|
636
620
|
}
|
|
637
|
-
if (
|
|
638
|
-
const
|
|
621
|
+
if (b.shiftKey && b.key === "Tab") {
|
|
622
|
+
const d = P(
|
|
639
623
|
t.bottomSheetContentWrapper
|
|
640
624
|
);
|
|
641
|
-
jt(
|
|
625
|
+
jt(d);
|
|
642
626
|
}
|
|
643
627
|
});
|
|
644
628
|
}
|
|
645
|
-
function U() {
|
|
646
|
-
|
|
629
|
+
function U(T) {
|
|
630
|
+
const O = T ?? e;
|
|
631
|
+
e.shouldCloseOnOutsideClick && !e.preventClosing ? u.addEventListener("click", x) : u.style.pointerEvents = "none", O.draggable && (c.addEventListeners({
|
|
632
|
+
onStart: w
|
|
633
|
+
}), s.forEach((b) => {
|
|
634
|
+
b.removeEventListeners({
|
|
635
|
+
onStart: w
|
|
636
|
+
});
|
|
637
|
+
}), s = e.dragTriggers.reduce((b, d) => {
|
|
638
|
+
const p = o.querySelectorAll(d);
|
|
639
|
+
if (!p.length)
|
|
640
|
+
return b;
|
|
641
|
+
const g = Array.from(p).map((m) => m instanceof HTMLElement ? new X(m) : null).filter((m) => !!m);
|
|
642
|
+
return [...b, ...g];
|
|
643
|
+
}, []), s.forEach((b) => {
|
|
644
|
+
b.addEventListeners({
|
|
645
|
+
onStart: w,
|
|
646
|
+
onStartOptions: {
|
|
647
|
+
eventPhase: j.Target
|
|
648
|
+
}
|
|
649
|
+
});
|
|
650
|
+
}));
|
|
647
651
|
}
|
|
648
652
|
function $() {
|
|
649
653
|
u.removeEventListener("click", x);
|
|
650
654
|
}
|
|
651
|
-
function P(
|
|
652
|
-
let
|
|
653
|
-
for (;
|
|
654
|
-
const
|
|
655
|
-
if (Gt(
|
|
656
|
-
return
|
|
657
|
-
|
|
658
|
-
...
|
|
659
|
-
...Array.from(
|
|
655
|
+
function P(T) {
|
|
656
|
+
let O = [...Array.from(T.childNodes).reverse()];
|
|
657
|
+
for (; O.length; ) {
|
|
658
|
+
const b = O.shift();
|
|
659
|
+
if (Gt(b))
|
|
660
|
+
return b;
|
|
661
|
+
b && (O = [
|
|
662
|
+
...O,
|
|
663
|
+
...Array.from(b.childNodes).reverse()
|
|
660
664
|
]);
|
|
661
665
|
}
|
|
662
666
|
return null;
|
|
663
667
|
}
|
|
664
668
|
function F() {
|
|
665
|
-
|
|
666
|
-
onStart:
|
|
667
|
-
}),
|
|
668
|
-
onStart:
|
|
669
|
-
}),
|
|
670
|
-
onStart:
|
|
671
|
-
}),
|
|
672
|
-
|
|
673
|
-
onStart:
|
|
669
|
+
c.removeEventListeners({
|
|
670
|
+
onStart: w
|
|
671
|
+
}), f.removeEventListeners({
|
|
672
|
+
onStart: w
|
|
673
|
+
}), y.removeEventListeners({
|
|
674
|
+
onStart: w
|
|
675
|
+
}), s.forEach((T) => {
|
|
676
|
+
T.removeEventListeners({
|
|
677
|
+
onStart: w
|
|
674
678
|
});
|
|
675
|
-
}),
|
|
676
|
-
onStart:
|
|
679
|
+
}), C.removeEventListeners({
|
|
680
|
+
onStart: v,
|
|
677
681
|
onMove: S,
|
|
678
|
-
onEnd:
|
|
682
|
+
onEnd: E
|
|
679
683
|
});
|
|
680
684
|
}
|
|
681
685
|
return {
|
|
@@ -698,8 +702,8 @@ class ee {
|
|
|
698
702
|
this.isInProgress = !0;
|
|
699
703
|
const r = (i) => {
|
|
700
704
|
this.startedAt || (this.startedAt = i);
|
|
701
|
-
const a = i - this.startedAt,
|
|
702
|
-
e(
|
|
705
|
+
const a = i - this.startedAt, l = n === 0 ? 1 : tt(a / n, 2), u = l >= 1 && !o;
|
|
706
|
+
e(l), u ? this.stop() : this.animationId = requestAnimationFrame(r);
|
|
703
707
|
};
|
|
704
708
|
this.animationId = requestAnimationFrame(r);
|
|
705
709
|
}
|
|
@@ -715,15 +719,15 @@ function ne(t) {
|
|
|
715
719
|
animationFrame: r,
|
|
716
720
|
onEnd: i,
|
|
717
721
|
animationTimingFunction: a,
|
|
718
|
-
animationDuration:
|
|
722
|
+
animationDuration: l
|
|
719
723
|
} = t, u = wt(e, n);
|
|
720
724
|
r.stop();
|
|
721
725
|
let h = !1;
|
|
722
|
-
r.start((
|
|
726
|
+
r.start((c) => {
|
|
723
727
|
et(o, {
|
|
724
|
-
y: e + u * a(
|
|
725
|
-
}), !h &&
|
|
726
|
-
},
|
|
728
|
+
y: e + u * a(c)
|
|
729
|
+
}), !h && c >= 1 && (i == null || i(), h = !0);
|
|
730
|
+
}, l);
|
|
727
731
|
}
|
|
728
732
|
const ut = (t, e) => (n) => {
|
|
729
733
|
ne({
|
|
@@ -768,32 +772,32 @@ function xt(t) {
|
|
|
768
772
|
return !!(t instanceof Object && "p1x" in t && "p1y" in t && "p2x" in t && "p2y" in t && A(t.p1x) && A(t.p1y) && A(t.p2x) && A(t.p2y));
|
|
769
773
|
}
|
|
770
774
|
function G(t, e, n, o) {
|
|
771
|
-
return function(
|
|
772
|
-
return a(r(
|
|
775
|
+
return function(l) {
|
|
776
|
+
return a(r(l));
|
|
773
777
|
};
|
|
774
|
-
function r(
|
|
775
|
-
let u = 0, h = 1,
|
|
776
|
-
if (
|
|
777
|
-
return
|
|
778
|
+
function r(l) {
|
|
779
|
+
let u = 0, h = 1, c = l, f;
|
|
780
|
+
if (l === 0 || l === 1)
|
|
781
|
+
return l;
|
|
778
782
|
for (; u < h; ) {
|
|
779
|
-
if (
|
|
780
|
-
return
|
|
781
|
-
|
|
783
|
+
if (f = i(c), Math.abs(f - l) < 1e-3)
|
|
784
|
+
return c;
|
|
785
|
+
l > f ? u = c : h = c, c = (h + u) / 2;
|
|
782
786
|
}
|
|
783
|
-
return
|
|
787
|
+
return c;
|
|
784
788
|
}
|
|
785
|
-
function i(
|
|
786
|
-
return 3 * t *
|
|
789
|
+
function i(l) {
|
|
790
|
+
return 3 * t * l * Math.pow(1 - l, 2) + 3 * n * Math.pow(l, 2) * (1 - l) + Math.pow(l, 3);
|
|
787
791
|
}
|
|
788
|
-
function a(
|
|
789
|
-
return 3 * e *
|
|
792
|
+
function a(l) {
|
|
793
|
+
return 3 * e * l * Math.pow(1 - l, 2) + 3 * o * Math.pow(l, 2) * (1 - l) + Math.pow(l, 3);
|
|
790
794
|
}
|
|
791
795
|
}
|
|
792
|
-
const
|
|
796
|
+
const St = G(0.25, 0.1, 0.25, 1), se = G(0.42, 0, 1, 1), At = G(0.42, 0, 0.58, 1), ce = G(0.4, 0.1, 0.6, 1), le = G(0.45, 1.5, 0.55, 1);
|
|
793
797
|
function ue(t) {
|
|
794
798
|
switch (t) {
|
|
795
799
|
case W.EASE:
|
|
796
|
-
return
|
|
800
|
+
return St;
|
|
797
801
|
case W.EASE_IN:
|
|
798
802
|
return se;
|
|
799
803
|
case W.EASE_OUT:
|
|
@@ -803,7 +807,7 @@ function ue(t) {
|
|
|
803
807
|
case W.SPRING:
|
|
804
808
|
return le;
|
|
805
809
|
default:
|
|
806
|
-
return
|
|
810
|
+
return St;
|
|
807
811
|
}
|
|
808
812
|
}
|
|
809
813
|
function yt(t) {
|
|
@@ -959,10 +963,13 @@ function he(t, e, n, o) {
|
|
|
959
963
|
case "draggable":
|
|
960
964
|
o.clearEventListeners(), o.attachEventListeners(n);
|
|
961
965
|
break;
|
|
966
|
+
case "dragTriggers":
|
|
967
|
+
o.clearEventListeners(), o.attachEventListeners(n);
|
|
968
|
+
break;
|
|
962
969
|
case "draggingAnimationTimings":
|
|
963
970
|
if (xt(a)) {
|
|
964
|
-
const
|
|
965
|
-
|
|
971
|
+
const l = dt(a), u = ut(
|
|
972
|
+
l,
|
|
966
973
|
n.draggingAnimationDuration
|
|
967
974
|
);
|
|
968
975
|
e.translateContainer = u;
|
|
@@ -970,10 +977,10 @@ function he(t, e, n, o) {
|
|
|
970
977
|
break;
|
|
971
978
|
case "draggingAnimationDuration":
|
|
972
979
|
if (A(a)) {
|
|
973
|
-
const
|
|
980
|
+
const l = dt(
|
|
974
981
|
n.draggingAnimationTimings
|
|
975
982
|
), u = ut(
|
|
976
|
-
|
|
983
|
+
l,
|
|
977
984
|
a
|
|
978
985
|
);
|
|
979
986
|
e.translateContainer = u;
|
|
@@ -1041,18 +1048,18 @@ function me(t) {
|
|
|
1041
1048
|
function i() {
|
|
1042
1049
|
r.originalDocumentOverflowY && r.originalDocumentOverflowY !== "hidden" && (document.body.style.overflowY = r.originalDocumentOverflowY), r.originalDocumentOverscrollBehavior && (document.body.style.position = r.originalDocumentOverscrollBehavior);
|
|
1043
1050
|
}
|
|
1044
|
-
const a = new ee(),
|
|
1051
|
+
const a = new ee(), l = {
|
|
1045
1052
|
animationFrame: a,
|
|
1046
|
-
onClose:
|
|
1053
|
+
onClose: E,
|
|
1047
1054
|
bottomSheetState: o,
|
|
1048
1055
|
draggingState: r,
|
|
1049
|
-
snapTo:
|
|
1050
|
-
moveUp:
|
|
1051
|
-
moveDown:
|
|
1056
|
+
snapTo: b,
|
|
1057
|
+
moveUp: T,
|
|
1058
|
+
moveDown: O
|
|
1052
1059
|
}, { elements: u, eventHandlers: h } = Jt(
|
|
1053
1060
|
e,
|
|
1054
|
-
|
|
1055
|
-
),
|
|
1061
|
+
l
|
|
1062
|
+
), c = re(
|
|
1056
1063
|
e,
|
|
1057
1064
|
he(
|
|
1058
1065
|
u,
|
|
@@ -1060,184 +1067,184 @@ function me(t) {
|
|
|
1060
1067
|
e,
|
|
1061
1068
|
h
|
|
1062
1069
|
)
|
|
1063
|
-
), { bottomSheetBackdrop:
|
|
1064
|
-
const
|
|
1065
|
-
|
|
1066
|
-
const
|
|
1067
|
-
et(
|
|
1068
|
-
y:
|
|
1070
|
+
), { bottomSheetBackdrop: f, bottomSheetRoot: y, bottomSheetContainer: s } = u, C = (d) => {
|
|
1071
|
+
const p = d ?? window.document.body;
|
|
1072
|
+
p.appendChild(y), p.appendChild(f);
|
|
1073
|
+
const g = window.innerHeight;
|
|
1074
|
+
et(s, {
|
|
1075
|
+
y: g
|
|
1069
1076
|
}), h.attachEventListeners(), o.isMounted = !0;
|
|
1070
|
-
},
|
|
1071
|
-
h.clearEventListeners(), Object.values(u).forEach((
|
|
1072
|
-
|
|
1077
|
+
}, v = () => {
|
|
1078
|
+
h.clearEventListeners(), Object.values(u).forEach((d) => {
|
|
1079
|
+
d.remove();
|
|
1073
1080
|
}), i(), o.isMounted = !1;
|
|
1074
1081
|
}, S = () => {
|
|
1075
|
-
var
|
|
1082
|
+
var d;
|
|
1076
1083
|
if (x() || ae(
|
|
1077
1084
|
'Bottom Sheet is not mounted yet. call the "mount" method first.'
|
|
1078
|
-
), (
|
|
1085
|
+
), (d = t.beforeOpen) == null || d.call(t), w())
|
|
1079
1086
|
return;
|
|
1080
|
-
ot(
|
|
1081
|
-
y:
|
|
1087
|
+
ot(f, !0), c.shouldShowBackdrop || K(f, "transparent"), ot([s], !0), et(s, {
|
|
1088
|
+
y: s.clientHeight
|
|
1082
1089
|
});
|
|
1083
|
-
const
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
),
|
|
1090
|
+
const p = window.innerHeight, g = mt(
|
|
1091
|
+
p,
|
|
1092
|
+
s.clientHeight,
|
|
1093
|
+
c.marginTop,
|
|
1094
|
+
c.defaultPosition
|
|
1095
|
+
), m = D(s).y;
|
|
1089
1096
|
o.translateContainer({
|
|
1090
|
-
startY:
|
|
1091
|
-
endY:
|
|
1097
|
+
startY: m,
|
|
1098
|
+
endY: g,
|
|
1092
1099
|
animationFrame: a,
|
|
1093
|
-
bottomSheetContainer:
|
|
1100
|
+
bottomSheetContainer: s,
|
|
1094
1101
|
onEnd: t.afterOpen
|
|
1095
1102
|
});
|
|
1096
|
-
const
|
|
1097
|
-
r.originalDocumentOverflowY =
|
|
1103
|
+
const H = document.body.style.overflowY;
|
|
1104
|
+
r.originalDocumentOverflowY = H || "initial";
|
|
1098
1105
|
const B = document.body.style.overscrollBehavior;
|
|
1099
1106
|
r.originalDocumentOverscrollBehavior = B || "initial", document.body.style.overflow = "hidden", document.body.style.overscrollBehavior = "contain", u.bottomSheetHandle.focus(), h.attacheOnOpenEventListeners();
|
|
1100
1107
|
};
|
|
1101
|
-
function
|
|
1102
|
-
var
|
|
1108
|
+
function E() {
|
|
1109
|
+
var d;
|
|
1103
1110
|
if (Y())
|
|
1104
1111
|
return;
|
|
1105
|
-
(
|
|
1106
|
-
const
|
|
1112
|
+
(d = t.beforeClose) == null || d.call(t);
|
|
1113
|
+
const p = D(s).y, g = s.clientHeight;
|
|
1107
1114
|
o.translateContainer({
|
|
1108
|
-
startY:
|
|
1109
|
-
endY:
|
|
1115
|
+
startY: p,
|
|
1116
|
+
endY: g,
|
|
1110
1117
|
animationFrame: a,
|
|
1111
|
-
bottomSheetContainer:
|
|
1118
|
+
bottomSheetContainer: s,
|
|
1112
1119
|
onEnd: () => {
|
|
1113
|
-
var
|
|
1114
|
-
(
|
|
1120
|
+
var m;
|
|
1121
|
+
(m = t.afterClose) == null || m.call(t), ot([f, s], !1), h.clearOnOpenEventListeners();
|
|
1115
1122
|
}
|
|
1116
1123
|
}), i();
|
|
1117
1124
|
}
|
|
1118
1125
|
function x() {
|
|
1119
1126
|
return o.isMounted;
|
|
1120
1127
|
}
|
|
1121
|
-
function
|
|
1122
|
-
const
|
|
1123
|
-
return
|
|
1128
|
+
function w() {
|
|
1129
|
+
const d = D(s).y, p = window.innerHeight, g = s.clientHeight >= p ? p : s.clientHeight;
|
|
1130
|
+
return d <= g;
|
|
1124
1131
|
}
|
|
1125
1132
|
function Y() {
|
|
1126
|
-
return !
|
|
1133
|
+
return !w();
|
|
1127
1134
|
}
|
|
1128
1135
|
function U() {
|
|
1129
|
-
const
|
|
1130
|
-
if (
|
|
1136
|
+
const d = D(s).y, p = s.clientHeight, g = window.innerHeight;
|
|
1137
|
+
if (d <= 5 && d >= -5)
|
|
1131
1138
|
return N.CONTENT_HEIGHT;
|
|
1132
|
-
const
|
|
1133
|
-
if (
|
|
1139
|
+
const m = p - d;
|
|
1140
|
+
if (m === g / 2)
|
|
1134
1141
|
return N.MIDDLE;
|
|
1135
|
-
const
|
|
1136
|
-
return
|
|
1142
|
+
const H = g - c.marginTop, B = 10;
|
|
1143
|
+
return m <= H + B && m >= H - B ? N.TOP : N.CLOSED;
|
|
1137
1144
|
}
|
|
1138
1145
|
function $() {
|
|
1139
|
-
return
|
|
1146
|
+
return s.clientHeight;
|
|
1140
1147
|
}
|
|
1141
|
-
function P(
|
|
1142
|
-
if (!
|
|
1148
|
+
function P(d) {
|
|
1149
|
+
if (!w())
|
|
1143
1150
|
return;
|
|
1144
|
-
const
|
|
1151
|
+
const p = D(s).y, g = s.clientHeight - p, m = window.innerHeight - d, H = Ut(g, m), B = V(g, m);
|
|
1145
1152
|
o.translateContainer({
|
|
1146
|
-
startY:
|
|
1147
|
-
endY:
|
|
1153
|
+
startY: p,
|
|
1154
|
+
endY: p + (H.isUp ? -B : B),
|
|
1148
1155
|
animationFrame: a,
|
|
1149
|
-
bottomSheetContainer:
|
|
1156
|
+
bottomSheetContainer: s
|
|
1150
1157
|
});
|
|
1151
1158
|
}
|
|
1152
|
-
function F(
|
|
1153
|
-
viewportHeight:
|
|
1154
|
-
visibleHeight:
|
|
1159
|
+
function F(d, {
|
|
1160
|
+
viewportHeight: p,
|
|
1161
|
+
visibleHeight: g
|
|
1155
1162
|
}) {
|
|
1156
|
-
let
|
|
1157
|
-
for (const
|
|
1158
|
-
const B =
|
|
1159
|
-
|
|
1163
|
+
let m = null;
|
|
1164
|
+
for (const H of d) {
|
|
1165
|
+
const B = H * p, I = V(
|
|
1166
|
+
g,
|
|
1160
1167
|
B
|
|
1161
1168
|
);
|
|
1162
|
-
(
|
|
1169
|
+
(m === null || I < m) && (m = I);
|
|
1163
1170
|
}
|
|
1164
1171
|
return {
|
|
1165
|
-
minOffset:
|
|
1172
|
+
minOffset: m
|
|
1166
1173
|
};
|
|
1167
1174
|
}
|
|
1168
|
-
function
|
|
1169
|
-
const
|
|
1170
|
-
if (!
|
|
1175
|
+
function T() {
|
|
1176
|
+
const d = [...c.snapPoints].reverse(), p = D(s).y, g = s.clientHeight, m = g - p;
|
|
1177
|
+
if (!c.expandable && m >= g)
|
|
1171
1178
|
return;
|
|
1172
|
-
const
|
|
1179
|
+
const H = window.innerHeight, B = ft(
|
|
1173
1180
|
"above",
|
|
1174
|
-
{ visibleHeight:
|
|
1175
|
-
|
|
1181
|
+
{ visibleHeight: m, viewportHeight: H },
|
|
1182
|
+
d
|
|
1176
1183
|
), { minOffset: I } = F(B, {
|
|
1177
|
-
visibleHeight:
|
|
1178
|
-
viewportHeight:
|
|
1184
|
+
visibleHeight: m,
|
|
1185
|
+
viewportHeight: H
|
|
1179
1186
|
});
|
|
1180
|
-
if (I === null &&
|
|
1187
|
+
if (I === null && m < H - c.marginTop) {
|
|
1181
1188
|
o.translateContainer({
|
|
1182
|
-
startY:
|
|
1189
|
+
startY: p,
|
|
1183
1190
|
endY: mt(
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1191
|
+
H,
|
|
1192
|
+
g,
|
|
1193
|
+
c.marginTop,
|
|
1187
1194
|
"top"
|
|
1188
1195
|
),
|
|
1189
1196
|
animationFrame: a,
|
|
1190
|
-
bottomSheetContainer:
|
|
1197
|
+
bottomSheetContainer: s
|
|
1191
1198
|
});
|
|
1192
1199
|
return;
|
|
1193
1200
|
}
|
|
1194
1201
|
A(I) && o.translateContainer({
|
|
1195
|
-
startY:
|
|
1196
|
-
endY:
|
|
1202
|
+
startY: p,
|
|
1203
|
+
endY: p - I,
|
|
1197
1204
|
animationFrame: a,
|
|
1198
|
-
bottomSheetContainer:
|
|
1205
|
+
bottomSheetContainer: s
|
|
1199
1206
|
});
|
|
1200
1207
|
}
|
|
1201
|
-
function
|
|
1202
|
-
const
|
|
1203
|
-
if (
|
|
1208
|
+
function O() {
|
|
1209
|
+
const d = D(s).y, p = s.clientHeight - d;
|
|
1210
|
+
if (p < 1)
|
|
1204
1211
|
return;
|
|
1205
|
-
const
|
|
1212
|
+
const g = window.innerHeight, m = ft(
|
|
1206
1213
|
"below",
|
|
1207
|
-
{ visibleHeight:
|
|
1208
|
-
|
|
1209
|
-
), { minOffset:
|
|
1210
|
-
visibleHeight:
|
|
1211
|
-
viewportHeight:
|
|
1214
|
+
{ visibleHeight: p, viewportHeight: g },
|
|
1215
|
+
c.snapPoints
|
|
1216
|
+
), { minOffset: H } = F(m, {
|
|
1217
|
+
visibleHeight: p,
|
|
1218
|
+
viewportHeight: g
|
|
1212
1219
|
});
|
|
1213
|
-
A(
|
|
1214
|
-
startY:
|
|
1215
|
-
endY:
|
|
1220
|
+
A(H) && o.translateContainer({
|
|
1221
|
+
startY: d,
|
|
1222
|
+
endY: d + H,
|
|
1216
1223
|
animationFrame: a,
|
|
1217
|
-
bottomSheetContainer:
|
|
1224
|
+
bottomSheetContainer: s
|
|
1218
1225
|
});
|
|
1219
1226
|
}
|
|
1220
|
-
function
|
|
1221
|
-
const
|
|
1222
|
-
if (!oe(
|
|
1227
|
+
function b(d) {
|
|
1228
|
+
const p = window.innerHeight;
|
|
1229
|
+
if (!oe(d))
|
|
1223
1230
|
return;
|
|
1224
|
-
const
|
|
1225
|
-
P(
|
|
1231
|
+
const g = tt(p * d, 2);
|
|
1232
|
+
P(g);
|
|
1226
1233
|
}
|
|
1227
1234
|
return {
|
|
1228
|
-
props:
|
|
1235
|
+
props: c,
|
|
1229
1236
|
elements: u,
|
|
1230
|
-
mount:
|
|
1231
|
-
unmount:
|
|
1237
|
+
mount: C,
|
|
1238
|
+
unmount: v,
|
|
1232
1239
|
open: S,
|
|
1233
|
-
close:
|
|
1240
|
+
close: E,
|
|
1234
1241
|
getIsMounted: x,
|
|
1235
|
-
getIsOpen:
|
|
1242
|
+
getIsOpen: w,
|
|
1236
1243
|
getIsClosed: Y,
|
|
1237
1244
|
getPosition: U,
|
|
1238
1245
|
getHeight: $,
|
|
1239
1246
|
moveTo: P,
|
|
1240
|
-
snapTo:
|
|
1247
|
+
snapTo: b
|
|
1241
1248
|
};
|
|
1242
1249
|
}
|
|
1243
1250
|
function Bt() {
|
|
@@ -1273,133 +1280,134 @@ function Bt() {
|
|
|
1273
1280
|
}
|
|
1274
1281
|
};
|
|
1275
1282
|
}
|
|
1276
|
-
const fe = Bt(),
|
|
1283
|
+
const fe = Bt(), Se = Dt(
|
|
1277
1284
|
function(e, n) {
|
|
1278
1285
|
const {
|
|
1279
1286
|
children: o,
|
|
1280
1287
|
isOpen: r,
|
|
1281
1288
|
setIsOpen: i,
|
|
1282
1289
|
afterClose: a,
|
|
1283
|
-
mountingPointRef:
|
|
1290
|
+
mountingPointRef: l,
|
|
1284
1291
|
...u
|
|
1285
|
-
} = e, h = rt(fe), [
|
|
1292
|
+
} = e, h = rt(fe), [c, f] = at(
|
|
1286
1293
|
h.current
|
|
1287
1294
|
);
|
|
1288
1295
|
Mt(
|
|
1289
1296
|
n,
|
|
1290
|
-
() =>
|
|
1291
|
-
[
|
|
1297
|
+
() => c,
|
|
1298
|
+
[c]
|
|
1292
1299
|
);
|
|
1293
|
-
const
|
|
1300
|
+
const y = z(() => {
|
|
1294
1301
|
i(!1), a == null || a();
|
|
1295
1302
|
}, [a]);
|
|
1296
1303
|
q(() => {
|
|
1297
|
-
r ?
|
|
1304
|
+
r ? c.open() : c.close();
|
|
1298
1305
|
}, [r]);
|
|
1299
|
-
const
|
|
1306
|
+
const s = rt(null);
|
|
1300
1307
|
return q(
|
|
1301
1308
|
function() {
|
|
1302
|
-
var
|
|
1303
|
-
if (
|
|
1309
|
+
var E;
|
|
1310
|
+
if (l && !l.current)
|
|
1304
1311
|
return;
|
|
1305
|
-
const
|
|
1306
|
-
if (!
|
|
1312
|
+
const v = Ft((E = e.mountingPointRef) == null ? void 0 : E.current) ? e.mountingPointRef.current : window.document.body;
|
|
1313
|
+
if (!v || c.getIsMounted())
|
|
1307
1314
|
return;
|
|
1308
1315
|
const S = me({
|
|
1309
1316
|
content: "",
|
|
1310
1317
|
...u,
|
|
1311
|
-
afterClose:
|
|
1318
|
+
afterClose: y
|
|
1312
1319
|
});
|
|
1313
|
-
return S.mount(
|
|
1314
|
-
|
|
1320
|
+
return S.mount(v), s.current = S.elements.bottomSheetContentWrapper ?? null, h.current = S, f(S), () => {
|
|
1321
|
+
c.unmount();
|
|
1315
1322
|
};
|
|
1316
1323
|
},
|
|
1317
|
-
[e.mountingPointRef, u,
|
|
1324
|
+
[e.mountingPointRef, u, y]
|
|
1318
1325
|
), q(
|
|
1319
1326
|
function() {
|
|
1320
1327
|
Object.assign(h.current.props, {
|
|
1321
1328
|
...u
|
|
1322
|
-
}),
|
|
1329
|
+
}), f(h.current);
|
|
1323
1330
|
},
|
|
1324
1331
|
[u]
|
|
1325
1332
|
), q(function() {
|
|
1326
1333
|
return () => {
|
|
1327
1334
|
h.current.unmount();
|
|
1328
1335
|
};
|
|
1329
|
-
}, []),
|
|
1336
|
+
}, []), s.current ? Pt(
|
|
1330
1337
|
e.children,
|
|
1331
|
-
|
|
1338
|
+
s.current
|
|
1332
1339
|
) : null;
|
|
1333
1340
|
}
|
|
1334
1341
|
), be = Bt();
|
|
1335
1342
|
function ye(t = {}) {
|
|
1336
|
-
const e = rt(be), [n, o] = at(!1),
|
|
1343
|
+
const e = rt(be), [n, o] = at(!1), r = !n, [i, a] = at(e.current);
|
|
1337
1344
|
q(() => {
|
|
1338
|
-
|
|
1345
|
+
a(e.current);
|
|
1339
1346
|
}, [e.current]);
|
|
1340
1347
|
const {
|
|
1341
|
-
beforeOpen:
|
|
1342
|
-
afterOpen:
|
|
1343
|
-
beforeClose:
|
|
1344
|
-
afterClose:
|
|
1345
|
-
onDragStart:
|
|
1346
|
-
onDragMove:
|
|
1347
|
-
onDragEnd:
|
|
1348
|
-
...
|
|
1349
|
-
} = t,
|
|
1350
|
-
|
|
1351
|
-
}, f = () => {
|
|
1352
|
-
c == null || c(), o(!0);
|
|
1348
|
+
beforeOpen: l,
|
|
1349
|
+
afterOpen: u,
|
|
1350
|
+
beforeClose: h,
|
|
1351
|
+
afterClose: c,
|
|
1352
|
+
onDragStart: f,
|
|
1353
|
+
onDragMove: y,
|
|
1354
|
+
onDragEnd: s,
|
|
1355
|
+
...C
|
|
1356
|
+
} = t, v = () => {
|
|
1357
|
+
l == null || l();
|
|
1353
1358
|
}, S = () => {
|
|
1354
|
-
u == null || u();
|
|
1355
|
-
},
|
|
1356
|
-
h == null || h()
|
|
1359
|
+
u == null || u(), o(!0);
|
|
1360
|
+
}, E = () => {
|
|
1361
|
+
h == null || h();
|
|
1357
1362
|
}, x = () => {
|
|
1363
|
+
c == null || c(), o(!1);
|
|
1364
|
+
}, w = () => {
|
|
1365
|
+
f == null || f();
|
|
1366
|
+
}, Y = (b, d) => {
|
|
1367
|
+
y == null || y(b, d);
|
|
1368
|
+
}, U = () => {
|
|
1358
1369
|
s == null || s();
|
|
1359
|
-
},
|
|
1360
|
-
m == null || m(y, v);
|
|
1361
|
-
}, Y = () => {
|
|
1362
|
-
C == null || C();
|
|
1363
|
-
}, U = Yt(() => ({
|
|
1370
|
+
}, $ = Yt(() => ({
|
|
1364
1371
|
ref: e,
|
|
1365
1372
|
isOpen: n,
|
|
1366
1373
|
setIsOpen: o,
|
|
1367
|
-
beforeOpen:
|
|
1368
|
-
afterOpen:
|
|
1369
|
-
beforeClose:
|
|
1370
|
-
afterClose:
|
|
1371
|
-
onDragStart:
|
|
1372
|
-
onDragMove:
|
|
1373
|
-
onDragEnd:
|
|
1374
|
-
...
|
|
1375
|
-
}), [e.current, n, o, t]),
|
|
1376
|
-
o(!0);
|
|
1377
|
-
}, [o]), P = z(() => {
|
|
1374
|
+
beforeOpen: v,
|
|
1375
|
+
afterOpen: S,
|
|
1376
|
+
beforeClose: E,
|
|
1377
|
+
afterClose: x,
|
|
1378
|
+
onDragStart: w,
|
|
1379
|
+
onDragMove: Y,
|
|
1380
|
+
onDragEnd: U,
|
|
1381
|
+
...C
|
|
1382
|
+
}), [e.current, n, o, t]), P = z(() => {
|
|
1378
1383
|
o(!0);
|
|
1379
|
-
}, [o]), F = z(
|
|
1380
|
-
(
|
|
1381
|
-
|
|
1384
|
+
}, [o]), F = z(() => {
|
|
1385
|
+
o(!1);
|
|
1386
|
+
}, [o]), T = z(
|
|
1387
|
+
(...b) => {
|
|
1388
|
+
i.moveTo(...b);
|
|
1382
1389
|
},
|
|
1383
|
-
[
|
|
1384
|
-
),
|
|
1385
|
-
(...
|
|
1386
|
-
|
|
1390
|
+
[i]
|
|
1391
|
+
), O = z(
|
|
1392
|
+
(...b) => {
|
|
1393
|
+
i.snapTo(...b);
|
|
1387
1394
|
},
|
|
1388
|
-
[
|
|
1395
|
+
[i]
|
|
1389
1396
|
);
|
|
1390
1397
|
return {
|
|
1391
|
-
props:
|
|
1392
|
-
instance:
|
|
1398
|
+
props: $,
|
|
1399
|
+
instance: i,
|
|
1393
1400
|
isOpen: n,
|
|
1401
|
+
isClosed: r,
|
|
1394
1402
|
setIsOpen: o,
|
|
1395
|
-
open:
|
|
1396
|
-
close:
|
|
1397
|
-
moveTo:
|
|
1398
|
-
snapTo:
|
|
1403
|
+
open: P,
|
|
1404
|
+
close: F,
|
|
1405
|
+
moveTo: T,
|
|
1406
|
+
snapTo: O
|
|
1399
1407
|
};
|
|
1400
1408
|
}
|
|
1401
1409
|
export {
|
|
1402
|
-
|
|
1410
|
+
Se as BottomSheet,
|
|
1403
1411
|
Bt as createPlaceholderBottomSheet,
|
|
1404
1412
|
ye as useBottomSheet
|
|
1405
1413
|
};
|