@webority/mobile-ui 0.146.2 → 0.148.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 (294) hide show
  1. package/dist/canvas-kit/kit.js +4527 -4326
  2. package/dist/canvas-kit/manifest.json +8 -1
  3. package/dist/canvas-kit/release.json +6 -6
  4. package/lib/commonjs/components/AppBar/AppBar.js +1 -1
  5. package/lib/commonjs/components/AuthedImage/authedImageCache.js +1 -1
  6. package/lib/commonjs/components/AuthedImage/imageStore.js +1 -1
  7. package/lib/commonjs/components/AuthedImage/imageStore.web.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/Carousel/Carousel.js +1 -1
  18. package/lib/commonjs/components/Checkbox/Checkbox.js +1 -1
  19. package/lib/commonjs/components/Confetti/Confetti.js +1 -1
  20. package/lib/commonjs/components/DatePicker/DatePicker.js +1 -1
  21. package/lib/commonjs/components/Drawer/Drawer.js +1 -1
  22. package/lib/commonjs/components/FieldBase/Chevron.js +1 -1
  23. package/lib/commonjs/components/FieldBase/FieldBase.js +1 -1
  24. package/lib/commonjs/components/FilePicker/FilePicker.js +1 -1
  25. package/lib/commonjs/components/FloatingActionButton/FloatingActionButton.js +1 -1
  26. package/lib/commonjs/components/FormField/FormField.js +1 -1
  27. package/lib/commonjs/components/Input/Input.js +1 -1
  28. package/lib/commonjs/components/ListItem/ListItem.js +1 -1
  29. package/lib/commonjs/components/LoaderOverlay/LoaderOverlay.js +1 -1
  30. package/lib/commonjs/components/Markdown/Markdown.js +1 -1
  31. package/lib/commonjs/components/Menu/MenuSurface.js +1 -1
  32. package/lib/commonjs/components/MessageList/MessageList.js +1 -1
  33. package/lib/commonjs/components/Modal/Modal.js +1 -1
  34. package/lib/commonjs/components/OTPInput/OTPInput.js +1 -1
  35. package/lib/commonjs/components/OptionSheet/OptionSheet.js +1 -1
  36. package/lib/commonjs/components/ProfilePicker/ProfilePicker.js +1 -1
  37. package/lib/commonjs/components/ProgressBar/ProgressBar.js +1 -1
  38. package/lib/commonjs/components/Radio/RadioDot.js +1 -1
  39. package/lib/commonjs/components/Rating/Rating.js +1 -1
  40. package/lib/commonjs/components/RichTextEditor/RichTextEditor.js +1 -1
  41. package/lib/commonjs/components/RichTextEditor/markdownActions.js +1 -1
  42. package/lib/commonjs/components/ScannerOverlay/ScannerOverlay.js +1 -1
  43. package/lib/commonjs/components/SegmentedControl/SegmentedControl.js +1 -1
  44. package/lib/commonjs/components/SignaturePad/SignaturePad.js +1 -1
  45. package/lib/commonjs/components/SignaturePad/signatureGeometry.js +1 -1
  46. package/lib/commonjs/components/SignaturePad/writePng.js +1 -1
  47. package/lib/commonjs/components/SignaturePad/writePng.web.js +1 -1
  48. package/lib/commonjs/components/Skeleton/SkeletonClock.js +1 -1
  49. package/lib/commonjs/components/Skeleton/SkeletonContent.js +1 -1
  50. package/lib/commonjs/components/Slider/valueText.js +1 -1
  51. package/lib/commonjs/components/Sparkline/Sparkline.js +1 -1
  52. package/lib/commonjs/components/Sparkline/geometry.js +1 -1
  53. package/lib/commonjs/components/Spinner/Spinner.js +1 -1
  54. package/lib/commonjs/components/Stepper/Stepper.js +1 -1
  55. package/lib/commonjs/components/Switch/Switch.js +1 -1
  56. package/lib/commonjs/components/Tabs/Tabs.js +1 -1
  57. package/lib/commonjs/components/TagInput/TagInput.js +1 -1
  58. package/lib/commonjs/components/Text/Text.js +1 -1
  59. package/lib/commonjs/components/Toast/Toast.js +1 -1
  60. package/lib/commonjs/components/Toast/ToastProvider.js +1 -1
  61. package/lib/commonjs/components/Tooltip/Tooltip.js +1 -1
  62. package/lib/commonjs/components/Tour/Tour.js +1 -1
  63. package/lib/commonjs/components/WheelPicker/Wheel.js +1 -1
  64. package/lib/commonjs/form/path.js +1 -1
  65. package/lib/commonjs/hooks/useDragToDismiss.js +1 -1
  66. package/lib/commonjs/hooks/usePressAnimation.js +1 -1
  67. package/lib/commonjs/index.js +1 -1
  68. package/lib/commonjs/network/NetworkStatusBanner.js +1 -1
  69. package/lib/commonjs/theme/Gradient.js +1 -1
  70. package/lib/commonjs/theme/animatedValue.js +1 -1
  71. package/lib/commonjs/theme/componentSizes.js +1 -1
  72. package/lib/commonjs/theme/merge.js +1 -1
  73. package/lib/commonjs/theme/toneInk.js +1 -1
  74. package/lib/commonjs/utils/color.js +1 -1
  75. package/lib/commonjs/utils/nativeDriver.js +1 -0
  76. package/lib/module/components/AppBar/AppBar.js +1 -1
  77. package/lib/module/components/AuthedImage/authedImageCache.js +1 -1
  78. package/lib/module/components/AuthedImage/imageStore.js +1 -1
  79. package/lib/module/components/AuthedImage/imageStore.web.js +1 -1
  80. package/lib/module/components/Avatar/Avatar.js +1 -1
  81. package/lib/module/components/Badge/Badge.js +1 -1
  82. package/lib/module/components/Banner/Banner.js +1 -1
  83. package/lib/module/components/BarChart/BarChart.js +1 -1
  84. package/lib/module/components/BottomNavigation/BottomNavigation.js +1 -1
  85. package/lib/module/components/BottomSheet/BottomSheet.js +1 -1
  86. package/lib/module/components/Box/Box.js +1 -1
  87. package/lib/module/components/Button/Button.js +1 -1
  88. package/lib/module/components/Calendar/Calendar.js +1 -1
  89. package/lib/module/components/Carousel/Carousel.js +1 -1
  90. package/lib/module/components/Checkbox/Checkbox.js +1 -1
  91. package/lib/module/components/Confetti/Confetti.js +1 -1
  92. package/lib/module/components/DatePicker/DatePicker.js +1 -1
  93. package/lib/module/components/Drawer/Drawer.js +1 -1
  94. package/lib/module/components/FieldBase/Chevron.js +1 -1
  95. package/lib/module/components/FieldBase/FieldBase.js +1 -1
  96. package/lib/module/components/FilePicker/FilePicker.js +1 -1
  97. package/lib/module/components/FloatingActionButton/FloatingActionButton.js +1 -1
  98. package/lib/module/components/FormField/FormField.js +1 -1
  99. package/lib/module/components/Input/Input.js +1 -1
  100. package/lib/module/components/ListItem/ListItem.js +1 -1
  101. package/lib/module/components/LoaderOverlay/LoaderOverlay.js +1 -1
  102. package/lib/module/components/Markdown/Markdown.js +1 -1
  103. package/lib/module/components/Menu/MenuSurface.js +1 -1
  104. package/lib/module/components/MessageList/MessageList.js +1 -1
  105. package/lib/module/components/Modal/Modal.js +1 -1
  106. package/lib/module/components/OTPInput/OTPInput.js +1 -1
  107. package/lib/module/components/OptionSheet/OptionSheet.js +1 -1
  108. package/lib/module/components/ProfilePicker/ProfilePicker.js +1 -1
  109. package/lib/module/components/ProgressBar/ProgressBar.js +1 -1
  110. package/lib/module/components/Radio/RadioDot.js +1 -1
  111. package/lib/module/components/Rating/Rating.js +1 -1
  112. package/lib/module/components/RichTextEditor/RichTextEditor.js +1 -1
  113. package/lib/module/components/RichTextEditor/markdownActions.js +1 -1
  114. package/lib/module/components/ScannerOverlay/ScannerOverlay.js +1 -1
  115. package/lib/module/components/SegmentedControl/SegmentedControl.js +1 -1
  116. package/lib/module/components/SignaturePad/SignaturePad.js +1 -1
  117. package/lib/module/components/SignaturePad/signatureGeometry.js +1 -1
  118. package/lib/module/components/SignaturePad/writePng.js +1 -1
  119. package/lib/module/components/SignaturePad/writePng.web.js +1 -1
  120. package/lib/module/components/Skeleton/SkeletonClock.js +1 -1
  121. package/lib/module/components/Skeleton/SkeletonContent.js +1 -1
  122. package/lib/module/components/Slider/valueText.js +1 -1
  123. package/lib/module/components/Sparkline/Sparkline.js +1 -1
  124. package/lib/module/components/Sparkline/geometry.js +1 -1
  125. package/lib/module/components/Spinner/Spinner.js +1 -1
  126. package/lib/module/components/Stepper/Stepper.js +1 -1
  127. package/lib/module/components/Switch/Switch.js +1 -1
  128. package/lib/module/components/Tabs/Tabs.js +1 -1
  129. package/lib/module/components/TagInput/TagInput.js +1 -1
  130. package/lib/module/components/Text/Text.js +1 -1
  131. package/lib/module/components/Toast/Toast.js +1 -1
  132. package/lib/module/components/Toast/ToastProvider.js +1 -1
  133. package/lib/module/components/Tooltip/Tooltip.js +1 -1
  134. package/lib/module/components/Tour/Tour.js +1 -1
  135. package/lib/module/components/WheelPicker/Wheel.js +1 -1
  136. package/lib/module/form/path.js +1 -1
  137. package/lib/module/hooks/useDragToDismiss.js +1 -1
  138. package/lib/module/hooks/usePressAnimation.js +1 -1
  139. package/lib/module/index.js +1 -1
  140. package/lib/module/network/NetworkStatusBanner.js +1 -1
  141. package/lib/module/theme/Gradient.js +1 -1
  142. package/lib/module/theme/animatedValue.js +1 -1
  143. package/lib/module/theme/componentSizes.js +1 -1
  144. package/lib/module/theme/merge.js +1 -1
  145. package/lib/module/theme/toneInk.js +1 -1
  146. package/lib/module/utils/color.js +1 -1
  147. package/lib/module/utils/nativeDriver.js +1 -0
  148. package/lib/typescript/commonjs/canvasKit/index.d.ts +15 -6
  149. package/lib/typescript/commonjs/components/AmountSlider/AmountSlider.d.ts +3 -2
  150. package/lib/typescript/commonjs/components/AppBar/AppBar.d.ts +2 -2
  151. package/lib/typescript/commonjs/components/AuthedImage/imageStore.d.ts +1 -1
  152. package/lib/typescript/commonjs/components/AuthedImage/imageStore.web.d.ts +1 -1
  153. package/lib/typescript/commonjs/components/Avatar/Avatar.d.ts +2 -2
  154. package/lib/typescript/commonjs/components/Badge/Badge.d.ts +2 -2
  155. package/lib/typescript/commonjs/components/Banner/Banner.d.ts +2 -2
  156. package/lib/typescript/commonjs/components/BarChart/BarChart.d.ts +2 -2
  157. package/lib/typescript/commonjs/components/BottomNavigation/BottomNavigation.d.ts +2 -2
  158. package/lib/typescript/commonjs/components/BottomSheet/BottomSheet.d.ts +2 -3
  159. package/lib/typescript/commonjs/components/Box/Box.d.ts +4 -4
  160. package/lib/typescript/commonjs/components/Button/Button.d.ts +3 -2
  161. package/lib/typescript/commonjs/components/Calendar/Calendar.d.ts +3 -2
  162. package/lib/typescript/commonjs/components/Calendar/calendarStyles.d.ts +25 -116
  163. package/lib/typescript/commonjs/components/Card/Card.d.ts +2 -2
  164. package/lib/typescript/commonjs/components/Checkbox/Checkbox.d.ts +2 -2
  165. package/lib/typescript/commonjs/components/Chip/Chip.d.ts +2 -2
  166. package/lib/typescript/commonjs/components/ChoiceGroup/ChoiceGroup.d.ts +2 -2
  167. package/lib/typescript/commonjs/components/Composer/Composer.d.ts +2 -3
  168. package/lib/typescript/commonjs/components/DateRangePicker/DateRangePicker.d.ts +3 -2
  169. package/lib/typescript/commonjs/components/DecimalInput/DecimalInput.d.ts +3 -2
  170. package/lib/typescript/commonjs/components/Divider/Divider.d.ts +3 -2
  171. package/lib/typescript/commonjs/components/EmptyState/EmptyState.d.ts +2 -2
  172. package/lib/typescript/commonjs/components/FileViewer/useFileViewerZoom.d.ts +14 -22
  173. package/lib/typescript/commonjs/components/FilterChipRow/FilterChipRow.d.ts +3 -2
  174. package/lib/typescript/commonjs/components/FloatingActionButton/FloatingActionButton.d.ts +2 -2
  175. package/lib/typescript/commonjs/components/FormField/FormField.d.ts +2 -2
  176. package/lib/typescript/commonjs/components/IconBadge/IconBadge.d.ts +3 -2
  177. package/lib/typescript/commonjs/components/IconButton/IconButton.d.ts +3 -2
  178. package/lib/typescript/commonjs/components/InlineSelect/InlineSelect.d.ts +2 -2
  179. package/lib/typescript/commonjs/components/Input/Input.d.ts +2 -3
  180. package/lib/typescript/commonjs/components/KeyboardAwareScrollView/KeyboardAwareScrollView.d.ts +1 -1
  181. package/lib/typescript/commonjs/components/ListItem/ListItem.d.ts +4 -3
  182. package/lib/typescript/commonjs/components/Markdown/Markdown.d.ts +3 -1
  183. package/lib/typescript/commonjs/components/Menu/useContextMenu.d.ts +2 -2
  184. package/lib/typescript/commonjs/components/Modal/Modal.d.ts +3 -3
  185. package/lib/typescript/commonjs/components/PickerTrigger/PickerTrigger.d.ts +4 -2
  186. package/lib/typescript/commonjs/components/ProfileCompletion/ProfileCompletion.d.ts +2 -2
  187. package/lib/typescript/commonjs/components/ProfilePicker/ProfilePicker.d.ts +2 -2
  188. package/lib/typescript/commonjs/components/ProgressBar/ProgressBar.d.ts +4 -4
  189. package/lib/typescript/commonjs/components/ProgressRing/ProgressRing.d.ts +2 -2
  190. package/lib/typescript/commonjs/components/Radio/Radio.d.ts +3 -3
  191. package/lib/typescript/commonjs/components/Rating/Rating.d.ts +2 -2
  192. package/lib/typescript/commonjs/components/RichTextEditor/RichTextEditor.d.ts +2 -2
  193. package/lib/typescript/commonjs/components/ScannerOverlay/ScannerOverlay.d.ts +2 -2
  194. package/lib/typescript/commonjs/components/Screen/Screen.d.ts +2 -2
  195. package/lib/typescript/commonjs/components/SearchBar/SearchBar.d.ts +3 -3
  196. package/lib/typescript/commonjs/components/SegmentedControl/SegmentedControl.d.ts +3 -3
  197. package/lib/typescript/commonjs/components/Select/Select.d.ts +2 -2
  198. package/lib/typescript/commonjs/components/SignaturePad/writePng.d.ts +1 -1
  199. package/lib/typescript/commonjs/components/SignaturePad/writePng.web.d.ts +1 -1
  200. package/lib/typescript/commonjs/components/SlideToConfirm/SlideToConfirm.d.ts +2 -2
  201. package/lib/typescript/commonjs/components/Slider/Slider.d.ts +2 -2
  202. package/lib/typescript/commonjs/components/SliderField/SliderField.d.ts +2 -2
  203. package/lib/typescript/commonjs/components/Sparkline/Sparkline.d.ts +3 -2
  204. package/lib/typescript/commonjs/components/Spinner/Spinner.d.ts +2 -2
  205. package/lib/typescript/commonjs/components/SquircleView/SquircleView.d.ts +3 -2
  206. package/lib/typescript/commonjs/components/StatTile/StatTile.d.ts +3 -3
  207. package/lib/typescript/commonjs/components/StatusBadge/StatusBadge.d.ts +2 -2
  208. package/lib/typescript/commonjs/components/Stepper/Stepper.d.ts +2 -2
  209. package/lib/typescript/commonjs/components/Switch/Switch.d.ts +3 -3
  210. package/lib/typescript/commonjs/components/Tabs/Tabs.d.ts +3 -3
  211. package/lib/typescript/commonjs/components/TagInput/TagInput.d.ts +3 -2
  212. package/lib/typescript/commonjs/components/Text/Text.d.ts +2 -2
  213. package/lib/typescript/commonjs/components/Tooltip/RichTooltipBody.d.ts +3 -3
  214. package/lib/typescript/commonjs/components/Tour/Tour.d.ts +2 -2
  215. package/lib/typescript/commonjs/hooks/useFieldErrorScroll.d.ts +5 -5
  216. package/lib/typescript/commonjs/index.d.ts +1 -1
  217. package/lib/typescript/commonjs/theme/Gradient.d.ts +5 -1
  218. package/lib/typescript/commonjs/theme/animatedValue.d.ts +1 -1
  219. package/lib/typescript/commonjs/theme/makeStyles.d.ts +4 -2
  220. package/lib/typescript/commonjs/utils/nativeDriver.d.ts +2 -0
  221. package/lib/typescript/module/canvasKit/index.d.ts +15 -6
  222. package/lib/typescript/module/components/AmountSlider/AmountSlider.d.ts +3 -2
  223. package/lib/typescript/module/components/AppBar/AppBar.d.ts +2 -2
  224. package/lib/typescript/module/components/AuthedImage/imageStore.d.ts +1 -1
  225. package/lib/typescript/module/components/AuthedImage/imageStore.web.d.ts +1 -1
  226. package/lib/typescript/module/components/Avatar/Avatar.d.ts +2 -2
  227. package/lib/typescript/module/components/Badge/Badge.d.ts +2 -2
  228. package/lib/typescript/module/components/Banner/Banner.d.ts +2 -2
  229. package/lib/typescript/module/components/BarChart/BarChart.d.ts +2 -2
  230. package/lib/typescript/module/components/BottomNavigation/BottomNavigation.d.ts +2 -2
  231. package/lib/typescript/module/components/BottomSheet/BottomSheet.d.ts +2 -3
  232. package/lib/typescript/module/components/Box/Box.d.ts +4 -4
  233. package/lib/typescript/module/components/Button/Button.d.ts +3 -2
  234. package/lib/typescript/module/components/Calendar/Calendar.d.ts +3 -2
  235. package/lib/typescript/module/components/Calendar/calendarStyles.d.ts +25 -116
  236. package/lib/typescript/module/components/Card/Card.d.ts +2 -2
  237. package/lib/typescript/module/components/Checkbox/Checkbox.d.ts +2 -2
  238. package/lib/typescript/module/components/Chip/Chip.d.ts +2 -2
  239. package/lib/typescript/module/components/ChoiceGroup/ChoiceGroup.d.ts +2 -2
  240. package/lib/typescript/module/components/Composer/Composer.d.ts +2 -3
  241. package/lib/typescript/module/components/DateRangePicker/DateRangePicker.d.ts +3 -2
  242. package/lib/typescript/module/components/DecimalInput/DecimalInput.d.ts +3 -2
  243. package/lib/typescript/module/components/Divider/Divider.d.ts +3 -2
  244. package/lib/typescript/module/components/EmptyState/EmptyState.d.ts +2 -2
  245. package/lib/typescript/module/components/FileViewer/useFileViewerZoom.d.ts +14 -22
  246. package/lib/typescript/module/components/FilterChipRow/FilterChipRow.d.ts +3 -2
  247. package/lib/typescript/module/components/FloatingActionButton/FloatingActionButton.d.ts +2 -2
  248. package/lib/typescript/module/components/FormField/FormField.d.ts +2 -2
  249. package/lib/typescript/module/components/IconBadge/IconBadge.d.ts +3 -2
  250. package/lib/typescript/module/components/IconButton/IconButton.d.ts +3 -2
  251. package/lib/typescript/module/components/InlineSelect/InlineSelect.d.ts +2 -2
  252. package/lib/typescript/module/components/Input/Input.d.ts +2 -3
  253. package/lib/typescript/module/components/KeyboardAwareScrollView/KeyboardAwareScrollView.d.ts +1 -1
  254. package/lib/typescript/module/components/ListItem/ListItem.d.ts +4 -3
  255. package/lib/typescript/module/components/Markdown/Markdown.d.ts +3 -1
  256. package/lib/typescript/module/components/Menu/useContextMenu.d.ts +2 -2
  257. package/lib/typescript/module/components/Modal/Modal.d.ts +3 -3
  258. package/lib/typescript/module/components/PickerTrigger/PickerTrigger.d.ts +4 -2
  259. package/lib/typescript/module/components/ProfileCompletion/ProfileCompletion.d.ts +2 -2
  260. package/lib/typescript/module/components/ProfilePicker/ProfilePicker.d.ts +2 -2
  261. package/lib/typescript/module/components/ProgressBar/ProgressBar.d.ts +4 -4
  262. package/lib/typescript/module/components/ProgressRing/ProgressRing.d.ts +2 -2
  263. package/lib/typescript/module/components/Radio/Radio.d.ts +3 -3
  264. package/lib/typescript/module/components/Rating/Rating.d.ts +2 -2
  265. package/lib/typescript/module/components/RichTextEditor/RichTextEditor.d.ts +2 -2
  266. package/lib/typescript/module/components/ScannerOverlay/ScannerOverlay.d.ts +2 -2
  267. package/lib/typescript/module/components/Screen/Screen.d.ts +2 -2
  268. package/lib/typescript/module/components/SearchBar/SearchBar.d.ts +3 -3
  269. package/lib/typescript/module/components/SegmentedControl/SegmentedControl.d.ts +3 -3
  270. package/lib/typescript/module/components/Select/Select.d.ts +2 -2
  271. package/lib/typescript/module/components/SignaturePad/writePng.d.ts +1 -1
  272. package/lib/typescript/module/components/SignaturePad/writePng.web.d.ts +1 -1
  273. package/lib/typescript/module/components/SlideToConfirm/SlideToConfirm.d.ts +2 -2
  274. package/lib/typescript/module/components/Slider/Slider.d.ts +2 -2
  275. package/lib/typescript/module/components/SliderField/SliderField.d.ts +2 -2
  276. package/lib/typescript/module/components/Sparkline/Sparkline.d.ts +3 -2
  277. package/lib/typescript/module/components/Spinner/Spinner.d.ts +2 -2
  278. package/lib/typescript/module/components/SquircleView/SquircleView.d.ts +3 -2
  279. package/lib/typescript/module/components/StatTile/StatTile.d.ts +3 -3
  280. package/lib/typescript/module/components/StatusBadge/StatusBadge.d.ts +2 -2
  281. package/lib/typescript/module/components/Stepper/Stepper.d.ts +2 -2
  282. package/lib/typescript/module/components/Switch/Switch.d.ts +3 -3
  283. package/lib/typescript/module/components/Tabs/Tabs.d.ts +3 -3
  284. package/lib/typescript/module/components/TagInput/TagInput.d.ts +3 -2
  285. package/lib/typescript/module/components/Text/Text.d.ts +2 -2
  286. package/lib/typescript/module/components/Tooltip/RichTooltipBody.d.ts +3 -3
  287. package/lib/typescript/module/components/Tour/Tour.d.ts +2 -2
  288. package/lib/typescript/module/hooks/useFieldErrorScroll.d.ts +5 -5
  289. package/lib/typescript/module/index.d.ts +1 -1
  290. package/lib/typescript/module/theme/Gradient.d.ts +5 -1
  291. package/lib/typescript/module/theme/animatedValue.d.ts +1 -1
  292. package/lib/typescript/module/theme/makeStyles.d.ts +4 -2
  293. package/lib/typescript/module/utils/nativeDriver.d.ts +2 -0
  294. package/package.json +29 -29
