@webority/mobile-ui 0.148.0 → 0.150.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.
Files changed (485) hide show
  1. package/dist/canvas-kit/kit.js +13 -56553
  2. package/dist/canvas-kit/manifest.json +20 -41
  3. package/dist/canvas-kit/release.json +6 -6
  4. package/lib/commonjs/components/Accordion/Accordion.js +1 -1
  5. package/lib/commonjs/components/AppIcon/AppIcon.js +1 -1
  6. package/lib/commonjs/components/AppIcon/glyphs.g.js +1 -1
  7. package/lib/commonjs/components/AsyncBlock/AsyncBlock.js +1 -1
  8. package/lib/commonjs/components/AuthedImage/AuthedImage.js +1 -1
  9. package/lib/commonjs/components/AuthedImage/authedImageCache.js +1 -1
  10. package/lib/commonjs/components/Avatar/Avatar.js +1 -1
  11. package/lib/commonjs/components/Badge/Badge.js +1 -1
  12. package/lib/commonjs/components/Banner/Banner.js +1 -1
  13. package/lib/commonjs/components/BarChart/BarChart.js +1 -1
  14. package/lib/commonjs/components/BottomNavigation/BottomNavigation.js +1 -1
  15. package/lib/commonjs/components/BottomSheet/BottomSheet.js +1 -1
  16. package/lib/commonjs/components/Box/Box.js +1 -1
  17. package/lib/commonjs/components/Card/Card.js +1 -1
  18. package/lib/commonjs/components/Carousel/Carousel.js +1 -1
  19. package/lib/commonjs/components/Chip/Chip.js +1 -1
  20. package/lib/commonjs/components/ChoiceGroup/ChoiceGroup.js +1 -1
  21. package/lib/commonjs/components/Confetti/Confetti.js +1 -1
  22. package/lib/commonjs/components/DatePicker/DatePicker.js +1 -1
  23. package/lib/commonjs/components/DateRangePicker/DateRangePicker.js +1 -1
  24. package/lib/commonjs/components/Descriptions/Descriptions.js +1 -1
  25. package/lib/commonjs/components/Dialog/Dialog.js +1 -1
  26. package/lib/commonjs/components/Drawer/Drawer.js +1 -1
  27. package/lib/commonjs/components/FieldBase/useFloatingLabel.js +1 -1
  28. package/lib/commonjs/components/FileViewer/fileSource.js +1 -1
  29. package/lib/commonjs/components/FileViewer/useFileViewerZoom.js +1 -1
  30. package/lib/commonjs/components/FloatingActionButton/FloatingActionButton.js +1 -1
  31. package/lib/commonjs/components/ImageGallery/ImageGallery.js +1 -1
  32. package/lib/commonjs/components/InlineSelect/InlineSelect.js +1 -1
  33. package/lib/commonjs/components/Input/Input.js +1 -1
  34. package/lib/commonjs/components/ListItem/ListItem.js +1 -1
  35. package/lib/commonjs/components/Markdown/Markdown.js +1 -1
  36. package/lib/commonjs/components/Menu/MenuSurface.js +1 -1
  37. package/lib/commonjs/components/Menu/focusHost.js +1 -1
  38. package/lib/commonjs/components/OptionSheet/OptionSheet.js +1 -1
  39. package/lib/commonjs/components/OptionSheet/optionAccessors.js +1 -0
  40. package/lib/commonjs/components/PhoneNumberInput/PhoneNumberInput.js +1 -1
  41. package/lib/commonjs/components/ProgressRing/ProgressRing.js +1 -1
  42. package/lib/commonjs/components/Radio/RadioGroup.js +1 -1
  43. package/lib/commonjs/components/Rating/Rating.js +1 -1
  44. package/lib/commonjs/components/Repeater/Repeater.js +1 -1
  45. package/lib/commonjs/components/Screen/Screen.js +1 -1
  46. package/lib/commonjs/components/SearchBar/useRecentSearches.js +1 -1
  47. package/lib/commonjs/components/SegmentedControl/SegmentedControl.js +1 -1
  48. package/lib/commonjs/components/Select/Select.js +1 -1
  49. package/lib/commonjs/components/SignaturePad/SignaturePad.js +1 -1
  50. package/lib/commonjs/components/Skeleton/SkeletonContent.js +1 -1
  51. package/lib/commonjs/components/Skeleton/SkeletonList.js +1 -1
  52. package/lib/commonjs/components/SlideToConfirm/SlideToConfirm.js +1 -1
  53. package/lib/commonjs/components/Slider/Slider.js +1 -1
  54. package/lib/commonjs/components/SliderField/SliderField.js +1 -1
  55. package/lib/commonjs/components/SortableList/SortableList.js +1 -1
  56. package/lib/commonjs/components/Sparkline/Sparkline.js +1 -1
  57. package/lib/commonjs/components/SquircleFill/SquircleFill.js +1 -1
  58. package/lib/commonjs/components/StatTile/StatTile.js +1 -1
  59. package/lib/commonjs/components/StatusBadge/StatusBadge.js +1 -1
  60. package/lib/commonjs/components/StatusBadge/statusMap.js +1 -1
  61. package/lib/commonjs/components/Stepper/Stepper.js +1 -1
  62. package/lib/commonjs/components/Swipeable/Swipeable.js +1 -1
  63. package/lib/commonjs/components/Text/Text.js +1 -1
  64. package/lib/commonjs/components/TimePicker/TimePicker.js +1 -1
  65. package/lib/commonjs/components/WheelPicker/Wheel.js +1 -1
  66. package/lib/commonjs/components/WheelPicker/WheelPicker.js +1 -1
  67. package/lib/commonjs/components/ZoomableImage/ZoomableImage.js +1 -1
  68. package/lib/commonjs/form/HookFormField.js +1 -1
  69. package/lib/commonjs/form/path.js +1 -1
  70. package/lib/commonjs/hooks/useControllableState.js +1 -1
  71. package/lib/commonjs/hooks/useDragToDismiss.js +1 -1
  72. package/lib/commonjs/navigation/NavigationScreen.js +1 -1
  73. package/lib/commonjs/specs/NativePdfRasterizer.js +1 -1
  74. package/lib/commonjs/theme/ThemeContext.js +1 -1
  75. package/lib/commonjs/theme/animatedValue.js +1 -1
  76. package/lib/commonjs/theme/componentSizes.js +1 -1
  77. package/lib/commonjs/theme/merge.js +1 -1
  78. package/lib/commonjs/theme/scale.js +1 -1
  79. package/lib/commonjs/utils/complete.js +1 -0
  80. package/lib/commonjs/utils/guards.js +1 -0
  81. package/lib/commonjs/utils/hapticUtils.js +1 -1
  82. package/lib/module/components/Accordion/Accordion.js +1 -1
  83. package/lib/module/components/AppIcon/AppIcon.js +1 -1
  84. package/lib/module/components/AppIcon/glyphs.g.js +1 -1
  85. package/lib/module/components/AsyncBlock/AsyncBlock.js +1 -1
  86. package/lib/module/components/AuthedImage/AuthedImage.js +1 -1
  87. package/lib/module/components/AuthedImage/authedImageCache.js +1 -1
  88. package/lib/module/components/Avatar/Avatar.js +1 -1
  89. package/lib/module/components/Badge/Badge.js +1 -1
  90. package/lib/module/components/Banner/Banner.js +1 -1
  91. package/lib/module/components/BarChart/BarChart.js +1 -1
  92. package/lib/module/components/BottomNavigation/BottomNavigation.js +1 -1
  93. package/lib/module/components/BottomSheet/BottomSheet.js +1 -1
  94. package/lib/module/components/Box/Box.js +1 -1
  95. package/lib/module/components/Card/Card.js +1 -1
  96. package/lib/module/components/Carousel/Carousel.js +1 -1
  97. package/lib/module/components/Chip/Chip.js +1 -1
  98. package/lib/module/components/ChoiceGroup/ChoiceGroup.js +1 -1
  99. package/lib/module/components/Confetti/Confetti.js +1 -1
  100. package/lib/module/components/DatePicker/DatePicker.js +1 -1
  101. package/lib/module/components/DateRangePicker/DateRangePicker.js +1 -1
  102. package/lib/module/components/Descriptions/Descriptions.js +1 -1
  103. package/lib/module/components/Dialog/Dialog.js +1 -1
  104. package/lib/module/components/Drawer/Drawer.js +1 -1
  105. package/lib/module/components/FieldBase/useFloatingLabel.js +1 -1
  106. package/lib/module/components/FileViewer/fileSource.js +1 -1
  107. package/lib/module/components/FileViewer/useFileViewerZoom.js +1 -1
  108. package/lib/module/components/FloatingActionButton/FloatingActionButton.js +1 -1
  109. package/lib/module/components/ImageGallery/ImageGallery.js +1 -1
  110. package/lib/module/components/InlineSelect/InlineSelect.js +1 -1
  111. package/lib/module/components/Input/Input.js +1 -1
  112. package/lib/module/components/ListItem/ListItem.js +1 -1
  113. package/lib/module/components/Markdown/Markdown.js +1 -1
  114. package/lib/module/components/Menu/MenuSurface.js +1 -1
  115. package/lib/module/components/Menu/focusHost.js +1 -1
  116. package/lib/module/components/OptionSheet/OptionSheet.js +1 -1
  117. package/lib/module/components/OptionSheet/optionAccessors.js +1 -0
  118. package/lib/module/components/PhoneNumberInput/PhoneNumberInput.js +1 -1
  119. package/lib/module/components/ProgressRing/ProgressRing.js +1 -1
  120. package/lib/module/components/Radio/RadioGroup.js +1 -1
  121. package/lib/module/components/Rating/Rating.js +1 -1
  122. package/lib/module/components/Repeater/Repeater.js +1 -1
  123. package/lib/module/components/Screen/Screen.js +1 -1
  124. package/lib/module/components/SearchBar/useRecentSearches.js +1 -1
  125. package/lib/module/components/SegmentedControl/SegmentedControl.js +1 -1
  126. package/lib/module/components/Select/Select.js +1 -1
  127. package/lib/module/components/SignaturePad/SignaturePad.js +1 -1
  128. package/lib/module/components/Skeleton/SkeletonContent.js +1 -1
  129. package/lib/module/components/Skeleton/SkeletonList.js +1 -1
  130. package/lib/module/components/SlideToConfirm/SlideToConfirm.js +1 -1
  131. package/lib/module/components/Slider/Slider.js +1 -1
  132. package/lib/module/components/SliderField/SliderField.js +1 -1
  133. package/lib/module/components/SortableList/SortableList.js +1 -1
  134. package/lib/module/components/Sparkline/Sparkline.js +1 -1
  135. package/lib/module/components/SquircleFill/SquircleFill.js +1 -1
  136. package/lib/module/components/StatTile/StatTile.js +1 -1
  137. package/lib/module/components/StatusBadge/StatusBadge.js +1 -1
  138. package/lib/module/components/StatusBadge/statusMap.js +1 -1
  139. package/lib/module/components/Stepper/Stepper.js +1 -1
  140. package/lib/module/components/Swipeable/Swipeable.js +1 -1
  141. package/lib/module/components/Text/Text.js +1 -1
  142. package/lib/module/components/TimePicker/TimePicker.js +1 -1
  143. package/lib/module/components/WheelPicker/Wheel.js +1 -1
  144. package/lib/module/components/WheelPicker/WheelPicker.js +1 -1
  145. package/lib/module/components/ZoomableImage/ZoomableImage.js +1 -1
  146. package/lib/module/form/HookFormField.js +1 -1
  147. package/lib/module/form/path.js +1 -1
  148. package/lib/module/hooks/useControllableState.js +1 -1
  149. package/lib/module/hooks/useDragToDismiss.js +1 -1
  150. package/lib/module/navigation/NavigationScreen.js +1 -1
  151. package/lib/module/specs/NativePdfRasterizer.js +1 -1
  152. package/lib/module/theme/ThemeContext.js +1 -1
  153. package/lib/module/theme/animatedValue.js +1 -1
  154. package/lib/module/theme/componentSizes.js +1 -1
  155. package/lib/module/theme/merge.js +1 -1
  156. package/lib/module/theme/scale.js +1 -1
  157. package/lib/module/utils/complete.js +1 -0
  158. package/lib/module/utils/guards.js +1 -0
  159. package/lib/module/utils/hapticUtils.js +1 -1
  160. package/lib/typescript/commonjs/canvasKit/index.d.ts +12 -12
  161. package/lib/typescript/commonjs/canvasKit/meta.d.ts +5 -7
  162. package/lib/typescript/commonjs/components/Accordion/Accordion.d.ts +22 -22
  163. package/lib/typescript/commonjs/components/AmountSlider/AmountSlider.d.ts +23 -23
  164. package/lib/typescript/commonjs/components/AnimatePresence/AnimatePresence.d.ts +5 -5
  165. package/lib/typescript/commonjs/components/AppBar/AppBar.d.ts +39 -39
  166. package/lib/typescript/commonjs/components/AppIcon/AppIcon.d.ts +7 -7
  167. package/lib/typescript/commonjs/components/AppIcon/defaultIcons.d.ts +2 -1
  168. package/lib/typescript/commonjs/components/AppIcon/glyphs.g.d.ts +233 -233
  169. package/lib/typescript/commonjs/components/AppIcon/slotIcon.d.ts +1 -1
  170. package/lib/typescript/commonjs/components/AppLockOverlay/AppLockOverlay.d.ts +5 -5
  171. package/lib/typescript/commonjs/components/AsyncBlock/AsyncBlock.d.ts +22 -40
  172. package/lib/typescript/commonjs/components/AuthedImage/AuthedImage.d.ts +15 -15
  173. package/lib/typescript/commonjs/components/AuthedImage/authedImageCache.d.ts +2 -2
  174. package/lib/typescript/commonjs/components/Autocomplete/Autocomplete.d.ts +24 -24
  175. package/lib/typescript/commonjs/components/Avatar/Avatar.d.ts +36 -36
  176. package/lib/typescript/commonjs/components/Badge/Badge.d.ts +18 -18
  177. package/lib/typescript/commonjs/components/Banner/Banner.d.ts +25 -25
  178. package/lib/typescript/commonjs/components/BarChart/BarChart.d.ts +21 -21
  179. package/lib/typescript/commonjs/components/BottomNavigation/BottomNavigation.d.ts +36 -36
  180. package/lib/typescript/commonjs/components/BottomSheet/BottomSheet.d.ts +33 -33
  181. package/lib/typescript/commonjs/components/Box/Box.d.ts +27 -27
  182. package/lib/typescript/commonjs/components/Button/Button.d.ts +22 -22
  183. package/lib/typescript/commonjs/components/Calendar/Calendar.d.ts +20 -20
  184. package/lib/typescript/commonjs/components/Calendar/CalendarDay.d.ts +4 -2
  185. package/lib/typescript/commonjs/components/Card/Card.d.ts +41 -41
  186. package/lib/typescript/commonjs/components/Carousel/Carousel.d.ts +21 -21
  187. package/lib/typescript/commonjs/components/Checkbox/Checkbox.d.ts +21 -21
  188. package/lib/typescript/commonjs/components/Chip/Chip.d.ts +23 -23
  189. package/lib/typescript/commonjs/components/ChoiceGroup/ChoiceGroup.d.ts +51 -46
  190. package/lib/typescript/commonjs/components/Composer/Composer.d.ts +27 -27
  191. package/lib/typescript/commonjs/components/Confetti/Confetti.d.ts +22 -21
  192. package/lib/typescript/commonjs/components/Confirm/confirm.d.ts +4 -4
  193. package/lib/typescript/commonjs/components/DatePicker/DatePicker.d.ts +20 -20
  194. package/lib/typescript/commonjs/components/DateRangePicker/DateRangePicker.d.ts +22 -22
  195. package/lib/typescript/commonjs/components/DateSeparator/DateSeparator.d.ts +9 -9
  196. package/lib/typescript/commonjs/components/DecimalInput/DecimalInput.d.ts +14 -14
  197. package/lib/typescript/commonjs/components/Descriptions/Descriptions.d.ts +13 -13
  198. package/lib/typescript/commonjs/components/Dialog/Dialog.d.ts +24 -24
  199. package/lib/typescript/commonjs/components/Dialog/OverlayActions.d.ts +5 -5
  200. package/lib/typescript/commonjs/components/Divider/Divider.d.ts +9 -9
  201. package/lib/typescript/commonjs/components/Drawer/Drawer.d.ts +15 -15
  202. package/lib/typescript/commonjs/components/EmptyState/EmptyState.d.ts +13 -13
  203. package/lib/typescript/commonjs/components/ErrorBoundary/ErrorBoundary.d.ts +8 -8
  204. package/lib/typescript/commonjs/components/FieldBase/Chevron.d.ts +2 -2
  205. package/lib/typescript/commonjs/components/FieldBase/ChoiceText.d.ts +10 -10
  206. package/lib/typescript/commonjs/components/FieldBase/FieldBase.d.ts +54 -54
  207. package/lib/typescript/commonjs/components/FieldBase/useFloatingLabel.d.ts +8 -8
  208. package/lib/typescript/commonjs/components/FilePicker/FilePicker.d.ts +35 -35
  209. package/lib/typescript/commonjs/components/FileViewer/FileViewer.d.ts +10 -10
  210. package/lib/typescript/commonjs/components/FileViewer/fileSource.d.ts +3 -3
  211. package/lib/typescript/commonjs/components/FileViewer/useFileViewerZoom.d.ts +3 -3
  212. package/lib/typescript/commonjs/components/FilterChipRow/FilterChipRow.d.ts +12 -12
  213. package/lib/typescript/commonjs/components/FloatingActionButton/FloatingActionButton.d.ts +35 -35
  214. package/lib/typescript/commonjs/components/ForceUpdateDialog/ForceUpdateDialog.d.ts +11 -11
  215. package/lib/typescript/commonjs/components/FormField/FormField.d.ts +15 -15
  216. package/lib/typescript/commonjs/components/IconBadge/IconBadge.d.ts +11 -11
  217. package/lib/typescript/commonjs/components/IconButton/IconButton.d.ts +14 -14
  218. package/lib/typescript/commonjs/components/ImageGallery/ImageGallery.d.ts +14 -14
  219. package/lib/typescript/commonjs/components/InlineSelect/InlineSelect.d.ts +36 -31
  220. package/lib/typescript/commonjs/components/Input/Input.d.ts +47 -47
  221. package/lib/typescript/commonjs/components/KeyboardAwareScrollView/KeyboardAwareScrollView.d.ts +7 -7
  222. package/lib/typescript/commonjs/components/KeyboardToolbar/KeyboardToolbar.d.ts +8 -8
  223. package/lib/typescript/commonjs/components/ListItem/ListItem.d.ts +44 -44
  224. package/lib/typescript/commonjs/components/ListSection/ListSection.d.ts +6 -6
  225. package/lib/typescript/commonjs/components/LoaderOverlay/LoaderOverlay.d.ts +17 -11
  226. package/lib/typescript/commonjs/components/Markdown/Markdown.d.ts +15 -15
  227. package/lib/typescript/commonjs/components/Menu/Menu.d.ts +17 -12
  228. package/lib/typescript/commonjs/components/Menu/MenuSurface.d.ts +8 -8
  229. package/lib/typescript/commonjs/components/Menu/menuModel.d.ts +11 -11
  230. package/lib/typescript/commonjs/components/Menu/useContextMenu.d.ts +13 -13
  231. package/lib/typescript/commonjs/components/Menu/webOnly.d.ts +3 -3
  232. package/lib/typescript/commonjs/components/MessageBubble/MessageBubble.d.ts +20 -20
  233. package/lib/typescript/commonjs/components/MessageList/MessageList.d.ts +14 -14
  234. package/lib/typescript/commonjs/components/Modal/Modal.d.ts +19 -19
  235. package/lib/typescript/commonjs/components/NumberInput/NumberInput.d.ts +27 -27
  236. package/lib/typescript/commonjs/components/OTPInput/OTPInput.d.ts +20 -20
  237. package/lib/typescript/commonjs/components/OTPInput/OTPResendRow.d.ts +9 -9
  238. package/lib/typescript/commonjs/components/OnboardingPager/OnboardingPager.d.ts +5 -5
  239. package/lib/typescript/commonjs/components/OptionSheet/OptionSheet.d.ts +33 -33
  240. package/lib/typescript/commonjs/components/OptionSheet/optionAccessors.d.ts +8 -0
  241. package/lib/typescript/commonjs/components/PagedListFooter/PagedListFooter.d.ts +2 -2
  242. package/lib/typescript/commonjs/components/PermissionPrompt/PermissionPrompt.d.ts +6 -6
  243. package/lib/typescript/commonjs/components/PermissionPrompt/usePermissionPrompt.d.ts +1 -1
  244. package/lib/typescript/commonjs/components/PhoneNumberInput/PhoneNumberInput.d.ts +43 -43
  245. package/lib/typescript/commonjs/components/PickerTrigger/PickerTrigger.d.ts +23 -23
  246. package/lib/typescript/commonjs/components/ProfileCompletion/ProfileCompletion.d.ts +23 -23
  247. package/lib/typescript/commonjs/components/ProfilePicker/ProfilePicker.d.ts +30 -30
  248. package/lib/typescript/commonjs/components/ProgressBar/ProgressBar.d.ts +21 -21
  249. package/lib/typescript/commonjs/components/ProgressRing/ProgressRing.d.ts +13 -13
  250. package/lib/typescript/commonjs/components/Radio/Radio.d.ts +18 -18
  251. package/lib/typescript/commonjs/components/Radio/RadioDot.d.ts +5 -5
  252. package/lib/typescript/commonjs/components/Radio/RadioGroup.d.ts +8 -8
  253. package/lib/typescript/commonjs/components/Rating/Rating.d.ts +15 -15
  254. package/lib/typescript/commonjs/components/Repeater/Repeater.d.ts +10 -10
  255. package/lib/typescript/commonjs/components/RichTextEditor/RichTextEditor.d.ts +15 -15
  256. package/lib/typescript/commonjs/components/ScannerOverlay/ScannerOverlay.d.ts +13 -13
  257. package/lib/typescript/commonjs/components/Screen/Screen.d.ts +43 -44
  258. package/lib/typescript/commonjs/components/Screen/index.d.ts +1 -1
  259. package/lib/typescript/commonjs/components/SearchBar/SearchBar.d.ts +31 -31
  260. package/lib/typescript/commonjs/components/SearchBar/SearchPanel.d.ts +6 -6
  261. package/lib/typescript/commonjs/components/SearchBar/useRecentSearches.d.ts +1 -1
  262. package/lib/typescript/commonjs/components/SectionHeader/SectionHeader.d.ts +10 -10
  263. package/lib/typescript/commonjs/components/SegmentedControl/SegmentedControl.d.ts +25 -24
  264. package/lib/typescript/commonjs/components/Select/Select.d.ts +50 -45
  265. package/lib/typescript/commonjs/components/SignaturePad/SignaturePad.d.ts +20 -20
  266. package/lib/typescript/commonjs/components/Skeleton/Skeleton.d.ts +13 -13
  267. package/lib/typescript/commonjs/components/Skeleton/SkeletonContent.d.ts +9 -9
  268. package/lib/typescript/commonjs/components/Skeleton/SkeletonList.d.ts +30 -8
  269. package/lib/typescript/commonjs/components/Skeleton/SkeletonProvider.d.ts +9 -9
  270. package/lib/typescript/commonjs/components/SlideToConfirm/SlideToConfirm.d.ts +14 -14
  271. package/lib/typescript/commonjs/components/Slider/Slider.d.ts +30 -30
  272. package/lib/typescript/commonjs/components/Slider/valueText.d.ts +9 -9
  273. package/lib/typescript/commonjs/components/SliderField/SliderField.d.ts +41 -41
  274. package/lib/typescript/commonjs/components/SortableList/SortableList.d.ts +5 -5
  275. package/lib/typescript/commonjs/components/Sparkline/Sparkline.d.ts +13 -13
  276. package/lib/typescript/commonjs/components/Sparkline/geometry.d.ts +3 -1
  277. package/lib/typescript/commonjs/components/Spinner/Spinner.d.ts +10 -10
  278. package/lib/typescript/commonjs/components/SquircleFill/SquircleFill.d.ts +3 -3
  279. package/lib/typescript/commonjs/components/SquircleImage/SquircleImage.d.ts +5 -12
  280. package/lib/typescript/commonjs/components/StatTile/StatTile.d.ts +14 -14
  281. package/lib/typescript/commonjs/components/StatusBadge/StatusBadge.d.ts +13 -13
  282. package/lib/typescript/commonjs/components/Stepper/Stepper.d.ts +21 -21
  283. package/lib/typescript/commonjs/components/Swipeable/Swipeable.d.ts +16 -16
  284. package/lib/typescript/commonjs/components/Switch/Switch.d.ts +19 -19
  285. package/lib/typescript/commonjs/components/Tabs/Tabs.d.ts +20 -20
  286. package/lib/typescript/commonjs/components/TagInput/TagInput.d.ts +19 -19
  287. package/lib/typescript/commonjs/components/Text/Text.d.ts +10 -10
  288. package/lib/typescript/commonjs/components/TimePicker/TimePicker.d.ts +14 -14
  289. package/lib/typescript/commonjs/components/Timeline/Timeline.d.ts +12 -12
  290. package/lib/typescript/commonjs/components/Toast/Toast.d.ts +17 -17
  291. package/lib/typescript/commonjs/components/Toast/ToastProvider.d.ts +8 -8
  292. package/lib/typescript/commonjs/components/Tooltip/RichTooltipBody.d.ts +4 -4
  293. package/lib/typescript/commonjs/components/Tooltip/Tooltip.d.ts +24 -19
  294. package/lib/typescript/commonjs/components/Tour/Tour.d.ts +7 -7
  295. package/lib/typescript/commonjs/components/TypingIndicator/TypingIndicator.d.ts +6 -6
  296. package/lib/typescript/commonjs/components/WheelPicker/Wheel.d.ts +6 -6
  297. package/lib/typescript/commonjs/components/WheelPicker/WheelPicker.d.ts +20 -20
  298. package/lib/typescript/commonjs/components/ZoomableImage/ZoomableImage.d.ts +8 -8
  299. package/lib/typescript/commonjs/form/HookFormField.d.ts +5 -18
  300. package/lib/typescript/commonjs/form/path.d.ts +4 -2
  301. package/lib/typescript/commonjs/form/useFormCompletion.d.ts +1 -1
  302. package/lib/typescript/commonjs/hooks/useControllableState.d.ts +2 -2
  303. package/lib/typescript/commonjs/hooks/useDragToDismiss.d.ts +8 -8
  304. package/lib/typescript/commonjs/hooks/useFieldErrorScroll.d.ts +1 -1
  305. package/lib/typescript/commonjs/hooks/usePressAnimation.d.ts +4 -4
  306. package/lib/typescript/commonjs/hooks/useRefreshControl.d.ts +8 -8
  307. package/lib/typescript/commonjs/hooks/useResendCountdown.d.ts +1 -1
  308. package/lib/typescript/commonjs/hooks/useScrollDirection.d.ts +1 -1
  309. package/lib/typescript/commonjs/navigation/DiscardGuard.d.ts +2 -2
  310. package/lib/typescript/commonjs/navigation/NavigationScreen.d.ts +3 -3
  311. package/lib/typescript/commonjs/network/NetworkStatusBanner.d.ts +7 -7
  312. package/lib/typescript/commonjs/theme/Gradient.d.ts +2 -2
  313. package/lib/typescript/commonjs/theme/ThemeContext.d.ts +5 -5
  314. package/lib/typescript/commonjs/theme/componentSizes.d.ts +15 -38
  315. package/lib/typescript/commonjs/theme/types.d.ts +84 -84
  316. package/lib/typescript/commonjs/utils/announce.d.ts +1 -1
  317. package/lib/typescript/commonjs/utils/complete.d.ts +5 -0
  318. package/lib/typescript/commonjs/utils/feedback.d.ts +3 -1
  319. package/lib/typescript/commonjs/utils/guards.d.ts +9 -0
  320. package/lib/typescript/commonjs/utils/placement.d.ts +3 -3
  321. package/lib/typescript/commonjs/utils/squircle.d.ts +2 -2
  322. package/lib/typescript/module/canvasKit/index.d.ts +12 -12
  323. package/lib/typescript/module/canvasKit/meta.d.ts +5 -7
  324. package/lib/typescript/module/components/Accordion/Accordion.d.ts +22 -22
  325. package/lib/typescript/module/components/AmountSlider/AmountSlider.d.ts +23 -23
  326. package/lib/typescript/module/components/AnimatePresence/AnimatePresence.d.ts +5 -5
  327. package/lib/typescript/module/components/AppBar/AppBar.d.ts +39 -39
  328. package/lib/typescript/module/components/AppIcon/AppIcon.d.ts +7 -7
  329. package/lib/typescript/module/components/AppIcon/defaultIcons.d.ts +2 -1
  330. package/lib/typescript/module/components/AppIcon/glyphs.g.d.ts +233 -233
  331. package/lib/typescript/module/components/AppIcon/slotIcon.d.ts +1 -1
  332. package/lib/typescript/module/components/AppLockOverlay/AppLockOverlay.d.ts +5 -5
  333. package/lib/typescript/module/components/AsyncBlock/AsyncBlock.d.ts +22 -40
  334. package/lib/typescript/module/components/AuthedImage/AuthedImage.d.ts +15 -15
  335. package/lib/typescript/module/components/AuthedImage/authedImageCache.d.ts +2 -2
  336. package/lib/typescript/module/components/Autocomplete/Autocomplete.d.ts +24 -24
  337. package/lib/typescript/module/components/Avatar/Avatar.d.ts +36 -36
  338. package/lib/typescript/module/components/Badge/Badge.d.ts +18 -18
  339. package/lib/typescript/module/components/Banner/Banner.d.ts +25 -25
  340. package/lib/typescript/module/components/BarChart/BarChart.d.ts +21 -21
  341. package/lib/typescript/module/components/BottomNavigation/BottomNavigation.d.ts +36 -36
  342. package/lib/typescript/module/components/BottomSheet/BottomSheet.d.ts +33 -33
  343. package/lib/typescript/module/components/Box/Box.d.ts +27 -27
  344. package/lib/typescript/module/components/Button/Button.d.ts +22 -22
  345. package/lib/typescript/module/components/Calendar/Calendar.d.ts +20 -20
  346. package/lib/typescript/module/components/Calendar/CalendarDay.d.ts +4 -2
  347. package/lib/typescript/module/components/Card/Card.d.ts +41 -41
  348. package/lib/typescript/module/components/Carousel/Carousel.d.ts +21 -21
  349. package/lib/typescript/module/components/Checkbox/Checkbox.d.ts +21 -21
  350. package/lib/typescript/module/components/Chip/Chip.d.ts +23 -23
  351. package/lib/typescript/module/components/ChoiceGroup/ChoiceGroup.d.ts +51 -46
  352. package/lib/typescript/module/components/Composer/Composer.d.ts +27 -27
  353. package/lib/typescript/module/components/Confetti/Confetti.d.ts +22 -21
  354. package/lib/typescript/module/components/Confirm/confirm.d.ts +4 -4
  355. package/lib/typescript/module/components/DatePicker/DatePicker.d.ts +20 -20
  356. package/lib/typescript/module/components/DateRangePicker/DateRangePicker.d.ts +22 -22
  357. package/lib/typescript/module/components/DateSeparator/DateSeparator.d.ts +9 -9
  358. package/lib/typescript/module/components/DecimalInput/DecimalInput.d.ts +14 -14
  359. package/lib/typescript/module/components/Descriptions/Descriptions.d.ts +13 -13
  360. package/lib/typescript/module/components/Dialog/Dialog.d.ts +24 -24
  361. package/lib/typescript/module/components/Dialog/OverlayActions.d.ts +5 -5
  362. package/lib/typescript/module/components/Divider/Divider.d.ts +9 -9
  363. package/lib/typescript/module/components/Drawer/Drawer.d.ts +15 -15
  364. package/lib/typescript/module/components/EmptyState/EmptyState.d.ts +13 -13
  365. package/lib/typescript/module/components/ErrorBoundary/ErrorBoundary.d.ts +8 -8
  366. package/lib/typescript/module/components/FieldBase/Chevron.d.ts +2 -2
  367. package/lib/typescript/module/components/FieldBase/ChoiceText.d.ts +10 -10
  368. package/lib/typescript/module/components/FieldBase/FieldBase.d.ts +54 -54
  369. package/lib/typescript/module/components/FieldBase/useFloatingLabel.d.ts +8 -8
  370. package/lib/typescript/module/components/FilePicker/FilePicker.d.ts +35 -35
  371. package/lib/typescript/module/components/FileViewer/FileViewer.d.ts +10 -10
  372. package/lib/typescript/module/components/FileViewer/fileSource.d.ts +3 -3
  373. package/lib/typescript/module/components/FileViewer/useFileViewerZoom.d.ts +3 -3
  374. package/lib/typescript/module/components/FilterChipRow/FilterChipRow.d.ts +12 -12
  375. package/lib/typescript/module/components/FloatingActionButton/FloatingActionButton.d.ts +35 -35
  376. package/lib/typescript/module/components/ForceUpdateDialog/ForceUpdateDialog.d.ts +11 -11
  377. package/lib/typescript/module/components/FormField/FormField.d.ts +15 -15
  378. package/lib/typescript/module/components/IconBadge/IconBadge.d.ts +11 -11
  379. package/lib/typescript/module/components/IconButton/IconButton.d.ts +14 -14
  380. package/lib/typescript/module/components/ImageGallery/ImageGallery.d.ts +14 -14
  381. package/lib/typescript/module/components/InlineSelect/InlineSelect.d.ts +36 -31
  382. package/lib/typescript/module/components/Input/Input.d.ts +47 -47
  383. package/lib/typescript/module/components/KeyboardAwareScrollView/KeyboardAwareScrollView.d.ts +7 -7
  384. package/lib/typescript/module/components/KeyboardToolbar/KeyboardToolbar.d.ts +8 -8
  385. package/lib/typescript/module/components/ListItem/ListItem.d.ts +44 -44
  386. package/lib/typescript/module/components/ListSection/ListSection.d.ts +6 -6
  387. package/lib/typescript/module/components/LoaderOverlay/LoaderOverlay.d.ts +17 -11
  388. package/lib/typescript/module/components/Markdown/Markdown.d.ts +15 -15
  389. package/lib/typescript/module/components/Menu/Menu.d.ts +17 -12
  390. package/lib/typescript/module/components/Menu/MenuSurface.d.ts +8 -8
  391. package/lib/typescript/module/components/Menu/menuModel.d.ts +11 -11
  392. package/lib/typescript/module/components/Menu/useContextMenu.d.ts +13 -13
  393. package/lib/typescript/module/components/Menu/webOnly.d.ts +3 -3
  394. package/lib/typescript/module/components/MessageBubble/MessageBubble.d.ts +20 -20
  395. package/lib/typescript/module/components/MessageList/MessageList.d.ts +14 -14
  396. package/lib/typescript/module/components/Modal/Modal.d.ts +19 -19
  397. package/lib/typescript/module/components/NumberInput/NumberInput.d.ts +27 -27
  398. package/lib/typescript/module/components/OTPInput/OTPInput.d.ts +20 -20
  399. package/lib/typescript/module/components/OTPInput/OTPResendRow.d.ts +9 -9
  400. package/lib/typescript/module/components/OnboardingPager/OnboardingPager.d.ts +5 -5
  401. package/lib/typescript/module/components/OptionSheet/OptionSheet.d.ts +33 -33
  402. package/lib/typescript/module/components/OptionSheet/optionAccessors.d.ts +8 -0
  403. package/lib/typescript/module/components/PagedListFooter/PagedListFooter.d.ts +2 -2
  404. package/lib/typescript/module/components/PermissionPrompt/PermissionPrompt.d.ts +6 -6
  405. package/lib/typescript/module/components/PermissionPrompt/usePermissionPrompt.d.ts +1 -1
  406. package/lib/typescript/module/components/PhoneNumberInput/PhoneNumberInput.d.ts +43 -43
  407. package/lib/typescript/module/components/PickerTrigger/PickerTrigger.d.ts +23 -23
  408. package/lib/typescript/module/components/ProfileCompletion/ProfileCompletion.d.ts +23 -23
  409. package/lib/typescript/module/components/ProfilePicker/ProfilePicker.d.ts +30 -30
  410. package/lib/typescript/module/components/ProgressBar/ProgressBar.d.ts +21 -21
  411. package/lib/typescript/module/components/ProgressRing/ProgressRing.d.ts +13 -13
  412. package/lib/typescript/module/components/Radio/Radio.d.ts +18 -18
  413. package/lib/typescript/module/components/Radio/RadioDot.d.ts +5 -5
  414. package/lib/typescript/module/components/Radio/RadioGroup.d.ts +8 -8
  415. package/lib/typescript/module/components/Rating/Rating.d.ts +15 -15
  416. package/lib/typescript/module/components/Repeater/Repeater.d.ts +10 -10
  417. package/lib/typescript/module/components/RichTextEditor/RichTextEditor.d.ts +15 -15
  418. package/lib/typescript/module/components/ScannerOverlay/ScannerOverlay.d.ts +13 -13
  419. package/lib/typescript/module/components/Screen/Screen.d.ts +43 -44
  420. package/lib/typescript/module/components/Screen/index.d.ts +1 -1
  421. package/lib/typescript/module/components/SearchBar/SearchBar.d.ts +31 -31
  422. package/lib/typescript/module/components/SearchBar/SearchPanel.d.ts +6 -6
  423. package/lib/typescript/module/components/SearchBar/useRecentSearches.d.ts +1 -1
  424. package/lib/typescript/module/components/SectionHeader/SectionHeader.d.ts +10 -10
  425. package/lib/typescript/module/components/SegmentedControl/SegmentedControl.d.ts +25 -24
  426. package/lib/typescript/module/components/Select/Select.d.ts +50 -45
  427. package/lib/typescript/module/components/SignaturePad/SignaturePad.d.ts +20 -20
  428. package/lib/typescript/module/components/Skeleton/Skeleton.d.ts +13 -13
  429. package/lib/typescript/module/components/Skeleton/SkeletonContent.d.ts +9 -9
  430. package/lib/typescript/module/components/Skeleton/SkeletonList.d.ts +30 -8
  431. package/lib/typescript/module/components/Skeleton/SkeletonProvider.d.ts +9 -9
  432. package/lib/typescript/module/components/SlideToConfirm/SlideToConfirm.d.ts +14 -14
  433. package/lib/typescript/module/components/Slider/Slider.d.ts +30 -30
  434. package/lib/typescript/module/components/Slider/valueText.d.ts +9 -9
  435. package/lib/typescript/module/components/SliderField/SliderField.d.ts +41 -41
  436. package/lib/typescript/module/components/SortableList/SortableList.d.ts +5 -5
  437. package/lib/typescript/module/components/Sparkline/Sparkline.d.ts +13 -13
  438. package/lib/typescript/module/components/Sparkline/geometry.d.ts +3 -1
  439. package/lib/typescript/module/components/Spinner/Spinner.d.ts +10 -10
  440. package/lib/typescript/module/components/SquircleFill/SquircleFill.d.ts +3 -3
  441. package/lib/typescript/module/components/SquircleImage/SquircleImage.d.ts +5 -12
  442. package/lib/typescript/module/components/StatTile/StatTile.d.ts +14 -14
  443. package/lib/typescript/module/components/StatusBadge/StatusBadge.d.ts +13 -13
  444. package/lib/typescript/module/components/Stepper/Stepper.d.ts +21 -21
  445. package/lib/typescript/module/components/Swipeable/Swipeable.d.ts +16 -16
  446. package/lib/typescript/module/components/Switch/Switch.d.ts +19 -19
  447. package/lib/typescript/module/components/Tabs/Tabs.d.ts +20 -20
  448. package/lib/typescript/module/components/TagInput/TagInput.d.ts +19 -19
  449. package/lib/typescript/module/components/Text/Text.d.ts +10 -10
  450. package/lib/typescript/module/components/TimePicker/TimePicker.d.ts +14 -14
  451. package/lib/typescript/module/components/Timeline/Timeline.d.ts +12 -12
  452. package/lib/typescript/module/components/Toast/Toast.d.ts +17 -17
  453. package/lib/typescript/module/components/Toast/ToastProvider.d.ts +8 -8
  454. package/lib/typescript/module/components/Tooltip/RichTooltipBody.d.ts +4 -4
  455. package/lib/typescript/module/components/Tooltip/Tooltip.d.ts +24 -19
  456. package/lib/typescript/module/components/Tour/Tour.d.ts +7 -7
  457. package/lib/typescript/module/components/TypingIndicator/TypingIndicator.d.ts +6 -6
  458. package/lib/typescript/module/components/WheelPicker/Wheel.d.ts +6 -6
  459. package/lib/typescript/module/components/WheelPicker/WheelPicker.d.ts +20 -20
  460. package/lib/typescript/module/components/ZoomableImage/ZoomableImage.d.ts +8 -8
  461. package/lib/typescript/module/form/HookFormField.d.ts +5 -18
  462. package/lib/typescript/module/form/path.d.ts +4 -2
  463. package/lib/typescript/module/form/useFormCompletion.d.ts +1 -1
  464. package/lib/typescript/module/hooks/useControllableState.d.ts +2 -2
  465. package/lib/typescript/module/hooks/useDragToDismiss.d.ts +8 -8
  466. package/lib/typescript/module/hooks/useFieldErrorScroll.d.ts +1 -1
  467. package/lib/typescript/module/hooks/usePressAnimation.d.ts +4 -4
  468. package/lib/typescript/module/hooks/useRefreshControl.d.ts +8 -8
  469. package/lib/typescript/module/hooks/useResendCountdown.d.ts +1 -1
  470. package/lib/typescript/module/hooks/useScrollDirection.d.ts +1 -1
  471. package/lib/typescript/module/navigation/DiscardGuard.d.ts +2 -2
  472. package/lib/typescript/module/navigation/NavigationScreen.d.ts +3 -3
  473. package/lib/typescript/module/network/NetworkStatusBanner.d.ts +7 -7
  474. package/lib/typescript/module/theme/Gradient.d.ts +2 -2
  475. package/lib/typescript/module/theme/ThemeContext.d.ts +5 -5
  476. package/lib/typescript/module/theme/componentSizes.d.ts +15 -38
  477. package/lib/typescript/module/theme/types.d.ts +84 -84
  478. package/lib/typescript/module/utils/announce.d.ts +1 -1
  479. package/lib/typescript/module/utils/complete.d.ts +5 -0
  480. package/lib/typescript/module/utils/feedback.d.ts +3 -1
  481. package/lib/typescript/module/utils/guards.d.ts +9 -0
  482. package/lib/typescript/module/utils/placement.d.ts +3 -3
  483. package/lib/typescript/module/utils/squircle.d.ts +2 -2
  484. package/package.json +11 -11
  485. package/src/specs/NativePdfRasterizer.ts +1 -1
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.DEFAULT_ASYNC_BLOCK_LABELS=exports.AsyncBlock=void 0;var _mobileCore=require("@webority/mobile-core"),_react=require("react"),_reactNative=require("react-native"),_index=require("../../theme/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_index2=require("../AppIcon/index.js"),_index3=require("../EmptyState/index.js"),_index4=require("../Spinner/index.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_ASYNC_BLOCK_LABELS=exports.DEFAULT_ASYNC_BLOCK_LABELS=Object.freeze({emptyTitle:"Nothing here yet",errorTitle:"That didn't load",offlineTitle:"You're offline",offlineHint:"Check your connection, then try again.",retry:"Try again"}),isNode=e=>(0,_react.isValidElement)(e)||Array.isArray(e),AsyncBlock=({loading:e=!1,error:t,errorVariant:i,empty:r=!1,onRetry:n,skeleton:s,emptyTitle:l,emptyDescription:o,emptyIcon:a,errorTitle:c,offlineTitle:_,labels:d,children:u,style:x,testID:m})=>{const y=(0,_index.useTheme)(),f=(0,_react.useMemo)(()=>({...DEFAULT_ASYNC_BLOCK_LABELS,...d}),[d]);if((0,_assertValidValue.assertValidValue)("AsyncBlock","errorVariant",i,["default","offline"]),e)return(0,_jsxRuntime.jsx)(_reactNative.View,{style:x,testID:m,children:s??(0,_jsxRuntime.jsx)(_reactNative.View,{style:{paddingVertical:y.space["2xl"],alignItems:"center"},children:(0,_jsxRuntime.jsx)(_index4.Spinner,{})})});if(t){const e="string"==typeof t?t:null,r=null!==e||isNode(t)?null:(0,_mobileCore.extractApiError)(t),s="offline"===(i??(r?.code===_mobileCore.OFFLINE_CODE?"offline":"default")),l=e??r?.message??(s?f.offlineHint:void 0);return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:x,testID:m,children:[(0,_jsxRuntime.jsx)(_index3.EmptyState,{icon:s?(0,_jsxRuntime.jsx)(_index2.AppIcon,{name:"cloud-cross",size:"xl",color:y.colors["text-subtle"],testID:"async-block-offline-icon"}):void 0,title:s?_??f.offlineTitle:c??f.errorTitle,description:l,action:n?{label:f.retry,onPress:n}:void 0}),isNode(t)?t:null]})}return r?(0,_jsxRuntime.jsx)(_reactNative.View,{style:x,testID:m,children:(0,_jsxRuntime.jsx)(_index3.EmptyState,{icon:a,title:l??f.emptyTitle,description:o})}):(0,_jsxRuntime.jsx)(_jsxRuntime.Fragment,{children:u})};exports.AsyncBlock=AsyncBlock;var _default=exports.default=AsyncBlock;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.AsyncBlock=AsyncBlock,exports.default=exports.DEFAULT_ASYNC_BLOCK_LABELS=void 0;var _mobileCore=require("@webority/mobile-core"),_react=require("react"),_reactNative=require("react-native"),_index=require("../../theme/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_index2=require("../AppIcon/index.js"),_index3=require("../EmptyState/index.js"),_index4=require("../Spinner/index.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_ASYNC_BLOCK_LABELS=exports.DEFAULT_ASYNC_BLOCK_LABELS=Object.freeze({emptyTitle:"Nothing here yet",errorTitle:"That didn't load",offlineTitle:"You're offline",retry:"Try again"});function AsyncBlock({state:e,children:t,empty:r,errorVariant:i,skeleton:s,errorTitle:n,offlineTitle:a,labels:l,style:o,testID:c}){const u=(0,_index.useTheme)(),_=(0,_react.useMemo)(()=>({...DEFAULT_ASYNC_BLOCK_LABELS,...l}),[l]);switch((0,_assertValidValue.assertValidValue)("AsyncBlock","errorVariant",i,["default","offline"]),(0,_assertValidValue.assertValidValue)("AsyncBlock","status",e.status,["loading","error","empty","data"]),e.status){case"loading":return(0,_jsxRuntime.jsx)(_reactNative.View,{style:o,testID:c,children:s??(0,_jsxRuntime.jsx)(_reactNative.View,{style:{paddingVertical:u.space["2xl"],alignItems:"center"},children:(0,_jsxRuntime.jsx)(_index4.Spinner,{})})});case"error":{const t="offline"===(i??(e.error.code===_mobileCore.OFFLINE_CODE?"offline":"default"));return(0,_jsxRuntime.jsx)(_reactNative.View,{style:o,testID:c,children:(0,_jsxRuntime.jsx)(_index3.EmptyState,{icon:t?(0,_jsxRuntime.jsx)(_index2.AppIcon,{name:"cloud-cross",size:"xl",color:u.colors["text-subtle"],testID:"async-block-offline-icon"}):void 0,title:t?a??_.offlineTitle:n??_.errorTitle,description:e.error.message,action:{label:_.retry,onPress:e.retry}})})}case"empty":return(0,_jsxRuntime.jsx)(_reactNative.View,{style:o,testID:c,children:(0,_jsxRuntime.jsx)(_index3.EmptyState,{...r??{title:_.emptyTitle}})});case"data":return(0,_jsxRuntime.jsx)(_jsxRuntime.Fragment,{children:t(e.data)})}}var _default=exports.default=AsyncBlock;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.DEFAULT_AUTHED_IMAGE_LABELS=exports.AuthedImage=void 0;var _expoImage=require("expo-image"),_react=require("react"),_reactNative=require("react-native"),_index=require("../../theme/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_corners=require("../../utils/corners.js"),_index2=require("../Spinner/index.js"),_index3=require("../Text/index.js"),_authedImageCache=require("./authedImageCache.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_AUTHED_IMAGE_LABELS=exports.DEFAULT_AUTHED_IMAGE_LABELS=Object.freeze({loading:"Loading image",unavailable:"Image unavailable",unavailableNamed:e=>`${e}, image unavailable`}),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:a,authenticated:i=!0,ttlMs:s=_authedImageCache.DEFAULT_TTL_MS,placeholder:n,fallback:o,onLoadStart:c,onLoadEnd:l,onError:u,cacheKey:d,testID:_,accessibilityLabel:h,style:m,resizeMode:g,fadeDuration:b,contentFit:y,transition:x,labels:I,cachePolicy:E="memory",...v}=e;(0,_assertValidValue.assertValidValue)("AuthedImage","resizeMode",g,Object.keys(CONTENT_FIT));const f=(0,_react.useMemo)(()=>({...DEFAULT_AUTHED_IMAGE_LABELS,...I}),[I]),j=(0,_index.useTheme)(),L=(0,_react.useMemo)(()=>buildStyles(j),[j]),[A,p]=(0,_react.useState)({status:"loading"}),C=(0,_react.useRef)({onLoadStart:c,onLoadEnd:l,onError:u});C.current={onLoadStart:c,onLoadEnd:l,onError:u};const T=JSON.stringify(r??{});return(0,_react.useEffect)(()=>{let e=!1,r=null;const finish=t=>{e||(p(t),C.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||(p({status:"error"}),C.current.onError?.(t)))}p({status:"loading"}),C.current.onLoadStart?.();const n=(0,_authedImageCache.deriveCacheKey)(t,d),o=await(0,_authedImageCache.readEntry)(n);if(e)return;if(o&&(0,_authedImageCache.isFresh)(o.meta,s))return(0,_authedImageCache.touchEntry)(n),void finish({status:"ready",fileUri:o.fileUri});const c=(0,_authedImageCache.acquireFetch)(n,{uri:t,headers:JSON.parse(T),authenticated:i,client:a});r={key:n,entry:c};try{const e=await c.promise;finish({status:"ready",fileUri:e.fileUri})}catch(t){if(e)return;if(o&&!(0,_authedImageCache.isPermanentRefusal)(t))return void finish({status:"ready",fileUri:o.fileUri});if(o&&(await(0,_authedImageCache.removeEntry)(n),e))return;p({status:"error"}),C.current.onError?.(toError(t)),C.current.onLoadEnd?.()}})(),()=>{e=!0,r&&(0,_authedImageCache.releaseFetch)(r.key,r.entry)}},[t,d,s,i,a,T]),"loading"===A.status?void 0!==n?(0,_jsxRuntime.jsx)(_reactNative.View,{style:m,testID:_,children:n}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:[L.placeholder,m],testID:_,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:L.stateFill,testID:_?`${_}-placeholder`:void 0,pointerEvents:"none",children:(0,_jsxRuntime.jsx)(_index2.Spinner,{size:"sm",accessibilityLabel:f.loading})})}):"error"===A.status?void 0!==o?(0,_jsxRuntime.jsx)(_reactNative.View,{style:m,testID:_,children:o}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:[L.fallback,m],testID:_,children:(0,_jsxRuntime.jsx)(_reactNative.View,{accessible:!0,accessibilityRole:"image",accessibilityLabel:h?f.unavailableNamed(h):f.unavailable,testID:_?`${_}-fallback`:void 0,style:L.stateFill,children:(0,_jsxRuntime.jsx)(_index3.Text,{variant:"title",color:"tertiary",accessible:!1,children:"!"})})}):(0,_jsxRuntime.jsx)(_expoImage.Image,{...v,accessible:!0,accessibilityRole:"image",accessibilityLabel:h,testID:_,style:m,contentFit:y??(g?CONTENT_FIT[g]:void 0),transition:x??b,cachePolicy:E,source:{uri:A.fileUri}})};exports.AuthedImage=AuthedImage,AuthedImage.displayName="AuthedImage";const buildStyles=e=>_reactNative.StyleSheet.create({placeholder:{alignItems:"center",justifyContent:"center",backgroundColor:e.colors["bg-subtle"],borderRadius:e.radius.md,..._corners.smoothCorners},fallback:{alignItems:"center",justifyContent:"center",backgroundColor:e.colors["bg-subtle"],borderRadius:e.radius.md,..._corners.smoothCorners,borderWidth:e.size.border,borderColor:e.colors["border-subtle"],padding:e.space.sm},stateFill:{alignItems:"center",flex:1,justifyContent:"center"}});var _default=exports.default=AuthedImage;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.DEFAULT_AUTHED_IMAGE_LABELS=exports.AuthedImage=void 0;var _expoImage=require("expo-image"),_react=require("react"),_reactNative=require("react-native"),_index=require("../../theme/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_corners=require("../../utils/corners.js"),_index2=require("../Spinner/index.js"),_index3=require("../Text/index.js"),_authedImageCache=require("./authedImageCache.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_AUTHED_IMAGE_LABELS=exports.DEFAULT_AUTHED_IMAGE_LABELS=Object.freeze({loading:"Loading image",unavailable:"Image unavailable",unavailableNamed:e=>`${e}, image unavailable`}),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:a,authenticated:i=!0,ttlMs:s=_authedImageCache.DEFAULT_TTL_MS,placeholder:n,fallback:o,onLoadStart:c,onLoadEnd:l,onError:d,cacheKey:u,testID:_,accessibilityLabel:h,style:m,resizeMode:g,fadeDuration:b,contentFit:y,transition:x,labels:I,cachePolicy:v="memory",...E}=e;(0,_assertValidValue.assertValidValue)("AuthedImage","resizeMode",g,Object.keys(CONTENT_FIT));const f=(0,_react.useMemo)(()=>({...DEFAULT_AUTHED_IMAGE_LABELS,...I}),[I]),j=(0,_index.useTheme)(),L=(0,_react.useMemo)(()=>buildStyles(j),[j]),[A,p]=(0,_react.useState)({status:"loading"}),C=(0,_react.useRef)({onLoadStart:c,onLoadEnd:l,onError:d});C.current={onLoadStart:c,onLoadEnd:l,onError:d};const T=JSON.stringify(r??{});if((0,_react.useEffect)(()=>{let e=!1,r=null;const finish=t=>{e||(p(t),C.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||(p({status:"error"}),C.current.onError?.(t)))}p({status:"loading"}),C.current.onLoadStart?.();const n=(0,_authedImageCache.deriveCacheKey)(t,u),o=await(0,_authedImageCache.readEntry)(n);if(e)return;if(o&&(0,_authedImageCache.isFresh)(o.meta,s))return(0,_authedImageCache.touchEntry)(n),void finish({status:"ready",fileUri:o.fileUri});const c=JSON.parse(T),l=(0,_authedImageCache.acquireFetch)(n,{uri:t,headers:c,authenticated:i,client:a});r={key:n,entry:l};try{const e=await l.promise;finish({status:"ready",fileUri:e.fileUri})}catch(t){if(e)return;if(o&&!(0,_authedImageCache.isPermanentRefusal)(t))return void finish({status:"ready",fileUri:o.fileUri});if(o&&(await(0,_authedImageCache.removeEntry)(n),e))return;p({status:"error"}),C.current.onError?.(toError(t)),C.current.onLoadEnd?.()}})(),()=>{e=!0,r&&(0,_authedImageCache.releaseFetch)(r.key,r.entry)}},[t,u,s,i,a,T]),"loading"===A.status)return void 0!==n?(0,_jsxRuntime.jsx)(_reactNative.View,{style:m,testID:_,children:n}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:[L.placeholder,m],testID:_,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:L.stateFill,testID:_?`${_}-placeholder`:void 0,pointerEvents:"none",children:(0,_jsxRuntime.jsx)(_index2.Spinner,{size:"sm",accessibilityLabel:f.loading})})});if("error"===A.status)return void 0!==o?(0,_jsxRuntime.jsx)(_reactNative.View,{style:m,testID:_,children:o}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:[L.fallback,m],testID:_,children:(0,_jsxRuntime.jsx)(_reactNative.View,{accessible:!0,accessibilityRole:"image",accessibilityLabel:h?f.unavailableNamed(h):f.unavailable,testID:_?`${_}-fallback`:void 0,style:L.stateFill,children:(0,_jsxRuntime.jsx)(_index3.Text,{variant:"title",color:"tertiary",accessible:!1,children:"!"})})});const N=y??(g?CONTENT_FIT[g]:void 0),S=x??b,D={...void 0!==h?{accessibilityLabel:h}:{},...void 0!==_?{testID:_}:{},...void 0!==m?{style:m}:{},...void 0!==N?{contentFit:N}:{},...void 0!==S?{transition:S}:{}};return(0,_jsxRuntime.jsx)(_expoImage.Image,{...E,...D,accessible:!0,accessibilityRole:"image",cachePolicy:v,source:{uri:A.fileUri}})};exports.AuthedImage=AuthedImage,AuthedImage.displayName="AuthedImage";const buildStyles=e=>_reactNative.StyleSheet.create({placeholder:{alignItems:"center",justifyContent:"center",backgroundColor:e.colors["bg-subtle"],borderRadius:e.radius.md,..._corners.smoothCorners},fallback:{alignItems:"center",justifyContent:"center",backgroundColor:e.colors["bg-subtle"],borderRadius:e.radius.md,..._corners.smoothCorners,borderWidth:e.size.border,borderColor:e.colors["border-subtle"],padding:e.space.sm},stateFill:{alignItems:"center",flex:1,justifyContent:"center"}});var _default=exports.default=AuthedImage;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.touchEntry=exports.setAuthedImageCacheLimit=exports.removeEntry=exports.releaseFetch=exports.readEntry=exports.isPermanentRefusal=exports.isFresh=exports.getAuthedImageCacheLimit=exports.flushAuthedImageIndex=exports.deriveCacheKey=exports.clearAuthedImageCache=exports.authedImageCacheStats=exports.acquireFetch=exports.DEFAULT_TTL_MS=exports.AuthedImageHttpError=void 0;var _mobileCore=require("@webority/mobile-core"),_reactNative=require("react-native"),_hashString=require("../../utils/hashString.js"),_imageStore=require("./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,DEFAULT_TTL_MS=exports.DEFAULT_TTL_MS=6048e5;let byteCeiling=52428800;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};exports.setAuthedImageCacheLimit=setAuthedImageCacheLimit;const getAuthedImageCacheLimit=()=>byteCeiling;exports.getAuthedImageCacheLimit=getAuthedImageCacheLimit;const deriveCacheKey=(e,t)=>(0,_hashString.hashString)(t??e);exports.deriveCacheKey=deriveCacheKey;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(!(0,_mobileCore.isStorageAvailable)())return;const t={};for(const[r,s]of e)t[r]={...s,persistedAccessAt:s.lastAccessedAt};if(await _mobileCore.Storage.setItem(INDEX_KEY,JSON.stringify(t)))for(const t of e.values())t.persistedAccessAt=t.lastAccessedAt},schedulePersist=e=>{persistTarget=e,null===appStateSub&&(appStateSub=_reactNative.AppState.addEventListener("change",e=>{"active"!==e&&flushAuthedImageIndex()})),null===persistTimer&&(persistTimer=setTimeout(()=>{flushAuthedImageIndex()},1e3))},flushAuthedImageIndex=async()=>{null!==persistTimer&&(clearTimeout(persistTimer),persistTimer=null);const e=persistTarget;persistTarget=null,null!==e&&await persistIndex(e)};exports.flushAuthedImageIndex=flushAuthedImageIndex;const removeLegacyEntries=async()=>{const e=(await _mobileCore.Storage.getAllKeys()).filter(e=>e.startsWith(LEGACY_PREFIX));e.length>0&&await _mobileCore.Storage.multiRemove(e)},removeOrphanFiles=e=>{try{const t=new Set([...e.values()].map(e=>e.fileName));for(const e of(0,_imageStore.listImageNames)())t.has(e)||(0,_imageStore.deleteImage)(e)}catch(e){_mobileCore.Logger.warn("[@webority/mobile-ui] AuthedImage could not tidy the image cache folder",e)}},readStoredIndex=async()=>{const e=new Map;if(!(0,_mobileCore.isStorageAvailable)())return e;const t=await _mobileCore.Storage.getItem(INDEX_KEY);if(!t)return await removeLegacyEntries(),e;try{for(const[r,s]of Object.entries(JSON.parse(t)))e.set(r,s)}catch{}return e},loadIndex=()=>index?Promise.resolve(index):(indexLoad||(indexLoad=readStoredIndex().then(e=>{removeOrphanFiles(e);for(const[t,r]of e)(0,_imageStore.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{(0,_imageStore.deleteImage)(e)}catch(e){_mobileCore.Logger.warn("[@webority/mobile-ui] AuthedImage could not delete a cached image file",e)}},readEntry=async e=>{const t=await loadIndex(),r=t.get(e);return r?(0,_imageStore.imageExists)(r.fileName)?{fileUri:(0,_imageStore.imageUri)(r.fileName),meta:toMeta(r)}:(t.delete(e),indexBytes-=r.bytes,schedulePersist(t),null):null};exports.readEntry=readEntry;const removeEntry=async e=>{const t=await loadIndex(),r=t.get(e);r&&(t.delete(e),indexBytes-=r.bytes,deleteFile(r.fileName),schedulePersist(t))};exports.removeEntry=removeEntry;class AuthedImageHttpError extends Error{constructor(e,t){super(e),this.name="AuthedImageHttpError",this.status=t}}exports.AuthedImageHttpError=AuthedImageHttpError;const isPermanentRefusal=e=>e instanceof AuthedImageHttpError&&e.status>=400&&e.status<500&&408!==e.status&&429!==e.status;exports.isPermanentRefusal=isPermanentRefusal;const isFresh=(e,t,r=Date.now())=>r-e.fetchedAt<t;exports.isFresh=isFresh;const touchEntry=async e=>{const t=await loadIndex(),r=t.get(e);r&&(r.lastAccessedAt=Date.now(),r.lastAccessedAt-r.persistedAccessAt>=36e5&&schedulePersist(t))};exports.touchEntry=touchEntry;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},clearAuthedImageCache=async()=>{null!==persistTimer&&(clearTimeout(persistTimer),persistTimer=null),persistTarget=null;(await loadIndex()).clear(),indexBytes=0,(0,_imageStore.clearImages)(),(0,_mobileCore.isStorageAvailable)()&&await _mobileCore.Storage.removeItem(INDEX_KEY)};exports.clearAuthedImageCache=clearAuthedImageCache;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}};exports.authedImageCacheStats=authedImageCacheStats;const responseHeader=(e,t)=>{if(!e||"object"!=typeof 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=(0,_mobileCore.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(0,_mobileCore.getToken)(_mobileCore.ACCESS_TOKEN_KEY);e?.token&&(s.Authorization=`Bearer ${e.token}`)}const i=t.client??_mobileCore.publicClient;let a;try{a=await i.get(t.uri,{headers:s,responseType:"arraybuffer",signal:r})}catch(e){const r=e?.response?.status;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 o=new Uint8Array(a.data??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 n=responseHeader(a.headers,"content-type"),l=(n?mediaTypeOf(n):"")||"image/jpeg",c=await loadIndex(),d=Date.now(),u=`${e}-${d.toString(36)}`;let h;try{h=await(0,_imageStore.writeImage)(u,o,l)}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 m={fetchedAt:d,bytes:o.byteLength,contentType:l,lastAccessedAt:d,fileName:u,persistedAccessAt:d},g=c.get(e);g&&(indexBytes-=g.bytes),c.set(e,m),indexBytes+=m.bytes,g&&g.fileName!==u&&deleteFile(g.fileName);const p=evictIfNeeded(c);return schedulePersist(c),p>0&&_mobileCore.Logger.info(`[@webority/mobile-ui] AuthedImage evicted ${p} cached image(s) over the byte ceiling`),{fileUri:h,meta:toMeta(m)}},inFlight=new Map,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:Promise.resolve()};return i.promise=fetchAndStore(e,t,s.signal).finally(()=>{inFlight.get(e)===i&&inFlight.delete(e)}),inFlight.set(e,i),i};exports.acquireFetch=acquireFetch;const releaseFetch=(e,t)=>{t.waiters-=1,t.waiters>0||(inFlight.get(e)===t&&inFlight.delete(e),t.controller.abort())};exports.releaseFetch=releaseFetch;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.touchEntry=exports.setAuthedImageCacheLimit=exports.removeEntry=exports.releaseFetch=exports.readEntry=exports.isPermanentRefusal=exports.isFresh=exports.getAuthedImageCacheLimit=exports.flushAuthedImageIndex=exports.deriveCacheKey=exports.clearAuthedImageCache=exports.authedImageCacheStats=exports.acquireFetch=exports.DEFAULT_TTL_MS=exports.AuthedImageHttpError=void 0;var _mobileCore=require("@webority/mobile-core"),_reactNative=require("react-native"),_guards=require("../../utils/guards.js"),_hashString=require("../../utils/hashString.js"),_imageStore=require("./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,DEFAULT_TTL_MS=exports.DEFAULT_TTL_MS=6048e5,isIndexEntry=e=>(0,_guards.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;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};exports.setAuthedImageCacheLimit=setAuthedImageCacheLimit;const getAuthedImageCacheLimit=()=>byteCeiling;exports.getAuthedImageCacheLimit=getAuthedImageCacheLimit;const deriveCacheKey=(e,t)=>(0,_hashString.hashString)(t??e);exports.deriveCacheKey=deriveCacheKey;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(!(0,_mobileCore.isStorageAvailable)())return;const t={};for(const[r,s]of e)t[r]={...s,persistedAccessAt:s.lastAccessedAt};if(await _mobileCore.Storage.setItem(INDEX_KEY,JSON.stringify(t)))for(const t of e.values())t.persistedAccessAt=t.lastAccessedAt},schedulePersist=e=>{persistTarget=e,null===appStateSub&&(appStateSub=_reactNative.AppState.addEventListener("change",e=>{"active"!==e&&flushAuthedImageIndex()})),null===persistTimer&&(persistTimer=setTimeout(()=>{flushAuthedImageIndex()},1e3))},flushAuthedImageIndex=async()=>{null!==persistTimer&&(clearTimeout(persistTimer),persistTimer=null);const e=persistTarget;persistTarget=null,null!==e&&await persistIndex(e)};exports.flushAuthedImageIndex=flushAuthedImageIndex;const removeLegacyEntries=async()=>{const e=(await _mobileCore.Storage.getAllKeys()).filter(e=>e.startsWith(LEGACY_PREFIX));e.length>0&&await _mobileCore.Storage.multiRemove(e)},removeOrphanFiles=e=>{try{const t=new Set([...e.values()].map(e=>e.fileName));for(const e of(0,_imageStore.listImageNames)())t.has(e)||(0,_imageStore.deleteImage)(e)}catch(e){_mobileCore.Logger.warn("[@webority/mobile-ui] AuthedImage could not tidy the image cache folder",e)}},readStoredIndex=async()=>{const e=new Map;if(!(0,_mobileCore.isStorageAvailable)())return e;const t=await _mobileCore.Storage.getItem(INDEX_KEY);if(!t)return await removeLegacyEntries(),e;try{const r=JSON.parse(t);if((0,_guards.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)(0,_imageStore.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{(0,_imageStore.deleteImage)(e)}catch(e){_mobileCore.Logger.warn("[@webority/mobile-ui] AuthedImage could not delete a cached image file",e)}},readEntry=async e=>{const t=await loadIndex(),r=t.get(e);return r?(0,_imageStore.imageExists)(r.fileName)?{fileUri:(0,_imageStore.imageUri)(r.fileName),meta:toMeta(r)}:(t.delete(e),indexBytes-=r.bytes,schedulePersist(t),null):null};exports.readEntry=readEntry;const removeEntry=async e=>{const t=await loadIndex(),r=t.get(e);r&&(t.delete(e),indexBytes-=r.bytes,deleteFile(r.fileName),schedulePersist(t))};exports.removeEntry=removeEntry;class AuthedImageHttpError extends Error{constructor(e,t){super(e),this.name="AuthedImageHttpError",this.status=t}}exports.AuthedImageHttpError=AuthedImageHttpError;const isPermanentRefusal=e=>e instanceof AuthedImageHttpError&&e.status>=400&&e.status<500&&408!==e.status&&429!==e.status;exports.isPermanentRefusal=isPermanentRefusal;const isFresh=(e,t,r=Date.now())=>r-e.fetchedAt<t;exports.isFresh=isFresh;const touchEntry=async e=>{const t=await loadIndex(),r=t.get(e);r&&(r.lastAccessedAt=Date.now(),r.lastAccessedAt-r.persistedAccessAt>=36e5&&schedulePersist(t))};exports.touchEntry=touchEntry;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},clearAuthedImageCache=async()=>{null!==persistTimer&&(clearTimeout(persistTimer),persistTimer=null),persistTarget=null;(await loadIndex()).clear(),indexBytes=0,(0,_imageStore.clearImages)(),(0,_mobileCore.isStorageAvailable)()&&await _mobileCore.Storage.removeItem(INDEX_KEY)};exports.clearAuthedImageCache=clearAuthedImageCache;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}};exports.authedImageCacheStats=authedImageCacheStats;const responseHeader=(e,t)=>{if(!(0,_guards.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=(0,_mobileCore.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(0,_mobileCore.getToken)(_mobileCore.ACCESS_TOKEN_KEY);e?.token&&(s.Authorization=`Bearer ${e.token}`)}const i=t.client??_mobileCore.publicClient;let a;try{a=await i.get(t.uri,{headers:s,responseType:"arraybuffer",signal:r})}catch(e){const r=(0,_guards.isRecord)(e)&&(0,_guards.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:o}=a;if(null!=o&&!(o instanceof ArrayBuffer))throw new Error(`[@webority/mobile-ui] AuthedImage could not load "${t.uri}": the client returned ${typeof o} instead of raw bytes. Pass a client that honours \`responseType: "arraybuffer"\`.`);const n=new Uint8Array(o??new ArrayBuffer(0));if(0===n.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(),h=`${e}-${u.toString(36)}`;let m;try{m=await(0,_imageStore.writeImage)(h,n,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 g={fetchedAt:u,bytes:n.byteLength,contentType:c,lastAccessedAt:u,fileName:h,persistedAccessAt:u},p=d.get(e);p&&(indexBytes-=p.bytes),d.set(e,g),indexBytes+=g.bytes,p&&p.fileName!==h&&deleteFile(p.fileName);const y=evictIfNeeded(d);return schedulePersist(d),y>0&&_mobileCore.Logger.info(`[@webority/mobile-ui] AuthedImage evicted ${y} cached image(s) over the byte ceiling`),{fileUri:m,meta:toMeta(g)}},inFlight=new Map,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};exports.acquireFetch=acquireFetch;const releaseFetch=(e,t)=>{t.waiters-=1,t.waiters>0||(inFlight.get(e)===t&&inFlight.delete(e),t.controller.abort())};exports.releaseFetch=releaseFetch;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.avatarToneColors=exports.DEFAULT_AVATAR_LABELS=exports.AvatarGroup=exports.Avatar=exports.AVATAR_COLORS=void 0;var _expoImage=require("expo-image"),_react=require("react"),_reactNative=require("react-native"),_index=require("../../theme/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_color=require("../../utils/color.js"),_corners=require("../../utils/corners.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_hitSlop=require("../../utils/hitSlop.js"),_nativeDriver=require("../../utils/nativeDriver.js"),_index2=require("../AppIcon/index.js"),_slotIcon=require("../AppIcon/slotIcon.js"),_AuthedImage=require("../AuthedImage/AuthedImage.js"),_index3=require("../Skeleton/index.js"),_index4=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const SOFT_FILL_OPACITY=.14,MIN_TOUCH_TARGET=44,PRESSED_OPACITY=.7,INITIALS_MAX_FONT_SCALE=1.2,AVATAR_COLORS=exports.AVATAR_COLORS=["avatar-1","avatar-2","avatar-3","avatar-4","avatar-5","avatar-6","avatar-7","avatar-8"],avatarToneColors=(e,t)=>{const soft=(e,t)=>(0,_color.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"]}}};exports.avatarToneColors=avatarToneColors;const DEFAULT_AVATAR_LABELS=exports.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"}),sizeMap={xs:24,sm:32,md:48,lg:64,xl:80},resolveSize=e=>sizeMap[e],resolveRadius=(e,t,r,s)=>{switch(t){case"circle":return r/2;case"rounded":return s?e.radius[s]: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,s]=t;return void 0===r?"":void 0===s?r.charAt(0).toUpperCase():(r.charAt(0)+s.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 s=t[Math.abs(r)%t.length];if(void 0===s)throw new Error("The avatar colour palette is empty.");return s},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=exports.Avatar=(0,_react.forwardRef)((e,t)=>{const{source:r,ImageComponent:s,imageClient:a,name:o,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:_,color:v,fontSize:b,loading:A=!1,accessibilityLabel:x,onPress:y,onLongPress:f,haptic:R,hitSlop:V,style:j,textStyle:S,testID:C,labels:I}=e;(0,_assertValidValue.assertValidValue)("Avatar","size",e.size,Object.keys(sizeMap)),(0,_assertValidValue.assertValidValue)("Avatar","shape",e.shape,["circle","square","rounded"]),(0,_assertValidValue.assertValidValue)("Avatar","radius",e.radius,["sm","md","lg"]),(0,_assertValidValue.assertValidValue)("Avatar","contentFit",e.contentFit,["cover","contain"]),(0,_assertValidValue.assertValidValue)("Avatar","status",e.status,["online","offline","busy","away","verified","pending"]),(0,_assertValidValue.assertValidValue)("Avatar","statusPosition",e.statusPosition,["topRight","bottomRight"]),(0,_assertValidValue.assertValidValue)("Avatar","tone",e.tone,["primary","success","warning","danger","info","neutral"]);const T=(0,_react.useMemo)(()=>I?{...DEFAULT_AVATAR_LABELS,...I}:DEFAULT_AVATAR_LABELS,[I]),L=(0,_index.useTheme)(),[M,w]=(0,_react.useState)(null),E=(0,_react.useMemo)(()=>l??resolveSize(i),[l,i]),O=(0,_react.useMemo)(()=>resolveRadius(L,n,E,c),[L,n,E,c]),k=u?L.size.border:0,N=L.colors.border,z=L.colors.surface,F=(0,_react.useMemo)(()=>initialsFromName(o),[o]),D=(0,_react.useMemo)(()=>p?avatarToneColors(L,p):null,[L,p]),q=(0,_react.useMemo)(()=>_||(D?.background??L.colors[hashColor(o??"",AVATAR_COLORS)]),[_,D,o,L]),G=v??D?.color??L.colors["on-primary"],U=r?keyOfSource(r):null,P=null!==U&&U!==M,$=!P&&""===F&&null!=m,B=v??D?.color??L.colors["text-subtle"],W=b??Math.max(L.text.xs.size,Math.round(.4*E)),H=Math.max(8,Math.round(.25*E)),Y=isRingStatus(h),X=E-2*(Y?3:k),J=Y?resolveRadius(L,n,X,c):Math.max(0,O-k),K=$?(0,_slotIcon.renderSlotIcon)(m,{color:B,size:Math.round(.45*X),disabled:!1}):null,Q=Y?statusColor(L,h):"transparent",Z=Math.max(12,Math.round(.32*E)),ee=Math.max(10,Z-4),te=_??D?.background??L.colors["bg-muted"],re=P?"contain"===d?"transparent":L.colors["bg-muted"]:$?te:q,se=C??"avatar",ae=o?T.avatarOf(o):T.avatar,oe="verified"===h?`, ${T.verified}`:"pending"===h?`, ${T.pendingVerification}`:"",ie=x??`${ae}${oe}`,ne="function"==typeof y||"function"==typeof f,le=x??`${o||ae}${oe}`,ce=Math.max(0,Math.ceil((44-E)/2)),ue=V??ce,de=[styles.root,{width:E,height:E,borderRadius:O,..._corners.smoothCorners,borderWidth:Y?0:k,borderColor:N,backgroundColor:Y?"transparent":re},j],me=(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[Y?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.ring,{borderRadius:O,..._corners.smoothCorners,borderWidth:1.5,borderColor:Q}],accessible:!1,pointerEvents:"none",testID:`${se}-ring`}):null,(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.picture,{width:X,height:X,borderRadius:J,..._corners.smoothCorners,borderWidth:Y?k:0,borderColor:N,backgroundColor:Y?re:"transparent"}],children:P?(()=>{const e={width:X,height:X,borderRadius:J,..._corners.smoothCorners},onError=()=>w(U),t=uriOfSource(r);return s?(0,_jsxRuntime.jsx)(s,{source:r,onError:onError,style:e,contentFit:d,resizeMode:d,accessibilityIgnoresInvertColors:!0}):a&&void 0!==t?(0,_jsxRuntime.jsx)(_AuthedImage.AuthedImage,{uri:t,client:a,onError:onError,style:e,contentFit:d,placeholder:null,fallback:null,accessibilityIgnoresInvertColors:!0}):(0,_jsxRuntime.jsx)(_expoImage.Image,{source:isImageSourceList(r)?[...r]:r,onError:onError,style:e,contentFit:d,accessibilityIgnoresInvertColors:!0})})():K||(0,_jsxRuntime.jsx)(_index4.Text,{variant:"label",weight:"semibold",numberOfLines:1,maxFontSizeMultiplier:1.2,style:[styles.initials,{color:G,fontSize:W,lineHeight:Math.round(W*L.leading.body)},S],children:F??" "})}),"verified"===h?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.status,"topRight"===g?styles.badgeTopRight:styles.badgeBottomRight,{width:Z,height:Z,borderRadius:Z/2,..._corners.smoothCorners,backgroundColor:z}],accessible:!1,pointerEvents:"none",testID:`${se}-badge`,children:(0,_jsxRuntime.jsx)(_index2.AppIcon,{name:"verify",variant:"bold",size:ee,color:Q})}):null,h&&!Y?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.status,"topRight"===g?styles.statusTopRight:styles.statusBottomRight,{width:H,height:H,borderRadius:H/2,..._corners.smoothCorners,backgroundColor:statusColor(L,h),borderWidth:2,borderColor:z}],accessible:!1,pointerEvents:"none"}):null]}),he=ne?(0,_jsxRuntime.jsx)(_reactNative.Pressable,{ref:t,onPress:y?e=>{const t=(0,_hapticUtils.resolveHaptic)(R,"selection");t&&(0,_hapticUtils.triggerHaptic)(t),y?.(e)}:void 0,onLongPress:f?e=>{const t=(0,_hapticUtils.resolveHaptic)(R,"longPress");t&&(0,_hapticUtils.triggerHaptic)(t),f?.(e)}:void 0,hitSlop:ue,...(0,_hitSlop.hitSlopMarker)(ue),accessibilityRole:"button",accessibilityLabel:le,testID:C,style:({pressed:e})=>[de,e?styles.pressed:null],children:me}):(0,_jsxRuntime.jsx)(_reactNative.View,{ref:t,style:de,accessible:!0,accessibilityRole:"image",accessibilityLabel:ie,testID:C,children:me});return A?(0,_jsxRuntime.jsx)(AvatarSkeleton,{...e}):he});Avatar.displayName="Avatar";const AvatarSkeleton=({size:e="md",shape:t="circle",dimension:r,style:s})=>{const a=r??resolveSize(e),o="circle"===t?"circle":"rounded"===t?"rounded":"rect";return(0,_jsxRuntime.jsx)(_index3.Skeleton,{shape:o,width:a,height:a,style:s})};AvatarSkeleton.displayName="AvatarSkeleton",Avatar.Skeleton=AvatarSkeleton;const styles=_reactNative.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:s,children:a})=>{const o=(0,_index.useTheme)(),i=(0,_react.useRef)((0,_index.createAnimatedValue)(0)).current;return(0,_react.useEffect)(()=>{const t=_reactNative.Animated.timing(i,{toValue:1,duration:220,delay:e,easing:_reactNative.Easing.out(_reactNative.Easing.cubic),useNativeDriver:_nativeDriver.nativeDriver});return t.start(),()=>t.stop()},[e,i]),(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[groupStyles.item,{marginLeft:t,borderRadius:o.radius.pill,borderColor:r,borderWidth:s,opacity:i}],children:a})},AvatarGroup=e=>{const{children:t,max:r=4,size:s="md",spacing:a="normal",overflowVariant:o="count",accessibilityLabel:i,style:n,testID:l,labels:c}=e;(0,_assertValidValue.assertValidValue)("AvatarGroup","spacing",e.spacing,["tight","normal","loose"]),(0,_assertValidValue.assertValidValue)("AvatarGroup","overflowVariant",e.overflowVariant,["count","plus"]),(0,_assertValidValue.assertValidValue)("AvatarGroup","size",e.size,Object.keys(sizeMap));const u=(0,_react.useMemo)(()=>c?{...DEFAULT_AVATAR_LABELS,...c}:DEFAULT_AVATAR_LABELS,[c]),d=(0,_index.useTheme)(),m=(0,_react.useMemo)(()=>_react.Children.toArray(t).filter(e=>(0,_react.isValidElement)(e)),[t]),h=m.length,g=m.slice(0,r),p=Math.max(0,h-r),_=p>0,v=-d.space[SPACING_OFFSET[a]],b=d.colors.surface,A=i??u.groupOf(h),x=(0,_react.useMemo)(()=>resolveSize(s),[s]),y=Math.max(d.text.xs.size,Math.round(.34*x));return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[groupStyles.row,n],accessible:!0,accessibilityLabel:A,accessibilityRole:"summary",testID:l,children:[g.map((e,t)=>{const r=e.key??`avatar-${t}`,a=(0,_react.cloneElement)(e,{size:s,labels:e.props.labels??c});return(0,_jsxRuntime.jsx)(AvatarGroupItem,{delay:50*t,marginLeft:0===t?0:v,borderColor:b,borderWidth:1.5,children:a},r)}),_?(0,_jsxRuntime.jsx)(AvatarGroupItem,{delay:50*g.length,marginLeft:0===g.length?0:v,borderColor:b,borderWidth:1.5,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:[groupStyles.overflow,{width:x,height:x,borderRadius:x/2,..._corners.smoothCorners,backgroundColor:d.colors["surface-disabled"]}],accessible:!0,accessibilityRole:"text",accessibilityLabel:"count"===o?u.moreCount(p):u.moreAvatars,children:(0,_jsxRuntime.jsx)(_index4.Text,{variant:"label",weight:"semibold",color:"secondary",numberOfLines:1,maxFontSizeMultiplier:1.2,style:{fontSize:y,lineHeight:Math.round(y*d.leading.body)},children:"count"===o?`+${p}`:"+"})})},"avatar-overflow"):null]})};exports.AvatarGroup=AvatarGroup;const groupStyles=_reactNative.StyleSheet.create({row:{flexDirection:"row",alignItems:"center"},item:{..._corners.smoothCorners},overflow:{alignItems:"center",justifyContent:"center"}});var _default=exports.default=Avatar;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.avatarToneColors=exports.DEFAULT_AVATAR_LABELS=exports.AvatarGroup=exports.Avatar=exports.AVATAR_COLORS=void 0;var _expoImage=require("expo-image"),_react=require("react"),_reactNative=require("react-native"),_index=require("../../theme/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_color=require("../../utils/color.js"),_corners=require("../../utils/corners.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_hitSlop=require("../../utils/hitSlop.js"),_nativeDriver=require("../../utils/nativeDriver.js"),_index2=require("../AppIcon/index.js"),_slotIcon=require("../AppIcon/slotIcon.js"),_AuthedImage=require("../AuthedImage/AuthedImage.js"),_index3=require("../Skeleton/index.js"),_index4=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const SOFT_FILL_OPACITY=.14,MIN_TOUCH_TARGET=44,PRESSED_OPACITY=.7,INITIALS_MAX_FONT_SCALE=1.2,AVATAR_COLORS=exports.AVATAR_COLORS=["avatar-1","avatar-2","avatar-3","avatar-4","avatar-5","avatar-6","avatar-7","avatar-8"],avatarToneColors=(e,t)=>{const soft=(e,t)=>(0,_color.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"]}}};exports.avatarToneColors=avatarToneColors;const DEFAULT_AVATAR_LABELS=exports.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"}),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,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"]}},AvatarRoot=(0,_react.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:h,status:m=null,statusPosition:p="bottomRight",tone:g,backgroundColor:v,color:_,fontSize:b,loading:x=!1,accessibilityLabel:A,onPress:y,onLongPress:f,haptic:R,hitSlop:V,style:S,textStyle:j,testID:C,labels:I}=e;(0,_assertValidValue.assertValidValue)("Avatar","size",e.size,Object.keys(sizeMap)),(0,_assertValidValue.assertValidValue)("Avatar","shape",e.shape,["circle","square","rounded"]),(0,_assertValidValue.assertValidValue)("Avatar","radius",e.radius,["sm","md","lg"]),(0,_assertValidValue.assertValidValue)("Avatar","contentFit",e.contentFit,["cover","contain"]),(0,_assertValidValue.assertValidValue)("Avatar","status",e.status,["online","offline","busy","away","verified","pending"]),(0,_assertValidValue.assertValidValue)("Avatar","statusPosition",e.statusPosition,["topRight","bottomRight"]),(0,_assertValidValue.assertValidValue)("Avatar","tone",e.tone,["primary","success","warning","danger","info","neutral"]);const T=(0,_react.useMemo)(()=>I?{...DEFAULT_AVATAR_LABELS,...I}:DEFAULT_AVATAR_LABELS,[I]),L=(0,_index.useTheme)(),[w,M]=(0,_react.useState)(null),E=(0,_react.useMemo)(()=>l??resolveSize(i),[l,i]),O=(0,_react.useMemo)(()=>resolveRadius(L,n,E,c),[L,n,E,c]),k=u?L.size.border:0,N=L.colors.border,z=L.colors.surface,F=(0,_react.useMemo)(()=>initialsFromName(a),[a]),D=(0,_react.useMemo)(()=>g?avatarToneColors(L,g):null,[L,g]),q=(0,_react.useMemo)(()=>v||(D?.background??L.colors[hashColor(a??"",AVATAR_COLORS)]),[v,D,a,L]),G=_??D?.color??L.colors["on-primary"],U=r?keyOfSource(r):null,P=(0,_react.useMemo)(()=>void 0!==r?toExpoSources(r):void 0,[r]),$=null!==U&&U!==w,B=!$&&""===F&&null!=h,W=_??D?.color??L.colors["text-subtle"],H=b??Math.max(L.text.xs.size,Math.round(.4*E)),Y=Math.max(8,Math.round(.25*E)),X=isRingStatus(m),J=E-2*(X?3:k),K=X?resolveRadius(L,n,J,c):Math.max(0,O-k),Q=B?(0,_slotIcon.renderSlotIcon)(h,{color:W,size:Math.round(.45*J),disabled:!1}):null,Z=X?statusColor(L,m):"transparent",ee=Math.max(12,Math.round(.32*E)),te=Math.max(10,ee-4),re=v??D?.background??L.colors["bg-muted"],oe=$?"contain"===d?"transparent":L.colors["bg-muted"]:B?re:q,se=C??"avatar",ae=a?T.avatarOf(a):T.avatar,ie="verified"===m?`, ${T.verified}`:"pending"===m?`, ${T.pendingVerification}`:"",ne=A??`${ae}${ie}`,le="function"==typeof y||"function"==typeof f,ce=A??`${a||ae}${ie}`,ue=Math.max(0,Math.ceil((44-E)/2)),de=V??ue,he=[styles.root,{width:E,height:E,borderRadius:O,..._corners.smoothCorners,borderWidth:X?0:k,borderColor:N,backgroundColor:X?"transparent":oe},S],me=(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[X?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.ring,{borderRadius:O,..._corners.smoothCorners,borderWidth:1.5,borderColor:Z}],accessible:!1,pointerEvents:"none",testID:`${se}-ring`}):null,(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.picture,{width:J,height:J,borderRadius:K,..._corners.smoothCorners,borderWidth:X?k:0,borderColor:N,backgroundColor:X?oe:"transparent"}],children:$?(()=>{const e={width:J,height:J,borderRadius:K,..._corners.smoothCorners};if(!r)return null;const onError=()=>M(U),t=uriOfSource(r);return o?(0,_jsxRuntime.jsx)(o,{source:r,onError:onError,style:e,contentFit:d,resizeMode:d,accessibilityIgnoresInvertColors:!0}):s&&void 0!==t?(0,_jsxRuntime.jsx)(_AuthedImage.AuthedImage,{uri:t,client:s,onError:onError,style:e,contentFit:d,placeholder:null,fallback:null,accessibilityIgnoresInvertColors:!0}):(0,_jsxRuntime.jsx)(_expoImage.Image,{...void 0!==P?{source:P}:{},onError:onError,style:e,contentFit:d,accessibilityIgnoresInvertColors:!0})})():Q||(0,_jsxRuntime.jsx)(_index4.Text,{variant:"label",weight:"semibold",numberOfLines:1,maxFontSizeMultiplier:1.2,style:[styles.initials,{color:G,fontSize:H,lineHeight:Math.round(H*L.leading.body)},j],children:F??" "})}),"verified"===m?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.status,"topRight"===p?styles.badgeTopRight:styles.badgeBottomRight,{width:ee,height:ee,borderRadius:ee/2,..._corners.smoothCorners,backgroundColor:z}],accessible:!1,pointerEvents:"none",testID:`${se}-badge`,children:(0,_jsxRuntime.jsx)(_index2.AppIcon,{name:"verify",variant:"bold",size:te,color:Z})}):null,m&&!X?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.status,"topRight"===p?styles.statusTopRight:styles.statusBottomRight,{width:Y,height:Y,borderRadius:Y/2,..._corners.smoothCorners,backgroundColor:statusColor(L,m),borderWidth:2,borderColor:z}],accessible:!1,pointerEvents:"none"}):null]}),pe=le?(0,_jsxRuntime.jsx)(_reactNative.Pressable,{ref:t,onPress:y?e=>{const t=(0,_hapticUtils.resolveHaptic)(R,"selection");t&&(0,_hapticUtils.triggerHaptic)(t),y?.(e)}:void 0,onLongPress:f?e=>{const t=(0,_hapticUtils.resolveHaptic)(R,"longPress");t&&(0,_hapticUtils.triggerHaptic)(t),f?.(e)}:void 0,hitSlop:de,...(0,_hitSlop.hitSlopMarker)(de),accessibilityRole:"button",accessibilityLabel:ce,testID:C,style:({pressed:e})=>[he,e?styles.pressed:null],children:me}):(0,_jsxRuntime.jsx)(_reactNative.View,{ref:t,style:he,accessible:!0,accessibilityRole:"image",accessibilityLabel:ne,testID:C,children:me});return x?(0,_jsxRuntime.jsx)(AvatarSkeleton,{...e}):pe}),AvatarSkeleton=({size:e="md",shape:t="circle",dimension:r,style:o})=>{const s=r??resolveSize(e),a="circle"===t?"circle":"rounded"===t?"rounded":"rect";return(0,_jsxRuntime.jsx)(_index3.Skeleton,{shape:a,width:s,height:s,style:o})};AvatarSkeleton.displayName="AvatarSkeleton";const Avatar=exports.Avatar=Object.assign(AvatarRoot,{Skeleton:AvatarSkeleton});Avatar.displayName="Avatar";const styles=_reactNative.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=(0,_index.useTheme)(),i=(0,_react.useRef)((0,_index.createAnimatedValue)(0)).current;return(0,_react.useEffect)(()=>{const t=_reactNative.Animated.timing(i,{toValue:1,duration:220,delay:e,easing:_reactNative.Easing.out(_reactNative.Easing.cubic),useNativeDriver:_nativeDriver.nativeDriver});return t.start(),()=>t.stop()},[e,i]),(0,_jsxRuntime.jsx)(_reactNative.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;(0,_assertValidValue.assertValidValue)("AvatarGroup","spacing",e.spacing,["tight","normal","loose"]),(0,_assertValidValue.assertValidValue)("AvatarGroup","overflowVariant",e.overflowVariant,["count","plus"]),(0,_assertValidValue.assertValidValue)("AvatarGroup","size",e.size,Object.keys(sizeMap));const u=(0,_react.useMemo)(()=>c?{...DEFAULT_AVATAR_LABELS,...c}:DEFAULT_AVATAR_LABELS,[c]),d=(0,_index.useTheme)(),h=(0,_react.useMemo)(()=>_react.Children.toArray(t).filter(e=>(0,_react.isValidElement)(e)),[t]),m=h.length,p=h.slice(0,r),g=Math.max(0,m-r),v=g>0,_=-d.space[SPACING_OFFSET[s]],b=d.colors.surface,x=i??u.groupOf(m),A=(0,_react.useMemo)(()=>resolveSize(o),[o]),y=Math.max(d.text.xs.size,Math.round(.34*A));return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[groupStyles.row,n],accessible:!0,accessibilityLabel:x,accessibilityRole:"summary",testID:l,children:[p.map((e,t)=>{const r=e.key??`avatar-${t}`,s=(0,_react.cloneElement)(e,{size:o,labels:e.props.labels??c});return(0,_jsxRuntime.jsx)(AvatarGroupItem,{delay:50*t,marginLeft:0===t?0:_,borderColor:b,borderWidth:1.5,children:s},r)}),v?(0,_jsxRuntime.jsx)(AvatarGroupItem,{delay:50*p.length,marginLeft:0===p.length?0:_,borderColor:b,borderWidth:1.5,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:[groupStyles.overflow,{width:A,height:A,borderRadius:A/2,..._corners.smoothCorners,backgroundColor:d.colors["surface-disabled"]}],accessible:!0,accessibilityRole:"text",accessibilityLabel:"count"===a?u.moreCount(g):u.moreAvatars,children:(0,_jsxRuntime.jsx)(_index4.Text,{variant:"label",weight:"semibold",color:"secondary",numberOfLines:1,maxFontSizeMultiplier:1.2,style:{fontSize:y,lineHeight:Math.round(y*d.leading.body)},children:"count"===a?`+${g}`:"+"})})},"avatar-overflow"):null]})};exports.AvatarGroup=AvatarGroup;const groupStyles=_reactNative.StyleSheet.create({row:{flexDirection:"row",alignItems:"center"},item:{..._corners.smoothCorners},overflow:{alignItems:"center",justifyContent:"center"}});var _default=exports.default=Avatar;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.DEFAULT_BADGE_LABELS=exports.Badge=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../../theme/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_corners=require("../../utils/corners.js"),_nativeDriver=require("../../utils/nativeDriver.js"),_index2=require("../Skeleton/index.js"),_index3=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_BADGE_LABELS=exports.DEFAULT_BADGE_LABELS=Object.freeze({indicator:"Notification indicator",unread:e=>`${e} unread`}),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 r=-t;switch(e){case"topLeft":return{top:r,left:r};case"bottomRight":return{bottom:r,right:r};case"bottomLeft":return{bottom:r,left:r};default:return{top:r,right:r}}},formatValue=(e,t)=>{if(null==e)return null;if("number"==typeof e)return e<=0?null:e>t?`${t}+`:String(e);const r=String(e);return 0===r.length?null:r},Badge=exports.Badge=(0,_react.forwardRef)((e,t)=>{const{value:r,max:i=99,variant:o="standard",tone:a="danger",size:s="sm",fill:n="solid",accessible:l=!0,invisible:d=!1,loading:c=!1,children:u,anchor:g="topRight",pulse:h=!1,accessibilityLabel:m,labels:x,style:_,badgeStyle:f,textStyle:b,testID:v}=e;(0,_assertValidValue.assertValidValue)("Badge","variant",e.variant,["standard","dot"]),(0,_assertValidValue.assertValidValue)("Badge","tone",e.tone,["primary","success","warning","danger","neutral","info"]),(0,_assertValidValue.assertValidValue)("Badge","size",e.size,["sm","md"]),(0,_assertValidValue.assertValidValue)("Badge","anchor",e.anchor,["topRight","topLeft","bottomRight","bottomLeft"]),(0,_assertValidValue.assertValidValue)("Badge","fill",e.fill,["solid","soft"]);const p=(0,_react.useMemo)(()=>({...DEFAULT_BADGE_LABELS,...x}),[x]),y=(0,_index.useTheme)(),V=(0,_react.useMemo)(()=>"soft"===n?softToneFor(y,a):toneFor(y,a),[y,a,n]),j=(0,_index.resolveBadgeSize)(y,s),w=y.components.badge["border-width"],B=y.components.badge["anchor-offset"],S="dot"===o?null:formatValue(r,i),k=!d&&("dot"===o||null!==S),L=(0,_react.useRef)((0,_index.createAnimatedValue)(1)).current;(0,_react.useEffect)(()=>{if(!h||!k)return void(0,_index.setNativeValue)(L,1);const e=_reactNative.Animated.loop(_reactNative.Animated.sequence([_reactNative.Animated.timing(L,{toValue:1.15,duration:y.motion.duration.slow,easing:_reactNative.Easing.bezier(...y.motion.ease["in-out"]),useNativeDriver:_nativeDriver.nativeDriver}),_reactNative.Animated.timing(L,{toValue:1,duration:y.motion.duration.slow,easing:_reactNative.Easing.bezier(...y.motion.ease["in-out"]),useNativeDriver:_nativeDriver.nativeDriver})]));return e.start(),()=>{e.stop()}},[h,k,L,y]);const R="dot"===o,A=R?"image":"text",D=m??(R?p.indicator:S?p.unread(S):void 0),N=k?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[styles.badge,R?{width:j["dot-size"],height:j["dot-size"],borderRadius:j["dot-size"]/2,..._corners.smoothCorners,paddingHorizontal:0}:{minWidth:j["min-width"],minHeight:j.height,borderRadius:y.radius.pill,..._corners.smoothCorners,paddingHorizontal:j["padding-x"]},{backgroundColor:V.background,transform:[{scale:L}]},u?{position:"absolute",borderWidth:w,borderColor:y.colors.surface,...anchorPosition(g,B)}:null,f],accessible:l,importantForAccessibility:l?void 0:"no-hide-descendants",accessibilityElementsHidden:!l||void 0,accessibilityRole:l?A:void 0,accessibilityLabel:l?D:void 0,children:R||null===S?null:(0,_jsxRuntime.jsx)(_index3.Text,{variant:"caption",weight:"soft"===n?"semibold":"bold",numberOfLines:1,style:[styles.text,{color:V.text,fontSize:j.text,lineHeight:Math.round(j.text*y.leading.body)},b],children:S??" "})}):null,z=u?(0,_jsxRuntime.jsxs)(_reactNative.View,{ref:t,style:[styles.wrapper,_],testID:v,children:[u,N]}):(0,_jsxRuntime.jsx)(_reactNative.View,{ref:t,style:_,testID:v,children:N});return c?(0,_jsxRuntime.jsx)(BadgeSkeleton,{...e}):z});Badge.displayName="Badge";const BadgeSkeleton=({variant:e="standard",size:t="md",children:r,anchor:i,style:o,badgeStyle:a})=>{const s=(0,_index.useTheme)(),n=(0,_index.resolveBadgeSize)(s,t);if("dot"===e)return(0,_jsxRuntime.jsx)(_index2.Skeleton,{shape:"circle",width:n["dot-size"],height:n["dot-size"],style:[a,o]});const l=n.height/2;if(void 0!==r){const e="topLeft"===i?{top:-n.height/2,left:-n.height/2}:"bottomRight"===i?{bottom:-n.height/2,right:-n.height/2}:"bottomLeft"===i?{bottom:-n.height/2,left:-n.height/2}:{top:-n.height/2,right:-n.height/2};return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[styles.wrapper,o],children:[r,(0,_jsxRuntime.jsx)(_reactNative.View,{style:[{position:"absolute"},e],children:(0,_jsxRuntime.jsx)(_index2.Skeleton,{width:n["min-width"]+n["padding-x"],height:n.height,radius:l,style:a})})]})}return(0,_jsxRuntime.jsx)(_index2.Skeleton,{width:n["min-width"]+n["padding-x"],height:n.height,radius:l,style:[a,o]})};BadgeSkeleton.displayName="BadgeSkeleton",Badge.Skeleton=BadgeSkeleton;const styles=_reactNative.StyleSheet.create({wrapper:{position:"relative",alignSelf:"flex-start"},badge:{alignItems:"center",justifyContent:"center",flexDirection:"row"},text:{textAlign:"center",includeFontPadding:!1}});var _default=exports.default=Badge;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.DEFAULT_BADGE_LABELS=exports.Badge=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../../theme/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_corners=require("../../utils/corners.js"),_nativeDriver=require("../../utils/nativeDriver.js"),_index2=require("../Skeleton/index.js"),_index3=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_BADGE_LABELS=exports.DEFAULT_BADGE_LABELS=Object.freeze({indicator:"Notification indicator",unread:e=>`${e} unread`}),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 r=-t;switch(e){case"topLeft":return{top:r,left:r};case"bottomRight":return{bottom:r,right:r};case"bottomLeft":return{bottom:r,left:r};default:return{top:r,right:r}}},formatValue=(e,t)=>{if(null==e)return null;if("number"==typeof e)return e<=0?null:e>t?`${t}+`:String(e);const r=String(e);return 0===r.length?null:r},BadgeRoot=(0,_react.forwardRef)((e,t)=>{const{value:r,max:i=99,variant:o="standard",tone:a="danger",size:s="sm",fill:n="solid",accessible:l=!0,invisible:d=!1,loading:c=!1,children:u,anchor:g="topRight",pulse:h=!1,accessibilityLabel:m,labels:x,style:_,badgeStyle:f,textStyle:b,testID:v}=e;(0,_assertValidValue.assertValidValue)("Badge","variant",e.variant,["standard","dot"]),(0,_assertValidValue.assertValidValue)("Badge","tone",e.tone,["primary","success","warning","danger","neutral","info"]),(0,_assertValidValue.assertValidValue)("Badge","size",e.size,["sm","md"]),(0,_assertValidValue.assertValidValue)("Badge","anchor",e.anchor,["topRight","topLeft","bottomRight","bottomLeft"]),(0,_assertValidValue.assertValidValue)("Badge","fill",e.fill,["solid","soft"]);const p=(0,_react.useMemo)(()=>({...DEFAULT_BADGE_LABELS,...x}),[x]),y=(0,_index.useTheme)(),V=(0,_react.useMemo)(()=>"soft"===n?softToneFor(y,a):toneFor(y,a),[y,a,n]),j=(0,_index.resolveBadgeSize)(y,s),w=y.components.badge["border-width"],B=y.components.badge["anchor-offset"],S="dot"===o?null:formatValue(r,i),k=!d&&("dot"===o||null!==S),R=(0,_react.useRef)((0,_index.createAnimatedValue)(1)).current;(0,_react.useEffect)(()=>{if(!h||!k)return void(0,_index.setNativeValue)(R,1);const e=_reactNative.Animated.loop(_reactNative.Animated.sequence([_reactNative.Animated.timing(R,{toValue:1.15,duration:y.motion.duration.slow,easing:_reactNative.Easing.bezier(...y.motion.ease["in-out"]),useNativeDriver:_nativeDriver.nativeDriver}),_reactNative.Animated.timing(R,{toValue:1,duration:y.motion.duration.slow,easing:_reactNative.Easing.bezier(...y.motion.ease["in-out"]),useNativeDriver:_nativeDriver.nativeDriver})]));return e.start(),()=>{e.stop()}},[h,k,R,y]);const L="dot"===o,A=L?"image":"text",D=m??(L?p.indicator:S?p.unread(S):void 0),N=k?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:[styles.badge,L?{width:j["dot-size"],height:j["dot-size"],borderRadius:j["dot-size"]/2,..._corners.smoothCorners,paddingHorizontal:0}:{minWidth:j["min-width"],minHeight:j.height,borderRadius:y.radius.pill,..._corners.smoothCorners,paddingHorizontal:j["padding-x"]},{backgroundColor:V.background,transform:[{scale:R}]},u?{position:"absolute",borderWidth:w,borderColor:y.colors.surface,...anchorPosition(g,B)}:null,f],accessible:l,importantForAccessibility:l?void 0:"no-hide-descendants",accessibilityElementsHidden:!l||void 0,accessibilityRole:l?A:void 0,accessibilityLabel:l?D:void 0,children:L||null===S?null:(0,_jsxRuntime.jsx)(_index3.Text,{variant:"caption",weight:"soft"===n?"semibold":"bold",numberOfLines:1,style:[styles.text,{color:V.text,fontSize:j.text,lineHeight:Math.round(j.text*y.leading.body)},b],children:S??" "})}):null,z=u?(0,_jsxRuntime.jsxs)(_reactNative.View,{ref:t,style:[styles.wrapper,_],testID:v,children:[u,N]}):(0,_jsxRuntime.jsx)(_reactNative.View,{ref:t,style:_,testID:v,children:N});return c?(0,_jsxRuntime.jsx)(BadgeSkeleton,{...e}):z}),BadgeSkeleton=({variant:e="standard",size:t="md",children:r,anchor:i,style:o,badgeStyle:a})=>{const s=(0,_index.useTheme)(),n=(0,_index.resolveBadgeSize)(s,t);if("dot"===e)return(0,_jsxRuntime.jsx)(_index2.Skeleton,{shape:"circle",width:n["dot-size"],height:n["dot-size"],style:[a,o]});const l=n.height/2;if(void 0!==r){const e="topLeft"===i?{top:-n.height/2,left:-n.height/2}:"bottomRight"===i?{bottom:-n.height/2,right:-n.height/2}:"bottomLeft"===i?{bottom:-n.height/2,left:-n.height/2}:{top:-n.height/2,right:-n.height/2};return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[styles.wrapper,o],children:[r,(0,_jsxRuntime.jsx)(_reactNative.View,{style:[{position:"absolute"},e],children:(0,_jsxRuntime.jsx)(_index2.Skeleton,{width:n["min-width"]+n["padding-x"],height:n.height,radius:l,style:a})})]})}return(0,_jsxRuntime.jsx)(_index2.Skeleton,{width:n["min-width"]+n["padding-x"],height:n.height,radius:l,style:[a,o]})};BadgeSkeleton.displayName="BadgeSkeleton";const Badge=exports.Badge=Object.assign(BadgeRoot,{Skeleton:BadgeSkeleton});Badge.displayName="Badge";const styles=_reactNative.StyleSheet.create({wrapper:{position:"relative",alignSelf:"flex-start"},badge:{alignItems:"center",justifyContent:"center",flexDirection:"row"},text:{textAlign:"center",includeFontPadding:!1}});var _default=exports.default=Badge;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.DEFAULT_BANNER_LABELS=exports.Banner=void 0;var _react=require("react"),_reactNative=require("react-native"),_usePresenceMotion=require("../../hooks/usePresenceMotion.js"),_index=require("../../theme/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_corners=require("../../utils/corners.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_hitSlop=require("../../utils/hitSlop.js"),_nativeDriver=require("../../utils/nativeDriver.js"),_slotIcon=require("../AppIcon/slotIcon.js"),_index2=require("../IconBadge/index.js"),_index3=require("../Skeleton/index.js"),_index4=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_BANNER_LABELS=exports.DEFAULT_BANNER_LABELS=Object.freeze({dismiss:"Dismiss banner"}),Banner=exports.Banner=(0,_react.forwardRef)((e,t)=>{const{title:r,message:i,tone:s="neutral",variant:n="bar",icon:a,actions:o,dismissible:l=!1,onClose:c,haptic:d,open:u=!0,animateMount:m=!0,loading:x=!1,accessibilityRole:p="alert",accessibilityLabel:_,labels:g,style:h,containerStyle:y,iconCircleStyle:b,tintBarStyle:v,closeButtonStyle:j,actionButtonStyle:f,testID:R}=e;(0,_assertValidValue.assertValidValue)("Banner","tone",e.tone,["primary","success","warning","danger","info","neutral"]),(0,_assertValidValue.assertValidValue)("Banner","variant",e.variant,["bar","wash","tint"]),(0,_assertValidValue.assertValidValue)("Banner","accessibilityRole",e.accessibilityRole,["alert","summary","none"]);const w=(0,_index.useTheme)(),V=(0,_usePresenceMotion.usePresenceMotion)(),B=(0,_react.useMemo)(()=>buildStyles(w),[w]),S=(0,_react.useMemo)(()=>tintFor(w,s),[w,s]),N=(0,_react.useMemo)(()=>({...DEFAULT_BANNER_LABELS,...g}),[g]),[C,k]=V.range(-20,0),D=(0,_react.useRef)((0,_index.createAnimatedValue)(m&&u?C:0)).current,A=(0,_react.useRef)((0,_index.createAnimatedValue)(m&&u?0:u?1:0)).current,[L,I]=(0,_react.useState)(u),E=(0,_react.useRef)(!0);if((0,_react.useEffect)(()=>{if(E.current&&(E.current=!1,!m))return;let e;return u?(I(!0),e=_reactNative.Animated.parallel([_reactNative.Animated.timing(D,{toValue:k,duration:w.motion.duration.default,useNativeDriver:_nativeDriver.nativeDriver}),_reactNative.Animated.timing(A,{toValue:1,duration:V.duration("default"),useNativeDriver:_nativeDriver.nativeDriver})]),e.start()):L&&(e=_reactNative.Animated.parallel([_reactNative.Animated.timing(D,{toValue:C,duration:w.motion.duration.fast,useNativeDriver:_nativeDriver.nativeDriver}),_reactNative.Animated.timing(A,{toValue:0,duration:V.duration("fast"),useNativeDriver:_nativeDriver.nativeDriver})]),e.start(()=>{I(!1)})),()=>e?.stop()},[u]),!L)return null;const T=r??" ",q="string"==typeof i?i??" ":"",H="wash"===n,M="bar"!==n,z="alert"===p?"danger"===s?"assertive":"polite":"none",P=(0,_jsxRuntime.jsxs)(_reactNative.Animated.View,{ref:t,accessibilityRole:p,accessibilityLiveRegion:z,accessibilityLabel:_,testID:R,style:[B.container,{backgroundColor:M?S.soft:w.colors["bg-subtle"],borderRadius:H?w.radius.sm:w.radius.md,..._corners.smoothCorners,padding:w.space.md,opacity:A,transform:[{translateY:D}]},y,h],children:[!H&&w.components.banner["tint-bar-width"]>0?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[B.tintBar,{backgroundColor:S.bar},v]}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[B.row,void 0===r&&B.rowCentred],children:[!1===a?null:a?(0,_jsxRuntime.jsx)(_reactNative.View,{style:B.iconWrap,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:(0,_slotIcon.renderSlotIcon)(a,{color:S.ink,size:w.text.xl.size,disabled:!1})}):(0,_jsxRuntime.jsx)(_index2.IconBadge,{dimension:ICON_CIRCLE_SIZE,color:S.bar,icon:(0,_jsxRuntime.jsx)(_index4.Text,{variant:"body",weight:"bold",accessible:!1,style:[B.iconGlyph,{color:S.ink}],children:S.glyph}),style:[B.iconCircle,b]}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:B.textBlock,children:[r||x?(0,_jsxRuntime.jsx)(_index4.Text,{variant:"body",weight:"semibold",numberOfLines:2,style:{lineHeight:20,...H?{color:S.ink}:null},children:T}):null,"string"==typeof i||x?(0,_jsxRuntime.jsx)(_index4.Text,{variant:"bodySmall",color:"secondary",style:{lineHeight:18,marginTop:r?w.space.xxs:0},children:q||" "}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:{marginTop:r?w.space.xxs:0},children:i})]}),l?(0,_jsxRuntime.jsx)(_reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:N.dismiss,onPress:()=>{const e=(0,_hapticUtils.resolveHaptic)(d,"selection");e&&(0,_hapticUtils.triggerHaptic)(e),c?.()},hitSlop:8,...(0,_hitSlop.hitSlopMarker)(8),style:({pressed:e})=>[B.closeBtn,{backgroundColor:e?w.colors["surface-pressed"]:"transparent"},j],children:(0,_jsxRuntime.jsx)(_index4.Text,{variant:"title",weight:"bold",color:"secondary",accessible:!1,style:{lineHeight:17},children:"×"})}):null]}),o&&o.length>0?(0,_jsxRuntime.jsx)(_reactNative.View,{style:B.actionsRow,children:o.map((e,t)=>{(0,_assertValidValue.assertValidValue)("Banner","action.tone",e.tone,["primary","success","warning","danger","info","neutral"]),(0,_assertValidValue.assertValidValue)("Banner","action.variant",e.variant,["solid","outline","ghost"]),(0,_assertValidValue.assertValidValue)("Banner","action.size",e.size,["sm","md"]);const r=e.tone??"primary",i=e.variant??"ghost",s="primary"===r?S.glyphColor:"neutral"===r?w.colors["text-muted"]:w.colors[r],n="primary"===r?S.ink:"neutral"===r?w.colors["text-muted"]:w.colors[`${r}-text`],a="primary"===r?S.on:"neutral"===r?w.colors["on-neutral-strong"]:w.colors[`on-${r}`],o="solid"===i;return(0,_jsxRuntime.jsx)(_reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:e.label,testID:e.testID,onPress:()=>{const t=(0,_hapticUtils.resolveHaptic)(d,"selection");t&&(0,_hapticUtils.triggerHaptic)(t),e.onPress()},style:({pressed:t})=>[B.actionBtn,"md"===e.size&&B.actionBtnMd,"outline"===i&&{borderWidth:1,borderColor:n},{backgroundColor:o?s:t?w.colors["surface-pressed"]:"transparent",opacity:o&&t?.85:1},f],children:(0,_jsxRuntime.jsx)(_index4.Text,{variant:"bodySmall",weight:"semibold",align:"center",style:{color:o?a:n},children:e.label})},`${e.label}-${t}`)})}):null]});return x?(0,_jsxRuntime.jsx)(BannerSkeleton,{...e}):P});Banner.displayName="Banner";const BannerSkeleton=({title:e,actions:t,icon:r,containerStyle:i,style:s})=>{const n=(0,_index.useTheme)(),a=!1!==r;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[{flexDirection:"row",alignItems:"flex-start",backgroundColor:n.colors.surface,borderRadius:n.radius.md,..._corners.smoothCorners,padding:n.space.md,borderWidth:1,borderColor:n.colors.border},i,s],accessibilityRole:"progressbar",accessibilityState:{busy:!0},"aria-busy":!0,children:[a?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{marginRight:n.space.sm},children:(0,_jsxRuntime.jsx)(_index3.Skeleton,{shape:"circle",width:32,height:32})}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flex:1},children:[void 0!==e?(0,_jsxRuntime.jsx)(_index3.Skeleton,{shape:"text",width:"55%",height:16,style:{marginBottom:n.space.xs}}):null,(0,_jsxRuntime.jsx)(_index3.SkeletonText,{lines:2,fontSize:n.text.sm.size,lastLineWidth:"70%"}),t&&t.length>0?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{flexDirection:"row",marginTop:n.space.sm},children:t.map((e,t)=>(0,_jsxRuntime.jsx)(_index3.Skeleton,{width:72,height:28,shape:"rounded",style:{marginRight:n.space.sm}},`sk-banner-action-${t}`))}):null]})]})};BannerSkeleton.displayName="BannerSkeleton",Banner.Skeleton=BannerSkeleton;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 _reactNative.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:17},textBlock:{flex:1,paddingRight:e.space.xs},closeBtn:{width:28,height:28,borderRadius:e.radius.pill,..._corners.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,..._corners.smoothCorners,maxWidth:"100%",alignItems:"center",justifyContent:"center"},actionBtnMd:{minHeight:44,paddingHorizontal:e.space.md}})};var _default=exports.default=Banner;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.DEFAULT_BANNER_LABELS=exports.Banner=void 0;var _react=require("react"),_reactNative=require("react-native"),_usePresenceMotion=require("../../hooks/usePresenceMotion.js"),_index=require("../../theme/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_corners=require("../../utils/corners.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_hitSlop=require("../../utils/hitSlop.js"),_nativeDriver=require("../../utils/nativeDriver.js"),_slotIcon=require("../AppIcon/slotIcon.js"),_index2=require("../IconBadge/index.js"),_index3=require("../Skeleton/index.js"),_index4=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_BANNER_LABELS=exports.DEFAULT_BANNER_LABELS=Object.freeze({dismiss:"Dismiss banner"}),BannerRoot=(0,_react.forwardRef)((e,t)=>{const{title:r,message:i,tone:s="neutral",variant:n="bar",icon:a,actions:o,dismissible:l=!1,onClose:c,haptic:d,open:u=!0,animateMount:m=!0,loading:x=!1,accessibilityRole:p="alert",accessibilityLabel:_,labels:g,style:h,containerStyle:y,iconCircleStyle:b,tintBarStyle:v,closeButtonStyle:j,actionButtonStyle:f,testID:R}=e;(0,_assertValidValue.assertValidValue)("Banner","tone",e.tone,["primary","success","warning","danger","info","neutral"]),(0,_assertValidValue.assertValidValue)("Banner","variant",e.variant,["bar","wash","tint"]),(0,_assertValidValue.assertValidValue)("Banner","accessibilityRole",e.accessibilityRole,["alert","summary","none"]);const w=(0,_index.useTheme)(),V=(0,_usePresenceMotion.usePresenceMotion)(),B=(0,_react.useMemo)(()=>buildStyles(w),[w]),S=(0,_react.useMemo)(()=>tintFor(w,s),[w,s]),N=(0,_react.useMemo)(()=>({...DEFAULT_BANNER_LABELS,...g}),[g]),[C,k]=V.range(-20,0),D=(0,_react.useRef)((0,_index.createAnimatedValue)(m&&u?C:0)).current,A=(0,_react.useRef)((0,_index.createAnimatedValue)(m&&u?0:u?1:0)).current,[L,I]=(0,_react.useState)(u),E=(0,_react.useRef)(!0);if((0,_react.useEffect)(()=>{if(E.current&&(E.current=!1,!m))return;let e;return u?(I(!0),e=_reactNative.Animated.parallel([_reactNative.Animated.timing(D,{toValue:k,duration:w.motion.duration.default,useNativeDriver:_nativeDriver.nativeDriver}),_reactNative.Animated.timing(A,{toValue:1,duration:V.duration("default"),useNativeDriver:_nativeDriver.nativeDriver})]),e.start()):L&&(e=_reactNative.Animated.parallel([_reactNative.Animated.timing(D,{toValue:C,duration:w.motion.duration.fast,useNativeDriver:_nativeDriver.nativeDriver}),_reactNative.Animated.timing(A,{toValue:0,duration:V.duration("fast"),useNativeDriver:_nativeDriver.nativeDriver})]),e.start(()=>{I(!1)})),()=>e?.stop()},[u]),!L)return null;const T=r??" ",q="string"==typeof i?i??" ":"",H="wash"===n,M="bar"!==n,z="alert"===p?"danger"===s?"assertive":"polite":"none",P=(0,_jsxRuntime.jsxs)(_reactNative.Animated.View,{ref:t,accessibilityRole:p,accessibilityLiveRegion:z,accessibilityLabel:_,testID:R,style:[B.container,{backgroundColor:M?S.soft:w.colors["bg-subtle"],borderRadius:H?w.radius.sm:w.radius.md,..._corners.smoothCorners,padding:w.space.md,opacity:A,transform:[{translateY:D}]},y,h],children:[!H&&w.components.banner["tint-bar-width"]>0?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[B.tintBar,{backgroundColor:S.bar},v]}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[B.row,void 0===r&&B.rowCentred],children:[!1===a?null:a?(0,_jsxRuntime.jsx)(_reactNative.View,{style:B.iconWrap,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:(0,_slotIcon.renderSlotIcon)(a,{color:S.ink,size:w.text.xl.size,disabled:!1})}):(0,_jsxRuntime.jsx)(_index2.IconBadge,{dimension:ICON_CIRCLE_SIZE,color:S.bar,icon:(0,_jsxRuntime.jsx)(_index4.Text,{variant:"body",weight:"bold",accessible:!1,style:[B.iconGlyph,{color:S.ink}],children:S.glyph}),style:[B.iconCircle,b]}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:B.textBlock,children:[r||x?(0,_jsxRuntime.jsx)(_index4.Text,{variant:"body",weight:"semibold",numberOfLines:2,style:{lineHeight:20,...H?{color:S.ink}:null},children:T}):null,"string"==typeof i||x?(0,_jsxRuntime.jsx)(_index4.Text,{variant:"bodySmall",color:"secondary",style:{lineHeight:18,marginTop:r?w.space.xxs:0},children:q||" "}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:{marginTop:r?w.space.xxs:0},children:i})]}),l?(0,_jsxRuntime.jsx)(_reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:N.dismiss,onPress:()=>{const e=(0,_hapticUtils.resolveHaptic)(d,"selection");e&&(0,_hapticUtils.triggerHaptic)(e),c?.()},hitSlop:8,...(0,_hitSlop.hitSlopMarker)(8),style:({pressed:e})=>[B.closeBtn,{backgroundColor:e?w.colors["surface-pressed"]:"transparent"},j],children:(0,_jsxRuntime.jsx)(_index4.Text,{variant:"title",weight:"bold",color:"secondary",accessible:!1,style:{lineHeight:17},children:"×"})}):null]}),o&&o.length>0?(0,_jsxRuntime.jsx)(_reactNative.View,{style:B.actionsRow,children:o.map((e,t)=>{(0,_assertValidValue.assertValidValue)("Banner","action.tone",e.tone,["primary","success","warning","danger","info","neutral"]),(0,_assertValidValue.assertValidValue)("Banner","action.variant",e.variant,["solid","outline","ghost"]),(0,_assertValidValue.assertValidValue)("Banner","action.size",e.size,["sm","md"]);const r=e.tone??"primary",i=e.variant??"ghost",s="primary"===r?S.glyphColor:"neutral"===r?w.colors["text-muted"]:w.colors[r],n="primary"===r?S.ink:"neutral"===r?w.colors["text-muted"]:w.colors[`${r}-text`],a="primary"===r?S.on:"neutral"===r?w.colors["on-neutral-strong"]:w.colors[`on-${r}`],o="solid"===i;return(0,_jsxRuntime.jsx)(_reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:e.label,testID:e.testID,onPress:()=>{const t=(0,_hapticUtils.resolveHaptic)(d,"selection");t&&(0,_hapticUtils.triggerHaptic)(t),e.onPress()},style:({pressed:t})=>[B.actionBtn,"md"===e.size&&B.actionBtnMd,"outline"===i&&{borderWidth:1,borderColor:n},{backgroundColor:o?s:t?w.colors["surface-pressed"]:"transparent",opacity:o&&t?.85:1},f],children:(0,_jsxRuntime.jsx)(_index4.Text,{variant:"bodySmall",weight:"semibold",align:"center",style:{color:o?a:n},children:e.label})},`${e.label}-${t}`)})}):null]});return x?(0,_jsxRuntime.jsx)(BannerSkeleton,{...e}):P}),BannerSkeleton=({title:e,actions:t,icon:r,containerStyle:i,style:s})=>{const n=(0,_index.useTheme)(),a=!1!==r;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[{flexDirection:"row",alignItems:"flex-start",backgroundColor:n.colors.surface,borderRadius:n.radius.md,..._corners.smoothCorners,padding:n.space.md,borderWidth:1,borderColor:n.colors.border},i,s],accessibilityRole:"progressbar",accessibilityState:{busy:!0},"aria-busy":!0,children:[a?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{marginRight:n.space.sm},children:(0,_jsxRuntime.jsx)(_index3.Skeleton,{shape:"circle",width:32,height:32})}):null,(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flex:1},children:[void 0!==e?(0,_jsxRuntime.jsx)(_index3.Skeleton,{shape:"text",width:"55%",height:16,style:{marginBottom:n.space.xs}}):null,(0,_jsxRuntime.jsx)(_index3.SkeletonText,{lines:2,fontSize:n.text.sm.size,lastLineWidth:"70%"}),t&&t.length>0?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{flexDirection:"row",marginTop:n.space.sm},children:t.map((e,t)=>(0,_jsxRuntime.jsx)(_index3.Skeleton,{width:72,height:28,shape:"rounded",style:{marginRight:n.space.sm}},`sk-banner-action-${t}`))}):null]})]})};BannerSkeleton.displayName="BannerSkeleton";const Banner=exports.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 _reactNative.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:17},textBlock:{flex:1,paddingRight:e.space.xs},closeBtn:{width:28,height:28,borderRadius:e.radius.pill,..._corners.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,..._corners.smoothCorners,maxWidth:"100%",alignItems:"center",justifyContent:"center"},actionBtnMd:{minHeight:44,paddingHorizontal:e.space.md}})};var _default=exports.default=Banner;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.DEFAULT_BAR_CHART_LABELS=exports.BarChart=void 0;var _mobileCore=require("@webority/mobile-core"),_react=require("react"),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_index=require("../../hooks/index.js"),_index2=require("../../theme/index.js"),_index3=require("../../utils/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_corners=require("../../utils/corners.js"),_index4=require("../Text/index.js"),_scale=require("./scale.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_BAR_CHART_LABELS=exports.DEFAULT_BAR_CHART_LABELS=Object.freeze({chart:"Bar chart",noData:"no data",highest:(e,t)=>`Highest: ${e}, ${t}`}),AUTO_VALUES_MAX_BARS=7,MAX_BAR_WIDTH=40,BAR_SHARE=.6,MIN_BAR_HEIGHT=2,VALUE_LABEL_ROOM=20,PLOT_PAD=6,HEADER_MIN_HEIGHT=48,AXIS_LABEL_MIN_WIDTH=44,CHAR_WIDTH=8,SWATCH_SIZE=10,STACK_TONES=["primary","info","success","warning","danger","neutral"],FONT_SCALE_CAP=1.2,toneColor=(e,t)=>"neutral"===t?e.colors["text-muted"]:e.colors[`${t}-text`],safe=e=>"number"==typeof e&&Number.isFinite(e)?e:0,entryAt=(e,t)=>{const r=e[t];if(void 0===r)throw new Error(`BarChart has no entry at index ${t}.`);return r},defaultFormatValue=e=>(0,_mobileCore.formatNumber)(e),defaultFormatTick=e=>(0,_mobileCore.formatCompactNumber)(e),BarChart=exports.BarChart=(0,_react.forwardRef)((e,t)=>{const{data:r,tone:a="primary",color:i,series:s,height:n=160,label:l,summary:o,formatValue:c=defaultFormatValue,formatTick:u=defaultFormatTick,showValues:d,selection:m,defaultSelection:_=null,onSelect:x,haptic:h,labels:y,style:p,testID:b}=e;(0,_assertValidValue.assertValidValue)("BarChart","tone",e.tone,["primary","success","warning","danger","info","neutral"]);const f=(0,_react.useMemo)(()=>({...DEFAULT_BAR_CHART_LABELS,...y}),[y]),j=(0,_index2.useTheme)(),R=r.length,[v,A]=(0,_react.useState)(0),[g,w]=(0,_index.useControllableState)({value:m,defaultValue:_,onChange:x}),C=null!==g&&g>=0&&g<R?g:null,S=(0,_react.useRef)(C);S.current=C;const T=(0,_react.useRef)(-1),M=(0,_index3.resolveHaptic)(h,"tick"),N=(0,_react.useCallback)(()=>{M&&(0,_index3.triggerHaptic)(M)},[M]),L=d??(R>0&&R<=7),V=void 0!==s&&s.length>0,B=(0,_react.useMemo)(()=>V?s.map((e,t)=>e.tone??entryAt(STACK_TONES,t%STACK_TONES.length)):[],[V,s]),E=(0,_react.useMemo)(()=>V?s.map(e=>e.key):[],[V,s]),D=(0,_react.useMemo)(()=>V?r.map(e=>s.map(t=>safe(e.values?.[t.key]))):null,[r,s,V]),$=(0,_react.useMemo)(()=>D?D.map(e=>e.reduce((e,t)=>e+t,0)):r.map(e=>safe(e.value)),[r,D]),H=(0,_react.useMemo)(()=>D?D.flatMap(e=>[e.reduce((e,t)=>t>0?e+t:e,0),e.reduce((e,t)=>t<0?e+t:e,0)]):$,[D,$]),I=(0,_react.useMemo)(()=>(0,_scale.barScale)(H),[H]),k=L?20:6,O=L&&I.min<0?20:6,F=Math.max(1,n-k-O),G=(0,_react.useCallback)(e=>k+(I.max-e)/(I.max-I.min)*F,[k,I.max,I.min,F]),q=G(0),W=(0,_react.useMemo)(()=>I.ticks.map(e=>u(e)),[I.ticks,u]),U=Math.ceil(8*Math.max(...W.map(e=>e.length),1)*1.2)+j.space.xs,z=R>0?v/R:0,P=Math.max(1,Math.ceil(44/Math.max(1,z||44))),X=(0,_react.useCallback)(e=>{const t=entryAt(r,e);if(t.accessibilityLabel)return t.accessibilityLabel;if(D&&s){const r=entryAt(D,e);return`${t.label}, ${s.map((e,t)=>`${e.label} ${c(entryAt(r,t))}`).join(", ")}`}return`${t.label}, ${c(entryAt($,e))}`},[r,c,$,D,s]),K=(0,_react.useMemo)(()=>{let e=-1,t=0;for(const[r,a]of $.entries())(-1===e||a>t)&&(e=r,t=a);return e},[$]),J=o??(K>=0?f.highest(entryAt(r,K).label,c(entryAt($,K))):""),Y=(0,_react.useRef)({fire:N,setSelected:w,count:R,plotWidth:v});Y.current={fire:N,setSelected:w,count:R,plotWidth:v};const Z=(0,_react.useMemo)(()=>{const indexAt=e=>{const{count:t,plotWidth:r}=Y.current;return 0===t||r<=0||!Number.isFinite(e)?-1:Math.min(t-1,Math.max(0,Math.floor(e/r*t)))},scrubTo=e=>{const t=indexAt(e);t<0||t===T.current||(T.current=t,Y.current.fire(),Y.current.setSelected(t))},e=_reactNativeGestureHandler.Gesture.Pan().runOnJS(!0).activeOffsetX([-8,8]).failOffsetY([-12,12]).onStart(e=>{T.current=S.current??-1,scrubTo(e.x)}).onUpdate(e=>scrubTo(e.x)).withTestId(b?`${b}-pan`:"bar-chart-pan"),t=_reactNativeGestureHandler.Gesture.Tap().runOnJS(!0).onEnd((e,t)=>{if(!t)return;const r=indexAt(e.x);r<0||(Y.current.fire(),T.current=r,Y.current.setSelected(r===S.current?null:r))}).withTestId(b?`${b}-tap`:"bar-chart-tap");return _reactNativeGestureHandler.Gesture.Race(e,t)},[b]),Q=(0,_react.useCallback)(e=>{if(0===R)return;const t=S.current,r="increment"===e.nativeEvent.actionName?null===t?0:Math.min(R-1,t+1):null===t?R-1:Math.max(0,t-1);r!==t&&(N(),w(r))},[R,N,w]),ee=(0,_react.useCallback)(e=>{const t=Math.round(e.nativeEvent.layout.width);A(e=>e===t?e:t)},[]),te=i??toneColor(j,a),re=j.radius.sm,ae=l??f.chart,ie=0===R?`${ae}, ${f.noData}`:J?`${ae}, ${J}`:ae,se=null===C?J:X(C),ne=Math.min(40,Math.max(4,.6*z)),renderStack=(e,t,r)=>{const a=e.reduce((e,t)=>t>0?e+t:e,0),i=e.reduce((e,t)=>t<0?e+t:e,0);if(0===a&&0===i)return null;const s=G(a),n=[];let l=0,o=0;return e.forEach((e,r)=>{if(0===e)return;const a=e>0?l:o,i=a+e;e>0?l=i:o=i;const c=G(a),u=G(i);n.push((0,_jsxRuntime.jsx)(_reactNative.View,{testID:b?`${b}-bar-${t}-series-${r}`:void 0,style:{position:"absolute",left:0,right:0,top:Math.min(c,u)-s,height:Math.abs(c-u),backgroundColor:toneColor(j,entryAt(B,r))}},entryAt(E,r)))}),(0,_jsxRuntime.jsx)(_reactNative.View,{testID:b?`${b}-bar-${t}`:void 0,style:{position:"absolute",left:(z-ne)/2,top:s,width:ne,height:Math.max(2,G(i)-s),overflow:"hidden",opacity:r?.4:1,..._corners.smoothCorners,...a>0?{borderTopLeftRadius:re,borderTopRightRadius:re}:null,...i<0?{borderBottomLeftRadius:re,borderBottomRightRadius:re}:null},children:n})},le=$.map((e,t)=>{const r=G(e),a=e>=0?r:q,i=0===e?0:Math.max(2,Math.abs(r-q)),s=null!==C&&C!==t;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[styles.slot,{height:n}],children:[v>0&&D?renderStack(entryAt(D,t),t,s):null,v>0&&!D&&i>0?(0,_jsxRuntime.jsx)(_reactNative.View,{testID:b?`${b}-bar-${t}`:void 0,style:{position:"absolute",left:(z-ne)/2,top:a,width:ne,height:i,backgroundColor:te,opacity:s?.4:1,..._corners.smoothCorners,...e>=0?{borderTopLeftRadius:re,borderTopRightRadius:re}:{borderBottomLeftRadius:re,borderBottomRightRadius:re}}}):null,L&&v>0?(0,_jsxRuntime.jsx)(_index4.Text,{variant:"caption",color:"secondary",align:"center",numberOfLines:1,maxFontSizeMultiplier:1.2,style:{position:"absolute",left:0,right:0,top:e>=0?(D?G(entryAt(H,2*t)):r)-20+2:(D?G(entryAt(H,2*t+1)):r)+2},children:u(e)}):null]},t)});return 0===R?(0,_jsxRuntime.jsx)(_reactNative.View,{ref:t,accessible:!0,accessibilityRole:"image",accessibilityLabel:ie,testID:b,style:[styles.root,p],children:(0,_jsxRuntime.jsx)(_index4.Text,{variant:"bodySmall",color:"secondary",children:"No data"})}):(0,_jsxRuntime.jsxs)(_reactNative.View,{ref:t,accessible:!0,accessibilityRole:"adjustable",accessibilityLabel:ie,accessibilityValue:{min:0,max:R-1,now:C??0,text:se},accessibilityActions:[{name:"increment"},{name:"decrement"}],onAccessibilityAction:Q,testID:b,style:[styles.root,p],children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.header,{minHeight:48,marginBottom:j.space.sm}],children:null===C?J?(0,_jsxRuntime.jsx)(_index4.Text,{variant:"bodySmall",color:"secondary",children:J}):null:(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_index4.Text,{variant:"caption",color:"secondary",numberOfLines:1,children:entryAt(r,C).label}),(0,_jsxRuntime.jsx)(_index4.Text,{variant:"h3",numberOfLines:1,testID:b?`${b}-callout`:void 0,children:c(entryAt($,C))})]})}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.body,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:{width:U,height:n},children:I.ticks.map((e,t)=>(0,_jsxRuntime.jsx)(_index4.Text,{variant:"caption",color:"tertiary",align:"right",numberOfLines:1,maxFontSizeMultiplier:1.2,style:{position:"absolute",right:j.space.xs,left:0,top:G(e)-8},children:entryAt(W,t)},e))}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.plotColumn,children:[(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:Z,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{height:n},onLayout:ee,testID:b?`${b}-plot`:void 0,children:[I.ticks.map(e=>(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:{position:"absolute",left:0,right:0,top:G(e)-(0===e?.75:_reactNative.StyleSheet.hairlineWidth),height:0===e?1.5:2*_reactNative.StyleSheet.hairlineWidth,backgroundColor:0===e?j.colors["text-subtle"]:j.colors["border-subtle"]}},e)),(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.slots,{height:n}],children:le})]})}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.axis,children:r.map((e,t)=>(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.axisSlot,children:t%P===0?(0,_jsxRuntime.jsx)(_index4.Text,{variant:"caption",color:C===t?"primary":"tertiary",weight:C===t?"semibold":void 0,align:"center",numberOfLines:1,maxFontSizeMultiplier:1.2,style:z>0?{width:z*P}:void 0,children:e.axisLabel??e.label}):null},t))})]})]}),s&&V?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.legend,{marginTop:j.space.sm,columnGap:j.space.md,rowGap:j.space.xs}],children:s.map((e,t)=>(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[styles.legendItem,{columnGap:j.space.xs}],children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:{width:10,height:10,borderRadius:j.radius.sm,..._corners.smoothCorners,backgroundColor:toneColor(j,entryAt(B,t))}}),(0,_jsxRuntime.jsx)(_index4.Text,{variant:"caption",color:"secondary",numberOfLines:1,maxFontSizeMultiplier:1.2,children:e.label})]},e.key))}):null]})});BarChart.displayName="BarChart";const styles=_reactNative.StyleSheet.create({root:{alignSelf:"stretch"},header:{justifyContent:"center"},body:{flexDirection:"row"},plotColumn:{flex:1},slots:{flexDirection:"row"},slot:{flex:1},axis:{flexDirection:"row"},legend:{flexDirection:"row",flexWrap:"wrap"},legendItem:{flexDirection:"row",alignItems:"center"},axisSlot:{flex:1,alignItems:"center",overflow:"visible"}});var _default=exports.default=BarChart;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.DEFAULT_BAR_CHART_LABELS=exports.BarChart=void 0;var _mobileCore=require("@webority/mobile-core"),_react=require("react"),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_index=require("../../hooks/index.js"),_index2=require("../../theme/index.js"),_index3=require("../../utils/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_corners=require("../../utils/corners.js"),_index4=require("../Text/index.js"),_scale=require("./scale.js"),_jsxRuntime=require("react/jsx-runtime");const DEFAULT_BAR_CHART_LABELS=exports.DEFAULT_BAR_CHART_LABELS=Object.freeze({chart:"Bar chart",noData:"no data",highest:(e,t)=>`Highest: ${e}, ${t}`}),AUTO_VALUES_MAX_BARS=7,MAX_BAR_WIDTH=40,BAR_SHARE=.6,MIN_BAR_HEIGHT=2,VALUE_LABEL_ROOM=20,PLOT_PAD=6,HEADER_MIN_HEIGHT=48,AXIS_LABEL_MIN_WIDTH=44,CHAR_WIDTH=8,SWATCH_SIZE=10,STACK_TONES=["primary","info","success","warning","danger","neutral"],FONT_SCALE_CAP=1.2,toneColor=(e,t)=>"neutral"===t?e.colors["text-muted"]:e.colors[`${t}-text`],safe=e=>"number"==typeof e&&Number.isFinite(e)?e:0,entryAt=(e,t)=>{const r=e[t];if(void 0===r)throw new Error(`BarChart has no entry at index ${t}.`);return r},defaultFormatValue=e=>(0,_mobileCore.formatNumber)(e),defaultFormatTick=e=>(0,_mobileCore.formatCompactNumber)(e),BarChart=exports.BarChart=(0,_react.forwardRef)((e,t)=>{const{data:r,tone:a="primary",color:i,series:s,height:n=160,label:l,summary:o,formatValue:c=defaultFormatValue,formatTick:u=defaultFormatTick,showValues:d,selection:m,defaultSelection:_=null,onSelect:x,haptic:h,labels:y,style:b,testID:p}=e;(0,_assertValidValue.assertValidValue)("BarChart","tone",e.tone,["primary","success","warning","danger","info","neutral"]);const f=(0,_react.useMemo)(()=>({...DEFAULT_BAR_CHART_LABELS,...y}),[y]),j=(0,_index2.useTheme)(),v=r.length,[R,A]=(0,_react.useState)(0),[g,C]=(0,_index.useControllableState)({value:m,defaultValue:_,onChange:x}),S=null!==g&&g>=0&&g<v?g:null,w=(0,_react.useRef)(S);w.current=S;const M=(0,_react.useRef)(-1),T=(0,_index3.resolveHaptic)(h,"tick"),N=(0,_react.useCallback)(()=>{T&&(0,_index3.triggerHaptic)(T)},[T]),L=d??(v>0&&v<=7),V=void 0!==s&&s.length>0,B=(0,_react.useMemo)(()=>V?s.map((e,t)=>e.tone??entryAt(STACK_TONES,t%STACK_TONES.length)):[],[V,s]),D=(0,_react.useMemo)(()=>V?s.map(e=>e.key):[],[V,s]),E=(0,_react.useMemo)(()=>V?r.map(e=>s.map(t=>safe(e.values?.[t.key]))):null,[r,s,V]),$=(0,_react.useMemo)(()=>E?E.map(e=>e.reduce((e,t)=>e+t,0)):r.map(e=>safe(e.value)),[r,E]),H=(0,_react.useMemo)(()=>E?E.flatMap(e=>[e.reduce((e,t)=>t>0?e+t:e,0),e.reduce((e,t)=>t<0?e+t:e,0)]):$,[E,$]),I=(0,_react.useMemo)(()=>(0,_scale.barScale)(H),[H]),k=L?20:6,O=L&&I.min<0?20:6,F=Math.max(1,n-k-O),G=(0,_react.useCallback)(e=>k+(I.max-e)/(I.max-I.min)*F,[k,I.max,I.min,F]),q=G(0),W=(0,_react.useMemo)(()=>I.ticks.map(e=>u(e)),[I.ticks,u]),U=Math.ceil(8*Math.max(...W.map(e=>e.length),1)*1.2)+j.space.xs,z=v>0?R/v:0,P=Math.max(1,Math.ceil(44/Math.max(1,z||44))),X=(0,_react.useCallback)(e=>{const t=entryAt(r,e);if(t.accessibilityLabel)return t.accessibilityLabel;if(E&&s){const r=entryAt(E,e);return`${t.label}, ${s.map((e,t)=>`${e.label} ${c(entryAt(r,t))}`).join(", ")}`}return`${t.label}, ${c(entryAt($,e))}`},[r,c,$,E,s]),K=(0,_react.useMemo)(()=>{let e=-1,t=0;for(const[r,a]of $.entries())(-1===e||a>t)&&(e=r,t=a);return e},[$]),J=o??(K>=0?f.highest(entryAt(r,K).label,c(entryAt($,K))):""),Y=(0,_react.useRef)({fire:N,setSelected:C,count:v,plotWidth:R});Y.current={fire:N,setSelected:C,count:v,plotWidth:R};const Z=(0,_react.useCallback)(e=>{const{count:t,plotWidth:r}=Y.current;return 0===t||r<=0||!Number.isFinite(e)?-1:Math.min(t-1,Math.max(0,Math.floor(e/r*t)))},[]),Q=(0,_react.useCallback)(e=>{const t=Z(e);t<0||t===M.current||(M.current=t,Y.current.fire(),Y.current.setSelected(t))},[Z]),ee=(0,_react.useMemo)(()=>({runOnJS:!0,activeOffsetX:[-8,8],failOffsetY:[-12,12],onActivate:e=>{M.current=w.current??-1,Q(e.x)},onUpdate:e=>Q(e.x),testID:p?`${p}-pan`:"bar-chart-pan"}),[Q,p]),te=(0,_reactNativeGestureHandler.usePanGesture)(ee),re=(0,_react.useMemo)(()=>({runOnJS:!0,onDeactivate:e=>{if(e.canceled)return;const t=Z(e.x);t<0||(Y.current.fire(),M.current=t,Y.current.setSelected(t===w.current?null:t))},testID:p?`${p}-tap`:"bar-chart-tap"}),[Z,p]),ae=(0,_reactNativeGestureHandler.useTapGesture)(re),ie=(0,_reactNativeGestureHandler.useCompetingGestures)(te,ae),se=(0,_react.useCallback)(e=>{if(0===v)return;const t=w.current,r="increment"===e.nativeEvent.actionName?null===t?0:Math.min(v-1,t+1):null===t?v-1:Math.max(0,t-1);r!==t&&(N(),C(r))},[v,N,C]),ne=(0,_react.useCallback)(e=>{const t=Math.round(e.nativeEvent.layout.width);A(e=>e===t?e:t)},[]),le=i??toneColor(j,a),oe=j.radius.sm,ce=l??f.chart,ue=0===v?`${ce}, ${f.noData}`:J?`${ce}, ${J}`:ce,de=null===S?J:X(S),me=Math.min(40,Math.max(4,.6*z)),renderStack=(e,t,r)=>{const a=e.reduce((e,t)=>t>0?e+t:e,0),i=e.reduce((e,t)=>t<0?e+t:e,0);if(0===a&&0===i)return null;const s=G(a),n=[];let l=0,o=0;return e.forEach((e,r)=>{if(0===e)return;const a=e>0?l:o,i=a+e;e>0?l=i:o=i;const c=G(a),u=G(i);n.push((0,_jsxRuntime.jsx)(_reactNative.View,{testID:p?`${p}-bar-${t}-series-${r}`:void 0,style:{position:"absolute",left:0,right:0,top:Math.min(c,u)-s,height:Math.abs(c-u),backgroundColor:toneColor(j,entryAt(B,r))}},entryAt(D,r)))}),(0,_jsxRuntime.jsx)(_reactNative.View,{testID:p?`${p}-bar-${t}`:void 0,style:{position:"absolute",left:(z-me)/2,top:s,width:me,height:Math.max(2,G(i)-s),overflow:"hidden",opacity:r?.4:1,..._corners.smoothCorners,...a>0?{borderTopLeftRadius:oe,borderTopRightRadius:oe}:null,...i<0?{borderBottomLeftRadius:oe,borderBottomRightRadius:oe}:null},children:n})},xe=$.map((e,t)=>{const r=G(e),a=e>=0?r:q,i=0===e?0:Math.max(2,Math.abs(r-q)),s=null!==S&&S!==t;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[styles.slot,{height:n}],children:[R>0&&E?renderStack(entryAt(E,t),t,s):null,R>0&&!E&&i>0?(0,_jsxRuntime.jsx)(_reactNative.View,{testID:p?`${p}-bar-${t}`:void 0,style:{position:"absolute",left:(z-me)/2,top:a,width:me,height:i,backgroundColor:le,opacity:s?.4:1,..._corners.smoothCorners,...e>=0?{borderTopLeftRadius:oe,borderTopRightRadius:oe}:{borderBottomLeftRadius:oe,borderBottomRightRadius:oe}}}):null,L&&R>0?(0,_jsxRuntime.jsx)(_index4.Text,{variant:"caption",color:"secondary",align:"center",numberOfLines:1,maxFontSizeMultiplier:1.2,style:{position:"absolute",left:0,right:0,top:e>=0?(E?G(entryAt(H,2*t)):r)-20+2:(E?G(entryAt(H,2*t+1)):r)+2},children:u(e)}):null]},t)});return 0===v?(0,_jsxRuntime.jsx)(_reactNative.View,{ref:t,accessible:!0,accessibilityRole:"image",accessibilityLabel:ue,testID:p,style:[styles.root,b],children:(0,_jsxRuntime.jsx)(_index4.Text,{variant:"bodySmall",color:"secondary",children:"No data"})}):(0,_jsxRuntime.jsxs)(_reactNative.View,{ref:t,accessible:!0,accessibilityRole:"adjustable",accessibilityLabel:ue,accessibilityValue:{min:0,max:v-1,now:S??0,text:de},accessibilityActions:[{name:"increment"},{name:"decrement"}],onAccessibilityAction:se,testID:p,style:[styles.root,b],children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.header,{minHeight:48,marginBottom:j.space.sm}],children:null===S?J?(0,_jsxRuntime.jsx)(_index4.Text,{variant:"bodySmall",color:"secondary",children:J}):null:(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_index4.Text,{variant:"caption",color:"secondary",numberOfLines:1,children:entryAt(r,S).label}),(0,_jsxRuntime.jsx)(_index4.Text,{variant:"h3",numberOfLines:1,testID:p?`${p}-callout`:void 0,children:c(entryAt($,S))})]})}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.body,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:{width:U,height:n},children:I.ticks.map((e,t)=>(0,_jsxRuntime.jsx)(_index4.Text,{variant:"caption",color:"tertiary",align:"right",numberOfLines:1,maxFontSizeMultiplier:1.2,style:{position:"absolute",right:j.space.xs,left:0,top:G(e)-8},children:entryAt(W,t)},e))}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.plotColumn,children:[(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:ie,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{height:n},onLayout:ne,testID:p?`${p}-plot`:void 0,children:[I.ticks.map(e=>(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:{position:"absolute",left:0,right:0,top:G(e)-(0===e?.75:_reactNative.StyleSheet.hairlineWidth),height:0===e?1.5:2*_reactNative.StyleSheet.hairlineWidth,backgroundColor:0===e?j.colors["text-subtle"]:j.colors["border-subtle"]}},e)),(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.slots,{height:n}],children:xe})]})}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.axis,children:r.map((e,t)=>(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.axisSlot,children:t%P===0?(0,_jsxRuntime.jsx)(_index4.Text,{variant:"caption",color:S===t?"primary":"tertiary",weight:S===t?"semibold":void 0,align:"center",numberOfLines:1,maxFontSizeMultiplier:1.2,style:z>0?{width:z*P}:void 0,children:e.axisLabel??e.label}):null},t))})]})]}),s&&V?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.legend,{marginTop:j.space.sm,columnGap:j.space.md,rowGap:j.space.xs}],children:s.map((e,t)=>(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[styles.legendItem,{columnGap:j.space.xs}],children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:{width:10,height:10,borderRadius:j.radius.sm,..._corners.smoothCorners,backgroundColor:toneColor(j,entryAt(B,t))}}),(0,_jsxRuntime.jsx)(_index4.Text,{variant:"caption",color:"secondary",numberOfLines:1,maxFontSizeMultiplier:1.2,children:e.label})]},e.key))}):null]})});BarChart.displayName="BarChart";const styles=_reactNative.StyleSheet.create({root:{alignSelf:"stretch"},header:{justifyContent:"center"},body:{flexDirection:"row"},plotColumn:{flex:1},slots:{flexDirection:"row"},slot:{flex:1},axis:{flexDirection:"row"},legend:{flexDirection:"row",flexWrap:"wrap"},legendItem:{flexDirection:"row",alignItems:"center"},axisSlot:{flex:1,alignItems:"center",overflow:"visible"}});var _default=exports.default=BarChart;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.DEFAULT_BOTTOM_NAVIGATION_LABELS=exports.BottomNavigation=void 0;var cache,_react=_interopRequireWildcard(require("react")),_reactNative=require("react-native"),_reactNativeSafeAreaContext=require("react-native-safe-area-context"),_useReducedMotion=require("../../hooks/useReducedMotion.js"),_index=require("../../theme/index.js"),_index2=require("../../utils/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_corners=require("../../utils/corners.js"),_hitSlop=require("../../utils/hitSlop.js"),_nativeDriver=require("../../utils/nativeDriver.js"),_shadows=require("../../utils/shadows.js"),_index3=require("../AppIcon/index.js"),_index4=require("../Badge/index.js"),_index5=require("../Text/index.js"),_useScreenReaderEnabled=require("./useScreenReaderEnabled.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var i,a,n=Object.defineProperty,r={__proto__:null,default:e};if(Object(e)!==e)return r;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,r)}for(a in e)"default"!==a&&{}.hasOwnProperty.call(e,a)&&((i=n&&Object.getOwnPropertyDescriptor(e,a))&&(i.get||i.set)?n(r,a,i):r[a]=e[a]);return r}const DEFAULT_BOTTOM_NAVIGATION_LABELS=exports.DEFAULT_BOTTOM_NAVIGATION_LABELS=Object.freeze({switchesTo:e=>`Switches to ${e}`,unread:e=>`${e} unread`,newUpdates:"new updates"}),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=exports.BottomNavigation=(0,_react.forwardRef)((e,t)=>{const{tabs:i,centerAction:a,activeTab:n,onChange:r,haptic:o="selection",showLabels:s=!0,variant:l="pill",indicatorPosition:d="bottom",radius:c,indicatorRadius:u="auto",elevation:p,iconSize:h,marginHorizontal:_,marginVertical:m,paddingHorizontal:g,paddingVertical:b,border:x,minimizeOnScroll:f=!1,scrollDirection:v="idle",accessory:y,style:R,indicatorStyle:N,labelStyle:j,labelMaxFontScale:A,labels:S,testID:w}=e;(0,_assertValidValue.assertValidValue)("BottomNavigation","variant",e.variant,["pill","underline","floating","bubble","expand","solid","tile"]),(0,_assertValidValue.assertValidValue)("BottomNavigation","indicatorPosition",e.indicatorPosition,["top","bottom"]);const E=(0,_react.useMemo)(()=>S?{...DEFAULT_BOTTOM_NAVIGATION_LABELS,...S}:DEFAULT_BOTTOM_NAVIGATION_LABELS,[S]),I=(0,_index.useTheme)(),T=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),V=(0,_react.useMemo)(()=>buildStyles(I),[I]),L=h??18,D=L+4+8,M=I.space.lg,B=I.space.lg,C=I.radius.xl,k=(0,_useReducedMotion.useReducedMotion)(),O=(0,_useScreenReaderEnabled.useScreenReaderEnabled)(f),[P,z]=_react.default.useState(null);(0,_react.useEffect)(()=>{null!==P&&P!==v&&z(null)},[P,v]);const F=f&&!O&&"down"===v&&null===P,[H,W]=_react.default.useState(F);(0,_react.useEffect)(()=>{H!==F&&(k||"web"===_reactNative.Platform.OS||_reactNative.LayoutAnimation.configureNext(_reactNative.LayoutAnimation.Presets.easeInEaseOut),W(F))},[H,F,k]);const q="function"==typeof y?y({minimized:H}):y,U=null!=q&&!1!==q,$=H&&U,[X,G]=_react.default.useState(0),Z=U&&!$?X+I.space.xs:0,Y="tile"===l,K="floating"===l||Y,J="bubble"===l,Q="expand"===l,ee="solid"===l,te="pill"===l||K||ee,ie=Math.max(0,i.findIndex(e=>e.key===n)),[ae,ne]=_react.default.useState(0),[re,oe]=_react.default.useState(0),se=a?Math.ceil(i.length/2):i.length,le=i.length+(a?1:0),[de,ce]=_react.default.useState({width:0,height:0}),ue=a?.size??48,pe=void 0!==a?.gap,he=Math.max(0,a?.gap??0),me=pe?(de.width||ue)+2*he:0,ge=pe?i.length>0?Math.max(0,ae-me)/i.length:0:le>0?ae/le:0,be=pe?me:ge,xe=(0,_react.useRef)((0,_index.createAnimatedValue)(ie)).current,fe=(0,_react.useRef)({}),ve=(0,_react.useRef)({});i.forEach(e=>{fe.current[e.key]||(fe.current[e.key]=new _reactNative.Animated.Value(1)),ve.current[e.key]||(ve.current[e.key]=(0,_index.createAnimatedValue)(e.key===n?1:0))});const ye=ge>0?Y?Math.min(ge-4,96):Math.min(ge-M,64):0,Re=ge>0?(ge-ye)/2:0,Ne=ge>0?(ge-48)/2:0,hasLabel=e=>s&&!H&&!1!==e.showLabel&&e.label.trim().length>0,je=i[ie],Ae=je&&!hasLabel(je)&&re>0?re/2:I.space.xs+(L+4)/2,Se=Ae-14-24,we=Math.max(0,re-4),Ee=Y?2:Ae-D/2,Ie=(0,_react.useRef)(ie);(0,_react.useEffect)(()=>{if(Ie.current===ie)return;Ie.current=ie;const e=_reactNative.Animated.spring(xe,{toValue:ie,tension:120,friction:14,useNativeDriver:_nativeDriver.nativeDriver});return e.start(),()=>e.stop()},[ie,xe]);const Te=Math.max(1,i.length-1),Ve=(0,_react.useMemo)(()=>{const e=[],t=[];for(let i=0;i<=Te;i++)e.push(i),t.push(i<se?i*ge:i*ge+be);return xe.interpolate({inputRange:e,outputRange:t})},[xe,Te,se,ge,be]),Le=i.map(e=>e.key).join(" "),De=J||Q;(0,_react.useEffect)(()=>{const e=Le.split(" ").flatMap(e=>{const t=e===n?1:0,i=ve.current[e];return i?De?[_reactNative.Animated.spring(i,{toValue:t,tension:140,friction:13,useNativeDriver:!1})]:(i.setValue(t),[]):[]});if(0===e.length)return;const t=_reactNative.Animated.parallel(e);return t.start(),()=>t.stop()},[n,Le,De]);const popIcon=e=>{_reactNative.Animated.sequence([_reactNative.Animated.timing(e,{toValue:1.15,duration:120,useNativeDriver:_nativeDriver.nativeDriver}),_reactNative.Animated.spring(e,{toValue:1,tension:200,friction:8,useNativeDriver:_nativeDriver.nativeDriver})]).start()},Me=(0,_react.useRef)(new _reactNative.Animated.Value(1)).current,{colors:Be}=I,Ce=ee?Be.primary:Be.surface,ke=ee?Be["on-primary"]:Be.primary,Oe=ee?Be["on-primary"]:Y?Be["text-body"]:Be["text-subtle"],Pe=ee?Be["on-primary"]:Be["primary-soft"],ze=ee?Be.primary:J?Be["on-primary"]:ke,Fe=_??B,He=m??(K?B:0),We=He>0,qe=b??I.space.sm,Ue=g??(K?I.space.sm:I.space.xs),$e=We?qe:Math.max(qe,T.bottom),Xe=We?Math.max(He,T.bottom>0?T.bottom+I.space.sm:0):0,Ge="pill"===c,Ze=K?re+Z+2*qe+2*_reactNative.StyleSheet.hairlineWidth:re+Z+qe+$e,Ye=Ge?re>0?Ze/2:I.radius.pill:c??(Y?I.radius.pill:K?C:I.radius.none),Ke=void 0!==c,activeBgRadius=(e,t)=>"number"==typeof u?Math.max(0,Math.min(u,e/2)):"auto"===u&&Ke?Math.min(Ye,e/2):t,Je="underline"===l?Math.max(Ue,Ge&&0===re?0:Ye):Ue,Qe=p??"none",et="none"===Qe?void 0:I.shadow[Qe],tt=void 0===et?null:(0,_shadows.supportsBoxShadow)()?{boxShadow:(0,_shadows.toBoxShadow)(et)}:et,it=x?_reactNative.StyleSheet.hairlineWidth:0,at=ee?Be.primary:Be.border,nt=a?.lift??0,rt=qe+it+Z,ot=a&&re>0?Math.max(0,(de.height||ue)/2+nt-re/2-rt):0,st=a?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[V.centerCell,pe?{flex:0,marginHorizontal:he}:null],pointerEvents:"box-none",children:(0,_jsxRuntime.jsxs)(_reactNative.Pressable,{onPress:()=>{if(!a)return;const e=a.haptic??o;!1!==e&&(0,_index2.triggerHaptic)(e),popIcon(Me),a.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:a.label,hitSlop:{top:6,bottom:6,left:6,right:6},...(0,_hitSlop.hitSlopMarker)({top:6,bottom:6,left:6,right:6}),style:({pressed:e})=>[V.centerPressable,{top:-nt},e?{opacity:.85}:null],testID:a.testID??(w?`${w}-center`:void 0),children:[a.content?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:{transform:[{scale:Me}]},children:a.content}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:[V.centerCircle,{width:ue,height:ue,borderRadius:I.radius.pill,..._corners.smoothCorners,backgroundColor:a.color??Be.primary}],children:(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:{transform:[{scale:Me}]},children:(0,_index3.renderSlotIcon)(a.icon??"add",{color:a.iconColor??Be["on-primary"],size:a.iconSize??24,disabled:!1})})}),(lt=a,s&&!H&&lt.label.trim().length>0?(0,_jsxRuntime.jsx)(_index5.Text,{variant:"caption",numberOfLines:1,maxFontSizeMultiplier:A??I.settings.maxFontSizeMultiplier??1.2,style:[V.label,{color:Oe,opacity:ee?.7:1},j],children:a.label}):null)]})},CENTER_KEY):null;var lt;const dt=U?(0,_jsxRuntime.jsx)(_reactNative.View,{style:$?V.accessoryInline:V.accessoryStacked,onLayout:e=>G(e.nativeEvent.layout.height),testID:w?`${w}-accessory`:void 0,children:q}):null,ct=(0,_jsxRuntime.jsxs)(_reactNative.View,{style:$?[V.tabRow,V.tabRowInline]:V.tabRow,onLayout:e=>{const{width:t,height:i}=e.nativeEvent.layout;ne(t),oe(i)},children:[te&&ye>0&&(!Y||we>0)?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{pointerEvents:"none",style:[V.pill,{width:ye,height:Y?we:D,left:Re,top:Ee,backgroundColor:Pe,borderRadius:Y?activeBgRadius(we,we/2):activeBgRadius(D,I.radius.pill),..._corners.smoothCorners,transform:[{translateX:Ve}]},N]}):null,J&&ge>0?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{pointerEvents:"none",style:[V.bubble,I.shadow.elevated,{width:48,height:48,borderRadius:I.radius.pill,..._corners.smoothCorners,left:Ne,top:Se,backgroundColor:Be.primary,borderColor:Be.surface,transform:[{translateX:Ve}]},N]}):null,(ut=i.map(e=>{const t=e.key===n,i=t?ke:Oe,a=t?ze:Oe,s="string"==typeof e.icon?{name:e.icon,variant:"bold"}:e.icon,l=t?e.activeIcon??s:e.icon,d=fe.current[e.key],c=ve.current[e.key];if(void 0===d||void 0===c)throw new Error(`BottomNavigation has no animation values for tab "${e.key}".`);const u=badgeVariantOf(e.badge??null),p=badgeAccessibilitySuffix(e.badge??null,E),h=ee&&!t?.7:1,_=J&&t||ee?Be.primary:Be.surface,m=hasLabel(e),g=m&&(!Q||t),b=(0,_jsxRuntime.jsxs)(_reactNative.Animated.View,{style:[V.iconWrap,{width:L+4,height:L+4,opacity:h,transform:[{scale:d}]}],children:[(0,_jsxRuntime.jsx)(_reactNative.View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:(0,_index3.renderSlotIcon)(l,{color:a,size:L,focused:t,disabled:!1})}),u?(0,_jsxRuntime.jsx)(_index4.Badge,{variant:u,value:"standard"===u?e.badge:void 0,tone:"danger",accessible:!1,style:"dot"===u?V.badgeDotPosition:V.badgePillPosition,badgeStyle:["dot"===u?V.badgeDot:V.badgePill,{borderColor:_}],textStyle:V.badgeText}):null]}),x=J?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:{top:c.interpolate({inputRange:[0,1],outputRange:[0,-14]})},children:b}):b,f=g?(0,_jsxRuntime.jsx)(_reactNative.Animated.Text,{numberOfLines:1,maxFontSizeMultiplier:A??I.settings.maxFontSizeMultiplier??1.2,style:[V.label,Q?V.labelInline:null,{color:i,opacity:Q?c:h,fontWeight:t?I.weight.semibold:I.weight.normal},j],children:e.label}):null,y=(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:()=>(e=>{H&&z(v),e.key!==n&&!1!==o&&(0,_index2.triggerHaptic)(o);const t=fe.current[e.key];t&&popIcon(t),r(e.key)})(e),accessibilityRole:"tab",accessibilityState:{selected:t},"aria-selected":t,accessibilityLabel:`${e.label}${p}`,accessibilityHint:E.switchesTo(e.label),hitSlop:{top:6,bottom:6,left:6,right:6},...(0,_hitSlop.hitSlopMarker)({top:6,bottom:6,left:6,right:6}),style:({pressed:e})=>[V.tab,Y?V.tabTile:null,e?{opacity:.85}:null],testID:w?`${w}-tab-${e.key}`:void 0,children:Q?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[V.expandPill,{height:D,paddingHorizontal:t&&m?I.space.md:Math.max(0,(D-(L+4))/2)}],children:[(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:[V.expandFill,{borderRadius:activeBgRadius(D,D/2),..._corners.smoothCorners,backgroundColor:t?Be["primary-soft"]:"transparent"},t?N:null]}),x,f]}):(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[x,f]})},e.key);return Q?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:{flex:c.interpolate({inputRange:[0,1],outputRange:[1,m?1.5:1]})},children:y},e.key):y}),st?[...ut.slice(0,se),st,...ut.slice(se)]:ut),"underline"===l&&ge>0?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{pointerEvents:"none",style:[V.underline,"top"===d?V.underlineTop:V.underlineBottom,"top"===d?{top:-qe-Z}:{bottom:-qe},{width:ge,height:3,backgroundColor:Be.primary,transform:[{translateX:Ve}]},N]}):null]});var ut;return(0,_jsxRuntime.jsx)(_reactNative.View,{ref:t,testID:w,accessibilityRole:"tablist",style:[V.outer,{paddingHorizontal:Fe,paddingTop:Math.max(He,ot),paddingBottom:Xe},R],children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[K?V.floatingBar:V.dockedBar,$?V.barInline:null,tt,{backgroundColor:Ce,borderColor:at,borderRadius:Ye,..._corners.smoothCorners},K?{borderWidth:it,paddingHorizontal:Ue,paddingVertical:qe}:{borderTopWidth:it,borderBottomWidth:it,borderLeftWidth:it,borderRightWidth:it,paddingHorizontal:Je,paddingTop:qe,paddingBottom:$e}],children:[dt,ct]})})});BottomNavigation.displayName="BottomNavigation";const buildStyles=e=>_reactNative.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,..._corners.smoothCorners},underlineTop:{borderBottomLeftRadius:e.radius.none,borderBottomRightRadius:e.radius.none,..._corners.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}});var _default=exports.default=BottomNavigation;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.DEFAULT_BOTTOM_NAVIGATION_LABELS=exports.BottomNavigation=void 0;var cache,_react=_interopRequireWildcard(require("react")),_reactNative=require("react-native"),_reactNativeSafeAreaContext=require("react-native-safe-area-context"),_useReducedMotion=require("../../hooks/useReducedMotion.js"),_index=require("../../theme/index.js"),_index2=require("../../utils/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_corners=require("../../utils/corners.js"),_hitSlop=require("../../utils/hitSlop.js"),_nativeDriver=require("../../utils/nativeDriver.js"),_shadows=require("../../utils/shadows.js"),_index3=require("../AppIcon/index.js"),_index4=require("../Badge/index.js"),_index5=require("../Text/index.js"),_useScreenReaderEnabled=require("./useScreenReaderEnabled.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var i,a,n=Object.defineProperty,r={__proto__:null,default:e};if(Object(e)!==e)return r;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,r)}for(a in e)"default"!==a&&{}.hasOwnProperty.call(e,a)&&((i=n&&Object.getOwnPropertyDescriptor(e,a))&&(i.get||i.set)?n(r,a,i):r[a]=e[a]);return r}const DEFAULT_BOTTOM_NAVIGATION_LABELS=exports.DEFAULT_BOTTOM_NAVIGATION_LABELS=Object.freeze({switchesTo:e=>`Switches to ${e}`,unread:e=>`${e} unread`,newUpdates:"new updates"}),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=exports.BottomNavigation=(0,_react.forwardRef)((e,t)=>{const{tabs:i,centerAction:a,activeTab:n,onChange:r,haptic:o="selection",showLabels:s=!0,variant:l="pill",indicatorPosition:d="bottom",radius:c,indicatorRadius:u="auto",elevation:p,iconSize:h,marginHorizontal:_,marginVertical:m,paddingHorizontal:g,paddingVertical:b,border:x,minimizeOnScroll:f=!1,scrollDirection:v="idle",accessory:y,style:R,indicatorStyle:N,labelStyle:j,labelMaxFontScale:A,labels:S,testID:w}=e;(0,_assertValidValue.assertValidValue)("BottomNavigation","variant",e.variant,["pill","underline","floating","bubble","expand","solid","tile"]),(0,_assertValidValue.assertValidValue)("BottomNavigation","indicatorPosition",e.indicatorPosition,["top","bottom"]);const E=(0,_react.useMemo)(()=>S?{...DEFAULT_BOTTOM_NAVIGATION_LABELS,...S}:DEFAULT_BOTTOM_NAVIGATION_LABELS,[S]),I=(0,_index.useTheme)(),T=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),V=(0,_react.useMemo)(()=>buildStyles(I),[I]),L=h??18,D=L+4+8,M=I.space.lg,B=I.space.lg,C=I.radius.xl,k=(0,_useReducedMotion.useReducedMotion)(),O=(0,_useScreenReaderEnabled.useScreenReaderEnabled)(f),[P,z]=_react.default.useState(null);(0,_react.useEffect)(()=>{null!==P&&P!==v&&z(null)},[P,v]);const F=f&&!O&&"down"===v&&null===P,[H,W]=_react.default.useState(F);(0,_react.useEffect)(()=>{H!==F&&(k||"web"===_reactNative.Platform.OS||_reactNative.LayoutAnimation.configureNext(_reactNative.LayoutAnimation.Presets.easeInEaseOut),W(F))},[H,F,k]);const q="function"==typeof y?y({minimized:H}):y,U=null!=q&&!1!==q,$=H&&U,[X,G]=_react.default.useState(0),Z=U&&!$?X+I.space.xs:0,Y="tile"===l,K="floating"===l||Y,J="bubble"===l,Q="expand"===l,ee="solid"===l,te="pill"===l||K||ee,ie=Math.max(0,i.findIndex(e=>e.key===n)),[ae,ne]=_react.default.useState(0),[re,oe]=_react.default.useState(0),se=a?Math.ceil(i.length/2):i.length,le=i.length+(a?1:0),[de,ce]=_react.default.useState({width:0,height:0}),ue=a?.size??48,pe=void 0!==a?.gap,he=Math.max(0,a?.gap??0),me=pe?(de.width||ue)+2*he:0,ge=pe?i.length>0?Math.max(0,ae-me)/i.length:0:le>0?ae/le:0,be=pe?me:ge,xe=(0,_react.useRef)((0,_index.createAnimatedValue)(ie)).current,fe=(0,_react.useRef)({}),ve=(0,_react.useRef)({});i.forEach(e=>{fe.current[e.key]||(fe.current[e.key]=new _reactNative.Animated.Value(1)),ve.current[e.key]||(ve.current[e.key]=(0,_index.createAnimatedValue)(e.key===n?1:0))});const ye=ge>0?Y?Math.min(ge-4,96):Math.min(ge-M,64):0,Re=ge>0?(ge-ye)/2:0,Ne=ge>0?(ge-48)/2:0,hasLabel=e=>s&&!H&&!1!==e.showLabel&&e.label.trim().length>0,je=i[ie],Ae=je&&!hasLabel(je)&&re>0?re/2:I.space.xs+(L+4)/2,Se=Ae-14-24,we=Math.max(0,re-4),Ee=Y?2:Ae-D/2,Ie=(0,_react.useRef)(ie);(0,_react.useEffect)(()=>{if(Ie.current===ie)return;Ie.current=ie;const e=_reactNative.Animated.spring(xe,{toValue:ie,tension:120,friction:14,useNativeDriver:_nativeDriver.nativeDriver});return e.start(),()=>e.stop()},[ie,xe]);const Te=Math.max(1,i.length-1),Ve=(0,_react.useMemo)(()=>{const e=[],t=[];for(let i=0;i<=Te;i++)e.push(i),t.push(i<se?i*ge:i*ge+be);return xe.interpolate({inputRange:e,outputRange:t})},[xe,Te,se,ge,be]),Le=i.map(e=>e.key).join(" "),De=J||Q;(0,_react.useEffect)(()=>{const e=Le.split(" ").flatMap(e=>{const t=e===n?1:0,i=ve.current[e];return i?De?[_reactNative.Animated.spring(i,{toValue:t,tension:140,friction:13,useNativeDriver:!1})]:(i.setValue(t),[]):[]});if(0===e.length)return;const t=_reactNative.Animated.parallel(e);return t.start(),()=>t.stop()},[n,Le,De]);const popIcon=e=>{_reactNative.Animated.sequence([_reactNative.Animated.timing(e,{toValue:1.15,duration:120,useNativeDriver:_nativeDriver.nativeDriver}),_reactNative.Animated.spring(e,{toValue:1,tension:200,friction:8,useNativeDriver:_nativeDriver.nativeDriver})]).start()},Me=(0,_react.useRef)(new _reactNative.Animated.Value(1)).current,{colors:Be}=I,Ce=ee?Be.primary:Be.surface,ke=ee?Be["on-primary"]:Be.primary,Oe=ee?Be["on-primary"]:Y?Be["text-body"]:Be["text-subtle"],Pe=ee?Be["on-primary"]:Be["primary-soft"],ze=ee?Be.primary:J?Be["on-primary"]:ke,Fe=_??B,He=m??(K?B:0),We=He>0,qe=b??I.space.sm,Ue=g??(K?I.space.sm:I.space.xs),$e=We?qe:Math.max(qe,T.bottom),Xe=We?Math.max(He,T.bottom>0?T.bottom+I.space.sm:0):0,Ge="pill"===c,Ze=K?re+Z+2*qe+2*_reactNative.StyleSheet.hairlineWidth:re+Z+qe+$e,Ye=Ge?re>0?Ze/2:I.radius.pill:c??(Y?I.radius.pill:K?C:I.radius.none),Ke=void 0!==c,activeBgRadius=(e,t)=>"number"==typeof u?Math.max(0,Math.min(u,e/2)):"auto"===u&&Ke?Math.min(Ye,e/2):t,Je="underline"===l?Math.max(Ue,Ge&&0===re?0:Ye):Ue,Qe=p??"none",et="none"===Qe?void 0:I.shadow[Qe],tt=void 0===et?null:(0,_shadows.supportsBoxShadow)()?{boxShadow:(0,_shadows.toBoxShadow)(et)}:et,it=x?_reactNative.StyleSheet.hairlineWidth:0,at=ee?Be.primary:Be.border,nt=a?.lift??0,rt=qe+it+Z,ot=a&&re>0?Math.max(0,(de.height||ue)/2+nt-re/2-rt):0,st=a?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[V.centerCell,pe?{flex:0,marginHorizontal:he}:null],pointerEvents:"box-none",children:(0,_jsxRuntime.jsxs)(_reactNative.Pressable,{onPress:()=>{if(!a)return;const e=a.haptic??o;!1!==e&&(0,_index2.triggerHaptic)(e),popIcon(Me),a.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:a.label,hitSlop:{top:6,bottom:6,left:6,right:6},...(0,_hitSlop.hitSlopMarker)({top:6,bottom:6,left:6,right:6}),style:({pressed:e})=>[V.centerPressable,{top:-nt},e?{opacity:.85}:null],testID:a.testID??(w?`${w}-center`:void 0),children:[a.content?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:{transform:[{scale:Me}]},children:a.content}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:[V.centerCircle,{width:ue,height:ue,borderRadius:I.radius.pill,..._corners.smoothCorners,backgroundColor:a.color??Be.primary}],children:(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:{transform:[{scale:Me}]},children:(0,_index3.renderSlotIcon)(a.icon??"add",{color:a.iconColor??Be["on-primary"],size:a.iconSize??24,disabled:!1})})}),(lt=a,s&&!H&&lt.label.trim().length>0?(0,_jsxRuntime.jsx)(_index5.Text,{variant:"caption",numberOfLines:1,maxFontSizeMultiplier:A??I.settings.maxFontSizeMultiplier??1.2,style:[V.label,{color:Oe,opacity:ee?.7:1},j],children:a.label}):null)]})},CENTER_KEY):null;var lt;const dt=U?(0,_jsxRuntime.jsx)(_reactNative.View,{style:$?V.accessoryInline:V.accessoryStacked,onLayout:e=>G(e.nativeEvent.layout.height),testID:w?`${w}-accessory`:void 0,children:q}):null,ct=(0,_jsxRuntime.jsxs)(_reactNative.View,{style:$?[V.tabRow,V.tabRowInline]:V.tabRow,onLayout:e=>{const{width:t,height:i}=e.nativeEvent.layout;ne(t),oe(i)},children:[te&&ye>0&&(!Y||we>0)?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{pointerEvents:"none",style:[V.pill,{width:ye,height:Y?we:D,left:Re,top:Ee,backgroundColor:Pe,borderRadius:Y?activeBgRadius(we,we/2):activeBgRadius(D,I.radius.pill),..._corners.smoothCorners,transform:[{translateX:Ve}]},N]}):null,J&&ge>0?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{pointerEvents:"none",style:[V.bubble,I.shadow.elevated,{width:48,height:48,borderRadius:I.radius.pill,..._corners.smoothCorners,left:Ne,top:Se,backgroundColor:Be.primary,borderColor:Be.surface,transform:[{translateX:Ve}]},N]}):null,(ut=i.map(e=>{const t=e.key===n,i=t?ke:Oe,a=t?ze:Oe,s="string"==typeof e.icon?{name:e.icon,variant:"bold"}:e.icon,l=t?e.activeIcon??s:e.icon,d=fe.current[e.key],c=ve.current[e.key];if(void 0===d||void 0===c)throw new Error(`BottomNavigation has no animation values for tab "${e.key}".`);const u=badgeVariantOf(e.badge??null),p=badgeAccessibilitySuffix(e.badge??null,E),h=ee&&!t?.7:1,_=J&&t||ee?Be.primary:Be.surface,m=hasLabel(e),g=m&&(!Q||t),b=(0,_jsxRuntime.jsxs)(_reactNative.Animated.View,{style:[V.iconWrap,{width:L+4,height:L+4,opacity:h,transform:[{scale:d}]}],children:[(0,_jsxRuntime.jsx)(_reactNative.View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:(0,_index3.renderSlotIcon)(l,{color:a,size:L,focused:t,disabled:!1})}),u?(0,_jsxRuntime.jsx)(_index4.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?V.badgeDotPosition:V.badgePillPosition,badgeStyle:["dot"===u?V.badgeDot:V.badgePill,{borderColor:_}],textStyle:V.badgeText}):null]}),x=J?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:{top:c.interpolate({inputRange:[0,1],outputRange:[0,-14]})},children:b}):b,f=g?(0,_jsxRuntime.jsx)(_reactNative.Animated.Text,{numberOfLines:1,maxFontSizeMultiplier:A??I.settings.maxFontSizeMultiplier??1.2,style:[V.label,Q?V.labelInline:null,{color:i,opacity:Q?c:h,fontWeight:t?I.weight.semibold:I.weight.normal},j],children:e.label}):null,y=(0,_jsxRuntime.jsx)(_reactNative.Pressable,{onPress:()=>(e=>{H&&z(v),e.key!==n&&!1!==o&&(0,_index2.triggerHaptic)(o);const t=fe.current[e.key];t&&popIcon(t),r(e.key)})(e),accessibilityRole:"tab",accessibilityState:{selected:t},"aria-selected":t,accessibilityLabel:`${e.label}${p}`,accessibilityHint:E.switchesTo(e.label),hitSlop:{top:6,bottom:6,left:6,right:6},...(0,_hitSlop.hitSlopMarker)({top:6,bottom:6,left:6,right:6}),style:({pressed:e})=>[V.tab,Y?V.tabTile:null,e?{opacity:.85}:null],testID:w?`${w}-tab-${e.key}`:void 0,children:Q?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[V.expandPill,{height:D,paddingHorizontal:t&&m?I.space.md:Math.max(0,(D-(L+4))/2)}],children:[(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"none",style:[V.expandFill,{borderRadius:activeBgRadius(D,D/2),..._corners.smoothCorners,backgroundColor:t?Be["primary-soft"]:"transparent"},t?N:null]}),x,f]}):(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[x,f]})},e.key);return Q?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:{flex:c.interpolate({inputRange:[0,1],outputRange:[1,m?1.5:1]})},children:y},e.key):y}),st?[...ut.slice(0,se),st,...ut.slice(se)]:ut),"underline"===l&&ge>0?(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{pointerEvents:"none",style:[V.underline,"top"===d?V.underlineTop:V.underlineBottom,"top"===d?{top:-qe-Z}:{bottom:-qe},{width:ge,height:3,backgroundColor:Be.primary,transform:[{translateX:Ve}]},N]}):null]});var ut;return(0,_jsxRuntime.jsx)(_reactNative.View,{ref:t,testID:w,accessibilityRole:"tablist",style:[V.outer,{paddingHorizontal:Fe,paddingTop:Math.max(He,ot),paddingBottom:Xe},R],children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[K?V.floatingBar:V.dockedBar,$?V.barInline:null,tt,{backgroundColor:Ce,borderColor:at,borderRadius:Ye,..._corners.smoothCorners},K?{borderWidth:it,paddingHorizontal:Ue,paddingVertical:qe}:{borderTopWidth:it,borderBottomWidth:it,borderLeftWidth:it,borderRightWidth:it,paddingHorizontal:Je,paddingTop:qe,paddingBottom:$e}],children:[dt,ct]})})});BottomNavigation.displayName="BottomNavigation";const buildStyles=e=>_reactNative.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,..._corners.smoothCorners},underlineTop:{borderBottomLeftRadius:e.radius.none,borderBottomRightRadius:e.radius.none,..._corners.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}});var _default=exports.default=BottomNavigation;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.useBottomSheet=exports.default=exports.DEFAULT_BOTTOM_SHEET_LABELS=exports.BottomSheet=void 0;var cache,_react=require("react"),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_reactNativeKeyboardController=require("react-native-keyboard-controller"),_reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated")),_reactNativeSafeAreaContext=require("react-native-safe-area-context"),_usePresenceMotion=require("../../hooks/usePresenceMotion.js"),_index=require("../../theme/index.js"),_index2=require("../../utils/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_color=require("../../utils/color.js"),_corners=require("../../utils/corners.js"),_OverlayActions=require("../Dialog/OverlayActions.js"),_Modal=require("../Modal/Modal.js"),_ModalSafeArea=require("../ModalSafeArea/ModalSafeArea.js"),_index3=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var a,r,n=Object.defineProperty,o={__proto__:null,default:e};if(Object(e)!==e)return o;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,o)}for(r in e)"default"!==r&&{}.hasOwnProperty.call(e,r)&&((a=n&&Object.getOwnPropertyDescriptor(e,r))&&(a.get||a.set)?n(o,r,a):o[r]=e[r]);return o}const DEFAULT_BOTTOM_SHEET_LABELS=exports.DEFAULT_BOTTOM_SHEET_LABELS=Object.freeze({close:"Close bottom sheet",dragHandle:"Drag handle"}),DEFAULT_SNAP_POINTS=["content"],TABLET_MIN_SHORT_SIDE=600,DIALOG_MAX_WIDTH=560,BottomSheetContext=(0,_react.createContext)(null),useBottomSheet=()=>{const e=(0,_react.useContext)(BottomSheetContext);if(!e)throw new Error("[@webority/mobile-ui] BottomSheet: useBottomSheet must be used inside a <BottomSheet>.");return e};exports.useBottomSheet=useBottomSheet;const SPRING_CONFIG={damping:20,stiffness:240,mass:1},CLOSE_VELOCITY_THRESHOLD=1e3,DRAG_ACTIVATION_OFFSET=10,BottomSheet=e=>{const{snapPoints:t=DEFAULT_SNAP_POINTS,open:a,onClose:r,snapIndex:n,onSnapChange:o,onAnimate:s,onAfterClose:i,enablePanDownToClose:c=!0,enableBackdropPress:l=!0,onBeforeClose:u,title:d,labels:_,scrollable:h=!1,scrollRef:m,onScroll:v,onContentSizeChange:f,onScrollLayout:S,scrollEventThrottle:b,keyboardBehavior:p="shift",inline:y=!1,presentation:x="sheet",animateMount:R=!0,handleIndicatorStyle:N,containerStyle:g,header:w,actions:j,actionsLayout:C="auto",footer:M,headerStyle:O,footerStyle:E,children:T,accessibilityLabel:k,accessibilityViewIsModal:A,testID:B}=e;(0,_assertValidValue.assertValidValue)("BottomSheet","presentation",e.presentation,["sheet","dialog","auto"]),(0,_assertValidValue.assertValidValue)("BottomSheet","keyboardBehavior",e.keyboardBehavior,["none","shift"]),(0,_assertValidValue.assertValidValue)("BottomSheet","actionsLayout",e.actionsLayout,_OverlayActions.ACTIONS_LAYOUTS);const V=(0,_react.useMemo)(()=>({...DEFAULT_BOTTOM_SHEET_LABELS,..._}),[_]),I=null!=w||null!=d,L=null!=j&&j.length>0,P=null!=M||L,D=y?"inline":"modal",H=(0,_index.useTheme)(),G=(0,_usePresenceMotion.usePresenceMotion)(),q=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),[F,U]=(0,_react.useState)(()=>_reactNative.Dimensions.get("window").height),[J,z]=(0,_react.useState)(()=>_reactNative.Dimensions.get("window").width),W=(0,_react.useCallback)(e=>{const{height:t,width:a}=e.nativeEvent.layout;t>0&&U(e=>e===t?e:t),a>0&&z(e=>e===a?e:a)},[]),Y=(0,_reactNative.useWindowDimensions)(),K="dialog"===x||"auto"===x&&Math.min(Y.width,Y.height)>=600,$=Math.min(560,J-2*H.space.xl),[X,Q]=(0,_ModalSafeArea.useModalInsets)(),Z="modal"===D?X.top:q.top,ee="modal"===D?X.bottom:q.bottom,te=t.includes("content"),[ae,re]=useMeasuredHeight(),[ne,oe]=useMeasuredHeight(),[se,ie,ce]=useMeasuredHeight(),[le,ue]=useMeasuredHeight(),de=K?H.space.md:ae,he=te?Math.min(de+(I?ne:0)+se+(P?le:0)+ee,F-Z):0,me=(0,_react.useCallback)((e,t)=>{te&&ce(t),f?.(e,t)},[te,f,ce]),ve=(0,_react.useMemo)(()=>resolveSnapPoints(t,F,he),[t,F,he]),fe=F,Se=ve[ve.length-1]??0,be=(0,_reactNativeReanimated.useSharedValue)(fe),pe=(0,_reactNativeReanimated.useSharedValue)(fe),ye=(0,_reactNativeReanimated.useSharedValue)(1),xe=(0,_reactNativeReanimated.useSharedValue)(-1),[Re,Ne]=(0,_react.useState)(-1),ge=(0,_react.useRef)(!1),[we,je]=(0,_react.useState)(!1),[Ce,Me]=(0,_react.useState)(!1),Oe=(0,_react.useRef)(!1),Ee=(0,_react.useRef)(i);Ee.current=i;const[Te,ke]=(0,_react.useState)(!1),Ae=(0,_react.useRef)(!R&&a),Be=(0,_react.useRef)(-1),Ve=(0,_react.useRef)(!1);Ve.current="modal"===D?Ce:Te;const Ie=(0,_react.useRef)(u);Ie.current=u;const Le=(0,_react.useRef)(r);Le.current=r;const Pe=(0,_react.useRef)(!1),De=(0,_react.useRef)(!0),He=(0,_react.useRef)([]),Ge=(0,_react.useCallback)(e=>{const t=He.current;He.current=[];for(const a of t)a(e)},[]);(0,_react.useEffect)(()=>(De.current=!0,()=>{De.current=!1,Ge(!1)}),[Ge]);const qe=(0,_react.useCallback)(e=>{if(e<0||e>=ve.length)return fe;const t=ve[e];if(void 0===t)throw new Error("BottomSheet: an in-range snap index always has a resolved snap point");return K?(F-t)/2:F-t},[ve,F,fe,K]),Fe=(0,_react.useCallback)(e=>{Be.current=e;Re!==e&&(Ne(e),xe.value=e,e>=0&&o?.(e))},[Re,xe,o]),Ue=(0,_react.useCallback)(()=>{ge.current=!1,xe.value<0&&(Oe.current=!0,"modal"===D?(je(!1),"ios"!==_reactNative.Platform.OS&&Me(!1)):ke(!1))},[D,xe]),Je=(0,_react.useCallback)(()=>{Oe.current&&Me(!1)},[]);(0,_react.useEffect)(()=>{("modal"===D?!Ce:!Te)&&Oe.current&&(Oe.current=!1,Ee.current?.(),Ge(!0))},[D,Ce,Te,Ge]);const ze=(0,_react.useCallback)((e,t,a)=>{ge.current=!0,s?.(t,a),be.value=(0,_reactNativeReanimated.withSpring)(e,SPRING_CONFIG,e=>{"worklet";e&&(0,_reactNativeReanimated.runOnJS)(Ue)()})},[s,be,Ue]),We=(0,_react.useCallback)(e=>{const t="number"==typeof e?clamp(e,0,ve.length-1):Re>=0?Re:0,a=xe.value,r=qe(t);return Oe.current=!1,Ge(!1),"modal"===D?(Me(!0),je(!0)):ke(!0),a<0&&Ae.current?(be.value=r,ye.value=1,Fe(t),void s?.(a,t)):a<0&&G.reduced?(be.value=r,ye.value=0,ye.value=(0,_reactNativeReanimated.withTiming)(1,{duration:G.duration("fast"),easing:_reactNativeReanimated.Easing.bezier(...H.motion.ease.decelerate),reduceMotion:_usePresenceMotion.PRESENCE_REDUCE_MOTION}),Fe(t),void s?.(a,t)):(a<0&&(be.value=fe,ye.value=1),Fe(t),void ze(r,a,t))},[ze,fe,Re,xe,D,s,G,ye,ve.length,Fe,Ge,H.motion.ease.decelerate,be,qe]),Ye=(0,_react.useCallback)(()=>new Promise(e=>{if(Be.current<0)return void(Ve.current?He.current.push(e):e(!0));He.current.push(e),Ae.current=!1;const t=xe.value;Fe(-1),ge.current=!0,s?.(t,-1);const a=G.reduced?ye:be,r=G.reduced?0:fe;a.value=(0,_reactNativeReanimated.withTiming)(r,{duration:G.duration("fast"),easing:_reactNativeReanimated.Easing.bezier(...H.motion.ease.accelerate),reduceMotion:_usePresenceMotion.PRESENCE_REDUCE_MOTION},e=>{"worklet";e&&(0,_reactNativeReanimated.runOnJS)(Ue)()})}),[fe,xe,Ue,s,G,ye,Fe,be,H.motion.ease.accelerate]),Ke=(0,_react.useCallback)((e,t,a)=>{const r=Ie.current;if(!r)return void e();if(Pe.current)return void t?.();const n=r();"boolean"!=typeof n?(Pe.current=!0,a?.(),n.then(a=>{Pe.current=!1,a&&De.current&&Be.current>=0?e():t?.()},e=>{throw Pe.current=!1,e})):(n?e:t)?.()},[]),$e=(0,_react.useCallback)(()=>new Promise(e=>{Be.current<0?e(!0):Ke(()=>{Le.current(),Ye(),e(!0)},()=>e(!1))}),[Ye,Ke]),Xe=(0,_react.useCallback)(()=>{Le.current()},[]),Qe=(0,_react.useCallback)(()=>{l&&$e()},[l,$e]),Ze=(0,_react.useRef)(null);(0,_react.useEffect)(()=>{const e=Ze.current!==a;Ze.current=a,e?a?We(n??0):Ye():a&&"number"==typeof n&&n!==xe.value&&We(n)},[a,n]);const et=(0,_react.useRef)({hostHeight:F,contentSnap:he});(0,_react.useEffect)(()=>{const e=et.current;if(e.hostHeight===F&&e.contentSnap===he)return;if(et.current={hostHeight:F,contentSnap:he},e.hostHeight===F&&xe.value<0)return;const t=qe(xe.value);be.value=Ae.current?t:(0,_reactNativeReanimated.withSpring)(t,SPRING_CONFIG)},[F,he]);const tt=F-Se,at=(0,_react.useMemo)(()=>ve.map(e=>F-e),[ve,F]),rt=(0,_react.useCallback)(()=>{const e=Be.current;e<0||ze(qe(e),e,e)},[ze,qe]),nt=(0,_react.useCallback)((e,t)=>{const a=xe.value;-1!==e?(Fe(e),ze(t,a,e)):Ke(()=>{_reactNative.Keyboard.dismiss(),(0,_index2.triggerHaptic)("selection"),Le.current(),Ye()},rt,rt)},[ze,Ye,xe,Ke,Fe,rt]),ot=(0,_react.useMemo)(()=>_reactNativeGestureHandler.Gesture.Native().withTestId(B?`${B}-content-gesture`:"bottom-sheet-content-gesture"),[B]),st=(0,_react.useMemo)(()=>{const e=at,t=fe,a=tt,r=c;return _reactNativeGestureHandler.Gesture.Pan().withTestId(B?`${B}-pan-gesture`:"bottom-sheet-pan-gesture").activeOffsetY([-10,10]).failOffsetX([-15,15]).onStart(()=>{"worklet";pe.value=be.value}).onUpdate(e=>{"worklet";const t=pe.value+e.translationY;be.value=t<a?a+.25*(t-a):t}).onEnd(a=>{"worklet";const n=be.value,o=a.velocityY,[s]=e;if(void 0===s)return void(0,_reactNativeReanimated.runOnJS)(nt)(-1,t);if(o>1e3)return r?void(0,_reactNativeReanimated.runOnJS)(nt)(-1,t):void(0,_reactNativeReanimated.runOnJS)(nt)(0,s);let i=0,c=s,l=1/0,u=0;for(const t of e){const e=Math.abs(n-t);e<l&&(l=e,c=t,i=u),u++}r&&n-s>80?(0,_reactNativeReanimated.runOnJS)(nt)(-1,t):(0,_reactNativeReanimated.runOnJS)(nt)(i,c)})},[fe,pe,c,nt,tt,at,B,be]),{height:it}=(0,_reactNativeKeyboardController.useReanimatedKeyboardAnimation)(),ct="shift"===p,lt=(0,_reactNativeReanimated.useDerivedValue)(()=>ct?it.value:0,[ct,it]),ut=ve[Re>=0?Re:0]??Se,dt=H.space.md,_t=(0,_reactNativeReanimated.useAnimatedStyle)(()=>{if(K){const e=lt.value,t=F+e-ut-dt,a=e<0&&be.value>t?t:be.value;return{top:a<Z?Z:a,opacity:ye.value}}const e=be.value+lt.value,t=lt.value<0?Z:tt;return{top:e<t?t:e,opacity:ye.value}},[K,lt,F,ut,dt,be,Z,ye,tt]),ht=(0,_reactNativeReanimated.useAnimatedStyle)(()=>{const e=lt.value;if(K){const t=F+e-ut-dt,a=e<0&&be.value>t?t:be.value,r=F+e-dt-(a<Z?Z:a);return{height:r<0?0:r>ut?ut:r}}const t=e<0?Z:tt,a=be.value+e,r=F+e-(a<t?t:a);return{height:r<0?0:r>Se?Se:r}},[lt,K,F,ut,dt,be,Z,tt,Se]),mt=Re>=0,vt=(0,_react.useMemo)(()=>buildStyles(H),[H]),ft=(0,_react.useCallback)(()=>{l&&Ke(()=>{(0,_index2.triggerHaptic)("selection"),Le.current(),Ye()})},[l,Ye,Ke]),St=(0,_react.useMemo)(()=>_reactNativeGestureHandler.Gesture.Tap().withTestId(B?`${B}-backdrop-gesture`:"bottom-sheet-backdrop-gesture").maxDuration(250).onEnd((_e,e)=>{"worklet";e&&(0,_reactNativeReanimated.runOnJS)(ft)()}),[ft,B]),bt=(0,_react.useMemo)(()=>({snapIndex:Re,snapPoints:ve,close:Xe,requestClose:$e}),[Re,ve,Xe,$e]);if("inline"===D&&!Te)return null;if("modal"===D&&!Ce)return null;const pt=(0,_jsxRuntime.jsxs)(_reactNative.View,{collapsable:!1,style:["modal"===D?vt.backdropModal:vt.backdropInline,{backgroundColor:"modal"===D?(0,_color.transparentOf)(H.colors.scrim):H.colors.scrim}],onLayout:W,testID:B,accessibilityViewIsModal:A??mt,children:[(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:St,children:(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:_reactNative.StyleSheet.absoluteFill,accessibilityRole:"button",accessibilityLabel:V.close})}),(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{accessibilityRole:"alert",accessibilityLabel:k,accessibilityViewIsModal:A??mt,accessibilityActions:[{name:"escape",label:V.close}],onAccessibilityAction:e=>{"escape"===e.nativeEvent.actionName&&Qe()},onAccessibilityEscape:Qe,style:[vt.sheet,{height:Se,backgroundColor:H.colors.surface,borderTopLeftRadius:H.radius.xl,borderTopRightRadius:H.radius.xl,..._corners.smoothCorners,...H.shadow.modal},K?{height:ut,left:(J-$)/2,right:void 0,width:$,borderBottomLeftRadius:H.radius.xl,borderBottomRightRadius:H.radius.xl}:null,g,_t],children:(0,_jsxRuntime.jsxs)(SheetBody,{style:[vt.body,ht],keyboardOffset:lt,children:[K?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{height:H.space.md}}):(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:st,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:vt.handleRow,onLayout:te?re:void 0,accessible:!0,accessibilityLabel:V.dragHandle,accessibilityHint:"Drag up or down to resize the sheet, or swipe down to close it",testID:B?`${B}-handle`:"bottom-sheet-handle",children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:[vt.handle,{backgroundColor:H.colors.border},N]})})}),I&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[vt.header,O],onLayout:te?oe:void 0,children:[null!=d?(0,_jsxRuntime.jsx)(_index3.Text,{variant:"title",accessibilityRole:"header",children:d}):null,w]}),h?(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:ot,children:(0,_jsxRuntime.jsx)(_reactNative.ScrollView,{ref:m,style:vt.scrollContent,onScroll:v,onContentSizeChange:me,onLayout:S,scrollEventThrottle:b,keyboardShouldPersistTaps:"always",keyboardDismissMode:"none",children:T})}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:te?[vt.content,{overflow:"visible"}]:vt.content,children:te?(0,_jsxRuntime.jsx)(_reactNative.View,{onLayout:ie,children:T}):T}),P&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[vt.footer,E],onLayout:te?ue:void 0,children:[L?(0,_jsxRuntime.jsx)(_reactNative.View,{style:vt.actions,children:(0,_jsxRuntime.jsx)(_OverlayActions.OverlayActions,{actions:j??[],layout:C})}):null,M]})]})})]}),yt=(0,_jsxRuntime.jsx)(BottomSheetContext.Provider,{value:bt,children:pt});return"modal"===D?(0,_jsxRuntime.jsx)(_Modal.Modal,{open:we,onClose:Qe,presentation:"fullScreen",bare:!0,backdropPressClose:!1,haptic:!1,animateMount:!1,onInsetsChange:Q,onDismissed:"ios"===_reactNative.Platform.OS?Je:void 0,children:"android"===_reactNative.Platform.OS?(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureHandlerRootView,{style:vt.modalRoot,children:yt}):yt}):yt};exports.BottomSheet=BottomSheet;const SheetBody=({style:e,keyboardOffset:t,children:a})=>{const r=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)().bottom,n=(0,_reactNativeReanimated.useAnimatedStyle)(()=>{const e=r+t.value;return{paddingBottom:e>0?e:0}},[r,t]);return(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[e,n],children:a})};BottomSheet.displayName="BottomSheet";const useMeasuredHeight=()=>{const[e,t]=(0,_react.useState)(0),a=(0,_react.useCallback)(e=>{t(t=>t===e?t:e)},[]);return[e,(0,_react.useCallback)(e=>a(e.nativeEvent.layout.height),[a]),a]},resolveSnapPoints=(e,t,a)=>[...e.map(e=>{if("number"==typeof e)return e;if("content"===e)return a;const r=parseFloat(e);return Number.isNaN(r)?0:r/100*t})].sort((e,t)=>e-t),clamp=(e,t,a)=>Math.min(Math.max(e,t),a),buildStyles=e=>_reactNative.StyleSheet.create({backdropModal:{flex:1},backdropInline:{..._reactNative.StyleSheet.absoluteFill},sheet:{position:"absolute",left:0,right:0,overflow:"hidden"},body:{overflow:"hidden"},handleRow:{alignItems:"center",justifyContent:"center",alignSelf:"stretch",paddingTop:e.space.md,paddingBottom:e.space.xl},header:{},actions:{padding:e.space.lg},footer:{},handle:{width:36,height:4,borderRadius:e.radius.pill,..._corners.smoothCorners},content:{flex:1,overflow:"hidden"},scrollContent:{flex:1},modalRoot:{flex:1}});var _default=exports.default=BottomSheet;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.useBottomSheet=exports.default=exports.DEFAULT_BOTTOM_SHEET_LABELS=exports.BottomSheet=void 0;var cache,_react=require("react"),_reactNative=require("react-native"),_reactNativeGestureHandler=require("react-native-gesture-handler"),_reactNativeKeyboardController=require("react-native-keyboard-controller"),_reactNativeReanimated=_interopRequireWildcard(require("react-native-reanimated")),_reactNativeSafeAreaContext=require("react-native-safe-area-context"),_usePresenceMotion=require("../../hooks/usePresenceMotion.js"),_index=require("../../theme/index.js"),_index2=require("../../utils/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_color=require("../../utils/color.js"),_corners=require("../../utils/corners.js"),_OverlayActions=require("../Dialog/OverlayActions.js"),_Modal=require("../Modal/Modal.js"),_ModalSafeArea=require("../ModalSafeArea/ModalSafeArea.js"),_index3=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var a,r,n=Object.defineProperty,o={__proto__:null,default:e};if(Object(e)!==e)return o;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,o)}for(r in e)"default"!==r&&{}.hasOwnProperty.call(e,r)&&((a=n&&Object.getOwnPropertyDescriptor(e,r))&&(a.get||a.set)?n(o,r,a):o[r]=e[r]);return o}const DEFAULT_BOTTOM_SHEET_LABELS=exports.DEFAULT_BOTTOM_SHEET_LABELS=Object.freeze({close:"Close bottom sheet",dragHandle:"Drag handle"}),DEFAULT_SNAP_POINTS=["content"],TABLET_MIN_SHORT_SIDE=600,DIALOG_MAX_WIDTH=560,BottomSheetContext=(0,_react.createContext)(null),useBottomSheet=()=>{const e=(0,_react.useContext)(BottomSheetContext);if(!e)throw new Error("[@webority/mobile-ui] BottomSheet: useBottomSheet must be used inside a <BottomSheet>.");return e};exports.useBottomSheet=useBottomSheet;const SPRING_CONFIG={damping:20,stiffness:240,mass:1},CLOSE_VELOCITY_THRESHOLD=1e3,DRAG_ACTIVATION_OFFSET=10,BottomSheet=e=>{const{snapPoints:t=DEFAULT_SNAP_POINTS,open:a,onClose:r,snapIndex:n,onSnapChange:o,onAnimate:s,onAfterClose:i,enablePanDownToClose:c=!0,enableBackdropPress:l=!0,onBeforeClose:u,title:d,labels:_,scrollable:h=!1,scrollRef:m,onScroll:v,onContentSizeChange:f,onScrollLayout:S,scrollEventThrottle:b,keyboardBehavior:p="shift",inline:y=!1,presentation:x="sheet",animateMount:R=!0,handleIndicatorStyle:N,containerStyle:g,header:j,actions:C,actionsLayout:w="auto",footer:M,headerStyle:O,footerStyle:E,children:k,accessibilityLabel:T,accessibilityViewIsModal:A,testID:B}=e;(0,_assertValidValue.assertValidValue)("BottomSheet","presentation",e.presentation,["sheet","dialog","auto"]),(0,_assertValidValue.assertValidValue)("BottomSheet","keyboardBehavior",e.keyboardBehavior,["none","shift"]),(0,_assertValidValue.assertValidValue)("BottomSheet","actionsLayout",e.actionsLayout,_OverlayActions.ACTIONS_LAYOUTS);const V=(0,_react.useMemo)(()=>({...DEFAULT_BOTTOM_SHEET_LABELS,..._}),[_]),I=null!=j||null!=d,D=null!=C&&C.length>0,L=null!=M||D,P=y?"inline":"modal",H=(0,_index.useTheme)(),G=(0,_usePresenceMotion.usePresenceMotion)(),q=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)(),[F,U]=(0,_react.useState)(()=>_reactNative.Dimensions.get("window").height),[J,z]=(0,_react.useState)(()=>_reactNative.Dimensions.get("window").width),W=(0,_react.useCallback)(e=>{const{height:t,width:a}=e.nativeEvent.layout;t>0&&U(e=>e===t?e:t),a>0&&z(e=>e===a?e:a)},[]),Y=(0,_reactNative.useWindowDimensions)(),K="dialog"===x||"auto"===x&&Math.min(Y.width,Y.height)>=600,$=Math.min(560,J-2*H.space.xl),[X,Q]=(0,_ModalSafeArea.useModalInsets)(),Z="modal"===P?X.top:q.top,ee="modal"===P?X.bottom:q.bottom,te=t.includes("content"),[ae,re]=useMeasuredHeight(),[ne,oe]=useMeasuredHeight(),[se,ie,ce]=useMeasuredHeight(),[le,ue]=useMeasuredHeight(),de=K?H.space.md:ae,he=te?Math.min(de+(I?ne:0)+se+(L?le:0)+ee,F-Z):0,me=(0,_react.useCallback)((e,t)=>{te&&ce(t),f?.(e,t)},[te,f,ce]),ve=(0,_react.useMemo)(()=>resolveSnapPoints(t,F,he),[t,F,he]),fe=F,Se=ve[ve.length-1]??0,be=(0,_reactNativeReanimated.useSharedValue)(fe),pe=(0,_reactNativeReanimated.useSharedValue)(fe),ye=(0,_reactNativeReanimated.useSharedValue)(1),xe=(0,_reactNativeReanimated.useSharedValue)(-1),[Re,Ne]=(0,_react.useState)(-1),ge=(0,_react.useRef)(!1),[je,Ce]=(0,_react.useState)(!1),[we,Me]=(0,_react.useState)(!1),Oe=(0,_react.useRef)(!1),Ee=(0,_react.useRef)(i);Ee.current=i;const[ke,Te]=(0,_react.useState)(!1),Ae=(0,_react.useRef)(!R&&a),Be=(0,_react.useRef)(-1),Ve=(0,_react.useRef)(!1);Ve.current="modal"===P?we:ke;const Ie=(0,_react.useRef)(u);Ie.current=u;const De=(0,_react.useRef)(r);De.current=r;const Le=(0,_react.useRef)(!1),Pe=(0,_react.useRef)(!0),He=(0,_react.useRef)([]),Ge=(0,_react.useCallback)(e=>{const t=He.current;He.current=[];for(const a of t)a(e)},[]);(0,_react.useEffect)(()=>(Pe.current=!0,()=>{Pe.current=!1,Ge(!1)}),[Ge]);const qe=(0,_react.useCallback)(e=>{if(e<0||e>=ve.length)return fe;const t=ve[e];if(void 0===t)throw new Error("BottomSheet: an in-range snap index always has a resolved snap point");return K?(F-t)/2:F-t},[ve,F,fe,K]),Fe=(0,_react.useCallback)(e=>{Be.current=e;Re!==e&&(Ne(e),xe.value=e,e>=0&&o?.(e))},[Re,xe,o]),Ue=(0,_react.useCallback)(()=>{ge.current=!1,xe.value<0&&(Oe.current=!0,"modal"===P?(Ce(!1),"ios"!==_reactNative.Platform.OS&&Me(!1)):Te(!1))},[P,xe]),Je=(0,_react.useCallback)(()=>{Oe.current&&Me(!1)},[]);(0,_react.useEffect)(()=>{("modal"===P?!we:!ke)&&Oe.current&&(Oe.current=!1,Ee.current?.(),Ge(!0))},[P,we,ke,Ge]);const ze=(0,_react.useCallback)((e,t,a)=>{ge.current=!0,s?.(t,a),be.value=(0,_reactNativeReanimated.withSpring)(e,SPRING_CONFIG,e=>{"worklet";e&&(0,_reactNativeReanimated.runOnJS)(Ue)()})},[s,be,Ue]),We=(0,_react.useCallback)(e=>{const t="number"==typeof e?clamp(e,0,ve.length-1):Re>=0?Re:0,a=xe.value,r=qe(t);return Oe.current=!1,Ge(!1),"modal"===P?(Me(!0),Ce(!0)):Te(!0),a<0&&Ae.current?(be.value=r,ye.value=1,Fe(t),void s?.(a,t)):a<0&&G.reduced?(be.value=r,ye.value=0,ye.value=(0,_reactNativeReanimated.withTiming)(1,{duration:G.duration("fast"),easing:_reactNativeReanimated.Easing.bezier(...H.motion.ease.decelerate),reduceMotion:_usePresenceMotion.PRESENCE_REDUCE_MOTION}),Fe(t),void s?.(a,t)):(a<0&&(be.value=fe,ye.value=1),Fe(t),void ze(r,a,t))},[ze,fe,Re,xe,P,s,G,ye,ve.length,Fe,Ge,H.motion.ease.decelerate,be,qe]),Ye=(0,_react.useCallback)(()=>new Promise(e=>{if(Be.current<0)return void(Ve.current?He.current.push(e):e(!0));He.current.push(e),Ae.current=!1;const t=xe.value;Fe(-1),ge.current=!0,s?.(t,-1);const a=G.reduced?ye:be,r=G.reduced?0:fe;a.value=(0,_reactNativeReanimated.withTiming)(r,{duration:G.duration("fast"),easing:_reactNativeReanimated.Easing.bezier(...H.motion.ease.accelerate),reduceMotion:_usePresenceMotion.PRESENCE_REDUCE_MOTION},e=>{"worklet";e&&(0,_reactNativeReanimated.runOnJS)(Ue)()})}),[fe,xe,Ue,s,G,ye,Fe,be,H.motion.ease.accelerate]),Ke=(0,_react.useCallback)((e,t,a)=>{const r=Ie.current;if(!r)return void e();if(Le.current)return void t?.();const n=r();"boolean"!=typeof n?(Le.current=!0,a?.(),n.then(a=>{Le.current=!1,a&&Pe.current&&Be.current>=0?e():t?.()},e=>{throw Le.current=!1,e})):(n?e:t)?.()},[]),$e=(0,_react.useCallback)(()=>new Promise(e=>{Be.current<0?e(!0):Ke(()=>{De.current(),Ye(),e(!0)},()=>e(!1))}),[Ye,Ke]),Xe=(0,_react.useCallback)(()=>{De.current()},[]),Qe=(0,_react.useCallback)(()=>{l&&$e()},[l,$e]),Ze=(0,_react.useRef)(null);(0,_react.useEffect)(()=>{const e=Ze.current!==a;Ze.current=a,e?a?We(n??0):Ye():a&&"number"==typeof n&&n!==xe.value&&We(n)},[a,n]);const et=(0,_react.useRef)({hostHeight:F,contentSnap:he});(0,_react.useEffect)(()=>{const e=et.current;if(e.hostHeight===F&&e.contentSnap===he)return;if(et.current={hostHeight:F,contentSnap:he},e.hostHeight===F&&xe.value<0)return;const t=qe(xe.value);be.value=Ae.current?t:(0,_reactNativeReanimated.withSpring)(t,SPRING_CONFIG)},[F,he]);const tt=F-Se,at=(0,_react.useMemo)(()=>ve.map(e=>F-e),[ve,F]),rt=(0,_react.useCallback)(()=>{const e=Be.current;e<0||ze(qe(e),e,e)},[ze,qe]),nt=(0,_react.useCallback)((e,t)=>{const a=xe.value;-1!==e?(Fe(e),ze(t,a,e)):Ke(()=>{_reactNative.Keyboard.dismiss(),(0,_index2.triggerHaptic)("selection"),De.current(),Ye()},rt,rt)},[ze,Ye,xe,Ke,Fe,rt]),ot=(0,_react.useMemo)(()=>({testID:B?`${B}-content-gesture`:"bottom-sheet-content-gesture"}),[B]),st=(0,_reactNativeGestureHandler.useNativeGesture)(ot),it=(0,_react.useMemo)(()=>{const e=at,t=fe,a=tt,r=c;return{testID:B?`${B}-pan-gesture`:"bottom-sheet-pan-gesture",activeOffsetY:[-10,10],failOffsetX:[-15,15],onActivate:()=>{"worklet";pe.value=be.value},onUpdate:e=>{"worklet";const t=pe.value+e.translationY;be.value=t<a?a+.25*(t-a):t},onDeactivate:a=>{"worklet";const n=be.value,o=a.velocityY,[s]=e;if(void 0===s)return void(0,_reactNativeReanimated.runOnJS)(nt)(-1,t);if(o>1e3)return r?void(0,_reactNativeReanimated.runOnJS)(nt)(-1,t):void(0,_reactNativeReanimated.runOnJS)(nt)(0,s);let i=0,c=s,l=1/0,u=0;for(const t of e){const e=Math.abs(n-t);e<l&&(l=e,c=t,i=u),u++}r&&n-s>80?(0,_reactNativeReanimated.runOnJS)(nt)(-1,t):(0,_reactNativeReanimated.runOnJS)(nt)(i,c)}}},[fe,pe,c,nt,tt,at,B,be]),ct=(0,_reactNativeGestureHandler.usePanGesture)(it),{height:lt}=(0,_reactNativeKeyboardController.useReanimatedKeyboardAnimation)(),ut="shift"===p,dt=(0,_reactNativeReanimated.useDerivedValue)(()=>ut?lt.value:0,[ut,lt]),_t=ve[Re>=0?Re:0]??Se,ht=H.space.md,mt=(0,_reactNativeReanimated.useAnimatedStyle)(()=>{if(K){const e=dt.value,t=F+e-_t-ht,a=e<0&&be.value>t?t:be.value;return{top:a<Z?Z:a,opacity:ye.value}}const e=be.value+dt.value,t=dt.value<0?Z:tt;return{top:e<t?t:e,opacity:ye.value}},[K,dt,F,_t,ht,be,Z,ye,tt]),vt=(0,_reactNativeReanimated.useAnimatedStyle)(()=>{const e=dt.value;if(K){const t=F+e-_t-ht,a=e<0&&be.value>t?t:be.value,r=F+e-ht-(a<Z?Z:a);return{height:r<0?0:r>_t?_t:r}}const t=e<0?Z:tt,a=be.value+e,r=F+e-(a<t?t:a);return{height:r<0?0:r>Se?Se:r}},[dt,K,F,_t,ht,be,Z,tt,Se]),ft=Re>=0,St=(0,_react.useMemo)(()=>buildStyles(H),[H]),bt=(0,_react.useCallback)(()=>{l&&Ke(()=>{(0,_index2.triggerHaptic)("selection"),De.current(),Ye()})},[l,Ye,Ke]),pt=(0,_react.useMemo)(()=>({testID:B?`${B}-backdrop-gesture`:"bottom-sheet-backdrop-gesture",maxDuration:250,onDeactivate:e=>{"worklet";e.canceled||(0,_reactNativeReanimated.runOnJS)(bt)()}}),[bt,B]),yt=(0,_reactNativeGestureHandler.useTapGesture)(pt),xt=(0,_react.useMemo)(()=>({snapIndex:Re,snapPoints:ve,close:Xe,requestClose:$e}),[Re,ve,Xe,$e]);if("inline"===P&&!ke)return null;if("modal"===P&&!we)return null;const Rt=(0,_jsxRuntime.jsxs)(_reactNative.View,{collapsable:!1,style:["modal"===P?St.backdropModal:St.backdropInline,{backgroundColor:"modal"===P?(0,_color.transparentOf)(H.colors.scrim):H.colors.scrim}],onLayout:W,testID:B,accessibilityViewIsModal:A??ft,children:[(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:yt,children:(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:_reactNative.StyleSheet.absoluteFill,accessibilityRole:"button",accessibilityLabel:V.close})}),(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{accessibilityRole:"alert",accessibilityLabel:T,accessibilityViewIsModal:A??ft,accessibilityActions:[{name:"escape",label:V.close}],onAccessibilityAction:e=>{"escape"===e.nativeEvent.actionName&&Qe()},onAccessibilityEscape:Qe,style:[St.sheet,{height:Se,backgroundColor:H.colors.surface,borderTopLeftRadius:H.radius.xl,borderTopRightRadius:H.radius.xl,..._corners.smoothCorners,...H.shadow.modal},K?{height:_t,left:(J-$)/2,right:void 0,width:$,borderBottomLeftRadius:H.radius.xl,borderBottomRightRadius:H.radius.xl}:null,g,mt],children:(0,_jsxRuntime.jsxs)(SheetBody,{style:[St.body,vt],keyboardOffset:dt,children:[K?(0,_jsxRuntime.jsx)(_reactNative.View,{style:{height:H.space.md}}):(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:ct,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:St.handleRow,onLayout:te?re:void 0,accessible:!0,accessibilityLabel:V.dragHandle,accessibilityHint:"Drag up or down to resize the sheet, or swipe down to close it",testID:B?`${B}-handle`:"bottom-sheet-handle",children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:[St.handle,{backgroundColor:H.colors.border},N]})})}),I&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[St.header,O],onLayout:te?oe:void 0,children:[null!=d?(0,_jsxRuntime.jsx)(_index3.Text,{variant:"title",accessibilityRole:"header",children:d}):null,j]}),h?(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureDetector,{gesture:st,children:(0,_jsxRuntime.jsx)(_reactNative.ScrollView,{ref:m,style:St.scrollContent,onScroll:v,onContentSizeChange:me,onLayout:S,scrollEventThrottle:b,keyboardShouldPersistTaps:"always",keyboardDismissMode:"none",children:k})}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:te?[St.content,{overflow:"visible"}]:St.content,children:te?(0,_jsxRuntime.jsx)(_reactNative.View,{onLayout:ie,children:k}):k}),L&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[St.footer,E],onLayout:te?ue:void 0,children:[D?(0,_jsxRuntime.jsx)(_reactNative.View,{style:St.actions,children:(0,_jsxRuntime.jsx)(_OverlayActions.OverlayActions,{actions:C??[],layout:w})}):null,M]})]})})]}),Nt=(0,_jsxRuntime.jsx)(BottomSheetContext.Provider,{value:xt,children:Rt});return"modal"===P?(0,_jsxRuntime.jsx)(_Modal.Modal,{open:je,onClose:Qe,presentation:"fullScreen",bare:!0,backdropPressClose:!1,haptic:!1,animateMount:!1,onInsetsChange:Q,onDismissed:"ios"===_reactNative.Platform.OS?Je:void 0,children:"android"===_reactNative.Platform.OS?(0,_jsxRuntime.jsx)(_reactNativeGestureHandler.GestureHandlerRootView,{style:St.modalRoot,children:Nt}):Nt}):Nt};exports.BottomSheet=BottomSheet;const SheetBody=({style:e,keyboardOffset:t,children:a})=>{const r=(0,_reactNativeSafeAreaContext.useSafeAreaInsets)().bottom,n=(0,_reactNativeReanimated.useAnimatedStyle)(()=>{const e=r+t.value;return{paddingBottom:e>0?e:0}},[r,t]);return(0,_jsxRuntime.jsx)(_reactNativeReanimated.default.View,{style:[e,n],children:a})};BottomSheet.displayName="BottomSheet";const useMeasuredHeight=()=>{const[e,t]=(0,_react.useState)(0),a=(0,_react.useCallback)(e=>{t(t=>t===e?t:e)},[]);return[e,(0,_react.useCallback)(e=>a(e.nativeEvent.layout.height),[a]),a]},resolveSnapPoints=(e,t,a)=>[...e.map(e=>{if("number"==typeof e)return e;if("content"===e)return a;const r=parseFloat(e);return Number.isNaN(r)?0:r/100*t})].sort((e,t)=>e-t),clamp=(e,t,a)=>Math.min(Math.max(e,t),a),buildStyles=e=>_reactNative.StyleSheet.create({backdropModal:{flex:1},backdropInline:{..._reactNative.StyleSheet.absoluteFill},sheet:{position:"absolute",left:0,right:0,overflow:"hidden"},body:{overflow:"hidden"},handleRow:{alignItems:"center",justifyContent:"center",alignSelf:"stretch",paddingTop:e.space.md,paddingBottom:e.space.xl},header:{},actions:{padding:e.space.lg},footer:{},handle:{width:36,height:4,borderRadius:e.radius.pill,..._corners.smoothCorners},content:{flex:1,overflow:"hidden"},scrollContent:{flex:1},modalRoot:{flex:1}});var _default=exports.default=BottomSheet;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.resolveBoxStyle=exports.default=exports.Stack=exports.Spacer=exports.Row=exports.Box=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../../theme/index.js"),_scale=require("../../theme/scale.js"),_corners=require("../../utils/corners.js"),_SquircleFill=require("../SquircleFill/SquircleFill.js"),_jsxRuntime=require("react/jsx-runtime");const BACKGROUND_TOKENS=["bg","bg-subtle","bg-muted","surface","scrim","surface-inverse","primary-wash"],space=(e,r)=>null==r?void 0:(0,_scale.spaceOf)(e,r),resolveBoxStyle=(e,r)=>({...null!=r.p?{padding:space(e,r.p)}:{},...null!=r.px?{paddingHorizontal:space(e,r.px)}:{},...null!=r.py?{paddingVertical:space(e,r.py)}:{},...null!=r.pt?{paddingTop:space(e,r.pt)}:{},...null!=r.pr?{paddingRight:space(e,r.pr)}:{},...null!=r.pb?{paddingBottom:space(e,r.pb)}:{},...null!=r.pl?{paddingLeft:space(e,r.pl)}:{},...null!=r.m?{margin:space(e,r.m)}:{},...null!=r.mx?{marginHorizontal:space(e,r.mx)}:{},...null!=r.my?{marginVertical:space(e,r.my)}:{},...null!=r.mt?{marginTop:space(e,r.mt)}:{},...null!=r.mr?{marginRight:space(e,r.mr)}:{},...null!=r.mb?{marginBottom:space(e,r.mb)}:{},...null!=r.ml?{marginLeft:space(e,r.ml)}:{},...null!=r.gap?{gap:space(e,r.gap)}:{},...null!=r.bg?{backgroundColor:BACKGROUND_TOKENS.includes(r.bg)?e.colors[r.bg]:r.bg}:{},...null!=r.radius?{borderRadius:(0,_scale.radiusOf)(e,r.radius),borderCurve:_corners.smoothCorners.borderCurve}:{},...r.border?{borderWidth:e.size.border,borderColor:e.colors.border}:{},...null!=r.flex?{flex:r.flex}:{},...null!=r.align?{alignItems:r.align}:{},...null!=r.justify?{justifyContent:r.justify}:{},...null!=r.direction?{flexDirection:r.direction}:{},...r.wrap?{flexWrap:"wrap"}:{}});exports.resolveBoxStyle=resolveBoxStyle;const Box=exports.Box=(0,_react.forwardRef)((e,r)=>{const l=(0,_index.useTheme)(),{p:t,px:a,py:i,pt:s,pr:o,pb:n,pl:p,m:c,mx:u,my:d,mt:m,mr:x,mb:g,ml:b,gap:f,bg:y,radius:_,border:S,flex:j,align:h,justify:R,direction:v,wrap:w,style:B,children:q,...C}=e,N=resolveBoxStyle(l,{p:t,px:a,py:i,pt:s,pr:o,pb:n,pl:p,m:c,mx:u,my:d,mt:m,mr:x,mb:g,ml:b,gap:f,bg:y,radius:_,border:S,flex:j,align:h,justify:R,direction:v,wrap:w}),k=(0,_SquircleFill.useSquircle)(null!=_&&(null!=y||Boolean(S)),N.borderRadius,C.onLayout),O=k.active?{...N,backgroundColor:"transparent",borderColor:"transparent"}:N;return(0,_jsxRuntime.jsxs)(_reactNative.View,{ref:r,...C,onLayout:k.onLayout,style:[O,B],children:[k.active&&k.size?(0,_jsxRuntime.jsx)(_SquircleFill.SquircleFill,{width:k.size.width,height:k.size.height,radius:N.borderRadius,fill:N.backgroundColor??"transparent",stroke:N.borderColor,strokeWidth:N.borderWidth??0}):null,q]})});Box.displayName="Box";const Stack=exports.Stack=(0,_react.forwardRef)(({gap:e="md",...r},l)=>(0,_jsxRuntime.jsx)(Box,{ref:l,direction:"column",gap:e,...r}));Stack.displayName="Stack";const Row=exports.Row=(0,_react.forwardRef)(({gap:e="sm",align:r="center",...l},t)=>(0,_jsxRuntime.jsx)(Box,{ref:t,direction:"row",gap:e,align:r,...l}));Row.displayName="Row";const Spacer=({size:e,style:r,testID:l})=>{const t=(0,_index.useTheme)();if(null!=e){const a=(0,_scale.spaceOf)(t,e);return(0,_jsxRuntime.jsx)(_reactNative.View,{testID:l,style:[{width:a,height:a},r]})}return(0,_jsxRuntime.jsx)(_reactNative.View,{testID:l,style:[{flex:1},r]})};exports.Spacer=Spacer,Spacer.displayName="Spacer";var _default=exports.default=Box;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.resolveBoxStyle=exports.default=exports.Stack=exports.Spacer=exports.Row=exports.Box=void 0;var _react=require("react"),_reactNative=require("react-native"),_index=require("../../theme/index.js"),_scale=require("../../theme/scale.js"),_corners=require("../../utils/corners.js"),_guards=require("../../utils/guards.js"),_SquircleFill=require("../SquircleFill/SquircleFill.js"),_jsxRuntime=require("react/jsx-runtime");const BACKGROUND_TOKENS=["bg","bg-subtle","bg-muted","surface","scrim","surface-inverse","primary-wash"],space=(e,r)=>null==r?void 0:(0,_scale.spaceOf)(e,r),resolveBoxStyle=(e,r)=>({...null!=r.p?{padding:space(e,r.p)}:{},...null!=r.px?{paddingHorizontal:space(e,r.px)}:{},...null!=r.py?{paddingVertical:space(e,r.py)}:{},...null!=r.pt?{paddingTop:space(e,r.pt)}:{},...null!=r.pr?{paddingRight:space(e,r.pr)}:{},...null!=r.pb?{paddingBottom:space(e,r.pb)}:{},...null!=r.pl?{paddingLeft:space(e,r.pl)}:{},...null!=r.m?{margin:space(e,r.m)}:{},...null!=r.mx?{marginHorizontal:space(e,r.mx)}:{},...null!=r.my?{marginVertical:space(e,r.my)}:{},...null!=r.mt?{marginTop:space(e,r.mt)}:{},...null!=r.mr?{marginRight:space(e,r.mr)}:{},...null!=r.mb?{marginBottom:space(e,r.mb)}:{},...null!=r.ml?{marginLeft:space(e,r.ml)}:{},...null!=r.gap?{gap:space(e,r.gap)}:{},...null!=r.bg?{backgroundColor:(0,_guards.isOneOf)(BACKGROUND_TOKENS,r.bg)?e.colors[r.bg]:r.bg}:{},...null!=r.radius?{borderRadius:(0,_scale.radiusOf)(e,r.radius),borderCurve:_corners.smoothCorners.borderCurve}:{},...r.border?{borderWidth:e.size.border,borderColor:e.colors.border}:{},...null!=r.flex?{flex:r.flex}:{},...null!=r.align?{alignItems:r.align}:{},...null!=r.justify?{justifyContent:r.justify}:{},...null!=r.direction?{flexDirection:r.direction}:{},...r.wrap?{flexWrap:"wrap"}:{}});exports.resolveBoxStyle=resolveBoxStyle;const Box=exports.Box=(0,_react.forwardRef)((e,r)=>{const t=(0,_index.useTheme)(),{p:l,px:a,py:i,pt:s,pr:o,pb:n,pl:p,m:u,mx:c,my:d,mt:m,mr:x,mb:g,ml:b,gap:f,bg:y,radius:_,border:j,flex:S,align:h,justify:R,direction:v,wrap:w,style:B,children:q,...C}=e,N=resolveBoxStyle(t,{p:l,px:a,py:i,pt:s,pr:o,pb:n,pl:p,m:u,mx:c,my:d,mt:m,mr:x,mb:g,ml:b,gap:f,bg:y,radius:_,border:j,flex:S,align:h,justify:R,direction:v,wrap:w}),k="number"==typeof N.borderRadius?N.borderRadius:0,O="string"==typeof N.backgroundColor?N.backgroundColor:"transparent",z="string"==typeof N.borderColor?N.borderColor:void 0,D="number"==typeof N.borderWidth?N.borderWidth:0,F=(0,_SquircleFill.useSquircle)(null!=_&&(null!=y||Boolean(j)),k,C.onLayout),T=F.active?{...N,backgroundColor:"transparent",borderColor:"transparent"}:N;return(0,_jsxRuntime.jsxs)(_reactNative.View,{ref:r,...C,onLayout:F.onLayout,style:[T,B],children:[F.active&&F.size?(0,_jsxRuntime.jsx)(_SquircleFill.SquircleFill,{width:F.size.width,height:F.size.height,radius:k,fill:O,stroke:z,strokeWidth:D}):null,q]})});Box.displayName="Box";const Stack=exports.Stack=(0,_react.forwardRef)(({gap:e="md",...r},t)=>(0,_jsxRuntime.jsx)(Box,{ref:t,direction:"column",gap:e,...r}));Stack.displayName="Stack";const Row=exports.Row=(0,_react.forwardRef)(({gap:e="sm",align:r="center",...t},l)=>(0,_jsxRuntime.jsx)(Box,{ref:l,direction:"row",gap:e,align:r,...t}));Row.displayName="Row";const Spacer=({size:e,style:r,testID:t})=>{const l=(0,_index.useTheme)();if(null!=e){const a=(0,_scale.spaceOf)(l,e);return(0,_jsxRuntime.jsx)(_reactNative.View,{testID:t,style:[{width:a,height:a},r]})}return(0,_jsxRuntime.jsx)(_reactNative.View,{testID:t,style:[{flex:1},r]})};exports.Spacer=Spacer,Spacer.displayName="Spacer";var _default=exports.default=Box;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.DEFAULT_CARD_LABELS=exports.Card=void 0;var cache,_react=_interopRequireWildcard(require("react")),_reactNative=require("react-native"),_useControllableState=require("../../hooks/useControllableState.js"),_usePressAnimation=require("../../hooks/usePressAnimation.js"),_index=require("../../theme/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_corners=require("../../utils/corners.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_mergeRefs=require("../../utils/mergeRefs.js"),_shadows=require("../../utils/shadows.js"),_squircle=require("../../utils/squircle.js"),_themeStyles=require("../../utils/themeStyles.js"),_AppIcon=require("../AppIcon/AppIcon.js"),_useContextMenu=require("../Menu/useContextMenu.js"),_index2=require("../Skeleton/index.js"),_SquircleFill=require("../SquircleFill/SquircleFill.js"),_index3=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var i,s,a=Object.defineProperty,r={__proto__:null,default:e};if(Object(e)!==e)return r;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,r)}for(s in e)"default"!==s&&{}.hasOwnProperty.call(e,s)&&((i=a&&Object.getOwnPropertyDescriptor(e,s))&&(i.get||i.set)?a(r,s,i):r[s]=e[s]);return r}const BACKGROUND_TOKENS=["bg","bg-subtle","bg-muted","surface","scrim","surface-inverse","primary-wash"],DEFAULT_CARD_LABELS=exports.DEFAULT_CARD_LABELS=Object.freeze({remove:"Remove",show:"Show",hide:"Hide",loading:"Loading"}),paddingMap={none:"none",sm:"sm",md:"lg",lg:"xl",xl:"2xl"},Card=exports.Card=_react.default.memo((0,_react.forwardRef)((e,t)=>{const{children:i,variant:s,elevation:a="card",radius:r,padding:n,interactive:l=!1,pressAnimation:o="scale",bg:d,header:c,title:u,titleFont:h,lead:m,action:_,headerActions:x,collapsible:p=!1,collapsed:b,defaultCollapsed:g=!1,onCollapsedChange:j,collapsedSummary:y,onRemove:v,separatorHeight:R=_reactNative.StyleSheet.hairlineWidth,footer:f,imageSource:S,imageHeight:C=160,imageAspectRatio:w,imageOverlay:A,loading:V=!1,gradient:q,onPress:F,haptic:N,contextMenu:L,accessibilityLabel:k,accessibilityHint:T,accessibilityRole:B,style:P,containerStyle:I,headerStyle:D,bodyStyle:H,footerStyle:M,testID:z,labels:E,onLayout:O,...W}=e;(0,_assertValidValue.assertValidValue)("Card","variant",e.variant,["elevated","outline","filled","flat"]),(0,_assertValidValue.assertValidValue)("Card","radius",e.radius,["sm","md","lg","xl","pill"]),(0,_assertValidValue.assertValidValue)("Card","padding",e.padding,["none","sm","md","lg","xl"]),(0,_assertValidValue.assertValidValue)("Card","titleFont",e.titleFont,["sans","serif"]),(0,_assertValidValue.assertValidValue)("Card","pressAnimation",e.pressAnimation,["scale","bounce","fade","sink","pulse","dim","false"]);const U=(0,_index.useTheme)(),G=U.settings.components.card,K=s??G?.defaultVariant??"elevated",$=r??G?.defaultRadius??"lg",J=n??G?.defaultPadding??"md",Q=h??G?.defaultTitleFont??"sans",X=(0,_react.useMemo)(()=>({...DEFAULT_CARD_LABELS,...E}),[E]),Y=l||"function"==typeof F,Z=(0,_useContextMenu.useContextMenu)(L,{haptic:N||!1,testID:z,accessibilityActions:W.accessibilityActions,onAccessibilityAction:W.onAccessibilityAction}),ee=(0,_react.useMemo)(()=>(0,_mergeRefs.mergeRefs)(t,Z.hostRef),[t,Z.hostRef]),te=Y||Z.enabled,{style:ie,pressIn:se,pressOut:ae}=(0,_usePressAnimation.usePressAnimation)({preset:o||"scale",enabled:te&&!1!==o}),re=stylesFor(U),ne=Boolean(S),le=U.space[paddingMap[J]],oe=(0,_react.useMemo)(()=>q?"string"==typeof q?U.settings.gradients[q]??null:q:null,[q,U.settings.gradients]),de="flat"===K,ce=de?U.radius.none:U.radius[$],ue=resolveBackground(U,d),[he,me]=(0,_useControllableState.useControllableState)({value:b,defaultValue:g,onChange:j}),xe=p&&he,pe=hasBuiltInHeaderContent(e),be=Boolean(c)||pe,ge=(0,_SquircleFill.useSquircle)(!ne&&!oe&&!de,ce,O),je=_reactNative.StyleSheet.flatten([I,P])??{},ye=je.backgroundColor,ve=je.borderColor,Re=ye??ue??("filled"===K?U.colors["bg-subtle"]:U.colors.surface),fe="outline"===K?U.size.border:0,Se=ve??U.colors.border,Ce="none"===a?void 0:U.shadow[a],we="elevated"===K&&(0,_shadows.supportsBoxShadow)()&&Ce?(0,_shadows.toBoxShadow)(Ce):void 0,Ae=ge.active&&"elevated"===K&&!we,Ve=ge.active&&!Ae?{backgroundColor:"transparent",borderColor:"transparent"}:null,qe=(0,_react.useMemo)(()=>{const e={borderRadius:Ae&&ge.size?(0,_squircle.squircleHostRadius)(ge.size.width,ge.size.height,ce):ce,..._corners.smoothCorners,padding:ne||ge.active?U.space.none:le,overflow:ge.active?"visible":"hidden"};switch(K){case"flat":return{...e,backgroundColor:ue??U.colors.surface,borderBottomWidth:R,borderBottomColor:U.colors.border};case"outline":return{...e,backgroundColor:ge.active?"transparent":ue??U.colors.surface,borderWidth:U.size.border,borderColor:ge.active?"transparent":U.colors.border};case"filled":return{...e,backgroundColor:ge.active?"transparent":ue??U.colors["bg-subtle"]};default:return{...e,backgroundColor:ue??U.colors.surface,...we?{boxShadow:we}:Ce}}},[U,K,Ce,ce,ne,le,ge.active,ge.size,we,Ae,ue,R]),Fe=(0,_react.useMemo)(()=>({..."number"==typeof w?{width:"100%",aspectRatio:w}:{width:"100%",height:C},borderTopLeftRadius:ce,borderTopRightRadius:ce,borderBottomLeftRadius:U.radius.none,borderBottomRightRadius:U.radius.none,..._corners.smoothCorners}),[U,ce,w,C]),Ne=u??"",Le=(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:re.titleColumn,children:[u?(0,_jsxRuntime.jsx)(_index3.Text,{variant:"title",accessibilityRole:"header",style:titleFaceFor(U,Q),children:u}):null,m?(0,_jsxRuntime.jsx)(_index3.Text,{variant:"bodySmall",style:re.lead,children:m}):null,xe&&y?(0,_jsxRuntime.jsx)(_index3.Text,{variant:"caption",style:re.lead,children:y}):null]}),isCardTextAction(_)?(0,_jsxRuntime.jsx)(CardTextActionButton,{action:_,haptic:N}):_?(0,_jsxRuntime.jsx)(_reactNative.View,{style:re.actionNode,children:_}):null,x,p?(0,_jsxRuntime.jsx)(CardIconAction,{icon:xe?"chevron-down":"chevron-up",label:`${xe?X.show:X.hide} ${Ne}`.trim(),expanded:!xe,onPress:()=>me(!xe),haptic:N}):null,v?(0,_jsxRuntime.jsx)(CardIconAction,{icon:"trash",label:X.remove,onPress:v,color:U.colors["danger-text"],haptic:N}):null]}),ke=(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[be?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[re.header,!c&&re.headerRow,xe&&re.headerFolded,D],children:c??Le}):null,xe?null:(0,_jsxRuntime.jsx)(_reactNative.View,{style:[be||f?re.body:null,H],children:i}),f&&!xe?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[re.footer,M],children:f}):null]}),Te=ne?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:re.imageWrapper,children:[(0,_jsxRuntime.jsx)(_reactNative.Image,{source:S,resizeMode:"cover",style:Fe,accessibilityLabel:"",accessible:!1}),A?(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"box-none",style:re.imageOverlay,children:A}):null]}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:{padding:le},children:ke})]}):ke,Be=oe?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_index.Gradient,{gradient:oe,style:_reactNative.StyleSheet.absoluteFill}),Te]}):ge.active&&ge.size?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_SquircleFill.SquircleFill,{width:ge.size.width,height:ge.size.height,radius:ce,fill:Re,stroke:fe?Se:void 0,strokeWidth:fe}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:[re.squircleClip,{padding:le,borderRadius:ge.size?(0,_squircle.squircleHostRadius)(ge.size.width,ge.size.height,ce):ce}],children:Te})]}):Te;let Pe;if(te){const handlePress=e=>{Y&&(N&&(0,_hapticUtils.triggerHaptic)(N),F?.(e))};Pe=(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:ie,children:(0,_jsxRuntime.jsx)(_reactNative.Pressable,{ref:ee,onPress:handlePress,onPressIn:se,onPressOut:ae,accessibilityRole:B??(Y?"button":void 0),accessibilityLabel:k,accessibilityHint:T,testID:z,onLayout:ge.onLayout,style:[qe,I,P,Ve],...W,...Z.hostProps,children:Be})})}else Pe=(0,_jsxRuntime.jsx)(_reactNative.View,{ref:t,accessibilityLabel:k,accessibilityHint:T,accessibilityRole:B,testID:z,onLayout:ge.onLayout,style:[qe,I,P,Ve],...W,children:Be});return V?(0,_jsxRuntime.jsx)(CardSkeleton,{...e}):Z.enabled?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[Pe,Z.renderSurface((0,_jsxRuntime.jsx)(_reactNative.View,{style:[qe,I,P,Ve,re.preview],children:Be}))]}):Pe}));Card.displayName="Card";const CardSkeleton=({variant:e,elevation:t,radius:i,padding:s,bg:a,header:r,footer:n,imageSource:l,imageHeight:o=160,imageAspectRatio:d,containerStyle:c,headerStyle:u,bodyStyle:h,footerStyle:m,style:_,labels:x,...p})=>{const b=(0,_index.useTheme)(),g=b.settings.components.card,j=e??g?.defaultVariant??"elevated",y=i??g?.defaultRadius??"lg",v=s??g?.defaultPadding??"md",R={...DEFAULT_CARD_LABELS,...x},f=paddingMap[v],S=b.space[f],C="flat"===j?b.radius.none:b.radius[y],w=void 0!==r||hasBuiltInHeaderContent(p),A=resolveBackground(b,a)??b.colors.surface,V="outline"===j?1:0,q="outline"===j?b.colors.border:void 0;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[{backgroundColor:A,borderRadius:C,..._corners.smoothCorners,borderWidth:V,borderColor:q,overflow:"hidden"},c,_],accessibilityRole:"progressbar",accessibilityLabel:R.loading,accessibilityState:{busy:!0},"aria-busy":!0,children:[void 0!==l?(0,_jsxRuntime.jsx)(_index2.Skeleton,{width:"100%",height:d?void 0:o,style:d?{aspectRatio:d,width:"100%"}:void 0}):null,w?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[{padding:S,paddingBottom:b.space.sm},u],children:(0,_jsxRuntime.jsx)(_index2.Skeleton,{shape:"text",width:"60%",height:18})}):null,(0,_jsxRuntime.jsx)(_reactNative.View,{style:[{padding:S},h],children:(0,_jsxRuntime.jsx)(_index2.SkeletonText,{lines:3,fontSize:b.text.base.size,lastLineWidth:"55%"})}),void 0!==n?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[{padding:S,paddingTop:b.space.sm,flexDirection:"row"},m],children:(0,_jsxRuntime.jsx)(_index2.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.default.isValidElement(e)&&"label"in e&&"onPress"in e,HIT_TARGET=44,CardIconAction=({icon:e,label:t,onPress:i,expanded:s,color:a,haptic:r})=>{const n=(0,_index.useTheme)();return(0,_jsxRuntime.jsx)(_reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:t,accessibilityState:void 0===s?void 0:{expanded:s},"aria-expanded":s,onPress:()=>{r&&(0,_hapticUtils.triggerHaptic)(r),i()},style:iconActionStyle,children:(0,_jsxRuntime.jsx)(_reactNative.View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:(0,_jsxRuntime.jsx)(_AppIcon.AppIcon,{name:e,size:20,color:a??n.colors["text-body"]})})})},CardTextActionButton=({action:e,haptic:t})=>(0,_jsxRuntime.jsx)(_reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:e.accessibilityLabel??e.label,onPress:()=>{t&&(0,_hapticUtils.triggerHaptic)(t),e.onPress()},style:textActionStyle,children:(0,_jsxRuntime.jsx)(_index3.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?(0,_index.fontFor)(e,"semibold","display"):{fontFamily:void 0,...(0,_index.fontFor)(e,"semibold")},resolveBackground=(e,t)=>{if(null!=t)return BACKGROUND_TOKENS.includes(t)?e.colors[t]:t},buildStyles=e=>_reactNative.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:{..._reactNative.StyleSheet.absoluteFill},squircleClip:{flexGrow:1,overflow:"hidden",..._corners.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=(0,_themeStyles.themeStyles)(buildStyles);var _default=exports.default=Card;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.DEFAULT_CARD_LABELS=exports.Card=void 0;var cache,_react=_interopRequireWildcard(require("react")),_reactNative=require("react-native"),_useControllableState=require("../../hooks/useControllableState.js"),_usePressAnimation=require("../../hooks/usePressAnimation.js"),_index=require("../../theme/index.js"),_assertValidValue=require("../../utils/assertValidValue.js"),_corners=require("../../utils/corners.js"),_guards=require("../../utils/guards.js"),_hapticUtils=require("../../utils/hapticUtils.js"),_mergeRefs=require("../../utils/mergeRefs.js"),_shadows=require("../../utils/shadows.js"),_squircle=require("../../utils/squircle.js"),_themeStyles=require("../../utils/themeStyles.js"),_AppIcon=require("../AppIcon/AppIcon.js"),_useContextMenu=require("../Menu/useContextMenu.js"),_index2=require("../Skeleton/index.js"),_SquircleFill=require("../SquircleFill/SquircleFill.js"),_index3=require("../Text/index.js"),_jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if(!t&&e&&e.__esModule)return e;var i,s,a=Object.defineProperty,r={__proto__:null,default:e};if(Object(e)!==e)return r;if(cache||"function"!=typeof WeakMap||(cache=new WeakMap),cache){if(cache.has(e))return cache.get(e);cache.set(e,r)}for(s in e)"default"!==s&&{}.hasOwnProperty.call(e,s)&&((i=a&&Object.getOwnPropertyDescriptor(e,s))&&(i.get||i.set)?a(r,s,i):r[s]=e[s]);return r}const BACKGROUND_TOKENS=["bg","bg-subtle","bg-muted","surface","scrim","surface-inverse","primary-wash"],DEFAULT_CARD_LABELS=exports.DEFAULT_CARD_LABELS=Object.freeze({remove:"Remove",show:"Show",hide:"Hide",loading:"Loading"}),paddingMap={none:"none",sm:"sm",md:"lg",lg:"xl",xl:"2xl"},CardRoot=_react.default.memo((0,_react.forwardRef)((e,t)=>{const{children:i,variant:s,elevation:a="card",radius:r,padding:n,interactive:o=!1,pressAnimation:l="scale",bg:d,header:c,title:u,titleFont:h,lead:m,action:_,headerActions:x,collapsible:p=!1,collapsed:g,defaultCollapsed:b=!1,onCollapsedChange:j,collapsedSummary:y,onRemove:v,separatorHeight:R=_reactNative.StyleSheet.hairlineWidth,footer:f,imageSource:S,imageHeight:C=160,imageAspectRatio:w,imageOverlay:A,loading:V=!1,gradient:q,onPress:F,haptic:N,contextMenu:L,accessibilityLabel:k,accessibilityHint:T,accessibilityRole:B,style:P,containerStyle:I,headerStyle:D,bodyStyle:H,footerStyle:M,testID:O,labels:z,onLayout:E,...W}=e;(0,_assertValidValue.assertValidValue)("Card","variant",e.variant,["elevated","outline","filled","flat"]),(0,_assertValidValue.assertValidValue)("Card","radius",e.radius,["sm","md","lg","xl","pill"]),(0,_assertValidValue.assertValidValue)("Card","padding",e.padding,["none","sm","md","lg","xl"]),(0,_assertValidValue.assertValidValue)("Card","titleFont",e.titleFont,["sans","serif"]),(0,_assertValidValue.assertValidValue)("Card","pressAnimation",e.pressAnimation,["scale","bounce","fade","sink","pulse","dim","false"]);const U=(0,_index.useTheme)(),G=U.settings.components.card,K=s??G?.defaultVariant??"elevated",$=r??G?.defaultRadius??"lg",J=n??G?.defaultPadding??"md",Q=h??G?.defaultTitleFont??"sans",X=(0,_react.useMemo)(()=>({...DEFAULT_CARD_LABELS,...z}),[z]),Y=o||"function"==typeof F,Z=(0,_useContextMenu.useContextMenu)(L,{haptic:N||!1,testID:O,accessibilityActions:W.accessibilityActions,onAccessibilityAction:W.onAccessibilityAction}),ee=(0,_react.useMemo)(()=>(0,_mergeRefs.mergeRefs)(t,Z.hostRef),[t,Z.hostRef]),te=Y||Z.enabled,{style:ie,pressIn:se,pressOut:ae}=(0,_usePressAnimation.usePressAnimation)({preset:l||"scale",enabled:te&&!1!==l}),re=stylesFor(U),ne=Boolean(S),oe=U.space[paddingMap[J]],le=(0,_react.useMemo)(()=>q?"string"==typeof q?U.settings.gradients[q]??null:q:null,[q,U.settings.gradients]),de="flat"===K,ce=de?U.radius.none:U.radius[$],ue=resolveBackground(U,d),[he,me]=(0,_useControllableState.useControllableState)({value:g,defaultValue:b,onChange:j}),xe=p&&he,pe=hasBuiltInHeaderContent(e),ge=Boolean(c)||pe,be=(0,_SquircleFill.useSquircle)(!ne&&!le&&!de,ce,E),je=_reactNative.StyleSheet.flatten([I,P])??{},ye="string"==typeof je.backgroundColor?je.backgroundColor:void 0,ve="string"==typeof je.borderColor?je.borderColor:void 0,Re=ye??ue??("filled"===K?U.colors["bg-subtle"]:U.colors.surface),fe="outline"===K?U.size.border:0,Se=ve??U.colors.border,Ce="none"===a?void 0:U.shadow[a],we="elevated"===K&&(0,_shadows.supportsBoxShadow)()&&Ce?(0,_shadows.toBoxShadow)(Ce):void 0,Ae=be.active&&"elevated"===K&&!we,Ve=be.active&&!Ae?{backgroundColor:"transparent",borderColor:"transparent"}:null,qe=(0,_react.useMemo)(()=>{const e={borderRadius:Ae&&be.size?(0,_squircle.squircleHostRadius)(be.size.width,be.size.height,ce):ce,..._corners.smoothCorners,padding:ne||be.active?U.space.none:oe,overflow:be.active?"visible":"hidden"};switch(K){case"flat":return{...e,backgroundColor:ue??U.colors.surface,borderBottomWidth:R,borderBottomColor:U.colors.border};case"outline":return{...e,backgroundColor:be.active?"transparent":ue??U.colors.surface,borderWidth:U.size.border,borderColor:be.active?"transparent":U.colors.border};case"filled":return{...e,backgroundColor:be.active?"transparent":ue??U.colors["bg-subtle"]};default:return{...e,backgroundColor:ue??U.colors.surface,...we?{boxShadow:we}:Ce}}},[U,K,Ce,ce,ne,oe,be.active,be.size,we,Ae,ue,R]),Fe=(0,_react.useMemo)(()=>({..."number"==typeof w?{width:"100%",aspectRatio:w}:{width:"100%",height:C},borderTopLeftRadius:ce,borderTopRightRadius:ce,borderBottomLeftRadius:U.radius.none,borderBottomRightRadius:U.radius.none,..._corners.smoothCorners}),[U,ce,w,C]),Ne=u??"",Le=(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:re.titleColumn,children:[u?(0,_jsxRuntime.jsx)(_index3.Text,{variant:"title",accessibilityRole:"header",style:titleFaceFor(U,Q),children:u}):null,m?(0,_jsxRuntime.jsx)(_index3.Text,{variant:"bodySmall",style:re.lead,children:m}):null,xe&&y?(0,_jsxRuntime.jsx)(_index3.Text,{variant:"caption",style:re.lead,children:y}):null]}),isCardTextAction(_)?(0,_jsxRuntime.jsx)(CardTextActionButton,{action:_,haptic:N}):_?(0,_jsxRuntime.jsx)(_reactNative.View,{style:re.actionNode,children:_}):null,x,p?(0,_jsxRuntime.jsx)(CardIconAction,{icon:xe?"chevron-down":"chevron-up",label:`${xe?X.show:X.hide} ${Ne}`.trim(),expanded:!xe,onPress:()=>me(!xe),haptic:N}):null,v?(0,_jsxRuntime.jsx)(CardIconAction,{icon:"trash",label:X.remove,onPress:v,color:U.colors["danger-text"],haptic:N}):null]}),ke=(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[ge?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[re.header,!c&&re.headerRow,xe&&re.headerFolded,D],children:c??Le}):null,xe?null:(0,_jsxRuntime.jsx)(_reactNative.View,{style:[ge||f?re.body:null,H],children:i}),f&&!xe?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[re.footer,M],children:f}):null]}),Te=S?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:re.imageWrapper,children:[(0,_jsxRuntime.jsx)(_reactNative.Image,{source:S,resizeMode:"cover",style:Fe,accessibilityLabel:"",accessible:!1}),A?(0,_jsxRuntime.jsx)(_reactNative.View,{pointerEvents:"box-none",style:re.imageOverlay,children:A}):null]}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:{padding:oe},children:ke})]}):ke,Be=le?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_index.Gradient,{gradient:le,style:_reactNative.StyleSheet.absoluteFill}),Te]}):be.active&&be.size?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_SquircleFill.SquircleFill,{width:be.size.width,height:be.size.height,radius:ce,fill:Re,stroke:fe?Se:void 0,strokeWidth:fe}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:[re.squircleClip,{padding:oe,borderRadius:be.size?(0,_squircle.squircleHostRadius)(be.size.width,be.size.height,ce):ce}],children:Te})]}):Te;let Pe;if(te){const handlePress=e=>{Y&&(N&&(0,_hapticUtils.triggerHaptic)(N),F?.(e))};Pe=(0,_jsxRuntime.jsx)(_reactNative.Animated.View,{style:ie,children:(0,_jsxRuntime.jsx)(_reactNative.Pressable,{ref:ee,onPress:handlePress,onPressIn:se,onPressOut:ae,accessibilityRole:B??(Y?"button":void 0),accessibilityLabel:k,accessibilityHint:T,testID:O,onLayout:be.onLayout,style:[qe,I,P,Ve],...W,...Z.hostProps,children:Be})})}else Pe=(0,_jsxRuntime.jsx)(_reactNative.View,{ref:t,accessibilityLabel:k,accessibilityHint:T,accessibilityRole:B,testID:O,onLayout:be.onLayout,style:[qe,I,P,Ve],...W,children:Be});return V?(0,_jsxRuntime.jsx)(CardSkeleton,{...e}):Z.enabled?(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[Pe,Z.renderSurface((0,_jsxRuntime.jsx)(_reactNative.View,{style:[qe,I,P,Ve,re.preview],children:Be}))]}):Pe})),CardSkeleton=({variant:e,elevation:t,radius:i,padding:s,bg:a,header:r,footer:n,imageSource:o,imageHeight:l=160,imageAspectRatio:d,containerStyle:c,headerStyle:u,bodyStyle:h,footerStyle:m,style:_,labels:x,...p})=>{const g=(0,_index.useTheme)(),b=g.settings.components.card,j=e??b?.defaultVariant??"elevated",y=i??b?.defaultRadius??"lg",v=s??b?.defaultPadding??"md",R={...DEFAULT_CARD_LABELS,...x},f=paddingMap[v],S=g.space[f],C="flat"===j?g.radius.none:g.radius[y],w=void 0!==r||hasBuiltInHeaderContent(p),A=resolveBackground(g,a)??g.colors.surface,V="outline"===j?1:0,q="outline"===j?g.colors.border:void 0;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[{backgroundColor:A,borderRadius:C,..._corners.smoothCorners,borderWidth:V,borderColor:q,overflow:"hidden"},c,_],accessibilityRole:"progressbar",accessibilityLabel:R.loading,accessibilityState:{busy:!0},"aria-busy":!0,children:[void 0!==o?(0,_jsxRuntime.jsx)(_index2.Skeleton,{width:"100%",height:d?void 0:l,style:d?{aspectRatio:d,width:"100%"}:void 0}):null,w?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[{padding:S,paddingBottom:g.space.sm},u],children:(0,_jsxRuntime.jsx)(_index2.Skeleton,{shape:"text",width:"60%",height:18})}):null,(0,_jsxRuntime.jsx)(_reactNative.View,{style:[{padding:S},h],children:(0,_jsxRuntime.jsx)(_index2.SkeletonText,{lines:3,fontSize:g.text.base.size,lastLineWidth:"55%"})}),void 0!==n?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[{padding:S,paddingTop:g.space.sm,flexDirection:"row"},m],children:(0,_jsxRuntime.jsx)(_index2.Skeleton,{width:88,height:32,shape:"rounded"})}):null]})};CardSkeleton.displayName="CardSkeleton";const Card=exports.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.default.isValidElement(e)&&"label"in e&&"onPress"in e,HIT_TARGET=44,CardIconAction=({icon:e,label:t,onPress:i,expanded:s,color:a,haptic:r})=>{const n=(0,_index.useTheme)();return(0,_jsxRuntime.jsx)(_reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:t,accessibilityState:void 0===s?void 0:{expanded:s},"aria-expanded":s,onPress:()=>{r&&(0,_hapticUtils.triggerHaptic)(r),i()},style:iconActionStyle,children:(0,_jsxRuntime.jsx)(_reactNative.View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:(0,_jsxRuntime.jsx)(_AppIcon.AppIcon,{name:e,size:20,color:a??n.colors["text-body"]})})})},CardTextActionButton=({action:e,haptic:t})=>(0,_jsxRuntime.jsx)(_reactNative.Pressable,{accessibilityRole:"button",accessibilityLabel:e.accessibilityLabel??e.label,onPress:()=>{t&&(0,_hapticUtils.triggerHaptic)(t),e.onPress()},style:textActionStyle,children:(0,_jsxRuntime.jsx)(_index3.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?(0,_index.fontFor)(e,"semibold","display"):{fontFamily:void 0,...(0,_index.fontFor)(e,"semibold")},resolveBackground=(e,t)=>{if(null!=t)return(0,_guards.isOneOf)(BACKGROUND_TOKENS,t)?e.colors[t]:t},buildStyles=e=>_reactNative.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:{..._reactNative.StyleSheet.absoluteFill},squircleClip:{flexGrow:1,overflow:"hidden",..._corners.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=(0,_themeStyles.themeStyles)(buildStyles);var _default=exports.default=Card;