@oxyhq/bloom 0.33.0 → 0.34.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 (41) hide show
  1. package/lib/commonjs/command/Command.js +49 -2
  2. package/lib/commonjs/command/Command.js.map +1 -1
  3. package/lib/commonjs/zoomable-image-gallery/ZoomableImageGallery.js +375 -20
  4. package/lib/commonjs/zoomable-image-gallery/ZoomableImageGallery.js.map +1 -1
  5. package/lib/commonjs/zoomable-image-gallery/constants.js +16 -1
  6. package/lib/commonjs/zoomable-image-gallery/constants.js.map +1 -1
  7. package/lib/commonjs/zoomable-image-gallery/index.js +15 -0
  8. package/lib/commonjs/zoomable-image-gallery/index.js.map +1 -1
  9. package/lib/module/command/Command.js +50 -3
  10. package/lib/module/command/Command.js.map +1 -1
  11. package/lib/module/zoomable-image-gallery/ZoomableImageGallery.js +368 -13
  12. package/lib/module/zoomable-image-gallery/ZoomableImageGallery.js.map +1 -1
  13. package/lib/module/zoomable-image-gallery/constants.js +15 -0
  14. package/lib/module/zoomable-image-gallery/constants.js.map +1 -1
  15. package/lib/module/zoomable-image-gallery/index.js +1 -0
  16. package/lib/module/zoomable-image-gallery/index.js.map +1 -1
  17. package/lib/typescript/commonjs/command/Command.d.ts +14 -0
  18. package/lib/typescript/commonjs/command/Command.d.ts.map +1 -1
  19. package/lib/typescript/commonjs/zoomable-image-gallery/ZoomableImageGallery.d.ts.map +1 -1
  20. package/lib/typescript/commonjs/zoomable-image-gallery/constants.d.ts +14 -0
  21. package/lib/typescript/commonjs/zoomable-image-gallery/constants.d.ts.map +1 -1
  22. package/lib/typescript/commonjs/zoomable-image-gallery/index.d.ts +1 -0
  23. package/lib/typescript/commonjs/zoomable-image-gallery/index.d.ts.map +1 -1
  24. package/lib/typescript/commonjs/zoomable-image-gallery/types.d.ts +6 -0
  25. package/lib/typescript/commonjs/zoomable-image-gallery/types.d.ts.map +1 -1
  26. package/lib/typescript/module/command/Command.d.ts +14 -0
  27. package/lib/typescript/module/command/Command.d.ts.map +1 -1
  28. package/lib/typescript/module/zoomable-image-gallery/ZoomableImageGallery.d.ts.map +1 -1
  29. package/lib/typescript/module/zoomable-image-gallery/constants.d.ts +14 -0
  30. package/lib/typescript/module/zoomable-image-gallery/constants.d.ts.map +1 -1
  31. package/lib/typescript/module/zoomable-image-gallery/index.d.ts +1 -0
  32. package/lib/typescript/module/zoomable-image-gallery/index.d.ts.map +1 -1
  33. package/lib/typescript/module/zoomable-image-gallery/types.d.ts +6 -0
  34. package/lib/typescript/module/zoomable-image-gallery/types.d.ts.map +1 -1
  35. package/package.json +1 -1
  36. package/src/__tests__/Command.test.tsx +122 -1
  37. package/src/command/Command.tsx +50 -3
  38. package/src/zoomable-image-gallery/ZoomableImageGallery.tsx +420 -19
  39. package/src/zoomable-image-gallery/constants.ts +15 -0
  40. package/src/zoomable-image-gallery/index.ts +1 -0
  41. package/src/zoomable-image-gallery/types.ts +6 -0
