@plainsheet/react 0.4.8 → 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.
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { forwardRef as
|
|
2
|
-
import { createPortal as
|
|
3
|
-
function
|
|
1
|
+
import { forwardRef as Dt, useRef as rt, useState as at, useImperativeHandle as Mt, useCallback as z, useEffect as q, useMemo as Yt } from "react";
|
|
2
|
+
import { createPortal as Pt } from "react-dom";
|
|
3
|
+
function Ft(t) {
|
|
4
4
|
return t != null;
|
|
5
5
|
}
|
|
6
6
|
(function() {
|
|
@@ -13,11 +13,11 @@ function It(t) {
|
|
|
13
13
|
console.error("vite-plugin-css-injected-by-js", e);
|
|
14
14
|
}
|
|
15
15
|
})();
|
|
16
|
-
var
|
|
17
|
-
function
|
|
16
|
+
var It = Object.defineProperty, Rt = (t, e, n) => e in t ? It(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n, J = (t, e, n) => Rt(t, typeof e != "symbol" ? e + "" : e, n);
|
|
17
|
+
function L(t) {
|
|
18
18
|
return typeof t == "string";
|
|
19
19
|
}
|
|
20
|
-
function
|
|
20
|
+
function Wt(t, e) {
|
|
21
21
|
return t.classList.contains(nt(e));
|
|
22
22
|
}
|
|
23
23
|
function K(t, e) {
|
|
@@ -27,15 +27,15 @@ function it(t, e) {
|
|
|
27
27
|
t.classList.remove(nt(e));
|
|
28
28
|
}
|
|
29
29
|
function _(t, e, n) {
|
|
30
|
-
|
|
30
|
+
L(n) && (L(e) && it(t, e), K(t, n));
|
|
31
31
|
}
|
|
32
32
|
function nt(t) {
|
|
33
|
-
return
|
|
33
|
+
return L(t) ? t.trim().replace(/\./g, "") : "";
|
|
34
34
|
}
|
|
35
|
-
function
|
|
35
|
+
function R(t) {
|
|
36
36
|
return t.map((e) => nt(e)).filter(Boolean).join(" ");
|
|
37
37
|
}
|
|
38
|
-
function
|
|
38
|
+
function Nt(t) {
|
|
39
39
|
return t.map((e) => e == null ? void 0 : e.trim()).filter(Boolean).map((e) => `.${e}`).join(" ");
|
|
40
40
|
}
|
|
41
41
|
const pt = "open", ht = "hidden";
|
|
@@ -61,7 +61,7 @@ function A(t) {
|
|
|
61
61
|
function jt(t) {
|
|
62
62
|
Ct(t) && t.focus();
|
|
63
63
|
}
|
|
64
|
-
function
|
|
64
|
+
function Gt(t) {
|
|
65
65
|
if (!Ct(t) || t.offsetParent === null || "disabled" in t && t.disabled)
|
|
66
66
|
return !1;
|
|
67
67
|
const e = t.getAttribute("tabindex"), n = A(e) ? parseInt(e, 10) : -1, o = [
|
|
@@ -75,21 +75,21 @@ function Ut(t) {
|
|
|
75
75
|
].includes(t.tagName), r = t instanceof HTMLAnchorElement && t.href !== "" || t instanceof HTMLAreaElement && t.href !== "";
|
|
76
76
|
return o || r || n > -1;
|
|
77
77
|
}
|
|
78
|
-
var
|
|
78
|
+
var k = /* @__PURE__ */ ((t) => (t.Backdrop = "pbs-backdrop", t.Root = "pbs-root", t.Container = "pbs-container", t.GapFiller = "pbs-gap-filler", t.Handle = "pbs-handle", t.HandleBar = "pbs-handle-bar", t.ContentWrapper = "pbs-content-wrapper", t))(k || {}), st = /* @__PURE__ */ ((t) => (t.Button = "pbs-button-reset", t.Dialog = "pbs-dialog-reset", t))(st || {}), Q = /* @__PURE__ */ ((t) => (t.Hidden = "hidden", t))(Q || {});
|
|
79
79
|
function M(t, e, n) {
|
|
80
80
|
const o = document.createElement(t);
|
|
81
81
|
return e.split(" ").forEach((r) => {
|
|
82
82
|
K(o, r);
|
|
83
|
-
}),
|
|
83
|
+
}), L(n) && o.setAttribute("data-testid", n), o;
|
|
84
84
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
85
|
+
Nt([
|
|
86
|
+
k.Root,
|
|
87
|
+
k.ContentWrapper
|
|
88
88
|
]);
|
|
89
89
|
function mt(t, e, n, o) {
|
|
90
90
|
switch (o) {
|
|
91
91
|
case "content-height":
|
|
92
|
-
return e >= t ?
|
|
92
|
+
return e >= t ? kt(t, e, n) : 0;
|
|
93
93
|
case "middle":
|
|
94
94
|
return -(t / 2 - e);
|
|
95
95
|
case "top":
|
|
@@ -112,7 +112,7 @@ function wt(t, e) {
|
|
|
112
112
|
function V(t, e) {
|
|
113
113
|
return t > e ? t - e : e - t;
|
|
114
114
|
}
|
|
115
|
-
function
|
|
115
|
+
function Ut(t, e) {
|
|
116
116
|
const n = t < e, o = t > e;
|
|
117
117
|
return {
|
|
118
118
|
isUp: n,
|
|
@@ -120,23 +120,23 @@ function $t(t, e) {
|
|
|
120
120
|
stayedSame: t === e
|
|
121
121
|
};
|
|
122
122
|
}
|
|
123
|
-
function
|
|
123
|
+
function ft(t, e, n) {
|
|
124
124
|
const o = t === "above";
|
|
125
125
|
return n.filter((r) => {
|
|
126
126
|
const i = r * e.viewportHeight;
|
|
127
127
|
return o ? e.visibleHeight < i : e.visibleHeight > i;
|
|
128
128
|
});
|
|
129
129
|
}
|
|
130
|
-
function
|
|
130
|
+
function kt(t, e, n) {
|
|
131
131
|
return -(t - e) + n;
|
|
132
132
|
}
|
|
133
|
-
function
|
|
133
|
+
function bt(t) {
|
|
134
134
|
return Number(t.replace("px", ""));
|
|
135
135
|
}
|
|
136
136
|
function tt(t, ...e) {
|
|
137
137
|
return Number(t.toFixed(...e));
|
|
138
138
|
}
|
|
139
|
-
function
|
|
139
|
+
function Tt(t) {
|
|
140
140
|
const e = /(?<type>\w+)\((?<values>[^)]+)\)/g, n = [];
|
|
141
141
|
let o;
|
|
142
142
|
for (; (o = e.exec(t)) !== null; ) {
|
|
@@ -145,8 +145,8 @@ function kt(t) {
|
|
|
145
145
|
}
|
|
146
146
|
return n;
|
|
147
147
|
}
|
|
148
|
-
function
|
|
149
|
-
const e = t.style.transform, n =
|
|
148
|
+
function $t(t) {
|
|
149
|
+
const e = t.style.transform, n = Tt(e);
|
|
150
150
|
return { transform: e, transformValues: n };
|
|
151
151
|
}
|
|
152
152
|
function Ht(t, e) {
|
|
@@ -155,8 +155,8 @@ function Ht(t, e) {
|
|
|
155
155
|
) || null;
|
|
156
156
|
}
|
|
157
157
|
const ct = "translate";
|
|
158
|
-
function
|
|
159
|
-
const e = t.style.transform, n =
|
|
158
|
+
function D(t) {
|
|
159
|
+
const e = t.style.transform, n = Tt(e), o = Ht(
|
|
160
160
|
n,
|
|
161
161
|
ct
|
|
162
162
|
);
|
|
@@ -169,7 +169,7 @@ function et(t, { x: e, y: n }) {
|
|
|
169
169
|
const {
|
|
170
170
|
transform: o,
|
|
171
171
|
transformValues: r
|
|
172
|
-
} =
|
|
172
|
+
} = $t(t), i = Ht(
|
|
173
173
|
r,
|
|
174
174
|
ct
|
|
175
175
|
);
|
|
@@ -191,8 +191,8 @@ function Ot(t) {
|
|
|
191
191
|
);
|
|
192
192
|
const e = t.values[0], n = t.values[1];
|
|
193
193
|
return {
|
|
194
|
-
x:
|
|
195
|
-
y:
|
|
194
|
+
x: bt(e) ?? 0,
|
|
195
|
+
y: bt(n) ?? 0
|
|
196
196
|
};
|
|
197
197
|
}
|
|
198
198
|
function lt(t) {
|
|
@@ -205,9 +205,9 @@ function gt(t, {
|
|
|
205
205
|
return lt(n) && t >= n ? n : lt(e) && t <= e ? e : t;
|
|
206
206
|
}
|
|
207
207
|
const _t = (t, e, n) => {
|
|
208
|
-
e instanceof HTMLElement && !
|
|
208
|
+
e instanceof HTMLElement && !Wt(e, k.Handle) && n.scrollTop >= 1 || (t.isDragging = !0);
|
|
209
209
|
}, Xt = (t, e, n, o) => (r) => {
|
|
210
|
-
o.startY = t.getCoordinates(r).y, o.containerStartTranslate =
|
|
210
|
+
o.startY = t.getCoordinates(r).y, o.containerStartTranslate = D(e), n.onDragStart();
|
|
211
211
|
}, zt = (t, e, n, o, r) => (i) => {
|
|
212
212
|
qt(
|
|
213
213
|
i,
|
|
@@ -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(
|
|
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,61 +254,61 @@ 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
|
|
273
|
-
if (
|
|
274
|
-
const
|
|
275
|
-
|
|
276
|
-
|
|
271
|
+
for (const E of C) {
|
|
272
|
+
const x = E * window.innerHeight;
|
|
273
|
+
if (v <= x) {
|
|
274
|
+
const w = V(
|
|
275
|
+
v,
|
|
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
|
});
|
|
284
284
|
return;
|
|
285
285
|
}
|
|
286
286
|
}
|
|
287
|
-
const
|
|
288
|
-
|
|
289
|
-
|
|
287
|
+
const S = kt(
|
|
288
|
+
y,
|
|
289
|
+
s,
|
|
290
290
|
n.marginTop
|
|
291
291
|
);
|
|
292
292
|
a.translateContainer({
|
|
293
|
-
startY:
|
|
294
|
-
endY:
|
|
293
|
+
startY: c,
|
|
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
|
|
304
|
-
if (
|
|
305
|
-
const
|
|
306
|
-
|
|
307
|
-
|
|
302
|
+
for (const v of C) {
|
|
303
|
+
const S = v * window.innerHeight, E = s + -c;
|
|
304
|
+
if (E >= S) {
|
|
305
|
+
const x = V(
|
|
306
|
+
E,
|
|
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
|
|
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
|
});
|
|
@@ -457,7 +457,10 @@ function Jt(t, e) {
|
|
|
457
457
|
bottomSheetProps: t,
|
|
458
458
|
options: e
|
|
459
459
|
});
|
|
460
|
-
return t.rootStyle && Object.assign(n.bottomSheetRoot.style, t.rootStyle), t.backdropStyle && Object.assign(n.bottomSheetBackdrop.style, t.backdropStyle), t.
|
|
460
|
+
return t.rootStyle && Object.assign(n.bottomSheetRoot.style, t.rootStyle), t.backdropStyle && Object.assign(n.bottomSheetBackdrop.style, t.backdropStyle), t.containerGapFillerStyle && Object.assign(n.bottomSheetContainer.style, t.containerStyle), t.containerStyle && Object.assign(
|
|
461
|
+
n.bottomSheetContainerGapFiller.style,
|
|
462
|
+
t.containerGapFillerStyle
|
|
463
|
+
), t.handleStyle && Object.assign(n.bottomSheetHandleBar.style, t.handleStyle), t.contentWrapperStyle && Object.assign(
|
|
461
464
|
n.bottomSheetContentWrapper.style,
|
|
462
465
|
t.contentWrapperStyle
|
|
463
466
|
), { elements: n, eventHandlers: i };
|
|
@@ -465,63 +468,65 @@ function Jt(t, e) {
|
|
|
465
468
|
function Qt(t) {
|
|
466
469
|
const e = M(
|
|
467
470
|
"dialog",
|
|
468
|
-
|
|
469
|
-
|
|
471
|
+
R([
|
|
472
|
+
k.Root,
|
|
470
473
|
st.Dialog,
|
|
471
474
|
t.rootClass
|
|
472
475
|
]),
|
|
473
|
-
|
|
476
|
+
k.Root
|
|
474
477
|
);
|
|
475
478
|
e.ariaLabel = t.ariaLabel;
|
|
476
479
|
const n = M(
|
|
477
480
|
"section",
|
|
478
|
-
|
|
479
|
-
|
|
481
|
+
R([k.Container, t.containerClass]),
|
|
482
|
+
k.Container
|
|
480
483
|
);
|
|
481
484
|
t.containerBorderRadius && (n.style.borderRadius = Lt(
|
|
482
485
|
t.containerBorderRadius
|
|
483
486
|
));
|
|
484
487
|
const o = M(
|
|
485
488
|
"div",
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
)
|
|
489
|
+
k.GapFiller,
|
|
490
|
+
k.GapFiller
|
|
491
|
+
);
|
|
492
|
+
t.containerBackgroundColor && (n.style.backgroundColor = t.containerBackgroundColor, o.style.backgroundColor = t.containerBackgroundColor);
|
|
493
|
+
const r = M(
|
|
489
494
|
"button",
|
|
490
|
-
|
|
491
|
-
|
|
495
|
+
R([
|
|
496
|
+
k.Handle,
|
|
492
497
|
st.Button,
|
|
493
498
|
t.shouldShowHandle ? null : Q.Hidden,
|
|
494
499
|
t.handleClass
|
|
495
500
|
]),
|
|
496
|
-
|
|
501
|
+
k.Handle
|
|
497
502
|
);
|
|
498
503
|
r.setAttribute("type", "button"), r.ariaLabel = "bottom sheet close button";
|
|
499
504
|
const i = M(
|
|
500
505
|
"span",
|
|
501
|
-
|
|
502
|
-
|
|
506
|
+
R([
|
|
507
|
+
k.HandleBar,
|
|
503
508
|
t.shouldShowHandle ? null : Q.Hidden
|
|
504
509
|
]),
|
|
505
|
-
|
|
510
|
+
k.HandleBar
|
|
506
511
|
), a = M(
|
|
507
512
|
"article",
|
|
508
|
-
|
|
509
|
-
|
|
513
|
+
R([
|
|
514
|
+
k.ContentWrapper,
|
|
510
515
|
t.contentWrapperClass
|
|
511
516
|
]),
|
|
512
|
-
|
|
513
|
-
),
|
|
517
|
+
k.ContentWrapper
|
|
518
|
+
), l = M(
|
|
514
519
|
"div",
|
|
515
|
-
|
|
516
|
-
|
|
520
|
+
R([
|
|
521
|
+
k.Backdrop,
|
|
517
522
|
t.backdropClass,
|
|
518
523
|
Q.Hidden
|
|
519
524
|
]),
|
|
520
|
-
|
|
525
|
+
k.Backdrop
|
|
521
526
|
);
|
|
522
|
-
return t.backdropColor && (
|
|
527
|
+
return t.backdropColor && (l.style.backgroundColor = t.backdropColor), t.backDropTransition && (l.style.transition = t.backDropTransition), {
|
|
523
528
|
bottomSheetRoot: e,
|
|
524
|
-
bottomSheetBackdrop:
|
|
529
|
+
bottomSheetBackdrop: l,
|
|
525
530
|
bottomSheetContainer: n,
|
|
526
531
|
bottomSheetHandle: r,
|
|
527
532
|
bottomSheetHandleBar: i,
|
|
@@ -549,36 +554,29 @@ function te({
|
|
|
549
554
|
bottomSheetContainer: r,
|
|
550
555
|
bottomSheetHandle: i,
|
|
551
556
|
bottomSheetContainerGapFiller: a,
|
|
552
|
-
bottomSheetContentWrapper:
|
|
557
|
+
bottomSheetContentWrapper: l,
|
|
553
558
|
bottomSheetBackdrop: u
|
|
554
|
-
} = t, { animationFrame: h } = n,
|
|
555
|
-
|
|
556
|
-
),
|
|
559
|
+
} = t, { animationFrame: h } = n, c = new X(i), f = new X(
|
|
560
|
+
l
|
|
561
|
+
), y = new X(
|
|
557
562
|
a
|
|
558
|
-
)
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
if (!S.length)
|
|
562
|
-
return H;
|
|
563
|
-
const p = Array.from(S).map((d) => d instanceof HTMLElement ? new X(d) : null).filter((d) => !!d);
|
|
564
|
-
return [...H, ...p];
|
|
565
|
-
},
|
|
566
|
-
[]
|
|
567
|
-
), E = new X(
|
|
563
|
+
);
|
|
564
|
+
let s = [];
|
|
565
|
+
const C = new X(
|
|
568
566
|
window
|
|
569
|
-
),
|
|
570
|
-
|
|
567
|
+
), v = Xt(
|
|
568
|
+
C,
|
|
571
569
|
r,
|
|
572
570
|
e,
|
|
573
571
|
n.draggingState
|
|
574
|
-
),
|
|
575
|
-
|
|
572
|
+
), S = zt(
|
|
573
|
+
C,
|
|
576
574
|
r,
|
|
577
575
|
e,
|
|
578
576
|
n.draggingState,
|
|
579
577
|
h
|
|
580
|
-
),
|
|
581
|
-
|
|
578
|
+
), E = Vt(
|
|
579
|
+
C,
|
|
582
580
|
r,
|
|
583
581
|
e,
|
|
584
582
|
n.draggingState,
|
|
@@ -586,98 +584,109 @@ function te({
|
|
|
586
584
|
n.onClose,
|
|
587
585
|
n.bottomSheetState
|
|
588
586
|
);
|
|
589
|
-
function
|
|
590
|
-
|
|
587
|
+
function x(T) {
|
|
588
|
+
T.target instanceof Element && !o.contains(T.target) && n.onClose();
|
|
591
589
|
}
|
|
592
|
-
function
|
|
590
|
+
function w(T) {
|
|
593
591
|
_t(
|
|
594
592
|
n.draggingState,
|
|
595
|
-
|
|
593
|
+
T.target,
|
|
596
594
|
t.bottomSheetContentWrapper
|
|
597
595
|
);
|
|
598
596
|
}
|
|
599
|
-
function
|
|
600
|
-
const
|
|
601
|
-
|
|
602
|
-
onStart:
|
|
603
|
-
}), l.forEach((S) => {
|
|
604
|
-
S.addEventListeners({
|
|
605
|
-
onStart: k,
|
|
606
|
-
onStartOptions: {
|
|
607
|
-
eventPhase: j.Target
|
|
608
|
-
}
|
|
609
|
-
});
|
|
610
|
-
})), y.draggable && y.backgroundDraggable && (m.addEventListeners({
|
|
611
|
-
onStart: k,
|
|
597
|
+
function Y(T) {
|
|
598
|
+
const O = T ?? e;
|
|
599
|
+
O.draggable && O.backgroundDraggable && (f.addEventListeners({
|
|
600
|
+
onStart: w,
|
|
612
601
|
onStartOptions: {
|
|
613
602
|
eventPhase: j.Target
|
|
614
603
|
}
|
|
615
|
-
}),
|
|
616
|
-
onStart:
|
|
617
|
-
})),
|
|
618
|
-
onStart:
|
|
619
|
-
onMove:
|
|
620
|
-
onEnd:
|
|
621
|
-
}),
|
|
622
|
-
|
|
623
|
-
}), i.addEventListener("keyup", (
|
|
624
|
-
if (
|
|
604
|
+
}), y.addEventListeners({
|
|
605
|
+
onStart: w
|
|
606
|
+
})), O.draggable && C.addEventListeners({
|
|
607
|
+
onStart: v,
|
|
608
|
+
onMove: S,
|
|
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") {
|
|
625
614
|
n.moveUp();
|
|
626
615
|
return;
|
|
627
616
|
}
|
|
628
|
-
if (
|
|
617
|
+
if (b.key === "ArrowDown") {
|
|
629
618
|
n.moveDown();
|
|
630
619
|
return;
|
|
631
620
|
}
|
|
632
|
-
if (
|
|
633
|
-
const
|
|
621
|
+
if (b.shiftKey && b.key === "Tab") {
|
|
622
|
+
const d = P(
|
|
634
623
|
t.bottomSheetContentWrapper
|
|
635
624
|
);
|
|
636
|
-
jt(
|
|
625
|
+
jt(d);
|
|
637
626
|
}
|
|
638
627
|
});
|
|
639
628
|
}
|
|
640
|
-
function
|
|
641
|
-
|
|
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
|
+
}));
|
|
642
651
|
}
|
|
643
|
-
function
|
|
644
|
-
u.removeEventListener("click",
|
|
652
|
+
function $() {
|
|
653
|
+
u.removeEventListener("click", x);
|
|
645
654
|
}
|
|
646
|
-
function
|
|
647
|
-
let
|
|
648
|
-
for (;
|
|
649
|
-
const
|
|
650
|
-
if (
|
|
651
|
-
return
|
|
652
|
-
|
|
653
|
-
...
|
|
654
|
-
...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()
|
|
655
664
|
]);
|
|
656
665
|
}
|
|
657
666
|
return null;
|
|
658
667
|
}
|
|
659
|
-
function
|
|
660
|
-
|
|
661
|
-
onStart:
|
|
662
|
-
}),
|
|
663
|
-
onStart:
|
|
664
|
-
}),
|
|
665
|
-
onStart:
|
|
666
|
-
}),
|
|
667
|
-
|
|
668
|
-
onStart:
|
|
668
|
+
function F() {
|
|
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
|
|
669
678
|
});
|
|
670
|
-
}),
|
|
671
|
-
onStart:
|
|
672
|
-
onMove:
|
|
673
|
-
onEnd:
|
|
679
|
+
}), C.removeEventListeners({
|
|
680
|
+
onStart: v,
|
|
681
|
+
onMove: S,
|
|
682
|
+
onEnd: E
|
|
674
683
|
});
|
|
675
684
|
}
|
|
676
685
|
return {
|
|
677
|
-
attachEventListeners:
|
|
678
|
-
clearEventListeners:
|
|
679
|
-
attacheOnOpenEventListeners:
|
|
680
|
-
clearOnOpenEventListeners:
|
|
686
|
+
attachEventListeners: Y,
|
|
687
|
+
clearEventListeners: F,
|
|
688
|
+
attacheOnOpenEventListeners: U,
|
|
689
|
+
clearOnOpenEventListeners: $
|
|
681
690
|
};
|
|
682
691
|
}
|
|
683
692
|
class ee {
|
|
@@ -693,8 +702,8 @@ class ee {
|
|
|
693
702
|
this.isInProgress = !0;
|
|
694
703
|
const r = (i) => {
|
|
695
704
|
this.startedAt || (this.startedAt = i);
|
|
696
|
-
const a = i - this.startedAt,
|
|
697
|
-
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);
|
|
698
707
|
};
|
|
699
708
|
this.animationId = requestAnimationFrame(r);
|
|
700
709
|
}
|
|
@@ -710,15 +719,15 @@ function ne(t) {
|
|
|
710
719
|
animationFrame: r,
|
|
711
720
|
onEnd: i,
|
|
712
721
|
animationTimingFunction: a,
|
|
713
|
-
animationDuration:
|
|
722
|
+
animationDuration: l
|
|
714
723
|
} = t, u = wt(e, n);
|
|
715
724
|
r.stop();
|
|
716
725
|
let h = !1;
|
|
717
|
-
r.start((
|
|
726
|
+
r.start((c) => {
|
|
718
727
|
et(o, {
|
|
719
|
-
y: e + u * a(
|
|
720
|
-
}), !h &&
|
|
721
|
-
},
|
|
728
|
+
y: e + u * a(c)
|
|
729
|
+
}), !h && c >= 1 && (i == null || i(), h = !0);
|
|
730
|
+
}, l);
|
|
722
731
|
}
|
|
723
732
|
const ut = (t, e) => (n) => {
|
|
724
733
|
ne({
|
|
@@ -726,7 +735,7 @@ const ut = (t, e) => (n) => {
|
|
|
726
735
|
animationTimingFunction: t,
|
|
727
736
|
animationDuration: e
|
|
728
737
|
});
|
|
729
|
-
},
|
|
738
|
+
}, N = {
|
|
730
739
|
TOP: "top",
|
|
731
740
|
MIDDLE: "middle",
|
|
732
741
|
CONTENT_HEIGHT: "content-height",
|
|
@@ -746,7 +755,7 @@ function re(t, e) {
|
|
|
746
755
|
function ae(...t) {
|
|
747
756
|
console.error(t);
|
|
748
757
|
}
|
|
749
|
-
const
|
|
758
|
+
const W = {
|
|
750
759
|
EASE: "ease",
|
|
751
760
|
EASE_IN: "ease-in",
|
|
752
761
|
EASE_OUT: "ease-out",
|
|
@@ -754,7 +763,7 @@ const N = {
|
|
|
754
763
|
SPRING: "spring"
|
|
755
764
|
};
|
|
756
765
|
function ie(t) {
|
|
757
|
-
for (const e of Object.values(
|
|
766
|
+
for (const e of Object.values(W))
|
|
758
767
|
if (e === t)
|
|
759
768
|
return !0;
|
|
760
769
|
return !1;
|
|
@@ -762,40 +771,40 @@ function ie(t) {
|
|
|
762
771
|
function xt(t) {
|
|
763
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));
|
|
764
773
|
}
|
|
765
|
-
function
|
|
766
|
-
return function(
|
|
767
|
-
return a(r(
|
|
774
|
+
function G(t, e, n, o) {
|
|
775
|
+
return function(l) {
|
|
776
|
+
return a(r(l));
|
|
768
777
|
};
|
|
769
|
-
function r(
|
|
770
|
-
let u = 0, h = 1,
|
|
771
|
-
if (
|
|
772
|
-
return
|
|
778
|
+
function r(l) {
|
|
779
|
+
let u = 0, h = 1, c = l, f;
|
|
780
|
+
if (l === 0 || l === 1)
|
|
781
|
+
return l;
|
|
773
782
|
for (; u < h; ) {
|
|
774
|
-
if (
|
|
775
|
-
return
|
|
776
|
-
|
|
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;
|
|
777
786
|
}
|
|
778
|
-
return
|
|
787
|
+
return c;
|
|
779
788
|
}
|
|
780
|
-
function i(
|
|
781
|
-
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);
|
|
782
791
|
}
|
|
783
|
-
function a(
|
|
784
|
-
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);
|
|
785
794
|
}
|
|
786
795
|
}
|
|
787
|
-
const St =
|
|
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);
|
|
788
797
|
function ue(t) {
|
|
789
798
|
switch (t) {
|
|
790
|
-
case
|
|
799
|
+
case W.EASE:
|
|
791
800
|
return St;
|
|
792
|
-
case
|
|
801
|
+
case W.EASE_IN:
|
|
793
802
|
return se;
|
|
794
|
-
case
|
|
803
|
+
case W.EASE_OUT:
|
|
795
804
|
return At;
|
|
796
|
-
case
|
|
805
|
+
case W.EASE_IN_OUT:
|
|
797
806
|
return ce;
|
|
798
|
-
case
|
|
807
|
+
case W.SPRING:
|
|
799
808
|
return le;
|
|
800
809
|
default:
|
|
801
810
|
return St;
|
|
@@ -807,7 +816,7 @@ function yt(t) {
|
|
|
807
816
|
const de = {
|
|
808
817
|
ariaLabel: "Bottom sheet",
|
|
809
818
|
content: "",
|
|
810
|
-
defaultPosition:
|
|
819
|
+
defaultPosition: N.CONTENT_HEIGHT,
|
|
811
820
|
marginTop: 20,
|
|
812
821
|
snapPoints: [],
|
|
813
822
|
width: "92%",
|
|
@@ -835,6 +844,7 @@ const de = {
|
|
|
835
844
|
shouldShowHandle: !0,
|
|
836
845
|
backDropTransition: null,
|
|
837
846
|
backdropColor: null,
|
|
847
|
+
containerBackgroundColor: null,
|
|
838
848
|
containerBorderRadius: null,
|
|
839
849
|
rootClass: null,
|
|
840
850
|
containerClass: null,
|
|
@@ -847,7 +857,8 @@ const de = {
|
|
|
847
857
|
containerStyle: {},
|
|
848
858
|
handleStyle: {},
|
|
849
859
|
contentWrapperStyle: {},
|
|
850
|
-
backdropStyle: {}
|
|
860
|
+
backdropStyle: {},
|
|
861
|
+
containerGapFillerStyle: {}
|
|
851
862
|
};
|
|
852
863
|
function pe(t) {
|
|
853
864
|
const e = {
|
|
@@ -867,7 +878,7 @@ function pe(t) {
|
|
|
867
878
|
function dt(t) {
|
|
868
879
|
if (xt(t)) {
|
|
869
880
|
const { p1x: e, p1y: n, p2x: o, p2y: r } = t;
|
|
870
|
-
return
|
|
881
|
+
return G(e, n, o, r);
|
|
871
882
|
}
|
|
872
883
|
return ie(t) ? ue(t) : At;
|
|
873
884
|
}
|
|
@@ -875,10 +886,10 @@ function he(t, e, n, o) {
|
|
|
875
886
|
function r(i, a) {
|
|
876
887
|
switch (i) {
|
|
877
888
|
case "content":
|
|
878
|
-
|
|
889
|
+
L(a) && (t.bottomSheetContentWrapper.innerHTML = a);
|
|
879
890
|
break;
|
|
880
891
|
case "width":
|
|
881
|
-
|
|
892
|
+
L(a) && (t.bottomSheetContainer.style.width = a);
|
|
882
893
|
break;
|
|
883
894
|
case "shouldShowHandle":
|
|
884
895
|
yt(a) || Z(t.bottomSheetHandle, !1);
|
|
@@ -887,16 +898,19 @@ function he(t, e, n, o) {
|
|
|
887
898
|
yt(a) || Z(t.bottomSheetBackdrop, !1);
|
|
888
899
|
break;
|
|
889
900
|
case "containerBorderRadius":
|
|
890
|
-
|
|
901
|
+
L(a) && (t.bottomSheetContainer.style.borderRadius = Lt(a));
|
|
902
|
+
break;
|
|
903
|
+
case "containerBackgroundColor":
|
|
904
|
+
L(a) && (t.bottomSheetContainer.style.backgroundColor = a, t.bottomSheetContainerGapFiller.style.backgroundColor = a);
|
|
891
905
|
break;
|
|
892
906
|
case "backdropColor":
|
|
893
|
-
|
|
907
|
+
L(a) && (t.bottomSheetBackdrop.style.backgroundColor = a);
|
|
894
908
|
break;
|
|
895
909
|
case "backDropTransition":
|
|
896
|
-
|
|
910
|
+
L(a) && (t.bottomSheetBackdrop.style.transition = a);
|
|
897
911
|
break;
|
|
898
912
|
case "rootClass":
|
|
899
|
-
if (!
|
|
913
|
+
if (!L(a))
|
|
900
914
|
return;
|
|
901
915
|
_(
|
|
902
916
|
t.bottomSheetRoot,
|
|
@@ -905,7 +919,7 @@ function he(t, e, n, o) {
|
|
|
905
919
|
);
|
|
906
920
|
break;
|
|
907
921
|
case "containerClass":
|
|
908
|
-
if (!
|
|
922
|
+
if (!L(a))
|
|
909
923
|
return;
|
|
910
924
|
_(
|
|
911
925
|
t.bottomSheetContainer,
|
|
@@ -914,7 +928,7 @@ function he(t, e, n, o) {
|
|
|
914
928
|
);
|
|
915
929
|
break;
|
|
916
930
|
case "handleClass":
|
|
917
|
-
if (!
|
|
931
|
+
if (!L(a))
|
|
918
932
|
return;
|
|
919
933
|
_(
|
|
920
934
|
t.bottomSheetHandle,
|
|
@@ -923,7 +937,7 @@ function he(t, e, n, o) {
|
|
|
923
937
|
);
|
|
924
938
|
break;
|
|
925
939
|
case "contentWrapperClass":
|
|
926
|
-
if (!
|
|
940
|
+
if (!L(a))
|
|
927
941
|
return;
|
|
928
942
|
_(
|
|
929
943
|
t.bottomSheetContentWrapper,
|
|
@@ -932,7 +946,7 @@ function he(t, e, n, o) {
|
|
|
932
946
|
);
|
|
933
947
|
break;
|
|
934
948
|
case "backdropClass":
|
|
935
|
-
if (!
|
|
949
|
+
if (!L(a))
|
|
936
950
|
return;
|
|
937
951
|
_(
|
|
938
952
|
t.bottomSheetBackdrop,
|
|
@@ -949,10 +963,13 @@ function he(t, e, n, o) {
|
|
|
949
963
|
case "draggable":
|
|
950
964
|
o.clearEventListeners(), o.attachEventListeners(n);
|
|
951
965
|
break;
|
|
966
|
+
case "dragTriggers":
|
|
967
|
+
o.clearEventListeners(), o.attachEventListeners(n);
|
|
968
|
+
break;
|
|
952
969
|
case "draggingAnimationTimings":
|
|
953
970
|
if (xt(a)) {
|
|
954
|
-
const
|
|
955
|
-
|
|
971
|
+
const l = dt(a), u = ut(
|
|
972
|
+
l,
|
|
956
973
|
n.draggingAnimationDuration
|
|
957
974
|
);
|
|
958
975
|
e.translateContainer = u;
|
|
@@ -960,10 +977,10 @@ function he(t, e, n, o) {
|
|
|
960
977
|
break;
|
|
961
978
|
case "draggingAnimationDuration":
|
|
962
979
|
if (A(a)) {
|
|
963
|
-
const
|
|
980
|
+
const l = dt(
|
|
964
981
|
n.draggingAnimationTimings
|
|
965
982
|
), u = ut(
|
|
966
|
-
|
|
983
|
+
l,
|
|
967
984
|
a
|
|
968
985
|
);
|
|
969
986
|
e.translateContainer = u;
|
|
@@ -987,6 +1004,12 @@ function he(t, e, n, o) {
|
|
|
987
1004
|
n.containerStyle
|
|
988
1005
|
);
|
|
989
1006
|
break;
|
|
1007
|
+
case "containerGapFillerStyle":
|
|
1008
|
+
n.containerGapFillerStyle && Object.assign(
|
|
1009
|
+
t.bottomSheetContainerGapFiller.style,
|
|
1010
|
+
n.containerGapFillerStyle
|
|
1011
|
+
);
|
|
1012
|
+
break;
|
|
990
1013
|
case "handleStyle":
|
|
991
1014
|
n.handleStyle && Object.assign(
|
|
992
1015
|
t.bottomSheetHandleBar.style,
|
|
@@ -1025,18 +1048,18 @@ function me(t) {
|
|
|
1025
1048
|
function i() {
|
|
1026
1049
|
r.originalDocumentOverflowY && r.originalDocumentOverflowY !== "hidden" && (document.body.style.overflowY = r.originalDocumentOverflowY), r.originalDocumentOverscrollBehavior && (document.body.style.position = r.originalDocumentOverscrollBehavior);
|
|
1027
1050
|
}
|
|
1028
|
-
const a = new ee(),
|
|
1051
|
+
const a = new ee(), l = {
|
|
1029
1052
|
animationFrame: a,
|
|
1030
|
-
onClose:
|
|
1053
|
+
onClose: E,
|
|
1031
1054
|
bottomSheetState: o,
|
|
1032
1055
|
draggingState: r,
|
|
1033
|
-
snapTo:
|
|
1034
|
-
moveUp:
|
|
1035
|
-
moveDown:
|
|
1056
|
+
snapTo: b,
|
|
1057
|
+
moveUp: T,
|
|
1058
|
+
moveDown: O
|
|
1036
1059
|
}, { elements: u, eventHandlers: h } = Jt(
|
|
1037
1060
|
e,
|
|
1038
|
-
|
|
1039
|
-
),
|
|
1061
|
+
l
|
|
1062
|
+
), c = re(
|
|
1040
1063
|
e,
|
|
1041
1064
|
he(
|
|
1042
1065
|
u,
|
|
@@ -1044,187 +1067,187 @@ function me(t) {
|
|
|
1044
1067
|
e,
|
|
1045
1068
|
h
|
|
1046
1069
|
)
|
|
1047
|
-
), { bottomSheetBackdrop:
|
|
1048
|
-
const
|
|
1049
|
-
|
|
1050
|
-
const
|
|
1051
|
-
et(
|
|
1052
|
-
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
|
|
1053
1076
|
}), h.attachEventListeners(), o.isMounted = !0;
|
|
1054
|
-
}, b = () => {
|
|
1055
|
-
h.clearEventListeners(), Object.values(u).forEach((p) => {
|
|
1056
|
-
p.remove();
|
|
1057
|
-
}), i(), o.isMounted = !1;
|
|
1058
1077
|
}, v = () => {
|
|
1059
|
-
|
|
1060
|
-
|
|
1078
|
+
h.clearEventListeners(), Object.values(u).forEach((d) => {
|
|
1079
|
+
d.remove();
|
|
1080
|
+
}), i(), o.isMounted = !1;
|
|
1081
|
+
}, S = () => {
|
|
1082
|
+
var d;
|
|
1083
|
+
if (x() || ae(
|
|
1061
1084
|
'Bottom Sheet is not mounted yet. call the "mount" method first.'
|
|
1062
|
-
), (
|
|
1085
|
+
), (d = t.beforeOpen) == null || d.call(t), w())
|
|
1063
1086
|
return;
|
|
1064
|
-
ot(
|
|
1065
|
-
y:
|
|
1087
|
+
ot(f, !0), c.shouldShowBackdrop || K(f, "transparent"), ot([s], !0), et(s, {
|
|
1088
|
+
y: s.clientHeight
|
|
1066
1089
|
});
|
|
1067
|
-
const
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
),
|
|
1090
|
+
const p = window.innerHeight, g = mt(
|
|
1091
|
+
p,
|
|
1092
|
+
s.clientHeight,
|
|
1093
|
+
c.marginTop,
|
|
1094
|
+
c.defaultPosition
|
|
1095
|
+
), m = D(s).y;
|
|
1073
1096
|
o.translateContainer({
|
|
1074
|
-
startY:
|
|
1075
|
-
endY:
|
|
1097
|
+
startY: m,
|
|
1098
|
+
endY: g,
|
|
1076
1099
|
animationFrame: a,
|
|
1077
|
-
bottomSheetContainer:
|
|
1100
|
+
bottomSheetContainer: s,
|
|
1078
1101
|
onEnd: t.afterOpen
|
|
1079
1102
|
});
|
|
1080
|
-
const
|
|
1081
|
-
r.originalDocumentOverflowY =
|
|
1082
|
-
const
|
|
1083
|
-
r.originalDocumentOverscrollBehavior =
|
|
1103
|
+
const H = document.body.style.overflowY;
|
|
1104
|
+
r.originalDocumentOverflowY = H || "initial";
|
|
1105
|
+
const B = document.body.style.overscrollBehavior;
|
|
1106
|
+
r.originalDocumentOverscrollBehavior = B || "initial", document.body.style.overflow = "hidden", document.body.style.overscrollBehavior = "contain", u.bottomSheetHandle.focus(), h.attacheOnOpenEventListeners();
|
|
1084
1107
|
};
|
|
1085
|
-
function
|
|
1086
|
-
var
|
|
1087
|
-
if (
|
|
1108
|
+
function E() {
|
|
1109
|
+
var d;
|
|
1110
|
+
if (Y())
|
|
1088
1111
|
return;
|
|
1089
|
-
(
|
|
1090
|
-
const
|
|
1112
|
+
(d = t.beforeClose) == null || d.call(t);
|
|
1113
|
+
const p = D(s).y, g = s.clientHeight;
|
|
1091
1114
|
o.translateContainer({
|
|
1092
|
-
startY:
|
|
1093
|
-
endY:
|
|
1115
|
+
startY: p,
|
|
1116
|
+
endY: g,
|
|
1094
1117
|
animationFrame: a,
|
|
1095
|
-
bottomSheetContainer:
|
|
1118
|
+
bottomSheetContainer: s,
|
|
1096
1119
|
onEnd: () => {
|
|
1097
|
-
var
|
|
1098
|
-
(
|
|
1120
|
+
var m;
|
|
1121
|
+
(m = t.afterClose) == null || m.call(t), ot([f, s], !1), h.clearOnOpenEventListeners();
|
|
1099
1122
|
}
|
|
1100
1123
|
}), i();
|
|
1101
1124
|
}
|
|
1102
|
-
function
|
|
1125
|
+
function x() {
|
|
1103
1126
|
return o.isMounted;
|
|
1104
1127
|
}
|
|
1105
|
-
function
|
|
1106
|
-
const
|
|
1107
|
-
return
|
|
1128
|
+
function w() {
|
|
1129
|
+
const d = D(s).y, p = window.innerHeight, g = s.clientHeight >= p ? p : s.clientHeight;
|
|
1130
|
+
return d <= g;
|
|
1131
|
+
}
|
|
1132
|
+
function Y() {
|
|
1133
|
+
return !w();
|
|
1108
1134
|
}
|
|
1109
|
-
function
|
|
1110
|
-
|
|
1135
|
+
function U() {
|
|
1136
|
+
const d = D(s).y, p = s.clientHeight, g = window.innerHeight;
|
|
1137
|
+
if (d <= 5 && d >= -5)
|
|
1138
|
+
return N.CONTENT_HEIGHT;
|
|
1139
|
+
const m = p - d;
|
|
1140
|
+
if (m === g / 2)
|
|
1141
|
+
return N.MIDDLE;
|
|
1142
|
+
const H = g - c.marginTop, B = 10;
|
|
1143
|
+
return m <= H + B && m >= H - B ? N.TOP : N.CLOSED;
|
|
1111
1144
|
}
|
|
1112
1145
|
function $() {
|
|
1113
|
-
|
|
1114
|
-
if (p <= 5 && p >= -5)
|
|
1115
|
-
return F.CONTENT_HEIGHT;
|
|
1116
|
-
const g = d - p;
|
|
1117
|
-
if (g === f / 2)
|
|
1118
|
-
return F.MIDDLE;
|
|
1119
|
-
const O = f - s.marginTop, D = 10;
|
|
1120
|
-
return g <= O + D && g >= O - D ? F.TOP : F.CLOSED;
|
|
1121
|
-
}
|
|
1122
|
-
function G() {
|
|
1123
|
-
return l.clientHeight;
|
|
1146
|
+
return s.clientHeight;
|
|
1124
1147
|
}
|
|
1125
|
-
function
|
|
1126
|
-
if (!
|
|
1148
|
+
function P(d) {
|
|
1149
|
+
if (!w())
|
|
1127
1150
|
return;
|
|
1128
|
-
const
|
|
1151
|
+
const p = D(s).y, g = s.clientHeight - p, m = window.innerHeight - d, H = Ut(g, m), B = V(g, m);
|
|
1129
1152
|
o.translateContainer({
|
|
1130
|
-
startY:
|
|
1131
|
-
endY:
|
|
1153
|
+
startY: p,
|
|
1154
|
+
endY: p + (H.isUp ? -B : B),
|
|
1132
1155
|
animationFrame: a,
|
|
1133
|
-
bottomSheetContainer:
|
|
1156
|
+
bottomSheetContainer: s
|
|
1134
1157
|
});
|
|
1135
1158
|
}
|
|
1136
|
-
function
|
|
1137
|
-
viewportHeight:
|
|
1138
|
-
visibleHeight:
|
|
1159
|
+
function F(d, {
|
|
1160
|
+
viewportHeight: p,
|
|
1161
|
+
visibleHeight: g
|
|
1139
1162
|
}) {
|
|
1140
|
-
let
|
|
1141
|
-
for (const
|
|
1142
|
-
const
|
|
1143
|
-
|
|
1144
|
-
|
|
1163
|
+
let m = null;
|
|
1164
|
+
for (const H of d) {
|
|
1165
|
+
const B = H * p, I = V(
|
|
1166
|
+
g,
|
|
1167
|
+
B
|
|
1145
1168
|
);
|
|
1146
|
-
(
|
|
1169
|
+
(m === null || I < m) && (m = I);
|
|
1147
1170
|
}
|
|
1148
1171
|
return {
|
|
1149
|
-
minOffset:
|
|
1172
|
+
minOffset: m
|
|
1150
1173
|
};
|
|
1151
1174
|
}
|
|
1152
|
-
function
|
|
1153
|
-
const
|
|
1154
|
-
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)
|
|
1155
1178
|
return;
|
|
1156
|
-
const
|
|
1179
|
+
const H = window.innerHeight, B = ft(
|
|
1157
1180
|
"above",
|
|
1158
|
-
{ visibleHeight:
|
|
1159
|
-
|
|
1160
|
-
), { minOffset:
|
|
1161
|
-
visibleHeight:
|
|
1162
|
-
viewportHeight:
|
|
1181
|
+
{ visibleHeight: m, viewportHeight: H },
|
|
1182
|
+
d
|
|
1183
|
+
), { minOffset: I } = F(B, {
|
|
1184
|
+
visibleHeight: m,
|
|
1185
|
+
viewportHeight: H
|
|
1163
1186
|
});
|
|
1164
|
-
if (
|
|
1187
|
+
if (I === null && m < H - c.marginTop) {
|
|
1165
1188
|
o.translateContainer({
|
|
1166
|
-
startY:
|
|
1189
|
+
startY: p,
|
|
1167
1190
|
endY: mt(
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1191
|
+
H,
|
|
1192
|
+
g,
|
|
1193
|
+
c.marginTop,
|
|
1171
1194
|
"top"
|
|
1172
1195
|
),
|
|
1173
1196
|
animationFrame: a,
|
|
1174
|
-
bottomSheetContainer:
|
|
1197
|
+
bottomSheetContainer: s
|
|
1175
1198
|
});
|
|
1176
1199
|
return;
|
|
1177
1200
|
}
|
|
1178
|
-
A(
|
|
1179
|
-
startY:
|
|
1180
|
-
endY:
|
|
1201
|
+
A(I) && o.translateContainer({
|
|
1202
|
+
startY: p,
|
|
1203
|
+
endY: p - I,
|
|
1181
1204
|
animationFrame: a,
|
|
1182
|
-
bottomSheetContainer:
|
|
1205
|
+
bottomSheetContainer: s
|
|
1183
1206
|
});
|
|
1184
1207
|
}
|
|
1185
|
-
function
|
|
1186
|
-
const
|
|
1187
|
-
if (
|
|
1208
|
+
function O() {
|
|
1209
|
+
const d = D(s).y, p = s.clientHeight - d;
|
|
1210
|
+
if (p < 1)
|
|
1188
1211
|
return;
|
|
1189
|
-
const
|
|
1212
|
+
const g = window.innerHeight, m = ft(
|
|
1190
1213
|
"below",
|
|
1191
|
-
{ visibleHeight:
|
|
1192
|
-
|
|
1193
|
-
), { minOffset:
|
|
1194
|
-
visibleHeight:
|
|
1195
|
-
viewportHeight:
|
|
1214
|
+
{ visibleHeight: p, viewportHeight: g },
|
|
1215
|
+
c.snapPoints
|
|
1216
|
+
), { minOffset: H } = F(m, {
|
|
1217
|
+
visibleHeight: p,
|
|
1218
|
+
viewportHeight: g
|
|
1196
1219
|
});
|
|
1197
|
-
A(
|
|
1198
|
-
startY:
|
|
1199
|
-
endY:
|
|
1220
|
+
A(H) && o.translateContainer({
|
|
1221
|
+
startY: d,
|
|
1222
|
+
endY: d + H,
|
|
1200
1223
|
animationFrame: a,
|
|
1201
|
-
bottomSheetContainer:
|
|
1224
|
+
bottomSheetContainer: s
|
|
1202
1225
|
});
|
|
1203
1226
|
}
|
|
1204
|
-
function
|
|
1205
|
-
const
|
|
1206
|
-
if (!oe(
|
|
1227
|
+
function b(d) {
|
|
1228
|
+
const p = window.innerHeight;
|
|
1229
|
+
if (!oe(d))
|
|
1207
1230
|
return;
|
|
1208
|
-
const
|
|
1209
|
-
|
|
1231
|
+
const g = tt(p * d, 2);
|
|
1232
|
+
P(g);
|
|
1210
1233
|
}
|
|
1211
1234
|
return {
|
|
1212
|
-
props:
|
|
1235
|
+
props: c,
|
|
1213
1236
|
elements: u,
|
|
1214
|
-
mount:
|
|
1215
|
-
unmount:
|
|
1216
|
-
open:
|
|
1217
|
-
close:
|
|
1218
|
-
getIsMounted:
|
|
1219
|
-
getIsOpen:
|
|
1220
|
-
getIsClosed:
|
|
1221
|
-
getPosition:
|
|
1222
|
-
getHeight:
|
|
1223
|
-
moveTo:
|
|
1224
|
-
snapTo:
|
|
1237
|
+
mount: C,
|
|
1238
|
+
unmount: v,
|
|
1239
|
+
open: S,
|
|
1240
|
+
close: E,
|
|
1241
|
+
getIsMounted: x,
|
|
1242
|
+
getIsOpen: w,
|
|
1243
|
+
getIsClosed: Y,
|
|
1244
|
+
getPosition: U,
|
|
1245
|
+
getHeight: $,
|
|
1246
|
+
moveTo: P,
|
|
1247
|
+
snapTo: b
|
|
1225
1248
|
};
|
|
1226
1249
|
}
|
|
1227
|
-
function
|
|
1250
|
+
function Bt() {
|
|
1228
1251
|
return {
|
|
1229
1252
|
elements: {
|
|
1230
1253
|
bottomSheetRoot: void 0,
|
|
@@ -1247,7 +1270,7 @@ function Dt() {
|
|
|
1247
1270
|
getHeight: () => 0,
|
|
1248
1271
|
getIsOpen: () => !1,
|
|
1249
1272
|
getIsClosed: () => !0,
|
|
1250
|
-
getPosition: () =>
|
|
1273
|
+
getPosition: () => N.CLOSED,
|
|
1251
1274
|
moveTo: () => {
|
|
1252
1275
|
},
|
|
1253
1276
|
snapTo: () => {
|
|
@@ -1257,133 +1280,134 @@ function Dt() {
|
|
|
1257
1280
|
}
|
|
1258
1281
|
};
|
|
1259
1282
|
}
|
|
1260
|
-
const
|
|
1283
|
+
const fe = Bt(), Se = Dt(
|
|
1261
1284
|
function(e, n) {
|
|
1262
1285
|
const {
|
|
1263
1286
|
children: o,
|
|
1264
1287
|
isOpen: r,
|
|
1265
1288
|
setIsOpen: i,
|
|
1266
1289
|
afterClose: a,
|
|
1267
|
-
mountingPointRef:
|
|
1290
|
+
mountingPointRef: l,
|
|
1268
1291
|
...u
|
|
1269
|
-
} = e, h = rt(
|
|
1292
|
+
} = e, h = rt(fe), [c, f] = at(
|
|
1270
1293
|
h.current
|
|
1271
1294
|
);
|
|
1272
1295
|
Mt(
|
|
1273
1296
|
n,
|
|
1274
|
-
() =>
|
|
1275
|
-
[
|
|
1297
|
+
() => c,
|
|
1298
|
+
[c]
|
|
1276
1299
|
);
|
|
1277
|
-
const
|
|
1300
|
+
const y = z(() => {
|
|
1278
1301
|
i(!1), a == null || a();
|
|
1279
1302
|
}, [a]);
|
|
1280
1303
|
q(() => {
|
|
1281
|
-
r ?
|
|
1304
|
+
r ? c.open() : c.close();
|
|
1282
1305
|
}, [r]);
|
|
1283
|
-
const
|
|
1306
|
+
const s = rt(null);
|
|
1284
1307
|
return q(
|
|
1285
1308
|
function() {
|
|
1286
|
-
var
|
|
1287
|
-
if (
|
|
1309
|
+
var E;
|
|
1310
|
+
if (l && !l.current)
|
|
1288
1311
|
return;
|
|
1289
|
-
const
|
|
1290
|
-
if (!
|
|
1312
|
+
const v = Ft((E = e.mountingPointRef) == null ? void 0 : E.current) ? e.mountingPointRef.current : window.document.body;
|
|
1313
|
+
if (!v || c.getIsMounted())
|
|
1291
1314
|
return;
|
|
1292
|
-
const
|
|
1315
|
+
const S = me({
|
|
1293
1316
|
content: "",
|
|
1294
1317
|
...u,
|
|
1295
|
-
afterClose:
|
|
1318
|
+
afterClose: y
|
|
1296
1319
|
});
|
|
1297
|
-
return
|
|
1298
|
-
|
|
1320
|
+
return S.mount(v), s.current = S.elements.bottomSheetContentWrapper ?? null, h.current = S, f(S), () => {
|
|
1321
|
+
c.unmount();
|
|
1299
1322
|
};
|
|
1300
1323
|
},
|
|
1301
|
-
[e.mountingPointRef, u,
|
|
1324
|
+
[e.mountingPointRef, u, y]
|
|
1302
1325
|
), q(
|
|
1303
1326
|
function() {
|
|
1304
1327
|
Object.assign(h.current.props, {
|
|
1305
1328
|
...u
|
|
1306
|
-
}),
|
|
1329
|
+
}), f(h.current);
|
|
1307
1330
|
},
|
|
1308
1331
|
[u]
|
|
1309
1332
|
), q(function() {
|
|
1310
1333
|
return () => {
|
|
1311
1334
|
h.current.unmount();
|
|
1312
1335
|
};
|
|
1313
|
-
}, []),
|
|
1336
|
+
}, []), s.current ? Pt(
|
|
1314
1337
|
e.children,
|
|
1315
|
-
|
|
1338
|
+
s.current
|
|
1316
1339
|
) : null;
|
|
1317
1340
|
}
|
|
1318
|
-
),
|
|
1341
|
+
), be = Bt();
|
|
1319
1342
|
function ye(t = {}) {
|
|
1320
|
-
const e = rt(
|
|
1343
|
+
const e = rt(be), [n, o] = at(!1), r = !n, [i, a] = at(e.current);
|
|
1321
1344
|
q(() => {
|
|
1322
|
-
|
|
1345
|
+
a(e.current);
|
|
1323
1346
|
}, [e.current]);
|
|
1324
1347
|
const {
|
|
1325
|
-
beforeOpen:
|
|
1326
|
-
afterOpen:
|
|
1327
|
-
beforeClose:
|
|
1328
|
-
afterClose:
|
|
1329
|
-
onDragStart:
|
|
1330
|
-
onDragMove:
|
|
1331
|
-
onDragEnd:
|
|
1332
|
-
...
|
|
1333
|
-
} = t,
|
|
1334
|
-
|
|
1335
|
-
},
|
|
1336
|
-
|
|
1337
|
-
},
|
|
1338
|
-
|
|
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();
|
|
1358
|
+
}, S = () => {
|
|
1359
|
+
u == null || u(), o(!0);
|
|
1360
|
+
}, E = () => {
|
|
1361
|
+
h == null || h();
|
|
1362
|
+
}, x = () => {
|
|
1363
|
+
c == null || c(), o(!1);
|
|
1339
1364
|
}, w = () => {
|
|
1340
|
-
|
|
1341
|
-
},
|
|
1365
|
+
f == null || f();
|
|
1366
|
+
}, Y = (b, d) => {
|
|
1367
|
+
y == null || y(b, d);
|
|
1368
|
+
}, U = () => {
|
|
1342
1369
|
s == null || s();
|
|
1343
|
-
},
|
|
1344
|
-
m == null || m(y, S);
|
|
1345
|
-
}, P = () => {
|
|
1346
|
-
C == null || C();
|
|
1347
|
-
}, $ = Pt(() => ({
|
|
1370
|
+
}, $ = Yt(() => ({
|
|
1348
1371
|
ref: e,
|
|
1349
1372
|
isOpen: n,
|
|
1350
1373
|
setIsOpen: o,
|
|
1351
|
-
beforeOpen:
|
|
1352
|
-
afterOpen:
|
|
1353
|
-
beforeClose:
|
|
1354
|
-
afterClose:
|
|
1355
|
-
onDragStart:
|
|
1356
|
-
onDragMove:
|
|
1357
|
-
onDragEnd:
|
|
1358
|
-
...
|
|
1359
|
-
}), [e.current, n, o, t]),
|
|
1360
|
-
o(!0);
|
|
1361
|
-
}, [o]), Y = 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(() => {
|
|
1362
1383
|
o(!0);
|
|
1363
|
-
}, [o]),
|
|
1364
|
-
(
|
|
1365
|
-
|
|
1384
|
+
}, [o]), F = z(() => {
|
|
1385
|
+
o(!1);
|
|
1386
|
+
}, [o]), T = z(
|
|
1387
|
+
(...b) => {
|
|
1388
|
+
i.moveTo(...b);
|
|
1366
1389
|
},
|
|
1367
|
-
[
|
|
1368
|
-
),
|
|
1369
|
-
(...
|
|
1370
|
-
|
|
1390
|
+
[i]
|
|
1391
|
+
), O = z(
|
|
1392
|
+
(...b) => {
|
|
1393
|
+
i.snapTo(...b);
|
|
1371
1394
|
},
|
|
1372
|
-
[
|
|
1395
|
+
[i]
|
|
1373
1396
|
);
|
|
1374
1397
|
return {
|
|
1375
1398
|
props: $,
|
|
1376
|
-
instance:
|
|
1399
|
+
instance: i,
|
|
1377
1400
|
isOpen: n,
|
|
1401
|
+
isClosed: r,
|
|
1378
1402
|
setIsOpen: o,
|
|
1379
|
-
open:
|
|
1380
|
-
close:
|
|
1381
|
-
moveTo:
|
|
1382
|
-
snapTo:
|
|
1403
|
+
open: P,
|
|
1404
|
+
close: F,
|
|
1405
|
+
moveTo: T,
|
|
1406
|
+
snapTo: O
|
|
1383
1407
|
};
|
|
1384
1408
|
}
|
|
1385
1409
|
export {
|
|
1386
1410
|
Se as BottomSheet,
|
|
1387
|
-
|
|
1411
|
+
Bt as createPlaceholderBottomSheet,
|
|
1388
1412
|
ye as useBottomSheet
|
|
1389
1413
|
};
|