@webority/mobile-ui 0.174.1 → 0.175.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/dist/canvas-kit/kit.js +10 -10
- package/dist/canvas-kit/manifest.json +1 -1
- package/dist/canvas-kit/release.json +5 -5
- package/lib/commonjs/components/Accordion/Accordion.js +1 -1
- package/lib/commonjs/components/AmountSlider/AmountSlider.js +1 -1
- package/lib/commonjs/components/AppBar/AppBar.js +1 -1
- package/lib/commonjs/components/AuthedImage/authedImageCache.js +1 -1
- package/lib/commonjs/components/Avatar/Avatar.js +1 -1
- package/lib/commonjs/components/Badge/Badge.js +1 -1
- package/lib/commonjs/components/Banner/Banner.js +1 -1
- package/lib/commonjs/components/BarChart/BarChart.js +1 -1
- package/lib/commonjs/components/BottomNavigation/BottomNavigation.js +1 -1
- package/lib/commonjs/components/BottomSheet/BottomSheet.js +1 -1
- package/lib/commonjs/components/Box/Box.js +1 -1
- package/lib/commonjs/components/Button/Button.js +1 -1
- package/lib/commonjs/components/Calendar/Calendar.js +1 -1
- package/lib/commonjs/components/Card/Card.js +1 -1
- package/lib/commonjs/components/Carousel/Carousel.js +1 -1
- package/lib/commonjs/components/Checkbox/Checkbox.js +1 -1
- package/lib/commonjs/components/Chip/Chip.js +1 -1
- package/lib/commonjs/components/Composer/Composer.js +1 -1
- package/lib/commonjs/components/Confetti/Confetti.js +1 -1
- package/lib/commonjs/components/DateRangePicker/DateRangePicker.js +1 -1
- package/lib/commonjs/components/DecimalInput/DecimalInput.js +1 -1
- package/lib/commonjs/components/Descriptions/Descriptions.js +1 -1
- package/lib/commonjs/components/Divider/Divider.js +1 -1
- package/lib/commonjs/components/Drawer/Drawer.js +1 -1
- package/lib/commonjs/components/EmptyState/EmptyState.js +1 -1
- package/lib/commonjs/components/FieldBase/ChoiceText.js +1 -1
- package/lib/commonjs/components/FieldBase/FieldBase.js +1 -1
- package/lib/commonjs/components/FieldBase/useFloatingLabel.js +1 -1
- package/lib/commonjs/components/FilePicker/FilePicker.js +1 -1
- package/lib/commonjs/components/FilterChipRow/FilterChipRow.js +1 -1
- package/lib/commonjs/components/FloatingActionButton/FloatingActionButton.js +1 -1
- package/lib/commonjs/components/FormField/FormField.js +1 -1
- package/lib/commonjs/components/IconBadge/IconBadge.js +1 -1
- package/lib/commonjs/components/IconButton/IconButton.js +1 -1
- package/lib/commonjs/components/Input/Input.js +1 -1
- package/lib/commonjs/components/KeyboardAwareScrollView/KeyboardAwareScrollView.js +1 -1
- package/lib/commonjs/components/ListItem/ListItem.js +1 -1
- package/lib/commonjs/components/Modal/Modal.js +1 -1
- package/lib/commonjs/components/NumberInput/NumberInput.js +1 -1
- package/lib/commonjs/components/OTPInput/OTPInput.js +1 -1
- package/lib/commonjs/components/OptionSheet/OptionSheet.js +1 -1
- package/lib/commonjs/components/PhoneNumberInput/PhoneNumberInput.js +1 -1
- package/lib/commonjs/components/PickerTrigger/PickerTrigger.js +1 -1
- package/lib/commonjs/components/ProfileCompletion/ProfileCompletion.js +1 -1
- package/lib/commonjs/components/ProgressBar/ProgressBar.js +1 -1
- package/lib/commonjs/components/ProgressRing/ProgressRing.js +1 -1
- package/lib/commonjs/components/Radio/Radio.js +1 -1
- package/lib/commonjs/components/Radio/RadioGroup.js +1 -1
- package/lib/commonjs/components/Rating/Rating.js +1 -1
- package/lib/commonjs/components/RichTextEditor/RichTextEditor.js +1 -1
- package/lib/commonjs/components/ScannerOverlay/ScannerOverlay.js +1 -1
- package/lib/commonjs/components/Screen/Screen.js +1 -1
- package/lib/commonjs/components/SearchBar/SearchBar.js +1 -1
- package/lib/commonjs/components/SegmentedControl/SegmentedControl.js +1 -1
- package/lib/commonjs/components/Select/Select.js +1 -1
- package/lib/commonjs/components/SignaturePad/SignaturePad.js +1 -1
- package/lib/commonjs/components/Skeleton/SkeletonClock.js +1 -1
- package/lib/commonjs/components/Skeleton/SkeletonProvider.js +1 -1
- package/lib/commonjs/components/SlideToConfirm/SlideToConfirm.js +1 -1
- package/lib/commonjs/components/Slider/Slider.js +1 -1
- package/lib/commonjs/components/SliderField/SliderField.js +1 -1
- package/lib/commonjs/components/Sparkline/Sparkline.js +1 -1
- package/lib/commonjs/components/Spinner/Spinner.js +1 -1
- package/lib/commonjs/components/SquircleView/SquircleView.js +1 -1
- package/lib/commonjs/components/StatTile/StatTile.js +1 -1
- package/lib/commonjs/components/StatusBadge/StatusBadge.js +1 -1
- package/lib/commonjs/components/Stepper/Stepper.js +1 -1
- package/lib/commonjs/components/Switch/Switch.js +1 -1
- package/lib/commonjs/components/Tabs/Tabs.js +1 -1
- package/lib/commonjs/components/TagInput/TagInput.js +1 -1
- package/lib/commonjs/components/Text/Text.js +1 -1
- package/lib/commonjs/components/Toast/ToastProvider.js +1 -1
- package/lib/commonjs/navigation/DiscardGuard.js +1 -1
- package/lib/commonjs/theme/ThemeContext.js +1 -1
- package/lib/commonjs/utils/shadows.js +1 -1
- package/lib/module/components/Accordion/Accordion.js +1 -1
- package/lib/module/components/AmountSlider/AmountSlider.js +1 -1
- package/lib/module/components/AppBar/AppBar.js +1 -1
- package/lib/module/components/AuthedImage/authedImageCache.js +1 -1
- package/lib/module/components/Avatar/Avatar.js +1 -1
- package/lib/module/components/Badge/Badge.js +1 -1
- package/lib/module/components/Banner/Banner.js +1 -1
- package/lib/module/components/BarChart/BarChart.js +1 -1
- package/lib/module/components/BottomNavigation/BottomNavigation.js +1 -1
- package/lib/module/components/BottomSheet/BottomSheet.js +1 -1
- package/lib/module/components/Box/Box.js +1 -1
- package/lib/module/components/Button/Button.js +1 -1
- package/lib/module/components/Calendar/Calendar.js +1 -1
- package/lib/module/components/Card/Card.js +1 -1
- package/lib/module/components/Carousel/Carousel.js +1 -1
- package/lib/module/components/Checkbox/Checkbox.js +1 -1
- package/lib/module/components/Chip/Chip.js +1 -1
- package/lib/module/components/Composer/Composer.js +1 -1
- package/lib/module/components/Confetti/Confetti.js +1 -1
- package/lib/module/components/DateRangePicker/DateRangePicker.js +1 -1
- package/lib/module/components/DecimalInput/DecimalInput.js +1 -1
- package/lib/module/components/Descriptions/Descriptions.js +1 -1
- package/lib/module/components/Divider/Divider.js +1 -1
- package/lib/module/components/Drawer/Drawer.js +1 -1
- package/lib/module/components/EmptyState/EmptyState.js +1 -1
- package/lib/module/components/FieldBase/ChoiceText.js +1 -1
- package/lib/module/components/FieldBase/FieldBase.js +1 -1
- package/lib/module/components/FieldBase/useFloatingLabel.js +1 -1
- package/lib/module/components/FilePicker/FilePicker.js +1 -1
- package/lib/module/components/FilterChipRow/FilterChipRow.js +1 -1
- package/lib/module/components/FloatingActionButton/FloatingActionButton.js +1 -1
- package/lib/module/components/FormField/FormField.js +1 -1
- package/lib/module/components/IconBadge/IconBadge.js +1 -1
- package/lib/module/components/IconButton/IconButton.js +1 -1
- package/lib/module/components/Input/Input.js +1 -1
- package/lib/module/components/KeyboardAwareScrollView/KeyboardAwareScrollView.js +1 -1
- package/lib/module/components/ListItem/ListItem.js +1 -1
- package/lib/module/components/Modal/Modal.js +1 -1
- package/lib/module/components/NumberInput/NumberInput.js +1 -1
- package/lib/module/components/OTPInput/OTPInput.js +1 -1
- package/lib/module/components/OptionSheet/OptionSheet.js +1 -1
- package/lib/module/components/PhoneNumberInput/PhoneNumberInput.js +1 -1
- package/lib/module/components/PickerTrigger/PickerTrigger.js +1 -1
- package/lib/module/components/ProfileCompletion/ProfileCompletion.js +1 -1
- package/lib/module/components/ProgressBar/ProgressBar.js +1 -1
- package/lib/module/components/ProgressRing/ProgressRing.js +1 -1
- package/lib/module/components/Radio/Radio.js +1 -1
- package/lib/module/components/Radio/RadioGroup.js +1 -1
- package/lib/module/components/Rating/Rating.js +1 -1
- package/lib/module/components/RichTextEditor/RichTextEditor.js +1 -1
- package/lib/module/components/ScannerOverlay/ScannerOverlay.js +1 -1
- package/lib/module/components/Screen/Screen.js +1 -1
- package/lib/module/components/SearchBar/SearchBar.js +1 -1
- package/lib/module/components/SegmentedControl/SegmentedControl.js +1 -1
- package/lib/module/components/Select/Select.js +1 -1
- package/lib/module/components/SignaturePad/SignaturePad.js +1 -1
- package/lib/module/components/Skeleton/SkeletonClock.js +1 -1
- package/lib/module/components/Skeleton/SkeletonProvider.js +1 -1
- package/lib/module/components/SlideToConfirm/SlideToConfirm.js +1 -1
- package/lib/module/components/Slider/Slider.js +1 -1
- package/lib/module/components/SliderField/SliderField.js +1 -1
- package/lib/module/components/Sparkline/Sparkline.js +1 -1
- package/lib/module/components/Spinner/Spinner.js +1 -1
- package/lib/module/components/SquircleView/SquircleView.js +1 -1
- package/lib/module/components/StatTile/StatTile.js +1 -1
- package/lib/module/components/StatusBadge/StatusBadge.js +1 -1
- package/lib/module/components/Stepper/Stepper.js +1 -1
- package/lib/module/components/Switch/Switch.js +1 -1
- package/lib/module/components/Tabs/Tabs.js +1 -1
- package/lib/module/components/TagInput/TagInput.js +1 -1
- package/lib/module/components/Text/Text.js +1 -1
- package/lib/module/components/Toast/ToastProvider.js +1 -1
- package/lib/module/navigation/DiscardGuard.js +1 -1
- package/lib/module/theme/ThemeContext.js +1 -1
- package/lib/module/utils/shadows.js +1 -1
- package/lib/typescript/commonjs/components/AmountSlider/AmountSlider.d.ts +3 -2
- package/lib/typescript/commonjs/components/AppBar/AppBar.d.ts +4 -1
- package/lib/typescript/commonjs/components/AuthedImage/authedImageCache.d.ts +3 -1
- package/lib/typescript/commonjs/components/Avatar/Avatar.d.ts +6 -1
- package/lib/typescript/commonjs/components/Badge/Badge.d.ts +5 -1
- package/lib/typescript/commonjs/components/Banner/Banner.d.ts +3 -1
- package/lib/typescript/commonjs/components/BarChart/BarChart.d.ts +4 -1
- package/lib/typescript/commonjs/components/BottomNavigation/BottomNavigation.d.ts +3 -1
- package/lib/typescript/commonjs/components/Box/Box.d.ts +6 -3
- package/lib/typescript/commonjs/components/Button/Button.d.ts +4 -2
- package/lib/typescript/commonjs/components/Calendar/Calendar.d.ts +4 -2
- package/lib/typescript/commonjs/components/Card/Card.d.ts +2 -1
- package/lib/typescript/commonjs/components/Checkbox/Checkbox.d.ts +4 -1
- package/lib/typescript/commonjs/components/Chip/Chip.d.ts +3 -1
- package/lib/typescript/commonjs/components/Composer/Composer.d.ts +3 -1
- package/lib/typescript/commonjs/components/Confetti/Confetti.d.ts +3 -1
- package/lib/typescript/commonjs/components/DateRangePicker/DateRangePicker.d.ts +4 -2
- package/lib/typescript/commonjs/components/DecimalInput/DecimalInput.d.ts +4 -2
- package/lib/typescript/commonjs/components/Divider/Divider.d.ts +3 -2
- package/lib/typescript/commonjs/components/Drawer/Drawer.d.ts +3 -1
- package/lib/typescript/commonjs/components/EmptyState/EmptyState.d.ts +2 -1
- package/lib/typescript/commonjs/components/FilePicker/FilePicker.d.ts +4 -1
- package/lib/typescript/commonjs/components/FilterChipRow/FilterChipRow.d.ts +4 -2
- package/lib/typescript/commonjs/components/FloatingActionButton/FloatingActionButton.d.ts +2 -1
- package/lib/typescript/commonjs/components/FormField/FormField.d.ts +3 -2
- package/lib/typescript/commonjs/components/IconBadge/IconBadge.d.ts +4 -2
- package/lib/typescript/commonjs/components/IconButton/IconButton.d.ts +4 -2
- package/lib/typescript/commonjs/components/Input/Input.d.ts +4 -1
- package/lib/typescript/commonjs/components/KeyboardAwareScrollView/KeyboardAwareScrollView.d.ts +4 -1
- package/lib/typescript/commonjs/components/ListItem/ListItem.d.ts +2 -0
- package/lib/typescript/commonjs/components/Modal/Modal.d.ts +3 -1
- package/lib/typescript/commonjs/components/NumberInput/NumberInput.d.ts +4 -2
- package/lib/typescript/commonjs/components/OTPInput/OTPInput.d.ts +3 -2
- package/lib/typescript/commonjs/components/PhoneNumberInput/PhoneNumberInput.d.ts +4 -2
- package/lib/typescript/commonjs/components/PickerTrigger/PickerTrigger.d.ts +4 -4
- package/lib/typescript/commonjs/components/ProfileCompletion/ProfileCompletion.d.ts +4 -1
- package/lib/typescript/commonjs/components/ProgressBar/ProgressBar.d.ts +3 -2
- package/lib/typescript/commonjs/components/ProgressRing/ProgressRing.d.ts +2 -1
- package/lib/typescript/commonjs/components/Radio/Radio.d.ts +4 -2
- package/lib/typescript/commonjs/components/Rating/Rating.d.ts +5 -1
- package/lib/typescript/commonjs/components/RichTextEditor/RichTextEditor.d.ts +2 -1
- package/lib/typescript/commonjs/components/ScannerOverlay/ScannerOverlay.d.ts +2 -1
- package/lib/typescript/commonjs/components/SearchBar/SearchBar.d.ts +4 -2
- package/lib/typescript/commonjs/components/SegmentedControl/SegmentedControl.d.ts +3 -2
- package/lib/typescript/commonjs/components/SignaturePad/SignaturePad.d.ts +4 -1
- package/lib/typescript/commonjs/components/SlideToConfirm/SlideToConfirm.d.ts +3 -1
- package/lib/typescript/commonjs/components/Slider/Slider.d.ts +3 -1
- package/lib/typescript/commonjs/components/SliderField/SliderField.d.ts +3 -1
- package/lib/typescript/commonjs/components/Sparkline/Sparkline.d.ts +4 -2
- package/lib/typescript/commonjs/components/Spinner/Spinner.d.ts +2 -1
- package/lib/typescript/commonjs/components/SquircleView/SquircleView.d.ts +8 -3
- package/lib/typescript/commonjs/components/StatTile/StatTile.d.ts +3 -2
- package/lib/typescript/commonjs/components/StatusBadge/StatusBadge.d.ts +4 -1
- package/lib/typescript/commonjs/components/Stepper/Stepper.d.ts +3 -1
- package/lib/typescript/commonjs/components/Switch/Switch.d.ts +3 -2
- package/lib/typescript/commonjs/components/Tabs/Tabs.d.ts +3 -2
- package/lib/typescript/commonjs/components/TagInput/TagInput.d.ts +4 -2
- package/lib/typescript/commonjs/components/Text/Text.d.ts +4 -1
- package/lib/typescript/commonjs/navigation/DiscardGuard.d.ts +3 -1
- package/lib/typescript/module/components/AmountSlider/AmountSlider.d.ts +3 -2
- package/lib/typescript/module/components/AppBar/AppBar.d.ts +4 -1
- package/lib/typescript/module/components/AuthedImage/authedImageCache.d.ts +3 -1
- package/lib/typescript/module/components/Avatar/Avatar.d.ts +6 -1
- package/lib/typescript/module/components/Badge/Badge.d.ts +5 -1
- package/lib/typescript/module/components/Banner/Banner.d.ts +3 -1
- package/lib/typescript/module/components/BarChart/BarChart.d.ts +4 -1
- package/lib/typescript/module/components/BottomNavigation/BottomNavigation.d.ts +3 -1
- package/lib/typescript/module/components/Box/Box.d.ts +6 -3
- package/lib/typescript/module/components/Button/Button.d.ts +4 -2
- package/lib/typescript/module/components/Calendar/Calendar.d.ts +4 -2
- package/lib/typescript/module/components/Card/Card.d.ts +2 -1
- package/lib/typescript/module/components/Checkbox/Checkbox.d.ts +4 -1
- package/lib/typescript/module/components/Chip/Chip.d.ts +3 -1
- package/lib/typescript/module/components/Composer/Composer.d.ts +3 -1
- package/lib/typescript/module/components/Confetti/Confetti.d.ts +3 -1
- package/lib/typescript/module/components/DateRangePicker/DateRangePicker.d.ts +4 -2
- package/lib/typescript/module/components/DecimalInput/DecimalInput.d.ts +4 -2
- package/lib/typescript/module/components/Divider/Divider.d.ts +3 -2
- package/lib/typescript/module/components/Drawer/Drawer.d.ts +3 -1
- package/lib/typescript/module/components/EmptyState/EmptyState.d.ts +2 -1
- package/lib/typescript/module/components/FilePicker/FilePicker.d.ts +4 -1
- package/lib/typescript/module/components/FilterChipRow/FilterChipRow.d.ts +4 -2
- package/lib/typescript/module/components/FloatingActionButton/FloatingActionButton.d.ts +2 -1
- package/lib/typescript/module/components/FormField/FormField.d.ts +3 -2
- package/lib/typescript/module/components/IconBadge/IconBadge.d.ts +4 -2
- package/lib/typescript/module/components/IconButton/IconButton.d.ts +4 -2
- package/lib/typescript/module/components/Input/Input.d.ts +4 -1
- package/lib/typescript/module/components/KeyboardAwareScrollView/KeyboardAwareScrollView.d.ts +4 -1
- package/lib/typescript/module/components/ListItem/ListItem.d.ts +2 -0
- package/lib/typescript/module/components/Modal/Modal.d.ts +3 -1
- package/lib/typescript/module/components/NumberInput/NumberInput.d.ts +4 -2
- package/lib/typescript/module/components/OTPInput/OTPInput.d.ts +3 -2
- package/lib/typescript/module/components/PhoneNumberInput/PhoneNumberInput.d.ts +4 -2
- package/lib/typescript/module/components/PickerTrigger/PickerTrigger.d.ts +4 -4
- package/lib/typescript/module/components/ProfileCompletion/ProfileCompletion.d.ts +4 -1
- package/lib/typescript/module/components/ProgressBar/ProgressBar.d.ts +3 -2
- package/lib/typescript/module/components/ProgressRing/ProgressRing.d.ts +2 -1
- package/lib/typescript/module/components/Radio/Radio.d.ts +4 -2
- package/lib/typescript/module/components/Rating/Rating.d.ts +5 -1
- package/lib/typescript/module/components/RichTextEditor/RichTextEditor.d.ts +2 -1
- package/lib/typescript/module/components/ScannerOverlay/ScannerOverlay.d.ts +2 -1
- package/lib/typescript/module/components/SearchBar/SearchBar.d.ts +4 -2
- package/lib/typescript/module/components/SegmentedControl/SegmentedControl.d.ts +3 -2
- package/lib/typescript/module/components/SignaturePad/SignaturePad.d.ts +4 -1
- package/lib/typescript/module/components/SlideToConfirm/SlideToConfirm.d.ts +3 -1
- package/lib/typescript/module/components/Slider/Slider.d.ts +3 -1
- package/lib/typescript/module/components/SliderField/SliderField.d.ts +3 -1
- package/lib/typescript/module/components/Sparkline/Sparkline.d.ts +4 -2
- package/lib/typescript/module/components/Spinner/Spinner.d.ts +2 -1
- package/lib/typescript/module/components/SquircleView/SquircleView.d.ts +8 -3
- package/lib/typescript/module/components/StatTile/StatTile.d.ts +3 -2
- package/lib/typescript/module/components/StatusBadge/StatusBadge.d.ts +4 -1
- package/lib/typescript/module/components/Stepper/Stepper.d.ts +3 -1
- package/lib/typescript/module/components/Switch/Switch.d.ts +3 -2
- package/lib/typescript/module/components/Tabs/Tabs.d.ts +3 -2
- package/lib/typescript/module/components/TagInput/TagInput.d.ts +4 -2
- package/lib/typescript/module/components/Text/Text.d.ts +4 -1
- package/lib/typescript/module/navigation/DiscardGuard.d.ts +3 -1
- package/package.json +7 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{Image}from"expo-image";import{Children,cloneElement,forwardRef,isValidElement,useEffect,useMemo,useRef,useState}from"react";import{Animated,Easing,Pressable,StyleSheet,View}from"react-native";import{fillText,pluralText,useMobileUiText}from"../../text/index.js";import{AVATAR_TEXT}from"../../text/phone/avatar.g.js";import{createAnimatedValue,useTheme}from"../../theme/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{tintOf}from"../../utils/color.js";import{smoothCorners}from"../../utils/corners.js";import{resolveHaptic,triggerHaptic}from"../../utils/hapticUtils.js";import{hitSlopMarker}from"../../utils/hitSlop.js";import{nativeDriver}from"../../utils/nativeDriver.js";import{AppIcon}from"../AppIcon/index.js";import{renderSlotIcon}from"../AppIcon/slotIcon.js";import{AuthedImage}from"../AuthedImage/AuthedImage.js";import{Skeleton}from"../Skeleton/index.js";import{Text}from"../Text/index.js";import{jsx as _jsx,Fragment as _Fragment,jsxs as _jsxs}from"react/jsx-runtime";const SOFT_FILL_OPACITY=.14,MIN_TOUCH_TARGET=44,PRESSED_OPACITY=.7,INITIALS_MAX_FONT_SCALE=1.2;export const AVATAR_COLORS=["avatar-1","avatar-2","avatar-3","avatar-4","avatar-5","avatar-6","avatar-7","avatar-8"];export const avatarToneColors=(e,t)=>{const soft=(e,t)=>tintOf(e,.14,t);switch(t){case"primary":return{background:soft(e.colors.primary,e.colors["primary-soft"]),color:e.colors["primary-text"]};case"success":return{background:soft(e.colors.success,e.colors["bg-subtle"]),color:e.colors["success-text"]};case"warning":return{background:soft(e.colors.warning,e.colors["bg-subtle"]),color:e.colors["warning-text"]};case"danger":return{background:soft(e.colors.danger,e.colors["bg-subtle"]),color:e.colors["danger-text"]};case"info":return{background:soft(e.colors.info,e.colors["bg-subtle"]),color:e.colors["info-text"]};case"neutral":return{background:e.colors["bg-muted"],color:e.colors["text-body"]}}};const sizeMap={xs:24,sm:32,md:48,lg:64,xl:80},resolveSize=e=>sizeMap[e],resolveRadius=(e,t,r,o)=>{switch(t){case"circle":return r/2;case"rounded":return o?e.radius[o]:Math.max(e.radius.sm,Math.round(.22*r));case"square":return 0}},initialsFromName=e=>{if(!e)return"";const t=e.trim().split(/\s+/u).filter(Boolean),[r,o]=t;return void 0===r?"":void 0===o?r.charAt(0).toUpperCase():(r.charAt(0)+o.charAt(0)).toUpperCase()},hashColor=(e,t)=>{let r=0;for(let t=0;t<e.length;t+=1)r=(r<<5)-r+e.charCodeAt(t),r|=0;const o=t[Math.abs(r)%t.length];if(void 0===o)throw new Error("The avatar colour palette is empty.");return o},RING_WIDTH=1.5,keyOfSource=e=>"object"==typeof e&&null!==e&&"uri"in e&&"string"==typeof e.uri?e.uri:e,uriOfSource=e=>"object"==typeof e&&null!==e&&"uri"in e&&"string"==typeof e.uri?e.uri:void 0,isImageSourceList=e=>Array.isArray(e),toExpoSource=e=>({...void 0!==e.uri?{uri:e.uri}:{},...void 0!==e.headers?{headers:e.headers}:{},...void 0!==e.width?{width:e.width}:{},...void 0!==e.height?{height:e.height}:{}}),toExpoSources=e=>"number"==typeof e?e:isImageSourceList(e)?e.map(toExpoSource):toExpoSource(e),isRingStatus=e=>"verified"===e||"pending"===e||"rejected"===e,statusColor=(e,t)=>{switch(t){case"online":case"verified":return e.colors.success;case"busy":case"rejected":return e.colors.danger;case"away":case"pending":return e.colors.warning;case"offline":return e.colors["text-subtle"]}},AvatarRoot=forwardRef((e,t)=>{const{source:r,ImageComponent:o,imageClient:s,name:a,size:i="md",shape:l="circle",dimension:n,radius:c,border:u=!1,contentFit:d="cover",placeholderIcon:m,status:h=null,statusPosition:g="bottomRight",tone:p,backgroundColor:b,color:v,fontSize:f,loading:y=!1,accessibilityLabel:x,onPress:A,onLongPress:S,haptic:j,hitSlop:C,style:I,textStyle:R,testID:T,labels:V}=e;assertValidValue("Avatar","size",e.size,Object.keys(sizeMap)),assertValidValue("Avatar","shape",e.shape,["circle","square","rounded"]),assertValidValue("Avatar","radius",e.radius,["sm","md","lg"]),assertValidValue("Avatar","contentFit",e.contentFit,["cover","contain"]),assertValidValue("Avatar","status",e.status,["online","offline","busy","away","verified","pending","rejected"]),assertValidValue("Avatar","statusPosition",e.statusPosition,["topRight","bottomRight"]),assertValidValue("Avatar","tone",e.tone,["primary","success","warning","danger","info","neutral"]);const w=useMobileUiText("avatar",AVATAR_TEXT),M=useMemo(()=>V?{...w,...V}:w,[w,V]),_=useTheme(),[E,k]=useState(null),z=useMemo(()=>n??resolveSize(i),[n,i]),O=useMemo(()=>resolveRadius(_,l,z,c),[_,l,z,c]),L=u?_.size.border:0,F=_.colors.border,D=_.colors.surface,P=useMemo(()=>initialsFromName(a),[a]),G=useMemo(()=>p?avatarToneColors(_,p):null,[_,p]),N=useMemo(()=>b||(G?.background??_.colors[hashColor(a??"",AVATAR_COLORS)]),[b,G,a,_]),$=v??G?.color??_.colors["on-primary"],H=r?keyOfSource(r):null,W=useMemo(()=>void 0!==r?toExpoSources(r):void 0,[r]),U=null!==H&&H!==E,B=!U&&""===P&&null!=m,X=v??G?.color??_.colors["text-subtle"],q=f??Math.max(_.text.xs.size,Math.round(.4*z)),Y=Math.max(8,Math.round(.25*z)),J=isRingStatus(h),K=z-2*(J?3:L),Q=J?resolveRadius(_,l,K,c):Math.max(0,O-L),Z=B?renderSlotIcon(m,{color:X,size:Math.round(.45*K),disabled:!1}):null,ee=J?statusColor(_,h):"transparent",te=Math.max(12,Math.round(.32*z)),re=Math.max(10,te-4),oe=b??G?.background??_.colors["bg-muted"],se=U?"contain"===d?"transparent":_.colors["bg-muted"]:B?oe:N,ae=T??"avatar",ie=a?fillText(M.avatarOf,{name:a}):M.avatar,le="verified"===h?`, ${M.verified}`:"pending"===h?`, ${M.pendingVerification}`:"rejected"===h?`, ${M.rejected}`:"",ne=x??`${ie}${le}`,ce="function"==typeof A||"function"==typeof S,ue=x??`${a||ie}${le}`,de=Math.max(0,Math.ceil((44-z)/2)),me=C??de,he=[styles.root,{width:z,height:z,borderRadius:O,...smoothCorners,borderWidth:J?0:L,borderColor:F,backgroundColor:J?"transparent":se},I],ge=_jsxs(_Fragment,{children:[J?_jsx(View,{style:[styles.ring,{borderRadius:O,...smoothCorners,borderWidth:1.5,borderColor:ee}],accessible:!1,pointerEvents:"none",testID:`${ae}-ring`}):null,_jsx(View,{style:[styles.picture,{width:K,height:K,borderRadius:Q,...smoothCorners,borderWidth:J?L:0,borderColor:F,backgroundColor:J?se:"transparent"}],children:U?(()=>{const e={width:K,height:K,borderRadius:Q,...smoothCorners};if(!r)return null;const onError=()=>k(H),t=uriOfSource(r);return o?_jsx(o,{source:r,onError:onError,style:e,contentFit:d,resizeMode:d,accessibilityIgnoresInvertColors:!0}):s&&void 0!==t?_jsx(AuthedImage,{uri:t,client:s,onError:onError,style:e,contentFit:d,placeholder:null,fallback:null,accessibilityIgnoresInvertColors:!0}):_jsx(Image,{...void 0!==W?{source:W}:{},onError:onError,style:e,contentFit:d,accessibilityIgnoresInvertColors:!0,testID:T?`${T}-image`:void 0})})():Z||_jsx(Text,{variant:"label",weight:"semibold",numberOfLines:1,maxFontSizeMultiplier:1.2,style:[styles.initials,{color:$,fontSize:q,lineHeight:Math.round(q*_.leading.body)},R],children:P??" "})}),"verified"===h||"rejected"===h?_jsx(View,{style:[styles.status,"topRight"===g?styles.badgeTopRight:styles.badgeBottomRight,{width:te,height:te,borderRadius:te/2,...smoothCorners,backgroundColor:D}],accessible:!1,pointerEvents:"none",testID:`${ae}-badge`,children:_jsx(AppIcon,{name:"verified"===h?"verify":"close-circle",variant:"bold",size:re,color:ee})}):null,h&&!J?_jsx(View,{style:[styles.status,"topRight"===g?styles.statusTopRight:styles.statusBottomRight,{width:Y,height:Y,borderRadius:Y/2,...smoothCorners,backgroundColor:statusColor(_,h),borderWidth:2,borderColor:D}],accessible:!1,pointerEvents:"none"}):null]}),pe=ce?_jsx(Pressable,{ref:t,onPress:A?e=>{const t=resolveHaptic(j,"selection");t&&triggerHaptic(t),A?.(e)}:void 0,onLongPress:S?e=>{const t=resolveHaptic(j,"longPress");t&&triggerHaptic(t),S?.(e)}:void 0,hitSlop:me,...hitSlopMarker(me),accessibilityRole:"button",accessibilityLabel:ue,testID:T,style:({pressed:e})=>[he,e?styles.pressed:null],children:ge}):_jsx(View,{ref:t,style:he,accessible:!0,accessibilityRole:"image",accessibilityLabel:ne,testID:T,children:ge});return y?_jsx(AvatarSkeleton,{...e}):pe}),AvatarSkeleton=({size:e="md",shape:t="circle",dimension:r,style:o})=>{const s=r??resolveSize(e);return _jsx(Skeleton,{shape:"circle"===t?"circle":"rounded"===t?"rounded":"rect",width:s,height:s,style:o})};AvatarSkeleton.displayName="AvatarSkeleton";const Avatar=Object.assign(AvatarRoot,{Skeleton:AvatarSkeleton});Avatar.displayName="Avatar";const styles=StyleSheet.create({root:{alignItems:"center",justifyContent:"center",overflow:"visible",position:"relative"},pressed:{opacity:.7},initials:{textAlign:"center"},ring:{position:"absolute",top:0,right:0,bottom:0,left:0},picture:{alignItems:"center",justifyContent:"center",overflow:"hidden"},status:{position:"absolute"},badgeTopRight:{top:-2,right:-2,alignItems:"center",justifyContent:"center"},badgeBottomRight:{bottom:-2,right:-2,alignItems:"center",justifyContent:"center"},statusTopRight:{top:0,right:0},statusBottomRight:{bottom:0,right:0}}),SPACING_OFFSET={tight:"lg",normal:"md",loose:"sm"},STAGGER_MS=50,ENTRANCE_DURATION_MS=220,AvatarGroupItem=({delay:e,marginLeft:t,borderColor:r,borderWidth:o,children:s})=>{const a=useTheme(),i=useRef(createAnimatedValue(0)).current;return useEffect(()=>{const t=Animated.timing(i,{toValue:1,duration:220,delay:e,easing:Easing.out(Easing.cubic),useNativeDriver:nativeDriver});return t.start(),()=>t.stop()},[e,i]),_jsx(Animated.View,{style:[groupStyles.item,{marginLeft:t,borderRadius:a.radius.pill,borderColor:r,borderWidth:o,opacity:i}],children:s})},AvatarGroup=e=>{const{children:t,max:r=4,size:o="md",spacing:s="normal",overflowVariant:a="count",accessibilityLabel:i,style:l,testID:n,labels:c}=e;assertValidValue("AvatarGroup","spacing",e.spacing,["tight","normal","loose"]),assertValidValue("AvatarGroup","overflowVariant",e.overflowVariant,["count","plus"]),assertValidValue("AvatarGroup","size",e.size,Object.keys(sizeMap));const u=useMobileUiText("avatar",AVATAR_TEXT),d=useMemo(()=>c?{...u,...c}:u,[u,c]),m=useTheme(),h=useMemo(()=>Children.toArray(t).filter(e=>isValidElement(e)),[t]),g=h.length,p=h.slice(0,r),b=Math.max(0,g-r),v=b>0,f=-m.space[SPACING_OFFSET[s]],y=m.colors.surface,x=i??pluralText(d,"groupOf",g),A=useMemo(()=>resolveSize(o),[o]),S=Math.max(m.text.xs.size,Math.round(.34*A));return _jsxs(View,{style:[groupStyles.row,l],accessible:!0,accessibilityLabel:x,accessibilityRole:"summary",testID:n,children:[p.map((e,t)=>{const r=e.key??`avatar-${t}`,s=cloneElement(e,{size:o,labels:e.props.labels??c});return _jsx(AvatarGroupItem,{delay:50*t,marginLeft:0===t?0:f,borderColor:y,borderWidth:1.5,children:s},r)}),v?_jsx(AvatarGroupItem,{delay:50*p.length,marginLeft:0===p.length?0:f,borderColor:y,borderWidth:1.5,children:_jsx(View,{style:[groupStyles.overflow,{width:A,height:A,borderRadius:A/2,...smoothCorners,backgroundColor:m.colors["surface-disabled"]}],accessible:!0,accessibilityRole:"text",accessibilityLabel:"count"===a?fillText(d.moreCount,{count:b}):d.moreAvatars,children:_jsx(Text,{variant:"label",weight:"semibold",color:"secondary",numberOfLines:1,maxFontSizeMultiplier:1.2,style:{fontSize:S,lineHeight:Math.round(S*m.leading.body)},children:"count"===a?`+${b}`:"+"})})},"avatar-overflow"):null]})},groupStyles=StyleSheet.create({row:{flexDirection:"row",alignItems:"center"},item:{...smoothCorners},overflow:{alignItems:"center",justifyContent:"center"}});export{Avatar,AvatarGroup};export default Avatar;
|
|
1
|
+
"use strict";import{Image}from"expo-image";import{Children,cloneElement,isValidElement,useEffect,useMemo,useRef,useState}from"react";import{Animated,Easing,Pressable,StyleSheet,View}from"react-native";import{fillText,pluralText,useMobileUiText}from"../../text/index.js";import{AVATAR_TEXT}from"../../text/phone/avatar.g.js";import{createAnimatedValue,useTheme}from"../../theme/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{tintOf}from"../../utils/color.js";import{smoothCorners}from"../../utils/corners.js";import{resolveHaptic,triggerHaptic}from"../../utils/hapticUtils.js";import{hitSlopMarker}from"../../utils/hitSlop.js";import{nativeDriver}from"../../utils/nativeDriver.js";import{AppIcon}from"../AppIcon/index.js";import{renderSlotIcon}from"../AppIcon/slotIcon.js";import{AuthedImage}from"../AuthedImage/AuthedImage.js";import{Skeleton}from"../Skeleton/index.js";import{Text}from"../Text/index.js";import{jsx as _jsx,Fragment as _Fragment,jsxs as _jsxs}from"react/jsx-runtime";const SOFT_FILL_OPACITY=.14,MIN_TOUCH_TARGET=44,PRESSED_OPACITY=.7,INITIALS_MAX_FONT_SCALE=1.2;export const AVATAR_COLORS=["avatar-1","avatar-2","avatar-3","avatar-4","avatar-5","avatar-6","avatar-7","avatar-8"];export const avatarToneColors=(e,t)=>{const soft=(e,t)=>tintOf(e,.14,t);switch(t){case"primary":return{background:soft(e.colors.primary,e.colors["primary-soft"]),color:e.colors["primary-text"]};case"success":return{background:soft(e.colors.success,e.colors["bg-subtle"]),color:e.colors["success-text"]};case"warning":return{background:soft(e.colors.warning,e.colors["bg-subtle"]),color:e.colors["warning-text"]};case"danger":return{background:soft(e.colors.danger,e.colors["bg-subtle"]),color:e.colors["danger-text"]};case"info":return{background:soft(e.colors.info,e.colors["bg-subtle"]),color:e.colors["info-text"]};case"neutral":return{background:e.colors["bg-muted"],color:e.colors["text-body"]}}};const sizeMap={xs:24,sm:32,md:48,lg:64,xl:80},resolveSize=e=>sizeMap[e],resolveRadius=(e,t,r,o)=>{switch(t){case"circle":return r/2;case"rounded":return o?e.radius[o]:Math.max(e.radius.sm,Math.round(.22*r));case"square":return 0}},initialsFromName=e=>{if(!e)return"";const t=e.trim().split(/\s+/u).filter(Boolean),[r,o]=t;return void 0===r?"":void 0===o?r.charAt(0).toUpperCase():(r.charAt(0)+o.charAt(0)).toUpperCase()},hashColor=(e,t)=>{let r=0;for(let t=0;t<e.length;t+=1)r=(r<<5)-r+e.charCodeAt(t),r|=0;const o=t[Math.abs(r)%t.length];if(void 0===o)throw new Error("The avatar colour palette is empty.");return o},RING_WIDTH=1.5,keyOfSource=e=>"object"==typeof e&&null!==e&&"uri"in e&&"string"==typeof e.uri?e.uri:e,uriOfSource=e=>"object"==typeof e&&null!==e&&"uri"in e&&"string"==typeof e.uri?e.uri:void 0,isImageSourceList=e=>Array.isArray(e),toExpoSource=e=>({...void 0!==e.uri?{uri:e.uri}:{},...void 0!==e.headers?{headers:e.headers}:{},...void 0!==e.width?{width:e.width}:{},...void 0!==e.height?{height:e.height}:{}}),toExpoSources=e=>"number"==typeof e?e:isImageSourceList(e)?e.map(toExpoSource):toExpoSource(e),isRingStatus=e=>"verified"===e||"pending"===e||"rejected"===e,statusColor=(e,t)=>{switch(t){case"online":case"verified":return e.colors.success;case"busy":case"rejected":return e.colors.danger;case"away":case"pending":return e.colors.warning;case"offline":return e.colors["text-subtle"]}};function AvatarRoot({ref:e,...t}){const{source:r,ImageComponent:o,imageClient:s,name:a,size:i="md",shape:l="circle",dimension:n,radius:c,border:u=!1,contentFit:d="cover",placeholderIcon:m,status:h=null,statusPosition:g="bottomRight",tone:p,backgroundColor:b,color:v,fontSize:f,loading:y=!1,accessibilityLabel:x,onPress:A,onLongPress:S,haptic:j,hitSlop:C,style:I,textStyle:T,testID:R,labels:V}=t;assertValidValue("Avatar","size",t.size,Object.keys(sizeMap)),assertValidValue("Avatar","shape",t.shape,["circle","square","rounded"]),assertValidValue("Avatar","radius",t.radius,["sm","md","lg"]),assertValidValue("Avatar","contentFit",t.contentFit,["cover","contain"]),assertValidValue("Avatar","status",t.status,["online","offline","busy","away","verified","pending","rejected"]),assertValidValue("Avatar","statusPosition",t.statusPosition,["topRight","bottomRight"]),assertValidValue("Avatar","tone",t.tone,["primary","success","warning","danger","info","neutral"]);const M=useMobileUiText("avatar",AVATAR_TEXT),w=useMemo(()=>V?{...M,...V}:M,[M,V]),_=useTheme(),[E,k]=useState(null),z=useMemo(()=>n??resolveSize(i),[n,i]),O=useMemo(()=>resolveRadius(_,l,z,c),[_,l,z,c]),L=u?_.size.border:0,F=_.colors.border,D=_.colors.surface,P=useMemo(()=>initialsFromName(a),[a]),G=useMemo(()=>p?avatarToneColors(_,p):null,[_,p]),N=useMemo(()=>b||(G?.background??_.colors[hashColor(a??"",AVATAR_COLORS)]),[b,G,a,_]),$=v??G?.color??_.colors["on-primary"],H=r?keyOfSource(r):null,W=useMemo(()=>void 0!==r?toExpoSources(r):void 0,[r]),U=null!==H&&H!==E,B=!U&&""===P&&null!=m,X=v??G?.color??_.colors["text-subtle"],q=f??Math.max(_.text.xs.size,Math.round(.4*z)),Y=Math.max(8,Math.round(.25*z)),J=isRingStatus(h),K=z-2*(J?3:L),Q=J?resolveRadius(_,l,K,c):Math.max(0,O-L),Z=B?renderSlotIcon(m,{color:X,size:Math.round(.45*K),disabled:!1}):null,ee=J?statusColor(_,h):"transparent",te=Math.max(12,Math.round(.32*z)),re=Math.max(10,te-4),oe=b??G?.background??_.colors["bg-muted"],se=U?"contain"===d?"transparent":_.colors["bg-muted"]:B?oe:N,ae=R??"avatar",ie=a?fillText(w.avatarOf,{name:a}):w.avatar,le="verified"===h?`, ${w.verified}`:"pending"===h?`, ${w.pendingVerification}`:"rejected"===h?`, ${w.rejected}`:"",ne=x??`${ie}${le}`,ce="function"==typeof A||"function"==typeof S,ue=x??`${a||ie}${le}`,de=Math.max(0,Math.ceil((44-z)/2)),me=C??de,he=[styles.root,{width:z,height:z,borderRadius:O,...smoothCorners,borderWidth:J?0:L,borderColor:F,backgroundColor:J?"transparent":se},I],ge=_jsxs(_Fragment,{children:[J?_jsx(View,{style:[styles.ring,{borderRadius:O,...smoothCorners,borderWidth:1.5,borderColor:ee}],accessible:!1,pointerEvents:"none",testID:`${ae}-ring`}):null,_jsx(View,{style:[styles.picture,{width:K,height:K,borderRadius:Q,...smoothCorners,borderWidth:J?L:0,borderColor:F,backgroundColor:J?se:"transparent"}],children:U?(()=>{const e={width:K,height:K,borderRadius:Q,...smoothCorners};if(!r)return null;const onError=()=>k(H),t=uriOfSource(r);return o?_jsx(o,{source:r,onError:onError,style:e,contentFit:d,resizeMode:d,accessibilityIgnoresInvertColors:!0}):s&&void 0!==t?_jsx(AuthedImage,{uri:t,client:s,onError:onError,style:e,contentFit:d,placeholder:null,fallback:null,accessibilityIgnoresInvertColors:!0}):_jsx(Image,{...void 0!==W?{source:W}:{},onError:onError,style:e,contentFit:d,accessibilityIgnoresInvertColors:!0,testID:R?`${R}-image`:void 0})})():Z||_jsx(Text,{variant:"label",weight:"semibold",numberOfLines:1,maxFontSizeMultiplier:1.2,style:[styles.initials,{color:$,fontSize:q,lineHeight:Math.round(q*_.leading.body)},T],children:P??" "})}),"verified"===h||"rejected"===h?_jsx(View,{style:[styles.status,"topRight"===g?styles.badgeTopRight:styles.badgeBottomRight,{width:te,height:te,borderRadius:te/2,...smoothCorners,backgroundColor:D}],accessible:!1,pointerEvents:"none",testID:`${ae}-badge`,children:_jsx(AppIcon,{name:"verified"===h?"verify":"close-circle",variant:"bold",size:re,color:ee})}):null,h&&!J?_jsx(View,{style:[styles.status,"topRight"===g?styles.statusTopRight:styles.statusBottomRight,{width:Y,height:Y,borderRadius:Y/2,...smoothCorners,backgroundColor:statusColor(_,h),borderWidth:2,borderColor:D}],accessible:!1,pointerEvents:"none"}):null]}),pe=ce?_jsx(Pressable,{ref:e,onPress:A?e=>{const t=resolveHaptic(j,"selection");t&&triggerHaptic(t),A?.(e)}:void 0,onLongPress:S?e=>{const t=resolveHaptic(j,"longPress");t&&triggerHaptic(t),S?.(e)}:void 0,hitSlop:me,...hitSlopMarker(me),accessibilityRole:"button",accessibilityLabel:ue,testID:R,style:({pressed:e})=>[he,e?styles.pressed:null],children:ge}):_jsx(View,{ref:e,style:he,accessible:!0,accessibilityRole:"image",accessibilityLabel:ne,testID:R,children:ge});return y?_jsx(AvatarSkeleton,{...t}):pe}const AvatarSkeleton=({size:e="md",shape:t="circle",dimension:r,style:o})=>{const s=r??resolveSize(e);return _jsx(Skeleton,{shape:"circle"===t?"circle":"rounded"===t?"rounded":"rect",width:s,height:s,style:o})};AvatarSkeleton.displayName="AvatarSkeleton";const Avatar=Object.assign(AvatarRoot,{Skeleton:AvatarSkeleton});Avatar.displayName="Avatar";const styles=StyleSheet.create({root:{alignItems:"center",justifyContent:"center",overflow:"visible",position:"relative"},pressed:{opacity:.7},initials:{textAlign:"center"},ring:{position:"absolute",top:0,right:0,bottom:0,left:0},picture:{alignItems:"center",justifyContent:"center",overflow:"hidden"},status:{position:"absolute"},badgeTopRight:{top:-2,right:-2,alignItems:"center",justifyContent:"center"},badgeBottomRight:{bottom:-2,right:-2,alignItems:"center",justifyContent:"center"},statusTopRight:{top:0,right:0},statusBottomRight:{bottom:0,right:0}}),SPACING_OFFSET={tight:"lg",normal:"md",loose:"sm"},STAGGER_MS=50,ENTRANCE_DURATION_MS=220,AvatarGroupItem=({delay:e,marginLeft:t,borderColor:r,borderWidth:o,children:s})=>{const a=useTheme(),i=useRef(createAnimatedValue(0)).current;return useEffect(()=>{const t=Animated.timing(i,{toValue:1,duration:220,delay:e,easing:Easing.out(Easing.cubic),useNativeDriver:nativeDriver});return t.start(),()=>t.stop()},[e,i]),_jsx(Animated.View,{style:[groupStyles.item,{marginLeft:t,borderRadius:a.radius.pill,borderColor:r,borderWidth:o,opacity:i}],children:s})},AvatarGroup=e=>{const{children:t,max:r=4,size:o="md",spacing:s="normal",overflowVariant:a="count",accessibilityLabel:i,style:l,testID:n,labels:c}=e;assertValidValue("AvatarGroup","spacing",e.spacing,["tight","normal","loose"]),assertValidValue("AvatarGroup","overflowVariant",e.overflowVariant,["count","plus"]),assertValidValue("AvatarGroup","size",e.size,Object.keys(sizeMap));const u=useMobileUiText("avatar",AVATAR_TEXT),d=useMemo(()=>c?{...u,...c}:u,[u,c]),m=useTheme(),h=useMemo(()=>Children.toArray(t).filter(e=>isValidElement(e)),[t]),g=h.length,p=h.slice(0,r),b=Math.max(0,g-r),v=b>0,f=-m.space[SPACING_OFFSET[s]],y=m.colors.surface,x=i??pluralText(d,"groupOf",g),A=useMemo(()=>resolveSize(o),[o]),S=Math.max(m.text.xs.size,Math.round(.34*A));return _jsxs(View,{style:[groupStyles.row,l],accessible:!0,accessibilityLabel:x,accessibilityRole:"summary",testID:n,children:[p.map((e,t)=>{const r=e.key??`avatar-${t}`,s=cloneElement(e,{size:o,labels:e.props.labels??c});return _jsx(AvatarGroupItem,{delay:50*t,marginLeft:0===t?0:f,borderColor:y,borderWidth:1.5,children:s},r)}),v?_jsx(AvatarGroupItem,{delay:50*p.length,marginLeft:0===p.length?0:f,borderColor:y,borderWidth:1.5,children:_jsx(View,{style:[groupStyles.overflow,{width:A,height:A,borderRadius:A/2,...smoothCorners,backgroundColor:m.colors["surface-disabled"]}],accessible:!0,accessibilityRole:"text",accessibilityLabel:"count"===a?fillText(d.moreCount,{count:b}):d.moreAvatars,children:_jsx(Text,{variant:"label",weight:"semibold",color:"secondary",numberOfLines:1,maxFontSizeMultiplier:1.2,style:{fontSize:S,lineHeight:Math.round(S*m.leading.body)},children:"count"===a?`+${b}`:"+"})})},"avatar-overflow"):null]})},groupStyles=StyleSheet.create({row:{flexDirection:"row",alignItems:"center"},item:{...smoothCorners},overflow:{alignItems:"center",justifyContent:"center"}});export{Avatar,AvatarGroup};export default Avatar;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{
|
|
1
|
+
"use strict";import{useEffect,useMemo,useRef}from"react";import{Animated,Easing,StyleSheet,View}from"react-native";import{fillText,useMobileUiText}from"../../text/index.js";import{BADGE_TEXT}from"../../text/phone/badge.g.js";import{createAnimatedValue,resolveBadgeSize,setNativeValue,useTheme}from"../../theme/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{smoothCorners}from"../../utils/corners.js";import{nativeDriver}from"../../utils/nativeDriver.js";import{Skeleton}from"../Skeleton/index.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const toneFor=(e,t)=>{switch(t){case"primary":return{background:e.colors.primary,text:e.colors["on-primary"]};case"success":return{background:e.colors.success,text:e.colors["on-success"]};case"warning":return{background:e.colors.warning,text:e.colors["on-warning"]};case"info":return{background:e.colors.info,text:e.colors["on-info"]};case"neutral":return{background:e.colors["bg-muted"],text:e.colors["text-body"]};default:return{background:e.colors.danger,text:e.colors["on-danger"]}}},softToneFor=(e,t)=>{switch(t){case"primary":return{background:e.colors["primary-soft"],text:e.colors.primary};case"success":return{background:e.colors["success-soft"],text:e.colors.success};case"warning":return{background:e.colors["warning-soft"],text:e.colors.warning};case"info":return{background:e.colors["info-soft"],text:e.colors.info};case"neutral":return{background:e.colors["bg-muted"],text:e.colors["text-muted"]};default:return{background:e.colors["danger-soft"],text:e.colors.danger}}},anchorPosition=(e,t)=>{const o=-t;switch(e){case"topLeft":return{top:o,left:o};case"bottomRight":return{bottom:o,right:o};case"bottomLeft":return{bottom:o,left:o};default:return{top:o,right:o}}},formatValue=(e,t)=>{if(null==e)return null;if("number"==typeof e)return e<=0?null:e>t?`${t}+`:String(e);const o=String(e);return 0===o.length?null:o};function BadgeRoot({ref:e,...t}){const{value:o,max:r=99,variant:i="standard",tone:s="danger",size:n="sm",fill:a="solid",accessible:l=!0,invisible:d=!1,loading:c=!1,children:u,anchor:g="topRight",pulse:m=!1,accessibilityLabel:h,labels:f,style:b,badgeStyle:x,textStyle:p,testID:y}=t;assertValidValue("Badge","variant",t.variant,["standard","dot"]),assertValidValue("Badge","tone",t.tone,["primary","success","warning","danger","neutral","info"]),assertValidValue("Badge","size",t.size,["sm","md"]),assertValidValue("Badge","anchor",t.anchor,["topRight","topLeft","bottomRight","bottomLeft"]),assertValidValue("Badge","fill",t.fill,["solid","soft"]);const v=useMobileUiText("badge",BADGE_TEXT),w=useMemo(()=>({...v,...f}),[v,f]),V=useTheme(),j=useMemo(()=>"soft"===a?softToneFor(V,s):toneFor(V,s),[V,s,a]),k=resolveBadgeSize(V,n),S=V.components.badge["border-width"],B=V.components.badge["anchor-offset"],z="dot"===i?null:formatValue(o,r),T=!d&&("dot"===i||null!==z),_=useRef(createAnimatedValue(1)).current;useEffect(()=>{if(!m||!T)return void setNativeValue(_,1);const e=Animated.loop(Animated.sequence([Animated.timing(_,{toValue:1.15,duration:V.motion.duration.slow,easing:Easing.bezier(...V.motion.ease["in-out"]),useNativeDriver:nativeDriver}),Animated.timing(_,{toValue:1,duration:V.motion.duration.slow,easing:Easing.bezier(...V.motion.ease["in-out"]),useNativeDriver:nativeDriver})]));return e.start(),()=>{e.stop()}},[m,T,_,V]);const A="dot"===i,D=A?"image":"text",R=h??(A?w.indicator:z?fillText(w.unread,{count:z}):void 0),E=T?_jsx(Animated.View,{style:[styles.badge,A?{width:k["dot-size"],height:k["dot-size"],borderRadius:k["dot-size"]/2,...smoothCorners,paddingHorizontal:0}:{minWidth:k["min-width"],minHeight:k.height,borderRadius:V.radius.pill,...smoothCorners,paddingHorizontal:k["padding-x"]},{backgroundColor:j.background,transform:[{scale:_}]},u?{position:"absolute",borderWidth:S,borderColor:V.colors.surface,...anchorPosition(g,B)}:null,x],accessible:l,importantForAccessibility:l?void 0:"no-hide-descendants",accessibilityElementsHidden:!l||void 0,accessibilityRole:l?D:void 0,accessibilityLabel:l?R:void 0,children:A||null===z?null:_jsx(Text,{variant:"caption",weight:"soft"===a?"semibold":"bold",numberOfLines:1,style:[styles.text,{color:j.text,fontSize:k.text,lineHeight:Math.round(k.text*V.leading.body)},p],children:z??" "})}):null,L=u?_jsxs(View,{ref:e,style:[styles.wrapper,b],testID:y,children:[u,E]}):_jsx(View,{ref:e,style:b,testID:y,children:E});return c?_jsx(BadgeSkeleton,{...t}):L}const BadgeSkeleton=({variant:e="standard",size:t="md",children:o,anchor:r,style:i,badgeStyle:s})=>{const n=useTheme(),a=resolveBadgeSize(n,t);if("dot"===e)return _jsx(Skeleton,{shape:"circle",width:a["dot-size"],height:a["dot-size"],style:[s,i]});const l=a.height/2;if(void 0!==o){const e="topLeft"===r?{top:-a.height/2,left:-a.height/2}:"bottomRight"===r?{bottom:-a.height/2,right:-a.height/2}:"bottomLeft"===r?{bottom:-a.height/2,left:-a.height/2}:{top:-a.height/2,right:-a.height/2};return _jsxs(View,{style:[styles.wrapper,i],children:[o,_jsx(View,{style:[{position:"absolute"},e],children:_jsx(Skeleton,{width:a["min-width"]+a["padding-x"],height:a.height,radius:l,style:s})})]})}return _jsx(Skeleton,{width:a["min-width"]+a["padding-x"],height:a.height,radius:l,style:[s,i]})};BadgeSkeleton.displayName="BadgeSkeleton";const Badge=Object.assign(BadgeRoot,{Skeleton:BadgeSkeleton});Badge.displayName="Badge";const styles=StyleSheet.create({wrapper:{position:"relative",alignSelf:"flex-start"},badge:{alignItems:"center",justifyContent:"center",flexDirection:"row"},text:{textAlign:"center",includeFontPadding:!1}});export{Badge};export default Badge;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{
|
|
1
|
+
"use strict";import{useEffect,useMemo,useRef,useState}from"react";import{Animated,Platform,Pressable,StyleSheet,View}from"react-native";import{usePresenceMotion}from"../../hooks/usePresenceMotion.js";import{useMobileUiText}from"../../text/index.js";import{BANNER_TEXT}from"../../text/phone/banner.g.js";import{createAnimatedValue,useTheme}from"../../theme/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{smoothCorners}from"../../utils/corners.js";import{resolveHaptic,triggerHaptic}from"../../utils/hapticUtils.js";import{hitSlopMarker}from"../../utils/hitSlop.js";import{nativeDriver}from"../../utils/nativeDriver.js";import{renderSlotIcon}from"../AppIcon/slotIcon.js";import{IconBadge}from"../IconBadge/index.js";import{Skeleton,SkeletonText}from"../Skeleton/index.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";function BannerRoot({ref:e,...t}){const{title:r,message:n,tone:o="neutral",variant:s="bar",icon:i,actions:a,dismissible:l=!1,onClose:c,haptic:d,open:u=!0,animateMount:m=!0,loading:p=!1,accessibilityRole:g="alert",accessibilityLabel:h,labels:y,style:x,iconCircleStyle:b,tintBarStyle:f,closeButtonStyle:w,actionButtonStyle:j,testID:v}=t;assertValidValue("Banner","tone",t.tone,["primary","success","warning","danger","info","neutral"]),assertValidValue("Banner","variant",t.variant,["bar","wash","tint"]),assertValidValue("Banner","accessibilityRole",t.accessibilityRole,["alert","summary","none"]);const k=useTheme(),S=usePresenceMotion(),B=useMemo(()=>buildStyles(k),[k]),V=useMemo(()=>tintFor(k,o),[k,o]),C=useMobileUiText("banner",BANNER_TEXT),_=useMemo(()=>({...C,...y}),[C,y]),R=useMemo(()=>(a??[]).map((e,t)=>({key:`${e.label}-${t}`,action:e})),[a]),[I,T]=S.range(-20,0),M=useRef(createAnimatedValue(m&&u?I:0)).current,D=useRef(createAnimatedValue(m&&u?0:u?1:0)).current,[A,H]=useState(u),N=useRef(!0),z=useRef({animateMount:m,mounted:A,theme:k,presence:S,hiddenY:I,shownY:T,translateY:M,opacity:D});if(z.current={animateMount:m,mounted:A,theme:k,presence:S,hiddenY:I,shownY:T,translateY:M,opacity:D},useEffect(()=>{if(N.current&&(N.current=!1,!z.current.animateMount))return;let e;return u?(H(!0),e=Animated.parallel([Animated.timing(z.current.translateY,{toValue:z.current.shownY,duration:z.current.theme.motion.duration.default,useNativeDriver:nativeDriver}),Animated.timing(z.current.opacity,{toValue:1,duration:z.current.presence.duration("default"),useNativeDriver:nativeDriver})]),e.start()):z.current.mounted&&(e=Animated.parallel([Animated.timing(z.current.translateY,{toValue:z.current.hiddenY,duration:z.current.theme.motion.duration.fast,useNativeDriver:nativeDriver}),Animated.timing(z.current.opacity,{toValue:0,duration:z.current.presence.duration("fast"),useNativeDriver:nativeDriver})]),e.start(()=>{H(!1)})),()=>e?.stop()},[u]),!A)return null;const E=r??" ",L="string"==typeof n?n??" ":"",P="wash"===s,Y="bar"!==s,W="alert"===g,O=W?"danger"===o?"assertive":"polite":"none",$=_jsxs(Animated.View,{ref:e,accessibilityRole:g,..."web"===Platform.OS&&W&&"danger"!==o?{role:"status"}:null,accessibilityLiveRegion:O,accessibilityLabel:h,testID:v,style:[B.container,{backgroundColor:Y?V.soft:k.colors["bg-subtle"],borderRadius:P?k.radius.sm:k.radius.md,...smoothCorners,padding:k.space.md,opacity:D,transform:[{translateY:M}]},x],children:[!P&&k.components.banner["tint-bar-width"]>0?_jsx(View,{style:[B.tintBar,{backgroundColor:V.bar},f]}):null,_jsxs(View,{style:[B.row,void 0===r&&B.rowCentred],children:[!1===i?null:i?_jsx(View,{style:B.iconWrap,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:renderSlotIcon(i,{color:V.ink,size:k.text.xl.size,disabled:!1})}):_jsx(IconBadge,{dimension:ICON_CIRCLE_SIZE,color:V.bar,icon:_jsx(Text,{variant:"body",weight:"bold",accessible:!1,style:[B.iconGlyph,{color:V.ink}],children:V.glyph}),style:[B.iconCircle,b]}),_jsxs(View,{style:B.textBlock,children:[r||p?_jsx(Text,{variant:"body",weight:"semibold",numberOfLines:2,style:P?{color:V.ink}:void 0,children:E}):null,"string"==typeof n||p?_jsx(Text,{variant:"bodySmall",color:"secondary",style:{marginTop:r?k.space.xxs:0},children:L||" "}):_jsx(View,{style:{marginTop:r?k.space.xxs:0},children:n})]}),l?_jsx(Pressable,{accessibilityRole:"button",accessibilityLabel:_.dismiss,onPress:()=>{const e=resolveHaptic(d,"selection");e&&triggerHaptic(e),c?.()},hitSlop:8,...hitSlopMarker(8),style:({pressed:e})=>[B.closeBtn,{backgroundColor:e?k.colors["surface-pressed"]:"transparent"},w],children:_jsx(Text,{variant:"title",weight:"bold",color:"secondary",accessible:!1,style:{lineHeight:Math.round(k.text.lg.size*k.leading.heading)},children:"×"})}):null]}),a&&a.length>0?_jsx(View,{style:B.actionsRow,children:R.map(({key:e,action:t})=>{assertValidValue("Banner","action.tone",t.tone,["primary","success","warning","danger","info","neutral"]),assertValidValue("Banner","action.variant",t.variant,["solid","outline","ghost"]),assertValidValue("Banner","action.size",t.size,["sm","md"]);const r=t.tone??"primary",n=t.variant??"ghost",o="primary"===r?V.glyphColor:"neutral"===r?k.colors["text-muted"]:k.colors[r],s="primary"===r?V.ink:"neutral"===r?k.colors["text-muted"]:k.colors[`${r}-text`],i="primary"===r?V.on:"neutral"===r?k.colors["on-neutral-strong"]:k.colors[`on-${r}`],a="solid"===n;return _jsx(Pressable,{accessibilityRole:"button",accessibilityLabel:t.label,testID:t.testID,onPress:()=>{const e=resolveHaptic(d,"selection");e&&triggerHaptic(e),t.onPress()},style:({pressed:e})=>[B.actionBtn,"md"===t.size&&B.actionBtnMd,"outline"===n&&{borderWidth:1,borderColor:s},{backgroundColor:a?o:e?k.colors["surface-pressed"]:"transparent",opacity:a&&e?.85:1},j],children:_jsx(Text,{variant:"bodySmall",weight:"semibold",align:"center",style:{color:a?i:s},children:t.label})},e)})}):null]});return p?_jsx(BannerSkeleton,{...t}):$}const BannerSkeleton=({title:e,actions:t,icon:r,style:n})=>{const o=useTheme(),s=!1!==r,i=t?.length??0,a=useMemo(()=>Array.from({length:i},(e,t)=>({key:`sk-banner-action-${t}`})),[i]);return _jsxs(View,{style:[{flexDirection:"row",alignItems:"flex-start",backgroundColor:o.colors.surface,borderRadius:o.radius.md,...smoothCorners,padding:o.space.md,borderWidth:1,borderColor:o.colors.border},n],accessibilityRole:"progressbar",accessibilityState:{busy:!0},"aria-busy":!0,children:[s?_jsx(View,{style:{marginRight:o.space.sm},children:_jsx(Skeleton,{shape:"circle",width:32,height:32})}):null,_jsxs(View,{style:{flex:1},children:[void 0!==e?_jsx(Skeleton,{shape:"text",width:"55%",height:16,style:{marginBottom:o.space.xs}}):null,_jsx(SkeletonText,{lines:2,fontSize:o.text.sm.size,lastLineWidth:"70%"}),t&&t.length>0?_jsx(View,{style:{flexDirection:"row",marginTop:o.space.sm},children:a.map(e=>_jsx(Skeleton,{width:72,height:28,shape:"rounded",style:{marginRight:o.space.sm}},e.key))}):null]})]})};BannerSkeleton.displayName="BannerSkeleton";const Banner=Object.assign(BannerRoot,{Skeleton:BannerSkeleton});Banner.displayName="Banner";const tintFor=(e,t)=>{switch(t){case"success":return{soft:e.colors["success-soft"],bar:e.colors.success,glyphColor:e.colors.success,ink:e.colors["success-text"],on:e.colors["on-success"],glyph:"✓"};case"warning":return{soft:e.colors["warning-soft"],bar:e.colors.warning,glyphColor:e.colors.warning,ink:e.colors["warning-text"],on:e.colors["on-warning"],glyph:"⚠"};case"danger":return{soft:e.colors["danger-soft"],bar:e.colors.danger,glyphColor:e.colors.danger,ink:e.colors["danger-text"],on:e.colors["on-danger"],glyph:"✗"};case"neutral":return{soft:e.colors["bg-subtle"],bar:e.colors["text-subtle"],glyphColor:e.colors["text-muted"],ink:e.colors["text-muted"],on:e.colors["on-neutral-strong"],glyph:"i"};case"primary":return{soft:e.colors["primary-soft"],bar:e.colors.primary,glyphColor:e.colors.primary,ink:e.colors["primary-text"],on:e.colors["on-primary"],glyph:"i"};case"info":return{soft:e.colors["info-soft"],bar:e.colors.info,glyphColor:e.colors.info,ink:e.colors["info-text"],on:e.colors["on-info"],glyph:"i"};default:return tintFor(e,"neutral")}},ICON_CIRCLE_SIZE=28,buildStyles=e=>{const t=e.components.banner,r=e.space.sm;return StyleSheet.create({container:{overflow:"hidden",paddingLeft:e.space.md},tintBar:{position:"absolute",left:0,top:0,bottom:0,width:t["tint-bar-width"]},row:{flexDirection:"row",alignItems:"flex-start"},rowCentred:{alignItems:"center"},iconWrap:{marginRight:r},iconCircle:{marginRight:r},iconGlyph:{lineHeight:Math.round(e.text.base.size*e.leading.heading)},textBlock:{flex:1,paddingRight:e.space.xs},closeBtn:{width:28,height:28,borderRadius:e.radius.pill,...smoothCorners,alignItems:"center",justifyContent:"center",marginLeft:e.space.xxs},actionsRow:{flexDirection:"row",flexWrap:"wrap",justifyContent:"flex-end",marginTop:e.space.xs,columnGap:e.space.xs,rowGap:e.space.xs},actionBtn:{paddingHorizontal:e.space.sm,paddingVertical:e.space.xs,borderRadius:e.radius.sm,...smoothCorners,maxWidth:"100%",alignItems:"center",justifyContent:"center"},actionBtnMd:{minHeight:44,paddingHorizontal:e.space.md}})};export{Banner};export default Banner;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{formatCompactNumber,formatNumber}from"@webority/mobile-core";import{
|
|
1
|
+
"use strict";import{formatCompactNumber,formatNumber}from"@webority/mobile-core";import{useCallback,useMemo,useRef,useState}from"react";import{StyleSheet,View}from"react-native";import{GestureDetector,useCompetingGestures,usePanGesture,useTapGesture}from"react-native-gesture-handler";import{useControllableState}from"../../hooks/index.js";import{fillText,useMobileUiText}from"../../text/index.js";import{BAR_CHART_TEXT}from"../../text/phone/barChart.g.js";import{useTheme}from"../../theme/index.js";import{resolveHaptic,triggerHaptic}from"../../utils/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{smoothCorners}from"../../utils/corners.js";import{Text}from"../Text/index.js";import{barScale}from"./scale.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";const AUTO_VALUES_MAX_BARS=7,MAX_BAR_WIDTH=40,BAR_SHARE=.6,MIN_BAR_HEIGHT=2,VALUE_LABEL_ROOM=20,PLOT_PAD=6,HEADER_MIN_HEIGHT=48,AXIS_LABEL_MIN_WIDTH=44,CHAR_WIDTH=8,SWATCH_SIZE=10,STACK_TONES=["primary","info","success","warning","danger","neutral"],FONT_SCALE_CAP=1.2,toneColor=(e,t)=>"neutral"===t?e.colors["text-muted"]:e.colors[`${t}-text`],safe=e=>"number"==typeof e&&Number.isFinite(e)?e:0,entryAt=(e,t)=>{const r=e[t];if(void 0===r)throw new Error(`BarChart has no entry at index ${t}.`);return r},defaultFormatValue=e=>formatNumber(e),defaultFormatTick=e=>formatCompactNumber(e);function BarChart({ref:e,...t}){const{data:r,tone:s="primary",color:a,series:i,height:l=160,label:o,summary:n,formatValue:c=defaultFormatValue,formatTick:u=defaultFormatTick,showValues:m,selection:d,defaultSelection:h=null,onSelect:x,haptic:p,labels:b,style:y,testID:f}=t;assertValidValue("BarChart","tone",t.tone,["primary","success","warning","danger","info","neutral"]);const g=useMobileUiText("barChart",BAR_CHART_TEXT),_=useMemo(()=>({...g,...b}),[g,b]),A=useTheme(),T=r.length,[C,M]=useState(0),[j,S]=useControllableState({value:d,defaultValue:h,onChange:x}),w=null!==j&&j>=0&&j<T?j:null,v=useRef(w);v.current=w;const V=useRef(-1),R=resolveHaptic(p,"tick"),k=useCallback(()=>{R&&triggerHaptic(R)},[R]),D=m??(T>0&&T<=7),L=void 0!==i&&i.length>0,$=useMemo(()=>L?i.map((e,t)=>e.tone??entryAt(STACK_TONES,t%STACK_TONES.length)):[],[L,i]),I=useMemo(()=>L?i.map(e=>e.key):[],[L,i]),E=useMemo(()=>L?r.map(e=>i.map(t=>safe(e.values?.[t.key]))):null,[r,i,L]),B=useMemo(()=>E?E.map(e=>e.reduce((e,t)=>e+t,0)):r.map(e=>safe(e.value)),[r,E]),H=useMemo(()=>E?E.flatMap(e=>[e.reduce((e,t)=>t>0?e+t:e,0),e.reduce((e,t)=>t<0?e+t:e,0)]):B,[E,B]),O=useMemo(()=>barScale(H),[H]),F=D?20:6,N=D&&O.min<0?20:6,G=Math.max(1,l-F-N),W=useCallback(e=>F+(O.max-e)/(O.max-O.min)*G,[F,O.max,O.min,G]),U=W(0),X=useMemo(()=>O.ticks.map(e=>u(e)),[O.ticks,u]),P=Math.ceil(8*Math.max(...X.map(e=>e.length),1)*1.2)+A.space.xs,z=T>0?C/T:0,K=Math.max(1,Math.ceil(44/Math.max(1,z||44))),J=useMemo(()=>r.map((e,t)=>({key:`axis-${t}`,d:e,index:t})),[r]),Y=useCallback(e=>{const t=entryAt(r,e);if(t.accessibilityLabel)return t.accessibilityLabel;if(E&&i){const r=entryAt(E,e);return`${t.label}, ${i.map((e,t)=>`${e.label} ${c(entryAt(r,t))}`).join(", ")}`}return`${t.label}, ${c(entryAt(B,e))}`},[r,c,B,E,i]),Z=useMemo(()=>{let e=-1,t=0;for(const[r,s]of B.entries())(-1===e||s>t)&&(e=r,t=s);return e},[B]),q=n??(Z>=0?fillText(_.highest,{label:entryAt(r,Z).label,value:c(entryAt(B,Z))}):""),Q=useRef({fire:k,setSelected:S,count:T,plotWidth:C});Q.current={fire:k,setSelected:S,count:T,plotWidth:C};const ee=useCallback(e=>{const{count:t,plotWidth:r}=Q.current;return 0===t||r<=0||!Number.isFinite(e)?-1:Math.min(t-1,Math.max(0,Math.floor(e/r*t)))},[]),te=useCallback(e=>{const t=ee(e);t<0||t===V.current||(V.current=t,Q.current.fire(),Q.current.setSelected(t))},[ee]),re=useMemo(()=>({runOnJS:!0,activeOffsetX:[-8,8],failOffsetY:[-12,12],onActivate:e=>{V.current=v.current??-1,te(e.x)},onUpdate:e=>te(e.x),testID:f?`${f}-pan`:"bar-chart-pan"}),[te,f]),se=usePanGesture(re),ae=useMemo(()=>({runOnJS:!0,onDeactivate:e=>{if(e.canceled)return;const t=ee(e.x);t<0||(Q.current.fire(),V.current=t,Q.current.setSelected(t===v.current?null:t))},testID:f?`${f}-tap`:"bar-chart-tap"}),[ee,f]),ie=useTapGesture(ae),le=useCompetingGestures(se,ie),oe=useCallback(e=>{if(0===T)return;const t=v.current,r="increment"===e.nativeEvent.actionName?null===t?0:Math.min(T-1,t+1):null===t?T-1:Math.max(0,t-1);r!==t&&(k(),S(r))},[T,k,S]),ne=useCallback(e=>{const t=Math.round(e.nativeEvent.layout.width);M(e=>e===t?e:t)},[]),ce=a??toneColor(A,s),ue=A.radius.sm,me=o??_.chart,de=0===T?`${me}, ${_.noData}`:q?`${me}, ${q}`:me,he=null===w?q:Y(w),xe=Math.min(40,Math.max(4,.6*z)),renderStack=(e,t,r)=>{const s=e.reduce((e,t)=>t>0?e+t:e,0),a=e.reduce((e,t)=>t<0?e+t:e,0);if(0===s&&0===a)return null;const i=W(s),l=[];let o=0,n=0;return e.forEach((e,r)=>{if(0===e)return;const s=e>0?o:n,a=s+e;e>0?o=a:n=a;const c=W(s),u=W(a);l.push(_jsx(View,{testID:f?`${f}-bar-${t}-series-${r}`:void 0,style:{position:"absolute",left:0,right:0,top:Math.min(c,u)-i,height:Math.abs(c-u),backgroundColor:toneColor(A,entryAt($,r))}},entryAt(I,r)))}),_jsx(View,{testID:f?`${f}-bar-${t}`:void 0,style:{position:"absolute",left:(z-xe)/2,top:i,width:xe,height:Math.max(2,W(a)-i),overflow:"hidden",opacity:r?.4:1,...smoothCorners,...s>0?{borderTopLeftRadius:ue,borderTopRightRadius:ue}:null,...a<0?{borderBottomLeftRadius:ue,borderBottomRightRadius:ue}:null},children:l})},pe=useMemo(()=>B.map((e,t)=>({key:`bar-${t}`,value:e,index:t})),[B]).map(({key:e,value:t,index:r})=>{const s=W(t),a=t>=0?s:U,i=0===t?0:Math.max(2,Math.abs(s-U)),o=null!==w&&w!==r;return _jsxs(View,{style:[styles.slot,{height:l}],children:[C>0&&E?renderStack(entryAt(E,r),r,o):null,C>0&&!E&&i>0?_jsx(View,{testID:f?`${f}-bar-${r}`:void 0,style:{position:"absolute",left:(z-xe)/2,top:a,width:xe,height:i,backgroundColor:ce,opacity:o?.4:1,...smoothCorners,...t>=0?{borderTopLeftRadius:ue,borderTopRightRadius:ue}:{borderBottomLeftRadius:ue,borderBottomRightRadius:ue}}}):null,D&&C>0?_jsx(Text,{variant:"caption",color:"secondary",align:"center",numberOfLines:1,maxFontSizeMultiplier:1.2,style:{position:"absolute",left:0,right:0,top:t>=0?(E?W(entryAt(H,2*r)):s)-20+2:(E?W(entryAt(H,2*r+1)):s)+2},children:u(t)}):null]},e)});return 0===T?_jsx(View,{ref:e,accessible:!0,accessibilityRole:"image",accessibilityLabel:de,testID:f,style:[styles.root,y],children:_jsx(Text,{variant:"bodySmall",color:"secondary",children:_.noDataLabel})}):_jsxs(View,{ref:e,accessible:!0,accessibilityRole:"adjustable",accessibilityLabel:de,accessibilityValue:{min:0,max:T-1,now:w??0,text:he},accessibilityActions:[{name:"increment"},{name:"decrement"}],onAccessibilityAction:oe,testID:f,style:[styles.root,y],children:[_jsx(View,{style:[styles.header,{minHeight:48,marginBottom:A.space.sm}],children:null===w?q?_jsx(Text,{variant:"bodySmall",color:"secondary",children:q}):null:_jsxs(_Fragment,{children:[_jsx(Text,{variant:"caption",color:"secondary",numberOfLines:1,children:entryAt(r,w).label}),_jsx(Text,{variant:"h3",numberOfLines:1,testID:f?`${f}-callout`:void 0,children:c(entryAt(B,w))})]})}),_jsxs(View,{style:styles.body,children:[_jsx(View,{style:{width:P,height:l},children:O.ticks.map((e,t)=>_jsx(Text,{variant:"caption",color:"tertiary",align:"right",numberOfLines:1,maxFontSizeMultiplier:1.2,style:{position:"absolute",right:A.space.xs,left:0,top:W(e)-8},children:entryAt(X,t)},e))}),_jsxs(View,{style:styles.plotColumn,children:[_jsx(GestureDetector,{gesture:le,children:_jsxs(View,{style:{height:l},onLayout:ne,testID:f?`${f}-plot`:void 0,children:[O.ticks.map(e=>_jsx(View,{pointerEvents:"none",style:{position:"absolute",left:0,right:0,top:W(e)-(0===e?.75:StyleSheet.hairlineWidth),height:0===e?1.5:2*StyleSheet.hairlineWidth,backgroundColor:0===e?A.colors["text-subtle"]:A.colors["border-subtle"]}},e)),_jsx(View,{style:[styles.slots,{height:l}],children:pe})]})}),_jsx(View,{style:styles.axis,children:J.map(({key:e,d:t,index:r})=>_jsx(View,{style:styles.axisSlot,children:r%K===0?_jsx(Text,{variant:"caption",color:w===r?"primary":"tertiary",weight:w===r?"semibold":void 0,align:"center",numberOfLines:1,maxFontSizeMultiplier:1.2,style:z>0?{width:z*K}:void 0,children:t.axisLabel??t.label}):null},e))})]})]}),i&&L?_jsx(View,{style:[styles.legend,{marginTop:A.space.sm,columnGap:A.space.md,rowGap:A.space.xs}],children:i.map((e,t)=>_jsxs(View,{style:[styles.legendItem,{columnGap:A.space.xs}],children:[_jsx(View,{style:{width:10,height:10,borderRadius:A.radius.sm,...smoothCorners,backgroundColor:toneColor(A,entryAt($,t))}}),_jsx(Text,{variant:"caption",color:"secondary",numberOfLines:1,maxFontSizeMultiplier:1.2,children:e.label})]},e.key))}):null]})}const styles=StyleSheet.create({root:{alignSelf:"stretch"},header:{justifyContent:"center"},body:{flexDirection:"row"},plotColumn:{flex:1},slots:{flexDirection:"row"},slot:{flex:1},axis:{flexDirection:"row"},legend:{flexDirection:"row",flexWrap:"wrap"},legendItem:{flexDirection:"row",alignItems:"center"},axisSlot:{flex:1,alignItems:"center",overflow:"visible"}});export{BarChart};export default BarChart;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import React,{forwardRef,useEffect,useMemo,useRef}from"react";import{Animated,LayoutAnimation,Platform,Pressable,StyleSheet,View}from"react-native";import{useSafeAreaInsets}from"react-native-safe-area-context";import{useReducedMotion}from"../../hooks/useReducedMotion.js";import{fillText,useMobileUiText}from"../../text/index.js";import{BOTTOM_NAVIGATION_TEXT}from"../../text/phone/bottomNavigation.g.js";import{createAnimatedValue,useTheme}from"../../theme/index.js";import{triggerHaptic}from"../../utils/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{smoothCorners}from"../../utils/corners.js";import{hitSlopMarker}from"../../utils/hitSlop.js";import{nativeDriver}from"../../utils/nativeDriver.js";import{supportsBoxShadow,toBoxShadow}from"../../utils/shadows.js";import{renderSlotIcon}from"../AppIcon/index.js";import{Badge}from"../Badge/index.js";import{Text}from"../Text/index.js";import{useScreenReaderEnabled}from"./useScreenReaderEnabled.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";const DEFAULT_ICON_SIZE=18,DEFAULT_LABEL_MAX_FONT_SCALE=1.2,ICON_WRAP_AIR=4,PILL_AIR=8,DEFAULT_PILL_MAX_WIDTH=64,TILE_MAX_WIDTH=96,DEFAULT_UNDERLINE_HEIGHT=3,DEFAULT_BUBBLE_SIZE=48,DEFAULT_BUBBLE_LIFT=14,DEFAULT_CENTER_SIZE=48,DEFAULT_CENTER_ICON_SIZE=24,CENTER_KEY="__center_action__",EXPANDED_FLEX=1.5,SOLID_INACTIVE_OPACITY=.7,TILE_INSET=2,badgeVariantOf=e=>null==e||!1===e?null:!0===e||"·"===e?"dot":"number"==typeof e?e>0?"standard":null:e.length>0?"standard":null,badgeAccessibilitySuffix=(e,t)=>null==e||!1===e?"":"number"==typeof e?e>0?`, ${fillText(t.unread,{count:e})}`:"":!0===e||"·"===e?`, ${t.newUpdates}`:"string"==typeof e&&e.length>0?`, ${e}`:"",BottomNavigation=forwardRef((e,t)=>{const{tabs:i,centerAction:o,activeTab:n,onChange:a,haptic:r="selection",showLabels:s=!0,variant:l="pill",indicatorPosition:d="bottom",radius:c,indicatorRadius:u="auto",elevation:p,iconSize:m,marginHorizontal:h,marginVertical:g,paddingHorizontal:b,paddingVertical:f,border:x,minimizeOnScroll:y=!1,scrollDirection:v="idle",accessory:_,style:S,indicatorStyle:w,labelStyle:E,labelMaxFontScale:I,labels:R,testID:T}=e;assertValidValue("BottomNavigation","variant",e.variant,["pill","underline","floating","bubble","expand","solid","tile"]),assertValidValue("BottomNavigation","indicatorPosition",e.indicatorPosition,["top","bottom"]);const A=useMobileUiText("bottomNavigation",BOTTOM_NAVIGATION_TEXT),j=useMemo(()=>R?{...A,...R}:A,[A,R]),V=useTheme(),M=useSafeAreaInsets(),C=useMemo(()=>buildStyles(V),[V]),L=m??18,D=L+4+8,B=V.space.lg,k=V.space.lg,N=V.radius.xl,P=useReducedMotion(),z=useScreenReaderEnabled(y),[F,H]=React.useState(null);useEffect(()=>{null!==F&&F!==v&&H(null)},[F,v]);const O=y&&!z&&"down"===v&&null===F,[W,U]=React.useState(O);useEffect(()=>{W!==O&&(P||"web"===Platform.OS||LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut),U(O))},[W,O,P]);const X="function"==typeof _?_({minimized:W}):_,$=null!=X&&!1!==X,Z=W&&$,[G,Y]=React.useState(0),K=$&&!Z?G+V.space.xs:0,q="tile"===l,J="floating"===l||q,Q="bubble"===l,ee="expand"===l,te="solid"===l,ie="pill"===l||J||te,oe=Math.max(0,i.findIndex(e=>e.key===n)),[ne,ae]=React.useState(0),[re,se]=React.useState(0),le=o?Math.ceil(i.length/2):i.length,de=i.length+(o?1:0),[ce,ue]=React.useState({width:0,height:0}),pe=o?.size??48,me=void 0!==o?.gap,he=Math.max(0,o?.gap??0),ge=me?(ce.width||pe)+2*he:0,be=me?i.length>0?Math.max(0,ne-ge)/i.length:0:de>0?ne/de:0,fe=me?ge:be,xe=useRef(createAnimatedValue(oe)).current,ye=useRef({}),ve=useRef({});i.forEach(e=>{ye.current[e.key]||(ye.current[e.key]=new Animated.Value(1)),ve.current[e.key]||(ve.current[e.key]=createAnimatedValue(e.key===n?1:0))});const Se=be>0?q?Math.min(be-4,96):Math.min(be-B,64):0,we=be>0?(be-Se)/2:0,Ee=be>0?(be-48)/2:0,hasLabel=e=>s&&!W&&!1!==e.showLabel&&e.label.trim().length>0,Ie=i[oe],Re=Ie&&!hasLabel(Ie)&&re>0?re/2:V.space.xs+(L+4)/2,Te=Re-14-24,Ae=Math.max(0,re-4),je=q?2:Re-D/2,Ve=useRef(oe);useEffect(()=>{if(Ve.current===oe)return;Ve.current=oe;const e=Animated.spring(xe,{toValue:oe,tension:120,friction:14,useNativeDriver:nativeDriver});return e.start(),()=>e.stop()},[oe,xe]);const Me=Math.max(1,i.length-1),Ce=useMemo(()=>{const e=[],t=[];for(let i=0;i<=Me;i++)e.push(i),t.push(i<le?i*be:i*be+fe);return xe.interpolate({inputRange:e,outputRange:t})},[xe,Me,le,be,fe]),Le=i.map(e=>e.key).join(" "),De=Q||ee;useEffect(()=>{const e=Le.split(" ").flatMap(e=>{const t=e===n?1:0,i=ve.current[e];return i?De?[Animated.spring(i,{toValue:t,tension:140,friction:13,useNativeDriver:!1})]:(i.setValue(t),[]):[]});if(0===e.length)return;const t=Animated.parallel(e);return t.start(),()=>t.stop()},[n,Le,De]);const popIcon=e=>{Animated.sequence([Animated.timing(e,{toValue:1.15,duration:120,useNativeDriver:nativeDriver}),Animated.spring(e,{toValue:1,tension:200,friction:8,useNativeDriver:nativeDriver})]).start()},Be=useRef(new Animated.Value(1)).current,{colors:ke}=V,Ne=te?ke.primary:ke.surface,Pe=te?ke["on-primary"]:ke.primary,ze=te?ke["on-primary"]:q?ke["text-body"]:ke["text-subtle"],Fe=te?ke["on-primary"]:ke["primary-soft"],He=te?ke.primary:Q?ke["on-primary"]:Pe,Oe=h??k,We=g??(J?k:0),Ue=We>0,Xe=f??V.space.sm,$e=b??(J?V.space.sm:V.space.xs),Ze=Ue?Xe:Math.max(Xe,M.bottom),Ge=Ue?Math.max(We,M.bottom>0?M.bottom+V.space.sm:0):0,Ye="pill"===c,Ke=J?re+K+2*Xe+2*StyleSheet.hairlineWidth:re+K+Xe+Ze,qe=Ye?re>0?Ke/2:V.radius.pill:c??(q?V.radius.pill:J?N:V.radius.none),Je=void 0!==c,activeBgRadius=(e,t)=>"number"==typeof u?Math.max(0,Math.min(u,e/2)):"auto"===u&&Je?Math.min(qe,e/2):t,Qe="underline"===l?Math.max($e,Ye&&0===re?0:qe):$e,et=p??"none",tt="none"===et?void 0:V.shadow[et],it=void 0===tt?null:supportsBoxShadow()?{boxShadow:toBoxShadow(tt)}:tt,ot=x?StyleSheet.hairlineWidth:0,nt=te?ke.primary:ke.border,at=o?.lift??0,rt=Xe+ot+K,st=o&&re>0?Math.max(0,(ce.height||pe)/2+at-re/2-rt):0,lt=o?_jsx(View,{style:[C.centerCell,me?{flex:0,marginHorizontal:he}:null],pointerEvents:"box-none",children:_jsxs(Pressable,{onPress:()=>{if(!o)return;const e=o.haptic??r;!1!==e&&triggerHaptic(e),popIcon(Be),o.onPress()},onLayout:e=>{const{width:t,height:i}=e.nativeEvent.layout;ue(e=>e.width===t&&e.height===i?e:{width:t,height:i})},accessibilityRole:"button",accessibilityLabel:o.label,hitSlop:{top:6,bottom:6,left:6,right:6},...hitSlopMarker({top:6,bottom:6,left:6,right:6}),style:({pressed:e})=>[C.centerPressable,{top:-at},e?{opacity:.85}:null],testID:o.testID??(T?`${T}-center`:void 0),children:[o.content?_jsx(Animated.View,{style:{transform:[{scale:Be}]},children:o.content}):_jsx(View,{style:[C.centerCircle,{width:pe,height:pe,borderRadius:V.radius.pill,...smoothCorners,backgroundColor:o.color??ke.primary}],children:_jsx(Animated.View,{style:{transform:[{scale:Be}]},children:renderSlotIcon(o.icon??"add",{color:o.iconColor??ke["on-primary"],size:o.iconSize??24,disabled:!1})})}),(dt=o,s&&!W&&dt.label.trim().length>0?_jsx(Text,{variant:"caption",numberOfLines:1,maxFontSizeMultiplier:I??V.settings.maxFontSizeMultiplier??1.2,style:[C.label,{color:ze,opacity:te?.7:1},E],children:o.label}):null)]})},CENTER_KEY):null;var dt;const ct=$?_jsx(View,{style:Z?C.accessoryInline:C.accessoryStacked,onLayout:e=>Y(e.nativeEvent.layout.height),testID:T?`${T}-accessory`:void 0,children:X}):null,ut=_jsxs(View,{style:Z?[C.tabRow,C.tabRowInline]:C.tabRow,onLayout:e=>{const{width:t,height:i}=e.nativeEvent.layout;ae(t),se(i)},children:[ie&&Se>0&&(!q||Ae>0)?_jsx(Animated.View,{pointerEvents:"none",style:[C.pill,{width:Se,height:q?Ae:D,left:we,top:je,backgroundColor:Fe,borderRadius:q?activeBgRadius(Ae,Ae/2):activeBgRadius(D,V.radius.pill),...smoothCorners,transform:[{translateX:Ce}]},w]}):null,Q&&be>0?_jsx(Animated.View,{pointerEvents:"none",style:[C.bubble,V.shadow.elevated,{width:48,height:48,borderRadius:V.radius.pill,...smoothCorners,left:Ee,top:Te,backgroundColor:ke.primary,borderColor:ke.surface,transform:[{translateX:Ce}]},w]}):null,(pt=i.map(e=>{const t=e.key===n,i=t?Pe:ze,o=t?He:ze,s="string"==typeof e.icon?{name:e.icon,variant:"bold"}:e.icon,l=t?e.activeIcon??s:e.icon,d=ye.current[e.key],c=ve.current[e.key];if(void 0===d||void 0===c)throw new Error(`BottomNavigation has no animation values for tab "${e.key}".`);const u=badgeVariantOf(e.badge??null),p=badgeAccessibilitySuffix(e.badge??null,j),m=te&&!t?.7:1,h=Q&&t||te?ke.primary:ke.surface,g=hasLabel(e),b=g&&(!ee||t),f=_jsxs(Animated.View,{style:[C.iconWrap,{width:L+4,height:L+4,opacity:m,transform:[{scale:d}]}],children:[_jsx(View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:renderSlotIcon(l,{color:o,size:L,focused:t,disabled:!1})}),u?_jsx(Badge,{variant:u,value:"standard"!==u||"number"!=typeof e.badge&&"string"!=typeof e.badge?void 0:e.badge,tone:"danger",accessible:!1,style:"dot"===u?C.badgeDotPosition:C.badgePillPosition,badgeStyle:["dot"===u?C.badgeDot:C.badgePill,{borderColor:h}],textStyle:C.badgeText}):null]}),x=Q?_jsx(Animated.View,{style:{top:c.interpolate({inputRange:[0,1],outputRange:[0,-14]})},children:f}):f,y=b?_jsx(Animated.Text,{numberOfLines:1,maxFontSizeMultiplier:I??V.settings.maxFontSizeMultiplier??1.2,style:[C.label,ee?C.labelInline:null,{color:i,opacity:ee?c:m,fontWeight:t?V.weight.semibold:V.weight.normal},E],children:e.label}):null,_=_jsx(Pressable,{onPress:()=>(e=>{W&&H(v),e.key!==n&&!1!==r&&triggerHaptic(r);const t=ye.current[e.key];t&&popIcon(t),a(e.key)})(e),accessibilityRole:"tab",accessibilityState:{selected:t},"aria-selected":t,accessibilityLabel:`${e.label}${p}`,accessibilityHint:fillText(j.switchesTo,{label:e.label}),hitSlop:{top:6,bottom:6,left:6,right:6},...hitSlopMarker({top:6,bottom:6,left:6,right:6}),style:({pressed:e})=>[C.tab,q?C.tabTile:null,e?{opacity:.85}:null],testID:T?`${T}-tab-${e.key}`:void 0,children:ee?_jsxs(View,{style:[C.expandPill,{height:D,paddingHorizontal:t&&g?V.space.md:Math.max(0,(D-(L+4))/2)}],children:[_jsx(View,{pointerEvents:"none",style:[C.expandFill,{borderRadius:activeBgRadius(D,D/2),...smoothCorners,backgroundColor:t?ke["primary-soft"]:"transparent"},t?w:null]}),x,y]}):_jsxs(_Fragment,{children:[x,y]})},e.key);return ee?_jsx(Animated.View,{style:{flex:c.interpolate({inputRange:[0,1],outputRange:[1,g?1.5:1]})},children:_},e.key):_}),lt?[...pt.slice(0,le),lt,...pt.slice(le)]:pt),"underline"===l&&be>0?_jsx(Animated.View,{pointerEvents:"none",style:[C.underline,"top"===d?C.underlineTop:C.underlineBottom,"top"===d?{top:-Xe-K}:{bottom:-Xe},{width:be,height:3,backgroundColor:ke.primary,transform:[{translateX:Ce}]},w]}):null]});var pt;return _jsx(View,{ref:t,testID:T,accessibilityRole:"tablist",style:[C.outer,{paddingHorizontal:Oe,paddingTop:Math.max(We,st),paddingBottom:Ge},S],children:_jsxs(View,{style:[J?C.floatingBar:C.dockedBar,Z?C.barInline:null,it,{backgroundColor:Ne,borderColor:nt,borderRadius:qe,...smoothCorners},J?{borderWidth:ot,paddingHorizontal:$e,paddingVertical:Xe}:{borderTopWidth:ot,borderBottomWidth:ot,borderLeftWidth:ot,borderRightWidth:ot,paddingHorizontal:Qe,paddingTop:Xe,paddingBottom:Ze}],children:[ct,ut]})})});BottomNavigation.displayName="BottomNavigation";const buildStyles=e=>StyleSheet.create({outer:{backgroundColor:"transparent"},dockedBar:{paddingHorizontal:e.space.xs},floatingBar:{paddingVertical:e.space.sm,paddingHorizontal:e.space.sm},tabRow:{flexDirection:"row",alignItems:"stretch",position:"relative"},tabRowInline:{flex:1},barInline:{flexDirection:"row",alignItems:"center"},accessoryStacked:{marginBottom:e.space.xs},accessoryInline:{flexShrink:0,marginRight:e.space.xs},tab:{flex:1,minHeight:44,alignItems:"center",justifyContent:"center",paddingVertical:e.space.xs,gap:e.space.xs},tabTile:{paddingVertical:e.space.sm,gap:e.space.xxs},centerCell:{flex:1,minHeight:44,alignItems:"center",justifyContent:"center"},centerPressable:{alignItems:"center",maxWidth:"100%",gap:e.space.xs},centerCircle:{alignItems:"center",justifyContent:"center"},iconWrap:{alignItems:"center",justifyContent:"center",position:"relative"},label:{fontSize:e.text.xs.size,lineHeight:e.text.xs.size*e.leading.heading,textAlign:"center",includeFontPadding:!1},labelInline:{fontSize:e.text.sm.size,lineHeight:e.text.sm.size*e.leading.heading,flexShrink:1,includeFontPadding:!1},expandPill:{flexDirection:"row",alignItems:"center",justifyContent:"center",gap:e.space.xs},expandFill:{position:"absolute",top:0,right:0,bottom:0,left:0,overflow:"hidden"},pill:{position:"absolute",left:0},bubble:{position:"absolute",left:0,borderWidth:3},underline:{position:"absolute",left:0,height:3},underlineBottom:{borderTopLeftRadius:e.radius.none,borderTopRightRadius:e.radius.none,...smoothCorners},underlineTop:{borderBottomLeftRadius:e.radius.none,borderBottomRightRadius:e.radius.none,...smoothCorners},badgePillPosition:{position:"absolute",top:-4,right:-8},badgePill:{minWidth:18,height:18,paddingHorizontal:e.space.xs,paddingVertical:e.space.xxs,borderWidth:1.5},badgeDotPosition:{position:"absolute",top:-2,right:-2},badgeDot:{width:10,height:10,borderRadius:e.radius.pill,borderWidth:1.5},badgeText:{lineHeight:Math.round(e.text.xs.size*e.leading.heading)}});export{BottomNavigation};export default BottomNavigation;
|
|
1
|
+
"use strict";import React,{useEffect,useMemo,useRef}from"react";import{Animated,LayoutAnimation,Platform,Pressable,StyleSheet,View}from"react-native";import{useSafeAreaInsets}from"react-native-safe-area-context";import{useReducedMotion}from"../../hooks/useReducedMotion.js";import{fillText,useMobileUiText}from"../../text/index.js";import{BOTTOM_NAVIGATION_TEXT}from"../../text/phone/bottomNavigation.g.js";import{createAnimatedValue,useTheme}from"../../theme/index.js";import{triggerHaptic}from"../../utils/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{smoothCorners}from"../../utils/corners.js";import{hitSlopMarker}from"../../utils/hitSlop.js";import{nativeDriver}from"../../utils/nativeDriver.js";import{supportsBoxShadow,toBoxShadow}from"../../utils/shadows.js";import{renderSlotIcon}from"../AppIcon/index.js";import{Badge}from"../Badge/index.js";import{Text}from"../Text/index.js";import{useScreenReaderEnabled}from"./useScreenReaderEnabled.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";const DEFAULT_ICON_SIZE=18,DEFAULT_LABEL_MAX_FONT_SCALE=1.2,ICON_WRAP_AIR=4,PILL_AIR=8,DEFAULT_PILL_MAX_WIDTH=64,TILE_MAX_WIDTH=96,DEFAULT_UNDERLINE_HEIGHT=3,DEFAULT_BUBBLE_SIZE=48,DEFAULT_BUBBLE_LIFT=14,DEFAULT_CENTER_SIZE=48,DEFAULT_CENTER_ICON_SIZE=24,CENTER_KEY="__center_action__",EXPANDED_FLEX=1.5,SOLID_INACTIVE_OPACITY=.7,TILE_INSET=2,badgeVariantOf=e=>null==e||!1===e?null:!0===e||"·"===e?"dot":"number"==typeof e?e>0?"standard":null:e.length>0?"standard":null,badgeAccessibilitySuffix=(e,t)=>null==e||!1===e?"":"number"==typeof e?e>0?`, ${fillText(t.unread,{count:e})}`:"":!0===e||"·"===e?`, ${t.newUpdates}`:"string"==typeof e&&e.length>0?`, ${e}`:"";function BottomNavigation({ref:e,...t}){const{tabs:i,centerAction:n,activeTab:o,onChange:a,haptic:r="selection",showLabels:s=!0,variant:l="pill",indicatorPosition:d="bottom",radius:c,indicatorRadius:u="auto",elevation:p,iconSize:m,marginHorizontal:h,marginVertical:g,paddingHorizontal:b,paddingVertical:f,border:x,minimizeOnScroll:y=!1,scrollDirection:_="idle",accessory:v,style:S,indicatorStyle:w,labelStyle:E,labelMaxFontScale:I,labels:R,testID:T}=t;assertValidValue("BottomNavigation","variant",t.variant,["pill","underline","floating","bubble","expand","solid","tile"]),assertValidValue("BottomNavigation","indicatorPosition",t.indicatorPosition,["top","bottom"]);const A=useMobileUiText("bottomNavigation",BOTTOM_NAVIGATION_TEXT),j=useMemo(()=>R?{...A,...R}:A,[A,R]),V=useTheme(),M=useSafeAreaInsets(),C=useMemo(()=>buildStyles(V),[V]),L=m??18,D=L+4+8,k=V.space.lg,B=V.space.lg,P=V.radius.xl,N=useReducedMotion(),z=useScreenReaderEnabled(y),[F,H]=React.useState(null);useEffect(()=>{null!==F&&F!==_&&H(null)},[F,_]);const O=y&&!z&&"down"===_&&null===F,[W,U]=React.useState(O);useEffect(()=>{W!==O&&(N||"web"===Platform.OS||LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut),U(O))},[W,O,N]);const X="function"==typeof v?v({minimized:W}):v,$=null!=X&&!1!==X,Z=W&&$,[G,Y]=React.useState(0),K=$&&!Z?G+V.space.xs:0,q="tile"===l,J="floating"===l||q,Q="bubble"===l,ee="expand"===l,te="solid"===l,ie="pill"===l||J||te,ne=Math.max(0,i.findIndex(e=>e.key===o)),[oe,ae]=React.useState(0),[re,se]=React.useState(0),le=n?Math.ceil(i.length/2):i.length,de=i.length+(n?1:0),[ce,ue]=React.useState({width:0,height:0}),pe=n?.size??48,me=void 0!==n?.gap,he=Math.max(0,n?.gap??0),ge=me?(ce.width||pe)+2*he:0,be=me?i.length>0?Math.max(0,oe-ge)/i.length:0:de>0?oe/de:0,fe=me?ge:be,xe=useRef(createAnimatedValue(ne)).current,ye=useRef({}),ve=useRef({});i.forEach(e=>{ye.current[e.key]||(ye.current[e.key]=new Animated.Value(1)),ve.current[e.key]||(ve.current[e.key]=createAnimatedValue(e.key===o?1:0))});const Se=be>0?q?Math.min(be-4,96):Math.min(be-k,64):0,we=be>0?(be-Se)/2:0,Ee=be>0?(be-48)/2:0,hasLabel=e=>s&&!W&&!1!==e.showLabel&&e.label.trim().length>0,Ie=i[ne],Re=Ie&&!hasLabel(Ie)&&re>0?re/2:V.space.xs+(L+4)/2,Te=Re-14-24,Ae=Math.max(0,re-4),je=q?2:Re-D/2,Ve=useRef(ne);useEffect(()=>{if(Ve.current===ne)return;Ve.current=ne;const e=Animated.spring(xe,{toValue:ne,tension:120,friction:14,useNativeDriver:nativeDriver});return e.start(),()=>e.stop()},[ne,xe]);const Me=Math.max(1,i.length-1),Ce=useMemo(()=>{const e=[],t=[];for(let i=0;i<=Me;i++)e.push(i),t.push(i<le?i*be:i*be+fe);return xe.interpolate({inputRange:e,outputRange:t})},[xe,Me,le,be,fe]),Le=i.map(e=>e.key).join(" "),De=Q||ee;useEffect(()=>{const e=Le.split(" ").flatMap(e=>{const t=e===o?1:0,i=ve.current[e];return i?De?[Animated.spring(i,{toValue:t,tension:140,friction:13,useNativeDriver:!1})]:(i.setValue(t),[]):[]});if(0===e.length)return;const t=Animated.parallel(e);return t.start(),()=>t.stop()},[o,Le,De]);const popIcon=e=>{Animated.sequence([Animated.timing(e,{toValue:1.15,duration:120,useNativeDriver:nativeDriver}),Animated.spring(e,{toValue:1,tension:200,friction:8,useNativeDriver:nativeDriver})]).start()},ke=useRef(new Animated.Value(1)).current,{colors:Be}=V,Pe=te?Be.primary:Be.surface,Ne=te?Be["on-primary"]:Be.primary,ze=te?Be["on-primary"]:q?Be["text-body"]:Be["text-subtle"],Fe=te?Be["on-primary"]:Be["primary-soft"],He=te?Be.primary:Q?Be["on-primary"]:Ne,Oe=h??B,We=g??(J?B:0),Ue=We>0,Xe=f??V.space.sm,$e=b??(J?V.space.sm:V.space.xs),Ze=Ue?Xe:Math.max(Xe,M.bottom),Ge=Ue?Math.max(We,M.bottom>0?M.bottom+V.space.sm:0):0,Ye="pill"===c,Ke=J?re+K+2*Xe+2*StyleSheet.hairlineWidth:re+K+Xe+Ze,qe=Ye?re>0?Ke/2:V.radius.pill:c??(q?V.radius.pill:J?P:V.radius.none),Je=void 0!==c,activeBgRadius=(e,t)=>"number"==typeof u?Math.max(0,Math.min(u,e/2)):"auto"===u&&Je?Math.min(qe,e/2):t,Qe="underline"===l?Math.max($e,Ye&&0===re?0:qe):$e,et=p??"none",tt="none"===et?void 0:V.shadow[et],it=void 0===tt?null:supportsBoxShadow()?{boxShadow:toBoxShadow(tt)}:tt,nt=x?StyleSheet.hairlineWidth:0,ot=te?Be.primary:Be.border,at=n?.lift??0,rt=Xe+nt+K,st=n&&re>0?Math.max(0,(ce.height||pe)/2+at-re/2-rt):0,lt=n?_jsx(View,{style:[C.centerCell,me?{flex:0,marginHorizontal:he}:null],pointerEvents:"box-none",children:_jsxs(Pressable,{onPress:()=>{if(!n)return;const e=n.haptic??r;!1!==e&&triggerHaptic(e),popIcon(ke),n.onPress()},onLayout:e=>{const{width:t,height:i}=e.nativeEvent.layout;ue(e=>e.width===t&&e.height===i?e:{width:t,height:i})},accessibilityRole:"button",accessibilityLabel:n.label,hitSlop:{top:6,bottom:6,left:6,right:6},...hitSlopMarker({top:6,bottom:6,left:6,right:6}),style:({pressed:e})=>[C.centerPressable,{top:-at},e?{opacity:.85}:null],testID:n.testID??(T?`${T}-center`:void 0),children:[n.content?_jsx(Animated.View,{style:{transform:[{scale:ke}]},children:n.content}):_jsx(View,{style:[C.centerCircle,{width:pe,height:pe,borderRadius:V.radius.pill,...smoothCorners,backgroundColor:n.color??Be.primary}],children:_jsx(Animated.View,{style:{transform:[{scale:ke}]},children:renderSlotIcon(n.icon??"add",{color:n.iconColor??Be["on-primary"],size:n.iconSize??24,disabled:!1})})}),(dt=n,s&&!W&&dt.label.trim().length>0?_jsx(Text,{variant:"caption",numberOfLines:1,maxFontSizeMultiplier:I??V.settings.maxFontSizeMultiplier??1.2,style:[C.label,{color:ze,opacity:te?.7:1},E],children:n.label}):null)]})},CENTER_KEY):null;var dt;const ct=$?_jsx(View,{style:Z?C.accessoryInline:C.accessoryStacked,onLayout:e=>Y(e.nativeEvent.layout.height),testID:T?`${T}-accessory`:void 0,children:X}):null,ut=_jsxs(View,{style:Z?[C.tabRow,C.tabRowInline]:C.tabRow,onLayout:e=>{const{width:t,height:i}=e.nativeEvent.layout;ae(t),se(i)},children:[ie&&Se>0&&(!q||Ae>0)?_jsx(Animated.View,{pointerEvents:"none",style:[C.pill,{width:Se,height:q?Ae:D,left:we,top:je,backgroundColor:Fe,borderRadius:q?activeBgRadius(Ae,Ae/2):activeBgRadius(D,V.radius.pill),...smoothCorners,transform:[{translateX:Ce}]},w]}):null,Q&&be>0?_jsx(Animated.View,{pointerEvents:"none",style:[C.bubble,V.shadow.elevated,{width:48,height:48,borderRadius:V.radius.pill,...smoothCorners,left:Ee,top:Te,backgroundColor:Be.primary,borderColor:Be.surface,transform:[{translateX:Ce}]},w]}):null,(pt=i.map(e=>{const t=e.key===o,i=t?Ne:ze,n=t?He:ze,s="string"==typeof e.icon?{name:e.icon,variant:"bold"}:e.icon,l=t?e.activeIcon??s:e.icon,d=ye.current[e.key],c=ve.current[e.key];if(void 0===d||void 0===c)throw new Error(`BottomNavigation has no animation values for tab "${e.key}".`);const u=badgeVariantOf(e.badge??null),p=badgeAccessibilitySuffix(e.badge??null,j),m=te&&!t?.7:1,h=Q&&t||te?Be.primary:Be.surface,g=hasLabel(e),b=g&&(!ee||t),f=_jsxs(Animated.View,{style:[C.iconWrap,{width:L+4,height:L+4,opacity:m,transform:[{scale:d}]}],children:[_jsx(View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:renderSlotIcon(l,{color:n,size:L,focused:t,disabled:!1})}),u?_jsx(Badge,{variant:u,value:"standard"!==u||"number"!=typeof e.badge&&"string"!=typeof e.badge?void 0:e.badge,tone:"danger",accessible:!1,style:"dot"===u?C.badgeDotPosition:C.badgePillPosition,badgeStyle:["dot"===u?C.badgeDot:C.badgePill,{borderColor:h}],textStyle:C.badgeText}):null]}),x=Q?_jsx(Animated.View,{style:{top:c.interpolate({inputRange:[0,1],outputRange:[0,-14]})},children:f}):f,y=b?_jsx(Animated.Text,{numberOfLines:1,maxFontSizeMultiplier:I??V.settings.maxFontSizeMultiplier??1.2,style:[C.label,ee?C.labelInline:null,{color:i,opacity:ee?c:m,fontWeight:t?V.weight.semibold:V.weight.normal},E],children:e.label}):null,v=_jsx(Pressable,{onPress:()=>(e=>{W&&H(_),e.key!==o&&!1!==r&&triggerHaptic(r);const t=ye.current[e.key];t&&popIcon(t),a(e.key)})(e),accessibilityRole:"tab",accessibilityState:{selected:t},"aria-selected":t,accessibilityLabel:`${e.label}${p}`,accessibilityHint:fillText(j.switchesTo,{label:e.label}),hitSlop:{top:6,bottom:6,left:6,right:6},...hitSlopMarker({top:6,bottom:6,left:6,right:6}),style:({pressed:e})=>[C.tab,q?C.tabTile:null,e?{opacity:.85}:null],testID:T?`${T}-tab-${e.key}`:void 0,children:ee?_jsxs(View,{style:[C.expandPill,{height:D,paddingHorizontal:t&&g?V.space.md:Math.max(0,(D-(L+4))/2)}],children:[_jsx(View,{pointerEvents:"none",style:[C.expandFill,{borderRadius:activeBgRadius(D,D/2),...smoothCorners,backgroundColor:t?Be["primary-soft"]:"transparent"},t?w:null]}),x,y]}):_jsxs(_Fragment,{children:[x,y]})},e.key);return ee?_jsx(Animated.View,{style:{flex:c.interpolate({inputRange:[0,1],outputRange:[1,g?1.5:1]})},children:v},e.key):v}),lt?[...pt.slice(0,le),lt,...pt.slice(le)]:pt),"underline"===l&&be>0?_jsx(Animated.View,{pointerEvents:"none",style:[C.underline,"top"===d?C.underlineTop:C.underlineBottom,"top"===d?{top:-Xe-K}:{bottom:-Xe},{width:be,height:3,backgroundColor:Be.primary,transform:[{translateX:Ce}]},w]}):null]});var pt;return _jsx(View,{ref:e,testID:T,accessibilityRole:"tablist",style:[C.outer,{paddingHorizontal:Oe,paddingTop:Math.max(We,st),paddingBottom:Ge},S],children:_jsxs(View,{style:[J?C.floatingBar:C.dockedBar,Z?C.barInline:null,it,{backgroundColor:Pe,borderColor:ot,borderRadius:qe,...smoothCorners},J?{borderWidth:nt,paddingHorizontal:$e,paddingVertical:Xe}:{borderTopWidth:nt,borderBottomWidth:nt,borderLeftWidth:nt,borderRightWidth:nt,paddingHorizontal:Qe,paddingTop:Xe,paddingBottom:Ze}],children:[ct,ut]})})}const buildStyles=e=>StyleSheet.create({outer:{backgroundColor:"transparent"},dockedBar:{paddingHorizontal:e.space.xs},floatingBar:{paddingVertical:e.space.sm,paddingHorizontal:e.space.sm},tabRow:{flexDirection:"row",alignItems:"stretch",position:"relative"},tabRowInline:{flex:1},barInline:{flexDirection:"row",alignItems:"center"},accessoryStacked:{marginBottom:e.space.xs},accessoryInline:{flexShrink:0,marginRight:e.space.xs},tab:{flex:1,minHeight:44,alignItems:"center",justifyContent:"center",paddingVertical:e.space.xs,gap:e.space.xs},tabTile:{paddingVertical:e.space.sm,gap:e.space.xxs},centerCell:{flex:1,minHeight:44,alignItems:"center",justifyContent:"center"},centerPressable:{alignItems:"center",maxWidth:"100%",gap:e.space.xs},centerCircle:{alignItems:"center",justifyContent:"center"},iconWrap:{alignItems:"center",justifyContent:"center",position:"relative"},label:{fontSize:e.text.xs.size,lineHeight:e.text.xs.size*e.leading.heading,textAlign:"center",includeFontPadding:!1},labelInline:{fontSize:e.text.sm.size,lineHeight:e.text.sm.size*e.leading.heading,flexShrink:1,includeFontPadding:!1},expandPill:{flexDirection:"row",alignItems:"center",justifyContent:"center",gap:e.space.xs},expandFill:{position:"absolute",top:0,right:0,bottom:0,left:0,overflow:"hidden"},pill:{position:"absolute",left:0},bubble:{position:"absolute",left:0,borderWidth:3},underline:{position:"absolute",left:0,height:3},underlineBottom:{borderTopLeftRadius:e.radius.none,borderTopRightRadius:e.radius.none,...smoothCorners},underlineTop:{borderBottomLeftRadius:e.radius.none,borderBottomRightRadius:e.radius.none,...smoothCorners},badgePillPosition:{position:"absolute",top:-4,right:-8},badgePill:{minWidth:18,height:18,paddingHorizontal:e.space.xs,paddingVertical:e.space.xxs,borderWidth:1.5},badgeDotPosition:{position:"absolute",top:-2,right:-2},badgeDot:{width:10,height:10,borderRadius:e.radius.pill,borderWidth:1.5},badgeText:{lineHeight:Math.round(e.text.xs.size*e.leading.heading)}});export{BottomNavigation};export default BottomNavigation;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{createContext,useCallback,useContext,useEffect,useMemo,useRef,useState}from"react";import{Dimensions,Keyboard,Platform,ScrollView,StyleSheet,useWindowDimensions,View}from"react-native";import{GestureDetector,GestureHandlerRootView,useNativeGesture,usePanGesture,useTapGesture}from"react-native-gesture-handler";import{useReanimatedKeyboardAnimation}from"react-native-keyboard-controller";import Animated,{Easing,useAnimatedReaction,useAnimatedStyle,useDerivedValue,useSharedValue,withSpring,withTiming}from"react-native-reanimated";import{useSafeAreaInsets}from"react-native-safe-area-context";import{scheduleOnRN}from"react-native-worklets";import{PRESENCE_REDUCE_MOTION,usePresenceMotion}from"../../hooks/usePresenceMotion.js";import{useMobileUiText}from"../../text/index.js";import{BOTTOM_SHEET_TEXT}from"../../text/phone/bottomSheet.g.js";import{useTheme}from"../../theme/index.js";import{triggerHaptic}from"../../utils/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{transparentOf}from"../../utils/color.js";import{smoothCorners}from"../../utils/corners.js";import{ACTIONS_LAYOUTS,OverlayActions}from"../Dialog/OverlayActions.js";import{Modal}from"../Modal/Modal.js";import{useModalInsets}from"../ModalSafeArea/ModalSafeArea.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const DEFAULT_SNAP_POINTS=["content"],TABLET_MIN_SHORT_SIDE=600,DIALOG_MAX_WIDTH=560,BottomSheetContext=createContext(null);export const useBottomSheet=()=>{const e=useContext(BottomSheetContext);if(!e)throw new Error("[@webority/mobile-ui] BottomSheet: useBottomSheet must be used inside a <BottomSheet>.");return e};const SPRING_CONFIG={damping:20,stiffness:240,mass:1},CLOSE_VELOCITY_THRESHOLD=1e3,DRAG_ACTIVATION_OFFSET=10,BottomSheet=e=>{const{snapPoints:t=DEFAULT_SNAP_POINTS,open:o,onClose:s,snapIndex:r,onSnapChange:a,onAnimate:n,onAfterClose:l,enablePanDownToClose:i=!0,enableBackdropPress:u=!0,onBeforeClose:c,title:d,labels:h,scrollable:m=!1,scrollRef:f,onScroll:b,onContentSizeChange:p,onScrollLayout:S,scrollEventThrottle:v,keyboardBehavior:y="shift",inline:g=!1,presentation:x="sheet",animateMount:C=!0,handleIndicatorStyle:w,sheetStyle:M,header:R,actions:_,actionsLayout:T="auto",footer:O,headerStyle:k,footerStyle:E,children:I,accessibilityLabel:A,accessibilityViewIsModal:j,testID:V}=e;assertValidValue("BottomSheet","presentation",e.presentation,["sheet","dialog","auto"]),assertValidValue("BottomSheet","keyboardBehavior",e.keyboardBehavior,["none","shift"]),assertValidValue("BottomSheet","actionsLayout",e.actionsLayout,ACTIONS_LAYOUTS);const N=useMobileUiText("bottomSheet",BOTTOM_SHEET_TEXT),D=useMemo(()=>({...N,...h}),[N,h]),B=null!=R||null!=d,P=null!=_&&_.length>0,L=null!=O||P,H=g?"inline":"modal",G=useTheme(),F=usePresenceMotion(),U=useSafeAreaInsets(),[Y,K]=useState(()=>Dimensions.get("window").height),[$,z]=useState(()=>Dimensions.get("window").width),X=useCallback(e=>{const{height:t,width:o}=e.nativeEvent.layout;t>0&&K(e=>e===t?e:t),o>0&&z(e=>e===o?e:o)},[]),W=useWindowDimensions(),q="dialog"===x||"auto"===x&&Math.min(W.width,W.height)>=600,J=Math.min(560,$-2*G.space.xl),[Q,Z]=useModalInsets(),ee="modal"===H?Q.top:U.top,te="modal"===H?Q.bottom:U.bottom,oe=t.includes("content"),[se,re]=useMeasuredHeight(),[ae,ne]=useMeasuredHeight(),[le,ie,ue]=useMeasuredHeight(),[ce,de]=useMeasuredHeight(),he=q?G.space.md:se,me=oe?Math.min(he+(B?ae:0)+le+(L?ce:0)+te,Y-ee):0,fe=useCallback((e,t)=>{oe&&ue(t),p?.(e,t)},[oe,p,ue]),be=useMemo(()=>resolveSnapPoints(t,Y,me),[t,Y,me]),pe=Y,Se=be[be.length-1]??0,ve=useSharedValue(pe),ye=useSharedValue(pe),ge=useSharedValue(1),xe=useSharedValue(-1),[Ce,we]=useState(-1),[Me,Re]=useState(!1),[Te,Oe]=useState(!1),ke=useRef(!1),Ee=useRef(l);Ee.current=l;const[Ie,Ae]=useState(!1),je=useRef(!C&&o),Ve=useRef(-1),Ne=useRef(!1);Ne.current="modal"===H?Te:Ie;const De=useRef(c);De.current=c;const Be=useRef(s);Be.current=s;const Pe=useRef(!1),Le=useRef(!0),He=useRef([]),Ge=useCallback(e=>{const t=He.current;He.current=[];for(const o of t)o(e)},[]);useEffect(()=>(Le.current=!0,()=>{Le.current=!1,Ge(!1)}),[Ge]);const Fe=useCallback(e=>{if(e<0||e>=be.length)return pe;const t=be[e];if(void 0===t)throw new Error("BottomSheet: an in-range snap index always has a resolved snap point");return q?(Y-t)/2:Y-t},[be,Y,pe,q]),Ue=useCallback(e=>{Ve.current=e;Ce!==e&&(we(e),xe.value=e,e>=0&&a?.(e))},[Ce,xe,a]),Ye=useCallback(()=>{xe.value<0&&(ke.current=!0,"modal"===H?(Re(!1),"ios"!==Platform.OS&&Oe(!1)):Ae(!1))},[H,xe]),Ke=useCallback(()=>{ke.current&&Oe(!1)},[]);useEffect(()=>{("modal"===H?!Te:!Ie)&&ke.current&&(ke.current=!1,Ee.current?.(),Ge(!0))},[H,Te,Ie,Ge]);const $e=useCallback((e,t,o)=>{n?.(t,o),ve.value=withSpring(e,SPRING_CONFIG,e=>{"worklet";e&&scheduleOnRN(Ye)})},[n,ve,Ye]),ze=useRef(null),Xe=useCallback(e=>{const t="number"==typeof e?clamp(e,0,be.length-1):Math.max(Ce,0),o=xe.value,s=Fe(t);return ke.current=!1,Ge(!1),"modal"===H?(Oe(!0),Re(!0)):Ae(!0),o<0&&je.current?(ve.value=s,ge.value=1,Ue(t),void n?.(o,t)):o<0&&F.reduced?(ve.value=s,ge.value=0,ge.value=withTiming(1,{duration:F.duration("fast"),easing:Easing.bezier(...G.motion.ease.decelerate),reduceMotion:PRESENCE_REDUCE_MOTION}),Ue(t),void n?.(o,t)):(o<0&&(ve.value=pe,ge.value=1),Ue(t),void(o<0&&t>=0&&!Ne.current?ze.current={fromIndex:o,target:t}:$e(s,o,t)))},[$e,pe,Ce,xe,H,n,F,ge,be.length,Ue,Ge,G.motion.ease.decelerate,ve,Fe]),We=useCallback(()=>new Promise(e=>{if(Ve.current<0)return void(Ne.current?He.current.push(e):e(!0));He.current.push(e),je.current=!1,ze.current=null;const t=xe.value;Ue(-1),n?.(t,-1);const o=F.reduced?ge:ve,s=F.reduced?0:pe;o.value=withTiming(s,{duration:F.duration("fast"),easing:Easing.bezier(...G.motion.ease.accelerate),reduceMotion:PRESENCE_REDUCE_MOTION},e=>{"worklet";e&&scheduleOnRN(Ye)})}),[pe,xe,Ye,n,F,ge,Ue,ve,G.motion.ease.accelerate]),qe=useCallback((e,t,o)=>{const s=De.current;if(!s)return void e();if(Pe.current)return void t?.();const r=s();"boolean"!=typeof r?(Pe.current=!0,o?.(),r.then(o=>{Pe.current=!1,o&&Le.current&&Ve.current>=0?e():t?.()},e=>{throw Pe.current=!1,e})):(r?e:t)?.()},[]),Je=useCallback(()=>new Promise(e=>{Ve.current<0?e(!0):qe(()=>{Be.current(),We(),e(!0)},()=>e(!1))}),[We,qe]),Qe=useCallback(()=>{Be.current()},[]),Ze=useCallback(()=>{u&&Je()},[u,Je]),et=useRef(null),tt=useRef(Xe);tt.current=Xe;const ot=useRef(We);ot.current=We,useEffect(()=>{const e=et.current!==o;et.current=o,e?o?tt.current(r??0):ot.current():o&&"number"==typeof r&&r!==xe.value&&tt.current(r)},[o,r,xe]);const st=useRef({hostHeight:Y,contentSnap:me}),rt=useRef(Fe);rt.current=Fe,useEffect(()=>{const e=st.current;if(e.hostHeight===Y&&e.contentSnap===me)return;if(st.current={hostHeight:Y,contentSnap:me},e.hostHeight===Y&&xe.value<0)return;const t=rt.current(xe.value);ve.value=je.current?t:withSpring(t,SPRING_CONFIG)},[Y,me,xe,ve]);const at="modal"===H?Te:Ie;useEffect(()=>{const e=ze.current;null!==e&&at&&(ze.current=null,Ve.current===e.target&&$e(rt.current(e.target),e.fromIndex,e.target))},[at,$e]);const nt=Y-Se,lt=useMemo(()=>be.map(e=>Y-e),[be,Y]),it=useCallback(()=>{const e=Ve.current;e<0||$e(Fe(e),e,e)},[$e,Fe]),ut=useCallback((e,t)=>{const o=xe.value;-1!==e?(Ue(e),$e(t,o,e)):qe(()=>{Keyboard.dismiss(),triggerHaptic("selection"),Be.current(),We()},it,it)},[$e,We,xe,qe,Ue,it]),ct=useMemo(()=>({testID:V?`${V}-content-gesture`:"bottom-sheet-content-gesture"}),[V]),dt=useNativeGesture(ct),ht=useMemo(()=>{const e=lt,t=pe,o=nt,s=i;return{testID:V?`${V}-pan-gesture`:"bottom-sheet-pan-gesture",activeOffsetY:[-10,10],failOffsetX:[-15,15],onActivate:()=>{"worklet";ye.value=ve.value},onUpdate:e=>{"worklet";const t=ye.value+e.translationY;ve.value=t<o?o+.25*(t-o):t},onDeactivate:o=>{"worklet";const r=ve.value,a=o.velocityY,[n]=e;if(void 0===n)return void scheduleOnRN(ut,-1,t);if(a>1e3)return s?void scheduleOnRN(ut,-1,t):void scheduleOnRN(ut,0,n);let l=0,i=n,u=1/0,c=0;for(const t of e){const e=Math.abs(r-t);e<u&&(u=e,i=t,l=c),c++}s&&r-n>80?scheduleOnRN(ut,-1,t):scheduleOnRN(ut,l,i)}}},[pe,ye,i,ut,nt,lt,V,ve]),mt=usePanGesture(ht),{height:ft,progress:bt}=useReanimatedKeyboardAnimation(),pt="shift"===y,St=useDerivedValue(()=>pt?ft.value:0,[pt,ft]),vt=useSharedValue(0);useAnimatedReaction(()=>pt&&bt.value>=1?ft.value:0,e=>{vt.value=e},[pt,ft,bt,vt]);const yt=be[Math.max(Ce,0)]??Se,gt=G.space.md,xt=useAnimatedStyle(()=>{const e=St.value;if(q){const t=Y+e-yt-gt,o=e<0&&ve.value>t?t:ve.value;return{top:ve.value,transform:[{translateY:Math.max(o,ee)-ve.value}],opacity:ge.value}}const t=e<0?ee:nt,o=Math.max(ve.value+e,t);return{top:ve.value,transform:[{translateY:o-ve.value}],opacity:ge.value}},[q,St,Y,yt,gt,ve,ee,ge,nt]),Ct=useAnimatedStyle(()=>{const e=vt.value;if(q){const t=Y+e-yt-gt,o=e<0&&ve.value>t?t:ve.value,s=Math.max(o,ee),r=Y+e-gt-s;return{height:r<0?0:Math.min(r,yt)}}const t=e<0?ee:nt,o=ve.value+e,s=Math.max(o,t),r=Y+e-s;return{height:r<0?0:Math.min(r,Se)}},[vt,q,Y,yt,gt,ve,ee,nt,Se]),wt=Ce>=0,Mt=useMemo(()=>buildStyles(G),[G]),Rt=useCallback(()=>{u&&qe(()=>{triggerHaptic("selection"),Be.current(),We()})},[u,We,qe]),_t=useMemo(()=>({testID:V?`${V}-backdrop-gesture`:"bottom-sheet-backdrop-gesture",maxDuration:250,onDeactivate:e=>{"worklet";e.canceled||scheduleOnRN(Rt)}}),[Rt,V]),Tt=useTapGesture(_t),Ot=useMemo(()=>({snapIndex:Ce,snapPoints:be,close:Qe,requestClose:Je}),[Ce,be,Qe,Je]);if("inline"===H&&!Ie)return null;if("modal"===H&&!Te)return null;const kt=_jsxs(View,{collapsable:!1,style:["modal"===H?Mt.backdropModal:Mt.backdropInline,{backgroundColor:"modal"===H?transparentOf(G.colors.scrim):G.colors.scrim}],onLayout:X,testID:V,accessibilityViewIsModal:j??wt,children:[_jsx(GestureDetector,{gesture:Tt,children:_jsx(Animated.View,{style:StyleSheet.absoluteFill,accessibilityRole:"button",accessibilityLabel:D.close})}),_jsx(Animated.View,{accessibilityRole:"alert",accessibilityLabel:A,accessibilityViewIsModal:j??wt,accessibilityActions:[{name:"escape",label:D.close}],onAccessibilityAction:e=>{"escape"===e.nativeEvent.actionName&&Ze()},onAccessibilityEscape:Ze,style:[Mt.sheet,{height:Se,backgroundColor:G.colors.surface,borderTopLeftRadius:G.radius.xl,borderTopRightRadius:G.radius.xl,...smoothCorners,...G.shadow.modal},q?{height:yt,left:($-J)/2,right:void 0,width:J,borderBottomLeftRadius:G.radius.xl,borderBottomRightRadius:G.radius.xl}:null,M,xt],children:_jsxs(SheetBody,{style:[Mt.body,Ct],settledKeyboardOffset:vt,children:[q?_jsx(View,{style:{height:G.space.md}}):_jsx(GestureDetector,{gesture:mt,children:_jsx(View,{style:Mt.handleRow,onLayout:oe?re:void 0,accessible:!0,accessibilityLabel:D.dragHandle,accessibilityHint:D.dragHandleHintText,testID:V?`${V}-handle`:"bottom-sheet-handle",children:_jsx(View,{style:[Mt.handle,{backgroundColor:G.colors.border},w]})})}),B&&_jsxs(View,{style:[Mt.header,k],onLayout:oe?ne:void 0,children:[null!=d?_jsx(Text,{variant:"title",accessibilityRole:"header",children:d}):null,R]}),m?_jsx(GestureDetector,{gesture:dt,children:_jsx(ScrollView,{ref:f,testID:V?`${V}-scroll`:void 0,style:Mt.scrollContent,onScroll:b,onContentSizeChange:fe,onLayout:S,scrollEventThrottle:v,keyboardShouldPersistTaps:"always",keyboardDismissMode:"none",children:I})}):_jsx(View,{style:oe?[Mt.content,{overflow:"visible"}]:Mt.content,children:oe?_jsx(View,{onLayout:ie,children:I}):I}),L&&_jsxs(View,{style:[Mt.footer,E],onLayout:oe?de:void 0,children:[P?_jsx(View,{style:Mt.actions,children:_jsx(OverlayActions,{actions:_??[],layout:T})}):null,O]})]})})]}),Et=_jsx(BottomSheetContext.Provider,{value:Ot,children:kt});return"modal"===H?_jsx(Modal,{open:Me,onClose:Ze,presentation:"fullScreen",bare:!0,backdropPressClose:!1,haptic:!1,animateMount:!1,onInsetsChange:Z,onDismissed:"ios"===Platform.OS?Ke:void 0,children:"android"===Platform.OS?_jsx(GestureHandlerRootView,{style:Mt.modalRoot,children:Et}):Et}):Et},SheetBody=({style:e,settledKeyboardOffset:t,children:o})=>{const s=useSafeAreaInsets().bottom,r=useAnimatedStyle(()=>{const e=s+t.value;return{paddingBottom:Math.max(e,0)}},[s,t]);return _jsx(Animated.View,{style:[e,r],children:o})};BottomSheet.displayName="BottomSheet";const useMeasuredHeight=()=>{const[e,t]=useState(0),o=useCallback(e=>{t(t=>t===e?t:e)},[]);return[e,useCallback(e=>o(e.nativeEvent.layout.height),[o]),o]},resolveSnapPoints=(e,t,o)=>[...e.map(e=>{if("number"==typeof e)return e;if("content"===e)return o;const s=parseFloat(e);return Number.isNaN(s)?0:s/100*t})].sort((e,t)=>e-t),clamp=(e,t,o)=>Math.min(Math.max(e,t),o),buildStyles=e=>StyleSheet.create({backdropModal:{flex:1},backdropInline:{...StyleSheet.absoluteFill},sheet:{position:"absolute",left:0,right:0,overflow:"hidden"},body:{overflow:"hidden"},handleRow:{alignItems:"center",justifyContent:"center",alignSelf:"stretch",paddingTop:e.space.md,paddingBottom:e.space.xl},header:{},actions:{padding:e.space.lg},footer:{backgroundColor:e.colors.surface},handle:{width:36,height:4,borderRadius:e.radius.pill,...smoothCorners},content:{flex:1,overflow:"hidden"},scrollContent:{flex:1},modalRoot:{flex:1}});export{BottomSheet};export default BottomSheet;
|
|
1
|
+
"use strict";import{createContext,useCallback,useContext,useEffect,useMemo,useRef,useState}from"react";import{Dimensions,Keyboard,Platform,ScrollView,StyleSheet,useWindowDimensions,View}from"react-native";import{GestureDetector,GestureHandlerRootView,useNativeGesture,usePanGesture,useTapGesture}from"react-native-gesture-handler";import{useReanimatedKeyboardAnimation}from"react-native-keyboard-controller";import Animated,{Easing,useAnimatedReaction,useAnimatedStyle,useDerivedValue,useSharedValue,withSpring,withTiming}from"react-native-reanimated";import{useSafeAreaInsets}from"react-native-safe-area-context";import{scheduleOnRN}from"react-native-worklets";import{PRESENCE_REDUCE_MOTION,usePresenceMotion}from"../../hooks/usePresenceMotion.js";import{useMobileUiText}from"../../text/index.js";import{BOTTOM_SHEET_TEXT}from"../../text/phone/bottomSheet.g.js";import{useTheme}from"../../theme/index.js";import{triggerHaptic}from"../../utils/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{transparentOf}from"../../utils/color.js";import{smoothCorners}from"../../utils/corners.js";import{ACTIONS_LAYOUTS,OverlayActions}from"../Dialog/OverlayActions.js";import{Modal}from"../Modal/Modal.js";import{useModalInsets}from"../ModalSafeArea/ModalSafeArea.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const DEFAULT_SNAP_POINTS=["content"],TABLET_MIN_SHORT_SIDE=600,DIALOG_MAX_WIDTH=560,BottomSheetContext=createContext(null);export const useBottomSheet=()=>{const e=useContext(BottomSheetContext);if(!e)throw new Error("[@webority/mobile-ui] BottomSheet: useBottomSheet must be used inside a <BottomSheet>.");return e};const SPRING_CONFIG={damping:20,stiffness:240,mass:1},CLOSE_VELOCITY_THRESHOLD=1e3,DRAG_ACTIVATION_OFFSET=10,BottomSheet=e=>{const{snapPoints:t=DEFAULT_SNAP_POINTS,open:o,onClose:s,snapIndex:r,onSnapChange:a,onAnimate:n,onAfterClose:l,enablePanDownToClose:i=!0,enableBackdropPress:u=!0,onBeforeClose:c,title:d,labels:h,scrollable:m=!1,scrollRef:f,onScroll:b,onContentSizeChange:p,onScrollLayout:S,scrollEventThrottle:v,keyboardBehavior:y="shift",inline:g=!1,presentation:x="sheet",animateMount:C=!0,handleIndicatorStyle:w,sheetStyle:M,header:R,actions:_,actionsLayout:T="auto",footer:O,headerStyle:k,footerStyle:E,children:I,accessibilityLabel:A,accessibilityViewIsModal:j,testID:V}=e;assertValidValue("BottomSheet","presentation",e.presentation,["sheet","dialog","auto"]),assertValidValue("BottomSheet","keyboardBehavior",e.keyboardBehavior,["none","shift"]),assertValidValue("BottomSheet","actionsLayout",e.actionsLayout,ACTIONS_LAYOUTS);const N=useMobileUiText("bottomSheet",BOTTOM_SHEET_TEXT),D=useMemo(()=>({...N,...h}),[N,h]),B=null!=R||null!=d,P=null!=_&&_.length>0,L=null!=O||P,H=g?"inline":"modal",G=useTheme(),F=usePresenceMotion(),U=useSafeAreaInsets(),[Y,K]=useState(()=>Dimensions.get("window").height),[$,z]=useState(()=>Dimensions.get("window").width),X=useCallback(e=>{const{height:t,width:o}=e.nativeEvent.layout;t>0&&K(e=>e===t?e:t),o>0&&z(e=>e===o?e:o)},[]),W=useWindowDimensions(),q="dialog"===x||"auto"===x&&Math.min(W.width,W.height)>=600,J=Math.min(560,$-2*G.space.xl),[Q,Z]=useModalInsets(),ee="modal"===H?Q.top:U.top,te="modal"===H?Q.bottom:U.bottom,oe=t.includes("content"),[se,re]=useMeasuredHeight(),[ae,ne]=useMeasuredHeight(),[le,ie,ue]=useMeasuredHeight(),[ce,de]=useMeasuredHeight(),he=q?G.space.md:se,me=oe?Math.min(he+(B?ae:0)+le+(L?ce:0)+te,Y-ee):0,fe=useCallback((e,t)=>{oe&&ue(t),p?.(e,t)},[oe,p,ue]),be=useMemo(()=>resolveSnapPoints(t,Y,me),[t,Y,me]),pe=Y,Se=be[be.length-1]??0,ve=useSharedValue(pe),ye=useSharedValue(pe),ge=useSharedValue(1),xe=useSharedValue(-1),[Ce,we]=useState(-1),[Me,Re]=useState(!1),[Te,Oe]=useState(!1),ke=useRef(!1),Ee=useRef(l);Ee.current=l;const[Ie,Ae]=useState(!1),je=useRef(!C&&o),Ve=useRef(-1),Ne=useRef(!1);Ne.current="modal"===H?Te:Ie;const De=useRef(c);De.current=c;const Be=useRef(s);Be.current=s;const Pe=useRef(!1),Le=useRef(!0),He=useRef([]),Ge=useCallback(e=>{const t=He.current;He.current=[];for(const o of t)o(e)},[]);useEffect(()=>(Le.current=!0,()=>{Le.current=!1,Ge(!1)}),[Ge]);const Fe=useCallback(e=>{if(e<0||e>=be.length)return pe;const t=be[e];if(void 0===t)throw new Error("BottomSheet: an in-range snap index always has a resolved snap point");return q?(Y-t)/2:Y-t},[be,Y,pe,q]),Ue=useCallback(e=>{Ve.current=e;Ce!==e&&(we(e),xe.value=e,e>=0&&a?.(e))},[Ce,xe,a]),Ye=useCallback(()=>{xe.value<0&&(ke.current=!0,"modal"===H?(Re(!1),"ios"!==Platform.OS&&Oe(!1)):Ae(!1))},[H,xe]),Ke=useCallback(()=>{ke.current&&Oe(!1)},[]);useEffect(()=>{("modal"===H?!Te:!Ie)&&ke.current&&(ke.current=!1,Ee.current?.(),Ge(!0))},[H,Te,Ie,Ge]);const $e=useCallback((e,t,o)=>{n?.(t,o),ve.value=withSpring(e,SPRING_CONFIG,e=>{"worklet";e&&scheduleOnRN(Ye)})},[n,ve,Ye]),ze=useRef(null),Xe=useCallback(e=>{const t="number"==typeof e?clamp(e,0,be.length-1):Math.max(Ce,0),o=xe.value,s=Fe(t);return ke.current=!1,Ge(!1),"modal"===H?(Oe(!0),Re(!0)):Ae(!0),o<0&&je.current?(ve.value=s,ge.value=1,Ue(t),void n?.(o,t)):o<0&&F.reduced?(ve.value=s,ge.value=0,ge.value=withTiming(1,{duration:F.duration("fast"),easing:Easing.bezier(...G.motion.ease.decelerate),reduceMotion:PRESENCE_REDUCE_MOTION}),Ue(t),void n?.(o,t)):(o<0&&(ve.value=pe,ge.value=1),Ue(t),void(o<0&&t>=0&&!Ne.current?ze.current={fromIndex:o,target:t}:$e(s,o,t)))},[$e,pe,Ce,xe,H,n,F,ge,be.length,Ue,Ge,G.motion.ease.decelerate,ve,Fe]),We=useCallback(()=>new Promise(e=>{if(Ve.current<0)return void(Ne.current?He.current.push(e):e(!0));He.current.push(e),je.current=!1,ze.current=null;const t=xe.value;Ue(-1),n?.(t,-1);const o=F.reduced?ge:ve,s=F.reduced?0:pe;o.value=withTiming(s,{duration:F.duration("fast"),easing:Easing.bezier(...G.motion.ease.accelerate),reduceMotion:PRESENCE_REDUCE_MOTION},e=>{"worklet";e&&scheduleOnRN(Ye)})}),[pe,xe,Ye,n,F,ge,Ue,ve,G.motion.ease.accelerate]),qe=useCallback((e,t,o)=>{const s=De.current;if(!s)return void e();if(Pe.current)return void t?.();const r=s();"boolean"!=typeof r?(Pe.current=!0,o?.(),r.then(o=>{Pe.current=!1,o&&Le.current&&Ve.current>=0?e():t?.()},e=>{throw Pe.current=!1,e})):(r?e:t)?.()},[]),Je=useCallback(()=>new Promise(e=>{Ve.current<0?e(!0):qe(()=>{Be.current(),We(),e(!0)},()=>e(!1))}),[We,qe]),Qe=useCallback(()=>{Be.current()},[]),Ze=useCallback(()=>{u&&Je()},[u,Je]),et=useRef(null),tt=useRef(Xe);tt.current=Xe;const ot=useRef(We);ot.current=We,useEffect(()=>{const e=et.current!==o;et.current=o,e?o?tt.current(r??0):ot.current():o&&"number"==typeof r&&r!==xe.value&&tt.current(r)},[o,r,xe]);const st=useRef({hostHeight:Y,contentSnap:me}),rt=useRef(Fe);rt.current=Fe,useEffect(()=>{const e=st.current;if(e.hostHeight===Y&&e.contentSnap===me)return;if(st.current={hostHeight:Y,contentSnap:me},e.hostHeight===Y&&xe.value<0)return;const t=rt.current(xe.value);ve.value=je.current?t:withSpring(t,SPRING_CONFIG)},[Y,me,xe,ve]);const at="modal"===H?Te:Ie;useEffect(()=>{const e=ze.current;null!==e&&at&&(ze.current=null,Ve.current===e.target&&$e(rt.current(e.target),e.fromIndex,e.target))},[at,$e]);const nt=Y-Se,lt=useMemo(()=>be.map(e=>Y-e),[be,Y]),it=useCallback(()=>{const e=Ve.current;e<0||$e(Fe(e),e,e)},[$e,Fe]),ut=useCallback((e,t)=>{const o=xe.value;-1!==e?(Ue(e),$e(t,o,e)):qe(()=>{Keyboard.dismiss(),triggerHaptic("selection"),Be.current(),We()},it,it)},[$e,We,xe,qe,Ue,it]),ct=useMemo(()=>({testID:V?`${V}-content-gesture`:"bottom-sheet-content-gesture"}),[V]),dt=useNativeGesture(ct),ht=useMemo(()=>{const e=lt,t=pe,o=nt,s=i;return{testID:V?`${V}-pan-gesture`:"bottom-sheet-pan-gesture",activeOffsetY:[-10,10],failOffsetX:[-15,15],onActivate:()=>{"worklet";ye.value=ve.value},onUpdate:e=>{"worklet";const t=ye.value+e.translationY;ve.value=t<o?o+.25*(t-o):t},onDeactivate:o=>{"worklet";const r=ve.value,a=o.velocityY,[n]=e;if(void 0===n)return void scheduleOnRN(ut,-1,t);if(a>1e3)return s?void scheduleOnRN(ut,-1,t):void scheduleOnRN(ut,0,n);let l=0,i=n,u=1/0,c=0;for(const t of e){const e=Math.abs(r-t);e<u&&(u=e,i=t,l=c),c++}s&&r-n>80?scheduleOnRN(ut,-1,t):scheduleOnRN(ut,l,i)}}},[pe,ye,i,ut,nt,lt,V,ve]),mt=usePanGesture(ht),{height:ft,progress:bt}=useReanimatedKeyboardAnimation(),pt="shift"===y,St=useDerivedValue(()=>pt?ft.value:0,[pt,ft]),vt=useSharedValue(0);useAnimatedReaction(()=>pt&&bt.value>=1?ft.value:0,e=>{vt.value=e},[pt,ft,bt,vt]);const yt=be[Math.max(Ce,0)]??Se,gt=G.space.md,xt=useAnimatedStyle(()=>{const e=St.value;if(q){const t=Y+e-yt-gt,o=e<0&&ve.value>t?t:ve.value;return{top:ve.value,transform:[{translateY:Math.max(o,ee)-ve.value}],opacity:ge.value}}const t=e<0?ee:nt,o=Math.max(ve.value+e,t);return{top:ve.value,transform:[{translateY:o-ve.value}],opacity:ge.value}},[q,St,Y,yt,gt,ve,ee,ge,nt]),Ct=useAnimatedStyle(()=>{const e=vt.value;if(q){const t=Y+e-yt-gt,o=e<0&&ve.value>t?t:ve.value,s=Math.max(o,ee),r=Y+e-gt-s;return{height:r<0?0:Math.min(r,yt)}}const t=e<0?ee:nt,o=ve.value+e,s=Math.max(o,t),r=Y+e-s;return{height:r<0?0:Math.min(r,Se)}},[vt,q,Y,yt,gt,ve,ee,nt,Se]),wt=Ce>=0,Mt=useMemo(()=>buildStyles(G),[G]),Rt=useCallback(()=>{u&&qe(()=>{triggerHaptic("selection"),Be.current(),We()})},[u,We,qe]),_t=useMemo(()=>({testID:V?`${V}-backdrop-gesture`:"bottom-sheet-backdrop-gesture",maxDuration:250,onDeactivate:e=>{"worklet";e.canceled||scheduleOnRN(Rt)}}),[Rt,V]),Tt=useTapGesture(_t),Ot=useMemo(()=>({snapIndex:Ce,snapPoints:be,close:Qe,requestClose:Je}),[Ce,be,Qe,Je]);if("inline"===H&&!Ie)return null;if("modal"===H&&!Te)return null;const kt=_jsxs(View,{collapsable:!1,style:["modal"===H?Mt.backdropModal:Mt.backdropInline,{backgroundColor:"modal"===H?transparentOf(G.colors.scrim):G.colors.scrim}],onLayout:X,testID:V,accessibilityViewIsModal:j??wt,children:[_jsx(GestureDetector,{gesture:Tt,children:_jsx(Animated.View,{style:StyleSheet.absoluteFill,accessibilityRole:"button",accessibilityLabel:D.close})}),_jsx(Animated.View,{accessibilityRole:"alert",accessibilityLabel:A,accessibilityViewIsModal:j??wt,accessibilityActions:[{name:"escape",label:D.close}],onAccessibilityAction:e=>{"escape"===e.nativeEvent.actionName&&Ze()},onAccessibilityEscape:Ze,style:[Mt.sheet,{height:Se,backgroundColor:G.colors.surface,borderTopLeftRadius:G.radius.xl,borderTopRightRadius:G.radius.xl,...smoothCorners,...G.shadow.modal},q?{height:yt,left:($-J)/2,right:void 0,width:J,borderBottomLeftRadius:G.radius.xl,borderBottomRightRadius:G.radius.xl}:null,M,xt],children:_jsxs(SheetBody,{style:[Mt.body,Ct],settledKeyboardOffset:vt,children:[q?_jsx(View,{style:{height:G.space.md}}):_jsx(GestureDetector,{gesture:mt,children:_jsx(View,{style:Mt.handleRow,onLayout:oe?re:void 0,accessible:!0,accessibilityLabel:D.dragHandle,accessibilityHint:D.dragHandleHintText,testID:V?`${V}-handle`:"bottom-sheet-handle",children:_jsx(View,{style:[Mt.handle,{backgroundColor:G.colors.border},w]})})}),B&&_jsxs(View,{style:[Mt.header,k],onLayout:oe?ne:void 0,children:[null!=d?_jsx(Text,{variant:"title",accessibilityRole:"header",children:d}):null,R]}),m?_jsx(GestureDetector,{gesture:dt,children:_jsx(ScrollView,{ref:f,testID:V?`${V}-scroll`:void 0,style:Mt.scrollContent,onScroll:b,onContentSizeChange:fe,onLayout:S,scrollEventThrottle:v,keyboardShouldPersistTaps:"always",keyboardDismissMode:"none",children:I})}):_jsx(View,{style:oe?[Mt.content,{overflow:"visible"}]:Mt.content,children:oe?_jsx(View,{onLayout:ie,children:I}):I}),L&&_jsxs(View,{style:[Mt.footer,E],onLayout:oe?de:void 0,children:[P?_jsx(View,{style:Mt.actions,children:_jsx(OverlayActions,{actions:_??[],layout:T})}):null,O]})]})})]}),Et=_jsx(BottomSheetContext,{value:Ot,children:kt});return"modal"===H?_jsx(Modal,{open:Me,onClose:Ze,presentation:"fullScreen",bare:!0,backdropPressClose:!1,haptic:!1,animateMount:!1,onInsetsChange:Z,onDismissed:"ios"===Platform.OS?Ke:void 0,children:"android"===Platform.OS?_jsx(GestureHandlerRootView,{style:Mt.modalRoot,children:Et}):Et}):Et},SheetBody=({style:e,settledKeyboardOffset:t,children:o})=>{const s=useSafeAreaInsets().bottom,r=useAnimatedStyle(()=>{const e=s+t.value;return{paddingBottom:Math.max(e,0)}},[s,t]);return _jsx(Animated.View,{style:[e,r],children:o})};BottomSheet.displayName="BottomSheet";const useMeasuredHeight=()=>{const[e,t]=useState(0),o=useCallback(e=>{t(t=>t===e?t:e)},[]);return[e,useCallback(e=>o(e.nativeEvent.layout.height),[o]),o]},resolveSnapPoints=(e,t,o)=>[...e.map(e=>{if("number"==typeof e)return e;if("content"===e)return o;const s=parseFloat(e);return Number.isNaN(s)?0:s/100*t})].sort((e,t)=>e-t),clamp=(e,t,o)=>Math.min(Math.max(e,t),o),buildStyles=e=>StyleSheet.create({backdropModal:{flex:1},backdropInline:{...StyleSheet.absoluteFill},sheet:{position:"absolute",left:0,right:0,overflow:"hidden"},body:{overflow:"hidden"},handleRow:{alignItems:"center",justifyContent:"center",alignSelf:"stretch",paddingTop:e.space.md,paddingBottom:e.space.xl},header:{},actions:{padding:e.space.lg},footer:{backgroundColor:e.colors.surface},handle:{width:36,height:4,borderRadius:e.radius.pill,...smoothCorners},content:{flex:1,overflow:"hidden"},scrollContent:{flex:1},modalRoot:{flex:1}});export{BottomSheet};export default BottomSheet;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{
|
|
1
|
+
"use strict";import{View}from"react-native";import{useTheme}from"../../theme/index.js";import{radiusOf,spaceOf}from"../../theme/scale.js";import{smoothCorners}from"../../utils/corners.js";import{isOneOf}from"../../utils/guards.js";import{SquircleFill,useSquircle}from"../SquircleFill/SquircleFill.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const BACKGROUND_TOKENS=["bg","bg-subtle","bg-muted","surface","scrim","surface-inverse","primary-wash"],space=(r,e)=>null==e?void 0:spaceOf(r,e);export const resolveBoxStyle=(r,e)=>({...null!=e.p?{padding:space(r,e.p)}:{},...null!=e.px?{paddingHorizontal:space(r,e.px)}:{},...null!=e.py?{paddingVertical:space(r,e.py)}:{},...null!=e.pt?{paddingTop:space(r,e.pt)}:{},...null!=e.pr?{paddingRight:space(r,e.pr)}:{},...null!=e.pb?{paddingBottom:space(r,e.pb)}:{},...null!=e.pl?{paddingLeft:space(r,e.pl)}:{},...null!=e.m?{margin:space(r,e.m)}:{},...null!=e.mx?{marginHorizontal:space(r,e.mx)}:{},...null!=e.my?{marginVertical:space(r,e.my)}:{},...null!=e.mt?{marginTop:space(r,e.mt)}:{},...null!=e.mr?{marginRight:space(r,e.mr)}:{},...null!=e.mb?{marginBottom:space(r,e.mb)}:{},...null!=e.ml?{marginLeft:space(r,e.ml)}:{},...null!=e.gap?{gap:space(r,e.gap)}:{},...null!=e.bg?{backgroundColor:isOneOf(BACKGROUND_TOKENS,e.bg)?r.colors[e.bg]:e.bg}:{},...null!=e.radius?{borderRadius:radiusOf(r,e.radius),borderCurve:smoothCorners.borderCurve}:{},...e.border?{borderWidth:r.size.border,borderColor:r.colors.border}:{},...null!=e.flex?{flex:e.flex}:{},...null!=e.align?{alignItems:e.align}:{},...null!=e.justify?{justifyContent:e.justify}:{},...null!=e.direction?{flexDirection:e.direction}:{},...e.wrap?{flexWrap:"wrap"}:{}});function Box(r){const e=useTheme(),{p:l,px:o,py:t,pt:i,pr:s,pb:n,pl:a,m:p,mx:u,my:c,mt:m,mr:d,mb:g,ml:f,gap:b,bg:x,radius:y,border:h,flex:j,align:S,justify:w,direction:C,wrap:O,style:B,children:v,ref:_,...R}=r,k=resolveBoxStyle(e,{p:l,px:o,py:t,pt:i,pr:s,pb:n,pl:a,m:p,mx:u,my:c,mt:m,mr:d,mb:g,ml:f,gap:b,bg:x,radius:y,border:h,flex:j,align:S,justify:w,direction:C,wrap:O}),z="number"==typeof k.borderRadius?k.borderRadius:0,T="string"==typeof k.backgroundColor?k.backgroundColor:"transparent",q="string"==typeof k.borderColor?k.borderColor:void 0,D="number"==typeof k.borderWidth?k.borderWidth:0,V=useSquircle(null!=y&&(null!=x||Boolean(h)),z,R.onLayout),L=V.active?{...k,backgroundColor:"transparent",borderColor:"transparent"}:k;return _jsxs(View,{ref:_,...R,onLayout:V.onLayout,style:[L,B],children:[V.active&&V.size?_jsx(SquircleFill,{width:V.size.width,height:V.size.height,radius:z,fill:T,stroke:q,strokeWidth:D}):null,v]})}function Stack({gap:r="md",ref:e,...l}){return _jsx(Box,{ref:e,direction:"column",gap:r,...l})}function Row({gap:r="sm",align:e="center",ref:l,...o}){return _jsx(Box,{ref:l,direction:"row",gap:r,align:e,...o})}const Spacer=({size:r,style:e,testID:l})=>{const o=useTheme();if(null!=r){const t=spaceOf(o,r);return _jsx(View,{testID:l,style:[{width:t,height:t},e]})}return _jsx(View,{testID:l,style:[{flex:1},e]})};Spacer.displayName="Spacer";export{Box,Row,Spacer,Stack};export default Box;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{forwardRef,useMemo,useRef,useState}from"react";import{Animated,Easing,Pressable,StyleSheet,View}from"react-native";import{useFlickGuard}from"../../hooks/useFlickGuard.js";import{usePressAnimation}from"../../hooks/usePressAnimation.js";import{useMobileUiText}from"../../text/index.js";import{BUTTON_TEXT}from"../../text/phone/button.g.js";import{Gradient,resolveButtonSize,useTheme}from"../../theme/index.js";import{createAnimatedValue}from"../../theme/animatedValue.js";import{ariaFromState}from"../../utils/ariaState.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{ACCENT_PRESSED_TINT,tintOf}from"../../utils/color.js";import{smoothCorners}from"../../utils/corners.js";import{resolveHaptic,triggerHaptic}from"../../utils/hapticUtils.js";import{hitSlopMarker}from"../../utils/hitSlop.js";import{nativeDriver}from"../../utils/nativeDriver.js";import{renderSlotIcon}from"../AppIcon/slotIcon.js";import{Spinner}from"../Spinner/index.js";import{SquircleFill,useSquircle}from"../SquircleFill/SquircleFill.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";export const BUTTON_VARIANTS=["solid","soft","outline","ghost","link","glass"];export const BUTTON_TONES=["primary","success","warning","danger","info","neutral"];export function isButtonVariant(e){return BUTTON_VARIANTS.some(t=>t===e)}export function isButtonTone(e){return BUTTON_TONES.some(t=>t===e)}const Button=forwardRef((e,t)=>{const{label:o,variant:r,tone:s="primary",size:i,loading:n=!1,disabled:l=!1,fullWidth:a=!1,leftIcon:d,rightIcon:c,iconVariant:u,leftIconBadge:b=!1,haptic:g,rounded:p=!1,gradient:m,style:f,wrapperStyle:h,textStyle:x,pressAnimation:y,onPress:S,accessibilityLabel:T,accessibilityHint:C,accessibilityState:_,testID:I,onLayout:v,labels:j,...k}=e;assertValidValue("Button","variant",e.variant,["solid","soft","outline","ghost","link","glass"]),assertValidValue("Button","tone",e.tone,["primary","success","warning","danger","info","neutral"]),assertValidValue("Button","size",e.size,["xs","sm","md","lg","xl"]);const w=useTheme(),F=w.settings.components.button,V=r??F?.defaultVariant??"solid",O=i??F?.defaultSize??"md",L=useMobileUiText("button",BUTTON_TEXT),R=useMemo(()=>({...L,...j}),[L,j]),[A,B]=useState(!1),N=useRef(!1),P=n||A,E=!l&&!P,z={..._,disabled:!E,busy:P},H="link"===V,W=y??F?.defaultPressAnimation??(!H&&"scale"),D=usePressAnimation({preset:W||"scale",enabled:!1!==W&&E}),M=useFlickGuard(),U=useMemo(()=>buildStyles(w),[w]),q=useMemo(()=>resolveButtonSize(w,O),[w,O]),G=useMemo(()=>toneFor(w,s),[w,s]),K=useMemo(()=>variantFor(w,V,G,l),[w,V,G,l]),X=useMemo(()=>!m||l||"solid"!==V?null:"string"==typeof m?w.settings.gradients[m]??null:m,[m,l,V,w.settings.gradients]),Y=StyleSheet.flatten(f)?.borderRadius,J=H?0:"number"==typeof Y?Y:p?w.radius.pill:q.radius,Q=useSquircle(!X&&"link"!==V,J,v),Z=useRef(createAnimatedValue(0)).current,[$,ee]=useState(0),[te,oe]=useState(null),re=H?e=>ee(e.nativeEvent.layout.width):void 0,settlePending=()=>{N.current=!1,B(!1)},se=T??o,ie="outline"===V||"ghost"===V,ne=!ie&&!H,le={color:K.textColor,size:q.icon,disabled:l},ae=b&&!H&&Boolean(d),de=w.space.xs,ce=q["min-height"]-2*de-2*K.borderWidth,ue={color:K.badgeInk,size:q["badge-icon"],disabled:l},be=P?_jsx(Spinner,{variant:"circular",size:"sm",color:ae?K.badgeInk:K.textColor,accessibilityLabel:R.loading}):d?_jsx(View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:renderSlotIcon(d,ae?ue:le,u)}):null,ge=_jsxs(View,{style:U.contentRow,children:[ae?_jsx(View,{testID:"button-icon-badge",style:[U.iconLeft,U.iconBadge,{width:ce,height:ce,borderRadius:ce/2,backgroundColor:K.badgeFill}],children:be}):be?_jsx(View,{style:U.iconLeft,children:be}):null,_jsxs(View,{onLayout:re,children:[_jsx(Text,{variant:"label",weight:"semibold",numberOfLines:1,style:[U.label,{color:K.textColor,fontSize:q.text,lineHeight:Math.round(q.text*w.leading.body)},x],children:o}),H?_jsx(Animated.View,{pointerEvents:"none",testID:"button-link-underline",style:[U.linkUnderline,{backgroundColor:K.textColor,transform:[{translateX:Z.interpolate({inputRange:[0,1],outputRange:[-$/2,0]})},{scaleX:Z.interpolate({inputRange:[0,1],outputRange:[0,1]})}]}]}):null]}),c?_jsx(View,{style:U.iconRight,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:renderSlotIcon(c,le,u)}):null]}),pe=H?null===te?LINK_HIT_SLOP:Math.max(LINK_HIT_SLOP,touchSlopFor(te)):touchSlopFor(q["min-height"]),me={top:pe,bottom:pe,left:H?LINK_HIT_SLOP:0,right:H?LINK_HIT_SLOP:0};return _jsx(Animated.View,{style:[D.style,a?U.fullWidth:null,h],children:_jsx(Pressable,{ref:t,onPress:e=>{if(!E||N.current||M.isFlick(e))return;D.press();const t=resolveHaptic(g,"impactLight");t&&triggerHaptic(t);const o=S?.(e);return o instanceof Promise?(N.current=!0,B(!0),o.then(settlePending,e=>{throw settlePending(),e})):void 0},onPressIn:e=>{M.onPressIn(e),D.pressIn(),H&&E&&(Z.stopAnimation(),Z.setValue(0),Animated.timing(Z,{toValue:1,duration:w.motion.duration.slower,easing:Easing.bezier(...w.motion.ease.decelerate),useNativeDriver:nativeDriver}).start())},onPressOut:()=>{D.pressOut()},disabled:!E,hitSlop:me,...hitSlopMarker(me),accessibilityRole:"button",accessibilityLabel:se,accessibilityHint:C,accessibilityState:z,...ariaFromState(z),testID:I,onLayout:e=>{Q.onLayout(e),H&&oe(e.nativeEvent.layout.height)},style:({pressed:e})=>[U.base,{paddingHorizontal:H?0:q["padding-x"],paddingVertical:H?0:ae?de:q["padding-y"],paddingLeft:ae?de:void 0,minHeight:H?void 0:q["min-height"],borderRadius:J,...smoothCorners,backgroundColor:X||Q.active?"transparent":K.backgroundColor,borderWidth:K.borderWidth,borderColor:Q.active?"transparent":K.borderColor,opacity:P?.55:1,overflow:Q.active||H?"visible":"hidden"},e&&ie&&!Q.active?{backgroundColor:w.colors["surface-pressed"]}:null,a?U.fullWidth:null,f],...k,"aria-disabled":!E,"aria-busy":P,children:({pressed:e})=>_jsxs(_Fragment,{children:[Q.active&&Q.size?_jsx(SquircleFill,{width:Q.size.width,height:Q.size.height,radius:J,fill:e&&ie?w.colors["surface-pressed"]:K.backgroundColor,stroke:K.borderColor,strokeWidth:K.borderWidth}):null,X?_jsx(Gradient,{gradient:X,style:[StyleSheet.absoluteFill,{borderRadius:J,...smoothCorners}]}):null,e&&ne?Q.active&&Q.size?_jsx(SquircleFill,{width:Q.size.width,height:Q.size.height,radius:J,fill:K.pressedTint,testID:"button-pressed"}):_jsx(View,{pointerEvents:"none",style:[U.pressedOverlay,{borderRadius:J,backgroundColor:K.pressedTint,...smoothCorners}],testID:"button-pressed"}):null,ge]})})})});Button.displayName="Button";const SOFT_FILL_OPACITY=.14,toneFor=(e,t)=>{switch(t){case"primary":return{base:e.colors.primary,outline:e.colors.primary,on:e.colors["on-primary"],fg:e.colors["primary-text"],soft:tintOf(e.colors.primary,.14,e.colors["primary-soft"])};case"success":return{base:e.colors.success,outline:e.colors.success,on:e.colors["on-success"],fg:e.colors["success-text"],soft:tintOf(e.colors.success,.14,e.colors["bg-subtle"])};case"warning":return{base:e.colors.warning,outline:e.colors.warning,on:e.colors["on-warning"],fg:e.colors["warning-text"],soft:tintOf(e.colors.warning,.14,e.colors["bg-subtle"])};case"danger":return{base:e.colors.danger,outline:e.colors.danger,on:e.colors["on-danger"],fg:e.colors["danger-text"],soft:tintOf(e.colors.danger,.14,e.colors["bg-subtle"])};case"info":return{base:e.colors.info,outline:e.colors.info,on:e.colors["on-info"],fg:e.colors["info-text"],soft:tintOf(e.colors.info,.14,e.colors["bg-subtle"])};case"neutral":return{base:e.colors["bg-muted"],outline:e.colors.border,on:e.colors["text-body"],fg:e.colors["text-body"],soft:e.colors["bg-subtle"]}}},BUTTON_BORDER_WIDTH=1,MIN_TOUCH_TARGET=44,LINK_HIT_SLOP=8,touchSlopFor=e=>Math.max(0,Math.ceil((44-e)/2)),variantFor=(e,t,o,r)=>{const s=r?e.colors["text-disabled"]:o.fg,i={badgeFill:e.colors["surface-disabled"],badgeInk:e.colors["text-disabled"]},n=r?i:{badgeFill:o.on,badgeInk:o.base},l=r?i:{badgeFill:o.base,badgeInk:o.on};switch(t){case"solid":return{backgroundColor:r?e.colors["surface-disabled"]:o.base,borderColor:"transparent",borderWidth:1,textColor:r?e.colors["text-disabled"]:o.on,pressedTint:e.colors["surface-pressed"],...n};case"soft":return{backgroundColor:r?e.colors["surface-disabled"]:o.soft,borderColor:"transparent",borderWidth:1,textColor:s,pressedTint:e.colors["surface-pressed"],...l};case"outline":return{backgroundColor:"transparent",borderColor:r?e.colors.border:o.outline,borderWidth:1,textColor:s,pressedTint:e.colors["surface-pressed"],...l};case"ghost":return{backgroundColor:"transparent",borderColor:"transparent",borderWidth:1,textColor:s,pressedTint:e.colors["surface-pressed"],...l};case"link":return{backgroundColor:"transparent",borderColor:"transparent",borderWidth:0,textColor:r?e.colors["text-disabled"]:e.colors.link,pressedTint:e.colors["surface-pressed"],...l};case"glass":return{backgroundColor:e.colors["glass-fill"],borderColor:e.colors["glass-border"],borderWidth:1,textColor:r?e.colors["text-disabled"]:e.colors["on-glass"],pressedTint:ACCENT_PRESSED_TINT,badgeFill:e.colors["glass-badge"],badgeInk:r?e.colors["text-disabled"]:o.base};default:return{backgroundColor:o.base,borderColor:"transparent",borderWidth:1,textColor:o.on,pressedTint:e.colors["surface-pressed"],...n}}};export function buttonLabelInk(e,t){return variantFor(t,e.variant??"solid",toneFor(t,e.tone??"primary"),e.disabled??!1).textColor}const buildStyles=e=>StyleSheet.create({pressedOverlay:{position:"absolute",top:0,right:0,bottom:0,left:0},base:{alignItems:"center",justifyContent:"center",flexDirection:"row",overflow:"hidden"},contentRow:{flexDirection:"row",alignItems:"center",justifyContent:"center"},label:{textAlign:"center",includeFontPadding:!1,textAlignVertical:"center"},linkUnderline:{height:1.5,marginTop:e.size.border},iconLeft:{marginRight:e.space.sm},iconBadge:{alignItems:"center",justifyContent:"center"},iconRight:{marginLeft:e.space.sm},fullWidth:{alignSelf:"stretch"}});export{Button};export default Button;
|
|
1
|
+
"use strict";import{useMemo,useRef,useState}from"react";import{Animated,Easing,Pressable,StyleSheet,View}from"react-native";import{useFlickGuard}from"../../hooks/useFlickGuard.js";import{usePressAnimation}from"../../hooks/usePressAnimation.js";import{useMobileUiText}from"../../text/index.js";import{BUTTON_TEXT}from"../../text/phone/button.g.js";import{Gradient,resolveButtonSize,useTheme}from"../../theme/index.js";import{createAnimatedValue}from"../../theme/animatedValue.js";import{ariaFromState}from"../../utils/ariaState.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{ACCENT_PRESSED_TINT,tintOf}from"../../utils/color.js";import{smoothCorners}from"../../utils/corners.js";import{resolveHaptic,triggerHaptic}from"../../utils/hapticUtils.js";import{hitSlopMarker}from"../../utils/hitSlop.js";import{nativeDriver}from"../../utils/nativeDriver.js";import{renderSlotIcon}from"../AppIcon/slotIcon.js";import{Spinner}from"../Spinner/index.js";import{SquircleFill,useSquircle}from"../SquircleFill/SquircleFill.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";export const BUTTON_VARIANTS=["solid","soft","outline","ghost","link","glass"];export const BUTTON_TONES=["primary","success","warning","danger","info","neutral"];export function isButtonVariant(e){return BUTTON_VARIANTS.some(t=>t===e)}export function isButtonTone(e){return BUTTON_TONES.some(t=>t===e)}function Button({ref:e,...t}){const{label:o,variant:r,tone:s="primary",size:i,loading:n=!1,disabled:l=!1,fullWidth:a=!1,leftIcon:d,rightIcon:c,iconVariant:u,leftIconBadge:b=!1,haptic:g,rounded:p=!1,gradient:m,style:f,wrapperStyle:h,textStyle:x,pressAnimation:y,onPress:S,accessibilityLabel:T,accessibilityHint:C,accessibilityState:_,testID:I,onLayout:v,labels:j,...k}=t;assertValidValue("Button","variant",t.variant,["solid","soft","outline","ghost","link","glass"]),assertValidValue("Button","tone",t.tone,["primary","success","warning","danger","info","neutral"]),assertValidValue("Button","size",t.size,["xs","sm","md","lg","xl"]);const w=useTheme(),F=w.settings.components.button,V=r??F?.defaultVariant??"solid",O=i??F?.defaultSize??"md",L=useMobileUiText("button",BUTTON_TEXT),A=useMemo(()=>({...L,...j}),[L,j]),[R,B]=useState(!1),N=useRef(!1),P=n||R,E=!l&&!P,z={..._,disabled:!E,busy:P},H="link"===V,W=y??F?.defaultPressAnimation??(!H&&"scale"),D=usePressAnimation({preset:W||"scale",enabled:!1!==W&&E}),M=useFlickGuard(),U=useMemo(()=>buildStyles(w),[w]),q=useMemo(()=>resolveButtonSize(w,O),[w,O]),G=useMemo(()=>toneFor(w,s),[w,s]),K=useMemo(()=>variantFor(w,V,G,l),[w,V,G,l]),X=useMemo(()=>!m||l||"solid"!==V?null:"string"==typeof m?w.settings.gradients[m]??null:m,[m,l,V,w.settings.gradients]),Y=StyleSheet.flatten(f)?.borderRadius,J=H?0:"number"==typeof Y?Y:p?w.radius.pill:q.radius,Q=useSquircle(!X&&"link"!==V,J,v),Z=useRef(createAnimatedValue(0)).current,[$,ee]=useState(0),[te,oe]=useState(null),re=H?e=>ee(e.nativeEvent.layout.width):void 0,settlePending=()=>{N.current=!1,B(!1)},se=T??o,ie="outline"===V||"ghost"===V,ne=!ie&&!H,le={color:K.textColor,size:q.icon,disabled:l},ae=b&&!H&&Boolean(d),de=w.space.xs,ce=q["min-height"]-2*de-2*K.borderWidth,ue={color:K.badgeInk,size:q["badge-icon"],disabled:l},be=P?_jsx(Spinner,{variant:"circular",size:"sm",color:ae?K.badgeInk:K.textColor,accessibilityLabel:A.loading}):d?_jsx(View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:renderSlotIcon(d,ae?ue:le,u)}):null,ge=_jsxs(View,{style:U.contentRow,children:[ae?_jsx(View,{testID:"button-icon-badge",style:[U.iconLeft,U.iconBadge,{width:ce,height:ce,borderRadius:ce/2,backgroundColor:K.badgeFill}],children:be}):be?_jsx(View,{style:U.iconLeft,children:be}):null,_jsxs(View,{onLayout:re,children:[_jsx(Text,{variant:"label",weight:"semibold",numberOfLines:1,style:[U.label,{color:K.textColor,fontSize:q.text,lineHeight:Math.round(q.text*w.leading.body)},x],children:o}),H?_jsx(Animated.View,{pointerEvents:"none",testID:"button-link-underline",style:[U.linkUnderline,{backgroundColor:K.textColor,transform:[{translateX:Z.interpolate({inputRange:[0,1],outputRange:[-$/2,0]})},{scaleX:Z.interpolate({inputRange:[0,1],outputRange:[0,1]})}]}]}):null]}),c?_jsx(View,{style:U.iconRight,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:renderSlotIcon(c,le,u)}):null]}),pe=H?null===te?LINK_HIT_SLOP:Math.max(LINK_HIT_SLOP,touchSlopFor(te)):touchSlopFor(q["min-height"]),me={top:pe,bottom:pe,left:H?LINK_HIT_SLOP:0,right:H?LINK_HIT_SLOP:0};return _jsx(Animated.View,{style:[D.style,a?U.fullWidth:null,h],children:_jsx(Pressable,{ref:e,onPress:e=>{if(!E||N.current||M.isFlick(e))return;D.press();const t=resolveHaptic(g,"impactLight");t&&triggerHaptic(t);const o=S?.(e);return o instanceof Promise?(N.current=!0,B(!0),o.then(settlePending,e=>{throw settlePending(),e})):void 0},onPressIn:e=>{M.onPressIn(e),D.pressIn(),H&&E&&(Z.stopAnimation(),Z.setValue(0),Animated.timing(Z,{toValue:1,duration:w.motion.duration.slower,easing:Easing.bezier(...w.motion.ease.decelerate),useNativeDriver:nativeDriver}).start())},onPressOut:()=>{D.pressOut()},disabled:!E,hitSlop:me,...hitSlopMarker(me),accessibilityRole:"button",accessibilityLabel:se,accessibilityHint:C,accessibilityState:z,...ariaFromState(z),testID:I,onLayout:e=>{Q.onLayout(e),H&&oe(e.nativeEvent.layout.height)},style:({pressed:e})=>[U.base,{paddingHorizontal:H?0:q["padding-x"],paddingVertical:H?0:ae?de:q["padding-y"],paddingLeft:ae?de:void 0,minHeight:H?void 0:q["min-height"],borderRadius:J,...smoothCorners,backgroundColor:X||Q.active?"transparent":K.backgroundColor,borderWidth:K.borderWidth,borderColor:Q.active?"transparent":K.borderColor,opacity:P?.55:1,overflow:Q.active||H?"visible":"hidden"},e&&ie&&!Q.active?{backgroundColor:w.colors["surface-pressed"]}:null,a?U.fullWidth:null,f],...k,"aria-disabled":!E,"aria-busy":P,children:({pressed:e})=>_jsxs(_Fragment,{children:[Q.active&&Q.size?_jsx(SquircleFill,{width:Q.size.width,height:Q.size.height,radius:J,fill:e&&ie?w.colors["surface-pressed"]:K.backgroundColor,stroke:K.borderColor,strokeWidth:K.borderWidth}):null,X?_jsx(Gradient,{gradient:X,style:[StyleSheet.absoluteFill,{borderRadius:J,...smoothCorners}]}):null,e&&ne?Q.active&&Q.size?_jsx(SquircleFill,{width:Q.size.width,height:Q.size.height,radius:J,fill:K.pressedTint,testID:"button-pressed"}):_jsx(View,{pointerEvents:"none",style:[U.pressedOverlay,{borderRadius:J,backgroundColor:K.pressedTint,...smoothCorners}],testID:"button-pressed"}):null,ge]})})})}const SOFT_FILL_OPACITY=.14,toneFor=(e,t)=>{switch(t){case"primary":return{base:e.colors.primary,outline:e.colors.primary,on:e.colors["on-primary"],fg:e.colors["primary-text"],soft:tintOf(e.colors.primary,.14,e.colors["primary-soft"])};case"success":return{base:e.colors.success,outline:e.colors.success,on:e.colors["on-success"],fg:e.colors["success-text"],soft:tintOf(e.colors.success,.14,e.colors["bg-subtle"])};case"warning":return{base:e.colors.warning,outline:e.colors.warning,on:e.colors["on-warning"],fg:e.colors["warning-text"],soft:tintOf(e.colors.warning,.14,e.colors["bg-subtle"])};case"danger":return{base:e.colors.danger,outline:e.colors.danger,on:e.colors["on-danger"],fg:e.colors["danger-text"],soft:tintOf(e.colors.danger,.14,e.colors["bg-subtle"])};case"info":return{base:e.colors.info,outline:e.colors.info,on:e.colors["on-info"],fg:e.colors["info-text"],soft:tintOf(e.colors.info,.14,e.colors["bg-subtle"])};case"neutral":return{base:e.colors["bg-muted"],outline:e.colors.border,on:e.colors["text-body"],fg:e.colors["text-body"],soft:e.colors["bg-subtle"]}}},BUTTON_BORDER_WIDTH=1,MIN_TOUCH_TARGET=44,LINK_HIT_SLOP=8,touchSlopFor=e=>Math.max(0,Math.ceil((44-e)/2)),variantFor=(e,t,o,r)=>{const s=r?e.colors["text-disabled"]:o.fg,i={badgeFill:e.colors["surface-disabled"],badgeInk:e.colors["text-disabled"]},n=r?i:{badgeFill:o.on,badgeInk:o.base},l=r?i:{badgeFill:o.base,badgeInk:o.on};switch(t){case"solid":return{backgroundColor:r?e.colors["surface-disabled"]:o.base,borderColor:"transparent",borderWidth:1,textColor:r?e.colors["text-disabled"]:o.on,pressedTint:e.colors["surface-pressed"],...n};case"soft":return{backgroundColor:r?e.colors["surface-disabled"]:o.soft,borderColor:"transparent",borderWidth:1,textColor:s,pressedTint:e.colors["surface-pressed"],...l};case"outline":return{backgroundColor:"transparent",borderColor:r?e.colors.border:o.outline,borderWidth:1,textColor:s,pressedTint:e.colors["surface-pressed"],...l};case"ghost":return{backgroundColor:"transparent",borderColor:"transparent",borderWidth:1,textColor:s,pressedTint:e.colors["surface-pressed"],...l};case"link":return{backgroundColor:"transparent",borderColor:"transparent",borderWidth:0,textColor:r?e.colors["text-disabled"]:e.colors.link,pressedTint:e.colors["surface-pressed"],...l};case"glass":return{backgroundColor:e.colors["glass-fill"],borderColor:e.colors["glass-border"],borderWidth:1,textColor:r?e.colors["text-disabled"]:e.colors["on-glass"],pressedTint:ACCENT_PRESSED_TINT,badgeFill:e.colors["glass-badge"],badgeInk:r?e.colors["text-disabled"]:o.base};default:return{backgroundColor:o.base,borderColor:"transparent",borderWidth:1,textColor:o.on,pressedTint:e.colors["surface-pressed"],...n}}};export function buttonLabelInk(e,t){return variantFor(t,e.variant??"solid",toneFor(t,e.tone??"primary"),e.disabled??!1).textColor}const buildStyles=e=>StyleSheet.create({pressedOverlay:{position:"absolute",top:0,right:0,bottom:0,left:0},base:{alignItems:"center",justifyContent:"center",flexDirection:"row",overflow:"hidden"},contentRow:{flexDirection:"row",alignItems:"center",justifyContent:"center"},label:{textAlign:"center",includeFontPadding:!1,textAlignVertical:"center"},linkUnderline:{height:1.5,marginTop:e.size.border},iconLeft:{marginRight:e.space.sm},iconBadge:{alignItems:"center",justifyContent:"center"},iconRight:{marginLeft:e.space.sm},fullWidth:{alignSelf:"stretch"}});export{Button};export default Button;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{
|
|
1
|
+
"use strict";import{useCallback,useEffect,useLayoutEffect,useMemo,useRef}from"react";import{AccessibilityInfo,Animated,Easing,Pressable,View}from"react-native";import{useControllableState,usePresenceMotion}from"../../hooks/index.js";import{useMobileUiText}from"../../text/index.js";import{CALENDAR_TEXT}from"../../text/phone/calendar.g.js";import{createAnimatedValue,useTheme}from"../../theme/index.js";import{resolveHaptic,triggerHaptic}from"../../utils/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{hitSlopMarker}from"../../utils/hitSlop.js";import{nativeDriver}from"../../utils/nativeDriver.js";import{Text}from"../Text/index.js";import{CalendarDay}from"./CalendarDay.js";import{addMonths,buildMonthMatrix,GRID_CELLS,startOfDay,startOfMonth,toIso,weekdayLabels}from"./calendarDates.js";import{buildCalendarStyles,MIN_CELL_SIZE,NAV_BUTTON_SIZE}from"./calendarStyles.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const MAX_DOTS=3,DAY_TEXT_MAX_SCALE=1.5,toneColor=(e,t)=>{switch(t){case"success":return e.colors.success;case"warning":return e.colors.warning;case"danger":return e.colors.danger;case"info":return e.colors.info;case"primary":return e.colors.primary;case"neutral":return e.colors["text-muted"]}};function Calendar({ref:e,...t}){const{selectionMode:a="single",value:s,onChange:i,month:n,onMonthChange:r,minDate:l,maxDate:o,disabledDates:d,weekStartsOn:u=0,locale:c="en-IN",marks:m,cellSize:h,haptic:p,accessibilityLabel:b,onTitlePress:g,labels:f,style:y,headerLabelStyle:M,navButtonStyle:x,testID:v}=t;assertValidValue("Calendar","selectionMode",t.selectionMode,["single","range"]);const D=useMobileUiText("calendar",CALENDAR_TEXT),T=useMemo(()=>({...D,...f}),[D,f]),_=T.marked,S=useTheme(),j=usePresenceMotion(),L=useMemo(()=>buildCalendarStyles(S),[S]),[w,C]=useControllableState({value:n?startOfMonth(n):void 0,defaultValue:startOfMonth(s?.start??new Date),onChange:r}),E=12*w.getFullYear()+w.getMonth(),A=s?.start?startOfDay(s.start):null,k="range"===a&&s?.end?startOfDay(s.end):null,V=A?.getTime()??null,I=k?.getTime()??null,R=toIso(new Date),N=l?startOfDay(l).getTime():null,O=o?startOfDay(o).getTime():null,P=useMemo(()=>new Set((d??[]).map(e=>toIso(e))),[d]),F=useCallback(e=>null!==N&&e.getTime()<N||null!==O&&e.getTime()>O||P.has(toIso(e)),[N,O,P]),B=useMemo(()=>{const e=new Map;for(const t of m??[]){const a=t.date;let s=e.get(a);s||(s={dots:[],spoken:[]},e.set(a,s)),s.dots.length<3&&s.dots.push({key:`${t.tone}-${s.dots.length}`,color:toneColor(S,t.tone)}),s.spoken.push(t.label??_)}return e},[m,S,_]),H=useMemo(()=>buildMonthMatrix(new Date(Math.floor(E/12),E%12,1),u),[E,u]),X=useMemo(()=>weekdayLabels(c,u),[c,u]),z=useMemo(()=>new Intl.DateTimeFormat(c,{month:"long",year:"numeric"}),[c]),Z=useMemo(()=>new Intl.DateTimeFormat(c,{weekday:"short",day:"numeric",month:"long"}),[c]),$=z.format(w),U=null===N||startOfMonth(new Date(N)).getTime()<w.getTime(),q=null===O||startOfMonth(new Date(O)).getTime()>w.getTime(),G=useRef(createAnimatedValue(0)).current,Y=useRef(createAnimatedValue(1)).current,W=useRef(null);useEffect(()=>()=>W.current?.stop(),[]);const J=useCallback(e=>{!1!==p&&triggerHaptic("impactLight");const t=S.motion.duration.fast,a=S.motion.duration.fast,[s]=j.range(32*-e,0),[i]=j.range(32*e,0),n=j.reduced?j.duration("fast"):t,r=j.reduced?j.duration("fast"):a;W.current?.stop(),W.current=Animated.sequence([Animated.parallel([Animated.timing(G,{toValue:s,duration:t,easing:Easing.out(Easing.quad),useNativeDriver:nativeDriver}),Animated.timing(Y,{toValue:0,duration:n,useNativeDriver:nativeDriver})]),Animated.timing(G,{toValue:i,duration:0,useNativeDriver:nativeDriver}),Animated.parallel([Animated.timing(G,{toValue:0,duration:a,easing:Easing.out(Easing.cubic),useNativeDriver:nativeDriver}),Animated.timing(Y,{toValue:1,duration:r,useNativeDriver:nativeDriver})])]),W.current.start();const l=addMonths(w,e);C(l),AccessibilityInfo.announceForAccessibility(z.format(l))},[p,w,Y,z,G,j,C,S]),K=useCallback(()=>J(-1),[J]),Q=useCallback(()=>J(1),[J]),pressDay=e=>{if(F(e.date))return;const t=resolveHaptic(p,"selection");t&&triggerHaptic(t);const s=e.date;"single"===a||!A||k||s.getTime()<A.getTime()?i({start:s}):i({start:A,end:s}),e.inMonth||C(startOfMonth(s))},ee=useRef(pressDay);useLayoutEffect(()=>{ee.current=pressDay});const te=useCallback(e=>ee.current(e),[]),ae=void 0===h?void 0:Math.max(h,MIN_CELL_SIZE),se=useMemo(()=>void 0===ae?{flex:1}:{width:ae},[ae]),ie=useMemo(()=>void 0===ae?{flex:1,aspectRatio:1,minHeight:MIN_CELL_SIZE}:{width:ae,height:ae},[ae]),ne=Math.max(S.space.sm,(MIN_CELL_SIZE-NAV_BUTTON_SIZE)/2),re=Math.min(S.settings.maxFontSizeMultiplier??1.5,1.5),le=[];for(let e=0;e<GRID_CELLS;e+=7)le.push(H.slice(e,e+7));const oe=_jsx(Text,{variant:"title",accessibilityRole:"header",accessibilityLabel:b?`${b}, ${$}`:void 0,style:L.headerLabel,children:$});return _jsxs(View,{ref:e,style:[L.root,y],testID:v,children:[_jsxs(View,{style:L.headerRow,children:[_jsx(Pressable,{onPress:K,disabled:!U,style:({pressed:e})=>[L.navBtn,e&&L.navBtnPressed,!U&&L.navBtnDisabled,x],accessibilityRole:"button",accessibilityLabel:T.previousMonth,accessibilityState:{disabled:!U},"aria-disabled":!U,hitSlop:ne,...hitSlopMarker(ne),children:_jsx(Text,{variant:"title",style:L.navText,maxFontSizeMultiplier:re,children:"‹"})}),_jsx(Animated.View,{style:[L.headerLabelWrap,{opacity:Y,transform:[{translateX:G}]},M],children:g?_jsx(Pressable,{onPress:g,accessibilityRole:"button",accessibilityLabel:b?`${b}, ${$}`:$,hitSlop:ne,...hitSlopMarker(ne),children:oe}):oe}),_jsx(Pressable,{onPress:Q,disabled:!q,style:({pressed:e})=>[L.navBtn,e&&L.navBtnPressed,!q&&L.navBtnDisabled,x],accessibilityRole:"button",accessibilityLabel:T.nextMonth,accessibilityState:{disabled:!q},"aria-disabled":!q,hitSlop:ne,...hitSlopMarker(ne),children:_jsx(Text,{variant:"title",style:L.navText,maxFontSizeMultiplier:re,children:"›"})})]}),_jsx(View,{style:L.weekdayRow,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:X.map(({weekday:e,label:t})=>_jsx(View,{style:[L.weekdayCell,se],children:_jsx(Text,{variant:"caption",style:L.weekdayText,maxFontSizeMultiplier:re,children:t})},e))}),_jsx(Animated.View,{style:{opacity:Y,transform:[{translateX:G}]},children:le.map(e=>_jsx(View,{style:L.gridRow,children:e.map(e=>{const t=e.date.getTime(),s=null!==V&&t===V,i=null!==I&&t===I,n=null!==V&&null!==I&&t>=V&&t<=I,r=n&&!s&&!i,l=e.iso===R,o=B.get(e.iso),d=[Z.format(e.date),...o?.spoken??[]];return l&&d.push(T.today),"range"===a&&(s&&i?d.push(T.startEndRangeLabel):s?d.push(T.startRangeLabel):i?d.push(T.endRangeLabel):r&&d.push(T.inRangeLabel)),_jsx(CalendarDay,{cell:e,accessibilityLabel:d.join(", "),disabled:F(e.date),edge:s||i,mid:r,barLeft:n&&(i||r)&&!(s&&i),barRight:n&&(s||r)&&!(s&&i),today:l,dots:o?.dots,cellStyle:ie,styles:L,maxFontSizeMultiplier:re,onPressDay:te},e.iso)})},e.map(e=>e.iso).join(",")))})]})}export{Calendar};export default Calendar;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import React,{forwardRef,useMemo}from"react";import{Animated,Image,Pressable,StyleSheet,View}from"react-native";import{useControllableState}from"../../hooks/useControllableState.js";import{usePressAnimation}from"../../hooks/usePressAnimation.js";import{useMobileUiText}from"../../text/index.js";import{CARD_TEXT}from"../../text/phone/card.g.js";import{fontFor,Gradient,useTheme}from"../../theme/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{smoothCorners}from"../../utils/corners.js";import{isOneOf}from"../../utils/guards.js";import{triggerHaptic}from"../../utils/hapticUtils.js";import{mergeRefs}from"../../utils/mergeRefs.js";import{supportsBoxShadow,toBoxShadow}from"../../utils/shadows.js";import{squircleHostRadius}from"../../utils/squircle.js";import{themeStyles}from"../../utils/themeStyles.js";import{AppIcon}from"../AppIcon/AppIcon.js";import{useContextMenu}from"../Menu/useContextMenu.js";import{Skeleton,SkeletonText}from"../Skeleton/index.js";import{SquircleFill,useSquircle}from"../SquircleFill/SquircleFill.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";const OUTER_LAYOUT_KEYS=new Set(["flex","flexGrow","flexShrink","flexBasis","alignSelf","width","height","minWidth","maxWidth","minHeight","maxHeight","position","top","right","bottom","left","start","end","zIndex"]),splitOuterLayout=e=>{const t={},i={};for(const[s,o]of Object.entries(StyleSheet.flatten(e)??{}))(OUTER_LAYOUT_KEYS.has(s)||s.startsWith("margin")?t:i)[s]=o;return{outer:t,inner:i}},flexStyleOf=e=>void 0===e?[]:[{flex:e}],BACKGROUND_TOKENS=["bg","bg-subtle","bg-muted","surface","scrim","surface-inverse","primary-wash"],paddingMap={none:"none",sm:"sm",md:"lg",lg:"xl",xl:"2xl"},CardRoot=React.memo(forwardRef((e,t)=>{const{children:i,variant:s,elevation:o="card",radius:r,padding:l,interactive:a=!1,pressAnimation:n="scale",bg:d,header:c,title:u,titleFont:m,lead:h,action:p,headerActions:g,collapsible:b=!1,collapsed:f,defaultCollapsed:x=!1,onCollapsedChange:y,collapsedSummary:S,onRemove:j,separatorHeight:C=StyleSheet.hairlineWidth,footer:v,imageSource:_,imageHeight:w=160,imageAspectRatio:R,imageOverlay:A,loading:T=!1,gradient:V,onPress:F,haptic:k,contextMenu:B,accessibilityLabel:O,accessibilityHint:I,accessibilityRole:H,flex:L,style:P,headerStyle:z,bodyStyle:M,footerStyle:E,testID:q,labels:W,onLayout:D,...U}=e;assertValidValue("Card","variant",e.variant,["elevated","outline","filled","flat"]),assertValidValue("Card","radius",e.radius,["sm","md","lg","xl","pill"]),assertValidValue("Card","padding",e.padding,["none","sm","md","lg","xl"]),assertValidValue("Card","titleFont",e.titleFont,["sans","serif"]),assertValidValue("Card","pressAnimation",e.pressAnimation,["scale","bounce","fade","sink","pulse","dim","false"]);const N=useTheme(),G=N.settings.components.card,K=s??G?.defaultVariant??"elevated",Y=r??G?.defaultRadius??"lg",X=l??G?.defaultPadding??"md",$=m??G?.defaultTitleFont??"sans",J=useMobileUiText("card",CARD_TEXT),Q=useMemo(()=>({...J,...W}),[J,W]),Z=a||"function"==typeof F,ee=useContextMenu(B,{haptic:k||!1,testID:q,accessibilityActions:U.accessibilityActions,onAccessibilityAction:U.onAccessibilityAction}),te=useMemo(()=>mergeRefs(t,ee.hostRef),[t,ee.hostRef]),ie=Z||ee.enabled,{style:se,pressIn:oe,pressOut:re}=usePressAnimation({preset:n||"scale",enabled:ie&&!1!==n}),le=stylesFor(N),ae=Boolean(_),ne=N.space[paddingMap[X]],de=useMemo(()=>V?"string"==typeof V?N.settings.gradients[V]??null:V:null,[V,N.settings.gradients]),ce="flat"===K,ue=ce?N.radius.none:N.radius[Y],me=resolveBackground(N,d),[he,pe]=useControllableState({value:f,defaultValue:x,onChange:y}),ge=b&&he,be=hasBuiltInHeaderContent(e),fe=Boolean(c)||be,xe=useSquircle(!ae&&!de&&!ce,ue,D),ye=StyleSheet.flatten(P)??{},Se="string"==typeof ye.backgroundColor?ye.backgroundColor:void 0,je="string"==typeof ye.borderColor?ye.borderColor:void 0,Ce=Se??me??("filled"===K?N.colors["bg-subtle"]:N.colors.surface),ve="outline"===K?N.size.border:0,we=je??N.colors.border,Re="none"===o?void 0:N.shadow[o],Ae="elevated"===K&&supportsBoxShadow()&&Re?toBoxShadow(Re):void 0,Te=xe.active&&"elevated"===K&&!Ae,Ve=xe.active&&!Te?{backgroundColor:"transparent",borderColor:"transparent"}:null,Fe=useMemo(()=>{const e={borderRadius:Te&&xe.size?squircleHostRadius(xe.size.width,xe.size.height,ue):ue,...smoothCorners,padding:ae||xe.active?N.space.none:ne,overflow:xe.active?"visible":"hidden"};switch(K){case"flat":return{...e,backgroundColor:me??N.colors.surface,borderBottomWidth:C,borderBottomColor:N.colors.border};case"outline":return{...e,backgroundColor:xe.active?"transparent":me??N.colors.surface,borderWidth:N.size.border,borderColor:xe.active?"transparent":N.colors.border};case"filled":return{...e,backgroundColor:xe.active?"transparent":me??N.colors["bg-subtle"]};default:return{...e,backgroundColor:me??N.colors.surface,...Ae?{boxShadow:Ae}:Re}}},[N,K,Re,ue,ae,ne,xe.active,xe.size,Ae,Te,me,C]),ke=useMemo(()=>({..."number"==typeof R?{width:"100%",aspectRatio:R}:{width:"100%",height:w},borderTopLeftRadius:ue,borderTopRightRadius:ue,borderBottomLeftRadius:N.radius.none,borderBottomRightRadius:N.radius.none,...smoothCorners}),[N,ue,R,w]),Be=u??"",Oe=_jsxs(_Fragment,{children:[_jsxs(View,{style:le.titleColumn,children:[u?_jsx(Text,{variant:"title",accessibilityRole:"header",style:titleFaceFor(N,$),children:u}):null,h?_jsx(Text,{variant:"bodySmall",style:le.lead,children:h}):null,ge&&S?_jsx(Text,{variant:"caption",style:le.lead,children:S}):null]}),isCardTextAction(p)?_jsx(CardTextActionButton,{action:p,haptic:k}):p?_jsx(View,{style:le.actionNode,children:p}):null,g,b?_jsx(CardIconAction,{icon:ge?"chevron-down":"chevron-up",label:`${ge?Q.show:Q.hide} ${Be}`.trim(),expanded:!ge,onPress:()=>pe(!ge),haptic:k}):null,j?_jsx(CardIconAction,{icon:"trash",label:Q.remove,onPress:j,color:N.colors["danger-text"],haptic:k}):null]}),Ie=_jsxs(_Fragment,{children:[fe?_jsx(View,{style:[le.header,!c&&le.headerRow,ge&&le.headerFolded,z],children:c??Oe}):null,ge?null:_jsx(View,{style:[fe||v?le.body:null,M],children:i}),v&&!ge?_jsx(View,{style:[le.footer,E],children:v}):null]}),He=_?_jsxs(_Fragment,{children:[_jsxs(View,{style:le.imageWrapper,children:[_jsx(Image,{source:_,resizeMode:"cover",style:ke,accessibilityLabel:"",accessible:!1}),A?_jsx(View,{pointerEvents:"box-none",style:le.imageOverlay,children:A}):null]}),_jsx(View,{style:{padding:ne},children:Ie})]}):Ie,Le=de?_jsxs(_Fragment,{children:[_jsx(Gradient,{gradient:de,style:StyleSheet.absoluteFill}),He]}):xe.active&&xe.size?_jsxs(_Fragment,{children:[_jsx(SquircleFill,{width:xe.size.width,height:xe.size.height,radius:ue,fill:Ce,stroke:ve?we:void 0,strokeWidth:ve}),_jsx(View,{style:[le.squircleClip,{padding:ne,borderRadius:xe.size?squircleHostRadius(xe.size.width,xe.size.height,ue):ue}],children:He})]}):He,{outer:Pe,inner:ze}=splitOuterLayout(P);let Me;if(ie){const handlePress=e=>{Z&&(k&&triggerHaptic(k),F?.(e))};Me=_jsx(Animated.View,{style:[se,...flexStyleOf(L),Pe],children:_jsx(Pressable,{ref:te,onPress:handlePress,onPressIn:oe,onPressOut:re,accessibilityRole:H??(Z?"button":void 0),accessibilityLabel:O,accessibilityHint:I,testID:q,onLayout:xe.onLayout,style:[Fe,ze,Ve,le.pressFill],...U,...ee.hostProps,children:Le})})}else Me=_jsx(View,{ref:t,accessibilityLabel:O,accessibilityHint:I,accessibilityRole:H,testID:q,onLayout:xe.onLayout,style:[Fe,...flexStyleOf(L),P,Ve],...U,children:Le});return T?_jsx(CardSkeleton,{...e}):ee.enabled?_jsxs(_Fragment,{children:[Me,ee.renderSurface(_jsx(View,{style:[Fe,P,Ve,le.preview],children:Le}))]}):Me})),CardSkeleton=({variant:e,elevation:t,radius:i,padding:s,bg:o,header:r,footer:l,imageSource:a,imageHeight:n=160,imageAspectRatio:d,headerStyle:c,bodyStyle:u,footerStyle:m,flex:h,style:p,labels:g,...b})=>{const f=useTheme(),x=f.settings.components.card,y=e??x?.defaultVariant??"elevated",S=i??x?.defaultRadius??"lg",j=s??x?.defaultPadding??"md",C={...useMobileUiText("card",CARD_TEXT),...g},v=paddingMap[j],_=f.space[v],w="flat"===y?f.radius.none:f.radius[S],R=void 0!==r||hasBuiltInHeaderContent(b),A=resolveBackground(f,o)??f.colors.surface,T="outline"===y?1:0,V="outline"===y?f.colors.border:void 0;return _jsxs(View,{style:[{backgroundColor:A,borderRadius:w,...smoothCorners,borderWidth:T,borderColor:V,overflow:"hidden"},...flexStyleOf(h),p],accessibilityRole:"progressbar",accessibilityLabel:C.loading,accessibilityState:{busy:!0},"aria-busy":!0,children:[void 0!==a?_jsx(Skeleton,{width:"100%",height:d?void 0:n,style:d?{aspectRatio:d,width:"100%"}:void 0}):null,R?_jsx(View,{style:[{padding:_,paddingBottom:f.space.sm},c],children:_jsx(Skeleton,{shape:"text",width:"60%",height:18})}):null,_jsx(View,{style:[{padding:_},u],children:_jsx(SkeletonText,{lines:3,fontSize:f.text.base.size,lastLineWidth:"55%"})}),void 0!==l?_jsx(View,{style:[{padding:_,paddingTop:f.space.sm,flexDirection:"row"},m],children:_jsx(Skeleton,{width:88,height:32,shape:"rounded"})}):null]})};CardSkeleton.displayName="CardSkeleton";const Card=Object.assign(CardRoot,{Skeleton:CardSkeleton});Card.displayName="Card";const hasBuiltInHeaderContent=e=>Boolean(e.title||e.lead||e.action||e.headerActions||e.collapsible||e.onRemove),isCardTextAction=e=>"object"==typeof e&&null!==e&&!React.isValidElement(e)&&"label"in e&&"onPress"in e,HIT_TARGET=44,CardIconAction=({icon:e,label:t,onPress:i,expanded:s,color:o,haptic:r})=>{const l=useTheme();return _jsx(Pressable,{accessibilityRole:"button",accessibilityLabel:t,accessibilityState:void 0===s?void 0:{expanded:s},"aria-expanded":s,onPress:()=>{r&&triggerHaptic(r),i()},style:iconActionStyle,children:_jsx(View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:_jsx(AppIcon,{name:e,size:20,color:o??l.colors["text-body"]})})})},CardTextActionButton=({action:e,haptic:t})=>_jsx(Pressable,{accessibilityRole:"button",accessibilityLabel:e.accessibilityLabel??e.label,onPress:()=>{t&&triggerHaptic(t),e.onPress()},style:textActionStyle,children:_jsx(Text,{variant:"label",weight:"semibold",color:"brand",children:e.label})}),iconActionStyle={width:44,height:44,alignItems:"center",justifyContent:"center"},textActionStyle={minWidth:44,minHeight:44,alignItems:"center",justifyContent:"center"},titleFaceFor=(e,t)=>"serif"===t?fontFor(e,"semibold","display"):{fontFamily:void 0,...fontFor(e,"semibold")},resolveBackground=(e,t)=>{if(null!=t)return isOneOf(BACKGROUND_TOKENS,t)?e.colors[t]:t},buildStyles=e=>StyleSheet.create({header:{marginBottom:e.space.md},headerRow:{flexDirection:"row",alignItems:"center",gap:e.space.sm},headerFolded:{marginBottom:e.space.none},titleColumn:{flex:1},lead:{marginTop:e.space.xs},actionNode:{flexShrink:0},body:{flexShrink:1},footer:{marginTop:e.space.md},imageWrapper:{position:"relative"},imageOverlay:{...StyleSheet.absoluteFill},squircleClip:{overflow:"hidden",...smoothCorners},pressFill:{flexGrow:1},preview:{margin:e.space.none,marginTop:e.space.none,marginBottom:e.space.none,marginLeft:e.space.none,marginRight:e.space.none,marginStart:e.space.none,marginEnd:e.space.none,marginHorizontal:e.space.none,marginVertical:e.space.none,position:"relative",top:0,left:0,width:"100%",height:"100%"}}),stylesFor=themeStyles(buildStyles);export{Card};export default Card;
|
|
1
|
+
"use strict";import React,{useMemo}from"react";import{Animated,Image,Pressable,StyleSheet,View}from"react-native";import{useControllableState}from"../../hooks/useControllableState.js";import{usePressAnimation}from"../../hooks/usePressAnimation.js";import{useMobileUiText}from"../../text/index.js";import{CARD_TEXT}from"../../text/phone/card.g.js";import{fontFor,Gradient,useTheme}from"../../theme/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{smoothCorners}from"../../utils/corners.js";import{isOneOf}from"../../utils/guards.js";import{triggerHaptic}from"../../utils/hapticUtils.js";import{mergeRefs}from"../../utils/mergeRefs.js";import{supportsBoxShadow,toBoxShadow}from"../../utils/shadows.js";import{squircleHostRadius}from"../../utils/squircle.js";import{themeStyles}from"../../utils/themeStyles.js";import{AppIcon}from"../AppIcon/AppIcon.js";import{useContextMenu}from"../Menu/useContextMenu.js";import{Skeleton,SkeletonText}from"../Skeleton/index.js";import{SquircleFill,useSquircle}from"../SquircleFill/SquircleFill.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";const OUTER_LAYOUT_KEYS=new Set(["flex","flexGrow","flexShrink","flexBasis","alignSelf","width","height","minWidth","maxWidth","minHeight","maxHeight","position","top","right","bottom","left","start","end","zIndex"]),splitOuterLayout=e=>{const t={},i={};for(const[s,o]of Object.entries(StyleSheet.flatten(e)??{}))(OUTER_LAYOUT_KEYS.has(s)||s.startsWith("margin")?t:i)[s]=o;return{outer:t,inner:i}},flexStyleOf=e=>void 0===e?[]:[{flex:e}],BACKGROUND_TOKENS=["bg","bg-subtle","bg-muted","surface","scrim","surface-inverse","primary-wash"],paddingMap={none:"none",sm:"sm",md:"lg",lg:"xl",xl:"2xl"},CardRoot=React.memo(function CardRoot({ref:e,...t}){const{children:i,variant:s,elevation:o="card",radius:r,padding:l,interactive:a=!1,pressAnimation:n="scale",bg:d,header:c,title:u,titleFont:m,lead:h,action:p,headerActions:g,collapsible:b=!1,collapsed:f,defaultCollapsed:x=!1,onCollapsedChange:y,collapsedSummary:S,onRemove:j,separatorHeight:C=StyleSheet.hairlineWidth,footer:v,imageSource:_,imageHeight:w=160,imageAspectRatio:R,imageOverlay:A,loading:T=!1,gradient:V,onPress:F,haptic:k,contextMenu:B,accessibilityLabel:O,accessibilityHint:I,accessibilityRole:H,flex:L,style:P,headerStyle:z,bodyStyle:M,footerStyle:E,testID:q,labels:W,onLayout:D,...U}=t;assertValidValue("Card","variant",t.variant,["elevated","outline","filled","flat"]),assertValidValue("Card","radius",t.radius,["sm","md","lg","xl","pill"]),assertValidValue("Card","padding",t.padding,["none","sm","md","lg","xl"]),assertValidValue("Card","titleFont",t.titleFont,["sans","serif"]),assertValidValue("Card","pressAnimation",t.pressAnimation,["scale","bounce","fade","sink","pulse","dim","false"]);const N=useTheme(),G=N.settings.components.card,K=s??G?.defaultVariant??"elevated",Y=r??G?.defaultRadius??"lg",X=l??G?.defaultPadding??"md",$=m??G?.defaultTitleFont??"sans",J=useMobileUiText("card",CARD_TEXT),Q=useMemo(()=>({...J,...W}),[J,W]),Z=a||"function"==typeof F,ee=useContextMenu(B,{haptic:k||!1,testID:q,accessibilityActions:U.accessibilityActions,onAccessibilityAction:U.onAccessibilityAction}),te=useMemo(()=>mergeRefs(e,ee.hostRef),[e,ee.hostRef]),ie=Z||ee.enabled,{style:se,pressIn:oe,pressOut:re}=usePressAnimation({preset:n||"scale",enabled:ie&&!1!==n}),le=stylesFor(N),ae=Boolean(_),ne=N.space[paddingMap[X]],de=useMemo(()=>V?"string"==typeof V?N.settings.gradients[V]??null:V:null,[V,N.settings.gradients]),ce="flat"===K,ue=ce?N.radius.none:N.radius[Y],me=resolveBackground(N,d),[he,pe]=useControllableState({value:f,defaultValue:x,onChange:y}),ge=b&&he,be=hasBuiltInHeaderContent(t),fe=Boolean(c)||be,xe=useSquircle(!ae&&!de&&!ce,ue,D),ye=StyleSheet.flatten(P)??{},Se="string"==typeof ye.backgroundColor?ye.backgroundColor:void 0,je="string"==typeof ye.borderColor?ye.borderColor:void 0,Ce=Se??me??("filled"===K?N.colors["bg-subtle"]:N.colors.surface),ve="outline"===K?N.size.border:0,we=je??N.colors.border,Re="none"===o?void 0:N.shadow[o],Ae="elevated"===K&&supportsBoxShadow()&&Re?toBoxShadow(Re):void 0,Te=xe.active&&"elevated"===K&&!Ae,Ve=xe.active&&!Te?{backgroundColor:"transparent",borderColor:"transparent"}:null,Fe=useMemo(()=>{const e={borderRadius:Te&&xe.size?squircleHostRadius(xe.size.width,xe.size.height,ue):ue,...smoothCorners,padding:ae||xe.active?N.space.none:ne,overflow:xe.active?"visible":"hidden"};switch(K){case"flat":return{...e,backgroundColor:me??N.colors.surface,borderBottomWidth:C,borderBottomColor:N.colors.border};case"outline":return{...e,backgroundColor:xe.active?"transparent":me??N.colors.surface,borderWidth:N.size.border,borderColor:xe.active?"transparent":N.colors.border};case"filled":return{...e,backgroundColor:xe.active?"transparent":me??N.colors["bg-subtle"]};default:return{...e,backgroundColor:me??N.colors.surface,...Ae?{boxShadow:Ae}:Re}}},[N,K,Re,ue,ae,ne,xe.active,xe.size,Ae,Te,me,C]),ke=useMemo(()=>({..."number"==typeof R?{width:"100%",aspectRatio:R}:{width:"100%",height:w},borderTopLeftRadius:ue,borderTopRightRadius:ue,borderBottomLeftRadius:N.radius.none,borderBottomRightRadius:N.radius.none,...smoothCorners}),[N,ue,R,w]),Be=u??"",Oe=_jsxs(_Fragment,{children:[_jsxs(View,{style:le.titleColumn,children:[u?_jsx(Text,{variant:"title",accessibilityRole:"header",style:titleFaceFor(N,$),children:u}):null,h?_jsx(Text,{variant:"bodySmall",style:le.lead,children:h}):null,ge&&S?_jsx(Text,{variant:"caption",style:le.lead,children:S}):null]}),isCardTextAction(p)?_jsx(CardTextActionButton,{action:p,haptic:k}):p?_jsx(View,{style:le.actionNode,children:p}):null,g,b?_jsx(CardIconAction,{icon:ge?"chevron-down":"chevron-up",label:`${ge?Q.show:Q.hide} ${Be}`.trim(),expanded:!ge,onPress:()=>pe(!ge),haptic:k}):null,j?_jsx(CardIconAction,{icon:"trash",label:Q.remove,onPress:j,color:N.colors["danger-text"],haptic:k}):null]}),Ie=_jsxs(_Fragment,{children:[fe?_jsx(View,{style:[le.header,!c&&le.headerRow,ge&&le.headerFolded,z],children:c??Oe}):null,ge?null:_jsx(View,{style:[fe||v?le.body:null,M],children:i}),v&&!ge?_jsx(View,{style:[le.footer,E],children:v}):null]}),He=_?_jsxs(_Fragment,{children:[_jsxs(View,{style:le.imageWrapper,children:[_jsx(Image,{source:_,resizeMode:"cover",style:ke,accessibilityLabel:"",accessible:!1}),A?_jsx(View,{pointerEvents:"box-none",style:le.imageOverlay,children:A}):null]}),_jsx(View,{style:{padding:ne},children:Ie})]}):Ie,Le=de?_jsxs(_Fragment,{children:[_jsx(Gradient,{gradient:de,style:StyleSheet.absoluteFill}),He]}):xe.active&&xe.size?_jsxs(_Fragment,{children:[_jsx(SquircleFill,{width:xe.size.width,height:xe.size.height,radius:ue,fill:Ce,stroke:ve?we:void 0,strokeWidth:ve}),_jsx(View,{style:[le.squircleClip,{padding:ne,borderRadius:xe.size?squircleHostRadius(xe.size.width,xe.size.height,ue):ue}],children:He})]}):He,{outer:Pe,inner:ze}=splitOuterLayout(P);let Me;if(ie){const handlePress=e=>{Z&&(k&&triggerHaptic(k),F?.(e))};Me=_jsx(Animated.View,{style:[se,...flexStyleOf(L),Pe],children:_jsx(Pressable,{ref:te,onPress:handlePress,onPressIn:oe,onPressOut:re,accessibilityRole:H??(Z?"button":void 0),accessibilityLabel:O,accessibilityHint:I,testID:q,onLayout:xe.onLayout,style:[Fe,ze,Ve,le.pressFill],...U,...ee.hostProps,children:Le})})}else Me=_jsx(View,{ref:e,accessibilityLabel:O,accessibilityHint:I,accessibilityRole:H,testID:q,onLayout:xe.onLayout,style:[Fe,...flexStyleOf(L),P,Ve],...U,children:Le});return T?_jsx(CardSkeleton,{...t}):ee.enabled?_jsxs(_Fragment,{children:[Me,ee.renderSurface(_jsx(View,{style:[Fe,P,Ve,le.preview],children:Le}))]}):Me}),CardSkeleton=({variant:e,elevation:t,radius:i,padding:s,bg:o,header:r,footer:l,imageSource:a,imageHeight:n=160,imageAspectRatio:d,headerStyle:c,bodyStyle:u,footerStyle:m,flex:h,style:p,labels:g,...b})=>{const f=useTheme(),x=f.settings.components.card,y=e??x?.defaultVariant??"elevated",S=i??x?.defaultRadius??"lg",j=s??x?.defaultPadding??"md",C={...useMobileUiText("card",CARD_TEXT),...g},v=paddingMap[j],_=f.space[v],w="flat"===y?f.radius.none:f.radius[S],R=void 0!==r||hasBuiltInHeaderContent(b),A=resolveBackground(f,o)??f.colors.surface,T="outline"===y?1:0,V="outline"===y?f.colors.border:void 0;return _jsxs(View,{style:[{backgroundColor:A,borderRadius:w,...smoothCorners,borderWidth:T,borderColor:V,overflow:"hidden"},...flexStyleOf(h),p],accessibilityRole:"progressbar",accessibilityLabel:C.loading,accessibilityState:{busy:!0},"aria-busy":!0,children:[void 0!==a?_jsx(Skeleton,{width:"100%",height:d?void 0:n,style:d?{aspectRatio:d,width:"100%"}:void 0}):null,R?_jsx(View,{style:[{padding:_,paddingBottom:f.space.sm},c],children:_jsx(Skeleton,{shape:"text",width:"60%",height:18})}):null,_jsx(View,{style:[{padding:_},u],children:_jsx(SkeletonText,{lines:3,fontSize:f.text.base.size,lastLineWidth:"55%"})}),void 0!==l?_jsx(View,{style:[{padding:_,paddingTop:f.space.sm,flexDirection:"row"},m],children:_jsx(Skeleton,{width:88,height:32,shape:"rounded"})}):null]})};CardSkeleton.displayName="CardSkeleton";const Card=Object.assign(CardRoot,{Skeleton:CardSkeleton});Card.displayName="Card";const hasBuiltInHeaderContent=e=>Boolean(e.title||e.lead||e.action||e.headerActions||e.collapsible||e.onRemove),isCardTextAction=e=>"object"==typeof e&&null!==e&&!React.isValidElement(e)&&"label"in e&&"onPress"in e,HIT_TARGET=44,CardIconAction=({icon:e,label:t,onPress:i,expanded:s,color:o,haptic:r})=>{const l=useTheme();return _jsx(Pressable,{accessibilityRole:"button",accessibilityLabel:t,accessibilityState:void 0===s?void 0:{expanded:s},"aria-expanded":s,onPress:()=>{r&&triggerHaptic(r),i()},style:iconActionStyle,children:_jsx(View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:_jsx(AppIcon,{name:e,size:20,color:o??l.colors["text-body"]})})})},CardTextActionButton=({action:e,haptic:t})=>_jsx(Pressable,{accessibilityRole:"button",accessibilityLabel:e.accessibilityLabel??e.label,onPress:()=>{t&&triggerHaptic(t),e.onPress()},style:textActionStyle,children:_jsx(Text,{variant:"label",weight:"semibold",color:"brand",children:e.label})}),iconActionStyle={width:44,height:44,alignItems:"center",justifyContent:"center"},textActionStyle={minWidth:44,minHeight:44,alignItems:"center",justifyContent:"center"},titleFaceFor=(e,t)=>"serif"===t?fontFor(e,"semibold","display"):{fontFamily:void 0,...fontFor(e,"semibold")},resolveBackground=(e,t)=>{if(null!=t)return isOneOf(BACKGROUND_TOKENS,t)?e.colors[t]:t},buildStyles=e=>StyleSheet.create({header:{marginBottom:e.space.md},headerRow:{flexDirection:"row",alignItems:"center",gap:e.space.sm},headerFolded:{marginBottom:e.space.none},titleColumn:{flex:1},lead:{marginTop:e.space.xs},actionNode:{flexShrink:0},body:{flexShrink:1},footer:{marginTop:e.space.md},imageWrapper:{position:"relative"},imageOverlay:{...StyleSheet.absoluteFill},squircleClip:{overflow:"hidden",...smoothCorners},pressFill:{flexGrow:1},preview:{margin:e.space.none,marginTop:e.space.none,marginBottom:e.space.none,marginLeft:e.space.none,marginRight:e.space.none,marginStart:e.space.none,marginEnd:e.space.none,marginHorizontal:e.space.none,marginVertical:e.space.none,position:"relative",top:0,left:0,width:"100%",height:"100%"}}),stylesFor=themeStyles(buildStyles);export{Card};export default Card;
|