@webority/mobile-ui 0.149.0 → 0.152.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 +13 -56714
- package/dist/canvas-kit/manifest.json +157 -56
- package/dist/canvas-kit/release.json +6 -6
- package/lib/commonjs/components/Accordion/Accordion.js +1 -1
- package/lib/commonjs/components/AppBar/AppBar.js +1 -1
- package/lib/commonjs/components/AppIcon/AppIcon.js +1 -1
- package/lib/commonjs/components/AppIcon/glyphs.g.js +1 -1
- package/lib/commonjs/components/AsyncBlock/AsyncBlock.js +1 -1
- package/lib/commonjs/components/AuthedImage/AuthedImage.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/BottomNavigation/BottomNavigation.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/calendarStyles.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/Chip/Chip.js +1 -1
- package/lib/commonjs/components/ChoiceGroup/ChoiceGroup.js +1 -1
- package/lib/commonjs/components/Confetti/Confetti.js +1 -1
- package/lib/commonjs/components/DatePicker/DatePicker.js +1 -1
- package/lib/commonjs/components/DateRangePicker/DateRangePicker.js +1 -1
- package/lib/commonjs/components/Descriptions/Descriptions.js +1 -1
- package/lib/commonjs/components/Dialog/Dialog.js +1 -1
- package/lib/commonjs/components/FilePicker/FilePicker.js +1 -1
- package/lib/commonjs/components/FileViewer/fileSource.js +1 -1
- package/lib/commonjs/components/FloatingActionButton/FloatingActionButton.js +1 -1
- package/lib/commonjs/components/ImageGallery/ImageGallery.js +1 -1
- package/lib/commonjs/components/InlineSelect/InlineSelect.js +1 -1
- package/lib/commonjs/components/Input/Input.js +1 -1
- package/lib/commonjs/components/ListItem/ListItem.js +1 -1
- package/lib/commonjs/components/Markdown/Markdown.js +1 -1
- package/lib/commonjs/components/Menu/MenuSurface.js +1 -1
- package/lib/commonjs/components/Menu/focusHost.js +1 -1
- package/lib/commonjs/components/NonModalBottomSheet/NonModalBottomSheet.js +1 -0
- package/lib/commonjs/components/NonModalBottomSheet/index.js +1 -0
- package/lib/commonjs/components/OptionSheet/OptionSheet.js +1 -1
- package/lib/commonjs/components/OptionSheet/optionAccessors.js +1 -0
- package/lib/commonjs/components/PhoneNumberInput/PhoneNumberInput.js +1 -1
- package/lib/commonjs/components/ProgressRing/ProgressRing.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/Repeater/Repeater.js +1 -1
- package/lib/commonjs/components/Screen/Screen.js +1 -1
- package/lib/commonjs/components/SearchBar/useRecentSearches.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/Skeleton/SkeletonContent.js +1 -1
- package/lib/commonjs/components/Skeleton/SkeletonList.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/SortableList/SortableList.js +1 -1
- package/lib/commonjs/components/Sparkline/Sparkline.js +1 -1
- package/lib/commonjs/components/SquircleFill/SquircleFill.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/StatusBadge/statusMap.js +1 -1
- package/lib/commonjs/components/Stepper/Stepper.js +1 -1
- package/lib/commonjs/components/Text/Text.js +1 -1
- package/lib/commonjs/components/TimePicker/TimePicker.js +1 -1
- package/lib/commonjs/components/Toast/Toast.js +1 -1
- package/lib/commonjs/components/WheelPicker/Wheel.js +1 -1
- package/lib/commonjs/components/WheelPicker/WheelPicker.js +1 -1
- package/lib/commonjs/components/index.js +1 -1
- package/lib/commonjs/form/HookFormField.js +1 -1
- package/lib/commonjs/form/path.js +1 -1
- package/lib/commonjs/hooks/useControllableState.js +1 -1
- package/lib/commonjs/index.js +1 -1
- package/lib/commonjs/specs/NativePdfRasterizer.js +1 -1
- package/lib/commonjs/theme/ThemeContext.js +1 -1
- package/lib/commonjs/theme/animatedValue.js +1 -1
- package/lib/commonjs/theme/componentSizes.js +1 -1
- package/lib/commonjs/theme/merge.js +1 -1
- package/lib/commonjs/theme/scale.js +1 -1
- package/lib/commonjs/theme/tokens.generated.js +1 -1
- package/lib/commonjs/utils/complete.js +1 -0
- package/lib/commonjs/utils/guards.js +1 -0
- package/lib/commonjs/utils/hapticUtils.js +1 -1
- package/lib/module/components/Accordion/Accordion.js +1 -1
- package/lib/module/components/AppBar/AppBar.js +1 -1
- package/lib/module/components/AppIcon/AppIcon.js +1 -1
- package/lib/module/components/AppIcon/glyphs.g.js +1 -1
- package/lib/module/components/AsyncBlock/AsyncBlock.js +1 -1
- package/lib/module/components/AuthedImage/AuthedImage.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/BottomNavigation/BottomNavigation.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/calendarStyles.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/Chip/Chip.js +1 -1
- package/lib/module/components/ChoiceGroup/ChoiceGroup.js +1 -1
- package/lib/module/components/Confetti/Confetti.js +1 -1
- package/lib/module/components/DatePicker/DatePicker.js +1 -1
- package/lib/module/components/DateRangePicker/DateRangePicker.js +1 -1
- package/lib/module/components/Descriptions/Descriptions.js +1 -1
- package/lib/module/components/Dialog/Dialog.js +1 -1
- package/lib/module/components/FilePicker/FilePicker.js +1 -1
- package/lib/module/components/FileViewer/fileSource.js +1 -1
- package/lib/module/components/FloatingActionButton/FloatingActionButton.js +1 -1
- package/lib/module/components/ImageGallery/ImageGallery.js +1 -1
- package/lib/module/components/InlineSelect/InlineSelect.js +1 -1
- package/lib/module/components/Input/Input.js +1 -1
- package/lib/module/components/ListItem/ListItem.js +1 -1
- package/lib/module/components/Markdown/Markdown.js +1 -1
- package/lib/module/components/Menu/MenuSurface.js +1 -1
- package/lib/module/components/Menu/focusHost.js +1 -1
- package/lib/module/components/NonModalBottomSheet/NonModalBottomSheet.js +1 -0
- package/lib/module/components/NonModalBottomSheet/index.js +1 -0
- package/lib/module/components/OptionSheet/OptionSheet.js +1 -1
- package/lib/module/components/OptionSheet/optionAccessors.js +1 -0
- package/lib/module/components/PhoneNumberInput/PhoneNumberInput.js +1 -1
- package/lib/module/components/ProgressRing/ProgressRing.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/Repeater/Repeater.js +1 -1
- package/lib/module/components/Screen/Screen.js +1 -1
- package/lib/module/components/SearchBar/useRecentSearches.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/Skeleton/SkeletonContent.js +1 -1
- package/lib/module/components/Skeleton/SkeletonList.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/SortableList/SortableList.js +1 -1
- package/lib/module/components/Sparkline/Sparkline.js +1 -1
- package/lib/module/components/SquircleFill/SquircleFill.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/StatusBadge/statusMap.js +1 -1
- package/lib/module/components/Stepper/Stepper.js +1 -1
- package/lib/module/components/Text/Text.js +1 -1
- package/lib/module/components/TimePicker/TimePicker.js +1 -1
- package/lib/module/components/Toast/Toast.js +1 -1
- package/lib/module/components/WheelPicker/Wheel.js +1 -1
- package/lib/module/components/WheelPicker/WheelPicker.js +1 -1
- package/lib/module/components/index.js +1 -1
- package/lib/module/form/HookFormField.js +1 -1
- package/lib/module/form/path.js +1 -1
- package/lib/module/hooks/useControllableState.js +1 -1
- package/lib/module/index.js +1 -1
- package/lib/module/specs/NativePdfRasterizer.js +1 -1
- package/lib/module/theme/ThemeContext.js +1 -1
- package/lib/module/theme/animatedValue.js +1 -1
- package/lib/module/theme/componentSizes.js +1 -1
- package/lib/module/theme/merge.js +1 -1
- package/lib/module/theme/scale.js +1 -1
- package/lib/module/theme/tokens.generated.js +1 -1
- package/lib/module/utils/complete.js +1 -0
- package/lib/module/utils/guards.js +1 -0
- package/lib/module/utils/hapticUtils.js +1 -1
- package/lib/typescript/commonjs/canvasKit/index.d.ts +12 -12
- package/lib/typescript/commonjs/canvasKit/meta.d.ts +5 -7
- package/lib/typescript/commonjs/components/Accordion/Accordion.d.ts +22 -22
- package/lib/typescript/commonjs/components/AmountSlider/AmountSlider.d.ts +23 -23
- package/lib/typescript/commonjs/components/AnimatePresence/AnimatePresence.d.ts +5 -5
- package/lib/typescript/commonjs/components/AppBar/AppBar.d.ts +39 -39
- package/lib/typescript/commonjs/components/AppIcon/AppIcon.d.ts +7 -7
- package/lib/typescript/commonjs/components/AppIcon/defaultIcons.d.ts +2 -1
- package/lib/typescript/commonjs/components/AppIcon/glyphs.g.d.ts +233 -233
- package/lib/typescript/commonjs/components/AppIcon/slotIcon.d.ts +1 -1
- package/lib/typescript/commonjs/components/AppLockOverlay/AppLockOverlay.d.ts +5 -5
- package/lib/typescript/commonjs/components/AsyncBlock/AsyncBlock.d.ts +22 -40
- package/lib/typescript/commonjs/components/AuthedImage/AuthedImage.d.ts +15 -15
- package/lib/typescript/commonjs/components/AuthedImage/authedImageCache.d.ts +2 -2
- package/lib/typescript/commonjs/components/Autocomplete/Autocomplete.d.ts +24 -24
- package/lib/typescript/commonjs/components/Avatar/Avatar.d.ts +41 -39
- package/lib/typescript/commonjs/components/Badge/Badge.d.ts +18 -18
- package/lib/typescript/commonjs/components/Banner/Banner.d.ts +25 -25
- package/lib/typescript/commonjs/components/BarChart/BarChart.d.ts +21 -21
- package/lib/typescript/commonjs/components/BottomNavigation/BottomNavigation.d.ts +36 -36
- package/lib/typescript/commonjs/components/BottomSheet/BottomSheet.d.ts +32 -32
- package/lib/typescript/commonjs/components/Box/Box.d.ts +27 -27
- package/lib/typescript/commonjs/components/Button/Button.d.ts +29 -24
- package/lib/typescript/commonjs/components/Calendar/Calendar.d.ts +20 -20
- package/lib/typescript/commonjs/components/Calendar/CalendarDay.d.ts +4 -2
- package/lib/typescript/commonjs/components/Card/Card.d.ts +41 -41
- package/lib/typescript/commonjs/components/Carousel/Carousel.d.ts +21 -21
- package/lib/typescript/commonjs/components/Checkbox/Checkbox.d.ts +21 -21
- package/lib/typescript/commonjs/components/Chip/Chip.d.ts +23 -23
- package/lib/typescript/commonjs/components/ChoiceGroup/ChoiceGroup.d.ts +51 -46
- package/lib/typescript/commonjs/components/Composer/Composer.d.ts +27 -27
- package/lib/typescript/commonjs/components/Confetti/Confetti.d.ts +22 -21
- package/lib/typescript/commonjs/components/Confirm/confirm.d.ts +4 -4
- package/lib/typescript/commonjs/components/DatePicker/DatePicker.d.ts +20 -20
- package/lib/typescript/commonjs/components/DateRangePicker/DateRangePicker.d.ts +22 -22
- package/lib/typescript/commonjs/components/DateSeparator/DateSeparator.d.ts +9 -9
- package/lib/typescript/commonjs/components/DecimalInput/DecimalInput.d.ts +14 -14
- package/lib/typescript/commonjs/components/Descriptions/Descriptions.d.ts +13 -13
- package/lib/typescript/commonjs/components/Dialog/Dialog.d.ts +24 -24
- package/lib/typescript/commonjs/components/Dialog/OverlayActions.d.ts +5 -5
- package/lib/typescript/commonjs/components/Divider/Divider.d.ts +9 -9
- package/lib/typescript/commonjs/components/Drawer/Drawer.d.ts +14 -14
- package/lib/typescript/commonjs/components/EmptyState/EmptyState.d.ts +13 -13
- package/lib/typescript/commonjs/components/ErrorBoundary/ErrorBoundary.d.ts +8 -8
- package/lib/typescript/commonjs/components/FieldBase/Chevron.d.ts +2 -2
- package/lib/typescript/commonjs/components/FieldBase/ChoiceText.d.ts +10 -10
- package/lib/typescript/commonjs/components/FieldBase/FieldBase.d.ts +54 -54
- package/lib/typescript/commonjs/components/FieldBase/useFloatingLabel.d.ts +8 -8
- package/lib/typescript/commonjs/components/FilePicker/FilePicker.d.ts +35 -35
- package/lib/typescript/commonjs/components/FileViewer/FileViewer.d.ts +10 -10
- package/lib/typescript/commonjs/components/FileViewer/fileSource.d.ts +3 -3
- package/lib/typescript/commonjs/components/FilterChipRow/FilterChipRow.d.ts +12 -12
- package/lib/typescript/commonjs/components/FloatingActionButton/FloatingActionButton.d.ts +35 -35
- package/lib/typescript/commonjs/components/ForceUpdateDialog/ForceUpdateDialog.d.ts +11 -11
- package/lib/typescript/commonjs/components/FormField/FormField.d.ts +15 -15
- package/lib/typescript/commonjs/components/IconBadge/IconBadge.d.ts +11 -11
- package/lib/typescript/commonjs/components/IconButton/IconButton.d.ts +14 -14
- package/lib/typescript/commonjs/components/ImageGallery/ImageGallery.d.ts +14 -14
- package/lib/typescript/commonjs/components/InlineSelect/InlineSelect.d.ts +36 -31
- package/lib/typescript/commonjs/components/Input/Input.d.ts +47 -47
- package/lib/typescript/commonjs/components/KeyboardAwareScrollView/KeyboardAwareScrollView.d.ts +7 -7
- package/lib/typescript/commonjs/components/KeyboardToolbar/KeyboardToolbar.d.ts +8 -8
- package/lib/typescript/commonjs/components/ListItem/ListItem.d.ts +44 -44
- package/lib/typescript/commonjs/components/ListSection/ListSection.d.ts +6 -6
- package/lib/typescript/commonjs/components/LoaderOverlay/LoaderOverlay.d.ts +17 -11
- package/lib/typescript/commonjs/components/Markdown/Markdown.d.ts +15 -15
- package/lib/typescript/commonjs/components/Menu/Menu.d.ts +17 -12
- package/lib/typescript/commonjs/components/Menu/MenuSurface.d.ts +8 -8
- package/lib/typescript/commonjs/components/Menu/menuModel.d.ts +11 -11
- package/lib/typescript/commonjs/components/Menu/useContextMenu.d.ts +13 -13
- package/lib/typescript/commonjs/components/Menu/webOnly.d.ts +3 -3
- package/lib/typescript/commonjs/components/MessageBubble/MessageBubble.d.ts +20 -20
- package/lib/typescript/commonjs/components/MessageList/MessageList.d.ts +14 -14
- package/lib/typescript/commonjs/components/Modal/Modal.d.ts +19 -19
- package/lib/typescript/commonjs/components/NonModalBottomSheet/NonModalBottomSheet.d.ts +52 -0
- package/lib/typescript/commonjs/components/NonModalBottomSheet/index.d.ts +3 -0
- package/lib/typescript/commonjs/components/NumberInput/NumberInput.d.ts +27 -27
- package/lib/typescript/commonjs/components/OTPInput/OTPInput.d.ts +20 -20
- package/lib/typescript/commonjs/components/OTPInput/OTPResendRow.d.ts +9 -9
- package/lib/typescript/commonjs/components/OnboardingPager/OnboardingPager.d.ts +5 -5
- package/lib/typescript/commonjs/components/OptionSheet/OptionSheet.d.ts +39 -34
- package/lib/typescript/commonjs/components/OptionSheet/optionAccessors.d.ts +9 -0
- package/lib/typescript/commonjs/components/PagedListFooter/PagedListFooter.d.ts +2 -2
- package/lib/typescript/commonjs/components/PermissionPrompt/PermissionPrompt.d.ts +6 -6
- package/lib/typescript/commonjs/components/PermissionPrompt/usePermissionPrompt.d.ts +1 -1
- package/lib/typescript/commonjs/components/PhoneNumberInput/PhoneNumberInput.d.ts +43 -43
- package/lib/typescript/commonjs/components/PickerTrigger/PickerTrigger.d.ts +23 -23
- package/lib/typescript/commonjs/components/ProfileCompletion/ProfileCompletion.d.ts +23 -23
- package/lib/typescript/commonjs/components/ProfilePicker/ProfilePicker.d.ts +30 -30
- package/lib/typescript/commonjs/components/ProgressBar/ProgressBar.d.ts +21 -21
- package/lib/typescript/commonjs/components/ProgressRing/ProgressRing.d.ts +13 -13
- package/lib/typescript/commonjs/components/Radio/Radio.d.ts +18 -18
- package/lib/typescript/commonjs/components/Radio/RadioDot.d.ts +5 -5
- package/lib/typescript/commonjs/components/Radio/RadioGroup.d.ts +8 -8
- package/lib/typescript/commonjs/components/Rating/Rating.d.ts +15 -15
- package/lib/typescript/commonjs/components/Repeater/Repeater.d.ts +10 -10
- package/lib/typescript/commonjs/components/RichTextEditor/RichTextEditor.d.ts +15 -15
- package/lib/typescript/commonjs/components/ScannerOverlay/ScannerOverlay.d.ts +13 -13
- package/lib/typescript/commonjs/components/Screen/Screen.d.ts +43 -44
- package/lib/typescript/commonjs/components/Screen/index.d.ts +1 -1
- package/lib/typescript/commonjs/components/SearchBar/SearchBar.d.ts +31 -31
- package/lib/typescript/commonjs/components/SearchBar/SearchPanel.d.ts +6 -6
- package/lib/typescript/commonjs/components/SearchBar/useRecentSearches.d.ts +1 -1
- package/lib/typescript/commonjs/components/SectionHeader/SectionHeader.d.ts +10 -10
- package/lib/typescript/commonjs/components/SegmentedControl/SegmentedControl.d.ts +25 -24
- package/lib/typescript/commonjs/components/Select/Select.d.ts +50 -45
- package/lib/typescript/commonjs/components/SignaturePad/SignaturePad.d.ts +20 -20
- package/lib/typescript/commonjs/components/Skeleton/Skeleton.d.ts +13 -13
- package/lib/typescript/commonjs/components/Skeleton/SkeletonContent.d.ts +9 -9
- package/lib/typescript/commonjs/components/Skeleton/SkeletonList.d.ts +30 -8
- package/lib/typescript/commonjs/components/Skeleton/SkeletonProvider.d.ts +9 -9
- package/lib/typescript/commonjs/components/SlideToConfirm/SlideToConfirm.d.ts +14 -14
- package/lib/typescript/commonjs/components/Slider/Slider.d.ts +30 -30
- package/lib/typescript/commonjs/components/Slider/valueText.d.ts +9 -9
- package/lib/typescript/commonjs/components/SliderField/SliderField.d.ts +41 -41
- package/lib/typescript/commonjs/components/SortableList/SortableList.d.ts +5 -5
- package/lib/typescript/commonjs/components/Sparkline/Sparkline.d.ts +13 -13
- package/lib/typescript/commonjs/components/Sparkline/geometry.d.ts +3 -1
- package/lib/typescript/commonjs/components/Spinner/Spinner.d.ts +10 -10
- package/lib/typescript/commonjs/components/SquircleFill/SquircleFill.d.ts +3 -3
- package/lib/typescript/commonjs/components/SquircleImage/SquircleImage.d.ts +5 -12
- package/lib/typescript/commonjs/components/StatTile/StatTile.d.ts +14 -14
- package/lib/typescript/commonjs/components/StatusBadge/StatusBadge.d.ts +13 -13
- package/lib/typescript/commonjs/components/Stepper/Stepper.d.ts +21 -21
- package/lib/typescript/commonjs/components/Swipeable/Swipeable.d.ts +15 -15
- package/lib/typescript/commonjs/components/Switch/Switch.d.ts +19 -19
- package/lib/typescript/commonjs/components/Tabs/Tabs.d.ts +20 -20
- package/lib/typescript/commonjs/components/TagInput/TagInput.d.ts +19 -19
- package/lib/typescript/commonjs/components/Text/Text.d.ts +10 -10
- package/lib/typescript/commonjs/components/TimePicker/TimePicker.d.ts +14 -14
- package/lib/typescript/commonjs/components/Timeline/Timeline.d.ts +12 -12
- package/lib/typescript/commonjs/components/Toast/Toast.d.ts +17 -17
- package/lib/typescript/commonjs/components/Toast/ToastProvider.d.ts +8 -8
- package/lib/typescript/commonjs/components/Tooltip/RichTooltipBody.d.ts +4 -4
- package/lib/typescript/commonjs/components/Tooltip/Tooltip.d.ts +24 -19
- package/lib/typescript/commonjs/components/Tour/Tour.d.ts +7 -7
- package/lib/typescript/commonjs/components/TypingIndicator/TypingIndicator.d.ts +6 -6
- package/lib/typescript/commonjs/components/WheelPicker/Wheel.d.ts +10 -6
- package/lib/typescript/commonjs/components/WheelPicker/WheelPicker.d.ts +22 -20
- package/lib/typescript/commonjs/components/ZoomableImage/ZoomableImage.d.ts +8 -8
- package/lib/typescript/commonjs/components/index.d.ts +2 -0
- package/lib/typescript/commonjs/form/HookFormField.d.ts +5 -18
- package/lib/typescript/commonjs/form/path.d.ts +4 -2
- package/lib/typescript/commonjs/form/useFormCompletion.d.ts +1 -1
- package/lib/typescript/commonjs/hooks/useControllableState.d.ts +2 -2
- package/lib/typescript/commonjs/hooks/useDragToDismiss.d.ts +3 -3
- package/lib/typescript/commonjs/hooks/useFieldErrorScroll.d.ts +1 -1
- package/lib/typescript/commonjs/hooks/usePressAnimation.d.ts +4 -4
- package/lib/typescript/commonjs/hooks/useRefreshControl.d.ts +8 -8
- package/lib/typescript/commonjs/hooks/useResendCountdown.d.ts +1 -1
- package/lib/typescript/commonjs/hooks/useScrollDirection.d.ts +1 -1
- package/lib/typescript/commonjs/index.d.ts +1 -1
- package/lib/typescript/commonjs/navigation/DiscardGuard.d.ts +2 -2
- package/lib/typescript/commonjs/navigation/NavigationScreen.d.ts +3 -3
- package/lib/typescript/commonjs/network/NetworkStatusBanner.d.ts +7 -7
- package/lib/typescript/commonjs/theme/Gradient.d.ts +2 -2
- package/lib/typescript/commonjs/theme/ThemeContext.d.ts +5 -5
- package/lib/typescript/commonjs/theme/componentSizes.d.ts +15 -38
- package/lib/typescript/commonjs/theme/types.d.ts +84 -84
- package/lib/typescript/commonjs/utils/announce.d.ts +1 -1
- package/lib/typescript/commonjs/utils/complete.d.ts +5 -0
- package/lib/typescript/commonjs/utils/feedback.d.ts +3 -1
- package/lib/typescript/commonjs/utils/guards.d.ts +9 -0
- package/lib/typescript/commonjs/utils/placement.d.ts +3 -3
- package/lib/typescript/commonjs/utils/squircle.d.ts +2 -2
- package/lib/typescript/module/canvasKit/index.d.ts +12 -12
- package/lib/typescript/module/canvasKit/meta.d.ts +5 -7
- package/lib/typescript/module/components/Accordion/Accordion.d.ts +22 -22
- package/lib/typescript/module/components/AmountSlider/AmountSlider.d.ts +23 -23
- package/lib/typescript/module/components/AnimatePresence/AnimatePresence.d.ts +5 -5
- package/lib/typescript/module/components/AppBar/AppBar.d.ts +39 -39
- package/lib/typescript/module/components/AppIcon/AppIcon.d.ts +7 -7
- package/lib/typescript/module/components/AppIcon/defaultIcons.d.ts +2 -1
- package/lib/typescript/module/components/AppIcon/glyphs.g.d.ts +233 -233
- package/lib/typescript/module/components/AppIcon/slotIcon.d.ts +1 -1
- package/lib/typescript/module/components/AppLockOverlay/AppLockOverlay.d.ts +5 -5
- package/lib/typescript/module/components/AsyncBlock/AsyncBlock.d.ts +22 -40
- package/lib/typescript/module/components/AuthedImage/AuthedImage.d.ts +15 -15
- package/lib/typescript/module/components/AuthedImage/authedImageCache.d.ts +2 -2
- package/lib/typescript/module/components/Autocomplete/Autocomplete.d.ts +24 -24
- package/lib/typescript/module/components/Avatar/Avatar.d.ts +41 -39
- package/lib/typescript/module/components/Badge/Badge.d.ts +18 -18
- package/lib/typescript/module/components/Banner/Banner.d.ts +25 -25
- package/lib/typescript/module/components/BarChart/BarChart.d.ts +21 -21
- package/lib/typescript/module/components/BottomNavigation/BottomNavigation.d.ts +36 -36
- package/lib/typescript/module/components/BottomSheet/BottomSheet.d.ts +32 -32
- package/lib/typescript/module/components/Box/Box.d.ts +27 -27
- package/lib/typescript/module/components/Button/Button.d.ts +29 -24
- package/lib/typescript/module/components/Calendar/Calendar.d.ts +20 -20
- package/lib/typescript/module/components/Calendar/CalendarDay.d.ts +4 -2
- package/lib/typescript/module/components/Card/Card.d.ts +41 -41
- package/lib/typescript/module/components/Carousel/Carousel.d.ts +21 -21
- package/lib/typescript/module/components/Checkbox/Checkbox.d.ts +21 -21
- package/lib/typescript/module/components/Chip/Chip.d.ts +23 -23
- package/lib/typescript/module/components/ChoiceGroup/ChoiceGroup.d.ts +51 -46
- package/lib/typescript/module/components/Composer/Composer.d.ts +27 -27
- package/lib/typescript/module/components/Confetti/Confetti.d.ts +22 -21
- package/lib/typescript/module/components/Confirm/confirm.d.ts +4 -4
- package/lib/typescript/module/components/DatePicker/DatePicker.d.ts +20 -20
- package/lib/typescript/module/components/DateRangePicker/DateRangePicker.d.ts +22 -22
- package/lib/typescript/module/components/DateSeparator/DateSeparator.d.ts +9 -9
- package/lib/typescript/module/components/DecimalInput/DecimalInput.d.ts +14 -14
- package/lib/typescript/module/components/Descriptions/Descriptions.d.ts +13 -13
- package/lib/typescript/module/components/Dialog/Dialog.d.ts +24 -24
- package/lib/typescript/module/components/Dialog/OverlayActions.d.ts +5 -5
- package/lib/typescript/module/components/Divider/Divider.d.ts +9 -9
- package/lib/typescript/module/components/Drawer/Drawer.d.ts +14 -14
- package/lib/typescript/module/components/EmptyState/EmptyState.d.ts +13 -13
- package/lib/typescript/module/components/ErrorBoundary/ErrorBoundary.d.ts +8 -8
- package/lib/typescript/module/components/FieldBase/Chevron.d.ts +2 -2
- package/lib/typescript/module/components/FieldBase/ChoiceText.d.ts +10 -10
- package/lib/typescript/module/components/FieldBase/FieldBase.d.ts +54 -54
- package/lib/typescript/module/components/FieldBase/useFloatingLabel.d.ts +8 -8
- package/lib/typescript/module/components/FilePicker/FilePicker.d.ts +35 -35
- package/lib/typescript/module/components/FileViewer/FileViewer.d.ts +10 -10
- package/lib/typescript/module/components/FileViewer/fileSource.d.ts +3 -3
- package/lib/typescript/module/components/FilterChipRow/FilterChipRow.d.ts +12 -12
- package/lib/typescript/module/components/FloatingActionButton/FloatingActionButton.d.ts +35 -35
- package/lib/typescript/module/components/ForceUpdateDialog/ForceUpdateDialog.d.ts +11 -11
- package/lib/typescript/module/components/FormField/FormField.d.ts +15 -15
- package/lib/typescript/module/components/IconBadge/IconBadge.d.ts +11 -11
- package/lib/typescript/module/components/IconButton/IconButton.d.ts +14 -14
- package/lib/typescript/module/components/ImageGallery/ImageGallery.d.ts +14 -14
- package/lib/typescript/module/components/InlineSelect/InlineSelect.d.ts +36 -31
- package/lib/typescript/module/components/Input/Input.d.ts +47 -47
- package/lib/typescript/module/components/KeyboardAwareScrollView/KeyboardAwareScrollView.d.ts +7 -7
- package/lib/typescript/module/components/KeyboardToolbar/KeyboardToolbar.d.ts +8 -8
- package/lib/typescript/module/components/ListItem/ListItem.d.ts +44 -44
- package/lib/typescript/module/components/ListSection/ListSection.d.ts +6 -6
- package/lib/typescript/module/components/LoaderOverlay/LoaderOverlay.d.ts +17 -11
- package/lib/typescript/module/components/Markdown/Markdown.d.ts +15 -15
- package/lib/typescript/module/components/Menu/Menu.d.ts +17 -12
- package/lib/typescript/module/components/Menu/MenuSurface.d.ts +8 -8
- package/lib/typescript/module/components/Menu/menuModel.d.ts +11 -11
- package/lib/typescript/module/components/Menu/useContextMenu.d.ts +13 -13
- package/lib/typescript/module/components/Menu/webOnly.d.ts +3 -3
- package/lib/typescript/module/components/MessageBubble/MessageBubble.d.ts +20 -20
- package/lib/typescript/module/components/MessageList/MessageList.d.ts +14 -14
- package/lib/typescript/module/components/Modal/Modal.d.ts +19 -19
- package/lib/typescript/module/components/NonModalBottomSheet/NonModalBottomSheet.d.ts +52 -0
- package/lib/typescript/module/components/NonModalBottomSheet/index.d.ts +3 -0
- package/lib/typescript/module/components/NumberInput/NumberInput.d.ts +27 -27
- package/lib/typescript/module/components/OTPInput/OTPInput.d.ts +20 -20
- package/lib/typescript/module/components/OTPInput/OTPResendRow.d.ts +9 -9
- package/lib/typescript/module/components/OnboardingPager/OnboardingPager.d.ts +5 -5
- package/lib/typescript/module/components/OptionSheet/OptionSheet.d.ts +39 -34
- package/lib/typescript/module/components/OptionSheet/optionAccessors.d.ts +9 -0
- package/lib/typescript/module/components/PagedListFooter/PagedListFooter.d.ts +2 -2
- package/lib/typescript/module/components/PermissionPrompt/PermissionPrompt.d.ts +6 -6
- package/lib/typescript/module/components/PermissionPrompt/usePermissionPrompt.d.ts +1 -1
- package/lib/typescript/module/components/PhoneNumberInput/PhoneNumberInput.d.ts +43 -43
- package/lib/typescript/module/components/PickerTrigger/PickerTrigger.d.ts +23 -23
- package/lib/typescript/module/components/ProfileCompletion/ProfileCompletion.d.ts +23 -23
- package/lib/typescript/module/components/ProfilePicker/ProfilePicker.d.ts +30 -30
- package/lib/typescript/module/components/ProgressBar/ProgressBar.d.ts +21 -21
- package/lib/typescript/module/components/ProgressRing/ProgressRing.d.ts +13 -13
- package/lib/typescript/module/components/Radio/Radio.d.ts +18 -18
- package/lib/typescript/module/components/Radio/RadioDot.d.ts +5 -5
- package/lib/typescript/module/components/Radio/RadioGroup.d.ts +8 -8
- package/lib/typescript/module/components/Rating/Rating.d.ts +15 -15
- package/lib/typescript/module/components/Repeater/Repeater.d.ts +10 -10
- package/lib/typescript/module/components/RichTextEditor/RichTextEditor.d.ts +15 -15
- package/lib/typescript/module/components/ScannerOverlay/ScannerOverlay.d.ts +13 -13
- package/lib/typescript/module/components/Screen/Screen.d.ts +43 -44
- package/lib/typescript/module/components/Screen/index.d.ts +1 -1
- package/lib/typescript/module/components/SearchBar/SearchBar.d.ts +31 -31
- package/lib/typescript/module/components/SearchBar/SearchPanel.d.ts +6 -6
- package/lib/typescript/module/components/SearchBar/useRecentSearches.d.ts +1 -1
- package/lib/typescript/module/components/SectionHeader/SectionHeader.d.ts +10 -10
- package/lib/typescript/module/components/SegmentedControl/SegmentedControl.d.ts +25 -24
- package/lib/typescript/module/components/Select/Select.d.ts +50 -45
- package/lib/typescript/module/components/SignaturePad/SignaturePad.d.ts +20 -20
- package/lib/typescript/module/components/Skeleton/Skeleton.d.ts +13 -13
- package/lib/typescript/module/components/Skeleton/SkeletonContent.d.ts +9 -9
- package/lib/typescript/module/components/Skeleton/SkeletonList.d.ts +30 -8
- package/lib/typescript/module/components/Skeleton/SkeletonProvider.d.ts +9 -9
- package/lib/typescript/module/components/SlideToConfirm/SlideToConfirm.d.ts +14 -14
- package/lib/typescript/module/components/Slider/Slider.d.ts +30 -30
- package/lib/typescript/module/components/Slider/valueText.d.ts +9 -9
- package/lib/typescript/module/components/SliderField/SliderField.d.ts +41 -41
- package/lib/typescript/module/components/SortableList/SortableList.d.ts +5 -5
- package/lib/typescript/module/components/Sparkline/Sparkline.d.ts +13 -13
- package/lib/typescript/module/components/Sparkline/geometry.d.ts +3 -1
- package/lib/typescript/module/components/Spinner/Spinner.d.ts +10 -10
- package/lib/typescript/module/components/SquircleFill/SquircleFill.d.ts +3 -3
- package/lib/typescript/module/components/SquircleImage/SquircleImage.d.ts +5 -12
- package/lib/typescript/module/components/StatTile/StatTile.d.ts +14 -14
- package/lib/typescript/module/components/StatusBadge/StatusBadge.d.ts +13 -13
- package/lib/typescript/module/components/Stepper/Stepper.d.ts +21 -21
- package/lib/typescript/module/components/Swipeable/Swipeable.d.ts +15 -15
- package/lib/typescript/module/components/Switch/Switch.d.ts +19 -19
- package/lib/typescript/module/components/Tabs/Tabs.d.ts +20 -20
- package/lib/typescript/module/components/TagInput/TagInput.d.ts +19 -19
- package/lib/typescript/module/components/Text/Text.d.ts +10 -10
- package/lib/typescript/module/components/TimePicker/TimePicker.d.ts +14 -14
- package/lib/typescript/module/components/Timeline/Timeline.d.ts +12 -12
- package/lib/typescript/module/components/Toast/Toast.d.ts +17 -17
- package/lib/typescript/module/components/Toast/ToastProvider.d.ts +8 -8
- package/lib/typescript/module/components/Tooltip/RichTooltipBody.d.ts +4 -4
- package/lib/typescript/module/components/Tooltip/Tooltip.d.ts +24 -19
- package/lib/typescript/module/components/Tour/Tour.d.ts +7 -7
- package/lib/typescript/module/components/TypingIndicator/TypingIndicator.d.ts +6 -6
- package/lib/typescript/module/components/WheelPicker/Wheel.d.ts +10 -6
- package/lib/typescript/module/components/WheelPicker/WheelPicker.d.ts +22 -20
- package/lib/typescript/module/components/ZoomableImage/ZoomableImage.d.ts +8 -8
- package/lib/typescript/module/components/index.d.ts +2 -0
- package/lib/typescript/module/form/HookFormField.d.ts +5 -18
- package/lib/typescript/module/form/path.d.ts +4 -2
- package/lib/typescript/module/form/useFormCompletion.d.ts +1 -1
- package/lib/typescript/module/hooks/useControllableState.d.ts +2 -2
- package/lib/typescript/module/hooks/useDragToDismiss.d.ts +3 -3
- package/lib/typescript/module/hooks/useFieldErrorScroll.d.ts +1 -1
- package/lib/typescript/module/hooks/usePressAnimation.d.ts +4 -4
- package/lib/typescript/module/hooks/useRefreshControl.d.ts +8 -8
- package/lib/typescript/module/hooks/useResendCountdown.d.ts +1 -1
- package/lib/typescript/module/hooks/useScrollDirection.d.ts +1 -1
- package/lib/typescript/module/index.d.ts +1 -1
- package/lib/typescript/module/navigation/DiscardGuard.d.ts +2 -2
- package/lib/typescript/module/navigation/NavigationScreen.d.ts +3 -3
- package/lib/typescript/module/network/NetworkStatusBanner.d.ts +7 -7
- package/lib/typescript/module/theme/Gradient.d.ts +2 -2
- package/lib/typescript/module/theme/ThemeContext.d.ts +5 -5
- package/lib/typescript/module/theme/componentSizes.d.ts +15 -38
- package/lib/typescript/module/theme/types.d.ts +84 -84
- package/lib/typescript/module/utils/announce.d.ts +1 -1
- package/lib/typescript/module/utils/complete.d.ts +5 -0
- package/lib/typescript/module/utils/feedback.d.ts +3 -1
- package/lib/typescript/module/utils/guards.d.ts +9 -0
- package/lib/typescript/module/utils/placement.d.ts +3 -3
- package/lib/typescript/module/utils/squircle.d.ts +2 -2
- package/package.json +9 -9
- package/src/specs/NativePdfRasterizer.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{
|
|
1
|
+
"use strict";import{OFFLINE_CODE}from"@webority/mobile-core";import{useMemo}from"react";import{View}from"react-native";import{useTheme}from"../../theme/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{AppIcon}from"../AppIcon/index.js";import{EmptyState}from"../EmptyState/index.js";import{Spinner}from"../Spinner/index.js";import{jsx as _jsx,Fragment as _Fragment}from"react/jsx-runtime";export const DEFAULT_ASYNC_BLOCK_LABELS=Object.freeze({emptyTitle:"Nothing here yet",errorTitle:"That didn't load",offlineTitle:"You're offline",retry:"Try again"});export function AsyncBlock({state:e,children:t,empty:r,errorVariant:s,skeleton:i,errorTitle:o,offlineTitle:l,labels:n,style:a,testID:c}){const m=useTheme(),d=useMemo(()=>({...DEFAULT_ASYNC_BLOCK_LABELS,...n}),[n]);switch(assertValidValue("AsyncBlock","errorVariant",s,["default","offline"]),assertValidValue("AsyncBlock","status",e.status,["idle","loading","error","empty","data"]),e.status){case"idle":return null;case"loading":return _jsx(View,{style:a,testID:c,children:i??_jsx(View,{style:{paddingVertical:m.space["2xl"],alignItems:"center"},children:_jsx(Spinner,{})})});case"error":{const t="offline"===(s??(e.error.code===OFFLINE_CODE?"offline":"default"));return _jsx(View,{style:a,testID:c,children:_jsx(EmptyState,{icon:t?_jsx(AppIcon,{name:"cloud-cross",size:"xl",color:m.colors["text-subtle"],testID:"async-block-offline-icon"}):void 0,title:t?l??d.offlineTitle:o??d.errorTitle,description:e.error.message,action:{label:d.retry,onPress:e.retry}})})}case"empty":return _jsx(View,{style:a,testID:c,children:_jsx(EmptyState,{...r??{title:d.emptyTitle}})});case"data":return _jsx(_Fragment,{children:t(e.data)})}}export default AsyncBlock;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{Image}from"expo-image";import{useEffect,useMemo,useRef,useState}from"react";import{StyleSheet,View}from"react-native";import{useTheme}from"../../theme/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{smoothCorners}from"../../utils/corners.js";import{Spinner}from"../Spinner/index.js";import{Text}from"../Text/index.js";import{acquireFetch,DEFAULT_TTL_MS,deriveCacheKey,isFresh,isPermanentRefusal,readEntry,releaseFetch,removeEntry,touchEntry}from"./authedImageCache.js";import{jsx as _jsx}from"react/jsx-runtime";export const DEFAULT_AUTHED_IMAGE_LABELS=Object.freeze({loading:"Loading image",unavailable:"Image unavailable",unavailableNamed:e=>`${e}, image unavailable`});const CONTENT_FIT={cover:"cover",contain:"contain",stretch:"fill",center:"scale-down",repeat:"cover"},toError=e=>e instanceof Error?e:new Error(String(e)),AuthedImage=e=>{const{uri:t,headers:r,client:
|
|
1
|
+
"use strict";import{Image}from"expo-image";import{useEffect,useMemo,useRef,useState}from"react";import{StyleSheet,View}from"react-native";import{useTheme}from"../../theme/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{smoothCorners}from"../../utils/corners.js";import{Spinner}from"../Spinner/index.js";import{Text}from"../Text/index.js";import{acquireFetch,DEFAULT_TTL_MS,deriveCacheKey,isFresh,isPermanentRefusal,readEntry,releaseFetch,removeEntry,touchEntry}from"./authedImageCache.js";import{jsx as _jsx}from"react/jsx-runtime";export const DEFAULT_AUTHED_IMAGE_LABELS=Object.freeze({loading:"Loading image",unavailable:"Image unavailable",unavailableNamed:e=>`${e}, image unavailable`});const CONTENT_FIT={cover:"cover",contain:"contain",stretch:"fill",center:"scale-down",repeat:"cover"},toError=e=>e instanceof Error?e:new Error(String(e)),AuthedImage=e=>{const{uri:t,headers:r,client:i,authenticated:a=!0,ttlMs:s=DEFAULT_TTL_MS,placeholder:o,fallback:n,onLoadStart:l,onLoadEnd:c,onError:d,cacheKey:u,testID:m,accessibilityLabel:h,style:y,resizeMode:f,fadeDuration:b,contentFit:E,transition:g,labels:v,cachePolicy:p="memory",...I}=e;assertValidValue("AuthedImage","resizeMode",f,Object.keys(CONTENT_FIT));const L=useMemo(()=>({...DEFAULT_AUTHED_IMAGE_LABELS,...v}),[v]),T=useTheme(),S=useMemo(()=>buildStyles(T),[T]),[j,x]=useState({status:"loading"}),_=useRef({onLoadStart:l,onLoadEnd:c,onError:d});_.current={onLoadStart:l,onLoadEnd:c,onError:d};const F=JSON.stringify(r??{});if(useEffect(()=>{let e=!1,r=null;const finish=t=>{e||(x(t),_.current.onLoadEnd?.())};return(async()=>{if(!t){const t=new Error("[@webority/mobile-ui] AuthedImage was given an empty `uri`. Pass the image URL, or render nothing while the URL is still unknown.");return void(e||(x({status:"error"}),_.current.onError?.(t)))}x({status:"loading"}),_.current.onLoadStart?.();const o=deriveCacheKey(t,u),n=await readEntry(o);if(e)return;if(n&&isFresh(n.meta,s))return touchEntry(o),void finish({status:"ready",fileUri:n.fileUri});const l=JSON.parse(F),c=acquireFetch(o,{uri:t,headers:l,authenticated:a,client:i});r={key:o,entry:c};try{const e=await c.promise;finish({status:"ready",fileUri:e.fileUri})}catch(t){if(e)return;if(n&&!isPermanentRefusal(t))return void finish({status:"ready",fileUri:n.fileUri});if(n&&(await removeEntry(o),e))return;x({status:"error"}),_.current.onError?.(toError(t)),_.current.onLoadEnd?.()}})(),()=>{e=!0,r&&releaseFetch(r.key,r.entry)}},[t,u,s,a,i,F]),"loading"===j.status)return _jsx(View,void 0!==o?{style:y,testID:m,children:o}:{style:[S.placeholder,y],testID:m,children:_jsx(View,{style:S.stateFill,testID:m?`${m}-placeholder`:void 0,pointerEvents:"none",children:_jsx(Spinner,{size:"sm",accessibilityLabel:L.loading})})});if("error"===j.status)return _jsx(View,void 0!==n?{style:y,testID:m,children:n}:{style:[S.fallback,y],testID:m,children:_jsx(View,{accessible:!0,accessibilityRole:"image",accessibilityLabel:h?L.unavailableNamed(h):L.unavailable,testID:m?`${m}-fallback`:void 0,style:S.stateFill,children:_jsx(Text,{variant:"title",color:"tertiary",accessible:!1,children:"!"})})});const A=E??(f?CONTENT_FIT[f]:void 0),w=g??b,C={...void 0!==h?{accessibilityLabel:h}:{},...void 0!==m?{testID:m}:{},...void 0!==y?{style:y}:{},...void 0!==A?{contentFit:A}:{},...void 0!==w?{transition:w}:{}};return _jsx(Image,{...I,...C,accessible:!0,accessibilityRole:"image",cachePolicy:p,source:{uri:j.fileUri}})};AuthedImage.displayName="AuthedImage";const buildStyles=e=>StyleSheet.create({placeholder:{alignItems:"center",justifyContent:"center",backgroundColor:e.colors["bg-subtle"],borderRadius:e.radius.md,...smoothCorners},fallback:{alignItems:"center",justifyContent:"center",backgroundColor:e.colors["bg-subtle"],borderRadius:e.radius.md,...smoothCorners,borderWidth:e.size.border,borderColor:e.colors["border-subtle"],padding:e.space.sm},stateFill:{alignItems:"center",flex:1,justifyContent:"center"}});export{AuthedImage};export default AuthedImage;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{ACCESS_TOKEN_KEY,getConfigValue,getToken,isStorageAvailable,Logger,publicClient,Storage}from"@webority/mobile-core";import{AppState}from"react-native";import{hashString}from"../../utils/hashString.js";import{clearImages,deleteImage,imageExists,imageUri,listImageNames,writeImage}from"./imageStore";const INDEX_KEY="@webority/authed-image/v2/index",LEGACY_PREFIX="@webority/authed-image/v1/",DEFAULT_BYTE_CEILING=52428800,TOUCH_PERSIST_MS=36e5,PERSIST_DELAY_MS=1e3;export const DEFAULT_TTL_MS=6048e5;let byteCeiling=52428800;export const setAuthedImageCacheLimit=e=>{if(!Number.isFinite(e)||e<=0)throw new Error(`[@webority/mobile-ui] setAuthedImageCacheLimit() needs a positive number of bytes, received ${String(e)}. Pass e.g. 50 * 1024 * 1024 for 50 MB.`);byteCeiling=e};export const getAuthedImageCacheLimit=()=>byteCeiling;export const deriveCacheKey=(e,t)=>hashString(t??e);const toMeta=({fetchedAt:e,bytes:t,contentType:
|
|
1
|
+
"use strict";import{ACCESS_TOKEN_KEY,getConfigValue,getToken,isStorageAvailable,Logger,publicClient,Storage}from"@webority/mobile-core";import{AppState}from"react-native";import{isRecord}from"../../utils/guards.js";import{hashString}from"../../utils/hashString.js";import{clearImages,deleteImage,imageExists,imageUri,listImageNames,writeImage}from"./imageStore";const INDEX_KEY="@webority/authed-image/v2/index",LEGACY_PREFIX="@webority/authed-image/v1/",DEFAULT_BYTE_CEILING=52428800,TOUCH_PERSIST_MS=36e5,PERSIST_DELAY_MS=1e3;export const DEFAULT_TTL_MS=6048e5;const isIndexEntry=e=>isRecord(e)&&"number"==typeof e.fetchedAt&&"number"==typeof e.bytes&&"string"==typeof e.contentType&&"number"==typeof e.lastAccessedAt&&"string"==typeof e.fileName&&"number"==typeof e.persistedAccessAt;let byteCeiling=52428800;export const setAuthedImageCacheLimit=e=>{if(!Number.isFinite(e)||e<=0)throw new Error(`[@webority/mobile-ui] setAuthedImageCacheLimit() needs a positive number of bytes, received ${String(e)}. Pass e.g. 50 * 1024 * 1024 for 50 MB.`);byteCeiling=e};export const getAuthedImageCacheLimit=()=>byteCeiling;export const deriveCacheKey=(e,t)=>hashString(t??e);const toMeta=({fetchedAt:e,bytes:t,contentType:r,lastAccessedAt:s})=>({fetchedAt:e,bytes:t,contentType:r,lastAccessedAt:s});let index=null,indexBytes=0,indexLoad=null,persistTimer=null,persistTarget=null,appStateSub=null;const persistIndex=async e=>{if(!isStorageAvailable())return;const t={};for(const[r,s]of e)t[r]={...s,persistedAccessAt:s.lastAccessedAt};if(await Storage.setItem(INDEX_KEY,JSON.stringify(t)))for(const t of e.values())t.persistedAccessAt=t.lastAccessedAt},schedulePersist=e=>{persistTarget=e,null===appStateSub&&(appStateSub=AppState.addEventListener("change",e=>{"active"!==e&&flushAuthedImageIndex()})),null===persistTimer&&(persistTimer=setTimeout(()=>{flushAuthedImageIndex()},1e3))};export const flushAuthedImageIndex=async()=>{null!==persistTimer&&(clearTimeout(persistTimer),persistTimer=null);const e=persistTarget;persistTarget=null,null!==e&&await persistIndex(e)};const removeLegacyEntries=async()=>{const e=(await Storage.getAllKeys()).filter(e=>e.startsWith(LEGACY_PREFIX));e.length>0&&await Storage.multiRemove(e)},removeOrphanFiles=e=>{try{const t=new Set([...e.values()].map(e=>e.fileName));for(const e of listImageNames())t.has(e)||deleteImage(e)}catch(e){Logger.warn("[@webority/mobile-ui] AuthedImage could not tidy the image cache folder",e)}},readStoredIndex=async()=>{const e=new Map;if(!isStorageAvailable())return e;const t=await Storage.getItem(INDEX_KEY);if(!t)return await removeLegacyEntries(),e;try{const r=JSON.parse(t);if(isRecord(r))for(const[t,s]of Object.entries(r))isIndexEntry(s)&&e.set(t,s)}catch{}return e},loadIndex=()=>index?Promise.resolve(index):(indexLoad||(indexLoad=readStoredIndex().then(e=>{removeOrphanFiles(e);for(const[t,r]of e)imageExists(r.fileName)||e.delete(t);return index=e,indexBytes=[...e.values()].reduce((e,t)=>e+t.bytes,0),e}).finally(()=>{indexLoad=null})),indexLoad),deleteFile=e=>{try{deleteImage(e)}catch(e){Logger.warn("[@webority/mobile-ui] AuthedImage could not delete a cached image file",e)}};export const readEntry=async e=>{const t=await loadIndex(),r=t.get(e);return r?imageExists(r.fileName)?{fileUri:imageUri(r.fileName),meta:toMeta(r)}:(t.delete(e),indexBytes-=r.bytes,schedulePersist(t),null):null};export const removeEntry=async e=>{const t=await loadIndex(),r=t.get(e);r&&(t.delete(e),indexBytes-=r.bytes,deleteFile(r.fileName),schedulePersist(t))};export class AuthedImageHttpError extends Error{constructor(e,t){super(e),this.name="AuthedImageHttpError",this.status=t}}export const isPermanentRefusal=e=>e instanceof AuthedImageHttpError&&e.status>=400&&e.status<500&&408!==e.status&&429!==e.status;export const isFresh=(e,t,r=Date.now())=>r-e.fetchedAt<t;export const touchEntry=async e=>{const t=await loadIndex(),r=t.get(e);r&&(r.lastAccessedAt=Date.now(),r.lastAccessedAt-r.persistedAccessAt>=36e5&&schedulePersist(t))};const evictIfNeeded=e=>{let t=indexBytes;if(t<=byteCeiling)return 0;const r=[...e].sort(([,e],[,t])=>e.lastAccessedAt-t.lastAccessedAt);let s=0;for(const[i,a]of r){if(t<=byteCeiling)break;e.delete(i),indexBytes-=a.bytes,deleteFile(a.fileName),t-=a.bytes,s+=1}return s};export const clearAuthedImageCache=async()=>{null!==persistTimer&&(clearTimeout(persistTimer),persistTimer=null),persistTarget=null;(await loadIndex()).clear(),indexBytes=0,clearImages(),isStorageAvailable()&&await Storage.removeItem(INDEX_KEY)};export const authedImageCacheStats=async()=>{const e=await loadIndex();let t=0;for(const r of e.values())t+=r.bytes;return{entries:e.size,bytes:t}};const responseHeader=(e,t)=>{if(!isRecord(e))return;const r=e.get,s="function"==typeof r?r.call(e,t):e[t];return"string"==typeof s?s:void 0},originOf=e=>{const t=/^([a-z][a-z0-9+.-]*:\/\/[^/?#]+)/i.exec(e);if(null===t)return null;const r=t[1];if(void 0===r)throw new Error("originOf: the origin pattern always captures group 1 when it matches");return r.toLowerCase()},mediaTypeOf=e=>{const[t]=e.split(";");if(void 0===t)throw new Error("mediaTypeOf: String.split always returns at least one part");return t.trim()},isOwnApiAddress=e=>{const t=originOf(e);if(null===t)return!0;const r=getConfigValue("baseUrl");return"string"==typeof r&&originOf(r)===t},fetchAndStore=async(e,t,r)=>{const s={Accept:"image/*",...t.headers};if(!t.client&&t.authenticated&&isOwnApiAddress(t.uri)){const e=await getToken(ACCESS_TOKEN_KEY);e?.token&&(s.Authorization=`Bearer ${e.token}`)}const i=t.client??publicClient;let a;try{a=await i.get(t.uri,{headers:s,responseType:"arraybuffer",signal:r})}catch(e){const r=isRecord(e)&&isRecord(e.response)?e.response.status:void 0;if("number"!=typeof r)throw e;throw new AuthedImageHttpError(`[@webority/mobile-ui] AuthedImage could not load "${t.uri}": the server answered ${r}. Check the URL and whether the request needs to be signed in (pass the signed-in client as \`client\`, or authenticated={false} for public media).`,r)}const{data:n}=a;if(null!=n&&!(n instanceof ArrayBuffer))throw new Error(`[@webority/mobile-ui] AuthedImage could not load "${t.uri}": the client returned ${typeof n} instead of raw bytes. Pass a client that honours \`responseType: "arraybuffer"\`.`);const o=new Uint8Array(n??new ArrayBuffer(0));if(0===o.byteLength)throw new AuthedImageHttpError(`[@webority/mobile-ui] AuthedImage could not load "${t.uri}": the server answered with an empty body, so the address holds no image.`,404);const l=responseHeader(a.headers,"content-type"),c=(l?mediaTypeOf(l):"")||"image/jpeg",d=await loadIndex(),u=Date.now(),g=`${e}-${u.toString(36)}`;let m;try{m=await writeImage(g,o,c)}catch(e){throw new Error(`[@webority/mobile-ui] AuthedImage fetched "${t.uri}" but could not write it to the app's cache folder: ${e instanceof Error?e.message:String(e)}. The device may be out of storage.`)}const h={fetchedAt:u,bytes:o.byteLength,contentType:c,lastAccessedAt:u,fileName:g,persistedAccessAt:u},f=d.get(e);f&&(indexBytes-=f.bytes),d.set(e,h),indexBytes+=h.bytes,f&&f.fileName!==g&&deleteFile(f.fileName);const p=evictIfNeeded(d);return schedulePersist(d),p>0&&Logger.info(`[@webority/mobile-ui] AuthedImage evicted ${p} cached image(s) over the byte ceiling`),{fileUri:m,meta:toMeta(h)}},inFlight=new Map;export const acquireFetch=(e,t)=>{const r=inFlight.get(e);if(r)return r.waiters+=1,r;const s=new AbortController,i={controller:s,waiters:1,promise:fetchAndStore(e,t,s.signal).finally(()=>{inFlight.get(e)===i&&inFlight.delete(e)})};return inFlight.set(e,i),i};export const releaseFetch=(e,t)=>{t.waiters-=1,t.waiters>0||(inFlight.get(e)===t&&inFlight.delete(e),t.controller.abort())};
|
|
@@ -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{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"]}}};export const DEFAULT_AVATAR_LABELS=Object.freeze({avatar:"Avatar",avatarOf:e=>`${e}'s avatar`,verified:"verified",pendingVerification:"pending verification",groupOf:e=>`Group of ${e} ${1===e?"person":"people"}`,moreCount:e=>`${e} more`,moreAvatars:"More avatars"});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),isRingStatus=e=>"verified"===e||"pending"===e,statusColor=(e,t)=>{switch(t){case"online":case"verified":return e.colors.success;case"busy":return e.colors.danger;case"away":case"pending":return e.colors.warning;case"offline":return e.colors["text-subtle"]}},Avatar=forwardRef((e,t)=>{const{source:r,ImageComponent:o,imageClient:s,name:a,size:i="md",shape:n="circle",dimension:l,radius:c,border:u=!1,contentFit:d="cover",placeholderIcon:m,status:g=null,statusPosition:h="bottomRight",tone:p,backgroundColor:b,color:v,fontSize:f,loading:y=!1,accessibilityLabel:A,onPress:x,onLongPress:S,haptic:C,hitSlop:I,style:V,textStyle:_,testID:R,labels:j}=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"]),assertValidValue("Avatar","statusPosition",e.statusPosition,["topRight","bottomRight"]),assertValidValue("Avatar","tone",e.tone,["primary","success","warning","danger","info","neutral"]);const w=useMemo(()=>j?{...DEFAULT_AVATAR_LABELS,...j}:DEFAULT_AVATAR_LABELS,[j]),M=useTheme(),[T,L]=useState(null),E=useMemo(()=>l??resolveSize(i),[l,i]),k=useMemo(()=>resolveRadius(M,n,E,c),[M,n,E,c]),z=u?M.size.border:0,O=M.colors.border,F=M.colors.surface,D=useMemo(()=>initialsFromName(a),[a]),G=useMemo(()=>p?avatarToneColors(M,p):null,[M,p]),P=useMemo(()=>b||(G?.background??M.colors[hashColor(a??"",AVATAR_COLORS)]),[b,G,a,M]),N=v??G?.color??M.colors["on-primary"],$=r?keyOfSource(r):null,B=null!==$&&$!==T,H=!B&&""===D&&null!=m,U=v??G?.color??M.colors["text-subtle"],W=f??Math.max(M.text.xs.size,Math.round(.4*E)),q=Math.max(8,Math.round(.25*E)),Y=isRingStatus(g),X=E-2*(Y?3:z),J=Y?resolveRadius(M,n,X,c):Math.max(0,k-z),K=H?renderSlotIcon(m,{color:U,size:Math.round(.45*X),disabled:!1}):null,Q=Y?statusColor(M,g):"transparent",Z=Math.max(12,Math.round(.32*E)),ee=Math.max(10,Z-4),te=b??G?.background??M.colors["bg-muted"],re=B?"contain"===d?"transparent":M.colors["bg-muted"]:H?te:P,oe=R??"avatar",se=a?w.avatarOf(a):w.avatar,ae="verified"===g?`, ${w.verified}`:"pending"===g?`, ${w.pendingVerification}`:"",ie=A??`${se}${ae}`,ne="function"==typeof x||"function"==typeof S,le=A??`${a||se}${ae}`,ce=Math.max(0,Math.ceil((44-E)/2)),ue=I??ce,de=[styles.root,{width:E,height:E,borderRadius:k,...smoothCorners,borderWidth:Y?0:z,borderColor:O,backgroundColor:Y?"transparent":re},V],me=_jsxs(_Fragment,{children:[Y?_jsx(View,{style:[styles.ring,{borderRadius:k,...smoothCorners,borderWidth:1.5,borderColor:Q}],accessible:!1,pointerEvents:"none",testID:`${oe}-ring`}):null,_jsx(View,{style:[styles.picture,{width:X,height:X,borderRadius:J,...smoothCorners,borderWidth:Y?z:0,borderColor:O,backgroundColor:Y?re:"transparent"}],children:B?(()=>{const e={width:X,height:X,borderRadius:J,...smoothCorners},onError=()=>L($),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,{source:isImageSourceList(r)?[...r]:r,onError:onError,style:e,contentFit:d,accessibilityIgnoresInvertColors:!0})})():K||_jsx(Text,{variant:"label",weight:"semibold",numberOfLines:1,maxFontSizeMultiplier:1.2,style:[styles.initials,{color:N,fontSize:W,lineHeight:Math.round(W*M.leading.body)},_],children:D??" "})}),"verified"===g?_jsx(View,{style:[styles.status,"topRight"===h?styles.badgeTopRight:styles.badgeBottomRight,{width:Z,height:Z,borderRadius:Z/2,...smoothCorners,backgroundColor:F}],accessible:!1,pointerEvents:"none",testID:`${oe}-badge`,children:_jsx(AppIcon,{name:"verify",variant:"bold",size:ee,color:Q})}):null,g&&!Y?_jsx(View,{style:[styles.status,"topRight"===h?styles.statusTopRight:styles.statusBottomRight,{width:q,height:q,borderRadius:q/2,...smoothCorners,backgroundColor:statusColor(M,g),borderWidth:2,borderColor:F}],accessible:!1,pointerEvents:"none"}):null]}),ge=ne?_jsx(Pressable,{ref:t,onPress:x?e=>{const t=resolveHaptic(C,"selection");t&&triggerHaptic(t),x?.(e)}:void 0,onLongPress:S?e=>{const t=resolveHaptic(C,"longPress");t&&triggerHaptic(t),S?.(e)}:void 0,hitSlop:ue,...hitSlopMarker(ue),accessibilityRole:"button",accessibilityLabel:le,testID:R,style:({pressed:e})=>[de,e?styles.pressed:null],children:me}):_jsx(View,{ref:t,style:de,accessible:!0,accessibilityRole:"image",accessibilityLabel:ie,testID:R,children:me});return y?_jsx(AvatarSkeleton,{...e}):ge});Avatar.displayName="Avatar";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",Avatar.Skeleton=AvatarSkeleton;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:n,testID:l,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=useMemo(()=>c?{...DEFAULT_AVATAR_LABELS,...c}:DEFAULT_AVATAR_LABELS,[c]),d=useTheme(),m=useMemo(()=>Children.toArray(t).filter(e=>isValidElement(e)),[t]),g=m.length,h=m.slice(0,r),p=Math.max(0,g-r),b=p>0,v=-d.space[SPACING_OFFSET[s]],f=d.colors.surface,y=i??u.groupOf(g),A=useMemo(()=>resolveSize(o),[o]),x=Math.max(d.text.xs.size,Math.round(.34*A));return _jsxs(View,{style:[groupStyles.row,n],accessible:!0,accessibilityLabel:y,accessibilityRole:"summary",testID:l,children:[h.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:v,borderColor:f,borderWidth:1.5,children:s},r)}),b?_jsx(AvatarGroupItem,{delay:50*h.length,marginLeft:0===h.length?0:v,borderColor:f,borderWidth:1.5,children:_jsx(View,{style:[groupStyles.overflow,{width:A,height:A,borderRadius:A/2,...smoothCorners,backgroundColor:d.colors["surface-disabled"]}],accessible:!0,accessibilityRole:"text",accessibilityLabel:"count"===a?u.moreCount(p):u.moreAvatars,children:_jsx(Text,{variant:"label",weight:"semibold",color:"secondary",numberOfLines:1,maxFontSizeMultiplier:1.2,style:{fontSize:x,lineHeight:Math.round(x*d.leading.body)},children:"count"===a?`+${p}`:"+"})})},"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,forwardRef,isValidElement,useEffect,useMemo,useRef,useState}from"react";import{Animated,Easing,Pressable,StyleSheet,View}from"react-native";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"]}}};export const DEFAULT_AVATAR_LABELS=Object.freeze({avatar:"Avatar",avatarOf:e=>`${e}'s avatar`,verified:"verified",pendingVerification:"pending verification",rejected:"rejected",groupOf:e=>`Group of ${e} ${1===e?"person":"people"}`,moreCount:e=>`${e} more`,moreAvatars:"More avatars"});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:n="circle",dimension:l,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:A,onPress:x,onLongPress:S,haptic:j,hitSlop:C,style:I,textStyle:R,testID:V,labels:_}=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=useMemo(()=>_?{...DEFAULT_AVATAR_LABELS,..._}:DEFAULT_AVATAR_LABELS,[_]),M=useTheme(),[T,E]=useState(null),L=useMemo(()=>l??resolveSize(i),[l,i]),k=useMemo(()=>resolveRadius(M,n,L,c),[M,n,L,c]),z=u?M.size.border:0,O=M.colors.border,F=M.colors.surface,D=useMemo(()=>initialsFromName(a),[a]),G=useMemo(()=>p?avatarToneColors(M,p):null,[M,p]),P=useMemo(()=>b||(G?.background??M.colors[hashColor(a??"",AVATAR_COLORS)]),[b,G,a,M]),$=v??G?.color??M.colors["on-primary"],N=r?keyOfSource(r):null,B=useMemo(()=>void 0!==r?toExpoSources(r):void 0,[r]),H=null!==N&&N!==T,U=!H&&""===D&&null!=m,W=v??G?.color??M.colors["text-subtle"],q=f??Math.max(M.text.xs.size,Math.round(.4*L)),Y=Math.max(8,Math.round(.25*L)),X=isRingStatus(h),J=L-2*(X?3:z),K=X?resolveRadius(M,n,J,c):Math.max(0,k-z),Q=U?renderSlotIcon(m,{color:W,size:Math.round(.45*J),disabled:!1}):null,Z=X?statusColor(M,h):"transparent",ee=Math.max(12,Math.round(.32*L)),te=Math.max(10,ee-4),re=b??G?.background??M.colors["bg-muted"],oe=H?"contain"===d?"transparent":M.colors["bg-muted"]:U?re:P,se=V??"avatar",ae=a?w.avatarOf(a):w.avatar,ie="verified"===h?`, ${w.verified}`:"pending"===h?`, ${w.pendingVerification}`:"rejected"===h?`, ${w.rejected}`:"",ne=A??`${ae}${ie}`,le="function"==typeof x||"function"==typeof S,ce=A??`${a||ae}${ie}`,ue=Math.max(0,Math.ceil((44-L)/2)),de=C??ue,me=[styles.root,{width:L,height:L,borderRadius:k,...smoothCorners,borderWidth:X?0:z,borderColor:O,backgroundColor:X?"transparent":oe},I],he=_jsxs(_Fragment,{children:[X?_jsx(View,{style:[styles.ring,{borderRadius:k,...smoothCorners,borderWidth:1.5,borderColor:Z}],accessible:!1,pointerEvents:"none",testID:`${se}-ring`}):null,_jsx(View,{style:[styles.picture,{width:J,height:J,borderRadius:K,...smoothCorners,borderWidth:X?z:0,borderColor:O,backgroundColor:X?oe:"transparent"}],children:H?(()=>{const e={width:J,height:J,borderRadius:K,...smoothCorners};if(!r)return null;const onError=()=>E(N),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!==B?{source:B}:{},onError:onError,style:e,contentFit:d,accessibilityIgnoresInvertColors:!0})})():Q||_jsx(Text,{variant:"label",weight:"semibold",numberOfLines:1,maxFontSizeMultiplier:1.2,style:[styles.initials,{color:$,fontSize:q,lineHeight:Math.round(q*M.leading.body)},R],children:D??" "})}),"verified"===h||"rejected"===h?_jsx(View,{style:[styles.status,"topRight"===g?styles.badgeTopRight:styles.badgeBottomRight,{width:ee,height:ee,borderRadius:ee/2,...smoothCorners,backgroundColor:F}],accessible:!1,pointerEvents:"none",testID:`${se}-badge`,children:_jsx(AppIcon,{name:"verified"===h?"verify":"close-circle",variant:"bold",size:te,color:Z})}):null,h&&!X?_jsx(View,{style:[styles.status,"topRight"===g?styles.statusTopRight:styles.statusBottomRight,{width:Y,height:Y,borderRadius:Y/2,...smoothCorners,backgroundColor:statusColor(M,h),borderWidth:2,borderColor:F}],accessible:!1,pointerEvents:"none"}):null]}),ge=le?_jsx(Pressable,{ref:t,onPress:x?e=>{const t=resolveHaptic(j,"selection");t&&triggerHaptic(t),x?.(e)}:void 0,onLongPress:S?e=>{const t=resolveHaptic(j,"longPress");t&&triggerHaptic(t),S?.(e)}:void 0,hitSlop:de,...hitSlopMarker(de),accessibilityRole:"button",accessibilityLabel:ce,testID:V,style:({pressed:e})=>[me,e?styles.pressed:null],children:he}):_jsx(View,{ref:t,style:me,accessible:!0,accessibilityRole:"image",accessibilityLabel:ne,testID:V,children:he});return y?_jsx(AvatarSkeleton,{...e}):ge}),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:n,testID:l,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=useMemo(()=>c?{...DEFAULT_AVATAR_LABELS,...c}:DEFAULT_AVATAR_LABELS,[c]),d=useTheme(),m=useMemo(()=>Children.toArray(t).filter(e=>isValidElement(e)),[t]),h=m.length,g=m.slice(0,r),p=Math.max(0,h-r),b=p>0,v=-d.space[SPACING_OFFSET[s]],f=d.colors.surface,y=i??u.groupOf(h),A=useMemo(()=>resolveSize(o),[o]),x=Math.max(d.text.xs.size,Math.round(.34*A));return _jsxs(View,{style:[groupStyles.row,n],accessible:!0,accessibilityLabel:y,accessibilityRole:"summary",testID:l,children:[g.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:v,borderColor:f,borderWidth:1.5,children:s},r)}),b?_jsx(AvatarGroupItem,{delay:50*g.length,marginLeft:0===g.length?0:v,borderColor:f,borderWidth:1.5,children:_jsx(View,{style:[groupStyles.overflow,{width:A,height:A,borderRadius:A/2,...smoothCorners,backgroundColor:d.colors["surface-disabled"]}],accessible:!0,accessibilityRole:"text",accessibilityLabel:"count"===a?u.moreCount(p):u.moreAvatars,children:_jsx(Text,{variant:"label",weight:"semibold",color:"secondary",numberOfLines:1,maxFontSizeMultiplier:1.2,style:{fontSize:x,lineHeight:Math.round(x*d.leading.body)},children:"count"===a?`+${p}`:"+"})})},"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{forwardRef,useEffect,useMemo,useRef}from"react";import{Animated,Easing,StyleSheet,View}from"react-native";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";export const DEFAULT_BADGE_LABELS=Object.freeze({indicator:"Notification indicator",unread:e=>`${e} unread`});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},
|
|
1
|
+
"use strict";import{forwardRef,useEffect,useMemo,useRef}from"react";import{Animated,Easing,StyleSheet,View}from"react-native";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";export const DEFAULT_BADGE_LABELS=Object.freeze({indicator:"Notification indicator",unread:e=>`${e} unread`});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},BadgeRoot=forwardRef((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:p,textStyle:x,testID:y}=e;assertValidValue("Badge","variant",e.variant,["standard","dot"]),assertValidValue("Badge","tone",e.tone,["primary","success","warning","danger","neutral","info"]),assertValidValue("Badge","size",e.size,["sm","md"]),assertValidValue("Badge","anchor",e.anchor,["topRight","topLeft","bottomRight","bottomLeft"]),assertValidValue("Badge","fill",e.fill,["solid","soft"]);const v=useMemo(()=>({...DEFAULT_BADGE_LABELS,...f}),[f]),w=useTheme(),V=useMemo(()=>"soft"===a?softToneFor(w,s):toneFor(w,s),[w,s,a]),S=resolveBadgeSize(w,n),k=w.components.badge["border-width"],j=w.components.badge["anchor-offset"],B="dot"===i?null:formatValue(o,r),z=!d&&("dot"===i||null!==B),A=useRef(createAnimatedValue(1)).current;useEffect(()=>{if(!m||!z)return void setNativeValue(A,1);const e=Animated.loop(Animated.sequence([Animated.timing(A,{toValue:1.15,duration:w.motion.duration.slow,easing:Easing.bezier(...w.motion.ease["in-out"]),useNativeDriver:nativeDriver}),Animated.timing(A,{toValue:1,duration:w.motion.duration.slow,easing:Easing.bezier(...w.motion.ease["in-out"]),useNativeDriver:nativeDriver})]));return e.start(),()=>{e.stop()}},[m,z,A,w]);const _="dot"===i,L=_?"image":"text",D=h??(_?v.indicator:B?v.unread(B):void 0),R=z?_jsx(Animated.View,{style:[styles.badge,_?{width:S["dot-size"],height:S["dot-size"],borderRadius:S["dot-size"]/2,...smoothCorners,paddingHorizontal:0}:{minWidth:S["min-width"],minHeight:S.height,borderRadius:w.radius.pill,...smoothCorners,paddingHorizontal:S["padding-x"]},{backgroundColor:V.background,transform:[{scale:A}]},u?{position:"absolute",borderWidth:k,borderColor:w.colors.surface,...anchorPosition(g,j)}:null,p],accessible:l,importantForAccessibility:l?void 0:"no-hide-descendants",accessibilityElementsHidden:!l||void 0,accessibilityRole:l?L:void 0,accessibilityLabel:l?D:void 0,children:_||null===B?null:_jsx(Text,{variant:"caption",weight:"soft"===a?"semibold":"bold",numberOfLines:1,style:[styles.text,{color:V.text,fontSize:S.text,lineHeight:Math.round(S.text*w.leading.body)},x],children:B??" "})}):null,E=u?_jsxs(View,{ref:t,style:[styles.wrapper,b],testID:y,children:[u,R]}):_jsx(View,{ref:t,style:b,testID:y,children:R});return c?_jsx(BadgeSkeleton,{...e}):E}),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{forwardRef,useEffect,useMemo,useRef,useState}from"react";import{Animated,Pressable,StyleSheet,View}from"react-native";import{usePresenceMotion}from"../../hooks/usePresenceMotion.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";export const DEFAULT_BANNER_LABELS=Object.freeze({dismiss:"Dismiss banner"});const
|
|
1
|
+
"use strict";import{forwardRef,useEffect,useMemo,useRef,useState}from"react";import{Animated,Pressable,StyleSheet,View}from"react-native";import{usePresenceMotion}from"../../hooks/usePresenceMotion.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";export const DEFAULT_BANNER_LABELS=Object.freeze({dismiss:"Dismiss banner"});const BannerRoot=forwardRef((e,t)=>{const{title:r,message:o,tone:s="neutral",variant:n="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:b,containerStyle:x,iconCircleStyle:f,tintBarStyle:w,closeButtonStyle:j,actionButtonStyle:v,testID:S}=e;assertValidValue("Banner","tone",e.tone,["primary","success","warning","danger","info","neutral"]),assertValidValue("Banner","variant",e.variant,["bar","wash","tint"]),assertValidValue("Banner","accessibilityRole",e.accessibilityRole,["alert","summary","none"]);const B=useTheme(),V=usePresenceMotion(),k=useMemo(()=>buildStyles(B),[B]),C=useMemo(()=>tintFor(B,s),[B,s]),_=useMemo(()=>({...DEFAULT_BANNER_LABELS,...y}),[y]),[R,I]=V.range(-20,0),D=useRef(createAnimatedValue(m&&u?R:0)).current,A=useRef(createAnimatedValue(m&&u?0:u?1:0)).current,[T,L]=useState(u),M=useRef(!0);if(useEffect(()=>{if(M.current&&(M.current=!1,!m))return;let e;return u?(L(!0),e=Animated.parallel([Animated.timing(D,{toValue:I,duration:B.motion.duration.default,useNativeDriver:nativeDriver}),Animated.timing(A,{toValue:1,duration:V.duration("default"),useNativeDriver:nativeDriver})]),e.start()):T&&(e=Animated.parallel([Animated.timing(D,{toValue:R,duration:B.motion.duration.fast,useNativeDriver:nativeDriver}),Animated.timing(A,{toValue:0,duration:V.duration("fast"),useNativeDriver:nativeDriver})]),e.start(()=>{L(!1)})),()=>e?.stop()},[u]),!T)return null;const E=r??" ",z="string"==typeof o?o??" ":"",H="wash"===n,N="bar"!==n,P="alert"===g?"danger"===s?"assertive":"polite":"none",W=_jsxs(Animated.View,{ref:t,accessibilityRole:g,accessibilityLiveRegion:P,accessibilityLabel:h,testID:S,style:[k.container,{backgroundColor:N?C.soft:B.colors["bg-subtle"],borderRadius:H?B.radius.sm:B.radius.md,...smoothCorners,padding:B.space.md,opacity:A,transform:[{translateY:D}]},x,b],children:[!H&&B.components.banner["tint-bar-width"]>0?_jsx(View,{style:[k.tintBar,{backgroundColor:C.bar},w]}):null,_jsxs(View,{style:[k.row,void 0===r&&k.rowCentred],children:[!1===i?null:i?_jsx(View,{style:k.iconWrap,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:renderSlotIcon(i,{color:C.ink,size:B.text.xl.size,disabled:!1})}):_jsx(IconBadge,{dimension:ICON_CIRCLE_SIZE,color:C.bar,icon:_jsx(Text,{variant:"body",weight:"bold",accessible:!1,style:[k.iconGlyph,{color:C.ink}],children:C.glyph}),style:[k.iconCircle,f]}),_jsxs(View,{style:k.textBlock,children:[r||p?_jsx(Text,{variant:"body",weight:"semibold",numberOfLines:2,style:H?{color:C.ink}:void 0,children:E}):null,"string"==typeof o||p?_jsx(Text,{variant:"bodySmall",color:"secondary",style:{marginTop:r?B.space.xxs:0},children:z||" "}):_jsx(View,{style:{marginTop:r?B.space.xxs:0},children:o})]}),l?_jsx(Pressable,{accessibilityRole:"button",accessibilityLabel:_.dismiss,onPress:()=>{const e=resolveHaptic(d,"selection");e&&triggerHaptic(e),c?.()},hitSlop:8,...hitSlopMarker(8),style:({pressed:e})=>[k.closeBtn,{backgroundColor:e?B.colors["surface-pressed"]:"transparent"},j],children:_jsx(Text,{variant:"title",weight:"bold",color:"secondary",accessible:!1,style:{lineHeight:Math.round(B.text.lg.size*B.leading.heading)},children:"×"})}):null]}),a&&a.length>0?_jsx(View,{style:k.actionsRow,children:a.map((e,t)=>{assertValidValue("Banner","action.tone",e.tone,["primary","success","warning","danger","info","neutral"]),assertValidValue("Banner","action.variant",e.variant,["solid","outline","ghost"]),assertValidValue("Banner","action.size",e.size,["sm","md"]);const r=e.tone??"primary",o=e.variant??"ghost",s="primary"===r?C.glyphColor:"neutral"===r?B.colors["text-muted"]:B.colors[r],n="primary"===r?C.ink:"neutral"===r?B.colors["text-muted"]:B.colors[`${r}-text`],i="primary"===r?C.on:"neutral"===r?B.colors["on-neutral-strong"]:B.colors[`on-${r}`],a="solid"===o;return _jsx(Pressable,{accessibilityRole:"button",accessibilityLabel:e.label,testID:e.testID,onPress:()=>{const t=resolveHaptic(d,"selection");t&&triggerHaptic(t),e.onPress()},style:({pressed:t})=>[k.actionBtn,"md"===e.size&&k.actionBtnMd,"outline"===o&&{borderWidth:1,borderColor:n},{backgroundColor:a?s:t?B.colors["surface-pressed"]:"transparent",opacity:a&&t?.85:1},v],children:_jsx(Text,{variant:"bodySmall",weight:"semibold",align:"center",style:{color:a?i:n},children:e.label})},`${e.label}-${t}`)})}):null]});return p?_jsx(BannerSkeleton,{...e}):W}),BannerSkeleton=({title:e,actions:t,icon:r,containerStyle:o,style:s})=>{const n=useTheme(),i=!1!==r;return _jsxs(View,{style:[{flexDirection:"row",alignItems:"flex-start",backgroundColor:n.colors.surface,borderRadius:n.radius.md,...smoothCorners,padding:n.space.md,borderWidth:1,borderColor:n.colors.border},o,s],accessibilityRole:"progressbar",accessibilityState:{busy:!0},"aria-busy":!0,children:[i?_jsx(View,{style:{marginRight:n.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:n.space.xs}}):null,_jsx(SkeletonText,{lines:2,fontSize:n.text.sm.size,lastLineWidth:"70%"}),t&&t.length>0?_jsx(View,{style:{flexDirection:"row",marginTop:n.space.sm},children:t.map((e,t)=>_jsx(Skeleton,{width:72,height:28,shape:"rounded",style:{marginRight:n.space.sm}},`sk-banner-action-${t}`))}):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 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{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";export const DEFAULT_BOTTOM_NAVIGATION_LABELS=Object.freeze({switchesTo:e=>`Switches to ${e}`,unread:e=>`${e} unread`,newUpdates:"new updates"});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?`, ${t.unread(e)}`:"":!0===e||"·"===e?`, ${t.newUpdates}`:"string"==typeof e&&e.length>0?`, ${e}`:"",BottomNavigation=forwardRef((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:S,style:v,indicatorStyle:w,labelStyle:A,labelMaxFontScale:E,labels:I,testID:R}=e;assertValidValue("BottomNavigation","variant",e.variant,["pill","underline","floating","bubble","expand","solid","tile"]),assertValidValue("BottomNavigation","indicatorPosition",e.indicatorPosition,["top","bottom"]);const T=useMemo(()=>I?{...DEFAULT_BOTTOM_NAVIGATION_LABELS,...I}:DEFAULT_BOTTOM_NAVIGATION_LABELS,[I]),V=useTheme(),j=useSafeAreaInsets(),L=useMemo(()=>buildStyles(V),[V]),B=m??18,D=B+4+8,C=V.space.lg,M=V.space.lg,k=V.radius.xl,N=useReducedMotion(),P=useScreenReaderEnabled(y),[z,F]=React.useState(null);useEffect(()=>{null!==z&&z!==_&&F(null)},[z,_]);const H=y&&!P&&"down"===_&&null===z,[O,W]=React.useState(H);useEffect(()=>{O!==H&&(N||"web"===Platform.OS||LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut),W(H))},[O,H,N]);const U="function"==typeof S?S({minimized:O}):S,$=null!=U&&!1!==U,X=O&&$,[G,Z]=React.useState(0),Y=$&&!X?G+V.space.xs:0,K="tile"===l,q="floating"===l||K,J="bubble"===l,Q="expand"===l,ee="solid"===l,te="pill"===l||q||ee,ie=Math.max(0,i.findIndex(e=>e.key===o)),[ne,oe]=React.useState(0),[ae,re]=React.useState(0),se=n?Math.ceil(i.length/2):i.length,le=i.length+(n?1:0),[de,ce]=React.useState({width:0,height:0}),ue=n?.size??48,pe=void 0!==n?.gap,me=Math.max(0,n?.gap??0),he=pe?(de.width||ue)+2*me:0,ge=pe?i.length>0?Math.max(0,ne-he)/i.length:0:le>0?ne/le:0,be=pe?he:ge,fe=useRef(createAnimatedValue(ie)).current,xe=useRef({}),ye=useRef({});i.forEach(e=>{xe.current[e.key]||(xe.current[e.key]=new Animated.Value(1)),ye.current[e.key]||(ye.current[e.key]=createAnimatedValue(e.key===o?1:0))});const Se=ge>0?K?Math.min(ge-4,96):Math.min(ge-C,64):0,ve=ge>0?(ge-Se)/2:0,we=ge>0?(ge-48)/2:0,hasLabel=e=>s&&!O&&!1!==e.showLabel&&e.label.trim().length>0,Ae=i[ie],Ee=Ae&&!hasLabel(Ae)&&ae>0?ae/2:V.space.xs+(B+4)/2,Ie=Ee-14-24,Re=Math.max(0,ae-4),Te=K?2:Ee-D/2,Ve=useRef(ie);useEffect(()=>{if(Ve.current===ie)return;Ve.current=ie;const e=Animated.spring(fe,{toValue:ie,tension:120,friction:14,useNativeDriver:nativeDriver});return e.start(),()=>e.stop()},[ie,fe]);const je=Math.max(1,i.length-1),Le=useMemo(()=>{const e=[],t=[];for(let i=0;i<=je;i++)e.push(i),t.push(i<se?i*ge:i*ge+be);return fe.interpolate({inputRange:e,outputRange:t})},[fe,je,se,ge,be]),Be=i.map(e=>e.key).join(" "),De=J||Q;useEffect(()=>{const e=Be.split(" ").flatMap(e=>{const t=e===o?1:0,i=ye.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,Be,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()},Ce=useRef(new Animated.Value(1)).current,{colors:Me}=V,ke=ee?Me.primary:Me.surface,Ne=ee?Me["on-primary"]:Me.primary,Pe=ee?Me["on-primary"]:K?Me["text-body"]:Me["text-subtle"],ze=ee?Me["on-primary"]:Me["primary-soft"],Fe=ee?Me.primary:J?Me["on-primary"]:Ne,He=h??M,Oe=g??(q?M:0),We=Oe>0,Ue=f??V.space.sm,$e=b??(q?V.space.sm:V.space.xs),Xe=We?Ue:Math.max(Ue,j.bottom),Ge=We?Math.max(Oe,j.bottom>0?j.bottom+V.space.sm:0):0,Ze="pill"===c,Ye=q?ae+Y+2*Ue+2*StyleSheet.hairlineWidth:ae+Y+Ue+Xe,Ke=Ze?ae>0?Ye/2:V.radius.pill:c??(K?V.radius.pill:q?k:V.radius.none),qe=void 0!==c,activeBgRadius=(e,t)=>"number"==typeof u?Math.max(0,Math.min(u,e/2)):"auto"===u&&qe?Math.min(Ke,e/2):t,Je="underline"===l?Math.max($e,Ze&&0===ae?0:Ke):$e,Qe=p??"none",et="none"===Qe?void 0:V.shadow[Qe],tt=void 0===et?null:supportsBoxShadow()?{boxShadow:toBoxShadow(et)}:et,it=x?StyleSheet.hairlineWidth:0,nt=ee?Me.primary:Me.border,ot=n?.lift??0,at=Ue+it+Y,rt=n&&ae>0?Math.max(0,(de.height||ue)/2+ot-ae/2-at):0,st=n?_jsx(View,{style:[L.centerCell,pe?{flex:0,marginHorizontal:me}:null],pointerEvents:"box-none",children:_jsxs(Pressable,{onPress:()=>{if(!n)return;const e=n.haptic??r;!1!==e&&triggerHaptic(e),popIcon(Ce),n.onPress()},onLayout:e=>{const{width:t,height:i}=e.nativeEvent.layout;ce(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})=>[L.centerPressable,{top:-ot},e?{opacity:.85}:null],testID:n.testID??(R?`${R}-center`:void 0),children:[n.content?_jsx(Animated.View,{style:{transform:[{scale:Ce}]},children:n.content}):_jsx(View,{style:[L.centerCircle,{width:ue,height:ue,borderRadius:V.radius.pill,...smoothCorners,backgroundColor:n.color??Me.primary}],children:_jsx(Animated.View,{style:{transform:[{scale:Ce}]},children:renderSlotIcon(n.icon??"add",{color:n.iconColor??Me["on-primary"],size:n.iconSize??24,disabled:!1})})}),(lt=n,s&&!O&<.label.trim().length>0?_jsx(Text,{variant:"caption",numberOfLines:1,maxFontSizeMultiplier:E??V.settings.maxFontSizeMultiplier??1.2,style:[L.label,{color:Pe,opacity:ee?.7:1},A],children:n.label}):null)]})},CENTER_KEY):null;var lt;const dt=$?_jsx(View,{style:X?L.accessoryInline:L.accessoryStacked,onLayout:e=>Z(e.nativeEvent.layout.height),testID:R?`${R}-accessory`:void 0,children:U}):null,ct=_jsxs(View,{style:X?[L.tabRow,L.tabRowInline]:L.tabRow,onLayout:e=>{const{width:t,height:i}=e.nativeEvent.layout;oe(t),re(i)},children:[te&&Se>0&&(!K||Re>0)?_jsx(Animated.View,{pointerEvents:"none",style:[L.pill,{width:Se,height:K?Re:D,left:ve,top:Te,backgroundColor:ze,borderRadius:K?activeBgRadius(Re,Re/2):activeBgRadius(D,V.radius.pill),...smoothCorners,transform:[{translateX:Le}]},w]}):null,J&&ge>0?_jsx(Animated.View,{pointerEvents:"none",style:[L.bubble,V.shadow.elevated,{width:48,height:48,borderRadius:V.radius.pill,...smoothCorners,left:we,top:Ie,backgroundColor:Me.primary,borderColor:Me.surface,transform:[{translateX:Le}]},w]}):null,(ut=i.map(e=>{const t=e.key===o,i=t?Ne:Pe,n=t?Fe:Pe,s="string"==typeof e.icon?{name:e.icon,variant:"bold"}:e.icon,l=t?e.activeIcon??s:e.icon,d=xe.current[e.key],c=ye.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,T),m=ee&&!t?.7:1,h=J&&t||ee?Me.primary:Me.surface,g=hasLabel(e),b=g&&(!Q||t),f=_jsxs(Animated.View,{style:[L.iconWrap,{width:B+4,height:B+4,opacity:m,transform:[{scale:d}]}],children:[_jsx(View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:renderSlotIcon(l,{color:n,size:B,focused:t,disabled:!1})}),u?_jsx(Badge,{variant:u,value:"standard"===u?e.badge:void 0,tone:"danger",accessible:!1,style:"dot"===u?L.badgeDotPosition:L.badgePillPosition,badgeStyle:["dot"===u?L.badgeDot:L.badgePill,{borderColor:h}],textStyle:L.badgeText}):null]}),x=J?_jsx(Animated.View,{style:{top:c.interpolate({inputRange:[0,1],outputRange:[0,-14]})},children:f}):f,y=b?_jsx(Animated.Text,{numberOfLines:1,maxFontSizeMultiplier:E??V.settings.maxFontSizeMultiplier??1.2,style:[L.label,Q?L.labelInline:null,{color:i,opacity:Q?c:m,fontWeight:t?V.weight.semibold:V.weight.normal},A],children:e.label}):null,S=_jsx(Pressable,{onPress:()=>(e=>{O&&F(_),e.key!==o&&!1!==r&&triggerHaptic(r);const t=xe.current[e.key];t&&popIcon(t),a(e.key)})(e),accessibilityRole:"tab",accessibilityState:{selected:t},"aria-selected":t,accessibilityLabel:`${e.label}${p}`,accessibilityHint:T.switchesTo(e.label),hitSlop:{top:6,bottom:6,left:6,right:6},...hitSlopMarker({top:6,bottom:6,left:6,right:6}),style:({pressed:e})=>[L.tab,K?L.tabTile:null,e?{opacity:.85}:null],testID:R?`${R}-tab-${e.key}`:void 0,children:Q?_jsxs(View,{style:[L.expandPill,{height:D,paddingHorizontal:t&&g?V.space.md:Math.max(0,(D-(B+4))/2)}],children:[_jsx(View,{pointerEvents:"none",style:[L.expandFill,{borderRadius:activeBgRadius(D,D/2),...smoothCorners,backgroundColor:t?Me["primary-soft"]:"transparent"},t?w:null]}),x,y]}):_jsxs(_Fragment,{children:[x,y]})},e.key);return Q?_jsx(Animated.View,{style:{flex:c.interpolate({inputRange:[0,1],outputRange:[1,g?1.5:1]})},children:S},e.key):S}),st?[...ut.slice(0,se),st,...ut.slice(se)]:ut),"underline"===l&&ge>0?_jsx(Animated.View,{pointerEvents:"none",style:[L.underline,"top"===d?L.underlineTop:L.underlineBottom,"top"===d?{top:-Ue-Y}:{bottom:-Ue},{width:ge,height:3,backgroundColor:Me.primary,transform:[{translateX:Le}]},w]}):null]});var ut;return _jsx(View,{ref:t,testID:R,accessibilityRole:"tablist",style:[L.outer,{paddingHorizontal:He,paddingTop:Math.max(Oe,rt),paddingBottom:Ge},v],children:_jsxs(View,{style:[q?L.floatingBar:L.dockedBar,X?L.barInline:null,tt,{backgroundColor:ke,borderColor:nt,borderRadius:Ke,...smoothCorners},q?{borderWidth:it,paddingHorizontal:$e,paddingVertical:Ue}:{borderTopWidth:it,borderBottomWidth:it,borderLeftWidth:it,borderRightWidth:it,paddingHorizontal:Je,paddingTop:Ue,paddingBottom:Xe}],children:[dt,ct]})})});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:13}});export{BottomNavigation};export default BottomNavigation;
|
|
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{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";export const DEFAULT_BOTTOM_NAVIGATION_LABELS=Object.freeze({switchesTo:e=>`Switches to ${e}`,unread:e=>`${e} unread`,newUpdates:"new updates"});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?`, ${t.unread(e)}`:"":!0===e||"·"===e?`, ${t.newUpdates}`:"string"==typeof e&&e.length>0?`, ${e}`:"",BottomNavigation=forwardRef((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:S,style:v,indicatorStyle:w,labelStyle:A,labelMaxFontScale:E,labels:I,testID:R}=e;assertValidValue("BottomNavigation","variant",e.variant,["pill","underline","floating","bubble","expand","solid","tile"]),assertValidValue("BottomNavigation","indicatorPosition",e.indicatorPosition,["top","bottom"]);const T=useMemo(()=>I?{...DEFAULT_BOTTOM_NAVIGATION_LABELS,...I}:DEFAULT_BOTTOM_NAVIGATION_LABELS,[I]),V=useTheme(),j=useSafeAreaInsets(),L=useMemo(()=>buildStyles(V),[V]),B=m??18,D=B+4+8,M=V.space.lg,C=V.space.lg,k=V.radius.xl,N=useReducedMotion(),P=useScreenReaderEnabled(y),[z,F]=React.useState(null);useEffect(()=>{null!==z&&z!==_&&F(null)},[z,_]);const H=y&&!P&&"down"===_&&null===z,[O,W]=React.useState(H);useEffect(()=>{O!==H&&(N||"web"===Platform.OS||LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut),W(H))},[O,H,N]);const U="function"==typeof S?S({minimized:O}):S,$=null!=U&&!1!==U,X=O&&$,[G,Z]=React.useState(0),Y=$&&!X?G+V.space.xs:0,K="tile"===l,q="floating"===l||K,J="bubble"===l,Q="expand"===l,ee="solid"===l,te="pill"===l||q||ee,ie=Math.max(0,i.findIndex(e=>e.key===o)),[ne,oe]=React.useState(0),[ae,re]=React.useState(0),se=n?Math.ceil(i.length/2):i.length,le=i.length+(n?1:0),[de,ce]=React.useState({width:0,height:0}),ue=n?.size??48,pe=void 0!==n?.gap,me=Math.max(0,n?.gap??0),he=pe?(de.width||ue)+2*me:0,ge=pe?i.length>0?Math.max(0,ne-he)/i.length:0:le>0?ne/le:0,be=pe?he:ge,fe=useRef(createAnimatedValue(ie)).current,xe=useRef({}),ye=useRef({});i.forEach(e=>{xe.current[e.key]||(xe.current[e.key]=new Animated.Value(1)),ye.current[e.key]||(ye.current[e.key]=createAnimatedValue(e.key===o?1:0))});const Se=ge>0?K?Math.min(ge-4,96):Math.min(ge-M,64):0,ve=ge>0?(ge-Se)/2:0,we=ge>0?(ge-48)/2:0,hasLabel=e=>s&&!O&&!1!==e.showLabel&&e.label.trim().length>0,Ae=i[ie],Ee=Ae&&!hasLabel(Ae)&&ae>0?ae/2:V.space.xs+(B+4)/2,Ie=Ee-14-24,Re=Math.max(0,ae-4),Te=K?2:Ee-D/2,Ve=useRef(ie);useEffect(()=>{if(Ve.current===ie)return;Ve.current=ie;const e=Animated.spring(fe,{toValue:ie,tension:120,friction:14,useNativeDriver:nativeDriver});return e.start(),()=>e.stop()},[ie,fe]);const je=Math.max(1,i.length-1),Le=useMemo(()=>{const e=[],t=[];for(let i=0;i<=je;i++)e.push(i),t.push(i<se?i*ge:i*ge+be);return fe.interpolate({inputRange:e,outputRange:t})},[fe,je,se,ge,be]),Be=i.map(e=>e.key).join(" "),De=J||Q;useEffect(()=>{const e=Be.split(" ").flatMap(e=>{const t=e===o?1:0,i=ye.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,Be,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()},Me=useRef(new Animated.Value(1)).current,{colors:Ce}=V,ke=ee?Ce.primary:Ce.surface,Ne=ee?Ce["on-primary"]:Ce.primary,Pe=ee?Ce["on-primary"]:K?Ce["text-body"]:Ce["text-subtle"],ze=ee?Ce["on-primary"]:Ce["primary-soft"],Fe=ee?Ce.primary:J?Ce["on-primary"]:Ne,He=h??C,Oe=g??(q?C:0),We=Oe>0,Ue=f??V.space.sm,$e=b??(q?V.space.sm:V.space.xs),Xe=We?Ue:Math.max(Ue,j.bottom),Ge=We?Math.max(Oe,j.bottom>0?j.bottom+V.space.sm:0):0,Ze="pill"===c,Ye=q?ae+Y+2*Ue+2*StyleSheet.hairlineWidth:ae+Y+Ue+Xe,Ke=Ze?ae>0?Ye/2:V.radius.pill:c??(K?V.radius.pill:q?k:V.radius.none),qe=void 0!==c,activeBgRadius=(e,t)=>"number"==typeof u?Math.max(0,Math.min(u,e/2)):"auto"===u&&qe?Math.min(Ke,e/2):t,Je="underline"===l?Math.max($e,Ze&&0===ae?0:Ke):$e,Qe=p??"none",et="none"===Qe?void 0:V.shadow[Qe],tt=void 0===et?null:supportsBoxShadow()?{boxShadow:toBoxShadow(et)}:et,it=x?StyleSheet.hairlineWidth:0,nt=ee?Ce.primary:Ce.border,ot=n?.lift??0,at=Ue+it+Y,rt=n&&ae>0?Math.max(0,(de.height||ue)/2+ot-ae/2-at):0,st=n?_jsx(View,{style:[L.centerCell,pe?{flex:0,marginHorizontal:me}:null],pointerEvents:"box-none",children:_jsxs(Pressable,{onPress:()=>{if(!n)return;const e=n.haptic??r;!1!==e&&triggerHaptic(e),popIcon(Me),n.onPress()},onLayout:e=>{const{width:t,height:i}=e.nativeEvent.layout;ce(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})=>[L.centerPressable,{top:-ot},e?{opacity:.85}:null],testID:n.testID??(R?`${R}-center`:void 0),children:[n.content?_jsx(Animated.View,{style:{transform:[{scale:Me}]},children:n.content}):_jsx(View,{style:[L.centerCircle,{width:ue,height:ue,borderRadius:V.radius.pill,...smoothCorners,backgroundColor:n.color??Ce.primary}],children:_jsx(Animated.View,{style:{transform:[{scale:Me}]},children:renderSlotIcon(n.icon??"add",{color:n.iconColor??Ce["on-primary"],size:n.iconSize??24,disabled:!1})})}),(lt=n,s&&!O&<.label.trim().length>0?_jsx(Text,{variant:"caption",numberOfLines:1,maxFontSizeMultiplier:E??V.settings.maxFontSizeMultiplier??1.2,style:[L.label,{color:Pe,opacity:ee?.7:1},A],children:n.label}):null)]})},CENTER_KEY):null;var lt;const dt=$?_jsx(View,{style:X?L.accessoryInline:L.accessoryStacked,onLayout:e=>Z(e.nativeEvent.layout.height),testID:R?`${R}-accessory`:void 0,children:U}):null,ct=_jsxs(View,{style:X?[L.tabRow,L.tabRowInline]:L.tabRow,onLayout:e=>{const{width:t,height:i}=e.nativeEvent.layout;oe(t),re(i)},children:[te&&Se>0&&(!K||Re>0)?_jsx(Animated.View,{pointerEvents:"none",style:[L.pill,{width:Se,height:K?Re:D,left:ve,top:Te,backgroundColor:ze,borderRadius:K?activeBgRadius(Re,Re/2):activeBgRadius(D,V.radius.pill),...smoothCorners,transform:[{translateX:Le}]},w]}):null,J&&ge>0?_jsx(Animated.View,{pointerEvents:"none",style:[L.bubble,V.shadow.elevated,{width:48,height:48,borderRadius:V.radius.pill,...smoothCorners,left:we,top:Ie,backgroundColor:Ce.primary,borderColor:Ce.surface,transform:[{translateX:Le}]},w]}):null,(ut=i.map(e=>{const t=e.key===o,i=t?Ne:Pe,n=t?Fe:Pe,s="string"==typeof e.icon?{name:e.icon,variant:"bold"}:e.icon,l=t?e.activeIcon??s:e.icon,d=xe.current[e.key],c=ye.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,T),m=ee&&!t?.7:1,h=J&&t||ee?Ce.primary:Ce.surface,g=hasLabel(e),b=g&&(!Q||t),f=_jsxs(Animated.View,{style:[L.iconWrap,{width:B+4,height:B+4,opacity:m,transform:[{scale:d}]}],children:[_jsx(View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:renderSlotIcon(l,{color:n,size:B,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?L.badgeDotPosition:L.badgePillPosition,badgeStyle:["dot"===u?L.badgeDot:L.badgePill,{borderColor:h}],textStyle:L.badgeText}):null]}),x=J?_jsx(Animated.View,{style:{top:c.interpolate({inputRange:[0,1],outputRange:[0,-14]})},children:f}):f,y=b?_jsx(Animated.Text,{numberOfLines:1,maxFontSizeMultiplier:E??V.settings.maxFontSizeMultiplier??1.2,style:[L.label,Q?L.labelInline:null,{color:i,opacity:Q?c:m,fontWeight:t?V.weight.semibold:V.weight.normal},A],children:e.label}):null,S=_jsx(Pressable,{onPress:()=>(e=>{O&&F(_),e.key!==o&&!1!==r&&triggerHaptic(r);const t=xe.current[e.key];t&&popIcon(t),a(e.key)})(e),accessibilityRole:"tab",accessibilityState:{selected:t},"aria-selected":t,accessibilityLabel:`${e.label}${p}`,accessibilityHint:T.switchesTo(e.label),hitSlop:{top:6,bottom:6,left:6,right:6},...hitSlopMarker({top:6,bottom:6,left:6,right:6}),style:({pressed:e})=>[L.tab,K?L.tabTile:null,e?{opacity:.85}:null],testID:R?`${R}-tab-${e.key}`:void 0,children:Q?_jsxs(View,{style:[L.expandPill,{height:D,paddingHorizontal:t&&g?V.space.md:Math.max(0,(D-(B+4))/2)}],children:[_jsx(View,{pointerEvents:"none",style:[L.expandFill,{borderRadius:activeBgRadius(D,D/2),...smoothCorners,backgroundColor:t?Ce["primary-soft"]:"transparent"},t?w:null]}),x,y]}):_jsxs(_Fragment,{children:[x,y]})},e.key);return Q?_jsx(Animated.View,{style:{flex:c.interpolate({inputRange:[0,1],outputRange:[1,g?1.5:1]})},children:S},e.key):S}),st?[...ut.slice(0,se),st,...ut.slice(se)]:ut),"underline"===l&&ge>0?_jsx(Animated.View,{pointerEvents:"none",style:[L.underline,"top"===d?L.underlineTop:L.underlineBottom,"top"===d?{top:-Ue-Y}:{bottom:-Ue},{width:ge,height:3,backgroundColor:Ce.primary,transform:[{translateX:Le}]},w]}):null]});var ut;return _jsx(View,{ref:t,testID:R,accessibilityRole:"tablist",style:[L.outer,{paddingHorizontal:He,paddingTop:Math.max(Oe,rt),paddingBottom:Ge},v],children:_jsxs(View,{style:[q?L.floatingBar:L.dockedBar,X?L.barInline:null,tt,{backgroundColor:ke,borderColor:nt,borderRadius:Ke,...smoothCorners},q?{borderWidth:it,paddingHorizontal:$e,paddingVertical:Ue}:{borderTopWidth:it,borderBottomWidth:it,borderLeftWidth:it,borderRightWidth:it,paddingHorizontal:Je,paddingTop:Ue,paddingBottom:Xe}],children:[dt,ct]})})});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 +1 @@
|
|
|
1
|
-
"use strict";import{forwardRef}from"react";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{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=(e
|
|
1
|
+
"use strict";import{forwardRef}from"react";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"}:{}});const Box=forwardRef((r,e)=>{const o=useTheme(),{p:l,px:t,py:i,pt:s,pr:a,pb:n,pl:p,m:u,mx:d,my:m,mt:c,mr:g,mb:f,ml:b,gap:x,bg:y,radius:h,border:j,flex:w,align:S,justify:C,direction:R,wrap:B,style:O,children:k,...v}=r,_=resolveBoxStyle(o,{p:l,px:t,py:i,pt:s,pr:a,pb:n,pl:p,m:u,mx:d,my:m,mt:c,mr:g,mb:f,ml:b,gap:x,bg:y,radius:h,border:j,flex:w,align:S,justify:C,direction:R,wrap:B}),N="number"==typeof _.borderRadius?_.borderRadius:0,z="string"==typeof _.backgroundColor?_.backgroundColor:"transparent",T="string"==typeof _.borderColor?_.borderColor:void 0,q="number"==typeof _.borderWidth?_.borderWidth:0,D=useSquircle(null!=h&&(null!=y||Boolean(j)),N,v.onLayout),V=D.active?{..._,backgroundColor:"transparent",borderColor:"transparent"}:_;return _jsxs(View,{ref:e,...v,onLayout:D.onLayout,style:[V,O],children:[D.active&&D.size?_jsx(SquircleFill,{width:D.size.width,height:D.size.height,radius:N,fill:z,stroke:T,strokeWidth:q}):null,k]})});Box.displayName="Box";const Stack=forwardRef(({gap:r="md",...e},o)=>_jsx(Box,{ref:o,direction:"column",gap:r,...e}));Stack.displayName="Stack";const Row=forwardRef(({gap:r="sm",align:e="center",...o},l)=>_jsx(Box,{ref:l,direction:"row",gap:r,align:e,...o}));Row.displayName="Row";const Spacer=({size:r,style:e,testID:o})=>{const l=useTheme();if(null!=r){const t=spaceOf(l,r);return _jsx(View,{testID:o,style:[{width:t,height:t},e]})}return _jsx(View,{testID:o,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{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 DEFAULT_BUTTON_LABELS=Object.freeze({loading:"Loading"});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,containerStyle:h,textStyle:x,pressAnimation:y,onPress:S,accessibilityLabel:C,accessibilityHint:_,accessibilityState:
|
|
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{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 DEFAULT_BUTTON_LABELS=Object.freeze({loading:"Loading"});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,containerStyle:h,textStyle:x,pressAnimation:y,onPress:S,accessibilityLabel:C,accessibilityHint:_,accessibilityState:v,testID:I,onLayout:j,labels:T,...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,L=r??F?.defaultVariant??"solid",V=i??F?.defaultSize??"md",A=useMemo(()=>({...DEFAULT_BUTTON_LABELS,...T}),[T]),[R,O]=useState(!1),P=useRef(!1),z=n||R,B=!l&&!z,E={...v,disabled:!B,busy:z},D="link"===L,H=y??F?.defaultPressAnimation??(!D&&"scale"),W=usePressAnimation({preset:H||"scale",enabled:!1!==H&&B}),N=useFlickGuard(),M=useMemo(()=>buildStyles(w),[w]),U=useMemo(()=>resolveButtonSize(w,V),[w,V]),q=useMemo(()=>toneFor(w,s),[w,s]),G=useMemo(()=>variantFor(w,L,q,l),[w,L,q,l]),K=useMemo(()=>!m||l||"solid"!==L?null:"string"==typeof m?w.settings.gradients[m]??null:m,[m,l,L,w.settings.gradients]),X=StyleSheet.flatten(f)?.borderRadius,Y=D?0:"number"==typeof X?X:p?w.radius.pill:U.radius,J=useSquircle(!K&&"link"!==L,Y,j),Q=useRef(createAnimatedValue(0)).current,[Z,$]=useState(0),[ee,te]=useState(null),oe=D?e=>$(e.nativeEvent.layout.width):void 0,settlePending=()=>{P.current=!1,O(!1)},re=C??o,se="outline"===L||"ghost"===L,ie=!se&&!D,ne={color:G.textColor,size:U.icon,disabled:l},le=b&&!D&&Boolean(d),ae=w.space.xs,de=U["min-height"]-2*ae-2*G.borderWidth,ce={color:G.badgeInk,size:U["badge-icon"],disabled:l},ue=z?_jsx(Spinner,{variant:"circular",size:"sm",color:le?G.badgeInk:G.textColor,accessibilityLabel:A.loading}):d?_jsx(View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:renderSlotIcon(d,le?ce:ne,u)}):null,be=_jsxs(View,{style:M.contentRow,children:[le?_jsx(View,{testID:"button-icon-badge",style:[M.iconLeft,M.iconBadge,{width:de,height:de,borderRadius:de/2,backgroundColor:G.badgeFill}],children:ue}):ue?_jsx(View,{style:M.iconLeft,children:ue}):null,_jsxs(View,{onLayout:oe,children:[_jsx(Text,{variant:"label",weight:"semibold",numberOfLines:1,style:[M.label,{color:G.textColor,fontSize:U.text,lineHeight:Math.round(U.text*w.leading.body)},x],children:o}),D?_jsx(Animated.View,{pointerEvents:"none",testID:"button-link-underline",style:[M.linkUnderline,{backgroundColor:G.textColor,transform:[{translateX:Q.interpolate({inputRange:[0,1],outputRange:[-Z/2,0]})},{scaleX:Q.interpolate({inputRange:[0,1],outputRange:[0,1]})}]}]}):null]}),c?_jsx(View,{style:M.iconRight,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:renderSlotIcon(c,ne,u)}):null]}),ge=D?null===ee?LINK_HIT_SLOP:Math.max(LINK_HIT_SLOP,touchSlopFor(ee)):touchSlopFor(U["min-height"]),pe={top:ge,bottom:ge,left:D?LINK_HIT_SLOP:0,right:D?LINK_HIT_SLOP:0};return _jsx(Animated.View,{style:[W.style,a?M.fullWidth:null,h],children:_jsx(Pressable,{ref:t,onPress:e=>{if(!B||P.current||N.isFlick(e))return;W.press();const t=resolveHaptic(g,"impactLight");t&&triggerHaptic(t);const o=S?.(e);return o instanceof Promise?(P.current=!0,O(!0),o.then(settlePending,e=>{throw settlePending(),e})):void 0},onPressIn:e=>{N.onPressIn(e),W.pressIn(),D&&B&&(Q.stopAnimation(),Q.setValue(0),Animated.timing(Q,{toValue:1,duration:w.motion.duration.slower,easing:Easing.bezier(...w.motion.ease.decelerate),useNativeDriver:nativeDriver}).start())},onPressOut:()=>{W.pressOut()},disabled:!B,hitSlop:pe,...hitSlopMarker(pe),accessibilityRole:"button",accessibilityLabel:re,accessibilityHint:_,accessibilityState:E,...ariaFromState(E),testID:I,onLayout:e=>{J.onLayout(e),D&&te(e.nativeEvent.layout.height)},style:({pressed:e})=>[M.base,{paddingHorizontal:D?0:U["padding-x"],paddingVertical:D?0:le?ae:U["padding-y"],paddingLeft:le?ae:void 0,minHeight:D?void 0:U["min-height"],borderRadius:Y,...smoothCorners,backgroundColor:K||J.active?"transparent":G.backgroundColor,borderWidth:G.borderWidth,borderColor:J.active?"transparent":G.borderColor,opacity:z?.55:1,overflow:J.active||D?"visible":"hidden"},e&&se&&!J.active?{backgroundColor:w.colors["surface-pressed"]}:null,a?M.fullWidth:null,f],...k,"aria-disabled":!B,"aria-busy":z,children:({pressed:e})=>_jsxs(_Fragment,{children:[J.active&&J.size?_jsx(SquircleFill,{width:J.size.width,height:J.size.height,radius:Y,fill:e&&se?w.colors["surface-pressed"]:G.backgroundColor,stroke:G.borderColor,strokeWidth:G.borderWidth}):null,K?_jsx(Gradient,{gradient:K,style:[StyleSheet.absoluteFill,{borderRadius:Y,...smoothCorners}]}):null,e&&ie?J.active&&J.size?_jsx(SquircleFill,{width:J.size.width,height:J.size.height,radius:Y,fill:G.pressedTint,testID:"button-pressed"}):_jsx(View,{pointerEvents:"none",style:[M.pressedOverlay,{borderRadius:Y,backgroundColor:G.pressedTint,...smoothCorners}],testID:"button-pressed"}):null,be]})})})});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 +1 @@
|
|
|
1
|
-
"use strict";import{StyleSheet}from"react-native";import{fontFor}from"../../theme/index.js";import{smoothCorners}from"../../utils/corners.js";export const MIN_CELL_SIZE=44;export const NAV_BUTTON_SIZE=36;const DOT_SIZE=5;export const buildCalendarStyles=e=>StyleSheet.create({root:{alignSelf:"stretch"},headerRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",marginBottom:e.space.md},navBtn:{width:36,height:36,borderRadius:e.radius.pill,...smoothCorners,alignItems:"center",justifyContent:"center",backgroundColor:e.colors["bg-subtle"]},navBtnPressed:{backgroundColor:e.colors["surface-pressed"]},navBtnDisabled:{opacity:.4},navText:{fontSize:e.text["2xl"].size,lineHeight:
|
|
1
|
+
"use strict";import{StyleSheet}from"react-native";import{fontFor}from"../../theme/index.js";import{smoothCorners}from"../../utils/corners.js";export const MIN_CELL_SIZE=44;export const NAV_BUTTON_SIZE=36;const DOT_SIZE=5;export const buildCalendarStyles=e=>StyleSheet.create({root:{alignSelf:"stretch"},headerRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",marginBottom:e.space.md},navBtn:{width:36,height:36,borderRadius:e.radius.pill,...smoothCorners,alignItems:"center",justifyContent:"center",backgroundColor:e.colors["bg-subtle"]},navBtnPressed:{backgroundColor:e.colors["surface-pressed"]},navBtnDisabled:{opacity:.4},navText:{fontSize:e.text["2xl"].size,lineHeight:Math.round(e.text["2xl"].size*e.leading.heading),color:e.colors["text-body"],...fontFor(e,"semibold")},headerLabelWrap:{flex:1,alignItems:"center"},headerLabel:{fontSize:e.text.base.size,color:e.colors["text-body"],...fontFor(e,"semibold")},weekdayRow:{flexDirection:"row",justifyContent:"center",marginBottom:e.space.xs},weekdayCell:{alignItems:"center",paddingVertical:e.space.xs},weekdayText:{fontSize:e.text.xs.size,color:e.colors["text-subtle"],letterSpacing:e["letter-spacing"].wide,...fontFor(e,"medium")},gridRow:{flexDirection:"row",justifyContent:"center"},dayCell:{alignItems:"center",justifyContent:"center",padding:e.space.none},barLeft:{position:"absolute",left:0,right:"50%",top:"5%",bottom:"5%"},barRight:{position:"absolute",left:"50%",right:0,top:"5%",bottom:"5%"},rangeFill:{backgroundColor:e.colors["primary-soft"]},dayInner:{width:"90%",height:"90%",alignItems:"center",justifyContent:"center",borderRadius:e.radius.pill,...smoothCorners},dayEdge:{backgroundColor:e.colors.primary},dayMid:{borderRadius:e.radius.none},dayText:{fontSize:e.text.sm.size,...fontFor(e,"medium")},dots:{position:"absolute",bottom:e.space.xs,flexDirection:"row",gap:e.space.xxs},dot:{width:5,height:5,borderRadius:e.radius.pill,...smoothCorners}});
|
|
@@ -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{fontFor,Gradient,useTheme}from"../../theme/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{smoothCorners}from"../../utils/corners.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 BACKGROUND_TOKENS=["bg","bg-subtle","bg-muted","surface","scrim","surface-inverse","primary-wash"];export const DEFAULT_CARD_LABELS=Object.freeze({remove:"Remove",show:"Show",hide:"Hide",loading:"Loading"});const paddingMap={none:"none",sm:"sm",md:"lg",lg:"xl",xl:"2xl"},Card=React.memo(forwardRef((e,t)=>{const{children:i,variant:s,elevation:o="card",radius:a,padding:r,interactive:l=!1,pressAnimation:n="scale",bg:d,header:c,title:u,titleFont:m,lead:h,action:p,headerActions:g,collapsible:b=!1,collapsed:y,defaultCollapsed:x=!1,onCollapsedChange:f,collapsedSummary:S,onRemove:j,separatorHeight:v=StyleSheet.hairlineWidth,footer:C,imageSource:_,imageHeight:w=160,imageAspectRatio:R,imageOverlay:A,loading:V=!1,gradient:F,onPress:T,haptic:k,contextMenu:B,accessibilityLabel:L,accessibilityHint:I,accessibilityRole:H,style:P,containerStyle:z,headerStyle:M,bodyStyle:D,footerStyle:E,testID:q,labels:O,onLayout:W,...N}=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 G=useTheme(),U=G.settings.components.card,K=s??U?.defaultVariant??"elevated",$=a??U?.defaultRadius??"lg",J=r??U?.defaultPadding??"md",Q=m??U?.defaultTitleFont??"sans",X=useMemo(()=>({...DEFAULT_CARD_LABELS,...O}),[O]),Y=l||"function"==typeof T,Z=useContextMenu(B,{haptic:k||!1,testID:q,accessibilityActions:N.accessibilityActions,onAccessibilityAction:N.onAccessibilityAction}),ee=useMemo(()=>mergeRefs(t,Z.hostRef),[t,Z.hostRef]),te=Y||Z.enabled,{style:ie,pressIn:se,pressOut:oe}=usePressAnimation({preset:n||"scale",enabled:te&&!1!==n}),ae=stylesFor(G),re=Boolean(_),le=G.space[paddingMap[J]],ne=useMemo(()=>F?"string"==typeof F?G.settings.gradients[F]??null:F:null,[F,G.settings.gradients]),de="flat"===K,ce=de?G.radius.none:G.radius[$],ue=resolveBackground(G,d),[me,he]=useControllableState({value:y,defaultValue:x,onChange:f}),pe=b&&me,ge=hasBuiltInHeaderContent(e),be=Boolean(c)||ge,ye=useSquircle(!re&&!ne&&!de,ce,W),xe=StyleSheet.flatten([z,P])??{},fe=xe.backgroundColor,Se=xe.borderColor,je=fe??ue??("filled"===K?G.colors["bg-subtle"]:G.colors.surface),ve="outline"===K?G.size.border:0,Ce=Se??G.colors.border,we="none"===o?void 0:G.shadow[o],Re="elevated"===K&&supportsBoxShadow()&&we?toBoxShadow(we):void 0,Ae=ye.active&&"elevated"===K&&!Re,Ve=ye.active&&!Ae?{backgroundColor:"transparent",borderColor:"transparent"}:null,Fe=useMemo(()=>{const e={borderRadius:Ae&&ye.size?squircleHostRadius(ye.size.width,ye.size.height,ce):ce,...smoothCorners,padding:re||ye.active?G.space.none:le,overflow:ye.active?"visible":"hidden"};switch(K){case"flat":return{...e,backgroundColor:ue??G.colors.surface,borderBottomWidth:v,borderBottomColor:G.colors.border};case"outline":return{...e,backgroundColor:ye.active?"transparent":ue??G.colors.surface,borderWidth:G.size.border,borderColor:ye.active?"transparent":G.colors.border};case"filled":return{...e,backgroundColor:ye.active?"transparent":ue??G.colors["bg-subtle"]};default:return{...e,backgroundColor:ue??G.colors.surface,...Re?{boxShadow:Re}:we}}},[G,K,we,ce,re,le,ye.active,ye.size,Re,Ae,ue,v]),Te=useMemo(()=>({..."number"==typeof R?{width:"100%",aspectRatio:R}:{width:"100%",height:w},borderTopLeftRadius:ce,borderTopRightRadius:ce,borderBottomLeftRadius:G.radius.none,borderBottomRightRadius:G.radius.none,...smoothCorners}),[G,ce,R,w]),ke=u??"",Be=_jsxs(_Fragment,{children:[_jsxs(View,{style:ae.titleColumn,children:[u?_jsx(Text,{variant:"title",accessibilityRole:"header",style:titleFaceFor(G,Q),children:u}):null,h?_jsx(Text,{variant:"bodySmall",style:ae.lead,children:h}):null,pe&&S?_jsx(Text,{variant:"caption",style:ae.lead,children:S}):null]}),isCardTextAction(p)?_jsx(CardTextActionButton,{action:p,haptic:k}):p?_jsx(View,{style:ae.actionNode,children:p}):null,g,b?_jsx(CardIconAction,{icon:pe?"chevron-down":"chevron-up",label:`${pe?X.show:X.hide} ${ke}`.trim(),expanded:!pe,onPress:()=>he(!pe),haptic:k}):null,j?_jsx(CardIconAction,{icon:"trash",label:X.remove,onPress:j,color:G.colors["danger-text"],haptic:k}):null]}),Le=_jsxs(_Fragment,{children:[be?_jsx(View,{style:[ae.header,!c&&ae.headerRow,pe&&ae.headerFolded,M],children:c??Be}):null,pe?null:_jsx(View,{style:[be||C?ae.body:null,D],children:i}),C&&!pe?_jsx(View,{style:[ae.footer,E],children:C}):null]}),Ie=re?_jsxs(_Fragment,{children:[_jsxs(View,{style:ae.imageWrapper,children:[_jsx(Image,{source:_,resizeMode:"cover",style:Te,accessibilityLabel:"",accessible:!1}),A?_jsx(View,{pointerEvents:"box-none",style:ae.imageOverlay,children:A}):null]}),_jsx(View,{style:{padding:le},children:Le})]}):Le,He=ne?_jsxs(_Fragment,{children:[_jsx(Gradient,{gradient:ne,style:StyleSheet.absoluteFill}),Ie]}):ye.active&&ye.size?_jsxs(_Fragment,{children:[_jsx(SquircleFill,{width:ye.size.width,height:ye.size.height,radius:ce,fill:je,stroke:ve?Ce:void 0,strokeWidth:ve}),_jsx(View,{style:[ae.squircleClip,{padding:le,borderRadius:ye.size?squircleHostRadius(ye.size.width,ye.size.height,ce):ce}],children:Ie})]}):Ie;let Pe;if(te){const handlePress=e=>{Y&&(k&&triggerHaptic(k),T?.(e))};Pe=_jsx(Animated.View,{style:ie,children:_jsx(Pressable,{ref:ee,onPress:handlePress,onPressIn:se,onPressOut:oe,accessibilityRole:H??(Y?"button":void 0),accessibilityLabel:L,accessibilityHint:I,testID:q,onLayout:ye.onLayout,style:[Fe,z,P,Ve],...N,...Z.hostProps,children:He})})}else Pe=_jsx(View,{ref:t,accessibilityLabel:L,accessibilityHint:I,accessibilityRole:H,testID:q,onLayout:ye.onLayout,style:[Fe,z,P,Ve],...N,children:He});return V?_jsx(CardSkeleton,{...e}):Z.enabled?_jsxs(_Fragment,{children:[Pe,Z.renderSurface(_jsx(View,{style:[Fe,z,P,Ve,ae.preview],children:He}))]}):Pe}));Card.displayName="Card";const CardSkeleton=({variant:e,elevation:t,radius:i,padding:s,bg:o,header:a,footer:r,imageSource:l,imageHeight:n=160,imageAspectRatio:d,containerStyle:c,headerStyle:u,bodyStyle:m,footerStyle:h,style:p,labels:g,...b})=>{const y=useTheme(),x=y.settings.components.card,f=e??x?.defaultVariant??"elevated",S=i??x?.defaultRadius??"lg",j=s??x?.defaultPadding??"md",v={...DEFAULT_CARD_LABELS,...g},C=paddingMap[j],_=y.space[C],w="flat"===f?y.radius.none:y.radius[S],R=void 0!==a||hasBuiltInHeaderContent(b),A=resolveBackground(y,o)??y.colors.surface,V="outline"===f?1:0,F="outline"===f?y.colors.border:void 0;return _jsxs(View,{style:[{backgroundColor:A,borderRadius:w,...smoothCorners,borderWidth:V,borderColor:F,overflow:"hidden"},c,p],accessibilityRole:"progressbar",accessibilityLabel:v.loading,accessibilityState:{busy:!0},"aria-busy":!0,children:[void 0!==l?_jsx(Skeleton,{width:"100%",height:d?void 0:n,style:d?{aspectRatio:d,width:"100%"}:void 0}):null,R?_jsx(View,{style:[{padding:_,paddingBottom:y.space.sm},u],children:_jsx(Skeleton,{shape:"text",width:"60%",height:18})}):null,_jsx(View,{style:[{padding:_},m],children:_jsx(SkeletonText,{lines:3,fontSize:y.text.base.size,lastLineWidth:"55%"})}),void 0!==r?_jsx(View,{style:[{padding:_,paddingTop:y.space.sm,flexDirection:"row"},h],children:_jsx(Skeleton,{width:88,height:32,shape:"rounded"})}):null]})};CardSkeleton.displayName="CardSkeleton",Card.Skeleton=CardSkeleton;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:a})=>{const r=useTheme();return _jsx(Pressable,{accessibilityRole:"button",accessibilityLabel:t,accessibilityState:void 0===s?void 0:{expanded:s},"aria-expanded":s,onPress:()=>{a&&triggerHaptic(a),i()},style:iconActionStyle,children:_jsx(View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:_jsx(AppIcon,{name:e,size:20,color:o??r.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 BACKGROUND_TOKENS.includes(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:{flexGrow:1,overflow:"hidden",...smoothCorners},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,{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{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 BACKGROUND_TOKENS=["bg","bg-subtle","bg-muted","surface","scrim","surface-inverse","primary-wash"];export const DEFAULT_CARD_LABELS=Object.freeze({remove:"Remove",show:"Show",hide:"Hide",loading:"Loading"});const paddingMap={none:"none",sm:"sm",md:"lg",lg:"xl",xl:"2xl"},CardRoot=React.memo(forwardRef((e,t)=>{const{children:i,variant:o,elevation:s="card",radius:r,padding:a,interactive:l=!1,pressAnimation:n="scale",bg:d,header:c,title:u,titleFont:m,lead:h,action:p,headerActions:g,collapsible:b=!1,collapsed:y,defaultCollapsed:f=!1,onCollapsedChange:x,collapsedSummary:S,onRemove:j,separatorHeight:C=StyleSheet.hairlineWidth,footer:v,imageSource:_,imageHeight:w=160,imageAspectRatio:R,imageOverlay:A,loading:V=!1,gradient:F,onPress:k,haptic:T,contextMenu:B,accessibilityLabel:L,accessibilityHint:I,accessibilityRole:H,style:P,containerStyle:z,headerStyle:M,bodyStyle:O,footerStyle:D,testID:E,labels:q,onLayout:W,...N}=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 G=useTheme(),U=G.settings.components.card,K=o??U?.defaultVariant??"elevated",$=r??U?.defaultRadius??"lg",J=a??U?.defaultPadding??"md",Q=m??U?.defaultTitleFont??"sans",X=useMemo(()=>({...DEFAULT_CARD_LABELS,...q}),[q]),Y=l||"function"==typeof k,Z=useContextMenu(B,{haptic:T||!1,testID:E,accessibilityActions:N.accessibilityActions,onAccessibilityAction:N.onAccessibilityAction}),ee=useMemo(()=>mergeRefs(t,Z.hostRef),[t,Z.hostRef]),te=Y||Z.enabled,{style:ie,pressIn:oe,pressOut:se}=usePressAnimation({preset:n||"scale",enabled:te&&!1!==n}),re=stylesFor(G),ae=Boolean(_),le=G.space[paddingMap[J]],ne=useMemo(()=>F?"string"==typeof F?G.settings.gradients[F]??null:F:null,[F,G.settings.gradients]),de="flat"===K,ce=de?G.radius.none:G.radius[$],ue=resolveBackground(G,d),[me,he]=useControllableState({value:y,defaultValue:f,onChange:x}),pe=b&&me,ge=hasBuiltInHeaderContent(e),be=Boolean(c)||ge,ye=useSquircle(!ae&&!ne&&!de,ce,W),fe=StyleSheet.flatten([z,P])??{},xe="string"==typeof fe.backgroundColor?fe.backgroundColor:void 0,Se="string"==typeof fe.borderColor?fe.borderColor:void 0,je=xe??ue??("filled"===K?G.colors["bg-subtle"]:G.colors.surface),Ce="outline"===K?G.size.border:0,ve=Se??G.colors.border,we="none"===s?void 0:G.shadow[s],Re="elevated"===K&&supportsBoxShadow()&&we?toBoxShadow(we):void 0,Ae=ye.active&&"elevated"===K&&!Re,Ve=ye.active&&!Ae?{backgroundColor:"transparent",borderColor:"transparent"}:null,Fe=useMemo(()=>{const e={borderRadius:Ae&&ye.size?squircleHostRadius(ye.size.width,ye.size.height,ce):ce,...smoothCorners,padding:ae||ye.active?G.space.none:le,overflow:ye.active?"visible":"hidden"};switch(K){case"flat":return{...e,backgroundColor:ue??G.colors.surface,borderBottomWidth:C,borderBottomColor:G.colors.border};case"outline":return{...e,backgroundColor:ye.active?"transparent":ue??G.colors.surface,borderWidth:G.size.border,borderColor:ye.active?"transparent":G.colors.border};case"filled":return{...e,backgroundColor:ye.active?"transparent":ue??G.colors["bg-subtle"]};default:return{...e,backgroundColor:ue??G.colors.surface,...Re?{boxShadow:Re}:we}}},[G,K,we,ce,ae,le,ye.active,ye.size,Re,Ae,ue,C]),ke=useMemo(()=>({..."number"==typeof R?{width:"100%",aspectRatio:R}:{width:"100%",height:w},borderTopLeftRadius:ce,borderTopRightRadius:ce,borderBottomLeftRadius:G.radius.none,borderBottomRightRadius:G.radius.none,...smoothCorners}),[G,ce,R,w]),Te=u??"",Be=_jsxs(_Fragment,{children:[_jsxs(View,{style:re.titleColumn,children:[u?_jsx(Text,{variant:"title",accessibilityRole:"header",style:titleFaceFor(G,Q),children:u}):null,h?_jsx(Text,{variant:"bodySmall",style:re.lead,children:h}):null,pe&&S?_jsx(Text,{variant:"caption",style:re.lead,children:S}):null]}),isCardTextAction(p)?_jsx(CardTextActionButton,{action:p,haptic:T}):p?_jsx(View,{style:re.actionNode,children:p}):null,g,b?_jsx(CardIconAction,{icon:pe?"chevron-down":"chevron-up",label:`${pe?X.show:X.hide} ${Te}`.trim(),expanded:!pe,onPress:()=>he(!pe),haptic:T}):null,j?_jsx(CardIconAction,{icon:"trash",label:X.remove,onPress:j,color:G.colors["danger-text"],haptic:T}):null]}),Le=_jsxs(_Fragment,{children:[be?_jsx(View,{style:[re.header,!c&&re.headerRow,pe&&re.headerFolded,M],children:c??Be}):null,pe?null:_jsx(View,{style:[be||v?re.body:null,O],children:i}),v&&!pe?_jsx(View,{style:[re.footer,D],children:v}):null]}),Ie=_?_jsxs(_Fragment,{children:[_jsxs(View,{style:re.imageWrapper,children:[_jsx(Image,{source:_,resizeMode:"cover",style:ke,accessibilityLabel:"",accessible:!1}),A?_jsx(View,{pointerEvents:"box-none",style:re.imageOverlay,children:A}):null]}),_jsx(View,{style:{padding:le},children:Le})]}):Le,He=ne?_jsxs(_Fragment,{children:[_jsx(Gradient,{gradient:ne,style:StyleSheet.absoluteFill}),Ie]}):ye.active&&ye.size?_jsxs(_Fragment,{children:[_jsx(SquircleFill,{width:ye.size.width,height:ye.size.height,radius:ce,fill:je,stroke:Ce?ve:void 0,strokeWidth:Ce}),_jsx(View,{style:[re.squircleClip,{padding:le,borderRadius:ye.size?squircleHostRadius(ye.size.width,ye.size.height,ce):ce}],children:Ie})]}):Ie;let Pe;if(te){const handlePress=e=>{Y&&(T&&triggerHaptic(T),k?.(e))};Pe=_jsx(Animated.View,{style:ie,children:_jsx(Pressable,{ref:ee,onPress:handlePress,onPressIn:oe,onPressOut:se,accessibilityRole:H??(Y?"button":void 0),accessibilityLabel:L,accessibilityHint:I,testID:E,onLayout:ye.onLayout,style:[Fe,z,P,Ve],...N,...Z.hostProps,children:He})})}else Pe=_jsx(View,{ref:t,accessibilityLabel:L,accessibilityHint:I,accessibilityRole:H,testID:E,onLayout:ye.onLayout,style:[Fe,z,P,Ve],...N,children:He});return V?_jsx(CardSkeleton,{...e}):Z.enabled?_jsxs(_Fragment,{children:[Pe,Z.renderSurface(_jsx(View,{style:[Fe,z,P,Ve,re.preview],children:He}))]}):Pe})),CardSkeleton=({variant:e,elevation:t,radius:i,padding:o,bg:s,header:r,footer:a,imageSource:l,imageHeight:n=160,imageAspectRatio:d,containerStyle:c,headerStyle:u,bodyStyle:m,footerStyle:h,style:p,labels:g,...b})=>{const y=useTheme(),f=y.settings.components.card,x=e??f?.defaultVariant??"elevated",S=i??f?.defaultRadius??"lg",j=o??f?.defaultPadding??"md",C={...DEFAULT_CARD_LABELS,...g},v=paddingMap[j],_=y.space[v],w="flat"===x?y.radius.none:y.radius[S],R=void 0!==r||hasBuiltInHeaderContent(b),A=resolveBackground(y,s)??y.colors.surface,V="outline"===x?1:0,F="outline"===x?y.colors.border:void 0;return _jsxs(View,{style:[{backgroundColor:A,borderRadius:w,...smoothCorners,borderWidth:V,borderColor:F,overflow:"hidden"},c,p],accessibilityRole:"progressbar",accessibilityLabel:C.loading,accessibilityState:{busy:!0},"aria-busy":!0,children:[void 0!==l?_jsx(Skeleton,{width:"100%",height:d?void 0:n,style:d?{aspectRatio:d,width:"100%"}:void 0}):null,R?_jsx(View,{style:[{padding:_,paddingBottom:y.space.sm},u],children:_jsx(Skeleton,{shape:"text",width:"60%",height:18})}):null,_jsx(View,{style:[{padding:_},m],children:_jsx(SkeletonText,{lines:3,fontSize:y.text.base.size,lastLineWidth:"55%"})}),void 0!==a?_jsx(View,{style:[{padding:_,paddingTop:y.space.sm,flexDirection:"row"},h],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:o,color:s,haptic:r})=>{const a=useTheme();return _jsx(Pressable,{accessibilityRole:"button",accessibilityLabel:t,accessibilityState:void 0===o?void 0:{expanded:o},"aria-expanded":o,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:s??a.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:{flexGrow:1,overflow:"hidden",...smoothCorners},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 +1 @@
|
|
|
1
|
-
"use strict";import{
|
|
1
|
+
"use strict";import{useCallback,useEffect,useImperativeHandle,useMemo,useRef,useState}from"react";import{Animated,AppState,Dimensions,FlatList,Image,Pressable,ScrollView,StyleSheet,View}from"react-native";import{createAnimatedValue,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{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";export const DEFAULT_CAROUSEL_LABELS=Object.freeze({carousel:"Carousel",slideOf:(e,t)=>`Slide ${e} of ${t}`,goToSlide:e=>`Go to slide ${e}`});function CarouselRoot({ref:e,...t}){const{data:n,renderItem:r,keyExtractor:i,index:s,defaultIndex:a=0,onIndexChange:l,onScrollOffsetChange:o,autoPlay:c=!1,autoPlayInterval:u=4e3,loop:d=!1,showPagination:m=!0,paginationStyle:h="dots",itemWidth:g="screen",spacing:b=0,containerStyle:p,accessibilityLabel:f,testID:y,showThumbnails:x=!1,haptic:S,renderThumbnail:v,loading:w=!1,labels:C}=t;assertValidValue("Carousel","paginationStyle",t.paginationStyle,["dots","bars","numbers"]);const T=useMemo(()=>({...DEFAULT_CAROUSEL_LABELS,...C}),[C]),j=useTheme(),I=d||c,[k,_]=useState(()=>Dimensions.get("window").width),A="screen"===g?k:g,E=A+b,R=useRef(null),V=useRef(createAnimatedValue(0)).current,L=clamp("number"==typeof s?s:a,0,Math.max(0,n.length-1)),[D,O]=useState(L),H=useRef(null),M=useRef(null),P=useRef(!1),z=useRef(D);z.current=D;const N=useCallback(e=>{const t=clamp(e,0,Math.max(0,n.length-1));O(e=>e===t?e:(l?.(t),t))},[n.length,l]),W=useCallback((e,t=!0)=>{if(0===n.length)return;const r=clamp(e,0,n.length-1);R.current?.scrollToOffset({offset:r*E,animated:t}),N(r)},[n.length,E,N]),F=useCallback(()=>{if(0===n.length)return;const e=z.current+1;e>=n.length?I&&W(0,!1):W(e,!0)},[n.length,I,W]),$=useCallback(()=>{if(0===n.length)return;const e=z.current-1;e<0?I&&W(n.length-1,!1):W(e,!0)},[n.length,I,W]);useImperativeHandle(e,()=>({scrollTo:W,next:F,prev:$}),[W,F,$]),useEffect(()=>{"number"==typeof s&&s!==D&&W(s,!0)},[s]);const U=useCallback(()=>{H.current&&(clearInterval(H.current),H.current=null)},[]),B=useCallback(()=>{!c||n.length<=1||(U(),H.current=setInterval(()=>{if(P.current)return;const e=z.current+1;e>=n.length?W(0,!1):W(e,!0)},u))},[c,u,n.length,W,U]);useEffect(()=>(B(),()=>{U(),M.current&&clearTimeout(M.current)}),[B,U]),useEffect(()=>{const e=AppState.addEventListener("change",e=>{"active"!==e?(U(),M.current&&(clearTimeout(M.current),M.current=null)):B()});return()=>e.remove()},[B,U]);const G=m&&n.length>1&&"numbers"!==h||void 0!==o,K=useMemo(()=>Animated.event([{nativeEvent:{contentOffset:{x:V}}}],{useNativeDriver:!1,listener:o?e=>o(e.nativeEvent.contentOffset.x):void 0}),[V,o]),X=useCallback(e=>{if(E<=0)return;const t=e.nativeEvent.contentOffset.x,n=Math.round(t/E);N(n)},[E,N]),q=useCallback(()=>{P.current=!0,U(),M.current&&(clearTimeout(M.current),M.current=null)},[U]),J=useCallback(()=>{P.current=!1,c&&(M.current&&clearTimeout(M.current),M.current=setTimeout(()=>{B()},1e3))},[c,B]),Q=useCallback(e=>{switch(e.nativeEvent.actionName){case"increment":F();break;case"decrement":$()}},[F,$]),Y=useMemo(()=>buildStyles(j),[j]),Z=useCallback(({item:e,index:t})=>_jsx(View,{style:{width:A,marginRight:t===n.length-1?0:b},accessibilityElementsHidden:t!==D,importantForAccessibility:t===D?"yes":"no-hide-descendants",children:r(e,t)}),[r,A,b,n.length,D]),ee=useCallback((e,t)=>String(t),[]),te=useCallback((e,t)=>({length:E,offset:E*t,index:t}),[E]);return w?_jsx(CarouselSkeleton,{...t,containerWidth:k}):_jsxs(View,{style:[Y.container,p],onLayout:e=>_(e.nativeEvent.layout.width),accessibilityRole:"adjustable",accessibilityLabel:f??T.carousel,accessibilityValue:{min:0,max:Math.max(0,n.length-1),now:D,text:T.slideOf(D+1,n.length)},accessibilityActions:[{name:"increment"},{name:"decrement"}],onAccessibilityAction:Q,testID:y,children:[_jsx(FlatList,{ref:R,data:n,keyExtractor:i??ee,renderItem:Z,horizontal:!0,pagingEnabled:"screen"===g&&0===b,snapToInterval:E,snapToAlignment:"start",decelerationRate:"fast",showsHorizontalScrollIndicator:!1,onScroll:G?K:void 0,scrollEventThrottle:G?16:void 0,onMomentumScrollEnd:X,onScrollBeginDrag:q,onScrollEndDrag:J,getItemLayout:te,initialScrollIndex:L,bounces:!1}),m&&n.length>1?_jsx(Pagination,{count:n.length,currentIndex:D,scrollX:V,slideStride:E,variant:h,theme:j,labels:T}):null,x&&n.length>0?_jsx(ThumbnailStrip,{data:n,currentIndex:D,renderThumbnail:v,labels:T,onSelect:e=>{const t=resolveHaptic(S,"selection");t&&triggerHaptic(t),W(e,!0)},theme:j}):null]})}CarouselRoot.displayName="Carousel";const CarouselSkeleton=({itemWidth:e="screen",showPagination:t=!0,paginationStyle:n="dots",containerStyle:r,containerWidth:i})=>{const s=useTheme(),a="screen"===e?i||320:e;return _jsxs(View,{style:[carouselSkeletonStyles.container,r],children:[_jsx(Skeleton,{width:a,height:160,radius:"md"}),t?_jsx(View,{style:[carouselSkeletonStyles.paginationRow,{marginTop:s.space.md}],children:SKELETON_PAGINATION_DOTS.map(e=>_jsx(Skeleton,"numbers"===n?{width:24,height:16,radius:"sm",style:{marginHorizontal:s.space.xs}}:"bars"===n?{width:20,height:4,radius:"pill",style:{marginHorizontal:s.space.xxs}}:{shape:"circle",width:8,height:8,style:{marginHorizontal:s.space.xs}},e))}):null]})};CarouselSkeleton.displayName="CarouselSkeleton";const SKELETON_PAGINATION_DOTS=["first","second","third"],carouselSkeletonStyles=StyleSheet.create({container:{alignItems:"center"},paginationRow:{flexDirection:"row",justifyContent:"center"}}),Carousel=Object.assign(CarouselRoot,{Skeleton:CarouselSkeleton}),Pagination=({count:e,currentIndex:t,scrollX:n,slideStride:r,variant:i,theme:s,labels:a})=>{const l=useMemo(()=>buildPaginationStyles(s),[s]);if("numbers"===i)return _jsx(View,{style:l.numbersWrap,children:_jsx(Text,{variant:"bodySmall",weight:"medium",color:"secondary",style:l.numbersText,accessibilityLabel:a.slideOf(t+1,e),children:`${t+1} / ${e}`})});const o=Array.from({length:e},(e,t)=>t),c="bars"===i,u=c?24:6,d=c?36:16,m=c?3:6;return _jsx(View,{style:l.dotRow,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:o.map(e=>{const i=[(e-1)*r,e*r,(e+1)*r],a=n.interpolate({inputRange:i,outputRange:[u,d,u],extrapolate:"clamp"}),l=n.interpolate({inputRange:i,outputRange:[.5,1,.5],extrapolate:"clamp"});return _jsx(Animated.View,{style:[{width:a,height:m,marginHorizontal:s.space.xs,borderRadius:s.radius.pill,...smoothCorners,backgroundColor:e===t?s.colors.primary:s.colors.border,opacity:l}]},e)})})};function ThumbnailStrip({data:e,currentIndex:t,renderThumbnail:n,onSelect:r,theme:i,labels:s}){const a=useMemo(()=>buildThumbStyles(i),[i]);return _jsx(ScrollView,{horizontal:!0,showsHorizontalScrollIndicator:!1,contentContainerStyle:a.row,accessibilityRole:"tablist",children:e.map((e,l)=>_jsx(ThumbnailItem,{item:e,index:l,isActive:l===t,renderThumbnail:n,onPress:()=>r(l),theme:i,styles:a,labels:s},l))})}function ThumbnailItem({item:e,index:t,isActive:n,renderThumbnail:r,onPress:i,theme:s,styles:a,labels:l}){const o=useRef(createAnimatedValue(n?1.1:1)).current;useEffect(()=>{const e=Animated.spring(o,{toValue:n?1.1:1,useNativeDriver:nativeDriver,friction:6,tension:80});return e.start(),()=>e.stop()},[n,o]);const c=useMemo(()=>r?r(e,t):e&&"object"==typeof e&&"uri"in e&&"string"==typeof e.uri?_jsx(Image,{source:{uri:e.uri},style:a.image,resizeMode:"cover"}):_jsx(View,{style:[a.placeholder,{backgroundColor:s.colors["bg-subtle"]}],children:_jsx(Text,{variant:"caption",weight:"semibold",color:"secondary",children:t+1})}),[e,t,r,s,a]);return _jsx(Pressable,{onPress:i,accessibilityRole:"tab",accessibilityState:{selected:n},"aria-selected":n,accessibilityLabel:l.goToSlide(t+1),children:_jsx(Animated.View,{style:[a.thumb,{borderColor:n?s.colors.primary:"transparent",transform:[{scale:o}]}],children:c})})}const buildThumbStyles=e=>StyleSheet.create({row:{flexDirection:"row",alignItems:"center",paddingHorizontal:e.space.sm,paddingVertical:e.space.sm},thumb:{width:40,height:40,marginHorizontal:e.space.xs,borderRadius:e.radius.sm,...smoothCorners,borderWidth:2,overflow:"hidden"},image:{width:"100%",height:"100%"},placeholder:{flex:1,alignItems:"center",justifyContent:"center"}}),clamp=(e,t,n)=>Math.min(Math.max(e,t),n),buildStyles=e=>StyleSheet.create({container:{width:"100%"}}),buildPaginationStyles=e=>StyleSheet.create({dotRow:{flexDirection:"row",alignItems:"center",justifyContent:"center",paddingVertical:e.space.md},numbersWrap:{alignItems:"center",justifyContent:"center",paddingVertical:e.space.md},numbersText:{textAlign:"center"}});export{Carousel};export default Carousel;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{forwardRef,useMemo}from"react";import{Animated,Pressable,StyleSheet,View}from"react-native";import{usePressAnimation}from"../../hooks/usePressAnimation.js";import{resolveChipSize,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{renderSlotIcon}from"../AppIcon/slotIcon.js";import{Skeleton}from"../Skeleton/index.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_CHIP_LABELS=Object.freeze({remove:e=>`Remove ${e}`});const toneFor=(e,s)=>{switch(s){case"primary":return{base:e.colors["primary-soft"],on:e.colors.primary,ink:e.colors["primary-text"],border:e.colors.primary,selectedBg:e.colors["primary-soft"],selectedOn:e.colors.primary,selectedInk:e.colors["primary-text"],selectedBorder:e.colors.primary};case"success":return{base:e.colors["bg-muted"],on:e.colors.success,ink:e.colors["success-text"],border:e.colors.success,selectedBg:e.colors["primary-soft"],selectedOn:e.colors.primary,selectedInk:e.colors["primary-text"],selectedBorder:e.colors.primary};case"warning":return{base:e.colors["bg-muted"],on:e.colors.warning,ink:e.colors["warning-text"],border:e.colors.warning,selectedBg:e.colors["primary-soft"],selectedOn:e.colors.primary,selectedInk:e.colors["primary-text"],selectedBorder:e.colors.primary};case"danger":return{base:e.colors["bg-muted"],on:e.colors.danger,ink:e.colors["danger-text"],border:e.colors.danger,selectedBg:e.colors["primary-soft"],selectedOn:e.colors.primary,selectedInk:e.colors["primary-text"],selectedBorder:e.colors.primary};case"info":return{base:e.colors["bg-muted"],on:e.colors.info,ink:e.colors["info-text"],border:e.colors.info,selectedBg:e.colors["primary-soft"],selectedOn:e.colors.primary,selectedInk:e.colors["primary-text"],selectedBorder:e.colors.primary};default:return{base:e.colors["bg-muted"],on:e.colors["text-body"],ink:e.colors["text-body"],border:e.colors.border,selectedBg:e.colors["primary-soft"],selectedOn:e.colors.primary,selectedInk:e.colors["primary-text"],selectedBorder:e.colors.primary}}},SOFT_FILL_OPACITY=.14,SOFT_SELECTED_FILL_OPACITY=.24,hasChipCount=e=>null!=e&&""!==e,
|
|
1
|
+
"use strict";import{forwardRef,useMemo}from"react";import{Animated,Pressable,StyleSheet,View}from"react-native";import{usePressAnimation}from"../../hooks/usePressAnimation.js";import{resolveChipSize,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{renderSlotIcon}from"../AppIcon/slotIcon.js";import{Skeleton}from"../Skeleton/index.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_CHIP_LABELS=Object.freeze({remove:e=>`Remove ${e}`});const toneFor=(e,s)=>{switch(s){case"primary":return{base:e.colors["primary-soft"],on:e.colors.primary,ink:e.colors["primary-text"],border:e.colors.primary,selectedBg:e.colors["primary-soft"],selectedOn:e.colors.primary,selectedInk:e.colors["primary-text"],selectedBorder:e.colors.primary};case"success":return{base:e.colors["bg-muted"],on:e.colors.success,ink:e.colors["success-text"],border:e.colors.success,selectedBg:e.colors["primary-soft"],selectedOn:e.colors.primary,selectedInk:e.colors["primary-text"],selectedBorder:e.colors.primary};case"warning":return{base:e.colors["bg-muted"],on:e.colors.warning,ink:e.colors["warning-text"],border:e.colors.warning,selectedBg:e.colors["primary-soft"],selectedOn:e.colors.primary,selectedInk:e.colors["primary-text"],selectedBorder:e.colors.primary};case"danger":return{base:e.colors["bg-muted"],on:e.colors.danger,ink:e.colors["danger-text"],border:e.colors.danger,selectedBg:e.colors["primary-soft"],selectedOn:e.colors.primary,selectedInk:e.colors["primary-text"],selectedBorder:e.colors.primary};case"info":return{base:e.colors["bg-muted"],on:e.colors.info,ink:e.colors["info-text"],border:e.colors.info,selectedBg:e.colors["primary-soft"],selectedOn:e.colors.primary,selectedInk:e.colors["primary-text"],selectedBorder:e.colors.primary};default:return{base:e.colors["bg-muted"],on:e.colors["text-body"],ink:e.colors["text-body"],border:e.colors.border,selectedBg:e.colors["primary-soft"],selectedOn:e.colors.primary,selectedInk:e.colors["primary-text"],selectedBorder:e.colors.primary}}},SOFT_FILL_OPACITY=.14,SOFT_SELECTED_FILL_OPACITY=.24,hasChipCount=e=>null!=e&&""!==e,ChipRoot=forwardRef((e,s)=>{const{label:t,count:r,selected:o=!1,selectionMode:i="single",onPress:l,onRemove:a,leftIcon:n,iconVariant:c,variant:d="soft",tone:p="neutral",size:m="md",disabled:u=!1,loading:h=!1,accessibilityLabel:b,haptic:y,style:g,textStyle:f,containerStyle:x,countStyle:S,closeButtonStyle:C,closeIconStyle:k,labels:j,removeTestID:I,testID:v}=e;assertValidValue("Chip","variant",e.variant,["solid","soft","outline"]),assertValidValue("Chip","tone",e.tone,["primary","neutral","success","warning","danger","info"]),assertValidValue("Chip","size",e.size,["sm","md"]),assertValidValue("Chip","selectionMode",e.selectionMode,["single","multiple","radio"]);const w=useTheme(),_=useMemo(()=>({...DEFAULT_CHIP_LABELS,...j}),[j]),z=!!l&&!u,L="radio"===i,V=!!l&&(!u||L),O=hasChipCount(r),{style:B,pressIn:M,pressOut:T}=usePressAnimation({enabled:z}),P=useMemo(()=>toneFor(w,p),[w,p]),A=useMemo(()=>resolveChipSize(w,m),[w,m]),R=Math.max(0,Math.ceil((44-A["min-height"])/2)),H=L?{top:R,bottom:R}:void 0,D="solid"===d,F="soft"===d,E=(()=>{if(F){const e=o?P.selectedOn:P.on;return tintOf(e,o?.24:.14,o?P.selectedBg:P.base)}return o?D?P.selectedBg:"transparent":D?P.base:"transparent"})(),U=F?"transparent":o?P.selectedBorder:D?"transparent":P.border,$=u?w.colors["text-disabled"]:o?F?w.colors["text-body"]:P.selectedInk:P.ink,N=D||F?0:w.size.border,handlePress=()=>{if(!z)return;const e=resolveHaptic(y,"selection");e&&triggerHaptic(e),l?.()},Y=b??(O?`${t}, ${r}`:t),W=_jsxs(View,{style:styles.row,children:[n?_jsx(View,{style:{marginRight:A.gap},accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:renderSlotIcon(n,{color:$,size:A.icon,disabled:u},c)}):null,_jsx(Text,{variant:"label",weight:"medium",numberOfLines:1,style:[styles.label,{color:$,fontSize:A.text,lineHeight:Math.round(A.text*w.leading.body)},f],children:t??" "}),O?_jsx(Text,{variant:"caption",numberOfLines:1,style:[styles.count,{color:$,fontSize:Math.min(w.text.xs.size,A.text),marginLeft:w.space.xs},S],children:r}):null,a?_jsx(Pressable,{onPress:()=>{u||(!1!==y&&triggerHaptic("impactLight"),a?.())},disabled:u,accessibilityRole:"button",accessibilityLabel:_.remove(t),accessibilityState:{disabled:u},"aria-disabled":u,testID:I,hitSlop:6,...hitSlopMarker(6),style:({pressed:e})=>[styles.close,{width:A["close-size"],height:A["close-size"],borderRadius:A["close-size"]/2,...smoothCorners,marginLeft:A.gap,backgroundColor:e?w.colors["surface-pressed"]:w.colors["surface-hover"]},C],children:_jsx(Text,{variant:"label",weight:"bold",maxFontSizeMultiplier:1,style:[{color:$,fontSize:A["close-text"],lineHeight:A["close-text"]+2},k],children:"×"})}):null]}),q={paddingHorizontal:A["padding-x"],paddingVertical:A["padding-y"],minHeight:A["min-height"],borderRadius:w.radius.pill,...smoothCorners,overflow:"hidden",backgroundColor:E,borderWidth:N,borderColor:U,opacity:u?.55:1};let G;return G=V?_jsx(Animated.View,{style:[B,{alignSelf:"flex-start",borderRadius:w.radius.pill,...smoothCorners,overflow:"hidden"}],children:_jsx(Pressable,{ref:s,onPress:handlePress,onPressIn:M,onPressOut:T,disabled:!z,accessibilityRole:L?"radio":"multiple"===i?"checkbox":"button",accessibilityLabel:Y,accessibilityState:L||"multiple"===i?{checked:o,disabled:u}:{selected:o,disabled:u},"aria-checked":L||"multiple"===i?o:void 0,"aria-selected":L||"multiple"===i?void 0:o,"aria-disabled":u,hitSlop:H,...H?hitSlopMarker(H):{},android_ripple:{color:w.colors["surface-pressed"],borderless:!1},testID:v,style:({pressed:e})=>[styles.base,q,e&&"outline"===d?{backgroundColor:w.colors["surface-pressed"]}:null,x,g],children:W})}):_jsx(View,{ref:s,style:[styles.base,q,x,g],accessible:!0,accessibilityRole:"text",accessibilityLabel:Y,accessibilityState:{selected:o,disabled:u},"aria-selected":o,"aria-disabled":u,testID:v,children:W}),h?_jsx(ChipSkeleton,{...e}):G}),ChipSkeleton=({label:e,count:s,size:t="md",leftIcon:r,onRemove:o,style:i,containerStyle:l})=>{const a=useTheme(),n=resolveChipSize(a,t),c=Math.max(40,Math.min(120,7*(e??"").length)),d=n["min-height"],p=d/2,m=c+2*n["padding-x"]+(hasChipCount(s)?n.gap/2+7*String(s).length:0)+(void 0!==r?n.gap+14:0)+(void 0!==o?n.gap+n["close-size"]:0);return _jsx(Skeleton,{width:m,height:d,radius:p,style:[{alignSelf:"flex-start"},l,i]})};ChipSkeleton.displayName="ChipSkeleton";const Chip=Object.assign(ChipRoot,{Skeleton:ChipSkeleton});Chip.displayName="Chip";const styles=StyleSheet.create({base:{alignSelf:"flex-start",flexDirection:"row",alignItems:"center",justifyContent:"center"},row:{flexDirection:"row",alignItems:"center"},label:{flexShrink:1,textAlign:"center"},count:{flexShrink:0,fontVariant:["tabular-nums"]},close:{alignItems:"center",justifyContent:"center"}});export{Chip};export default Chip;
|