@@ -35,4 +35,19 @@ export const SNAP_BACK_SPRING = {
35
35
 
36
36
  /** Default corner radius for the zoomed images — Bloom's `radius-12` token. */
37
37
  export const DEFAULT_CORNER_RADIUS = RADIUS['radius-12'];
38
+
39
+ /** Minimum pinch-zoom scale of the active image (its un-zoomed size). */
40
+ export const MIN_ZOOM_SCALE = 1;
41
+ /** Maximum pinch-zoom scale of the active image. */
42
+ export const MAX_ZOOM_SCALE = 3;
43
+ /** Below this final pinch scale, the zoom snaps back to 1 (treated as un-zoomed). */
44
+ export const ZOOM_SNAP_THRESHOLD = 1.1;
45
+ /** Scale a double-tap zooms the active image to when it is currently un-zoomed. */
46
+ export const DOUBLE_TAP_ZOOM_SCALE = 2;
47
+ /** Fraction of finger travel applied while panning a zoomed image. */
48
+ export const ZOOM_PAN_DAMPING = 0.8;
49
+ /** Base clamp (px, multiplied by the current zoom) bounding a zoomed image's pan. */
50
+ export const ZOOM_PAN_MAX_BASE = 100;
51
+ /** Edge length (px) of each tile in the `thumbnails` indicator variant. */
52
+ export const THUMBNAIL_STRIP_TILE_SIZE = 52;
38
53
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["RADIUS","FIT_FRACTION","MAX_DRAG_FRACTION","SCALE_DRAG_FRACTION","MIN_DRAG_SCALE","DISMISS_FRACTION","AXIS_DECISION_OFFSET","OPEN_DURATION_WEB","CLOSE_DURATION_WEB","OPACITY_DURATION","OPEN_SPRING","damping","stiffness","mass","CLOSE_SPRING","SNAP_BACK_SPRING","DEFAULT_CORNER_RADIUS"],"sourceRoot":"../../../src","sources":["zoomable-image-gallery/constants.ts"],"mappings":";;AAAA,SAASA,MAAM,QAAQ,2BAAkB;;AAEzC;AACA,OAAO,MAAMC,YAAY,GAAG,GAAG;AAC/B;AACA,OAAO,MAAMC,iBAAiB,GAAG,GAAG;AACpC;AACA,OAAO,MAAMC,mBAAmB,GAAG,GAAG;AACtC;AACA,OAAO,MAAMC,cAAc,GAAG,GAAG;AACjC;AACA,OAAO,MAAMC,gBAAgB,GAAG,IAAI;AACpC;AACA,OAAO,MAAMC,oBAAoB,GAAG,EAAE;AAEtC,OAAO,MAAMC,iBAAiB,GAAG,GAAG;AACpC,OAAO,MAAMC,kBAAkB,GAAG,GAAG;AACrC,OAAO,MAAMC,gBAAgB,GAAG,GAAG;AAEnC,OAAO,MAAMC,WAAW,GAAG;EAAEC,OAAO,EAAE,EAAE;EAAEC,SAAS,EAAE,GAAG;EAAEC,IAAI,EAAE;AAAI,CAAU;AAC9E,OAAO,MAAMC,YAAY,GAAG;EAAEH,OAAO,EAAE,EAAE;EAAEC,SAAS,EAAE,GAAG;EAAEC,IAAI,EAAE;AAAK,CAAU;AAChF,OAAO,MAAME,gBAAgB,GAAG;EAAEJ,OAAO,EAAE,EAAE;EAAEC,SAAS,EAAE,GAAG;EAAEC,IAAI,EAAE;AAAI,CAAU;;AAEnF;AACA,OAAO,MAAMG,qBAAqB,GAAGhB,MAAM,CAAC,WAAW,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["RADIUS","FIT_FRACTION","MAX_DRAG_FRACTION","SCALE_DRAG_FRACTION","MIN_DRAG_SCALE","DISMISS_FRACTION","AXIS_DECISION_OFFSET","OPEN_DURATION_WEB","CLOSE_DURATION_WEB","OPACITY_DURATION","OPEN_SPRING","damping","stiffness","mass","CLOSE_SPRING","SNAP_BACK_SPRING","DEFAULT_CORNER_RADIUS","MIN_ZOOM_SCALE","MAX_ZOOM_SCALE","ZOOM_SNAP_THRESHOLD","DOUBLE_TAP_ZOOM_SCALE","ZOOM_PAN_DAMPING","ZOOM_PAN_MAX_BASE","THUMBNAIL_STRIP_TILE_SIZE"],"sourceRoot":"../../../src","sources":["zoomable-image-gallery/constants.ts"],"mappings":";;AAAA,SAASA,MAAM,QAAQ,2BAAkB;;AAEzC;AACA,OAAO,MAAMC,YAAY,GAAG,GAAG;AAC/B;AACA,OAAO,MAAMC,iBAAiB,GAAG,GAAG;AACpC;AACA,OAAO,MAAMC,mBAAmB,GAAG,GAAG;AACtC;AACA,OAAO,MAAMC,cAAc,GAAG,GAAG;AACjC;AACA,OAAO,MAAMC,gBAAgB,GAAG,IAAI;AACpC;AACA,OAAO,MAAMC,oBAAoB,GAAG,EAAE;AAEtC,OAAO,MAAMC,iBAAiB,GAAG,GAAG;AACpC,OAAO,MAAMC,kBAAkB,GAAG,GAAG;AACrC,OAAO,MAAMC,gBAAgB,GAAG,GAAG;AAEnC,OAAO,MAAMC,WAAW,GAAG;EAAEC,OAAO,EAAE,EAAE;EAAEC,SAAS,EAAE,GAAG;EAAEC,IAAI,EAAE;AAAI,CAAU;AAC9E,OAAO,MAAMC,YAAY,GAAG;EAAEH,OAAO,EAAE,EAAE;EAAEC,SAAS,EAAE,GAAG;EAAEC,IAAI,EAAE;AAAK,CAAU;AAChF,OAAO,MAAME,gBAAgB,GAAG;EAAEJ,OAAO,EAAE,EAAE;EAAEC,SAAS,EAAE,GAAG;EAAEC,IAAI,EAAE;AAAI,CAAU;;AAEnF;AACA,OAAO,MAAMG,qBAAqB,GAAGhB,MAAM,CAAC,WAAW,CAAC;;AAExD;AACA,OAAO,MAAMiB,cAAc,GAAG,CAAC;AAC/B;AACA,OAAO,MAAMC,cAAc,GAAG,CAAC;AAC/B;AACA,OAAO,MAAMC,mBAAmB,GAAG,GAAG;AACtC;AACA,OAAO,MAAMC,qBAAqB,GAAG,CAAC;AACtC;AACA,OAAO,MAAMC,gBAAgB,GAAG,GAAG;AACnC;AACA,OAAO,MAAMC,iBAAiB,GAAG,GAAG;AACpC;AACA,OAAO,MAAMC,yBAAyB,GAAG,EAAE","ignoreList":[]}
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
2
 
3
3
  export { ZoomableImageGallery, ZoomableImageGallery as default } from "./ZoomableImageGallery.js";
4
+ export * from "./constants.js";
4
5
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["ZoomableImageGallery","default"],"sourceRoot":"../../../src","sources":["zoomable-image-gallery/index.ts"],"mappings":";;AAAA,SAASA,oBAAoB,EAAEA,oBAAoB,IAAIC,OAAO,QAAQ,2BAAwB","ignoreList":[]}
1
+ {"version":3,"names":["ZoomableImageGallery","default"],"sourceRoot":"../../../src","sources":["zoomable-image-gallery/index.ts"],"mappings":";;AAAA,SAASA,oBAAoB,EAAEA,oBAAoB,IAAIC,OAAO,QAAQ,2BAAwB;AAQ9F,cAAc,gBAAa","ignoreList":[]}
@@ -12,6 +12,20 @@ type DialogComponent = React.ComponentType<DialogProps>;
12
12
  * `SearchInput`, an `Item` results list and `Kbd` shortcut hints. Items group
