@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,11 +1,7 @@
|
|
|
1
1
|
import React, {
|
|
2
|
-
createContext,
|
|
3
2
|
memo,
|
|
4
3
|
useCallback,
|
|
5
4
|
useContext,
|
|
6
|
-
useEffect,
|
|
7
|
-
useMemo,
|
|
8
|
-
useRef,
|
|
9
5
|
useState,
|
|
10
6
|
} from 'react';
|
|
11
7
|
import {
|
|
@@ -14,86 +10,37 @@ import {
|
|
|
14
10
|
Pressable,
|
|
15
11
|
Animated,
|
|
16
12
|
type LayoutChangeEvent,
|
|
17
|
-
|
|
13
|
+
StyleSheet,
|
|
14
|
+
type TextStyle,
|
|
18
15
|
} from 'react-native';
|
|
19
16
|
|
|
20
17
|
import { RiArrowDownSLine as ChevronBottomIcon } from '../icons/remix/RiArrowDownSLine';
|
|
21
18
|
import { useTheme } from '../theme/use-theme';
|
|
22
19
|
import { useInteractionState } from '../hooks/use-interaction-state';
|
|
23
|
-
import { DISABLED_OPACITY,
|
|
20
|
+
import { DISABLED_OPACITY, space } from '../styles/tokens';
|
|
24
21
|
import { SUPPORTS_NATIVE_DRIVER } from '../styles/native-driver';
|
|
22
|
+
import { styled } from 'react-native-css';
|
|
23
|
+
import { AccordionContext, AccordionItemContext } from './context';
|
|
24
|
+
import { useAccordionState, useAccordionItem, useAccordionMotion } from './use-accordion';
|
|
25
25
|
import type {
|
|
26
26
|
AccordionProps,
|
|
27
27
|
AccordionItemProps,
|
|
28
28
|
AccordionTriggerProps,
|
|
29
29
|
AccordionContentProps,
|
|
30
|
-
AccordionType,
|
|
31
30
|
} from './types';
|
|
32
31
|
|
|
33
|
-
// ---- Context ----
|
|
34
|
-
|
|
35
|
-
interface AccordionContextValue {
|
|
36
|
-
expandedValues: Set<string>;
|
|
37
|
-
toggle: (value: string) => void;
|
|
38
|
-
type: AccordionType;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const AccordionContext = createContext<AccordionContextValue>({
|
|
42
|
-
expandedValues: new Set(),
|
|
43
|
-
toggle: () => {},
|
|
44
|
-
type: 'single',
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
interface AccordionItemContextValue {
|
|
48
|
-
value: string;
|
|
49
|
-
isExpanded: boolean;
|
|
50
|
-
disabled: boolean;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
const AccordionItemContext = createContext<AccordionItemContextValue>({
|
|
54
|
-
value: '',
|
|
55
|
-
isExpanded: false,
|
|
56
|
-
disabled: false,
|
|
57
|
-
});
|
|
58
|
-
|
|
59
32
|
// ---- Accordion Root ----
|
|
60
33
|
|
|
61
34
|
const AccordionComponent: React.FC<AccordionProps> = ({
|
|
62
35
|
value,
|
|
63
36
|
onValueChange,
|
|
64
37
|
type = 'single',
|
|
38
|
+
transition,
|
|
65
39
|
children,
|
|
66
40
|
style,
|
|
67
41
|
testID,
|
|
68
42
|
}) => {
|
|
69
|
-
const
|
|
70
|
-
if (value == null) return new Set<string>();
|
|
71
|
-
if (Array.isArray(value)) return new Set(value);
|
|
72
|
-
return new Set([value]);
|
|
73
|
-
}, [value]);
|
|
74
|
-
|
|
75
|
-
const toggle = useCallback(
|
|
76
|
-
(itemValue: string) => {
|
|
77
|
-
if (type === 'single') {
|
|
78
|
-
const next = expandedValues.has(itemValue) ? undefined : itemValue;
|
|
79
|
-
onValueChange(next);
|
|
80
|
-
} else {
|
|
81
|
-
const next = new Set(expandedValues);
|
|
82
|
-
if (next.has(itemValue)) {
|
|
83
|
-
next.delete(itemValue);
|
|
84
|
-
} else {
|
|
85
|
-
next.add(itemValue);
|
|
86
|
-
}
|
|
87
|
-
onValueChange(Array.from(next));
|
|
88
|
-
}
|
|
89
|
-
},
|
|
90
|
-
[type, expandedValues, onValueChange],
|
|
91
|
-
);
|
|
92
|
-
|
|
93
|
-
const contextValue = useMemo(
|
|
94
|
-
() => ({ expandedValues, toggle, type }),
|
|
95
|
-
[expandedValues, toggle, type],
|
|
96
|
-
);
|
|
43
|
+
const contextValue = useAccordionState({ value, onValueChange, type, transition, children });
|
|
97
44
|
|
|
98
45
|
return (
|
|
99
46
|
<AccordionContext.Provider value={contextValue}>
|
|
@@ -112,15 +59,9 @@ const AccordionItemComponent: React.FC<AccordionItemProps> = ({
|
|
|
112
59
|
disabled = false,
|
|
113
60
|
style,
|
|
114
61
|
}) => {
|
|
115
|
-
const
|
|
116
|
-
const isExpanded = expandedValues.has(value);
|
|
62
|
+
const itemContext = useAccordionItem(value, disabled);
|
|
117
63
|
const theme = useTheme();
|
|
118
64
|
|
|
119
|
-
const itemContext = useMemo(
|
|
120
|
-
() => ({ value, isExpanded, disabled }),
|
|
121
|
-
[value, isExpanded, disabled],
|
|
122
|
-
);
|
|
123
|
-
|
|
124
65
|
return (
|
|
125
66
|
<AccordionItemContext.Provider value={itemContext}>
|
|
126
67
|
<View
|
|
@@ -151,22 +92,19 @@ const AccordionTriggerComponent: React.FC<AccordionTriggerProps> = ({
|
|
|
151
92
|
}) => {
|
|
152
93
|
const theme = useTheme();
|
|
153
94
|
const { toggle } = useContext(AccordionContext);
|
|
154
|
-
const { value, isExpanded, disabled } = useContext(AccordionItemContext);
|
|
155
|
-
const rotateAnim =
|
|
95
|
+
const { value, isExpanded, disabled, triggerId, contentId } = useContext(AccordionItemContext);
|
|
96
|
+
const rotateAnim = useAccordionMotion(isExpanded, 'trigger', SUPPORTS_NATIVE_DRIVER);
|
|
97
|
+
const resolved = StyleSheet.flatten(style) as TextStyle | undefined;
|
|
98
|
+
const callerText: TextStyle = {};
|
|
99
|
+
for (const key of ['color', 'fontSize', 'fontWeight', 'fontFamily', 'lineHeight', 'letterSpacing'] as const) {
|
|
100
|
+
if (resolved?.[key] !== undefined) Object.assign(callerText, { [key]: resolved[key] });
|
|
101
|
+
}
|
|
156
102
|
// Drive press-opacity via state, not Pressable's function-form `style`,
|
|
157
103
|
// which NativeWind v4's css-interop swallows (dropping the trigger's base
|
|
158
104
|
// layout: flexDirection, padding, gap).
|
|
159
105
|
const { state: pressed, onIn: onPressIn, onOut: onPressOut } =
|
|
160
106
|
useInteractionState();
|
|
161
107
|
|
|
162
|
-
useEffect(() => {
|
|
163
|
-
Animated.spring(rotateAnim, {
|
|
164
|
-
toValue: isExpanded ? 1 : 0,
|
|
165
|
-
useNativeDriver: SUPPORTS_NATIVE_DRIVER,
|
|
166
|
-
...animation.spring.snappy,
|
|
167
|
-
}).start();
|
|
168
|
-
}, [isExpanded, rotateAnim]);
|
|
169
|
-
|
|
170
108
|
const handlePress = useCallback(() => {
|
|
171
109
|
if (!disabled) {
|
|
172
110
|
toggle(value);
|
|
@@ -180,6 +118,8 @@ const AccordionTriggerComponent: React.FC<AccordionTriggerProps> = ({
|
|
|
180
118
|
|
|
181
119
|
return (
|
|
182
120
|
<Pressable
|
|
121
|
+
nativeID={triggerId}
|
|
122
|
+
{...{ 'aria-controls': contentId }}
|
|
183
123
|
style={[
|
|
184
124
|
{
|
|
185
125
|
flexDirection: 'row',
|
|
@@ -217,6 +157,7 @@ const AccordionTriggerComponent: React.FC<AccordionTriggerProps> = ({
|
|
|
217
157
|
fontWeight: '600',
|
|
218
158
|
color: theme.colors.text,
|
|
219
159
|
},
|
|
160
|
+
callerText,
|
|
220
161
|
textStyle,
|
|
221
162
|
]}
|
|
222
163
|
>
|
|
@@ -235,12 +176,13 @@ const AccordionTriggerComponent: React.FC<AccordionTriggerProps> = ({
|
|
|
235
176
|
|
|
236
177
|
// ---- Accordion Content ----
|
|
237
178
|
|
|
238
|
-
const AccordionContentComponent: React.FC<AccordionContentProps> = ({
|
|
179
|
+
const AccordionContentComponent: React.FC<AccordionContentProps & { contentStyle?: AccordionContentProps['style'] }> = ({
|
|
239
180
|
children,
|
|
240
181
|
style,
|
|
182
|
+
contentStyle,
|
|
241
183
|
}) => {
|
|
242
|
-
const { isExpanded } = useContext(AccordionItemContext);
|
|
243
|
-
const heightAnim =
|
|
184
|
+
const { isExpanded, contentId, triggerId } = useContext(AccordionItemContext);
|
|
185
|
+
const heightAnim = useAccordionMotion(isExpanded, 'content', false);
|
|
244
186
|
// The content's own height, measured. The reveal used to interpolate to a
|
|
245
187
|
// hardcoded 500 ("reasonable max"), which is not a max at all: `overflow:
|
|
246
188
|
// hidden` above it meant anything taller was CLIPPED, silently, with no error
|
|
@@ -254,14 +196,6 @@ const AccordionContentComponent: React.FC<AccordionContentProps> = ({
|
|
|
254
196
|
setContentHeight((prev) => (Math.abs(prev - next) > 0.5 ? next : prev));
|
|
255
197
|
}, []);
|
|
256
198
|
|
|
257
|
-
useEffect(() => {
|
|
258
|
-
Animated.spring(heightAnim, {
|
|
259
|
-
toValue: isExpanded ? 1 : 0,
|
|
260
|
-
useNativeDriver: false,
|
|
261
|
-
...animation.spring.gentle,
|
|
262
|
-
}).start();
|
|
263
|
-
}, [isExpanded, heightAnim]);
|
|
264
|
-
|
|
265
199
|
const opacity = heightAnim.interpolate({
|
|
266
200
|
inputRange: [0, 1],
|
|
267
201
|
outputRange: [0, 1],
|
|
@@ -274,6 +208,12 @@ const AccordionContentComponent: React.FC<AccordionContentProps> = ({
|
|
|
274
208
|
|
|
275
209
|
return (
|
|
276
210
|
<Animated.View
|
|
211
|
+
nativeID={contentId}
|
|
212
|
+
{...{ 'aria-labelledby': triggerId }}
|
|
213
|
+
aria-hidden={!isExpanded}
|
|
214
|
+
pointerEvents={isExpanded ? 'auto' : 'none'}
|
|
215
|
+
accessibilityElementsHidden={!isExpanded}
|
|
216
|
+
importantForAccessibility={isExpanded ? 'auto' : 'no-hide-descendants'}
|
|
277
217
|
style={[
|
|
278
218
|
{
|
|
279
219
|
overflow: 'hidden',
|
|
@@ -289,7 +229,7 @@ const AccordionContentComponent: React.FC<AccordionContentProps> = ({
|
|
|
289
229
|
>
|
|
290
230
|
<View
|
|
291
231
|
onLayout={handleContentLayout}
|
|
292
|
-
style={{ paddingBottom: space.md,
|
|
232
|
+
style={[{ paddingBottom: space.md, paddingLeft: space.xs, paddingRight: space.xs }, contentStyle]}
|
|
293
233
|
>
|
|
294
234
|
{children}
|
|
295
235
|
</View>
|
|
@@ -297,14 +237,14 @@ const AccordionContentComponent: React.FC<AccordionContentProps> = ({
|
|
|
297
237
|
);
|
|
298
238
|
};
|
|
299
239
|
|
|
300
|
-
export const Accordion = memo(AccordionComponent);
|
|
240
|
+
export const Accordion = memo(styled(AccordionComponent, { className: 'style' }));
|
|
301
241
|
Accordion.displayName = 'Accordion';
|
|
302
242
|
|
|
303
|
-
export const AccordionItem = memo(AccordionItemComponent);
|
|
243
|
+
export const AccordionItem = memo(styled(AccordionItemComponent, { className: 'style' }));
|
|
304
244
|
AccordionItem.displayName = 'AccordionItem';
|
|
305
245
|
|
|
306
|
-
export const AccordionTrigger = memo(AccordionTriggerComponent);
|
|
246
|
+
export const AccordionTrigger = memo(styled(AccordionTriggerComponent, { className: 'style' }));
|
|
307
247
|
AccordionTrigger.displayName = 'AccordionTrigger';
|
|
308
248
|
|
|
309
|
-
export const AccordionContent = memo(AccordionContentComponent);
|
|
249
|
+
export const AccordionContent = memo(styled(AccordionContentComponent, { className: 'style', contentClassName: 'contentStyle' }));
|
|
310
250
|
AccordionContent.displayName = 'AccordionContent';
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import React, { forwardRef, memo, useContext, useLayoutEffect, useRef, useState } from 'react';
|
|
2
|
+
import { Animated, type StyleProp, type ViewStyle } from 'react-native';
|
|
3
|
+
import { RiArrowDownSLine } from '../icons/remix/RiArrowDownSLine';
|
|
4
|
+
import { resolveNativeWebStyle } from '../styles/resolve-native-web-style';
|
|
5
|
+
import { useInteractiveWebCss } from '../styles/interactive-web-css';
|
|
6
|
+
import { useTheme } from '../theme/use-theme';
|
|
7
|
+
import { AccordionContext, AccordionItemContext } from './context';
|
|
8
|
+
import { useAccordionState, useAccordionItem, useAccordionMotion } from './use-accordion';
|
|
9
|
+
import type { AccordionProps, AccordionItemProps, AccordionTriggerProps, AccordionContentProps } from './types';
|
|
10
|
+
|
|
11
|
+
const CSS = `@layer base {
|
|
12
|
+
.bloom-accordion-root,.bloom-accordion-item,.bloom-accordion-panel,.bloom-accordion-body { box-sizing:border-box; display:flex; flex-direction:column; flex-shrink:0; min-width:0; }
|
|
13
|
+
.bloom-accordion-item { border:0 solid var(--bloom-accordion-border); border-bottom-width:1px; }
|
|
14
|
+
.bloom-accordion-trigger { box-sizing:border-box; flex-shrink:0; min-width:0; display:flex; align-items:center; gap:8px; padding:12px 4px; border:0; margin:0; background:transparent; color:var(--bloom-accordion-text); text-align:start; font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif; line-height:normal; font-size:15px; font-weight:600; cursor:pointer; }
|
|
15
|
+
.bloom-accordion-trigger:active:not(:disabled) { opacity:.7; }
|
|
16
|
+
.bloom-accordion-trigger:disabled { opacity:.5; cursor:default; }
|
|
17
|
+
.bloom-accordion-label { white-space:pre-wrap; overflow-wrap:break-word; flex-grow:1; flex-shrink:1; min-width:0; }
|
|
18
|
+
.bloom-accordion-panel { overflow:hidden; }
|
|
19
|
+
.bloom-accordion-body { padding:0 4px 12px; }
|
|
20
|
+
}`;
|
|
21
|
+
function useStyles() { useInteractiveWebCss('bloom-accordion', CSS); }
|
|
22
|
+
|
|
23
|
+
/** RN Animated resolves numeric layout/opacity before this DOM host receives them. */
|
|
24
|
+
const PanelHost = forwardRef<HTMLDivElement, Omit<React.HTMLAttributes<HTMLDivElement>, 'style'> & { style?: StyleProp<ViewStyle> }>(function PanelHost({ style, ...props }, ref) {
|
|
25
|
+
return <div {...props} ref={ref} style={resolveNativeWebStyle(style)} />;
|
|
26
|
+
});
|
|
27
|
+
const AnimatedPanel = Animated.createAnimatedComponent(PanelHost);
|
|
28
|
+
|
|
29
|
+
export const Accordion = memo(function Accordion(props: AccordionProps) {
|
|
30
|
+
useStyles();
|
|
31
|
+
const state = useAccordionState(props);
|
|
32
|
+
return <AccordionContext.Provider value={state}>
|
|
33
|
+
<div className={['bloom-accordion-root', props.className].filter(Boolean).join(' ')} style={resolveNativeWebStyle(props.style)} data-testid={props.testID}>{props.children}</div>
|
|
34
|
+
</AccordionContext.Provider>;
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
export const AccordionItem = memo(function AccordionItem({ value, disabled = false, children, style, className }: AccordionItemProps) {
|
|
38
|
+
useStyles();
|
|
39
|
+
const state = useAccordionItem(value, disabled);
|
|
40
|
+
const theme = useTheme();
|
|
41
|
+
const vars = { '--bloom-accordion-border': theme.colors.borderLight } as React.CSSProperties;
|
|
42
|
+
return <AccordionItemContext.Provider value={state}>
|
|
43
|
+
<div className={['bloom-accordion-item', className].filter(Boolean).join(' ')} style={{ ...vars, ...resolveNativeWebStyle(style) }}>{children}</div>
|
|
44
|
+
</AccordionItemContext.Provider>;
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
export const AccordionTrigger = memo(function AccordionTrigger({ children, icon, style, textStyle, className }: AccordionTriggerProps) {
|
|
48
|
+
useStyles();
|
|
49
|
+
const theme = useTheme();
|
|
50
|
+
const { toggle } = useContext(AccordionContext);
|
|
51
|
+
const { value, isExpanded, disabled, triggerId, contentId } = useContext(AccordionItemContext);
|
|
52
|
+
const progress = useAccordionMotion(isExpanded, 'trigger', false);
|
|
53
|
+
const rotation = progress.interpolate({ inputRange: [0, 1], outputRange: ['0deg', '180deg'] });
|
|
54
|
+
const vars = { '--bloom-accordion-text': theme.colors.text } as React.CSSProperties;
|
|
55
|
+
return <button type="button" id={triggerId} aria-expanded={isExpanded} aria-controls={contentId} disabled={disabled}
|
|
56
|
+
className={['bloom-accordion-trigger', className].filter(Boolean).join(' ')} style={{ ...vars, ...resolveNativeWebStyle(style) }}
|
|
57
|
+
onClick={() => toggle(value)}>
|
|
58
|
+
{icon}
|
|
59
|
+
<span className="bloom-accordion-label" data-testid="accordion-trigger-label" style={resolveNativeWebStyle(textStyle)}>{children}</span>
|
|
60
|
+
<Animated.View aria-hidden style={{ transform: [{ rotate: rotation }] }}><RiArrowDownSLine size="sm" fill={theme.colors.textSecondary} /></Animated.View>
|
|
61
|
+
</button>;
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
export const AccordionContent = memo(function AccordionContent({ children, style, className, contentClassName }: AccordionContentProps) {
|
|
65
|
+
useStyles();
|
|
66
|
+
const { isExpanded, triggerId, contentId } = useContext(AccordionItemContext);
|
|
67
|
+
const progress = useAccordionMotion(isExpanded, 'content', false);
|
|
68
|
+
const body = useRef<HTMLDivElement>(null);
|
|
69
|
+
const panel = useRef<HTMLDivElement>(null);
|
|
70
|
+
const [height, setHeight] = useState(0);
|
|
71
|
+
useLayoutEffect(() => {
|
|
72
|
+
const node = body.current;
|
|
73
|
+
if (!node) return;
|
|
74
|
+
const measure = () => {
|
|
75
|
+
const next = node.getBoundingClientRect().height;
|
|
76
|
+
setHeight(previous => Math.abs(previous - next) > .5 ? next : previous);
|
|
77
|
+
};
|
|
78
|
+
measure();
|
|
79
|
+
const observer = new ResizeObserver(measure); observer.observe(node);
|
|
80
|
+
return () => observer.disconnect();
|
|
81
|
+
}, []);
|
|
82
|
+
useLayoutEffect(() => {
|
|
83
|
+
if (!isExpanded && panel.current?.contains(document.activeElement)) document.getElementById(triggerId)?.focus();
|
|
84
|
+
}, [isExpanded, triggerId]);
|
|
85
|
+
const maxHeight = progress.interpolate({ inputRange: [0, 1], outputRange: [0, height] });
|
|
86
|
+
return <AnimatedPanel ref={panel} id={contentId} role="region" aria-labelledby={triggerId} aria-hidden={!isExpanded} inert={!isExpanded}
|
|
87
|
+
className={['bloom-accordion-panel', className].filter(Boolean).join(' ')}
|
|
88
|
+
style={[{ opacity: progress, maxHeight: height === 0 && isExpanded ? undefined : maxHeight }, style]}>
|
|
89
|
+
<div ref={body} className={['bloom-accordion-body', contentClassName].filter(Boolean).join(' ')}>{children}</div>
|
|
90
|
+
</AnimatedPanel>;
|
|
91
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { createContext } from 'react';
|
|
2
|
+
import type { AccordionTransition, AccordionType } from './types';
|
|
3
|
+
|
|
4
|
+
export interface AccordionContextValue {
|
|
5
|
+
expandedValues: Set<string>;
|
|
6
|
+
toggle: (value: string) => void;
|
|
7
|
+
type: AccordionType;
|
|
8
|
+
transition: AccordionTransition;
|
|
9
|
+
}
|
|
10
|
+
export const AccordionContext = createContext<AccordionContextValue>({
|
|
11
|
+
expandedValues: new Set(), toggle: () => {}, type: 'single', transition: 'spring',
|
|
12
|
+
});
|
|
13
|
+
export const AccordionItemContext = createContext({
|
|
14
|
+
value: '', isExpanded: false, disabled: false, triggerId: '', contentId: '',
|
|
15
|
+
});
|
package/src/accordion/index.ts
CHANGED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// AUTO-GENERATED by scripts/generate-platform-exports.mjs — DO NOT EDIT.
|
|
2
|
+
// Source of truth: src/accordion/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 { Accordion, AccordionItem, AccordionTrigger, AccordionContent } from './Accordion.web';
|
|
7
|
+
export type {
|
|
8
|
+
AccordionProps,
|
|
9
|
+
AccordionItemProps,
|
|
10
|
+
AccordionTriggerProps,
|
|
11
|
+
AccordionContentProps,
|
|
12
|
+
AccordionType,
|
|
13
|
+
AccordionTransition,
|
|
14
|
+
} from './types';
|
package/src/accordion/types.ts
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import type { StyleProp, ViewStyle, TextStyle } from 'react-native';
|
|
2
2
|
|
|
3
3
|
export type AccordionType = 'single' | 'multiple';
|
|
4
|
+
/** Preserve the default springs, or opt into a shared timed reveal/chevron curve. */
|
|
5
|
+
export type AccordionTransition = 'spring' | {
|
|
6
|
+
/** Non-negative duration in milliseconds. Zero settles immediately. */
|
|
7
|
+
duration: number;
|
|
8
|
+
/** CSS cubic-bezier control points; x coordinates must be in 0..1. Default ease. */
|
|
9
|
+
easing?: readonly [number, number, number, number];
|
|
10
|
+
};
|
|
4
11
|
|
|
5
12
|
export interface AccordionProps {
|
|
6
13
|
/** Controls which items are expanded. For 'single' type, pass a string or undefined.
|
|
@@ -10,8 +17,11 @@ export interface AccordionProps {
|
|
|
10
17
|
onValueChange: (value: string | string[] | undefined) => void;
|
|
11
18
|
/** Whether only one item can be expanded at a time. */
|
|
12
19
|
type?: AccordionType;
|
|
20
|
+
/** OS reduced motion always settles immediately, including live changes. */
|
|
21
|
+
transition?: AccordionTransition;
|
|
13
22
|
/** Accordion items. */
|
|
14
23
|
children: React.ReactNode;
|
|
24
|
+
className?: string;
|
|
15
25
|
style?: StyleProp<ViewStyle>;
|
|
16
26
|
testID?: string;
|
|
17
27
|
}
|
|
@@ -23,6 +33,7 @@ export interface AccordionItemProps {
|
|
|
23
33
|
children: React.ReactNode;
|
|
24
34
|
/** Whether this item is disabled. */
|
|
25
35
|
disabled?: boolean;
|
|
36
|
+
className?: string;
|
|
26
37
|
style?: StyleProp<ViewStyle>;
|
|
27
38
|
}
|
|
28
39
|
|
|
@@ -31,12 +42,16 @@ export interface AccordionTriggerProps {
|
|
|
31
42
|
children: React.ReactNode;
|
|
32
43
|
/** Icon to show on the left side. */
|
|
33
44
|
icon?: React.ReactNode;
|
|
45
|
+
className?: string;
|
|
34
46
|
style?: StyleProp<ViewStyle>;
|
|
35
47
|
textStyle?: StyleProp<TextStyle>;
|
|
36
48
|
}
|
|
37
49
|
|
|
38
50
|
export interface AccordionContentProps {
|
|
51
|
+
/** Classes for the measured body, including its default content padding. */
|
|
52
|
+
contentClassName?: string;
|
|
39
53
|
/** Content to show when expanded. */
|
|
40
54
|
children: React.ReactNode;
|
|
55
|
+
className?: string;
|
|
41
56
|
style?: StyleProp<ViewStyle>;
|
|
42
57
|
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { useCallback, useContext, useLayoutEffect, useId, useMemo, useRef } from 'react';
|
|
2
|
+
import { Animated, Easing } from 'react-native';
|
|
3
|
+
import { usePrefersReducedMotion } from '../hooks/use-prefers-reduced-motion';
|
|
4
|
+
import { animation } from '../styles/tokens';
|
|
5
|
+
import { AccordionContext } from './context';
|
|
6
|
+
import type { AccordionProps } from './types';
|
|
7
|
+
|
|
8
|
+
export function useAccordionState({ value, onValueChange, type = 'single', transition = 'spring' }: AccordionProps) {
|
|
9
|
+
const expandedValues = useMemo(() => new Set(value == null ? [] : Array.isArray(value) ? value : [value]), [value]);
|
|
10
|
+
const toggle = useCallback((item: string) => {
|
|
11
|
+
if (type === 'single') onValueChange(expandedValues.has(item) ? undefined : item);
|
|
12
|
+
else {
|
|
13
|
+
const next = new Set(expandedValues);
|
|
14
|
+
if (next.has(item)) next.delete(item); else next.add(item);
|
|
15
|
+
onValueChange([...next]);
|
|
16
|
+
}
|
|
17
|
+
}, [expandedValues, onValueChange, type]);
|
|
18
|
+
return useMemo(() => ({ expandedValues, toggle, type, transition }), [expandedValues, toggle, type, transition]);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function useAccordionItem(value: string, disabled: boolean) {
|
|
22
|
+
const { expandedValues } = useContext(AccordionContext);
|
|
23
|
+
const id = useId();
|
|
24
|
+
const isExpanded = expandedValues.has(value);
|
|
25
|
+
return useMemo(() => ({ value, disabled, isExpanded, triggerId: `${id}-trigger`, contentId: `${id}-content` }), [value, disabled, isExpanded, id]);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** One motion policy for both forks, including a live OS preference change. */
|
|
29
|
+
export function useAccordionMotion(expanded: boolean, kind: 'trigger' | 'content', useNativeDriver: boolean) {
|
|
30
|
+
const { transition } = useContext(AccordionContext);
|
|
31
|
+
const reduced = usePrefersReducedMotion();
|
|
32
|
+
const progress = useRef(new Animated.Value(expanded ? 1 : 0)).current;
|
|
33
|
+
const duration = transition === 'spring' ? undefined : transition.duration;
|
|
34
|
+
const [x1, y1, x2, y2] = transition === 'spring' || !transition.easing ? [.25, .1, .25, 1] : transition.easing;
|
|
35
|
+
const easing = useMemo(() => Easing.bezier(x1, y1, x2, y2), [x1, y1, x2, y2]);
|
|
36
|
+
useLayoutEffect(() => {
|
|
37
|
+
progress.stopAnimation();
|
|
38
|
+
const toValue = expanded ? 1 : 0;
|
|
39
|
+
if (reduced || duration === 0) { progress.setValue(toValue); return; }
|
|
40
|
+
const motion = duration === undefined
|
|
41
|
+
? Animated.spring(progress, { toValue, useNativeDriver, ...animation.spring[kind === 'trigger' ? 'snappy' : 'gentle'] })
|
|
42
|
+
: Animated.timing(progress, { toValue, useNativeDriver, duration: Math.max(0, duration), easing });
|
|
43
|
+
motion.start();
|
|
44
|
+
return () => motion.stop();
|
|
45
|
+
}, [expanded, progress, reduced, duration, easing, kind, useNativeDriver]);
|
|
46
|
+
return progress;
|
|
47
|
+
}
|
package/src/dialog/Dialog.tsx
CHANGED
|
@@ -304,6 +304,7 @@ function CenteredOrSideDialog({
|
|
|
304
304
|
<SideSheet
|
|
305
305
|
presentation={presentation}
|
|
306
306
|
exitDuration={exitDuration}
|
|
307
|
+
scrollable={scrollableResolved}
|
|
307
308
|
open={sideOpen}
|
|
308
309
|
onDismiss={handleDismiss}
|
|
309
310
|
side={placement}
|
|
@@ -341,7 +342,8 @@ function CenteredOrSideDialog({
|
|
|
341
342
|
// Nav-header mode hides the drag handle (the nav bar sits at the very top)
|
|
342
343
|
// and coordinates the body pan with the scroll so content scrolls.
|
|
343
344
|
showHandle={!header}
|
|
344
|
-
|
|
345
|
+
scrollable={scrollableResolved}
|
|
346
|
+
manualActivation={!!header && scrollableResolved}
|
|
345
347
|
scrollY={header ? headerController.scrollY : undefined}
|
|
346
348
|
headerOverlay={
|
|
347
349
|
header ? (
|
|
@@ -374,6 +376,7 @@ function CenteredOrSideDialog({
|
|
|
374
376
|
// Nav-header mode: the large title + screens own their padding.
|
|
375
377
|
header ? null : { padding: contentPadding },
|
|
376
378
|
{ backgroundColor: 'transparent' },
|
|
379
|
+
scrollableResolved ? null : { flex: 1, minHeight: 0 },
|
|
377
380
|
style,
|
|
378
381
|
panelStyle,
|
|
379
382
|
]}
|
|
@@ -381,7 +384,7 @@ function CenteredOrSideDialog({
|
|
|
381
384
|
{/* The morph layer is its own node INSIDE the class-name'd container:
|
|
382
385
|
a className'd component's `onLayout` never fires on web, and this
|
|
383
386
|
one has to measure the incoming frame. */}
|
|
384
|
-
<DialogMorphContent morph={morphState}>
|
|
387
|
+
<DialogMorphContent morph={morphState} style={scrollableResolved ? undefined : { flex: 1, minHeight: 0 }}>
|
|
385
388
|
{header ? headerBody : bodyNode}
|
|
386
389
|
</DialogMorphContent>
|
|
387
390
|
</StyledView>
|
|
@@ -399,6 +402,7 @@ function CenteredOrSideDialog({
|
|
|
399
402
|
* exit animations are safe (the web `removeChild` crash does not apply).
|
|
400
403
|
*/
|
|
401
404
|
function SideSheet({
|
|
405
|
+
scrollable,
|
|
402
406
|
presentation,
|
|
403
407
|
exitDuration,
|
|
404
408
|
open,
|
|
@@ -424,6 +428,7 @@ function SideSheet({
|
|
|
424
428
|
style,
|
|
425
429
|
children,
|
|
426
430
|
}: {
|
|
431
|
+
scrollable: boolean;
|
|
427
432
|
presentation?: DialogProps['presentation'];
|
|
428
433
|
exitDuration?: number;
|
|
429
434
|
open: boolean;
|
|
@@ -608,7 +613,7 @@ function SideSheet({
|
|
|
608
613
|
<DialogHeaderProvider controller={headerController}>{surfaceChildren}</DialogHeaderProvider>
|
|
609
614
|
</View>
|
|
610
615
|
) : (
|
|
611
|
-
<View style={{ padding: contentPadding, flex: presentation === 'custom' ? 1 : undefined, minHeight: 0, borderRadius: panelRadius, overflow: presentation === 'custom' ? 'visible' : 'hidden' }}>{surfaceChildren}</View>
|
|
616
|
+
<View style={{ padding: contentPadding, flex: presentation === 'custom' || !scrollable ? 1 : undefined, minHeight: 0, borderRadius: panelRadius, overflow: presentation === 'custom' ? 'visible' : 'hidden' }}>{surfaceChildren}</View>
|
|
612
617
|
)}
|
|
613
618
|
</SurfaceLevelProvider>
|
|
614
619
|
</AnimatedStyledView>
|
|
@@ -825,31 +825,47 @@ function SheetSurface({
|
|
|
825
825
|
onDismiss={onDismiss}
|
|
826
826
|
collapse={false}
|
|
827
827
|
/>
|
|
828
|
-
|
|
829
|
-
style={{
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
828
|
+
{scrollable === false ? (
|
|
829
|
+
<View style={{ flex: 1, minHeight: 0, paddingBottom: contentPadding }}>
|
|
830
|
+
<DialogNavBarSpacer controller={headerController} header={header} />
|
|
831
|
+
<DialogHeaderProvider controller={headerController}>
|
|
832
|
+
<DialogBody
|
|
833
|
+
titleId={titleId}
|
|
834
|
+
descriptionId={descriptionId}
|
|
835
|
+
title={title}
|
|
836
|
+
description={description}
|
|
837
|
+
actions={actions}
|
|
838
|
+
>
|
|
839
|
+
{surfaceChildren}
|
|
840
|
+
</DialogBody>
|
|
841
|
+
</DialogHeaderProvider>
|
|
842
|
+
</View>
|
|
843
|
+
) : (
|
|
844
|
+
<ScrollView
|
|
845
|
+
style={{ flexShrink: 1 }}
|
|
846
|
+
contentContainerStyle={{ paddingTop: DIALOG_NAV_BAR_HEIGHT, paddingBottom: contentPadding }}
|
|
847
|
+
showsVerticalScrollIndicator={false}
|
|
848
|
+
scrollEventThrottle={16}
|
|
849
|
+
onScroll={(e) => {
|
|
850
|
+
headerController.scrollY.value = e.nativeEvent.contentOffset.y;
|
|
851
|
+
}}
|
|
852
|
+
>
|
|
853
|
+
<DialogHeaderProvider controller={headerController}>
|
|
854
|
+
<DialogBody
|
|
855
|
+
titleId={titleId}
|
|
856
|
+
descriptionId={descriptionId}
|
|
857
|
+
title={title}
|
|
858
|
+
description={description}
|
|
859
|
+
actions={actions}
|
|
860
|
+
>
|
|
861
|
+
{surfaceChildren}
|
|
862
|
+
</DialogBody>
|
|
863
|
+
</DialogHeaderProvider>
|
|
864
|
+
</ScrollView>
|
|
865
|
+
)}
|
|
850
866
|
</View>
|
|
851
867
|
) : (
|
|
852
|
-
<View style={{ padding: contentPadding }}>
|
|
868
|
+
<View style={[{ padding: contentPadding }, scrollable === false && { flex: 1, minHeight: 0 }]}>
|
|
853
869
|
<DialogBody
|
|
854
870
|
titleId={titleId}
|
|
855
871
|
descriptionId={descriptionId}
|
|
@@ -552,10 +552,10 @@ export type DialogMorph = ReturnType<typeof useDialogMorph>;
|
|
|
552
552
|
* declare swaps via {@link useDialogFrame}), measures the content's natural
|
|
553
553
|
* height, and carries the incoming-frame fade.
|
|
554
554
|
*
|
|
555
|
-
*
|
|
556
|
-
* growing
|
|
557
|
-
*
|
|
558
|
-
*
|
|
555
|
+
* With natural-height measurement enabled, render inside the surface's scroll
|
|
556
|
+
* content without a growing style: the incoming frame must report its own
|
|
557
|
+
* height while the panel is pinned at the outgoing one. A surface whose child
|
|
558
|
+
* owns scrolling disables measurement and passes a bounded flex style instead.
|
|
559
559
|
*/
|
|
560
560
|
export function DialogMorphContent({
|
|
561
561
|
morph,
|
package/src/index.web.ts
CHANGED
|
@@ -339,7 +339,7 @@ export type { BottomSheetRef, BottomSheetProps } from './bottom-sheet/index.web'
|
|
|
339
339
|
// Data display
|
|
340
340
|
export * from './card';
|
|
341
341
|
export * from './badge';
|
|
342
|
-
export { Rating, RatingBar, RatingInput } from './rating';
|
|
342
|
+
export { Rating, RatingBar, RatingInput } from './rating/index.web';
|
|
343
343
|
export type {
|
|
344
344
|
RatingBarProps,
|
|
345
345
|
RatingCountStyle,
|
|
@@ -347,7 +347,7 @@ export type {
|
|
|
347
347
|
RatingInputSize,
|
|
348
348
|
RatingProps,
|
|
349
349
|
RatingSize,
|
|
350
|
-
} from './rating';
|
|
350
|
+
} from './rating/index.web';
|
|
351
351
|
export {
|
|
352
352
|
ExplicitBadge,
|
|
353
353
|
formatDuration,
|
|
@@ -1974,14 +1974,14 @@ export * from './aspect-ratio';
|
|
|
1974
1974
|
export * from './tabs';
|
|
1975
1975
|
export * from './checkbox';
|
|
1976
1976
|
export * from './radio';
|
|
1977
|
-
export * from './accordion';
|
|
1977
|
+
export * from './accordion/index.web';
|
|
1978
1978
|
export { LinkPreviewCard } from './link-preview';
|
|
1979
1979
|
export type { LinkPreviewCardProps } from './link-preview';
|
|
1980
1980
|
|
|
1981
1981
|
// Stat / profile widgets
|
|
1982
1982
|
export { CompositionBar } from './composition-bar';
|
|
1983
1983
|
export type { CompositionBarProps, CompositionCategory } from './composition-bar';
|
|
1984
|
-
export { Meter, MeterRing, StatBar, meterFraction, meterValue, resolveMeterColors } from './stat-bar';
|
|
1984
|
+
export { Meter, MeterRing, StatBar, meterFraction, meterValue, resolveMeterColors } from './stat-bar/index.web';
|
|
1985
1985
|
export type {
|
|
1986
1986
|
AnyMeterProps,
|
|
1987
1987
|
MeterColors,
|
|
@@ -1992,7 +1992,7 @@ export type {
|
|
|
1992
1992
|
StatBarProgressProps,
|
|
1993
1993
|
StatBarSplitProps,
|
|
1994
1994
|
StatBarVariant,
|
|
1995
|
-
} from './stat-bar';
|
|
1995
|
+
} from './stat-bar/index.web';
|
|
1996
1996
|
export { ActivityHeatmap, bucketByDay } from './activity-heatmap';
|
|
1997
1997
|
export type { ActivityHeatmapProps, ActivityHeatmapDay } from './activity-heatmap';
|
|
1998
1998
|
|