@webority/mobile-ui 0.149.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 (459) hide show
  1. package/dist/canvas-kit/kit.js +13 -56714
  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/BottomNavigation/BottomNavigation.js +1 -1
  14. package/lib/commonjs/components/Box/Box.js +1 -1
  15. package/lib/commonjs/components/Card/Card.js +1 -1
  16. package/lib/commonjs/components/Carousel/Carousel.js +1 -1
  17. package/lib/commonjs/components/Chip/Chip.js +1 -1
  18. package/lib/commonjs/components/ChoiceGroup/ChoiceGroup.js +1 -1
  19. package/lib/commonjs/components/Confetti/Confetti.js +1 -1
  20. package/lib/commonjs/components/DatePicker/DatePicker.js +1 -1
  21. package/lib/commonjs/components/DateRangePicker/DateRangePicker.js +1 -1
  22. package/lib/commonjs/components/Descriptions/Descriptions.js +1 -1
  23. package/lib/commonjs/components/Dialog/Dialog.js +1 -1
  24. package/lib/commonjs/components/FileViewer/fileSource.js +1 -1
  25. package/lib/commonjs/components/FloatingActionButton/FloatingActionButton.js +1 -1
  26. package/lib/commonjs/components/ImageGallery/ImageGallery.js +1 -1
  27. package/lib/commonjs/components/InlineSelect/InlineSelect.js +1 -1
  28. package/lib/commonjs/components/Input/Input.js +1 -1
  29. package/lib/commonjs/components/ListItem/ListItem.js +1 -1
  30. package/lib/commonjs/components/Markdown/Markdown.js +1 -1
  31. package/lib/commonjs/components/Menu/MenuSurface.js +1 -1
  32. package/lib/commonjs/components/Menu/focusHost.js +1 -1
  33. package/lib/commonjs/components/OptionSheet/OptionSheet.js +1 -1
  34. package/lib/commonjs/components/OptionSheet/optionAccessors.js +1 -0
  35. package/lib/commonjs/components/PhoneNumberInput/PhoneNumberInput.js +1 -1
  36. package/lib/commonjs/components/ProgressRing/ProgressRing.js +1 -1
  37. package/lib/commonjs/components/Radio/RadioGroup.js +1 -1
  38. package/lib/commonjs/components/Rating/Rating.js +1 -1
  39. package/lib/commonjs/components/Repeater/Repeater.js +1 -1
  40. package/lib/commonjs/components/Screen/Screen.js +1 -1
  41. package/lib/commonjs/components/SearchBar/useRecentSearches.js +1 -1
  42. package/lib/commonjs/components/SegmentedControl/SegmentedControl.js +1 -1
  43. package/lib/commonjs/components/Select/Select.js +1 -1
  44. package/lib/commonjs/components/Skeleton/SkeletonContent.js +1 -1
  45. package/lib/commonjs/components/Skeleton/SkeletonList.js +1 -1
  46. package/lib/commonjs/components/Slider/Slider.js +1 -1
  47. package/lib/commonjs/components/SliderField/SliderField.js +1 -1
  48. package/lib/commonjs/components/SortableList/SortableList.js +1 -1
  49. package/lib/commonjs/components/Sparkline/Sparkline.js +1 -1
  50. package/lib/commonjs/components/SquircleFill/SquircleFill.js +1 -1
  51. package/lib/commonjs/components/StatTile/StatTile.js +1 -1
  52. package/lib/commonjs/components/StatusBadge/StatusBadge.js +1 -1
  53. package/lib/commonjs/components/StatusBadge/statusMap.js +1 -1
  54. package/lib/commonjs/components/Stepper/Stepper.js +1 -1
  55. package/lib/commonjs/components/Text/Text.js +1 -1
  56. package/lib/commonjs/components/TimePicker/TimePicker.js +1 -1
  57. package/lib/commonjs/components/WheelPicker/WheelPicker.js +1 -1
  58. package/lib/commonjs/form/HookFormField.js +1 -1
  59. package/lib/commonjs/form/path.js +1 -1
  60. package/lib/commonjs/hooks/useControllableState.js +1 -1
  61. package/lib/commonjs/specs/NativePdfRasterizer.js +1 -1
  62. package/lib/commonjs/theme/ThemeContext.js +1 -1
  63. package/lib/commonjs/theme/animatedValue.js +1 -1
  64. package/lib/commonjs/theme/componentSizes.js +1 -1
  65. package/lib/commonjs/theme/merge.js +1 -1
  66. package/lib/commonjs/theme/scale.js +1 -1
  67. package/lib/commonjs/utils/complete.js +1 -0
  68. package/lib/commonjs/utils/guards.js +1 -0
  69. package/lib/commonjs/utils/hapticUtils.js +1 -1
  70. package/lib/module/components/Accordion/Accordion.js +1 -1
  71. package/lib/module/components/AppIcon/AppIcon.js +1 -1
  72. package/lib/module/components/AppIcon/glyphs.g.js +1 -1
  73. package/lib/module/components/AsyncBlock/AsyncBlock.js +1 -1
  74. package/lib/module/components/AuthedImage/AuthedImage.js +1 -1
  75. package/lib/module/components/AuthedImage/authedImageCache.js +1 -1
  76. package/lib/module/components/Avatar/Avatar.js +1 -1
  77. package/lib/module/components/Badge/Badge.js +1 -1
  78. package/lib/module/components/Banner/Banner.js +1 -1
  79. package/lib/module/components/BottomNavigation/BottomNavigation.js +1 -1
  80. package/lib/module/components/Box/Box.js +1 -1
  81. package/lib/module/components/Card/Card.js +1 -1
  82. package/lib/module/components/Carousel/Carousel.js +1 -1
  83. package/lib/module/components/Chip/Chip.js +1 -1
  84. package/lib/module/components/ChoiceGroup/ChoiceGroup.js +1 -1
  85. package/lib/module/components/Confetti/Confetti.js +1 -1
  86. package/lib/module/components/DatePicker/DatePicker.js +1 -1
  87. package/lib/module/components/DateRangePicker/DateRangePicker.js +1 -1
  88. package/lib/module/components/Descriptions/Descriptions.js +1 -1
  89. package/lib/module/components/Dialog/Dialog.js +1 -1
  90. package/lib/module/components/FileViewer/fileSource.js +1 -1
  91. package/lib/module/components/FloatingActionButton/FloatingActionButton.js +1 -1
  92. package/lib/module/components/ImageGallery/ImageGallery.js +1 -1
  93. package/lib/module/components/InlineSelect/InlineSelect.js +1 -1
  94. package/lib/module/components/Input/Input.js +1 -1
  95. package/lib/module/components/ListItem/ListItem.js +1 -1
  96. package/lib/module/components/Markdown/Markdown.js +1 -1
  97. package/lib/module/components/Menu/MenuSurface.js +1 -1
  98. package/lib/module/components/Menu/focusHost.js +1 -1
  99. package/lib/module/components/OptionSheet/OptionSheet.js +1 -1
  100. package/lib/module/components/OptionSheet/optionAccessors.js +1 -0
  101. package/lib/module/components/PhoneNumberInput/PhoneNumberInput.js +1 -1
  102. package/lib/module/components/ProgressRing/ProgressRing.js +1 -1
  103. package/lib/module/components/Radio/RadioGroup.js +1 -1
  104. package/lib/module/components/Rating/Rating.js +1 -1
  105. package/lib/module/components/Repeater/Repeater.js +1 -1
  106. package/lib/module/components/Screen/Screen.js +1 -1
  107. package/lib/module/components/SearchBar/useRecentSearches.js +1 -1
  108. package/lib/module/components/SegmentedControl/SegmentedControl.js +1 -1
  109. package/lib/module/components/Select/Select.js +1 -1
  110. package/lib/module/components/Skeleton/SkeletonContent.js +1 -1
  111. package/lib/module/components/Skeleton/SkeletonList.js +1 -1
  112. package/lib/module/components/Slider/Slider.js +1 -1
  113. package/lib/module/components/SliderField/SliderField.js +1 -1
  114. package/lib/module/components/SortableList/SortableList.js +1 -1
  115. package/lib/module/components/Sparkline/Sparkline.js +1 -1
  116. package/lib/module/components/SquircleFill/SquircleFill.js +1 -1
  117. package/lib/module/components/StatTile/StatTile.js +1 -1
  118. package/lib/module/components/StatusBadge/StatusBadge.js +1 -1
  119. package/lib/module/components/StatusBadge/statusMap.js +1 -1
  120. package/lib/module/components/Stepper/Stepper.js +1 -1
  121. package/lib/module/components/Text/Text.js +1 -1
  122. package/lib/module/components/TimePicker/TimePicker.js +1 -1
  123. package/lib/module/components/WheelPicker/WheelPicker.js +1 -1
  124. package/lib/module/form/HookFormField.js +1 -1
  125. package/lib/module/form/path.js +1 -1
  126. package/lib/module/hooks/useControllableState.js +1 -1
  127. package/lib/module/specs/NativePdfRasterizer.js +1 -1
  128. package/lib/module/theme/ThemeContext.js +1 -1
  129. package/lib/module/theme/animatedValue.js +1 -1
  130. package/lib/module/theme/componentSizes.js +1 -1
  131. package/lib/module/theme/merge.js +1 -1
  132. package/lib/module/theme/scale.js +1 -1
  133. package/lib/module/utils/complete.js +1 -0
  134. package/lib/module/utils/guards.js +1 -0
  135. package/lib/module/utils/hapticUtils.js +1 -1
  136. package/lib/typescript/commonjs/canvasKit/index.d.ts +12 -12
  137. package/lib/typescript/commonjs/canvasKit/meta.d.ts +5 -7
  138. package/lib/typescript/commonjs/components/Accordion/Accordion.d.ts +22 -22
  139. package/lib/typescript/commonjs/components/AmountSlider/AmountSlider.d.ts +23 -23
  140. package/lib/typescript/commonjs/components/AnimatePresence/AnimatePresence.d.ts +5 -5
  141. package/lib/typescript/commonjs/components/AppBar/AppBar.d.ts +39 -39
  142. package/lib/typescript/commonjs/components/AppIcon/AppIcon.d.ts +7 -7
  143. package/lib/typescript/commonjs/components/AppIcon/defaultIcons.d.ts +2 -1
  144. package/lib/typescript/commonjs/components/AppIcon/glyphs.g.d.ts +233 -233
  145. package/lib/typescript/commonjs/components/AppIcon/slotIcon.d.ts +1 -1
  146. package/lib/typescript/commonjs/components/AppLockOverlay/AppLockOverlay.d.ts +5 -5
  147. package/lib/typescript/commonjs/components/AsyncBlock/AsyncBlock.d.ts +22 -40
  148. package/lib/typescript/commonjs/components/AuthedImage/AuthedImage.d.ts +15 -15
  149. package/lib/typescript/commonjs/components/AuthedImage/authedImageCache.d.ts +2 -2
  150. package/lib/typescript/commonjs/components/Autocomplete/Autocomplete.d.ts +24 -24
  151. package/lib/typescript/commonjs/components/Avatar/Avatar.d.ts +36 -36
  152. package/lib/typescript/commonjs/components/Badge/Badge.d.ts +18 -18
  153. package/lib/typescript/commonjs/components/Banner/Banner.d.ts +25 -25
  154. package/lib/typescript/commonjs/components/BarChart/BarChart.d.ts +21 -21
  155. package/lib/typescript/commonjs/components/BottomNavigation/BottomNavigation.d.ts +36 -36
  156. package/lib/typescript/commonjs/components/BottomSheet/BottomSheet.d.ts +32 -32
  157. package/lib/typescript/commonjs/components/Box/Box.d.ts +27 -27
  158. package/lib/typescript/commonjs/components/Button/Button.d.ts +22 -22
  159. package/lib/typescript/commonjs/components/Calendar/Calendar.d.ts +20 -20
  160. package/lib/typescript/commonjs/components/Calendar/CalendarDay.d.ts +4 -2
  161. package/lib/typescript/commonjs/components/Card/Card.d.ts +41 -41
  162. package/lib/typescript/commonjs/components/Carousel/Carousel.d.ts +21 -21
  163. package/lib/typescript/commonjs/components/Checkbox/Checkbox.d.ts +21 -21
  164. package/lib/typescript/commonjs/components/Chip/Chip.d.ts +23 -23
  165. package/lib/typescript/commonjs/components/ChoiceGroup/ChoiceGroup.d.ts +51 -46
  166. package/lib/typescript/commonjs/components/Composer/Composer.d.ts +27 -27
  167. package/lib/typescript/commonjs/components/Confetti/Confetti.d.ts +22 -21
  168. package/lib/typescript/commonjs/components/Confirm/confirm.d.ts +4 -4
  169. package/lib/typescript/commonjs/components/DatePicker/DatePicker.d.ts +20 -20
  170. package/lib/typescript/commonjs/components/DateRangePicker/DateRangePicker.d.ts +22 -22
  171. package/lib/typescript/commonjs/components/DateSeparator/DateSeparator.d.ts +9 -9
  172. package/lib/typescript/commonjs/components/DecimalInput/DecimalInput.d.ts +14 -14
  173. package/lib/typescript/commonjs/components/Descriptions/Descriptions.d.ts +13 -13
  174. package/lib/typescript/commonjs/components/Dialog/Dialog.d.ts +24 -24
  175. package/lib/typescript/commonjs/components/Dialog/OverlayActions.d.ts +5 -5
  176. package/lib/typescript/commonjs/components/Divider/Divider.d.ts +9 -9
  177. package/lib/typescript/commonjs/components/Drawer/Drawer.d.ts +14 -14
  178. package/lib/typescript/commonjs/components/EmptyState/EmptyState.d.ts +13 -13
  179. package/lib/typescript/commonjs/components/ErrorBoundary/ErrorBoundary.d.ts +8 -8
  180. package/lib/typescript/commonjs/components/FieldBase/Chevron.d.ts +2 -2
  181. package/lib/typescript/commonjs/components/FieldBase/ChoiceText.d.ts +10 -10
  182. package/lib/typescript/commonjs/components/FieldBase/FieldBase.d.ts +54 -54
  183. package/lib/typescript/commonjs/components/FieldBase/useFloatingLabel.d.ts +8 -8
  184. package/lib/typescript/commonjs/components/FilePicker/FilePicker.d.ts +35 -35
  185. package/lib/typescript/commonjs/components/FileViewer/FileViewer.d.ts +10 -10
  186. package/lib/typescript/commonjs/components/FileViewer/fileSource.d.ts +3 -3
  187. package/lib/typescript/commonjs/components/FilterChipRow/FilterChipRow.d.ts +12 -12
  188. package/lib/typescript/commonjs/components/FloatingActionButton/FloatingActionButton.d.ts +35 -35
  189. package/lib/typescript/commonjs/components/ForceUpdateDialog/ForceUpdateDialog.d.ts +11 -11
  190. package/lib/typescript/commonjs/components/FormField/FormField.d.ts +15 -15
  191. package/lib/typescript/commonjs/components/IconBadge/IconBadge.d.ts +11 -11
  192. package/lib/typescript/commonjs/components/IconButton/IconButton.d.ts +14 -14
  193. package/lib/typescript/commonjs/components/ImageGallery/ImageGallery.d.ts +14 -14
  194. package/lib/typescript/commonjs/components/InlineSelect/InlineSelect.d.ts +36 -31
  195. package/lib/typescript/commonjs/components/Input/Input.d.ts +47 -47
  196. package/lib/typescript/commonjs/components/KeyboardAwareScrollView/KeyboardAwareScrollView.d.ts +7 -7
  197. package/lib/typescript/commonjs/components/KeyboardToolbar/KeyboardToolbar.d.ts +8 -8
  198. package/lib/typescript/commonjs/components/ListItem/ListItem.d.ts +44 -44
  199. package/lib/typescript/commonjs/components/ListSection/ListSection.d.ts +6 -6
  200. package/lib/typescript/commonjs/components/LoaderOverlay/LoaderOverlay.d.ts +17 -11
  201. package/lib/typescript/commonjs/components/Markdown/Markdown.d.ts +15 -15
  202. package/lib/typescript/commonjs/components/Menu/Menu.d.ts +17 -12
  203. package/lib/typescript/commonjs/components/Menu/MenuSurface.d.ts +8 -8
  204. package/lib/typescript/commonjs/components/Menu/menuModel.d.ts +11 -11
  205. package/lib/typescript/commonjs/components/Menu/useContextMenu.d.ts +13 -13
  206. package/lib/typescript/commonjs/components/Menu/webOnly.d.ts +3 -3
  207. package/lib/typescript/commonjs/components/MessageBubble/MessageBubble.d.ts +20 -20
  208. package/lib/typescript/commonjs/components/MessageList/MessageList.d.ts +14 -14
  209. package/lib/typescript/commonjs/components/Modal/Modal.d.ts +19 -19
  210. package/lib/typescript/commonjs/components/NumberInput/NumberInput.d.ts +27 -27
  211. package/lib/typescript/commonjs/components/OTPInput/OTPInput.d.ts +20 -20
  212. package/lib/typescript/commonjs/components/OTPInput/OTPResendRow.d.ts +9 -9
  213. package/lib/typescript/commonjs/components/OnboardingPager/OnboardingPager.d.ts +5 -5
  214. package/lib/typescript/commonjs/components/OptionSheet/OptionSheet.d.ts +33 -33
  215. package/lib/typescript/commonjs/components/OptionSheet/optionAccessors.d.ts +8 -0
  216. package/lib/typescript/commonjs/components/PagedListFooter/PagedListFooter.d.ts +2 -2
  217. package/lib/typescript/commonjs/components/PermissionPrompt/PermissionPrompt.d.ts +6 -6
  218. package/lib/typescript/commonjs/components/PermissionPrompt/usePermissionPrompt.d.ts +1 -1
  219. package/lib/typescript/commonjs/components/PhoneNumberInput/PhoneNumberInput.d.ts +43 -43
  220. package/lib/typescript/commonjs/components/PickerTrigger/PickerTrigger.d.ts +23 -23
  221. package/lib/typescript/commonjs/components/ProfileCompletion/ProfileCompletion.d.ts +23 -23
  222. package/lib/typescript/commonjs/components/ProfilePicker/ProfilePicker.d.ts +30 -30
  223. package/lib/typescript/commonjs/components/ProgressBar/ProgressBar.d.ts +21 -21
  224. package/lib/typescript/commonjs/components/ProgressRing/ProgressRing.d.ts +13 -13
  225. package/lib/typescript/commonjs/components/Radio/Radio.d.ts +18 -18
  226. package/lib/typescript/commonjs/components/Radio/RadioDot.d.ts +5 -5
  227. package/lib/typescript/commonjs/components/Radio/RadioGroup.d.ts +8 -8
  228. package/lib/typescript/commonjs/components/Rating/Rating.d.ts +15 -15
  229. package/lib/typescript/commonjs/components/Repeater/Repeater.d.ts +10 -10
  230. package/lib/typescript/commonjs/components/RichTextEditor/RichTextEditor.d.ts +15 -15
  231. package/lib/typescript/commonjs/components/ScannerOverlay/ScannerOverlay.d.ts +13 -13
  232. package/lib/typescript/commonjs/components/Screen/Screen.d.ts +43 -44
  233. package/lib/typescript/commonjs/components/Screen/index.d.ts +1 -1
  234. package/lib/typescript/commonjs/components/SearchBar/SearchBar.d.ts +31 -31
  235. package/lib/typescript/commonjs/components/SearchBar/SearchPanel.d.ts +6 -6
  236. package/lib/typescript/commonjs/components/SearchBar/useRecentSearches.d.ts +1 -1
  237. package/lib/typescript/commonjs/components/SectionHeader/SectionHeader.d.ts +10 -10
  238. package/lib/typescript/commonjs/components/SegmentedControl/SegmentedControl.d.ts +25 -24
  239. package/lib/typescript/commonjs/components/Select/Select.d.ts +50 -45
  240. package/lib/typescript/commonjs/components/SignaturePad/SignaturePad.d.ts +20 -20
  241. package/lib/typescript/commonjs/components/Skeleton/Skeleton.d.ts +13 -13
  242. package/lib/typescript/commonjs/components/Skeleton/SkeletonContent.d.ts +9 -9
  243. package/lib/typescript/commonjs/components/Skeleton/SkeletonList.d.ts +30 -8
  244. package/lib/typescript/commonjs/components/Skeleton/SkeletonProvider.d.ts +9 -9
  245. package/lib/typescript/commonjs/components/SlideToConfirm/SlideToConfirm.d.ts +14 -14
  246. package/lib/typescript/commonjs/components/Slider/Slider.d.ts +30 -30
  247. package/lib/typescript/commonjs/components/Slider/valueText.d.ts +9 -9
  248. package/lib/typescript/commonjs/components/SliderField/SliderField.d.ts +41 -41
  249. package/lib/typescript/commonjs/components/SortableList/SortableList.d.ts +5 -5
  250. package/lib/typescript/commonjs/components/Sparkline/Sparkline.d.ts +13 -13
  251. package/lib/typescript/commonjs/components/Sparkline/geometry.d.ts +3 -1
  252. package/lib/typescript/commonjs/components/Spinner/Spinner.d.ts +10 -10
  253. package/lib/typescript/commonjs/components/SquircleFill/SquircleFill.d.ts +3 -3
  254. package/lib/typescript/commonjs/components/SquircleImage/SquircleImage.d.ts +5 -12
  255. package/lib/typescript/commonjs/components/StatTile/StatTile.d.ts +14 -14
  256. package/lib/typescript/commonjs/components/StatusBadge/StatusBadge.d.ts +13 -13
  257. package/lib/typescript/commonjs/components/Stepper/Stepper.d.ts +21 -21
  258. package/lib/typescript/commonjs/components/Swipeable/Swipeable.d.ts +15 -15
  259. package/lib/typescript/commonjs/components/Switch/Switch.d.ts +19 -19
  260. package/lib/typescript/commonjs/components/Tabs/Tabs.d.ts +20 -20
  261. package/lib/typescript/commonjs/components/TagInput/TagInput.d.ts +19 -19
  262. package/lib/typescript/commonjs/components/Text/Text.d.ts +10 -10
  263. package/lib/typescript/commonjs/components/TimePicker/TimePicker.d.ts +14 -14
  264. package/lib/typescript/commonjs/components/Timeline/Timeline.d.ts +12 -12
  265. package/lib/typescript/commonjs/components/Toast/Toast.d.ts +17 -17
  266. package/lib/typescript/commonjs/components/Toast/ToastProvider.d.ts +8 -8
  267. package/lib/typescript/commonjs/components/Tooltip/RichTooltipBody.d.ts +4 -4
  268. package/lib/typescript/commonjs/components/Tooltip/Tooltip.d.ts +24 -19
  269. package/lib/typescript/commonjs/components/Tour/Tour.d.ts +7 -7
  270. package/lib/typescript/commonjs/components/TypingIndicator/TypingIndicator.d.ts +6 -6
  271. package/lib/typescript/commonjs/components/WheelPicker/Wheel.d.ts +6 -6
  272. package/lib/typescript/commonjs/components/WheelPicker/WheelPicker.d.ts +20 -20
  273. package/lib/typescript/commonjs/components/ZoomableImage/ZoomableImage.d.ts +8 -8
  274. package/lib/typescript/commonjs/form/HookFormField.d.ts +5 -18
  275. package/lib/typescript/commonjs/form/path.d.ts +4 -2
  276. package/lib/typescript/commonjs/form/useFormCompletion.d.ts +1 -1
  277. package/lib/typescript/commonjs/hooks/useControllableState.d.ts +2 -2
  278. package/lib/typescript/commonjs/hooks/useDragToDismiss.d.ts +3 -3
  279. package/lib/typescript/commonjs/hooks/useFieldErrorScroll.d.ts +1 -1
  280. package/lib/typescript/commonjs/hooks/usePressAnimation.d.ts +4 -4
  281. package/lib/typescript/commonjs/hooks/useRefreshControl.d.ts +8 -8
  282. package/lib/typescript/commonjs/hooks/useResendCountdown.d.ts +1 -1
  283. package/lib/typescript/commonjs/hooks/useScrollDirection.d.ts +1 -1
  284. package/lib/typescript/commonjs/navigation/DiscardGuard.d.ts +2 -2
  285. package/lib/typescript/commonjs/navigation/NavigationScreen.d.ts +3 -3
  286. package/lib/typescript/commonjs/network/NetworkStatusBanner.d.ts +7 -7
  287. package/lib/typescript/commonjs/theme/Gradient.d.ts +2 -2
  288. package/lib/typescript/commonjs/theme/ThemeContext.d.ts +5 -5
  289. package/lib/typescript/commonjs/theme/componentSizes.d.ts +15 -38
  290. package/lib/typescript/commonjs/theme/types.d.ts +84 -84
  291. package/lib/typescript/commonjs/utils/announce.d.ts +1 -1
  292. package/lib/typescript/commonjs/utils/complete.d.ts +5 -0
  293. package/lib/typescript/commonjs/utils/feedback.d.ts +3 -1
  294. package/lib/typescript/commonjs/utils/guards.d.ts +9 -0
  295. package/lib/typescript/commonjs/utils/placement.d.ts +3 -3
  296. package/lib/typescript/commonjs/utils/squircle.d.ts +2 -2
  297. package/lib/typescript/module/canvasKit/index.d.ts +12 -12
  298. package/lib/typescript/module/canvasKit/meta.d.ts +5 -7
  299. package/lib/typescript/module/components/Accordion/Accordion.d.ts +22 -22
  300. package/lib/typescript/module/components/AmountSlider/AmountSlider.d.ts +23 -23
  301. package/lib/typescript/module/components/AnimatePresence/AnimatePresence.d.ts +5 -5
  302. package/lib/typescript/module/components/AppBar/AppBar.d.ts +39 -39
  303. package/lib/typescript/module/components/AppIcon/AppIcon.d.ts +7 -7
  304. package/lib/typescript/module/components/AppIcon/defaultIcons.d.ts +2 -1
  305. package/lib/typescript/module/components/AppIcon/glyphs.g.d.ts +233 -233
  306. package/lib/typescript/module/components/AppIcon/slotIcon.d.ts +1 -1
  307. package/lib/typescript/module/components/AppLockOverlay/AppLockOverlay.d.ts +5 -5
  308. package/lib/typescript/module/components/AsyncBlock/AsyncBlock.d.ts +22 -40
  309. package/lib/typescript/module/components/AuthedImage/AuthedImage.d.ts +15 -15
  310. package/lib/typescript/module/components/AuthedImage/authedImageCache.d.ts +2 -2
  311. package/lib/typescript/module/components/Autocomplete/Autocomplete.d.ts +24 -24
  312. package/lib/typescript/module/components/Avatar/Avatar.d.ts +36 -36
  313. package/lib/typescript/module/components/Badge/Badge.d.ts +18 -18
  314. package/lib/typescript/module/components/Banner/Banner.d.ts +25 -25
  315. package/lib/typescript/module/components/BarChart/BarChart.d.ts +21 -21
  316. package/lib/typescript/module/components/BottomNavigation/BottomNavigation.d.ts +36 -36
  317. package/lib/typescript/module/components/BottomSheet/BottomSheet.d.ts +32 -32
  318. package/lib/typescript/module/components/Box/Box.d.ts +27 -27
  319. package/lib/typescript/module/components/Button/Button.d.ts +22 -22
  320. package/lib/typescript/module/components/Calendar/Calendar.d.ts +20 -20
  321. package/lib/typescript/module/components/Calendar/CalendarDay.d.ts +4 -2
  322. package/lib/typescript/module/components/Card/Card.d.ts +41 -41
  323. package/lib/typescript/module/components/Carousel/Carousel.d.ts +21 -21
  324. package/lib/typescript/module/components/Checkbox/Checkbox.d.ts +21 -21
  325. package/lib/typescript/module/components/Chip/Chip.d.ts +23 -23
  326. package/lib/typescript/module/components/ChoiceGroup/ChoiceGroup.d.ts +51 -46
  327. package/lib/typescript/module/components/Composer/Composer.d.ts +27 -27
  328. package/lib/typescript/module/components/Confetti/Confetti.d.ts +22 -21
  329. package/lib/typescript/module/components/Confirm/confirm.d.ts +4 -4
  330. package/lib/typescript/module/components/DatePicker/DatePicker.d.ts +20 -20
  331. package/lib/typescript/module/components/DateRangePicker/DateRangePicker.d.ts +22 -22
  332. package/lib/typescript/module/components/DateSeparator/DateSeparator.d.ts +9 -9
  333. package/lib/typescript/module/components/DecimalInput/DecimalInput.d.ts +14 -14
  334. package/lib/typescript/module/components/Descriptions/Descriptions.d.ts +13 -13
  335. package/lib/typescript/module/components/Dialog/Dialog.d.ts +24 -24
  336. package/lib/typescript/module/components/Dialog/OverlayActions.d.ts +5 -5
  337. package/lib/typescript/module/components/Divider/Divider.d.ts +9 -9
  338. package/lib/typescript/module/components/Drawer/Drawer.d.ts +14 -14
  339. package/lib/typescript/module/components/EmptyState/EmptyState.d.ts +13 -13
  340. package/lib/typescript/module/components/ErrorBoundary/ErrorBoundary.d.ts +8 -8
  341. package/lib/typescript/module/components/FieldBase/Chevron.d.ts +2 -2
  342. package/lib/typescript/module/components/FieldBase/ChoiceText.d.ts +10 -10
  343. package/lib/typescript/module/components/FieldBase/FieldBase.d.ts +54 -54
  344. package/lib/typescript/module/components/FieldBase/useFloatingLabel.d.ts +8 -8
  345. package/lib/typescript/module/components/FilePicker/FilePicker.d.ts +35 -35
  346. package/lib/typescript/module/components/FileViewer/FileViewer.d.ts +10 -10
  347. package/lib/typescript/module/components/FileViewer/fileSource.d.ts +3 -3
  348. package/lib/typescript/module/components/FilterChipRow/FilterChipRow.d.ts +12 -12
  349. package/lib/typescript/module/components/FloatingActionButton/FloatingActionButton.d.ts +35 -35
  350. package/lib/typescript/module/components/ForceUpdateDialog/ForceUpdateDialog.d.ts +11 -11
  351. package/lib/typescript/module/components/FormField/FormField.d.ts +15 -15
  352. package/lib/typescript/module/components/IconBadge/IconBadge.d.ts +11 -11
  353. package/lib/typescript/module/components/IconButton/IconButton.d.ts +14 -14
  354. package/lib/typescript/module/components/ImageGallery/ImageGallery.d.ts +14 -14
  355. package/lib/typescript/module/components/InlineSelect/InlineSelect.d.ts +36 -31
  356. package/lib/typescript/module/components/Input/Input.d.ts +47 -47
  357. package/lib/typescript/module/components/KeyboardAwareScrollView/KeyboardAwareScrollView.d.ts +7 -7
  358. package/lib/typescript/module/components/KeyboardToolbar/KeyboardToolbar.d.ts +8 -8
  359. package/lib/typescript/module/components/ListItem/ListItem.d.ts +44 -44
  360. package/lib/typescript/module/components/ListSection/ListSection.d.ts +6 -6
  361. package/lib/typescript/module/components/LoaderOverlay/LoaderOverlay.d.ts +17 -11
  362. package/lib/typescript/module/components/Markdown/Markdown.d.ts +15 -15
  363. package/lib/typescript/module/components/Menu/Menu.d.ts +17 -12
  364. package/lib/typescript/module/components/Menu/MenuSurface.d.ts +8 -8
  365. package/lib/typescript/module/components/Menu/menuModel.d.ts +11 -11
  366. package/lib/typescript/module/components/Menu/useContextMenu.d.ts +13 -13
  367. package/lib/typescript/module/components/Menu/webOnly.d.ts +3 -3
  368. package/lib/typescript/module/components/MessageBubble/MessageBubble.d.ts +20 -20
  369. package/lib/typescript/module/components/MessageList/MessageList.d.ts +14 -14
  370. package/lib/typescript/module/components/Modal/Modal.d.ts +19 -19
  371. package/lib/typescript/module/components/NumberInput/NumberInput.d.ts +27 -27
  372. package/lib/typescript/module/components/OTPInput/OTPInput.d.ts +20 -20
  373. package/lib/typescript/module/components/OTPInput/OTPResendRow.d.ts +9 -9
  374. package/lib/typescript/module/components/OnboardingPager/OnboardingPager.d.ts +5 -5
  375. package/lib/typescript/module/components/OptionSheet/OptionSheet.d.ts +33 -33
  376. package/lib/typescript/module/components/OptionSheet/optionAccessors.d.ts +8 -0
  377. package/lib/typescript/module/components/PagedListFooter/PagedListFooter.d.ts +2 -2
  378. package/lib/typescript/module/components/PermissionPrompt/PermissionPrompt.d.ts +6 -6
  379. package/lib/typescript/module/components/PermissionPrompt/usePermissionPrompt.d.ts +1 -1
  380. package/lib/typescript/module/components/PhoneNumberInput/PhoneNumberInput.d.ts +43 -43
  381. package/lib/typescript/module/components/PickerTrigger/PickerTrigger.d.ts +23 -23
  382. package/lib/typescript/module/components/ProfileCompletion/ProfileCompletion.d.ts +23 -23
  383. package/lib/typescript/module/components/ProfilePicker/ProfilePicker.d.ts +30 -30
  384. package/lib/typescript/module/components/ProgressBar/ProgressBar.d.ts +21 -21
  385. package/lib/typescript/module/components/ProgressRing/ProgressRing.d.ts +13 -13
  386. package/lib/typescript/module/components/Radio/Radio.d.ts +18 -18
  387. package/lib/typescript/module/components/Radio/RadioDot.d.ts +5 -5
  388. package/lib/typescript/module/components/Radio/RadioGroup.d.ts +8 -8
  389. package/lib/typescript/module/components/Rating/Rating.d.ts +15 -15
  390. package/lib/typescript/module/components/Repeater/Repeater.d.ts +10 -10
  391. package/lib/typescript/module/components/RichTextEditor/RichTextEditor.d.ts +15 -15
  392. package/lib/typescript/module/components/ScannerOverlay/ScannerOverlay.d.ts +13 -13
  393. package/lib/typescript/module/components/Screen/Screen.d.ts +43 -44
  394. package/lib/typescript/module/components/Screen/index.d.ts +1 -1
  395. package/lib/typescript/module/components/SearchBar/SearchBar.d.ts +31 -31
  396. package/lib/typescript/module/components/SearchBar/SearchPanel.d.ts +6 -6
  397. package/lib/typescript/module/components/SearchBar/useRecentSearches.d.ts +1 -1
  398. package/lib/typescript/module/components/SectionHeader/SectionHeader.d.ts +10 -10
  399. package/lib/typescript/module/components/SegmentedControl/SegmentedControl.d.ts +25 -24
  400. package/lib/typescript/module/components/Select/Select.d.ts +50 -45
  401. package/lib/typescript/module/components/SignaturePad/SignaturePad.d.ts +20 -20
  402. package/lib/typescript/module/components/Skeleton/Skeleton.d.ts +13 -13
  403. package/lib/typescript/module/components/Skeleton/SkeletonContent.d.ts +9 -9
  404. package/lib/typescript/module/components/Skeleton/SkeletonList.d.ts +30 -8
  405. package/lib/typescript/module/components/Skeleton/SkeletonProvider.d.ts +9 -9
  406. package/lib/typescript/module/components/SlideToConfirm/SlideToConfirm.d.ts +14 -14
  407. package/lib/typescript/module/components/Slider/Slider.d.ts +30 -30
  408. package/lib/typescript/module/components/Slider/valueText.d.ts +9 -9
  409. package/lib/typescript/module/components/SliderField/SliderField.d.ts +41 -41
  410. package/lib/typescript/module/components/SortableList/SortableList.d.ts +5 -5
  411. package/lib/typescript/module/components/Sparkline/Sparkline.d.ts +13 -13
  412. package/lib/typescript/module/components/Sparkline/geometry.d.ts +3 -1
  413. package/lib/typescript/module/components/Spinner/Spinner.d.ts +10 -10
  414. package/lib/typescript/module/components/SquircleFill/SquircleFill.d.ts +3 -3
  415. package/lib/typescript/module/components/SquircleImage/SquircleImage.d.ts +5 -12
  416. package/lib/typescript/module/components/StatTile/StatTile.d.ts +14 -14
  417. package/lib/typescript/module/components/StatusBadge/StatusBadge.d.ts +13 -13
  418. package/lib/typescript/module/components/Stepper/Stepper.d.ts +21 -21
  419. package/lib/typescript/module/components/Swipeable/Swipeable.d.ts +15 -15
  420. package/lib/typescript/module/components/Switch/Switch.d.ts +19 -19
  421. package/lib/typescript/module/components/Tabs/Tabs.d.ts +20 -20
  422. package/lib/typescript/module/components/TagInput/TagInput.d.ts +19 -19
  423. package/lib/typescript/module/components/Text/Text.d.ts +10 -10
  424. package/lib/typescript/module/components/TimePicker/TimePicker.d.ts +14 -14
  425. package/lib/typescript/module/components/Timeline/Timeline.d.ts +12 -12
  426. package/lib/typescript/module/components/Toast/Toast.d.ts +17 -17
  427. package/lib/typescript/module/components/Toast/ToastProvider.d.ts +8 -8
  428. package/lib/typescript/module/components/Tooltip/RichTooltipBody.d.ts +4 -4
  429. package/lib/typescript/module/components/Tooltip/Tooltip.d.ts +24 -19
  430. package/lib/typescript/module/components/Tour/Tour.d.ts +7 -7
  431. package/lib/typescript/module/components/TypingIndicator/TypingIndicator.d.ts +6 -6
  432. package/lib/typescript/module/components/WheelPicker/Wheel.d.ts +6 -6
  433. package/lib/typescript/module/components/WheelPicker/WheelPicker.d.ts +20 -20
  434. package/lib/typescript/module/components/ZoomableImage/ZoomableImage.d.ts +8 -8
  435. package/lib/typescript/module/form/HookFormField.d.ts +5 -18
  436. package/lib/typescript/module/form/path.d.ts +4 -2
  437. package/lib/typescript/module/form/useFormCompletion.d.ts +1 -1
  438. package/lib/typescript/module/hooks/useControllableState.d.ts +2 -2
  439. package/lib/typescript/module/hooks/useDragToDismiss.d.ts +3 -3
  440. package/lib/typescript/module/hooks/useFieldErrorScroll.d.ts +1 -1
  441. package/lib/typescript/module/hooks/usePressAnimation.d.ts +4 -4
  442. package/lib/typescript/module/hooks/useRefreshControl.d.ts +8 -8
  443. package/lib/typescript/module/hooks/useResendCountdown.d.ts +1 -1
  444. package/lib/typescript/module/hooks/useScrollDirection.d.ts +1 -1
  445. package/lib/typescript/module/navigation/DiscardGuard.d.ts +2 -2
  446. package/lib/typescript/module/navigation/NavigationScreen.d.ts +3 -3
  447. package/lib/typescript/module/network/NetworkStatusBanner.d.ts +7 -7
  448. package/lib/typescript/module/theme/Gradient.d.ts +2 -2
  449. package/lib/typescript/module/theme/ThemeContext.d.ts +5 -5
  450. package/lib/typescript/module/theme/componentSizes.d.ts +15 -38
  451. package/lib/typescript/module/theme/types.d.ts +84 -84
  452. package/lib/typescript/module/utils/announce.d.ts +1 -1
  453. package/lib/typescript/module/utils/complete.d.ts +5 -0
  454. package/lib/typescript/module/utils/feedback.d.ts +3 -1
  455. package/lib/typescript/module/utils/guards.d.ts +9 -0
  456. package/lib/typescript/module/utils/placement.d.ts +3 -3
  457. package/lib/typescript/module/utils/squircle.d.ts +2 -2
  458. package/package.json +9 -9
  459. package/src/specs/NativePdfRasterizer.ts +1 -1
