@oxyhq/bloom 0.69.1 → 0.71.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 (56) hide show
  1. package/lib/commonjs/context-menu/index.web.js +51 -3
  2. package/lib/commonjs/context-menu/index.web.js.map +1 -1
  3. package/lib/commonjs/dialog/SheetShell.js +7 -1
  4. package/lib/commonjs/dialog/SheetShell.js.map +1 -1
  5. package/lib/commonjs/menu/index.web.js +47 -10
  6. package/lib/commonjs/menu/index.web.js.map +1 -1
  7. package/lib/commonjs/overlay/dropdown-placement.js +62 -0
  8. package/lib/commonjs/overlay/dropdown-placement.js.map +1 -0
  9. package/lib/commonjs/select/index.web.js +82 -5
  10. package/lib/commonjs/select/index.web.js.map +1 -1
  11. package/lib/commonjs/zoomable-image-gallery/ZoomableImageGallery.js +32 -18
  12. package/lib/commonjs/zoomable-image-gallery/ZoomableImageGallery.js.map +1 -1
  13. package/lib/module/context-menu/index.web.js +52 -4
  14. package/lib/module/context-menu/index.web.js.map +1 -1
  15. package/lib/module/dialog/SheetShell.js +7 -1
  16. package/lib/module/dialog/SheetShell.js.map +1 -1
  17. package/lib/module/menu/index.web.js +47 -10
  18. package/lib/module/menu/index.web.js.map +1 -1
  19. package/lib/module/overlay/dropdown-placement.js +58 -0
  20. package/lib/module/overlay/dropdown-placement.js.map +1 -0
  21. package/lib/module/select/index.web.js +83 -6
  22. package/lib/module/select/index.web.js.map +1 -1
  23. package/lib/module/zoomable-image-gallery/ZoomableImageGallery.js +33 -19
  24. package/lib/module/zoomable-image-gallery/ZoomableImageGallery.js.map +1 -1
  25. package/lib/typescript/commonjs/context-menu/index.web.d.ts.map +1 -1
  26. package/lib/typescript/commonjs/dialog/SheetShell.d.ts.map +1 -1
  27. package/lib/typescript/commonjs/menu/index.web.d.ts.map +1 -1
  28. package/lib/typescript/commonjs/overlay/dropdown-placement.d.ts +55 -0
  29. package/lib/typescript/commonjs/overlay/dropdown-placement.d.ts.map +1 -0
  30. package/lib/typescript/commonjs/select/index.web.d.ts +1 -1
  31. package/lib/typescript/commonjs/select/index.web.d.ts.map +1 -1
  32. package/lib/typescript/commonjs/select/types.d.ts +6 -0
  33. package/lib/typescript/commonjs/select/types.d.ts.map +1 -1
  34. package/lib/typescript/commonjs/zoomable-image-gallery/ZoomableImageGallery.d.ts.map +1 -1
  35. package/lib/typescript/module/context-menu/index.web.d.ts.map +1 -1
  36. package/lib/typescript/module/dialog/SheetShell.d.ts.map +1 -1
  37. package/lib/typescript/module/menu/index.web.d.ts.map +1 -1
  38. package/lib/typescript/module/overlay/dropdown-placement.d.ts +55 -0
  39. package/lib/typescript/module/overlay/dropdown-placement.d.ts.map +1 -0
  40. package/lib/typescript/module/select/index.web.d.ts +1 -1
  41. package/lib/typescript/module/select/index.web.d.ts.map +1 -1
  42. package/lib/typescript/module/select/types.d.ts +6 -0
  43. package/lib/typescript/module/select/types.d.ts.map +1 -1
  44. package/lib/typescript/module/zoomable-image-gallery/ZoomableImageGallery.d.ts.map +1 -1
  45. package/package.json +1 -1
  46. package/src/__tests__/SelectItemLabel.test.tsx +46 -0
  47. package/src/__tests__/SheetShell.test.tsx +82 -0
  48. package/src/__tests__/dropdown-placement.test.ts +90 -0
  49. package/src/__tests__/optional-peer-imports.test.ts +31 -12
  50. package/src/context-menu/index.web.tsx +47 -3
  51. package/src/dialog/SheetShell.tsx +5 -0
  52. package/src/menu/index.web.tsx +45 -16
  53. package/src/overlay/dropdown-placement.ts +88 -0
  54. package/src/select/index.web.tsx +92 -5
  55. package/src/select/types.ts +6 -0
  56. package/src/zoomable-image-gallery/ZoomableImageGallery.tsx +29 -16
