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