@webority/mobile-ui 0.9.1 → 0.11.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 (346) hide show
  1. package/android/src/newarch/java/com/webority/mobileui/pdfrasterizer/PdfRasterizerModule.kt +6 -7
  2. package/ios/PdfRasterizer.mm +36 -9
  3. package/lib/commonjs/components/BarChart/BarChart.js +1 -0
  4. package/lib/commonjs/components/BarChart/index.js +1 -0
  5. package/lib/commonjs/components/BarChart/scale.js +1 -0
  6. package/lib/commonjs/components/BottomNavigation/BottomNavigation.js +1 -1
  7. package/lib/commonjs/components/BottomNavigation/useScreenReaderEnabled.js +1 -0
  8. package/lib/commonjs/components/BottomSheet/BottomSheet.js +1 -1
  9. package/lib/commonjs/components/BottomSheet/index.js +1 -1
  10. package/lib/commonjs/components/BottomSheet/useSheetSwap.js +1 -0
  11. package/lib/commonjs/components/Card/Card.js +1 -1
  12. package/lib/commonjs/components/Checkbox/Checkbox.js +1 -1
  13. package/lib/commonjs/components/Composer/Composer.js +1 -0
  14. package/lib/commonjs/components/Composer/index.js +1 -0
  15. package/lib/commonjs/components/DateSeparator/DateSeparator.js +1 -0
  16. package/lib/commonjs/components/DateSeparator/index.js +1 -0
  17. package/lib/commonjs/components/FieldBase/ChoiceText.js +1 -1
  18. package/lib/commonjs/components/FieldBase/FieldBase.js +1 -1
  19. package/lib/commonjs/components/FieldBase/useFloatingLabel.js +1 -1
  20. package/lib/commonjs/components/FloatingActionButton/FloatingActionButton.js +1 -1
  21. package/lib/commonjs/components/FormField/FormField.js +1 -1
  22. package/lib/commonjs/components/Input/Input.js +1 -1
  23. package/lib/commonjs/components/ListItem/ListItem.js +1 -1
  24. package/lib/commonjs/components/Menu/Menu.js +1 -0
  25. package/lib/commonjs/components/Menu/MenuSurface.js +1 -0
  26. package/lib/commonjs/components/Menu/focusHost.js +1 -0
  27. package/lib/commonjs/components/Menu/index.js +1 -0
  28. package/lib/commonjs/components/Menu/menuModel.js +1 -0
  29. package/lib/commonjs/components/Menu/useContextMenu.js +1 -0
  30. package/lib/commonjs/components/Menu/webOnly.js +1 -0
  31. package/lib/commonjs/components/MessageBubble/MessageBubble.js +1 -0
  32. package/lib/commonjs/components/MessageBubble/index.js +1 -0
  33. package/lib/commonjs/components/MessageList/MessageList.js +1 -0
  34. package/lib/commonjs/components/MessageList/index.js +1 -0
  35. package/lib/commonjs/components/Notation/Notation.js +1 -1
  36. package/lib/commonjs/components/OnboardingPager/OnboardingPager.js +1 -0
  37. package/lib/commonjs/components/OnboardingPager/index.js +1 -0
  38. package/lib/commonjs/components/OptionSheet/OptionSheet.js +1 -1
  39. package/lib/commonjs/components/PaymentResult/PaymentResult.js +1 -0
  40. package/lib/commonjs/components/PaymentResult/index.js +1 -0
  41. package/lib/commonjs/components/PermissionPrompt/PermissionPrompt.js +1 -0
  42. package/lib/commonjs/components/PermissionPrompt/index.js +1 -0
  43. package/lib/commonjs/components/PermissionPrompt/usePermissionPrompt.js +1 -0
  44. package/lib/commonjs/components/PhoneNumberInput/PhoneNumberInput.js +1 -1
  45. package/lib/commonjs/components/Radio/Radio.js +1 -1
  46. package/lib/commonjs/components/Radio/RadioGroup.js +1 -1
  47. package/lib/commonjs/components/ScannerOverlay/ScannerOverlay.js +1 -0
  48. package/lib/commonjs/components/ScannerOverlay/index.js +1 -0
  49. package/lib/commonjs/components/SearchBar/SearchBar.js +1 -1
  50. package/lib/commonjs/components/SearchBar/SearchPanel.js +1 -0
  51. package/lib/commonjs/components/SearchBar/highlight.js +1 -0
  52. package/lib/commonjs/components/SearchBar/index.js +1 -1
  53. package/lib/commonjs/components/SearchBar/useRecentSearches.js +1 -0
  54. package/lib/commonjs/components/SegmentedControl/SegmentedControl.js +1 -1
  55. package/lib/commonjs/components/Select/Select.js +1 -1
  56. package/lib/commonjs/components/SignaturePad/SignaturePad.js +1 -0
  57. package/lib/commonjs/components/SignaturePad/index.js +1 -0
  58. package/lib/commonjs/components/SignaturePad/signatureGeometry.js +1 -0
  59. package/lib/commonjs/components/SignaturePad/writePng.js +1 -0
  60. package/lib/commonjs/components/SignaturePad/writePng.web.js +1 -0
  61. package/lib/commonjs/components/Sparkline/Sparkline.js +1 -0
  62. package/lib/commonjs/components/Sparkline/geometry.js +1 -0
  63. package/lib/commonjs/components/Sparkline/index.js +1 -0
  64. package/lib/commonjs/components/Spinner/Spinner.js +1 -1
  65. package/lib/commonjs/components/StatTile/StatTile.js +1 -1
  66. package/lib/commonjs/components/Switch/Switch.js +1 -1
  67. package/lib/commonjs/components/TagInput/TagInput.js +1 -1
  68. package/lib/commonjs/components/TimePicker/TimePicker.js +1 -1
  69. package/lib/commonjs/components/Toast/Toast.js +1 -1
  70. package/lib/commonjs/components/Toast/ToastProvider.js +1 -1
  71. package/lib/commonjs/components/Tooltip/RichTooltipBody.js +1 -0
  72. package/lib/commonjs/components/Tooltip/Tooltip.js +1 -1
  73. package/lib/commonjs/components/Tooltip/tooltipPosition.js +1 -0
  74. package/lib/commonjs/components/TypingIndicator/TypingIndicator.js +1 -0
  75. package/lib/commonjs/components/TypingIndicator/index.js +1 -0
  76. package/lib/commonjs/components/WheelPicker/Wheel.js +1 -0
  77. package/lib/commonjs/components/WheelPicker/WheelPicker.js +1 -0
  78. package/lib/commonjs/components/WheelPicker/index.js +1 -0
  79. package/lib/commonjs/components/index.js +1 -1
  80. package/lib/commonjs/hooks/index.js +1 -1
  81. package/lib/commonjs/hooks/useRefreshControl.js +1 -0
  82. package/lib/commonjs/hooks/useScrollDirection.js +1 -0
  83. package/lib/commonjs/index.js +1 -1
  84. package/lib/commonjs/utils/announce.js +1 -0
  85. package/lib/commonjs/utils/hapticUtils.js +1 -1
  86. package/lib/commonjs/utils/index.js +1 -1
  87. package/lib/commonjs/utils/placement.js +1 -0
  88. package/lib/module/components/BarChart/BarChart.js +1 -0
  89. package/lib/module/components/BarChart/index.js +1 -0
  90. package/lib/module/components/BarChart/scale.js +1 -0
  91. package/lib/module/components/BottomNavigation/BottomNavigation.js +1 -1
  92. package/lib/module/components/BottomNavigation/useScreenReaderEnabled.js +1 -0
  93. package/lib/module/components/BottomSheet/BottomSheet.js +1 -1
  94. package/lib/module/components/BottomSheet/index.js +1 -1
  95. package/lib/module/components/BottomSheet/useSheetSwap.js +1 -0
  96. package/lib/module/components/Card/Card.js +1 -1
  97. package/lib/module/components/Checkbox/Checkbox.js +1 -1
  98. package/lib/module/components/Composer/Composer.js +1 -0
  99. package/lib/module/components/Composer/index.js +1 -0
  100. package/lib/module/components/DateSeparator/DateSeparator.js +1 -0
  101. package/lib/module/components/DateSeparator/index.js +1 -0
  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/FloatingActionButton/FloatingActionButton.js +1 -1
  106. package/lib/module/components/FormField/FormField.js +1 -1
  107. package/lib/module/components/Input/Input.js +1 -1
  108. package/lib/module/components/ListItem/ListItem.js +1 -1
  109. package/lib/module/components/Menu/Menu.js +1 -0
  110. package/lib/module/components/Menu/MenuSurface.js +1 -0
  111. package/lib/module/components/Menu/focusHost.js +1 -0
  112. package/lib/module/components/Menu/index.js +1 -0
  113. package/lib/module/components/Menu/menuModel.js +1 -0
  114. package/lib/module/components/Menu/useContextMenu.js +1 -0
  115. package/lib/module/components/Menu/webOnly.js +1 -0
  116. package/lib/module/components/MessageBubble/MessageBubble.js +1 -0
  117. package/lib/module/components/MessageBubble/index.js +1 -0
  118. package/lib/module/components/MessageList/MessageList.js +1 -0
  119. package/lib/module/components/MessageList/index.js +1 -0
  120. package/lib/module/components/Notation/Notation.js +1 -1
  121. package/lib/module/components/OnboardingPager/OnboardingPager.js +1 -0
  122. package/lib/module/components/OnboardingPager/index.js +1 -0
  123. package/lib/module/components/OptionSheet/OptionSheet.js +1 -1
  124. package/lib/module/components/PaymentResult/PaymentResult.js +1 -0
  125. package/lib/module/components/PaymentResult/index.js +1 -0
  126. package/lib/module/components/PermissionPrompt/PermissionPrompt.js +1 -0
  127. package/lib/module/components/PermissionPrompt/index.js +1 -0
  128. package/lib/module/components/PermissionPrompt/usePermissionPrompt.js +1 -0
  129. package/lib/module/components/PhoneNumberInput/PhoneNumberInput.js +1 -1
  130. package/lib/module/components/Radio/Radio.js +1 -1
  131. package/lib/module/components/Radio/RadioGroup.js +1 -1
  132. package/lib/module/components/ScannerOverlay/ScannerOverlay.js +1 -0
  133. package/lib/module/components/ScannerOverlay/index.js +1 -0
  134. package/lib/module/components/SearchBar/SearchBar.js +1 -1
  135. package/lib/module/components/SearchBar/SearchPanel.js +1 -0
  136. package/lib/module/components/SearchBar/highlight.js +1 -0
  137. package/lib/module/components/SearchBar/index.js +1 -1
  138. package/lib/module/components/SearchBar/useRecentSearches.js +1 -0
  139. package/lib/module/components/SegmentedControl/SegmentedControl.js +1 -1
  140. package/lib/module/components/Select/Select.js +1 -1
  141. package/lib/module/components/SignaturePad/SignaturePad.js +1 -0
  142. package/lib/module/components/SignaturePad/index.js +1 -0
  143. package/lib/module/components/SignaturePad/signatureGeometry.js +1 -0
  144. package/lib/module/components/SignaturePad/writePng.js +1 -0
  145. package/lib/module/components/SignaturePad/writePng.web.js +1 -0
  146. package/lib/module/components/Sparkline/Sparkline.js +1 -0
  147. package/lib/module/components/Sparkline/geometry.js +1 -0
  148. package/lib/module/components/Sparkline/index.js +1 -0
  149. package/lib/module/components/Spinner/Spinner.js +1 -1
  150. package/lib/module/components/StatTile/StatTile.js +1 -1
  151. package/lib/module/components/Switch/Switch.js +1 -1
  152. package/lib/module/components/TagInput/TagInput.js +1 -1
  153. package/lib/module/components/TimePicker/TimePicker.js +1 -1
  154. package/lib/module/components/Toast/Toast.js +1 -1
  155. package/lib/module/components/Toast/ToastProvider.js +1 -1
  156. package/lib/module/components/Tooltip/RichTooltipBody.js +1 -0
  157. package/lib/module/components/Tooltip/Tooltip.js +1 -1
  158. package/lib/module/components/Tooltip/tooltipPosition.js +1 -0
  159. package/lib/module/components/TypingIndicator/TypingIndicator.js +1 -0
  160. package/lib/module/components/TypingIndicator/index.js +1 -0
  161. package/lib/module/components/WheelPicker/Wheel.js +1 -0
  162. package/lib/module/components/WheelPicker/WheelPicker.js +1 -0
  163. package/lib/module/components/WheelPicker/index.js +1 -0
  164. package/lib/module/components/index.js +1 -1
  165. package/lib/module/hooks/index.js +1 -1
  166. package/lib/module/hooks/useRefreshControl.js +1 -0
  167. package/lib/module/hooks/useScrollDirection.js +1 -0
  168. package/lib/module/index.js +1 -1
  169. package/lib/module/utils/announce.js +1 -0
  170. package/lib/module/utils/hapticUtils.js +1 -1
  171. package/lib/module/utils/index.js +1 -1
  172. package/lib/module/utils/placement.js +1 -0
  173. package/lib/typescript/commonjs/components/BarChart/BarChart.d.ts +62 -0
  174. package/lib/typescript/commonjs/components/BarChart/index.d.ts +3 -0
  175. package/lib/typescript/commonjs/components/BarChart/scale.d.ts +15 -0
  176. package/lib/typescript/commonjs/components/BottomNavigation/BottomNavigation.d.ts +32 -0
  177. package/lib/typescript/commonjs/components/BottomNavigation/index.d.ts +1 -1
  178. package/lib/typescript/commonjs/components/BottomNavigation/useScreenReaderEnabled.d.ts +8 -0
  179. package/lib/typescript/commonjs/components/BottomSheet/BottomSheet.d.ts +34 -3
  180. package/lib/typescript/commonjs/components/BottomSheet/index.d.ts +2 -0
  181. package/lib/typescript/commonjs/components/BottomSheet/useSheetSwap.d.ts +24 -0
  182. package/lib/typescript/commonjs/components/Card/Card.d.ts +9 -0
  183. package/lib/typescript/commonjs/components/Checkbox/Checkbox.d.ts +4 -1
  184. package/lib/typescript/commonjs/components/Composer/Composer.d.ts +61 -0
  185. package/lib/typescript/commonjs/components/Composer/index.d.ts +3 -0
  186. package/lib/typescript/commonjs/components/DateSeparator/DateSeparator.d.ts +37 -0
  187. package/lib/typescript/commonjs/components/DateSeparator/index.d.ts +3 -0
  188. package/lib/typescript/commonjs/components/FileViewer/FileViewer.d.ts +1 -1
  189. package/lib/typescript/commonjs/components/FloatingActionButton/FloatingActionButton.d.ts +3 -1
  190. package/lib/typescript/commonjs/components/Input/Input.d.ts +2 -2
  191. package/lib/typescript/commonjs/components/ListItem/ListItem.d.ts +9 -0
  192. package/lib/typescript/commonjs/components/Menu/Menu.d.ts +46 -0
  193. package/lib/typescript/commonjs/components/Menu/MenuSurface.d.ts +30 -0
  194. package/lib/typescript/commonjs/components/Menu/focusHost.d.ts +9 -0
  195. package/lib/typescript/commonjs/components/Menu/index.d.ts +5 -0
  196. package/lib/typescript/commonjs/components/Menu/menuModel.d.ts +68 -0
  197. package/lib/typescript/commonjs/components/Menu/useContextMenu.d.ts +58 -0
  198. package/lib/typescript/commonjs/components/Menu/webOnly.d.ts +7 -0
  199. package/lib/typescript/commonjs/components/MessageBubble/MessageBubble.d.ts +87 -0
  200. package/lib/typescript/commonjs/components/MessageBubble/index.d.ts +3 -0
  201. package/lib/typescript/commonjs/components/MessageList/MessageList.d.ts +68 -0
  202. package/lib/typescript/commonjs/components/MessageList/index.d.ts +3 -0
  203. package/lib/typescript/commonjs/components/Notation/Notation.d.ts +10 -4
  204. package/lib/typescript/commonjs/components/OnboardingPager/OnboardingPager.d.ts +53 -0
  205. package/lib/typescript/commonjs/components/OnboardingPager/index.d.ts +3 -0
  206. package/lib/typescript/commonjs/components/OptionSheet/OptionSheet.d.ts +2 -0
  207. package/lib/typescript/commonjs/components/PaymentResult/PaymentResult.d.ts +71 -0
  208. package/lib/typescript/commonjs/components/PaymentResult/index.d.ts +3 -0
  209. package/lib/typescript/commonjs/components/PermissionPrompt/PermissionPrompt.d.ts +39 -0
  210. package/lib/typescript/commonjs/components/PermissionPrompt/index.d.ts +5 -0
  211. package/lib/typescript/commonjs/components/PermissionPrompt/usePermissionPrompt.d.ts +44 -0
  212. package/lib/typescript/commonjs/components/PhoneNumberInput/PhoneNumberInput.d.ts +5 -2
  213. package/lib/typescript/commonjs/components/Radio/Radio.d.ts +13 -4
  214. package/lib/typescript/commonjs/components/Radio/RadioGroup.d.ts +5 -0
  215. package/lib/typescript/commonjs/components/ScannerOverlay/ScannerOverlay.d.ts +74 -0
  216. package/lib/typescript/commonjs/components/ScannerOverlay/index.d.ts +3 -0
  217. package/lib/typescript/commonjs/components/SearchBar/SearchBar.d.ts +35 -0
  218. package/lib/typescript/commonjs/components/SearchBar/SearchPanel.d.ts +49 -0
  219. package/lib/typescript/commonjs/components/SearchBar/highlight.d.ts +14 -0
  220. package/lib/typescript/commonjs/components/SearchBar/index.d.ts +3 -0
  221. package/lib/typescript/commonjs/components/SearchBar/useRecentSearches.d.ts +24 -0
  222. package/lib/typescript/commonjs/components/SegmentedControl/SegmentedControl.d.ts +5 -1
  223. package/lib/typescript/commonjs/components/Select/Select.d.ts +4 -1
  224. package/lib/typescript/commonjs/components/SignaturePad/SignaturePad.d.ts +94 -0
  225. package/lib/typescript/commonjs/components/SignaturePad/index.d.ts +4 -0
  226. package/lib/typescript/commonjs/components/SignaturePad/signatureGeometry.d.ts +36 -0
  227. package/lib/typescript/commonjs/components/SignaturePad/writePng.d.ts +7 -0
  228. package/lib/typescript/commonjs/components/SignaturePad/writePng.web.d.ts +3 -0
  229. package/lib/typescript/commonjs/components/Sparkline/Sparkline.d.ts +41 -0
  230. package/lib/typescript/commonjs/components/Sparkline/geometry.d.ts +20 -0
  231. package/lib/typescript/commonjs/components/Sparkline/index.d.ts +3 -0
  232. package/lib/typescript/commonjs/components/Spinner/Spinner.d.ts +7 -1
  233. package/lib/typescript/commonjs/components/StatTile/StatTile.d.ts +24 -1
  234. package/lib/typescript/commonjs/components/StatTile/index.d.ts +1 -1
  235. package/lib/typescript/commonjs/components/Switch/Switch.d.ts +11 -4
  236. package/lib/typescript/commonjs/components/TagInput/TagInput.d.ts +4 -0
  237. package/lib/typescript/commonjs/components/Toast/Toast.d.ts +21 -0
  238. package/lib/typescript/commonjs/components/Toast/ToastProvider.d.ts +21 -0
  239. package/lib/typescript/commonjs/components/Toast/index.d.ts +1 -1
  240. package/lib/typescript/commonjs/components/Tooltip/RichTooltipBody.d.ts +27 -0
  241. package/lib/typescript/commonjs/components/Tooltip/Tooltip.d.ts +24 -0
  242. package/lib/typescript/commonjs/components/Tooltip/index.d.ts +1 -1
  243. package/lib/typescript/commonjs/components/Tooltip/tooltipPosition.d.ts +35 -0
  244. package/lib/typescript/commonjs/components/TypingIndicator/TypingIndicator.d.ts +21 -0
  245. package/lib/typescript/commonjs/components/TypingIndicator/index.d.ts +3 -0
  246. package/lib/typescript/commonjs/components/WheelPicker/Wheel.d.ts +34 -0
  247. package/lib/typescript/commonjs/components/WheelPicker/WheelPicker.d.ts +73 -0
  248. package/lib/typescript/commonjs/components/WheelPicker/index.d.ts +3 -0
  249. package/lib/typescript/commonjs/components/index.d.ts +36 -8
  250. package/lib/typescript/commonjs/hooks/index.d.ts +4 -0
  251. package/lib/typescript/commonjs/hooks/useRefreshControl.d.ts +75 -0
  252. package/lib/typescript/commonjs/hooks/useScrollDirection.d.ts +21 -0
  253. package/lib/typescript/commonjs/index.d.ts +4 -4
  254. package/lib/typescript/commonjs/specs/NativePdfRasterizer.d.ts +1 -1
  255. package/lib/typescript/commonjs/utils/announce.d.ts +14 -0
  256. package/lib/typescript/commonjs/utils/hapticUtils.d.ts +1 -1
  257. package/lib/typescript/commonjs/utils/index.d.ts +2 -0
  258. package/lib/typescript/commonjs/utils/placement.d.ts +55 -0
  259. package/lib/typescript/module/components/BarChart/BarChart.d.ts +62 -0
  260. package/lib/typescript/module/components/BarChart/index.d.ts +3 -0
  261. package/lib/typescript/module/components/BarChart/scale.d.ts +15 -0
  262. package/lib/typescript/module/components/BottomNavigation/BottomNavigation.d.ts +32 -0
  263. package/lib/typescript/module/components/BottomNavigation/index.d.ts +1 -1
  264. package/lib/typescript/module/components/BottomNavigation/useScreenReaderEnabled.d.ts +8 -0
  265. package/lib/typescript/module/components/BottomSheet/BottomSheet.d.ts +34 -3
  266. package/lib/typescript/module/components/BottomSheet/index.d.ts +2 -0
  267. package/lib/typescript/module/components/BottomSheet/useSheetSwap.d.ts +24 -0
  268. package/lib/typescript/module/components/Card/Card.d.ts +9 -0
  269. package/lib/typescript/module/components/Checkbox/Checkbox.d.ts +4 -1
  270. package/lib/typescript/module/components/Composer/Composer.d.ts +61 -0
  271. package/lib/typescript/module/components/Composer/index.d.ts +3 -0
  272. package/lib/typescript/module/components/DateSeparator/DateSeparator.d.ts +37 -0
  273. package/lib/typescript/module/components/DateSeparator/index.d.ts +3 -0
  274. package/lib/typescript/module/components/FileViewer/FileViewer.d.ts +1 -1
  275. package/lib/typescript/module/components/FloatingActionButton/FloatingActionButton.d.ts +3 -1
  276. package/lib/typescript/module/components/Input/Input.d.ts +2 -2
  277. package/lib/typescript/module/components/ListItem/ListItem.d.ts +9 -0
  278. package/lib/typescript/module/components/Menu/Menu.d.ts +46 -0
  279. package/lib/typescript/module/components/Menu/MenuSurface.d.ts +30 -0
  280. package/lib/typescript/module/components/Menu/focusHost.d.ts +9 -0
  281. package/lib/typescript/module/components/Menu/index.d.ts +5 -0
  282. package/lib/typescript/module/components/Menu/menuModel.d.ts +68 -0
  283. package/lib/typescript/module/components/Menu/useContextMenu.d.ts +58 -0
  284. package/lib/typescript/module/components/Menu/webOnly.d.ts +7 -0
  285. package/lib/typescript/module/components/MessageBubble/MessageBubble.d.ts +87 -0
  286. package/lib/typescript/module/components/MessageBubble/index.d.ts +3 -0
  287. package/lib/typescript/module/components/MessageList/MessageList.d.ts +68 -0
  288. package/lib/typescript/module/components/MessageList/index.d.ts +3 -0
  289. package/lib/typescript/module/components/Notation/Notation.d.ts +10 -4
  290. package/lib/typescript/module/components/OnboardingPager/OnboardingPager.d.ts +53 -0
  291. package/lib/typescript/module/components/OnboardingPager/index.d.ts +3 -0
  292. package/lib/typescript/module/components/OptionSheet/OptionSheet.d.ts +2 -0
  293. package/lib/typescript/module/components/PaymentResult/PaymentResult.d.ts +71 -0
  294. package/lib/typescript/module/components/PaymentResult/index.d.ts +3 -0
  295. package/lib/typescript/module/components/PermissionPrompt/PermissionPrompt.d.ts +39 -0
  296. package/lib/typescript/module/components/PermissionPrompt/index.d.ts +5 -0
  297. package/lib/typescript/module/components/PermissionPrompt/usePermissionPrompt.d.ts +44 -0
  298. package/lib/typescript/module/components/PhoneNumberInput/PhoneNumberInput.d.ts +5 -2
  299. package/lib/typescript/module/components/Radio/Radio.d.ts +13 -4
  300. package/lib/typescript/module/components/Radio/RadioGroup.d.ts +5 -0
  301. package/lib/typescript/module/components/ScannerOverlay/ScannerOverlay.d.ts +74 -0
  302. package/lib/typescript/module/components/ScannerOverlay/index.d.ts +3 -0
  303. package/lib/typescript/module/components/SearchBar/SearchBar.d.ts +35 -0
  304. package/lib/typescript/module/components/SearchBar/SearchPanel.d.ts +49 -0
  305. package/lib/typescript/module/components/SearchBar/highlight.d.ts +14 -0
  306. package/lib/typescript/module/components/SearchBar/index.d.ts +3 -0
  307. package/lib/typescript/module/components/SearchBar/useRecentSearches.d.ts +24 -0
  308. package/lib/typescript/module/components/SegmentedControl/SegmentedControl.d.ts +5 -1
  309. package/lib/typescript/module/components/Select/Select.d.ts +4 -1
  310. package/lib/typescript/module/components/SignaturePad/SignaturePad.d.ts +94 -0
  311. package/lib/typescript/module/components/SignaturePad/index.d.ts +4 -0
  312. package/lib/typescript/module/components/SignaturePad/signatureGeometry.d.ts +36 -0
  313. package/lib/typescript/module/components/SignaturePad/writePng.d.ts +7 -0
  314. package/lib/typescript/module/components/SignaturePad/writePng.web.d.ts +3 -0
  315. package/lib/typescript/module/components/Sparkline/Sparkline.d.ts +41 -0
  316. package/lib/typescript/module/components/Sparkline/geometry.d.ts +20 -0
  317. package/lib/typescript/module/components/Sparkline/index.d.ts +3 -0
  318. package/lib/typescript/module/components/Spinner/Spinner.d.ts +7 -1
  319. package/lib/typescript/module/components/StatTile/StatTile.d.ts +24 -1
  320. package/lib/typescript/module/components/StatTile/index.d.ts +1 -1
  321. package/lib/typescript/module/components/Switch/Switch.d.ts +11 -4
  322. package/lib/typescript/module/components/TagInput/TagInput.d.ts +4 -0
  323. package/lib/typescript/module/components/Toast/Toast.d.ts +21 -0
  324. package/lib/typescript/module/components/Toast/ToastProvider.d.ts +21 -0
  325. package/lib/typescript/module/components/Toast/index.d.ts +1 -1
  326. package/lib/typescript/module/components/Tooltip/RichTooltipBody.d.ts +27 -0
  327. package/lib/typescript/module/components/Tooltip/Tooltip.d.ts +24 -0
  328. package/lib/typescript/module/components/Tooltip/index.d.ts +1 -1
  329. package/lib/typescript/module/components/Tooltip/tooltipPosition.d.ts +35 -0
  330. package/lib/typescript/module/components/TypingIndicator/TypingIndicator.d.ts +21 -0
  331. package/lib/typescript/module/components/TypingIndicator/index.d.ts +3 -0
  332. package/lib/typescript/module/components/WheelPicker/Wheel.d.ts +34 -0
  333. package/lib/typescript/module/components/WheelPicker/WheelPicker.d.ts +73 -0
  334. package/lib/typescript/module/components/WheelPicker/index.d.ts +3 -0
  335. package/lib/typescript/module/components/index.d.ts +36 -8
  336. package/lib/typescript/module/hooks/index.d.ts +4 -0
  337. package/lib/typescript/module/hooks/useRefreshControl.d.ts +75 -0
  338. package/lib/typescript/module/hooks/useScrollDirection.d.ts +21 -0
  339. package/lib/typescript/module/index.d.ts +4 -4
  340. package/lib/typescript/module/specs/NativePdfRasterizer.d.ts +1 -1
  341. package/lib/typescript/module/utils/announce.d.ts +14 -0
  342. package/lib/typescript/module/utils/hapticUtils.d.ts +1 -1
  343. package/lib/typescript/module/utils/index.d.ts +2 -0
  344. package/lib/typescript/module/utils/placement.d.ts +55 -0
  345. package/package.json +3 -3
  346. package/src/specs/NativePdfRasterizer.ts +1 -1
