@plainsheet/react 0.4.4 → 0.4.7

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