@webority/mobile-ui 0.128.0 → 0.130.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 (312) hide show
  1. package/dist/canvas-kit/kit.js +8340 -8095
  2. package/dist/canvas-kit/manifest.json +492 -333
  3. package/dist/canvas-kit/release.json +6 -6
  4. package/lib/commonjs/components/Accordion/Accordion.js +1 -1
  5. package/lib/commonjs/components/AppBar/AppBar.js +1 -1
  6. package/lib/commonjs/components/AppIcon/AppIcon.js +1 -1
  7. package/lib/commonjs/components/AppIcon/catalog.g.js +1 -1
  8. package/lib/commonjs/components/AppIcon/glyphs.g.js +1 -1
  9. package/lib/commonjs/components/AppIcon/variants.g.js +1 -1
  10. package/lib/commonjs/components/AppLockOverlay/AppLockOverlay.js +1 -1
  11. package/lib/commonjs/components/Avatar/Avatar.js +1 -1
  12. package/lib/commonjs/components/Banner/Banner.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/Card/Card.js +1 -1
  17. package/lib/commonjs/components/Checkbox/Checkbox.js +1 -1
  18. package/lib/commonjs/components/Composer/Composer.js +1 -1
  19. package/lib/commonjs/components/Confirm/confirm.js +1 -1
  20. package/lib/commonjs/components/DatePicker/DatePicker.js +1 -1
  21. package/lib/commonjs/components/DateRangePicker/DateRangePicker.js +1 -1
  22. package/lib/commonjs/components/Descriptions/Descriptions.js +1 -1
  23. package/lib/commonjs/components/Dialog/Dialog.js +1 -1
  24. package/lib/commonjs/components/Drawer/Drawer.js +1 -1
  25. package/lib/commonjs/components/FieldBase/ChoiceText.js +1 -1
  26. package/lib/commonjs/components/FieldBase/FieldBase.js +1 -1
  27. package/lib/commonjs/components/FieldBase/useFloatingLabel.js +1 -1
  28. package/lib/commonjs/components/FilePicker/FilePicker.js +1 -1
  29. package/lib/commonjs/components/FileViewer/FileViewer.js +1 -1
  30. package/lib/commonjs/components/FileViewer/FileViewerImage.js +1 -0
  31. package/lib/commonjs/components/FileViewer/fileSource.js +1 -0
  32. package/lib/commonjs/components/FloatingActionButton/FloatingActionButton.js +1 -1
  33. package/lib/commonjs/components/ForceUpdateDialog/ForceUpdateDialog.js +1 -1
  34. package/lib/commonjs/components/FormField/FormField.js +1 -1
  35. package/lib/commonjs/components/IconBadge/IconBadge.js +1 -1
  36. package/lib/commonjs/components/ImageGallery/ImageGallery.js +1 -1
  37. package/lib/commonjs/components/InlineSelect/InlineSelect.js +1 -1
  38. package/lib/commonjs/components/Input/Input.js +1 -1
  39. package/lib/commonjs/components/ListItem/ListItem.js +1 -1
  40. package/lib/commonjs/components/Markdown/Markdown.js +1 -1
  41. package/lib/commonjs/components/Menu/Menu.js +1 -1
  42. package/lib/commonjs/components/Menu/MenuSurface.js +1 -1
  43. package/lib/commonjs/components/Menu/useContextMenu.js +1 -1
  44. package/lib/commonjs/components/Modal/Modal.js +1 -1
  45. package/lib/commonjs/components/NumberInput/NumberInput.js +1 -1
  46. package/lib/commonjs/components/OTPInput/OTPInput.js +1 -1
  47. package/lib/commonjs/components/OTPInput/OTPResendRow.js +1 -0
  48. package/lib/commonjs/components/OTPInput/index.js +1 -1
  49. package/lib/commonjs/components/OptionSheet/OptionSheet.js +1 -1
  50. package/lib/commonjs/components/PhoneNumberInput/PhoneNumberInput.js +1 -1
  51. package/lib/commonjs/components/PickerTrigger/PickerTrigger.js +1 -1
  52. package/lib/commonjs/components/ProfilePicker/ProfilePicker.js +1 -1
  53. package/lib/commonjs/components/ProgressBar/ProgressBar.js +1 -1
  54. package/lib/commonjs/components/Radio/Radio.js +1 -1
  55. package/lib/commonjs/components/Rating/Rating.js +1 -1
  56. package/lib/commonjs/components/SearchBar/SearchBar.js +1 -1
  57. package/lib/commonjs/components/SectionHeader/SectionHeader.js +1 -1
  58. package/lib/commonjs/components/Select/Select.js +1 -1
  59. package/lib/commonjs/components/SliderField/SliderField.js +1 -1
  60. package/lib/commonjs/components/SquircleImage/SquircleImage.js +1 -1
  61. package/lib/commonjs/components/Text/Text.js +1 -1
  62. package/lib/commonjs/components/Text/textInk.js +1 -0
  63. package/lib/commonjs/components/TimePicker/TimePicker.js +1 -1
  64. package/lib/commonjs/components/Tooltip/Tooltip.js +1 -1
  65. package/lib/commonjs/components/Tour/Tour.js +1 -1
  66. package/lib/commonjs/components/index.js +1 -1
  67. package/lib/commonjs/components/not-drawn.json +1 -0
  68. package/lib/commonjs/form/HookFormField.js +1 -1
  69. package/lib/commonjs/hooks/index.js +1 -1
  70. package/lib/commonjs/hooks/useFieldErrorScroll.js +1 -0
  71. package/lib/commonjs/hooks/useResendCountdown.js +1 -0
  72. package/lib/commonjs/icons.js +1 -0
  73. package/lib/commonjs/index.js +1 -1
  74. package/lib/commonjs/navigation/DiscardGuard.js +1 -1
  75. package/lib/commonjs/navigation/index.js +1 -1
  76. package/lib/commonjs/navigation/useNavigationTheme.js +1 -0
  77. package/lib/commonjs/sizes.js +1 -0
  78. package/lib/commonjs/squircle.js +1 -0
  79. package/lib/commonjs/utils/feedback.js +1 -1
  80. package/lib/commonjs/utils/hapticUtils.js +1 -1
  81. package/lib/module/components/Accordion/Accordion.js +1 -1
  82. package/lib/module/components/AppBar/AppBar.js +1 -1
  83. package/lib/module/components/AppIcon/AppIcon.js +1 -1
  84. package/lib/module/components/AppIcon/catalog.g.js +1 -1
  85. package/lib/module/components/AppIcon/glyphs.g.js +1 -1
  86. package/lib/module/components/AppIcon/variants.g.js +1 -1
  87. package/lib/module/components/AppLockOverlay/AppLockOverlay.js +1 -1
  88. package/lib/module/components/Avatar/Avatar.js +1 -1
  89. package/lib/module/components/Banner/Banner.js +1 -1
  90. package/lib/module/components/BottomSheet/BottomSheet.js +1 -1
  91. package/lib/module/components/Box/Box.js +1 -1
  92. package/lib/module/components/Button/Button.js +1 -1
  93. package/lib/module/components/Card/Card.js +1 -1
  94. package/lib/module/components/Checkbox/Checkbox.js +1 -1
  95. package/lib/module/components/Composer/Composer.js +1 -1
  96. package/lib/module/components/Confirm/confirm.js +1 -1
  97. package/lib/module/components/DatePicker/DatePicker.js +1 -1
  98. package/lib/module/components/DateRangePicker/DateRangePicker.js +1 -1
  99. package/lib/module/components/Descriptions/Descriptions.js +1 -1
  100. package/lib/module/components/Dialog/Dialog.js +1 -1
  101. package/lib/module/components/Drawer/Drawer.js +1 -1
  102. package/lib/module/components/FieldBase/ChoiceText.js +1 -1
  103. package/lib/module/components/FieldBase/FieldBase.js +1 -1
  104. package/lib/module/components/FieldBase/useFloatingLabel.js +1 -1
  105. package/lib/module/components/FilePicker/FilePicker.js +1 -1
  106. package/lib/module/components/FileViewer/FileViewer.js +1 -1
  107. package/lib/module/components/FileViewer/FileViewerImage.js +1 -0
  108. package/lib/module/components/FileViewer/fileSource.js +1 -0
  109. package/lib/module/components/FloatingActionButton/FloatingActionButton.js +1 -1
  110. package/lib/module/components/ForceUpdateDialog/ForceUpdateDialog.js +1 -1
  111. package/lib/module/components/FormField/FormField.js +1 -1
  112. package/lib/module/components/IconBadge/IconBadge.js +1 -1
  113. package/lib/module/components/ImageGallery/ImageGallery.js +1 -1
  114. package/lib/module/components/InlineSelect/InlineSelect.js +1 -1
  115. package/lib/module/components/Input/Input.js +1 -1
  116. package/lib/module/components/ListItem/ListItem.js +1 -1
  117. package/lib/module/components/Markdown/Markdown.js +1 -1
  118. package/lib/module/components/Menu/Menu.js +1 -1
  119. package/lib/module/components/Menu/MenuSurface.js +1 -1
  120. package/lib/module/components/Menu/useContextMenu.js +1 -1
  121. package/lib/module/components/Modal/Modal.js +1 -1
  122. package/lib/module/components/NumberInput/NumberInput.js +1 -1
  123. package/lib/module/components/OTPInput/OTPInput.js +1 -1
  124. package/lib/module/components/OTPInput/OTPResendRow.js +1 -0
  125. package/lib/module/components/OTPInput/index.js +1 -1
  126. package/lib/module/components/OptionSheet/OptionSheet.js +1 -1
  127. package/lib/module/components/PhoneNumberInput/PhoneNumberInput.js +1 -1
  128. package/lib/module/components/PickerTrigger/PickerTrigger.js +1 -1
  129. package/lib/module/components/ProfilePicker/ProfilePicker.js +1 -1
  130. package/lib/module/components/ProgressBar/ProgressBar.js +1 -1
  131. package/lib/module/components/Radio/Radio.js +1 -1
  132. package/lib/module/components/Rating/Rating.js +1 -1
  133. package/lib/module/components/SearchBar/SearchBar.js +1 -1
  134. package/lib/module/components/SectionHeader/SectionHeader.js +1 -1
  135. package/lib/module/components/Select/Select.js +1 -1
  136. package/lib/module/components/SliderField/SliderField.js +1 -1
  137. package/lib/module/components/SquircleImage/SquircleImage.js +1 -1
  138. package/lib/module/components/Text/Text.js +1 -1
  139. package/lib/module/components/Text/textInk.js +1 -0
  140. package/lib/module/components/TimePicker/TimePicker.js +1 -1
  141. package/lib/module/components/Tooltip/Tooltip.js +1 -1
  142. package/lib/module/components/Tour/Tour.js +1 -1
  143. package/lib/module/components/index.js +1 -1
  144. package/lib/module/components/not-drawn.json +1 -0
  145. package/lib/module/form/HookFormField.js +1 -1
  146. package/lib/module/hooks/index.js +1 -1
  147. package/lib/module/hooks/useFieldErrorScroll.js +1 -0
  148. package/lib/module/hooks/useResendCountdown.js +1 -0
  149. package/lib/module/icons.js +1 -0
  150. package/lib/module/index.js +1 -1
  151. package/lib/module/navigation/DiscardGuard.js +1 -1
  152. package/lib/module/navigation/index.js +1 -1
  153. package/lib/module/navigation/useNavigationTheme.js +1 -0
  154. package/lib/module/sizes.js +1 -0
  155. package/lib/module/squircle.js +1 -0
  156. package/lib/module/utils/feedback.js +1 -1
  157. package/lib/module/utils/hapticUtils.js +1 -1
  158. package/lib/typescript/commonjs/components/Accordion/Accordion.d.ts +2 -1
  159. package/lib/typescript/commonjs/components/AppBar/AppBar.d.ts +2 -1
  160. package/lib/typescript/commonjs/components/AppIcon/AppIcon.d.ts +6 -3
  161. package/lib/typescript/commonjs/components/AppIcon/catalog.g.d.ts +1 -1
  162. package/lib/typescript/commonjs/components/AppIcon/glyphs.g.d.ts +1 -0
  163. package/lib/typescript/commonjs/components/AppIcon/index.d.ts +1 -1
  164. package/lib/typescript/commonjs/components/AppLockOverlay/AppLockOverlay.d.ts +3 -3
  165. package/lib/typescript/commonjs/components/Avatar/Avatar.d.ts +7 -0
  166. package/lib/typescript/commonjs/components/Banner/Banner.d.ts +3 -2
  167. package/lib/typescript/commonjs/components/BottomSheet/BottomSheet.d.ts +4 -4
  168. package/lib/typescript/commonjs/components/Box/Box.d.ts +2 -2
  169. package/lib/typescript/commonjs/components/Button/Button.d.ts +3 -0
  170. package/lib/typescript/commonjs/components/Card/Card.d.ts +6 -7
  171. package/lib/typescript/commonjs/components/Checkbox/Checkbox.d.ts +2 -1
  172. package/lib/typescript/commonjs/components/Chip/Chip.d.ts +2 -1
  173. package/lib/typescript/commonjs/components/Composer/Composer.d.ts +4 -0
  174. package/lib/typescript/commonjs/components/DatePicker/DatePicker.d.ts +7 -17
  175. package/lib/typescript/commonjs/components/DateRangePicker/DateRangePicker.d.ts +7 -17
  176. package/lib/typescript/commonjs/components/Descriptions/Descriptions.d.ts +2 -2
  177. package/lib/typescript/commonjs/components/Dialog/Dialog.d.ts +1 -1
  178. package/lib/typescript/commonjs/components/Drawer/Drawer.d.ts +4 -4
  179. package/lib/typescript/commonjs/components/FieldBase/FieldBase.d.ts +8 -6
  180. package/lib/typescript/commonjs/components/FileViewer/FileViewer.d.ts +5 -33
  181. package/lib/typescript/commonjs/components/FileViewer/FileViewerImage.d.ts +5 -0
  182. package/lib/typescript/commonjs/components/FileViewer/fileSource.d.ts +24 -0
  183. package/lib/typescript/commonjs/components/FileViewer/index.d.ts +1 -1
  184. package/lib/typescript/commonjs/components/FloatingActionButton/FloatingActionButton.d.ts +8 -0
  185. package/lib/typescript/commonjs/components/ForceUpdateDialog/ForceUpdateDialog.d.ts +3 -3
  186. package/lib/typescript/commonjs/components/IconBadge/IconBadge.d.ts +4 -0
  187. package/lib/typescript/commonjs/components/IconBadge/index.d.ts +1 -1
  188. package/lib/typescript/commonjs/components/Input/Input.d.ts +3 -2
  189. package/lib/typescript/commonjs/components/ListItem/ListItem.d.ts +7 -7
  190. package/lib/typescript/commonjs/components/Markdown/Markdown.d.ts +3 -1
  191. package/lib/typescript/commonjs/components/Menu/Menu.d.ts +3 -3
  192. package/lib/typescript/commonjs/components/Menu/useContextMenu.d.ts +1 -1
  193. package/lib/typescript/commonjs/components/Modal/Modal.d.ts +14 -4
  194. package/lib/typescript/commonjs/components/NumberInput/NumberInput.d.ts +2 -0
  195. package/lib/typescript/commonjs/components/OTPInput/OTPResendRow.d.ts +25 -0
  196. package/lib/typescript/commonjs/components/OTPInput/index.d.ts +2 -0
  197. package/lib/typescript/commonjs/components/OptionSheet/OptionSheet.d.ts +5 -5
  198. package/lib/typescript/commonjs/components/PhoneNumberInput/PhoneNumberInput.d.ts +3 -2
  199. package/lib/typescript/commonjs/components/PickerTrigger/PickerTrigger.d.ts +7 -2
  200. package/lib/typescript/commonjs/components/PickerTrigger/index.d.ts +1 -1
  201. package/lib/typescript/commonjs/components/ProgressBar/ProgressBar.d.ts +2 -0
  202. package/lib/typescript/commonjs/components/Radio/Radio.d.ts +2 -0
  203. package/lib/typescript/commonjs/components/Rating/Rating.d.ts +2 -0
  204. package/lib/typescript/commonjs/components/SearchBar/SearchBar.d.ts +5 -3
  205. package/lib/typescript/commonjs/components/SectionHeader/SectionHeader.d.ts +2 -0
  206. package/lib/typescript/commonjs/components/SegmentedControl/SegmentedControl.d.ts +2 -0
  207. package/lib/typescript/commonjs/components/Select/Select.d.ts +4 -3
  208. package/lib/typescript/commonjs/components/Slider/Slider.d.ts +2 -0
  209. package/lib/typescript/commonjs/components/SliderField/SliderField.d.ts +2 -2
  210. package/lib/typescript/commonjs/components/SquircleImage/SquircleImage.d.ts +4 -3
  211. package/lib/typescript/commonjs/components/Stepper/Stepper.d.ts +2 -0
  212. package/lib/typescript/commonjs/components/Switch/Switch.d.ts +2 -0
  213. package/lib/typescript/commonjs/components/Text/Text.d.ts +2 -0
  214. package/lib/typescript/commonjs/components/Text/textInk.d.ts +14 -0
  215. package/lib/typescript/commonjs/components/TimePicker/TimePicker.d.ts +7 -18
  216. package/lib/typescript/commonjs/components/Tooltip/Tooltip.d.ts +4 -3
  217. package/lib/typescript/commonjs/components/Tour/Tour.d.ts +1 -1
  218. package/lib/typescript/commonjs/components/index.d.ts +5 -6
  219. package/lib/typescript/commonjs/form/HookFormField.d.ts +4 -4
  220. package/lib/typescript/commonjs/hooks/index.d.ts +4 -0
  221. package/lib/typescript/commonjs/hooks/useFieldErrorScroll.d.ts +28 -0
  222. package/lib/typescript/commonjs/hooks/useResendCountdown.d.ts +16 -0
  223. package/lib/typescript/commonjs/icons.d.ts +3 -0
  224. package/lib/typescript/commonjs/index.d.ts +9 -8
  225. package/lib/typescript/commonjs/navigation/index.d.ts +1 -0
  226. package/lib/typescript/commonjs/navigation/useNavigationTheme.d.ts +7 -0
  227. package/lib/typescript/commonjs/sizes.d.ts +2 -0
  228. package/lib/typescript/commonjs/squircle.d.ts +2 -0
  229. package/lib/typescript/commonjs/utils/feedback.d.ts +2 -2
  230. package/lib/typescript/commonjs/utils/hapticUtils.d.ts +2 -0
  231. package/lib/typescript/module/components/Accordion/Accordion.d.ts +2 -1
  232. package/lib/typescript/module/components/AppBar/AppBar.d.ts +2 -1
  233. package/lib/typescript/module/components/AppIcon/AppIcon.d.ts +6 -3
  234. package/lib/typescript/module/components/AppIcon/catalog.g.d.ts +1 -1
  235. package/lib/typescript/module/components/AppIcon/glyphs.g.d.ts +1 -0
  236. package/lib/typescript/module/components/AppIcon/index.d.ts +1 -1
  237. package/lib/typescript/module/components/AppLockOverlay/AppLockOverlay.d.ts +3 -3
  238. package/lib/typescript/module/components/Avatar/Avatar.d.ts +7 -0
  239. package/lib/typescript/module/components/Banner/Banner.d.ts +3 -2
  240. package/lib/typescript/module/components/BottomSheet/BottomSheet.d.ts +4 -4
  241. package/lib/typescript/module/components/Box/Box.d.ts +2 -2
  242. package/lib/typescript/module/components/Button/Button.d.ts +3 -0
  243. package/lib/typescript/module/components/Card/Card.d.ts +6 -7
  244. package/lib/typescript/module/components/Checkbox/Checkbox.d.ts +2 -1
  245. package/lib/typescript/module/components/Chip/Chip.d.ts +2 -1
  246. package/lib/typescript/module/components/Composer/Composer.d.ts +4 -0
  247. package/lib/typescript/module/components/DatePicker/DatePicker.d.ts +7 -17
  248. package/lib/typescript/module/components/DateRangePicker/DateRangePicker.d.ts +7 -17
  249. package/lib/typescript/module/components/Descriptions/Descriptions.d.ts +2 -2
  250. package/lib/typescript/module/components/Dialog/Dialog.d.ts +1 -1
  251. package/lib/typescript/module/components/Drawer/Drawer.d.ts +4 -4
  252. package/lib/typescript/module/components/FieldBase/FieldBase.d.ts +8 -6
  253. package/lib/typescript/module/components/FileViewer/FileViewer.d.ts +5 -33
  254. package/lib/typescript/module/components/FileViewer/FileViewerImage.d.ts +5 -0
  255. package/lib/typescript/module/components/FileViewer/fileSource.d.ts +24 -0
  256. package/lib/typescript/module/components/FileViewer/index.d.ts +1 -1
  257. package/lib/typescript/module/components/FloatingActionButton/FloatingActionButton.d.ts +8 -0
  258. package/lib/typescript/module/components/ForceUpdateDialog/ForceUpdateDialog.d.ts +3 -3
  259. package/lib/typescript/module/components/IconBadge/IconBadge.d.ts +4 -0
  260. package/lib/typescript/module/components/IconBadge/index.d.ts +1 -1
  261. package/lib/typescript/module/components/Input/Input.d.ts +3 -2
  262. package/lib/typescript/module/components/ListItem/ListItem.d.ts +7 -7
  263. package/lib/typescript/module/components/Markdown/Markdown.d.ts +3 -1
  264. package/lib/typescript/module/components/Menu/Menu.d.ts +3 -3
  265. package/lib/typescript/module/components/Menu/useContextMenu.d.ts +1 -1
  266. package/lib/typescript/module/components/Modal/Modal.d.ts +14 -4
  267. package/lib/typescript/module/components/NumberInput/NumberInput.d.ts +2 -0
  268. package/lib/typescript/module/components/OTPInput/OTPResendRow.d.ts +25 -0
  269. package/lib/typescript/module/components/OTPInput/index.d.ts +2 -0
  270. package/lib/typescript/module/components/OptionSheet/OptionSheet.d.ts +5 -5
  271. package/lib/typescript/module/components/PhoneNumberInput/PhoneNumberInput.d.ts +3 -2
  272. package/lib/typescript/module/components/PickerTrigger/PickerTrigger.d.ts +7 -2
  273. package/lib/typescript/module/components/PickerTrigger/index.d.ts +1 -1
  274. package/lib/typescript/module/components/ProgressBar/ProgressBar.d.ts +2 -0
  275. package/lib/typescript/module/components/Radio/Radio.d.ts +2 -0
  276. package/lib/typescript/module/components/Rating/Rating.d.ts +2 -0
  277. package/lib/typescript/module/components/SearchBar/SearchBar.d.ts +5 -3
  278. package/lib/typescript/module/components/SectionHeader/SectionHeader.d.ts +2 -0
  279. package/lib/typescript/module/components/SegmentedControl/SegmentedControl.d.ts +2 -0
  280. package/lib/typescript/module/components/Select/Select.d.ts +4 -3
  281. package/lib/typescript/module/components/Slider/Slider.d.ts +2 -0
  282. package/lib/typescript/module/components/SliderField/SliderField.d.ts +2 -2
  283. package/lib/typescript/module/components/SquircleImage/SquircleImage.d.ts +4 -3
  284. package/lib/typescript/module/components/Stepper/Stepper.d.ts +2 -0
  285. package/lib/typescript/module/components/Switch/Switch.d.ts +2 -0
  286. package/lib/typescript/module/components/Text/Text.d.ts +2 -0
  287. package/lib/typescript/module/components/Text/textInk.d.ts +14 -0
  288. package/lib/typescript/module/components/TimePicker/TimePicker.d.ts +7 -18
  289. package/lib/typescript/module/components/Tooltip/Tooltip.d.ts +4 -3
  290. package/lib/typescript/module/components/Tour/Tour.d.ts +1 -1
  291. package/lib/typescript/module/components/index.d.ts +5 -6
  292. package/lib/typescript/module/form/HookFormField.d.ts +4 -4
  293. package/lib/typescript/module/hooks/index.d.ts +4 -0
  294. package/lib/typescript/module/hooks/useFieldErrorScroll.d.ts +28 -0
  295. package/lib/typescript/module/hooks/useResendCountdown.d.ts +16 -0
  296. package/lib/typescript/module/icons.d.ts +3 -0
  297. package/lib/typescript/module/index.d.ts +9 -8
  298. package/lib/typescript/module/navigation/index.d.ts +1 -0
  299. package/lib/typescript/module/navigation/useNavigationTheme.d.ts +7 -0
  300. package/lib/typescript/module/sizes.d.ts +2 -0
  301. package/lib/typescript/module/squircle.d.ts +2 -0
  302. package/lib/typescript/module/utils/feedback.d.ts +2 -2
  303. package/lib/typescript/module/utils/hapticUtils.d.ts +2 -0
  304. package/package.json +37 -7
  305. package/lib/commonjs/components/Notation/Notation.js +0 -1
  306. package/lib/commonjs/components/Notation/index.js +0 -1
  307. package/lib/module/components/Notation/Notation.js +0 -1
  308. package/lib/module/components/Notation/index.js +0 -1
  309. package/lib/typescript/commonjs/components/Notation/Notation.d.ts +0 -53
  310. package/lib/typescript/commonjs/components/Notation/index.d.ts +0 -3
  311. package/lib/typescript/module/components/Notation/Notation.d.ts +0 -53
  312. package/lib/typescript/module/components/Notation/index.d.ts +0 -3
