@plainsheet/react 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +22 -0
- package/README.md +70 -0
- package/dist/ReactPlainBottomSheet.d.ts +19 -0
- package/dist/index.d.ts +1 -0
- package/dist/plainsheet-core.cjs.js +1 -0
- package/dist/plainsheet-core.es.js +1217 -0
- package/dist/plainsheet-core.umd.js +1 -0
- package/package.json +66 -0
|
@@ -0,0 +1,1217 @@
|
|
|
1
|
+
import { forwardRef as Lt, useRef as ct, useState as xt, useImperativeHandle as At, useCallback as Ot, useEffect as tt } from "react";
|
|
2
|
+
import { createPortal as Dt } from "react-dom";
|
|
3
|
+
function Pt(t) {
|
|
4
|
+
return t != null;
|
|
5
|
+
}
|
|
6
|
+
(function() {
|
|
7
|
+
try {
|
|
8
|
+
if (typeof document < "u") {
|
|
9
|
+
var t = document.createElement("style");
|
|
10
|
+
t.appendChild(document.createTextNode('.pbs-root{position:fixed;left:0;bottom:0;display:flex;flex-direction:column;align-items:center;justify-content:flex-start;width:100%;height:fit-content;max-height:100vh;z-index:2}.pbs-dialog-reset{background-color:transparent;color:inherit;border:none;outline:none;padding:0;margin:0}.pbs-backdrop{position:fixed;top:0;left:0;width:100%;height:100%;pointer-events:none;background-color:transparent;z-index:1;transition:background-color .2s ease-out}.pbs-backdrop.hidden{display:none}.pbs-backdrop.open{background-color:#454545b3}.pbs-container{--pbs-container-background-color: rgb(240, 240, 240);background-color:var(--pbs-container-background-color);position:relative;display:none;flex-direction:column;align-items:center;justify-content:flex-start;width:92%;height:fit-content;max-height:100vh;border-radius:10px 10px 0 0}.pbs-container.open{display:flex}.pbs-container .pbs-gap-filler{position:absolute;bottom:calc(-100vh + .5px);left:0;background-color:var(--pbs-container-background-color);content:"";width:100%;height:100vh}.pbs-handle{position:relative;display:flex;align-items:center;justify-content:center;width:100%;height:30px;cursor:pointer}.pbs-handle.hidden{display:none}.pbs-button-reset{background-color:transparent;-webkit-appearance:none;-moz-appearance:none;appearance:none;outline:none;border:none}button:focus.pbs-button-reset{outline:none}.pbs-handle-bar{background-color:#a8a8a8;position:relative;width:12%;height:7px;border-radius:12px}.pbs-handle-bar.hidden{display:none}.pbs-content-wrapper{position:relative;width:100%;height:fit-content;max-height:100%;overflow-y:scroll}.pbs-content-wrapper::-webkit-scrollbar{display:none}.example{-ms-overflow-style:none;scrollbar-width:none}')), document.head.appendChild(t);
|
|
11
|
+
}
|
|
12
|
+
} catch (e) {
|
|
13
|
+
console.error("vite-plugin-css-injected-by-js", e);
|
|
14
|
+
}
|
|
15
|
+
})();
|
|
16
|
+
var Bt = Object.defineProperty, Mt = (t, e, n) => e in t ? Bt(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n, G = (t, e, n) => (Mt(t, typeof e != "symbol" ? e + "" : e, n), n);
|
|
17
|
+
function H(t) {
|
|
18
|
+
return typeof t == "string";
|
|
19
|
+
}
|
|
20
|
+
function Yt(t, e) {
|
|
21
|
+
return t.classList.contains(K(e));
|
|
22
|
+
}
|
|
23
|
+
function $(t, e) {
|
|
24
|
+
t.classList.add(K(e));
|
|
25
|
+
}
|
|
26
|
+
function nt(t, e) {
|
|
27
|
+
t.classList.remove(K(e));
|
|
28
|
+
}
|
|
29
|
+
function U(t, e, n) {
|
|
30
|
+
H(n) && (H(e) && nt(t, e), $(t, n));
|
|
31
|
+
}
|
|
32
|
+
function K(t) {
|
|
33
|
+
return H(t) ? t.trim().replace(/\./g, "") : "";
|
|
34
|
+
}
|
|
35
|
+
function I(t) {
|
|
36
|
+
return t.map((e) => K(e)).filter(Boolean).join(" ");
|
|
37
|
+
}
|
|
38
|
+
function It(t) {
|
|
39
|
+
return t.map((e) => e == null ? void 0 : e.trim()).filter(Boolean).map((e) => `.${e}`).join(" ");
|
|
40
|
+
}
|
|
41
|
+
const lt = "open", ut = "hidden";
|
|
42
|
+
function et(t, e) {
|
|
43
|
+
const n = e;
|
|
44
|
+
if (Array.isArray(t)) {
|
|
45
|
+
t.forEach((o) => {
|
|
46
|
+
X(o, n), o.setAttribute("aria-modal", n ? "true" : "false");
|
|
47
|
+
});
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
X(t, n), t.setAttribute("aria-modal", n ? "true" : "false");
|
|
51
|
+
}
|
|
52
|
+
function X(t, e) {
|
|
53
|
+
e ? ($(t, lt), nt(t, ut)) : ($(t, ut), nt(t, lt));
|
|
54
|
+
}
|
|
55
|
+
function vt(t) {
|
|
56
|
+
return t instanceof HTMLElement;
|
|
57
|
+
}
|
|
58
|
+
function L(t) {
|
|
59
|
+
return typeof t == "number" && !Number.isNaN(t);
|
|
60
|
+
}
|
|
61
|
+
function Rt(t) {
|
|
62
|
+
vt(t) && t.focus();
|
|
63
|
+
}
|
|
64
|
+
function Nt(t) {
|
|
65
|
+
if (!vt(t) || t.offsetParent === null || "disabled" in t && t.disabled)
|
|
66
|
+
return !1;
|
|
67
|
+
const e = t.getAttribute("tabindex"), n = L(e) ? parseInt(e, 10) : -1, o = [
|
|
68
|
+
"INPUT",
|
|
69
|
+
"BUTTON",
|
|
70
|
+
"SELECT",
|
|
71
|
+
"TEXTAREA",
|
|
72
|
+
"A",
|
|
73
|
+
"AREA",
|
|
74
|
+
"IFRAME"
|
|
75
|
+
].includes(t.tagName), i = t instanceof HTMLAnchorElement && t.href !== "" || t instanceof HTMLAreaElement && t.href !== "";
|
|
76
|
+
return o || i || n > -1;
|
|
77
|
+
}
|
|
78
|
+
var y = /* @__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))(y || {}), ot = /* @__PURE__ */ ((t) => (t.Button = "pbs-button-reset", t.Dialog = "pbs-dialog-reset", t))(ot || {}), _ = /* @__PURE__ */ ((t) => (t.Hidden = "hidden", t))(_ || {});
|
|
79
|
+
function B(t, e, n) {
|
|
80
|
+
const o = document.createElement(t);
|
|
81
|
+
return e.split(" ").forEach((i) => {
|
|
82
|
+
$(o, i);
|
|
83
|
+
}), H(n) && o.setAttribute("data-testid", n), o;
|
|
84
|
+
}
|
|
85
|
+
It([
|
|
86
|
+
y.Root,
|
|
87
|
+
y.ContentWrapper
|
|
88
|
+
]);
|
|
89
|
+
function dt(t, e, n, o) {
|
|
90
|
+
switch (o) {
|
|
91
|
+
case "content-height":
|
|
92
|
+
return e >= t ? wt(t, e, n) : 0;
|
|
93
|
+
case "middle":
|
|
94
|
+
return -(t / 2 - e);
|
|
95
|
+
case "top":
|
|
96
|
+
return -(t - e) + n;
|
|
97
|
+
default:
|
|
98
|
+
return 0;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
function St(t, e) {
|
|
102
|
+
const n = e < t, o = e > t;
|
|
103
|
+
return {
|
|
104
|
+
isUp: n,
|
|
105
|
+
isDown: o,
|
|
106
|
+
stayedSame: e === t
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
function Ct(t, e) {
|
|
110
|
+
return e < t ? -(t - e) : e - t;
|
|
111
|
+
}
|
|
112
|
+
function q(t, e) {
|
|
113
|
+
return t > e ? t - e : e - t;
|
|
114
|
+
}
|
|
115
|
+
function Ft(t, e) {
|
|
116
|
+
const n = t < e, o = t > e;
|
|
117
|
+
return {
|
|
118
|
+
isUp: n,
|
|
119
|
+
isDown: o,
|
|
120
|
+
stayedSame: t === e
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
function pt(t, e, n) {
|
|
124
|
+
const o = t === "above";
|
|
125
|
+
return n.filter((i) => {
|
|
126
|
+
const r = i * e.viewportHeight;
|
|
127
|
+
return o ? e.visibleHeight < r : e.visibleHeight > r;
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
function wt(t, e, n) {
|
|
131
|
+
return -(t - e) + n;
|
|
132
|
+
}
|
|
133
|
+
function ht(t) {
|
|
134
|
+
return Number(t.replace("px", ""));
|
|
135
|
+
}
|
|
136
|
+
function z(t, ...e) {
|
|
137
|
+
return Number(t.toFixed(...e));
|
|
138
|
+
}
|
|
139
|
+
function yt(t) {
|
|
140
|
+
const e = /(?<type>\w+)\((?<values>[^)]+)\)/g, n = [];
|
|
141
|
+
let o;
|
|
142
|
+
for (; (o = e.exec(t)) !== null; ) {
|
|
143
|
+
const i = o[1], r = o[2].split(",").map((c) => c.trim());
|
|
144
|
+
n.push({ type: i, values: r });
|
|
145
|
+
}
|
|
146
|
+
return n;
|
|
147
|
+
}
|
|
148
|
+
function Wt(t) {
|
|
149
|
+
const e = t.style.transform, n = yt(e);
|
|
150
|
+
return { transform: e, transformValues: n };
|
|
151
|
+
}
|
|
152
|
+
function Et(t, e) {
|
|
153
|
+
return t.find(
|
|
154
|
+
(o) => o.type.startsWith(e)
|
|
155
|
+
) || null;
|
|
156
|
+
}
|
|
157
|
+
const rt = "translate";
|
|
158
|
+
function D(t) {
|
|
159
|
+
const e = t.style.transform, n = yt(e), o = Et(
|
|
160
|
+
n,
|
|
161
|
+
rt
|
|
162
|
+
);
|
|
163
|
+
return Tt(o ?? {
|
|
164
|
+
type: rt,
|
|
165
|
+
values: []
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
function V(t, { x: e, y: n }) {
|
|
169
|
+
const {
|
|
170
|
+
transform: o,
|
|
171
|
+
transformValues: i
|
|
172
|
+
} = Wt(t), r = Et(
|
|
173
|
+
i,
|
|
174
|
+
rt
|
|
175
|
+
);
|
|
176
|
+
if (r) {
|
|
177
|
+
const c = Tt(r);
|
|
178
|
+
t.style.transform = `translate(${e ?? c.x ?? 0}px,${n ?? c.y ?? 0}px)`;
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
if (o) {
|
|
182
|
+
t.style.transform = `${o}, translate(${e ?? 0}px,${n ?? 0}px)`;
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
t.style.transform = `translate(${e ?? 0}px,${n ?? 0}px)`;
|
|
186
|
+
}
|
|
187
|
+
function Tt(t) {
|
|
188
|
+
if (t.type !== "translate")
|
|
189
|
+
throw new Error(
|
|
190
|
+
`Could not get coordinates from ${t.type}, since is not translate.`
|
|
191
|
+
);
|
|
192
|
+
const e = t.values[0], n = t.values[1];
|
|
193
|
+
return {
|
|
194
|
+
x: ht(e) ?? 0,
|
|
195
|
+
y: ht(n) ?? 0
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
function it(t) {
|
|
199
|
+
return t != null;
|
|
200
|
+
}
|
|
201
|
+
function mt(t, {
|
|
202
|
+
min: e,
|
|
203
|
+
max: n
|
|
204
|
+
}) {
|
|
205
|
+
return it(n) && t >= n ? n : it(e) && t <= e ? e : t;
|
|
206
|
+
}
|
|
207
|
+
const Ut = (t, e, n) => {
|
|
208
|
+
e instanceof HTMLElement && !Yt(e, y.Handle) && n.scrollTop >= 1 || (t.isDragging = !0);
|
|
209
|
+
}, jt = (t, e, n, o) => (i) => {
|
|
210
|
+
o.startY = t.getCoordinates(i).y, o.containerStartTranslate = D(e), o.originalDocumentOverflowY = document.body.style.overflowY, document.body.style.overflowY = "hidden", n.onDragStart();
|
|
211
|
+
}, Gt = (t, e, n, o, i) => (r) => {
|
|
212
|
+
_t(
|
|
213
|
+
r,
|
|
214
|
+
t,
|
|
215
|
+
n,
|
|
216
|
+
o,
|
|
217
|
+
i,
|
|
218
|
+
e,
|
|
219
|
+
n.marginTop
|
|
220
|
+
);
|
|
221
|
+
};
|
|
222
|
+
function _t(t, e, n, o, i, r, c) {
|
|
223
|
+
if (!o.isDragging || !L(o.startY))
|
|
224
|
+
return;
|
|
225
|
+
const a = e.getCoordinates(t).y, m = Ct(o.startY, a), u = window.innerHeight, l = r.clientHeight, b = l - (o.containerStartTranslate.y + m);
|
|
226
|
+
if (b >= u)
|
|
227
|
+
return;
|
|
228
|
+
const s = St(o.startY, a);
|
|
229
|
+
if (s.isUp && !n.expandable && b >= l)
|
|
230
|
+
return;
|
|
231
|
+
i.start(() => {
|
|
232
|
+
V(r, {
|
|
233
|
+
y: o.containerStartTranslate.y + m
|
|
234
|
+
});
|
|
235
|
+
}, 0);
|
|
236
|
+
const v = u - c, k = l - o.containerStartTranslate.y;
|
|
237
|
+
if (s.isUp) {
|
|
238
|
+
const S = v - k, C = v - b, E = mt(
|
|
239
|
+
1 - z(C / S, 2),
|
|
240
|
+
{
|
|
241
|
+
min: 0,
|
|
242
|
+
max: 1
|
|
243
|
+
}
|
|
244
|
+
);
|
|
245
|
+
n.onDragMove(s, E);
|
|
246
|
+
} else if (s.isDown) {
|
|
247
|
+
const S = mt(
|
|
248
|
+
z(
|
|
249
|
+
1 - b / k,
|
|
250
|
+
2
|
|
251
|
+
),
|
|
252
|
+
{
|
|
253
|
+
min: 0,
|
|
254
|
+
max: 1
|
|
255
|
+
}
|
|
256
|
+
);
|
|
257
|
+
n.onDragMove(s, S);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
const $t = (t, e, n, o, i, r, c) => (a) => {
|
|
261
|
+
if (!o.isDragging || (o.isDragging = !1, document.body.style.overflowY = o.originalDocumentOverflowY, !L(o.startY)))
|
|
262
|
+
return;
|
|
263
|
+
n.onDragEnd();
|
|
264
|
+
const m = o.startY, u = t.getCoordinates(a).y, l = D(e).y, b = St(m, u), s = window.innerHeight, v = e.clientHeight;
|
|
265
|
+
if (b.isUp) {
|
|
266
|
+
const k = [...n.snapPoints].sort(
|
|
267
|
+
(E, w) => E - w
|
|
268
|
+
), S = v + -l;
|
|
269
|
+
if (!n.expandable && S >= v)
|
|
270
|
+
return;
|
|
271
|
+
for (const E of k) {
|
|
272
|
+
const w = E * window.innerHeight;
|
|
273
|
+
if (S <= w) {
|
|
274
|
+
const M = q(
|
|
275
|
+
S,
|
|
276
|
+
w
|
|
277
|
+
);
|
|
278
|
+
c.translateContainer({
|
|
279
|
+
startY: l,
|
|
280
|
+
endY: l - M,
|
|
281
|
+
animationFrame: i,
|
|
282
|
+
bottomSheetContainer: e
|
|
283
|
+
});
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
const C = wt(
|
|
288
|
+
s,
|
|
289
|
+
v,
|
|
290
|
+
n.marginTop
|
|
291
|
+
);
|
|
292
|
+
c.translateContainer({
|
|
293
|
+
startY: l,
|
|
294
|
+
endY: C,
|
|
295
|
+
animationFrame: i,
|
|
296
|
+
bottomSheetContainer: e
|
|
297
|
+
});
|
|
298
|
+
} else if (b.isDown) {
|
|
299
|
+
const k = [...n.snapPoints].sort(
|
|
300
|
+
(S, C) => C - S
|
|
301
|
+
);
|
|
302
|
+
for (const S of k) {
|
|
303
|
+
const C = S * window.innerHeight, E = v + -l;
|
|
304
|
+
if (E >= C) {
|
|
305
|
+
const w = q(
|
|
306
|
+
E,
|
|
307
|
+
C
|
|
308
|
+
);
|
|
309
|
+
c.translateContainer({
|
|
310
|
+
startY: l,
|
|
311
|
+
endY: l + w,
|
|
312
|
+
animationFrame: i,
|
|
313
|
+
bottomSheetContainer: e
|
|
314
|
+
});
|
|
315
|
+
return;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
r();
|
|
319
|
+
}
|
|
320
|
+
};
|
|
321
|
+
var F = /* @__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))(F || {});
|
|
322
|
+
function ft(t) {
|
|
323
|
+
switch (t) {
|
|
324
|
+
case 0:
|
|
325
|
+
return 0;
|
|
326
|
+
case 1:
|
|
327
|
+
return 1;
|
|
328
|
+
case 2:
|
|
329
|
+
return 2;
|
|
330
|
+
case 3:
|
|
331
|
+
return 3;
|
|
332
|
+
default:
|
|
333
|
+
return -1;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
const Xt = {
|
|
337
|
+
eventPhase: F.All
|
|
338
|
+
};
|
|
339
|
+
class j {
|
|
340
|
+
constructor(e) {
|
|
341
|
+
G(this, "currentTarget"), this.currentTarget = e;
|
|
342
|
+
}
|
|
343
|
+
addEventListeners({
|
|
344
|
+
onStart: e,
|
|
345
|
+
onStartOptions: n = Xt,
|
|
346
|
+
onMove: o,
|
|
347
|
+
onEnd: i
|
|
348
|
+
}) {
|
|
349
|
+
this.addTouchEventListeners({ onStart: e, onStartOptions: n, onMove: o, onEnd: i }), this.addMouseEventListeners({ onStart: e, onStartOptions: n, onMove: o, onEnd: i });
|
|
350
|
+
}
|
|
351
|
+
addTouchEventListeners({
|
|
352
|
+
onStart: e,
|
|
353
|
+
onStartOptions: n,
|
|
354
|
+
onMove: o,
|
|
355
|
+
onEnd: i
|
|
356
|
+
}) {
|
|
357
|
+
e && this.currentTarget.addEventListener(
|
|
358
|
+
"touchstart",
|
|
359
|
+
(r) => {
|
|
360
|
+
if (n.eventPhase === F.All) {
|
|
361
|
+
e(r);
|
|
362
|
+
return;
|
|
363
|
+
}
|
|
364
|
+
ft(r.eventPhase) === n.eventPhase && e(r);
|
|
365
|
+
},
|
|
366
|
+
{
|
|
367
|
+
passive: !0
|
|
368
|
+
}
|
|
369
|
+
), o && this.currentTarget.addEventListener("touchmove", o), i && this.currentTarget.addEventListener("touchend", i);
|
|
370
|
+
}
|
|
371
|
+
addMouseEventListeners({
|
|
372
|
+
onStart: e,
|
|
373
|
+
onStartOptions: n,
|
|
374
|
+
onMove: o,
|
|
375
|
+
onEnd: i
|
|
376
|
+
}) {
|
|
377
|
+
e && this.currentTarget.addEventListener(
|
|
378
|
+
"mousedown",
|
|
379
|
+
(r) => {
|
|
380
|
+
if (n.eventPhase === F.All) {
|
|
381
|
+
e(r);
|
|
382
|
+
return;
|
|
383
|
+
}
|
|
384
|
+
ft(r.eventPhase) === n.eventPhase && e(r);
|
|
385
|
+
},
|
|
386
|
+
{
|
|
387
|
+
passive: !0
|
|
388
|
+
}
|
|
389
|
+
), o && this.currentTarget.addEventListener("mousemove", o), i && this.currentTarget.addEventListener("mouseup", (r) => {
|
|
390
|
+
i(r);
|
|
391
|
+
});
|
|
392
|
+
}
|
|
393
|
+
removeEventListeners({
|
|
394
|
+
onStart: e,
|
|
395
|
+
onMove: n,
|
|
396
|
+
onEnd: o
|
|
397
|
+
}) {
|
|
398
|
+
e && this.currentTarget.removeEventListener("touchstart", e), o && this.currentTarget.removeEventListener("touchend", o), n && this.currentTarget.removeEventListener("touchmove", n), e && this.currentTarget.removeEventListener("mousedown", e), n && this.currentTarget.removeEventListener("mousemove", n), o && this.currentTarget.removeEventListener("mouseup", o);
|
|
399
|
+
}
|
|
400
|
+
getCoordinates(e) {
|
|
401
|
+
if (e.type === "touchstart" || e.type === "mousedown") {
|
|
402
|
+
if ("touches" in e)
|
|
403
|
+
return {
|
|
404
|
+
x: e.touches[0].clientX,
|
|
405
|
+
y: e.touches[0].clientY
|
|
406
|
+
};
|
|
407
|
+
if (e instanceof MouseEvent)
|
|
408
|
+
return {
|
|
409
|
+
x: e.clientX,
|
|
410
|
+
y: e.clientY
|
|
411
|
+
};
|
|
412
|
+
}
|
|
413
|
+
if (e.type === "touchend" || e.type === "mouseup" || e.type === "mousemove" || e.type === "touchmove") {
|
|
414
|
+
if ("touches" in e)
|
|
415
|
+
return {
|
|
416
|
+
x: e.changedTouches[0].clientX,
|
|
417
|
+
y: e.changedTouches[0].clientY
|
|
418
|
+
};
|
|
419
|
+
if (e instanceof MouseEvent)
|
|
420
|
+
return {
|
|
421
|
+
x: e.clientX,
|
|
422
|
+
y: e.clientY
|
|
423
|
+
};
|
|
424
|
+
}
|
|
425
|
+
return {
|
|
426
|
+
x: 0,
|
|
427
|
+
y: 0
|
|
428
|
+
};
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
function qt(t, e) {
|
|
432
|
+
const n = zt(t);
|
|
433
|
+
Vt(n), n.bottomSheetContainer.style.width = t.width;
|
|
434
|
+
const o = document.createElement("div");
|
|
435
|
+
o.innerHTML = t.content ?? "";
|
|
436
|
+
const i = window.innerHeight;
|
|
437
|
+
n.bottomSheetContainer.style.maxHeight = `${i}px`, n.bottomSheetContentWrapper.appendChild(o);
|
|
438
|
+
const r = Kt({
|
|
439
|
+
bottomSheetElements: n,
|
|
440
|
+
bottomSheetProps: t,
|
|
441
|
+
options: e
|
|
442
|
+
});
|
|
443
|
+
return { elements: n, eventHandlers: r };
|
|
444
|
+
}
|
|
445
|
+
function zt(t) {
|
|
446
|
+
const e = B(
|
|
447
|
+
"dialog",
|
|
448
|
+
I([
|
|
449
|
+
y.Root,
|
|
450
|
+
ot.Dialog,
|
|
451
|
+
t.rootClass
|
|
452
|
+
]),
|
|
453
|
+
y.Root
|
|
454
|
+
);
|
|
455
|
+
e.ariaLabel = t.ariaLabel;
|
|
456
|
+
const n = B(
|
|
457
|
+
"section",
|
|
458
|
+
I([y.Container, t.containerClass]),
|
|
459
|
+
y.Container
|
|
460
|
+
);
|
|
461
|
+
t.containerBorderRadius && (n.style.borderRadius = t.containerBorderRadius);
|
|
462
|
+
const o = B(
|
|
463
|
+
"div",
|
|
464
|
+
y.GapFiller,
|
|
465
|
+
y.GapFiller
|
|
466
|
+
), i = B(
|
|
467
|
+
"button",
|
|
468
|
+
I([
|
|
469
|
+
y.Handle,
|
|
470
|
+
ot.Button,
|
|
471
|
+
t.shouldShowHandle ? null : _.Hidden,
|
|
472
|
+
t.handleClass
|
|
473
|
+
]),
|
|
474
|
+
y.Handle
|
|
475
|
+
);
|
|
476
|
+
i.setAttribute("type", "button"), i.ariaLabel = "bottom sheet close button";
|
|
477
|
+
const r = B(
|
|
478
|
+
"span",
|
|
479
|
+
I([
|
|
480
|
+
y.HandleBar,
|
|
481
|
+
t.shouldShowHandle ? null : _.Hidden
|
|
482
|
+
]),
|
|
483
|
+
y.HandleBar
|
|
484
|
+
), c = B(
|
|
485
|
+
"article",
|
|
486
|
+
I([
|
|
487
|
+
y.ContentWrapper,
|
|
488
|
+
t.contentWrapperClass
|
|
489
|
+
]),
|
|
490
|
+
y.ContentWrapper
|
|
491
|
+
), a = B(
|
|
492
|
+
"div",
|
|
493
|
+
I([
|
|
494
|
+
y.Backdrop,
|
|
495
|
+
t.backdropClass,
|
|
496
|
+
_.Hidden
|
|
497
|
+
]),
|
|
498
|
+
y.Backdrop
|
|
499
|
+
);
|
|
500
|
+
return t.backdropColor && (a.style.backgroundColor = t.backdropColor), t.backDropTransition && (a.style.transition = t.backDropTransition), {
|
|
501
|
+
bottomSheetRoot: e,
|
|
502
|
+
bottomSheetBackdrop: a,
|
|
503
|
+
bottomSheetContainer: n,
|
|
504
|
+
bottomSheetHandle: i,
|
|
505
|
+
bottomSheetHandleBar: r,
|
|
506
|
+
bottomSheetContentWrapper: c,
|
|
507
|
+
bottomSheetContainerGapFiller: o
|
|
508
|
+
};
|
|
509
|
+
}
|
|
510
|
+
function Vt({
|
|
511
|
+
bottomSheetRoot: t,
|
|
512
|
+
bottomSheetContainer: e,
|
|
513
|
+
bottomSheetHandle: n,
|
|
514
|
+
bottomSheetHandleBar: o,
|
|
515
|
+
bottomSheetContentWrapper: i,
|
|
516
|
+
bottomSheetContainerGapFiller: r
|
|
517
|
+
}) {
|
|
518
|
+
t.appendChild(e), n.appendChild(o), e.appendChild(n), e.appendChild(i), e.appendChild(r);
|
|
519
|
+
}
|
|
520
|
+
function Kt({
|
|
521
|
+
bottomSheetElements: t,
|
|
522
|
+
bottomSheetProps: e,
|
|
523
|
+
options: n
|
|
524
|
+
}) {
|
|
525
|
+
const {
|
|
526
|
+
bottomSheetRoot: o,
|
|
527
|
+
bottomSheetContainer: i,
|
|
528
|
+
bottomSheetHandle: r,
|
|
529
|
+
bottomSheetContainerGapFiller: c,
|
|
530
|
+
bottomSheetContentWrapper: a
|
|
531
|
+
} = t, { animationFrame: m } = n, u = new j(r), l = new j(
|
|
532
|
+
a
|
|
533
|
+
), b = new j(
|
|
534
|
+
c
|
|
535
|
+
), s = e.dragTriggers.reduce(
|
|
536
|
+
(f, x) => {
|
|
537
|
+
const A = o.querySelectorAll(x);
|
|
538
|
+
if (!A.length)
|
|
539
|
+
return f;
|
|
540
|
+
const J = Array.from(A).map((P) => P instanceof HTMLElement ? new j(P) : null).filter((P) => !!P);
|
|
541
|
+
return [...f, ...J];
|
|
542
|
+
},
|
|
543
|
+
[]
|
|
544
|
+
), v = new j(
|
|
545
|
+
window
|
|
546
|
+
), k = jt(
|
|
547
|
+
v,
|
|
548
|
+
i,
|
|
549
|
+
e,
|
|
550
|
+
n.draggingState
|
|
551
|
+
), S = Gt(
|
|
552
|
+
v,
|
|
553
|
+
i,
|
|
554
|
+
e,
|
|
555
|
+
n.draggingState,
|
|
556
|
+
m
|
|
557
|
+
), C = $t(
|
|
558
|
+
v,
|
|
559
|
+
i,
|
|
560
|
+
e,
|
|
561
|
+
n.draggingState,
|
|
562
|
+
m,
|
|
563
|
+
n.onClose,
|
|
564
|
+
n.bottomSheetState
|
|
565
|
+
);
|
|
566
|
+
function E(f) {
|
|
567
|
+
f.target instanceof Element && !o.contains(f.target) && n.onClose();
|
|
568
|
+
}
|
|
569
|
+
function w(f) {
|
|
570
|
+
Ut(
|
|
571
|
+
n.draggingState,
|
|
572
|
+
f.target,
|
|
573
|
+
t.bottomSheetContentWrapper
|
|
574
|
+
);
|
|
575
|
+
}
|
|
576
|
+
function M() {
|
|
577
|
+
e.draggable && (u.addEventListeners({
|
|
578
|
+
onStart: w
|
|
579
|
+
}), s.forEach((f) => {
|
|
580
|
+
f.addEventListeners({
|
|
581
|
+
onStart: w,
|
|
582
|
+
onStartOptions: {
|
|
583
|
+
eventPhase: F.Target
|
|
584
|
+
}
|
|
585
|
+
});
|
|
586
|
+
})), e.draggable && e.backgroundDraggable && (l.addEventListeners({
|
|
587
|
+
onStart: w,
|
|
588
|
+
onStartOptions: {
|
|
589
|
+
eventPhase: F.Target
|
|
590
|
+
}
|
|
591
|
+
}), b.addEventListeners({
|
|
592
|
+
onStart: w
|
|
593
|
+
})), e.draggable && v.addEventListeners({
|
|
594
|
+
onStart: k,
|
|
595
|
+
onMove: S,
|
|
596
|
+
onEnd: C
|
|
597
|
+
}), e.draggable && window.document.addEventListener("keyup", (f) => {
|
|
598
|
+
f.key === "Escape" && n.onClose();
|
|
599
|
+
}), e.shouldCloseOnOutsideClick && window.document.addEventListener("click", E), r.addEventListener("keyup", (f) => {
|
|
600
|
+
if (f.key === "ArrowUp") {
|
|
601
|
+
n.moveUp();
|
|
602
|
+
return;
|
|
603
|
+
}
|
|
604
|
+
if (f.key === "ArrowDown") {
|
|
605
|
+
n.moveDown();
|
|
606
|
+
return;
|
|
607
|
+
}
|
|
608
|
+
if (f.shiftKey && f.key === "Tab") {
|
|
609
|
+
const x = Q(
|
|
610
|
+
t.bottomSheetContentWrapper
|
|
611
|
+
);
|
|
612
|
+
Rt(x);
|
|
613
|
+
}
|
|
614
|
+
});
|
|
615
|
+
}
|
|
616
|
+
function Q(f) {
|
|
617
|
+
let x = [...Array.from(f.childNodes).reverse()];
|
|
618
|
+
for (; x.length; ) {
|
|
619
|
+
const A = x.shift();
|
|
620
|
+
if (Nt(A))
|
|
621
|
+
return A;
|
|
622
|
+
A && (x = [
|
|
623
|
+
...x,
|
|
624
|
+
...Array.from(A.childNodes).reverse()
|
|
625
|
+
]);
|
|
626
|
+
}
|
|
627
|
+
return null;
|
|
628
|
+
}
|
|
629
|
+
function Z() {
|
|
630
|
+
u.removeEventListeners({
|
|
631
|
+
onStart: w
|
|
632
|
+
}), l.removeEventListeners({
|
|
633
|
+
onStart: w
|
|
634
|
+
}), b.removeEventListeners({
|
|
635
|
+
onStart: w
|
|
636
|
+
}), s.forEach((f) => {
|
|
637
|
+
f.removeEventListeners({
|
|
638
|
+
onStart: w
|
|
639
|
+
});
|
|
640
|
+
}), v.removeEventListeners({
|
|
641
|
+
onStart: k,
|
|
642
|
+
onMove: S,
|
|
643
|
+
onEnd: C
|
|
644
|
+
}), window.removeEventListener("click", E);
|
|
645
|
+
}
|
|
646
|
+
return {
|
|
647
|
+
attachEventListeners: M,
|
|
648
|
+
clearEventListeners: Z
|
|
649
|
+
};
|
|
650
|
+
}
|
|
651
|
+
class Qt {
|
|
652
|
+
constructor() {
|
|
653
|
+
G(this, "animationId"), G(this, "isInProgress"), G(this, "startedAt"), this.animationId = null, this.isInProgress = !1, this.startedAt = null;
|
|
654
|
+
}
|
|
655
|
+
/**
|
|
656
|
+
*
|
|
657
|
+
* @param renderFrame- Function to render screen using the animation progress percentage.
|
|
658
|
+
* @param duration- Duration of the animation, in MS.
|
|
659
|
+
*/
|
|
660
|
+
start(e, n, o = !1) {
|
|
661
|
+
this.isInProgress = !0;
|
|
662
|
+
const i = (r) => {
|
|
663
|
+
this.startedAt || (this.startedAt = r);
|
|
664
|
+
const c = r - this.startedAt, a = n === 0 ? 1 : z(c / n, 2), m = a >= 1 && !o;
|
|
665
|
+
e(a), m ? this.stop() : this.animationId = requestAnimationFrame(i);
|
|
666
|
+
};
|
|
667
|
+
this.animationId = requestAnimationFrame(i);
|
|
668
|
+
}
|
|
669
|
+
stop() {
|
|
670
|
+
this.isInProgress = !1, this.startedAt = null, L(this.animationId) && cancelAnimationFrame(this.animationId);
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
function Zt(t) {
|
|
674
|
+
const {
|
|
675
|
+
startY: e,
|
|
676
|
+
endY: n,
|
|
677
|
+
bottomSheetContainer: o,
|
|
678
|
+
animationFrame: i,
|
|
679
|
+
onEnd: r,
|
|
680
|
+
animationTimingFunction: c,
|
|
681
|
+
animationDuration: a
|
|
682
|
+
} = t, m = Ct(e, n);
|
|
683
|
+
i.stop();
|
|
684
|
+
let u = !1;
|
|
685
|
+
i.start((l) => {
|
|
686
|
+
V(o, {
|
|
687
|
+
y: e + m * c(l)
|
|
688
|
+
}), !u && l >= 1 && (r == null || r(), u = !0);
|
|
689
|
+
}, a);
|
|
690
|
+
}
|
|
691
|
+
const at = (t, e) => (n) => {
|
|
692
|
+
Zt({
|
|
693
|
+
...n,
|
|
694
|
+
animationTimingFunction: t,
|
|
695
|
+
animationDuration: e
|
|
696
|
+
});
|
|
697
|
+
}, N = {
|
|
698
|
+
TOP: "top",
|
|
699
|
+
MIDDLE: "middle",
|
|
700
|
+
CONTENT_HEIGHT: "content-height",
|
|
701
|
+
CLOSED: "closed"
|
|
702
|
+
};
|
|
703
|
+
function Jt(t) {
|
|
704
|
+
return !(!L(t) || t > 1 || t < 0);
|
|
705
|
+
}
|
|
706
|
+
function te(t, e) {
|
|
707
|
+
const n = {
|
|
708
|
+
set(o, i, r, c) {
|
|
709
|
+
return e(i, r), Reflect.set(o, i, r, c);
|
|
710
|
+
}
|
|
711
|
+
};
|
|
712
|
+
return new Proxy(t, n);
|
|
713
|
+
}
|
|
714
|
+
function ee(...t) {
|
|
715
|
+
console.error(t);
|
|
716
|
+
}
|
|
717
|
+
const R = {
|
|
718
|
+
EASE: "ease",
|
|
719
|
+
EASE_IN: "ease-in",
|
|
720
|
+
EASE_OUT: "ease-out",
|
|
721
|
+
EASE_IN_OUT: "ease-in-out",
|
|
722
|
+
SPRING: "spring"
|
|
723
|
+
};
|
|
724
|
+
function ne(t) {
|
|
725
|
+
for (const e of Object.values(R))
|
|
726
|
+
if (e === t)
|
|
727
|
+
return !0;
|
|
728
|
+
return !1;
|
|
729
|
+
}
|
|
730
|
+
function Ht(t) {
|
|
731
|
+
return !!(t instanceof Object && "p1x" in t && "p1y" in t && "p2x" in t && "p2y" in t && L(t.p1x) && L(t.p1y) && L(t.p2x) && L(t.p2y));
|
|
732
|
+
}
|
|
733
|
+
function W(t, e, n, o) {
|
|
734
|
+
return function(a) {
|
|
735
|
+
return c(i(a));
|
|
736
|
+
};
|
|
737
|
+
function i(a) {
|
|
738
|
+
let m = 0, u = 1, l = a, b;
|
|
739
|
+
if (a === 0 || a === 1)
|
|
740
|
+
return a;
|
|
741
|
+
for (; m < u; ) {
|
|
742
|
+
if (b = r(l), Math.abs(b - a) < 1e-3)
|
|
743
|
+
return l;
|
|
744
|
+
a > b ? m = l : u = l, l = (u + m) / 2;
|
|
745
|
+
}
|
|
746
|
+
return l;
|
|
747
|
+
}
|
|
748
|
+
function r(a) {
|
|
749
|
+
return 3 * t * a * Math.pow(1 - a, 2) + 3 * n * Math.pow(a, 2) * (1 - a) + Math.pow(a, 3);
|
|
750
|
+
}
|
|
751
|
+
function c(a) {
|
|
752
|
+
return 3 * e * a * Math.pow(1 - a, 2) + 3 * o * Math.pow(a, 2) * (1 - a) + Math.pow(a, 3);
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
const oe = W(0.25, 0.1, 0.25, 1), re = W(0.42, 0, 1, 1), kt = W(0.42, 0, 0.58, 1), gt = W(0.4, 0.1, 0.6, 1), ie = W(0.45, 1.5, 0.55, 1);
|
|
756
|
+
function ae(t) {
|
|
757
|
+
switch (t) {
|
|
758
|
+
case R.EASE:
|
|
759
|
+
return oe;
|
|
760
|
+
case R.EASE_IN:
|
|
761
|
+
return re;
|
|
762
|
+
case R.EASE_OUT:
|
|
763
|
+
return kt;
|
|
764
|
+
case R.EASE_IN_OUT:
|
|
765
|
+
return gt;
|
|
766
|
+
case R.SPRING:
|
|
767
|
+
return ie;
|
|
768
|
+
default:
|
|
769
|
+
return gt;
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
function bt(t) {
|
|
773
|
+
return typeof t == "boolean";
|
|
774
|
+
}
|
|
775
|
+
const se = {
|
|
776
|
+
ariaLabel: "Bottom sheet",
|
|
777
|
+
content: "",
|
|
778
|
+
defaultPosition: N.CONTENT_HEIGHT,
|
|
779
|
+
marginTop: 20,
|
|
780
|
+
snapPoints: [],
|
|
781
|
+
width: "92%",
|
|
782
|
+
dragTriggers: [],
|
|
783
|
+
beforeOpen: () => {
|
|
784
|
+
},
|
|
785
|
+
afterOpen: () => {
|
|
786
|
+
},
|
|
787
|
+
beforeClose: () => {
|
|
788
|
+
},
|
|
789
|
+
afterClose: () => {
|
|
790
|
+
},
|
|
791
|
+
onDragStart: () => {
|
|
792
|
+
},
|
|
793
|
+
onDragMove: () => {
|
|
794
|
+
},
|
|
795
|
+
onDragEnd: () => {
|
|
796
|
+
},
|
|
797
|
+
expandable: !0,
|
|
798
|
+
draggable: !0,
|
|
799
|
+
backgroundDraggable: !0,
|
|
800
|
+
shouldCloseOnOutsideClick: !0,
|
|
801
|
+
shouldShowBackdrop: !0,
|
|
802
|
+
shouldShowHandle: !0,
|
|
803
|
+
backDropTransition: null,
|
|
804
|
+
backdropColor: null,
|
|
805
|
+
containerBorderRadius: null,
|
|
806
|
+
rootClass: null,
|
|
807
|
+
containerClass: null,
|
|
808
|
+
handleClass: null,
|
|
809
|
+
contentWrapperClass: null,
|
|
810
|
+
backdropClass: null,
|
|
811
|
+
draggingAnimationTimings: "ease-in-out",
|
|
812
|
+
draggingAnimationDuration: 180
|
|
813
|
+
};
|
|
814
|
+
function ce(t) {
|
|
815
|
+
const e = {
|
|
816
|
+
...se
|
|
817
|
+
}, n = Object.entries(t).reduce(
|
|
818
|
+
(o, i) => {
|
|
819
|
+
const [r, c] = i;
|
|
820
|
+
return it(c) && (o[r] = c), o;
|
|
821
|
+
},
|
|
822
|
+
{}
|
|
823
|
+
);
|
|
824
|
+
return {
|
|
825
|
+
...e,
|
|
826
|
+
...n
|
|
827
|
+
};
|
|
828
|
+
}
|
|
829
|
+
function st(t) {
|
|
830
|
+
if (Ht(t)) {
|
|
831
|
+
const { p1x: e, p1y: n, p2x: o, p2y: i } = t;
|
|
832
|
+
return W(e, n, o, i);
|
|
833
|
+
}
|
|
834
|
+
return ne(t) ? ae(t) : kt;
|
|
835
|
+
}
|
|
836
|
+
function le(t, e, n) {
|
|
837
|
+
function o(i, r) {
|
|
838
|
+
switch (i) {
|
|
839
|
+
case "content":
|
|
840
|
+
H(r) && (t.bottomSheetContentWrapper.innerHTML = r);
|
|
841
|
+
break;
|
|
842
|
+
case "width":
|
|
843
|
+
H(r) && (t.bottomSheetContainer.style.width = r);
|
|
844
|
+
break;
|
|
845
|
+
case "shouldShowHandle":
|
|
846
|
+
bt(r) || X(t.bottomSheetHandle, !1);
|
|
847
|
+
break;
|
|
848
|
+
case "shouldShowBackdrop":
|
|
849
|
+
bt(r) || X(t.bottomSheetBackdrop, !1);
|
|
850
|
+
break;
|
|
851
|
+
case "containerBorderRadius":
|
|
852
|
+
H(r) && (t.bottomSheetContainer.style.borderRadius = r);
|
|
853
|
+
break;
|
|
854
|
+
case "backdropColor":
|
|
855
|
+
H(r) && (t.bottomSheetBackdrop.style.backgroundColor = r);
|
|
856
|
+
break;
|
|
857
|
+
case "backDropTransition":
|
|
858
|
+
H(r) && (t.bottomSheetBackdrop.style.transition = r);
|
|
859
|
+
break;
|
|
860
|
+
case "rootClass":
|
|
861
|
+
if (!H(r))
|
|
862
|
+
return;
|
|
863
|
+
U(
|
|
864
|
+
t.bottomSheetRoot,
|
|
865
|
+
n.rootClass,
|
|
866
|
+
r
|
|
867
|
+
);
|
|
868
|
+
break;
|
|
869
|
+
case "containerClass":
|
|
870
|
+
if (!H(r))
|
|
871
|
+
return;
|
|
872
|
+
U(
|
|
873
|
+
t.bottomSheetContainer,
|
|
874
|
+
n.containerClass,
|
|
875
|
+
r
|
|
876
|
+
);
|
|
877
|
+
break;
|
|
878
|
+
case "handleClass":
|
|
879
|
+
if (!H(r))
|
|
880
|
+
return;
|
|
881
|
+
U(
|
|
882
|
+
t.bottomSheetHandle,
|
|
883
|
+
n.handleClass,
|
|
884
|
+
r
|
|
885
|
+
);
|
|
886
|
+
break;
|
|
887
|
+
case "contentWrapperClass":
|
|
888
|
+
if (!H(r))
|
|
889
|
+
return;
|
|
890
|
+
U(
|
|
891
|
+
t.bottomSheetContentWrapper,
|
|
892
|
+
n.contentWrapperClass,
|
|
893
|
+
r
|
|
894
|
+
);
|
|
895
|
+
break;
|
|
896
|
+
case "backdropClass":
|
|
897
|
+
if (!H(r))
|
|
898
|
+
return;
|
|
899
|
+
U(
|
|
900
|
+
t.bottomSheetBackdrop,
|
|
901
|
+
n.backdropClass,
|
|
902
|
+
r
|
|
903
|
+
);
|
|
904
|
+
break;
|
|
905
|
+
case "draggingAnimationTimings":
|
|
906
|
+
if (Ht(r)) {
|
|
907
|
+
const c = st(r), a = at(
|
|
908
|
+
c,
|
|
909
|
+
n.draggingAnimationDuration
|
|
910
|
+
);
|
|
911
|
+
e.translateContainer = a;
|
|
912
|
+
}
|
|
913
|
+
break;
|
|
914
|
+
case "draggingAnimationDuration":
|
|
915
|
+
if (L(r)) {
|
|
916
|
+
const c = st(
|
|
917
|
+
n.draggingAnimationTimings
|
|
918
|
+
), a = at(
|
|
919
|
+
c,
|
|
920
|
+
r
|
|
921
|
+
);
|
|
922
|
+
e.translateContainer = a;
|
|
923
|
+
}
|
|
924
|
+
break;
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
return o;
|
|
928
|
+
}
|
|
929
|
+
function ue(t) {
|
|
930
|
+
const e = ce(t), n = st(
|
|
931
|
+
t.draggingAnimationTimings
|
|
932
|
+
), o = {
|
|
933
|
+
isMounted: !1,
|
|
934
|
+
translateContainer: at(
|
|
935
|
+
n,
|
|
936
|
+
e.draggingAnimationDuration
|
|
937
|
+
)
|
|
938
|
+
}, i = {
|
|
939
|
+
startY: null,
|
|
940
|
+
containerStartTranslate: {
|
|
941
|
+
x: 0,
|
|
942
|
+
y: 0
|
|
943
|
+
},
|
|
944
|
+
isDragging: !1,
|
|
945
|
+
originalDocumentOverflowY: document.body.style.overflowY
|
|
946
|
+
}, r = new Qt(), c = {
|
|
947
|
+
animationFrame: r,
|
|
948
|
+
onClose: C,
|
|
949
|
+
bottomSheetState: o,
|
|
950
|
+
draggingState: i,
|
|
951
|
+
snapTo: P,
|
|
952
|
+
moveUp: A,
|
|
953
|
+
moveDown: J
|
|
954
|
+
}, { elements: a, eventHandlers: m } = qt(
|
|
955
|
+
e,
|
|
956
|
+
c
|
|
957
|
+
), u = te(
|
|
958
|
+
e,
|
|
959
|
+
le(a, o, e)
|
|
960
|
+
), { bottomSheetBackdrop: l, bottomSheetRoot: b, bottomSheetContainer: s } = a, v = (d) => {
|
|
961
|
+
const p = d ?? window.document.body;
|
|
962
|
+
p.appendChild(b), p.appendChild(l);
|
|
963
|
+
const h = window.innerHeight;
|
|
964
|
+
V(s, {
|
|
965
|
+
y: h
|
|
966
|
+
}), m.attachEventListeners(), o.isMounted = !0;
|
|
967
|
+
}, k = () => {
|
|
968
|
+
m.clearEventListeners(), Object.values(a).forEach((d) => {
|
|
969
|
+
d.remove();
|
|
970
|
+
}), o.isMounted = !1;
|
|
971
|
+
}, S = () => {
|
|
972
|
+
var d;
|
|
973
|
+
if (E() || ee(
|
|
974
|
+
'Bottom Sheet is not mounted yet. call the "mount" method first.'
|
|
975
|
+
), (d = t.beforeOpen) == null || d.call(t), w())
|
|
976
|
+
return;
|
|
977
|
+
u.shouldShowBackdrop && et(l, !0), et([s], !0), V(s, {
|
|
978
|
+
y: s.clientHeight
|
|
979
|
+
});
|
|
980
|
+
const p = window.innerHeight, h = dt(
|
|
981
|
+
p,
|
|
982
|
+
s.clientHeight,
|
|
983
|
+
u.marginTop,
|
|
984
|
+
u.defaultPosition
|
|
985
|
+
), g = D(s).y;
|
|
986
|
+
o.translateContainer({
|
|
987
|
+
startY: g,
|
|
988
|
+
endY: h,
|
|
989
|
+
animationFrame: r,
|
|
990
|
+
bottomSheetContainer: s,
|
|
991
|
+
onEnd: t.afterOpen
|
|
992
|
+
}), a.bottomSheetHandle.focus();
|
|
993
|
+
};
|
|
994
|
+
function C() {
|
|
995
|
+
var d;
|
|
996
|
+
if (M())
|
|
997
|
+
return;
|
|
998
|
+
(d = t.beforeClose) == null || d.call(t);
|
|
999
|
+
const p = D(s).y, h = s.clientHeight;
|
|
1000
|
+
o.translateContainer({
|
|
1001
|
+
startY: p,
|
|
1002
|
+
endY: h,
|
|
1003
|
+
animationFrame: r,
|
|
1004
|
+
bottomSheetContainer: s,
|
|
1005
|
+
onEnd: () => {
|
|
1006
|
+
var g;
|
|
1007
|
+
(g = t.afterClose) == null || g.call(t), et([l, s], !1);
|
|
1008
|
+
}
|
|
1009
|
+
});
|
|
1010
|
+
}
|
|
1011
|
+
function E() {
|
|
1012
|
+
return o.isMounted;
|
|
1013
|
+
}
|
|
1014
|
+
function w() {
|
|
1015
|
+
const d = D(s).y, p = window.innerHeight, h = s.clientHeight >= p ? p : s.clientHeight;
|
|
1016
|
+
return d < h;
|
|
1017
|
+
}
|
|
1018
|
+
function M() {
|
|
1019
|
+
return !w();
|
|
1020
|
+
}
|
|
1021
|
+
function Q() {
|
|
1022
|
+
const d = D(s).y, p = s.clientHeight, h = window.innerHeight;
|
|
1023
|
+
if (d <= 5 && d >= -5)
|
|
1024
|
+
return N.CONTENT_HEIGHT;
|
|
1025
|
+
const g = p - d;
|
|
1026
|
+
if (g === h / 2)
|
|
1027
|
+
return N.MIDDLE;
|
|
1028
|
+
const T = h - u.marginTop, O = 10;
|
|
1029
|
+
return g <= T + O && g >= T - O ? N.TOP : N.CLOSED;
|
|
1030
|
+
}
|
|
1031
|
+
function Z() {
|
|
1032
|
+
return s.clientHeight;
|
|
1033
|
+
}
|
|
1034
|
+
function f(d) {
|
|
1035
|
+
const p = D(s).y, h = s.clientHeight - p, g = window.innerHeight - d, T = Ft(h, g), O = q(h, g);
|
|
1036
|
+
o.translateContainer({
|
|
1037
|
+
startY: p,
|
|
1038
|
+
endY: p + (T.isUp ? -O : O),
|
|
1039
|
+
animationFrame: r,
|
|
1040
|
+
bottomSheetContainer: s
|
|
1041
|
+
});
|
|
1042
|
+
}
|
|
1043
|
+
function x(d, {
|
|
1044
|
+
viewportHeight: p,
|
|
1045
|
+
visibleHeight: h
|
|
1046
|
+
}) {
|
|
1047
|
+
let g = null;
|
|
1048
|
+
for (const T of d) {
|
|
1049
|
+
const O = T * p, Y = q(
|
|
1050
|
+
h,
|
|
1051
|
+
O
|
|
1052
|
+
);
|
|
1053
|
+
(g === null || Y < g) && (g = Y);
|
|
1054
|
+
}
|
|
1055
|
+
return {
|
|
1056
|
+
minOffset: g
|
|
1057
|
+
};
|
|
1058
|
+
}
|
|
1059
|
+
function A() {
|
|
1060
|
+
const d = [...u.snapPoints].reverse(), p = D(s).y, h = s.clientHeight, g = h - p;
|
|
1061
|
+
if (!u.expandable && g >= h)
|
|
1062
|
+
return;
|
|
1063
|
+
const T = window.innerHeight, O = pt(
|
|
1064
|
+
"above",
|
|
1065
|
+
{ visibleHeight: g, viewportHeight: T },
|
|
1066
|
+
d
|
|
1067
|
+
), { minOffset: Y } = x(O, {
|
|
1068
|
+
visibleHeight: g,
|
|
1069
|
+
viewportHeight: T
|
|
1070
|
+
});
|
|
1071
|
+
if (Y === null && g < T - u.marginTop) {
|
|
1072
|
+
o.translateContainer({
|
|
1073
|
+
startY: p,
|
|
1074
|
+
endY: dt(
|
|
1075
|
+
T,
|
|
1076
|
+
h,
|
|
1077
|
+
u.marginTop,
|
|
1078
|
+
"top"
|
|
1079
|
+
),
|
|
1080
|
+
animationFrame: r,
|
|
1081
|
+
bottomSheetContainer: s
|
|
1082
|
+
});
|
|
1083
|
+
return;
|
|
1084
|
+
}
|
|
1085
|
+
L(Y) && o.translateContainer({
|
|
1086
|
+
startY: p,
|
|
1087
|
+
endY: p - Y,
|
|
1088
|
+
animationFrame: r,
|
|
1089
|
+
bottomSheetContainer: s
|
|
1090
|
+
});
|
|
1091
|
+
}
|
|
1092
|
+
function J() {
|
|
1093
|
+
const d = D(s).y, p = s.clientHeight - d;
|
|
1094
|
+
if (p < 1)
|
|
1095
|
+
return;
|
|
1096
|
+
const h = window.innerHeight, g = pt(
|
|
1097
|
+
"below",
|
|
1098
|
+
{ visibleHeight: p, viewportHeight: h },
|
|
1099
|
+
u.snapPoints
|
|
1100
|
+
), { minOffset: T } = x(g, {
|
|
1101
|
+
visibleHeight: p,
|
|
1102
|
+
viewportHeight: h
|
|
1103
|
+
});
|
|
1104
|
+
L(T) && o.translateContainer({
|
|
1105
|
+
startY: d,
|
|
1106
|
+
endY: d + T,
|
|
1107
|
+
animationFrame: r,
|
|
1108
|
+
bottomSheetContainer: s
|
|
1109
|
+
});
|
|
1110
|
+
}
|
|
1111
|
+
function P(d) {
|
|
1112
|
+
const p = window.innerHeight;
|
|
1113
|
+
if (!Jt(d))
|
|
1114
|
+
return;
|
|
1115
|
+
const h = z(p * d, 2);
|
|
1116
|
+
f(h);
|
|
1117
|
+
}
|
|
1118
|
+
return {
|
|
1119
|
+
props: u,
|
|
1120
|
+
elements: a,
|
|
1121
|
+
mount: v,
|
|
1122
|
+
unmount: k,
|
|
1123
|
+
open: S,
|
|
1124
|
+
close: C,
|
|
1125
|
+
getIsMounted: E,
|
|
1126
|
+
getIsOpen: w,
|
|
1127
|
+
getIsClosed: M,
|
|
1128
|
+
getPosition: Q,
|
|
1129
|
+
getHeight: Z,
|
|
1130
|
+
moveTo: f,
|
|
1131
|
+
snapTo: P
|
|
1132
|
+
};
|
|
1133
|
+
}
|
|
1134
|
+
function de() {
|
|
1135
|
+
return {
|
|
1136
|
+
elements: {
|
|
1137
|
+
bottomSheetRoot: void 0,
|
|
1138
|
+
bottomSheetBackdrop: void 0,
|
|
1139
|
+
bottomSheetContainer: void 0,
|
|
1140
|
+
bottomSheetHandle: void 0,
|
|
1141
|
+
bottomSheetHandleBar: void 0,
|
|
1142
|
+
bottomSheetContentWrapper: void 0,
|
|
1143
|
+
bottomSheetContainerGapFiller: void 0
|
|
1144
|
+
},
|
|
1145
|
+
mount: () => {
|
|
1146
|
+
},
|
|
1147
|
+
unmount: () => {
|
|
1148
|
+
},
|
|
1149
|
+
open: () => {
|
|
1150
|
+
},
|
|
1151
|
+
close: () => {
|
|
1152
|
+
},
|
|
1153
|
+
getIsMounted: () => !1,
|
|
1154
|
+
getHeight: () => 0,
|
|
1155
|
+
getIsOpen: () => !1,
|
|
1156
|
+
getIsClosed: () => !0,
|
|
1157
|
+
getPosition: () => N.CLOSED,
|
|
1158
|
+
moveTo: () => {
|
|
1159
|
+
},
|
|
1160
|
+
snapTo: () => {
|
|
1161
|
+
},
|
|
1162
|
+
props: {
|
|
1163
|
+
content: ""
|
|
1164
|
+
}
|
|
1165
|
+
};
|
|
1166
|
+
}
|
|
1167
|
+
const pe = de(), fe = Lt(function(e, n) {
|
|
1168
|
+
const {
|
|
1169
|
+
children: o,
|
|
1170
|
+
isOpen: i,
|
|
1171
|
+
setIsOpen: r,
|
|
1172
|
+
afterClose: c,
|
|
1173
|
+
mountingPoint: a,
|
|
1174
|
+
...m
|
|
1175
|
+
} = e, u = ct(pe), [l, b] = xt(
|
|
1176
|
+
u.current
|
|
1177
|
+
);
|
|
1178
|
+
At(
|
|
1179
|
+
n,
|
|
1180
|
+
() => l,
|
|
1181
|
+
[l]
|
|
1182
|
+
);
|
|
1183
|
+
const s = Ot(() => {
|
|
1184
|
+
r(!1), c == null || c();
|
|
1185
|
+
}, [c]);
|
|
1186
|
+
tt(() => {
|
|
1187
|
+
i ? l.open() : l.close();
|
|
1188
|
+
}, [i]);
|
|
1189
|
+
const v = ct(null);
|
|
1190
|
+
return tt(
|
|
1191
|
+
function() {
|
|
1192
|
+
const S = Pt(e.mountingPoint) ? e.mountingPoint : window.document.body;
|
|
1193
|
+
if (!S || l.getIsMounted())
|
|
1194
|
+
return;
|
|
1195
|
+
const C = ue({
|
|
1196
|
+
content: "",
|
|
1197
|
+
...m,
|
|
1198
|
+
afterClose: s
|
|
1199
|
+
});
|
|
1200
|
+
return C.mount(S), v.current = C.elements.bottomSheetContentWrapper ?? null, u.current = C, b(C), () => {
|
|
1201
|
+
l.unmount();
|
|
1202
|
+
};
|
|
1203
|
+
},
|
|
1204
|
+
[e.mountingPoint, m, s]
|
|
1205
|
+
), tt(
|
|
1206
|
+
function() {
|
|
1207
|
+
Object.assign(u.current.props, {
|
|
1208
|
+
...m
|
|
1209
|
+
}), b(u.current);
|
|
1210
|
+
},
|
|
1211
|
+
[m]
|
|
1212
|
+
), v.current ? Dt(e.children, v.current) : null;
|
|
1213
|
+
});
|
|
1214
|
+
export {
|
|
1215
|
+
fe as ReactPlainBottomSheet,
|
|
1216
|
+
de as createPlaceholderBottomSheet
|
|
1217
|
+
};
|