@plainsheet/core 0.7.8 → 0.7.10

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,8 +1,8 @@
1
1
  (function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode('.pbs-root{position:fixed;left:0;bottom:0;display:flex;flex-direction:column;align-items:center;justify-content:flex-start;width:100%;height:fit-content;max-height:100vh;z-index:2}.pbs-dialog-reset{background-color:transparent;color:inherit;border:none;outline:none;padding:0;margin:0}.pbs-backdrop{position:fixed;top:0;left:0;width:100%;height:100%;background-color:transparent;z-index:1;transition:background-color .2s ease-out}.pbs-backdrop.hidden{visibility:hidden}.pbs-backdrop.open{background-color:#454545b3}.pbs-backdrop.transparent{background-color:transparent}.pbs-container{--pbs-container-background-color: rgb(240, 240, 240);background-color:var(--pbs-container-background-color);position:relative;display:none;flex-direction:column;align-items:center;justify-content:flex-start;width:92%;height:fit-content;max-height:100vh;border-radius:10px 10px 0 0}.pbs-container.open{display:flex}.pbs-container .pbs-gap-filler{position:absolute;bottom:calc(-100vh + .5px);left:0;background-color:var(--pbs-container-background-color);content:"";width:100%;height:100vh}.pbs-handle{position:relative;display:flex;align-items:center;justify-content:center;width:100%;height:30px;cursor:pointer}.pbs-handle.hidden{display:none}.pbs-button-reset{background-color:transparent;-webkit-appearance:none;-moz-appearance:none;appearance:none;outline:none;border:none}button:focus.pbs-button-reset{outline:none}.pbs-handle-bar{background-color:#a8a8a8;position:relative;width:12%;height:7px;border-radius:12px}.pbs-handle-bar.hidden{display:none}.pbs-content-wrapper{position:relative;width:100%;height:fit-content;max-height:100%;overflow-y:scroll}.pbs-content-wrapper::-webkit-scrollbar{display:none}.example{-ms-overflow-style:none;scrollbar-width:none}')),document.head.appendChild(e)}}catch(n){console.error("vite-plugin-css-injected-by-js",n)}})();
