@plainsheet/react 0.4.5 → 0.4.8

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