@plainsheet/react 0.4.4 → 0.4.5
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,4 +1,4 @@
|
|
|
1
|
-
import { forwardRef as
|
|
1
|
+
import { forwardRef as At, useRef as ot, useState as rt, useImperativeHandle as Bt, useCallback as Pt, useEffect as _, useMemo as Mt } from "react";
|
|
2
2
|
import { createPortal as Yt } from "react-dom";
|
|
3
3
|
function It(t) {
|
|
4
4
|
return t != null;
|
|
@@ -14,7 +14,7 @@ function It(t) {
|
|
|
14
14
|
}
|
|
15
15
|
})();
|
|
16
16
|
var Rt = Object.defineProperty, Nt = (t, e, n) => e in t ? Rt(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n, V = (t, e, n) => Nt(t, typeof e != "symbol" ? e + "" : e, n);
|
|
17
|
-
function
|
|
17
|
+
function x(t) {
|
|
18
18
|
return typeof t == "string";
|
|
19
19
|
}
|
|
20
20
|
function Ft(t, e) {
|
|
@@ -27,10 +27,10 @@ function it(t, e) {
|
|
|
27
27
|
t.classList.remove(et(e));
|
|
28
28
|
}
|
|
29
29
|
function $(t, e, n) {
|
|
30
|
-
|
|
30
|
+
x(n) && (x(e) && it(t, e), X(t, n));
|
|
31
31
|
}
|
|
32
32
|
function et(t) {
|
|
33
|
-
return
|
|
33
|
+
return x(t) ? t.trim().replace(/\./g, "") : "";
|
|
34
34
|
}
|
|
35
35
|
function R(t) {
|
|
36
36
|
return t.map((e) => et(e)).filter(Boolean).join(" ");
|
|
@@ -38,7 +38,7 @@ function R(t) {
|
|
|
38
38
|
function Wt(t) {
|
|
39
39
|
return t.map((e) => e == null ? void 0 : e.trim()).filter(Boolean).map((e) => `.${e}`).join(" ");
|
|
40
40
|
}
|
|
41
|
-
const dt = "open",
|
|
41
|
+
const dt = "open", pt = "hidden";
|
|
42
42
|
function nt(t, e) {
|
|
43
43
|
const n = e;
|
|
44
44
|
if (Array.isArray(t)) {
|
|
@@ -50,12 +50,12 @@ function nt(t, e) {
|
|
|
50
50
|
J(t, n), t.setAttribute("aria-modal", n ? "true" : "false");
|
|
51
51
|
}
|
|
52
52
|
function J(t, e) {
|
|
53
|
-
e ? (X(t, dt), it(t,
|
|
53
|
+
e ? (X(t, dt), it(t, pt)) : (X(t, pt), it(t, dt));
|
|
54
54
|
}
|
|
55
55
|
function Ct(t) {
|
|
56
56
|
return t instanceof HTMLElement;
|
|
57
57
|
}
|
|
58
|
-
function
|
|
58
|
+
function D(t) {
|
|
59
59
|
return typeof t == "number" && !Number.isNaN(t);
|
|
60
60
|
}
|
|
61
61
|
function Ut(t) {
|
|
@@ -64,7 +64,7 @@ function Ut(t) {
|
|
|
64
64
|
function jt(t) {
|
|
65
65
|
if (!Ct(t) || t.offsetParent === null || "disabled" in t && t.disabled)
|
|
66
66
|
return !1;
|
|
67
|
-
const e = t.getAttribute("tabindex"), n =
|
|
67
|
+
const e = t.getAttribute("tabindex"), n = D(e) ? parseInt(e, 10) : -1, o = [
|
|
68
68
|
"INPUT",
|
|
69
69
|
"BUTTON",
|
|
70
70
|
"SELECT",
|
|
@@ -72,24 +72,24 @@ function jt(t) {
|
|
|
72
72
|
"A",
|
|
73
73
|
"AREA",
|
|
74
74
|
"IFRAME"
|
|
75
|
-
].includes(t.tagName),
|
|
76
|
-
return o ||
|
|
75
|
+
].includes(t.tagName), r = t instanceof HTMLAnchorElement && t.href !== "" || t instanceof HTMLAreaElement && t.href !== "";
|
|
76
|
+
return o || r || n > -1;
|
|
77
77
|
}
|
|
78
|
-
var
|
|
79
|
-
function
|
|
78
|
+
var E = /* @__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))(E || {}), at = /* @__PURE__ */ ((t) => (t.Button = "pbs-button-reset", t.Dialog = "pbs-dialog-reset", t))(at || {}), K = /* @__PURE__ */ ((t) => (t.Hidden = "hidden", t))(K || {});
|
|
79
|
+
function P(t, e, n) {
|
|
80
80
|
const o = document.createElement(t);
|
|
81
|
-
return e.split(" ").forEach((
|
|
82
|
-
X(o,
|
|
83
|
-
}),
|
|
81
|
+
return e.split(" ").forEach((r) => {
|
|
82
|
+
X(o, r);
|
|
83
|
+
}), x(n) && o.setAttribute("data-testid", n), o;
|
|
84
84
|
}
|
|
85
85
|
Wt([
|
|
86
|
-
|
|
87
|
-
|
|
86
|
+
E.Root,
|
|
87
|
+
E.ContentWrapper
|
|
88
88
|
]);
|
|
89
|
-
function
|
|
89
|
+
function ht(t, e, n, o) {
|
|
90
90
|
switch (o) {
|
|
91
91
|
case "content-height":
|
|
92
|
-
return e >= t ?
|
|
92
|
+
return e >= t ? Et(t, e, n) : 0;
|
|
93
93
|
case "middle":
|
|
94
94
|
return -(t / 2 - e);
|
|
95
95
|
case "top":
|
|
@@ -106,7 +106,7 @@ function yt(t, e) {
|
|
|
106
106
|
stayedSame: e === t
|
|
107
107
|
};
|
|
108
108
|
}
|
|
109
|
-
function
|
|
109
|
+
function wt(t, e) {
|
|
110
110
|
return e < t ? -(t - e) : e - t;
|
|
111
111
|
}
|
|
112
112
|
function Q(t, e) {
|
|
@@ -122,12 +122,12 @@ function $t(t, e) {
|
|
|
122
122
|
}
|
|
123
123
|
function mt(t, e, n) {
|
|
124
124
|
const o = t === "above";
|
|
125
|
-
return n.filter((
|
|
126
|
-
const
|
|
127
|
-
return o ? e.visibleHeight <
|
|
125
|
+
return n.filter((r) => {
|
|
126
|
+
const a = r * e.viewportHeight;
|
|
127
|
+
return o ? e.visibleHeight < a : e.visibleHeight > a;
|
|
128
128
|
});
|
|
129
129
|
}
|
|
130
|
-
function
|
|
130
|
+
function Et(t, e, n) {
|
|
131
131
|
return -(t - e) + n;
|
|
132
132
|
}
|
|
133
133
|
function ft(t) {
|
|
@@ -140,8 +140,8 @@ function Tt(t) {
|
|
|
140
140
|
const e = /(?<type>\w+)\((?<values>[^)]+)\)/g, n = [];
|
|
141
141
|
let o;
|
|
142
142
|
for (; (o = e.exec(t)) !== null; ) {
|
|
143
|
-
const
|
|
144
|
-
n.push({ type:
|
|
143
|
+
const r = o[1], a = o[2].split(",").map((i) => i.trim());
|
|
144
|
+
n.push({ type: r, values: a });
|
|
145
145
|
}
|
|
146
146
|
return n;
|
|
147
147
|
}
|
|
@@ -168,14 +168,14 @@ function B(t) {
|
|
|
168
168
|
function tt(t, { x: e, y: n }) {
|
|
169
169
|
const {
|
|
170
170
|
transform: o,
|
|
171
|
-
transformValues:
|
|
172
|
-
} = Gt(t),
|
|
173
|
-
|
|
171
|
+
transformValues: r
|
|
172
|
+
} = Gt(t), a = Ht(
|
|
173
|
+
r,
|
|
174
174
|
st
|
|
175
175
|
);
|
|
176
|
-
if (
|
|
177
|
-
const
|
|
178
|
-
t.style.transform = `translate(${e ??
|
|
176
|
+
if (a) {
|
|
177
|
+
const i = kt(a);
|
|
178
|
+
t.style.transform = `translate(${e ?? i.x ?? 0}px,${n ?? i.y ?? 0}px)`;
|
|
179
179
|
return;
|
|
180
180
|
}
|
|
181
181
|
if (o) {
|
|
@@ -205,48 +205,48 @@ function gt(t, {
|
|
|
205
205
|
return ct(n) && t >= n ? n : ct(e) && t <= e ? e : t;
|
|
206
206
|
}
|
|
207
207
|
const _t = (t, e, n) => {
|
|
208
|
-
e instanceof HTMLElement && !Ft(e,
|
|
209
|
-
}, Xt = (t, e, n, o) => (
|
|
210
|
-
o.startY = t.getCoordinates(
|
|
211
|
-
}, zt = (t, e, n, o,
|
|
208
|
+
e instanceof HTMLElement && !Ft(e, E.Handle) && n.scrollTop >= 1 || (t.isDragging = !0);
|
|
209
|
+
}, Xt = (t, e, n, o) => (r) => {
|
|
210
|
+
o.startY = t.getCoordinates(r).y, o.containerStartTranslate = B(e), n.onDragStart();
|
|
211
|
+
}, zt = (t, e, n, o, r) => (a) => {
|
|
212
212
|
qt(
|
|
213
|
-
|
|
213
|
+
a,
|
|
214
214
|
t,
|
|
215
215
|
n,
|
|
216
216
|
o,
|
|
217
|
-
|
|
217
|
+
r,
|
|
218
218
|
e,
|
|
219
219
|
n.marginTop
|
|
220
220
|
);
|
|
221
221
|
};
|
|
222
|
-
function qt(t, e, n, o,
|
|
223
|
-
if (!o.isDragging || !
|
|
222
|
+
function qt(t, e, n, o, r, a, i) {
|
|
223
|
+
if (!o.isDragging || !D(o.startY))
|
|
224
224
|
return;
|
|
225
|
-
const
|
|
226
|
-
if (m >=
|
|
225
|
+
const s = e.getCoordinates(t).y, u = wt(o.startY, s), h = window.innerHeight, c = a.clientHeight, m = c - (o.containerStartTranslate.y + u);
|
|
226
|
+
if (m >= h)
|
|
227
227
|
return;
|
|
228
|
-
const
|
|
229
|
-
if (
|
|
228
|
+
const S = yt(o.startY, s);
|
|
229
|
+
if (S.isUp && !n.expandable && m >= c)
|
|
230
230
|
return;
|
|
231
|
-
|
|
232
|
-
tt(
|
|
233
|
-
y: o.containerStartTranslate.y +
|
|
231
|
+
r.start(() => {
|
|
232
|
+
tt(a, {
|
|
233
|
+
y: o.containerStartTranslate.y + u
|
|
234
234
|
});
|
|
235
235
|
}, 0);
|
|
236
|
-
const l =
|
|
237
|
-
if (
|
|
238
|
-
const
|
|
239
|
-
1 - Z(
|
|
236
|
+
const l = h - i, C = c - o.containerStartTranslate.y;
|
|
237
|
+
if (S.isUp) {
|
|
238
|
+
const b = l - C, v = l - m, y = gt(
|
|
239
|
+
1 - Z(v / b, 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(S, y);
|
|
246
|
+
} else if (S.isDown) {
|
|
247
|
+
const b = gt(
|
|
248
248
|
Z(
|
|
249
|
-
1 - m /
|
|
249
|
+
1 - m / C,
|
|
250
250
|
2
|
|
251
251
|
),
|
|
252
252
|
{
|
|
@@ -254,68 +254,68 @@ function qt(t, e, n, o, i, r, s) {
|
|
|
254
254
|
max: 1
|
|
255
255
|
}
|
|
256
256
|
);
|
|
257
|
-
n.onDragMove(
|
|
257
|
+
n.onDragMove(S, b);
|
|
258
258
|
}
|
|
259
259
|
}
|
|
260
|
-
const Vt = (t, e, n, o,
|
|
261
|
-
if (!o.isDragging || (o.isDragging = !1, !
|
|
260
|
+
const Vt = (t, e, n, o, r, a, i) => (s) => {
|
|
261
|
+
if (!o.isDragging || (o.isDragging = !1, !D(o.startY)))
|
|
262
262
|
return;
|
|
263
263
|
n.onDragEnd();
|
|
264
|
-
const
|
|
264
|
+
const u = o.startY, h = t.getCoordinates(s).y, c = B(e).y, m = yt(u, h), S = window.innerHeight, l = e.clientHeight;
|
|
265
265
|
if (m.isUp) {
|
|
266
|
-
const
|
|
267
|
-
(
|
|
268
|
-
),
|
|
269
|
-
if (!n.expandable &&
|
|
266
|
+
const C = [...n.snapPoints].sort(
|
|
267
|
+
(y, L) => y - L
|
|
268
|
+
), b = l + -c;
|
|
269
|
+
if (!n.expandable && b >= l)
|
|
270
270
|
return;
|
|
271
|
-
for (const
|
|
272
|
-
const
|
|
273
|
-
if (
|
|
271
|
+
for (const y of C) {
|
|
272
|
+
const L = y * window.innerHeight;
|
|
273
|
+
if (b <= L) {
|
|
274
274
|
const T = Q(
|
|
275
|
-
|
|
276
|
-
|
|
275
|
+
b,
|
|
276
|
+
L
|
|
277
277
|
);
|
|
278
|
-
|
|
278
|
+
i.translateContainer({
|
|
279
279
|
startY: c,
|
|
280
280
|
endY: c - T,
|
|
281
|
-
animationFrame:
|
|
281
|
+
animationFrame: r,
|
|
282
282
|
bottomSheetContainer: e
|
|
283
283
|
});
|
|
284
284
|
return;
|
|
285
285
|
}
|
|
286
286
|
}
|
|
287
|
-
const
|
|
288
|
-
|
|
287
|
+
const v = Et(
|
|
288
|
+
S,
|
|
289
289
|
l,
|
|
290
290
|
n.marginTop
|
|
291
291
|
);
|
|
292
|
-
|
|
292
|
+
i.translateContainer({
|
|
293
293
|
startY: c,
|
|
294
|
-
endY:
|
|
295
|
-
animationFrame:
|
|
294
|
+
endY: v,
|
|
295
|
+
animationFrame: r,
|
|
296
296
|
bottomSheetContainer: e
|
|
297
297
|
});
|
|
298
298
|
} else if (m.isDown) {
|
|
299
|
-
const
|
|
300
|
-
(
|
|
299
|
+
const C = [...n.snapPoints].sort(
|
|
300
|
+
(b, v) => v - b
|
|
301
301
|
);
|
|
302
|
-
for (const
|
|
303
|
-
const
|
|
304
|
-
if (
|
|
305
|
-
const
|
|
306
|
-
|
|
307
|
-
|
|
302
|
+
for (const b of C) {
|
|
303
|
+
const v = b * window.innerHeight, y = l + -c;
|
|
304
|
+
if (y >= v) {
|
|
305
|
+
const L = Q(
|
|
306
|
+
y,
|
|
307
|
+
v
|
|
308
308
|
);
|
|
309
|
-
|
|
309
|
+
i.translateContainer({
|
|
310
310
|
startY: c,
|
|
311
|
-
endY: c +
|
|
312
|
-
animationFrame:
|
|
311
|
+
endY: c + L,
|
|
312
|
+
animationFrame: r,
|
|
313
313
|
bottomSheetContainer: e
|
|
314
314
|
});
|
|
315
315
|
return;
|
|
316
316
|
}
|
|
317
317
|
}
|
|
318
|
-
|
|
318
|
+
a();
|
|
319
319
|
}
|
|
320
320
|
};
|
|
321
321
|
var W = /* @__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))(W || {});
|
|
@@ -344,50 +344,50 @@ class G {
|
|
|
344
344
|
onStart: e,
|
|
345
345
|
onStartOptions: n = Kt,
|
|
346
346
|
onMove: o,
|
|
347
|
-
onEnd:
|
|
347
|
+
onEnd: r
|
|
348
348
|
}) {
|
|
349
|
-
this.addTouchEventListeners({ onStart: e, onStartOptions: n, onMove: o, onEnd:
|
|
349
|
+
this.addTouchEventListeners({ onStart: e, onStartOptions: n, onMove: o, onEnd: r }), this.addMouseEventListeners({ onStart: e, onStartOptions: n, onMove: o, onEnd: r });
|
|
350
350
|
}
|
|
351
351
|
addTouchEventListeners({
|
|
352
352
|
onStart: e,
|
|
353
353
|
onStartOptions: n,
|
|
354
354
|
onMove: o,
|
|
355
|
-
onEnd:
|
|
355
|
+
onEnd: r
|
|
356
356
|
}) {
|
|
357
357
|
e && this.currentTarget.addEventListener(
|
|
358
358
|
"touchstart",
|
|
359
|
-
(
|
|
359
|
+
(a) => {
|
|
360
360
|
if (n.eventPhase === W.All) {
|
|
361
|
-
e(
|
|
361
|
+
e(a);
|
|
362
362
|
return;
|
|
363
363
|
}
|
|
364
|
-
bt(
|
|
364
|
+
bt(a.eventPhase) === n.eventPhase && e(a);
|
|
365
365
|
},
|
|
366
366
|
{
|
|
367
367
|
passive: !0
|
|
368
368
|
}
|
|
369
|
-
), o && this.currentTarget.addEventListener("touchmove", o),
|
|
369
|
+
), o && this.currentTarget.addEventListener("touchmove", o), r && this.currentTarget.addEventListener("touchend", r);
|
|
370
370
|
}
|
|
371
371
|
addMouseEventListeners({
|
|
372
372
|
onStart: e,
|
|
373
373
|
onStartOptions: n,
|
|
374
374
|
onMove: o,
|
|
375
|
-
onEnd:
|
|
375
|
+
onEnd: r
|
|
376
376
|
}) {
|
|
377
377
|
e && this.currentTarget.addEventListener(
|
|
378
378
|
"mousedown",
|
|
379
|
-
(
|
|
379
|
+
(a) => {
|
|
380
380
|
if (n.eventPhase === W.All) {
|
|
381
|
-
e(
|
|
381
|
+
e(a);
|
|
382
382
|
return;
|
|
383
383
|
}
|
|
384
|
-
bt(
|
|
384
|
+
bt(a.eventPhase) === n.eventPhase && e(a);
|
|
385
385
|
},
|
|
386
386
|
{
|
|
387
387
|
passive: !0
|
|
388
388
|
}
|
|
389
|
-
), o && this.currentTarget.addEventListener("mousemove", o),
|
|
390
|
-
|
|
389
|
+
), o && this.currentTarget.addEventListener("mousemove", o), r && this.currentTarget.addEventListener("mouseup", (a) => {
|
|
390
|
+
r(a);
|
|
391
391
|
});
|
|
392
392
|
}
|
|
393
393
|
removeEventListeners({
|
|
@@ -437,79 +437,79 @@ function Jt(t, e) {
|
|
|
437
437
|
Zt(n), n.bottomSheetContainer.style.width = t.width;
|
|
438
438
|
const o = document.createElement("div");
|
|
439
439
|
o.innerHTML = t.content ?? "";
|
|
440
|
-
const
|
|
441
|
-
n.bottomSheetContainer.style.maxHeight = `${
|
|
442
|
-
const
|
|
440
|
+
const r = window.innerHeight;
|
|
441
|
+
n.bottomSheetContainer.style.maxHeight = `${r}px`, n.bottomSheetContentWrapper.appendChild(o);
|
|
442
|
+
const a = te({
|
|
443
443
|
bottomSheetElements: n,
|
|
444
444
|
bottomSheetProps: t,
|
|
445
445
|
options: e
|
|
446
446
|
});
|
|
447
|
-
return { elements: n, eventHandlers:
|
|
447
|
+
return { elements: n, eventHandlers: a };
|
|
448
448
|
}
|
|
449
449
|
function Qt(t) {
|
|
450
|
-
const e =
|
|
450
|
+
const e = P(
|
|
451
451
|
"dialog",
|
|
452
452
|
R([
|
|
453
|
-
|
|
453
|
+
E.Root,
|
|
454
454
|
at.Dialog,
|
|
455
455
|
t.rootClass
|
|
456
456
|
]),
|
|
457
|
-
|
|
457
|
+
E.Root
|
|
458
458
|
);
|
|
459
459
|
e.ariaLabel = t.ariaLabel;
|
|
460
|
-
const n =
|
|
460
|
+
const n = P(
|
|
461
461
|
"section",
|
|
462
|
-
R([
|
|
463
|
-
|
|
462
|
+
R([E.Container, t.containerClass]),
|
|
463
|
+
E.Container
|
|
464
464
|
);
|
|
465
465
|
t.containerBorderRadius && (n.style.borderRadius = Lt(
|
|
466
466
|
t.containerBorderRadius
|
|
467
467
|
));
|
|
468
|
-
const o =
|
|
468
|
+
const o = P(
|
|
469
469
|
"div",
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
),
|
|
470
|
+
E.GapFiller,
|
|
471
|
+
E.GapFiller
|
|
472
|
+
), r = P(
|
|
473
473
|
"button",
|
|
474
474
|
R([
|
|
475
|
-
|
|
475
|
+
E.Handle,
|
|
476
476
|
at.Button,
|
|
477
477
|
t.shouldShowHandle ? null : K.Hidden,
|
|
478
478
|
t.handleClass
|
|
479
479
|
]),
|
|
480
|
-
|
|
480
|
+
E.Handle
|
|
481
481
|
);
|
|
482
|
-
|
|
483
|
-
const
|
|
482
|
+
r.setAttribute("type", "button"), r.ariaLabel = "bottom sheet close button";
|
|
483
|
+
const a = P(
|
|
484
484
|
"span",
|
|
485
485
|
R([
|
|
486
|
-
|
|
486
|
+
E.HandleBar,
|
|
487
487
|
t.shouldShowHandle ? null : K.Hidden
|
|
488
488
|
]),
|
|
489
|
-
|
|
490
|
-
),
|
|
489
|
+
E.HandleBar
|
|
490
|
+
), i = P(
|
|
491
491
|
"article",
|
|
492
492
|
R([
|
|
493
|
-
|
|
493
|
+
E.ContentWrapper,
|
|
494
494
|
t.contentWrapperClass
|
|
495
495
|
]),
|
|
496
|
-
|
|
497
|
-
),
|
|
496
|
+
E.ContentWrapper
|
|
497
|
+
), s = P(
|
|
498
498
|
"div",
|
|
499
499
|
R([
|
|
500
|
-
|
|
500
|
+
E.Backdrop,
|
|
501
501
|
t.backdropClass,
|
|
502
502
|
K.Hidden
|
|
503
503
|
]),
|
|
504
|
-
|
|
504
|
+
E.Backdrop
|
|
505
505
|
);
|
|
506
|
-
return t.backdropColor && (
|
|
506
|
+
return t.backdropColor && (s.style.backgroundColor = t.backdropColor), t.backDropTransition && (s.style.transition = t.backDropTransition), {
|
|
507
507
|
bottomSheetRoot: e,
|
|
508
|
-
bottomSheetBackdrop:
|
|
508
|
+
bottomSheetBackdrop: s,
|
|
509
509
|
bottomSheetContainer: n,
|
|
510
|
-
bottomSheetHandle:
|
|
511
|
-
bottomSheetHandleBar:
|
|
512
|
-
bottomSheetContentWrapper:
|
|
510
|
+
bottomSheetHandle: r,
|
|
511
|
+
bottomSheetHandleBar: a,
|
|
512
|
+
bottomSheetContentWrapper: i,
|
|
513
513
|
bottomSheetContainerGapFiller: o
|
|
514
514
|
};
|
|
515
515
|
}
|
|
@@ -518,10 +518,10 @@ function Zt({
|
|
|
518
518
|
bottomSheetContainer: e,
|
|
519
519
|
bottomSheetHandle: n,
|
|
520
520
|
bottomSheetHandleBar: o,
|
|
521
|
-
bottomSheetContentWrapper:
|
|
522
|
-
bottomSheetContainerGapFiller:
|
|
521
|
+
bottomSheetContentWrapper: r,
|
|
522
|
+
bottomSheetContainerGapFiller: a
|
|
523
523
|
}) {
|
|
524
|
-
t.appendChild(e), n.appendChild(o), e.appendChild(n), e.appendChild(
|
|
524
|
+
t.appendChild(e), n.appendChild(o), e.appendChild(n), e.appendChild(r), e.appendChild(a);
|
|
525
525
|
}
|
|
526
526
|
function te({
|
|
527
527
|
bottomSheetElements: t,
|
|
@@ -530,111 +530,112 @@ function te({
|
|
|
530
530
|
}) {
|
|
531
531
|
const {
|
|
532
532
|
bottomSheetRoot: o,
|
|
533
|
-
bottomSheetContainer:
|
|
534
|
-
bottomSheetHandle:
|
|
535
|
-
bottomSheetContainerGapFiller:
|
|
536
|
-
bottomSheetContentWrapper:
|
|
537
|
-
bottomSheetBackdrop:
|
|
538
|
-
} = t, { animationFrame:
|
|
539
|
-
a
|
|
540
|
-
), C = new G(
|
|
533
|
+
bottomSheetContainer: r,
|
|
534
|
+
bottomSheetHandle: a,
|
|
535
|
+
bottomSheetContainerGapFiller: i,
|
|
536
|
+
bottomSheetContentWrapper: s,
|
|
537
|
+
bottomSheetBackdrop: u
|
|
538
|
+
} = t, { animationFrame: h } = n, c = new G(a), m = new G(
|
|
541
539
|
s
|
|
540
|
+
), S = new G(
|
|
541
|
+
i
|
|
542
542
|
), l = e.dragTriggers.reduce(
|
|
543
|
-
(
|
|
544
|
-
const
|
|
545
|
-
if (!
|
|
546
|
-
return
|
|
547
|
-
const
|
|
548
|
-
return [...
|
|
543
|
+
(k, O) => {
|
|
544
|
+
const w = o.querySelectorAll(O);
|
|
545
|
+
if (!w.length)
|
|
546
|
+
return k;
|
|
547
|
+
const p = Array.from(w).map((d) => d instanceof HTMLElement ? new G(d) : null).filter((d) => !!d);
|
|
548
|
+
return [...k, ...p];
|
|
549
549
|
},
|
|
550
550
|
[]
|
|
551
|
-
),
|
|
551
|
+
), C = new G(
|
|
552
552
|
window
|
|
553
|
-
),
|
|
554
|
-
|
|
555
|
-
|
|
553
|
+
), b = Xt(
|
|
554
|
+
C,
|
|
555
|
+
r,
|
|
556
556
|
e,
|
|
557
557
|
n.draggingState
|
|
558
|
-
),
|
|
559
|
-
|
|
560
|
-
|
|
558
|
+
), v = zt(
|
|
559
|
+
C,
|
|
560
|
+
r,
|
|
561
561
|
e,
|
|
562
562
|
n.draggingState,
|
|
563
|
-
|
|
564
|
-
),
|
|
565
|
-
|
|
566
|
-
|
|
563
|
+
h
|
|
564
|
+
), y = Vt(
|
|
565
|
+
C,
|
|
566
|
+
r,
|
|
567
567
|
e,
|
|
568
568
|
n.draggingState,
|
|
569
|
-
|
|
569
|
+
h,
|
|
570
570
|
n.onClose,
|
|
571
571
|
n.bottomSheetState
|
|
572
572
|
);
|
|
573
|
-
function k
|
|
574
|
-
|
|
573
|
+
function L(k) {
|
|
574
|
+
k.target instanceof Element && !o.contains(k.target) && n.onClose();
|
|
575
575
|
}
|
|
576
|
-
function T(
|
|
576
|
+
function T(k) {
|
|
577
577
|
_t(
|
|
578
578
|
n.draggingState,
|
|
579
|
-
|
|
579
|
+
k.target,
|
|
580
580
|
t.bottomSheetContentWrapper
|
|
581
581
|
);
|
|
582
582
|
}
|
|
583
|
-
function
|
|
584
|
-
|
|
583
|
+
function M(k) {
|
|
584
|
+
const O = k ?? e;
|
|
585
|
+
O.draggable && (c.addEventListeners({
|
|
585
586
|
onStart: T
|
|
586
|
-
}), l.forEach((
|
|
587
|
-
|
|
587
|
+
}), l.forEach((w) => {
|
|
588
|
+
w.addEventListeners({
|
|
588
589
|
onStart: T,
|
|
589
590
|
onStartOptions: {
|
|
590
591
|
eventPhase: W.Target
|
|
591
592
|
}
|
|
592
593
|
});
|
|
593
|
-
})),
|
|
594
|
+
})), O.draggable && O.backgroundDraggable && (m.addEventListeners({
|
|
594
595
|
onStart: T,
|
|
595
596
|
onStartOptions: {
|
|
596
597
|
eventPhase: W.Target
|
|
597
598
|
}
|
|
598
|
-
}),
|
|
599
|
+
}), S.addEventListeners({
|
|
599
600
|
onStart: T
|
|
600
|
-
})),
|
|
601
|
-
onStart:
|
|
602
|
-
onMove:
|
|
603
|
-
onEnd:
|
|
604
|
-
}),
|
|
605
|
-
|
|
606
|
-
}),
|
|
607
|
-
if (
|
|
601
|
+
})), O.draggable && C.addEventListeners({
|
|
602
|
+
onStart: b,
|
|
603
|
+
onMove: v,
|
|
604
|
+
onEnd: y
|
|
605
|
+
}), O.draggable && window.document.addEventListener("keyup", (w) => {
|
|
606
|
+
w.key === "Escape" && n.onClose();
|
|
607
|
+
}), a.addEventListener("keyup", (w) => {
|
|
608
|
+
if (w.key === "ArrowUp") {
|
|
608
609
|
n.moveUp();
|
|
609
610
|
return;
|
|
610
611
|
}
|
|
611
|
-
if (
|
|
612
|
+
if (w.key === "ArrowDown") {
|
|
612
613
|
n.moveDown();
|
|
613
614
|
return;
|
|
614
615
|
}
|
|
615
|
-
if (
|
|
616
|
-
const
|
|
616
|
+
if (w.shiftKey && w.key === "Tab") {
|
|
617
|
+
const p = Y(
|
|
617
618
|
t.bottomSheetContentWrapper
|
|
618
619
|
);
|
|
619
|
-
Ut(
|
|
620
|
+
Ut(p);
|
|
620
621
|
}
|
|
621
622
|
});
|
|
622
623
|
}
|
|
623
624
|
function z() {
|
|
624
|
-
e.shouldCloseOnOutsideClick ?
|
|
625
|
+
e.shouldCloseOnOutsideClick ? u.addEventListener("click", L) : u.style.pointerEvents = "none";
|
|
625
626
|
}
|
|
626
627
|
function j() {
|
|
627
|
-
|
|
628
|
+
u.removeEventListener("click", L);
|
|
628
629
|
}
|
|
629
|
-
function Y(
|
|
630
|
-
let
|
|
631
|
-
for (;
|
|
632
|
-
const
|
|
633
|
-
if (jt(
|
|
634
|
-
return
|
|
635
|
-
|
|
636
|
-
...
|
|
637
|
-
...Array.from(
|
|
630
|
+
function Y(k) {
|
|
631
|
+
let O = [...Array.from(k.childNodes).reverse()];
|
|
632
|
+
for (; O.length; ) {
|
|
633
|
+
const w = O.shift();
|
|
634
|
+
if (jt(w))
|
|
635
|
+
return w;
|
|
636
|
+
w && (O = [
|
|
637
|
+
...O,
|
|
638
|
+
...Array.from(w.childNodes).reverse()
|
|
638
639
|
]);
|
|
639
640
|
}
|
|
640
641
|
return null;
|
|
@@ -644,20 +645,20 @@ function te({
|
|
|
644
645
|
onStart: T
|
|
645
646
|
}), m.removeEventListeners({
|
|
646
647
|
onStart: T
|
|
647
|
-
}),
|
|
648
|
+
}), S.removeEventListeners({
|
|
648
649
|
onStart: T
|
|
649
|
-
}), l.forEach((
|
|
650
|
-
|
|
650
|
+
}), l.forEach((k) => {
|
|
651
|
+
k.removeEventListeners({
|
|
651
652
|
onStart: T
|
|
652
653
|
});
|
|
653
|
-
}),
|
|
654
|
-
onStart:
|
|
655
|
-
onMove:
|
|
656
|
-
onEnd:
|
|
654
|
+
}), C.removeEventListeners({
|
|
655
|
+
onStart: b,
|
|
656
|
+
onMove: v,
|
|
657
|
+
onEnd: y
|
|
657
658
|
});
|
|
658
659
|
}
|
|
659
660
|
return {
|
|
660
|
-
attachEventListeners:
|
|
661
|
+
attachEventListeners: M,
|
|
661
662
|
clearEventListeners: q,
|
|
662
663
|
attacheOnOpenEventListeners: z,
|
|
663
664
|
clearOnOpenEventListeners: j
|
|
@@ -674,15 +675,15 @@ class ee {
|
|
|
674
675
|
*/
|
|
675
676
|
start(e, n, o = !1) {
|
|
676
677
|
this.isInProgress = !0;
|
|
677
|
-
const
|
|
678
|
-
this.startedAt || (this.startedAt =
|
|
679
|
-
const
|
|
680
|
-
e(
|
|
678
|
+
const r = (a) => {
|
|
679
|
+
this.startedAt || (this.startedAt = a);
|
|
680
|
+
const i = a - this.startedAt, s = n === 0 ? 1 : Z(i / n, 2), u = s >= 1 && !o;
|
|
681
|
+
e(s), u ? this.stop() : this.animationId = requestAnimationFrame(r);
|
|
681
682
|
};
|
|
682
|
-
this.animationId = requestAnimationFrame(
|
|
683
|
+
this.animationId = requestAnimationFrame(r);
|
|
683
684
|
}
|
|
684
685
|
stop() {
|
|
685
|
-
this.isInProgress = !1, this.startedAt = null,
|
|
686
|
+
this.isInProgress = !1, this.startedAt = null, D(this.animationId) && cancelAnimationFrame(this.animationId);
|
|
686
687
|
}
|
|
687
688
|
}
|
|
688
689
|
function ne(t) {
|
|
@@ -690,18 +691,18 @@ function ne(t) {
|
|
|
690
691
|
startY: e,
|
|
691
692
|
endY: n,
|
|
692
693
|
bottomSheetContainer: o,
|
|
693
|
-
animationFrame:
|
|
694
|
-
onEnd:
|
|
695
|
-
animationTimingFunction:
|
|
696
|
-
animationDuration:
|
|
697
|
-
} = t,
|
|
698
|
-
|
|
699
|
-
let
|
|
700
|
-
|
|
694
|
+
animationFrame: r,
|
|
695
|
+
onEnd: a,
|
|
696
|
+
animationTimingFunction: i,
|
|
697
|
+
animationDuration: s
|
|
698
|
+
} = t, u = wt(e, n);
|
|
699
|
+
r.stop();
|
|
700
|
+
let h = !1;
|
|
701
|
+
r.start((c) => {
|
|
701
702
|
tt(o, {
|
|
702
|
-
y: e +
|
|
703
|
-
}), !
|
|
704
|
-
},
|
|
703
|
+
y: e + u * i(c)
|
|
704
|
+
}), !h && c >= 1 && (a == null || a(), h = !0);
|
|
705
|
+
}, s);
|
|
705
706
|
}
|
|
706
707
|
const lt = (t, e) => (n) => {
|
|
707
708
|
ne({
|
|
@@ -716,12 +717,12 @@ const lt = (t, e) => (n) => {
|
|
|
716
717
|
CLOSED: "closed"
|
|
717
718
|
};
|
|
718
719
|
function oe(t) {
|
|
719
|
-
return !(!
|
|
720
|
+
return !(!D(t) || t > 1 || t < 0);
|
|
720
721
|
}
|
|
721
722
|
function re(t, e) {
|
|
722
723
|
const n = {
|
|
723
|
-
set(o,
|
|
724
|
-
return e(
|
|
724
|
+
set(o, r, a, i) {
|
|
725
|
+
return e(r, a), Reflect.set(o, r, a, i);
|
|
725
726
|
}
|
|
726
727
|
};
|
|
727
728
|
return new Proxy(t, n);
|
|
@@ -743,28 +744,28 @@ function ae(t) {
|
|
|
743
744
|
return !1;
|
|
744
745
|
}
|
|
745
746
|
function Ot(t) {
|
|
746
|
-
return !!(t instanceof Object && "p1x" in t && "p1y" in t && "p2x" in t && "p2y" in t &&
|
|
747
|
+
return !!(t instanceof Object && "p1x" in t && "p1y" in t && "p2x" in t && "p2y" in t && D(t.p1x) && D(t.p1y) && D(t.p2x) && D(t.p2y));
|
|
747
748
|
}
|
|
748
749
|
function U(t, e, n, o) {
|
|
749
|
-
return function(
|
|
750
|
-
return
|
|
750
|
+
return function(s) {
|
|
751
|
+
return i(r(s));
|
|
751
752
|
};
|
|
752
|
-
function
|
|
753
|
-
let
|
|
754
|
-
if (
|
|
755
|
-
return
|
|
756
|
-
for (;
|
|
757
|
-
if (m =
|
|
753
|
+
function r(s) {
|
|
754
|
+
let u = 0, h = 1, c = s, m;
|
|
755
|
+
if (s === 0 || s === 1)
|
|
756
|
+
return s;
|
|
757
|
+
for (; u < h; ) {
|
|
758
|
+
if (m = a(c), Math.abs(m - s) < 1e-3)
|
|
758
759
|
return c;
|
|
759
|
-
|
|
760
|
+
s > m ? u = c : h = c, c = (h + u) / 2;
|
|
760
761
|
}
|
|
761
762
|
return c;
|
|
762
763
|
}
|
|
763
|
-
function
|
|
764
|
-
return 3 * t *
|
|
764
|
+
function a(s) {
|
|
765
|
+
return 3 * t * s * Math.pow(1 - s, 2) + 3 * n * Math.pow(s, 2) * (1 - s) + Math.pow(s, 3);
|
|
765
766
|
}
|
|
766
|
-
function s
|
|
767
|
-
return 3 * e *
|
|
767
|
+
function i(s) {
|
|
768
|
+
return 3 * e * s * Math.pow(1 - s, 2) + 3 * o * Math.pow(s, 2) * (1 - s) + Math.pow(s, 3);
|
|
768
769
|
}
|
|
769
770
|
}
|
|
770
771
|
const vt = U(0.25, 0.1, 0.25, 1), se = U(0.42, 0, 1, 1), xt = U(0.42, 0, 0.58, 1), ce = U(0.4, 0.1, 0.6, 1), le = U(0.45, 1.5, 0.55, 1);
|
|
@@ -826,13 +827,13 @@ const de = {
|
|
|
826
827
|
draggingAnimationTimings: "ease-in-out",
|
|
827
828
|
draggingAnimationDuration: 180
|
|
828
829
|
};
|
|
829
|
-
function
|
|
830
|
+
function pe(t) {
|
|
830
831
|
const e = {
|
|
831
832
|
...de
|
|
832
833
|
}, n = Object.entries(t).reduce(
|
|
833
|
-
(o,
|
|
834
|
-
const [
|
|
835
|
-
return ct(
|
|
834
|
+
(o, r) => {
|
|
835
|
+
const [a, i] = r;
|
|
836
|
+
return ct(i) && (o[a] = i), o;
|
|
836
837
|
},
|
|
837
838
|
{}
|
|
838
839
|
);
|
|
@@ -843,106 +844,112 @@ function he(t) {
|
|
|
843
844
|
}
|
|
844
845
|
function ut(t) {
|
|
845
846
|
if (Ot(t)) {
|
|
846
|
-
const { p1x: e, p1y: n, p2x: o, p2y:
|
|
847
|
-
return U(e, n, o,
|
|
847
|
+
const { p1x: e, p1y: n, p2x: o, p2y: r } = t;
|
|
848
|
+
return U(e, n, o, r);
|
|
848
849
|
}
|
|
849
850
|
return ae(t) ? ue(t) : xt;
|
|
850
851
|
}
|
|
851
|
-
function
|
|
852
|
-
function
|
|
853
|
-
switch (
|
|
852
|
+
function he(t, e, n, o) {
|
|
853
|
+
function r(a, i) {
|
|
854
|
+
switch (a) {
|
|
854
855
|
case "content":
|
|
855
|
-
|
|
856
|
+
x(i) && (t.bottomSheetContentWrapper.innerHTML = i);
|
|
856
857
|
break;
|
|
857
858
|
case "width":
|
|
858
|
-
|
|
859
|
+
x(i) && (t.bottomSheetContainer.style.width = i);
|
|
859
860
|
break;
|
|
860
861
|
case "shouldShowHandle":
|
|
861
|
-
St(
|
|
862
|
+
St(i) || J(t.bottomSheetHandle, !1);
|
|
862
863
|
break;
|
|
863
864
|
case "shouldShowBackdrop":
|
|
864
|
-
St(
|
|
865
|
+
St(i) || J(t.bottomSheetBackdrop, !1);
|
|
865
866
|
break;
|
|
866
867
|
case "containerBorderRadius":
|
|
867
|
-
|
|
868
|
+
x(i) && (t.bottomSheetContainer.style.borderRadius = Lt(i));
|
|
868
869
|
break;
|
|
869
870
|
case "backdropColor":
|
|
870
|
-
|
|
871
|
+
x(i) && (t.bottomSheetBackdrop.style.backgroundColor = i);
|
|
871
872
|
break;
|
|
872
873
|
case "backDropTransition":
|
|
873
|
-
|
|
874
|
+
x(i) && (t.bottomSheetBackdrop.style.transition = i);
|
|
874
875
|
break;
|
|
875
876
|
case "rootClass":
|
|
876
|
-
if (!
|
|
877
|
+
if (!x(i))
|
|
877
878
|
return;
|
|
878
879
|
$(
|
|
879
880
|
t.bottomSheetRoot,
|
|
880
881
|
n.rootClass,
|
|
881
|
-
|
|
882
|
+
i
|
|
882
883
|
);
|
|
883
884
|
break;
|
|
884
885
|
case "containerClass":
|
|
885
|
-
if (!
|
|
886
|
+
if (!x(i))
|
|
886
887
|
return;
|
|
887
888
|
$(
|
|
888
889
|
t.bottomSheetContainer,
|
|
889
890
|
n.containerClass,
|
|
890
|
-
|
|
891
|
+
i
|
|
891
892
|
);
|
|
892
893
|
break;
|
|
893
894
|
case "handleClass":
|
|
894
|
-
if (!
|
|
895
|
+
if (!x(i))
|
|
895
896
|
return;
|
|
896
897
|
$(
|
|
897
898
|
t.bottomSheetHandle,
|
|
898
899
|
n.handleClass,
|
|
899
|
-
|
|
900
|
+
i
|
|
900
901
|
);
|
|
901
902
|
break;
|
|
902
903
|
case "contentWrapperClass":
|
|
903
|
-
if (!
|
|
904
|
+
if (!x(i))
|
|
904
905
|
return;
|
|
905
906
|
$(
|
|
906
907
|
t.bottomSheetContentWrapper,
|
|
907
908
|
n.contentWrapperClass,
|
|
908
|
-
|
|
909
|
+
i
|
|
909
910
|
);
|
|
910
911
|
break;
|
|
911
912
|
case "backdropClass":
|
|
912
|
-
if (!
|
|
913
|
+
if (!x(i))
|
|
913
914
|
return;
|
|
914
915
|
$(
|
|
915
916
|
t.bottomSheetBackdrop,
|
|
916
917
|
n.backdropClass,
|
|
917
|
-
|
|
918
|
+
i
|
|
918
919
|
);
|
|
919
920
|
break;
|
|
921
|
+
case "expandable":
|
|
922
|
+
o.clearEventListeners(), o.attachEventListeners(n);
|
|
923
|
+
break;
|
|
924
|
+
case "draggable":
|
|
925
|
+
o.clearEventListeners(), o.attachEventListeners(n);
|
|
926
|
+
break;
|
|
920
927
|
case "draggingAnimationTimings":
|
|
921
|
-
if (Ot(
|
|
922
|
-
const s = ut(
|
|
928
|
+
if (Ot(i)) {
|
|
929
|
+
const s = ut(i), u = lt(
|
|
923
930
|
s,
|
|
924
931
|
n.draggingAnimationDuration
|
|
925
932
|
);
|
|
926
|
-
e.translateContainer =
|
|
933
|
+
e.translateContainer = u;
|
|
927
934
|
}
|
|
928
935
|
break;
|
|
929
936
|
case "draggingAnimationDuration":
|
|
930
|
-
if (
|
|
937
|
+
if (D(i)) {
|
|
931
938
|
const s = ut(
|
|
932
939
|
n.draggingAnimationTimings
|
|
933
|
-
),
|
|
940
|
+
), u = lt(
|
|
934
941
|
s,
|
|
935
|
-
|
|
942
|
+
i
|
|
936
943
|
);
|
|
937
|
-
e.translateContainer =
|
|
944
|
+
e.translateContainer = u;
|
|
938
945
|
}
|
|
939
946
|
break;
|
|
940
947
|
}
|
|
941
948
|
}
|
|
942
|
-
return
|
|
949
|
+
return r;
|
|
943
950
|
}
|
|
944
951
|
function me(t) {
|
|
945
|
-
const e =
|
|
952
|
+
const e = pe(t), n = ut(
|
|
946
953
|
t.draggingAnimationTimings
|
|
947
954
|
), o = {
|
|
948
955
|
isMounted: !1,
|
|
@@ -950,7 +957,7 @@ function me(t) {
|
|
|
950
957
|
n,
|
|
951
958
|
e.draggingAnimationDuration
|
|
952
959
|
)
|
|
953
|
-
},
|
|
960
|
+
}, r = {
|
|
954
961
|
startY: null,
|
|
955
962
|
containerStartTranslate: {
|
|
956
963
|
x: 0,
|
|
@@ -960,45 +967,50 @@ function me(t) {
|
|
|
960
967
|
originalDocumentOverflowY: null,
|
|
961
968
|
originalDocumentOverscrollBehavior: null
|
|
962
969
|
};
|
|
963
|
-
function
|
|
964
|
-
|
|
970
|
+
function a() {
|
|
971
|
+
r.originalDocumentOverflowY && r.originalDocumentOverflowY !== "hidden" && (document.body.style.overflowY = r.originalDocumentOverflowY), r.originalDocumentOverscrollBehavior && (document.body.style.position = r.originalDocumentOverscrollBehavior);
|
|
965
972
|
}
|
|
966
|
-
const
|
|
967
|
-
animationFrame:
|
|
968
|
-
onClose:
|
|
973
|
+
const i = new ee(), s = {
|
|
974
|
+
animationFrame: i,
|
|
975
|
+
onClose: y,
|
|
969
976
|
bottomSheetState: o,
|
|
970
|
-
draggingState:
|
|
971
|
-
snapTo:
|
|
972
|
-
moveUp:
|
|
973
|
-
moveDown:
|
|
974
|
-
}, { elements:
|
|
977
|
+
draggingState: r,
|
|
978
|
+
snapTo: w,
|
|
979
|
+
moveUp: k,
|
|
980
|
+
moveDown: O
|
|
981
|
+
}, { elements: u, eventHandlers: h } = Jt(
|
|
975
982
|
e,
|
|
976
|
-
|
|
983
|
+
s
|
|
977
984
|
), c = re(
|
|
978
985
|
e,
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
986
|
+
he(
|
|
987
|
+
u,
|
|
988
|
+
o,
|
|
989
|
+
e,
|
|
990
|
+
h
|
|
991
|
+
)
|
|
992
|
+
), { bottomSheetBackdrop: m, bottomSheetRoot: S, bottomSheetContainer: l } = u, C = (p) => {
|
|
993
|
+
const d = p ?? window.document.body;
|
|
994
|
+
d.appendChild(S), d.appendChild(m);
|
|
983
995
|
const f = window.innerHeight;
|
|
984
996
|
tt(l, {
|
|
985
997
|
y: f
|
|
986
|
-
}),
|
|
998
|
+
}), h.attachEventListeners(), o.isMounted = !0;
|
|
999
|
+
}, b = () => {
|
|
1000
|
+
h.clearEventListeners(), Object.values(u).forEach((p) => {
|
|
1001
|
+
p.remove();
|
|
1002
|
+
}), a(), o.isMounted = !1;
|
|
987
1003
|
}, v = () => {
|
|
988
|
-
p
|
|
989
|
-
|
|
990
|
-
}), r(), o.isMounted = !1;
|
|
991
|
-
}, S = () => {
|
|
992
|
-
var h;
|
|
993
|
-
if (k() || ie(
|
|
1004
|
+
var p;
|
|
1005
|
+
if (L() || ie(
|
|
994
1006
|
'Bottom Sheet is not mounted yet. call the "mount" method first.'
|
|
995
|
-
), (
|
|
1007
|
+
), (p = t.beforeOpen) == null || p.call(t), T())
|
|
996
1008
|
return;
|
|
997
1009
|
nt(m, !0), c.shouldShowBackdrop || X(m, "transparent"), nt([l], !0), tt(l, {
|
|
998
1010
|
y: l.clientHeight
|
|
999
1011
|
});
|
|
1000
|
-
const
|
|
1001
|
-
|
|
1012
|
+
const d = window.innerHeight, f = ht(
|
|
1013
|
+
d,
|
|
1002
1014
|
l.clientHeight,
|
|
1003
1015
|
c.marginTop,
|
|
1004
1016
|
c.defaultPosition
|
|
@@ -1006,75 +1018,75 @@ function me(t) {
|
|
|
1006
1018
|
o.translateContainer({
|
|
1007
1019
|
startY: g,
|
|
1008
1020
|
endY: f,
|
|
1009
|
-
animationFrame:
|
|
1021
|
+
animationFrame: i,
|
|
1010
1022
|
bottomSheetContainer: l,
|
|
1011
1023
|
onEnd: t.afterOpen
|
|
1012
1024
|
});
|
|
1013
1025
|
const H = document.body.style.overflowY;
|
|
1014
|
-
|
|
1015
|
-
const
|
|
1016
|
-
|
|
1026
|
+
r.originalDocumentOverflowY = H || "initial";
|
|
1027
|
+
const A = document.body.style.overscrollBehavior;
|
|
1028
|
+
r.originalDocumentOverscrollBehavior = A || "initial", document.body.style.overflow = "hidden", document.body.style.overscrollBehavior = "contain", u.bottomSheetHandle.focus(), h.attacheOnOpenEventListeners();
|
|
1017
1029
|
};
|
|
1018
|
-
function
|
|
1019
|
-
var
|
|
1020
|
-
if (
|
|
1030
|
+
function y() {
|
|
1031
|
+
var p;
|
|
1032
|
+
if (M())
|
|
1021
1033
|
return;
|
|
1022
|
-
(
|
|
1023
|
-
const
|
|
1034
|
+
(p = t.beforeClose) == null || p.call(t);
|
|
1035
|
+
const d = B(l).y, f = l.clientHeight;
|
|
1024
1036
|
o.translateContainer({
|
|
1025
|
-
startY:
|
|
1037
|
+
startY: d,
|
|
1026
1038
|
endY: f,
|
|
1027
|
-
animationFrame:
|
|
1039
|
+
animationFrame: i,
|
|
1028
1040
|
bottomSheetContainer: l,
|
|
1029
1041
|
onEnd: () => {
|
|
1030
1042
|
var g;
|
|
1031
|
-
(g = t.afterClose) == null || g.call(t), nt([m, l], !1),
|
|
1043
|
+
(g = t.afterClose) == null || g.call(t), nt([m, l], !1), h.clearOnOpenEventListeners();
|
|
1032
1044
|
}
|
|
1033
|
-
}),
|
|
1045
|
+
}), a();
|
|
1034
1046
|
}
|
|
1035
|
-
function
|
|
1047
|
+
function L() {
|
|
1036
1048
|
return o.isMounted;
|
|
1037
1049
|
}
|
|
1038
1050
|
function T() {
|
|
1039
|
-
const
|
|
1040
|
-
return
|
|
1051
|
+
const p = B(l).y, d = window.innerHeight, f = l.clientHeight >= d ? d : l.clientHeight;
|
|
1052
|
+
return p <= f;
|
|
1041
1053
|
}
|
|
1042
|
-
function
|
|
1054
|
+
function M() {
|
|
1043
1055
|
return !T();
|
|
1044
1056
|
}
|
|
1045
1057
|
function z() {
|
|
1046
|
-
const
|
|
1047
|
-
if (
|
|
1058
|
+
const p = B(l).y, d = l.clientHeight, f = window.innerHeight;
|
|
1059
|
+
if (p <= 5 && p >= -5)
|
|
1048
1060
|
return F.CONTENT_HEIGHT;
|
|
1049
|
-
const g =
|
|
1061
|
+
const g = d - p;
|
|
1050
1062
|
if (g === f / 2)
|
|
1051
1063
|
return F.MIDDLE;
|
|
1052
|
-
const H = f - c.marginTop,
|
|
1053
|
-
return g <= H +
|
|
1064
|
+
const H = f - c.marginTop, A = 10;
|
|
1065
|
+
return g <= H + A && g >= H - A ? F.TOP : F.CLOSED;
|
|
1054
1066
|
}
|
|
1055
1067
|
function j() {
|
|
1056
1068
|
return l.clientHeight;
|
|
1057
1069
|
}
|
|
1058
|
-
function Y(
|
|
1070
|
+
function Y(p) {
|
|
1059
1071
|
if (!T())
|
|
1060
1072
|
return;
|
|
1061
|
-
const
|
|
1073
|
+
const d = B(l).y, f = l.clientHeight - d, g = window.innerHeight - p, H = $t(f, g), A = Q(f, g);
|
|
1062
1074
|
o.translateContainer({
|
|
1063
|
-
startY:
|
|
1064
|
-
endY:
|
|
1065
|
-
animationFrame:
|
|
1075
|
+
startY: d,
|
|
1076
|
+
endY: d + (H.isUp ? -A : A),
|
|
1077
|
+
animationFrame: i,
|
|
1066
1078
|
bottomSheetContainer: l
|
|
1067
1079
|
});
|
|
1068
1080
|
}
|
|
1069
|
-
function q(
|
|
1070
|
-
viewportHeight:
|
|
1081
|
+
function q(p, {
|
|
1082
|
+
viewportHeight: d,
|
|
1071
1083
|
visibleHeight: f
|
|
1072
1084
|
}) {
|
|
1073
1085
|
let g = null;
|
|
1074
|
-
for (const H of
|
|
1075
|
-
const
|
|
1086
|
+
for (const H of p) {
|
|
1087
|
+
const A = H * d, I = Q(
|
|
1076
1088
|
f,
|
|
1077
|
-
|
|
1089
|
+
A
|
|
1078
1090
|
);
|
|
1079
1091
|
(g === null || I < g) && (g = I);
|
|
1080
1092
|
}
|
|
@@ -1082,82 +1094,82 @@ function me(t) {
|
|
|
1082
1094
|
minOffset: g
|
|
1083
1095
|
};
|
|
1084
1096
|
}
|
|
1085
|
-
function
|
|
1086
|
-
const
|
|
1097
|
+
function k() {
|
|
1098
|
+
const p = [...c.snapPoints].reverse(), d = B(l).y, f = l.clientHeight, g = f - d;
|
|
1087
1099
|
if (!c.expandable && g >= f)
|
|
1088
1100
|
return;
|
|
1089
|
-
const H = window.innerHeight,
|
|
1101
|
+
const H = window.innerHeight, A = mt(
|
|
1090
1102
|
"above",
|
|
1091
1103
|
{ visibleHeight: g, viewportHeight: H },
|
|
1092
|
-
|
|
1093
|
-
), { minOffset: I } = q(
|
|
1104
|
+
p
|
|
1105
|
+
), { minOffset: I } = q(A, {
|
|
1094
1106
|
visibleHeight: g,
|
|
1095
1107
|
viewportHeight: H
|
|
1096
1108
|
});
|
|
1097
1109
|
if (I === null && g < H - c.marginTop) {
|
|
1098
1110
|
o.translateContainer({
|
|
1099
|
-
startY:
|
|
1100
|
-
endY:
|
|
1111
|
+
startY: d,
|
|
1112
|
+
endY: ht(
|
|
1101
1113
|
H,
|
|
1102
1114
|
f,
|
|
1103
1115
|
c.marginTop,
|
|
1104
1116
|
"top"
|
|
1105
1117
|
),
|
|
1106
|
-
animationFrame:
|
|
1118
|
+
animationFrame: i,
|
|
1107
1119
|
bottomSheetContainer: l
|
|
1108
1120
|
});
|
|
1109
1121
|
return;
|
|
1110
1122
|
}
|
|
1111
|
-
|
|
1112
|
-
startY:
|
|
1113
|
-
endY:
|
|
1114
|
-
animationFrame:
|
|
1123
|
+
D(I) && o.translateContainer({
|
|
1124
|
+
startY: d,
|
|
1125
|
+
endY: d - I,
|
|
1126
|
+
animationFrame: i,
|
|
1115
1127
|
bottomSheetContainer: l
|
|
1116
1128
|
});
|
|
1117
1129
|
}
|
|
1118
|
-
function
|
|
1119
|
-
const
|
|
1120
|
-
if (
|
|
1130
|
+
function O() {
|
|
1131
|
+
const p = B(l).y, d = l.clientHeight - p;
|
|
1132
|
+
if (d < 1)
|
|
1121
1133
|
return;
|
|
1122
1134
|
const f = window.innerHeight, g = mt(
|
|
1123
1135
|
"below",
|
|
1124
|
-
{ visibleHeight:
|
|
1136
|
+
{ visibleHeight: d, viewportHeight: f },
|
|
1125
1137
|
c.snapPoints
|
|
1126
1138
|
), { minOffset: H } = q(g, {
|
|
1127
|
-
visibleHeight:
|
|
1139
|
+
visibleHeight: d,
|
|
1128
1140
|
viewportHeight: f
|
|
1129
1141
|
});
|
|
1130
|
-
|
|
1131
|
-
startY:
|
|
1132
|
-
endY:
|
|
1133
|
-
animationFrame:
|
|
1142
|
+
D(H) && o.translateContainer({
|
|
1143
|
+
startY: p,
|
|
1144
|
+
endY: p + H,
|
|
1145
|
+
animationFrame: i,
|
|
1134
1146
|
bottomSheetContainer: l
|
|
1135
1147
|
});
|
|
1136
1148
|
}
|
|
1137
|
-
function
|
|
1138
|
-
const
|
|
1139
|
-
if (!oe(
|
|
1149
|
+
function w(p) {
|
|
1150
|
+
const d = window.innerHeight;
|
|
1151
|
+
if (!oe(p))
|
|
1140
1152
|
return;
|
|
1141
|
-
const f = Z(
|
|
1153
|
+
const f = Z(d * p, 2);
|
|
1142
1154
|
Y(f);
|
|
1143
1155
|
}
|
|
1144
1156
|
return {
|
|
1145
1157
|
props: c,
|
|
1146
|
-
elements:
|
|
1147
|
-
mount:
|
|
1148
|
-
unmount:
|
|
1149
|
-
open:
|
|
1150
|
-
close:
|
|
1151
|
-
getIsMounted:
|
|
1158
|
+
elements: u,
|
|
1159
|
+
mount: C,
|
|
1160
|
+
unmount: b,
|
|
1161
|
+
open: v,
|
|
1162
|
+
close: y,
|
|
1163
|
+
getIsMounted: L,
|
|
1152
1164
|
getIsOpen: T,
|
|
1153
|
-
getIsClosed:
|
|
1165
|
+
getIsClosed: M,
|
|
1154
1166
|
getPosition: z,
|
|
1155
1167
|
getHeight: j,
|
|
1156
1168
|
moveTo: Y,
|
|
1157
|
-
snapTo:
|
|
1169
|
+
snapTo: w
|
|
1158
1170
|
};
|
|
1159
1171
|
}
|
|
1160
|
-
function
|
|
1172
|
+
function Dt() {
|
|
1161
1173
|
return {
|
|
1162
1174
|
elements: {
|
|
1163
1175
|
bottomSheetRoot: void 0,
|
|
@@ -1190,115 +1202,115 @@ function At() {
|
|
|
1190
1202
|
}
|
|
1191
1203
|
};
|
|
1192
1204
|
}
|
|
1193
|
-
const fe =
|
|
1205
|
+
const fe = Dt(), Se = At(
|
|
1194
1206
|
function(e, n) {
|
|
1195
1207
|
const {
|
|
1196
1208
|
children: o,
|
|
1197
|
-
isOpen:
|
|
1198
|
-
setIsOpen:
|
|
1199
|
-
afterClose:
|
|
1200
|
-
mountingPointRef:
|
|
1201
|
-
...
|
|
1202
|
-
} = e,
|
|
1203
|
-
|
|
1209
|
+
isOpen: r,
|
|
1210
|
+
setIsOpen: a,
|
|
1211
|
+
afterClose: i,
|
|
1212
|
+
mountingPointRef: s,
|
|
1213
|
+
...u
|
|
1214
|
+
} = e, h = ot(fe), [c, m] = rt(
|
|
1215
|
+
h.current
|
|
1204
1216
|
);
|
|
1205
1217
|
Bt(
|
|
1206
1218
|
n,
|
|
1207
1219
|
() => c,
|
|
1208
1220
|
[c]
|
|
1209
1221
|
);
|
|
1210
|
-
const
|
|
1211
|
-
|
|
1212
|
-
}, [s]);
|
|
1213
|
-
_(() => {
|
|
1214
|
-
i ? c.open() : c.close();
|
|
1222
|
+
const S = Pt(() => {
|
|
1223
|
+
a(!1), i == null || i();
|
|
1215
1224
|
}, [i]);
|
|
1225
|
+
_(() => {
|
|
1226
|
+
r ? c.open() : c.close();
|
|
1227
|
+
}, [r]);
|
|
1216
1228
|
const l = ot(null);
|
|
1217
1229
|
return _(
|
|
1218
1230
|
function() {
|
|
1219
|
-
var
|
|
1220
|
-
if (
|
|
1231
|
+
var y;
|
|
1232
|
+
if (s && !s.current)
|
|
1221
1233
|
return;
|
|
1222
|
-
const
|
|
1223
|
-
if (!
|
|
1234
|
+
const b = It((y = e.mountingPointRef) == null ? void 0 : y.current) ? e.mountingPointRef.current : window.document.body;
|
|
1235
|
+
if (!b || c.getIsMounted())
|
|
1224
1236
|
return;
|
|
1225
|
-
const
|
|
1237
|
+
const v = me({
|
|
1226
1238
|
content: "",
|
|
1227
|
-
...
|
|
1228
|
-
afterClose:
|
|
1239
|
+
...u,
|
|
1240
|
+
afterClose: S
|
|
1229
1241
|
});
|
|
1230
|
-
return
|
|
1242
|
+
return v.mount(b), l.current = v.elements.bottomSheetContentWrapper ?? null, h.current = v, m(v), () => {
|
|
1231
1243
|
c.unmount();
|
|
1232
1244
|
};
|
|
1233
1245
|
},
|
|
1234
|
-
[e.mountingPointRef,
|
|
1246
|
+
[e.mountingPointRef, u, S]
|
|
1235
1247
|
), _(
|
|
1236
1248
|
function() {
|
|
1237
|
-
Object.assign(
|
|
1238
|
-
...
|
|
1239
|
-
}), m(
|
|
1249
|
+
Object.assign(h.current.props, {
|
|
1250
|
+
...u
|
|
1251
|
+
}), m(h.current);
|
|
1240
1252
|
},
|
|
1241
|
-
[
|
|
1253
|
+
[u]
|
|
1242
1254
|
), _(function() {
|
|
1243
1255
|
return () => {
|
|
1244
|
-
|
|
1256
|
+
h.current.unmount();
|
|
1245
1257
|
};
|
|
1246
1258
|
}, []), l.current ? Yt(
|
|
1247
1259
|
e.children,
|
|
1248
1260
|
l.current
|
|
1249
1261
|
) : null;
|
|
1250
1262
|
}
|
|
1251
|
-
), ge =
|
|
1263
|
+
), ge = Dt();
|
|
1252
1264
|
function Ce(t = {}) {
|
|
1253
|
-
const e = ot(ge), [n, o] = rt(!1), [
|
|
1265
|
+
const e = ot(ge), [n, o] = rt(!1), [r, a] = rt(e.current);
|
|
1254
1266
|
_(() => {
|
|
1255
|
-
|
|
1267
|
+
a(e.current);
|
|
1256
1268
|
}, [e.current]);
|
|
1257
1269
|
const {
|
|
1258
|
-
beforeOpen:
|
|
1259
|
-
afterOpen:
|
|
1260
|
-
beforeClose:
|
|
1261
|
-
afterClose:
|
|
1270
|
+
beforeOpen: i,
|
|
1271
|
+
afterOpen: s,
|
|
1272
|
+
beforeClose: u,
|
|
1273
|
+
afterClose: h,
|
|
1262
1274
|
onDragStart: c,
|
|
1263
1275
|
onDragMove: m,
|
|
1264
|
-
onDragEnd:
|
|
1276
|
+
onDragEnd: S,
|
|
1265
1277
|
...l
|
|
1266
|
-
} = t,
|
|
1267
|
-
|
|
1278
|
+
} = t, C = () => {
|
|
1279
|
+
i == null || i();
|
|
1280
|
+
}, b = () => {
|
|
1281
|
+
s == null || s(), o(!0);
|
|
1268
1282
|
}, v = () => {
|
|
1269
|
-
|
|
1270
|
-
},
|
|
1271
|
-
|
|
1272
|
-
},
|
|
1273
|
-
p == null || p(), o(!1);
|
|
1274
|
-
}, k = () => {
|
|
1283
|
+
u == null || u();
|
|
1284
|
+
}, y = () => {
|
|
1285
|
+
h == null || h(), o(!1);
|
|
1286
|
+
}, L = () => {
|
|
1275
1287
|
c == null || c();
|
|
1276
1288
|
}, T = (j, Y) => {
|
|
1277
1289
|
m == null || m(j, Y);
|
|
1278
|
-
},
|
|
1279
|
-
|
|
1290
|
+
}, M = () => {
|
|
1291
|
+
S == null || S();
|
|
1280
1292
|
};
|
|
1281
1293
|
return {
|
|
1282
|
-
props:
|
|
1294
|
+
props: Mt(() => ({
|
|
1283
1295
|
ref: e,
|
|
1284
1296
|
isOpen: n,
|
|
1285
1297
|
setIsOpen: o,
|
|
1286
|
-
beforeOpen:
|
|
1287
|
-
afterOpen:
|
|
1288
|
-
beforeClose:
|
|
1289
|
-
afterClose:
|
|
1290
|
-
onDragStart:
|
|
1298
|
+
beforeOpen: C,
|
|
1299
|
+
afterOpen: b,
|
|
1300
|
+
beforeClose: v,
|
|
1301
|
+
afterClose: y,
|
|
1302
|
+
onDragStart: L,
|
|
1291
1303
|
onDragMove: T,
|
|
1292
|
-
onDragEnd:
|
|
1304
|
+
onDragEnd: M,
|
|
1293
1305
|
...l
|
|
1294
1306
|
}), [e.current, n, o, t]),
|
|
1295
|
-
instance:
|
|
1307
|
+
instance: r,
|
|
1296
1308
|
isOpen: n,
|
|
1297
1309
|
setIsOpen: o
|
|
1298
1310
|
};
|
|
1299
1311
|
}
|
|
1300
1312
|
export {
|
|
1301
1313
|
Se as BottomSheet,
|
|
1302
|
-
|
|
1314
|
+
Dt as createPlaceholderBottomSheet,
|
|
1303
1315
|
Ce as useBottomSheet
|
|
1304
1316
|
};
|