@plainsheet/react 0.2.1 → 0.3.1

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