@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.
- package/lib/commonjs/context-menu/index.web.js +51 -3
- package/lib/commonjs/context-menu/index.web.js.map +1 -1
- package/lib/commonjs/dialog/SheetShell.js +7 -1
- package/lib/commonjs/dialog/SheetShell.js.map +1 -1
- package/lib/commonjs/menu/index.web.js +47 -10
- package/lib/commonjs/menu/index.web.js.map +1 -1
- package/lib/commonjs/overlay/dropdown-placement.js +62 -0
- package/lib/commonjs/overlay/dropdown-placement.js.map +1 -0
- package/lib/commonjs/select/index.web.js +82 -5
- package/lib/commonjs/select/index.web.js.map +1 -1
- package/lib/commonjs/zoomable-image-gallery/ZoomableImageGallery.js +32 -18
- package/lib/commonjs/zoomable-image-gallery/ZoomableImageGallery.js.map +1 -1
- package/lib/module/context-menu/index.web.js +52 -4
- package/lib/module/context-menu/index.web.js.map +1 -1
- package/lib/module/dialog/SheetShell.js +7 -1
- package/lib/module/dialog/SheetShell.js.map +1 -1
- package/lib/module/menu/index.web.js +47 -10
- package/lib/module/menu/index.web.js.map +1 -1
- package/lib/module/overlay/dropdown-placement.js +58 -0
- package/lib/module/overlay/dropdown-placement.js.map +1 -0
- package/lib/module/select/index.web.js +83 -6
- package/lib/module/select/index.web.js.map +1 -1
- package/lib/module/zoomable-image-gallery/ZoomableImageGallery.js +33 -19
- package/lib/module/zoomable-image-gallery/ZoomableImageGallery.js.map +1 -1
- package/lib/typescript/commonjs/context-menu/index.web.d.ts.map +1 -1
- package/lib/typescript/commonjs/dialog/SheetShell.d.ts.map +1 -1
- package/lib/typescript/commonjs/menu/index.web.d.ts.map +1 -1
- package/lib/typescript/commonjs/overlay/dropdown-placement.d.ts +55 -0
- package/lib/typescript/commonjs/overlay/dropdown-placement.d.ts.map +1 -0
- package/lib/typescript/commonjs/select/index.web.d.ts +1 -1
- package/lib/typescript/commonjs/select/index.web.d.ts.map +1 -1
- package/lib/typescript/commonjs/select/types.d.ts +6 -0
- package/lib/typescript/commonjs/select/types.d.ts.map +1 -1
- package/lib/typescript/commonjs/zoomable-image-gallery/ZoomableImageGallery.d.ts.map +1 -1
- package/lib/typescript/module/context-menu/index.web.d.ts.map +1 -1
- package/lib/typescript/module/dialog/SheetShell.d.ts.map +1 -1
- package/lib/typescript/module/menu/index.web.d.ts.map +1 -1
- package/lib/typescript/module/overlay/dropdown-placement.d.ts +55 -0
- package/lib/typescript/module/overlay/dropdown-placement.d.ts.map +1 -0
- package/lib/typescript/module/select/index.web.d.ts +1 -1
- package/lib/typescript/module/select/index.web.d.ts.map +1 -1
- package/lib/typescript/module/select/types.d.ts +6 -0
- package/lib/typescript/module/select/types.d.ts.map +1 -1
- package/lib/typescript/module/zoomable-image-gallery/ZoomableImageGallery.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/__tests__/SelectItemLabel.test.tsx +46 -0
- package/src/__tests__/SheetShell.test.tsx +82 -0
- package/src/__tests__/dropdown-placement.test.ts +90 -0
- package/src/__tests__/optional-peer-imports.test.ts +31 -12
- package/src/context-menu/index.web.tsx +47 -3
- package/src/dialog/SheetShell.tsx +5 -0
- package/src/menu/index.web.tsx +45 -16
- package/src/overlay/dropdown-placement.ts +88 -0
- package/src/select/index.web.tsx +92 -5
- package/src/select/types.ts +6 -0
- 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
|
|
364
|
-
//
|
|
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
|
-
//
|
|
599
|
-
//
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
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:
|
|
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}
|