@oxy.so/bloom 7.19.1 → 7.20.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/docs/adoption-matrix.mdx +10 -9
- package/docs/dialog.mdx +2 -0
- package/docs/popover.mdx +2 -0
- package/docs/rating.mdx +2 -0
- package/docs/stat-bar.mdx +10 -0
- package/docs/viewport.mdx +47 -0
- package/lib/commonjs/dialog/Dialog.js +5 -3
- package/lib/commonjs/dialog/Dialog.js.map +1 -1
- package/lib/commonjs/dialog/Dialog.web.js +5 -3
- package/lib/commonjs/dialog/Dialog.web.js.map +1 -1
- package/lib/commonjs/dialog/placement.js +8 -1
- package/lib/commonjs/dialog/placement.js.map +1 -1
- package/lib/commonjs/index.js +12 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/index.web.js +12 -0
- package/lib/commonjs/index.web.js.map +1 -1
- package/lib/commonjs/popover/Popover.web.js +11 -1
- package/lib/commonjs/popover/Popover.web.js.map +1 -1
- package/lib/commonjs/popover/context.js.map +1 -1
- package/lib/commonjs/rating/RatingBar.js +2 -0
- package/lib/commonjs/rating/RatingBar.js.map +1 -1
- package/lib/commonjs/rating/RatingBar.web.js +2 -0
- package/lib/commonjs/rating/RatingBar.web.js.map +1 -1
- package/lib/commonjs/stat-bar/Meter.js +7 -4
- package/lib/commonjs/stat-bar/Meter.js.map +1 -1
- package/lib/commonjs/stat-bar/Meter.web.js +11 -4
- package/lib/commonjs/stat-bar/Meter.web.js.map +1 -1
- package/lib/commonjs/stat-bar/use-meter-reveal-policy.js +29 -0
- package/lib/commonjs/stat-bar/use-meter-reveal-policy.js.map +1 -0
- package/lib/commonjs/stat-bar/use-meter-reveal.js +39 -0
- package/lib/commonjs/stat-bar/use-meter-reveal.js.map +1 -0
- package/lib/commonjs/stat-bar/use-meter-reveal.web.js +38 -0
- package/lib/commonjs/stat-bar/use-meter-reveal.web.js.map +1 -0
- package/lib/commonjs/viewport/ViewportProvider.js +28 -0
- package/lib/commonjs/viewport/ViewportProvider.js.map +1 -0
- package/lib/commonjs/viewport/context.js +9 -0
- package/lib/commonjs/viewport/context.js.map +1 -0
- package/lib/commonjs/viewport/geometry.js +31 -0
- package/lib/commonjs/viewport/geometry.js.map +1 -0
- package/lib/commonjs/viewport/index.js +27 -0
- package/lib/commonjs/viewport/index.js.map +1 -0
- package/lib/commonjs/viewport/index.web.js +27 -0
- package/lib/commonjs/viewport/index.web.js.map +1 -0
- package/lib/commonjs/viewport/types.js +6 -0
- package/lib/commonjs/viewport/types.js.map +1 -0
- package/lib/commonjs/viewport/use-in-view.js +106 -0
- package/lib/commonjs/viewport/use-in-view.js.map +1 -0
- package/lib/commonjs/viewport/use-in-view.web.js +49 -0
- package/lib/commonjs/viewport/use-in-view.web.js.map +1 -0
- package/lib/commonjs/viewport/use-viewport-binding.js +55 -0
- package/lib/commonjs/viewport/use-viewport-binding.js.map +1 -0
- package/lib/module/dialog/Dialog.js +6 -4
- package/lib/module/dialog/Dialog.js.map +1 -1
- package/lib/module/dialog/Dialog.web.js +6 -4
- package/lib/module/dialog/Dialog.web.js.map +1 -1
- package/lib/module/dialog/placement.js +7 -1
- package/lib/module/dialog/placement.js.map +1 -1
- package/lib/module/index.js +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/index.web.js +1 -0
- package/lib/module/index.web.js.map +1 -1
- package/lib/module/popover/Popover.web.js +11 -1
- package/lib/module/popover/Popover.web.js.map +1 -1
- package/lib/module/popover/context.js.map +1 -1
- package/lib/module/rating/RatingBar.js +2 -0
- package/lib/module/rating/RatingBar.js.map +1 -1
- package/lib/module/rating/RatingBar.web.js +2 -0
- package/lib/module/rating/RatingBar.web.js.map +1 -1
- package/lib/module/stat-bar/Meter.js +9 -4
- package/lib/module/stat-bar/Meter.js.map +1 -1
- package/lib/module/stat-bar/Meter.web.js +11 -4
- package/lib/module/stat-bar/Meter.web.js.map +1 -1
- package/lib/module/stat-bar/use-meter-reveal-policy.js +25 -0
- package/lib/module/stat-bar/use-meter-reveal-policy.js.map +1 -0
- package/lib/module/stat-bar/use-meter-reveal.js +35 -0
- package/lib/module/stat-bar/use-meter-reveal.js.map +1 -0
- package/lib/module/stat-bar/use-meter-reveal.web.js +34 -0
- package/lib/module/stat-bar/use-meter-reveal.web.js.map +1 -0
- package/lib/module/viewport/ViewportProvider.js +23 -0
- package/lib/module/viewport/ViewportProvider.js.map +1 -0
- package/lib/module/viewport/context.js +5 -0
- package/lib/module/viewport/context.js.map +1 -0
- package/lib/module/viewport/geometry.js +25 -0
- package/lib/module/viewport/geometry.js.map +1 -0
- package/lib/module/viewport/index.js +6 -0
- package/lib/module/viewport/index.js.map +1 -0
- package/lib/module/viewport/index.web.js +11 -0
- package/lib/module/viewport/index.web.js.map +1 -0
- package/lib/module/viewport/types.js +4 -0
- package/lib/module/viewport/types.js.map +1 -0
- package/lib/module/viewport/use-in-view.js +102 -0
- package/lib/module/viewport/use-in-view.js.map +1 -0
- package/lib/module/viewport/use-in-view.web.js +45 -0
- package/lib/module/viewport/use-in-view.web.js.map +1 -0
- package/lib/module/viewport/use-viewport-binding.js +51 -0
- package/lib/module/viewport/use-viewport-binding.js.map +1 -0
- package/lib/typescript/commonjs/dialog/Dialog.web.d.ts.map +1 -1
- package/lib/typescript/commonjs/dialog/placement.d.ts +3 -1
- package/lib/typescript/commonjs/dialog/placement.d.ts.map +1 -1
- package/lib/typescript/commonjs/dialog/types.d.ts +2 -0
- package/lib/typescript/commonjs/dialog/types.d.ts.map +1 -1
- package/lib/typescript/commonjs/index.d.ts +1 -0
- package/lib/typescript/commonjs/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/index.web.d.ts +1 -0
- package/lib/typescript/commonjs/index.web.d.ts.map +1 -1
- package/lib/typescript/commonjs/popover/Popover.web.d.ts.map +1 -1
- package/lib/typescript/commonjs/popover/context.d.ts +16 -2
- package/lib/typescript/commonjs/popover/context.d.ts.map +1 -1
- package/lib/typescript/commonjs/rating/RatingBar.d.ts.map +1 -1
- package/lib/typescript/commonjs/rating/types.d.ts +3 -0
- package/lib/typescript/commonjs/rating/types.d.ts.map +1 -1
- package/lib/typescript/commonjs/stat-bar/Meter.d.ts.map +1 -1
- package/lib/typescript/commonjs/stat-bar/Meter.web.d.ts.map +1 -1
- package/lib/typescript/commonjs/stat-bar/index.d.ts +1 -0
- package/lib/typescript/commonjs/stat-bar/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/stat-bar/index.web.d.ts +1 -0
- package/lib/typescript/commonjs/stat-bar/index.web.d.ts.map +1 -1
- package/lib/typescript/commonjs/stat-bar/types.d.ts +14 -0
- package/lib/typescript/commonjs/stat-bar/types.d.ts.map +1 -1
- package/lib/typescript/commonjs/stat-bar/use-meter-reveal-policy.d.ts +10 -0
- package/lib/typescript/commonjs/stat-bar/use-meter-reveal-policy.d.ts.map +1 -0
- package/lib/typescript/commonjs/stat-bar/use-meter-reveal.d.ts +5 -0
- package/lib/typescript/commonjs/stat-bar/use-meter-reveal.d.ts.map +1 -0
- package/lib/typescript/commonjs/stat-bar/use-meter-reveal.web.d.ts +9 -0
- package/lib/typescript/commonjs/stat-bar/use-meter-reveal.web.d.ts.map +1 -0
- package/lib/typescript/commonjs/viewport/ViewportProvider.d.ts +4 -0
- package/lib/typescript/commonjs/viewport/ViewportProvider.d.ts.map +1 -0
- package/lib/typescript/commonjs/viewport/context.d.ts +8 -0
- package/lib/typescript/commonjs/viewport/context.d.ts.map +1 -0
- package/lib/typescript/commonjs/viewport/geometry.d.ts +10 -0
- package/lib/typescript/commonjs/viewport/geometry.d.ts.map +1 -0
- package/lib/typescript/commonjs/viewport/index.d.ts +5 -0
- package/lib/typescript/commonjs/viewport/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/viewport/index.web.d.ts +5 -0
- package/lib/typescript/commonjs/viewport/index.web.d.ts.map +1 -0
- package/lib/typescript/commonjs/viewport/types.d.ts +25 -0
- package/lib/typescript/commonjs/viewport/types.d.ts.map +1 -0
- package/lib/typescript/commonjs/viewport/use-in-view.d.ts +11 -0
- package/lib/typescript/commonjs/viewport/use-in-view.d.ts.map +1 -0
- package/lib/typescript/commonjs/viewport/use-in-view.web.d.ts +10 -0
- package/lib/typescript/commonjs/viewport/use-in-view.web.d.ts.map +1 -0
- package/lib/typescript/commonjs/viewport/use-viewport-binding.d.ts +9 -0
- package/lib/typescript/commonjs/viewport/use-viewport-binding.d.ts.map +1 -0
- package/lib/typescript/module/dialog/Dialog.web.d.ts.map +1 -1
- package/lib/typescript/module/dialog/placement.d.ts +3 -1
- package/lib/typescript/module/dialog/placement.d.ts.map +1 -1
- package/lib/typescript/module/dialog/types.d.ts +2 -0
- package/lib/typescript/module/dialog/types.d.ts.map +1 -1
- package/lib/typescript/module/index.d.ts +1 -0
- package/lib/typescript/module/index.d.ts.map +1 -1
- package/lib/typescript/module/index.web.d.ts +1 -0
- package/lib/typescript/module/index.web.d.ts.map +1 -1
- package/lib/typescript/module/popover/Popover.web.d.ts.map +1 -1
- package/lib/typescript/module/popover/context.d.ts +16 -2
- package/lib/typescript/module/popover/context.d.ts.map +1 -1
- package/lib/typescript/module/rating/RatingBar.d.ts.map +1 -1
- package/lib/typescript/module/rating/types.d.ts +3 -0
- package/lib/typescript/module/rating/types.d.ts.map +1 -1
- package/lib/typescript/module/stat-bar/Meter.d.ts.map +1 -1
- package/lib/typescript/module/stat-bar/Meter.web.d.ts.map +1 -1
- package/lib/typescript/module/stat-bar/index.d.ts +1 -0
- package/lib/typescript/module/stat-bar/index.d.ts.map +1 -1
- package/lib/typescript/module/stat-bar/index.web.d.ts +1 -0
- package/lib/typescript/module/stat-bar/index.web.d.ts.map +1 -1
- package/lib/typescript/module/stat-bar/types.d.ts +14 -0
- package/lib/typescript/module/stat-bar/types.d.ts.map +1 -1
- package/lib/typescript/module/stat-bar/use-meter-reveal-policy.d.ts +10 -0
- package/lib/typescript/module/stat-bar/use-meter-reveal-policy.d.ts.map +1 -0
- package/lib/typescript/module/stat-bar/use-meter-reveal.d.ts +5 -0
- package/lib/typescript/module/stat-bar/use-meter-reveal.d.ts.map +1 -0
- package/lib/typescript/module/stat-bar/use-meter-reveal.web.d.ts +9 -0
- package/lib/typescript/module/stat-bar/use-meter-reveal.web.d.ts.map +1 -0
- package/lib/typescript/module/viewport/ViewportProvider.d.ts +4 -0
- package/lib/typescript/module/viewport/ViewportProvider.d.ts.map +1 -0
- package/lib/typescript/module/viewport/context.d.ts +8 -0
- package/lib/typescript/module/viewport/context.d.ts.map +1 -0
- package/lib/typescript/module/viewport/geometry.d.ts +10 -0
- package/lib/typescript/module/viewport/geometry.d.ts.map +1 -0
- package/lib/typescript/module/viewport/index.d.ts +5 -0
- package/lib/typescript/module/viewport/index.d.ts.map +1 -0
- package/lib/typescript/module/viewport/index.web.d.ts +5 -0
- package/lib/typescript/module/viewport/index.web.d.ts.map +1 -0
- package/lib/typescript/module/viewport/types.d.ts +25 -0
- package/lib/typescript/module/viewport/types.d.ts.map +1 -0
- package/lib/typescript/module/viewport/use-in-view.d.ts +11 -0
- package/lib/typescript/module/viewport/use-in-view.d.ts.map +1 -0
- package/lib/typescript/module/viewport/use-in-view.web.d.ts +10 -0
- package/lib/typescript/module/viewport/use-in-view.web.d.ts.map +1 -0
- package/lib/typescript/module/viewport/use-viewport-binding.d.ts +9 -0
- package/lib/typescript/module/viewport/use-viewport-binding.d.ts.map +1 -0
- package/package.json +23 -1
- package/src/dialog/Dialog.tsx +7 -4
- package/src/dialog/Dialog.web.tsx +7 -4
- package/src/dialog/placement.ts +9 -1
- package/src/dialog/types.ts +2 -0
- package/src/index.ts +2 -0
- package/src/index.web.ts +2 -0
- package/src/popover/Popover.web.tsx +12 -1
- package/src/popover/context.ts +9 -3
- package/src/rating/RatingBar.tsx +2 -1
- package/src/rating/RatingBar.web.tsx +2 -2
- package/src/rating/types.ts +3 -0
- package/src/stat-bar/Meter.tsx +7 -3
- package/src/stat-bar/Meter.web.tsx +7 -4
- package/src/stat-bar/index.ts +2 -0
- package/src/stat-bar/index.web.ts +2 -0
- package/src/stat-bar/types.ts +15 -0
- package/src/stat-bar/use-meter-reveal-policy.ts +19 -0
- package/src/stat-bar/use-meter-reveal.ts +21 -0
- package/src/stat-bar/use-meter-reveal.web.ts +24 -0
- package/src/viewport/ViewportProvider.tsx +11 -0
- package/src/viewport/context.ts +9 -0
- package/src/viewport/geometry.ts +18 -0
- package/src/viewport/index.ts +4 -0
- package/src/viewport/index.web.ts +9 -0
- package/src/viewport/types.ts +23 -0
- package/src/viewport/use-in-view.ts +69 -0
- package/src/viewport/use-in-view.web.ts +33 -0
- package/src/viewport/use-viewport-binding.ts +34 -0
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Animated } from 'react-native';
|
|
2
|
+
import type { MeterReveal } from './types';
|
|
3
|
+
/** Width animation on the native JS driver; layout properties cannot use the native driver. */
|
|
4
|
+
export declare function useMeterReveal(fraction: number, reveal?: MeterReveal): Animated.AnimatedInterpolation<string | number>;
|
|
5
|
+
//# sourceMappingURL=use-meter-reveal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-meter-reveal.d.ts","sourceRoot":"","sources":["../../../../src/stat-bar/use-meter-reveal.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAU,MAAM,cAAc,CAAC;AAEhD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C,+FAA+F;AAC/F,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,mDAcpE"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { MeterReveal } from './types';
|
|
2
|
+
/** Stage an initial empty paint before the CSS transition, including visible-on-mount. */
|
|
3
|
+
export declare function useMeterReveal(fraction: number, reveal?: MeterReveal): {
|
|
4
|
+
fraction: number;
|
|
5
|
+
duration: number;
|
|
6
|
+
delay: number;
|
|
7
|
+
easing: string;
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=use-meter-reveal.web.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-meter-reveal.web.d.ts","sourceRoot":"","sources":["../../../../src/stat-bar/use-meter-reveal.web.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C,0FAA0F;AAC1F,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW;;;;;EAkBpE"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ViewportProviderProps } from './types';
|
|
2
|
+
/** Scope native clipping geometry without inserting a layout wrapper. */
|
|
3
|
+
export declare function ViewportProvider({ children, root }: ViewportProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
//# sourceMappingURL=ViewportProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ViewportProvider.d.ts","sourceRoot":"","sources":["../../../../src/viewport/ViewportProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAErD,yEAAyE;AACzE,wBAAgB,gBAAgB,CAAC,EAAE,QAAQ,EAAE,IAAY,EAAE,EAAE,qBAAqB,2CAKjF"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ViewportHandle } from './types';
|
|
2
|
+
export interface ViewportScope {
|
|
3
|
+
parent: ViewportScope | null;
|
|
4
|
+
getNode: (() => ViewportHandle | null) | null;
|
|
5
|
+
listeners: Set<() => void>;
|
|
6
|
+
}
|
|
7
|
+
export declare const ViewportContext: import("react").Context<ViewportScope | null>;
|
|
8
|
+
//# sourceMappingURL=context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../../src/viewport/context.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,aAAa,GAAG,IAAI,CAAC;IAC7B,OAAO,EAAE,CAAC,MAAM,cAAc,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC;IAC9C,SAAS,EAAE,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC;CAC5B;AACD,eAAO,MAAM,eAAe,+CAA4C,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface VisibilityRect {
|
|
2
|
+
x: number;
|
|
3
|
+
y: number;
|
|
4
|
+
width: number;
|
|
5
|
+
height: number;
|
|
6
|
+
}
|
|
7
|
+
export declare function validVisibilityRect(rect: VisibilityRect): boolean;
|
|
8
|
+
export declare function intersectionRatio(target: VisibilityRect, clips: readonly VisibilityRect[]): number;
|
|
9
|
+
export declare function visibilityThreshold(value?: number): number;
|
|
10
|
+
//# sourceMappingURL=geometry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"geometry.d.ts","sourceRoot":"","sources":["../../../../src/viewport/geometry.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,cAAc;IAAG,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE;AACvF,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,CAEjE;AACD,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,cAAc,EAAE,KAAK,EAAE,SAAS,cAAc,EAAE,GAAG,MAAM,CASlG;AACD,wBAAgB,mBAAmB,CAAC,KAAK,SAAI,GAAG,MAAM,CAGrD"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { ViewportProvider } from './ViewportProvider';
|
|
2
|
+
export { useViewportBinding } from './use-viewport-binding';
|
|
3
|
+
export { useInView } from './use-in-view';
|
|
4
|
+
export type { ViewportProviderProps, ViewportBindingOptions, InViewOptions, VisibilityHandle, ViewportHandle } from './types';
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/viewport/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,YAAY,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,aAAa,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { ViewportProvider } from './ViewportProvider';
|
|
2
|
+
export { useViewportBinding } from './use-viewport-binding';
|
|
3
|
+
export { useInView } from './use-in-view.web';
|
|
4
|
+
export type { ViewportProviderProps, ViewportBindingOptions, InViewOptions, VisibilityHandle, ViewportHandle } from './types';
|
|
5
|
+
//# sourceMappingURL=index.web.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.web.d.ts","sourceRoot":"","sources":["../../../../src/viewport/index.web.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,YAAY,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,aAAa,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { PropsWithChildren, RefObject } from 'react';
|
|
2
|
+
import type { ScrollViewProps } from 'react-native';
|
|
3
|
+
/** A mounted native viewport or target supporting window-space measurement. */
|
|
4
|
+
export interface VisibilityHandle {
|
|
5
|
+
measureInWindow(callback: (x: number, y: number, width: number, height: number) => void): void;
|
|
6
|
+
}
|
|
7
|
+
/** ScrollView exposes measurement through its native scroll host. */
|
|
8
|
+
export type ViewportHandle = VisibilityHandle | {
|
|
9
|
+
getNativeScrollRef(): VisibilityHandle | null;
|
|
10
|
+
};
|
|
11
|
+
export interface ViewportProviderProps extends PropsWithChildren {
|
|
12
|
+
/** Start a separate clipping chain, e.g. in a portaled dialog. */
|
|
13
|
+
root?: boolean;
|
|
14
|
+
}
|
|
15
|
+
export interface ViewportBindingOptions extends Pick<ScrollViewProps, 'onScroll' | 'onLayout' | 'onContentSizeChange'> {
|
|
16
|
+
/** The actual scrolling/clipping host. Keep its ref on the ScrollView. */
|
|
17
|
+
viewportRef: RefObject<ViewportHandle | null>;
|
|
18
|
+
}
|
|
19
|
+
export interface InViewOptions {
|
|
20
|
+
/** Required visible area fraction, from 0 to 1. Defaults to 0. */
|
|
21
|
+
threshold?: number;
|
|
22
|
+
/** Stop observing after the threshold is first reached. Defaults to false. */
|
|
23
|
+
once?: boolean;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/viewport/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAC1D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAEpD,+EAA+E;AAC/E,MAAM,WAAW,gBAAgB;IAC/B,eAAe,CAAC,QAAQ,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,GAAG,IAAI,CAAC;CAChG;AACD,qEAAqE;AACrE,MAAM,MAAM,cAAc,GAAG,gBAAgB,GAAG;IAAE,kBAAkB,IAAI,gBAAgB,GAAG,IAAI,CAAA;CAAE,CAAC;AAClG,MAAM,WAAW,qBAAsB,SAAQ,iBAAiB;IAC9D,kEAAkE;IAClE,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AACD,MAAM,WAAW,sBAAuB,SAAQ,IAAI,CAAC,eAAe,EAAE,UAAU,GAAG,UAAU,GAAG,qBAAqB,CAAC;IACpH,0EAA0E;IAC1E,WAAW,EAAE,SAAS,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;CAC/C;AACD,MAAM,WAAW,aAAa;IAC5B,kEAAkE;IAClE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,8EAA8E;IAC9E,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { InViewOptions } from './types';
|
|
2
|
+
/** Native visibility is measured against every bound ancestor viewport. */
|
|
3
|
+
export declare function useInView({ threshold: requestedThreshold, once }?: InViewOptions): {
|
|
4
|
+
inView: boolean;
|
|
5
|
+
targetProps: {
|
|
6
|
+
ref: (value: unknown) => void;
|
|
7
|
+
onLayout: () => void;
|
|
8
|
+
collapsable: false;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=use-in-view.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-in-view.d.ts","sourceRoot":"","sources":["../../../../src/viewport/use-in-view.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAoC,MAAM,SAAS,CAAC;AAE/E,2EAA2E;AAC3E,wBAAgB,SAAS,CAAC,EAAE,SAAS,EAAE,kBAAkB,EAAE,IAAY,EAAE,GAAE,aAAkB;;;qBAQ3D,OAAO;;;;EAqDxC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { InViewOptions } from './types';
|
|
2
|
+
/** The browser owns ancestor clipping, scrolling and resize observation. */
|
|
3
|
+
export declare function useInView({ threshold: requestedThreshold, once }?: InViewOptions): {
|
|
4
|
+
inView: boolean;
|
|
5
|
+
targetProps: {
|
|
6
|
+
ref: (value: unknown) => void;
|
|
7
|
+
onLayout: () => void;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=use-in-view.web.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-in-view.web.d.ts","sourceRoot":"","sources":["../../../../src/viewport/use-in-view.web.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C,4EAA4E;AAC5E,wBAAgB,SAAS,CAAC,EAAE,SAAS,EAAE,kBAAkB,EAAE,IAAY,EAAE,GAAE,aAAkB;;;qBAK3D,OAAO;;;EAsBxC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ViewportBindingOptions } from './types';
|
|
2
|
+
/** Compose with restoration/metrics callbacks; no React renders on scroll. */
|
|
3
|
+
export declare function useViewportBinding({ viewportRef, onScroll, onLayout, onContentSizeChange }: ViewportBindingOptions): {
|
|
4
|
+
onScroll: (event: import("react-native").NativeSyntheticEvent<import("react-native").NativeScrollEvent>) => void;
|
|
5
|
+
onLayout: (event: import("react-native").LayoutChangeEvent) => void;
|
|
6
|
+
onContentSizeChange: (contentWidth: number, contentHeight: number) => void;
|
|
7
|
+
scrollEventThrottle: number;
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=use-viewport-binding.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-viewport-binding.d.ts","sourceRoot":"","sources":["../../../../src/viewport/use-viewport-binding.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAEtD,8EAA8E;AAC9E,wBAAgB,kBAAkB,CAAC,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,mBAAmB,EAAE,EAAE,sBAAsB;;;;;EA2BlH"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oxy.so/bloom",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.20.0",
|
|
4
4
|
"packageManager": "bun@1.3.14",
|
|
5
5
|
"description": "Bloom UI — Oxy ecosystem component library for React Native + Expo + Web",
|
|
6
6
|
"main": "lib/commonjs/index.js",
|
|
@@ -371,6 +371,25 @@
|
|
|
371
371
|
"default": "./lib/commonjs/layout/index.js"
|
|
372
372
|
}
|
|
373
373
|
},
|
|
374
|
+
"./viewport": {
|
|
375
|
+
"react-native": {
|
|
376
|
+
"types": "./lib/typescript/module/viewport/index.d.ts",
|
|
377
|
+
"default": "./src/viewport/index.ts"
|
|
378
|
+
},
|
|
379
|
+
"browser": {
|
|
380
|
+
"types": "./lib/typescript/module/viewport/index.web.d.ts",
|
|
381
|
+
"import": "./lib/module/viewport/index.web.js",
|
|
382
|
+
"require": "./lib/commonjs/viewport/index.web.js"
|
|
383
|
+
},
|
|
384
|
+
"import": {
|
|
385
|
+
"types": "./lib/typescript/module/viewport/index.d.ts",
|
|
386
|
+
"default": "./lib/module/viewport/index.js"
|
|
387
|
+
},
|
|
388
|
+
"require": {
|
|
389
|
+
"types": "./lib/typescript/commonjs/viewport/index.d.ts",
|
|
390
|
+
"default": "./lib/commonjs/viewport/index.js"
|
|
391
|
+
}
|
|
392
|
+
},
|
|
374
393
|
"./fab": {
|
|
375
394
|
"react-native": {
|
|
376
395
|
"types": "./lib/typescript/module/fab/index.d.ts",
|
|
@@ -3725,6 +3744,9 @@
|
|
|
3725
3744
|
"layout": [
|
|
3726
3745
|
"./lib/typescript/module/layout/index.d.ts"
|
|
3727
3746
|
],
|
|
3747
|
+
"viewport": [
|
|
3748
|
+
"./lib/typescript/module/viewport/index.d.ts"
|
|
3749
|
+
],
|
|
3728
3750
|
"fab": [
|
|
3729
3751
|
"./lib/typescript/module/fab/index.d.ts"
|
|
3730
3752
|
],
|
package/src/dialog/Dialog.tsx
CHANGED
|
@@ -47,7 +47,7 @@ import {
|
|
|
47
47
|
DEFAULT_DIALOG_CONTENT_PADDING,
|
|
48
48
|
DEFAULT_SIDE_WIDTH,
|
|
49
49
|
DIALOG_SHEET_BACKDROP_TESTID,
|
|
50
|
-
|
|
50
|
+
resolveSideSheetWidth,
|
|
51
51
|
useResolvedPlacement,
|
|
52
52
|
physicalDialogSide,
|
|
53
53
|
type DialogSidePlacement,
|
|
@@ -128,6 +128,7 @@ function CenteredOrSideDialog({
|
|
|
128
128
|
morph,
|
|
129
129
|
placement,
|
|
130
130
|
width = DEFAULT_SIDE_WIDTH,
|
|
131
|
+
minSideGutter,
|
|
131
132
|
inset,
|
|
132
133
|
dismissOnBackdrop = true,
|
|
133
134
|
contentPadding = DEFAULT_DIALOG_CONTENT_PADDING,
|
|
@@ -310,6 +311,7 @@ function CenteredOrSideDialog({
|
|
|
310
311
|
open={sideOpen}
|
|
311
312
|
onDismiss={handleDismiss}
|
|
312
313
|
side={placement}
|
|
314
|
+
minSideGutter={minSideGutter}
|
|
313
315
|
width={width}
|
|
314
316
|
inset={inset}
|
|
315
317
|
dismissOnBackdrop={dismissOnBackdrop}
|
|
@@ -415,6 +417,7 @@ function SideSheet({
|
|
|
415
417
|
onDismiss,
|
|
416
418
|
side,
|
|
417
419
|
width,
|
|
420
|
+
minSideGutter,
|
|
418
421
|
inset,
|
|
419
422
|
dismissOnBackdrop,
|
|
420
423
|
contentPadding,
|
|
@@ -442,6 +445,7 @@ function SideSheet({
|
|
|
442
445
|
onDismiss: () => void;
|
|
443
446
|
side: DialogSidePlacement;
|
|
444
447
|
width: number;
|
|
448
|
+
minSideGutter?: number;
|
|
445
449
|
inset?: DialogInset;
|
|
446
450
|
dismissOnBackdrop: boolean;
|
|
447
451
|
contentPadding: number;
|
|
@@ -484,9 +488,8 @@ function SideSheet({
|
|
|
484
488
|
const oppositeInset = edge === 'left' ? insetRight : insetLeft;
|
|
485
489
|
|
|
486
490
|
const sideWidth = useMemo(() => {
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
}, [viewportWidth, anchorInset, oppositeInset, width]);
|
|
491
|
+
return resolveSideSheetWidth(viewportWidth, width, anchorInset, oppositeInset, minSideGutter);
|
|
492
|
+
}, [viewportWidth, anchorInset, oppositeInset, width, minSideGutter]);
|
|
490
493
|
|
|
491
494
|
// Travel distance for the hidden state: the panel's measured width, with the
|
|
492
495
|
// geometry target as the pre-measurement fallback.
|
|
@@ -66,7 +66,7 @@ import {
|
|
|
66
66
|
DEFAULT_SIDE_WIDTH,
|
|
67
67
|
DIALOG_SHEET_BACKDROP_TESTID,
|
|
68
68
|
EASE_OUT,
|
|
69
|
-
|
|
69
|
+
resolveSideSheetWidth,
|
|
70
70
|
useResolvedPlacement,
|
|
71
71
|
physicalDialogSide,
|
|
72
72
|
type DialogSidePlacement,
|
|
@@ -189,6 +189,7 @@ function CenterOrSideDialog({
|
|
|
189
189
|
header,
|
|
190
190
|
placement,
|
|
191
191
|
width = DEFAULT_SIDE_WIDTH,
|
|
192
|
+
minSideGutter,
|
|
192
193
|
maxWidth = DEFAULT_CENTER_MAX_WIDTH,
|
|
193
194
|
inset,
|
|
194
195
|
dismissOnBackdrop = true,
|
|
@@ -419,6 +420,7 @@ function CenterOrSideDialog({
|
|
|
419
420
|
scrollable={scrollable}
|
|
420
421
|
placement={resolvedPlacement}
|
|
421
422
|
shown={!isClosing}
|
|
423
|
+
minSideGutter={minSideGutter}
|
|
422
424
|
width={width}
|
|
423
425
|
inset={inset}
|
|
424
426
|
dismissOnBackdrop={dismissOnBackdrop}
|
|
@@ -652,6 +654,7 @@ function SheetSurface({
|
|
|
652
654
|
placement,
|
|
653
655
|
shown,
|
|
654
656
|
width,
|
|
657
|
+
minSideGutter,
|
|
655
658
|
inset,
|
|
656
659
|
dismissOnBackdrop,
|
|
657
660
|
contentPadding,
|
|
@@ -675,6 +678,7 @@ function SheetSurface({
|
|
|
675
678
|
placement: DialogSidePlacement;
|
|
676
679
|
shown: boolean;
|
|
677
680
|
width: number;
|
|
681
|
+
minSideGutter?: number;
|
|
678
682
|
inset?: DialogInset;
|
|
679
683
|
dismissOnBackdrop: boolean;
|
|
680
684
|
contentPadding: number;
|
|
@@ -740,8 +744,7 @@ function SheetSurface({
|
|
|
740
744
|
const edge = physicalDialogSide(placement, rtl);
|
|
741
745
|
const anchorInset = edge === 'left' ? insetLeft : insetRight;
|
|
742
746
|
const oppositeInset = edge === 'left' ? insetRight : insetLeft;
|
|
743
|
-
const
|
|
744
|
-
const cappedWidth = Math.max(0, Math.min(width, available));
|
|
747
|
+
const cappedWidth = resolveSideSheetWidth(viewportWidth, width, anchorInset, oppositeInset, minSideGutter);
|
|
745
748
|
const hiddenSign = edge === 'left' ? '-100%' : '100%';
|
|
746
749
|
|
|
747
750
|
return {
|
|
@@ -753,7 +756,7 @@ function SheetSurface({
|
|
|
753
756
|
transform: [{ translateX: visible ? 0 : hiddenSign }],
|
|
754
757
|
opacity: visible ? 1 : 0,
|
|
755
758
|
};
|
|
756
|
-
}, [visible, placement, rtl, width, inset, viewportWidth]);
|
|
759
|
+
}, [visible, placement, rtl, width, inset, viewportWidth, minSideGutter]);
|
|
757
760
|
|
|
758
761
|
const handleBackdropPress = useCallback(() => {
|
|
759
762
|
if (dismissOnBackdrop) onDismiss();
|
package/src/dialog/placement.ts
CHANGED
|
@@ -110,10 +110,18 @@ export const HANDLE_RADIUS = 3;
|
|
|
110
110
|
|
|
111
111
|
/**
|
|
112
112
|
* Minimum gutter kept between a wide side-sheet and the opposite viewport edge
|
|
113
|
-
* when capping its width
|
|
113
|
+
* when capping its width by default. Callers can opt into a zero gutter.
|
|
114
114
|
*/
|
|
115
115
|
export const SIDE_SHEET_MIN_GUTTER = 24;
|
|
116
116
|
|
|
117
|
+
/** Shared native/web width cap; the gutter is separate from edge insets. */
|
|
118
|
+
export function resolveSideSheetWidth(viewportWidth: number, width: number, anchorInset: number,
|
|
119
|
+
oppositeInset: number, minSideGutter = SIDE_SHEET_MIN_GUTTER): number {
|
|
120
|
+
const gutter = Number.isFinite(minSideGutter) ? Math.max(0, minSideGutter) : SIDE_SHEET_MIN_GUTTER;
|
|
121
|
+
return Math.max(0, Math.min(width, viewportWidth - anchorInset - oppositeInset - gutter));
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
|
|
117
125
|
/**
|
|
118
126
|
* Resolve a (possibly responsive) `placement` to a concrete `DialogPlacement`
|
|
119
127
|
* for the current viewport width.
|
package/src/dialog/types.ts
CHANGED
|
@@ -272,6 +272,8 @@ export type DialogProps = React.PropsWithChildren<{
|
|
|
272
272
|
placement?: ResponsiveDialogPlacement;
|
|
273
273
|
/** Side-sheet width (px) on wide screens. Defaults to `460`. */
|
|
274
274
|
width?: number;
|
|
275
|
+
/** Minimum space beyond a side sheet and its insets. Defaults to 24; zero permits full viewport width. */
|
|
276
|
+
minSideGutter?: number;
|
|
275
277
|
/** Centered-card max width (px). Defaults to `480`. */
|
|
276
278
|
maxWidth?: number;
|
|
277
279
|
/** Bottom-sheet max height as a fraction of the viewport height. Defaults to `0.9`. */
|
package/src/index.ts
CHANGED
package/src/index.web.ts
CHANGED
|
@@ -13,6 +13,7 @@ import { useWindowDimensions, type View } from 'react-native';
|
|
|
13
13
|
|
|
14
14
|
import { POPOVER_TRIGGER_POPUP } from '../floating/constants';
|
|
15
15
|
import { FloatingPanel } from '../floating/FloatingPanel';
|
|
16
|
+
import { hostElement, useReturnFocusOnClose } from '../floating/menu-keyboard';
|
|
16
17
|
import { useMenuPalette } from '../floating/menu-palette';
|
|
17
18
|
import { TriggerSlot } from '../floating/TriggerSlot';
|
|
18
19
|
import { useAnchorRect } from '../floating/use-anchor-rect';
|
|
@@ -34,7 +35,13 @@ export function Popover({ children, open, defaultOpen = false, onOpenChange }: P
|
|
|
34
35
|
onChange: onOpenChange,
|
|
35
36
|
});
|
|
36
37
|
const anchorRef = useRef<View | null>(null);
|
|
37
|
-
const
|
|
38
|
+
const panelRef = useRef<View | null>(null);
|
|
39
|
+
// The root survives conditionally mounted content, so a caller removing the
|
|
40
|
+
// panel on close still gets the same focus return as an animated exit.
|
|
41
|
+
useReturnFocusOnClose(anchorRef, isOpen, (element) =>
|
|
42
|
+
hostElement(panelRef.current)?.contains(element) ?? false,
|
|
43
|
+
);
|
|
44
|
+
const value = useMemo(() => ({ open: isOpen, setOpen, anchorRef, panelRef }), [isOpen, setOpen]);
|
|
38
45
|
|
|
39
46
|
return <PopoverProvider value={value}>{children}</PopoverProvider>;
|
|
40
47
|
}
|
|
@@ -89,6 +96,9 @@ export function PopoverContent({
|
|
|
89
96
|
const label = labelProp ?? messages.popover;
|
|
90
97
|
const popover = usePopover();
|
|
91
98
|
const anchor = useAnchorRect(popover.anchorRef, popover.open);
|
|
99
|
+
const attachPanel = useCallback((node: View | null) => {
|
|
100
|
+
if (popover.panelRef) popover.panelRef.current = node;
|
|
101
|
+
}, [popover.panelRef]);
|
|
92
102
|
const close = useCallback(() => popover.setOpen(false), [popover]);
|
|
93
103
|
const palette = useMenuPalette();
|
|
94
104
|
const { width: viewportWidth } = useWindowDimensions();
|
|
@@ -106,6 +116,7 @@ export function PopoverContent({
|
|
|
106
116
|
return (
|
|
107
117
|
<FloatingPanel
|
|
108
118
|
material={material}
|
|
119
|
+
panelRef={attachPanel}
|
|
109
120
|
open={popover.open}
|
|
110
121
|
anchor={anchor}
|
|
111
122
|
role="dialog"
|
package/src/popover/context.ts
CHANGED
|
@@ -5,16 +5,22 @@
|
|
|
5
5
|
* have theirs: a dropdown menu opened from inside a popover must drive the MENU,
|
|
6
6
|
* and one shared open-state context would hand it the popover instead.
|
|
7
7
|
*/
|
|
8
|
-
import { createContext, useContext } from 'react';
|
|
8
|
+
import { createContext, useContext, type RefObject } from 'react';
|
|
9
|
+
import type { View } from 'react-native';
|
|
9
10
|
|
|
10
11
|
import type { OverlayShellContextValue } from '../floating/types';
|
|
11
12
|
|
|
12
|
-
|
|
13
|
+
interface PopoverContextValue extends OverlayShellContextValue {
|
|
14
|
+
/** Web floating host; the native sheet owns its own focus lifecycle. */
|
|
15
|
+
panelRef?: RefObject<View | null>;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const PopoverContext = createContext<PopoverContextValue | null>(null);
|
|
13
19
|
PopoverContext.displayName = 'BloomPopoverContext';
|
|
14
20
|
|
|
15
21
|
export const PopoverProvider = PopoverContext.Provider;
|
|
16
22
|
|
|
17
|
-
export function usePopover():
|
|
23
|
+
export function usePopover(): PopoverContextValue {
|
|
18
24
|
const value = useContext(PopoverContext);
|
|
19
25
|
if (!value) {
|
|
20
26
|
throw new Error('Popover parts must be rendered inside a <Popover>.');
|
package/src/rating/RatingBar.tsx
CHANGED
|
@@ -29,7 +29,7 @@ import type { RatingBarProps } from './types';
|
|
|
29
29
|
|
|
30
30
|
const BAR_WIDTH = 96;
|
|
31
31
|
|
|
32
|
-
function RatingBarComponent({ label, value, max = 5, display, labelWidth, style, testID, labelStyle, displayStyle, trackStyle, fillClassName }: RatingBarProps & {
|
|
32
|
+
function RatingBarComponent({ label, value, reveal, max = 5, display, labelWidth, style, testID, labelStyle, displayStyle, trackStyle, fillClassName }: RatingBarProps & {
|
|
33
33
|
labelStyle?: StyleProp<TextStyle>; displayStyle?: StyleProp<TextStyle>; trackStyle?: StyleProp<ViewStyle>;
|
|
34
34
|
}) {
|
|
35
35
|
const theme = useTheme();
|
|
@@ -54,6 +54,7 @@ function RatingBarComponent({ label, value, max = 5, display, labelWidth, style,
|
|
|
54
54
|
{label}
|
|
55
55
|
</Text>
|
|
56
56
|
<Meter
|
|
57
|
+
reveal={reveal}
|
|
57
58
|
value={value}
|
|
58
59
|
max={safeMax}
|
|
59
60
|
height={4}
|
|
@@ -14,14 +14,14 @@ const CSS = `@layer base {
|
|
|
14
14
|
.bloom-rating-track-flex { flex:1; min-width:0; }
|
|
15
15
|
.bloom-rating-display { min-width:28px; text-align:right; font-family:var(--bloom-font-sans); font-size:${semibold.fontSize}px; line-height:${semibold.lineHeight}px; font-weight:${semibold.fontWeight}; font-variant-numeric:tabular-nums; }
|
|
16
16
|
}`;
|
|
17
|
-
export const RatingBar = memo(function RatingBar({ label, value, max = 5, display, labelWidth, style, testID,
|
|
17
|
+
export const RatingBar = memo(function RatingBar({ label, value, reveal, max = 5, display, labelWidth, style, testID,
|
|
18
18
|
className, labelClassName, displayClassName, trackClassName, fillClassName }: RatingBarProps) {
|
|
19
19
|
useInteractiveWebCss('bloom-rating-bar', CSS);
|
|
20
20
|
const theme = useTheme();
|
|
21
21
|
const vars = { '--bloom-rating-text': theme.colors.text, '--bloom-rating-label-width': `${labelWidth ?? 0}px` } as React.CSSProperties;
|
|
22
22
|
return <div className={['bloom-rating-bar', className].filter(Boolean).join(' ')} style={{ ...vars, ...resolveNativeWebStyle(style) }} data-testid={testID}>
|
|
23
23
|
<span className={['bloom-rating-label', labelClassName].filter(Boolean).join(' ')} data-fixed={labelWidth !== undefined ? '' : undefined} aria-hidden>{label}</span>
|
|
24
|
-
<Meter value={value} max={max > 0 ? max : 1} height={4} width={labelWidth === undefined ? 96 : undefined} accessibilityLabel={label} valueText={display}
|
|
24
|
+
<Meter reveal={reveal} value={value} max={max > 0 ? max : 1} height={4} width={labelWidth === undefined ? 96 : undefined} accessibilityLabel={label} valueText={display}
|
|
25
25
|
testID={testID ? `${testID}-bar` : undefined} fillTestID={testID ? `${testID}-fill` : undefined}
|
|
26
26
|
className={['bloom-rating-track', labelWidth !== undefined ? 'bloom-rating-track-flex' : '', trackClassName].filter(Boolean).join(' ')} fillClassName={fillClassName} />
|
|
27
27
|
{display != null && <span className={['bloom-rating-display', displayClassName].filter(Boolean).join(' ')} aria-hidden>{display}</span>}
|
package/src/rating/types.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { MeterReveal } from '../stat-bar/types';
|
|
1
2
|
import type { StyleProp, ViewStyle } from 'react-native';
|
|
2
3
|
|
|
3
4
|
/** `small` is body-2 text with a 14px star; `medium` (default) body text with a 16px star. */
|
|
@@ -103,6 +104,8 @@ export interface RatingInputProps {
|
|
|
103
104
|
}
|
|
104
105
|
|
|
105
106
|
export interface RatingBarProps {
|
|
107
|
+
/** Forwarded to Meter; never changes the accessible measurement. */
|
|
108
|
+
reveal?: MeterReveal;
|
|
106
109
|
className?: string;
|
|
107
110
|
labelClassName?: string;
|
|
108
111
|
displayClassName?: string;
|
package/src/stat-bar/Meter.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { memo, useEffect, useMemo } from 'react';
|
|
2
2
|
import { styled } from 'react-native-css';
|
|
3
|
-
import { Platform, View, type StyleProp, type ViewStyle } from 'react-native';
|
|
3
|
+
import { Animated, Platform, View, type StyleProp, type ViewStyle } from 'react-native';
|
|
4
4
|
|
|
5
5
|
import { webDataSet } from '../styles/web-data';
|
|
6
6
|
import type { WebCssStyle } from '../styles/web-view-style';
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
resolveMeterColors,
|
|
14
14
|
} from './shared';
|
|
15
15
|
import type { AnyMeterProps } from './types';
|
|
16
|
+
import { useMeterReveal } from './use-meter-reveal';
|
|
16
17
|
|
|
17
18
|
/**
|
|
18
19
|
* ONE determinate bar. Every progress bar in Bloom is this one.
|
|
@@ -41,6 +42,7 @@ function MeterComponent(props: AnyMeterProps & { fillStyle?: StyleProp<ViewStyle
|
|
|
41
42
|
const defaults = useMemo(() => resolveMeterColors(theme), [theme]);
|
|
42
43
|
const {
|
|
43
44
|
value,
|
|
45
|
+
reveal,
|
|
44
46
|
max = 1,
|
|
45
47
|
height = 6,
|
|
46
48
|
radius = height / 2,
|
|
@@ -59,6 +61,8 @@ function MeterComponent(props: AnyMeterProps & { fillStyle?: StyleProp<ViewStyle
|
|
|
59
61
|
}, [transitionMs]);
|
|
60
62
|
|
|
61
63
|
const fraction = meterFraction(value, max);
|
|
64
|
+
const revealedWidth = useMeterReveal(fraction, reveal);
|
|
65
|
+
const Fill = reveal ? Animated.View : View;
|
|
62
66
|
|
|
63
67
|
const fillStyle: WebCssStyle = {
|
|
64
68
|
width: `${fraction * 100}%`,
|
|
@@ -69,10 +73,10 @@ function MeterComponent(props: AnyMeterProps & { fillStyle?: StyleProp<ViewStyle
|
|
|
69
73
|
};
|
|
70
74
|
|
|
71
75
|
const bar = (
|
|
72
|
-
<
|
|
76
|
+
<Fill
|
|
73
77
|
{...(transitionMs > 0 ? webDataSet({ bloomMeterFill: '' }) : null)}
|
|
74
78
|
testID={fillTestID}
|
|
75
|
-
style={[fillStyle, callerFillStyle, { width: fillStyle.width }]}
|
|
79
|
+
style={[fillStyle, callerFillStyle, { width: reveal ? revealedWidth : fillStyle.width }]}
|
|
76
80
|
/>
|
|
77
81
|
);
|
|
78
82
|
|
|
@@ -4,11 +4,12 @@ import { useInteractiveWebCss } from '../styles/interactive-web-css';
|
|
|
4
4
|
import { useTheme } from '../theme/use-theme';
|
|
5
5
|
import { meterFraction, meterValue, resolveMeterColors } from './shared';
|
|
6
6
|
import type { AnyMeterProps } from './types';
|
|
7
|
+
import { useMeterReveal } from './use-meter-reveal.web';
|
|
7
8
|
|
|
8
9
|
const CSS = `@layer base {
|
|
9
10
|
.bloom-meter-track { display:block; flex-shrink:0; box-sizing:border-box; width:var(--bloom-meter-width,100%); height:var(--bloom-meter-height); border-radius:var(--bloom-meter-radius); background:var(--bloom-meter-track); overflow:hidden; }
|
|
10
11
|
.bloom-meter-fill { display:block; box-sizing:border-box; height:100%; border-radius:var(--bloom-meter-radius); background:var(--bloom-meter-fill); }
|
|
11
|
-
.bloom-meter-fill[data-transition] { transition:width var(--bloom-meter-ms,0ms) ease-out; }
|
|
12
|
+
.bloom-meter-fill[data-transition] { transition:width var(--bloom-meter-ms,0ms) var(--bloom-meter-easing,ease-out) var(--bloom-meter-delay,0ms); }
|
|
12
13
|
@media(prefers-reduced-motion:reduce) { .bloom-meter-fill[data-transition] { transition:none; } }
|
|
13
14
|
}`;
|
|
14
15
|
|
|
@@ -16,15 +17,17 @@ export const Meter = memo(function Meter(props: AnyMeterProps) {
|
|
|
16
17
|
useInteractiveWebCss('bloom-meter-classes', CSS);
|
|
17
18
|
const theme = useTheme();
|
|
18
19
|
const colors = resolveMeterColors(theme);
|
|
19
|
-
const { value, max = 1, height = 6, radius = height / 2, width, fill = colors.fill, track = colors.track,
|
|
20
|
+
const { value, reveal, max = 1, height = 6, radius = height / 2, width, fill = colors.fill, track = colors.track,
|
|
20
21
|
transitionMs = 0, style, testID, fillTestID = testID ? `${testID}-fill` : undefined, className, fillClassName } = props;
|
|
22
|
+
const motion = useMeterReveal(meterFraction(value, max), reveal);
|
|
21
23
|
const vars = {
|
|
22
24
|
'--bloom-meter-width': width == null ? '100%' : `${width}px`,
|
|
23
25
|
'--bloom-meter-height': `${height}px`, '--bloom-meter-radius': `${radius}px`,
|
|
24
|
-
'--bloom-meter-track': track, '--bloom-meter-fill': fill, '--bloom-meter-ms': `${transitionMs}ms`,
|
|
26
|
+
'--bloom-meter-track': track, '--bloom-meter-fill': fill, '--bloom-meter-ms': `${reveal ? motion.duration : transitionMs}ms`,
|
|
27
|
+
...(reveal ? { '--bloom-meter-delay': `${motion.delay}ms`, '--bloom-meter-easing': motion.easing } : {}),
|
|
25
28
|
} as React.CSSProperties;
|
|
26
29
|
const contents = <div className={['bloom-meter-fill', fillClassName].filter(Boolean).join(' ')}
|
|
27
|
-
data-transition={transitionMs > 0 ? '' : undefined} data-testid={fillTestID} style={{ width: `${meterFraction(value, max) * 100}%` }} />;
|
|
30
|
+
data-transition={(reveal ? motion.duration : transitionMs) > 0 ? '' : undefined} data-testid={fillTestID} style={{ width: `${reveal ? motion.fraction * 100 : meterFraction(value, max) * 100}%` }} />;
|
|
28
31
|
const root = { className: ['bloom-meter-track', className].filter(Boolean).join(' '), style: { ...vars, ...resolveNativeWebStyle(style) }, 'data-testid': testID };
|
|
29
32
|
if (props.decorative) return <div {...root} aria-hidden>{contents}</div>;
|
|
30
33
|
return <div {...root} role="progressbar" aria-label={props.accessibilityLabel} aria-valuemin={0} aria-valuemax={max}
|
package/src/stat-bar/index.ts
CHANGED
package/src/stat-bar/types.ts
CHANGED
|
@@ -68,7 +68,22 @@ export type StatBarProps = StatBarProgressProps | StatBarSplitProps;
|
|
|
68
68
|
// Meter — the bare determinate bar every progress bar in Bloom is built from
|
|
69
69
|
// ---------------------------------------------------------------------------
|
|
70
70
|
|
|
71
|
+
/** Visual-only entrance; the accessible value always remains the real measurement. */
|
|
72
|
+
export interface MeterReveal {
|
|
73
|
+
visible: boolean;
|
|
74
|
+
/** Retain the revealed state after the first visible observation. Default false. */
|
|
75
|
+
once?: boolean;
|
|
76
|
+
/** Non-negative milliseconds. Default 300. */
|
|
77
|
+
duration?: number;
|
|
78
|
+
/** Non-negative milliseconds before motion begins. Default 0. */
|
|
79
|
+
delay?: number;
|
|
80
|
+
/** CSS cubic-bezier control points. Default ease. */
|
|
81
|
+
easing?: readonly [number, number, number, number];
|
|
82
|
+
}
|
|
83
|
+
|
|
71
84
|
interface MeterGeometryProps {
|
|
85
|
+
/** Animate only the fill from empty when visible; reduced motion displays the real value immediately. */
|
|
86
|
+
reveal?: MeterReveal;
|
|
72
87
|
/** Classes on the track. Unclaimed properties retain the normal Meter defaults. */
|
|
73
88
|
className?: string;
|
|
74
89
|
/** Classes on the fill. Width continues to represent value/max. */
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import { usePrefersReducedMotion } from '../hooks/use-prefers-reduced-motion';
|
|
3
|
+
import type { MeterReveal } from './types';
|
|
4
|
+
|
|
5
|
+
/** Shared reveal policy. Visibility never replaces the public data value. */
|
|
6
|
+
export function useMeterRevealPolicy(fraction: number, reveal?: MeterReveal) {
|
|
7
|
+
const reduced = usePrefersReducedMotion();
|
|
8
|
+
const [entered, setEntered] = useState(false);
|
|
9
|
+
if (reveal?.visible && !entered) setEntered(true);
|
|
10
|
+
const visible = !reveal || reduced || reveal.visible || (!!reveal.once && entered);
|
|
11
|
+
const duration = Math.max(0, Number.isFinite(reveal?.duration) ? reveal!.duration! : 300);
|
|
12
|
+
const delay = Math.max(0, Number.isFinite(reveal?.delay) ? reveal!.delay! : 0);
|
|
13
|
+
const easing = reveal?.easing ?? [.25, .1, .25, 1] as const;
|
|
14
|
+
if (easing.some((value) => !Number.isFinite(value)) || easing[0] < 0 || easing[0] > 1 || easing[2] < 0 || easing[2] > 1) {
|
|
15
|
+
throw new Error('Bloom Meter reveal easing requires finite cubic-bezier coordinates with x values in 0..1.');
|
|
16
|
+
}
|
|
17
|
+
return { fraction: visible ? fraction : 0, animate: !!reveal && visible && !reduced && duration > 0, duration, delay, easing };
|
|
18
|
+
}
|
|
19
|
+
|