@plainsheet/react 0.4.7 → 0.4.9
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,29 +13,29 @@ 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
|
-
function
|
|
23
|
+
function K(t, e) {
|
|
24
24
|
t.classList.add(nt(e));
|
|
25
25
|
}
|
|
26
26
|
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";
|
|
@@ -43,14 +43,14 @@ function ot(t, e) {
|
|
|
43
43
|
const n = e;
|
|
44
44
|
if (Array.isArray(t)) {
|
|
45
45
|
t.forEach((o) => {
|
|
46
|
-
|
|
46
|
+
Z(o, n), o.setAttribute("aria-modal", n ? "true" : "false");
|
|
47
47
|
});
|
|
48
48
|
return;
|
|
49
49
|
}
|
|
50
|
-
|
|
50
|
+
Z(t, n), t.setAttribute("aria-modal", n ? "true" : "false");
|
|
51
51
|
}
|
|
52
|
-
function
|
|
53
|
-
e ? (
|
|
52
|
+
function Z(t, e) {
|
|
53
|
+
e ? (K(t, pt), it(t, ht)) : (K(t, ht), it(t, pt));
|
|
54
54
|
}
|
|
55
55
|
function Ct(t) {
|
|
56
56
|
return t instanceof HTMLElement;
|
|
@@ -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,14 +75,14 @@ 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 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 || {}),
|
|
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
|
-
|
|
83
|
-
}),
|
|
82
|
+
K(o, r);
|
|
83
|
+
}), L(n) && o.setAttribute("data-testid", n), o;
|
|
84
84
|
}
|
|
85
|
-
|
|
85
|
+
Nt([
|
|
86
86
|
k.Root,
|
|
87
87
|
k.ContentWrapper
|
|
88
88
|
]);
|
|
@@ -109,10 +109,10 @@ function Et(t, e) {
|
|
|
109
109
|
function wt(t, e) {
|
|
110
110
|
return e < t ? -(t - e) : e - t;
|
|
111
111
|
}
|
|
112
|
-
function
|
|
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,7 +120,7 @@ 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;
|
|
@@ -130,13 +130,13 @@ function bt(t, e, n) {
|
|
|
130
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,18 +145,18 @@ function Ht(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
|
-
function
|
|
152
|
+
function Ht(t, e) {
|
|
153
153
|
return t.find(
|
|
154
154
|
(o) => o.type.startsWith(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,21 +222,21 @@ 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
|
|
225
|
+
const c = e.getCoordinates(t).y, u = wt(o.startY, c), h = window.innerHeight, s = i.clientHeight, m = s - (o.containerStartTranslate.y + u);
|
|
226
226
|
if (m >= h)
|
|
227
227
|
return;
|
|
228
|
-
const C = Et(o.startY,
|
|
229
|
-
if (C.isUp && !n.expandable && m >=
|
|
228
|
+
const C = Et(o.startY, c);
|
|
229
|
+
if (C.isUp && !n.expandable && m >= s || n.preventClosing && m <= s)
|
|
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 l = h - a, E =
|
|
236
|
+
const l = h - a, E = s - o.containerStartTranslate.y;
|
|
237
237
|
if (C.isUp) {
|
|
238
|
-
const
|
|
239
|
-
1 - tt(S /
|
|
238
|
+
const f = l - E, S = l - m, w = gt(
|
|
239
|
+
1 - tt(S / f, 2),
|
|
240
240
|
{
|
|
241
241
|
min: 0,
|
|
242
242
|
max: 1
|
|
@@ -244,7 +244,7 @@ function qt(t, e, n, o, r, i, a) {
|
|
|
244
244
|
);
|
|
245
245
|
n.onDragMove(C, w);
|
|
246
246
|
} else if (C.isDown) {
|
|
247
|
-
const
|
|
247
|
+
const f = gt(
|
|
248
248
|
tt(
|
|
249
249
|
1 - m / E,
|
|
250
250
|
2
|
|
@@ -254,30 +254,30 @@ function qt(t, e, n, o, r, i, a) {
|
|
|
254
254
|
max: 1
|
|
255
255
|
}
|
|
256
256
|
);
|
|
257
|
-
n.onDragMove(C,
|
|
257
|
+
n.onDragMove(C, f);
|
|
258
258
|
}
|
|
259
259
|
}
|
|
260
|
-
const Vt = (t, e, n, o, r, i, a) => (
|
|
260
|
+
const Vt = (t, e, n, o, r, i, a) => (c) => {
|
|
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(
|
|
264
|
+
const u = o.startY, h = t.getCoordinates(c).y, s = D(e).y, m = Et(u, h), C = window.innerHeight, l = e.clientHeight;
|
|
265
265
|
if (m.isUp) {
|
|
266
266
|
const E = [...n.snapPoints].sort(
|
|
267
|
-
(w,
|
|
268
|
-
),
|
|
269
|
-
if (!n.expandable &&
|
|
267
|
+
(w, x) => w - x
|
|
268
|
+
), f = l + -s;
|
|
269
|
+
if (!n.expandable && f >= l)
|
|
270
270
|
return;
|
|
271
271
|
for (const w of E) {
|
|
272
|
-
const
|
|
273
|
-
if (
|
|
274
|
-
const
|
|
275
|
-
|
|
276
|
-
|
|
272
|
+
const x = w * window.innerHeight;
|
|
273
|
+
if (f <= x) {
|
|
274
|
+
const T = V(
|
|
275
|
+
f,
|
|
276
|
+
x
|
|
277
277
|
);
|
|
278
278
|
a.translateContainer({
|
|
279
|
-
startY:
|
|
280
|
-
endY:
|
|
279
|
+
startY: s,
|
|
280
|
+
endY: s - T,
|
|
281
281
|
animationFrame: r,
|
|
282
282
|
bottomSheetContainer: e
|
|
283
283
|
});
|
|
@@ -290,36 +290,49 @@ const Vt = (t, e, n, o, r, i, a) => (s) => {
|
|
|
290
290
|
n.marginTop
|
|
291
291
|
);
|
|
292
292
|
a.translateContainer({
|
|
293
|
-
startY:
|
|
293
|
+
startY: s,
|
|
294
294
|
endY: S,
|
|
295
295
|
animationFrame: r,
|
|
296
296
|
bottomSheetContainer: e
|
|
297
297
|
});
|
|
298
298
|
} else if (m.isDown) {
|
|
299
299
|
const E = [...n.snapPoints].sort(
|
|
300
|
-
(
|
|
300
|
+
(f, S) => S - f
|
|
301
301
|
);
|
|
302
|
-
for (const
|
|
303
|
-
const S =
|
|
302
|
+
for (const f of E) {
|
|
303
|
+
const S = f * window.innerHeight, w = l + -s;
|
|
304
304
|
if (w >= S) {
|
|
305
|
-
const
|
|
305
|
+
const x = V(
|
|
306
306
|
w,
|
|
307
307
|
S
|
|
308
308
|
);
|
|
309
309
|
a.translateContainer({
|
|
310
|
-
startY:
|
|
311
|
-
endY:
|
|
310
|
+
startY: s,
|
|
311
|
+
endY: s + x,
|
|
312
312
|
animationFrame: r,
|
|
313
313
|
bottomSheetContainer: e
|
|
314
314
|
});
|
|
315
315
|
return;
|
|
316
316
|
}
|
|
317
317
|
}
|
|
318
|
+
if (n.preventClosing) {
|
|
319
|
+
const f = l + -s;
|
|
320
|
+
if (f >= l) {
|
|
321
|
+
const S = V(f, l);
|
|
322
|
+
a.translateContainer({
|
|
323
|
+
startY: s,
|
|
324
|
+
endY: s + S,
|
|
325
|
+
animationFrame: r,
|
|
326
|
+
bottomSheetContainer: e
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
return;
|
|
330
|
+
}
|
|
318
331
|
i();
|
|
319
332
|
}
|
|
320
333
|
};
|
|
321
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 || {});
|
|
322
|
-
function
|
|
335
|
+
function St(t) {
|
|
323
336
|
switch (t) {
|
|
324
337
|
case 0:
|
|
325
338
|
return 0;
|
|
@@ -338,7 +351,7 @@ const Kt = {
|
|
|
338
351
|
};
|
|
339
352
|
class X {
|
|
340
353
|
constructor(e) {
|
|
341
|
-
|
|
354
|
+
J(this, "currentTarget"), this.currentTarget = e;
|
|
342
355
|
}
|
|
343
356
|
addEventListeners({
|
|
344
357
|
onStart: e,
|
|
@@ -361,7 +374,7 @@ class X {
|
|
|
361
374
|
e(i);
|
|
362
375
|
return;
|
|
363
376
|
}
|
|
364
|
-
|
|
377
|
+
St(i.eventPhase) === n.eventPhase && e(i);
|
|
365
378
|
},
|
|
366
379
|
{
|
|
367
380
|
passive: !0
|
|
@@ -381,7 +394,7 @@ class X {
|
|
|
381
394
|
e(i);
|
|
382
395
|
return;
|
|
383
396
|
}
|
|
384
|
-
|
|
397
|
+
St(i.eventPhase) === n.eventPhase && e(i);
|
|
385
398
|
},
|
|
386
399
|
{
|
|
387
400
|
passive: !0
|
|
@@ -444,7 +457,10 @@ function Jt(t, e) {
|
|
|
444
457
|
bottomSheetProps: t,
|
|
445
458
|
options: e
|
|
446
459
|
});
|
|
447
|
-
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(
|
|
448
464
|
n.bottomSheetContentWrapper.style,
|
|
449
465
|
t.contentWrapperStyle
|
|
450
466
|
), { elements: n, eventHandlers: i };
|
|
@@ -452,7 +468,7 @@ function Jt(t, e) {
|
|
|
452
468
|
function Qt(t) {
|
|
453
469
|
const e = M(
|
|
454
470
|
"dialog",
|
|
455
|
-
|
|
471
|
+
R([
|
|
456
472
|
k.Root,
|
|
457
473
|
st.Dialog,
|
|
458
474
|
t.rootClass
|
|
@@ -462,7 +478,7 @@ function Qt(t) {
|
|
|
462
478
|
e.ariaLabel = t.ariaLabel;
|
|
463
479
|
const n = M(
|
|
464
480
|
"section",
|
|
465
|
-
|
|
481
|
+
R([k.Container, t.containerClass]),
|
|
466
482
|
k.Container
|
|
467
483
|
);
|
|
468
484
|
t.containerBorderRadius && (n.style.borderRadius = Lt(
|
|
@@ -472,12 +488,14 @@ function Qt(t) {
|
|
|
472
488
|
"div",
|
|
473
489
|
k.GapFiller,
|
|
474
490
|
k.GapFiller
|
|
475
|
-
)
|
|
491
|
+
);
|
|
492
|
+
t.containerBackgroundColor && (n.style.backgroundColor = t.containerBackgroundColor, o.style.backgroundColor = t.containerBackgroundColor);
|
|
493
|
+
const r = M(
|
|
476
494
|
"button",
|
|
477
|
-
|
|
495
|
+
R([
|
|
478
496
|
k.Handle,
|
|
479
497
|
st.Button,
|
|
480
|
-
t.shouldShowHandle ? null :
|
|
498
|
+
t.shouldShowHandle ? null : Q.Hidden,
|
|
481
499
|
t.handleClass
|
|
482
500
|
]),
|
|
483
501
|
k.Handle
|
|
@@ -485,30 +503,30 @@ function Qt(t) {
|
|
|
485
503
|
r.setAttribute("type", "button"), r.ariaLabel = "bottom sheet close button";
|
|
486
504
|
const i = M(
|
|
487
505
|
"span",
|
|
488
|
-
|
|
506
|
+
R([
|
|
489
507
|
k.HandleBar,
|
|
490
|
-
t.shouldShowHandle ? null :
|
|
508
|
+
t.shouldShowHandle ? null : Q.Hidden
|
|
491
509
|
]),
|
|
492
510
|
k.HandleBar
|
|
493
511
|
), a = M(
|
|
494
512
|
"article",
|
|
495
|
-
|
|
513
|
+
R([
|
|
496
514
|
k.ContentWrapper,
|
|
497
515
|
t.contentWrapperClass
|
|
498
516
|
]),
|
|
499
517
|
k.ContentWrapper
|
|
500
|
-
),
|
|
518
|
+
), c = M(
|
|
501
519
|
"div",
|
|
502
|
-
|
|
520
|
+
R([
|
|
503
521
|
k.Backdrop,
|
|
504
522
|
t.backdropClass,
|
|
505
|
-
|
|
523
|
+
Q.Hidden
|
|
506
524
|
]),
|
|
507
525
|
k.Backdrop
|
|
508
526
|
);
|
|
509
|
-
return t.backdropColor && (
|
|
527
|
+
return t.backdropColor && (c.style.backgroundColor = t.backdropColor), t.backDropTransition && (c.style.transition = t.backDropTransition), {
|
|
510
528
|
bottomSheetRoot: e,
|
|
511
|
-
bottomSheetBackdrop:
|
|
529
|
+
bottomSheetBackdrop: c,
|
|
512
530
|
bottomSheetContainer: n,
|
|
513
531
|
bottomSheetHandle: r,
|
|
514
532
|
bottomSheetHandleBar: i,
|
|
@@ -536,24 +554,24 @@ function te({
|
|
|
536
554
|
bottomSheetContainer: r,
|
|
537
555
|
bottomSheetHandle: i,
|
|
538
556
|
bottomSheetContainerGapFiller: a,
|
|
539
|
-
bottomSheetContentWrapper:
|
|
557
|
+
bottomSheetContentWrapper: c,
|
|
540
558
|
bottomSheetBackdrop: u
|
|
541
|
-
} = t, { animationFrame: h } = n,
|
|
542
|
-
|
|
559
|
+
} = t, { animationFrame: h } = n, s = new X(i), m = new X(
|
|
560
|
+
c
|
|
543
561
|
), C = new X(
|
|
544
562
|
a
|
|
545
563
|
), l = e.dragTriggers.reduce(
|
|
546
|
-
(
|
|
564
|
+
(H, y) => {
|
|
547
565
|
const v = o.querySelectorAll(y);
|
|
548
566
|
if (!v.length)
|
|
549
|
-
return
|
|
567
|
+
return H;
|
|
550
568
|
const p = Array.from(v).map((d) => d instanceof HTMLElement ? new X(d) : null).filter((d) => !!d);
|
|
551
|
-
return [...
|
|
569
|
+
return [...H, ...p];
|
|
552
570
|
},
|
|
553
571
|
[]
|
|
554
572
|
), E = new X(
|
|
555
573
|
window
|
|
556
|
-
),
|
|
574
|
+
), f = Xt(
|
|
557
575
|
E,
|
|
558
576
|
r,
|
|
559
577
|
e,
|
|
@@ -573,36 +591,36 @@ function te({
|
|
|
573
591
|
n.onClose,
|
|
574
592
|
n.bottomSheetState
|
|
575
593
|
);
|
|
576
|
-
function
|
|
577
|
-
|
|
594
|
+
function x(H) {
|
|
595
|
+
H.target instanceof Element && !o.contains(H.target) && n.onClose();
|
|
578
596
|
}
|
|
579
|
-
function H
|
|
597
|
+
function T(H) {
|
|
580
598
|
_t(
|
|
581
599
|
n.draggingState,
|
|
582
|
-
|
|
600
|
+
H.target,
|
|
583
601
|
t.bottomSheetContentWrapper
|
|
584
602
|
);
|
|
585
603
|
}
|
|
586
|
-
function
|
|
587
|
-
const y =
|
|
588
|
-
y.draggable && (
|
|
589
|
-
onStart:
|
|
604
|
+
function Y(H) {
|
|
605
|
+
const y = H ?? e;
|
|
606
|
+
y.draggable && (s.addEventListeners({
|
|
607
|
+
onStart: T
|
|
590
608
|
}), l.forEach((v) => {
|
|
591
609
|
v.addEventListeners({
|
|
592
|
-
onStart:
|
|
610
|
+
onStart: T,
|
|
593
611
|
onStartOptions: {
|
|
594
612
|
eventPhase: j.Target
|
|
595
613
|
}
|
|
596
614
|
});
|
|
597
615
|
})), y.draggable && y.backgroundDraggable && (m.addEventListeners({
|
|
598
|
-
onStart:
|
|
616
|
+
onStart: T,
|
|
599
617
|
onStartOptions: {
|
|
600
618
|
eventPhase: j.Target
|
|
601
619
|
}
|
|
602
620
|
}), C.addEventListeners({
|
|
603
|
-
onStart:
|
|
621
|
+
onStart: T
|
|
604
622
|
})), y.draggable && E.addEventListeners({
|
|
605
|
-
onStart:
|
|
623
|
+
onStart: f,
|
|
606
624
|
onMove: S,
|
|
607
625
|
onEnd: w
|
|
608
626
|
}), y.draggable && window.document.addEventListener("keyup", (v) => {
|
|
@@ -617,24 +635,24 @@ function te({
|
|
|
617
635
|
return;
|
|
618
636
|
}
|
|
619
637
|
if (v.shiftKey && v.key === "Tab") {
|
|
620
|
-
const p =
|
|
638
|
+
const p = P(
|
|
621
639
|
t.bottomSheetContentWrapper
|
|
622
640
|
);
|
|
623
641
|
jt(p);
|
|
624
642
|
}
|
|
625
643
|
});
|
|
626
644
|
}
|
|
627
|
-
function
|
|
628
|
-
e.shouldCloseOnOutsideClick ? u.addEventListener("click",
|
|
645
|
+
function U() {
|
|
646
|
+
e.shouldCloseOnOutsideClick ? u.addEventListener("click", x) : u.style.pointerEvents = "none";
|
|
629
647
|
}
|
|
630
|
-
function
|
|
631
|
-
u.removeEventListener("click",
|
|
648
|
+
function $() {
|
|
649
|
+
u.removeEventListener("click", x);
|
|
632
650
|
}
|
|
633
|
-
function
|
|
634
|
-
let y = [...Array.from(
|
|
651
|
+
function P(H) {
|
|
652
|
+
let y = [...Array.from(H.childNodes).reverse()];
|
|
635
653
|
for (; y.length; ) {
|
|
636
654
|
const v = y.shift();
|
|
637
|
-
if (
|
|
655
|
+
if (Gt(v))
|
|
638
656
|
return v;
|
|
639
657
|
v && (y = [
|
|
640
658
|
...y,
|
|
@@ -643,33 +661,33 @@ function te({
|
|
|
643
661
|
}
|
|
644
662
|
return null;
|
|
645
663
|
}
|
|
646
|
-
function
|
|
647
|
-
|
|
648
|
-
onStart:
|
|
664
|
+
function F() {
|
|
665
|
+
s.removeEventListeners({
|
|
666
|
+
onStart: T
|
|
649
667
|
}), m.removeEventListeners({
|
|
650
|
-
onStart:
|
|
668
|
+
onStart: T
|
|
651
669
|
}), C.removeEventListeners({
|
|
652
|
-
onStart:
|
|
653
|
-
}), l.forEach((
|
|
654
|
-
|
|
655
|
-
onStart:
|
|
670
|
+
onStart: T
|
|
671
|
+
}), l.forEach((H) => {
|
|
672
|
+
H.removeEventListeners({
|
|
673
|
+
onStart: T
|
|
656
674
|
});
|
|
657
675
|
}), E.removeEventListeners({
|
|
658
|
-
onStart:
|
|
676
|
+
onStart: f,
|
|
659
677
|
onMove: S,
|
|
660
678
|
onEnd: w
|
|
661
679
|
});
|
|
662
680
|
}
|
|
663
681
|
return {
|
|
664
|
-
attachEventListeners:
|
|
665
|
-
clearEventListeners:
|
|
666
|
-
attacheOnOpenEventListeners:
|
|
667
|
-
clearOnOpenEventListeners:
|
|
682
|
+
attachEventListeners: Y,
|
|
683
|
+
clearEventListeners: F,
|
|
684
|
+
attacheOnOpenEventListeners: U,
|
|
685
|
+
clearOnOpenEventListeners: $
|
|
668
686
|
};
|
|
669
687
|
}
|
|
670
688
|
class ee {
|
|
671
689
|
constructor() {
|
|
672
|
-
|
|
690
|
+
J(this, "animationId"), J(this, "isInProgress"), J(this, "startedAt"), this.animationId = null, this.isInProgress = !1, this.startedAt = null;
|
|
673
691
|
}
|
|
674
692
|
/**
|
|
675
693
|
*
|
|
@@ -680,8 +698,8 @@ class ee {
|
|
|
680
698
|
this.isInProgress = !0;
|
|
681
699
|
const r = (i) => {
|
|
682
700
|
this.startedAt || (this.startedAt = i);
|
|
683
|
-
const a = i - this.startedAt,
|
|
684
|
-
e(
|
|
701
|
+
const a = i - this.startedAt, c = n === 0 ? 1 : tt(a / n, 2), u = c >= 1 && !o;
|
|
702
|
+
e(c), u ? this.stop() : this.animationId = requestAnimationFrame(r);
|
|
685
703
|
};
|
|
686
704
|
this.animationId = requestAnimationFrame(r);
|
|
687
705
|
}
|
|
@@ -697,15 +715,15 @@ function ne(t) {
|
|
|
697
715
|
animationFrame: r,
|
|
698
716
|
onEnd: i,
|
|
699
717
|
animationTimingFunction: a,
|
|
700
|
-
animationDuration:
|
|
718
|
+
animationDuration: c
|
|
701
719
|
} = t, u = wt(e, n);
|
|
702
720
|
r.stop();
|
|
703
721
|
let h = !1;
|
|
704
|
-
r.start((
|
|
722
|
+
r.start((s) => {
|
|
705
723
|
et(o, {
|
|
706
|
-
y: e + u * a(
|
|
707
|
-
}), !h &&
|
|
708
|
-
},
|
|
724
|
+
y: e + u * a(s)
|
|
725
|
+
}), !h && s >= 1 && (i == null || i(), h = !0);
|
|
726
|
+
}, c);
|
|
709
727
|
}
|
|
710
728
|
const ut = (t, e) => (n) => {
|
|
711
729
|
ne({
|
|
@@ -713,7 +731,7 @@ const ut = (t, e) => (n) => {
|
|
|
713
731
|
animationTimingFunction: t,
|
|
714
732
|
animationDuration: e
|
|
715
733
|
});
|
|
716
|
-
},
|
|
734
|
+
}, N = {
|
|
717
735
|
TOP: "top",
|
|
718
736
|
MIDDLE: "middle",
|
|
719
737
|
CONTENT_HEIGHT: "content-height",
|
|
@@ -733,7 +751,7 @@ function re(t, e) {
|
|
|
733
751
|
function ae(...t) {
|
|
734
752
|
console.error(t);
|
|
735
753
|
}
|
|
736
|
-
const
|
|
754
|
+
const W = {
|
|
737
755
|
EASE: "ease",
|
|
738
756
|
EASE_IN: "ease-in",
|
|
739
757
|
EASE_OUT: "ease-out",
|
|
@@ -741,7 +759,7 @@ const N = {
|
|
|
741
759
|
SPRING: "spring"
|
|
742
760
|
};
|
|
743
761
|
function ie(t) {
|
|
744
|
-
for (const e of Object.values(
|
|
762
|
+
for (const e of Object.values(W))
|
|
745
763
|
if (e === t)
|
|
746
764
|
return !0;
|
|
747
765
|
return !1;
|
|
@@ -749,43 +767,43 @@ function ie(t) {
|
|
|
749
767
|
function xt(t) {
|
|
750
768
|
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));
|
|
751
769
|
}
|
|
752
|
-
function
|
|
753
|
-
return function(
|
|
754
|
-
return a(r(
|
|
770
|
+
function G(t, e, n, o) {
|
|
771
|
+
return function(c) {
|
|
772
|
+
return a(r(c));
|
|
755
773
|
};
|
|
756
|
-
function r(
|
|
757
|
-
let u = 0, h = 1,
|
|
758
|
-
if (
|
|
759
|
-
return
|
|
774
|
+
function r(c) {
|
|
775
|
+
let u = 0, h = 1, s = c, m;
|
|
776
|
+
if (c === 0 || c === 1)
|
|
777
|
+
return c;
|
|
760
778
|
for (; u < h; ) {
|
|
761
|
-
if (m = i(
|
|
762
|
-
return
|
|
763
|
-
|
|
779
|
+
if (m = i(s), Math.abs(m - c) < 1e-3)
|
|
780
|
+
return s;
|
|
781
|
+
c > m ? u = s : h = s, s = (h + u) / 2;
|
|
764
782
|
}
|
|
765
|
-
return
|
|
783
|
+
return s;
|
|
766
784
|
}
|
|
767
|
-
function i(
|
|
768
|
-
return 3 * t *
|
|
785
|
+
function i(c) {
|
|
786
|
+
return 3 * t * c * Math.pow(1 - c, 2) + 3 * n * Math.pow(c, 2) * (1 - c) + Math.pow(c, 3);
|
|
769
787
|
}
|
|
770
|
-
function a(
|
|
771
|
-
return 3 * e *
|
|
788
|
+
function a(c) {
|
|
789
|
+
return 3 * e * c * Math.pow(1 - c, 2) + 3 * o * Math.pow(c, 2) * (1 - c) + Math.pow(c, 3);
|
|
772
790
|
}
|
|
773
791
|
}
|
|
774
|
-
const
|
|
792
|
+
const vt = 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);
|
|
775
793
|
function ue(t) {
|
|
776
794
|
switch (t) {
|
|
777
|
-
case
|
|
778
|
-
return
|
|
779
|
-
case
|
|
795
|
+
case W.EASE:
|
|
796
|
+
return vt;
|
|
797
|
+
case W.EASE_IN:
|
|
780
798
|
return se;
|
|
781
|
-
case
|
|
799
|
+
case W.EASE_OUT:
|
|
782
800
|
return At;
|
|
783
|
-
case
|
|
801
|
+
case W.EASE_IN_OUT:
|
|
784
802
|
return ce;
|
|
785
|
-
case
|
|
803
|
+
case W.SPRING:
|
|
786
804
|
return le;
|
|
787
805
|
default:
|
|
788
|
-
return
|
|
806
|
+
return vt;
|
|
789
807
|
}
|
|
790
808
|
}
|
|
791
809
|
function yt(t) {
|
|
@@ -794,7 +812,7 @@ function yt(t) {
|
|
|
794
812
|
const de = {
|
|
795
813
|
ariaLabel: "Bottom sheet",
|
|
796
814
|
content: "",
|
|
797
|
-
defaultPosition:
|
|
815
|
+
defaultPosition: N.CONTENT_HEIGHT,
|
|
798
816
|
marginTop: 20,
|
|
799
817
|
snapPoints: [],
|
|
800
818
|
width: "92%",
|
|
@@ -814,6 +832,7 @@ const de = {
|
|
|
814
832
|
onDragEnd: () => {
|
|
815
833
|
},
|
|
816
834
|
expandable: !0,
|
|
835
|
+
preventClosing: !1,
|
|
817
836
|
draggable: !0,
|
|
818
837
|
backgroundDraggable: !0,
|
|
819
838
|
shouldCloseOnOutsideClick: !0,
|
|
@@ -821,6 +840,7 @@ const de = {
|
|
|
821
840
|
shouldShowHandle: !0,
|
|
822
841
|
backDropTransition: null,
|
|
823
842
|
backdropColor: null,
|
|
843
|
+
containerBackgroundColor: null,
|
|
824
844
|
containerBorderRadius: null,
|
|
825
845
|
rootClass: null,
|
|
826
846
|
containerClass: null,
|
|
@@ -833,7 +853,8 @@ const de = {
|
|
|
833
853
|
containerStyle: {},
|
|
834
854
|
handleStyle: {},
|
|
835
855
|
contentWrapperStyle: {},
|
|
836
|
-
backdropStyle: {}
|
|
856
|
+
backdropStyle: {},
|
|
857
|
+
containerGapFillerStyle: {}
|
|
837
858
|
};
|
|
838
859
|
function pe(t) {
|
|
839
860
|
const e = {
|
|
@@ -853,7 +874,7 @@ function pe(t) {
|
|
|
853
874
|
function dt(t) {
|
|
854
875
|
if (xt(t)) {
|
|
855
876
|
const { p1x: e, p1y: n, p2x: o, p2y: r } = t;
|
|
856
|
-
return
|
|
877
|
+
return G(e, n, o, r);
|
|
857
878
|
}
|
|
858
879
|
return ie(t) ? ue(t) : At;
|
|
859
880
|
}
|
|
@@ -861,28 +882,31 @@ function he(t, e, n, o) {
|
|
|
861
882
|
function r(i, a) {
|
|
862
883
|
switch (i) {
|
|
863
884
|
case "content":
|
|
864
|
-
|
|
885
|
+
L(a) && (t.bottomSheetContentWrapper.innerHTML = a);
|
|
865
886
|
break;
|
|
866
887
|
case "width":
|
|
867
|
-
|
|
888
|
+
L(a) && (t.bottomSheetContainer.style.width = a);
|
|
868
889
|
break;
|
|
869
890
|
case "shouldShowHandle":
|
|
870
|
-
yt(a) ||
|
|
891
|
+
yt(a) || Z(t.bottomSheetHandle, !1);
|
|
871
892
|
break;
|
|
872
893
|
case "shouldShowBackdrop":
|
|
873
|
-
yt(a) ||
|
|
894
|
+
yt(a) || Z(t.bottomSheetBackdrop, !1);
|
|
874
895
|
break;
|
|
875
896
|
case "containerBorderRadius":
|
|
876
|
-
|
|
897
|
+
L(a) && (t.bottomSheetContainer.style.borderRadius = Lt(a));
|
|
898
|
+
break;
|
|
899
|
+
case "containerBackgroundColor":
|
|
900
|
+
L(a) && (t.bottomSheetContainer.style.backgroundColor = a, t.bottomSheetContainerGapFiller.style.backgroundColor = a);
|
|
877
901
|
break;
|
|
878
902
|
case "backdropColor":
|
|
879
|
-
|
|
903
|
+
L(a) && (t.bottomSheetBackdrop.style.backgroundColor = a);
|
|
880
904
|
break;
|
|
881
905
|
case "backDropTransition":
|
|
882
|
-
|
|
906
|
+
L(a) && (t.bottomSheetBackdrop.style.transition = a);
|
|
883
907
|
break;
|
|
884
908
|
case "rootClass":
|
|
885
|
-
if (!
|
|
909
|
+
if (!L(a))
|
|
886
910
|
return;
|
|
887
911
|
_(
|
|
888
912
|
t.bottomSheetRoot,
|
|
@@ -891,7 +915,7 @@ function he(t, e, n, o) {
|
|
|
891
915
|
);
|
|
892
916
|
break;
|
|
893
917
|
case "containerClass":
|
|
894
|
-
if (!
|
|
918
|
+
if (!L(a))
|
|
895
919
|
return;
|
|
896
920
|
_(
|
|
897
921
|
t.bottomSheetContainer,
|
|
@@ -900,7 +924,7 @@ function he(t, e, n, o) {
|
|
|
900
924
|
);
|
|
901
925
|
break;
|
|
902
926
|
case "handleClass":
|
|
903
|
-
if (!
|
|
927
|
+
if (!L(a))
|
|
904
928
|
return;
|
|
905
929
|
_(
|
|
906
930
|
t.bottomSheetHandle,
|
|
@@ -909,7 +933,7 @@ function he(t, e, n, o) {
|
|
|
909
933
|
);
|
|
910
934
|
break;
|
|
911
935
|
case "contentWrapperClass":
|
|
912
|
-
if (!
|
|
936
|
+
if (!L(a))
|
|
913
937
|
return;
|
|
914
938
|
_(
|
|
915
939
|
t.bottomSheetContentWrapper,
|
|
@@ -918,7 +942,7 @@ function he(t, e, n, o) {
|
|
|
918
942
|
);
|
|
919
943
|
break;
|
|
920
944
|
case "backdropClass":
|
|
921
|
-
if (!
|
|
945
|
+
if (!L(a))
|
|
922
946
|
return;
|
|
923
947
|
_(
|
|
924
948
|
t.bottomSheetBackdrop,
|
|
@@ -929,13 +953,16 @@ function he(t, e, n, o) {
|
|
|
929
953
|
case "expandable":
|
|
930
954
|
o.clearEventListeners(), o.attachEventListeners(n);
|
|
931
955
|
break;
|
|
956
|
+
case "preventClosing":
|
|
957
|
+
o.clearEventListeners(), o.attachEventListeners(n);
|
|
958
|
+
break;
|
|
932
959
|
case "draggable":
|
|
933
960
|
o.clearEventListeners(), o.attachEventListeners(n);
|
|
934
961
|
break;
|
|
935
962
|
case "draggingAnimationTimings":
|
|
936
963
|
if (xt(a)) {
|
|
937
|
-
const
|
|
938
|
-
|
|
964
|
+
const c = dt(a), u = ut(
|
|
965
|
+
c,
|
|
939
966
|
n.draggingAnimationDuration
|
|
940
967
|
);
|
|
941
968
|
e.translateContainer = u;
|
|
@@ -943,10 +970,10 @@ function he(t, e, n, o) {
|
|
|
943
970
|
break;
|
|
944
971
|
case "draggingAnimationDuration":
|
|
945
972
|
if (A(a)) {
|
|
946
|
-
const
|
|
973
|
+
const c = dt(
|
|
947
974
|
n.draggingAnimationTimings
|
|
948
975
|
), u = ut(
|
|
949
|
-
|
|
976
|
+
c,
|
|
950
977
|
a
|
|
951
978
|
);
|
|
952
979
|
e.translateContainer = u;
|
|
@@ -970,6 +997,12 @@ function he(t, e, n, o) {
|
|
|
970
997
|
n.containerStyle
|
|
971
998
|
);
|
|
972
999
|
break;
|
|
1000
|
+
case "containerGapFillerStyle":
|
|
1001
|
+
n.containerGapFillerStyle && Object.assign(
|
|
1002
|
+
t.bottomSheetContainerGapFiller.style,
|
|
1003
|
+
n.containerGapFillerStyle
|
|
1004
|
+
);
|
|
1005
|
+
break;
|
|
973
1006
|
case "handleStyle":
|
|
974
1007
|
n.handleStyle && Object.assign(
|
|
975
1008
|
t.bottomSheetHandleBar.style,
|
|
@@ -1008,18 +1041,18 @@ function me(t) {
|
|
|
1008
1041
|
function i() {
|
|
1009
1042
|
r.originalDocumentOverflowY && r.originalDocumentOverflowY !== "hidden" && (document.body.style.overflowY = r.originalDocumentOverflowY), r.originalDocumentOverscrollBehavior && (document.body.style.position = r.originalDocumentOverscrollBehavior);
|
|
1010
1043
|
}
|
|
1011
|
-
const a = new ee(),
|
|
1044
|
+
const a = new ee(), c = {
|
|
1012
1045
|
animationFrame: a,
|
|
1013
1046
|
onClose: w,
|
|
1014
1047
|
bottomSheetState: o,
|
|
1015
1048
|
draggingState: r,
|
|
1016
1049
|
snapTo: v,
|
|
1017
|
-
moveUp:
|
|
1050
|
+
moveUp: H,
|
|
1018
1051
|
moveDown: y
|
|
1019
1052
|
}, { elements: u, eventHandlers: h } = Jt(
|
|
1020
1053
|
e,
|
|
1021
|
-
|
|
1022
|
-
),
|
|
1054
|
+
c
|
|
1055
|
+
), s = re(
|
|
1023
1056
|
e,
|
|
1024
1057
|
he(
|
|
1025
1058
|
u,
|
|
@@ -1034,27 +1067,27 @@ function me(t) {
|
|
|
1034
1067
|
et(l, {
|
|
1035
1068
|
y: b
|
|
1036
1069
|
}), h.attachEventListeners(), o.isMounted = !0;
|
|
1037
|
-
},
|
|
1070
|
+
}, f = () => {
|
|
1038
1071
|
h.clearEventListeners(), Object.values(u).forEach((p) => {
|
|
1039
1072
|
p.remove();
|
|
1040
1073
|
}), i(), o.isMounted = !1;
|
|
1041
1074
|
}, S = () => {
|
|
1042
1075
|
var p;
|
|
1043
|
-
if (
|
|
1076
|
+
if (x() || ae(
|
|
1044
1077
|
'Bottom Sheet is not mounted yet. call the "mount" method first.'
|
|
1045
|
-
), (p = t.beforeOpen) == null || p.call(t),
|
|
1078
|
+
), (p = t.beforeOpen) == null || p.call(t), T())
|
|
1046
1079
|
return;
|
|
1047
|
-
ot(m, !0),
|
|
1080
|
+
ot(m, !0), s.shouldShowBackdrop || K(m, "transparent"), ot([l], !0), et(l, {
|
|
1048
1081
|
y: l.clientHeight
|
|
1049
1082
|
});
|
|
1050
1083
|
const d = window.innerHeight, b = mt(
|
|
1051
1084
|
d,
|
|
1052
1085
|
l.clientHeight,
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
),
|
|
1086
|
+
s.marginTop,
|
|
1087
|
+
s.defaultPosition
|
|
1088
|
+
), g = D(l).y;
|
|
1056
1089
|
o.translateContainer({
|
|
1057
|
-
startY:
|
|
1090
|
+
startY: g,
|
|
1058
1091
|
endY: b,
|
|
1059
1092
|
animationFrame: a,
|
|
1060
1093
|
bottomSheetContainer: l,
|
|
@@ -1062,95 +1095,95 @@ function me(t) {
|
|
|
1062
1095
|
});
|
|
1063
1096
|
const O = document.body.style.overflowY;
|
|
1064
1097
|
r.originalDocumentOverflowY = O || "initial";
|
|
1065
|
-
const
|
|
1066
|
-
r.originalDocumentOverscrollBehavior =
|
|
1098
|
+
const B = document.body.style.overscrollBehavior;
|
|
1099
|
+
r.originalDocumentOverscrollBehavior = B || "initial", document.body.style.overflow = "hidden", document.body.style.overscrollBehavior = "contain", u.bottomSheetHandle.focus(), h.attacheOnOpenEventListeners();
|
|
1067
1100
|
};
|
|
1068
1101
|
function w() {
|
|
1069
1102
|
var p;
|
|
1070
|
-
if (
|
|
1103
|
+
if (Y())
|
|
1071
1104
|
return;
|
|
1072
1105
|
(p = t.beforeClose) == null || p.call(t);
|
|
1073
|
-
const d =
|
|
1106
|
+
const d = D(l).y, b = l.clientHeight;
|
|
1074
1107
|
o.translateContainer({
|
|
1075
1108
|
startY: d,
|
|
1076
1109
|
endY: b,
|
|
1077
1110
|
animationFrame: a,
|
|
1078
1111
|
bottomSheetContainer: l,
|
|
1079
1112
|
onEnd: () => {
|
|
1080
|
-
var
|
|
1081
|
-
(
|
|
1113
|
+
var g;
|
|
1114
|
+
(g = t.afterClose) == null || g.call(t), ot([m, l], !1), h.clearOnOpenEventListeners();
|
|
1082
1115
|
}
|
|
1083
1116
|
}), i();
|
|
1084
1117
|
}
|
|
1085
|
-
function
|
|
1118
|
+
function x() {
|
|
1086
1119
|
return o.isMounted;
|
|
1087
1120
|
}
|
|
1088
|
-
function
|
|
1089
|
-
const p =
|
|
1121
|
+
function T() {
|
|
1122
|
+
const p = D(l).y, d = window.innerHeight, b = l.clientHeight >= d ? d : l.clientHeight;
|
|
1090
1123
|
return p <= b;
|
|
1091
1124
|
}
|
|
1092
|
-
function
|
|
1093
|
-
return !
|
|
1125
|
+
function Y() {
|
|
1126
|
+
return !T();
|
|
1094
1127
|
}
|
|
1095
|
-
function
|
|
1096
|
-
const p =
|
|
1128
|
+
function U() {
|
|
1129
|
+
const p = D(l).y, d = l.clientHeight, b = window.innerHeight;
|
|
1097
1130
|
if (p <= 5 && p >= -5)
|
|
1098
|
-
return
|
|
1099
|
-
const
|
|
1100
|
-
if (
|
|
1101
|
-
return
|
|
1102
|
-
const O = b -
|
|
1103
|
-
return
|
|
1131
|
+
return N.CONTENT_HEIGHT;
|
|
1132
|
+
const g = d - p;
|
|
1133
|
+
if (g === b / 2)
|
|
1134
|
+
return N.MIDDLE;
|
|
1135
|
+
const O = b - s.marginTop, B = 10;
|
|
1136
|
+
return g <= O + B && g >= O - B ? N.TOP : N.CLOSED;
|
|
1104
1137
|
}
|
|
1105
|
-
function
|
|
1138
|
+
function $() {
|
|
1106
1139
|
return l.clientHeight;
|
|
1107
1140
|
}
|
|
1108
|
-
function
|
|
1109
|
-
if (!
|
|
1141
|
+
function P(p) {
|
|
1142
|
+
if (!T())
|
|
1110
1143
|
return;
|
|
1111
|
-
const d =
|
|
1144
|
+
const d = D(l).y, b = l.clientHeight - d, g = window.innerHeight - p, O = Ut(b, g), B = V(b, g);
|
|
1112
1145
|
o.translateContainer({
|
|
1113
1146
|
startY: d,
|
|
1114
|
-
endY: d + (O.isUp ? -
|
|
1147
|
+
endY: d + (O.isUp ? -B : B),
|
|
1115
1148
|
animationFrame: a,
|
|
1116
1149
|
bottomSheetContainer: l
|
|
1117
1150
|
});
|
|
1118
1151
|
}
|
|
1119
|
-
function
|
|
1152
|
+
function F(p, {
|
|
1120
1153
|
viewportHeight: d,
|
|
1121
1154
|
visibleHeight: b
|
|
1122
1155
|
}) {
|
|
1123
|
-
let
|
|
1156
|
+
let g = null;
|
|
1124
1157
|
for (const O of p) {
|
|
1125
|
-
const
|
|
1158
|
+
const B = O * d, I = V(
|
|
1126
1159
|
b,
|
|
1127
|
-
|
|
1160
|
+
B
|
|
1128
1161
|
);
|
|
1129
|
-
(
|
|
1162
|
+
(g === null || I < g) && (g = I);
|
|
1130
1163
|
}
|
|
1131
1164
|
return {
|
|
1132
|
-
minOffset:
|
|
1165
|
+
minOffset: g
|
|
1133
1166
|
};
|
|
1134
1167
|
}
|
|
1135
|
-
function
|
|
1136
|
-
const p = [...
|
|
1137
|
-
if (!
|
|
1168
|
+
function H() {
|
|
1169
|
+
const p = [...s.snapPoints].reverse(), d = D(l).y, b = l.clientHeight, g = b - d;
|
|
1170
|
+
if (!s.expandable && g >= b)
|
|
1138
1171
|
return;
|
|
1139
|
-
const O = window.innerHeight,
|
|
1172
|
+
const O = window.innerHeight, B = ft(
|
|
1140
1173
|
"above",
|
|
1141
|
-
{ visibleHeight:
|
|
1174
|
+
{ visibleHeight: g, viewportHeight: O },
|
|
1142
1175
|
p
|
|
1143
|
-
), { minOffset:
|
|
1144
|
-
visibleHeight:
|
|
1176
|
+
), { minOffset: I } = F(B, {
|
|
1177
|
+
visibleHeight: g,
|
|
1145
1178
|
viewportHeight: O
|
|
1146
1179
|
});
|
|
1147
|
-
if (
|
|
1180
|
+
if (I === null && g < O - s.marginTop) {
|
|
1148
1181
|
o.translateContainer({
|
|
1149
1182
|
startY: d,
|
|
1150
1183
|
endY: mt(
|
|
1151
1184
|
O,
|
|
1152
1185
|
b,
|
|
1153
|
-
|
|
1186
|
+
s.marginTop,
|
|
1154
1187
|
"top"
|
|
1155
1188
|
),
|
|
1156
1189
|
animationFrame: a,
|
|
@@ -1158,22 +1191,22 @@ function me(t) {
|
|
|
1158
1191
|
});
|
|
1159
1192
|
return;
|
|
1160
1193
|
}
|
|
1161
|
-
A(
|
|
1194
|
+
A(I) && o.translateContainer({
|
|
1162
1195
|
startY: d,
|
|
1163
|
-
endY: d -
|
|
1196
|
+
endY: d - I,
|
|
1164
1197
|
animationFrame: a,
|
|
1165
1198
|
bottomSheetContainer: l
|
|
1166
1199
|
});
|
|
1167
1200
|
}
|
|
1168
1201
|
function y() {
|
|
1169
|
-
const p =
|
|
1202
|
+
const p = D(l).y, d = l.clientHeight - p;
|
|
1170
1203
|
if (d < 1)
|
|
1171
1204
|
return;
|
|
1172
|
-
const b = window.innerHeight,
|
|
1205
|
+
const b = window.innerHeight, g = ft(
|
|
1173
1206
|
"below",
|
|
1174
1207
|
{ visibleHeight: d, viewportHeight: b },
|
|
1175
|
-
|
|
1176
|
-
), { minOffset: O } =
|
|
1208
|
+
s.snapPoints
|
|
1209
|
+
), { minOffset: O } = F(g, {
|
|
1177
1210
|
visibleHeight: d,
|
|
1178
1211
|
viewportHeight: b
|
|
1179
1212
|
});
|
|
@@ -1189,25 +1222,25 @@ function me(t) {
|
|
|
1189
1222
|
if (!oe(p))
|
|
1190
1223
|
return;
|
|
1191
1224
|
const b = tt(d * p, 2);
|
|
1192
|
-
|
|
1225
|
+
P(b);
|
|
1193
1226
|
}
|
|
1194
1227
|
return {
|
|
1195
|
-
props:
|
|
1228
|
+
props: s,
|
|
1196
1229
|
elements: u,
|
|
1197
1230
|
mount: E,
|
|
1198
|
-
unmount:
|
|
1231
|
+
unmount: f,
|
|
1199
1232
|
open: S,
|
|
1200
1233
|
close: w,
|
|
1201
|
-
getIsMounted:
|
|
1202
|
-
getIsOpen:
|
|
1203
|
-
getIsClosed:
|
|
1204
|
-
getPosition:
|
|
1205
|
-
getHeight:
|
|
1206
|
-
moveTo:
|
|
1234
|
+
getIsMounted: x,
|
|
1235
|
+
getIsOpen: T,
|
|
1236
|
+
getIsClosed: Y,
|
|
1237
|
+
getPosition: U,
|
|
1238
|
+
getHeight: $,
|
|
1239
|
+
moveTo: P,
|
|
1207
1240
|
snapTo: v
|
|
1208
1241
|
};
|
|
1209
1242
|
}
|
|
1210
|
-
function
|
|
1243
|
+
function Bt() {
|
|
1211
1244
|
return {
|
|
1212
1245
|
elements: {
|
|
1213
1246
|
bottomSheetRoot: void 0,
|
|
@@ -1230,7 +1263,7 @@ function Dt() {
|
|
|
1230
1263
|
getHeight: () => 0,
|
|
1231
1264
|
getIsOpen: () => !1,
|
|
1232
1265
|
getIsClosed: () => !0,
|
|
1233
|
-
getPosition: () =>
|
|
1266
|
+
getPosition: () => N.CLOSED,
|
|
1234
1267
|
moveTo: () => {
|
|
1235
1268
|
},
|
|
1236
1269
|
snapTo: () => {
|
|
@@ -1240,45 +1273,45 @@ function Dt() {
|
|
|
1240
1273
|
}
|
|
1241
1274
|
};
|
|
1242
1275
|
}
|
|
1243
|
-
const
|
|
1276
|
+
const fe = Bt(), ve = Dt(
|
|
1244
1277
|
function(e, n) {
|
|
1245
1278
|
const {
|
|
1246
1279
|
children: o,
|
|
1247
1280
|
isOpen: r,
|
|
1248
1281
|
setIsOpen: i,
|
|
1249
1282
|
afterClose: a,
|
|
1250
|
-
mountingPointRef:
|
|
1283
|
+
mountingPointRef: c,
|
|
1251
1284
|
...u
|
|
1252
|
-
} = e, h = rt(
|
|
1285
|
+
} = e, h = rt(fe), [s, m] = at(
|
|
1253
1286
|
h.current
|
|
1254
1287
|
);
|
|
1255
1288
|
Mt(
|
|
1256
1289
|
n,
|
|
1257
|
-
() =>
|
|
1258
|
-
[
|
|
1290
|
+
() => s,
|
|
1291
|
+
[s]
|
|
1259
1292
|
);
|
|
1260
1293
|
const C = z(() => {
|
|
1261
1294
|
i(!1), a == null || a();
|
|
1262
1295
|
}, [a]);
|
|
1263
1296
|
q(() => {
|
|
1264
|
-
r ?
|
|
1297
|
+
r ? s.open() : s.close();
|
|
1265
1298
|
}, [r]);
|
|
1266
1299
|
const l = rt(null);
|
|
1267
1300
|
return q(
|
|
1268
1301
|
function() {
|
|
1269
1302
|
var w;
|
|
1270
|
-
if (
|
|
1303
|
+
if (c && !c.current)
|
|
1271
1304
|
return;
|
|
1272
|
-
const
|
|
1273
|
-
if (!
|
|
1305
|
+
const f = Ft((w = e.mountingPointRef) == null ? void 0 : w.current) ? e.mountingPointRef.current : window.document.body;
|
|
1306
|
+
if (!f || s.getIsMounted())
|
|
1274
1307
|
return;
|
|
1275
1308
|
const S = me({
|
|
1276
1309
|
content: "",
|
|
1277
1310
|
...u,
|
|
1278
1311
|
afterClose: C
|
|
1279
1312
|
});
|
|
1280
|
-
return S.mount(
|
|
1281
|
-
|
|
1313
|
+
return S.mount(f), l.current = S.elements.bottomSheetContentWrapper ?? null, h.current = S, m(S), () => {
|
|
1314
|
+
s.unmount();
|
|
1282
1315
|
};
|
|
1283
1316
|
},
|
|
1284
1317
|
[e.mountingPointRef, u, C]
|
|
@@ -1293,80 +1326,80 @@ const be = Dt(), Se = Bt(
|
|
|
1293
1326
|
return () => {
|
|
1294
1327
|
h.current.unmount();
|
|
1295
1328
|
};
|
|
1296
|
-
}, []), l.current ?
|
|
1329
|
+
}, []), l.current ? Pt(
|
|
1297
1330
|
e.children,
|
|
1298
1331
|
l.current
|
|
1299
1332
|
) : null;
|
|
1300
1333
|
}
|
|
1301
|
-
),
|
|
1334
|
+
), be = Bt();
|
|
1302
1335
|
function ye(t = {}) {
|
|
1303
|
-
const e = rt(
|
|
1336
|
+
const e = rt(be), [n, o] = at(!1), [r, i] = at(e.current);
|
|
1304
1337
|
q(() => {
|
|
1305
1338
|
i(e.current);
|
|
1306
1339
|
}, [e.current]);
|
|
1307
1340
|
const {
|
|
1308
1341
|
beforeOpen: a,
|
|
1309
|
-
afterOpen:
|
|
1342
|
+
afterOpen: c,
|
|
1310
1343
|
beforeClose: u,
|
|
1311
1344
|
afterClose: h,
|
|
1312
|
-
onDragStart:
|
|
1345
|
+
onDragStart: s,
|
|
1313
1346
|
onDragMove: m,
|
|
1314
1347
|
onDragEnd: C,
|
|
1315
1348
|
...l
|
|
1316
1349
|
} = t, E = () => {
|
|
1317
1350
|
a == null || a();
|
|
1318
|
-
},
|
|
1319
|
-
|
|
1351
|
+
}, f = () => {
|
|
1352
|
+
c == null || c(), o(!0);
|
|
1320
1353
|
}, S = () => {
|
|
1321
1354
|
u == null || u();
|
|
1322
1355
|
}, w = () => {
|
|
1323
1356
|
h == null || h(), o(!1);
|
|
1324
|
-
},
|
|
1325
|
-
|
|
1326
|
-
},
|
|
1357
|
+
}, x = () => {
|
|
1358
|
+
s == null || s();
|
|
1359
|
+
}, T = (y, v) => {
|
|
1327
1360
|
m == null || m(y, v);
|
|
1328
|
-
},
|
|
1361
|
+
}, Y = () => {
|
|
1329
1362
|
C == null || C();
|
|
1330
|
-
},
|
|
1363
|
+
}, U = Yt(() => ({
|
|
1331
1364
|
ref: e,
|
|
1332
1365
|
isOpen: n,
|
|
1333
1366
|
setIsOpen: o,
|
|
1334
1367
|
beforeOpen: E,
|
|
1335
|
-
afterOpen:
|
|
1368
|
+
afterOpen: f,
|
|
1336
1369
|
beforeClose: S,
|
|
1337
1370
|
afterClose: w,
|
|
1338
|
-
onDragStart:
|
|
1339
|
-
onDragMove:
|
|
1340
|
-
onDragEnd:
|
|
1371
|
+
onDragStart: x,
|
|
1372
|
+
onDragMove: T,
|
|
1373
|
+
onDragEnd: Y,
|
|
1341
1374
|
...l
|
|
1342
|
-
}), [e.current, n, o, t]),
|
|
1375
|
+
}), [e.current, n, o, t]), $ = z(() => {
|
|
1343
1376
|
o(!0);
|
|
1344
|
-
}, [o]),
|
|
1377
|
+
}, [o]), P = z(() => {
|
|
1345
1378
|
o(!0);
|
|
1346
|
-
}, [o]),
|
|
1379
|
+
}, [o]), F = z(
|
|
1347
1380
|
(...y) => {
|
|
1348
1381
|
r.moveTo(...y);
|
|
1349
1382
|
},
|
|
1350
1383
|
[r]
|
|
1351
|
-
),
|
|
1384
|
+
), H = z(
|
|
1352
1385
|
(...y) => {
|
|
1353
1386
|
r.snapTo(...y);
|
|
1354
1387
|
},
|
|
1355
1388
|
[r]
|
|
1356
1389
|
);
|
|
1357
1390
|
return {
|
|
1358
|
-
props:
|
|
1391
|
+
props: U,
|
|
1359
1392
|
instance: r,
|
|
1360
1393
|
isOpen: n,
|
|
1361
1394
|
setIsOpen: o,
|
|
1362
|
-
open:
|
|
1363
|
-
close:
|
|
1364
|
-
moveTo:
|
|
1365
|
-
snapTo:
|
|
1395
|
+
open: $,
|
|
1396
|
+
close: P,
|
|
1397
|
+
moveTo: F,
|
|
1398
|
+
snapTo: H
|
|
1366
1399
|
};
|
|
1367
1400
|
}
|
|
1368
1401
|
export {
|
|
1369
|
-
|
|
1370
|
-
|
|
1402
|
+
ve as BottomSheet,
|
|
1403
|
+
Bt as createPlaceholderBottomSheet,
|
|
1371
1404
|
ye as useBottomSheet
|
|
1372
1405
|
};
|