13
13
  * by their `group` field (ungrouped first). On web the list is
14
14
  * keyboard-navigable (Up/Down/Enter); on native, tap to select.
15
+ *
16
+ * Control mode — IMPERATIVE, not controlled. `Command` keeps its public
17
+ * *controlled* API (`visible` boolean + `onClose`) but internally bridges it
18
+ * onto the Dialog's imperative `useDialogControl()` handle, exactly like
19
+ * `AlertDialog`. This makes `Command` the LAST controlled-`open` `Dialog`
20
+ * consumer to move onto the imperative path every other surface uses
21
+ * (`alert()`, `confirm()`, native `Menu`/`Select`/`ContextMenu`, Mention's
22
+ * dialogs), so there is one code path across the ecosystem. It also guarantees
23
+ * the palette's exit animation on the dismiss path even for a consumer that
24
+ * unmounts the palette in response to `onClose` (`{open && <Command …/>}`): the
25
+ * imperative `close()` runs the exit animation FIRST and fires `onClose` only
26
+ * once it settles, whereas the controlled `open` path fires `onClose`
27
+ * synchronously — which, for an unmount-on-close consumer, would tear the
28
+ * surface down before it could animate out.
15
29
  */
16
30
  export declare function createCommand(Dialog: DialogComponent): {
17
31
  ({ visible, onClose, items, placeholder, emptyText, query: queryProp, onQueryChange, filter, maxListHeight, style, testID, }: CommandProps): import("react/jsx-runtime").JSX.Element;
@@ -1 +1 @@
1
- {"version":3,"file":"Command.d.ts","sourceRoot":"","sources":["../../../../src/command/Command.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAiD,MAAM,OAAO,CAAC;AAgBtE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,KAAK,EAAe,YAAY,EAAE,MAAM,SAAS,CAAC;AAEzD,KAAK,eAAe,GAAG,KAAK,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC;AAqBxD;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,eAAe;kIAahD,YAAY;;EA2LhB;AAED,MAAM,MAAM,WAAW,GAAG,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC"}
1
+ {"version":3,"file":"Command.d.ts","sourceRoot":"","sources":["../../../../src/command/Command.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4D,MAAM,OAAO,CAAC;AAgBjF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAE7C,OAAO,KAAK,EAAe,YAAY,EAAE,MAAM,SAAS,CAAC;AAEzD,KAAK,eAAe,GAAG,KAAK,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC;AAqBxD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,eAAe;kIAahD,YAAY;;EA2NhB;AAED,MAAM,MAAM,WAAW,GAAG,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"ZoomableImageGallery.d.ts","sourceRoot":"","sources":["../../../../src/zoomable-image-gallery/ZoomableImageGallery.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAiD,MAAM,OAAO,CAAC;AAmDtE,OAAO,KAAK,EAGV,0BAA0B,EAC1B,yBAAyB,EAC1B,MAAM,SAAS,CAAC;AAwhBjB,eAAO,MAAM,oBAAoB,8GAA4B,CAAC;AAsG9D,eAAe,oBAAoB,CAAC"}
1
+ {"version":3,"file":"ZoomableImageGallery.d.ts","sourceRoot":"","sources":["../../../../src/zoomable-image-gallery/ZoomableImageGallery.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4D,MAAM,OAAO,CAAC;AAiEjF,OAAO,KAAK,EAGV,0BAA0B,EAC1B,yBAAyB,EAC1B,MAAM,SAAS,CAAC;AAy1BjB,eAAO,MAAM,oBAAoB,8GAA4B,CAAC;AAwK9D,eAAe,oBAAoB,CAAC"}
@@ -30,4 +30,18 @@ export declare const SNAP_BACK_SPRING: {
30
30
  };
31
31
  /** Default corner radius for the zoomed images — Bloom's `radius-12` token. */
32
32
  export declare const DEFAULT_CORNER_RADIUS: 12;
33
+ /** Minimum pinch-zoom scale of the active image (its un-zoomed size). */
34
+ export declare const MIN_ZOOM_SCALE = 1;
35
+ /** Maximum pinch-zoom scale of the active image. */
36
+ export declare const MAX_ZOOM_SCALE = 3;
37
+ /** Below this final pinch scale, the zoom snaps back to 1 (treated as un-zoomed). */
38
+ export declare const ZOOM_SNAP_THRESHOLD = 1.1;
39
+ /** Scale a double-tap zooms the active image to when it is currently un-zoomed. */
40
+ export declare const DOUBLE_TAP_ZOOM_SCALE = 2;
41
+ /** Fraction of finger travel applied while panning a zoomed image. */
42
+ export declare const ZOOM_PAN_DAMPING = 0.8;
43
+ /** Base clamp (px, multiplied by the current zoom) bounding a zoomed image's pan. */
44
+ export declare const ZOOM_PAN_MAX_BASE = 100;
45
+ /** Edge length (px) of each tile in the `thumbnails` indicator variant. */
46
+ export declare const THUMBNAIL_STRIP_TILE_SIZE = 52;
33
47
  //# sourceMappingURL=constants.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../src/zoomable-image-gallery/constants.ts"],"names":[],"mappings":"AAEA,0EAA0E;AAC1E,eAAO,MAAM,YAAY,MAAM,CAAC;AAChC,oFAAoF;AACpF,eAAO,MAAM,iBAAiB,MAAM,CAAC;AACrC,kFAAkF;AAClF,eAAO,MAAM,mBAAmB,MAAM,CAAC;AACvC,uDAAuD;AACvD,eAAO,MAAM,cAAc,MAAM,CAAC;AAClC,kFAAkF;AAClF,eAAO,MAAM,gBAAgB,OAAO,CAAC;AACrC,0FAA0F;AAC1F,eAAO,MAAM,oBAAoB,KAAK,CAAC;AAEvC,eAAO,MAAM,iBAAiB,MAAM,CAAC;AACrC,eAAO,MAAM,kBAAkB,MAAM,CAAC;AACtC,eAAO,MAAM,gBAAgB,MAAM,CAAC;AAEpC,eAAO,MAAM,WAAW;;;;CAAsD,CAAC;AAC/E,eAAO,MAAM,YAAY;;;;CAAuD,CAAC;AACjF,eAAO,MAAM,gBAAgB;;;;CAAsD,CAAC;AAEpF,+EAA+E;AAC/E,eAAO,MAAM,qBAAqB,IAAsB,CAAC"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../src/zoomable-image-gallery/constants.ts"],"names":[],"mappings":"AAEA,0EAA0E;AAC1E,eAAO,MAAM,YAAY,MAAM,CAAC;AAChC,oFAAoF;AACpF,eAAO,MAAM,iBAAiB,MAAM,CAAC;AACrC,kFAAkF;AAClF,eAAO,MAAM,mBAAmB,MAAM,CAAC;AACvC,uDAAuD;AACvD,eAAO,MAAM,cAAc,MAAM,CAAC;AAClC,kFAAkF;AAClF,eAAO,MAAM,gBAAgB,OAAO,CAAC;AACrC,0FAA0F;AAC1F,eAAO,MAAM,oBAAoB,KAAK,CAAC;AAEvC,eAAO,MAAM,iBAAiB,MAAM,CAAC;AACrC,eAAO,MAAM,kBAAkB,MAAM,CAAC;AACtC,eAAO,MAAM,gBAAgB,MAAM,CAAC;AAEpC,eAAO,MAAM,WAAW;;;;CAAsD,CAAC;AAC/E,eAAO,MAAM,YAAY;;;;CAAuD,CAAC;AACjF,eAAO,MAAM,gBAAgB;;;;CAAsD,CAAC;AAEpF,+EAA+E;AAC/E,eAAO,MAAM,qBAAqB,IAAsB,CAAC;AAEzD,yEAAyE;AACzE,eAAO,MAAM,cAAc,IAAI,CAAC;AAChC,oDAAoD;AACpD,eAAO,MAAM,cAAc,IAAI,CAAC;AAChC,qFAAqF;AACrF,eAAO,MAAM,mBAAmB,MAAM,CAAC;AACvC,mFAAmF;AACnF,eAAO,MAAM,qBAAqB,IAAI,CAAC;AACvC,sEAAsE;AACtE,eAAO,MAAM,gBAAgB,MAAM,CAAC;AACpC,qFAAqF;AACrF,eAAO,MAAM,iBAAiB,MAAM,CAAC;AACrC,2EAA2E;AAC3E,eAAO,MAAM,yBAAyB,KAAK,CAAC"}
@@ -1,3 +1,4 @@
1
1
  export { ZoomableImageGallery, ZoomableImageGallery as default } from './ZoomableImageGallery';
2
2
  export type { ZoomableImageGalleryHandle, ZoomableImageGalleryProps, GalleryImage, MeasureThumb, MeasuredRect, } from './types';
3
+ export * from './constants';
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/zoomable-image-gallery/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,IAAI,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAC/F,YAAY,EACV,0BAA0B,EAC1B,yBAAyB,EACzB,YAAY,EACZ,YAAY,EACZ,YAAY,GACb,MAAM,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/zoomable-image-gallery/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,IAAI,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAC/F,YAAY,EACV,0BAA0B,EAC1B,yBAAyB,EACzB,YAAY,EACZ,YAAY,EACZ,YAAY,GACb,MAAM,SAAS,CAAC;AACjB,cAAc,aAAa,CAAC"}
@@ -42,5 +42,11 @@ export interface ZoomableImageGalleryProps {
42
42
  measureThumb?: MeasureThumb;
43
43
  /** Corner radius applied to the zoomed images. Defaults to `DEFAULT_CORNER_RADIUS`. */
44
44
  cornerRadius?: number;
45
+ /**
46
+ * Bottom page indicator for multi-image galleries. `'dots'` (default) renders the
47
+ * compact dot row; `'thumbnails'` renders a horizontal strip of tappable image
48
+ * tiles. The counter pill shows in both. Ignored for single-image galleries.
49
+ */
50
+ indicatorVariant?: 'dots' | 'thumbnails';
45
51
  }
46
52
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/zoomable-image-gallery/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,YAAY;IAC3B,sEAAsE;IACtE,GAAG,EAAE,MAAM,CAAC;IACZ;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;GAMG;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CAAC;AAE3E,MAAM,WAAW,0BAA0B;IACzC;;;OAGG;IACH,IAAI,EAAE,CAAC,MAAM,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,YAAY,KAAK,IAAI,CAAC;CAC5E;AAED,MAAM,WAAW,yBAAyB;IACxC,+EAA+E;IAC/E,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,uFAAuF;IACvF,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/zoomable-image-gallery/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,YAAY;IAC3B,sEAAsE;IACtE,GAAG,EAAE,MAAM,CAAC;IACZ;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;GAMG;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CAAC;AAE3E,MAAM,WAAW,0BAA0B;IACzC;;;OAGG;IACH,IAAI,EAAE,CAAC,MAAM,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,YAAY,KAAK,IAAI,CAAC;CAC5E;AAED,MAAM,WAAW,yBAAyB;IACxC,+EAA+E;IAC/E,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,uFAAuF;IACvF,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,MAAM,GAAG,YAAY,CAAC;CAC1C"}
@@ -12,6 +12,20 @@ type DialogComponent = React.ComponentType<DialogProps>;
12
12
  * `SearchInput`, an `Item` results list and `Kbd` shortcut hints. Items group
13
13
  * by their `group` field (ungrouped first). On web the list is
14
14
  * keyboard-navigable (Up/Down/Enter); on native, tap to select.
15
+ *
16
+ * Control mode — IMPERATIVE, not controlled. `Command` keeps its public
17
+ * *controlled* API (`visible` boolean + `onClose`) but internally bridges it
18
+ * onto the Dialog's imperative `useDialogControl()` handle, exactly like
19
+ * `AlertDialog`. This makes `Command` the LAST controlled-`open` `Dialog`
20
+ * consumer to move onto the imperative path every other surface uses
21
+ * (`alert()`, `confirm()`, native `Menu`/`Select`/`ContextMenu`, Mention's
22
+ * dialogs), so there is one code path across the ecosystem. It also guarantees
23
+ * the palette's exit animation on the dismiss path even for a consumer that
24
+ * unmounts the palette in response to `onClose` (`{open && <Command …/>}`): the
25
+ * imperative `close()` runs the exit animation FIRST and fires `onClose` only
26
+ * once it settles, whereas the controlled `open` path fires `onClose`
27
+ * synchronously — which, for an unmount-on-close consumer, would tear the
28
+ * surface down before it could animate out.
15
29
  */
16
30
  export declare function createCommand(Dialog: DialogComponent): {
17
31
  ({ visible, onClose, items, placeholder, emptyText, query: queryProp, onQueryChange, filter, maxListHeight, style, testID, }: CommandProps): import("react/jsx-runtime").JSX.Element;
@@ -1 +1 @@
1
- {"version":3,"file":"Command.d.ts","sourceRoot":"","sources":["../../../../src/command/Command.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAiD,MAAM,OAAO,CAAC;AAgBtE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,KAAK,EAAe,YAAY,EAAE,MAAM,SAAS,CAAC;AAEzD,KAAK,eAAe,GAAG,KAAK,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC;AAqBxD;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,eAAe;kIAahD,YAAY;;EA2LhB;AAED,MAAM,MAAM,WAAW,GAAG,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC"}
1
+ {"version":3,"file":"Command.d.ts","sourceRoot":"","sources":["../../../../src/command/Command.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4D,MAAM,OAAO,CAAC;AAgBjF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAE7C,OAAO,KAAK,EAAe,YAAY,EAAE,MAAM,SAAS,CAAC;AAEzD,KAAK,eAAe,GAAG,KAAK,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC;AAqBxD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,eAAe;kIAahD,YAAY;;EA2NhB;AAED,MAAM,MAAM,WAAW,GAAG,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"ZoomableImageGallery.d.ts","sourceRoot":"","sources":["../../../../src/zoomable-image-gallery/ZoomableImageGallery.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAiD,MAAM,OAAO,CAAC;AAmDtE,OAAO,KAAK,EAGV,0BAA0B,EAC1B,yBAAyB,EAC1B,MAAM,SAAS,CAAC;AAwhBjB,eAAO,MAAM,oBAAoB,8GAA4B,CAAC;AAsG9D,eAAe,oBAAoB,CAAC"}
1
+ {"version":3,"file":"ZoomableImageGallery.d.ts","sourceRoot":"","sources":["../../../../src/zoomable-image-gallery/ZoomableImageGallery.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4D,MAAM,OAAO,CAAC;AAiEjF,OAAO,KAAK,EAGV,0BAA0B,EAC1B,yBAAyB,EAC1B,MAAM,SAAS,CAAC;AAy1BjB,eAAO,MAAM,oBAAoB,8GAA4B,CAAC;AAwK9D,eAAe,oBAAoB,CAAC"}
@@ -30,4 +30,18 @@ export declare const SNAP_BACK_SPRING: {
30
30
  };
31
31
  /** Default corner radius for the zoomed images — Bloom's `radius-12` token. */
32
32
  export declare const DEFAULT_CORNER_RADIUS: 12;
33
+ /** Minimum pinch-zoom scale of the active image (its un-zoomed size). */
34
+ export declare const MIN_ZOOM_SCALE = 1;
35
+ /** Maximum pinch-zoom scale of the active image. */
36
+ export declare const MAX_ZOOM_SCALE = 3;
37
+ /** Below this final pinch scale, the zoom snaps back to 1 (treated as un-zoomed). */
38
+ export declare const ZOOM_SNAP_THRESHOLD = 1.1;
39
+ /** Scale a double-tap zooms the active image to when it is currently un-zoomed. */
40
+ export declare const DOUBLE_TAP_ZOOM_SCALE = 2;
41
+ /** Fraction of finger travel applied while panning a zoomed image. */
42
+ export declare const ZOOM_PAN_DAMPING = 0.8;
43
+ /** Base clamp (px, multiplied by the current zoom) bounding a zoomed image's pan. */
44
+ export declare const ZOOM_PAN_MAX_BASE = 100;
45
+ /** Edge length (px) of each tile in the `thumbnails` indicator variant. */
46
+ export declare const THUMBNAIL_STRIP_TILE_SIZE = 52;
33
47
  //# sourceMappingURL=constants.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../src/zoomable-image-gallery/constants.ts"],"names":[],"mappings":"AAEA,0EAA0E;AAC1E,eAAO,MAAM,YAAY,MAAM,CAAC;AAChC,oFAAoF;AACpF,eAAO,MAAM,iBAAiB,MAAM,CAAC;AACrC,kFAAkF;AAClF,eAAO,MAAM,mBAAmB,MAAM,CAAC;AACvC,uDAAuD;AACvD,eAAO,MAAM,cAAc,MAAM,CAAC;AAClC,kFAAkF;AAClF,eAAO,MAAM,gBAAgB,OAAO,CAAC;AACrC,0FAA0F;AAC1F,eAAO,MAAM,oBAAoB,KAAK,CAAC;AAEvC,eAAO,MAAM,iBAAiB,MAAM,CAAC;AACrC,eAAO,MAAM,kBAAkB,MAAM,CAAC;AACtC,eAAO,MAAM,gBAAgB,MAAM,CAAC;AAEpC,eAAO,MAAM,WAAW;;;;CAAsD,CAAC;AAC/E,eAAO,MAAM,YAAY;;;;CAAuD,CAAC;AACjF,eAAO,MAAM,gBAAgB;;;;CAAsD,CAAC;AAEpF,+EAA+E;AAC/E,eAAO,MAAM,qBAAqB,IAAsB,CAAC"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../src/zoomable-image-gallery/constants.ts"],"names":[],"mappings":"AAEA,0EAA0E;AAC1E,eAAO,MAAM,YAAY,MAAM,CAAC;AAChC,oFAAoF;AACpF,eAAO,MAAM,iBAAiB,MAAM,CAAC;AACrC,kFAAkF;AAClF,eAAO,MAAM,mBAAmB,MAAM,CAAC;AACvC,uDAAuD;AACvD,eAAO,MAAM,cAAc,MAAM,CAAC;AAClC,kFAAkF;AAClF,eAAO,MAAM,gBAAgB,OAAO,CAAC;AACrC,0FAA0F;AAC1F,eAAO,MAAM,oBAAoB,KAAK,CAAC;AAEvC,eAAO,MAAM,iBAAiB,MAAM,CAAC;AACrC,eAAO,MAAM,kBAAkB,MAAM,CAAC;AACtC,eAAO,MAAM,gBAAgB,MAAM,CAAC;AAEpC,eAAO,MAAM,WAAW;;;;CAAsD,CAAC;AAC/E,eAAO,MAAM,YAAY;;;;CAAuD,CAAC;AACjF,eAAO,MAAM,gBAAgB;;;;CAAsD,CAAC;AAEpF,+EAA+E;AAC/E,eAAO,MAAM,qBAAqB,IAAsB,CAAC;AAEzD,yEAAyE;AACzE,eAAO,MAAM,cAAc,IAAI,CAAC;AAChC,oDAAoD;AACpD,eAAO,MAAM,cAAc,IAAI,CAAC;AAChC,qFAAqF;AACrF,eAAO,MAAM,mBAAmB,MAAM,CAAC;AACvC,mFAAmF;AACnF,eAAO,MAAM,qBAAqB,IAAI,CAAC;AACvC,sEAAsE;AACtE,eAAO,MAAM,gBAAgB,MAAM,CAAC;AACpC,qFAAqF;AACrF,eAAO,MAAM,iBAAiB,MAAM,CAAC;AACrC,2EAA2E;AAC3E,eAAO,MAAM,yBAAyB,KAAK,CAAC"}
@@ -1,3 +1,4 @@
1
1
  export { ZoomableImageGallery, ZoomableImageGallery as default } from './ZoomableImageGallery';
2
2
  export type { ZoomableImageGalleryHandle, ZoomableImageGalleryProps, GalleryImage, MeasureThumb, MeasuredRect, } from './types';
3
+ export * from './constants';
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/zoomable-image-gallery/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,IAAI,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAC/F,YAAY,EACV,0BAA0B,EAC1B,yBAAyB,EACzB,YAAY,EACZ,YAAY,EACZ,YAAY,GACb,MAAM,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/zoomable-image-gallery/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,IAAI,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAC/F,YAAY,EACV,0BAA0B,EAC1B,yBAAyB,EACzB,YAAY,EACZ,YAAY,EACZ,YAAY,GACb,MAAM,SAAS,CAAC;AACjB,cAAc,aAAa,CAAC"}
@@ -42,5 +42,11 @@ export interface ZoomableImageGalleryProps {
42
42
  measureThumb?: MeasureThumb;
43
43
  /** Corner radius applied to the zoomed images. Defaults to `DEFAULT_CORNER_RADIUS`. */
44
44
  cornerRadius?: number;
45
+ /**
46
+ * Bottom page indicator for multi-image galleries. `'dots'` (default) renders the
47
+ * compact dot row; `'thumbnails'` renders a horizontal strip of tappable image
48
+ * tiles. The counter pill shows in both. Ignored for single-image galleries.
49
+ */
50
+ indicatorVariant?: 'dots' | 'thumbnails';
45
51
  }
46
52
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/zoomable-image-gallery/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,YAAY;IAC3B,sEAAsE;IACtE,GAAG,EAAE,MAAM,CAAC;IACZ;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;GAMG;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CAAC;AAE3E,MAAM,WAAW,0BAA0B;IACzC;;;OAGG;IACH,IAAI,EAAE,CAAC,MAAM,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,YAAY,KAAK,IAAI,CAAC;CAC5E;AAED,MAAM,WAAW,yBAAyB;IACxC,+EAA+E;IAC/E,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,uFAAuF;IACvF,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/zoomable-image-gallery/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,YAAY;IAC3B,sEAAsE;IACtE,GAAG,EAAE,MAAM,CAAC;IACZ;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;GAMG;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CAAC;AAE3E,MAAM,WAAW,0BAA0B;IACzC;;;OAGG;IACH,IAAI,EAAE,CAAC,MAAM,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,YAAY,KAAK,IAAI,CAAC;CAC5E;AAED,MAAM,WAAW,yBAAyB;IACxC,+EAA+E;IAC/E,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,uFAAuF;IACvF,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,MAAM,GAAG,YAAY,CAAC;CAC1C"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oxyhq/bloom",
3
- "version": "0.33.0",
3
+ "version": "0.34.0",
4
4
  "description": "Bloom UI — Oxy ecosystem component library for React Native + Expo + Web",
5
5
  "main": "lib/commonjs/index.js",
6
6
  "module": "lib/module/index.js",
@@ -1,8 +1,10 @@
1
- import React from 'react';
1
+ import React, { useImperativeHandle } from 'react';
2
2
  import { act, fireEvent, render } from '@testing-library/react-native';
3
3
 
4
4
  import { Command } from '../command';
5
+ import { createCommand } from '../command/Command';
5
6
  import type { CommandItem } from '../command';
7
+ import type { DialogProps } from '../dialog';
6
8
  import { BloomThemeProvider } from '../theme/BloomThemeProvider';
7
9
 
8
10
  function renderWithTheme(ui: React.ReactElement) {
@@ -104,4 +106,123 @@ describe('Command (built on Dialog)', () => {
104
106
  expect(onSelect).toHaveBeenCalledTimes(1);
105
107
  expect(onClose).toHaveBeenCalledTimes(1);
106
108
  });
109
+
110
+ // The migration off the controlled `open` prop onto the imperative `control`
111
+ // handle (making `Command` the last controlled-mode `Dialog` consumer to move
112
+ // over). These pin the fix at the prop boundary between `Command` and the
113
+ // underlying `Dialog`, using a prop-capturing mock `Dialog` so the assertions
114
+ // are deterministic and platform-agnostic — mirroring `AlertDialog`'s round.
115
+ describe('control-mode bridge', () => {
116
+ function captureDialogProps() {
117
+ const captured: { props?: DialogProps } = {};
118
+ const MockDialog = (props: DialogProps) => {
119
+ captured.props = props;
120
+ return null;
121
+ };
122
+ return { captured, MockDialog };
123
+ }
124
+
125
+ it('drives the underlying Dialog imperatively (control), never the controlled `open` prop', () => {
126
+ const { captured, MockDialog } = captureDialogProps();
127
+ const TestCommand = createCommand(MockDialog);
128
+ renderWithTheme(
129
+ <TestCommand visible onClose={() => {}} items={makeItems(() => {})} />,
130
+ );
131
+ // The whole point of the migration: `Command` must take the Dialog's
132
+ // imperative/uncontrolled branch (the one that plays the exit animation on
133
+ // dismiss), so an imperative `control` handle is passed and the controlled
134
+ // `open` boolean — which fires `onClose` synchronously — is never set.
135
+ expect(captured.props?.control).toBeDefined();
136
+ expect(captured.props?.open).toBeUndefined();
137
+ });
138
+
139
+ // A mock Dialog that registers the real imperative contract on `control.ref`
140
+ // (so `Command`'s `control.open()` / `control.close()` proxy through it) and
141
+ // fires `onClose` when imperatively closed — modelling the real Dialog,
142
+ // which invokes `onClose` only AFTER its exit animation settles.
143
+ function ImperativeMockDialog(props: DialogProps) {
144
+ const onCloseRef = React.useRef(props.onClose);
145
+ onCloseRef.current = props.onClose;
146
+ useImperativeHandle(
147
+ props.control?.ref,
148
+ () => ({
149
+ open: () => {},
150
+ // The real Dialog fires `onClose` post-exit-animation.
151
+ close: () => onCloseRef.current?.(),
152
+ }),
153
+ [],
154
+ );
155
+ return null;
156
+ }
157
+
158
+ it('opens the Dialog imperatively on mount when visible, and closes it when visible flips false', () => {
159
+ const spies = { open: jest.fn(), close: jest.fn() };
160
+ const MockDialog = (props: DialogProps) => {
161
+ useImperativeHandle(props.control?.ref, () => spies, []);
162
+ return null;
163
+ };
164
+ const TestCommand = createCommand(MockDialog);
165
+ const { rerender } = renderWithTheme(
166
+ <TestCommand visible onClose={() => {}} items={makeItems(() => {})} />,
167
+ );
168
+ expect(spies.open).toHaveBeenCalledTimes(1);
169
+ expect(spies.close).not.toHaveBeenCalled();
170
+
171
+ act(() => {
172
+ rerender(
173
+ <BloomThemeProvider mode="light" colorPreset="teal">
174
+ <TestCommand
175
+ visible={false}
176
+ onClose={() => {}}
177
+ items={makeItems(() => {})}
178
+ />
179
+ </BloomThemeProvider>,
180
+ );
181
+ });
182
+ expect(spies.close).toHaveBeenCalledTimes(1);
183
+ });
184
+
185
+ it('forwards a user dismissal (backdrop / Escape) through onClose', () => {
186
+ const spyRef: { fn?: () => void } = {};
187
+ const MockDialog = (props: DialogProps) => {
188
+ spyRef.fn = props.onClose;
189
+ return null;
190
+ };
191
+ const onClose = jest.fn();
192
+ const TestCommand = createCommand(MockDialog);
193
+ renderWithTheme(
194
+ <TestCommand visible onClose={onClose} items={makeItems(() => {})} />,
195
+ );
196
+ // The real Dialog fires `onClose` once its exit animation settles after a
197
+ // backdrop / Escape dismissal. `Command` must forward that to the consumer.
198
+ act(() => {
199
+ spyRef.fn?.();
200
+ });
201
+ expect(onClose).toHaveBeenCalledTimes(1);
202
+ });
203
+
204
+ it('does not re-enter onClose when the consumer closes it (visible → false)', () => {
205
+ const onClose = jest.fn();
206
+ const TestCommand = createCommand(ImperativeMockDialog);
207
+ const { rerender } = renderWithTheme(
208
+ <TestCommand visible onClose={onClose} items={makeItems(() => {})} />,
209
+ );
210
+ act(() => {
211
+ rerender(
212
+ <BloomThemeProvider mode="light" colorPreset="teal">
213
+ <TestCommand
214
+ visible={false}
215
+ onClose={onClose}
216
+ items={makeItems(() => {})}
217
+ />
218
+ </BloomThemeProvider>,
219
+ );
220
+ });
221
+ // A consumer-initiated close flips `visible` to false → `Command`
222
+ // imperatively `close()`s the Dialog (which fires its post-exit `onClose`).
223
+ // That programmatic close must NOT re-enter the consumer's `onClose`,
224
+ // preserving the previous controlled semantics.
225
+ expect(onClose).not.toHaveBeenCalled();
226
+ });
227
+ });
107
228
  });
@@ -1,4 +1,4 @@
1
- import React, { useCallback, useMemo, useRef, useState } from 'react';
1
+ import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
2
2
  import {
3
3
  Platform,
4
4
  ScrollView,
@@ -15,6 +15,7 @@ import { Kbd } from '../kbd';
15
15
  import { SearchInput } from '../search-input';
16
16
  import { fontSize, space } from '../styles/tokens';
17
17
  import type { DialogProps } from '../dialog';
18
+ import { useDialogControl } from '../dialog/context';
18
19
  import type { CommandItem, CommandProps } from './types';
19
20
 
20
21
  type DialogComponent = React.ComponentType<DialogProps>;
@@ -48,6 +49,20 @@ interface FlatEntry {
48
49
  * `SearchInput`, an `Item` results list and `Kbd` shortcut hints. Items group
49
50
  * by their `group` field (ungrouped first). On web the list is
50
51
  * keyboard-navigable (Up/Down/Enter); on native, tap to select.
52
+ *
53
+ * Control mode — IMPERATIVE, not controlled. `Command` keeps its public
54
+ * *controlled* API (`visible` boolean + `onClose`) but internally bridges it
55
+ * onto the Dialog's imperative `useDialogControl()` handle, exactly like
56
+ * `AlertDialog`. This makes `Command` the LAST controlled-`open` `Dialog`
57
+ * consumer to move onto the imperative path every other surface uses
58
+ * (`alert()`, `confirm()`, native `Menu`/`Select`/`ContextMenu`, Mention's
59
+ * dialogs), so there is one code path across the ecosystem. It also guarantees
60
+ * the palette's exit animation on the dismiss path even for a consumer that
61
+ * unmounts the palette in response to `onClose` (`{open && <Command …/>}`): the
62
+ * imperative `close()` runs the exit animation FIRST and fires `onClose` only
63
+ * once it settles, whereas the controlled `open` path fires `onClose`
64
+ * synchronously — which, for an unmount-on-close consumer, would tear the
65
+ * surface down before it could animate out.
51
66
  */
52
67
  export function createCommand(Dialog: DialogComponent) {
53
68
  const Command = function Command({
@@ -64,6 +79,7 @@ export function createCommand(Dialog: DialogComponent) {
64
79
  testID,
65
80
  }: CommandProps) {
66
81
  const theme = useTheme();
82
+ const control = useDialogControl();
67
83
  const searchRef = useRef<TextInput>(null);
68
84
  const [activeIndex, setActiveIndex] = useState(0);
69
85
 
@@ -142,6 +158,37 @@ export function createCommand(Dialog: DialogComponent) {
142
158
  [setQuery, onClose],
143
159
  );
144
160
 
161
+ // Bridge the public *controlled* `visible` prop onto the Dialog's imperative
162
+ // open/close (mirrors `AlertDialog`). `control` is referentially stable
163
+ // (memoised on its id), so this effect only re-runs when `visible` actually
164
+ // flips. Opening straight from an effect on mount matches bloom's own
165
+ // `AutoMountedDialog`. When a consumer flips `visible` to `false` (their own
166
+ // close, or after a select), we imperatively `close()` so the exit animation
167
+ // still plays.
168
+ const closingFromPropRef = useRef(false);
169
+ useEffect(() => {
170
+ if (visible) {
171
+ control.open();
172
+ return;
173
+ }
174
+ closingFromPropRef.current = true;
175
+ control.close();
176
+ }, [visible, control]);
177
+
178
+ // The Dialog fires `onClose` after the exit animation settles (imperative
179
+ // mode). Forward ONLY user-initiated dismissals (backdrop / Escape) to the
180
+ // consumer — a consumer-initiated close (they flipped `visible` to `false`,
181
+ // e.g. `select` already called `onClose`) must not re-enter `onClose`,
182
+ // preserving the previous controlled semantics where a programmatic close
183
+ // does not fire `onClose` a second time.
184
+ const handleClose = useCallback(() => {
185
+ if (closingFromPropRef.current) {
186
+ closingFromPropRef.current = false;
187
+ return;
188
+ }
189
+ onClose();
190
+ }, [onClose]);
191
+
145
192
  // Web keyboard navigation on the search input.
146
193
  const webKeyHandler: Record<string, unknown> =
147
194
  Platform.OS === 'web'
@@ -172,8 +219,8 @@ export function createCommand(Dialog: DialogComponent) {
172
219
 
173
220
  return (
174
221
  <Dialog
175
- open={visible}
176
- onClose={onClose}
222
+ control={control}
223
+ onClose={handleClose}
177
224
  placement="center"
178
225
  dismissOnBackdrop
179
226
  maxWidth={COMMAND_MAX_WIDTH}