@webority/mobile-ui 0.174.1 → 0.176.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 (272) hide show
  1. package/dist/canvas-kit/kit.js +10 -10
  2. package/dist/canvas-kit/manifest.json +1 -1
  3. package/dist/canvas-kit/release.json +5 -5
  4. package/lib/commonjs/components/Accordion/Accordion.js +1 -1
  5. package/lib/commonjs/components/AmountSlider/AmountSlider.js +1 -1
  6. package/lib/commonjs/components/AppBar/AppBar.js +1 -1
  7. package/lib/commonjs/components/AuthedImage/authedImageCache.js +1 -1
  8. package/lib/commonjs/components/Avatar/Avatar.js +1 -1
  9. package/lib/commonjs/components/Badge/Badge.js +1 -1
  10. package/lib/commonjs/components/Banner/Banner.js +1 -1
  11. package/lib/commonjs/components/BarChart/BarChart.js +1 -1
  12. package/lib/commonjs/components/BottomNavigation/BottomNavigation.js +1 -1
  13. package/lib/commonjs/components/BottomSheet/BottomSheet.js +1 -1
  14. package/lib/commonjs/components/Box/Box.js +1 -1
  15. package/lib/commonjs/components/Button/Button.js +1 -1
  16. package/lib/commonjs/components/Calendar/Calendar.js +1 -1
  17. package/lib/commonjs/components/Card/Card.js +1 -1
  18. package/lib/commonjs/components/Carousel/Carousel.js +1 -1
  19. package/lib/commonjs/components/Checkbox/Checkbox.js +1 -1
  20. package/lib/commonjs/components/Chip/Chip.js +1 -1
  21. package/lib/commonjs/components/Composer/Composer.js +1 -1
  22. package/lib/commonjs/components/Confetti/Confetti.js +1 -1
  23. package/lib/commonjs/components/DateRangePicker/DateRangePicker.js +1 -1
  24. package/lib/commonjs/components/DecimalInput/DecimalInput.js +1 -1
  25. package/lib/commonjs/components/Descriptions/Descriptions.js +1 -1
  26. package/lib/commonjs/components/Divider/Divider.js +1 -1
  27. package/lib/commonjs/components/Drawer/Drawer.js +1 -1
  28. package/lib/commonjs/components/EmptyState/EmptyState.js +1 -1
  29. package/lib/commonjs/components/FieldBase/ChoiceText.js +1 -1
  30. package/lib/commonjs/components/FieldBase/FieldBase.js +1 -1
  31. package/lib/commonjs/components/FieldBase/useFloatingLabel.js +1 -1
  32. package/lib/commonjs/components/FilePicker/FilePicker.js +1 -1
  33. package/lib/commonjs/components/FilterChipRow/FilterChipRow.js +1 -1
  34. package/lib/commonjs/components/FloatingActionButton/FloatingActionButton.js +1 -1
  35. package/lib/commonjs/components/FormField/FormField.js +1 -1
  36. package/lib/commonjs/components/IconBadge/IconBadge.js +1 -1
  37. package/lib/commonjs/components/IconButton/IconButton.js +1 -1
  38. package/lib/commonjs/components/Input/Input.js +1 -1
  39. package/lib/commonjs/components/KeyboardAwareScrollView/KeyboardAwareScrollView.js +1 -1
  40. package/lib/commonjs/components/ListItem/ListItem.js +1 -1
  41. package/lib/commonjs/components/Modal/Modal.js +1 -1
  42. package/lib/commonjs/components/NumberInput/NumberInput.js +1 -1
  43. package/lib/commonjs/components/OTPInput/OTPInput.js +1 -1
  44. package/lib/commonjs/components/OptionSheet/OptionSheet.js +1 -1
  45. package/lib/commonjs/components/PhoneNumberInput/PhoneNumberInput.js +1 -1
  46. package/lib/commonjs/components/PickerTrigger/PickerTrigger.js +1 -1
  47. package/lib/commonjs/components/ProfileCompletion/ProfileCompletion.js +1 -1
  48. package/lib/commonjs/components/ProgressBar/ProgressBar.js +1 -1
  49. package/lib/commonjs/components/ProgressRing/ProgressRing.js +1 -1
  50. package/lib/commonjs/components/Radio/Radio.js +1 -1
  51. package/lib/commonjs/components/Radio/RadioGroup.js +1 -1
  52. package/lib/commonjs/components/Rating/Rating.js +1 -1
  53. package/lib/commonjs/components/RichTextEditor/RichTextEditor.js +1 -1
  54. package/lib/commonjs/components/ScannerOverlay/ScannerOverlay.js +1 -1
  55. package/lib/commonjs/components/Screen/Screen.js +1 -1
  56. package/lib/commonjs/components/SearchBar/SearchBar.js +1 -1
  57. package/lib/commonjs/components/SegmentedControl/SegmentedControl.js +1 -1
  58. package/lib/commonjs/components/Select/Select.js +1 -1
  59. package/lib/commonjs/components/SignaturePad/SignaturePad.js +1 -1
  60. package/lib/commonjs/components/Skeleton/SkeletonClock.js +1 -1
  61. package/lib/commonjs/components/Skeleton/SkeletonProvider.js +1 -1
  62. package/lib/commonjs/components/SlideToConfirm/SlideToConfirm.js +1 -1
  63. package/lib/commonjs/components/Slider/Slider.js +1 -1
  64. package/lib/commonjs/components/SliderField/SliderField.js +1 -1
  65. package/lib/commonjs/components/Sparkline/Sparkline.js +1 -1
  66. package/lib/commonjs/components/Spinner/Spinner.js +1 -1
  67. package/lib/commonjs/components/SquircleView/SquircleView.js +1 -1
  68. package/lib/commonjs/components/StatTile/StatTile.js +1 -1
  69. package/lib/commonjs/components/StatusBadge/StatusBadge.js +1 -1
  70. package/lib/commonjs/components/Stepper/Stepper.js +1 -1
  71. package/lib/commonjs/components/Switch/Switch.js +1 -1
  72. package/lib/commonjs/components/Tabs/Tabs.js +1 -1
  73. package/lib/commonjs/components/TagInput/TagInput.js +1 -1
  74. package/lib/commonjs/components/Text/Text.js +1 -1
  75. package/lib/commonjs/components/Toast/ToastProvider.js +1 -1
  76. package/lib/commonjs/navigation/DiscardGuard.js +1 -1
  77. package/lib/commonjs/theme/ThemeContext.js +1 -1
  78. package/lib/commonjs/utils/shadows.js +1 -1
  79. package/lib/module/components/Accordion/Accordion.js +1 -1
  80. package/lib/module/components/AmountSlider/AmountSlider.js +1 -1
  81. package/lib/module/components/AppBar/AppBar.js +1 -1
  82. package/lib/module/components/AuthedImage/authedImageCache.js +1 -1
  83. package/lib/module/components/Avatar/Avatar.js +1 -1
  84. package/lib/module/components/Badge/Badge.js +1 -1
  85. package/lib/module/components/Banner/Banner.js +1 -1
  86. package/lib/module/components/BarChart/BarChart.js +1 -1
  87. package/lib/module/components/BottomNavigation/BottomNavigation.js +1 -1
  88. package/lib/module/components/BottomSheet/BottomSheet.js +1 -1
  89. package/lib/module/components/Box/Box.js +1 -1
  90. package/lib/module/components/Button/Button.js +1 -1
  91. package/lib/module/components/Calendar/Calendar.js +1 -1
  92. package/lib/module/components/Card/Card.js +1 -1
  93. package/lib/module/components/Carousel/Carousel.js +1 -1
  94. package/lib/module/components/Checkbox/Checkbox.js +1 -1
  95. package/lib/module/components/Chip/Chip.js +1 -1
  96. package/lib/module/components/Composer/Composer.js +1 -1
  97. package/lib/module/components/Confetti/Confetti.js +1 -1
  98. package/lib/module/components/DateRangePicker/DateRangePicker.js +1 -1
  99. package/lib/module/components/DecimalInput/DecimalInput.js +1 -1
  100. package/lib/module/components/Descriptions/Descriptions.js +1 -1
  101. package/lib/module/components/Divider/Divider.js +1 -1
  102. package/lib/module/components/Drawer/Drawer.js +1 -1
  103. package/lib/module/components/EmptyState/EmptyState.js +1 -1
  104. package/lib/module/components/FieldBase/ChoiceText.js +1 -1
  105. package/lib/module/components/FieldBase/FieldBase.js +1 -1
  106. package/lib/module/components/FieldBase/useFloatingLabel.js +1 -1
  107. package/lib/module/components/FilePicker/FilePicker.js +1 -1
  108. package/lib/module/components/FilterChipRow/FilterChipRow.js +1 -1
  109. package/lib/module/components/FloatingActionButton/FloatingActionButton.js +1 -1
  110. package/lib/module/components/FormField/FormField.js +1 -1
  111. package/lib/module/components/IconBadge/IconBadge.js +1 -1
  112. package/lib/module/components/IconButton/IconButton.js +1 -1
  113. package/lib/module/components/Input/Input.js +1 -1
  114. package/lib/module/components/KeyboardAwareScrollView/KeyboardAwareScrollView.js +1 -1
  115. package/lib/module/components/ListItem/ListItem.js +1 -1
  116. package/lib/module/components/Modal/Modal.js +1 -1
  117. package/lib/module/components/NumberInput/NumberInput.js +1 -1
  118. package/lib/module/components/OTPInput/OTPInput.js +1 -1
  119. package/lib/module/components/OptionSheet/OptionSheet.js +1 -1
  120. package/lib/module/components/PhoneNumberInput/PhoneNumberInput.js +1 -1
  121. package/lib/module/components/PickerTrigger/PickerTrigger.js +1 -1
  122. package/lib/module/components/ProfileCompletion/ProfileCompletion.js +1 -1
  123. package/lib/module/components/ProgressBar/ProgressBar.js +1 -1
  124. package/lib/module/components/ProgressRing/ProgressRing.js +1 -1
  125. package/lib/module/components/Radio/Radio.js +1 -1
  126. package/lib/module/components/Radio/RadioGroup.js +1 -1
  127. package/lib/module/components/Rating/Rating.js +1 -1
  128. package/lib/module/components/RichTextEditor/RichTextEditor.js +1 -1
  129. package/lib/module/components/ScannerOverlay/ScannerOverlay.js +1 -1
  130. package/lib/module/components/Screen/Screen.js +1 -1
  131. package/lib/module/components/SearchBar/SearchBar.js +1 -1
  132. package/lib/module/components/SegmentedControl/SegmentedControl.js +1 -1
  133. package/lib/module/components/Select/Select.js +1 -1
  134. package/lib/module/components/SignaturePad/SignaturePad.js +1 -1
  135. package/lib/module/components/Skeleton/SkeletonClock.js +1 -1
  136. package/lib/module/components/Skeleton/SkeletonProvider.js +1 -1
  137. package/lib/module/components/SlideToConfirm/SlideToConfirm.js +1 -1
  138. package/lib/module/components/Slider/Slider.js +1 -1
  139. package/lib/module/components/SliderField/SliderField.js +1 -1
  140. package/lib/module/components/Sparkline/Sparkline.js +1 -1
  141. package/lib/module/components/Spinner/Spinner.js +1 -1
  142. package/lib/module/components/SquircleView/SquircleView.js +1 -1
  143. package/lib/module/components/StatTile/StatTile.js +1 -1
  144. package/lib/module/components/StatusBadge/StatusBadge.js +1 -1
  145. package/lib/module/components/Stepper/Stepper.js +1 -1
  146. package/lib/module/components/Switch/Switch.js +1 -1
  147. package/lib/module/components/Tabs/Tabs.js +1 -1
  148. package/lib/module/components/TagInput/TagInput.js +1 -1
  149. package/lib/module/components/Text/Text.js +1 -1
  150. package/lib/module/components/Toast/ToastProvider.js +1 -1
  151. package/lib/module/navigation/DiscardGuard.js +1 -1
  152. package/lib/module/theme/ThemeContext.js +1 -1
  153. package/lib/module/utils/shadows.js +1 -1
  154. package/lib/typescript/commonjs/components/AmountSlider/AmountSlider.d.ts +3 -2
  155. package/lib/typescript/commonjs/components/AppBar/AppBar.d.ts +4 -1
  156. package/lib/typescript/commonjs/components/AuthedImage/authedImageCache.d.ts +3 -1
  157. package/lib/typescript/commonjs/components/Avatar/Avatar.d.ts +6 -1
  158. package/lib/typescript/commonjs/components/Badge/Badge.d.ts +5 -1
  159. package/lib/typescript/commonjs/components/Banner/Banner.d.ts +3 -1
  160. package/lib/typescript/commonjs/components/BarChart/BarChart.d.ts +4 -1
  161. package/lib/typescript/commonjs/components/BottomNavigation/BottomNavigation.d.ts +3 -1
  162. package/lib/typescript/commonjs/components/Box/Box.d.ts +6 -3
  163. package/lib/typescript/commonjs/components/Button/Button.d.ts +4 -2
  164. package/lib/typescript/commonjs/components/Calendar/Calendar.d.ts +4 -2
  165. package/lib/typescript/commonjs/components/Card/Card.d.ts +2 -1
  166. package/lib/typescript/commonjs/components/Checkbox/Checkbox.d.ts +4 -1
  167. package/lib/typescript/commonjs/components/Chip/Chip.d.ts +3 -1
  168. package/lib/typescript/commonjs/components/Composer/Composer.d.ts +3 -1
  169. package/lib/typescript/commonjs/components/Confetti/Confetti.d.ts +3 -1
  170. package/lib/typescript/commonjs/components/DateRangePicker/DateRangePicker.d.ts +4 -2
  171. package/lib/typescript/commonjs/components/DecimalInput/DecimalInput.d.ts +4 -2
  172. package/lib/typescript/commonjs/components/Divider/Divider.d.ts +3 -2
  173. package/lib/typescript/commonjs/components/Drawer/Drawer.d.ts +3 -1
  174. package/lib/typescript/commonjs/components/EmptyState/EmptyState.d.ts +2 -1
  175. package/lib/typescript/commonjs/components/FilePicker/FilePicker.d.ts +4 -1
  176. package/lib/typescript/commonjs/components/FilterChipRow/FilterChipRow.d.ts +4 -2
  177. package/lib/typescript/commonjs/components/FloatingActionButton/FloatingActionButton.d.ts +2 -1
  178. package/lib/typescript/commonjs/components/FormField/FormField.d.ts +3 -2
  179. package/lib/typescript/commonjs/components/IconBadge/IconBadge.d.ts +4 -2
  180. package/lib/typescript/commonjs/components/IconButton/IconButton.d.ts +4 -2
  181. package/lib/typescript/commonjs/components/Input/Input.d.ts +4 -1
  182. package/lib/typescript/commonjs/components/KeyboardAwareScrollView/KeyboardAwareScrollView.d.ts +4 -1
  183. package/lib/typescript/commonjs/components/ListItem/ListItem.d.ts +2 -0
  184. package/lib/typescript/commonjs/components/Modal/Modal.d.ts +3 -1
  185. package/lib/typescript/commonjs/components/NumberInput/NumberInput.d.ts +4 -2
  186. package/lib/typescript/commonjs/components/OTPInput/OTPInput.d.ts +3 -2
  187. package/lib/typescript/commonjs/components/PhoneNumberInput/PhoneNumberInput.d.ts +4 -2
  188. package/lib/typescript/commonjs/components/PickerTrigger/PickerTrigger.d.ts +4 -4
  189. package/lib/typescript/commonjs/components/ProfileCompletion/ProfileCompletion.d.ts +4 -1
  190. package/lib/typescript/commonjs/components/ProgressBar/ProgressBar.d.ts +3 -2
  191. package/lib/typescript/commonjs/components/ProgressRing/ProgressRing.d.ts +2 -1
  192. package/lib/typescript/commonjs/components/Radio/Radio.d.ts +4 -2
  193. package/lib/typescript/commonjs/components/Rating/Rating.d.ts +5 -1
  194. package/lib/typescript/commonjs/components/RichTextEditor/RichTextEditor.d.ts +2 -1
  195. package/lib/typescript/commonjs/components/ScannerOverlay/ScannerOverlay.d.ts +2 -1
  196. package/lib/typescript/commonjs/components/SearchBar/SearchBar.d.ts +4 -2
  197. package/lib/typescript/commonjs/components/SegmentedControl/SegmentedControl.d.ts +3 -2
  198. package/lib/typescript/commonjs/components/SignaturePad/SignaturePad.d.ts +4 -1
  199. package/lib/typescript/commonjs/components/SlideToConfirm/SlideToConfirm.d.ts +3 -1
  200. package/lib/typescript/commonjs/components/Slider/Slider.d.ts +3 -1
  201. package/lib/typescript/commonjs/components/SliderField/SliderField.d.ts +3 -1
  202. package/lib/typescript/commonjs/components/Sparkline/Sparkline.d.ts +4 -2
  203. package/lib/typescript/commonjs/components/Spinner/Spinner.d.ts +2 -1
  204. package/lib/typescript/commonjs/components/SquircleView/SquircleView.d.ts +8 -3
  205. package/lib/typescript/commonjs/components/StatTile/StatTile.d.ts +3 -2
  206. package/lib/typescript/commonjs/components/StatusBadge/StatusBadge.d.ts +4 -1
  207. package/lib/typescript/commonjs/components/Stepper/Stepper.d.ts +3 -1
  208. package/lib/typescript/commonjs/components/Switch/Switch.d.ts +3 -2
  209. package/lib/typescript/commonjs/components/Tabs/Tabs.d.ts +3 -2
  210. package/lib/typescript/commonjs/components/TagInput/TagInput.d.ts +4 -2
  211. package/lib/typescript/commonjs/components/Text/Text.d.ts +4 -1
  212. package/lib/typescript/commonjs/navigation/DiscardGuard.d.ts +3 -1
  213. package/lib/typescript/module/components/AmountSlider/AmountSlider.d.ts +3 -2
  214. package/lib/typescript/module/components/AppBar/AppBar.d.ts +4 -1
  215. package/lib/typescript/module/components/AuthedImage/authedImageCache.d.ts +3 -1
  216. package/lib/typescript/module/components/Avatar/Avatar.d.ts +6 -1
  217. package/lib/typescript/module/components/Badge/Badge.d.ts +5 -1
  218. package/lib/typescript/module/components/Banner/Banner.d.ts +3 -1
  219. package/lib/typescript/module/components/BarChart/BarChart.d.ts +4 -1
  220. package/lib/typescript/module/components/BottomNavigation/BottomNavigation.d.ts +3 -1
  221. package/lib/typescript/module/components/Box/Box.d.ts +6 -3
  222. package/lib/typescript/module/components/Button/Button.d.ts +4 -2
  223. package/lib/typescript/module/components/Calendar/Calendar.d.ts +4 -2
  224. package/lib/typescript/module/components/Card/Card.d.ts +2 -1
  225. package/lib/typescript/module/components/Checkbox/Checkbox.d.ts +4 -1
  226. package/lib/typescript/module/components/Chip/Chip.d.ts +3 -1
  227. package/lib/typescript/module/components/Composer/Composer.d.ts +3 -1
  228. package/lib/typescript/module/components/Confetti/Confetti.d.ts +3 -1
  229. package/lib/typescript/module/components/DateRangePicker/DateRangePicker.d.ts +4 -2
  230. package/lib/typescript/module/components/DecimalInput/DecimalInput.d.ts +4 -2
  231. package/lib/typescript/module/components/Divider/Divider.d.ts +3 -2
  232. package/lib/typescript/module/components/Drawer/Drawer.d.ts +3 -1
  233. package/lib/typescript/module/components/EmptyState/EmptyState.d.ts +2 -1
  234. package/lib/typescript/module/components/FilePicker/FilePicker.d.ts +4 -1
  235. package/lib/typescript/module/components/FilterChipRow/FilterChipRow.d.ts +4 -2
  236. package/lib/typescript/module/components/FloatingActionButton/FloatingActionButton.d.ts +2 -1
  237. package/lib/typescript/module/components/FormField/FormField.d.ts +3 -2
  238. package/lib/typescript/module/components/IconBadge/IconBadge.d.ts +4 -2
  239. package/lib/typescript/module/components/IconButton/IconButton.d.ts +4 -2
  240. package/lib/typescript/module/components/Input/Input.d.ts +4 -1
  241. package/lib/typescript/module/components/KeyboardAwareScrollView/KeyboardAwareScrollView.d.ts +4 -1
  242. package/lib/typescript/module/components/ListItem/ListItem.d.ts +2 -0
  243. package/lib/typescript/module/components/Modal/Modal.d.ts +3 -1
  244. package/lib/typescript/module/components/NumberInput/NumberInput.d.ts +4 -2
  245. package/lib/typescript/module/components/OTPInput/OTPInput.d.ts +3 -2
  246. package/lib/typescript/module/components/PhoneNumberInput/PhoneNumberInput.d.ts +4 -2
  247. package/lib/typescript/module/components/PickerTrigger/PickerTrigger.d.ts +4 -4
  248. package/lib/typescript/module/components/ProfileCompletion/ProfileCompletion.d.ts +4 -1
  249. package/lib/typescript/module/components/ProgressBar/ProgressBar.d.ts +3 -2
  250. package/lib/typescript/module/components/ProgressRing/ProgressRing.d.ts +2 -1
  251. package/lib/typescript/module/components/Radio/Radio.d.ts +4 -2
  252. package/lib/typescript/module/components/Rating/Rating.d.ts +5 -1
  253. package/lib/typescript/module/components/RichTextEditor/RichTextEditor.d.ts +2 -1
  254. package/lib/typescript/module/components/ScannerOverlay/ScannerOverlay.d.ts +2 -1
  255. package/lib/typescript/module/components/SearchBar/SearchBar.d.ts +4 -2
  256. package/lib/typescript/module/components/SegmentedControl/SegmentedControl.d.ts +3 -2
  257. package/lib/typescript/module/components/SignaturePad/SignaturePad.d.ts +4 -1
  258. package/lib/typescript/module/components/SlideToConfirm/SlideToConfirm.d.ts +3 -1
  259. package/lib/typescript/module/components/Slider/Slider.d.ts +3 -1
  260. package/lib/typescript/module/components/SliderField/SliderField.d.ts +3 -1
  261. package/lib/typescript/module/components/Sparkline/Sparkline.d.ts +4 -2
  262. package/lib/typescript/module/components/Spinner/Spinner.d.ts +2 -1
  263. package/lib/typescript/module/components/SquircleView/SquircleView.d.ts +8 -3
  264. package/lib/typescript/module/components/StatTile/StatTile.d.ts +3 -2
  265. package/lib/typescript/module/components/StatusBadge/StatusBadge.d.ts +4 -1
  266. package/lib/typescript/module/components/Stepper/Stepper.d.ts +3 -1
  267. package/lib/typescript/module/components/Switch/Switch.d.ts +3 -2
  268. package/lib/typescript/module/components/Tabs/Tabs.d.ts +3 -2
  269. package/lib/typescript/module/components/TagInput/TagInput.d.ts +4 -2
  270. package/lib/typescript/module/components/Text/Text.d.ts +4 -1
  271. package/lib/typescript/module/navigation/DiscardGuard.d.ts +3 -1
  272. package/package.json +7 -7