@@ -1,4 +1,4 @@
1
- import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
1
+ import React, { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';
2
2
  import {
3
3
  View,
4
4
  Text,
@@ -180,8 +180,6 @@ const ZoomableImageGalleryInner = React.forwardRef<ZoomableImageGalleryHandle, Z
180
180
  const originScale = useSharedValue(1);
181
181
 
182
182
  const pagerRef = useRef<ScrollView>(null);
183
- // Latch the index the pager must land on once it has mounted + laid out.
184
- const pendingIndexRef = useRef(0);
185
183
  // Mirror of `activeIndex` readable synchronously from callbacks/worklets
186
184
  // (`handleDismiss` runs via `runOnJS` and from `Pressable.onPress`, where the
187
185
  // state closure can be stale). Kept in lockstep by `setActiveIndexBoth`.
@@ -360,8 +358,8 @@ const ZoomableImageGalleryInner = React.forwardRef<ZoomableImageGalleryHandle, Z
360
358
  ]);
361
359
 
362
360
  // Reveal the swipeable pager once the open animation has settled. The index it
363
- // lands on is held in `pendingIndexRef` (set synchronously in `open`) and
364
- // applied in `onPagerLayout`.
361
+ // lands on is `activeIndexRef` (set synchronously in `open`), seated by the
362
+ // layout effect below.
365
363
  const revealPager = useCallback(() => {
366
364
  setPagerReady(true);
367
365
  }, []);
@@ -388,7 +386,6 @@ const ZoomableImageGalleryInner = React.forwardRef<ZoomableImageGalleryHandle, Z
388
386
  if (r !== undefined) initialRatios[i] = r;
389
387
  });
390
388
  setPageRatios(initialRatios);
391
- pendingIndexRef.current = safeIndex;
392
389
 
393
390
  // Resolve the opening ratio if it was not yet known, then re-fit.
394
391
  if (knownRatio === undefined) {
@@ -595,14 +592,31 @@ const ZoomableImageGalleryInner = React.forwardRef<ZoomableImageGalleryHandle, Z
595
592
  [updateIndexFromOffset]
596
593
  );
597
594
 
598
- // When the pager mounts, jump it to the open index without animation so the
599
- // swap from the open-image to the pager is seamless.
600
- const onPagerLayout = useCallback(() => {
601
- const idx = pendingIndexRef.current;
602
- if (idx > 0) {
603
- pagerRef.current?.scrollTo({ x: idx * SCREEN_WIDTH, animated: false });
604
- }
605
- }, [SCREEN_WIDTH]);
595
+ // Re-seat the pager on the CURRENT page, without animation, whenever it mounts
596
+ // or the page width changes.
597
+ //
598
+ // Rotation is the case that needs this: the pager's retained scroll offset is
599
+ // in PIXELS, so when `SCREEN_WIDTH` changes the page widths change underneath
600
+ // a stale offset and the pager lands between two pages — showing the wrong
601
+ // image while the counter and dots still point at the right one. Nothing else
602
+ // corrects it: `contentOffset` below is only an initial value, and `pageTo`
603
+ // runs only on an explicit page change. Reading the index from
604
+ // `activeIndexRef` (rather than the index the viewer was opened at) is what
605
+ // makes it land on the page the user is actually looking at.
606
+ //
607
+ // This is a layout EFFECT rather than the pager's `onLayout` on purpose. The
608
+ // pages are sized from `SCREEN_WIDTH`, so the scroll offset is only meaningful
609
+ // once React has committed a render carrying the new width. `onLayout` fires
610
+ // from a different signal (the pager's own frame) than the one that resizes
611
+ // the pages (`useWindowDimensions`), and the two are not ordered against each
612
+ // other — so an `onLayout` handler can run holding the previous `SCREEN_WIDTH`
613
+ // and re-seat the pager to the offset it already had. Keying the effect on
614
+ // `SCREEN_WIDTH` makes the two agree by construction, and running it before
615
+ // paint keeps the corrected offset from being visible as a jump.
616
+ useLayoutEffect(() => {
617
+ if (!pagerReady) return;
618
+ pagerRef.current?.scrollTo({ x: activeIndexRef.current * SCREEN_WIDTH, y: 0, animated: false });
619
+ }, [pagerReady, SCREEN_WIDTH]);
606
620
 
607
621
  // Double-tap toggles zoom: reset when already zoomed, else zoom to the tapped
608
622
  // point (biased toward it, clamped near the image center). `x`/`y` are local
@@ -834,8 +848,7 @@ const ZoomableImageGalleryInner = React.forwardRef<ZoomableImageGalleryHandle, Z
834
848
  // instead of paging away from it.
835
849
  scrollEnabled={!isZoomed}
836
850
  showsHorizontalScrollIndicator={false}
837
- contentOffset={{ x: pendingIndexRef.current * SCREEN_WIDTH, y: 0 }}
838
- onLayout={onPagerLayout}
851
+ contentOffset={{ x: activeIndexRef.current * SCREEN_WIDTH, y: 0 }}
839
852
  onMomentumScrollEnd={onPagerScroll}
840
853
  {...(Platform.OS === 'web' ? { onScroll: onPagerScroll } : {})}
841
854
  scrollEventThrottle={16}