@webority/mobile-ui 0.130.3 → 0.131.0

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.
Files changed (33) hide show
  1. package/README.md +6 -0
  2. package/dist/canvas-kit/kit.js +157 -70
  3. package/dist/canvas-kit/manifest.json +6 -1
  4. package/dist/canvas-kit/release.json +6 -6
  5. package/lib/commonjs/components/BottomSheet/BottomSheet.js +1 -1
  6. package/lib/commonjs/components/Confetti/Confetti.js +1 -1
  7. package/lib/commonjs/components/Drawer/Drawer.js +1 -1
  8. package/lib/commonjs/components/FileViewer/useFileViewerZoom.js +1 -1
  9. package/lib/commonjs/components/FloatingActionButton/FloatingActionButton.js +1 -1
  10. package/lib/commonjs/components/ImageGallery/ImageGallery.js +1 -1
  11. package/lib/commonjs/components/MessageList/MessageList.js +1 -1
  12. package/lib/commonjs/components/SlideToConfirm/SlideToConfirm.js +1 -1
  13. package/lib/commonjs/components/Slider/Slider.js +1 -1
  14. package/lib/commonjs/components/SortableList/SortableList.js +1 -1
  15. package/lib/commonjs/components/Swipeable/Swipeable.js +1 -1
  16. package/lib/commonjs/components/TypingIndicator/TypingIndicator.js +1 -1
  17. package/lib/commonjs/components/ZoomableImage/ZoomableImage.js +1 -1
  18. package/lib/module/components/BottomSheet/BottomSheet.js +1 -1
  19. package/lib/module/components/Confetti/Confetti.js +1 -1
  20. package/lib/module/components/Drawer/Drawer.js +1 -1
  21. package/lib/module/components/FileViewer/useFileViewerZoom.js +1 -1
  22. package/lib/module/components/FloatingActionButton/FloatingActionButton.js +1 -1
  23. package/lib/module/components/ImageGallery/ImageGallery.js +1 -1
  24. package/lib/module/components/MessageList/MessageList.js +1 -1
  25. package/lib/module/components/SlideToConfirm/SlideToConfirm.js +1 -1
  26. package/lib/module/components/Slider/Slider.js +1 -1
  27. package/lib/module/components/SortableList/SortableList.js +1 -1
  28. package/lib/module/components/Swipeable/Swipeable.js +1 -1
  29. package/lib/module/components/TypingIndicator/TypingIndicator.js +1 -1
  30. package/lib/module/components/ZoomableImage/ZoomableImage.js +1 -1
  31. package/lib/typescript/commonjs/components/MessageList/MessageList.d.ts +1 -1
  32. package/lib/typescript/module/components/MessageList/MessageList.d.ts +1 -1
  33. package/package.json +7 -7
package/README.md CHANGED
@@ -15,4 +15,10 @@ No external runtime dependencies beyond `@webority/mobile-core`. Requires
15
15
  peers, and `expo-file-system`, where `AuthedImage` keeps its downloaded images; `react-native-haptic-feedback` is optional. Gradients use React Native's own
16
16
  `experimental_backgroundImage`, so no gradient library is needed.
17
17
 
18
+ ## Web and navigation
19
+
20
+ Animated hooks in this package carry explicit dependency arrays, so web builds work without the Reanimated Babel plugin. The `@webority/mobile-dev` check `scripts/check-animated-deps.mjs` keeps it that way.
21
+
22
+ Navigation components live only at the `@webority/mobile-ui/navigation` entry. That entry needs the optional peers `@react-navigation/native` and `@react-navigation/bottom-tabs`, which an app installs only when it uses navigation.
23
+
18
24
  Full documentation lives in the repository's `docs/` directory.