@@ -1 +1 @@
1
- "use strict";import{forwardRef,useMemo}from"react";import{StyleSheet,View}from"react-native";import{fillText,useMobileUiText}from"../../text/index.js";import{PROFILE_COMPLETION_TEXT}from"../../text/phone/profileCompletion.g.js";import{useTheme}from"../../theme/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{AppIcon}from"../AppIcon/index.js";import{Avatar}from"../Avatar/index.js";import{IconBadge}from"../IconBadge/index.js";import{ProgressRing}from"../ProgressRing/index.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const AVATAR_PX={sm:32,md:48,lg:64,xl:80},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}},DEFAULT_RING_WIDTH=3,DEFAULT_RING_GAP=1,ProfileCompletion=forwardRef((e,t)=>{const{progress:r,title:i,subtitle:o,description:s,source:l,ImageComponent:a,size:n="md",avatarTone:m="neutral",avatarBackgroundColor:c,avatarColor:d,ringWidth:u,ringGap:p=DEFAULT_RING_GAP,ringVariant:x="banded",tone:f,ringColor:g,animated:y=!0,showCompleteBadge:b=!0,trailing:h,labels:T,accessibilityLabel:_,style:j,titleStyle:I,subtitleStyle:C,descriptionStyle:V,testID:P}=e;assertValidValue("ProfileCompletion","size",e.size,["sm","md","lg","xl"]),assertValidValue("ProfileCompletion","ringVariant",e.ringVariant,["banded","single"]),assertValidValue("ProfileCompletion","tone",e.tone,["primary","success","warning","danger","info","neutral"]);const w=useTheme(),A=useMemo(()=>buildStyles(w),[w]),v=useMobileUiText("profileCompletion",PROFILE_COMPLETION_TEXT),R=useMemo(()=>({...v,...T}),[v,T]),M=u??3,L=AVATAR_PX[n]+2*(p+M),S=Math.min(100,Math.max(0,Number.isNaN(r)?0:r)),D=Math.round(S),E=_??fillText(R.summary,{title:i,percent:D}),G=P??"profile-completion",N=b&&S>=100,O=Math.max(16,Math.round(.3*L)),z=L/2*(1+Math.SQRT1_2)-M/2,B=g??("banded"===x&&null==f?w.colors.success:toneColor(w,f??"primary"));return _jsxs(View,{ref:t,style:[A.root,j],testID:P,children:[_jsxs(View,{style:A.summary,accessible:!0,accessibilityRole:"summary",accessibilityLabel:E,accessibilityValue:{min:0,max:100,now:D},testID:`${G}-summary`,children:[_jsxs(View,{style:{width:L,height:L},children:[_jsx(ProgressRing,{progress:S/100,size:L,strokeWidth:M,tone:f??"primary",ringColor:g,colorByProgress:"banded"===x&&null==f&&null==g,animated:y,testID:`${G}-ring`,children:_jsx(Avatar,{name:i,source:l,ImageComponent:a,size:n,tone:m,backgroundColor:c,color:d,accessibilityLabel:fillText(R.avatar,{title:i})})}),N?_jsx(IconBadge,{dimension:O,fill:"surface",icon:_jsx(AppIcon,{name:"verify",variant:"bold",size:O-2,color:B}),pointerEvents:"none",style:[A.badge,{left:z-O/2,top:z-O/2}],testID:`${G}-complete-badge`}):null]}),_jsxs(View,{style:A.body,children:[_jsx(Text,{variant:"h3",numberOfLines:2,style:I,children:i}),o?_jsx(Text,{variant:"label",color:"tertiary",numberOfLines:1,style:[A.subtitle,C],children:o}):null,s?_jsx(Text,{variant:"body",color:"secondary",style:V,children:s}):null]})]}),null!=h?_jsx(View,{style:A.trailing,children:h}):null]})});ProfileCompletion.displayName="ProfileCompletion";const buildStyles=e=>StyleSheet.create({root:{flexDirection:"row",alignItems:"center",columnGap:e.space.md},summary:{flex:1,flexDirection:"row",alignItems:"center",columnGap:e.space.md},body:{flex:1,rowGap:e.space.xxs},badge:{position:"absolute"},subtitle:{textTransform:"uppercase",letterSpacing:e["letter-spacing"].wide},trailing:{alignSelf:"flex-start"}});export{ProfileCompletion};export default ProfileCompletion;
1
+ "use strict";import{useMemo}from"react";import{StyleSheet,View}from"react-native";import{fillText,useMobileUiText}from"../../text/index.js";import{PROFILE_COMPLETION_TEXT}from"../../text/phone/profileCompletion.g.js";import{useTheme}from"../../theme/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{AppIcon}from"../AppIcon/index.js";import{Avatar}from"../Avatar/index.js";import{IconBadge}from"../IconBadge/index.js";import{ProgressRing}from"../ProgressRing/index.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const AVATAR_PX={sm:32,md:48,lg:64,xl:80},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}},DEFAULT_RING_WIDTH=3,DEFAULT_RING_GAP=1;function ProfileCompletion({ref:e,...t}){const{progress:r,title:i,subtitle:o,description:s,source:l,ImageComponent:n,size:a="md",avatarTone:c="neutral",avatarBackgroundColor:m,avatarColor:d,ringWidth:u,ringGap:p=DEFAULT_RING_GAP,ringVariant:x="banded",tone:g,ringColor:f,animated:y=!0,showCompleteBadge:b=!0,trailing:h,labels:T,accessibilityLabel:_,style:j,titleStyle:I,subtitleStyle:V,descriptionStyle:C,testID:P}=t;assertValidValue("ProfileCompletion","size",t.size,["sm","md","lg","xl"]),assertValidValue("ProfileCompletion","ringVariant",t.ringVariant,["banded","single"]),assertValidValue("ProfileCompletion","tone",t.tone,["primary","success","warning","danger","info","neutral"]);const w=useTheme(),A=useMemo(()=>buildStyles(w),[w]),v=useMobileUiText("profileCompletion",PROFILE_COMPLETION_TEXT),M=useMemo(()=>({...v,...T}),[v,T]),L=u??3,R=AVATAR_PX[a]+2*(p+L),S=Math.min(100,Math.max(0,Number.isNaN(r)?0:r)),D=Math.round(S),E=_??fillText(M.summary,{title:i,percent:D}),G=P??"profile-completion",N=b&&S>=100,O=Math.max(16,Math.round(.3*R)),z=R/2*(1+Math.SQRT1_2)-L/2,B=f??("banded"===x&&null==g?w.colors.success:toneColor(w,g??"primary"));return _jsxs(View,{ref:e,style:[A.root,j],testID:P,children:[_jsxs(View,{style:A.summary,accessible:!0,accessibilityRole:"summary",accessibilityLabel:E,accessibilityValue:{min:0,max:100,now:D},testID:`${G}-summary`,children:[_jsxs(View,{style:{width:R,height:R},children:[_jsx(ProgressRing,{progress:S/100,size:R,strokeWidth:L,tone:g??"primary",ringColor:f,colorByProgress:"banded"===x&&null==g&&null==f,animated:y,testID:`${G}-ring`,children:_jsx(Avatar,{name:i,source:l,ImageComponent:n,size:a,tone:c,backgroundColor:m,color:d,accessibilityLabel:fillText(M.avatar,{title:i})})}),N?_jsx(IconBadge,{dimension:O,fill:"surface",icon:_jsx(AppIcon,{name:"verify",variant:"bold",size:O-2,color:B}),pointerEvents:"none",style:[A.badge,{left:z-O/2,top:z-O/2}],testID:`${G}-complete-badge`}):null]}),_jsxs(View,{style:A.body,children:[_jsx(Text,{variant:"h3",numberOfLines:2,style:I,children:i}),o?_jsx(Text,{variant:"label",color:"tertiary",numberOfLines:1,style:[A.subtitle,V],children:o}):null,s?_jsx(Text,{variant:"body",color:"secondary",style:C,children:s}):null]})]}),null!=h?_jsx(View,{style:A.trailing,children:h}):null]})}const buildStyles=e=>StyleSheet.create({root:{flexDirection:"row",alignItems:"center",columnGap:e.space.md},summary:{flex:1,flexDirection:"row",alignItems:"center",columnGap:e.space.md},body:{flex:1,rowGap:e.space.xxs},badge:{position:"absolute"},subtitle:{textTransform:"uppercase",letterSpacing:e["letter-spacing"].wide},trailing:{alignSelf:"flex-start"}});export{ProfileCompletion};export default ProfileCompletion;
@@ -1 +1 @@
1
- "use strict";import{forwardRef,useEffect,useMemo,useRef}from"react";import{Animated,Easing,StyleSheet,View}from"react-native";import{useReducedMotion}from"../../hooks/useReducedMotion.js";import{useMobileUiText}from"../../text/index.js";import{PROGRESS_BAR_TEXT}from"../../text/phone/progressBar.g.js";import{createAnimatedValue,Gradient,setNativeValue,useTheme}from"../../theme/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{tintOf}from"../../utils/color.js";import{smoothCorners}from"../../utils/corners.js";import{nativeDriver}from"../../utils/nativeDriver.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const 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.neutral;case"primary":return e.colors.primary}},DETERMINATE_ANIMATION_DURATION=400,INDETERMINATE_LOOP_DURATION=1500,INDETERMINATE_WIDTH="30%",GLOW_LOCATIONS=[0,.35,.5,.65,1],glowOf=e=>{const t=tintOf(e,0,"transparent"),r=tintOf(e,.6,e);return{colors:[t,r,e,r,t],locations:GLOW_LOCATIONS,start:{x:0,y:.5},end:{x:1,y:.5}}},clampProgress=e=>"number"!=typeof e||Number.isNaN(e)||e<0?0:e>1?1:e,ProgressBar=forwardRef((e,t)=>{const r=useTheme(),s=useReducedMotion(),{progress:i,label:o,showPercent:n=!1,valueLabel:a,indeterminate:l,height:u=6,radius:c,tone:d="primary",trackColor:m,barColor:g,gradient:p,segments:f,animated:h=!0,style:y,barStyle:b,accessibilityLabel:w,labels:x,testID:R}=e;assertValidValue("ProgressBar","tone",e.tone,["primary","success","warning","danger","info","neutral"]);const j=useMobileUiText("progressBar",PROGRESS_BAR_TEXT),v=useMemo(()=>({...j,...x}),[j,x]),A=l??"number"!=typeof i,T=clampProgress(i),V=useRef(createAnimatedValue(T)).current,_=useRef(createAnimatedValue(0)).current,E=useRef(createAnimatedValue(0)).current,N=useRef(0),O=useMemo(()=>buildStyles(r),[r]),S=c??r.radius.pill,M=m??r.colors["surface-disabled"],B=g??toneColor(r,d),D=useMemo(()=>{if(null==p)return null;if("string"!=typeof p)return p;const e=r.settings.gradients[p];if(void 0===e){const e=Object.keys(r.settings.gradients);throw new RangeError(`[@webority/mobile-ui] <ProgressBar> received gradient="${p}", which is not a gradient in theme.settings.gradients (${e.length>0?`known: ${e.map(e=>`"${e}"`).join(", ")}`:"the theme defines none"}). Pass a known gradient name or a GradientDefinition, or omit the prop.`)}return e},[p,r.settings.gradients]),I=useMemo(()=>glowOf(B),[B]),P=Array.isArray(f)&&f.length>0,C=useMemo(()=>(f??[]).map((e,t)=>({key:`segment-${t}`,segment:e})),[f]);useEffect(()=>{A||(h?Animated.timing(V,{toValue:T,duration:400,easing:Easing.bezier(...r.motion.ease["in-out"]),useNativeDriver:!1}).start():V.setValue(T))},[h,T,V,A,r]),useEffect(()=>{if(!A)return;setNativeValue(_,0);const e=Animated.loop(Animated.timing(_,{toValue:1,duration:1500,easing:Easing.inOut(Easing.ease),useNativeDriver:nativeDriver}));return e.start(),()=>{e.stop()}},[A,_]);const k=V.interpolate({inputRange:[0,1],outputRange:["0%","100%"]}),G=_.interpolate({inputRange:[0,1],outputRange:[-1,1]}),L=_.interpolate({inputRange:[0,.5,1],outputRange:[.4,1,.4]}),$=n&&!A&&!P,F=null!=o||$||null!=a,U=_jsx(View,{ref:t,accessibilityRole:"progressbar",accessibilityLabel:w??("string"==typeof o?o:void 0),accessibilityValue:A?{text:v.loading}:{min:0,max:100,now:Math.round(100*T)},testID:R,onLayout:e=>{const t=e.nativeEvent.layout.width;N.current=t,setNativeValue(E,t)},style:[O.track,{height:u,borderRadius:S,...smoothCorners,backgroundColor:M},y],children:P?_jsx(View,{style:[O.segments,{height:u}],children:C.map(({key:e,segment:t})=>_jsx(View,{style:{width:100*clampProgress(t.value)+"%",height:u,backgroundColor:t.color??toneColor(r,t.tone??"primary")}},e))}):_jsx(Animated.View,A?{style:[O.indeterminateBar,{height:u,width:s?"100%":"30%",opacity:s?L:1,transform:s?[]:[{translateX:Animated.multiply(G,E)}]},b],children:_jsx(Gradient,{gradient:I,style:StyleSheet.absoluteFill})}:{style:[O.determinateBar,{height:u,borderRadius:S,...smoothCorners,backgroundColor:D?"transparent":B,width:k,overflow:D?"hidden":void 0},b],children:D?_jsx(Gradient,{gradient:D,style:StyleSheet.absoluteFill}):null})});return F?_jsxs(View,{style:O.wrapper,children:[_jsxs(View,{style:[O.labelRow,{marginBottom:r.space.xs}],children:["string"==typeof o||"number"==typeof o?_jsx(Text,{variant:"label",color:"primary",style:O.label,children:o}):_jsx(View,{style:O.label,children:o}),null!=a?"string"==typeof a||"number"==typeof a?_jsx(Text,{variant:"label",color:"secondary",accessible:!1,importantForAccessibility:"no",children:a}):a:$?_jsx(Text,{variant:"label",color:"secondary",accessible:!1,importantForAccessibility:"no",children:`${Math.round(100*T)}%`}):null]}),U]}):U});ProgressBar.displayName="ProgressBar";const buildStyles=e=>StyleSheet.create({wrapper:{width:"100%"},labelRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",columnGap:e.space.sm},label:{flexShrink:1},track:{width:"100%",overflow:"hidden"},determinateBar:{position:"absolute",left:0,top:0},indeterminateBar:{position:"absolute",left:0,top:0},segments:{flexDirection:"row",width:"100%"}});export{ProgressBar};export default ProgressBar;
1
+ "use strict";import{useEffect,useMemo,useRef}from"react";import{Animated,Easing,StyleSheet,View}from"react-native";import{useReducedMotion}from"../../hooks/useReducedMotion.js";import{useMobileUiText}from"../../text/index.js";import{PROGRESS_BAR_TEXT}from"../../text/phone/progressBar.g.js";import{createAnimatedValue,Gradient,setNativeValue,useTheme}from"../../theme/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{tintOf}from"../../utils/color.js";import{smoothCorners}from"../../utils/corners.js";import{nativeDriver}from"../../utils/nativeDriver.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const 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.neutral;case"primary":return e.colors.primary}},DETERMINATE_ANIMATION_DURATION=400,INDETERMINATE_LOOP_DURATION=1500,INDETERMINATE_WIDTH="30%",GLOW_LOCATIONS=[0,.35,.5,.65,1],glowOf=e=>{const t=tintOf(e,0,"transparent"),r=tintOf(e,.6,e);return{colors:[t,r,e,r,t],locations:GLOW_LOCATIONS,start:{x:0,y:.5},end:{x:1,y:.5}}},clampProgress=e=>"number"!=typeof e||Number.isNaN(e)||e<0?0:e>1?1:e;function ProgressBar({ref:e,...t}){const r=useTheme(),s=useReducedMotion(),{progress:i,label:n,showPercent:o=!1,valueLabel:a,indeterminate:l,height:u=6,radius:c,tone:m="primary",trackColor:d,barColor:g,gradient:p,segments:f,animated:h=!0,style:y,barStyle:b,accessibilityLabel:x,labels:w,testID:R}=t;assertValidValue("ProgressBar","tone",t.tone,["primary","success","warning","danger","info","neutral"]);const j=useMobileUiText("progressBar",PROGRESS_BAR_TEXT),v=useMemo(()=>({...j,...w}),[j,w]),A=l??"number"!=typeof i,T=clampProgress(i),V=useRef(createAnimatedValue(T)).current,_=useRef(createAnimatedValue(0)).current,E=useRef(createAnimatedValue(0)).current,O=useRef(0),N=useMemo(()=>buildStyles(r),[r]),S=c??r.radius.pill,M=d??r.colors["surface-disabled"],D=g??toneColor(r,m),I=useMemo(()=>{if(null==p)return null;if("string"!=typeof p)return p;const e=r.settings.gradients[p];if(void 0===e){const e=Object.keys(r.settings.gradients);throw new RangeError(`[@webority/mobile-ui] <ProgressBar> received gradient="${p}", which is not a gradient in theme.settings.gradients (${e.length>0?`known: ${e.map(e=>`"${e}"`).join(", ")}`:"the theme defines none"}). Pass a known gradient name or a GradientDefinition, or omit the prop.`)}return e},[p,r.settings.gradients]),B=useMemo(()=>glowOf(D),[D]),C=Array.isArray(f)&&f.length>0,k=useMemo(()=>(f??[]).map((e,t)=>({key:`segment-${t}`,segment:e})),[f]);useEffect(()=>{A||(h?Animated.timing(V,{toValue:T,duration:400,easing:Easing.bezier(...r.motion.ease["in-out"]),useNativeDriver:!1}).start():V.setValue(T))},[h,T,V,A,r]),useEffect(()=>{if(!A)return;setNativeValue(_,0);const e=Animated.loop(Animated.timing(_,{toValue:1,duration:1500,easing:Easing.inOut(Easing.ease),useNativeDriver:nativeDriver}));return e.start(),()=>{e.stop()}},[A,_]);const P=V.interpolate({inputRange:[0,1],outputRange:["0%","100%"]}),G=_.interpolate({inputRange:[0,1],outputRange:[-1,1]}),L=_.interpolate({inputRange:[0,.5,1],outputRange:[.4,1,.4]}),$=o&&!A&&!C,F=null!=n||$||null!=a,U=_jsx(View,{ref:e,accessibilityRole:"progressbar",accessibilityLabel:x??("string"==typeof n?n:void 0),accessibilityValue:A?{text:v.loading}:{min:0,max:100,now:Math.round(100*T)},testID:R,onLayout:e=>{const t=e.nativeEvent.layout.width;O.current=t,setNativeValue(E,t)},style:[N.track,{height:u,borderRadius:S,...smoothCorners,backgroundColor:M},y],children:C?_jsx(View,{style:[N.segments,{height:u}],children:k.map(({key:e,segment:t})=>_jsx(View,{style:{width:100*clampProgress(t.value)+"%",height:u,backgroundColor:t.color??toneColor(r,t.tone??"primary")}},e))}):_jsx(Animated.View,A?{style:[N.indeterminateBar,{height:u,width:s?"100%":"30%",opacity:s?L:1,transform:s?[]:[{translateX:Animated.multiply(G,E)}]},b],children:_jsx(Gradient,{gradient:B,style:StyleSheet.absoluteFill})}:{style:[N.determinateBar,{height:u,borderRadius:S,...smoothCorners,backgroundColor:I?"transparent":D,width:P,overflow:I?"hidden":void 0},b],children:I?_jsx(Gradient,{gradient:I,style:StyleSheet.absoluteFill}):null})});return F?_jsxs(View,{style:N.wrapper,children:[_jsxs(View,{style:[N.labelRow,{marginBottom:r.space.xs}],children:["string"==typeof n||"number"==typeof n?_jsx(Text,{variant:"label",color:"primary",style:N.label,children:n}):_jsx(View,{style:N.label,children:n}),null!=a?"string"==typeof a||"number"==typeof a?_jsx(Text,{variant:"label",color:"secondary",accessible:!1,importantForAccessibility:"no",children:a}):a:$?_jsx(Text,{variant:"label",color:"secondary",accessible:!1,importantForAccessibility:"no",children:`${Math.round(100*T)}%`}):null]}),U]}):U}const buildStyles=e=>StyleSheet.create({wrapper:{width:"100%"},labelRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",columnGap:e.space.sm},label:{flexShrink:1},track:{width:"100%",overflow:"hidden"},determinateBar:{position:"absolute",left:0,top:0},indeterminateBar:{position:"absolute",left:0,top:0},segments:{flexDirection:"row",width:"100%"}});export{ProgressBar};export default ProgressBar;
@@ -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})`,...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
+ "use strict";import{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;function ProgressRing({ref: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}=t;assertValidValue("ProgressRing","tone",t.tone,["primary","success","warning","danger","info","neutral"]);const p=useTheme(),h=useReducedMotion(),x=clampProgress(r),y=o??4,R=i??p.colors["surface-disabled"],[b,j]=DEFAULT_COLOR_STOPS,_=Math.max(0,(s-y)/2),w=2*Math.PI*_,C=useRef(createAnimatedValue(x)).current;useEffect(()=>{if(!l||h)return void C.setValue(x);const e=Animated.timing(C,{toValue:x,duration:600,easing:Easing.bezier(...p.motion.ease["in-out"]),useNativeDriver:!1});return e.start(),()=>e.stop()},[l,x,C,h,p.motion.ease["in-out"]]);const S=C.interpolate({inputRange:[0,1],outputRange:[w,0]}),V=C.interpolate({inputRange:[0,.001,1],outputRange:[0,1,1]}),A=useMemo(()=>C.interpolate({inputRange:[0,b-1e-4,b,j-1e-4,j,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)),E=useMemo(()=>buildStyles(),[]),T=s/2;return _jsxs(View,{ref:e,accessible:null==m,accessibilityRole:"progressbar",accessibilityLabel:d,accessibilityValue:{min:0,max:100,now:Math.round(100*x)},testID:f,style:[E.root,{width:s,height:s},g],children:[_jsxs(Svg,{width:s,height:s,viewBox:`0 0 ${s} ${s}`,children:[_jsx(Circle,{cx:T,cy:T,r:_,stroke:R,strokeWidth:y,fill:"none"}),_jsx(AnimatedCircle,{cx:T,cy:T,r:_,stroke:D,strokeWidth:y,strokeLinecap:u?"round":"butt",strokeDasharray:`${w} ${w}`,strokeDashoffset:S,strokeOpacity:V,fill:"none",transform:`rotate(-90 ${T} ${T})`,...f?{testID:`${f}-fill`}:{}})]}),null!=m?_jsx(View,{style:E.content,pointerEvents:"box-none",children:m}):null]})}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{Logger}from"@webority/mobile-core";import{createContext,forwardRef,useContext,useMemo}from"react";import{Pressable,StyleSheet}from"react-native";import{spaceOf,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{fieldTextAsString,hasFieldText}from"../FieldBase/index.js";import{ChoiceText,hasChoiceDetail}from"../FieldBase/ChoiceText.js";import{RadioDot}from"./RadioDot.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const RadioGroupContext=createContext(null);export const useRadioGroup=()=>useContext(RadioGroupContext);const 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.neutral;default:return e.colors.primary}},Radio=forwardRef((e,t)=>{const{value:r,selected:o,onChange:i,disabled:s=!1,label:a,helperText:l,description:c,error:n,size:d="md",tone:p="primary",accessibilityLabel:u,haptic:m,style:h,circleStyle:x,dotStyle:f,labelStyle:b,testID:g,hitSlop:y,...S}=e;assertValidValue("Radio","size",e.size,["sm","md","lg"]),assertValidValue("Radio","tone",e.tone,["primary","success","warning","danger","info","neutral"]);const R=useTheme(),w=useMemo(()=>buildStyles(R),[R]),C=useRadioGroup();__DEV__&&void 0===r&&Logger.warn("[@webority/mobile-ui] Radio was rendered without a `value`. Selection compares against it, so the group cannot track which option is chosen.");const T=C?C.selectedValue===r:!!o,j=C&&C.disabled||s,V=toneColor(R,p),D=spaceOf(R,R.components.radio["label-gap"]),_=y??6,v=u??fieldTextAsString(a),H="string"==typeof n?n:void 0,k={description:c,helperText:l,error:H},L=!0===C?.error||!0===n||hasFieldText(n);return _jsxs(Pressable,{ref:t,onPress:e=>{if(j)return;const t=resolveHaptic(m,"selection");t&&triggerHaptic(t),C?C.onChange(r):i?.(r)},disabled:j,accessibilityRole:"radio",accessibilityLabel:v,accessibilityHint:S.accessibilityHint??fieldTextAsString(l)??fieldTextAsString(c),accessibilityState:{checked:T,disabled:j},"aria-checked":T,"aria-disabled":j,testID:g,hitSlop:_,...hitSlopMarker(_),...S,style:({pressed:e})=>[w.row,hasChoiceDetail(k)?w.rowTop:null,{opacity:j?.55:e?.85:1},h],children:[_jsx(RadioDot,{selected:T,color:V,disabled:j&&!T,size:d,style:[!L||T||j?null:{borderColor:R.colors["field-border-error"]},x],dotStyle:f}),_jsx(ChoiceText,{label:a,helperText:l,description:c,error:H,disabled:j,style:{marginLeft:D},labelStyle:b})]})});Radio.displayName="Radio";const buildStyles=e=>StyleSheet.create({row:{flexDirection:"row",alignItems:"center"},rowTop:{alignItems:"flex-start"}});export{Radio};export default Radio;
1
+ "use strict";import{Logger}from"@webority/mobile-core";import{createContext,useContext,useMemo}from"react";import{Pressable,StyleSheet}from"react-native";import{spaceOf,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{fieldTextAsString,hasFieldText}from"../FieldBase/index.js";import{ChoiceText,hasChoiceDetail}from"../FieldBase/ChoiceText.js";import{RadioDot}from"./RadioDot.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const RadioGroupContext=createContext(null);export const useRadioGroup=()=>useContext(RadioGroupContext);const 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.neutral;default:return e.colors.primary}};function Radio(e){const{ref:t,value:r,selected:o,onChange:i,disabled:s=!1,label:a,helperText:l,description:c,error:n,size:d="md",tone:p="primary",accessibilityLabel:u,haptic:m,style:h,circleStyle:x,dotStyle:f,labelStyle:b,testID:g,hitSlop:y,...S}=e;assertValidValue("Radio","size",e.size,["sm","md","lg"]),assertValidValue("Radio","tone",e.tone,["primary","success","warning","danger","info","neutral"]);const C=useTheme(),T=useMemo(()=>buildStyles(C),[C]),j=useRadioGroup();__DEV__&&void 0===r&&Logger.warn("[@webority/mobile-ui] Radio was rendered without a `value`. Selection compares against it, so the group cannot track which option is chosen.");const w=j?j.selectedValue===r:!!o,R=j&&j.disabled||s,V=toneColor(C,p),D=spaceOf(C,C.components.radio["label-gap"]),_=y??6,v=u??fieldTextAsString(a),H="string"==typeof n?n:void 0,k={description:c,helperText:l,error:H},L=!0===j?.error||!0===n||hasFieldText(n);return _jsxs(Pressable,{ref:t,onPress:e=>{if(R)return;const t=resolveHaptic(m,"selection");t&&triggerHaptic(t),j?j.onChange(r):i?.(r)},disabled:R,accessibilityRole:"radio",accessibilityLabel:v,accessibilityHint:S.accessibilityHint??fieldTextAsString(l)??fieldTextAsString(c),accessibilityState:{checked:w,disabled:R},"aria-checked":w,"aria-disabled":R,testID:g,hitSlop:_,...hitSlopMarker(_),...S,style:({pressed:e})=>[T.row,hasChoiceDetail(k)?T.rowTop:null,{opacity:R?.55:e?.85:1},h],children:[_jsx(RadioDot,{selected:w,color:V,disabled:R&&!w,size:d,style:[!L||w||R?null:{borderColor:C.colors["field-border-error"]},x],dotStyle:f}),_jsx(ChoiceText,{label:a,helperText:l,description:c,error:H,disabled:R,style:{marginLeft:D},labelStyle:b})]})}const buildStyles=e=>StyleSheet.create({row:{flexDirection:"row",alignItems:"center"},rowTop:{alignItems:"flex-start"}});export{Radio};export default Radio;
@@ -1 +1 @@
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=e=>{const{value:o,defaultValue:i,onChange:r,children:a,disabled:t=!1,error:s,accessibilityLabel:l,style:d,testID:u}=e,n=useCallback(e=>{if("string"!=typeof e&&"number"!=typeof e)throw new Error("RadioGroup received a missing value in single mode.");r?.(e)},[r]),[c,p]=useControllableState({controlled:"value"in e,value:o,defaultValue:i??void 0,onChange:n}),m=!0===s||hasFieldText(s),x=useMemo(()=>({selectedValue:c,onChange:p,disabled:t,error:m}),[c,p,t,m]);return _jsxs(RadioGroupContext.Provider,{value:x,children:[_jsx(View,{accessibilityRole:"radiogroup",accessibilityLabel:l,accessibilityState:{disabled:t},"aria-disabled":t,testID:u,style:d,children:a}),_jsx(ChoiceText,{error:"string"==typeof s?s: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=e=>{const{value:o,defaultValue:i,onChange:a,children:r,disabled:t=!1,error:s,accessibilityLabel:l,style:d,testID:u}=e,n=useCallback(e=>{if("string"!=typeof e&&"number"!=typeof e)throw new Error("RadioGroup received a missing value in single mode.");a?.(e)},[a]),[c,p]=useControllableState({controlled:"value"in e,value:o,defaultValue:i??void 0,onChange:n}),m=!0===s||hasFieldText(s),x=useMemo(()=>({selectedValue:c,onChange:p,disabled:t,error:m}),[c,p,t,m]);return _jsxs(RadioGroupContext,{value:x,children:[_jsx(View,{accessibilityRole:"radiogroup",accessibilityLabel:l,accessibilityState:{disabled:t},"aria-disabled":t,testID:u,style:d,children:r}),_jsx(ChoiceText,{error:"string"==typeof s?s: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{fillText,useMobileUiText}from"../../text/index.js";import{RATING_TEXT}from"../../text/phone/rating.g.js";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"],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,starContainerStyle:x,testID:y}=e;assertValidValue("Rating","size",e.size,RATING_SIZES),assertValidValue("Rating","tone",e.tone,RATING_TONES);const f=useMobileUiText("rating",RATING_TEXT),h=useMemo(()=>({...f,...d}),[f,d]),b=useTheme(),S=useMemo(()=>buildStyles(b),[b]),v=!n&&"function"==typeof i,w=a?.5:1,R=resolveSize(o),j=toneColorFor(b,l),T=b.colors.border,_=useRef(R),k=useCallback(e=>{_.current=e.nativeEvent.layout.width},[]),V=useRef(new Map),A=useMemo(()=>{const e=V.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=b.settings.components.rating?.pulseOnPress??!1,M=useCallback(e=>{const t=A[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:b.motion.duration.fast,easing:Easing.bezier(...b.motion.ease["in-out"]),useNativeDriver:nativeDriver}),Animated.spring(t,{toValue:1,damping:b.motion.spring.bouncy.damping,stiffness:b.motion.spring.bouncy.stiffness,mass:b.motion.spring.bouncy.mass,useNativeDriver:nativeDriver})]).start()},[b.motion,A]),E=useCallback((e,t)=>{if(!v||!i)return;const s=clampToStep(e,r,w),a=resolveHaptic(u,"selection");a&&triggerHaptic(a),C&&"number"==typeof t&&M(t),i(s)},[v,i,r,w,M,u,C]),N=useCallback(e=>t=>{if(!v)return;const s=_.current||R,i=t.nativeEvent.locationX??s;let r;r=a&&i<s/2?e+.5:e+1,E(r,e)},[v,R,a,E]),z=useCallback(e=>{v&&("increment"===e.nativeEvent.actionName?E(s+w):"decrement"===e.nativeEvent.actionName&&E(s-w))},[v,s,w,E]),I=fillText(h.value,{value:s,max:r}),D=p??c??I,P=[];for(const[e,t]of A.entries()){const i=_jsx(Star,{index:e,filled:s,size:R,filledColor:j,emptyColor:T,scale:t},e);P.push(v?_jsx(Pressable,{onPress:N(e),onLayout:0===e?k:void 0,hitSlop:4,...hitSlopMarker(4),accessible:!1,style:S.starPress,children:i},e):_jsx(View,{onLayout:0===e?k:void 0,style:S.starPress,children:i},e))}const H=_jsxs(View,{style:[S.wrapper,g],ref:t,testID:y,children:[c?_jsx(Text,{variant:"bodySmall",color:"secondary",style:S.label,children:c}):null,_jsx(View,{style:[S.row,x],accessible:!0,accessibilityRole:v?"adjustable":"text",accessibilityLabel:D,accessibilityValue:v?{min:0,max:r,now:s,text:I}:void 0,accessibilityActions:v?[{name:"increment"},{name:"decrement"}]:void 0,onAccessibilityAction:v?z:void 0,children:P})]});return m?_jsx(RatingSkeleton,{...e}):H});RatingRoot.displayName="Rating";const RatingSkeleton=({max:e=5,size:t="md",label:s,starContainerStyle:i,style:r})=>{const a=useTheme(),n=resolveSize(t),o=Math.max(1,e),l=useMemo(()=>Array.from({length:o},(e,t)=>({key:`sk-star-${t}`,index:t})),[o]);return _jsxs(View,{style:[{alignItems:"flex-start"},r],accessibilityRole:"progressbar",accessibilityState:{busy:!0},"aria-busy":!0,children:[void 0!==s?_jsx(Skeleton,{shape:"text",width:80,height:14,style:{marginBottom:a.space.xs}}):null,_jsx(View,{style:[{flexDirection:"row"},i],children:l.map(({key:e,index:t})=>_jsx(Skeleton,{width:n,height:n,radius:Math.round(.25*n),style:t<o-1?{marginRight:a.space.xs}:void 0},e))})]})};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
+ "use strict";import{useCallback,useMemo,useRef}from"react";import{Animated,Easing,Pressable,StyleSheet,View}from"react-native";import{fillText,useMobileUiText}from"../../text/index.js";import{RATING_TEXT}from"../../text/phone/rating.g.js";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"],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]})};function RatingRoot({ref: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,starContainerStyle:x,testID:y}=t;assertValidValue("Rating","size",t.size,RATING_SIZES),assertValidValue("Rating","tone",t.tone,RATING_TONES);const h=useMobileUiText("rating",RATING_TEXT),f=useMemo(()=>({...h,...d}),[h,d]),b=useTheme(),S=useMemo(()=>buildStyles(b),[b]),v=!n&&"function"==typeof i,j=a?.5:1,w=resolveSize(o),R=toneColorFor(b,l),T=b.colors.border,_=useRef(w),k=useCallback(e=>{_.current=e.nativeEvent.layout.width},[]),V=useRef(new Map),A=useMemo(()=>{const e=V.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=b.settings.components.rating?.pulseOnPress??!1,M=useCallback(e=>{const t=A[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:b.motion.duration.fast,easing:Easing.bezier(...b.motion.ease["in-out"]),useNativeDriver:nativeDriver}),Animated.spring(t,{toValue:1,damping:b.motion.spring.bouncy.damping,stiffness:b.motion.spring.bouncy.stiffness,mass:b.motion.spring.bouncy.mass,useNativeDriver:nativeDriver})]).start()},[b.motion,A]),E=useCallback((e,t)=>{if(!v||!i)return;const s=clampToStep(e,r,j),a=resolveHaptic(u,"selection");a&&triggerHaptic(a),C&&"number"==typeof t&&M(t),i(s)},[v,i,r,j,M,u,C]),N=useCallback(e=>t=>{if(!v)return;const s=_.current||w,i=t.nativeEvent.locationX??s;let r;r=a&&i<s/2?e+.5:e+1,E(r,e)},[v,w,a,E]),z=useCallback(e=>{v&&("increment"===e.nativeEvent.actionName?E(s+j):"decrement"===e.nativeEvent.actionName&&E(s-j))},[v,s,j,E]),I=fillText(f.value,{value:s,max:r}),D=p??c??I,P=[];for(const[e,t]of A.entries()){const i=_jsx(Star,{index:e,filled:s,size:w,filledColor:R,emptyColor:T,scale:t},e);P.push(v?_jsx(Pressable,{onPress:N(e),onLayout:0===e?k:void 0,hitSlop:4,...hitSlopMarker(4),accessible:!1,style:S.starPress,children:i},e):_jsx(View,{onLayout:0===e?k:void 0,style:S.starPress,children:i},e))}const H=_jsxs(View,{style:[S.wrapper,g],ref:e,testID:y,children:[c?_jsx(Text,{variant:"bodySmall",color:"secondary",style:S.label,children:c}):null,_jsx(View,{style:[S.row,x],accessible:!0,accessibilityRole:v?"adjustable":"text",accessibilityLabel:D,accessibilityValue:v?{min:0,max:r,now:s,text:I}:void 0,accessibilityActions:v?[{name:"increment"},{name:"decrement"}]:void 0,onAccessibilityAction:v?z:void 0,children:P})]});return m?_jsx(RatingSkeleton,{...t}):H}RatingRoot.displayName="Rating";const RatingSkeleton=({max:e=5,size:t="md",label:s,starContainerStyle:i,style:r})=>{const a=useTheme(),n=resolveSize(t),o=Math.max(1,e),l=useMemo(()=>Array.from({length:o},(e,t)=>({key:`sk-star-${t}`,index:t})),[o]);return _jsxs(View,{style:[{alignItems:"flex-start"},r],accessibilityRole:"progressbar",accessibilityState:{busy:!0},"aria-busy":!0,children:[void 0!==s?_jsx(Skeleton,{shape:"text",width:80,height:14,style:{marginBottom:a.space.xs}}):null,_jsx(View,{style:[{flexDirection:"row"},i],children:l.map(({key:e,index:t})=>_jsx(Skeleton,{width:n,height:n,radius:Math.round(.25*n),style:t<o-1?{marginRight:a.space.xs}:void 0},e))})]})};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{reportIdleActivity}from"@webority/mobile-core";import{forwardRef,useCallback,useMemo,useState}from"react";import{Pressable,StyleSheet,TextInput,View}from"react-native";import{useMobileUiText}from"../../text/index.js";import{RICH_TEXT_EDITOR_TEXT}from"../../text/phone/richTextEditor.g.js";import{fontFor,useTheme}from"../../theme/index.js";import{resolveHaptic,triggerHaptic}from"../../utils/index.js";import{smoothCorners}from"../../utils/corners.js";import{hitSlopMarker}from"../../utils/hitSlop.js";import{Skeleton}from"../Skeleton/index.js";import{Text}from"../Text/index.js";import{applyMarkdownAction,normalizeSelection}from"./markdownActions.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const ACTION_GLYPH={bold:"B",italic:"I",strikethrough:"S",code:"</>",link:"link",heading1:"H1",heading2:"H2",bulletList:"•",numberedList:"1.",quote:">"},DEFAULT_ACTIONS=["bold","italic","strikethrough","code","link","heading1","heading2","bulletList","numberedList","quote"],DEFAULT_MIN_HEIGHT=160,TOOLBAR_GLYPH_MAX_SCALE=1.5;export const RichTextEditor=forwardRef((e,t)=>{const{value:o,onChangeText:i,placeholder:s,actions:r=DEFAULT_ACTIONS,disabled:l=!1,loading:n=!1,minHeight:a=DEFAULT_MIN_HEIGHT,autoFocus:c=!1,accessibilityLabel:d,haptic:h,labels:u,style:b,toolbarStyle:m,inputStyle:p,testID:x}=e,g=useTheme(),T=useMemo(()=>buildStyles(g),[g]),y=useMobileUiText("richTextEditor",RICH_TEXT_EDITOR_TEXT),S=useMemo(()=>u?{...y,...u}:y,[y,u]),f=o??"",[_,k]=useState({start:0,end:0}),[j,I]=useState(!1),[C,E]=useState(null),H=useCallback(e=>{k(e.nativeEvent.selection),E(null)},[]),w=useCallback(e=>{reportIdleActivity(),E(null),i?.(e)},[i]),L=useCallback(e=>{if(l)return;const t=resolveHaptic(h,"selection");t&&triggerHaptic(t);const o=applyMarkdownAction({text:f,selection:normalizeSelection(_,f.length)},e);k(o.selection),E(o.selection),i?.(o.text)},[l,h,i,_,f]);return n?_jsx(RichTextEditorSkeleton,{actionCount:r.length,minHeight:a,style:b,testID:x}):_jsxs(View,{testID:x,style:[T.container,{borderColor:j?g.colors["focus-ring"]:g.colors.border,opacity:l?.55:1},b],children:[_jsx(View,{style:[T.toolbar,m],children:r.map(e=>_jsx(ToolbarButton,{action:e,label:S[e],disabled:l,onPress:L,styles:T,theme:g,testID:x?`${x}-${e}`:void 0},e))}),_jsx(TextInput,{ref:t,value:f,onChangeText:w,onSelectionChange:H,onFocus:()=>I(!0),onBlur:()=>I(!1),selection:C??void 0,editable:!l,autoFocus:c,multiline:!0,textAlignVertical:"top",placeholder:s,placeholderTextColor:g.colors["text-subtle"],accessibilityLabel:d,style:[T.input,{minHeight:a},p],testID:x?`${x}-input`:void 0})]})});RichTextEditor.displayName="RichTextEditor";const ToolbarButton=({action:e,label:t,disabled:o,onPress:i,styles:s,theme:r,testID:l})=>{const n={color:o?r.colors["text-disabled"]:r.colors["text-body"],..."bold"===e?{fontWeight:r.weight.bold}:{},..."italic"===e?{fontStyle:"italic"}:{},..."strikethrough"===e?{textDecorationLine:"line-through"}:{}};return _jsx(Pressable,{onPress:()=>i(e),disabled:o,accessibilityRole:"button",accessibilityLabel:t,accessibilityState:{disabled:o},"aria-disabled":o,hitSlop:4,...hitSlopMarker(4),testID:l,style:({pressed:e})=>[s.button,{backgroundColor:e?r.colors["surface-pressed"]:r.colors["bg-subtle"]}],children:_jsx(Text,{variant:"body",maxFontSizeMultiplier:Math.min(r.settings.maxFontSizeMultiplier??1.5,1.5),style:[s.buttonLabel,n],children:ACTION_GLYPH[e]})})};ToolbarButton.displayName="RichTextEditorToolbarButton";const RichTextEditorSkeleton=({actionCount:e,minHeight:t,style:o,testID:i})=>{const s=useTheme(),r=useMemo(()=>buildStyles(s),[s]),l=Array.from({length:Math.max(1,e)},(e,t)=>t);return _jsxs(View,{testID:i,style:[r.container,o],children:[_jsx(View,{style:r.toolbar,children:l.map(e=>_jsx(Skeleton,{width:34,height:30,radius:"sm"},e))}),_jsxs(View,{style:[r.skeletonBody,{minHeight:t}],children:[_jsx(Skeleton,{shape:"text",width:"94%",height:14}),_jsx(Skeleton,{shape:"text",width:"100%",height:14}),_jsx(Skeleton,{shape:"text",width:"72%",height:14})]})]})};RichTextEditorSkeleton.displayName="RichTextEditorSkeleton";const buildStyles=e=>StyleSheet.create({container:{borderWidth:e.size.border,borderColor:e.colors.border,borderRadius:e.radius.md,...smoothCorners,backgroundColor:e.colors.bg,overflow:"hidden"},toolbar:{flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:e.space.xs,padding:e.space.xs,borderBottomWidth:StyleSheet.hairlineWidth,borderBottomColor:e.colors["border-subtle"],backgroundColor:e.colors["bg-subtle"]},button:{minWidth:34,height:30,paddingHorizontal:e.space.xs,borderRadius:e.radius.sm,...smoothCorners,alignItems:"center",justifyContent:"center"},buttonLabel:{...fontFor(e,"medium"),fontSize:e.text.sm.size},input:{...fontFor(e,"normal"),color:e.colors["text-body"],fontSize:e.text.base.size,lineHeight:1.5*e.text.base.size,paddingHorizontal:e.space.md,paddingVertical:e.space.sm},skeletonBody:{paddingHorizontal:e.space.md,paddingVertical:e.space.sm,gap:e.space.sm}});export default RichTextEditor;
1
+ "use strict";import{reportIdleActivity}from"@webority/mobile-core";import{useCallback,useMemo,useState}from"react";import{Pressable,StyleSheet,TextInput,View}from"react-native";import{useMobileUiText}from"../../text/index.js";import{RICH_TEXT_EDITOR_TEXT}from"../../text/phone/richTextEditor.g.js";import{fontFor,useTheme}from"../../theme/index.js";import{resolveHaptic,triggerHaptic}from"../../utils/index.js";import{smoothCorners}from"../../utils/corners.js";import{hitSlopMarker}from"../../utils/hitSlop.js";import{Skeleton}from"../Skeleton/index.js";import{Text}from"../Text/index.js";import{applyMarkdownAction,normalizeSelection}from"./markdownActions.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const ACTION_GLYPH={bold:"B",italic:"I",strikethrough:"S",code:"</>",link:"link",heading1:"H1",heading2:"H2",bulletList:"•",numberedList:"1.",quote:">"},DEFAULT_ACTIONS=["bold","italic","strikethrough","code","link","heading1","heading2","bulletList","numberedList","quote"],DEFAULT_MIN_HEIGHT=160,TOOLBAR_GLYPH_MAX_SCALE=1.5;export const RichTextEditor=e=>{const{ref:t,value:o,onChangeText:i,placeholder:s,actions:r=DEFAULT_ACTIONS,disabled:l=!1,loading:n=!1,minHeight:a=DEFAULT_MIN_HEIGHT,autoFocus:c=!1,accessibilityLabel:d,haptic:h,labels:u,style:b,toolbarStyle:m,inputStyle:p,testID:x}=e,g=useTheme(),T=useMemo(()=>buildStyles(g),[g]),y=useMobileUiText("richTextEditor",RICH_TEXT_EDITOR_TEXT),S=useMemo(()=>u?{...y,...u}:y,[y,u]),_=o??"",[f,k]=useState({start:0,end:0}),[j,I]=useState(!1),[C,H]=useState(null),E=useCallback(e=>{k(e.nativeEvent.selection),H(null)},[]),L=useCallback(e=>{reportIdleActivity(),H(null),i?.(e)},[i]),w=useCallback(e=>{if(l)return;const t=resolveHaptic(h,"selection");t&&triggerHaptic(t);const o=applyMarkdownAction({text:_,selection:normalizeSelection(f,_.length)},e);k(o.selection),H(o.selection),i?.(o.text)},[l,h,i,f,_]);return n?_jsx(RichTextEditorSkeleton,{actionCount:r.length,minHeight:a,style:b,testID:x}):_jsxs(View,{testID:x,style:[T.container,{borderColor:j?g.colors["focus-ring"]:g.colors.border,opacity:l?.55:1},b],children:[_jsx(View,{style:[T.toolbar,m],children:r.map(e=>_jsx(ToolbarButton,{action:e,label:S[e],disabled:l,onPress:w,styles:T,theme:g,testID:x?`${x}-${e}`:void 0},e))}),_jsx(TextInput,{ref:t,value:_,onChangeText:L,onSelectionChange:E,onFocus:()=>I(!0),onBlur:()=>I(!1),selection:C??void 0,editable:!l,autoFocus:c,multiline:!0,textAlignVertical:"top",placeholder:s,placeholderTextColor:g.colors["text-subtle"],accessibilityLabel:d,style:[T.input,{minHeight:a},p],testID:x?`${x}-input`:void 0})]})};const ToolbarButton=({action:e,label:t,disabled:o,onPress:i,styles:s,theme:r,testID:l})=>{const n={color:o?r.colors["text-disabled"]:r.colors["text-body"],..."bold"===e?{fontWeight:r.weight.bold}:{},..."italic"===e?{fontStyle:"italic"}:{},..."strikethrough"===e?{textDecorationLine:"line-through"}:{}};return _jsx(Pressable,{onPress:()=>i(e),disabled:o,accessibilityRole:"button",accessibilityLabel:t,accessibilityState:{disabled:o},"aria-disabled":o,hitSlop:4,...hitSlopMarker(4),testID:l,style:({pressed:e})=>[s.button,{backgroundColor:e?r.colors["surface-pressed"]:r.colors["bg-subtle"]}],children:_jsx(Text,{variant:"body",maxFontSizeMultiplier:Math.min(r.settings.maxFontSizeMultiplier??1.5,1.5),style:[s.buttonLabel,n],children:ACTION_GLYPH[e]})})};ToolbarButton.displayName="RichTextEditorToolbarButton";const RichTextEditorSkeleton=({actionCount:e,minHeight:t,style:o,testID:i})=>{const s=useTheme(),r=useMemo(()=>buildStyles(s),[s]),l=Array.from({length:Math.max(1,e)},(e,t)=>t);return _jsxs(View,{testID:i,style:[r.container,o],children:[_jsx(View,{style:r.toolbar,children:l.map(e=>_jsx(Skeleton,{width:34,height:30,radius:"sm"},e))}),_jsxs(View,{style:[r.skeletonBody,{minHeight:t}],children:[_jsx(Skeleton,{shape:"text",width:"94%",height:14}),_jsx(Skeleton,{shape:"text",width:"100%",height:14}),_jsx(Skeleton,{shape:"text",width:"72%",height:14})]})]})};RichTextEditorSkeleton.displayName="RichTextEditorSkeleton";const buildStyles=e=>StyleSheet.create({container:{borderWidth:e.size.border,borderColor:e.colors.border,borderRadius:e.radius.md,...smoothCorners,backgroundColor:e.colors.bg,overflow:"hidden"},toolbar:{flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:e.space.xs,padding:e.space.xs,borderBottomWidth:StyleSheet.hairlineWidth,borderBottomColor:e.colors["border-subtle"],backgroundColor:e.colors["bg-subtle"]},button:{minWidth:34,height:30,paddingHorizontal:e.space.xs,borderRadius:e.radius.sm,...smoothCorners,alignItems:"center",justifyContent:"center"},buttonLabel:{...fontFor(e,"medium"),fontSize:e.text.sm.size},input:{...fontFor(e,"normal"),color:e.colors["text-body"],fontSize:e.text.base.size,lineHeight:1.5*e.text.base.size,paddingHorizontal:e.space.md,paddingVertical:e.space.sm},skeletonBody:{paddingHorizontal:e.space.md,paddingVertical:e.space.sm,gap:e.space.sm}});export default RichTextEditor;
@@ -1 +1 @@
1
- "use strict";import{forwardRef,useEffect,useMemo,useRef,useState}from"react";import{Animated,StyleSheet,View}from"react-native";import{useSafeAreaInsets}from"react-native-safe-area-context";import{useReducedMotion}from"../../hooks/useReducedMotion.js";import{useMobileUiText}from"../../text/index.js";import{SCANNER_OVERLAY_TEXT}from"../../text/phone/scannerOverlay.g.js";import{createAnimatedValue,useTheme}from"../../theme/index.js";import{announce}from"../../utils/announce.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{smoothCorners}from"../../utils/corners.js";import{triggerHaptic}from"../../utils/hapticUtils.js";import{nativeDriver}from"../../utils/nativeDriver.js";import{AppIcon}from"../AppIcon/index.js";import{Button}from"../Button/index.js";import{EmptyState}from"../EmptyState/index.js";import{IconButton}from"../IconButton/index.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";const MIN_FRAME=240,DEFAULT_FRAME=260,MARK_LENGTH=32,MARK_THICKNESS=4,BREATHE_SCALE=1.03,SNAP_SCALE=1.08,T=4,CORNERS=[{key:"tl",style:{top:0,left:0,borderTopWidth:4,borderLeftWidth:4}},{key:"tr",style:{top:0,right:0,borderTopWidth:4,borderRightWidth:4}},{key:"bl",style:{bottom:0,left:0,borderBottomWidth:4,borderLeftWidth:4}},{key:"br",style:{bottom:0,right:0,borderBottomWidth:4,borderRightWidth:4}}],ScannerOverlay=forwardRef((e,t)=>{assertValidValue("ScannerOverlay","state",e.state,["scanning","found","invalid","noPermission","noCamera"]);const{children:i,state:o,helperText:n,labels:s,torch:r=!1,onTorchChange:a,onManualEntry:l,onGallery:c,onPermissionAction:d,frameSize:m=DEFAULT_FRAME,haptic:u,style:h,testID:p}=e,f=o??"scanning",g=useTheme(),y=useSafeAreaInsets(),x=useReducedMotion(),b=useMemo(()=>buildStyles(g),[g]),v=useMobileUiText("scannerOverlay",SCANNER_OVERLAY_TEXT),j=useMemo(()=>({...v,...s}),[v,s]),S=n??j.hint,[_,E]=useState({width:0,height:0}),[w,A]=useState(0),V="scanning"===f||"found"===f||"invalid"===f,R=useRef(createAnimatedValue(1)).current,C=g.motion.duration.slower,M=g.motion.duration.default;useEffect(()=>{if(R.setValue(1),x)return;let e;return"scanning"===f&&C>0?e=Animated.loop(Animated.sequence([Animated.timing(R,{toValue:1.03,duration:2*C,useNativeDriver:nativeDriver}),Animated.timing(R,{toValue:1,duration:2*C,useNativeDriver:nativeDriver})])):"found"===f&&M>0&&(R.setValue(1.08),e=Animated.timing(R,{toValue:1,duration:M,useNativeDriver:nativeDriver})),e?.start(),()=>e?.stop()},[f,x,C,M,R]);const I=useRef(f);useEffect(()=>{I.current!==f&&(I.current=f,!1!==u&&("found"===f?triggerHaptic("notificationSuccess"):"invalid"===f&&triggerHaptic("notificationError")))},[f,u]);const{found:k,invalid:D}=j,{noPermissionTitle:N,noPermissionMessage:O}=j,{noCameraTitle:P,noCameraMessage:F}=j;useEffect(()=>{switch(f){case"scanning":announce(S);break;case"found":announce(k);break;case"invalid":announce(D,{polite:!1});break;case"noPermission":announce(`${N}. ${O}`);break;case"noCamera":announce(`${P}. ${F}`)}},[f,S,k,D,N,O,P,F]);const L=Math.max(240,Math.min(m,_.width-2*g.space.xl)),B=(_.width-L)/2,H=Math.max(g.space.md,(_.height-w-L)/2),W=_.width>0&&_.height>0,z={borderColor:"found"===f?g.colors.success:"invalid"===f?g.colors.danger:g.colors["on-scrim"],width:32,height:32},U="found"===f||"invalid"===f?_jsx(View,{style:[b.pill,{backgroundColor:"found"===f?g.colors.success:g.colors.danger}],children:_jsx(Text,{variant:"bodySmall",weight:"semibold",align:"center",style:{color:"found"===f?g.colors["on-success"]:g.colors["on-danger"]},children:"found"===f?k:D})}):_jsx(Text,{variant:"bodySmall",align:"center",style:{color:g.colors["on-scrim"]},children:S}),$=V&&null!=a,K=V?"glass":"outline";return _jsxs(View,{ref:t,testID:p,onLayout:e=>{const{width:t,height:i}=e.nativeEvent.layout;E(e=>e.width===t&&e.height===i?e:{width:t,height:i})},style:[b.root,!V&&{backgroundColor:g.colors.bg},h],children:[V?_jsx(View,{style:StyleSheet.absoluteFill,children:i}):null,V&&W?_jsx(_Fragment,{children:_jsxs(View,{pointerEvents:"none",style:StyleSheet.absoluteFill,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:[_jsx(View,{style:[b.scrim,{left:0,right:0,top:0,height:H}]}),_jsx(View,{style:[b.scrim,{left:0,right:0,top:H+L,bottom:0}]}),_jsx(View,{style:[b.scrim,{left:0,width:B,top:H,height:L}]}),_jsx(View,{style:[b.scrim,{left:B+L,right:0,top:H,height:L}]}),_jsx(Animated.View,{style:{position:"absolute",left:B,top:H,width:L,height:L,transform:[{scale:R}]},children:CORNERS.map(e=>_jsx(View,{style:[b.mark,z,e.style]},e.key))})]})}):null,V?null:_jsx(View,{style:b.panel,children:_jsx(EmptyState,{fill:!0,icon:_jsx(AppIcon,{name:"noPermission"===f?"camera":"camera-slash",size:48,color:g.colors["text-subtle"]}),title:"noPermission"===f?N:P,description:"noPermission"===f?O:F,action:"noPermission"===f&&d?{label:j.permissionAction,onPress:d}:void 0})}),_jsxs(View,{pointerEvents:"box-none",onLayout:e=>{const{height:t}=e.nativeEvent.layout;A(e=>e===t?e:t)},style:[b.bar,{paddingBottom:Math.max(y.bottom,g.space.md)}],children:[V&&W?_jsx(View,{pointerEvents:"none",style:b.message,children:U}):null,_jsxs(View,{style:b.actions,children:[$?_jsx(IconButton,{icon:r?"flash":"flash-slash",variant:"glass",size:"lg",active:r,haptic:u,accessibilityLabel:r?j.torchOff:j.torchOn,onPress:()=>a?.(!r)}):null,c?_jsx(Button,{label:j.gallery,leftIcon:"gallery",variant:K,tone:"neutral",size:"lg",haptic:u,onPress:c}):null,l?_jsx(Button,{label:j.manualEntry,leftIcon:"keyboard",variant:K,tone:"neutral",size:"lg",haptic:u,onPress:l}):null]})]})]})});ScannerOverlay.displayName="ScannerOverlay";const buildStyles=e=>StyleSheet.create({root:{flex:1,overflow:"hidden"},scrim:{position:"absolute",backgroundColor:e.colors.scrim},mark:{position:"absolute"},message:{alignItems:"center",paddingHorizontal:e.space.xl},pill:{paddingHorizontal:e.space.md,paddingVertical:e.space.xs,borderRadius:e.radius.pill,...smoothCorners},panel:{...StyleSheet.absoluteFill,justifyContent:"center"},bar:{position:"absolute",left:0,right:0,bottom:0,flexDirection:"column",alignItems:"center",justifyContent:"center",gap:e.space.sm,paddingHorizontal:e.space.md},actions:{flexDirection:"row",flexWrap:"wrap",alignItems:"center",justifyContent:"center",gap:e.space.sm}});export{ScannerOverlay};export default ScannerOverlay;
1
+ "use strict";import{useEffect,useMemo,useRef,useState}from"react";import{Animated,StyleSheet,View}from"react-native";import{useSafeAreaInsets}from"react-native-safe-area-context";import{useReducedMotion}from"../../hooks/useReducedMotion.js";import{useMobileUiText}from"../../text/index.js";import{SCANNER_OVERLAY_TEXT}from"../../text/phone/scannerOverlay.g.js";import{createAnimatedValue,useTheme}from"../../theme/index.js";import{announce}from"../../utils/announce.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{smoothCorners}from"../../utils/corners.js";import{triggerHaptic}from"../../utils/hapticUtils.js";import{nativeDriver}from"../../utils/nativeDriver.js";import{AppIcon}from"../AppIcon/index.js";import{Button}from"../Button/index.js";import{EmptyState}from"../EmptyState/index.js";import{IconButton}from"../IconButton/index.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";const MIN_FRAME=240,DEFAULT_FRAME=260,MARK_LENGTH=32,MARK_THICKNESS=4,BREATHE_SCALE=1.03,SNAP_SCALE=1.08,T=4,CORNERS=[{key:"tl",style:{top:0,left:0,borderTopWidth:4,borderLeftWidth:4}},{key:"tr",style:{top:0,right:0,borderTopWidth:4,borderRightWidth:4}},{key:"bl",style:{bottom:0,left:0,borderBottomWidth:4,borderLeftWidth:4}},{key:"br",style:{bottom:0,right:0,borderBottomWidth:4,borderRightWidth:4}}];function ScannerOverlay(e){assertValidValue("ScannerOverlay","state",e.state,["scanning","found","invalid","noPermission","noCamera"]);const{children:t,state:i,helperText:o,labels:n,torch:s=!1,onTorchChange:r,onManualEntry:a,onGallery:l,onPermissionAction:c,frameSize:d=DEFAULT_FRAME,haptic:m,style:u,testID:h,ref:p}=e,f=i??"scanning",g=useTheme(),y=useSafeAreaInsets(),x=useReducedMotion(),b=useMemo(()=>buildStyles(g),[g]),v=useMobileUiText("scannerOverlay",SCANNER_OVERLAY_TEXT),j=useMemo(()=>({...v,...n}),[v,n]),S=o??j.hint,[_,E]=useState({width:0,height:0}),[A,w]=useState(0),V="scanning"===f||"found"===f||"invalid"===f,R=useRef(createAnimatedValue(1)).current,C=g.motion.duration.slower,M=g.motion.duration.default;useEffect(()=>{if(R.setValue(1),x)return;let e;return"scanning"===f&&C>0?e=Animated.loop(Animated.sequence([Animated.timing(R,{toValue:1.03,duration:2*C,useNativeDriver:nativeDriver}),Animated.timing(R,{toValue:1,duration:2*C,useNativeDriver:nativeDriver})])):"found"===f&&M>0&&(R.setValue(1.08),e=Animated.timing(R,{toValue:1,duration:M,useNativeDriver:nativeDriver})),e?.start(),()=>e?.stop()},[f,x,C,M,R]);const I=useRef(f);useEffect(()=>{I.current!==f&&(I.current=f,!1!==m&&("found"===f?triggerHaptic("notificationSuccess"):"invalid"===f&&triggerHaptic("notificationError")))},[f,m]);const{found:k,invalid:D}=j,{noPermissionTitle:P,noPermissionMessage:N}=j,{noCameraTitle:F,noCameraMessage:L}=j;useEffect(()=>{switch(f){case"scanning":announce(S);break;case"found":announce(k);break;case"invalid":announce(D,{polite:!1});break;case"noPermission":announce(`${P}. ${N}`);break;case"noCamera":announce(`${F}. ${L}`)}},[f,S,k,D,P,N,F,L]);const O=Math.max(240,Math.min(d,_.width-2*g.space.xl)),B=(_.width-O)/2,H=Math.max(g.space.md,(_.height-A-O)/2),W=_.width>0&&_.height>0,z={borderColor:"found"===f?g.colors.success:"invalid"===f?g.colors.danger:g.colors["on-scrim"],width:32,height:32},U="found"===f||"invalid"===f?_jsx(View,{style:[b.pill,{backgroundColor:"found"===f?g.colors.success:g.colors.danger}],children:_jsx(Text,{variant:"bodySmall",weight:"semibold",align:"center",style:{color:"found"===f?g.colors["on-success"]:g.colors["on-danger"]},children:"found"===f?k:D})}):_jsx(Text,{variant:"bodySmall",align:"center",style:{color:g.colors["on-scrim"]},children:S}),$=V&&null!=r,K=V?"glass":"outline";return _jsxs(View,{ref:p,testID:h,onLayout:e=>{const{width:t,height:i}=e.nativeEvent.layout;E(e=>e.width===t&&e.height===i?e:{width:t,height:i})},style:[b.root,!V&&{backgroundColor:g.colors.bg},u],children:[V?_jsx(View,{style:StyleSheet.absoluteFill,children:t}):null,V&&W?_jsx(_Fragment,{children:_jsxs(View,{pointerEvents:"none",style:StyleSheet.absoluteFill,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:[_jsx(View,{style:[b.scrim,{left:0,right:0,top:0,height:H}]}),_jsx(View,{style:[b.scrim,{left:0,right:0,top:H+O,bottom:0}]}),_jsx(View,{style:[b.scrim,{left:0,width:B,top:H,height:O}]}),_jsx(View,{style:[b.scrim,{left:B+O,right:0,top:H,height:O}]}),_jsx(Animated.View,{style:{position:"absolute",left:B,top:H,width:O,height:O,transform:[{scale:R}]},children:CORNERS.map(e=>_jsx(View,{style:[b.mark,z,e.style]},e.key))})]})}):null,V?null:_jsx(View,{style:b.panel,children:_jsx(EmptyState,{fill:!0,icon:_jsx(AppIcon,{name:"noPermission"===f?"camera":"camera-slash",size:48,color:g.colors["text-subtle"]}),title:"noPermission"===f?P:F,description:"noPermission"===f?N:L,action:"noPermission"===f&&c?{label:j.permissionAction,onPress:c}:void 0})}),_jsxs(View,{pointerEvents:"box-none",onLayout:e=>{const{height:t}=e.nativeEvent.layout;w(e=>e===t?e:t)},style:[b.bar,{paddingBottom:Math.max(y.bottom,g.space.md)}],children:[V&&W?_jsx(View,{pointerEvents:"none",style:b.message,children:U}):null,_jsxs(View,{style:b.actions,children:[$?_jsx(IconButton,{icon:s?"flash":"flash-slash",variant:"glass",size:"lg",active:s,haptic:m,accessibilityLabel:s?j.torchOff:j.torchOn,onPress:()=>r?.(!s)}):null,l?_jsx(Button,{label:j.gallery,leftIcon:"gallery",variant:K,tone:"neutral",size:"lg",haptic:m,onPress:l}):null,a?_jsx(Button,{label:j.manualEntry,leftIcon:"keyboard",variant:K,tone:"neutral",size:"lg",haptic:m,onPress:a}):null]})]})]})}const buildStyles=e=>StyleSheet.create({root:{flex:1,overflow:"hidden"},scrim:{position:"absolute",backgroundColor:e.colors.scrim},mark:{position:"absolute"},message:{alignItems:"center",paddingHorizontal:e.space.xl},pill:{paddingHorizontal:e.space.md,paddingVertical:e.space.xs,borderRadius:e.radius.pill,...smoothCorners},panel:{...StyleSheet.absoluteFill,justifyContent:"center"},bar:{position:"absolute",left:0,right:0,bottom:0,flexDirection:"column",alignItems:"center",justifyContent:"center",gap:e.space.sm,paddingHorizontal:e.space.md},actions:{flexDirection:"row",flexWrap:"wrap",alignItems:"center",justifyContent:"center",gap:e.space.sm}});export{ScannerOverlay};export default ScannerOverlay;
@@ -1 +1 @@
1
- "use strict";import{cloneElement,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{KeyboardAwareScrollView}from"../KeyboardAwareScrollView/index.js";import{KeyboardToolbar}from"../KeyboardToolbar/index.js";import{PagedList}from"../PagedList/index.js";import{ScrollHostContext}from"./ScrollHost.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const DEFAULT_EDGES=["top","bottom"],SCROLL_EVENT_THROTTLE=16,noop=()=>{},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:r=!0,headerShadowOnScroll:n,onBack:a,rightActions:l,leading:s,trailing:i,children:d,onRefresh:c,refreshing:u=!1,footer:f,scroll:p=!0,list:m,edges:g=DEFAULT_EDGES,keyboardToolbar:h=!0,bottomInset:S=0,gutter:v,floatingAction:b,scrollRef:y,onScroll:x,contentContainerStyle:C,testID:T}=e,E=useTheme(),j=v??void 0===m,R=E.space[E.components.screen.gutter],w=j?R:0,V=useSafeAreaInsets(),k=useMemo(()=>buildStyles(E),[E]),[A]=useState(()=>new Animated.Value(0)),[L,_]=useState(0),[O,B]=useState(0),P=void 0!==a,z=useRef(a);z.current=a;const D=Boolean(t||o||a||s||i||l?.length),H=r&&void 0!==t,I=H&&(void 0!==m||p),K=I?L:0,M=D&&!I&&(n??E.settings.components.screen?.headerShadowOnScroll??!0),[F,N]=useState(!1),W=useRef(M);W.current=M;const headerGap=e=>e>0?e:D?E.space.lg:0,G=void 0!==f,{refreshControl:U}=useRefreshControl({onRefresh:c??noop,refreshing:u}),Y=c?cloneElement(U,{progressViewOffset:K}):void 0,$=useSharedValue(0),q=useSharedValue(0),J=useSharedValue(0),Q=useSharedValue(0),X=useRef(null),Z=useRef(0),ee=useRef(0),te=useMemo(()=>({top:$,bottom:q,offset:J,maxOffset:Q,scrollTo:e=>{const t=X.current;t instanceof FlatList?t.scrollToOffset({offset:e,animated:!1}):t?.scrollTo({y:e,animated:!1})}}),[$,q,J,Q]),oe=useCallback(e=>{X.current=e,"function"==typeof y?y(e):y&&(y.current=e)},[y]),re=useCallback(()=>{Q.value=Math.max(0,Z.current-ee.current)},[Q]),ne=useRef(x);ne.current=x;const ae=useMemo(()=>Animated.event([{nativeEvent:{contentOffset:{y:A}}}],{useNativeDriver:!1,listener:e=>{if(J.value=e.nativeEvent.contentOffset.y,W.current){const t=e.nativeEvent.contentOffset.y>0;N(e=>e===t?e:t)}ne.current?.(e)}}),[A,J]),le=useCallback(e=>{const{height:t}=e.nativeEvent.layout;_(e=>Math.max(e,t))},[]),se=useCallback(e=>{B(e.nativeEvent.layout.height)},[]);useEffect(()=>{if(!P)return;const e=BackHandler.addEventListener("hardwareBackPress",()=>(z.current?.(),!0));return()=>e.remove()},[P]);const ie=g.includes("left")?V.left:0,de=g.includes("right")?V.right:0,ce=g.includes("bottom")?V.bottom:0,ue=g.includes("top")&&!D?V.top:0,fe=E.space[E.components["floating-action-button"]["bottom-offset"]],pe=b?.props.bottomOffset??fe,me=b?resolveFloatingActionButtonSize(E,b.props.size??"md").diameter+pe+E.space.lg:0,ge=G?Math.max(0,O-V.bottom):S,he=b?cloneElement(b,{bottomOffset:pe+ge,position:b.props.position??"bottomRight"}):null,Se=G?me:Math.max(ce,b?me+V.bottom:0),ve=S+Se-(G?0:ce),be=g.filter(e=>"top"!==e&&!("bottom"===e&&G)),ye=D?_jsx(View,{style:I?k.overlay:M?k.headerRaised:void 0,onLayout:I?le:void 0,children:_jsx(AppBar,{title:t,subtitle:o,variant:H?"large":"default",scrollY:I?A:void 0,elevated:M&&F,onBack:a,rightActions:l,leading:s,trailing:i,gutter:R,testID:T?`${T}-app-bar`:void 0})}):null,xe=useCallback(()=>{const e=X.current?.getNativeScrollRef();e&&e.measureInWindow((e,t,o,r)=>{ee.current=r,$.value=t+K,q.value=t+r,re()})},[K,$,q,re]);useEffect(()=>{xe()},[xe]);const Ce=useCallback((e,t)=>{Z.current=t,re()},[re]);let Te;if(void 0!==m){const e=topPaddingOf([m.contentContainerStyle,C]);Te=_jsx(ScrollHostContext.Provider,{value:te,children:_jsx(PagedList,{...m,ref:oe,onRefresh:m.state?void 0:c,refreshing:m.state?void 0:u,progressViewOffset:K,placeholderStyle:[k.flex,{paddingTop:K+headerGap(e)}],onScroll:ae,onLayout:e=>{xe(),m.onLayout?.(e)},onContentSizeChange:(e,t)=>{Ce(e,t),m.onContentSizeChange?.(e,t)},scrollEventThrottle:16,style:k.flex,contentContainerStyle:[{paddingTop:K,paddingLeft:ie+w,paddingRight:de+w},{paddingBottom:S+Se},m.contentContainerStyle,C,{paddingTop:K+headerGap(e)}]})})}else Te=p?_jsx(ScrollHostContext.Provider,{value:te,children:_jsxs(KeyboardAwareScrollView,{ref:oe,refreshControl:Y,onScroll:ae,scrollEventThrottle:16,onLayout:xe,onContentSizeChange:Ce,safeAreaEdges:be,style:k.flex,contentContainerStyle:[{paddingHorizontal:w},C,{paddingTop:K+headerGap(topPaddingOf(C))}],children:[d,ve>0?_jsx(View,{style:{height:ve}}):null]})}):_jsx(View,{style:[k.flex,{paddingLeft:ie+w,paddingRight:de+w,paddingBottom:S+Se},C],children:d});const Ee=G?_jsx(KeyboardStickyView,{onLayout:se,style:[k.footer,{paddingLeft:ie+R,paddingRight:de+R,paddingBottom:ce+S}],children:f}):null;return _jsxs(View,{testID:T,style:[k.root,{paddingTop:ue}],children:[I?null:ye,Te,Ee,he,void 0!==m?d:null,I?ye:null,h?_jsx(KeyboardToolbar,{}):null]})}
1
+ "use strict";import{cloneElement,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{KeyboardAwareScrollView}from"../KeyboardAwareScrollView/index.js";import{KeyboardToolbar}from"../KeyboardToolbar/index.js";import{PagedList}from"../PagedList/index.js";import{ScrollHostContext}from"./ScrollHost.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const DEFAULT_EDGES=["top","bottom"],SCROLL_EVENT_THROTTLE=16,noop=()=>{},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:a,rightActions:l,leading:s,trailing:i,children:d,onRefresh:c,refreshing:u=!1,footer:f,scroll:p=!0,list:m,edges:g=DEFAULT_EDGES,keyboardToolbar:h=!0,bottomInset:S=0,gutter:b,floatingAction:v,scrollRef:y,onScroll:x,contentContainerStyle:C,testID:T}=e,E=useTheme(),j=b??void 0===m,R=E.space[E.components.screen.gutter],w=j?R:0,V=useSafeAreaInsets(),k=useMemo(()=>buildStyles(E),[E]),[A]=useState(()=>new Animated.Value(0)),[L,_]=useState(0),[O,B]=useState(0),z=void 0!==a,D=useRef(a);D.current=a;const H=Boolean(t||o||a||s||i||l?.length),I=n&&void 0!==t,K=I&&(void 0!==m||p),M=K?L:0,P=H&&!K&&(r??E.settings.components.screen?.headerShadowOnScroll??!0),[F,N]=useState(!1),W=useRef(P);W.current=P;const headerGap=e=>e>0?e:H?E.space.lg:0,G=void 0!==f,{refreshControl:U}=useRefreshControl({onRefresh:c??noop,refreshing:u}),Y=c?cloneElement(U,{progressViewOffset:M}):void 0,$=useSharedValue(0),q=useSharedValue(0),J=useSharedValue(0),Q=useSharedValue(0),X=useRef(null),Z=useRef(0),ee=useRef(0),te=useMemo(()=>({top:$,bottom:q,offset:J,maxOffset:Q,scrollTo:e=>{const t=X.current;t instanceof FlatList?t.scrollToOffset({offset:e,animated:!1}):t?.scrollTo({y:e,animated:!1})}}),[$,q,J,Q]),oe=useCallback(e=>{X.current=e,"function"==typeof y?y(e):y&&(y.current=e)},[y]),ne=useCallback(()=>{Q.value=Math.max(0,Z.current-ee.current)},[Q]),re=useRef(x);re.current=x;const ae=useMemo(()=>Animated.event([{nativeEvent:{contentOffset:{y:A}}}],{useNativeDriver:!1,listener:e=>{if(J.value=e.nativeEvent.contentOffset.y,W.current){const t=e.nativeEvent.contentOffset.y>0;N(e=>e===t?e:t)}re.current?.(e)}}),[A,J]),le=useCallback(e=>{const{height:t}=e.nativeEvent.layout;_(e=>Math.max(e,t))},[]),se=useCallback(e=>{B(e.nativeEvent.layout.height)},[]);useEffect(()=>{if(!z)return;const e=BackHandler.addEventListener("hardwareBackPress",()=>(D.current?.(),!0));return()=>e.remove()},[z]);const ie=g.includes("left")?V.left:0,de=g.includes("right")?V.right:0,ce=g.includes("bottom")?V.bottom:0,ue=g.includes("top")&&!H?V.top:0,fe=E.space[E.components["floating-action-button"]["bottom-offset"]],pe=v?.props.bottomOffset??fe,me=v?resolveFloatingActionButtonSize(E,v.props.size??"md").diameter+pe+E.space.lg:0,ge=G?Math.max(0,O-V.bottom):S,he=v?cloneElement(v,{bottomOffset:pe+ge,position:v.props.position??"bottomRight"}):null,Se=G?me:Math.max(ce,v?me+V.bottom:0),be=S+Se-(G?0:ce),ve=g.filter(e=>"top"!==e&&!("bottom"===e&&G)),ye=H?_jsx(View,{style:K?k.overlay:P?k.headerRaised:void 0,onLayout:K?le:void 0,children:_jsx(AppBar,{title:t,subtitle:o,variant:I?"large":"default",scrollY:K?A:void 0,elevated:P&&F,onBack:a,rightActions:l,leading:s,trailing:i,gutter:R,testID:T?`${T}-app-bar`:void 0})}):null,xe=useCallback(()=>{const e=X.current?.getNativeScrollRef();e&&e.measureInWindow((e,t,o,n)=>{ee.current=n,$.value=t+M,q.value=t+n,ne()})},[M,$,q,ne]);useEffect(()=>{xe()},[xe]);const Ce=useCallback((e,t)=>{Z.current=t,ne()},[ne]);let Te;if(void 0!==m){const e=topPaddingOf([m.contentContainerStyle,C]);Te=_jsx(ScrollHostContext,{value:te,children:_jsx(PagedList,{...m,ref:oe,onRefresh:m.state?void 0:c,refreshing:m.state?void 0:u,progressViewOffset:M,placeholderStyle:[k.flex,{paddingTop:M+headerGap(e)}],onScroll:ae,onLayout:e=>{xe(),m.onLayout?.(e)},onContentSizeChange:(e,t)=>{Ce(e,t),m.onContentSizeChange?.(e,t)},scrollEventThrottle:16,style:k.flex,contentContainerStyle:[{paddingTop:M,paddingLeft:ie+w,paddingRight:de+w},{paddingBottom:S+Se},m.contentContainerStyle,C,{paddingTop:M+headerGap(e)}]})})}else Te=p?_jsx(ScrollHostContext,{value:te,children:_jsxs(KeyboardAwareScrollView,{ref:oe,refreshControl:Y,onScroll:ae,scrollEventThrottle:16,onLayout:xe,onContentSizeChange:Ce,safeAreaEdges:ve,style:k.flex,contentContainerStyle:[{paddingHorizontal:w},C,{paddingTop:M+headerGap(topPaddingOf(C))}],children:[d,be>0?_jsx(View,{style:{height:be}}):null]})}):_jsx(View,{style:[k.flex,{paddingLeft:ie+w,paddingRight:de+w,paddingBottom:S+Se},C],children:d});const Ee=G?_jsx(KeyboardStickyView,{onLayout:se,style:[k.footer,{paddingLeft:ie+R,paddingRight:de+R,paddingBottom:ce+S}],children:f}):null;return _jsxs(View,{testID:T,style:[k.root,{paddingTop:ue}],children:[K?null:ye,Te,Ee,he,void 0!==m?d:null,K?ye:null,h?_jsx(KeyboardToolbar,{}):null]})}
@@ -1 +1 @@
1
- "use strict";import{reportIdleActivity}from"@webority/mobile-core";import{forwardRef,useCallback,useEffect,useMemo,useRef,useState}from"react";import{Pressable,StyleSheet,TextInput,View}from"react-native";import{useControllableState}from"../../hooks/useControllableState.js";import{useDebounce}from"../../hooks/useDebounce.js";import{fillText,pluralText,useMobileUiText}from"../../text/index.js";import{SEARCH_BAR_TEXT}from"../../text/phone/searchBar.g.js";import{resolveFieldSize,useTheme}from"../../theme/index.js";import{announce}from"../../utils/announce.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{resolveHaptic,triggerHaptic}from"../../utils/hapticUtils.js";import{hitSlopMarker}from"../../utils/hitSlop.js";import{mergeRefs}from"../../utils/mergeRefs.js";import{defaultIcons}from"../AppIcon/defaultIcons.js";import{renderSlotIcon}from"../AppIcon/slotIcon.js";import{FieldBase,FieldLabel,resolveFieldTextStyle,resolveVariantColors}from"../FieldBase/FieldBase.js";import{useFloatingLabel}from"../FieldBase/useFloatingLabel.js";import{normalizeSuggestion,SearchRecents,SearchScopeBar,SearchSuggestions}from"./SearchPanel.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const DEFAULT_PANEL_ROWS=8,HOLD_RELEASE_MS=50,SearchBar=forwardRef((e,l)=>{const{value:s,onChangeText:t,onSubmit:o,onFocus:a,onBlur:i,placeholder:r,autoFocus:n=!1,disabled:c=!1,onClear:u,leftIcon:d,debounceMs:p,size:b="md",variant:f,radius:m,label:h,labelMode:S="top",labelStyle:g,scopes:x,scope:v,onScopeChange:C,recents:y,maxRecents:j=DEFAULT_PANEL_ROWS,onSelectRecent:R,onRemove:T,onClearRecents:F,suggestions:_,maxSuggestions:k=DEFAULT_PANEL_ROWS,onSelect:B,haptic:E,labels:V,style:I,inputStyle:L,accessibilityLabel:A,testID:M,...z}=e;assertValidValue("SearchBar","size",e.size,["sm","md","lg"]),assertValidValue("SearchBar","variant",e.variant,["outline","filled","underline"]),assertValidValue("SearchBar","labelMode",e.labelMode,["top","float"]);const H=useTheme(),w=useMobileUiText("searchBar",SEARCH_BAR_TEXT),D=useMemo(()=>({...w,...V}),[w,V]),P=r??D.placeholder,N=f??H.settings.components["search-bar"]?.defaultVariant??H.settings.components.field?.defaultVariant??"filled",O="underline"===N,U=resolveFieldSize(H,b),W=m??H.components["search-bar"][b].radius,X=resolveFieldTextStyle(H,{disabled:c}),q=useRef(null),K=useMemo(()=>mergeRefs(q,l),[l]),$=useCallback(()=>{c||q.current?.focus()},[c]),G=useMemo(()=>buildStyles(H),[H]),J="string"==typeof s?s:"",[Q,Y]=useState(!1),Z=useCallback(e=>{Y(!0),a?.(e)},[a]),ee=useCallback(e=>{Y(!1),i?.(e)},[i]),[le,se]=useState(J),te=useRef(le);te.current=le;const oe=useDebounce(le,p??0);useEffect(()=>{void 0!==p&&J!==te.current&&se(J)},[J,p]);const ae=useRef(J);useEffect(()=>{void 0!==p&&oe!==ae.current&&(ae.current=oe,t(oe))},[oe,p,t]);const ie=useCallback(e=>{reportIdleActivity(),void 0===p?t(e):se(e)},[p,t]),re=useCallback(()=>{const e=resolveHaptic(E,"selection");e&&triggerHaptic(e),void 0!==p&&(se(""),ae.current=""),t(""),u?.()},[E,p,t,u]),ne=useCallback(()=>{o?.(void 0!==p?le:J)},[o,p,le,J]),ce=void 0!==p?le:J,ue=ce.length>0,[de,pe]=useControllableState({value:v,defaultValue:x?.[0]?.value??"",onChange:C}),be=useCallback(e=>{pe(e);const l=x?.find(l=>l.value===e)?.label;l&&announce(fillText(D.searching,{label:l}))},[x,pe,D]),[fe,me]=useState(!1),he=useRef(null),Se=useCallback(()=>{he.current&&(clearTimeout(he.current),he.current=null)},[]),ge=useCallback(()=>{Se(),me(!0)},[Se]),xe=useCallback(()=>{Se(),he.current=setTimeout(()=>me(!1),50)},[Se]);useEffect(()=>Se,[Se]);const ve=!c&&(Q||fe),Ce=useMemo(()=>(y??[]).slice(0,j),[y,j]),ye=useMemo(()=>(_??[]).slice(0,k).map(normalizeSuggestion),[_,k]),je=ve&&!ue&&Ce.length>0,Re=ve&&ue&&ye.length>0,Te=Re?ye.length:0,Fe=Te>0?pluralText(D,"suggestionCount",Te):"";useEffect(()=>{Fe&&announce(Fe)},[Fe]);const ke=useCallback(()=>{const e=resolveHaptic(E,"selection");e&&triggerHaptic(e)},[E]),Be=useCallback(e=>{ke(),q.current?.blur(),me(!1),R?.(e)},[ke,R]),Ee=useCallback(e=>{ke(),q.current?.blur(),me(!1),B?.(e)},[ke,B]),Ve=useCallback(e=>{ke(),T?.(e),announce(fillText(D.removed,{text:e})),$()},[ke,T,$,D]),Ie=useCallback(()=>{ke(),F?.(),announce(D.recentsCleared),$()},[ke,F,$,D]),Le={size:U.icon,color:c?H.colors["text-disabled"]:H.colors["text-subtle"],disabled:c},Ae=d?renderSlotIcon(d,Le):(H.settings.icons.search??defaultIcons.search)(Le),Me=_jsx(View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:Ae}),ze=Boolean(h)&&"float"===S,He=useFloatingLabel({label:h,enabled:ze,floated:Q||ue,variant:N,sizeTokens:U,leadingOffset:U.icon+H.space.md,trailingOffset:ue?U.icon+H.space.md:0,paddingLeft:O?H.space.none:U["padding-x"],color:H.colors["field-label"],style:g}),we=ue&&!c?_jsx(Pressable,{onPress:re,hitSlop:8,...hitSlopMarker(8),accessibilityRole:"button",accessibilityLabel:D.clearSearch,children:(H.settings.icons.close??defaultIcons.close)({size:U.icon,color:H.colors["text-muted"]})}):null;return _jsxs(View,{style:I,testID:M,children:[h&&!ze?_jsx(FieldLabel,{size:b,style:g,children:h}):null,_jsx(View,{style:G.root,children:_jsxs(View,{style:G.fieldWrap,children:[_jsx(FieldBase,{testID:M?`${M}-field`:void 0,size:b,variant:N,focused:Q,disabled:c,filled:ue,minHeight:U["min-height"],paddingHorizontal:O?H.space.none:U["padding-x"],radius:W,leading:Me,trailing:we,topNotch:He.topNotch,onPress:$,pressFeedback:!1,accessibilityRole:"search",accessibilityLabel:A??P,children:_jsx(TextInput,{ref:K,style:[G.input,{fontSize:U.text,color:X.color,...X.weightStyle},L],value:ce,onChangeText:ie,onSubmitEditing:ne,onFocus:Z,onBlur:ee,placeholder:!ze||Q||ue?P:void 0,placeholderTextColor:X.placeholderColor,autoFocus:n,editable:!c,returnKeyType:"search",selectionColor:resolveVariantColors(H,N).borderFocusedRepresentative,accessibilityLabel:A??P,accessibilityState:{disabled:c},"aria-disabled":c,...z})}),He.node]})}),x&&x.length>0?_jsx(SearchScopeBar,{scopes:x,scope:de||(x[0]?.value??""),disabled:c,haptic:E,labels:D,onChange:be}):null,je?_jsx(SearchRecents,{recents:Ce,labels:D,onSelect:Be,onRemove:T?Ve:void 0,onClear:F?Ie:void 0,onHold:ge,onRelease:xe}):null,Re?_jsx(SearchSuggestions,{suggestions:ye,query:ce,onSelect:Ee,onHold:ge,onRelease:xe}):null]})});SearchBar.displayName="SearchBar";const buildStyles=e=>StyleSheet.create({root:{flexDirection:"row",alignItems:"center",width:"100%",position:"relative",overflow:"visible"},fieldWrap:{flex:1,position:"relative",overflow:"visible"},input:{flex:1,padding:e.space.none,margin:e.space.none,includeFontPadding:!1}});export{SearchBar};export default SearchBar;
1
+ "use strict";import{reportIdleActivity}from"@webority/mobile-core";import{useCallback,useEffect,useMemo,useRef,useState}from"react";import{Pressable,StyleSheet,TextInput,View}from"react-native";import{useControllableState}from"../../hooks/useControllableState.js";import{useDebounce}from"../../hooks/useDebounce.js";import{fillText,pluralText,useMobileUiText}from"../../text/index.js";import{SEARCH_BAR_TEXT}from"../../text/phone/searchBar.g.js";import{resolveFieldSize,useTheme}from"../../theme/index.js";import{announce}from"../../utils/announce.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{resolveHaptic,triggerHaptic}from"../../utils/hapticUtils.js";import{hitSlopMarker}from"../../utils/hitSlop.js";import{mergeRefs}from"../../utils/mergeRefs.js";import{defaultIcons}from"../AppIcon/defaultIcons.js";import{renderSlotIcon}from"../AppIcon/slotIcon.js";import{FieldBase,FieldLabel,resolveFieldTextStyle,resolveVariantColors}from"../FieldBase/FieldBase.js";import{useFloatingLabel}from"../FieldBase/useFloatingLabel.js";import{normalizeSuggestion,SearchRecents,SearchScopeBar,SearchSuggestions}from"./SearchPanel.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const DEFAULT_PANEL_ROWS=8,HOLD_RELEASE_MS=50;function SearchBar({ref:e,...l}){const{value:s,onChangeText:t,onSubmit:o,onFocus:a,onBlur:i,placeholder:r,autoFocus:n=!1,disabled:c=!1,onClear:u,leftIcon:d,debounceMs:p,size:b="md",variant:m,radius:f,label:h,labelMode:S="top",labelStyle:g,scopes:x,scope:v,onScopeChange:C,recents:y,maxRecents:j=DEFAULT_PANEL_ROWS,onSelectRecent:R,onRemove:T,onClearRecents:F,suggestions:_,maxSuggestions:k=DEFAULT_PANEL_ROWS,onSelect:B,haptic:E,labels:V,style:I,inputStyle:L,accessibilityLabel:A,testID:M,...z}=l;assertValidValue("SearchBar","size",l.size,["sm","md","lg"]),assertValidValue("SearchBar","variant",l.variant,["outline","filled","underline"]),assertValidValue("SearchBar","labelMode",l.labelMode,["top","float"]);const H=useTheme(),w=useMobileUiText("searchBar",SEARCH_BAR_TEXT),D=useMemo(()=>({...w,...V}),[w,V]),P=r??D.placeholder,O=m??H.settings.components["search-bar"]?.defaultVariant??H.settings.components.field?.defaultVariant??"filled",U="underline"===O,N=resolveFieldSize(H,b),W=f??H.components["search-bar"][b].radius,X=resolveFieldTextStyle(H,{disabled:c}),q=useRef(null),K=useMemo(()=>mergeRefs(q,e),[e]),$=useCallback(()=>{c||q.current?.focus()},[c]),G=useMemo(()=>buildStyles(H),[H]),J="string"==typeof s?s:"",[Q,Y]=useState(!1),Z=useCallback(e=>{Y(!0),a?.(e)},[a]),ee=useCallback(e=>{Y(!1),i?.(e)},[i]),[le,se]=useState(J),te=useRef(le);te.current=le;const oe=useDebounce(le,p??0);useEffect(()=>{void 0!==p&&J!==te.current&&se(J)},[J,p]);const ae=useRef(J);useEffect(()=>{void 0!==p&&oe!==ae.current&&(ae.current=oe,t(oe))},[oe,p,t]);const ie=useCallback(e=>{reportIdleActivity(),void 0===p?t(e):se(e)},[p,t]),re=useCallback(()=>{const e=resolveHaptic(E,"selection");e&&triggerHaptic(e),void 0!==p&&(se(""),ae.current=""),t(""),u?.()},[E,p,t,u]),ne=useCallback(()=>{o?.(void 0!==p?le:J)},[o,p,le,J]),ce=void 0!==p?le:J,ue=ce.length>0,[de,pe]=useControllableState({value:v,defaultValue:x?.[0]?.value??"",onChange:C}),be=useCallback(e=>{pe(e);const l=x?.find(l=>l.value===e)?.label;l&&announce(fillText(D.searching,{label:l}))},[x,pe,D]),[me,fe]=useState(!1),he=useRef(null),Se=useCallback(()=>{he.current&&(clearTimeout(he.current),he.current=null)},[]),ge=useCallback(()=>{Se(),fe(!0)},[Se]),xe=useCallback(()=>{Se(),he.current=setTimeout(()=>fe(!1),50)},[Se]);useEffect(()=>Se,[Se]);const ve=!c&&(Q||me),Ce=useMemo(()=>(y??[]).slice(0,j),[y,j]),ye=useMemo(()=>(_??[]).slice(0,k).map(normalizeSuggestion),[_,k]),je=ve&&!ue&&Ce.length>0,Re=ve&&ue&&ye.length>0,Te=Re?ye.length:0,Fe=Te>0?pluralText(D,"suggestionCount",Te):"";useEffect(()=>{Fe&&announce(Fe)},[Fe]);const ke=useCallback(()=>{const e=resolveHaptic(E,"selection");e&&triggerHaptic(e)},[E]),Be=useCallback(e=>{ke(),q.current?.blur(),fe(!1),R?.(e)},[ke,R]),Ee=useCallback(e=>{ke(),q.current?.blur(),fe(!1),B?.(e)},[ke,B]),Ve=useCallback(e=>{ke(),T?.(e),announce(fillText(D.removed,{text:e})),$()},[ke,T,$,D]),Ie=useCallback(()=>{ke(),F?.(),announce(D.recentsCleared),$()},[ke,F,$,D]),Le={size:N.icon,color:c?H.colors["text-disabled"]:H.colors["text-subtle"],disabled:c},Ae=d?renderSlotIcon(d,Le):(H.settings.icons.search??defaultIcons.search)(Le),Me=_jsx(View,{accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:Ae}),ze=Boolean(h)&&"float"===S,He=useFloatingLabel({label:h,enabled:ze,floated:Q||ue,variant:O,sizeTokens:N,leadingOffset:N.icon+H.space.md,trailingOffset:ue?N.icon+H.space.md:0,paddingLeft:U?H.space.none:N["padding-x"],color:H.colors["field-label"],style:g}),we=ue&&!c?_jsx(Pressable,{onPress:re,hitSlop:8,...hitSlopMarker(8),accessibilityRole:"button",accessibilityLabel:D.clearSearch,children:(H.settings.icons.close??defaultIcons.close)({size:N.icon,color:H.colors["text-muted"]})}):null;return _jsxs(View,{style:I,testID:M,children:[h&&!ze?_jsx(FieldLabel,{size:b,style:g,children:h}):null,_jsx(View,{style:G.root,children:_jsxs(View,{style:G.fieldWrap,children:[_jsx(FieldBase,{testID:M?`${M}-field`:void 0,size:b,variant:O,focused:Q,disabled:c,filled:ue,minHeight:N["min-height"],paddingHorizontal:U?H.space.none:N["padding-x"],radius:W,leading:Me,trailing:we,topNotch:He.topNotch,onPress:$,pressFeedback:!1,accessibilityRole:"search",accessibilityLabel:A??P,children:_jsx(TextInput,{ref:K,style:[G.input,{fontSize:N.text,color:X.color,...X.weightStyle},L],value:ce,onChangeText:ie,onSubmitEditing:ne,onFocus:Z,onBlur:ee,placeholder:!ze||Q||ue?P:void 0,placeholderTextColor:X.placeholderColor,autoFocus:n,editable:!c,returnKeyType:"search",selectionColor:resolveVariantColors(H,O).borderFocusedRepresentative,accessibilityLabel:A??P,accessibilityState:{disabled:c},"aria-disabled":c,...z})}),He.node]})}),x&&x.length>0?_jsx(SearchScopeBar,{scopes:x,scope:de||(x[0]?.value??""),disabled:c,haptic:E,labels:D,onChange:be}):null,je?_jsx(SearchRecents,{recents:Ce,labels:D,onSelect:Be,onRemove:T?Ve:void 0,onClear:F?Ie:void 0,onHold:ge,onRelease:xe}):null,Re?_jsx(SearchSuggestions,{suggestions:ye,query:ce,onSelect:Ee,onHold:ge,onRelease:xe}):null]})}const buildStyles=e=>StyleSheet.create({root:{flexDirection:"row",alignItems:"center",width:"100%",position:"relative",overflow:"visible"},fieldWrap:{flex:1,position:"relative",overflow:"visible"},input:{flex:1,padding:e.space.none,margin:e.space.none,includeFontPadding:!1}});export{SearchBar};export default SearchBar;
@@ -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:s,helperText:i,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,segmentStyle:y,selectedIndicatorStyle:S,textStyle:v,labelStyle:w,testID:C}=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[j]=r;if(void 0===j)throw new Error("SegmentedControl needs at least one segment");const[V,k]=useControllableState({value:o,defaultValue:n??j.value,onChange:e=>{null!==e&&a?.(e)}}),F=useTheme(),I=F.components["segmented-control"],L=useMemo(()=>buildStyles(F),[F]),_=useMemo(()=>resolveSegmentedControlSize(F,d),[F,d]),z=p>=2?2:1,M=z>1,R="segmented"===h,T="underline"===h,E="pills"===h,A=R?F.space[I["track-padding"]]:0,D=Math.ceil(1.25*_.text)*(z-1),H=I["underline-height"],q=F.space[I["pill-inset"]],B="number"==typeof g?g:g?F.radius[g]:void 0,W=B??F.radius.md,P=void 0===B?F.radius.sm:Math.max(B-A,0),N=B??F.radius.pill,G=B??F.radius.none,[O,X]=useState([]),J=useRef(createAnimatedValue(0)).current,K=Math.max(0,r.findIndex(e=>e.value===V)),Q=O[K],U=Q?.x,Y=useCallback(e=>{const t=F.motion.spring.snappy,r=Animated.spring(J,{toValue:e,damping:t.damping,stiffness:t.stiffness,mass:t.mass,overshootClamping:!0,useNativeDriver:nativeDriver});return r.start(),r},[F.motion.spring.snappy,J]);useEffect(()=>{X(e=>e.length===r.length||0===e.length?e:[])},[r.length]);const Z=useRef(null);useEffect(()=>{if(void 0===U)return;const e=null!==Z.current&&Z.current!==K;if(Z.current=K,!e)return void J.setValue(U);const t=Y(U);return()=>t.stop()},[K,U,Y,J]);const $=useCallback((e,t)=>{const{x:r,width:s}=t.nativeEvent.layout;X(t=>{const i=t[e];if(i&&i.x===r&&i.width===s)return t;const l=t.slice();return l[e]={x:r,width:s},l})},[]),ee=useCallback(e=>{if(u)return;if(e.value===V)return;const t=resolveHaptic(f,"selection");t&&triggerHaptic(t),k(e.value)},[u,k,V,f]),te=R?F.colors.thumb:E?F.colors["primary-soft"]:F.colors.primary,re=R?P:E?N:G,se=activeInkFor(F,m),ie=F.colors["bg-muted"],le=useSquircle(R,W),oe=!0===l||hasFieldText(l),ne=oe&&!u,ae=F.colors["field-border-error"],de=F.size.border,ce=hasFieldText(s),ue=oe?l:i,me=hasFieldText(ue),he=_jsxs(View,{ref:t,accessibilityRole:"radiogroup",accessibilityLabel:b??("string"==typeof s?s:void 0),testID:C,style:[L.track,{...M?{minHeight:_.height+D}:{height:_.height},opacity:u?.55:1,alignSelf:c?"stretch":"flex-start"},R?{borderRadius:W,...smoothCorners,backgroundColor:le.active?"transparent":ie,padding:A}:T?{borderBottomColor:ne?ae:F.colors["border-subtle"],borderBottomWidth:StyleSheet.hairlineWidth}:null,x],onLayout:le.onLayout,children:[le.active&&le.size?_jsx(SquircleFill,{width:le.size.width,height:le.size.height,radius:W,fill:ie,stroke:ne?ae:void 0,strokeWidth:de}):null,_jsxs(View,{style:L.row,children:[Q?_jsx(Animated.View,{pointerEvents:"none",style:[L.thumb,R?M?{top:0,bottom:0}:{top:0,height:_.height-2*A}:E?{top:q,bottom:q,left:q}:{bottom:0,height:H},{width:E?Math.max(Q.width-2*q,0):Q.width,borderRadius:re,...smoothCorners,backgroundColor:te,transform:[{translateX:J}]},S]}):null,r.map((e,t)=>{const r=e.value===V,s=r?se:F.colors["text-subtle"],i=renderSlotIcon(e.icon,{color:s,size:_.icon,selected:r,disabled:u}),l=Boolean(i);return _jsxs(Pressable,{onPress:()=>ee(e),onLayout:e=>$(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})=>[L.segment,M?L.segmentMultiline:null,{paddingHorizontal:_["padding-x"],opacity:e&&!r?.7:1},y],children:[l?_jsx(View,{style:L.segmentIcon,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:i}):null,_jsx(Text,{variant:"label",weight:r?"semibold":"medium",style:[L.segmentLabel,M?L.segmentLabelMultiline:null,{color:s,fontSize:_.text},v,w],numberOfLines:z,children:e.label})]},String(e.value))})]}),!ne||T||le.active?null:_jsx(View,{pointerEvents:"none",style:[StyleSheet.absoluteFill,{borderWidth:de,borderColor:ae,borderRadius:R?W:N,...smoothCorners}]})]});return ce||me?_jsxs(View,{style:{alignSelf:c?"stretch":"flex-start"},children:[ce?_jsx(FieldLabel,{size:d,children:s}):null,he,me?_jsx(FieldMessage,{size:d,text:ue,error:oe}):null]}):he});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{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"]}};function SegmentedControl({ref:e,...t}){const{segments:i,label:s,helperText:r,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,segmentStyle:v,selectedIndicatorStyle:y,textStyle:S,labelStyle:w,testID:j}=t;assertValidValue("SegmentedControl","size",t.size,["sm","md","lg"]),assertValidValue("SegmentedControl","tone",t.tone,["primary","success","warning","danger","info","neutral"]),assertValidValue("SegmentedControl","variant",t.variant,["underline","pills","segmented"]);const[C]=i;if(void 0===C)throw new Error("SegmentedControl needs at least one segment");const[V,k]=useControllableState({value:o,defaultValue:n??C.value,onChange:e=>{null!==e&&a?.(e)}}),F=useTheme(),I=F.components["segmented-control"],L=useMemo(()=>buildStyles(F),[F]),_=useMemo(()=>resolveSegmentedControlSize(F,d),[F,d]),z=p>=2?2:1,M=z>1,T="segmented"===h,E="underline"===h,A="pills"===h,R=T?F.space[I["track-padding"]]:0,D=Math.ceil(1.25*_.text)*(z-1),H=I["underline-height"],q=F.space[I["pill-inset"]],B="number"==typeof g?g:g?F.radius[g]:void 0,W=B??F.radius.md,P=void 0===B?F.radius.sm:Math.max(B-R,0),G=B??F.radius.pill,N=B??F.radius.none,[O,X]=useState([]),J=useRef(createAnimatedValue(0)).current,K=Math.max(0,i.findIndex(e=>e.value===V)),Q=O[K],U=Q?.x,Y=useCallback(e=>{const t=F.motion.spring.snappy,i=Animated.spring(J,{toValue:e,damping:t.damping,stiffness:t.stiffness,mass:t.mass,overshootClamping:!0,useNativeDriver:nativeDriver});return i.start(),i},[F.motion.spring.snappy,J]);useEffect(()=>{X(e=>e.length===i.length||0===e.length?e:[])},[i.length]);const Z=useRef(null);useEffect(()=>{if(void 0===U)return;const e=null!==Z.current&&Z.current!==K;if(Z.current=K,!e)return void J.setValue(U);const t=Y(U);return()=>t.stop()},[K,U,Y,J]);const $=useCallback((e,t)=>{const{x:i,width:s}=t.nativeEvent.layout;X(t=>{const r=t[e];if(r&&r.x===i&&r.width===s)return t;const l=t.slice();return l[e]={x:i,width:s},l})},[]),ee=useCallback(e=>{if(u)return;if(e.value===V)return;const t=resolveHaptic(f,"selection");t&&triggerHaptic(t),k(e.value)},[u,k,V,f]),te=T?F.colors.thumb:A?F.colors["primary-soft"]:F.colors.primary,ie=T?P:A?G:N,se=activeInkFor(F,m),re=F.colors["bg-muted"],le=useSquircle(T,W),oe=!0===l||hasFieldText(l),ne=oe&&!u,ae=F.colors["field-border-error"],de=F.size.border,ce=hasFieldText(s),ue=oe?l:r,me=hasFieldText(ue),he=_jsxs(View,{ref:e,accessibilityRole:"radiogroup",accessibilityLabel:b??("string"==typeof s?s:void 0),testID:j,style:[L.track,{...M?{minHeight:_.height+D}:{height:_.height},opacity:u?.55:1,alignSelf:c?"stretch":"flex-start"},T?{borderRadius:W,...smoothCorners,backgroundColor:le.active?"transparent":re,padding:R}:E?{borderBottomColor:ne?ae:F.colors["border-subtle"],borderBottomWidth:StyleSheet.hairlineWidth}:null,x],onLayout:le.onLayout,children:[le.active&&le.size?_jsx(SquircleFill,{width:le.size.width,height:le.size.height,radius:W,fill:re,stroke:ne?ae:void 0,strokeWidth:de}):null,_jsxs(View,{style:L.row,children:[Q?_jsx(Animated.View,{pointerEvents:"none",style:[L.thumb,T?M?{top:0,bottom:0}:{top:0,height:_.height-2*R}:A?{top:q,bottom:q,left:q}:{bottom:0,height:H},{width:A?Math.max(Q.width-2*q,0):Q.width,borderRadius:ie,...smoothCorners,backgroundColor:te,transform:[{translateX:J}]},y]}):null,i.map((e,t)=>{const i=e.value===V,s=i?se:F.colors["text-subtle"],r=renderSlotIcon(e.icon,{color:s,size:_.icon,selected:i,disabled:u}),l=Boolean(r);return _jsxs(Pressable,{onPress:()=>ee(e),onLayout:e=>$(t,e),disabled:u,accessibilityRole:"radio",accessibilityLabel:e.label,accessibilityState:{checked:i,selected:i,disabled:u},"aria-checked":i,"aria-disabled":u,style:({pressed:e})=>[L.segment,M?L.segmentMultiline:null,{paddingHorizontal:_["padding-x"],opacity:e&&!i?.7:1},v],children:[l?_jsx(View,{style:L.segmentIcon,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:r}):null,_jsx(Text,{variant:"label",weight:i?"semibold":"medium",style:[L.segmentLabel,M?L.segmentLabelMultiline:null,{color:s,fontSize:_.text},S,w],numberOfLines:z,children:e.label})]},String(e.value))})]}),!ne||E||le.active?null:_jsx(View,{pointerEvents:"none",style:[StyleSheet.absoluteFill,{borderWidth:de,borderColor:ae,borderRadius:T?W:G,...smoothCorners}]})]});return ce||me?_jsxs(View,{style:{alignSelf:c?"stretch":"flex-start"},children:[ce?_jsx(FieldLabel,{size:d,children:s}):null,he,me?_jsx(FieldMessage,{size:d,text:ue,error:oe}):null]}):he}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{useCallback,useMemo,useState}from"react";import{StyleSheet,View}from"react-native";import{fillText,useMobileUiText}from"../../text/index.js";import{SELECT_TEXT}from"../../text/phone/select.g.js";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{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";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:x,title:h,required:m=!1,error:f,helperText:g,prefix:S,numberOfLines:b=1,disabled:v=!1,size:y="md",variant:T,leftIcon:j,rightIcon:O,chevronColor:C,chevronSize:V,radius:F,accessibilityLabel:I,labelStyle:k,style:_,triggerStyle:z,textStyle:L,optionStyle:H,selectedOptionStyle:M,optionTextStyle:D,selectedOptionTextStyle:w,testID:P,ref:E}=e,R=!0===e.multi,A={...useMobileUiText("select",SELECT_TEXT),...p},B=useCallback(e=>l?l(e):selectOptionLabel(e),[l]),N=useCallback(e=>i?i(e):selectOptionValue(e),[i]),q=useCallback(e=>o?o(e):selectOptionDisabled(e),[o]),U=useCallback(e=>s?s(e):selectOptionDescription(e),[s]),X=useCallback(e=>n?n(e):selectOptionIcon(e),[n]),$=useTheme(),G=useMemo(()=>buildStyles($),[$]),J=resolveFieldSize($,y),K=resolveFieldTextStyle($,{disabled:v}),Q=T??$.settings.components.select?.defaultVariant??$.settings.components.field?.defaultVariant??"outline",[W,Y]=useState(!1),Z=useMemo(()=>{if(R){const l=e.value??[];return t.filter(e=>containsValue(l,N(e)))}const l=e.value;if(null==l)return[];const i=t.find(e=>sameSelectValue(N(e),l));return i?[i]:[]},[R,t,e.value,N]),ee=useCallback(()=>{if(v)return;const e=resolveHaptic(d,"selection");e&&triggerHaptic(e),Y(!0)},[v,d]),te=useCallback(()=>{Y(!1)},[]),le=useCallback(t=>{if(q(t))return;const l=N(t),i=resolveHaptic(d,"selection");if(i&&triggerHaptic(i),R){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()},[R,e,te,q,N,d]),ie=0===Z.length?r??A.placeholder:Z.map(e=>B(e)).join(", "),oe=0===Z.length,se=!0===f||hasFieldText(f),ne=hasFieldText(u),re=fieldTextAsString(u),ae=Math.round(1.4*J.text),ce=useMemo(()=>({fontSize:J.text,color:K.placeholderColor}),[J.text,K.placeholderColor]),de={color:v?$.colors["field-icon-disabled"]:W?$.colors["field-icon-focus"]:$.colors["field-icon"],size:J.icon,disabled:v,focused:W,error:se},pe=0===Z.length?r??A.noSelection:fillText(A.selected,{summary:Z.map(e=>B(e)).join(", ")}),ue=I??`${re??A.fallbackName}. ${pe}`;return _jsxs(View,{style:[G.container,_],testID:P,children:[ne?_jsx(FieldLabel,{size:y,required:m,help:x,style:k,children:u}):null,_jsx(View,{ref:E,collapsable:!1,children:_jsxs(FieldBase,{size:y,variant:Q,disabled:v,error:se,filled:Z.length>0,onPress:ee,radius:F,paddingHorizontal:"underline"===Q?$.space.none:void 0,accessibilityRole:"button",accessibilityLabel:ue,accessibilityState:{disabled:v,expanded:W},"aria-disabled":v,"aria-expanded":W,style:z,slotAlign:1===b?"center":"top",slotLineHeight:1===b?void 0:ae,leading:j?slotIconView(j,renderSlotIcon(j,de)):null,trailing:O?slotIconView(O,renderSlotIcon(O,de)):_jsx(Chevron,{color:C??(v?$.colors["text-disabled"]:$.colors["text-subtle"]),size:V??J.icon,open:W,style:G.chevron}),children:[hasFieldText(S)?"string"==typeof S||"number"==typeof S?_jsx(Text,{variant:"body",style:[G.prefix,{color:K.placeholderColor,fontSize:J.text,lineHeight:1===b?void 0:ae,marginRight:$.space.xs}],children:S}):_jsx(View,{style:[G.prefixNode,{minHeight:1===b?void 0:ae,justifyContent:"center",marginRight:$.space.xs}],children:_jsx(Text,{variant:"body",style:[G.prefix,{color:K.placeholderColor,fontSize:J.text,lineHeight:1===b?void 0:ae}],children:_jsx(TextInkContext.Provider,{value:ce,children:S})})}):null,_jsxs(Text,{variant:"body",style:[G.triggerText,{color:oe?K.placeholderColor:K.color,fontSize:J.text,lineHeight:1===b?void 0:ae,...K.weightStyle},L],numberOfLines:b,children:[ie,oe&&m&&!ne?_jsx(RequiredMark,{}):null]})]})}),_jsx(FieldMessage,{size:y,error:se,text:se?f:g}),_jsx(OptionSheet,{open:W,onClose:te,onOpenChange:a,haptic:d,title:h??re,accessibilityLabel:re??(ne?h:void 0)??r??A.sheetName,options:t,getOptionLabel:B,getOptionValue:N,isOptionDisabled:q,getOptionDescription:U,getOptionIcon:X,value:e.value,onChange:(e,t)=>le(t),multi:R,searchable:c,labels:{...void 0===A.searchPlaceholder?{}:{searchPlaceholder:A.searchPlaceholder},...void 0===A.empty?{}:{empty:A.empty}},optionStyle:H,selectedOptionStyle:M,optionTextStyle:D,selectedOptionTextStyle:w,searchSelectionColor:resolveVariantColors($,Q).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{fillText,useMobileUiText}from"../../text/index.js";import{SELECT_TEXT}from"../../text/phone/select.g.js";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{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";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:x,title:h,required:m=!1,error:f,helperText:g,prefix:S,numberOfLines:b=1,disabled:y=!1,size:v="md",variant:T,leftIcon:j,rightIcon:O,chevronColor:C,chevronSize:V,radius:F,accessibilityLabel:I,labelStyle:k,style:_,triggerStyle:z,textStyle:L,optionStyle:H,selectedOptionStyle:M,optionTextStyle:D,selectedOptionTextStyle:w,testID:P,ref:E}=e,R=!0===e.multi,A={...useMobileUiText("select",SELECT_TEXT),...p},B=useCallback(e=>l?l(e):selectOptionLabel(e),[l]),N=useCallback(e=>i?i(e):selectOptionValue(e),[i]),q=useCallback(e=>o?o(e):selectOptionDisabled(e),[o]),U=useCallback(e=>s?s(e):selectOptionDescription(e),[s]),X=useCallback(e=>n?n(e):selectOptionIcon(e),[n]),$=useTheme(),G=useMemo(()=>buildStyles($),[$]),J=resolveFieldSize($,v),K=resolveFieldTextStyle($,{disabled:y}),Q=T??$.settings.components.select?.defaultVariant??$.settings.components.field?.defaultVariant??"outline",[W,Y]=useState(!1),Z=useMemo(()=>{if(R){const l=e.value??[];return t.filter(e=>containsValue(l,N(e)))}const l=e.value;if(null==l)return[];const i=t.find(e=>sameSelectValue(N(e),l));return i?[i]:[]},[R,t,e.value,N]),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(q(t))return;const l=N(t),i=resolveHaptic(d,"selection");if(i&&triggerHaptic(i),R){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()},[R,e,te,q,N,d]),ie=0===Z.length?r??A.placeholder:Z.map(e=>B(e)).join(", "),oe=0===Z.length,se=!0===f||hasFieldText(f),ne=hasFieldText(u),re=fieldTextAsString(u),ae=Math.round(1.4*J.text),ce=useMemo(()=>({fontSize:J.text,color:K.placeholderColor}),[J.text,K.placeholderColor]),de={color:y?$.colors["field-icon-disabled"]:W?$.colors["field-icon-focus"]:$.colors["field-icon"],size:J.icon,disabled:y,focused:W,error:se},pe=0===Z.length?r??A.noSelection:fillText(A.selected,{summary:Z.map(e=>B(e)).join(", ")}),ue=I??`${re??A.fallbackName}. ${pe}`;return _jsxs(View,{style:[G.container,_],testID:P,children:[ne?_jsx(FieldLabel,{size:v,required:m,help:x,style:k,children:u}):null,_jsx(View,{ref:E,collapsable:!1,children:_jsxs(FieldBase,{size:v,variant:Q,disabled:y,error:se,filled:Z.length>0,onPress:ee,radius:F,paddingHorizontal:"underline"===Q?$.space.none:void 0,accessibilityRole:"button",accessibilityLabel:ue,accessibilityState:{disabled:y,expanded:W},"aria-disabled":y,"aria-expanded":W,style:z,slotAlign:1===b?"center":"top",slotLineHeight:1===b?void 0:ae,leading:j?slotIconView(j,renderSlotIcon(j,de)):null,trailing:O?slotIconView(O,renderSlotIcon(O,de)):_jsx(Chevron,{color:C??(y?$.colors["text-disabled"]:$.colors["text-subtle"]),size:V??J.icon,open:W,style:G.chevron}),children:[hasFieldText(S)?"string"==typeof S||"number"==typeof S?_jsx(Text,{variant:"body",style:[G.prefix,{color:K.placeholderColor,fontSize:J.text,lineHeight:1===b?void 0:ae,marginRight:$.space.xs}],children:S}):_jsx(View,{style:[G.prefixNode,{minHeight:1===b?void 0:ae,justifyContent:"center",marginRight:$.space.xs}],children:_jsx(Text,{variant:"body",style:[G.prefix,{color:K.placeholderColor,fontSize:J.text,lineHeight:1===b?void 0:ae}],children:_jsx(TextInkContext,{value:ce,children:S})})}):null,_jsxs(Text,{variant:"body",style:[G.triggerText,{color:oe?K.placeholderColor:K.color,fontSize:J.text,lineHeight:1===b?void 0:ae,...K.weightStyle},L],numberOfLines:b,children:[ie,oe&&m&&!ne?_jsx(RequiredMark,{}):null]})]})}),_jsx(FieldMessage,{size:v,error:se,text:se?f:g}),_jsx(OptionSheet,{open:W,onClose:te,onOpenChange:a,haptic:d,title:h??re,accessibilityLabel:re??(ne?h:void 0)??r??A.sheetName,options:t,getOptionLabel:B,getOptionValue:N,isOptionDisabled:q,getOptionDescription:U,getOptionIcon:X,value:e.value,onChange:(e,t)=>le(t),multi:R,searchable:c,labels:{...void 0===A.searchPlaceholder?{}:{searchPlaceholder:A.searchPlaceholder},...void 0===A.empty?{}:{empty:A.empty}},optionStyle:H,selectedOptionStyle:M,optionTextStyle:D,selectedOptionTextStyle:w,searchSelectionColor:resolveVariantColors($,Q).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{formatDateTime}from"@webority/mobile-core";import{forwardRef,memo,useCallback,useEffect,useImperativeHandle,useMemo,useRef,useState}from"react";import{AccessibilityInfo,Modal,PixelRatio,Platform,StyleSheet,useWindowDimensions,View}from"react-native";import{GestureDetector,GestureHandlerRootView,useCompetingGestures,usePanGesture}from"react-native-gesture-handler";import Svg,{Path,Rect,Text as SvgText}from"react-native-svg";import{useMobileUiText}from"../../text/index.js";import{SIGNATURE_PAD_TEXT}from"../../text/phone/signaturePad.g.js";import{lightTheme,useTheme}from"../../theme/index.js";import{announce}from"../../utils/announce.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{smoothCorners}from"../../utils/corners.js";import{Button}from"../Button/index.js";import{Input}from"../Input/index.js";import{Text}from"../Text/index.js";import{BASELINE_RATIO,buildSignatureSvg,distanceBetween,FALLBACK_WIDTH,pointOf,strokePath,typedFontSize}from"./signatureGeometry.js";import{writePng}from"./writePng";import{jsx as _jsx,Fragment as _Fragment,jsxs as _jsxs}from"react/jsx-runtime";const STROKE_WIDTH=2.5,SIDEWAYS_TO_DRAW=6,UPRIGHT_TO_SCROLL=8,REST_TO_DRAW_MS=200,MIN_POINT_GAP=.8,DEFAULT_HEIGHT=180,EXPANDED_CHROME=200,DEFAULT_NAME_LENGTH=100,MAX_EXPORT_SCALE=3,MIN_TARGET=44,BASELINE_OPACITY=.3,DISABLED_OPACITY=.5,TARGET_STYLE={minHeight:44},defaultScriptFont=()=>Platform.select({ios:"Snell Roundhand",default:"cursive"}),cssFontStack=e=>"cursive"===e?"cursive":`'${e}', cursive`,useScreenReader=()=>{const[e,t]=useState(!1);return useEffect(()=>{let e=!0;AccessibilityInfo.isScreenReaderEnabled().then(n=>{e&&t(n)});const n=AccessibilityInfo.addEventListener("screenReaderChanged",t);return()=>{e=!1,n.remove()}},[]),e},StrokePath=memo(({points:e,color:t})=>_jsx(Path,{d:strokePath(e),stroke:t,strokeWidth:2.5,strokeLinecap:"round",strokeLinejoin:"round",fill:"none"}));StrokePath.displayName="SignaturePadStroke";const Marks=({mode:e,strokes:t,name:n,color:a,fontFamily:r,width:o,height:s})=>"draw"===e?_jsx(_Fragment,{children:t.map(e=>_jsx(StrokePath,{points:e.points,color:a},e.id))}):n?_jsx(SvgText,{x:o/2,y:s*BASELINE_RATIO,fontSize:typedFontSize(o,n),fontFamily:r,textAnchor:"middle",fill:a,children:n}):null,SignaturePadSurface=forwardRef((e,t)=>{const{expandable:n,initialStrokes:a,onChange:r,initialTypedName:o="",onTypedNameChange:s,defaultMode:i="draw",onModeChange:l,onEmptyChange:d,allowTyped:c=!0,signedBy:u,signedAt:p,height:m=DEFAULT_HEIGHT,maxNameLength:h=DEFAULT_NAME_LENGTH,inkColor:g,paperColor:f,scriptFontFamily:y,labels:x,haptic:S="selection",disabled:T=!1,style:b,testID:_}=e;assertValidValue("SignaturePad","defaultMode",e.defaultMode,["draw","type"]);const w=useTheme(),E=void 0===g&&void 0===f,C=E?w.colors["text-body"]:g??lightTheme.colors["text-body"],A=E?w.colors.surface:f??lightTheme.colors.surface,v=E?lightTheme.colors["text-body"]:C,R=E?lightTheme.colors.surface:A,j=v!==C||R!==A,I=y??defaultScriptFont(),P=useMobileUiText("signaturePad",SIGNATURE_PAD_TEXT),k=useMemo(()=>({...P,...x}),[P,x]),D=useScreenReader(),L=useRef(null),M=useRef(null),[F,G]=useState(0),[N,B]=useState(()=>(a??[]).map((e,t)=>({id:t+1,points:[...e]}))),O=useRef(N),H=useRef(N.length),V=useRef(null),$=useRef(null),[z,W]=useState(c?i:"draw"),[U,Y]=useState(o),[X,K]=useState(null),q=useRef(!1),{height:J}=useWindowDimensions(),[Q,Z]=useState(!1),[ee,te]=useState([]),ne=useRef({onChange:r,onTypedNameChange:s,onModeChange:l,onEmptyChange:d});useEffect(()=>{ne.current={onChange:r,onTypedNameChange:s,onModeChange:l,onEmptyChange:d}});const ae="draw"===z&&!T,re="draw"===z?0===N.length:0===U.trim().length,oe=useRef(null);useEffect(()=>{oe.current!==re&&(oe.current=re,ne.current.onEmptyChange?.(re))},[re]);const se=useCallback(e=>{O.current=e,B(e)},[]),ie=useCallback(()=>{K(Date.now()),ne.current.onChange?.(O.current.map(e=>e.points))},[]),le=useMemo(()=>{const pan=e=>({enabled:ae,runOnJS:!0,onBegin:e=>{V.current=pointOf(e.x,e.y)},onActivate:t=>{$.current=e,H.current+=1;const n=pointOf(t.x,t.y);se([...O.current,{id:H.current,points:[V.current??n,n]}])},onUpdate:t=>{if($.current!==e)return;const n=O.current[O.current.length-1];if(void 0===n)throw new Error("The stroke being drawn is missing.");const a=pointOf(t.x,t.y),r=n.points[n.points.length-1];if(void 0===r)throw new Error("A drawn stroke has no points.");distanceBetween(r,a)<.8||se([...O.current.slice(0,-1),{...n,points:[...n.points,a]}])},onFinalize:()=>{$.current===e&&($.current=null,ie())}});return{sidewaysConfig:{...pan("sideways"),activeOffsetX:[-6,6],failOffsetY:[-8,8]},restedConfig:{...pan("rested"),activateAfterLongPress:200}}},[ae,se,ie]),de=usePanGesture(le.sidewaysConfig),ce=usePanGesture(le.restedConfig),ue=useCompetingGestures(de,ce),pe=useCallback(e=>{W(e),ne.current.onModeChange?.(e),announce("type"===e?k.typingAnnouncement:k.drawingAnnouncement)},[k.typingAnnouncement,k.drawingAnnouncement]);useEffect(()=>{D&&c&&!q.current&&"draw"===z&&0===O.current.length&&pe("type")},[D,c,z,pe]);const me=useCallback(()=>{q.current=!0,pe("draw"===z?"type":"draw")},[z,pe]),he=useCallback(e=>{Y(e),K(Date.now()),ne.current.onTypedNameChange?.(e)},[]),ge=useCallback(()=>{"type"===z?he(""):(se([]),ie()),announce(k.clearedAnnouncement)},[z,he,se,ie,k.clearedAnnouncement]),fe=useCallback(()=>{"draw"===z&&0!==O.current.length&&(se(O.current.slice(0,-1)),ie(),announce(k.undoneAnnouncement))},[z,se,ie,k.undoneAnnouncement]),ye=useCallback(()=>{te(O.current.map(e=>e.points)),Z(!0)},[]),xe=useCallback(()=>{Z(!1)},[]),Se=useCallback(()=>{se(ee.map(e=>(H.current+=1,{id:H.current,points:[...e]}))),ie(),Z(!1)},[ee,se,ie]),Te=F||FALLBACK_WIDTH;useImperativeHandle(t,()=>({toFile:()=>new Promise((e,t)=>{if(re)return void t(new Error(k.emptyError));const n=j?M.current:L.current;if(!n)return void t(new Error("The signature pad is not on screen."));const a=Math.min(3,Math.max(1,PixelRatio.get()));n.toDataURL(n=>{writePng(n).then(e,t)},{width:Te*a,height:m*a})}),toSvg:()=>buildSignatureSvg({width:Te,height:m,mode:z,strokes:N.map(e=>e.points),typedName:U,ink:v,paper:R,strokeWidth:2.5,fontFamily:cssFontStack(I)}),clear:ge,undo:fe,isEmpty:()=>re}),[re,k.emptyError,Te,m,z,N,U,j,v,R,I,ge,fe]);const be=useMemo(()=>[{name:"undo",label:k.undo},{name:"clear",label:k.clear},...c?[{name:"toggleMode",label:"draw"===z?k.typeInstead:k.drawInstead}]:[]],[k.undo,k.clear,k.typeInstead,k.drawInstead,c,z]),we=useCallback(e=>{if(T)return;const{actionName:t}=e.nativeEvent;"undo"===t?fe():"clear"===t?ge():"toggleMode"===t&&c&&me()},[T,fe,ge,me,c]),Ee=useCallback(e=>{G(e.nativeEvent.layout.width)},[]),Ce=useMemo(()=>StyleSheet.create({root:{gap:w.space.sm},pad:{height:m,borderWidth:w.size.border,borderColor:w.colors.border,borderRadius:w.radius.md,...smoothCorners,overflow:"hidden",backgroundColor:A,opacity:T?.5:1},baseline:{position:"absolute",left:w.space.md,right:w.space.md,top:m*BASELINE_RATIO,height:StyleSheet.hairlineWidth,backgroundColor:C,opacity:.3},actions:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",flexWrap:"wrap",gap:w.space.xs},trailing:{flexDirection:"row",alignItems:"center",gap:w.space.xs},expandedRoot:{flex:1,padding:w.space.md,gap:w.space.sm,backgroundColor:w.colors.bg},expandedBar:{flexDirection:"row",alignItems:"center",justifyContent:"space-between"}}),[w,m,A,C,T]),Ae=U.trim(),ve=p??X,Re=u&&!re?`Signed by ${u}${ve?`, ${formatDateTime(ve)}`:""}`:null,je="type"===z&&Ae?`${k.pad}. ${Ae}`:k.pad;return _jsxs(View,{style:[Ce.root,b],testID:_,children:[_jsx(GestureDetector,{gesture:ue,children:_jsxs(View,{style:Ce.pad,onLayout:Ee,accessible:!0,accessibilityRole:"image",accessibilityLabel:je,accessibilityHint:"draw"===z?k.padHint:void 0,accessibilityValue:{text:re?k.empty:k.signed},accessibilityState:{disabled:T},"aria-disabled":T,accessibilityActions:be,onAccessibilityAction:we,children:[j?_jsxs(Svg,{ref:M,style:StyleSheet.absoluteFill,width:"100%",height:m,children:[_jsx(Rect,{x:"0",y:"0",width:"100%",height:"100%",fill:R}),_jsx(Marks,{mode:z,strokes:N,name:Ae,color:v,fontFamily:I,width:Te,height:m})]}):null,_jsxs(Svg,{ref:L,width:"100%",height:m,children:[_jsx(Rect,{x:"0",y:"0",width:"100%",height:"100%",fill:A}),_jsx(Marks,{mode:z,strokes:N,name:Ae,color:C,fontFamily:I,width:Te,height:m})]}),_jsx(View,{pointerEvents:"none",style:Ce.baseline})]})}),"type"===z?_jsx(Input,{label:k.typedLabel,placeholder:k.typedPlaceholder,value:U,onChangeText:he,maxLength:h,disabled:T,autoComplete:"name",textContentType:"name",autoCapitalize:"words",autoCorrect:!1,returnKeyType:"done",testID:_?`${_}-name`:void 0}):null,_jsx(Text,{variant:"caption",color:"tertiary",children:"draw"===z?k.caption:k.typedCaption}),_jsxs(View,{style:Ce.actions,children:[c?_jsx(Button,{label:"draw"===z?k.typeInstead:k.drawInstead,variant:"ghost",tone:"primary",size:"md",style:TARGET_STYLE,haptic:S,disabled:T,onPress:me,testID:_?`${_}-mode`:void 0}):_jsx(View,{}),"draw"===z?_jsxs(View,{style:Ce.trailing,children:[N.length>0?_jsxs(_Fragment,{children:[_jsx(Button,{label:k.undo,variant:"ghost",tone:"primary",size:"md",style:TARGET_STYLE,haptic:S,disabled:T,onPress:fe,testID:_?`${_}-undo`:void 0}),_jsx(Button,{label:k.clear,variant:"ghost",tone:"primary",size:"md",style:TARGET_STYLE,haptic:S,disabled:T,onPress:ge,testID:_?`${_}-clear`:void 0})]}):null,n?_jsx(Button,{label:k.expand,variant:"ghost",tone:"primary",size:"md",style:TARGET_STYLE,haptic:S,disabled:T,onPress:ye,testID:_?`${_}-expand`:void 0}):null]}):null,"type"===z&&Ae?_jsx(Button,{label:k.clear,variant:"ghost",tone:"primary",size:"md",style:TARGET_STYLE,haptic:S,disabled:T,onPress:ge,testID:_?`${_}-clear`:void 0}):null]}),Re?_jsx(Text,{variant:"caption",color:"secondary",children:Re}):null,n?_jsx(Modal,{visible:Q,animationType:"slide",presentationStyle:"fullScreen",onRequestClose:xe,children:_jsxs(ExpandedRoot,{style:Ce.expandedRoot,children:[_jsxs(View,{style:Ce.expandedBar,children:[_jsx(Button,{label:k.close,variant:"ghost",tone:"primary",size:"md",style:TARGET_STYLE,haptic:S,onPress:xe,testID:_?`${_}-close`:void 0}),_jsx(Button,{label:k.done,variant:"solid",tone:"primary",size:"md",style:TARGET_STYLE,haptic:S,onPress:Se,testID:_?`${_}-done`:void 0})]}),Q?_jsx(SignaturePadSurface,{expandable:!1,defaultMode:"draw",allowTyped:!1,initialStrokes:ee,onChange:te,height:Math.max(DEFAULT_HEIGHT,J-200),inkColor:g,paperColor:f,scriptFontFamily:y,labels:x,haptic:S,testID:_?`${_}-expanded`:void 0}):null]})}):null]})});SignaturePadSurface.displayName="SignaturePadSurface";const ExpandedRoot="android"===Platform.OS?GestureHandlerRootView:View,SignaturePad=forwardRef((e,t)=>_jsx(SignaturePadSurface,{...e,expandable:!0,ref:t}));SignaturePad.displayName="SignaturePad";export{SignaturePad};export default SignaturePad;
1
+ "use strict";import{formatDateTime}from"@webority/mobile-core";import{memo,useCallback,useEffect,useImperativeHandle,useMemo,useRef,useState}from"react";import{AccessibilityInfo,Modal,PixelRatio,Platform,StyleSheet,useWindowDimensions,View}from"react-native";import{GestureDetector,GestureHandlerRootView,useCompetingGestures,usePanGesture}from"react-native-gesture-handler";import Svg,{Path,Rect,Text as SvgText}from"react-native-svg";import{useMobileUiText}from"../../text/index.js";import{SIGNATURE_PAD_TEXT}from"../../text/phone/signaturePad.g.js";import{lightTheme,useTheme}from"../../theme/index.js";import{announce}from"../../utils/announce.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{smoothCorners}from"../../utils/corners.js";import{Button}from"../Button/index.js";import{Input}from"../Input/index.js";import{Text}from"../Text/index.js";import{BASELINE_RATIO,buildSignatureSvg,distanceBetween,FALLBACK_WIDTH,pointOf,strokePath,typedFontSize}from"./signatureGeometry.js";import{writePng}from"./writePng";import{jsx as _jsx,Fragment as _Fragment,jsxs as _jsxs}from"react/jsx-runtime";const STROKE_WIDTH=2.5,SIDEWAYS_TO_DRAW=6,UPRIGHT_TO_SCROLL=8,REST_TO_DRAW_MS=200,MIN_POINT_GAP=.8,DEFAULT_HEIGHT=180,EXPANDED_CHROME=200,DEFAULT_NAME_LENGTH=100,MAX_EXPORT_SCALE=3,MIN_TARGET=44,BASELINE_OPACITY=.3,DISABLED_OPACITY=.5,TARGET_STYLE={minHeight:44},defaultScriptFont=()=>Platform.select({ios:"Snell Roundhand",default:"cursive"}),cssFontStack=e=>"cursive"===e?"cursive":`'${e}', cursive`,useScreenReader=()=>{const[e,t]=useState(!1);return useEffect(()=>{let e=!0;AccessibilityInfo.isScreenReaderEnabled().then(n=>{e&&t(n)});const n=AccessibilityInfo.addEventListener("screenReaderChanged",t);return()=>{e=!1,n.remove()}},[]),e},StrokePath=memo(({points:e,color:t})=>_jsx(Path,{d:strokePath(e),stroke:t,strokeWidth:2.5,strokeLinecap:"round",strokeLinejoin:"round",fill:"none"}));StrokePath.displayName="SignaturePadStroke";const Marks=({mode:e,strokes:t,name:n,color:a,fontFamily:r,width:o,height:s})=>"draw"===e?_jsx(_Fragment,{children:t.map(e=>_jsx(StrokePath,{points:e.points,color:a},e.id))}):n?_jsx(SvgText,{x:o/2,y:s*BASELINE_RATIO,fontSize:typedFontSize(o,n),fontFamily:r,textAnchor:"middle",fill:a,children:n}):null;function SignaturePadSurface({ref:e,...t}){const{expandable:n,initialStrokes:a,onChange:r,initialTypedName:o="",onTypedNameChange:s,defaultMode:i="draw",onModeChange:l,onEmptyChange:d,allowTyped:c=!0,signedBy:u,signedAt:p,height:m=DEFAULT_HEIGHT,maxNameLength:h=DEFAULT_NAME_LENGTH,inkColor:g,paperColor:y,scriptFontFamily:f,labels:x,haptic:T="selection",disabled:S=!1,style:b,testID:_}=t;assertValidValue("SignaturePad","defaultMode",t.defaultMode,["draw","type"]);const w=useTheme(),E=void 0===g&&void 0===y,C=E?w.colors["text-body"]:g??lightTheme.colors["text-body"],A=E?w.colors.surface:y??lightTheme.colors.surface,v=E?lightTheme.colors["text-body"]:C,R=E?lightTheme.colors.surface:A,j=v!==C||R!==A,I=f??defaultScriptFont(),P=useMobileUiText("signaturePad",SIGNATURE_PAD_TEXT),k=useMemo(()=>({...P,...x}),[P,x]),D=useScreenReader(),L=useRef(null),M=useRef(null),[F,G]=useState(0),[N,B]=useState(()=>(a??[]).map((e,t)=>({id:t+1,points:[...e]}))),O=useRef(N),H=useRef(N.length),V=useRef(null),$=useRef(null),[z,W]=useState(c?i:"draw"),[U,Y]=useState(o),[X,K]=useState(null),q=useRef(!1),{height:J}=useWindowDimensions(),[Q,Z]=useState(!1),[ee,te]=useState([]),ne=useRef({onChange:r,onTypedNameChange:s,onModeChange:l,onEmptyChange:d});useEffect(()=>{ne.current={onChange:r,onTypedNameChange:s,onModeChange:l,onEmptyChange:d}});const ae="draw"===z&&!S,re="draw"===z?0===N.length:0===U.trim().length,oe=useRef(null);useEffect(()=>{oe.current!==re&&(oe.current=re,ne.current.onEmptyChange?.(re))},[re]);const se=useCallback(e=>{O.current=e,B(e)},[]),ie=useCallback(()=>{K(Date.now()),ne.current.onChange?.(O.current.map(e=>e.points))},[]),le=useMemo(()=>{const pan=e=>({enabled:ae,runOnJS:!0,onBegin:e=>{V.current=pointOf(e.x,e.y)},onActivate:t=>{$.current=e,H.current+=1;const n=pointOf(t.x,t.y);se([...O.current,{id:H.current,points:[V.current??n,n]}])},onUpdate:t=>{if($.current!==e)return;const n=O.current[O.current.length-1];if(void 0===n)throw new Error("The stroke being drawn is missing.");const a=pointOf(t.x,t.y),r=n.points[n.points.length-1];if(void 0===r)throw new Error("A drawn stroke has no points.");distanceBetween(r,a)<.8||se([...O.current.slice(0,-1),{...n,points:[...n.points,a]}])},onFinalize:()=>{$.current===e&&($.current=null,ie())}});return{sidewaysConfig:{...pan("sideways"),activeOffsetX:[-6,6],failOffsetY:[-8,8]},restedConfig:{...pan("rested"),activateAfterLongPress:200}}},[ae,se,ie]),de=usePanGesture(le.sidewaysConfig),ce=usePanGesture(le.restedConfig),ue=useCompetingGestures(de,ce),pe=useCallback(e=>{W(e),ne.current.onModeChange?.(e),announce("type"===e?k.typingAnnouncement:k.drawingAnnouncement)},[k.typingAnnouncement,k.drawingAnnouncement]);useEffect(()=>{D&&c&&!q.current&&"draw"===z&&0===O.current.length&&pe("type")},[D,c,z,pe]);const me=useCallback(()=>{q.current=!0,pe("draw"===z?"type":"draw")},[z,pe]),he=useCallback(e=>{Y(e),K(Date.now()),ne.current.onTypedNameChange?.(e)},[]),ge=useCallback(()=>{"type"===z?he(""):(se([]),ie()),announce(k.clearedAnnouncement)},[z,he,se,ie,k.clearedAnnouncement]),ye=useCallback(()=>{"draw"===z&&0!==O.current.length&&(se(O.current.slice(0,-1)),ie(),announce(k.undoneAnnouncement))},[z,se,ie,k.undoneAnnouncement]),fe=useCallback(()=>{te(O.current.map(e=>e.points)),Z(!0)},[]),xe=useCallback(()=>{Z(!1)},[]),Te=useCallback(()=>{se(ee.map(e=>(H.current+=1,{id:H.current,points:[...e]}))),ie(),Z(!1)},[ee,se,ie]),Se=F||FALLBACK_WIDTH;useImperativeHandle(e,()=>({toFile:()=>new Promise((e,t)=>{if(re)return void t(new Error(k.emptyError));const n=j?M.current:L.current;if(!n)return void t(new Error("The signature pad is not on screen."));const a=Math.min(3,Math.max(1,PixelRatio.get()));n.toDataURL(n=>{writePng(n).then(e,t)},{width:Se*a,height:m*a})}),toSvg:()=>buildSignatureSvg({width:Se,height:m,mode:z,strokes:N.map(e=>e.points),typedName:U,ink:v,paper:R,strokeWidth:2.5,fontFamily:cssFontStack(I)}),clear:ge,undo:ye,isEmpty:()=>re}),[re,k.emptyError,Se,m,z,N,U,j,v,R,I,ge,ye]);const be=useMemo(()=>[{name:"undo",label:k.undo},{name:"clear",label:k.clear},...c?[{name:"toggleMode",label:"draw"===z?k.typeInstead:k.drawInstead}]:[]],[k.undo,k.clear,k.typeInstead,k.drawInstead,c,z]),we=useCallback(e=>{if(S)return;const{actionName:t}=e.nativeEvent;"undo"===t?ye():"clear"===t?ge():"toggleMode"===t&&c&&me()},[S,ye,ge,me,c]),Ee=useCallback(e=>{G(e.nativeEvent.layout.width)},[]),Ce=useMemo(()=>StyleSheet.create({root:{gap:w.space.sm},pad:{height:m,borderWidth:w.size.border,borderColor:w.colors.border,borderRadius:w.radius.md,...smoothCorners,overflow:"hidden",backgroundColor:A,opacity:S?.5:1},baseline:{position:"absolute",left:w.space.md,right:w.space.md,top:m*BASELINE_RATIO,height:StyleSheet.hairlineWidth,backgroundColor:C,opacity:.3},actions:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",flexWrap:"wrap",gap:w.space.xs},trailing:{flexDirection:"row",alignItems:"center",gap:w.space.xs},expandedRoot:{flex:1,padding:w.space.md,gap:w.space.sm,backgroundColor:w.colors.bg},expandedBar:{flexDirection:"row",alignItems:"center",justifyContent:"space-between"}}),[w,m,A,C,S]),Ae=U.trim(),ve=p??X,Re=u&&!re?`Signed by ${u}${ve?`, ${formatDateTime(ve)}`:""}`:null,je="type"===z&&Ae?`${k.pad}. ${Ae}`:k.pad;return _jsxs(View,{style:[Ce.root,b],testID:_,children:[_jsx(GestureDetector,{gesture:ue,children:_jsxs(View,{style:Ce.pad,onLayout:Ee,accessible:!0,accessibilityRole:"image",accessibilityLabel:je,accessibilityHint:"draw"===z?k.padHint:void 0,accessibilityValue:{text:re?k.empty:k.signed},accessibilityState:{disabled:S},"aria-disabled":S,accessibilityActions:be,onAccessibilityAction:we,children:[j?_jsxs(Svg,{ref:M,style:StyleSheet.absoluteFill,width:"100%",height:m,children:[_jsx(Rect,{x:"0",y:"0",width:"100%",height:"100%",fill:R}),_jsx(Marks,{mode:z,strokes:N,name:Ae,color:v,fontFamily:I,width:Se,height:m})]}):null,_jsxs(Svg,{ref:L,width:"100%",height:m,children:[_jsx(Rect,{x:"0",y:"0",width:"100%",height:"100%",fill:A}),_jsx(Marks,{mode:z,strokes:N,name:Ae,color:C,fontFamily:I,width:Se,height:m})]}),_jsx(View,{pointerEvents:"none",style:Ce.baseline})]})}),"type"===z?_jsx(Input,{label:k.typedLabel,placeholder:k.typedPlaceholder,value:U,onChangeText:he,maxLength:h,disabled:S,autoComplete:"name",textContentType:"name",autoCapitalize:"words",autoCorrect:!1,returnKeyType:"done",testID:_?`${_}-name`:void 0}):null,_jsx(Text,{variant:"caption",color:"tertiary",children:"draw"===z?k.caption:k.typedCaption}),_jsxs(View,{style:Ce.actions,children:[c?_jsx(Button,{label:"draw"===z?k.typeInstead:k.drawInstead,variant:"ghost",tone:"primary",size:"md",style:TARGET_STYLE,haptic:T,disabled:S,onPress:me,testID:_?`${_}-mode`:void 0}):_jsx(View,{}),"draw"===z?_jsxs(View,{style:Ce.trailing,children:[N.length>0?_jsxs(_Fragment,{children:[_jsx(Button,{label:k.undo,variant:"ghost",tone:"primary",size:"md",style:TARGET_STYLE,haptic:T,disabled:S,onPress:ye,testID:_?`${_}-undo`:void 0}),_jsx(Button,{label:k.clear,variant:"ghost",tone:"primary",size:"md",style:TARGET_STYLE,haptic:T,disabled:S,onPress:ge,testID:_?`${_}-clear`:void 0})]}):null,n?_jsx(Button,{label:k.expand,variant:"ghost",tone:"primary",size:"md",style:TARGET_STYLE,haptic:T,disabled:S,onPress:fe,testID:_?`${_}-expand`:void 0}):null]}):null,"type"===z&&Ae?_jsx(Button,{label:k.clear,variant:"ghost",tone:"primary",size:"md",style:TARGET_STYLE,haptic:T,disabled:S,onPress:ge,testID:_?`${_}-clear`:void 0}):null]}),Re?_jsx(Text,{variant:"caption",color:"secondary",children:Re}):null,n?_jsx(Modal,{visible:Q,animationType:"slide",presentationStyle:"fullScreen",onRequestClose:xe,children:_jsxs(ExpandedRoot,{style:Ce.expandedRoot,children:[_jsxs(View,{style:Ce.expandedBar,children:[_jsx(Button,{label:k.close,variant:"ghost",tone:"primary",size:"md",style:TARGET_STYLE,haptic:T,onPress:xe,testID:_?`${_}-close`:void 0}),_jsx(Button,{label:k.done,variant:"solid",tone:"primary",size:"md",style:TARGET_STYLE,haptic:T,onPress:Te,testID:_?`${_}-done`:void 0})]}),Q?_jsx(SignaturePadSurface,{expandable:!1,defaultMode:"draw",allowTyped:!1,initialStrokes:ee,onChange:te,height:Math.max(DEFAULT_HEIGHT,J-200),inkColor:g,paperColor:y,scriptFontFamily:f,labels:x,haptic:T,testID:_?`${_}-expanded`:void 0}):null]})}):null]})}const ExpandedRoot="android"===Platform.OS?GestureHandlerRootView:View;function SignaturePad({ref:e,...t}){return _jsx(SignaturePadSurface,{...t,expandable:!0,ref:e})}export{SignaturePad};export default SignaturePad;
@@ -1 +1 @@
1
- "use strict";import{createContext,useContext,useEffect,useMemo,useRef}from"react";import{Animated,Easing}from"react-native";import{createAnimatedValue}from"../../theme/index.js";import{nativeDriver}from"../../utils/nativeDriver.js";import{jsx as _jsx}from"react/jsx-runtime";const SHIMMER_DURATION={slow:1800,normal:1200,fast:800},PULSE_DURATION=1e3,SkeletonClockContext=createContext(null);export const SkeletonClockProvider=({speed:e,enabled:t,variant:n,children:a})=>{const r=useRef(createAnimatedValue(0)).current,i=useRef(createAnimatedValue(0)).current;useEffect(()=>{if(!t)return r.setValue(0),void i.setValue(.5);const n=Animated.loop(Animated.timing(r,{toValue:1,duration:SHIMMER_DURATION[e],easing:Easing.linear,useNativeDriver:nativeDriver})),a=Animated.loop(Animated.sequence([Animated.timing(i,{toValue:1,duration:500,easing:Easing.inOut(Easing.ease),useNativeDriver:nativeDriver}),Animated.timing(i,{toValue:0,duration:500,easing:Easing.inOut(Easing.ease),useNativeDriver:nativeDriver})]));return n.start(),a.start(),()=>{n.stop(),a.stop()}},[e,t,r,i]);const o=useMemo(()=>({shimmer:r,pulse:i,enabled:t}),[r,i,t]);return _jsx(SkeletonClockContext.Provider,{value:o,children:a})};SkeletonClockProvider.displayName="SkeletonClockProvider";export const useSkeletonClock=()=>{const e=useContext(SkeletonClockContext);return e||fallbackClock};const fallbackClock={shimmer:createAnimatedValue(0),pulse:createAnimatedValue(.5),enabled:!1};
1
+ "use strict";import{createContext,useContext,useEffect,useMemo,useRef}from"react";import{Animated,Easing}from"react-native";import{createAnimatedValue}from"../../theme/index.js";import{nativeDriver}from"../../utils/nativeDriver.js";import{jsx as _jsx}from"react/jsx-runtime";const SHIMMER_DURATION={slow:1800,normal:1200,fast:800},PULSE_DURATION=1e3,SkeletonClockContext=createContext(null);export const SkeletonClockProvider=({speed:e,enabled:t,variant:n,children:a})=>{const i=useRef(createAnimatedValue(0)).current,r=useRef(createAnimatedValue(0)).current;useEffect(()=>{if(!t)return i.setValue(0),void r.setValue(.5);const n=Animated.loop(Animated.timing(i,{toValue:1,duration:SHIMMER_DURATION[e],easing:Easing.linear,useNativeDriver:nativeDriver})),a=Animated.loop(Animated.sequence([Animated.timing(r,{toValue:1,duration:500,easing:Easing.inOut(Easing.ease),useNativeDriver:nativeDriver}),Animated.timing(r,{toValue:0,duration:500,easing:Easing.inOut(Easing.ease),useNativeDriver:nativeDriver})]));return n.start(),a.start(),()=>{n.stop(),a.stop()}},[e,t,i,r]);const o=useMemo(()=>({shimmer:i,pulse:r,enabled:t}),[i,r,t]);return _jsx(SkeletonClockContext,{value:o,children:a})};SkeletonClockProvider.displayName="SkeletonClockProvider";export const useSkeletonClock=()=>{const e=useContext(SkeletonClockContext);return e||fallbackClock};const fallbackClock={shimmer:createAnimatedValue(0),pulse:createAnimatedValue(.5),enabled:!1};
@@ -1 +1 @@
1
- "use strict";import{createContext,useContext,useMemo}from"react";import{SkeletonClockProvider}from"./SkeletonClock.js";import{jsx as _jsx}from"react/jsx-runtime";const SkeletonDefaultsContext=createContext({});export const SkeletonProvider=({children:e,variant:t,speed:o,placeholderCount:r,radius:n,colors:a,fadeDuration:s,animation:l="auto"})=>{const i="never"!==l,d=o??"normal",u=t??"shimmer",c=useMemo(()=>({variant:t,speed:o,placeholderCount:r,radius:n,colors:a,fadeDuration:s,animation:l}),[t,o,r,n,a,s,l]);return _jsx(SkeletonDefaultsContext.Provider,{value:c,children:_jsx(SkeletonClockProvider,{speed:d,variant:u,enabled:i,children:e})})};SkeletonProvider.displayName="SkeletonProvider";export const useSkeletonDefaults=()=>useContext(SkeletonDefaultsContext);
1
+ "use strict";import{createContext,useContext,useMemo}from"react";import{SkeletonClockProvider}from"./SkeletonClock.js";import{jsx as _jsx}from"react/jsx-runtime";const SkeletonDefaultsContext=createContext({});export const SkeletonProvider=({children:e,variant:t,speed:o,placeholderCount:r,radius:n,colors:a,fadeDuration:s,animation:l="auto"})=>{const i="never"!==l,u=o??"normal",c=t??"shimmer",d=useMemo(()=>({variant:t,speed:o,placeholderCount:r,radius:n,colors:a,fadeDuration:s,animation:l}),[t,o,r,n,a,s,l]);return _jsx(SkeletonDefaultsContext,{value:d,children:_jsx(SkeletonClockProvider,{speed:u,variant:c,enabled:i,children:e})})};SkeletonProvider.displayName="SkeletonProvider";export const useSkeletonDefaults=()=>useContext(SkeletonDefaultsContext);
@@ -1 +1 @@
1
- "use strict";import React,{forwardRef,useCallback,useMemo,useRef,useState}from"react";import{StyleSheet,View}from"react-native";import{GestureDetector,usePanGesture}from"react-native-gesture-handler";import Animated,{cancelAnimation,Easing,useAnimatedStyle,useSharedValue,withSpring,withTiming}from"react-native-reanimated";import{scheduleOnRN}from"react-native-worklets";import{useMobileUiText}from"../../text/index.js";import{SLIDE_TO_CONFIRM_TEXT}from"../../text/phone/slideToConfirm.g.js";import{useTheme}from"../../theme/index.js";import{resolveHaptic,triggerHaptic}from"../../utils/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{smoothCorners}from"../../utils/corners.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const SIZE_MAP={sm:{height:44,pad:"xxs"},md:{height:56,pad:"xs"},lg:{height:64,pad:"sm"}},Chevron=({color:e,size:t})=>_jsx(View,{style:{width:0,height:0,borderTopWidth:.4*t,borderBottomWidth:.4*t,borderLeftWidth:.55*t,borderTopColor:"transparent",borderBottomColor:"transparent",borderLeftColor:e,marginLeft:.2*t}}),SlideToConfirm=forwardRef((e,t)=>{const{onConfirm:i,label:a,tone:r="primary",size:o="md",disabled:s=!1,threshold:n=.9,resetAfter:l=!1,haptic:u,icon:c,labels:d,style:m,trackStyle:h,handleStyle:f,labelStyle:p,testID:b}=e;assertValidValue("SlideToConfirm","tone",e.tone,["primary","success","warning","danger","info","neutral"]),assertValidValue("SlideToConfirm","size",e.size,["sm","md","lg"]);const g=useMobileUiText("slideToConfirm",SLIDE_TO_CONFIRM_TEXT),v=useMemo(()=>({...g,...d}),[g,d]),S=useMemo(()=>[{name:"activate",label:v.confirmAction},{name:"increment",label:v.confirmAction}],[v.confirmAction]),x=useTheme(),y=SIZE_MAP[o],C=x.space[y.pad],T=y.height-2*C,w=useMemo(()=>buildStyles(x,y),[x,y]),j=x.colors[r],[A,V]=useState(!1),_=useSharedValue(0),k=useSharedValue(0),M=useSharedValue(0),E=useRef(null),R=useCallback(()=>{const e=resolveHaptic(u,"notificationSuccess");e&&triggerHaptic(e)},[u]),I=useCallback(()=>{V(!1),_.value=withSpring(0,{damping:18,stiffness:160,mass:1})},[_]),D=useCallback(()=>{V(!0),R(),i(),!1!==l&&(E.current&&clearTimeout(E.current),E.current=setTimeout(I,l))},[R,i,l,I]),L=useCallback(e=>{if(s||A)return;const{actionName:t}=e.nativeEvent;"activate"!==t&&"increment"!==t||D()},[s,A,D]);React.useEffect(()=>()=>{cancelAnimation(_),E.current&&clearTimeout(E.current)},[_]);const O=useCallback(e=>{k.value=Math.max(0,e.nativeEvent.layout.width-T-2*C)},[k,T,C]),N=useMemo(()=>{const e=n,t={damping:18,stiffness:160,mass:1},i={duration:x.motion.duration.fast,easing:Easing.out(Easing.cubic)};return{enabled:!s&&!A,minDistance:0,onActivate:()=>{"worklet";M.value=_.value},onUpdate:e=>{"worklet";_.value=Math.min(Math.max(M.value+e.translationX,0),k.value)},onDeactivate:()=>{"worklet";k.value>0&&_.value>=k.value*e?(_.value=withTiming(k.value,i),scheduleOnRN(D)):_.value=withSpring(0,t)}}},[s,A,n,_,k,M,D,x.motion.duration.fast]),z=usePanGesture(N),P=useAnimatedStyle(()=>({transform:[{translateX:_.value}]}),[_]),W=useAnimatedStyle(()=>({width:_.value+T+C}),[_,T,C]),G=useAnimatedStyle(()=>{const e=k.value>0?k.value:1;return{opacity:Math.max(0,1-_.value/(.6*e))}},[k,_]);return _jsxs(View,{ref:t,style:[w.track,{backgroundColor:x.colors["bg-subtle"]},h,m],onLayout:O,testID:b,accessibilityRole:"adjustable",accessibilityLabel:A?v.confirmed:a??v.slide,accessibilityState:{disabled:s},"aria-disabled":s,accessibilityActions:S,onAccessibilityAction:L,children:[_jsx(Animated.View,{style:[w.fill,{backgroundColor:j,opacity:s?.5:1},W],pointerEvents:"none"}),_jsx(Animated.View,{style:[w.labelWrap,G],pointerEvents:"none",children:_jsx(Text,{variant:"body",style:[w.label,{color:x.colors["text-muted"]},p],numberOfLines:1,children:A?v.confirmed:a??v.slide})}),_jsx(GestureDetector,{gesture:z,children:_jsx(Animated.View,{style:[w.handle,{width:T,height:T,borderRadius:x.radius.pill,...smoothCorners,backgroundColor:x.colors.surface,opacity:s?.5:1,...x.shadow.card},f,P],children:c??_jsx(Chevron,{color:j,size:.5*T})})})]})});SlideToConfirm.displayName="SlideToConfirm";const buildStyles=(e,t)=>StyleSheet.create({track:{height:t.height,borderRadius:e.radius.pill,...smoothCorners,justifyContent:"center",overflow:"hidden",padding:e.space[t.pad]},fill:{position:"absolute",left:0,top:0,bottom:0,borderRadius:e.radius.pill,...smoothCorners},labelWrap:{position:"absolute",left:t.height,right:t.height},label:{textAlign:"center",includeFontPadding:!1},handle:{alignItems:"center",justifyContent:"center"}});export{SlideToConfirm};export default SlideToConfirm;
1
+ "use strict";import React,{useCallback,useMemo,useRef,useState}from"react";import{StyleSheet,View}from"react-native";import{GestureDetector,usePanGesture}from"react-native-gesture-handler";import Animated,{cancelAnimation,Easing,useAnimatedStyle,useSharedValue,withSpring,withTiming}from"react-native-reanimated";import{scheduleOnRN}from"react-native-worklets";import{useMobileUiText}from"../../text/index.js";import{SLIDE_TO_CONFIRM_TEXT}from"../../text/phone/slideToConfirm.g.js";import{useTheme}from"../../theme/index.js";import{resolveHaptic,triggerHaptic}from"../../utils/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{smoothCorners}from"../../utils/corners.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const SIZE_MAP={sm:{height:44,pad:"xxs"},md:{height:56,pad:"xs"},lg:{height:64,pad:"sm"}},Chevron=({color:e,size:t})=>_jsx(View,{style:{width:0,height:0,borderTopWidth:.4*t,borderBottomWidth:.4*t,borderLeftWidth:.55*t,borderTopColor:"transparent",borderBottomColor:"transparent",borderLeftColor:e,marginLeft:.2*t}});function SlideToConfirm({ref:e,...t}){const{onConfirm:i,label:a,tone:r="primary",size:o="md",disabled:s=!1,threshold:n=.9,resetAfter:l=!1,haptic:u,icon:c,labels:d,style:m,trackStyle:h,handleStyle:f,labelStyle:p,testID:b}=t;assertValidValue("SlideToConfirm","tone",t.tone,["primary","success","warning","danger","info","neutral"]),assertValidValue("SlideToConfirm","size",t.size,["sm","md","lg"]);const g=useMobileUiText("slideToConfirm",SLIDE_TO_CONFIRM_TEXT),v=useMemo(()=>({...g,...d}),[g,d]),x=useMemo(()=>[{name:"activate",label:v.confirmAction},{name:"increment",label:v.confirmAction}],[v.confirmAction]),y=useTheme(),S=SIZE_MAP[o],C=y.space[S.pad],T=S.height-2*C,j=useMemo(()=>buildStyles(y,S),[y,S]),w=y.colors[r],[A,V]=useState(!1),_=useSharedValue(0),k=useSharedValue(0),M=useSharedValue(0),E=useRef(null),R=useCallback(()=>{const e=resolveHaptic(u,"notificationSuccess");e&&triggerHaptic(e)},[u]),I=useCallback(()=>{V(!1),_.value=withSpring(0,{damping:18,stiffness:160,mass:1})},[_]),D=useCallback(()=>{V(!0),R(),i(),!1!==l&&(E.current&&clearTimeout(E.current),E.current=setTimeout(I,l))},[R,i,l,I]),L=useCallback(e=>{if(s||A)return;const{actionName:t}=e.nativeEvent;"activate"!==t&&"increment"!==t||D()},[s,A,D]);React.useEffect(()=>()=>{cancelAnimation(_),E.current&&clearTimeout(E.current)},[_]);const O=useCallback(e=>{k.value=Math.max(0,e.nativeEvent.layout.width-T-2*C)},[k,T,C]),z=useMemo(()=>{const e=n,t={damping:18,stiffness:160,mass:1},i={duration:y.motion.duration.fast,easing:Easing.out(Easing.cubic)};return{enabled:!s&&!A,minDistance:0,onActivate:()=>{"worklet";M.value=_.value},onUpdate:e=>{"worklet";_.value=Math.min(Math.max(M.value+e.translationX,0),k.value)},onDeactivate:()=>{"worklet";k.value>0&&_.value>=k.value*e?(_.value=withTiming(k.value,i),scheduleOnRN(D)):_.value=withSpring(0,t)}}},[s,A,n,_,k,M,D,y.motion.duration.fast]),N=usePanGesture(z),P=useAnimatedStyle(()=>({transform:[{translateX:_.value}]}),[_]),W=useAnimatedStyle(()=>({width:_.value+T+C}),[_,T,C]),G=useAnimatedStyle(()=>{const e=k.value>0?k.value:1;return{opacity:Math.max(0,1-_.value/(.6*e))}},[k,_]);return _jsxs(View,{ref:e,style:[j.track,{backgroundColor:y.colors["bg-subtle"]},h,m],onLayout:O,testID:b,accessibilityRole:"adjustable",accessibilityLabel:A?v.confirmed:a??v.slide,accessibilityState:{disabled:s},"aria-disabled":s,accessibilityActions:x,onAccessibilityAction:L,children:[_jsx(Animated.View,{style:[j.fill,{backgroundColor:w,opacity:s?.5:1},W],pointerEvents:"none"}),_jsx(Animated.View,{style:[j.labelWrap,G],pointerEvents:"none",children:_jsx(Text,{variant:"body",style:[j.label,{color:y.colors["text-muted"]},p],numberOfLines:1,children:A?v.confirmed:a??v.slide})}),_jsx(GestureDetector,{gesture:N,children:_jsx(Animated.View,{style:[j.handle,{width:T,height:T,borderRadius:y.radius.pill,...smoothCorners,backgroundColor:y.colors.surface,opacity:s?.5:1,...y.shadow.card},f,P],children:c??_jsx(Chevron,{color:w,size:.5*T})})})]})}const buildStyles=(e,t)=>StyleSheet.create({track:{height:t.height,borderRadius:e.radius.pill,...smoothCorners,justifyContent:"center",overflow:"hidden",padding:e.space[t.pad]},fill:{position:"absolute",left:0,top:0,bottom:0,borderRadius:e.radius.pill,...smoothCorners},labelWrap:{position:"absolute",left:t.height,right:t.height},label:{textAlign:"center",includeFontPadding:!1},handle:{alignItems:"center",justifyContent:"center"}});export{SlideToConfirm};export default SlideToConfirm;
@@ -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,useAnimatedStyle,useSharedValue,withSpring,withTiming}from"react-native-reanimated";import{scheduleOnRN}from"react-native-worklets";import{useControllableState}from"../../hooks/index.js";import{fillText,useMobileUiText}from"../../text/index.js";import{SLIDER_TEXT}from"../../text/phone/slider.g.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),isPair=e=>Array.isArray(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:f,trackStyle:p,fillStyle:g,thumbStyle:v,labelStyle:w,thumbPressScale:y,labelShowDuration:S,labelOpacity:k,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 C=useTheme(),A=useMobileUiText("slider",SLIDER_TEXT),V=useMemo(()=>{const e=resolveSliderSize(C,o);return{trackHeight:e["track-height"],thumbDiameter:e["thumb-diameter"]}},[C,o]),D=useMemo(()=>"default"===l?V:VARIANT_SIZE_MAP[l][o],[V,o,l]),j="inset"===l?D.trackHeight/2:0,M=C.settings.components.slider?.thumbPressAnimation??!1,_=y??1.1,T=S??C.motion.duration.fast,R=k??1,E=useMemo(()=>buildStyles(C,D),[C,D]),H=useMemo(()=>({damping:C.motion.spring.snappy.damping,stiffness:C.motion.spring.snappy.stiffness,mass:C.motion.spring.snappy.mass}),[C.motion.spring.snappy]),[O,I]=useState(0),P=C.colors[n],N=sliderToneInk(C,n),L=!0===e.range,W=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,i]:a),onChange:W}),F=useSharedValue(0),G=useSharedValue(0),U=useSharedValue(isPair(X)?X[0]:X),z=useSharedValue(isPair(X)?X[1]:X),$=useSharedValue(0),Z=useSharedValue(0),J=useSharedValue(1),q=useSharedValue(1),K="always"===u,Q=useSharedValue(K?1:0),Y=useSharedValue(K?1:0),ee=useMemo(()=>10**(String(r).split(".")[1]?.length??0),[r]);useEffect(()=>()=>{cancelAnimation(F),cancelAnimation(G),cancelAnimation(J),cancelAnimation(q),cancelAnimation(Q),cancelAnimation(Y)},[F,G,J,q,Q,Y]);const te=useCallback((e,t)=>{const r=t-2*j;return i===a||r<=0?j:j+(e-a)/(i-a)*r},[a,i,j]),ae=useCallback((e,t)=>{const s=t-2*j;if(s<=0)return a;const n=clamp((e-j)/s,0,1);return snapToStep(a+n*(i-a),a,i,r)},[a,i,r,j]),ie=useRef(!1),re=C.motion.duration.fast,se=useRef(X);se.current=X;const ne=useRef(O);ne.current=O;const oe=useCallback((e=!1)=>{const t=ne.current;if(t<=0)return;const place=t=>e?withTiming(t,{duration:re,easing:Easing.out(Easing.cubic)}):t,a=se.current;if(isPair(a)){const[e,i]=a,r=Math.min(e,i),s=Math.max(e,i);U.value=r,z.value=s,F.value=place(te(r,t)),G.value=place(te(s,t))}else{const e=a;U.value=e,z.value=e,F.value=place(te(e,t))}},[te,U,z,F,G,re]),[le,ue]=useState(0),ce=useRef(!1),de=useCallback(e=>{ie.current=e,e||(ce.current=!0,ue(e=>e+1))},[]);useEffect(()=>{if(ie.current)return;const e=ce.current;ce.current=!1,oe(e)},[JSON.stringify(X),O,le,oe]);const me=useCallback(e=>{const t=e.nativeEvent.layout.width;Z.value=t,I(t)},[Z]),he=useCallback((e,t)=>{B(L?[e,t]:e)},[L,B]),be=useCallback(()=>{const e=resolveHaptic(b,"selection");e&&triggerHaptic(e)},[b]),fe=useRef(he);fe.current=he;const pe=useRef(be);pe.current=be;const ge=useCallback((e,t)=>fe.current(e,t),[]),ve=useCallback(()=>pe.current(),[]),we=Math.max(0,(44-D.thumbDiameter)/2),ye=we>0?we:void 0,Se=useCallback(e=>{const t="low"===e?F:G,n="low"===e?U:z,o="low"===e?z:U,l="low"===e?J:q,d="low"===e?Q:Y,m="low"===e,h=a,b=i,f=r,p=ee,g=L,v=_,w=M,y=!0===u,S=c,k=R,C=T,A=H,V=j,D=m&&x?`${x}-pan`:void 0,follow=e=>{"worklet";const a=Z.value-2*V;if(a<=0||!Number.isFinite(e))return;const i=Math.min(Math.max($.value+e,V),Z.value-V);let r=h+(i-V)/a*(b-h);f>0&&(r=Math.round((r-h)/f)*f+h,r=Math.round(r*p)/p),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,G.value):Math.max(i,F.value):i,r!==n.value&&(n.value=r,r!==h&&r!==b||scheduleOnRN(ve),scheduleOnRN(ge,U.value,z.value))};return{enabled:!s,minDistance:0,testID:D,...void 0===ye?{}:{hitSlop:ye},onActivate:()=>{"worklet";scheduleOnRN(de,!0),$.value=t.value,w&&(l.value=withSpring(v,A)),y&&(d.value=withTiming(k,{duration:C,easing:Easing.out(Easing.cubic)})),scheduleOnRN(ve)},onUpdate:e=>{"worklet";follow(e.translationX)},onDeactivate:e=>{"worklet";follow(e.translationX),w&&(l.value=withSpring(1,A)),y&&(d.value=withTiming(0,{duration:C,easing:Easing.out(Easing.cubic)}))},onFinalize:()=>{"worklet";scheduleOnRN(de,!1)}}},[s,a,i,r,ee,L,_,M,u,c,R,T,H,j,ye,x,ge,ve,de,F,G,U,z,J,q,Q,Y,$,Z]),ke=useMemo(()=>Se("low"),[Se]),xe=useMemo(()=>Se("high"),[Se]),Ce=usePanGesture(ke),Ae=usePanGesture(xe),Ve=useCallback(e=>{if(s||L||O<=0)return;const t=clamp(e.nativeEvent.locationX,0,O),a=ae(t,O);a!==U.value&&(be(),U.value=a,F.value=withTiming(te(a,O),{duration:C.motion.duration.fast,easing:Easing.out(Easing.cubic)}),he(a,a))},[s,L,O,ae,te,he,be,F,U,C.motion.duration.fast]),De=useCallback(e=>{if(s)return;const t="increment"===e.nativeEvent.actionName?r:-r,n=r>0?Math.round(t*ee)/ee:t;if(L){const e=Math.round((U.value+n)*ee)/ee,t=clamp(e,a,z.value);t!==U.value&&(U.value=t,F.value=te(t,O),be(),he(t,z.value))}else{const e=Math.round((U.value+n)*ee)/ee,t=clamp(e,a,i);t!==U.value&&(U.value=t,F.value=te(t,O),be(),he(t,t))}},[s,r,ee,L,a,i,te,O,F,U,z,he,be]),je=D.thumbDiameter/2,Me=s?C.colors["surface-disabled"]:P,Te="inset"===l?{backgroundColor:Me,borderColor:C.colors.surface,borderWidth:Math.max(2,Math.round(.3*D.thumbDiameter)),...NO_SHADOW}:"minimal"===l?{backgroundColor:Me,borderWidth:0}:"bar"===l?{backgroundColor:"transparent",borderWidth:0,...NO_SHADOW}:{backgroundColor:C.colors.surface,borderColor:Me},Re=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*j);return{opacity:t,transform:[{translateX:F.value-j},{scaleX:a/e}]}}return{opacity:t,transform:[{translateX:F.value+j-e},{scaleX:1}]}},[Z,s,L,G,F,j]),Ee=useAnimatedStyle(()=>({transform:[{translateX:F.value-je},{scale:J.value}]}),[F,je,J]),He=useAnimatedStyle(()=>({transform:[{translateX:G.value-je},{scale:q.value}]}),[G,je,q]),Oe=useAnimatedStyle(()=>({opacity:Q.value}),[Q]),Ie=useAnimatedStyle(()=>({opacity:Y.value}),[Y]),clampDisplay=e=>clamp(e,a,i),Pe=clampDisplay(isPair(X)?Math.min(...X):X),Ne=clampDisplay(isPair(X)?Math.max(...X):X);return _jsx(View,{ref:t,style:[E.container,f],testID:x,accessibilityRole:"adjustable",accessibilityLabel:h,accessibilityState:{disabled:s},"aria-disabled":s,accessibilityValue:L?{min:a,max:i,now:Pe,text:fillText(A.text,{start:Pe,end:Ne})}:{min:a,max:i,now:Pe},accessibilityActions:[{name:"increment"},{name:"decrement"}],onAccessibilityAction:De,children:_jsx(Pressable,{onPress:Ve,disabled:s||L,style:E.trackTouch,testID:x?`${x}-track-press`:void 0,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:_jsxs(View,{style:E.trackWrap,onLayout:me,testID:x?`${x}-track`:void 0,children:[_jsxs(View,{style:E.trackClip,pointerEvents:"none",children:[_jsx(View,{style:[E.track,{backgroundColor:s?C.colors["surface-disabled"]:C.colors.border},p]}),_jsx(Animated.View,{style:[E.fill,{backgroundColor:s?C.colors["surface-disabled"]:P},g,Re],testID:x?`${x}-fill`:void 0})]}),_jsx(GestureDetector,{gesture:Ce,children:_jsx(Animated.View,{style:[E.thumb,{width:D.thumbDiameter,height:D.thumbDiameter,borderRadius:je,...smoothCorners,opacity:s?.55:1},Te,v,Ee],testID:x?`${x}-thumb`:void 0,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:u?_jsxs(Animated.View,{style:[E.bubbleWrap,Oe],pointerEvents:"none",children:[_jsx(View,{style:[E.bubble,{backgroundColor:P}],children:m?m(Pe):_jsx(Text,{variant:"caption",weight:"semibold",style:[{color:N},w],numberOfLines:1,children:d(Pe)})}),_jsx(View,{style:[E.bubbleCaret,{backgroundColor:P}]})]}):null})}),L?_jsx(GestureDetector,{gesture:Ae,children:_jsx(Animated.View,{style:[E.thumb,{width:D.thumbDiameter,height:D.thumbDiameter,borderRadius:je,...smoothCorners,opacity:s?.55:1},Te,v,He],accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:u?_jsxs(Animated.View,{style:[E.bubbleWrap,Ie],pointerEvents:"none",children:[_jsx(View,{style:[E.bubble,{backgroundColor:P}],children:m?m(Ne):_jsx(Text,{variant:"caption",weight:"semibold",style:[{color:N},w],numberOfLines:1,children:d(Ne)})}),_jsx(View,{style:[E.bubbleCaret,{backgroundColor:P}]})]}):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{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,useAnimatedStyle,useSharedValue,withSpring,withTiming}from"react-native-reanimated";import{scheduleOnRN}from"react-native-worklets";import{useControllableState}from"../../hooks/index.js";import{fillText,useMobileUiText}from"../../text/index.js";import{SLIDER_TEXT}from"../../text/phone/slider.g.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),isPair=e=>Array.isArray(e);function Slider({ref: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:g,trackStyle:p,fillStyle:f,thumbStyle:v,labelStyle:w,thumbPressScale:y,labelShowDuration:S,labelOpacity:k,testID:x}=t;assertValidValue("Slider","tone",t.tone,["primary","success","warning","danger","info","neutral"]),assertValidValue("Slider","size",t.size,["sm","md","lg"]),assertValidValue("Slider","variant",t.variant,["default","inset","minimal","bar"]);const C=useTheme(),A=useMobileUiText("slider",SLIDER_TEXT),V=useMemo(()=>{const e=resolveSliderSize(C,o);return{trackHeight:e["track-height"],thumbDiameter:e["thumb-diameter"]}},[C,o]),D=useMemo(()=>"default"===l?V:VARIANT_SIZE_MAP[l][o],[V,o,l]),j="inset"===l?D.trackHeight/2:0,M=C.settings.components.slider?.thumbPressAnimation??!1,_=y??1.1,T=S??C.motion.duration.fast,E=k??1,R=useMemo(()=>buildStyles(C,D),[C,D]),H=useMemo(()=>({damping:C.motion.spring.snappy.damping,stiffness:C.motion.spring.snappy.stiffness,mass:C.motion.spring.snappy.mass}),[C.motion.spring.snappy]),[O,I]=useState(0),P=C.colors[n],N=sliderToneInk(C,n),L=!0===t.range,W=useCallback(e=>{if(!0!==t.range){if(Array.isArray(e))throw new Error("Slider received a range value in single mode.");t.onChange?.(e)}else{if(!Array.isArray(e))throw new Error("Slider received a single value in range mode.");t.onChange?.(e)}},[t.onChange,t.range]),[X,B]=useControllableState({value:t.value,defaultValue:t.defaultValue??(L?[a,i]:a),onChange:W}),F=useSharedValue(0),G=useSharedValue(0),U=useSharedValue(isPair(X)?X[0]:X),z=useSharedValue(isPair(X)?X[1]:X),$=useSharedValue(0),Z=useSharedValue(0),J=useSharedValue(1),q=useSharedValue(1),K="always"===u,Q=useSharedValue(K?1:0),Y=useSharedValue(K?1:0),ee=useMemo(()=>10**(String(r).split(".")[1]?.length??0),[r]);useEffect(()=>()=>{cancelAnimation(F),cancelAnimation(G),cancelAnimation(J),cancelAnimation(q),cancelAnimation(Q),cancelAnimation(Y)},[F,G,J,q,Q,Y]);const te=useCallback((e,t)=>{const r=t-2*j;return i===a||r<=0?j:j+(e-a)/(i-a)*r},[a,i,j]),ae=useCallback((e,t)=>{const s=t-2*j;if(s<=0)return a;const n=clamp((e-j)/s,0,1);return snapToStep(a+n*(i-a),a,i,r)},[a,i,r,j]),ie=useRef(!1),re=C.motion.duration.fast,se=useRef(X);se.current=X;const ne=useRef(O);ne.current=O;const oe=useCallback((e=!1)=>{const t=ne.current;if(t<=0)return;const place=t=>e?withTiming(t,{duration:re,easing:Easing.out(Easing.cubic)}):t,a=se.current;if(isPair(a)){const[e,i]=a,r=Math.min(e,i),s=Math.max(e,i);U.value=r,z.value=s,F.value=place(te(r,t)),G.value=place(te(s,t))}else{const e=a;U.value=e,z.value=e,F.value=place(te(e,t))}},[te,U,z,F,G,re]),[le,ue]=useState(0),ce=useRef(!1),de=useCallback(e=>{ie.current=e,e||(ce.current=!0,ue(e=>e+1))},[]);useEffect(()=>{if(ie.current)return;const e=ce.current;ce.current=!1,oe(e)},[JSON.stringify(X),O,le,oe]);const me=useCallback(e=>{const t=e.nativeEvent.layout.width;Z.value=t,I(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 pe=useRef(be);pe.current=be;const fe=useCallback((e,t)=>ge.current(e,t),[]),ve=useCallback(()=>pe.current(),[]),we=Math.max(0,(44-D.thumbDiameter)/2),ye=we>0?we:void 0,Se=useCallback(e=>{const t="low"===e?F:G,n="low"===e?U:z,o="low"===e?z:U,l="low"===e?J:q,d="low"===e?Q:Y,m="low"===e,h=a,b=i,g=r,p=ee,f=L,v=_,w=M,y=!0===u,S=c,k=E,C=T,A=H,V=j,D=m&&x?`${x}-pan`:void 0,follow=e=>{"worklet";const a=Z.value-2*V;if(a<=0||!Number.isFinite(e))return;const i=Math.min(Math.max($.value+e,V),Z.value-V);let r=h+(i-V)/a*(b-h);g>0&&(r=Math.round((r-h)/g)*g+h,r=Math.round(r*p)/p),r=Math.min(Math.max(r,h),b),f&&(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:f?m?Math.min(i,G.value):Math.max(i,F.value):i,r!==n.value&&(n.value=r,r!==h&&r!==b||scheduleOnRN(ve),scheduleOnRN(fe,U.value,z.value))};return{enabled:!s,minDistance:0,testID:D,...void 0===ye?{}:{hitSlop:ye},onActivate:()=>{"worklet";scheduleOnRN(de,!0),$.value=t.value,w&&(l.value=withSpring(v,A)),y&&(d.value=withTiming(k,{duration:C,easing:Easing.out(Easing.cubic)})),scheduleOnRN(ve)},onUpdate:e=>{"worklet";follow(e.translationX)},onDeactivate:e=>{"worklet";follow(e.translationX),w&&(l.value=withSpring(1,A)),y&&(d.value=withTiming(0,{duration:C,easing:Easing.out(Easing.cubic)}))},onFinalize:()=>{"worklet";scheduleOnRN(de,!1)}}},[s,a,i,r,ee,L,_,M,u,c,E,T,H,j,ye,x,fe,ve,de,F,G,U,z,J,q,Q,Y,$,Z]),ke=useMemo(()=>Se("low"),[Se]),xe=useMemo(()=>Se("high"),[Se]),Ce=usePanGesture(ke),Ae=usePanGesture(xe),Ve=useCallback(e=>{if(s||L||O<=0)return;const t=clamp(e.nativeEvent.locationX,0,O),a=ae(t,O);a!==U.value&&(be(),U.value=a,F.value=withTiming(te(a,O),{duration:C.motion.duration.fast,easing:Easing.out(Easing.cubic)}),he(a,a))},[s,L,O,ae,te,he,be,F,U,C.motion.duration.fast]),De=useCallback(e=>{if(s)return;const t="increment"===e.nativeEvent.actionName?r:-r,n=r>0?Math.round(t*ee)/ee:t;if(L){const e=Math.round((U.value+n)*ee)/ee,t=clamp(e,a,z.value);t!==U.value&&(U.value=t,F.value=te(t,O),be(),he(t,z.value))}else{const e=Math.round((U.value+n)*ee)/ee,t=clamp(e,a,i);t!==U.value&&(U.value=t,F.value=te(t,O),be(),he(t,t))}},[s,r,ee,L,a,i,te,O,F,U,z,he,be]),je=D.thumbDiameter/2,Me=s?C.colors["surface-disabled"]:P,Te="inset"===l?{backgroundColor:Me,borderColor:C.colors.surface,borderWidth:Math.max(2,Math.round(.3*D.thumbDiameter)),...NO_SHADOW}:"minimal"===l?{backgroundColor:Me,borderWidth:0}:"bar"===l?{backgroundColor:"transparent",borderWidth:0,...NO_SHADOW}:{backgroundColor:C.colors.surface,borderColor:Me},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*j);return{opacity:t,transform:[{translateX:F.value-j},{scaleX:a/e}]}}return{opacity:t,transform:[{translateX:F.value+j-e},{scaleX:1}]}},[Z,s,L,G,F,j]),Re=useAnimatedStyle(()=>({transform:[{translateX:F.value-je},{scale:J.value}]}),[F,je,J]),He=useAnimatedStyle(()=>({transform:[{translateX:G.value-je},{scale:q.value}]}),[G,je,q]),Oe=useAnimatedStyle(()=>({opacity:Q.value}),[Q]),Ie=useAnimatedStyle(()=>({opacity:Y.value}),[Y]),clampDisplay=e=>clamp(e,a,i),Pe=clampDisplay(isPair(X)?Math.min(...X):X),Ne=clampDisplay(isPair(X)?Math.max(...X):X);return _jsx(View,{ref:e,style:[R.container,g],testID:x,accessibilityRole:"adjustable",accessibilityLabel:h,accessibilityState:{disabled:s},"aria-disabled":s,accessibilityValue:L?{min:a,max:i,now:Pe,text:fillText(A.text,{start:Pe,end:Ne})}:{min:a,max:i,now:Pe},accessibilityActions:[{name:"increment"},{name:"decrement"}],onAccessibilityAction:De,children:_jsx(Pressable,{onPress:Ve,disabled:s||L,style:R.trackTouch,testID:x?`${x}-track-press`:void 0,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:_jsxs(View,{style:R.trackWrap,onLayout:me,testID:x?`${x}-track`:void 0,children:[_jsxs(View,{style:R.trackClip,pointerEvents:"none",children:[_jsx(View,{style:[R.track,{backgroundColor:s?C.colors["surface-disabled"]:C.colors.border},p]}),_jsx(Animated.View,{style:[R.fill,{backgroundColor:s?C.colors["surface-disabled"]:P},f,Ee],testID:x?`${x}-fill`:void 0})]}),_jsx(GestureDetector,{gesture:Ce,children:_jsx(Animated.View,{style:[R.thumb,{width:D.thumbDiameter,height:D.thumbDiameter,borderRadius:je,...smoothCorners,opacity:s?.55:1},Te,v,Re],testID:x?`${x}-thumb`:void 0,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:u?_jsxs(Animated.View,{style:[R.bubbleWrap,Oe],pointerEvents:"none",children:[_jsx(View,{style:[R.bubble,{backgroundColor:P}],children:m?m(Pe):_jsx(Text,{variant:"caption",weight:"semibold",style:[{color:N},w],numberOfLines:1,children:d(Pe)})}),_jsx(View,{style:[R.bubbleCaret,{backgroundColor:P}]})]}):null})}),L?_jsx(GestureDetector,{gesture:Ae,children:_jsx(Animated.View,{style:[R.thumb,{width:D.thumbDiameter,height:D.thumbDiameter,borderRadius:je,...smoothCorners,opacity:s?.55:1},Te,v,He],accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",children:u?_jsxs(Animated.View,{style:[R.bubbleWrap,Ie],pointerEvents:"none",children:[_jsx(View,{style:[R.bubble,{backgroundColor:P}],children:m?m(Ne):_jsx(Text,{variant:"caption",weight:"semibold",style:[{color:N},w],numberOfLines:1,children:d(Ne)})}),_jsx(View,{style:[R.bubbleCaret,{backgroundColor:P}]})]}):null})}):null]})})})}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;