@@ -1 +1 @@
1
- "use strict";import{useEffect,useMemo,useRef}from"react";import{View}from"react-native";import{useSafeAreaInsets}from"react-native-safe-area-context";import{makeStyles,useTheme}from"../../theme/index.js";import{smoothCorners}from"../../utils/corners.js";import{AppIcon}from"../AppIcon/index.js";import{Button}from"../Button/index.js";import{Modal}from"../Modal/index.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_APP_LOCK_OVERLAY_LABELS=Object.freeze({title:"Locked",message:"Unlock to continue",unlock:"Unlock",lockout:"Too many tries. Wait a moment, then try again.",notEnrolled:"Set up a screen lock on this phone to use app lock.",failed:"That didn't unlock. Try again."});const noop=()=>{},useStyles=makeStyles(e=>({body:{alignItems:"center",flex:1,gap:e.space.sm,justifyContent:"center",paddingHorizontal:e.space["2xl"]},footer:{paddingHorizontal:e.space.xl},iconCircle:{alignItems:"center",backgroundColor:e.colors["primary-wash"],borderRadius:e.radius.pill,...smoothCorners,height:e.space["4xl"],justifyContent:"center",marginBottom:e.space.md,width:e.space["4xl"]}})),failureMessage=(e,t)=>{switch(e){case"lockout":return t.lockout;case"not-enrolled":return t.notEnrolled;case"failed":case"not-available":return t.failed;default:return null}};export function AppLockOverlay({visible:e,onUnlock:t,failure:o,secondaryAction:s,brandMark:n,labels:r,testID:l}){const a=useTheme(),i=useStyles(),c=useSafeAreaInsets(),u=useMemo(()=>({...DEFAULT_APP_LOCK_OVERLAY_LABELS,...r}),[r]),d=useRef(t);d.current=t,useEffect(()=>{e&&d.current()},[e]);const m=failureMessage(o,u);return _jsxs(Modal,{visible:e,onClose:noop,presentation:"fullScreen",hardwareBackPress:!1,haptic:!1,accessibilityLabel:u.title,testID:l,children:[_jsxs(View,{style:i.body,children:[n??_jsx(View,{style:i.iconCircle,children:_jsx(AppIcon,{name:"lock",size:"xl",color:a.colors["primary-text"]})}),_jsx(Text,{variant:"h3",weight:"semibold",align:"center",children:u.title}),_jsx(Text,{variant:"bodySmall",weight:"medium",align:"center",children:u.message}),m?_jsx(Text,{variant:"caption",weight:"semibold",align:"center",color:"danger",children:m}):null]}),_jsxs(View,{style:[i.footer,{paddingBottom:a.space.xl+c.bottom}],children:[_jsx(Button,{fullWidth:!0,size:"lg",label:u.unlock,onPress:t,testID:l?`${l}-unlock`:void 0}),s?_jsx(Button,{variant:"link",label:s.label,onPress:s.onPress,testID:l?`${l}-secondary`:void 0}):null]})]})}
1
+ "use strict";import{useEffect,useMemo,useRef}from"react";import{View}from"react-native";import{useSafeAreaInsets}from"react-native-safe-area-context";import{makeStyles,useTheme}from"../../theme/index.js";import{smoothCorners}from"../../utils/corners.js";import{AppIcon}from"../AppIcon/index.js";import{Button}from"../Button/index.js";import{Modal}from"../Modal/index.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_APP_LOCK_OVERLAY_LABELS=Object.freeze({title:"Locked",message:"Unlock to continue",unlock:"Unlock",lockout:"Too many tries. Wait a moment, then try again.",notEnrolled:"Set up a screen lock on this phone to use app lock.",failed:"That didn't unlock. Try again."});const noop=()=>{},useStyles=makeStyles(e=>({body:{alignItems:"center",flex:1,gap:e.space.sm,justifyContent:"center",paddingHorizontal:e.space["2xl"]},footer:{paddingHorizontal:e.space.xl},iconCircle:{alignItems:"center",backgroundColor:e.colors["primary-wash"],borderRadius:e.radius.pill,...smoothCorners,height:e.space["4xl"],justifyContent:"center",marginBottom:e.space.md,width:e.space["4xl"]}})),failureMessage=(e,t)=>{switch(e){case"lockout":return t.lockout;case"not-enrolled":return t.notEnrolled;case"failed":case"not-available":return t.failed;default:return null}};export function AppLockOverlay({open:e,onUnlock:t,failure:o,secondaryAction:s,brandMark:n,labels:r,testID:a}){const l=useTheme(),i=useStyles(),c=useSafeAreaInsets(),u=useMemo(()=>({...DEFAULT_APP_LOCK_OVERLAY_LABELS,...r}),[r]),d=useRef(t);d.current=t,useEffect(()=>{e&&d.current()},[e]);const m=failureMessage(o,u);return _jsxs(Modal,{open:e,onClose:noop,presentation:"fullScreen",hardwareBackPress:!1,haptic:!1,accessibilityLabel:u.title,testID:a,children:[_jsxs(View,{style:i.body,children:[n??_jsx(View,{style:i.iconCircle,children:_jsx(AppIcon,{name:"lock",size:"xl",color:l.colors["primary-text"]})}),_jsx(Text,{variant:"h3",weight:"semibold",align:"center",children:u.title}),_jsx(Text,{variant:"bodySmall",weight:"medium",align:"center",children:u.message}),m?_jsx(Text,{variant:"caption",weight:"semibold",align:"center",color:"danger",children:m}):null]}),_jsxs(View,{style:[i.footer,{paddingBottom:l.space.xl+c.bottom}],children:[_jsx(Button,{fullWidth:!0,size:"lg",label:u.unlock,onPress:t,testID:a?`${a}-unlock`:void 0}),s?_jsx(Button,{variant:"link",label:s.label,onPress:s.onPress,testID:a?`${a}-secondary`:void 0}):null]})]})}
@@ -1 +1 @@
1
- "use strict";import{Image}from"expo-image";import{Children,cloneElement,forwardRef,isValidElement,useEffect,useMemo,useRef,useState}from"react";import{Animated,Easing,Pressable,StyleSheet,View}from"react-native";import{createAnimatedValue,useTheme}from"../../theme/index.js";import{tintOf}from"../../utils/color.js";import{smoothCorners}from"../../utils/corners.js";import{resolveHaptic,triggerHaptic}from"../../utils/hapticUtils.js";import{hitSlopMarker}from"../../utils/hitSlop.js";import{warnInvalidValue}from"../../utils/warnInvalidValue.js";import{AppIcon}from"../AppIcon/index.js";import{renderSlotIcon}from"../AppIcon/slotIcon.js";import{Skeleton}from"../Skeleton/index.js";import{Text}from"../Text/index.js";import{jsx as _jsx,Fragment as _Fragment,jsxs as _jsxs}from"react/jsx-runtime";const SOFT_FILL_OPACITY=.14,MIN_TOUCH_TARGET=44,PRESSED_OPACITY=.7,INITIALS_MAX_FONT_SCALE=1.2;export const AVATAR_COLORS=["avatar-1","avatar-2","avatar-3","avatar-4","avatar-5","avatar-6","avatar-7","avatar-8"];export const avatarToneColors=(e,t)=>{const soft=(e,t)=>tintOf(e,.14,t);switch(t){case"primary":return{background:soft(e.colors.primary,e.colors["primary-soft"]),color:e.colors["primary-text"]};case"success":return{background:soft(e.colors.success,e.colors["bg-subtle"]),color:e.colors["success-text"]};case"warning":return{background:soft(e.colors.warning,e.colors["bg-subtle"]),color:e.colors["warning-text"]};case"danger":return{background:soft(e.colors.danger,e.colors["bg-subtle"]),color:e.colors["danger-text"]};case"info":return{background:soft(e.colors.info,e.colors["bg-subtle"]),color:e.colors["info-text"]};default:return{background:e.colors["bg-muted"],color:e.colors["text-body"]}}};export const DEFAULT_AVATAR_LABELS=Object.freeze({avatar:"Avatar",avatarOf:e=>`${e}'s avatar`,verified:"verified",pendingVerification:"pending verification",groupOf:e=>`Group of ${e} ${1===e?"person":"people"}`,moreCount:e=>`${e} more`,moreAvatars:"More avatars"});const sizeMap={xs:24,sm:32,md:48,lg:64,xl:80},resolveSize=e=>sizeMap[e],resolveRadius=(e,t,r,o)=>{switch(t){case"circle":return r/2;case"rounded":return o?e.radius[o]:Math.max(e.radius.sm,Math.round(.22*r));default:return 0}},initialsFromName=e=>{if(!e)return"";const t=e.trim().split(/\s+/u).filter(Boolean);return 0===t.length?"":1===t.length?t[0].charAt(0).toUpperCase():(t[0].charAt(0)+t[1].charAt(0)).toUpperCase()},hashColor=(e,t)=>{if(!e)return t[0];let r=0;for(let t=0;t<e.length;t+=1)r=(r<<5)-r+e.charCodeAt(t),r|=0;return t[Math.abs(r)%t.length]},RING_WIDTH=1.5,keyOfSource=e=>"object"==typeof e&&null!==e&&"uri"in e&&"string"==typeof e.uri?e.uri:e,isRingStatus=e=>"verified"===e||"pending"===e,statusColor=(e,t)=>{switch(t){case"online":case"verified":return e.colors.success;case"busy":return e.colors.danger;case"away":case"pending":return e.colors.warning;default:return e.colors["text-subtle"]}},Avatar=forwardRef((e,t)=>{const{source:r,ImageComponent:o,name:s,size:a="md",shape:i="circle",dimension:n,radius:l,border:c=!1,contentFit:u="cover",placeholderIcon:d,status:m=null,statusPosition:g="bottomRight",tone:h,backgroundColor:p,color:b,fontSize:v,loading:f=!1,accessibilityLabel:y,onPress:A,onLongPress:x,haptic:S,hitSlop:I,style:C,textStyle:w,testID:R,labels:_}=e;warnInvalidValue("Avatar","size",e.size,Object.keys(sizeMap)),warnInvalidValue("Avatar","shape",e.shape,["circle","square","rounded"]),warnInvalidValue("Avatar","radius",e.radius,["sm","md","lg"]),warnInvalidValue("Avatar","contentFit",e.contentFit,["cover","contain"]),warnInvalidValue("Avatar","status",e.status,["online","offline","busy","away","verified","pending"]),warnInvalidValue("Avatar","statusPosition",e.statusPosition,["topRight","bottomRight"]),warnInvalidValue("Avatar","tone",e.tone,["primary","success","warning","danger","info","neutral"]);const j=useMemo(()=>_?{...DEFAULT_AVATAR_LABELS,..._}:DEFAULT_AVATAR_LABELS,[_]),M=useTheme(),[T,V]=useState(null),L=useMemo(()=>n??resolveSize(a),[n,a]),E=useMemo(()=>resolveRadius(M,i,L,l),[M,i,L,l]),k=c?M.size.border:0,z=M.colors.border,O=M.colors.surface,F=useMemo(()=>initialsFromName(s),[s]),D=useMemo(()=>h?avatarToneColors(M,h):null,[M,h]),G=useMemo(()=>p||(D?.background??M.colors[hashColor(s??"",AVATAR_COLORS)]),[p,D,s,M]),P=b??D?.color??M.colors["on-primary"],N=r?keyOfSource(r):null,$=null!==N&&N!==T,B=!$&&""===F&&null!=d,H=b??D?.color??M.colors["text-subtle"],U=v??Math.max(M.text.xs.size,Math.round(.4*L)),W=Math.max(8,Math.round(.25*L)),Y=isRingStatus(m),q=L-2*(Y?3:k),X=Y?resolveRadius(M,i,q,l):Math.max(0,E-k),J=B?renderSlotIcon(d,{color:H,size:Math.round(.45*q),disabled:!1}):null,K=Y?statusColor(M,m):"transparent",Q=Math.max(12,Math.round(.32*L)),Z=Math.max(10,Q-4),ee=p??D?.background??M.colors["bg-muted"],te=$?"contain"===u?"transparent":M.colors["bg-muted"]:B?ee:G,re=R??"avatar",oe=s?j.avatarOf(s):j.avatar,se="verified"===m?`, ${j.verified}`:"pending"===m?`, ${j.pendingVerification}`:"",ae=y??`${oe}${se}`,ie="function"==typeof A||"function"==typeof x,ne=y??`${s||oe}${se}`,le=Math.max(0,Math.ceil((44-L)/2)),ce=I??le,ue=[styles.root,{width:L,height:L,borderRadius:E,...smoothCorners,borderWidth:Y?0:k,borderColor:z,backgroundColor:Y?"transparent":te},C],de=_jsxs(_Fragment,{children:[Y?_jsx(View,{style:[styles.ring,{borderRadius:E,...smoothCorners,borderWidth:1.5,borderColor:K}],accessible:!1,pointerEvents:"none",testID:`${re}-ring`}):null,_jsx(View,{style:[styles.picture,{width:q,height:q,borderRadius:X,...smoothCorners,borderWidth:Y?k:0,borderColor:z,backgroundColor:Y?te:"transparent"}],children:$?(()=>{const e={width:q,height:q,borderRadius:X,...smoothCorners},onError=()=>V(N);return o?_jsx(o,{source:r,onError:onError,style:e,contentFit:u,resizeMode:u,accessibilityIgnoresInvertColors:!0}):_jsx(Image,{source:r,onError:onError,style:e,contentFit:u,accessibilityIgnoresInvertColors:!0})})():J||_jsx(Text,{variant:"label",weight:"semibold",numberOfLines:1,maxFontSizeMultiplier:1.2,style:[styles.initials,{color:P,fontSize:U,lineHeight:Math.round(U*M.leading.body)},w],children:F??" "})}),"verified"===m?_jsx(View,{style:[styles.status,"topRight"===g?styles.badgeTopRight:styles.badgeBottomRight,{width:Q,height:Q,borderRadius:Q/2,...smoothCorners,backgroundColor:O}],accessible:!1,pointerEvents:"none",testID:`${re}-badge`,children:_jsx(AppIcon,{name:"verify",variant:"bold",size:Z,color:K})}):null,m&&!Y?_jsx(View,{style:[styles.status,"topRight"===g?styles.statusTopRight:styles.statusBottomRight,{width:W,height:W,borderRadius:W/2,...smoothCorners,backgroundColor:statusColor(M,m),borderWidth:2,borderColor:O}],accessible:!1,pointerEvents:"none"}):null]}),me=ie?_jsx(Pressable,{ref:t,onPress:A?e=>{const t=resolveHaptic(S,"selection");t&&triggerHaptic(t),A?.(e)}:void 0,onLongPress:x?e=>{const t=resolveHaptic(S,"longPress");t&&triggerHaptic(t),x?.(e)}:void 0,hitSlop:ce,...hitSlopMarker(ce),accessibilityRole:"button",accessibilityLabel:ne,testID:R,style:({pressed:e})=>[ue,e?styles.pressed:null],children:de}):_jsx(View,{ref:t,style:ue,accessible:!0,accessibilityRole:"image",accessibilityLabel:ae,testID:R,children:de});return f?_jsx(AvatarSkeleton,{...e}):me});Avatar.displayName="Avatar";const AvatarSkeleton=({size:e="md",shape:t="circle",dimension:r,style:o})=>{const s=r??resolveSize(e);return _jsx(Skeleton,{shape:"circle"===t?"circle":"rounded"===t?"rounded":"rect",width:s,height:s,style:o})};AvatarSkeleton.displayName="AvatarSkeleton",Avatar.Skeleton=AvatarSkeleton;const styles=StyleSheet.create({root:{alignItems:"center",justifyContent:"center",overflow:"visible",position:"relative"},pressed:{opacity:.7},initials:{textAlign:"center"},ring:{position:"absolute",top:0,right:0,bottom:0,left:0},picture:{alignItems:"center",justifyContent:"center",overflow:"hidden"},status:{position:"absolute"},badgeTopRight:{top:-2,right:-2,alignItems:"center",justifyContent:"center"},badgeBottomRight:{bottom:-2,right:-2,alignItems:"center",justifyContent:"center"},statusTopRight:{top:0,right:0},statusBottomRight:{bottom:0,right:0}}),SPACING_OFFSET={tight:"lg",normal:"md",loose:"sm"},STAGGER_MS=50,ENTRANCE_DURATION_MS=220,AvatarGroupItem=({delay:e,marginLeft:t,borderColor:r,borderWidth:o,children:s})=>{const a=useTheme(),i=useRef(createAnimatedValue(0)).current;return useEffect(()=>{const t=Animated.timing(i,{toValue:1,duration:220,delay:e,easing:Easing.out(Easing.cubic),useNativeDriver:!0});return t.start(),()=>t.stop()},[e,i]),_jsx(Animated.View,{style:[groupStyles.item,{marginLeft:t,borderRadius:a.radius.pill,borderColor:r,borderWidth:o,opacity:i}],children:s})},AvatarGroup=e=>{const{children:t,max:r=4,size:o="md",spacing:s="normal",overflowVariant:a="count",accessibilityLabel:i,style:n,testID:l,labels:c}=e;warnInvalidValue("AvatarGroup","spacing",e.spacing,["tight","normal","loose"]),warnInvalidValue("AvatarGroup","overflowVariant",e.overflowVariant,["count","plus"]),warnInvalidValue("AvatarGroup","size",e.size,Object.keys(sizeMap));const u=useMemo(()=>c?{...DEFAULT_AVATAR_LABELS,...c}:DEFAULT_AVATAR_LABELS,[c]),d=useTheme(),m=useMemo(()=>Children.toArray(t).filter(e=>isValidElement(e)),[t]),g=m.length,h=m.slice(0,r),p=Math.max(0,g-r),b=p>0,v=-d.space[SPACING_OFFSET[s]],f=d.colors.surface,y=i??u.groupOf(g),A=useMemo(()=>resolveSize(o),[o]),x=Math.max(d.text.xs.size,Math.round(.34*A));return _jsxs(View,{style:[groupStyles.row,n],accessible:!0,accessibilityLabel:y,accessibilityRole:"summary",testID:l,children:[h.map((e,t)=>{const r=e.key??`avatar-${t}`,s=cloneElement(e,{size:o,labels:e.props.labels??c});return _jsx(AvatarGroupItem,{delay:50*t,marginLeft:0===t?0:v,borderColor:f,borderWidth:1.5,children:s},r)}),b?_jsx(AvatarGroupItem,{delay:50*h.length,marginLeft:0===h.length?0:v,borderColor:f,borderWidth:1.5,children:_jsx(View,{style:[groupStyles.overflow,{width:A,height:A,borderRadius:A/2,...smoothCorners,backgroundColor:d.colors["surface-disabled"]}],accessible:!0,accessibilityRole:"text",accessibilityLabel:"count"===a?u.moreCount(p):u.moreAvatars,children:_jsx(Text,{variant:"label",weight:"semibold",color:"secondary",numberOfLines:1,maxFontSizeMultiplier:1.2,style:{fontSize:x,lineHeight:Math.round(x*d.leading.body)},children:"count"===a?`+${p}`:"+"})})},"avatar-overflow"):null]})},groupStyles=StyleSheet.create({row:{flexDirection:"row",alignItems:"center"},item:{...smoothCorners},overflow:{alignItems:"center",justifyContent:"center"}});export{Avatar,AvatarGroup};export default Avatar;
1
+ "use strict";import{Image}from"expo-image";import{Children,cloneElement,forwardRef,isValidElement,useEffect,useMemo,useRef,useState}from"react";import{Animated,Easing,Pressable,StyleSheet,View}from"react-native";import{createAnimatedValue,useTheme}from"../../theme/index.js";import{tintOf}from"../../utils/color.js";import{smoothCorners}from"../../utils/corners.js";import{resolveHaptic,triggerHaptic}from"../../utils/hapticUtils.js";import{hitSlopMarker}from"../../utils/hitSlop.js";import{warnInvalidValue}from"../../utils/warnInvalidValue.js";import{AppIcon}from"../AppIcon/index.js";import{renderSlotIcon}from"../AppIcon/slotIcon.js";import{AuthedImage}from"../AuthedImage/AuthedImage.js";import{Skeleton}from"../Skeleton/index.js";import{Text}from"../Text/index.js";import{jsx as _jsx,Fragment as _Fragment,jsxs as _jsxs}from"react/jsx-runtime";const SOFT_FILL_OPACITY=.14,MIN_TOUCH_TARGET=44,PRESSED_OPACITY=.7,INITIALS_MAX_FONT_SCALE=1.2;export const AVATAR_COLORS=["avatar-1","avatar-2","avatar-3","avatar-4","avatar-5","avatar-6","avatar-7","avatar-8"];export const avatarToneColors=(e,t)=>{const soft=(e,t)=>tintOf(e,.14,t);switch(t){case"primary":return{background:soft(e.colors.primary,e.colors["primary-soft"]),color:e.colors["primary-text"]};case"success":return{background:soft(e.colors.success,e.colors["bg-subtle"]),color:e.colors["success-text"]};case"warning":return{background:soft(e.colors.warning,e.colors["bg-subtle"]),color:e.colors["warning-text"]};case"danger":return{background:soft(e.colors.danger,e.colors["bg-subtle"]),color:e.colors["danger-text"]};case"info":return{background:soft(e.colors.info,e.colors["bg-subtle"]),color:e.colors["info-text"]};default:return{background:e.colors["bg-muted"],color:e.colors["text-body"]}}};export const DEFAULT_AVATAR_LABELS=Object.freeze({avatar:"Avatar",avatarOf:e=>`${e}'s avatar`,verified:"verified",pendingVerification:"pending verification",groupOf:e=>`Group of ${e} ${1===e?"person":"people"}`,moreCount:e=>`${e} more`,moreAvatars:"More avatars"});const sizeMap={xs:24,sm:32,md:48,lg:64,xl:80},resolveSize=e=>sizeMap[e],resolveRadius=(e,t,r,o)=>{switch(t){case"circle":return r/2;case"rounded":return o?e.radius[o]:Math.max(e.radius.sm,Math.round(.22*r));default:return 0}},initialsFromName=e=>{if(!e)return"";const t=e.trim().split(/\s+/u).filter(Boolean);return 0===t.length?"":1===t.length?t[0].charAt(0).toUpperCase():(t[0].charAt(0)+t[1].charAt(0)).toUpperCase()},hashColor=(e,t)=>{if(!e)return t[0];let r=0;for(let t=0;t<e.length;t+=1)r=(r<<5)-r+e.charCodeAt(t),r|=0;return t[Math.abs(r)%t.length]},RING_WIDTH=1.5,keyOfSource=e=>"object"==typeof e&&null!==e&&"uri"in e&&"string"==typeof e.uri?e.uri:e,uriOfSource=e=>"object"==typeof e&&null!==e&&"uri"in e&&"string"==typeof e.uri?e.uri:void 0,isRingStatus=e=>"verified"===e||"pending"===e,statusColor=(e,t)=>{switch(t){case"online":case"verified":return e.colors.success;case"busy":return e.colors.danger;case"away":case"pending":return e.colors.warning;default:return e.colors["text-subtle"]}},Avatar=forwardRef((e,t)=>{const{source:r,ImageComponent:o,imageClient:s,name:a,size:i="md",shape:n="circle",dimension:l,radius:c,border:u=!1,contentFit:d="cover",placeholderIcon:m,status:g=null,statusPosition:h="bottomRight",tone:p,backgroundColor:b,color:v,fontSize:f,loading:y=!1,accessibilityLabel:A,onPress:x,onLongPress:S,haptic:I,hitSlop:C,style:w,textStyle:_,testID:R,labels:j}=e;warnInvalidValue("Avatar","size",e.size,Object.keys(sizeMap)),warnInvalidValue("Avatar","shape",e.shape,["circle","square","rounded"]),warnInvalidValue("Avatar","radius",e.radius,["sm","md","lg"]),warnInvalidValue("Avatar","contentFit",e.contentFit,["cover","contain"]),warnInvalidValue("Avatar","status",e.status,["online","offline","busy","away","verified","pending"]),warnInvalidValue("Avatar","statusPosition",e.statusPosition,["topRight","bottomRight"]),warnInvalidValue("Avatar","tone",e.tone,["primary","success","warning","danger","info","neutral"]);const M=useMemo(()=>j?{...DEFAULT_AVATAR_LABELS,...j}:DEFAULT_AVATAR_LABELS,[j]),T=useTheme(),[V,L]=useState(null),E=useMemo(()=>l??resolveSize(i),[l,i]),k=useMemo(()=>resolveRadius(T,n,E,c),[T,n,E,c]),z=u?T.size.border:0,O=T.colors.border,F=T.colors.surface,D=useMemo(()=>initialsFromName(a),[a]),G=useMemo(()=>p?avatarToneColors(T,p):null,[T,p]),P=useMemo(()=>b||(G?.background??T.colors[hashColor(a??"",AVATAR_COLORS)]),[b,G,a,T]),N=v??G?.color??T.colors["on-primary"],$=r?keyOfSource(r):null,B=null!==$&&$!==V,H=!B&&""===D&&null!=m,U=v??G?.color??T.colors["text-subtle"],W=f??Math.max(T.text.xs.size,Math.round(.4*E)),Y=Math.max(8,Math.round(.25*E)),q=isRingStatus(g),X=E-2*(q?3:z),J=q?resolveRadius(T,n,X,c):Math.max(0,k-z),K=H?renderSlotIcon(m,{color:U,size:Math.round(.45*X),disabled:!1}):null,Q=q?statusColor(T,g):"transparent",Z=Math.max(12,Math.round(.32*E)),ee=Math.max(10,Z-4),te=b??G?.background??T.colors["bg-muted"],re=B?"contain"===d?"transparent":T.colors["bg-muted"]:H?te:P,oe=R??"avatar",se=a?M.avatarOf(a):M.avatar,ae="verified"===g?`, ${M.verified}`:"pending"===g?`, ${M.pendingVerification}`:"",ie=A??`${se}${ae}`,ne="function"==typeof x||"function"==typeof S,le=A??`${a||se}${ae}`,ce=Math.max(0,Math.ceil((44-E)/2)),ue=C??ce,de=[styles.root,{width:E,height:E,borderRadius:k,...smoothCorners,borderWidth:q?0:z,borderColor:O,backgroundColor:q?"transparent":re},w],me=_jsxs(_Fragment,{children:[q?_jsx(View,{style:[styles.ring,{borderRadius:k,...smoothCorners,borderWidth:1.5,borderColor:Q}],accessible:!1,pointerEvents:"none",testID:`${oe}-ring`}):null,_jsx(View,{style:[styles.picture,{width:X,height:X,borderRadius:J,...smoothCorners,borderWidth:q?z:0,borderColor:O,backgroundColor:q?re:"transparent"}],children:B?(()=>{const e={width:X,height:X,borderRadius:J,...smoothCorners},onError=()=>L($),t=uriOfSource(r);return o?_jsx(o,{source:r,onError:onError,style:e,contentFit:d,resizeMode:d,accessibilityIgnoresInvertColors:!0}):s&&void 0!==t?_jsx(AuthedImage,{uri:t,client:s,onError:onError,style:e,contentFit:d,placeholder:null,fallback:null,accessibilityIgnoresInvertColors:!0}):_jsx(Image,{source:r,onError:onError,style:e,contentFit:d,accessibilityIgnoresInvertColors:!0})})():K||_jsx(Text,{variant:"label",weight:"semibold",numberOfLines:1,maxFontSizeMultiplier:1.2,style:[styles.initials,{color:N,fontSize:W,lineHeight:Math.round(W*T.leading.body)},_],children:D??" "})}),"verified"===g?_jsx(View,{style:[styles.status,"topRight"===h?styles.badgeTopRight:styles.badgeBottomRight,{width:Z,height:Z,borderRadius:Z/2,...smoothCorners,backgroundColor:F}],accessible:!1,pointerEvents:"none",testID:`${oe}-badge`,children:_jsx(AppIcon,{name:"verify",variant:"bold",size:ee,color:Q})}):null,g&&!q?_jsx(View,{style:[styles.status,"topRight"===h?styles.statusTopRight:styles.statusBottomRight,{width:Y,height:Y,borderRadius:Y/2,...smoothCorners,backgroundColor:statusColor(T,g),borderWidth:2,borderColor:F}],accessible:!1,pointerEvents:"none"}):null]}),ge=ne?_jsx(Pressable,{ref:t,onPress:x?e=>{const t=resolveHaptic(I,"selection");t&&triggerHaptic(t),x?.(e)}:void 0,onLongPress:S?e=>{const t=resolveHaptic(I,"longPress");t&&triggerHaptic(t),S?.(e)}:void 0,hitSlop:ue,...hitSlopMarker(ue),accessibilityRole:"button",accessibilityLabel:le,testID:R,style:({pressed:e})=>[de,e?styles.pressed:null],children:me}):_jsx(View,{ref:t,style:de,accessible:!0,accessibilityRole:"image",accessibilityLabel:ie,testID:R,children:me});return y?_jsx(AvatarSkeleton,{...e}):ge});Avatar.displayName="Avatar";const AvatarSkeleton=({size:e="md",shape:t="circle",dimension:r,style:o})=>{const s=r??resolveSize(e);return _jsx(Skeleton,{shape:"circle"===t?"circle":"rounded"===t?"rounded":"rect",width:s,height:s,style:o})};AvatarSkeleton.displayName="AvatarSkeleton",Avatar.Skeleton=AvatarSkeleton;const styles=StyleSheet.create({root:{alignItems:"center",justifyContent:"center",overflow:"visible",position:"relative"},pressed:{opacity:.7},initials:{textAlign:"center"},ring:{position:"absolute",top:0,right:0,bottom:0,left:0},picture:{alignItems:"center",justifyContent:"center",overflow:"hidden"},status:{position:"absolute"},badgeTopRight:{top:-2,right:-2,alignItems:"center",justifyContent:"center"},badgeBottomRight:{bottom:-2,right:-2,alignItems:"center",justifyContent:"center"},statusTopRight:{top:0,right:0},statusBottomRight:{bottom:0,right:0}}),SPACING_OFFSET={tight:"lg",normal:"md",loose:"sm"},STAGGER_MS=50,ENTRANCE_DURATION_MS=220,AvatarGroupItem=({delay:e,marginLeft:t,borderColor:r,borderWidth:o,children:s})=>{const a=useTheme(),i=useRef(createAnimatedValue(0)).current;return useEffect(()=>{const t=Animated.timing(i,{toValue:1,duration:220,delay:e,easing:Easing.out(Easing.cubic),useNativeDriver:!0});return t.start(),()=>t.stop()},[e,i]),_jsx(Animated.View,{style:[groupStyles.item,{marginLeft:t,borderRadius:a.radius.pill,borderColor:r,borderWidth:o,opacity:i}],children:s})},AvatarGroup=e=>{const{children:t,max:r=4,size:o="md",spacing:s="normal",overflowVariant:a="count",accessibilityLabel:i,style:n,testID:l,labels:c}=e;warnInvalidValue("AvatarGroup","spacing",e.spacing,["tight","normal","loose"]),warnInvalidValue("AvatarGroup","overflowVariant",e.overflowVariant,["count","plus"]),warnInvalidValue("AvatarGroup","size",e.size,Object.keys(sizeMap));const u=useMemo(()=>c?{...DEFAULT_AVATAR_LABELS,...c}:DEFAULT_AVATAR_LABELS,[c]),d=useTheme(),m=useMemo(()=>Children.toArray(t).filter(e=>isValidElement(e)),[t]),g=m.length,h=m.slice(0,r),p=Math.max(0,g-r),b=p>0,v=-d.space[SPACING_OFFSET[s]],f=d.colors.surface,y=i??u.groupOf(g),A=useMemo(()=>resolveSize(o),[o]),x=Math.max(d.text.xs.size,Math.round(.34*A));return _jsxs(View,{style:[groupStyles.row,n],accessible:!0,accessibilityLabel:y,accessibilityRole:"summary",testID:l,children:[h.map((e,t)=>{const r=e.key??`avatar-${t}`,s=cloneElement(e,{size:o,labels:e.props.labels??c});return _jsx(AvatarGroupItem,{delay:50*t,marginLeft:0===t?0:v,borderColor:f,borderWidth:1.5,children:s},r)}),b?_jsx(AvatarGroupItem,{delay:50*h.length,marginLeft:0===h.length?0:v,borderColor:f,borderWidth:1.5,children:_jsx(View,{style:[groupStyles.overflow,{width:A,height:A,borderRadius:A/2,...smoothCorners,backgroundColor:d.colors["surface-disabled"]}],accessible:!0,accessibilityRole:"text",accessibilityLabel:"count"===a?u.moreCount(p):u.moreAvatars,children:_jsx(Text,{variant:"label",weight:"semibold",color:"secondary",numberOfLines:1,maxFontSizeMultiplier:1.2,style:{fontSize:x,lineHeight:Math.round(x*d.leading.body)},children:"count"===a?`+${p}`:"+"})})},"avatar-overflow"):null]})},groupStyles=StyleSheet.create({row:{flexDirection:"row",alignItems:"center"},item:{...smoothCorners},overflow:{alignItems:"center",justifyContent:"center"}});export{Avatar,AvatarGroup};export default Avatar;
@@ -1 +1 @@
1
- "use strict";import{forwardRef,useEffect,useMemo,useRef,useState}from"react";import{Animated,Pressable,StyleSheet,View}from"react-native";import{usePresenceMotion}from"../../hooks/usePresenceMotion.js";import{createAnimatedValue,useTheme}from"../../theme/index.js";import{smoothCorners}from"../../utils/corners.js";import{resolveHaptic,triggerHaptic}from"../../utils/hapticUtils.js";import{hitSlopMarker}from"../../utils/hitSlop.js";import{warnInvalidValue}from"../../utils/warnInvalidValue.js";import{renderSlotIcon}from"../AppIcon/slotIcon.js";import{IconBadge}from"../IconBadge/index.js";import{Skeleton,SkeletonText}from"../Skeleton/index.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_BANNER_LABELS=Object.freeze({dismiss:"Dismiss banner"});const Banner=forwardRef((e,t)=>{const{title:r,message:o,tone:n="neutral",variant:s="bar",icon:i,actions:a,dismissible:l=!1,onClose:c,haptic:d,visible:u=!0,animateMount:m=!0,loading:p=!1,accessibilityRole:g="alert",accessibilityLabel:h,labels:y,style:x,containerStyle:b,iconCircleStyle:f,tintBarStyle:w,closeButtonStyle:j,actionButtonStyle:S,testID:B}=e;warnInvalidValue("Banner","tone",e.tone,["primary","success","warning","danger","info","neutral"]),warnInvalidValue("Banner","variant",e.variant,["bar","wash","tint"]),warnInvalidValue("Banner","accessibilityRole",e.accessibilityRole,["alert","summary","none"]);const v=useTheme(),k=usePresenceMotion(),C=useMemo(()=>buildStyles(v),[v]),_=useMemo(()=>tintFor(v,n),[v,n]),I=useMemo(()=>({...DEFAULT_BANNER_LABELS,...y}),[y]),[R,V]=k.range(-20,0),A=useRef(createAnimatedValue(m&&u?R:0)).current,T=useRef(createAnimatedValue(m&&u?0:u?1:0)).current,[L,D]=useState(u),H=useRef(!0);if(useEffect(()=>{if(H.current&&(H.current=!1,!m))return;let e;return u?(D(!0),e=Animated.parallel([Animated.timing(A,{toValue:V,duration:v.motion.duration.default,useNativeDriver:!0}),Animated.timing(T,{toValue:1,duration:k.duration("default"),useNativeDriver:!0})]),e.start()):L&&(e=Animated.parallel([Animated.timing(A,{toValue:R,duration:v.motion.duration.fast,useNativeDriver:!0}),Animated.timing(T,{toValue:0,duration:k.duration("fast"),useNativeDriver:!0})]),e.start(()=>{D(!1)})),()=>e?.stop()},[u]),!L)return null;const E=r??" ",M="string"==typeof o?o??" ":"",N="wash"===s,z="bar"!==s,P="alert"===g?"danger"===n?"assertive":"polite":"none",W=_jsxs(Animated.View,{ref:t,accessibilityRole:g,accessibilityLiveRegion:P,accessibilityLabel:h,testID:B,style:[C.container,{backgroundColor:z?_.soft:v.colors["bg-subtle"],borderRadius:N?v.radius.sm:v.radius.md,...smoothCorners,padding:v.space.md,opacity:T,transform:[{translateY:A}]},x,b],children:[!N&&v.components.banner["tint-bar-width"]>0?_jsx(View,{style:[C.tintBar,{backgroundColor:_.bar},w]}):null,_jsxs(View,{style:[C.row,void 0===r&&C.rowCentred],children:[!1===i?null:i?_jsx(View,{style:C.iconWrap,children:renderSlotIcon(i,{color:_.ink,size:v.text.xl.size,disabled:!1})}):_jsx(IconBadge,{dimension:ICON_CIRCLE_SIZE,color:_.bar,icon:_jsx(Text,{variant:"body",weight:"bold",accessible:!1,style:[C.iconGlyph,{color:_.ink}],children:_.glyph}),style:[C.iconCircle,f]}),_jsxs(View,{style:C.textBlock,children:[r||p?_jsx(Text,{variant:"body",weight:"semibold",numberOfLines:2,style:{lineHeight:20,...N?{color:_.ink}:null},children:E}):null,"string"==typeof o||p?_jsx(Text,{variant:"bodySmall",color:"secondary",style:{lineHeight:18,marginTop:r?v.space.xxs:0},children:M||" "}):_jsx(View,{style:{marginTop:r?v.space.xxs:0},children:o})]}),l?_jsx(Pressable,{accessibilityRole:"button",accessibilityLabel:I.dismiss,onPress:()=>{const e=resolveHaptic(d,"selection");e&&triggerHaptic(e),c?.()},hitSlop:8,...hitSlopMarker(8),style:({pressed:e})=>[C.closeBtn,{backgroundColor:e?v.colors["surface-pressed"]:"transparent"},j],children:_jsx(Text,{variant:"title",weight:"bold",color:"secondary",accessible:!1,style:{lineHeight:17},children:"×"})}):null]}),a&&a.length>0?_jsx(View,{style:C.actionsRow,children:a.map((e,t)=>{warnInvalidValue("Banner","action.tone",e.tone,["primary","success","warning","danger","info","neutral"]),warnInvalidValue("Banner","action.variant",e.variant,["solid","outline","ghost"]),warnInvalidValue("Banner","action.size",e.size,["sm","md"]);const r=e.tone??"primary",o=e.variant??"ghost",n="primary"===r?_.glyphColor:"neutral"===r?v.colors["text-muted"]:v.colors[r],s="primary"===r?_.ink:"neutral"===r?v.colors["text-muted"]:v.colors[`${r}-text`],i="primary"===r?_.on:"neutral"===r?v.colors["on-neutral-strong"]:v.colors[`on-${r}`],a="solid"===o;return _jsx(Pressable,{accessibilityRole:"button",accessibilityLabel:e.label,testID:e.testID,onPress:()=>{const t=resolveHaptic(d,"selection");t&&triggerHaptic(t),e.onPress()},style:({pressed:t})=>[C.actionBtn,"md"===e.size&&C.actionBtnMd,"outline"===o&&{borderWidth:1,borderColor:s},{backgroundColor:a?n:t?v.colors["surface-pressed"]:"transparent",opacity:a&&t?.85:1},S],children:_jsx(Text,{variant:"bodySmall",weight:"semibold",align:"center",style:{color:a?i:s},children:e.label})},`${e.label}-${t}`)})}):null]});return p?_jsx(BannerSkeleton,{...e}):W});Banner.displayName="Banner";const BannerSkeleton=({title:e,actions:t,icon:r,containerStyle:o,style:n})=>{const s=useTheme(),i=!1!==r;return _jsxs(View,{style:[{flexDirection:"row",alignItems:"flex-start",backgroundColor:s.colors.surface,borderRadius:s.radius.md,...smoothCorners,padding:s.space.md,borderWidth:1,borderColor:s.colors.border},o,n],accessibilityRole:"progressbar",accessibilityState:{busy:!0},"aria-busy":!0,children:[i?_jsx(View,{style:{marginRight:s.space.sm},children:_jsx(Skeleton,{shape:"circle",width:32,height:32})}):null,_jsxs(View,{style:{flex:1},children:[void 0!==e?_jsx(Skeleton,{shape:"text",width:"55%",height:16,style:{marginBottom:s.space.xs}}):null,_jsx(SkeletonText,{lines:2,fontSize:s.text.sm.size,lastLineWidth:"70%"}),t&&t.length>0?_jsx(View,{style:{flexDirection:"row",marginTop:s.space.sm},children:t.map((e,t)=>_jsx(Skeleton,{width:72,height:28,shape:"rounded",style:{marginRight:s.space.sm}},`sk-banner-action-${t}`))}):null]})]})};BannerSkeleton.displayName="BannerSkeleton",Banner.Skeleton=BannerSkeleton;const tintFor=(e,t)=>{switch(t){case"success":return{soft:e.colors["success-soft"],bar:e.colors.success,glyphColor:e.colors.success,ink:e.colors["success-text"],on:e.colors["on-success"],glyph:"✓"};case"warning":return{soft:e.colors["warning-soft"],bar:e.colors.warning,glyphColor:e.colors.warning,ink:e.colors["warning-text"],on:e.colors["on-warning"],glyph:"⚠"};case"danger":return{soft:e.colors["danger-soft"],bar:e.colors.danger,glyphColor:e.colors.danger,ink:e.colors["danger-text"],on:e.colors["on-danger"],glyph:"✗"};case"neutral":return{soft:e.colors["bg-subtle"],bar:e.colors["text-subtle"],glyphColor:e.colors["text-muted"],ink:e.colors["text-muted"],on:e.colors["on-neutral-strong"],glyph:"i"};case"primary":return{soft:e.colors["primary-soft"],bar:e.colors.primary,glyphColor:e.colors.primary,ink:e.colors["primary-text"],on:e.colors["on-primary"],glyph:"i"};case"info":return{soft:e.colors["info-soft"],bar:e.colors.info,glyphColor:e.colors.info,ink:e.colors["info-text"],on:e.colors["on-info"],glyph:"i"};default:return tintFor(e,"neutral")}},ICON_CIRCLE_SIZE=28,buildStyles=e=>{const t=e.components.banner,r=e.space.sm;return StyleSheet.create({container:{overflow:"hidden",paddingLeft:e.space.md},tintBar:{position:"absolute",left:0,top:0,bottom:0,width:t["tint-bar-width"]},row:{flexDirection:"row",alignItems:"flex-start"},rowCentred:{alignItems:"center"},iconWrap:{marginRight:r},iconCircle:{marginRight:r},iconGlyph:{lineHeight:17},textBlock:{flex:1,paddingRight:e.space.xs},closeBtn:{width:28,height:28,borderRadius:e.radius.pill,...smoothCorners,alignItems:"center",justifyContent:"center",marginLeft:e.space.xxs},actionsRow:{flexDirection:"row",flexWrap:"wrap",justifyContent:"flex-end",marginTop:e.space.xs,columnGap:e.space.xs,rowGap:e.space.xs},actionBtn:{paddingHorizontal:e.space.sm,paddingVertical:e.space.xs,borderRadius:e.radius.sm,...smoothCorners,maxWidth:"100%",alignItems:"center",justifyContent:"center"},actionBtnMd:{minHeight:44,paddingHorizontal:e.space.md}})};export{Banner};export default Banner;
1
+ "use strict";import{forwardRef,useEffect,useMemo,useRef,useState}from"react";import{Animated,Pressable,StyleSheet,View}from"react-native";import{usePresenceMotion}from"../../hooks/usePresenceMotion.js";import{createAnimatedValue,useTheme}from"../../theme/index.js";import{smoothCorners}from"../../utils/corners.js";import{resolveHaptic,triggerHaptic}from"../../utils/hapticUtils.js";import{hitSlopMarker}from"../../utils/hitSlop.js";import{warnInvalidValue}from"../../utils/warnInvalidValue.js";import{renderSlotIcon}from"../AppIcon/slotIcon.js";import{IconBadge}from"../IconBadge/index.js";import{Skeleton,SkeletonText}from"../Skeleton/index.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_BANNER_LABELS=Object.freeze({dismiss:"Dismiss banner"});const Banner=forwardRef((e,t)=>{const{title:r,message:o,tone:n="neutral",variant:s="bar",icon:i,actions:a,dismissible:l=!1,onClose:c,haptic:d,open:u=!0,animateMount:m=!0,loading:p=!1,accessibilityRole:g="alert",accessibilityLabel:h,labels:y,style:x,containerStyle:b,iconCircleStyle:f,tintBarStyle:w,closeButtonStyle:j,actionButtonStyle:S,testID:B}=e;warnInvalidValue("Banner","tone",e.tone,["primary","success","warning","danger","info","neutral"]),warnInvalidValue("Banner","variant",e.variant,["bar","wash","tint"]),warnInvalidValue("Banner","accessibilityRole",e.accessibilityRole,["alert","summary","none"]);const v=useTheme(),k=usePresenceMotion(),C=useMemo(()=>buildStyles(v),[v]),_=useMemo(()=>tintFor(v,n),[v,n]),I=useMemo(()=>({...DEFAULT_BANNER_LABELS,...y}),[y]),[R,V]=k.range(-20,0),A=useRef(createAnimatedValue(m&&u?R:0)).current,T=useRef(createAnimatedValue(m&&u?0:u?1:0)).current,[L,D]=useState(u),H=useRef(!0);if(useEffect(()=>{if(H.current&&(H.current=!1,!m))return;let e;return u?(D(!0),e=Animated.parallel([Animated.timing(A,{toValue:V,duration:v.motion.duration.default,useNativeDriver:!0}),Animated.timing(T,{toValue:1,duration:k.duration("default"),useNativeDriver:!0})]),e.start()):L&&(e=Animated.parallel([Animated.timing(A,{toValue:R,duration:v.motion.duration.fast,useNativeDriver:!0}),Animated.timing(T,{toValue:0,duration:k.duration("fast"),useNativeDriver:!0})]),e.start(()=>{D(!1)})),()=>e?.stop()},[u]),!L)return null;const E=r??" ",M="string"==typeof o?o??" ":"",N="wash"===s,z="bar"!==s,P="alert"===g?"danger"===n?"assertive":"polite":"none",W=_jsxs(Animated.View,{ref:t,accessibilityRole:g,accessibilityLiveRegion:P,accessibilityLabel:h,testID:B,style:[C.container,{backgroundColor:z?_.soft:v.colors["bg-subtle"],borderRadius:N?v.radius.sm:v.radius.md,...smoothCorners,padding:v.space.md,opacity:T,transform:[{translateY:A}]},b,x],children:[!N&&v.components.banner["tint-bar-width"]>0?_jsx(View,{style:[C.tintBar,{backgroundColor:_.bar},w]}):null,_jsxs(View,{style:[C.row,void 0===r&&C.rowCentred],children:[!1===i?null:i?_jsx(View,{style:C.iconWrap,children:renderSlotIcon(i,{color:_.ink,size:v.text.xl.size,disabled:!1})}):_jsx(IconBadge,{dimension:ICON_CIRCLE_SIZE,color:_.bar,icon:_jsx(Text,{variant:"body",weight:"bold",accessible:!1,style:[C.iconGlyph,{color:_.ink}],children:_.glyph}),style:[C.iconCircle,f]}),_jsxs(View,{style:C.textBlock,children:[r||p?_jsx(Text,{variant:"body",weight:"semibold",numberOfLines:2,style:{lineHeight:20,...N?{color:_.ink}:null},children:E}):null,"string"==typeof o||p?_jsx(Text,{variant:"bodySmall",color:"secondary",style:{lineHeight:18,marginTop:r?v.space.xxs:0},children:M||" "}):_jsx(View,{style:{marginTop:r?v.space.xxs:0},children:o})]}),l?_jsx(Pressable,{accessibilityRole:"button",accessibilityLabel:I.dismiss,onPress:()=>{const e=resolveHaptic(d,"selection");e&&triggerHaptic(e),c?.()},hitSlop:8,...hitSlopMarker(8),style:({pressed:e})=>[C.closeBtn,{backgroundColor:e?v.colors["surface-pressed"]:"transparent"},j],children:_jsx(Text,{variant:"title",weight:"bold",color:"secondary",accessible:!1,style:{lineHeight:17},children:"×"})}):null]}),a&&a.length>0?_jsx(View,{style:C.actionsRow,children:a.map((e,t)=>{warnInvalidValue("Banner","action.tone",e.tone,["primary","success","warning","danger","info","neutral"]),warnInvalidValue("Banner","action.variant",e.variant,["solid","outline","ghost"]),warnInvalidValue("Banner","action.size",e.size,["sm","md"]);const r=e.tone??"primary",o=e.variant??"ghost",n="primary"===r?_.glyphColor:"neutral"===r?v.colors["text-muted"]:v.colors[r],s="primary"===r?_.ink:"neutral"===r?v.colors["text-muted"]:v.colors[`${r}-text`],i="primary"===r?_.on:"neutral"===r?v.colors["on-neutral-strong"]:v.colors[`on-${r}`],a="solid"===o;return _jsx(Pressable,{accessibilityRole:"button",accessibilityLabel:e.label,testID:e.testID,onPress:()=>{const t=resolveHaptic(d,"selection");t&&triggerHaptic(t),e.onPress()},style:({pressed:t})=>[C.actionBtn,"md"===e.size&&C.actionBtnMd,"outline"===o&&{borderWidth:1,borderColor:s},{backgroundColor:a?n:t?v.colors["surface-pressed"]:"transparent",opacity:a&&t?.85:1},S],children:_jsx(Text,{variant:"bodySmall",weight:"semibold",align:"center",style:{color:a?i:s},children:e.label})},`${e.label}-${t}`)})}):null]});return p?_jsx(BannerSkeleton,{...e}):W});Banner.displayName="Banner";const BannerSkeleton=({title:e,actions:t,icon:r,containerStyle:o,style:n})=>{const s=useTheme(),i=!1!==r;return _jsxs(View,{style:[{flexDirection:"row",alignItems:"flex-start",backgroundColor:s.colors.surface,borderRadius:s.radius.md,...smoothCorners,padding:s.space.md,borderWidth:1,borderColor:s.colors.border},o,n],accessibilityRole:"progressbar",accessibilityState:{busy:!0},"aria-busy":!0,children:[i?_jsx(View,{style:{marginRight:s.space.sm},children:_jsx(Skeleton,{shape:"circle",width:32,height:32})}):null,_jsxs(View,{style:{flex:1},children:[void 0!==e?_jsx(Skeleton,{shape:"text",width:"55%",height:16,style:{marginBottom:s.space.xs}}):null,_jsx(SkeletonText,{lines:2,fontSize:s.text.sm.size,lastLineWidth:"70%"}),t&&t.length>0?_jsx(View,{style:{flexDirection:"row",marginTop:s.space.sm},children:t.map((e,t)=>_jsx(Skeleton,{width:72,height:28,shape:"rounded",style:{marginRight:s.space.sm}},`sk-banner-action-${t}`))}):null]})]})};BannerSkeleton.displayName="BannerSkeleton",Banner.Skeleton=BannerSkeleton;const tintFor=(e,t)=>{switch(t){case"success":return{soft:e.colors["success-soft"],bar:e.colors.success,glyphColor:e.colors.success,ink:e.colors["success-text"],on:e.colors["on-success"],glyph:"✓"};case"warning":return{soft:e.colors["warning-soft"],bar:e.colors.warning,glyphColor:e.colors.warning,ink:e.colors["warning-text"],on:e.colors["on-warning"],glyph:"⚠"};case"danger":return{soft:e.colors["danger-soft"],bar:e.colors.danger,glyphColor:e.colors.danger,ink:e.colors["danger-text"],on:e.colors["on-danger"],glyph:"✗"};case"neutral":return{soft:e.colors["bg-subtle"],bar:e.colors["text-subtle"],glyphColor:e.colors["text-muted"],ink:e.colors["text-muted"],on:e.colors["on-neutral-strong"],glyph:"i"};case"primary":return{soft:e.colors["primary-soft"],bar:e.colors.primary,glyphColor:e.colors.primary,ink:e.colors["primary-text"],on:e.colors["on-primary"],glyph:"i"};case"info":return{soft:e.colors["info-soft"],bar:e.colors.info,glyphColor:e.colors.info,ink:e.colors["info-text"],on:e.colors["on-info"],glyph:"i"};default:return tintFor(e,"neutral")}},ICON_CIRCLE_SIZE=28,buildStyles=e=>{const t=e.components.banner,r=e.space.sm;return StyleSheet.create({container:{overflow:"hidden",paddingLeft:e.space.md},tintBar:{position:"absolute",left:0,top:0,bottom:0,width:t["tint-bar-width"]},row:{flexDirection:"row",alignItems:"flex-start"},rowCentred:{alignItems:"center"},iconWrap:{marginRight:r},iconCircle:{marginRight:r},iconGlyph:{lineHeight:17},textBlock:{flex:1,paddingRight:e.space.xs},closeBtn:{width:28,height:28,borderRadius:e.radius.pill,...smoothCorners,alignItems:"center",justifyContent:"center",marginLeft:e.space.xxs},actionsRow:{flexDirection:"row",flexWrap:"wrap",justifyContent:"flex-end",marginTop:e.space.xs,columnGap:e.space.xs,rowGap:e.space.xs},actionBtn:{paddingHorizontal:e.space.sm,paddingVertical:e.space.xs,borderRadius:e.radius.sm,...smoothCorners,maxWidth:"100%",alignItems:"center",justifyContent:"center"},actionBtnMd:{minHeight:44,paddingHorizontal:e.space.md}})};export{Banner};export default Banner;
@@ -1 +1 @@
1
- "use strict";import{createContext,useCallback,useContext,useEffect,useMemo,useRef,useState}from"react";import{Dimensions,Keyboard,Modal,Platform,ScrollView,StyleSheet,useWindowDimensions,View}from"react-native";import{Gesture,GestureDetector,GestureHandlerRootView}from"react-native-gesture-handler";import{useReanimatedKeyboardAnimation}from"react-native-keyboard-controller";import Animated,{Easing,runOnJS,useAnimatedStyle,useDerivedValue,useSharedValue,withSpring,withTiming}from"react-native-reanimated";import{useSafeAreaInsets}from"react-native-safe-area-context";import{PRESENCE_REDUCE_MOTION,usePresenceMotion}from"../../hooks/usePresenceMotion.js";import{useTheme}from"../../theme/index.js";import{triggerHaptic}from"../../utils/index.js";import{smoothCorners}from"../../utils/corners.js";import{warnInvalidValue}from"../../utils/warnInvalidValue.js";import{ACTIONS_LAYOUTS,OverlayActions}from"../Dialog/OverlayActions.js";import{ModalSafeArea,useModalInsets}from"../ModalSafeArea/ModalSafeArea.js";import{Text}from"../Text/index.js";import{ToastHost}from"../Toast/ToastProvider.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_BOTTOM_SHEET_LABELS=Object.freeze({close:"Close bottom sheet",dragHandle:"Drag handle"});const DEFAULT_SNAP_POINTS=["content"],TABLET_MIN_SHORT_SIDE=600,DIALOG_MAX_WIDTH=560,BottomSheetContext=createContext(null);export const useBottomSheet=()=>{const e=useContext(BottomSheetContext);if(!e)throw new Error("[@webority/mobile-ui] BottomSheet: useBottomSheet must be used inside a <BottomSheet>.");return e};const SPRING_CONFIG={damping:20,stiffness:240,mass:1},CLOSE_VELOCITY_THRESHOLD=1e3,DRAG_ACTIVATION_OFFSET=10,BottomSheet=e=>{const{snapPoints:t=DEFAULT_SNAP_POINTS,visible:o,onClose:s,snapIndex:n,onSnapChange:r,onAnimate:a,onAfterClose:i,enablePanDownToClose:l=!0,enableBackdropPress:u=!0,onBeforeClose:c,title:d,labels:h,scrollable:m=!1,scrollRef:f,onScroll:S,onContentSizeChange:b,onScrollLayout:p,scrollEventThrottle:v,keyboardBehavior:y="shift",inline:g=!1,presentation:w="sheet",animateMount:C=!0,handleIndicatorStyle:x,containerStyle:_,header:T,actions:E,actionsLayout:M="auto",footer:I,headerStyle:O,footerStyle:R,children:k,accessibilityLabel:A,accessibilityViewIsModal:j,testID:V}=e;warnInvalidValue("BottomSheet","presentation",e.presentation,["sheet","dialog","auto"]),warnInvalidValue("BottomSheet","keyboardBehavior",e.keyboardBehavior,["none","shift"]),warnInvalidValue("BottomSheet","actionsLayout",e.actionsLayout,ACTIONS_LAYOUTS);const B=useMemo(()=>({...DEFAULT_BOTTOM_SHEET_LABELS,...h}),[h]),D=null!=T||null!=d,L=null!=E&&E.length>0,P=null!=I||L,N=g?"inline":"modal",H=useTheme(),G=usePresenceMotion(),F=useSafeAreaInsets(),[U,J]=useState(()=>Dimensions.get("window").height),[z,Y]=useState(()=>Dimensions.get("window").width),K=useCallback(e=>{const{height:t,width:o}=e.nativeEvent.layout;t>0&&J(e=>e===t?e:t),o>0&&Y(e=>e===o?e:o)},[]),$=useWindowDimensions(),W="dialog"===w||"auto"===w&&Math.min($.width,$.height)>=600,q=Math.min(560,z-2*H.space.xl),[X,Q]=useModalInsets(),Z="modal"===N?X.top:F.top,ee="modal"===N?X.bottom:F.bottom,te=t.includes("content"),[oe,se]=useMeasuredHeight(),[ne,re]=useMeasuredHeight(),[ae,ie,le]=useMeasuredHeight(),[ue,ce]=useMeasuredHeight(),de=W?H.space.md:oe,he=te?Math.min(de+(D?ne:0)+ae+(P?ue:0)+ee,U-Z):0,me=useCallback((e,t)=>{te&&le(t),b?.(e,t)},[te,b,le]),fe=useMemo(()=>resolveSnapPoints(t,U,he),[t,U,he]),Se=U,be=fe[fe.length-1]??0,pe=useSharedValue(Se),ve=useSharedValue(Se),ye=useSharedValue(1),ge=useSharedValue(-1),[we,Ce]=useState(-1),xe=useRef(!1),[Te,Ee]=useState(!1),[Me,Ie]=useState(!1),Oe=useRef(!1),Re=useRef(i);Re.current=i;const[ke,Ae]=useState(!1),je=useRef(!C&&o),Ve=useRef(-1),Be=useRef(!1);Be.current="modal"===N?Me:ke;const De=useRef(c);De.current=c;const Le=useRef(s);Le.current=s;const Pe=useRef(!1),Ne=useRef(!0),He=useRef([]),Ge=useCallback(e=>{const t=He.current;He.current=[];for(const o of t)o(e)},[]);useEffect(()=>(Ne.current=!0,()=>{Ne.current=!1,Ge(!1)}),[Ge]);const Fe=useCallback(e=>{if(e<0||e>=fe.length)return Se;const t=fe[e];return W?(U-t)/2:U-t},[fe,U,Se,W]),Ue=useCallback(e=>{Ve.current=e;we!==e&&(Ce(e),ge.value=e,e>=0&&r?.(e))},[we,ge,r]),Je=useCallback(()=>{xe.current=!1,ge.value<0&&(Oe.current=!0,"modal"===N?(Ee(!1),"ios"!==Platform.OS&&Ie(!1)):Ae(!1))},[N,ge]),ze=useCallback(()=>{Oe.current&&Ie(!1)},[]);useEffect(()=>{("modal"===N?!Me:!ke)&&Oe.current&&(Oe.current=!1,Re.current?.(),Ge(!0))},[N,Me,ke,Ge]);const Ye=useCallback((e,t,o)=>{xe.current=!0,a?.(t,o),pe.value=withSpring(e,SPRING_CONFIG,e=>{"worklet";e&&runOnJS(Je)()})},[a,pe,Je]),Ke=useCallback(e=>{const t="number"==typeof e?clamp(e,0,fe.length-1):we>=0?we:0,o=ge.value,s=Fe(t);return Oe.current=!1,Ge(!1),"modal"===N?(Ie(!0),Ee(!0)):Ae(!0),o<0&&je.current?(pe.value=s,ye.value=1,Ue(t),void a?.(o,t)):o<0&&G.reduced?(pe.value=s,ye.value=0,ye.value=withTiming(1,{duration:G.duration("fast"),easing:Easing.bezier(...H.motion.ease.decelerate),reduceMotion:PRESENCE_REDUCE_MOTION}),Ue(t),void a?.(o,t)):(o<0&&(pe.value=Se,ye.value=1),Ue(t),void Ye(s,o,t))},[Ye,Se,we,ge,N,a,G,ye,fe.length,Ue,Ge,H.motion.ease.decelerate,pe,Fe]),$e=useCallback(()=>new Promise(e=>{if(Ve.current<0)return void(Be.current?He.current.push(e):e(!0));He.current.push(e),je.current=!1;const t=ge.value;Ue(-1),xe.current=!0,a?.(t,-1);const o=G.reduced?ye:pe,s=G.reduced?0:Se;o.value=withTiming(s,{duration:G.duration("fast"),easing:Easing.bezier(...H.motion.ease.accelerate),reduceMotion:PRESENCE_REDUCE_MOTION},e=>{"worklet";e&&runOnJS(Je)()})}),[Se,ge,Je,a,G,ye,Ue,pe,H.motion.ease.accelerate]),We=useCallback((e,t,o)=>{const s=De.current;if(!s)return void e();if(Pe.current)return void t?.();const n=s();"boolean"!=typeof n?(Pe.current=!0,o?.(),n.then(o=>{Pe.current=!1,o&&Ne.current&&Ve.current>=0?e():t?.()},e=>{throw Pe.current=!1,e})):(n?e:t)?.()},[]),qe=useCallback(()=>new Promise(e=>{Ve.current<0?e(!0):We(()=>{Le.current(),$e(),e(!0)},()=>e(!1))}),[$e,We]),Xe=useCallback(()=>{Le.current()},[]),Qe=useCallback(()=>{u&&qe()},[u,qe]),Ze=useRef(null);useEffect(()=>{const e=Ze.current!==o;Ze.current=o,e?o?Ke(n??0):$e():o&&"number"==typeof n&&n!==ge.value&&Ke(n)},[o,n]);const et=useRef({hostHeight:U,contentSnap:he});useEffect(()=>{const e=et.current;if(e.hostHeight===U&&e.contentSnap===he)return;if(et.current={hostHeight:U,contentSnap:he},e.hostHeight===U&&ge.value<0)return;const t=Fe(ge.value);pe.value=je.current?t:withSpring(t,SPRING_CONFIG)},[U,he]);const tt=U-be,ot=useMemo(()=>fe.map(e=>U-e),[fe,U]),st=useCallback(()=>{const e=Ve.current;e<0||Ye(Fe(e),e,e)},[Ye,Fe]),nt=useCallback((e,t)=>{const o=ge.value;-1!==e?(Ue(e),Ye(t,o,e)):We(()=>{Keyboard.dismiss(),triggerHaptic("selection"),Le.current(),$e()},st,st)},[Ye,$e,ge,We,Ue,st]),rt=useMemo(()=>Gesture.Native().withTestId(V?`${V}-content-gesture`:"bottom-sheet-content-gesture"),[V]),at=useMemo(()=>{const e=ot,t=Se,o=tt,s=l;return Gesture.Pan().withTestId(V?`${V}-pan-gesture`:"bottom-sheet-pan-gesture").activeOffsetY([-10,10]).failOffsetX([-15,15]).onStart(()=>{"worklet";ve.value=pe.value}).onUpdate(e=>{"worklet";const t=ve.value+e.translationY;pe.value=t<o?o+.25*(t-o):t}).onEnd(o=>{"worklet";const n=pe.value;if(o.velocityY>1e3)return s?void runOnJS(nt)(-1,t):void runOnJS(nt)(0,e[0]);let r=0,a=Math.abs(n-e[0]);for(let t=1;t<e.length;t++){const o=Math.abs(n-e[t]);o<a&&(a=o,r=t)}const i=e[0];s&&n-i>80?runOnJS(nt)(-1,t):runOnJS(nt)(r,e[r])})},[Se,ve,l,nt,tt,ot,V,pe]),{height:it}=useReanimatedKeyboardAnimation(),lt="shift"===y,ut=useDerivedValue(()=>lt?it.value:0),ct=fe[we>=0?we:0]??be,dt=H.space.md,ht=useAnimatedStyle(()=>{if(W){const e=ut.value,t=U+e-ct-dt,o=e<0&&pe.value>t?t:pe.value;return{top:o<Z?Z:o,opacity:ye.value}}const e=pe.value+ut.value,t=ut.value<0?Z:tt;return{top:e<t?t:e,opacity:ye.value}}),mt=useAnimatedStyle(()=>{const e=ut.value;if(W){const t=U+e-ct-dt,o=e<0&&pe.value>t?t:pe.value,s=U+e-dt-(o<Z?Z:o);return{height:s<0?0:s>ct?ct:s}}const t=e<0?Z:tt,o=pe.value+e,s=U+e-(o<t?t:o);return{height:s<0?0:s>be?be:s}}),ft=we>=0,St=useMemo(()=>buildStyles(H),[H]),bt=useCallback(()=>{u&&We(()=>{triggerHaptic("selection"),Le.current(),$e()})},[u,$e,We]),pt=useMemo(()=>Gesture.Tap().withTestId(V?`${V}-backdrop-gesture`:"bottom-sheet-backdrop-gesture").maxDuration(250).onEnd((_e,e)=>{"worklet";e&&runOnJS(bt)()}),[bt,V]),vt=useMemo(()=>({snapIndex:we,snapPoints:fe,close:Xe,requestClose:qe}),[we,fe,Xe,qe]);if("inline"===N&&!ke)return null;if("modal"===N&&!Me)return null;const yt=_jsxs(View,{collapsable:!1,style:["modal"===N?St.backdropModal:St.backdropInline,{backgroundColor:H.colors.scrim}],onLayout:K,testID:V,accessibilityViewIsModal:j??ft,children:[_jsx(GestureDetector,{gesture:pt,children:_jsx(Animated.View,{style:StyleSheet.absoluteFill,accessibilityRole:"button",accessibilityLabel:B.close})}),_jsx(Animated.View,{accessibilityRole:"alert",accessibilityLabel:A,accessibilityViewIsModal:j??ft,accessibilityActions:[{name:"escape",label:B.close}],onAccessibilityAction:e=>{"escape"===e.nativeEvent.actionName&&Qe()},onAccessibilityEscape:Qe,style:[St.sheet,{height:be,backgroundColor:H.colors.surface,borderTopLeftRadius:H.radius.xl,borderTopRightRadius:H.radius.xl,...smoothCorners,...H.shadow.modal},W?{height:ct,left:(z-q)/2,right:void 0,width:q,borderBottomLeftRadius:H.radius.xl,borderBottomRightRadius:H.radius.xl}:null,_,ht],children:_jsxs(SheetBody,{style:[St.body,mt],keyboardOffset:ut,children:[W?_jsx(View,{style:{height:H.space.md}}):_jsx(GestureDetector,{gesture:at,children:_jsx(View,{style:St.handleRow,onLayout:te?se:void 0,accessible:!0,accessibilityLabel:B.dragHandle,accessibilityHint:"Drag up or down to resize the sheet, or swipe down to close it",testID:V?`${V}-handle`:"bottom-sheet-handle",children:_jsx(View,{style:[St.handle,{backgroundColor:H.colors.border},x]})})}),D&&_jsxs(View,{style:[St.header,O],onLayout:te?re:void 0,children:[null!=d?_jsx(Text,{variant:"title",accessibilityRole:"header",children:d}):null,T]}),m?_jsx(GestureDetector,{gesture:rt,children:_jsx(ScrollView,{ref:f,style:St.scrollContent,onScroll:S,onContentSizeChange:me,onLayout:p,scrollEventThrottle:v,keyboardShouldPersistTaps:"always",keyboardDismissMode:"none",children:k})}):_jsx(View,{style:te?[St.content,{overflow:"visible"}]:St.content,children:te?_jsx(View,{onLayout:ie,children:k}):k}),P&&_jsxs(View,{style:[St.footer,R],onLayout:te?ce:void 0,children:[L?_jsx(View,{style:St.actions,children:_jsx(OverlayActions,{actions:E??[],layout:M})}):null,I]})]})})]}),gt=_jsx(BottomSheetContext.Provider,{value:vt,children:yt});return"modal"===N?_jsx(Modal,{transparent:!0,visible:Te,onRequestClose:Qe,onDismiss:"ios"===Platform.OS?ze:void 0,statusBarTranslucent:!0,navigationBarTranslucent:!0,animationType:"none",supportedOrientations:["portrait","landscape"],children:_jsxs(ModalSafeArea,{onInsets:Q,children:["android"===Platform.OS?_jsx(GestureHandlerRootView,{style:St.modalRoot,children:gt}):gt,_jsx(ToastHost,{})]})}):gt},SheetBody=({style:e,keyboardOffset:t,children:o})=>{const s=useSafeAreaInsets().bottom,n=useAnimatedStyle(()=>{const e=s+t.value;return{paddingBottom:e>0?e:0}});return _jsx(Animated.View,{style:[e,n],children:o})};BottomSheet.displayName="BottomSheet";const useMeasuredHeight=()=>{const[e,t]=useState(0),o=useCallback(e=>{t(t=>t===e?t:e)},[]);return[e,useCallback(e=>o(e.nativeEvent.layout.height),[o]),o]},resolveSnapPoints=(e,t,o)=>[...e.map(e=>{if("number"==typeof e)return e;if("content"===e)return o;const s=parseFloat(e);return Number.isNaN(s)?0:s/100*t})].sort((e,t)=>e-t),clamp=(e,t,o)=>Math.min(Math.max(e,t),o),buildStyles=e=>StyleSheet.create({backdropModal:{flex:1},backdropInline:{...StyleSheet.absoluteFill},sheet:{position:"absolute",left:0,right:0,overflow:"hidden"},body:{overflow:"hidden"},handleRow:{alignItems:"center",justifyContent:"center",alignSelf:"stretch",paddingTop:e.space.md,paddingBottom:e.space.xl},header:{},actions:{padding:e.space.lg},footer:{},handle:{width:36,height:4,borderRadius:e.radius.pill,...smoothCorners},content:{flex:1,overflow:"hidden"},scrollContent:{flex:1},modalRoot:{flex:1}});export{BottomSheet};export default BottomSheet;
1
+ "use strict";import{createContext,useCallback,useContext,useEffect,useMemo,useRef,useState}from"react";import{Dimensions,Keyboard,Platform,ScrollView,StyleSheet,useWindowDimensions,View}from"react-native";import{Gesture,GestureDetector,GestureHandlerRootView}from"react-native-gesture-handler";import{useReanimatedKeyboardAnimation}from"react-native-keyboard-controller";import Animated,{Easing,runOnJS,useAnimatedStyle,useDerivedValue,useSharedValue,withSpring,withTiming}from"react-native-reanimated";import{useSafeAreaInsets}from"react-native-safe-area-context";import{PRESENCE_REDUCE_MOTION,usePresenceMotion}from"../../hooks/usePresenceMotion.js";import{useTheme}from"../../theme/index.js";import{triggerHaptic}from"../../utils/index.js";import{transparentOf}from"../../utils/color.js";import{smoothCorners}from"../../utils/corners.js";import{warnInvalidValue}from"../../utils/warnInvalidValue.js";import{ACTIONS_LAYOUTS,OverlayActions}from"../Dialog/OverlayActions.js";import{Modal}from"../Modal/Modal.js";import{useModalInsets}from"../ModalSafeArea/ModalSafeArea.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_BOTTOM_SHEET_LABELS=Object.freeze({close:"Close bottom sheet",dragHandle:"Drag handle"});const DEFAULT_SNAP_POINTS=["content"],TABLET_MIN_SHORT_SIDE=600,DIALOG_MAX_WIDTH=560,BottomSheetContext=createContext(null);export const useBottomSheet=()=>{const e=useContext(BottomSheetContext);if(!e)throw new Error("[@webority/mobile-ui] BottomSheet: useBottomSheet must be used inside a <BottomSheet>.");return e};const SPRING_CONFIG={damping:20,stiffness:240,mass:1},CLOSE_VELOCITY_THRESHOLD=1e3,DRAG_ACTIVATION_OFFSET=10,BottomSheet=e=>{const{snapPoints:t=DEFAULT_SNAP_POINTS,open:o,onClose:s,snapIndex:n,onSnapChange:r,onAnimate:a,onAfterClose:l,enablePanDownToClose:i=!0,enableBackdropPress:u=!0,onBeforeClose:c,title:d,labels:h,scrollable:m=!1,scrollRef:f,onScroll:S,onContentSizeChange:b,onScrollLayout:p,scrollEventThrottle:v,keyboardBehavior:y="shift",inline:g=!1,presentation:w="sheet",animateMount:C=!0,handleIndicatorStyle:x,containerStyle:_,header:M,actions:E,actionsLayout:O="auto",footer:T,headerStyle:k,footerStyle:I,children:R,accessibilityLabel:A,accessibilityViewIsModal:j,testID:V}=e;warnInvalidValue("BottomSheet","presentation",e.presentation,["sheet","dialog","auto"]),warnInvalidValue("BottomSheet","keyboardBehavior",e.keyboardBehavior,["none","shift"]),warnInvalidValue("BottomSheet","actionsLayout",e.actionsLayout,ACTIONS_LAYOUTS);const D=useMemo(()=>({...DEFAULT_BOTTOM_SHEET_LABELS,...h}),[h]),B=null!=M||null!=d,L=null!=E&&E.length>0,P=null!=T||L,N=g?"inline":"modal",H=useTheme(),G=usePresenceMotion(),F=useSafeAreaInsets(),[U,J]=useState(()=>Dimensions.get("window").height),[z,Y]=useState(()=>Dimensions.get("window").width),K=useCallback(e=>{const{height:t,width:o}=e.nativeEvent.layout;t>0&&J(e=>e===t?e:t),o>0&&Y(e=>e===o?e:o)},[]),$=useWindowDimensions(),W="dialog"===w||"auto"===w&&Math.min($.width,$.height)>=600,X=Math.min(560,z-2*H.space.xl),[q,Q]=useModalInsets(),Z="modal"===N?q.top:F.top,ee="modal"===N?q.bottom:F.bottom,te=t.includes("content"),[oe,se]=useMeasuredHeight(),[ne,re]=useMeasuredHeight(),[ae,le,ie]=useMeasuredHeight(),[ue,ce]=useMeasuredHeight(),de=W?H.space.md:oe,he=te?Math.min(de+(B?ne:0)+ae+(P?ue:0)+ee,U-Z):0,me=useCallback((e,t)=>{te&&ie(t),b?.(e,t)},[te,b,ie]),fe=useMemo(()=>resolveSnapPoints(t,U,he),[t,U,he]),Se=U,be=fe[fe.length-1]??0,pe=useSharedValue(Se),ve=useSharedValue(Se),ye=useSharedValue(1),ge=useSharedValue(-1),[we,Ce]=useState(-1),xe=useRef(!1),[Me,Ee]=useState(!1),[Oe,Te]=useState(!1),ke=useRef(!1),Ie=useRef(l);Ie.current=l;const[Re,Ae]=useState(!1),je=useRef(!C&&o),Ve=useRef(-1),De=useRef(!1);De.current="modal"===N?Oe:Re;const Be=useRef(c);Be.current=c;const Le=useRef(s);Le.current=s;const Pe=useRef(!1),Ne=useRef(!0),He=useRef([]),Ge=useCallback(e=>{const t=He.current;He.current=[];for(const o of t)o(e)},[]);useEffect(()=>(Ne.current=!0,()=>{Ne.current=!1,Ge(!1)}),[Ge]);const Fe=useCallback(e=>{if(e<0||e>=fe.length)return Se;const t=fe[e];return W?(U-t)/2:U-t},[fe,U,Se,W]),Ue=useCallback(e=>{Ve.current=e;we!==e&&(Ce(e),ge.value=e,e>=0&&r?.(e))},[we,ge,r]),Je=useCallback(()=>{xe.current=!1,ge.value<0&&(ke.current=!0,"modal"===N?(Ee(!1),"ios"!==Platform.OS&&Te(!1)):Ae(!1))},[N,ge]),ze=useCallback(()=>{ke.current&&Te(!1)},[]);useEffect(()=>{("modal"===N?!Oe:!Re)&&ke.current&&(ke.current=!1,Ie.current?.(),Ge(!0))},[N,Oe,Re,Ge]);const Ye=useCallback((e,t,o)=>{xe.current=!0,a?.(t,o),pe.value=withSpring(e,SPRING_CONFIG,e=>{"worklet";e&&runOnJS(Je)()})},[a,pe,Je]),Ke=useCallback(e=>{const t="number"==typeof e?clamp(e,0,fe.length-1):we>=0?we:0,o=ge.value,s=Fe(t);return ke.current=!1,Ge(!1),"modal"===N?(Te(!0),Ee(!0)):Ae(!0),o<0&&je.current?(pe.value=s,ye.value=1,Ue(t),void a?.(o,t)):o<0&&G.reduced?(pe.value=s,ye.value=0,ye.value=withTiming(1,{duration:G.duration("fast"),easing:Easing.bezier(...H.motion.ease.decelerate),reduceMotion:PRESENCE_REDUCE_MOTION}),Ue(t),void a?.(o,t)):(o<0&&(pe.value=Se,ye.value=1),Ue(t),void Ye(s,o,t))},[Ye,Se,we,ge,N,a,G,ye,fe.length,Ue,Ge,H.motion.ease.decelerate,pe,Fe]),$e=useCallback(()=>new Promise(e=>{if(Ve.current<0)return void(De.current?He.current.push(e):e(!0));He.current.push(e),je.current=!1;const t=ge.value;Ue(-1),xe.current=!0,a?.(t,-1);const o=G.reduced?ye:pe,s=G.reduced?0:Se;o.value=withTiming(s,{duration:G.duration("fast"),easing:Easing.bezier(...H.motion.ease.accelerate),reduceMotion:PRESENCE_REDUCE_MOTION},e=>{"worklet";e&&runOnJS(Je)()})}),[Se,ge,Je,a,G,ye,Ue,pe,H.motion.ease.accelerate]),We=useCallback((e,t,o)=>{const s=Be.current;if(!s)return void e();if(Pe.current)return void t?.();const n=s();"boolean"!=typeof n?(Pe.current=!0,o?.(),n.then(o=>{Pe.current=!1,o&&Ne.current&&Ve.current>=0?e():t?.()},e=>{throw Pe.current=!1,e})):(n?e:t)?.()},[]),Xe=useCallback(()=>new Promise(e=>{Ve.current<0?e(!0):We(()=>{Le.current(),$e(),e(!0)},()=>e(!1))}),[$e,We]),qe=useCallback(()=>{Le.current()},[]),Qe=useCallback(()=>{u&&Xe()},[u,Xe]),Ze=useRef(null);useEffect(()=>{const e=Ze.current!==o;Ze.current=o,e?o?Ke(n??0):$e():o&&"number"==typeof n&&n!==ge.value&&Ke(n)},[o,n]);const et=useRef({hostHeight:U,contentSnap:he});useEffect(()=>{const e=et.current;if(e.hostHeight===U&&e.contentSnap===he)return;if(et.current={hostHeight:U,contentSnap:he},e.hostHeight===U&&ge.value<0)return;const t=Fe(ge.value);pe.value=je.current?t:withSpring(t,SPRING_CONFIG)},[U,he]);const tt=U-be,ot=useMemo(()=>fe.map(e=>U-e),[fe,U]),st=useCallback(()=>{const e=Ve.current;e<0||Ye(Fe(e),e,e)},[Ye,Fe]),nt=useCallback((e,t)=>{const o=ge.value;-1!==e?(Ue(e),Ye(t,o,e)):We(()=>{Keyboard.dismiss(),triggerHaptic("selection"),Le.current(),$e()},st,st)},[Ye,$e,ge,We,Ue,st]),rt=useMemo(()=>Gesture.Native().withTestId(V?`${V}-content-gesture`:"bottom-sheet-content-gesture"),[V]),at=useMemo(()=>{const e=ot,t=Se,o=tt,s=i;return Gesture.Pan().withTestId(V?`${V}-pan-gesture`:"bottom-sheet-pan-gesture").activeOffsetY([-10,10]).failOffsetX([-15,15]).onStart(()=>{"worklet";ve.value=pe.value}).onUpdate(e=>{"worklet";const t=ve.value+e.translationY;pe.value=t<o?o+.25*(t-o):t}).onEnd(o=>{"worklet";const n=pe.value;if(o.velocityY>1e3)return s?void runOnJS(nt)(-1,t):void runOnJS(nt)(0,e[0]);let r=0,a=Math.abs(n-e[0]);for(let t=1;t<e.length;t++){const o=Math.abs(n-e[t]);o<a&&(a=o,r=t)}const l=e[0];s&&n-l>80?runOnJS(nt)(-1,t):runOnJS(nt)(r,e[r])})},[Se,ve,i,nt,tt,ot,V,pe]),{height:lt}=useReanimatedKeyboardAnimation(),it="shift"===y,ut=useDerivedValue(()=>it?lt.value:0),ct=fe[we>=0?we:0]??be,dt=H.space.md,ht=useAnimatedStyle(()=>{if(W){const e=ut.value,t=U+e-ct-dt,o=e<0&&pe.value>t?t:pe.value;return{top:o<Z?Z:o,opacity:ye.value}}const e=pe.value+ut.value,t=ut.value<0?Z:tt;return{top:e<t?t:e,opacity:ye.value}}),mt=useAnimatedStyle(()=>{const e=ut.value;if(W){const t=U+e-ct-dt,o=e<0&&pe.value>t?t:pe.value,s=U+e-dt-(o<Z?Z:o);return{height:s<0?0:s>ct?ct:s}}const t=e<0?Z:tt,o=pe.value+e,s=U+e-(o<t?t:o);return{height:s<0?0:s>be?be:s}}),ft=we>=0,St=useMemo(()=>buildStyles(H),[H]),bt=useCallback(()=>{u&&We(()=>{triggerHaptic("selection"),Le.current(),$e()})},[u,$e,We]),pt=useMemo(()=>Gesture.Tap().withTestId(V?`${V}-backdrop-gesture`:"bottom-sheet-backdrop-gesture").maxDuration(250).onEnd((_e,e)=>{"worklet";e&&runOnJS(bt)()}),[bt,V]),vt=useMemo(()=>({snapIndex:we,snapPoints:fe,close:qe,requestClose:Xe}),[we,fe,qe,Xe]);if("inline"===N&&!Re)return null;if("modal"===N&&!Oe)return null;const yt=_jsxs(View,{collapsable:!1,style:["modal"===N?St.backdropModal:St.backdropInline,{backgroundColor:"modal"===N?transparentOf(H.colors.scrim):H.colors.scrim}],onLayout:K,testID:V,accessibilityViewIsModal:j??ft,children:[_jsx(GestureDetector,{gesture:pt,children:_jsx(Animated.View,{style:StyleSheet.absoluteFill,accessibilityRole:"button",accessibilityLabel:D.close})}),_jsx(Animated.View,{accessibilityRole:"alert",accessibilityLabel:A,accessibilityViewIsModal:j??ft,accessibilityActions:[{name:"escape",label:D.close}],onAccessibilityAction:e=>{"escape"===e.nativeEvent.actionName&&Qe()},onAccessibilityEscape:Qe,style:[St.sheet,{height:be,backgroundColor:H.colors.surface,borderTopLeftRadius:H.radius.xl,borderTopRightRadius:H.radius.xl,...smoothCorners,...H.shadow.modal},W?{height:ct,left:(z-X)/2,right:void 0,width:X,borderBottomLeftRadius:H.radius.xl,borderBottomRightRadius:H.radius.xl}:null,_,ht],children:_jsxs(SheetBody,{style:[St.body,mt],keyboardOffset:ut,children:[W?_jsx(View,{style:{height:H.space.md}}):_jsx(GestureDetector,{gesture:at,children:_jsx(View,{style:St.handleRow,onLayout:te?se:void 0,accessible:!0,accessibilityLabel:D.dragHandle,accessibilityHint:"Drag up or down to resize the sheet, or swipe down to close it",testID:V?`${V}-handle`:"bottom-sheet-handle",children:_jsx(View,{style:[St.handle,{backgroundColor:H.colors.border},x]})})}),B&&_jsxs(View,{style:[St.header,k],onLayout:te?re:void 0,children:[null!=d?_jsx(Text,{variant:"title",accessibilityRole:"header",children:d}):null,M]}),m?_jsx(GestureDetector,{gesture:rt,children:_jsx(ScrollView,{ref:f,style:St.scrollContent,onScroll:S,onContentSizeChange:me,onLayout:p,scrollEventThrottle:v,keyboardShouldPersistTaps:"always",keyboardDismissMode:"none",children:R})}):_jsx(View,{style:te?[St.content,{overflow:"visible"}]:St.content,children:te?_jsx(View,{onLayout:le,children:R}):R}),P&&_jsxs(View,{style:[St.footer,I],onLayout:te?ce:void 0,children:[L?_jsx(View,{style:St.actions,children:_jsx(OverlayActions,{actions:E??[],layout:O})}):null,T]})]})})]}),gt=_jsx(BottomSheetContext.Provider,{value:vt,children:yt});return"modal"===N?_jsx(Modal,{open:Me,onClose:Qe,presentation:"fullScreen",bare:!0,backdropPressClose:!1,haptic:!1,animateMount:!1,onInsetsChange:Q,onDismissed:"ios"===Platform.OS?ze:void 0,children:"android"===Platform.OS?_jsx(GestureHandlerRootView,{style:St.modalRoot,children:gt}):gt}):gt},SheetBody=({style:e,keyboardOffset:t,children:o})=>{const s=useSafeAreaInsets().bottom,n=useAnimatedStyle(()=>{const e=s+t.value;return{paddingBottom:e>0?e:0}});return _jsx(Animated.View,{style:[e,n],children:o})};BottomSheet.displayName="BottomSheet";const useMeasuredHeight=()=>{const[e,t]=useState(0),o=useCallback(e=>{t(t=>t===e?t:e)},[]);return[e,useCallback(e=>o(e.nativeEvent.layout.height),[o]),o]},resolveSnapPoints=(e,t,o)=>[...e.map(e=>{if("number"==typeof e)return e;if("content"===e)return o;const s=parseFloat(e);return Number.isNaN(s)?0:s/100*t})].sort((e,t)=>e-t),clamp=(e,t,o)=>Math.min(Math.max(e,t),o),buildStyles=e=>StyleSheet.create({backdropModal:{flex:1},backdropInline:{...StyleSheet.absoluteFill},sheet:{position:"absolute",left:0,right:0,overflow:"hidden"},body:{overflow:"hidden"},handleRow:{alignItems:"center",justifyContent:"center",alignSelf:"stretch",paddingTop:e.space.md,paddingBottom:e.space.xl},header:{},actions:{padding:e.space.lg},footer:{},handle:{width:36,height:4,borderRadius:e.radius.pill,...smoothCorners},content:{flex:1,overflow:"hidden"},scrollContent:{flex:1},modalRoot:{flex:1}});export{BottomSheet};export default BottomSheet;
@@ -1 +1 @@
1
- "use strict";import{forwardRef}from"react";import{View}from"react-native";import{useTheme}from"../../theme/index.js";import{radiusOf,spaceOf}from"../../theme/scale.js";import{smoothCorners}from"../../utils/corners.js";import{SquircleFill,useSquircle}from"../SquircleFill/SquircleFill.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const BACKGROUND_TOKENS=["bg","bg-subtle","bg-muted","surface","scrim","surface-inverse"],space=(e,r)=>null==r?void 0:spaceOf(e,r);export const resolveBoxStyle=(e,r)=>{const l={};return null!=r.p&&(l.padding=space(e,r.p)),null!=r.px&&(l.paddingHorizontal=space(e,r.px)),null!=r.py&&(l.paddingVertical=space(e,r.py)),null!=r.pt&&(l.paddingTop=space(e,r.pt)),null!=r.pr&&(l.paddingRight=space(e,r.pr)),null!=r.pb&&(l.paddingBottom=space(e,r.pb)),null!=r.pl&&(l.paddingLeft=space(e,r.pl)),null!=r.m&&(l.margin=space(e,r.m)),null!=r.mx&&(l.marginHorizontal=space(e,r.mx)),null!=r.my&&(l.marginVertical=space(e,r.my)),null!=r.mt&&(l.marginTop=space(e,r.mt)),null!=r.mr&&(l.marginRight=space(e,r.mr)),null!=r.mb&&(l.marginBottom=space(e,r.mb)),null!=r.ml&&(l.marginLeft=space(e,r.ml)),null!=r.gap&&(l.gap=space(e,r.gap)),null!=r.bg&&(l.backgroundColor=BACKGROUND_TOKENS.includes(r.bg)?e.colors[r.bg]:r.bg),null!=r.radius&&(l.borderRadius=radiusOf(e,r.radius),l.borderCurve=smoothCorners.borderCurve),r.border&&(l.borderWidth=e.size.border,l.borderColor=e.colors.border),null!=r.flex&&(l.flex=r.flex),null!=r.align&&(l.alignItems=r.align),null!=r.justify&&(l.justifyContent=r.justify),null!=r.direction&&(l.flexDirection=r.direction),r.wrap&&(l.flexWrap="wrap"),l};const Box=forwardRef((e,r)=>{const l=useTheme(),{p:o,px:t,py:a,pt:s,pr:i,pb:n,pl:p,m:u,mx:c,my:d,mt:m,mr:g,mb:f,ml:x,gap:b,bg:y,radius:h,border:j,flex:w,align:S,justify:R,direction:B,wrap:C,style:_,children:k,...v}=e,O=resolveBoxStyle(l,{p:o,px:t,py:a,pt:s,pr:i,pb:n,pl:p,m:u,mx:c,my:d,mt:m,mr:g,mb:f,ml:x,gap:b,bg:y,radius:h,border:j,flex:w,align:S,justify:R,direction:B,wrap:C}),N=useSquircle(null!=h&&(null!=y||Boolean(j)),O.borderRadius,v.onLayout),z=N.active?{...O,backgroundColor:"transparent",borderColor:"transparent"}:O;return _jsxs(View,{ref:r,...v,onLayout:N.onLayout,style:[z,_],children:[N.active&&N.size?_jsx(SquircleFill,{width:N.size.width,height:N.size.height,radius:O.borderRadius,fill:O.backgroundColor??"transparent",stroke:O.borderColor,strokeWidth:O.borderWidth??0}):null,k]})});Box.displayName="Box";const Stack=forwardRef(({gap:e="md",...r},l)=>_jsx(Box,{ref:l,direction:"column",gap:e,...r}));Stack.displayName="Stack";const Row=forwardRef(({gap:e="sm",align:r="center",...l},o)=>_jsx(Box,{ref:o,direction:"row",gap:e,align:r,...l}));Row.displayName="Row";const Spacer=({size:e,style:r,testID:l})=>{const o=useTheme();if(null!=e){const t=spaceOf(o,e);return _jsx(View,{testID:l,style:[{width:t,height:t},r]})}return _jsx(View,{testID:l,style:[{flex:1},r]})};Spacer.displayName="Spacer";export{Box,Row,Spacer,Stack};export default Box;
1
+ "use strict";import{forwardRef}from"react";import{View}from"react-native";import{useTheme}from"../../theme/index.js";import{radiusOf,spaceOf}from"../../theme/scale.js";import{smoothCorners}from"../../utils/corners.js";import{SquircleFill,useSquircle}from"../SquircleFill/SquircleFill.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const BACKGROUND_TOKENS=["bg","bg-subtle","bg-muted","surface","scrim","surface-inverse","primary-wash"],space=(r,e)=>null==e?void 0:spaceOf(r,e);export const resolveBoxStyle=(r,e)=>{const l={};return null!=e.p&&(l.padding=space(r,e.p)),null!=e.px&&(l.paddingHorizontal=space(r,e.px)),null!=e.py&&(l.paddingVertical=space(r,e.py)),null!=e.pt&&(l.paddingTop=space(r,e.pt)),null!=e.pr&&(l.paddingRight=space(r,e.pr)),null!=e.pb&&(l.paddingBottom=space(r,e.pb)),null!=e.pl&&(l.paddingLeft=space(r,e.pl)),null!=e.m&&(l.margin=space(r,e.m)),null!=e.mx&&(l.marginHorizontal=space(r,e.mx)),null!=e.my&&(l.marginVertical=space(r,e.my)),null!=e.mt&&(l.marginTop=space(r,e.mt)),null!=e.mr&&(l.marginRight=space(r,e.mr)),null!=e.mb&&(l.marginBottom=space(r,e.mb)),null!=e.ml&&(l.marginLeft=space(r,e.ml)),null!=e.gap&&(l.gap=space(r,e.gap)),null!=e.bg&&(l.backgroundColor=BACKGROUND_TOKENS.includes(e.bg)?r.colors[e.bg]:e.bg),null!=e.radius&&(l.borderRadius=radiusOf(r,e.radius),l.borderCurve=smoothCorners.borderCurve),e.border&&(l.borderWidth=r.size.border,l.borderColor=r.colors.border),null!=e.flex&&(l.flex=e.flex),null!=e.align&&(l.alignItems=e.align),null!=e.justify&&(l.justifyContent=e.justify),null!=e.direction&&(l.flexDirection=e.direction),e.wrap&&(l.flexWrap="wrap"),l};const Box=forwardRef((r,e)=>{const l=useTheme(),{p:o,px:a,py:t,pt:s,pr:i,pb:n,pl:p,m:u,mx:c,my:d,mt:m,mr:g,mb:f,ml:x,gap:b,bg:y,radius:h,border:w,flex:j,align:S,justify:R,direction:B,wrap:C,style:_,children:k,...v}=r,O=resolveBoxStyle(l,{p:o,px:a,py:t,pt:s,pr:i,pb:n,pl:p,m:u,mx:c,my:d,mt:m,mr:g,mb:f,ml:x,gap:b,bg:y,radius:h,border:w,flex:j,align:S,justify:R,direction:B,wrap:C}),N=useSquircle(null!=h&&(null!=y||Boolean(w)),O.borderRadius,v.onLayout),z=N.active?{...O,backgroundColor:"transparent",borderColor:"transparent"}:O;return _jsxs(View,{ref:e,...v,onLayout:N.onLayout,style:[z,_],children:[N.active&&N.size?_jsx(SquircleFill,{width:N.size.width,height:N.size.height,radius:O.borderRadius,fill:O.backgroundColor??"transparent",stroke:O.borderColor,strokeWidth:O.borderWidth??0}):null,k]})});Box.displayName="Box";const Stack=forwardRef(({gap:r="md",...e},l)=>_jsx(Box,{ref:l,direction:"column",gap:r,...e}));Stack.displayName="Stack";const Row=forwardRef(({gap:r="sm",align:e="center",...l},o)=>_jsx(Box,{ref:o,direction:"row",gap:r,align:e,...l}));Row.displayName="Row";const Spacer=({size:r,style:e,testID:l})=>{const o=useTheme();if(null!=r){const a=spaceOf(o,r);return _jsx(View,{testID:l,style:[{width:a,height:a},e]})}return _jsx(View,{testID:l,style:[{flex:1},e]})};Spacer.displayName="Spacer";export{Box,Row,Spacer,Stack};export default Box;
@@ -1 +1 @@
1
- "use strict";import{forwardRef,useMemo,useRef,useState}from"react";import{Animated,Easing,Pressable,StyleSheet,View}from"react-native";import{useFlickGuard}from"../../hooks/useFlickGuard.js";import{usePressAnimation}from"../../hooks/usePressAnimation.js";import{Gradient,resolveButtonSize,useTheme}from"../../theme/index.js";import{createAnimatedValue}from"../../theme/animatedValue.js";import{ariaFromState}from"../../utils/ariaState.js";import{ACCENT_PRESSED_TINT,tintOf}from"../../utils/color.js";import{smoothCorners}from"../../utils/corners.js";import{triggerHaptic}from"../../utils/hapticUtils.js";import{hitSlopMarker}from"../../utils/hitSlop.js";import{warnInvalidValue}from"../../utils/warnInvalidValue.js";import{renderSlotIcon}from"../AppIcon/slotIcon.js";import{Spinner}from"../Spinner/index.js";import{SquircleFill,useSquircle}from"../SquircleFill/SquircleFill.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";export const DEFAULT_BUTTON_LABELS=Object.freeze({loading:"Loading"});const Button=forwardRef((e,o)=>{const{label:t,variant:r,tone:s="primary",size:i,loading:n=!1,disabled:l=!1,fullWidth:a=!1,leftIcon:d,rightIcon:c,iconVariant:u,leftIconBadge:b=!1,haptic:g,rounded:p=!1,gradient:m,style:f,containerStyle:h,textStyle:x,pressAnimation:y,onPress:S,accessibilityLabel:C,accessibilityHint:I,accessibilityState:_,testID:T,onLayout:k,labels:v,...w}=e;warnInvalidValue("Button","variant",e.variant,["solid","soft","outline","ghost","link","glass"]),warnInvalidValue("Button","tone",e.tone,["primary","success","warning","danger","info","neutral"]),warnInvalidValue("Button","size",e.size,["xs","sm","md","lg","xl"]);const j=useTheme(),F=j.settings.components.button,L=r??F?.defaultVariant??"solid",O=i??F?.defaultSize??"md",R=useMemo(()=>({...DEFAULT_BUTTON_LABELS,...v}),[v]),A=!l&&!n,V={..._,disabled:!A,busy:n},B="link"===L,P=y??F?.defaultPressAnimation??(!B&&"scale"),z=usePressAnimation({preset:P||"scale",enabled:!1!==P&&A}),E=useFlickGuard(),W=useMemo(()=>buildStyles(j),[j]),D=useMemo(()=>resolveButtonSize(j,O),[j,O]),N=useMemo(()=>toneFor(j,s),[j,s]),H=useMemo(()=>variantFor(j,L,N,l),[j,L,N,l]),M=useMemo(()=>!m||l||"solid"!==L?null:"string"==typeof m?j.settings.gradients[m]??null:m,[m,l,L,j.settings.gradients]),U=StyleSheet.flatten(f)?.borderRadius,q=B?0:"number"==typeof U?U:p?j.radius.pill:D.radius,G=useSquircle(!M&&"link"!==L,q,k),K=useRef(createAnimatedValue(0)).current,[X,Y]=useState(0),[J,Q]=useState(null),Z=B?e=>Y(e.nativeEvent.layout.width):void 0,$=C??t,ee="outline"===L||"ghost"===L,oe=!ee&&!B,te={color:H.textColor,size:D.icon,disabled:l},re=b&&!B&&Boolean(d),se=j.space.xs,ie=D["min-height"]-2*se-2*H.borderWidth,ne={color:H.badgeInk,size:D["badge-icon"],disabled:l},le=n?_jsx(Spinner,{variant:"circular",size:"sm",color:re?H.badgeInk:H.textColor,accessibilityLabel:R.loading}):d?renderSlotIcon(d,re?ne:te,u):null,ae=_jsxs(View,{style:W.contentRow,children:[re?_jsx(View,{testID:"button-icon-badge",style:[W.iconLeft,W.iconBadge,{width:ie,height:ie,borderRadius:ie/2,backgroundColor:H.badgeFill}],children:le}):le?_jsx(View,{style:W.iconLeft,children:le}):null,_jsxs(View,{onLayout:Z,children:[_jsx(Text,{variant:"label",weight:"semibold",numberOfLines:1,style:[W.label,{color:H.textColor,fontSize:D.text,lineHeight:Math.round(D.text*j.leading.body)},x],children:t}),B?_jsx(Animated.View,{pointerEvents:"none",testID:"button-link-underline",style:[W.linkUnderline,{backgroundColor:H.textColor,transform:[{translateX:K.interpolate({inputRange:[0,1],outputRange:[-X/2,0]})},{scaleX:K.interpolate({inputRange:[0,1],outputRange:[0,1]})}]}]}):null]}),c?_jsx(View,{style:W.iconRight,children:renderSlotIcon(c,te,u)}):null]}),de=B?null===J?LINK_HIT_SLOP:Math.max(LINK_HIT_SLOP,touchSlopFor(J)):touchSlopFor(D["min-height"]),ce={top:de,bottom:de,left:B?LINK_HIT_SLOP:0,right:B?LINK_HIT_SLOP:0};return _jsx(Animated.View,{style:[z.style,a?W.fullWidth:null,h],children:_jsx(Pressable,{ref:o,onPress:e=>{A&&!E.isFlick(e)&&(z.press(),g&&triggerHaptic(g),S?.(e))},onPressIn:e=>{E.onPressIn(e),z.pressIn(),B&&A&&(K.stopAnimation(),K.setValue(0),Animated.timing(K,{toValue:1,duration:j.motion.duration.slower,easing:Easing.bezier(...j.motion.ease.decelerate),useNativeDriver:!0}).start())},onPressOut:()=>{z.pressOut()},disabled:!A,hitSlop:ce,...hitSlopMarker(ce),accessibilityRole:"button",accessibilityLabel:$,accessibilityHint:I,accessibilityState:V,...ariaFromState(V),testID:T,onLayout:e=>{G.onLayout(e),B&&Q(e.nativeEvent.layout.height)},style:({pressed:e})=>[W.base,{paddingHorizontal:B?0:D["padding-x"],paddingVertical:B?0:re?se:D["padding-y"],paddingLeft:re?se:void 0,minHeight:B?void 0:D["min-height"],borderRadius:q,...smoothCorners,backgroundColor:M||G.active?"transparent":H.backgroundColor,borderWidth:H.borderWidth,borderColor:G.active?"transparent":H.borderColor,opacity:n?.55:1,overflow:G.active||B?"visible":"hidden"},e&&ee&&!G.active?{backgroundColor:j.colors["surface-pressed"]}:null,a?W.fullWidth:null,f],...w,"aria-disabled":!A,"aria-busy":n,children:({pressed:e})=>_jsxs(_Fragment,{children:[G.active&&G.size?_jsx(SquircleFill,{width:G.size.width,height:G.size.height,radius:q,fill:e&&ee?j.colors["surface-pressed"]:H.backgroundColor,stroke:H.borderColor,strokeWidth:H.borderWidth}):null,M?_jsx(Gradient,{gradient:M,style:[StyleSheet.absoluteFill,{borderRadius:q,...smoothCorners}]}):null,e&&oe?G.active&&G.size?_jsx(SquircleFill,{width:G.size.width,height:G.size.height,radius:q,fill:H.pressedTint,testID:"button-pressed"}):_jsx(View,{pointerEvents:"none",style:[W.pressedOverlay,{borderRadius:q,backgroundColor:H.pressedTint,...smoothCorners}],testID:"button-pressed"}):null,ae]})})})});Button.displayName="Button";const SOFT_FILL_OPACITY=.14,toneFor=(e,o)=>{switch(o){case"primary":return{base:e.colors.primary,outline:e.colors.primary,on:e.colors["on-primary"],fg:e.colors["primary-text"],soft:tintOf(e.colors.primary,.14,e.colors["primary-soft"])};case"success":return{base:e.colors.success,outline:e.colors.success,on:e.colors["on-success"],fg:e.colors["success-text"],soft:tintOf(e.colors.success,.14,e.colors["bg-subtle"])};case"warning":return{base:e.colors.warning,outline:e.colors.warning,on:e.colors["on-warning"],fg:e.colors["warning-text"],soft:tintOf(e.colors.warning,.14,e.colors["bg-subtle"])};case"danger":return{base:e.colors.danger,outline:e.colors.danger,on:e.colors["on-danger"],fg:e.colors["danger-text"],soft:tintOf(e.colors.danger,.14,e.colors["bg-subtle"])};case"info":return{base:e.colors.info,outline:e.colors.info,on:e.colors["on-info"],fg:e.colors["info-text"],soft:tintOf(e.colors.info,.14,e.colors["bg-subtle"])};default:return{base:e.colors["bg-muted"],outline:e.colors.border,on:e.colors["text-body"],fg:e.colors["text-body"],soft:e.colors["bg-subtle"]}}},BUTTON_BORDER_WIDTH=1,MIN_TOUCH_TARGET=44,LINK_HIT_SLOP=8,touchSlopFor=e=>Math.max(0,Math.ceil((44-e)/2)),variantFor=(e,o,t,r)=>{const s=r?e.colors["text-disabled"]:t.fg,i={badgeFill:e.colors["surface-disabled"],badgeInk:e.colors["text-disabled"]},n=r?i:{badgeFill:t.on,badgeInk:t.base},l=r?i:{badgeFill:t.base,badgeInk:t.on};switch(o){case"solid":return{backgroundColor:r?e.colors["surface-disabled"]:t.base,borderColor:"transparent",borderWidth:1,textColor:r?e.colors["text-disabled"]:t.on,pressedTint:e.colors["surface-pressed"],...n};case"soft":return{backgroundColor:r?e.colors["surface-disabled"]:t.soft,borderColor:"transparent",borderWidth:1,textColor:s,pressedTint:e.colors["surface-pressed"],...l};case"outline":return{backgroundColor:"transparent",borderColor:r?e.colors.border:t.outline,borderWidth:1,textColor:s,pressedTint:e.colors["surface-pressed"],...l};case"ghost":return{backgroundColor:"transparent",borderColor:"transparent",borderWidth:1,textColor:s,pressedTint:e.colors["surface-pressed"],...l};case"link":return{backgroundColor:"transparent",borderColor:"transparent",borderWidth:0,textColor:r?e.colors["text-disabled"]:e.colors.link,pressedTint:e.colors["surface-pressed"],...l};case"glass":return{backgroundColor:e.colors["glass-fill"],borderColor:e.colors["glass-border"],borderWidth:1,textColor:r?e.colors["text-disabled"]:e.colors["on-glass"],pressedTint:ACCENT_PRESSED_TINT,badgeFill:e.colors["glass-badge"],badgeInk:r?e.colors["text-disabled"]:t.base};default:return{backgroundColor:t.base,borderColor:"transparent",borderWidth:1,textColor:t.on,pressedTint:e.colors["surface-pressed"],...n}}};export function buttonLabelInk(e,o){return variantFor(o,e.variant??"solid",toneFor(o,e.tone??"primary"),e.disabled??!1).textColor}const buildStyles=e=>StyleSheet.create({pressedOverlay:{position:"absolute",top:0,right:0,bottom:0,left:0},base:{alignItems:"center",justifyContent:"center",flexDirection:"row",overflow:"hidden"},contentRow:{flexDirection:"row",alignItems:"center",justifyContent:"center"},label:{textAlign:"center",includeFontPadding:!1,textAlignVertical:"center"},linkUnderline:{height:1.5,marginTop:1},iconLeft:{marginRight:e.space.sm},iconBadge:{alignItems:"center",justifyContent:"center"},iconRight:{marginLeft:e.space.sm},fullWidth:{alignSelf:"stretch"}});export{Button};export default Button;
1
+ "use strict";import{forwardRef,useMemo,useRef,useState}from"react";import{Animated,Easing,Pressable,StyleSheet,View}from"react-native";import{useFlickGuard}from"../../hooks/useFlickGuard.js";import{usePressAnimation}from"../../hooks/usePressAnimation.js";import{Gradient,resolveButtonSize,useTheme}from"../../theme/index.js";import{createAnimatedValue}from"../../theme/animatedValue.js";import{ariaFromState}from"../../utils/ariaState.js";import{ACCENT_PRESSED_TINT,tintOf}from"../../utils/color.js";import{smoothCorners}from"../../utils/corners.js";import{resolveHaptic,triggerHaptic}from"../../utils/hapticUtils.js";import{hitSlopMarker}from"../../utils/hitSlop.js";import{warnInvalidValue}from"../../utils/warnInvalidValue.js";import{renderSlotIcon}from"../AppIcon/slotIcon.js";import{Spinner}from"../Spinner/index.js";import{SquircleFill,useSquircle}from"../SquircleFill/SquircleFill.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";export const DEFAULT_BUTTON_LABELS=Object.freeze({loading:"Loading"});const Button=forwardRef((e,o)=>{const{label:t,variant:r,tone:s="primary",size:i,loading:n=!1,disabled:l=!1,fullWidth:a=!1,leftIcon:d,rightIcon:c,iconVariant:u,leftIconBadge:b=!1,haptic:g,rounded:p=!1,gradient:m,style:f,containerStyle:h,textStyle:x,pressAnimation:y,onPress:S,accessibilityLabel:C,accessibilityHint:I,accessibilityState:_,testID:v,onLayout:T,labels:k,...w}=e;warnInvalidValue("Button","variant",e.variant,["solid","soft","outline","ghost","link","glass"]),warnInvalidValue("Button","tone",e.tone,["primary","success","warning","danger","info","neutral"]),warnInvalidValue("Button","size",e.size,["xs","sm","md","lg","xl"]);const j=useTheme(),F=j.settings.components.button,L=r??F?.defaultVariant??"solid",O=i??F?.defaultSize??"md",R=useMemo(()=>({...DEFAULT_BUTTON_LABELS,...k}),[k]),A=!l&&!n,V={..._,disabled:!A,busy:n},B="link"===L,P=y??F?.defaultPressAnimation??(!B&&"scale"),z=usePressAnimation({preset:P||"scale",enabled:!1!==P&&A}),E=useFlickGuard(),W=useMemo(()=>buildStyles(j),[j]),H=useMemo(()=>resolveButtonSize(j,O),[j,O]),D=useMemo(()=>toneFor(j,s),[j,s]),N=useMemo(()=>variantFor(j,L,D,l),[j,L,D,l]),M=useMemo(()=>!m||l||"solid"!==L?null:"string"==typeof m?j.settings.gradients[m]??null:m,[m,l,L,j.settings.gradients]),U=StyleSheet.flatten(f)?.borderRadius,q=B?0:"number"==typeof U?U:p?j.radius.pill:H.radius,G=useSquircle(!M&&"link"!==L,q,T),K=useRef(createAnimatedValue(0)).current,[X,Y]=useState(0),[J,Q]=useState(null),Z=B?e=>Y(e.nativeEvent.layout.width):void 0,$=C??t,ee="outline"===L||"ghost"===L,oe=!ee&&!B,te={color:N.textColor,size:H.icon,disabled:l},re=b&&!B&&Boolean(d),se=j.space.xs,ie=H["min-height"]-2*se-2*N.borderWidth,ne={color:N.badgeInk,size:H["badge-icon"],disabled:l},le=n?_jsx(Spinner,{variant:"circular",size:"sm",color:re?N.badgeInk:N.textColor,accessibilityLabel:R.loading}):d?renderSlotIcon(d,re?ne:te,u):null,ae=_jsxs(View,{style:W.contentRow,children:[re?_jsx(View,{testID:"button-icon-badge",style:[W.iconLeft,W.iconBadge,{width:ie,height:ie,borderRadius:ie/2,backgroundColor:N.badgeFill}],children:le}):le?_jsx(View,{style:W.iconLeft,children:le}):null,_jsxs(View,{onLayout:Z,children:[_jsx(Text,{variant:"label",weight:"semibold",numberOfLines:1,style:[W.label,{color:N.textColor,fontSize:H.text,lineHeight:Math.round(H.text*j.leading.body)},x],children:t}),B?_jsx(Animated.View,{pointerEvents:"none",testID:"button-link-underline",style:[W.linkUnderline,{backgroundColor:N.textColor,transform:[{translateX:K.interpolate({inputRange:[0,1],outputRange:[-X/2,0]})},{scaleX:K.interpolate({inputRange:[0,1],outputRange:[0,1]})}]}]}):null]}),c?_jsx(View,{style:W.iconRight,children:renderSlotIcon(c,te,u)}):null]}),de=B?null===J?LINK_HIT_SLOP:Math.max(LINK_HIT_SLOP,touchSlopFor(J)):touchSlopFor(H["min-height"]),ce={top:de,bottom:de,left:B?LINK_HIT_SLOP:0,right:B?LINK_HIT_SLOP:0};return _jsx(Animated.View,{style:[z.style,a?W.fullWidth:null,h],children:_jsx(Pressable,{ref:o,onPress:e=>{if(!A||E.isFlick(e))return;z.press();const o=resolveHaptic(g,"impactLight");o&&triggerHaptic(o),S?.(e)},onPressIn:e=>{E.onPressIn(e),z.pressIn(),B&&A&&(K.stopAnimation(),K.setValue(0),Animated.timing(K,{toValue:1,duration:j.motion.duration.slower,easing:Easing.bezier(...j.motion.ease.decelerate),useNativeDriver:!0}).start())},onPressOut:()=>{z.pressOut()},disabled:!A,hitSlop:ce,...hitSlopMarker(ce),accessibilityRole:"button",accessibilityLabel:$,accessibilityHint:I,accessibilityState:V,...ariaFromState(V),testID:v,onLayout:e=>{G.onLayout(e),B&&Q(e.nativeEvent.layout.height)},style:({pressed:e})=>[W.base,{paddingHorizontal:B?0:H["padding-x"],paddingVertical:B?0:re?se:H["padding-y"],paddingLeft:re?se:void 0,minHeight:B?void 0:H["min-height"],borderRadius:q,...smoothCorners,backgroundColor:M||G.active?"transparent":N.backgroundColor,borderWidth:N.borderWidth,borderColor:G.active?"transparent":N.borderColor,opacity:n?.55:1,overflow:G.active||B?"visible":"hidden"},e&&ee&&!G.active?{backgroundColor:j.colors["surface-pressed"]}:null,a?W.fullWidth:null,f],...w,"aria-disabled":!A,"aria-busy":n,children:({pressed:e})=>_jsxs(_Fragment,{children:[G.active&&G.size?_jsx(SquircleFill,{width:G.size.width,height:G.size.height,radius:q,fill:e&&ee?j.colors["surface-pressed"]:N.backgroundColor,stroke:N.borderColor,strokeWidth:N.borderWidth}):null,M?_jsx(Gradient,{gradient:M,style:[StyleSheet.absoluteFill,{borderRadius:q,...smoothCorners}]}):null,e&&oe?G.active&&G.size?_jsx(SquircleFill,{width:G.size.width,height:G.size.height,radius:q,fill:N.pressedTint,testID:"button-pressed"}):_jsx(View,{pointerEvents:"none",style:[W.pressedOverlay,{borderRadius:q,backgroundColor:N.pressedTint,...smoothCorners}],testID:"button-pressed"}):null,ae]})})})});Button.displayName="Button";const SOFT_FILL_OPACITY=.14,toneFor=(e,o)=>{switch(o){case"primary":return{base:e.colors.primary,outline:e.colors.primary,on:e.colors["on-primary"],fg:e.colors["primary-text"],soft:tintOf(e.colors.primary,.14,e.colors["primary-soft"])};case"success":return{base:e.colors.success,outline:e.colors.success,on:e.colors["on-success"],fg:e.colors["success-text"],soft:tintOf(e.colors.success,.14,e.colors["bg-subtle"])};case"warning":return{base:e.colors.warning,outline:e.colors.warning,on:e.colors["on-warning"],fg:e.colors["warning-text"],soft:tintOf(e.colors.warning,.14,e.colors["bg-subtle"])};case"danger":return{base:e.colors.danger,outline:e.colors.danger,on:e.colors["on-danger"],fg:e.colors["danger-text"],soft:tintOf(e.colors.danger,.14,e.colors["bg-subtle"])};case"info":return{base:e.colors.info,outline:e.colors.info,on:e.colors["on-info"],fg:e.colors["info-text"],soft:tintOf(e.colors.info,.14,e.colors["bg-subtle"])};default:return{base:e.colors["bg-muted"],outline:e.colors.border,on:e.colors["text-body"],fg:e.colors["text-body"],soft:e.colors["bg-subtle"]}}},BUTTON_BORDER_WIDTH=1,MIN_TOUCH_TARGET=44,LINK_HIT_SLOP=8,touchSlopFor=e=>Math.max(0,Math.ceil((44-e)/2)),variantFor=(e,o,t,r)=>{const s=r?e.colors["text-disabled"]:t.fg,i={badgeFill:e.colors["surface-disabled"],badgeInk:e.colors["text-disabled"]},n=r?i:{badgeFill:t.on,badgeInk:t.base},l=r?i:{badgeFill:t.base,badgeInk:t.on};switch(o){case"solid":return{backgroundColor:r?e.colors["surface-disabled"]:t.base,borderColor:"transparent",borderWidth:1,textColor:r?e.colors["text-disabled"]:t.on,pressedTint:e.colors["surface-pressed"],...n};case"soft":return{backgroundColor:r?e.colors["surface-disabled"]:t.soft,borderColor:"transparent",borderWidth:1,textColor:s,pressedTint:e.colors["surface-pressed"],...l};case"outline":return{backgroundColor:"transparent",borderColor:r?e.colors.border:t.outline,borderWidth:1,textColor:s,pressedTint:e.colors["surface-pressed"],...l};case"ghost":return{backgroundColor:"transparent",borderColor:"transparent",borderWidth:1,textColor:s,pressedTint:e.colors["surface-pressed"],...l};case"link":return{backgroundColor:"transparent",borderColor:"transparent",borderWidth:0,textColor:r?e.colors["text-disabled"]:e.colors.link,pressedTint:e.colors["surface-pressed"],...l};case"glass":return{backgroundColor:e.colors["glass-fill"],borderColor:e.colors["glass-border"],borderWidth:1,textColor:r?e.colors["text-disabled"]:e.colors["on-glass"],pressedTint:ACCENT_PRESSED_TINT,badgeFill:e.colors["glass-badge"],badgeInk:r?e.colors["text-disabled"]:t.base};default:return{backgroundColor:t.base,borderColor:"transparent",borderWidth:1,textColor:t.on,pressedTint:e.colors["surface-pressed"],...n}}};export function buttonLabelInk(e,o){return variantFor(o,e.variant??"solid",toneFor(o,e.tone??"primary"),e.disabled??!1).textColor}const buildStyles=e=>StyleSheet.create({pressedOverlay:{position:"absolute",top:0,right:0,bottom:0,left:0},base:{alignItems:"center",justifyContent:"center",flexDirection:"row",overflow:"hidden"},contentRow:{flexDirection:"row",alignItems:"center",justifyContent:"center"},label:{textAlign:"center",includeFontPadding:!1,textAlignVertical:"center"},linkUnderline:{height:1.5,marginTop:1},iconLeft:{marginRight:e.space.sm},iconBadge:{alignItems:"center",justifyContent:"center"},iconRight:{marginLeft:e.space.sm},fullWidth:{alignSelf:"stretch"}});export{Button};export default Button;
@@ -1 +1 @@
1
- "use strict";import React,{forwardRef,useMemo}from"react";import{Animated,Image,Pressable,StyleSheet,View}from"react-native";import{useControllableState}from"../../hooks/useControllableState.js";import{usePressAnimation}from"../../hooks/usePressAnimation.js";import{fontFor,Gradient,useTheme}from"../../theme/index.js";import{smoothCorners}from"../../utils/corners.js";import{triggerHaptic}from"../../utils/hapticUtils.js";import{mergeRefs}from"../../utils/mergeRefs.js";import{supportsBoxShadow,toBoxShadow}from"../../utils/shadows.js";import{squircleHostRadius}from"../../utils/squircle.js";import{themeStyles}from"../../utils/themeStyles.js";import{warnInvalidValue}from"../../utils/warnInvalidValue.js";import{AppIcon}from"../AppIcon/AppIcon.js";import{useContextMenu}from"../Menu/useContextMenu.js";import{Skeleton,SkeletonText}from"../Skeleton/index.js";import{SquircleFill,useSquircle}from"../SquircleFill/SquircleFill.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";const BACKGROUND_TOKENS=["bg","bg-subtle","bg-muted","surface","scrim","surface-inverse"];export const DEFAULT_CARD_LABELS=Object.freeze({remove:"Remove",show:"Show",hide:"Hide",loading:"Loading"});const paddingMap={none:"none",sm:"sm",md:"lg",lg:"xl",xl:"2xl"},Card=React.memo(forwardRef((e,t)=>{const{children:i,variant:o,elevation:s="card",radius:r,padding:a,interactive:l=!1,pressAnimation:n="scale",bg:d,header:c,title:u,titleFont:m,lead:h,action:p,headerActions:g,collapsible:b=!1,collapsed:y,defaultCollapsed:x=!1,onCollapsedChange:f,collapsedSummary:S,onRemove:v,separatorHeight:j=StyleSheet.hairlineWidth,footer:C,imageSource:w,imageHeight:_=160,imageAspectRatio:R,imageOverlay:A,loading:F=!1,gradient:T,onPress:k,haptic:I,contextMenu:V,accessibilityLabel:B,accessibilityHint:L,accessibilityRole:P,style:H,containerStyle:z,headerStyle:M,bodyStyle:D,footerStyle:q,borderRadius:E,testID:O,labels:W,onLayout:N,...G}=e;warnInvalidValue("Card","variant",e.variant,["elevated","outline","filled","flat"]),warnInvalidValue("Card","radius",e.radius,["sm","md","lg","xl"]),warnInvalidValue("Card","padding",e.padding,["none","sm","md","lg","xl"]),warnInvalidValue("Card","titleFont",e.titleFont,["sans","serif"]),warnInvalidValue("Card","pressAnimation",e.pressAnimation,["scale","bounce","fade","sink","pulse","dim","false"]);const U=useTheme(),K=U.settings.components.card,$=o??K?.defaultVariant??"elevated",J=r??K?.defaultRadius??"lg",Q=a??K?.defaultPadding??"md",X=m??K?.defaultTitleFont??"sans",Y=useMemo(()=>({...DEFAULT_CARD_LABELS,...W}),[W]),Z=l||"function"==typeof k,ee=useContextMenu(V,{haptic:I||!1,testID:O,accessibilityActions:G.accessibilityActions,onAccessibilityAction:G.onAccessibilityAction}),te=useMemo(()=>mergeRefs(t,ee.hostRef),[t,ee.hostRef]),ie=Z||ee.enabled,{style:oe,pressIn:se,pressOut:re}=usePressAnimation({preset:n||"scale",enabled:ie&&!1!==n}),ae=stylesFor(U),le=Boolean(w),ne=U.space[paddingMap[Q]],de=useMemo(()=>T?"string"==typeof T?U.settings.gradients[T]??null:T:null,[T,U.settings.gradients]),ce="flat"===$,ue=ce?U.radius.none:E??U.radius[J],me=resolveBackground(U,d),[he,pe]=useControllableState({value:y,defaultValue:x,onChange:f}),ge=b&&he,be=hasBuiltInHeaderContent(e),ye=Boolean(c)||be,xe=useSquircle(!le&&!de&&!ce,ue,N),fe=StyleSheet.flatten([H,z])??{},Se=fe.backgroundColor,ve=fe.borderColor,je=Se??me??("filled"===$?U.colors["bg-subtle"]:U.colors.surface),Ce="outline"===$?U.size.border:0,we=ve??U.colors.border,Re="none"===s?void 0:U.shadow[s],Ae="elevated"===$&&supportsBoxShadow()&&Re?toBoxShadow(Re):void 0,Fe=xe.active&&"elevated"===$&&!Ae,Te=xe.active&&!Fe?{backgroundColor:"transparent",borderColor:"transparent"}:null,ke=useMemo(()=>{const e={borderRadius:Fe&&xe.size?squircleHostRadius(xe.size.width,xe.size.height,ue):ue,...smoothCorners,padding:le||xe.active?U.space.none:ne,overflow:xe.active?"visible":"hidden"};switch($){case"flat":return{...e,backgroundColor:me??U.colors.surface,borderBottomWidth:j,borderBottomColor:U.colors.border};case"outline":return{...e,backgroundColor:xe.active?"transparent":me??U.colors.surface,borderWidth:U.size.border,borderColor:xe.active?"transparent":U.colors.border};case"filled":return{...e,backgroundColor:xe.active?"transparent":me??U.colors["bg-subtle"]};default:return{...e,backgroundColor:me??U.colors.surface,...Ae?{boxShadow:Ae}:Re}}},[U,$,Re,ue,le,ne,xe.active,xe.size,Ae,Fe,me,j]),Ie=useMemo(()=>({..."number"==typeof R?{width:"100%",aspectRatio:R}:{width:"100%",height:_},borderTopLeftRadius:ue,borderTopRightRadius:ue,borderBottomLeftRadius:U.radius.none,borderBottomRightRadius:U.radius.none,...smoothCorners}),[U,ue,R,_]),Ve=u??"",Be=_jsxs(_Fragment,{children:[_jsxs(View,{style:ae.titleColumn,children:[u?_jsx(Text,{variant:"title",accessibilityRole:"header",style:titleFaceFor(U,X),children:u}):null,h?_jsx(Text,{variant:"bodySmall",style:ae.lead,children:h}):null,ge&&S?_jsx(Text,{variant:"caption",style:ae.lead,children:S}):null]}),isCardTextAction(p)?_jsx(CardTextActionButton,{action:p,haptic:I}):p?_jsx(View,{style:ae.actionNode,children:p}):null,g,b?_jsx(CardIconAction,{icon:ge?"chevron-down":"chevron-up",label:`${ge?Y.show:Y.hide} ${Ve}`.trim(),expanded:!ge,onPress:()=>pe(!ge),haptic:I}):null,v?_jsx(CardIconAction,{icon:"trash",label:Y.remove,onPress:v,color:U.colors["danger-text"],haptic:I}):null]}),Le=_jsxs(_Fragment,{children:[ye?_jsx(View,{style:[ae.header,!c&&ae.headerRow,ge&&ae.headerFolded,M],children:c??Be}):null,ge?null:_jsx(View,{style:[ye||C?ae.body:null,D],children:i}),C&&!ge?_jsx(View,{style:[ae.footer,q],children:C}):null]}),Pe=le?_jsxs(_Fragment,{children:[_jsxs(View,{style:ae.imageWrapper,children:[_jsx(Image,{source:w,resizeMode:"cover",style:Ie,accessibilityLabel:"",accessible:!1}),A?_jsx(View,{pointerEvents:"box-none",style:ae.imageOverlay,children:A}):null]}),_jsx(View,{style:{padding:ne},children:Le})]}):Le,He=de?_jsxs(_Fragment,{children:[_jsx(Gradient,{gradient:de,style:StyleSheet.absoluteFill}),Pe]}):xe.active&&xe.size?_jsxs(_Fragment,{children:[_jsx(SquircleFill,{width:xe.size.width,height:xe.size.height,radius:ue,fill:je,stroke:Ce?we:void 0,strokeWidth:Ce}),_jsx(View,{style:[ae.squircleClip,{padding:ne,borderRadius:xe.size?squircleHostRadius(xe.size.width,xe.size.height,ue):ue}],children:Pe})]}):Pe;let ze;if(ie){const handlePress=e=>{Z&&(I&&triggerHaptic(I),k?.(e))};ze=_jsx(Animated.View,{style:oe,children:_jsx(Pressable,{ref:te,onPress:handlePress,onPressIn:se,onPressOut:re,accessibilityRole:P??(Z?"button":void 0),accessibilityLabel:B,accessibilityHint:L,testID:O,onLayout:xe.onLayout,style:[ke,H,z,Te],...G,...ee.hostProps,children:He})})}else ze=_jsx(View,{ref:t,accessibilityLabel:B,accessibilityHint:L,accessibilityRole:P,testID:O,onLayout:xe.onLayout,style:[ke,H,z,Te],...G,children:He});return F?_jsx(CardSkeleton,{...e}):ee.enabled?_jsxs(_Fragment,{children:[ze,ee.renderSurface(_jsx(View,{style:[ke,H,z,Te,ae.preview],children:He}))]}):ze}));Card.displayName="Card";const CardSkeleton=({variant:e,elevation:t,radius:i,padding:o,bg:s,header:r,footer:a,imageSource:l,imageHeight:n=160,imageAspectRatio:d,borderRadius:c,containerStyle:u,headerStyle:m,bodyStyle:h,footerStyle:p,style:g,labels:b,...y})=>{const x=useTheme(),f=x.settings.components.card,S=e??f?.defaultVariant??"elevated",v=i??f?.defaultRadius??"lg",j=o??f?.defaultPadding??"md",C={...DEFAULT_CARD_LABELS,...b},w=paddingMap[j],_=x.space[w],R="flat"===S?x.radius.none:c??x.radius[v],A=void 0!==r||hasBuiltInHeaderContent(y),F=resolveBackground(x,s)??x.colors.surface,T="outline"===S?1:0,k="outline"===S?x.colors.border:void 0;return _jsxs(View,{style:[{backgroundColor:F,borderRadius:R,...smoothCorners,borderWidth:T,borderColor:k,overflow:"hidden"},u,g],accessibilityRole:"progressbar",accessibilityLabel:C.loading,accessibilityState:{busy:!0},"aria-busy":!0,children:[void 0!==l?_jsx(Skeleton,{width:"100%",height:d?void 0:n,style:d?{aspectRatio:d,width:"100%"}:void 0}):null,A?_jsx(View,{style:[{padding:_,paddingBottom:x.space.sm},m],children:_jsx(Skeleton,{shape:"text",width:"60%",height:18})}):null,_jsx(View,{style:[{padding:_},h],children:_jsx(SkeletonText,{lines:3,fontSize:x.text.base.size,lastLineWidth:"55%"})}),void 0!==a?_jsx(View,{style:[{padding:_,paddingTop:x.space.sm,flexDirection:"row"},p],children:_jsx(Skeleton,{width:88,height:32,shape:"rounded"})}):null]})};CardSkeleton.displayName="CardSkeleton",Card.Skeleton=CardSkeleton;const hasBuiltInHeaderContent=e=>Boolean(e.title||e.lead||e.action||e.headerActions||e.collapsible||e.onRemove),isCardTextAction=e=>"object"==typeof e&&null!==e&&!React.isValidElement(e)&&"label"in e&&"onPress"in e,HIT_TARGET=44,CardIconAction=({icon:e,label:t,onPress:i,expanded:o,color:s,haptic:r})=>{const a=useTheme();return _jsx(Pressable,{accessibilityRole:"button",accessibilityLabel:t,accessibilityState:void 0===o?void 0:{expanded:o},"aria-expanded":o,onPress:()=>{r&&triggerHaptic(r),i()},style:iconActionStyle,children:_jsx(AppIcon,{name:e,size:20,color:s??a.colors["text-body"]})})},CardTextActionButton=({action:e,haptic:t})=>_jsx(Pressable,{accessibilityRole:"button",accessibilityLabel:e.accessibilityLabel??e.label,onPress:()=>{t&&triggerHaptic(t),e.onPress()},style:textActionStyle,children:_jsx(Text,{variant:"label",weight:"semibold",color:"brand",children:e.label})}),iconActionStyle={width:44,height:44,alignItems:"center",justifyContent:"center"},textActionStyle={minWidth:44,minHeight:44,alignItems:"center",justifyContent:"center"},titleFaceFor=(e,t)=>"serif"===t?fontFor(e,"semibold","display"):{fontFamily:void 0,...fontFor(e,"semibold")},resolveBackground=(e,t)=>{if(null!=t)return BACKGROUND_TOKENS.includes(t)?e.colors[t]:t},buildStyles=e=>StyleSheet.create({header:{marginBottom:e.space.md},headerRow:{flexDirection:"row",alignItems:"center",gap:e.space.sm},headerFolded:{marginBottom:e.space.none},titleColumn:{flex:1},lead:{marginTop:e.space.xs},actionNode:{flexShrink:0},body:{flexShrink:1},footer:{marginTop:e.space.md},imageWrapper:{position:"relative"},imageOverlay:{...StyleSheet.absoluteFill},squircleClip:{flexGrow:1,overflow:"hidden",...smoothCorners},preview:{margin:e.space.none,marginTop:e.space.none,marginBottom:e.space.none,marginLeft:e.space.none,marginRight:e.space.none,marginStart:e.space.none,marginEnd:e.space.none,marginHorizontal:e.space.none,marginVertical:e.space.none,position:"relative",top:0,left:0,width:"100%",height:"100%"}}),stylesFor=themeStyles(buildStyles);export{Card};export default Card;
1
+ "use strict";import React,{forwardRef,useMemo}from"react";import{Animated,Image,Pressable,StyleSheet,View}from"react-native";import{useControllableState}from"../../hooks/useControllableState.js";import{usePressAnimation}from"../../hooks/usePressAnimation.js";import{fontFor,Gradient,useTheme}from"../../theme/index.js";import{smoothCorners}from"../../utils/corners.js";import{triggerHaptic}from"../../utils/hapticUtils.js";import{mergeRefs}from"../../utils/mergeRefs.js";import{supportsBoxShadow,toBoxShadow}from"../../utils/shadows.js";import{squircleHostRadius}from"../../utils/squircle.js";import{themeStyles}from"../../utils/themeStyles.js";import{warnInvalidValue}from"../../utils/warnInvalidValue.js";import{AppIcon}from"../AppIcon/AppIcon.js";import{useContextMenu}from"../Menu/useContextMenu.js";import{Skeleton,SkeletonText}from"../Skeleton/index.js";import{SquircleFill,useSquircle}from"../SquircleFill/SquircleFill.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";const BACKGROUND_TOKENS=["bg","bg-subtle","bg-muted","surface","scrim","surface-inverse","primary-wash"];export const DEFAULT_CARD_LABELS=Object.freeze({remove:"Remove",show:"Show",hide:"Hide",loading:"Loading"});const paddingMap={none:"none",sm:"sm",md:"lg",lg:"xl",xl:"2xl"},Card=React.memo(forwardRef((e,t)=>{const{children:i,variant:o,elevation:s="card",radius:a,padding:r,interactive:l=!1,pressAnimation:n="scale",bg:d,header:c,title:u,titleFont:m,lead:h,action:p,headerActions:g,collapsible:b=!1,collapsed:y,defaultCollapsed:x=!1,onCollapsedChange:f,collapsedSummary:S,onRemove:v,separatorHeight:j=StyleSheet.hairlineWidth,footer:C,imageSource:w,imageHeight:_=160,imageAspectRatio:R,imageOverlay:A,loading:F=!1,gradient:T,onPress:k,haptic:I,contextMenu:V,accessibilityLabel:B,accessibilityHint:L,accessibilityRole:P,style:H,containerStyle:z,headerStyle:M,bodyStyle:D,footerStyle:q,testID:E,labels:O,onLayout:W,...N}=e;warnInvalidValue("Card","variant",e.variant,["elevated","outline","filled","flat"]),warnInvalidValue("Card","radius",e.radius,["sm","md","lg","xl","pill"]),warnInvalidValue("Card","padding",e.padding,["none","sm","md","lg","xl"]),warnInvalidValue("Card","titleFont",e.titleFont,["sans","serif"]),warnInvalidValue("Card","pressAnimation",e.pressAnimation,["scale","bounce","fade","sink","pulse","dim","false"]);const G=useTheme(),U=G.settings.components.card,K=o??U?.defaultVariant??"elevated",$=a??U?.defaultRadius??"lg",J=r??U?.defaultPadding??"md",Q=m??U?.defaultTitleFont??"sans",X=useMemo(()=>({...DEFAULT_CARD_LABELS,...O}),[O]),Y=l||"function"==typeof k,Z=useContextMenu(V,{haptic:I||!1,testID:E,accessibilityActions:N.accessibilityActions,onAccessibilityAction:N.onAccessibilityAction}),ee=useMemo(()=>mergeRefs(t,Z.hostRef),[t,Z.hostRef]),te=Y||Z.enabled,{style:ie,pressIn:oe,pressOut:se}=usePressAnimation({preset:n||"scale",enabled:te&&!1!==n}),ae=stylesFor(G),re=Boolean(w),le=G.space[paddingMap[J]],ne=useMemo(()=>T?"string"==typeof T?G.settings.gradients[T]??null:T:null,[T,G.settings.gradients]),de="flat"===K,ce=de?G.radius.none:G.radius[$],ue=resolveBackground(G,d),[me,he]=useControllableState({value:y,defaultValue:x,onChange:f}),pe=b&&me,ge=hasBuiltInHeaderContent(e),be=Boolean(c)||ge,ye=useSquircle(!re&&!ne&&!de,ce,W),xe=StyleSheet.flatten([z,H])??{},fe=xe.backgroundColor,Se=xe.borderColor,ve=fe??ue??("filled"===K?G.colors["bg-subtle"]:G.colors.surface),je="outline"===K?G.size.border:0,Ce=Se??G.colors.border,we="none"===s?void 0:G.shadow[s],Re="elevated"===K&&supportsBoxShadow()&&we?toBoxShadow(we):void 0,Ae=ye.active&&"elevated"===K&&!Re,Fe=ye.active&&!Ae?{backgroundColor:"transparent",borderColor:"transparent"}:null,Te=useMemo(()=>{const e={borderRadius:Ae&&ye.size?squircleHostRadius(ye.size.width,ye.size.height,ce):ce,...smoothCorners,padding:re||ye.active?G.space.none:le,overflow:ye.active?"visible":"hidden"};switch(K){case"flat":return{...e,backgroundColor:ue??G.colors.surface,borderBottomWidth:j,borderBottomColor:G.colors.border};case"outline":return{...e,backgroundColor:ye.active?"transparent":ue??G.colors.surface,borderWidth:G.size.border,borderColor:ye.active?"transparent":G.colors.border};case"filled":return{...e,backgroundColor:ye.active?"transparent":ue??G.colors["bg-subtle"]};default:return{...e,backgroundColor:ue??G.colors.surface,...Re?{boxShadow:Re}:we}}},[G,K,we,ce,re,le,ye.active,ye.size,Re,Ae,ue,j]),ke=useMemo(()=>({..."number"==typeof R?{width:"100%",aspectRatio:R}:{width:"100%",height:_},borderTopLeftRadius:ce,borderTopRightRadius:ce,borderBottomLeftRadius:G.radius.none,borderBottomRightRadius:G.radius.none,...smoothCorners}),[G,ce,R,_]),Ie=u??"",Ve=_jsxs(_Fragment,{children:[_jsxs(View,{style:ae.titleColumn,children:[u?_jsx(Text,{variant:"title",accessibilityRole:"header",style:titleFaceFor(G,Q),children:u}):null,h?_jsx(Text,{variant:"bodySmall",style:ae.lead,children:h}):null,pe&&S?_jsx(Text,{variant:"caption",style:ae.lead,children:S}):null]}),isCardTextAction(p)?_jsx(CardTextActionButton,{action:p,haptic:I}):p?_jsx(View,{style:ae.actionNode,children:p}):null,g,b?_jsx(CardIconAction,{icon:pe?"chevron-down":"chevron-up",label:`${pe?X.show:X.hide} ${Ie}`.trim(),expanded:!pe,onPress:()=>he(!pe),haptic:I}):null,v?_jsx(CardIconAction,{icon:"trash",label:X.remove,onPress:v,color:G.colors["danger-text"],haptic:I}):null]}),Be=_jsxs(_Fragment,{children:[be?_jsx(View,{style:[ae.header,!c&&ae.headerRow,pe&&ae.headerFolded,M],children:c??Ve}):null,pe?null:_jsx(View,{style:[be||C?ae.body:null,D],children:i}),C&&!pe?_jsx(View,{style:[ae.footer,q],children:C}):null]}),Le=re?_jsxs(_Fragment,{children:[_jsxs(View,{style:ae.imageWrapper,children:[_jsx(Image,{source:w,resizeMode:"cover",style:ke,accessibilityLabel:"",accessible:!1}),A?_jsx(View,{pointerEvents:"box-none",style:ae.imageOverlay,children:A}):null]}),_jsx(View,{style:{padding:le},children:Be})]}):Be,Pe=ne?_jsxs(_Fragment,{children:[_jsx(Gradient,{gradient:ne,style:StyleSheet.absoluteFill}),Le]}):ye.active&&ye.size?_jsxs(_Fragment,{children:[_jsx(SquircleFill,{width:ye.size.width,height:ye.size.height,radius:ce,fill:ve,stroke:je?Ce:void 0,strokeWidth:je}),_jsx(View,{style:[ae.squircleClip,{padding:le,borderRadius:ye.size?squircleHostRadius(ye.size.width,ye.size.height,ce):ce}],children:Le})]}):Le;let He;if(te){const handlePress=e=>{Y&&(I&&triggerHaptic(I),k?.(e))};He=_jsx(Animated.View,{style:ie,children:_jsx(Pressable,{ref:ee,onPress:handlePress,onPressIn:oe,onPressOut:se,accessibilityRole:P??(Y?"button":void 0),accessibilityLabel:B,accessibilityHint:L,testID:E,onLayout:ye.onLayout,style:[Te,z,H,Fe],...N,...Z.hostProps,children:Pe})})}else He=_jsx(View,{ref:t,accessibilityLabel:B,accessibilityHint:L,accessibilityRole:P,testID:E,onLayout:ye.onLayout,style:[Te,z,H,Fe],...N,children:Pe});return F?_jsx(CardSkeleton,{...e}):Z.enabled?_jsxs(_Fragment,{children:[He,Z.renderSurface(_jsx(View,{style:[Te,z,H,Fe,ae.preview],children:Pe}))]}):He}));Card.displayName="Card";const CardSkeleton=({variant:e,elevation:t,radius:i,padding:o,bg:s,header:a,footer:r,imageSource:l,imageHeight:n=160,imageAspectRatio:d,containerStyle:c,headerStyle:u,bodyStyle:m,footerStyle:h,style:p,labels:g,...b})=>{const y=useTheme(),x=y.settings.components.card,f=e??x?.defaultVariant??"elevated",S=i??x?.defaultRadius??"lg",v=o??x?.defaultPadding??"md",j={...DEFAULT_CARD_LABELS,...g},C=paddingMap[v],w=y.space[C],_="flat"===f?y.radius.none:y.radius[S],R=void 0!==a||hasBuiltInHeaderContent(b),A=resolveBackground(y,s)??y.colors.surface,F="outline"===f?1:0,T="outline"===f?y.colors.border:void 0;return _jsxs(View,{style:[{backgroundColor:A,borderRadius:_,...smoothCorners,borderWidth:F,borderColor:T,overflow:"hidden"},c,p],accessibilityRole:"progressbar",accessibilityLabel:j.loading,accessibilityState:{busy:!0},"aria-busy":!0,children:[void 0!==l?_jsx(Skeleton,{width:"100%",height:d?void 0:n,style:d?{aspectRatio:d,width:"100%"}:void 0}):null,R?_jsx(View,{style:[{padding:w,paddingBottom:y.space.sm},u],children:_jsx(Skeleton,{shape:"text",width:"60%",height:18})}):null,_jsx(View,{style:[{padding:w},m],children:_jsx(SkeletonText,{lines:3,fontSize:y.text.base.size,lastLineWidth:"55%"})}),void 0!==r?_jsx(View,{style:[{padding:w,paddingTop:y.space.sm,flexDirection:"row"},h],children:_jsx(Skeleton,{width:88,height:32,shape:"rounded"})}):null]})};CardSkeleton.displayName="CardSkeleton",Card.Skeleton=CardSkeleton;const hasBuiltInHeaderContent=e=>Boolean(e.title||e.lead||e.action||e.headerActions||e.collapsible||e.onRemove),isCardTextAction=e=>"object"==typeof e&&null!==e&&!React.isValidElement(e)&&"label"in e&&"onPress"in e,HIT_TARGET=44,CardIconAction=({icon:e,label:t,onPress:i,expanded:o,color:s,haptic:a})=>{const r=useTheme();return _jsx(Pressable,{accessibilityRole:"button",accessibilityLabel:t,accessibilityState:void 0===o?void 0:{expanded:o},"aria-expanded":o,onPress:()=>{a&&triggerHaptic(a),i()},style:iconActionStyle,children:_jsx(AppIcon,{name:e,size:20,color:s??r.colors["text-body"]})})},CardTextActionButton=({action:e,haptic:t})=>_jsx(Pressable,{accessibilityRole:"button",accessibilityLabel:e.accessibilityLabel??e.label,onPress:()=>{t&&triggerHaptic(t),e.onPress()},style:textActionStyle,children:_jsx(Text,{variant:"label",weight:"semibold",color:"brand",children:e.label})}),iconActionStyle={width:44,height:44,alignItems:"center",justifyContent:"center"},textActionStyle={minWidth:44,minHeight:44,alignItems:"center",justifyContent:"center"},titleFaceFor=(e,t)=>"serif"===t?fontFor(e,"semibold","display"):{fontFamily:void 0,...fontFor(e,"semibold")},resolveBackground=(e,t)=>{if(null!=t)return BACKGROUND_TOKENS.includes(t)?e.colors[t]:t},buildStyles=e=>StyleSheet.create({header:{marginBottom:e.space.md},headerRow:{flexDirection:"row",alignItems:"center",gap:e.space.sm},headerFolded:{marginBottom:e.space.none},titleColumn:{flex:1},lead:{marginTop:e.space.xs},actionNode:{flexShrink:0},body:{flexShrink:1},footer:{marginTop:e.space.md},imageWrapper:{position:"relative"},imageOverlay:{...StyleSheet.absoluteFill},squircleClip:{flexGrow:1,overflow:"hidden",...smoothCorners},preview:{margin:e.space.none,marginTop:e.space.none,marginBottom:e.space.none,marginLeft:e.space.none,marginRight:e.space.none,marginStart:e.space.none,marginEnd:e.space.none,marginHorizontal:e.space.none,marginVertical:e.space.none,position:"relative",top:0,left:0,width:"100%",height:"100%"}}),stylesFor=themeStyles(buildStyles);export{Card};export default Card;
@@ -1 +1 @@
1
- "use strict";import{forwardRef,useEffect,useMemo,useRef}from"react";import{Animated,Pressable,StyleSheet,View}from"react-native";import Svg,{Path}from"react-native-svg";import{useControllableState}from"../../hooks/index.js";import{createAnimatedValue,resolveCheckboxSize,spaceOf,useTheme}from"../../theme/index.js";import{smoothCorners}from"../../utils/corners.js";import{resolveHaptic,triggerHaptic}from"../../utils/hapticUtils.js";import{hitSlopMarker}from"../../utils/hitSlop.js";import{warnInvalidValue}from"../../utils/warnInvalidValue.js";import{ChoiceText,hasChoiceDetail}from"../FieldBase/ChoiceText.js";import{fieldTextAsString,hasFieldText}from"../FieldBase/FieldBase.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const CHECKBOX_SHAPES=["circle"],toneColor=(e,r)=>{switch(r){case"success":return e.colors.success;case"warning":return e.colors.warning;case"danger":return e.colors.danger;case"info":return e.colors.info;case"neutral":return e.colors["text-muted"];default:return e.colors.primary}},toneOnColor=(e,r)=>{switch(r){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"];default:return e.colors["on-primary"]}},Checkbox=forwardRef((e,r)=>{const{checked:t,defaultChecked:s,onChange:o,indeterminate:i=!1,disabled:a=!1,label:n,helperText:l,description:c,error:d,help:h,size:u="md",tone:p="primary",shape:m,accessibilityLabel:x,haptic:f,style:b,boxStyle:g,indeterminateBarStyle:y,containerStyle:C,labelStyle:w,testID:S,hitSlop:k,...j}=e,[v,T]=useControllableState({value:t,defaultValue:s??!1,onChange:o}),V=useTheme(),_=useMemo(()=>buildStyles(V),[V]),{"box-size":I}=useMemo(()=>resolveCheckboxSize(V,u),[V,u]),R=V.size.border,A=spaceOf(V,V.components.checkbox["label-gap"]),H=toneColor(V,p),M=k??6;warnInvalidValue("Checkbox","shape",m,CHECKBOX_SHAPES),warnInvalidValue("Checkbox","size",e.size,["sm","md","lg"]),warnInvalidValue("Checkbox","tone",e.tone,["primary","success","warning","danger","info","neutral"]);const D="circle"===m,P="string"==typeof d?d:void 0,z={description:c,helperText:l,error:P},B=v||i,F=useRef(createAnimatedValue(B?1:0)).current;useEffect(()=>{const e=Animated.spring(F,{toValue:B?1:0,damping:V.motion.spring.snappy.damping,stiffness:V.motion.spring.snappy.stiffness,mass:V.motion.spring.snappy.mass,useNativeDriver:!0});return e.start(),()=>e.stop()},[B,F,V.motion.spring.snappy]);const L=F.interpolate({inputRange:[0,1],outputRange:[0,1]}),O=x??fieldTextAsString(n),E=!0===d||hasFieldText(d),W=B?H:a?V.colors.border:E?V.colors["field-border-error"]:V.colors.border,K=B?H:a?V.colors["surface-disabled"]:"transparent",N=a&&!B?V.colors["text-disabled"]:toneOnColor(V,p),X=Math.round(.72*I),U=Math.round(.55*I),q=Math.max(2,Math.round(.12*I)),G=_jsxs(Pressable,{ref:r,onPress:e=>{if(a)return;const r=resolveHaptic(f,"selection");r&&triggerHaptic(r),T(!v),j.onPressOut?.(e)},disabled:a,accessibilityRole:"checkbox",accessibilityLabel:O,accessibilityHint:j.accessibilityHint??fieldTextAsString(l??c),accessibilityState:{checked:i?"mixed":v,disabled:a},"aria-checked":i?"mixed":v,"aria-disabled":a,testID:S,hitSlop:M,...hitSlopMarker(M),...j,style:({pressed:e})=>[_.row,hasChoiceDetail(z)?_.rowTop:null,hasFieldText(h)?_.rowShrink:null,{opacity:a?.55:e?.85:1},C,b],children:[_jsx(View,{style:[_.box,{width:I,height:I,borderWidth:R,borderRadius:D?I/2:V.radius.sm,...D?{}:smoothCorners,borderColor:W,backgroundColor:K},g],children:_jsx(Animated.View,{style:[_.glyphWrap,{opacity:F,transform:[{scale:L}]}],children:i?_jsx(View,{style:[{width:U,height:q,borderRadius:V.radius.pill,...smoothCorners,backgroundColor:N},y]}):_jsx(Svg,{width:X,height:X,viewBox:"0 0 24 24",children:_jsx(Path,{d:"M5 12.5l4.5 4.5L19 7.5",stroke:N,strokeWidth:3,strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})})})}),_jsx(ChoiceText,{label:n,helperText:l,description:c,error:P,disabled:a,style:{marginLeft:A},labelStyle:w})]});return hasFieldText(h)?_jsxs(View,{style:[_.helpRow,hasChoiceDetail(z)?_.rowTop:null],children:[G,_jsx(View,{style:[_.help,{marginLeft:V.space.xs}],children:h})]}):G});Checkbox.displayName="Checkbox";const buildStyles=e=>StyleSheet.create({row:{flexDirection:"row",alignItems:"center"},rowTop:{alignItems:"flex-start"},rowShrink:{flexShrink:1},helpRow:{flexDirection:"row",alignItems:"center"},help:{flexShrink:0},box:{alignItems:"center",justifyContent:"center"},glyphWrap:{alignItems:"center",justifyContent:"center"}});export{Checkbox};export default Checkbox;
1
+ "use strict";import{forwardRef,useEffect,useMemo,useRef}from"react";import{Animated,Pressable,StyleSheet,View}from"react-native";import Svg,{Path}from"react-native-svg";import{useControllableState}from"../../hooks/index.js";import{createAnimatedValue,resolveCheckboxSize,spaceOf,useTheme}from"../../theme/index.js";import{smoothCorners}from"../../utils/corners.js";import{resolveHaptic,triggerHaptic}from"../../utils/hapticUtils.js";import{hitSlopMarker}from"../../utils/hitSlop.js";import{warnInvalidValue}from"../../utils/warnInvalidValue.js";import{ChoiceText,hasChoiceDetail}from"../FieldBase/ChoiceText.js";import{fieldTextAsString,hasFieldText}from"../FieldBase/FieldBase.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const CHECKBOX_SHAPES=["circle"],toneColor=(e,r)=>{switch(r){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}},toneOnColor=(e,r)=>{switch(r){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"];default:return e.colors["on-primary"]}},Checkbox=forwardRef((e,r)=>{const{checked:t,defaultChecked:s,onChange:o,indeterminate:i=!1,disabled:a=!1,label:n,helperText:l,description:c,error:d,help:h,size:u="md",tone:p="primary",shape:m,accessibilityLabel:x,haptic:f,style:b,boxStyle:g,indeterminateBarStyle:y,containerStyle:C,labelStyle:w,testID:S,hitSlop:k,...j}=e,[v,T]=useControllableState({value:t,defaultValue:s??!1,onChange:o}),V=useTheme(),_=useMemo(()=>buildStyles(V),[V]),{"box-size":I}=useMemo(()=>resolveCheckboxSize(V,u),[V,u]),R=V.size.border,A=spaceOf(V,V.components.checkbox["label-gap"]),H=toneColor(V,p),M=k??6;warnInvalidValue("Checkbox","shape",m,CHECKBOX_SHAPES),warnInvalidValue("Checkbox","size",e.size,["sm","md","lg"]),warnInvalidValue("Checkbox","tone",e.tone,["primary","success","warning","danger","info","neutral"]);const D="circle"===m,P="string"==typeof d?d:void 0,z={description:c,helperText:l,error:P},B=v||i,F=useRef(createAnimatedValue(B?1:0)).current;useEffect(()=>{const e=Animated.spring(F,{toValue:B?1:0,damping:V.motion.spring.snappy.damping,stiffness:V.motion.spring.snappy.stiffness,mass:V.motion.spring.snappy.mass,useNativeDriver:!0});return e.start(),()=>e.stop()},[B,F,V.motion.spring.snappy]);const L=F.interpolate({inputRange:[0,1],outputRange:[0,1]}),O=x??fieldTextAsString(n),E=!0===d||hasFieldText(d),W=B?H:a?V.colors.border:E?V.colors["field-border-error"]:V.colors.border,K=B?H:a?V.colors["surface-disabled"]:"transparent",N=a&&!B?V.colors["text-disabled"]:toneOnColor(V,p),X=Math.round(.72*I),U=Math.round(.55*I),q=Math.max(2,Math.round(.12*I)),G=_jsxs(Pressable,{ref:r,onPress:e=>{if(a)return;const r=resolveHaptic(f,"selection");r&&triggerHaptic(r),T(!v),j.onPressOut?.(e)},disabled:a,accessibilityRole:"checkbox",accessibilityLabel:O,accessibilityHint:j.accessibilityHint??fieldTextAsString(l??c),accessibilityState:{checked:i?"mixed":v,disabled:a},"aria-checked":i?"mixed":v,"aria-disabled":a,testID:S,hitSlop:M,...hitSlopMarker(M),...j,style:({pressed:e})=>[_.row,hasChoiceDetail(z)?_.rowTop:null,hasFieldText(h)?_.rowShrink:null,{opacity:a?.55:e?.85:1},C,b],children:[_jsx(View,{style:[_.box,{width:I,height:I,borderWidth:R,borderRadius:D?I/2:V.radius.sm,...D?{}:smoothCorners,borderColor:W,backgroundColor:K},g],children:_jsx(Animated.View,{style:[_.glyphWrap,{opacity:F,transform:[{scale:L}]}],children:i?_jsx(View,{style:[{width:U,height:q,borderRadius:V.radius.pill,...smoothCorners,backgroundColor:N},y]}):_jsx(Svg,{width:X,height:X,viewBox:"0 0 24 24",children:_jsx(Path,{d:"M5 12.5l4.5 4.5L19 7.5",stroke:N,strokeWidth:3,strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})})})}),_jsx(ChoiceText,{label:n,helperText:l,description:c,error:P,disabled:a,style:{marginLeft:A},labelStyle:w})]});return hasFieldText(h)?_jsxs(View,{style:[_.helpRow,hasChoiceDetail(z)?_.rowTop:null],children:[G,_jsx(View,{style:[_.help,{marginLeft:V.space.xs}],children:h})]}):G});Checkbox.displayName="Checkbox";const buildStyles=e=>StyleSheet.create({row:{flexDirection:"row",alignItems:"center"},rowTop:{alignItems:"flex-start"},rowShrink:{flexShrink:1},helpRow:{flexDirection:"row",alignItems:"center"},help:{flexShrink:0},box:{alignItems:"center",justifyContent:"center"},glyphWrap:{alignItems:"center",justifyContent:"center"}});export{Checkbox};export default Checkbox;
@@ -1 +1 @@
1
- "use strict";import{forwardRef,useCallback,useMemo,useState}from"react";import{Platform,StyleSheet,TextInput,View}from"react-native";import{KeyboardStickyView}from"react-native-keyboard-controller";import{useSafeAreaInsets}from"react-native-safe-area-context";import{useControllableState}from"../../hooks/useControllableState.js";import{useTheme}from"../../theme/index.js";import{smoothCorners}from"../../utils/corners.js";import{resolveFieldTextStyle}from"../FieldBase/FieldBase.js";import{IconButton}from"../IconButton/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_COMPOSER_LABELS=Object.freeze({send:"Send",message:"Message"});const MIN_BOX=44;export const Composer=forwardRef(({onSend:e,value:o,onChangeText:t,placeholder:a,accessibilityLabel:s,labels:i,loading:l=!1,onStop:r,stopLabel:n="Stop",disabled:d=!1,canSend:c,maxLength:m,maxLines:b=5,leading:p,trailing:u,above:g,below:h,keyboardAware:x=!0,keyboardOffset:f,safeArea:S=!0,autoFocus:y,haptic:C,style:j,testID:v},w)=>{const L=useTheme(),T=useSafeAreaInsets(),_=useMemo(()=>buildStyles(L),[L]),I=i?{...DEFAULT_COMPOSER_LABELS,...i}:DEFAULT_COMPOSER_LABELS,[k,A]=useControllableState({value:o,defaultValue:"",onChange:t}),O=k.trim(),B=l&&void 0!==r,D=l||d||!(c??""!==O),E=S?T.bottom:0,F=f??E,M=resolveFieldTextStyle(L,{disabled:d}),V=L.text.base.size,z=Math.round(V*L.leading.body),P=(44-z)/2,H=z*b+2*P,[R,U]=useState(void 0),K=useCallback(e=>{const o=e.nativeEvent.contentSize.height+2*P;U(Math.min(Math.max(o,44),H))},[P,H]),N=useCallback(()=>{B?r?.():D||(A(""),e(O))},[B,r,D,A,e,O]),W=_jsxs(View,{style:[_.bar,{paddingBottom:L.space.sm+E},j],testID:v,children:[g,_jsxs(View,{style:_.row,children:[p,_jsx(View,{style:[_.box,d?_.boxDisabled:null],children:_jsx(TextInput,{ref:w,value:k,onChangeText:A,multiline:!0,maxLength:m,editable:!d,autoFocus:y,placeholder:a??I.message,placeholderTextColor:M.placeholderColor,selectionColor:L.colors["field-caret"],accessibilityLabel:s??a??I.message,accessibilityState:{disabled:d},"aria-disabled":d,onContentSizeChange:"web"===Platform.OS?K:void 0,style:[_.input,{color:M.color,...M.weightStyle,fontSize:V,lineHeight:z,paddingVertical:P,maxHeight:H,height:"web"===Platform.OS?R:void 0}],testID:v?`${v}-input`:void 0})}),u,_jsx(IconButton,{icon:B?"stop":"send",accessibilityLabel:B?n:I.send,variant:"solid",tone:"primary",disabled:B?d:D,loading:l&&!B,haptic:C,onPress:N,testID:v?`${v}-send`:void 0})]}),h]});return x?_jsx(KeyboardStickyView,{offset:{closed:0,opened:F},children:W}):W});Composer.displayName="Composer";const buildStyles=e=>StyleSheet.create({bar:{gap:e.space.xs,paddingHorizontal:e.space.md,paddingTop:e.space.sm,backgroundColor:e.colors.bg,borderTopWidth:StyleSheet.hairlineWidth,borderTopColor:e.colors["border-subtle"]},row:{flexDirection:"row",alignItems:"flex-end",gap:e.space.sm},box:{flex:1,minHeight:44,justifyContent:"center",backgroundColor:e.colors["field-bg"],borderRadius:e.radius.pill,...smoothCorners,paddingHorizontal:e.space.md},boxDisabled:{backgroundColor:e.colors["field-bg-disabled"]},input:{margin:e.space.none,paddingHorizontal:e.space.none,includeFontPadding:!1,textAlignVertical:"top"}});export default Composer;
1
+ "use strict";import{forwardRef,useCallback,useEffect,useMemo,useRef,useState}from"react";import{Animated,Easing,Platform,StyleSheet,TextInput,View}from"react-native";import{KeyboardStickyView}from"react-native-keyboard-controller";import{useSafeAreaInsets}from"react-native-safe-area-context";import{useControllableState}from"../../hooks/useControllableState.js";import{useReducedMotion}from"../../hooks/useReducedMotion.js";import{useTheme}from"../../theme/index.js";import{smoothCorners}from"../../utils/corners.js";import{resolveFieldTextStyle}from"../FieldBase/FieldBase.js";import{IconButton}from"../IconButton/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_COMPOSER_LABELS=Object.freeze({send:"Send",message:"Message"});const MIN_BOX=44,RING_MS=900,RING_WIDTH=1.5;export const Composer=forwardRef(({onSend:e,value:t,onChangeText:o,placeholder:a,accessibilityLabel:s,labels:i,loading:r=!1,onStop:n,stopLabel:l="Stop",disabled:d=!1,canSend:c,ring:u=!1,sendReveal:m="always",maxLength:p,maxLines:b=5,leading:g,trailing:f,above:h,below:x,keyboardAware:S=!0,keyboardOffset:y,safeArea:C=!0,autoFocus:v,haptic:j,style:w,testID:A},E)=>{const I=useTheme(),_=useSafeAreaInsets(),L=useMemo(()=>buildStyles(I),[I]),R=i?{...DEFAULT_COMPOSER_LABELS,...i}:DEFAULT_COMPOSER_LABELS,[T,D]=useControllableState({value:t,defaultValue:"",onChange:o}),M=T.trim(),k=r&&void 0!==n,O=r||d||!(c??""!==M),V=C?_.bottom:0,B=y??V,F=resolveFieldTextStyle(I,{disabled:d}),z=I.text.base.size,P=Math.round(z*I.leading.body),H=(44-P)/2,N=P*b+2*H,[W,U]=useState(void 0),$=useCallback(e=>{const t=e.nativeEvent.contentSize.height+2*H;U(Math.min(Math.max(t,44),N))},[H,N]),G=useReducedMotion(),K=useRef(new Animated.Value(0)).current;useEffect(()=>{if(!u||G)return void K.setValue(u?1:0);const e=Animated.loop(Animated.sequence([Animated.timing(K,{toValue:1,duration:900,easing:Easing.inOut(Easing.ease),useNativeDriver:!1}),Animated.timing(K,{toValue:0,duration:900,easing:Easing.inOut(Easing.ease),useNativeDriver:!1})]));return e.start(),()=>e.stop()},[u,G,K]);const q=u?{borderWidth:1.5,borderColor:K.interpolate({inputRange:[0,1],outputRange:[I.colors["border-subtle"],I.colors.primary]})}:null,X="always"===m||r||""!==T||!0===c,J=useCallback(()=>{k?n?.():O||(D(""),e(M))},[k,n,O,D,e,M]),Q=_jsxs(View,{style:[L.bar,{paddingBottom:I.space.sm+V},w],testID:A,children:[h,_jsxs(View,{style:L.row,children:[g,_jsx(Animated.View,{style:[L.box,d?L.boxDisabled:null,q],testID:A?`${A}-box`:void 0,children:_jsx(TextInput,{ref:E,value:T,onChangeText:D,multiline:!0,maxLength:p,editable:!d,autoFocus:v,placeholder:a??R.message,placeholderTextColor:F.placeholderColor,selectionColor:I.colors["field-caret"],accessibilityLabel:s??a??R.message,accessibilityState:{disabled:d},"aria-disabled":d,onContentSizeChange:"web"===Platform.OS?$:void 0,style:[L.input,{color:F.color,...F.weightStyle,fontSize:z,lineHeight:P,paddingVertical:H,maxHeight:N,height:"web"===Platform.OS?W:void 0}],testID:A?`${A}-input`:void 0})}),f,X?_jsx(IconButton,{icon:k?"stop":"send",accessibilityLabel:k?l:R.send,variant:"solid",tone:"primary",disabled:k?d:O,loading:r&&!k,haptic:j,onPress:J,testID:A?`${A}-send`:void 0}):null]}),x]});return S?_jsx(KeyboardStickyView,{offset:{closed:0,opened:B},children:Q}):Q});Composer.displayName="Composer";const buildStyles=e=>StyleSheet.create({bar:{gap:e.space.xs,paddingHorizontal:e.space.md,paddingTop:e.space.sm,backgroundColor:e.colors.bg,borderTopWidth:StyleSheet.hairlineWidth,borderTopColor:e.colors["border-subtle"]},row:{flexDirection:"row",alignItems:"flex-end",gap:e.space.sm},box:{flex:1,minHeight:44,justifyContent:"center",backgroundColor:e.colors["field-bg"],borderRadius:e.radius.pill,...smoothCorners,paddingHorizontal:e.space.md},boxDisabled:{backgroundColor:e.colors["field-bg-disabled"]},input:{margin:e.space.none,paddingHorizontal:e.space.none,includeFontPadding:!1,textAlignVertical:"top"}});export default Composer;
@@ -1 +1 @@
1
- "use strict";import{Logger}from"@webority/mobile-core";import{useEffect,useMemo,useRef,useSyncExternalStore}from"react";import{Dialog}from"../Dialog/index.js";import{jsx as _jsx}from"react/jsx-runtime";const DEFAULT_CONFIRM_HOST_LABELS={cancel:"Cancel"};let queue=[],hostCount=0,nextId=0;const listeners=new Set,emit=()=>{for(const e of listeners)e()},subscribe=e=>(listeners.add(e),()=>{listeners.delete(e)}),getQueue=()=>queue,settle=(e,t)=>{const o=queue.find(t=>t.id===e);o&&(queue=queue.filter(t=>t.id!==e),emit(),o.resolve(t))};export function confirm(e){if(0===hostCount)throw new Error("[@webority/mobile-ui] confirm: mount <ConfirmHost /> once at the app root before calling confirm.");return new Promise(t=>{nextId+=1,queue=[...queue,{id:nextId,options:e,resolve:t}],emit()})}export function ConfirmHost({labels:e,testID:t}){const o=useMemo(()=>({...DEFAULT_CONFIRM_HOST_LABELS,...e}),[e]),s=useSyncExternalStore(subscribe,getQueue)[0],n=useRef(void 0);s&&(n.current=s),useEffect(()=>(hostCount+=1,hostCount>1&&Logger.warn("[@webority/mobile-ui] ConfirmHost: mounted more than once; mount one at the app root."),()=>{if(hostCount-=1,0===hostCount){const e=queue;queue=[],emit();for(const t of e)t.resolve(!1)}}),[]);const r=s??n.current;return r?_jsx(Dialog,{visible:void 0!==s,onClose:()=>settle(r.id,!1),title:r.options.title,message:r.options.message,dismissOnAction:!1,actions:[{label:o.cancel,tone:"neutral",onPress:()=>settle(r.id,!1)},{label:r.options.confirmLabel,tone:r.options.tone??"primary",onPress:()=>settle(r.id,!0)}],testID:t}):null}
1
+ "use strict";import{Logger}from"@webority/mobile-core";import{useEffect,useMemo,useRef,useSyncExternalStore}from"react";import{Dialog}from"../Dialog/index.js";import{jsx as _jsx}from"react/jsx-runtime";const DEFAULT_CONFIRM_HOST_LABELS={cancel:"Cancel"};let queue=[],hostCount=0,nextId=0;const listeners=new Set,emit=()=>{for(const e of listeners)e()},subscribe=e=>(listeners.add(e),()=>{listeners.delete(e)}),getQueue=()=>queue,settle=(e,t)=>{const o=queue.find(t=>t.id===e);o&&(queue=queue.filter(t=>t.id!==e),emit(),o.resolve(t))};export function confirm(e){if(0===hostCount)throw new Error("[@webority/mobile-ui] confirm: mount <ConfirmHost /> once at the app root before calling confirm.");return new Promise(t=>{nextId+=1,queue=[...queue,{id:nextId,options:e,resolve:t}],emit()})}export function ConfirmHost({labels:e,testID:t}){const o=useMemo(()=>({...DEFAULT_CONFIRM_HOST_LABELS,...e}),[e]),n=useSyncExternalStore(subscribe,getQueue)[0],s=useRef(void 0);n&&(s.current=n),useEffect(()=>(hostCount+=1,hostCount>1&&Logger.warn("[@webority/mobile-ui] ConfirmHost: mounted more than once; mount one at the app root."),()=>{if(hostCount-=1,0===hostCount){const e=queue;queue=[],emit();for(const t of e)t.resolve(!1)}}),[]);const r=n??s.current;return r?_jsx(Dialog,{open:void 0!==n,onClose:()=>settle(r.id,!1),title:r.options.title,message:r.options.message,dismissOnAction:!1,actions:[{label:o.cancel,tone:"neutral",onPress:()=>settle(r.id,!1)},{label:r.options.confirmLabel,tone:r.options.tone??"primary",onPress:()=>settle(r.id,!0)}],testID:t}):null}
@@ -1 +1 @@
1
- "use strict";import{useCallback,useEffect,useMemo,useRef,useState}from"react";import{Animated,Easing,Modal,Pressable,StyleSheet,View}from"react-native";import{GestureDetector,GestureHandlerRootView}from"react-native-gesture-handler";import{useDragToDismiss}from"../../hooks/useDragToDismiss.js";import{usePresenceMotion}from"../../hooks/usePresenceMotion.js";import{createAnimatedValue,setNativeValue,useTheme}from"../../theme/index.js";import{resolveHaptic,triggerHaptic}from"../../utils/index.js";import{transparentOf}from"../../utils/color.js";import{smoothCorners}from"../../utils/corners.js";import{hitSlopMarker}from"../../utils/hitSlop.js";import{defaultIcons}from"../AppIcon/defaultIcons.js";import{Calendar}from"../Calendar/index.js";import{ModalSafeArea,useModalInsets}from"../ModalSafeArea/ModalSafeArea.js";import{PickerTrigger}from"../PickerTrigger/index.js";import{Text}from"../Text/index.js";import{ToastHost}from"../Toast/ToastProvider.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";const NAV_BUTTON_SIZE=36;export const DEFAULT_DATE_PICKER_LABELS=Object.freeze({title:"Select Date",confirm:"Confirm",cancel:"Cancel",dismiss:"Dismiss",previousMonth:"Previous month",nextMonth:"Next month",previousYears:"Previous years",nextYears:"Next years",previousDecades:"Previous decades",nextDecades:"Next decades",switchToYears:"switch to year selection",switchToDecades:"switch to decade selection",year:e=>`Year ${e}`,decade:(e,t)=>`Decade ${e} to ${t}`});const AnimatedGestureRoot=Animated.createAnimatedComponent(GestureHandlerRootView),GRID_SIZE=12,DECADE_SPAN=10,startOfDay=e=>new Date(e.getFullYear(),e.getMonth(),e.getDate()),decadeStartFor=e=>10*Math.floor(e/10),buildYearCells=e=>{const t=e-4;return Array.from({length:12},(e,a)=>t+a)},buildDecadeCells=e=>{const t=decadeStartFor(e)-40;return Array.from({length:12},(e,a)=>t+10*a)},DatePicker=e=>{const{value:t,onChange:a,onClose:r,minDate:s,maxDate:i,disabledDates:o,inline:l=!1,locale:n="en-IN",weekStartsOn:c=0,title:d,labels:u,style:m,containerStyle:g,headerLabelStyle:h,navButtonStyle:b,footerButtonStyle:y,haptic:p,testID:f,label:x,placeholder:v,helperText:D,error:C,required:w,disabled:j,size:S,variant:_,clearable:T,onClear:A,formatValue:R,triggerStyle:M}=e,V=l?"inline":"modal",P=useMemo(()=>u?{...DEFAULT_DATE_PICKER_LABELS,...u}:DEFAULT_DATE_PICKER_LABELS,[u]),k=void 0!==e.visible,[I,L]=useState(!1),E=k?e.visible:I,B=k?f:f?`${f}-calendar`:void 0,F=useTheme(),z=usePresenceMotion(),[Y,H]=useModalInsets(),N=useMemo(()=>buildStyles(F),[F]),[O,$]=useState(()=>startOfDay(new Date));useEffect(()=>{E&&$(startOfDay(new Date))},[E]);const W=t?startOfDay(t):O,[G,q]=useState(W),[U,K]=useState(t?startOfDay(t):null),[Z,X]=useState("days"),J=useRef(createAnimatedValue(0)).current,Q=useRef(createAnimatedValue(0)).current,ee=useRef(createAnimatedValue(0)).current,te=useRef(0),ae=useRef(createAnimatedValue(1)).current,re=useRef(createAnimatedValue(1)).current,se=useRef(createAnimatedValue(1)).current;useEffect(()=>{if(t){const e=startOfDay(t);K(e),q(e)}else K(null)},[t]);const ie=useMemo(()=>s?startOfDay(s):null,[s]),oe=useMemo(()=>i?startOfDay(i):null,[i]),le=useMemo(()=>buildYearCells(G.getFullYear()),[G]),ne=useMemo(()=>buildDecadeCells(G.getFullYear()),[G]),ce=useMemo(()=>{if("years"===Z){return`${le[0]} - ${le[le.length-1]}`}return`${ne[0]} - ${ne[ne.length-1]+9}`},[ne,Z,le]),de=useCallback(e=>!!(ie&&e<ie.getFullYear())||!!(oe&&e>oe.getFullYear()),[ie,oe]),ue=useCallback(e=>!!(ie&&e+10-1<ie.getFullYear())||!!(oe&&e>oe.getFullYear()),[ie,oe]),me=useCallback(()=>{!1!==p&&triggerHaptic("impactLight"),q("years"===Z?e=>new Date(e.getFullYear()-12,e.getMonth(),1):e=>new Date(e.getFullYear()-120,e.getMonth(),1))},[Z,p]),ge=useCallback(()=>{!1!==p&&triggerHaptic("impactLight"),q("years"===Z?e=>new Date(e.getFullYear()+12,e.getMonth(),1):e=>new Date(e.getFullYear()+120,e.getMonth(),1))},[Z,p]),he=useCallback(()=>{const[e]=z.range(.9,1),t=z.reduced?z.duration("default"):F.motion.duration.default;setNativeValue(ae,0),setNativeValue(re,e),Animated.parallel([Animated.timing(ae,{toValue:1,duration:t,easing:Easing.out(Easing.cubic),useNativeDriver:!0}),Animated.timing(re,{toValue:1,duration:t,easing:Easing.out(Easing.cubic),useNativeDriver:!0})]).start()},[ae,re,z,F.motion.duration.default]),be=useCallback(()=>{const e=resolveHaptic(p,"selection");if(e&&triggerHaptic(e),!z.reduced){const e=80,t=100;Animated.sequence([Animated.timing(se,{toValue:.96,duration:e,useNativeDriver:!0}),Animated.timing(se,{toValue:1,duration:t,useNativeDriver:!0})]).start()}X(e=>"days"===e?"years":"years"===e?"decades":"years"),he()},[he,se,p,z.reduced]),ye=useCallback(e=>{const t=resolveHaptic(p,"selection");t&&triggerHaptic(t),q(t=>new Date(e,t.getMonth(),1)),X("days"),he()},[he,p]),pe=useCallback(e=>{const t=resolveHaptic(p,"selection");t&&triggerHaptic(t),q(t=>new Date(e+4,t.getMonth(),1)),X("years"),he()},[he,p]),fe=useCallback(e=>{K(e.start)},[]),xe=useCallback(()=>{k||L(!1),r?.()},[k,r]),ve=useCallback(()=>{"modal"===V?Animated.parallel([Animated.timing(J,{toValue:0,duration:z.duration("default"),easing:Easing.bezier(...F.motion.ease.accelerate),useNativeDriver:!1}),Animated.timing(Q,{toValue:0,duration:z.duration("fast"),easing:Easing.bezier(...F.motion.ease.accelerate),useNativeDriver:!0})]).start(()=>{xe()}):xe()},[J,V,xe,z,Q,F.motion.ease.accelerate]),{handleGesture:De,opacity:Ce}=useDragToDismiss({drag:ee,travel:()=>te.current||320,onDismiss:ve}),we=useMemo(()=>Animated.multiply(Q,Ce),[Q,Ce]),je=useMemo(()=>J.interpolate({inputRange:[0,1],outputRange:[transparentOf(F.colors.scrim),F.colors.scrim]}),[J,F.colors.scrim]);useEffect(()=>{if("modal"===V&&E){J.setValue(0),setNativeValue(Q,0),setNativeValue(ee,0),setNativeValue(Ce,1);const e=z.reduced?Animated.timing(Q,{toValue:1,duration:z.duration("default"),useNativeDriver:!0}):Animated.spring(Q,{toValue:1,damping:F.motion.spring.gentle.damping,stiffness:F.motion.spring.gentle.stiffness,mass:F.motion.spring.gentle.mass,useNativeDriver:!0}),t=Animated.parallel([Animated.timing(J,{toValue:1,duration:z.duration("default"),easing:Easing.out(Easing.cubic),useNativeDriver:!1}),e]);return t.start(),()=>t.stop()}},[E,V,J,z,Q,ee,Ce,F.motion]);const Se=useCallback(()=>{!1!==p&&triggerHaptic("selection"),ve()},[ve,p]),Te=useCallback(()=>{U&&(!1!==p&&triggerHaptic("notificationSuccess"),a?.(U),ve())},[ve,a,U,p]),Ae=Q.interpolate({inputRange:[0,1],outputRange:z.range(320,0)}),Re=_jsx(View,{style:N.titleRow,children:_jsx(Text,{style:N.title,variant:"title",accessibilityRole:"header",children:d??P.title})}),Me=_jsxs(View,{style:[N.card,m,g],accessibilityRole:"modal"===V?void 0:"none",accessible:!1,testID:B,children:["modal"===V?_jsx(GestureDetector,{gesture:De,children:_jsxs(View,{style:N.grabArea,children:[_jsx(View,{style:N.handle}),Re]})}):Re,"days"!==Z?_jsxs(View,{style:N.headerRow,children:[_jsx(Pressable,{onPress:me,style:({pressed:e})=>[N.navBtn,e&&N.navBtnPressed,b],accessibilityRole:"button",accessibilityLabel:"years"===Z?P.previousYears:P.previousDecades,hitSlop:8,...hitSlopMarker(8),children:_jsx(Text,{style:N.navText,variant:"title",children:"‹"})}),_jsx(Pressable,{onPress:be,style:[N.headerLabelWrap,h],accessibilityRole:"button",accessibilityLabel:`${ce}, ${"years"===Z?P.switchToDecades:P.switchToYears}`,hitSlop:8,...hitSlopMarker(8),children:_jsxs(Animated.View,{style:[N.headerLabelInner,{transform:[{scale:se}]}],children:[_jsx(Animated.Text,{style:[N.headerLabel,{transform:[{translateX:0}]}],accessibilityLiveRegion:"polite",children:ce}),_jsx(View,{style:N.headerCaret,children:(F.settings.icons.chevronDown??defaultIcons.chevronDown)({size:F.text.sm.size,color:F.colors["text-muted"]})})]})}),_jsx(Pressable,{onPress:ge,style:({pressed:e})=>[N.navBtn,e&&N.navBtnPressed,b],accessibilityRole:"button",accessibilityLabel:"years"===Z?P.nextYears:P.nextDecades,hitSlop:8,...hitSlopMarker(8),children:_jsx(Text,{style:N.navText,variant:"title",children:"›"})})]}):null,"days"===Z?_jsx(Calendar,{selectionMode:"single",value:U?{start:U}:null,onChange:fe,month:G,onMonthChange:q,minDate:s,maxDate:i,disabledDates:o,weekStartsOn:c,locale:n,haptic:p,headerLabelStyle:h,navButtonStyle:b,onTitlePress:be,labels:{previousMonth:P.previousMonth,nextMonth:P.nextMonth},testID:B?`${B}-grid`:void 0}):_jsx(Animated.View,"years"===Z?{style:[N.yearGrid,{opacity:ae,transform:[{scale:re}]}],children:Array.from({length:3},(e,t)=>le.slice(4*t,4*t+4)).map(e=>_jsx(View,{style:N.gridRow,children:e.map(e=>{const t=de(e),a=!!U&&U.getFullYear()===e,r=O.getFullYear()===e,s=a?F.colors.primary:"transparent",i=r&&!a?F.colors.primary:"transparent",o=a?F.colors["on-primary"]:t?F.colors["text-disabled"]:F.colors["text-body"],l=t?.3:1;return _jsx(Pressable,{disabled:t,onPress:()=>ye(e),accessibilityRole:"button",accessibilityLabel:P.year(e),accessibilityState:{selected:a,disabled:t},"aria-selected":a,"aria-disabled":t,style:N.yearCell,children:_jsx(View,{style:[N.yearInner,{backgroundColor:s,borderColor:i,borderWidth:r&&!a?1.5:0,opacity:l}],children:_jsx(Text,{style:[N.yearText,{color:o}],variant:"body",children:e})})},`year-${e}`)})},`yr-${e[0]}`))}:{style:[N.yearGrid,{opacity:ae,transform:[{scale:re}]}],children:Array.from({length:3},(e,t)=>ne.slice(4*t,4*t+4)).map(e=>_jsx(View,{style:N.gridRow,children:e.map(e=>{const t=e+10-1,a=ue(e),r=!!U&&decadeStartFor(U.getFullYear())===e,s=decadeStartFor(O.getFullYear())===e,i=r?F.colors.primary:"transparent",o=s&&!r?F.colors.primary:"transparent",l=r?F.colors["on-primary"]:a?F.colors["text-disabled"]:F.colors["text-body"],n=a?.3:1;return _jsx(Pressable,{disabled:a,onPress:()=>pe(e),accessibilityRole:"button",accessibilityLabel:P.decade(e,t),accessibilityState:{selected:r,disabled:a},"aria-selected":r,"aria-disabled":a,style:N.yearCell,children:_jsxs(View,{style:[N.yearInner,{backgroundColor:i,borderColor:o,borderWidth:s&&!r?1.5:0,opacity:n}],children:[_jsx(Text,{style:[N.yearText,{color:l}],variant:"body",children:`${e}s`}),_jsx(Text,{variant:"caption",style:[N.decadeRangeText,{color:r?F.colors["on-primary"]:F.colors["text-subtle"]}],children:`${e}-${t}`})]})},`decade-${e}`)})},`dec-${e[0]}`))}),_jsxs(View,{style:N.footer,children:[_jsx(Pressable,{onPress:Se,style:({pressed:e})=>[N.footerBtn,N.footerCancel,e&&N.footerBtnPressed,y],accessibilityRole:"button",accessibilityLabel:P.cancel,children:_jsx(Text,{style:[N.footerBtnText,{color:F.colors["text-muted"]}],variant:"label",weight:"semibold",children:P.cancel})}),_jsx(Pressable,{onPress:Te,disabled:!U,style:({pressed:e})=>[N.footerBtn,N.footerConfirm,{backgroundColor:F.colors.primary,opacity:U?1:.5},e&&{backgroundColor:F.colors["primary-hover"]},y],accessibilityRole:"button",accessibilityLabel:P.confirm,accessibilityState:{disabled:!U},"aria-disabled":!U,children:_jsx(Text,{style:[N.footerBtnText,{color:F.colors["on-primary"]}],variant:"label",weight:"semibold",children:P.confirm})})]})]}),Ve=t?(R??(e=>e.toLocaleDateString()))(t):void 0,Pe=!k;if("inline"===V)return E||Pe?Pe?_jsxs(_Fragment,{children:[_jsx(PickerTrigger,{label:x,value:Ve,placeholder:v,helperText:D,error:C,required:w,disabled:j,size:S,variant:_,clearable:T,onClear:A,onPress:()=>L(!0),triggerStyle:M,testID:f}),E?Me:null]}):Me:null;const ke=_jsx(Modal,{visible:E,transparent:!0,statusBarTranslucent:!0,navigationBarTranslucent:!0,animationType:"none",onRequestClose:ve,children:_jsx(ModalSafeArea,{onInsets:H,children:_jsxs(AnimatedGestureRoot,{collapsable:!1,style:[N.backdrop,{backgroundColor:je}],children:[_jsx(Pressable,{style:StyleSheet.absoluteFill,onPress:ve,accessibilityLabel:P.dismiss}),_jsx(Animated.View,{style:[N.sheetWrap,{paddingBottom:Math.max(Y.bottom,F.space.lg),opacity:we,transform:[{translateY:Animated.add(Ae,ee)}]}],onLayout:e=>{te.current=e.nativeEvent.layout.height},accessibilityViewIsModal:!0,accessibilityRole:"none",children:Me}),_jsx(ToastHost,{})]})})});return Pe?_jsxs(_Fragment,{children:[_jsx(PickerTrigger,{label:x,value:Ve,placeholder:v,helperText:D,error:C,required:w,disabled:j,size:S,variant:_,clearable:T,onClear:A,onPress:()=>L(!0),triggerStyle:M,testID:f}),ke]}):ke},buildStyles=e=>{const t=e.shadow.popover;return StyleSheet.create({backdrop:{...StyleSheet.absoluteFill},sheetWrap:{position:"absolute",left:0,right:0,bottom:0,paddingHorizontal:e.space.md,paddingBottom:e.space.lg},card:{backgroundColor:e.colors.surface,borderRadius:e.radius.xl,...smoothCorners,padding:e.space.lg,shadowColor:t.shadowColor,shadowOffset:t.shadowOffset,shadowOpacity:t.shadowOpacity,shadowRadius:t.shadowRadius,elevation:t.elevation},grabArea:{marginTop:-e.space.lg,paddingTop:e.space.sm},handle:{alignSelf:"center",width:36,height:4,borderRadius:e.radius.pill,...smoothCorners,backgroundColor:e.colors["border-subtle"],marginBottom:e.space.sm},titleRow:{marginBottom:e.space.sm},title:{fontSize:e.text.lg.size,lineHeight:Math.round(e.text.lg.size*e.leading.body),fontWeight:e.weight.semibold,color:e.colors["text-body"]},headerRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",marginBottom:e.space.md},navBtn:{width:36,height:36,borderRadius:e.radius.pill,...smoothCorners,alignItems:"center",justifyContent:"center",backgroundColor:e.colors["bg-subtle"]},navBtnPressed:{backgroundColor:e.colors["surface-pressed"]},navText:{fontSize:e.text["2xl"].size,lineHeight:26,color:e.colors["text-body"],fontWeight:e.weight.semibold},headerLabelWrap:{flex:1,alignItems:"center"},headerLabelInner:{flexDirection:"row",alignItems:"center",justifyContent:"center"},headerLabel:{fontSize:e.text.base.size,fontWeight:e.weight.semibold,color:e.colors["text-body"]},headerCaret:{marginLeft:e.space.xs,alignItems:"center",justifyContent:"center"},gridRow:{flexDirection:"row"},yearGrid:{},yearCell:{flex:1,aspectRatio:1.6,alignItems:"center",justifyContent:"center",padding:e.space.xs},yearInner:{width:"100%",height:"100%",borderRadius:e.radius.lg,...smoothCorners,alignItems:"center",justifyContent:"center"},yearText:{fontSize:e.text.base.size,lineHeight:Math.round(e.text.base.size*e.leading.body),fontWeight:e.weight.semibold},decadeRangeText:{fontSize:e.text.xs.size,lineHeight:Math.round(e.text.xs.size*e.leading.body),fontWeight:e.weight.medium,marginTop:e.space.xxs},footer:{flexDirection:"row",justifyContent:"flex-end",alignItems:"center",marginTop:e.space.lg,gap:e.space.sm},footerBtn:{paddingHorizontal:e.space.lg,paddingVertical:e.space.sm,borderRadius:e.radius.md,...smoothCorners,minHeight:40,alignItems:"center",justifyContent:"center"},footerCancel:{backgroundColor:"transparent"},footerConfirm:{},footerBtnPressed:{opacity:.85},footerBtnText:{fontSize:e.text.sm.size,lineHeight:Math.round(e.text.sm.size*e.leading.body),fontWeight:e.weight.semibold}})};export{DatePicker};export default DatePicker;
1
+ "use strict";import{useCallback,useEffect,useMemo,useRef,useState}from"react";import{Animated,Easing,Pressable,StyleSheet,View}from"react-native";import{GestureDetector,GestureHandlerRootView}from"react-native-gesture-handler";import{useDragToDismiss}from"../../hooks/useDragToDismiss.js";import{usePresenceMotion}from"../../hooks/usePresenceMotion.js";import{createAnimatedValue,setNativeValue,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{defaultIcons}from"../AppIcon/defaultIcons.js";import{Calendar}from"../Calendar/index.js";import{Modal}from"../Modal/index.js";import{useModalInsets}from"../ModalSafeArea/ModalSafeArea.js";import{PickerTrigger}from"../PickerTrigger/index.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";const NAV_BUTTON_SIZE=36;export const DEFAULT_DATE_PICKER_LABELS=Object.freeze({title:"Select Date",confirm:"Confirm",cancel:"Cancel",dismiss:"Dismiss",previousMonth:"Previous month",nextMonth:"Next month",previousYears:"Previous years",nextYears:"Next years",previousDecades:"Previous decades",nextDecades:"Next decades",switchToYears:"switch to year selection",switchToDecades:"switch to decade selection",year:e=>`Year ${e}`,decade:(e,t)=>`Decade ${e} to ${t}`});const GRID_SIZE=12,DECADE_SPAN=10,startOfDay=e=>new Date(e.getFullYear(),e.getMonth(),e.getDate()),decadeStartFor=e=>10*Math.floor(e/10),buildYearCells=e=>{const t=e-4;return Array.from({length:12},(e,a)=>t+a)},buildDecadeCells=e=>{const t=decadeStartFor(e)-40;return Array.from({length:12},(e,a)=>t+10*a)},DatePicker=e=>{const{value:t,onChange:a,onClose:s,minDate:r,maxDate:i,disabledDates:o,inline:l=!1,locale:n="en-IN",weekStartsOn:c=0,title:d,labels:u,style:g,containerStyle:m,headerLabelStyle:h,navButtonStyle:y,footerButtonStyle:b,haptic:p,testID:x,label:f,help:D,placeholder:v,helperText:C,error:w,required:j,disabled:S,size:_,variant:T,clearable:M,onClear:P,leftIcon:R,trailing:k,triggerStyle:A,valueStyle:I,labelStyle:V,messageStyle:L,accessibilityLabel:B,triggerLabels:E,formatValue:F}=e,Y=l?"inline":"modal",z=useMemo(()=>u?{...DEFAULT_DATE_PICKER_LABELS,...u}:DEFAULT_DATE_PICKER_LABELS,[u]),H=void 0!==e.open,[$,N]=useState(!1),O=H?e.open:$,W=H?x:x?`${x}-calendar`:void 0,G=useTheme(),U=usePresenceMotion(),[q,K]=useModalInsets(),Z=useMemo(()=>buildStyles(G),[G]),[X,J]=useState(()=>startOfDay(new Date));useEffect(()=>{O&&J(startOfDay(new Date))},[O]);const Q=t?startOfDay(t):X,[ee,te]=useState(Q),[ae,se]=useState(t?startOfDay(t):null),[re,ie]=useState("days"),oe=useRef(createAnimatedValue(0)).current,le=useRef(0),ne=useRef(createAnimatedValue(1)).current,ce=useRef(createAnimatedValue(1)).current,de=useRef(createAnimatedValue(1)).current;useEffect(()=>{if(t){const e=startOfDay(t);se(e),te(e)}else se(null)},[t]);const ue=useMemo(()=>r?startOfDay(r):null,[r]),ge=useMemo(()=>i?startOfDay(i):null,[i]),me=useMemo(()=>buildYearCells(ee.getFullYear()),[ee]),he=useMemo(()=>buildDecadeCells(ee.getFullYear()),[ee]),ye=useMemo(()=>{if("years"===re){return`${me[0]} - ${me[me.length-1]}`}return`${he[0]} - ${he[he.length-1]+9}`},[he,re,me]),be=useCallback(e=>!!(ue&&e<ue.getFullYear())||!!(ge&&e>ge.getFullYear()),[ue,ge]),pe=useCallback(e=>!!(ue&&e+10-1<ue.getFullYear())||!!(ge&&e>ge.getFullYear()),[ue,ge]),xe=useCallback(()=>{!1!==p&&triggerHaptic("impactLight"),te("years"===re?e=>new Date(e.getFullYear()-12,e.getMonth(),1):e=>new Date(e.getFullYear()-120,e.getMonth(),1))},[re,p]),fe=useCallback(()=>{!1!==p&&triggerHaptic("impactLight"),te("years"===re?e=>new Date(e.getFullYear()+12,e.getMonth(),1):e=>new Date(e.getFullYear()+120,e.getMonth(),1))},[re,p]),De=useCallback(()=>{const[e]=U.range(.9,1),t=U.reduced?U.duration("default"):G.motion.duration.default;setNativeValue(ne,0),setNativeValue(ce,e),Animated.parallel([Animated.timing(ne,{toValue:1,duration:t,easing:Easing.out(Easing.cubic),useNativeDriver:!0}),Animated.timing(ce,{toValue:1,duration:t,easing:Easing.out(Easing.cubic),useNativeDriver:!0})]).start()},[ne,ce,U,G.motion.duration.default]),ve=useCallback(()=>{const e=resolveHaptic(p,"selection");if(e&&triggerHaptic(e),!U.reduced){const e=80,t=100;Animated.sequence([Animated.timing(de,{toValue:.96,duration:e,useNativeDriver:!0}),Animated.timing(de,{toValue:1,duration:t,useNativeDriver:!0})]).start()}ie(e=>"days"===e?"years":"years"===e?"decades":"years"),De()},[De,de,p,U.reduced]),Ce=useCallback(e=>{const t=resolveHaptic(p,"selection");t&&triggerHaptic(t),te(t=>new Date(e,t.getMonth(),1)),ie("days"),De()},[De,p]),we=useCallback(e=>{const t=resolveHaptic(p,"selection");t&&triggerHaptic(t),te(t=>new Date(e+4,t.getMonth(),1)),ie("years"),De()},[De,p]),je=useCallback(e=>{se(e.start)},[]),Se=useCallback(()=>{H||N(!1),s?.()},[H,s]),{handleGesture:Te,opacity:Me}=useDragToDismiss({drag:oe,travel:()=>le.current||320,onDismiss:Se});useEffect(()=>{O&&"modal"===Y&&(setNativeValue(oe,0),setNativeValue(Me,1))},[O,Y,oe,Me]);const Pe=useCallback(()=>{!1!==p&&triggerHaptic("selection"),Se()},[Se,p]),Re=useCallback(()=>{ae&&(!1!==p&&triggerHaptic("notificationSuccess"),a?.(ae),Se())},[Se,a,ae,p]),ke=_jsx(View,{style:Z.titleRow,children:_jsx(Text,{style:Z.title,variant:"title",accessibilityRole:"header",children:d??z.title})}),Ae=_jsxs(View,{style:[Z.card,m,g],accessibilityRole:"modal"===Y?void 0:"none",accessible:!1,testID:W,children:["modal"===Y?_jsx(GestureDetector,{gesture:Te,children:_jsxs(View,{style:Z.grabArea,children:[_jsx(View,{style:Z.handle}),ke]})}):ke,"days"!==re?_jsxs(View,{style:Z.headerRow,children:[_jsx(Pressable,{onPress:xe,style:({pressed:e})=>[Z.navBtn,e&&Z.navBtnPressed,y],accessibilityRole:"button",accessibilityLabel:"years"===re?z.previousYears:z.previousDecades,hitSlop:8,...hitSlopMarker(8),children:_jsx(Text,{style:Z.navText,variant:"title",children:"‹"})}),_jsx(Pressable,{onPress:ve,style:[Z.headerLabelWrap,h],accessibilityRole:"button",accessibilityLabel:`${ye}, ${"years"===re?z.switchToDecades:z.switchToYears}`,hitSlop:8,...hitSlopMarker(8),children:_jsxs(Animated.View,{style:[Z.headerLabelInner,{transform:[{scale:de}]}],children:[_jsx(Animated.Text,{style:[Z.headerLabel,{transform:[{translateX:0}]}],accessibilityLiveRegion:"polite",children:ye}),_jsx(View,{style:Z.headerCaret,children:(G.settings.icons.chevronDown??defaultIcons.chevronDown)({size:G.text.sm.size,color:G.colors["text-muted"]})})]})}),_jsx(Pressable,{onPress:fe,style:({pressed:e})=>[Z.navBtn,e&&Z.navBtnPressed,y],accessibilityRole:"button",accessibilityLabel:"years"===re?z.nextYears:z.nextDecades,hitSlop:8,...hitSlopMarker(8),children:_jsx(Text,{style:Z.navText,variant:"title",children:"›"})})]}):null,"days"===re?_jsx(Calendar,{selectionMode:"single",value:ae?{start:ae}:null,onChange:je,month:ee,onMonthChange:te,minDate:r,maxDate:i,disabledDates:o,weekStartsOn:c,locale:n,haptic:p,headerLabelStyle:h,navButtonStyle:y,onTitlePress:ve,labels:{previousMonth:z.previousMonth,nextMonth:z.nextMonth},testID:W?`${W}-grid`:void 0}):_jsx(Animated.View,"years"===re?{style:[Z.yearGrid,{opacity:ne,transform:[{scale:ce}]}],children:Array.from({length:3},(e,t)=>me.slice(4*t,4*t+4)).map(e=>_jsx(View,{style:Z.gridRow,children:e.map(e=>{const t=be(e),a=!!ae&&ae.getFullYear()===e,s=X.getFullYear()===e,r=a?G.colors.primary:"transparent",i=s&&!a?G.colors.primary:"transparent",o=a?G.colors["on-primary"]:t?G.colors["text-disabled"]:G.colors["text-body"],l=t?.3:1;return _jsx(Pressable,{disabled:t,onPress:()=>Ce(e),accessibilityRole:"button",accessibilityLabel:z.year(e),accessibilityState:{selected:a,disabled:t},"aria-selected":a,"aria-disabled":t,style:Z.yearCell,children:_jsx(View,{style:[Z.yearInner,{backgroundColor:r,borderColor:i,borderWidth:s&&!a?1.5:0,opacity:l}],children:_jsx(Text,{style:[Z.yearText,{color:o}],variant:"body",children:e})})},`year-${e}`)})},`yr-${e[0]}`))}:{style:[Z.yearGrid,{opacity:ne,transform:[{scale:ce}]}],children:Array.from({length:3},(e,t)=>he.slice(4*t,4*t+4)).map(e=>_jsx(View,{style:Z.gridRow,children:e.map(e=>{const t=e+10-1,a=pe(e),s=!!ae&&decadeStartFor(ae.getFullYear())===e,r=decadeStartFor(X.getFullYear())===e,i=s?G.colors.primary:"transparent",o=r&&!s?G.colors.primary:"transparent",l=s?G.colors["on-primary"]:a?G.colors["text-disabled"]:G.colors["text-body"],n=a?.3:1;return _jsx(Pressable,{disabled:a,onPress:()=>we(e),accessibilityRole:"button",accessibilityLabel:z.decade(e,t),accessibilityState:{selected:s,disabled:a},"aria-selected":s,"aria-disabled":a,style:Z.yearCell,children:_jsxs(View,{style:[Z.yearInner,{backgroundColor:i,borderColor:o,borderWidth:r&&!s?1.5:0,opacity:n}],children:[_jsx(Text,{style:[Z.yearText,{color:l}],variant:"body",children:`${e}s`}),_jsx(Text,{variant:"caption",style:[Z.decadeRangeText,{color:s?G.colors["on-primary"]:G.colors["text-subtle"]}],children:`${e}-${t}`})]})},`decade-${e}`)})},`dec-${e[0]}`))}),_jsxs(View,{style:Z.footer,children:[_jsx(Pressable,{onPress:Pe,style:({pressed:e})=>[Z.footerBtn,Z.footerCancel,e&&Z.footerBtnPressed,b],accessibilityRole:"button",accessibilityLabel:z.cancel,children:_jsx(Text,{style:[Z.footerBtnText,{color:G.colors["text-muted"]}],variant:"label",weight:"semibold",children:z.cancel})}),_jsx(Pressable,{onPress:Re,disabled:!ae,style:({pressed:e})=>[Z.footerBtn,Z.footerConfirm,{backgroundColor:G.colors.primary,opacity:ae?1:.5},e&&{backgroundColor:G.colors["primary-hover"]},b],accessibilityRole:"button",accessibilityLabel:z.confirm,accessibilityState:{disabled:!ae},"aria-disabled":!ae,children:_jsx(Text,{style:[Z.footerBtnText,{color:G.colors["on-primary"]}],variant:"label",weight:"semibold",children:z.confirm})})]})]}),Ie=t?(F??(e=>e.toLocaleDateString()))(t):void 0,Ve=!H,Le={label:f,help:D,placeholder:v,helperText:C,error:w,required:j,disabled:S,size:_,variant:T,clearable:M,onClear:P,leftIcon:R,trailing:k,triggerStyle:A,valueStyle:I,labelStyle:V,messageStyle:L,accessibilityLabel:B,labels:E};if("inline"===Y)return O||Ve?Ve?_jsxs(_Fragment,{children:[_jsx(PickerTrigger,{...Le,value:Ie,onPress:()=>N(!0),testID:x}),O?Ae:null]}):Ae:null;const Be=_jsx(Modal,{open:O,onClose:Se,presentation:"bottom",bare:!0,haptic:!1,labels:{close:z.dismiss},onInsetsChange:K,children:_jsx(GestureHandlerRootView,{children:_jsx(Animated.View,{style:[Z.sheetWrap,{paddingBottom:Math.max(q.bottom,G.space.lg),opacity:Me,transform:[{translateY:oe}]}],onLayout:e=>{le.current=e.nativeEvent.layout.height},accessibilityViewIsModal:!0,accessibilityRole:"none",children:Ae})})});return Ve?_jsxs(_Fragment,{children:[_jsx(PickerTrigger,{...Le,value:Ie,onPress:()=>N(!0),testID:x}),Be]}):Be},buildStyles=e=>{const t=e.shadow.popover;return StyleSheet.create({sheetWrap:{paddingHorizontal:e.space.md,paddingBottom:e.space.lg},card:{backgroundColor:e.colors.surface,borderRadius:e.radius.xl,...smoothCorners,padding:e.space.lg,shadowColor:t.shadowColor,shadowOffset:t.shadowOffset,shadowOpacity:t.shadowOpacity,shadowRadius:t.shadowRadius,elevation:t.elevation},grabArea:{marginTop:-e.space.lg,paddingTop:e.space.sm},handle:{alignSelf:"center",width:36,height:4,borderRadius:e.radius.pill,...smoothCorners,backgroundColor:e.colors["border-subtle"],marginBottom:e.space.sm},titleRow:{marginBottom:e.space.sm},title:{fontSize:e.text.lg.size,lineHeight:Math.round(e.text.lg.size*e.leading.body),fontWeight:e.weight.semibold,color:e.colors["text-body"]},headerRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",marginBottom:e.space.md},navBtn:{width:36,height:36,borderRadius:e.radius.pill,...smoothCorners,alignItems:"center",justifyContent:"center",backgroundColor:e.colors["bg-subtle"]},navBtnPressed:{backgroundColor:e.colors["surface-pressed"]},navText:{fontSize:e.text["2xl"].size,lineHeight:26,color:e.colors["text-body"],fontWeight:e.weight.semibold},headerLabelWrap:{flex:1,alignItems:"center"},headerLabelInner:{flexDirection:"row",alignItems:"center",justifyContent:"center"},headerLabel:{fontSize:e.text.base.size,fontWeight:e.weight.semibold,color:e.colors["text-body"]},headerCaret:{marginLeft:e.space.xs,alignItems:"center",justifyContent:"center"},gridRow:{flexDirection:"row"},yearGrid:{},yearCell:{flex:1,aspectRatio:1.6,alignItems:"center",justifyContent:"center",padding:e.space.xs},yearInner:{width:"100%",height:"100%",borderRadius:e.radius.lg,...smoothCorners,alignItems:"center",justifyContent:"center"},yearText:{fontSize:e.text.base.size,lineHeight:Math.round(e.text.base.size*e.leading.body),fontWeight:e.weight.semibold},decadeRangeText:{fontSize:e.text.xs.size,lineHeight:Math.round(e.text.xs.size*e.leading.body),fontWeight:e.weight.medium,marginTop:e.space.xxs},footer:{flexDirection:"row",justifyContent:"flex-end",alignItems:"center",marginTop:e.space.lg,gap:e.space.sm},footerBtn:{paddingHorizontal:e.space.lg,paddingVertical:e.space.sm,borderRadius:e.radius.md,...smoothCorners,minHeight:40,alignItems:"center",justifyContent:"center"},footerCancel:{backgroundColor:"transparent"},footerConfirm:{},footerBtnPressed:{opacity:.85},footerBtnText:{fontSize:e.text.sm.size,lineHeight:Math.round(e.text.sm.size*e.leading.body),fontWeight:e.weight.semibold}})};export{DatePicker};export default DatePicker;
@@ -1 +1 @@
1
- "use strict";import{forwardRef,useCallback,useEffect,useMemo,useRef,useState}from"react";import{Animated,Easing,Modal,Pressable,StyleSheet,View}from"react-native";import{GestureDetector,GestureHandlerRootView}from"react-native-gesture-handler";import{useDragToDismiss}from"../../hooks/useDragToDismiss.js";import{usePresenceMotion}from"../../hooks/usePresenceMotion.js";import{createAnimatedValue,setNativeValue,useTheme}from"../../theme/index.js";import{triggerHaptic}from"../../utils/index.js";import{transparentOf}from"../../utils/color.js";import{smoothCorners}from"../../utils/corners.js";import{Calendar}from"../Calendar/index.js";import{daysBetween,startOfDay,startOfMonth}from"../Calendar/calendarDates.js";import{ModalSafeArea,useModalInsets}from"../ModalSafeArea/ModalSafeArea.js";import{PickerTrigger}from"../PickerTrigger/index.js";import{Text}from"../Text/index.js";import{ToastHost}from"../Toast/ToastProvider.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";export const DEFAULT_DATE_RANGE_PICKER_LABELS=Object.freeze({title:"Select Date Range",confirm:"Confirm",cancel:"Cancel",dismiss:"Dismiss"});const AnimatedGestureRoot=Animated.createAnimatedComponent(GestureHandlerRootView),formatRangePart=(e,t)=>new Intl.DateTimeFormat(t,{weekday:"short",day:"numeric",month:"short"}).format(e),DateRangePicker=forwardRef((e,t)=>{const{visible:a,value:s,onChange:r,onClose:o,label:i,placeholder:n,helperText:l,error:d,required:c,disabled:m,size:u,variant:g,clearable:f,onClear:p,formatValue:h,triggerStyle:b,minDate:y,maxDate:x,disabledDates:D,marks:v,locale:R="en-IN",weekStartsOn:j=0,title:S,labels:C,maxRange:w,haptic:T,style:A,containerStyle:_,headerLabelStyle:k,navButtonStyle:M,footerButtonStyle:P,testID:V}=e,B=void 0!==a,[E,O]=useState(!1),z=B?a:E,L=B?V:V?`${V}-calendar`:void 0,H=useTheme(),I=usePresenceMotion(),[N,G]=useModalInsets(),F=useMemo(()=>buildStyles(H),[H]),$=useMemo(()=>({...DEFAULT_DATE_RANGE_PICKER_LABELS,...C}),[C]),[W,q]=useState(()=>startOfMonth(s.start??new Date)),[K,U]=useState(s.start?startOfDay(s.start):null),[Y,J]=useState(s.end?startOfDay(s.end):null),Q=useRef(createAnimatedValue(0)).current,X=useRef(createAnimatedValue(0)).current,Z=useRef(createAnimatedValue(0)).current,ee=useRef(0);useEffect(()=>{if(s.start){const e=startOfDay(s.start);U(e),q(startOfMonth(e))}else U(null);s.end?J(startOfDay(s.end)):J(null)},[s.start,s.end]);const te=useCallback(e=>{if(e.end&&w&&daysBetween(e.start,e.end)+1>w)return!1!==T&&triggerHaptic("notificationWarning"),U(e.end),void J(null);U(e.start),J(e.end??null)},[w,T]),ae=useCallback(()=>{B?o?.():O(!1)},[B,o]),se=useCallback(()=>{Animated.parallel([Animated.timing(Q,{toValue:0,duration:I.duration("default"),easing:Easing.bezier(...H.motion.ease.accelerate),useNativeDriver:!1}),Animated.timing(X,{toValue:0,duration:I.duration("fast"),easing:Easing.bezier(...H.motion.ease.accelerate),useNativeDriver:!0})]).start(()=>{ae()})},[Q,ae,I,X,H.motion.ease.accelerate]),{handleGesture:re,opacity:oe}=useDragToDismiss({drag:Z,travel:()=>ee.current||320,onDismiss:se}),ie=useMemo(()=>Animated.multiply(X,oe),[X,oe]),ne=useMemo(()=>Q.interpolate({inputRange:[0,1],outputRange:[transparentOf(H.colors.scrim),H.colors.scrim]}),[Q,H.colors.scrim]);useEffect(()=>{let e;if(z){Q.setValue(0),setNativeValue(X,0),setNativeValue(Z,0),setNativeValue(oe,1);const t=I.reduced?Animated.timing(X,{toValue:1,duration:I.duration("default"),useNativeDriver:!0}):Animated.spring(X,{toValue:1,damping:H.motion.spring.gentle.damping,stiffness:H.motion.spring.gentle.stiffness,mass:H.motion.spring.gentle.mass,useNativeDriver:!0});e=Animated.parallel([Animated.timing(Q,{toValue:1,duration:I.duration("default"),easing:Easing.out(Easing.cubic),useNativeDriver:!1}),t]),e.start()}return()=>e?.stop()},[z,Q,I,X,Z,oe,H.motion]);const le=useCallback(()=>{!1!==T&&triggerHaptic("selection"),se()},[se,T]),de=useCallback(()=>{K&&Y&&(!1!==T&&triggerHaptic("notificationSuccess"),r?.({start:K,end:Y}),se())},[se,r,K,Y,T]),ce=X.interpolate({inputRange:[0,1],outputRange:I.range(320,0)}),me=useMemo(()=>K&&Y?`${formatRangePart(K,R)} — ${formatRangePart(Y,R)}`:K?`${formatRangePart(K,R)} — …`:"—",[K,Y,R]),ue=!K||!Y,ge=_jsxs(View,{style:[F.card,A,_],ref:t,accessible:!1,testID:L,children:[_jsx(GestureDetector,{gesture:re,children:_jsxs(View,{style:F.grabArea,children:[_jsx(View,{style:F.handle}),_jsxs(View,{style:F.titleRow,children:[_jsx(Text,{variant:"title",style:F.title,accessibilityRole:"header",children:S??$.title}),_jsx(Text,{variant:"bodySmall",style:F.subtitle,accessibilityLiveRegion:"polite",children:me})]})]})}),_jsx(Calendar,{selectionMode:"range",value:K?{start:K,end:Y??void 0}:null,onChange:te,month:W,onMonthChange:q,minDate:y,maxDate:x,disabledDates:D,marks:v,weekStartsOn:j,locale:R,haptic:T,headerLabelStyle:k,navButtonStyle:M,testID:L?`${L}-grid`:void 0}),_jsxs(View,{style:F.footer,children:[_jsx(Pressable,{onPress:le,style:({pressed:e})=>[F.footerBtn,F.footerCancel,e&&F.footerBtnPressed,P],accessibilityRole:"button",accessibilityLabel:$.cancel,children:_jsx(Text,{variant:"label",weight:"semibold",style:[F.footerBtnText,{color:H.colors["text-muted"]}],children:$.cancel})}),_jsx(Pressable,{onPress:de,disabled:ue,style:({pressed:e})=>[F.footerBtn,F.footerConfirm,{backgroundColor:H.colors.primary,opacity:ue?.5:1},e&&{backgroundColor:H.colors["primary-hover"]},P],accessibilityRole:"button",accessibilityLabel:$.confirm,accessibilityState:{disabled:ue},"aria-disabled":ue,children:_jsx(Text,{variant:"label",weight:"semibold",style:[F.footerBtnText,{color:H.colors["on-primary"]}],children:$.confirm})})]})]}),fe=useMemo(()=>{if(!s.start||!s.end)return"";const e={start:s.start,end:s.end};return h?h(e):`${e.start.toLocaleDateString()} – ${e.end.toLocaleDateString()}`},[s.start,s.end,h]);return _jsxs(_Fragment,{children:[B?null:_jsx(PickerTrigger,{label:i,placeholder:n,helperText:l,error:d,required:c,disabled:m,size:u,variant:g,clearable:f,onClear:p,value:fe,onPress:()=>O(!0),triggerStyle:b,testID:V}),_jsx(Modal,{visible:z,transparent:!0,statusBarTranslucent:!0,navigationBarTranslucent:!0,animationType:"none",onRequestClose:se,children:_jsx(ModalSafeArea,{onInsets:G,children:_jsxs(AnimatedGestureRoot,{collapsable:!1,style:[F.backdrop,{backgroundColor:ne}],children:[_jsx(Pressable,{style:StyleSheet.absoluteFill,onPress:se,accessibilityLabel:$.dismiss}),_jsx(Animated.View,{style:[F.sheetWrap,{paddingBottom:Math.max(N.bottom,H.space.lg),opacity:ie,transform:[{translateY:Animated.add(ce,Z)}]}],onLayout:e=>{ee.current=e.nativeEvent.layout.height},accessibilityViewIsModal:!0,accessibilityRole:"none",children:ge}),_jsx(ToastHost,{})]})})})]})});DateRangePicker.displayName="DateRangePicker";const buildStyles=e=>{const t=e.shadow.popover;return StyleSheet.create({backdrop:{...StyleSheet.absoluteFill},sheetWrap:{position:"absolute",left:0,right:0,bottom:0,paddingHorizontal:e.space.md,paddingBottom:e.space.lg},card:{backgroundColor:e.colors.surface,borderRadius:e.radius.xl,...smoothCorners,padding:e.space.lg,shadowColor:t.shadowColor,shadowOffset:t.shadowOffset,shadowOpacity:t.shadowOpacity,shadowRadius:t.shadowRadius,elevation:t.elevation},grabArea:{marginTop:-e.space.lg,paddingTop:e.space.sm},handle:{alignSelf:"center",width:36,height:4,borderRadius:e.radius.pill,...smoothCorners,backgroundColor:e.colors["border-subtle"],marginBottom:e.space.sm},titleRow:{marginBottom:e.space.sm},title:{fontSize:e.text.lg.size,lineHeight:Math.round(e.text.lg.size*e.leading.body),fontWeight:e.weight.semibold,color:e.colors["text-body"]},subtitle:{marginTop:e.space.xxs,fontSize:e.text.sm.size,lineHeight:Math.round(e.text.sm.size*e.leading.body),color:e.colors["text-muted"]},footer:{flexDirection:"row",justifyContent:"flex-end",alignItems:"center",marginTop:e.space.lg,gap:e.space.sm},footerBtn:{paddingHorizontal:e.space.lg,paddingVertical:e.space.sm,borderRadius:e.radius.md,...smoothCorners,minHeight:40,alignItems:"center",justifyContent:"center"},footerCancel:{backgroundColor:"transparent"},footerConfirm:{},footerBtnPressed:{opacity:.85},footerBtnText:{fontSize:e.text.sm.size,lineHeight:Math.round(e.text.sm.size*e.leading.body),fontWeight:e.weight.semibold}})};export{DateRangePicker};export default DateRangePicker;
1
+ "use strict";import{forwardRef,useCallback,useEffect,useMemo,useRef,useState}from"react";import{Animated,Pressable,StyleSheet,View}from"react-native";import{GestureDetector,GestureHandlerRootView}from"react-native-gesture-handler";import{useDragToDismiss}from"../../hooks/useDragToDismiss.js";import{createAnimatedValue,setNativeValue,useTheme}from"../../theme/index.js";import{triggerHaptic}from"../../utils/index.js";import{smoothCorners}from"../../utils/corners.js";import{Calendar}from"../Calendar/index.js";import{daysBetween,startOfDay,startOfMonth}from"../Calendar/calendarDates.js";import{Modal}from"../Modal/index.js";import{useModalInsets}from"../ModalSafeArea/ModalSafeArea.js";import{PickerTrigger}from"../PickerTrigger/index.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";export const DEFAULT_DATE_RANGE_PICKER_LABELS=Object.freeze({title:"Select Date Range",confirm:"Confirm",cancel:"Cancel",dismiss:"Dismiss"});const formatRangePart=(e,t)=>new Intl.DateTimeFormat(t,{weekday:"short",day:"numeric",month:"short"}).format(e),DateRangePicker=forwardRef((e,t)=>{const{open:a,value:s,onChange:r,onClose:o,label:i,help:l,placeholder:n,helperText:d,error:c,required:m,disabled:u,size:g,variant:f,clearable:h,onClear:p,leftIcon:b,trailing:y,triggerStyle:x,valueStyle:D,labelStyle:S,messageStyle:C,accessibilityLabel:j,triggerLabels:w,formatValue:R,minDate:v,maxDate:_,disabledDates:T,marks:k,locale:M="en-IN",weekStartsOn:P=0,title:B,labels:L,maxRange:V,haptic:A,style:I,containerStyle:O,headerLabelStyle:z,navButtonStyle:E,footerButtonStyle:H,testID:G}=e,N={label:i,help:l,placeholder:n,helperText:d,error:c,required:m,disabled:u,size:g,variant:f,clearable:h,onClear:p,leftIcon:b,trailing:y,triggerStyle:x,valueStyle:D,labelStyle:S,messageStyle:C,accessibilityLabel:j},$=void 0!==a,[F,W]=useState(!1),q=$?a:F,K=$?G:G?`${G}-calendar`:void 0,U=useTheme(),[Y,J]=useModalInsets(),Q=useMemo(()=>buildStyles(U),[U]),X=useMemo(()=>({...DEFAULT_DATE_RANGE_PICKER_LABELS,...L}),[L]),[Z,ee]=useState(()=>startOfMonth(s.start??new Date)),[te,ae]=useState(s.start?startOfDay(s.start):null),[se,re]=useState(s.end?startOfDay(s.end):null),oe=useRef(createAnimatedValue(0)).current,ie=useRef(0);useEffect(()=>{if(s.start){const e=startOfDay(s.start);ae(e),ee(startOfMonth(e))}else ae(null);s.end?re(startOfDay(s.end)):re(null)},[s.start,s.end]);const le=useCallback(e=>{if(e.end&&V&&daysBetween(e.start,e.end)+1>V)return!1!==A&&triggerHaptic("notificationWarning"),ae(e.end),void re(null);ae(e.start),re(e.end??null)},[V,A]),ne=useCallback(()=>{$?o?.():W(!1)},[$,o]),{handleGesture:de,opacity:ce}=useDragToDismiss({drag:oe,travel:()=>ie.current||320,onDismiss:ne});useEffect(()=>{q&&(setNativeValue(oe,0),setNativeValue(ce,1))},[q,oe,ce]);const me=useCallback(()=>{!1!==A&&triggerHaptic("selection"),ne()},[ne,A]),ue=useCallback(()=>{te&&se&&(!1!==A&&triggerHaptic("notificationSuccess"),r?.({start:te,end:se}),ne())},[ne,r,te,se,A]),ge=useMemo(()=>te&&se?`${formatRangePart(te,M)} — ${formatRangePart(se,M)}`:te?`${formatRangePart(te,M)} — …`:"—",[te,se,M]),fe=!te||!se,he=_jsxs(View,{style:[Q.card,O,I],ref:t,accessible:!1,testID:K,children:[_jsx(GestureDetector,{gesture:de,children:_jsxs(View,{style:Q.grabArea,children:[_jsx(View,{style:Q.handle}),_jsxs(View,{style:Q.titleRow,children:[_jsx(Text,{variant:"title",style:Q.title,accessibilityRole:"header",children:B??X.title}),_jsx(Text,{variant:"bodySmall",style:Q.subtitle,accessibilityLiveRegion:"polite",children:ge})]})]})}),_jsx(Calendar,{selectionMode:"range",value:te?{start:te,end:se??void 0}:null,onChange:le,month:Z,onMonthChange:ee,minDate:v,maxDate:_,disabledDates:T,marks:k,weekStartsOn:P,locale:M,haptic:A,headerLabelStyle:z,navButtonStyle:E,testID:K?`${K}-grid`:void 0}),_jsxs(View,{style:Q.footer,children:[_jsx(Pressable,{onPress:me,style:({pressed:e})=>[Q.footerBtn,Q.footerCancel,e&&Q.footerBtnPressed,H],accessibilityRole:"button",accessibilityLabel:X.cancel,children:_jsx(Text,{variant:"label",weight:"semibold",style:[Q.footerBtnText,{color:U.colors["text-muted"]}],children:X.cancel})}),_jsx(Pressable,{onPress:ue,disabled:fe,style:({pressed:e})=>[Q.footerBtn,Q.footerConfirm,{backgroundColor:U.colors.primary,opacity:fe?.5:1},e&&{backgroundColor:U.colors["primary-hover"]},H],accessibilityRole:"button",accessibilityLabel:X.confirm,accessibilityState:{disabled:fe},"aria-disabled":fe,children:_jsx(Text,{variant:"label",weight:"semibold",style:[Q.footerBtnText,{color:U.colors["on-primary"]}],children:X.confirm})})]})]}),pe=useMemo(()=>{if(!s.start||!s.end)return"";const e={start:s.start,end:s.end};return R?R(e):`${e.start.toLocaleDateString()} – ${e.end.toLocaleDateString()}`},[s.start,s.end,R]);return _jsxs(_Fragment,{children:[$?null:_jsx(PickerTrigger,{...N,labels:w,value:pe,onPress:()=>W(!0),testID:G}),_jsx(Modal,{open:q,onClose:ne,presentation:"bottom",bare:!0,haptic:!1,labels:{close:X.dismiss},onInsetsChange:J,children:_jsx(GestureHandlerRootView,{children:_jsx(Animated.View,{style:[Q.sheetWrap,{paddingBottom:Math.max(Y.bottom,U.space.lg),opacity:ce,transform:[{translateY:oe}]}],onLayout:e=>{ie.current=e.nativeEvent.layout.height},accessibilityViewIsModal:!0,accessibilityRole:"none",children:he})})})]})});DateRangePicker.displayName="DateRangePicker";const buildStyles=e=>{const t=e.shadow.popover;return StyleSheet.create({sheetWrap:{paddingHorizontal:e.space.md,paddingBottom:e.space.lg},card:{backgroundColor:e.colors.surface,borderRadius:e.radius.xl,...smoothCorners,padding:e.space.lg,shadowColor:t.shadowColor,shadowOffset:t.shadowOffset,shadowOpacity:t.shadowOpacity,shadowRadius:t.shadowRadius,elevation:t.elevation},grabArea:{marginTop:-e.space.lg,paddingTop:e.space.sm},handle:{alignSelf:"center",width:36,height:4,borderRadius:e.radius.pill,...smoothCorners,backgroundColor:e.colors["border-subtle"],marginBottom:e.space.sm},titleRow:{marginBottom:e.space.sm},title:{fontSize:e.text.lg.size,lineHeight:Math.round(e.text.lg.size*e.leading.body),fontWeight:e.weight.semibold,color:e.colors["text-body"]},subtitle:{marginTop:e.space.xxs,fontSize:e.text.sm.size,lineHeight:Math.round(e.text.sm.size*e.leading.body),color:e.colors["text-muted"]},footer:{flexDirection:"row",justifyContent:"flex-end",alignItems:"center",marginTop:e.space.lg,gap:e.space.sm},footerBtn:{paddingHorizontal:e.space.lg,paddingVertical:e.space.sm,borderRadius:e.radius.md,...smoothCorners,minHeight:40,alignItems:"center",justifyContent:"center"},footerCancel:{backgroundColor:"transparent"},footerConfirm:{},footerBtnPressed:{opacity:.85},footerBtnText:{fontSize:e.text.sm.size,lineHeight:Math.round(e.text.sm.size*e.leading.body),fontWeight:e.weight.semibold}})};export{DateRangePicker};export default DateRangePicker;
@@ -1 +1 @@
1
- "use strict";import{isValidElement,useMemo}from"react";import{StyleSheet,Text,View}from"react-native";import{fontFor,useTheme}from"../../theme/index.js";import{warnInvalidValue}from"../../utils/warnInvalidValue.js";import{Notation,NotationInkContext}from"../Notation/Notation.js";import{resolveColor}from"../Text/Text.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const EMPTY_VALUE="-",rowKey=(e,t)=>e.key??("string"==typeof e.label?`${e.label}-${t}`:`row-${t}`),isEmptyValue=e=>null==e||""===e||Array.isArray(e)&&!e.length,isInlineText=e=>"string"==typeof e||"number"==typeof e||isValidElement(e)&&e.type===Notation||Array.isArray(e)&&e.length>0&&e.every(isInlineText);export const Descriptions=({items:e,columns:t=1,size:l="md",bordered:o=!1,title:r,variant:s="list",style:i,testID:n})=>{warnInvalidValue("Descriptions","size",l,["sm","md"]),warnInvalidValue("Descriptions","variant",s,["list","summary"]),warnInvalidValue("Descriptions","columns",t,[1,2]);const a=useTheme(),m=useMemo(()=>buildStyles(a),[a]),u="sm"===l?a.text.xs.size:a.text.sm.size,d="sm"===l?a.text.sm.size:a.text.base.size,x="sm"===l?a.space.xs:a.space.sm,c="summary"===s,y=useMemo(()=>({fontSize:u,color:a.colors["text-subtle"]}),[u,a.colors["text-subtle"]]),b=useMemo(()=>({fontSize:d,color:a.colors["text-muted"]}),[d,a.colors["text-muted"]]);return _jsxs(View,{style:[c?null:{gap:x},i],testID:n,children:[r?_jsx(Text,{style:[m.title,{fontSize:a.text.lg.size,color:a.colors["text-body"]}],children:r}):null,e.map((e,l)=>{const r=isEmptyValue(e.value),s=2===t&&!e.full,i=r?a.colors["text-subtle"]:resolveColor(a,e.tone??"primary"),n=fontFor(a,e.strong?"semibold":"normal"),f=r||isInlineText(e.value),p=r?"-":"string"==typeof e.value?e.value:_jsx(NotationInkContext.Provider,{value:{fontSize:d,color:i},children:e.value});return _jsxs(View,c?{testID:e.testID,style:[m.summaryRow,{paddingVertical:x,borderBottomColor:a.colors["border-subtle"]}],children:[_jsx(Text,{style:[m.summaryLabel,{fontSize:d,color:a.colors["text-muted"]}],children:_jsx(NotationInkContext.Provider,{value:b,children:e.label})}),f?_jsx(Text,{style:[m.summaryValue,{fontSize:d,color:i},n],children:p}):_jsx(View,{style:m.summaryValueView,children:e.value})]}:{testID:e.testID,style:[s?m.rowSide:m.rowStack,{paddingVertical:x},o&&l>0?m.bordered:null,o&&l>0?{borderTopColor:a.colors["border-subtle"]}:null],children:["string"==typeof e.label?_jsx(Text,{style:[m.label,{fontSize:u,color:a.colors["text-subtle"]},s?m.labelSide:null],children:e.label}):_jsx(View,{style:s?m.labelSide:null,children:_jsx(Text,{style:[m.label,{fontSize:u,color:a.colors["text-subtle"]}],children:_jsx(NotationInkContext.Provider,{value:y,children:e.label})})}),f?_jsx(Text,{style:[m.value,{fontSize:d,color:i},e.strong?n:null,s?m.valueSide:null],children:p}):_jsx(View,{style:s?m.valueSide:null,children:e.value})]},rowKey(e,l))})]})};const buildStyles=e=>StyleSheet.create({title:{...fontFor(e,"semibold")},rowStack:{gap:e.space.xxs},rowSide:{flexDirection:"row",alignItems:"flex-start",gap:e.space.md},bordered:{borderTopWidth:StyleSheet.hairlineWidth},label:{...fontFor(e,"semibold")},labelSide:{flex:4},value:{...fontFor(e,"normal")},valueSide:{flex:6},summaryRow:{flexDirection:"row",alignItems:"center",gap:e.space.md,borderBottomWidth:StyleSheet.hairlineWidth},summaryLabel:{flex:1,...fontFor(e,"normal")},summaryValue:{textAlign:"right",flexShrink:1,maxWidth:"60%"},summaryValueView:{flexShrink:1,maxWidth:"60%",alignItems:"flex-end"}});export default Descriptions;
1
+ "use strict";import{isValidElement,useMemo}from"react";import{StyleSheet,Text,View}from"react-native";import{fontFor,useTheme}from"../../theme/index.js";import{warnInvalidValue}from"../../utils/warnInvalidValue.js";import{resolveColor}from"../Text/Text.js";import{TextInkContext}from"../Text/textInk.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const EMPTY_VALUE="-",rowKey=(e,t)=>e.key??("string"==typeof e.label?`${e.label}-${t}`:`row-${t}`),isEmptyValue=e=>null==e||""===e||Array.isArray(e)&&!e.length,isInlineText=e=>"string"==typeof e||"number"==typeof e||isValidElement(e)&&!0===e.type.inlineText||Array.isArray(e)&&e.length>0&&e.every(isInlineText);export const Descriptions=({items:e,columns:t=1,size:l="md",bordered:r=!1,title:s,variant:o="list",style:i,testID:n})=>{warnInvalidValue("Descriptions","size",l,["sm","md"]),warnInvalidValue("Descriptions","variant",o,["list","summary"]),warnInvalidValue("Descriptions","columns",t,[1,2]);const a=useTheme(),m=useMemo(()=>buildStyles(a),[a]),x="sm"===l?a.text.xs.size:a.text.sm.size,u="sm"===l?a.text.sm.size:a.text.base.size,d="sm"===l?a.space.xs:a.space.sm,c="summary"===o,y=useMemo(()=>({fontSize:x,color:a.colors["text-subtle"]}),[x,a.colors["text-subtle"]]),b=useMemo(()=>({fontSize:u,color:a.colors["text-muted"]}),[u,a.colors["text-muted"]]);return _jsxs(View,{style:[c?null:{gap:d},i],testID:n,children:[s?_jsx(Text,{style:[m.title,{fontSize:a.text.lg.size,color:a.colors["text-body"]}],children:s}):null,e.map((e,l)=>{const s=isEmptyValue(e.value),o=2===t&&!e.full,i=s?a.colors["text-subtle"]:resolveColor(a,e.tone??"primary"),n=fontFor(a,e.strong?"semibold":"normal"),f=s||isInlineText(e.value),p=s?"-":"string"==typeof e.value?e.value:_jsx(TextInkContext.Provider,{value:{fontSize:u,color:i},children:e.value});return _jsxs(View,c?{testID:e.testID,style:[m.summaryRow,{paddingVertical:d,borderBottomColor:a.colors["border-subtle"]}],children:[_jsx(Text,{style:[m.summaryLabel,{fontSize:u,color:a.colors["text-muted"]}],children:_jsx(TextInkContext.Provider,{value:b,children:e.label})}),f?_jsx(Text,{style:[m.summaryValue,{fontSize:u,color:i},n],children:p}):_jsx(View,{style:m.summaryValueView,children:e.value})]}:{testID:e.testID,style:[o?m.rowSide:m.rowStack,{paddingVertical:d},r&&l>0?m.bordered:null,r&&l>0?{borderTopColor:a.colors["border-subtle"]}:null],children:["string"==typeof e.label?_jsx(Text,{style:[m.label,{fontSize:x,color:a.colors["text-subtle"]},o?m.labelSide:null],children:e.label}):_jsx(View,{style:o?m.labelSide:null,children:_jsx(Text,{style:[m.label,{fontSize:x,color:a.colors["text-subtle"]}],children:_jsx(TextInkContext.Provider,{value:y,children:e.label})})}),f?_jsx(Text,{style:[m.value,{fontSize:u,color:i},e.strong?n:null,o?m.valueSide:null],children:p}):_jsx(View,{style:o?m.valueSide:null,children:e.value})]},rowKey(e,l))})]})};const buildStyles=e=>StyleSheet.create({title:{...fontFor(e,"semibold")},rowStack:{gap:e.space.xxs},rowSide:{flexDirection:"row",alignItems:"flex-start",gap:e.space.md},bordered:{borderTopWidth:StyleSheet.hairlineWidth},label:{...fontFor(e,"semibold")},labelSide:{flex:4},value:{...fontFor(e,"normal")},valueSide:{flex:6},summaryRow:{flexDirection:"row",alignItems:"center",gap:e.space.md,borderBottomWidth:StyleSheet.hairlineWidth},summaryLabel:{flex:1,...fontFor(e,"normal")},summaryValue:{textAlign:"right",flexShrink:1,maxWidth:"60%"},summaryValueView:{flexShrink:1,maxWidth:"60%",alignItems:"flex-end"}});export default Descriptions;
@@ -1 +1 @@
1
- "use strict";import{isValidElement,useCallback,useMemo,useState}from"react";import{Image,StyleSheet,Text,View}from"react-native";import{fontFor,useTheme}from"../../theme/index.js";import{tintOf}from"../../utils/color.js";import{smoothCorners}from"../../utils/corners.js";import{resolveHaptic,triggerHaptic}from"../../utils/hapticUtils.js";import{warnInvalidValue}from"../../utils/warnInvalidValue.js";import{AppIcon}from"../AppIcon/index.js";import{MODAL_DISMISS_GRACE_MS,Modal}from"../Modal/Modal.js";import{ACTIONS_LAYOUTS,OVERLAY_TONES,OverlayActions}from"./OverlayActions.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const DIALOG_ILLUSTRATION_SIZE=120,STATUS_MARK={success:"check-circle",warning:"alert-triangle",danger:"alert-circle",info:"info-circle"},Dialog=e=>{const{visible:t,onClose:s,title:o,message:i,children:l,icon:n,illustration:r,tone:a="neutral",actions:c,actionsLayout:m="auto",dismissOnAction:u=!0,accessibilityLabel:d,contentStyle:g,containerStyle:p,titleStyle:S,messageStyle:y,iconWrapperStyle:x,actionsRowStyle:h,actionButtonStyle:f,actionTextStyle:_,haptic:A,testID:I}=e;warnInvalidValue("Dialog","tone",e.tone,OVERLAY_TONES),warnInvalidValue("Dialog","actionsLayout",e.actionsLayout,ACTIONS_LAYOUTS);const b=useTheme(),j=useMemo(()=>buildStyles(),[]),O=useMemo(()=>discFor(b,a),[b,a]),T=b.components.dialog["icon-wrapper-size"],M=Boolean(c&&c.length>0),w=useState(null),L=useCallback(e=>{if(e.loading||e.disabled)return;const t=resolveHaptic(A,"selection");t&&triggerHaptic(t),u?(s(),setTimeout(e.onPress,MODAL_DISMISS_GRACE_MS)):e.onPress()},[u,s,A]),C=useMemo(()=>(c??[]).map(e=>({...e,onPress:()=>L(e)})),[c,L]),D=null==n&&null==r&&STATUS_MARK[a]?_jsx(AppIcon,{name:STATUS_MARK[a],size:Math.round(T/2),color:b.colors[a]}):null,v=n??D;return _jsx(Modal,{visible:t,onClose:s,haptic:A,presentation:"centered",accessibilityLabel:d??o,contentStyle:g,testID:I,children:_jsxs(View,{accessibilityRole:"alert",accessibilityLabel:d??o,style:[j.container,p],children:[null!=r?_jsx(View,{style:{alignItems:"center",marginBottom:b.space.md},children:isValidElement(r)?r:_jsx(Image,{source:r,style:{width:120,height:120},resizeMode:"contain",accessibilityIgnoresInvertColors:!0})}):null,v?_jsx(View,{style:[j.iconWrapper,{width:T,height:T,borderRadius:b.radius.pill,...smoothCorners,backgroundColor:O,marginBottom:b.space.md},x],children:v}):null,o?_jsx(Text,{style:[j.title,{color:b.colors["text-body"],fontSize:b.text.xl.size,...fontFor(b,"semibold"),marginBottom:i||null!=l?b.space.sm:b.space.md},S],accessibilityRole:"header",children:o}):null,i?_jsx(Text,{style:[j.message,{color:b.colors["text-muted"],fontSize:b.text.base.size,lineHeight:b.text.base.size*b.leading.body,marginBottom:null!=l?b.space.md:M?b.space.lg:0},y],children:i}):null,null!=l?_jsx(View,{style:{marginBottom:M?b.space.lg:0},children:l}):null,M?_jsx(OverlayActions,{actions:C,layout:m,stackedLabels:w,rowStyle:h,buttonStyle:f,textStyle:_}):null]})})};Dialog.displayName="Dialog";const SOFT_DISC_OPACITY=.14,discFor=(e,t)=>{const s=e.colors["bg-subtle"];switch(t){case"success":return tintOf(e.colors.success,.14,s);case"warning":return tintOf(e.colors.warning,.14,s);case"danger":return tintOf(e.colors.danger,.14,s);case"info":return tintOf(e.colors.info,.14,s);default:return e.colors["primary-soft"]}},buildStyles=()=>StyleSheet.create({container:{alignItems:"stretch"},iconWrapper:{alignItems:"center",justifyContent:"center",alignSelf:"center"},title:{textAlign:"center"},message:{textAlign:"center"}});export{Dialog};export default Dialog;
1
+ "use strict";import{isValidElement,useCallback,useMemo,useState}from"react";import{Image,StyleSheet,Text,View}from"react-native";import{fontFor,useTheme}from"../../theme/index.js";import{tintOf}from"../../utils/color.js";import{smoothCorners}from"../../utils/corners.js";import{resolveHaptic,triggerHaptic}from"../../utils/hapticUtils.js";import{warnInvalidValue}from"../../utils/warnInvalidValue.js";import{AppIcon}from"../AppIcon/index.js";import{MODAL_DISMISS_GRACE_MS,Modal}from"../Modal/Modal.js";import{ACTIONS_LAYOUTS,OVERLAY_TONES,OverlayActions}from"./OverlayActions.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const DIALOG_ILLUSTRATION_SIZE=120,STATUS_MARK={success:"check-circle",warning:"alert-triangle",danger:"alert-circle",info:"info-circle"},Dialog=e=>{const{open:t,onClose:o,title:s,message:l,children:i,icon:n,illustration:r,tone:a="neutral",actions:c,actionsLayout:m="auto",dismissOnAction:u=!0,accessibilityLabel:d,contentStyle:p,containerStyle:g,titleStyle:S,messageStyle:y,iconWrapperStyle:x,actionsRowStyle:h,actionButtonStyle:f,actionTextStyle:_,haptic:A,testID:I}=e;warnInvalidValue("Dialog","tone",e.tone,OVERLAY_TONES),warnInvalidValue("Dialog","actionsLayout",e.actionsLayout,ACTIONS_LAYOUTS);const b=useTheme(),j=useMemo(()=>buildStyles(),[]),O=useMemo(()=>discFor(b,a),[b,a]),T=b.components.dialog["icon-wrapper-size"],M=Boolean(c&&c.length>0),w=useState(null),L=useCallback(e=>{if(e.loading||e.disabled)return;const t=resolveHaptic(A,"selection");t&&triggerHaptic(t),u?(o(),setTimeout(e.onPress,MODAL_DISMISS_GRACE_MS)):e.onPress()},[u,o,A]),C=useMemo(()=>(c??[]).map(e=>({...e,onPress:()=>L(e)})),[c,L]),D=null==n&&null==r&&STATUS_MARK[a]?_jsx(AppIcon,{name:STATUS_MARK[a],size:Math.round(T/2),color:b.colors[a]}):null,V=n??D;return _jsx(Modal,{open:t,onClose:o,haptic:A,presentation:"centered",accessibilityLabel:d??s,contentStyle:p,testID:I,children:_jsxs(View,{accessibilityRole:"alert",accessibilityLabel:d??s,style:[j.container,g],children:[null!=r?_jsx(View,{style:{alignItems:"center",marginBottom:b.space.md},children:isValidElement(r)?r:_jsx(Image,{source:r,style:{width:120,height:120},resizeMode:"contain",accessibilityIgnoresInvertColors:!0})}):null,V?_jsx(View,{style:[j.iconWrapper,{width:T,height:T,borderRadius:b.radius.pill,...smoothCorners,backgroundColor:O,marginBottom:b.space.md},x],children:V}):null,s?_jsx(Text,{style:[j.title,{color:b.colors["text-body"],fontSize:b.text.xl.size,...fontFor(b,"semibold"),marginBottom:l||null!=i?b.space.sm:b.space.md},S],accessibilityRole:"header",children:s}):null,l?_jsx(Text,{style:[j.message,{color:b.colors["text-muted"],fontSize:b.text.base.size,lineHeight:b.text.base.size*b.leading.body,marginBottom:null!=i?b.space.md:M?b.space.lg:0},y],children:l}):null,null!=i?_jsx(View,{style:{marginBottom:M?b.space.lg:0},children:i}):null,M?_jsx(OverlayActions,{actions:C,layout:m,stackedLabels:w,rowStyle:h,buttonStyle:f,textStyle:_}):null]})})};Dialog.displayName="Dialog";const SOFT_DISC_OPACITY=.14,discFor=(e,t)=>{const o=e.colors["bg-subtle"];switch(t){case"success":return tintOf(e.colors.success,.14,o);case"warning":return tintOf(e.colors.warning,.14,o);case"danger":return tintOf(e.colors.danger,.14,o);case"info":return tintOf(e.colors.info,.14,o);default:return e.colors["primary-soft"]}},buildStyles=()=>StyleSheet.create({container:{alignItems:"stretch"},iconWrapper:{alignItems:"center",justifyContent:"center",alignSelf:"center"},title:{textAlign:"center"},message:{textAlign:"center"}});export{Dialog};export default Dialog;