@oxy.so/bloom 7.15.0 → 7.16.1
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/accordion.mdx +38 -1
- package/docs/adoption-matrix.mdx +8 -8
- package/docs/dialog.mdx +15 -0
- package/docs/rating.mdx +18 -0
- package/docs/stat-bar.mdx +1 -0
- package/lib/commonjs/accordion/Accordion.js +60 -78
- package/lib/commonjs/accordion/Accordion.js.map +1 -1
- package/lib/commonjs/accordion/Accordion.web.js +193 -0
- package/lib/commonjs/accordion/Accordion.web.js.map +1 -0
- package/lib/commonjs/accordion/context.js +21 -0
- package/lib/commonjs/accordion/context.js.map +1 -0
- package/lib/commonjs/accordion/index.js +1 -1
- package/lib/commonjs/accordion/index.web.js +31 -0
- package/lib/commonjs/accordion/index.web.js.map +1 -0
- package/lib/commonjs/accordion/use-accordion.js +82 -0
- package/lib/commonjs/accordion/use-accordion.js.map +1 -0
- package/lib/commonjs/booking/BookingCard.js +2 -2
- package/lib/commonjs/booking/BookingCard.js.map +1 -1
- package/lib/commonjs/carrier-quote/CarrierQuoteCard.js +11 -11
- package/lib/commonjs/carrier-quote/CarrierQuoteCard.js.map +1 -1
- package/lib/commonjs/cart-panel/CartPanel.js +5 -5
- package/lib/commonjs/cart-panel/CartPanel.js.map +1 -1
- package/lib/commonjs/creator-studio/TrackUploadRow.js +10 -10
- package/lib/commonjs/creator-studio/TrackUploadRow.js.map +1 -1
- package/lib/commonjs/dialog/Dialog.js +12 -2
- package/lib/commonjs/dialog/Dialog.js.map +1 -1
- package/lib/commonjs/dialog/Dialog.web.js +26 -4
- package/lib/commonjs/dialog/Dialog.web.js.map +1 -1
- package/lib/commonjs/dialog/DialogMorph.js +4 -4
- package/lib/commonjs/index.js +839 -839
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/index.web.js +906 -906
- package/lib/commonjs/index.web.js.map +1 -1
- package/lib/commonjs/lead-score/LeadScoreCard.js +10 -10
- package/lib/commonjs/lead-score/LeadScoreCard.js.map +1 -1
- package/lib/commonjs/listing-actions/ApplicationChecklist.js +7 -7
- package/lib/commonjs/listing-actions/ApplicationChecklist.js.map +1 -1
- package/lib/commonjs/listing-card/ListingCard.js +25 -25
- package/lib/commonjs/listing-card/ListingCard.js.map +1 -1
- package/lib/commonjs/listing-details/ListingHeader.js +8 -8
- package/lib/commonjs/listing-details/ListingHeader.js.map +1 -1
- package/lib/commonjs/listing-details/ReviewSummary.js +8 -8
- package/lib/commonjs/listing-details/ReviewSummary.js.map +1 -1
- package/lib/commonjs/listing-editor/ListingQualityMeter.js +10 -10
- package/lib/commonjs/listing-editor/ListingQualityMeter.js.map +1 -1
- package/lib/commonjs/map-marker/MapListingPreview.js +9 -9
- package/lib/commonjs/map-marker/MapListingPreview.js.map +1 -1
- package/lib/commonjs/media-card/parts.js +2 -2
- package/lib/commonjs/media-card/parts.js.map +1 -1
- package/lib/commonjs/media-header/AudiobookHeader.js +6 -6
- package/lib/commonjs/media-header/AudiobookHeader.js.map +1 -1
- package/lib/commonjs/media-header/PodcastShowHeader.js +8 -8
- package/lib/commonjs/media-header/PodcastShowHeader.js.map +1 -1
- package/lib/commonjs/media-header/parts.js +11 -11
- package/lib/commonjs/media-header/parts.js.map +1 -1
- package/lib/commonjs/order-status/OrderStatusBar.js +6 -6
- package/lib/commonjs/order-status/OrderStatusBar.js.map +1 -1
- package/lib/commonjs/outline-nav/OutlineNav.js +5 -5
- package/lib/commonjs/outline-nav/OutlineNav.js.map +1 -1
- package/lib/commonjs/overlay/ModalKeyboard.js +7 -3
- package/lib/commonjs/overlay/ModalKeyboard.js.map +1 -1
- package/lib/commonjs/overlay/modal-keyboard.js +10 -0
- package/lib/commonjs/overlay/modal-keyboard.js.map +1 -1
- package/lib/commonjs/place-card/PlaceCard.js +21 -21
- package/lib/commonjs/place-card/PlaceCard.js.map +1 -1
- package/lib/commonjs/place-details/PlaceHours.js +12 -12
- package/lib/commonjs/place-details/PlaceHours.js.map +1 -1
- package/lib/commonjs/place-reviews/PlaceReviewCard.js +9 -9
- package/lib/commonjs/place-reviews/PlaceReviewCard.js.map +1 -1
- package/lib/commonjs/property-insights/NeighbourhoodScores.js +10 -10
- package/lib/commonjs/property-insights/NeighbourhoodScores.js.map +1 -1
- package/lib/commonjs/property-insights/PricePerAreaComparison.js +5 -5
- package/lib/commonjs/property-insights/PricePerAreaComparison.js.map +1 -1
- package/lib/commonjs/rating/Rating.js +7 -4
- package/lib/commonjs/rating/Rating.js.map +1 -1
- package/lib/commonjs/rating/RatingBar.js +23 -12
- package/lib/commonjs/rating/RatingBar.js.map +1 -1
- package/lib/commonjs/rating/RatingBar.web.js +74 -0
- package/lib/commonjs/rating/RatingBar.web.js.map +1 -0
- package/lib/commonjs/rating/index.js +1 -1
- package/lib/commonjs/rating/index.web.js +27 -0
- package/lib/commonjs/rating/index.web.js.map +1 -0
- package/lib/commonjs/stat-bar/Meter.js +9 -2
- package/lib/commonjs/stat-bar/Meter.js.map +1 -1
- package/lib/commonjs/stat-bar/Meter.web.js +79 -0
- package/lib/commonjs/stat-bar/Meter.web.js.map +1 -0
- package/lib/commonjs/stat-bar/StatBar.js +1 -1
- package/lib/commonjs/stat-bar/index.js +1 -1
- package/lib/commonjs/stat-bar/index.web.js +46 -0
- package/lib/commonjs/stat-bar/index.web.js.map +1 -0
- package/lib/commonjs/styles/resolve-native-web-style.js +50 -0
- package/lib/commonjs/styles/resolve-native-web-style.js.map +1 -0
- package/lib/commonjs/tenancy/parts.js +5 -5
- package/lib/commonjs/tenancy/parts.js.map +1 -1
- package/lib/commonjs/track-list/EpisodeRow.js +9 -9
- package/lib/commonjs/track-list/EpisodeRow.js.map +1 -1
- package/lib/commonjs/vendor-card/VendorCard.js +11 -11
- package/lib/commonjs/vendor-card/VendorCard.js.map +1 -1
- package/lib/commonjs/wizard/WizardProgress.js +6 -6
- package/lib/commonjs/wizard/WizardProgress.js.map +1 -1
- package/lib/module/accordion/Accordion.js +58 -76
- package/lib/module/accordion/Accordion.js.map +1 -1
- package/lib/module/accordion/Accordion.web.js +188 -0
- package/lib/module/accordion/Accordion.web.js.map +1 -0
- package/lib/module/accordion/context.js +17 -0
- package/lib/module/accordion/context.js.map +1 -0
- package/lib/module/accordion/index.js +1 -1
- package/lib/module/accordion/index.js.map +1 -1
- package/lib/module/accordion/index.web.js +9 -0
- package/lib/module/accordion/index.web.js.map +1 -0
- package/lib/module/accordion/use-accordion.js +76 -0
- package/lib/module/accordion/use-accordion.js.map +1 -0
- package/lib/module/booking/BookingCard.js +1 -1
- package/lib/module/booking/BookingCard.js.map +1 -1
- package/lib/module/carrier-quote/CarrierQuoteCard.js +1 -1
- package/lib/module/carrier-quote/CarrierQuoteCard.js.map +1 -1
- package/lib/module/cart-panel/CartPanel.js +1 -1
- package/lib/module/cart-panel/CartPanel.js.map +1 -1
- package/lib/module/creator-studio/TrackUploadRow.js +1 -1
- package/lib/module/creator-studio/TrackUploadRow.js.map +1 -1
- package/lib/module/dialog/Dialog.js +12 -2
- package/lib/module/dialog/Dialog.js.map +1 -1
- package/lib/module/dialog/Dialog.web.js +26 -4
- package/lib/module/dialog/Dialog.web.js.map +1 -1
- package/lib/module/dialog/DialogMorph.js +4 -4
- package/lib/module/index.js +3 -3
- package/lib/module/index.js.map +1 -1
- package/lib/module/index.web.js +3 -3
- package/lib/module/index.web.js.map +1 -1
- package/lib/module/lead-score/LeadScoreCard.js +1 -1
- package/lib/module/lead-score/LeadScoreCard.js.map +1 -1
- package/lib/module/listing-actions/ApplicationChecklist.js +1 -1
- package/lib/module/listing-actions/ApplicationChecklist.js.map +1 -1
- package/lib/module/listing-card/ListingCard.js +1 -1
- package/lib/module/listing-card/ListingCard.js.map +1 -1
- package/lib/module/listing-details/ListingHeader.js +1 -1
- package/lib/module/listing-details/ListingHeader.js.map +1 -1
- package/lib/module/listing-details/ReviewSummary.js +1 -1
- package/lib/module/listing-details/ReviewSummary.js.map +1 -1
- package/lib/module/listing-editor/ListingQualityMeter.js +1 -1
- package/lib/module/listing-editor/ListingQualityMeter.js.map +1 -1
- package/lib/module/map-marker/MapListingPreview.js +1 -1
- package/lib/module/map-marker/MapListingPreview.js.map +1 -1
- package/lib/module/media-card/parts.js +1 -1
- package/lib/module/media-card/parts.js.map +1 -1
- package/lib/module/media-header/AudiobookHeader.js +1 -1
- package/lib/module/media-header/AudiobookHeader.js.map +1 -1
- package/lib/module/media-header/PodcastShowHeader.js +1 -1
- package/lib/module/media-header/PodcastShowHeader.js.map +1 -1
- package/lib/module/media-header/parts.js +1 -1
- package/lib/module/media-header/parts.js.map +1 -1
- package/lib/module/order-status/OrderStatusBar.js +1 -1
- package/lib/module/order-status/OrderStatusBar.js.map +1 -1
- package/lib/module/outline-nav/OutlineNav.js +1 -1
- package/lib/module/outline-nav/OutlineNav.js.map +1 -1
- package/lib/module/overlay/ModalKeyboard.js +8 -4
- package/lib/module/overlay/ModalKeyboard.js.map +1 -1
- package/lib/module/overlay/modal-keyboard.js +9 -0
- package/lib/module/overlay/modal-keyboard.js.map +1 -1
- package/lib/module/place-card/PlaceCard.js +1 -1
- package/lib/module/place-card/PlaceCard.js.map +1 -1
- package/lib/module/place-details/PlaceHours.js +1 -1
- package/lib/module/place-details/PlaceHours.js.map +1 -1
- package/lib/module/place-reviews/PlaceReviewCard.js +1 -1
- package/lib/module/place-reviews/PlaceReviewCard.js.map +1 -1
- package/lib/module/property-insights/NeighbourhoodScores.js +1 -1
- package/lib/module/property-insights/NeighbourhoodScores.js.map +1 -1
- package/lib/module/property-insights/PricePerAreaComparison.js +1 -1
- package/lib/module/property-insights/PricePerAreaComparison.js.map +1 -1
- package/lib/module/rating/Rating.js +7 -4
- package/lib/module/rating/Rating.js.map +1 -1
- package/lib/module/rating/RatingBar.js +19 -8
- package/lib/module/rating/RatingBar.js.map +1 -1
- package/lib/module/rating/RatingBar.web.js +69 -0
- package/lib/module/rating/RatingBar.web.js.map +1 -0
- package/lib/module/rating/index.js +1 -1
- package/lib/module/rating/index.js.map +1 -1
- package/lib/module/rating/index.web.js +11 -0
- package/lib/module/rating/index.web.js.map +1 -0
- package/lib/module/stat-bar/Meter.js +9 -2
- package/lib/module/stat-bar/Meter.js.map +1 -1
- package/lib/module/stat-bar/Meter.web.js +74 -0
- package/lib/module/stat-bar/Meter.web.js.map +1 -0
- package/lib/module/stat-bar/StatBar.js +1 -1
- package/lib/module/stat-bar/StatBar.js.map +1 -1
- package/lib/module/stat-bar/index.js +1 -1
- package/lib/module/stat-bar/index.js.map +1 -1
- package/lib/module/stat-bar/index.web.js +12 -0
- package/lib/module/stat-bar/index.web.js.map +1 -0
- package/lib/module/styles/resolve-native-web-style.js +47 -0
- package/lib/module/styles/resolve-native-web-style.js.map +1 -0
- package/lib/module/tenancy/parts.js +1 -1
- package/lib/module/tenancy/parts.js.map +1 -1
- package/lib/module/track-list/EpisodeRow.js +1 -1
- package/lib/module/track-list/EpisodeRow.js.map +1 -1
- package/lib/module/vendor-card/VendorCard.js +1 -1
- package/lib/module/vendor-card/VendorCard.js.map +1 -1
- package/lib/module/wizard/WizardProgress.js +1 -1
- package/lib/module/wizard/WizardProgress.js.map +1 -1
- package/lib/typescript/commonjs/accordion/Accordion.d.ts +15 -4
- package/lib/typescript/commonjs/accordion/Accordion.d.ts.map +1 -1
- package/lib/typescript/commonjs/accordion/Accordion.web.d.ts +7 -0
- package/lib/typescript/commonjs/accordion/Accordion.web.d.ts.map +1 -0
- package/lib/typescript/commonjs/accordion/context.d.ts +16 -0
- package/lib/typescript/commonjs/accordion/context.d.ts.map +1 -0
- package/lib/typescript/commonjs/accordion/index.d.ts +1 -1
- package/lib/typescript/commonjs/accordion/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/accordion/index.web.d.ts +3 -0
- package/lib/typescript/commonjs/accordion/index.web.d.ts.map +1 -0
- package/lib/typescript/commonjs/accordion/types.d.ts +15 -0
- package/lib/typescript/commonjs/accordion/types.d.ts.map +1 -1
- package/lib/typescript/commonjs/accordion/use-accordion.d.ts +18 -0
- package/lib/typescript/commonjs/accordion/use-accordion.d.ts.map +1 -0
- package/lib/typescript/commonjs/dialog/Dialog.web.d.ts.map +1 -1
- package/lib/typescript/commonjs/dialog/DialogMorph.d.ts +4 -4
- package/lib/typescript/commonjs/index.web.d.ts +5 -5
- package/lib/typescript/commonjs/index.web.d.ts.map +1 -1
- package/lib/typescript/commonjs/overlay/ModalKeyboard.d.ts +1 -1
- package/lib/typescript/commonjs/overlay/modal-keyboard.d.ts +2 -0
- package/lib/typescript/commonjs/overlay/modal-keyboard.d.ts.map +1 -1
- package/lib/typescript/commonjs/rating/Rating.d.ts +1 -1
- package/lib/typescript/commonjs/rating/Rating.d.ts.map +1 -1
- package/lib/typescript/commonjs/rating/RatingBar.d.ts +11 -3
- package/lib/typescript/commonjs/rating/RatingBar.d.ts.map +1 -1
- package/lib/typescript/commonjs/rating/RatingBar.web.d.ts +4 -0
- package/lib/typescript/commonjs/rating/RatingBar.web.d.ts.map +1 -0
- package/lib/typescript/commonjs/rating/index.web.d.ts +5 -0
- package/lib/typescript/commonjs/rating/index.web.d.ts.map +1 -0
- package/lib/typescript/commonjs/rating/types.d.ts +11 -0
- package/lib/typescript/commonjs/rating/types.d.ts.map +1 -1
- package/lib/typescript/commonjs/stat-bar/Meter.d.ts +7 -25
- package/lib/typescript/commonjs/stat-bar/Meter.d.ts.map +1 -1
- package/lib/typescript/commonjs/stat-bar/Meter.web.d.ts +4 -0
- package/lib/typescript/commonjs/stat-bar/Meter.web.d.ts.map +1 -0
- package/lib/typescript/commonjs/stat-bar/index.web.d.ts +7 -0
- package/lib/typescript/commonjs/stat-bar/index.web.d.ts.map +1 -0
- package/lib/typescript/commonjs/stat-bar/types.d.ts +4 -0
- package/lib/typescript/commonjs/stat-bar/types.d.ts.map +1 -1
- package/lib/typescript/commonjs/styles/resolve-native-web-style.d.ts +5 -0
- package/lib/typescript/commonjs/styles/resolve-native-web-style.d.ts.map +1 -0
- package/lib/typescript/module/accordion/Accordion.d.ts +15 -4
- package/lib/typescript/module/accordion/Accordion.d.ts.map +1 -1
- package/lib/typescript/module/accordion/Accordion.web.d.ts +7 -0
- package/lib/typescript/module/accordion/Accordion.web.d.ts.map +1 -0
- package/lib/typescript/module/accordion/context.d.ts +16 -0
- package/lib/typescript/module/accordion/context.d.ts.map +1 -0
- package/lib/typescript/module/accordion/index.d.ts +1 -1
- package/lib/typescript/module/accordion/index.d.ts.map +1 -1
- package/lib/typescript/module/accordion/index.web.d.ts +3 -0
- package/lib/typescript/module/accordion/index.web.d.ts.map +1 -0
- package/lib/typescript/module/accordion/types.d.ts +15 -0
- package/lib/typescript/module/accordion/types.d.ts.map +1 -1
- package/lib/typescript/module/accordion/use-accordion.d.ts +18 -0
- package/lib/typescript/module/accordion/use-accordion.d.ts.map +1 -0
- package/lib/typescript/module/dialog/Dialog.web.d.ts.map +1 -1
- package/lib/typescript/module/dialog/DialogMorph.d.ts +4 -4
- package/lib/typescript/module/index.web.d.ts +5 -5
- package/lib/typescript/module/index.web.d.ts.map +1 -1
- package/lib/typescript/module/overlay/ModalKeyboard.d.ts +1 -1
- package/lib/typescript/module/overlay/modal-keyboard.d.ts +2 -0
- package/lib/typescript/module/overlay/modal-keyboard.d.ts.map +1 -1
- package/lib/typescript/module/rating/Rating.d.ts +1 -1
- package/lib/typescript/module/rating/Rating.d.ts.map +1 -1
- package/lib/typescript/module/rating/RatingBar.d.ts +11 -3
- package/lib/typescript/module/rating/RatingBar.d.ts.map +1 -1
- package/lib/typescript/module/rating/RatingBar.web.d.ts +4 -0
- package/lib/typescript/module/rating/RatingBar.web.d.ts.map +1 -0
- package/lib/typescript/module/rating/index.web.d.ts +5 -0
- package/lib/typescript/module/rating/index.web.d.ts.map +1 -0
- package/lib/typescript/module/rating/types.d.ts +11 -0
- package/lib/typescript/module/rating/types.d.ts.map +1 -1
- package/lib/typescript/module/stat-bar/Meter.d.ts +7 -25
- package/lib/typescript/module/stat-bar/Meter.d.ts.map +1 -1
- package/lib/typescript/module/stat-bar/Meter.web.d.ts +4 -0
- package/lib/typescript/module/stat-bar/Meter.web.d.ts.map +1 -0
- package/lib/typescript/module/stat-bar/index.web.d.ts +7 -0
- package/lib/typescript/module/stat-bar/index.web.d.ts.map +1 -0
- package/lib/typescript/module/stat-bar/types.d.ts +4 -0
- package/lib/typescript/module/stat-bar/types.d.ts.map +1 -1
- package/lib/typescript/module/styles/resolve-native-web-style.d.ts +5 -0
- package/lib/typescript/module/styles/resolve-native-web-style.d.ts.map +1 -0
- package/package.json +16 -1
- package/src/accordion/Accordion.tsx +34 -94
- package/src/accordion/Accordion.web.tsx +91 -0
- package/src/accordion/context.ts +15 -0
- package/src/accordion/index.ts +1 -0
- package/src/accordion/index.web.ts +14 -0
- package/src/accordion/types.ts +15 -0
- package/src/accordion/use-accordion.ts +47 -0
- package/src/dialog/Dialog.tsx +8 -3
- package/src/dialog/Dialog.web.tsx +39 -23
- package/src/dialog/DialogMorph.tsx +4 -4
- package/src/index.web.ts +5 -5
- package/src/overlay/ModalKeyboard.tsx +4 -4
- package/src/overlay/modal-keyboard.ts +9 -0
- package/src/rating/Rating.tsx +7 -4
- package/src/rating/RatingBar.tsx +10 -5
- package/src/rating/RatingBar.web.tsx +29 -0
- package/src/rating/index.web.ts +17 -0
- package/src/rating/types.ts +11 -0
- package/src/stat-bar/Meter.tsx +6 -4
- package/src/stat-bar/Meter.web.tsx +32 -0
- package/src/stat-bar/index.web.ts +20 -0
- package/src/stat-bar/types.ts +4 -0
- package/src/styles/resolve-native-web-style.ts +41 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useCallback, useEffect, useRef } from 'react';
|
|
2
2
|
import type { View } from 'react-native';
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { initialFocusWithin, listenForEscape, wrapTab } from './modal-keyboard';
|
|
5
5
|
import { useOverlayLayerContext } from './Overlay';
|
|
6
6
|
import { isTopmostOverlayLayer } from './stack';
|
|
7
7
|
|
|
@@ -22,7 +22,7 @@ export interface ModalKeyboardProps {
|
|
|
22
22
|
* and the web `BottomSheet`.
|
|
23
23
|
*
|
|
24
24
|
* - Focus moves INTO the panel when it opens — to whatever the content
|
|
25
|
-
* focused itself (an `autoFocus` field), else the first tabbable, else the
|
|
25
|
+
* focused itself (an `autoFocus` field), else the first visible tabbable, else the
|
|
26
26
|
* panel — and goes BACK to the element that had it once the surface starts
|
|
27
27
|
* closing (or unmounts), unless the host has already put it somewhere else.
|
|
28
28
|
* - Tab and Shift+Tab wrap at the panel's edges.
|
|
@@ -48,7 +48,7 @@ export function ModalKeyboard({ panelRef, closing = false, dismissible, dismiss
|
|
|
48
48
|
const active = document.activeElement;
|
|
49
49
|
// Only focus the surface still holds (or lost with its nodes): a host that
|
|
50
50
|
// moved focus on purpose while closing keeps its choice.
|
|
51
|
-
if (!active || active === document.body || panel?.contains(active)) target.focus();
|
|
51
|
+
if (!active || active === document.body || panel?.contains(active)) target.focus({ preventScroll: true });
|
|
52
52
|
}, [panelRef]);
|
|
53
53
|
|
|
54
54
|
useEffect(() => {
|
|
@@ -60,7 +60,7 @@ export function ModalKeyboard({ panelRef, closing = false, dismissible, dismiss
|
|
|
60
60
|
const frame = requestAnimationFrame(() => {
|
|
61
61
|
const node = panel();
|
|
62
62
|
if (!node || node.contains(document.activeElement) || !isTopmostOverlayLayer(layer)) return;
|
|
63
|
-
(
|
|
63
|
+
initialFocusWithin(node).focus({ preventScroll: true });
|
|
64
64
|
});
|
|
65
65
|
const onTab = (event: KeyboardEvent) => {
|
|
66
66
|
if (event.defaultPrevented || !isTopmostOverlayLayer(layer)) return;
|
|
@@ -59,6 +59,15 @@ export function tabbablesWithin(node: HTMLElement | null): HTMLElement[] {
|
|
|
59
59
|
);
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
+
/** Initial focus must not scroll long content to an offscreen action. Tab still reaches every control. */
|
|
63
|
+
export function initialFocusWithin(node: HTMLElement): HTMLElement {
|
|
64
|
+
const panel = node.getBoundingClientRect();
|
|
65
|
+
return tabbablesWithin(node).find(element => {
|
|
66
|
+
const rect = element.getBoundingClientRect();
|
|
67
|
+
return rect.top >= panel.top && rect.bottom <= panel.bottom && rect.left >= panel.left && rect.right <= panel.right;
|
|
68
|
+
}) ?? node;
|
|
69
|
+
}
|
|
70
|
+
|
|
62
71
|
/**
|
|
63
72
|
* Keep Tab inside `node`: from the last tabbable (or from outside) forward to
|
|
64
73
|
* the first, from the first (or from outside) backward to the last. Returns
|
package/src/rating/Rating.tsx
CHANGED
|
@@ -145,6 +145,8 @@ function RatingComponent({
|
|
|
145
145
|
newLabel: newLabelProp,
|
|
146
146
|
size = 'medium',
|
|
147
147
|
variant = 'compact',
|
|
148
|
+
showValue = true,
|
|
149
|
+
starSize,
|
|
148
150
|
color,
|
|
149
151
|
starColor,
|
|
150
152
|
countColor,
|
|
@@ -162,6 +164,7 @@ function RatingComponent({
|
|
|
162
164
|
const starPaint = starColor ?? textColor;
|
|
163
165
|
const countPaint = countColor ?? color ?? theme.colors.textSecondary;
|
|
164
166
|
const config = SIZE_CONFIG[size];
|
|
167
|
+
const glyphSize = typeof starSize === 'number' && Number.isFinite(starSize) && starSize > 0 ? starSize : config.star;
|
|
165
168
|
const rated = value != null && value !== '';
|
|
166
169
|
const shownValue = rated ? formatRatingValue(value) : newLabel;
|
|
167
170
|
const hasCount = rated && count != null && count !== '';
|
|
@@ -196,17 +199,17 @@ function RatingComponent({
|
|
|
196
199
|
{variant === 'stars' && rated ? (
|
|
197
200
|
<StarRow
|
|
198
201
|
rating={clampRating(fillValue ?? parseRatingValue(value))}
|
|
199
|
-
size={
|
|
202
|
+
size={glyphSize}
|
|
200
203
|
fill={starPaint}
|
|
201
204
|
empty={emptyStarColor ?? theme.colors.border}
|
|
202
205
|
testID={testID ? `${testID}-stars` : undefined}
|
|
203
206
|
/>
|
|
204
207
|
) : variant === 'stars' ? null : (
|
|
205
|
-
<RiStarFill width={
|
|
208
|
+
<RiStarFill width={glyphSize} height={glyphSize} fill={starPaint} />
|
|
206
209
|
)}
|
|
207
|
-
<Text variant={config.value} style={{ color: textColor, fontVariant: ['tabular-nums'] }}>
|
|
210
|
+
{(showValue || !rated) && <Text variant={config.value} style={{ color: textColor, fontVariant: ['tabular-nums'] }}>
|
|
208
211
|
{shownValue}
|
|
209
|
-
</Text>
|
|
212
|
+
</Text>}
|
|
210
213
|
{countText != null && (
|
|
211
214
|
<Text variant={config.count} style={{ color: countPaint }}>
|
|
212
215
|
{countText}
|
package/src/rating/RatingBar.tsx
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React, { memo } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { styled } from 'react-native-css';
|
|
3
|
+
import { View, type StyleProp, type TextStyle, type ViewStyle } from 'react-native';
|
|
3
4
|
|
|
4
5
|
import { Meter } from '../stat-bar';
|
|
5
6
|
import { useTheme } from '../theme/use-theme';
|
|
@@ -28,7 +29,9 @@ import type { RatingBarProps } from './types';
|
|
|
28
29
|
|
|
29
30
|
const BAR_WIDTH = 96;
|
|
30
31
|
|
|
31
|
-
function RatingBarComponent({ label, value, max = 5, display, labelWidth, style, testID }: RatingBarProps
|
|
32
|
+
function RatingBarComponent({ label, value, max = 5, display, labelWidth, style, testID, labelStyle, displayStyle, trackStyle, fillClassName }: RatingBarProps & {
|
|
33
|
+
labelStyle?: StyleProp<TextStyle>; displayStyle?: StyleProp<TextStyle>; trackStyle?: StyleProp<ViewStyle>;
|
|
34
|
+
}) {
|
|
32
35
|
const theme = useTheme();
|
|
33
36
|
const safeMax = max > 0 ? max : 1;
|
|
34
37
|
|
|
@@ -45,6 +48,7 @@ function RatingBarComponent({ label, value, max = 5, display, labelWidth, style,
|
|
|
45
48
|
style={[
|
|
46
49
|
{ color: theme.colors.text },
|
|
47
50
|
labelWidth === undefined ? { flex: 1, minWidth: 0 } : { width: labelWidth },
|
|
51
|
+
labelStyle,
|
|
48
52
|
]}
|
|
49
53
|
>
|
|
50
54
|
{label}
|
|
@@ -57,14 +61,15 @@ function RatingBarComponent({ label, value, max = 5, display, labelWidth, style,
|
|
|
57
61
|
valueText={display}
|
|
58
62
|
testID={testID ? `${testID}-bar` : undefined}
|
|
59
63
|
fillTestID={testID ? `${testID}-fill` : undefined}
|
|
60
|
-
|
|
64
|
+
fillClassName={fillClassName}
|
|
65
|
+
style={[labelWidth === undefined ? { width: BAR_WIDTH } : { flex: 1, minWidth: 0 }, trackStyle]}
|
|
61
66
|
/>
|
|
62
67
|
{display != null && (
|
|
63
68
|
<Text
|
|
64
69
|
variant="body-semibold"
|
|
65
70
|
importantForAccessibility="no"
|
|
66
71
|
accessibilityElementsHidden
|
|
67
|
-
style={{ color: theme.colors.text, minWidth: 28, textAlign: 'right', fontVariant: ['tabular-nums'] }}
|
|
72
|
+
style={[{ color: theme.colors.text, minWidth: 28, textAlign: 'right', fontVariant: ['tabular-nums'] }, displayStyle]}
|
|
68
73
|
>
|
|
69
74
|
{display}
|
|
70
75
|
</Text>
|
|
@@ -73,5 +78,5 @@ function RatingBarComponent({ label, value, max = 5, display, labelWidth, style,
|
|
|
73
78
|
);
|
|
74
79
|
}
|
|
75
80
|
|
|
76
|
-
export const RatingBar = memo(RatingBarComponent);
|
|
81
|
+
export const RatingBar = memo(styled(RatingBarComponent, { className: 'style', labelClassName: 'labelStyle', displayClassName: 'displayStyle', trackClassName: 'trackStyle' }));
|
|
77
82
|
RatingBar.displayName = 'RatingBar';
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React, { memo } from 'react';
|
|
2
|
+
import { Meter } from '../stat-bar/index.web';
|
|
3
|
+
import { resolveNativeWebStyle } from '../styles/resolve-native-web-style';
|
|
4
|
+
import { useInteractiveWebCss } from '../styles/interactive-web-css';
|
|
5
|
+
import { useTheme } from '../theme/use-theme';
|
|
6
|
+
import { TYPE_SCALE } from '../typography/scale';
|
|
7
|
+
import type { RatingBarProps } from './types';
|
|
8
|
+
const regular = TYPE_SCALE['body-regular'];
|
|
9
|
+
const semibold = TYPE_SCALE['body-semibold'];
|
|
10
|
+
const CSS = `@layer base {
|
|
11
|
+
.bloom-rating-bar { box-sizing:border-box; flex-shrink:0; display:flex; flex-direction:row; align-items:center; gap:12px; min-width:0; color:var(--bloom-rating-text); }
|
|
12
|
+
.bloom-rating-label { display:block; flex:1; min-width:0; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; font-family:var(--bloom-font-sans); font-size:${regular.fontSize}px; line-height:${regular.lineHeight}px; font-weight:${regular.fontWeight}; letter-spacing:${regular.letterSpacing}px; }
|
|
13
|
+
.bloom-rating-label[data-fixed] { flex:none; width:var(--bloom-rating-label-width); }
|
|
14
|
+
.bloom-rating-track-flex { flex:1; min-width:0; }
|
|
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
|
+
}`;
|
|
17
|
+
export const RatingBar = memo(function RatingBar({ label, value, max = 5, display, labelWidth, style, testID,
|
|
18
|
+
className, labelClassName, displayClassName, trackClassName, fillClassName }: RatingBarProps) {
|
|
19
|
+
useInteractiveWebCss('bloom-rating-bar', CSS);
|
|
20
|
+
const theme = useTheme();
|
|
21
|
+
const vars = { '--bloom-rating-text': theme.colors.text, '--bloom-rating-label-width': `${labelWidth ?? 0}px` } as React.CSSProperties;
|
|
22
|
+
return <div className={['bloom-rating-bar', className].filter(Boolean).join(' ')} style={{ ...vars, ...resolveNativeWebStyle(style) }} data-testid={testID}>
|
|
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}
|
|
25
|
+
testID={testID ? `${testID}-bar` : undefined} fillTestID={testID ? `${testID}-fill` : undefined}
|
|
26
|
+
className={['bloom-rating-track', labelWidth !== undefined ? 'bloom-rating-track-flex' : '', trackClassName].filter(Boolean).join(' ')} fillClassName={fillClassName} />
|
|
27
|
+
{display != null && <span className={['bloom-rating-display', displayClassName].filter(Boolean).join(' ')} aria-hidden>{display}</span>}
|
|
28
|
+
</div>;
|
|
29
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// AUTO-GENERATED by scripts/generate-platform-exports.mjs — DO NOT EDIT.
|
|
2
|
+
// Source of truth: src/rating/index.ts.
|
|
3
|
+
// Re-run `bun run generate:exports` (or any `bun run build`) after
|
|
4
|
+
// changing that barrel or the set of web-forked subpaths.
|
|
5
|
+
|
|
6
|
+
export { Rating } from './Rating';
|
|
7
|
+
export { RatingBar } from './RatingBar.web';
|
|
8
|
+
export { RatingInput } from './RatingInput';
|
|
9
|
+
export type {
|
|
10
|
+
RatingBarProps,
|
|
11
|
+
RatingCountStyle,
|
|
12
|
+
RatingInputProps,
|
|
13
|
+
RatingInputSize,
|
|
14
|
+
RatingProps,
|
|
15
|
+
RatingSize,
|
|
16
|
+
RatingVariant,
|
|
17
|
+
} from './types';
|
package/src/rating/types.ts
CHANGED
|
@@ -32,6 +32,10 @@ export interface RatingProps {
|
|
|
32
32
|
size?: RatingSize;
|
|
33
33
|
/** Default `compact` — one star. `stars` draws a row of five, filled fractionally. */
|
|
34
34
|
variant?: RatingVariant;
|
|
35
|
+
/** Hide the visible numeric value while retaining its accessible name. Default true. */
|
|
36
|
+
showValue?: boolean;
|
|
37
|
+
/** Star dimensions, independent of the label type size. Defaults to the size scale. */
|
|
38
|
+
starSize?: number;
|
|
35
39
|
/**
|
|
36
40
|
* Paints the star(s) and the value — and the count, unless `countColor` is
|
|
37
41
|
* given — e.g. white over a brand-coloured hero, where text-primary and
|
|
@@ -99,6 +103,13 @@ export interface RatingInputProps {
|
|
|
99
103
|
}
|
|
100
104
|
|
|
101
105
|
export interface RatingBarProps {
|
|
106
|
+
className?: string;
|
|
107
|
+
labelClassName?: string;
|
|
108
|
+
displayClassName?: string;
|
|
109
|
+
/** Classes on the underlying Meter track (geometry and paint). */
|
|
110
|
+
trackClassName?: string;
|
|
111
|
+
/** Classes on the underlying Meter fill; its measured fraction stays data-owned. */
|
|
112
|
+
fillClassName?: string;
|
|
102
113
|
/** What the row measures ("Cleanliness", "5 stars"). Also the bar's accessible name. */
|
|
103
114
|
label: string;
|
|
104
115
|
/** Position on the scale, `0..max`; clamped. */
|
package/src/stat-bar/Meter.tsx
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React, { memo, useEffect, useMemo } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { styled } from 'react-native-css';
|
|
3
|
+
import { Platform, View, type StyleProp, type ViewStyle } from 'react-native';
|
|
3
4
|
|
|
4
5
|
import { webDataSet } from '../styles/web-data';
|
|
5
6
|
import type { WebCssStyle } from '../styles/web-view-style';
|
|
@@ -35,7 +36,7 @@ import type { AnyMeterProps } from './types';
|
|
|
35
36
|
* A bar that is one SEGMENT of a larger progressbar passes `decorative` and
|
|
36
37
|
* gets no role at all — two nested progressbars announce the measurement twice.
|
|
37
38
|
*/
|
|
38
|
-
function MeterComponent(props: AnyMeterProps) {
|
|
39
|
+
function MeterComponent(props: AnyMeterProps & { fillStyle?: StyleProp<ViewStyle> }) {
|
|
39
40
|
const theme = useTheme();
|
|
40
41
|
const defaults = useMemo(() => resolveMeterColors(theme), [theme]);
|
|
41
42
|
const {
|
|
@@ -49,6 +50,7 @@ function MeterComponent(props: AnyMeterProps) {
|
|
|
49
50
|
transitionMs = 0,
|
|
50
51
|
style,
|
|
51
52
|
testID,
|
|
53
|
+
fillStyle: callerFillStyle,
|
|
52
54
|
fillTestID = testID ? `${testID}-fill` : undefined,
|
|
53
55
|
} = props;
|
|
54
56
|
|
|
@@ -70,7 +72,7 @@ function MeterComponent(props: AnyMeterProps) {
|
|
|
70
72
|
<View
|
|
71
73
|
{...(transitionMs > 0 ? webDataSet({ bloomMeterFill: '' }) : null)}
|
|
72
74
|
testID={fillTestID}
|
|
73
|
-
style={fillStyle}
|
|
75
|
+
style={[fillStyle, callerFillStyle, { width: fillStyle.width }]}
|
|
74
76
|
/>
|
|
75
77
|
);
|
|
76
78
|
|
|
@@ -112,5 +114,5 @@ function MeterComponent(props: AnyMeterProps) {
|
|
|
112
114
|
);
|
|
113
115
|
}
|
|
114
116
|
|
|
115
|
-
export const Meter = memo(MeterComponent);
|
|
117
|
+
export const Meter = memo(styled(MeterComponent, { className: 'style', fillClassName: 'fillStyle' }));
|
|
116
118
|
Meter.displayName = 'Meter';
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React, { memo } from 'react';
|
|
2
|
+
import { resolveNativeWebStyle } from '../styles/resolve-native-web-style';
|
|
3
|
+
import { useInteractiveWebCss } from '../styles/interactive-web-css';
|
|
4
|
+
import { useTheme } from '../theme/use-theme';
|
|
5
|
+
import { meterFraction, meterValue, resolveMeterColors } from './shared';
|
|
6
|
+
import type { AnyMeterProps } from './types';
|
|
7
|
+
|
|
8
|
+
const CSS = `@layer base {
|
|
9
|
+
.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
|
+
.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
|
+
@media(prefers-reduced-motion:reduce) { .bloom-meter-fill[data-transition] { transition:none; } }
|
|
13
|
+
}`;
|
|
14
|
+
|
|
15
|
+
export const Meter = memo(function Meter(props: AnyMeterProps) {
|
|
16
|
+
useInteractiveWebCss('bloom-meter-classes', CSS);
|
|
17
|
+
const theme = useTheme();
|
|
18
|
+
const colors = resolveMeterColors(theme);
|
|
19
|
+
const { value, max = 1, height = 6, radius = height / 2, width, fill = colors.fill, track = colors.track,
|
|
20
|
+
transitionMs = 0, style, testID, fillTestID = testID ? `${testID}-fill` : undefined, className, fillClassName } = props;
|
|
21
|
+
const vars = {
|
|
22
|
+
'--bloom-meter-width': width == null ? '100%' : `${width}px`,
|
|
23
|
+
'--bloom-meter-height': `${height}px`, '--bloom-meter-radius': `${radius}px`,
|
|
24
|
+
'--bloom-meter-track': track, '--bloom-meter-fill': fill, '--bloom-meter-ms': `${transitionMs}ms`,
|
|
25
|
+
} as React.CSSProperties;
|
|
26
|
+
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}%` }} />;
|
|
28
|
+
const root = { className: ['bloom-meter-track', className].filter(Boolean).join(' '), style: { ...vars, ...resolveNativeWebStyle(style) }, 'data-testid': testID };
|
|
29
|
+
if (props.decorative) return <div {...root} aria-hidden>{contents}</div>;
|
|
30
|
+
return <div {...root} role="progressbar" aria-label={props.accessibilityLabel} aria-valuemin={0} aria-valuemax={max}
|
|
31
|
+
aria-valuenow={meterValue(value, max)} aria-valuetext={props.valueText}>{contents}</div>;
|
|
32
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// AUTO-GENERATED by scripts/generate-platform-exports.mjs — DO NOT EDIT.
|
|
2
|
+
// Source of truth: src/stat-bar/index.ts.
|
|
3
|
+
// Re-run `bun run generate:exports` (or any `bun run build`) after
|
|
4
|
+
// changing that barrel or the set of web-forked subpaths.
|
|
5
|
+
|
|
6
|
+
export { Meter } from './Meter.web';
|
|
7
|
+
export { MeterRing } from './MeterRing';
|
|
8
|
+
export { StatBar } from './StatBar';
|
|
9
|
+
export { meterFraction, meterValue, resolveMeterColors } from './shared';
|
|
10
|
+
export type { MeterColors } from './shared';
|
|
11
|
+
export type {
|
|
12
|
+
AnyMeterProps,
|
|
13
|
+
MeterDecorativeProps,
|
|
14
|
+
MeterProps,
|
|
15
|
+
MeterRingProps,
|
|
16
|
+
StatBarProps,
|
|
17
|
+
StatBarProgressProps,
|
|
18
|
+
StatBarSplitProps,
|
|
19
|
+
StatBarVariant,
|
|
20
|
+
} from './types';
|
package/src/stat-bar/types.ts
CHANGED
|
@@ -69,6 +69,10 @@ export type StatBarProps = StatBarProgressProps | StatBarSplitProps;
|
|
|
69
69
|
// ---------------------------------------------------------------------------
|
|
70
70
|
|
|
71
71
|
interface MeterGeometryProps {
|
|
72
|
+
/** Classes on the track. Unclaimed properties retain the normal Meter defaults. */
|
|
73
|
+
className?: string;
|
|
74
|
+
/** Classes on the fill. Width continues to represent value/max. */
|
|
75
|
+
fillClassName?: string;
|
|
72
76
|
/** Current value. Clamped into `[0, max]`; `NaN` reads as empty. */
|
|
73
77
|
value: number;
|
|
74
78
|
/**
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { CSSProperties } from 'react';
|
|
2
|
+
import type { StyleProp, TextStyle, ViewStyle } from 'react-native';
|
|
3
|
+
import { flattenWebStyle } from './flatten-web-style';
|
|
4
|
+
|
|
5
|
+
/** Preserve RN-style overrides when a family moves from RNW hosts to DOM hosts. */
|
|
6
|
+
export function resolveNativeWebStyle(style: StyleProp<ViewStyle | TextStyle>): CSSProperties {
|
|
7
|
+
const input = flattenWebStyle(style) as Record<string, unknown>;
|
|
8
|
+
const output: Record<string, unknown> = { ...input };
|
|
9
|
+
for (const property of ['padding', 'margin'] as const) {
|
|
10
|
+
for (const [axis, sides] of [['Horizontal', ['Left', 'Right']], ['Vertical', ['Top', 'Bottom']]] as const) {
|
|
11
|
+
const key = `${property}${axis}`;
|
|
12
|
+
if (input[key] !== undefined) {
|
|
13
|
+
for (const side of sides) {
|
|
14
|
+
const longhand = `${property}${side}`;
|
|
15
|
+
if (input[longhand] === undefined) output[longhand] = input[key];
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
delete output[key];
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
for (const [native, css] of Object.entries({
|
|
22
|
+
paddingStart: 'paddingInlineStart', paddingEnd: 'paddingInlineEnd',
|
|
23
|
+
marginStart: 'marginInlineStart', marginEnd: 'marginInlineEnd',
|
|
24
|
+
start: 'insetInlineStart', end: 'insetInlineEnd',
|
|
25
|
+
borderStartWidth: 'borderInlineStartWidth', borderEndWidth: 'borderInlineEndWidth',
|
|
26
|
+
borderStartColor: 'borderInlineStartColor', borderEndColor: 'borderInlineEndColor',
|
|
27
|
+
})) {
|
|
28
|
+
if (input[native] !== undefined) output[css] = input[native];
|
|
29
|
+
delete output[native];
|
|
30
|
+
}
|
|
31
|
+
if (typeof input.lineHeight === 'number') output.lineHeight = `${input.lineHeight}px`;
|
|
32
|
+
if (Array.isArray(input.fontVariant)) output.fontVariant = input.fontVariant.join(' ');
|
|
33
|
+
if (Array.isArray(input.transform)) output.transform = input.transform.flatMap(entry =>
|
|
34
|
+
Object.entries(entry).map(([name, value]) => {
|
|
35
|
+
if (name === 'matrix') return `${(value as number[]).length === 6 ? 'matrix' : 'matrix3d'}(${(value as number[]).join(',')})`;
|
|
36
|
+
const unit = typeof value === 'number' && (name.startsWith('translate') || name === 'perspective') ? 'px' : '';
|
|
37
|
+
return `${name}(${value}${unit})`;
|
|
38
|
+
}),
|
|
39
|
+
).join(' ');
|
|
40
|
+
return output as CSSProperties;
|
|
41
|
+
}
|