@@ -13164,7 +13164,22 @@ var $m = R.create({
13164
13164
  opacity: t,
13165
13165
  transform: [{ translateX: K.value + N - e }, { scaleX: 1 }]
13166
13166
  };
13167
- }), Ue = Ge(() => ({ transform: [{ translateX: K.value - Le }, { scale: ie.value }] })), We = Ge(() => ({ transform: [{ translateX: re.value - Le }, { scale: ae.value }] })), Ke = Ge(() => ({ opacity: se.value })), qe = Ge(() => ({ opacity: ce.value })), Je = (e) => th(e, n, r), Ye = Je(G ? Math.min(...te) : te), Ze = Je(G ? Math.max(...te) : te);
13167
+ }, [
13168
+ Q,
13169
+ a,
13170
+ G,
13171
+ re,
13172
+ K,
13173
+ N
13174
+ ]), Ue = Ge(() => ({ transform: [{ translateX: K.value - Le }, { scale: ie.value }] }), [
13175
+ K,
13176
+ Le,
13177
+ ie
13178
+ ]), We = Ge(() => ({ transform: [{ translateX: re.value - Le }, { scale: ae.value }] }), [
13179
+ re,
13180
+ Le,
13181
+ ae
13182
+ ]), Ke = Ge(() => ({ opacity: se.value }), [se]), qe = Ge(() => ({ opacity: ce.value }), [ce]), Je = (e) => th(e, n, r), Ye = Je(G ? Math.min(...te) : te), Ze = Je(G ? Math.max(...te) : te);
13168
13183
  return q(H, {
13169
13184
  ref: t,
13170
13185
  style: [
@@ -14050,7 +14065,7 @@ var Fh = R.create({
14050
14065
  b,
14051
14066
  A,
14052
14067
  v
14053
- ]), z = Ge(() => ({ transform: [{ translateX: A.value }] })), B = Ge(() => ({ opacity: O > 0 ? Math.min(1, Math.max(0, A.value / O)) : 0 })), V = Ge(() => ({ opacity: k > 0 ? Math.min(1, Math.max(0, -A.value / k)) : 0 })), U = m(() => {
14068
+ ]), z = Ge(() => ({ transform: [{ translateX: A.value }] }), [A]), B = Ge(() => ({ opacity: O > 0 ? Math.min(1, Math.max(0, A.value / O)) : 0 }), [O, A]), V = Ge(() => ({ opacity: k > 0 ? Math.min(1, Math.max(0, -A.value / k)) : 0 }), [k, A]), U = m(() => {
14054
14069
  let e = [];
14055
14070
  return n?.forEach((t) => {
14056
14071
  e.push({
@@ -19441,7 +19456,7 @@ var Xv = (e, t, n) => {
19441
19456
  kt,
19442
19457
  G,
19443
19458
  Fe
19444
- ]), { height: Pt } = K(), Ft = T === "shift", It = Ke(() => Ft ? Pt.value : 0), Lt = Me[ze >= 0 ? ze : 0] ?? Pe, Rt = Z.space.md, zt = Ge(() => {
19459
+ ]), { height: Pt } = K(), Ft = T === "shift", It = Ke(() => Ft ? Pt.value : 0, [Ft, Pt]), Lt = Me[ze >= 0 ? ze : 0] ?? Pe, Rt = Z.space.md, zt = Ge(() => {
19445
19460
  if (de) {
19446
19461
  let e = It.value, t = ae + e - Lt - Rt, n = e < 0 && Fe.value > t ? t : Fe.value;
19447
19462
  return {
@@ -19454,7 +19469,17 @@ var Xv = (e, t, n) => {
19454
19469
  top: e < t ? t : e,
19455
19470
  opacity: Le.value
19456
19471
  };
19457
- }), Bt = Ge(() => {
19472
+ }, [
19473
+ de,
19474
+ It,
19475
+ ae,
19476
+ Lt,
19477
+ Rt,
19478
+ Fe,
19479
+ he,
19480
+ Le,
19481
+ Ot
19482
+ ]), Bt = Ge(() => {
19458
19483
  let e = It.value;
19459
19484
  if (de) {
19460
19485
  let t = ae + e - Lt - Rt, n = e < 0 && Fe.value > t ? t : Fe.value, r = ae + e - Rt - (n < he ? he : n);
@@ -19462,7 +19487,17 @@ var Xv = (e, t, n) => {
19462
19487
  }
19463
19488
  let t = e < 0 ? he : Ot, n = Fe.value + e, r = ae + e - (n < t ? t : n);
19464
19489
  return { height: r < 0 ? 0 : r > Pe ? Pe : r };
19465
- }), Vt = ze >= 0, Ht = m(() => sy(Z), [Z]), Ut = l(() => {
19490
+ }, [
19491
+ It,
19492
+ de,
19493
+ ae,
19494
+ Lt,
19495
+ Rt,
19496
+ Fe,
19497
+ he,
19498
+ Ot,
19499
+ Pe
19500
+ ]), Vt = ze >= 0, Ht = m(() => sy(Z), [Z]), Ut = l(() => {
19466
19501
  u && St(() => {
19467
19502
  Gr("selection"), ot.current(), xt();
19468
19503
  });
@@ -19617,7 +19652,7 @@ var Xv = (e, t, n) => {
19617
19652
  let r = mt().bottom, i = Ge(() => {
19618
19653
  let e = r + t.value;
19619
19654
  return { paddingBottom: e > 0 ? e : 0 };
19620
- });
19655
+ }, [r, t]);
19621
19656
  return q(Ee.View, {
19622
19657
  style: [e, i],
19623
19658
  children: n
@@ -22044,7 +22079,13 @@ var vb = (e) => R.create({
22044
22079
  { scaleY: f }
22045
22080
  ]
22046
22081
  };
22047
- }), o = jb[e.shape], s = e.shape === "triangle" || e.shape === "star" || e.shape === "streamer";
22082
+ }, [
22083
+ e,
22084
+ t,
22085
+ n,
22086
+ r,
22087
+ i
22088
+ ]), o = jb[e.shape], s = e.shape === "triangle" || e.shape === "star" || e.shape === "streamer";
22048
22089
  return q(Ee.View, {
22049
22090
  style: [{
22050
22091
  position: "absolute",
@@ -23580,10 +23621,19 @@ var _x = (e, t) => e.key ?? (typeof e.label == "string" ? `${e.label}-${t}` : `r
23580
23621
  } : {
23581
23622
  opacity: B.value,
23582
23623
  transform: [{ translateY: L.value }]
23583
- }), Q = Ge(() => ({
23624
+ }, [
23625
+ N,
23626
+ L,
23627
+ B
23628
+ ]), Q = Ge(() => ({
23584
23629
  opacity: ze(L.value, [I, 0], [0, u], Oe.CLAMP) * B.value,
23585
23630
  pointerEvents: Math.abs(L.value - I) < .5 ? "none" : "auto"
23586
- }), [I, u]), ie = m(() => Tx(S), [S]), ae = l(() => {
23631
+ }), [
23632
+ L,
23633
+ I,
23634
+ u,
23635
+ B
23636
+ ]), ie = m(() => Tx(S), [S]), ae = l(() => {
23587
23637
  if (!c) return;
23588
23638
  let e = Kr(p, "selection");
23589
23639
  e && Gr(e), re();
@@ -24383,7 +24433,11 @@ var Fx = (e) => R.create({
24383
24433
  { translateX: y.value },
24384
24434
  { translateY: b.value },
24385
24435
  { scale: _.value }
24386
- ] })),
24436
+ ] }), [
24437
+ y,
24438
+ b,
24439
+ _
24440
+ ]),
24387
24441
  zoomLevel: a,
24388
24442
  resetZoom: C
24389
24443
  };
@@ -24849,7 +24903,7 @@ var oS = R.create({ row: { alignItems: "center" } }), sS = (e, t) => {
24849
24903
  let ce = l((e) => {
24850
24904
  let t = Math.ceil(e);
24851
24905
  se((e) => e === t ? e : t);
24852
- }, []), le = Ge(() => ({ paddingHorizontal: Z * (1 - ae.value) })), ue = Ge(() => {
24906
+ }, []), le = Ge(() => ({ paddingHorizontal: Z * (1 - ae.value) }), [Z, ae]), ue = Ge(() => {
24853
24907
  let e = Math.max(0, 1 - 2 * ae.value);
24854
24908
  return oe === null ? ae.value >= 1 ? {
24855
24909
  opacity: e,
@@ -24858,7 +24912,11 @@ var oS = R.create({ row: { alignItems: "center" } }), sS = (e, t) => {
24858
24912
  opacity: e,
24859
24913
  width: (oe + X) * (1 - ae.value)
24860
24914
  };
24861
- }), de = f ? k.colors["surface-disabled"] : sS(k, s), fe = f ? k.colors["text-disabled"] : lS(k, s), pe = p ? q(mm, {
24915
+ }, [
24916
+ ae,
24917
+ oe,
24918
+ X
24919
+ ]), de = f ? k.colors["surface-disabled"] : sS(k, s), fe = f ? k.colors["text-disabled"] : lS(k, s), pe = p ? q(mm, {
24862
24920
  variant: "circular",
24863
24921
  size: o === "lg" ? "md" : "sm",
24864
24922
  color: fe
@@ -25887,7 +25945,11 @@ var ES = ({ open: e, images: t, initialIndex: n, enablePinchZoom: r, showCounter
25887
25945
  { translateX: g.value },
25888
25946
  { translateY: _.value },
25889
25947
  { scale: p.value }
25890
- ] }));
25948
+ ] }), [
25949
+ g,
25950
+ _,
25951
+ p
25952
+ ]);
25891
25953
  e.useEffect(() => {
25892
25954
  i || b();
25893
25955
  }, [i, b]);
@@ -27211,11 +27273,11 @@ var UC = Object.freeze({
27211
27273
  minIndexForVisible: 0,
27212
27274
  autoscrollToTopThreshold: 160
27213
27275
  }, XC = (e, t) => e ? t ? "middle" : "last" : t ? "first" : "single";
27214
- function ZC({ messages: e, keyExtractor: t, renderMessage: n, getAuthorKey: r, getDate: i, firstUnreadKey: a, onLoadOlder: o, loadingOlder: s = !1, hasOlder: c = !0, typing: u, empty: f, getAnnouncement: p, followNew: _, keyboardAware: v = !0, keyboardOffset: y, labels: b, now: x, onScroll: S, contentContainerStyle: C, style: w, testID: E, ...D }) {
27215
- let O = br(), k = mt(), A = wn(), j = m(() => QC(O), [O]), M = m(() => ({
27276
+ function ZC({ messages: e, keyExtractor: t, renderMessage: n, getAuthorKey: r, getDate: i, firstUnreadKey: a, onLoadOlder: o, loadingOlder: s = !1, hasOlder: c = !0, typing: u, empty: f, getAnnouncement: p, followNew: _, keyboardAware: v = !0, keyboardOffset: y, labels: b, now: x, onScroll: S, onContentSizeChange: C, contentContainerStyle: w, style: E, testID: D, ...O }) {
27277
+ let k = br(), A = mt(), j = wn(), M = m(() => QC(k), [k]), N = m(() => ({
27216
27278
  ...JC,
27217
27279
  ...b
27218
- }), [b]), N = y ?? k.bottom, P = h(null), F = h(!1), [I, L] = g(!1), [R, z] = g(0), B = m(() => {
27280
+ }), [b]), P = y ?? A.bottom, F = h(null), I = h(!1), L = h(!0), R = h(0), [z, B] = g(!1), [V, U] = g(0), ee = m(() => {
27219
27281
  let n = i ? e.map((e) => le(i(e))) : null, o = r ? e.map(r) : null, s = a === void 0 ? -1 : e.findIndex((e) => t(e) === a);
27220
27282
  return e.map((t, r) => {
27221
27283
  let a = r === e.length - 1, c = n !== null && (a || n[r] !== n[r + 1]);
@@ -27223,7 +27285,7 @@ function ZC({ messages: e, keyExtractor: t, renderMessage: n, getAuthorKey: r, g
27223
27285
  groupPosition: XC(o !== null && !a && o[r + 1] === o[r] && !c && r !== s, o !== null && r > 0 && o[r - 1] === o[r] && (n === null || n[r - 1] === n[r]) && r - 1 !== s),
27224
27286
  day: c && i ? ax(i(t), {
27225
27287
  now: x,
27226
- labels: M
27288
+ labels: N
27227
27289
  }) : null,
27228
27290
  unread: r === s
27229
27291
  };
@@ -27235,40 +27297,47 @@ function ZC({ messages: e, keyExtractor: t, renderMessage: n, getAuthorKey: r, g
27235
27297
  a,
27236
27298
  t,
27237
27299
  x,
27238
- M
27239
- ]), V = l(() => {
27240
- P.current?.scrollToOffset({
27300
+ N
27301
+ ]), G = l(() => {
27302
+ L.current = !0, F.current?.scrollToOffset({
27241
27303
  offset: 0,
27242
- animated: !A
27243
- }), z(0);
27244
- }, [A]), U = e.length > 0 ? t(e[0]) : null, ee = h(U);
27304
+ animated: !j
27305
+ }), U(0);
27306
+ }, [j]), te = e.length > 0 ? t(e[0]) : null, ne = h(te);
27245
27307
  d(() => {
27246
- let n = ee.current;
27247
- if (ee.current = U, n === null || U === null || n === U) return;
27308
+ let n = ne.current;
27309
+ if (ne.current = te, n === null || te === null || n === te) return;
27248
27310
  let r = e.findIndex((e) => t(e) === n);
27249
- if (r === -1) return void z(0);
27311
+ if (r === -1) return void U(0);
27250
27312
  let i = e.slice(0, r).reverse();
27251
27313
  for (let e of i) {
27252
27314
  let t = p?.(e);
27253
27315
  t && ap(t);
27254
27316
  }
27255
- _ && i.some(_) ? V() : F.current && z((e) => e + i.length);
27256
- }, [U]);
27257
- let G = l((e) => {
27317
+ _ && i.some(_) ? G() : I.current && U((e) => e + i.length);
27318
+ }, [te]);
27319
+ let K = l((e) => {
27320
+ L.current = e.nativeEvent.contentOffset.y <= 48;
27258
27321
  let t = e.nativeEvent.contentOffset.y > 160;
27259
- t !== F.current && (F.current = t, L(t), t || z(0)), S?.(e);
27260
- }, [S]), te = l(() => {
27322
+ t !== I.current && (I.current = t, B(t), t || U(0)), S?.(e);
27323
+ }, [S]), re = l((e, t) => {
27324
+ let n = t > R.current;
27325
+ R.current = t, n && L.current && F.current?.scrollToOffset({
27326
+ offset: 0,
27327
+ animated: !1
27328
+ }), C?.(e, t);
27329
+ }, [C]), Y = l(() => {
27261
27330
  c && !s && o?.();
27262
27331
  }, [
27263
27332
  c,
27264
27333
  s,
27265
27334
  o
27266
- ]), ne = l(({ item: e, index: t }) => {
27267
- let r = B[t];
27268
- return J(re, { children: [
27335
+ ]), X = l(({ item: e, index: t }) => {
27336
+ let r = ee[t];
27337
+ return J(H, { children: [
27269
27338
  r?.day ? q(ox, { label: r.day }) : null,
27270
27339
  r?.unread ? q(ox, {
27271
- label: M.unread,
27340
+ label: N.unread,
27272
27341
  emphasis: !0
27273
27342
  }) : null,
27274
27343
  n({
@@ -27278,64 +27347,65 @@ function ZC({ messages: e, keyExtractor: t, renderMessage: n, getAuthorKey: r, g
27278
27347
  })
27279
27348
  ] });
27280
27349
  }, [
27281
- B,
27282
- M.unread,
27350
+ ee,
27351
+ N.unread,
27283
27352
  n
27284
- ]), K = l((e) => t(e), [t]), Y = l((e) => q(W, {
27353
+ ]), Z = l((e) => t(e), [t]), Q = l((e) => q(W, {
27285
27354
  ...e,
27286
27355
  inverted: !0,
27287
- offset: N
27288
- }), [N]), X = R > 0 ? `${M.newMessages(R)}. ${M.jumpToLatest}` : M.jumpToLatest;
27356
+ offset: P
27357
+ }), [P]), ie = V > 0 ? `${N.newMessages(V)}. ${N.jumpToLatest}` : N.jumpToLatest;
27289
27358
  return J(H, {
27290
- style: [j.root, w],
27359
+ style: [M.root, E],
27291
27360
  children: [q(T, {
27292
27361
  keyboardShouldPersistTaps: "handled",
27293
27362
  maintainVisibleContentPosition: YC,
27294
- ...D,
27295
- ref: P,
27363
+ ...O,
27364
+ ref: F,
27296
27365
  data: e,
27297
- renderItem: ne,
27298
- keyExtractor: K,
27366
+ renderItem: X,
27367
+ keyExtractor: Z,
27299
27368
  inverted: !0,
27300
- onScroll: G,
27301
- onEndReached: o ? te : void 0,
27369
+ onScroll: K,
27370
+ onContentSizeChange: re,
27371
+ onEndReached: o ? Y : void 0,
27302
27372
  ListHeaderComponent: u ? q(H, { children: u }) : null,
27303
27373
  ListFooterComponent: s ? q(mm, {
27304
27374
  size: "sm",
27305
- accessibilityLabel: M.loadingOlder,
27306
- style: j.older
27375
+ accessibilityLabel: N.loadingOlder,
27376
+ style: M.older
27307
27377
  }) : null,
27308
27378
  ListEmptyComponent: f ? q(H, {
27309
- style: j.fill,
27379
+ style: M.fill,
27310
27380
  children: f
27311
27381
  }) : null,
27312
- renderScrollComponent: v ? Y : void 0,
27382
+ renderScrollComponent: v ? Q : void 0,
27313
27383
  contentContainerStyle: [
27314
- j.content,
27315
- e.length === 0 ? j.grow : null,
27316
- C
27384
+ M.content,
27385
+ e.length === 0 ? M.grow : null,
27386
+ w
27317
27387
  ],
27318
- testID: E
27319
- }), I ? J(H, {
27320
- style: j.jump,
27388
+ testID: D
27389
+ }), z ? J(H, {
27390
+ style: M.jump,
27321
27391
  pointerEvents: "box-none",
27322
27392
  children: [q(H, {
27323
- style: j.jumpDisc,
27393
+ style: M.jumpDisc,
27324
27394
  children: q(mb, {
27325
27395
  icon: "arrow-down",
27326
- accessibilityLabel: X,
27396
+ accessibilityLabel: ie,
27327
27397
  variant: "ghost",
27328
27398
  tone: "neutral",
27329
- onPress: V,
27330
- testID: E ? `${E}-jump` : void 0
27399
+ onPress: G,
27400
+ testID: D ? `${D}-jump` : void 0
27331
27401
  })
27332
- }), R > 0 ? q(H, {
27333
- style: j.count,
27402
+ }), V > 0 ? q(H, {
27403
+ style: M.count,
27334
27404
  pointerEvents: "none",
27335
27405
  importantForAccessibility: "no-hide-descendants",
27336
27406
  accessibilityElementsHidden: !0,
27337
27407
  children: q(Sv, {
27338
- value: R,
27408
+ value: V,
27339
27409
  max: 99,
27340
27410
  tone: "primary",
27341
27411
  size: "sm"
@@ -32956,10 +33026,14 @@ var vD = (e) => R.create({
32956
33026
  P,
32957
33027
  R,
32958
33028
  w.motion.duration.fast
32959
- ]), U = Ge(() => ({ transform: [{ translateX: M.value }] })), ee = Ge(() => ({ width: M.value + D + E })), W = Ge(() => {
33029
+ ]), U = Ge(() => ({ transform: [{ translateX: M.value }] }), [M]), ee = Ge(() => ({ width: M.value + D + E }), [
33030
+ M,
33031
+ D,
33032
+ E
33033
+ ]), W = Ge(() => {
32960
33034
  let e = N.value > 0 ? N.value : 1;
32961
33035
  return { opacity: Math.max(0, 1 - M.value / (.6 * e)) };
32962
- });
33036
+ }, [N, M]);
32963
33037
  return J(H, {
32964
33038
  ref: n,
32965
33039
  style: [
@@ -33136,7 +33210,11 @@ function PD({ rowKey: e, index: t, count: n, shift: r, isActive: i, dragging: a,
33136
33210
  let _ = Ge(() => ({
33137
33211
  transform: [{ translateY: i ? c.dragY.value : g.value }],
33138
33212
  zIndex: +!!i
33139
- })), v = m(() => {
33213
+ }), [
33214
+ i,
33215
+ c,
33216
+ g
33217
+ ]), v = m(() => {
33140
33218
  let { dragIndex: e, dropTo: n, dragY: r, translation: i, absoluteY: a, scrollY: u, scrollStart: d, hostOffset: f, hostStart: p, hostTarget: m, heights: h } = c, { onLift: g, onDrop: _, onSettled: v } = l, y = ut.Pan().enabled(!s).onStart((o) => {
33141
33219
  "worklet";
33142
33220
  a.value = o.absoluteY, e.value = t, n.value = t, d.value = u.value, p.value = f.value, m.value = f.value, i.value = 0, r.value = 0, Ve(g)(t);
@@ -36208,7 +36286,7 @@ var nk = (e) => R.create({
36208
36286
  e,
36209
36287
  i
36210
36288
  ]);
36211
- let a = Ge(() => ({ opacity: i.value }));
36289
+ let a = Ge(() => ({ opacity: i.value }), [i]);
36212
36290
  return q(Ee.View, { style: [
36213
36291
  r,
36214
36292
  { backgroundColor: n },
@@ -36349,7 +36427,11 @@ var nk = (e) => R.create({
36349
36427
  { translateX: p.value },
36350
36428
  { translateY: h.value },
36351
36429
  { scale: u.value }
36352
- ] }));
36430
+ ] }), [
36431
+ p,
36432
+ h,
36433
+ u
36434
+ ]);
36353
36435
  return q(dt, {
36354
36436
  gesture: C,
36355
36437
  children: q(Ee.View, {
@@ -36991,7 +37073,7 @@ var dk = R.create({
36991
37073
  kind: "WeborityPhone",
36992
37074
  library: {
36993
37075
  name: "@webority/mobile-ui",
36994
- version: "0.130.3"
37076
+ version: "0.131.0"
36995
37077
  },
36996
37078
  rendererProtocolVersion: 13,
36997
37079
  platform: "Phone",
@@ -55078,6 +55160,11 @@ var dk = R.create({
55078
55160
  components: [],
55079
55161
  values: {}
55080
55162
  },
55163
+ {
55164
+ version: "0.114.0",
55165
+ components: [],
55166
+ values: {}
55167
+ },
55081
55168
  {
55082
55169
  version: "0.130.0",
55083
55170
  components: [
@@ -2,7 +2,7 @@
2
2
  "kind": "WeborityPhone",
3
3
  "library": {
4
4
  "name": "@webority/mobile-ui",
5
- "version": "0.130.3"
5
+ "version": "0.131.0"
6
6
  },
7
7
  "rendererProtocolVersion": 13,
8
8
  "platform": "Phone",
@@ -22615,6 +22615,11 @@
22615
22615
  "components": [],
22616
22616
  "values": {}
22617
22617
  },
22618
+ {
22619
+ "version": "0.114.0",
22620
+ "components": [],
22621
+ "values": {}
22622
+ },
22618
22623
  {
22619
22624
  "version": "0.130.0",
22620
22625
  "components": [
@@ -1,21 +1,21 @@
1
1
  {
2
2
  "name": "webority-phone",
3
- "version": "0.130.3",
3
+ "version": "0.131.0",
4
4
  "platform": "Phone",
5
5
  "kitModuleVersion": 2,
6
6
  "rendererProtocolVersion": 13,
7
7
  "library": {
8
8
  "name": "@webority/mobile-ui",
9
- "version": "0.130.3"
9
+ "version": "0.131.0"
10
10
  },
11
11
  "files": {
12
12
  "manifest.json": {
13
- "sha256": "f53003c56876d70b6710225e9391cb2b964b6e71d311024d48c4b547143f0fa0",
14
- "bytes": 662171
13
+ "sha256": "576741fa610212e433381257501d8eaafe727f43c05ddde24b17c62327c12d01",
14
+ "bytes": 662255
15
15
  },
16
16
  "kit.js": {
17
- "sha256": "7fd16eefd962ab6c9fc055f99e03f0f2d87134c2a5e6d4cee532c00d77899599",
18
- "bytes": 6106511
17
+ "sha256": "d71c8f815cbfd3ca7c602775257494283285db94cfad97c5f0230edddee3a997",
18
+ "bytes": 6107361
19
19
  },
20
20
  "kit.css": {
21
21
  "sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.useBottomSheet=exports.default=exports.DEFAULT_BOTTOM_SHEET_LABELS=exports.BottomSheet=void 0;var cache,_react=require("react"),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_reactNativeKeyboardController=require("react-native-keyboard-controller"),_reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated")),_reactNativeSafeAreaContext=require("react-native-safe-area-context"),_usePresenceMotion=require("../../hooks/usePresenceMotion.js"),_index=require("../../theme/index.js"),_index2=require("../../utils/index.js"),_color=require("../../utils/color.js"),_corners=require("../../utils/corners.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_OverlayActions=require("../Dialog/OverlayActions.js"),_Modal=require("../Modal/Modal.js"),_ModalSafeArea=require("../ModalSafeArea/ModalSafeArea.js"),_index3=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var a,r,n=Object.defineProperty,o={__proto__:null,default:e};if(Object(e)!==e)return o;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,o)}for(r in e)"default"!==r&&{}.hasOwnProperty.call(e,r)&&((a=n&&Object.getOwnPropertyDescriptor(e,r))&&(a.get||a.set)?n(o,r,a):o[r]=e[r]);return o}const DEFAULT_BOTTOM_SHEET_LABELS=exports.DEFAULT_BOTTOM_SHEET_LABELS=Object.freeze({close:"Close bottom sheet",dragHandle:"Drag handle"}),DEFAULT_SNAP_POINTS=["content"],TABLET_MIN_SHORT_SIDE=600,DIALOG_MAX_WIDTH=560,BottomSheetContext=(0,_react.createContext)(null),useBottomSheet=()=>{const e=(0,_react.useContext)(BottomSheetContext);if(!e)throw new Error("[@webority/mobile-ui] BottomSheet: useBottomSheet must be used inside a <BottomSheet>.");return e};exports.useBottomSheet=useBottomSheet;const SPRING_CONFIG={damping:20,stiffness:240,mass:1},CLOSE_VELOCITY_THRESHOLD=1e3,DRAG_ACTIVATION_OFFSET=10,BottomSheet=e=>{const{snapPoints:t=DEFAULT_SNAP_POINTS,open:a,onClose:r,snapIndex:n,onSnapChange:o,onAnimate:i,onAfterClose:s,enablePanDownToClose:c=!0,enableBackdropPress:l=!0,onBeforeClose:u,title:d,labels:_,scrollable:h=!1,scrollRef:m,onScroll:v,onContentSizeChange:f,onScrollLayout:S,scrollEventThrottle:b,keyboardBehavior:p="shift",inline:y=!1,presentation:x="sheet",animateMount:R=!0,handleIndicatorStyle:N,containerStyle:g,header:w,actions:j,actionsLayout:C="auto",footer:M,headerStyle:O,footerStyle:E,children:T,accessibilityLabel:k,accessibilityViewIsModal:I,testID:A}=e;(0,_warnInvalidValue.warnInvalidValue)("BottomSheet","presentation",e.presentation,["sheet","dialog","auto"]),(0,_warnInvalidValue.warnInvalidValue)("BottomSheet","keyboardBehavior",e.keyboardBehavior,["none","shift"]),(0,_warnInvalidValue.warnInvalidValue)("BottomSheet","actionsLayout",e.actionsLayout,_OverlayActions.ACTIONS_LAYOUTS);const B=(0,_react.useMemo)(()=>({...DEFAULT_BOTTOM_SHEET_LABELS,..._}),[_]),L=null!=w||null!=d,P=null!=j&&j.length>0,V=null!=M||P,D=y?"inline":"modal",H=(0,_index.useTheme)(),G=(0,_usePresenceMotion.usePresenceMotion)(),q=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),[F,U]=(0,_react.useState)(()=>_reactNative.Dimensions.get("window").height),[J,z]=(0,_react.useState)(()=>_reactNative.Dimensions.get("window").width),W=(0,_react.useCallback)(e=>{const{height:t,width:a}=e.nativeEvent.layout;t>0&&U(e=>e===t?e:t),a>0&&z(e=>e===a?e:a)},[]),Y=(0,_reactNative.useWindowDimensions)(),K="dialog"===x||"auto"===x&&Math.min(Y.width,Y.height)>=600,$=Math.min(560,J-2*H.space.xl),[X,Q]=(0,_ModalSafeArea.useModalInsets)(),Z="modal"===D?X.top:q.top,ee="modal"===D?X.bottom:q.bottom,te=t.includes("content"),[ae,re]=useMeasuredHeight(),[ne,oe]=useMeasuredHeight(),[ie,se,ce]=useMeasuredHeight(),[le,ue]=useMeasuredHeight(),de=K?H.space.md:ae,he=te?Math.min(de+(L?ne:0)+ie+(V?le:0)+ee,F-Z):0,me=(0,_react.useCallback)((e,t)=>{te&&ce(t),f?.(e,t)},[te,f,ce]),ve=(0,_react.useMemo)(()=>resolveSnapPoints(t,F,he),[t,F,he]),fe=F,Se=ve[ve.length-1]??0,be=(0,_reactNativeReanimated.useSharedValue)(fe),pe=(0,_reactNativeReanimated.useSharedValue)(fe),ye=(0,_reactNativeReanimated.useSharedValue)(1),xe=(0,_reactNativeReanimated.useSharedValue)(-1),[Re,Ne]=(0,_react.useState)(-1),ge=(0,_react.useRef)(!1),[we,je]=(0,_react.useState)(!1),[Ce,Me]=(0,_react.useState)(!1),Oe=(0,_react.useRef)(!1),Ee=(0,_react.useRef)(s);Ee.current=s;const[Te,ke]=(0,_react.useState)(!1),Ie=(0,_react.useRef)(!R&&a),Ae=(0,_react.useRef)(-1),Be=(0,_react.useRef)(!1);Be.current="modal"===D?Ce:Te;const Le=(0,_react.useRef)(u);Le.current=u;const Pe=(0,_react.useRef)(r);Pe.current=r;const Ve=(0,_react.useRef)(!1),De=(0,_react.useRef)(!0),He=(0,_react.useRef)([]),Ge=(0,_react.useCallback)(e=>{const t=He.current;He.current=[];for(const a of t)a(e)},[]);(0,_react.useEffect)(()=>(De.current=!0,()=>{De.current=!1,Ge(!1)}),[Ge]);const qe=(0,_react.useCallback)(e=>{if(e<0||e>=ve.length)return fe;const t=ve[e];return K?(F-t)/2:F-t},[ve,F,fe,K]),Fe=(0,_react.useCallback)(e=>{Ae.current=e;Re!==e&&(Ne(e),xe.value=e,e>=0&&o?.(e))},[Re,xe,o]),Ue=(0,_react.useCallback)(()=>{ge.current=!1,xe.value<0&&(Oe.current=!0,"modal"===D?(je(!1),"ios"!==_reactNative.Platform.OS&&Me(!1)):ke(!1))},[D,xe]),Je=(0,_react.useCallback)(()=>{Oe.current&&Me(!1)},[]);(0,_react.useEffect)(()=>{("modal"===D?!Ce:!Te)&&Oe.current&&(Oe.current=!1,Ee.current?.(),Ge(!0))},[D,Ce,Te,Ge]);const ze=(0,_react.useCallback)((e,t,a)=>{ge.current=!0,i?.(t,a),be.value=(0,_reactNativeReanimated.withSpring)(e,SPRING_CONFIG,e=>{"worklet";e&&(0,_reactNativeReanimated.runOnJS)(Ue)()})},[i,be,Ue]),We=(0,_react.useCallback)(e=>{const t="number"==typeof e?clamp(e,0,ve.length-1):Re>=0?Re:0,a=xe.value,r=qe(t);return Oe.current=!1,Ge(!1),"modal"===D?(Me(!0),je(!0)):ke(!0),a<0&&Ie.current?(be.value=r,ye.value=1,Fe(t),void i?.(a,t)):a<0&&G.reduced?(be.value=r,ye.value=0,ye.value=(0,_reactNativeReanimated.withTiming)(1,{duration:G.duration("fast"),easing:_reactNativeReanimated.Easing.bezier(...H.motion.ease.decelerate),reduceMotion:_usePresenceMotion.PRESENCE_REDUCE_MOTION}),Fe(t),void i?.(a,t)):(a<0&&(be.value=fe,ye.value=1),Fe(t),void ze(r,a,t))},[ze,fe,Re,xe,D,i,G,ye,ve.length,Fe,Ge,H.motion.ease.decelerate,be,qe]),Ye=(0,_react.useCallback)(()=>new Promise(e=>{if(Ae.current<0)return void(Be.current?He.current.push(e):e(!0));He.current.push(e),Ie.current=!1;const t=xe.value;Fe(-1),ge.current=!0,i?.(t,-1);const a=G.reduced?ye:be,r=G.reduced?0:fe;a.value=(0,_reactNativeReanimated.withTiming)(r,{duration:G.duration("fast"),easing:_reactNativeReanimated.Easing.bezier(...H.motion.ease.accelerate),reduceMotion:_usePresenceMotion.PRESENCE_REDUCE_MOTION},e=>{"worklet";e&&(0,_reactNativeReanimated.runOnJS)(Ue)()})}),[fe,xe,Ue,i,G,ye,Fe,be,H.motion.ease.accelerate]),Ke=(0,_react.useCallback)((e,t,a)=>{const r=Le.current;if(!r)return void e();if(Ve.current)return void t?.();const n=r();"boolean"!=typeof n?(Ve.current=!0,a?.(),n.then(a=>{Ve.current=!1,a&&De.current&&Ae.current>=0?e():t?.()},e=>{throw Ve.current=!1,e})):(n?e:t)?.()},[]),$e=(0,_react.useCallback)(()=>new Promise(e=>{Ae.current<0?e(!0):Ke(()=>{Pe.current(),Ye(),e(!0)},()=>e(!1))}),[Ye,Ke]),Xe=(0,_react.useCallback)(()=>{Pe.current()},[]),Qe=(0,_react.useCallback)(()=>{l&&$e()},[l,$e]),Ze=(0,_react.useRef)(null);(0,_react.useEffect)(()=>{const e=Ze.current!==a;Ze.current=a,e?a?We(n??0):Ye():a&&"number"==typeof n&&n!==xe.value&&We(n)},[a,n]);const et=(0,_react.useRef)({hostHeight:F,contentSnap:he});(0,_react.useEffect)(()=>{const e=et.current;if(e.hostHeight===F&&e.contentSnap===he)return;if(et.current={hostHeight:F,contentSnap:he},e.hostHeight===F&&xe.value<0)return;const t=qe(xe.value);be.value=Ie.current?t:(0,_reactNativeReanimated.withSpring)(t,SPRING_CONFIG)},[F,he]);const tt=F-Se,at=(0,_react.useMemo)(()=>ve.map(e=>F-e),[ve,F]),rt=(0,_react.useCallback)(()=>{const e=Ae.current;e<0||ze(qe(e),e,e)},[ze,qe]),nt=(0,_react.useCallback)((e,t)=>{const a=xe.value;-1!==e?(Fe(e),ze(t,a,e)):Ke(()=>{_reactNative.Keyboard.dismiss(),(0,_index2.triggerHaptic)("selection"),Pe.current(),Ye()},rt,rt)},[ze,Ye,xe,Ke,Fe,rt]),ot=(0,_react.useMemo)(()=>_reactNativeGestureHandler.Gesture.Native().withTestId(A?`${A}-content-gesture`:"bottom-sheet-content-gesture"),[A]),it=(0,_react.useMemo)(()=>{const e=at,t=fe,a=tt,r=c;return _reactNativeGestureHandler.Gesture.Pan().withTestId(A?`${A}-pan-gesture`:"bottom-sheet-pan-gesture").activeOffsetY([-10,10]).failOffsetX([-15,15]).onStart(()=>{"worklet";pe.value=be.value}).onUpdate(e=>{"worklet";const t=pe.value+e.translationY;be.value=t<a?a+.25*(t-a):t}).onEnd(a=>{"worklet";const n=be.value;if(a.velocityY>1e3)return r?void(0,_reactNativeReanimated.runOnJS)(nt)(-1,t):void(0,_reactNativeReanimated.runOnJS)(nt)(0,e[0]);let o=0,i=Math.abs(n-e[0]);for(let t=1;t<e.length;t++){const a=Math.abs(n-e[t]);a<i&&(i=a,o=t)}const s=e[0];r&&n-s>80?(0,_reactNativeReanimated.runOnJS)(nt)(-1,t):(0,_reactNativeReanimated.runOnJS)(nt)(o,e[o])})},[fe,pe,c,nt,tt,at,A,be]),{height:st}=(0,_reactNativeKeyboardController.useReanimatedKeyboardAnimation)(),ct="shift"===p,lt=(0,_reactNativeReanimated.useDerivedValue)(()=>ct?st.value:0),ut=ve[Re>=0?Re:0]??Se,dt=H.space.md,_t=(0,_reactNativeReanimated.useAnimatedStyle)(()=>{if(K){const e=lt.value,t=F+e-ut-dt,a=e<0&&be.value>t?t:be.value;return{top:a<Z?Z:a,opacity:ye.value}}const e=be.value+lt.value,t=lt.value<0?Z:tt;return{top:e<t?t:e,opacity:ye.value}}),ht=(0,_reactNativeReanimated.useAnimatedStyle)(()=>{const e=lt.value;if(K){const t=F+e-ut-dt,a=e<0&&be.value>t?t:be.value,r=F+e-dt-(a<Z?Z:a);return{height:r<0?0:r>ut?ut:r}}const t=e<0?Z:tt,a=be.value+e,r=F+e-(a<t?t:a);return{height:r<0?0:r>Se?Se:r}}),mt=Re>=0,vt=(0,_react.useMemo)(()=>buildStyles(H),[H]),ft=(0,_react.useCallback)(()=>{l&&Ke(()=>{(0,_index2.triggerHaptic)("selection"),Pe.current(),Ye()})},[l,Ye,Ke]),St=(0,_react.useMemo)(()=>_reactNativeGestureHandler.Gesture.Tap().withTestId(A?`${A}-backdrop-gesture`:"bottom-sheet-backdrop-gesture").maxDuration(250).onEnd((_e,e)=>{"worklet";e&&(0,_reactNativeReanimated.runOnJS)(ft)()}),[ft,A]),bt=(0,_react.useMemo)(()=>({snapIndex:Re,snapPoints:ve,close:Xe,requestClose:$e}),[Re,ve,Xe,$e]);if("inline"===D&&!Te)return null;if("modal"===D&&!Ce)return null;const pt=(0,_jsxRuntime.jsxs)(_reactNative.View,{collapsable:!1,style:["modal"===D?vt.backdropModal:vt.backdropInline,{backgroundColor:"modal"===D?(0,_color.transparentOf)(H.colors.scrim):H.colors.scrim}],onLayout:W,testID:A,accessibilityViewIsModal:I??mt,children:[(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:St,children:(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:_reactNative.StyleSheet.absoluteFill,accessibilityRole:"button",accessibilityLabel:B.close})}),(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{accessibilityRole:"alert",accessibilityLabel:k,accessibilityViewIsModal:I??mt,accessibilityActions:[{name:"escape",label:B.close}],onAccessibilityAction:e=>{"escape"===e.nativeEvent.actionName&&Qe()},onAccessibilityEscape:Qe,style:[vt.sheet,{height:Se,backgroundColor:H.colors.surface,borderTopLeftRadius:H.radius.xl,borderTopRightRadius:H.radius.xl,..._corners.smoothCorners,...H.shadow.modal},K?{height:ut,left:(J-$)/2,right:void 0,width:$,borderBottomLeftRadius:H.radius.xl,borderBottomRightRadius:H.radius.xl}:null,g,_t],children:(0,_jsxRuntime.jsxs)(SheetBody,{style:[vt.body,ht],keyboardOffset:lt,children:[K?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{height:H.space.md}}):(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:it,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:vt.handleRow,onLayout:te?re:void 0,accessible:!0,accessibilityLabel:B.dragHandle,accessibilityHint:"Drag up or down to resize the sheet, or swipe down to close it",testID:A?`${A}-handle`:"bottom-sheet-handle",children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:[vt.handle,{backgroundColor:H.colors.border},N]})})}),L&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[vt.header,O],onLayout:te?oe:void 0,children:[null!=d?(0,_jsxRuntime.jsx)(_index3.Text,{variant:"title",accessibilityRole:"header",children:d}):null,w]}),h?(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:ot,children:(0,_jsxRuntime.jsx)(_reactNative.ScrollView,{ref:m,style:vt.scrollContent,onScroll:v,onContentSizeChange:me,onLayout:S,scrollEventThrottle:b,keyboardShouldPersistTaps:"always",keyboardDismissMode:"none",children:T})}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:te?[vt.content,{overflow:"visible"}]:vt.content,children:te?(0,_jsxRuntime.jsx)(_reactNative.View,{onLayout:se,children:T}):T}),V&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[vt.footer,E],onLayout:te?ue:void 0,children:[P?(0,_jsxRuntime.jsx)(_reactNative.View,{style:vt.actions,children:(0,_jsxRuntime.jsx)(_OverlayActions.OverlayActions,{actions:j??[],layout:C})}):null,M]})]})})]}),yt=(0,_jsxRuntime.jsx)(BottomSheetContext.Provider,{value:bt,children:pt});return"modal"===D?(0,_jsxRuntime.jsx)(_Modal.Modal,{open:we,onClose:Qe,presentation:"fullScreen",bare:!0,backdropPressClose:!1,haptic:!1,animateMount:!1,onInsetsChange:Q,onDismissed:"ios"===_reactNative.Platform.OS?Je:void 0,children:"android"===_reactNative.Platform.OS?(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureHandlerRootView,{style:vt.modalRoot,children:yt}):yt}):yt};exports.BottomSheet=BottomSheet;const SheetBody=({style:e,keyboardOffset:t,children:a})=>{const r=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)().bottom,n=(0,_reactNativeReanimated.useAnimatedStyle)(()=>{const e=r+t.value;return{paddingBottom:e>0?e:0}});return(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[e,n],children:a})};BottomSheet.displayName="BottomSheet";const useMeasuredHeight=()=>{const[e,t]=(0,_react.useState)(0),a=(0,_react.useCallback)(e=>{t(t=>t===e?t:e)},[]);return[e,(0,_react.useCallback)(e=>a(e.nativeEvent.layout.height),[a]),a]},resolveSnapPoints=(e,t,a)=>[...e.map(e=>{if("number"==typeof e)return e;if("content"===e)return a;const r=parseFloat(e);return Number.isNaN(r)?0:r/100*t})].sort((e,t)=>e-t),clamp=(e,t,a)=>Math.min(Math.max(e,t),a),buildStyles=e=>_reactNative.StyleSheet.create({backdropModal:{flex:1},backdropInline:{..._reactNative.StyleSheet.absoluteFill},sheet:{position:"absolute",left:0,right:0,overflow:"hidden"},body:{overflow:"hidden"},handleRow:{alignItems:"center",justifyContent:"center",alignSelf:"stretch",paddingTop:e.space.md,paddingBottom:e.space.xl},header:{},actions:{padding:e.space.lg},footer:{},handle:{width:36,height:4,borderRadius:e.radius.pill,..._corners.smoothCorners},content:{flex:1,overflow:"hidden"},scrollContent:{flex:1},modalRoot:{flex:1}});var _default=exports.default=BottomSheet;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.useBottomSheet=exports.default=exports.DEFAULT_BOTTOM_SHEET_LABELS=exports.BottomSheet=void 0;var cache,_react=require("react"),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_reactNativeKeyboardController=require("react-native-keyboard-controller"),_reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated")),_reactNativeSafeAreaContext=require("react-native-safe-area-context"),_usePresenceMotion=require("../../hooks/usePresenceMotion.js"),_index=require("../../theme/index.js"),_index2=require("../../utils/index.js"),_color=require("../../utils/color.js"),_corners=require("../../utils/corners.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_OverlayActions=require("../Dialog/OverlayActions.js"),_Modal=require("../Modal/Modal.js"),_ModalSafeArea=require("../ModalSafeArea/ModalSafeArea.js"),_index3=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var a,r,n=Object.defineProperty,o={__proto__:null,default:e};if(Object(e)!==e)return o;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,o)}for(r in e)"default"!==r&&{}.hasOwnProperty.call(e,r)&&((a=n&&Object.getOwnPropertyDescriptor(e,r))&&(a.get||a.set)?n(o,r,a):o[r]=e[r]);return o}const DEFAULT_BOTTOM_SHEET_LABELS=exports.DEFAULT_BOTTOM_SHEET_LABELS=Object.freeze({close:"Close bottom sheet",dragHandle:"Drag handle"}),DEFAULT_SNAP_POINTS=["content"],TABLET_MIN_SHORT_SIDE=600,DIALOG_MAX_WIDTH=560,BottomSheetContext=(0,_react.createContext)(null),useBottomSheet=()=>{const e=(0,_react.useContext)(BottomSheetContext);if(!e)throw new Error("[@webority/mobile-ui] BottomSheet: useBottomSheet must be used inside a <BottomSheet>.");return e};exports.useBottomSheet=useBottomSheet;const SPRING_CONFIG={damping:20,stiffness:240,mass:1},CLOSE_VELOCITY_THRESHOLD=1e3,DRAG_ACTIVATION_OFFSET=10,BottomSheet=e=>{const{snapPoints:t=DEFAULT_SNAP_POINTS,open:a,onClose:r,snapIndex:n,onSnapChange:o,onAnimate:i,onAfterClose:s,enablePanDownToClose:c=!0,enableBackdropPress:l=!0,onBeforeClose:u,title:d,labels:_,scrollable:h=!1,scrollRef:m,onScroll:v,onContentSizeChange:f,onScrollLayout:S,scrollEventThrottle:b,keyboardBehavior:p="shift",inline:y=!1,presentation:x="sheet",animateMount:R=!0,handleIndicatorStyle:N,containerStyle:g,header:w,actions:j,actionsLayout:C="auto",footer:M,headerStyle:O,footerStyle:E,children:T,accessibilityLabel:k,accessibilityViewIsModal:I,testID:A}=e;(0,_warnInvalidValue.warnInvalidValue)("BottomSheet","presentation",e.presentation,["sheet","dialog","auto"]),(0,_warnInvalidValue.warnInvalidValue)("BottomSheet","keyboardBehavior",e.keyboardBehavior,["none","shift"]),(0,_warnInvalidValue.warnInvalidValue)("BottomSheet","actionsLayout",e.actionsLayout,_OverlayActions.ACTIONS_LAYOUTS);const B=(0,_react.useMemo)(()=>({...DEFAULT_BOTTOM_SHEET_LABELS,..._}),[_]),L=null!=w||null!=d,P=null!=j&&j.length>0,V=null!=M||P,D=y?"inline":"modal",H=(0,_index.useTheme)(),G=(0,_usePresenceMotion.usePresenceMotion)(),q=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),[F,U]=(0,_react.useState)(()=>_reactNative.Dimensions.get("window").height),[J,z]=(0,_react.useState)(()=>_reactNative.Dimensions.get("window").width),W=(0,_react.useCallback)(e=>{const{height:t,width:a}=e.nativeEvent.layout;t>0&&U(e=>e===t?e:t),a>0&&z(e=>e===a?e:a)},[]),Y=(0,_reactNative.useWindowDimensions)(),K="dialog"===x||"auto"===x&&Math.min(Y.width,Y.height)>=600,$=Math.min(560,J-2*H.space.xl),[X,Q]=(0,_ModalSafeArea.useModalInsets)(),Z="modal"===D?X.top:q.top,ee="modal"===D?X.bottom:q.bottom,te=t.includes("content"),[ae,re]=useMeasuredHeight(),[ne,oe]=useMeasuredHeight(),[ie,se,ce]=useMeasuredHeight(),[le,ue]=useMeasuredHeight(),de=K?H.space.md:ae,he=te?Math.min(de+(L?ne:0)+ie+(V?le:0)+ee,F-Z):0,me=(0,_react.useCallback)((e,t)=>{te&&ce(t),f?.(e,t)},[te,f,ce]),ve=(0,_react.useMemo)(()=>resolveSnapPoints(t,F,he),[t,F,he]),fe=F,Se=ve[ve.length-1]??0,be=(0,_reactNativeReanimated.useSharedValue)(fe),pe=(0,_reactNativeReanimated.useSharedValue)(fe),ye=(0,_reactNativeReanimated.useSharedValue)(1),xe=(0,_reactNativeReanimated.useSharedValue)(-1),[Re,Ne]=(0,_react.useState)(-1),ge=(0,_react.useRef)(!1),[we,je]=(0,_react.useState)(!1),[Ce,Me]=(0,_react.useState)(!1),Oe=(0,_react.useRef)(!1),Ee=(0,_react.useRef)(s);Ee.current=s;const[Te,ke]=(0,_react.useState)(!1),Ie=(0,_react.useRef)(!R&&a),Ae=(0,_react.useRef)(-1),Be=(0,_react.useRef)(!1);Be.current="modal"===D?Ce:Te;const Le=(0,_react.useRef)(u);Le.current=u;const Pe=(0,_react.useRef)(r);Pe.current=r;const Ve=(0,_react.useRef)(!1),De=(0,_react.useRef)(!0),He=(0,_react.useRef)([]),Ge=(0,_react.useCallback)(e=>{const t=He.current;He.current=[];for(const a of t)a(e)},[]);(0,_react.useEffect)(()=>(De.current=!0,()=>{De.current=!1,Ge(!1)}),[Ge]);const qe=(0,_react.useCallback)(e=>{if(e<0||e>=ve.length)return fe;const t=ve[e];return K?(F-t)/2:F-t},[ve,F,fe,K]),Fe=(0,_react.useCallback)(e=>{Ae.current=e;Re!==e&&(Ne(e),xe.value=e,e>=0&&o?.(e))},[Re,xe,o]),Ue=(0,_react.useCallback)(()=>{ge.current=!1,xe.value<0&&(Oe.current=!0,"modal"===D?(je(!1),"ios"!==_reactNative.Platform.OS&&Me(!1)):ke(!1))},[D,xe]),Je=(0,_react.useCallback)(()=>{Oe.current&&Me(!1)},[]);(0,_react.useEffect)(()=>{("modal"===D?!Ce:!Te)&&Oe.current&&(Oe.current=!1,Ee.current?.(),Ge(!0))},[D,Ce,Te,Ge]);const ze=(0,_react.useCallback)((e,t,a)=>{ge.current=!0,i?.(t,a),be.value=(0,_reactNativeReanimated.withSpring)(e,SPRING_CONFIG,e=>{"worklet";e&&(0,_reactNativeReanimated.runOnJS)(Ue)()})},[i,be,Ue]),We=(0,_react.useCallback)(e=>{const t="number"==typeof e?clamp(e,0,ve.length-1):Re>=0?Re:0,a=xe.value,r=qe(t);return Oe.current=!1,Ge(!1),"modal"===D?(Me(!0),je(!0)):ke(!0),a<0&&Ie.current?(be.value=r,ye.value=1,Fe(t),void i?.(a,t)):a<0&&G.reduced?(be.value=r,ye.value=0,ye.value=(0,_reactNativeReanimated.withTiming)(1,{duration:G.duration("fast"),easing:_reactNativeReanimated.Easing.bezier(...H.motion.ease.decelerate),reduceMotion:_usePresenceMotion.PRESENCE_REDUCE_MOTION}),Fe(t),void i?.(a,t)):(a<0&&(be.value=fe,ye.value=1),Fe(t),void ze(r,a,t))},[ze,fe,Re,xe,D,i,G,ye,ve.length,Fe,Ge,H.motion.ease.decelerate,be,qe]),Ye=(0,_react.useCallback)(()=>new Promise(e=>{if(Ae.current<0)return void(Be.current?He.current.push(e):e(!0));He.current.push(e),Ie.current=!1;const t=xe.value;Fe(-1),ge.current=!0,i?.(t,-1);const a=G.reduced?ye:be,r=G.reduced?0:fe;a.value=(0,_reactNativeReanimated.withTiming)(r,{duration:G.duration("fast"),easing:_reactNativeReanimated.Easing.bezier(...H.motion.ease.accelerate),reduceMotion:_usePresenceMotion.PRESENCE_REDUCE_MOTION},e=>{"worklet";e&&(0,_reactNativeReanimated.runOnJS)(Ue)()})}),[fe,xe,Ue,i,G,ye,Fe,be,H.motion.ease.accelerate]),Ke=(0,_react.useCallback)((e,t,a)=>{const r=Le.current;if(!r)return void e();if(Ve.current)return void t?.();const n=r();"boolean"!=typeof n?(Ve.current=!0,a?.(),n.then(a=>{Ve.current=!1,a&&De.current&&Ae.current>=0?e():t?.()},e=>{throw Ve.current=!1,e})):(n?e:t)?.()},[]),$e=(0,_react.useCallback)(()=>new Promise(e=>{Ae.current<0?e(!0):Ke(()=>{Pe.current(),Ye(),e(!0)},()=>e(!1))}),[Ye,Ke]),Xe=(0,_react.useCallback)(()=>{Pe.current()},[]),Qe=(0,_react.useCallback)(()=>{l&&$e()},[l,$e]),Ze=(0,_react.useRef)(null);(0,_react.useEffect)(()=>{const e=Ze.current!==a;Ze.current=a,e?a?We(n??0):Ye():a&&"number"==typeof n&&n!==xe.value&&We(n)},[a,n]);const et=(0,_react.useRef)({hostHeight:F,contentSnap:he});(0,_react.useEffect)(()=>{const e=et.current;if(e.hostHeight===F&&e.contentSnap===he)return;if(et.current={hostHeight:F,contentSnap:he},e.hostHeight===F&&xe.value<0)return;const t=qe(xe.value);be.value=Ie.current?t:(0,_reactNativeReanimated.withSpring)(t,SPRING_CONFIG)},[F,he]);const tt=F-Se,at=(0,_react.useMemo)(()=>ve.map(e=>F-e),[ve,F]),rt=(0,_react.useCallback)(()=>{const e=Ae.current;e<0||ze(qe(e),e,e)},[ze,qe]),nt=(0,_react.useCallback)((e,t)=>{const a=xe.value;-1!==e?(Fe(e),ze(t,a,e)):Ke(()=>{_reactNative.Keyboard.dismiss(),(0,_index2.triggerHaptic)("selection"),Pe.current(),Ye()},rt,rt)},[ze,Ye,xe,Ke,Fe,rt]),ot=(0,_react.useMemo)(()=>_reactNativeGestureHandler.Gesture.Native().withTestId(A?`${A}-content-gesture`:"bottom-sheet-content-gesture"),[A]),it=(0,_react.useMemo)(()=>{const e=at,t=fe,a=tt,r=c;return _reactNativeGestureHandler.Gesture.Pan().withTestId(A?`${A}-pan-gesture`:"bottom-sheet-pan-gesture").activeOffsetY([-10,10]).failOffsetX([-15,15]).onStart(()=>{"worklet";pe.value=be.value}).onUpdate(e=>{"worklet";const t=pe.value+e.translationY;be.value=t<a?a+.25*(t-a):t}).onEnd(a=>{"worklet";const n=be.value;if(a.velocityY>1e3)return r?void(0,_reactNativeReanimated.runOnJS)(nt)(-1,t):void(0,_reactNativeReanimated.runOnJS)(nt)(0,e[0]);let o=0,i=Math.abs(n-e[0]);for(let t=1;t<e.length;t++){const a=Math.abs(n-e[t]);a<i&&(i=a,o=t)}const s=e[0];r&&n-s>80?(0,_reactNativeReanimated.runOnJS)(nt)(-1,t):(0,_reactNativeReanimated.runOnJS)(nt)(o,e[o])})},[fe,pe,c,nt,tt,at,A,be]),{height:st}=(0,_reactNativeKeyboardController.useReanimatedKeyboardAnimation)(),ct="shift"===p,lt=(0,_reactNativeReanimated.useDerivedValue)(()=>ct?st.value:0,[ct,st]),ut=ve[Re>=0?Re:0]??Se,dt=H.space.md,_t=(0,_reactNativeReanimated.useAnimatedStyle)(()=>{if(K){const e=lt.value,t=F+e-ut-dt,a=e<0&&be.value>t?t:be.value;return{top:a<Z?Z:a,opacity:ye.value}}const e=be.value+lt.value,t=lt.value<0?Z:tt;return{top:e<t?t:e,opacity:ye.value}},[K,lt,F,ut,dt,be,Z,ye,tt]),ht=(0,_reactNativeReanimated.useAnimatedStyle)(()=>{const e=lt.value;if(K){const t=F+e-ut-dt,a=e<0&&be.value>t?t:be.value,r=F+e-dt-(a<Z?Z:a);return{height:r<0?0:r>ut?ut:r}}const t=e<0?Z:tt,a=be.value+e,r=F+e-(a<t?t:a);return{height:r<0?0:r>Se?Se:r}},[lt,K,F,ut,dt,be,Z,tt,Se]),mt=Re>=0,vt=(0,_react.useMemo)(()=>buildStyles(H),[H]),ft=(0,_react.useCallback)(()=>{l&&Ke(()=>{(0,_index2.triggerHaptic)("selection"),Pe.current(),Ye()})},[l,Ye,Ke]),St=(0,_react.useMemo)(()=>_reactNativeGestureHandler.Gesture.Tap().withTestId(A?`${A}-backdrop-gesture`:"bottom-sheet-backdrop-gesture").maxDuration(250).onEnd((_e,e)=>{"worklet";e&&(0,_reactNativeReanimated.runOnJS)(ft)()}),[ft,A]),bt=(0,_react.useMemo)(()=>({snapIndex:Re,snapPoints:ve,close:Xe,requestClose:$e}),[Re,ve,Xe,$e]);if("inline"===D&&!Te)return null;if("modal"===D&&!Ce)return null;const pt=(0,_jsxRuntime.jsxs)(_reactNative.View,{collapsable:!1,style:["modal"===D?vt.backdropModal:vt.backdropInline,{backgroundColor:"modal"===D?(0,_color.transparentOf)(H.colors.scrim):H.colors.scrim}],onLayout:W,testID:A,accessibilityViewIsModal:I??mt,children:[(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:St,children:(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:_reactNative.StyleSheet.absoluteFill,accessibilityRole:"button",accessibilityLabel:B.close})}),(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{accessibilityRole:"alert",accessibilityLabel:k,accessibilityViewIsModal:I??mt,accessibilityActions:[{name:"escape",label:B.close}],onAccessibilityAction:e=>{"escape"===e.nativeEvent.actionName&&Qe()},onAccessibilityEscape:Qe,style:[vt.sheet,{height:Se,backgroundColor:H.colors.surface,borderTopLeftRadius:H.radius.xl,borderTopRightRadius:H.radius.xl,..._corners.smoothCorners,...H.shadow.modal},K?{height:ut,left:(J-$)/2,right:void 0,width:$,borderBottomLeftRadius:H.radius.xl,borderBottomRightRadius:H.radius.xl}:null,g,_t],children:(0,_jsxRuntime.jsxs)(SheetBody,{style:[vt.body,ht],keyboardOffset:lt,children:[K?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{height:H.space.md}}):(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:it,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:vt.handleRow,onLayout:te?re:void 0,accessible:!0,accessibilityLabel:B.dragHandle,accessibilityHint:"Drag up or down to resize the sheet, or swipe down to close it",testID:A?`${A}-handle`:"bottom-sheet-handle",children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:[vt.handle,{backgroundColor:H.colors.border},N]})})}),L&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[vt.header,O],onLayout:te?oe:void 0,children:[null!=d?(0,_jsxRuntime.jsx)(_index3.Text,{variant:"title",accessibilityRole:"header",children:d}):null,w]}),h?(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:ot,children:(0,_jsxRuntime.jsx)(_reactNative.ScrollView,{ref:m,style:vt.scrollContent,onScroll:v,onContentSizeChange:me,onLayout:S,scrollEventThrottle:b,keyboardShouldPersistTaps:"always",keyboardDismissMode:"none",children:T})}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:te?[vt.content,{overflow:"visible"}]:vt.content,children:te?(0,_jsxRuntime.jsx)(_reactNative.View,{onLayout:se,children:T}):T}),V&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[vt.footer,E],onLayout:te?ue:void 0,children:[P?(0,_jsxRuntime.jsx)(_reactNative.View,{style:vt.actions,children:(0,_jsxRuntime.jsx)(_OverlayActions.OverlayActions,{actions:j??[],layout:C})}):null,M]})]})})]}),yt=(0,_jsxRuntime.jsx)(BottomSheetContext.Provider,{value:bt,children:pt});return"modal"===D?(0,_jsxRuntime.jsx)(_Modal.Modal,{open:we,onClose:Qe,presentation:"fullScreen",bare:!0,backdropPressClose:!1,haptic:!1,animateMount:!1,onInsetsChange:Q,onDismissed:"ios"===_reactNative.Platform.OS?Je:void 0,children:"android"===_reactNative.Platform.OS?(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureHandlerRootView,{style:vt.modalRoot,children:yt}):yt}):yt};exports.BottomSheet=BottomSheet;const SheetBody=({style:e,keyboardOffset:t,children:a})=>{const r=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)().bottom,n=(0,_reactNativeReanimated.useAnimatedStyle)(()=>{const e=r+t.value;return{paddingBottom:e>0?e:0}},[r,t]);return(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[e,n],children:a})};BottomSheet.displayName="BottomSheet";const useMeasuredHeight=()=>{const[e,t]=(0,_react.useState)(0),a=(0,_react.useCallback)(e=>{t(t=>t===e?t:e)},[]);return[e,(0,_react.useCallback)(e=>a(e.nativeEvent.layout.height),[a]),a]},resolveSnapPoints=(e,t,a)=>[...e.map(e=>{if("number"==typeof e)return e;if("content"===e)return a;const r=parseFloat(e);return Number.isNaN(r)?0:r/100*t})].sort((e,t)=>e-t),clamp=(e,t,a)=>Math.min(Math.max(e,t),a),buildStyles=e=>_reactNative.StyleSheet.create({backdropModal:{flex:1},backdropInline:{..._reactNative.StyleSheet.absoluteFill},sheet:{position:"absolute",left:0,right:0,overflow:"hidden"},body:{overflow:"hidden"},handleRow:{alignItems:"center",justifyContent:"center",alignSelf:"stretch",paddingTop:e.space.md,paddingBottom:e.space.xl},header:{},actions:{padding:e.space.lg},footer:{},handle:{width:36,height:4,borderRadius:e.radius.pill,..._corners.smoothCorners},content:{flex:1,overflow:"hidden"},scrollContent:{flex:1},modalRoot:{flex:1}});var _default=exports.default=BottomSheet;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.buildPieces=exports.DEFAULT_PHYSICS=exports.Confetti=void 0;var cache,_react=require("react"),_reactNative=require("react-native"),_reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated")),_reactNativeSvg=_interopRequireWildcard(require("react-native-svg")),_index=require("../../hooks/index.js"),_index2=require("../../theme/index.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,a){if(!a&&e&&e.__esModule)return e;var t,r,i=Object.defineProperty,s={__proto__:null,default:e};if(Object(e)!==e)return s;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,s)}for(r in e)"default"!==r&&{}.hasOwnProperty.call(e,r)&&((t=i&&Object.getOwnPropertyDescriptor(e,r))&&(t.get||t.set)?i(s,r,t):s[r]=e[r]);return s}const TAU=2*Math.PI,DEG=Math.PI/180,SPEED_FACTOR={slow:1.6,normal:1,fast:.6},DEFAULT_PHYSICS=exports.DEFAULT_PHYSICS={velocity:1,drag:1,fallSpeed:1,spread:0},PRESET_SHAPES={pop:["strip","strip","strip","square","circle","triangle","star","streamer"],rain:["strip","strip","strip","circle","square"],fireworks:["circle","circle","star","star","triangle","strip"]},rand=(e,a)=>e+Math.random()*(a-e),pick=e=>e[Math.floor(Math.random()*e.length)]??e[0],commonPiece=(e,a)=>({color:e.colors[a%e.colors.length]??e.colors[0],size:e.baseSize*rand(.6,1.4),shape:pick(e.shapes),rotations:rand(1,5),rotateDir:Math.random()<.5?1:-1,flutterFreq:rand(2,5)}),popPiece=(e,a)=>{const t=e.physics.spread>0?e.physics.spread/2:100,r=(-90+rand(-t,t))*DEG,i=rand(1.8,4.2)*e.physics.velocity;return{...commonPiece(e,a),x0Frac:e.originXFrac,y0Frac:e.originYFrac,vxFrac:Math.cos(r)*i*.7,vyFrac:Math.sin(r)*i,drag:rand(5.5,7.5)*e.physics.drag,terminalFrac:rand(.22,.44)*e.physics.fallSpeed,delay:rand(0,.05),swayAmp:rand(4,16),swayFreq:rand(1,3)}},rainPiece=(e,a)=>({...commonPiece(e,a),x0Frac:Math.random(),y0Frac:-.05,vxFrac:rand(-.12,.12)*e.physics.velocity,vyFrac:rand(.05,.25)*e.physics.velocity,drag:rand(2.5,4)*e.physics.drag,terminalFrac:rand(.95,1.35)*e.physics.fallSpeed,delay:rand(0,.35),swayAmp:rand(10,30),swayFreq:rand(1,3)}),FIREWORK_BURSTS=4,buildFireworks=(e,a)=>{const t=Math.max(1,Math.round(e/4)),r=a.physics.spread>0?a.physics.spread/2:180,i=[];for(let s=0;s<4&&i.length<e;s+=1){const n=rand(.18,.82),c=rand(.18,.52),o=s/4*.5+rand(0,.06);for(let s=0;s<t&&i.length<e;s+=1){const e=rand(-r,r)*DEG,t=rand(1.4,3.4)*a.physics.velocity;i.push({...commonPiece(a,i.length),x0Frac:n,y0Frac:c,vxFrac:Math.cos(e)*t*.7,vyFrac:Math.sin(e)*t,drag:rand(6.5,8.5)*a.physics.drag,terminalFrac:rand(.18,.38)*a.physics.fallSpeed,delay:o,swayAmp:rand(3,12),swayFreq:rand(1,3)})}}return i},buildPieces=(e,a,t)=>{if("fireworks"===a)return buildFireworks(e,t);const r="rain"===a?rainPiece:popPiece;return Array.from({length:e},(e,a)=>r(t,a))};exports.buildPieces=buildPieces;const SHAPE_BOX={strip:{w:1,h:.45},square:{w:1,h:1},circle:{w:1,h:1},triangle:{w:1,h:1},star:{w:1.2,h:1.2},streamer:{w:3,h:1.2}},TRIANGLE_POINTS="50,4 96,96 4,96",STAR_POINTS="50,2 61,36 97,36 68,58 79,94 50,72 21,94 32,58 3,36 39,36",STREAMER_PATH="M2,50 C20,6 44,94 62,50 S92,6 98,50",ShapeBody=({shape:e,color:a})=>"triangle"===e||"star"===e?(0,_jsxRuntime.jsx)(_reactNativeSvg.default,{width:"100%",height:"100%",viewBox:"0 0 100 100",children:(0,_jsxRuntime.jsx)(_reactNativeSvg.Polygon,{points:"star"===e?STAR_POINTS:TRIANGLE_POINTS,fill:a})}):"streamer"===e?(0,_jsxRuntime.jsx)(_reactNativeSvg.default,{width:"100%",height:"100%",viewBox:"0 0 100 100",preserveAspectRatio:"none",children:(0,_jsxRuntime.jsx)(_reactNativeSvg.Path,{d:STREAMER_PATH,stroke:a,strokeWidth:22,strokeLinecap:"round",fill:"none"})}):null,ConfettiPiece=({piece:e,progress:a,width:t,height:r,fadeOut:i})=>{const s=(0,_reactNativeReanimated.useAnimatedStyle)(()=>{const s=1-e.delay,n=s<=0?0:Math.min(1,Math.max(0,(a.value-e.delay)/s)),c=(1-Math.exp(-e.drag*n))/e.drag,o=e.x0Frac*t+e.vxFrac*t*c,l=e.y0Frac*r+e.terminalFrac*r*n+(e.vyFrac-e.terminalFrac)*r*c,d=Math.sin(n*e.swayFreq*TAU)*e.swayAmp,h=e.rotateDir*e.rotations*360*n,p=.35+.65*Math.abs(Math.cos(n*e.flutterFreq*TAU));return{opacity:i?Math.max(0,1-Math.max(0,n-.75)/.25):1,transform:[{translateX:o+d},{translateY:l},{rotate:`${h}deg`},{scaleY:p}]}}),n=SHAPE_BOX[e.shape],c="triangle"===e.shape||"star"===e.shape||"streamer"===e.shape;return(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[{position:"absolute",width:e.size*n.w,height:e.size*n.h,borderRadius:"circle"===e.shape?e.size*n.h/2:1,backgroundColor:c?"transparent":e.color},s],children:(0,_jsxRuntime.jsx)(ShapeBody,{shape:e.shape,color:e.color})})},Confetti=exports.Confetti=(0,_react.forwardRef)(({count:e=80,colors:a,preset:t="pop",shapes:r,speed:i="normal",physics:s,origin:n,duration:c=2800,fadeOut:o=!0,autoStart:l=!1,recycle:d=!1,size:h=10,onComplete:p,style:u,testID:_},m)=>{(0,_warnInvalidValue.warnInvalidValue)("Confetti","preset",t,["pop","rain","fireworks"]),(0,_warnInvalidValue.warnInvalidValue)("Confetti","speed",i,["slow","normal","fast"]);for(const e of r??[])(0,_warnInvalidValue.warnInvalidValue)("Confetti","shapes",e,["strip","square","circle","triangle","star","streamer"]);const v=(0,_index2.useTheme)(),y=(0,_index.useReducedMotion)(),f=(0,_reactNative.useWindowDimensions)(),[g,w]=(0,_react.useState)({width:f.width,height:f.height}),[x,S]=(0,_react.useState)(!1),[R,F]=(0,_react.useState)([]),P=(0,_react.useMemo)(()=>a??[v.colors.primary,v.colors.neutral,v.colors.success,v.colors.warning,v.colors.danger,v.colors.info],[a,v.colors]),M=(0,_reactNativeReanimated.useSharedValue)(0),A=c*SPEED_FACTOR[i],E=(0,_react.useCallback)(()=>{S(!1),p?.()},[p]),N=(0,_react.useCallback)(()=>{if(y)return void p?.();(0,_reactNativeReanimated.cancelAnimation)(M),M.value=0,F(buildPieces(e,t,{colors:P,baseSize:h,originXFrac:n?n.x/Math.max(1,g.width):.5,originYFrac:n?n.y/Math.max(1,g.height):.5,physics:{...DEFAULT_PHYSICS,...s},shapes:r??PRESET_SHAPES[t]})),S(!0);const a=(0,_reactNativeReanimated.withTiming)(1,{duration:A,easing:_reactNativeReanimated.Easing.linear},e=>{"worklet";e&&!d&&(0,_reactNativeReanimated.runOnJS)(E)()});M.value=d?(0,_reactNativeReanimated.withRepeat)(a,-1,!1):a},[y,M,A,d,E,p,e,P,t,r,s,h,n,g.width,g.height]),T=(0,_react.useCallback)(()=>{(0,_reactNativeReanimated.cancelAnimation)(M),S(!1)},[M]);(0,_react.useImperativeHandle)(m,()=>({start:N,stop:T}),[N,T]),(0,_react.useEffect)(()=>(l&&N(),()=>(0,_reactNativeReanimated.cancelAnimation)(M)),[]);const j=(0,_react.useCallback)(e=>{const{width:a,height:t}=e.nativeEvent.layout;a>0&&t>0&&w({width:a,height:t})},[]);return(0,_jsxRuntime.jsx)(_reactNative.View,{style:[_reactNative.StyleSheet.absoluteFill,u],pointerEvents:"none",onLayout:j,testID:_,children:x?R.map((e,a)=>(0,_jsxRuntime.jsx)(ConfettiPiece,{piece:e,progress:M,width:g.width,height:g.height,fadeOut:o},a)):null})});Confetti.displayName="Confetti";var _default=exports.default=Confetti;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.buildPieces=exports.DEFAULT_PHYSICS=exports.Confetti=void 0;var cache,_react=require("react"),_reactNative=require("react-native"),_reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated")),_reactNativeSvg=_interopRequireWildcard(require("react-native-svg")),_index=require("../../hooks/index.js"),_index2=require("../../theme/index.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,a){if(!a&&e&&e.__esModule)return e;var t,r,i=Object.defineProperty,s={__proto__:null,default:e};if(Object(e)!==e)return s;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,s)}for(r in e)"default"!==r&&{}.hasOwnProperty.call(e,r)&&((t=i&&Object.getOwnPropertyDescriptor(e,r))&&(t.get||t.set)?i(s,r,t):s[r]=e[r]);return s}const TAU=2*Math.PI,DEG=Math.PI/180,SPEED_FACTOR={slow:1.6,normal:1,fast:.6},DEFAULT_PHYSICS=exports.DEFAULT_PHYSICS={velocity:1,drag:1,fallSpeed:1,spread:0},PRESET_SHAPES={pop:["strip","strip","strip","square","circle","triangle","star","streamer"],rain:["strip","strip","strip","circle","square"],fireworks:["circle","circle","star","star","triangle","strip"]},rand=(e,a)=>e+Math.random()*(a-e),pick=e=>e[Math.floor(Math.random()*e.length)]??e[0],commonPiece=(e,a)=>({color:e.colors[a%e.colors.length]??e.colors[0],size:e.baseSize*rand(.6,1.4),shape:pick(e.shapes),rotations:rand(1,5),rotateDir:Math.random()<.5?1:-1,flutterFreq:rand(2,5)}),popPiece=(e,a)=>{const t=e.physics.spread>0?e.physics.spread/2:100,r=(-90+rand(-t,t))*DEG,i=rand(1.8,4.2)*e.physics.velocity;return{...commonPiece(e,a),x0Frac:e.originXFrac,y0Frac:e.originYFrac,vxFrac:Math.cos(r)*i*.7,vyFrac:Math.sin(r)*i,drag:rand(5.5,7.5)*e.physics.drag,terminalFrac:rand(.22,.44)*e.physics.fallSpeed,delay:rand(0,.05),swayAmp:rand(4,16),swayFreq:rand(1,3)}},rainPiece=(e,a)=>({...commonPiece(e,a),x0Frac:Math.random(),y0Frac:-.05,vxFrac:rand(-.12,.12)*e.physics.velocity,vyFrac:rand(.05,.25)*e.physics.velocity,drag:rand(2.5,4)*e.physics.drag,terminalFrac:rand(.95,1.35)*e.physics.fallSpeed,delay:rand(0,.35),swayAmp:rand(10,30),swayFreq:rand(1,3)}),FIREWORK_BURSTS=4,buildFireworks=(e,a)=>{const t=Math.max(1,Math.round(e/4)),r=a.physics.spread>0?a.physics.spread/2:180,i=[];for(let s=0;s<4&&i.length<e;s+=1){const n=rand(.18,.82),c=rand(.18,.52),o=s/4*.5+rand(0,.06);for(let s=0;s<t&&i.length<e;s+=1){const e=rand(-r,r)*DEG,t=rand(1.4,3.4)*a.physics.velocity;i.push({...commonPiece(a,i.length),x0Frac:n,y0Frac:c,vxFrac:Math.cos(e)*t*.7,vyFrac:Math.sin(e)*t,drag:rand(6.5,8.5)*a.physics.drag,terminalFrac:rand(.18,.38)*a.physics.fallSpeed,delay:o,swayAmp:rand(3,12),swayFreq:rand(1,3)})}}return i},buildPieces=(e,a,t)=>{if("fireworks"===a)return buildFireworks(e,t);const r="rain"===a?rainPiece:popPiece;return Array.from({length:e},(e,a)=>r(t,a))};exports.buildPieces=buildPieces;const SHAPE_BOX={strip:{w:1,h:.45},square:{w:1,h:1},circle:{w:1,h:1},triangle:{w:1,h:1},star:{w:1.2,h:1.2},streamer:{w:3,h:1.2}},TRIANGLE_POINTS="50,4 96,96 4,96",STAR_POINTS="50,2 61,36 97,36 68,58 79,94 50,72 21,94 32,58 3,36 39,36",STREAMER_PATH="M2,50 C20,6 44,94 62,50 S92,6 98,50",ShapeBody=({shape:e,color:a})=>"triangle"===e||"star"===e?(0,_jsxRuntime.jsx)(_reactNativeSvg.default,{width:"100%",height:"100%",viewBox:"0 0 100 100",children:(0,_jsxRuntime.jsx)(_reactNativeSvg.Polygon,{points:"star"===e?STAR_POINTS:TRIANGLE_POINTS,fill:a})}):"streamer"===e?(0,_jsxRuntime.jsx)(_reactNativeSvg.default,{width:"100%",height:"100%",viewBox:"0 0 100 100",preserveAspectRatio:"none",children:(0,_jsxRuntime.jsx)(_reactNativeSvg.Path,{d:STREAMER_PATH,stroke:a,strokeWidth:22,strokeLinecap:"round",fill:"none"})}):null,ConfettiPiece=({piece:e,progress:a,width:t,height:r,fadeOut:i})=>{const s=(0,_reactNativeReanimated.useAnimatedStyle)(()=>{const s=1-e.delay,n=s<=0?0:Math.min(1,Math.max(0,(a.value-e.delay)/s)),c=(1-Math.exp(-e.drag*n))/e.drag,o=e.x0Frac*t+e.vxFrac*t*c,l=e.y0Frac*r+e.terminalFrac*r*n+(e.vyFrac-e.terminalFrac)*r*c,d=Math.sin(n*e.swayFreq*TAU)*e.swayAmp,h=e.rotateDir*e.rotations*360*n,p=.35+.65*Math.abs(Math.cos(n*e.flutterFreq*TAU));return{opacity:i?Math.max(0,1-Math.max(0,n-.75)/.25):1,transform:[{translateX:o+d},{translateY:l},{rotate:`${h}deg`},{scaleY:p}]}},[e,a,t,r,i]),n=SHAPE_BOX[e.shape],c="triangle"===e.shape||"star"===e.shape||"streamer"===e.shape;return(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[{position:"absolute",width:e.size*n.w,height:e.size*n.h,borderRadius:"circle"===e.shape?e.size*n.h/2:1,backgroundColor:c?"transparent":e.color},s],children:(0,_jsxRuntime.jsx)(ShapeBody,{shape:e.shape,color:e.color})})},Confetti=exports.Confetti=(0,_react.forwardRef)(({count:e=80,colors:a,preset:t="pop",shapes:r,speed:i="normal",physics:s,origin:n,duration:c=2800,fadeOut:o=!0,autoStart:l=!1,recycle:d=!1,size:h=10,onComplete:p,style:u,testID:_},m)=>{(0,_warnInvalidValue.warnInvalidValue)("Confetti","preset",t,["pop","rain","fireworks"]),(0,_warnInvalidValue.warnInvalidValue)("Confetti","speed",i,["slow","normal","fast"]);for(const e of r??[])(0,_warnInvalidValue.warnInvalidValue)("Confetti","shapes",e,["strip","square","circle","triangle","star","streamer"]);const v=(0,_index2.useTheme)(),y=(0,_index.useReducedMotion)(),f=(0,_reactNative.useWindowDimensions)(),[g,w]=(0,_react.useState)({width:f.width,height:f.height}),[x,S]=(0,_react.useState)(!1),[R,F]=(0,_react.useState)([]),P=(0,_react.useMemo)(()=>a??[v.colors.primary,v.colors.neutral,v.colors.success,v.colors.warning,v.colors.danger,v.colors.info],[a,v.colors]),M=(0,_reactNativeReanimated.useSharedValue)(0),A=c*SPEED_FACTOR[i],E=(0,_react.useCallback)(()=>{S(!1),p?.()},[p]),N=(0,_react.useCallback)(()=>{if(y)return void p?.();(0,_reactNativeReanimated.cancelAnimation)(M),M.value=0,F(buildPieces(e,t,{colors:P,baseSize:h,originXFrac:n?n.x/Math.max(1,g.width):.5,originYFrac:n?n.y/Math.max(1,g.height):.5,physics:{...DEFAULT_PHYSICS,...s},shapes:r??PRESET_SHAPES[t]})),S(!0);const a=(0,_reactNativeReanimated.withTiming)(1,{duration:A,easing:_reactNativeReanimated.Easing.linear},e=>{"worklet";e&&!d&&(0,_reactNativeReanimated.runOnJS)(E)()});M.value=d?(0,_reactNativeReanimated.withRepeat)(a,-1,!1):a},[y,M,A,d,E,p,e,P,t,r,s,h,n,g.width,g.height]),T=(0,_react.useCallback)(()=>{(0,_reactNativeReanimated.cancelAnimation)(M),S(!1)},[M]);(0,_react.useImperativeHandle)(m,()=>({start:N,stop:T}),[N,T]),(0,_react.useEffect)(()=>(l&&N(),()=>(0,_reactNativeReanimated.cancelAnimation)(M)),[]);const j=(0,_react.useCallback)(e=>{const{width:a,height:t}=e.nativeEvent.layout;a>0&&t>0&&w({width:a,height:t})},[]);return(0,_jsxRuntime.jsx)(_reactNative.View,{style:[_reactNative.StyleSheet.absoluteFill,u],pointerEvents:"none",onLayout:j,testID:_,children:x?R.map((e,a)=>(0,_jsxRuntime.jsx)(ConfettiPiece,{piece:e,progress:M,width:g.width,height:g.height,fadeOut:o},a)):null})});Confetti.displayName="Confetti";var _default=exports.default=Confetti;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.Drawer=exports.DEFAULT_DRAWER_LABELS=void 0;var cache,_react=require("react"),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated")),_reactNativeSafeAreaContext=require("react-native-safe-area-context"),_usePresenceMotion=require("../../hooks/usePresenceMotion.js"),_index=require("../../theme/index.js"),_index2=require("../../utils/index.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var a,r,i=Object.defineProperty,n={__proto__:null,default:e};if(Object(e)!==e)return n;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,n)}for(r in e)"default"!==r&&{}.hasOwnProperty.call(e,r)&&((a=i&&Object.getOwnPropertyDescriptor(e,r))&&(a.get||a.set)?i(n,r,a):n[r]=e[r]);return n}const DEFAULT_DRAWER_LABELS=exports.DEFAULT_DRAWER_LABELS={close:"Close drawer",drawer:"Drawer"},DEFAULT_CLOSE_VELOCITY_THRESHOLD=1e3,DEFAULT_DRAG_ACTIVATION_OFFSET=10,Drawer=exports.Drawer=(0,_react.forwardRef)((e,t)=>{const{open:a,defaultOpen:r=!1,onOpenChange:i,side:n="left",width:o,enableSwipe:s=!0,enableBackdropPress:c=!0,backdropOpacity:l=.5,haptic:u,containerStyle:d,children:_,accessibilityLabel:v,labels:p,testID:h}=e,f=(0,_index.useTheme)();(0,_warnInvalidValue.warnInvalidValue)("Drawer","side",e.side,["left","right","top","bottom"]);const m=(0,_react.useMemo)(()=>({...DEFAULT_DRAWER_LABELS,...p}),[p]),b=(0,_usePresenceMotion.usePresenceMotion)(),R=b.reduced,g=b.duration("default"),w=b.duration("fast"),N=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),E="boolean"==typeof a,[S,y]=(0,_react.useState)(()=>_reactNative.Dimensions.get("window"));(0,_react.useEffect)(()=>{const e=_reactNative.Dimensions.addEventListener("change",({window:e})=>y(e));return()=>e.remove()},[]);const x="left"===n||"right"===n,M=(0,_react.useMemo)(()=>resolveSize(o,x,S),[o,x,S]),D=(0,_react.useMemo)(()=>{switch(n){case"left":case"top":return-M;case"right":case"bottom":return M}},[n,M]),O=(0,_reactNativeReanimated.useSharedValue)(r?0:D),C=(0,_reactNativeReanimated.useSharedValue)(r?0:D),L=(0,_reactNativeReanimated.useSharedValue)(r?1:0),[A,T]=(0,_react.useState)(r),j=(0,_reactNativeReanimated.useSharedValue)(r);(0,_react.useEffect)(()=>{A||R||(O.value=D,C.value=D)},[D,A,O,C,R]);const k=f.motion.spring.snappy,P=(0,_react.useCallback)(()=>{if(R)return O.value=0,void(L.value=(0,_reactNativeReanimated.withTiming)(1,{duration:g,reduceMotion:_usePresenceMotion.PRESENCE_REDUCE_MOTION}));L.value=1,O.value=(0,_reactNativeReanimated.withSpring)(0,k)},[O,L,k,R,g]),I=(0,_react.useCallback)(()=>{R?L.value=(0,_reactNativeReanimated.withTiming)(0,{duration:w,reduceMotion:_usePresenceMotion.PRESENCE_REDUCE_MOTION},e=>{"worklet";e&&(O.value=D)}):O.value=(0,_reactNativeReanimated.withSpring)(D,k)},[O,L,D,k,R,w]),V=(0,_react.useCallback)(e=>{T(t=>t===e?t:(i?.(e),e)),j.value=e},[i,j]),q=(0,_react.useCallback)(()=>{V(!0),P()},[V,P]),F=(0,_react.useCallback)(()=>{V(!1),I()},[V,I]),U=(0,_react.useCallback)(()=>{A?F():q()},[A,q,F]);(0,_react.useImperativeHandle)(t,()=>({open:q,close:F,toggle:U}),[q,F,U]),(0,_react.useEffect)(()=>{E&&a!==A&&(a?q():F())},[a]);const B=(0,_react.useMemo)(()=>{const e=D,t=n,a=s;let r=_reactNativeGestureHandler.Gesture.Pan();return r=x?r.activeOffsetX([-10,10]).failOffsetY([-15,15]):r.activeOffsetY([-10,10]).failOffsetX([-15,15]),r.onStart(()=>{"worklet";a&&(C.value=O.value)}).onUpdate(t=>{"worklet";if(!a)return;const r=x?t.translationX:t.translationY,i=C.value+r,n=Math.min(0,e),o=Math.max(0,e);O.value=i<n?n+.25*(i-n):i>o?o+.25*(i-o):i}).onEnd(r=>{"worklet";if(!a)return;const i=x?r.velocityX:r.velocityY,n=O.value;let o=!1;o="left"===t||"top"===t?i<-1e3:i>1e3;const s=Math.abs(e),c=Math.abs(n)/s;o||c>.5?((0,_reactNativeReanimated.runOnJS)(V)(!1),R?L.value=(0,_reactNativeReanimated.withTiming)(0,{duration:w,reduceMotion:_usePresenceMotion.PRESENCE_REDUCE_MOTION},t=>{"worklet";t&&(O.value=e)}):O.value=(0,_reactNativeReanimated.withSpring)(e,k)):((0,_reactNativeReanimated.runOnJS)(V)(!0),R?(O.value=0,L.value=(0,_reactNativeReanimated.withTiming)(1,{duration:g,reduceMotion:_usePresenceMotion.PRESENCE_REDUCE_MOTION})):O.value=(0,_reactNativeReanimated.withSpring)(0,k))})},[D,C,s,x,O,L,V,n,k,R,g,w]),H=(0,_reactNativeReanimated.useAnimatedStyle)(()=>x?{opacity:L.value,transform:[{translateX:O.value}]}:{opacity:L.value,transform:[{translateY:O.value}]}),W=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({opacity:(0,_reactNativeReanimated.interpolate)(O.value,[D,0],[0,l],_reactNativeReanimated.Extrapolation.CLAMP)*L.value,pointerEvents:Math.abs(O.value-D)<.5?"none":"auto"}),[D,l]),G=(0,_react.useMemo)(()=>buildStyles(f),[f]),Y=(0,_react.useCallback)(()=>{if(!c)return;const e=(0,_index2.resolveHaptic)(u,"selection");e&&(0,_index2.triggerHaptic)(e),F()},[c,F,u]),X=(0,_react.useMemo)(()=>{switch(n){case"left":return{position:"absolute",top:0,bottom:0,left:0,width:M,paddingTop:N.top,paddingBottom:N.bottom,paddingLeft:N.left};case"right":return{position:"absolute",top:0,bottom:0,right:0,width:M,paddingTop:N.top,paddingBottom:N.bottom,paddingRight:N.right};case"top":return{position:"absolute",top:0,left:0,right:0,height:M,paddingTop:N.top,paddingLeft:N.left,paddingRight:N.right};case"bottom":return{position:"absolute",bottom:0,left:0,right:0,height:M,paddingBottom:N.bottom,paddingLeft:N.left,paddingRight:N.right}}},[n,M,N]),z=(0,_react.useRef)(r);return A&&(z.current=!0),z.current?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:_reactNative.StyleSheet.absoluteFill,pointerEvents:"box-none",testID:h,accessibilityViewIsModal:A,children:[(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[G.backdrop,{backgroundColor:f.colors.scrim},W],children:(0,_jsxRuntime.jsx)(_reactNative.Pressable,{style:_reactNative.StyleSheet.absoluteFill,onPress:Y,accessibilityRole:"button",accessibilityLabel:m.close,disabled:!c||!A})}),(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:B,children:(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{accessibilityRole:"alert",accessibilityLabel:v??m.drawer,style:[X,{backgroundColor:f.colors.surface,...f.shadow.modal},d,H],children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:G.content,children:_})})})]}):null});Drawer.displayName="Drawer";const resolveSize=(e,t,a)=>{if("number"==typeof e)return e;if("string"==typeof e){const r=parseFloat(e);if(Number.isNaN(r))return t?280:Math.round(.4*a.height);return r/100*(t?a.width:a.height)}return t?280:Math.round(.4*a.height)},buildStyles=e=>_reactNative.StyleSheet.create({backdrop:{..._reactNative.StyleSheet.absoluteFill},content:{flex:1}});var _default=exports.default=Drawer;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.Drawer=exports.DEFAULT_DRAWER_LABELS=void 0;var cache,_react=require("react"),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated")),_reactNativeSafeAreaContext=require("react-native-safe-area-context"),_usePresenceMotion=require("../../hooks/usePresenceMotion.js"),_index=require("../../theme/index.js"),_index2=require("../../utils/index.js"),_warnInvalidValue=require("../../utils/warnInvalidValue.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var a,r,i=Object.defineProperty,n={__proto__:null,default:e};if(Object(e)!==e)return n;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,n)}for(r in e)"default"!==r&&{}.hasOwnProperty.call(e,r)&&((a=i&&Object.getOwnPropertyDescriptor(e,r))&&(a.get||a.set)?i(n,r,a):n[r]=e[r]);return n}const DEFAULT_DRAWER_LABELS=exports.DEFAULT_DRAWER_LABELS={close:"Close drawer",drawer:"Drawer"},DEFAULT_CLOSE_VELOCITY_THRESHOLD=1e3,DEFAULT_DRAG_ACTIVATION_OFFSET=10,Drawer=exports.Drawer=(0,_react.forwardRef)((e,t)=>{const{open:a,defaultOpen:r=!1,onOpenChange:i,side:n="left",width:o,enableSwipe:s=!0,enableBackdropPress:c=!0,backdropOpacity:l=.5,haptic:u,containerStyle:d,children:_,accessibilityLabel:v,labels:p,testID:h}=e,f=(0,_index.useTheme)();(0,_warnInvalidValue.warnInvalidValue)("Drawer","side",e.side,["left","right","top","bottom"]);const m=(0,_react.useMemo)(()=>({...DEFAULT_DRAWER_LABELS,...p}),[p]),b=(0,_usePresenceMotion.usePresenceMotion)(),R=b.reduced,g=b.duration("default"),w=b.duration("fast"),N=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),E="boolean"==typeof a,[S,y]=(0,_react.useState)(()=>_reactNative.Dimensions.get("window"));(0,_react.useEffect)(()=>{const e=_reactNative.Dimensions.addEventListener("change",({window:e})=>y(e));return()=>e.remove()},[]);const x="left"===n||"right"===n,M=(0,_react.useMemo)(()=>resolveSize(o,x,S),[o,x,S]),D=(0,_react.useMemo)(()=>{switch(n){case"left":case"top":return-M;case"right":case"bottom":return M}},[n,M]),O=(0,_reactNativeReanimated.useSharedValue)(r?0:D),C=(0,_reactNativeReanimated.useSharedValue)(r?0:D),L=(0,_reactNativeReanimated.useSharedValue)(r?1:0),[A,T]=(0,_react.useState)(r),j=(0,_reactNativeReanimated.useSharedValue)(r);(0,_react.useEffect)(()=>{A||R||(O.value=D,C.value=D)},[D,A,O,C,R]);const k=f.motion.spring.snappy,P=(0,_react.useCallback)(()=>{if(R)return O.value=0,void(L.value=(0,_reactNativeReanimated.withTiming)(1,{duration:g,reduceMotion:_usePresenceMotion.PRESENCE_REDUCE_MOTION}));L.value=1,O.value=(0,_reactNativeReanimated.withSpring)(0,k)},[O,L,k,R,g]),I=(0,_react.useCallback)(()=>{R?L.value=(0,_reactNativeReanimated.withTiming)(0,{duration:w,reduceMotion:_usePresenceMotion.PRESENCE_REDUCE_MOTION},e=>{"worklet";e&&(O.value=D)}):O.value=(0,_reactNativeReanimated.withSpring)(D,k)},[O,L,D,k,R,w]),V=(0,_react.useCallback)(e=>{T(t=>t===e?t:(i?.(e),e)),j.value=e},[i,j]),q=(0,_react.useCallback)(()=>{V(!0),P()},[V,P]),F=(0,_react.useCallback)(()=>{V(!1),I()},[V,I]),U=(0,_react.useCallback)(()=>{A?F():q()},[A,q,F]);(0,_react.useImperativeHandle)(t,()=>({open:q,close:F,toggle:U}),[q,F,U]),(0,_react.useEffect)(()=>{E&&a!==A&&(a?q():F())},[a]);const B=(0,_react.useMemo)(()=>{const e=D,t=n,a=s;let r=_reactNativeGestureHandler.Gesture.Pan();return r=x?r.activeOffsetX([-10,10]).failOffsetY([-15,15]):r.activeOffsetY([-10,10]).failOffsetX([-15,15]),r.onStart(()=>{"worklet";a&&(C.value=O.value)}).onUpdate(t=>{"worklet";if(!a)return;const r=x?t.translationX:t.translationY,i=C.value+r,n=Math.min(0,e),o=Math.max(0,e);O.value=i<n?n+.25*(i-n):i>o?o+.25*(i-o):i}).onEnd(r=>{"worklet";if(!a)return;const i=x?r.velocityX:r.velocityY,n=O.value;let o=!1;o="left"===t||"top"===t?i<-1e3:i>1e3;const s=Math.abs(e),c=Math.abs(n)/s;o||c>.5?((0,_reactNativeReanimated.runOnJS)(V)(!1),R?L.value=(0,_reactNativeReanimated.withTiming)(0,{duration:w,reduceMotion:_usePresenceMotion.PRESENCE_REDUCE_MOTION},t=>{"worklet";t&&(O.value=e)}):O.value=(0,_reactNativeReanimated.withSpring)(e,k)):((0,_reactNativeReanimated.runOnJS)(V)(!0),R?(O.value=0,L.value=(0,_reactNativeReanimated.withTiming)(1,{duration:g,reduceMotion:_usePresenceMotion.PRESENCE_REDUCE_MOTION})):O.value=(0,_reactNativeReanimated.withSpring)(0,k))})},[D,C,s,x,O,L,V,n,k,R,g,w]),H=(0,_reactNativeReanimated.useAnimatedStyle)(()=>x?{opacity:L.value,transform:[{translateX:O.value}]}:{opacity:L.value,transform:[{translateY:O.value}]},[x,O,L]),W=(0,_reactNativeReanimated.useAnimatedStyle)(()=>({opacity:(0,_reactNativeReanimated.interpolate)(O.value,[D,0],[0,l],_reactNativeReanimated.Extrapolation.CLAMP)*L.value,pointerEvents:Math.abs(O.value-D)<.5?"none":"auto"}),[O,D,l,L]),G=(0,_react.useMemo)(()=>buildStyles(f),[f]),Y=(0,_react.useCallback)(()=>{if(!c)return;const e=(0,_index2.resolveHaptic)(u,"selection");e&&(0,_index2.triggerHaptic)(e),F()},[c,F,u]),X=(0,_react.useMemo)(()=>{switch(n){case"left":return{position:"absolute",top:0,bottom:0,left:0,width:M,paddingTop:N.top,paddingBottom:N.bottom,paddingLeft:N.left};case"right":return{position:"absolute",top:0,bottom:0,right:0,width:M,paddingTop:N.top,paddingBottom:N.bottom,paddingRight:N.right};case"top":return{position:"absolute",top:0,left:0,right:0,height:M,paddingTop:N.top,paddingLeft:N.left,paddingRight:N.right};case"bottom":return{position:"absolute",bottom:0,left:0,right:0,height:M,paddingBottom:N.bottom,paddingLeft:N.left,paddingRight:N.right}}},[n,M,N]),z=(0,_react.useRef)(r);return A&&(z.current=!0),z.current?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:_reactNative.StyleSheet.absoluteFill,pointerEvents:"box-none",testID:h,accessibilityViewIsModal:A,children:[(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[G.backdrop,{backgroundColor:f.colors.scrim},W],children:(0,_jsxRuntime.jsx)(_reactNative.Pressable,{style:_reactNative.StyleSheet.absoluteFill,onPress:Y,accessibilityRole:"button",accessibilityLabel:m.close,disabled:!c||!A})}),(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:B,children:(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{accessibilityRole:"alert",accessibilityLabel:v??m.drawer,style:[X,{backgroundColor:f.colors.surface,...f.shadow.modal},d,H],children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:G.content,children:_})})})]}):null});Drawer.displayName="Drawer";const resolveSize=(e,t,a)=>{if("number"==typeof e)return e;if("string"==typeof e){const r=parseFloat(e);if(Number.isNaN(r))return t?280:Math.round(.4*a.height);return r/100*(t?a.width:a.height)}return t?280:Math.round(.4*a.height)},buildStyles=e=>_reactNative.StyleSheet.create({backdrop:{..._reactNative.StyleSheet.absoluteFill},content:{flex:1}});var _default=exports.default=Drawer;