@@ -1 +1 @@
1
- "use strict";import{countryFlagEmoji,formatPhoneAsTyped,getPhoneCountries,isSupportedCountry,isValidNationalNumber,maxNationalNumberLength,splitPhoneNumber}from"@webority/mobile-core";import{PHONE_COUNTRY_NAMES}from"@webority/mobile-core/phone/countries";import{forwardRef,useCallback,useEffect,useImperativeHandle,useMemo,useRef,useState}from"react";import{Pressable,StyleSheet,Text,TextInput,View}from"react-native";import{useControllableState}from"../../hooks/index.js";import{fontFor,useTheme}from"../../theme/index.js";import{resolveHaptic,triggerHaptic}from"../../utils/index.js";import{FieldBase,FieldLabel,FieldMessage,hasFieldText,RequiredPlaceholder,resolveFieldSize,resolveFieldTextStyle}from"../FieldBase/index.js";import{Chevron}from"../FieldBase/Chevron.js";import{useFloatingLabel}from"../FieldBase/useFloatingLabel.js";import{OptionSheet}from"../OptionSheet/OptionSheet.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_CALLING_CODES=[{iso:"IN",code:"91",label:"India"},{iso:"AE",code:"971",label:"United Arab Emirates"},{iso:"GB",code:"44",label:"United Kingdom"},{iso:"US",code:"1",label:"United States"},{iso:"CA",code:"1",label:"Canada"},{iso:"AU",code:"61",label:"Australia"},{iso:"SG",code:"65",label:"Singapore"},{iso:"SA",code:"966",label:"Saudi Arabia"}];export const ALL_CALLING_CODES=getPhoneCountries().map(e=>({iso:e.iso,code:e.callingCode,label:PHONE_COUNTRY_NAMES[e.iso]??e.iso})).sort((e,t)=>e.label.localeCompare(t.label));const digitsOnly=e=>e.replace(/[^0-9]/g,"");export const formatE164=e=>`+${e.callingCode}${e.nationalNumber}`;export const parseE164=(e,t,o)=>{const i=e.replace(/[^0-9]/g,"");if(!i)return null;const n=splitPhoneNumber(`+${i}`);let l=n?.callingCode,r=n?.nationalNumber??"";if(!l){const e=Array.from(new Set(t.map(e=>e.code))).sort((e,t)=>t.length-e.length);if(l=e.find(e=>i.startsWith(e)),!l)return null;r=i.slice(l.length)}const a=t.filter(e=>e.code===l),s=a.find(e=>e.iso===o)?.iso??a.find(e=>e.iso===n?.country)?.iso??n?.country??a[0]?.iso??"";return{callingCode:l,nationalNumber:r,iso:s}};const planOf=e=>isSupportedCountry(e)?e:null;export const PhoneNumberInput=forwardRef((e,t)=>{const{value:o,defaultValue:i,onChange:n,e164:l,onChangeE164:r,returnKeyType:a,submitBehavior:s,onSubmitEditing:u,blurOnSubmit:d,onComplete:c,onValidityChange:b,countries:m=ALL_CALLING_CODES,popularCountries:p,popularCountriesTitle:f="Popular",allCountriesTitle:g="All countries",hiddenCountries:h,showFlag:y=!0,renderFlag:N,renderCountry:C,countrySearchPlaceholder:S,showAlphabetIndex:x,defaultIso:v="IN",validation:F="any",maxLength:T,formatAsYouType:I=!0,countryLocked:E=!1,label:L,labelMode:O="top",labelStyle:P,placeholder:j="Phone number",helperText:_,error:A,invalidMessage:w,required:z,disabled:R=!1,size:k="md",variant:M,borderRadius:V,countrySheetTitle:D="Country code",haptic:B,accessibilityLabel:$,countryAccessibilityLabel:H,onFocus:U,onBlur:W,style:q,testID:G}=e,Y=useTheme(),K=useMemo(()=>buildStyles(Y),[Y]),J=useRef(null),Q=useMemo(()=>h?.length?m.filter(e=>!h.includes(e.iso)):m,[m,h]),X=useMemo(()=>{if(!p?.length)return;const e=p.map(e=>Q.find(t=>t.iso===e)).filter(e=>void 0!==e);return e.length?[{title:f,options:e},{title:g,options:Q}]:void 0},[p,f,g,Q]),Z=useCallback((e,t,o)=>{if(!e)return null;if(N)return N(e);if(!y)return null;const i=countryFlagEmoji(e.iso);return i?_jsx(Text,{style:[K.flag,{fontSize:t}],testID:o,children:i}):null},[N,y,K.flag]),ee=useCallback(e=>{const t=planOf(e),o=t?maxNationalNumberLength(t,!1===F?"any":F):Number.POSITIVE_INFINITY;return T?Math.min(o,T):o},[T,F]),te=useCallback((e,t)=>e.slice(0,ee(t)),[ee]),oe=useCallback((e,t)=>{const o=planOf(t)??void 0,i=splitPhoneNumber(e,o);if(!i)return null;const n=i.country??t,l=m.find(e=>e.iso===n);return{callingCode:l?.code??i.callingCode,nationalNumber:te(i.nationalNumber,n),iso:l?.iso??n}},[m,te]),ie=useMemo(()=>{const e=Q.find(e=>e.iso===v)??Q[0]??m[0],t={callingCode:e?.code??"91",nationalNumber:"",iso:e?.iso??"IN"};return"string"==typeof i?oe(i,t.iso)??t:i??t},[m,Q,v,i,oe]),ne=useCallback(e=>{if(!1===F)return e.nationalNumber.length>0;const t=planOf(e.iso);return t?isValidNationalNumber(e.nationalNumber,t,F):e.nationalNumber.length>0},[F]),[le,re]=useState(ie.iso),ae=useMemo(()=>{if(void 0===l)return;const e=l?parseE164(l,m,le):null;if(e)return{...e,nationalNumber:te(e.nationalNumber,e.iso)};const t=m.find(e=>e.iso===le);return{callingCode:t?.code??ie.callingCode,nationalNumber:"",iso:le}},[l,m,le,ie.callingCode,te]),se=useCallback(e=>{re(e.iso),n?.(e),r?.(e.nationalNumber?formatE164(e):"",{country:m.find(t=>t.iso===e.iso),national:e.nationalNumber,valid:ne(e)})},[n,r,m,ne]),[ue,de]=useControllableState({value:o??ae,defaultValue:ie,onChange:se}),[ce,be]=useState(!1),me=useCallback(()=>{R||J.current?.focus()},[R]),[pe,fe]=useState(!1),[ge,he]=useState(!1),[ye,Ne]=useState(!1),Ce=useRef(!1);useEffect(()=>{ye||(Ce.current=!1)},[ye]);const Se=resolveFieldSize(Y,k),xe=resolveFieldTextStyle(Y,{disabled:R}),ve=M??Y.components.field?.defaultVariant??"outlined",Fe="underline"===ve,Te=V??Y.components.phoneNumberInput?.borderRadius,Ie=Y.spacing.md,[Ee,Le]=useState(0),Oe=Ee+Ie+1+Ie,Pe=ue.nationalNumber.length>0,je=z&&!L&&!Pe&&j.length>0,_e=ce||Pe,Ae=Boolean(L)&&"float"===O&&Ee>0,we=useFloatingLabel({label:L,enabled:Ae,floated:_e,required:z,variant:ve,sizeTokens:Se,leadingOffset:Oe,paddingLeft:Fe?0:Se.paddingHorizontal,color:Y.colors.field.label,style:P}),ze=useMemo(()=>m.find(e=>e.iso===ue.iso),[m,ue.iso]),Re=planOf(ue.iso),ke=I&&Re?formatPhoneAsTyped(ue.nationalNumber,Re):ue.nationalNumber,Me=ee(ue.iso),Ve=0===ue.nationalNumber.length||pe||!Number.isFinite(Me)?void 0:ke.length+Math.max(0,Me-ue.nationalNumber.length),De=ne(ue);useEffect(()=>{Pe||he(!1)},[Pe]);const Be=Re?maxNationalNumberLength(Re,!1===F?"any":F):Number.POSITIVE_INFINITY,$e=ue.nationalNumber.length>=Be,He=A??(!1!==F&&!1!==w&&Pe&&!De&&(ge||$e)?w||("mobile"===F?"Enter a valid mobile number":"Enter a valid number"):void 0),Ue=useRef(De),We=useRef(ue);We.current=ue,useEffect(()=>{Ue.current!==De&&(Ue.current=De,b?.(De),De&&c?.(formatE164(We.current)))},[De,c,b]);const qe=useCallback(e=>{if(e.includes("+")){const t=oe(e,ue.iso);if(t&&!E&&Q.some(e=>e.iso===t.iso))return void de(t);if(t&&t.iso===ue.iso)return void de(t)}de({...ue,nationalNumber:te(digitsOnly(e),ue.iso)})},[Q,E,ue,oe,te,de]),Ge=useCallback(e=>{const t=e;de({callingCode:t.code,iso:t.iso,nationalNumber:te(ue.nationalNumber,t.iso)}),Ne(!1);const o=resolveHaptic(B,"selection");o&&triggerHaptic(o)},[ue,B,te,de]);useImperativeHandle(t,()=>({focus:()=>J.current?.focus(),blur:()=>J.current?.blur(),clear:()=>de({...We.current,nationalNumber:""}),isFocused:()=>J.current?.isFocused()??!1,getValue:()=>We.current,getE164:()=>formatE164(We.current),getFormatted:()=>{const e=We.current,t=planOf(e.iso);return t?formatPhoneAsTyped(e.nationalNumber,t):e.nationalNumber},isValid:()=>ne(We.current),getCountry:()=>m.find(e=>e.iso===We.current.iso)}),[m,ne,de]);const Ye=R||E,Ke=_jsx(FieldBase,{size:k,variant:ve,borderRadius:Te,topNotch:we.topNotch,focused:ce,disabled:R,error:hasFieldText(He),filled:Pe,onPress:me,pressFeedback:!1,leadingDivider:!0,paddingLeft:Fe?0:void 0,leading:_jsxs(Pressable,{onPress:()=>{Ye||(Ce.current=!0,Ne(!0))},disabled:Ye,accessibilityRole:"button",accessibilityLabel:H??`Country code, currently +${ue.callingCode}`,accessibilityState:{disabled:Ye},"aria-disabled":Ye,hitSlop:6,onLayout:e=>{const{width:t}=e.nativeEvent.layout;Le(e=>e===t?e:t)},style:K.codeTrigger,testID:G?`${G}-code`:void 0,children:[Z(ze,Se.fontSize,G?`${G}-flag`:void 0),_jsx(Text,{style:[K.codeText,{color:xe.color,fontSize:Se.fontSize}],children:`+${ue.callingCode}`}),E?null:_jsx(Chevron,{color:R?Y.colors.field.iconDisabled:Y.colors.field.icon,size:Se.iconSize,open:ye})]}),children:_jsxs(View,{style:K.inputWrap,children:[_jsx(TextInput,{ref:J,value:ke,maxLength:Ve,onChangeText:qe,returnKeyType:a,submitBehavior:s,onSubmitEditing:u,blurOnSubmit:d,onSelectionChange:e=>{const{start:t,end:o}=e.nativeEvent.selection;fe(t!==o)},onFocus:()=>{be(!0),U?.()},onBlur:()=>{be(!1),Pe&&!Ce.current&&he(!0),W?.()},editable:!R,placeholder:Ae&&!_e||je?void 0:j,placeholderTextColor:xe.placeholderColor,accessibilityLabel:$??L??j,selectionColor:Y.colors.field.caret,keyboardType:"phone-pad",textContentType:"telephoneNumber",autoComplete:"tel",style:[K.input,{color:xe.color,fontSize:Se.fontSize,...xe.weightStyle,paddingLeft:Fe?0:void 0}],testID:G?`${G}-input`:void 0}),je?_jsx(RequiredPlaceholder,{text:j,color:xe.placeholderColor,fontSize:Se.fontSize,weightStyle:xe.weightStyle}):null]})});return _jsxs(View,{style:q,testID:G,children:[L&&"top"===O?_jsx(FieldLabel,{size:k,required:z,children:L}):null,_jsxs(View,{style:K.fieldWrapper,children:[Ke,we.node]}),_jsx(FieldMessage,{size:k,error:hasFieldText(He),text:He??_}),_jsx(OptionSheet,{open:ye,onClose:()=>Ne(!1),title:D,options:Q,sections:X,labelOf:e=>`${e.label} (+${e.code})`,getValue:e=>e.iso,disabledOf:()=>!1,descriptionOf:()=>{},iconOf:e=>Z(e,Y.typography.fontSize.lg),renderOption:C?(e,t)=>C(e,{selected:t.selected}):void 0,isSelected:e=>e===ze?.iso,onSelect:Ge,searchable:Q.length>8,searchPlaceholder:S,alphabetIndex:x??Q.length>20})]})});PhoneNumberInput.displayName="PhoneNumberInput";const buildStyles=e=>StyleSheet.create({fieldWrapper:{position:"relative",overflow:"visible"},codeTrigger:{flexDirection:"row",alignItems:"center",gap:2},flag:{includeFontPadding:!1,marginRight:4},codeText:{...fontFor(e,"semibold"),fontWeight:"600",includeFontPadding:!1,writingDirection:"ltr"},input:{padding:0,margin:0,includeFontPadding:!1,writingDirection:"ltr"},inputWrap:{flex:1,alignSelf:"stretch",justifyContent:"center"}});export default PhoneNumberInput;
1
+ "use strict";import{countryFlagEmoji,formatPhoneAsTyped,getPhoneCountries,isSupportedCountry,isValidNationalNumber,maxNationalNumberLength,splitPhoneNumber}from"@webority/mobile-core";import{PHONE_COUNTRY_NAMES}from"@webority/mobile-core/phone/countries";import{forwardRef,useCallback,useEffect,useImperativeHandle,useMemo,useRef,useState}from"react";import{Pressable,StyleSheet,Text,TextInput,View}from"react-native";import{useControllableState}from"../../hooks/index.js";import{fontFor,useTheme}from"../../theme/index.js";import{resolveHaptic,triggerHaptic}from"../../utils/index.js";import{FieldBase,FieldLabel,FieldMessage,hasFieldText,RequiredPlaceholder,resolveFieldSize,resolveFieldTextStyle}from"../FieldBase/index.js";import{Chevron}from"../FieldBase/Chevron.js";import{useFloatingLabel}from"../FieldBase/useFloatingLabel.js";import{OptionSheet}from"../OptionSheet/OptionSheet.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const DEFAULT_CALLING_CODES=[{iso:"IN",code:"91",label:"India"},{iso:"AE",code:"971",label:"United Arab Emirates"},{iso:"GB",code:"44",label:"United Kingdom"},{iso:"US",code:"1",label:"United States"},{iso:"CA",code:"1",label:"Canada"},{iso:"AU",code:"61",label:"Australia"},{iso:"SG",code:"65",label:"Singapore"},{iso:"SA",code:"966",label:"Saudi Arabia"}];export const ALL_CALLING_CODES=getPhoneCountries().map(e=>({iso:e.iso,code:e.callingCode,label:PHONE_COUNTRY_NAMES[e.iso]??e.iso})).sort((e,t)=>e.label.localeCompare(t.label));const digitsOnly=e=>e.replace(/[^0-9]/g,"");export const formatE164=e=>`+${e.callingCode}${e.nationalNumber}`;export const parseE164=(e,t,o)=>{const i=e.replace(/[^0-9]/g,"");if(!i)return null;const n=splitPhoneNumber(`+${i}`);let l=n?.callingCode,r=n?.nationalNumber??"";if(!l){const e=Array.from(new Set(t.map(e=>e.code))).sort((e,t)=>t.length-e.length);if(l=e.find(e=>i.startsWith(e)),!l)return null;r=i.slice(l.length)}const a=t.filter(e=>e.code===l),s=a.find(e=>e.iso===o)?.iso??a.find(e=>e.iso===n?.country)?.iso??n?.country??a[0]?.iso??"";return{callingCode:l,nationalNumber:r,iso:s}};const planOf=e=>isSupportedCountry(e)?e:null;export const PhoneNumberInput=forwardRef((e,t)=>{const{value:o,defaultValue:i,onChange:n,e164:l,onChangeE164:r,returnKeyType:a,submitBehavior:s,onSubmitEditing:u,blurOnSubmit:d,onComplete:c,onValidityChange:b,countries:m=ALL_CALLING_CODES,popularCountries:p,popularCountriesTitle:f="Popular",allCountriesTitle:g="All countries",hiddenCountries:h,showFlag:y=!0,renderFlag:N,renderCountry:C,countrySearchPlaceholder:S,showAlphabetIndex:x,defaultIso:v="IN",validation:F="any",maxLength:T,formatAsYouType:I=!0,countryLocked:E=!1,label:L,labelMode:O="top",labelStyle:P,placeholder:j="Phone number",helperText:_,error:A,invalidMessage:w,required:z,disabled:R=!1,size:k="md",variant:M,borderRadius:V,countrySheetTitle:D="Country code",haptic:B,accessibilityLabel:$,countryAccessibilityLabel:H,onFocus:U,onBlur:W,style:q,testID:G}=e,Y=useTheme(),K=useMemo(()=>buildStyles(Y),[Y]),J=useRef(null),Q=useMemo(()=>h?.length?m.filter(e=>!h.includes(e.iso)):m,[m,h]),X=useMemo(()=>{if(!p?.length)return;const e=p.map(e=>Q.find(t=>t.iso===e)).filter(e=>void 0!==e);return e.length?[{title:f,options:e},{title:g,options:Q}]:void 0},[p,f,g,Q]),Z=useCallback((e,t,o)=>{if(!e)return null;if(N)return N(e);if(!y)return null;const i=countryFlagEmoji(e.iso);return i?_jsx(Text,{style:[K.flag,{fontSize:t}],testID:o,children:i}):null},[N,y,K.flag]),ee=useCallback(e=>{const t=planOf(e),o=t?maxNationalNumberLength(t,!1===F?"any":F):Number.POSITIVE_INFINITY;return T?Math.min(o,T):o},[T,F]),te=useCallback((e,t)=>e.slice(0,ee(t)),[ee]),oe=useCallback((e,t)=>{const o=planOf(t)??void 0,i=splitPhoneNumber(e,o);if(!i)return null;const n=i.country??t,l=m.find(e=>e.iso===n);return{callingCode:l?.code??i.callingCode,nationalNumber:te(i.nationalNumber,n),iso:l?.iso??n}},[m,te]),ie=useMemo(()=>{const e=Q.find(e=>e.iso===v)??Q[0]??m[0],t={callingCode:e?.code??"91",nationalNumber:"",iso:e?.iso??"IN"};return"string"==typeof i?oe(i,t.iso)??t:i??t},[m,Q,v,i,oe]),ne=useCallback(e=>{if(!1===F)return e.nationalNumber.length>0;const t=planOf(e.iso);return t?isValidNationalNumber(e.nationalNumber,t,F):e.nationalNumber.length>0},[F]),[le,re]=useState(ie.iso),ae=useMemo(()=>{if(void 0===l)return;const e=l?parseE164(l,m,le):null;if(e)return{...e,nationalNumber:te(e.nationalNumber,e.iso)};const t=m.find(e=>e.iso===le);return{callingCode:t?.code??ie.callingCode,nationalNumber:"",iso:le}},[l,m,le,ie.callingCode,te]),se=useCallback(e=>{re(e.iso),n?.(e),r?.(e.nationalNumber?formatE164(e):"",{country:m.find(t=>t.iso===e.iso),national:e.nationalNumber,valid:ne(e)})},[n,r,m,ne]),[ue,de]=useControllableState({value:o??ae,defaultValue:ie,onChange:se}),[ce,be]=useState(!1),me=useCallback(()=>{R||J.current?.focus()},[R]),[pe,fe]=useState(!1),[ge,he]=useState(!1),[ye,Ne]=useState(!1),Ce=useRef(!1);useEffect(()=>{ye||(Ce.current=!1)},[ye]);const Se=resolveFieldSize(Y,k),xe=resolveFieldTextStyle(Y,{disabled:R}),ve=M??Y.components.field?.defaultVariant??"outlined",Fe="underline"===ve,Te=V??Y.components.phoneNumberInput?.borderRadius,Ie=Y.spacing.md,[Ee,Le]=useState(0),Oe=Ee+Ie+1+Ie,Pe=ue.nationalNumber.length>0,je=z&&!L&&!Pe&&j.length>0,_e=ce||Pe,Ae=Boolean(L)&&"float"===O&&Ee>0,we=useFloatingLabel({label:L,enabled:Ae,floated:_e,required:z,variant:ve,sizeTokens:Se,leadingOffset:Oe,paddingLeft:Fe?0:Se.paddingHorizontal,color:Y.colors.field.label,style:P}),ze=useMemo(()=>m.find(e=>e.iso===ue.iso),[m,ue.iso]),Re=planOf(ue.iso),ke=I&&Re?formatPhoneAsTyped(ue.nationalNumber,Re):ue.nationalNumber,Me=ee(ue.iso),Ve=0===ue.nationalNumber.length||pe||!Number.isFinite(Me)?void 0:ke.length+Math.max(0,Me-ue.nationalNumber.length),De=ne(ue);useEffect(()=>{Pe||he(!1)},[Pe]);const Be=Re?maxNationalNumberLength(Re,!1===F?"any":F):Number.POSITIVE_INFINITY,$e=ue.nationalNumber.length>=Be,He=!1!==F&&!1!==w&&Pe&&!De&&(ge||$e),Ue="mobile"===F?"Enter a valid mobile number":"Enter a valid number",We=hasFieldText(A)?A:He?w||Ue:void 0,qe=!0===A||hasFieldText(We),Ge=useRef(De),Ye=useRef(ue);Ye.current=ue,useEffect(()=>{Ge.current!==De&&(Ge.current=De,b?.(De),De&&c?.(formatE164(Ye.current)))},[De,c,b]);const Ke=useCallback(e=>{if(e.includes("+")){const t=oe(e,ue.iso);if(t&&!E&&Q.some(e=>e.iso===t.iso))return void de(t);if(t&&t.iso===ue.iso)return void de(t)}de({...ue,nationalNumber:te(digitsOnly(e),ue.iso)})},[Q,E,ue,oe,te,de]),Je=useCallback(e=>{const t=e;de({callingCode:t.code,iso:t.iso,nationalNumber:te(ue.nationalNumber,t.iso)}),Ne(!1);const o=resolveHaptic(B,"selection");o&&triggerHaptic(o)},[ue,B,te,de]);useImperativeHandle(t,()=>({focus:()=>J.current?.focus(),blur:()=>J.current?.blur(),clear:()=>de({...Ye.current,nationalNumber:""}),isFocused:()=>J.current?.isFocused()??!1,getValue:()=>Ye.current,getE164:()=>formatE164(Ye.current),getFormatted:()=>{const e=Ye.current,t=planOf(e.iso);return t?formatPhoneAsTyped(e.nationalNumber,t):e.nationalNumber},isValid:()=>ne(Ye.current),getCountry:()=>m.find(e=>e.iso===Ye.current.iso)}),[m,ne,de]);const Qe=R||E,Xe=_jsx(FieldBase,{size:k,variant:ve,borderRadius:Te,topNotch:we.topNotch,focused:ce,disabled:R,error:qe,filled:Pe,onPress:me,pressFeedback:!1,leadingDivider:!0,paddingLeft:Fe?0:void 0,leading:_jsxs(Pressable,{onPress:()=>{Qe||(Ce.current=!0,Ne(!0))},disabled:Qe,accessibilityRole:"button",accessibilityLabel:H??`Country code, currently +${ue.callingCode}`,accessibilityState:{disabled:Qe},"aria-disabled":Qe,hitSlop:6,onLayout:e=>{const{width:t}=e.nativeEvent.layout;Le(e=>e===t?e:t)},style:K.codeTrigger,testID:G?`${G}-code`:void 0,children:[Z(ze,Se.fontSize,G?`${G}-flag`:void 0),_jsx(Text,{style:[K.codeText,{color:xe.color,fontSize:Se.fontSize}],children:`+${ue.callingCode}`}),E?null:_jsx(Chevron,{color:R?Y.colors.field.iconDisabled:Y.colors.field.icon,size:Se.iconSize,open:ye})]}),children:_jsxs(View,{style:K.inputWrap,children:[_jsx(TextInput,{ref:J,value:ke,maxLength:Ve,onChangeText:Ke,returnKeyType:a,submitBehavior:s,onSubmitEditing:u,blurOnSubmit:d,onSelectionChange:e=>{const{start:t,end:o}=e.nativeEvent.selection;fe(t!==o)},onFocus:()=>{be(!0),U?.()},onBlur:()=>{be(!1),Pe&&!Ce.current&&he(!0),W?.()},editable:!R,placeholder:Ae&&!_e||je?void 0:j,placeholderTextColor:xe.placeholderColor,accessibilityLabel:$??L??j,selectionColor:Y.colors.field.caret,keyboardType:"phone-pad",textContentType:"telephoneNumber",autoComplete:"tel",style:[K.input,{color:xe.color,fontSize:Se.fontSize,...xe.weightStyle,paddingLeft:Fe?0:void 0}],testID:G?`${G}-input`:void 0}),je?_jsx(RequiredPlaceholder,{text:j,color:xe.placeholderColor,fontSize:Se.fontSize,weightStyle:xe.weightStyle}):null]})});return _jsxs(View,{style:q,testID:G,children:[L&&"top"===O?_jsx(FieldLabel,{size:k,required:z,children:L}):null,_jsxs(View,{style:K.fieldWrapper,children:[Xe,we.node]}),_jsx(FieldMessage,{size:k,error:qe,text:qe?We:_}),_jsx(OptionSheet,{open:ye,onClose:()=>Ne(!1),title:D,options:Q,sections:X,labelOf:e=>`${e.label} (+${e.code})`,getValue:e=>e.iso,disabledOf:()=>!1,descriptionOf:()=>{},iconOf:e=>Z(e,Y.typography.fontSize.lg),renderOption:C?(e,t)=>C(e,{selected:t.selected}):void 0,isSelected:e=>e===ze?.iso,onSelect:Je,searchable:Q.length>8,searchPlaceholder:S,alphabetIndex:x??Q.length>20})]})});PhoneNumberInput.displayName="PhoneNumberInput";const buildStyles=e=>StyleSheet.create({fieldWrapper:{position:"relative",overflow:"visible"},codeTrigger:{flexDirection:"row",alignItems:"center",gap:2},flag:{includeFontPadding:!1,marginRight:4},codeText:{...fontFor(e,"semibold"),fontWeight:"600",includeFontPadding:!1,writingDirection:"ltr"},input:{padding:0,margin:0,includeFontPadding:!1,writingDirection:"ltr"},inputWrap:{flex:1,alignSelf:"stretch",justifyContent:"center"}});export default PhoneNumberInput;
@@ -1 +1 @@
1
- "use strict";import{createContext,forwardRef,useContext,useMemo}from"react";import{Pressable,StyleSheet}from"react-native";import{useTheme}from"../../theme/index.js";import{resolveHaptic,triggerHaptic}from"../../utils/hapticUtils.js";import{hasFieldText}from"../FieldBase/index.js";import{ChoiceText,hasChoiceDetail}from"../FieldBase/ChoiceText.js";import{RadioDot}from"./RadioDot.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const RadioGroupContext=createContext(null);export const useRadioGroup=()=>useContext(RadioGroupContext);const toneColor=(e,t)=>{switch(t){case"success":return e.colors.success;case"warning":return e.colors.warning;case"error":return e.colors.error;default:return e.colors.primary}},Radio=forwardRef((e,t)=>{const{value:o,selected:r,onChange:i,disabled:s=!1,label:a,description:l,error:c,size:n="md",tone:d="primary",accessibilityLabel:p,haptic:u,style:m,containerStyle:b,circleStyle:h,dotStyle:x,labelStyle:y,testID:f,...C}=e,R=useTheme(),w=useMemo(()=>buildStyles(R),[R]),S=useRadioGroup();__DEV__&&void 0===o&&console.warn("[@webority/mobile-ui] Radio was rendered without a `value`. Selection compares against it, so the group cannot track which option is chosen.");const g=S?S.selectedValue===o:!!r,j=S&&S.disabled||s,D=toneColor(R,d),T=R.components.radio?.labelGap??10;return _jsxs(Pressable,{ref:t,onPress:e=>{if(j)return;const t=resolveHaptic(u,"selection");t&&triggerHaptic(t),S?S.onChange(o):i?.(o)},disabled:j,accessibilityRole:"radio",accessibilityLabel:p??a,accessibilityHint:C.accessibilityHint??l,accessibilityState:{checked:g,disabled:j},"aria-checked":g,"aria-disabled":j,testID:f,hitSlop:6,...C,style:({pressed:e})=>[w.row,hasChoiceDetail(l,c)?w.rowTop:null,{opacity:j?.55:e?.85:1},m,b],children:[_jsx(RadioDot,{selected:g,color:D,disabled:j&&!g,size:n,style:[!hasFieldText(c)||g||j?null:{borderColor:R.colors.field.borderError},h],dotStyle:x}),_jsx(ChoiceText,{label:a,description:l,error:c,disabled:j,labelLines:2,style:{marginLeft:T},labelStyle:y})]})});Radio.displayName="Radio";const buildStyles=e=>StyleSheet.create({row:{flexDirection:"row",alignItems:"center"},rowTop:{alignItems:"flex-start"}});export{Radio};export default Radio;
1
+ "use strict";import{createContext,forwardRef,useContext,useMemo}from"react";import{Pressable,StyleSheet}from"react-native";import{useTheme}from"../../theme/index.js";import{resolveHaptic,triggerHaptic}from"../../utils/hapticUtils.js";import{fieldTextAsString,hasFieldText}from"../FieldBase/index.js";import{ChoiceText,hasChoiceDetail}from"../FieldBase/ChoiceText.js";import{RadioDot}from"./RadioDot.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const RadioGroupContext=createContext(null);export const useRadioGroup=()=>useContext(RadioGroupContext);const toneColor=(e,t)=>{switch(t){case"success":return e.colors.success;case"warning":return e.colors.warning;case"error":return e.colors.error;default:return e.colors.primary}},Radio=forwardRef((e,t)=>{const{value:o,selected:r,onChange:i,disabled:s=!1,label:a,description:l,error:c,size:n="md",tone:d="primary",accessibilityLabel:p,haptic:u,style:m,containerStyle:x,circleStyle:b,dotStyle:h,labelStyle:y,testID:f,...S}=e,g=useTheme(),C=useMemo(()=>buildStyles(g),[g]),R=useRadioGroup();__DEV__&&void 0===o&&console.warn("[@webority/mobile-ui] Radio was rendered without a `value`. Selection compares against it, so the group cannot track which option is chosen.");const w=R?R.selectedValue===o:!!r,j=R&&R.disabled||s,T=toneColor(g,d),D=g.components.radio?.labelGap??10,_=p??fieldTextAsString(a),v=!0===R?.error||!0===c||hasFieldText(c);return _jsxs(Pressable,{ref:t,onPress:e=>{if(j)return;const t=resolveHaptic(u,"selection");t&&triggerHaptic(t),R?R.onChange(o):i?.(o)},disabled:j,accessibilityRole:"radio",accessibilityLabel:_,accessibilityHint:S.accessibilityHint??fieldTextAsString(l),accessibilityState:{checked:w,disabled:j},"aria-checked":w,"aria-disabled":j,testID:f,hitSlop:6,...S,style:({pressed:e})=>[C.row,hasChoiceDetail(l,c)?C.rowTop:null,{opacity:j?.55:e?.85:1},m,x],children:[_jsx(RadioDot,{selected:w,color:T,disabled:j&&!w,size:n,style:[!v||w||j?null:{borderColor:g.colors.field.borderError},b],dotStyle:h}),_jsx(ChoiceText,{label:a,description:l,error:c,disabled:j,labelLines:2,style:{marginLeft:D},labelStyle:y})]})});Radio.displayName="Radio";const buildStyles=e=>StyleSheet.create({row:{flexDirection:"row",alignItems:"center"},rowTop:{alignItems:"flex-start"}});export{Radio};export default Radio;
@@ -1 +1 @@
1
- "use strict";import{useMemo}from"react";import{View}from"react-native";import{useControllableState}from"../../hooks/index.js";import{RadioGroupContext}from"./Radio.js";import{jsx as _jsx}from"react/jsx-runtime";const RadioGroup=({value:e,defaultValue:o,onChange:a,children:i,disabled:t=!1,accessibilityLabel:r,style:s,testID:l})=>{const[d,u]=useControllableState({value:e,defaultValue:o??void 0,onChange:a}),n=useMemo(()=>({selectedValue:d,onChange:u,disabled:t}),[d,u,t]);return _jsx(RadioGroupContext.Provider,{value:n,children:_jsx(View,{accessibilityRole:"radiogroup",accessibilityLabel:r,accessibilityState:{disabled:t},"aria-disabled":t,testID:l,style:s,children:i})})};RadioGroup.displayName="RadioGroup";export{RadioGroup};export default RadioGroup;
1
+ "use strict";import{useMemo}from"react";import{View}from"react-native";import{useControllableState}from"../../hooks/index.js";import{hasFieldText}from"../FieldBase/index.js";import{ChoiceText}from"../FieldBase/ChoiceText.js";import{RadioGroupContext}from"./Radio.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const RadioGroup=({value:e,defaultValue:o,onChange:i,children:a,disabled:t=!1,error:r,accessibilityLabel:s,style:l,testID:d})=>{const[u,c]=useControllableState({value:e,defaultValue:o??void 0,onChange:i}),n=!0===r||hasFieldText(r),x=useMemo(()=>({selectedValue:u,onChange:c,disabled:t,error:n}),[u,c,t,n]);return _jsxs(RadioGroupContext.Provider,{value:x,children:[_jsx(View,{accessibilityRole:"radiogroup",accessibilityLabel:s,accessibilityState:{disabled:t},"aria-disabled":t,testID:d,style:l,children:a}),_jsx(ChoiceText,{error:r})]})};RadioGroup.displayName="RadioGroup";export{RadioGroup};export default RadioGroup;
@@ -0,0 +1 @@
1
+ "use strict";import{forwardRef,useEffect,useMemo,useRef,useState}from"react";import{Animated,StyleSheet,View}from"react-native";import{useSafeAreaInsets}from"react-native-safe-area-context";import{useReducedMotion}from"../../hooks/useReducedMotion.js";import{createAnimatedValue,useTheme}from"../../theme/index.js";import{announce}from"../../utils/announce.js";import{smoothCorners}from"../../utils/corners.js";import{triggerHaptic}from"../../utils/hapticUtils.js";import{AppIcon}from"../AppIcon/index.js";import{Button}from"../Button/index.js";import{EmptyState}from"../EmptyState/index.js";import{IconButton}from"../IconButton/index.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";const MIN_FRAME=240,DEFAULT_FRAME=260,MARK_LENGTH=32,MARK_THICKNESS=4,LIFT=.06,BREATHE_SCALE=1.03,SNAP_SCALE=1.08,T=4,CORNERS=[{key:"tl",style:{top:0,left:0,borderTopWidth:4,borderLeftWidth:4}},{key:"tr",style:{top:0,right:0,borderTopWidth:4,borderRightWidth:4}},{key:"bl",style:{bottom:0,left:0,borderBottomWidth:4,borderLeftWidth:4}},{key:"br",style:{bottom:0,right:0,borderBottomWidth:4,borderRightWidth:4}}],DEFAULT_LABELS={found:"Code found",invalid:"This code cannot be used. Try another.",torchOn:"Turn torch on",torchOff:"Turn torch off",manualEntry:"Enter code instead",gallery:"Upload from gallery",noPermissionTitle:"Camera access is off",noPermissionMessage:"Allow camera access to scan a code.",permissionAction:"Allow camera access",noCameraTitle:"No camera found",noCameraMessage:"This device has no camera available. You can still add the code another way."},ScannerOverlay=forwardRef((e,t)=>{const{children:o,state:n="scanning",hint:i="Point the camera at the code",labels:r,torch:s=!1,onTorchChange:a,onManualEntry:l,onGallery:c,onPermissionAction:d,frameSize:m=DEFAULT_FRAME,haptic:u,style:h,testID:f}=e,p=useTheme(),g=useSafeAreaInsets(),y=useReducedMotion(),b=useMemo(()=>buildStyles(p),[p]),x={...DEFAULT_LABELS,...r},[j,v]=useState({width:0,height:0}),S="scanning"===n||"found"===n||"invalid"===n,w=useRef(createAnimatedValue(1)).current,A=p.motion.duration.slower,E=p.motion.duration.normal;useEffect(()=>{if(w.setValue(1),y)return;let e;return"scanning"===n&&A>0?e=Animated.loop(Animated.sequence([Animated.timing(w,{toValue:1.03,duration:2*A,useNativeDriver:!0}),Animated.timing(w,{toValue:1,duration:2*A,useNativeDriver:!0})])):"found"===n&&E>0&&(w.setValue(1.08),e=Animated.timing(w,{toValue:1,duration:E,useNativeDriver:!0})),e?.start(),()=>e?.stop()},[n,y,A,E,w]);const _=useRef(n);useEffect(()=>{_.current!==n&&(_.current=n,!1!==u&&("found"===n?triggerHaptic("notificationSuccess"):"invalid"===n&&triggerHaptic("notificationError")))},[n,u]);const{found:V,invalid:C}=x,{noPermissionTitle:R,noPermissionMessage:M}=x,{noCameraTitle:k,noCameraMessage:I}=x;useEffect(()=>{switch(n){case"scanning":announce(i);break;case"found":announce(V);break;case"invalid":announce(C,{polite:!1});break;case"noPermission":announce(`${R}. ${M}`);break;case"noCamera":announce(`${k}. ${I}`)}},[n,i,V,C,R,M,k,I]);const L=Math.max(240,Math.min(m,j.width-2*p.spacing.xl)),P=(j.width-L)/2,F=Math.max(p.spacing.md,(j.height-L)/2-.06*j.height),B=j.width>0&&j.height>0,O={borderColor:"found"===n?p.colors.success:"invalid"===n?p.colors.error:p.colors.onOverlay,width:32,height:32},N="found"===n||"invalid"===n?_jsx(View,{style:[b.pill,{backgroundColor:"found"===n?p.colors.success:p.colors.error}],children:_jsx(Text,{variant:"bodySmall",weight:"semibold",align:"center",color:"found"===n?p.colors.onSuccess:p.colors.onError,children:"found"===n?V:C})}):_jsx(Text,{variant:"bodySmall",align:"center",color:p.colors.onOverlay,children:i}),D=S&&null!=a,H=S?"glass":"outline";return _jsxs(View,{ref:t,testID:f,onLayout:e=>{const{width:t,height:o}=e.nativeEvent.layout;v(e=>e.width===t&&e.height===o?e:{width:t,height:o})},style:[b.root,!S&&{backgroundColor:p.colors.background.primary},h],children:[S?_jsx(View,{style:StyleSheet.absoluteFill,children:o}):null,S&&B?_jsxs(_Fragment,{children:[_jsxs(View,{pointerEvents:"none",style:StyleSheet.absoluteFill,accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants","aria-hidden":!0,children:[_jsx(View,{style:[b.scrim,{left:0,right:0,top:0,height:F}]}),_jsx(View,{style:[b.scrim,{left:0,right:0,top:F+L,bottom:0}]}),_jsx(View,{style:[b.scrim,{left:0,width:P,top:F,height:L}]}),_jsx(View,{style:[b.scrim,{left:P+L,right:0,top:F,height:L}]}),_jsx(Animated.View,{style:{position:"absolute",left:P,top:F,width:L,height:L,transform:[{scale:w}]},children:CORNERS.map(e=>_jsx(View,{style:[b.mark,O,e.style]},e.key))})]}),_jsx(View,{pointerEvents:"none",style:[b.message,{top:F+L+p.spacing.md}],children:N})]}):null,S?null:_jsx(View,{style:b.panel,children:_jsx(EmptyState,{fill:!0,icon:_jsx(AppIcon,{name:"noPermission"===n?"camera":"camera-slash",size:48,color:p.colors.text.tertiary}),title:"noPermission"===n?R:k,description:"noPermission"===n?M:I,action:"noPermission"===n&&d?{label:x.permissionAction,onPress:d}:void 0})}),_jsxs(View,{pointerEvents:"box-none",style:[b.bar,{paddingBottom:Math.max(g.bottom,p.spacing.md)}],children:[D?_jsx(IconButton,{icon:s?"flash":"flash-slash",variant:"glass",size:"lg",active:s,haptic:u,accessibilityLabel:s?x.torchOff:x.torchOn,onPress:()=>a?.(!s)}):null,c?_jsx(Button,{title:x.gallery,leftIcon:"gallery",variant:H,tone:"neutral",size:"lg",haptic:u,onPress:c}):null,l?_jsx(Button,{title:x.manualEntry,leftIcon:"keyboard",variant:H,tone:"neutral",size:"lg",haptic:u,onPress:l}):null]})]})});ScannerOverlay.displayName="ScannerOverlay";const buildStyles=e=>StyleSheet.create({root:{flex:1,overflow:"hidden"},scrim:{position:"absolute",backgroundColor:e.colors.background.overlay},mark:{position:"absolute"},message:{position:"absolute",left:0,right:0,alignItems:"center",paddingHorizontal:e.spacing.xl},pill:{paddingHorizontal:e.spacing.md,paddingVertical:e.spacing.xs,borderRadius:e.radius.full,...smoothCorners},panel:{...StyleSheet.absoluteFill,justifyContent:"center"},bar:{position:"absolute",left:0,right:0,bottom:0,flexDirection:"row",flexWrap:"wrap",alignItems:"center",justifyContent:"center",gap:e.spacing.sm,paddingHorizontal:e.spacing.md}});export{ScannerOverlay};export default ScannerOverlay;
@@ -0,0 +1 @@
1
+ "use strict";export{default,ScannerOverlay}from"./ScannerOverlay.js";
@@ -1 +1 @@
1
- "use strict";import{forwardRef,useCallback,useEffect,useMemo,useRef,useState}from"react";import{Pressable,StyleSheet,TextInput,View}from"react-native";import{useDebounce}from"../../hooks/useDebounce.js";import{useTheme}from"../../theme/index.js";import{resolveHaptic,triggerHaptic}from"../../utils/hapticUtils.js";import{mergeRefs}from"../../utils/mergeRefs.js";import{defaultIcons}from"../AppIcon/defaultIcons.js";import{renderSlotIcon}from"../AppIcon/slotIcon.js";import{FieldBase,FieldLabel,resolveFieldSize,resolveFieldTextStyle,resolveVariantColors}from"../FieldBase/FieldBase.js";import{useFloatingLabel}from"../FieldBase/useFloatingLabel.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const SearchBar=forwardRef((e,o)=>{const{value:l,onChangeText:i,onSubmit:s,placeholder:t="Search…",autoFocus:a=!1,disabled:r=!1,onClear:n,leftIcon:c,debounceMs:d,size:u="md",variant:f,borderRadius:p,label:b,labelMode:m="top",labelStyle:h,haptic:S,style:g,inputStyle:y,accessibilityLabel:v,testID:x,...j}=e,F=useTheme(),z=f??F.components.searchBar?.defaultVariant??F.components.field?.defaultVariant??"filled",I="underline"===z,B=resolveFieldSize(F,u),C={...B,...F.components.searchBar?.[u]??{}},R=resolveFieldTextStyle(F,{disabled:r}),w=useRef(null),T=useMemo(()=>mergeRefs(w,o),[o]),L=useCallback(()=>{r||w.current?.focus()},[r]),H=useMemo(()=>buildStyles(F),[F]),_="string"==typeof l?l:"",[k,V]=useState(!1),[D,M]=useState(_),P=useDebounce(D,d??0);useEffect(()=>{void 0!==d&&_!==D&&M(_)},[_,d]);const E=useRef(_);useEffect(()=>{void 0!==d&&P!==E.current&&(E.current=P,i(P))},[P,d,i]);const N=useCallback(e=>{void 0===d?i(e):M(e)},[d,i]),A=useCallback(()=>{const e=resolveHaptic(S,"selection");e&&triggerHaptic(e),void 0!==d&&(M(""),E.current=""),i(""),n?.()},[S,d,i,n]),O=useCallback(()=>{s?.(void 0!==d?D:_)},[s,d,D,_]),W=void 0!==d?D:_,K=W.length>0,U={size:C.iconSize,color:r?F.colors.text.disabled:F.colors.text.tertiary,disabled:r},q=c?renderSlotIcon(c,U):(F.icons?.search??defaultIcons.search)(U),G=Boolean(b)&&"float"===m,J=useFloatingLabel({label:b,enabled:G,floated:k||K,variant:z,sizeTokens:{...B,...C},leadingOffset:C.iconSize+F.spacing.md,trailingOffset:K?C.iconSize+F.spacing.md:0,paddingLeft:I?0:C.paddingHorizontal,color:F.colors.field.label,style:h}),Q=K&&!r?_jsx(Pressable,{onPress:A,hitSlop:8,accessibilityRole:"button",accessibilityLabel:"Clear search",children:(F.icons?.close??defaultIcons.close)({size:C.iconSize,color:F.colors.text.secondary})}):null;return _jsxs(View,{style:g,testID:x,children:[b&&!G?_jsx(FieldLabel,{size:u,style:h,children:b}):null,_jsx(View,{style:H.root,children:_jsxs(View,{style:H.fieldWrap,children:[_jsx(FieldBase,{size:u,variant:z,focused:k,disabled:r,filled:K,minHeight:C.minHeight,paddingHorizontal:I?0:C.paddingHorizontal,borderRadius:p??C.borderRadius,leading:q,trailing:Q,topNotch:J.topNotch,onPress:L,pressFeedback:!1,accessibilityRole:"search",accessibilityLabel:v??t,children:_jsx(TextInput,{ref:T,style:[H.input,{fontSize:C.fontSize,color:R.color,...R.weightStyle},y],value:W,onChangeText:N,onSubmitEditing:O,onFocus:()=>V(!0),onBlur:()=>V(!1),placeholder:!G||k||K?t:void 0,placeholderTextColor:R.placeholderColor,autoFocus:a,editable:!r,returnKeyType:"search",selectionColor:resolveVariantColors(F,z).borderFocusedRepresentative,accessibilityLabel:v??t,accessibilityState:{disabled:r},"aria-disabled":r,...j})}),J.node]})})]})});SearchBar.displayName="SearchBar";const buildStyles=e=>StyleSheet.create({root:{flexDirection:"row",alignItems:"center",width:"100%",position:"relative",overflow:"visible"},fieldWrap:{flex:1,position:"relative",overflow:"visible"},input:{flex:1,padding:0,margin:0,includeFontPadding:!1}});export{SearchBar};export default SearchBar;
1
+ "use strict";import{forwardRef,useCallback,useEffect,useMemo,useRef,useState}from"react";import{Pressable,StyleSheet,TextInput,View}from"react-native";import{useControllableState}from"../../hooks/useControllableState.js";import{useDebounce}from"../../hooks/useDebounce.js";import{useTheme}from"../../theme/index.js";import{announce}from"../../utils/announce.js";import{resolveHaptic,triggerHaptic}from"../../utils/hapticUtils.js";import{mergeRefs}from"../../utils/mergeRefs.js";import{defaultIcons}from"../AppIcon/defaultIcons.js";import{renderSlotIcon}from"../AppIcon/slotIcon.js";import{FieldBase,FieldLabel,resolveFieldSize,resolveFieldTextStyle,resolveVariantColors}from"../FieldBase/FieldBase.js";import{useFloatingLabel}from"../FieldBase/useFloatingLabel.js";import{normalizeSuggestion,SearchRecents,SearchScopeBar,SearchSuggestions}from"./SearchPanel.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const DEFAULT_PANEL_ROWS=8,HOLD_RELEASE_MS=50,SearchBar=forwardRef((e,l)=>{const{value:o,onChangeText:s,onSubmit:t,onFocus:a,onBlur:i,placeholder:n="Search…",autoFocus:r=!1,disabled:c=!1,onClear:u,leftIcon:d,debounceMs:b,size:f="md",variant:p,borderRadius:S,label:m,labelMode:g="top",labelStyle:h,scopes:v,scope:x,onScopeChange:C,recents:R,recentsTitle:y="Recent searches",maxRecents:j=DEFAULT_PANEL_ROWS,onSelectRecent:F,onRemoveRecent:k,onClearRecents:_,suggestions:z,maxSuggestions:L=DEFAULT_PANEL_ROWS,onSelectSuggestion:B,haptic:T,style:E,inputStyle:I,accessibilityLabel:H,testID:w,...D}=e,A=useTheme(),P=p??A.components.searchBar?.defaultVariant??A.components.field?.defaultVariant??"filled",V="underline"===P,M=resolveFieldSize(A,f),N={...M,...A.components.searchBar?.[f]??{}},O=resolveFieldTextStyle(A,{disabled:c}),W=useRef(null),U=useMemo(()=>mergeRefs(W,l),[l]),$=useCallback(()=>{c||W.current?.focus()},[c]),q=useMemo(()=>buildStyles(A),[A]),K="string"==typeof o?o:"",[G,J]=useState(!1),Q=useCallback(e=>{J(!0),a?.(e)},[a]),X=useCallback(e=>{J(!1),i?.(e)},[i]),[Y,Z]=useState(K),ee=useDebounce(Y,b??0);useEffect(()=>{void 0!==b&&K!==Y&&Z(K)},[K,b]);const le=useRef(K);useEffect(()=>{void 0!==b&&ee!==le.current&&(le.current=ee,s(ee))},[ee,b,s]);const oe=useCallback(e=>{void 0===b?s(e):Z(e)},[b,s]),se=useCallback(()=>{const e=resolveHaptic(T,"selection");e&&triggerHaptic(e),void 0!==b&&(Z(""),le.current=""),s(""),u?.()},[T,b,s,u]),te=useCallback(()=>{t?.(void 0!==b?Y:K)},[t,b,Y,K]),ae=void 0!==b?Y:K,ie=ae.length>0,[ne,re]=useControllableState({value:x,defaultValue:v?.[0]?.value??"",onChange:C}),ce=useCallback(e=>{re(e);const l=v?.find(l=>l.value===e)?.label;l&&announce(`Searching ${l}`)},[v,re]),[ue,de]=useState(!1),be=useRef(null),fe=useCallback(()=>{be.current&&(clearTimeout(be.current),be.current=null)},[]),pe=useCallback(()=>{fe(),de(!0)},[fe]),Se=useCallback(()=>{fe(),be.current=setTimeout(()=>de(!1),50)},[fe]);useEffect(()=>fe,[fe]);const me=!c&&(G||ue),ge=useMemo(()=>(R??[]).slice(0,j),[R,j]),he=useMemo(()=>(z??[]).slice(0,L).map(normalizeSuggestion),[z,L]),ve=me&&!ie&&ge.length>0,xe=me&&ie&&he.length>0,Ce=xe?he.length:0;useEffect(()=>{Ce>0&&announce(1===Ce?"1 suggestion":`${Ce} suggestions`)},[Ce]);const Re=useCallback(()=>{const e=resolveHaptic(T,"selection");e&&triggerHaptic(e)},[T]),ye=useCallback(e=>{Re(),W.current?.blur(),de(!1),F?.(e)},[Re,F]),je=useCallback(e=>{Re(),W.current?.blur(),de(!1),B?.(e)},[Re,B]),Fe=useCallback(e=>{Re(),k?.(e),announce(`Removed ${e}`),$()},[Re,k,$]),ke=useCallback(()=>{Re(),_?.(),announce("Recent searches cleared"),$()},[Re,_,$]),_e={size:N.iconSize,color:c?A.colors.text.disabled:A.colors.text.tertiary,disabled:c},ze=d?renderSlotIcon(d,_e):(A.icons?.search??defaultIcons.search)(_e),Le=Boolean(m)&&"float"===g,Be=useFloatingLabel({label:m,enabled:Le,floated:G||ie,variant:P,sizeTokens:{...M,...N},leadingOffset:N.iconSize+A.spacing.md,trailingOffset:ie?N.iconSize+A.spacing.md:0,paddingLeft:V?0:N.paddingHorizontal,color:A.colors.field.label,style:h}),Te=ie&&!c?_jsx(Pressable,{onPress:se,hitSlop:8,accessibilityRole:"button",accessibilityLabel:"Clear search",children:(A.icons?.close??defaultIcons.close)({size:N.iconSize,color:A.colors.text.secondary})}):null;return _jsxs(View,{style:E,testID:w,children:[m&&!Le?_jsx(FieldLabel,{size:f,style:h,children:m}):null,_jsx(View,{style:q.root,children:_jsxs(View,{style:q.fieldWrap,children:[_jsx(FieldBase,{size:f,variant:P,focused:G,disabled:c,filled:ie,minHeight:N.minHeight,paddingHorizontal:V?0:N.paddingHorizontal,borderRadius:S??N.borderRadius,leading:ze,trailing:Te,topNotch:Be.topNotch,onPress:$,pressFeedback:!1,accessibilityRole:"search",accessibilityLabel:H??n,children:_jsx(TextInput,{ref:U,style:[q.input,{fontSize:N.fontSize,color:O.color,...O.weightStyle},I],value:ae,onChangeText:oe,onSubmitEditing:te,onFocus:Q,onBlur:X,placeholder:!Le||G||ie?n:void 0,placeholderTextColor:O.placeholderColor,autoFocus:r,editable:!c,returnKeyType:"search",selectionColor:resolveVariantColors(A,P).borderFocusedRepresentative,accessibilityLabel:H??n,accessibilityState:{disabled:c},"aria-disabled":c,...D})}),Be.node]})}),v&&v.length>0?_jsx(SearchScopeBar,{scopes:v,scope:ne||(v[0]?.value??""),disabled:c,haptic:T,onChange:ce}):null,ve?_jsx(SearchRecents,{recents:ge,title:y,onSelect:ye,onRemove:k?Fe:void 0,onClear:_?ke:void 0,onHold:pe,onRelease:Se}):null,xe?_jsx(SearchSuggestions,{suggestions:he,query:ae,onSelect:je,onHold:pe,onRelease:Se}):null]})});SearchBar.displayName="SearchBar";const buildStyles=e=>StyleSheet.create({root:{flexDirection:"row",alignItems:"center",width:"100%",position:"relative",overflow:"visible"},fieldWrap:{flex:1,position:"relative",overflow:"visible"},input:{flex:1,padding:0,margin:0,includeFontPadding:!1}});export{SearchBar};export default SearchBar;
@@ -0,0 +1 @@
1
+ "use strict";import{memo,useMemo}from"react";import{Pressable,Text as RNText,ScrollView,StyleSheet,View}from"react-native";import{fontFor,useTheme}from"../../theme/index.js";import{AppIcon}from"../AppIcon/index.js";import{renderSlotIcon}from"../AppIcon/slotIcon.js";import{Chip}from"../Chip/index.js";import{Text}from"../Text/index.js";import{splitHighlight}from"./highlight.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const TOUCH=44,ICON=18;export const normalizeSuggestion=e=>"string"==typeof e?{text:e}:e;export const SearchScopeBar=({scopes:e,scope:s,disabled:t,haptic:o,onChange:i})=>{const r=useTheme(),n=useMemo(()=>buildStyles(r),[r]);return _jsx(ScrollView,{horizontal:!0,showsHorizontalScrollIndicator:!1,keyboardShouldPersistTaps:"handled",contentContainerStyle:n.scopes,accessibilityLabel:"Search scope",children:e.map(e=>_jsx(Chip,{label:e.label,selected:e.value===s,disabled:t,haptic:o,onPress:()=>i(e.value),containerStyle:n.scopeChip},e.value))})};export const SearchRecents=({recents:e,title:s,onSelect:t,onRemove:o,onClear:i,onHold:r,onRelease:n})=>{const l=useTheme(),c=useMemo(()=>buildStyles(l),[l]);return _jsxs(View,{style:c.list,children:[_jsxs(View,{style:c.header,children:[_jsx(Text,{variant:"label",accessibilityRole:"header",style:c.headerTitle,children:s}),i?_jsx(Pressable,{onPress:i,onPressIn:r,onPressOut:n,accessibilityRole:"button",accessibilityLabel:"Clear all recent searches",style:c.clearAll,children:_jsx(Text,{variant:"label",color:"link",children:"Clear all"})}):null]}),e.map(e=>_jsxs(View,{style:c.row,children:[_jsxs(Pressable,{onPress:()=>t(e),onPressIn:r,onPressOut:n,accessibilityRole:"button",accessibilityLabel:e,accessibilityHint:"Searches again",android_ripple:{color:l.colors.surface.pressed},style:({pressed:e})=>[c.rowMain,e?{backgroundColor:l.colors.surface.pressed}:null],children:[_jsx(AppIcon,{name:"history",size:18,color:l.colors.text.tertiary}),_jsx(Text,{variant:"body",numberOfLines:1,style:c.rowText,children:e})]}),o?_jsx(Pressable,{onPress:()=>o(e),onPressIn:r,onPressOut:n,accessibilityRole:"button",accessibilityLabel:`Remove ${e} from recent searches`,style:c.remove,children:_jsx(AppIcon,{name:"x",size:18,color:l.colors.text.secondary})}):null]},e))]})};const SuggestionRow=memo(({item:e,query:s,onSelect:t,onHold:o,onRelease:i,theme:r,styles:n})=>{const l=splitHighlight(e.text,s),c=e.icon?renderSlotIcon(e.icon,{size:18,color:r.colors.text.tertiary,disabled:!1}):_jsx(AppIcon,{name:"search",size:18,color:r.colors.text.tertiary});return _jsxs(Pressable,{onPress:()=>t(e),onPressIn:o,onPressOut:i,accessibilityRole:"button",accessibilityLabel:e.subtitle?`${e.text}, ${e.subtitle}`:e.text,android_ripple:{color:r.colors.surface.pressed},style:({pressed:e})=>[n.rowMain,n.suggestion,e?{backgroundColor:r.colors.surface.pressed}:null],children:[c,_jsxs(View,{style:n.rowText,children:[_jsx(Text,{variant:"body",color:"secondary",numberOfLines:1,children:l.map(e=>_jsx(RNText,{style:e.match?n.match:void 0,children:e.text},e.start))}),e.subtitle?_jsx(Text,{variant:"caption",numberOfLines:1,children:e.subtitle}):null]})]})});SuggestionRow.displayName="SuggestionRow";export const SearchSuggestions=({suggestions:e,query:s,onSelect:t,onHold:o,onRelease:i})=>{const r=useTheme(),n=useMemo(()=>buildStyles(r),[r]);return _jsx(View,{style:n.list,children:e.map(e=>_jsx(SuggestionRow,{item:e,query:s,onSelect:t,onHold:o,onRelease:i,theme:r,styles:n},e.id??e.text))})};const buildStyles=e=>({...StyleSheet.create({scopes:{flexDirection:"row",alignItems:"center",gap:e.spacing.sm,paddingTop:e.spacing.sm},scopeChip:{minHeight:44},list:{width:"100%",paddingTop:e.spacing.xs},header:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",minHeight:44,paddingHorizontal:e.spacing.xs},headerTitle:{flex:1},clearAll:{minHeight:44,minWidth:44,justifyContent:"center",alignItems:"flex-end"},row:{flexDirection:"row",alignItems:"center"},rowMain:{flex:1,flexDirection:"row",alignItems:"center",gap:e.spacing.md,minHeight:44,paddingHorizontal:e.spacing.xs},suggestion:{paddingVertical:e.spacing.xs},rowText:{flex:1},remove:{width:44,height:44,alignItems:"center",justifyContent:"center"}}),match:{...fontFor(e,"bold"),color:e.colors.text.primary}});
@@ -0,0 +1 @@
1
+ "use strict";const MAX_TOKENS=8,escapeRegExp=t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");export const splitHighlight=(t,e)=>{const s=e.trim().split(/\s+/).filter(Boolean).slice(0,8).sort((t,e)=>e.length-t.length);if(!t||0===s.length)return[{text:t,match:!1,start:0}];const c=new RegExp(s.map(escapeRegExp).join("|"),"gi"),n=[];let l=0,h=c.exec(t);for(;null!==h;){const e=h.index,s=e+h[0].length;e>l&&n.push({text:t.slice(l,e),match:!1,start:l});const a=n[n.length-1];a?.match&&e===l?a.text+=h[0]:n.push({text:h[0],match:!0,start:e}),l=s,h=c.exec(t)}return l<t.length&&n.push({text:t.slice(l),match:!1,start:l}),n.length>0?n:[{text:t,match:!1,start:0}]};
@@ -1 +1 @@
1
- "use strict";export{default,SearchBar}from"./SearchBar.js";
1
+ "use strict";export{default,SearchBar}from"./SearchBar.js";export{useRecentSearches}from"./useRecentSearches.js";
@@ -0,0 +1 @@
1
+ "use strict";import{Storage}from"@webority/mobile-core";import{useCallback,useEffect,useRef,useState}from"react";const DEFAULT_MAX=8,isStringList=e=>Array.isArray(e)&&e.every(e=>"string"==typeof e);export const useRecentSearches=(e,r)=>{const t=r?.max??8,[s,c]=useState([]),n=useRef([]),u=useRef(!1);useEffect(()=>{let r=!1;return u.current=!1,n.current=[],c([]),Storage.getJson(e).then(e=>{if(r||u.current||!isStringList(e))return;const s=e.slice(0,t);n.current=s,c(s)}),()=>{r=!0}},[e]);const a=useCallback(r=>{u.current=!0,n.current=r,c(r),Storage.setJson(e,r)},[e]);return{recents:s,add:useCallback(e=>{const r=e.trim();if(!r)return;const s=r.toLowerCase(),c=n.current.filter(e=>e.toLowerCase()!==s);a([r,...c].slice(0,t))},[a,t]),remove:useCallback(e=>{a(n.current.filter(r=>r!==e))},[a]),clear:useCallback(()=>{const e=n.current;return a([]),e},[a]),replace:useCallback(e=>{a(e.slice(0,t))},[a,t])}};
@@ -1 +1 @@
1
- "use strict";import{forwardRef,useCallback,useEffect,useMemo,useRef,useState}from"react";import{Animated,Pressable,StyleSheet,Text,View}from"react-native";import{useControllableState}from"../../hooks/index.js";import{createAnimatedValue,useTheme}from"../../theme/index.js";import{resolveHaptic,triggerHaptic}from"../../utils/index.js";import{smoothCorners}from"../../utils/corners.js";import{renderSlotIcon}from"../AppIcon/slotIcon.js";import{FieldLabel,FieldMessage,hasFieldText}from"../FieldBase/index.js";import{SquircleFill,useSquircle}from"../SquircleFill/SquircleFill.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const segmentedControlSizes={sm:{height:32,fontSize:12,paddingHorizontal:10,iconSize:14},md:{height:40,fontSize:14,paddingHorizontal:14,iconSize:16},lg:{height:48,fontSize:16,paddingHorizontal:18,iconSize:18}};export const segmentedControlTrackPadding=4;const LABEL_LINE_HEIGHT_RATIO=1.25,sizeMap=segmentedControlSizes,TRACK_PADDING=4,SegmentedControl=forwardRef((e,t)=>{const{segments:i,label:o,helperText:l,error:r,value:s,defaultValue:n,onChange:a,size:d="md",fullWidth:c=!0,disabled:m=!1,tone:u="primary",variant:g="segmented",radius:h,labelLines:p=1,haptic:f,accessibilityLabel:b,style:S,containerStyle:x,segmentStyle:y,selectedIndicatorStyle:z,textStyle:v,labelStyle:C,testID:j}=e,[w,I]=useControllableState({value:s,defaultValue:n??i[0]?.value,onChange:a}),k=useTheme(),H=k.components.segmentedControl,L=useMemo(()=>buildStyles(k),[k]),_=sizeMap[d],F={height:H?.[d]?.height??_.height,fontSize:H?.[d]?.fontSize??_.fontSize,paddingHorizontal:H?.[d]?.paddingHorizontal??_.paddingHorizontal,iconSize:H?.[d]?.iconSize??_.iconSize},M=p>=2?2:1,T=M>1,V="segmented"===g,A="underline"===g,R="pills"===g,D=V?H?.trackPadding??4:0,E=Math.ceil(1.25*F.fontSize)*(M-1),P=H?.underlineHeight??2,q=H?.pillInset??4,W="number"==typeof h?h:h?k.radius[h]:H?.radius,B=W??k.radius.md,N=void 0===W?k.radius.sm:Math.max(W-D,0),G=W??k.radius.full,O=W??0,[K,X]=useState(0),J=useRef(createAnimatedValue(0)).current,Q=Math.max(0,i.findIndex(e=>e.value===w)),U=K>0?(K-2*D)/Math.max(i.length,1):0,Y=useCallback((e,t)=>{if(t<=0)return;const i=t*e,o=k.motion.spring.snappy,l=Animated.spring(J,{toValue:i,damping:o.damping,stiffness:o.stiffness,mass:o.mass,overshootClamping:!0,useNativeDriver:!0});return l.start(),l},[k.motion.spring.snappy,J]);useEffect(()=>{if(U>0){const e=Y(Q,U);return()=>e?.stop()}},[Q,U,Y]);const Z=useCallback(e=>{const t=e.nativeEvent.layout.width;t!==K&&X(t)},[K]),$=useCallback(e=>{if(m)return;if(e.value===w)return;const t=resolveHaptic(f,"selection");t&&triggerHaptic(t),I(e.value)},[m,I,w,f]),ee=V?k.colors.background.elevated:R?k.colors.primaryMuted:k.colors.primary,te=V?N:R?G:O,ie="neutral"===u?k.colors.text.primary:k.colors.primary,oe=k.colors.background.tertiary,le=useSquircle(V,B,Z),re=hasFieldText(o),se=hasFieldText(r)?r:l,ne=hasFieldText(se),ae=_jsxs(View,{ref:t,accessibilityRole:"radiogroup",accessibilityLabel:b??("string"==typeof o?o:void 0),testID:j,style:[L.track,{...T?{minHeight:F.height+E}:{height:F.height},opacity:m?.55:1,alignSelf:c?"stretch":"flex-start"},V?{borderRadius:B,...smoothCorners,backgroundColor:le.active?"transparent":oe,padding:D}:A?{borderBottomColor:k.colors.border.secondary,borderBottomWidth:StyleSheet.hairlineWidth}:null,x,S],onLayout:le.onLayout,children:[le.active&&le.size?_jsx(SquircleFill,{width:le.size.width,height:le.size.height,radius:B,fill:oe}):null,_jsxs(View,{style:L.row,children:[U>0?_jsx(Animated.View,{pointerEvents:"none",style:[L.thumb,V?T?{top:0,bottom:0}:{top:0,height:F.height-2*D}:R?{top:q,bottom:q}:{bottom:0,height:P},{width:U,borderRadius:te,...smoothCorners,backgroundColor:ee,transform:[{translateX:J}]},z]}):null,i.map(e=>{const t=e.value===w,i=t?ie:k.colors.text.tertiary,o=renderSlotIcon(e.icon,{color:i,size:F.iconSize,selected:t,disabled:m});return _jsxs(Pressable,{onPress:()=>$(e),disabled:m,accessibilityRole:"radio",accessibilityLabel:e.label,accessibilityState:{checked:t,selected:t,disabled:m},"aria-checked":t,"aria-disabled":m,style:({pressed:e})=>[L.segment,T?L.segmentMultiline:null,{paddingHorizontal:F.paddingHorizontal,opacity:e&&!t?.7:1},y],children:[o?_jsx(View,{style:L.segmentIcon,children:o}):null,_jsx(Text,{style:[L.segmentLabel,T?L.segmentLabelMultiline:null,{color:i,fontSize:F.fontSize,fontWeight:t?k.typography.fontWeight.semibold:k.typography.fontWeight.medium},v,C],numberOfLines:M,children:e.label})]},String(e.value))})]})]});return re||ne?_jsxs(View,{style:{alignSelf:c?"stretch":"flex-start"},children:[re?_jsx(FieldLabel,{size:d,children:o}):null,ae,ne?_jsx(FieldMessage,{size:d,text:se,error:hasFieldText(r)}):null]}):ae});SegmentedControl.displayName="SegmentedControl";const buildStyles=e=>StyleSheet.create({track:{flexDirection:"row",alignItems:"stretch",position:"relative"},row:{flex:1,flexDirection:"row",alignItems:"stretch",position:"relative",overflow:"hidden"},thumb:{position:"absolute",left:0},segment:{flex:1,flexDirection:"row",alignItems:"center",justifyContent:"center"},segmentIcon:{marginRight:6},segmentMultiline:{paddingVertical:6},segmentLabel:{includeFontPadding:!1},segmentLabelMultiline:{flexShrink:1,textAlign:"center"}});export{SegmentedControl};export default SegmentedControl;
1
+ "use strict";import{forwardRef,useCallback,useEffect,useMemo,useRef,useState}from"react";import{Animated,Pressable,StyleSheet,Text,View}from"react-native";import{useControllableState}from"../../hooks/index.js";import{createAnimatedValue,useTheme}from"../../theme/index.js";import{resolveHaptic,triggerHaptic}from"../../utils/index.js";import{smoothCorners}from"../../utils/corners.js";import{renderSlotIcon}from"../AppIcon/slotIcon.js";import{FieldLabel,FieldMessage,hasFieldText}from"../FieldBase/index.js";import{SquircleFill,useSquircle}from"../SquircleFill/SquircleFill.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const segmentedControlSizes={sm:{height:32,fontSize:12,paddingHorizontal:10,iconSize:14},md:{height:40,fontSize:14,paddingHorizontal:14,iconSize:16},lg:{height:48,fontSize:16,paddingHorizontal:18,iconSize:18}};export const segmentedControlTrackPadding=4;const LABEL_LINE_HEIGHT_RATIO=1.25,sizeMap=segmentedControlSizes,TRACK_PADDING=4,SegmentedControl=forwardRef((e,t)=>{const{segments:i,label:o,helperText:r,error:l,value:s,defaultValue:n,onChange:a,size:d="md",fullWidth:c=!0,disabled:u=!1,tone:m="primary",variant:h="segmented",radius:g,labelLines:p=1,haptic:f,accessibilityLabel:b,style:S,containerStyle:y,segmentStyle:x,selectedIndicatorStyle:z,textStyle:v,labelStyle:C,testID:j}=e,[w,k]=useControllableState({value:s,defaultValue:n??i[0]?.value,onChange:a}),I=useTheme(),_=I.components.segmentedControl,H=useMemo(()=>buildStyles(I),[I]),L=sizeMap[d],F={height:_?.[d]?.height??L.height,fontSize:_?.[d]?.fontSize??L.fontSize,paddingHorizontal:_?.[d]?.paddingHorizontal??L.paddingHorizontal,iconSize:_?.[d]?.iconSize??L.iconSize},M=p>=2?2:1,T=M>1,V="segmented"===h,R="underline"===h,A="pills"===h,E=V?_?.trackPadding??4:0,D=Math.ceil(1.25*F.fontSize)*(M-1),W=_?.underlineHeight??2,P=_?.pillInset??4,q="number"==typeof g?g:g?I.radius[g]:_?.radius,B=q??I.radius.md,N=void 0===q?I.radius.sm:Math.max(q-E,0),G=q??I.radius.full,O=q??0,[K,X]=useState(0),J=useRef(createAnimatedValue(0)).current,Q=Math.max(0,i.findIndex(e=>e.value===w)),U=K>0?(K-2*E)/Math.max(i.length,1):0,Y=useCallback((e,t)=>{if(t<=0)return;const i=t*e,o=I.motion.spring.snappy,r=Animated.spring(J,{toValue:i,damping:o.damping,stiffness:o.stiffness,mass:o.mass,overshootClamping:!0,useNativeDriver:!0});return r.start(),r},[I.motion.spring.snappy,J]);useEffect(()=>{if(U>0){const e=Y(Q,U);return()=>e?.stop()}},[Q,U,Y]);const Z=useCallback(e=>{const t=e.nativeEvent.layout.width;t!==K&&X(t)},[K]),$=useCallback(e=>{if(u)return;if(e.value===w)return;const t=resolveHaptic(f,"selection");t&&triggerHaptic(t),k(e.value)},[u,k,w,f]),ee=V?I.colors.background.elevated:A?I.colors.primaryMuted:I.colors.primary,te=V?N:A?G:O,ie="neutral"===m?I.colors.text.primary:I.colors.primary,oe=I.colors.background.tertiary,re=useSquircle(V,B,Z),le=!0===l||hasFieldText(l),se=le&&!u,ne=I.colors.field.borderError,ae=I.colors.border.width,de=hasFieldText(o),ce=le?l:r,ue=hasFieldText(ce),me=_jsxs(View,{ref:t,accessibilityRole:"radiogroup",accessibilityLabel:b??("string"==typeof o?o:void 0),testID:j,style:[H.track,{...T?{minHeight:F.height+D}:{height:F.height},opacity:u?.55:1,alignSelf:c?"stretch":"flex-start"},V?{borderRadius:B,...smoothCorners,backgroundColor:re.active?"transparent":oe,padding:E}:R?{borderBottomColor:se?ne:I.colors.border.secondary,borderBottomWidth:StyleSheet.hairlineWidth}:null,y,S],onLayout:re.onLayout,children:[re.active&&re.size?_jsx(SquircleFill,{width:re.size.width,height:re.size.height,radius:B,fill:oe,stroke:se?ne:void 0,strokeWidth:ae}):null,_jsxs(View,{style:H.row,children:[U>0?_jsx(Animated.View,{pointerEvents:"none",style:[H.thumb,V?T?{top:0,bottom:0}:{top:0,height:F.height-2*E}:A?{top:P,bottom:P}:{bottom:0,height:W},{width:U,borderRadius:te,...smoothCorners,backgroundColor:ee,transform:[{translateX:J}]},z]}):null,i.map(e=>{const t=e.value===w,i=t?ie:I.colors.text.tertiary,o=renderSlotIcon(e.icon,{color:i,size:F.iconSize,selected:t,disabled:u});return _jsxs(Pressable,{onPress:()=>$(e),disabled:u,accessibilityRole:"radio",accessibilityLabel:e.label,accessibilityState:{checked:t,selected:t,disabled:u},"aria-checked":t,"aria-disabled":u,style:({pressed:e})=>[H.segment,T?H.segmentMultiline:null,{paddingHorizontal:F.paddingHorizontal,opacity:e&&!t?.7:1},x],children:[o?_jsx(View,{style:H.segmentIcon,children:o}):null,_jsx(Text,{style:[H.segmentLabel,T?H.segmentLabelMultiline:null,{color:i,fontSize:F.fontSize,fontWeight:t?I.typography.fontWeight.semibold:I.typography.fontWeight.medium},v,C],numberOfLines:M,children:e.label})]},String(e.value))})]}),!se||R||re.active?null:_jsx(View,{pointerEvents:"none",style:[StyleSheet.absoluteFill,{borderWidth:ae,borderColor:ne,borderRadius:V?B:G,...smoothCorners}]})]});return de||ue?_jsxs(View,{style:{alignSelf:c?"stretch":"flex-start"},children:[de?_jsx(FieldLabel,{size:d,children:o}):null,me,ue?_jsx(FieldMessage,{size:d,text:ce,error:le}):null]}):me});SegmentedControl.displayName="SegmentedControl";const buildStyles=e=>StyleSheet.create({track:{flexDirection:"row",alignItems:"stretch",position:"relative"},row:{flex:1,flexDirection:"row",alignItems:"stretch",position:"relative",overflow:"hidden"},thumb:{position:"absolute",left:0},segment:{flex:1,flexDirection:"row",alignItems:"center",justifyContent:"center"},segmentIcon:{marginRight:6},segmentMultiline:{paddingVertical:6},segmentLabel:{includeFontPadding:!1},segmentLabelMultiline:{flexShrink:1,textAlign:"center"}});export{SegmentedControl};export default SegmentedControl;
@@ -1 +1 @@
1
- "use strict";import{forwardRef,useCallback,useMemo,useState}from"react";import{StyleSheet,Text,View}from"react-native";import{useTheme}from"../../theme/index.js";import{resolveHaptic,triggerHaptic}from"../../utils/index.js";import{renderSlotIcon}from"../AppIcon/slotIcon.js";import{Chevron}from"../FieldBase/Chevron.js";import{FieldBase,FieldLabel,FieldMessage,fieldTextAsString,hasFieldText,RequiredMark,resolveFieldSize,resolveFieldTextStyle,resolveVariantColors}from"../FieldBase/FieldBase.js";import{OptionSheet}from"../OptionSheet/OptionSheet.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const sameSelectValue=(e,l)=>String(e)===String(l),containsValue=(e,l)=>e.some(e=>sameSelectValue(e,l)),Select=forwardRef((e,l)=>{const{options:t,getOptionLabel:i,getOptionValue:o,getOptionDisabled:r,getOptionDescription:s,getOptionIcon:n,placeholder:a,searchable:d=!1,haptic:c,label:u,help:p,title:f,required:S=!1,error:b,helperText:g,prefix:h,numberOfLines:x=1,disabled:m=!1,size:v="md",variant:y,leftIcon:j,rightIcon:F,chevronColor:C,chevronSize:O,borderRadius:T,accessibilityLabel:V,labelStyle:k,style:z,triggerStyle:_,textStyle:I,optionStyle:H,selectedOptionStyle:R,optionTextStyle:w,selectedOptionTextStyle:L,testID:M}=e,D=!0===e.multi,B=useCallback(e=>i?i(e):e.label??"",[i]),P=useCallback(e=>o?o(e):e.value,[o]),q=useCallback(e=>r?r(e):!0===e.disabled,[r]),A=useCallback(e=>s?s(e):e.description,[s]),E=useCallback(e=>n?n(e):e.icon,[n]),N=useTheme(),$=useMemo(()=>buildStyles(N),[N]),G=resolveFieldSize(N,v),J=resolveFieldTextStyle(N,{disabled:m}),K=y??N.components.select?.defaultVariant??N.components.field?.defaultVariant??"outlined",Q=useMemo(()=>{const e=N.components.select?.fillColors?.[K];if(!e)return;const l={};return void 0!==e.idleEmpty&&(l.backgroundIdleEmpty=e.idleEmpty),void 0!==e.idleFilled&&(l.backgroundIdleFilled=e.idleFilled),void 0!==e.focus&&(l.backgroundFocused=e.focus),void 0!==e.error&&(l.backgroundError=e.error),void 0!==e.disabled&&(l.backgroundDisabled=e.disabled),Object.keys(l).length>0?l:void 0},[N.components.select?.fillColors,K]),U=T??N.components.select?.borderRadius,[W,X]=useState(!1),Y=useCallback(l=>{if(D){const t=e.value??[];return containsValue(t,l)}return null!=e.value&&sameSelectValue(e.value,l)},[D,e.value]),Z=useMemo(()=>{if(D){const l=e.value??[];return t.filter(e=>containsValue(l,P(e)))}const l=e.value;if(null==l)return[];const i=t.find(e=>sameSelectValue(P(e),l));return i?[i]:[]},[D,t,e.value,P]),ee=useCallback(()=>{if(m)return;const e=resolveHaptic(c,"selection");e&&triggerHaptic(e),X(!0)},[m,c]),le=useCallback(()=>{X(!1)},[]),te=useCallback(l=>{if(q(l))return;const t=P(l),i=resolveHaptic(c,"selection");if(i&&triggerHaptic(i),D){const l=e.value??[],i=containsValue(l,t)?l.filter(e=>!sameSelectValue(e,t)):[...l,t];return void e.onChange(i)}e.onChange(t),le()},[D,e,le,q,P,c]),ie=0===Z.length?a??"Select…":Z.map(e=>B(e)).join(", "),oe=0===Z.length,re=!0===b||hasFieldText(b),se=hasFieldText(u),ne=fieldTextAsString(u),ae=Math.round(1.4*G.fontSize),de={color:m?N.colors.field.iconDisabled:W?N.colors.field.iconFocused:N.colors.field.icon,size:G.iconSize,disabled:m,focused:W,error:re},ce=0===Z.length?a??"No selection":`Selected: ${Z.map(e=>B(e)).join(", ")}`,ue=V??`${ne??"Select"}. ${ce}`;return _jsxs(View,{style:[$.container,z],testID:M,children:[se?_jsx(FieldLabel,{size:v,required:S,help:p,style:k,children:u}):null,_jsx(View,{ref:l,collapsable:!1,children:_jsxs(FieldBase,{size:v,variant:K,disabled:m,error:re,filled:Z.length>0,onPress:ee,borderRadius:U,fillOverrides:Q,paddingHorizontal:"underline"===K?0:void 0,accessibilityRole:"button",accessibilityLabel:ue,accessibilityState:{disabled:m,expanded:W},"aria-disabled":m,"aria-expanded":W,style:_,slotAlign:1===x?"center":"top",slotLineHeight:1===x?void 0:ae,leading:j?_jsx(View,{children:renderSlotIcon(j,de)}):null,trailing:F?_jsx(View,{children:renderSlotIcon(F,de)}):_jsx(Chevron,{color:C??(m?N.colors.text.disabled:N.colors.text.tertiary),size:O??G.iconSize,open:W,style:$.chevron}),children:[hasFieldText(h)?"string"==typeof h||"number"==typeof h?_jsx(Text,{style:[$.prefix,{color:J.placeholderColor,fontSize:G.fontSize,lineHeight:1===x?void 0:ae,marginRight:N.spacing.xs}],children:h}):_jsx(View,{style:[$.prefixNode,{minHeight:1===x?void 0:ae,justifyContent:"center",marginRight:N.spacing.xs}],children:h}):null,_jsxs(Text,{style:[$.triggerText,{color:oe?J.placeholderColor:J.color,fontSize:G.fontSize,lineHeight:1===x?void 0:ae,...J.weightStyle},I],numberOfLines:x,children:[ie,oe&&S&&!se?_jsx(RequiredMark,{}):null]})]})}),_jsx(FieldMessage,{size:v,error:re,text:re?b:g}),_jsx(OptionSheet,{open:W,onClose:le,title:f??ne,accessibilityLabel:ne??(se?f:void 0)??a??"Options",options:t,labelOf:B,getValue:P,disabledOf:q,descriptionOf:A,iconOf:E,isSelected:Y,onSelect:te,multi:D,searchable:d,optionStyle:H,selectedOptionStyle:R,optionTextStyle:w,selectedOptionTextStyle:L,searchSelectionColor:resolveVariantColors(N,K,Q).borderFocusedRepresentative})]})});Select.displayName="Select";const buildStyles=e=>StyleSheet.create({container:{width:"100%"},label:{includeFontPadding:!1},triggerText:{flex:1,includeFontPadding:!1},errorText:{includeFontPadding:!1},prefix:{flexShrink:0,includeFontPadding:!1},prefixNode:{flexShrink:0},chevron:{marginLeft:8}});export{Select};export default Select;
1
+ "use strict";import{forwardRef,useCallback,useMemo,useState}from"react";import{StyleSheet,Text,View}from"react-native";import{useTheme}from"../../theme/index.js";import{resolveHaptic,triggerHaptic}from"../../utils/index.js";import{renderSlotIcon}from"../AppIcon/slotIcon.js";import{Chevron}from"../FieldBase/Chevron.js";import{FieldBase,FieldLabel,FieldMessage,fieldTextAsString,hasFieldText,RequiredMark,resolveFieldSize,resolveFieldTextStyle,resolveVariantColors}from"../FieldBase/FieldBase.js";import{NotationInkContext}from"../Notation/Notation.js";import{OptionSheet}from"../OptionSheet/OptionSheet.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const sameSelectValue=(e,t)=>String(e)===String(t),containsValue=(e,t)=>e.some(e=>sameSelectValue(e,t)),Select=forwardRef((e,t)=>{const{options:l,getOptionLabel:i,getOptionValue:o,getOptionDisabled:r,getOptionDescription:n,getOptionIcon:s,placeholder:a,onOpenChange:d,searchable:c=!1,haptic:u,label:p,help:f,title:S,required:h=!1,error:x,helperText:g,prefix:b,numberOfLines:m=1,disabled:v=!1,size:y="md",variant:C,leftIcon:j,rightIcon:F,chevronColor:O,chevronSize:k,borderRadius:z,accessibilityLabel:T,labelStyle:V,style:_,triggerStyle:I,textStyle:H,optionStyle:R,selectedOptionStyle:w,optionTextStyle:L,selectedOptionTextStyle:M,testID:N}=e,D=!0===e.multi,P=useCallback(e=>i?i(e):e.label??"",[i]),B=useCallback(e=>o?o(e):e.value,[o]),q=useCallback(e=>r?r(e):!0===e.disabled,[r]),A=useCallback(e=>n?n(e):e.description,[n]),E=useCallback(e=>s?s(e):e.icon,[s]),$=useTheme(),G=useMemo(()=>buildStyles($),[$]),J=resolveFieldSize($,y),K=resolveFieldTextStyle($,{disabled:v}),Q=C??$.components.select?.defaultVariant??$.components.field?.defaultVariant??"outlined",U=useMemo(()=>{const e=$.components.select?.fillColors?.[Q];if(!e)return;const t={};return void 0!==e.idleEmpty&&(t.backgroundIdleEmpty=e.idleEmpty),void 0!==e.idleFilled&&(t.backgroundIdleFilled=e.idleFilled),void 0!==e.focus&&(t.backgroundFocused=e.focus),void 0!==e.error&&(t.backgroundError=e.error),void 0!==e.disabled&&(t.backgroundDisabled=e.disabled),Object.keys(t).length>0?t:void 0},[$.components.select?.fillColors,Q]),W=z??$.components.select?.borderRadius,[X,Y]=useState(!1),Z=useCallback(t=>{if(D){const l=e.value??[];return containsValue(l,t)}return null!=e.value&&sameSelectValue(e.value,t)},[D,e.value]),ee=useMemo(()=>{if(D){const t=e.value??[];return l.filter(e=>containsValue(t,B(e)))}const t=e.value;if(null==t)return[];const i=l.find(e=>sameSelectValue(B(e),t));return i?[i]:[]},[D,l,e.value,B]),te=useCallback(()=>{if(v)return;const e=resolveHaptic(u,"selection");e&&triggerHaptic(e),Y(!0)},[v,u]),le=useCallback(()=>{Y(!1)},[]),ie=useCallback(t=>{if(q(t))return;const l=B(t),i=resolveHaptic(u,"selection");if(i&&triggerHaptic(i),D){const t=e.value??[],i=containsValue(t,l)?t.filter(e=>!sameSelectValue(e,l)):[...t,l];return void e.onChange(i)}e.onChange(l),le()},[D,e,le,q,B,u]),oe=0===ee.length?a??"Select…":ee.map(e=>P(e)).join(", "),re=0===ee.length,ne=!0===x||hasFieldText(x),se=hasFieldText(p),ae=fieldTextAsString(p),de=Math.round(1.4*J.fontSize),ce=useMemo(()=>({fontSize:J.fontSize,color:K.placeholderColor}),[J.fontSize,K.placeholderColor]),ue={color:v?$.colors.field.iconDisabled:X?$.colors.field.iconFocused:$.colors.field.icon,size:J.iconSize,disabled:v,focused:X,error:ne},pe=0===ee.length?a??"No selection":`Selected: ${ee.map(e=>P(e)).join(", ")}`,fe=T??`${ae??"Select"}. ${pe}`;return _jsxs(View,{style:[G.container,_],testID:N,children:[se?_jsx(FieldLabel,{size:y,required:h,help:f,style:V,children:p}):null,_jsx(View,{ref:t,collapsable:!1,children:_jsxs(FieldBase,{size:y,variant:Q,disabled:v,error:ne,filled:ee.length>0,onPress:te,borderRadius:W,fillOverrides:U,paddingHorizontal:"underline"===Q?0:void 0,accessibilityRole:"button",accessibilityLabel:fe,accessibilityState:{disabled:v,expanded:X},"aria-disabled":v,"aria-expanded":X,style:I,slotAlign:1===m?"center":"top",slotLineHeight:1===m?void 0:de,leading:j?_jsx(View,{children:renderSlotIcon(j,ue)}):null,trailing:F?_jsx(View,{children:renderSlotIcon(F,ue)}):_jsx(Chevron,{color:O??(v?$.colors.text.disabled:$.colors.text.tertiary),size:k??J.iconSize,open:X,style:G.chevron}),children:[hasFieldText(b)?"string"==typeof b||"number"==typeof b?_jsx(Text,{style:[G.prefix,{color:K.placeholderColor,fontSize:J.fontSize,lineHeight:1===m?void 0:de,marginRight:$.spacing.xs}],children:b}):_jsx(View,{style:[G.prefixNode,{minHeight:1===m?void 0:de,justifyContent:"center",marginRight:$.spacing.xs}],children:_jsx(Text,{style:[G.prefix,{color:K.placeholderColor,fontSize:J.fontSize,lineHeight:1===m?void 0:de}],children:_jsx(NotationInkContext.Provider,{value:ce,children:b})})}):null,_jsxs(Text,{style:[G.triggerText,{color:re?K.placeholderColor:K.color,fontSize:J.fontSize,lineHeight:1===m?void 0:de,...K.weightStyle},H],numberOfLines:m,children:[oe,re&&h&&!se?_jsx(RequiredMark,{}):null]})]})}),_jsx(FieldMessage,{size:y,error:ne,text:ne?x:g}),_jsx(OptionSheet,{open:X,onClose:le,onOpenChange:d,title:S??ae,accessibilityLabel:ae??(se?S:void 0)??a??"Options",options:l,labelOf:P,getValue:B,disabledOf:q,descriptionOf:A,iconOf:E,isSelected:Z,onSelect:ie,multi:D,searchable:c,optionStyle:R,selectedOptionStyle:w,optionTextStyle:L,selectedOptionTextStyle:M,searchSelectionColor:resolveVariantColors($,Q,U).borderFocusedRepresentative})]})});Select.displayName="Select";const buildStyles=e=>StyleSheet.create({container:{width:"100%"},label:{includeFontPadding:!1},triggerText:{flex:1,includeFontPadding:!1},errorText:{includeFontPadding:!1},prefix:{flexShrink:0,includeFontPadding:!1},prefixNode:{flexShrink:0},chevron:{marginLeft:8}});export{Select};export default Select;
@@ -0,0 +1 @@
1
+ "use strict";import{formatDateTime}from"@webority/mobile-core";import{forwardRef,memo,useCallback,useEffect,useImperativeHandle,useMemo,useRef,useState}from"react";import{AccessibilityInfo,PixelRatio,Platform,StyleSheet,View}from"react-native";import{Gesture,GestureDetector}from"react-native-gesture-handler";import Svg,{Path,Rect,Text as SvgText}from"react-native-svg";import{lightTheme,useTheme}from"../../theme/index.js";import{announce}from"../../utils/announce.js";import{smoothCorners}from"../../utils/corners.js";import{Button}from"../Button/index.js";import{Input}from"../Input/index.js";import{Text}from"../Text/index.js";import{BASELINE_RATIO,buildSignatureSvg,distanceBetween,FALLBACK_WIDTH,pointOf,strokePath,typedFontSize}from"./signatureGeometry.js";import{writePng}from"./writePng";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const DEFAULT_LABELS={pad:"Signature pad",padHint:"Draw with one finger. To sign without drawing, use the type your name action.",caption:"Sign above the line. To start with an up or down stroke, rest your finger a moment first.",typedCaption:"Your typed name is used as your signature.",undo:"Undo",clear:"Clear",typeInstead:"Type your name instead",drawInstead:"Draw instead",typedLabel:"Type your name",typedPlaceholder:"Your full name",empty:"Not signed",signed:"Signed",typingAnnouncement:"Signing by typing your name. Your typed name is used as your signature. Choose Draw instead to sign with your finger.",drawingAnnouncement:"Signing by drawing. Use one finger on the pad.",clearedAnnouncement:"Signature cleared",undoneAnnouncement:"Last stroke removed",emptyError:"Add a signature first."},STROKE_WIDTH=2.5,SIDEWAYS_TO_DRAW=6,UPRIGHT_TO_SCROLL=8,REST_TO_DRAW_MS=200,MIN_POINT_GAP=.8,DEFAULT_HEIGHT=180,DEFAULT_NAME_LENGTH=100,MAX_EXPORT_SCALE=3,MIN_TARGET=44,BASELINE_OPACITY=.3,DISABLED_OPACITY=.5,TARGET_STYLE={minHeight:44},defaultScriptFont=()=>Platform.select({ios:"Snell Roundhand",default:"cursive"}),cssFontStack=e=>"cursive"===e?"cursive":`'${e}', cursive`,useScreenReader=()=>{const[e,t]=useState(!1);return useEffect(()=>{let e=!0;AccessibilityInfo.isScreenReaderEnabled().then(n=>{e&&t(n)});const n=AccessibilityInfo.addEventListener("screenReaderChanged",t);return()=>{e=!1,n.remove()}},[]),e},StrokePath=memo(({points:e,color:t})=>_jsx(Path,{d:strokePath(e),stroke:t,strokeWidth:2.5,strokeLinecap:"round",strokeLinejoin:"round",fill:"none"}));StrokePath.displayName="SignaturePadStroke";const SignaturePad=forwardRef((e,t)=>{const{initialStrokes:n,onChange:r,initialTypedName:a="",onTypedNameChange:o,defaultMode:i="draw",onModeChange:s,onEmptyChange:l,allowTyped:d=!0,signedBy:c,signedAt:u,height:p=DEFAULT_HEIGHT,maxNameLength:m=DEFAULT_NAME_LENGTH,inkColor:g,paperColor:h,scriptFontFamily:y,labels:f,haptic:S="selection",disabled:T=!1,style:w,testID:b}=e,E=useTheme(),A=g??lightTheme.colors.text.primary,x=h??lightTheme.colors.background.elevated,_=y??defaultScriptFont(),C=useMemo(()=>({...DEFAULT_LABELS,...f}),[f]),v=useScreenReader(),I=useRef(null),[L,R]=useState(0),[P,j]=useState(()=>(n??[]).map((e,t)=>({id:t+1,points:[...e]}))),D=useRef(P),k=useRef(P.length),N=useRef(null),F=useRef(null),[M,B]=useState(d?i:"draw"),[O,G]=useState(a),[H,Y]=useState(null),U=useRef(!1),W=useRef({onChange:r,onTypedNameChange:o,onModeChange:s,onEmptyChange:l});useEffect(()=>{W.current={onChange:r,onTypedNameChange:o,onModeChange:s,onEmptyChange:l}});const $="draw"===M&&!T,z="draw"===M?0===P.length:0===O.trim().length,V=useRef(null);useEffect(()=>{V.current!==z&&(V.current=z,W.current.onEmptyChange?.(z))},[z]);const K=useCallback(e=>{D.current=e,j(e)},[]),X=useCallback(()=>{Y(Date.now()),W.current.onChange?.(D.current.map(e=>e.points))},[]),J=useMemo(()=>{const pan=e=>Gesture.Pan().enabled($).runOnJS(!0).onBegin(e=>{N.current=pointOf(e.x,e.y)}).onStart(t=>{F.current=e,k.current+=1;const n=pointOf(t.x,t.y);K([...D.current,{id:k.current,points:[N.current??n,n]}])}).onUpdate(t=>{if(F.current!==e)return;const n=D.current[D.current.length-1],r=pointOf(t.x,t.y);distanceBetween(n.points[n.points.length-1],r)<.8||K([...D.current.slice(0,-1),{...n,points:[...n.points,r]}])}).onFinalize(()=>{F.current===e&&(F.current=null,X())}),e=pan("sideways").activeOffsetX([-6,6]).failOffsetY([-8,8]),t=pan("rested").activateAfterLongPress(200);return Gesture.Race(e,t)},[$,K,X]),q=useCallback(e=>{B(e),W.current.onModeChange?.(e),announce("type"===e?C.typingAnnouncement:C.drawingAnnouncement)},[C.typingAnnouncement,C.drawingAnnouncement]);useEffect(()=>{v&&d&&!U.current&&"draw"===M&&0===D.current.length&&q("type")},[v,d,M,q]);const Q=useCallback(()=>{U.current=!0,q("draw"===M?"type":"draw")},[M,q]),Z=useCallback(e=>{G(e),Y(Date.now()),W.current.onTypedNameChange?.(e)},[]),ee=useCallback(()=>{"type"===M?Z(""):(K([]),X()),announce(C.clearedAnnouncement)},[M,Z,K,X,C.clearedAnnouncement]),te=useCallback(()=>{"draw"===M&&0!==D.current.length&&(K(D.current.slice(0,-1)),X(),announce(C.undoneAnnouncement))},[M,K,X,C.undoneAnnouncement]),ne=L||FALLBACK_WIDTH;useImperativeHandle(t,()=>({toFile:()=>new Promise((e,t)=>{if(z)return void t(new Error(C.emptyError));if(!I.current)return void t(new Error("The signature pad is not on screen."));const n=Math.min(3,Math.max(1,PixelRatio.get()));I.current.toDataURL(n=>{try{e(writePng(n))}catch(e){t(e)}},{width:ne*n,height:p*n})}),toSvg:()=>buildSignatureSvg({width:ne,height:p,mode:M,strokes:P.map(e=>e.points),typedName:O,ink:A,paper:x,strokeWidth:2.5,fontFamily:cssFontStack(_)}),clear:ee,undo:te,isEmpty:()=>z}),[z,C.emptyError,ne,p,M,P,O,A,x,_,ee,te]);const re=useMemo(()=>[{name:"undo",label:C.undo},{name:"clear",label:C.clear},...d?[{name:"toggleMode",label:"draw"===M?C.typeInstead:C.drawInstead}]:[]],[C.undo,C.clear,C.typeInstead,C.drawInstead,d,M]),ae=useCallback(e=>{if(T)return;const{actionName:t}=e.nativeEvent;"undo"===t?te():"clear"===t?ee():"toggleMode"===t&&d&&Q()},[T,te,ee,Q,d]),oe=useCallback(e=>{R(e.nativeEvent.layout.width)},[]),ie=useMemo(()=>StyleSheet.create({root:{gap:E.spacing.sm},pad:{height:p,borderWidth:E.colors.border.width,borderColor:E.colors.border.primary,borderRadius:E.radius.md,...smoothCorners,overflow:"hidden",backgroundColor:x,opacity:T?.5:1},baseline:{position:"absolute",left:E.spacing.md,right:E.spacing.md,top:p*BASELINE_RATIO,height:StyleSheet.hairlineWidth,backgroundColor:A,opacity:.3},actions:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",flexWrap:"wrap",gap:E.spacing.xs},trailing:{flexDirection:"row",alignItems:"center",gap:E.spacing.xs}}),[E,p,x,A,T]),se=O.trim(),le=u??H,de=c&&!z?`Signed by ${c}${le?`, ${formatDateTime(le)}`:""}`:null,ce="type"===M&&se?`${C.pad}. ${se}`:C.pad;return _jsxs(View,{style:[ie.root,w],testID:b,children:[_jsx(GestureDetector,{gesture:J,children:_jsxs(View,{style:ie.pad,onLayout:oe,accessible:!0,accessibilityRole:"image",accessibilityLabel:ce,accessibilityHint:"draw"===M?C.padHint:void 0,accessibilityValue:{text:z?C.empty:C.signed},accessibilityState:{disabled:T},"aria-disabled":T,accessibilityActions:re,onAccessibilityAction:ae,children:[_jsxs(Svg,{ref:I,width:"100%",height:p,children:[_jsx(Rect,{x:"0",y:"0",width:"100%",height:"100%",fill:x}),"draw"===M?P.map(e=>_jsx(StrokePath,{points:e.points,color:A},e.id)):null,"type"===M&&se?_jsx(SvgText,{x:ne/2,y:p*BASELINE_RATIO,fontSize:typedFontSize(ne,se),fontFamily:_,textAnchor:"middle",fill:A,children:se}):null]}),_jsx(View,{pointerEvents:"none",style:ie.baseline})]})}),"type"===M?_jsx(Input,{label:C.typedLabel,placeholder:C.typedPlaceholder,value:O,onChangeText:Z,maxLength:m,disabled:T,autoComplete:"name",textContentType:"name",autoCapitalize:"words",autoCorrect:!1,returnKeyType:"done",testID:b?`${b}-name`:void 0}):null,_jsx(Text,{variant:"caption",color:"tertiary",children:"draw"===M?C.caption:C.typedCaption}),_jsxs(View,{style:ie.actions,children:[d?_jsx(Button,{title:"draw"===M?C.typeInstead:C.drawInstead,variant:"ghost",tone:"primary",size:"md",style:TARGET_STYLE,haptic:S,disabled:T,onPress:Q,testID:b?`${b}-mode`:void 0}):_jsx(View,{}),"draw"===M&&P.length>0?_jsxs(View,{style:ie.trailing,children:[_jsx(Button,{title:C.undo,variant:"ghost",tone:"primary",size:"md",style:TARGET_STYLE,haptic:S,disabled:T,onPress:te,testID:b?`${b}-undo`:void 0}),_jsx(Button,{title:C.clear,variant:"ghost",tone:"primary",size:"md",style:TARGET_STYLE,haptic:S,disabled:T,onPress:ee,testID:b?`${b}-clear`:void 0})]}):null,"type"===M&&se?_jsx(Button,{title:C.clear,variant:"ghost",tone:"primary",size:"md",style:TARGET_STYLE,haptic:S,disabled:T,onPress:ee,testID:b?`${b}-clear`:void 0}):null]}),de?_jsx(Text,{variant:"caption",color:"secondary",children:de}):null]})});SignaturePad.displayName="SignaturePad";export{SignaturePad};export default SignaturePad;
@@ -0,0 +1 @@
1
+ "use strict";export{SignaturePad}from"./SignaturePad.js";
@@ -0,0 +1 @@
1
+ "use strict";export const FALLBACK_WIDTH=320;const MIN_FONT_SIZE=18,MAX_FONT_SIZE=56,SCRIPT_ADVANCE=.5,TYPED_WIDTH_SHARE=.88;export const BASELINE_RATIO=.7;const oneDecimal=t=>Math.round(10*t)/10;export const pointOf=(t,e)=>[oneDecimal(t),oneDecimal(e)];export const distanceBetween=(t,e)=>Math.hypot(t[0]-e[0],t[1]-e[1]);const format=t=>t.toFixed(1);export const strokePath=t=>{if(0===t.length)return"";const[e,...o]=t,r=[`M${format(e[0])} ${format(e[1])}`];if(0===o.length)return r.push(`L${format(e[0])} ${format(e[1])}`),r.join(" ");if(1===o.length)return r.push(`L${format(o[0][0])} ${format(o[0][1])}`),r.join(" ");for(let t=0;t<o.length-1;t+=1){const e=o[t],n=o[t+1],a=(e[0]+n[0])/2,s=(e[1]+n[1])/2;r.push(`Q${format(e[0])} ${format(e[1])} ${format(a)} ${format(s)}`)}const n=o[o.length-1];return r.push(`L${format(n[0])} ${format(n[1])}`),r.join(" ")};export const typedFontSize=(t,e)=>{const o=Math.max(1,e.length),r=Math.floor(.88*t/(.5*o));return Math.min(56,Math.max(18,r))};export const escapeXml=t=>t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;");export const buildSignatureSvg=t=>{const{width:e,height:o,mode:r,strokes:n,typedName:a,ink:s,paper:i,strokeWidth:p,fontFamily:c}=t,h=Math.round(e),l=Math.round(o),m=[`<rect x="0" y="0" width="${h}" height="${l}" fill="${escapeXml(i)}"/>`];if("type"===r){const t=a.trim();t&&m.push(`<text x="${h/2}" y="${format(.7*l)}" text-anchor="middle" font-family="${escapeXml(c)}" font-size="${typedFontSize(h,t)}" fill="${escapeXml(s)}">${escapeXml(t)}</text>`)}else for(const t of n)m.push(`<path d="${strokePath(t)}" fill="none" stroke="${escapeXml(s)}" stroke-width="${p}" stroke-linecap="round" stroke-linejoin="round"/>`);return`<svg xmlns="http://www.w3.org/2000/svg" width="${h}" height="${l}" viewBox="0 0 ${h} ${l}">${m.join("")}</svg>`};
@@ -0,0 +1 @@
1
+ "use strict";export const writePng=e=>{const{File:t,Paths:r}=require("expo-file-system"),i=new t(r.cache,`signature-${Date.now().toString(36)}.png`);return i.create({intermediates:!0,overwrite:!0}),i.write(e,{encoding:"base64"}),i.uri};
@@ -0,0 +1 @@
1
+ "use strict";export const writePng=t=>`data:image/png;base64,${t}`;
@@ -0,0 +1 @@
1
+ "use strict";import{formatNumber}from"@webority/mobile-core";import{forwardRef,useCallback,useMemo,useState}from"react";import{StyleSheet,View}from"react-native";import Svg,{Circle,Path}from"react-native-svg";import{useTheme}from"../../theme/index.js";import{finiteValues,sparklineGeometry}from"./geometry.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const DOT_RADIUS=3,lineColor=(e,t)=>"neutral"===t?e.colors.text.secondary:e.colors.toneText[t],defaultFormat=e=>formatNumber(e),Sparkline=forwardRef((e,t)=>{const{data:r,tone:i="primary",color:o,fill:l=!1,highlightLast:s=!0,height:a=32,width:n,strokeWidth:m=2,label:h,formatLabel:c=defaultFormat,accessibilityLabel:f,style:u,testID:d}=e,y=useTheme(),[p,x]=useState(0),g=n??p,k=useCallback(e=>{if(void 0===n){const t=Math.round(e.nativeEvent.layout.width);x(e=>e===t?e:t)}},[n]),S=Math.max(3,m/2)+1,b=useMemo(()=>sparklineGeometry(r,g,a,S),[r,g,a,S]),v=o??lineColor(y,i),j=useMemo(()=>{if(void 0!==f)return f;const e=finiteValues(r),t=h?`${h}, `:"";if(0===e.length)return`${t}no data`;if(1===e.length)return`${t}${c(e[0])}`;return`${t}from ${c(e[0])} to ${c(e[e.length-1])}, low ${c(Math.min(...e))}, high ${c(Math.max(...e))}`},[f,r,c,h]);return _jsx(View,{ref:t,accessible:!0,accessibilityRole:"image",accessibilityLabel:j,testID:d,onLayout:k,style:[styles.root,void 0===n?styles.stretch:{width:n},{height:a},u],children:""===b.line?null:_jsxs(Svg,{width:g,height:a,viewBox:`0 0 ${g} ${a}`,children:[l?_jsx(Path,{d:b.area,fill:v,fillOpacity:.14,stroke:"none"}):null,_jsx(Path,{d:b.line,fill:"none",stroke:v,strokeWidth:m,strokeLinecap:"round",strokeLinejoin:"round",testID:d?`${d}-line`:void 0}),s&&b.last?_jsx(Circle,{cx:b.last.x,cy:b.last.y,r:3,fill:v,testID:d?`${d}-dot`:void 0}):null]})})});Sparkline.displayName="Sparkline";const styles=StyleSheet.create({root:{overflow:"hidden"},stretch:{alignSelf:"stretch"}});export{Sparkline};export default Sparkline;
@@ -0,0 +1 @@
1
+ "use strict";const finite=n=>n.filter(n=>Number.isFinite(n)),round=n=>(Math.round(100*n)/100).toString();export const sparklineGeometry=(n,t,e,r)=>{const i=finite(n);if(0===i.length||t<=0||e<=0)return{line:"",area:"",last:null};const a=Math.min(...i),o=Math.max(...i),u=Math.max(0,t-2*r),l=Math.max(0,e-2*r),s=o-a,h=i.map((n,a)=>({x:1===i.length?t/2:r+a*u/(i.length-1),y:0===s?e/2:r+(o-n)/s*l})),x=h.map((n,t)=>`${0===t?"M":"L"}${round(n.x)} ${round(n.y)}`).join(" "),d=h[0],m=h[h.length-1];return{line:x,area:`${x} L${round(m.x)} ${round(e)} L${round(d.x)} ${round(e)} Z`,last:m}};export const finiteValues=finite;
@@ -0,0 +1 @@
1
+ "use strict";export{default,Sparkline}from"./Sparkline.js";
@@ -1 +1 @@
1
- "use strict";import{forwardRef,useEffect,useMemo,useRef}from"react";import{ActivityIndicator,Animated,Easing,StyleSheet,Text,View}from"react-native";import{createAnimatedValue,useTheme}from"../../theme/index.js";import{smoothCorners}from"../../utils/corners.js";import{squircleHostRadius}from"../../utils/squircle.js";import{SquircleFill,useSquircle}from"../SquircleFill/SquircleFill.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const sizeMap={sm:20,md:32,lg:48},DOT_COUNT=3,DOT_STAGGER_MS=150,DOT_CYCLE_MS=600,Dot=({size:e,color:t,delay:i,duration:r})=>{const s=useRef(createAnimatedValue(1)).current;return useEffect(()=>{const e=Animated.loop(Animated.sequence([Animated.delay(i),Animated.timing(s,{toValue:1.4,duration:r/2,easing:Easing.out(Easing.quad),useNativeDriver:!0}),Animated.timing(s,{toValue:1,duration:r/2,easing:Easing.in(Easing.quad),useNativeDriver:!0})]));return e.start(),()=>{e.stop()}},[s,i,r]),_jsx(Animated.View,{style:{width:e,height:e,borderRadius:e/2,...smoothCorners,backgroundColor:t,transform:[{scale:s}]}})},Spinner=forwardRef((e,t)=>{const{size:i="md",color:r,message:s,overlay:n=!1,backdropColor:o,variant:a="circular",accessibilityLabel:l,style:c,testID:u}=e,d=useTheme(),m=useRef(createAnimatedValue(0)).current;useEffect(()=>{Animated.timing(m,{toValue:1,duration:d.motion.duration.normal,easing:Easing.bezier(...d.motion.easing.standard),useNativeDriver:!0}).start()},[m,d]);const g=useMemo(()=>buildStyles(d),[d]),y=sizeMap[i],h=r??d.colors.primary,p=o??d.colors.background.overlay,f=useMemo(()=>{if("dots"===a){const e=Math.max(6,Math.round(y/4));return _jsx(View,{style:[g.dotsRow,{gap:Math.round(e/2)}],children:Array.from({length:3}).map((t,i)=>_jsx(Dot,{size:e,color:h,delay:150*i,duration:600},i))})}return _jsx(ActivityIndicator,{color:h,size:"sm"===i?"small":"large",style:{width:y,height:y}})},[a,i,y,h,g.dotsRow]),b=l??s??"Loading",x=useSquircle(n,d.radius.lg),S=x.active&&x.size?{borderRadius:squircleHostRadius(x.size.width,x.size.height,d.radius.lg)}:null,j=_jsxs(Animated.View,{ref:t,accessible:!0,accessibilityRole:"progressbar",accessibilityLiveRegion:"polite",accessibilityLabel:b,accessibilityState:{busy:!0},"aria-busy":!0,testID:u,onLayout:x.onLayout,style:[n?g.overlayContent:g.inlineContent,S,{opacity:m}],children:[x.active&&x.size?_jsx(SquircleFill,{width:x.size.width,height:x.size.height,radius:d.radius.lg,fill:d.colors.background.elevated}):null,f,s?_jsx(Text,{style:[g.message,{color:d.colors.text.primary,fontSize:d.typography.fontSize.base,fontWeight:d.typography.fontWeight.medium,marginTop:d.spacing.md}],numberOfLines:2,children:s}):null]});return _jsx(View,n?{pointerEvents:"auto",style:[g.overlay,{backgroundColor:p},c],children:j}:{style:[g.inline,c],children:j})});Spinner.displayName="Spinner";const buildStyles=e=>StyleSheet.create({inline:{alignItems:"center",justifyContent:"center"},inlineContent:{alignItems:"center",justifyContent:"center"},overlay:{...StyleSheet.absoluteFill,alignItems:"center",justifyContent:"center",zIndex:1e3},overlayContent:{alignItems:"center",justifyContent:"center",backgroundColor:e.colors.background.elevated,borderRadius:e.radius.lg,...smoothCorners,paddingHorizontal:e.spacing.xl,paddingVertical:e.spacing.xl,minWidth:140,...e.shadows.lg},dotsRow:{flexDirection:"row",alignItems:"center",justifyContent:"center"},message:{textAlign:"center"}});export{Spinner};export default Spinner;
1
+ "use strict";import{forwardRef,useEffect,useMemo,useRef}from"react";import{ActivityIndicator,Animated,Easing,StyleSheet,Text,View}from"react-native";import{createAnimatedValue,useTheme}from"../../theme/index.js";import{announce}from"../../utils/announce.js";import{blendOf}from"../../utils/color.js";import{smoothCorners}from"../../utils/corners.js";import{squircleHostRadius}from"../../utils/squircle.js";import{SquircleFill,useSquircle}from"../SquircleFill/SquircleFill.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const sizeMap={sm:20,md:32,lg:48},CONTAINER_RATIO=1.5,DOT_COUNT=3,DOT_STAGGER_MS=150,DOT_CYCLE_MS=600,Dot=({size:e,color:t,delay:i,duration:n})=>{const r=useRef(createAnimatedValue(1)).current;return useEffect(()=>{const e=Animated.loop(Animated.sequence([Animated.delay(i),Animated.timing(r,{toValue:1.4,duration:n/2,easing:Easing.out(Easing.quad),useNativeDriver:!0}),Animated.timing(r,{toValue:1,duration:n/2,easing:Easing.in(Easing.quad),useNativeDriver:!0})]));return e.start(),()=>{e.stop()}},[r,i,n]),_jsx(Animated.View,{style:{width:e,height:e,borderRadius:e/2,...smoothCorners,backgroundColor:t,transform:[{scale:r}]}})},Spinner=forwardRef((e,t)=>{const{size:i="md",color:n,message:r,overlay:o=!1,backdropColor:s,variant:a="circular",accessibilityLabel:l,style:c,testID:d}=e,u="contained"===a,m=o&&!u,g=useTheme(),y=useRef(createAnimatedValue(0)).current;useEffect(()=>{Animated.timing(y,{toValue:1,duration:g.motion.duration.normal,easing:Easing.bezier(...g.motion.easing.standard),useNativeDriver:!0}).start()},[y,g]);const f=useMemo(()=>buildStyles(g),[g]),h=sizeMap[i],p=n??g.colors.primary,b=s??g.colors.background.overlay,j=useMemo(()=>{if("contained"===a){const e=Math.round(1.5*h);return _jsx(View,{style:[f.container,{width:e,height:e,borderRadius:e/2,backgroundColor:blendOf(p,.14,g.colors.background.elevated,g.colors.background.secondary)}],children:_jsx(ActivityIndicator,{color:p,size:"sm"===i?"small":"large",style:{width:h,height:h}})})}if("dots"===a){const e=Math.max(6,Math.round(h/4));return _jsx(View,{style:[f.dotsRow,{gap:Math.round(e/2)}],children:Array.from({length:3}).map((t,i)=>_jsx(Dot,{size:e,color:p,delay:150*i,duration:600},i))})}return _jsx(ActivityIndicator,{color:p,size:"sm"===i?"small":"large",style:{width:h,height:h}})},[a,i,h,p,f.dotsRow,f.container,g.colors.background.elevated,g.colors.background.secondary]),x=l??r??"Loading",C=useRef(x);C.current=x,useEffect(()=>{u&&announce(C.current)},[u]);const S=useSquircle(m,g.radius.lg),v=S.active&&S.size?{borderRadius:squircleHostRadius(S.size.width,S.size.height,g.radius.lg)}:null;let w=f.inlineContent;m?w=f.overlayContent:u&&(w=f.containedContent);const z=_jsxs(Animated.View,{ref:t,accessible:!0,accessibilityRole:"progressbar",accessibilityLiveRegion:u?"none":"polite",accessibilityLabel:x,accessibilityState:{busy:!0},"aria-busy":!0,testID:d,onLayout:S.onLayout,style:[w,v,{opacity:y}],children:[S.active&&S.size?_jsx(SquircleFill,{width:S.size.width,height:S.size.height,radius:g.radius.lg,fill:g.colors.background.elevated}):null,j,r?_jsx(Text,{style:[f.message,{color:g.colors.text.primary,fontSize:g.typography.fontSize.base,fontWeight:g.typography.fontWeight.medium,marginTop:g.spacing.md}],numberOfLines:2,children:r}):null]});return _jsx(View,m?{pointerEvents:"auto",style:[f.overlay,{backgroundColor:b},c],children:z}:{style:[u?f.containedFill:f.inline,c],children:z})});Spinner.displayName="Spinner";const buildStyles=e=>StyleSheet.create({inline:{alignItems:"center",justifyContent:"center"},inlineContent:{alignItems:"center",justifyContent:"center"},containedFill:{flex:1,alignSelf:"stretch",alignItems:"center",justifyContent:"center",minHeight:Math.round(1.5*sizeMap.lg)+2*e.spacing.xl},containedContent:{alignItems:"center",justifyContent:"center",paddingHorizontal:e.spacing.lg},container:{alignItems:"center",justifyContent:"center"},overlay:{...StyleSheet.absoluteFill,alignItems:"center",justifyContent:"center",zIndex:1e3},overlayContent:{alignItems:"center",justifyContent:"center",backgroundColor:e.colors.background.elevated,borderRadius:e.radius.lg,...smoothCorners,paddingHorizontal:e.spacing.xl,paddingVertical:e.spacing.xl,minWidth:140,...e.shadows.lg},dotsRow:{flexDirection:"row",alignItems:"center",justifyContent:"center"},message:{textAlign:"center"}});export{Spinner};export default Spinner;
@@ -1 +1 @@
1
- "use strict";import{forwardRef}from"react";import{StyleSheet,View}from"react-native";import{useTheme}from"../../theme/index.js";import{Card}from"../Card/index.js";import{IconBadge}from"../IconBadge/index.js";import{Skeleton}from"../Skeleton/index.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const isText=e=>"string"==typeof e||"number"==typeof e,StatTile=forwardRef((e,t)=>{const{label:i,value:s,icon:r,iconVariant:n,tone:o="primary",caption:l,onPress:a,loading:c=!1,accessibilityLabel:x,style:d,testID:m}=e,h=useTheme(),p=x??(isText(s)?`${i}, ${s}`:void 0);return _jsx(Card,c?{ref:t,variant:"outlined",style:d,testID:m,children:_jsxs(View,{style:[styles.row,{columnGap:h.spacing.md}],children:[void 0===r?null:_jsx(Skeleton,{shape:"circle",width:40,height:40}),_jsxs(View,{style:styles.text,children:[_jsx(Skeleton,{shape:"text",width:"50%",height:12}),_jsx(Skeleton,{shape:"text",width:"35%",height:24,style:{marginTop:h.spacing.xs}})]})]})}:{ref:t,variant:"outlined",onPress:a,accessibilityLabel:p,style:d,testID:m,children:_jsxs(View,{style:[styles.row,{columnGap:h.spacing.md}],children:[void 0===r?null:_jsx(IconBadge,{icon:r,iconVariant:n,tone:o}),_jsxs(View,{style:styles.text,children:[_jsx(Text,{variant:"caption",color:"secondary",numberOfLines:1,children:i}),isText(s)?_jsx(Text,{variant:"h3",numberOfLines:1,children:s}):s,null==l||""===l?null:isText(l)?_jsx(Text,{variant:"caption",color:"tertiary",numberOfLines:1,children:l}):l]})]})})});StatTile.displayName="StatTile";const styles=StyleSheet.create({row:{flexDirection:"row",alignItems:"center"},text:{flex:1,minWidth:0}});export{StatTile};export default StatTile;
1
+ "use strict";import{formatPercent}from"@webority/mobile-core";import{forwardRef}from"react";import{StyleSheet,View}from"react-native";import{useTheme}from"../../theme/index.js";import{AppIcon}from"../AppIcon/index.js";import{Card}from"../Card/index.js";import{IconBadge}from"../IconBadge/index.js";import{Skeleton}from"../Skeleton/index.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const isText=e=>"string"==typeof e||"number"==typeof e,TREND_ICON={up:"arrow-up",down:"arrow-down",flat:"minus"},TREND_WORD={up:"up",down:"down",flat:"no change"},TREND_SIGN={up:"+",down:"-",flat:""},percentText=e=>formatPercent(Math.abs(e),{scale:"percent",maximumFractionDigits:1}),trendFigure=e=>"number"==typeof e.value?`${TREND_SIGN[e.direction]}${percentText(e.value)}`:e.value,trendSpoken=e=>{const t=[TREND_WORD[e.direction]];return"flat"!==e.direction&&t.push("number"==typeof e.value?percentText(e.value):e.value),e.period&&t.push(e.period),t.join(" ")},StatTile=forwardRef((e,t)=>{const{label:r,value:n,icon:i,iconVariant:o,tone:s="primary",caption:l,trend:a,sparkline:c,onPress:d,loading:p=!1,accessibilityLabel:x,style:m,testID:u}=e,h=useTheme(),f=a?`, ${trendSpoken(a)}`:"",y=x??(isText(n)?`${r}, ${n}${f}`:void 0),T=!!a&&a.direction===(a.goodWhen??"up"),j=a&&"flat"!==a.direction?T?"success":"error":"secondary",w="secondary"===j?h.colors.text.secondary:h.colors.toneText[j];return _jsx(Card,p?{ref:t,variant:"outlined",style:m,testID:u,children:_jsxs(View,{style:[styles.row,{columnGap:h.spacing.md}],children:[void 0===i?null:_jsx(Skeleton,{shape:"circle",width:40,height:40}),_jsxs(View,{style:styles.text,children:[_jsx(Skeleton,{shape:"text",width:"50%",height:12}),_jsx(Skeleton,{shape:"text",width:"35%",height:24,style:{marginTop:h.spacing.xs}})]})]})}:{ref:t,variant:"outlined",onPress:d,accessibilityLabel:y,style:m,testID:u,children:_jsxs(View,{style:[styles.row,{columnGap:h.spacing.md}],children:[void 0===i?null:_jsx(IconBadge,{icon:i,iconVariant:o,tone:s}),_jsxs(View,{style:styles.text,children:[_jsx(Text,{variant:"caption",color:"secondary",numberOfLines:1,children:r}),isText(n)?_jsx(Text,{variant:"h3",numberOfLines:1,children:n}):n,a?_jsxs(View,{style:[styles.trend,{columnGap:h.spacing.xxs}],testID:u?`${u}-trend`:void 0,children:[_jsx(AppIcon,{name:TREND_ICON[a.direction],size:"xs",color:w}),_jsxs(Text,{variant:"caption",color:j,numberOfLines:2,style:styles.text,children:[trendFigure(a),a.period?_jsx(Text,{variant:"caption",color:"tertiary",children:` ${a.period}`}):null]})]}):null,null==l||""===l?null:isText(l)?_jsx(Text,{variant:"caption",color:"tertiary",numberOfLines:1,children:l}):l,null==c?null:_jsx(View,{style:{marginTop:h.spacing.sm},children:c})]})]})})});StatTile.displayName="StatTile";const styles=StyleSheet.create({row:{flexDirection:"row",alignItems:"center"},text:{flex:1,minWidth:0},trend:{flexDirection:"row",alignItems:"center"}});export{StatTile};export default StatTile;
@@ -1 +1 @@
1
- "use strict";import{forwardRef,useEffect,useMemo,useRef}from"react";import{Animated,Easing,Pressable,StyleSheet,View}from"react-native";import{useControllableState}from"../../hooks/index.js";import{createAnimatedValue,useTheme}from"../../theme/index.js";import{smoothCorners}from"../../utils/corners.js";import{triggerHaptic}from"../../utils/hapticUtils.js";import{ChoiceText,hasChoiceDetail}from"../FieldBase/ChoiceText.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const sizeMap={sm:{trackWidth:42,trackHeight:26,thumbSize:22,padding:2},md:{trackWidth:51,trackHeight:31,thumbSize:27,padding:2},lg:{trackWidth:60,trackHeight:36,thumbSize:32,padding:2}},toneColor=(e,t)=>{switch(t){case"success":return e.colors.success;case"warning":return e.colors.warning;case"error":return e.colors.error;default:return e.colors.primary}},Switch=forwardRef((e,t)=>{const{value:i,defaultValue:s,onChange:r,disabled:a=!1,size:o="md",tone:n="primary",label:c,description:l,error:d,labelLines:u,layout:m="inline",accessibilityLabel:h,haptic:p="selection",bounce:b=!1,style:f,containerStyle:g,trackStyle:y,thumbStyle:w,testID:x,...S}=e,[C,k]=useControllableState({value:i,defaultValue:s??!1,onChange:r}),j=useTheme(),R={...sizeMap[o],...j.components.switch?.[o]??{}},v=j.components.switch?.thumbColor??"#FFFFFF",V=useMemo(()=>buildStyles(j),[j]),A="dark"===j.mode?j.colors.secondary:j.colors.surface.disabled,D=toneColor(j,n),H=useRef(createAnimatedValue(C?1:0)).current;useEffect(()=>{const e=Animated.spring(H,{toValue:C?1:0,damping:j.motion.spring.snappy.damping,stiffness:j.motion.spring.snappy.stiffness,mass:j.motion.spring.snappy.mass,useNativeDriver:!0});return e.start(),()=>e.stop()},[C,H,j.motion.spring.snappy]);const T=useRef(createAnimatedValue(C?1:0)).current;useEffect(()=>{const e=Animated.timing(T,{toValue:C?1:0,duration:j.motion.duration.fast,easing:Easing.out(Easing.ease),useNativeDriver:!1});return e.start(),()=>e.stop()},[C,T,j.motion.duration.fast]);const z=R.padding,_=R.trackWidth-R.thumbSize-R.padding,L=H.interpolate({inputRange:[0,1],outputRange:[z,_]}),E=T.interpolate({inputRange:[0,1],outputRange:[A,D]}),F=useRef(createAnimatedValue(1)).current,P=useRef(!0);useEffect(()=>{if(!b)return;if(P.current)return void(P.current=!1);const e=Animated.sequence([Animated.spring(F,{toValue:1.15,damping:10,stiffness:220,mass:1,useNativeDriver:!0}),Animated.spring(F,{toValue:1,damping:14,stiffness:240,mass:1,useNativeDriver:!0})]);return e.start(),()=>e.stop()},[C,b,F]);const handlePress=e=>{a||(!1!==p&&triggerHaptic(p),k(!C),S.onPressOut?.(e))},I=h??c,N=Boolean(c)||hasChoiceDetail(l,d),W="row"===m&&N,M=_jsx(Animated.View,{style:[V.track,{width:R.trackWidth,height:R.trackHeight,borderRadius:R.trackHeight/2,...smoothCorners,backgroundColor:E},y],children:_jsx(Animated.View,{style:[V.thumb,j.shadows.sm,{backgroundColor:v,width:R.thumbSize,height:R.thumbSize,borderRadius:R.thumbSize/2,...smoothCorners,transform:[{translateX:L},{scale:F}]},w]})});if(W)return _jsxs(Pressable,{ref:t,onPress:handlePress,disabled:a,accessibilityRole:"switch",accessibilityLabel:I,accessibilityHint:S.accessibilityHint??l,accessibilityState:{checked:C,disabled:a},"aria-checked":C,"aria-disabled":a,testID:x,...S,style:({pressed:e})=>[V.row,V.spreadRow,hasChoiceDetail(l,d)?V.rowTop:null,{opacity:a?.55:e?.9:1},g,f],children:[_jsx(ChoiceText,{label:c,description:l,error:d,disabled:a,labelLines:u||void 0,descriptionLines:u||void 0,style:V.spreadText}),M]});const B=_jsx(Pressable,{ref:t,onPress:handlePress,disabled:a,accessibilityRole:"switch",accessibilityLabel:I,accessibilityHint:S.accessibilityHint??l,accessibilityState:{checked:C,disabled:a},"aria-checked":C,"aria-disabled":a,testID:x,hitSlop:8,...S,style:({pressed:e})=>[{opacity:a?.55:e?.9:1},N?null:f],children:M});return N?_jsxs(View,{style:[V.row,hasChoiceDetail(l,d)?V.rowTop:null,g,f],children:[B,_jsx(ChoiceText,{label:c,description:l,error:d,disabled:a,labelLines:u||void 0,descriptionLines:u||void 0,style:V.text})]}):g?_jsx(View,{style:g,children:B}):B});Switch.displayName="Switch";const buildStyles=e=>StyleSheet.create({row:{flexDirection:"row",alignItems:"center"},track:{justifyContent:"center"},thumb:{position:"absolute",top:2},rowTop:{alignItems:"flex-start"},text:{marginLeft:10},spreadRow:{minHeight:44,justifyContent:"space-between"},spreadText:{flex:1,marginRight:12}});export{Switch};export default Switch;
1
+ "use strict";import{forwardRef,useEffect,useMemo,useRef}from"react";import{Animated,Easing,Pressable,StyleSheet,View}from"react-native";import{useControllableState}from"../../hooks/index.js";import{createAnimatedValue,useTheme}from"../../theme/index.js";import{smoothCorners}from"../../utils/corners.js";import{triggerHaptic}from"../../utils/hapticUtils.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 sizeMap={sm:{trackWidth:42,trackHeight:26,thumbSize:22,padding:2},md:{trackWidth:51,trackHeight:31,thumbSize:27,padding:2},lg:{trackWidth:60,trackHeight:36,thumbSize:32,padding:2}},toneColor=(e,t)=>{switch(t){case"success":return e.colors.success;case"warning":return e.colors.warning;case"error":return e.colors.error;default:return e.colors.primary}},Switch=forwardRef((e,t)=>{const{value:i,defaultValue:s,onChange:r,disabled:a=!1,size:o="md",tone:n="primary",label:l,description:c,error:d,labelLines:u,layout:h="inline",accessibilityLabel:m,haptic:p="selection",bounce:b=!1,style:f,containerStyle:g,trackStyle:y,thumbStyle:x,testID:w,...S}=e,[C,j]=useControllableState({value:i,defaultValue:s??!1,onChange:r}),k=useTheme(),R={...sizeMap[o],...k.components.switch?.[o]??{}},T=k.components.switch?.thumbColor??"#FFFFFF",v=useMemo(()=>buildStyles(k),[k]),A="dark"===k.mode?k.colors.secondary:k.colors.surface.disabled,V=toneColor(k,n),F=useRef(createAnimatedValue(C?1:0)).current;useEffect(()=>{const e=Animated.spring(F,{toValue:C?1:0,damping:k.motion.spring.snappy.damping,stiffness:k.motion.spring.snappy.stiffness,mass:k.motion.spring.snappy.mass,useNativeDriver:!0});return e.start(),()=>e.stop()},[C,F,k.motion.spring.snappy]);const H=useRef(createAnimatedValue(C?1:0)).current;useEffect(()=>{const e=Animated.timing(H,{toValue:C?1:0,duration:k.motion.duration.fast,easing:Easing.out(Easing.ease),useNativeDriver:!1});return e.start(),()=>e.stop()},[C,H,k.motion.duration.fast]);const D=R.padding,_=R.trackWidth-R.thumbSize-R.padding,z=F.interpolate({inputRange:[0,1],outputRange:[D,_]}),E=H.interpolate({inputRange:[0,1],outputRange:[A,V]}),L=useRef(createAnimatedValue(1)).current,P=useRef(!0);useEffect(()=>{if(!b)return;if(P.current)return void(P.current=!1);const e=Animated.sequence([Animated.spring(L,{toValue:1.15,damping:10,stiffness:220,mass:1,useNativeDriver:!0}),Animated.spring(L,{toValue:1,damping:14,stiffness:240,mass:1,useNativeDriver:!0})]);return e.start(),()=>e.stop()},[C,b,L]);const handlePress=e=>{a||(!1!==p&&triggerHaptic(p),j(!C),S.onPressOut?.(e))},W=m??fieldTextAsString(l),I=hasFieldText(l)||hasChoiceDetail(c,d),N=(!0===d||hasFieldText(d))&&!C&&!a,M="row"===h&&I,B=_jsxs(Animated.View,{style:[v.track,{width:R.trackWidth,height:R.trackHeight,borderRadius:R.trackHeight/2,...smoothCorners,backgroundColor:E},y],children:[N?_jsx(View,{pointerEvents:"none",style:[v.errorRing,{borderRadius:R.trackHeight/2,...smoothCorners,borderWidth:k.colors.border.width,borderColor:k.colors.field.borderError}]}):null,_jsx(Animated.View,{style:[v.thumb,k.shadows.sm,{backgroundColor:T,width:R.thumbSize,height:R.thumbSize,borderRadius:R.thumbSize/2,...smoothCorners,transform:[{translateX:z},{scale:L}]},x]})]});if(M)return _jsxs(Pressable,{ref:t,onPress:handlePress,disabled:a,accessibilityRole:"switch",accessibilityLabel:W,accessibilityHint:S.accessibilityHint??fieldTextAsString(c),accessibilityState:{checked:C,disabled:a},"aria-checked":C,"aria-disabled":a,testID:w,...S,style:({pressed:e})=>[v.row,v.spreadRow,hasChoiceDetail(c,d)?v.rowTop:null,{opacity:a?.55:e?.9:1},g,f],children:[_jsx(ChoiceText,{label:l,description:c,error:d,disabled:a,labelLines:u||void 0,descriptionLines:u||void 0,style:v.spreadText}),B]});const q=_jsx(Pressable,{ref:t,onPress:handlePress,disabled:a,accessibilityRole:"switch",accessibilityLabel:W,accessibilityHint:S.accessibilityHint??fieldTextAsString(c),accessibilityState:{checked:C,disabled:a},"aria-checked":C,"aria-disabled":a,testID:w,hitSlop:8,...S,style:({pressed:e})=>[{opacity:a?.55:e?.9:1},I?null:f],children:B});return I?_jsxs(View,{style:[v.row,hasChoiceDetail(c,d)?v.rowTop:null,g,f],children:[q,_jsx(ChoiceText,{label:l,description:c,error:d,disabled:a,labelLines:u||void 0,descriptionLines:u||void 0,style:v.text})]}):g?_jsx(View,{style:g,children:q}):q});Switch.displayName="Switch";const buildStyles=e=>StyleSheet.create({row:{flexDirection:"row",alignItems:"center"},track:{justifyContent:"center"},thumb:{position:"absolute",top:2},errorRing:{...StyleSheet.absoluteFill},rowTop:{alignItems:"flex-start"},text:{marginLeft:10},spreadRow:{minHeight:44,justifyContent:"space-between"},spreadText:{flex:1,marginRight:12}});export{Switch};export default Switch;
@@ -1 +1 @@
1
- "use strict";import{forwardRef,useCallback,useMemo,useRef,useState}from"react";import{StyleSheet,TextInput,View}from"react-native";import{useControllableState}from"../../hooks/index.js";import{fontFor,useTheme}from"../../theme/index.js";import{mergeRefs,resolveHaptic,triggerHaptic}from"../../utils/index.js";import{Chip}from"../Chip/index.js";import{FieldBase,hasFieldText}from"../FieldBase/index.js";import{FormField}from"../FormField/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const TagInput=forwardRef((e,t)=>{const{value:r,defaultValue:s,onChange:i,placeholder:l,label:a,helperText:o,error:n,required:u,disabled:d=!1,size:p="md",variant:c,maxTags:m,unique:f=!0,transform:x,separators:h=[","],haptic:g,style:b,testID:j}=e,y=useTheme(),C=useMemo(()=>buildStyles(y),[y]),[T,v]=useControllableState({value:r,defaultValue:s??[],onChange:i}),[F,S]=useState(""),[w,I]=useState(!1),k=useRef(null),_=useMemo(()=>mergeRefs(k,t),[t]),V=useCallback(()=>{d||k.current?.focus()},[d]),H="number"==typeof m&&T.length>=m,R=useCallback(e=>{const t=x?x(e.trim()):e.trim();if(!t)return;if(H)return;if(f&&T.some(e=>e.toLowerCase()===t.toLowerCase()))return void S("");v([...T,t]),S("");const r=resolveHaptic(g,"selection");r&&triggerHaptic(r)},[H,g,v,T,x,f]),z=useCallback(e=>{const t=T.filter((t,r)=>r!==e);v(t);const r=resolveHaptic(g,"selection");r&&triggerHaptic(r)},[g,v,T]),B=useCallback(e=>{const t=h.find(t=>t.length>0&&e.includes(t));if(t){const[r]=e.split(t);return void R(r)}S(e)},[R,h]),D=useCallback(e=>{d||"Backspace"===e.nativeEvent.key&&""===F&&T.length>0&&z(T.length-1)},[d,F,z,T.length]),q=_jsx(FieldBase,{size:p,variant:c,focused:w,disabled:d,error:hasFieldText(n),filled:T.length>0||F.length>0,onPress:V,pressFeedback:!1,style:b,children:_jsxs(View,{style:C.wrap,children:[T.map((e,t)=>_jsx(Chip,{label:e,size:"sm",onClose:d?void 0:()=>z(t),haptic:g},`${e}-${t}`)),_jsx(TextInput,{ref:_,value:F,onChangeText:B,onKeyPress:D,onSubmitEditing:()=>R(F),onFocus:()=>I(!0),onBlur:()=>{I(!1),R(F)},editable:!d&&!H,placeholder:H?void 0:l,placeholderTextColor:y.colors.text.tertiary,blurOnSubmit:!1,returnKeyType:"done",style:[C.input,{color:y.colors.text.primary,fontSize:y.typography.fontSize.base}],testID:j?`${j}-input`:void 0})]})});return a||o||hasFieldText(n)?_jsx(View,{testID:j,children:_jsx(FormField,{label:a,helperText:o,error:n,required:u,children:q})}):_jsx(View,{testID:j,children:q})});TagInput.displayName="TagInput";const buildStyles=e=>StyleSheet.create({wrap:{flex:1,flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:e.spacing.xs,paddingVertical:e.spacing.xs},input:{...fontFor(e,"normal"),flexGrow:1,minWidth:80,padding:0}});export default TagInput;
1
+ "use strict";import{forwardRef,useCallback,useMemo,useRef,useState}from"react";import{StyleSheet,TextInput,View}from"react-native";import{useControllableState}from"../../hooks/index.js";import{fontFor,useTheme}from"../../theme/index.js";import{mergeRefs,resolveHaptic,triggerHaptic}from"../../utils/index.js";import{Chip}from"../Chip/index.js";import{FieldBase,FieldLabel,FieldMessage,hasFieldText}from"../FieldBase/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const TagInput=forwardRef((e,t)=>{const{value:s,defaultValue:r,onChange:i,placeholder:a,label:l,helperText:o,error:n,required:u,disabled:c=!1,size:d="md",variant:p,maxTags:m,unique:f=!0,transform:x,separators:g=[","],haptic:h,style:b,testID:y}=e,C=useTheme(),j=useMemo(()=>buildStyles(C),[C]),[v,S]=useControllableState({value:s,defaultValue:r??[],onChange:i}),[T,F]=useState(""),[w,k]=useState(!1),I=useRef(null),_=useMemo(()=>mergeRefs(I,t),[t]),z=useCallback(()=>{c||I.current?.focus()},[c]),H="number"==typeof m&&v.length>=m,R=!0===n||hasFieldText(n),V=useCallback(e=>{const t=x?x(e.trim()):e.trim();if(!t)return;if(H)return;if(f&&v.some(e=>e.toLowerCase()===t.toLowerCase()))return void F("");S([...v,t]),F("");const s=resolveHaptic(h,"selection");s&&triggerHaptic(s)},[H,h,S,v,x,f]),B=useCallback(e=>{const t=v.filter((t,s)=>s!==e);S(t);const s=resolveHaptic(h,"selection");s&&triggerHaptic(s)},[h,S,v]),L=useCallback(e=>{const t=g.find(t=>t.length>0&&e.includes(t));if(t){const[s]=e.split(t);return void V(s)}F(e)},[V,g]),M=useCallback(e=>{c||"Backspace"===e.nativeEvent.key&&""===T&&v.length>0&&B(v.length-1)},[c,T,B,v.length]),D=_jsx(FieldBase,{size:d,variant:p,focused:w,disabled:c,error:R,filled:v.length>0||T.length>0,onPress:z,pressFeedback:!1,style:b,children:_jsxs(View,{style:j.wrap,children:[v.map((e,t)=>_jsx(Chip,{label:e,size:"sm",onClose:c?void 0:()=>B(t),haptic:h},`${e}-${t}`)),_jsx(TextInput,{ref:_,value:T,onChangeText:L,onKeyPress:M,onSubmitEditing:()=>V(T),onFocus:()=>k(!0),onBlur:()=>{k(!1),V(T)},editable:!c&&!H,placeholder:H?void 0:a,placeholderTextColor:C.colors.text.tertiary,blurOnSubmit:!1,returnKeyType:"done",accessibilityLabel:l??a,style:[j.input,{color:C.colors.text.primary,fontSize:C.typography.fontSize.base}],testID:y?`${y}-input`:void 0})]})});return _jsxs(View,{testID:y,children:[l?_jsx(FieldLabel,{size:d,required:u,children:l}):null,D,_jsx(FieldMessage,{size:d,error:R,text:R?n:o})]})});TagInput.displayName="TagInput";const buildStyles=e=>StyleSheet.create({wrap:{flex:1,flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:e.spacing.xs,paddingVertical:e.spacing.xs},input:{...fontFor(e,"normal"),flexGrow:1,minWidth:80,padding:0}});export default TagInput;
@@ -1 +1 @@
1
- "use strict";import{useCallback,useEffect,useMemo,useRef,useState}from"react";import{AccessibilityInfo,Animated,Easing,Modal,Platform,Pressable,StyleSheet,Text,View}from"react-native";import{GestureDetector,GestureHandlerRootView}from"react-native-gesture-handler";import{useSafeAreaInsets}from"react-native-safe-area-context";import{useDragToDismiss}from"../../hooks/useDragToDismiss.js";import{createAnimatedValue,setNativeValue,useTheme}from"../../theme/index.js";import{smoothCorners}from"../../utils/corners.js";import{resolveHaptic,triggerHaptic}from"../../utils/hapticUtils.js";import Button from"../Button/Button.js";import{PickerTrigger}from"../PickerTrigger/PickerTrigger.js";import{ToastHost}from"../Toast/ToastProvider.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";const ITEM_HEIGHT=40,VISIBLE_ITEMS=5,PICKER_HEIGHT=200,CENTER_OFFSET=Math.floor(2.5),HAPTIC_DEBOUNCE_MS=35,range=(e,t,i=1)=>{const a=[];for(let n=e;n<=t;n+=i)a.push(n);return a},pad2=e=>e.toString().padStart(2,"0"),to24h=(e,t,i)=>"24h"===i?e:"AM"===t?12===e?0:e:12===e?12:e+12,from24h=(e,t)=>"24h"===t?{displayHour:e,period:"AM"}:0===e?{displayHour:12,period:"AM"}:12===e?{displayHour:12,period:"PM"}:e>12?{displayHour:e-12,period:"PM"}:{displayHour:e,period:"AM"},clampMinuteToStep=(e,t)=>{const i=Math.round(e/t)*t;return Math.min(59,Math.max(0,i))},Wheel=({kind:e,label:t,data:i,selectedIndex:a,onIndexChange:n,formatItem:s,theme:r,haptic:o,testID:l})=>{const c=useRef(null),u=useRef(createAnimatedValue(40*a)).current,d=useRef(a),m=useRef(0);useEffect(()=>{if(d.current!==a){d.current=a;const e=40*a;setNativeValue(u,e),requestAnimationFrame(()=>{c.current?.scrollToOffset({offset:e,animated:!1})})}},[a,u]);const p=r.components.timePicker?.hapticDebounceMs??35,h=useMemo(()=>Animated.event([{nativeEvent:{contentOffset:{y:u}}}],{useNativeDriver:!0,listener:e=>{const t=e.nativeEvent.contentOffset.y,a=Math.round(t/40);if(a!==d.current&&a>=0&&a<i.length){const e=Date.now();if(e-m.current>=p){const t=resolveHaptic(o,"selection");t&&triggerHaptic(t),m.current=e}d.current=a}}}),[u,i.length,o,p]),g=useCallback(e=>{const t=e.nativeEvent.contentOffset.y,s=Math.max(0,Math.min(i.length-1,Math.round(t/40)));s!==a&&n(s)},[i.length,n,a]),f=useCallback(e=>{const t=e.nativeEvent.actionName;if("increment"===t){const e=Math.min(i.length-1,a+1);e!==a&&n(e)}else if("decrement"===t){const e=Math.max(0,a-1);e!==a&&n(e)}},[i.length,n,a]),y=useCallback(({item:e,index:t})=>{const i=Animated.subtract(Animated.divide(u,40),t),n=i.interpolate({inputRange:[-2,-1,0,1,2],outputRange:[.3,.6,1,.6,.3],extrapolate:"clamp"}),o=i.interpolate({inputRange:[-2,-1,0,1,2],outputRange:[.85,.95,1.05,.95,.85],extrapolate:"clamp"}),l=t===a;return _jsx(Animated.View,{style:[styles.wheelItem,{opacity:n,transform:[{scale:o}]}],accessible:!1,importantForAccessibility:"no",children:_jsx(Text,{style:[{fontSize:r.typography.fontSize.xl,color:l?r.colors.text.primary:r.colors.text.secondary,fontWeight:l?r.typography.fontWeight.semibold:r.typography.fontWeight.medium,letterSpacing:r.typography.letterSpacing.normal}],children:s(e)})})},[u,a,r,s]),b=useCallback((t,i)=>`${e}-${String(t)}-${i}`,[e]),x=useCallback((e,t)=>({length:40,offset:40*t,index:t}),[]),S=s(i[a]??"");return _jsxs(View,{style:styles.wheelColumn,testID:l,children:[_jsx(View,{pointerEvents:"none",style:styles.wheelA11yLayer,accessible:!0,accessibilityRole:"adjustable",accessibilityLabel:t,accessibilityValue:{text:S},accessibilityActions:[{name:"increment"},{name:"decrement"}],onAccessibilityAction:f}),_jsx(Animated.FlatList,{ref:c,data:i,keyExtractor:b,renderItem:y,getItemLayout:x,showsVerticalScrollIndicator:!1,snapToInterval:40,snapToAlignment:"start",decelerationRate:"fast",bounces:!1,scrollEventThrottle:16,onScroll:h,onMomentumScrollEnd:g,contentContainerStyle:{paddingVertical:40*CENTER_OFFSET},initialScrollIndex:a,style:styles.wheelList,importantForAccessibility:"no-hide-descendants"})]})},TimePicker=e=>{const{visible:t,value:i,onChange:a,onClose:n,format:s="12h",minuteStep:r=1,title:o="Select Time",confirmLabel:l="Confirm",cancelLabel:c="Cancel",testID:u,style:d,containerStyle:m,headerLabelStyle:p,footerButtonStyle:h,label:g,placeholder:f,helperText:y,error:b,required:x,disabled:S,size:v,variant:w,clearable:C,onClear:j,formatValue:k,triggerStyle:T,haptic:I}=e,M=void 0!==e.visible,[_,A]=useState(!1),E=M?t:_,V=M?u:u?`${u}-modal`:void 0,H=useTheme(),D=useSafeAreaInsets(),R=useMemo(()=>buildStyles(H),[H]),P=useRef(createAnimatedValue(0)).current,B=useRef(createAnimatedValue(40)).current,F=useRef(createAnimatedValue(0)).current,L=useRef(0),N=useCallback(()=>{M?n?.():A(!1)},[M,n]),O=useCallback(()=>{Animated.parallel([Animated.timing(P,{toValue:0,duration:H.motion.duration.fast,easing:Easing.bezier(...H.motion.easing.accelerate),useNativeDriver:!1}),Animated.timing(B,{toValue:40,duration:H.motion.duration.fast,easing:Easing.bezier(...H.motion.easing.accelerate),useNativeDriver:!0})]).start(()=>N())},[N,P,B,H.motion.duration.fast,H.motion.easing.accelerate]),{handleGesture:W}=useDragToDismiss({drag:F,travel:()=>L.current||320,onDismiss:O}),$=useMemo(()=>"24h"===s?range(0,23):range(1,12),[s]),z=useMemo(()=>range(0,59,r),[r]),G=useMemo(()=>["AM","PM"],[]),q=useMemo(()=>{const e=i&&Number.isFinite(i.hour)?i.hour:(new Date).getHours(),t=i&&Number.isFinite(i.minute)?i.minute:(new Date).getMinutes(),a=clampMinuteToStep(t,r),{displayHour:n,period:o}=from24h(e,s);return{displayHour:n,minute:a,period:o,hour24:e}},[i,s,r]),[U,K]=useState(()=>{const e=$.indexOf(q.displayHour);return e>=0?e:0}),[Y,J]=useState(()=>{const e=z.indexOf(q.minute);return e>=0?e:0}),[Q,X]=useState(()=>"PM"===q.period?1:0);useEffect(()=>{if(!E)return;const e=i&&Number.isFinite(i.hour)?i.hour:(new Date).getHours(),t=i&&Number.isFinite(i.minute)?i.minute:(new Date).getMinutes(),a=clampMinuteToStep(t,r),{displayHour:n,period:o}=from24h(e,s),l=$.indexOf(n);K(l>=0?l:0);const c=z.indexOf(a);J(c>=0?c:0),X("PM"===o?1:0)},[E,i,s,r,$,z]),useEffect(()=>{let e;return E?(e=Animated.parallel([Animated.timing(P,{toValue:1,duration:H.motion.duration.normal,easing:Easing.out(Easing.cubic),useNativeDriver:!1}),Animated.spring(B,{toValue:0,damping:H.motion.spring.snappy.damping,stiffness:H.motion.spring.snappy.stiffness,mass:H.motion.spring.snappy.mass,useNativeDriver:!0})]),e.start()):(P.setValue(0),setNativeValue(B,40),setNativeValue(F,0)),()=>e?.stop()},[E,P,B,F,H.motion]);const Z=useCallback(e=>{"ios"!==Platform.OS&&"android"!==Platform.OS||AccessibilityInfo.announceForAccessibility(e)},[]),ee=useCallback(e=>{K(e),Z(`Hour ${$[e]}`)},[$,Z]),te=useCallback(e=>{J(e),Z(`${z[e]} minutes`)},[z,Z]),ie=useCallback(e=>{X(e),Z(G[e]??"")},[G,Z]),ae=useCallback(()=>{!1!==I&&triggerHaptic("selection"),O()},[O,I]),ne=useCallback(()=>{const e=$[U]??0,t=G[Q]??"AM",i=to24h(e,t,s),n=z[Y]??0;!1!==I&&triggerHaptic("notificationSuccess"),a?.({hour:i,minute:n}),O()},[$,U,G,Q,z,Y,s,a,O,I]),se=useMemo(()=>{const e=$[U]??0,t=z[Y]??0;if("24h"===s)return`${pad2(e)}:${pad2(t)}`;const i=G[Q]??"AM";return`${pad2(e)}:${pad2(t)} ${i}`},[$,U,z,Y,G,Q,s]),re=useCallback(e=>pad2(Number(e)),[]),oe=useCallback(e=>pad2(Number(e)),[]),le=useCallback(e=>String(e),[]),ce=useCallback(e=>{if("24h"===s)return`${pad2(e.hour)}:${pad2(e.minute)}`;const{displayHour:t,period:i}=from24h(e.hour,"12h");return`${t}:${pad2(e.minute)} ${i}`},[s]),ue=!M&&i&&Number.isFinite(i.hour)&&Number.isFinite(i.minute)?(k??ce)(i):void 0,de=_jsx(Modal,{visible:E,transparent:!0,statusBarTranslucent:!0,navigationBarTranslucent:!0,animationType:"none",onRequestClose:O,testID:V,children:_jsxs(GestureHandlerRootView,{collapsable:!1,style:R.backdrop,children:[_jsx(Pressable,{style:StyleSheet.absoluteFill,onPress:O,accessibilityLabel:"Close time picker",accessibilityRole:"button"}),_jsxs(Animated.View,{style:[R.sheet,{paddingBottom:Math.max(D.bottom,H.spacing.lg),transform:[{translateY:Animated.add(B,F)}]},d,m],onLayout:e=>{L.current=e.nativeEvent.layout.height},accessibilityViewIsModal:!0,accessible:!0,accessibilityRole:"none",accessibilityLabel:o,children:[_jsx(GestureDetector,{gesture:W,children:_jsxs(View,{children:[_jsx(View,{style:R.handle}),_jsx(Text,{style:[R.title,p],accessibilityRole:"header",children:o})]})}),_jsx(View,{style:R.summaryWrap,accessibilityLiveRegion:"polite",accessibilityLabel:`Selected ${se}`,children:_jsx(Text,{style:R.summary,children:se})}),_jsxs(View,{style:R.wheelsRow,children:[_jsxs(View,{pointerEvents:"none",style:R.selectionBand,children:[_jsx(View,{style:R.bandLine}),_jsx(View,{style:[R.bandLine,R.bandLineBottom]})]}),_jsx(Wheel,{kind:"hour",label:"Hour",data:$,selectedIndex:U,onIndexChange:ee,formatItem:re,theme:H,haptic:I,testID:"time-picker-hour"}),_jsx(Text,{style:R.separator,children:":"}),_jsx(Wheel,{kind:"minute",label:"Minute",data:z,selectedIndex:Y,onIndexChange:te,formatItem:oe,theme:H,haptic:I,testID:"time-picker-minute"}),"12h"===s?_jsxs(_Fragment,{children:[_jsx(View,{style:R.spacer}),_jsx(Wheel,{kind:"period",label:"Period",data:G,selectedIndex:Q,onIndexChange:ie,formatItem:le,theme:H,haptic:I,testID:"time-picker-period"})]}):null]}),_jsxs(View,{style:R.footer,children:[_jsx(Button,{title:c,haptic:!1,variant:"ghost",tone:"neutral",onPress:ae,style:[R.footerBtn,h],accessibilityHint:"Dismiss without changes",testID:"time-picker-cancel"}),_jsx(Button,{title:l,variant:"solid",tone:"primary",haptic:!1,onPress:ne,style:[R.footerBtn,h],accessibilityHint:"Confirm selected time",testID:"time-picker-confirm"})]})]}),_jsx(ToastHost,{})]})});return M?de:_jsxs(_Fragment,{children:[_jsx(PickerTrigger,{label:g,placeholder:f,helperText:y,error:b,required:x,disabled:S,size:v,variant:w,clearable:C,onClear:j,value:ue,onPress:()=>A(!0),triggerStyle:T,testID:u}),de]})},styles=StyleSheet.create({wheelColumn:{width:64,height:200,overflow:"hidden"},wheelList:{flexGrow:0,height:200},wheelItem:{height:40,alignItems:"center",justifyContent:"center"},wheelA11yLayer:{...StyleSheet.absoluteFill,zIndex:2}}),buildStyles=e=>{const t=e.shadows.xl;return StyleSheet.create({backdrop:{flex:1,backgroundColor:e.colors.background.overlay,justifyContent:"flex-end"},sheet:{backgroundColor:e.colors.background.elevated,borderTopLeftRadius:e.radius.xl,borderTopRightRadius:e.radius.xl,...smoothCorners,paddingTop:e.spacing.sm,paddingHorizontal:e.spacing.lg,paddingBottom:e.spacing.xl,shadowColor:t.shadowColor,shadowOffset:t.shadowOffset,shadowOpacity:t.shadowOpacity,shadowRadius:t.shadowRadius,elevation:t.elevation},handle:{alignSelf:"center",width:e.components.timePicker?.handleWidth??36,height:e.components.timePicker?.handleHeight??4,borderRadius:e.radius.full,...smoothCorners,backgroundColor:e.colors.border.secondary,marginBottom:e.spacing.sm},title:{textAlign:"center",fontSize:e.typography.fontSize.lg,fontWeight:e.typography.fontWeight.semibold,color:e.colors.text.primary,marginBottom:e.spacing.sm},summaryWrap:{alignItems:"center",marginBottom:e.spacing.md},summary:{fontSize:e.typography.fontSize["2xl"],fontWeight:e.typography.fontWeight.bold,color:e.colors.primary,letterSpacing:e.typography.letterSpacing.wide},wheelsRow:{flexDirection:"row",alignItems:"center",justifyContent:"center",height:200,position:"relative",marginBottom:e.spacing.lg},selectionBand:{position:"absolute",left:0,right:0,top:40*CENTER_OFFSET,height:40,justifyContent:"space-between"},bandLine:{height:2*StyleSheet.hairlineWidth,backgroundColor:e.colors.primary,opacity:.85},bandLineBottom:{},separator:{fontSize:e.typography.fontSize["2xl"],fontWeight:e.typography.fontWeight.bold,color:e.colors.text.primary,paddingHorizontal:e.spacing.xs},spacer:{width:e.spacing.md},footer:{flexDirection:"row",justifyContent:"flex-end",alignItems:"center",gap:e.spacing.sm},footerBtn:{paddingHorizontal:e.spacing.lg}})};export{TimePicker};export default TimePicker;
1
+ "use strict";import{useCallback,useEffect,useMemo,useRef,useState}from"react";import{Animated,Easing,Modal,Pressable,StyleSheet,Text,View}from"react-native";import{GestureDetector,GestureHandlerRootView}from"react-native-gesture-handler";import{useSafeAreaInsets}from"react-native-safe-area-context";import{useDragToDismiss}from"../../hooks/useDragToDismiss.js";import{createAnimatedValue,setNativeValue,useTheme}from"../../theme/index.js";import{smoothCorners}from"../../utils/corners.js";import{triggerHaptic}from"../../utils/hapticUtils.js";import Button from"../Button/Button.js";import{PickerTrigger}from"../PickerTrigger/PickerTrigger.js";import{ToastHost}from"../Toast/ToastProvider.js";import{WheelPicker}from"../WheelPicker/index.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";const range=(e,t,i=1)=>{const r=[];for(let a=e;a<=t;a+=i)r.push(a);return r},pad2=e=>e.toString().padStart(2,"0"),to24h=(e,t,i)=>"24h"===i?e:"AM"===t?12===e?0:e:12===e?12:e+12,from24h=(e,t)=>"24h"===t?{displayHour:e,period:"AM"}:0===e?{displayHour:12,period:"AM"}:12===e?{displayHour:12,period:"PM"}:e>12?{displayHour:e-12,period:"PM"}:{displayHour:e,period:"AM"},clampMinuteToStep=(e,t)=>{const i=Math.round(e/t)*t;return Math.min(59,Math.max(0,i))},TimePicker=e=>{const{visible:t,value:i,onChange:r,onClose:a,format:s="12h",minuteStep:o=1,title:n="Select Time",confirmLabel:l="Confirm",cancelLabel:u="Cancel",testID:m,style:c,containerStyle:d,headerLabelStyle:p,footerButtonStyle:g,label:h,placeholder:f,helperText:y,error:b,required:x,disabled:v,size:M,variant:k,clearable:S,onClear:j,formatValue:T,triggerStyle:w,haptic:C}=e,D=void 0!==e.visible,[H,P]=useState(!1),A=D?t:H,V=D?m:m?`${m}-modal`:void 0,_=useTheme(),R=useSafeAreaInsets(),B=useMemo(()=>buildStyles(_),[_]),N=useRef(createAnimatedValue(0)).current,$=useRef(createAnimatedValue(40)).current,I=useRef(createAnimatedValue(0)).current,L=useRef(0),z=useCallback(()=>{D?a?.():P(!1)},[D,a]),F=useCallback(()=>{Animated.parallel([Animated.timing(N,{toValue:0,duration:_.motion.duration.fast,easing:Easing.bezier(..._.motion.easing.accelerate),useNativeDriver:!1}),Animated.timing($,{toValue:40,duration:_.motion.duration.fast,easing:Easing.bezier(..._.motion.easing.accelerate),useNativeDriver:!0})]).start(()=>z())},[z,N,$,_.motion.duration.fast,_.motion.easing.accelerate]),{handleGesture:O}=useDragToDismiss({drag:I,travel:()=>L.current||320,onDismiss:F}),W=useMemo(()=>"24h"===s?range(0,23):range(1,12),[s]),E=useMemo(()=>range(0,59,o),[o]),G=useMemo(()=>["AM","PM"],[]),q=useMemo(()=>{const e=i&&Number.isFinite(i.hour)?i.hour:(new Date).getHours(),t=i&&Number.isFinite(i.minute)?i.minute:(new Date).getMinutes(),r=clampMinuteToStep(t,o),{displayHour:a,period:n}=from24h(e,s);return{displayHour:a,minute:r,period:n,hour24:e}},[i,s,o]),[U,Y]=useState(()=>{const e=W.indexOf(q.displayHour);return e>=0?e:0}),[J,K]=useState(()=>{const e=E.indexOf(q.minute);return e>=0?e:0}),[Q,X]=useState(()=>"PM"===q.period?1:0);useEffect(()=>{if(!A)return;const e=i&&Number.isFinite(i.hour)?i.hour:(new Date).getHours(),t=i&&Number.isFinite(i.minute)?i.minute:(new Date).getMinutes(),r=clampMinuteToStep(t,o),{displayHour:a,period:n}=from24h(e,s),l=W.indexOf(a);Y(l>=0?l:0);const u=E.indexOf(r);K(u>=0?u:0),X("PM"===n?1:0)},[A,i,s,o,W,E]),useEffect(()=>{let e;return A?(e=Animated.parallel([Animated.timing(N,{toValue:1,duration:_.motion.duration.normal,easing:Easing.out(Easing.cubic),useNativeDriver:!1}),Animated.spring($,{toValue:0,damping:_.motion.spring.snappy.damping,stiffness:_.motion.spring.snappy.stiffness,mass:_.motion.spring.snappy.mass,useNativeDriver:!0})]),e.start()):(N.setValue(0),setNativeValue($,40),setNativeValue(I,0)),()=>e?.stop()},[A,N,$,I,_.motion]);const Z=useCallback((e,t)=>{"hour"===e?Y(Math.max(0,W.indexOf(Number(t)))):"minute"===e?K(Math.max(0,E.indexOf(Number(t)))):X("PM"===t?1:0)},[W,E]),ee=useCallback(()=>{!1!==C&&triggerHaptic("selection"),F()},[F,C]),te=useCallback(()=>{const e=W[U]??0,t=G[Q]??"AM",i=to24h(e,t,s),a=E[J]??0;!1!==C&&triggerHaptic("notificationSuccess"),r?.({hour:i,minute:a}),F()},[W,U,G,Q,E,J,s,r,F,C]),ie=useMemo(()=>{const e=W[U]??0,t=E[J]??0;if("24h"===s)return`${pad2(e)}:${pad2(t)}`;const i=G[Q]??"AM";return`${pad2(e)}:${pad2(t)} ${i}`},[W,U,E,J,G,Q,s]),re=useMemo(()=>W.map(e=>({value:e,label:pad2(e),accessibilityLabel:`Hour ${e}`})),[W]),ae=useMemo(()=>E.map(e=>({value:e,label:pad2(e),accessibilityLabel:`${e} minutes`})),[E]),se=useMemo(()=>G.map(e=>({value:e,label:e})),[G]),oe=useMemo(()=>{const e=[{key:"hour",label:"Hour",items:re,value:W[U]??0,separator:":",testID:"time-picker-hour"},{key:"minute",label:"Minute",items:ae,value:E[J]??0,gapAfter:"12h"===s?_.spacing.md:void 0,testID:"time-picker-minute"}];return"12h"===s&&e.push({key:"period",label:"Period",items:se,value:G[Q]??"AM",testID:"time-picker-period"}),e},[re,ae,se,W,U,E,J,G,Q,s,_.spacing.md]),ne=useCallback(e=>{if("24h"===s)return`${pad2(e.hour)}:${pad2(e.minute)}`;const{displayHour:t,period:i}=from24h(e.hour,"12h");return`${t}:${pad2(e.minute)} ${i}`},[s]),le=!D&&i&&Number.isFinite(i.hour)&&Number.isFinite(i.minute)?(T??ne)(i):void 0,ue=_jsx(Modal,{visible:A,transparent:!0,statusBarTranslucent:!0,navigationBarTranslucent:!0,animationType:"none",onRequestClose:F,testID:V,children:_jsxs(GestureHandlerRootView,{collapsable:!1,style:B.backdrop,children:[_jsx(Pressable,{style:StyleSheet.absoluteFill,onPress:F,accessibilityLabel:"Close time picker",accessibilityRole:"button"}),_jsxs(Animated.View,{style:[B.sheet,{paddingBottom:Math.max(R.bottom,_.spacing.lg),transform:[{translateY:Animated.add($,I)}]},c,d],onLayout:e=>{L.current=e.nativeEvent.layout.height},accessibilityViewIsModal:!0,accessible:!0,accessibilityRole:"none",accessibilityLabel:n,children:[_jsx(GestureDetector,{gesture:O,children:_jsxs(View,{children:[_jsx(View,{style:B.handle}),_jsx(Text,{style:[B.title,p],accessibilityRole:"header",children:n})]})}),_jsx(View,{style:B.summaryWrap,accessibilityLiveRegion:"polite",accessibilityLabel:`Selected ${ie}`,children:_jsx(Text,{style:B.summary,children:ie})}),_jsx(WheelPicker,{columns:oe,onChange:Z,haptic:C,style:B.wheels}),_jsxs(View,{style:B.footer,children:[_jsx(Button,{title:u,haptic:!1,variant:"ghost",tone:"neutral",onPress:ee,style:[B.footerBtn,g],accessibilityHint:"Dismiss without changes",testID:"time-picker-cancel"}),_jsx(Button,{title:l,variant:"solid",tone:"primary",haptic:!1,onPress:te,style:[B.footerBtn,g],accessibilityHint:"Confirm selected time",testID:"time-picker-confirm"})]})]}),_jsx(ToastHost,{})]})});return D?ue:_jsxs(_Fragment,{children:[_jsx(PickerTrigger,{label:h,placeholder:f,helperText:y,error:b,required:x,disabled:v,size:M,variant:k,clearable:S,onClear:j,value:le,onPress:()=>P(!0),triggerStyle:w,testID:m}),ue]})},buildStyles=e=>{const t=e.shadows.xl;return StyleSheet.create({backdrop:{flex:1,backgroundColor:e.colors.background.overlay,justifyContent:"flex-end"},sheet:{backgroundColor:e.colors.background.elevated,borderTopLeftRadius:e.radius.xl,borderTopRightRadius:e.radius.xl,...smoothCorners,paddingTop:e.spacing.sm,paddingHorizontal:e.spacing.lg,paddingBottom:e.spacing.xl,shadowColor:t.shadowColor,shadowOffset:t.shadowOffset,shadowOpacity:t.shadowOpacity,shadowRadius:t.shadowRadius,elevation:t.elevation},handle:{alignSelf:"center",width:e.components.timePicker?.handleWidth??36,height:e.components.timePicker?.handleHeight??4,borderRadius:e.radius.full,...smoothCorners,backgroundColor:e.colors.border.secondary,marginBottom:e.spacing.sm},title:{textAlign:"center",fontSize:e.typography.fontSize.lg,fontWeight:e.typography.fontWeight.semibold,color:e.colors.text.primary,marginBottom:e.spacing.sm},summaryWrap:{alignItems:"center",marginBottom:e.spacing.md},summary:{fontSize:e.typography.fontSize["2xl"],fontWeight:e.typography.fontWeight.bold,color:e.colors.primary,letterSpacing:e.typography.letterSpacing.wide},wheels:{marginBottom:e.spacing.lg},footer:{flexDirection:"row",justifyContent:"flex-end",alignItems:"center",gap:e.spacing.sm},footerBtn:{paddingHorizontal:e.spacing.lg}})};export{TimePicker};export default TimePicker;
@@ -1 +1 @@
1
- "use strict";import{useEffect,useMemo,useRef}from"react";import{Animated,Easing,PanResponder,Pressable,StyleSheet,Text,View}from"react-native";import{createAnimatedValue,fontFor,setNativeValue,useTheme}from"../../theme/index.js";import{smoothCorners}from"../../utils/corners.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const DEFAULT_SWIPE_DISMISS_THRESHOLD=80,DEFAULT_SWIPE_VELOCITY_THRESHOLD=.5,DEFAULT_STACK_OFFSET=8,DEFAULT_STACK_SCALE_STEP=.04,DEFAULT_AUTO_DISMISS_MS=3e3,Toast=({toast:e,index:t,onDismiss:s,shownAt:i})=>{const n=useTheme(),r=e.variant??"default",o=e.position??"bottom",a=useMemo(()=>buildStyles(n),[n]),l=useMemo(()=>tintFor(n,r),[n,r]),c=useMemo(()=>inkFor(n,r),[n,r]),d=n.components.toast,u=d?.iconCircleSize??28,m=d?.iconCircleBorderRadius??14,p=d?.iconGlyphFontSize??16,f=d?.tintBarWidth??0,g=d?.swipeDismissThreshold??80,h=d?.swipeVelocityThreshold??.5,y=d?.stackOffset??8,x=d?.stackScaleStep??.04,S=d?.stackMinScale??.9,b=d?.defaultDurationMs??3e3,v=d?.enableSwipeDismiss??!0,A=d?.enterSpringDamping??18,T=d?.enterSpringStiffness??180,w=d?.enterSpringMass??1,V="top"===o?-120:120,D=useRef(createAnimatedValue(V)).current,_=useRef(createAnimatedValue(0)).current,R=useRef(createAnimatedValue(0)).current,M=useRef(!1),C="top"===o?t*y:-t*y,E=Math.max(1-t*x,S),j=useRef(createAnimatedValue(C)).current;useEffect(()=>{setNativeValue(j,C)},[C,j]);const L=useMemo(()=>Animated.add(D,j),[D,j]),dismiss=()=>{M.current||(M.current=!0,Animated.parallel([Animated.timing(R,{toValue:0,duration:n.motion.duration.fast,easing:Easing.bezier(...n.motion.easing.accelerate),useNativeDriver:!0}),Animated.timing(D,{toValue:V,duration:n.motion.duration.fast,easing:Easing.bezier(...n.motion.easing.accelerate),useNativeDriver:!0})]).start(()=>s(e.id)))};useEffect(()=>{const t=Animated.parallel([Animated.spring(D,{toValue:0,damping:A,stiffness:T,mass:w,useNativeDriver:!0}),Animated.timing(R,{toValue:1,duration:n.motion.duration.fast,useNativeDriver:!0})]);t.start();const s=e.duration??b;if(s>0){const e=void 0===i?0:Date.now()-i,n=setTimeout(()=>dismiss(),Math.max(s-e,0));return()=>{t.stop(),clearTimeout(n)}}return()=>t.stop()},[]);const F=useMemo(()=>PanResponder.create({onMoveShouldSetPanResponder:(e,t)=>Math.abs(t.dx)>Math.abs(t.dy)&&Math.abs(t.dx)>6,onPanResponderMove:(e,t)=>{setNativeValue(_,t.dx);const s=1-.7*Math.min(Math.abs(t.dx)/200,1);setNativeValue(R,s)},onPanResponderTerminate:()=>{Animated.parallel([Animated.spring(_,{toValue:0,damping:n.motion.spring.snappy.damping,stiffness:n.motion.spring.snappy.stiffness,mass:n.motion.spring.snappy.mass,useNativeDriver:!0}),Animated.timing(R,{toValue:1,duration:n.motion.duration.fast,useNativeDriver:!0})]).start()},onPanResponderRelease:(t,i)=>{if(Math.abs(i.dx)>g||Math.abs(i.vx)>h){const t=i.dx>=0?1:-1;Animated.parallel([Animated.timing(_,{toValue:500*t,duration:n.motion.duration.fast,useNativeDriver:!0}),Animated.timing(R,{toValue:0,duration:n.motion.duration.fast,useNativeDriver:!0})]).start(()=>{M.current=!0,s(e.id)})}else Animated.parallel([Animated.spring(_,{toValue:0,useNativeDriver:!0}),Animated.spring(R,{toValue:1,useNativeDriver:!0})]).start()}}),[_,R,g,h,n.motion.duration.fast,n.motion.spring.snappy.damping,n.motion.spring.snappy.stiffness,n.motion.spring.snappy.mass,s,e.id]),N=e.description?`${e.message}. ${e.description}`:e.message;return _jsxs(Animated.View,{...v?F.panHandlers:{},accessibilityRole:"alert",accessibilityLiveRegion:"assertive",accessibilityLabel:N,testID:e.testID,style:[a.container,{backgroundColor:n.colors.background.elevated,borderRadius:n.radius.lg,...smoothCorners,padding:n.spacing.md,...n.shadows.md,shadowColor:n.shadows.md.shadowColor,opacity:R,transform:[{translateY:L},{translateX:_},{scale:E}]},e.style,e.containerStyle],children:[f>0?_jsx(View,{style:[a.tintBar,{width:f,backgroundColor:l}]}):null,_jsxs(View,{style:a.row,children:[(()=>{if(e.icon)return e.icon;const t=defaultGlyph(r);return t?_jsx(View,{style:[a.iconCircle,{width:u,height:u,borderRadius:m,...smoothCorners,backgroundColor:l+"22"},e.iconCircleStyle],children:_jsx(Text,{style:[a.iconGlyph,{color:c,fontSize:p}],accessible:!1,children:t})}):null})(),_jsxs(View,{style:a.textBlock,children:[_jsx(Text,{style:[a.message,{color:n.colors.text.primary,fontSize:n.typography.fontSize.base,...fontFor(n,"semibold")},e.textStyle,e.messageStyle],numberOfLines:2,children:e.message}),e.description?_jsx(Text,{style:[a.description,{color:n.colors.text.secondary,fontSize:n.typography.fontSize.sm}],numberOfLines:3,children:e.description}):null]}),e.action?_jsx(Pressable,{accessibilityRole:"button",accessibilityLabel:e.action.label,onPress:()=>{e.action?.onPress(),dismiss()},style:({pressed:t})=>[a.actionBtn,{backgroundColor:t?n.colors.surface.pressed:"transparent"},e.actionButtonStyle],children:_jsx(Text,{style:{color:l,fontSize:n.typography.fontSize.sm,...fontFor(n,"semibold")},numberOfLines:1,children:e.action.label})}):null]})]})},tintFor=(e,t)=>{switch(t){case"success":return e.colors.success;case"error":return e.colors.error;case"warning":return e.colors.warning;case"info":return e.colors.info;default:return e.colors.text.primary}},inkFor=(e,t)=>{switch(t){case"success":return e.colors.toneText.success;case"error":return e.colors.toneText.error;case"warning":return e.colors.toneText.warning;case"info":return e.colors.toneText.info;default:return e.colors.text.primary}},defaultGlyph=e=>{switch(e){case"success":return"✓";case"error":return"×";case"warning":return"!";case"info":return"i";default:return""}},buildStyles=e=>StyleSheet.create({container:{overflow:"hidden",marginVertical:4},tintBar:{position:"absolute",left:0,top:0,bottom:0},row:{flexDirection:"row",alignItems:"center",paddingLeft:8},iconCircle:{alignItems:"center",justifyContent:"center",marginRight:12},iconGlyph:{fontWeight:"700",lineHeight:18},textBlock:{flex:1,paddingRight:8},message:{lineHeight:20},description:{marginTop:2,lineHeight:18},actionBtn:{paddingHorizontal:10,paddingVertical:6,borderRadius:8,...smoothCorners,marginLeft:8}});export{Toast};export default Toast;
1
+ "use strict";import{useCallback,useEffect,useMemo,useRef,useState}from"react";import{Animated,Easing,PanResponder,Platform,Pressable,StyleSheet,Text,View}from"react-native";import{useReducedMotion}from"../../hooks/useReducedMotion.js";import{createAnimatedValue,fontFor,setNativeValue,useTheme}from"../../theme/index.js";import{smoothCorners}from"../../utils/corners.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";const DEFAULT_SWIPE_DISMISS_THRESHOLD=80,DEFAULT_SWIPE_VELOCITY_THRESHOLD=.5,DEFAULT_STACK_OFFSET=8,DEFAULT_STACK_SCALE_STEP=.04,DEFAULT_AUTO_DISMISS_MS=3e3,WEB_ACTION_MIN_DURATION_MS=8e3,COUNTDOWN_BAR_HEIGHT=3,ACTION_HIT_SLOP={top:8,bottom:8,left:8,right:8},DISMISS_ACTIONS=[{name:"dismiss",label:"Dismiss"}],Toast=({toast:e,index:t,onDismiss:n,shownAt:i,runtime:s})=>{const a=useTheme(),o=e.variant??"default",r=e.position??"bottom",l=useMemo(()=>buildStyles(a),[a]),c=useMemo(()=>tintFor(a,o),[a,o]),u=useMemo(()=>inkFor(a,o),[a,o]),d=a.components.toast,m=d?.iconCircleSize??28,p=d?.iconCircleBorderRadius??14,g=d?.iconGlyphFontSize??16,f=d?.tintBarWidth??0,h=d?.swipeDismissThreshold??80,b=d?.swipeVelocityThreshold??.5,S=d?.stackOffset??8,y=d?.stackScaleStep??.04,A=d?.stackMinScale??.9,x=d?.defaultDurationMs??3e3,w=d?.enableSwipeDismiss??!0,v=d?.enterSpringDamping??18,T=d?.enterSpringStiffness??180,M=d?.enterSpringMass??1,_="top"===r?-120:120,D=useRef(createAnimatedValue(_)).current,R=useRef(createAnimatedValue(0)).current,C=useRef(createAnimatedValue(0)).current,V=useRef(!1),E="top"===r?t*S:-t*S,I=Math.max(1-t*y,A),N=useRef(createAnimatedValue(E)).current;useEffect(()=>{setNativeValue(N,E)},[E,N]);const k=useMemo(()=>Animated.add(D,N),[D,N]),j=useReducedMotion(),O=void 0!==e.action,P=e.duration??x,L=P>0&&O&&"web"===Platform.OS?Math.max(P,8e3):P,F=L<=0||O&&!0===s?.screenReaderOn,B=!0===e.countdown&&!F,H=useRef(createAnimatedValue(1)).current,z=useRef({initialised:!1,timer:null,remaining:0,startedAt:0}),U=useRef({touch:!1,pan:!1,hover:!1}),G=useRef(()=>{}),W=useRef({id:e.id,totalMs:L,shownAt:i,runtime:s,persistent:F,animateBar:!1});W.current={id:e.id,totalMs:L,shownAt:i,runtime:s,persistent:F,animateBar:B&&!j};const $=useCallback(()=>{const e=z.current,t=W.current,n=U.current;if(!e.initialised){e.initialised=!0;const n=t.runtime?.readRemaining(t.id),i=void 0===t.shownAt?0:Date.now()-t.shownAt;e.remaining=n??(t.totalMs>0?Math.max(t.totalMs-i,0):0),t.totalMs>0&&e.remaining<t.totalMs&&setNativeValue(H,e.remaining/t.totalMs)}const i=!(t.persistent||V.current||n.touch||n.pan||n.hover);i&&null===e.timer?(e.startedAt=Date.now(),e.timer=setTimeout(()=>{e.timer=null,e.remaining=0,G.current()},e.remaining),t.animateBar&&Animated.timing(H,{toValue:0,duration:e.remaining,easing:Easing.linear,useNativeDriver:!0}).start()):i||null===e.timer||(clearTimeout(e.timer),e.timer=null,e.remaining=Math.max(e.remaining-(Date.now()-e.startedAt),0),H.stopAnimation())},[H]),dismiss=()=>{V.current||(V.current=!0,$(),Animated.parallel([Animated.timing(C,{toValue:0,duration:a.motion.duration.fast,easing:Easing.bezier(...a.motion.easing.accelerate),useNativeDriver:!0}),Animated.timing(D,{toValue:_,duration:a.motion.duration.fast,easing:Easing.bezier(...a.motion.easing.accelerate),useNativeDriver:!0})]).start(()=>n(e.id)))};G.current=dismiss,useEffect(()=>{const e=Animated.parallel([Animated.spring(D,{toValue:0,damping:v,stiffness:T,mass:M,useNativeDriver:!0}),Animated.timing(C,{toValue:1,duration:a.motion.duration.fast,useNativeDriver:!0})]);return e.start(),()=>e.stop()},[]),useEffect(()=>{$()},[F,$]),useEffect(()=>()=>{const e=z.current,t=W.current;null!==e.timer&&(clearTimeout(e.timer),e.timer=null,e.remaining=Math.max(e.remaining-(Date.now()-e.startedAt),0)),H.stopAnimation(),e.initialised&&t.totalMs>0&&!V.current&&t.runtime?.writeRemaining(t.id,e.remaining)},[H]);const K=useCallback((e,t)=>{U.current[e]=t,$()},[$]),X=useCallback(()=>K("touch",!0),[K]),Y=useCallback(e=>K("touch",(e.nativeEvent.touches?.length??0)>0),[K]),q=useCallback(()=>K("hover",!0),[K]),J=useCallback(()=>K("hover",!1),[K]),Q=useMemo(()=>PanResponder.create({onMoveShouldSetPanResponder:(e,t)=>Math.abs(t.dx)>Math.abs(t.dy)&&Math.abs(t.dx)>6,onPanResponderGrant:()=>K("pan",!0),onPanResponderMove:(e,t)=>{setNativeValue(R,t.dx);const n=1-.7*Math.min(Math.abs(t.dx)/200,1);setNativeValue(C,n)},onPanResponderTerminate:()=>{K("pan",!1),Animated.parallel([Animated.spring(R,{toValue:0,damping:a.motion.spring.snappy.damping,stiffness:a.motion.spring.snappy.stiffness,mass:a.motion.spring.snappy.mass,useNativeDriver:!0}),Animated.timing(C,{toValue:1,duration:a.motion.duration.fast,useNativeDriver:!0})]).start()},onPanResponderRelease:(t,i)=>{if(Math.abs(i.dx)>h||Math.abs(i.vx)>b){const t=i.dx>=0?1:-1;V.current=!0,K("pan",!1),Animated.parallel([Animated.timing(R,{toValue:500*t,duration:a.motion.duration.fast,useNativeDriver:!0}),Animated.timing(C,{toValue:0,duration:a.motion.duration.fast,useNativeDriver:!0})]).start(()=>n(e.id))}else K("pan",!1),Animated.parallel([Animated.spring(R,{toValue:0,useNativeDriver:!0}),Animated.spring(C,{toValue:1,useNativeDriver:!0})]).start()}}),[R,C,K,h,b,a.motion.duration.fast,a.motion.spring.snappy.damping,a.motion.spring.snappy.stiffness,a.motion.spring.snappy.mass,n,e.id]),Z={accessibilityActions:DISMISS_ACTIONS,onAccessibilityAction:e=>{"dismiss"===e.nativeEvent.actionName&&dismiss()}},[ee,te]=useState(0),ne=useMemo(()=>H.interpolate({inputRange:[0,1],outputRange:[-ee,0]}),[H,ee]),ie=e.description?`${e.message}. ${e.description}`:e.message,se=e.action&&B?`${e.action.label}, ${Math.ceil(L/1e3)} seconds`:e.action?.label;return _jsxs(Animated.View,{...w?Q.panHandlers:{},...O?{}:{accessible:!0,...Z},..."web"===Platform.OS?{onPointerEnter:q,onPointerLeave:J}:{},onTouchStart:X,onTouchEnd:Y,onTouchCancel:Y,accessibilityLabel:ie,testID:e.testID,style:[l.container,{backgroundColor:a.colors.background.elevated,borderRadius:a.radius.lg,...smoothCorners,padding:a.spacing.md,...a.shadows.md,shadowColor:a.shadows.md.shadowColor,opacity:C,transform:[{translateY:k},{translateX:R},{scale:I}]},e.style,e.containerStyle],children:[f>0?_jsx(View,{style:[l.tintBar,{width:f,backgroundColor:c}]}):null,_jsxs(View,{style:l.row,children:[(()=>{if(e.icon)return e.icon;const t=defaultGlyph(o);return t?_jsx(View,{style:[l.iconCircle,{width:m,height:m,borderRadius:p,...smoothCorners,backgroundColor:c+"22"},e.iconCircleStyle],children:_jsx(Text,{style:[l.iconGlyph,{color:u,fontSize:g}],accessible:!1,children:t})}):null})(),_jsxs(View,{style:l.textBlock,children:[_jsx(Text,{style:[l.message,{color:a.colors.text.primary,fontSize:a.typography.fontSize.base,...fontFor(a,"semibold")},e.textStyle,e.messageStyle],numberOfLines:2,children:e.message}),e.description?_jsx(Text,{style:[l.description,{color:a.colors.text.secondary,fontSize:a.typography.fontSize.sm}],numberOfLines:3,children:e.description}):null]}),e.action?_jsx(Pressable,{accessibilityRole:"button",accessibilityLabel:se,hitSlop:ACTION_HIT_SLOP,...Z,onPress:()=>{e.action?.onPress(),dismiss()},style:({pressed:t})=>[l.actionBtn,{backgroundColor:t?a.colors.surface.pressed:"transparent"},e.actionButtonStyle],children:_jsx(Text,{style:{color:c,fontSize:a.typography.fontSize.sm,...fontFor(a,"semibold")},numberOfLines:1,children:e.action.label})}):null]}),B?_jsxs(View,{pointerEvents:"none",accessibilityElementsHidden:!0,importantForAccessibility:"no-hide-descendants",onLayout:e=>te(e.nativeEvent.layout.width),testID:"toast-countdown",style:[l.countdownTrack,{backgroundColor:c+"22"}],children:[j?_jsx(View,{style:[l.countdownFill,{backgroundColor:c}]}):null,!j&&ee>0?_jsx(Animated.View,{style:[l.countdownFill,{backgroundColor:c,transform:[{translateX:ne}]}]}):null]}):null]})},tintFor=(e,t)=>{switch(t){case"success":return e.colors.success;case"error":return e.colors.error;case"warning":return e.colors.warning;case"info":return e.colors.info;default:return e.colors.text.primary}},inkFor=(e,t)=>{switch(t){case"success":return e.colors.toneText.success;case"error":return e.colors.toneText.error;case"warning":return e.colors.toneText.warning;case"info":return e.colors.toneText.info;default:return e.colors.text.primary}},defaultGlyph=e=>{switch(e){case"success":return"✓";case"error":return"×";case"warning":return"!";case"info":return"i";default:return""}},buildStyles=e=>StyleSheet.create({container:{overflow:"hidden",marginVertical:4},tintBar:{position:"absolute",left:0,top:0,bottom:0},row:{flexDirection:"row",alignItems:"center",paddingLeft:8},iconCircle:{alignItems:"center",justifyContent:"center",marginRight:12},iconGlyph:{fontWeight:"700",lineHeight:18},textBlock:{flex:1,paddingRight:8},message:{lineHeight:20},description:{marginTop:2,lineHeight:18},countdownTrack:{position:"absolute",left:0,right:0,bottom:0,height:3,overflow:"hidden"},countdownFill:{position:"absolute",left:0,right:0,top:0,bottom:0},actionBtn:{paddingHorizontal:10,paddingVertical:6,borderRadius:8,...smoothCorners,marginLeft:8}});export{Toast};export default Toast;
@@ -1 +1 @@
1
- "use strict";import{createContext,useCallback,useContext,useEffect,useMemo,useRef,useState}from"react";import{StyleSheet,View}from"react-native";import{useSafeAreaInsets}from"react-native-safe-area-context";import{useTheme}from"../../theme/index.js";import{triggerHaptic}from"../../utils/hapticUtils.js";import Toast from"./Toast.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";const MAX_VISIBLE=3,ToastContext=createContext(null),ToastHostContext=createContext(null);let nextId=0;const makeId=()=>(nextId+=1,`toast-${Date.now().toString(36)}-${nextId.toString(36)}`),defaultHaptic=t=>{switch(t){case"error":return"notificationError";case"success":return"notificationSuccess";case"warning":return"notificationWarning";default:return"selection"}},resolveHaptics=(t,e)=>{if(!1===t)return!1;const o=t?.[e??"default"];return void 0===o?defaultHaptic(e):o};let nextHostId=0;const makeHostId=()=>(nextHostId+=1,nextHostId);let providerCount=0,activeApi=null;const setActiveApi=t=>{activeApi=t},getActiveApi=()=>activeApi;export const ToastProvider=({children:t,maxVisible:e=3,topOffset:o,bottomOffset:s,defaultDuration:r,haptics:n})=>{const a=useRef({defaultDuration:r,haptics:n});a.current={defaultDuration:r,haptics:n};const[i,u]=useState([]),[c,l]=useState([]),d=useCallback(t=>{u(e=>e.filter(e=>e.id!==t))},[]),p=useCallback(()=>{u([])},[]),f=useCallback(t=>{const o=makeId(),{defaultDuration:s,haptics:r}=a.current,n={...t,duration:t.duration??s,id:o,shownAt:Date.now()},i=void 0!==t.haptic?t.haptic:resolveHaptics(r,t.variant);return!1!==i&&triggerHaptic(i),u(t=>{const o=[...t,n];return o.length>e?o.slice(o.length-e):o}),o},[e]),m=useMemo(()=>({show:f,hide:d,hideAll:p}),[f,d,p]);useEffect(()=>(providerCount+=1,setActiveApi(m),()=>{providerCount-=1,providerCount<=0&&(providerCount=0,setActiveApi(null))}),[m]);const h=useCallback(t=>{l(e=>[...e,t])},[]),x=useCallback(t=>{l(e=>e.filter(e=>e!==t))},[]),v=c.length>0?c[c.length-1]:null,g=useMemo(()=>({register:h,unregister:x,activeHostId:v,queue:i,hide:d,topOffset:o,bottomOffset:s}),[h,x,v,i,d,o,s]);return _jsx(ToastContext.Provider,{value:m,children:_jsxs(ToastHostContext.Provider,{value:g,children:[t,null===v?_jsx(ToastLayers,{queue:i,onDismiss:d,topOffset:o,bottomOffset:s}):null]})})};let warnedHost=!1;const warnHostWithoutProvider=()=>{warnedHost||(warnedHost=!0,"undefined"!=typeof __DEV__&&__DEV__&&console.warn("[toast] <ToastHost /> rendered outside a <ToastProvider />; it renders nothing. Mount a provider near your app root."))};export const ToastHost=()=>{const t=useContext(ToastHostContext),[e]=useState(makeHostId),o=t?.register,s=t?.unregister;return useEffect(()=>{if(o&&s)return o(e),()=>s(e);warnHostWithoutProvider()},[o,s,e]),t&&t.activeHostId===e?_jsx(ToastLayers,{queue:t.queue,onDismiss:t.hide,topOffset:t.topOffset,bottomOffset:t.bottomOffset}):null};const ToastLayers=({queue:t,onDismiss:e,topOffset:o,bottomOffset:s})=>{const r=useTheme(),n=useSafeAreaInsets(),a=useMemo(()=>buildStyles(),[]),i=t.filter(t=>"top"===(t.position??"bottom")),u=t.filter(t=>"bottom"===(t.position??"bottom"));return _jsxs(_Fragment,{children:[_jsx(View,{testID:"toast-layer-top",pointerEvents:"box-none",style:[a.layer,a.top,{top:(o??n.top)+r.spacing.sm,paddingHorizontal:r.spacing.md}],children:i.map((t,o)=>_jsx(Toast,{toast:t,index:i.length-1-o,shownAt:t.shownAt,onDismiss:e},t.id))}),_jsx(View,{testID:"toast-layer-bottom",pointerEvents:"box-none",style:[a.layer,a.bottom,{bottom:(s??n.bottom)+r.spacing.sm,paddingHorizontal:r.spacing.md}],children:u.map((t,o)=>_jsx(Toast,{toast:t,index:u.length-1-o,shownAt:t.shownAt,onDismiss:e},t.id))})]})};export const useToast=()=>{const t=useContext(ToastContext);if(!t)throw new Error("useToast must be used within a <ToastProvider>.");return t};let warned=!1;const warnNoProvider=()=>{warned||(warned=!0,"undefined"!=typeof __DEV__&&__DEV__&&console.warn("[toast] No <ToastProvider /> mounted; toast() calls are no-ops. Mount a provider near your app root."))},proxy=t=>{const e=getActiveApi();return e?t(e):(warnNoProvider(),"")};export const toast={show:t=>proxy(e=>e.show(t)),success:(t,e)=>proxy(o=>o.show({...e,message:t,variant:"success"})),error:(t,e)=>proxy(o=>o.show({...e,message:t,variant:"error"})),warning:(t,e)=>proxy(o=>o.show({...e,message:t,variant:"warning"})),info:(t,e)=>proxy(o=>o.show({...e,message:t,variant:"info"})),hideAll:()=>{const t=getActiveApi();t?t.hideAll():warnNoProvider()}};const buildStyles=()=>StyleSheet.create({layer:{position:"absolute",left:0,right:0},top:{alignItems:"stretch"},bottom:{alignItems:"stretch"}});
1
+ "use strict";import{createContext,useCallback,useContext,useEffect,useMemo,useRef,useState}from"react";import{AccessibilityInfo,Platform,StyleSheet,View}from"react-native";import{useSafeAreaInsets}from"react-native-safe-area-context";import{useTheme}from"../../theme/index.js";import{announce}from"../../utils/announce.js";import{triggerHaptic}from"../../utils/hapticUtils.js";import Toast from"./Toast.js";import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";const MAX_VISIBLE=3,UNDO_DEFAULT_DURATION_MS=6e3,UNDO_MIN_DURATION_MS=6e3,ToastContext=createContext(null),ToastHostContext=createContext(null);let nextId=0;const makeId=()=>(nextId+=1,`toast-${Date.now().toString(36)}-${nextId.toString(36)}`),defaultHaptic=e=>{switch(e){case"error":return"notificationError";case"success":return"notificationSuccess";case"warning":return"notificationWarning";default:return"selection"}},resolveHaptics=(e,t)=>{if(!1===e)return!1;const o=e?.[t??"default"];return void 0===o?defaultHaptic(t):o};let nextHostId=0;const makeHostId=()=>(nextHostId+=1,nextHostId),useScreenReaderEnabled=()=>{const[e,t]=useState(!1);return useEffect(()=>{if("web"===Platform.OS)return;let e=!0;AccessibilityInfo.isScreenReaderEnabled().then(o=>{e&&t(o)});const o=AccessibilityInfo.addEventListener("screenReaderChanged",t);return()=>{e=!1,o.remove()}},[]),e};let providerCount=0,activeApi=null;const setActiveApi=e=>{activeApi=e},getActiveApi=()=>activeApi;export const ToastProvider=({children:e,maxVisible:t=3,topOffset:o,bottomOffset:s,defaultDuration:r,haptics:n})=>{const a=useRef({defaultDuration:r,haptics:n});a.current={defaultDuration:r,haptics:n};const[i,u]=useState([]),[c,d]=useState([]),l=useScreenReaderEnabled(),f=useRef(new Map),p=useRef(new Map);useEffect(()=>{const e=new Set(i.map(e=>e.id));for(const[t,o]of[...f.current])e.has(t)||(f.current.delete(t),o());for(const t of[...p.current.keys()])e.has(t)||p.current.delete(t)},[i]),useEffect(()=>{const e=f.current;return()=>{for(const[t,o]of[...e])e.delete(t),o()}},[]);const m=useMemo(()=>({screenReaderOn:l,readRemaining:e=>p.current.get(e),writeRemaining:(e,t)=>{p.current.set(e,t)}}),[l]),h=useCallback(e=>{u(t=>t.filter(t=>t.id!==e))},[]),x=useCallback(()=>{u([])},[]),v=useCallback(e=>{const o=makeId(),{defaultDuration:s,haptics:r}=a.current,n={...e,duration:e.duration??s,id:o,shownAt:Date.now()},i=void 0!==e.haptic?e.haptic:resolveHaptics(r,e.variant);return!1!==i&&triggerHaptic(i),announce(e.description?`${e.message}. ${e.description}`:e.message,{polite:"error"!==e.variant}),u(o=>{const s=[...void 0===e.key?o:o.filter(t=>t.key!==e.key),n];return s.length>t?s.slice(s.length-t):s}),o},[t]),g=useCallback((e,t)=>{const{onUndo:o,onCommit:s,undoLabel:r,duration:n,...a}=t,i={id:""},u=v({...a,message:e,duration:0===n?0:Math.max(n??6e3,6e3),countdown:!0,action:{label:r??"Undo",onPress:()=>{f.current.delete(i.id),o()}}});return i.id=u,s&&f.current.set(u,s),u},[v]),w=useMemo(()=>({show:v,undo:g,hide:h,hideAll:x}),[v,g,h,x]);useEffect(()=>(providerCount+=1,setActiveApi(w),()=>{providerCount-=1,providerCount<=0&&(providerCount=0,setActiveApi(null))}),[w]);const b=useCallback(e=>{d(t=>[...t,e])},[]),_=useCallback(e=>{d(t=>t.filter(t=>t!==e))},[]),y=c.length>0?c[c.length-1]:null,A=useMemo(()=>({register:b,unregister:_,activeHostId:y,queue:i,hide:h,topOffset:o,bottomOffset:s,runtime:m}),[b,_,y,i,h,o,s,m]);return _jsx(ToastContext.Provider,{value:w,children:_jsxs(ToastHostContext.Provider,{value:A,children:[e,null===y?_jsx(ToastLayers,{queue:i,onDismiss:h,topOffset:o,bottomOffset:s,runtime:m}):null]})})};let warnedHost=!1;const warnHostWithoutProvider=()=>{warnedHost||(warnedHost=!0,"undefined"!=typeof __DEV__&&__DEV__&&console.warn("[toast] <ToastHost /> rendered outside a <ToastProvider />; it renders nothing. Mount a provider near your app root."))};export const ToastHost=()=>{const e=useContext(ToastHostContext),[t]=useState(makeHostId),o=e?.register,s=e?.unregister;return useEffect(()=>{if(o&&s)return o(t),()=>s(t);warnHostWithoutProvider()},[o,s,t]),e&&e.activeHostId===t?_jsx(ToastLayers,{queue:e.queue,onDismiss:e.hide,topOffset:e.topOffset,bottomOffset:e.bottomOffset,runtime:e.runtime}):null};const ToastLayers=({queue:e,onDismiss:t,topOffset:o,bottomOffset:s,runtime:r})=>{const n=useTheme(),a=useSafeAreaInsets(),i=useMemo(()=>buildStyles(),[]),u=e.filter(e=>"top"===(e.position??"bottom")),c=e.filter(e=>"bottom"===(e.position??"bottom"));return _jsxs(_Fragment,{children:[_jsx(View,{testID:"toast-layer-top",pointerEvents:"box-none",style:[i.layer,i.top,{top:(o??a.top)+n.spacing.sm,paddingHorizontal:n.spacing.md}],children:u.map((e,o)=>_jsx(Toast,{toast:e,index:u.length-1-o,shownAt:e.shownAt,runtime:r,onDismiss:t},e.id))}),_jsx(View,{testID:"toast-layer-bottom",pointerEvents:"box-none",style:[i.layer,i.bottom,{bottom:(s??a.bottom)+n.spacing.sm,paddingHorizontal:n.spacing.md}],children:c.map((e,o)=>_jsx(Toast,{toast:e,index:c.length-1-o,shownAt:e.shownAt,runtime:r,onDismiss:t},e.id))})]})};export const useToast=()=>{const e=useContext(ToastContext);if(!e)throw new Error("useToast must be used within a <ToastProvider>.");return e};let warned=!1;const warnNoProvider=()=>{warned||(warned=!0,"undefined"!=typeof __DEV__&&__DEV__&&console.warn("[toast] No <ToastProvider /> mounted; toast() calls are no-ops. Mount a provider near your app root."))},proxy=e=>{const t=getActiveApi();return t?e(t):(warnNoProvider(),"")};export const toast={show:e=>proxy(t=>t.show(e)),undo:(e,t)=>proxy(o=>o.undo(e,t)),success:(e,t)=>proxy(o=>o.show({...t,message:e,variant:"success"})),error:(e,t)=>proxy(o=>o.show({...t,message:e,variant:"error"})),warning:(e,t)=>proxy(o=>o.show({...t,message:e,variant:"warning"})),info:(e,t)=>proxy(o=>o.show({...t,message:e,variant:"info"})),hideAll:()=>{const e=getActiveApi();e?e.hideAll():warnNoProvider()}};const buildStyles=()=>StyleSheet.create({layer:{position:"absolute",left:0,right:0},top:{alignItems:"stretch"},bottom:{alignItems:"stretch"}});
@@ -0,0 +1 @@
1
+ "use strict";import{useMemo}from"react";import{StyleSheet,View}from"react-native";import{useTheme}from"../../theme/index.js";import{smoothCorners}from"../../utils/corners.js";import{Button}from"../Button/index.js";import{Text}from"../Text/index.js";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";export const RichTooltipBody=({title:e,content:t,action:s,onAction:o,focusRef:i,actionRef:r,messageStyle:n})=>{const a=useTheme(),l=useMemo(()=>buildStyles(a),[a]);return _jsxs(View,{style:l.card,children:[e?_jsx(Text,{ref:i,variant:"label",weight:"semibold",accessibilityRole:"header",children:e}):null,"string"==typeof t?_jsx(Text,{ref:e?void 0:i,variant:"bodySmall",color:"secondary",style:n,children:t}):t,s?_jsx(View,{style:l.actions,children:_jsx(Button,{ref:r,title:s.label,variant:"ghost",size:"sm",accessibilityLabel:s.accessibilityLabel,onPress:o})}):null]})};const buildStyles=e=>StyleSheet.create({card:{gap:e.spacing.xs,paddingHorizontal:e.spacing.md,paddingTop:e.spacing.md,paddingBottom:e.spacing.sm,backgroundColor:e.colors.background.elevated,borderRadius:e.radius.md,...smoothCorners,...e.shadows.lg},actions:{flexDirection:"row",justifyContent:"flex-end",marginTop:e.spacing.xs}});