@@ -1 +1 @@
1
- "use strict";import{useCallback,useEffect,useMemo,useRef,useState}from"react";import{Animated,Dimensions,FlatList,Pressable,StatusBar,StyleSheet,TextInput,View}from"react-native";import{GestureDetector,GestureHandlerRootView,useNativeGesture}from"react-native-gesture-handler";import{useKeyboardState}from"react-native-keyboard-controller";import{useSafeAreaInsets}from"react-native-safe-area-context";import{useDragToDismiss}from"../../hooks/useDragToDismiss.js";import{createAnimatedValue,useTheme}from"../../theme/index.js";import{smoothCorners}from"../../utils/corners.js";import{hitSlopMarker}from"../../utils/hitSlop.js";import{defaultIcons}from"../AppIcon/defaultIcons.js";import{Modal}from"../Modal/index.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";const SEARCH_ICON_SIZE=18;export const DEFAULT_OPTION_SHEET_LABELS=Object.freeze({searchPlaceholder:"Search…",empty:"No options",done:"Done",closePicker:"Close picker",fallbackName:"Options",searchOptions:"Search options",clearSearch:"Clear search",jumpToLetter:"Jump to letter",jumpTo:e=>`Jump to ${e}`});const selectOptionLabel=e=>e.label,selectOptionValue=e=>e.value,selectOptionDescription=e=>e.description,selectOptionDisabled=e=>!0===e.disabled,selectOptionIcon=e=>e.icon,hostStyle=StyleSheet.create({host:{padding:0,paddingTop:0,paddingHorizontal:0,paddingBottom:0,backgroundColor:"transparent",borderTopLeftRadius:0,borderTopRightRadius:0,shadowOpacity:0,elevation:0}}).host;function OptionSheetPanel(e){const{onClose:t,title:o,options:s,sections:i,renderSectionHeader:r,renderOption:l,alphabetIndex:n=!1,labels:a,getOptionLabel:c,getOptionValue:d,getOptionDescription:p,isOptionDisabled:u,getOptionIcon:h,destructiveOf:m,value:b,onChange:g,multi:x=!1,searchable:y=!1,searchSelectionColor:f,accessibilityLabel:S,optionStyle:T,selectedOptionStyle:j,optionTextStyle:w,selectedOptionTextStyle:C,testID:_}=e,k=c??selectOptionLabel,L=d??selectOptionValue,I=p??selectOptionDescription,O=u??selectOptionDisabled,R=h??selectOptionIcon,V=useTheme(),D=useSafeAreaInsets(),v=useMemo(()=>buildStyles(V),[V]),[P,H]=useState(""),M=Dimensions.get("window").height,B=Math.round(.7*M),A=useRef(createAnimatedValue(0)).current,{handleGesture:E,opacity:F}=useDragToDismiss({drag:A,travel:B,onDismiss:t}),z=useNativeGesture(),W=useKeyboardState(e=>e.height),N=Math.max(0,Math.round(W)),G=Math.max(D.top,StatusBar.currentHeight??0)+V.space.sm,U=N>0,$=U?Math.max(0,Math.min(B,M-N-G)):B,J=useMemo(()=>{const e=y?P.trim().toLowerCase():"",matches=t=>0===e.length||k(t).toLowerCase().includes(e)||(I(t)??"").toLowerCase().includes(e);if(!i)return s.filter(matches).map(e=>({kind:"option",option:e}));const t=[];return i.forEach((e,o)=>{const s=e.options.filter(matches);if(0!==s.length){t.push({kind:"header",title:e.title});for(const e of s)t.push({kind:"option",option:e,section:o})}}),t},[y,P,s,i,k,I]),K=useCallback(()=>{t()},[t]),Y=useRef(null),Z=useMemo(()=>{const e=new Map;if(!n)return e;let t=0;if(i)for(const[e,o]of J.entries())"header"===o.kind&&(t=e+1);for(const[o,s]of J.entries()){if(o<t||"option"!==s.kind)continue;const i=k(s.option).trim().charAt(0).toUpperCase(),r=/^[A-Z]$/.test(i)?i:"#";e.has(r)||e.set(r,o)}return e},[n,J,i,k]),Q=n&&Z.size>0&&0===P.trim().length,X=useMemo(()=>[..."ABCDEFGHIJKLMNOPQRSTUVWXYZ",...Z.has("#")?["#"]:[]],[Z]),q=useCallback(e=>{const t=Z.get(e);void 0!==t&&Y.current?.scrollToIndex({index:t,animated:!0,viewPosition:0})},[Z]),ee=useRef(null),te=useCallback(()=>{null!==ee.current&&(clearTimeout(ee.current),ee.current=null)},[]),oe=useCallback(e=>{Y.current?.scrollToOffset({offset:e.averageItemLength*e.index,animated:!1}),te(),ee.current=setTimeout(()=>{ee.current=null,Y.current?.scrollToIndex({index:e.index,animated:!0,viewPosition:0})},50)},[te]);useEffect(()=>te,[te]);return _jsx(GestureHandlerRootView,{style:v.gestureRoot,children:_jsxs(Animated.View,{testID:_,accessibilityViewIsModal:!0,accessibilityLabel:S??o??a.fallbackName,style:[v.sheet,{maxHeight:$,marginBottom:N,paddingBottom:U?V.space.lg:D.bottom+V.space.lg,backgroundColor:V.colors.surface,borderTopLeftRadius:V.radius.xl,borderTopRightRadius:V.radius.xl,...smoothCorners,opacity:F,transform:[{translateY:A}],...V.shadow.modal}],children:[_jsx(GestureDetector,{gesture:E,children:_jsxs(View,{children:[_jsx(View,{style:v.sheetHandleRow,children:_jsx(View,{style:[v.sheetHandle,{backgroundColor:V.colors.border}]})}),o?_jsx(Text,{variant:"title",style:[v.sheetTitle,{paddingHorizontal:V.space.lg,marginBottom:V.space.sm}],children:o}):null]})}),y?_jsx(View,{style:[v.searchWrap,{marginHorizontal:V.space.lg,marginBottom:V.space.sm}],children:_jsxs(View,{style:[v.searchBox,{backgroundColor:V.colors["bg-subtle"],borderColor:V.colors.border,borderRadius:V.radius.md,...smoothCorners,paddingHorizontal:V.space.md,gap:V.space.sm}],children:[(V.settings.icons.search??defaultIcons.search)({size:18,color:V.colors["text-subtle"]}),_jsx(TextInput,{value:P,onChangeText:H,placeholder:a.searchPlaceholder,placeholderTextColor:V.colors["text-subtle"],selectionColor:f??V.colors["focus-ring"],accessibilityLabel:a.searchOptions,style:[v.searchInput,{color:V.colors["text-body"],fontSize:V.text.base.size,paddingVertical:V.space.sm}]}),P.length>0?_jsx(Pressable,{onPress:()=>H(""),hitSlop:8,...hitSlopMarker(8),accessibilityRole:"button",accessibilityLabel:a.clearSearch,children:(V.settings.icons.close??defaultIcons.close)({size:18,color:V.colors["text-muted"]})}):null]})}):null,_jsxs(View,{style:[v.listWrap,Q?v.listRow:null],children:[_jsx(GestureDetector,{gesture:z,children:_jsx(FlatList,{ref:Y,data:J,keyExtractor:e=>"header"===e.kind?`h:${e.title}`:`o:${e.section??""}:${String(L(e.option))}`,renderItem:({item:e,index:t})=>{if("header"===e.kind)return _jsx(View,{accessible:!0,accessibilityRole:"header",style:[v.sectionHeader,{paddingHorizontal:V.space.lg,paddingTop:V.space.md}],children:r?r(e.title):_jsx(Text,{variant:"caption",weight:"semibold",color:"tertiary",style:v.sectionTitle,children:e.title.toUpperCase()})});const o=e.option,s=k(o),i=L(o),n=I(o),a=R(o),c=(d=i,Array.isArray(b)?b.some(e=>String(e)===String(d)):null!=b&&String(b)===String(d));var d;const p=O(o),u=m?.(o)??!1;return _jsxs(Pressable,{onPress:()=>g(i,o),disabled:p,android_ripple:{color:V.colors["surface-pressed"],borderless:!1},accessibilityRole:"button",accessibilityLabel:s,accessibilityState:{selected:c,disabled:p},"aria-selected":c,"aria-disabled":p,style:({pressed:e})=>[v.optionRow,{backgroundColor:c?V.colors["surface-selected"]:e?V.colors["surface-pressed"]:"transparent",opacity:p?.5:1,paddingHorizontal:V.space.lg,paddingVertical:V.space.md},T,c?j:null],children:[l?_jsx(View,{style:v.optionTextWrap,children:l({option:o,selected:c,disabled:p,index:t})}):_jsxs(_Fragment,{children:[a?_jsx(View,{style:v.optionIcon,children:a}):null,_jsxs(View,{style:v.optionTextWrap,children:[_jsx(Text,{variant:"body",weight:c?"semibold":"medium",color:u?"danger":c?"brand":void 0,style:[v.optionLabel,w,c?C:null],children:s}),n?_jsx(Text,{variant:"bodySmall",color:"tertiary",numberOfLines:2,style:v.optionDescription,children:n}):null]})]}),x?_jsx(View,{style:[v.checkbox,{borderColor:c?V.colors.primary:V.colors.border,backgroundColor:c?V.colors.primary:"transparent"}],children:c?_jsx(View,{style:v.checkboxTick}):null}):c?"icon"===V.settings.components["option-sheet"]?.selectedMarker?_jsx(View,{style:v.singleSelectedIcon,children:(V.settings.icons.selectedTick??defaultIcons.selectedTick)({size:20,color:V.colors.primary})}):_jsx(View,{style:[v.singleSelectedDot,{backgroundColor:V.colors.primary}]}):null]})},onScrollToIndexFailed:oe,overScrollMode:"never",bounces:!1,keyboardShouldPersistTaps:"handled",showsVerticalScrollIndicator:!Q,style:Q?v.listBesideRail:null,ListEmptyComponent:_jsx(Text,{variant:"bodySmall",color:"tertiary",align:"center",style:{paddingVertical:V.space.xl},children:a.empty})})}),Q?_jsx(View,{style:[v.rail,{paddingRight:V.space.xs}],accessibilityRole:"list",accessibilityLabel:a.jumpToLetter,testID:"option-sheet-alphabet",children:X.map(e=>{const t=Z.has(e);return _jsx(Pressable,{onPress:()=>q(e),disabled:!t,hitSlop:{left:8,right:8},...hitSlopMarker({left:8,right:8}),accessibilityRole:"button",accessibilityLabel:a.jumpTo(e),accessibilityState:{disabled:!t},"aria-disabled":!t,style:v.railLetter,children:_jsx(Text,{variant:"caption",weight:"semibold",color:t?"brand":"tertiary",style:[v.railLetterText,{opacity:t?1:.45}],children:e})},e)})}):null]}),x?_jsx(View,{style:[v.sheetFooter,{borderTopColor:V.colors["border-subtle"],paddingHorizontal:V.space.lg,paddingVertical:V.space.md}],children:_jsx(Pressable,{onPress:K,accessibilityRole:"button",accessibilityLabel:a.done,style:({pressed:e})=>[v.doneButton,{backgroundColor:e?V.colors["primary-pressed"]:V.colors.primary,borderRadius:V.radius.md,...smoothCorners,paddingVertical:V.space.sm,paddingHorizontal:V.space.lg}],children:_jsx(Text,{variant:"body",weight:"semibold",style:{color:V.colors["on-primary"]},children:a.done})})}):null]})})}export function OptionSheet(e){const{open:t,onOpenChange:o,onAfterClose:s,labels:i,onClose:r,haptic:l,...n}=e,a=useMemo(()=>({...DEFAULT_OPTION_SHEET_LABELS,...i}),[i]),c=useRef(o);c.current=o;const d=useRef(!1);return useEffect(()=>{d.current!==t&&(d.current=t,c.current?.(t))},[t]),_jsx(Modal,{open:t,onClose:r,presentation:"bottom",onDismissed:s,haptic:l,contentStyle:hostStyle,labels:{close:a.closePicker},accessibilityLabel:n.accessibilityLabel??n.title??a.fallbackName,children:_jsx(OptionSheetPanel,{...n,onClose:r,labels:a})})}OptionSheet.displayName="OptionSheet";const buildStyles=e=>StyleSheet.create({gestureRoot:{width:"100%"},sheet:{paddingBottom:e.space.lg,overflow:"hidden"},sheetHandleRow:{alignItems:"center",paddingTop:e.space.sm,paddingBottom:e.space.sm},sheetHandle:{width:36,height:4,borderRadius:e.radius.pill,...smoothCorners},sheetTitle:{includeFontPadding:!1},searchWrap:{width:"auto"},searchBox:{flexDirection:"row",alignItems:"center",borderWidth:1},searchInput:{flex:1,includeFontPadding:!1},optionRow:{flexDirection:"row",alignItems:"center"},sectionHeader:{paddingBottom:e.space.xs},listWrap:{flexShrink:1},listRow:{flexDirection:"row"},listBesideRail:{flex:1},rail:{justifyContent:"space-between",alignItems:"center",alignSelf:"stretch",paddingVertical:e.space.xs},railLetter:{paddingHorizontal:e.space.xs,minHeight:14,justifyContent:"center"},railLetterText:{includeFontPadding:!1,lineHeight:14},sectionTitle:{includeFontPadding:!1,letterSpacing:.6},optionIcon:{marginRight:e.space.md},optionTextWrap:{flex:1},optionLabel:{includeFontPadding:!1},optionDescription:{includeFontPadding:!1,marginTop:e.space.xxs},checkbox:{width:22,height:22,borderRadius:e.radius.sm,...smoothCorners,borderWidth:2,alignItems:"center",justifyContent:"center",marginLeft:e.space.md},checkboxTick:{width:10,height:6,borderLeftWidth:2,borderBottomWidth:2,borderColor:e.colors["on-primary"],transform:[{rotate:"-45deg"},{translateY:-1}]},singleSelectedDot:{width:8,height:8,borderRadius:e.radius.pill,...smoothCorners,marginLeft:e.space.md},singleSelectedIcon:{marginLeft:e.space.md},sheetFooter:{borderTopWidth:StyleSheet.hairlineWidth,alignItems:"flex-end"},doneButton:{alignSelf:"flex-end"}});export default OptionSheet;
1
+ "use strict";import{useCallback,useEffect,useMemo,useRef,useState}from"react";import{Animated,Dimensions,FlatList,Pressable,StatusBar,StyleSheet,TextInput,View}from"react-native";import{GestureDetector,GestureHandlerRootView,useNativeGesture}from"react-native-gesture-handler";import{useKeyboardState}from"react-native-keyboard-controller";import{useSafeAreaInsets}from"react-native-safe-area-context";import{useDragToDismiss}from"../../hooks/useDragToDismiss.js";import{createAnimatedValue,useTheme}from"../../theme/index.js";import{smoothCorners}from"../../utils/corners.js";import{hitSlopMarker}from"../../utils/hitSlop.js";import{defaultIcons}from"../AppIcon/defaultIcons.js";import{Modal}from"../Modal/index.js";import{Text}from"../Text/index.js";import{selectOptionDescription,selectOptionDisabled,selectOptionIcon,selectOptionLabel,selectOptionValue}from"./optionAccessors.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";const SEARCH_ICON_SIZE=18;export const DEFAULT_OPTION_SHEET_LABELS=Object.freeze({searchPlaceholder:"Search…",empty:"No options",done:"Done",closePicker:"Close picker",fallbackName:"Options",searchOptions:"Search options",clearSearch:"Clear search",jumpToLetter:"Jump to letter",jumpTo:e=>`Jump to ${e}`});const hostStyle=StyleSheet.create({host:{padding:0,paddingTop:0,paddingHorizontal:0,paddingBottom:0,backgroundColor:"transparent",borderTopLeftRadius:0,borderTopRightRadius:0,shadowOpacity:0,elevation:0}}).host;function OptionSheetPanel(e){const{onClose:t,title:o,options:s,sections:i,renderSectionHeader:r,renderOption:l,alphabetIndex:n=!1,labels:a,getOptionLabel:c,getOptionValue:d,getOptionDescription:p,isOptionDisabled:u,getOptionIcon:h,destructiveOf:m,value:b,onChange:g,multi:x=!1,searchable:y=!1,searchSelectionColor:f,accessibilityLabel:S,optionStyle:T,selectedOptionStyle:j,optionTextStyle:w,selectedOptionTextStyle:C,testID:_}=e,k=c??selectOptionLabel,L=d??selectOptionValue,I=p??selectOptionDescription,O=u??selectOptionDisabled,R=h??selectOptionIcon,V=useTheme(),D=useSafeAreaInsets(),v=useMemo(()=>buildStyles(V),[V]),[P,H]=useState(""),M=Dimensions.get("window").height,B=Math.round(.7*M),A=useRef(createAnimatedValue(0)).current,{handleGesture:E,opacity:F}=useDragToDismiss({drag:A,travel:B,onDismiss:t}),z=useNativeGesture(),W=useKeyboardState(e=>e.height),N=Math.max(0,Math.round(W)),G=Math.max(D.top,StatusBar.currentHeight??0)+V.space.sm,U=N>0,$=U?Math.max(0,Math.min(B,M-N-G)):B,J=useMemo(()=>{const e=y?P.trim().toLowerCase():"",matches=t=>0===e.length||k(t).toLowerCase().includes(e)||(I(t)??"").toLowerCase().includes(e);if(!i)return s.filter(matches).map(e=>({kind:"option",option:e}));const t=[];return i.forEach((e,o)=>{const s=e.options.filter(matches);if(0!==s.length){t.push({kind:"header",title:e.title});for(const e of s)t.push({kind:"option",option:e,section:o})}}),t},[y,P,s,i,k,I]),K=useCallback(()=>{t()},[t]),Y=useRef(null),Z=useMemo(()=>{const e=new Map;if(!n)return e;let t=0;if(i)for(const[e,o]of J.entries())"header"===o.kind&&(t=e+1);for(const[o,s]of J.entries()){if(o<t||"option"!==s.kind)continue;const i=k(s.option).trim().charAt(0).toUpperCase(),r=/^[A-Z]$/.test(i)?i:"#";e.has(r)||e.set(r,o)}return e},[n,J,i,k]),Q=n&&Z.size>0&&0===P.trim().length,X=useMemo(()=>[..."ABCDEFGHIJKLMNOPQRSTUVWXYZ",...Z.has("#")?["#"]:[]],[Z]),q=useCallback(e=>{const t=Z.get(e);void 0!==t&&Y.current?.scrollToIndex({index:t,animated:!0,viewPosition:0})},[Z]),ee=useRef(null),te=useCallback(()=>{null!==ee.current&&(clearTimeout(ee.current),ee.current=null)},[]),oe=useCallback(e=>{Y.current?.scrollToOffset({offset:e.averageItemLength*e.index,animated:!1}),te(),ee.current=setTimeout(()=>{ee.current=null,Y.current?.scrollToIndex({index:e.index,animated:!0,viewPosition:0})},50)},[te]);useEffect(()=>te,[te]);return _jsx(GestureHandlerRootView,{style:v.gestureRoot,children:_jsxs(Animated.View,{testID:_,accessibilityViewIsModal:!0,accessibilityLabel:S??o??a.fallbackName,style:[v.sheet,{maxHeight:$,marginBottom:N,paddingBottom:U?V.space.lg:D.bottom+V.space.lg,backgroundColor:V.colors.surface,borderTopLeftRadius:V.radius.xl,borderTopRightRadius:V.radius.xl,...smoothCorners,opacity:F,transform:[{translateY:A}],...V.shadow.modal}],children:[_jsx(GestureDetector,{gesture:E,children:_jsxs(View,{children:[_jsx(View,{style:v.sheetHandleRow,children:_jsx(View,{style:[v.sheetHandle,{backgroundColor:V.colors.border}]})}),o?_jsx(Text,{variant:"title",style:[v.sheetTitle,{paddingHorizontal:V.space.lg,marginBottom:V.space.sm}],children:o}):null]})}),y?_jsx(View,{style:[v.searchWrap,{marginHorizontal:V.space.lg,marginBottom:V.space.sm}],children:_jsxs(View,{style:[v.searchBox,{backgroundColor:V.colors["bg-subtle"],borderColor:V.colors.border,borderRadius:V.radius.md,...smoothCorners,paddingHorizontal:V.space.md,gap:V.space.sm}],children:[(V.settings.icons.search??defaultIcons.search)({size:18,color:V.colors["text-subtle"]}),_jsx(TextInput,{value:P,onChangeText:H,placeholder:a.searchPlaceholder,placeholderTextColor:V.colors["text-subtle"],selectionColor:f??V.colors["focus-ring"],accessibilityLabel:a.searchOptions,style:[v.searchInput,{color:V.colors["text-body"],fontSize:V.text.base.size,paddingVertical:V.space.sm}]}),P.length>0?_jsx(Pressable,{onPress:()=>H(""),hitSlop:8,...hitSlopMarker(8),accessibilityRole:"button",accessibilityLabel:a.clearSearch,children:(V.settings.icons.close??defaultIcons.close)({size:18,color:V.colors["text-muted"]})}):null]})}):null,_jsxs(View,{style:[v.listWrap,Q?v.listRow:null],children:[_jsx(GestureDetector,{gesture:z,children:_jsx(FlatList,{ref:Y,data:J,keyExtractor:e=>"header"===e.kind?`h:${e.title}`:`o:${e.section??""}:${String(L(e.option))}`,renderItem:({item:e,index:t})=>{if("header"===e.kind)return _jsx(View,{accessible:!0,accessibilityRole:"header",style:[v.sectionHeader,{paddingHorizontal:V.space.lg,paddingTop:V.space.md}],children:r?r(e.title):_jsx(Text,{variant:"caption",weight:"semibold",color:"tertiary",style:v.sectionTitle,children:e.title.toUpperCase()})});const o=e.option,s=k(o),i=L(o),n=I(o),a=R(o),c=(d=i,Array.isArray(b)?b.some(e=>String(e)===String(d)):null!=b&&String(b)===String(d));var d;const p=O(o),u=m?.(o)??!1;return _jsxs(Pressable,{onPress:()=>g(i,o),disabled:p,android_ripple:{color:V.colors["surface-pressed"],borderless:!1},accessibilityRole:"button",accessibilityLabel:s,accessibilityState:{selected:c,disabled:p},"aria-selected":c,"aria-disabled":p,style:({pressed:e})=>[v.optionRow,{backgroundColor:c?V.colors["surface-selected"]:e?V.colors["surface-pressed"]:"transparent",opacity:p?.5:1,paddingHorizontal:V.space.lg,paddingVertical:V.space.md},T,c?j:null],children:[l?_jsx(View,{style:v.optionTextWrap,children:l({option:o,selected:c,disabled:p,index:t})}):_jsxs(_Fragment,{children:[a?_jsx(View,{style:v.optionIcon,children:a}):null,_jsxs(View,{style:v.optionTextWrap,children:[_jsx(Text,{variant:"body",weight:c?"semibold":"medium",color:u?"danger":c?"brand":void 0,style:[v.optionLabel,w,c?C:null],children:s}),n?_jsx(Text,{variant:"bodySmall",color:"tertiary",numberOfLines:2,style:v.optionDescription,children:n}):null]})]}),x?_jsx(View,{style:[v.checkbox,{borderColor:c?V.colors.primary:V.colors.border,backgroundColor:c?V.colors.primary:"transparent"}],children:c?_jsx(View,{style:v.checkboxTick}):null}):c?"icon"===V.settings.components["option-sheet"]?.selectedMarker?_jsx(View,{style:v.singleSelectedIcon,children:(V.settings.icons.selectedTick??defaultIcons.selectedTick)({size:20,color:V.colors.primary})}):_jsx(View,{style:[v.singleSelectedDot,{backgroundColor:V.colors.primary}]}):null]})},onScrollToIndexFailed:oe,overScrollMode:"never",bounces:!1,keyboardShouldPersistTaps:"handled",showsVerticalScrollIndicator:!Q,style:Q?v.listBesideRail:null,ListEmptyComponent:_jsx(Text,{variant:"bodySmall",color:"tertiary",align:"center",style:{paddingVertical:V.space.xl},children:a.empty})})}),Q?_jsx(View,{style:[v.rail,{paddingRight:V.space.xs}],accessibilityRole:"list",accessibilityLabel:a.jumpToLetter,testID:"option-sheet-alphabet",children:X.map(e=>{const t=Z.has(e);return _jsx(Pressable,{onPress:()=>q(e),disabled:!t,hitSlop:{left:8,right:8},...hitSlopMarker({left:8,right:8}),accessibilityRole:"button",accessibilityLabel:a.jumpTo(e),accessibilityState:{disabled:!t},"aria-disabled":!t,style:v.railLetter,children:_jsx(Text,{variant:"caption",weight:"semibold",color:t?"brand":"tertiary",style:[v.railLetterText,{opacity:t?1:.45}],children:e})},e)})}):null]}),x?_jsx(View,{style:[v.sheetFooter,{borderTopColor:V.colors["border-subtle"],paddingHorizontal:V.space.lg,paddingVertical:V.space.md}],children:_jsx(Pressable,{onPress:K,accessibilityRole:"button",accessibilityLabel:a.done,style:({pressed:e})=>[v.doneButton,{backgroundColor:e?V.colors["primary-pressed"]:V.colors.primary,borderRadius:V.radius.md,...smoothCorners,paddingVertical:V.space.sm,paddingHorizontal:V.space.lg}],children:_jsx(Text,{variant:"body",weight:"semibold",style:{color:V.colors["on-primary"]},children:a.done})})}):null]})})}export function OptionSheet(e){const{open:t,onOpenChange:o,onAfterClose:s,labels:i,onClose:r,haptic:l,...n}=e,a=useMemo(()=>({...DEFAULT_OPTION_SHEET_LABELS,...i}),[i]),c=useRef(o);c.current=o;const d=useRef(!1);return useEffect(()=>{d.current!==t&&(d.current=t,c.current?.(t))},[t]),_jsx(Modal,{open:t,onClose:r,presentation:"bottom",onDismissed:s,haptic:l,contentStyle:hostStyle,labels:{close:a.closePicker},accessibilityLabel:n.accessibilityLabel??n.title??a.fallbackName,children:_jsx(OptionSheetPanel,{...n,onClose:r,labels:a})})}OptionSheet.displayName="OptionSheet";const buildStyles=e=>StyleSheet.create({gestureRoot:{width:"100%"},sheet:{paddingBottom:e.space.lg,overflow:"hidden"},sheetHandleRow:{alignItems:"center",paddingTop:e.space.sm,paddingBottom:e.space.sm},sheetHandle:{width:36,height:4,borderRadius:e.radius.pill,...smoothCorners},sheetTitle:{includeFontPadding:!1},searchWrap:{width:"auto"},searchBox:{flexDirection:"row",alignItems:"center",borderWidth:1},searchInput:{flex:1,includeFontPadding:!1},optionRow:{flexDirection:"row",alignItems:"center"},sectionHeader:{paddingBottom:e.space.xs},listWrap:{flexShrink:1},listRow:{flexDirection:"row"},listBesideRail:{flex:1},rail:{justifyContent:"space-between",alignItems:"center",alignSelf:"stretch",paddingVertical:e.space.xs},railLetter:{paddingHorizontal:e.space.xs,minHeight:14,justifyContent:"center"},railLetterText:{includeFontPadding:!1,lineHeight:14},sectionTitle:{includeFontPadding:!1,letterSpacing:.6},optionIcon:{marginRight:e.space.md},optionTextWrap:{flex:1},optionLabel:{includeFontPadding:!1},optionDescription:{includeFontPadding:!1,marginTop:e.space.xxs},checkbox:{width:22,height:22,borderRadius:e.radius.sm,...smoothCorners,borderWidth:2,alignItems:"center",justifyContent:"center",marginLeft:e.space.md},checkboxTick:{width:10,height:6,borderLeftWidth:2,borderBottomWidth:2,borderColor:e.colors["on-primary"],transform:[{rotate:"-45deg"},{translateY:-1}]},singleSelectedDot:{width:8,height:8,borderRadius:e.radius.pill,...smoothCorners,marginLeft:e.space.md},singleSelectedIcon:{marginLeft:e.space.md},sheetFooter:{borderTopWidth:StyleSheet.hairlineWidth,alignItems:"flex-end"},doneButton:{alignSelf:"flex-end"}});export default OptionSheet;
@@ -0,0 +1 @@
1
+ "use strict";import{isValidElement}from"react";import{isRecord}from"../../utils/guards.js";const isReactNode=e=>null==e||"string"==typeof e||"number"==typeof e||"boolean"==typeof e||Array.isArray(e)||isValidElement(e);export const selectOptionLabel=e=>isRecord(e)&&"string"==typeof e.label?e.label:"";export const selectOptionValue=e=>{if(isRecord(e)&&("string"==typeof e.value||"number"==typeof e.value))return e.value;throw new Error("Option has no string or number value; pass getOptionValue.")};export const selectOptionDescription=e=>isRecord(e)&&"string"==typeof e.description?e.description:void 0;export const selectOptionDisabled=e=>isRecord(e)&&!0===e.disabled;export const selectOptionIcon=e=>isRecord(e)&&isReactNode(e.icon)?e.icon:void 0;
@@ -1 +1 @@
1
- "use strict";import{countryFlagEmoji,formatPhoneAsTyped,getFormatterConfig,getPhoneCountries,isSupportedCountry,isValidNationalNumber,maxNationalNumberLength,splitPhoneNumber}from"@webority/mobile-core";import{PHONE_COUNTRY_NAMES}from"@webority/mobile-core/phone/countries";import{forwardRef,useCallback,useEffect,useImperativeHandle,useMemo,useRef,useState}from"react";import{Pressable,StyleSheet,TextInput,View}from"react-native";import{useControllableState}from"../../hooks/index.js";import{fontFor,resolveFieldSize,useTheme}from"../../theme/index.js";import{resolveHaptic,triggerHaptic}from"../../utils/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{hitSlopMarker}from"../../utils/hitSlop.js";import{FieldBase,FieldLabel,FieldMessage,hasFieldText,RequiredPlaceholder,resolveFieldTextStyle}from"../FieldBase/index.js";import{Chevron}from"../FieldBase/Chevron.js";import{useFloatingLabel}from"../FieldBase/useFloatingLabel.js";import{OptionSheet}from"../OptionSheet/OptionSheet.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_PHONE_NUMBER_INPUT_LABELS=Object.freeze({placeholder:"Phone number",popular:"Popular",allCountries:"All countries",countrySheetTitle:"Country code",countrySearchPlaceholder:"Search…",invalid:"Enter a valid number",invalidMobile:"Enter a valid mobile number",countryButton:e=>`Country code, currently +${e}`});export const DEFAULT_CALLING_CODES=[{iso:"AU",code:"61",label:"Australia"},{iso:"CA",code:"1",label:"Canada"},{iso:"IN",code:"91",label:"India"},{iso:"SA",code:"966",label:"Saudi Arabia"},{iso:"SG",code:"65",label:"Singapore"},{iso:"AE",code:"971",label:"United Arab Emirates"},{iso:"GB",code:"44",label:"United Kingdom"},{iso:"US",code:"1",label:"United States"}];export const ALL_CALLING_CODES=getPhoneCountries().map(e=>({iso:e.iso,code:e.callingCode,label:PHONE_COUNTRY_NAMES[e.iso]??e.iso})).sort((e,t)=>e.label.localeCompare(t.label));const digitsOnly=e=>e.replace(/[^0-9]/g,"");export const formatE164=e=>`+${e.callingCode}${e.nationalNumber}`;export const parseE164=(e,t,o)=>{const i=e.replace(/[^0-9]/g,"");if(!i)return null;const l=splitPhoneNumber(`+${i}`);let n=l?.callingCode,a=l?.nationalNumber??"";if(!n){const e=Array.from(new Set(t.map(e=>e.code))).sort((e,t)=>t.length-e.length);if(n=e.find(e=>i.startsWith(e)),!n)return null;a=i.slice(n.length)}const r=t.filter(e=>e.code===n),s=r.find(e=>e.iso===o)?.iso??r.find(e=>e.iso===l?.country)?.iso??l?.country??r[0]?.iso??"";return{callingCode:n,nationalNumber:a,iso:s}};const planOf=e=>isSupportedCountry(e)?e:null;export const PhoneNumberInput=forwardRef((e,t)=>{const{value:o,defaultValue:i,onChange:l,e164:n,onChangeE164:a,returnKeyType:r,submitBehavior:s,onSubmitEditing:u,blurOnSubmit:d,onComplete:c,onValidityChange:p,countries:m=ALL_CALLING_CODES,popularCountries:b,hiddenCountries:f,showFlag:h=!0,renderFlag:g,renderCountry:N,showAlphabetIndex:y,defaultCountry:C,validation:x="any",maxLength:S,formatAsYouType:v=!0,countryLocked:E=!1,label:T,labelMode:F="top",labelStyle:L,placeholder:P,helperText:I,error:_,invalidMessage:j,required:O,disabled:A=!1,size:V="md",variant:M,radius:w,labels:B,haptic:U,accessibilityLabel:k,countryAccessibilityLabel:z,onFocus:D,onBlur:R,style:H,testID:$}=e;assertValidValue("PhoneNumberInput","size",e.size,["sm","md","lg"]),assertValidValue("PhoneNumberInput","variant",e.variant,["outline","filled","underline"]),assertValidValue("PhoneNumberInput","labelMode",e.labelMode,["top","float"]),assertValidValue("PhoneNumberInput","validation",!1===e.validation?void 0:e.validation,["any","mobile"]);const W=useTheme(),q=useMemo(()=>buildStyles(W),[W]),G=useRef(null),Y=useMemo(()=>B?{...DEFAULT_PHONE_NUMBER_INPUT_LABELS,...B}:DEFAULT_PHONE_NUMBER_INPUT_LABELS,[B]),K=P??Y.placeholder,Z=useMemo(()=>/-([A-Za-z]{2})(?:-|$)/.exec(getFormatterConfig().locale)?.[1]?.toUpperCase(),[]),J=useMemo(()=>f?.length?m.filter(e=>!f.includes(e.iso)):m,[m,f]),Q=useMemo(()=>{if(!b?.length)return;const e=b.map(e=>J.find(t=>t.iso===e)).filter(e=>void 0!==e);return e.length?[{title:Y.popular,options:e},{title:Y.allCountries,options:J}]:void 0},[b,Y.popular,Y.allCountries,J]),X=useCallback((e,t,o)=>{if(!e)return null;if(g)return g(e);if(!h)return null;const i=countryFlagEmoji(e.iso);return i?_jsx(Text,{variant:"body",style:[q.flag,{fontSize:t}],testID:o,children:i}):null},[g,h,q.flag]),ee=useCallback(e=>{const t=planOf(e),o=t?maxNationalNumberLength(t,!1===x?"any":x):Number.POSITIVE_INFINITY;return S?Math.min(o,S):o},[S,x]),te=useCallback((e,t)=>e.slice(0,ee(t)),[ee]),oe=useCallback((e,t)=>{const o=planOf(t)??void 0,i=splitPhoneNumber(e,o);if(!i)return null;const l=i.country??t,n=m.find(e=>e.iso===l);return{callingCode:n?.code??i.callingCode,nationalNumber:te(i.nationalNumber,l),iso:n?.iso??l}},[m,te]),ie=useMemo(()=>{const e=J.find(e=>e.iso===(C??Z))??J[0]??m[0],t={callingCode:e?.code??"",nationalNumber:"",iso:e?.iso??""};return"string"==typeof i?oe(i,t.iso)??t:i??t},[m,J,C,Z,i,oe]),le=useCallback(e=>{if(!1===x)return e.nationalNumber.length>0;const t=planOf(e.iso);return t?isValidNationalNumber(e.nationalNumber,t,x):e.nationalNumber.length>0},[x]),[ne,ae]=useState(ie.iso),re=useMemo(()=>{if(void 0===n)return;const e=n?parseE164(n,m,ne):null;if(e)return{...e,nationalNumber:te(e.nationalNumber,e.iso)};const t=m.find(e=>e.iso===ne);return{callingCode:t?.code??ie.callingCode,nationalNumber:"",iso:ne}},[n,m,ne,ie.callingCode,te]),se=useCallback(e=>{ae(e.iso),l?.(e),a?.(e.nationalNumber?formatE164(e):"",{country:m.find(t=>t.iso===e.iso),national:e.nationalNumber,valid:le(e)})},[l,a,m,le]),[ue,de]=useControllableState({value:o??re,defaultValue:ie,onChange:se}),[ce,pe]=useState(!1),me=useCallback(()=>{A||G.current?.focus()},[A]),[be,fe]=useState(!1),[he,ge]=useState(!1),[Ne,ye]=useState(!1),Ce=useRef(!1);useEffect(()=>{Ne||(Ce.current=!1)},[Ne]);const xe=resolveFieldSize(W,V),Se=resolveFieldTextStyle(W,{disabled:A}),ve=M??W.settings.components.field?.defaultVariant??"outline",Ee="underline"===ve,Te=W.space.md,[Fe,Le]=useState(0),Pe=Fe+Te+1+Te,Ie=ue.nationalNumber.length>0,je=O&&!T&&!Ie&&K.length>0,Oe=ce||Ie,Ae=Boolean(T)&&"float"===F&&Fe>0,Ve=useFloatingLabel({label:T,enabled:Ae,floated:Oe,required:O,variant:ve,sizeTokens:xe,leadingOffset:Pe,paddingLeft:Ee?W.space.none:xe["padding-x"],color:W.colors["field-label"],style:L}),Me=useMemo(()=>m.find(e=>e.iso===ue.iso),[m,ue.iso]),we=planOf(ue.iso),Be=v&&we?formatPhoneAsTyped(ue.nationalNumber,we):ue.nationalNumber,Ue=ee(ue.iso),ke=0===ue.nationalNumber.length||be||!Number.isFinite(Ue)?void 0:Be.length+Math.max(0,Ue-ue.nationalNumber.length),ze=le(ue);useEffect(()=>{Ie||ge(!1)},[Ie]);const De=we?maxNationalNumberLength(we,!1===x?"any":x):Number.POSITIVE_INFINITY,Re=ue.nationalNumber.length>=De,He=!1!==x&&!1!==j&&Ie&&!ze&&(he||Re),$e="mobile"===x?Y.invalidMobile:Y.invalid,We=hasFieldText(_)?_:He?j||$e:void 0,qe=!0===_||hasFieldText(We),Ge=useRef(ze),Ye=useRef(ue);Ye.current=ue,useEffect(()=>{Ge.current!==ze&&(Ge.current=ze,p?.(ze),ze&&c?.(formatE164(Ye.current)))},[ze,c,p]);const Ke=useCallback(e=>{if(e.includes("+")){const t=oe(e,ue.iso);if(t&&!E&&J.some(e=>e.iso===t.iso))return void de(t);if(t&&t.iso===ue.iso)return void de(t)}de({...ue,nationalNumber:te(digitsOnly(e),ue.iso)})},[J,E,ue,oe,te,de]),Ze=useCallback(e=>{de({callingCode:e.code,iso:e.iso,nationalNumber:te(ue.nationalNumber,e.iso)}),ye(!1);const t=resolveHaptic(U,"selection");t&&triggerHaptic(t)},[ue,U,te,de]);useImperativeHandle(t,()=>({focus:()=>G.current?.focus(),blur:()=>G.current?.blur(),clear:()=>de({...Ye.current,nationalNumber:""}),isFocused:()=>G.current?.isFocused()??!1,getValue:()=>Ye.current,getE164:()=>formatE164(Ye.current),getFormatted:()=>{const e=Ye.current,t=planOf(e.iso);return t?formatPhoneAsTyped(e.nationalNumber,t):e.nationalNumber},isValid:()=>le(Ye.current),getCountry:()=>m.find(e=>e.iso===Ye.current.iso)}),[m,le,de]);const Je=A||E,Qe=_jsx(FieldBase,{size:V,variant:ve,radius:w,topNotch:Ve.topNotch,focused:ce,disabled:A,error:qe,filled:Ie,onPress:me,pressFeedback:!1,leadingDivider:!0,paddingLeft:Ee?W.space.none:void 0,leading:_jsxs(Pressable,{onPress:()=>{Je||(Ce.current=!0,ye(!0))},disabled:Je,accessibilityRole:"button",accessibilityLabel:z??Y.countryButton(ue.callingCode),accessibilityState:{disabled:Je},"aria-disabled":Je,hitSlop:6,...hitSlopMarker(6),onLayout:e=>{const{width:t}=e.nativeEvent.layout;Le(e=>e===t?e:t)},style:q.codeTrigger,testID:$?`${$}-code`:void 0,children:[X(Me,xe.text,$?`${$}-flag`:void 0),_jsx(Text,{variant:"body",style:[q.codeText,{color:Se.color,fontSize:xe.text}],children:`+${ue.callingCode}`}),E?null:_jsx(Chevron,{color:A?W.colors["field-icon-disabled"]:W.colors["field-icon"],size:xe.icon,open:Ne})]}),children:_jsxs(View,{style:q.inputWrap,children:[_jsx(TextInput,{ref:G,value:Be,maxLength:ke,onChangeText:Ke,returnKeyType:r,submitBehavior:s,onSubmitEditing:u,blurOnSubmit:d,onSelectionChange:e=>{const{start:t,end:o}=e.nativeEvent.selection;fe(t!==o)},onFocus:()=>{pe(!0),D?.()},onBlur:()=>{pe(!1),Ie&&!Ce.current&&ge(!0),R?.()},editable:!A,placeholder:Ae&&!Oe||je?void 0:K,placeholderTextColor:Se.placeholderColor,accessibilityLabel:k??T??K,selectionColor:W.colors["field-caret"],keyboardType:"phone-pad",textContentType:"telephoneNumber",autoComplete:"tel",style:[q.input,{color:Se.color,fontSize:xe.text,...Se.weightStyle,paddingLeft:Ee?W.space.none:void 0}],testID:$?`${$}-input`:void 0}),je?_jsx(RequiredPlaceholder,{text:K,color:Se.placeholderColor,fontSize:xe.text,weightStyle:Se.weightStyle}):null]})});return _jsxs(View,{style:H,testID:$,children:[T&&"top"===F?_jsx(FieldLabel,{size:V,required:O,children:T}):null,_jsxs(View,{style:q.fieldWrapper,children:[Qe,Ve.node]}),_jsx(FieldMessage,{size:V,error:qe,text:qe?We:I}),_jsx(OptionSheet,{open:Ne,haptic:U,onClose:()=>ye(!1),title:Y.countrySheetTitle,options:J,sections:Q,getOptionLabel:e=>`${e.label} (+${e.code})`,getOptionValue:e=>e.iso,getOptionIcon:e=>X(e,W.text.lg.size),renderOption:N?({option:e,selected:t})=>N(e,{selected:t}):void 0,value:Me?.iso,onChange:(e,t)=>Ze(t),searchable:J.length>8,labels:{searchPlaceholder:Y.countrySearchPlaceholder},alphabetIndex:y??J.length>20})]})});PhoneNumberInput.displayName="PhoneNumberInput";const buildStyles=e=>StyleSheet.create({fieldWrapper:{position:"relative",overflow:"visible"},codeTrigger:{flexDirection:"row",alignItems:"center",gap:e.space.xxs},flag:{includeFontPadding:!1,marginRight:e.space.xs},codeText:{...fontFor(e,"semibold"),fontWeight:"600",includeFontPadding:!1,writingDirection:"ltr"},input:{padding:e.space.none,margin:e.space.none,includeFontPadding:!1,writingDirection:"ltr"},inputWrap:{flex:1,alignSelf:"stretch",justifyContent:"center"}});export default PhoneNumberInput;
1
+ "use strict";import{countryFlagEmoji,formatPhoneAsTyped,getFormatterConfig,getPhoneCountries,isSupportedCountry,isValidNationalNumber,maxNationalNumberLength,splitPhoneNumber}from"@webority/mobile-core";import{PHONE_COUNTRY_NAMES}from"@webority/mobile-core/phone/countries";import{forwardRef,useCallback,useEffect,useImperativeHandle,useMemo,useRef,useState}from"react";import{Pressable,StyleSheet,TextInput,View}from"react-native";import{useControllableState}from"../../hooks/index.js";import{fontFor,resolveFieldSize,useTheme}from"../../theme/index.js";import{resolveHaptic,triggerHaptic}from"../../utils/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{hitSlopMarker}from"../../utils/hitSlop.js";import{FieldBase,FieldLabel,FieldMessage,hasFieldText,RequiredPlaceholder,resolveFieldTextStyle}from"../FieldBase/index.js";import{Chevron}from"../FieldBase/Chevron.js";import{useFloatingLabel}from"../FieldBase/useFloatingLabel.js";import{OptionSheet}from"../OptionSheet/OptionSheet.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_PHONE_NUMBER_INPUT_LABELS=Object.freeze({placeholder:"Phone number",popular:"Popular",allCountries:"All countries",countrySheetTitle:"Country code",countrySearchPlaceholder:"Search…",invalid:"Enter a valid number",invalidMobile:"Enter a valid mobile number",countryButton:e=>`Country code, currently +${e}`});export const DEFAULT_CALLING_CODES=[{iso:"AU",code:"61",label:"Australia"},{iso:"CA",code:"1",label:"Canada"},{iso:"IN",code:"91",label:"India"},{iso:"SA",code:"966",label:"Saudi Arabia"},{iso:"SG",code:"65",label:"Singapore"},{iso:"AE",code:"971",label:"United Arab Emirates"},{iso:"GB",code:"44",label:"United Kingdom"},{iso:"US",code:"1",label:"United States"}];export const ALL_CALLING_CODES=getPhoneCountries().map(e=>({iso:e.iso,code:e.callingCode,label:PHONE_COUNTRY_NAMES[e.iso]??e.iso})).sort((e,t)=>e.label.localeCompare(t.label));const digitsOnly=e=>e.replace(/[^0-9]/g,"");export const formatE164=e=>`+${e.callingCode}${e.nationalNumber}`;export const parseE164=(e,t,o)=>{const i=e.replace(/[^0-9]/g,"");if(!i)return null;const n=splitPhoneNumber(`+${i}`);let l=n?.callingCode,r=n?.nationalNumber??"";if(!l){const e=Array.from(new Set(t.map(e=>e.code))).sort((e,t)=>t.length-e.length);if(l=e.find(e=>i.startsWith(e)),!l)return null;r=i.slice(l.length)}const a=t.filter(e=>e.code===l),s=a.find(e=>e.iso===o)?.iso??a.find(e=>e.iso===n?.country)?.iso??n?.country??a[0]?.iso??"";return{callingCode:l,nationalNumber:r,iso:s}};const planOf=e=>isSupportedCountry(e)?e:null,assertDefaultCountryVisible=(e,t)=>{if(void 0!==e&&!t.some(t=>t.iso===e))throw new RangeError(`PhoneNumberInput: defaultCountry "${e}" is not among the visible countries. Add it to countries, or remove it from hiddenCountries.`)};export const PhoneNumberInput=forwardRef((e,t)=>{const{value:o,defaultValue:i,onChange:n,e164:l,onChangeE164:r,returnKeyType:a,submitBehavior:s,onSubmitEditing:u,blurOnSubmit:d,onComplete:c,onValidityChange:p,countries:m=ALL_CALLING_CODES,popularCountries:b,hiddenCountries:f,showFlag:h=!0,renderFlag:g,renderCountry:y,showAlphabetIndex:N,defaultCountry:C,validation:x="any",maxLength:S,formatAsYouType:v=!0,countryLocked:E=!1,label:T,labelMode:F="top",labelStyle:P,placeholder:I,helperText:L,error:_,invalidMessage:j,required:O,disabled:A=!1,size:V="md",variant:M,radius:w,labels:B,haptic:D,accessibilityLabel:U,countryAccessibilityLabel:k,onFocus:z,onBlur:R,style:$,testID:H}=e;assertValidValue("PhoneNumberInput","size",e.size,["sm","md","lg"]),assertValidValue("PhoneNumberInput","variant",e.variant,["outline","filled","underline"]),assertValidValue("PhoneNumberInput","labelMode",e.labelMode,["top","float"]),assertValidValue("PhoneNumberInput","validation",!1===e.validation?void 0:e.validation,["any","mobile"]);const W=useTheme(),q=useMemo(()=>buildStyles(W),[W]),G=useRef(null),Y=useMemo(()=>B?{...DEFAULT_PHONE_NUMBER_INPUT_LABELS,...B}:DEFAULT_PHONE_NUMBER_INPUT_LABELS,[B]),K=I??Y.placeholder,Z=useMemo(()=>/-([A-Za-z]{2})(?:-|$)/.exec(getFormatterConfig().locale)?.[1]?.toUpperCase(),[]),J=useMemo(()=>f?.length?m.filter(e=>!f.includes(e.iso)):m,[m,f]),Q=useMemo(()=>{if(!b?.length)return;const e=b.map(e=>J.find(t=>t.iso===e)).filter(e=>void 0!==e);return e.length?[{title:Y.popular,options:e},{title:Y.allCountries,options:J}]:void 0},[b,Y.popular,Y.allCountries,J]),X=useCallback((e,t,o)=>{if(!e)return null;if(g)return g(e);if(!h)return null;const i=countryFlagEmoji(e.iso);return i?_jsx(Text,{variant:"body",style:[q.flag,{fontSize:t}],testID:o,children:i}):null},[g,h,q.flag]),ee=useCallback(e=>{const t=planOf(e),o=t?maxNationalNumberLength(t,!1===x?"any":x):Number.POSITIVE_INFINITY;return S?Math.min(o,S):o},[S,x]),te=useCallback((e,t)=>e.slice(0,ee(t)),[ee]),oe=useCallback((e,t)=>{const o=planOf(t)??void 0,i=splitPhoneNumber(e,o);if(!i)return null;const n=i.country??t,l=m.find(e=>e.iso===n);return{callingCode:l?.code??i.callingCode,nationalNumber:te(i.nationalNumber,n),iso:l?.iso??n}},[m,te]);useState(()=>assertDefaultCountryVisible(C,J));const ie=useMemo(()=>{const e=J.find(e=>e.iso===(C??Z))??J[0]??m[0],t={callingCode:e?.code??"",nationalNumber:"",iso:e?.iso??""};return"string"==typeof i?oe(i,t.iso)??t:i??t},[m,J,C,Z,i,oe]),ne=useCallback(e=>{if(!1===x)return e.nationalNumber.length>0;const t=planOf(e.iso);return t?isValidNationalNumber(e.nationalNumber,t,x):e.nationalNumber.length>0},[x]),[le,re]=useState(ie.iso),ae=useMemo(()=>{if(void 0===l)return;const e=l?parseE164(l,m,le):null;if(e)return{...e,nationalNumber:te(e.nationalNumber,e.iso)};const t=m.find(e=>e.iso===le);return{callingCode:t?.code??ie.callingCode,nationalNumber:"",iso:le}},[l,m,le,ie.callingCode,te]),se=useCallback(e=>{re(e.iso),n?.(e),r?.(e.nationalNumber?formatE164(e):"",{country:m.find(t=>t.iso===e.iso),national:e.nationalNumber,valid:ne(e)})},[n,r,m,ne]),[ue,de]=useControllableState({value:o??ae,defaultValue:ie,onChange:se}),[ce,pe]=useState(!1),me=useCallback(()=>{A||G.current?.focus()},[A]),[be,fe]=useState(!1),[he,ge]=useState(!1),[ye,Ne]=useState(!1),Ce=useRef(!1);useEffect(()=>{ye||(Ce.current=!1)},[ye]);const xe=resolveFieldSize(W,V),Se=resolveFieldTextStyle(W,{disabled:A}),ve=M??W.settings.components.field?.defaultVariant??"outline",Ee="underline"===ve,Te=W.space.md,[Fe,Pe]=useState(0),Ie=Fe+Te+1+Te,Le=ue.nationalNumber.length>0,je=O&&!T&&!Le&&K.length>0,Oe=ce||Le,Ae=Boolean(T)&&"float"===F&&Fe>0,Ve=useFloatingLabel({label:T,enabled:Ae,floated:Oe,required:O,variant:ve,sizeTokens:xe,leadingOffset:Ie,paddingLeft:Ee?W.space.none:xe["padding-x"],color:W.colors["field-label"],style:P}),Me=useMemo(()=>m.find(e=>e.iso===ue.iso),[m,ue.iso]),we=planOf(ue.iso),Be=v&&we?formatPhoneAsTyped(ue.nationalNumber,we):ue.nationalNumber,De=ee(ue.iso),Ue=0===ue.nationalNumber.length||be||!Number.isFinite(De)?void 0:Be.length+Math.max(0,De-ue.nationalNumber.length),ke=ne(ue);useEffect(()=>{Le||ge(!1)},[Le]);const ze=we?maxNationalNumberLength(we,!1===x?"any":x):Number.POSITIVE_INFINITY,Re=ue.nationalNumber.length>=ze,$e=!1!==x&&!1!==j&&Le&&!ke&&(he||Re),He="mobile"===x?Y.invalidMobile:Y.invalid,We=hasFieldText(_)?_:$e?j||He:void 0,qe=!0===_||hasFieldText(We),Ge=useRef(ke),Ye=useRef(ue);Ye.current=ue,useEffect(()=>{Ge.current!==ke&&(Ge.current=ke,p?.(ke),ke&&c?.(formatE164(Ye.current)))},[ke,c,p]);const Ke=useCallback(e=>{if(e.includes("+")){const t=oe(e,ue.iso);if(t&&!E&&J.some(e=>e.iso===t.iso))return void de(t);if(t&&t.iso===ue.iso)return void de(t)}de({...ue,nationalNumber:te(digitsOnly(e),ue.iso)})},[J,E,ue,oe,te,de]),Ze=useCallback(e=>{de({callingCode:e.code,iso:e.iso,nationalNumber:te(ue.nationalNumber,e.iso)}),Ne(!1);const t=resolveHaptic(D,"selection");t&&triggerHaptic(t)},[ue,D,te,de]);useImperativeHandle(t,()=>({focus:()=>G.current?.focus(),blur:()=>G.current?.blur(),clear:()=>de({...Ye.current,nationalNumber:""}),isFocused:()=>G.current?.isFocused()??!1,getValue:()=>Ye.current,getE164:()=>formatE164(Ye.current),getFormatted:()=>{const e=Ye.current,t=planOf(e.iso);return t?formatPhoneAsTyped(e.nationalNumber,t):e.nationalNumber},isValid:()=>ne(Ye.current),getCountry:()=>m.find(e=>e.iso===Ye.current.iso)}),[m,ne,de]);const Je=A||E,Qe=_jsx(FieldBase,{size:V,variant:ve,radius:w,topNotch:Ve.topNotch,focused:ce,disabled:A,error:qe,filled:Le,onPress:me,pressFeedback:!1,leadingDivider:!0,paddingLeft:Ee?W.space.none:void 0,leading:_jsxs(Pressable,{onPress:()=>{Je||(Ce.current=!0,Ne(!0))},disabled:Je,accessibilityRole:"button",accessibilityLabel:k??Y.countryButton(ue.callingCode),accessibilityState:{disabled:Je},"aria-disabled":Je,hitSlop:6,...hitSlopMarker(6),onLayout:e=>{const{width:t}=e.nativeEvent.layout;Pe(e=>e===t?e:t)},style:q.codeTrigger,testID:H?`${H}-code`:void 0,children:[X(Me,xe.text,H?`${H}-flag`:void 0),_jsx(Text,{variant:"body",style:[q.codeText,{color:Se.color,fontSize:xe.text}],children:`+${ue.callingCode}`}),E?null:_jsx(Chevron,{color:A?W.colors["field-icon-disabled"]:W.colors["field-icon"],size:xe.icon,open:ye})]}),children:_jsxs(View,{style:q.inputWrap,children:[_jsx(TextInput,{ref:G,value:Be,maxLength:Ue,onChangeText:Ke,returnKeyType:a,submitBehavior:s,onSubmitEditing:u,blurOnSubmit:d,onSelectionChange:e=>{const{start:t,end:o}=e.nativeEvent.selection;fe(t!==o)},onFocus:()=>{pe(!0),z?.()},onBlur:()=>{pe(!1),Le&&!Ce.current&&ge(!0),R?.()},editable:!A,placeholder:Ae&&!Oe||je?void 0:K,placeholderTextColor:Se.placeholderColor,accessibilityLabel:U??T??K,selectionColor:W.colors["field-caret"],keyboardType:"phone-pad",textContentType:"telephoneNumber",autoComplete:"tel",style:[q.input,{color:Se.color,fontSize:xe.text,...Se.weightStyle,paddingLeft:Ee?W.space.none:void 0}],testID:H?`${H}-input`:void 0}),je?_jsx(RequiredPlaceholder,{text:K,color:Se.placeholderColor,fontSize:xe.text,weightStyle:Se.weightStyle}):null]})});return _jsxs(View,{style:$,testID:H,children:[T&&"top"===F?_jsx(FieldLabel,{size:V,required:O,children:T}):null,_jsxs(View,{style:q.fieldWrapper,children:[Qe,Ve.node]}),_jsx(FieldMessage,{size:V,error:qe,text:qe?We:L}),_jsx(OptionSheet,{open:ye,haptic:D,onClose:()=>Ne(!1),title:Y.countrySheetTitle,options:J,sections:Q,getOptionLabel:e=>`${e.label} (+${e.code})`,getOptionValue:e=>e.iso,getOptionIcon:e=>X(e,W.text.lg.size),renderOption:y?({option:e,selected:t})=>y(e,{selected:t}):void 0,value:Me?.iso,onChange:(e,t)=>Ze(t),searchable:J.length>8,labels:{searchPlaceholder:Y.countrySearchPlaceholder},alphabetIndex:N??J.length>20})]})});PhoneNumberInput.displayName="PhoneNumberInput";const buildStyles=e=>StyleSheet.create({fieldWrapper:{position:"relative",overflow:"visible"},codeTrigger:{flexDirection:"row",alignItems:"center",gap:e.space.xxs},flag:{includeFontPadding:!1,marginRight:e.space.xs},codeText:{...fontFor(e,"semibold"),fontWeight:"600",includeFontPadding:!1,writingDirection:"ltr"},input:{padding:e.space.none,margin:e.space.none,includeFontPadding:!1,writingDirection:"ltr"},inputWrap:{flex:1,alignSelf:"stretch",justifyContent:"center"}});export default PhoneNumberInput;
@@ -1 +1 @@
1
- "use strict";import{forwardRef,useEffect,useMemo,useRef}from"react";import{Animated,Easing,StyleSheet,View}from"react-native";import Svg,{Circle}from"react-native-svg";import{useReducedMotion}from"../../hooks/index.js";import{createAnimatedValue,useTheme}from"../../theme/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const AnimatedCircle=Animated.createAnimatedComponent(Circle),toneColor=(e,t)=>{switch(t){case"success":return e.colors.success;case"warning":return e.colors.warning;case"danger":return e.colors.danger;case"info":return e.colors.info;case"neutral":return e.colors["text-muted"];default:return e.colors.primary}},clampProgress=e=>"number"!=typeof e||Number.isNaN(e)?0:Math.min(1,Math.max(0,e)),DEFAULT_STROKE_WIDTH=4,DEFAULT_DURATION=600,DEFAULT_COLOR_STOPS=[1/3,2/3],STOP_EDGE=1e-4,ProgressRing=forwardRef((e,t)=>{const{progress:r,size:s=48,strokeWidth:o,tone:n="primary",trackColor:i,ringColor:a,colorByProgress:c=!1,animated:l=!0,rounded:u=!0,children:m,accessibilityLabel:d,style:g,testID:f}=e;assertValidValue("ProgressRing","tone",e.tone,["primary","success","warning","danger","info","neutral"]);const p=useTheme(),h=useReducedMotion(),y=clampProgress(r),R=o??4,x=i??p.colors["surface-disabled"],[b,w]=DEFAULT_COLOR_STOPS,j=Math.max(0,(s-R)/2),_=2*Math.PI*j,C=useRef(createAnimatedValue(y)).current;useEffect(()=>{if(!l||h)return void C.setValue(y);const e=Animated.timing(C,{toValue:y,duration:600,easing:Easing.bezier(...p.motion.ease["in-out"]),useNativeDriver:!1});return e.start(),()=>e.stop()},[l,y,C,h,p.motion.ease["in-out"]]);const S=C.interpolate({inputRange:[0,1],outputRange:[_,0]}),V=C.interpolate({inputRange:[0,.001,1],outputRange:[0,1,1]}),A=useMemo(()=>C.interpolate({inputRange:[0,b-1e-4,b,w-1e-4,w,1],outputRange:[p.colors.danger,p.colors.danger,p.colors.warning,p.colors.warning,p.colors.success,p.colors.success]}),[C,p.colors.danger,p.colors.warning,p.colors.success]),D=a??(c?A:toneColor(p,n)),P=useMemo(()=>buildStyles(),[]),E=s/2;return _jsxs(View,{ref:t,accessible:null==m,accessibilityRole:"progressbar",accessibilityLabel:d,accessibilityValue:{min:0,max:100,now:Math.round(100*y)},testID:f,style:[P.root,{width:s,height:s},g],children:[_jsxs(Svg,{width:s,height:s,viewBox:`0 0 ${s} ${s}`,children:[_jsx(Circle,{cx:E,cy:E,r:j,stroke:x,strokeWidth:R,fill:"none"}),_jsx(AnimatedCircle,{cx:E,cy:E,r:j,stroke:D,strokeWidth:R,strokeLinecap:u?"round":"butt",strokeDasharray:`${_} ${_}`,strokeDashoffset:S,strokeOpacity:V,fill:"none",transform:`rotate(-90 ${E} ${E})`,testID:f?`${f}-fill`:void 0})]}),null!=m?_jsx(View,{style:P.content,pointerEvents:"box-none",children:m}):null]})});ProgressRing.displayName="ProgressRing";const buildStyles=()=>StyleSheet.create({root:{alignItems:"center",justifyContent:"center"},content:{position:"absolute",top:0,right:0,bottom:0,left:0,alignItems:"center",justifyContent:"center"}});export{ProgressRing};export default ProgressRing;
1
+ "use strict";import{forwardRef,useEffect,useMemo,useRef}from"react";import{Animated,Easing,StyleSheet,View}from"react-native";import Svg,{Circle}from"react-native-svg";import{useReducedMotion}from"../../hooks/index.js";import{createAnimatedValue,useTheme}from"../../theme/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const AnimatedCircle=Animated.createAnimatedComponent(Circle),toneColor=(e,t)=>{switch(t){case"success":return e.colors.success;case"warning":return e.colors.warning;case"danger":return e.colors.danger;case"info":return e.colors.info;case"neutral":return e.colors["text-muted"];default:return e.colors.primary}},clampProgress=e=>"number"!=typeof e||Number.isNaN(e)?0:Math.min(1,Math.max(0,e)),DEFAULT_STROKE_WIDTH=4,DEFAULT_DURATION=600,DEFAULT_COLOR_STOPS=[1/3,2/3],STOP_EDGE=1e-4,ProgressRing=forwardRef((e,t)=>{const{progress:r,size:s=48,strokeWidth:o,tone:n="primary",trackColor:i,ringColor:a,colorByProgress:c=!1,animated:l=!0,rounded:u=!0,children:m,accessibilityLabel:d,style:g,testID:f}=e;assertValidValue("ProgressRing","tone",e.tone,["primary","success","warning","danger","info","neutral"]);const p=useTheme(),h=useReducedMotion(),y=clampProgress(r),R=o??4,x=i??p.colors["surface-disabled"],[b,w]=DEFAULT_COLOR_STOPS,j=Math.max(0,(s-R)/2),_=2*Math.PI*j,C=useRef(createAnimatedValue(y)).current;useEffect(()=>{if(!l||h)return void C.setValue(y);const e=Animated.timing(C,{toValue:y,duration:600,easing:Easing.bezier(...p.motion.ease["in-out"]),useNativeDriver:!1});return e.start(),()=>e.stop()},[l,y,C,h,p.motion.ease["in-out"]]);const S=C.interpolate({inputRange:[0,1],outputRange:[_,0]}),V=C.interpolate({inputRange:[0,.001,1],outputRange:[0,1,1]}),A=useMemo(()=>C.interpolate({inputRange:[0,b-1e-4,b,w-1e-4,w,1],outputRange:[p.colors.danger,p.colors.danger,p.colors.warning,p.colors.warning,p.colors.success,p.colors.success]}),[C,p.colors.danger,p.colors.warning,p.colors.success]),D=a??(c?A:toneColor(p,n)),P=useMemo(()=>buildStyles(),[]),E=s/2;return _jsxs(View,{ref:t,accessible:null==m,accessibilityRole:"progressbar",accessibilityLabel:d,accessibilityValue:{min:0,max:100,now:Math.round(100*y)},testID:f,style:[P.root,{width:s,height:s},g],children:[_jsxs(Svg,{width:s,height:s,viewBox:`0 0 ${s} ${s}`,children:[_jsx(Circle,{cx:E,cy:E,r:j,stroke:x,strokeWidth:R,fill:"none"}),_jsx(AnimatedCircle,{cx:E,cy:E,r:j,stroke:D,strokeWidth:R,strokeLinecap:u?"round":"butt",strokeDasharray:`${_} ${_}`,strokeDashoffset:S,strokeOpacity:V,fill:"none",transform:`rotate(-90 ${E} ${E})`,...f?{testID:`${f}-fill`}:{}})]}),null!=m?_jsx(View,{style:P.content,pointerEvents:"box-none",children:m}):null]})});ProgressRing.displayName="ProgressRing";const buildStyles=()=>StyleSheet.create({root:{alignItems:"center",justifyContent:"center"},content:{position:"absolute",top:0,right:0,bottom:0,left:0,alignItems:"center",justifyContent:"center"}});export{ProgressRing};export default ProgressRing;
@@ -1 +1 @@
1
- "use strict";import{useMemo}from"react";import{View}from"react-native";import{useControllableState}from"../../hooks/index.js";import{hasFieldText}from"../FieldBase/index.js";import{ChoiceText}from"../FieldBase/ChoiceText.js";import{RadioGroupContext}from"./Radio.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const RadioGroup=({value:e,defaultValue:o,onChange:i,children:t,disabled:a=!1,error:r,accessibilityLabel:s,style:l,testID:d})=>{const[u,c]=useControllableState({value:e,defaultValue:o??void 0,onChange:i}),n=!0===r||hasFieldText(r),p=useMemo(()=>({selectedValue:u,onChange:c,disabled:a,error:n}),[u,c,a,n]);return _jsxs(RadioGroupContext.Provider,{value:p,children:[_jsx(View,{accessibilityRole:"radiogroup",accessibilityLabel:s,accessibilityState:{disabled:a},"aria-disabled":a,testID:d,style:l,children:t}),_jsx(ChoiceText,{error:"string"==typeof r?r:void 0})]})};RadioGroup.displayName="RadioGroup";export{RadioGroup};export default RadioGroup;
1
+ "use strict";import{useCallback,useMemo}from"react";import{View}from"react-native";import{useControllableState}from"../../hooks/index.js";import{hasFieldText}from"../FieldBase/index.js";import{ChoiceText}from"../FieldBase/ChoiceText.js";import{RadioGroupContext}from"./Radio.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const RadioGroup=({value:e,defaultValue:o,onChange:i,children:r,disabled:a=!1,error:t,accessibilityLabel:s,style:l,testID:d})=>{const u=useCallback(e=>{if("string"!=typeof e&&"number"!=typeof e)throw new Error("RadioGroup received a missing value in single mode.");i?.(e)},[i]),[n,c]=useControllableState({value:e,defaultValue:o??void 0,onChange:u}),p=!0===t||hasFieldText(t),m=useMemo(()=>({selectedValue:n,onChange:c,disabled:a,error:p}),[n,c,a,p]);return _jsxs(RadioGroupContext.Provider,{value:m,children:[_jsx(View,{accessibilityRole:"radiogroup",accessibilityLabel:s,accessibilityState:{disabled:a},"aria-disabled":a,testID:d,style:l,children:r}),_jsx(ChoiceText,{error:"string"==typeof t?t:void 0})]})};RadioGroup.displayName="RadioGroup";export{RadioGroup};export default RadioGroup;
@@ -1 +1 @@
1
- "use strict";import{forwardRef,useCallback,useMemo,useRef}from"react";import{Animated,Easing,Pressable,StyleSheet,View}from"react-native";import{useTheme}from"../../theme/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{resolveHaptic,triggerHaptic}from"../../utils/hapticUtils.js";import{hitSlopMarker}from"../../utils/hitSlop.js";import{nativeDriver}from"../../utils/nativeDriver.js";import{Skeleton}from"../Skeleton/index.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const RATING_SIZES=["sm","md","lg"],RATING_TONES=["primary","success","warning","danger","info","neutral"];export const DEFAULT_RATING_LABELS=Object.freeze({value:(e,t)=>`${e} of ${t} stars`});const sizePxMap={sm:16,md:24,lg:32},resolveSize=e=>sizePxMap[e],PULSE_SCALE=1.2,toneColorFor=(e,t)=>{switch(t){case"success":return e.colors.success;case"warning":return e.colors.warning;case"danger":return e.colors.danger;case"info":return e.colors.info;case"neutral":return e.colors.neutral;case"primary":return e.colors.primary}},clampToStep=(e,t,s)=>{const i=Math.max(0,Math.min(t,e)),r=Math.round(i/s)*s;return Number(r.toFixed(2))},Star=({index:e,filled:t,size:s,filledColor:i,emptyColor:r,scale:a})=>{const n=Math.max(0,Math.min(1,t-e));return _jsxs(Animated.View,{style:[starStyles.starWrap,{width:s,height:s,transform:[{scale:a}]}],children:[_jsx(Text,{variant:"body",style:[starStyles.glyph,{color:r,fontSize:s,lineHeight:s}],accessible:!1,children:"☆"}),n>0?_jsx(View,{pointerEvents:"none",style:[starStyles.fillClip,{width:s*n,height:s}],children:_jsx(Text,{variant:"body",style:[starStyles.glyph,{color:i,fontSize:s,lineHeight:s}],accessible:!1,children:"★"})}):null]})},Rating=forwardRef((e,t)=>{const{value:s,onChange:i,max:r=5,allowHalf:a=!0,readonly:n=!1,size:o="md",tone:l="warning",label:c,loading:m=!1,haptic:u,labels:d,accessibilityLabel:p,style:y,containerStyle:g,starContainerStyle:f,testID:h}=e;assertValidValue("Rating","size",e.size,RATING_SIZES),assertValidValue("Rating","tone",e.tone,RATING_TONES);const x=useMemo(()=>({...DEFAULT_RATING_LABELS,...d}),[d]),S=useTheme(),b=useMemo(()=>buildStyles(S),[S]),v=!n&&"function"==typeof i,w=a?.5:1,j=resolveSize(o),R=toneColorFor(S,l),_=S.colors.border,A=useRef(j),k=useCallback(e=>{A.current=e.nativeEvent.layout.width},[]),T=useRef(new Map),V=useMemo(()=>{const e=T.current,t=[];for(let s=0;s<r;s+=1){let i=e.get(s);i||(i=new Animated.Value(1),e.set(s,i)),t.push(i)}for(const t of Array.from(e.keys()))t>=r&&e.delete(t);return t},[r]),C=S.settings.components.rating?.pulseOnPress??!1,E=useCallback(e=>{const t=V[e];if(!t)throw new Error(`Rating has no star at index ${e}; the pulse index must be below max.`);Animated.sequence([Animated.timing(t,{toValue:1.2,duration:S.motion.duration.fast,easing:Easing.bezier(...S.motion.ease["in-out"]),useNativeDriver:nativeDriver}),Animated.spring(t,{toValue:1,damping:S.motion.spring.bouncy.damping,stiffness:S.motion.spring.bouncy.stiffness,mass:S.motion.spring.bouncy.mass,useNativeDriver:nativeDriver})]).start()},[S.motion,V]),M=useCallback((e,t)=>{if(!v||!i)return;const s=clampToStep(e,r,w),a=resolveHaptic(u,"selection");a&&triggerHaptic(a),C&&"number"==typeof t&&E(t),i(s)},[v,i,r,w,E,u,C]),z=useCallback(e=>t=>{if(!v)return;const s=A.current||j,i=t.nativeEvent.locationX??s;let r;r=a&&i<s/2?e+.5:e+1,M(r,e)},[v,j,a,M]),N=useCallback(e=>{v&&("increment"===e.nativeEvent.actionName?M(s+w):"decrement"===e.nativeEvent.actionName&&M(s-w))},[v,s,w,M]),D=x.value(s,r),I=p??c??D,L=[];for(const[e,t]of V.entries()){const i=_jsx(Star,{index:e,filled:s,size:j,filledColor:R,emptyColor:_,scale:t},e);L.push(v?_jsx(Pressable,{onPress:z(e),onLayout:0===e?k:void 0,hitSlop:4,...hitSlopMarker(4),accessible:!1,style:b.starPress,children:i},e):_jsx(View,{onLayout:0===e?k:void 0,style:b.starPress,children:i},e))}const P=_jsxs(View,{style:[b.wrapper,g,y],ref:t,testID:h,children:[c?_jsx(Text,{variant:"bodySmall",color:"secondary",style:b.label,children:c}):null,_jsx(View,{style:[b.row,f],accessible:!0,accessibilityRole:v?"adjustable":"text",accessibilityLabel:I,accessibilityValue:v?{min:0,max:r,now:s,text:D}:void 0,accessibilityActions:v?[{name:"increment"},{name:"decrement"}]:void 0,onAccessibilityAction:v?N:void 0,children:L})]});return m?_jsx(RatingSkeleton,{...e}):P});Rating.displayName="Rating";const RatingSkeleton=({max:e=5,size:t="md",label:s,containerStyle:i,starContainerStyle:r,style:a})=>{const n=useTheme(),o=resolveSize(t),l=Math.max(1,e);return _jsxs(View,{style:[{alignItems:"flex-start"},i,a],accessibilityRole:"progressbar",accessibilityState:{busy:!0},"aria-busy":!0,children:[void 0!==s?_jsx(Skeleton,{shape:"text",width:80,height:14,style:{marginBottom:n.space.xs}}):null,_jsx(View,{style:[{flexDirection:"row"},r],children:Array.from({length:l}).map((e,t)=>_jsx(Skeleton,{width:o,height:o,radius:Math.round(.25*o),style:t<l-1?{marginRight:n.space.xs}:void 0},`sk-star-${t}`))})]})};RatingSkeleton.displayName="RatingSkeleton",Rating.Skeleton=RatingSkeleton;const starStyles=StyleSheet.create({starWrap:{position:"relative",alignItems:"flex-start",justifyContent:"center"},glyph:{textAlign:"left",includeFontPadding:!1},fillClip:{position:"absolute",top:0,left:0,overflow:"hidden"}}),buildStyles=e=>StyleSheet.create({wrapper:{flexDirection:"column"},row:{flexDirection:"row",alignItems:"center"},starPress:{marginRight:e.space.xs},label:{marginBottom:e.space.xs}});export{Rating};export default Rating;
1
+ "use strict";import{forwardRef,useCallback,useMemo,useRef}from"react";import{Animated,Easing,Pressable,StyleSheet,View}from"react-native";import{useTheme}from"../../theme/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{resolveHaptic,triggerHaptic}from"../../utils/hapticUtils.js";import{hitSlopMarker}from"../../utils/hitSlop.js";import{nativeDriver}from"../../utils/nativeDriver.js";import{Skeleton}from"../Skeleton/index.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const RATING_SIZES=["sm","md","lg"],RATING_TONES=["primary","success","warning","danger","info","neutral"];export const DEFAULT_RATING_LABELS=Object.freeze({value:(e,t)=>`${e} of ${t} stars`});const sizePxMap={sm:16,md:24,lg:32},resolveSize=e=>sizePxMap[e],PULSE_SCALE=1.2,toneColorFor=(e,t)=>{switch(t){case"success":return e.colors.success;case"warning":return e.colors.warning;case"danger":return e.colors.danger;case"info":return e.colors.info;case"neutral":return e.colors.neutral;case"primary":return e.colors.primary}},clampToStep=(e,t,s)=>{const i=Math.max(0,Math.min(t,e)),r=Math.round(i/s)*s;return Number(r.toFixed(2))},Star=({index:e,filled:t,size:s,filledColor:i,emptyColor:r,scale:a})=>{const n=Math.max(0,Math.min(1,t-e));return _jsxs(Animated.View,{style:[starStyles.starWrap,{width:s,height:s,transform:[{scale:a}]}],children:[_jsx(Text,{variant:"body",style:[starStyles.glyph,{color:r,fontSize:s,lineHeight:s}],accessible:!1,children:"☆"}),n>0?_jsx(View,{pointerEvents:"none",style:[starStyles.fillClip,{width:s*n,height:s}],children:_jsx(Text,{variant:"body",style:[starStyles.glyph,{color:i,fontSize:s,lineHeight:s}],accessible:!1,children:"★"})}):null]})},RatingRoot=forwardRef((e,t)=>{const{value:s,onChange:i,max:r=5,allowHalf:a=!0,readonly:n=!1,size:o="md",tone:l="warning",label:c,loading:m=!1,haptic:u,labels:d,accessibilityLabel:p,style:g,containerStyle:y,starContainerStyle:f,testID:h}=e;assertValidValue("Rating","size",e.size,RATING_SIZES),assertValidValue("Rating","tone",e.tone,RATING_TONES);const x=useMemo(()=>({...DEFAULT_RATING_LABELS,...d}),[d]),S=useTheme(),b=useMemo(()=>buildStyles(S),[S]),v=!n&&"function"==typeof i,w=a?.5:1,R=resolveSize(o),j=toneColorFor(S,l),_=S.colors.border,A=useRef(R),k=useCallback(e=>{A.current=e.nativeEvent.layout.width},[]),T=useRef(new Map),V=useMemo(()=>{const e=T.current,t=[];for(let s=0;s<r;s+=1){let i=e.get(s);i||(i=new Animated.Value(1),e.set(s,i)),t.push(i)}for(const t of Array.from(e.keys()))t>=r&&e.delete(t);return t},[r]),C=S.settings.components.rating?.pulseOnPress??!1,E=useCallback(e=>{const t=V[e];if(!t)throw new Error(`Rating has no star at index ${e}; the pulse index must be below max.`);Animated.sequence([Animated.timing(t,{toValue:1.2,duration:S.motion.duration.fast,easing:Easing.bezier(...S.motion.ease["in-out"]),useNativeDriver:nativeDriver}),Animated.spring(t,{toValue:1,damping:S.motion.spring.bouncy.damping,stiffness:S.motion.spring.bouncy.stiffness,mass:S.motion.spring.bouncy.mass,useNativeDriver:nativeDriver})]).start()},[S.motion,V]),M=useCallback((e,t)=>{if(!v||!i)return;const s=clampToStep(e,r,w),a=resolveHaptic(u,"selection");a&&triggerHaptic(a),C&&"number"==typeof t&&E(t),i(s)},[v,i,r,w,E,u,C]),z=useCallback(e=>t=>{if(!v)return;const s=A.current||R,i=t.nativeEvent.locationX??s;let r;r=a&&i<s/2?e+.5:e+1,M(r,e)},[v,R,a,M]),N=useCallback(e=>{v&&("increment"===e.nativeEvent.actionName?M(s+w):"decrement"===e.nativeEvent.actionName&&M(s-w))},[v,s,w,M]),D=x.value(s,r),I=p??c??D,L=[];for(const[e,t]of V.entries()){const i=_jsx(Star,{index:e,filled:s,size:R,filledColor:j,emptyColor:_,scale:t},e);L.push(v?_jsx(Pressable,{onPress:z(e),onLayout:0===e?k:void 0,hitSlop:4,...hitSlopMarker(4),accessible:!1,style:b.starPress,children:i},e):_jsx(View,{onLayout:0===e?k:void 0,style:b.starPress,children:i},e))}const P=_jsxs(View,{style:[b.wrapper,y,g],ref:t,testID:h,children:[c?_jsx(Text,{variant:"bodySmall",color:"secondary",style:b.label,children:c}):null,_jsx(View,{style:[b.row,f],accessible:!0,accessibilityRole:v?"adjustable":"text",accessibilityLabel:I,accessibilityValue:v?{min:0,max:r,now:s,text:D}:void 0,accessibilityActions:v?[{name:"increment"},{name:"decrement"}]:void 0,onAccessibilityAction:v?N:void 0,children:L})]});return m?_jsx(RatingSkeleton,{...e}):P});RatingRoot.displayName="Rating";const RatingSkeleton=({max:e=5,size:t="md",label:s,containerStyle:i,starContainerStyle:r,style:a})=>{const n=useTheme(),o=resolveSize(t),l=Math.max(1,e);return _jsxs(View,{style:[{alignItems:"flex-start"},i,a],accessibilityRole:"progressbar",accessibilityState:{busy:!0},"aria-busy":!0,children:[void 0!==s?_jsx(Skeleton,{shape:"text",width:80,height:14,style:{marginBottom:n.space.xs}}):null,_jsx(View,{style:[{flexDirection:"row"},r],children:Array.from({length:l}).map((e,t)=>_jsx(Skeleton,{width:o,height:o,radius:Math.round(.25*o),style:t<l-1?{marginRight:n.space.xs}:void 0},`sk-star-${t}`))})]})};RatingSkeleton.displayName="RatingSkeleton";const Rating=Object.assign(RatingRoot,{Skeleton:RatingSkeleton}),starStyles=StyleSheet.create({starWrap:{position:"relative",alignItems:"flex-start",justifyContent:"center"},glyph:{textAlign:"left",includeFontPadding:!1},fillClip:{position:"absolute",top:0,left:0,overflow:"hidden"}}),buildStyles=e=>StyleSheet.create({wrapper:{flexDirection:"column"},row:{flexDirection:"row",alignItems:"center"},starPress:{marginRight:e.space.xs},label:{marginBottom:e.space.xs}});export{Rating};export default Rating;
@@ -1 +1 @@
1
- "use strict";import{useCallback,useMemo,useRef}from"react";import{StyleSheet,View}from"react-native";import{useTheme}from"../../theme/index.js";import{resolveHaptic,triggerHaptic}from"../../utils/index.js";import{AppIcon}from"../AppIcon/index.js";import{Button}from"../Button/index.js";import{IconButton}from"../IconButton/index.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";let rowIdCounter=0;const nextRowId=()=>(rowIdCounter+=1,`row-${rowIdCounter}`);export const DEFAULT_REPEATER_LABELS=Object.freeze({add:"Add another",empty:"",row:null,removeRow:e=>`Remove ${e}`,fallbackRow:e=>`row ${e+1}`});export const Repeater=({value:e,onChange:t,createRow:r,renderRow:o,labels:n,renderRowHeader:s,onRemove:l,minRows:i=0,maxRows:a,removable:c=!0,disabled:m=!1,haptic:u,style:p,testID:d})=>{const x=useTheme(),h=useMemo(()=>({...DEFAULT_REPEATER_LABELS,...n}),[n]),w=useRef([]);if(w.current.length<e.length)for(;w.current.length<e.length;)w.current.push(nextRowId());else w.current.length>e.length&&(w.current.length=e.length);const g="number"==typeof a&&e.length>=a,f=c&&e.length>i,j=useCallback(e=>{const t=resolveHaptic(u,e);t&&triggerHaptic(t)},[u]),R=useCallback(()=>{m||g||(t([...e,r()]),j("impactLight"))},[g,r,m,j,t,e]),v=useCallback((r,o)=>{t(e.map((e,t)=>t===r?o:e))},[t,e]),b=useCallback(r=>{!m&&f&&(w.current=w.current.filter((e,t)=>t!==r),l?.(r,e[r]),t(e.filter((e,t)=>t!==r)),j("notificationWarning"))},[f,m,j,t,l,e]);return _jsxs(View,{style:[{gap:x.space.md},p],testID:d,children:[0===e.length&&h.empty.length>0?_jsx(Text,{variant:"bodySmall",color:"tertiary",children:h.empty}):null,e.map((e,t)=>{const r={item:e,index:t,update:e=>v(t,e),remove:()=>b(t),canRemove:f};return _jsxs(View,{style:{gap:x.space.xs},children:[s?s(r):h.row||f&&!m?_jsxs(View,{style:styles.rowHeader,children:[h.row?_jsx(Text,{variant:"overline",color:"tertiary",children:h.row(t)}):_jsx(View,{}),f&&!m?_jsx(IconButton,{icon:({color:e,size:t})=>_jsx(AppIcon,{name:"x",size:t,color:e}),onPress:()=>b(t),accessibilityLabel:h.removeRow(h.row?h.row(t):h.fallbackRow(t)),size:"sm",tone:"danger",variant:"ghost",haptic:u,testID:d?`${d}-remove-${t}`:void 0}):null]}):null,o(r)]},w.current[t])}),g||m?null:_jsx(Button,{label:h.add,onPress:R,variant:"outline",size:"sm",haptic:u,testID:d?`${d}-add`:void 0})]})};const styles=StyleSheet.create({rowHeader:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",minHeight:24}});export default Repeater;
1
+ "use strict";import{useCallback,useMemo,useRef}from"react";import{StyleSheet,View}from"react-native";import{useTheme}from"../../theme/index.js";import{resolveHaptic,triggerHaptic}from"../../utils/index.js";import{AppIcon}from"../AppIcon/index.js";import{Button}from"../Button/index.js";import{IconButton}from"../IconButton/index.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";let rowIdCounter=0;const nextRowId=()=>(rowIdCounter+=1,`row-${rowIdCounter}`);export const DEFAULT_REPEATER_LABELS=Object.freeze({add:"Add another",empty:"",row:null,removeRow:e=>`Remove ${e}`,fallbackRow:e=>`row ${e+1}`});export const Repeater=({value:e,onChange:t,createRow:r,renderRow:o,labels:n,renderRowHeader:s,onRemove:i,minRows:a=0,maxRows:l,removable:c=!0,disabled:m=!1,haptic:u,style:p,testID:d})=>{const x=useTheme(),w=useMemo(()=>({...DEFAULT_REPEATER_LABELS,...n}),[n]),h=useRef([]);if(h.current.length<e.length)for(;h.current.length<e.length;)h.current.push(nextRowId());else h.current.length>e.length&&(h.current.length=e.length);const f="number"==typeof l&&e.length>=l,g=c&&e.length>a,R=useCallback(e=>{const t=resolveHaptic(u,e);t&&triggerHaptic(t)},[u]),j=useCallback(()=>{m||f||(t([...e,r()]),R("impactLight"))},[f,r,m,R,t,e]),v=useCallback((r,o)=>{t(e.map((e,t)=>t===r?o:e))},[t,e]),b=useCallback(r=>{if(m||!g)return;const o=e[r];if(void 0===o)throw new Error(`Repeater: no row at index ${r} to remove.`);h.current=h.current.filter((e,t)=>t!==r),i?.(r,o),t(e.filter((e,t)=>t!==r)),R("notificationWarning")},[g,m,R,t,i,e]);return _jsxs(View,{style:[{gap:x.space.md},p],testID:d,children:[0===e.length&&w.empty.length>0?_jsx(Text,{variant:"bodySmall",color:"tertiary",children:w.empty}):null,e.map((e,t)=>{const r={item:e,index:t,update:e=>v(t,e),remove:()=>b(t),canRemove:g};return _jsxs(View,{style:{gap:x.space.xs},children:[s?s(r):w.row||g&&!m?_jsxs(View,{style:styles.rowHeader,children:[w.row?_jsx(Text,{variant:"overline",color:"tertiary",children:w.row(t)}):_jsx(View,{}),g&&!m?_jsx(IconButton,{icon:({color:e,size:t})=>_jsx(AppIcon,{name:"x",size:t,color:e}),onPress:()=>b(t),accessibilityLabel:w.removeRow(w.row?w.row(t):w.fallbackRow(t)),size:"sm",tone:"danger",variant:"ghost",haptic:u,testID:d?`${d}-remove-${t}`:void 0}):null]}):null,o(r)]},h.current[t])}),f||m?null:_jsx(Button,{label:w.add,onPress:j,variant:"outline",size:"sm",haptic:u,testID:d?`${d}-add`:void 0})]})};const styles=StyleSheet.create({rowHeader:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",minHeight:24}});export default Repeater;
@@ -1 +1 @@
1
- "use strict";import{cloneElement,createElement,isValidElement,useCallback,useEffect,useMemo,useRef,useState}from"react";import{Animated,BackHandler,FlatList,StyleSheet,View}from"react-native";import{KeyboardStickyView}from"react-native-keyboard-controller";import{useSharedValue}from"react-native-reanimated";import{useSafeAreaInsets}from"react-native-safe-area-context";import{useRefreshControl}from"../../hooks/useRefreshControl.js";import{resolveFloatingActionButtonSize,useTheme}from"../../theme/index.js";import{AppBar}from"../AppBar/index.js";import{AsyncBlock}from"../AsyncBlock/index.js";import{EmptyState}from"../EmptyState/index.js";import{KeyboardAwareScrollView}from"../KeyboardAwareScrollView/index.js";import{KeyboardToolbar}from"../KeyboardToolbar/index.js";import{PagedListFooter}from"../PagedListFooter/index.js";import{ScrollHostContext}from"./ScrollHost.js";import{jsx as _jsx,Fragment as _Fragment,jsxs as _jsxs}from"react/jsx-runtime";const DEFAULT_EDGES=["top","bottom"],SCROLL_EVENT_THROTTLE=16,noop=()=>{};function renderFooter(e){return isValidElement(e)?e:e?createElement(e):null}const topPaddingOf=e=>{const t=StyleSheet.flatten(e),o=t?.paddingTop??t?.paddingVertical??t?.padding;return"number"==typeof o?o:0},buildStyles=e=>StyleSheet.create({flex:{flex:1},root:{flex:1,backgroundColor:e.colors.bg},overlay:{position:"absolute",top:0,left:0,right:0},headerRaised:{zIndex:1},footer:{backgroundColor:e.colors.bg,borderTopWidth:StyleSheet.hairlineWidth,borderTopColor:e.colors.border}});export function Screen(e){const{title:t,subtitle:o,largeTitle:n=!0,headerShadowOnScroll:r,onBack:l,rightActions:a,leading:s,trailing:i,children:d,onRefresh:c,refreshing:u=!1,footer:f,scroll:m=!0,list:p,edges:h=DEFAULT_EDGES,keyboardToolbar:g=!0,bottomInset:y=0,gutter:S,floatingAction:v,scrollRef:b,onScroll:x,contentContainerStyle:E,testID:C}=e,T=useTheme(),j=S??void 0===p,R=T.space[T.components.screen.gutter],k=j?R:0,L=useSafeAreaInsets(),_=useMemo(()=>buildStyles(T),[T]),[A]=useState(()=>new Animated.Value(0)),[V,w]=useState(0),[F,B]=useState(0),O=void 0!==l,M=useRef(l);M.current=l;const P=Boolean(t||o||l||s||i||a?.length),z=n&&void 0!==t,H=z&&(void 0!==p||m),K=H?V:0,D=P&&!H&&(r??T.settings.components.screen?.headerShadowOnScroll??!0),[I,N]=useState(!1),W=useRef(D);W.current=D;const headerGap=e=>e>0?e:P?T.space.lg:0,G=void 0!==f,{refreshControl:U}=useRefreshControl({onRefresh:c??noop,refreshing:u}),Y=c?cloneElement(U,{progressViewOffset:K}):void 0,q=useSharedValue(0),J=useSharedValue(0),Q=useSharedValue(0),X=useSharedValue(0),Z=useRef(null),$=useRef(0),ee=useRef(0),te=useMemo(()=>({top:q,bottom:J,offset:Q,maxOffset:X,scrollTo:e=>{const t=Z.current;t instanceof FlatList?t.scrollToOffset({offset:e,animated:!1}):t?.scrollTo({y:e,animated:!1})}}),[q,J,Q,X]),oe=useCallback(e=>{Z.current=e,"function"==typeof b?b(e):b&&(b.current=e)},[b]),ne=useCallback(()=>{X.value=Math.max(0,$.current-ee.current)},[X]),re=useRef(x);re.current=x;const le=useMemo(()=>Animated.event([{nativeEvent:{contentOffset:{y:A}}}],{useNativeDriver:!1,listener:e=>{if(Q.value=e.nativeEvent.contentOffset.y,W.current){const t=e.nativeEvent.contentOffset.y>0;N(e=>e===t?e:t)}re.current?.(e)}}),[A,Q]),ae=useCallback(e=>{const{height:t}=e.nativeEvent.layout;w(e=>Math.max(e,t))},[]),se=useCallback(e=>{B(e.nativeEvent.layout.height)},[]);useEffect(()=>{if(!O)return;const e=BackHandler.addEventListener("hardwareBackPress",()=>(M.current?.(),!0));return()=>e.remove()},[O]);const ie=h.includes("left")?L.left:0,de=h.includes("right")?L.right:0,ce=h.includes("bottom")?L.bottom:0,ue=h.includes("top")&&!P?L.top:0,fe=T.space[T.components["floating-action-button"]["bottom-offset"]],me=v?.props.bottomOffset??fe,pe=v?resolveFloatingActionButtonSize(T,v.props.size??"md").diameter+me+T.space.lg:0,he=G?Math.max(0,F-L.bottom):y,ge=v?cloneElement(v,{bottomOffset:me+he,position:v.props.position??"bottomRight"}):null,ye=G?pe:Math.max(ce,v?pe+L.bottom:0),Se=y+ye-(G?0:ce),ve=h.filter(e=>"top"!==e&&!("bottom"===e&&G)),be=P?_jsx(View,{style:H?_.overlay:D?_.headerRaised:void 0,onLayout:H?ae:void 0,children:_jsx(AppBar,{title:t,subtitle:o,variant:z?"large":"default",scrollY:H?A:void 0,elevated:D&&I,onBack:l,rightActions:a,leading:s,trailing:i,gutter:R})}):null,xe=useCallback(()=>{const e=Z.current?.getNativeScrollRef();e&&e.measureInWindow((e,t,o,n)=>{ee.current=n,q.value=t+K,J.value=t+n,ne()})},[K,q,J,ne]);useEffect(()=>{xe()},[xe]);const Ee=useCallback((e,t)=>{$.current=t,ne()},[ne]);let Ce;if(void 0!==p){const{state:e,paging:t,...o}=p,n=topPaddingOf([o.contentContainerStyle,E]),handleEndReached=e=>{t?.hasMore&&!t.loadingMore&&null==t.errorMore&&t.loadMore(),o.onEndReached?.(e)},r=_jsx(FlatList,{keyboardShouldPersistTaps:"handled",onEndReachedThreshold:t?.5:void 0,...o,ref:oe,refreshControl:Y,onScroll:le,onLayout:e=>{xe(),o.onLayout?.(e)},onContentSizeChange:(e,t)=>{Ee(e,t),o.onContentSizeChange?.(e,t)},onEndReached:t?handleEndReached:o.onEndReached,ListEmptyComponent:e?.empty?_jsx(EmptyState,{...e.empty}):void 0,ListFooterComponent:t||o.ListFooterComponent?_jsxs(_Fragment,{children:[renderFooter(o.ListFooterComponent),t?_jsx(PagedListFooter,{paging:t}):null]}):void 0,scrollEventThrottle:16,style:_.flex,contentContainerStyle:[{paddingTop:K,paddingLeft:ie+k,paddingRight:de+k},{paddingBottom:y+ye},o.contentContainerStyle,E,{paddingTop:K+headerGap(n)}]});Ce=_jsx(ScrollHostContext.Provider,{value:te,children:e?_jsx(AsyncBlock,{loading:e.loading,error:e.error,errorTitle:e.errorTitle,onRetry:e.onRetry,skeleton:e.skeleton,style:[_.flex,{paddingTop:K+headerGap(n)}],children:r}):r})}else Ce=m?_jsx(ScrollHostContext.Provider,{value:te,children:_jsxs(KeyboardAwareScrollView,{ref:oe,refreshControl:Y,onScroll:le,scrollEventThrottle:16,onLayout:xe,onContentSizeChange:Ee,safeAreaEdges:ve,style:_.flex,contentContainerStyle:[{paddingHorizontal:k},E,{paddingTop:K+headerGap(topPaddingOf(E))}],children:[d,Se>0?_jsx(View,{style:{height:Se}}):null]})}):_jsx(View,{style:[_.flex,{paddingLeft:ie+k,paddingRight:de+k,paddingBottom:y+ye},E],children:d});const Te=G?_jsx(KeyboardStickyView,{onLayout:se,style:[_.footer,{paddingLeft:ie+R,paddingRight:de+R,paddingBottom:ce+y}],children:f}):null;return _jsxs(View,{testID:C,style:[_.root,{paddingTop:ue}],children:[H?null:be,Ce,Te,ge,void 0!==p?d:null,H?be:null,g?_jsx(KeyboardToolbar,{}):null]})}
1
+ "use strict";import{cloneElement,isValidElement,useCallback,useEffect,useMemo,useRef,useState}from"react";import{Animated,BackHandler,FlatList,StyleSheet,View}from"react-native";import{KeyboardStickyView}from"react-native-keyboard-controller";import{useSharedValue}from"react-native-reanimated";import{useSafeAreaInsets}from"react-native-safe-area-context";import{useRefreshControl}from"../../hooks/useRefreshControl.js";import{resolveFloatingActionButtonSize,useTheme}from"../../theme/index.js";import{AppBar}from"../AppBar/index.js";import{AsyncBlock,DEFAULT_ASYNC_BLOCK_LABELS}from"../AsyncBlock/index.js";import{EmptyState}from"../EmptyState/index.js";import{KeyboardAwareScrollView}from"../KeyboardAwareScrollView/index.js";import{KeyboardToolbar}from"../KeyboardToolbar/index.js";import{PagedListFooter}from"../PagedListFooter/index.js";import{ScrollHostContext}from"./ScrollHost.js";import{jsx as _jsx,Fragment as _Fragment,jsxs as _jsxs}from"react/jsx-runtime";const DEFAULT_EDGES=["top","bottom"],SCROLL_EVENT_THROTTLE=16,noop=()=>{},isElementFooter=e=>isValidElement(e);function renderFooter(e){if(null==e)return null;if(isElementFooter(e))return e;return _jsx(e,{})}const topPaddingOf=e=>{const t=StyleSheet.flatten(e),o=t?.paddingTop??t?.paddingVertical??t?.padding;return"number"==typeof o?o:0},buildStyles=e=>StyleSheet.create({flex:{flex:1},root:{flex:1,backgroundColor:e.colors.bg},overlay:{position:"absolute",top:0,left:0,right:0},headerRaised:{zIndex:1},footer:{backgroundColor:e.colors.bg,borderTopWidth:StyleSheet.hairlineWidth,borderTopColor:e.colors.border}});export function Screen(e){const{title:t,subtitle:o,largeTitle:n=!0,headerShadowOnScroll:r,onBack:s,rightActions:a,leading:l,trailing:i,children:d,onRefresh:c,refreshing:u=!1,footer:f,scroll:m=!0,list:p,edges:h=DEFAULT_EDGES,keyboardToolbar:g=!0,bottomInset:S=0,gutter:y,floatingAction:v,scrollRef:b,onScroll:x,contentContainerStyle:E,testID:C}=e,T=useTheme(),L=y??void 0===p,j=T.space[T.components.screen.gutter],_=L?j:0,A=useSafeAreaInsets(),R=useMemo(()=>buildStyles(T),[T]),[k]=useState(()=>new Animated.Value(0)),[F,B]=useState(0),[V,w]=useState(0),O=void 0!==s,M=useRef(s);M.current=s;const K=Boolean(t||o||s||l||i||a?.length),P=n&&void 0!==t,D=P&&(void 0!==p||m),z=D?F:0,H=K&&!D&&(r??T.settings.components.screen?.headerShadowOnScroll??!0),[I,N]=useState(!1),U=useRef(H);U.current=H;const headerGap=e=>e>0?e:K?T.space.lg:0,G=void 0!==f,W=p?.state,Y="data"===W?.status||"empty"===W?.status?W:void 0,{refreshControl:q}=useRefreshControl({onRefresh:Y?Y.refresh:c??noop,refreshing:Y?Y.refreshing:u}),J=c||Y?cloneElement(q,{progressViewOffset:z}):void 0,Q=useSharedValue(0),X=useSharedValue(0),Z=useSharedValue(0),$=useSharedValue(0),ee=useRef(null),te=useRef(0),oe=useRef(0),ne=useMemo(()=>({top:Q,bottom:X,offset:Z,maxOffset:$,scrollTo:e=>{const t=ee.current;t instanceof FlatList?t.scrollToOffset({offset:e,animated:!1}):t?.scrollTo({y:e,animated:!1})}}),[Q,X,Z,$]),re=useCallback(e=>{ee.current=e,"function"==typeof b?b(e):b&&(b.current=e)},[b]),se=useCallback(()=>{$.value=Math.max(0,te.current-oe.current)},[$]),ae=useRef(x);ae.current=x;const le=useMemo(()=>Animated.event([{nativeEvent:{contentOffset:{y:k}}}],{useNativeDriver:!1,listener:e=>{if(Z.value=e.nativeEvent.contentOffset.y,U.current){const t=e.nativeEvent.contentOffset.y>0;N(e=>e===t?e:t)}ae.current?.(e)}}),[k,Z]),ie=useCallback(e=>{const{height:t}=e.nativeEvent.layout;B(e=>Math.max(e,t))},[]),de=useCallback(e=>{w(e.nativeEvent.layout.height)},[]);useEffect(()=>{if(!O)return;const e=BackHandler.addEventListener("hardwareBackPress",()=>(M.current?.(),!0));return()=>e.remove()},[O]);const ce=h.includes("left")?A.left:0,ue=h.includes("right")?A.right:0,fe=h.includes("bottom")?A.bottom:0,me=h.includes("top")&&!K?A.top:0,pe=T.space[T.components["floating-action-button"]["bottom-offset"]],he=v?.props.bottomOffset??pe,ge=v?resolveFloatingActionButtonSize(T,v.props.size??"md").diameter+he+T.space.lg:0,Se=G?Math.max(0,V-A.bottom):S,ye=v?cloneElement(v,{bottomOffset:he+Se,position:v.props.position??"bottomRight"}):null,ve=G?ge:Math.max(fe,v?ge+A.bottom:0),be=S+ve-(G?0:fe),xe=h.filter(e=>"top"!==e&&!("bottom"===e&&G)),Ee=K?_jsx(View,{style:D?R.overlay:H?R.headerRaised:void 0,onLayout:D?ie:void 0,children:_jsx(AppBar,{title:t,subtitle:o,variant:P?"large":"default",scrollY:D?k:void 0,elevated:H&&I,onBack:s,rightActions:a,leading:l,trailing:i,gutter:j})}):null,Ce=useCallback(()=>{const e=ee.current?.getNativeScrollRef();e&&e.measureInWindow((e,t,o,n)=>{oe.current=n,Q.value=t+z,X.value=t+n,se()})},[z,Q,X,se]);useEffect(()=>{Ce()},[Ce]);const Te=useCallback((e,t)=>{te.current=t,se()},[se]);let Le;if(void 0!==p){const{state:e,paging:t,empty:o,skeleton:n,errorTitle:r,data:s,...a}=p,l=topPaddingOf([a.contentContainerStyle,E]),handleEndReached=e=>{t?.hasMore&&!t.loadingMore&&null==t.errorMore&&t.loadMore(),a.onEndReached?.(e)},renderList=(e,o)=>_jsx(FlatList,{data:e,keyboardShouldPersistTaps:"handled",onEndReachedThreshold:t?.5:void 0,...a,ref:re,refreshControl:J,onScroll:le,onLayout:e=>{Ce(),a.onLayout?.(e)},onContentSizeChange:(e,t)=>{Te(e,t),a.onContentSizeChange?.(e,t)},onEndReached:t?handleEndReached:a.onEndReached,ListEmptyComponent:o,ListFooterComponent:t||a.ListFooterComponent?_jsxs(_Fragment,{children:[renderFooter(a.ListFooterComponent),t?_jsx(PagedListFooter,{paging:t}):null]}):void 0,scrollEventThrottle:16,style:R.flex,contentContainerStyle:[{paddingTop:z,paddingLeft:ce+_,paddingRight:ue+_},{paddingBottom:S+ve},a.contentContainerStyle,E,o?{flexGrow:1}:void 0,{paddingTop:z+headerGap(l)}]});Le=_jsx(ScrollHostContext.Provider,{value:ne,children:"empty"===e?.status?renderList([],_jsx(EmptyState,{...o??{title:DEFAULT_ASYNC_BLOCK_LABELS.emptyTitle}})):e?_jsx(AsyncBlock,{state:e,skeleton:n,errorTitle:r,style:[R.flex,{paddingTop:z+headerGap(l)}],children:e=>renderList(e,void 0)}):renderList(s,o?_jsx(EmptyState,{...o}):void 0)})}else Le=m?_jsx(ScrollHostContext.Provider,{value:ne,children:_jsxs(KeyboardAwareScrollView,{ref:re,refreshControl:J,onScroll:le,scrollEventThrottle:16,onLayout:Ce,onContentSizeChange:Te,safeAreaEdges:xe,style:R.flex,contentContainerStyle:[{paddingHorizontal:_},E,{paddingTop:z+headerGap(topPaddingOf(E))}],children:[d,be>0?_jsx(View,{style:{height:be}}):null]})}):_jsx(View,{style:[R.flex,{paddingLeft:ce+_,paddingRight:ue+_,paddingBottom:S+ve},E],children:d});const je=G?_jsx(KeyboardStickyView,{onLayout:de,style:[R.footer,{paddingLeft:ce+j,paddingRight:ue+j,paddingBottom:fe+S}],children:f}):null;return _jsxs(View,{testID:C,style:[R.root,{paddingTop:me}],children:[D?null:Ee,Le,je,ye,void 0!==p?d:null,D?Ee:null,g?_jsx(KeyboardToolbar,{}):null]})}
@@ -1 +1 @@
1
- "use strict";import{Storage}from"@webority/mobile-core";import{useCallback,useEffect,useRef,useState}from"react";const DEFAULT_MAX=8,isStringList=e=>Array.isArray(e)&&e.every(e=>"string"==typeof e);export const useRecentSearches=(e,r)=>{const t=r?.max??8,[s,c]=useState([]),n=useRef([]),u=useRef(!1);useEffect(()=>{let r=!1;return u.current=!1,n.current=[],c([]),Storage.getJson(e).then(e=>{if(r||u.current||!isStringList(e))return;const s=e.slice(0,t);n.current=s,c(s)}),()=>{r=!0}},[e]);const a=useCallback(r=>{u.current=!0,n.current=r,c(r),Storage.setJson(e,r)},[e]);return{recents:s,add:useCallback(e=>{const r=e.trim();if(!r)return;const s=r.toLowerCase(),c=n.current.filter(e=>e.toLowerCase()!==s);a([r,...c].slice(0,t))},[a,t]),remove:useCallback(e=>{a(n.current.filter(r=>r!==e))},[a]),clear:useCallback(()=>{const e=n.current;return a([]),e},[a]),replace:useCallback(e=>{a(e.slice(0,t))},[a,t])}};
1
+ "use strict";import{Storage}from"@webority/mobile-core";import{useCallback,useEffect,useRef,useState}from"react";const DEFAULT_MAX=8,isStringList=e=>Array.isArray(e)&&e.every(e=>"string"==typeof e),parseStringList=e=>isStringList(e)?e:null;export const useRecentSearches=(e,r)=>{const t=r?.max??8,[s,c]=useState([]),n=useRef([]),u=useRef(!1);useEffect(()=>{let r=!1;return u.current=!1,n.current=[],c([]),Storage.getJson(e,parseStringList).then(e=>{if(r||u.current||null===e)return;const s=e.slice(0,t);n.current=s,c(s)}),()=>{r=!0}},[e]);const a=useCallback(r=>{u.current=!0,n.current=r,c(r),Storage.setJson(e,r)},[e]);return{recents:s,add:useCallback(e=>{const r=e.trim();if(!r)return;const s=r.toLowerCase(),c=n.current.filter(e=>e.toLowerCase()!==s);a([r,...c].slice(0,t))},[a,t]),remove:useCallback(e=>{a(n.current.filter(r=>r!==e))},[a]),clear:useCallback(()=>{const e=n.current;return a([]),e},[a]),replace:useCallback(e=>{a(e.slice(0,t))},[a,t])}};
@@ -1 +1 @@
1
- "use strict";import{forwardRef,useCallback,useEffect,useMemo,useRef,useState}from"react";import{Animated,Pressable,StyleSheet,View}from"react-native";import{useControllableState}from"../../hooks/index.js";import{createAnimatedValue,resolveSegmentedControlSize,useTheme}from"../../theme/index.js";import{resolveHaptic,triggerHaptic}from"../../utils/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{smoothCorners}from"../../utils/corners.js";import{nativeDriver}from"../../utils/nativeDriver.js";import{renderSlotIcon}from"../AppIcon/slotIcon.js";import{FieldLabel,FieldMessage,hasFieldText}from"../FieldBase/index.js";import{SquircleFill,useSquircle}from"../SquircleFill/SquircleFill.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const LABEL_LINE_HEIGHT_RATIO=1.25,activeInkFor=(e,t)=>{switch(t){case"primary":return e.colors.primary;case"neutral":return e.colors["text-body"];case"success":return e.colors["success-text"];case"warning":return e.colors["warning-text"];case"danger":return e.colors["danger-text"];case"info":return e.colors["info-text"]}},SegmentedControl=forwardRef((e,t)=>{const{segments:r,label:i,helperText:s,error:l,value:o,defaultValue:n,onChange:a,size:d="md",fullWidth:c=!0,disabled:u=!1,tone:m="primary",variant:h="segmented",radius:g,labelLines:p=1,haptic:f,accessibilityLabel:b,style:x,containerStyle:y,segmentStyle:S,selectedIndicatorStyle:v,textStyle:w,labelStyle:C,testID:j}=e;assertValidValue("SegmentedControl","size",e.size,["sm","md","lg"]),assertValidValue("SegmentedControl","tone",e.tone,["primary","success","warning","danger","info","neutral"]),assertValidValue("SegmentedControl","variant",e.variant,["underline","pills","segmented"]);const[V]=r;if(void 0===V)throw new Error("SegmentedControl needs at least one segment");const[k,F]=useControllableState({value:o,defaultValue:n??V.value,onChange:a}),I=useTheme(),L=I.components["segmented-control"],_=useMemo(()=>buildStyles(I),[I]),z=useMemo(()=>resolveSegmentedControlSize(I,d),[I,d]),M=p>=2?2:1,R=M>1,T="segmented"===h,E="underline"===h,A="pills"===h,D=T?I.space[L["track-padding"]]:0,H=Math.ceil(1.25*z.text)*(M-1),q=L["underline-height"],B=I.space[L["pill-inset"]],W="number"==typeof g?g:g?I.radius[g]:void 0,P=W??I.radius.md,N=void 0===W?I.radius.sm:Math.max(W-D,0),G=W??I.radius.pill,O=W??I.radius.none,[X,J]=useState([]),K=useRef(createAnimatedValue(0)).current,Q=Math.max(0,r.findIndex(e=>e.value===k)),U=X[Q],Y=U?.x,Z=useCallback(e=>{const t=I.motion.spring.snappy,r=Animated.spring(K,{toValue:e,damping:t.damping,stiffness:t.stiffness,mass:t.mass,overshootClamping:!0,useNativeDriver:nativeDriver});return r.start(),r},[I.motion.spring.snappy,K]);useEffect(()=>{J(e=>e.length===r.length||0===e.length?e:[])},[r.length]);const $=useRef(null);useEffect(()=>{if(void 0===Y)return;const e=null!==$.current&&$.current!==Q;if($.current=Q,!e)return void K.setValue(Y);const t=Z(Y);return()=>t.stop()},[Q,Y,Z,K]);const ee=useCallback((e,t)=>{const{x:r,width:i}=t.nativeEvent.layout;J(t=>{const s=t[e];if(s&&s.x===r&&s.width===i)return t;const l=t.slice();return l[e]={x:r,width:i},l})},[]),te=useCallback(e=>{if(u)return;if(e.value===k)return;const t=resolveHaptic(f,"selection");t&&triggerHaptic(t),F(e.value)},[u,F,k,f]),re=T?I.colors.thumb:A?I.colors["primary-soft"]:I.colors.primary,ie=T?N:A?G:O,se=activeInkFor(I,m),le=I.colors["bg-muted"],oe=useSquircle(T,P),ne=!0===l||hasFieldText(l),ae=ne&&!u,de=I.colors["field-border-error"],ce=I.size.border,ue=hasFieldText(i),me=ne?l:s,he=hasFieldText(me),ge=_jsxs(View,{ref:t,accessibilityRole:"radiogroup",accessibilityLabel:b??("string"==typeof i?i:void 0),testID:j,style:[_.track,{...R?{minHeight:z.height+H}:{height:z.height},opacity:u?.55:1,alignSelf:c?"stretch":"flex-start"},T?{borderRadius:P,...smoothCorners,backgroundColor:oe.active?"transparent":le,padding:D}:E?{borderBottomColor:ae?de:I.colors["border-subtle"],borderBottomWidth:StyleSheet.hairlineWidth}:null,y,x],onLayout:oe.onLayout,children:[oe.active&&oe.size?_jsx(SquircleFill,{width:oe.size.width,height:oe.size.height,radius:P,fill:le,stroke:ae?de:void 0,strokeWidth:ce}):null,_jsxs(View,{style:_.row,children:[U?_jsx(Animated.View,{pointerEvents:"none",style:[_.thumb,T?R?{top:0,bottom:0}:{top:0,height:z.height-2*D}:A?{top:B,bottom:B,left:B}:{bottom:0,height:q},{width:A?Math.max(U.width-2*B,0):U.width,borderRadius:ie,...smoothCorners,backgroundColor:re,transform:[{translateX:K}]},v]}):null,r.map((e,t)=>{const r=e.value===k,i=r?se:I.colors["text-subtle"],s=renderSlotIcon(e.icon,{color:i,size:z.icon,selected:r,disabled:u});return _jsxs(Pressable,{onPress:()=>te(e),onLayout:e=>ee(t,e),disabled:u,accessibilityRole:"radio",accessibilityLabel:e.label,accessibilityState:{checked:r,selected:r,disabled:u},"aria-checked":r,"aria-disabled":u,style:({pressed:e})=>[_.segment,R?_.segmentMultiline:null,{paddingHorizontal:z["padding-x"],opacity:e&&!r?.7:1},S],children:[s?_jsx(View,{style:_.segmentIcon,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:s}):null,_jsx(Text,{variant:"label",weight:r?"semibold":"medium",style:[_.segmentLabel,R?_.segmentLabelMultiline:null,{color:i,fontSize:z.text},w,C],numberOfLines:M,children:e.label})]},String(e.value))})]}),!ae||E||oe.active?null:_jsx(View,{pointerEvents:"none",style:[StyleSheet.absoluteFill,{borderWidth:ce,borderColor:de,borderRadius:T?P:G,...smoothCorners}]})]});return ue||he?_jsxs(View,{style:{alignSelf:c?"stretch":"flex-start"},children:[ue?_jsx(FieldLabel,{size:d,children:i}):null,ge,he?_jsx(FieldMessage,{size:d,text:me,error:ne}):null]}):ge});SegmentedControl.displayName="SegmentedControl";const buildStyles=e=>StyleSheet.create({track:{flexDirection:"row",alignItems:"stretch",position:"relative"},row:{flex:1,flexDirection:"row",alignItems:"stretch",position:"relative",overflow:"hidden"},thumb:{position:"absolute",left:0},segment:{flexGrow:1,flexShrink:1,flexBasis:"auto",flexDirection:"row",alignItems:"center",justifyContent:"center"},segmentIcon:{marginRight:e.space.xs},segmentMultiline:{paddingVertical:e.space.xs},segmentLabel:{includeFontPadding:!1},segmentLabelMultiline:{flexShrink:1,textAlign:"center"}});export{SegmentedControl};export default SegmentedControl;
1
+ "use strict";import{forwardRef,useCallback,useEffect,useMemo,useRef,useState}from"react";import{Animated,Pressable,StyleSheet,View}from"react-native";import{useControllableState}from"../../hooks/index.js";import{createAnimatedValue,resolveSegmentedControlSize,useTheme}from"../../theme/index.js";import{resolveHaptic,triggerHaptic}from"../../utils/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{smoothCorners}from"../../utils/corners.js";import{nativeDriver}from"../../utils/nativeDriver.js";import{renderSlotIcon}from"../AppIcon/slotIcon.js";import{FieldLabel,FieldMessage,hasFieldText}from"../FieldBase/index.js";import{SquircleFill,useSquircle}from"../SquircleFill/SquircleFill.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const LABEL_LINE_HEIGHT_RATIO=1.25,activeInkFor=(e,t)=>{switch(t){case"primary":return e.colors.primary;case"neutral":return e.colors["text-body"];case"success":return e.colors["success-text"];case"warning":return e.colors["warning-text"];case"danger":return e.colors["danger-text"];case"info":return e.colors["info-text"]}},SegmentedControl=forwardRef((e,t)=>{const{segments:r,label:i,helperText:s,error:l,value:o,defaultValue:n,onChange:a,size:d="md",fullWidth:c=!0,disabled:u=!1,tone:m="primary",variant:h="segmented",radius:g,labelLines:p=1,haptic:f,accessibilityLabel:b,style:x,containerStyle:y,segmentStyle:S,selectedIndicatorStyle:v,textStyle:w,labelStyle:C,testID:j}=e;assertValidValue("SegmentedControl","size",e.size,["sm","md","lg"]),assertValidValue("SegmentedControl","tone",e.tone,["primary","success","warning","danger","info","neutral"]),assertValidValue("SegmentedControl","variant",e.variant,["underline","pills","segmented"]);const[V]=r;if(void 0===V)throw new Error("SegmentedControl needs at least one segment");const[k,F]=useControllableState({value:o,defaultValue:n??V.value,onChange:e=>{null!==e&&a?.(e)}}),I=useTheme(),L=I.components["segmented-control"],_=useMemo(()=>buildStyles(I),[I]),z=useMemo(()=>resolveSegmentedControlSize(I,d),[I,d]),M=p>=2?2:1,R=M>1,T="segmented"===h,E="underline"===h,A="pills"===h,D=T?I.space[L["track-padding"]]:0,H=Math.ceil(1.25*z.text)*(M-1),q=L["underline-height"],B=I.space[L["pill-inset"]],W="number"==typeof g?g:g?I.radius[g]:void 0,P=W??I.radius.md,N=void 0===W?I.radius.sm:Math.max(W-D,0),G=W??I.radius.pill,O=W??I.radius.none,[X,J]=useState([]),K=useRef(createAnimatedValue(0)).current,Q=Math.max(0,r.findIndex(e=>e.value===k)),U=X[Q],Y=U?.x,Z=useCallback(e=>{const t=I.motion.spring.snappy,r=Animated.spring(K,{toValue:e,damping:t.damping,stiffness:t.stiffness,mass:t.mass,overshootClamping:!0,useNativeDriver:nativeDriver});return r.start(),r},[I.motion.spring.snappy,K]);useEffect(()=>{J(e=>e.length===r.length||0===e.length?e:[])},[r.length]);const $=useRef(null);useEffect(()=>{if(void 0===Y)return;const e=null!==$.current&&$.current!==Q;if($.current=Q,!e)return void K.setValue(Y);const t=Z(Y);return()=>t.stop()},[Q,Y,Z,K]);const ee=useCallback((e,t)=>{const{x:r,width:i}=t.nativeEvent.layout;J(t=>{const s=t[e];if(s&&s.x===r&&s.width===i)return t;const l=t.slice();return l[e]={x:r,width:i},l})},[]),te=useCallback(e=>{if(u)return;if(e.value===k)return;const t=resolveHaptic(f,"selection");t&&triggerHaptic(t),F(e.value)},[u,F,k,f]),re=T?I.colors.thumb:A?I.colors["primary-soft"]:I.colors.primary,ie=T?N:A?G:O,se=activeInkFor(I,m),le=I.colors["bg-muted"],oe=useSquircle(T,P),ne=!0===l||hasFieldText(l),ae=ne&&!u,de=I.colors["field-border-error"],ce=I.size.border,ue=hasFieldText(i),me=ne?l:s,he=hasFieldText(me),ge=_jsxs(View,{ref:t,accessibilityRole:"radiogroup",accessibilityLabel:b??("string"==typeof i?i:void 0),testID:j,style:[_.track,{...R?{minHeight:z.height+H}:{height:z.height},opacity:u?.55:1,alignSelf:c?"stretch":"flex-start"},T?{borderRadius:P,...smoothCorners,backgroundColor:oe.active?"transparent":le,padding:D}:E?{borderBottomColor:ae?de:I.colors["border-subtle"],borderBottomWidth:StyleSheet.hairlineWidth}:null,y,x],onLayout:oe.onLayout,children:[oe.active&&oe.size?_jsx(SquircleFill,{width:oe.size.width,height:oe.size.height,radius:P,fill:le,stroke:ae?de:void 0,strokeWidth:ce}):null,_jsxs(View,{style:_.row,children:[U?_jsx(Animated.View,{pointerEvents:"none",style:[_.thumb,T?R?{top:0,bottom:0}:{top:0,height:z.height-2*D}:A?{top:B,bottom:B,left:B}:{bottom:0,height:q},{width:A?Math.max(U.width-2*B,0):U.width,borderRadius:ie,...smoothCorners,backgroundColor:re,transform:[{translateX:K}]},v]}):null,r.map((e,t)=>{const r=e.value===k,i=r?se:I.colors["text-subtle"],s=renderSlotIcon(e.icon,{color:i,size:z.icon,selected:r,disabled:u});return _jsxs(Pressable,{onPress:()=>te(e),onLayout:e=>ee(t,e),disabled:u,accessibilityRole:"radio",accessibilityLabel:e.label,accessibilityState:{checked:r,selected:r,disabled:u},"aria-checked":r,"aria-disabled":u,style:({pressed:e})=>[_.segment,R?_.segmentMultiline:null,{paddingHorizontal:z["padding-x"],opacity:e&&!r?.7:1},S],children:[s?_jsx(View,{style:_.segmentIcon,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:s}):null,_jsx(Text,{variant:"label",weight:r?"semibold":"medium",style:[_.segmentLabel,R?_.segmentLabelMultiline:null,{color:i,fontSize:z.text},w,C],numberOfLines:M,children:e.label})]},String(e.value))})]}),!ae||E||oe.active?null:_jsx(View,{pointerEvents:"none",style:[StyleSheet.absoluteFill,{borderWidth:ce,borderColor:de,borderRadius:T?P:G,...smoothCorners}]})]});return ue||he?_jsxs(View,{style:{alignSelf:c?"stretch":"flex-start"},children:[ue?_jsx(FieldLabel,{size:d,children:i}):null,ge,he?_jsx(FieldMessage,{size:d,text:me,error:ne}):null]}):ge});SegmentedControl.displayName="SegmentedControl";const buildStyles=e=>StyleSheet.create({track:{flexDirection:"row",alignItems:"stretch",position:"relative"},row:{flex:1,flexDirection:"row",alignItems:"stretch",position:"relative",overflow:"hidden"},thumb:{position:"absolute",left:0},segment:{flexGrow:1,flexShrink:1,flexBasis:"auto",flexDirection:"row",alignItems:"center",justifyContent:"center"},segmentIcon:{marginRight:e.space.xs},segmentMultiline:{paddingVertical:e.space.xs},segmentLabel:{includeFontPadding:!1},segmentLabelMultiline:{flexShrink:1,textAlign:"center"}});export{SegmentedControl};export default SegmentedControl;
@@ -1 +1 @@
1
- "use strict";import{forwardRef,useCallback,useMemo,useState}from"react";import{StyleSheet,View}from"react-native";import{resolveFieldSize,useTheme}from"../../theme/index.js";import{resolveHaptic,triggerHaptic}from"../../utils/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{renderSlotIcon,slotIconView}from"../AppIcon/slotIcon.js";import{Chevron}from"../FieldBase/Chevron.js";import{FieldBase,FieldLabel,FieldMessage,fieldTextAsString,hasFieldText,RequiredMark,resolveFieldTextStyle,resolveVariantColors}from"../FieldBase/FieldBase.js";import{DEFAULT_OPTION_SHEET_LABELS,OptionSheet}from"../OptionSheet/OptionSheet.js";import{Text}from"../Text/index.js";import{TextInkContext}from"../Text/textInk.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_SELECT_LABELS={placeholder:"Select…",noSelection:"No selection",selected:e=>`Selected: ${e}`,fallbackName:"Select",sheetName:"Options",searchPlaceholder:DEFAULT_OPTION_SHEET_LABELS.searchPlaceholder,empty:DEFAULT_OPTION_SHEET_LABELS.empty};const sameSelectValue=(e,t)=>String(e)===String(t),containsValue=(e,t)=>e.some(e=>sameSelectValue(e,t)),Select=forwardRef((e,t)=>{assertValidValue("Select","size",e.size,["sm","md","lg"]),assertValidValue("Select","variant",e.variant,["outline","filled","underline"]);const{options:l,getOptionLabel:i,getOptionValue:o,isOptionDisabled:s,getOptionDescription:r,getOptionIcon:n,placeholder:a,onOpenChange:c,searchable:d=!1,haptic:p,labels:u,label:h,help:x,title:S,required:m=!1,error:f,helperText:g,prefix:b,numberOfLines:y=1,disabled:v=!1,size:T="md",variant:C,leftIcon:L,rightIcon:j,chevronColor:_,chevronSize:O,radius:F,accessibilityLabel:V,labelStyle:E,style:I,triggerStyle:k,textStyle:z,optionStyle:A,selectedOptionStyle:H,optionTextStyle:P,selectedOptionTextStyle:D,testID:w}=e,B=!0===e.multi,N=u?{...DEFAULT_SELECT_LABELS,...u}:DEFAULT_SELECT_LABELS,M=useCallback(e=>i?i(e):e.label??"",[i]),R=useCallback(e=>o?o(e):e.value,[o]),U=useCallback(e=>s?s(e):!0===e.disabled,[s]),q=useCallback(e=>r?r(e):e.description,[r]),$=useCallback(e=>n?n(e):e.icon,[n]),G=useTheme(),J=useMemo(()=>buildStyles(G),[G]),K=resolveFieldSize(G,T),Q=resolveFieldTextStyle(G,{disabled:v}),W=C??G.settings.components.select?.defaultVariant??G.settings.components.field?.defaultVariant??"outline",[X,Y]=useState(!1),Z=useMemo(()=>{if(B){const t=e.value??[];return l.filter(e=>containsValue(t,R(e)))}const t=e.value;if(null==t)return[];const i=l.find(e=>sameSelectValue(R(e),t));return i?[i]:[]},[B,l,e.value,R]),ee=useCallback(()=>{if(v)return;const e=resolveHaptic(p,"selection");e&&triggerHaptic(e),Y(!0)},[v,p]),te=useCallback(()=>{Y(!1)},[]),le=useCallback(t=>{if(U(t))return;const l=R(t),i=resolveHaptic(p,"selection");if(i&&triggerHaptic(i),B){const t=e.value??[],i=containsValue(t,l)?t.filter(e=>!sameSelectValue(e,l)):[...t,l];return void e.onChange(i)}e.onChange(l),te()},[B,e,te,U,R,p]),ie=0===Z.length?a??N.placeholder:Z.map(e=>M(e)).join(", "),oe=0===Z.length,se=!0===f||hasFieldText(f),re=hasFieldText(h),ne=fieldTextAsString(h),ae=Math.round(1.4*K.text),ce=useMemo(()=>({fontSize:K.text,color:Q.placeholderColor}),[K.text,Q.placeholderColor]),de={color:v?G.colors["field-icon-disabled"]:X?G.colors["field-icon-focus"]:G.colors["field-icon"],size:K.icon,disabled:v,focused:X,error:se},pe=0===Z.length?a??N.noSelection:N.selected(Z.map(e=>M(e)).join(", ")),ue=V??`${ne??N.fallbackName}. ${pe}`;return _jsxs(View,{style:[J.container,I],testID:w,children:[re?_jsx(FieldLabel,{size:T,required:m,help:x,style:E,children:h}):null,_jsx(View,{ref:t,collapsable:!1,children:_jsxs(FieldBase,{size:T,variant:W,disabled:v,error:se,filled:Z.length>0,onPress:ee,radius:F,paddingHorizontal:"underline"===W?G.space.none:void 0,accessibilityRole:"button",accessibilityLabel:ue,accessibilityState:{disabled:v,expanded:X},"aria-disabled":v,"aria-expanded":X,style:k,slotAlign:1===y?"center":"top",slotLineHeight:1===y?void 0:ae,leading:L?slotIconView(L,renderSlotIcon(L,de)):null,trailing:j?slotIconView(j,renderSlotIcon(j,de)):_jsx(Chevron,{color:_??(v?G.colors["text-disabled"]:G.colors["text-subtle"]),size:O??K.icon,open:X,style:J.chevron}),children:[hasFieldText(b)?"string"==typeof b||"number"==typeof b?_jsx(Text,{variant:"body",style:[J.prefix,{color:Q.placeholderColor,fontSize:K.text,lineHeight:1===y?void 0:ae,marginRight:G.space.xs}],children:b}):_jsx(View,{style:[J.prefixNode,{minHeight:1===y?void 0:ae,justifyContent:"center",marginRight:G.space.xs}],children:_jsx(Text,{variant:"body",style:[J.prefix,{color:Q.placeholderColor,fontSize:K.text,lineHeight:1===y?void 0:ae}],children:_jsx(TextInkContext.Provider,{value:ce,children:b})})}):null,_jsxs(Text,{variant:"body",style:[J.triggerText,{color:oe?Q.placeholderColor:Q.color,fontSize:K.text,lineHeight:1===y?void 0:ae,...Q.weightStyle},z],numberOfLines:y,children:[ie,oe&&m&&!re?_jsx(RequiredMark,{}):null]})]})}),_jsx(FieldMessage,{size:T,error:se,text:se?f:g}),_jsx(OptionSheet,{open:X,onClose:te,onOpenChange:c,haptic:p,title:S??ne,accessibilityLabel:ne??(re?S:void 0)??a??N.sheetName,options:l,getOptionLabel:M,getOptionValue:R,isOptionDisabled:U,getOptionDescription:q,getOptionIcon:$,value:e.value,onChange:(e,t)=>le(t),multi:B,searchable:d,labels:{searchPlaceholder:N.searchPlaceholder,empty:N.empty},optionStyle:A,selectedOptionStyle:H,optionTextStyle:P,selectedOptionTextStyle:D,searchSelectionColor:resolveVariantColors(G,W).borderFocusedRepresentative})]})});Select.displayName="Select";const buildStyles=e=>StyleSheet.create({container:{width:"100%"},label:{includeFontPadding:!1},triggerText:{flex:1,includeFontPadding:!1},errorText:{includeFontPadding:!1},prefix:{flexShrink:0,includeFontPadding:!1},prefixNode:{flexShrink:0},chevron:{marginLeft:e.space.sm}});export{Select};export default Select;
1
+ "use strict";import{useCallback,useMemo,useState}from"react";import{StyleSheet,View}from"react-native";import{resolveFieldSize,useTheme}from"../../theme/index.js";import{resolveHaptic,triggerHaptic}from"../../utils/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{renderSlotIcon,slotIconView}from"../AppIcon/slotIcon.js";import{Chevron}from"../FieldBase/Chevron.js";import{FieldBase,FieldLabel,FieldMessage,fieldTextAsString,hasFieldText,RequiredMark,resolveFieldTextStyle,resolveVariantColors}from"../FieldBase/FieldBase.js";import{DEFAULT_OPTION_SHEET_LABELS,OptionSheet}from"../OptionSheet/OptionSheet.js";import{selectOptionDescription,selectOptionDisabled,selectOptionIcon,selectOptionLabel,selectOptionValue}from"../OptionSheet/optionAccessors.js";import{Text}from"../Text/index.js";import{TextInkContext}from"../Text/textInk.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_SELECT_LABELS={placeholder:"Select…",noSelection:"No selection",selected:e=>`Selected: ${e}`,fallbackName:"Select",sheetName:"Options",searchPlaceholder:DEFAULT_OPTION_SHEET_LABELS.searchPlaceholder,empty:DEFAULT_OPTION_SHEET_LABELS.empty};const sameSelectValue=(e,t)=>String(e)===String(t),containsValue=(e,t)=>e.some(e=>sameSelectValue(e,t));function Select(e){assertValidValue("Select","size",e.size,["sm","md","lg"]),assertValidValue("Select","variant",e.variant,["outline","filled","underline"]);const{options:t,getOptionLabel:l,getOptionValue:i,isOptionDisabled:o,getOptionDescription:s,getOptionIcon:n,placeholder:r,onOpenChange:a,searchable:c=!1,haptic:d,labels:p,label:u,help:h,title:x,required:S=!1,error:m,helperText:f,prefix:g,numberOfLines:b=1,disabled:y=!1,size:v="md",variant:T,leftIcon:O,rightIcon:L,chevronColor:C,chevronSize:j,radius:V,accessibilityLabel:_,labelStyle:F,style:E,triggerStyle:I,textStyle:k,optionStyle:A,selectedOptionStyle:z,optionTextStyle:D,selectedOptionTextStyle:H,testID:P,ref:B}=e,N=!0===e.multi,w=p?{...DEFAULT_SELECT_LABELS,...p}:DEFAULT_SELECT_LABELS,M=useCallback(e=>l?l(e):selectOptionLabel(e),[l]),R=useCallback(e=>i?i(e):selectOptionValue(e),[i]),U=useCallback(e=>o?o(e):selectOptionDisabled(e),[o]),q=useCallback(e=>s?s(e):selectOptionDescription(e),[s]),$=useCallback(e=>n?n(e):selectOptionIcon(e),[n]),G=useTheme(),J=useMemo(()=>buildStyles(G),[G]),K=resolveFieldSize(G,v),Q=resolveFieldTextStyle(G,{disabled:y}),W=T??G.settings.components.select?.defaultVariant??G.settings.components.field?.defaultVariant??"outline",[X,Y]=useState(!1),Z=useMemo(()=>{if(N){const l=e.value??[];return t.filter(e=>containsValue(l,R(e)))}const l=e.value;if(null==l)return[];const i=t.find(e=>sameSelectValue(R(e),l));return i?[i]:[]},[N,t,e.value,R]),ee=useCallback(()=>{if(y)return;const e=resolveHaptic(d,"selection");e&&triggerHaptic(e),Y(!0)},[y,d]),te=useCallback(()=>{Y(!1)},[]),le=useCallback(t=>{if(U(t))return;const l=R(t),i=resolveHaptic(d,"selection");if(i&&triggerHaptic(i),N){const t=e.value??[],i=containsValue(t,l)?t.filter(e=>!sameSelectValue(e,l)):[...t,l];return void e.onChange(i)}e.onChange(l),te()},[N,e,te,U,R,d]),ie=0===Z.length?r??w.placeholder:Z.map(e=>M(e)).join(", "),oe=0===Z.length,se=!0===m||hasFieldText(m),ne=hasFieldText(u),re=fieldTextAsString(u),ae=Math.round(1.4*K.text),ce=useMemo(()=>({fontSize:K.text,color:Q.placeholderColor}),[K.text,Q.placeholderColor]),de={color:y?G.colors["field-icon-disabled"]:X?G.colors["field-icon-focus"]:G.colors["field-icon"],size:K.icon,disabled:y,focused:X,error:se},pe=0===Z.length?r??w.noSelection:w.selected(Z.map(e=>M(e)).join(", ")),ue=_??`${re??w.fallbackName}. ${pe}`;return _jsxs(View,{style:[J.container,E],testID:P,children:[ne?_jsx(FieldLabel,{size:v,required:S,help:h,style:F,children:u}):null,_jsx(View,{ref:B,collapsable:!1,children:_jsxs(FieldBase,{size:v,variant:W,disabled:y,error:se,filled:Z.length>0,onPress:ee,radius:V,paddingHorizontal:"underline"===W?G.space.none:void 0,accessibilityRole:"button",accessibilityLabel:ue,accessibilityState:{disabled:y,expanded:X},"aria-disabled":y,"aria-expanded":X,style:I,slotAlign:1===b?"center":"top",slotLineHeight:1===b?void 0:ae,leading:O?slotIconView(O,renderSlotIcon(O,de)):null,trailing:L?slotIconView(L,renderSlotIcon(L,de)):_jsx(Chevron,{color:C??(y?G.colors["text-disabled"]:G.colors["text-subtle"]),size:j??K.icon,open:X,style:J.chevron}),children:[hasFieldText(g)?"string"==typeof g||"number"==typeof g?_jsx(Text,{variant:"body",style:[J.prefix,{color:Q.placeholderColor,fontSize:K.text,lineHeight:1===b?void 0:ae,marginRight:G.space.xs}],children:g}):_jsx(View,{style:[J.prefixNode,{minHeight:1===b?void 0:ae,justifyContent:"center",marginRight:G.space.xs}],children:_jsx(Text,{variant:"body",style:[J.prefix,{color:Q.placeholderColor,fontSize:K.text,lineHeight:1===b?void 0:ae}],children:_jsx(TextInkContext.Provider,{value:ce,children:g})})}):null,_jsxs(Text,{variant:"body",style:[J.triggerText,{color:oe?Q.placeholderColor:Q.color,fontSize:K.text,lineHeight:1===b?void 0:ae,...Q.weightStyle},k],numberOfLines:b,children:[ie,oe&&S&&!ne?_jsx(RequiredMark,{}):null]})]})}),_jsx(FieldMessage,{size:v,error:se,text:se?m:f}),_jsx(OptionSheet,{open:X,onClose:te,onOpenChange:a,haptic:d,title:x??re,accessibilityLabel:re??(ne?x:void 0)??r??w.sheetName,options:t,getOptionLabel:M,getOptionValue:R,isOptionDisabled:U,getOptionDescription:q,getOptionIcon:$,value:e.value,onChange:(e,t)=>le(t),multi:N,searchable:c,labels:{searchPlaceholder:w.searchPlaceholder,empty:w.empty},optionStyle:A,selectedOptionStyle:z,optionTextStyle:D,selectedOptionTextStyle:H,searchSelectionColor:resolveVariantColors(G,W).borderFocusedRepresentative})]})}Select.displayName="Select";const buildStyles=e=>StyleSheet.create({container:{width:"100%"},label:{includeFontPadding:!1},triggerText:{flex:1,includeFontPadding:!1},errorText:{includeFontPadding:!1},prefix:{flexShrink:0,includeFontPadding:!1},prefixNode:{flexShrink:0},chevron:{marginLeft:e.space.sm}});export{Select};export default Select;
@@ -1 +1 @@
1
- "use strict";import React,{Children,cloneElement,isValidElement,useEffect,useMemo,useRef}from"react";import{Animated,Image,StyleSheet,Text,View}from"react-native";import{usePresenceMotion}from"../../hooks/usePresenceMotion.js";import{createAnimatedValue,useTheme}from"../../theme/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{nativeDriver}from"../../utils/nativeDriver.js";import{Text as LibraryText}from"../Text/index.js";import{DEFAULT_SKELETON_LABELS,Skeleton}from"./Skeleton.js";import{useSkeletonDefaults}from"./SkeletonProvider.js";import{SkeletonSkip}from"./SkeletonSkip.js";import{jsx as _jsx,Fragment as _Fragment}from"react/jsx-runtime";const DEFAULT_REVEAL_FADE_MS=300,flattenStyle=e=>{if(!e)return{};return StyleSheet.flatten(e)??{}},resolveWidth=(e,t)=>"number"==typeof e?e:"string"!=typeof e||"auto"!==e&&"100%"!==e&&!/^\d+(\.\d+)?%$/.test(e)?t:e,resolveRadius=(e,t)=>"number"==typeof e?e:t,skeletonizeNode=(e,t,i,r,n="r")=>{if(null==t||"boolean"==typeof t)return null;if("string"==typeof t||"number"==typeof t)return _jsx(Skeleton,{shape:"text",width:"60%",height:14,variant:i,colors:r},`${n}-text`);if(Array.isArray(t))return Children.map(t,(t,s)=>skeletonizeNode(e,t,i,r,`${n}-${s}`));if(!isValidElement(t))return null;const s=t,o=s.props??{},l=s.type;if(l===SkeletonSkip)return cloneElement(s,{key:`${n}-skip`});if("function"==typeof l||"object"==typeof l){const e=l.Skeleton;if(e){return _jsx(e,{...o},`${n}-self`)}}if(l===Image){const e=flattenStyle(o.style),t=resolveWidth(e.width,"100%"),s="number"==typeof e.height?e.height:120,l=resolveRadius(e.borderRadius,"sm");return _jsx(Skeleton,{width:t,height:s,radius:l,variant:i,colors:r,style:{margin:"number"==typeof e.margin?e.margin:void 0}},`${n}-img`)}if(l===Text||l===LibraryText){const t=flattenStyle(o.style),s="number"==typeof t.fontSize?t.fontSize:e.text.base.size,l=resolveWidth(t.width,"85%");return _jsx(Skeleton,{shape:"text",width:l,height:Math.round(1.15*s),variant:i,colors:r,style:{marginVertical:e.space.xxs}},`${n}-txt`)}if(null!=o.children)return cloneElement(s,{key:`${n}-w`},skeletonizeNode(e,o.children,i,r,`${n}-c`));if(l===View){const e=flattenStyle(o.style);if(null!=e.width||null!=e.height){const t=resolveWidth(e.width,"100%"),s="number"==typeof e.height?e.height:20,o=resolveRadius(e.borderRadius,"sm");return _jsx(Skeleton,{width:t,height:s,radius:o,variant:i,colors:r},`${n}-vw`)}}return cloneElement(s,{key:`${n}-leaf`})},SkeletonContent=e=>{const{loading:t,children:i,placeholder:r,variant:n,count:s=1,colors:o,labels:l,fadeDuration:a,style:u,testID:c}=e;assertValidValue("SkeletonContent","variant",e.variant,["shimmer","pulse","none"]);const d=useTheme(),m=useMemo(()=>({...DEFAULT_SKELETON_LABELS,...l}),[l]),f=useSkeletonDefaults(),h=usePresenceMotion(),y=a??f.fadeDuration??(h.reduced?h.duration("default"):300),p=useRef(t),S=useRef(createAnimatedValue(t?0:1)).current;if(useEffect(()=>{let e;return p.current&&!t?(S.setValue(0),e=Animated.timing(S,{toValue:1,duration:y,useNativeDriver:nativeDriver}),e.start()):!p.current&&t&&S.setValue(1),p.current=t,()=>e?.stop()},[t,S,y]),!t)return y<=0?_jsx(_Fragment,{children:i}):_jsx(Animated.View,{style:[u,{opacity:S}],testID:c,children:i});if(void 0!==r){const e=s>1?Array.from({length:s},(e,t)=>_jsx(React.Fragment,{children:r},`sk-ph-${t}`)):r;return _jsx(View,{style:u,testID:c,accessible:!0,accessibilityLabel:m.loading,accessibilityRole:"progressbar",accessibilityState:{busy:!0},"aria-busy":!0,accessibilityLiveRegion:"polite",children:e})}const b=s>1?Array.from({length:s},(e,t)=>_jsx(React.Fragment,{children:i},`sk-rep-${t}`)):i;return _jsx(View,{style:u,testID:c,accessible:!0,accessibilityLabel:m.loading,accessibilityRole:"progressbar",accessibilityState:{busy:!0},"aria-busy":!0,accessibilityLiveRegion:"polite",children:skeletonizeNode(d,b,n,o)})};SkeletonContent.displayName="SkeletonContent";export{SkeletonContent};export default SkeletonContent;
1
+ "use strict";import React,{Children,cloneElement,isValidElement,useEffect,useMemo,useRef}from"react";import{Animated,Image,StyleSheet,Text,View}from"react-native";import{usePresenceMotion}from"../../hooks/usePresenceMotion.js";import{createAnimatedValue,useTheme}from"../../theme/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{isRecord}from"../../utils/guards.js";import{nativeDriver}from"../../utils/nativeDriver.js";import{Text as LibraryText}from"../Text/index.js";import{DEFAULT_SKELETON_LABELS,Skeleton}from"./Skeleton.js";import{useSkeletonDefaults}from"./SkeletonProvider.js";import{SkeletonSkip}from"./SkeletonSkip.js";import{jsx as _jsx,Fragment as _Fragment}from"react/jsx-runtime";const DEFAULT_REVEAL_FADE_MS=300,flattenStyle=e=>({...StyleSheet.flatten(e)}),isWidthText=e=>"auto"===e||"100%"===e||/^\d+(\.\d+)?%$/.test(e),isComponentType=e=>"function"==typeof e||isRecord(e),resolveWidth=(e,t)=>"number"==typeof e||"string"==typeof e&&isWidthText(e)?e:t,resolveRadius=(e,t)=>"number"==typeof e?e:t,skeletonizeNode=(e,t,i,r,n="r")=>{if(null==t||"boolean"==typeof t)return null;if("string"==typeof t||"number"==typeof t)return _jsx(Skeleton,{shape:"text",width:"60%",height:14,variant:i,colors:r},`${n}-text`);if(Array.isArray(t))return Children.map(t,(t,s)=>skeletonizeNode(e,t,i,r,`${n}-${s}`));if(!isValidElement(t))return null;const s=t,o=s.props??{},l=s.type;if(l===SkeletonSkip)return cloneElement(s,{key:`${n}-skip`});if(("function"==typeof l||"object"==typeof l)&&"Skeleton"in l&&isComponentType(l.Skeleton)){const e=l.Skeleton;return _jsx(e,{...o},`${n}-self`)}if(l===Image){const e=flattenStyle(o.style),t=resolveWidth(e.width,"100%"),s="number"==typeof e.height?e.height:120,l=resolveRadius(e.borderRadius,"sm");return _jsx(Skeleton,{width:t,height:s,radius:l,variant:i,colors:r,style:{margin:"number"==typeof e.margin?e.margin:void 0}},`${n}-img`)}if(l===Text||l===LibraryText){const t=flattenStyle(o.style),s="number"==typeof t.fontSize?t.fontSize:e.text.base.size,l=resolveWidth(t.width,"85%");return _jsx(Skeleton,{shape:"text",width:l,height:Math.round(1.15*s),variant:i,colors:r,style:{marginVertical:e.space.xxs}},`${n}-txt`)}if(null!=o.children)return cloneElement(s,{key:`${n}-w`},skeletonizeNode(e,o.children,i,r,`${n}-c`));if(l===View){const e=flattenStyle(o.style);if(null!=e.width||null!=e.height){const t=resolveWidth(e.width,"100%"),s="number"==typeof e.height?e.height:20,o=resolveRadius(e.borderRadius,"sm");return _jsx(Skeleton,{width:t,height:s,radius:o,variant:i,colors:r},`${n}-vw`)}}return cloneElement(s,{key:`${n}-leaf`})},SkeletonContent=e=>{const{loading:t,children:i,placeholder:r,variant:n,count:s=1,colors:o,labels:l,fadeDuration:a,style:u,testID:c}=e;assertValidValue("SkeletonContent","variant",e.variant,["shimmer","pulse","none"]);const d=useTheme(),m=useMemo(()=>({...DEFAULT_SKELETON_LABELS,...l}),[l]),f=useSkeletonDefaults(),h=usePresenceMotion(),y=a??f.fadeDuration??(h.reduced?h.duration("default"):300),p=useRef(t),S=useRef(createAnimatedValue(t?0:1)).current;if(useEffect(()=>{let e;return p.current&&!t?(S.setValue(0),e=Animated.timing(S,{toValue:1,duration:y,useNativeDriver:nativeDriver}),e.start()):!p.current&&t&&S.setValue(1),p.current=t,()=>e?.stop()},[t,S,y]),!t)return y<=0?_jsx(_Fragment,{children:i}):_jsx(Animated.View,{style:[u,{opacity:S}],testID:c,children:i});if(void 0!==r){const e=s>1?Array.from({length:s},(e,t)=>_jsx(React.Fragment,{children:r},`sk-ph-${t}`)):r;return _jsx(View,{style:u,testID:c,accessible:!0,accessibilityLabel:m.loading,accessibilityRole:"progressbar",accessibilityState:{busy:!0},"aria-busy":!0,accessibilityLiveRegion:"polite",children:e})}const k=s>1?Array.from({length:s},(e,t)=>_jsx(React.Fragment,{children:i},`sk-rep-${t}`)):i;return _jsx(View,{style:u,testID:c,accessible:!0,accessibilityLabel:m.loading,accessibilityRole:"progressbar",accessibilityState:{busy:!0},"aria-busy":!0,accessibilityLiveRegion:"polite",children:skeletonizeNode(d,k,n,o)})};SkeletonContent.displayName="SkeletonContent";export{SkeletonContent};export default SkeletonContent;
@@ -1 +1 @@
1
- "use strict";import React from"react";import{FlatList,View}from"react-native";import{SkeletonContent}from"./SkeletonContent.js";import{useSkeletonDefaults}from"./SkeletonProvider.js";import{jsx as _jsx}from"react/jsx-runtime";function SkeletonListInner(e){const{loading:t,data:n,renderItem:o,renderPlaceholder:r,placeholderCount:l,variant:s,colors:a,labels:i,placeholderContainerStyle:c,horizontal:m,contentContainerStyle:d,style:u,testID:f,...S}=e,h=useSkeletonDefaults(),x=l??h.placeholderCount??3;if(t){const e=Array.from({length:Math.max(0,x)},(e,t)=>_jsx(React.Fragment,{children:r?r(t):null},`sk-list-${t}`));return _jsx(SkeletonContent,{loading:!0,variant:s,colors:a,labels:i,style:u,testID:f,children:_jsx(View,{style:[m?styles.row:styles.column,c],children:e})})}return _jsx(FlatList,{data:n??[],renderItem:o,horizontal:m,contentContainerStyle:d,style:u,testID:f,...S})}const styles={row:{flexDirection:"row"},column:{flexDirection:"column"}};export const SkeletonList=SkeletonListInner;
1
+ "use strict";import React from"react";import{FlatList,View}from"react-native";import{SkeletonContent}from"./SkeletonContent.js";import{useSkeletonDefaults}from"./SkeletonProvider.js";import{jsx as _jsx}from"react/jsx-runtime";export function SkeletonList(e){const{loading:t,data:o,renderItem:n,renderPlaceholder:r,placeholderCount:l,variant:s,colors:a,labels:i,placeholderContainerStyle:c,horizontal:m,contentContainerStyle:d,style:u,testID:f,...h}=e,x=useSkeletonDefaults(),y=l??x.placeholderCount??3;if(t){const e=Array.from({length:Math.max(0,y)},(e,t)=>_jsx(React.Fragment,{children:r?r(t):null},`sk-list-${t}`));return _jsx(SkeletonContent,{loading:!0,variant:s,colors:a,labels:i,style:u,testID:f,children:_jsx(View,{style:[m?styles.row:styles.column,c],children:e})})}return _jsx(FlatList,{data:o??[],renderItem:n,horizontal:m,contentContainerStyle:d,style:u,testID:f,...h})}const styles={row:{flexDirection:"row"},column:{flexDirection:"column"}};
@@ -1 +1 @@
1
- "use strict";import{forwardRef,useCallback,useEffect,useMemo,useRef,useState}from"react";import{Platform,Pressable,StyleSheet,View}from"react-native";import{GestureDetector,usePanGesture}from"react-native-gesture-handler";import Animated,{cancelAnimation,Easing,runOnJS,useAnimatedStyle,useSharedValue,withSpring,withTiming}from"react-native-reanimated";import{useControllableState}from"../../hooks/index.js";import{resolveSliderSize,useTheme}from"../../theme/index.js";import{resolveHaptic,triggerHaptic}from"../../utils/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{smoothCorners}from"../../utils/corners.js";import{Text}from"../Text/index.js";import{sliderToneInk}from"./valueText.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const VARIANT_SIZE_MAP={inset:{sm:{trackHeight:14,thumbDiameter:10},md:{trackHeight:20,thumbDiameter:14},lg:{trackHeight:26,thumbDiameter:18}},minimal:{sm:{trackHeight:2,thumbDiameter:14},md:{trackHeight:3,thumbDiameter:18},lg:{trackHeight:4,thumbDiameter:22}},bar:{sm:{trackHeight:20,thumbDiameter:20},md:{trackHeight:28,thumbDiameter:28},lg:{trackHeight:36,thumbDiameter:36}}},INSET_RING_RATIO=.3,MIN_THUMB_TOUCH=44,clamp=(e,t,a)=>Math.min(Math.max(e,t),a),snapToStep=(e,t,a,i)=>{if(i<=0)return clamp(e,t,a);const r=Math.round((e-t)/i)*i+t,s=String(i).split(".")[1]?.length??0,n=s>0?Number(r.toFixed(s)):r;return clamp(n,t,a)},BUBBLE_GAP=2,BUBBLE_CARET=8,BUBBLE_WRAP_WIDTH=160,NO_SHADOW={shadowOpacity:0,elevation:0},defaultFormatLabel=e=>String(e),Slider=forwardRef((e,t)=>{const{min:a=0,max:i=100,step:r=1,disabled:s=!1,tone:n="primary",size:o="md",variant:l="default",showLabel:u=!1,snapThumb:c=!1,formatLabel:d=defaultFormatLabel,renderLabel:m,accessibilityLabel:h,haptic:b,style:p,containerStyle:f,trackStyle:g,fillStyle:v,thumbStyle:w,labelStyle:y,thumbPressScale:S,labelShowDuration:k,labelOpacity:C,testID:x}=e;assertValidValue("Slider","tone",e.tone,["primary","success","warning","danger","info","neutral"]),assertValidValue("Slider","size",e.size,["sm","md","lg"]),assertValidValue("Slider","variant",e.variant,["default","inset","minimal","bar"]);const V=useTheme(),A=useMemo(()=>{const e=resolveSliderSize(V,o);return{trackHeight:e["track-height"],thumbDiameter:e["thumb-diameter"]}},[V,o]),j=useMemo(()=>"default"===l?A:VARIANT_SIZE_MAP[l][o],[A,o,l]),M="inset"===l?j.trackHeight/2:0,_=V.settings.components.slider?.thumbPressAnimation??!1,D=S??1.1,H=k??V.motion.duration.fast,E=C??1,O=useMemo(()=>buildStyles(V,j),[V,j]),T=useMemo(()=>({damping:V.motion.spring.snappy.damping,stiffness:V.motion.spring.snappy.stiffness,mass:V.motion.spring.snappy.mass}),[V.motion.spring.snappy]),[R,I]=useState(0),W=V.colors[n],P=sliderToneInk(V,n),L=!0===e.range,[N,X]=useControllableState({value:e.value,defaultValue:e.defaultValue??(L?[a,i]:a),onChange:e.onChange}),B=useSharedValue(0),F=useSharedValue(0),G=useSharedValue(L?N[0]:N),z=useSharedValue(L?N[1]:N),J=useSharedValue(0),U=useSharedValue(0),Z=useSharedValue(1),$=useSharedValue(1),q="always"===u,K=useSharedValue(q?1:0),Q=useSharedValue(q?1:0),Y=useMemo(()=>10**(String(r).split(".")[1]?.length??0),[r]);useEffect(()=>()=>{cancelAnimation(B),cancelAnimation(F),cancelAnimation(Z),cancelAnimation($),cancelAnimation(K),cancelAnimation(Q)},[B,F,Z,$,K,Q]);const ee=useCallback((e,t)=>{const r=t-2*M;return i===a||r<=0?M:M+(e-a)/(i-a)*r},[a,i,M]),te=useCallback((e,t)=>{const s=t-2*M;if(s<=0)return a;const n=clamp((e-M)/s,0,1);return snapToStep(a+n*(i-a),a,i,r)},[a,i,r,M]),ae=useRef(!1),ie=V.motion.duration.fast,re=useRef(N);re.current=N;const se=useRef(R);se.current=R;const ne=useCallback((e=!1)=>{const t=se.current;if(t<=0)return;const place=t=>e?withTiming(t,{duration:ie,easing:Easing.out(Easing.cubic)}):t,a=re.current;if(L){const[e,i]=a,r=Math.min(e,i),s=Math.max(e,i);G.value=r,z.value=s,B.value=place(ee(r,t)),F.value=place(ee(s,t))}else{const e=a;G.value=e,z.value=e,B.value=place(ee(e,t))}},[L,ee,G,z,B,F,ie]),[oe,le]=useState(0),ue=useRef(!1),ce=useCallback(e=>{ae.current=e,e||(ue.current=!0,le(e=>e+1))},[]);useEffect(()=>{if(ae.current)return;const e=ue.current;ue.current=!1,ne(e)},[JSON.stringify(N),R,oe,ne]);const de=useCallback(e=>{const t=e.nativeEvent.layout.width;U.value=t,I(t)},[U]),me=useCallback((e,t)=>{X(L?[e,t]:e)},[L,X]),he=useCallback(()=>{const e=resolveHaptic(b,"selection");e&&triggerHaptic(e)},[b]),be=useRef(me);be.current=me;const pe=useRef(he);pe.current=he;const fe=useCallback((e,t)=>be.current(e,t),[]),ge=useCallback(()=>pe.current(),[]),ve=Math.max(0,(44-j.thumbDiameter)/2),we=ve>0?ve:void 0,ye=useCallback(e=>{const t="low"===e?B:F,n="low"===e?G:z,o="low"===e?z:G,l="low"===e?Z:$,d="low"===e?K:Q,m="low"===e,h=a,b=i,p=r,f=Y,g=L,v=D,w=_,y=!0===u,S=c,k=E,C=H,x=T,V=M,follow=e=>{"worklet";const a=U.value-2*V;if(a<=0||!Number.isFinite(e))return;const i=Math.min(Math.max(J.value+e,V),U.value-V);let r=h+(i-V)/a*(b-h);p>0&&(r=Math.round((r-h)/p)*p+h,r=Math.round(r*f)/f),r=Math.min(Math.max(r,h),b),g&&(m&&r>o.value&&(r=o.value),!m&&r<o.value&&(r=o.value)),t.value=S||b===h?b===h?V:V+(r-h)/(b-h)*a:g?m?Math.min(i,F.value):Math.max(i,B.value):i,r!==n.value&&(n.value=r,r!==h&&r!==b||runOnJS(ge)(),runOnJS(fe)(G.value,z.value))};return{enabled:!s,minDistance:0,...void 0===we?{}:{hitSlop:we},onActivate:()=>{"worklet";runOnJS(ce)(!0),J.value=t.value,w&&(l.value=withSpring(v,x)),y&&(d.value=withTiming(k,{duration:C,easing:Easing.out(Easing.cubic)})),runOnJS(ge)()},onUpdate:e=>{"worklet";follow(e.translationX)},onDeactivate:e=>{"worklet";follow(e.translationX),w&&(l.value=withSpring(1,x)),y&&(d.value=withTiming(0,{duration:C,easing:Easing.out(Easing.cubic)}))},onFinalize:()=>{"worklet";runOnJS(ce)(!1)}}},[s,a,i,r,Y,L,D,_,u,c,E,H,T,M,we,fe,ge,ce,B,F,G,z,Z,$,K,Q,J,U]),Se=useMemo(()=>ye("low"),[ye]),ke=useMemo(()=>ye("high"),[ye]),Ce=usePanGesture(Se),xe=usePanGesture(ke),Ve=useCallback(e=>{if(s||L||R<=0)return;const t=clamp(e.nativeEvent.locationX,0,R),a=te(t,R);a!==G.value&&(he(),G.value=a,B.value=withTiming(ee(a,R),{duration:V.motion.duration.fast,easing:Easing.out(Easing.cubic)}),me(a,a))},[s,L,R,te,ee,me,he,B,G,V.motion.duration.fast]),Ae=useCallback(e=>{if(s)return;const t="increment"===e.nativeEvent.actionName?r:-r,n=r>0?Math.round(t*Y)/Y:t;if(L){const e=Math.round((G.value+n)*Y)/Y,t=clamp(e,a,z.value);t!==G.value&&(G.value=t,B.value=ee(t,R),he(),me(t,z.value))}else{const e=Math.round((G.value+n)*Y)/Y,t=clamp(e,a,i);t!==G.value&&(G.value=t,B.value=ee(t,R),he(),me(t,t))}},[s,r,Y,L,a,i,ee,R,B,G,z,me,he]),je=j.thumbDiameter/2,Me=s?V.colors["surface-disabled"]:W,De="inset"===l?{backgroundColor:Me,borderColor:V.colors.surface,borderWidth:Math.max(2,Math.round(.3*j.thumbDiameter)),...NO_SHADOW}:"minimal"===l?{backgroundColor:Me,borderWidth:0}:"bar"===l?{backgroundColor:"transparent",borderWidth:0,...NO_SHADOW}:{backgroundColor:V.colors.surface,borderColor:Me},He=useAnimatedStyle(()=>{const e=U.value;if(e<=0)return{opacity:0,transform:[{translateX:0},{scaleX:1}]};const t=s?.55:1;if(L){const a=Math.max(0,F.value-B.value+2*M);return{opacity:t,transform:[{translateX:B.value-M},{scaleX:a/e}]}}return{opacity:t,transform:[{translateX:B.value+M-e},{scaleX:1}]}},[U,s,L,F,B,M]),Ee=useAnimatedStyle(()=>({transform:[{translateX:B.value-je},{scale:Z.value}]}),[B,je,Z]),Oe=useAnimatedStyle(()=>({transform:[{translateX:F.value-je},{scale:$.value}]}),[F,je,$]),Te=useAnimatedStyle(()=>({opacity:K.value}),[K]),Re=useAnimatedStyle(()=>({opacity:Q.value}),[Q]),clampDisplay=e=>clamp(e,a,i),Ie=clampDisplay(L?Math.min(...N):N),We=clampDisplay(L?Math.max(...N):N);return _jsx(View,{ref:t,style:[O.container,f,p],testID:x,accessibilityRole:"adjustable",accessibilityLabel:h,accessibilityState:{disabled:s},"aria-disabled":s,accessibilityValue:L?{min:a,max:i,now:Ie,text:`${Ie} to ${We}`}:{min:a,max:i,now:Ie},accessibilityActions:[{name:"increment"},{name:"decrement"}],onAccessibilityAction:Ae,children:_jsx(Pressable,{onPress:Ve,disabled:s||L,style:O.trackTouch,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:_jsxs(View,{style:O.trackWrap,onLayout:de,children:[_jsxs(View,{style:O.trackClip,pointerEvents:"none",children:[_jsx(View,{style:[O.track,{backgroundColor:s?V.colors["surface-disabled"]:V.colors.border},g]}),_jsx(Animated.View,{style:[O.fill,{backgroundColor:s?V.colors["surface-disabled"]:W},v,He]})]}),_jsx(GestureDetector,{gesture:Ce,children:_jsx(Animated.View,{style:[O.thumb,{width:j.thumbDiameter,height:j.thumbDiameter,borderRadius:je,...smoothCorners,opacity:s?.55:1},De,w,Ee],accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:u?_jsxs(Animated.View,{style:[O.bubbleWrap,Te],pointerEvents:"none",children:[_jsx(View,{style:[O.bubble,{backgroundColor:W}],children:m?m(Ie):_jsx(Text,{variant:"caption",weight:"semibold",style:[{color:P},y],numberOfLines:1,children:d(Ie)})}),_jsx(View,{style:[O.bubbleCaret,{backgroundColor:W}]})]}):null})}),L?_jsx(GestureDetector,{gesture:xe,children:_jsx(Animated.View,{style:[O.thumb,{width:j.thumbDiameter,height:j.thumbDiameter,borderRadius:je,...smoothCorners,opacity:s?.55:1},De,w,Oe],accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:u?_jsxs(Animated.View,{style:[O.bubbleWrap,Re],pointerEvents:"none",children:[_jsx(View,{style:[O.bubble,{backgroundColor:W}],children:m?m(We):_jsx(Text,{variant:"caption",weight:"semibold",style:[{color:P},y],numberOfLines:1,children:d(We)})}),_jsx(View,{style:[O.bubbleCaret,{backgroundColor:W}]})]}):null})}):null]})})})});Slider.displayName="Slider";const buildStyles=(e,t)=>{const a=e.shadow.elevated,i=Math.max(t.thumbDiameter,t.trackHeight),r=i/2+e.space.xs;return StyleSheet.create({container:{width:"100%",paddingVertical:r,justifyContent:"center"},trackTouch:{width:"100%",justifyContent:"center"},trackWrap:{width:"100%",height:i,justifyContent:"center"},trackClip:{position:"absolute",left:0,right:0,height:t.trackHeight,top:(i-t.trackHeight)/2,borderRadius:t.trackHeight/2,...smoothCorners,overflow:"hidden"},track:{position:"absolute",top:0,right:0,bottom:0,left:0,borderRadius:t.trackHeight/2,...smoothCorners},fill:{position:"absolute",top:0,left:0,width:"100%",height:t.trackHeight,borderRadius:t.trackHeight/2,...smoothCorners,transformOrigin:"left"},thumb:{position:"absolute",top:(i-t.thumbDiameter)/2,left:0,borderWidth:2,shadowColor:a.shadowColor,shadowOffset:a.shadowOffset,shadowOpacity:a.shadowOpacity,shadowRadius:a.shadowRadius,elevation:a.elevation,alignItems:"center",justifyContent:"center"},bubbleWrap:{position:"absolute",bottom:t.thumbDiameter+2,left:t.thumbDiameter/2-80,width:160,alignItems:"center"},bubbleCaret:{width:8,height:8,marginTop:-5,borderRadius:e.radius.none,...smoothCorners,transform:[{rotate:"45deg"}]},bubble:{paddingHorizontal:e.space.sm,paddingVertical:e.space.xxs,borderRadius:e.radius.md,...smoothCorners,minWidth:36,alignItems:"center",justifyContent:"center",...Platform.select({ios:{shadowColor:e.shadow.card.shadowColor,shadowOffset:e.shadow.card.shadowOffset,shadowOpacity:e.shadow.card.shadowOpacity,shadowRadius:e.shadow.card.shadowRadius},android:{elevation:e.shadow.card.elevation},default:{}})}})};export{Slider};export default Slider;
1
+ "use strict";import{forwardRef,useCallback,useEffect,useMemo,useRef,useState}from"react";import{Platform,Pressable,StyleSheet,View}from"react-native";import{GestureDetector,usePanGesture}from"react-native-gesture-handler";import Animated,{cancelAnimation,Easing,runOnJS,useAnimatedStyle,useSharedValue,withSpring,withTiming}from"react-native-reanimated";import{useControllableState}from"../../hooks/index.js";import{resolveSliderSize,useTheme}from"../../theme/index.js";import{resolveHaptic,triggerHaptic}from"../../utils/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{smoothCorners}from"../../utils/corners.js";import{Text}from"../Text/index.js";import{sliderToneInk}from"./valueText.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const VARIANT_SIZE_MAP={inset:{sm:{trackHeight:14,thumbDiameter:10},md:{trackHeight:20,thumbDiameter:14},lg:{trackHeight:26,thumbDiameter:18}},minimal:{sm:{trackHeight:2,thumbDiameter:14},md:{trackHeight:3,thumbDiameter:18},lg:{trackHeight:4,thumbDiameter:22}},bar:{sm:{trackHeight:20,thumbDiameter:20},md:{trackHeight:28,thumbDiameter:28},lg:{trackHeight:36,thumbDiameter:36}}},INSET_RING_RATIO=.3,MIN_THUMB_TOUCH=44,clamp=(e,t,a)=>Math.min(Math.max(e,t),a),snapToStep=(e,t,a,r)=>{if(r<=0)return clamp(e,t,a);const i=Math.round((e-t)/r)*r+t,s=String(r).split(".")[1]?.length??0,n=s>0?Number(i.toFixed(s)):i;return clamp(n,t,a)},BUBBLE_GAP=2,BUBBLE_CARET=8,BUBBLE_WRAP_WIDTH=160,NO_SHADOW={shadowOpacity:0,elevation:0},defaultFormatLabel=e=>String(e),isPair=e=>Array.isArray(e),Slider=forwardRef((e,t)=>{const{min:a=0,max:r=100,step:i=1,disabled:s=!1,tone:n="primary",size:o="md",variant:l="default",showLabel:u=!1,snapThumb:c=!1,formatLabel:d=defaultFormatLabel,renderLabel:m,accessibilityLabel:h,haptic:b,style:g,containerStyle:f,trackStyle:p,fillStyle:v,thumbStyle:w,labelStyle:y,thumbPressScale:S,labelShowDuration:k,labelOpacity:C,testID:x}=e;assertValidValue("Slider","tone",e.tone,["primary","success","warning","danger","info","neutral"]),assertValidValue("Slider","size",e.size,["sm","md","lg"]),assertValidValue("Slider","variant",e.variant,["default","inset","minimal","bar"]);const A=useTheme(),V=useMemo(()=>{const e=resolveSliderSize(A,o);return{trackHeight:e["track-height"],thumbDiameter:e["thumb-diameter"]}},[A,o]),j=useMemo(()=>"default"===l?V:VARIANT_SIZE_MAP[l][o],[V,o,l]),M="inset"===l?j.trackHeight/2:0,_=A.settings.components.slider?.thumbPressAnimation??!1,D=S??1.1,H=k??A.motion.duration.fast,E=C??1,O=useMemo(()=>buildStyles(A,j),[A,j]),T=useMemo(()=>({damping:A.motion.spring.snappy.damping,stiffness:A.motion.spring.snappy.stiffness,mass:A.motion.spring.snappy.mass}),[A.motion.spring.snappy]),[R,P]=useState(0),I=A.colors[n],W=sliderToneInk(A,n),L=!0===e.range,N=useCallback(t=>{if(!0!==e.range){if(Array.isArray(t))throw new Error("Slider received a range value in single mode.");e.onChange?.(t)}else{if(!Array.isArray(t))throw new Error("Slider received a single value in range mode.");e.onChange?.(t)}},[e.onChange,e.range]),[X,B]=useControllableState({value:e.value,defaultValue:e.defaultValue??(L?[a,r]:a),onChange:N}),F=useSharedValue(0),G=useSharedValue(0),z=useSharedValue(isPair(X)?X[0]:X),J=useSharedValue(isPair(X)?X[1]:X),U=useSharedValue(0),Z=useSharedValue(0),$=useSharedValue(1),q=useSharedValue(1),K="always"===u,Q=useSharedValue(K?1:0),Y=useSharedValue(K?1:0),ee=useMemo(()=>10**(String(i).split(".")[1]?.length??0),[i]);useEffect(()=>()=>{cancelAnimation(F),cancelAnimation(G),cancelAnimation($),cancelAnimation(q),cancelAnimation(Q),cancelAnimation(Y)},[F,G,$,q,Q,Y]);const te=useCallback((e,t)=>{const i=t-2*M;return r===a||i<=0?M:M+(e-a)/(r-a)*i},[a,r,M]),ae=useCallback((e,t)=>{const s=t-2*M;if(s<=0)return a;const n=clamp((e-M)/s,0,1);return snapToStep(a+n*(r-a),a,r,i)},[a,r,i,M]),re=useRef(!1),ie=A.motion.duration.fast,se=useRef(X);se.current=X;const ne=useRef(R);ne.current=R;const oe=useCallback((e=!1)=>{const t=ne.current;if(t<=0)return;const place=t=>e?withTiming(t,{duration:ie,easing:Easing.out(Easing.cubic)}):t,a=se.current;if(isPair(a)){const[e,r]=a,i=Math.min(e,r),s=Math.max(e,r);z.value=i,J.value=s,F.value=place(te(i,t)),G.value=place(te(s,t))}else{const e=a;z.value=e,J.value=e,F.value=place(te(e,t))}},[te,z,J,F,G,ie]),[le,ue]=useState(0),ce=useRef(!1),de=useCallback(e=>{re.current=e,e||(ce.current=!0,ue(e=>e+1))},[]);useEffect(()=>{if(re.current)return;const e=ce.current;ce.current=!1,oe(e)},[JSON.stringify(X),R,le,oe]);const me=useCallback(e=>{const t=e.nativeEvent.layout.width;Z.value=t,P(t)},[Z]),he=useCallback((e,t)=>{B(L?[e,t]:e)},[L,B]),be=useCallback(()=>{const e=resolveHaptic(b,"selection");e&&triggerHaptic(e)},[b]),ge=useRef(he);ge.current=he;const fe=useRef(be);fe.current=be;const pe=useCallback((e,t)=>ge.current(e,t),[]),ve=useCallback(()=>fe.current(),[]),we=Math.max(0,(44-j.thumbDiameter)/2),ye=we>0?we:void 0,Se=useCallback(e=>{const t="low"===e?F:G,n="low"===e?z:J,o="low"===e?J:z,l="low"===e?$:q,d="low"===e?Q:Y,m="low"===e,h=a,b=r,g=i,f=ee,p=L,v=D,w=_,y=!0===u,S=c,k=E,C=H,x=T,A=M,follow=e=>{"worklet";const a=Z.value-2*A;if(a<=0||!Number.isFinite(e))return;const r=Math.min(Math.max(U.value+e,A),Z.value-A);let i=h+(r-A)/a*(b-h);g>0&&(i=Math.round((i-h)/g)*g+h,i=Math.round(i*f)/f),i=Math.min(Math.max(i,h),b),p&&(m&&i>o.value&&(i=o.value),!m&&i<o.value&&(i=o.value)),t.value=S||b===h?b===h?A:A+(i-h)/(b-h)*a:p?m?Math.min(r,G.value):Math.max(r,F.value):r,i!==n.value&&(n.value=i,i!==h&&i!==b||runOnJS(ve)(),runOnJS(pe)(z.value,J.value))};return{enabled:!s,minDistance:0,...void 0===ye?{}:{hitSlop:ye},onActivate:()=>{"worklet";runOnJS(de)(!0),U.value=t.value,w&&(l.value=withSpring(v,x)),y&&(d.value=withTiming(k,{duration:C,easing:Easing.out(Easing.cubic)})),runOnJS(ve)()},onUpdate:e=>{"worklet";follow(e.translationX)},onDeactivate:e=>{"worklet";follow(e.translationX),w&&(l.value=withSpring(1,x)),y&&(d.value=withTiming(0,{duration:C,easing:Easing.out(Easing.cubic)}))},onFinalize:()=>{"worklet";runOnJS(de)(!1)}}},[s,a,r,i,ee,L,D,_,u,c,E,H,T,M,ye,pe,ve,de,F,G,z,J,$,q,Q,Y,U,Z]),ke=useMemo(()=>Se("low"),[Se]),Ce=useMemo(()=>Se("high"),[Se]),xe=usePanGesture(ke),Ae=usePanGesture(Ce),Ve=useCallback(e=>{if(s||L||R<=0)return;const t=clamp(e.nativeEvent.locationX,0,R),a=ae(t,R);a!==z.value&&(be(),z.value=a,F.value=withTiming(te(a,R),{duration:A.motion.duration.fast,easing:Easing.out(Easing.cubic)}),he(a,a))},[s,L,R,ae,te,he,be,F,z,A.motion.duration.fast]),je=useCallback(e=>{if(s)return;const t="increment"===e.nativeEvent.actionName?i:-i,n=i>0?Math.round(t*ee)/ee:t;if(L){const e=Math.round((z.value+n)*ee)/ee,t=clamp(e,a,J.value);t!==z.value&&(z.value=t,F.value=te(t,R),be(),he(t,J.value))}else{const e=Math.round((z.value+n)*ee)/ee,t=clamp(e,a,r);t!==z.value&&(z.value=t,F.value=te(t,R),be(),he(t,t))}},[s,i,ee,L,a,r,te,R,F,z,J,he,be]),Me=j.thumbDiameter/2,De=s?A.colors["surface-disabled"]:I,He="inset"===l?{backgroundColor:De,borderColor:A.colors.surface,borderWidth:Math.max(2,Math.round(.3*j.thumbDiameter)),...NO_SHADOW}:"minimal"===l?{backgroundColor:De,borderWidth:0}:"bar"===l?{backgroundColor:"transparent",borderWidth:0,...NO_SHADOW}:{backgroundColor:A.colors.surface,borderColor:De},Ee=useAnimatedStyle(()=>{const e=Z.value;if(e<=0)return{opacity:0,transform:[{translateX:0},{scaleX:1}]};const t=s?.55:1;if(L){const a=Math.max(0,G.value-F.value+2*M);return{opacity:t,transform:[{translateX:F.value-M},{scaleX:a/e}]}}return{opacity:t,transform:[{translateX:F.value+M-e},{scaleX:1}]}},[Z,s,L,G,F,M]),Oe=useAnimatedStyle(()=>({transform:[{translateX:F.value-Me},{scale:$.value}]}),[F,Me,$]),Te=useAnimatedStyle(()=>({transform:[{translateX:G.value-Me},{scale:q.value}]}),[G,Me,q]),Re=useAnimatedStyle(()=>({opacity:Q.value}),[Q]),Pe=useAnimatedStyle(()=>({opacity:Y.value}),[Y]),clampDisplay=e=>clamp(e,a,r),Ie=clampDisplay(isPair(X)?Math.min(...X):X),We=clampDisplay(isPair(X)?Math.max(...X):X);return _jsx(View,{ref:t,style:[O.container,f,g],testID:x,accessibilityRole:"adjustable",accessibilityLabel:h,accessibilityState:{disabled:s},"aria-disabled":s,accessibilityValue:L?{min:a,max:r,now:Ie,text:`${Ie} to ${We}`}:{min:a,max:r,now:Ie},accessibilityActions:[{name:"increment"},{name:"decrement"}],onAccessibilityAction:je,children:_jsx(Pressable,{onPress:Ve,disabled:s||L,style:O.trackTouch,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:_jsxs(View,{style:O.trackWrap,onLayout:me,children:[_jsxs(View,{style:O.trackClip,pointerEvents:"none",children:[_jsx(View,{style:[O.track,{backgroundColor:s?A.colors["surface-disabled"]:A.colors.border},p]}),_jsx(Animated.View,{style:[O.fill,{backgroundColor:s?A.colors["surface-disabled"]:I},v,Ee]})]}),_jsx(GestureDetector,{gesture:xe,children:_jsx(Animated.View,{style:[O.thumb,{width:j.thumbDiameter,height:j.thumbDiameter,borderRadius:Me,...smoothCorners,opacity:s?.55:1},He,w,Oe],accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:u?_jsxs(Animated.View,{style:[O.bubbleWrap,Re],pointerEvents:"none",children:[_jsx(View,{style:[O.bubble,{backgroundColor:I}],children:m?m(Ie):_jsx(Text,{variant:"caption",weight:"semibold",style:[{color:W},y],numberOfLines:1,children:d(Ie)})}),_jsx(View,{style:[O.bubbleCaret,{backgroundColor:I}]})]}):null})}),L?_jsx(GestureDetector,{gesture:Ae,children:_jsx(Animated.View,{style:[O.thumb,{width:j.thumbDiameter,height:j.thumbDiameter,borderRadius:Me,...smoothCorners,opacity:s?.55:1},He,w,Te],accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:u?_jsxs(Animated.View,{style:[O.bubbleWrap,Pe],pointerEvents:"none",children:[_jsx(View,{style:[O.bubble,{backgroundColor:I}],children:m?m(We):_jsx(Text,{variant:"caption",weight:"semibold",style:[{color:W},y],numberOfLines:1,children:d(We)})}),_jsx(View,{style:[O.bubbleCaret,{backgroundColor:I}]})]}):null})}):null]})})})});Slider.displayName="Slider";const buildStyles=(e,t)=>{const a=e.shadow.elevated,r=Math.max(t.thumbDiameter,t.trackHeight),i=r/2+e.space.xs;return StyleSheet.create({container:{width:"100%",paddingVertical:i,justifyContent:"center"},trackTouch:{width:"100%",justifyContent:"center"},trackWrap:{width:"100%",height:r,justifyContent:"center"},trackClip:{position:"absolute",left:0,right:0,height:t.trackHeight,top:(r-t.trackHeight)/2,borderRadius:t.trackHeight/2,...smoothCorners,overflow:"hidden"},track:{position:"absolute",top:0,right:0,bottom:0,left:0,borderRadius:t.trackHeight/2,...smoothCorners},fill:{position:"absolute",top:0,left:0,width:"100%",height:t.trackHeight,borderRadius:t.trackHeight/2,...smoothCorners,transformOrigin:"left"},thumb:{position:"absolute",top:(r-t.thumbDiameter)/2,left:0,borderWidth:2,shadowColor:a.shadowColor,shadowOffset:a.shadowOffset,shadowOpacity:a.shadowOpacity,shadowRadius:a.shadowRadius,elevation:a.elevation,alignItems:"center",justifyContent:"center"},bubbleWrap:{position:"absolute",bottom:t.thumbDiameter+2,left:t.thumbDiameter/2-80,width:160,alignItems:"center"},bubbleCaret:{width:8,height:8,marginTop:-5,borderRadius:e.radius.none,...smoothCorners,transform:[{rotate:"45deg"}]},bubble:{paddingHorizontal:e.space.sm,paddingVertical:e.space.xxs,borderRadius:e.radius.md,...smoothCorners,minWidth:36,alignItems:"center",justifyContent:"center",...Platform.select({ios:{shadowColor:e.shadow.card.shadowColor,shadowOffset:e.shadow.card.shadowOffset,shadowOpacity:e.shadow.card.shadowOpacity,shadowRadius:e.shadow.card.shadowRadius},android:{elevation:e.shadow.card.elevation},default:{}})}})};export{Slider};export default Slider;
@@ -1 +1 @@
1
- "use strict";import{forwardRef,useCallback,useMemo,useRef}from"react";import{Pressable,StyleSheet,TextInput,View}from"react-native";import{useControllableState}from"../../hooks/index.js";import{resolveFieldSize,useTheme}from"../../theme/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{hitSlopMarker}from"../../utils/hitSlop.js";import{AppIcon,renderSlotIcon}from"../AppIcon/index.js";import{FieldBase,FieldLabel,FieldMessage,hasFieldText,resolveFieldTextStyle}from"../FieldBase/FieldBase.js";import{IconButton}from"../IconButton/index.js";import{Slider}from"../Slider/index.js";import{CountingText,clampValue,sliderToneInk,snapValue,useValueDraft}from"../Slider/valueText.js";import{Text}from"../Text/index.js";import{Tooltip}from"../Tooltip/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_SLIDER_FIELD_LABELS=Object.freeze({about:e=>`About ${e}`,decrease:"Decrease",increase:"Increase",fallbackName:"Value",low:e=>`${e} low`,high:e=>`${e} high`,current:e=>`${e} value`});const DEFAULT_INPUT_WIDTH=72,defaultFormatValue=e=>String(e),stepDecimals=e=>String(e).split(".")[1]?.length??0,ValueBox=({draft:e,error:l,disabled:t,width:i,accessibilityLabel:s,styles:a,style:o,testID:r})=>{const n=useTheme(),d=resolveFieldSize(n,"sm"),c=resolveFieldTextStyle(n,{disabled:t}),u=useRef(null),m=useCallback(()=>{t||u.current?.focus()},[t]);return _jsx(FieldBase,{size:"sm",focused:e.editing,disabled:t,error:l,filled:!0,width:i,onPress:m,pressFeedback:!1,paddingHorizontal:n.space.sm,gap:n.space.xs,trailing:l?_jsx(AppIcon,{name:"info-circle",size:d.icon,color:n.colors["danger-text"]}):void 0,style:o,children:_jsx(TextInput,{ref:u,style:[a.boxInput,{color:c.color,fontSize:d.text,...c.weightStyle}],value:e.text,onChangeText:e.onChangeText,onFocus:e.onFocus,onBlur:e.onBlur,onSubmitEditing:e.onBlur,editable:!t,keyboardType:"decimal-pad",returnKeyType:"done",textAlign:"center",selectionColor:n.colors.primary,accessibilityLabel:s,accessibilityState:{disabled:t},"aria-disabled":t,testID:r})})},SliderField=forwardRef((e,l)=>{const{label:t,unit:i,info:s,required:a=!1,helperText:o,error:r,min:n=0,max:d=100,step:c=1,disabled:u=!1,tone:m="primary",size:p,variant:b,haptic:x,showBubble:h=!0,showBounds:f=!0,showInput:y=!1,showStepper:g=!1,leftIcon:S,rightIcon:I,startLabel:j,endLabel:T,formatValue:V=defaultFormatValue,parseInput:_,animationDuration:w,inputWidth:F=DEFAULT_INPUT_WIDTH,labels:v,accessibilityLabel:D,style:L,labelStyle:B,boundStyle:z,sliderStyle:C,inputStyle:A,testID:k}=e;assertValidValue("SliderField","tone",e.tone,["primary","success","warning","danger","info","neutral"]),assertValidValue("SliderField","size",e.size,["sm","md","lg"]),assertValidValue("SliderField","variant",e.variant,["default","inset","minimal","bar"]);const E=useMemo(()=>({...DEFAULT_SLIDER_FIELD_LABELS,...v}),[v]),M=useTheme(),$=useMemo(()=>buildStyles(M),[M]),R=w??M.motion.duration.fast,P=!0===e.range,N=!0===r||hasFieldText(r),W=stepDecimals(c),[U,H]=useControllableState({value:e.value,defaultValue:e.defaultValue??(P?[n,d]:n),onChange:e.onChange}),[q,K]=P?U:[U,d],O=clampValue(Math.min(q,K),n,d),G=clampValue(Math.max(q,K),n,d),J=useValueDraft({value:O,min:n,max:d,step:c,format:V,parse:_,onChange:e=>H(P?[Math.min(e,G),G]:e)}),Q=useValueDraft({value:G,min:n,max:d,step:c,format:V,parse:_,onChange:e=>H([O,Math.max(e,O)])}),stepBy=e=>{const l=snapValue(O+e*c,n,d,c);l!==O&&H(l)},X={color:u?M.colors["text-disabled"]:M.colors["text-muted"],size:resolveFieldSize(M,"md").icon,disabled:u},Y=[$.bubbleText,{color:sliderToneInk(M,m)}],boundText=e=>_jsx(Text,{variant:"bodySmall",style:[$.bound,{color:u?M.colors["text-disabled"]:M.colors["text-muted"]},z],children:e}),Z={min:n,max:d,step:c,disabled:u,tone:m,size:p,variant:b,haptic:x,showLabel:!!h&&"always",renderLabel:h?e=>_jsx(CountingText,{value:e,format:V,decimals:W,duration:R,style:Y,testID:k&&!P?`${k}-bubble`:void 0}):void 0,accessibilityLabel:D??t,style:C,testID:k?`${k}-slider`:void 0};return _jsxs(View,{ref:l,style:[$.container,L],testID:k,children:[t?_jsxs(View,{style:$.labelRow,children:[_jsx(FieldLabel,{required:a,style:B,children:t}),i?_jsx(Text,{variant:"caption",style:{color:M.colors["text-subtle"]},children:i}):null,s?_jsx(Tooltip,{content:s,trigger:"press",placement:"top",children:_jsx(Pressable,{accessibilityRole:"button",accessibilityLabel:E.about(t),hitSlop:8,...hitSlopMarker(8),style:$.infoButton,children:_jsx(AppIcon,{name:"info-circle",variant:"bold",size:16,color:M.colors["text-subtle"]})})}):null]}):null,_jsxs(View,{style:[$.row,h?$.rowWithBubble:null],children:[S?_jsx(View,{children:renderSlotIcon(S,X)}):null,g&&!P?_jsx(IconButton,{icon:e=>_jsx(AppIcon,{name:"minus",size:e.size,color:e.color}),onPress:()=>stepBy(-1),accessibilityLabel:E.decrease,variant:"ghost",tone:"neutral",size:"sm",disabled:u||O<=n,haptic:x,testID:k?`${k}-minus`:void 0}):null,P&&y?_jsx(ValueBox,{draft:J,error:N,disabled:u,width:F,accessibilityLabel:E.low(t??E.fallbackName),styles:$,style:A,testID:k?`${k}-input-low`:void 0}):f?boundText(j??V(n)):null,_jsx(View,{style:$.sliderWrap,children:_jsx(Slider,P?{...Z,range:!0,value:[O,G],onChange:H}:{...Z,value:O,onChange:H})}),P&&y?_jsx(ValueBox,{draft:Q,error:N,disabled:u,width:F,accessibilityLabel:E.high(t??E.fallbackName),styles:$,style:A,testID:k?`${k}-input-high`:void 0}):f?boundText(T??V(d)):null,g&&!P?_jsx(IconButton,{icon:e=>_jsx(AppIcon,{name:"add",size:e.size,color:e.color}),onPress:()=>stepBy(1),accessibilityLabel:E.increase,variant:"ghost",tone:"neutral",size:"sm",disabled:u||O>=d,haptic:x,testID:k?`${k}-plus`:void 0}):null,I?_jsx(View,{children:renderSlotIcon(I,X)}):null,!P&&y?_jsx(ValueBox,{draft:J,error:N,disabled:u,width:F,accessibilityLabel:E.current(t??E.fallbackName),styles:$,style:A,testID:k?`${k}-input`:void 0}):null]}),_jsx(FieldMessage,{text:N?r:o,error:N})]})});SliderField.displayName="SliderField";const buildStyles=e=>StyleSheet.create({container:{width:"100%"},labelRow:{flexDirection:"row",alignItems:"center",gap:e.space.xs},infoButton:{marginLeft:e.space.xxs},row:{flexDirection:"row",alignItems:"center",gap:e.space.sm},rowWithBubble:{marginTop:e.space.lg},sliderWrap:{flex:1,paddingHorizontal:e.space.sm},bound:{fontVariant:["tabular-nums"]},bubbleText:{fontVariant:["tabular-nums"]},boxInput:{flex:1,padding:e.space.none,margin:e.space.none,includeFontPadding:!1}});export{SliderField};export default SliderField;
1
+ "use strict";import{forwardRef,useCallback,useMemo,useRef}from"react";import{Pressable,StyleSheet,TextInput,View}from"react-native";import{useControllableState}from"../../hooks/index.js";import{resolveFieldSize,useTheme}from"../../theme/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{hitSlopMarker}from"../../utils/hitSlop.js";import{AppIcon,renderSlotIcon}from"../AppIcon/index.js";import{FieldBase,FieldLabel,FieldMessage,hasFieldText,resolveFieldTextStyle}from"../FieldBase/FieldBase.js";import{IconButton}from"../IconButton/index.js";import{Slider}from"../Slider/index.js";import{CountingText,clampValue,sliderToneInk,snapValue,useValueDraft}from"../Slider/valueText.js";import{Text}from"../Text/index.js";import{Tooltip}from"../Tooltip/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_SLIDER_FIELD_LABELS=Object.freeze({about:e=>`About ${e}`,decrease:"Decrease",increase:"Increase",fallbackName:"Value",low:e=>`${e} low`,high:e=>`${e} high`,current:e=>`${e} value`});const DEFAULT_INPUT_WIDTH=72,defaultFormatValue=e=>String(e),stepDecimals=e=>String(e).split(".")[1]?.length??0,ValueBox=({draft:e,error:l,disabled:t,width:i,accessibilityLabel:a,styles:s,style:r,testID:o})=>{const n=useTheme(),d=resolveFieldSize(n,"sm"),c=resolveFieldTextStyle(n,{disabled:t}),u=useRef(null),m=useCallback(()=>{t||u.current?.focus()},[t]);return _jsx(FieldBase,{size:"sm",focused:e.editing,disabled:t,error:l,filled:!0,width:i,onPress:m,pressFeedback:!1,paddingHorizontal:n.space.sm,gap:n.space.xs,trailing:l?_jsx(AppIcon,{name:"info-circle",size:d.icon,color:n.colors["danger-text"]}):void 0,style:r,children:_jsx(TextInput,{ref:u,style:[s.boxInput,{color:c.color,fontSize:d.text,...c.weightStyle}],value:e.text,onChangeText:e.onChangeText,onFocus:e.onFocus,onBlur:e.onBlur,onSubmitEditing:e.onBlur,editable:!t,keyboardType:"decimal-pad",returnKeyType:"done",textAlign:"center",selectionColor:n.colors.primary,accessibilityLabel:a,accessibilityState:{disabled:t},"aria-disabled":t,testID:o})})},SliderField=forwardRef((e,l)=>{const{label:t,unit:i,info:a,required:s=!1,helperText:r,error:o,min:n=0,max:d=100,step:c=1,disabled:u=!1,tone:m="primary",size:p,variant:b,haptic:x,showBubble:h=!0,showBounds:f=!0,showInput:y=!1,showStepper:g=!1,leftIcon:S,rightIcon:I,startLabel:j,endLabel:w,formatValue:v=defaultFormatValue,parseInput:F,animationDuration:T,inputWidth:V=DEFAULT_INPUT_WIDTH,labels:_,accessibilityLabel:D,style:L,labelStyle:B,boundStyle:z,sliderStyle:A,inputStyle:C,testID:k}=e;assertValidValue("SliderField","tone",e.tone,["primary","success","warning","danger","info","neutral"]),assertValidValue("SliderField","size",e.size,["sm","md","lg"]),assertValidValue("SliderField","variant",e.variant,["default","inset","minimal","bar"]);const E=useMemo(()=>({...DEFAULT_SLIDER_FIELD_LABELS,..._}),[_]),M=useTheme(),$=useMemo(()=>buildStyles(M),[M]),R=T??M.motion.duration.fast,P=!0===e.range,N=!0===o||hasFieldText(o),W=stepDecimals(c),U=useCallback(l=>{if(!0!==e.range){if(Array.isArray(l))throw new Error("SliderField received a range value in single mode.");e.onChange?.(l)}else{if(!Array.isArray(l))throw new Error("SliderField received a single value in range mode.");e.onChange?.(l)}},[e.onChange,e.range]),[H,q]=useControllableState({value:e.value,defaultValue:e.defaultValue??(P?[n,d]:n),onChange:U}),[K,O]=Array.isArray(H)?H:[H,d],G=clampValue(Math.min(K,O),n,d),J=clampValue(Math.max(K,O),n,d),Q=useValueDraft({value:G,min:n,max:d,step:c,format:v,parse:F,onChange:e=>q(P?[Math.min(e,J),J]:e)}),X=useValueDraft({value:J,min:n,max:d,step:c,format:v,parse:F,onChange:e=>q([G,Math.max(e,G)])}),stepBy=e=>{const l=snapValue(G+e*c,n,d,c);l!==G&&q(l)},Y={color:u?M.colors["text-disabled"]:M.colors["text-muted"],size:resolveFieldSize(M,"md").icon,disabled:u},Z=[$.bubbleText,{color:sliderToneInk(M,m)}],boundText=e=>_jsx(Text,{variant:"bodySmall",style:[$.bound,{color:u?M.colors["text-disabled"]:M.colors["text-muted"]},z],children:e}),ee={min:n,max:d,step:c,disabled:u,tone:m,size:p,variant:b,haptic:x,showLabel:!!h&&"always",renderLabel:h?e=>_jsx(CountingText,{value:e,format:v,decimals:W,duration:R,style:Z,testID:k&&!P?`${k}-bubble`:void 0}):void 0,accessibilityLabel:D??t,style:A,testID:k?`${k}-slider`:void 0};return _jsxs(View,{ref:l,style:[$.container,L],testID:k,children:[t?_jsxs(View,{style:$.labelRow,children:[_jsx(FieldLabel,{required:s,style:B,children:t}),i?_jsx(Text,{variant:"caption",style:{color:M.colors["text-subtle"]},children:i}):null,a?_jsx(Tooltip,{content:a,trigger:"press",placement:"top",children:_jsx(Pressable,{accessibilityRole:"button",accessibilityLabel:E.about(t),hitSlop:8,...hitSlopMarker(8),style:$.infoButton,children:_jsx(AppIcon,{name:"info-circle",variant:"bold",size:16,color:M.colors["text-subtle"]})})}):null]}):null,_jsxs(View,{style:[$.row,h?$.rowWithBubble:null],children:[S?_jsx(View,{children:renderSlotIcon(S,Y)}):null,g&&!P?_jsx(IconButton,{icon:e=>_jsx(AppIcon,{name:"minus",size:e.size,color:e.color}),onPress:()=>stepBy(-1),accessibilityLabel:E.decrease,variant:"ghost",tone:"neutral",size:"sm",disabled:u||G<=n,haptic:x,testID:k?`${k}-minus`:void 0}):null,P&&y?_jsx(ValueBox,{draft:Q,error:N,disabled:u,width:V,accessibilityLabel:E.low(t??E.fallbackName),styles:$,style:C,testID:k?`${k}-input-low`:void 0}):f?boundText(j??v(n)):null,_jsx(View,{style:$.sliderWrap,children:_jsx(Slider,P?{...ee,range:!0,value:[G,J],onChange:q}:{...ee,value:G,onChange:q})}),P&&y?_jsx(ValueBox,{draft:X,error:N,disabled:u,width:V,accessibilityLabel:E.high(t??E.fallbackName),styles:$,style:C,testID:k?`${k}-input-high`:void 0}):f?boundText(w??v(d)):null,g&&!P?_jsx(IconButton,{icon:e=>_jsx(AppIcon,{name:"add",size:e.size,color:e.color}),onPress:()=>stepBy(1),accessibilityLabel:E.increase,variant:"ghost",tone:"neutral",size:"sm",disabled:u||G>=d,haptic:x,testID:k?`${k}-plus`:void 0}):null,I?_jsx(View,{children:renderSlotIcon(I,Y)}):null,!P&&y?_jsx(ValueBox,{draft:Q,error:N,disabled:u,width:V,accessibilityLabel:E.current(t??E.fallbackName),styles:$,style:C,testID:k?`${k}-input`:void 0}):null]}),_jsx(FieldMessage,{text:N?o:r,error:N})]})});SliderField.displayName="SliderField";const buildStyles=e=>StyleSheet.create({container:{width:"100%"},labelRow:{flexDirection:"row",alignItems:"center",gap:e.space.xs},infoButton:{marginLeft:e.space.xxs},row:{flexDirection:"row",alignItems:"center",gap:e.space.sm},rowWithBubble:{marginTop:e.space.lg},sliderWrap:{flex:1,paddingHorizontal:e.space.sm},bound:{fontVariant:["tabular-nums"]},bubbleText:{fontVariant:["tabular-nums"]},boxInput:{flex:1,padding:e.space.none,margin:e.space.none,includeFontPadding:!1}});export{SliderField};export default SliderField;
@@ -1 +1 @@
1
- "use strict";import{useCallback,useEffect,useMemo,useRef,useState}from"react";import{StyleSheet,View}from"react-native";import{GestureDetector,usePanGesture}from"react-native-gesture-handler";import Animated,{cancelAnimation,measure,runOnJS,scrollTo,useAnimatedRef,useAnimatedScrollHandler,useAnimatedStyle,useFrameCallback,useSharedValue,withSpring}from"react-native-reanimated";import{useTheme}from"../../theme/index.js";import{triggerHaptic}from"../../utils/index.js";import{useScrollHost}from"../Screen/ScrollHost.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_SORTABLE_LIST_LABELS=Object.freeze({moveUp:"Move up",moveDown:"Move down"});const LONG_PRESS_MS=350,EDGE_PX=48,SCROLL_STEP_PX=12,SCROLL_SLACK_PX=1,SPRING_CONFIG={damping:22,stiffness:260,mass:1},ACTION_STEP={moveUp:-1,moveDown:1},noop=e=>{};export function moveItem(e,t,a){const l=e.slice();if(t<0||t>=l.length)return l;const[o]=l.splice(t,1);return l.splice(a,0,o),l}export function topOf(e,t){"worklet";let a=0;for(let l=0;l<t;l++)a+=e[l]??0;return a}export function slotTop(e,t,a){"worklet";let l=0,o=0;for(let r=0;r<e.length&&o<a;r++)r!==t&&(l+=e[r]??0,o++);return l}export function dropIndex(e,t,a){"worklet";const l=topOf(e,t)+(e[t]??0)/2+a;let o=0,r=0;for(let a=0;a<e.length;a++){const s=e[a]??0;a!==t&&r+s/2<l&&o++,r+=s}return o}export function rowShifts(e,t,a){const l=[];let o=0;for(const t of e)l.push(o),o+=t;const r=e.map(()=>0),s=moveItem(e.map((e,t)=>t),t,a);let n=0;for(const t of s)r[t]=n-(l[t]??0),n+=e[t]??0;return r}const buildStyles=e=>StyleSheet.create({handleRow:{flexDirection:"row",alignItems:"center"},handle:{paddingHorizontal:e.space.sm,paddingVertical:e.space.md,gap:e.space.xxs},bar:{width:e.space.md,height:e.space.xxs,backgroundColor:e.colors["text-muted"]},body:{flex:1}});function SortableRow({rowKey:e,index:t,count:a,shift:l,isActive:o,dragging:r,handle:s,disabled:n,shared:u,callbacks:i,labels:c,children:d}){const m=useTheme(),v=useMemo(()=>buildStyles(m),[m]),h=useSharedValue(0);useEffect(()=>{h.value=r&&!o?withSpring(l,SPRING_CONFIG):l},[r,o,l,h]),useEffect(()=>()=>{cancelAnimation(h)},[h]);const S=useAnimatedStyle(()=>({transform:[{translateY:o?u.dragY.value:h.value}],zIndex:o?1:0}),[o,u,h]),f=useMemo(()=>{const{dragIndex:e,dropTo:a,dragY:l,translation:o,absoluteY:r,scrollY:c,scrollStart:d,hostOffset:m,hostStart:v,hostTarget:h,heights:S}=u,{onLift:f,onDrop:g,onSettled:p}=i;return{enabled:!n,activateAfterLongPress:s?void 0:350,onActivate:s=>{"worklet";r.value=s.absoluteY,e.value=t,a.value=t,d.value=c.value,v.value=m.value,h.value=m.value,o.value=0,l.value=0,runOnJS(f)(t)},onUpdate:a=>{"worklet";e.value===t&&(o.value=a.translationY,r.value=a.absoluteY)},onFinalize:()=>{"worklet";if(e.value!==t)return;const o=a.value,r=S.value;e.value=-1,l.value=topOf(r,t)+l.value-slotTop(r,t,o),l.value=withSpring(0,SPRING_CONFIG,e=>{"worklet";e&&runOnJS(p)()}),runOnJS(g)(t,o)}}},[n,s,t,i,u]),g=usePanGesture(f),p=n?[]:[...t>0?[{name:"moveUp",label:c.moveUp}]:[],...t<a-1?[{name:"moveDown",label:c.moveDown}]:[]];return _jsx(Animated.View,{style:S,onLayout:t=>i.onHeight(e,t.nativeEvent.layout.height),accessibilityActions:p,onAccessibilityAction:e=>{if(n)return;const l=t+(ACTION_STEP[e.nativeEvent.actionName]??0);l!==t&&l>=0&&l<a&&i.onMove(t,l)},testID:`sortable-row-${e}`,children:s?_jsxs(View,{style:v.handleRow,children:[_jsx(GestureDetector,{gesture:g,children:_jsxs(View,{style:v.handle,children:[_jsx(View,{style:v.bar}),_jsx(View,{style:v.bar}),_jsx(View,{style:v.bar})]})}),_jsx(View,{style:v.body,children:d})]}):_jsx(GestureDetector,{gesture:g,children:_jsx(View,{children:d})})})}export function SortableList(e){const{data:t,keyExtractor:a,renderItem:l,onReorder:o,handle:r=!1,disabled:s=!1,accessibilityLabel:n,labels:u,testID:i}=e,c=useMemo(()=>({...DEFAULT_SORTABLE_LIST_LABELS,...u}),[u]),d=useMemo(()=>t.map((e,t)=>({key:a(e,t),item:e})),[t,a]),m=useMemo(()=>d.map(e=>e.key),[d]),v=useAnimatedRef(),h=useSharedValue(0),S=useSharedValue(0),f=useSharedValue(0),g=useScrollHost(),p=useSharedValue(0),b=null!==g,x=g?.top??p,w=g?.bottom??p,y=g?.offset??p,_=g?.maxOffset??p,k=g?.scrollTo??noop,A=useSharedValue(0),L=useSharedValue(0),O=useSharedValue(0),V=useSharedValue(0),I=useSharedValue(-1),T=useSharedValue(-1),C=useSharedValue(0),E=useSharedValue([]),j=useRef(new Map),M=useRef(m),[R,D]=useState(null),Y=useCallback(()=>{E.value=M.current.map(e=>j.current.get(e)??0)},[E]);useEffect(()=>{M.current=m,Y()},[m,Y]),useEffect(()=>()=>{cancelAnimation(C)},[C]);const P=useCallback(e=>{D(t=>t?.dragging?{...t,to:e}:t)},[]),G=useFrameCallback(()=>{"worklet";const e=I.value;if(e<0)return;const t=measure(v);if(t){const e=b?Math.max(t.pageY,x.value):t.pageY,a=b?Math.min(t.pageY+t.height,w.value):t.pageY+t.height,l=Math.max(0,f.value-t.height-1);V.value<e+48?h.value>1?scrollTo(v,0,Math.max(0,h.value-12),!1):b&&L.value>0&&(L.value=Math.max(0,L.value-12),runOnJS(k)(L.value)):V.value>a-48&&(h.value<l?scrollTo(v,0,Math.min(l,h.value+12),!1):b&&L.value<_.value&&(L.value=Math.min(_.value,L.value+12),runOnJS(k)(L.value)))}C.value=O.value+h.value-S.value+y.value-A.value;const a=dropIndex(E.value,e,C.value);a!==T.value&&(T.value=a,runOnJS(P)(a))},!1),N=useCallback(e=>{triggerHaptic("longPress"),G.setActive(!0),D({key:m[e]??"",from:e,to:e,dragging:!0})},[G,m]),H=useCallback((e,t)=>{G.setActive(!1),D(e=>e?{...e,to:t,dragging:!1}:e),t!==e&&o(moveItem(m,e,t))},[G,m,o]),F=useCallback(()=>{D(e=>e&&!e.dragging?null:e)},[]),J=useCallback((e,t)=>{o(moveItem(m,e,t))},[m,o]),U=useCallback((e,t)=>{j.current.set(e,t),Y()},[Y]),z=useAnimatedScrollHandler({onScroll:e=>{"worklet";h.value=e.contentOffset.y}}),B=useCallback((e,t)=>{f.value=t},[f]),K=useMemo(()=>({scrollRef:v,scrollY:h,scrollStart:S,hostOffset:y,hostStart:A,hostTarget:L,translation:O,absoluteY:V,dragIndex:I,dropTo:T,dragY:C,heights:E}),[v,h,S,y,A,L,O,V,I,T,C,E]),X=useMemo(()=>({onLift:N,onDrop:H,onSettled:F,onMove:J,onHeight:U}),[N,H,F,J,U]),$=!0===R?.dragging,q=$&&R?rowShifts(m.map(e=>j.current.get(e)??0),R.from,R.to):null;return _jsx(Animated.ScrollView,{ref:v,onScroll:z,onContentSizeChange:B,scrollEventThrottle:16,scrollEnabled:!$,accessibilityLabel:n,testID:i,children:d.map((e,t)=>{const a=R?.key===e.key;return _jsx(SortableRow,{rowKey:e.key,index:t,count:d.length,shift:q?.[t]??0,isActive:a,dragging:$,handle:r,disabled:s,shared:K,callbacks:X,labels:c,children:l({item:e.item,index:t,isActive:a})},e.key)})})}SortableList.displayName="SortableList";export default SortableList;
1
+ "use strict";import{useCallback,useEffect,useMemo,useRef,useState}from"react";import{StyleSheet,View}from"react-native";import{GestureDetector,usePanGesture}from"react-native-gesture-handler";import Animated,{cancelAnimation,measure,runOnJS,scrollTo,useAnimatedRef,useAnimatedScrollHandler,useAnimatedStyle,useFrameCallback,useSharedValue,withSpring}from"react-native-reanimated";import{useTheme}from"../../theme/index.js";import{triggerHaptic}from"../../utils/index.js";import{useScrollHost}from"../Screen/ScrollHost.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_SORTABLE_LIST_LABELS=Object.freeze({moveUp:"Move up",moveDown:"Move down"});const LONG_PRESS_MS=350,EDGE_PX=48,SCROLL_STEP_PX=12,SCROLL_SLACK_PX=1,SPRING_CONFIG={damping:22,stiffness:260,mass:1},ACTION_STEP={moveUp:-1,moveDown:1},noop=e=>{};export function moveItem(e,t,a){const l=e.slice();if(t<0||t>=l.length)return l;const[o]=l.splice(t,1);return void 0===o||l.splice(a,0,o),l}export function topOf(e,t){"worklet";let a=0;for(let l=0;l<t;l++)a+=e[l]??0;return a}export function slotTop(e,t,a){"worklet";let l=0,o=0;for(let r=0;r<e.length&&o<a;r++)r!==t&&(l+=e[r]??0,o++);return l}export function dropIndex(e,t,a){"worklet";const l=topOf(e,t)+(e[t]??0)/2+a;let o=0,r=0;for(let a=0;a<e.length;a++){const s=e[a]??0;a!==t&&r+s/2<l&&o++,r+=s}return o}export function rowShifts(e,t,a){const l=[];let o=0;for(const t of e)l.push(o),o+=t;const r=e.map(()=>0),s=moveItem(e.map((e,t)=>t),t,a);let n=0;for(const t of s)r[t]=n-(l[t]??0),n+=e[t]??0;return r}const buildStyles=e=>StyleSheet.create({handleRow:{flexDirection:"row",alignItems:"center"},handle:{paddingHorizontal:e.space.sm,paddingVertical:e.space.md,gap:e.space.xxs},bar:{width:e.space.md,height:e.space.xxs,backgroundColor:e.colors["text-muted"]},body:{flex:1}});function SortableRow({rowKey:e,index:t,count:a,shift:l,isActive:o,dragging:r,handle:s,disabled:n,shared:u,callbacks:i,labels:c,children:d}){const m=useTheme(),v=useMemo(()=>buildStyles(m),[m]),h=useSharedValue(0);useEffect(()=>{h.value=r&&!o?withSpring(l,SPRING_CONFIG):l},[r,o,l,h]),useEffect(()=>()=>{cancelAnimation(h)},[h]);const S=useAnimatedStyle(()=>({transform:[{translateY:o?u.dragY.value:h.value}],zIndex:o?1:0}),[o,u,h]),f=useMemo(()=>{const{dragIndex:e,dropTo:a,dragY:l,translation:o,absoluteY:r,scrollY:c,scrollStart:d,hostOffset:m,hostStart:v,hostTarget:h,heights:S}=u,{onLift:f,onDrop:g,onSettled:p}=i;return{enabled:!n,...s?{}:{activateAfterLongPress:350},onActivate:s=>{"worklet";r.value=s.absoluteY,e.value=t,a.value=t,d.value=c.value,v.value=m.value,h.value=m.value,o.value=0,l.value=0,runOnJS(f)(t)},onUpdate:a=>{"worklet";e.value===t&&(o.value=a.translationY,r.value=a.absoluteY)},onFinalize:()=>{"worklet";if(e.value!==t)return;const o=a.value,r=S.value;e.value=-1,l.value=topOf(r,t)+l.value-slotTop(r,t,o),l.value=withSpring(0,SPRING_CONFIG,e=>{"worklet";e&&runOnJS(p)()}),runOnJS(g)(t,o)}}},[n,s,t,i,u]),g=usePanGesture(f),p=n?[]:[...t>0?[{name:"moveUp",label:c.moveUp}]:[],...t<a-1?[{name:"moveDown",label:c.moveDown}]:[]];return _jsx(Animated.View,{style:S,onLayout:t=>i.onHeight(e,t.nativeEvent.layout.height),accessibilityActions:p,onAccessibilityAction:e=>{if(n)return;const l=t+(ACTION_STEP[e.nativeEvent.actionName]??0);l!==t&&l>=0&&l<a&&i.onMove(t,l)},testID:`sortable-row-${e}`,children:s?_jsxs(View,{style:v.handleRow,children:[_jsx(GestureDetector,{gesture:g,children:_jsxs(View,{style:v.handle,children:[_jsx(View,{style:v.bar}),_jsx(View,{style:v.bar}),_jsx(View,{style:v.bar})]})}),_jsx(View,{style:v.body,children:d})]}):_jsx(GestureDetector,{gesture:g,children:_jsx(View,{children:d})})})}export function SortableList(e){const{data:t,keyExtractor:a,renderItem:l,onReorder:o,handle:r=!1,disabled:s=!1,accessibilityLabel:n,labels:u,testID:i}=e,c=useMemo(()=>({...DEFAULT_SORTABLE_LIST_LABELS,...u}),[u]),d=useMemo(()=>t.map((e,t)=>({key:a(e,t),item:e})),[t,a]),m=useMemo(()=>d.map(e=>e.key),[d]),v=useAnimatedRef(),h=useSharedValue(0),S=useSharedValue(0),f=useSharedValue(0),g=useScrollHost(),p=useSharedValue(0),b=null!==g,x=g?.top??p,w=g?.bottom??p,y=g?.offset??p,_=g?.maxOffset??p,k=g?.scrollTo??noop,A=useSharedValue(0),L=useSharedValue(0),O=useSharedValue(0),V=useSharedValue(0),I=useSharedValue(-1),T=useSharedValue(-1),C=useSharedValue(0),E=useSharedValue([]),j=useRef(new Map),M=useRef(m),[R,D]=useState(null),Y=useCallback(()=>{E.value=M.current.map(e=>j.current.get(e)??0)},[E]);useEffect(()=>{M.current=m,Y()},[m,Y]),useEffect(()=>()=>{cancelAnimation(C)},[C]);const P=useCallback(e=>{D(t=>t?.dragging?{...t,to:e}:t)},[]),G=useFrameCallback(()=>{"worklet";const e=I.value;if(e<0)return;const t=measure(v);if(t){const e=b?Math.max(t.pageY,x.value):t.pageY,a=b?Math.min(t.pageY+t.height,w.value):t.pageY+t.height,l=Math.max(0,f.value-t.height-1);V.value<e+48?h.value>1?scrollTo(v,0,Math.max(0,h.value-12),!1):b&&L.value>0&&(L.value=Math.max(0,L.value-12),runOnJS(k)(L.value)):V.value>a-48&&(h.value<l?scrollTo(v,0,Math.min(l,h.value+12),!1):b&&L.value<_.value&&(L.value=Math.min(_.value,L.value+12),runOnJS(k)(L.value)))}C.value=O.value+h.value-S.value+y.value-A.value;const a=dropIndex(E.value,e,C.value);a!==T.value&&(T.value=a,runOnJS(P)(a))},!1),N=useCallback(e=>{triggerHaptic("longPress"),G.setActive(!0),D({key:m[e]??"",from:e,to:e,dragging:!0})},[G,m]),H=useCallback((e,t)=>{G.setActive(!1),D(e=>e?{...e,to:t,dragging:!1}:e),t!==e&&o(moveItem(m,e,t))},[G,m,o]),F=useCallback(()=>{D(e=>e&&!e.dragging?null:e)},[]),J=useCallback((e,t)=>{o(moveItem(m,e,t))},[m,o]),U=useCallback((e,t)=>{j.current.set(e,t),Y()},[Y]),z=useAnimatedScrollHandler({onScroll:e=>{"worklet";h.value=e.contentOffset.y}}),B=useCallback((e,t)=>{f.value=t},[f]),K=useMemo(()=>({scrollRef:v,scrollY:h,scrollStart:S,hostOffset:y,hostStart:A,hostTarget:L,translation:O,absoluteY:V,dragIndex:I,dropTo:T,dragY:C,heights:E}),[v,h,S,y,A,L,O,V,I,T,C,E]),X=useMemo(()=>({onLift:N,onDrop:H,onSettled:F,onMove:J,onHeight:U}),[N,H,F,J,U]),$=!0===R?.dragging,q=$&&R?rowShifts(m.map(e=>j.current.get(e)??0),R.from,R.to):null;return _jsx(Animated.ScrollView,{ref:v,onScroll:z,onContentSizeChange:B,scrollEventThrottle:16,scrollEnabled:!$,accessibilityLabel:n,testID:i,children:d.map((e,t)=>{const a=R?.key===e.key;return _jsx(SortableRow,{rowKey:e.key,index:t,count:d.length,shift:q?.[t]??0,isActive:a,dragging:$,handle:r,disabled:s,shared:K,callbacks:X,labels:c,children:l({item:e.item,index:t,isActive:a})},e.key)})})}SortableList.displayName="SortableList";export default SortableList;
@@ -1 +1 @@
1
- "use strict";import{formatNumber}from"@webority/mobile-core";import{forwardRef,useCallback,useMemo,useState}from"react";import{StyleSheet,View}from"react-native";import Svg,{Circle,Path}from"react-native-svg";import{useTheme}from"../../theme/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{finiteValues,sparklineGeometry}from"./geometry.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_SPARKLINE_LABELS=Object.freeze({noData:"no data",range:(e,t,r,o)=>`from ${e} to ${t}, low ${r}, high ${o}`});const DOT_RADIUS=3,lineColor=(e,t)=>"neutral"===t?e.colors["text-muted"]:e.colors[`${t}-text`],defaultFormat=e=>formatNumber(e),Sparkline=forwardRef((e,t)=>{const{data:r,tone:o="primary",color:i,fill:a=!1,highlightLast:s=!0,height:l=32,width:n,strokeWidth:m=2,label:c,formatLabel:u=defaultFormat,accessibilityLabel:h,labels:d,style:f,testID:p}=e;assertValidValue("Sparkline","tone",e.tone,["primary","success","warning","danger","info","neutral"]);const y=useMemo(()=>({...DEFAULT_SPARKLINE_LABELS,...d}),[d]),x=useTheme(),[S,g]=useState(0),v=n??S,k=useCallback(e=>{if(void 0===n){const t=Math.round(e.nativeEvent.layout.width);g(e=>e===t?e:t)}},[n]),w=Math.max(3,m/2)+1,b=useMemo(()=>sparklineGeometry(r,v,l,w),[r,v,l,w]),$=i??lineColor(x,o),j=useMemo(()=>{if(void 0!==h)return h;const e=finiteValues(r),t=c?`${c}, `:"",[o]=e;if(void 0===o)return`${t}${y.noData}`;if(1===e.length)return`${t}${u(o)}`;const i=e[e.length-1];if(void 0===i)throw new Error("A sparkline with two or more finite values has a last value.");const a=u(o),s=u(i),l=u(Math.min(...e)),n=u(Math.max(...e));return`${t}${y.range(a,s,l,n)}`},[h,r,u,c,y]);return _jsx(View,{ref:t,accessible:!0,accessibilityRole:"image",accessibilityLabel:j,testID:p,onLayout:k,style:[styles.root,void 0===n?styles.stretch:{width:n},{height:l},f],children:""===b.line?null:_jsxs(Svg,{width:v,height:l,viewBox:`0 0 ${v} ${l}`,children:[a?_jsx(Path,{d:b.area,fill:$,fillOpacity:.14,stroke:"none"}):null,_jsx(Path,{d:b.line,fill:"none",stroke:$,strokeWidth:m,strokeLinecap:"round",strokeLinejoin:"round",testID:p?`${p}-line`:void 0}),s&&b.last?_jsx(Circle,{cx:b.last.x,cy:b.last.y,r:3,fill:$,testID:p?`${p}-dot`:void 0}):null]})})});Sparkline.displayName="Sparkline";const styles=StyleSheet.create({root:{overflow:"hidden"},stretch:{alignSelf:"stretch"}});export{Sparkline};export default Sparkline;
1
+ "use strict";import{formatNumber}from"@webority/mobile-core";import{forwardRef,useCallback,useMemo,useState}from"react";import{StyleSheet,View}from"react-native";import Svg,{Circle,Path}from"react-native-svg";import{useTheme}from"../../theme/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{finiteValues,sparklineGeometry}from"./geometry.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_SPARKLINE_LABELS=Object.freeze({noData:"no data",range:(e,t,r,o)=>`from ${e} to ${t}, low ${r}, high ${o}`});const DOT_RADIUS=3,lineColor=(e,t)=>{if("neutral"===t)return e.colors["text-muted"];const r=`${t}-text`;return e.colors[r]},defaultFormat=e=>formatNumber(e),Sparkline=forwardRef((e,t)=>{const{data:r,tone:o="primary",color:a,fill:i=!1,highlightLast:s=!0,height:l=32,width:n,strokeWidth:m=2,label:c,formatLabel:u=defaultFormat,accessibilityLabel:h,labels:f,style:d,testID:p}=e;assertValidValue("Sparkline","tone",e.tone,["primary","success","warning","danger","info","neutral"]);const y=useMemo(()=>({...DEFAULT_SPARKLINE_LABELS,...f}),[f]),x=useTheme(),[S,g]=useState(0),k=n??S,w=useCallback(e=>{if(void 0===n){const t=Math.round(e.nativeEvent.layout.width);g(e=>e===t?e:t)}},[n]),b=Math.max(3,m/2)+1,v=useMemo(()=>sparklineGeometry(r,k,l,b),[r,k,l,b]),$=a??lineColor(x,o),j=useMemo(()=>{if(void 0!==h)return h;const e=finiteValues(r),t=c?`${c}, `:"",[o]=e;if(void 0===o)return`${t}${y.noData}`;if(1===e.length)return`${t}${u(o)}`;const a=e[e.length-1];if(void 0===a)throw new Error("A sparkline with two or more finite values has a last value.");const i=u(o),s=u(a),l=u(Math.min(...e)),n=u(Math.max(...e));return`${t}${y.range(i,s,l,n)}`},[h,r,u,c,y]);return _jsx(View,{ref:t,accessible:!0,accessibilityRole:"image",accessibilityLabel:j,testID:p,onLayout:w,style:[styles.root,void 0===n?styles.stretch:{width:n},{height:l},d],children:""===v.line?null:_jsxs(Svg,{width:k,height:l,viewBox:`0 0 ${k} ${l}`,children:[i?_jsx(Path,{d:v.area,fill:$,fillOpacity:.14,stroke:"none"}):null,_jsx(Path,{d:v.line,fill:"none",stroke:$,strokeWidth:m,strokeLinecap:"round",strokeLinejoin:"round",...p?{testID:`${p}-line`}:{}}),s&&v.last?_jsx(Circle,{cx:v.last.x,cy:v.last.y,r:3,fill:$,...p?{testID:`${p}-dot`}:{}}):null]})})});Sparkline.displayName="Sparkline";const styles=StyleSheet.create({root:{overflow:"hidden"},stretch:{alignSelf:"stretch"}});export{Sparkline};export default Sparkline;
@@ -1 +1 @@
1
- "use strict";import{useCallback,useState}from"react";import{Animated,Platform,StyleSheet,View}from"react-native";import Svg,{Path}from"react-native-svg";import{useTheme}from"../../theme/index.js";import{squircleApplies,squirclePath}from"../../utils/squircle.js";import{jsx as _jsx}from"react/jsx-runtime";const AnimatedPath=Animated.createAnimatedComponent(Path);export function SquircleFill({width:t,height:e,radius:i,fill:r,stroke:s,strokeWidth:o=0,testID:l}){const a=o>0&&void 0!==s&&"transparent"!==s,n=a?o/2:0,h=useTheme().cornerSmoothing,u=squirclePath({width:t,height:e,radius:i,inset:n,smoothing:h});return _jsx(View,{pointerEvents:"none",style:styles.overlay,testID:l,children:_jsx(Svg,{width:t,height:e,viewBox:`0 0 ${t} ${e}`,children:_jsx(AnimatedPath,{d:u,fill:r,stroke:a?s:void 0,strokeWidth:a?o:void 0})})})}SquircleFill.displayName="SquircleFill";export function useSquircle(t,e,i){const[r,s]=useState(null),o=t&&"android"===Platform.OS;return{onLayout:useCallback(t=>{if(o){const{width:e,height:i}=t.nativeEvent.layout;s(t=>t&&t.width===e&&t.height===i?t:{width:e,height:i})}i?.(t)},[o,i]),size:r,active:o&&null!==r&&squircleApplies(r.width,r.height,e)}}const styles=StyleSheet.create({overlay:{position:"absolute",top:0,left:0,right:0,bottom:0}});
1
+ "use strict";import{useCallback,useState}from"react";import{Animated,Platform,StyleSheet,View}from"react-native";import Svg,{Path}from"react-native-svg";import{useTheme}from"../../theme/index.js";import{squircleApplies,squirclePath}from"../../utils/squircle.js";import{jsx as _jsx}from"react/jsx-runtime";const AnimatedPath=Animated.createAnimatedComponent(Path);export function SquircleFill({width:t,height:e,radius:i,fill:r,stroke:s,strokeWidth:o=0,testID:l}){const a=o>0&&void 0!==s&&"transparent"!==s,n=a?o/2:0,h=useTheme().cornerSmoothing,u=squirclePath({width:t,height:e,radius:i,inset:n,smoothing:h});return _jsx(View,{pointerEvents:"none",style:styles.overlay,testID:l,children:_jsx(Svg,{width:t,height:e,viewBox:`0 0 ${t} ${e}`,children:_jsx(AnimatedPath,{d:u,fill:r,...a?{stroke:s,strokeWidth:o}:{}})})})}SquircleFill.displayName="SquircleFill";export function useSquircle(t,e,i){const[r,s]=useState(null),o=t&&"android"===Platform.OS;return{onLayout:useCallback(t=>{if(o){const{width:e,height:i}=t.nativeEvent.layout;s(t=>t&&t.width===e&&t.height===i?t:{width:e,height:i})}i?.(t)},[o,i]),size:r,active:o&&null!==r&&squircleApplies(r.width,r.height,e)}}const styles=StyleSheet.create({overlay:{position:"absolute",top:0,left:0,right:0,bottom:0}});
@@ -1 +1 @@
1
- "use strict";import{formatPercent}from"@webority/mobile-core";import{forwardRef,useMemo}from"react";import{StyleSheet,View}from"react-native";import{useTheme}from"../../theme/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{AppIcon}from"../AppIcon/index.js";import{Card}from"../Card/index.js";import{IconBadge}from"../IconBadge/index.js";import{Skeleton}from"../Skeleton/index.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_STAT_TILE_LABELS=Object.freeze({trendUp:"up",trendDown:"down",trendFlat:"no change"});const isText=e=>"string"==typeof e||"number"==typeof e,TREND_ICON={up:"arrow-up",down:"arrow-down",flat:"minus"},TREND_SIGN={up:"+",down:"-",flat:""},percentText=e=>formatPercent(Math.abs(e),{scale:"percent",maximumFractionDigits:1}),trendFigure=e=>"number"==typeof e.value?`${TREND_SIGN[e.direction]}${percentText(e.value)}`:e.value,trendSpoken=(e,t)=>{const n=[{up:t.trendUp,down:t.trendDown,flat:t.trendFlat}[e.direction]];return"flat"!==e.direction&&n.push("number"==typeof e.value?percentText(e.value):e.value),e.period&&n.push(e.period),n.join(" ")},StatTile=forwardRef((e,t)=>{const{label:n,value:r,icon:i,iconVariant:s,tone:o="primary",caption:a,trend:l,sparkline:d,onPress:c,loading:p=!1,accessibilityLabel:x,labels:m,style:u,testID:h}=e,f=useTheme();assertValidValue("StatTile","tone",e.tone,["primary","success","warning","danger","info","neutral"]),assertValidValue("StatTile","trend.direction",l?.direction,["up","down","flat"]),assertValidValue("StatTile","trend.goodWhen",l?.goodWhen,["up","down"]);const T=useMemo(()=>({...DEFAULT_STAT_TILE_LABELS,...m}),[m]),y=l?`, ${trendSpoken(l,T)}`:"",j=isText(n)?`${n}, `:"",w=x??(isText(r)?`${j}${r}${y}`:void 0),_=!!l&&l.direction===(l.goodWhen??"up"),S=l&&"flat"!==l.direction?_?"success":"danger":"secondary",g="secondary"===S?f.colors["text-muted"]:f.colors[`${S}-text`];return _jsx(Card,p?{ref:t,variant:"outline",style:u,testID:h,children:_jsxs(View,{style:[styles.row,{columnGap:f.space.md}],children:[void 0===i?null:_jsx(Skeleton,{shape:"circle",width:40,height:40}),_jsxs(View,{style:styles.text,children:[_jsx(Skeleton,{shape:"text",width:"50%",height:12}),_jsx(Skeleton,{shape:"text",width:"35%",height:24,style:{marginTop:f.space.xs}})]})]})}:{ref:t,variant:"outline",onPress:c,accessibilityLabel:w,style:u,testID:h,children:_jsxs(View,{style:[styles.row,{columnGap:f.space.md}],children:[void 0===i?null:_jsx(IconBadge,{icon:i,iconVariant:s,tone:o}),_jsxs(View,{style:styles.text,children:[_jsx(Text,{variant:"caption",color:"secondary",numberOfLines:1,children:n}),isText(r)?_jsx(Text,{variant:"h3",numberOfLines:1,children:r}):r,l?_jsxs(View,{style:[styles.trend,{columnGap:f.space.xxs}],testID:h?`${h}-trend`:void 0,children:[_jsx(View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:_jsx(AppIcon,{name:TREND_ICON[l.direction],size:"xs",color:g})}),_jsxs(Text,{variant:"caption",color:S,numberOfLines:2,style:styles.text,children:[trendFigure(l),l.period?_jsx(Text,{variant:"caption",color:"tertiary",children:` ${l.period}`}):null]})]}):null,null==a||""===a?null:isText(a)?_jsx(Text,{variant:"caption",color:"tertiary",numberOfLines:1,children:a}):a,null==d?null:_jsx(View,{style:{marginTop:f.space.sm},children:d})]})]})})});StatTile.displayName="StatTile";const styles=StyleSheet.create({row:{flexDirection:"row",alignItems:"center"},text:{flex:1,minWidth:0},trend:{flexDirection:"row",alignItems:"center"}});export{StatTile};export default StatTile;
1
+ "use strict";import{formatPercent}from"@webority/mobile-core";import{forwardRef,useMemo}from"react";import{StyleSheet,View}from"react-native";import{useTheme}from"../../theme/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{AppIcon}from"../AppIcon/index.js";import{Card}from"../Card/index.js";import{IconBadge}from"../IconBadge/index.js";import{Skeleton}from"../Skeleton/index.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_STAT_TILE_LABELS=Object.freeze({trendUp:"up",trendDown:"down",trendFlat:"no change"});const isText=e=>"string"==typeof e||"number"==typeof e,TREND_ICON={up:"arrow-up",down:"arrow-down",flat:"minus"},TREND_SIGN={up:"+",down:"-",flat:""},trendToneTextKey=e=>`${e}-text`,percentText=e=>formatPercent(Math.abs(e),{scale:"percent",maximumFractionDigits:1}),trendFigure=e=>"number"==typeof e.value?`${TREND_SIGN[e.direction]}${percentText(e.value)}`:e.value,trendSpoken=(e,t)=>{const n=[{up:t.trendUp,down:t.trendDown,flat:t.trendFlat}[e.direction]];return"flat"!==e.direction&&n.push("number"==typeof e.value?percentText(e.value):e.value),e.period&&n.push(e.period),n.join(" ")},StatTile=forwardRef((e,t)=>{const{label:n,value:r,icon:i,iconVariant:s,tone:o="primary",caption:a,trend:l,sparkline:d,onPress:c,loading:p=!1,accessibilityLabel:x,labels:m,style:u,testID:T}=e,h=useTheme();assertValidValue("StatTile","tone",e.tone,["primary","success","warning","danger","info","neutral"]),assertValidValue("StatTile","trend.direction",l?.direction,["up","down","flat"]),assertValidValue("StatTile","trend.goodWhen",l?.goodWhen,["up","down"]);const f=useMemo(()=>({...DEFAULT_STAT_TILE_LABELS,...m}),[m]),y=l?`, ${trendSpoken(l,f)}`:"",j=isText(n)?`${n}, `:"",w=x??(isText(r)?`${j}${r}${y}`:void 0),_=!!l&&l.direction===(l.goodWhen??"up"),S=l&&"flat"!==l.direction?_?"success":"danger":"secondary",g="secondary"===S?h.colors["text-muted"]:h.colors[trendToneTextKey(S)];return _jsx(Card,p?{ref:t,variant:"outline",style:u,testID:T,children:_jsxs(View,{style:[styles.row,{columnGap:h.space.md}],children:[void 0===i?null:_jsx(Skeleton,{shape:"circle",width:40,height:40}),_jsxs(View,{style:styles.text,children:[_jsx(Skeleton,{shape:"text",width:"50%",height:12}),_jsx(Skeleton,{shape:"text",width:"35%",height:24,style:{marginTop:h.space.xs}})]})]})}:{ref:t,variant:"outline",onPress:c,accessibilityLabel:w,style:u,testID:T,children:_jsxs(View,{style:[styles.row,{columnGap:h.space.md}],children:[void 0===i?null:_jsx(IconBadge,{icon:i,iconVariant:s,tone:o}),_jsxs(View,{style:styles.text,children:[_jsx(Text,{variant:"caption",color:"secondary",numberOfLines:1,children:n}),isText(r)?_jsx(Text,{variant:"h3",numberOfLines:1,children:r}):r,l?_jsxs(View,{style:[styles.trend,{columnGap:h.space.xxs}],testID:T?`${T}-trend`:void 0,children:[_jsx(View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:_jsx(AppIcon,{name:TREND_ICON[l.direction],size:"xs",color:g})}),_jsxs(Text,{variant:"caption",color:S,numberOfLines:2,style:styles.text,children:[trendFigure(l),l.period?_jsx(Text,{variant:"caption",color:"tertiary",children:` ${l.period}`}):null]})]}):null,null==a||""===a?null:isText(a)?_jsx(Text,{variant:"caption",color:"tertiary",numberOfLines:1,children:a}):a,null==d?null:_jsx(View,{style:{marginTop:h.space.sm},children:d})]})]})})});StatTile.displayName="StatTile";const styles=StyleSheet.create({row:{flexDirection:"row",alignItems:"center"},text:{flex:1,minWidth:0},trend:{flexDirection:"row",alignItems:"center"}});export{StatTile};export default StatTile;