2
- var kt = Object.defineProperty;
3
- var At = (t, n, e) => n in t ? kt(t, n, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[n] = e;
2
+ var Lt = Object.defineProperty;
3
+ var At = (t, n, e) => n in t ? Lt(t, n, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[n] = e;
4
4
  var j = (t, n, e) => At(t, typeof n != "symbol" ? n + "" : n, e);
5
- function O(t) {
5
+ function H(t) {
6
6
  return typeof t == "string";
7
7
  }
8
8
  function Bt(t, n) {
@@ -14,11 +14,11 @@ function $(t, n) {
14
14
  function rt(t, n) {
15
15
  t.classList.remove(Z(n));
16
16
  }
17
- function W(t, n, e) {
18
- O(e) && (O(n) && rt(t, n), $(t, e));
17
+ function U(t, n, e) {
18
+ H(e) && (H(n) && rt(t, n), $(t, e));
19
19
  }
20
20
  function Z(t) {
21
- return O(t) ? t.trim().replace(/\./g, "") : "";
21
+ return H(t) ? t.trim().replace(/\./g, "") : "";
22
22
  }
23
23
  function M(t) {
24
24
  return t.map((n) => Z(n)).filter(Boolean).join(" ");
@@ -40,17 +40,17 @@ function et(t, n) {
40
40
  function q(t, n) {
41
41
  n ? ($(t, lt), rt(t, ut)) : ($(t, ut), rt(t, lt));
42
42
  }
43
- function Tt(t) {
43
+ function yt(t) {
44
44
  return t instanceof HTMLElement;
45
45
  }
46
46
  function Y(t) {
47
47
  return typeof t == "number" && !Number.isNaN(t);
48
48
  }
49
49
  function Yt(t) {
50
- Tt(t) && t.focus();
50
+ yt(t) && t.focus();
51
51
  }
52
52
  function It(t) {
53
- if (!Tt(t) || t.offsetParent === null || "disabled" in t && t.disabled)
53
+ if (!yt(t) || t.offsetParent === null || "disabled" in t && t.disabled)
54
54
  return !1;
55
55
  const e = t.getAttribute("tabindex"), r = Y(e) ? parseInt(e, 10) : -1, i = [
56
56
  "INPUT",
@@ -63,17 +63,17 @@ function It(t) {
63
63
  ].includes(t.tagName), a = t instanceof HTMLAnchorElement && t.href !== "" || t instanceof HTMLAreaElement && t.href !== "";
64
64
  return i || a || r > -1;
65
65
  }
66
- var C = /* @__PURE__ */ ((t) => (t.Backdrop = "pbs-backdrop", t.Root = "pbs-root", t.Container = "pbs-container", t.GapFiller = "pbs-gap-filler", t.Handle = "pbs-handle", t.HandleBar = "pbs-handle-bar", t.ContentWrapper = "pbs-content-wrapper", t))(C || {}), ot = /* @__PURE__ */ ((t) => (t.Button = "pbs-button-reset", t.Dialog = "pbs-dialog-reset", t))(ot || {}), K = /* @__PURE__ */ ((t) => (t.Hidden = "hidden", t))(K || {});
66
+ 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 || {}), ot = /* @__PURE__ */ ((t) => (t.Button = "pbs-button-reset", t.Dialog = "pbs-dialog-reset", t))(ot || {}), K = /* @__PURE__ */ ((t) => (t.Hidden = "hidden", t))(K || {});
67
67
  function x(t, n, e) {
68
68
  const r = document.createElement(t);
69
69
  return n.split(" ").forEach((i) => {
70
70
  $(r, i);
71
- }), O(e) && r.setAttribute("data-testid", e), r;
71
+ }), H(e) && r.setAttribute("data-testid", e), r;
72
72
  }
73
73
  const sn = {
74
74
  CONTENTS_WRAPPER: Dt([
75
- C.Root,
76
- C.ContentWrapper
75
+ T.Root,
76
+ T.ContentWrapper
77
77
  ])
78
78
  };
79
79
  function dt(t, n, e, r) {
@@ -88,7 +88,7 @@ function dt(t, n, e, r) {
88
88
  return 0;
89
89
  }
90
90
  }
91
- function yt(t, n) {
91
+ function Ct(t, n) {
92
92
  const e = n < t, r = n > t;
93
93
  return {
94
94
  isUp: e,
@@ -96,10 +96,10 @@ function yt(t, n) {
96
96
  stayedSame: n === t
97
97
  };
98
98
  }
99
- function Ct(t, n) {
99
+ function Tt(t, n) {
100
100
  return n < t ? -(t - n) : n - t;
101
101
  }
102
- function V(t, n) {
102
+ function W(t, n) {
103
103
  return t > n ? t - n : n - t;
104
104
  }
105
105
  function xt(t, n) {
@@ -151,7 +151,7 @@ function I(t) {
151
151
  e,
152
152
  it
153
153
  );
154
- return Ht(r ?? {
154
+ return St(r ?? {
155
155
  type: it,
156
156
  values: []
157
157
  });
@@ -165,7 +165,7 @@ function Q(t, { x: n, y: e }) {
165
165
  it
166
166
  );
167
167
  if (i) {
168
- const a = Ht(i);
168
+ const a = St(i);
169
169
  t.style.transform = `translate(${n ?? a.x ?? 0}px,${e ?? a.y ?? 0}px)`;
170
170
  return;
171
171
  }
@@ -175,7 +175,7 @@ function Q(t, { x: n, y: e }) {
175
175
  }
176
176
  t.style.transform = `translate(${n ?? 0}px,${e ?? 0}px)`;
177
177
  }
178
- function Ht(t) {
178
+ function St(t) {
179
179
  if (t.type !== "translate")
180
180
  throw new Error(
181
181
  `Could not get coordinates from ${t.type}, since is not translate.`
@@ -195,11 +195,11 @@ function ht(t, {
195
195
  }) {
196
196
  return at(e) && t >= e ? e : at(n) && t <= n ? n : t;
197
197
  }
198
- const Pt = (t, n, e) => {
199
- n instanceof HTMLElement && !Bt(n, C.Handle) && e.scrollTop >= 1 || (t.isDragging = !0);
198
+ const Ft = (t, n, e) => {
199
+ n instanceof HTMLElement && !Bt(n, T.Handle) && e.scrollTop >= 1 || (t.isDragging = !0);
200
200
  }, Mt = (t, n, e, r) => (o) => {
201
201
  r.startY = t.getCoordinates(o).y, r.containerStartTranslate = I(n), e.onDragStart();
202
- }, Ft = (t, n, e, r, o) => (i) => {
202
+ }, Pt = (t, n, e, r, o) => (i) => {
203
203
  Rt(
204
204
  i,
205
205
  t,
@@ -213,31 +213,31 @@ const Pt = (t, n, e) => {
213
213
  function Rt(t, n, e, r, o, i, a) {
214
214
  if (!r.isDragging || !Y(r.startY))
215
215
  return;
216
- const u = n.getCoordinates(t).y, s = Ct(r.startY, u), b = window.innerHeight, l = i.clientHeight, f = l - (r.containerStartTranslate.y + s);
217
- if (f >= b)
216
+ const u = n.getCoordinates(t).y, s = Tt(r.startY, u), b = window.innerHeight, l = i.clientHeight, d = l - (r.containerStartTranslate.y + s);
217
+ if (d >= b)
218
218
  return;
219
- const p = yt(r.startY, u);
220
- if (p.isUp && !e.expandable && f >= l || e.preventClosing && f <= l)
219
+ const y = Ct(r.startY, u);
220
+ if (y.isUp && !e.expandable && d >= l || e.preventClosing && d <= l)
221
221
  return;
222
222
  o.start(() => {
223
223
  Q(i, {
224
224
  y: r.containerStartTranslate.y + s
225
225
  });
226
226
  }, 0);
227
- const w = b - a, c = l - r.containerStartTranslate.y;
228
- if (p.isUp) {
229
- const T = w - c, H = w - f, L = ht(
230
- 1 - J(H / T, 2),
227
+ const E = b - a, c = l - r.containerStartTranslate.y;
228
+ if (y.isUp) {
229
+ const C = E - c, w = E - d, k = ht(
230
+ 1 - J(w / C, 2),
231
231
  {
232
232
  min: 0,
233
233
  max: 1
234
234
  }
235
235
  );
236
- e.onDragMove(p, L);
237
- } else if (p.isDown) {
238
- const T = ht(
236
+ e.onDragMove(y, k);
237
+ } else if (y.isDown) {
238
+ const C = ht(
239
239
  J(
240
- 1 - f / c,
240
+ 1 - d / c,
241
241
  2
242
242
  ),
243
243
  {
@@ -245,57 +245,57 @@ function Rt(t, n, e, r, o, i, a) {
245
245
  max: 1
246
246
  }
247
247
  );
248
- e.onDragMove(p, T);
248
+ e.onDragMove(y, C);
249
249
  }
250
250
  }
251
- const _t = (t, n, e, r, o, i, a) => (u) => {
251
+ const Gt = (t, n, e, r, o, i, a) => (u) => {
252
252
  if (!r.isDragging || (r.isDragging = !1, !Y(r.startY)))
253
253
  return;
254
254
  e.onDragEnd();
255
- const s = r.startY, b = t.getCoordinates(u).y, l = I(n).y, f = yt(s, b), p = window.innerHeight, w = n.clientHeight;
256
- if (f.isUp) {
255
+ const s = r.startY, b = t.getCoordinates(u).y, l = I(n).y, d = Ct(s, b), y = window.innerHeight, E = n.clientHeight;
256
+ if (d.isUp) {
257
257
  const c = [...e.snapPoints].sort(
258
- (L, B) => L - B
259
- ), T = w + -l;
260
- if (!e.expandable && T >= w)
258
+ (k, B) => k - B
259
+ ), C = E + -l;
260
+ if (!e.expandable && C >= E)
261
261
  return;
262
- for (const L of c) {
263
- const B = L * window.innerHeight;
264
- if (T <= B) {
265
- const k = V(
266
- T,
262
+ for (const k of c) {
263
+ const B = k * window.innerHeight;
264
+ if (C <= B) {
265
+ const O = W(
266
+ C,
267
267
  B
268
268
  );
269
269
  a.translateContainer({
270
270
  startY: l,
271
- endY: l - k,
271
+ endY: l - O,
272
272
  animationFrame: o,
273
273
  bottomSheetContainer: n
274
274
  });
275
275
  return;
276
276
  }
277
277
  }
278
- const H = Et(
279
- p,
280
- w,
278
+ const w = Et(
279
+ y,
280
+ E,
281
281
  e.marginTop
282
282
  );
283
283
  a.translateContainer({
284
284
  startY: l,
285
- endY: H,
285
+ endY: w,
286
286
  animationFrame: o,
287
287
  bottomSheetContainer: n
288
288
  });
289
- } else if (f.isDown) {
289
+ } else if (d.isDown) {
290
290
  const c = [...e.snapPoints].sort(
291
- (T, H) => H - T
291
+ (C, w) => w - C
292
292
  );
293
- for (const T of c) {
294
- const H = T * window.innerHeight, L = w + -l;
295
- if (L >= H) {
296
- const B = V(
297
- L,
298
- H
293
+ for (const C of c) {
294
+ const w = C * window.innerHeight, k = E + -l;
295
+ if (k >= w) {
296
+ const B = W(
297
+ k,
298
+ w
299
299
  );
300
300
  a.translateContainer({
301
301
  startY: l,
@@ -307,12 +307,12 @@ const _t = (t, n, e, r, o, i, a) => (u) => {
307
307
  }
308
308
  }
309
309
  if (e.preventClosing) {
310
- const T = w + -l;
311
- if (T >= w) {
312
- const H = V(T, w);
310
+ const C = E + -l;
311
+ if (C >= E) {
312
+ const w = W(C, E);
313
313
  a.translateContainer({
314
314
  startY: l,
315
- endY: l + H,
315
+ endY: l + w,
316
316
  animationFrame: o,
317
317
  bottomSheetContainer: n
318
318
  });
@@ -322,7 +322,7 @@ const _t = (t, n, e, r, o, i, a) => (u) => {
322
322
  i();
323
323
  }
324
324
  };
325
- var _ = /* @__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))(_ || {});
325
+ var G = /* @__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))(G || {});
326
326
  function mt(t) {
327
327
  switch (t) {
328
328
  case 0:
@@ -337,17 +337,17 @@ function mt(t) {
337
337
  return -1;
338
338
  }
339
339
  }
340
- const Ut = {
341
- eventPhase: _.All
340
+ const _t = {
341
+ eventPhase: G.All
342
342
  };
343
- class G {
343
+ class V {
344
344
  constructor(n) {
345
345
  j(this, "currentTarget");
346
346
  this.currentTarget = n;
347
347
  }
348
348
  addEventListeners({
349
349
  onStart: n,
350
- onStartOptions: e = Ut,
350
+ onStartOptions: e = _t,
351
351
  onMove: r,
352
352
  onEnd: o
353
353
  }) {
@@ -362,7 +362,7 @@ class G {
362
362
  n && this.currentTarget.addEventListener(
363
363
  "touchstart",
364
364
  (i) => {
365
- if (e.eventPhase === _.All) {
365
+ if (e.eventPhase === G.All) {
366
366
  n(i);
367
367
  return;
368
368
  }
@@ -382,7 +382,7 @@ class G {
382
382
  n && this.currentTarget.addEventListener(
383
383
  "mousedown",
384
384
  (i) => {
385
- if (e.eventPhase === _.All) {
385
+ if (e.eventPhase === G.All) {
386
386
  n(i);
387
387
  return;
388
388
  }
@@ -433,83 +433,88 @@ class G {
433
433
  };
434
434
  }
435
435
  }
436
- function St(t) {
436
+ function Ht(t) {
437
437
  const n = t;
438
438
  return `${n} ${n} 0px 0px`;
439
439
  }
440
440
  function jt(t, n) {
441
- const e = Wt(t);
442
- Gt(e), e.bottomSheetContainer.style.width = t.width;
441
+ const e = Ut(t);
442
+ Vt(e), e.bottomSheetContainer.style.width = t.width;
443
443
  const r = document.createElement("div");
444
444
  r.innerHTML = t.content ?? "";
445
445
  const o = window.innerHeight;
446
446
  e.bottomSheetContainer.style.maxHeight = `${o}px`, e.bottomSheetContentWrapper.appendChild(r);
447
- const i = Vt({
447
+ const i = Wt({
448
448
  bottomSheetElements: e,
449
449
  bottomSheetProps: t,
450
450
  options: n
451
451
  });
452
- return t.rootStyle && Object.assign(e.bottomSheetRoot.style, t.rootStyle), t.backdropStyle && Object.assign(e.bottomSheetBackdrop.style, t.backdropStyle), t.containerStyle && Object.assign(e.bottomSheetContainer.style, t.containerStyle), t.handleStyle && Object.assign(e.bottomSheetHandleBar.style, t.handleStyle), t.contentWrapperStyle && Object.assign(
452
+ return t.rootStyle && Object.assign(e.bottomSheetRoot.style, t.rootStyle), t.backdropStyle && Object.assign(e.bottomSheetBackdrop.style, t.backdropStyle), t.containerGapFillerStyle && Object.assign(e.bottomSheetContainer.style, t.containerStyle), t.containerStyle && Object.assign(
453
+ e.bottomSheetContainerGapFiller.style,
454
+ t.containerGapFillerStyle
455
+ ), t.handleStyle && Object.assign(e.bottomSheetHandleBar.style, t.handleStyle), t.contentWrapperStyle && Object.assign(
453
456
  e.bottomSheetContentWrapper.style,
454
457
  t.contentWrapperStyle
455
458
  ), { elements: e, eventHandlers: i };
456
459
  }
457
- function Wt(t) {
460
+ function Ut(t) {
458
461
  const n = x(
459
462
  "dialog",
460
463
  M([
461
- C.Root,
464
+ T.Root,
462
465
  ot.Dialog,
463
466
  t.rootClass
464
467
  ]),
465
- C.Root
468
+ T.Root
466
469
  );
467
470
  n.ariaLabel = t.ariaLabel;
468
471
  const e = x(
469
472
  "section",
470
- M([C.Container, t.containerClass]),
471
- C.Container
473
+ M([T.Container, t.containerClass]),
474
+ T.Container
472
475
  );
473
- t.containerBorderRadius && (e.style.borderRadius = St(
476
+ t.containerBorderRadius && (e.style.borderRadius = Ht(
474
477
  t.containerBorderRadius
475
478
  ));
476
479
  const r = x(
477
480
  "div",
478
- C.GapFiller,
479
- C.GapFiller
480
- ), o = x(
481
+ T.GapFiller,
482
+ T.GapFiller
483
+ );
484
+ t.containerBackgroundColor && (e.style.backgroundColor = t.containerBackgroundColor, r.style.backgroundColor = t.containerBackgroundColor);
485
+ const o = x(
481
486
  "button",
482
487
  M([
483
- C.Handle,
488
+ T.Handle,
484
489
  ot.Button,
485
490
  t.shouldShowHandle ? null : K.Hidden,
486
491
  t.handleClass
487
492
  ]),
488
- C.Handle
493
+ T.Handle
489
494
  );
490
495
  o.setAttribute("type", "button"), o.ariaLabel = "bottom sheet close button";
491
496
  const i = x(
492
497
  "span",
493
498
  M([
494
- C.HandleBar,
499
+ T.HandleBar,
495
500
  t.shouldShowHandle ? null : K.Hidden
496
501
  ]),
497
- C.HandleBar
502
+ T.HandleBar
498
503
  ), a = x(
499
504
  "article",
500
505
  M([
501
- C.ContentWrapper,
506
+ T.ContentWrapper,
502
507
  t.contentWrapperClass
503
508
  ]),
504
- C.ContentWrapper
509
+ T.ContentWrapper
505
510
  ), u = x(
506
511
  "div",
507
512
  M([
508
- C.Backdrop,
513
+ T.Backdrop,
509
514
  t.backdropClass,
510
515
  K.Hidden
511
516
  ]),
512
- C.Backdrop
517
+ T.Backdrop
513
518
  );
514
519
  return t.backdropColor && (u.style.backgroundColor = t.backdropColor), t.backDropTransition && (u.style.transition = t.backDropTransition), {
515
520
  bottomSheetRoot: n,
@@ -521,7 +526,7 @@ function Wt(t) {
521
526
  bottomSheetContainerGapFiller: r
522
527
  };
523
528
  }
524
- function Gt({
529
+ function Vt({
525
530
  bottomSheetRoot: t,
526
531
  bottomSheetContainer: n,
527
532
  bottomSheetHandle: e,
@@ -531,7 +536,7 @@ function Gt({
531
536
  }) {
532
537
  t.appendChild(n), e.appendChild(r), n.appendChild(e), n.appendChild(o), n.appendChild(i);
533
538
  }
534
- function Vt({
539
+ function Wt({
535
540
  bottomSheetElements: t,
536
541
  bottomSheetProps: n,
537
542
  options: e
@@ -543,33 +548,26 @@ function Vt({
543
548
  bottomSheetContainerGapFiller: a,
544
549
  bottomSheetContentWrapper: u,
545
550
  bottomSheetBackdrop: s
546
- } = t, { animationFrame: b } = e, l = new G(i), f = new G(
551
+ } = t, { animationFrame: b } = e, l = new V(i), d = new V(
547
552
  u
548
- ), p = new G(
553
+ ), y = new V(
549
554
  a
550
- ), w = n.dragTriggers.reduce(
551
- (E, S) => {
552
- const y = r.querySelectorAll(S);
553
- if (!y.length)
554
- return E;
555
- const P = Array.from(y).map((d) => d instanceof HTMLElement ? new G(d) : null).filter((d) => !!d);
556
- return [...E, ...P];
557
- },
558
- []
559
- ), c = new G(
555
+ );
556
+ let E = [];
557
+ const c = new V(
560
558
  window
561
- ), T = Mt(
559
+ ), C = Mt(
562
560
  c,
563
561
  o,
564
562
  n,
565
563
  e.draggingState
566
- ), H = Ft(
564
+ ), w = Pt(
567
565
  c,
568
566
  o,
569
567
  n,
570
568
  e.draggingState,
571
569
  b
572
- ), L = _t(
570
+ ), k = Gt(
573
571
  c,
574
572
  o,
575
573
  n,
@@ -578,91 +576,102 @@ function Vt({
578
576
  e.onClose,
579
577
  e.bottomSheetState
580
578
  );
581
- function B(E) {
582
- E.target instanceof Element && !r.contains(E.target) && e.onClose();
579
+ function B(S) {
580
+ S.target instanceof Element && !r.contains(S.target) && e.onClose();
583
581
  }
584
- function k(E) {
585
- Pt(
582
+ function O(S) {
583
+ Ft(
586
584
  e.draggingState,
587
- E.target,
585
+ S.target,
588
586
  t.bottomSheetContentWrapper
589
587
  );
590
588
  }
591
- function N(E) {
592
- const S = E ?? n;
593
- S.draggable && (l.addEventListeners({
594
- onStart: k
595
- }), w.forEach((y) => {
596
- y.addEventListeners({
597
- onStart: k,
598
- onStartOptions: {
599
- eventPhase: _.Target
600
- }
601
- });
602
- })), S.draggable && S.backgroundDraggable && (f.addEventListeners({
603
- onStart: k,
589
+ function N(S) {
590
+ const L = S ?? n;
591
+ L.draggable && L.backgroundDraggable && (d.addEventListeners({
592
+ onStart: O,
604
593
  onStartOptions: {
605
- eventPhase: _.Target
594
+ eventPhase: G.Target
606
595
  }
607
- }), p.addEventListeners({
608
- onStart: k
609
- })), S.draggable && c.addEventListeners({
610
- onStart: T,
611
- onMove: H,
612
- onEnd: L
613
- }), S.draggable && window.document.addEventListener("keyup", (y) => {
614
- y.key === "Escape" && e.onClose();
615
- }), i.addEventListener("keyup", (y) => {
616
- if (y.key === "ArrowUp") {
596
+ }), y.addEventListeners({
597
+ onStart: O
598
+ })), L.draggable && c.addEventListeners({
599
+ onStart: C,
600
+ onMove: w,
601
+ onEnd: k
602
+ }), L.draggable && window.document.addEventListener("keyup", (p) => {
603
+ p.key === "Escape" && e.onClose();
604
+ }), i.addEventListener("keyup", (p) => {
605
+ if (p.key === "ArrowUp") {
617
606
  e.moveUp();
618
607
  return;
619
608
  }
620
- if (y.key === "ArrowDown") {
609
+ if (p.key === "ArrowDown") {
621
610
  e.moveDown();
622
611
  return;
623
612
  }
624
- if (y.shiftKey && y.key === "Tab") {
625
- const P = nt(
613
+ if (p.shiftKey && p.key === "Tab") {
614
+ const F = nt(
626
615
  t.bottomSheetContentWrapper
627
616
  );
628
- Yt(P);
617
+ Yt(F);
629
618
  }
630
619
  });
631
620
  }
632
- function X() {
633
- n.shouldCloseOnOutsideClick ? s.addEventListener("click", B) : s.style.pointerEvents = "none";
621
+ function X(S) {
622
+ const L = S ?? n;
623
+ n.shouldCloseOnOutsideClick && !n.preventClosing ? s.addEventListener("click", B) : s.style.pointerEvents = "none", L.draggable && (l.addEventListeners({
624
+ onStart: O
625
+ }), E.forEach((p) => {
626
+ p.removeEventListeners({
627
+ onStart: O
628
+ });
629
+ }), E = n.dragTriggers.reduce((p, F) => {
630
+ const g = r.querySelectorAll(F);
631
+ if (!g.length)
632
+ return p;
633
+ const h = Array.from(g).map((f) => f instanceof HTMLElement ? new V(f) : null).filter((f) => !!f);
634
+ return [...p, ...h];
635
+ }, []), E.forEach((p) => {
636
+ p.addEventListeners({
637
+ onStart: O,
638
+ onStartOptions: {
639
+ eventPhase: G.Target
640
+ }
641
+ });
642
+ }));
634
643
  }
635
644
  function tt() {
636
645
  s.removeEventListener("click", B);
637
646
  }
638
- function nt(E) {
639
- let S = [...Array.from(E.childNodes).reverse()];
640
- for (; S.length; ) {
641
- const y = S.shift();
642
- if (It(y))
643
- return y;
644
- y && (S = [
645
- ...S,
646
- ...Array.from(y.childNodes).reverse()
647
+ function nt(S) {
648
+ let L = [...Array.from(S.childNodes).reverse()];
649
+ for (; L.length; ) {
650
+ const p = L.shift();
651
+ if (It(p))
652
+ return p;
653
+ p && (L = [
654
+ ...L,
655
+ ...Array.from(p.childNodes).reverse()
647
656
  ]);
648
657
  }
649
658
  return null;
650
659
  }
651
660
  function z() {
652
661
  l.removeEventListeners({
653
- onStart: k
654
- }), f.removeEventListeners({
655
- onStart: k
656
- }), p.removeEventListeners({
657
- onStart: k
658
- }), w.forEach((E) => {
659
- E.removeEventListeners({
660
- onStart: k
662
+ onStart: O
663
+ }), d.removeEventListeners({
664
+ onStart: O
665
+ }), y.removeEventListeners({
666
+ onStart: O
667
+ }), E.forEach((S) => {
668
+ S.removeEventListeners({
669
+ onStart: O
661
670
  });
662
671
  }), c.removeEventListeners({
663
- onStart: T,
664
- onMove: H,
665
- onEnd: L
672
+ onStart: C,
673
+ onMove: w,
674
+ onEnd: k
666
675
  });
667
676
  }
668
677
  return {
@@ -706,7 +715,7 @@ function Xt(t) {
706
715
  onEnd: i,
707
716
  animationTimingFunction: a,
708
717
  animationDuration: u
709
- } = t, s = Ct(n, e);
718
+ } = t, s = Tt(n, e);
710
719
  o.stop();
711
720
  let b = !1;
712
721
  o.start((l) => {
@@ -741,7 +750,7 @@ function Kt(t, n) {
741
750
  function qt(...t) {
742
751
  console.error(t);
743
752
  }
744
- const F = {
753
+ const P = {
745
754
  EASE: "ease",
746
755
  EASE_IN: "ease-in",
747
756
  EASE_OUT: "ease-out",
@@ -749,7 +758,7 @@ const F = {
749
758
  SPRING: "spring"
750
759
  };
751
760
  function Jt(t) {
752
- for (const n of Object.values(F))
761
+ for (const n of Object.values(P))
753
762
  if (n === t)
754
763
  return !0;
755
764
  return !1;
@@ -757,20 +766,20 @@ function Jt(t) {
757
766
  function Ot(t) {
758
767
  return !!(t instanceof Object && "p1x" in t && "p1y" in t && "p2x" in t && "p2y" in t && Y(t.p1x) && Y(t.p1y) && Y(t.p2x) && Y(t.p2y));
759
768
  }
760
- function U(t, n, e, r) {
769
+ function _(t, n, e, r) {
761
770
  return function(s) {
762
771
  return u(i(s));
763
772
  };
764
773
  function i(s) {
765
- let b = 0, l = 1, f = s, p;
774
+ let b = 0, l = 1, d = s, y;
766
775
  if (s === 0 || s === 1)
767
776
  return s;
768
777
  for (; b < l; ) {
769
- if (p = a(f), Math.abs(p - s) < 1e-3)
770
- return f;
771
- s > p ? b = f : l = f, f = (l + b) / 2;
778
+ if (y = a(d), Math.abs(y - s) < 1e-3)
779
+ return d;
780
+ s > y ? b = d : l = d, d = (l + b) / 2;
772
781
  }
773
- return f;
782
+ return d;
774
783
  }
775
784
  function a(s) {
776
785
  return 3 * t * s * Math.pow(1 - s, 2) + 3 * e * Math.pow(s, 2) * (1 - s) + Math.pow(s, 3);
@@ -779,18 +788,18 @@ function U(t, n, e, r) {
779
788
  return 3 * n * s * Math.pow(1 - s, 2) + 3 * r * Math.pow(s, 2) * (1 - s) + Math.pow(s, 3);
780
789
  }
781
790
  }
782
- const bt = U(0.25, 0.1, 0.25, 1), Qt = U(0.42, 0, 1, 1), Lt = U(0.42, 0, 0.58, 1), Zt = U(0.4, 0.1, 0.6, 1), tn = U(0.45, 1.5, 0.55, 1);
791
+ const bt = _(0.25, 0.1, 0.25, 1), Qt = _(0.42, 0, 1, 1), kt = _(0.42, 0, 0.58, 1), Zt = _(0.4, 0.1, 0.6, 1), tn = _(0.45, 1.5, 0.55, 1);
783
792
  function nn(t) {
784
793
  switch (t) {
785
- case F.EASE:
794
+ case P.EASE:
786
795
  return bt;
787
- case F.EASE_IN:
796
+ case P.EASE_IN:
788
797
  return Qt;
789
- case F.EASE_OUT:
790
- return Lt;
791
- case F.EASE_IN_OUT:
798
+ case P.EASE_OUT:
799
+ return kt;
800
+ case P.EASE_IN_OUT:
792
801
  return Zt;
793
- case F.SPRING:
802
+ case P.SPRING:
794
803
  return tn;
795
804
  default:
796
805
  return bt;
@@ -830,6 +839,7 @@ const en = {
830
839
  shouldShowHandle: !0,
831
840
  backDropTransition: null,
832
841
  backdropColor: null,
842
+ containerBackgroundColor: null,
833
843
  containerBorderRadius: null,
834
844
  rootClass: null,
835
845
  containerClass: null,
@@ -842,7 +852,8 @@ const en = {
842
852
  containerStyle: {},
843
853
  handleStyle: {},
844
854
  contentWrapperStyle: {},
845
- backdropStyle: {}
855
+ backdropStyle: {},
856
+ containerGapFillerStyle: {}
846
857
  };
847
858
  function rn(t) {
848
859
  const n = {
@@ -862,18 +873,18 @@ function rn(t) {
862
873
  function ct(t) {
863
874
  if (Ot(t)) {
864
875
  const { p1x: n, p1y: e, p2x: r, p2y: o } = t;
865
- return U(n, e, r, o);
876
+ return _(n, e, r, o);
866
877
  }
867
- return Jt(t) ? nn(t) : Lt;
878
+ return Jt(t) ? nn(t) : kt;
868
879
  }
869
880
  function on(t, n, e, r) {
870
881
  function o(i, a) {
871
882
  switch (i) {
872
883
  case "content":
873
- O(a) && (t.bottomSheetContentWrapper.innerHTML = a);
884
+ H(a) && (t.bottomSheetContentWrapper.innerHTML = a);
874
885
  break;
875
886
  case "width":
876
- O(a) && (t.bottomSheetContainer.style.width = a);
887
+ H(a) && (t.bottomSheetContainer.style.width = a);
877
888
  break;
878
889
  case "shouldShowHandle":
879
890
  pt(a) || q(t.bottomSheetHandle, !1);
@@ -882,54 +893,57 @@ function on(t, n, e, r) {
882
893
  pt(a) || q(t.bottomSheetBackdrop, !1);
883
894
  break;
884
895
  case "containerBorderRadius":
885
- O(a) && (t.bottomSheetContainer.style.borderRadius = St(a));
896
+ H(a) && (t.bottomSheetContainer.style.borderRadius = Ht(a));
897
+ break;
898
+ case "containerBackgroundColor":
899
+ H(a) && (t.bottomSheetContainer.style.backgroundColor = a, t.bottomSheetContainerGapFiller.style.backgroundColor = a);
886
900
  break;
887
901
  case "backdropColor":
888
- O(a) && (t.bottomSheetBackdrop.style.backgroundColor = a);
902
+ H(a) && (t.bottomSheetBackdrop.style.backgroundColor = a);
889
903
  break;
890
904
  case "backDropTransition":
891
- O(a) && (t.bottomSheetBackdrop.style.transition = a);
905
+ H(a) && (t.bottomSheetBackdrop.style.transition = a);
892
906
  break;
893
907
  case "rootClass":
894
- if (!O(a))
908
+ if (!H(a))
895
909
  return;
896
- W(
910
+ U(
897
911
  t.bottomSheetRoot,
898
912
  e.rootClass,
899
913
  a
900
914
  );
901
915
  break;
902
916
  case "containerClass":
903
- if (!O(a))
917
+ if (!H(a))
904
918
  return;
905
- W(
919
+ U(
906
920
  t.bottomSheetContainer,
907
921
  e.containerClass,
908
922
  a
909
923
  );
910
924
  break;
911
925
  case "handleClass":
912
- if (!O(a))
926
+ if (!H(a))
913
927
  return;
914
- W(
928
+ U(
915
929
  t.bottomSheetHandle,
916
930
  e.handleClass,
917
931
  a
918
932
  );
919
933
  break;
920
934
  case "contentWrapperClass":
921
- if (!O(a))
935
+ if (!H(a))
922
936
  return;
923
- W(
937
+ U(
924
938
  t.bottomSheetContentWrapper,
925
939
  e.contentWrapperClass,
926
940
  a
927
941
  );
928
942
  break;
929
943
  case "backdropClass":
930
- if (!O(a))
944
+ if (!H(a))
931
945
  return;
932
- W(
946
+ U(
933
947
  t.bottomSheetBackdrop,
934
948
  e.backdropClass,
935
949
  a
@@ -944,6 +958,9 @@ function on(t, n, e, r) {
944
958
  case "draggable":
945
959
  r.clearEventListeners(), r.attachEventListeners(e);
946
960
  break;
961
+ case "dragTriggers":
962
+ r.clearEventListeners(), r.attachEventListeners(e);
963
+ break;
947
964
  case "draggingAnimationTimings":
948
965
  if (Ot(a)) {
949
966
  const u = ct(a), s = st(
@@ -982,6 +999,12 @@ function on(t, n, e, r) {
982
999
  e.containerStyle
983
1000
  );
984
1001
  break;
1002
+ case "containerGapFillerStyle":
1003
+ e.containerGapFillerStyle && Object.assign(
1004
+ t.bottomSheetContainerGapFiller.style,
1005
+ e.containerGapFillerStyle
1006
+ );
1007
+ break;
985
1008
  case "handleStyle":
986
1009
  e.handleStyle && Object.assign(
987
1010
  t.bottomSheetHandleBar.style,
@@ -1025,13 +1048,13 @@ function cn(t) {
1025
1048
  onClose: B,
1026
1049
  bottomSheetState: o,
1027
1050
  draggingState: i,
1028
- snapTo: P,
1029
- moveUp: S,
1030
- moveDown: y
1051
+ snapTo: F,
1052
+ moveUp: L,
1053
+ moveDown: p
1031
1054
  }, { elements: b, eventHandlers: l } = jt(
1032
1055
  n,
1033
1056
  s
1034
- ), f = Kt(
1057
+ ), d = Kt(
1035
1058
  n,
1036
1059
  on(
1037
1060
  b,
@@ -1039,35 +1062,35 @@ function cn(t) {
1039
1062
  n,
1040
1063
  l
1041
1064
  )
1042
- ), { bottomSheetBackdrop: p, bottomSheetRoot: w, bottomSheetContainer: c } = b, T = (d) => {
1043
- const g = d ?? window.document.body;
1044
- g.appendChild(w), g.appendChild(p);
1045
- const h = window.innerHeight;
1065
+ ), { bottomSheetBackdrop: y, bottomSheetRoot: E, bottomSheetContainer: c } = b, C = (g) => {
1066
+ const h = g ?? window.document.body;
1067
+ h.appendChild(E), h.appendChild(y);
1068
+ const f = window.innerHeight;
1046
1069
  Q(c, {
1047
- y: h
1070
+ y: f
1048
1071
  }), l.attachEventListeners(), o.isMounted = !0;
1049
- }, H = () => {
1050
- l.clearEventListeners(), Object.values(b).forEach((d) => {
1051
- d.remove();
1072
+ }, w = () => {
1073
+ l.clearEventListeners(), Object.values(b).forEach((g) => {
1074
+ g.remove();
1052
1075
  }), a(), o.isMounted = !1;
1053
- }, L = () => {
1076
+ }, k = () => {
1054
1077
  var D;
1055
- if (k() || qt(
1078
+ if (O() || qt(
1056
1079
  'Bottom Sheet is not mounted yet. call the "mount" method first.'
1057
1080
  ), (D = t.beforeOpen) == null || D.call(t), N())
1058
1081
  return;
1059
- et(p, !0), f.shouldShowBackdrop || $(p, "transparent"), et([c], !0), Q(c, {
1082
+ et(y, !0), d.shouldShowBackdrop || $(y, "transparent"), et([c], !0), Q(c, {
1060
1083
  y: c.clientHeight
1061
1084
  });
1062
- const g = window.innerHeight, h = dt(
1063
- g,
1085
+ const h = window.innerHeight, f = dt(
1086
+ h,
1064
1087
  c.clientHeight,
1065
- f.marginTop,
1066
- f.defaultPosition
1088
+ d.marginTop,
1089
+ d.defaultPosition
1067
1090
  ), m = I(c).y;
1068
1091
  o.translateContainer({
1069
1092
  startY: m,
1070
- endY: h,
1093
+ endY: f,
1071
1094
  animationFrame: u,
1072
1095
  bottomSheetContainer: c,
1073
1096
  onEnd: t.afterOpen
@@ -1078,64 +1101,64 @@ function cn(t) {
1078
1101
  i.originalDocumentOverscrollBehavior = A || "initial", document.body.style.overflow = "hidden", document.body.style.overscrollBehavior = "contain", b.bottomSheetHandle.focus(), l.attacheOnOpenEventListeners();
1079
1102
  };
1080
1103
  function B() {
1081
- var h;
1104
+ var f;
1082
1105
  if (X())
1083
1106
  return;
1084
- (h = t.beforeClose) == null || h.call(t);
1085
- const d = I(c).y, g = c.clientHeight;
1107
+ (f = t.beforeClose) == null || f.call(t);
1108
+ const g = I(c).y, h = c.clientHeight;
1086
1109
  o.translateContainer({
1087
- startY: d,
1088
- endY: g,
1110
+ startY: g,
1111
+ endY: h,
1089
1112
  animationFrame: u,
1090
1113
  bottomSheetContainer: c,
1091
1114
  onEnd: () => {
1092
1115
  var m;
1093
- (m = t.afterClose) == null || m.call(t), et([p, c], !1), l.clearOnOpenEventListeners();
1116
+ (m = t.afterClose) == null || m.call(t), et([y, c], !1), l.clearOnOpenEventListeners();
1094
1117
  }
1095
1118
  }), a();
1096
1119
  }
1097
- function k() {
1120
+ function O() {
1098
1121
  return o.isMounted;
1099
1122
  }
1100
1123
  function N() {
1101
- const d = I(c).y, g = window.innerHeight, h = c.clientHeight >= g ? g : c.clientHeight;
1102
- return d <= h;
1124
+ const g = I(c).y, h = window.innerHeight, f = c.clientHeight >= h ? h : c.clientHeight;
1125
+ return g <= f;
1103
1126
  }
1104
1127
  function X() {
1105
1128
  return !N();
1106
1129
  }
1107
1130
  function tt() {
1108
- const d = I(c).y, g = c.clientHeight, h = window.innerHeight;
1109
- if (d <= 5 && d >= -5)
1131
+ const g = I(c).y, h = c.clientHeight, f = window.innerHeight;
1132
+ if (g <= 5 && g >= -5)
1110
1133
  return R.CONTENT_HEIGHT;
1111
- const m = g - d;
1112
- if (m === h / 2)
1134
+ const m = h - g;
1135
+ if (m === f / 2)
1113
1136
  return R.MIDDLE;
1114
- const v = h - f.marginTop, A = 10;
1137
+ const v = f - d.marginTop, A = 10;
1115
1138
  return m <= v + A && m >= v - A ? R.TOP : R.CLOSED;
1116
1139
  }
1117
1140
  function nt() {
1118
1141
  return c.clientHeight;
1119
1142
  }
1120
- function z(d) {
1143
+ function z(g) {
1121
1144
  if (!N())
1122
1145
  return;
1123
- const g = I(c).y, m = c.clientHeight - g, v = window.innerHeight - d, A = xt(m, v), D = V(m, v);
1146
+ const h = I(c).y, m = c.clientHeight - h, v = window.innerHeight - g, A = xt(m, v), D = W(m, v);
1124
1147
  o.translateContainer({
1125
- startY: g,
1126
- endY: g + (A.isUp ? -D : D),
1148
+ startY: h,
1149
+ endY: h + (A.isUp ? -D : D),
1127
1150
  animationFrame: u,
1128
1151
  bottomSheetContainer: c
1129
1152
  });
1130
1153
  }
1131
- function E(d, {
1132
- viewportHeight: g,
1133
- visibleHeight: h
1154
+ function S(g, {
1155
+ viewportHeight: h,
1156
+ visibleHeight: f
1134
1157
  }) {
1135
1158
  let m = null;
1136
- for (const v of d) {
1137
- const A = v * g, D = V(
1138
- h,
1159
+ for (const v of g) {
1160
+ const A = v * h, D = W(
1161
+ f,
1139
1162
  A
1140
1163
  );
1141
1164
  (m === null || D < m) && (m = D);
@@ -1144,25 +1167,25 @@ function cn(t) {
1144
1167
  minOffset: m
1145
1168
  };
1146
1169
  }
1147
- function S() {
1148
- const d = [...f.snapPoints].reverse(), g = I(c).y, h = c.clientHeight, m = h - g;
1149
- if (!f.expandable && m >= h)
1170
+ function L() {
1171
+ const g = [...d.snapPoints].reverse(), h = I(c).y, f = c.clientHeight, m = f - h;
1172
+ if (!d.expandable && m >= f)
1150
1173
  return;
1151
1174
  const v = window.innerHeight, A = ft(
1152
1175
  "above",
1153
1176
  { visibleHeight: m, viewportHeight: v },
1154
- d
1155
- ), { minOffset: D } = E(A, {
1177
+ g
1178
+ ), { minOffset: D } = S(A, {
1156
1179
  visibleHeight: m,
1157
1180
  viewportHeight: v
1158
1181
  });
1159
- if (D === null && m < v - f.marginTop) {
1182
+ if (D === null && m < v - d.marginTop) {
1160
1183
  o.translateContainer({
1161
- startY: g,
1184
+ startY: h,
1162
1185
  endY: dt(
1163
1186
  v,
1164
- h,
1165
- f.marginTop,
1187
+ f,
1188
+ d.marginTop,
1166
1189
  "top"
1167
1190
  ),
1168
1191
  animationFrame: u,
@@ -1171,52 +1194,52 @@ function cn(t) {
1171
1194
  return;
1172
1195
  }
1173
1196
  Y(D) && o.translateContainer({
1174
- startY: g,
1175
- endY: g - D,
1197
+ startY: h,
1198
+ endY: h - D,
1176
1199
  animationFrame: u,
1177
1200
  bottomSheetContainer: c
1178
1201
  });
1179
1202
  }
1180
- function y() {
1181
- const d = I(c).y, h = c.clientHeight - d;
1182
- if (h < 1)
1203
+ function p() {
1204
+ const g = I(c).y, f = c.clientHeight - g;
1205
+ if (f < 1)
1183
1206
  return;
1184
1207
  const m = window.innerHeight, v = ft(
1185
1208
  "below",
1186
- { visibleHeight: h, viewportHeight: m },
1187
- f.snapPoints
1188
- ), { minOffset: A } = E(v, {
1189
- visibleHeight: h,
1209
+ { visibleHeight: f, viewportHeight: m },
1210
+ d.snapPoints
1211
+ ), { minOffset: A } = S(v, {
1212
+ visibleHeight: f,
1190
1213
  viewportHeight: m
1191
1214
  });
1192
1215
  Y(A) && o.translateContainer({
1193
- startY: d,
1194
- endY: d + A,
1216
+ startY: g,
1217
+ endY: g + A,
1195
1218
  animationFrame: u,
1196
1219
  bottomSheetContainer: c
1197
1220
  });
1198
1221
  }
1199
- function P(d) {
1200
- const g = window.innerHeight;
1201
- if (!zt(d))
1222
+ function F(g) {
1223
+ const h = window.innerHeight;
1224
+ if (!zt(g))
1202
1225
  return;
1203
- const h = J(g * d, 2);
1204
- z(h);
1226
+ const f = J(h * g, 2);
1227
+ z(f);
1205
1228
  }
1206
1229
  return {
1207
- props: f,
1230
+ props: d,
1208
1231
  elements: b,
1209
- mount: T,
1210
- unmount: H,
1211
- open: L,
1232
+ mount: C,
1233
+ unmount: w,
1234
+ open: k,
1212
1235
  close: B,
1213
- getIsMounted: k,
1236
+ getIsMounted: O,
1214
1237
  getIsOpen: N,
1215
1238
  getIsClosed: X,
1216
1239
  getPosition: tt,
1217
1240
  getHeight: nt,
1218
1241
  moveTo: z,
1219
- snapTo: P
1242
+ snapTo: F
1220
1243
  };
1221
1244
  }
1222
1245
  function ln() {
@@ -1256,9 +1279,9 @@ export {
1256
1279
  en as BOTTOM_SHEET_DEFAULT_PROPS,
1257
1280
  R as BOTTOM_SHEET_POSITION,
1258
1281
  sn as BOTTOM_SHEET_SELECTORS,
1259
- F as COMMON_ANIMATION_KEYS,
1260
- C as ClassNames,
1261
- _ as EventPhase,
1282
+ P as COMMON_ANIMATION_KEYS,
1283
+ T as ClassNames,
1284
+ G as EventPhase,
1262
1285
  ot as ResetClassNames,
1263
1286
  K as UtilClassNames,
1264
1287
  cn as createBottomSheet,