@@ -1 +1 @@
1
- "use strict";import{useCallback,useEffect,useMemo,useRef,useState}from"react";import{Animated,Dimensions,FlatList,Pressable,StatusBar,StyleSheet,TextInput,View}from"react-native";import{Gesture,GestureDetector,GestureHandlerRootView}from"react-native-gesture-handler";import{useKeyboardState}from"react-native-keyboard-controller";import{useSafeAreaInsets}from"react-native-safe-area-context";import{useDragToDismiss}from"../../hooks/useDragToDismiss.js";import{createAnimatedValue,useTheme}from"../../theme/index.js";import{smoothCorners}from"../../utils/corners.js";import{hitSlopMarker}from"../../utils/hitSlop.js";import{defaultIcons}from"../AppIcon/defaultIcons.js";import{Modal}from"../Modal/index.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";const SEARCH_ICON_SIZE=18;export const DEFAULT_OPTION_SHEET_LABELS=Object.freeze({searchPlaceholder:"Search…",empty:"No options",done:"Done",closePicker:"Close picker",fallbackName:"Options",searchOptions:"Search options",clearSearch:"Clear search",jumpToLetter:"Jump to letter",jumpTo:e=>`Jump to ${e}`});const selectOptionLabel=e=>e.label,selectOptionValue=e=>e.value,selectOptionDescription=e=>e.description,selectOptionDisabled=e=>!0===e.disabled,selectOptionIcon=e=>e.icon,hostStyle=StyleSheet.create({host:{padding:0,paddingTop:0,paddingHorizontal:0,paddingBottom:0,backgroundColor:"transparent",borderTopLeftRadius:0,borderTopRightRadius:0,shadowOpacity:0,elevation:0}}).host;function OptionSheetPanel(e){const{onClose:t,title:o,options:s,sections:i,renderSectionHeader:r,renderOption:l,alphabetIndex:n=!1,labels:a,getOptionLabel:c,getOptionValue:d,getOptionDescription:p,isOptionDisabled:u,getOptionIcon:h,destructiveOf:m,value:b,onChange:g,multi:x=!1,searchable:y=!1,searchSelectionColor:f,accessibilityLabel:S,optionStyle:T,selectedOptionStyle:j,optionTextStyle:w,selectedOptionTextStyle:C,testID:_}=e,k=c??selectOptionLabel,L=d??selectOptionValue,I=p??selectOptionDescription,O=u??selectOptionDisabled,R=h??selectOptionIcon,V=useTheme(),D=useSafeAreaInsets(),v=useMemo(()=>buildStyles(V),[V]),[P,H]=useState(""),M=Dimensions.get("window").height,B=Math.round(.7*M),A=useRef(createAnimatedValue(0)).current,{handleGesture:E,opacity:F}=useDragToDismiss({drag:A,travel:B,onDismiss:t}),z=useMemo(()=>Gesture.Native(),[]),W=useKeyboardState(e=>e.height),N=Math.max(0,Math.round(W)),G=Math.max(D.top,StatusBar.currentHeight??0)+V.space.sm,U=N>0,$=U?Math.max(0,Math.min(B,M-N-G)):B,J=useMemo(()=>{const e=y?P.trim().toLowerCase():"",matches=t=>0===e.length||k(t).toLowerCase().includes(e)||(I(t)??"").toLowerCase().includes(e);if(!i)return s.filter(matches).map(e=>({kind:"option",option:e}));const t=[];return i.forEach((e,o)=>{const s=e.options.filter(matches);if(0!==s.length){t.push({kind:"header",title:e.title});for(const e of s)t.push({kind:"option",option:e,section:o})}}),t},[y,P,s,i,k,I]),K=useCallback(()=>{t()},[t]),Y=useRef(null),Z=useMemo(()=>{const e=new Map;if(!n)return e;let t=0;if(i)for(let e=J.length-1;e>=0;e-=1)if("header"===J[e].kind){t=e+1;break}for(let o=t;o<J.length;o+=1){const t=J[o];if("option"!==t.kind)continue;const s=k(t.option).trim().charAt(0).toUpperCase(),i=/^[A-Z]$/.test(s)?s:"#";e.has(i)||e.set(i,o)}return e},[n,J,i,k]),Q=n&&Z.size>0&&0===P.trim().length,X=useMemo(()=>[..."ABCDEFGHIJKLMNOPQRSTUVWXYZ",...Z.has("#")?["#"]:[]],[Z]),q=useCallback(e=>{const t=Z.get(e);void 0!==t&&Y.current?.scrollToIndex({index:t,animated:!0,viewPosition:0})},[Z]),ee=useRef(null),te=useCallback(()=>{null!==ee.current&&(clearTimeout(ee.current),ee.current=null)},[]),oe=useCallback(e=>{Y.current?.scrollToOffset({offset:e.averageItemLength*e.index,animated:!1}),te(),ee.current=setTimeout(()=>{ee.current=null,Y.current?.scrollToIndex({index:e.index,animated:!0,viewPosition:0})},50)},[te]);useEffect(()=>te,[te]);return _jsx(GestureHandlerRootView,{style:v.gestureRoot,children:_jsxs(Animated.View,{testID:_,accessibilityViewIsModal:!0,accessibilityLabel:S??o??a.fallbackName,style:[v.sheet,{maxHeight:$,marginBottom:N,paddingBottom:U?V.space.lg:D.bottom+V.space.lg,backgroundColor:V.colors.surface,borderTopLeftRadius:V.radius.xl,borderTopRightRadius:V.radius.xl,...smoothCorners,opacity:F,transform:[{translateY:A}],...V.shadow.modal}],children:[_jsx(GestureDetector,{gesture:E,children:_jsxs(View,{children:[_jsx(View,{style:v.sheetHandleRow,children:_jsx(View,{style:[v.sheetHandle,{backgroundColor:V.colors.border}]})}),o?_jsx(Text,{variant:"title",style:[v.sheetTitle,{paddingHorizontal:V.space.lg,marginBottom:V.space.sm}],children:o}):null]})}),y?_jsx(View,{style:[v.searchWrap,{marginHorizontal:V.space.lg,marginBottom:V.space.sm}],children:_jsxs(View,{style:[v.searchBox,{backgroundColor:V.colors["bg-subtle"],borderColor:V.colors.border,borderRadius:V.radius.md,...smoothCorners,paddingHorizontal:V.space.md,gap:V.space.sm}],children:[(V.settings.icons.search??defaultIcons.search)({size:18,color:V.colors["text-subtle"]}),_jsx(TextInput,{value:P,onChangeText:H,placeholder:a.searchPlaceholder,placeholderTextColor:V.colors["text-subtle"],selectionColor:f??V.colors["focus-ring"],accessibilityLabel:a.searchOptions,style:[v.searchInput,{color:V.colors["text-body"],fontSize:V.text.base.size,paddingVertical:V.space.sm}]}),P.length>0?_jsx(Pressable,{onPress:()=>H(""),hitSlop:8,...hitSlopMarker(8),accessibilityRole:"button",accessibilityLabel:a.clearSearch,children:(V.settings.icons.close??defaultIcons.close)({size:18,color:V.colors["text-muted"]})}):null]})}):null,_jsxs(View,{style:[v.listWrap,Q?v.listRow:null],children:[_jsx(GestureDetector,{gesture:z,children:_jsx(FlatList,{ref:Y,data:J,keyExtractor:e=>"header"===e.kind?`h:${e.title}`:`o:${e.section??""}:${String(L(e.option))}`,renderItem:({item:e,index:t})=>{if("header"===e.kind)return _jsx(View,{accessible:!0,accessibilityRole:"header",style:[v.sectionHeader,{paddingHorizontal:V.space.lg,paddingTop:V.space.md}],children:r?r(e.title):_jsx(Text,{variant:"caption",weight:"semibold",color:"tertiary",style:v.sectionTitle,children:e.title.toUpperCase()})});const o=e.option,s=k(o),i=L(o),n=I(o),a=R(o),c=(d=i,Array.isArray(b)?b.some(e=>String(e)===String(d)):null!=b&&String(b)===String(d));var d;const p=O(o),u=m?.(o)??!1;return _jsxs(Pressable,{onPress:()=>g(i,o),disabled:p,android_ripple:{color:V.colors["surface-pressed"],borderless:!1},accessibilityRole:"button",accessibilityLabel:s,accessibilityState:{selected:c,disabled:p},"aria-selected":c,"aria-disabled":p,style:({pressed:e})=>[v.optionRow,{backgroundColor:c?V.colors["surface-selected"]:e?V.colors["surface-pressed"]:"transparent",opacity:p?.5:1,paddingHorizontal:V.space.lg,paddingVertical:V.space.md},T,c?j:null],children:[l?_jsx(View,{style:v.optionTextWrap,children:l({option:o,selected:c,disabled:p,index:t})}):_jsxs(_Fragment,{children:[a?_jsx(View,{style:v.optionIcon,children:a}):null,_jsxs(View,{style:v.optionTextWrap,children:[_jsx(Text,{variant:"body",weight:c?"semibold":"medium",color:u?"danger":c?"brand":void 0,style:[v.optionLabel,w,c?C:null],children:s}),n?_jsx(Text,{variant:"bodySmall",color:"tertiary",numberOfLines:2,style:v.optionDescription,children:n}):null]})]}),x?_jsx(View,{style:[v.checkbox,{borderColor:c?V.colors.primary:V.colors.border,backgroundColor:c?V.colors.primary:"transparent"}],children:c?_jsx(View,{style:v.checkboxTick}):null}):c?"icon"===V.settings.components["option-sheet"]?.selectedMarker?_jsx(View,{style:v.singleSelectedIcon,children:(V.settings.icons.selectedTick??defaultIcons.selectedTick)({size:20,color:V.colors.primary})}):_jsx(View,{style:[v.singleSelectedDot,{backgroundColor:V.colors.primary}]}):null]})},onScrollToIndexFailed:oe,overScrollMode:"never",bounces:!1,keyboardShouldPersistTaps:"handled",showsVerticalScrollIndicator:!Q,style:Q?v.listBesideRail:null,ListEmptyComponent:_jsx(Text,{variant:"bodySmall",color:"tertiary",align:"center",style:{paddingVertical:V.space.xl},children:a.empty})})}),Q?_jsx(View,{style:[v.rail,{paddingRight:V.space.xs}],accessibilityRole:"list",accessibilityLabel:a.jumpToLetter,testID:"option-sheet-alphabet",children:X.map(e=>{const t=Z.has(e);return _jsx(Pressable,{onPress:()=>q(e),disabled:!t,hitSlop:{left:8,right:8},...hitSlopMarker({left:8,right:8}),accessibilityRole:"button",accessibilityLabel:a.jumpTo(e),accessibilityState:{disabled:!t},"aria-disabled":!t,style:v.railLetter,children:_jsx(Text,{variant:"caption",weight:"semibold",color:t?"brand":"tertiary",style:[v.railLetterText,{opacity:t?1:.45}],children:e})},e)})}):null]}),x?_jsx(View,{style:[v.sheetFooter,{borderTopColor:V.colors["border-subtle"],paddingHorizontal:V.space.lg,paddingVertical:V.space.md}],children:_jsx(Pressable,{onPress:K,accessibilityRole:"button",accessibilityLabel:a.done,style:({pressed:e})=>[v.doneButton,{backgroundColor:e?V.colors["primary-pressed"]:V.colors.primary,borderRadius:V.radius.md,...smoothCorners,paddingVertical:V.space.sm,paddingHorizontal:V.space.lg}],children:_jsx(Text,{variant:"body",weight:"semibold",style:{color:V.colors["on-primary"]},children:a.done})})}):null]})})}export function OptionSheet(e){const{open:t,onOpenChange:o,onAfterClose:s,labels:i,onClose:r,haptic:l,...n}=e,a=useMemo(()=>({...DEFAULT_OPTION_SHEET_LABELS,...i}),[i]),c=useRef(o);c.current=o;const d=useRef(!1);return useEffect(()=>{d.current!==t&&(d.current=t,c.current?.(t))},[t]),_jsx(Modal,{open:t,onClose:r,presentation:"bottom",onDismissed:s,haptic:l,contentStyle:hostStyle,labels:{close:a.closePicker},accessibilityLabel:n.accessibilityLabel??n.title??a.fallbackName,children:_jsx(OptionSheetPanel,{...n,onClose:r,labels:a})})}OptionSheet.displayName="OptionSheet";const buildStyles=e=>StyleSheet.create({gestureRoot:{width:"100%"},sheet:{paddingBottom:e.space.lg,overflow:"hidden"},sheetHandleRow:{alignItems:"center",paddingTop:e.space.sm,paddingBottom:e.space.sm},sheetHandle:{width:36,height:4,borderRadius:e.radius.pill,...smoothCorners},sheetTitle:{includeFontPadding:!1},searchWrap:{width:"auto"},searchBox:{flexDirection:"row",alignItems:"center",borderWidth:1},searchInput:{flex:1,includeFontPadding:!1},optionRow:{flexDirection:"row",alignItems:"center"},sectionHeader:{paddingBottom:e.space.xs},listWrap:{flexShrink:1},listRow:{flexDirection:"row"},listBesideRail:{flex:1},rail:{justifyContent:"space-between",alignItems:"center",alignSelf:"stretch",paddingVertical:e.space.xs},railLetter:{paddingHorizontal:e.space.xs,minHeight:14,justifyContent:"center"},railLetterText:{includeFontPadding:!1,lineHeight:14},sectionTitle:{includeFontPadding:!1,letterSpacing:.6},optionIcon:{marginRight:e.space.md},optionTextWrap:{flex:1},optionLabel:{includeFontPadding:!1},optionDescription:{includeFontPadding:!1,marginTop:e.space.xxs},checkbox:{width:22,height:22,borderRadius:e.radius.sm,...smoothCorners,borderWidth:2,alignItems:"center",justifyContent:"center",marginLeft:e.space.md},checkboxTick:{width:10,height:6,borderLeftWidth:2,borderBottomWidth:2,borderColor:e.colors["on-primary"],transform:[{rotate:"-45deg"},{translateY:-1}]},singleSelectedDot:{width:8,height:8,borderRadius:e.radius.pill,...smoothCorners,marginLeft:e.space.md},singleSelectedIcon:{marginLeft:e.space.md},sheetFooter:{borderTopWidth:StyleSheet.hairlineWidth,alignItems:"flex-end"},doneButton:{alignSelf:"flex-end"}});export default OptionSheet;
1
+ "use strict";import{useCallback,useEffect,useMemo,useRef,useState}from"react";import{Animated,Dimensions,FlatList,Pressable,StatusBar,StyleSheet,TextInput,View}from"react-native";import{Gesture,GestureDetector,GestureHandlerRootView}from"react-native-gesture-handler";import{useKeyboardState}from"react-native-keyboard-controller";import{useSafeAreaInsets}from"react-native-safe-area-context";import{useDragToDismiss}from"../../hooks/useDragToDismiss.js";import{createAnimatedValue,useTheme}from"../../theme/index.js";import{smoothCorners}from"../../utils/corners.js";import{hitSlopMarker}from"../../utils/hitSlop.js";import{defaultIcons}from"../AppIcon/defaultIcons.js";import{Modal}from"../Modal/index.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";const SEARCH_ICON_SIZE=18;export const DEFAULT_OPTION_SHEET_LABELS=Object.freeze({searchPlaceholder:"Search…",empty:"No options",done:"Done",closePicker:"Close picker",fallbackName:"Options",searchOptions:"Search options",clearSearch:"Clear search",jumpToLetter:"Jump to letter",jumpTo:e=>`Jump to ${e}`});const selectOptionLabel=e=>e.label,selectOptionValue=e=>e.value,selectOptionDescription=e=>e.description,selectOptionDisabled=e=>!0===e.disabled,selectOptionIcon=e=>e.icon,hostStyle=StyleSheet.create({host:{padding:0,paddingTop:0,paddingHorizontal:0,paddingBottom:0,backgroundColor:"transparent",borderTopLeftRadius:0,borderTopRightRadius:0,shadowOpacity:0,elevation:0}}).host;function OptionSheetPanel(e){const{onClose:t,title:o,options:s,sections:i,renderSectionHeader:r,renderOption:l,alphabetIndex:n=!1,labels:a,getOptionLabel:c,getOptionValue:d,getOptionDescription:p,isOptionDisabled:u,getOptionIcon:h,destructiveOf:m,value:b,onChange:g,multi:x=!1,searchable:y=!1,searchSelectionColor:f,accessibilityLabel:S,optionStyle:T,selectedOptionStyle:j,optionTextStyle:w,selectedOptionTextStyle:C,testID:_}=e,k=c??selectOptionLabel,L=d??selectOptionValue,I=p??selectOptionDescription,O=u??selectOptionDisabled,R=h??selectOptionIcon,V=useTheme(),D=useSafeAreaInsets(),v=useMemo(()=>buildStyles(V),[V]),[P,H]=useState(""),M=Dimensions.get("window").height,B=Math.round(.7*M),A=useRef(createAnimatedValue(0)).current,{handleGesture:E,opacity:F}=useDragToDismiss({drag:A,travel:B,onDismiss:t}),z=useMemo(()=>Gesture.Native(),[]),W=useKeyboardState(e=>e.height),N=Math.max(0,Math.round(W)),G=Math.max(D.top,StatusBar.currentHeight??0)+V.space.sm,U=N>0,$=U?Math.max(0,Math.min(B,M-N-G)):B,J=useMemo(()=>{const e=y?P.trim().toLowerCase():"",matches=t=>0===e.length||k(t).toLowerCase().includes(e)||(I(t)??"").toLowerCase().includes(e);if(!i)return s.filter(matches).map(e=>({kind:"option",option:e}));const t=[];return i.forEach((e,o)=>{const s=e.options.filter(matches);if(0!==s.length){t.push({kind:"header",title:e.title});for(const e of s)t.push({kind:"option",option:e,section:o})}}),t},[y,P,s,i,k,I]),K=useCallback(()=>{t()},[t]),Y=useRef(null),Z=useMemo(()=>{const e=new Map;if(!n)return e;let t=0;if(i)for(const[e,o]of J.entries())"header"===o.kind&&(t=e+1);for(const[o,s]of J.entries()){if(o<t||"option"!==s.kind)continue;const i=k(s.option).trim().charAt(0).toUpperCase(),r=/^[A-Z]$/.test(i)?i:"#";e.has(r)||e.set(r,o)}return e},[n,J,i,k]),Q=n&&Z.size>0&&0===P.trim().length,X=useMemo(()=>[..."ABCDEFGHIJKLMNOPQRSTUVWXYZ",...Z.has("#")?["#"]:[]],[Z]),q=useCallback(e=>{const t=Z.get(e);void 0!==t&&Y.current?.scrollToIndex({index:t,animated:!0,viewPosition:0})},[Z]),ee=useRef(null),te=useCallback(()=>{null!==ee.current&&(clearTimeout(ee.current),ee.current=null)},[]),oe=useCallback(e=>{Y.current?.scrollToOffset({offset:e.averageItemLength*e.index,animated:!1}),te(),ee.current=setTimeout(()=>{ee.current=null,Y.current?.scrollToIndex({index:e.index,animated:!0,viewPosition:0})},50)},[te]);useEffect(()=>te,[te]);return _jsx(GestureHandlerRootView,{style:v.gestureRoot,children:_jsxs(Animated.View,{testID:_,accessibilityViewIsModal:!0,accessibilityLabel:S??o??a.fallbackName,style:[v.sheet,{maxHeight:$,marginBottom:N,paddingBottom:U?V.space.lg:D.bottom+V.space.lg,backgroundColor:V.colors.surface,borderTopLeftRadius:V.radius.xl,borderTopRightRadius:V.radius.xl,...smoothCorners,opacity:F,transform:[{translateY:A}],...V.shadow.modal}],children:[_jsx(GestureDetector,{gesture:E,children:_jsxs(View,{children:[_jsx(View,{style:v.sheetHandleRow,children:_jsx(View,{style:[v.sheetHandle,{backgroundColor:V.colors.border}]})}),o?_jsx(Text,{variant:"title",style:[v.sheetTitle,{paddingHorizontal:V.space.lg,marginBottom:V.space.sm}],children:o}):null]})}),y?_jsx(View,{style:[v.searchWrap,{marginHorizontal:V.space.lg,marginBottom:V.space.sm}],children:_jsxs(View,{style:[v.searchBox,{backgroundColor:V.colors["bg-subtle"],borderColor:V.colors.border,borderRadius:V.radius.md,...smoothCorners,paddingHorizontal:V.space.md,gap:V.space.sm}],children:[(V.settings.icons.search??defaultIcons.search)({size:18,color:V.colors["text-subtle"]}),_jsx(TextInput,{value:P,onChangeText:H,placeholder:a.searchPlaceholder,placeholderTextColor:V.colors["text-subtle"],selectionColor:f??V.colors["focus-ring"],accessibilityLabel:a.searchOptions,style:[v.searchInput,{color:V.colors["text-body"],fontSize:V.text.base.size,paddingVertical:V.space.sm}]}),P.length>0?_jsx(Pressable,{onPress:()=>H(""),hitSlop:8,...hitSlopMarker(8),accessibilityRole:"button",accessibilityLabel:a.clearSearch,children:(V.settings.icons.close??defaultIcons.close)({size:18,color:V.colors["text-muted"]})}):null]})}):null,_jsxs(View,{style:[v.listWrap,Q?v.listRow:null],children:[_jsx(GestureDetector,{gesture:z,children:_jsx(FlatList,{ref:Y,data:J,keyExtractor:e=>"header"===e.kind?`h:${e.title}`:`o:${e.section??""}:${String(L(e.option))}`,renderItem:({item:e,index:t})=>{if("header"===e.kind)return _jsx(View,{accessible:!0,accessibilityRole:"header",style:[v.sectionHeader,{paddingHorizontal:V.space.lg,paddingTop:V.space.md}],children:r?r(e.title):_jsx(Text,{variant:"caption",weight:"semibold",color:"tertiary",style:v.sectionTitle,children:e.title.toUpperCase()})});const o=e.option,s=k(o),i=L(o),n=I(o),a=R(o),c=(d=i,Array.isArray(b)?b.some(e=>String(e)===String(d)):null!=b&&String(b)===String(d));var d;const p=O(o),u=m?.(o)??!1;return _jsxs(Pressable,{onPress:()=>g(i,o),disabled:p,android_ripple:{color:V.colors["surface-pressed"],borderless:!1},accessibilityRole:"button",accessibilityLabel:s,accessibilityState:{selected:c,disabled:p},"aria-selected":c,"aria-disabled":p,style:({pressed:e})=>[v.optionRow,{backgroundColor:c?V.colors["surface-selected"]:e?V.colors["surface-pressed"]:"transparent",opacity:p?.5:1,paddingHorizontal:V.space.lg,paddingVertical:V.space.md},T,c?j:null],children:[l?_jsx(View,{style:v.optionTextWrap,children:l({option:o,selected:c,disabled:p,index:t})}):_jsxs(_Fragment,{children:[a?_jsx(View,{style:v.optionIcon,children:a}):null,_jsxs(View,{style:v.optionTextWrap,children:[_jsx(Text,{variant:"body",weight:c?"semibold":"medium",color:u?"danger":c?"brand":void 0,style:[v.optionLabel,w,c?C:null],children:s}),n?_jsx(Text,{variant:"bodySmall",color:"tertiary",numberOfLines:2,style:v.optionDescription,children:n}):null]})]}),x?_jsx(View,{style:[v.checkbox,{borderColor:c?V.colors.primary:V.colors.border,backgroundColor:c?V.colors.primary:"transparent"}],children:c?_jsx(View,{style:v.checkboxTick}):null}):c?"icon"===V.settings.components["option-sheet"]?.selectedMarker?_jsx(View,{style:v.singleSelectedIcon,children:(V.settings.icons.selectedTick??defaultIcons.selectedTick)({size:20,color:V.colors.primary})}):_jsx(View,{style:[v.singleSelectedDot,{backgroundColor:V.colors.primary}]}):null]})},onScrollToIndexFailed:oe,overScrollMode:"never",bounces:!1,keyboardShouldPersistTaps:"handled",showsVerticalScrollIndicator:!Q,style:Q?v.listBesideRail:null,ListEmptyComponent:_jsx(Text,{variant:"bodySmall",color:"tertiary",align:"center",style:{paddingVertical:V.space.xl},children:a.empty})})}),Q?_jsx(View,{style:[v.rail,{paddingRight:V.space.xs}],accessibilityRole:"list",accessibilityLabel:a.jumpToLetter,testID:"option-sheet-alphabet",children:X.map(e=>{const t=Z.has(e);return _jsx(Pressable,{onPress:()=>q(e),disabled:!t,hitSlop:{left:8,right:8},...hitSlopMarker({left:8,right:8}),accessibilityRole:"button",accessibilityLabel:a.jumpTo(e),accessibilityState:{disabled:!t},"aria-disabled":!t,style:v.railLetter,children:_jsx(Text,{variant:"caption",weight:"semibold",color:t?"brand":"tertiary",style:[v.railLetterText,{opacity:t?1:.45}],children:e})},e)})}):null]}),x?_jsx(View,{style:[v.sheetFooter,{borderTopColor:V.colors["border-subtle"],paddingHorizontal:V.space.lg,paddingVertical:V.space.md}],children:_jsx(Pressable,{onPress:K,accessibilityRole:"button",accessibilityLabel:a.done,style:({pressed:e})=>[v.doneButton,{backgroundColor:e?V.colors["primary-pressed"]:V.colors.primary,borderRadius:V.radius.md,...smoothCorners,paddingVertical:V.space.sm,paddingHorizontal:V.space.lg}],children:_jsx(Text,{variant:"body",weight:"semibold",style:{color:V.colors["on-primary"]},children:a.done})})}):null]})})}export function OptionSheet(e){const{open:t,onOpenChange:o,onAfterClose:s,labels:i,onClose:r,haptic:l,...n}=e,a=useMemo(()=>({...DEFAULT_OPTION_SHEET_LABELS,...i}),[i]),c=useRef(o);c.current=o;const d=useRef(!1);return useEffect(()=>{d.current!==t&&(d.current=t,c.current?.(t))},[t]),_jsx(Modal,{open:t,onClose:r,presentation:"bottom",onDismissed:s,haptic:l,contentStyle:hostStyle,labels:{close:a.closePicker},accessibilityLabel:n.accessibilityLabel??n.title??a.fallbackName,children:_jsx(OptionSheetPanel,{...n,onClose:r,labels:a})})}OptionSheet.displayName="OptionSheet";const buildStyles=e=>StyleSheet.create({gestureRoot:{width:"100%"},sheet:{paddingBottom:e.space.lg,overflow:"hidden"},sheetHandleRow:{alignItems:"center",paddingTop:e.space.sm,paddingBottom:e.space.sm},sheetHandle:{width:36,height:4,borderRadius:e.radius.pill,...smoothCorners},sheetTitle:{includeFontPadding:!1},searchWrap:{width:"auto"},searchBox:{flexDirection:"row",alignItems:"center",borderWidth:1},searchInput:{flex:1,includeFontPadding:!1},optionRow:{flexDirection:"row",alignItems:"center"},sectionHeader:{paddingBottom:e.space.xs},listWrap:{flexShrink:1},listRow:{flexDirection:"row"},listBesideRail:{flex:1},rail:{justifyContent:"space-between",alignItems:"center",alignSelf:"stretch",paddingVertical:e.space.xs},railLetter:{paddingHorizontal:e.space.xs,minHeight:14,justifyContent:"center"},railLetterText:{includeFontPadding:!1,lineHeight:14},sectionTitle:{includeFontPadding:!1,letterSpacing:.6},optionIcon:{marginRight:e.space.md},optionTextWrap:{flex:1},optionLabel:{includeFontPadding:!1},optionDescription:{includeFontPadding:!1,marginTop:e.space.xxs},checkbox:{width:22,height:22,borderRadius:e.radius.sm,...smoothCorners,borderWidth:2,alignItems:"center",justifyContent:"center",marginLeft:e.space.md},checkboxTick:{width:10,height:6,borderLeftWidth:2,borderBottomWidth:2,borderColor:e.colors["on-primary"],transform:[{rotate:"-45deg"},{translateY:-1}]},singleSelectedDot:{width:8,height:8,borderRadius:e.radius.pill,...smoothCorners,marginLeft:e.space.md},singleSelectedIcon:{marginLeft:e.space.md},sheetFooter:{borderTopWidth:StyleSheet.hairlineWidth,alignItems:"flex-end"},doneButton:{alignSelf:"flex-end"}});export default OptionSheet;
@@ -1 +1 @@
1
- "use strict";import{forwardRef,useCallback,useMemo,useRef,useState}from"react";import{Pressable,StyleSheet,View}from"react-native";import{useTheme}from"../../theme/index.js";import{resolveHaptic,triggerHaptic}from"../../utils/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{blendOf}from"../../utils/color.js";import{smoothCorners}from"../../utils/corners.js";import{AppIcon}from"../AppIcon/index.js";import{renderSlotIcon}from"../AppIcon/slotIcon.js";import{Avatar}from"../Avatar/index.js";import{FieldLabel,FieldMessage,fieldTextAsString,hasFieldText}from"../FieldBase/index.js";import{matchesAccept}from"../FilePicker/FilePicker.js";import{OptionSheet}from"../OptionSheet/OptionSheet.js";import{Spinner}from"../Spinner/index.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_PROFILE_PICKER_LABELS=Object.freeze({pick:"Change profile photo",remove:"Remove photo",sheetTitle:"Change photo",errorTooLarge:e=>`The photo is larger than ${e} MB.`,errorWrongType:"That file is not a supported image."});const DEFAULT_ACCEPT=["image/*"],SHEET_ICON_SIZE=20,SOFT_FILL_OPACITY=.14,SIZE_PX={sm:72,md:120,lg:160},clamp=(e,r,t)=>Math.min(t,Math.max(r,e)),toneFor=(e,r)=>{switch(r){case"success":return{base:e.colors.success,on:e.colors["on-success"]};case"warning":return{base:e.colors.warning,on:e.colors["on-warning"]};case"danger":return{base:e.colors.danger,on:e.colors["on-danger"]};case"info":return{base:e.colors.info,on:e.colors["on-info"]};case"neutral":return{base:e.colors["text-muted"],on:e.colors["on-neutral-strong"]};default:return{base:e.colors.primary,on:e.colors["on-primary"]}}},badgeLookFor=(e,r,t)=>{const o=toneFor(e,r),s=o.base,i=e.colors.bg,l="neutral"===r;let n;switch(t){case"soft":n={fill:l?e.colors["bg-muted"]:blendOf(s,.14,i,e.colors["bg-subtle"]),ring:i,icon:s};break;case"outline":n={fill:i,ring:l?e.colors.border:s,icon:s};break;default:n={fill:s,ring:i,icon:o.on}}return n},resolveRadius=(e,r)=>"circle"===e?r/2:"rounded"===e?Math.max(6,Math.round(.22*r)):0,REMOVE_VALUE="__profile-picker-remove__",ProfilePicker=forwardRef((e,r)=>{const{value:t,name:o,sources:s,onPick:i,onRemove:l,loading:n=!1,disabled:a=!1,accept:c=DEFAULT_ACCEPT,maxSizeMB:d,size:u="md",shape:m="circle",badgeIcon:p="camera",tone:g,variant:h,avatarTone:f,avatarBackgroundColor:b,avatarColor:y,label:x,required:k=!1,helperText:v,error:C,layout:_="stacked",title:j,subtitle:P,ImageComponent:S,labels:T,haptic:I,onError:E,accessibilityLabel:F,style:V,testID:A}=e;assertValidValue("ProfilePicker","size",e.size,["sm","md","lg"]),assertValidValue("ProfilePicker","shape",e.shape,["circle","rounded","square"]),assertValidValue("ProfilePicker","tone",e.tone,["primary","success","warning","danger","info","neutral"]),assertValidValue("ProfilePicker","variant",e.variant,["solid","soft","outline"]),assertValidValue("ProfilePicker","layout",e.layout,["stacked","inline","profile"]);const w=useTheme(),L=w.settings.components["profile-picker"],R=g??L?.defaultTone??"primary",M=h??L?.defaultVariant??"solid",O=useMemo(()=>badgeLookFor(w,R,M),[w,R,M]),D=f??L?.defaultAvatarTone,H=useMemo(()=>({...DEFAULT_PROFILE_PICKER_LABELS,...T}),[T]),[z,B]=useState(null),[U,$]=useState(null),[q,W]=useState(!1),[Z,G]=useState(t);t!==Z&&(G(t),B(null));const K=n||a,N=z??t??null,X=useMemo(()=>N?{uri:N}:void 0,[N]),Q=C??U??void 0,Y=!K&&(null!==z||Boolean(t)&&Boolean(l)),J=s.length>0||Y,ee=SIZE_PX[u],re=resolveRadius(m,ee),te=re*(1-Math.SQRT1_2),oe=clamp(Math.round(.28*ee),24,44),se=te-oe/2,ie=Math.max(0,-se),le=useCallback(e=>{$(e),E?.(e),!1!==I&&triggerHaptic("notificationError")},[E,I]),ne=useCallback(async e=>{let r;try{r=await e.pick()}catch(e){return void le(e instanceof Error?e.message:String(e))}const t=r?.[0];if(!t)return;if("number"==typeof d&&"number"==typeof t.size&&t.size>1024*d*1024)return void le(H.errorTooLarge(d));if(t.type&&!matchesAccept(t.type,c))return void le(H.errorWrongType);$(null),B(t.uri);const o=resolveHaptic(I,"selection");o&&triggerHaptic(o),i?.(t)},[d,c,H,I,i,le]),ae=useCallback(()=>{K||(ue.current=null,1!==s.length||Y?(s.length>0||Y)&&W(!0):ne(s[0]))},[K,s,Y,ne]),ce=useCallback(()=>{B(null),$(null);const e=resolveHaptic(I,"selection");e&&triggerHaptic(e),l?.()},[I,l]),de=useMemo(()=>{const e=s.map(e=>({kind:"source",source:e}));return Y&&e.push({kind:"remove"}),e},[s,Y]),ue=useRef(null),me=useCallback(e=>{ue.current||(W(!1),"remove"===e.kind?ce():ue.current=e.source)},[ce]),pe=useRef(ne);pe.current=ne;const ge=useCallback(()=>{const e=ue.current;ue.current=null,e&&pe.current(e)},[]),he=A??"profile-picker",fe=F??(J?H.pick:o),be=_jsx(View,{style:{width:ee,height:ee,marginBottom:ie,marginRight:ie},children:_jsxs(Pressable,{onPress:ae,disabled:K||!J,accessibilityRole:J?"button":"image",accessibilityLabel:fe,accessibilityHint:fieldTextAsString(Q),accessibilityState:J?{disabled:K,busy:n}:{busy:n},"aria-disabled":J?K:void 0,"aria-busy":n,testID:`${he}-button`,style:({pressed:e})=>[{width:ee,height:ee,borderRadius:re,...smoothCorners},{opacity:a?.55:e?.85:1}],children:[_jsx(View,{importantForAccessibility:"no-hide-descendants",accessibilityElementsHidden:!0,pointerEvents:"none",children:_jsx(Avatar,{dimension:ee,shape:m,name:o||void 0,source:X,ImageComponent:S,tone:D,backgroundColor:b,color:y,placeholderIcon:"user"})}),n?_jsx(View,{style:[styles.fill,styles.overlay,{borderRadius:re,...smoothCorners,backgroundColor:w.colors.scrim}],testID:`${he}-loading`,children:_jsx(Spinner,{size:ee>=100?"md":"sm",color:w.colors["on-primary"]})}):null,!a&&J?_jsx(View,{pointerEvents:"none",testID:`${he}-badge`,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,style:[styles.badge,{width:oe,height:oe,borderRadius:w.radius.pill,...smoothCorners,right:se,bottom:se,backgroundColor:O.fill,borderColor:O.ring}],children:renderSlotIcon(p,{color:O.icon,size:Math.round(.55*oe),disabled:!1})}):null]})}),ye="stacked"!==_?_jsxs(View,{style:[styles.meta,"profile"===_?styles.metaCentred:null],children:[j?_jsx(Text,{variant:"body",weight:"semibold",style:[styles.title,"profile"===_?styles.textCentred:null],children:j}):null,P?_jsx(Text,{variant:"bodySmall",color:"secondary",style:[styles.subtitle,"profile"===_?styles.textCentred:null,{marginTop:w.space.xxs}],children:P}):null,_jsx(FieldMessage,{text:Q??v,error:hasFieldText(Q)})]}):_jsx(FieldMessage,{text:Q??v,error:hasFieldText(Q)});return _jsxs(View,{ref:r,style:V,testID:A,children:[x?_jsx(FieldLabel,{required:k,children:x}):null,_jsxs(View,{style:"inline"===_?[styles.row,{columnGap:w.space.md}]:["profile"===_?styles.columnCentred:styles.column,{rowGap:w.space.xs}],children:[be,ye]}),_jsx(OptionSheet,{open:q,haptic:I,onClose:()=>W(!1),onAfterClose:ge,title:H.sheetTitle,options:de,getOptionLabel:e=>"remove"===e.kind?H.remove:e.source.label,getOptionValue:e=>"remove"===e.kind?REMOVE_VALUE:e.source.key,destructiveOf:e=>"remove"===e.kind,getOptionDescription:e=>"remove"===e.kind?void 0:e.source.description,getOptionIcon:e=>"remove"===e.kind?_jsx(AppIcon,{name:"trash",size:20,color:w.colors["danger-text"]}):e.source.icon,onChange:(e,r)=>me(r)})]})});ProfilePicker.displayName="ProfilePicker";const styles=StyleSheet.create({fill:{alignItems:"center",justifyContent:"center",overflow:"hidden"},overlay:{...StyleSheet.absoluteFill},badge:{position:"absolute",alignItems:"center",justifyContent:"center",borderWidth:2},row:{flexDirection:"row",alignItems:"center"},column:{alignItems:"flex-start"},columnCentred:{alignItems:"center"},meta:{flexShrink:1},metaCentred:{alignItems:"center"},title:{includeFontPadding:!1},subtitle:{includeFontPadding:!1},textCentred:{textAlign:"center"}});export{ProfilePicker};export default ProfilePicker;
1
+ "use strict";import{forwardRef,useCallback,useMemo,useRef,useState}from"react";import{Pressable,StyleSheet,View}from"react-native";import{useTheme}from"../../theme/index.js";import{resolveHaptic,triggerHaptic}from"../../utils/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{blendOf}from"../../utils/color.js";import{smoothCorners}from"../../utils/corners.js";import{AppIcon}from"../AppIcon/index.js";import{renderSlotIcon}from"../AppIcon/slotIcon.js";import{Avatar}from"../Avatar/index.js";import{FieldLabel,FieldMessage,fieldTextAsString,hasFieldText}from"../FieldBase/index.js";import{matchesAccept}from"../FilePicker/FilePicker.js";import{OptionSheet}from"../OptionSheet/OptionSheet.js";import{Spinner}from"../Spinner/index.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_PROFILE_PICKER_LABELS=Object.freeze({pick:"Change profile photo",remove:"Remove photo",sheetTitle:"Change photo",errorTooLarge:e=>`The photo is larger than ${e} MB.`,errorWrongType:"That file is not a supported image."});const DEFAULT_ACCEPT=["image/*"],SHEET_ICON_SIZE=20,SOFT_FILL_OPACITY=.14,SIZE_PX={sm:72,md:120,lg:160},clamp=(e,r,t)=>Math.min(t,Math.max(r,e)),toneFor=(e,r)=>{switch(r){case"success":return{base:e.colors.success,on:e.colors["on-success"]};case"warning":return{base:e.colors.warning,on:e.colors["on-warning"]};case"danger":return{base:e.colors.danger,on:e.colors["on-danger"]};case"info":return{base:e.colors.info,on:e.colors["on-info"]};case"neutral":return{base:e.colors["text-muted"],on:e.colors["on-neutral-strong"]};default:return{base:e.colors.primary,on:e.colors["on-primary"]}}},badgeLookFor=(e,r,t)=>{const o=toneFor(e,r),s=o.base,i=e.colors.bg,n="neutral"===r;let l;switch(t){case"soft":l={fill:n?e.colors["bg-muted"]:blendOf(s,.14,i,e.colors["bg-subtle"]),ring:i,icon:s};break;case"outline":l={fill:i,ring:n?e.colors.border:s,icon:s};break;default:l={fill:s,ring:i,icon:o.on}}return l},resolveRadius=(e,r)=>"circle"===e?r/2:"rounded"===e?Math.max(6,Math.round(.22*r)):0,REMOVE_VALUE="__profile-picker-remove__",ProfilePicker=forwardRef((e,r)=>{const{value:t,name:o,sources:s,onPick:i,onRemove:n,loading:l=!1,disabled:a=!1,accept:c=DEFAULT_ACCEPT,maxSizeMB:d,size:u="md",shape:m="circle",badgeIcon:p="camera",tone:g,variant:h,avatarTone:f,avatarBackgroundColor:b,avatarColor:y,label:x,required:k=!1,helperText:v,error:C,layout:_="stacked",title:j,subtitle:P,ImageComponent:S,labels:T,haptic:I,onError:E,accessibilityLabel:F,style:V,testID:A}=e;assertValidValue("ProfilePicker","size",e.size,["sm","md","lg"]),assertValidValue("ProfilePicker","shape",e.shape,["circle","rounded","square"]),assertValidValue("ProfilePicker","tone",e.tone,["primary","success","warning","danger","info","neutral"]),assertValidValue("ProfilePicker","variant",e.variant,["solid","soft","outline"]),assertValidValue("ProfilePicker","layout",e.layout,["stacked","inline","profile"]);const w=useTheme(),L=w.settings.components["profile-picker"],R=g??L?.defaultTone??"primary",M=h??L?.defaultVariant??"solid",O=useMemo(()=>badgeLookFor(w,R,M),[w,R,M]),D=f??L?.defaultAvatarTone,H=useMemo(()=>({...DEFAULT_PROFILE_PICKER_LABELS,...T}),[T]),[z,B]=useState(null),[U,$]=useState(null),[q,W]=useState(!1),[Z,G]=useState(t);t!==Z&&(G(t),B(null));const K=l||a,N=z??t??null,X=useMemo(()=>N?{uri:N}:void 0,[N]),Q=C??U??void 0,Y=!K&&(null!==z||Boolean(t)&&Boolean(n)),J=s.length>0||Y,ee=SIZE_PX[u],re=resolveRadius(m,ee),te=re*(1-Math.SQRT1_2),oe=clamp(Math.round(.28*ee),24,44),se=te-oe/2,ie=Math.max(0,-se),ne=useCallback(e=>{$(e),E?.(e),!1!==I&&triggerHaptic("notificationError")},[E,I]),le=useCallback(async e=>{let r;try{r=await e.pick()}catch(e){return void ne(e instanceof Error?e.message:String(e))}const t=r?.[0];if(!t)return;if("number"==typeof d&&"number"==typeof t.size&&t.size>1024*d*1024)return void ne(H.errorTooLarge(d));if(t.type&&!matchesAccept(t.type,c))return void ne(H.errorWrongType);$(null),B(t.uri);const o=resolveHaptic(I,"selection");o&&triggerHaptic(o),i?.(t)},[d,c,H,I,i,ne]),ae=useCallback(()=>{if(K)return;ue.current=null;const[e]=s;void 0===e||1!==s.length||Y?(s.length>0||Y)&&W(!0):le(e)},[K,s,Y,le]),ce=useCallback(()=>{B(null),$(null);const e=resolveHaptic(I,"selection");e&&triggerHaptic(e),n?.()},[I,n]),de=useMemo(()=>{const e=s.map(e=>({kind:"source",source:e}));return Y&&e.push({kind:"remove"}),e},[s,Y]),ue=useRef(null),me=useCallback(e=>{ue.current||(W(!1),"remove"===e.kind?ce():ue.current=e.source)},[ce]),pe=useRef(le);pe.current=le;const ge=useCallback(()=>{const e=ue.current;ue.current=null,e&&pe.current(e)},[]),he=A??"profile-picker",fe=F??(J?H.pick:o),be=_jsx(View,{style:{width:ee,height:ee,marginBottom:ie,marginRight:ie},children:_jsxs(Pressable,{onPress:ae,disabled:K||!J,accessibilityRole:J?"button":"image",accessibilityLabel:fe,accessibilityHint:fieldTextAsString(Q),accessibilityState:J?{disabled:K,busy:l}:{busy:l},"aria-disabled":J?K:void 0,"aria-busy":l,testID:`${he}-button`,style:({pressed:e})=>[{width:ee,height:ee,borderRadius:re,...smoothCorners},{opacity:a?.55:e?.85:1}],children:[_jsx(View,{importantForAccessibility:"no-hide-descendants",accessibilityElementsHidden:!0,pointerEvents:"none",children:_jsx(Avatar,{dimension:ee,shape:m,name:o||void 0,source:X,ImageComponent:S,tone:D,backgroundColor:b,color:y,placeholderIcon:"user"})}),l?_jsx(View,{style:[styles.fill,styles.overlay,{borderRadius:re,...smoothCorners,backgroundColor:w.colors.scrim}],testID:`${he}-loading`,children:_jsx(Spinner,{size:ee>=100?"md":"sm",color:w.colors["on-primary"]})}):null,!a&&J?_jsx(View,{pointerEvents:"none",testID:`${he}-badge`,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,style:[styles.badge,{width:oe,height:oe,borderRadius:w.radius.pill,...smoothCorners,right:se,bottom:se,backgroundColor:O.fill,borderColor:O.ring}],children:renderSlotIcon(p,{color:O.icon,size:Math.round(.55*oe),disabled:!1})}):null]})}),ye="stacked"!==_?_jsxs(View,{style:[styles.meta,"profile"===_?styles.metaCentred:null],children:[j?_jsx(Text,{variant:"body",weight:"semibold",style:[styles.title,"profile"===_?styles.textCentred:null],children:j}):null,P?_jsx(Text,{variant:"bodySmall",color:"secondary",style:[styles.subtitle,"profile"===_?styles.textCentred:null,{marginTop:w.space.xxs}],children:P}):null,_jsx(FieldMessage,{text:Q??v,error:hasFieldText(Q)})]}):_jsx(FieldMessage,{text:Q??v,error:hasFieldText(Q)});return _jsxs(View,{ref:r,style:V,testID:A,children:[x?_jsx(FieldLabel,{required:k,children:x}):null,_jsxs(View,{style:"inline"===_?[styles.row,{columnGap:w.space.md}]:["profile"===_?styles.columnCentred:styles.column,{rowGap:w.space.xs}],children:[be,ye]}),_jsx(OptionSheet,{open:q,haptic:I,onClose:()=>W(!1),onAfterClose:ge,title:H.sheetTitle,options:de,getOptionLabel:e=>"remove"===e.kind?H.remove:e.source.label,getOptionValue:e=>"remove"===e.kind?REMOVE_VALUE:e.source.key,destructiveOf:e=>"remove"===e.kind,getOptionDescription:e=>"remove"===e.kind?void 0:e.source.description,getOptionIcon:e=>"remove"===e.kind?_jsx(AppIcon,{name:"trash",size:20,color:w.colors["danger-text"]}):e.source.icon,onChange:(e,r)=>me(r)})]})});ProfilePicker.displayName="ProfilePicker";const styles=StyleSheet.create({fill:{alignItems:"center",justifyContent:"center",overflow:"hidden"},overlay:{...StyleSheet.absoluteFill},badge:{position:"absolute",alignItems:"center",justifyContent:"center",borderWidth:2},row:{flexDirection:"row",alignItems:"center"},column:{alignItems:"flex-start"},columnCentred:{alignItems:"center"},meta:{flexShrink:1},metaCentred:{alignItems:"center"},title:{includeFontPadding:!1},subtitle:{includeFontPadding:!1},textCentred:{textAlign:"center"}});export{ProfilePicker};export default ProfilePicker;
@@ -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{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{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_PROGRESS_BAR_LABELS=Object.freeze({loading:"Loading"});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}},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:a,label:o,showPercent:i=!1,valueLabel:n,indeterminate:l,height:u=6,radius:c,tone:d="primary",trackColor:m,barColor:g,gradient:p,segments:f,animated:y=!0,style:h,containerStyle:b,barStyle:x,accessibilityLabel:w,labels:R,testID:A}=e;assertValidValue("ProgressBar","tone",e.tone,["primary","success","warning","danger","info","neutral"]);const _=useMemo(()=>({...DEFAULT_PROGRESS_BAR_LABELS,...R}),[R]),j=l??"number"!=typeof a,V=clampProgress(a),E=useRef(createAnimatedValue(V)).current,S=useRef(createAnimatedValue(0)).current,T=useRef(createAnimatedValue(0)).current,N=useRef(0),O=useMemo(()=>buildStyles(r),[r]),v=c??r.radius.pill,L=m??r.colors["surface-disabled"],B=g??toneColor(r,d),I=useMemo(()=>p?"string"==typeof p?r.settings.gradients[p]??null:p:null,[p,r.settings.gradients]),C=useMemo(()=>glowOf(B),[B]),D=Array.isArray(f)&&f.length>0;useEffect(()=>{j||(y?Animated.timing(E,{toValue:V,duration:400,easing:Easing.bezier(...r.motion.ease["in-out"]),useNativeDriver:!1}).start():E.setValue(V))},[y,V,E,j,r]),useEffect(()=>{if(!j)return;setNativeValue(S,0);const e=Animated.loop(Animated.timing(S,{toValue:1,duration:1500,easing:Easing.inOut(Easing.ease),useNativeDriver:!0}));return e.start(),()=>{e.stop()}},[j,S]);const M=E.interpolate({inputRange:[0,1],outputRange:["0%","100%"]}),P=S.interpolate({inputRange:[0,1],outputRange:[-1,1]}),k=S.interpolate({inputRange:[0,.5,1],outputRange:[.4,1,.4]}),G=i&&!j&&!D,F=null!=o||G||null!=n,U=_jsx(View,{ref:t,accessibilityRole:"progressbar",accessibilityLabel:w??("string"==typeof o?o:void 0),accessibilityValue:j?{text:_.loading}:{min:0,max:100,now:Math.round(100*V)},testID:A,onLayout:e=>{const t=e.nativeEvent.layout.width;N.current=t,setNativeValue(T,t)},style:[O.track,{height:u,borderRadius:v,...smoothCorners,backgroundColor:L},b,h],children:D?_jsx(View,{style:[O.segments,{height:u}],children:(f??[]).map((e,t)=>_jsx(View,{style:{width:100*clampProgress(e.value)+"%",height:u,backgroundColor:e.color??toneColor(r,e.tone??"primary")}},t))}):_jsx(Animated.View,j?{style:[O.indeterminateBar,{height:u,width:s?"100%":"30%",opacity:s?k:1,transform:s?[]:[{translateX:Animated.multiply(P,T)}]},x],children:_jsx(Gradient,{gradient:C,style:StyleSheet.absoluteFill})}:{style:[O.determinateBar,{height:u,borderRadius:v,...smoothCorners,backgroundColor:I?"transparent":B,width:M,overflow:I?"hidden":void 0},x],children:I?_jsx(Gradient,{gradient:I,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!=n?"string"==typeof n||"number"==typeof n?_jsx(Text,{variant:"label",color:"secondary",accessible:!1,importantForAccessibility:"no",children:n}):n:G?_jsx(Text,{variant:"label",color:"secondary",accessible:!1,importantForAccessibility:"no",children:`${Math.round(100*V)}%`}):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{forwardRef,useEffect,useMemo,useRef}from"react";import{Animated,Easing,StyleSheet,View}from"react-native";import{useReducedMotion}from"../../hooks/useReducedMotion.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";export const DEFAULT_PROGRESS_BAR_LABELS=Object.freeze({loading:"Loading"});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:n,showPercent:a=!1,valueLabel:o,indeterminate:l,height:u=6,radius:c,tone:d="primary",trackColor:m,barColor:g,gradient:p,segments:f,animated:h=!0,style:y,containerStyle:b,barStyle:w,accessibilityLabel:x,labels:R,testID:A}=e;assertValidValue("ProgressBar","tone",e.tone,["primary","success","warning","danger","info","neutral"]);const j=useMemo(()=>({...DEFAULT_PROGRESS_BAR_LABELS,...R}),[R]),v=l??"number"!=typeof i,_=clampProgress(i),V=useRef(createAnimatedValue(_)).current,E=useRef(createAnimatedValue(0)).current,O=useRef(createAnimatedValue(0)).current,S=useRef(0),T=useMemo(()=>buildStyles(r),[r]),N=c??r.radius.pill,D=m??r.colors["surface-disabled"],B=g??toneColor(r,d),L=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;useEffect(()=>{v||(h?Animated.timing(V,{toValue:_,duration:400,easing:Easing.bezier(...r.motion.ease["in-out"]),useNativeDriver:!1}).start():V.setValue(_))},[h,_,V,v,r]),useEffect(()=>{if(!v)return;setNativeValue(E,0);const e=Animated.loop(Animated.timing(E,{toValue:1,duration:1500,easing:Easing.inOut(Easing.ease),useNativeDriver:nativeDriver}));return e.start(),()=>{e.stop()}},[v,E]);const C=V.interpolate({inputRange:[0,1],outputRange:["0%","100%"]}),M=E.interpolate({inputRange:[0,1],outputRange:[-1,1]}),k=E.interpolate({inputRange:[0,.5,1],outputRange:[.4,1,.4]}),G=a&&!v&&!P,F=null!=n||G||null!=o,$=_jsx(View,{ref:t,accessibilityRole:"progressbar",accessibilityLabel:x??("string"==typeof n?n:void 0),accessibilityValue:v?{text:j.loading}:{min:0,max:100,now:Math.round(100*_)},testID:A,onLayout:e=>{const t=e.nativeEvent.layout.width;S.current=t,setNativeValue(O,t)},style:[T.track,{height:u,borderRadius:N,...smoothCorners,backgroundColor:D},b,y],children:P?_jsx(View,{style:[T.segments,{height:u}],children:(f??[]).map((e,t)=>_jsx(View,{style:{width:100*clampProgress(e.value)+"%",height:u,backgroundColor:e.color??toneColor(r,e.tone??"primary")}},t))}):_jsx(Animated.View,v?{style:[T.indeterminateBar,{height:u,width:s?"100%":"30%",opacity:s?k:1,transform:s?[]:[{translateX:Animated.multiply(M,O)}]},w],children:_jsx(Gradient,{gradient:I,style:StyleSheet.absoluteFill})}:{style:[T.determinateBar,{height:u,borderRadius:N,...smoothCorners,backgroundColor:L?"transparent":B,width:C,overflow:L?"hidden":void 0},w],children:L?_jsx(Gradient,{gradient:L,style:StyleSheet.absoluteFill}):null})});return F?_jsxs(View,{style:T.wrapper,children:[_jsxs(View,{style:[T.labelRow,{marginBottom:r.space.xs}],children:["string"==typeof n||"number"==typeof n?_jsx(Text,{variant:"label",color:"primary",style:T.label,children:n}):_jsx(View,{style:T.label,children:n}),null!=o?"string"==typeof o||"number"==typeof o?_jsx(Text,{variant:"label",color:"secondary",accessible:!1,importantForAccessibility:"no",children:o}):o:G?_jsx(Text,{variant:"label",color:"secondary",accessible:!1,importantForAccessibility:"no",children:`${Math.round(100*_)}%`}):null]}),$]}):$});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 +1 @@
1
- "use strict";import{useEffect,useMemo,useRef}from"react";import{Animated,StyleSheet,View}from"react-native";import{createAnimatedValue,resolveRadioSize,useTheme}from"../../theme/index.js";import{smoothCorners}from"../../utils/corners.js";import{jsx as _jsx}from"react/jsx-runtime";export const RadioDot=e=>{const{selected:t,color:o,disabled:r=!1,size:s="md",style:i,dotStyle:n}=e,a=useTheme(),d=useMemo(()=>buildStyles(),[]),l=o??a.colors.primary;let m,u;if("number"==typeof s)m=s,u=Math.round(s/2);else{const e=resolveRadioSize(a,s);m=e.outer,u=e.inner}const p=useRef(createAnimatedValue(t?1:0)).current;useEffect(()=>{const e=Animated.spring(p,{toValue:t?1:0,damping:a.motion.spring.snappy.damping,stiffness:a.motion.spring.snappy.stiffness,mass:a.motion.spring.snappy.mass,useNativeDriver:!0});return e.start(),()=>e.stop()},[t,p,a.motion.spring.snappy]);const c=p.interpolate({inputRange:[0,1],outputRange:[0,1]}),f=r?a.colors.border:t?l:a.colors.border;return _jsx(View,{style:[d.outer,{width:m,height:m,borderWidth:a.size.border,borderRadius:a.radius.pill,...smoothCorners,borderColor:f},i],children:_jsx(Animated.View,{style:[{width:u,height:u,borderRadius:a.radius.pill,...smoothCorners,backgroundColor:r?a.colors["text-disabled"]:l,opacity:p,transform:[{scale:c}]},n]})})};RadioDot.displayName="RadioDot";const buildStyles=()=>StyleSheet.create({outer:{alignItems:"center",justifyContent:"center"}});export default RadioDot;
1
+ "use strict";import{useEffect,useMemo,useRef}from"react";import{Animated,StyleSheet,View}from"react-native";import{createAnimatedValue,resolveRadioSize,useTheme}from"../../theme/index.js";import{smoothCorners}from"../../utils/corners.js";import{nativeDriver}from"../../utils/nativeDriver.js";import{jsx as _jsx}from"react/jsx-runtime";export const RadioDot=e=>{const{selected:t,color:r,disabled:o=!1,size:s="md",style:i,dotStyle:n}=e,a=useTheme(),d=useMemo(()=>buildStyles(),[]),m=r??a.colors.primary;let l,u;if("number"==typeof s)l=s,u=Math.round(s/2);else{const e=resolveRadioSize(a,s);l=e.outer,u=e.inner}const p=useRef(createAnimatedValue(t?1:0)).current;useEffect(()=>{const e=Animated.spring(p,{toValue:t?1:0,damping:a.motion.spring.snappy.damping,stiffness:a.motion.spring.snappy.stiffness,mass:a.motion.spring.snappy.mass,useNativeDriver:nativeDriver});return e.start(),()=>e.stop()},[t,p,a.motion.spring.snappy]);const c=p.interpolate({inputRange:[0,1],outputRange:[0,1]}),f=o?a.colors.border:t?m:a.colors.border;return _jsx(View,{style:[d.outer,{width:l,height:l,borderWidth:a.size.border,borderRadius:a.radius.pill,...smoothCorners,borderColor:f},i],children:_jsx(Animated.View,{style:[{width:u,height:u,borderRadius:a.radius.pill,...smoothCorners,backgroundColor:o?a.colors["text-disabled"]:m,opacity:p,transform:[{scale:c}]},n]})})};RadioDot.displayName="RadioDot";const buildStyles=()=>StyleSheet.create({outer:{alignItems:"center",justifyContent:"center"}});export default RadioDot;
@@ -1 +1 @@
1
- "use strict";import{forwardRef,useCallback,useMemo,useRef}from"react";import{Animated,Easing,Pressable,StyleSheet,View}from"react-native";import{useTheme}from"../../theme/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{resolveHaptic,triggerHaptic}from"../../utils/hapticUtils.js";import{hitSlopMarker}from"../../utils/hitSlop.js";import{Skeleton}from"../Skeleton/index.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const RATING_SIZES=["sm","md","lg"],RATING_TONES=["primary","success","warning","danger","info","neutral"];export const DEFAULT_RATING_LABELS=Object.freeze({value:(e,t)=>`${e} of ${t} stars`});const sizePxMap={sm:16,md:24,lg:32},resolveSize=e=>sizePxMap[e],PULSE_SCALE=1.2,toneColorFor=(e,t)=>{switch(t){case"success":return e.colors.success;case"warning":return e.colors.warning;case"danger":return e.colors.danger;case"info":return e.colors.info;case"neutral":return e.colors.neutral;default:return e.colors.primary}},clampToStep=(e,t,s)=>{const i=Math.max(0,Math.min(t,e)),a=Math.round(i/s)*s;return Number(a.toFixed(2))},Star=({index:e,filled:t,size:s,filledColor:i,emptyColor:a,scale:n})=>{const r=Math.max(0,Math.min(1,t-e));return _jsxs(Animated.View,{style:[starStyles.starWrap,{width:s,height:s,transform:[{scale:n}]}],children:[_jsx(Text,{variant:"body",style:[starStyles.glyph,{color:a,fontSize:s,lineHeight:s}],accessible:!1,children:"☆"}),r>0?_jsx(View,{pointerEvents:"none",style:[starStyles.fillClip,{width:s*r,height:s}],children:_jsx(Text,{variant:"body",style:[starStyles.glyph,{color:i,fontSize:s,lineHeight:s}],accessible:!1,children:"★"})}):null]})},Rating=forwardRef((e,t)=>{const{value:s,onChange:i,max:a=5,allowHalf:n=!0,readonly:r=!1,size:l="md",tone:o="warning",label:c,loading:m=!1,haptic:u,labels:d,accessibilityLabel:p,style:y,containerStyle:g,starContainerStyle:f,testID:h}=e;assertValidValue("Rating","size",e.size,RATING_SIZES),assertValidValue("Rating","tone",e.tone,RATING_TONES);const x=useMemo(()=>({...DEFAULT_RATING_LABELS,...d}),[d]),S=useTheme(),b=useMemo(()=>buildStyles(S),[S]),v=!r&&"function"==typeof i,w=n?.5:1,j=resolveSize(l),R=toneColorFor(S,o),_=S.colors.border,A=useRef(j),k=useCallback(e=>{A.current=e.nativeEvent.layout.width},[]),T=useRef(new Map),V=useMemo(()=>{const e=T.current,t=[];for(let s=0;s<a;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>=a&&e.delete(t);return t},[a]),C=S.settings.components.rating?.pulseOnPress??!1,E=useCallback(e=>{const t=V[e];t&&Animated.sequence([Animated.timing(t,{toValue:1.2,duration:S.motion.duration.fast,easing:Easing.bezier(...S.motion.ease["in-out"]),useNativeDriver:!0}),Animated.spring(t,{toValue:1,damping:S.motion.spring.bouncy.damping,stiffness:S.motion.spring.bouncy.stiffness,mass:S.motion.spring.bouncy.mass,useNativeDriver:!0})]).start()},[S.motion,V]),M=useCallback((e,t)=>{if(!v||!i)return;const s=clampToStep(e,a,w),n=resolveHaptic(u,"selection");n&&triggerHaptic(n),C&&"number"==typeof t&&E(t),i(s)},[v,i,a,w,E,u,C]),z=useCallback(e=>t=>{if(!v)return;const s=A.current||j,i=t.nativeEvent.locationX??s;let a;a=n&&i<s/2?e+.5:e+1,M(a,e)},[v,j,n,M]),N=useCallback(e=>{v&&("increment"===e.nativeEvent.actionName?M(s+w):"decrement"===e.nativeEvent.actionName&&M(s-w))},[v,s,w,M]),I=x.value(s,a),L=p??c??I,P=[];for(let e=0;e<a;e+=1){const t=V[e];if(!t)continue;const i=_jsx(Star,{index:e,filled:s,size:j,filledColor:R,emptyColor:_,scale:t},e);P.push(v?_jsx(Pressable,{onPress:z(e),onLayout:0===e?k:void 0,hitSlop:4,...hitSlopMarker(4),accessible:!1,style:b.starPress,children:i},e):_jsx(View,{onLayout:0===e?k:void 0,style:b.starPress,children:i},e))}const D=_jsxs(View,{style:[b.wrapper,g,y],ref:t,testID:h,children:[c?_jsx(Text,{variant:"bodySmall",color:"secondary",style:b.label,children:c}):null,_jsx(View,{style:[b.row,f],accessible:!0,accessibilityRole:v?"adjustable":"text",accessibilityLabel:L,accessibilityValue:v?{min:0,max:a,now:s,text:I}:void 0,accessibilityActions:v?[{name:"increment"},{name:"decrement"}]:void 0,onAccessibilityAction:v?N:void 0,children:P})]});return m?_jsx(RatingSkeleton,{...e}):D});Rating.displayName="Rating";const RatingSkeleton=({max:e=5,size:t="md",label:s,containerStyle:i,starContainerStyle:a,style:n})=>{const r=useTheme(),l=resolveSize(t),o=Math.max(1,e);return _jsxs(View,{style:[{alignItems:"flex-start"},i,n],accessibilityRole:"progressbar",accessibilityState:{busy:!0},"aria-busy":!0,children:[void 0!==s?_jsx(Skeleton,{shape:"text",width:80,height:14,style:{marginBottom:r.space.xs}}):null,_jsx(View,{style:[{flexDirection:"row"},a],children:Array.from({length:o}).map((e,t)=>_jsx(Skeleton,{width:l,height:l,radius:Math.round(.25*l),style:t<o-1?{marginRight:r.space.xs}:void 0},`sk-star-${t}`))})]})};RatingSkeleton.displayName="RatingSkeleton",Rating.Skeleton=RatingSkeleton;const starStyles=StyleSheet.create({starWrap:{position:"relative",alignItems:"flex-start",justifyContent:"center"},glyph:{textAlign:"left",includeFontPadding:!1},fillClip:{position:"absolute",top:0,left:0,overflow:"hidden"}}),buildStyles=e=>StyleSheet.create({wrapper:{flexDirection:"column"},row:{flexDirection:"row",alignItems:"center"},starPress:{marginRight:e.space.xs},label:{marginBottom:e.space.xs}});export{Rating};export default Rating;
1
+ "use strict";import{forwardRef,useCallback,useMemo,useRef}from"react";import{Animated,Easing,Pressable,StyleSheet,View}from"react-native";import{useTheme}from"../../theme/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{resolveHaptic,triggerHaptic}from"../../utils/hapticUtils.js";import{hitSlopMarker}from"../../utils/hitSlop.js";import{nativeDriver}from"../../utils/nativeDriver.js";import{Skeleton}from"../Skeleton/index.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const RATING_SIZES=["sm","md","lg"],RATING_TONES=["primary","success","warning","danger","info","neutral"];export const DEFAULT_RATING_LABELS=Object.freeze({value:(e,t)=>`${e} of ${t} stars`});const sizePxMap={sm:16,md:24,lg:32},resolveSize=e=>sizePxMap[e],PULSE_SCALE=1.2,toneColorFor=(e,t)=>{switch(t){case"success":return e.colors.success;case"warning":return e.colors.warning;case"danger":return e.colors.danger;case"info":return e.colors.info;case"neutral":return e.colors.neutral;case"primary":return e.colors.primary}},clampToStep=(e,t,s)=>{const i=Math.max(0,Math.min(t,e)),r=Math.round(i/s)*s;return Number(r.toFixed(2))},Star=({index:e,filled:t,size:s,filledColor:i,emptyColor:r,scale:a})=>{const n=Math.max(0,Math.min(1,t-e));return _jsxs(Animated.View,{style:[starStyles.starWrap,{width:s,height:s,transform:[{scale:a}]}],children:[_jsx(Text,{variant:"body",style:[starStyles.glyph,{color:r,fontSize:s,lineHeight:s}],accessible:!1,children:"☆"}),n>0?_jsx(View,{pointerEvents:"none",style:[starStyles.fillClip,{width:s*n,height:s}],children:_jsx(Text,{variant:"body",style:[starStyles.glyph,{color:i,fontSize:s,lineHeight:s}],accessible:!1,children:"★"})}):null]})},Rating=forwardRef((e,t)=>{const{value:s,onChange:i,max:r=5,allowHalf:a=!0,readonly:n=!1,size:o="md",tone:l="warning",label:c,loading:m=!1,haptic:u,labels:d,accessibilityLabel:p,style:y,containerStyle:g,starContainerStyle:f,testID:h}=e;assertValidValue("Rating","size",e.size,RATING_SIZES),assertValidValue("Rating","tone",e.tone,RATING_TONES);const x=useMemo(()=>({...DEFAULT_RATING_LABELS,...d}),[d]),S=useTheme(),b=useMemo(()=>buildStyles(S),[S]),v=!n&&"function"==typeof i,w=a?.5:1,j=resolveSize(o),R=toneColorFor(S,l),_=S.colors.border,A=useRef(j),k=useCallback(e=>{A.current=e.nativeEvent.layout.width},[]),T=useRef(new Map),V=useMemo(()=>{const e=T.current,t=[];for(let s=0;s<r;s+=1){let i=e.get(s);i||(i=new Animated.Value(1),e.set(s,i)),t.push(i)}for(const t of Array.from(e.keys()))t>=r&&e.delete(t);return t},[r]),C=S.settings.components.rating?.pulseOnPress??!1,E=useCallback(e=>{const t=V[e];if(!t)throw new Error(`Rating has no star at index ${e}; the pulse index must be below max.`);Animated.sequence([Animated.timing(t,{toValue:1.2,duration:S.motion.duration.fast,easing:Easing.bezier(...S.motion.ease["in-out"]),useNativeDriver:nativeDriver}),Animated.spring(t,{toValue:1,damping:S.motion.spring.bouncy.damping,stiffness:S.motion.spring.bouncy.stiffness,mass:S.motion.spring.bouncy.mass,useNativeDriver:nativeDriver})]).start()},[S.motion,V]),M=useCallback((e,t)=>{if(!v||!i)return;const s=clampToStep(e,r,w),a=resolveHaptic(u,"selection");a&&triggerHaptic(a),C&&"number"==typeof t&&E(t),i(s)},[v,i,r,w,E,u,C]),z=useCallback(e=>t=>{if(!v)return;const s=A.current||j,i=t.nativeEvent.locationX??s;let r;r=a&&i<s/2?e+.5:e+1,M(r,e)},[v,j,a,M]),N=useCallback(e=>{v&&("increment"===e.nativeEvent.actionName?M(s+w):"decrement"===e.nativeEvent.actionName&&M(s-w))},[v,s,w,M]),D=x.value(s,r),I=p??c??D,L=[];for(const[e,t]of V.entries()){const i=_jsx(Star,{index:e,filled:s,size:j,filledColor:R,emptyColor:_,scale:t},e);L.push(v?_jsx(Pressable,{onPress:z(e),onLayout:0===e?k:void 0,hitSlop:4,...hitSlopMarker(4),accessible:!1,style:b.starPress,children:i},e):_jsx(View,{onLayout:0===e?k:void 0,style:b.starPress,children:i},e))}const P=_jsxs(View,{style:[b.wrapper,g,y],ref:t,testID:h,children:[c?_jsx(Text,{variant:"bodySmall",color:"secondary",style:b.label,children:c}):null,_jsx(View,{style:[b.row,f],accessible:!0,accessibilityRole:v?"adjustable":"text",accessibilityLabel:I,accessibilityValue:v?{min:0,max:r,now:s,text:D}:void 0,accessibilityActions:v?[{name:"increment"},{name:"decrement"}]:void 0,onAccessibilityAction:v?N:void 0,children:L})]});return m?_jsx(RatingSkeleton,{...e}):P});Rating.displayName="Rating";const RatingSkeleton=({max:e=5,size:t="md",label:s,containerStyle:i,starContainerStyle:r,style:a})=>{const n=useTheme(),o=resolveSize(t),l=Math.max(1,e);return _jsxs(View,{style:[{alignItems:"flex-start"},i,a],accessibilityRole:"progressbar",accessibilityState:{busy:!0},"aria-busy":!0,children:[void 0!==s?_jsx(Skeleton,{shape:"text",width:80,height:14,style:{marginBottom:n.space.xs}}):null,_jsx(View,{style:[{flexDirection:"row"},r],children:Array.from({length:l}).map((e,t)=>_jsx(Skeleton,{width:o,height:o,radius:Math.round(.25*o),style:t<l-1?{marginRight:n.space.xs}:void 0},`sk-star-${t}`))})]})};RatingSkeleton.displayName="RatingSkeleton",Rating.Skeleton=RatingSkeleton;const starStyles=StyleSheet.create({starWrap:{position:"relative",alignItems:"flex-start",justifyContent:"center"},glyph:{textAlign:"left",includeFontPadding:!1},fillClip:{position:"absolute",top:0,left:0,overflow:"hidden"}}),buildStyles=e=>StyleSheet.create({wrapper:{flexDirection:"column"},row:{flexDirection:"row",alignItems:"center"},starPress:{marginRight:e.space.xs},label:{marginBottom:e.space.xs}});export{Rating};export default Rating;
@@ -1 +1 @@
1
- "use strict";import{forwardRef,useCallback,useMemo,useState}from"react";import{Pressable,StyleSheet,TextInput,View}from"react-native";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";export const DEFAULT_RICH_TEXT_EDITOR_LABELS=Object.freeze({bold:"Bold",italic:"Italic",strikethrough:"Strikethrough",code:"Inline code",link:"Link",heading1:"Heading 1",heading2:"Heading 2",bulletList:"Bulleted list",numberedList:"Numbered list",quote:"Quote"});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:l=DEFAULT_ACTIONS,disabled:r=!1,loading:n=!1,minHeight:a=DEFAULT_MIN_HEIGHT,autoFocus:d=!1,accessibilityLabel:c,haptic:h,labels:u,style:b,toolbarStyle:m,inputStyle:p,testID:x}=e,g=useTheme(),T=useMemo(()=>buildStyles(g),[g]),S=useMemo(()=>u?{...DEFAULT_RICH_TEXT_EDITOR_LABELS,...u}:DEFAULT_RICH_TEXT_EDITOR_LABELS,[u]),y=o??"",[_,k]=useState({start:0,end:0}),[f,L]=useState(!1),[I,E]=useState(null),j=useCallback(e=>{k(e.nativeEvent.selection),E(null)},[]),C=useCallback(e=>{E(null),i?.(e)},[i]),H=useCallback(e=>{if(r)return;const t=resolveHaptic(h,"selection");t&&triggerHaptic(t);const o=applyMarkdownAction({text:y,selection:normalizeSelection(_,y.length)},e);k(o.selection),E(o.selection),i?.(o.text)},[r,h,i,_,y]);return n?_jsx(RichTextEditorSkeleton,{actionCount:l.length,minHeight:a,style:b,testID:x}):_jsxs(View,{testID:x,style:[T.container,{borderColor:f?g.colors["focus-ring"]:g.colors.border,opacity:r?.55:1},b],children:[_jsx(View,{style:[T.toolbar,m],children:l.map(e=>_jsx(ToolbarButton,{action:e,label:S[e],disabled:r,onPress:H,styles:T,theme:g,testID:x?`${x}-${e}`:void 0},e))}),_jsx(TextInput,{ref:t,value:y,onChangeText:C,onSelectionChange:j,onFocus:()=>L(!0),onBlur:()=>L(!1),selection:I??void 0,editable:!r,autoFocus:d,multiline:!0,textAlignVertical:"top",placeholder:s,placeholderTextColor:g.colors["text-subtle"],accessibilityLabel:c,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:l,testID:r})=>{const n={color:o?l.colors["text-disabled"]:l.colors["text-body"]};return"bold"===e&&(n.fontWeight=l.weight.bold),"italic"===e&&(n.fontStyle="italic"),"strikethrough"===e&&(n.textDecorationLine="line-through"),_jsx(Pressable,{onPress:()=>i(e),disabled:o,accessibilityRole:"button",accessibilityLabel:t,accessibilityState:{disabled:o},"aria-disabled":o,hitSlop:4,...hitSlopMarker(4),testID:r,style:({pressed:e})=>[s.button,{backgroundColor:e?l.colors["surface-pressed"]:l.colors["bg-subtle"]}],children:_jsx(Text,{variant:"body",maxFontSizeMultiplier:Math.min(l.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(),l=useMemo(()=>buildStyles(s),[s]),r=Array.from({length:Math.max(1,e)},(e,t)=>t);return _jsxs(View,{testID:i,style:[l.container,o],children:[_jsx(View,{style:l.toolbar,children:r.map(e=>_jsx(Skeleton,{width:34,height:30,radius:"sm"},e))}),_jsxs(View,{style:[l.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{forwardRef,useCallback,useMemo,useState}from"react";import{Pressable,StyleSheet,TextInput,View}from"react-native";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";export const DEFAULT_RICH_TEXT_EDITOR_LABELS=Object.freeze({bold:"Bold",italic:"Italic",strikethrough:"Strikethrough",code:"Inline code",link:"Link",heading1:"Heading 1",heading2:"Heading 2",bulletList:"Bulleted list",numberedList:"Numbered list",quote:"Quote"});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:l=DEFAULT_ACTIONS,disabled:r=!1,loading:n=!1,minHeight:a=DEFAULT_MIN_HEIGHT,autoFocus:d=!1,accessibilityLabel:c,haptic:h,labels:u,style:b,toolbarStyle:m,inputStyle:p,testID:x}=e,g=useTheme(),T=useMemo(()=>buildStyles(g),[g]),S=useMemo(()=>u?{...DEFAULT_RICH_TEXT_EDITOR_LABELS,...u}:DEFAULT_RICH_TEXT_EDITOR_LABELS,[u]),y=o??"",[_,k]=useState({start:0,end:0}),[f,L]=useState(!1),[I,E]=useState(null),j=useCallback(e=>{k(e.nativeEvent.selection),E(null)},[]),C=useCallback(e=>{E(null),i?.(e)},[i]),H=useCallback(e=>{if(r)return;const t=resolveHaptic(h,"selection");t&&triggerHaptic(t);const o=applyMarkdownAction({text:y,selection:normalizeSelection(_,y.length)},e);k(o.selection),E(o.selection),i?.(o.text)},[r,h,i,_,y]);return n?_jsx(RichTextEditorSkeleton,{actionCount:l.length,minHeight:a,style:b,testID:x}):_jsxs(View,{testID:x,style:[T.container,{borderColor:f?g.colors["focus-ring"]:g.colors.border,opacity:r?.55:1},b],children:[_jsx(View,{style:[T.toolbar,m],children:l.map(e=>_jsx(ToolbarButton,{action:e,label:S[e],disabled:r,onPress:H,styles:T,theme:g,testID:x?`${x}-${e}`:void 0},e))}),_jsx(TextInput,{ref:t,value:y,onChangeText:C,onSelectionChange:j,onFocus:()=>L(!0),onBlur:()=>L(!1),selection:I??void 0,editable:!r,autoFocus:d,multiline:!0,textAlignVertical:"top",placeholder:s,placeholderTextColor:g.colors["text-subtle"],accessibilityLabel:c,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:l,testID:r})=>{const n={color:o?l.colors["text-disabled"]:l.colors["text-body"],..."bold"===e?{fontWeight:l.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:r,style:({pressed:e})=>[s.button,{backgroundColor:e?l.colors["surface-pressed"]:l.colors["bg-subtle"]}],children:_jsx(Text,{variant:"body",maxFontSizeMultiplier:Math.min(l.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(),l=useMemo(()=>buildStyles(s),[s]),r=Array.from({length:Math.max(1,e)},(e,t)=>t);return _jsxs(View,{testID:i,style:[l.container,o],children:[_jsx(View,{style:l.toolbar,children:r.map(e=>_jsx(Skeleton,{width:34,height:30,radius:"sm"},e))}),_jsxs(View,{style:[l.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";const INLINE_MARKERS={bold:"**",italic:"*",strikethrough:"~~",code:"`"},WHOLE_LINK=/^\[([^\]]*)\]\(([^)\s]*)\)$/,LINK_URL_PLACEHOLDER="url",BLOCK_RULES={heading1:{has:t=>/^#\s/.test(t),prefix:()=>"# "},heading2:{has:t=>/^##\s/.test(t),prefix:()=>"## "},bulletList:{has:t=>/^[-*+]\s/.test(t),prefix:()=>"- "},numberedList:{has:t=>/^\d+[.)]\s/.test(t),prefix:t=>`${t+1}. `},quote:{has:t=>/^>\s?/.test(t),prefix:()=>"> "}},ANY_BLOCK_PREFIX=/^(?:#{1,6}\s+|[-*+]\s+|\d+[.)]\s+|>\s?)/,isBlockAction=t=>t in BLOCK_RULES,clamp=(t,e)=>!Number.isFinite(t)||t<0?0:Math.min(Math.trunc(t),e);export const normalizeSelection=(t,e)=>{const s=clamp(t.start,e),n=clamp(t.end,e);return{start:Math.min(s,n),end:Math.max(s,n)}};const caret=t=>({start:t,end:t}),applyInlineMarker=(t,e,s)=>{const{start:n,end:l}=e,i=t.slice(n,l),r=s.length,c="*"===s;if(i.length>=2*r&&i.startsWith(s)&&i.endsWith(s)&&!(c&&i.startsWith("**")&&i.endsWith("**"))){const e=i.slice(r,i.length-r);return{text:t.slice(0,n)+e+t.slice(l),selection:{start:n,end:n+e.length}}}const a=t.slice(Math.max(0,n-r),n),o=t.slice(l,l+r);if(n>=r&&a===s&&o===s&&!(c&&"**"===t.slice(Math.max(0,n-2),n)))return{text:t.slice(0,n-r)+i+t.slice(l+r),selection:{start:n-r,end:l-r}};return{text:t.slice(0,n)+s+i+s+t.slice(l),selection:n===l?caret(n+r):{start:n+r,end:l+r}}},applyLink=(t,e)=>{const{start:s,end:n}=e,l=t.slice(s,n),i=WHOLE_LINK.exec(l);if(i){const e=i[1];return{text:t.slice(0,s)+e+t.slice(n),selection:{start:s,end:s+e.length}}}const r=`[${l}](url)`,c=t.slice(0,s)+r+t.slice(n);if(s===n)return{text:c,selection:caret(s+1)};const a=s+l.length+3;return{text:c,selection:{start:a,end:a+3}}},applyBlockPrefix=(t,e,s)=>{const n=BLOCK_RULES[s],l=t.split("\n"),i=[];let r=0;for(const t of l)i.push(r),r+=t.length+1;const lineIndexAt=t=>{let e=0;for(let s=0;s<l.length;s+=1)i[s]<=t&&(e=s);return e},c=lineIndexAt(e.start),a=lineIndexAt(e.end),o=l.slice(c,a+1),h=o.every(t=>n.has(t)),p=o.map((t,e)=>h?t.replace(ANY_BLOCK_PREFIX,""):n.prefix(e)+t.replace(ANY_BLOCK_PREFIX,"")),d=p[0].length-o[0].length,x=p.reduce((t,e,s)=>t+(e.length-o[s].length),0),L=[...l.slice(0,c),...p,...l.slice(a+1)].join("\n");return{text:L,selection:normalizeSelection({start:Math.max(i[c],e.start+d),end:e.end+x},L.length)}};export const applyMarkdownAction=(t,e)=>{const s=t.text??"",n=normalizeSelection(t.selection,s.length);return isBlockAction(e)?applyBlockPrefix(s,n,e):"link"===e?applyLink(s,n):applyInlineMarker(s,n,INLINE_MARKERS[e])};
1
+ "use strict";const INLINE_MARKERS={bold:"**",italic:"*",strikethrough:"~~",code:"`"},WHOLE_LINK=/^\[([^\]]*)\]\(([^)\s]*)\)$/,LINK_URL_PLACEHOLDER="url",BLOCK_RULES={heading1:{has:e=>/^#\s/.test(e),prefix:()=>"# "},heading2:{has:e=>/^##\s/.test(e),prefix:()=>"## "},bulletList:{has:e=>/^[-*+]\s/.test(e),prefix:()=>"- "},numberedList:{has:e=>/^\d+[.)]\s/.test(e),prefix:e=>`${e+1}. `},quote:{has:e=>/^>\s?/.test(e),prefix:()=>"> "}},ANY_BLOCK_PREFIX=/^(?:#{1,6}\s+|[-*+]\s+|\d+[.)]\s+|>\s?)/,isBlockAction=e=>e in BLOCK_RULES,clamp=(e,t)=>!Number.isFinite(e)||e<0?0:Math.min(Math.trunc(e),t);export const normalizeSelection=(e,t)=>{const s=clamp(e.start,t),n=clamp(e.end,t);return{start:Math.min(s,n),end:Math.max(s,n)}};const caret=e=>({start:e,end:e}),applyInlineMarker=(e,t,s)=>{const{start:n,end:r}=t,i=e.slice(n,r),l=s.length,a="*"===s;if(i.length>=2*l&&i.startsWith(s)&&i.endsWith(s)&&!(a&&i.startsWith("**")&&i.endsWith("**"))){const t=i.slice(l,i.length-l);return{text:e.slice(0,n)+t+e.slice(r),selection:{start:n,end:n+t.length}}}const c=e.slice(Math.max(0,n-l),n),o=e.slice(r,r+l);if(n>=l&&c===s&&o===s&&!(a&&"**"===e.slice(Math.max(0,n-2),n)))return{text:e.slice(0,n-l)+i+e.slice(r+l),selection:{start:n-l,end:r-l}};return{text:e.slice(0,n)+s+i+s+e.slice(r),selection:n===r?caret(n+l):{start:n+l,end:r+l}}},applyLink=(e,t)=>{const{start:s,end:n}=t,r=e.slice(s,n),i=WHOLE_LINK.exec(r);if(i){const t=i[1];if(void 0===t)throw new Error("WHOLE_LINK always captures the label in group 1 when it matches");return{text:e.slice(0,s)+t+e.slice(n),selection:{start:s,end:s+t.length}}}const l=`[${r}](url)`,a=e.slice(0,s)+l+e.slice(n);if(s===n)return{text:a,selection:caret(s+1)};const c=s+r.length+3;return{text:a,selection:{start:c,end:c+3}}},applyBlockPrefix=(e,t,s)=>{const n=BLOCK_RULES[s],r=e.split("\n"),i=[];let l=0;for(const e of r)i.push(l),l+=e.length+1;const lineIndexAt=e=>{let t=0;for(const[s,n]of i.entries())n<=e&&(t=s);return t},a=lineIndexAt(t.start),c=lineIndexAt(t.end),o=r.slice(a,c+1),h=o.every(e=>n.has(e)),p=o.map((e,t)=>({before:e,after:h?e.replace(ANY_BLOCK_PREFIX,""):n.prefix(t)+e.replace(ANY_BLOCK_PREFIX,"")})),f=p.map(e=>e.after),[d]=p;if(void 0===d)throw new Error("applyBlockPrefix: the selection always covers at least one line");const x=i[a];if(void 0===x)throw new Error("applyBlockPrefix: the first selected line always has an offset");const L=d.after.length-d.before.length,u=p.reduce((e,t)=>e+(t.after.length-t.before.length),0),E=[...r.slice(0,a),...f,...r.slice(c+1)].join("\n");return{text:E,selection:normalizeSelection({start:Math.max(x,t.start+L),end:t.end+u},E.length)}};export const applyMarkdownAction=(e,t)=>{const s=e.text??"",n=normalizeSelection(e.selection,s.length);return isBlockAction(t)?applyBlockPrefix(s,n,t):"link"===t?applyLink(s,n):applyInlineMarker(s,n,INLINE_MARKERS[t])};
@@ -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{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{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}}];export const DEFAULT_SCANNER_OVERLAY_LABELS=Object.freeze({hint:"Point the camera at the code",found:"Code found",invalid:"This code cannot be used. Try another.",torchOn:"Turn torch on",torchOff:"Turn torch off",manualEntry:"Enter code instead",gallery:"Upload from gallery",noPermissionTitle:"Camera access is off",noPermissionMessage:"Allow camera access to scan a code.",permissionAction:"Allow camera access",noCameraTitle:"No camera found",noCameraMessage:"This device has no camera available. You can still add the code another way."});const ScannerOverlay=forwardRef((e,t)=>{assertValidValue("ScannerOverlay","state",e.state,["scanning","found","invalid","noPermission","noCamera"]);const{children:o,state:n="scanning",helperText:i,labels:s,torch:a=!1,onTorchChange:r,onManualEntry:l,onGallery:c,onPermissionAction:d,frameSize:m=DEFAULT_FRAME,haptic:u,style:h,testID:f}=e,p=useTheme(),g=useSafeAreaInsets(),y=useReducedMotion(),x=useMemo(()=>buildStyles(p),[p]),b=useMemo(()=>({...DEFAULT_SCANNER_OVERLAY_LABELS,...s}),[s]),j=i??b.hint,[S,v]=useState({width:0,height:0}),[A,E]=useState(0),_="scanning"===n||"found"===n||"invalid"===n,w=useRef(createAnimatedValue(1)).current,V=p.motion.duration.slower,C=p.motion.duration.default;useEffect(()=>{if(w.setValue(1),y)return;let e;return"scanning"===n&&V>0?e=Animated.loop(Animated.sequence([Animated.timing(w,{toValue:1.03,duration:2*V,useNativeDriver:!0}),Animated.timing(w,{toValue:1,duration:2*V,useNativeDriver:!0})])):"found"===n&&C>0&&(w.setValue(1.08),e=Animated.timing(w,{toValue:1,duration:C,useNativeDriver:!0})),e?.start(),()=>e?.stop()},[n,y,V,C,w]);const R=useRef(n);useEffect(()=>{R.current!==n&&(R.current=n,!1!==u&&("found"===n?triggerHaptic("notificationSuccess"):"invalid"===n&&triggerHaptic("notificationError")))},[n,u]);const{found:M,invalid:L}=b,{noPermissionTitle:I,noPermissionMessage:P}=b,{noCameraTitle:k,noCameraMessage:N}=b;useEffect(()=>{switch(n){case"scanning":announce(j);break;case"found":announce(M);break;case"invalid":announce(L,{polite:!1});break;case"noPermission":announce(`${I}. ${P}`);break;case"noCamera":announce(`${k}. ${N}`)}},[n,j,M,L,I,P,k,N]);const O=Math.max(240,Math.min(m,S.width-2*p.space.xl)),F=(S.width-O)/2,B=Math.max(p.space.md,(S.height-A-O)/2),D=S.width>0&&S.height>0,H={borderColor:"found"===n?p.colors.success:"invalid"===n?p.colors.danger:p.colors["on-scrim"],width:32,height:32},z="found"===n||"invalid"===n?_jsx(View,{style:[x.pill,{backgroundColor:"found"===n?p.colors.success:p.colors.danger}],children:_jsx(Text,{variant:"bodySmall",weight:"semibold",align:"center",style:{color:"found"===n?p.colors["on-success"]:p.colors["on-danger"]},children:"found"===n?M:L})}):_jsx(Text,{variant:"bodySmall",align:"center",style:{color:p.colors["on-scrim"]},children:j}),W=_&&null!=r,U=_?"glass":"outline";return _jsxs(View,{ref:t,testID:f,onLayout:e=>{const{width:t,height:o}=e.nativeEvent.layout;v(e=>e.width===t&&e.height===o?e:{width:t,height:o})},style:[x.root,!_&&{backgroundColor:p.colors.bg},h],children:[_?_jsx(View,{style:StyleSheet.absoluteFill,children:o}):null,_&&D?_jsx(_Fragment,{children:_jsxs(View,{pointerEvents:"none",style:StyleSheet.absoluteFill,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:[_jsx(View,{style:[x.scrim,{left:0,right:0,top:0,height:B}]}),_jsx(View,{style:[x.scrim,{left:0,right:0,top:B+O,bottom:0}]}),_jsx(View,{style:[x.scrim,{left:0,width:F,top:B,height:O}]}),_jsx(View,{style:[x.scrim,{left:F+O,right:0,top:B,height:O}]}),_jsx(Animated.View,{style:{position:"absolute",left:F,top:B,width:O,height:O,transform:[{scale:w}]},children:CORNERS.map(e=>_jsx(View,{style:[x.mark,H,e.style]},e.key))})]})}):null,_?null:_jsx(View,{style:x.panel,children:_jsx(EmptyState,{fill:!0,icon:_jsx(AppIcon,{name:"noPermission"===n?"camera":"camera-slash",size:48,color:p.colors["text-subtle"]}),title:"noPermission"===n?I:k,description:"noPermission"===n?P:N,action:"noPermission"===n&&d?{label:b.permissionAction,onPress:d}:void 0})}),_jsxs(View,{pointerEvents:"box-none",onLayout:e=>{const{height:t}=e.nativeEvent.layout;E(e=>e===t?e:t)},style:[x.bar,{paddingBottom:Math.max(g.bottom,p.space.md)}],children:[_&&D?_jsx(View,{pointerEvents:"none",style:x.message,children:z}):null,_jsxs(View,{style:x.actions,children:[W?_jsx(IconButton,{icon:a?"flash":"flash-slash",variant:"glass",size:"lg",active:a,haptic:u,accessibilityLabel:a?b.torchOff:b.torchOn,onPress:()=>r?.(!a)}):null,c?_jsx(Button,{label:b.gallery,leftIcon:"gallery",variant:U,tone:"neutral",size:"lg",haptic:u,onPress:c}):null,l?_jsx(Button,{label:b.manualEntry,leftIcon:"keyboard",variant:U,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{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{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}}];export const DEFAULT_SCANNER_OVERLAY_LABELS=Object.freeze({hint:"Point the camera at the code",found:"Code found",invalid:"This code cannot be used. Try another.",torchOn:"Turn torch on",torchOff:"Turn torch off",manualEntry:"Enter code instead",gallery:"Upload from gallery",noPermissionTitle:"Camera access is off",noPermissionMessage:"Allow camera access to scan a code.",permissionAction:"Allow camera access",noCameraTitle:"No camera found",noCameraMessage:"This device has no camera available. You can still add the code another way."});const ScannerOverlay=forwardRef((e,t)=>{assertValidValue("ScannerOverlay","state",e.state,["scanning","found","invalid","noPermission","noCamera"]);const{children:o,state:n,helperText:i,labels:s,torch:r=!1,onTorchChange:a,onManualEntry:l,onGallery:c,onPermissionAction:d,frameSize:m=DEFAULT_FRAME,haptic:u,style:h,testID:f}=e,p=n??"scanning",g=useTheme(),y=useSafeAreaInsets(),x=useReducedMotion(),b=useMemo(()=>buildStyles(g),[g]),v=useMemo(()=>({...DEFAULT_SCANNER_OVERLAY_LABELS,...s}),[s]),j=i??v.hint,[S,A]=useState({width:0,height:0}),[E,_]=useState(0),w="scanning"===p||"found"===p||"invalid"===p,V=useRef(createAnimatedValue(1)).current,C=g.motion.duration.slower,R=g.motion.duration.default;useEffect(()=>{if(V.setValue(1),x)return;let e;return"scanning"===p&&C>0?e=Animated.loop(Animated.sequence([Animated.timing(V,{toValue:1.03,duration:2*C,useNativeDriver:nativeDriver}),Animated.timing(V,{toValue:1,duration:2*C,useNativeDriver:nativeDriver})])):"found"===p&&R>0&&(V.setValue(1.08),e=Animated.timing(V,{toValue:1,duration:R,useNativeDriver:nativeDriver})),e?.start(),()=>e?.stop()},[p,x,C,R,V]);const M=useRef(p);useEffect(()=>{M.current!==p&&(M.current=p,!1!==u&&("found"===p?triggerHaptic("notificationSuccess"):"invalid"===p&&triggerHaptic("notificationError")))},[p,u]);const{found:L,invalid:I}=v,{noPermissionTitle:P,noPermissionMessage:k}=v,{noCameraTitle:D,noCameraMessage:N}=v;useEffect(()=>{switch(p){case"scanning":announce(j);break;case"found":announce(L);break;case"invalid":announce(I,{polite:!1});break;case"noPermission":announce(`${P}. ${k}`);break;case"noCamera":announce(`${D}. ${N}`)}},[p,j,L,I,P,k,D,N]);const O=Math.max(240,Math.min(m,S.width-2*g.space.xl)),F=(S.width-O)/2,B=Math.max(g.space.md,(S.height-E-O)/2),H=S.width>0&&S.height>0,z={borderColor:"found"===p?g.colors.success:"invalid"===p?g.colors.danger:g.colors["on-scrim"],width:32,height:32},W="found"===p||"invalid"===p?_jsx(View,{style:[b.pill,{backgroundColor:"found"===p?g.colors.success:g.colors.danger}],children:_jsx(Text,{variant:"bodySmall",weight:"semibold",align:"center",style:{color:"found"===p?g.colors["on-success"]:g.colors["on-danger"]},children:"found"===p?L:I})}):_jsx(Text,{variant:"bodySmall",align:"center",style:{color:g.colors["on-scrim"]},children:j}),U=w&&null!=a,$=w?"glass":"outline";return _jsxs(View,{ref:t,testID:f,onLayout:e=>{const{width:t,height:o}=e.nativeEvent.layout;A(e=>e.width===t&&e.height===o?e:{width:t,height:o})},style:[b.root,!w&&{backgroundColor:g.colors.bg},h],children:[w?_jsx(View,{style:StyleSheet.absoluteFill,children:o}):null,w&&H?_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:B}]}),_jsx(View,{style:[b.scrim,{left:0,right:0,top:B+O,bottom:0}]}),_jsx(View,{style:[b.scrim,{left:0,width:F,top:B,height:O}]}),_jsx(View,{style:[b.scrim,{left:F+O,right:0,top:B,height:O}]}),_jsx(Animated.View,{style:{position:"absolute",left:F,top:B,width:O,height:O,transform:[{scale:V}]},children:CORNERS.map(e=>_jsx(View,{style:[b.mark,z,e.style]},e.key))})]})}):null,w?null:_jsx(View,{style:b.panel,children:_jsx(EmptyState,{fill:!0,icon:_jsx(AppIcon,{name:"noPermission"===p?"camera":"camera-slash",size:48,color:g.colors["text-subtle"]}),title:"noPermission"===p?P:D,description:"noPermission"===p?k:N,action:"noPermission"===p&&d?{label:v.permissionAction,onPress:d}:void 0})}),_jsxs(View,{pointerEvents:"box-none",onLayout:e=>{const{height:t}=e.nativeEvent.layout;_(e=>e===t?e:t)},style:[b.bar,{paddingBottom:Math.max(y.bottom,g.space.md)}],children:[w&&H?_jsx(View,{pointerEvents:"none",style:b.message,children:W}):null,_jsxs(View,{style:b.actions,children:[U?_jsx(IconButton,{icon:r?"flash":"flash-slash",variant:"glass",size:"lg",active:r,haptic:u,accessibilityLabel:r?v.torchOff:v.torchOn,onPress:()=>a?.(!r)}):null,c?_jsx(Button,{label:v.gallery,leftIcon:"gallery",variant:$,tone:"neutral",size:"lg",haptic:u,onPress:c}):null,l?_jsx(Button,{label:v.manualEntry,leftIcon:"keyboard",variant:$,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 +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{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"];default:return e.colors["info-text"]}},SegmentedControl=forwardRef((e,t)=>{const{segments:s,label:r,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,containerStyle:y,segmentStyle:S,selectedIndicatorStyle:v,textStyle:w,labelStyle:C,testID:j}=e;assertValidValue("SegmentedControl","size",e.size,["sm","md","lg"]),assertValidValue("SegmentedControl","tone",e.tone,["primary","success","warning","danger","info","neutral"]),assertValidValue("SegmentedControl","variant",e.variant,["underline","pills","segmented"]);const[V,k]=useControllableState({value:o,defaultValue:n??s[0]?.value,onChange:a}),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,A="pills"===h,E=R?F.space[I["track-padding"]]:0,H=Math.ceil(1.25*_.text)*(z-1),q=I["underline-height"],D=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-E,0),N=B??F.radius.pill,G=B??F.radius.none,[O,X]=useState([]),J=useRef(createAnimatedValue(0)).current,K=Math.max(0,s.findIndex(e=>e.value===V)),Q=O[K],U=Q?.x,Y=useCallback(e=>{const t=F.motion.spring.snappy,s=Animated.spring(J,{toValue:e,damping:t.damping,stiffness:t.stiffness,mass:t.mass,overshootClamping:!0,useNativeDriver:!0});return s.start(),s},[F.motion.spring.snappy,J]);useEffect(()=>{X(e=>e.length===s.length||0===e.length?e:[])},[s.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:s,width:r}=t.nativeEvent.layout;X(t=>{const i=t[e];if(i&&i.x===s&&i.width===r)return t;const l=t.slice();return l[e]={x:s,width:r},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:A?F.colors["primary-soft"]:F.colors.primary,se=R?P:A?N:G,re=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(r),ue=oe?l:i,me=hasFieldText(ue),he=_jsxs(View,{ref:t,accessibilityRole:"radiogroup",accessibilityLabel:b??("string"==typeof r?r:void 0),testID:j,style:[L.track,{...M?{minHeight:_.height+H}:{height:_.height},opacity:u?.55:1,alignSelf:c?"stretch":"flex-start"},R?{borderRadius:W,...smoothCorners,backgroundColor:le.active?"transparent":ie,padding:E}:T?{borderBottomColor:ne?ae:F.colors["border-subtle"],borderBottomWidth:StyleSheet.hairlineWidth}:null,y,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*E}:A?{top:D,bottom:D,left:D}:{bottom:0,height:q},{width:A?Math.max(Q.width-2*D,0):Q.width,borderRadius:se,...smoothCorners,backgroundColor:te,transform:[{translateX:J}]},v]}):null,s.map((e,t)=>{const s=e.value===V,r=s?re:F.colors["text-subtle"],i=renderSlotIcon(e.icon,{color:r,size:_.icon,selected:s,disabled:u});return _jsxs(Pressable,{onPress:()=>ee(e),onLayout:e=>$(t,e),disabled:u,accessibilityRole:"radio",accessibilityLabel:e.label,accessibilityState:{checked:s,selected:s,disabled:u},"aria-checked":s,"aria-disabled":u,style:({pressed:e})=>[L.segment,M?L.segmentMultiline:null,{paddingHorizontal:_["padding-x"],opacity:e&&!s?.7:1},S],children:[i?_jsx(View,{style:L.segmentIcon,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:i}):null,_jsx(Text,{variant:"label",weight:s?"semibold":"medium",style:[L.segmentLabel,M?L.segmentLabelMultiline:null,{color:r,fontSize:_.text},w,C],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:r}):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{forwardRef,useCallback,useEffect,useMemo,useRef,useState}from"react";import{Animated,Pressable,StyleSheet,View}from"react-native";import{useControllableState}from"../../hooks/index.js";import{createAnimatedValue,resolveSegmentedControlSize,useTheme}from"../../theme/index.js";import{resolveHaptic,triggerHaptic}from"../../utils/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{smoothCorners}from"../../utils/corners.js";import{nativeDriver}from"../../utils/nativeDriver.js";import{renderSlotIcon}from"../AppIcon/slotIcon.js";import{FieldLabel,FieldMessage,hasFieldText}from"../FieldBase/index.js";import{SquircleFill,useSquircle}from"../SquircleFill/SquircleFill.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const LABEL_LINE_HEIGHT_RATIO=1.25,activeInkFor=(e,t)=>{switch(t){case"primary":return e.colors.primary;case"neutral":return e.colors["text-body"];case"success":return e.colors["success-text"];case"warning":return e.colors["warning-text"];case"danger":return e.colors["danger-text"];case"info":return e.colors["info-text"]}},SegmentedControl=forwardRef((e,t)=>{const{segments:r,label:i,helperText:s,error:l,value:o,defaultValue:n,onChange:a,size:d="md",fullWidth:c=!0,disabled:u=!1,tone:m="primary",variant:h="segmented",radius:g,labelLines:p=1,haptic:f,accessibilityLabel:b,style:x,containerStyle:y,segmentStyle:S,selectedIndicatorStyle:v,textStyle:w,labelStyle:C,testID:j}=e;assertValidValue("SegmentedControl","size",e.size,["sm","md","lg"]),assertValidValue("SegmentedControl","tone",e.tone,["primary","success","warning","danger","info","neutral"]),assertValidValue("SegmentedControl","variant",e.variant,["underline","pills","segmented"]);const[V]=r;if(void 0===V)throw new Error("SegmentedControl needs at least one segment");const[k,F]=useControllableState({value:o,defaultValue:n??V.value,onChange:a}),I=useTheme(),L=I.components["segmented-control"],_=useMemo(()=>buildStyles(I),[I]),z=useMemo(()=>resolveSegmentedControlSize(I,d),[I,d]),M=p>=2?2:1,R=M>1,T="segmented"===h,E="underline"===h,A="pills"===h,D=T?I.space[L["track-padding"]]:0,H=Math.ceil(1.25*z.text)*(M-1),q=L["underline-height"],B=I.space[L["pill-inset"]],W="number"==typeof g?g:g?I.radius[g]:void 0,P=W??I.radius.md,N=void 0===W?I.radius.sm:Math.max(W-D,0),G=W??I.radius.pill,O=W??I.radius.none,[X,J]=useState([]),K=useRef(createAnimatedValue(0)).current,Q=Math.max(0,r.findIndex(e=>e.value===k)),U=X[Q],Y=U?.x,Z=useCallback(e=>{const t=I.motion.spring.snappy,r=Animated.spring(K,{toValue:e,damping:t.damping,stiffness:t.stiffness,mass:t.mass,overshootClamping:!0,useNativeDriver:nativeDriver});return r.start(),r},[I.motion.spring.snappy,K]);useEffect(()=>{J(e=>e.length===r.length||0===e.length?e:[])},[r.length]);const $=useRef(null);useEffect(()=>{if(void 0===Y)return;const e=null!==$.current&&$.current!==Q;if($.current=Q,!e)return void K.setValue(Y);const t=Z(Y);return()=>t.stop()},[Q,Y,Z,K]);const ee=useCallback((e,t)=>{const{x:r,width:i}=t.nativeEvent.layout;J(t=>{const s=t[e];if(s&&s.x===r&&s.width===i)return t;const l=t.slice();return l[e]={x:r,width:i},l})},[]),te=useCallback(e=>{if(u)return;if(e.value===k)return;const t=resolveHaptic(f,"selection");t&&triggerHaptic(t),F(e.value)},[u,F,k,f]),re=T?I.colors.thumb:A?I.colors["primary-soft"]:I.colors.primary,ie=T?N:A?G:O,se=activeInkFor(I,m),le=I.colors["bg-muted"],oe=useSquircle(T,P),ne=!0===l||hasFieldText(l),ae=ne&&!u,de=I.colors["field-border-error"],ce=I.size.border,ue=hasFieldText(i),me=ne?l:s,he=hasFieldText(me),ge=_jsxs(View,{ref:t,accessibilityRole:"radiogroup",accessibilityLabel:b??("string"==typeof i?i:void 0),testID:j,style:[_.track,{...R?{minHeight:z.height+H}:{height:z.height},opacity:u?.55:1,alignSelf:c?"stretch":"flex-start"},T?{borderRadius:P,...smoothCorners,backgroundColor:oe.active?"transparent":le,padding:D}:E?{borderBottomColor:ae?de:I.colors["border-subtle"],borderBottomWidth:StyleSheet.hairlineWidth}:null,y,x],onLayout:oe.onLayout,children:[oe.active&&oe.size?_jsx(SquircleFill,{width:oe.size.width,height:oe.size.height,radius:P,fill:le,stroke:ae?de:void 0,strokeWidth:ce}):null,_jsxs(View,{style:_.row,children:[U?_jsx(Animated.View,{pointerEvents:"none",style:[_.thumb,T?R?{top:0,bottom:0}:{top:0,height:z.height-2*D}:A?{top:B,bottom:B,left:B}:{bottom:0,height:q},{width:A?Math.max(U.width-2*B,0):U.width,borderRadius:ie,...smoothCorners,backgroundColor:re,transform:[{translateX:K}]},v]}):null,r.map((e,t)=>{const r=e.value===k,i=r?se:I.colors["text-subtle"],s=renderSlotIcon(e.icon,{color:i,size:z.icon,selected:r,disabled:u});return _jsxs(Pressable,{onPress:()=>te(e),onLayout:e=>ee(t,e),disabled:u,accessibilityRole:"radio",accessibilityLabel:e.label,accessibilityState:{checked:r,selected:r,disabled:u},"aria-checked":r,"aria-disabled":u,style:({pressed:e})=>[_.segment,R?_.segmentMultiline:null,{paddingHorizontal:z["padding-x"],opacity:e&&!r?.7:1},S],children:[s?_jsx(View,{style:_.segmentIcon,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:s}):null,_jsx(Text,{variant:"label",weight:r?"semibold":"medium",style:[_.segmentLabel,R?_.segmentLabelMultiline:null,{color:i,fontSize:z.text},w,C],numberOfLines:M,children:e.label})]},String(e.value))})]}),!ae||E||oe.active?null:_jsx(View,{pointerEvents:"none",style:[StyleSheet.absoluteFill,{borderWidth:ce,borderColor:de,borderRadius:T?P:G,...smoothCorners}]})]});return ue||he?_jsxs(View,{style:{alignSelf:c?"stretch":"flex-start"},children:[ue?_jsx(FieldLabel,{size:d,children:i}):null,ge,he?_jsx(FieldMessage,{size:d,text:me,error:ne}):null]}):ge});SegmentedControl.displayName="SegmentedControl";const buildStyles=e=>StyleSheet.create({track:{flexDirection:"row",alignItems:"stretch",position:"relative"},row:{flex:1,flexDirection:"row",alignItems:"stretch",position:"relative",overflow:"hidden"},thumb:{position:"absolute",left:0},segment:{flexGrow:1,flexShrink:1,flexBasis:"auto",flexDirection:"row",alignItems:"center",justifyContent:"center"},segmentIcon:{marginRight:e.space.xs},segmentMultiline:{paddingVertical:e.space.xs},segmentLabel:{includeFontPadding:!1},segmentLabelMultiline:{flexShrink:1,textAlign:"center"}});export{SegmentedControl};export default SegmentedControl;
@@ -1 +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{Gesture,GestureDetector,GestureHandlerRootView}from"react-native-gesture-handler";import Svg,{Path,Rect,Text as SvgText}from"react-native-svg";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";export const DEFAULT_SIGNATURE_PAD_LABELS=Object.freeze({pad:"Signature pad",padHint:"Draw with one finger. To sign without drawing, use the type your name action.",caption:"Sign above the line. To start with an up or down stroke, rest your finger a moment first.",typedCaption:"Your typed name is used as your signature.",undo:"Undo",clear:"Clear",typeInstead:"Type your name instead",drawInstead:"Draw instead",typedLabel:"Type your name",typedPlaceholder:"Your full name",empty:"Not signed",signed:"Signed",typingAnnouncement:"Signing by typing your name. Your typed name is used as your signature. Choose Draw instead to sign with your finger.",drawingAnnouncement:"Signing by drawing. Use one finger on the pad.",clearedAnnouncement:"Signature cleared",undoneAnnouncement:"Last stroke removed",emptyError:"Add a signature first.",expand:"Expand",done:"Done",close:"Close"});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:i})=>"draw"===e?_jsx(_Fragment,{children:t.map(e=>_jsx(StrokePath,{points:e.points,color:a},e.id))}):n?_jsx(SvgText,{x:o/2,y:i*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:i,defaultMode:s="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:S,haptic:x="selection",disabled:T=!1,style:b,testID:w}=e;assertValidValue("SignaturePad","defaultMode",e.defaultMode,["draw","type"]);const _=useTheme(),E=void 0===g&&void 0===y,A=E?_.colors["text-body"]:g??lightTheme.colors["text-body"],C=E?_.colors.surface:y??lightTheme.colors.surface,R=E?lightTheme.colors["text-body"]:A,v=E?lightTheme.colors.surface:C,I=R!==A||v!==C,j=f??defaultScriptFont(),P=useMemo(()=>({...DEFAULT_SIGNATURE_PAD_LABELS,...S}),[S]),D=useScreenReader(),L=useRef(null),k=useRef(null),[F,M]=useState(0),[G,N]=useState(()=>(a??[]).map((e,t)=>({id:t+1,points:[...e]}))),B=useRef(G),O=useRef(G.length),H=useRef(null),V=useRef(null),[Y,$]=useState(c?s:"draw"),[z,U]=useState(o),[W,K]=useState(null),X=useRef(!1),{height:q}=useWindowDimensions(),[J,Q]=useState(!1),[Z,ee]=useState([]),te=useRef({onChange:r,onTypedNameChange:i,onModeChange:l,onEmptyChange:d});useEffect(()=>{te.current={onChange:r,onTypedNameChange:i,onModeChange:l,onEmptyChange:d}});const ne="draw"===Y&&!T,ae="draw"===Y?0===G.length:0===z.trim().length,re=useRef(null);useEffect(()=>{re.current!==ae&&(re.current=ae,te.current.onEmptyChange?.(ae))},[ae]);const oe=useCallback(e=>{B.current=e,N(e)},[]),ie=useCallback(()=>{K(Date.now()),te.current.onChange?.(B.current.map(e=>e.points))},[]),se=useMemo(()=>{const pan=e=>Gesture.Pan().enabled(ne).runOnJS(!0).onBegin(e=>{H.current=pointOf(e.x,e.y)}).onStart(t=>{V.current=e,O.current+=1;const n=pointOf(t.x,t.y);oe([...B.current,{id:O.current,points:[H.current??n,n]}])}).onUpdate(t=>{if(V.current!==e)return;const n=B.current[B.current.length-1],a=pointOf(t.x,t.y);distanceBetween(n.points[n.points.length-1],a)<.8||oe([...B.current.slice(0,-1),{...n,points:[...n.points,a]}])}).onFinalize(()=>{V.current===e&&(V.current=null,ie())}),e=pan("sideways").activeOffsetX([-6,6]).failOffsetY([-8,8]),t=pan("rested").activateAfterLongPress(200);return Gesture.Race(e,t)},[ne,oe,ie]),le=useCallback(e=>{$(e),te.current.onModeChange?.(e),announce("type"===e?P.typingAnnouncement:P.drawingAnnouncement)},[P.typingAnnouncement,P.drawingAnnouncement]);useEffect(()=>{D&&c&&!X.current&&"draw"===Y&&0===B.current.length&&le("type")},[D,c,Y,le]);const de=useCallback(()=>{X.current=!0,le("draw"===Y?"type":"draw")},[Y,le]),ce=useCallback(e=>{U(e),K(Date.now()),te.current.onTypedNameChange?.(e)},[]),ue=useCallback(()=>{"type"===Y?ce(""):(oe([]),ie()),announce(P.clearedAnnouncement)},[Y,ce,oe,ie,P.clearedAnnouncement]),pe=useCallback(()=>{"draw"===Y&&0!==B.current.length&&(oe(B.current.slice(0,-1)),ie(),announce(P.undoneAnnouncement))},[Y,oe,ie,P.undoneAnnouncement]),me=useCallback(()=>{ee(B.current.map(e=>e.points)),Q(!0)},[]),he=useCallback(()=>{Q(!1)},[]),ge=useCallback(()=>{oe(Z.map(e=>(O.current+=1,{id:O.current,points:[...e]}))),ie(),Q(!1)},[Z,oe,ie]),ye=F||FALLBACK_WIDTH;useImperativeHandle(t,()=>({toFile:()=>new Promise((e,t)=>{if(ae)return void t(new Error(P.emptyError));const n=I?k.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=>{try{e(writePng(n))}catch(e){t(e)}},{width:ye*a,height:m*a})}),toSvg:()=>buildSignatureSvg({width:ye,height:m,mode:Y,strokes:G.map(e=>e.points),typedName:z,ink:R,paper:v,strokeWidth:2.5,fontFamily:cssFontStack(j)}),clear:ue,undo:pe,isEmpty:()=>ae}),[ae,P.emptyError,ye,m,Y,G,z,I,R,v,j,ue,pe]);const fe=useMemo(()=>[{name:"undo",label:P.undo},{name:"clear",label:P.clear},...c?[{name:"toggleMode",label:"draw"===Y?P.typeInstead:P.drawInstead}]:[]],[P.undo,P.clear,P.typeInstead,P.drawInstead,c,Y]),Se=useCallback(e=>{if(T)return;const{actionName:t}=e.nativeEvent;"undo"===t?pe():"clear"===t?ue():"toggleMode"===t&&c&&de()},[T,pe,ue,de,c]),xe=useCallback(e=>{M(e.nativeEvent.layout.width)},[]),Te=useMemo(()=>StyleSheet.create({root:{gap:_.space.sm},pad:{height:m,borderWidth:_.size.border,borderColor:_.colors.border,borderRadius:_.radius.md,...smoothCorners,overflow:"hidden",backgroundColor:C,opacity:T?.5:1},baseline:{position:"absolute",left:_.space.md,right:_.space.md,top:m*BASELINE_RATIO,height:StyleSheet.hairlineWidth,backgroundColor:A,opacity:.3},actions:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",flexWrap:"wrap",gap:_.space.xs},trailing:{flexDirection:"row",alignItems:"center",gap:_.space.xs},expandedRoot:{flex:1,padding:_.space.md,gap:_.space.sm,backgroundColor:_.colors.bg},expandedBar:{flexDirection:"row",alignItems:"center",justifyContent:"space-between"}}),[_,m,C,A,T]),be=z.trim(),we=p??W,Ee=u&&!ae?`Signed by ${u}${we?`, ${formatDateTime(we)}`:""}`:null,Ae="type"===Y&&be?`${P.pad}. ${be}`:P.pad;return _jsxs(View,{style:[Te.root,b],testID:w,children:[_jsx(GestureDetector,{gesture:se,children:_jsxs(View,{style:Te.pad,onLayout:xe,accessible:!0,accessibilityRole:"image",accessibilityLabel:Ae,accessibilityHint:"draw"===Y?P.padHint:void 0,accessibilityValue:{text:ae?P.empty:P.signed},accessibilityState:{disabled:T},"aria-disabled":T,accessibilityActions:fe,onAccessibilityAction:Se,children:[I?_jsxs(Svg,{ref:k,style:StyleSheet.absoluteFill,width:"100%",height:m,children:[_jsx(Rect,{x:"0",y:"0",width:"100%",height:"100%",fill:v}),_jsx(Marks,{mode:Y,strokes:G,name:be,color:R,fontFamily:j,width:ye,height:m})]}):null,_jsxs(Svg,{ref:L,width:"100%",height:m,children:[_jsx(Rect,{x:"0",y:"0",width:"100%",height:"100%",fill:C}),_jsx(Marks,{mode:Y,strokes:G,name:be,color:A,fontFamily:j,width:ye,height:m})]}),_jsx(View,{pointerEvents:"none",style:Te.baseline})]})}),"type"===Y?_jsx(Input,{label:P.typedLabel,placeholder:P.typedPlaceholder,value:z,onChangeText:ce,maxLength:h,disabled:T,autoComplete:"name",textContentType:"name",autoCapitalize:"words",autoCorrect:!1,returnKeyType:"done",testID:w?`${w}-name`:void 0}):null,_jsx(Text,{variant:"caption",color:"tertiary",children:"draw"===Y?P.caption:P.typedCaption}),_jsxs(View,{style:Te.actions,children:[c?_jsx(Button,{label:"draw"===Y?P.typeInstead:P.drawInstead,variant:"ghost",tone:"primary",size:"md",style:TARGET_STYLE,haptic:x,disabled:T,onPress:de,testID:w?`${w}-mode`:void 0}):_jsx(View,{}),"draw"===Y?_jsxs(View,{style:Te.trailing,children:[G.length>0?_jsxs(_Fragment,{children:[_jsx(Button,{label:P.undo,variant:"ghost",tone:"primary",size:"md",style:TARGET_STYLE,haptic:x,disabled:T,onPress:pe,testID:w?`${w}-undo`:void 0}),_jsx(Button,{label:P.clear,variant:"ghost",tone:"primary",size:"md",style:TARGET_STYLE,haptic:x,disabled:T,onPress:ue,testID:w?`${w}-clear`:void 0})]}):null,n?_jsx(Button,{label:P.expand,variant:"ghost",tone:"primary",size:"md",style:TARGET_STYLE,haptic:x,disabled:T,onPress:me,testID:w?`${w}-expand`:void 0}):null]}):null,"type"===Y&&be?_jsx(Button,{label:P.clear,variant:"ghost",tone:"primary",size:"md",style:TARGET_STYLE,haptic:x,disabled:T,onPress:ue,testID:w?`${w}-clear`:void 0}):null]}),Ee?_jsx(Text,{variant:"caption",color:"secondary",children:Ee}):null,n?_jsx(Modal,{visible:J,animationType:"slide",presentationStyle:"fullScreen",onRequestClose:he,children:_jsxs(ExpandedRoot,{style:Te.expandedRoot,children:[_jsxs(View,{style:Te.expandedBar,children:[_jsx(Button,{label:P.close,variant:"ghost",tone:"primary",size:"md",style:TARGET_STYLE,haptic:x,onPress:he,testID:w?`${w}-close`:void 0}),_jsx(Button,{label:P.done,variant:"solid",tone:"primary",size:"md",style:TARGET_STYLE,haptic:x,onPress:ge,testID:w?`${w}-done`:void 0})]}),J?_jsx(SignaturePadSurface,{expandable:!1,defaultMode:"draw",allowTyped:!1,initialStrokes:Z,onChange:ee,height:Math.max(DEFAULT_HEIGHT,q-200),inkColor:g,paperColor:y,scriptFontFamily:f,labels:S,haptic:x,testID:w?`${w}-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{forwardRef,memo,useCallback,useEffect,useImperativeHandle,useMemo,useRef,useState}from"react";import{AccessibilityInfo,Modal,PixelRatio,Platform,StyleSheet,useWindowDimensions,View}from"react-native";import{Gesture,GestureDetector,GestureHandlerRootView}from"react-native-gesture-handler";import Svg,{Path,Rect,Text as SvgText}from"react-native-svg";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";export const DEFAULT_SIGNATURE_PAD_LABELS=Object.freeze({pad:"Signature pad",padHint:"Draw with one finger. To sign without drawing, use the type your name action.",caption:"Sign above the line. To start with an up or down stroke, rest your finger a moment first.",typedCaption:"Your typed name is used as your signature.",undo:"Undo",clear:"Clear",typeInstead:"Type your name instead",drawInstead:"Draw instead",typedLabel:"Type your name",typedPlaceholder:"Your full name",empty:"Not signed",signed:"Signed",typingAnnouncement:"Signing by typing your name. Your typed name is used as your signature. Choose Draw instead to sign with your finger.",drawingAnnouncement:"Signing by drawing. Use one finger on the pad.",clearedAnnouncement:"Signature cleared",undoneAnnouncement:"Last stroke removed",emptyError:"Add a signature first.",expand:"Expand",done:"Done",close:"Close"});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:i})=>"draw"===e?_jsx(_Fragment,{children:t.map(e=>_jsx(StrokePath,{points:e.points,color:a},e.id))}):n?_jsx(SvgText,{x:o/2,y:i*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:i,defaultMode:s="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:S,haptic:x="selection",disabled:T=!1,style:w,testID:b}=e;assertValidValue("SignaturePad","defaultMode",e.defaultMode,["draw","type"]);const _=useTheme(),E=void 0===g&&void 0===y,A=E?_.colors["text-body"]:g??lightTheme.colors["text-body"],C=E?_.colors.surface:y??lightTheme.colors.surface,v=E?lightTheme.colors["text-body"]:A,R=E?lightTheme.colors.surface:C,I=v!==A||R!==C,j=f??defaultScriptFont(),P=useMemo(()=>({...DEFAULT_SIGNATURE_PAD_LABELS,...S}),[S]),D=useScreenReader(),k=useRef(null),L=useRef(null),[F,M]=useState(0),[G,N]=useState(()=>(a??[]).map((e,t)=>({id:t+1,points:[...e]}))),B=useRef(G),O=useRef(G.length),H=useRef(null),V=useRef(null),[Y,$]=useState(c?s:"draw"),[z,U]=useState(o),[W,K]=useState(null),X=useRef(!1),{height:q}=useWindowDimensions(),[J,Q]=useState(!1),[Z,ee]=useState([]),te=useRef({onChange:r,onTypedNameChange:i,onModeChange:l,onEmptyChange:d});useEffect(()=>{te.current={onChange:r,onTypedNameChange:i,onModeChange:l,onEmptyChange:d}});const ne="draw"===Y&&!T,ae="draw"===Y?0===G.length:0===z.trim().length,re=useRef(null);useEffect(()=>{re.current!==ae&&(re.current=ae,te.current.onEmptyChange?.(ae))},[ae]);const oe=useCallback(e=>{B.current=e,N(e)},[]),ie=useCallback(()=>{K(Date.now()),te.current.onChange?.(B.current.map(e=>e.points))},[]),se=useMemo(()=>{const pan=e=>Gesture.Pan().enabled(ne).runOnJS(!0).onBegin(e=>{H.current=pointOf(e.x,e.y)}).onStart(t=>{V.current=e,O.current+=1;const n=pointOf(t.x,t.y);oe([...B.current,{id:O.current,points:[H.current??n,n]}])}).onUpdate(t=>{if(V.current!==e)return;const n=B.current[B.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||oe([...B.current.slice(0,-1),{...n,points:[...n.points,a]}])}).onFinalize(()=>{V.current===e&&(V.current=null,ie())}),e=pan("sideways").activeOffsetX([-6,6]).failOffsetY([-8,8]),t=pan("rested").activateAfterLongPress(200);return Gesture.Race(e,t)},[ne,oe,ie]),le=useCallback(e=>{$(e),te.current.onModeChange?.(e),announce("type"===e?P.typingAnnouncement:P.drawingAnnouncement)},[P.typingAnnouncement,P.drawingAnnouncement]);useEffect(()=>{D&&c&&!X.current&&"draw"===Y&&0===B.current.length&&le("type")},[D,c,Y,le]);const de=useCallback(()=>{X.current=!0,le("draw"===Y?"type":"draw")},[Y,le]),ce=useCallback(e=>{U(e),K(Date.now()),te.current.onTypedNameChange?.(e)},[]),ue=useCallback(()=>{"type"===Y?ce(""):(oe([]),ie()),announce(P.clearedAnnouncement)},[Y,ce,oe,ie,P.clearedAnnouncement]),pe=useCallback(()=>{"draw"===Y&&0!==B.current.length&&(oe(B.current.slice(0,-1)),ie(),announce(P.undoneAnnouncement))},[Y,oe,ie,P.undoneAnnouncement]),me=useCallback(()=>{ee(B.current.map(e=>e.points)),Q(!0)},[]),he=useCallback(()=>{Q(!1)},[]),ge=useCallback(()=>{oe(Z.map(e=>(O.current+=1,{id:O.current,points:[...e]}))),ie(),Q(!1)},[Z,oe,ie]),ye=F||FALLBACK_WIDTH;useImperativeHandle(t,()=>({toFile:()=>new Promise((e,t)=>{if(ae)return void t(new Error(P.emptyError));const n=I?L.current:k.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:ye*a,height:m*a})}),toSvg:()=>buildSignatureSvg({width:ye,height:m,mode:Y,strokes:G.map(e=>e.points),typedName:z,ink:v,paper:R,strokeWidth:2.5,fontFamily:cssFontStack(j)}),clear:ue,undo:pe,isEmpty:()=>ae}),[ae,P.emptyError,ye,m,Y,G,z,I,v,R,j,ue,pe]);const fe=useMemo(()=>[{name:"undo",label:P.undo},{name:"clear",label:P.clear},...c?[{name:"toggleMode",label:"draw"===Y?P.typeInstead:P.drawInstead}]:[]],[P.undo,P.clear,P.typeInstead,P.drawInstead,c,Y]),Se=useCallback(e=>{if(T)return;const{actionName:t}=e.nativeEvent;"undo"===t?pe():"clear"===t?ue():"toggleMode"===t&&c&&de()},[T,pe,ue,de,c]),xe=useCallback(e=>{M(e.nativeEvent.layout.width)},[]),Te=useMemo(()=>StyleSheet.create({root:{gap:_.space.sm},pad:{height:m,borderWidth:_.size.border,borderColor:_.colors.border,borderRadius:_.radius.md,...smoothCorners,overflow:"hidden",backgroundColor:C,opacity:T?.5:1},baseline:{position:"absolute",left:_.space.md,right:_.space.md,top:m*BASELINE_RATIO,height:StyleSheet.hairlineWidth,backgroundColor:A,opacity:.3},actions:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",flexWrap:"wrap",gap:_.space.xs},trailing:{flexDirection:"row",alignItems:"center",gap:_.space.xs},expandedRoot:{flex:1,padding:_.space.md,gap:_.space.sm,backgroundColor:_.colors.bg},expandedBar:{flexDirection:"row",alignItems:"center",justifyContent:"space-between"}}),[_,m,C,A,T]),we=z.trim(),be=p??W,Ee=u&&!ae?`Signed by ${u}${be?`, ${formatDateTime(be)}`:""}`:null,Ae="type"===Y&&we?`${P.pad}. ${we}`:P.pad;return _jsxs(View,{style:[Te.root,w],testID:b,children:[_jsx(GestureDetector,{gesture:se,children:_jsxs(View,{style:Te.pad,onLayout:xe,accessible:!0,accessibilityRole:"image",accessibilityLabel:Ae,accessibilityHint:"draw"===Y?P.padHint:void 0,accessibilityValue:{text:ae?P.empty:P.signed},accessibilityState:{disabled:T},"aria-disabled":T,accessibilityActions:fe,onAccessibilityAction:Se,children:[I?_jsxs(Svg,{ref:L,style:StyleSheet.absoluteFill,width:"100%",height:m,children:[_jsx(Rect,{x:"0",y:"0",width:"100%",height:"100%",fill:R}),_jsx(Marks,{mode:Y,strokes:G,name:we,color:v,fontFamily:j,width:ye,height:m})]}):null,_jsxs(Svg,{ref:k,width:"100%",height:m,children:[_jsx(Rect,{x:"0",y:"0",width:"100%",height:"100%",fill:C}),_jsx(Marks,{mode:Y,strokes:G,name:we,color:A,fontFamily:j,width:ye,height:m})]}),_jsx(View,{pointerEvents:"none",style:Te.baseline})]})}),"type"===Y?_jsx(Input,{label:P.typedLabel,placeholder:P.typedPlaceholder,value:z,onChangeText:ce,maxLength:h,disabled:T,autoComplete:"name",textContentType:"name",autoCapitalize:"words",autoCorrect:!1,returnKeyType:"done",testID:b?`${b}-name`:void 0}):null,_jsx(Text,{variant:"caption",color:"tertiary",children:"draw"===Y?P.caption:P.typedCaption}),_jsxs(View,{style:Te.actions,children:[c?_jsx(Button,{label:"draw"===Y?P.typeInstead:P.drawInstead,variant:"ghost",tone:"primary",size:"md",style:TARGET_STYLE,haptic:x,disabled:T,onPress:de,testID:b?`${b}-mode`:void 0}):_jsx(View,{}),"draw"===Y?_jsxs(View,{style:Te.trailing,children:[G.length>0?_jsxs(_Fragment,{children:[_jsx(Button,{label:P.undo,variant:"ghost",tone:"primary",size:"md",style:TARGET_STYLE,haptic:x,disabled:T,onPress:pe,testID:b?`${b}-undo`:void 0}),_jsx(Button,{label:P.clear,variant:"ghost",tone:"primary",size:"md",style:TARGET_STYLE,haptic:x,disabled:T,onPress:ue,testID:b?`${b}-clear`:void 0})]}):null,n?_jsx(Button,{label:P.expand,variant:"ghost",tone:"primary",size:"md",style:TARGET_STYLE,haptic:x,disabled:T,onPress:me,testID:b?`${b}-expand`:void 0}):null]}):null,"type"===Y&&we?_jsx(Button,{label:P.clear,variant:"ghost",tone:"primary",size:"md",style:TARGET_STYLE,haptic:x,disabled:T,onPress:ue,testID:b?`${b}-clear`:void 0}):null]}),Ee?_jsx(Text,{variant:"caption",color:"secondary",children:Ee}):null,n?_jsx(Modal,{visible:J,animationType:"slide",presentationStyle:"fullScreen",onRequestClose:he,children:_jsxs(ExpandedRoot,{style:Te.expandedRoot,children:[_jsxs(View,{style:Te.expandedBar,children:[_jsx(Button,{label:P.close,variant:"ghost",tone:"primary",size:"md",style:TARGET_STYLE,haptic:x,onPress:he,testID:b?`${b}-close`:void 0}),_jsx(Button,{label:P.done,variant:"solid",tone:"primary",size:"md",style:TARGET_STYLE,haptic:x,onPress:ge,testID:b?`${b}-done`:void 0})]}),J?_jsx(SignaturePadSurface,{expandable:!1,defaultMode:"draw",allowTyped:!1,initialStrokes:Z,onChange:ee,height:Math.max(DEFAULT_HEIGHT,q-200),inkColor:g,paperColor:y,scriptFontFamily:f,labels:S,haptic:x,testID:b?`${b}-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 +1 @@
1
- "use strict";export const FALLBACK_WIDTH=320;const MIN_FONT_SIZE=18,MAX_FONT_SIZE=56,SCRIPT_ADVANCE=.5,TYPED_WIDTH_SHARE=.88;export const BASELINE_RATIO=.7;const oneDecimal=t=>Math.round(10*t)/10;export const pointOf=(t,e)=>[oneDecimal(t),oneDecimal(e)];export const distanceBetween=(t,e)=>Math.hypot(t[0]-e[0],t[1]-e[1]);const format=t=>t.toFixed(1);export const strokePath=t=>{if(0===t.length)return"";const[e,...o]=t,r=[`M${format(e[0])} ${format(e[1])}`];if(0===o.length)return r.push(`L${format(e[0])} ${format(e[1])}`),r.join(" ");if(1===o.length)return r.push(`L${format(o[0][0])} ${format(o[0][1])}`),r.join(" ");for(let t=0;t<o.length-1;t+=1){const e=o[t],n=o[t+1],a=(e[0]+n[0])/2,s=(e[1]+n[1])/2;r.push(`Q${format(e[0])} ${format(e[1])} ${format(a)} ${format(s)}`)}const n=o[o.length-1];return r.push(`L${format(n[0])} ${format(n[1])}`),r.join(" ")};export const typedFontSize=(t,e)=>{const o=Math.max(1,e.length),r=Math.floor(.88*t/(.5*o));return Math.min(56,Math.max(18,r))};export const escapeXml=t=>t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;");export const buildSignatureSvg=t=>{const{width:e,height:o,mode:r,strokes:n,typedName:a,ink:s,paper:i,strokeWidth:p,fontFamily:c}=t,h=Math.round(e),l=Math.round(o),m=[`<rect x="0" y="0" width="${h}" height="${l}" fill="${escapeXml(i)}"/>`];if("type"===r){const t=a.trim();t&&m.push(`<text x="${h/2}" y="${format(.7*l)}" text-anchor="middle" font-family="${escapeXml(c)}" font-size="${typedFontSize(h,t)}" fill="${escapeXml(s)}">${escapeXml(t)}</text>`)}else for(const t of n)m.push(`<path d="${strokePath(t)}" fill="none" stroke="${escapeXml(s)}" stroke-width="${p}" stroke-linecap="round" stroke-linejoin="round"/>`);return`<svg xmlns="http://www.w3.org/2000/svg" width="${h}" height="${l}" viewBox="0 0 ${h} ${l}">${m.join("")}</svg>`};
1
+ "use strict";export const FALLBACK_WIDTH=320;const MIN_FONT_SIZE=18,MAX_FONT_SIZE=56,SCRIPT_ADVANCE=.5,TYPED_WIDTH_SHARE=.88;export const BASELINE_RATIO=.7;const oneDecimal=t=>Math.round(10*t)/10;export const pointOf=(t,o)=>[oneDecimal(t),oneDecimal(o)];export const distanceBetween=(t,o)=>Math.hypot(t[0]-o[0],t[1]-o[1]);const format=t=>t.toFixed(1);export const strokePath=t=>{const[o,e,...r]=t;if(void 0===o)return"";const n=[`M${format(o[0])} ${format(o[1])}`];if(void 0===e)return n.push(`L${format(o[0])} ${format(o[1])}`),n.join(" ");if(0===r.length)return n.push(`L${format(e[0])} ${format(e[1])}`),n.join(" ");let a=e;for(const t of r){const o=(a[0]+t[0])/2,e=(a[1]+t[1])/2;n.push(`Q${format(a[0])} ${format(a[1])} ${format(o)} ${format(e)}`),a=t}return n.push(`L${format(a[0])} ${format(a[1])}`),n.join(" ")};export const typedFontSize=(t,o)=>{const e=Math.max(1,o.length),r=Math.floor(.88*t/(.5*e));return Math.min(56,Math.max(18,r))};export const escapeXml=t=>t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;");export const buildSignatureSvg=t=>{const{width:o,height:e,mode:r,strokes:n,typedName:a,ink:s,paper:i,strokeWidth:c,fontFamily:p}=t,m=Math.round(o),h=Math.round(e),l=[`<rect x="0" y="0" width="${m}" height="${h}" fill="${escapeXml(i)}"/>`];if("type"===r){const t=a.trim();t&&l.push(`<text x="${m/2}" y="${format(.7*h)}" text-anchor="middle" font-family="${escapeXml(p)}" font-size="${typedFontSize(m,t)}" fill="${escapeXml(s)}">${escapeXml(t)}</text>`)}else for(const t of n)l.push(`<path d="${strokePath(t)}" fill="none" stroke="${escapeXml(s)}" stroke-width="${c}" stroke-linecap="round" stroke-linejoin="round"/>`);return`<svg xmlns="http://www.w3.org/2000/svg" width="${m}" height="${h}" viewBox="0 0 ${m} ${h}">${l.join("")}</svg>`};
@@ -1 +1 @@
1
- "use strict";export const writePng=e=>{const{File:t,Paths:r}=require("expo-file-system"),i=new t(r.cache,`signature-${Date.now().toString(36)}.png`);return i.create({intermediates:!0,overwrite:!0}),i.write(e,{encoding:"base64"}),i.uri};
1
+ "use strict";export const writePng=async e=>{const{File:t,Paths:r}=require("expo-file-system"),i=new t(r.cache,`signature-${Date.now().toString(36)}.png`);return i.create({intermediates:!0,overwrite:!0}),await i.write(e,{encoding:"base64"}),i.uri};
@@ -1 +1 @@
1
- "use strict";export const writePng=t=>`data:image/png;base64,${t}`;
1
+ "use strict";export const writePng=async t=>`data:image/png;base64,${t}`;
@@ -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{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 o=useRef(createAnimatedValue(0)).current,r=useRef(createAnimatedValue(0)).current;useEffect(()=>{if(!t)return o.setValue(0),void r.setValue(.5);const n=Animated.loop(Animated.timing(o,{toValue:1,duration:SHIMMER_DURATION[e],easing:Easing.linear,useNativeDriver:!0})),a=Animated.loop(Animated.sequence([Animated.timing(r,{toValue:1,duration:500,easing:Easing.inOut(Easing.ease),useNativeDriver:!0}),Animated.timing(r,{toValue:0,duration:500,easing:Easing.inOut(Easing.ease),useNativeDriver:!0})]));return n.start(),a.start(),()=>{n.stop(),a.stop()}},[e,t,o,r]);const i=useMemo(()=>({shimmer:o,pulse:r,enabled:t}),[o,r,t]);return _jsx(SkeletonClockContext.Provider,{value:i,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 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 +1 @@
1
- "use strict";import React,{Children,cloneElement,isValidElement,useEffect,useMemo,useRef}from"react";import{Animated,Image,StyleSheet,Text,View}from"react-native";import{usePresenceMotion}from"../../hooks/usePresenceMotion.js";import{createAnimatedValue,useTheme}from"../../theme/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{Text as LibraryText}from"../Text/index.js";import{DEFAULT_SKELETON_LABELS,Skeleton}from"./Skeleton.js";import{useSkeletonDefaults}from"./SkeletonProvider.js";import{SkeletonSkip}from"./SkeletonSkip.js";import{jsx as _jsx,Fragment as _Fragment}from"react/jsx-runtime";const DEFAULT_REVEAL_FADE_MS=300,flattenStyle=e=>{if(!e)return{};return StyleSheet.flatten(e)??{}},resolveWidth=(e,t)=>"number"==typeof e?e:"string"!=typeof e||"auto"!==e&&"100%"!==e&&!/^\d+(\.\d+)?%$/.test(e)?t:e,resolveRadius=(e,t)=>"number"==typeof e?e:t,skeletonizeNode=(e,t,i,r,n="r")=>{if(null==t||"boolean"==typeof t)return null;if("string"==typeof t||"number"==typeof t)return _jsx(Skeleton,{shape:"text",width:"60%",height:14,variant:i,colors:r},`${n}-text`);if(Array.isArray(t))return Children.map(t,(t,s)=>skeletonizeNode(e,t,i,r,`${n}-${s}`));if(!isValidElement(t))return null;const s=t,o=s.props??{},l=s.type;if(l===SkeletonSkip)return cloneElement(s,{key:`${n}-skip`});if("function"==typeof l||"object"==typeof l){const e=l.Skeleton;if(e){return _jsx(e,{...o},`${n}-self`)}}if(l===Image){const e=flattenStyle(o.style),t=resolveWidth(e.width,"100%"),s="number"==typeof e.height?e.height:120,l=resolveRadius(e.borderRadius,"sm");return _jsx(Skeleton,{width:t,height:s,radius:l,variant:i,colors:r,style:{margin:"number"==typeof e.margin?e.margin:void 0}},`${n}-img`)}if(l===Text||l===LibraryText){const t=flattenStyle(o.style),s="number"==typeof t.fontSize?t.fontSize:e.text.base.size,l=resolveWidth(t.width,"85%");return _jsx(Skeleton,{shape:"text",width:l,height:Math.round(1.15*s),variant:i,colors:r,style:{marginVertical:e.space.xxs}},`${n}-txt`)}if(null!=o.children)return cloneElement(s,{key:`${n}-w`},skeletonizeNode(e,o.children,i,r,`${n}-c`));if(l===View){const e=flattenStyle(o.style);if(null!=e.width||null!=e.height){const t=resolveWidth(e.width,"100%"),s="number"==typeof e.height?e.height:20,o=resolveRadius(e.borderRadius,"sm");return _jsx(Skeleton,{width:t,height:s,radius:o,variant:i,colors:r},`${n}-vw`)}}return cloneElement(s,{key:`${n}-leaf`})},SkeletonContent=e=>{const{loading:t,children:i,placeholder:r,variant:n,count:s=1,colors:o,labels:l,fadeDuration:a,style:u,testID:c}=e;assertValidValue("SkeletonContent","variant",e.variant,["shimmer","pulse","none"]);const d=useTheme(),m=useMemo(()=>({...DEFAULT_SKELETON_LABELS,...l}),[l]),f=useSkeletonDefaults(),h=usePresenceMotion(),y=a??f.fadeDuration??(h.reduced?h.duration("default"):300),p=useRef(t),S=useRef(createAnimatedValue(t?0:1)).current;if(useEffect(()=>{let e;return p.current&&!t?(S.setValue(0),e=Animated.timing(S,{toValue:1,duration:y,useNativeDriver:!0}),e.start()):!p.current&&t&&S.setValue(1),p.current=t,()=>e?.stop()},[t,S,y]),!t)return y<=0?_jsx(_Fragment,{children:i}):_jsx(Animated.View,{style:[u,{opacity:S}],testID:c,children:i});if(void 0!==r){const e=s>1?Array.from({length:s},(e,t)=>_jsx(React.Fragment,{children:r},`sk-ph-${t}`)):r;return _jsx(View,{style:u,testID:c,accessible:!0,accessibilityLabel:m.loading,accessibilityRole:"progressbar",accessibilityState:{busy:!0},"aria-busy":!0,accessibilityLiveRegion:"polite",children:e})}const b=s>1?Array.from({length:s},(e,t)=>_jsx(React.Fragment,{children:i},`sk-rep-${t}`)):i;return _jsx(View,{style:u,testID:c,accessible:!0,accessibilityLabel:m.loading,accessibilityRole:"progressbar",accessibilityState:{busy:!0},"aria-busy":!0,accessibilityLiveRegion:"polite",children:skeletonizeNode(d,b,n,o)})};SkeletonContent.displayName="SkeletonContent";export{SkeletonContent};export default SkeletonContent;
1
+ "use strict";import React,{Children,cloneElement,isValidElement,useEffect,useMemo,useRef}from"react";import{Animated,Image,StyleSheet,Text,View}from"react-native";import{usePresenceMotion}from"../../hooks/usePresenceMotion.js";import{createAnimatedValue,useTheme}from"../../theme/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{nativeDriver}from"../../utils/nativeDriver.js";import{Text as LibraryText}from"../Text/index.js";import{DEFAULT_SKELETON_LABELS,Skeleton}from"./Skeleton.js";import{useSkeletonDefaults}from"./SkeletonProvider.js";import{SkeletonSkip}from"./SkeletonSkip.js";import{jsx as _jsx,Fragment as _Fragment}from"react/jsx-runtime";const DEFAULT_REVEAL_FADE_MS=300,flattenStyle=e=>{if(!e)return{};return StyleSheet.flatten(e)??{}},resolveWidth=(e,t)=>"number"==typeof e?e:"string"!=typeof e||"auto"!==e&&"100%"!==e&&!/^\d+(\.\d+)?%$/.test(e)?t:e,resolveRadius=(e,t)=>"number"==typeof e?e:t,skeletonizeNode=(e,t,i,r,n="r")=>{if(null==t||"boolean"==typeof t)return null;if("string"==typeof t||"number"==typeof t)return _jsx(Skeleton,{shape:"text",width:"60%",height:14,variant:i,colors:r},`${n}-text`);if(Array.isArray(t))return Children.map(t,(t,s)=>skeletonizeNode(e,t,i,r,`${n}-${s}`));if(!isValidElement(t))return null;const s=t,o=s.props??{},l=s.type;if(l===SkeletonSkip)return cloneElement(s,{key:`${n}-skip`});if("function"==typeof l||"object"==typeof l){const e=l.Skeleton;if(e){return _jsx(e,{...o},`${n}-self`)}}if(l===Image){const e=flattenStyle(o.style),t=resolveWidth(e.width,"100%"),s="number"==typeof e.height?e.height:120,l=resolveRadius(e.borderRadius,"sm");return _jsx(Skeleton,{width:t,height:s,radius:l,variant:i,colors:r,style:{margin:"number"==typeof e.margin?e.margin:void 0}},`${n}-img`)}if(l===Text||l===LibraryText){const t=flattenStyle(o.style),s="number"==typeof t.fontSize?t.fontSize:e.text.base.size,l=resolveWidth(t.width,"85%");return _jsx(Skeleton,{shape:"text",width:l,height:Math.round(1.15*s),variant:i,colors:r,style:{marginVertical:e.space.xxs}},`${n}-txt`)}if(null!=o.children)return cloneElement(s,{key:`${n}-w`},skeletonizeNode(e,o.children,i,r,`${n}-c`));if(l===View){const e=flattenStyle(o.style);if(null!=e.width||null!=e.height){const t=resolveWidth(e.width,"100%"),s="number"==typeof e.height?e.height:20,o=resolveRadius(e.borderRadius,"sm");return _jsx(Skeleton,{width:t,height:s,radius:o,variant:i,colors:r},`${n}-vw`)}}return cloneElement(s,{key:`${n}-leaf`})},SkeletonContent=e=>{const{loading:t,children:i,placeholder:r,variant:n,count:s=1,colors:o,labels:l,fadeDuration:a,style:u,testID:c}=e;assertValidValue("SkeletonContent","variant",e.variant,["shimmer","pulse","none"]);const d=useTheme(),m=useMemo(()=>({...DEFAULT_SKELETON_LABELS,...l}),[l]),f=useSkeletonDefaults(),h=usePresenceMotion(),y=a??f.fadeDuration??(h.reduced?h.duration("default"):300),p=useRef(t),S=useRef(createAnimatedValue(t?0:1)).current;if(useEffect(()=>{let e;return p.current&&!t?(S.setValue(0),e=Animated.timing(S,{toValue:1,duration:y,useNativeDriver:nativeDriver}),e.start()):!p.current&&t&&S.setValue(1),p.current=t,()=>e?.stop()},[t,S,y]),!t)return y<=0?_jsx(_Fragment,{children:i}):_jsx(Animated.View,{style:[u,{opacity:S}],testID:c,children:i});if(void 0!==r){const e=s>1?Array.from({length:s},(e,t)=>_jsx(React.Fragment,{children:r},`sk-ph-${t}`)):r;return _jsx(View,{style:u,testID:c,accessible:!0,accessibilityLabel:m.loading,accessibilityRole:"progressbar",accessibilityState:{busy:!0},"aria-busy":!0,accessibilityLiveRegion:"polite",children:e})}const b=s>1?Array.from({length:s},(e,t)=>_jsx(React.Fragment,{children:i},`sk-rep-${t}`)):i;return _jsx(View,{style:u,testID:c,accessible:!0,accessibilityLabel:m.loading,accessibilityRole:"progressbar",accessibilityState:{busy:!0},"aria-busy":!0,accessibilityLiveRegion:"polite",children:skeletonizeNode(d,b,n,o)})};SkeletonContent.displayName="SkeletonContent";export{SkeletonContent};export default SkeletonContent;
@@ -1 +1 @@
1
- "use strict";import{memo,useEffect,useRef,useState}from"react";import{Animated,Easing,StyleSheet,View}from"react-native";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const sliderToneInk=(t,e)=>{switch(e){case"success":return t.colors["on-success"];case"warning":return t.colors["on-warning"];case"danger":return t.colors["on-danger"];case"info":return t.colors["on-info"];case"neutral":return t.colors["on-neutral"];default:return t.colors["on-primary"]}};export const clampValue=(t,e,n)=>Math.min(Math.max(t,e),n);export const snapValue=(t,e,n,r)=>{if(r<=0)return clampValue(t,e,n);const o=String(r).split(".")[1]?.length??0,s=Math.round((t-e)/r)*r+e;return clampValue(o>0?Number(s.toFixed(o)):s,e,n)};export const parseTyped=t=>{const e=t.replace(/[^\d.-]/g,"");if(""===e||"."===e||"-"===e)return null;const n=Number.parseFloat(e);return Number.isFinite(n)?n:null};const easeOutCubic=t=>1-(1-t)**3,roundTo=(t,e)=>{const n=10**e;return Math.round(t*n)/n};export const CountingText=memo(({value:t,format:e,decimals:n=2,duration:r,jumpKey:o="",style:s,testID:l})=>{const[a,i]=useState(t),u=useRef(t),c=useRef(o);return useEffect(()=>{const e=c.current!==o;c.current=o;const n=u.current;if(e||r<=0||n===t)return u.current=t,void i(t);const s=Date.now();let l=0;const tick=()=>{const e=Math.min(1,(Date.now()-s)/r),o=n+(t-n)*easeOutCubic(e);u.current=o,i(o),e<1&&(l=requestAnimationFrame(tick))};return l=requestAnimationFrame(tick),()=>cancelAnimationFrame(l)},[t,o,r]),_jsx(Text,{variant:"caption",weight:"semibold",style:s,testID:l,children:e(roundTo(a,n))})});CountingText.displayName="CountingText";export const useValueDraft=({value:t,min:e,max:n,step:r,format:o,parse:s=parseTyped,onChange:l})=>{const[a,i]=useState(null);return{text:a??o(t),editing:null!==a,onFocus:()=>i(o(t)),onChangeText:t=>{i(t);const r=s(t);null!==r&&l(clampValue(r,e,n))},onBlur:()=>{if(null===a)return;const o=s(a);i(null);const u=snapValue(o??e,e,n,r);u!==t&&l(u)}}};const ROLL_TRAVEL_RATIO=1.2,RollingSlot=memo(({text:t,direction:e,duration:n,style:r,testID:o})=>{const[s,l]=useState(null),a=useRef(t),i=useRef(new Animated.Value(1)).current,u=1.2*(StyleSheet.flatten(r)?.fontSize??14);useEffect(()=>{if(a.current===t)return;const e=a.current;if(a.current=t,n<=0)return void l(null);l(e),i.setValue(0);const r=Animated.timing(i,{toValue:1,duration:n,easing:Easing.out(Easing.cubic),useNativeDriver:!0});return r.start(({finished:t})=>{t&&l(null)}),()=>r.stop()},[t,n,i]);const c="up"===e?-1:1,m=null===s?null:{opacity:i,transform:[{translateY:i.interpolate({inputRange:[0,1],outputRange:[-c*u,0]})}]},p={opacity:i.interpolate({inputRange:[0,1],outputRange:[1,0]}),transform:[{translateY:i.interpolate({inputRange:[0,1],outputRange:[0,c*u]})}]};return _jsxs(View,{style:rollStyles.slot,children:[_jsx(Animated.Text,{style:[r,m],testID:o,children:t}),null!==s?_jsx(Animated.Text,{style:[r,rollStyles.leaving,p],testID:o?`${o}-leaving`:void 0,children:s}):null]})});RollingSlot.displayName="RollingSlot";export const RollingText=memo(({text:t,direction:e="up",duration:n,perCharacter:r=!0,style:o,testID:s})=>{const l=useRef(t),a=r?Math.max(t.length,l.current.length):1;return useEffect(()=>{l.current=t},[t]),_jsx(View,{style:rollStyles.row,testID:s,children:r?Array.from({length:a},(r,l)=>_jsx(RollingSlot,{text:t[l]??"",direction:e,duration:n,style:o,testID:s?`${s}-char`:void 0},l)):_jsx(RollingSlot,{text:t,direction:e,duration:n,style:o,testID:s?`${s}-char`:void 0})})});RollingText.displayName="RollingText";const rollStyles=StyleSheet.create({row:{flexDirection:"row",alignItems:"baseline"},slot:{overflow:"hidden"},leaving:{position:"absolute",left:0,top:0}});
1
+ "use strict";import{memo,useEffect,useRef,useState}from"react";import{Animated,Easing,StyleSheet,View}from"react-native";import{nativeDriver}from"../../utils/nativeDriver.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const sliderToneInk=(e,t)=>{switch(t){case"success":return e.colors["on-success"];case"warning":return e.colors["on-warning"];case"danger":return e.colors["on-danger"];case"info":return e.colors["on-info"];case"neutral":return e.colors["on-neutral"];case"primary":return e.colors["on-primary"]}};export const clampValue=(e,t,n)=>Math.min(Math.max(e,t),n);export const snapValue=(e,t,n,r)=>{if(r<=0)return clampValue(e,t,n);const o=String(r).split(".")[1]?.length??0,s=Math.round((e-t)/r)*r+t;return clampValue(o>0?Number(s.toFixed(o)):s,t,n)};export const parseTyped=e=>{const t=e.replace(/[^\d.-]/g,"");if(""===t||"."===t||"-"===t)return null;const n=Number.parseFloat(t);return Number.isFinite(n)?n:null};const easeOutCubic=e=>1-(1-e)**3,roundTo=(e,t)=>{const n=10**t;return Math.round(e*n)/n};export const CountingText=memo(({value:e,format:t,decimals:n=2,duration:r,jumpKey:o="",style:s,testID:l})=>{const[a,i]=useState(e),u=useRef(e),c=useRef(o);return useEffect(()=>{const t=c.current!==o;c.current=o;const n=u.current;if(t||r<=0||n===e)return u.current=e,void i(e);const s=Date.now();let l=0;const tick=()=>{const t=Math.min(1,(Date.now()-s)/r),o=n+(e-n)*easeOutCubic(t);u.current=o,i(o),t<1&&(l=requestAnimationFrame(tick))};return l=requestAnimationFrame(tick),()=>cancelAnimationFrame(l)},[e,o,r]),_jsx(Text,{variant:"caption",weight:"semibold",style:s,testID:l,children:t(roundTo(a,n))})});CountingText.displayName="CountingText";export const useValueDraft=({value:e,min:t,max:n,step:r,format:o,parse:s=parseTyped,onChange:l})=>{const[a,i]=useState(null);return{text:a??o(e),editing:null!==a,onFocus:()=>i(o(e)),onChangeText:e=>{i(e);const r=s(e);null!==r&&l(clampValue(r,t,n))},onBlur:()=>{if(null===a)return;const o=s(a);i(null);const u=snapValue(o??t,t,n,r);u!==e&&l(u)}}};const ROLL_TRAVEL_RATIO=1.2,RollingSlot=memo(({text:e,direction:t,duration:n,style:r,testID:o})=>{const[s,l]=useState(null),a=useRef(e),i=useRef(new Animated.Value(1)).current,u=1.2*(StyleSheet.flatten(r)?.fontSize??14);useEffect(()=>{if(a.current===e)return;const t=a.current;if(a.current=e,n<=0)return void l(null);l(t),i.setValue(0);const r=Animated.timing(i,{toValue:1,duration:n,easing:Easing.out(Easing.cubic),useNativeDriver:nativeDriver});return r.start(({finished:e})=>{e&&l(null)}),()=>r.stop()},[e,n,i]);const c="up"===t?-1:1,m=null===s?null:{opacity:i,transform:[{translateY:i.interpolate({inputRange:[0,1],outputRange:[-c*u,0]})}]},p={opacity:i.interpolate({inputRange:[0,1],outputRange:[1,0]}),transform:[{translateY:i.interpolate({inputRange:[0,1],outputRange:[0,c*u]})}]};return _jsxs(View,{style:rollStyles.slot,children:[_jsx(Animated.Text,{style:[r,m],testID:o,children:e}),null!==s?_jsx(Animated.Text,{style:[r,rollStyles.leaving,p],testID:o?`${o}-leaving`:void 0,children:s}):null]})});RollingSlot.displayName="RollingSlot";export const RollingText=memo(({text:e,direction:t="up",duration:n,perCharacter:r=!0,style:o,testID:s})=>{const l=useRef(e),a=r?Math.max(e.length,l.current.length):1;return useEffect(()=>{l.current=e},[e]),_jsx(View,{style:rollStyles.row,testID:s,children:r?Array.from({length:a},(r,l)=>_jsx(RollingSlot,{text:e[l]??"",direction:t,duration:n,style:o,testID:s?`${s}-char`:void 0},l)):_jsx(RollingSlot,{text:e,direction:t,duration:n,style:o,testID:s?`${s}-char`:void 0})})});RollingText.displayName="RollingText";const rollStyles=StyleSheet.create({row:{flexDirection:"row",alignItems:"baseline"},slot:{overflow:"hidden"},leaving:{position:"absolute",left:0,top:0}});
@@ -1 +1 @@
1
- "use strict";import{formatNumber}from"@webority/mobile-core";import{forwardRef,useCallback,useMemo,useState}from"react";import{StyleSheet,View}from"react-native";import Svg,{Circle,Path}from"react-native-svg";import{useTheme}from"../../theme/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{finiteValues,sparklineGeometry}from"./geometry.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_SPARKLINE_LABELS=Object.freeze({noData:"no data",range:(e,t,r,a)=>`from ${e} to ${t}, low ${r}, high ${a}`});const DOT_RADIUS=3,lineColor=(e,t)=>"neutral"===t?e.colors["text-muted"]:e.colors[`${t}-text`],defaultFormat=e=>formatNumber(e),Sparkline=forwardRef((e,t)=>{const{data:r,tone:a="primary",color:i,fill:o=!1,highlightLast:s=!0,height:l=32,width:n,strokeWidth:m=2,label:c,formatLabel:u=defaultFormat,accessibilityLabel:h,labels:d,style:f,testID:p}=e;assertValidValue("Sparkline","tone",e.tone,["primary","success","warning","danger","info","neutral"]);const y=useMemo(()=>({...DEFAULT_SPARKLINE_LABELS,...d}),[d]),x=useTheme(),[S,g]=useState(0),b=n??S,k=useCallback(e=>{if(void 0===n){const t=Math.round(e.nativeEvent.layout.width);g(e=>e===t?e:t)}},[n]),$=Math.max(3,m/2)+1,j=useMemo(()=>sparklineGeometry(r,b,l,$),[r,b,l,$]),L=i??lineColor(x,a),v=useMemo(()=>{if(void 0!==h)return h;const e=finiteValues(r),t=c?`${c}, `:"";if(0===e.length)return`${t}${y.noData}`;if(1===e.length)return`${t}${u(e[0])}`;const a=u(e[0]),i=u(e[e.length-1]),o=u(Math.min(...e)),s=u(Math.max(...e));return`${t}${y.range(a,i,o,s)}`},[h,r,u,c,y]);return _jsx(View,{ref:t,accessible:!0,accessibilityRole:"image",accessibilityLabel:v,testID:p,onLayout:k,style:[styles.root,void 0===n?styles.stretch:{width:n},{height:l},f],children:""===j.line?null:_jsxs(Svg,{width:b,height:l,viewBox:`0 0 ${b} ${l}`,children:[o?_jsx(Path,{d:j.area,fill:L,fillOpacity:.14,stroke:"none"}):null,_jsx(Path,{d:j.line,fill:"none",stroke:L,strokeWidth:m,strokeLinecap:"round",strokeLinejoin:"round",testID:p?`${p}-line`:void 0}),s&&j.last?_jsx(Circle,{cx:j.last.x,cy:j.last.y,r:3,fill:L,testID:p?`${p}-dot`:void 0}):null]})})});Sparkline.displayName="Sparkline";const styles=StyleSheet.create({root:{overflow:"hidden"},stretch:{alignSelf:"stretch"}});export{Sparkline};export default Sparkline;
1
+ "use strict";import{formatNumber}from"@webority/mobile-core";import{forwardRef,useCallback,useMemo,useState}from"react";import{StyleSheet,View}from"react-native";import Svg,{Circle,Path}from"react-native-svg";import{useTheme}from"../../theme/index.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{finiteValues,sparklineGeometry}from"./geometry.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_SPARKLINE_LABELS=Object.freeze({noData:"no data",range:(e,t,r,o)=>`from ${e} to ${t}, low ${r}, high ${o}`});const DOT_RADIUS=3,lineColor=(e,t)=>"neutral"===t?e.colors["text-muted"]:e.colors[`${t}-text`],defaultFormat=e=>formatNumber(e),Sparkline=forwardRef((e,t)=>{const{data:r,tone:o="primary",color:i,fill:a=!1,highlightLast:s=!0,height:l=32,width:n,strokeWidth:m=2,label:c,formatLabel:u=defaultFormat,accessibilityLabel:h,labels:d,style:f,testID:p}=e;assertValidValue("Sparkline","tone",e.tone,["primary","success","warning","danger","info","neutral"]);const y=useMemo(()=>({...DEFAULT_SPARKLINE_LABELS,...d}),[d]),x=useTheme(),[S,g]=useState(0),v=n??S,k=useCallback(e=>{if(void 0===n){const t=Math.round(e.nativeEvent.layout.width);g(e=>e===t?e:t)}},[n]),w=Math.max(3,m/2)+1,b=useMemo(()=>sparklineGeometry(r,v,l,w),[r,v,l,w]),$=i??lineColor(x,o),j=useMemo(()=>{if(void 0!==h)return h;const e=finiteValues(r),t=c?`${c}, `:"",[o]=e;if(void 0===o)return`${t}${y.noData}`;if(1===e.length)return`${t}${u(o)}`;const i=e[e.length-1];if(void 0===i)throw new Error("A sparkline with two or more finite values has a last value.");const a=u(o),s=u(i),l=u(Math.min(...e)),n=u(Math.max(...e));return`${t}${y.range(a,s,l,n)}`},[h,r,u,c,y]);return _jsx(View,{ref:t,accessible:!0,accessibilityRole:"image",accessibilityLabel:j,testID:p,onLayout:k,style:[styles.root,void 0===n?styles.stretch:{width:n},{height:l},f],children:""===b.line?null:_jsxs(Svg,{width:v,height:l,viewBox:`0 0 ${v} ${l}`,children:[a?_jsx(Path,{d:b.area,fill:$,fillOpacity:.14,stroke:"none"}):null,_jsx(Path,{d:b.line,fill:"none",stroke:$,strokeWidth:m,strokeLinecap:"round",strokeLinejoin:"round",testID:p?`${p}-line`:void 0}),s&&b.last?_jsx(Circle,{cx:b.last.x,cy:b.last.y,r:3,fill:$,testID:p?`${p}-dot`:void 0}):null]})})});Sparkline.displayName="Sparkline";const styles=StyleSheet.create({root:{overflow:"hidden"},stretch:{alignSelf:"stretch"}});export{Sparkline};export default Sparkline;
@@ -1 +1 @@
1
- "use strict";const finite=n=>n.filter(n=>Number.isFinite(n)),round=n=>(Math.round(100*n)/100).toString();export const sparklineGeometry=(n,t,e,r)=>{const i=finite(n);if(0===i.length||t<=0||e<=0)return{line:"",area:"",last:null};const a=Math.min(...i),o=Math.max(...i),u=Math.max(0,t-2*r),l=Math.max(0,e-2*r),s=o-a,h=i.map((n,a)=>({x:1===i.length?t/2:r+a*u/(i.length-1),y:0===s?e/2:r+(o-n)/s*l})),x=h.map((n,t)=>`${0===t?"M":"L"}${round(n.x)} ${round(n.y)}`).join(" "),d=h[0],m=h[h.length-1];return{line:x,area:`${x} L${round(m.x)} ${round(e)} L${round(d.x)} ${round(e)} Z`,last:m}};export const finiteValues=finite;
1
+ "use strict";const finite=t=>t.filter(t=>Number.isFinite(t)),round=t=>(Math.round(100*t)/100).toString();export const sparklineGeometry=(t,n,r,e)=>{const i=finite(t);if(0===i.length||n<=0||r<=0)return{line:"",area:"",last:null};const o=Math.min(...i),a=Math.max(...i),s=Math.max(0,n-2*e),l=Math.max(0,r-2*e),u=a-o,h=i.map((t,o)=>({x:1===i.length?n/2:e+o*s/(i.length-1),y:0===u?r/2:e+(a-t)/u*l})),d=h.map((t,n)=>`${0===n?"M":"L"}${round(t.x)} ${round(t.y)}`).join(" "),x=h[0],m=h[h.length-1];if(void 0===x||void 0===m)throw new Error("A sparkline with values has points to draw.");return{line:d,area:`${d} L${round(m.x)} ${round(r)} L${round(x.x)} ${round(r)} Z`,last:m}};export const finiteValues=finite;
@@ -1 +1 @@
1
- "use strict";import{forwardRef,useEffect,useMemo,useRef}from"react";import{ActivityIndicator,Animated,Easing,StyleSheet,View}from"react-native";import{usePresenceMotion}from"../../hooks/usePresenceMotion.js";import{createAnimatedValue,useTheme}from"../../theme/index.js";import{announce}from"../../utils/announce.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{blendOf}from"../../utils/color.js";import{smoothCorners}from"../../utils/corners.js";import{squircleHostRadius}from"../../utils/squircle.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";export const DEFAULT_SPINNER_LABELS=Object.freeze({loading:"Loading"});const sizeMap={sm:20,md:32,lg:48},CONTAINER_RATIO=1.5,DOT_NAMES=["first","second","third"],DOT_STAGGER_MS=150,DOT_CYCLE_MS=600,DOT_GROW_SCALE=1.4,DOT_PULSE_MIN_OPACITY=.4,Dot=({size:e,color:t,delay:i,duration:n,reduced:s})=>{const r=useTheme(),o=useRef(createAnimatedValue(0)).current;useEffect(()=>{const e=Animated.loop(Animated.sequence([Animated.delay(i),Animated.timing(o,{toValue:1,duration:n/2,easing:Easing.out(Easing.quad),useNativeDriver:!0}),Animated.timing(o,{toValue:0,duration:n/2,easing:Easing.in(Easing.quad),useNativeDriver:!0})]));return e.start(),()=>{e.stop()}},[o,i,n]);const a=useMemo(()=>({grow:o.interpolate({inputRange:[0,1],outputRange:[1,1.4]}),fade:o.interpolate({inputRange:[0,1],outputRange:[.4,1]})}),[o]);return _jsx(Animated.View,{style:{width:e,height:e,borderRadius:r.radius.pill,...smoothCorners,backgroundColor:t,...s?{opacity:a.fade}:{transform:[{scale:a.grow}]}}})},Spinner=forwardRef((e,t)=>{const{size:i="md",color:n,message:s,overlay:r=!1,backdropColor:o,variant:a="circular",accessibilityLabel:l,labels:c,style:u,testID:d}=e;assertValidValue("Spinner","size",e.size,["sm","md","lg"]),assertValidValue("Spinner","variant",e.variant,["circular","dots","contained"]);const m=useMemo(()=>({...DEFAULT_SPINNER_LABELS,...c}),[c]),g="contained"===a,f=r&&!g,p=useTheme(),h=usePresenceMotion(),y=h.duration("default"),b=useRef(createAnimatedValue(0)).current;useEffect(()=>{Animated.timing(b,{toValue:1,duration:y,easing:Easing.bezier(...p.motion.ease["in-out"]),useNativeDriver:!0}).start()},[b,p,y]);const S=useMemo(()=>buildStyles(p),[p]),j=sizeMap[i],x=n??p.colors.primary,_=o??p.colors.scrim,A=useMemo(()=>{if("contained"===a){const e=Math.round(1.5*j);return _jsx(View,{style:[S.container,{width:e,height:e,borderRadius:p.radius.pill,backgroundColor:blendOf(x,.14,p.colors.surface,p.colors["bg-subtle"])}],children:_jsx(ActivityIndicator,{color:x,size:"sm"===i?"small":"large",style:{width:j,height:j}})})}if("dots"===a){const e=Math.max(6,Math.round(j/4));return _jsx(View,{style:[S.dotsRow,{gap:Math.round(e/2)}],children:DOT_NAMES.map((t,i)=>_jsx(Dot,{size:e,color:x,delay:150*i,duration:600,reduced:h.reduced},t))})}return _jsx(ActivityIndicator,{color:x,size:"sm"===i?"small":"large",style:{width:j,height:j}})},[a,i,j,x,S.dotsRow,S.container,h.reduced,p.radius.pill,p.colors.surface,p.colors["bg-subtle"]]),C=l??s??m.loading,R=useRef(C);R.current=C,useEffect(()=>{g&&announce(R.current)},[g]);const v=useSquircle(f,p.radius.lg),E=v.active&&v.size?{borderRadius:squircleHostRadius(v.size.width,v.size.height,p.radius.lg)}:null;let w=S.inlineContent;f?w=S.overlayContent:g&&(w=S.containedContent);const z=_jsxs(Animated.View,{ref:t,accessible:!0,accessibilityRole:"progressbar",accessibilityLiveRegion:g?"none":"polite",accessibilityLabel:C,accessibilityState:{busy:!0},"aria-busy":!0,testID:d,onLayout:v.onLayout,style:[w,E,{opacity:b}],children:[v.active&&v.size?_jsx(SquircleFill,{width:v.size.width,height:v.size.height,radius:p.radius.lg,fill:p.colors.surface}):null,A,s?_jsx(Text,{variant:"body",weight:"medium",style:[S.message,{marginTop:p.space.md}],numberOfLines:2,children:s}):null]});return _jsx(View,f?{pointerEvents:"auto",style:[S.overlay,{backgroundColor:_},u],children:z}:{style:[g?S.containedFill:S.inline,u],children:z})});Spinner.displayName="Spinner";const buildStyles=e=>StyleSheet.create({inline:{alignItems:"center",justifyContent:"center"},inlineContent:{alignItems:"center",justifyContent:"center"},containedFill:{flex:1,alignSelf:"stretch",alignItems:"center",justifyContent:"center",minHeight:Math.round(1.5*sizeMap.lg)+2*e.space.xl},containedContent:{alignItems:"center",justifyContent:"center",paddingHorizontal:e.space.lg},container:{alignItems:"center",justifyContent:"center"},overlay:{...StyleSheet.absoluteFill,alignItems:"center",justifyContent:"center",zIndex:1e3},overlayContent:{alignItems:"center",justifyContent:"center",backgroundColor:e.colors.surface,borderRadius:e.radius.lg,...smoothCorners,paddingHorizontal:e.space.xl,paddingVertical:e.space.xl,minWidth:140,...e.shadow.popover},dotsRow:{flexDirection:"row",alignItems:"center",justifyContent:"center"},message:{textAlign:"center"}});export{Spinner};export default Spinner;
1
+ "use strict";import{forwardRef,useEffect,useMemo,useRef}from"react";import{ActivityIndicator,Animated,Easing,StyleSheet,View}from"react-native";import{usePresenceMotion}from"../../hooks/usePresenceMotion.js";import{createAnimatedValue,useTheme}from"../../theme/index.js";import{announce}from"../../utils/announce.js";import{assertValidValue}from"../../utils/assertValidValue.js";import{blendOf}from"../../utils/color.js";import{smoothCorners}from"../../utils/corners.js";import{nativeDriver}from"../../utils/nativeDriver.js";import{squircleHostRadius}from"../../utils/squircle.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";export const DEFAULT_SPINNER_LABELS=Object.freeze({loading:"Loading"});const sizeMap={sm:20,md:32,lg:48},CONTAINER_RATIO=1.5,DOT_NAMES=["first","second","third"],DOT_STAGGER_MS=150,DOT_CYCLE_MS=600,DOT_GROW_SCALE=1.4,DOT_PULSE_MIN_OPACITY=.4,Dot=({size:e,color:t,delay:i,duration:r,reduced:n})=>{const s=useTheme(),o=useRef(createAnimatedValue(0)).current;useEffect(()=>{const e=Animated.loop(Animated.sequence([Animated.delay(i),Animated.timing(o,{toValue:1,duration:r/2,easing:Easing.out(Easing.quad),useNativeDriver:nativeDriver}),Animated.timing(o,{toValue:0,duration:r/2,easing:Easing.in(Easing.quad),useNativeDriver:nativeDriver})]));return e.start(),()=>{e.stop()}},[o,i,r]);const a=useMemo(()=>({grow:o.interpolate({inputRange:[0,1],outputRange:[1,1.4]}),fade:o.interpolate({inputRange:[0,1],outputRange:[.4,1]})}),[o]);return _jsx(Animated.View,{style:{width:e,height:e,borderRadius:s.radius.pill,...smoothCorners,backgroundColor:t,...n?{opacity:a.fade}:{transform:[{scale:a.grow}]}}})},Spinner=forwardRef((e,t)=>{const{size:i="md",color:r,message:n,overlay:s=!1,backdropColor:o,variant:a="circular",accessibilityLabel:l,labels:c,style:u,testID:d}=e;assertValidValue("Spinner","size",e.size,["sm","md","lg"]),assertValidValue("Spinner","variant",e.variant,["circular","dots","contained"]);const m=useMemo(()=>({...DEFAULT_SPINNER_LABELS,...c}),[c]),g="contained"===a,f=s&&!g,p=useTheme(),h=usePresenceMotion(),y=h.duration("default"),b=useRef(createAnimatedValue(0)).current;useEffect(()=>{Animated.timing(b,{toValue:1,duration:y,easing:Easing.bezier(...p.motion.ease["in-out"]),useNativeDriver:nativeDriver}).start()},[b,p,y]);const j=useMemo(()=>buildStyles(p),[p]),v=sizeMap[i],S=r??p.colors.primary,x=o??p.colors.scrim,_=useMemo(()=>{if("contained"===a){const e=Math.round(1.5*v);return _jsx(View,{style:[j.container,{width:e,height:e,borderRadius:p.radius.pill,backgroundColor:blendOf(S,.14,p.colors.surface,p.colors["bg-subtle"])}],children:_jsx(ActivityIndicator,{color:S,size:"sm"===i?"small":"large",style:{width:v,height:v}})})}if("dots"===a){const e=Math.max(6,Math.round(v/4));return _jsx(View,{style:[j.dotsRow,{gap:Math.round(e/2)}],children:DOT_NAMES.map((t,i)=>_jsx(Dot,{size:e,color:S,delay:150*i,duration:600,reduced:h.reduced},t))})}return _jsx(ActivityIndicator,{color:S,size:"sm"===i?"small":"large",style:{width:v,height:v}})},[a,i,v,S,j.dotsRow,j.container,h.reduced,p.radius.pill,p.colors.surface,p.colors["bg-subtle"]]),A=l??n??m.loading,C=useRef(A);C.current=A,useEffect(()=>{g&&announce(C.current)},[g]);const R=useSquircle(f,p.radius.lg),E=R.active&&R.size?{borderRadius:squircleHostRadius(R.size.width,R.size.height,p.radius.lg)}:null;let w=j.inlineContent;f?w=j.overlayContent:g&&(w=j.containedContent);const z=_jsxs(Animated.View,{ref:t,accessible:!0,accessibilityRole:"progressbar",accessibilityLiveRegion:g?"none":"polite",accessibilityLabel:A,accessibilityState:{busy:!0},"aria-busy":!0,testID:d,onLayout:R.onLayout,style:[w,E,{opacity:b}],children:[R.active&&R.size?_jsx(SquircleFill,{width:R.size.width,height:R.size.height,radius:p.radius.lg,fill:p.colors.surface}):null,_,n?_jsx(Text,{variant:"body",weight:"medium",style:[j.message,{marginTop:p.space.md}],numberOfLines:2,children:n}):null]});return _jsx(View,f?{pointerEvents:"auto",style:[j.overlay,{backgroundColor:x},u],children:z}:{style:[g?j.containedFill:j.inline,u],children:z})});Spinner.displayName="Spinner";const buildStyles=e=>StyleSheet.create({inline:{alignItems:"center",justifyContent:"center"},inlineContent:{alignItems:"center",justifyContent:"center"},containedFill:{flex:1,alignSelf:"stretch",alignItems:"center",justifyContent:"center",minHeight:Math.round(1.5*sizeMap.lg)+2*e.space.xl},containedContent:{alignItems:"center",justifyContent:"center",paddingHorizontal:e.space.lg},container:{alignItems:"center",justifyContent:"center"},overlay:{...StyleSheet.absoluteFill,alignItems:"center",justifyContent:"center",zIndex:1e3},overlayContent:{alignItems:"center",justifyContent:"center",backgroundColor:e.colors.surface,borderRadius:e.radius.lg,...smoothCorners,paddingHorizontal:e.space.xl,paddingVertical:e.space.xl,minWidth:140,...e.shadow.popover},dotsRow:{flexDirection:"row",alignItems:"center",justifyContent:"center"},message:{textAlign:"center"}});export{Spinner};export default Spinner;