@plainsheet/react 0.4.1 → 0.4.4

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