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